32aede997f0171fa91bfcf3554362a95a1146dd2
[deliverable/linux.git] / drivers / block / aoe / aoe.h
1 /* Copyright (c) 2007 Coraid, Inc. See COPYING for GPL terms. */
2 #define VERSION "49"
3 #define AOE_MAJOR 152
4 #define DEVICE_NAME "aoe"
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 */
9 #ifndef AOE_PARTITIONS
10 #define AOE_PARTITIONS (16)
11 #endif
12
13 #define SYSMINOR(aoemajor, aoeminor) ((aoemajor) * NPERSHELF + (aoeminor))
14 #define AOEMAJOR(sysminor) ((sysminor) / NPERSHELF)
15 #define AOEMINOR(sysminor) ((sysminor) % NPERSHELF)
16 #define WHITESPACE " \t\v\f\n"
17
18 enum {
19 AOECMD_ATA,
20 AOECMD_CFG,
21 AOECMD_VEND_MIN = 0xf0,
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];
43 __be16 type;
44 unsigned char verfl;
45 unsigned char err;
46 __be16 major;
47 unsigned char minor;
48 unsigned char cmd;
49 __be32 tag;
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 {
67 __be16 bufcnt;
68 __be16 fwver;
69 unsigned char scnt;
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 */
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 */
81 };
82
83 enum {
84 DEFAULTBCNT = 2 * 512, /* 2 sectors */
85 NPERSHELF = 16, /* number of slots per shelf address */
86 MIN_BUFS = 16,
87 NTARGETS = 8,
88 NAOEIFS = 8,
89 NSKBPOOLMAX = 256,
90 NFACTIVE = 61,
91
92 TIMERTICK = HZ / 10,
93 MINTIMER = HZ >> 2,
94 MAXTIMER = HZ << 1,
95 };
96
97 struct buf {
98 ulong nframesout;
99 ulong resid;
100 ulong bv_resid;
101 sector_t sector;
102 struct bio *bio;
103 struct bio_vec *bv;
104 struct request *rq;
105 };
106
107 struct frame {
108 struct list_head head;
109 u32 tag;
110 ulong waited;
111 struct aoetgt *t; /* parent target I belong to */
112 sector_t lba;
113 struct sk_buff *skb; /* command skb freed on module exit */
114 struct sk_buff *r_skb; /* response skb for async processing */
115 struct buf *buf;
116 struct bio_vec *bv;
117 ulong bcnt;
118 ulong bv_off;
119 };
120
121 struct aoeif {
122 struct net_device *nd;
123 ulong lost;
124 int bcnt;
125 };
126
127 struct aoetgt {
128 unsigned char addr[6];
129 ushort nframes;
130 struct aoedev *d; /* parent device I belong to */
131 struct list_head ffree; /* list of free frames */
132 struct aoeif ifs[NAOEIFS];
133 struct aoeif *ifp; /* current aoeif in use */
134 ushort nout;
135 ushort maxout;
136 ulong falloc;
137 ulong lastwadj; /* last window adjustment */
138 int minbcnt;
139 int wpkts, rpkts;
140 };
141
142 struct aoedev {
143 struct aoedev *next;
144 ulong sysminor;
145 ulong aoemajor;
146 u16 aoeminor;
147 u16 flags;
148 u16 nopen; /* (bd_openers isn't available without sleeping) */
149 u16 rttavg; /* round trip average of requests/responses */
150 u16 mintimer;
151 u16 fw_ver; /* version of blade's firmware */
152 u16 lasttag; /* last tag sent */
153 u16 useme;
154 ulong ref;
155 struct work_struct work;/* disk create work struct */
156 struct gendisk *gd;
157 struct request_queue *blkq;
158 struct hd_geometry geo;
159 sector_t ssize;
160 struct timer_list timer;
161 spinlock_t lock;
162 struct sk_buff_head skbpool;
163 mempool_t *bufpool; /* for deadlock-free Buf allocation */
164 struct { /* pointers to work in progress */
165 struct buf *buf;
166 struct bio *nxbio;
167 struct request *rq;
168 } ip;
169 ulong maxbcnt;
170 struct list_head factive[NFACTIVE]; /* hash of active frames */
171 struct aoetgt *targets[NTARGETS];
172 struct aoetgt **tgt; /* target in use when working */
173 struct aoetgt *htgt; /* target needing rexmit assistance */
174 ulong ntargets;
175 ulong kicked;
176 };
177
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 };
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);
198 void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor);
199 struct sk_buff *aoecmd_ata_rsp(struct sk_buff *);
200 void aoecmd_cfg_rsp(struct sk_buff *);
201 void aoecmd_sleepwork(struct work_struct *);
202 void aoecmd_cleanslate(struct aoedev *);
203 void aoecmd_exit(void);
204 int aoecmd_init(void);
205 struct sk_buff *aoecmd_ata_id(struct aoedev *);
206 void aoe_freetframe(struct frame *);
207 void aoe_flush_iocq(void);
208 void aoe_end_request(struct aoedev *, struct request *, int);
209 int aoe_ktstart(struct ktstate *k);
210 void aoe_ktstop(struct ktstate *k);
211
212 int aoedev_init(void);
213 void aoedev_exit(void);
214 struct aoedev *aoedev_by_aoeaddr(int maj, int min);
215 struct aoedev *aoedev_by_sysminor_m(ulong sysminor);
216 void aoedev_downdev(struct aoedev *d);
217 int aoedev_flush(const char __user *str, size_t size);
218 void aoe_failbuf(struct aoedev *, struct buf *);
219 void aoedev_put(struct aoedev *);
220
221 int aoenet_init(void);
222 void aoenet_exit(void);
223 void aoenet_xmit(struct sk_buff_head *);
224 int is_aoe_netif(struct net_device *ifp);
225 int set_aoe_iflist(const char __user *str, size_t size);
226
This page took 0.050814 seconds and 4 git commands to generate.