0001
0002 #include <linux/blk-mq.h>
0003
0004 #define VERSION "85"
0005 #define AOE_MAJOR 152
0006 #define DEVICE_NAME "aoe"
0007
0008
0009
0010
0011 #ifndef AOE_PARTITIONS
0012 #define AOE_PARTITIONS (16)
0013 #endif
0014
0015 #define WHITESPACE " \t\v\f\n,"
0016
0017 enum {
0018 AOECMD_ATA,
0019 AOECMD_CFG,
0020 AOECMD_VEND_MIN = 0xf0,
0021
0022 AOEFL_RSP = (1<<3),
0023 AOEFL_ERR = (1<<2),
0024
0025 AOEAFL_EXT = (1<<6),
0026 AOEAFL_DEV = (1<<4),
0027 AOEAFL_ASYNC = (1<<1),
0028 AOEAFL_WRITE = (1<<0),
0029
0030 AOECCMD_READ = 0,
0031 AOECCMD_TEST,
0032 AOECCMD_PTEST,
0033 AOECCMD_SET,
0034 AOECCMD_FSET,
0035
0036 AOE_HVER = 0x10,
0037 };
0038
0039 struct aoe_hdr {
0040 unsigned char dst[6];
0041 unsigned char src[6];
0042 __be16 type;
0043 unsigned char verfl;
0044 unsigned char err;
0045 __be16 major;
0046 unsigned char minor;
0047 unsigned char cmd;
0048 __be32 tag;
0049 };
0050
0051 struct aoe_atahdr {
0052 unsigned char aflags;
0053 unsigned char errfeat;
0054 unsigned char scnt;
0055 unsigned char cmdstat;
0056 unsigned char lba0;
0057 unsigned char lba1;
0058 unsigned char lba2;
0059 unsigned char lba3;
0060 unsigned char lba4;
0061 unsigned char lba5;
0062 unsigned char res[2];
0063 };
0064
0065 struct aoe_cfghdr {
0066 __be16 bufcnt;
0067 __be16 fwver;
0068 unsigned char scnt;
0069 unsigned char aoeccmd;
0070 unsigned char cslen[2];
0071 };
0072
0073 enum {
0074 DEVFL_UP = 1,
0075 DEVFL_TKILL = (1<<1),
0076 DEVFL_EXT = (1<<2),
0077 DEVFL_GDALLOC = (1<<3),
0078 DEVFL_GD_NOW = (1<<4),
0079 DEVFL_KICKME = (1<<5),
0080 DEVFL_NEWSIZE = (1<<6),
0081 DEVFL_FREEING = (1<<7),
0082 DEVFL_FREED = (1<<8),
0083 };
0084
0085 enum {
0086 DEFAULTBCNT = 2 * 512,
0087 MIN_BUFS = 16,
0088 NTARGETS = 4,
0089 NAOEIFS = 8,
0090 NSKBPOOLMAX = 256,
0091 NFACTIVE = 61,
0092
0093 TIMERTICK = HZ / 10,
0094 RTTSCALE = 8,
0095 RTTDSCALE = 3,
0096 RTTAVG_INIT = USEC_PER_SEC / 4 << RTTSCALE,
0097 RTTDEV_INIT = RTTAVG_INIT / 4,
0098
0099 HARD_SCORN_SECS = 10,
0100 MAX_TAINT = 1000,
0101 };
0102
0103 struct aoe_req {
0104 unsigned long nr_bios;
0105 };
0106
0107 struct buf {
0108 ulong nframesout;
0109 struct bio *bio;
0110 struct bvec_iter iter;
0111 struct request *rq;
0112 };
0113
0114 enum frame_flags {
0115 FFL_PROBE = 1,
0116 };
0117
0118 struct frame {
0119 struct list_head head;
0120 u32 tag;
0121 ktime_t sent;
0122 ulong waited;
0123 ulong waited_total;
0124 struct aoetgt *t;
0125 struct sk_buff *skb;
0126 struct sk_buff *r_skb;
0127 struct buf *buf;
0128 struct bvec_iter iter;
0129 char flags;
0130 };
0131
0132 struct aoeif {
0133 struct net_device *nd;
0134 ulong lost;
0135 int bcnt;
0136 };
0137
0138 struct aoetgt {
0139 unsigned char addr[6];
0140 ushort nframes;
0141 struct aoedev *d;
0142 struct list_head ffree;
0143 struct aoeif ifs[NAOEIFS];
0144 struct aoeif *ifp;
0145 ushort nout;
0146 ushort maxout;
0147 ushort next_cwnd;
0148 ushort ssthresh;
0149 ulong falloc;
0150 int taint;
0151 int minbcnt;
0152 int wpkts, rpkts;
0153 char nout_probes;
0154 };
0155
0156 struct aoedev {
0157 struct aoedev *next;
0158 ulong sysminor;
0159 ulong aoemajor;
0160 u32 rttavg;
0161 u32 rttdev;
0162 u16 aoeminor;
0163 u16 flags;
0164 u16 nopen;
0165 u16 fw_ver;
0166 u16 lasttag;
0167 u16 useme;
0168 ulong ref;
0169 struct work_struct work;
0170 struct gendisk *gd;
0171 struct dentry *debugfs;
0172 struct request_queue *blkq;
0173 struct list_head rq_list;
0174 struct blk_mq_tag_set tag_set;
0175 struct hd_geometry geo;
0176 sector_t ssize;
0177 struct timer_list timer;
0178 spinlock_t lock;
0179 struct sk_buff_head skbpool;
0180 mempool_t *bufpool;
0181 struct {
0182 struct buf *buf;
0183 struct bio *nxbio;
0184 struct request *rq;
0185 } ip;
0186 ulong maxbcnt;
0187 struct list_head factive[NFACTIVE];
0188 struct list_head rexmitq;
0189 struct aoetgt **targets;
0190 ulong ntargets;
0191 struct aoetgt **tgt;
0192 ulong kicked;
0193 char ident[512];
0194 };
0195
0196
0197 struct ktstate {
0198 struct completion rendez;
0199 struct task_struct *task;
0200 wait_queue_head_t *waitq;
0201 int (*fn) (int);
0202 char name[12];
0203 spinlock_t *lock;
0204 int id;
0205 int active;
0206 };
0207
0208 int aoeblk_init(void);
0209 void aoeblk_exit(void);
0210 void aoeblk_gdalloc(void *);
0211 void aoedisk_rm_debugfs(struct aoedev *d);
0212
0213 int aoechr_init(void);
0214 void aoechr_exit(void);
0215 void aoechr_error(char *);
0216
0217 void aoecmd_work(struct aoedev *d);
0218 void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor);
0219 struct sk_buff *aoecmd_ata_rsp(struct sk_buff *);
0220 void aoecmd_cfg_rsp(struct sk_buff *);
0221 void aoecmd_sleepwork(struct work_struct *);
0222 void aoecmd_wreset(struct aoetgt *t);
0223 void aoecmd_cleanslate(struct aoedev *);
0224 void aoecmd_exit(void);
0225 int aoecmd_init(void);
0226 struct sk_buff *aoecmd_ata_id(struct aoedev *);
0227 void aoe_freetframe(struct frame *);
0228 void aoe_flush_iocq(void);
0229 void aoe_flush_iocq_by_index(int);
0230 void aoe_end_request(struct aoedev *, struct request *, int);
0231 int aoe_ktstart(struct ktstate *k);
0232 void aoe_ktstop(struct ktstate *k);
0233
0234 int aoedev_init(void);
0235 void aoedev_exit(void);
0236 struct aoedev *aoedev_by_aoeaddr(ulong maj, int min, int do_alloc);
0237 void aoedev_downdev(struct aoedev *d);
0238 int aoedev_flush(const char __user *str, size_t size);
0239 void aoe_failbuf(struct aoedev *, struct buf *);
0240 void aoedev_put(struct aoedev *);
0241
0242 int aoenet_init(void);
0243 void aoenet_exit(void);
0244 void aoenet_xmit(struct sk_buff_head *);
0245 int is_aoe_netif(struct net_device *ifp);
0246 int set_aoe_iflist(const char __user *str, size_t size);
0247
0248 extern struct workqueue_struct *aoe_wq;