Commit | Line | Data |
---|---|---|
fea05a26 | 1 | /* Copyright (c) 2012 Coraid, Inc. See COPYING for GPL terms. */ |
7392fbe5 | 2 | #define VERSION "49" |
1da177e4 LT |
3 | #define AOE_MAJOR 152 |
4 | #define DEVICE_NAME "aoe" | |
fc458dcd | 5 | |
6 | /* set AOE_PARTITIONS to 1 to use whole-disks only | |
7 | * default is 16, which is 15 partitions plus the whole disk | |
8 | */ | |
1da177e4 | 9 | #ifndef AOE_PARTITIONS |
e39526e6 | 10 | #define AOE_PARTITIONS (16) |
1da177e4 | 11 | #endif |
fc458dcd | 12 | |
e39526e6 EC |
13 | #define SYSMINOR(aoemajor, aoeminor) ((aoemajor) * NPERSHELF + (aoeminor)) |
14 | #define AOEMAJOR(sysminor) ((sysminor) / NPERSHELF) | |
15 | #define AOEMINOR(sysminor) ((sysminor) % NPERSHELF) | |
1da177e4 LT |
16 | #define WHITESPACE " \t\v\f\n" |
17 | ||
18 | enum { | |
19 | AOECMD_ATA, | |
20 | AOECMD_CFG, | |
b6d6c517 | 21 | AOECMD_VEND_MIN = 0xf0, |
1da177e4 LT |
22 | |
23 | AOEFL_RSP = (1<<3), | |
24 | AOEFL_ERR = (1<<2), | |
25 | ||
26 | AOEAFL_EXT = (1<<6), | |
27 | AOEAFL_DEV = (1<<4), | |
28 | AOEAFL_ASYNC = (1<<1), | |
29 | AOEAFL_WRITE = (1<<0), | |
30 | ||
31 | AOECCMD_READ = 0, | |
32 | AOECCMD_TEST, | |
33 | AOECCMD_PTEST, | |
34 | AOECCMD_SET, | |
35 | AOECCMD_FSET, | |
36 | ||
37 | AOE_HVER = 0x10, | |
38 | }; | |
39 | ||
40 | struct aoe_hdr { | |
41 | unsigned char dst[6]; | |
42 | unsigned char src[6]; | |
63e9cc5d | 43 | __be16 type; |
1da177e4 LT |
44 | unsigned char verfl; |
45 | unsigned char err; | |
63e9cc5d | 46 | __be16 major; |
1da177e4 LT |
47 | unsigned char minor; |
48 | unsigned char cmd; | |
63e9cc5d | 49 | __be32 tag; |
1da177e4 LT |
50 | }; |
51 | ||
52 | struct aoe_atahdr { | |
53 | unsigned char aflags; | |
54 | unsigned char errfeat; | |
55 | unsigned char scnt; | |
56 | unsigned char cmdstat; | |
57 | unsigned char lba0; | |
58 | unsigned char lba1; | |
59 | unsigned char lba2; | |
60 | unsigned char lba3; | |
61 | unsigned char lba4; | |
62 | unsigned char lba5; | |
63 | unsigned char res[2]; | |
64 | }; | |
65 | ||
66 | struct aoe_cfghdr { | |
63e9cc5d | 67 | __be16 bufcnt; |
68 | __be16 fwver; | |
19bf2635 | 69 | unsigned char scnt; |
1da177e4 LT |
70 | unsigned char aoeccmd; |
71 | unsigned char cslen[2]; | |
72 | }; | |
73 | ||
74 | enum { | |
75 | DEVFL_UP = 1, /* device is installed in system and ready for AoE->ATA commands */ | |
76 | DEVFL_TKILL = (1<<1), /* flag for timer to know when to kill self */ | |
77 | DEVFL_EXT = (1<<2), /* device accepts lba48 commands */ | |
b21faa25 EC |
78 | DEVFL_GDALLOC = (1<<3), /* need to alloc gendisk */ |
79 | DEVFL_KICKME = (1<<4), /* slow polling network card catch */ | |
80 | DEVFL_NEWSIZE = (1<<5), /* need to update dev size in block layer */ | |
1da177e4 LT |
81 | }; |
82 | ||
83 | enum { | |
19bf2635 | 84 | DEFAULTBCNT = 2 * 512, /* 2 sectors */ |
e39526e6 | 85 | NPERSHELF = 16, /* number of slots per shelf address */ |
68e0d42f EC |
86 | MIN_BUFS = 16, |
87 | NTARGETS = 8, | |
88 | NAOEIFS = 8, | |
69cf2d85 | 89 | NSKBPOOLMAX = 256, |
64a80f5a | 90 | NFACTIVE = 61, |
68e0d42f EC |
91 | |
92 | TIMERTICK = HZ / 10, | |
93 | MINTIMER = HZ >> 2, | |
94 | MAXTIMER = HZ << 1, | |
1da177e4 LT |
95 | }; |
96 | ||
97 | struct buf { | |
1da177e4 | 98 | ulong nframesout; |
1da177e4 LT |
99 | ulong resid; |
100 | ulong bv_resid; | |
101 | sector_t sector; | |
102 | struct bio *bio; | |
103 | struct bio_vec *bv; | |
69cf2d85 | 104 | struct request *rq; |
1da177e4 LT |
105 | }; |
106 | ||
107 | struct frame { | |
896831f5 EC |
108 | struct list_head head; |
109 | u32 tag; | |
1da177e4 | 110 | ulong waited; |
896831f5 | 111 | struct aoetgt *t; /* parent target I belong to */ |
19bf2635 | 112 | sector_t lba; |
896831f5 EC |
113 | struct sk_buff *skb; /* command skb freed on module exit */ |
114 | struct sk_buff *r_skb; /* response skb for async processing */ | |
69cf2d85 | 115 | struct buf *buf; |
3d5b0605 | 116 | struct bio_vec *bv; |
69cf2d85 | 117 | ulong bcnt; |
3d5b0605 | 118 | ulong bv_off; |
1da177e4 LT |
119 | }; |
120 | ||
68e0d42f EC |
121 | struct aoeif { |
122 | struct net_device *nd; | |
3f0f0133 EC |
123 | ulong lost; |
124 | int bcnt; | |
68e0d42f EC |
125 | }; |
126 | ||
127 | struct aoetgt { | |
128 | unsigned char addr[6]; | |
129 | ushort nframes; | |
896831f5 | 130 | struct aoedev *d; /* parent device I belong to */ |
896831f5 | 131 | struct list_head ffree; /* list of free frames */ |
68e0d42f EC |
132 | struct aoeif ifs[NAOEIFS]; |
133 | struct aoeif *ifp; /* current aoeif in use */ | |
134 | ushort nout; | |
135 | ushort maxout; | |
896831f5 | 136 | ulong falloc; |
68e0d42f | 137 | ulong lastwadj; /* last window adjustment */ |
3f0f0133 | 138 | int minbcnt; |
68e0d42f EC |
139 | int wpkts, rpkts; |
140 | }; | |
141 | ||
1da177e4 LT |
142 | struct aoedev { |
143 | struct aoedev *next; | |
1da177e4 LT |
144 | ulong sysminor; |
145 | ulong aoemajor; | |
68e0d42f EC |
146 | u16 aoeminor; |
147 | u16 flags; | |
dced3a05 | 148 | u16 nopen; /* (bd_openers isn't available without sleeping) */ |
dced3a05 EC |
149 | u16 rttavg; /* round trip average of requests/responses */ |
150 | u16 mintimer; | |
1da177e4 | 151 | u16 fw_ver; /* version of blade's firmware */ |
64a80f5a EC |
152 | u16 lasttag; /* last tag sent */ |
153 | u16 useme; | |
69cf2d85 | 154 | ulong ref; |
1da177e4 LT |
155 | struct work_struct work;/* disk create work struct */ |
156 | struct gendisk *gd; | |
7135a71b | 157 | struct request_queue *blkq; |
1da177e4 LT |
158 | struct hd_geometry geo; |
159 | sector_t ssize; | |
160 | struct timer_list timer; | |
161 | spinlock_t lock; | |
e9bb8fb0 | 162 | struct sk_buff_head skbpool; |
1da177e4 | 163 | mempool_t *bufpool; /* for deadlock-free Buf allocation */ |
69cf2d85 EC |
164 | struct { /* pointers to work in progress */ |
165 | struct buf *buf; | |
166 | struct bio *nxbio; | |
167 | struct request *rq; | |
168 | } ip; | |
3f0f0133 | 169 | ulong maxbcnt; |
64a80f5a | 170 | struct list_head factive[NFACTIVE]; /* hash of active frames */ |
68e0d42f EC |
171 | struct aoetgt *targets[NTARGETS]; |
172 | struct aoetgt **tgt; /* target in use when working */ | |
896831f5 EC |
173 | struct aoetgt *htgt; /* target needing rexmit assistance */ |
174 | ulong ntargets; | |
175 | ulong kicked; | |
1da177e4 LT |
176 | }; |
177 | ||
896831f5 EC |
178 | /* kthread tracking */ |
179 | struct ktstate { | |
180 | struct completion rendez; | |
181 | struct task_struct *task; | |
182 | wait_queue_head_t *waitq; | |
183 | int (*fn) (void); | |
184 | char *name; | |
185 | spinlock_t *lock; | |
186 | }; | |
1da177e4 LT |
187 | |
188 | int aoeblk_init(void); | |
189 | void aoeblk_exit(void); | |
190 | void aoeblk_gdalloc(void *); | |
191 | void aoedisk_rm_sysfs(struct aoedev *d); | |
192 | ||
193 | int aoechr_init(void); | |
194 | void aoechr_exit(void); | |
195 | void aoechr_error(char *); | |
196 | ||
197 | void aoecmd_work(struct aoedev *d); | |
3ae1c24e | 198 | void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor); |
896831f5 | 199 | struct sk_buff *aoecmd_ata_rsp(struct sk_buff *); |
1da177e4 | 200 | void aoecmd_cfg_rsp(struct sk_buff *); |
c4028958 | 201 | void aoecmd_sleepwork(struct work_struct *); |
68e0d42f | 202 | void aoecmd_cleanslate(struct aoedev *); |
896831f5 EC |
203 | void aoecmd_exit(void); |
204 | int aoecmd_init(void); | |
68e0d42f | 205 | struct sk_buff *aoecmd_ata_id(struct aoedev *); |
896831f5 | 206 | void aoe_freetframe(struct frame *); |
69cf2d85 EC |
207 | void aoe_flush_iocq(void); |
208 | void aoe_end_request(struct aoedev *, struct request *, int); | |
eb086ec5 EC |
209 | int aoe_ktstart(struct ktstate *k); |
210 | void aoe_ktstop(struct ktstate *k); | |
1da177e4 LT |
211 | |
212 | int aoedev_init(void); | |
213 | void aoedev_exit(void); | |
32465c65 | 214 | struct aoedev *aoedev_by_aoeaddr(int maj, int min); |
68e0d42f | 215 | struct aoedev *aoedev_by_sysminor_m(ulong sysminor); |
1da177e4 | 216 | void aoedev_downdev(struct aoedev *d); |
262bf541 | 217 | int aoedev_flush(const char __user *str, size_t size); |
69cf2d85 EC |
218 | void aoe_failbuf(struct aoedev *, struct buf *); |
219 | void aoedev_put(struct aoedev *); | |
1da177e4 LT |
220 | |
221 | int aoenet_init(void); | |
222 | void aoenet_exit(void); | |
e9bb8fb0 | 223 | void aoenet_xmit(struct sk_buff_head *); |
1da177e4 LT |
224 | int is_aoe_netif(struct net_device *ifp); |
225 | int set_aoe_iflist(const char __user *str, size_t size); | |
226 |