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 /* END GENERIC DEFINES */
94 /* Opcodes for VF-PF communication. These are placed in the v_opcode field
95 * of the virtchnl_msg structure.
98 /* The PF sends status change events to VFs using
99 * the VIRTCHNL_OP_EVENT opcode.
100 * VFs send requests to the PF using the other ops.
101 * Use of "advanced opcode" features must be negotiated as part of capabilities
102 * exchange and are not considered part of base mode feature set.
104 VIRTCHNL_OP_UNKNOWN = 0,
105 VIRTCHNL_OP_VERSION = 1, /* must ALWAYS be 1 */
106 VIRTCHNL_OP_RESET_VF = 2,
107 VIRTCHNL_OP_GET_VF_RESOURCES = 3,
108 VIRTCHNL_OP_CONFIG_TX_QUEUE = 4,
109 VIRTCHNL_OP_CONFIG_RX_QUEUE = 5,
110 VIRTCHNL_OP_CONFIG_VSI_QUEUES = 6,
111 VIRTCHNL_OP_CONFIG_IRQ_MAP = 7,
112 VIRTCHNL_OP_ENABLE_QUEUES = 8,
113 VIRTCHNL_OP_DISABLE_QUEUES = 9,
114 VIRTCHNL_OP_ADD_ETH_ADDR = 10,
115 VIRTCHNL_OP_DEL_ETH_ADDR = 11,
116 VIRTCHNL_OP_ADD_VLAN = 12,
117 VIRTCHNL_OP_DEL_VLAN = 13,
118 VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE = 14,
119 VIRTCHNL_OP_GET_STATS = 15,
120 VIRTCHNL_OP_RSVD = 16,
121 VIRTCHNL_OP_EVENT = 17, /* must ALWAYS be 17 */
122 VIRTCHNL_OP_CONFIG_RSS_HFUNC = 18,
123 /* opcode 19 is reserved */
124 VIRTCHNL_OP_IWARP = 20, /* advanced opcode */
125 VIRTCHNL_OP_RDMA = VIRTCHNL_OP_IWARP,
126 VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP = 21, /* advanced opcode */
127 VIRTCHNL_OP_CONFIG_RDMA_IRQ_MAP = VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP,
128 VIRTCHNL_OP_RELEASE_IWARP_IRQ_MAP = 22, /* advanced opcode */
129 VIRTCHNL_OP_RELEASE_RDMA_IRQ_MAP = VIRTCHNL_OP_RELEASE_IWARP_IRQ_MAP,
130 VIRTCHNL_OP_CONFIG_RSS_KEY = 23,
131 VIRTCHNL_OP_CONFIG_RSS_LUT = 24,
132 VIRTCHNL_OP_GET_RSS_HENA_CAPS = 25,
133 VIRTCHNL_OP_SET_RSS_HENA = 26,
134 VIRTCHNL_OP_ENABLE_VLAN_STRIPPING = 27,
135 VIRTCHNL_OP_DISABLE_VLAN_STRIPPING = 28,
136 VIRTCHNL_OP_REQUEST_QUEUES = 29,
137 VIRTCHNL_OP_ENABLE_CHANNELS = 30,
138 VIRTCHNL_OP_DISABLE_CHANNELS = 31,
139 VIRTCHNL_OP_ADD_CLOUD_FILTER = 32,
140 VIRTCHNL_OP_DEL_CLOUD_FILTER = 33,
141 /* opcode 34 - 43 are reserved */
142 VIRTCHNL_OP_GET_SUPPORTED_RXDIDS = 44,
143 VIRTCHNL_OP_ADD_RSS_CFG = 45,
144 VIRTCHNL_OP_DEL_RSS_CFG = 46,
145 VIRTCHNL_OP_ADD_FDIR_FILTER = 47,
146 VIRTCHNL_OP_DEL_FDIR_FILTER = 48,
147 VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS = 51,
148 VIRTCHNL_OP_ADD_VLAN_V2 = 52,
149 VIRTCHNL_OP_DEL_VLAN_V2 = 53,
150 VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 = 54,
151 VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 = 55,
152 VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 = 56,
153 VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2 = 57,
157 /* These macros are used to generate compilation errors if a structure/union
158 * is not exactly the correct length. It gives a divide by zero error if the
159 * structure/union is not of the correct size, otherwise it creates an enum
160 * that is never used.
162 #define VIRTCHNL_CHECK_STRUCT_LEN(n, X) enum virtchnl_static_assert_enum_##X \
163 { virtchnl_static_assert_##X = (n)/((sizeof(struct X) == (n)) ? 1 : 0) }
164 #define VIRTCHNL_CHECK_UNION_LEN(n, X) enum virtchnl_static_asset_enum_##X \
165 { virtchnl_static_assert_##X = (n)/((sizeof(union X) == (n)) ? 1 : 0) }
167 /* Message descriptions and data structures. */
169 /* VIRTCHNL_OP_VERSION
170 * VF posts its version number to the PF. PF responds with its version number
171 * in the same format, along with a return code.
172 * Reply from PF has its major/minor versions also in param0 and param1.
173 * If there is a major version mismatch, then the VF cannot operate.
174 * If there is a minor version mismatch, then the VF can operate but should
175 * add a warning to the system log.
177 * This enum element MUST always be specified as == 1, regardless of other
178 * changes in the API. The PF must always respond to this message without
179 * error regardless of version mismatch.
181 #define VIRTCHNL_VERSION_MAJOR 1
182 #define VIRTCHNL_VERSION_MINOR 1
183 #define VIRTCHNL_VERSION_MINOR_NO_VF_CAPS 0
185 struct virtchnl_version_info {
190 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_version_info);
192 #define VF_IS_V10(_v) (((_v)->major == 1) && ((_v)->minor == 0))
193 #define VF_IS_V11(_ver) (((_ver)->major == 1) && ((_ver)->minor == 1))
195 /* VIRTCHNL_OP_RESET_VF
196 * VF sends this request to PF with no parameters
197 * PF does NOT respond! VF driver must delay then poll VFGEN_RSTAT register
198 * until reset completion is indicated. The admin queue must be reinitialized
199 * after this operation.
201 * When reset is complete, PF must ensure that all queues in all VSIs associated
202 * with the VF are stopped, all queue configurations in the HMC are set to 0,
203 * and all MAC and VLAN filters (except the default MAC address) on all VSIs
207 /* VSI types that use VIRTCHNL interface for VF-PF communication. VSI_SRIOV
208 * vsi_type should always be 6 for backward compatibility. Add other fields
211 enum virtchnl_vsi_type {
212 VIRTCHNL_VSI_TYPE_INVALID = 0,
213 VIRTCHNL_VSI_SRIOV = 6,
216 /* VIRTCHNL_OP_GET_VF_RESOURCES
217 * Version 1.0 VF sends this request to PF with no parameters
218 * Version 1.1 VF sends this request to PF with u32 bitmap of its capabilities
219 * PF responds with an indirect message containing
220 * virtchnl_vf_resource and one or more
221 * virtchnl_vsi_resource structures.
224 struct virtchnl_vsi_resource {
228 /* see enum virtchnl_vsi_type */
231 u8 default_mac_addr[ETH_ALEN];
234 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
236 /* VF capability flags
237 * VIRTCHNL_VF_OFFLOAD_L2 flag is inclusive of base mode L2 offloads including
238 * TX/RX Checksum offloading and TSO for non-tunnelled packets.
240 #define VIRTCHNL_VF_OFFLOAD_L2 BIT(0)
241 #define VIRTCHNL_VF_OFFLOAD_RDMA BIT(1)
242 #define VIRTCHNL_VF_CAP_RDMA VIRTCHNL_VF_OFFLOAD_RDMA
243 #define VIRTCHNL_VF_OFFLOAD_RSS_AQ BIT(3)
244 #define VIRTCHNL_VF_OFFLOAD_RSS_REG BIT(4)
245 #define VIRTCHNL_VF_OFFLOAD_WB_ON_ITR BIT(5)
246 #define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES BIT(6)
247 /* used to negotiate communicating link speeds in Mbps */
248 #define VIRTCHNL_VF_CAP_ADV_LINK_SPEED BIT(7)
249 #define VIRTCHNL_VF_OFFLOAD_CRC BIT(10)
250 #define VIRTCHNL_VF_OFFLOAD_VLAN_V2 BIT(15)
251 #define VIRTCHNL_VF_OFFLOAD_VLAN BIT(16)
252 #define VIRTCHNL_VF_OFFLOAD_RX_POLLING BIT(17)
253 #define VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 BIT(18)
254 #define VIRTCHNL_VF_OFFLOAD_RSS_PF BIT(19)
255 #define VIRTCHNL_VF_OFFLOAD_ENCAP BIT(20)
256 #define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM BIT(21)
257 #define VIRTCHNL_VF_OFFLOAD_RX_ENCAP_CSUM BIT(22)
258 #define VIRTCHNL_VF_OFFLOAD_ADQ BIT(23)
259 #define VIRTCHNL_VF_OFFLOAD_USO BIT(25)
260 #define VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC BIT(26)
261 #define VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF BIT(27)
262 #define VIRTCHNL_VF_OFFLOAD_FDIR_PF BIT(28)
264 #define VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \
265 VIRTCHNL_VF_OFFLOAD_VLAN | \
266 VIRTCHNL_VF_OFFLOAD_RSS_PF)
268 struct virtchnl_vf_resource {
278 struct virtchnl_vsi_resource vsi_res[];
281 VIRTCHNL_CHECK_STRUCT_LEN(20, virtchnl_vf_resource);
282 #define virtchnl_vf_resource_LEGACY_SIZEOF 36
284 /* VIRTCHNL_OP_CONFIG_TX_QUEUE
285 * VF sends this message to set up parameters for one TX queue.
286 * External data buffer contains one instance of virtchnl_txq_info.
287 * PF configures requested queue and returns a status code.
290 /* Tx queue config info */
291 struct virtchnl_txq_info {
294 u16 ring_len; /* number of descriptors, multiple of 8 */
295 u16 headwb_enabled; /* deprecated with AVF 1.0 */
297 u64 dma_headwb_addr; /* deprecated with AVF 1.0 */
300 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_txq_info);
302 /* VIRTCHNL_OP_CONFIG_RX_QUEUE
303 * VF sends this message to set up parameters for one RX queue.
304 * External data buffer contains one instance of virtchnl_rxq_info.
305 * PF configures requested queue and returns a status code. The
306 * crc_disable flag disables CRC stripping on the VF. Setting
307 * the crc_disable flag to 1 will disable CRC stripping for each
308 * queue in the VF where the flag is set. The VIRTCHNL_VF_OFFLOAD_CRC
309 * offload must have been set prior to sending this info or the PF
310 * will ignore the request. This flag should be set the same for
311 * all of the queues for a VF.
314 /* Rx queue config info */
315 struct virtchnl_rxq_info {
318 u32 ring_len; /* number of descriptors, multiple of 32 */
320 u16 splithdr_enabled; /* deprecated with AVF 1.0 */
328 /* see enum virtchnl_rx_hsplit; deprecated with AVF 1.0 */
333 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_rxq_info);
335 /* VIRTCHNL_OP_CONFIG_VSI_QUEUES
336 * VF sends this message to set parameters for all active TX and RX queues
337 * associated with the specified VSI.
338 * PF configures queues and returns status.
339 * If the number of queues specified is greater than the number of queues
340 * associated with the VSI, an error is returned and no queues are configured.
341 * NOTE: The VF is not required to configure all queues in a single request.
342 * It may send multiple messages. PF drivers must correctly handle all VF
345 struct virtchnl_queue_pair_info {
346 /* NOTE: vsi_id and queue_id should be identical for both queues. */
347 struct virtchnl_txq_info txq;
348 struct virtchnl_rxq_info rxq;
351 VIRTCHNL_CHECK_STRUCT_LEN(64, virtchnl_queue_pair_info);
353 struct virtchnl_vsi_queue_config_info {
357 struct virtchnl_queue_pair_info qpair[];
360 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_vsi_queue_config_info);
361 #define virtchnl_vsi_queue_config_info_LEGACY_SIZEOF 72
363 /* VIRTCHNL_OP_REQUEST_QUEUES
364 * VF sends this message to request the PF to allocate additional queues to
365 * this VF. Each VF gets a guaranteed number of queues on init but asking for
366 * additional queues must be negotiated. This is a best effort request as it
367 * is possible the PF does not have enough queues left to support the request.
368 * If the PF cannot support the number requested it will respond with the
369 * maximum number it is able to support. If the request is successful, PF will
370 * then reset the VF to institute required changes.
373 /* VF resource request */
374 struct virtchnl_vf_res_request {
378 /* VIRTCHNL_OP_CONFIG_IRQ_MAP
379 * VF uses this message to map vectors to queues.
380 * The rxq_map and txq_map fields are bitmaps used to indicate which queues
381 * are to be associated with the specified vector.
382 * The "other" causes are always mapped to vector 0. The VF may not request
383 * that vector 0 be used for traffic.
384 * PF configures interrupt mapping and returns status.
385 * NOTE: due to hardware requirements, all active queues (both TX and RX)
386 * should be mapped to interrupts, even if the driver intends to operate
387 * only in polling mode. In this case the interrupt may be disabled, but
388 * the ITR timer will still run to trigger writebacks.
390 struct virtchnl_vector_map {
399 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_vector_map);
401 struct virtchnl_irq_map_info {
403 struct virtchnl_vector_map vecmap[];
406 VIRTCHNL_CHECK_STRUCT_LEN(2, virtchnl_irq_map_info);
407 #define virtchnl_irq_map_info_LEGACY_SIZEOF 14
409 /* VIRTCHNL_OP_ENABLE_QUEUES
410 * VIRTCHNL_OP_DISABLE_QUEUES
411 * VF sends these message to enable or disable TX/RX queue pairs.
412 * The queues fields are bitmaps indicating which queues to act upon.
413 * (Currently, we only support 16 queues per VF, but we make the field
414 * u32 to allow for expansion.)
415 * PF performs requested action and returns status.
416 * NOTE: The VF is not required to enable/disable all queues in a single
417 * request. It may send multiple messages.
418 * PF drivers must correctly handle all VF requests.
420 struct virtchnl_queue_select {
427 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_select);
429 /* VIRTCHNL_OP_ADD_ETH_ADDR
430 * VF sends this message in order to add one or more unicast or multicast
431 * address filters for the specified VSI.
432 * PF adds the filters and returns status.
435 /* VIRTCHNL_OP_DEL_ETH_ADDR
436 * VF sends this message in order to remove one or more unicast or multicast
437 * filters for the specified VSI.
438 * PF removes the filters and returns status.
441 /* VIRTCHNL_ETHER_ADDR_LEGACY
442 * Prior to adding the @type member to virtchnl_ether_addr, there were 2 pad
443 * bytes. Moving forward all VF drivers should not set type to
444 * VIRTCHNL_ETHER_ADDR_LEGACY. This is only here to not break previous/legacy
445 * behavior. The control plane function (i.e. PF) can use a best effort method
446 * of tracking the primary/device unicast in this case, but there is no
447 * guarantee and functionality depends on the implementation of the PF.
450 /* VIRTCHNL_ETHER_ADDR_PRIMARY
451 * All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_PRIMARY for the
452 * primary/device unicast MAC address filter for VIRTCHNL_OP_ADD_ETH_ADDR and
453 * VIRTCHNL_OP_DEL_ETH_ADDR. This allows for the underlying control plane
454 * function (i.e. PF) to accurately track and use this MAC address for
455 * displaying on the host and for VM/function reset.
458 /* VIRTCHNL_ETHER_ADDR_EXTRA
459 * All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_EXTRA for any extra
460 * unicast and/or multicast filters that are being added/deleted via
461 * VIRTCHNL_OP_DEL_ETH_ADDR/VIRTCHNL_OP_ADD_ETH_ADDR respectively.
463 struct virtchnl_ether_addr {
466 #define VIRTCHNL_ETHER_ADDR_LEGACY 0
467 #define VIRTCHNL_ETHER_ADDR_PRIMARY 1
468 #define VIRTCHNL_ETHER_ADDR_EXTRA 2
469 #define VIRTCHNL_ETHER_ADDR_TYPE_MASK 3 /* first two bits of type are valid */
473 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_ether_addr);
475 struct virtchnl_ether_addr_list {
478 struct virtchnl_ether_addr list[];
481 VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_ether_addr_list);
482 #define virtchnl_ether_addr_list_LEGACY_SIZEOF 12
484 /* VIRTCHNL_OP_ADD_VLAN
485 * VF sends this message to add one or more VLAN tag filters for receives.
486 * PF adds the filters and returns status.
487 * If a port VLAN is configured by the PF, this operation will return an
491 /* VIRTCHNL_OP_DEL_VLAN
492 * VF sends this message to remove one or more VLAN tag filters for receives.
493 * PF removes the filters and returns status.
494 * If a port VLAN is configured by the PF, this operation will return an
498 struct virtchnl_vlan_filter_list {
504 VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_vlan_filter_list);
505 #define virtchnl_vlan_filter_list_LEGACY_SIZEOF 6
507 /* This enum is used for all of the VIRTCHNL_VF_OFFLOAD_VLAN_V2_CAPS related
508 * structures and opcodes.
510 * VIRTCHNL_VLAN_UNSUPPORTED - This field is not supported and if a VF driver
511 * populates it the PF should return VIRTCHNL_STATUS_ERR_NOT_SUPPORTED.
513 * VIRTCHNL_VLAN_ETHERTYPE_8100 - This field supports 0x8100 ethertype.
514 * VIRTCHNL_VLAN_ETHERTYPE_88A8 - This field supports 0x88A8 ethertype.
515 * VIRTCHNL_VLAN_ETHERTYPE_9100 - This field supports 0x9100 ethertype.
517 * VIRTCHNL_VLAN_ETHERTYPE_AND - Used when multiple ethertypes can be supported
518 * by the PF concurrently. For example, if the PF can support
519 * VIRTCHNL_VLAN_ETHERTYPE_8100 AND VIRTCHNL_VLAN_ETHERTYPE_88A8 filters it
520 * would OR the following bits:
522 * VIRTHCNL_VLAN_ETHERTYPE_8100 |
523 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
524 * VIRTCHNL_VLAN_ETHERTYPE_AND;
526 * The VF would interpret this as VLAN filtering can be supported on both 0x8100
527 * and 0x88A8 VLAN ethertypes.
529 * VIRTCHNL_ETHERTYPE_XOR - Used when only a single ethertype can be supported
530 * by the PF concurrently. For example if the PF can support
531 * VIRTCHNL_VLAN_ETHERTYPE_8100 XOR VIRTCHNL_VLAN_ETHERTYPE_88A8 stripping
532 * offload it would OR the following bits:
534 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
535 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
536 * VIRTCHNL_VLAN_ETHERTYPE_XOR;
538 * The VF would interpret this as VLAN stripping can be supported on either
539 * 0x8100 or 0x88a8 VLAN ethertypes. So when requesting VLAN stripping via
540 * VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 the specified ethertype will override
541 * the previously set value.
543 * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1 - Used to tell the VF to insert and/or
544 * strip the VLAN tag using the L2TAG1 field of the Tx/Rx descriptors.
546 * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 - Used to tell the VF to insert hardware
547 * offloaded VLAN tags using the L2TAG2 field of the Tx descriptor.
549 * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 - Used to tell the VF to strip hardware
550 * offloaded VLAN tags using the L2TAG2_2 field of the Rx descriptor.
552 * VIRTCHNL_VLAN_PRIO - This field supports VLAN priority bits. This is used for
553 * VLAN filtering if the underlying PF supports it.
555 * VIRTCHNL_VLAN_TOGGLE_ALLOWED - This field is used to say whether a
556 * certain VLAN capability can be toggled. For example if the underlying PF/CP
557 * allows the VF to toggle VLAN filtering, stripping, and/or insertion it should
558 * set this bit along with the supported ethertypes.
560 enum virtchnl_vlan_support {
561 VIRTCHNL_VLAN_UNSUPPORTED = 0,
562 VIRTCHNL_VLAN_ETHERTYPE_8100 = BIT(0),
563 VIRTCHNL_VLAN_ETHERTYPE_88A8 = BIT(1),
564 VIRTCHNL_VLAN_ETHERTYPE_9100 = BIT(2),
565 VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1 = BIT(8),
566 VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 = BIT(9),
567 VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2_2 = BIT(10),
568 VIRTCHNL_VLAN_PRIO = BIT(24),
569 VIRTCHNL_VLAN_FILTER_MASK = BIT(28),
570 VIRTCHNL_VLAN_ETHERTYPE_AND = BIT(29),
571 VIRTCHNL_VLAN_ETHERTYPE_XOR = BIT(30),
572 VIRTCHNL_VLAN_TOGGLE = BIT(31),
575 /* This structure is used as part of the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS
576 * for filtering, insertion, and stripping capabilities.
578 * If only outer capabilities are supported (for filtering, insertion, and/or
579 * stripping) then this refers to the outer most or single VLAN from the VF's
582 * If only inner capabilities are supported (for filtering, insertion, and/or
583 * stripping) then this refers to the outer most or single VLAN from the VF's
584 * perspective. Functionally this is the same as if only outer capabilities are
585 * supported. The VF driver is just forced to use the inner fields when
586 * adding/deleting filters and enabling/disabling offloads (if supported).
588 * If both outer and inner capabilities are supported (for filtering, insertion,
589 * and/or stripping) then outer refers to the outer most or single VLAN and
590 * inner refers to the second VLAN, if it exists, in the packet.
592 * There is no support for tunneled VLAN offloads, so outer or inner are never
593 * referring to a tunneled packet from the VF's perspective.
595 struct virtchnl_vlan_supported_caps {
600 /* The PF populates these fields based on the supported VLAN filtering. If a
601 * field is VIRTCHNL_VLAN_UNSUPPORTED then it's not supported and the PF will
602 * reject any VIRTCHNL_OP_ADD_VLAN_V2 or VIRTCHNL_OP_DEL_VLAN_V2 messages using
603 * the unsupported fields.
605 * Also, a VF is only allowed to toggle its VLAN filtering setting if the
606 * VIRTCHNL_VLAN_TOGGLE bit is set.
608 * The ethertype(s) specified in the ethertype_init field are the ethertypes
609 * enabled for VLAN filtering. VLAN filtering in this case refers to the outer
610 * most VLAN from the VF's perspective. If both inner and outer filtering are
611 * allowed then ethertype_init only refers to the outer most VLAN as only
612 * VLAN ethertype supported for inner VLAN filtering is
613 * VIRTCHNL_VLAN_ETHERTYPE_8100. By default, inner VLAN filtering is disabled
614 * when both inner and outer filtering are allowed.
616 * The max_filters field tells the VF how many VLAN filters it's allowed to have
617 * at any one time. If it exceeds this amount and tries to add another filter,
618 * then the request will be rejected by the PF. To prevent failures, the VF
619 * should keep track of how many VLAN filters it has added and not attempt to
620 * add more than max_filters.
622 struct virtchnl_vlan_filtering_caps {
623 struct virtchnl_vlan_supported_caps filtering_support;
629 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vlan_filtering_caps);
631 /* This enum is used for the virtchnl_vlan_offload_caps structure to specify
632 * if the PF supports a different ethertype for stripping and insertion.
634 * VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION - The ethertype(s) specified
635 * for stripping affect the ethertype(s) specified for insertion and visa versa
636 * as well. If the VF tries to configure VLAN stripping via
637 * VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 with VIRTCHNL_VLAN_ETHERTYPE_8100 then
638 * that will be the ethertype for both stripping and insertion.
640 * VIRTCHNL_ETHERTYPE_MATCH_NOT_REQUIRED - The ethertype(s) specified for
641 * stripping do not affect the ethertype(s) specified for insertion and visa
644 enum virtchnl_vlan_ethertype_match {
645 VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION = 0,
646 VIRTCHNL_ETHERTYPE_MATCH_NOT_REQUIRED = 1,
649 /* The PF populates these fields based on the supported VLAN offloads. If a
650 * field is VIRTCHNL_VLAN_UNSUPPORTED then it's not supported and the PF will
651 * reject any VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 or
652 * VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 messages using the unsupported fields.
654 * Also, a VF is only allowed to toggle its VLAN offload setting if the
655 * VIRTCHNL_VLAN_TOGGLE_ALLOWED bit is set.
657 * The VF driver needs to be aware of how the tags are stripped by hardware and
658 * inserted by the VF driver based on the level of offload support. The PF will
659 * populate these fields based on where the VLAN tags are expected to be
660 * offloaded via the VIRTHCNL_VLAN_TAG_LOCATION_* bits. The VF will need to
661 * interpret these fields. See the definition of the
662 * VIRTCHNL_VLAN_TAG_LOCATION_* bits above the virtchnl_vlan_support
665 struct virtchnl_vlan_offload_caps {
666 struct virtchnl_vlan_supported_caps stripping_support;
667 struct virtchnl_vlan_supported_caps insertion_support;
673 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_vlan_offload_caps);
675 /* VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS
676 * VF sends this message to determine its VLAN capabilities.
678 * PF will mark which capabilities it supports based on hardware support and
679 * current configuration. For example, if a port VLAN is configured the PF will
680 * not allow outer VLAN filtering, stripping, or insertion to be configured so
681 * it will block these features from the VF.
683 * The VF will need to cross reference its capabilities with the PFs
684 * capabilities in the response message from the PF to determine the VLAN
687 struct virtchnl_vlan_caps {
688 struct virtchnl_vlan_filtering_caps filtering;
689 struct virtchnl_vlan_offload_caps offloads;
692 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_vlan_caps);
694 struct virtchnl_vlan {
695 u16 tci; /* tci[15:13] = PCP and tci[11:0] = VID */
696 u16 tci_mask; /* only valid if VIRTCHNL_VLAN_FILTER_MASK set in
699 u16 tpid; /* 0x8100, 0x88a8, etc. and only type(s) set in
700 * filtering caps. Note that tpid here does not refer to
701 * VIRTCHNL_VLAN_ETHERTYPE_*, but it refers to the
702 * actual 2-byte VLAN TPID
707 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_vlan);
709 struct virtchnl_vlan_filter {
710 struct virtchnl_vlan inner;
711 struct virtchnl_vlan outer;
715 VIRTCHNL_CHECK_STRUCT_LEN(32, virtchnl_vlan_filter);
717 /* VIRTCHNL_OP_ADD_VLAN_V2
718 * VIRTCHNL_OP_DEL_VLAN_V2
720 * VF sends these messages to add/del one or more VLAN tag filters for Rx
723 * The PF attempts to add the filters and returns status.
725 * The VF should only ever attempt to add/del virtchnl_vlan_filter(s) using the
726 * supported fields negotiated via VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS.
728 struct virtchnl_vlan_filter_list_v2 {
732 struct virtchnl_vlan_filter filters[];
735 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_vlan_filter_list_v2);
736 #define virtchnl_vlan_filter_list_v2_LEGACY_SIZEOF 40
738 /* VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2
739 * VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2
740 * VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2
741 * VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2
743 * VF sends this message to enable or disable VLAN stripping or insertion. It
744 * also needs to specify an ethertype. The VF knows which VLAN ethertypes are
745 * allowed and whether or not it's allowed to enable/disable the specific
746 * offload via the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS message. The VF needs to
747 * parse the virtchnl_vlan_caps.offloads fields to determine which offload
748 * messages are allowed.
750 * For example, if the PF populates the virtchnl_vlan_caps.offloads in the
751 * following manner the VF will be allowed to enable and/or disable 0x8100 inner
752 * VLAN insertion and/or stripping via the opcodes listed above. Inner in this
753 * case means the outer most or single VLAN from the VF's perspective. This is
754 * because no outer offloads are supported. See the comments above the
755 * virtchnl_vlan_supported_caps structure for more details.
757 * virtchnl_vlan_caps.offloads.stripping_support.inner =
758 * VIRTCHNL_VLAN_TOGGLE |
759 * VIRTCHNL_VLAN_ETHERTYPE_8100;
761 * virtchnl_vlan_caps.offloads.insertion_support.inner =
762 * VIRTCHNL_VLAN_TOGGLE |
763 * VIRTCHNL_VLAN_ETHERTYPE_8100;
765 * In order to enable inner (again note that in this case inner is the outer
766 * most or single VLAN from the VF's perspective) VLAN stripping for 0x8100
767 * VLANs, the VF would populate the virtchnl_vlan_setting structure in the
768 * following manner and send the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 message.
770 * virtchnl_vlan_setting.inner_ethertype_setting =
771 * VIRTCHNL_VLAN_ETHERTYPE_8100;
773 * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on
776 * The reason that VLAN TPID(s) are not being used for the
777 * outer_ethertype_setting and inner_ethertype_setting fields is because it's
778 * possible a device could support VLAN insertion and/or stripping offload on
779 * multiple ethertypes concurrently, so this method allows a VF to request
780 * multiple ethertypes in one message using the virtchnl_vlan_support
783 * For example, if the PF populates the virtchnl_vlan_caps.offloads in the
784 * following manner the VF will be allowed to enable 0x8100 and 0x88a8 outer
785 * VLAN insertion and stripping simultaneously. The
786 * virtchnl_vlan_caps.offloads.ethertype_match field will also have to be
787 * populated based on what the PF can support.
789 * virtchnl_vlan_caps.offloads.stripping_support.outer =
790 * VIRTCHNL_VLAN_TOGGLE |
791 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
792 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
793 * VIRTCHNL_VLAN_ETHERTYPE_AND;
795 * virtchnl_vlan_caps.offloads.insertion_support.outer =
796 * VIRTCHNL_VLAN_TOGGLE |
797 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
798 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
799 * VIRTCHNL_VLAN_ETHERTYPE_AND;
801 * In order to enable outer VLAN stripping for 0x8100 and 0x88a8 VLANs, the VF
802 * would populate the virthcnl_vlan_offload_structure in the following manner
803 * and send the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 message.
805 * virtchnl_vlan_setting.outer_ethertype_setting =
806 * VIRTHCNL_VLAN_ETHERTYPE_8100 |
807 * VIRTHCNL_VLAN_ETHERTYPE_88A8;
809 * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on
812 * There is also the case where a PF and the underlying hardware can support
813 * VLAN offloads on multiple ethertypes, but not concurrently. For example, if
814 * the PF populates the virtchnl_vlan_caps.offloads in the following manner the
815 * VF will be allowed to enable and/or disable 0x8100 XOR 0x88a8 outer VLAN
816 * offloads. The ethertypes must match for stripping and insertion.
818 * virtchnl_vlan_caps.offloads.stripping_support.outer =
819 * VIRTCHNL_VLAN_TOGGLE |
820 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
821 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
822 * VIRTCHNL_VLAN_ETHERTYPE_XOR;
824 * virtchnl_vlan_caps.offloads.insertion_support.outer =
825 * VIRTCHNL_VLAN_TOGGLE |
826 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
827 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
828 * VIRTCHNL_VLAN_ETHERTYPE_XOR;
830 * virtchnl_vlan_caps.offloads.ethertype_match =
831 * VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION;
833 * In order to enable outer VLAN stripping for 0x88a8 VLANs, the VF would
834 * populate the virtchnl_vlan_setting structure in the following manner and send
835 * the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2. Also, this will change the
836 * ethertype for VLAN insertion if it's enabled. So, for completeness, a
837 * VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 with the same ethertype should be sent.
839 * virtchnl_vlan_setting.outer_ethertype_setting = VIRTHCNL_VLAN_ETHERTYPE_88A8;
841 * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on
844 struct virtchnl_vlan_setting {
845 u32 outer_ethertype_setting;
846 u32 inner_ethertype_setting;
851 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vlan_setting);
853 /* VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE
854 * VF sends VSI id and flags.
855 * PF returns status code in retval.
856 * Note: we assume that broadcast accept mode is always enabled.
858 struct virtchnl_promisc_info {
863 VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_promisc_info);
865 #define FLAG_VF_UNICAST_PROMISC 0x00000001
866 #define FLAG_VF_MULTICAST_PROMISC 0x00000002
868 /* VIRTCHNL_OP_GET_STATS
869 * VF sends this message to request stats for the selected VSI. VF uses
870 * the virtchnl_queue_select struct to specify the VSI. The queue_id
871 * field is ignored by the PF.
873 * PF replies with struct eth_stats in an external buffer.
876 /* VIRTCHNL_OP_CONFIG_RSS_KEY
877 * VIRTCHNL_OP_CONFIG_RSS_LUT
878 * VF sends these messages to configure RSS. Only supported if both PF
879 * and VF drivers set the VIRTCHNL_VF_OFFLOAD_RSS_PF bit during
880 * configuration negotiation. If this is the case, then the RSS fields in
881 * the VF resource struct are valid.
882 * Both the key and LUT are initialized to 0 by the PF, meaning that
883 * RSS is effectively disabled until set up by the VF.
885 struct virtchnl_rss_key {
888 u8 key[]; /* RSS hash key, packed bytes */
891 VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_rss_key);
892 #define virtchnl_rss_key_LEGACY_SIZEOF 6
894 struct virtchnl_rss_lut {
897 u8 lut[]; /* RSS lookup table */
900 VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_rss_lut);
901 #define virtchnl_rss_lut_LEGACY_SIZEOF 6
903 /* VIRTCHNL_OP_GET_RSS_HENA_CAPS
904 * VIRTCHNL_OP_SET_RSS_HENA
905 * VF sends these messages to get and set the hash filter enable bits for RSS.
906 * By default, the PF sets these to all possible traffic types that the
907 * hardware supports. The VF can query this value if it wants to change the
908 * traffic types that are hashed by the hardware.
910 struct virtchnl_rss_hena {
914 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_rss_hena);
916 /* Type of RSS algorithm */
917 enum virtchnl_rss_algorithm {
918 VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC = 0,
919 VIRTCHNL_RSS_ALG_R_ASYMMETRIC = 1,
920 VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC = 2,
921 VIRTCHNL_RSS_ALG_XOR_SYMMETRIC = 3,
924 /* VIRTCHNL_OP_CONFIG_RSS_HFUNC
925 * VF sends this message to configure the RSS hash function. Only supported
926 * if both PF and VF drivers set the VIRTCHNL_VF_OFFLOAD_RSS_PF bit during
927 * configuration negotiation.
928 * The hash function is initialized to VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC
931 struct virtchnl_rss_hfunc {
933 u16 rss_algorithm; /* enum virtchnl_rss_algorithm */
937 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_rss_hfunc);
939 /* VIRTCHNL_OP_ENABLE_CHANNELS
940 * VIRTCHNL_OP_DISABLE_CHANNELS
941 * VF sends these messages to enable or disable channels based on
942 * the user specified queue count and queue offset for each traffic class.
943 * This struct encompasses all the information that the PF needs from
944 * VF to create a channel.
946 struct virtchnl_channel_info {
947 u16 count; /* number of queues in a channel */
948 u16 offset; /* queues in a channel start from 'offset' */
953 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_channel_info);
955 struct virtchnl_tc_info {
958 struct virtchnl_channel_info list[];
961 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_tc_info);
962 #define virtchnl_tc_info_LEGACY_SIZEOF 24
964 /* VIRTCHNL_ADD_CLOUD_FILTER
965 * VIRTCHNL_DEL_CLOUD_FILTER
966 * VF sends these messages to add or delete a cloud filter based on the
967 * user specified match and action filters. These structures encompass
968 * all the information that the PF needs from the VF to add/delete a
972 struct virtchnl_l4_spec {
973 u8 src_mac[ETH_ALEN];
974 u8 dst_mac[ETH_ALEN];
976 __be16 pad; /* reserved for future use */
983 VIRTCHNL_CHECK_STRUCT_LEN(52, virtchnl_l4_spec);
985 union virtchnl_flow_spec {
986 struct virtchnl_l4_spec tcp_spec;
987 u8 buffer[128]; /* reserved for future use */
990 VIRTCHNL_CHECK_UNION_LEN(128, virtchnl_flow_spec);
992 enum virtchnl_action {
994 VIRTCHNL_ACTION_DROP = 0,
995 VIRTCHNL_ACTION_TC_REDIRECT,
996 VIRTCHNL_ACTION_PASSTHRU,
997 VIRTCHNL_ACTION_QUEUE,
998 VIRTCHNL_ACTION_Q_REGION,
999 VIRTCHNL_ACTION_MARK,
1000 VIRTCHNL_ACTION_COUNT,
1003 enum virtchnl_flow_type {
1005 VIRTCHNL_TCP_V4_FLOW = 0,
1006 VIRTCHNL_TCP_V6_FLOW,
1009 struct virtchnl_filter {
1010 union virtchnl_flow_spec data;
1011 union virtchnl_flow_spec mask;
1013 /* see enum virtchnl_flow_type */
1016 /* see enum virtchnl_action */
1023 VIRTCHNL_CHECK_STRUCT_LEN(272, virtchnl_filter);
1025 struct virtchnl_supported_rxdids {
1026 u64 supported_rxdids;
1029 /* VIRTCHNL_OP_EVENT
1030 * PF sends this message to inform the VF driver of events that may affect it.
1031 * No direct response is expected from the VF, though it may generate other
1032 * messages in response to this one.
1034 enum virtchnl_event_codes {
1035 VIRTCHNL_EVENT_UNKNOWN = 0,
1036 VIRTCHNL_EVENT_LINK_CHANGE,
1037 VIRTCHNL_EVENT_RESET_IMPENDING,
1038 VIRTCHNL_EVENT_PF_DRIVER_CLOSE,
1041 #define PF_EVENT_SEVERITY_INFO 0
1042 #define PF_EVENT_SEVERITY_CERTAIN_DOOM 255
1044 struct virtchnl_pf_event {
1045 /* see enum virtchnl_event_codes */
1048 /* If the PF driver does not support the new speed reporting
1049 * capabilities then use link_event else use link_event_adv to
1050 * get the speed and link information. The ability to understand
1051 * new speeds is indicated by setting the capability flag
1052 * VIRTCHNL_VF_CAP_ADV_LINK_SPEED in vf_cap_flags parameter
1053 * in virtchnl_vf_resource struct and can be used to determine
1054 * which link event struct to use below.
1057 enum virtchnl_link_speed link_speed;
1062 /* link_speed provided in Mbps */
1072 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_pf_event);
1074 /* used to specify if a ceq_idx or aeq_idx is invalid */
1075 #define VIRTCHNL_RDMA_INVALID_QUEUE_IDX 0xFFFF
1076 /* VIRTCHNL_OP_CONFIG_RDMA_IRQ_MAP
1077 * VF uses this message to request PF to map RDMA vectors to RDMA queues.
1078 * The request for this originates from the VF RDMA driver through
1079 * a client interface between VF LAN and VF RDMA driver.
1080 * A vector could have an AEQ and CEQ attached to it although
1081 * there is a single AEQ per VF RDMA instance in which case
1082 * most vectors will have an VIRTCHNL_RDMA_INVALID_QUEUE_IDX for aeq and valid
1083 * idx for ceqs There will never be a case where there will be multiple CEQs
1084 * attached to a single vector.
1085 * PF configures interrupt mapping and returns status.
1088 struct virtchnl_rdma_qv_info {
1089 u32 v_idx; /* msix_vector */
1090 u16 ceq_idx; /* set to VIRTCHNL_RDMA_INVALID_QUEUE_IDX if invalid */
1091 u16 aeq_idx; /* set to VIRTCHNL_RDMA_INVALID_QUEUE_IDX if invalid */
1096 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_rdma_qv_info);
1098 struct virtchnl_rdma_qvlist_info {
1100 struct virtchnl_rdma_qv_info qv_info[];
1103 VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_rdma_qvlist_info);
1104 #define virtchnl_rdma_qvlist_info_LEGACY_SIZEOF 16
1106 /* VF reset states - these are written into the RSTAT register:
1107 * VFGEN_RSTAT on the VF
1108 * When the PF initiates a reset, it writes 0
1109 * When the reset is complete, it writes 1
1110 * When the PF detects that the VF has recovered, it writes 2
1111 * VF checks this register periodically to determine if a reset has occurred,
1112 * then polls it to know when the reset is complete.
1113 * If either the PF or VF reads the register while the hardware
1114 * is in a reset state, it will return DEADBEEF, which, when masked
1117 enum virtchnl_vfr_states {
1118 VIRTCHNL_VFR_INPROGRESS = 0,
1119 VIRTCHNL_VFR_COMPLETED,
1120 VIRTCHNL_VFR_VFACTIVE,
1123 #define VIRTCHNL_MAX_NUM_PROTO_HDRS 32
1124 #define PROTO_HDR_SHIFT 5
1125 #define PROTO_HDR_FIELD_START(proto_hdr_type) ((proto_hdr_type) << PROTO_HDR_SHIFT)
1126 #define PROTO_HDR_FIELD_MASK ((1UL << PROTO_HDR_SHIFT) - 1)
1128 /* VF use these macros to configure each protocol header.
1129 * Specify which protocol headers and protocol header fields base on
1130 * virtchnl_proto_hdr_type and virtchnl_proto_hdr_field.
1131 * @param hdr: a struct of virtchnl_proto_hdr
1132 * @param hdr_type: ETH/IPV4/TCP, etc
1133 * @param field: SRC/DST/TEID/SPI, etc
1135 #define VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, field) \
1136 ((hdr)->field_selector |= BIT((field) & PROTO_HDR_FIELD_MASK))
1137 #define VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, field) \
1138 ((hdr)->field_selector &= ~BIT((field) & PROTO_HDR_FIELD_MASK))
1139 #define VIRTCHNL_TEST_PROTO_HDR_FIELD(hdr, val) \
1140 ((hdr)->field_selector & BIT((val) & PROTO_HDR_FIELD_MASK))
1141 #define VIRTCHNL_GET_PROTO_HDR_FIELD(hdr) ((hdr)->field_selector)
1143 #define VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \
1144 (VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, \
1145 VIRTCHNL_PROTO_HDR_ ## hdr_type ## _ ## field))
1146 #define VIRTCHNL_DEL_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \
1147 (VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, \
1148 VIRTCHNL_PROTO_HDR_ ## hdr_type ## _ ## field))
1150 #define VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, hdr_type) \
1151 ((hdr)->type = VIRTCHNL_PROTO_HDR_ ## hdr_type)
1152 #define VIRTCHNL_GET_PROTO_HDR_TYPE(hdr) \
1153 (((hdr)->type) >> PROTO_HDR_SHIFT)
1154 #define VIRTCHNL_TEST_PROTO_HDR_TYPE(hdr, val) \
1155 ((hdr)->type == ((s32)((val) >> PROTO_HDR_SHIFT)))
1156 #define VIRTCHNL_TEST_PROTO_HDR(hdr, val) \
1157 (VIRTCHNL_TEST_PROTO_HDR_TYPE((hdr), (val)) && \
1158 VIRTCHNL_TEST_PROTO_HDR_FIELD((hdr), (val)))
1160 /* Protocol header type within a packet segment. A segment consists of one or
1161 * more protocol headers that make up a logical group of protocol headers. Each
1162 * logical group of protocol headers encapsulates or is encapsulated using/by
1163 * tunneling or encapsulation protocols for network virtualization.
1165 enum virtchnl_proto_hdr_type {
1166 VIRTCHNL_PROTO_HDR_NONE,
1167 VIRTCHNL_PROTO_HDR_ETH,
1168 VIRTCHNL_PROTO_HDR_S_VLAN,
1169 VIRTCHNL_PROTO_HDR_C_VLAN,
1170 VIRTCHNL_PROTO_HDR_IPV4,
1171 VIRTCHNL_PROTO_HDR_IPV6,
1172 VIRTCHNL_PROTO_HDR_TCP,
1173 VIRTCHNL_PROTO_HDR_UDP,
1174 VIRTCHNL_PROTO_HDR_SCTP,
1175 VIRTCHNL_PROTO_HDR_GTPU_IP,
1176 VIRTCHNL_PROTO_HDR_GTPU_EH,
1177 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN,
1178 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP,
1179 VIRTCHNL_PROTO_HDR_PPPOE,
1180 VIRTCHNL_PROTO_HDR_L2TPV3,
1181 VIRTCHNL_PROTO_HDR_ESP,
1182 VIRTCHNL_PROTO_HDR_AH,
1183 VIRTCHNL_PROTO_HDR_PFCP,
1186 /* Protocol header field within a protocol header. */
1187 enum virtchnl_proto_hdr_field {
1189 VIRTCHNL_PROTO_HDR_ETH_SRC =
1190 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ETH),
1191 VIRTCHNL_PROTO_HDR_ETH_DST,
1192 VIRTCHNL_PROTO_HDR_ETH_ETHERTYPE,
1194 VIRTCHNL_PROTO_HDR_S_VLAN_ID =
1195 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_S_VLAN),
1197 VIRTCHNL_PROTO_HDR_C_VLAN_ID =
1198 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_C_VLAN),
1200 VIRTCHNL_PROTO_HDR_IPV4_SRC =
1201 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV4),
1202 VIRTCHNL_PROTO_HDR_IPV4_DST,
1203 VIRTCHNL_PROTO_HDR_IPV4_DSCP,
1204 VIRTCHNL_PROTO_HDR_IPV4_TTL,
1205 VIRTCHNL_PROTO_HDR_IPV4_PROT,
1207 VIRTCHNL_PROTO_HDR_IPV6_SRC =
1208 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV6),
1209 VIRTCHNL_PROTO_HDR_IPV6_DST,
1210 VIRTCHNL_PROTO_HDR_IPV6_TC,
1211 VIRTCHNL_PROTO_HDR_IPV6_HOP_LIMIT,
1212 VIRTCHNL_PROTO_HDR_IPV6_PROT,
1214 VIRTCHNL_PROTO_HDR_TCP_SRC_PORT =
1215 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_TCP),
1216 VIRTCHNL_PROTO_HDR_TCP_DST_PORT,
1218 VIRTCHNL_PROTO_HDR_UDP_SRC_PORT =
1219 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_UDP),
1220 VIRTCHNL_PROTO_HDR_UDP_DST_PORT,
1222 VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT =
1223 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_SCTP),
1224 VIRTCHNL_PROTO_HDR_SCTP_DST_PORT,
1226 VIRTCHNL_PROTO_HDR_GTPU_IP_TEID =
1227 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_IP),
1229 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU =
1230 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH),
1231 VIRTCHNL_PROTO_HDR_GTPU_EH_QFI,
1233 VIRTCHNL_PROTO_HDR_PPPOE_SESS_ID =
1234 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_PPPOE),
1236 VIRTCHNL_PROTO_HDR_L2TPV3_SESS_ID =
1237 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_L2TPV3),
1239 VIRTCHNL_PROTO_HDR_ESP_SPI =
1240 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ESP),
1242 VIRTCHNL_PROTO_HDR_AH_SPI =
1243 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_AH),
1245 VIRTCHNL_PROTO_HDR_PFCP_S_FIELD =
1246 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_PFCP),
1247 VIRTCHNL_PROTO_HDR_PFCP_SEID,
1250 struct virtchnl_proto_hdr {
1251 /* see enum virtchnl_proto_hdr_type */
1253 u32 field_selector; /* a bit mask to select field for header type */
1256 * binary buffer in network order for specific header type.
1257 * For example, if type = VIRTCHNL_PROTO_HDR_IPV4, a IPv4
1258 * header is expected to be copied into the buffer.
1262 VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_proto_hdr);
1264 struct virtchnl_proto_hdrs {
1268 * specify where protocol header start from.
1269 * 0 - from the outer layer
1270 * 1 - from the first inner layer
1271 * 2 - from the second inner layer
1274 int count; /* the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS */
1275 struct virtchnl_proto_hdr proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
1278 VIRTCHNL_CHECK_STRUCT_LEN(2312, virtchnl_proto_hdrs);
1280 struct virtchnl_rss_cfg {
1281 struct virtchnl_proto_hdrs proto_hdrs; /* protocol headers */
1283 /* see enum virtchnl_rss_algorithm; rss algorithm type */
1285 u8 reserved[128]; /* reserve for future */
1288 VIRTCHNL_CHECK_STRUCT_LEN(2444, virtchnl_rss_cfg);
1290 /* action configuration for FDIR */
1291 struct virtchnl_filter_action {
1292 /* see enum virtchnl_action type */
1295 /* used for queue and qgroup action */
1300 /* used for count action */
1302 /* share counter ID with other flow rules */
1304 u32 id; /* counter ID */
1306 /* used for mark action */
1312 VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_filter_action);
1314 #define VIRTCHNL_MAX_NUM_ACTIONS 8
1316 struct virtchnl_filter_action_set {
1317 /* action number must be less then VIRTCHNL_MAX_NUM_ACTIONS */
1319 struct virtchnl_filter_action actions[VIRTCHNL_MAX_NUM_ACTIONS];
1322 VIRTCHNL_CHECK_STRUCT_LEN(292, virtchnl_filter_action_set);
1324 /* pattern and action for FDIR rule */
1325 struct virtchnl_fdir_rule {
1326 struct virtchnl_proto_hdrs proto_hdrs;
1327 struct virtchnl_filter_action_set action_set;
1330 VIRTCHNL_CHECK_STRUCT_LEN(2604, virtchnl_fdir_rule);
1332 /* Status returned to VF after VF requests FDIR commands
1333 * VIRTCHNL_FDIR_SUCCESS
1334 * VF FDIR related request is successfully done by PF
1335 * The request can be OP_ADD/DEL/QUERY_FDIR_FILTER.
1337 * VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE
1338 * OP_ADD_FDIR_FILTER request is failed due to no Hardware resource.
1340 * VIRTCHNL_FDIR_FAILURE_RULE_EXIST
1341 * OP_ADD_FDIR_FILTER request is failed due to the rule is already existed.
1343 * VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT
1344 * OP_ADD_FDIR_FILTER request is failed due to conflict with existing rule.
1346 * VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST
1347 * OP_DEL_FDIR_FILTER request is failed due to this rule doesn't exist.
1349 * VIRTCHNL_FDIR_FAILURE_RULE_INVALID
1350 * OP_ADD_FDIR_FILTER request is failed due to parameters validation
1351 * or HW doesn't support.
1353 * VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT
1354 * OP_ADD/DEL_FDIR_FILTER request is failed due to timing out
1357 * VIRTCHNL_FDIR_FAILURE_QUERY_INVALID
1358 * OP_QUERY_FDIR_FILTER request is failed due to parameters validation,
1359 * for example, VF query counter of a rule who has no counter action.
1361 enum virtchnl_fdir_prgm_status {
1362 VIRTCHNL_FDIR_SUCCESS = 0,
1363 VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE,
1364 VIRTCHNL_FDIR_FAILURE_RULE_EXIST,
1365 VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT,
1366 VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST,
1367 VIRTCHNL_FDIR_FAILURE_RULE_INVALID,
1368 VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT,
1369 VIRTCHNL_FDIR_FAILURE_QUERY_INVALID,
1372 /* VIRTCHNL_OP_ADD_FDIR_FILTER
1373 * VF sends this request to PF by filling out vsi_id,
1374 * validate_only and rule_cfg. PF will return flow_id
1375 * if the request is successfully done and return add_status to VF.
1377 struct virtchnl_fdir_add {
1378 u16 vsi_id; /* INPUT */
1380 * 1 for validating a fdir rule, 0 for creating a fdir rule.
1381 * Validate and create share one ops: VIRTCHNL_OP_ADD_FDIR_FILTER.
1383 u16 validate_only; /* INPUT */
1384 u32 flow_id; /* OUTPUT */
1385 struct virtchnl_fdir_rule rule_cfg; /* INPUT */
1387 /* see enum virtchnl_fdir_prgm_status; OUTPUT */
1391 VIRTCHNL_CHECK_STRUCT_LEN(2616, virtchnl_fdir_add);
1393 /* VIRTCHNL_OP_DEL_FDIR_FILTER
1394 * VF sends this request to PF by filling out vsi_id
1395 * and flow_id. PF will return del_status to VF.
1397 struct virtchnl_fdir_del {
1398 u16 vsi_id; /* INPUT */
1400 u32 flow_id; /* INPUT */
1402 /* see enum virtchnl_fdir_prgm_status; OUTPUT */
1406 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del);
1408 #define __vss_byone(p, member, count, old) \
1409 (struct_size(p, member, count) + (old - 1 - struct_size(p, member, 0)))
1411 #define __vss_byelem(p, member, count, old) \
1412 (struct_size(p, member, count - 1) + (old - struct_size(p, member, 0)))
1414 #define __vss_full(p, member, count, old) \
1415 (struct_size(p, member, count) + (old - struct_size(p, member, 0)))
1417 #define __vss(type, func, p, member, count) \
1418 struct type: func(p, member, count, type##_LEGACY_SIZEOF)
1420 #define virtchnl_struct_size(p, m, c) \
1422 __vss(virtchnl_vf_resource, __vss_full, p, m, c), \
1423 __vss(virtchnl_vsi_queue_config_info, __vss_full, p, m, c), \
1424 __vss(virtchnl_irq_map_info, __vss_full, p, m, c), \
1425 __vss(virtchnl_ether_addr_list, __vss_full, p, m, c), \
1426 __vss(virtchnl_vlan_filter_list, __vss_full, p, m, c), \
1427 __vss(virtchnl_vlan_filter_list_v2, __vss_byelem, p, m, c), \
1428 __vss(virtchnl_tc_info, __vss_byelem, p, m, c), \
1429 __vss(virtchnl_rdma_qvlist_info, __vss_byelem, p, m, c), \
1430 __vss(virtchnl_rss_key, __vss_byone, p, m, c), \
1431 __vss(virtchnl_rss_lut, __vss_byone, p, m, c))
1434 * virtchnl_vc_validate_vf_msg
1435 * @ver: Virtchnl version info
1436 * @v_opcode: Opcode for the message
1437 * @msg: pointer to the msg buffer
1438 * @msglen: msg length
1440 * validate msg format against struct for each opcode
1443 virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
1444 u8 *msg, u16 msglen)
1446 bool err_msg_format = false;
1449 /* Validate message length. */
1451 case VIRTCHNL_OP_VERSION:
1452 valid_len = sizeof(struct virtchnl_version_info);
1454 case VIRTCHNL_OP_RESET_VF:
1456 case VIRTCHNL_OP_GET_VF_RESOURCES:
1458 valid_len = sizeof(u32);
1460 case VIRTCHNL_OP_CONFIG_TX_QUEUE:
1461 valid_len = sizeof(struct virtchnl_txq_info);
1463 case VIRTCHNL_OP_CONFIG_RX_QUEUE:
1464 valid_len = sizeof(struct virtchnl_rxq_info);
1466 case VIRTCHNL_OP_CONFIG_VSI_QUEUES:
1467 valid_len = virtchnl_vsi_queue_config_info_LEGACY_SIZEOF;
1468 if (msglen >= valid_len) {
1469 struct virtchnl_vsi_queue_config_info *vqc =
1470 (struct virtchnl_vsi_queue_config_info *)msg;
1471 valid_len = virtchnl_struct_size(vqc, qpair,
1472 vqc->num_queue_pairs);
1473 if (vqc->num_queue_pairs == 0)
1474 err_msg_format = true;
1477 case VIRTCHNL_OP_CONFIG_IRQ_MAP:
1478 valid_len = virtchnl_irq_map_info_LEGACY_SIZEOF;
1479 if (msglen >= valid_len) {
1480 struct virtchnl_irq_map_info *vimi =
1481 (struct virtchnl_irq_map_info *)msg;
1482 valid_len = virtchnl_struct_size(vimi, vecmap,
1484 if (vimi->num_vectors == 0)
1485 err_msg_format = true;
1488 case VIRTCHNL_OP_ENABLE_QUEUES:
1489 case VIRTCHNL_OP_DISABLE_QUEUES:
1490 valid_len = sizeof(struct virtchnl_queue_select);
1492 case VIRTCHNL_OP_ADD_ETH_ADDR:
1493 case VIRTCHNL_OP_DEL_ETH_ADDR:
1494 valid_len = virtchnl_ether_addr_list_LEGACY_SIZEOF;
1495 if (msglen >= valid_len) {
1496 struct virtchnl_ether_addr_list *veal =
1497 (struct virtchnl_ether_addr_list *)msg;
1498 valid_len = virtchnl_struct_size(veal, list,
1499 veal->num_elements);
1500 if (veal->num_elements == 0)
1501 err_msg_format = true;
1504 case VIRTCHNL_OP_ADD_VLAN:
1505 case VIRTCHNL_OP_DEL_VLAN:
1506 valid_len = virtchnl_vlan_filter_list_LEGACY_SIZEOF;
1507 if (msglen >= valid_len) {
1508 struct virtchnl_vlan_filter_list *vfl =
1509 (struct virtchnl_vlan_filter_list *)msg;
1510 valid_len = virtchnl_struct_size(vfl, vlan_id,
1512 if (vfl->num_elements == 0)
1513 err_msg_format = true;
1516 case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE:
1517 valid_len = sizeof(struct virtchnl_promisc_info);
1519 case VIRTCHNL_OP_GET_STATS:
1520 valid_len = sizeof(struct virtchnl_queue_select);
1522 case VIRTCHNL_OP_RDMA:
1523 /* These messages are opaque to us and will be validated in
1524 * the RDMA client code. We just need to check for nonzero
1525 * length. The firmware will enforce max length restrictions.
1530 err_msg_format = true;
1532 case VIRTCHNL_OP_RELEASE_RDMA_IRQ_MAP:
1534 case VIRTCHNL_OP_CONFIG_RDMA_IRQ_MAP:
1535 valid_len = virtchnl_rdma_qvlist_info_LEGACY_SIZEOF;
1536 if (msglen >= valid_len) {
1537 struct virtchnl_rdma_qvlist_info *qv =
1538 (struct virtchnl_rdma_qvlist_info *)msg;
1540 valid_len = virtchnl_struct_size(qv, qv_info,
1544 case VIRTCHNL_OP_CONFIG_RSS_KEY:
1545 valid_len = virtchnl_rss_key_LEGACY_SIZEOF;
1546 if (msglen >= valid_len) {
1547 struct virtchnl_rss_key *vrk =
1548 (struct virtchnl_rss_key *)msg;
1549 valid_len = virtchnl_struct_size(vrk, key,
1553 case VIRTCHNL_OP_CONFIG_RSS_LUT:
1554 valid_len = virtchnl_rss_lut_LEGACY_SIZEOF;
1555 if (msglen >= valid_len) {
1556 struct virtchnl_rss_lut *vrl =
1557 (struct virtchnl_rss_lut *)msg;
1558 valid_len = virtchnl_struct_size(vrl, lut,
1562 case VIRTCHNL_OP_CONFIG_RSS_HFUNC:
1563 valid_len = sizeof(struct virtchnl_rss_hfunc);
1565 case VIRTCHNL_OP_GET_RSS_HENA_CAPS:
1567 case VIRTCHNL_OP_SET_RSS_HENA:
1568 valid_len = sizeof(struct virtchnl_rss_hena);
1570 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING:
1571 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING:
1573 case VIRTCHNL_OP_REQUEST_QUEUES:
1574 valid_len = sizeof(struct virtchnl_vf_res_request);
1576 case VIRTCHNL_OP_ENABLE_CHANNELS:
1577 valid_len = virtchnl_tc_info_LEGACY_SIZEOF;
1578 if (msglen >= valid_len) {
1579 struct virtchnl_tc_info *vti =
1580 (struct virtchnl_tc_info *)msg;
1581 valid_len = virtchnl_struct_size(vti, list,
1583 if (vti->num_tc == 0)
1584 err_msg_format = true;
1587 case VIRTCHNL_OP_DISABLE_CHANNELS:
1589 case VIRTCHNL_OP_ADD_CLOUD_FILTER:
1590 case VIRTCHNL_OP_DEL_CLOUD_FILTER:
1591 valid_len = sizeof(struct virtchnl_filter);
1593 case VIRTCHNL_OP_GET_SUPPORTED_RXDIDS:
1595 case VIRTCHNL_OP_ADD_RSS_CFG:
1596 case VIRTCHNL_OP_DEL_RSS_CFG:
1597 valid_len = sizeof(struct virtchnl_rss_cfg);
1599 case VIRTCHNL_OP_ADD_FDIR_FILTER:
1600 valid_len = sizeof(struct virtchnl_fdir_add);
1602 case VIRTCHNL_OP_DEL_FDIR_FILTER:
1603 valid_len = sizeof(struct virtchnl_fdir_del);
1605 case VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS:
1607 case VIRTCHNL_OP_ADD_VLAN_V2:
1608 case VIRTCHNL_OP_DEL_VLAN_V2:
1609 valid_len = virtchnl_vlan_filter_list_v2_LEGACY_SIZEOF;
1610 if (msglen >= valid_len) {
1611 struct virtchnl_vlan_filter_list_v2 *vfl =
1612 (struct virtchnl_vlan_filter_list_v2 *)msg;
1614 valid_len = virtchnl_struct_size(vfl, filters,
1617 if (vfl->num_elements == 0) {
1618 err_msg_format = true;
1623 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2:
1624 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2:
1625 case VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2:
1626 case VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2:
1627 valid_len = sizeof(struct virtchnl_vlan_setting);
1629 /* These are always errors coming from the VF. */
1630 case VIRTCHNL_OP_EVENT:
1631 case VIRTCHNL_OP_UNKNOWN:
1633 return VIRTCHNL_STATUS_ERR_PARAM;
1635 /* few more checks */
1636 if (err_msg_format || valid_len != msglen)
1637 return VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH;
1641 #endif /* _VIRTCHNL_H_ */