1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright (c) 2013-2022, Intel Corporation. */
7 #include <linux/bitops.h>
8 #include <linux/bits.h>
9 #include <linux/overflow.h>
10 #include <uapi/linux/if_ether.h>
13 * This header file describes the Virtual Function (VF) - Physical Function
14 * (PF) communication protocol used by the drivers for all devices starting
15 * from our 40G product line
17 * Admin queue buffer usage:
18 * desc->opcode is always aqc_opc_send_msg_to_pf
19 * flags, retval, datalen, and data addr are all used normally.
20 * The Firmware copies the cookie fields when sending messages between the
21 * PF and VF, but uses all other fields internally. Due to this limitation,
22 * we must send all messages as "indirect", i.e. using an external buffer.
24 * All the VSI indexes are relative to the VF. Each VF can have maximum of
25 * three VSIs. All the queue indexes are relative to the VSI. Each VF can
26 * have a maximum of sixteen queues for all of its VSIs.
28 * The PF is required to return a status code in v_retval for all messages
29 * except RESET_VF, which does not require any response. The returned value
30 * is of virtchnl_status_code type, defined here.
32 * In general, VF driver initialization should roughly follow the order of
33 * these opcodes. The VF driver must first validate the API version of the
34 * PF driver, then request a reset, then get resources, then configure
35 * queues and interrupts. After these operations are complete, the VF
36 * driver may start its queues, optionally add MAC and VLAN filters, and
40 /* START GENERIC DEFINES
41 * Need to ensure the following enums and defines hold the same meaning and
42 * value in current and future projects
46 enum virtchnl_status_code
{
47 VIRTCHNL_STATUS_SUCCESS
= 0,
48 VIRTCHNL_STATUS_ERR_PARAM
= -5,
49 VIRTCHNL_STATUS_ERR_NO_MEMORY
= -18,
50 VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH
= -38,
51 VIRTCHNL_STATUS_ERR_CQP_COMPL_ERROR
= -39,
52 VIRTCHNL_STATUS_ERR_INVALID_VF_ID
= -40,
53 VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR
= -53,
54 VIRTCHNL_STATUS_ERR_NOT_SUPPORTED
= -64,
57 /* Backward compatibility */
58 #define VIRTCHNL_ERR_PARAM VIRTCHNL_STATUS_ERR_PARAM
59 #define VIRTCHNL_STATUS_NOT_SUPPORTED VIRTCHNL_STATUS_ERR_NOT_SUPPORTED
61 #define VIRTCHNL_LINK_SPEED_2_5GB_SHIFT 0x0
62 #define VIRTCHNL_LINK_SPEED_100MB_SHIFT 0x1
63 #define VIRTCHNL_LINK_SPEED_1000MB_SHIFT 0x2
64 #define VIRTCHNL_LINK_SPEED_10GB_SHIFT 0x3
65 #define VIRTCHNL_LINK_SPEED_40GB_SHIFT 0x4
66 #define VIRTCHNL_LINK_SPEED_20GB_SHIFT 0x5
67 #define VIRTCHNL_LINK_SPEED_25GB_SHIFT 0x6
68 #define VIRTCHNL_LINK_SPEED_5GB_SHIFT 0x7
70 enum virtchnl_link_speed
{
71 VIRTCHNL_LINK_SPEED_UNKNOWN
= 0,
72 VIRTCHNL_LINK_SPEED_100MB
= BIT(VIRTCHNL_LINK_SPEED_100MB_SHIFT
),
73 VIRTCHNL_LINK_SPEED_1GB
= BIT(VIRTCHNL_LINK_SPEED_1000MB_SHIFT
),
74 VIRTCHNL_LINK_SPEED_10GB
= BIT(VIRTCHNL_LINK_SPEED_10GB_SHIFT
),
75 VIRTCHNL_LINK_SPEED_40GB
= BIT(VIRTCHNL_LINK_SPEED_40GB_SHIFT
),
76 VIRTCHNL_LINK_SPEED_20GB
= BIT(VIRTCHNL_LINK_SPEED_20GB_SHIFT
),
77 VIRTCHNL_LINK_SPEED_25GB
= BIT(VIRTCHNL_LINK_SPEED_25GB_SHIFT
),
78 VIRTCHNL_LINK_SPEED_2_5GB
= BIT(VIRTCHNL_LINK_SPEED_2_5GB_SHIFT
),
79 VIRTCHNL_LINK_SPEED_5GB
= BIT(VIRTCHNL_LINK_SPEED_5GB_SHIFT
),
82 /* for hsplit_0 field of Rx HMC context */
83 /* deprecated with AVF 1.0 */
84 enum virtchnl_rx_hsplit
{
85 VIRTCHNL_RX_HSPLIT_NO_SPLIT
= 0,
86 VIRTCHNL_RX_HSPLIT_SPLIT_L2
= 1,
87 VIRTCHNL_RX_HSPLIT_SPLIT_IP
= 2,
88 VIRTCHNL_RX_HSPLIT_SPLIT_TCP_UDP
= 4,
89 VIRTCHNL_RX_HSPLIT_SPLIT_SCTP
= 8,
92 enum virtchnl_bw_limit_type
{
93 VIRTCHNL_BW_SHAPER
= 0,
95 /* END GENERIC DEFINES */
97 /* Opcodes for VF-PF communication. These are placed in the v_opcode field
98 * of the virtchnl_msg structure.
101 /* The PF sends status change events to VFs using
102 * the VIRTCHNL_OP_EVENT opcode.
103 * VFs send requests to the PF using the other ops.
104 * Use of "advanced opcode" features must be negotiated as part of capabilities
105 * exchange and are not considered part of base mode feature set.
107 VIRTCHNL_OP_UNKNOWN
= 0,
108 VIRTCHNL_OP_VERSION
= 1, /* must ALWAYS be 1 */
109 VIRTCHNL_OP_RESET_VF
= 2,
110 VIRTCHNL_OP_GET_VF_RESOURCES
= 3,
111 VIRTCHNL_OP_CONFIG_TX_QUEUE
= 4,
112 VIRTCHNL_OP_CONFIG_RX_QUEUE
= 5,
113 VIRTCHNL_OP_CONFIG_VSI_QUEUES
= 6,
114 VIRTCHNL_OP_CONFIG_IRQ_MAP
= 7,
115 VIRTCHNL_OP_ENABLE_QUEUES
= 8,
116 VIRTCHNL_OP_DISABLE_QUEUES
= 9,
117 VIRTCHNL_OP_ADD_ETH_ADDR
= 10,
118 VIRTCHNL_OP_DEL_ETH_ADDR
= 11,
119 VIRTCHNL_OP_ADD_VLAN
= 12,
120 VIRTCHNL_OP_DEL_VLAN
= 13,
121 VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE
= 14,
122 VIRTCHNL_OP_GET_STATS
= 15,
123 VIRTCHNL_OP_RSVD
= 16,
124 VIRTCHNL_OP_EVENT
= 17, /* must ALWAYS be 17 */
125 VIRTCHNL_OP_CONFIG_RSS_HFUNC
= 18,
126 /* opcode 19 is reserved */
127 VIRTCHNL_OP_IWARP
= 20, /* advanced opcode */
128 VIRTCHNL_OP_RDMA
= VIRTCHNL_OP_IWARP
,
129 VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP
= 21, /* advanced opcode */
130 VIRTCHNL_OP_CONFIG_RDMA_IRQ_MAP
= VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP
,
131 VIRTCHNL_OP_RELEASE_IWARP_IRQ_MAP
= 22, /* advanced opcode */
132 VIRTCHNL_OP_RELEASE_RDMA_IRQ_MAP
= VIRTCHNL_OP_RELEASE_IWARP_IRQ_MAP
,
133 VIRTCHNL_OP_CONFIG_RSS_KEY
= 23,
134 VIRTCHNL_OP_CONFIG_RSS_LUT
= 24,
135 VIRTCHNL_OP_GET_RSS_HENA_CAPS
= 25,
136 VIRTCHNL_OP_SET_RSS_HENA
= 26,
137 VIRTCHNL_OP_ENABLE_VLAN_STRIPPING
= 27,
138 VIRTCHNL_OP_DISABLE_VLAN_STRIPPING
= 28,
139 VIRTCHNL_OP_REQUEST_QUEUES
= 29,
140 VIRTCHNL_OP_ENABLE_CHANNELS
= 30,
141 VIRTCHNL_OP_DISABLE_CHANNELS
= 31,
142 VIRTCHNL_OP_ADD_CLOUD_FILTER
= 32,
143 VIRTCHNL_OP_DEL_CLOUD_FILTER
= 33,
144 /* opcode 34 - 43 are reserved */
145 VIRTCHNL_OP_GET_SUPPORTED_RXDIDS
= 44,
146 VIRTCHNL_OP_ADD_RSS_CFG
= 45,
147 VIRTCHNL_OP_DEL_RSS_CFG
= 46,
148 VIRTCHNL_OP_ADD_FDIR_FILTER
= 47,
149 VIRTCHNL_OP_DEL_FDIR_FILTER
= 48,
150 VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS
= 51,
151 VIRTCHNL_OP_ADD_VLAN_V2
= 52,
152 VIRTCHNL_OP_DEL_VLAN_V2
= 53,
153 VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2
= 54,
154 VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2
= 55,
155 VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2
= 56,
156 VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2
= 57,
157 /* opcode 57 - 65 are reserved */
158 VIRTCHNL_OP_GET_QOS_CAPS
= 66,
159 /* opcode 68 through 111 are reserved */
160 VIRTCHNL_OP_CONFIG_QUEUE_BW
= 112,
161 VIRTCHNL_OP_CONFIG_QUANTA
= 113,
165 /* These macros are used to generate compilation errors if a structure/union
166 * is not exactly the correct length. It gives a divide by zero error if the
167 * structure/union is not of the correct size, otherwise it creates an enum
168 * that is never used.
170 #define VIRTCHNL_CHECK_STRUCT_LEN(n, X) enum virtchnl_static_assert_enum_##X \
171 { virtchnl_static_assert_##X = (n)/((sizeof(struct X) == (n)) ? 1 : 0) }
172 #define VIRTCHNL_CHECK_UNION_LEN(n, X) enum virtchnl_static_asset_enum_##X \
173 { virtchnl_static_assert_##X = (n)/((sizeof(union X) == (n)) ? 1 : 0) }
175 /* Message descriptions and data structures. */
177 /* VIRTCHNL_OP_VERSION
178 * VF posts its version number to the PF. PF responds with its version number
179 * in the same format, along with a return code.
180 * Reply from PF has its major/minor versions also in param0 and param1.
181 * If there is a major version mismatch, then the VF cannot operate.
182 * If there is a minor version mismatch, then the VF can operate but should
183 * add a warning to the system log.
185 * This enum element MUST always be specified as == 1, regardless of other
186 * changes in the API. The PF must always respond to this message without
187 * error regardless of version mismatch.
189 #define VIRTCHNL_VERSION_MAJOR 1
190 #define VIRTCHNL_VERSION_MINOR 1
191 #define VIRTCHNL_VERSION_MINOR_NO_VF_CAPS 0
193 struct virtchnl_version_info
{
198 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_version_info
);
200 #define VF_IS_V10(_v) (((_v)->major == 1) && ((_v)->minor == 0))
201 #define VF_IS_V11(_ver) (((_ver)->major == 1) && ((_ver)->minor == 1))
203 /* VIRTCHNL_OP_RESET_VF
204 * VF sends this request to PF with no parameters
205 * PF does NOT respond! VF driver must delay then poll VFGEN_RSTAT register
206 * until reset completion is indicated. The admin queue must be reinitialized
207 * after this operation.
209 * When reset is complete, PF must ensure that all queues in all VSIs associated
210 * with the VF are stopped, all queue configurations in the HMC are set to 0,
211 * and all MAC and VLAN filters (except the default MAC address) on all VSIs
215 /* VSI types that use VIRTCHNL interface for VF-PF communication. VSI_SRIOV
216 * vsi_type should always be 6 for backward compatibility. Add other fields
219 enum virtchnl_vsi_type
{
220 VIRTCHNL_VSI_TYPE_INVALID
= 0,
221 VIRTCHNL_VSI_SRIOV
= 6,
224 /* VIRTCHNL_OP_GET_VF_RESOURCES
225 * Version 1.0 VF sends this request to PF with no parameters
226 * Version 1.1 VF sends this request to PF with u32 bitmap of its capabilities
227 * PF responds with an indirect message containing
228 * virtchnl_vf_resource and one or more
229 * virtchnl_vsi_resource structures.
232 struct virtchnl_vsi_resource
{
236 /* see enum virtchnl_vsi_type */
239 u8 default_mac_addr
[ETH_ALEN
];
242 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource
);
244 /* VF capability flags
245 * VIRTCHNL_VF_OFFLOAD_L2 flag is inclusive of base mode L2 offloads including
246 * TX/RX Checksum offloading and TSO for non-tunnelled packets.
248 #define VIRTCHNL_VF_OFFLOAD_L2 BIT(0)
249 #define VIRTCHNL_VF_OFFLOAD_RDMA BIT(1)
250 #define VIRTCHNL_VF_CAP_RDMA VIRTCHNL_VF_OFFLOAD_RDMA
251 #define VIRTCHNL_VF_OFFLOAD_RSS_AQ BIT(3)
252 #define VIRTCHNL_VF_OFFLOAD_RSS_REG BIT(4)
253 #define VIRTCHNL_VF_OFFLOAD_WB_ON_ITR BIT(5)
254 #define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES BIT(6)
255 /* used to negotiate communicating link speeds in Mbps */
256 #define VIRTCHNL_VF_CAP_ADV_LINK_SPEED BIT(7)
257 #define VIRTCHNL_VF_OFFLOAD_CRC BIT(10)
258 #define VIRTCHNL_VF_OFFLOAD_TC_U32 BIT(11)
259 #define VIRTCHNL_VF_OFFLOAD_VLAN_V2 BIT(15)
260 #define VIRTCHNL_VF_OFFLOAD_VLAN BIT(16)
261 #define VIRTCHNL_VF_OFFLOAD_RX_POLLING BIT(17)
262 #define VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 BIT(18)
263 #define VIRTCHNL_VF_OFFLOAD_RSS_PF BIT(19)
264 #define VIRTCHNL_VF_OFFLOAD_ENCAP BIT(20)
265 #define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM BIT(21)
266 #define VIRTCHNL_VF_OFFLOAD_RX_ENCAP_CSUM BIT(22)
267 #define VIRTCHNL_VF_OFFLOAD_ADQ BIT(23)
268 #define VIRTCHNL_VF_OFFLOAD_USO BIT(25)
269 #define VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC BIT(26)
270 #define VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF BIT(27)
271 #define VIRTCHNL_VF_OFFLOAD_FDIR_PF BIT(28)
272 #define VIRTCHNL_VF_OFFLOAD_QOS BIT(29)
274 #define VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \
275 VIRTCHNL_VF_OFFLOAD_VLAN | \
276 VIRTCHNL_VF_OFFLOAD_RSS_PF)
278 struct virtchnl_vf_resource
{
288 struct virtchnl_vsi_resource vsi_res
[];
291 VIRTCHNL_CHECK_STRUCT_LEN(20, virtchnl_vf_resource
);
292 #define virtchnl_vf_resource_LEGACY_SIZEOF 36
294 /* VIRTCHNL_OP_CONFIG_TX_QUEUE
295 * VF sends this message to set up parameters for one TX queue.
296 * External data buffer contains one instance of virtchnl_txq_info.
297 * PF configures requested queue and returns a status code.
300 /* Tx queue config info */
301 struct virtchnl_txq_info
{
304 u16 ring_len
; /* number of descriptors, multiple of 8 */
305 u16 headwb_enabled
; /* deprecated with AVF 1.0 */
307 u64 dma_headwb_addr
; /* deprecated with AVF 1.0 */
310 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_txq_info
);
312 /* VIRTCHNL_OP_CONFIG_RX_QUEUE
313 * VF sends this message to set up parameters for one RX queue.
314 * External data buffer contains one instance of virtchnl_rxq_info.
315 * PF configures requested queue and returns a status code. The
316 * crc_disable flag disables CRC stripping on the VF. Setting
317 * the crc_disable flag to 1 will disable CRC stripping for each
318 * queue in the VF where the flag is set. The VIRTCHNL_VF_OFFLOAD_CRC
319 * offload must have been set prior to sending this info or the PF
320 * will ignore the request. This flag should be set the same for
321 * all of the queues for a VF.
324 /* Rx queue config info */
325 struct virtchnl_rxq_info
{
328 u32 ring_len
; /* number of descriptors, multiple of 32 */
330 u16 splithdr_enabled
; /* deprecated with AVF 1.0 */
338 /* see enum virtchnl_rx_hsplit; deprecated with AVF 1.0 */
343 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_rxq_info
);
345 /* VIRTCHNL_OP_CONFIG_VSI_QUEUES
346 * VF sends this message to set parameters for all active TX and RX queues
347 * associated with the specified VSI.
348 * PF configures queues and returns status.
349 * If the number of queues specified is greater than the number of queues
350 * associated with the VSI, an error is returned and no queues are configured.
351 * NOTE: The VF is not required to configure all queues in a single request.
352 * It may send multiple messages. PF drivers must correctly handle all VF
355 struct virtchnl_queue_pair_info
{
356 /* NOTE: vsi_id and queue_id should be identical for both queues. */
357 struct virtchnl_txq_info txq
;
358 struct virtchnl_rxq_info rxq
;
361 VIRTCHNL_CHECK_STRUCT_LEN(64, virtchnl_queue_pair_info
);
363 struct virtchnl_vsi_queue_config_info
{
367 struct virtchnl_queue_pair_info qpair
[];
370 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_vsi_queue_config_info
);
371 #define virtchnl_vsi_queue_config_info_LEGACY_SIZEOF 72
373 /* VIRTCHNL_OP_REQUEST_QUEUES
374 * VF sends this message to request the PF to allocate additional queues to
375 * this VF. Each VF gets a guaranteed number of queues on init but asking for
376 * additional queues must be negotiated. This is a best effort request as it
377 * is possible the PF does not have enough queues left to support the request.
378 * If the PF cannot support the number requested it will respond with the
379 * maximum number it is able to support. If the request is successful, PF will
380 * then reset the VF to institute required changes.
383 /* VF resource request */
384 struct virtchnl_vf_res_request
{
388 /* VIRTCHNL_OP_CONFIG_IRQ_MAP
389 * VF uses this message to map vectors to queues.
390 * The rxq_map and txq_map fields are bitmaps used to indicate which queues
391 * are to be associated with the specified vector.
392 * The "other" causes are always mapped to vector 0. The VF may not request
393 * that vector 0 be used for traffic.
394 * PF configures interrupt mapping and returns status.
395 * NOTE: due to hardware requirements, all active queues (both TX and RX)
396 * should be mapped to interrupts, even if the driver intends to operate
397 * only in polling mode. In this case the interrupt may be disabled, but
398 * the ITR timer will still run to trigger writebacks.
400 struct virtchnl_vector_map
{
409 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_vector_map
);
411 struct virtchnl_irq_map_info
{
413 struct virtchnl_vector_map vecmap
[];
416 VIRTCHNL_CHECK_STRUCT_LEN(2, virtchnl_irq_map_info
);
417 #define virtchnl_irq_map_info_LEGACY_SIZEOF 14
419 /* VIRTCHNL_OP_ENABLE_QUEUES
420 * VIRTCHNL_OP_DISABLE_QUEUES
421 * VF sends these message to enable or disable TX/RX queue pairs.
422 * The queues fields are bitmaps indicating which queues to act upon.
423 * (Currently, we only support 16 queues per VF, but we make the field
424 * u32 to allow for expansion.)
425 * PF performs requested action and returns status.
426 * NOTE: The VF is not required to enable/disable all queues in a single
427 * request. It may send multiple messages.
428 * PF drivers must correctly handle all VF requests.
430 struct virtchnl_queue_select
{
437 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_select
);
439 /* VIRTCHNL_OP_ADD_ETH_ADDR
440 * VF sends this message in order to add one or more unicast or multicast
441 * address filters for the specified VSI.
442 * PF adds the filters and returns status.
445 /* VIRTCHNL_OP_DEL_ETH_ADDR
446 * VF sends this message in order to remove one or more unicast or multicast
447 * filters for the specified VSI.
448 * PF removes the filters and returns status.
451 /* VIRTCHNL_ETHER_ADDR_LEGACY
452 * Prior to adding the @type member to virtchnl_ether_addr, there were 2 pad
453 * bytes. Moving forward all VF drivers should not set type to
454 * VIRTCHNL_ETHER_ADDR_LEGACY. This is only here to not break previous/legacy
455 * behavior. The control plane function (i.e. PF) can use a best effort method
456 * of tracking the primary/device unicast in this case, but there is no
457 * guarantee and functionality depends on the implementation of the PF.
460 /* VIRTCHNL_ETHER_ADDR_PRIMARY
461 * All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_PRIMARY for the
462 * primary/device unicast MAC address filter for VIRTCHNL_OP_ADD_ETH_ADDR and
463 * VIRTCHNL_OP_DEL_ETH_ADDR. This allows for the underlying control plane
464 * function (i.e. PF) to accurately track and use this MAC address for
465 * displaying on the host and for VM/function reset.
468 /* VIRTCHNL_ETHER_ADDR_EXTRA
469 * All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_EXTRA for any extra
470 * unicast and/or multicast filters that are being added/deleted via
471 * VIRTCHNL_OP_DEL_ETH_ADDR/VIRTCHNL_OP_ADD_ETH_ADDR respectively.
473 struct virtchnl_ether_addr
{
476 #define VIRTCHNL_ETHER_ADDR_LEGACY 0
477 #define VIRTCHNL_ETHER_ADDR_PRIMARY 1
478 #define VIRTCHNL_ETHER_ADDR_EXTRA 2
479 #define VIRTCHNL_ETHER_ADDR_TYPE_MASK 3 /* first two bits of type are valid */
483 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_ether_addr
);
485 struct virtchnl_ether_addr_list
{
488 struct virtchnl_ether_addr list
[];
491 VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_ether_addr_list
);
492 #define virtchnl_ether_addr_list_LEGACY_SIZEOF 12
494 /* VIRTCHNL_OP_ADD_VLAN
495 * VF sends this message to add one or more VLAN tag filters for receives.
496 * PF adds the filters and returns status.
497 * If a port VLAN is configured by the PF, this operation will return an
501 /* VIRTCHNL_OP_DEL_VLAN
502 * VF sends this message to remove one or more VLAN tag filters for receives.
503 * PF removes the filters and returns status.
504 * If a port VLAN is configured by the PF, this operation will return an
508 struct virtchnl_vlan_filter_list
{
514 VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_vlan_filter_list
);
515 #define virtchnl_vlan_filter_list_LEGACY_SIZEOF 6
517 /* This enum is used for all of the VIRTCHNL_VF_OFFLOAD_VLAN_V2_CAPS related
518 * structures and opcodes.
520 * VIRTCHNL_VLAN_UNSUPPORTED - This field is not supported and if a VF driver
521 * populates it the PF should return VIRTCHNL_STATUS_ERR_NOT_SUPPORTED.
523 * VIRTCHNL_VLAN_ETHERTYPE_8100 - This field supports 0x8100 ethertype.
524 * VIRTCHNL_VLAN_ETHERTYPE_88A8 - This field supports 0x88A8 ethertype.
525 * VIRTCHNL_VLAN_ETHERTYPE_9100 - This field supports 0x9100 ethertype.
527 * VIRTCHNL_VLAN_ETHERTYPE_AND - Used when multiple ethertypes can be supported
528 * by the PF concurrently. For example, if the PF can support
529 * VIRTCHNL_VLAN_ETHERTYPE_8100 AND VIRTCHNL_VLAN_ETHERTYPE_88A8 filters it
530 * would OR the following bits:
532 * VIRTHCNL_VLAN_ETHERTYPE_8100 |
533 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
534 * VIRTCHNL_VLAN_ETHERTYPE_AND;
536 * The VF would interpret this as VLAN filtering can be supported on both 0x8100
537 * and 0x88A8 VLAN ethertypes.
539 * VIRTCHNL_ETHERTYPE_XOR - Used when only a single ethertype can be supported
540 * by the PF concurrently. For example if the PF can support
541 * VIRTCHNL_VLAN_ETHERTYPE_8100 XOR VIRTCHNL_VLAN_ETHERTYPE_88A8 stripping
542 * offload it would OR the following bits:
544 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
545 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
546 * VIRTCHNL_VLAN_ETHERTYPE_XOR;
548 * The VF would interpret this as VLAN stripping can be supported on either
549 * 0x8100 or 0x88a8 VLAN ethertypes. So when requesting VLAN stripping via
550 * VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 the specified ethertype will override
551 * the previously set value.
553 * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1 - Used to tell the VF to insert and/or
554 * strip the VLAN tag using the L2TAG1 field of the Tx/Rx descriptors.
556 * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 - Used to tell the VF to insert hardware
557 * offloaded VLAN tags using the L2TAG2 field of the Tx descriptor.
559 * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 - Used to tell the VF to strip hardware
560 * offloaded VLAN tags using the L2TAG2_2 field of the Rx descriptor.
562 * VIRTCHNL_VLAN_PRIO - This field supports VLAN priority bits. This is used for
563 * VLAN filtering if the underlying PF supports it.
565 * VIRTCHNL_VLAN_TOGGLE_ALLOWED - This field is used to say whether a
566 * certain VLAN capability can be toggled. For example if the underlying PF/CP
567 * allows the VF to toggle VLAN filtering, stripping, and/or insertion it should
568 * set this bit along with the supported ethertypes.
570 enum virtchnl_vlan_support
{
571 VIRTCHNL_VLAN_UNSUPPORTED
= 0,
572 VIRTCHNL_VLAN_ETHERTYPE_8100
= BIT(0),
573 VIRTCHNL_VLAN_ETHERTYPE_88A8
= BIT(1),
574 VIRTCHNL_VLAN_ETHERTYPE_9100
= BIT(2),
575 VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1
= BIT(8),
576 VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2
= BIT(9),
577 VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2_2
= BIT(10),
578 VIRTCHNL_VLAN_PRIO
= BIT(24),
579 VIRTCHNL_VLAN_FILTER_MASK
= BIT(28),
580 VIRTCHNL_VLAN_ETHERTYPE_AND
= BIT(29),
581 VIRTCHNL_VLAN_ETHERTYPE_XOR
= BIT(30),
582 VIRTCHNL_VLAN_TOGGLE
= BIT(31),
585 /* This structure is used as part of the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS
586 * for filtering, insertion, and stripping capabilities.
588 * If only outer capabilities are supported (for filtering, insertion, and/or
589 * stripping) then this refers to the outer most or single VLAN from the VF's
592 * If only inner capabilities are supported (for filtering, insertion, and/or
593 * stripping) then this refers to the outer most or single VLAN from the VF's
594 * perspective. Functionally this is the same as if only outer capabilities are
595 * supported. The VF driver is just forced to use the inner fields when
596 * adding/deleting filters and enabling/disabling offloads (if supported).
598 * If both outer and inner capabilities are supported (for filtering, insertion,
599 * and/or stripping) then outer refers to the outer most or single VLAN and
600 * inner refers to the second VLAN, if it exists, in the packet.
602 * There is no support for tunneled VLAN offloads, so outer or inner are never
603 * referring to a tunneled packet from the VF's perspective.
605 struct virtchnl_vlan_supported_caps
{
610 /* The PF populates these fields based on the supported VLAN filtering. If a
611 * field is VIRTCHNL_VLAN_UNSUPPORTED then it's not supported and the PF will
612 * reject any VIRTCHNL_OP_ADD_VLAN_V2 or VIRTCHNL_OP_DEL_VLAN_V2 messages using
613 * the unsupported fields.
615 * Also, a VF is only allowed to toggle its VLAN filtering setting if the
616 * VIRTCHNL_VLAN_TOGGLE bit is set.
618 * The ethertype(s) specified in the ethertype_init field are the ethertypes
619 * enabled for VLAN filtering. VLAN filtering in this case refers to the outer
620 * most VLAN from the VF's perspective. If both inner and outer filtering are
621 * allowed then ethertype_init only refers to the outer most VLAN as only
622 * VLAN ethertype supported for inner VLAN filtering is
623 * VIRTCHNL_VLAN_ETHERTYPE_8100. By default, inner VLAN filtering is disabled
624 * when both inner and outer filtering are allowed.
626 * The max_filters field tells the VF how many VLAN filters it's allowed to have
627 * at any one time. If it exceeds this amount and tries to add another filter,
628 * then the request will be rejected by the PF. To prevent failures, the VF
629 * should keep track of how many VLAN filters it has added and not attempt to
630 * add more than max_filters.
632 struct virtchnl_vlan_filtering_caps
{
633 struct virtchnl_vlan_supported_caps filtering_support
;
639 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vlan_filtering_caps
);
641 /* This enum is used for the virtchnl_vlan_offload_caps structure to specify
642 * if the PF supports a different ethertype for stripping and insertion.
644 * VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION - The ethertype(s) specified
645 * for stripping affect the ethertype(s) specified for insertion and visa versa
646 * as well. If the VF tries to configure VLAN stripping via
647 * VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 with VIRTCHNL_VLAN_ETHERTYPE_8100 then
648 * that will be the ethertype for both stripping and insertion.
650 * VIRTCHNL_ETHERTYPE_MATCH_NOT_REQUIRED - The ethertype(s) specified for
651 * stripping do not affect the ethertype(s) specified for insertion and visa
654 enum virtchnl_vlan_ethertype_match
{
655 VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION
= 0,
656 VIRTCHNL_ETHERTYPE_MATCH_NOT_REQUIRED
= 1,
659 /* The PF populates these fields based on the supported VLAN offloads. If a
660 * field is VIRTCHNL_VLAN_UNSUPPORTED then it's not supported and the PF will
661 * reject any VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 or
662 * VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 messages using the unsupported fields.
664 * Also, a VF is only allowed to toggle its VLAN offload setting if the
665 * VIRTCHNL_VLAN_TOGGLE_ALLOWED bit is set.
667 * The VF driver needs to be aware of how the tags are stripped by hardware and
668 * inserted by the VF driver based on the level of offload support. The PF will
669 * populate these fields based on where the VLAN tags are expected to be
670 * offloaded via the VIRTHCNL_VLAN_TAG_LOCATION_* bits. The VF will need to
671 * interpret these fields. See the definition of the
672 * VIRTCHNL_VLAN_TAG_LOCATION_* bits above the virtchnl_vlan_support
675 struct virtchnl_vlan_offload_caps
{
676 struct virtchnl_vlan_supported_caps stripping_support
;
677 struct virtchnl_vlan_supported_caps insertion_support
;
683 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_vlan_offload_caps
);
685 /* VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS
686 * VF sends this message to determine its VLAN capabilities.
688 * PF will mark which capabilities it supports based on hardware support and
689 * current configuration. For example, if a port VLAN is configured the PF will
690 * not allow outer VLAN filtering, stripping, or insertion to be configured so
691 * it will block these features from the VF.
693 * The VF will need to cross reference its capabilities with the PFs
694 * capabilities in the response message from the PF to determine the VLAN
697 struct virtchnl_vlan_caps
{
698 struct virtchnl_vlan_filtering_caps filtering
;
699 struct virtchnl_vlan_offload_caps offloads
;
702 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_vlan_caps
);
704 struct virtchnl_vlan
{
705 u16 tci
; /* tci[15:13] = PCP and tci[11:0] = VID */
706 u16 tci_mask
; /* only valid if VIRTCHNL_VLAN_FILTER_MASK set in
709 u16 tpid
; /* 0x8100, 0x88a8, etc. and only type(s) set in
710 * filtering caps. Note that tpid here does not refer to
711 * VIRTCHNL_VLAN_ETHERTYPE_*, but it refers to the
712 * actual 2-byte VLAN TPID
717 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_vlan
);
719 struct virtchnl_vlan_filter
{
720 struct virtchnl_vlan inner
;
721 struct virtchnl_vlan outer
;
725 VIRTCHNL_CHECK_STRUCT_LEN(32, virtchnl_vlan_filter
);
727 /* VIRTCHNL_OP_ADD_VLAN_V2
728 * VIRTCHNL_OP_DEL_VLAN_V2
730 * VF sends these messages to add/del one or more VLAN tag filters for Rx
733 * The PF attempts to add the filters and returns status.
735 * The VF should only ever attempt to add/del virtchnl_vlan_filter(s) using the
736 * supported fields negotiated via VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS.
738 struct virtchnl_vlan_filter_list_v2
{
742 struct virtchnl_vlan_filter filters
[];
745 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_vlan_filter_list_v2
);
746 #define virtchnl_vlan_filter_list_v2_LEGACY_SIZEOF 40
748 /* VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2
749 * VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2
750 * VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2
751 * VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2
753 * VF sends this message to enable or disable VLAN stripping or insertion. It
754 * also needs to specify an ethertype. The VF knows which VLAN ethertypes are
755 * allowed and whether or not it's allowed to enable/disable the specific
756 * offload via the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS message. The VF needs to
757 * parse the virtchnl_vlan_caps.offloads fields to determine which offload
758 * messages are allowed.
760 * For example, if the PF populates the virtchnl_vlan_caps.offloads in the
761 * following manner the VF will be allowed to enable and/or disable 0x8100 inner
762 * VLAN insertion and/or stripping via the opcodes listed above. Inner in this
763 * case means the outer most or single VLAN from the VF's perspective. This is
764 * because no outer offloads are supported. See the comments above the
765 * virtchnl_vlan_supported_caps structure for more details.
767 * virtchnl_vlan_caps.offloads.stripping_support.inner =
768 * VIRTCHNL_VLAN_TOGGLE |
769 * VIRTCHNL_VLAN_ETHERTYPE_8100;
771 * virtchnl_vlan_caps.offloads.insertion_support.inner =
772 * VIRTCHNL_VLAN_TOGGLE |
773 * VIRTCHNL_VLAN_ETHERTYPE_8100;
775 * In order to enable inner (again note that in this case inner is the outer
776 * most or single VLAN from the VF's perspective) VLAN stripping for 0x8100
777 * VLANs, the VF would populate the virtchnl_vlan_setting structure in the
778 * following manner and send the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 message.
780 * virtchnl_vlan_setting.inner_ethertype_setting =
781 * VIRTCHNL_VLAN_ETHERTYPE_8100;
783 * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on
786 * The reason that VLAN TPID(s) are not being used for the
787 * outer_ethertype_setting and inner_ethertype_setting fields is because it's
788 * possible a device could support VLAN insertion and/or stripping offload on
789 * multiple ethertypes concurrently, so this method allows a VF to request
790 * multiple ethertypes in one message using the virtchnl_vlan_support
793 * For example, if the PF populates the virtchnl_vlan_caps.offloads in the
794 * following manner the VF will be allowed to enable 0x8100 and 0x88a8 outer
795 * VLAN insertion and stripping simultaneously. The
796 * virtchnl_vlan_caps.offloads.ethertype_match field will also have to be
797 * populated based on what the PF can support.
799 * virtchnl_vlan_caps.offloads.stripping_support.outer =
800 * VIRTCHNL_VLAN_TOGGLE |
801 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
802 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
803 * VIRTCHNL_VLAN_ETHERTYPE_AND;
805 * virtchnl_vlan_caps.offloads.insertion_support.outer =
806 * VIRTCHNL_VLAN_TOGGLE |
807 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
808 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
809 * VIRTCHNL_VLAN_ETHERTYPE_AND;
811 * In order to enable outer VLAN stripping for 0x8100 and 0x88a8 VLANs, the VF
812 * would populate the virthcnl_vlan_offload_structure in the following manner
813 * and send the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 message.
815 * virtchnl_vlan_setting.outer_ethertype_setting =
816 * VIRTHCNL_VLAN_ETHERTYPE_8100 |
817 * VIRTHCNL_VLAN_ETHERTYPE_88A8;
819 * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on
822 * There is also the case where a PF and the underlying hardware can support
823 * VLAN offloads on multiple ethertypes, but not concurrently. For example, if
824 * the PF populates the virtchnl_vlan_caps.offloads in the following manner the
825 * VF will be allowed to enable and/or disable 0x8100 XOR 0x88a8 outer VLAN
826 * offloads. The ethertypes must match for stripping and insertion.
828 * virtchnl_vlan_caps.offloads.stripping_support.outer =
829 * VIRTCHNL_VLAN_TOGGLE |
830 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
831 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
832 * VIRTCHNL_VLAN_ETHERTYPE_XOR;
834 * virtchnl_vlan_caps.offloads.insertion_support.outer =
835 * VIRTCHNL_VLAN_TOGGLE |
836 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
837 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
838 * VIRTCHNL_VLAN_ETHERTYPE_XOR;
840 * virtchnl_vlan_caps.offloads.ethertype_match =
841 * VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION;
843 * In order to enable outer VLAN stripping for 0x88a8 VLANs, the VF would
844 * populate the virtchnl_vlan_setting structure in the following manner and send
845 * the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2. Also, this will change the
846 * ethertype for VLAN insertion if it's enabled. So, for completeness, a
847 * VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 with the same ethertype should be sent.
849 * virtchnl_vlan_setting.outer_ethertype_setting = VIRTHCNL_VLAN_ETHERTYPE_88A8;
851 * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on
854 struct virtchnl_vlan_setting
{
855 u32 outer_ethertype_setting
;
856 u32 inner_ethertype_setting
;
861 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vlan_setting
);
863 /* VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE
864 * VF sends VSI id and flags.
865 * PF returns status code in retval.
866 * Note: we assume that broadcast accept mode is always enabled.
868 struct virtchnl_promisc_info
{
873 VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_promisc_info
);
875 #define FLAG_VF_UNICAST_PROMISC 0x00000001
876 #define FLAG_VF_MULTICAST_PROMISC 0x00000002
878 /* VIRTCHNL_OP_GET_STATS
879 * VF sends this message to request stats for the selected VSI. VF uses
880 * the virtchnl_queue_select struct to specify the VSI. The queue_id
881 * field is ignored by the PF.
883 * PF replies with struct eth_stats in an external buffer.
886 /* VIRTCHNL_OP_CONFIG_RSS_KEY
887 * VIRTCHNL_OP_CONFIG_RSS_LUT
888 * VF sends these messages to configure RSS. Only supported if both PF
889 * and VF drivers set the VIRTCHNL_VF_OFFLOAD_RSS_PF bit during
890 * configuration negotiation. If this is the case, then the RSS fields in
891 * the VF resource struct are valid.
892 * Both the key and LUT are initialized to 0 by the PF, meaning that
893 * RSS is effectively disabled until set up by the VF.
895 struct virtchnl_rss_key
{
898 u8 key
[]; /* RSS hash key, packed bytes */
901 VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_rss_key
);
902 #define virtchnl_rss_key_LEGACY_SIZEOF 6
904 struct virtchnl_rss_lut
{
907 u8 lut
[]; /* RSS lookup table */
910 VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_rss_lut
);
911 #define virtchnl_rss_lut_LEGACY_SIZEOF 6
913 /* VIRTCHNL_OP_GET_RSS_HENA_CAPS
914 * VIRTCHNL_OP_SET_RSS_HENA
915 * VF sends these messages to get and set the hash filter enable bits for RSS.
916 * By default, the PF sets these to all possible traffic types that the
917 * hardware supports. The VF can query this value if it wants to change the
918 * traffic types that are hashed by the hardware.
920 struct virtchnl_rss_hena
{
924 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_rss_hena
);
926 /* Type of RSS algorithm */
927 enum virtchnl_rss_algorithm
{
928 VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC
= 0,
929 VIRTCHNL_RSS_ALG_R_ASYMMETRIC
= 1,
930 VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC
= 2,
931 VIRTCHNL_RSS_ALG_XOR_SYMMETRIC
= 3,
934 /* VIRTCHNL_OP_CONFIG_RSS_HFUNC
935 * VF sends this message to configure the RSS hash function. Only supported
936 * if both PF and VF drivers set the VIRTCHNL_VF_OFFLOAD_RSS_PF bit during
937 * configuration negotiation.
938 * The hash function is initialized to VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC
941 struct virtchnl_rss_hfunc
{
943 u16 rss_algorithm
; /* enum virtchnl_rss_algorithm */
947 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_rss_hfunc
);
949 /* VIRTCHNL_OP_ENABLE_CHANNELS
950 * VIRTCHNL_OP_DISABLE_CHANNELS
951 * VF sends these messages to enable or disable channels based on
952 * the user specified queue count and queue offset for each traffic class.
953 * This struct encompasses all the information that the PF needs from
954 * VF to create a channel.
956 struct virtchnl_channel_info
{
957 u16 count
; /* number of queues in a channel */
958 u16 offset
; /* queues in a channel start from 'offset' */
963 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_channel_info
);
965 struct virtchnl_tc_info
{
968 struct virtchnl_channel_info list
[];
971 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_tc_info
);
972 #define virtchnl_tc_info_LEGACY_SIZEOF 24
974 /* VIRTCHNL_ADD_CLOUD_FILTER
975 * VIRTCHNL_DEL_CLOUD_FILTER
976 * VF sends these messages to add or delete a cloud filter based on the
977 * user specified match and action filters. These structures encompass
978 * all the information that the PF needs from the VF to add/delete a
982 struct virtchnl_l4_spec
{
983 u8 src_mac
[ETH_ALEN
];
984 u8 dst_mac
[ETH_ALEN
];
986 __be16 pad
; /* reserved for future use */
993 VIRTCHNL_CHECK_STRUCT_LEN(52, virtchnl_l4_spec
);
995 union virtchnl_flow_spec
{
996 struct virtchnl_l4_spec tcp_spec
;
997 u8 buffer
[128]; /* reserved for future use */
1000 VIRTCHNL_CHECK_UNION_LEN(128, virtchnl_flow_spec
);
1002 enum virtchnl_action
{
1004 VIRTCHNL_ACTION_DROP
= 0,
1005 VIRTCHNL_ACTION_TC_REDIRECT
,
1006 VIRTCHNL_ACTION_PASSTHRU
,
1007 VIRTCHNL_ACTION_QUEUE
,
1008 VIRTCHNL_ACTION_Q_REGION
,
1009 VIRTCHNL_ACTION_MARK
,
1010 VIRTCHNL_ACTION_COUNT
,
1013 enum virtchnl_flow_type
{
1015 VIRTCHNL_TCP_V4_FLOW
= 0,
1016 VIRTCHNL_TCP_V6_FLOW
,
1019 struct virtchnl_filter
{
1020 union virtchnl_flow_spec data
;
1021 union virtchnl_flow_spec mask
;
1023 /* see enum virtchnl_flow_type */
1026 /* see enum virtchnl_action */
1033 VIRTCHNL_CHECK_STRUCT_LEN(272, virtchnl_filter
);
1035 struct virtchnl_supported_rxdids
{
1036 u64 supported_rxdids
;
1039 /* VIRTCHNL_OP_EVENT
1040 * PF sends this message to inform the VF driver of events that may affect it.
1041 * No direct response is expected from the VF, though it may generate other
1042 * messages in response to this one.
1044 enum virtchnl_event_codes
{
1045 VIRTCHNL_EVENT_UNKNOWN
= 0,
1046 VIRTCHNL_EVENT_LINK_CHANGE
,
1047 VIRTCHNL_EVENT_RESET_IMPENDING
,
1048 VIRTCHNL_EVENT_PF_DRIVER_CLOSE
,
1051 #define PF_EVENT_SEVERITY_INFO 0
1052 #define PF_EVENT_SEVERITY_CERTAIN_DOOM 255
1054 struct virtchnl_pf_event
{
1055 /* see enum virtchnl_event_codes */
1058 /* If the PF driver does not support the new speed reporting
1059 * capabilities then use link_event else use link_event_adv to
1060 * get the speed and link information. The ability to understand
1061 * new speeds is indicated by setting the capability flag
1062 * VIRTCHNL_VF_CAP_ADV_LINK_SPEED in vf_cap_flags parameter
1063 * in virtchnl_vf_resource struct and can be used to determine
1064 * which link event struct to use below.
1067 enum virtchnl_link_speed link_speed
;
1072 /* link_speed provided in Mbps */
1082 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_pf_event
);
1084 /* used to specify if a ceq_idx or aeq_idx is invalid */
1085 #define VIRTCHNL_RDMA_INVALID_QUEUE_IDX 0xFFFF
1086 /* VIRTCHNL_OP_CONFIG_RDMA_IRQ_MAP
1087 * VF uses this message to request PF to map RDMA vectors to RDMA queues.
1088 * The request for this originates from the VF RDMA driver through
1089 * a client interface between VF LAN and VF RDMA driver.
1090 * A vector could have an AEQ and CEQ attached to it although
1091 * there is a single AEQ per VF RDMA instance in which case
1092 * most vectors will have an VIRTCHNL_RDMA_INVALID_QUEUE_IDX for aeq and valid
1093 * idx for ceqs There will never be a case where there will be multiple CEQs
1094 * attached to a single vector.
1095 * PF configures interrupt mapping and returns status.
1098 struct virtchnl_rdma_qv_info
{
1099 u32 v_idx
; /* msix_vector */
1100 u16 ceq_idx
; /* set to VIRTCHNL_RDMA_INVALID_QUEUE_IDX if invalid */
1101 u16 aeq_idx
; /* set to VIRTCHNL_RDMA_INVALID_QUEUE_IDX if invalid */
1106 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_rdma_qv_info
);
1108 struct virtchnl_rdma_qvlist_info
{
1110 struct virtchnl_rdma_qv_info qv_info
[];
1113 VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_rdma_qvlist_info
);
1114 #define virtchnl_rdma_qvlist_info_LEGACY_SIZEOF 16
1116 /* VF reset states - these are written into the RSTAT register:
1117 * VFGEN_RSTAT on the VF
1118 * When the PF initiates a reset, it writes 0
1119 * When the reset is complete, it writes 1
1120 * When the PF detects that the VF has recovered, it writes 2
1121 * VF checks this register periodically to determine if a reset has occurred,
1122 * then polls it to know when the reset is complete.
1123 * If either the PF or VF reads the register while the hardware
1124 * is in a reset state, it will return DEADBEEF, which, when masked
1127 enum virtchnl_vfr_states
{
1128 VIRTCHNL_VFR_INPROGRESS
= 0,
1129 VIRTCHNL_VFR_COMPLETED
,
1130 VIRTCHNL_VFR_VFACTIVE
,
1133 #define VIRTCHNL_MAX_NUM_PROTO_HDRS 32
1134 #define VIRTCHNL_MAX_SIZE_RAW_PACKET 1024
1135 #define PROTO_HDR_SHIFT 5
1136 #define PROTO_HDR_FIELD_START(proto_hdr_type) ((proto_hdr_type) << PROTO_HDR_SHIFT)
1137 #define PROTO_HDR_FIELD_MASK ((1UL << PROTO_HDR_SHIFT) - 1)
1139 /* VF use these macros to configure each protocol header.
1140 * Specify which protocol headers and protocol header fields base on
1141 * virtchnl_proto_hdr_type and virtchnl_proto_hdr_field.
1142 * @param hdr: a struct of virtchnl_proto_hdr
1143 * @param hdr_type: ETH/IPV4/TCP, etc
1144 * @param field: SRC/DST/TEID/SPI, etc
1146 #define VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, field) \
1147 ((hdr)->field_selector |= BIT((field) & PROTO_HDR_FIELD_MASK))
1148 #define VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, field) \
1149 ((hdr)->field_selector &= ~BIT((field) & PROTO_HDR_FIELD_MASK))
1150 #define VIRTCHNL_TEST_PROTO_HDR_FIELD(hdr, val) \
1151 ((hdr)->field_selector & BIT((val) & PROTO_HDR_FIELD_MASK))
1152 #define VIRTCHNL_GET_PROTO_HDR_FIELD(hdr) ((hdr)->field_selector)
1154 #define VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \
1155 (VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, \
1156 VIRTCHNL_PROTO_HDR_ ## hdr_type ## _ ## field))
1157 #define VIRTCHNL_DEL_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \
1158 (VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, \
1159 VIRTCHNL_PROTO_HDR_ ## hdr_type ## _ ## field))
1161 #define VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, hdr_type) \
1162 ((hdr)->type = VIRTCHNL_PROTO_HDR_ ## hdr_type)
1163 #define VIRTCHNL_GET_PROTO_HDR_TYPE(hdr) \
1164 (((hdr)->type) >> PROTO_HDR_SHIFT)
1165 #define VIRTCHNL_TEST_PROTO_HDR_TYPE(hdr, val) \
1166 ((hdr)->type == ((s32)((val) >> PROTO_HDR_SHIFT)))
1167 #define VIRTCHNL_TEST_PROTO_HDR(hdr, val) \
1168 (VIRTCHNL_TEST_PROTO_HDR_TYPE((hdr), (val)) && \
1169 VIRTCHNL_TEST_PROTO_HDR_FIELD((hdr), (val)))
1171 /* Protocol header type within a packet segment. A segment consists of one or
1172 * more protocol headers that make up a logical group of protocol headers. Each
1173 * logical group of protocol headers encapsulates or is encapsulated using/by
1174 * tunneling or encapsulation protocols for network virtualization.
1176 enum virtchnl_proto_hdr_type
{
1177 VIRTCHNL_PROTO_HDR_NONE
,
1178 VIRTCHNL_PROTO_HDR_ETH
,
1179 VIRTCHNL_PROTO_HDR_S_VLAN
,
1180 VIRTCHNL_PROTO_HDR_C_VLAN
,
1181 VIRTCHNL_PROTO_HDR_IPV4
,
1182 VIRTCHNL_PROTO_HDR_IPV6
,
1183 VIRTCHNL_PROTO_HDR_TCP
,
1184 VIRTCHNL_PROTO_HDR_UDP
,
1185 VIRTCHNL_PROTO_HDR_SCTP
,
1186 VIRTCHNL_PROTO_HDR_GTPU_IP
,
1187 VIRTCHNL_PROTO_HDR_GTPU_EH
,
1188 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN
,
1189 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP
,
1190 VIRTCHNL_PROTO_HDR_PPPOE
,
1191 VIRTCHNL_PROTO_HDR_L2TPV3
,
1192 VIRTCHNL_PROTO_HDR_ESP
,
1193 VIRTCHNL_PROTO_HDR_AH
,
1194 VIRTCHNL_PROTO_HDR_PFCP
,
1197 /* Protocol header field within a protocol header. */
1198 enum virtchnl_proto_hdr_field
{
1200 VIRTCHNL_PROTO_HDR_ETH_SRC
=
1201 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ETH
),
1202 VIRTCHNL_PROTO_HDR_ETH_DST
,
1203 VIRTCHNL_PROTO_HDR_ETH_ETHERTYPE
,
1205 VIRTCHNL_PROTO_HDR_S_VLAN_ID
=
1206 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_S_VLAN
),
1208 VIRTCHNL_PROTO_HDR_C_VLAN_ID
=
1209 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_C_VLAN
),
1211 VIRTCHNL_PROTO_HDR_IPV4_SRC
=
1212 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV4
),
1213 VIRTCHNL_PROTO_HDR_IPV4_DST
,
1214 VIRTCHNL_PROTO_HDR_IPV4_DSCP
,
1215 VIRTCHNL_PROTO_HDR_IPV4_TTL
,
1216 VIRTCHNL_PROTO_HDR_IPV4_PROT
,
1218 VIRTCHNL_PROTO_HDR_IPV6_SRC
=
1219 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV6
),
1220 VIRTCHNL_PROTO_HDR_IPV6_DST
,
1221 VIRTCHNL_PROTO_HDR_IPV6_TC
,
1222 VIRTCHNL_PROTO_HDR_IPV6_HOP_LIMIT
,
1223 VIRTCHNL_PROTO_HDR_IPV6_PROT
,
1225 VIRTCHNL_PROTO_HDR_TCP_SRC_PORT
=
1226 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_TCP
),
1227 VIRTCHNL_PROTO_HDR_TCP_DST_PORT
,
1229 VIRTCHNL_PROTO_HDR_UDP_SRC_PORT
=
1230 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_UDP
),
1231 VIRTCHNL_PROTO_HDR_UDP_DST_PORT
,
1233 VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT
=
1234 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_SCTP
),
1235 VIRTCHNL_PROTO_HDR_SCTP_DST_PORT
,
1237 VIRTCHNL_PROTO_HDR_GTPU_IP_TEID
=
1238 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_IP
),
1240 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU
=
1241 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH
),
1242 VIRTCHNL_PROTO_HDR_GTPU_EH_QFI
,
1244 VIRTCHNL_PROTO_HDR_PPPOE_SESS_ID
=
1245 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_PPPOE
),
1247 VIRTCHNL_PROTO_HDR_L2TPV3_SESS_ID
=
1248 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_L2TPV3
),
1250 VIRTCHNL_PROTO_HDR_ESP_SPI
=
1251 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ESP
),
1253 VIRTCHNL_PROTO_HDR_AH_SPI
=
1254 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_AH
),
1256 VIRTCHNL_PROTO_HDR_PFCP_S_FIELD
=
1257 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_PFCP
),
1258 VIRTCHNL_PROTO_HDR_PFCP_SEID
,
1261 struct virtchnl_proto_hdr
{
1262 /* see enum virtchnl_proto_hdr_type */
1264 u32 field_selector
; /* a bit mask to select field for header type */
1267 * binary buffer in network order for specific header type.
1268 * For example, if type = VIRTCHNL_PROTO_HDR_IPV4, a IPv4
1269 * header is expected to be copied into the buffer.
1273 VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_proto_hdr
);
1275 struct virtchnl_proto_hdrs
{
1279 * specify where protocol header start from.
1280 * must be 0 when sending a raw packet request.
1281 * 0 - from the outer layer
1282 * 1 - from the first inner layer
1283 * 2 - from the second inner layer
1286 int count
; /* the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS */
1288 struct virtchnl_proto_hdr
1289 proto_hdr
[VIRTCHNL_MAX_NUM_PROTO_HDRS
];
1292 u8 spec
[VIRTCHNL_MAX_SIZE_RAW_PACKET
];
1293 u8 mask
[VIRTCHNL_MAX_SIZE_RAW_PACKET
];
1298 VIRTCHNL_CHECK_STRUCT_LEN(2312, virtchnl_proto_hdrs
);
1300 struct virtchnl_rss_cfg
{
1301 struct virtchnl_proto_hdrs proto_hdrs
; /* protocol headers */
1303 /* see enum virtchnl_rss_algorithm; rss algorithm type */
1305 u8 reserved
[128]; /* reserve for future */
1308 VIRTCHNL_CHECK_STRUCT_LEN(2444, virtchnl_rss_cfg
);
1310 /* action configuration for FDIR */
1311 struct virtchnl_filter_action
{
1312 /* see enum virtchnl_action type */
1315 /* used for queue and qgroup action */
1320 /* used for count action */
1322 /* share counter ID with other flow rules */
1324 u32 id
; /* counter ID */
1326 /* used for mark action */
1332 VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_filter_action
);
1334 #define VIRTCHNL_MAX_NUM_ACTIONS 8
1336 struct virtchnl_filter_action_set
{
1337 /* action number must be less then VIRTCHNL_MAX_NUM_ACTIONS */
1339 struct virtchnl_filter_action actions
[VIRTCHNL_MAX_NUM_ACTIONS
];
1342 VIRTCHNL_CHECK_STRUCT_LEN(292, virtchnl_filter_action_set
);
1344 /* pattern and action for FDIR rule */
1345 struct virtchnl_fdir_rule
{
1346 struct virtchnl_proto_hdrs proto_hdrs
;
1347 struct virtchnl_filter_action_set action_set
;
1350 VIRTCHNL_CHECK_STRUCT_LEN(2604, virtchnl_fdir_rule
);
1352 /* Status returned to VF after VF requests FDIR commands
1353 * VIRTCHNL_FDIR_SUCCESS
1354 * VF FDIR related request is successfully done by PF
1355 * The request can be OP_ADD/DEL/QUERY_FDIR_FILTER.
1357 * VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE
1358 * OP_ADD_FDIR_FILTER request is failed due to no Hardware resource.
1360 * VIRTCHNL_FDIR_FAILURE_RULE_EXIST
1361 * OP_ADD_FDIR_FILTER request is failed due to the rule is already existed.
1363 * VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT
1364 * OP_ADD_FDIR_FILTER request is failed due to conflict with existing rule.
1366 * VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST
1367 * OP_DEL_FDIR_FILTER request is failed due to this rule doesn't exist.
1369 * VIRTCHNL_FDIR_FAILURE_RULE_INVALID
1370 * OP_ADD_FDIR_FILTER request is failed due to parameters validation
1371 * or HW doesn't support.
1373 * VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT
1374 * OP_ADD/DEL_FDIR_FILTER request is failed due to timing out
1377 * VIRTCHNL_FDIR_FAILURE_QUERY_INVALID
1378 * OP_QUERY_FDIR_FILTER request is failed due to parameters validation,
1379 * for example, VF query counter of a rule who has no counter action.
1381 enum virtchnl_fdir_prgm_status
{
1382 VIRTCHNL_FDIR_SUCCESS
= 0,
1383 VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE
,
1384 VIRTCHNL_FDIR_FAILURE_RULE_EXIST
,
1385 VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT
,
1386 VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST
,
1387 VIRTCHNL_FDIR_FAILURE_RULE_INVALID
,
1388 VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT
,
1389 VIRTCHNL_FDIR_FAILURE_QUERY_INVALID
,
1392 /* VIRTCHNL_OP_ADD_FDIR_FILTER
1393 * VF sends this request to PF by filling out vsi_id,
1394 * validate_only and rule_cfg. PF will return flow_id
1395 * if the request is successfully done and return add_status to VF.
1397 struct virtchnl_fdir_add
{
1398 u16 vsi_id
; /* INPUT */
1400 * 1 for validating a fdir rule, 0 for creating a fdir rule.
1401 * Validate and create share one ops: VIRTCHNL_OP_ADD_FDIR_FILTER.
1403 u16 validate_only
; /* INPUT */
1404 u32 flow_id
; /* OUTPUT */
1405 struct virtchnl_fdir_rule rule_cfg
; /* INPUT */
1407 /* see enum virtchnl_fdir_prgm_status; OUTPUT */
1411 VIRTCHNL_CHECK_STRUCT_LEN(2616, virtchnl_fdir_add
);
1413 /* VIRTCHNL_OP_DEL_FDIR_FILTER
1414 * VF sends this request to PF by filling out vsi_id
1415 * and flow_id. PF will return del_status to VF.
1417 struct virtchnl_fdir_del
{
1418 u16 vsi_id
; /* INPUT */
1420 u32 flow_id
; /* INPUT */
1422 /* see enum virtchnl_fdir_prgm_status; OUTPUT */
1426 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del
);
1428 struct virtchnl_shaper_bw
{
1434 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_shaper_bw
);
1436 /* VIRTCHNL_OP_GET_QOS_CAPS
1437 * VF sends this message to get its QoS Caps, such as
1438 * TC number, Arbiter and Bandwidth.
1440 struct virtchnl_qos_cap_elem
{
1443 #define VIRTCHNL_ABITER_STRICT 0
1444 #define VIRTCHNL_ABITER_ETS 2
1446 #define VIRTCHNL_STRICT_WEIGHT 1
1448 enum virtchnl_bw_limit_type type
;
1450 struct virtchnl_shaper_bw shaper
;
1455 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_qos_cap_elem
);
1457 struct virtchnl_qos_cap_list
{
1460 struct virtchnl_qos_cap_elem cap
[];
1463 VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_qos_cap_list
);
1464 #define virtchnl_qos_cap_list_LEGACY_SIZEOF 44
1466 /* VIRTCHNL_OP_CONFIG_QUEUE_BW */
1467 struct virtchnl_queue_bw
{
1471 struct virtchnl_shaper_bw shaper
;
1474 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_bw
);
1476 struct virtchnl_queues_bw_cfg
{
1479 struct virtchnl_queue_bw cfg
[];
1482 VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_queues_bw_cfg
);
1483 #define virtchnl_queues_bw_cfg_LEGACY_SIZEOF 16
1485 enum virtchnl_queue_type
{
1486 VIRTCHNL_QUEUE_TYPE_TX
= 0,
1487 VIRTCHNL_QUEUE_TYPE_RX
= 1,
1490 /* structure to specify a chunk of contiguous queues */
1491 struct virtchnl_queue_chunk
{
1492 /* see enum virtchnl_queue_type */
1498 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_queue_chunk
);
1500 struct virtchnl_quanta_cfg
{
1503 struct virtchnl_queue_chunk queue_select
;
1506 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_quanta_cfg
);
1508 #define __vss_byone(p, member, count, old) \
1509 (struct_size(p, member, count) + (old - 1 - struct_size(p, member, 0)))
1511 #define __vss_byelem(p, member, count, old) \
1512 (struct_size(p, member, count - 1) + (old - struct_size(p, member, 0)))
1514 #define __vss_full(p, member, count, old) \
1515 (struct_size(p, member, count) + (old - struct_size(p, member, 0)))
1517 #define __vss(type, func, p, member, count) \
1518 struct type: func(p, member, count, type##_LEGACY_SIZEOF)
1520 #define virtchnl_struct_size(p, m, c) \
1522 __vss(virtchnl_vf_resource, __vss_full, p, m, c), \
1523 __vss(virtchnl_vsi_queue_config_info, __vss_full, p, m, c), \
1524 __vss(virtchnl_irq_map_info, __vss_full, p, m, c), \
1525 __vss(virtchnl_ether_addr_list, __vss_full, p, m, c), \
1526 __vss(virtchnl_vlan_filter_list, __vss_full, p, m, c), \
1527 __vss(virtchnl_vlan_filter_list_v2, __vss_byelem, p, m, c), \
1528 __vss(virtchnl_tc_info, __vss_byelem, p, m, c), \
1529 __vss(virtchnl_rdma_qvlist_info, __vss_byelem, p, m, c), \
1530 __vss(virtchnl_qos_cap_list, __vss_byelem, p, m, c), \
1531 __vss(virtchnl_queues_bw_cfg, __vss_byelem, p, m, c), \
1532 __vss(virtchnl_rss_key, __vss_byone, p, m, c), \
1533 __vss(virtchnl_rss_lut, __vss_byone, p, m, c))
1536 * virtchnl_vc_validate_vf_msg
1537 * @ver: Virtchnl version info
1538 * @v_opcode: Opcode for the message
1539 * @msg: pointer to the msg buffer
1540 * @msglen: msg length
1542 * validate msg format against struct for each opcode
1545 virtchnl_vc_validate_vf_msg(struct virtchnl_version_info
*ver
, u32 v_opcode
,
1546 u8
*msg
, u16 msglen
)
1548 bool err_msg_format
= false;
1551 /* Validate message length. */
1553 case VIRTCHNL_OP_VERSION
:
1554 valid_len
= sizeof(struct virtchnl_version_info
);
1556 case VIRTCHNL_OP_RESET_VF
:
1558 case VIRTCHNL_OP_GET_VF_RESOURCES
:
1560 valid_len
= sizeof(u32
);
1562 case VIRTCHNL_OP_CONFIG_TX_QUEUE
:
1563 valid_len
= sizeof(struct virtchnl_txq_info
);
1565 case VIRTCHNL_OP_CONFIG_RX_QUEUE
:
1566 valid_len
= sizeof(struct virtchnl_rxq_info
);
1568 case VIRTCHNL_OP_CONFIG_VSI_QUEUES
:
1569 valid_len
= virtchnl_vsi_queue_config_info_LEGACY_SIZEOF
;
1570 if (msglen
>= valid_len
) {
1571 struct virtchnl_vsi_queue_config_info
*vqc
=
1572 (struct virtchnl_vsi_queue_config_info
*)msg
;
1573 valid_len
= virtchnl_struct_size(vqc
, qpair
,
1574 vqc
->num_queue_pairs
);
1575 if (vqc
->num_queue_pairs
== 0)
1576 err_msg_format
= true;
1579 case VIRTCHNL_OP_CONFIG_IRQ_MAP
:
1580 valid_len
= virtchnl_irq_map_info_LEGACY_SIZEOF
;
1581 if (msglen
>= valid_len
) {
1582 struct virtchnl_irq_map_info
*vimi
=
1583 (struct virtchnl_irq_map_info
*)msg
;
1584 valid_len
= virtchnl_struct_size(vimi
, vecmap
,
1586 if (vimi
->num_vectors
== 0)
1587 err_msg_format
= true;
1590 case VIRTCHNL_OP_ENABLE_QUEUES
:
1591 case VIRTCHNL_OP_DISABLE_QUEUES
:
1592 valid_len
= sizeof(struct virtchnl_queue_select
);
1594 case VIRTCHNL_OP_ADD_ETH_ADDR
:
1595 case VIRTCHNL_OP_DEL_ETH_ADDR
:
1596 valid_len
= virtchnl_ether_addr_list_LEGACY_SIZEOF
;
1597 if (msglen
>= valid_len
) {
1598 struct virtchnl_ether_addr_list
*veal
=
1599 (struct virtchnl_ether_addr_list
*)msg
;
1600 valid_len
= virtchnl_struct_size(veal
, list
,
1601 veal
->num_elements
);
1602 if (veal
->num_elements
== 0)
1603 err_msg_format
= true;
1606 case VIRTCHNL_OP_ADD_VLAN
:
1607 case VIRTCHNL_OP_DEL_VLAN
:
1608 valid_len
= virtchnl_vlan_filter_list_LEGACY_SIZEOF
;
1609 if (msglen
>= valid_len
) {
1610 struct virtchnl_vlan_filter_list
*vfl
=
1611 (struct virtchnl_vlan_filter_list
*)msg
;
1612 valid_len
= virtchnl_struct_size(vfl
, vlan_id
,
1614 if (vfl
->num_elements
== 0)
1615 err_msg_format
= true;
1618 case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE
:
1619 valid_len
= sizeof(struct virtchnl_promisc_info
);
1621 case VIRTCHNL_OP_GET_STATS
:
1622 valid_len
= sizeof(struct virtchnl_queue_select
);
1624 case VIRTCHNL_OP_RDMA
:
1625 /* These messages are opaque to us and will be validated in
1626 * the RDMA client code. We just need to check for nonzero
1627 * length. The firmware will enforce max length restrictions.
1632 err_msg_format
= true;
1634 case VIRTCHNL_OP_RELEASE_RDMA_IRQ_MAP
:
1636 case VIRTCHNL_OP_CONFIG_RDMA_IRQ_MAP
:
1637 valid_len
= virtchnl_rdma_qvlist_info_LEGACY_SIZEOF
;
1638 if (msglen
>= valid_len
) {
1639 struct virtchnl_rdma_qvlist_info
*qv
=
1640 (struct virtchnl_rdma_qvlist_info
*)msg
;
1642 valid_len
= virtchnl_struct_size(qv
, qv_info
,
1646 case VIRTCHNL_OP_CONFIG_RSS_KEY
:
1647 valid_len
= virtchnl_rss_key_LEGACY_SIZEOF
;
1648 if (msglen
>= valid_len
) {
1649 struct virtchnl_rss_key
*vrk
=
1650 (struct virtchnl_rss_key
*)msg
;
1651 valid_len
= virtchnl_struct_size(vrk
, key
,
1655 case VIRTCHNL_OP_CONFIG_RSS_LUT
:
1656 valid_len
= virtchnl_rss_lut_LEGACY_SIZEOF
;
1657 if (msglen
>= valid_len
) {
1658 struct virtchnl_rss_lut
*vrl
=
1659 (struct virtchnl_rss_lut
*)msg
;
1660 valid_len
= virtchnl_struct_size(vrl
, lut
,
1664 case VIRTCHNL_OP_CONFIG_RSS_HFUNC
:
1665 valid_len
= sizeof(struct virtchnl_rss_hfunc
);
1667 case VIRTCHNL_OP_GET_RSS_HENA_CAPS
:
1669 case VIRTCHNL_OP_SET_RSS_HENA
:
1670 valid_len
= sizeof(struct virtchnl_rss_hena
);
1672 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING
:
1673 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING
:
1675 case VIRTCHNL_OP_REQUEST_QUEUES
:
1676 valid_len
= sizeof(struct virtchnl_vf_res_request
);
1678 case VIRTCHNL_OP_ENABLE_CHANNELS
:
1679 valid_len
= virtchnl_tc_info_LEGACY_SIZEOF
;
1680 if (msglen
>= valid_len
) {
1681 struct virtchnl_tc_info
*vti
=
1682 (struct virtchnl_tc_info
*)msg
;
1683 valid_len
= virtchnl_struct_size(vti
, list
,
1685 if (vti
->num_tc
== 0)
1686 err_msg_format
= true;
1689 case VIRTCHNL_OP_DISABLE_CHANNELS
:
1691 case VIRTCHNL_OP_ADD_CLOUD_FILTER
:
1692 case VIRTCHNL_OP_DEL_CLOUD_FILTER
:
1693 valid_len
= sizeof(struct virtchnl_filter
);
1695 case VIRTCHNL_OP_GET_SUPPORTED_RXDIDS
:
1697 case VIRTCHNL_OP_ADD_RSS_CFG
:
1698 case VIRTCHNL_OP_DEL_RSS_CFG
:
1699 valid_len
= sizeof(struct virtchnl_rss_cfg
);
1701 case VIRTCHNL_OP_ADD_FDIR_FILTER
:
1702 valid_len
= sizeof(struct virtchnl_fdir_add
);
1704 case VIRTCHNL_OP_DEL_FDIR_FILTER
:
1705 valid_len
= sizeof(struct virtchnl_fdir_del
);
1707 case VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS
:
1709 case VIRTCHNL_OP_ADD_VLAN_V2
:
1710 case VIRTCHNL_OP_DEL_VLAN_V2
:
1711 valid_len
= virtchnl_vlan_filter_list_v2_LEGACY_SIZEOF
;
1712 if (msglen
>= valid_len
) {
1713 struct virtchnl_vlan_filter_list_v2
*vfl
=
1714 (struct virtchnl_vlan_filter_list_v2
*)msg
;
1716 valid_len
= virtchnl_struct_size(vfl
, filters
,
1719 if (vfl
->num_elements
== 0) {
1720 err_msg_format
= true;
1725 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2
:
1726 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2
:
1727 case VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2
:
1728 case VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2
:
1729 valid_len
= sizeof(struct virtchnl_vlan_setting
);
1731 case VIRTCHNL_OP_GET_QOS_CAPS
:
1733 case VIRTCHNL_OP_CONFIG_QUEUE_BW
:
1734 valid_len
= virtchnl_queues_bw_cfg_LEGACY_SIZEOF
;
1735 if (msglen
>= valid_len
) {
1736 struct virtchnl_queues_bw_cfg
*q_bw
=
1737 (struct virtchnl_queues_bw_cfg
*)msg
;
1739 valid_len
= virtchnl_struct_size(q_bw
, cfg
,
1741 if (q_bw
->num_queues
== 0) {
1742 err_msg_format
= true;
1747 case VIRTCHNL_OP_CONFIG_QUANTA
:
1748 valid_len
= sizeof(struct virtchnl_quanta_cfg
);
1749 if (msglen
>= valid_len
) {
1750 struct virtchnl_quanta_cfg
*q_quanta
=
1751 (struct virtchnl_quanta_cfg
*)msg
;
1753 if (q_quanta
->quanta_size
== 0 ||
1754 q_quanta
->queue_select
.num_queues
== 0) {
1755 err_msg_format
= true;
1760 /* These are always errors coming from the VF. */
1761 case VIRTCHNL_OP_EVENT
:
1762 case VIRTCHNL_OP_UNKNOWN
:
1764 return VIRTCHNL_STATUS_ERR_PARAM
;
1766 /* few more checks */
1767 if (err_msg_format
|| valid_len
!= msglen
)
1768 return VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH
;
1772 #endif /* _VIRTCHNL_H_ */