]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/block/aoe/aoe.h
aoe: use dynamic number of remote ports for AoE storage target
[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_GD_NOW = (1<<4),  /* allocating gendisk */
78         DEVFL_KICKME = (1<<5),  /* slow polling network card catch */
79         DEVFL_NEWSIZE = (1<<6), /* need to update dev size in block layer */
80         DEVFL_FREEING = (1<<7), /* set when device is being cleaned up */
81         DEVFL_FREED = (1<<8),   /* device has been cleaned up */
82 };
83
84 enum {
85         DEFAULTBCNT = 2 * 512,  /* 2 sectors */
86         MIN_BUFS = 16,
87         NTARGETS = 4,
88         NAOEIFS = 8,
89         NSKBPOOLMAX = 256,
90         NFACTIVE = 61,
91
92         TIMERTICK = HZ / 10,
93         RTTSCALE = 8,
94         RTTDSCALE = 3,
95         RTTAVG_INIT = USEC_PER_SEC / 4 << RTTSCALE,
96         RTTDEV_INIT = RTTAVG_INIT / 4,
97
98         HARD_SCORN_SECS = 10,   /* try another remote port after this */
99         MAX_TAINT = 1000,       /* cap on aoetgt taint */
100 };
101
102 struct buf {
103         ulong nframesout;
104         ulong resid;
105         ulong bv_resid;
106         sector_t sector;
107         struct bio *bio;
108         struct bio_vec *bv;
109         struct request *rq;
110 };
111
112 enum frame_flags {
113         FFL_PROBE = 1,
114 };
115
116 struct frame {
117         struct list_head head;
118         u32 tag;
119         struct timeval sent;    /* high-res time packet was sent */
120         u32 sent_jiffs;         /* low-res jiffies-based sent time */
121         ulong waited;
122         ulong waited_total;
123         struct aoetgt *t;               /* parent target I belong to */
124         sector_t lba;
125         struct sk_buff *skb;            /* command skb freed on module exit */
126         struct sk_buff *r_skb;          /* response skb for async processing */
127         struct buf *buf;
128         struct bio_vec *bv;
129         ulong bcnt;
130         ulong bv_off;
131         char flags;
132 };
133
134 struct aoeif {
135         struct net_device *nd;
136         ulong lost;
137         int bcnt;
138 };
139
140 struct aoetgt {
141         unsigned char addr[6];
142         ushort nframes;         /* cap on frames to use */
143         struct aoedev *d;                       /* parent device I belong to */
144         struct list_head ffree;                 /* list of free frames */
145         struct aoeif ifs[NAOEIFS];
146         struct aoeif *ifp;      /* current aoeif in use */
147         ushort nout;            /* number of AoE commands outstanding */
148         ushort maxout;          /* current value for max outstanding */
149         ushort next_cwnd;       /* incr maxout after decrementing to zero */
150         ushort ssthresh;        /* slow start threshold */
151         ulong falloc;           /* number of allocated frames */
152         int taint;              /* how much we want to avoid this aoetgt */
153         int minbcnt;
154         int wpkts, rpkts;
155         char nout_probes;
156 };
157
158 struct aoedev {
159         struct aoedev *next;
160         ulong sysminor;
161         ulong aoemajor;
162         u32 rttavg;             /* scaled AoE round trip time average */
163         u32 rttdev;             /* scaled round trip time mean deviation */
164         u16 aoeminor;
165         u16 flags;
166         u16 nopen;              /* (bd_openers isn't available without sleeping) */
167         u16 fw_ver;             /* version of blade's firmware */
168         u16 lasttag;            /* last tag sent */
169         u16 useme;
170         ulong ref;
171         struct work_struct work;/* disk create work struct */
172         struct gendisk *gd;
173         struct request_queue *blkq;
174         struct hd_geometry geo;
175         sector_t ssize;
176         struct timer_list timer;
177         spinlock_t lock;
178         struct sk_buff_head skbpool;
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;
185         ulong maxbcnt;
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 */
191         ulong kicked;
192         char ident[512];
193 };
194
195 /* kthread tracking */
196 struct ktstate {
197         struct completion rendez;
198         struct task_struct *task;
199         wait_queue_head_t *waitq;
200         int (*fn) (void);
201         char *name;
202         spinlock_t *lock;
203 };
204
205 int aoeblk_init(void);
206 void aoeblk_exit(void);
207 void aoeblk_gdalloc(void *);
208 void aoedisk_rm_sysfs(struct aoedev *d);
209
210 int aoechr_init(void);
211 void aoechr_exit(void);
212 void aoechr_error(char *);
213
214 void aoecmd_work(struct aoedev *d);
215 void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor);
216 struct sk_buff *aoecmd_ata_rsp(struct sk_buff *);
217 void aoecmd_cfg_rsp(struct sk_buff *);
218 void aoecmd_sleepwork(struct work_struct *);
219 void aoecmd_wreset(struct aoetgt *t);
220 void aoecmd_cleanslate(struct aoedev *);
221 void aoecmd_exit(void);
222 int aoecmd_init(void);
223 struct sk_buff *aoecmd_ata_id(struct aoedev *);
224 void aoe_freetframe(struct frame *);
225 void aoe_flush_iocq(void);
226 void aoe_end_request(struct aoedev *, struct request *, int);
227 int aoe_ktstart(struct ktstate *k);
228 void aoe_ktstop(struct ktstate *k);
229
230 int aoedev_init(void);
231 void aoedev_exit(void);
232 struct aoedev *aoedev_by_aoeaddr(ulong maj, int min, int do_alloc);
233 void aoedev_downdev(struct aoedev *d);
234 int aoedev_flush(const char __user *str, size_t size);
235 void aoe_failbuf(struct aoedev *, struct buf *);
236 void aoedev_put(struct aoedev *);
237
238 int aoenet_init(void);
239 void aoenet_exit(void);
240 void aoenet_xmit(struct sk_buff_head *);
241 int is_aoe_netif(struct net_device *ifp);
242 int set_aoe_iflist(const char __user *str, size_t size);