1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #ifndef _VNIC_DEVCMD_H_
19 #define _VNIC_DEVCMD_H_
20
21 #define _CMD_NBITS 14
22 #define _CMD_VTYPEBITS 10
23 #define _CMD_FLAGSBITS 6
24 #define _CMD_DIRBITS 2
25
26 #define _CMD_NMASK ((1 << _CMD_NBITS)-1)
27 #define _CMD_VTYPEMASK ((1 << _CMD_VTYPEBITS)-1)
28 #define _CMD_FLAGSMASK ((1 << _CMD_FLAGSBITS)-1)
29 #define _CMD_DIRMASK ((1 << _CMD_DIRBITS)-1)
30
31 #define _CMD_NSHIFT 0
32 #define _CMD_VTYPESHIFT (_CMD_NSHIFT+_CMD_NBITS)
33 #define _CMD_FLAGSSHIFT (_CMD_VTYPESHIFT+_CMD_VTYPEBITS)
34 #define _CMD_DIRSHIFT (_CMD_FLAGSSHIFT+_CMD_FLAGSBITS)
35
36
37
38
39 #define _CMD_DIR_NONE 0U
40 #define _CMD_DIR_WRITE 1U
41 #define _CMD_DIR_READ 2U
42 #define _CMD_DIR_RW (_CMD_DIR_WRITE | _CMD_DIR_READ)
43
44
45
46
47 #define _CMD_FLAGS_NONE 0U
48 #define _CMD_FLAGS_NOWAIT 1U
49
50
51
52
53 #define _CMD_VTYPE_NONE 0U
54 #define _CMD_VTYPE_ENET 1U
55 #define _CMD_VTYPE_FC 2U
56 #define _CMD_VTYPE_SCSI 4U
57 #define _CMD_VTYPE_ALL (_CMD_VTYPE_ENET | _CMD_VTYPE_FC | _CMD_VTYPE_SCSI)
58
59
60
61
62 #define _CMDCF(dir, flags, vtype, nr) \
63 (((dir) << _CMD_DIRSHIFT) | \
64 ((flags) << _CMD_FLAGSSHIFT) | \
65 ((vtype) << _CMD_VTYPESHIFT) | \
66 ((nr) << _CMD_NSHIFT))
67 #define _CMDC(dir, vtype, nr) _CMDCF(dir, 0, vtype, nr)
68 #define _CMDCNW(dir, vtype, nr) _CMDCF(dir, _CMD_FLAGS_NOWAIT, vtype, nr)
69
70
71
72
73 #define _CMD_DIR(cmd) (((cmd) >> _CMD_DIRSHIFT) & _CMD_DIRMASK)
74 #define _CMD_FLAGS(cmd) (((cmd) >> _CMD_FLAGSSHIFT) & _CMD_FLAGSMASK)
75 #define _CMD_VTYPE(cmd) (((cmd) >> _CMD_VTYPESHIFT) & _CMD_VTYPEMASK)
76 #define _CMD_N(cmd) (((cmd) >> _CMD_NSHIFT) & _CMD_NMASK)
77
78 enum vnic_devcmd_cmd {
79 CMD_NONE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_NONE, 0),
80
81
82 CMD_MCPU_FW_INFO = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 1),
83
84
85
86
87 CMD_DEV_SPEC = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 2),
88
89
90 CMD_STATS_CLEAR = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 3),
91
92
93
94 CMD_STATS_DUMP = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 4),
95
96
97 CMD_NIC_CFG = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 16),
98
99
100
101
102
103
104
105
106
107 CMD_NOTIFY = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 21),
108
109
110 CMD_OPEN = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 23),
111
112
113
114 CMD_OPEN_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 24),
115
116
117 CMD_CLOSE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 25),
118
119
120 CMD_INIT = _CMDCNW(_CMD_DIR_READ, _CMD_VTYPE_ALL, 26),
121
122
123 CMD_ENABLE = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 28),
124
125
126 CMD_ENABLE_WAIT = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 28),
127
128
129 CMD_DISABLE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 29),
130
131
132 CMD_STATS_DUMP_ALL = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 30),
133
134
135
136
137 CMD_INIT_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 31),
138
139
140 CMD_DEINIT = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 34),
141
142
143
144
145 CMD_CAPABILITY = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 36),
146
147
148
149
150
151
152 CMD_INITIALIZE_DEVCMD2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 57)
153 };
154
155
156 #define CMD_OPENF_OPROM 0x1
157
158
159 #define CMD_INITF_DEFAULT_MAC 0x1
160
161
162 #define CMD_PFILTER_DIRECTED 0x01
163 #define CMD_PFILTER_MULTICAST 0x02
164 #define CMD_PFILTER_BROADCAST 0x04
165 #define CMD_PFILTER_PROMISCUOUS 0x08
166 #define CMD_PFILTER_ALL_MULTICAST 0x10
167
168 enum vnic_devcmd_status {
169 STAT_NONE = 0,
170 STAT_BUSY = 1 << 0,
171 STAT_ERROR = 1 << 1,
172 };
173
174 enum vnic_devcmd_error {
175 ERR_SUCCESS = 0,
176 ERR_EINVAL = 1,
177 ERR_EFAULT = 2,
178 ERR_EPERM = 3,
179 ERR_EBUSY = 4,
180 ERR_ECMDUNKNOWN = 5,
181 ERR_EBADSTATE = 6,
182 ERR_ENOMEM = 7,
183 ERR_ETIMEDOUT = 8,
184 ERR_ELINKDOWN = 9,
185 };
186
187 struct vnic_devcmd_fw_info {
188 char fw_version[32];
189 char fw_build[32];
190 char hw_version[32];
191 char hw_serial_number[32];
192 };
193
194 struct vnic_devcmd_notify {
195 u32 csum;
196
197 u32 link_state;
198 u32 port_speed;
199 u32 mtu;
200 u32 msglvl;
201 u32 uif;
202 u32 status;
203 u32 error;
204 u32 link_down_cnt;
205 };
206 #define VNIC_STF_FATAL_ERR 0x0001
207
208 struct vnic_devcmd_provinfo {
209 u8 oui[3];
210 u8 type;
211 u8 data[0];
212 };
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228 #define VNIC_DEVCMD_NARGS 15
229 struct vnic_devcmd {
230 u32 status;
231 u32 cmd;
232 u64 args[VNIC_DEVCMD_NARGS];
233 };
234
235
236
237
238
239
240
241
242
243
244
245
246 #define DEVCMD2_FNORESULT 0x1
247
248 #define VNIC_DEVCMD2_NARGS VNIC_DEVCMD_NARGS
249 struct vnic_devcmd2 {
250 u16 pad;
251 u16 flags;
252 u32 cmd;
253 u64 args[VNIC_DEVCMD2_NARGS];
254 };
255
256 #define VNIC_DEVCMD2_NRESULTS VNIC_DEVCMD_NARGS
257 struct devcmd2_result {
258 u64 results[VNIC_DEVCMD2_NRESULTS];
259 u32 pad;
260 u16 completed_index;
261 u8 error;
262 u8 color;
263 };
264
265 #define DEVCMD2_RING_SIZE 32
266 #define DEVCMD2_DESC_SIZE 128
267
268 #define DEVCMD2_RESULTS_SIZE_MAX ((1 << 16) - 1)
269
270 #endif