]> git.proxmox.com Git - ceph.git/blob - ceph/src/dpdk/drivers/net/enic/base/vnic_devcmd.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / dpdk / drivers / net / enic / base / vnic_devcmd.h
1 /*
2 * Copyright 2008-2016 Cisco Systems, Inc. All rights reserved.
3 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
4 *
5 * Copyright (c) 2014, Cisco Systems, Inc.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
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
18 * distribution.
19 *
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.
32 *
33 */
34
35 #ifndef _VNIC_DEVCMD_H_
36 #define _VNIC_DEVCMD_H_
37
38 #define _CMD_NBITS 14
39 #define _CMD_VTYPEBITS 10
40 #define _CMD_FLAGSBITS 6
41 #define _CMD_DIRBITS 2
42
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)
47
48 #define _CMD_NSHIFT 0
49 #define _CMD_VTYPESHIFT (_CMD_NSHIFT+_CMD_NBITS)
50 #define _CMD_FLAGSSHIFT (_CMD_VTYPESHIFT+_CMD_VTYPEBITS)
51 #define _CMD_DIRSHIFT (_CMD_FLAGSSHIFT+_CMD_FLAGSBITS)
52
53 /*
54 * Direction bits (from host perspective).
55 */
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)
60
61 /*
62 * Flag bits.
63 */
64 #define _CMD_FLAGS_NONE 0U
65 #define _CMD_FLAGS_NOWAIT 1U
66
67 /*
68 * vNIC type bits.
69 */
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)
75
76 /*
77 * Used to create cmds..
78 */
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)
86
87 /*
88 * Used to decode cmds..
89 */
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)
94
95 enum vnic_devcmd_cmd {
96 CMD_NONE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_NONE, 0),
97
98 /*
99 * mcpu fw info in mem:
100 * in:
101 * (u64)a0=paddr to struct vnic_devcmd_fw_info
102 * action:
103 * Fills in struct vnic_devcmd_fw_info (128 bytes)
104 * note:
105 * An old definition of CMD_MCPU_FW_INFO
106 */
107 CMD_MCPU_FW_INFO_OLD = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 1),
108
109 /*
110 * mcpu fw info in mem:
111 * in:
112 * (u64)a0=paddr to struct vnic_devcmd_fw_info
113 * (u16)a1=size of the structure
114 * out:
115 * (u16)a1=0 for in:a1 = 0,
116 * data size actually written for other values.
117 * action:
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.
121 * note:
122 * CMD_MCPU_FW_INFO and CMD_MCPU_FW_INFO_OLD have the same enum 1
123 * for source compatibility.
124 */
125 CMD_MCPU_FW_INFO = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 1),
126
127 /* dev-specific block member:
128 * in: (u16)a0=offset,(u8)a1=size
129 * out: a0=value
130 */
131 CMD_DEV_SPEC = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 2),
132
133 /* stats clear */
134 CMD_STATS_CLEAR = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 3),
135
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),
139
140 /* set Rx packet filter: (u32)a0=filters (see CMD_PFILTER_*) */
141 CMD_PACKET_FILTER = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 7),
142
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),
145
146 /* hang detection notification */
147 CMD_HANG_NOTIFY = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 8),
148
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 */
153
154 /* add addr from (u48)a0 */
155 CMD_ADDR_ADD = _CMDCNW(_CMD_DIR_WRITE,
156 _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 12),
157
158 /* del addr from (u48)a0 */
159 CMD_ADDR_DEL = _CMDCNW(_CMD_DIR_WRITE,
160 _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 13),
161
162 /* add VLAN id in (u16)a0 */
163 CMD_VLAN_ADD = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 14),
164
165 /* del VLAN id in (u16)a0 */
166 CMD_VLAN_DEL = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 15),
167
168 /* nic_cfg in (u32)a0 */
169 CMD_NIC_CFG = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 16),
170
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),
173
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),
176
177 /* initiate softreset */
178 CMD_SOFT_RESET = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 19),
179
180 /* softreset status:
181 * out: a0=0 reset complete, a0=1 reset in progress */
182 CMD_SOFT_RESET_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 20),
183
184 /* set struct vnic_devcmd_notify buffer in mem:
185 * in:
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)
189 * out:
190 * (u32)a1 = effective size
191 */
192 CMD_NOTIFY = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 21),
193
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),
197
198 /* initiate open sequence (u32)a0=flags (see CMD_OPENF_*) */
199 CMD_OPEN = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 23),
200
201 /* open status:
202 * out: a0=0 open complete, a0=1 open in progress */
203 CMD_OPEN_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 24),
204
205 /* close vnic */
206 CMD_CLOSE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 25),
207
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),
211
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),
216
217 /* enable virtual link */
218 CMD_ENABLE = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 28),
219
220 /* enable virtual link, waiting variant. */
221 CMD_ENABLE_WAIT = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 28),
222
223 /* disable virtual link */
224 CMD_DISABLE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 29),
225
226 /* stats dump sum of all vnic stats on same uplink in mem:
227 * (u64)a0=paddr
228 * (u16)a1=sizeof stats area */
229 CMD_STATS_DUMP_ALL = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 30),
230
231 /* init status:
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),
235
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),
239
240 /* logical uplink enable/disable: (u64)a0: 0/1=disable/enable */
241 CMD_LOGICAL_UPLINK = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 33),
242
243 /* undo initialize of virtual link */
244 CMD_DEINIT = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 34),
245
246 /* initialize virtual link: (u32)a0=flags (see CMD_INITF_*) */
247 CMD_INIT = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 35),
248
249 /* check fw capability of a cmd:
250 * in: (u32)a0=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),
253
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),
258
259 /* Interrupt Assert Register functionality
260 * in: (u16)a0=interrupt number to assert
261 */
262 CMD_IAR = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 38),
263
264 /* initiate hangreset, like softreset after hang detected */
265 CMD_HANG_RESET = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 39),
266
267 /* hangreset status:
268 * out: a0=0 reset complete, a0=1 reset in progress */
269 CMD_HANG_RESET_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 40),
270
271 /*
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),
276
277 /*
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),
284
285 /*
286 * As for BY_BDF except a0 is index of hvnlink subordinate vnic
287 * or SR-IOV virtual vnic
288 */
289 CMD_PROXY_BY_INDEX = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 43),
290
291 /*
292 * For HPP toggle:
293 * adapter-info-get
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),
300
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 /*
308 * Set default vlan:
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
313 */
314 CMD_SET_DEFAULT_VLAN = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 46),
315
316 /* init_prov_info2:
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),
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 be converted/obtained
362 * from 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 * ISCSI DUMP API:
375 * in: (u64)a0=paddr of the param or param itself
376 * (u32)a1=ISCSI_CMD_xxx
377 */
378 CMD_ISCSI_DUMP_REQ = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 51),
379
380 /*
381 * ISCSI DUMP STATUS API:
382 * in: (u32)a0=cmd tag
383 * in: (u32)a1=ISCSI_CMD_xxx
384 * out: (u32)a0=cmd status
385 */
386 CMD_ISCSI_DUMP_STATUS = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 52),
387
388 /*
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
395 * 0=> Migrate to VF
396 * 1=> Migrate to MQ
397 * (u32)a1=VF index (MQ index)
398 */
399 CMD_MIGRATE_SUBVNIC = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 53),
400
401 /*
402 * Register / Deregister the notification block for MQ subvnics
403 * in:
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)
407 * out:
408 * (u32)a1 = effective size
409 */
410 CMD_SUBVNIC_NOTIFY = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 54),
411
412 /*
413 * Set the predefined mac address as default
414 * in:
415 * (u48)a0=mac addr
416 */
417 CMD_SET_MAC_ADDR = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 55),
418
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),
423
424 /*
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
428 */
429 CMD_INITIALIZE_DEVCMD2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 57),
430
431 /*
432 * Add a filter.
433 * in: (u64) a0= filter address
434 * (u32) a1= size of filter
435 * out: (u32) a0=filter identifier
436 *
437 * Capability query:
438 * out: (u64) a0= 1 if capability query supported
439 * (u64) a1= MAX filter type supported
440 */
441 CMD_ADD_FILTER = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 58),
442
443 /*
444 * Delete a filter.
445 * in: (u32) a0=filter identifier
446 */
447 CMD_DEL_FILTER = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 59),
448
449 /*
450 * Enable a Queue Pair in User space NIC
451 * in: (u32) a0=Queue Pair number
452 * (u32) a1= command
453 */
454 CMD_QP_ENABLE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 60),
455
456 /*
457 * Disable a Queue Pair in User space NIC
458 * in: (u32) a0=Queue Pair number
459 * (u32) a1= command
460 */
461 CMD_QP_DISABLE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 61),
462
463 /*
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
468 */
469 CMD_QP_STATS_DUMP = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 62),
470
471 /*
472 * Clear stats for Queue Pair in User space NIC
473 * in: (u32) a0=Queue Pair number
474 */
475 CMD_QP_STATS_CLEAR = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 63),
476
477 /*
478 * UEFI BOOT API: (u64)a0= UEFI FLS_CMD_xxx
479 * (ui64)a1= paddr for the info buffer
480 */
481 CMD_FC_REQ = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_FC, 64),
482
483 /*
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
489 */
490 CMD_VNIC_BOOT_CONFIG_INFO = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 65),
491
492 /*
493 * Create a Queue Pair (RoCE)
494 * in: (u32) a0 = Queue Pair number
495 * (u32) a1 = Remote QP
496 * (u32) a2 = RDMA-RQ
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
502 * (u16) a8 = MSS
503 * (u32) a9 = protocol version
504 */
505 CMD_RDMA_QP_CREATE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 66),
506
507 /*
508 * Delete a Queue Pair (RoCE)
509 * in: (u32) a0 = Queue Pair number
510 */
511 CMD_RDMA_QP_DELETE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 67),
512
513 /*
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
518 */
519 CMD_RDMA_QP_STATUS = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 68),
520
521 /*
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
525 * on this feature)
526 * out: (u64) a0 = bitmap of all supported versions for that feature
527 */
528 CMD_GET_SUPP_FEATURE_VER = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 69),
529
530 /*
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
536 */
537 CMD_RDMA_INIT_INFO_BUF = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 70),
538
539 /*
540 * De-init the RDMA notification work queue
541 * in: (u64) a0=resource group number
542 */
543 CMD_RDMA_DEINIT_INFO_BUF = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 71),
544
545 /*
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
552 */
553 CMD_OVERLAY_OFFLOAD_CTRL =
554 _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 72),
555
556 /*
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
560 */
561 CMD_OVERLAY_OFFLOAD_CFG = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 73),
562
563 /*
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
567 */
568 CMD_GET_CONFIG_NAME = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 74),
569
570 /*
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
577 * vector bitmap
578 * in: (u64) a3 = Stride between group vectors
579 */
580 CMD_CONFIG_GRPINTR = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 75),
581
582 /*
583 * Set cq arrary base and size in a list of consective wqs and
584 * rqs for a device
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
591 */
592 CMD_CONFIG_CQ_ARRAY = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 76),
593
594 /*
595 * Add an advanced filter.
596 * in: (u64) a0= filter address
597 * (u32) a1= size of filter
598 * out: (u32) a0=filter identifier
599 *
600 * Capability query:
601 * out: (u64) a0= 1 if capabliity query supported
602 * (u64) a1= MAX filter type supported
603 */
604 CMD_ADD_ADV_FILTER = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 77),
605 };
606
607 /* CMD_ENABLE2 flags */
608 #define CMD_ENABLE2_STANDBY 0x0
609 #define CMD_ENABLE2_ACTIVE 0x1
610
611 /* flags for CMD_OPEN */
612 #define CMD_OPENF_OPROM 0x1 /* open coming from option rom */
613
614 /* flags for CMD_INIT */
615 #define CMD_INITF_DEFAULT_MAC 0x1 /* init with default mac addr */
616
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
623
624 /* Commands for CMD_QP_ENABLE/CM_QP_DISABLE */
625 #define CMD_QP_RQWQ 0x0
626
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
632
633 enum vnic_devcmd_status {
634 STAT_NONE = 0,
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
639 */
640 };
641
642 enum vnic_devcmd_error {
643 ERR_SUCCESS = 0,
644 ERR_EINVAL = 1,
645 ERR_EFAULT = 2,
646 ERR_EPERM = 3,
647 ERR_EBUSY = 4,
648 ERR_ECMDUNKNOWN = 5,
649 ERR_EBADSTATE = 6,
650 ERR_ENOMEM = 7,
651 ERR_ETIMEDOUT = 8,
652 ERR_ELINKDOWN = 9,
653 ERR_EMAXRES = 10,
654 ERR_ENOTSUPPORTED = 11,
655 ERR_EINPROGRESS = 12,
656 ERR_MAX
657 };
658
659 /*
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).
664 */
665 struct vnic_devcmd_fw_info {
666 char fw_version[32];
667 char fw_build[32];
668 char hw_version[32];
669 char hw_serial_number[32];
670 u16 asic_type;
671 u16 asic_rev;
672 };
673
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,
679 };
680
681 struct vnic_devcmd_notify {
682 u32 csum; /* checksum over following words */
683
684 u32 link_state; /* link up == 1 */
685 u32 port_speed; /* effective port speed (rate limit) */
686 u32 mtu; /* MTU */
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 */
693 };
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 |\
701 0)
702
703 struct vnic_devcmd_provinfo {
704 u8 oui[3];
705 u8 type;
706 u8 data[0];
707 };
708
709 /*
710 * These are used in flags field of different filters to denote
711 * valid fields used.
712 */
713 #define FILTER_FIELD_VALID(fld) (1 << (fld - 1))
714
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)
719
720 #define FILTER_FIELDS_USNIC (FILTER_FIELD_USNIC_VLAN | \
721 FILTER_FIELD_USNIC_ETHTYPE | \
722 FILTER_FIELD_USNIC_PROTO | \
723 FILTER_FIELD_USNIC_ID)
724
725 struct filter_usnic_id {
726 u32 flags;
727 u16 vlan;
728 u16 ethtype;
729 u8 proto_version;
730 u32 usnic_id;
731 } __attribute__((packed));
732
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)
738
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)
744
745 /* Enums for the protocol field. */
746 enum protocol_e {
747 PROTO_UDP = 0,
748 PROTO_TCP = 1,
749 PROTO_IPV4 = 2,
750 PROTO_IPV6 = 3
751 };
752
753 struct filter_ipv4_5tuple {
754 u32 flags;
755 u32 protocol;
756 u32 src_addr;
757 u32 dst_addr;
758 u16 src_port;
759 u16 dst_port;
760 } __attribute__((packed));
761
762 #define FILTER_FIELD_VMQ_VLAN FILTER_FIELD_VALID(1)
763 #define FILTER_FIELD_VMQ_MAC FILTER_FIELD_VALID(2)
764
765 #define FILTER_FIELDS_MAC_VLAN (FILTER_FIELD_VMQ_VLAN | \
766 FILTER_FIELD_VMQ_MAC)
767
768 #define FILTER_FIELDS_NVGRE FILTER_FIELD_VMQ_MAC
769
770 struct filter_mac_vlan {
771 u32 flags;
772 u16 vlan;
773 u8 mac_addr[6];
774 } __attribute__((packed));
775
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)
781
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)
787
788 struct filter_vlan_ip_3tuple {
789 u32 flags;
790 u16 vlan;
791 u16 l3_protocol;
792 union {
793 u32 dst_addr_v4;
794 u8 dst_addr_v6[16];
795 } u;
796 u32 l4_protocol;
797 u16 dst_port;
798 } __attribute__((packed));
799
800 #define FILTER_GENERIC_1_BYTES 64
801
802 enum filter_generic_1_layer {
803 FILTER_GENERIC_1_L2,
804 FILTER_GENERIC_1_L3,
805 FILTER_GENERIC_1_L4,
806 FILTER_GENERIC_1_L5,
807 FILTER_GENERIC_1_NUM_LAYERS
808 };
809
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)
818
819 #define FILTER_GENERIC_1_KEY_LEN 64
820
821 /*
822 * Version 1 of generic filter specification
823 * position is only 16 bits, reserving positions > 64k to be used by firmware
824 */
825 struct filter_generic_1 {
826 u16 position; /* lower position comes first */
827 u32 mask_flags;
828 u32 val_flags;
829 u16 mask_vlan;
830 u16 val_vlan;
831 struct {
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));
836
837 /* Specifies the filter_action type. */
838 enum {
839 FILTER_ACTION_RQ_STEERING = 0,
840 FILTER_ACTION_MAX
841 };
842
843 struct filter_action {
844 u32 type;
845 union {
846 u32 rq_idx;
847 } u;
848 } __attribute__((packed));
849
850 /* Specifies the filter type. */
851 enum filter_type {
852 FILTER_USNIC_ID = 0,
853 FILTER_IPV4_5TUPLE = 1,
854 FILTER_MAC_VLAN = 2,
855 FILTER_VLAN_IP_3TUPLE = 3,
856 FILTER_NVGRE_VMQ = 4,
857 FILTER_USNIC_IP = 5,
858 FILTER_DPDK_1 = 6,
859 FILTER_MAX
860 };
861
862 struct filter {
863 u32 type;
864 union {
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;
869 } u;
870 } __attribute__((packed));
871
872 /*
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
879 * growth.
880 */
881 struct filter_v2 {
882 u32 type;
883 union {
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;
889 } u;
890 } __attribute__((packed));
891
892 enum {
893 CLSF_TLV_FILTER = 0,
894 CLSF_TLV_ACTION = 1,
895 };
896
897 struct filter_tlv {
898 u_int32_t type;
899 u_int32_t length;
900 u_int32_t val[0];
901 };
902
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)))
908
909 /*
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.
913 */
914 static inline u_int32_t
915 vnic_filter_size(struct filter_v2 *fp)
916 {
917 u_int32_t size;
918
919 switch (fp->type) {
920 case FILTER_USNIC_ID:
921 size = sizeof(fp->u.usnic);
922 break;
923 case FILTER_IPV4_5TUPLE:
924 size = sizeof(fp->u.ipv4);
925 break;
926 case FILTER_MAC_VLAN:
927 case FILTER_NVGRE_VMQ:
928 size = sizeof(fp->u.mac_vlan);
929 break;
930 case FILTER_VLAN_IP_3TUPLE:
931 size = sizeof(fp->u.vlan_3tuple);
932 break;
933 case FILTER_USNIC_IP:
934 case FILTER_DPDK_1:
935 size = sizeof(fp->u.generic_1);
936 break;
937 default:
938 size = sizeof(fp->u);
939 break;
940 }
941 size += sizeof(fp->type);
942 return size;
943 }
944
945
946 enum {
947 CLSF_ADD = 0,
948 CLSF_DEL = 1,
949 };
950
951 /*
952 * Writing cmd register causes STAT_BUSY to get set in status register.
953 * When cmd completes, STAT_BUSY will be cleared.
954 *
955 * If cmd completed successfully STAT_ERROR will be clear
956 * and args registers contain cmd-specific results.
957 *
958 * If cmd error, STAT_ERROR will be set and args[0] contains error code.
959 *
960 * status register is read-only. While STAT_BUSY is set,
961 * all other register contents are read-only.
962 */
963
964 /* Make sizeof(vnic_devcmd) a power-of-2 for I/O BAR. */
965 #define VNIC_DEVCMD_NARGS 15
966 struct vnic_devcmd {
967 u32 status; /* RO */
968 u32 cmd; /* RW */
969 u64 args[VNIC_DEVCMD_NARGS]; /* RW cmd args (little-endian) */
970 };
971
972 /*
973 * Version 2 of the interface.
974 *
975 * Some things are carried over, notably the vnic_devcmd_cmd enum.
976 */
977
978 /*
979 * Flags for vnic_devcmd2.flags
980 */
981
982 #define DEVCMD2_FNORESULT 0x1 /* Don't copy result to host */
983
984 #define VNIC_DEVCMD2_NARGS VNIC_DEVCMD_NARGS
985 struct vnic_devcmd2 {
986 u16 pad;
987 u16 flags;
988 u32 cmd; /* same command #defines as original */
989 u64 args[VNIC_DEVCMD2_NARGS];
990 };
991
992 #define VNIC_DEVCMD2_NRESULTS VNIC_DEVCMD_NARGS
993 struct devcmd2_result {
994 u64 results[VNIC_DEVCMD2_NRESULTS];
995 u32 pad;
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 */
999 };
1000
1001 #define DEVCMD2_RING_SIZE 32
1002 #define DEVCMD2_DESC_SIZE 128
1003
1004 #define DEVCMD2_RESULTS_SIZE_MAX ((1 << 16) - 1)
1005
1006 /* Overlay related definitions */
1007
1008 /*
1009 * This enum lists the flag associated with each of the overlay features
1010 */
1011 typedef enum {
1012 OVERLAY_FEATURE_NVGRE = 1,
1013 OVERLAY_FEATURE_VXLAN,
1014 OVERLAY_FEATURE_MAX,
1015 } overlay_feature_t;
1016
1017 #define OVERLAY_OFFLOAD_ENABLE 0
1018 #define OVERLAY_OFFLOAD_DISABLE 1
1019 #define OVERLAY_OFFLOAD_ENABLE_V2 2
1020
1021 #define OVERLAY_CFG_VXLAN_PORT_UPDATE 0
1022
1023 /*
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
1027 */
1028 typedef enum {
1029 VIC_FEATURE_VXLAN,
1030 VIC_FEATURE_RDMA,
1031 VIC_FEATURE_MAX,
1032 } vic_feature_t;
1033
1034 /*
1035 * CMD_CONFIG_GRPINTR subcommands
1036 */
1037 typedef enum {
1038 GRPINTR_ENABLE = 1,
1039 GRPINTR_DISABLE,
1040 GRPINTR_UPD_VECT,
1041 } grpintr_subcmd_t;
1042
1043 #endif /* _VNIC_DEVCMD_H_ */