2 * Copyright 2008-2010 Cisco Systems, Inc. All rights reserved.
3 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
5 * This program is free software; you may redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
10 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
11 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
12 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
13 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
14 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
15 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 #ifndef _VNIC_DEVCMD_H_
21 #define _VNIC_DEVCMD_H_
24 #define _CMD_VTYPEBITS 10
25 #define _CMD_FLAGSBITS 6
26 #define _CMD_DIRBITS 2
28 #define _CMD_NMASK ((1 << _CMD_NBITS)-1)
29 #define _CMD_VTYPEMASK ((1 << _CMD_VTYPEBITS)-1)
30 #define _CMD_FLAGSMASK ((1 << _CMD_FLAGSBITS)-1)
31 #define _CMD_DIRMASK ((1 << _CMD_DIRBITS)-1)
34 #define _CMD_VTYPESHIFT (_CMD_NSHIFT+_CMD_NBITS)
35 #define _CMD_FLAGSSHIFT (_CMD_VTYPESHIFT+_CMD_VTYPEBITS)
36 #define _CMD_DIRSHIFT (_CMD_FLAGSSHIFT+_CMD_FLAGSBITS)
39 * Direction bits (from host perspective).
41 #define _CMD_DIR_NONE 0U
42 #define _CMD_DIR_WRITE 1U
43 #define _CMD_DIR_READ 2U
44 #define _CMD_DIR_RW (_CMD_DIR_WRITE | _CMD_DIR_READ)
49 #define _CMD_FLAGS_NONE 0U
50 #define _CMD_FLAGS_NOWAIT 1U
55 #define _CMD_VTYPE_NONE 0U
56 #define _CMD_VTYPE_ENET 1U
57 #define _CMD_VTYPE_FC 2U
58 #define _CMD_VTYPE_SCSI 4U
59 #define _CMD_VTYPE_ALL (_CMD_VTYPE_ENET | _CMD_VTYPE_FC | _CMD_VTYPE_SCSI)
62 * Used to create cmds..
64 #define _CMDCF(dir, flags, vtype, nr) \
65 (((dir) << _CMD_DIRSHIFT) | \
66 ((flags) << _CMD_FLAGSSHIFT) | \
67 ((vtype) << _CMD_VTYPESHIFT) | \
68 ((nr) << _CMD_NSHIFT))
69 #define _CMDC(dir, vtype, nr) _CMDCF(dir, 0, vtype, nr)
70 #define _CMDCNW(dir, vtype, nr) _CMDCF(dir, _CMD_FLAGS_NOWAIT, vtype, nr)
73 * Used to decode cmds..
75 #define _CMD_DIR(cmd) (((cmd) >> _CMD_DIRSHIFT) & _CMD_DIRMASK)
76 #define _CMD_FLAGS(cmd) (((cmd) >> _CMD_FLAGSSHIFT) & _CMD_FLAGSMASK)
77 #define _CMD_VTYPE(cmd) (((cmd) >> _CMD_VTYPESHIFT) & _CMD_VTYPEMASK)
78 #define _CMD_N(cmd) (((cmd) >> _CMD_NSHIFT) & _CMD_NMASK)
80 enum vnic_devcmd_cmd
{
81 CMD_NONE
= _CMDC(_CMD_DIR_NONE
, _CMD_VTYPE_NONE
, 0),
83 /* mcpu fw info in mem: (u64)a0=paddr to struct vnic_devcmd_fw_info */
84 CMD_MCPU_FW_INFO
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_ALL
, 1),
86 /* dev-specific block member:
87 * in: (u16)a0=offset,(u8)a1=size
89 CMD_DEV_SPEC
= _CMDC(_CMD_DIR_RW
, _CMD_VTYPE_ALL
, 2),
92 CMD_STATS_CLEAR
= _CMDCNW(_CMD_DIR_NONE
, _CMD_VTYPE_ALL
, 3),
94 /* stats dump in mem: (u64)a0=paddr to stats area,
95 * (u16)a1=sizeof stats area */
96 CMD_STATS_DUMP
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_ALL
, 4),
98 /* set Rx packet filter: (u32)a0=filters (see CMD_PFILTER_*) */
99 CMD_PACKET_FILTER
= _CMDCNW(_CMD_DIR_WRITE
, _CMD_VTYPE_ENET
, 7),
101 /* set Rx packet filter for all: (u32)a0=filters (see CMD_PFILTER_*) */
102 CMD_PACKET_FILTER_ALL
= _CMDCNW(_CMD_DIR_WRITE
, _CMD_VTYPE_ALL
, 7),
104 /* hang detection notification */
105 CMD_HANG_NOTIFY
= _CMDC(_CMD_DIR_NONE
, _CMD_VTYPE_ALL
, 8),
107 /* MAC address in (u48)a0 */
108 CMD_MAC_ADDR
= _CMDC(_CMD_DIR_READ
,
109 _CMD_VTYPE_ENET
| _CMD_VTYPE_FC
, 9),
111 /* add addr from (u48)a0 */
112 CMD_ADDR_ADD
= _CMDCNW(_CMD_DIR_WRITE
,
113 _CMD_VTYPE_ENET
| _CMD_VTYPE_FC
, 12),
115 /* del addr from (u48)a0 */
116 CMD_ADDR_DEL
= _CMDCNW(_CMD_DIR_WRITE
,
117 _CMD_VTYPE_ENET
| _CMD_VTYPE_FC
, 13),
119 /* add VLAN id in (u16)a0 */
120 CMD_VLAN_ADD
= _CMDCNW(_CMD_DIR_WRITE
, _CMD_VTYPE_ENET
, 14),
122 /* del VLAN id in (u16)a0 */
123 CMD_VLAN_DEL
= _CMDCNW(_CMD_DIR_WRITE
, _CMD_VTYPE_ENET
, 15),
125 /* nic_cfg in (u32)a0 */
126 CMD_NIC_CFG
= _CMDCNW(_CMD_DIR_WRITE
, _CMD_VTYPE_ALL
, 16),
128 /* union vnic_rss_key in mem: (u64)a0=paddr, (u16)a1=len */
129 CMD_RSS_KEY
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_ENET
, 17),
131 /* union vnic_rss_cpu in mem: (u64)a0=paddr, (u16)a1=len */
132 CMD_RSS_CPU
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_ENET
, 18),
134 /* initiate softreset */
135 CMD_SOFT_RESET
= _CMDCNW(_CMD_DIR_NONE
, _CMD_VTYPE_ALL
, 19),
138 * out: a0=0 reset complete, a0=1 reset in progress */
139 CMD_SOFT_RESET_STATUS
= _CMDC(_CMD_DIR_READ
, _CMD_VTYPE_ALL
, 20),
141 /* set struct vnic_devcmd_notify buffer in mem:
143 * (u64)a0=paddr to notify (set paddr=0 to unset)
144 * (u32)a1 & 0x00000000ffffffff=sizeof(struct vnic_devcmd_notify)
145 * (u16)a1 & 0x0000ffff00000000=intr num (-1 for no intr)
147 * (u32)a1 = effective size
149 CMD_NOTIFY
= _CMDC(_CMD_DIR_RW
, _CMD_VTYPE_ALL
, 21),
151 /* UNDI API: (u64)a0=paddr to s_PXENV_UNDI_ struct,
152 * (u8)a1=PXENV_UNDI_xxx */
153 CMD_UNDI
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_ENET
, 22),
155 /* initiate open sequence (u32)a0=flags (see CMD_OPENF_*) */
156 CMD_OPEN
= _CMDCNW(_CMD_DIR_WRITE
, _CMD_VTYPE_ALL
, 23),
159 * out: a0=0 open complete, a0=1 open in progress */
160 CMD_OPEN_STATUS
= _CMDC(_CMD_DIR_READ
, _CMD_VTYPE_ALL
, 24),
163 CMD_CLOSE
= _CMDC(_CMD_DIR_NONE
, _CMD_VTYPE_ALL
, 25),
165 /* initialize virtual link: (u32)a0=flags (see CMD_INITF_*) */
166 /***** Replaced by CMD_INIT *****/
167 CMD_INIT_v1
= _CMDCNW(_CMD_DIR_READ
, _CMD_VTYPE_ALL
, 26),
169 /* variant of CMD_INIT, with provisioning info
170 * (u64)a0=paddr of vnic_devcmd_provinfo
171 * (u32)a1=sizeof provision info */
172 CMD_INIT_PROV_INFO
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_ENET
, 27),
174 /* enable virtual link */
175 CMD_ENABLE
= _CMDCNW(_CMD_DIR_WRITE
, _CMD_VTYPE_ALL
, 28),
177 /* enable virtual link, waiting variant. */
178 CMD_ENABLE_WAIT
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_ALL
, 28),
180 /* disable virtual link */
181 CMD_DISABLE
= _CMDC(_CMD_DIR_NONE
, _CMD_VTYPE_ALL
, 29),
183 /* stats dump sum of all vnic stats on same uplink in mem:
185 * (u16)a1=sizeof stats area */
186 CMD_STATS_DUMP_ALL
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_ALL
, 30),
189 * out: a0=0 init complete, a0=1 init in progress
190 * if a0=0, a1=errno */
191 CMD_INIT_STATUS
= _CMDC(_CMD_DIR_READ
, _CMD_VTYPE_ALL
, 31),
193 /* INT13 API: (u64)a0=paddr to vnic_int13_params struct
194 * (u32)a1=INT13_CMD_xxx */
195 CMD_INT13
= _CMDC(_CMD_DIR_WRITE
, _CMD_VTYPE_FC
, 32),
197 /* logical uplink enable/disable: (u64)a0: 0/1=disable/enable */
198 CMD_LOGICAL_UPLINK
= _CMDCNW(_CMD_DIR_WRITE
, _CMD_VTYPE_ENET
, 33),
200 /* undo initialize of virtual link */
201 CMD_DEINIT
= _CMDCNW(_CMD_DIR_NONE
, _CMD_VTYPE_ALL
, 34),
203 /* initialize virtual link: (u32)a0=flags (see CMD_INITF_*) */
204 CMD_INIT
= _CMDCNW(_CMD_DIR_WRITE
, _CMD_VTYPE_ALL
, 35),
206 /* check fw capability of a cmd:
208 * out: (u32)a0=errno, 0:valid cmd, a1=supported VNIC_STF_* bits */
209 CMD_CAPABILITY
= _CMDC(_CMD_DIR_RW
, _CMD_VTYPE_ALL
, 36),
211 /* persistent binding info
212 * in: (u64)a0=paddr of arg
213 * (u32)a1=CMD_PERBI_XXX */
214 CMD_PERBI
= _CMDC(_CMD_DIR_RW
, _CMD_VTYPE_FC
, 37),
216 /* Interrupt Assert Register functionality
217 * in: (u16)a0=interrupt number to assert
219 CMD_IAR
= _CMDCNW(_CMD_DIR_WRITE
, _CMD_VTYPE_ALL
, 38),
221 /* initiate hangreset, like softreset after hang detected */
222 CMD_HANG_RESET
= _CMDC(_CMD_DIR_NONE
, _CMD_VTYPE_ALL
, 39),
225 * out: a0=0 reset complete, a0=1 reset in progress */
226 CMD_HANG_RESET_STATUS
= _CMDC(_CMD_DIR_READ
, _CMD_VTYPE_ALL
, 40),
229 * Set hw ingress packet vlan rewrite mode:
230 * in: (u32)a0=new vlan rewrite mode
231 * out: (u32)a0=old vlan rewrite mode */
232 CMD_IG_VLAN_REWRITE_MODE
= _CMDC(_CMD_DIR_RW
, _CMD_VTYPE_ENET
, 41),
235 * in: (u16)a0=bdf of target vnic
236 * (u32)a1=cmd to proxy
237 * a2-a15=args to cmd in a1
238 * out: (u32)a0=status of proxied cmd
239 * a1-a15=out args of proxied cmd */
240 CMD_PROXY_BY_BDF
= _CMDC(_CMD_DIR_RW
, _CMD_VTYPE_ALL
, 42),
243 * As for BY_BDF except a0 is index of hvnlink subordinate vnic
244 * or SR-IOV virtual vnic */
245 CMD_PROXY_BY_INDEX
= _CMDC(_CMD_DIR_RW
, _CMD_VTYPE_ALL
, 43),
248 * in: (u64)a0=paddr of buffer to put latest VIC VIF-CONFIG-INFO TLV in
249 * (u32)a1=length of buffer in a0
250 * out: (u64)a0=paddr of buffer with latest VIC VIF-CONFIG-INFO TLV
251 * (u32)a1=actual length of latest VIC VIF-CONFIG-INFO TLV */
252 CMD_CONFIG_INFO_GET
= _CMDC(_CMD_DIR_RW
, _CMD_VTYPE_ALL
, 44),
255 /* flags for CMD_OPEN */
256 #define CMD_OPENF_OPROM 0x1 /* open coming from option rom */
258 /* flags for CMD_INIT */
259 #define CMD_INITF_DEFAULT_MAC 0x1 /* init with default mac addr */
261 /* flags for CMD_PACKET_FILTER */
262 #define CMD_PFILTER_DIRECTED 0x01
263 #define CMD_PFILTER_MULTICAST 0x02
264 #define CMD_PFILTER_BROADCAST 0x04
265 #define CMD_PFILTER_PROMISCUOUS 0x08
266 #define CMD_PFILTER_ALL_MULTICAST 0x10
268 /* rewrite modes for CMD_IG_VLAN_REWRITE_MODE */
269 #define IG_VLAN_REWRITE_MODE_DEFAULT_TRUNK 0
270 #define IG_VLAN_REWRITE_MODE_UNTAG_DEFAULT_VLAN 1
271 #define IG_VLAN_REWRITE_MODE_PRIORITY_TAG_DEFAULT_VLAN 2
272 #define IG_VLAN_REWRITE_MODE_PASS_THRU 3
274 enum vnic_devcmd_status
{
276 STAT_BUSY
= 1 << 0, /* cmd in progress */
277 STAT_ERROR
= 1 << 1, /* last cmd caused error (code in a0) */
280 enum vnic_devcmd_error
{
294 struct vnic_devcmd_fw_info
{
298 char hw_serial_number
[32];
301 struct vnic_devcmd_notify
{
302 u32 csum
; /* checksum over following words */
304 u32 link_state
; /* link up == 1 */
305 u32 port_speed
; /* effective port speed (rate limit) */
307 u32 msglvl
; /* requested driver msg lvl */
308 u32 uif
; /* uplink interface */
309 u32 status
; /* status bits (see VNIC_STF_*) */
310 u32 error
; /* error code (see ERR_*) for first ERR */
311 u32 link_down_cnt
; /* running count of link down transitions */
312 u32 perbi_rebuild_cnt
; /* running count of perbi rebuilds */
314 #define VNIC_STF_FATAL_ERR 0x0001 /* fatal fw error */
315 #define VNIC_STF_STD_PAUSE 0x0002 /* standard link-level pause on */
316 #define VNIC_STF_PFC_PAUSE 0x0004 /* priority flow control pause on */
317 /* all supported status flags */
318 #define VNIC_STF_ALL (VNIC_STF_FATAL_ERR |\
319 VNIC_STF_STD_PAUSE |\
320 VNIC_STF_PFC_PAUSE |\
323 struct vnic_devcmd_provinfo
{
330 * Writing cmd register causes STAT_BUSY to get set in status register.
331 * When cmd completes, STAT_BUSY will be cleared.
333 * If cmd completed successfully STAT_ERROR will be clear
334 * and args registers contain cmd-specific results.
336 * If cmd error, STAT_ERROR will be set and args[0] contains error code.
338 * status register is read-only. While STAT_BUSY is set,
339 * all other register contents are read-only.
342 /* Make sizeof(vnic_devcmd) a power-of-2 for I/O BAR. */
343 #define VNIC_DEVCMD_NARGS 15
347 u64 args
[VNIC_DEVCMD_NARGS
]; /* RW cmd args (little-endian) */
350 #endif /* _VNIC_DEVCMD_H_ */