blob: db78f826d40c5beb3ce3254954d0e938f3f774c4 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* 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
13enum {
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
34struct 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
46struct 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
60struct 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
68enum {
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
79enum {
80 MAXATADATA = 1024,
81 NPERSHELF = 10,
82 FREETAG = -1,
83 MIN_BUFS = 8,
84};
85
86struct 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
98struct 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
110struct 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
138int aoeblk_init(void);
139void aoeblk_exit(void);
140void aoeblk_gdalloc(void *);
141void aoedisk_rm_sysfs(struct aoedev *d);
142
143int aoechr_init(void);
144void aoechr_exit(void);
145void aoechr_error(char *);
146
147void aoecmd_work(struct aoedev *d);
148void aoecmd_cfg(ushort, unsigned char);
149void aoecmd_ata_rsp(struct sk_buff *);
150void aoecmd_cfg_rsp(struct sk_buff *);
151
152int aoedev_init(void);
153void aoedev_exit(void);
154struct aoedev *aoedev_bymac(unsigned char *);
155void aoedev_downdev(struct aoedev *d);
156struct aoedev *aoedev_set(ulong, unsigned char *, struct net_device *, ulong);
157int aoedev_busy(void);
158
159int aoenet_init(void);
160void aoenet_exit(void);
161void aoenet_xmit(struct sk_buff *);
162int is_aoe_netif(struct net_device *ifp);
163int set_aoe_iflist(const char __user *str, size_t size);
164
165u64 mac_addr(char addr[6]);