]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/block/aoe/aoe.h
aoe: improve handling of misbehaving network paths
[karo-tx-linux.git] / drivers / block / aoe / aoe.h
1
2 /* Copyright (c) 2012 Coraid, Inc.  See COPYING for GPL terms. */
3 #define VERSION "64+"
4 #define AOE_MAJOR 152
5 #define DEVICE_NAME "aoe"
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  */
10 #ifndef AOE_PARTITIONS
11 #define AOE_PARTITIONS (16)
12 #endif
13
14 #define WHITESPACE " \t\v\f\n"
15
16 enum {
17         AOECMD_ATA,
18         AOECMD_CFG,
19         AOECMD_VEND_MIN = 0xf0,
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
38 struct aoe_hdr {
39         unsigned char dst[6];
40         unsigned char src[6];
41         __be16 type;
42         unsigned char verfl;
43         unsigned char err;
44         __be16 major;
45         unsigned char minor;
46         unsigned char cmd;
47         __be32 tag;
48 };
49
50 struct 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
64 struct aoe_cfghdr {
65         __be16 bufcnt;
66         __be16 fwver;
67         unsigned char scnt;
68         unsigned char aoeccmd;
69         unsigned char cslen[2];
70 };
71
72 enum {
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 */
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 */
79 };
80
81 enum {
82         DEFAULTBCNT = 2 * 512,  /* 2 sectors */
83         MIN_BUFS = 16,
84         NTARGETS = 8,
85         NAOEIFS = 8,
86         NSKBPOOLMAX = 256,
87         NFACTIVE = 61,
88
89         TIMERTICK = HZ / 10,
90         RTTSCALE = 8,
91         RTTDSCALE = 3,
92         RTTAVG_INIT = USEC_PER_SEC / 4 << RTTSCALE,
93         RTTDEV_INIT = RTTAVG_INIT / 4,
94
95         HARD_SCORN_SECS = 10,   /* try another remote port after this */
96         MAX_TAINT = 1000,       /* cap on aoetgt taint */
97 };
98
99 struct buf {
100         ulong nframesout;
101         ulong resid;
102         ulong bv_resid;
103         sector_t sector;
104         struct bio *bio;
105         struct bio_vec *bv;
106         struct request *rq;
107 };
108
109 enum frame_flags {
110         FFL_PROBE = 1,
111 };
112
113 struct frame {
114         struct list_head head;
115         u32 tag;
116         struct timeval sent;    /* high-res time packet was sent */
117         u32 sent_jiffs;         /* low-res jiffies-based sent time */
118         ulong waited;
119         ulong waited_total;
120         struct aoetgt *t;               /* parent target I belong to */
121         sector_t lba;
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 bio_vec *bv;
126         ulong bcnt;
127         ulong bv_off;
128         char flags;
129 };
130
131 struct aoeif {
132         struct net_device *nd;
133         ulong lost;
134         int bcnt;
135 };
136
137 struct aoetgt {
138         unsigned char addr[6];
139         ushort nframes;         /* cap on frames to use */
140         struct aoedev *d;                       /* parent device I belong to */
141         struct list_head ffree;                 /* list of free frames */
142         struct aoeif ifs[NAOEIFS];
143         struct aoeif *ifp;      /* current aoeif in use */
144         ushort nout;            /* number of AoE commands outstanding */
145         ushort maxout;          /* current value for max outstanding */
146         ushort next_cwnd;       /* incr maxout after decrementing to zero */
147         ushort ssthresh;        /* slow start threshold */
148         ulong falloc;           /* number of allocated frames */
149         int taint;              /* how much we want to avoid this aoetgt */
150         int minbcnt;
151         int wpkts, rpkts;
152         char nout_probes;
153 };
154
155 struct aoedev {
156         struct aoedev *next;
157         ulong sysminor;
158         ulong aoemajor;
159         u32 rttavg;             /* scaled AoE round trip time average */
160         u32 rttdev;             /* scaled round trip time mean deviation */
161         u16 aoeminor;
162         u16 flags;
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 */
166         u16 useme;
167         ulong ref;
168         struct work_struct work;/* disk create work struct */
169         struct gendisk *gd;
170         struct request_queue *blkq;
171         struct hd_geometry geo;
172         sector_t ssize;
173         struct timer_list timer;
174         spinlock_t lock;
175         struct sk_buff_head skbpool;
176         mempool_t *bufpool;     /* for deadlock-free Buf allocation */
177         struct {                /* pointers to work in progress */
178                 struct buf *buf;
179                 struct bio *nxbio;
180                 struct request *rq;
181         } ip;
182         ulong maxbcnt;
183         struct list_head factive[NFACTIVE];     /* hash of active frames */
184         struct list_head rexmitq; /* deferred retransmissions */
185         struct aoetgt *targets[NTARGETS];
186         struct aoetgt **tgt;    /* target in use when working */
187         ulong ntargets;
188         ulong kicked;
189         char ident[512];
190 };
191
192 /* kthread tracking */
193 struct ktstate {
194         struct completion rendez;
195         struct task_struct *task;
196         wait_queue_head_t *waitq;
197         int (*fn) (void);
198         char *name;
199         spinlock_t *lock;
200 };
201
202 int aoeblk_init(void);
203 void aoeblk_exit(void);
204 void aoeblk_gdalloc(void *);
205 void aoedisk_rm_sysfs(struct aoedev *d);
206
207 int aoechr_init(void);
208 void aoechr_exit(void);
209 void aoechr_error(char *);
210
211 void aoecmd_work(struct aoedev *d);
212 void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor);
213 struct sk_buff *aoecmd_ata_rsp(struct sk_buff *);
214 void aoecmd_cfg_rsp(struct sk_buff *);
215 void aoecmd_sleepwork(struct work_struct *);
216 void aoecmd_wreset(struct aoetgt *t);
217 void aoecmd_cleanslate(struct aoedev *);
218 void aoecmd_exit(void);
219 int aoecmd_init(void);
220 struct sk_buff *aoecmd_ata_id(struct aoedev *);
221 void aoe_freetframe(struct frame *);
222 void aoe_flush_iocq(void);
223 void aoe_end_request(struct aoedev *, struct request *, int);
224 int aoe_ktstart(struct ktstate *k);
225 void aoe_ktstop(struct ktstate *k);
226
227 int aoedev_init(void);
228 void aoedev_exit(void);
229 struct aoedev *aoedev_by_aoeaddr(ulong maj, int min, int do_alloc);
230 void aoedev_downdev(struct aoedev *d);
231 int aoedev_flush(const char __user *str, size_t size);
232 void aoe_failbuf(struct aoedev *, struct buf *);
233 void aoedev_put(struct aoedev *);
234
235 int aoenet_init(void);
236 void aoenet_exit(void);
237 void aoenet_xmit(struct sk_buff_head *);
238 int is_aoe_netif(struct net_device *ifp);
239 int set_aoe_iflist(const char __user *str, size_t size);