xref: /linux/drivers/net/ethernet/cisco/enic/vnic_devcmd.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright 2008-2010 Cisco Systems, Inc.  All rights reserved.
4  * Copyright 2007 Nuova Systems, Inc.  All rights reserved.
5  */
6 
7 #ifndef _VNIC_DEVCMD_H_
8 #define _VNIC_DEVCMD_H_
9 
10 #define _CMD_NBITS      14
11 #define _CMD_VTYPEBITS	10
12 #define _CMD_FLAGSBITS  6
13 #define _CMD_DIRBITS	2
14 
15 #define _CMD_NMASK      ((1 << _CMD_NBITS)-1)
16 #define _CMD_VTYPEMASK  ((1 << _CMD_VTYPEBITS)-1)
17 #define _CMD_FLAGSMASK  ((1 << _CMD_FLAGSBITS)-1)
18 #define _CMD_DIRMASK    ((1 << _CMD_DIRBITS)-1)
19 
20 #define _CMD_NSHIFT     0
21 #define _CMD_VTYPESHIFT (_CMD_NSHIFT+_CMD_NBITS)
22 #define _CMD_FLAGSSHIFT (_CMD_VTYPESHIFT+_CMD_VTYPEBITS)
23 #define _CMD_DIRSHIFT   (_CMD_FLAGSSHIFT+_CMD_FLAGSBITS)
24 
25 /*
26  * Direction bits (from host perspective).
27  */
28 #define _CMD_DIR_NONE   0U
29 #define _CMD_DIR_WRITE  1U
30 #define _CMD_DIR_READ   2U
31 #define _CMD_DIR_RW     (_CMD_DIR_WRITE | _CMD_DIR_READ)
32 
33 /*
34  * Flag bits.
35  */
36 #define _CMD_FLAGS_NONE 0U
37 #define _CMD_FLAGS_NOWAIT 1U
38 
39 /*
40  * vNIC type bits.
41  */
42 #define _CMD_VTYPE_NONE  0U
43 #define _CMD_VTYPE_ENET  1U
44 #define _CMD_VTYPE_FC    2U
45 #define _CMD_VTYPE_SCSI  4U
46 #define _CMD_VTYPE_ALL   (_CMD_VTYPE_ENET | _CMD_VTYPE_FC | _CMD_VTYPE_SCSI)
47 
48 /*
49  * Used to create cmds..
50 */
51 #define _CMDCF(dir, flags, vtype, nr)  \
52 	(((dir)   << _CMD_DIRSHIFT) | \
53 	((flags) << _CMD_FLAGSSHIFT) | \
54 	((vtype) << _CMD_VTYPESHIFT) | \
55 	((nr)    << _CMD_NSHIFT))
56 #define _CMDC(dir, vtype, nr)    _CMDCF(dir, 0, vtype, nr)
57 #define _CMDCNW(dir, vtype, nr)  _CMDCF(dir, _CMD_FLAGS_NOWAIT, vtype, nr)
58 
59 /*
60  * Used to decode cmds..
61 */
62 #define _CMD_DIR(cmd)            (((cmd) >> _CMD_DIRSHIFT) & _CMD_DIRMASK)
63 #define _CMD_FLAGS(cmd)          (((cmd) >> _CMD_FLAGSSHIFT) & _CMD_FLAGSMASK)
64 #define _CMD_VTYPE(cmd)          (((cmd) >> _CMD_VTYPESHIFT) & _CMD_VTYPEMASK)
65 #define _CMD_N(cmd)              (((cmd) >> _CMD_NSHIFT) & _CMD_NMASK)
66 
67 enum vnic_devcmd_cmd {
68 	CMD_NONE                = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_NONE, 0),
69 
70 	/*
71 	 * mcpu fw info in mem:
72 	 * in:
73 	 *   (u64)a0=paddr to struct vnic_devcmd_fw_info
74 	 * action:
75 	 *   Fills in struct vnic_devcmd_fw_info (128 bytes)
76 	 * note:
77 	 *   An old definition of CMD_MCPU_FW_INFO
78 	 */
79 	CMD_MCPU_FW_INFO_OLD    = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 1),
80 
81 	/*
82 	 * mcpu fw info in mem:
83 	 * in:
84 	 *   (u64)a0=paddr to struct vnic_devcmd_fw_info
85 	 *   (u16)a1=size of the structure
86 	 * out:
87 	 *	 (u16)a1=0                          for in:a1 = 0,
88 	 *	         data size actually written for other values.
89 	 * action:
90 	 *   Fills in first 128 bytes of vnic_devcmd_fw_info for in:a1 = 0,
91 	 *            first in:a1 bytes               for 0 < in:a1 <= 132,
92 	 *            132 bytes                       for other values of in:a1.
93 	 * note:
94 	 *   CMD_MCPU_FW_INFO and CMD_MCPU_FW_INFO_OLD have the same enum 1
95 	 *   for source compatibility.
96 	 */
97 	CMD_MCPU_FW_INFO        = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 1),
98 
99 	/* dev-specific block member:
100 	 *    in: (u16)a0=offset,(u8)a1=size
101 	 *    out: a0=value */
102 	CMD_DEV_SPEC            = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 2),
103 
104 	/* stats clear */
105 	CMD_STATS_CLEAR         = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 3),
106 
107 	/* stats dump in mem: (u64)a0=paddr to stats area,
108 	 *                    (u16)a1=sizeof stats area */
109 	CMD_STATS_DUMP          = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 4),
110 
111 	/* set Rx packet filter: (u32)a0=filters (see CMD_PFILTER_*) */
112 	CMD_PACKET_FILTER	= _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 7),
113 
114 	/* set Rx packet filter for all: (u32)a0=filters (see CMD_PFILTER_*) */
115 	CMD_PACKET_FILTER_ALL   = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 7),
116 
117 	/* hang detection notification */
118 	CMD_HANG_NOTIFY         = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 8),
119 
120 	/* MAC address in (u48)a0 */
121 	CMD_GET_MAC_ADDR        = _CMDC(_CMD_DIR_READ,
122 					_CMD_VTYPE_ENET | _CMD_VTYPE_FC, 9),
123 
124 	/* add addr from (u48)a0 */
125 	CMD_ADDR_ADD            = _CMDCNW(_CMD_DIR_WRITE,
126 					_CMD_VTYPE_ENET | _CMD_VTYPE_FC, 12),
127 
128 	/* del addr from (u48)a0 */
129 	CMD_ADDR_DEL            = _CMDCNW(_CMD_DIR_WRITE,
130 					_CMD_VTYPE_ENET | _CMD_VTYPE_FC, 13),
131 
132 	/* add VLAN id in (u16)a0 */
133 	CMD_VLAN_ADD            = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 14),
134 
135 	/* del VLAN id in (u16)a0 */
136 	CMD_VLAN_DEL            = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 15),
137 
138 	/* nic_cfg (no wait, always succeeds)
139 	 * in: (u32)a0
140 	 *
141 	 * Capability query:
142 	 * out: (u64) a0 = 1 if a1 is valid
143 	 *	(u64) a1 = (NIC_CFG bits supported) | (flags << 32)
144 	 *
145 	 * flags are CMD_NIC_CFG_CAPF_xxx
146 	 */
147 	CMD_NIC_CFG             = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 16),
148 	/* nic_cfg_chk (will return error if flags are invalid)
149 	 * in: (u32)a0
150 	 *
151 	 * Capability query:
152 	 * out: (u64) a0 = 1 if a1 is valid
153 	 *	(u64) a1 = (NIC_CFG bits supported) | (flags << 32)
154 	 *
155 	 * flags are CMD_NIC_CFG_CAPF_xxx
156 	 */
157 	CMD_NIC_CFG_CHK		= _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 16),
158 
159 	/* union vnic_rss_key in mem: (u64)a0=paddr, (u16)a1=len */
160 	CMD_RSS_KEY             = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 17),
161 
162 	/* union vnic_rss_cpu in mem: (u64)a0=paddr, (u16)a1=len */
163 	CMD_RSS_CPU             = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 18),
164 
165 	/* initiate softreset */
166 	CMD_SOFT_RESET          = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 19),
167 
168 	/* softreset status:
169 	 *    out: a0=0 reset complete, a0=1 reset in progress */
170 	CMD_SOFT_RESET_STATUS   = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 20),
171 
172 	/* set struct vnic_devcmd_notify buffer in mem:
173 	 * in:
174 	 *   (u64)a0=paddr to notify (set paddr=0 to unset)
175 	 *   (u32)a1 & 0x00000000ffffffff=sizeof(struct vnic_devcmd_notify)
176 	 *   (u16)a1 & 0x0000ffff00000000=intr num (-1 for no intr)
177 	 * out:
178 	 *   (u32)a1 = effective size
179 	 */
180 	CMD_NOTIFY              = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 21),
181 
182 	/* UNDI API: (u64)a0=paddr to s_PXENV_UNDI_ struct,
183 	 *           (u8)a1=PXENV_UNDI_xxx */
184 	CMD_UNDI                = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 22),
185 
186 	/* initiate open sequence (u32)a0=flags (see CMD_OPENF_*) */
187 	CMD_OPEN		= _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 23),
188 
189 	/* open status:
190 	 *    out: a0=0 open complete, a0=1 open in progress */
191 	CMD_OPEN_STATUS		= _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 24),
192 
193 	/* close vnic */
194 	CMD_CLOSE		= _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 25),
195 
196 	/* initialize virtual link: (u32)a0=flags (see CMD_INITF_*) */
197 /***** Replaced by CMD_INIT *****/
198 	CMD_INIT_v1		= _CMDCNW(_CMD_DIR_READ, _CMD_VTYPE_ALL, 26),
199 
200 	/* variant of CMD_INIT, with provisioning info
201 	 *     (u64)a0=paddr of vnic_devcmd_provinfo
202 	 *     (u32)a1=sizeof provision info */
203 	CMD_INIT_PROV_INFO	= _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 27),
204 
205 	/* enable virtual link */
206 	CMD_ENABLE		= _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 28),
207 
208 	/* enable virtual link, waiting variant. */
209 	CMD_ENABLE_WAIT		= _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 28),
210 
211 	/* disable virtual link */
212 	CMD_DISABLE		= _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 29),
213 
214 	/* stats dump sum of all vnic stats on same uplink in mem:
215 	 *     (u64)a0=paddr
216 	 *     (u16)a1=sizeof stats area */
217 	CMD_STATS_DUMP_ALL	= _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 30),
218 
219 	/* init status:
220 	 *    out: a0=0 init complete, a0=1 init in progress
221 	 *         if a0=0, a1=errno */
222 	CMD_INIT_STATUS		= _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 31),
223 
224 	/* INT13 API: (u64)a0=paddr to vnic_int13_params struct
225 	 *            (u32)a1=INT13_CMD_xxx */
226 	CMD_INT13               = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_FC, 32),
227 
228 	/* logical uplink enable/disable: (u64)a0: 0/1=disable/enable */
229 	CMD_LOGICAL_UPLINK      = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 33),
230 
231 	/* undo initialize of virtual link */
232 	CMD_DEINIT		= _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 34),
233 
234 	/* initialize virtual link: (u32)a0=flags (see CMD_INITF_*) */
235 	CMD_INIT		= _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 35),
236 
237 	/* check fw capability of a cmd:
238 	 * in:  (u32)a0=cmd
239 	 * out: (u32)a0=errno, 0:valid cmd, a1=supported VNIC_STF_* bits */
240 	CMD_CAPABILITY		= _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 36),
241 
242 	/* persistent binding info
243 	 * in:  (u64)a0=paddr of arg
244 	 *      (u32)a1=CMD_PERBI_XXX */
245 	CMD_PERBI		= _CMDC(_CMD_DIR_RW, _CMD_VTYPE_FC, 37),
246 
247 	/* Interrupt Assert Register functionality
248 	 * in: (u16)a0=interrupt number to assert
249 	 */
250 	CMD_IAR			= _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 38),
251 
252 	/* initiate hangreset, like softreset after hang detected */
253 	CMD_HANG_RESET		= _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 39),
254 
255 	/* hangreset status:
256 	 *    out: a0=0 reset complete, a0=1 reset in progress */
257 	CMD_HANG_RESET_STATUS   = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 40),
258 
259 	/*
260 	 * Set hw ingress packet vlan rewrite mode:
261 	 * in:  (u32)a0=new vlan rewrite mode
262 	 * out: (u32)a0=old vlan rewrite mode */
263 	CMD_IG_VLAN_REWRITE_MODE = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 41),
264 
265 	/*
266 	 * in:  (u16)a0=bdf of target vnic
267 	 *      (u32)a1=cmd to proxy
268 	 *      a2-a15=args to cmd in a1
269 	 * out: (u32)a0=status of proxied cmd
270 	 *      a1-a15=out args of proxied cmd */
271 	CMD_PROXY_BY_BDF =	_CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 42),
272 
273 	/*
274 	 * As for BY_BDF except a0 is index of hvnlink subordinate vnic
275 	 * or SR-IOV virtual vnic
276 	 */
277 	CMD_PROXY_BY_INDEX =    _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 43),
278 
279 	/*
280 	 * For HPP toggle:
281 	 * adapter-info-get
282 	 * in:  (u64)a0=phsical address of buffer passed in from caller.
283 	 *      (u16)a1=size of buffer specified in a0.
284 	 * out: (u64)a0=phsical address of buffer passed in from caller.
285 	 *      (u16)a1=actual bytes from VIF-CONFIG-INFO TLV, or
286 	 *              0 if no VIF-CONFIG-INFO TLV was ever received. */
287 	CMD_CONFIG_INFO_GET     = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 44),
288 
289 	/* INT13 API: (u64)a0=paddr to vnic_int13_params struct
290 	 *            (u32)a1=INT13_CMD_xxx
291 	 */
292 	CMD_INT13_ALL = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 45),
293 
294 	/* Set default vlan:
295 	 * in: (u16)a0=new default vlan
296 	 *     (u16)a1=zero for overriding vlan with param a0,
297 	 *		       non-zero for resetting vlan to the default
298 	 * out: (u16)a0=old default vlan
299 	 */
300 	CMD_SET_DEFAULT_VLAN = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 46),
301 
302 	/* init_prov_info2:
303 	 * Variant of CMD_INIT_PROV_INFO, where it will not try to enable
304 	 * the vnic until CMD_ENABLE2 is issued.
305 	 *     (u64)a0=paddr of vnic_devcmd_provinfo
306 	 *     (u32)a1=sizeof provision info
307 	 */
308 	CMD_INIT_PROV_INFO2  = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 47),
309 
310 	/* enable2:
311 	 *      (u32)a0=0                  ==> standby
312 	 *             =CMD_ENABLE2_ACTIVE ==> active
313 	 */
314 	CMD_ENABLE2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 48),
315 
316 	/*
317 	 * cmd_status:
318 	 *     Returns the status of the specified command
319 	 * Input:
320 	 *     a0 = command for which status is being queried.
321 	 *          Possible values are:
322 	 *              CMD_SOFT_RESET
323 	 *              CMD_HANG_RESET
324 	 *              CMD_OPEN
325 	 *              CMD_INIT
326 	 *              CMD_INIT_PROV_INFO
327 	 *              CMD_DEINIT
328 	 *              CMD_INIT_PROV_INFO2
329 	 *              CMD_ENABLE2
330 	 * Output:
331 	 *     if status == STAT_ERROR
332 	 *        a0 = ERR_ENOTSUPPORTED - status for command in a0 is
333 	 *                                 not supported
334 	 *     if status == STAT_NONE
335 	 *        a0 = status of the devcmd specified in a0 as follows.
336 	 *             ERR_SUCCESS   - command in a0 completed successfully
337 	 *             ERR_EINPROGRESS - command in a0 is still in progress
338 	 */
339 	CMD_STATUS = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 49),
340 
341 	/*
342 	 * Returns interrupt coalescing timer conversion factors.
343 	 * After calling this devcmd, ENIC driver can convert
344 	 * interrupt coalescing timer in usec into CPU cycles as follows:
345 	 *
346 	 *   intr_timer_cycles = intr_timer_usec * multiplier / divisor
347 	 *
348 	 * Interrupt coalescing timer in usecs can be obtained from
349 	 * CPU cycles as follows:
350 	 *
351 	 *   intr_timer_usec = intr_timer_cycles * divisor / multiplier
352 	 *
353 	 * in: none
354 	 * out: (u32)a0 = multiplier
355 	 *      (u32)a1 = divisor
356 	 *      (u32)a2 = maximum timer value in usec
357 	 */
358 	CMD_INTR_COAL_CONVERT = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 50),
359 
360 	/*
361 	 * Set the predefined mac address as default
362 	 * in:
363 	 *   (u48)a0 = mac addr
364 	 */
365 	CMD_SET_MAC_ADDR = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 55),
366 
367 	/* Update the provisioning info of the given VIF
368 	 *     (u64)a0=paddr of vnic_devcmd_provinfo
369 	 *     (u32)a1=sizeof provision info
370 	 */
371 	CMD_PROV_INFO_UPDATE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 56),
372 
373 	/* Initialization for the devcmd2 interface.
374 	 * in: (u64) a0 = host result buffer physical address
375 	 * in: (u16) a1 = number of entries in result buffer
376 	 */
377 	CMD_INITIALIZE_DEVCMD2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 57),
378 
379 	/* Add a filter.
380 	 * in: (u64) a0= filter address
381 	 *     (u32) a1= size of filter
382 	 * out: (u32) a0=filter identifier
383 	 */
384 	CMD_ADD_FILTER = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 58),
385 
386 	/* Delete a filter.
387 	 * in: (u32) a0=filter identifier
388 	 */
389 	CMD_DEL_FILTER = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 59),
390 
391 	/* Enable a Queue Pair in User space NIC
392 	 * in: (u32) a0=Queue Pair number
393 	 *     (u32) a1= command
394 	 */
395 	CMD_QP_ENABLE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 60),
396 
397 	/* Disable a Queue Pair in User space NIC
398 	 * in: (u32) a0=Queue Pair number
399 	 *     (u32) a1= command
400 	 */
401 	CMD_QP_DISABLE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 61),
402 
403 	/* Stats dump Queue Pair in User space NIC
404 	 * in: (u32) a0=Queue Pair number
405 	 *     (u64) a1=host buffer addr for status dump
406 	 *     (u32) a2=length of the buffer
407 	 */
408 	CMD_QP_STATS_DUMP = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 62),
409 
410 	/* Clear stats for Queue Pair in User space NIC
411 	 * in: (u32) a0=Queue Pair number
412 	 */
413 	CMD_QP_STATS_CLEAR = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 63),
414 
415 	/* Use this devcmd for agreeing on the highest common version supported
416 	 * by both driver and fw for features who need such a facility.
417 	 * in:	(u64) a0 = feature (driver requests for the supported versions
418 	 *	on this feature)
419 	 * out: (u64) a0 = bitmap of all supported versions for that feature
420 	 */
421 	CMD_GET_SUPP_FEATURE_VER = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 69),
422 
423 	/* Control (Enable/Disable) overlay offloads on the given vnic
424 	 * in: (u8) a0 = OVERLAY_FEATURE_NVGRE : NVGRE
425 	 *	    a0 = OVERLAY_FEATURE_VXLAN : VxLAN
426 	 * in: (u8) a1 = OVERLAY_OFFLOAD_ENABLE : Enable or
427 	 *	    a1 = OVERLAY_OFFLOAD_DISABLE : Disable or
428 	 *	    a1 = OVERLAY_OFFLOAD_ENABLE_V2 : Enable with version 2
429 	 */
430 	CMD_OVERLAY_OFFLOAD_CTRL = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 72),
431 
432 	/* Configuration of overlay offloads feature on a given vNIC
433 	 * in: (u8) a0 = DEVCMD_OVERLAY_NVGRE : NVGRE
434 	 *	    a0 = DEVCMD_OVERLAY_VXLAN : VxLAN
435 	 * in: (u8) a1 = VXLAN_PORT_UPDATE : VxLAN
436 	 * in: (u16) a2 = unsigned short int port information
437 	 */
438 	CMD_OVERLAY_OFFLOAD_CFG = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 73),
439 };
440 
441 /* CMD_ENABLE2 flags */
442 #define CMD_ENABLE2_STANDBY 0x0
443 #define CMD_ENABLE2_ACTIVE  0x1
444 
445 /* flags for CMD_OPEN */
446 #define CMD_OPENF_OPROM		0x1	/* open coming from option rom */
447 #define CMD_OPENF_IG_DESCCACHE	0x2	/* Do not flush IG DESC cache */
448 
449 /* flags for CMD_INIT */
450 #define CMD_INITF_DEFAULT_MAC	0x1	/* init with default mac addr */
451 
452 /* flags for CMD_PACKET_FILTER */
453 #define CMD_PFILTER_DIRECTED		0x01
454 #define CMD_PFILTER_MULTICAST		0x02
455 #define CMD_PFILTER_BROADCAST		0x04
456 #define CMD_PFILTER_PROMISCUOUS		0x08
457 #define CMD_PFILTER_ALL_MULTICAST	0x10
458 
459 /* Commands for CMD_QP_ENABLE/CM_QP_DISABLE */
460 #define CMD_QP_RQWQ                     0x0
461 
462 /* rewrite modes for CMD_IG_VLAN_REWRITE_MODE */
463 #define IG_VLAN_REWRITE_MODE_DEFAULT_TRUNK              0
464 #define IG_VLAN_REWRITE_MODE_UNTAG_DEFAULT_VLAN         1
465 #define IG_VLAN_REWRITE_MODE_PRIORITY_TAG_DEFAULT_VLAN  2
466 #define IG_VLAN_REWRITE_MODE_PASS_THRU                  3
467 
468 enum vnic_devcmd_status {
469 	STAT_NONE = 0,
470 	STAT_BUSY = 1 << 0,	/* cmd in progress */
471 	STAT_ERROR = 1 << 1,	/* last cmd caused error (code in a0) */
472 };
473 
474 enum vnic_devcmd_error {
475 	ERR_SUCCESS = 0,
476 	ERR_EINVAL = 1,
477 	ERR_EFAULT = 2,
478 	ERR_EPERM = 3,
479 	ERR_EBUSY = 4,
480 	ERR_ECMDUNKNOWN = 5,
481 	ERR_EBADSTATE = 6,
482 	ERR_ENOMEM = 7,
483 	ERR_ETIMEDOUT = 8,
484 	ERR_ELINKDOWN = 9,
485 	ERR_EMAXRES = 10,
486 	ERR_ENOTSUPPORTED = 11,
487 	ERR_EINPROGRESS = 12,
488 	ERR_MAX
489 };
490 
491 /*
492  * note: hw_version and asic_rev refer to the same thing,
493  *       but have different formats. hw_version is
494  *       a 32-byte string (e.g. "A2") and asic_rev is
495  *       a 16-bit integer (e.g. 0xA2).
496  */
497 struct vnic_devcmd_fw_info {
498 	char fw_version[32];
499 	char fw_build[32];
500 	char hw_version[32];
501 	char hw_serial_number[32];
502 	u16 asic_type;
503 	u16 asic_rev;
504 };
505 
506 struct vnic_devcmd_notify {
507 	u32 csum;		/* checksum over following words */
508 
509 	u32 link_state;		/* link up == 1 */
510 	u32 port_speed;		/* effective port speed (rate limit) */
511 	u32 mtu;		/* MTU */
512 	u32 msglvl;		/* requested driver msg lvl */
513 	u32 uif;		/* uplink interface */
514 	u32 status;		/* status bits (see VNIC_STF_*) */
515 	u32 error;		/* error code (see ERR_*) for first ERR */
516 	u32 link_down_cnt;	/* running count of link down transitions */
517 	u32 perbi_rebuild_cnt;	/* running count of perbi rebuilds */
518 };
519 #define VNIC_STF_FATAL_ERR	0x0001	/* fatal fw error */
520 #define VNIC_STF_STD_PAUSE	0x0002	/* standard link-level pause on */
521 #define VNIC_STF_PFC_PAUSE	0x0004	/* priority flow control pause on */
522 /* all supported status flags */
523 #define VNIC_STF_ALL		(VNIC_STF_FATAL_ERR |\
524 				 VNIC_STF_STD_PAUSE |\
525 				 VNIC_STF_PFC_PAUSE |\
526 				 0)
527 
528 struct vnic_devcmd_provinfo {
529 	u8 oui[3];
530 	u8 type;
531 	u8 data[];
532 };
533 
534 /* These are used in flags field of different filters to denote
535  * valid fields used.
536  */
537 #define FILTER_FIELD_VALID(fld) (1 << (fld - 1))
538 
539 #define FILTER_FIELDS_USNIC ( \
540 			FILTER_FIELD_VALID(1) | \
541 			FILTER_FIELD_VALID(2) | \
542 			FILTER_FIELD_VALID(3) | \
543 			FILTER_FIELD_VALID(4))
544 
545 #define FILTER_FIELDS_IPV4_5TUPLE ( \
546 			FILTER_FIELD_VALID(1) | \
547 			FILTER_FIELD_VALID(2) | \
548 			FILTER_FIELD_VALID(3) | \
549 			FILTER_FIELD_VALID(4) | \
550 			FILTER_FIELD_VALID(5))
551 
552 #define FILTER_FIELDS_MAC_VLAN ( \
553 			FILTER_FIELD_VALID(1) | \
554 			FILTER_FIELD_VALID(2))
555 
556 #define FILTER_FIELD_USNIC_VLAN    FILTER_FIELD_VALID(1)
557 #define FILTER_FIELD_USNIC_ETHTYPE FILTER_FIELD_VALID(2)
558 #define FILTER_FIELD_USNIC_PROTO   FILTER_FIELD_VALID(3)
559 #define FILTER_FIELD_USNIC_ID      FILTER_FIELD_VALID(4)
560 
561 struct filter_usnic_id {
562 	u32 flags;
563 	u16 vlan;
564 	u16 ethtype;
565 	u8 proto_version;
566 	u32 usnic_id;
567 } __packed;
568 
569 #define FILTER_FIELD_5TUP_PROTO  FILTER_FIELD_VALID(1)
570 #define FILTER_FIELD_5TUP_SRC_AD FILTER_FIELD_VALID(2)
571 #define FILTER_FIELD_5TUP_DST_AD FILTER_FIELD_VALID(3)
572 #define FILTER_FIELD_5TUP_SRC_PT FILTER_FIELD_VALID(4)
573 #define FILTER_FIELD_5TUP_DST_PT FILTER_FIELD_VALID(5)
574 
575 /* Enums for the protocol field. */
576 enum protocol_e {
577 	PROTO_UDP = 0,
578 	PROTO_TCP = 1,
579 };
580 
581 struct filter_ipv4_5tuple {
582 	u32 flags;
583 	u32 protocol;
584 	u32 src_addr;
585 	u32 dst_addr;
586 	u16 src_port;
587 	u16 dst_port;
588 } __packed;
589 
590 #define FILTER_FIELD_VMQ_VLAN   FILTER_FIELD_VALID(1)
591 #define FILTER_FIELD_VMQ_MAC    FILTER_FIELD_VALID(2)
592 
593 struct filter_mac_vlan {
594 	u32 flags;
595 	u16 vlan;
596 	u8 mac_addr[6];
597 } __packed;
598 
599 /* Specifies the filter_action type. */
600 enum {
601 	FILTER_ACTION_RQ_STEERING = 0,
602 	FILTER_ACTION_MAX
603 };
604 
605 struct filter_action {
606 	u32 type;
607 	union {
608 		u32 rq_idx;
609 	} u;
610 } __packed;
611 
612 /* Specifies the filter type. */
613 enum filter_type {
614 	FILTER_USNIC_ID = 0,
615 	FILTER_IPV4_5TUPLE = 1,
616 	FILTER_MAC_VLAN = 2,
617 	FILTER_MAX
618 };
619 
620 struct filter {
621 	u32 type;
622 	union {
623 		struct filter_usnic_id usnic;
624 		struct filter_ipv4_5tuple ipv4;
625 		struct filter_mac_vlan mac_vlan;
626 	} u;
627 } __packed;
628 
629 enum {
630 	CLSF_TLV_FILTER = 0,
631 	CLSF_TLV_ACTION = 1,
632 };
633 
634 /* Maximum size of buffer to CMD_ADD_FILTER */
635 #define FILTER_MAX_BUF_SIZE 100
636 
637 struct filter_tlv {
638 	u32 type;
639 	u32 length;
640 	u32 val[];
641 };
642 
643 enum {
644 	CLSF_ADD = 0,
645 	CLSF_DEL = 1,
646 };
647 
648 /*
649  * Writing cmd register causes STAT_BUSY to get set in status register.
650  * When cmd completes, STAT_BUSY will be cleared.
651  *
652  * If cmd completed successfully STAT_ERROR will be clear
653  * and args registers contain cmd-specific results.
654  *
655  * If cmd error, STAT_ERROR will be set and args[0] contains error code.
656  *
657  * status register is read-only.  While STAT_BUSY is set,
658  * all other register contents are read-only.
659  */
660 
661 /* Make sizeof(vnic_devcmd) a power-of-2 for I/O BAR. */
662 #define VNIC_DEVCMD_NARGS 15
663 struct vnic_devcmd {
664 	u32 status;			/* RO */
665 	u32 cmd;			/* RW */
666 	u64 args[VNIC_DEVCMD_NARGS];	/* RW cmd args (little-endian) */
667 };
668 
669 #define DEVCMD2_FNORESULT	0x1	/* Don't copy result to host */
670 
671 #define VNIC_DEVCMD2_NARGS	VNIC_DEVCMD_NARGS
672 struct vnic_devcmd2 {
673 	u16 pad;
674 	u16 flags;
675 	u32 cmd;
676 	u64 args[VNIC_DEVCMD2_NARGS];
677 };
678 
679 #define VNIC_DEVCMD2_NRESULTS	VNIC_DEVCMD_NARGS
680 struct devcmd2_result {
681 	u64 results[VNIC_DEVCMD2_NRESULTS];
682 	u32 pad;
683 	u16 completed_index;
684 	u8  error;
685 	u8  color;
686 };
687 
688 #define DEVCMD2_RING_SIZE	32
689 #define DEVCMD2_DESC_SIZE	128
690 
691 enum overlay_feature_t {
692 	OVERLAY_FEATURE_NVGRE = 1,
693 	OVERLAY_FEATURE_VXLAN,
694 	OVERLAY_FEATURE_MAX,
695 };
696 
697 enum overlay_ofld_cmd {
698 	OVERLAY_OFFLOAD_ENABLE,
699 	OVERLAY_OFFLOAD_DISABLE,
700 	OVERLAY_OFFLOAD_ENABLE_P2,
701 	OVERLAY_OFFLOAD_MAX,
702 };
703 
704 #define OVERLAY_CFG_VXLAN_PORT_UPDATE	0
705 
706 #define ENIC_VXLAN_INNER_IPV6		BIT(0)
707 #define ENIC_VXLAN_OUTER_IPV6		BIT(1)
708 #define ENIC_VXLAN_MULTI_WQ		BIT(2)
709 
710 /* Use this enum to get the supported versions for each of these features
711  * If you need to use the devcmd_get_supported_feature_version(), add
712  * the new feature into this enum and install function handler in devcmd.c
713  */
714 enum vic_feature_t {
715 	VIC_FEATURE_VXLAN,
716 	VIC_FEATURE_RDMA,
717 	VIC_FEATURE_VXLAN_PATCH,
718 	VIC_FEATURE_MAX,
719 };
720 
721 #endif /* _VNIC_DEVCMD_H_ */
722