1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright 2008 Cisco Systems, Inc. All rights reserved.
4 * 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 enum vnic_devcmd_cmd
{
67 CMD_NONE
= _CMDC(_CMD_DIR_NONE
, _CMD_VTYPE_NONE
, 0),
69 /* mcpu fw info in mem: (u64)a0=paddr to struct vnic_devcmd_fw_info */
70 CMD_MCPU_FW_INFO
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_ALL
, 1),
72 /* dev-specific block member:
73 * in: (u16)a0=offset,(u8)a1=size
75 CMD_DEV_SPEC
= _CMDC(_CMD_DIR_RW
, _CMD_VTYPE_ALL
, 2),
78 CMD_STATS_CLEAR
= _CMDCNW(_CMD_DIR_NONE
, _CMD_VTYPE_ALL
, 3),
80 /* stats dump in mem: (u64)a0=paddr to stats area,
81 * (u16)a1=sizeof stats area */
82 CMD_STATS_DUMP
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_ALL
, 4),
84 /* set Rx packet filter: (u32)a0=filters (see CMD_PFILTER_*) */
85 CMD_PACKET_FILTER
= _CMDCNW(_CMD_DIR_WRITE
, _CMD_VTYPE_ALL
, 7),
87 /* hang detection notification */
88 CMD_HANG_NOTIFY
= _CMDC(_CMD_DIR_NONE
, _CMD_VTYPE_ALL
, 8),
90 /* MAC address in (u48)a0 */
91 CMD_MAC_ADDR
= _CMDC(_CMD_DIR_READ
,
92 _CMD_VTYPE_ENET
| _CMD_VTYPE_FC
, 9),
94 /* disable/enable promisc mode: (u8)a0=0/1 */
95 /***** XXX DEPRECATED *****/
96 CMD_PROMISC_MODE
= _CMDCNW(_CMD_DIR_WRITE
, _CMD_VTYPE_ENET
, 10),
98 /* disable/enable all-multi mode: (u8)a0=0/1 */
99 /***** XXX DEPRECATED *****/
100 CMD_ALLMULTI_MODE
= _CMDCNW(_CMD_DIR_WRITE
, _CMD_VTYPE_ENET
, 11),
102 /* add addr from (u48)a0 */
103 CMD_ADDR_ADD
= _CMDCNW(_CMD_DIR_WRITE
,
104 _CMD_VTYPE_ENET
| _CMD_VTYPE_FC
, 12),
106 /* del addr from (u48)a0 */
107 CMD_ADDR_DEL
= _CMDCNW(_CMD_DIR_WRITE
,
108 _CMD_VTYPE_ENET
| _CMD_VTYPE_FC
, 13),
110 /* add VLAN id in (u16)a0 */
111 CMD_VLAN_ADD
= _CMDCNW(_CMD_DIR_WRITE
, _CMD_VTYPE_ENET
, 14),
113 /* del VLAN id in (u16)a0 */
114 CMD_VLAN_DEL
= _CMDCNW(_CMD_DIR_WRITE
, _CMD_VTYPE_ENET
, 15),
116 /* nic_cfg in (u32)a0 */
117 CMD_NIC_CFG
= _CMDCNW(_CMD_DIR_WRITE
, _CMD_VTYPE_ALL
, 16),
119 /* union vnic_rss_key in mem: (u64)a0=paddr, (u16)a1=len */
120 CMD_RSS_KEY
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_ENET
, 17),
122 /* union vnic_rss_cpu in mem: (u64)a0=paddr, (u16)a1=len */
123 CMD_RSS_CPU
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_ENET
, 18),
125 /* initiate softreset */
126 CMD_SOFT_RESET
= _CMDCNW(_CMD_DIR_NONE
, _CMD_VTYPE_ALL
, 19),
129 * out: a0=0 reset complete, a0=1 reset in progress */
130 CMD_SOFT_RESET_STATUS
= _CMDC(_CMD_DIR_READ
, _CMD_VTYPE_ALL
, 20),
132 /* set struct vnic_devcmd_notify buffer in mem:
134 * (u64)a0=paddr to notify (set paddr=0 to unset)
135 * (u32)a1 & 0x00000000ffffffff=sizeof(struct vnic_devcmd_notify)
136 * (u16)a1 & 0x0000ffff00000000=intr num (-1 for no intr)
138 * (u32)a1 = effective size
140 CMD_NOTIFY
= _CMDC(_CMD_DIR_RW
, _CMD_VTYPE_ALL
, 21),
142 /* UNDI API: (u64)a0=paddr to s_PXENV_UNDI_ struct,
143 * (u8)a1=PXENV_UNDI_xxx */
144 CMD_UNDI
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_ENET
, 22),
146 /* initiate open sequence (u32)a0=flags (see CMD_OPENF_*) */
147 CMD_OPEN
= _CMDCNW(_CMD_DIR_WRITE
, _CMD_VTYPE_ALL
, 23),
150 * out: a0=0 open complete, a0=1 open in progress */
151 CMD_OPEN_STATUS
= _CMDC(_CMD_DIR_READ
, _CMD_VTYPE_ALL
, 24),
154 CMD_CLOSE
= _CMDC(_CMD_DIR_NONE
, _CMD_VTYPE_ALL
, 25),
156 /* initialize virtual link: (u32)a0=flags (see CMD_INITF_*) */
157 CMD_INIT
= _CMDCNW(_CMD_DIR_READ
, _CMD_VTYPE_ALL
, 26),
159 /* variant of CMD_INIT, with provisioning info
160 * (u64)a0=paddr of vnic_devcmd_provinfo
161 * (u32)a1=sizeof provision info
163 CMD_INIT_PROV_INFO
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_ENET
, 27),
165 /* enable virtual link */
166 CMD_ENABLE
= _CMDCNW(_CMD_DIR_WRITE
, _CMD_VTYPE_ALL
, 28),
168 /* disable virtual link */
169 CMD_DISABLE
= _CMDC(_CMD_DIR_NONE
, _CMD_VTYPE_ALL
, 29),
171 /* stats dump all vnics on uplink in mem: (u64)a0=paddr (u32)a1=uif */
172 CMD_STATS_DUMP_ALL
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_ALL
, 30),
175 * out: a0=0 init complete, a0=1 init in progress
176 * if a0=0, a1=errno */
177 CMD_INIT_STATUS
= _CMDC(_CMD_DIR_READ
, _CMD_VTYPE_ALL
, 31),
179 /* INT13 API: (u64)a0=paddr to vnic_int13_params struct
180 * (u8)a1=INT13_CMD_xxx */
181 CMD_INT13
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_FC
, 32),
183 /* logical uplink enable/disable: (u64)a0: 0/1=disable/enable */
184 CMD_LOGICAL_UPLINK
= _CMDCNW(_CMD_DIR_WRITE
, _CMD_VTYPE_ENET
, 33),
186 /* undo initialize of virtual link */
187 CMD_DEINIT
= _CMDCNW(_CMD_DIR_NONE
, _CMD_VTYPE_ALL
, 34),
189 /* check fw capability of a cmd:
191 * out: (u32)a0=errno, 0:valid cmd, a1=supported VNIC_STF_* bits */
192 CMD_CAPABILITY
= _CMDC(_CMD_DIR_RW
, _CMD_VTYPE_ALL
, 36),
194 /* persistent binding info
195 * in: (u64)a0=paddr of arg
196 * (u32)a1=CMD_PERBI_XXX */
197 CMD_PERBI
= _CMDC(_CMD_DIR_RW
, _CMD_VTYPE_FC
, 37),
199 /* Interrupt Assert Register functionality
200 * in: (u16)a0=interrupt number to assert
202 CMD_IAR
= _CMDCNW(_CMD_DIR_WRITE
, _CMD_VTYPE_ALL
, 38),
204 /* initiate hangreset, like softreset after hang detected */
205 CMD_HANG_RESET
= _CMDC(_CMD_DIR_NONE
, _CMD_VTYPE_ALL
, 39),
208 * out: a0=0 reset complete, a0=1 reset in progress */
209 CMD_HANG_RESET_STATUS
= _CMDC(_CMD_DIR_READ
, _CMD_VTYPE_ALL
, 40),
212 * Set hw ingress packet vlan rewrite mode:
213 * in: (u32)a0=new vlan rewrite mode
214 * out: (u32)a0=old vlan rewrite mode */
215 CMD_IG_VLAN_REWRITE_MODE
= _CMDC(_CMD_DIR_RW
, _CMD_VTYPE_ENET
, 41),
218 * in: (u16)a0=bdf of target vnic
219 * (u32)a1=cmd to proxy
220 * a2-a15=args to cmd in a1
221 * out: (u32)a0=status of proxied cmd
222 * a1-a15=out args of proxied cmd */
223 CMD_PROXY_BY_BDF
= _CMDC(_CMD_DIR_RW
, _CMD_VTYPE_ALL
, 42),
226 * As for BY_BDF except a0 is index of hvnlink subordinate vnic
227 * or SR-IOV virtual vnic
229 CMD_PROXY_BY_INDEX
= _CMDC(_CMD_DIR_RW
, _CMD_VTYPE_ALL
, 43),
234 * in: (u64)a0=phsical address of buffer passed in from caller.
235 * (u16)a1=size of buffer specified in a0.
236 * out: (u64)a0=phsical address of buffer passed in from caller.
237 * (u16)a1=actual bytes from VIF-CONFIG-INFO TLV, or
238 * 0 if no VIF-CONFIG-INFO TLV was ever received. */
239 CMD_CONFIG_INFO_GET
= _CMDC(_CMD_DIR_RW
, _CMD_VTYPE_ALL
, 44),
242 * INT13 API: (u64)a0=paddr to vnic_int13_params struct
243 * (u32)a1=INT13_CMD_xxx
245 CMD_INT13_ALL
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_ALL
, 45),
249 * in: (u16)a0=new default vlan
250 * (u16)a1=zero for overriding vlan with param a0,
251 * non-zero for resetting vlan to the default
252 * out: (u16)a0=old default vlan
254 CMD_SET_DEFAULT_VLAN
= _CMDC(_CMD_DIR_RW
, _CMD_VTYPE_ALL
, 46),
257 * Variant of CMD_INIT_PROV_INFO, where it will not try to enable
258 * the vnic until CMD_ENABLE2 is issued.
259 * (u64)a0=paddr of vnic_devcmd_provinfo
260 * (u32)a1=sizeof provision info
262 CMD_INIT_PROV_INFO2
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_ENET
, 47),
265 * (u32)a0=0 ==> standby
266 * =CMD_ENABLE2_ACTIVE ==> active
268 CMD_ENABLE2
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_ENET
, 48),
272 * Returns the status of the specified command
274 * a0 = command for which status is being queried.
275 * Possible values are:
282 * CMD_INIT_PROV_INFO2
285 * if status == STAT_ERROR
286 * a0 = ERR_ENOTSUPPORTED - status for command in a0 is
288 * if status == STAT_NONE
289 * a0 = status of the devcmd specified in a0 as follows.
290 * ERR_SUCCESS - command in a0 completed successfully
291 * ERR_EINPROGRESS - command in a0 is still in progress
293 CMD_STATUS
= _CMDC(_CMD_DIR_RW
, _CMD_VTYPE_ALL
, 49),
296 * Returns interrupt coalescing timer conversion factors.
297 * After calling this devcmd, ENIC driver can convert
298 * interrupt coalescing timer in usec into CPU cycles as follows:
300 * intr_timer_cycles = intr_timer_usec * multiplier / divisor
302 * Interrupt coalescing timer in usecs can be be converted/obtained
303 * from CPU cycles as follows:
305 * intr_timer_usec = intr_timer_cycles * divisor / multiplier
308 * out: (u32)a0 = multiplier
310 * (u32)a2 = maximum timer value in usec
312 CMD_INTR_COAL_CONVERT
= _CMDC(_CMD_DIR_READ
, _CMD_VTYPE_ALL
, 50),
316 * in: (u64)a0=paddr of the param or param itself
317 * (u32)a1=ISCSI_CMD_xxx
319 CMD_ISCSI_DUMP_REQ
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_ALL
, 51),
322 * ISCSI DUMP STATUS API:
323 * in: (u32)a0=cmd tag
324 * in: (u32)a1=ISCSI_CMD_xxx
325 * out: (u32)a0=cmd status
327 CMD_ISCSI_DUMP_STATUS
= _CMDC(_CMD_DIR_RW
, _CMD_VTYPE_ALL
, 52),
330 * Subvnic migration from MQ <--> VF.
331 * Enable the LIF migration from MQ to VF and vice versa. MQ and VF
332 * indexes are statically bound at the time of initialization.
334 * direction of migration, the resources of either MQ or the VF shall
335 * be attached to the LIF.
336 * in: (u32)a0=Direction of Migration
339 * (u32)a1=VF index (MQ index)
341 CMD_MIGRATE_SUBVNIC
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_ENET
, 53),
344 * Register / Deregister the notification block for MQ subvnics
346 * (u64)a0=paddr to notify (set paddr=0 to unset)
347 * (u32)a1 & 0x00000000ffffffff=sizeof(struct vnic_devcmd_notify)
348 * (u16)a1 & 0x0000ffff00000000=intr num (-1 for no intr)
350 * (u32)a1 = effective size
352 CMD_SUBVNIC_NOTIFY
= _CMDC(_CMD_DIR_RW
, _CMD_VTYPE_ALL
, 54),
355 * Set the predefined mac address as default
359 CMD_SET_MAC_ADDR
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_ENET
, 55),
361 /* Update the provisioning info of the given VIF
362 * (u64)a0=paddr of vnic_devcmd_provinfo
363 * (u32)a1=sizeof provision info
365 CMD_PROV_INFO_UPDATE
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_ENET
, 56),
368 * Initialization for the devcmd2 interface.
369 * in: (u64) a0=host result buffer physical address
370 * in: (u16) a1=number of entries in result buffer
372 CMD_INITIALIZE_DEVCMD2
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_ALL
, 57)
375 /* flags for CMD_OPEN */
376 #define CMD_OPENF_OPROM 0x1 /* open coming from option rom */
378 #define CMD_OPENF_RQ_ENABLE_THEN_POST 0x2
380 /* flags for CMD_INIT */
381 #define CMD_INITF_DEFAULT_MAC 0x1 /* init with default mac addr */
383 /* flags for CMD_PACKET_FILTER */
384 #define CMD_PFILTER_DIRECTED 0x01
385 #define CMD_PFILTER_MULTICAST 0x02
386 #define CMD_PFILTER_BROADCAST 0x04
387 #define CMD_PFILTER_PROMISCUOUS 0x08
388 #define CMD_PFILTER_ALL_MULTICAST 0x10
390 enum vnic_devcmd_status
{
392 STAT_BUSY
= 1 << 0, /* cmd in progress */
393 STAT_ERROR
= 1 << 1, /* last cmd caused error (code in a0) */
396 enum vnic_devcmd_error
{
409 struct vnic_devcmd_fw_info
{
413 char hw_serial_number
[32];
416 struct vnic_devcmd_notify
{
417 u32 csum
; /* checksum over following words */
419 u32 link_state
; /* link up == 1 */
420 u32 port_speed
; /* effective port speed (rate limit) */
422 u32 msglvl
; /* requested driver msg lvl */
423 u32 uif
; /* uplink interface */
424 u32 status
; /* status bits (see VNIC_STF_*) */
425 u32 error
; /* error code (see ERR_*) for first ERR */
426 u32 link_down_cnt
; /* running count of link down transitions */
428 #define VNIC_STF_FATAL_ERR 0x0001 /* fatal fw error */
430 struct vnic_devcmd_provinfo
{
437 * Writing cmd register causes STAT_BUSY to get set in status register.
438 * When cmd completes, STAT_BUSY will be cleared.
440 * If cmd completed successfully STAT_ERROR will be clear
441 * and args registers contain cmd-specific results.
443 * If cmd error, STAT_ERROR will be set and args[0] contains error code.
445 * status register is read-only. While STAT_BUSY is set,
446 * all other register contents are read-only.
449 /* Make sizeof(vnic_devcmd) a power-of-2 for I/O BAR. */
450 #define VNIC_DEVCMD_NARGS 15
454 u64 args
[VNIC_DEVCMD_NARGS
]; /* RW cmd args (little-endian) */
458 * Version 2 of the interface.
460 * Some things are carried over, notably the vnic_devcmd_cmd enum.
464 * Flags for vnic_devcmd2.flags
467 #define DEVCMD2_FNORESULT 0x1 /* Don't copy result to host */
469 #define VNIC_DEVCMD2_NARGS VNIC_DEVCMD_NARGS
471 struct vnic_devcmd2
{
474 u32 cmd
; /* same command #defines as original */
475 u64 args
[VNIC_DEVCMD2_NARGS
];
478 #define VNIC_DEVCMD2_NRESULTS VNIC_DEVCMD_NARGS
479 struct devcmd2_result
{
480 u64 results
[VNIC_DEVCMD2_NRESULTS
];
482 u16 completed_index
; /* into copy WQ */
483 u8 error
; /* same error codes as original */
484 u8 color
; /* 0 or 1 as with completion queues */
487 #define DEVCMD2_RING_SIZE 32
488 #define DEVCMD2_DESC_SIZE 128
490 #define DEVCMD2_RESULTS_SIZE_MAX ((1 << 16) - 1)
492 #endif /* _VNIC_DEVCMD_H_ */