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