1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2008-2017 Cisco Systems, Inc. All rights reserved.
3 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
4 */
5
6 #ifndef _VNIC_DEVCMD_H_
7 #define _VNIC_DEVCMD_H_
8
9 #define _CMD_NBITS 14
10 #define _CMD_VTYPEBITS 10
11 #define _CMD_FLAGSBITS 6
12 #define _CMD_DIRBITS 2
13
14 #define _CMD_NMASK ((1 << _CMD_NBITS)-1)
15 #define _CMD_VTYPEMASK ((1 << _CMD_VTYPEBITS)-1)
16 #define _CMD_FLAGSMASK ((1 << _CMD_FLAGSBITS)-1)
17 #define _CMD_DIRMASK ((1 << _CMD_DIRBITS)-1)
18
19 #define _CMD_NSHIFT 0
20 #define _CMD_VTYPESHIFT (_CMD_NSHIFT+_CMD_NBITS)
21 #define _CMD_FLAGSSHIFT (_CMD_VTYPESHIFT+_CMD_VTYPEBITS)
22 #define _CMD_DIRSHIFT (_CMD_FLAGSSHIFT+_CMD_FLAGSBITS)
23
24 /*
25 * Direction bits (from host perspective).
26 */
27 #define _CMD_DIR_NONE 0U
28 #define _CMD_DIR_WRITE 1U
29 #define _CMD_DIR_READ 2U
30 #define _CMD_DIR_RW (_CMD_DIR_WRITE | _CMD_DIR_READ)
31
32 /*
33 * Flag bits.
34 */
35 #define _CMD_FLAGS_NONE 0U
36 #define _CMD_FLAGS_NOWAIT 1U
37
38 /*
39 * vNIC type bits.
40 */
41 #define _CMD_VTYPE_NONE 0U
42 #define _CMD_VTYPE_ENET 1U
43 #define _CMD_VTYPE_FC 2U
44 #define _CMD_VTYPE_SCSI 4U
45 #define _CMD_VTYPE_ALL (_CMD_VTYPE_ENET | _CMD_VTYPE_FC | _CMD_VTYPE_SCSI)
46
47 /*
48 * Used to create cmds..
49 */
50 #define _CMDCF(dir, flags, vtype, nr) \
51 (((dir) << _CMD_DIRSHIFT) | \
52 ((flags) << _CMD_FLAGSSHIFT) | \
53 ((vtype) << _CMD_VTYPESHIFT) | \
54 ((nr) << _CMD_NSHIFT))
55 #define _CMDC(dir, vtype, nr) _CMDCF(dir, 0, vtype, nr)
56 #define _CMDCNW(dir, vtype, nr) _CMDCF(dir, _CMD_FLAGS_NOWAIT, vtype, nr)
57
58 /*
59 * Used to decode cmds..
60 */
61 #define _CMD_DIR(cmd) (((cmd) >> _CMD_DIRSHIFT) & _CMD_DIRMASK)
62 #define _CMD_FLAGS(cmd) (((cmd) >> _CMD_FLAGSSHIFT) & _CMD_FLAGSMASK)
63 #define _CMD_VTYPE(cmd) (((cmd) >> _CMD_VTYPESHIFT) & _CMD_VTYPEMASK)
64 #define _CMD_N(cmd) (((cmd) >> _CMD_NSHIFT) & _CMD_NMASK)
65
66 #define ARRAY_SIZE(x) RTE_DIM(x)
67
68 enum vnic_devcmd_cmd {
69 CMD_NONE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_NONE, 0),
70
71 /*
72 * mcpu fw info in mem:
73 * in:
74 * (uint64_t)a0=paddr to struct vnic_devcmd_fw_info
75 * action:
76 * Fills in struct vnic_devcmd_fw_info (128 bytes)
77 * note:
78 * An old definition of CMD_MCPU_FW_INFO
79 */
80 CMD_MCPU_FW_INFO_OLD = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 1),
81
82 /*
83 * mcpu fw info in mem:
84 * in:
85 * (uint64_t)a0=paddr to struct vnic_devcmd_fw_info
86 * (uint16_t)a1=size of the structure
87 * out:
88 * (uint16_t)a1=0 for in:a1 = 0,
89 * data size actually written for other values.
90 * action:
91 * Fills in first 128 bytes of vnic_devcmd_fw_info for in:a1 = 0,
92 * first in:a1 bytes for 0 < in:a1 <= 132,
93 * 132 bytes for other values of in:a1.
94 * note:
95 * CMD_MCPU_FW_INFO and CMD_MCPU_FW_INFO_OLD have the same enum 1
96 * for source compatibility.
97 */
98 CMD_MCPU_FW_INFO = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 1),
99
100 /* dev-specific block member:
101 * in: (uint16_t)a0=offset,(uint8_t)a1=size
102 * out: a0=value
103 */
104 CMD_DEV_SPEC = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 2),
105
106 /* stats clear */
107 CMD_STATS_CLEAR = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 3),
108
109 /* stats dump in mem: (uint64_t)a0=paddr to stats area,
110 * (uint16_t)a1=sizeof stats area
111 */
112 CMD_STATS_DUMP = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 4),
113
114 /* set Rx packet filter: (uint32_t)a0=filters (see CMD_PFILTER_*) */
115 CMD_PACKET_FILTER = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 7),
116
117 /* set Rx packet filter for all: (uint32_t)a0=filters
118 * (see CMD_PFILTER_*)
119 */
120 CMD_PACKET_FILTER_ALL = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 7),
121
122 /* hang detection notification */
123 CMD_HANG_NOTIFY = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 8),
124
125 /* MAC address in (u48)a0 */
126 CMD_MAC_ADDR = _CMDC(_CMD_DIR_READ,
127 _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 9),
128 #define CMD_GET_MAC_ADDR CMD_MAC_ADDR /* some uses are aliased */
129
130 /* add addr from (u48)a0 */
131 CMD_ADDR_ADD = _CMDCNW(_CMD_DIR_WRITE,
132 _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 12),
133
134 /* del addr from (u48)a0 */
135 CMD_ADDR_DEL = _CMDCNW(_CMD_DIR_WRITE,
136 _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 13),
137
138 /* add VLAN id in (uint16_t)a0 */
139 CMD_VLAN_ADD = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 14),
140
141 /* del VLAN id in (uint16_t)a0 */
142 CMD_VLAN_DEL = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 15),
143
144 /*
145 * nic_cfg in (uint32_t)a0
146 *
147 * Capability query:
148 * out: (uint64_t) a0= 1 if a1 is valid
149 * (uint64_t) a1= (NIC_CFG bits supported) | (flags << 32)
150 * (flags are CMD_NIC_CFG_CAPF_xxx)
151 */
152 CMD_NIC_CFG = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 16),
153
154 /*
155 * nic_cfg_chk (same as nic_cfg, but may return error)
156 * in (uint32_t)a0
157 *
158 * Capability query:
159 * out: (uint64_t) a0= 1 if a1 is valid
160 * (uint64_t) a1= (NIC_CFG bits supported) | (flags << 32)
161 * (flags are CMD_NIC_CFG_CAPF_xxx)
162 */
163 CMD_NIC_CFG_CHK = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 16),
164
165 /* union vnic_rss_key in mem: (uint64_t)a0=paddr, (uint16_t)a1=len */
166 CMD_RSS_KEY = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 17),
167
168 /* union vnic_rss_cpu in mem: (uint64_t)a0=paddr, (uint16_t)a1=len */
169 CMD_RSS_CPU = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 18),
170
171 /* initiate softreset */
172 CMD_SOFT_RESET = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 19),
173
174 /* softreset status:
175 * out: a0=0 reset complete, a0=1 reset in progress */
176 CMD_SOFT_RESET_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 20),
177
178 /* set struct vnic_devcmd_notify buffer in mem:
179 * in:
180 * (uint64_t)a0=paddr to notify (set paddr=0 to unset)
181 * (uint32_t)a1 & 0x00000000ffffffff=sizeof(struct vnic_devcmd_notify)
182 * (uint16_t)a1 & 0x0000ffff00000000=intr num (-1 for no intr)
183 * out:
184 * (uint32_t)a1 = effective size
185 */
186 CMD_NOTIFY = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 21),
187
188 /* UNDI API: (uint64_t)a0=paddr to s_PXENV_UNDI_ struct,
189 * (uint8_t)a1=PXENV_UNDI_xxx
190 */
191 CMD_UNDI = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 22),
192
193 /* initiate open sequence (uint32_t)a0=flags (see CMD_OPENF_*) */
194 CMD_OPEN = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 23),
195
196 /* open status:
197 * out: a0=0 open complete, a0=1 open in progress */
198 CMD_OPEN_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 24),
199
200 /* close vnic */
201 CMD_CLOSE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 25),
202
203 /* initialize virtual link: (uint32_t)a0=flags (see CMD_INITF_*) */
204 /***** Replaced by CMD_INIT *****/
205 CMD_INIT_v1 = _CMDCNW(_CMD_DIR_READ, _CMD_VTYPE_ALL, 26),
206
207 /* variant of CMD_INIT, with provisioning info
208 * (uint64_t)a0=paddr of vnic_devcmd_provinfo
209 * (uint32_t)a1=sizeof provision info
210 */
211 CMD_INIT_PROV_INFO = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 27),
212
213 /* enable virtual link */
214 CMD_ENABLE = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 28),
215
216 /* enable virtual link, waiting variant. */
217 CMD_ENABLE_WAIT = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 28),
218
219 /* disable virtual link */
220 CMD_DISABLE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 29),
221
222 /* stats dump sum of all vnic stats on same uplink in mem:
223 * (uint64_t)a0=paddr
224 * (uint16_t)a1=sizeof stats area
225 */
226 CMD_STATS_DUMP_ALL = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 30),
227
228 /* init status:
229 * out: a0=0 init complete, a0=1 init in progress
230 * if a0=0, a1=errno
231 */
232 CMD_INIT_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 31),
233
234 /* INT13 API: (uint64_t)a0=paddr to vnic_int13_params struct
235 * (uint32_t)a1=INT13_CMD_xxx
236 */
237 CMD_INT13 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_FC, 32),
238
239 /* logical uplink enable/disable: (uint64_t)a0: 0/1=disable/enable */
240 CMD_LOGICAL_UPLINK = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 33),
241
242 /* undo initialize of virtual link */
243 CMD_DEINIT = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 34),
244
245 /* initialize virtual link: (uint32_t)a0=flags (see CMD_INITF_*) */
246 CMD_INIT = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 35),
247
248 /* check fw capability of a cmd:
249 * in: (uint32_t)a0=cmd
250 * out: (uint32_t)a0=errno, 0:valid cmd, a1=supported VNIC_STF_* bits
251 */
252 CMD_CAPABILITY = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 36),
253
254 /* persistent binding info
255 * in: (uint64_t)a0=paddr of arg
256 * (uint32_t)a1=CMD_PERBI_XXX
257 */
258 CMD_PERBI = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_FC, 37),
259
260 /* Interrupt Assert Register functionality
261 * in: (uint16_t)a0=interrupt number to assert
262 */
263 CMD_IAR = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 38),
264
265 /* initiate hangreset, like softreset after hang detected */
266 CMD_HANG_RESET = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 39),
267
268 /* hangreset status:
269 * out: a0=0 reset complete, a0=1 reset in progress
270 */
271 CMD_HANG_RESET_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 40),
272
273 /*
274 * Set hw ingress packet vlan rewrite mode:
275 * in: (uint32_t)a0=new vlan rewrite mode
276 * out: (uint32_t)a0=old vlan rewrite mode
277 */
278 CMD_IG_VLAN_REWRITE_MODE = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 41),
279
280 /*
281 * in: (uint16_t)a0=bdf of target vnic
282 * (uint32_t)a1=cmd to proxy
283 * a2-a15=args to cmd in a1
284 * out: (uint32_t)a0=status of proxied cmd
285 * a1-a15=out args of proxied cmd
286 */
287 CMD_PROXY_BY_BDF = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 42),
288
289 /*
290 * As for BY_BDF except a0 is index of hvnlink subordinate vnic
291 * or SR-IOV virtual vnic
292 */
293 CMD_PROXY_BY_INDEX = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 43),
294
295 /*
296 * For HPP toggle:
297 * adapter-info-get
298 * in: (uint64_t)a0=phsical address of buffer passed in from caller.
299 * (uint16_t)a1=size of buffer specified in a0.
300 * out: (uint64_t)a0=phsical address of buffer passed in from caller.
301 * (uint16_t)a1=actual bytes from VIF-CONFIG-INFO TLV, or
302 * 0 if no VIF-CONFIG-INFO TLV was ever received.
303 */
304 CMD_CONFIG_INFO_GET = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 44),
305
306 /*
307 * INT13 API: (uint64_t)a0=paddr to vnic_int13_params struct
308 * (uint32_t)a1=INT13_CMD_xxx
309 */
310 CMD_INT13_ALL = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 45),
311
312 /*
313 * Set default vlan:
314 * in: (uint16_t)a0=new default vlan
315 * (uint16_t)a1=zero for overriding vlan with param a0,
316 * non-zero for resetting vlan to the default
317 * out: (uint16_t)a0=old default vlan
318 */
319 CMD_SET_DEFAULT_VLAN = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 46),
320
321 /* init_prov_info2:
322 * Variant of CMD_INIT_PROV_INFO, where it will not try to enable
323 * the vnic until CMD_ENABLE2 is issued.
324 * (uint64_t)a0=paddr of vnic_devcmd_provinfo
325 * (uint32_t)a1=sizeof provision info
326 */
327 CMD_INIT_PROV_INFO2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 47),
328
329 /* enable2:
330 * (uint32_t)a0=0 ==> standby
331 * =CMD_ENABLE2_ACTIVE ==> active
332 */
333 CMD_ENABLE2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 48),
334
335 /*
336 * cmd_status:
337 * Returns the status of the specified command
338 * Input:
339 * a0 = command for which status is being queried.
340 * Possible values are:
341 * CMD_SOFT_RESET
342 * CMD_HANG_RESET
343 * CMD_OPEN
344 * CMD_INIT
345 * CMD_INIT_PROV_INFO
346 * CMD_DEINIT
347 * CMD_INIT_PROV_INFO2
348 * CMD_ENABLE2
349 * Output:
350 * if status == STAT_ERROR
351 * a0 = ERR_ENOTSUPPORTED - status for command in a0 is
352 * not supported
353 * if status == STAT_NONE
354 * a0 = status of the devcmd specified in a0 as follows.
355 * ERR_SUCCESS - command in a0 completed successfully
356 * ERR_EINPROGRESS - command in a0 is still in progress
357 */
358 CMD_STATUS = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 49),
359
360 /*
361 * Returns interrupt coalescing timer conversion factors.
362 * After calling this devcmd, ENIC driver can convert
363 * interrupt coalescing timer in usec into CPU cycles as follows:
364 *
365 * intr_timer_cycles = intr_timer_usec * multiplier / divisor
366 *
367 * Interrupt coalescing timer in usecs can be be converted/obtained
368 * from CPU cycles as follows:
369 *
370 * intr_timer_usec = intr_timer_cycles * divisor / multiplier
371 *
372 * in: none
373 * out: (uint32_t)a0 = multiplier
374 * (uint32_t)a1 = divisor
375 * (uint32_t)a2 = maximum timer value in usec
376 */
377 CMD_INTR_COAL_CONVERT = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 50),
378
379 /*
380 * ISCSI DUMP API:
381 * in: (uint64_t)a0=paddr of the param or param itself
382 * (uint32_t)a1=ISCSI_CMD_xxx
383 */
384 CMD_ISCSI_DUMP_REQ = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 51),
385
386 /*
387 * ISCSI DUMP STATUS API:
388 * in: (uint32_t)a0=cmd tag
389 * in: (uint32_t)a1=ISCSI_CMD_xxx
390 * out: (uint32_t)a0=cmd status
391 */
392 CMD_ISCSI_DUMP_STATUS = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 52),
393
394 /*
395 * Subvnic migration from MQ <--> VF.
396 * Enable the LIF migration from MQ to VF and vice versa. MQ and VF
397 * indexes are statically bound at the time of initialization.
398 * Based on the direction of migration, the resources of either MQ or
399 * the VF shall be attached to the LIF.
400 * in: (uint32_t)a0=Direction of Migration
401 * 0=> Migrate to VF
402 * 1=> Migrate to MQ
403 * (uint32_t)a1=VF index (MQ index)
404 */
405 CMD_MIGRATE_SUBVNIC = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 53),
406
407 /*
408 * Register / Deregister the notification block for MQ subvnics
409 * in:
410 * (uint64_t)a0=paddr to notify (set paddr=0 to unset)
411 * (uint32_t)a1 & 0x00000000ffffffff=sizeof(struct vnic_devcmd_notify)
412 * (uint16_t)a1 & 0x0000ffff00000000=intr num (-1 for no intr)
413 * out:
414 * (uint32_t)a1 = effective size
415 */
416 CMD_SUBVNIC_NOTIFY = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 54),
417
418 /*
419 * Set the predefined mac address as default
420 * in:
421 * (u48)a0=mac addr
422 */
423 CMD_SET_MAC_ADDR = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 55),
424
425 /* Update the provisioning info of the given VIF
426 * (uint64_t)a0=paddr of vnic_devcmd_provinfo
427 * (uint32_t)a1=sizeof provision info
428 */
429 CMD_PROV_INFO_UPDATE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 56),
430
431 /*
432 * Initialization for the devcmd2 interface.
433 * in: (uint64_t) a0=host result buffer physical address
434 * in: (uint16_t) a1=number of entries in result buffer
435 */
436 CMD_INITIALIZE_DEVCMD2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 57),
437
438 /*
439 * Add a filter.
440 * in: (uint64_t) a0= filter address
441 * (uint32_t) a1= size of filter
442 * out: (uint32_t) a0=filter identifier
443 *
444 * Capability query:
445 * out: (uint64_t) a0= 1 if capability query supported
446 * (uint64_t) a1= MAX filter type supported
447 */
448 CMD_ADD_FILTER = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 58),
449
450 /*
451 * Delete a filter.
452 * in: (uint32_t) a0=filter identifier
453 */
454 CMD_DEL_FILTER = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 59),
455
456 /*
457 * Enable a Queue Pair in User space NIC
458 * in: (uint32_t) a0=Queue Pair number
459 * (uint32_t) a1= command
460 */
461 CMD_QP_ENABLE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 60),
462
463 /*
464 * Disable a Queue Pair in User space NIC
465 * in: (uint32_t) a0=Queue Pair number
466 * (uint32_t) a1= command
467 */
468 CMD_QP_DISABLE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 61),
469
470 /*
471 * Stats dump Queue Pair in User space NIC
472 * in: (uint32_t) a0=Queue Pair number
473 * (uint64_t) a1=host buffer addr for status dump
474 * (uint32_t) a2=length of the buffer
475 */
476 CMD_QP_STATS_DUMP = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 62),
477
478 /*
479 * Clear stats for Queue Pair in User space NIC
480 * in: (uint32_t) a0=Queue Pair number
481 */
482 CMD_QP_STATS_CLEAR = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 63),
483
484 /*
485 * UEFI BOOT API: (uint64_t)a0= UEFI FLS_CMD_xxx
486 * (ui64)a1= paddr for the info buffer
487 */
488 CMD_FC_REQ = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_FC, 64),
489
490 /*
491 * Return the iSCSI config details required by the EFI Option ROM
492 * in: (uint32_t) a0=0 Get Boot Info for PXE eNIC as per
493 * pxe_boot_config_t
494 * a0=1 Get Boot info for iSCSI enic as per
495 * iscsi_boot_efi_cfg_t
496 * in: (uint64_t) a1=Host address where iSCSI config info is returned
497 */
498 CMD_VNIC_BOOT_CONFIG_INFO = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 65),
499
500 /*
501 * Create a Queue Pair (RoCE)
502 * in: (uint32_t) a0 = Queue Pair number
503 * (uint32_t) a1 = Remote QP
504 * (uint32_t) a2 = RDMA-RQ
505 * (uint16_t) a3 = RQ Res Group
506 * (uint16_t) a4 = SQ Res Group
507 * (uint32_t) a5 = Protection Domain
508 * (uint64_t) a6 = Remote MAC
509 * (uint32_t) a7 = start PSN
510 * (uint16_t) a8 = MSS
511 * (uint32_t) a9 = protocol version
512 */
513 CMD_RDMA_QP_CREATE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 66),
514
515 /*
516 * Delete a Queue Pair (RoCE)
517 * in: (uint32_t) a0 = Queue Pair number
518 */
519 CMD_RDMA_QP_DELETE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 67),
520
521 /*
522 * Retrieve a Queue Pair's status information (RoCE)
523 * in: (uint32_t) a0 = Queue Pair number
524 * (uint64_t) a1 = host buffer addr for QP status struct
525 * (uint32_t) a2 = length of the buffer
526 */
527 CMD_RDMA_QP_STATUS = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 68),
528
529 /*
530 * Use this devcmd for agreeing on the highest common version supported
531 * by both driver and fw for by features who need such a facility.
532 * in: (uint64_t) a0 = feature (driver requests for the supported
533 * versions on this feature)
534 * out: (uint64_t) a0 = bitmap of all supported versions for that
535 * feature
536 */
537 CMD_GET_SUPP_FEATURE_VER = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 69),
538
539 /*
540 * Initialize the RDMA notification work queue
541 * in: (uint64_t) a0 = host buffer address
542 * in: (uint16_t) a1 = number of entries in buffer
543 * in: (uint16_t) a2 = resource group number
544 * in: (uint16_t) a3 = CQ number to post completion
545 */
546 CMD_RDMA_INIT_INFO_BUF = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 70),
547
548 /*
549 * De-init the RDMA notification work queue
550 * in: (uint64_t) a0=resource group number
551 */
552 CMD_RDMA_DEINIT_INFO_BUF = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 71),
553
554 /*
555 * Control (Enable/Disable) overlay offloads on the given vnic
556 * in: (uint8_t) a0 = OVERLAY_FEATURE_NVGRE : NVGRE
557 * a0 = OVERLAY_FEATURE_VXLAN : VxLAN
558 * a0 = OVERLAY_FEATURE_GENEVE : Geneve
559 * in: (uint8_t) a1 = OVERLAY_OFFLOAD_ENABLE : Enable or
560 * a1 = OVERLAY_OFFLOAD_DISABLE : Disable or
561 * a1 = OVERLAY_OFFLOAD_ENABLE_V2 : Enable with version 2
562 */
563 CMD_OVERLAY_OFFLOAD_CTRL =
564 _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 72),
565
566 /*
567 * Configuration of overlay offloads feature on a given vNIC
568 * in: (uint8_t) a0 = OVERLAY_CFG_VXLAN_PORT_UPDATE : VxLAN
569 * OVERLAY_CFG_GENEVE_PORT_UPDATE : Geneve
570 * in: (uint16_t) a1 = unsigned short int port information
571 */
572 CMD_OVERLAY_OFFLOAD_CFG = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 73),
573
574 /*
575 * Return the configured name for the device
576 * in: (uint64_t) a0=Host address where the name is copied
577 * (uint32_t) a1=Size of the buffer
578 */
579 CMD_GET_CONFIG_NAME = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 74),
580
581 /*
582 * Enable group interrupt for the VF
583 * in: (uint32_t) a0 = GRPINTR_ENABLE : enable
584 * a0 = GRPINTR_DISABLE : disable
585 * a0 = GRPINTR_UPD_VECT: update group vector addr
586 * in: (uint32_t) a1 = interrupt group count
587 * in: (uint64_t) a2 = Start of host buffer address for DMAing group
588 * vector bitmap
589 * in: (uint64_t) a3 = Stride between group vectors
590 */
591 CMD_CONFIG_GRPINTR = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 75),
592
593 /*
594 * Set cq arrary base and size in a list of consective wqs and
595 * rqs for a device
596 * in: (uint16_t) a0 = the wq relative index in the device.
597 * -1 indicates skipping wq configuration
598 * in: (uint16_t) a1 = the wcq relative index in the device
599 * in: (uint16_t) a2 = the rq relative index in the device
600 * -1 indicates skipping rq configuration
601 * in: (uint16_t) a3 = the rcq relative index in the device
602 */
603 CMD_CONFIG_CQ_ARRAY = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 76),
604
605 /*
606 * Add an advanced filter.
607 * in: (uint64_t) a0= filter address
608 * (uint32_t) a1= size of filter
609 * out: (uint32_t) a0=filter identifier
610 *
611 * Capability query:
612 * in: (uint64_t) a1= supported filter capability exchange modes
613 * out: (uint64_t) a0= 1 if capability query supported
614 * if (uint64_t) a1 = 0: a1 = MAX filter type supported
615 * if (uint64_t) a1 & FILTER_CAP_MODE_V1_FLAG:
616 * a1 = bitmask of supported filters
617 * a2 = FILTER_CAP_MODE_V1
618 * a3 = bitmask of supported actions
619 */
620 CMD_ADD_ADV_FILTER = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 77),
621
622 /*
623 * Perform a Flow Manager Operation (see flowman_api.h)
624 * in: (uint32_t) a0 = sub-command
625 * (uint64_t) a1..15 = (sub-command specific)
626 *
627 * All arguments that have not been assigned a meaning should be
628 * initialized to 0 to allow for better driver forward compatibility.
629 */
630 CMD_FLOW_MANAGER_OP = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 88),
631
632 /*
633 * Set extended CQ field in MREGS of RQ (or all RQs)
634 * for given vNIC
635 * in: (u64) a0 = RQ selection (VNIC_RQ_ALL for all RQs)
636 * (u32) a1 = CQ entry size
637 * VNIC_RQ_CQ_ENTRY_SIZE_16 --> 16 bytes
638 * VNIC_RQ_CQ_ENTRY_SIZE_32 --> 32 bytes
639 * VNIC_RQ_CQ_ENTRY_SIZE_64 --> 64 bytes
640 *
641 * Capability query:
642 * out: (u32) a0 = errno, 0:valid cmd
643 * (u32) a1 = value consisting of supported entries
644 * bit 0: 16 bytes
645 * bit 1: 32 bytes
646 * bit 2: 64 bytes
647 */
648 CMD_CQ_ENTRY_SIZE_SET = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 90),
649 };
650
651 /* Modes for exchanging advanced filter capabilities. The modes supported by
652 * the driver are passed in the CMD_ADD_ADV_FILTER capability command and the
653 * mode selected is returned.
654 * V0: the maximum filter type supported is returned
655 * V1: bitmasks of supported filters and actions are returned
656 */
657 enum filter_cap_mode {
658 FILTER_CAP_MODE_V0 = 0, /* Must always be 0 for legacy drivers */
659 FILTER_CAP_MODE_V1 = 1,
660 };
661 #define FILTER_CAP_MODE_V1_FLAG (1 << FILTER_CAP_MODE_V1)
662
663 /* CMD_ENABLE2 flags */
664 #define CMD_ENABLE2_STANDBY 0x0
665 #define CMD_ENABLE2_ACTIVE 0x1
666
667 /* flags for CMD_OPEN */
668 #define CMD_OPENF_OPROM 0x1 /* open coming from option rom */
669 #define CMD_OPENF_IG_DESCCACHE 0x2 /* Do not flush IG DESC cache */
670
671 /* flags for CMD_INIT */
672 #define CMD_INITF_DEFAULT_MAC 0x1 /* init with default mac addr */
673
674 /* flags for CMD_NIC_CFG */
675 #define CMD_NIC_CFG_CAPF_UDP_WEAK (1ULL << 0) /* Bodega-style UDP RSS */
676
677 /* flags for CMD_PACKET_FILTER */
678 #define CMD_PFILTER_DIRECTED 0x01
679 #define CMD_PFILTER_MULTICAST 0x02
680 #define CMD_PFILTER_BROADCAST 0x04
681 #define CMD_PFILTER_PROMISCUOUS 0x08
682 #define CMD_PFILTER_ALL_MULTICAST 0x10
683
684 /* Commands for CMD_QP_ENABLE/CM_QP_DISABLE */
685 #define CMD_QP_RQWQ 0x0
686
687 /* rewrite modes for CMD_IG_VLAN_REWRITE_MODE */
688 #define IG_VLAN_REWRITE_MODE_DEFAULT_TRUNK 0
689 #define IG_VLAN_REWRITE_MODE_UNTAG_DEFAULT_VLAN 1
690 #define IG_VLAN_REWRITE_MODE_PRIORITY_TAG_DEFAULT_VLAN 2
691 #define IG_VLAN_REWRITE_MODE_PASS_THRU 3
692
693 enum vnic_devcmd_status {
694 STAT_NONE = 0,
695 STAT_BUSY = 1 << 0, /* cmd in progress */
696 STAT_ERROR = 1 << 1, /* last cmd caused error (code in a0) */
697 STAT_FAILOVER = 1 << 2, /* always set on vnics in pci standby state
698 * if seen a failover to the standby happened
699 */
700 };
701
702 enum vnic_devcmd_error {
703 ERR_SUCCESS = 0,
704 ERR_EINVAL = 1,
705 ERR_EFAULT = 2,
706 ERR_EPERM = 3,
707 ERR_EBUSY = 4,
708 ERR_ECMDUNKNOWN = 5,
709 ERR_EBADSTATE = 6,
710 ERR_ENOMEM = 7,
711 ERR_ETIMEDOUT = 8,
712 ERR_ELINKDOWN = 9,
713 ERR_EMAXRES = 10,
714 ERR_ENOTSUPPORTED = 11,
715 ERR_EINPROGRESS = 12,
716 ERR_MAX
717 };
718
719 /*
720 * note: hw_version and asic_rev refer to the same thing,
721 * but have different formats. hw_version is
722 * a 32-byte string (e.g. "A2") and asic_rev is
723 * a 16-bit integer (e.g. 0xA2).
724 */
725 struct vnic_devcmd_fw_info {
726 char fw_version[32];
727 char fw_build[32];
728 char hw_version[32];
729 char hw_serial_number[32];
730 uint16_t asic_type;
731 uint16_t asic_rev;
732 };
733
734 enum fwinfo_asic_type {
735 FWINFO_ASIC_TYPE_UNKNOWN,
736 FWINFO_ASIC_TYPE_PALO,
737 FWINFO_ASIC_TYPE_SERENO,
738 FWINFO_ASIC_TYPE_CRUZ,
739 };
740
741 struct vnic_devcmd_notify {
742 uint32_t csum; /* checksum over following words */
743
744 uint32_t link_state; /* link up == 1 */
745 uint32_t port_speed; /* effective port speed (rate limit) */
746 uint32_t mtu; /* MTU */
747 uint32_t msglvl; /* requested driver msg lvl */
748 uint32_t uif; /* uplink interface */
749 uint32_t status; /* status bits (see VNIC_STF_*) */
750 uint32_t error; /* error code (see ERR_*) for 1st ERR */
751 uint32_t link_down_cnt; /* running count of link down
752 * transitions
753 */
754 uint32_t perbi_rebuild_cnt; /* running count of perbi rebuilds */
755 };
756 #define VNIC_STF_FATAL_ERR 0x0001 /* fatal fw error */
757 #define VNIC_STF_STD_PAUSE 0x0002 /* standard link-level pause on */
758 #define VNIC_STF_PFC_PAUSE 0x0004 /* priority flow control pause on */
759 /* all supported status flags */
760 #define VNIC_STF_ALL (VNIC_STF_FATAL_ERR |\
761 VNIC_STF_STD_PAUSE |\
762 VNIC_STF_PFC_PAUSE |\
763 0)
764
765 struct vnic_devcmd_provinfo {
766 uint8_t oui[3];
767 uint8_t type;
768 uint8_t data[0];
769 };
770
771 /*
772 * These are used in flags field of different filters to denote
773 * valid fields used.
774 */
775 #define FILTER_FIELD_VALID(fld) (1 << (fld - 1))
776
777 #define FILTER_FIELD_USNIC_VLAN FILTER_FIELD_VALID(1)
778 #define FILTER_FIELD_USNIC_ETHTYPE FILTER_FIELD_VALID(2)
779 #define FILTER_FIELD_USNIC_PROTO FILTER_FIELD_VALID(3)
780 #define FILTER_FIELD_USNIC_ID FILTER_FIELD_VALID(4)
781
782 #define FILTER_FIELDS_USNIC (FILTER_FIELD_USNIC_VLAN | \
783 FILTER_FIELD_USNIC_ETHTYPE | \
784 FILTER_FIELD_USNIC_PROTO | \
785 FILTER_FIELD_USNIC_ID)
786
787 struct filter_usnic_id {
788 uint32_t flags;
789 uint16_t vlan;
790 uint16_t ethtype;
791 uint8_t proto_version;
792 uint32_t usnic_id;
793 } __rte_packed;
794
795 #define FILTER_FIELD_5TUP_PROTO FILTER_FIELD_VALID(1)
796 #define FILTER_FIELD_5TUP_SRC_AD FILTER_FIELD_VALID(2)
797 #define FILTER_FIELD_5TUP_DST_AD FILTER_FIELD_VALID(3)
798 #define FILTER_FIELD_5TUP_SRC_PT FILTER_FIELD_VALID(4)
799 #define FILTER_FIELD_5TUP_DST_PT FILTER_FIELD_VALID(5)
800
801 #define FILTER_FIELDS_IPV4_5TUPLE (FILTER_FIELD_5TUP_PROTO | \
802 FILTER_FIELD_5TUP_SRC_AD | \
803 FILTER_FIELD_5TUP_DST_AD | \
804 FILTER_FIELD_5TUP_SRC_PT | \
805 FILTER_FIELD_5TUP_DST_PT)
806
807 /* Enums for the protocol field. */
808 enum protocol_e {
809 PROTO_UDP = 0,
810 PROTO_TCP = 1,
811 PROTO_IPV4 = 2,
812 PROTO_IPV6 = 3
813 };
814
815 struct filter_ipv4_5tuple {
816 uint32_t flags;
817 uint32_t protocol;
818 uint32_t src_addr;
819 uint32_t dst_addr;
820 uint16_t src_port;
821 uint16_t dst_port;
822 } __rte_packed;
823
824 #define FILTER_FIELD_VMQ_VLAN FILTER_FIELD_VALID(1)
825 #define FILTER_FIELD_VMQ_MAC FILTER_FIELD_VALID(2)
826
827 #define FILTER_FIELDS_MAC_VLAN (FILTER_FIELD_VMQ_VLAN | \
828 FILTER_FIELD_VMQ_MAC)
829
830 #define FILTER_FIELDS_NVGRE FILTER_FIELD_VMQ_MAC
831
832 struct filter_mac_vlan {
833 uint32_t flags;
834 uint16_t vlan;
835 uint8_t mac_addr[6];
836 } __rte_packed;
837
838 #define FILTER_FIELD_VLAN_IP_3TUP_VLAN FILTER_FIELD_VALID(1)
839 #define FILTER_FIELD_VLAN_IP_3TUP_L3_PROTO FILTER_FIELD_VALID(2)
840 #define FILTER_FIELD_VLAN_IP_3TUP_DST_AD FILTER_FIELD_VALID(3)
841 #define FILTER_FIELD_VLAN_IP_3TUP_L4_PROTO FILTER_FIELD_VALID(4)
842 #define FILTER_FIELD_VLAN_IP_3TUP_DST_PT FILTER_FIELD_VALID(5)
843
844 #define FILTER_FIELDS_VLAN_IP_3TUP (FILTER_FIELD_VLAN_IP_3TUP_VLAN | \
845 FILTER_FIELD_VLAN_IP_3TUP_L3_PROTO | \
846 FILTER_FIELD_VLAN_IP_3TUP_DST_AD | \
847 FILTER_FIELD_VLAN_IP_3TUP_L4_PROTO | \
848 FILTER_FIELD_VLAN_IP_3TUP_DST_PT)
849
850 struct filter_vlan_ip_3tuple {
851 uint32_t flags;
852 uint16_t vlan;
853 uint16_t l3_protocol;
854 union {
855 uint32_t dst_addr_v4;
856 uint8_t dst_addr_v6[16];
857 } u;
858 uint32_t l4_protocol;
859 uint16_t dst_port;
860 } __rte_packed;
861
862 #define FILTER_GENERIC_1_BYTES 64
863
864 enum filter_generic_1_layer {
865 FILTER_GENERIC_1_L2,
866 FILTER_GENERIC_1_L3,
867 FILTER_GENERIC_1_L4,
868 FILTER_GENERIC_1_L5,
869 FILTER_GENERIC_1_NUM_LAYERS
870 };
871
872 #define FILTER_GENERIC_1_IPV4 (1 << 0)
873 #define FILTER_GENERIC_1_IPV6 (1 << 1)
874 #define FILTER_GENERIC_1_UDP (1 << 2)
875 #define FILTER_GENERIC_1_TCP (1 << 3)
876 #define FILTER_GENERIC_1_TCP_OR_UDP (1 << 4)
877 #define FILTER_GENERIC_1_IP4SUM_OK (1 << 5)
878 #define FILTER_GENERIC_1_L4SUM_OK (1 << 6)
879 #define FILTER_GENERIC_1_IPFRAG (1 << 7)
880
881 #define FILTER_GENERIC_1_KEY_LEN 64
882
883 /*
884 * Version 1 of generic filter specification
885 * position is only 16 bits, reserving positions > 64k to be used by firmware
886 */
887 struct filter_generic_1 {
888 uint16_t position; /* lower position comes first */
889 uint32_t mask_flags;
890 uint32_t val_flags;
891 uint16_t mask_vlan;
892 uint16_t val_vlan;
893 struct {
894 uint8_t mask[FILTER_GENERIC_1_KEY_LEN]; /* 0 bit means
895 * " don't care"
896 */
897 uint8_t val[FILTER_GENERIC_1_KEY_LEN];
898 } __rte_packed layer[FILTER_GENERIC_1_NUM_LAYERS];
899 } __rte_packed;
900
901 /* Specifies the filter_action type. */
902 enum {
903 FILTER_ACTION_RQ_STEERING = 0,
904 FILTER_ACTION_V2 = 1,
905 FILTER_ACTION_MAX
906 };
907
908 struct filter_action {
909 uint32_t type;
910 union {
911 uint32_t rq_idx;
912 } u;
913 } __rte_packed;
914
915 #define FILTER_ACTION_RQ_STEERING_FLAG (1 << 0)
916 #define FILTER_ACTION_FILTER_ID_FLAG (1 << 1)
917 #define FILTER_ACTION_DROP_FLAG (1 << 2)
918 #define FILTER_ACTION_COUNTER_FLAG (1 << 3)
919 #define FILTER_ACTION_V2_ALL (FILTER_ACTION_RQ_STEERING_FLAG \
920 | FILTER_ACTION_DROP_FLAG \
921 | FILTER_ACTION_FILTER_ID_FLAG)
922
923 /* Version 2 of filter action must be a strict extension of struct
924 * filter_action where the first fields exactly match in size and meaning.
925 */
926 struct filter_action_v2 {
927 uint32_t type;
928 uint32_t rq_idx;
929 uint32_t flags; /* use FILTER_ACTION_XXX_FLAG defines */
930 uint16_t filter_id;
931 uint8_t reserved[32]; /* for future expansion */
932 } __rte_packed;
933
934 /* Specifies the filter type. */
935 enum filter_type {
936 FILTER_USNIC_ID = 0,
937 FILTER_IPV4_5TUPLE = 1,
938 FILTER_MAC_VLAN = 2,
939 FILTER_VLAN_IP_3TUPLE = 3,
940 FILTER_NVGRE_VMQ = 4,
941 FILTER_USNIC_IP = 5,
942 FILTER_DPDK_1 = 6,
943 FILTER_FLOWMAN = 7,
944 FILTER_MAX
945 };
946
947 #define FILTER_USNIC_ID_FLAG (1 << FILTER_USNIC_ID)
948 #define FILTER_IPV4_5TUPLE_FLAG (1 << FILTER_IPV4_5TUPLE)
949 #define FILTER_MAC_VLAN_FLAG (1 << FILTER_MAC_VLAN)
950 #define FILTER_VLAN_IP_3TUPLE_FLAG (1 << FILTER_VLAN_IP_3TUPLE)
951 #define FILTER_NVGRE_VMQ_FLAG (1 << FILTER_NVGRE_VMQ)
952 #define FILTER_USNIC_IP_FLAG (1 << FILTER_USNIC_IP)
953 #define FILTER_DPDK_1_FLAG (1 << FILTER_DPDK_1)
954 #define FILTER_V1_ALL (FILTER_USNIC_ID_FLAG | \
955 FILTER_IPV4_5TUPLE_FLAG | \
956 FILTER_MAC_VLAN_FLAG | \
957 FILTER_VLAN_IP_3TUPLE_FLAG | \
958 FILTER_NVGRE_VMQ_FLAG | \
959 FILTER_USNIC_IP_FLAG | \
960 FILTER_DPDK_1_FLAG)
961
962 struct filter {
963 uint32_t type;
964 union {
965 struct filter_usnic_id usnic;
966 struct filter_ipv4_5tuple ipv4;
967 struct filter_mac_vlan mac_vlan;
968 struct filter_vlan_ip_3tuple vlan_3tuple;
969 } u;
970 } __rte_packed;
971
972 /*
973 * This is a strict superset of "struct filter" and exists only
974 * because many drivers use "sizeof (struct filter)" in deciding TLV size.
975 * This new, larger struct filter would cause any code that uses that method
976 * to not work with older firmware, so we add filter_v2 to hold the
977 * new filter types. Drivers should use vnic_filter_size() to determine
978 * the TLV size instead of sizeof (struct fiter_v2) to guard against future
979 * growth.
980 */
981 struct filter_v2 {
982 uint32_t type;
983 union {
984 struct filter_usnic_id usnic;
985 struct filter_ipv4_5tuple ipv4;
986 struct filter_mac_vlan mac_vlan;
987 struct filter_vlan_ip_3tuple vlan_3tuple;
988 struct filter_generic_1 generic_1;
989 } u;
990 } __rte_packed;
991
992 enum {
993 CLSF_TLV_FILTER = 0,
994 CLSF_TLV_ACTION = 1,
995 };
996
997 struct filter_tlv {
998 uint32_t type;
999 uint32_t length;
1000 uint32_t val[0];
1001 };
1002
1003 /* Data for CMD_ADD_FILTER is 2 TLV and filter + action structs */
1004 #define FILTER_MAX_BUF_SIZE 100
1005 #define FILTER_V2_MAX_BUF_SIZE (sizeof(struct filter_v2) + \
1006 sizeof(struct filter_action_v2) + \
1007 (2 * sizeof(struct filter_tlv)))
1008
1009 /*
1010 * Compute actual structure size given filter type. To be "future-proof,"
1011 * drivers should use this instead of "sizeof (struct filter_v2)" when
1012 * computing length for TLV.
1013 */
1014 static inline uint32_t
vnic_filter_size(struct filter_v2 * fp)1015 vnic_filter_size(struct filter_v2 *fp)
1016 {
1017 uint32_t size;
1018
1019 switch (fp->type) {
1020 case FILTER_USNIC_ID:
1021 size = sizeof(fp->u.usnic);
1022 break;
1023 case FILTER_IPV4_5TUPLE:
1024 size = sizeof(fp->u.ipv4);
1025 break;
1026 case FILTER_MAC_VLAN:
1027 case FILTER_NVGRE_VMQ:
1028 size = sizeof(fp->u.mac_vlan);
1029 break;
1030 case FILTER_VLAN_IP_3TUPLE:
1031 size = sizeof(fp->u.vlan_3tuple);
1032 break;
1033 case FILTER_USNIC_IP:
1034 case FILTER_DPDK_1:
1035 size = sizeof(fp->u.generic_1);
1036 break;
1037 default:
1038 size = sizeof(fp->u);
1039 break;
1040 }
1041 size += sizeof(fp->type);
1042 return size;
1043 }
1044
1045
1046 enum {
1047 CLSF_ADD = 0,
1048 CLSF_DEL = 1,
1049 };
1050
1051 /*
1052 * Get the action structure size given action type. To be "future-proof,"
1053 * drivers should use this instead of "sizeof (struct filter_action_v2)"
1054 * when computing length for TLV.
1055 */
1056 static inline uint32_t
vnic_action_size(struct filter_action_v2 * fap)1057 vnic_action_size(struct filter_action_v2 *fap)
1058 {
1059 uint32_t size;
1060
1061 switch (fap->type) {
1062 case FILTER_ACTION_RQ_STEERING:
1063 size = sizeof(struct filter_action);
1064 break;
1065 case FILTER_ACTION_V2:
1066 size = sizeof(struct filter_action_v2);
1067 break;
1068 default:
1069 size = sizeof(struct filter_action);
1070 break;
1071 }
1072 return size;
1073 }
1074
1075 /*
1076 * Writing cmd register causes STAT_BUSY to get set in status register.
1077 * When cmd completes, STAT_BUSY will be cleared.
1078 *
1079 * If cmd completed successfully STAT_ERROR will be clear
1080 * and args registers contain cmd-specific results.
1081 *
1082 * If cmd error, STAT_ERROR will be set and args[0] contains error code.
1083 *
1084 * status register is read-only. While STAT_BUSY is set,
1085 * all other register contents are read-only.
1086 */
1087
1088 /* Make sizeof(vnic_devcmd) a power-of-2 for I/O BAR. */
1089 #define VNIC_DEVCMD_NARGS 15
1090 struct vnic_devcmd {
1091 uint32_t status; /* RO */
1092 uint32_t cmd; /* RW */
1093 uint64_t args[VNIC_DEVCMD_NARGS]; /* RW cmd args (little-endian)*/
1094 };
1095
1096 /*
1097 * Version 2 of the interface.
1098 *
1099 * Some things are carried over, notably the vnic_devcmd_cmd enum.
1100 */
1101
1102 /*
1103 * Flags for vnic_devcmd2.flags
1104 */
1105
1106 #define DEVCMD2_FNORESULT 0x1 /* Don't copy result to host */
1107
1108 #define VNIC_DEVCMD2_NARGS VNIC_DEVCMD_NARGS
1109 struct vnic_devcmd2 {
1110 uint16_t pad;
1111 uint16_t flags;
1112 uint32_t cmd; /* same command #defines as original */
1113 uint64_t args[VNIC_DEVCMD2_NARGS];
1114 };
1115
1116 #define VNIC_DEVCMD2_NRESULTS VNIC_DEVCMD_NARGS
1117 struct devcmd2_result {
1118 uint64_t results[VNIC_DEVCMD2_NRESULTS];
1119 uint32_t pad;
1120 uint16_t completed_index; /* into copy WQ */
1121 uint8_t error; /* same error codes as original */
1122 uint8_t color; /* 0 or 1 as with completion queues */
1123 };
1124
1125 #define DEVCMD2_RING_SIZE 32
1126 #define DEVCMD2_DESC_SIZE 128
1127
1128 #define DEVCMD2_RESULTS_SIZE_MAX ((1 << 16) - 1)
1129
1130 /* Overlay related definitions */
1131
1132 /*
1133 * This enum lists the flag associated with each of the overlay features
1134 */
1135 typedef enum {
1136 OVERLAY_FEATURE_NVGRE = 1,
1137 OVERLAY_FEATURE_VXLAN,
1138 OVERLAY_FEATURE_GENEVE,
1139 OVERLAY_FEATURE_MAX,
1140 } overlay_feature_t;
1141
1142 #define OVERLAY_OFFLOAD_ENABLE 0
1143 #define OVERLAY_OFFLOAD_DISABLE 1
1144 #define OVERLAY_OFFLOAD_ENABLE_V2 2
1145
1146 #define OVERLAY_CFG_VXLAN_PORT_UPDATE 0
1147 #define OVERLAY_CFG_GENEVE_PORT_UPDATE 1
1148
1149 /*
1150 * Use this enum to get the supported versions for each of these features
1151 * If you need to use the devcmd_get_supported_feature_version(), add
1152 * the new feature into this enum and install function handler in devcmd.c
1153 */
1154 typedef enum {
1155 VIC_FEATURE_VXLAN,
1156 VIC_FEATURE_RDMA,
1157 VIC_FEATURE_GENEVE,
1158 VIC_FEATURE_MAX,
1159 } vic_feature_t;
1160
1161 /*
1162 * These flags are used in args[1] of devcmd CMD_GET_SUPP_FEATURE_VER
1163 * to indicate the host driver about the VxLAN and Multi WQ features
1164 * supported
1165 */
1166 #define FEATURE_VXLAN_IPV6_INNER (1 << 0)
1167 #define FEATURE_VXLAN_IPV6_OUTER (1 << 1)
1168 #define FEATURE_VXLAN_MULTI_WQ (1 << 2)
1169
1170 #define FEATURE_VXLAN_IPV6 (FEATURE_VXLAN_IPV6_INNER | \
1171 FEATURE_VXLAN_IPV6_OUTER)
1172 /* Support Geneve option bytes */
1173 #define FEATURE_GENEVE_OPTIONS (1 << 0)
1174
1175 /*
1176 * CMD_CONFIG_GRPINTR subcommands
1177 */
1178 typedef enum {
1179 GRPINTR_ENABLE = 1,
1180 GRPINTR_DISABLE,
1181 GRPINTR_UPD_VECT,
1182 } grpintr_subcmd_t;
1183
1184 /*
1185 * Defines and Capabilities for CMD_CQ_ENTRY_SIZE_SET
1186 */
1187 #define VNIC_RQ_ALL (~0ULL)
1188
1189 #define VNIC_RQ_CQ_ENTRY_SIZE_16 0
1190 #define VNIC_RQ_CQ_ENTRY_SIZE_32 1
1191 #define VNIC_RQ_CQ_ENTRY_SIZE_64 2
1192
1193 #define VNIC_RQ_CQ_ENTRY_SIZE_16_CAPABLE (1 << VNIC_RQ_CQ_ENTRY_SIZE_16)
1194 #define VNIC_RQ_CQ_ENTRY_SIZE_32_CAPABLE (1 << VNIC_RQ_CQ_ENTRY_SIZE_32)
1195 #define VNIC_RQ_CQ_ENTRY_SIZE_64_CAPABLE (1 << VNIC_RQ_CQ_ENTRY_SIZE_64)
1196
1197 #endif /* _VNIC_DEVCMD_H_ */
1198