2 * Copyright 2008-2016 Cisco Systems, Inc. All rights reserved.
3 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
5 * Copyright (c) 2014, Cisco Systems, Inc.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
35 #ifndef _VNIC_DEVCMD_H_
36 #define _VNIC_DEVCMD_H_
39 #define _CMD_VTYPEBITS 10
40 #define _CMD_FLAGSBITS 6
41 #define _CMD_DIRBITS 2
43 #define _CMD_NMASK ((1 << _CMD_NBITS)-1)
44 #define _CMD_VTYPEMASK ((1 << _CMD_VTYPEBITS)-1)
45 #define _CMD_FLAGSMASK ((1 << _CMD_FLAGSBITS)-1)
46 #define _CMD_DIRMASK ((1 << _CMD_DIRBITS)-1)
49 #define _CMD_VTYPESHIFT (_CMD_NSHIFT+_CMD_NBITS)
50 #define _CMD_FLAGSSHIFT (_CMD_VTYPESHIFT+_CMD_VTYPEBITS)
51 #define _CMD_DIRSHIFT (_CMD_FLAGSSHIFT+_CMD_FLAGSBITS)
54 * Direction bits (from host perspective).
56 #define _CMD_DIR_NONE 0U
57 #define _CMD_DIR_WRITE 1U
58 #define _CMD_DIR_READ 2U
59 #define _CMD_DIR_RW (_CMD_DIR_WRITE | _CMD_DIR_READ)
64 #define _CMD_FLAGS_NONE 0U
65 #define _CMD_FLAGS_NOWAIT 1U
70 #define _CMD_VTYPE_NONE 0U
71 #define _CMD_VTYPE_ENET 1U
72 #define _CMD_VTYPE_FC 2U
73 #define _CMD_VTYPE_SCSI 4U
74 #define _CMD_VTYPE_ALL (_CMD_VTYPE_ENET | _CMD_VTYPE_FC | _CMD_VTYPE_SCSI)
77 * Used to create cmds..
79 #define _CMDCF(dir, flags, vtype, nr) \
80 (((dir) << _CMD_DIRSHIFT) | \
81 ((flags) << _CMD_FLAGSSHIFT) | \
82 ((vtype) << _CMD_VTYPESHIFT) | \
83 ((nr) << _CMD_NSHIFT))
84 #define _CMDC(dir, vtype, nr) _CMDCF(dir, 0, vtype, nr)
85 #define _CMDCNW(dir, vtype, nr) _CMDCF(dir, _CMD_FLAGS_NOWAIT, vtype, nr)
88 * Used to decode cmds..
90 #define _CMD_DIR(cmd) (((cmd) >> _CMD_DIRSHIFT) & _CMD_DIRMASK)
91 #define _CMD_FLAGS(cmd) (((cmd) >> _CMD_FLAGSSHIFT) & _CMD_FLAGSMASK)
92 #define _CMD_VTYPE(cmd) (((cmd) >> _CMD_VTYPESHIFT) & _CMD_VTYPEMASK)
93 #define _CMD_N(cmd) (((cmd) >> _CMD_NSHIFT) & _CMD_NMASK)
95 enum vnic_devcmd_cmd {
96 CMD_NONE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_NONE, 0),
99 * mcpu fw info in mem:
101 * (u64)a0=paddr to struct vnic_devcmd_fw_info
103 * Fills in struct vnic_devcmd_fw_info (128 bytes)
105 * An old definition of CMD_MCPU_FW_INFO
107 CMD_MCPU_FW_INFO_OLD = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 1),
110 * mcpu fw info in mem:
112 * (u64)a0=paddr to struct vnic_devcmd_fw_info
113 * (u16)a1=size of the structure
115 * (u16)a1=0 for in:a1 = 0,
116 * data size actually written for other values.
118 * Fills in first 128 bytes of vnic_devcmd_fw_info for in:a1 = 0,
119 * first in:a1 bytes for 0 < in:a1 <= 132,
120 * 132 bytes for other values of in:a1.
122 * CMD_MCPU_FW_INFO and CMD_MCPU_FW_INFO_OLD have the same enum 1
123 * for source compatibility.
125 CMD_MCPU_FW_INFO = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 1),
127 /* dev-specific block member:
128 * in: (u16)a0=offset,(u8)a1=size
131 CMD_DEV_SPEC = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 2),
134 CMD_STATS_CLEAR = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 3),
136 /* stats dump in mem: (u64)a0=paddr to stats area,
137 * (u16)a1=sizeof stats area */
138 CMD_STATS_DUMP = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 4),
140 /* set Rx packet filter: (u32)a0=filters (see CMD_PFILTER_*) */
141 CMD_PACKET_FILTER = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 7),
143 /* set Rx packet filter for all: (u32)a0=filters (see CMD_PFILTER_*) */
144 CMD_PACKET_FILTER_ALL = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 7),
146 /* hang detection notification */
147 CMD_HANG_NOTIFY = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 8),
149 /* MAC address in (u48)a0 */
150 CMD_MAC_ADDR = _CMDC(_CMD_DIR_READ,
151 _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 9),
152 #define CMD_GET_MAC_ADDR CMD_MAC_ADDR /* some uses are aliased */
154 /* add addr from (u48)a0 */
155 CMD_ADDR_ADD = _CMDCNW(_CMD_DIR_WRITE,
156 _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 12),
158 /* del addr from (u48)a0 */
159 CMD_ADDR_DEL = _CMDCNW(_CMD_DIR_WRITE,
160 _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 13),
162 /* add VLAN id in (u16)a0 */
163 CMD_VLAN_ADD = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 14),
165 /* del VLAN id in (u16)a0 */
166 CMD_VLAN_DEL = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 15),
168 /* nic_cfg in (u32)a0 */
169 CMD_NIC_CFG = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 16),
171 /* union vnic_rss_key in mem: (u64)a0=paddr, (u16)a1=len */
172 CMD_RSS_KEY = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 17),
174 /* union vnic_rss_cpu in mem: (u64)a0=paddr, (u16)a1=len */
175 CMD_RSS_CPU = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 18),
177 /* initiate softreset */
178 CMD_SOFT_RESET = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 19),
181 * out: a0=0 reset complete, a0=1 reset in progress */
182 CMD_SOFT_RESET_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 20),
184 /* set struct vnic_devcmd_notify buffer in mem:
186 * (u64)a0=paddr to notify (set paddr=0 to unset)
187 * (u32)a1 & 0x00000000ffffffff=sizeof(struct vnic_devcmd_notify)
188 * (u16)a1 & 0x0000ffff00000000=intr num (-1 for no intr)
190 * (u32)a1 = effective size
192 CMD_NOTIFY = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 21),
194 /* UNDI API: (u64)a0=paddr to s_PXENV_UNDI_ struct,
195 * (u8)a1=PXENV_UNDI_xxx */
196 CMD_UNDI = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 22),
198 /* initiate open sequence (u32)a0=flags (see CMD_OPENF_*) */
199 CMD_OPEN = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 23),
202 * out: a0=0 open complete, a0=1 open in progress */
203 CMD_OPEN_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 24),
206 CMD_CLOSE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 25),
208 /* initialize virtual link: (u32)a0=flags (see CMD_INITF_*) */
209 /***** Replaced by CMD_INIT *****/
210 CMD_INIT_v1 = _CMDCNW(_CMD_DIR_READ, _CMD_VTYPE_ALL, 26),
212 /* variant of CMD_INIT, with provisioning info
213 * (u64)a0=paddr of vnic_devcmd_provinfo
214 * (u32)a1=sizeof provision info */
215 CMD_INIT_PROV_INFO = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 27),
217 /* enable virtual link */
218 CMD_ENABLE = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 28),
220 /* enable virtual link, waiting variant. */
221 CMD_ENABLE_WAIT = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 28),
223 /* disable virtual link */
224 CMD_DISABLE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 29),
226 /* stats dump sum of all vnic stats on same uplink in mem:
228 * (u16)a1=sizeof stats area */
229 CMD_STATS_DUMP_ALL = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 30),
232 * out: a0=0 init complete, a0=1 init in progress
233 * if a0=0, a1=errno */
234 CMD_INIT_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 31),
236 /* INT13 API: (u64)a0=paddr to vnic_int13_params struct
237 * (u32)a1=INT13_CMD_xxx */
238 CMD_INT13 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_FC, 32),
240 /* logical uplink enable/disable: (u64)a0: 0/1=disable/enable */
241 CMD_LOGICAL_UPLINK = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 33),
243 /* undo initialize of virtual link */
244 CMD_DEINIT = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 34),
246 /* initialize virtual link: (u32)a0=flags (see CMD_INITF_*) */
247 CMD_INIT = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 35),
249 /* check fw capability of a cmd:
251 * out: (u32)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: (u64)a0=paddr of arg
256 * (u32)a1=CMD_PERBI_XXX */
257 CMD_PERBI = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_FC, 37),
259 /* Interrupt Assert Register functionality
260 * in: (u16)a0=interrupt number to assert
262 CMD_IAR = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 38),
264 /* initiate hangreset, like softreset after hang detected */
265 CMD_HANG_RESET = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 39),
268 * out: a0=0 reset complete, a0=1 reset in progress */
269 CMD_HANG_RESET_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 40),
272 * Set hw ingress packet vlan rewrite mode:
273 * in: (u32)a0=new vlan rewrite mode
274 * out: (u32)a0=old vlan rewrite mode */
275 CMD_IG_VLAN_REWRITE_MODE = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 41),
278 * in: (u16)a0=bdf of target vnic
279 * (u32)a1=cmd to proxy
280 * a2-a15=args to cmd in a1
281 * out: (u32)a0=status of proxied cmd
282 * a1-a15=out args of proxied cmd */
283 CMD_PROXY_BY_BDF = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 42),
286 * As for BY_BDF except a0 is index of hvnlink subordinate vnic
287 * or SR-IOV virtual vnic
289 CMD_PROXY_BY_INDEX = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 43),
294 * in: (u64)a0=phsical address of buffer passed in from caller.
295 * (u16)a1=size of buffer specified in a0.
296 * out: (u64)a0=phsical address of buffer passed in from caller.
297 * (u16)a1=actual bytes from VIF-CONFIG-INFO TLV, or
298 * 0 if no VIF-CONFIG-INFO TLV was ever received. */
299 CMD_CONFIG_INFO_GET = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 44),
302 * INT13 API: (u64)a0=paddr to vnic_int13_params struct
303 * (u32)a1=INT13_CMD_xxx
305 CMD_INT13_ALL = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 45),
309 * in: (u16)a0=new default vlan
310 * (u16)a1=zero for overriding vlan with param a0,
311 * non-zero for resetting vlan to the default
312 * out: (u16)a0=old default vlan
314 CMD_SET_DEFAULT_VLAN = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 46),
317 * Variant of CMD_INIT_PROV_INFO, where it will not try to enable
318 * the vnic until CMD_ENABLE2 is issued.
319 * (u64)a0=paddr of vnic_devcmd_provinfo
320 * (u32)a1=sizeof provision info */
321 CMD_INIT_PROV_INFO2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 47),
324 * (u32)a0=0 ==> standby
325 * =CMD_ENABLE2_ACTIVE ==> active
327 CMD_ENABLE2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 48),
331 * Returns the status of the specified command
333 * a0 = command for which status is being queried.
334 * Possible values are:
341 * CMD_INIT_PROV_INFO2
344 * if status == STAT_ERROR
345 * a0 = ERR_ENOTSUPPORTED - status for command in a0 is
347 * if status == STAT_NONE
348 * a0 = status of the devcmd specified in a0 as follows.
349 * ERR_SUCCESS - command in a0 completed successfully
350 * ERR_EINPROGRESS - command in a0 is still in progress
352 CMD_STATUS = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 49),
355 * Returns interrupt coalescing timer conversion factors.
356 * After calling this devcmd, ENIC driver can convert
357 * interrupt coalescing timer in usec into CPU cycles as follows:
359 * intr_timer_cycles = intr_timer_usec * multiplier / divisor
361 * Interrupt coalescing timer in usecs can be be converted/obtained
362 * from CPU cycles as follows:
364 * intr_timer_usec = intr_timer_cycles * divisor / multiplier
367 * out: (u32)a0 = multiplier
369 * (u32)a2 = maximum timer value in usec
371 CMD_INTR_COAL_CONVERT = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 50),
375 * in: (u64)a0=paddr of the param or param itself
376 * (u32)a1=ISCSI_CMD_xxx
378 CMD_ISCSI_DUMP_REQ = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 51),
381 * ISCSI DUMP STATUS API:
382 * in: (u32)a0=cmd tag
383 * in: (u32)a1=ISCSI_CMD_xxx
384 * out: (u32)a0=cmd status
386 CMD_ISCSI_DUMP_STATUS = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 52),
389 * Subvnic migration from MQ <--> VF.
390 * Enable the LIF migration from MQ to VF and vice versa. MQ and VF
391 * indexes are statically bound at the time of initialization.
392 * Based on the direction of migration, the resources of either MQ or
393 * the VF shall be attached to the LIF.
394 * in: (u32)a0=Direction of Migration
397 * (u32)a1=VF index (MQ index)
399 CMD_MIGRATE_SUBVNIC = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 53),
402 * Register / Deregister the notification block for MQ subvnics
404 * (u64)a0=paddr to notify (set paddr=0 to unset)
405 * (u32)a1 & 0x00000000ffffffff=sizeof(struct vnic_devcmd_notify)
406 * (u16)a1 & 0x0000ffff00000000=intr num (-1 for no intr)
408 * (u32)a1 = effective size
410 CMD_SUBVNIC_NOTIFY = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 54),
413 * Set the predefined mac address as default
417 CMD_SET_MAC_ADDR = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 55),
419 /* Update the provisioning info of the given VIF
420 * (u64)a0=paddr of vnic_devcmd_provinfo
421 * (u32)a1=sizeof provision info */
422 CMD_PROV_INFO_UPDATE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 56),
425 * Initialization for the devcmd2 interface.
426 * in: (u64) a0=host result buffer physical address
427 * in: (u16) a1=number of entries in result buffer
429 CMD_INITIALIZE_DEVCMD2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 57),
433 * in: (u64) a0= filter address
434 * (u32) a1= size of filter
435 * out: (u32) a0=filter identifier
438 * out: (u64) a0= 1 if capability query supported
439 * (u64) a1= MAX filter type supported
441 CMD_ADD_FILTER = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 58),
445 * in: (u32) a0=filter identifier
447 CMD_DEL_FILTER = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 59),
450 * Enable a Queue Pair in User space NIC
451 * in: (u32) a0=Queue Pair number
454 CMD_QP_ENABLE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 60),
457 * Disable a Queue Pair in User space NIC
458 * in: (u32) a0=Queue Pair number
461 CMD_QP_DISABLE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 61),
464 * Stats dump Queue Pair in User space NIC
465 * in: (u32) a0=Queue Pair number
466 * (u64) a1=host buffer addr for status dump
467 * (u32) a2=length of the buffer
469 CMD_QP_STATS_DUMP = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 62),
472 * Clear stats for Queue Pair in User space NIC
473 * in: (u32) a0=Queue Pair number
475 CMD_QP_STATS_CLEAR = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 63),
478 * UEFI BOOT API: (u64)a0= UEFI FLS_CMD_xxx
479 * (ui64)a1= paddr for the info buffer
481 CMD_FC_REQ = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_FC, 64),
484 * Return the iSCSI config details required by the EFI Option ROM
485 * in: (u32) a0=0 Get Boot Info for PXE eNIC as per pxe_boot_config_t
486 * a0=1 Get Boot info for iSCSI enic as per
487 * iscsi_boot_efi_cfg_t
488 * in: (u64) a1=Host address where iSCSI config info is returned
490 CMD_VNIC_BOOT_CONFIG_INFO = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 65),
493 * Create a Queue Pair (RoCE)
494 * in: (u32) a0 = Queue Pair number
495 * (u32) a1 = Remote QP
497 * (u16) a3 = RQ Res Group
498 * (u16) a4 = SQ Res Group
499 * (u32) a5 = Protection Domain
500 * (u64) a6 = Remote MAC
501 * (u32) a7 = start PSN
503 * (u32) a9 = protocol version
505 CMD_RDMA_QP_CREATE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 66),
508 * Delete a Queue Pair (RoCE)
509 * in: (u32) a0 = Queue Pair number
511 CMD_RDMA_QP_DELETE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 67),
514 * Retrieve a Queue Pair's status information (RoCE)
515 * in: (u32) a0 = Queue Pair number
516 * (u64) a1 = host buffer addr for QP status struct
517 * (u32) a2 = length of the buffer
519 CMD_RDMA_QP_STATUS = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 68),
522 * Use this devcmd for agreeing on the highest common version supported
523 * by both driver and fw for by features who need such a facility.
524 * in: (u64) a0 = feature (driver requests for the supported versions
526 * out: (u64) a0 = bitmap of all supported versions for that feature
528 CMD_GET_SUPP_FEATURE_VER = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 69),
531 * Initialize the RDMA notification work queue
532 * in: (u64) a0 = host buffer address
533 * in: (u16) a1 = number of entries in buffer
534 * in: (u16) a2 = resource group number
535 * in: (u16) a3 = CQ number to post completion
537 CMD_RDMA_INIT_INFO_BUF = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 70),
540 * De-init the RDMA notification work queue
541 * in: (u64) a0=resource group number
543 CMD_RDMA_DEINIT_INFO_BUF = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 71),
546 * Control (Enable/Disable) overlay offloads on the given vnic
547 * in: (u8) a0 = OVERLAY_FEATURE_NVGRE : NVGRE
548 * a0 = OVERLAY_FEATURE_VXLAN : VxLAN
549 * in: (u8) a1 = OVERLAY_OFFLOAD_ENABLE : Enable or
550 * a1 = OVERLAY_OFFLOAD_DISABLE : Disable or
551 * a1 = OVERLAY_OFFLOAD_ENABLE_V2 : Enable with version 2
553 CMD_OVERLAY_OFFLOAD_CTRL =
554 _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 72),
557 * Configuration of overlay offloads feature on a given vNIC
558 * in: (u8) a0 = OVERLAY_CFG_VXLAN_PORT_UPDATE : VxLAN
559 * in: (u16) a1 = unsigned short int port information
561 CMD_OVERLAY_OFFLOAD_CFG = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 73),
564 * Return the configured name for the device
565 * in: (u64) a0=Host address where the name is copied
566 * (u32) a1=Size of the buffer
568 CMD_GET_CONFIG_NAME = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 74),
571 * Enable group interrupt for the VF
572 * in: (u32) a0 = GRPINTR_ENABLE : enable
573 * a0 = GRPINTR_DISABLE : disable
574 * a0 = GRPINTR_UPD_VECT: update group vector addr
575 * in: (u32) a1 = interrupt group count
576 * in: (u64) a2 = Start of host buffer address for DMAing group
578 * in: (u64) a3 = Stride between group vectors
580 CMD_CONFIG_GRPINTR = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 75),
583 * Set cq arrary base and size in a list of consective wqs and
585 * in: (u16) a0 = the wq relative index in the device.
586 * -1 indicates skipping wq configuration
587 * in: (u16) a1 = the wcq relative index in the device
588 * in: (u16) a2 = the rq relative index in the device
589 * -1 indicates skipping rq configuration
590 * in: (u16) a3 = the rcq relative index in the device
592 CMD_CONFIG_CQ_ARRAY = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 76),
595 * Add an advanced filter.
596 * in: (u64) a0= filter address
597 * (u32) a1= size of filter
598 * out: (u32) a0=filter identifier
601 * out: (u64) a0= 1 if capabliity query supported
602 * (u64) a1= MAX filter type supported
604 CMD_ADD_ADV_FILTER = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 77),
607 /* CMD_ENABLE2 flags */
608 #define CMD_ENABLE2_STANDBY 0x0
609 #define CMD_ENABLE2_ACTIVE 0x1
611 /* flags for CMD_OPEN */
612 #define CMD_OPENF_OPROM 0x1 /* open coming from option rom */
614 /* flags for CMD_INIT */
615 #define CMD_INITF_DEFAULT_MAC 0x1 /* init with default mac addr */
617 /* flags for CMD_PACKET_FILTER */
618 #define CMD_PFILTER_DIRECTED 0x01
619 #define CMD_PFILTER_MULTICAST 0x02
620 #define CMD_PFILTER_BROADCAST 0x04
621 #define CMD_PFILTER_PROMISCUOUS 0x08
622 #define CMD_PFILTER_ALL_MULTICAST 0x10
624 /* Commands for CMD_QP_ENABLE/CM_QP_DISABLE */
625 #define CMD_QP_RQWQ 0x0
627 /* rewrite modes for CMD_IG_VLAN_REWRITE_MODE */
628 #define IG_VLAN_REWRITE_MODE_DEFAULT_TRUNK 0
629 #define IG_VLAN_REWRITE_MODE_UNTAG_DEFAULT_VLAN 1
630 #define IG_VLAN_REWRITE_MODE_PRIORITY_TAG_DEFAULT_VLAN 2
631 #define IG_VLAN_REWRITE_MODE_PASS_THRU 3
633 enum vnic_devcmd_status {
635 STAT_BUSY = 1 << 0, /* cmd in progress */
636 STAT_ERROR = 1 << 1, /* last cmd caused error (code in a0) */
637 STAT_FAILOVER = 1 << 2, /* always set on vnics in pci standby state
638 * if seen a failover to the standby happened
642 enum vnic_devcmd_error {
654 ERR_ENOTSUPPORTED = 11,
655 ERR_EINPROGRESS = 12,
660 * note: hw_version and asic_rev refer to the same thing,
661 * but have different formats. hw_version is
662 * a 32-byte string (e.g. "A2") and asic_rev is
663 * a 16-bit integer (e.g. 0xA2).
665 struct vnic_devcmd_fw_info {
669 char hw_serial_number[32];
674 enum fwinfo_asic_type {
675 FWINFO_ASIC_TYPE_UNKNOWN,
676 FWINFO_ASIC_TYPE_PALO,
677 FWINFO_ASIC_TYPE_SERENO,
678 FWINFO_ASIC_TYPE_CRUZ,
681 struct vnic_devcmd_notify {
682 u32 csum; /* checksum over following words */
684 u32 link_state; /* link up == 1 */
685 u32 port_speed; /* effective port speed (rate limit) */
687 u32 msglvl; /* requested driver msg lvl */
688 u32 uif; /* uplink interface */
689 u32 status; /* status bits (see VNIC_STF_*) */
690 u32 error; /* error code (see ERR_*) for first ERR */
691 u32 link_down_cnt; /* running count of link down transitions */
692 u32 perbi_rebuild_cnt; /* running count of perbi rebuilds */
694 #define VNIC_STF_FATAL_ERR 0x0001 /* fatal fw error */
695 #define VNIC_STF_STD_PAUSE 0x0002 /* standard link-level pause on */
696 #define VNIC_STF_PFC_PAUSE 0x0004 /* priority flow control pause on */
697 /* all supported status flags */
698 #define VNIC_STF_ALL (VNIC_STF_FATAL_ERR |\
699 VNIC_STF_STD_PAUSE |\
700 VNIC_STF_PFC_PAUSE |\
703 struct vnic_devcmd_provinfo {
710 * These are used in flags field of different filters to denote
713 #define FILTER_FIELD_VALID(fld) (1 << (fld - 1))
715 #define FILTER_FIELD_USNIC_VLAN FILTER_FIELD_VALID(1)
716 #define FILTER_FIELD_USNIC_ETHTYPE FILTER_FIELD_VALID(2)
717 #define FILTER_FIELD_USNIC_PROTO FILTER_FIELD_VALID(3)
718 #define FILTER_FIELD_USNIC_ID FILTER_FIELD_VALID(4)
720 #define FILTER_FIELDS_USNIC (FILTER_FIELD_USNIC_VLAN | \
721 FILTER_FIELD_USNIC_ETHTYPE | \
722 FILTER_FIELD_USNIC_PROTO | \
723 FILTER_FIELD_USNIC_ID)
725 struct filter_usnic_id {
731 } __attribute__((packed));
733 #define FILTER_FIELD_5TUP_PROTO FILTER_FIELD_VALID(1)
734 #define FILTER_FIELD_5TUP_SRC_AD FILTER_FIELD_VALID(2)
735 #define FILTER_FIELD_5TUP_DST_AD FILTER_FIELD_VALID(3)
736 #define FILTER_FIELD_5TUP_SRC_PT FILTER_FIELD_VALID(4)
737 #define FILTER_FIELD_5TUP_DST_PT FILTER_FIELD_VALID(5)
739 #define FILTER_FIELDS_IPV4_5TUPLE (FILTER_FIELD_5TUP_PROTO | \
740 FILTER_FIELD_5TUP_SRC_AD | \
741 FILTER_FIELD_5TUP_DST_AD | \
742 FILTER_FIELD_5TUP_SRC_PT | \
743 FILTER_FIELD_5TUP_DST_PT)
745 /* Enums for the protocol field. */
753 struct filter_ipv4_5tuple {
760 } __attribute__((packed));
762 #define FILTER_FIELD_VMQ_VLAN FILTER_FIELD_VALID(1)
763 #define FILTER_FIELD_VMQ_MAC FILTER_FIELD_VALID(2)
765 #define FILTER_FIELDS_MAC_VLAN (FILTER_FIELD_VMQ_VLAN | \
766 FILTER_FIELD_VMQ_MAC)
768 #define FILTER_FIELDS_NVGRE FILTER_FIELD_VMQ_MAC
770 struct filter_mac_vlan {
774 } __attribute__((packed));
776 #define FILTER_FIELD_VLAN_IP_3TUP_VLAN FILTER_FIELD_VALID(1)
777 #define FILTER_FIELD_VLAN_IP_3TUP_L3_PROTO FILTER_FIELD_VALID(2)
778 #define FILTER_FIELD_VLAN_IP_3TUP_DST_AD FILTER_FIELD_VALID(3)
779 #define FILTER_FIELD_VLAN_IP_3TUP_L4_PROTO FILTER_FIELD_VALID(4)
780 #define FILTER_FIELD_VLAN_IP_3TUP_DST_PT FILTER_FIELD_VALID(5)
782 #define FILTER_FIELDS_VLAN_IP_3TUP (FILTER_FIELD_VLAN_IP_3TUP_VLAN | \
783 FILTER_FIELD_VLAN_IP_3TUP_L3_PROTO | \
784 FILTER_FIELD_VLAN_IP_3TUP_DST_AD | \
785 FILTER_FIELD_VLAN_IP_3TUP_L4_PROTO | \
786 FILTER_FIELD_VLAN_IP_3TUP_DST_PT)
788 struct filter_vlan_ip_3tuple {
798 } __attribute__((packed));
800 #define FILTER_GENERIC_1_BYTES 64
802 enum filter_generic_1_layer {
807 FILTER_GENERIC_1_NUM_LAYERS
810 #define FILTER_GENERIC_1_IPV4 (1 << 0)
811 #define FILTER_GENERIC_1_IPV6 (1 << 1)
812 #define FILTER_GENERIC_1_UDP (1 << 2)
813 #define FILTER_GENERIC_1_TCP (1 << 3)
814 #define FILTER_GENERIC_1_TCP_OR_UDP (1 << 4)
815 #define FILTER_GENERIC_1_IP4SUM_OK (1 << 5)
816 #define FILTER_GENERIC_1_L4SUM_OK (1 << 6)
817 #define FILTER_GENERIC_1_IPFRAG (1 << 7)
819 #define FILTER_GENERIC_1_KEY_LEN 64
822 * Version 1 of generic filter specification
823 * position is only 16 bits, reserving positions > 64k to be used by firmware
825 struct filter_generic_1 {
826 u16 position; /* lower position comes first */
832 u8 mask[FILTER_GENERIC_1_KEY_LEN]; /* 0 bit means "don't care"*/
833 u8 val[FILTER_GENERIC_1_KEY_LEN];
834 } __attribute__((packed)) layer[FILTER_GENERIC_1_NUM_LAYERS];
835 } __attribute__((packed));
837 /* Specifies the filter_action type. */
839 FILTER_ACTION_RQ_STEERING = 0,
843 struct filter_action {
848 } __attribute__((packed));
850 /* Specifies the filter type. */
853 FILTER_IPV4_5TUPLE = 1,
855 FILTER_VLAN_IP_3TUPLE = 3,
856 FILTER_NVGRE_VMQ = 4,
865 struct filter_usnic_id usnic;
866 struct filter_ipv4_5tuple ipv4;
867 struct filter_mac_vlan mac_vlan;
868 struct filter_vlan_ip_3tuple vlan_3tuple;
870 } __attribute__((packed));
873 * This is a strict superset of "struct filter" and exists only
874 * because many drivers use "sizeof (struct filter)" in deciding TLV size.
875 * This new, larger struct filter would cause any code that uses that method
876 * to not work with older firmware, so we add filter_v2 to hold the
877 * new filter types. Drivers should use vnic_filter_size() to determine
878 * the TLV size instead of sizeof (struct fiter_v2) to guard against future
884 struct filter_usnic_id usnic;
885 struct filter_ipv4_5tuple ipv4;
886 struct filter_mac_vlan mac_vlan;
887 struct filter_vlan_ip_3tuple vlan_3tuple;
888 struct filter_generic_1 generic_1;
890 } __attribute__((packed));
903 /* Data for CMD_ADD_FILTER is 2 TLV and filter + action structs */
904 #define FILTER_MAX_BUF_SIZE 100
905 #define FILTER_V2_MAX_BUF_SIZE (sizeof(struct filter_v2) + \
906 sizeof(struct filter_action) + \
907 (2 * sizeof(struct filter_tlv)))
910 * Compute actual structure size given filter type. To be "future-proof,"
911 * drivers should use this instead of "sizeof (struct filter_v2)" when
912 * computing length for TLV.
914 static inline u_int32_t
915 vnic_filter_size(struct filter_v2 *fp)
920 case FILTER_USNIC_ID:
921 size = sizeof(fp->u.usnic);
923 case FILTER_IPV4_5TUPLE:
924 size = sizeof(fp->u.ipv4);
926 case FILTER_MAC_VLAN:
927 case FILTER_NVGRE_VMQ:
928 size = sizeof(fp->u.mac_vlan);
930 case FILTER_VLAN_IP_3TUPLE:
931 size = sizeof(fp->u.vlan_3tuple);
933 case FILTER_USNIC_IP:
935 size = sizeof(fp->u.generic_1);
938 size = sizeof(fp->u);
941 size += sizeof(fp->type);
952 * Writing cmd register causes STAT_BUSY to get set in status register.
953 * When cmd completes, STAT_BUSY will be cleared.
955 * If cmd completed successfully STAT_ERROR will be clear
956 * and args registers contain cmd-specific results.
958 * If cmd error, STAT_ERROR will be set and args[0] contains error code.
960 * status register is read-only. While STAT_BUSY is set,
961 * all other register contents are read-only.
964 /* Make sizeof(vnic_devcmd) a power-of-2 for I/O BAR. */
965 #define VNIC_DEVCMD_NARGS 15
969 u64 args[VNIC_DEVCMD_NARGS]; /* RW cmd args (little-endian) */
973 * Version 2 of the interface.
975 * Some things are carried over, notably the vnic_devcmd_cmd enum.
979 * Flags for vnic_devcmd2.flags
982 #define DEVCMD2_FNORESULT 0x1 /* Don't copy result to host */
984 #define VNIC_DEVCMD2_NARGS VNIC_DEVCMD_NARGS
985 struct vnic_devcmd2 {
988 u32 cmd; /* same command #defines as original */
989 u64 args[VNIC_DEVCMD2_NARGS];
992 #define VNIC_DEVCMD2_NRESULTS VNIC_DEVCMD_NARGS
993 struct devcmd2_result {
994 u64 results[VNIC_DEVCMD2_NRESULTS];
996 u16 completed_index; /* into copy WQ */
997 u8 error; /* same error codes as original */
998 u8 color; /* 0 or 1 as with completion queues */
1001 #define DEVCMD2_RING_SIZE 32
1002 #define DEVCMD2_DESC_SIZE 128
1004 #define DEVCMD2_RESULTS_SIZE_MAX ((1 << 16) - 1)
1006 /* Overlay related definitions */
1009 * This enum lists the flag associated with each of the overlay features
1012 OVERLAY_FEATURE_NVGRE = 1,
1013 OVERLAY_FEATURE_VXLAN,
1014 OVERLAY_FEATURE_MAX,
1015 } overlay_feature_t;
1017 #define OVERLAY_OFFLOAD_ENABLE 0
1018 #define OVERLAY_OFFLOAD_DISABLE 1
1019 #define OVERLAY_OFFLOAD_ENABLE_V2 2
1021 #define OVERLAY_CFG_VXLAN_PORT_UPDATE 0
1024 * Use this enum to get the supported versions for each of these features
1025 * If you need to use the devcmd_get_supported_feature_version(), add
1026 * the new feature into this enum and install function handler in devcmd.c
1035 * CMD_CONFIG_GRPINTR subcommands
1043 #endif /* _VNIC_DEVCMD_H_ */