xref: /openbmc/linux/drivers/block/aoe/aoe.h (revision 1da177e4)
1 /* Copyright (c) 2004 Coraid, Inc.  See COPYING for GPL terms. */
2 #define VERSION "5"
3 #define AOE_MAJOR 152
4 #define DEVICE_NAME "aoe"
5 #ifndef AOE_PARTITIONS
6 #define AOE_PARTITIONS 16
7 #endif
8 #define SYSMINOR(aoemajor, aoeminor) ((aoemajor) * 10 + (aoeminor))
9 #define AOEMAJOR(sysminor) ((sysminor) / 10)
10 #define AOEMINOR(sysminor) ((sysminor) % 10)
11 #define WHITESPACE " \t\v\f\n"
12 
13 enum {
14 	AOECMD_ATA,
15 	AOECMD_CFG,
16 
17 	AOEFL_RSP = (1<<3),
18 	AOEFL_ERR = (1<<2),
19 
20 	AOEAFL_EXT = (1<<6),
21 	AOEAFL_DEV = (1<<4),
22 	AOEAFL_ASYNC = (1<<1),
23 	AOEAFL_WRITE = (1<<0),
24 
25 	AOECCMD_READ = 0,
26 	AOECCMD_TEST,
27 	AOECCMD_PTEST,
28 	AOECCMD_SET,
29 	AOECCMD_FSET,
30 
31 	AOE_HVER = 0x10,
32 };
33 
34 struct aoe_hdr {
35 	unsigned char dst[6];
36 	unsigned char src[6];
37 	unsigned char type[2];
38 	unsigned char verfl;
39 	unsigned char err;
40 	unsigned char major[2];
41 	unsigned char minor;
42 	unsigned char cmd;
43 	unsigned char tag[4];
44 };
45 
46 struct aoe_atahdr {
47 	unsigned char aflags;
48 	unsigned char errfeat;
49 	unsigned char scnt;
50 	unsigned char cmdstat;
51 	unsigned char lba0;
52 	unsigned char lba1;
53 	unsigned char lba2;
54 	unsigned char lba3;
55 	unsigned char lba4;
56 	unsigned char lba5;
57 	unsigned char res[2];
58 };
59 
60 struct aoe_cfghdr {
61 	unsigned char bufcnt[2];
62 	unsigned char fwver[2];
63 	unsigned char res;
64 	unsigned char aoeccmd;
65 	unsigned char cslen[2];
66 };
67 
68 enum {
69 	DEVFL_UP = 1,	/* device is installed in system and ready for AoE->ATA commands */
70 	DEVFL_TKILL = (1<<1),	/* flag for timer to know when to kill self */
71 	DEVFL_EXT = (1<<2),	/* device accepts lba48 commands */
72 	DEVFL_CLOSEWAIT = (1<<3), /* device is waiting for all closes to revalidate */
73 	DEVFL_WC_UPDATE = (1<<4), /* this device needs to update write cache status */
74 	DEVFL_WORKON = (1<<4),
75 
76 	BUFFL_FAIL = 1,
77 };
78 
79 enum {
80 	MAXATADATA = 1024,
81 	NPERSHELF = 10,
82 	FREETAG = -1,
83 	MIN_BUFS = 8,
84 };
85 
86 struct buf {
87 	struct list_head bufs;
88 	ulong flags;
89 	ulong nframesout;
90 	char *bufaddr;
91 	ulong resid;
92 	ulong bv_resid;
93 	sector_t sector;
94 	struct bio *bio;
95 	struct bio_vec *bv;
96 };
97 
98 struct frame {
99 	int tag;
100 	ulong waited;
101 	struct buf *buf;
102 	char *bufaddr;
103 	int writedatalen;
104 	int ndata;
105 
106 	/* largest possible */
107 	unsigned char data[sizeof(struct aoe_hdr) + sizeof(struct aoe_atahdr)];
108 };
109 
110 struct aoedev {
111 	struct aoedev *next;
112 	unsigned char addr[6];	/* remote mac addr */
113 	ushort flags;
114 	ulong sysminor;
115 	ulong aoemajor;
116 	ulong aoeminor;
117 	ulong nopen;		/* (bd_openers isn't available without sleeping) */
118 	ulong rttavg;		/* round trip average of requests/responses */
119 	u16 fw_ver;		/* version of blade's firmware */
120 	struct work_struct work;/* disk create work struct */
121 	struct gendisk *gd;
122 	request_queue_t blkq;
123 	struct hd_geometry geo;
124 	sector_t ssize;
125 	struct timer_list timer;
126 	spinlock_t lock;
127 	struct net_device *ifp;	/* interface ed is attached to */
128 	struct sk_buff *skblist;/* packets needing to be sent */
129 	mempool_t *bufpool;	/* for deadlock-free Buf allocation */
130 	struct list_head bufq;	/* queue of bios to work on */
131 	struct buf *inprocess;	/* the one we're currently working on */
132 	ulong lasttag;		/* last tag sent */
133 	ulong nframes;		/* number of frames below */
134 	struct frame *frames;
135 };
136 
137 
138 int aoeblk_init(void);
139 void aoeblk_exit(void);
140 void aoeblk_gdalloc(void *);
141 void aoedisk_rm_sysfs(struct aoedev *d);
142 
143 int aoechr_init(void);
144 void aoechr_exit(void);
145 void aoechr_error(char *);
146 
147 void aoecmd_work(struct aoedev *d);
148 void aoecmd_cfg(ushort, unsigned char);
149 void aoecmd_ata_rsp(struct sk_buff *);
150 void aoecmd_cfg_rsp(struct sk_buff *);
151 
152 int aoedev_init(void);
153 void aoedev_exit(void);
154 struct aoedev *aoedev_bymac(unsigned char *);
155 void aoedev_downdev(struct aoedev *d);
156 struct aoedev *aoedev_set(ulong, unsigned char *, struct net_device *, ulong);
157 int aoedev_busy(void);
158 
159 int aoenet_init(void);
160 void aoenet_exit(void);
161 void aoenet_xmit(struct sk_buff *);
162 int is_aoe_netif(struct net_device *ifp);
163 int set_aoe_iflist(const char __user *str, size_t size);
164 
165 u64 mac_addr(char addr[6]);
166