-
Notifications
You must be signed in to change notification settings - Fork 17
/
dat.h
175 lines (147 loc) · 2.38 KB
/
dat.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/* dat.h: include file for vblade AoE target */
#include <sys/types.h>
#define nil ((void *)0)
/*
* tunable variables
*/
enum {
VBLADE_VERSION = 25,
// Firmware version
FWV = 0x4000 + VBLADE_VERSION,
};
#undef major
#undef minor
#undef makedev
#define major(x) ((x) >> 24 & 0xFF)
#define minor(x) ((x) & 0xffffff)
#define makedev(x, y) ((x) << 24 | (y))
typedef unsigned char uchar;
//typedef unsigned short ushort;
#ifdef __FreeBSD__
typedef unsigned long ulong;
#else
//typedef unsigned long ulong;
#endif
typedef long long vlong;
typedef struct Aoehdr Aoehdr;
typedef struct Ata Ata;
typedef struct Conf Conf;
typedef struct Ataregs Ataregs;
typedef struct Mdir Mdir;
typedef struct Aoemask Aoemask;
typedef struct Aoesrr Aoesrr;
struct Ataregs
{
vlong lba;
uchar cmd;
uchar status;
uchar err;
uchar feature;
uchar sectors;
};
struct Aoehdr
{
uchar dst[6];
uchar src[6];
ushort type;
uchar flags;
uchar error;
ushort maj;
uchar min;
uchar cmd;
uchar tag[4];
};
struct Ata
{
Aoehdr h;
uchar aflag;
uchar err;
uchar sectors;
uchar cmd;
uchar lba[6];
uchar resvd[2];
};
struct Conf
{
Aoehdr h;
ushort bufcnt;
ushort firmware;
uchar scnt;
uchar vercmd;
ushort len;
uchar data[1024];
};
// mask directive
struct Mdir {
uchar res;
uchar cmd;
uchar mac[6];
};
struct Aoemask {
Aoehdr h;
uchar res;
uchar cmd;
uchar merror;
uchar nmacs;
// struct Mdir m[0];
};
struct Aoesrr {
Aoehdr h;
uchar rcmd;
uchar nmacs;
// uchar mac[6][nmacs];
};
enum {
AoEver = 1,
ATAcmd = 0, // command codes
Config,
Mask,
Resrel,
Resp = (1<<3), // flags
Error = (1<<2),
BadCmd = 1,
BadArg,
DevUnavailable,
ConfigErr,
BadVersion,
Res,
Write = (1<<0),
Async = (1<<1),
Device = (1<<4),
Extend = (1<<6),
Qread = 0,
Qtest,
Qprefix,
Qset,
Qfset,
Nretries = 3,
Nconfig = 1024,
Bufcount = 16,
/* mask commands */
Mread= 0,
Medit,
/* mask directives */
MDnop= 0,
MDadd,
MDdel,
/* mask errors */
MEunspec= 1,
MEbaddir,
MEfull,
/* header sizes, including aoe hdr */
Naoehdr= 24,
Natahdr= Naoehdr + 12,
Ncfghdr= Naoehdr + 8,
Nmaskhdr= Naoehdr + 4,
Nsrrhdr= Naoehdr + 2,
Nserial= 20,
};
extern int shelf, slot;
extern ulong aoetag;
extern uchar mac[6];
extern int bfd; // block file descriptor
extern int sfd; // socket file descriptor
extern vlong size; // size of vblade
extern vlong offset;
extern char *progname;
extern char serial[Nserial+1];