aoe  87
About: AoE (ATA over Ethernet) Protocol Driver (Linux kernel 4.8.x and greater are not supported).
  Fossies Dox: aoe-87.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

aoe.h
Go to the documentation of this file.
1 /* Copyright (c) 2013 Coraid, Inc. See COPYING for GPL terms. */
2 #define VERSION "87"
3 #define AOE_MAJOR 152
4 #define DEVICE_NAME "aoe"
5 #define DEVICE_SUBDIR "etherd"
6 
7 /* AOE_PARTITIONS and DEVSUBDIR are set in the Makefile */
8 
9 #define WHITESPACE " \t\v\f\n,"
10 /* for compatibility, so that this driver builds for kernels with
11  * or without AoE already in them
12  */
13 #ifndef ETH_P_AOE
14 #define ETH_P_AOE 0x88a2
15 #endif
16 
17 enum {
21 
22  AOEFL_RSP = (1<<3),
23  AOEFL_ERR = (1<<2),
24 
25  AOEAFL_EXT = (1<<6),
26  AOEAFL_DEV = (1<<4),
27  AOEAFL_ASYNC = (1<<1),
28  AOEAFL_WRITE = (1<<0),
29 
35 
36  AOE_HVER = 0x10,
37 };
38 
39 struct aoe_hdr {
40  unsigned char dst[6];
41  unsigned char src[6];
43  unsigned char verfl;
44  unsigned char err;
46  unsigned char minor;
47  unsigned char cmd;
49 };
50 
51 struct aoe_atahdr {
52  unsigned char aflags;
53  unsigned char errfeat;
54  unsigned char scnt;
55  unsigned char cmdstat;
56  unsigned char lba0;
57  unsigned char lba1;
58  unsigned char lba2;
59  unsigned char lba3;
60  unsigned char lba4;
61  unsigned char lba5;
62  unsigned char res[2];
63 };
64 
65 struct aoe_cfghdr {
68  unsigned char scnt;
69  unsigned char aoeccmd;
70  unsigned char cslen[2];
71 };
72 
73 enum {
74  DEVFL_UP = 1, /* device is installed in system and ready for AoE->ATA commands */
75  DEVFL_TKILL = (1<<1), /* flag for timer to know when to kill self */
76  DEVFL_EXT = (1<<2), /* device accepts lba48 commands */
77  DEVFL_GDALLOC = (1<<3), /* need to alloc gendisk */
78  DEVFL_GD_NOW = (1<<4), /* allocating gendisk */
79  DEVFL_KICKME = (1<<5), /* slow polling network card catch */
80  DEVFL_NEWSIZE = (1<<6), /* need to update dev size in block layer */
81  DEVFL_FREEING = (1<<7), /* set when device is being cleaned up */
82  DEVFL_FREED = (1<<8), /* device has been cleaned up */
83 };
84 
85 enum {
86  DEFAULTBCNT = 2 * 512, /* 2 sectors */
87  MIN_BUFS = 16,
88  NTARGETS = 4,
89  NAOEIFS = 8,
90  NSKBPOOLMAX = 256,
91  NFACTIVE = 61,
92 
93  TIMERTICK = HZ / 10,
94  RTTSCALE = 8,
95  RTTDSCALE = 3,
96  RTTAVG_INIT = USEC_PER_SEC / 4 << RTTSCALE,
98 
99  HARD_SCORN_SECS = 10, /* try another remote port after this */
100  MAX_TAINT = 1000, /* cap on aoetgt taint */
101 };
102 
103 struct buf {
105  struct bio *bio;
106  struct bvec_iter iter;
107  struct request *rq;
108 };
109 
112 };
113 
114 struct frame {
115  struct list_head head;
117  struct timeval sent; /* high-res time packet was sent */
118  u32 sent_jiffs; /* low-res jiffies-based sent time */
121  struct aoetgt *t; /* parent target I belong to */
122  struct sk_buff *skb; /* command skb freed on module exit */
123  struct sk_buff *r_skb; /* response skb for async processing */
124  struct buf *buf;
125  struct bvec_iter iter;
126  ushort nout; /* value of nout when skb was sent */
127  char flags;
128 };
129 
130 struct aoeif {
131  struct net_device *nd;
133  int bcnt;
134 };
135 
136 struct aoetgt {
137  unsigned char addr[6];
138  ushort nframes; /* cap on frames to use */
139  struct aoedev *d; /* parent device I belong to */
140  struct list_head ffree; /* list of free frames */
141  struct aoeif ifs[NAOEIFS];
142  struct aoeif *ifp; /* current aoeif in use */
143  ushort nout; /* number of AoE commands outstanding */
144  ushort maxout; /* current value for max outstanding */
145  ushort next_cwnd; /* incr maxout after decrementing to zero */
146  ushort ssthresh; /* slow start threshold */
147  ulong falloc; /* number of allocated frames */
148  ulong lost; /* AoE commands w/o response */
149  int taint; /* how much we want to avoid this aoetgt */
150  int minbcnt;
151  int wpkts, rpkts;
153 };
154 
155 struct aoedev {
156  struct aoedev *next;
159  u32 rttavg; /* scaled AoE round trip time average */
160  u32 rttdev; /* scaled round trip time mean deviation */
163  u16 nopen; /* (bd_openers isn't available without sleeping) */
164  u16 fw_ver; /* version of blade's firmware */
165  u16 lasttag; /* last tag sent */
168  struct work_struct work;/* disk create work struct */
169  struct gendisk *gd;
170  struct dentry *debugfs;
171  struct request_queue *blkq;
172  struct hd_geometry geo;
173  sector_t ssize;
174  struct timer_list timer;
175  spinlock_t lock;
176  struct sk_buff *skbpool_hd;
177  struct sk_buff *skbpool_tl;
178  int nskbpool;
179  mempool_t *bufpool; /* for deadlock-free Buf allocation */
180  struct { /* pointers to work in progress */
181  struct buf *buf;
182  struct bio *nxbio;
183  struct request *rq;
184  } ip;
186  struct list_head factive[NFACTIVE]; /* hash of active frames */
187  struct list_head rexmitq; /* deferred retransmissions */
188  struct aoetgt **targets;
189  ulong ntargets; /* number of allocated aoetgt pointers */
190  struct aoetgt **tgt; /* target in use when working */
192  void *dbg; /* opaque handle for aoedbg */
193  char ident[512];
194 };
195 
196 /* kthread tracking */
197 struct ktstate {
198  struct completion rendez;
199  struct task_struct *task;
200  wait_queue_head_t *waitq;
201  int (*fn) (int);
202  char name[12];
203  spinlock_t *lock;
204  int id;
205  int active;
206 };
207 
208 int aoeblk_init(void);
209 void aoeblk_exit(void);
210 void aoeblk_gdalloc(void *);
211 void aoedisk_rm_debugfs(struct aoedev *d);
212 void aoedisk_rm_sysfs(struct aoedev *d);
213 void aoe_bio_pagedec(struct bio *);
214 
215 int aoechr_init(void);
216 void aoechr_exit(void);
217 void aoechr_error(char *);
218 
219 void aoecmd_work(struct aoedev *d);
220 void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor);
221 struct sk_buff *aoecmd_ata_rsp(struct sk_buff *);
222 void aoecmd_cfg_rsp(struct sk_buff *);
223 void aoecmd_sleepwork(struct work_struct *);
224 void aoecmd_wreset(struct aoetgt *t);
225 void aoecmd_cleanslate(struct aoedev *);
226 void aoecmd_exit(void);
227 int aoecmd_init(void);
228 struct sk_buff *aoecmd_ata_id(struct aoedev *);
229 void aoe_freetframe(struct frame *);
230 void aoe_bio_pagedec(struct bio *);
231 void aoe_bio_pageinc(struct bio *);
232 void aoe_flush_iocq(void);
233 void aoe_flush_iocq_by_index(int);
234 void aoe_end_request(struct aoedev *, struct request *, int);
235 int aoe_ktstart(struct ktstate *k);
236 void aoe_ktstop(struct ktstate *k);
237 
238 int aoedev_init(void);
239 void aoedev_exit(void);
240 struct aoedev *aoedev_by_aoeaddr(ulong maj, int min, int do_alloc);
241 void aoedev_downdev(struct aoedev *d);
242 int aoedev_flush(const char __user *str, size_t size);
243 void aoe_failbuf(struct aoedev *, struct buf *);
244 void aoedev_put(struct aoedev *);
245 
246 int aoenet_init(void);
247 void aoenet_exit(void);
248 void aoenet_xmit(struct sk_buff *);
249 int is_aoe_netif(struct net_device *ifp);
250 int set_aoe_iflist(const char __user *str, size_t size);
251 
252 unsigned long long mac_addr(char addr[6]);
253 
254 /* for compatibility with older 2.6 kernels lacking kcalloc
255  */
256 extern void *aoe_kcalloc(size_t, size_t, int);
257 
258 #define AOEDBG_ACTIVE 0
259 void __init aoedbg_init(void);
260 void aoedbg_print(char *fmt, ...);
261 void aoedbg_rtt(struct aoedev *d, struct aoe_hdr *h, struct frame *f, int rtt);
262 void aoedbg_devinit(struct aoedev *d);
263 void aoedbg_undbg(struct aoedev *d);
264 void aoedbg_exit(void);
aoe_atahdr::lba3
unsigned char lba3
Definition: aoe.h:59
aoecmd_sleepwork
void aoecmd_sleepwork(struct work_struct *)
Definition: aoecmd.c:966
aoedbg_exit
void aoedbg_exit(void)
Definition: aoedbg.c:268
ktstate::name
char name[12]
Definition: aoe.h:202
aoedev::ref
ulong ref
Definition: aoe.h:167
aoedev::skbpool_hd
struct sk_buff * skbpool_hd
Definition: aoe.h:176
aoe_hdr::src
unsigned char src[6]
Definition: aoe.h:41
aoe_atahdr::aflags
unsigned char aflags
Definition: aoe.h:52
aoe_atahdr::lba5
unsigned char lba5
Definition: aoe.h:61
buf::rq
struct request * rq
Definition: aoe.h:107
aoedev::nxbio
struct bio * nxbio
Definition: aoe.h:182
frame::nout
ushort nout
Definition: aoe.h:126
aoedev::work
struct work_struct work
Definition: aoe.h:168
DEFAULTBCNT
Definition: aoe.h:86
aoe_flush_iocq_by_index
void aoe_flush_iocq_by_index(int)
Definition: aoecmd.c:1740
aoe_cfghdr
Definition: aoe.h:65
aoedev::rttdev
u32 rttdev
Definition: aoe.h:160
NTARGETS
Definition: aoe.h:88
aoedev::kicked
ulong kicked
Definition: aoe.h:191
aoetgt::nout
ushort nout
Definition: aoe.h:143
u32
uint32_t u32
Definition: dat.h:20
RTTDEV_INIT
Definition: aoe.h:97
aoe_kcalloc
void * aoe_kcalloc(size_t, size_t, int)
Definition: aoemain.c:32
aoedev::skbpool_tl
struct sk_buff * skbpool_tl
Definition: aoe.h:177
aoedbg_print
void aoedbg_print(char *fmt,...)
Definition: aoedbg.c:107
aoetgt::minbcnt
int minbcnt
Definition: aoe.h:150
AOEFL_ERR
Definition: aoe.h:23
aoetgt::falloc
ulong falloc
Definition: aoe.h:147
aoe_freetframe
void aoe_freetframe(struct frame *)
Definition: aoecmd.c:205
DEVFL_FREED
Definition: aoe.h:82
buf::bio
struct bio * bio
Definition: aoe.h:105
aoe_atahdr::lba0
unsigned char lba0
Definition: aoe.h:56
aoetgt::ssthresh
ushort ssthresh
Definition: aoe.h:146
aoe_bio_pagedec
void aoe_bio_pagedec(struct bio *)
Definition: aoeblk.c:31
aoe_hdr::dst
unsigned char dst[6]
Definition: aoe.h:40
AOECCMD_SET
Definition: aoe.h:33
aoeif::bcnt
int bcnt
Definition: aoe.h:133
aoedev::geo
struct hd_geometry geo
Definition: aoe.h:172
aoe_atahdr::lba1
unsigned char lba1
Definition: aoe.h:57
aoechr_exit
void aoechr_exit(void)
Definition: aoechr.c:297
AOECCMD_READ
Definition: aoe.h:30
aoetgt::ifp
struct aoeif * ifp
Definition: aoe.h:142
frame::skb
struct sk_buff * skb
Definition: aoe.h:122
aoenet_init
int aoenet_init(void)
Definition: aoenet.c:244
aoedev::blkq
struct request_queue * blkq
Definition: aoe.h:171
frame::buf
struct buf * buf
Definition: aoe.h:124
frame::waited_total
ulong waited_total
Definition: aoe.h:120
aoedbg_init
void __init aoedbg_init(void)
Definition: aoedbg.c:80
aoedev::useme
u16 useme
Definition: aoe.h:166
ktstate
Definition: aoe.h:197
ktstate::rendez
struct completion rendez
Definition: aoe.h:198
frame
Definition: aoe.h:114
AOECMD_VEND_MIN
Definition: aoe.h:20
is_aoe_netif
int is_aoe_netif(struct net_device *ifp)
Definition: aoenet.c:108
aoedev::buf
struct buf * buf
Definition: aoe.h:181
aoenet_xmit
void aoenet_xmit(struct sk_buff *)
Definition: aoenet.c:159
aoecmd_cleanslate
void aoecmd_cleanslate(struct aoedev *)
Definition: aoecmd.c:1703
aoecmd_ata_rsp
struct sk_buff * aoecmd_ata_rsp(struct sk_buff *)
Definition: aoecmd.c:1385
aoedev::timer
struct timer_list timer
Definition: aoe.h:174
ktstate::waitq
wait_queue_head_t * waitq
Definition: aoe.h:200
frame_flags
frame_flags
Definition: aoe.h:110
aoe_bio_pageinc
void aoe_bio_pageinc(struct bio *)
aoe_cfghdr::cslen
unsigned char cslen[2]
Definition: aoe.h:70
aoetgt::taint
int taint
Definition: aoe.h:149
aoedev_flush
int aoedev_flush(const char __user *str, size_t size)
Definition: aoedev.c:394
aoecmd_work
void aoecmd_work(struct aoedev *d)
Definition: aoecmd.c:956
aoeif::nd
struct net_device * nd
Definition: aoe.h:131
ktstate::id
int id
Definition: aoe.h:204
aoetgt
Definition: aoe.h:136
DEVFL_UP
Definition: aoe.h:74
aoedev::flags
u16 flags
Definition: aoe.h:162
aoeif::lost
ulong lost
Definition: aoe.h:132
aoedev::factive
struct list_head factive[NFACTIVE]
Definition: aoe.h:186
aoedev::rq
struct request * rq
Definition: aoe.h:183
AOEAFL_ASYNC
Definition: aoe.h:27
aoetgt::lost
ulong lost
Definition: aoe.h:148
AOEFL_RSP
Definition: aoe.h:22
aoedev::lock
spinlock_t lock
Definition: aoe.h:175
int
int
Definition: dummy.c:1
frame::iter
struct bvec_iter iter
Definition: aoe.h:125
aoe_cfghdr::bufcnt
u16 bufcnt
Definition: aoe.h:66
aoedev::sysminor
ulong sysminor
Definition: aoe.h:157
aoecmd_cfg
void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor)
Definition: aoecmd.c:1454
aoedev::dbg
void * dbg
Definition: aoe.h:192
aoe_atahdr::lba2
unsigned char lba2
Definition: aoe.h:58
buf
Definition: aoe.h:103
aoedev::ssize
sector_t ssize
Definition: aoe.h:173
aoedev_by_aoeaddr
struct aoedev * aoedev_by_aoeaddr(ulong maj, int min, int do_alloc)
Definition: aoedev.c:442
aoe_hdr::type
u16 type
Definition: aoe.h:42
RTTDSCALE
Definition: aoe.h:95
HARD_SCORN_SECS
Definition: aoe.h:99
aoedev
Definition: aoe.h:155
MIN_BUFS
Definition: aoe.h:87
frame::flags
char flags
Definition: aoe.h:127
aoe_failbuf
void aoe_failbuf(struct aoedev *, struct buf *)
Definition: aoecmd.c:1718
aoeblk_init
int aoeblk_init(void)
Definition: aoeblk.c:452
aoechr_error
void aoechr_error(char *)
Definition: aoechr.c:120
aoeblk_gdalloc
void aoeblk_gdalloc(void *)
Definition: aoeblk.c:358
aoe_cfghdr::scnt
unsigned char scnt
Definition: aoe.h:68
NAOEIFS
Definition: aoe.h:89
AOEAFL_WRITE
Definition: aoe.h:28
frame::tag
u32 tag
Definition: aoe.h:116
ktstate::task
struct task_struct * task
Definition: aoe.h:199
aoe_ktstop
void aoe_ktstop(struct ktstate *k)
Definition: aoecmd.c:1339
aoenet_exit
void aoenet_exit(void)
Definition: aoenet.c:261
aoe_atahdr::cmdstat
unsigned char cmdstat
Definition: aoe.h:55
frame::sent_jiffs
u32 sent_jiffs
Definition: aoe.h:118
aoe_cfghdr::aoeccmd
unsigned char aoeccmd
Definition: aoe.h:69
aoetgt::maxout
ushort maxout
Definition: aoe.h:144
ulong
unsigned long ulong
Definition: aoe-sancheck.c:30
aoedbg_undbg
void aoedbg_undbg(struct aoedev *d)
Definition: aoedbg.c:253
aoecmd_wreset
void aoecmd_wreset(struct aoetgt *t)
Definition: aoecmd.c:1695
aoedev_init
int aoedev_init(void)
Definition: aoedev.c:531
aoedev::aoemajor
ulong aoemajor
Definition: aoe.h:158
aoedev::next
struct aoedev * next
Definition: aoe.h:156
aoedev::lasttag
u16 lasttag
Definition: aoe.h:165
DEVFL_GDALLOC
Definition: aoe.h:77
aoedev::ident
char ident[512]
Definition: aoe.h:193
AOECMD_ATA
Definition: aoe.h:18
aoe_hdr::err
unsigned char err
Definition: aoe.h:44
aoedev_downdev
void aoedev_downdev(struct aoedev *d)
Definition: aoedev.c:199
aoetgt::nout_probes
char nout_probes
Definition: aoe.h:152
mac_addr
unsigned long long mac_addr(char addr[6])
Definition: aoenet.c:148
aoe_atahdr
Definition: aoe.h:51
AOECCMD_PTEST
Definition: aoe.h:32
aoecmd_exit
void aoecmd_exit(void)
Definition: aoecmd.c:1837
aoedev::ntargets
ulong ntargets
Definition: aoe.h:189
aoetgt::next_cwnd
ushort next_cwnd
Definition: aoe.h:145
set_aoe_iflist
int set_aoe_iflist(const char __user *str, size_t size)
Definition: aoenet.c:134
AOE_HVER
Definition: aoe.h:36
AOECMD_CFG
Definition: aoe.h:19
AOEAFL_EXT
Definition: aoe.h:25
aoetgt::ffree
struct list_head ffree
Definition: aoe.h:140
frame::r_skb
struct sk_buff * r_skb
Definition: aoe.h:123
aoecmd_cfg_rsp
void aoecmd_cfg_rsp(struct sk_buff *)
Definition: aoecmd.c:1618
aoe_atahdr::lba4
unsigned char lba4
Definition: aoe.h:60
aoecmd_init
int aoecmd_init(void)
Definition: aoecmd.c:1772
aoe_hdr::tag
u32 tag
Definition: aoe.h:48
buf::iter
struct bvec_iter iter
Definition: aoe.h:106
aoedev::fw_ver
u16 fw_ver
Definition: aoe.h:164
aoedev::targets
struct aoetgt ** targets
Definition: aoe.h:188
aoedbg_rtt
void aoedbg_rtt(struct aoedev *d, struct aoe_hdr *h, struct frame *f, int rtt)
Definition: aoedbg.c:188
aoetgt::ifs
struct aoeif ifs[NAOEIFS]
Definition: aoe.h:141
aoedev::nopen
u16 nopen
Definition: aoe.h:163
aoedev::gd
struct gendisk * gd
Definition: aoe.h:169
aoedev::nskbpool
int nskbpool
Definition: aoe.h:178
aoedev::maxbcnt
ulong maxbcnt
Definition: aoe.h:185
aoedev::rttavg
u32 rttavg
Definition: aoe.h:159
aoe_atahdr::res
unsigned char res[2]
Definition: aoe.h:62
ktstate::lock
spinlock_t * lock
Definition: aoe.h:203
DEVFL_TKILL
Definition: aoe.h:75
aoe_atahdr::scnt
unsigned char scnt
Definition: aoe.h:54
aoe_hdr::cmd
unsigned char cmd
Definition: aoe.h:47
aoedev::bufpool
mempool_t * bufpool
Definition: aoe.h:179
DEVFL_KICKME
Definition: aoe.h:79
aoetgt::wpkts
int wpkts
Definition: aoe.h:151
aoecmd_ata_id
struct sk_buff * aoecmd_ata_id(struct aoedev *)
Definition: aoecmd.c:1464
aoedev::debugfs
struct dentry * debugfs
Definition: aoe.h:170
aoetgt::nframes
ushort nframes
Definition: aoe.h:138
ktstate::fn
int(* fn)(int)
Definition: aoe.h:201
RTTAVG_INIT
Definition: aoe.h:96
FFL_PROBE
Definition: aoe.h:111
aoe_end_request
void aoe_end_request(struct aoedev *, struct request *, int)
Definition: aoecmd.c:1119
aoedev::aoeminor
u16 aoeminor
Definition: aoe.h:161
AOEAFL_DEV
Definition: aoe.h:26
u16
uint16_t u16
Definition: dat.h:21
DEVFL_GD_NOW
Definition: aoe.h:78
aoedev::rexmitq
struct list_head rexmitq
Definition: aoe.h:187
AOECCMD_TEST
Definition: aoe.h:31
frame::head
struct list_head head
Definition: aoe.h:115
MAX_TAINT
Definition: aoe.h:100
aoe_hdr::major
u16 major
Definition: aoe.h:45
aoe_flush_iocq
void aoe_flush_iocq(void)
Definition: aoecmd.c:1729
aoeblk_exit
void aoeblk_exit(void)
Definition: aoeblk.c:444
aoe_cfghdr::fwver
u16 fwver
Definition: aoe.h:67
aoeif
Definition: aoe.h:130
aoe_hdr
Definition: aoe.h:39
RTTSCALE
Definition: aoe.h:94
aoedev::tgt
struct aoetgt ** tgt
Definition: aoe.h:190
AOECCMD_FSET
Definition: aoe.h:34
aoetgt::addr
unsigned char addr[6]
Definition: aoe.h:137
aoe_hdr::verfl
unsigned char verfl
Definition: aoe.h:43
aoe_atahdr::errfeat
unsigned char errfeat
Definition: aoe.h:53
frame::waited
ulong waited
Definition: aoe.h:119
DEVFL_EXT
Definition: aoe.h:76
TIMERTICK
Definition: aoe.h:93
buf::nframesout
ulong nframesout
Definition: aoe.h:104
NFACTIVE
Definition: aoe.h:91
NSKBPOOLMAX
Definition: aoe.h:90
aoedev_exit
void aoedev_exit(void)
Definition: aoedev.c:524
aoedbg_devinit
void aoedbg_devinit(struct aoedev *d)
Definition: aoedbg.c:157
ktstate::active
int active
Definition: aoe.h:205
aoedev::ip
struct aoedev::@5 ip
aoechr_init
int aoechr_init(void)
Definition: 24-cdc4.c:14
aoedisk_rm_sysfs
void aoedisk_rm_sysfs(struct aoedev *d)
Definition: aoeblk.c:238
aoetgt::d
struct aoedev * d
Definition: aoe.h:139
aoedev_put
void aoedev_put(struct aoedev *)
Definition: aoedev.c:141
aoe_ktstart
int aoe_ktstart(struct ktstate *k)
Definition: aoecmd.c:1346
aoe_hdr::minor
unsigned char minor
Definition: aoe.h:46
frame::t
struct aoetgt * t
Definition: aoe.h:121
aoetgt::rpkts
int rpkts
Definition: aoe.h:151
DEVFL_NEWSIZE
Definition: aoe.h:80
frame::sent
struct timeval sent
Definition: aoe.h:117
DEVFL_FREEING
Definition: aoe.h:81
aoedisk_rm_debugfs
void aoedisk_rm_debugfs(struct aoedev *d)
Definition: aoeblk.c:226