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