Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/drivers/block/aoe/aoe.h
26282 views
1
/* Copyright (c) 2013 Coraid, Inc. See COPYING for GPL terms. */
2
#include <linux/blk-mq.h>
3
4
#define VERSION "85"
5
#define AOE_MAJOR 152
6
#define DEVICE_NAME "aoe"
7
8
/* set AOE_PARTITIONS to 1 to use whole-disks only
9
* default is 16, which is 15 partitions plus the whole disk
10
*/
11
#ifndef AOE_PARTITIONS
12
#define AOE_PARTITIONS (16)
13
#endif
14
15
#define WHITESPACE " \t\v\f\n,"
16
17
enum {
18
AOECMD_ATA,
19
AOECMD_CFG,
20
AOECMD_VEND_MIN = 0xf0,
21
22
AOEFL_RSP = (1<<3),
23
AOEFL_ERR = (1<<2),
24
25
AOEAFL_EXT = (1<<6),
26
AOEAFL_DEV = (1<<4),
27
AOEAFL_ASYNC = (1<<1),
28
AOEAFL_WRITE = (1<<0),
29
30
AOECCMD_READ = 0,
31
AOECCMD_TEST,
32
AOECCMD_PTEST,
33
AOECCMD_SET,
34
AOECCMD_FSET,
35
36
AOE_HVER = 0x10,
37
};
38
39
struct aoe_hdr {
40
unsigned char dst[6];
41
unsigned char src[6];
42
__be16 type;
43
unsigned char verfl;
44
unsigned char err;
45
__be16 major;
46
unsigned char minor;
47
unsigned char cmd;
48
__be32 tag;
49
};
50
51
struct aoe_atahdr {
52
unsigned char aflags;
53
unsigned char errfeat;
54
unsigned char scnt;
55
unsigned char cmdstat;
56
unsigned char lba0;
57
unsigned char lba1;
58
unsigned char lba2;
59
unsigned char lba3;
60
unsigned char lba4;
61
unsigned char lba5;
62
unsigned char res[2];
63
};
64
65
struct aoe_cfghdr {
66
__be16 bufcnt;
67
__be16 fwver;
68
unsigned char scnt;
69
unsigned char aoeccmd;
70
unsigned char cslen[2];
71
};
72
73
enum {
74
DEVFL_UP = 1, /* device is installed in system and ready for AoE->ATA commands */
75
DEVFL_TKILL = (1<<1), /* flag for timer to know when to kill self */
76
DEVFL_EXT = (1<<2), /* device accepts lba48 commands */
77
DEVFL_GDALLOC = (1<<3), /* need to alloc gendisk */
78
DEVFL_GD_NOW = (1<<4), /* allocating gendisk */
79
DEVFL_KICKME = (1<<5), /* slow polling network card catch */
80
DEVFL_NEWSIZE = (1<<6), /* need to update dev size in block layer */
81
DEVFL_FREEING = (1<<7), /* set when device is being cleaned up */
82
DEVFL_FREED = (1<<8), /* device has been cleaned up */
83
DEVFL_DEAD = (1<<9), /* device has timed out of aoe_deadsecs */
84
};
85
86
enum {
87
DEFAULTBCNT = 2 * 512, /* 2 sectors */
88
MIN_BUFS = 16,
89
NTARGETS = 4,
90
NAOEIFS = 8,
91
NSKBPOOLMAX = 256,
92
NFACTIVE = 61,
93
94
TIMERTICK = HZ / 10,
95
RTTSCALE = 8,
96
RTTDSCALE = 3,
97
RTTAVG_INIT = USEC_PER_SEC / 4 << RTTSCALE,
98
RTTDEV_INIT = RTTAVG_INIT / 4,
99
100
HARD_SCORN_SECS = 10, /* try another remote port after this */
101
MAX_TAINT = 1000, /* cap on aoetgt taint */
102
};
103
104
struct aoe_req {
105
unsigned long nr_bios;
106
};
107
108
struct buf {
109
ulong nframesout;
110
struct bio *bio;
111
struct bvec_iter iter;
112
struct request *rq;
113
};
114
115
enum frame_flags {
116
FFL_PROBE = 1,
117
};
118
119
struct frame {
120
struct list_head head;
121
u32 tag;
122
ktime_t sent; /* high-res time packet was sent */
123
ulong waited;
124
ulong waited_total;
125
struct aoetgt *t; /* parent target I belong to */
126
struct sk_buff *skb; /* command skb freed on module exit */
127
struct sk_buff *r_skb; /* response skb for async processing */
128
struct buf *buf;
129
struct bvec_iter iter;
130
char flags;
131
};
132
133
struct aoeif {
134
struct net_device *nd;
135
ulong lost;
136
int bcnt;
137
};
138
139
struct aoetgt {
140
unsigned char addr[6];
141
ushort nframes; /* cap on frames to use */
142
struct aoedev *d; /* parent device I belong to */
143
struct list_head ffree; /* list of free frames */
144
struct aoeif ifs[NAOEIFS];
145
struct aoeif *ifp; /* current aoeif in use */
146
ushort nout; /* number of AoE commands outstanding */
147
ushort maxout; /* current value for max outstanding */
148
ushort next_cwnd; /* incr maxout after decrementing to zero */
149
ushort ssthresh; /* slow start threshold */
150
ulong falloc; /* number of allocated frames */
151
int taint; /* how much we want to avoid this aoetgt */
152
int minbcnt;
153
int wpkts, rpkts;
154
char nout_probes;
155
};
156
157
struct aoedev {
158
struct aoedev *next;
159
ulong sysminor;
160
ulong aoemajor;
161
u32 rttavg; /* scaled AoE round trip time average */
162
u32 rttdev; /* scaled round trip time mean deviation */
163
u16 aoeminor;
164
u16 flags;
165
u16 nopen; /* (bd_openers isn't available without sleeping) */
166
u16 fw_ver; /* version of blade's firmware */
167
u16 lasttag; /* last tag sent */
168
u16 useme;
169
ulong ref;
170
struct work_struct work;/* disk create work struct */
171
struct gendisk *gd;
172
struct dentry *debugfs;
173
struct request_queue *blkq;
174
struct list_head rq_list;
175
struct blk_mq_tag_set tag_set;
176
struct hd_geometry geo;
177
sector_t ssize;
178
struct timer_list timer;
179
spinlock_t lock;
180
struct sk_buff_head skbpool;
181
mempool_t *bufpool; /* for deadlock-free Buf allocation */
182
struct { /* pointers to work in progress */
183
struct buf *buf;
184
struct bio *nxbio;
185
struct request *rq;
186
} ip;
187
ulong maxbcnt;
188
struct list_head factive[NFACTIVE]; /* hash of active frames */
189
struct list_head rexmitq; /* deferred retransmissions */
190
struct aoetgt **targets;
191
ulong ntargets; /* number of allocated aoetgt pointers */
192
struct aoetgt **tgt; /* target in use when working */
193
ulong kicked;
194
char ident[512];
195
};
196
197
/* kthread tracking */
198
struct ktstate {
199
struct completion rendez;
200
struct task_struct *task;
201
wait_queue_head_t *waitq;
202
int (*fn) (int);
203
char name[12];
204
spinlock_t *lock;
205
int id;
206
int active;
207
};
208
209
int aoeblk_init(void);
210
void aoeblk_exit(void);
211
void aoeblk_gdalloc(void *);
212
void aoedisk_rm_debugfs(struct aoedev *d);
213
214
int aoechr_init(void);
215
void aoechr_exit(void);
216
void aoechr_error(char *);
217
218
void aoecmd_work(struct aoedev *d);
219
void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor);
220
struct sk_buff *aoecmd_ata_rsp(struct sk_buff *);
221
void aoecmd_cfg_rsp(struct sk_buff *);
222
void aoecmd_sleepwork(struct work_struct *);
223
void aoecmd_wreset(struct aoetgt *t);
224
void aoecmd_cleanslate(struct aoedev *);
225
void aoecmd_exit(void);
226
int aoecmd_init(void);
227
struct sk_buff *aoecmd_ata_id(struct aoedev *);
228
void aoe_freetframe(struct frame *);
229
void aoe_flush_iocq(void);
230
void aoe_flush_iocq_by_index(int);
231
void aoe_end_request(struct aoedev *, struct request *, int);
232
int aoe_ktstart(struct ktstate *k);
233
void aoe_ktstop(struct ktstate *k);
234
235
int aoedev_init(void);
236
void aoedev_exit(void);
237
struct aoedev *aoedev_by_aoeaddr(ulong maj, int min, int do_alloc);
238
void aoedev_downdev(struct aoedev *d);
239
int aoedev_flush(const char __user *str, size_t size);
240
void aoe_failbuf(struct aoedev *, struct buf *);
241
void aoedev_put(struct aoedev *);
242
243
int aoenet_init(void);
244
void aoenet_exit(void);
245
void aoenet_xmit(struct sk_buff_head *);
246
int is_aoe_netif(struct net_device *ifp);
247
int set_aoe_iflist(const char __user *str, size_t size);
248
249
extern struct workqueue_struct *aoe_wq;
250
251