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.
6 #ifndef _VNIC_DEVCMD_H_
7 #define _VNIC_DEVCMD_H_
10 #define _CMD_VTYPEBITS 10
11 #define _CMD_FLAGSBITS 6
12 #define _CMD_DIRBITS 2
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)
20 #define _CMD_VTYPESHIFT (_CMD_NSHIFT+_CMD_NBITS)
21 #define _CMD_FLAGSSHIFT (_CMD_VTYPESHIFT+_CMD_VTYPEBITS)
22 #define _CMD_DIRSHIFT (_CMD_FLAGSSHIFT+_CMD_FLAGSBITS)
25 * Direction bits (from host perspective).
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)
35 #define _CMD_FLAGS_NONE 0U
36 #define _CMD_FLAGS_NOWAIT 1U
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)
48 * Used to create cmds..
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)
59 * Used to decode cmds..
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)
66 #define ARRAY_SIZE(x) RTE_DIM(x)
68 enum vnic_devcmd_cmd {
69 CMD_NONE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_NONE, 0),
72 * mcpu fw info in mem:
74 * (uint64_t)a0=paddr to struct vnic_devcmd_fw_info
76 * Fills in struct vnic_devcmd_fw_info (128 bytes)
78 * An old definition of CMD_MCPU_FW_INFO
80 CMD_MCPU_FW_INFO_OLD = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 1),
83 * mcpu fw info in mem:
85 * (uint64_t)a0=paddr to struct vnic_devcmd_fw_info
86 * (uint16_t)a1=size of the structure
88 * (uint16_t)a1=0 for in:a1 = 0,
89 * data size actually written for other values.
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.
95 * CMD_MCPU_FW_INFO and CMD_MCPU_FW_INFO_OLD have the same enum 1
96 * for source compatibility.
98 CMD_MCPU_FW_INFO = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 1),
100 /* dev-specific block member:
101 * in: (uint16_t)a0=offset,(uint8_t)a1=size
104 CMD_DEV_SPEC = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 2),
107 CMD_STATS_CLEAR = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 3),
109 /* stats dump in mem: (uint64_t)a0=paddr to stats area,
110 * (uint16_t)a1=sizeof stats area
112 CMD_STATS_DUMP = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 4),
114 /* set Rx packet filter: (uint32_t)a0=filters (see CMD_PFILTER_*) */
115 CMD_PACKET_FILTER = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 7),
117 /* set Rx packet filter for all: (uint32_t)a0=filters
118 * (see CMD_PFILTER_*)
120 CMD_PACKET_FILTER_ALL = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 7),
122 /* hang detection notification */
123 CMD_HANG_NOTIFY = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 8),
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 */
130 /* add addr from (u48)a0 */
131 CMD_ADDR_ADD = _CMDCNW(_CMD_DIR_WRITE,
132 _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 12),
134 /* del addr from (u48)a0 */
135 CMD_ADDR_DEL = _CMDCNW(_CMD_DIR_WRITE,
136 _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 13),
138 /* add VLAN id in (uint16_t)a0 */
139 CMD_VLAN_ADD = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 14),
141 /* del VLAN id in (uint16_t)a0 */
142 CMD_VLAN_DEL = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 15),
145 * nic_cfg in (uint32_t)a0
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)
152 CMD_NIC_CFG = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 16),
155 * nic_cfg_chk (same as nic_cfg, but may return error)
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)
163 CMD_NIC_CFG_CHK = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 16),
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),
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),
171 /* initiate softreset */
172 CMD_SOFT_RESET = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 19),
175 * out: a0=0 reset complete, a0=1 reset in progress */
176 CMD_SOFT_RESET_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 20),
178 /* set struct vnic_devcmd_notify buffer in mem:
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)
184 * (uint32_t)a1 = effective size
186 CMD_NOTIFY = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 21),
188 /* UNDI API: (uint64_t)a0=paddr to s_PXENV_UNDI_ struct,
189 * (uint8_t)a1=PXENV_UNDI_xxx
191 CMD_UNDI = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 22),
193 /* initiate open sequence (uint32_t)a0=flags (see CMD_OPENF_*) */
194 CMD_OPEN = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 23),
197 * out: a0=0 open complete, a0=1 open in progress */
198 CMD_OPEN_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 24),
201 CMD_CLOSE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 25),
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),
207 /* variant of CMD_INIT, with provisioning info
208 * (uint64_t)a0=paddr of vnic_devcmd_provinfo
209 * (uint32_t)a1=sizeof provision info
211 CMD_INIT_PROV_INFO = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 27),
213 /* enable virtual link */
214 CMD_ENABLE = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 28),
216 /* enable virtual link, waiting variant. */
217 CMD_ENABLE_WAIT = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 28),
219 /* disable virtual link */
220 CMD_DISABLE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 29),
222 /* stats dump sum of all vnic stats on same uplink in mem:
224 * (uint16_t)a1=sizeof stats area
226 CMD_STATS_DUMP_ALL = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 30),
229 * out: a0=0 init complete, a0=1 init in progress
232 CMD_INIT_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 31),
234 /* INT13 API: (uint64_t)a0=paddr to vnic_int13_params struct
235 * (uint32_t)a1=INT13_CMD_xxx
237 CMD_INT13 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_FC, 32),
239 /* logical uplink enable/disable: (uint64_t)a0: 0/1=disable/enable */
240 CMD_LOGICAL_UPLINK = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 33),
242 /* undo initialize of virtual link */
243 CMD_DEINIT = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 34),
245 /* initialize virtual link: (uint32_t)a0=flags (see CMD_INITF_*) */
246 CMD_INIT = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 35),
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
252 CMD_CAPABILITY = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 36),
254 /* persistent binding info
255 * in: (uint64_t)a0=paddr of arg
256 * (uint32_t)a1=CMD_PERBI_XXX
258 CMD_PERBI = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_FC, 37),
260 /* Interrupt Assert Register functionality
261 * in: (uint16_t)a0=interrupt number to assert
263 CMD_IAR = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 38),
265 /* initiate hangreset, like softreset after hang detected */
266 CMD_HANG_RESET = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 39),
269 * out: a0=0 reset complete, a0=1 reset in progress
271 CMD_HANG_RESET_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 40),
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
278 CMD_IG_VLAN_REWRITE_MODE = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 41),
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
287 CMD_PROXY_BY_BDF = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 42),
290 * As for BY_BDF except a0 is index of hvnlink subordinate vnic
291 * or SR-IOV virtual vnic
293 CMD_PROXY_BY_INDEX = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 43),
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.
304 CMD_CONFIG_INFO_GET = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 44),
307 * INT13 API: (uint64_t)a0=paddr to vnic_int13_params struct
308 * (uint32_t)a1=INT13_CMD_xxx
310 CMD_INT13_ALL = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 45),
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
319 CMD_SET_DEFAULT_VLAN = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 46),
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
327 CMD_INIT_PROV_INFO2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 47),
330 * (uint32_t)a0=0 ==> standby
331 * =CMD_ENABLE2_ACTIVE ==> active
333 CMD_ENABLE2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 48),
337 * Returns the status of the specified command
339 * a0 = command for which status is being queried.
340 * Possible values are:
347 * CMD_INIT_PROV_INFO2
350 * if status == STAT_ERROR
351 * a0 = ERR_ENOTSUPPORTED - status for command in a0 is
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
358 CMD_STATUS = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 49),
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:
365 * intr_timer_cycles = intr_timer_usec * multiplier / divisor
367 * Interrupt coalescing timer in usecs can be be converted/obtained
368 * from CPU cycles as follows:
370 * intr_timer_usec = intr_timer_cycles * divisor / multiplier
373 * out: (uint32_t)a0 = multiplier
374 * (uint32_t)a1 = divisor
375 * (uint32_t)a2 = maximum timer value in usec
377 CMD_INTR_COAL_CONVERT = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 50),
381 * in: (uint64_t)a0=paddr of the param or param itself
382 * (uint32_t)a1=ISCSI_CMD_xxx
384 CMD_ISCSI_DUMP_REQ = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 51),
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
392 CMD_ISCSI_DUMP_STATUS = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 52),
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
403 * (uint32_t)a1=VF index (MQ index)
405 CMD_MIGRATE_SUBVNIC = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 53),
408 * Register / Deregister the notification block for MQ subvnics
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)
414 * (uint32_t)a1 = effective size
416 CMD_SUBVNIC_NOTIFY = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 54),
419 * Set the predefined mac address as default
423 CMD_SET_MAC_ADDR = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 55),
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
429 CMD_PROV_INFO_UPDATE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 56),
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
436 CMD_INITIALIZE_DEVCMD2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 57),
440 * in: (uint64_t) a0= filter address
441 * (uint32_t) a1= size of filter
442 * out: (uint32_t) a0=filter identifier
445 * out: (uint64_t) a0= 1 if capability query supported
446 * (uint64_t) a1= MAX filter type supported
448 CMD_ADD_FILTER = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 58),
452 * in: (uint32_t) a0=filter identifier
454 CMD_DEL_FILTER = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 59),
457 * Enable a Queue Pair in User space NIC
458 * in: (uint32_t) a0=Queue Pair number
459 * (uint32_t) a1= command
461 CMD_QP_ENABLE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 60),
464 * Disable a Queue Pair in User space NIC
465 * in: (uint32_t) a0=Queue Pair number
466 * (uint32_t) a1= command
468 CMD_QP_DISABLE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 61),
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
476 CMD_QP_STATS_DUMP = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 62),
479 * Clear stats for Queue Pair in User space NIC
480 * in: (uint32_t) a0=Queue Pair number
482 CMD_QP_STATS_CLEAR = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 63),
485 * UEFI BOOT API: (uint64_t)a0= UEFI FLS_CMD_xxx
486 * (ui64)a1= paddr for the info buffer
488 CMD_FC_REQ = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_FC, 64),
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
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
498 CMD_VNIC_BOOT_CONFIG_INFO = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 65),
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
513 CMD_RDMA_QP_CREATE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 66),
516 * Delete a Queue Pair (RoCE)
517 * in: (uint32_t) a0 = Queue Pair number
519 CMD_RDMA_QP_DELETE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 67),
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
527 CMD_RDMA_QP_STATUS = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 68),
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
537 CMD_GET_SUPP_FEATURE_VER = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 69),
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
546 CMD_RDMA_INIT_INFO_BUF = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 70),
549 * De-init the RDMA notification work queue
550 * in: (uint64_t) a0=resource group number
552 CMD_RDMA_DEINIT_INFO_BUF = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 71),
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
563 CMD_OVERLAY_OFFLOAD_CTRL =
564 _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 72),
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
572 CMD_OVERLAY_OFFLOAD_CFG = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 73),
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
579 CMD_GET_CONFIG_NAME = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 74),
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
589 * in: (uint64_t) a3 = Stride between group vectors
591 CMD_CONFIG_GRPINTR = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 75),
594 * Set cq arrary base and size in a list of consective wqs and
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
603 CMD_CONFIG_CQ_ARRAY = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 76),
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
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
620 CMD_ADD_ADV_FILTER = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 77),
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)
627 * All arguments that have not been assigned a meaning should be
628 * initialized to 0 to allow for better driver forward compatibility.
630 CMD_FLOW_MANAGER_OP = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 88),
633 * Set extended CQ field in MREGS of RQ (or all RQs)
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
642 * out: (u32) a0 = errno, 0:valid cmd
643 * (u32) a1 = value consisting of supported entries
648 CMD_CQ_ENTRY_SIZE_SET = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 90),
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
657 enum filter_cap_mode {
658 FILTER_CAP_MODE_V0 = 0, /* Must always be 0 for legacy drivers */
659 FILTER_CAP_MODE_V1 = 1,
661 #define FILTER_CAP_MODE_V1_FLAG (1 << FILTER_CAP_MODE_V1)
663 /* CMD_ENABLE2 flags */
664 #define CMD_ENABLE2_STANDBY 0x0
665 #define CMD_ENABLE2_ACTIVE 0x1
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 */
671 /* flags for CMD_INIT */
672 #define CMD_INITF_DEFAULT_MAC 0x1 /* init with default mac addr */
674 /* flags for CMD_NIC_CFG */
675 #define CMD_NIC_CFG_CAPF_UDP_WEAK (1ULL << 0) /* Bodega-style UDP RSS */
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
684 /* Commands for CMD_QP_ENABLE/CM_QP_DISABLE */
685 #define CMD_QP_RQWQ 0x0
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
693 enum vnic_devcmd_status {
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
702 enum vnic_devcmd_error {
714 ERR_ENOTSUPPORTED = 11,
715 ERR_EINPROGRESS = 12,
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).
725 struct vnic_devcmd_fw_info {
729 char hw_serial_number[32];
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,
741 struct vnic_devcmd_notify {
742 uint32_t csum; /* checksum over following words */
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
754 uint32_t perbi_rebuild_cnt; /* running count of perbi rebuilds */
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 |\
765 struct vnic_devcmd_provinfo {
772 * These are used in flags field of different filters to denote
775 #define FILTER_FIELD_VALID(fld) (1 << (fld - 1))
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)
782 #define FILTER_FIELDS_USNIC (FILTER_FIELD_USNIC_VLAN | \
783 FILTER_FIELD_USNIC_ETHTYPE | \
784 FILTER_FIELD_USNIC_PROTO | \
785 FILTER_FIELD_USNIC_ID)
787 struct filter_usnic_id {
791 uint8_t proto_version;
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)
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)
807 /* Enums for the protocol field. */
815 struct filter_ipv4_5tuple {
824 #define FILTER_FIELD_VMQ_VLAN FILTER_FIELD_VALID(1)
825 #define FILTER_FIELD_VMQ_MAC FILTER_FIELD_VALID(2)
827 #define FILTER_FIELDS_MAC_VLAN (FILTER_FIELD_VMQ_VLAN | \
828 FILTER_FIELD_VMQ_MAC)
830 #define FILTER_FIELDS_NVGRE FILTER_FIELD_VMQ_MAC
832 struct filter_mac_vlan {
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)
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)
850 struct filter_vlan_ip_3tuple {
853 uint16_t l3_protocol;
855 uint32_t dst_addr_v4;
856 uint8_t dst_addr_v6[16];
858 uint32_t l4_protocol;
862 #define FILTER_GENERIC_1_BYTES 64
864 enum filter_generic_1_layer {
869 FILTER_GENERIC_1_NUM_LAYERS
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)
881 #define FILTER_GENERIC_1_KEY_LEN 64
884 * Version 1 of generic filter specification
885 * position is only 16 bits, reserving positions > 64k to be used by firmware
887 struct filter_generic_1 {
888 uint16_t position; /* lower position comes first */
894 uint8_t mask[FILTER_GENERIC_1_KEY_LEN]; /* 0 bit means
897 uint8_t val[FILTER_GENERIC_1_KEY_LEN];
898 } __rte_packed layer[FILTER_GENERIC_1_NUM_LAYERS];
901 /* Specifies the filter_action type. */
903 FILTER_ACTION_RQ_STEERING = 0,
904 FILTER_ACTION_V2 = 1,
908 struct filter_action {
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)
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.
926 struct filter_action_v2 {
929 uint32_t flags; /* use FILTER_ACTION_XXX_FLAG defines */
931 uint8_t reserved[32]; /* for future expansion */
934 /* Specifies the filter type. */
937 FILTER_IPV4_5TUPLE = 1,
939 FILTER_VLAN_IP_3TUPLE = 3,
940 FILTER_NVGRE_VMQ = 4,
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 | \
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;
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
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;
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)))
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.
1014 static inline uint32_t
1015 vnic_filter_size(struct filter_v2 *fp)
1020 case FILTER_USNIC_ID:
1021 size = sizeof(fp->u.usnic);
1023 case FILTER_IPV4_5TUPLE:
1024 size = sizeof(fp->u.ipv4);
1026 case FILTER_MAC_VLAN:
1027 case FILTER_NVGRE_VMQ:
1028 size = sizeof(fp->u.mac_vlan);
1030 case FILTER_VLAN_IP_3TUPLE:
1031 size = sizeof(fp->u.vlan_3tuple);
1033 case FILTER_USNIC_IP:
1035 size = sizeof(fp->u.generic_1);
1038 size = sizeof(fp->u);
1041 size += sizeof(fp->type);
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.
1056 static inline uint32_t
1057 vnic_action_size(struct filter_action_v2 *fap)
1061 switch (fap->type) {
1062 case FILTER_ACTION_RQ_STEERING:
1063 size = sizeof(struct filter_action);
1065 case FILTER_ACTION_V2:
1066 size = sizeof(struct filter_action_v2);
1069 size = sizeof(struct filter_action);
1076 * Writing cmd register causes STAT_BUSY to get set in status register.
1077 * When cmd completes, STAT_BUSY will be cleared.
1079 * If cmd completed successfully STAT_ERROR will be clear
1080 * and args registers contain cmd-specific results.
1082 * If cmd error, STAT_ERROR will be set and args[0] contains error code.
1084 * status register is read-only. While STAT_BUSY is set,
1085 * all other register contents are read-only.
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)*/
1097 * Version 2 of the interface.
1099 * Some things are carried over, notably the vnic_devcmd_cmd enum.
1103 * Flags for vnic_devcmd2.flags
1106 #define DEVCMD2_FNORESULT 0x1 /* Don't copy result to host */
1108 #define VNIC_DEVCMD2_NARGS VNIC_DEVCMD_NARGS
1109 struct vnic_devcmd2 {
1112 uint32_t cmd; /* same command #defines as original */
1113 uint64_t args[VNIC_DEVCMD2_NARGS];
1116 #define VNIC_DEVCMD2_NRESULTS VNIC_DEVCMD_NARGS
1117 struct devcmd2_result {
1118 uint64_t results[VNIC_DEVCMD2_NRESULTS];
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 */
1125 #define DEVCMD2_RING_SIZE 32
1126 #define DEVCMD2_DESC_SIZE 128
1128 #define DEVCMD2_RESULTS_SIZE_MAX ((1 << 16) - 1)
1130 /* Overlay related definitions */
1133 * This enum lists the flag associated with each of the overlay features
1136 OVERLAY_FEATURE_NVGRE = 1,
1137 OVERLAY_FEATURE_VXLAN,
1138 OVERLAY_FEATURE_GENEVE,
1139 OVERLAY_FEATURE_MAX,
1140 } overlay_feature_t;
1142 #define OVERLAY_OFFLOAD_ENABLE 0
1143 #define OVERLAY_OFFLOAD_DISABLE 1
1144 #define OVERLAY_OFFLOAD_ENABLE_V2 2
1146 #define OVERLAY_CFG_VXLAN_PORT_UPDATE 0
1147 #define OVERLAY_CFG_GENEVE_PORT_UPDATE 1
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
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
1166 #define FEATURE_VXLAN_IPV6_INNER (1 << 0)
1167 #define FEATURE_VXLAN_IPV6_OUTER (1 << 1)
1168 #define FEATURE_VXLAN_MULTI_WQ (1 << 2)
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)
1176 * CMD_CONFIG_GRPINTR subcommands
1185 * Defines and Capabilities for CMD_CQ_ENTRY_SIZE_SET
1187 #define VNIC_RQ_ALL (~0ULL)
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
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)
1197 #endif /* _VNIC_DEVCMD_H_ */