1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2001-2021 Intel Corporation
9 * This header file describes the VF-PF communication protocol used
10 * by the drivers for all devices starting from our 40G product line
12 * Admin queue buffer usage:
13 * desc->opcode is always aqc_opc_send_msg_to_pf
14 * flags, retval, datalen, and data addr are all used normally.
15 * The Firmware copies the cookie fields when sending messages between the
16 * PF and VF, but uses all other fields internally. Due to this limitation,
17 * we must send all messages as "indirect", i.e. using an external buffer.
19 * All the VSI indexes are relative to the VF. Each VF can have maximum of
20 * three VSIs. All the queue indexes are relative to the VSI. Each VF can
21 * have a maximum of sixteen queues for all of its VSIs.
23 * The PF is required to return a status code in v_retval for all messages
24 * except RESET_VF, which does not require any response. The return value
25 * is of status_code type, defined in the shared type.h.
27 * In general, VF driver initialization should roughly follow the order of
28 * these opcodes. The VF driver must first validate the API version of the
29 * PF driver, then request a reset, then get resources, then configure
30 * queues and interrupts. After these operations are complete, the VF
31 * driver may start its queues, optionally add MAC and VLAN filters, and
35 /* START GENERIC DEFINES
36 * Need to ensure the following enums and defines hold the same meaning and
37 * value in current and future projects
41 enum virtchnl_status_code {
42 VIRTCHNL_STATUS_SUCCESS = 0,
43 VIRTCHNL_STATUS_ERR_PARAM = -5,
44 VIRTCHNL_STATUS_ERR_NO_MEMORY = -18,
45 VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH = -38,
46 VIRTCHNL_STATUS_ERR_CQP_COMPL_ERROR = -39,
47 VIRTCHNL_STATUS_ERR_INVALID_VF_ID = -40,
48 VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR = -53,
49 VIRTCHNL_STATUS_ERR_NOT_SUPPORTED = -64,
52 /* Backward compatibility */
53 #define VIRTCHNL_ERR_PARAM VIRTCHNL_STATUS_ERR_PARAM
54 #define VIRTCHNL_STATUS_NOT_SUPPORTED VIRTCHNL_STATUS_ERR_NOT_SUPPORTED
56 #define VIRTCHNL_LINK_SPEED_2_5GB_SHIFT 0x0
57 #define VIRTCHNL_LINK_SPEED_100MB_SHIFT 0x1
58 #define VIRTCHNL_LINK_SPEED_1000MB_SHIFT 0x2
59 #define VIRTCHNL_LINK_SPEED_10GB_SHIFT 0x3
60 #define VIRTCHNL_LINK_SPEED_40GB_SHIFT 0x4
61 #define VIRTCHNL_LINK_SPEED_20GB_SHIFT 0x5
62 #define VIRTCHNL_LINK_SPEED_25GB_SHIFT 0x6
63 #define VIRTCHNL_LINK_SPEED_5GB_SHIFT 0x7
65 enum virtchnl_link_speed {
66 VIRTCHNL_LINK_SPEED_UNKNOWN = 0,
67 VIRTCHNL_LINK_SPEED_100MB = BIT(VIRTCHNL_LINK_SPEED_100MB_SHIFT),
68 VIRTCHNL_LINK_SPEED_1GB = BIT(VIRTCHNL_LINK_SPEED_1000MB_SHIFT),
69 VIRTCHNL_LINK_SPEED_10GB = BIT(VIRTCHNL_LINK_SPEED_10GB_SHIFT),
70 VIRTCHNL_LINK_SPEED_40GB = BIT(VIRTCHNL_LINK_SPEED_40GB_SHIFT),
71 VIRTCHNL_LINK_SPEED_20GB = BIT(VIRTCHNL_LINK_SPEED_20GB_SHIFT),
72 VIRTCHNL_LINK_SPEED_25GB = BIT(VIRTCHNL_LINK_SPEED_25GB_SHIFT),
73 VIRTCHNL_LINK_SPEED_2_5GB = BIT(VIRTCHNL_LINK_SPEED_2_5GB_SHIFT),
74 VIRTCHNL_LINK_SPEED_5GB = BIT(VIRTCHNL_LINK_SPEED_5GB_SHIFT),
77 /* for hsplit_0 field of Rx HMC context */
78 /* deprecated with IAVF 1.0 */
79 enum virtchnl_rx_hsplit {
80 VIRTCHNL_RX_HSPLIT_NO_SPLIT = 0,
81 VIRTCHNL_RX_HSPLIT_SPLIT_L2 = 1,
82 VIRTCHNL_RX_HSPLIT_SPLIT_IP = 2,
83 VIRTCHNL_RX_HSPLIT_SPLIT_TCP_UDP = 4,
84 VIRTCHNL_RX_HSPLIT_SPLIT_SCTP = 8,
87 #define VIRTCHNL_ETH_LENGTH_OF_ADDRESS 6
88 /* END GENERIC DEFINES */
90 /* Opcodes for VF-PF communication. These are placed in the v_opcode field
91 * of the virtchnl_msg structure.
94 /* The PF sends status change events to VFs using
95 * the VIRTCHNL_OP_EVENT opcode.
96 * VFs send requests to the PF using the other ops.
97 * Use of "advanced opcode" features must be negotiated as part of capabilities
98 * exchange and are not considered part of base mode feature set.
100 VIRTCHNL_OP_UNKNOWN = 0,
101 VIRTCHNL_OP_VERSION = 1, /* must ALWAYS be 1 */
102 VIRTCHNL_OP_RESET_VF = 2,
103 VIRTCHNL_OP_GET_VF_RESOURCES = 3,
104 VIRTCHNL_OP_CONFIG_TX_QUEUE = 4,
105 VIRTCHNL_OP_CONFIG_RX_QUEUE = 5,
106 VIRTCHNL_OP_CONFIG_VSI_QUEUES = 6,
107 VIRTCHNL_OP_CONFIG_IRQ_MAP = 7,
108 VIRTCHNL_OP_ENABLE_QUEUES = 8,
109 VIRTCHNL_OP_DISABLE_QUEUES = 9,
110 VIRTCHNL_OP_ADD_ETH_ADDR = 10,
111 VIRTCHNL_OP_DEL_ETH_ADDR = 11,
112 VIRTCHNL_OP_ADD_VLAN = 12,
113 VIRTCHNL_OP_DEL_VLAN = 13,
114 VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE = 14,
115 VIRTCHNL_OP_GET_STATS = 15,
116 VIRTCHNL_OP_RSVD = 16,
117 VIRTCHNL_OP_EVENT = 17, /* must ALWAYS be 17 */
118 /* opcode 19 is reserved */
119 /* opcodes 20, 21, and 22 are reserved */
120 VIRTCHNL_OP_CONFIG_RSS_KEY = 23,
121 VIRTCHNL_OP_CONFIG_RSS_LUT = 24,
122 VIRTCHNL_OP_GET_RSS_HENA_CAPS = 25,
123 VIRTCHNL_OP_SET_RSS_HENA = 26,
124 VIRTCHNL_OP_ENABLE_VLAN_STRIPPING = 27,
125 VIRTCHNL_OP_DISABLE_VLAN_STRIPPING = 28,
126 VIRTCHNL_OP_REQUEST_QUEUES = 29,
127 VIRTCHNL_OP_ENABLE_CHANNELS = 30,
128 VIRTCHNL_OP_DISABLE_CHANNELS = 31,
129 VIRTCHNL_OP_ADD_CLOUD_FILTER = 32,
130 VIRTCHNL_OP_DEL_CLOUD_FILTER = 33,
131 /* opcodes 34, 35, 36, and 37 are reserved */
132 VIRTCHNL_OP_DCF_VLAN_OFFLOAD = 38,
133 VIRTCHNL_OP_DCF_CMD_DESC = 39,
134 VIRTCHNL_OP_DCF_CMD_BUFF = 40,
135 VIRTCHNL_OP_DCF_DISABLE = 41,
136 VIRTCHNL_OP_DCF_GET_VSI_MAP = 42,
137 VIRTCHNL_OP_DCF_GET_PKG_INFO = 43,
138 VIRTCHNL_OP_GET_SUPPORTED_RXDIDS = 44,
139 VIRTCHNL_OP_ADD_RSS_CFG = 45,
140 VIRTCHNL_OP_DEL_RSS_CFG = 46,
141 VIRTCHNL_OP_ADD_FDIR_FILTER = 47,
142 VIRTCHNL_OP_DEL_FDIR_FILTER = 48,
143 VIRTCHNL_OP_QUERY_FDIR_FILTER = 49,
144 VIRTCHNL_OP_GET_MAX_RSS_QREGION = 50,
145 VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS = 51,
146 VIRTCHNL_OP_ADD_VLAN_V2 = 52,
147 VIRTCHNL_OP_DEL_VLAN_V2 = 53,
148 VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 = 54,
149 VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 = 55,
150 VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 = 56,
151 VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2 = 57,
152 VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2 = 58,
153 VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2 = 59,
154 VIRTCHNL_OP_ENABLE_QUEUES_V2 = 107,
155 VIRTCHNL_OP_DISABLE_QUEUES_V2 = 108,
156 VIRTCHNL_OP_MAP_QUEUE_VECTOR = 111,
160 static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)
163 case VIRTCHNL_OP_UNKNOWN:
164 return "VIRTCHNL_OP_UNKNOWN";
165 case VIRTCHNL_OP_VERSION:
166 return "VIRTCHNL_OP_VERSION";
167 case VIRTCHNL_OP_RESET_VF:
168 return "VIRTCHNL_OP_RESET_VF";
169 case VIRTCHNL_OP_GET_VF_RESOURCES:
170 return "VIRTCHNL_OP_GET_VF_RESOURCES";
171 case VIRTCHNL_OP_CONFIG_TX_QUEUE:
172 return "VIRTCHNL_OP_CONFIG_TX_QUEUE";
173 case VIRTCHNL_OP_CONFIG_RX_QUEUE:
174 return "VIRTCHNL_OP_CONFIG_RX_QUEUE";
175 case VIRTCHNL_OP_CONFIG_VSI_QUEUES:
176 return "VIRTCHNL_OP_CONFIG_VSI_QUEUES";
177 case VIRTCHNL_OP_CONFIG_IRQ_MAP:
178 return "VIRTCHNL_OP_CONFIG_IRQ_MAP";
179 case VIRTCHNL_OP_ENABLE_QUEUES:
180 return "VIRTCHNL_OP_ENABLE_QUEUES";
181 case VIRTCHNL_OP_DISABLE_QUEUES:
182 return "VIRTCHNL_OP_DISABLE_QUEUES";
183 case VIRTCHNL_OP_ADD_ETH_ADDR:
184 return "VIRTCHNL_OP_ADD_ETH_ADDR";
185 case VIRTCHNL_OP_DEL_ETH_ADDR:
186 return "VIRTCHNL_OP_DEL_ETH_ADDR";
187 case VIRTCHNL_OP_ADD_VLAN:
188 return "VIRTCHNL_OP_ADD_VLAN";
189 case VIRTCHNL_OP_DEL_VLAN:
190 return "VIRTCHNL_OP_DEL_VLAN";
191 case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE:
192 return "VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE";
193 case VIRTCHNL_OP_GET_STATS:
194 return "VIRTCHNL_OP_GET_STATS";
195 case VIRTCHNL_OP_RSVD:
196 return "VIRTCHNL_OP_RSVD";
197 case VIRTCHNL_OP_EVENT:
198 return "VIRTCHNL_OP_EVENT";
199 case VIRTCHNL_OP_CONFIG_RSS_KEY:
200 return "VIRTCHNL_OP_CONFIG_RSS_KEY";
201 case VIRTCHNL_OP_CONFIG_RSS_LUT:
202 return "VIRTCHNL_OP_CONFIG_RSS_LUT";
203 case VIRTCHNL_OP_GET_RSS_HENA_CAPS:
204 return "VIRTCHNL_OP_GET_RSS_HENA_CAPS";
205 case VIRTCHNL_OP_SET_RSS_HENA:
206 return "VIRTCHNL_OP_SET_RSS_HENA";
207 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING:
208 return "VIRTCHNL_OP_ENABLE_VLAN_STRIPPING";
209 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING:
210 return "VIRTCHNL_OP_DISABLE_VLAN_STRIPPING";
211 case VIRTCHNL_OP_REQUEST_QUEUES:
212 return "VIRTCHNL_OP_REQUEST_QUEUES";
213 case VIRTCHNL_OP_ENABLE_CHANNELS:
214 return "VIRTCHNL_OP_ENABLE_CHANNELS";
215 case VIRTCHNL_OP_DISABLE_CHANNELS:
216 return "VIRTCHNL_OP_DISABLE_CHANNELS";
217 case VIRTCHNL_OP_ADD_CLOUD_FILTER:
218 return "VIRTCHNL_OP_ADD_CLOUD_FILTER";
219 case VIRTCHNL_OP_DEL_CLOUD_FILTER:
220 return "VIRTCHNL_OP_DEL_CLOUD_FILTER";
221 case VIRTCHNL_OP_DCF_CMD_DESC:
222 return "VIRTCHNL_OP_DCF_CMD_DESC";
223 case VIRTCHNL_OP_DCF_CMD_BUFF:
224 return "VIRTCHHNL_OP_DCF_CMD_BUFF";
225 case VIRTCHNL_OP_DCF_DISABLE:
226 return "VIRTCHNL_OP_DCF_DISABLE";
227 case VIRTCHNL_OP_DCF_GET_VSI_MAP:
228 return "VIRTCHNL_OP_DCF_GET_VSI_MAP";
229 case VIRTCHNL_OP_GET_SUPPORTED_RXDIDS:
230 return "VIRTCHNL_OP_GET_SUPPORTED_RXDIDS";
231 case VIRTCHNL_OP_ADD_RSS_CFG:
232 return "VIRTCHNL_OP_ADD_RSS_CFG";
233 case VIRTCHNL_OP_DEL_RSS_CFG:
234 return "VIRTCHNL_OP_DEL_RSS_CFG";
235 case VIRTCHNL_OP_ADD_FDIR_FILTER:
236 return "VIRTCHNL_OP_ADD_FDIR_FILTER";
237 case VIRTCHNL_OP_DEL_FDIR_FILTER:
238 return "VIRTCHNL_OP_DEL_FDIR_FILTER";
239 case VIRTCHNL_OP_QUERY_FDIR_FILTER:
240 return "VIRTCHNL_OP_QUERY_FDIR_FILTER";
241 case VIRTCHNL_OP_GET_MAX_RSS_QREGION:
242 return "VIRTCHNL_OP_GET_MAX_RSS_QREGION";
243 case VIRTCHNL_OP_ENABLE_QUEUES_V2:
244 return "VIRTCHNL_OP_ENABLE_QUEUES_V2";
245 case VIRTCHNL_OP_DISABLE_QUEUES_V2:
246 return "VIRTCHNL_OP_DISABLE_QUEUES_V2";
247 case VIRTCHNL_OP_MAP_QUEUE_VECTOR:
248 return "VIRTCHNL_OP_MAP_QUEUE_VECTOR";
249 case VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS:
250 return "VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS";
251 case VIRTCHNL_OP_ADD_VLAN_V2:
252 return "VIRTCHNL_OP_ADD_VLAN_V2";
253 case VIRTCHNL_OP_DEL_VLAN_V2:
254 return "VIRTCHNL_OP_DEL_VLAN_V2";
255 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2:
256 return "VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2";
257 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2:
258 return "VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2";
259 case VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2:
260 return "VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2";
261 case VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2:
262 return "VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2";
263 case VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2:
264 return "VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2";
265 case VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2:
266 return "VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2";
267 case VIRTCHNL_OP_MAX:
268 return "VIRTCHNL_OP_MAX";
270 return "Unsupported (update virtchnl.h)";
274 /* These macros are used to generate compilation errors if a structure/union
275 * is not exactly the correct length. It gives a divide by zero error if the
276 * structure/union is not of the correct size, otherwise it creates an enum
277 * that is never used.
279 #define VIRTCHNL_CHECK_STRUCT_LEN(n, X) enum virtchnl_static_assert_enum_##X \
280 { virtchnl_static_assert_##X = (n)/((sizeof(struct X) == (n)) ? 1 : 0) }
281 #define VIRTCHNL_CHECK_UNION_LEN(n, X) enum virtchnl_static_asset_enum_##X \
282 { virtchnl_static_assert_##X = (n)/((sizeof(union X) == (n)) ? 1 : 0) }
284 /* Virtual channel message descriptor. This overlays the admin queue
285 * descriptor. All other data is passed in external buffers.
288 struct virtchnl_msg {
289 u8 pad[8]; /* AQ flags/opcode/len/retval fields */
290 enum virtchnl_ops v_opcode; /* avoid confusion with desc->opcode */
291 enum virtchnl_status_code v_retval; /* ditto for desc->retval */
292 u32 vfid; /* used by PF when sending to VF */
295 VIRTCHNL_CHECK_STRUCT_LEN(20, virtchnl_msg);
297 /* Message descriptions and data structures. */
299 /* VIRTCHNL_OP_VERSION
300 * VF posts its version number to the PF. PF responds with its version number
301 * in the same format, along with a return code.
302 * Reply from PF has its major/minor versions also in param0 and param1.
303 * If there is a major version mismatch, then the VF cannot operate.
304 * If there is a minor version mismatch, then the VF can operate but should
305 * add a warning to the system log.
307 * This enum element MUST always be specified as == 1, regardless of other
308 * changes in the API. The PF must always respond to this message without
309 * error regardless of version mismatch.
311 #define VIRTCHNL_VERSION_MAJOR 1
312 #define VIRTCHNL_VERSION_MINOR 1
313 #define VIRTCHNL_VERSION_MINOR_NO_VF_CAPS 0
315 struct virtchnl_version_info {
320 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_version_info);
322 #define VF_IS_V10(_v) (((_v)->major == 1) && ((_v)->minor == 0))
323 #define VF_IS_V11(_ver) (((_ver)->major == 1) && ((_ver)->minor == 1))
325 /* VIRTCHNL_OP_RESET_VF
326 * VF sends this request to PF with no parameters
327 * PF does NOT respond! VF driver must delay then poll VFGEN_RSTAT register
328 * until reset completion is indicated. The admin queue must be reinitialized
329 * after this operation.
331 * When reset is complete, PF must ensure that all queues in all VSIs associated
332 * with the VF are stopped, all queue configurations in the HMC are set to 0,
333 * and all MAC and VLAN filters (except the default MAC address) on all VSIs
337 /* VSI types that use VIRTCHNL interface for VF-PF communication. VSI_SRIOV
338 * vsi_type should always be 6 for backward compatibility. Add other fields
341 enum virtchnl_vsi_type {
342 VIRTCHNL_VSI_TYPE_INVALID = 0,
343 VIRTCHNL_VSI_SRIOV = 6,
346 /* VIRTCHNL_OP_GET_VF_RESOURCES
347 * Version 1.0 VF sends this request to PF with no parameters
348 * Version 1.1 VF sends this request to PF with u32 bitmap of its capabilities
349 * PF responds with an indirect message containing
350 * virtchnl_vf_resource and one or more
351 * virtchnl_vsi_resource structures.
354 struct virtchnl_vsi_resource {
357 enum virtchnl_vsi_type vsi_type;
359 u8 default_mac_addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
362 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
364 /* VF capability flags
365 * VIRTCHNL_VF_OFFLOAD_L2 flag is inclusive of base mode L2 offloads including
366 * TX/RX Checksum offloading and TSO for non-tunnelled packets.
368 #define VIRTCHNL_VF_OFFLOAD_L2 0x00000001
369 #define VIRTCHNL_VF_OFFLOAD_IWARP 0x00000002
370 #define VIRTCHNL_VF_OFFLOAD_RSVD 0x00000004
371 #define VIRTCHNL_VF_OFFLOAD_RSS_AQ 0x00000008
372 #define VIRTCHNL_VF_OFFLOAD_RSS_REG 0x00000010
373 #define VIRTCHNL_VF_OFFLOAD_WB_ON_ITR 0x00000020
374 #define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES 0x00000040
375 /* used to negotiate communicating link speeds in Mbps */
376 #define VIRTCHNL_VF_CAP_ADV_LINK_SPEED 0x00000080
377 /* 0X00000100 is reserved */
378 #define VIRTCHNL_VF_LARGE_NUM_QPAIRS 0x00000200
379 #define VIRTCHNL_VF_OFFLOAD_CRC 0x00000400
380 #define VIRTCHNL_VF_OFFLOAD_VLAN_V2 0x00008000
381 #define VIRTCHNL_VF_OFFLOAD_VLAN 0x00010000
382 #define VIRTCHNL_VF_OFFLOAD_RX_POLLING 0x00020000
383 #define VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 0x00040000
384 #define VIRTCHNL_VF_OFFLOAD_RSS_PF 0X00080000
385 #define VIRTCHNL_VF_OFFLOAD_ENCAP 0X00100000
386 #define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM 0X00200000
387 #define VIRTCHNL_VF_OFFLOAD_RX_ENCAP_CSUM 0X00400000
388 #define VIRTCHNL_VF_OFFLOAD_ADQ 0X00800000
389 #define VIRTCHNL_VF_OFFLOAD_ADQ_V2 0X01000000
390 #define VIRTCHNL_VF_OFFLOAD_USO 0X02000000
391 #define VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC 0X04000000
392 #define VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF 0X08000000
393 #define VIRTCHNL_VF_OFFLOAD_FDIR_PF 0X10000000
394 /* 0X20000000 is reserved */
395 #define VIRTCHNL_VF_CAP_DCF 0X40000000
396 /* 0X80000000 is reserved */
398 #define VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \
399 VIRTCHNL_VF_OFFLOAD_VLAN | \
400 VIRTCHNL_VF_OFFLOAD_RSS_PF)
402 struct virtchnl_vf_resource {
412 struct virtchnl_vsi_resource vsi_res[1];
415 VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_vf_resource);
417 /* VIRTCHNL_OP_CONFIG_TX_QUEUE
418 * VF sends this message to set up parameters for one TX queue.
419 * External data buffer contains one instance of virtchnl_txq_info.
420 * PF configures requested queue and returns a status code.
423 /* Tx queue config info */
424 struct virtchnl_txq_info {
427 u16 ring_len; /* number of descriptors, multiple of 8 */
428 u16 headwb_enabled; /* deprecated with AVF 1.0 */
430 u64 dma_headwb_addr; /* deprecated with AVF 1.0 */
433 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_txq_info);
435 /* RX descriptor IDs (range from 0 to 63) */
436 enum virtchnl_rx_desc_ids {
437 VIRTCHNL_RXDID_0_16B_BASE = 0,
438 /* 32B_BASE and FLEX_SPLITQ share desc ids as default descriptors
439 * because they can be differentiated based on queue model; e.g. single
440 * queue model can only use 32B_BASE and split queue model can only use
441 * FLEX_SPLITQ. Having these as 1 allows them to be used as default
442 * descriptors without negotiation.
444 VIRTCHNL_RXDID_1_32B_BASE = 1,
445 VIRTCHNL_RXDID_1_FLEX_SPLITQ = 1,
446 VIRTCHNL_RXDID_2_FLEX_SQ_NIC = 2,
447 VIRTCHNL_RXDID_3_FLEX_SQ_SW = 3,
448 VIRTCHNL_RXDID_4_FLEX_SQ_NIC_VEB = 4,
449 VIRTCHNL_RXDID_5_FLEX_SQ_NIC_ACL = 5,
450 VIRTCHNL_RXDID_6_FLEX_SQ_NIC_2 = 6,
451 VIRTCHNL_RXDID_7_HW_RSVD = 7,
452 /* 9 through 15 are reserved */
453 VIRTCHNL_RXDID_16_COMMS_GENERIC = 16,
454 VIRTCHNL_RXDID_17_COMMS_AUX_VLAN = 17,
455 VIRTCHNL_RXDID_18_COMMS_AUX_IPV4 = 18,
456 VIRTCHNL_RXDID_19_COMMS_AUX_IPV6 = 19,
457 VIRTCHNL_RXDID_20_COMMS_AUX_FLOW = 20,
458 VIRTCHNL_RXDID_21_COMMS_AUX_TCP = 21,
459 /* 22 through 63 are reserved */
462 /* RX descriptor ID bitmasks */
463 enum virtchnl_rx_desc_id_bitmasks {
464 VIRTCHNL_RXDID_0_16B_BASE_M = BIT(VIRTCHNL_RXDID_0_16B_BASE),
465 VIRTCHNL_RXDID_1_32B_BASE_M = BIT(VIRTCHNL_RXDID_1_32B_BASE),
466 VIRTCHNL_RXDID_1_FLEX_SPLITQ_M = BIT(VIRTCHNL_RXDID_1_FLEX_SPLITQ),
467 VIRTCHNL_RXDID_2_FLEX_SQ_NIC_M = BIT(VIRTCHNL_RXDID_2_FLEX_SQ_NIC),
468 VIRTCHNL_RXDID_3_FLEX_SQ_SW_M = BIT(VIRTCHNL_RXDID_3_FLEX_SQ_SW),
469 VIRTCHNL_RXDID_4_FLEX_SQ_NIC_VEB_M = BIT(VIRTCHNL_RXDID_4_FLEX_SQ_NIC_VEB),
470 VIRTCHNL_RXDID_5_FLEX_SQ_NIC_ACL_M = BIT(VIRTCHNL_RXDID_5_FLEX_SQ_NIC_ACL),
471 VIRTCHNL_RXDID_6_FLEX_SQ_NIC_2_M = BIT(VIRTCHNL_RXDID_6_FLEX_SQ_NIC_2),
472 VIRTCHNL_RXDID_7_HW_RSVD_M = BIT(VIRTCHNL_RXDID_7_HW_RSVD),
473 /* 9 through 15 are reserved */
474 VIRTCHNL_RXDID_16_COMMS_GENERIC_M = BIT(VIRTCHNL_RXDID_16_COMMS_GENERIC),
475 VIRTCHNL_RXDID_17_COMMS_AUX_VLAN_M = BIT(VIRTCHNL_RXDID_17_COMMS_AUX_VLAN),
476 VIRTCHNL_RXDID_18_COMMS_AUX_IPV4_M = BIT(VIRTCHNL_RXDID_18_COMMS_AUX_IPV4),
477 VIRTCHNL_RXDID_19_COMMS_AUX_IPV6_M = BIT(VIRTCHNL_RXDID_19_COMMS_AUX_IPV6),
478 VIRTCHNL_RXDID_20_COMMS_AUX_FLOW_M = BIT(VIRTCHNL_RXDID_20_COMMS_AUX_FLOW),
479 VIRTCHNL_RXDID_21_COMMS_AUX_TCP_M = BIT(VIRTCHNL_RXDID_21_COMMS_AUX_TCP),
480 /* 22 through 63 are reserved */
483 /* VIRTCHNL_OP_CONFIG_RX_QUEUE
484 * VF sends this message to set up parameters for one RX queue.
485 * External data buffer contains one instance of virtchnl_rxq_info.
486 * PF configures requested queue and returns a status code. The
487 * crc_disable flag disables CRC stripping on the VF. Setting
488 * the crc_disable flag to 1 will disable CRC stripping for each
489 * queue in the VF where the flag is set. The VIRTCHNL_VF_OFFLOAD_CRC
490 * offload must have been set prior to sending this info or the PF
491 * will ignore the request. This flag should be set the same for
492 * all of the queues for a VF.
495 /* Rx queue config info */
496 struct virtchnl_rxq_info {
499 u32 ring_len; /* number of descriptors, multiple of 32 */
501 u16 splithdr_enabled; /* deprecated with AVF 1.0 */
505 /* see enum virtchnl_rx_desc_ids;
506 * only used when VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC is supported. Note
507 * that when the offload is not supported, the descriptor format aligns
508 * with VIRTCHNL_RXDID_1_32B_BASE.
513 enum virtchnl_rx_hsplit rx_split_pos; /* deprecated with AVF 1.0 */
517 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_rxq_info);
519 /* VIRTCHNL_OP_CONFIG_VSI_QUEUES
520 * VF sends this message to set parameters for active TX and RX queues
521 * associated with the specified VSI.
522 * PF configures queues and returns status.
523 * If the number of queues specified is greater than the number of queues
524 * associated with the VSI, an error is returned and no queues are configured.
525 * NOTE: The VF is not required to configure all queues in a single request.
526 * It may send multiple messages. PF drivers must correctly handle all VF
529 struct virtchnl_queue_pair_info {
530 /* NOTE: vsi_id and queue_id should be identical for both queues. */
531 struct virtchnl_txq_info txq;
532 struct virtchnl_rxq_info rxq;
535 VIRTCHNL_CHECK_STRUCT_LEN(64, virtchnl_queue_pair_info);
537 struct virtchnl_vsi_queue_config_info {
541 struct virtchnl_queue_pair_info qpair[1];
544 VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_vsi_queue_config_info);
546 /* VIRTCHNL_OP_REQUEST_QUEUES
547 * VF sends this message to request the PF to allocate additional queues to
548 * this VF. Each VF gets a guaranteed number of queues on init but asking for
549 * additional queues must be negotiated. This is a best effort request as it
550 * is possible the PF does not have enough queues left to support the request.
551 * If the PF cannot support the number requested it will respond with the
552 * maximum number it is able to support. If the request is successful, PF will
553 * then reset the VF to institute required changes.
556 /* VF resource request */
557 struct virtchnl_vf_res_request {
561 /* VIRTCHNL_OP_CONFIG_IRQ_MAP
562 * VF uses this message to map vectors to queues.
563 * The rxq_map and txq_map fields are bitmaps used to indicate which queues
564 * are to be associated with the specified vector.
565 * The "other" causes are always mapped to vector 0. The VF may not request
566 * that vector 0 be used for traffic.
567 * PF configures interrupt mapping and returns status.
568 * NOTE: due to hardware requirements, all active queues (both TX and RX)
569 * should be mapped to interrupts, even if the driver intends to operate
570 * only in polling mode. In this case the interrupt may be disabled, but
571 * the ITR timer will still run to trigger writebacks.
573 struct virtchnl_vector_map {
582 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_vector_map);
584 struct virtchnl_irq_map_info {
586 struct virtchnl_vector_map vecmap[1];
589 VIRTCHNL_CHECK_STRUCT_LEN(14, virtchnl_irq_map_info);
591 /* VIRTCHNL_OP_ENABLE_QUEUES
592 * VIRTCHNL_OP_DISABLE_QUEUES
593 * VF sends these message to enable or disable TX/RX queue pairs.
594 * The queues fields are bitmaps indicating which queues to act upon.
595 * (Currently, we only support 16 queues per VF, but we make the field
596 * u32 to allow for expansion.)
597 * PF performs requested action and returns status.
598 * NOTE: The VF is not required to enable/disable all queues in a single
599 * request. It may send multiple messages.
600 * PF drivers must correctly handle all VF requests.
602 struct virtchnl_queue_select {
609 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_select);
611 /* VIRTCHNL_OP_GET_MAX_RSS_QREGION
613 * if VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
614 * then this op must be supported.
616 * VF sends this message in order to query the max RSS queue region
617 * size supported by PF, when VIRTCHNL_VF_LARGE_NUM_QPAIRS is enabled.
618 * This information should be used when configuring the RSS LUT and/or
619 * configuring queue region based filters.
621 * The maximum RSS queue region is 2^qregion_width. So, a qregion_width
622 * of 6 would inform the VF that the PF supports a maximum RSS queue region
625 * A queue region represents a range of queues that can be used to configure
626 * a RSS LUT. For example, if a VF is given 64 queues, but only a max queue
627 * region size of 16 (i.e. 2^qregion_width = 16) then it will only be able
628 * to configure the RSS LUT with queue indices from 0 to 15. However, other
629 * filters can be used to direct packets to queues >15 via specifying a queue
630 * base/offset and queue region width.
632 struct virtchnl_max_rss_qregion {
638 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_max_rss_qregion);
640 /* VIRTCHNL_OP_ADD_ETH_ADDR
641 * VF sends this message in order to add one or more unicast or multicast
642 * address filters for the specified VSI.
643 * PF adds the filters and returns status.
646 /* VIRTCHNL_OP_DEL_ETH_ADDR
647 * VF sends this message in order to remove one or more unicast or multicast
648 * filters for the specified VSI.
649 * PF removes the filters and returns status.
652 /* VIRTCHNL_ETHER_ADDR_LEGACY
653 * Prior to adding the @type member to virtchnl_ether_addr, there were 2 pad
654 * bytes. Moving forward all VF drivers should not set type to
655 * VIRTCHNL_ETHER_ADDR_LEGACY. This is only here to not break previous/legacy
656 * behavior. The control plane function (i.e. PF) can use a best effort method
657 * of tracking the primary/device unicast in this case, but there is no
658 * guarantee and functionality depends on the implementation of the PF.
661 /* VIRTCHNL_ETHER_ADDR_PRIMARY
662 * All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_PRIMARY for the
663 * primary/device unicast MAC address filter for VIRTCHNL_OP_ADD_ETH_ADDR and
664 * VIRTCHNL_OP_DEL_ETH_ADDR. This allows for the underlying control plane
665 * function (i.e. PF) to accurately track and use this MAC address for
666 * displaying on the host and for VM/function reset.
669 /* VIRTCHNL_ETHER_ADDR_EXTRA
670 * All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_EXTRA for any extra
671 * unicast and/or multicast filters that are being added/deleted via
672 * VIRTCHNL_OP_DEL_ETH_ADDR/VIRTCHNL_OP_ADD_ETH_ADDR respectively.
674 struct virtchnl_ether_addr {
675 u8 addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
677 #define VIRTCHNL_ETHER_ADDR_LEGACY 0
678 #define VIRTCHNL_ETHER_ADDR_PRIMARY 1
679 #define VIRTCHNL_ETHER_ADDR_EXTRA 2
680 #define VIRTCHNL_ETHER_ADDR_TYPE_MASK 3 /* first two bits of type are valid */
684 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_ether_addr);
686 struct virtchnl_ether_addr_list {
689 struct virtchnl_ether_addr list[1];
692 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_ether_addr_list);
694 /* VIRTCHNL_OP_ADD_VLAN
695 * VF sends this message to add one or more VLAN tag filters for receives.
696 * PF adds the filters and returns status.
697 * If a port VLAN is configured by the PF, this operation will return an
701 /* VIRTCHNL_OP_DEL_VLAN
702 * VF sends this message to remove one or more VLAN tag filters for receives.
703 * PF removes the filters and returns status.
704 * If a port VLAN is configured by the PF, this operation will return an
708 struct virtchnl_vlan_filter_list {
714 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_vlan_filter_list);
716 /* This enum is used for all of the VIRTCHNL_VF_OFFLOAD_VLAN_V2_CAPS related
717 * structures and opcodes.
719 * VIRTCHNL_VLAN_UNSUPPORTED - This field is not supported and if a VF driver
720 * populates it the PF should return VIRTCHNL_STATUS_ERR_NOT_SUPPORTED.
722 * VIRTCHNL_VLAN_ETHERTYPE_8100 - This field supports 0x8100 ethertype.
723 * VIRTCHNL_VLAN_ETHERTYPE_88A8 - This field supports 0x88A8 ethertype.
724 * VIRTCHNL_VLAN_ETHERTYPE_9100 - This field supports 0x9100 ethertype.
726 * VIRTCHNL_VLAN_ETHERTYPE_AND - Used when multiple ethertypes can be supported
727 * by the PF concurrently. For example, if the PF can support
728 * VIRTCHNL_VLAN_ETHERTYPE_8100 AND VIRTCHNL_VLAN_ETHERTYPE_88A8 filters it
729 * would OR the following bits:
731 * VIRTHCNL_VLAN_ETHERTYPE_8100 |
732 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
733 * VIRTCHNL_VLAN_ETHERTYPE_AND;
735 * The VF would interpret this as VLAN filtering can be supported on both 0x8100
736 * and 0x88A8 VLAN ethertypes.
738 * VIRTCHNL_ETHERTYPE_XOR - Used when only a single ethertype can be supported
739 * by the PF concurrently. For example if the PF can support
740 * VIRTCHNL_VLAN_ETHERTYPE_8100 XOR VIRTCHNL_VLAN_ETHERTYPE_88A8 stripping
741 * offload it would OR the following bits:
743 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
744 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
745 * VIRTCHNL_VLAN_ETHERTYPE_XOR;
747 * The VF would interpret this as VLAN stripping can be supported on either
748 * 0x8100 or 0x88a8 VLAN ethertypes. So when requesting VLAN stripping via
749 * VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 the specified ethertype will override
750 * the previously set value.
752 * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1 - Used to tell the VF to insert and/or
753 * strip the VLAN tag using the L2TAG1 field of the Tx/Rx descriptors.
755 * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 - Used to tell the VF to insert hardware
756 * offloaded VLAN tags using the L2TAG2 field of the Tx descriptor.
758 * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 - Used to tell the VF to strip hardware
759 * offloaded VLAN tags using the L2TAG2_2 field of the Rx descriptor.
761 * VIRTCHNL_VLAN_PRIO - This field supports VLAN priority bits. This is used for
762 * VLAN filtering if the underlying PF supports it.
764 * VIRTCHNL_VLAN_TOGGLE_ALLOWED - This field is used to say whether a
765 * certain VLAN capability can be toggled. For example if the underlying PF/CP
766 * allows the VF to toggle VLAN filtering, stripping, and/or insertion it should
767 * set this bit along with the supported ethertypes.
769 enum virtchnl_vlan_support {
770 VIRTCHNL_VLAN_UNSUPPORTED = 0,
771 VIRTCHNL_VLAN_ETHERTYPE_8100 = 0x00000001,
772 VIRTCHNL_VLAN_ETHERTYPE_88A8 = 0x00000002,
773 VIRTCHNL_VLAN_ETHERTYPE_9100 = 0x00000004,
774 VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1 = 0x00000100,
775 VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 = 0x00000200,
776 VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2_2 = 0x00000400,
777 VIRTCHNL_VLAN_PRIO = 0x01000000,
778 VIRTCHNL_VLAN_FILTER_MASK = 0x10000000,
779 VIRTCHNL_VLAN_ETHERTYPE_AND = 0x20000000,
780 VIRTCHNL_VLAN_ETHERTYPE_XOR = 0x40000000,
781 VIRTCHNL_VLAN_TOGGLE = 0x80000000
784 /* This structure is used as part of the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS
785 * for filtering, insertion, and stripping capabilities.
787 * If only outer capabilities are supported (for filtering, insertion, and/or
788 * stripping) then this refers to the outer most or single VLAN from the VF's
791 * If only inner capabilities are supported (for filtering, insertion, and/or
792 * stripping) then this refers to the outer most or single VLAN from the VF's
793 * perspective. Functionally this is the same as if only outer capabilities are
794 * supported. The VF driver is just forced to use the inner fields when
795 * adding/deleting filters and enabling/disabling offloads (if supported).
797 * If both outer and inner capabilities are supported (for filtering, insertion,
798 * and/or stripping) then outer refers to the outer most or single VLAN and
799 * inner refers to the second VLAN, if it exists, in the packet.
801 * There is no support for tunneled VLAN offloads, so outer or inner are never
802 * referring to a tunneled packet from the VF's perspective.
804 struct virtchnl_vlan_supported_caps {
809 /* The PF populates these fields based on the supported VLAN filtering. If a
810 * field is VIRTCHNL_VLAN_UNSUPPORTED then it's not supported and the PF will
811 * reject any VIRTCHNL_OP_ADD_VLAN_V2 or VIRTCHNL_OP_DEL_VLAN_V2 messages using
812 * the unsupported fields.
814 * Also, a VF is only allowed to toggle its VLAN filtering setting if the
815 * VIRTCHNL_VLAN_TOGGLE bit is set.
817 * The ethertype(s) specified in the ethertype_init field are the ethertypes
818 * enabled for VLAN filtering. VLAN filtering in this case refers to the outer
819 * most VLAN from the VF's perspective. If both inner and outer filtering are
820 * allowed then ethertype_init only refers to the outer most VLAN as only
821 * VLAN ethertype supported for inner VLAN filtering is
822 * VIRTCHNL_VLAN_ETHERTYPE_8100. By default, inner VLAN filtering is disabled
823 * when both inner and outer filtering are allowed.
825 * The max_filters field tells the VF how many VLAN filters it's allowed to have
826 * at any one time. If it exceeds this amount and tries to add another filter,
827 * then the request will be rejected by the PF. To prevent failures, the VF
828 * should keep track of how many VLAN filters it has added and not attempt to
829 * add more than max_filters.
831 struct virtchnl_vlan_filtering_caps {
832 struct virtchnl_vlan_supported_caps filtering_support;
838 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vlan_filtering_caps);
840 /* This enum is used for the virtchnl_vlan_offload_caps structure to specify
841 * if the PF supports a different ethertype for stripping and insertion.
843 * VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION - The ethertype(s) specified
844 * for stripping affect the ethertype(s) specified for insertion and visa versa
845 * as well. If the VF tries to configure VLAN stripping via
846 * VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 with VIRTCHNL_VLAN_ETHERTYPE_8100 then
847 * that will be the ethertype for both stripping and insertion.
849 * VIRTCHNL_ETHERTYPE_MATCH_NOT_REQUIRED - The ethertype(s) specified for
850 * stripping do not affect the ethertype(s) specified for insertion and visa
853 enum virtchnl_vlan_ethertype_match {
854 VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION = 0,
855 VIRTCHNL_ETHERTYPE_MATCH_NOT_REQUIRED = 1,
858 /* The PF populates these fields based on the supported VLAN offloads. If a
859 * field is VIRTCHNL_VLAN_UNSUPPORTED then it's not supported and the PF will
860 * reject any VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 or
861 * VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 messages using the unsupported fields.
863 * Also, a VF is only allowed to toggle its VLAN offload setting if the
864 * VIRTCHNL_VLAN_TOGGLE_ALLOWED bit is set.
866 * The VF driver needs to be aware of how the tags are stripped by hardware and
867 * inserted by the VF driver based on the level of offload support. The PF will
868 * populate these fields based on where the VLAN tags are expected to be
869 * offloaded via the VIRTHCNL_VLAN_TAG_LOCATION_* bits. The VF will need to
870 * interpret these fields. See the definition of the
871 * VIRTCHNL_VLAN_TAG_LOCATION_* bits above the virtchnl_vlan_support
874 struct virtchnl_vlan_offload_caps {
875 struct virtchnl_vlan_supported_caps stripping_support;
876 struct virtchnl_vlan_supported_caps insertion_support;
882 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_vlan_offload_caps);
884 /* VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS
885 * VF sends this message to determine its VLAN capabilities.
887 * PF will mark which capabilities it supports based on hardware support and
888 * current configuration. For example, if a port VLAN is configured the PF will
889 * not allow outer VLAN filtering, stripping, or insertion to be configured so
890 * it will block these features from the VF.
892 * The VF will need to cross reference its capabilities with the PFs
893 * capabilities in the response message from the PF to determine the VLAN
896 struct virtchnl_vlan_caps {
897 struct virtchnl_vlan_filtering_caps filtering;
898 struct virtchnl_vlan_offload_caps offloads;
901 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_vlan_caps);
903 struct virtchnl_vlan {
904 u16 tci; /* tci[15:13] = PCP and tci[11:0] = VID */
905 u16 tci_mask; /* only valid if VIRTCHNL_VLAN_FILTER_MASK set in
908 u16 tpid; /* 0x8100, 0x88a8, etc. and only type(s) set in
909 * filtering caps. Note that tpid here does not refer to
910 * VIRTCHNL_VLAN_ETHERTYPE_*, but it refers to the
911 * actual 2-byte VLAN TPID
916 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_vlan);
918 struct virtchnl_vlan_filter {
919 struct virtchnl_vlan inner;
920 struct virtchnl_vlan outer;
924 VIRTCHNL_CHECK_STRUCT_LEN(32, virtchnl_vlan_filter);
926 /* VIRTCHNL_OP_ADD_VLAN_V2
927 * VIRTCHNL_OP_DEL_VLAN_V2
929 * VF sends these messages to add/del one or more VLAN tag filters for Rx
932 * The PF attempts to add the filters and returns status.
934 * The VF should only ever attempt to add/del virtchnl_vlan_filter(s) using the
935 * supported fields negotiated via VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS.
937 struct virtchnl_vlan_filter_list_v2 {
941 struct virtchnl_vlan_filter filters[1];
944 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_vlan_filter_list_v2);
946 /* VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2
947 * VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2
948 * VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2
949 * VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2
951 * VF sends this message to enable or disable VLAN stripping or insertion. It
952 * also needs to specify an ethertype. The VF knows which VLAN ethertypes are
953 * allowed and whether or not it's allowed to enable/disable the specific
954 * offload via the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS message. The VF needs to
955 * parse the virtchnl_vlan_caps.offloads fields to determine which offload
956 * messages are allowed.
958 * For example, if the PF populates the virtchnl_vlan_caps.offloads in the
959 * following manner the VF will be allowed to enable and/or disable 0x8100 inner
960 * VLAN insertion and/or stripping via the opcodes listed above. Inner in this
961 * case means the outer most or single VLAN from the VF's perspective. This is
962 * because no outer offloads are supported. See the comments above the
963 * virtchnl_vlan_supported_caps structure for more details.
965 * virtchnl_vlan_caps.offloads.stripping_support.inner =
966 * VIRTCHNL_VLAN_TOGGLE |
967 * VIRTCHNL_VLAN_ETHERTYPE_8100;
969 * virtchnl_vlan_caps.offloads.insertion_support.inner =
970 * VIRTCHNL_VLAN_TOGGLE |
971 * VIRTCHNL_VLAN_ETHERTYPE_8100;
973 * In order to enable inner (again note that in this case inner is the outer
974 * most or single VLAN from the VF's perspective) VLAN stripping for 0x8100
975 * VLANs, the VF would populate the virtchnl_vlan_setting structure in the
976 * following manner and send the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 message.
978 * virtchnl_vlan_setting.inner_ethertype_setting =
979 * VIRTCHNL_VLAN_ETHERTYPE_8100;
981 * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on
984 * The reason that VLAN TPID(s) are not being used for the
985 * outer_ethertype_setting and inner_ethertype_setting fields is because it's
986 * possible a device could support VLAN insertion and/or stripping offload on
987 * multiple ethertypes concurrently, so this method allows a VF to request
988 * multiple ethertypes in one message using the virtchnl_vlan_support
991 * For example, if the PF populates the virtchnl_vlan_caps.offloads in the
992 * following manner the VF will be allowed to enable 0x8100 and 0x88a8 outer
993 * VLAN insertion and stripping simultaneously. The
994 * virtchnl_vlan_caps.offloads.ethertype_match field will also have to be
995 * populated based on what the PF can support.
997 * virtchnl_vlan_caps.offloads.stripping_support.outer =
998 * VIRTCHNL_VLAN_TOGGLE |
999 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1000 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
1001 * VIRTCHNL_VLAN_ETHERTYPE_AND;
1003 * virtchnl_vlan_caps.offloads.insertion_support.outer =
1004 * VIRTCHNL_VLAN_TOGGLE |
1005 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1006 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
1007 * VIRTCHNL_VLAN_ETHERTYPE_AND;
1009 * In order to enable outer VLAN stripping for 0x8100 and 0x88a8 VLANs, the VF
1010 * would populate the virthcnl_vlan_offload_structure in the following manner
1011 * and send the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 message.
1013 * virtchnl_vlan_setting.outer_ethertype_setting =
1014 * VIRTHCNL_VLAN_ETHERTYPE_8100 |
1015 * VIRTHCNL_VLAN_ETHERTYPE_88A8;
1017 * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on
1020 * There is also the case where a PF and the underlying hardware can support
1021 * VLAN offloads on multiple ethertypes, but not concurrently. For example, if
1022 * the PF populates the virtchnl_vlan_caps.offloads in the following manner the
1023 * VF will be allowed to enable and/or disable 0x8100 XOR 0x88a8 outer VLAN
1024 * offloads. The ethertypes must match for stripping and insertion.
1026 * virtchnl_vlan_caps.offloads.stripping_support.outer =
1027 * VIRTCHNL_VLAN_TOGGLE |
1028 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1029 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
1030 * VIRTCHNL_VLAN_ETHERTYPE_XOR;
1032 * virtchnl_vlan_caps.offloads.insertion_support.outer =
1033 * VIRTCHNL_VLAN_TOGGLE |
1034 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1035 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
1036 * VIRTCHNL_VLAN_ETHERTYPE_XOR;
1038 * virtchnl_vlan_caps.offloads.ethertype_match =
1039 * VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION;
1041 * In order to enable outer VLAN stripping for 0x88a8 VLANs, the VF would
1042 * populate the virtchnl_vlan_setting structure in the following manner and send
1043 * the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2. Also, this will change the
1044 * ethertype for VLAN insertion if it's enabled. So, for completeness, a
1045 * VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 with the same ethertype should be sent.
1047 * virtchnl_vlan_setting.outer_ethertype_setting = VIRTHCNL_VLAN_ETHERTYPE_88A8;
1049 * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on
1052 * VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2
1053 * VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2
1055 * VF sends this message to enable or disable VLAN filtering. It also needs to
1056 * specify an ethertype. The VF knows which VLAN ethertypes are allowed and
1057 * whether or not it's allowed to enable/disable filtering via the
1058 * VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS message. The VF needs to
1059 * parse the virtchnl_vlan_caps.filtering fields to determine which, if any,
1060 * filtering messages are allowed.
1062 * For example, if the PF populates the virtchnl_vlan_caps.filtering in the
1063 * following manner the VF will be allowed to enable/disable 0x8100 and 0x88a8
1064 * outer VLAN filtering together. Note, that the VIRTCHNL_VLAN_ETHERTYPE_AND
1065 * means that all filtering ethertypes will to be enabled and disabled together
1066 * regardless of the request from the VF. This means that the underlying
1067 * hardware only supports VLAN filtering for all VLAN the specified ethertypes
1070 * virtchnl_vlan_caps.filtering.filtering_support.outer =
1071 * VIRTCHNL_VLAN_TOGGLE |
1072 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1073 * VIRTHCNL_VLAN_ETHERTYPE_88A8 |
1074 * VIRTCHNL_VLAN_ETHERTYPE_9100 |
1075 * VIRTCHNL_VLAN_ETHERTYPE_AND;
1077 * In order to enable outer VLAN filtering for 0x88a8 and 0x8100 VLANs (0x9100
1078 * VLANs aren't supported by the VF driver), the VF would populate the
1079 * virtchnl_vlan_setting structure in the following manner and send the
1080 * VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2. The same message format would be used
1081 * to disable outer VLAN filtering for 0x88a8 and 0x8100 VLANs, but the
1082 * VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2 opcode is used.
1084 * virtchnl_vlan_setting.outer_ethertype_setting =
1085 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1086 * VIRTCHNL_VLAN_ETHERTYPE_88A8;
1089 struct virtchnl_vlan_setting {
1090 u32 outer_ethertype_setting;
1091 u32 inner_ethertype_setting;
1096 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vlan_setting);
1098 /* VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE
1099 * VF sends VSI id and flags.
1100 * PF returns status code in retval.
1101 * Note: we assume that broadcast accept mode is always enabled.
1103 struct virtchnl_promisc_info {
1108 VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_promisc_info);
1110 #define FLAG_VF_UNICAST_PROMISC 0x00000001
1111 #define FLAG_VF_MULTICAST_PROMISC 0x00000002
1113 /* VIRTCHNL_OP_GET_STATS
1114 * VF sends this message to request stats for the selected VSI. VF uses
1115 * the virtchnl_queue_select struct to specify the VSI. The queue_id
1116 * field is ignored by the PF.
1118 * PF replies with struct virtchnl_eth_stats in an external buffer.
1121 struct virtchnl_eth_stats {
1122 u64 rx_bytes; /* received bytes */
1123 u64 rx_unicast; /* received unicast pkts */
1124 u64 rx_multicast; /* received multicast pkts */
1125 u64 rx_broadcast; /* received broadcast pkts */
1127 u64 rx_unknown_protocol;
1128 u64 tx_bytes; /* transmitted bytes */
1129 u64 tx_unicast; /* transmitted unicast pkts */
1130 u64 tx_multicast; /* transmitted multicast pkts */
1131 u64 tx_broadcast; /* transmitted broadcast pkts */
1136 /* VIRTCHNL_OP_CONFIG_RSS_KEY
1137 * VIRTCHNL_OP_CONFIG_RSS_LUT
1138 * VF sends these messages to configure RSS. Only supported if both PF
1139 * and VF drivers set the VIRTCHNL_VF_OFFLOAD_RSS_PF bit during
1140 * configuration negotiation. If this is the case, then the RSS fields in
1141 * the VF resource struct are valid.
1142 * Both the key and LUT are initialized to 0 by the PF, meaning that
1143 * RSS is effectively disabled until set up by the VF.
1145 struct virtchnl_rss_key {
1148 u8 key[1]; /* RSS hash key, packed bytes */
1151 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_rss_key);
1153 struct virtchnl_rss_lut {
1156 u8 lut[1]; /* RSS lookup table */
1159 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_rss_lut);
1161 /* VIRTCHNL_OP_GET_RSS_HENA_CAPS
1162 * VIRTCHNL_OP_SET_RSS_HENA
1163 * VF sends these messages to get and set the hash filter enable bits for RSS.
1164 * By default, the PF sets these to all possible traffic types that the
1165 * hardware supports. The VF can query this value if it wants to change the
1166 * traffic types that are hashed by the hardware.
1168 struct virtchnl_rss_hena {
1172 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_rss_hena);
1174 /* Type of RSS algorithm */
1175 enum virtchnl_rss_algorithm {
1176 VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC = 0,
1177 VIRTCHNL_RSS_ALG_XOR_ASYMMETRIC = 1,
1178 VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC = 2,
1179 VIRTCHNL_RSS_ALG_XOR_SYMMETRIC = 3,
1182 /* This is used by PF driver to enforce how many channels can be supported.
1183 * When ADQ_V2 capability is negotiated, it will allow 16 channels otherwise
1184 * PF driver will allow only max 4 channels
1186 #define VIRTCHNL_MAX_ADQ_CHANNELS 4
1187 #define VIRTCHNL_MAX_ADQ_V2_CHANNELS 16
1189 /* VIRTCHNL_OP_ENABLE_CHANNELS
1190 * VIRTCHNL_OP_DISABLE_CHANNELS
1191 * VF sends these messages to enable or disable channels based on
1192 * the user specified queue count and queue offset for each traffic class.
1193 * This struct encompasses all the information that the PF needs from
1194 * VF to create a channel.
1196 struct virtchnl_channel_info {
1197 u16 count; /* number of queues in a channel */
1198 u16 offset; /* queues in a channel start from 'offset' */
1203 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_channel_info);
1205 struct virtchnl_tc_info {
1208 struct virtchnl_channel_info list[1];
1211 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_tc_info);
1213 /* VIRTCHNL_ADD_CLOUD_FILTER
1214 * VIRTCHNL_DEL_CLOUD_FILTER
1215 * VF sends these messages to add or delete a cloud filter based on the
1216 * user specified match and action filters. These structures encompass
1217 * all the information that the PF needs from the VF to add/delete a
1221 struct virtchnl_l4_spec {
1222 u8 src_mac[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
1223 u8 dst_mac[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
1224 /* vlan_prio is part of this 16 bit field even from OS perspective
1225 * vlan_id:12 is actual vlan_id, then vlanid:bit14..12 is vlan_prio
1226 * in future, when decided to offload vlan_prio, pass that information
1227 * as part of the "vlan_id" field, Bit14..12
1230 __be16 pad; /* reserved for future use */
1237 VIRTCHNL_CHECK_STRUCT_LEN(52, virtchnl_l4_spec);
1239 union virtchnl_flow_spec {
1240 struct virtchnl_l4_spec tcp_spec;
1241 u8 buffer[128]; /* reserved for future use */
1244 VIRTCHNL_CHECK_UNION_LEN(128, virtchnl_flow_spec);
1246 enum virtchnl_action {
1248 VIRTCHNL_ACTION_DROP = 0,
1249 VIRTCHNL_ACTION_TC_REDIRECT,
1250 VIRTCHNL_ACTION_PASSTHRU,
1251 VIRTCHNL_ACTION_QUEUE,
1252 VIRTCHNL_ACTION_Q_REGION,
1253 VIRTCHNL_ACTION_MARK,
1254 VIRTCHNL_ACTION_COUNT,
1257 enum virtchnl_flow_type {
1259 VIRTCHNL_TCP_V4_FLOW = 0,
1260 VIRTCHNL_TCP_V6_FLOW,
1261 VIRTCHNL_UDP_V4_FLOW,
1262 VIRTCHNL_UDP_V6_FLOW,
1265 struct virtchnl_filter {
1266 union virtchnl_flow_spec data;
1267 union virtchnl_flow_spec mask;
1268 enum virtchnl_flow_type flow_type;
1269 enum virtchnl_action action;
1274 VIRTCHNL_CHECK_STRUCT_LEN(272, virtchnl_filter);
1276 /* VIRTCHNL_OP_DCF_GET_VSI_MAP
1277 * VF sends this message to get VSI mapping table.
1278 * PF responds with an indirect message containing VF's
1280 * The index of vf_vsi array is the logical VF ID, the
1281 * value of vf_vsi array is the VF's HW VSI ID with its
1282 * valid configuration.
1284 struct virtchnl_dcf_vsi_map {
1285 u16 pf_vsi; /* PF's HW VSI ID */
1286 u16 num_vfs; /* The actual number of VFs allocated */
1287 #define VIRTCHNL_DCF_VF_VSI_ID_S 0
1288 #define VIRTCHNL_DCF_VF_VSI_ID_M (0xFFF << VIRTCHNL_DCF_VF_VSI_ID_S)
1289 #define VIRTCHNL_DCF_VF_VSI_VALID BIT(15)
1293 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_dcf_vsi_map);
1295 #define PKG_NAME_SIZE 32
1298 struct pkg_version {
1305 VIRTCHNL_CHECK_STRUCT_LEN(4, pkg_version);
1307 struct virtchnl_pkg_info {
1308 struct pkg_version pkg_ver;
1310 char pkg_name[PKG_NAME_SIZE];
1314 VIRTCHNL_CHECK_STRUCT_LEN(48, virtchnl_pkg_info);
1316 /* VIRTCHNL_OP_DCF_VLAN_OFFLOAD
1317 * DCF negotiates the VIRTCHNL_VF_OFFLOAD_VLAN_V2 capability firstly to get
1318 * the double VLAN configuration, then DCF sends this message to configure the
1319 * outer or inner VLAN offloads (insertion and strip) for the target VF.
1321 struct virtchnl_dcf_vlan_offload {
1325 #define VIRTCHNL_DCF_VLAN_TYPE_S 0
1326 #define VIRTCHNL_DCF_VLAN_TYPE_M \
1327 (0x1 << VIRTCHNL_DCF_VLAN_TYPE_S)
1328 #define VIRTCHNL_DCF_VLAN_TYPE_INNER 0x0
1329 #define VIRTCHNL_DCF_VLAN_TYPE_OUTER 0x1
1330 #define VIRTCHNL_DCF_VLAN_INSERT_MODE_S 1
1331 #define VIRTCHNL_DCF_VLAN_INSERT_MODE_M \
1332 (0x7 << VIRTCHNL_DCF_VLAN_INSERT_MODE_S)
1333 #define VIRTCHNL_DCF_VLAN_INSERT_DISABLE 0x1
1334 #define VIRTCHNL_DCF_VLAN_INSERT_PORT_BASED 0x2
1335 #define VIRTCHNL_DCF_VLAN_INSERT_VIA_TX_DESC 0x3
1336 #define VIRTCHNL_DCF_VLAN_STRIP_MODE_S 4
1337 #define VIRTCHNL_DCF_VLAN_STRIP_MODE_M \
1338 (0x7 << VIRTCHNL_DCF_VLAN_STRIP_MODE_S)
1339 #define VIRTCHNL_DCF_VLAN_STRIP_DISABLE 0x1
1340 #define VIRTCHNL_DCF_VLAN_STRIP_ONLY 0x2
1341 #define VIRTCHNL_DCF_VLAN_STRIP_INTO_RX_DESC 0x3
1346 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_dcf_vlan_offload);
1348 struct virtchnl_supported_rxdids {
1349 /* see enum virtchnl_rx_desc_id_bitmasks */
1350 u64 supported_rxdids;
1353 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_supported_rxdids);
1355 /* VIRTCHNL_OP_EVENT
1356 * PF sends this message to inform the VF driver of events that may affect it.
1357 * No direct response is expected from the VF, though it may generate other
1358 * messages in response to this one.
1360 enum virtchnl_event_codes {
1361 VIRTCHNL_EVENT_UNKNOWN = 0,
1362 VIRTCHNL_EVENT_LINK_CHANGE,
1363 VIRTCHNL_EVENT_RESET_IMPENDING,
1364 VIRTCHNL_EVENT_PF_DRIVER_CLOSE,
1365 VIRTCHNL_EVENT_DCF_VSI_MAP_UPDATE,
1368 #define PF_EVENT_SEVERITY_INFO 0
1369 #define PF_EVENT_SEVERITY_ATTENTION 1
1370 #define PF_EVENT_SEVERITY_ACTION_REQUIRED 2
1371 #define PF_EVENT_SEVERITY_CERTAIN_DOOM 255
1373 struct virtchnl_pf_event {
1374 enum virtchnl_event_codes event;
1376 /* If the PF driver does not support the new speed reporting
1377 * capabilities then use link_event else use link_event_adv to
1378 * get the speed and link information. The ability to understand
1379 * new speeds is indicated by setting the capability flag
1380 * VIRTCHNL_VF_CAP_ADV_LINK_SPEED in vf_cap_flags parameter
1381 * in virtchnl_vf_resource struct and can be used to determine
1382 * which link event struct to use below.
1385 enum virtchnl_link_speed link_speed;
1389 /* link_speed provided in Mbps */
1402 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_pf_event);
1405 /* VF reset states - these are written into the RSTAT register:
1406 * VFGEN_RSTAT on the VF
1407 * When the PF initiates a reset, it writes 0
1408 * When the reset is complete, it writes 1
1409 * When the PF detects that the VF has recovered, it writes 2
1410 * VF checks this register periodically to determine if a reset has occurred,
1411 * then polls it to know when the reset is complete.
1412 * If either the PF or VF reads the register while the hardware
1413 * is in a reset state, it will return DEADBEEF, which, when masked
1416 enum virtchnl_vfr_states {
1417 VIRTCHNL_VFR_INPROGRESS = 0,
1418 VIRTCHNL_VFR_COMPLETED,
1419 VIRTCHNL_VFR_VFACTIVE,
1422 #define VIRTCHNL_MAX_NUM_PROTO_HDRS 32
1423 #define PROTO_HDR_SHIFT 5
1424 #define PROTO_HDR_FIELD_START(proto_hdr_type) \
1425 (proto_hdr_type << PROTO_HDR_SHIFT)
1426 #define PROTO_HDR_FIELD_MASK ((1UL << PROTO_HDR_SHIFT) - 1)
1428 /* VF use these macros to configure each protocol header.
1429 * Specify which protocol headers and protocol header fields base on
1430 * virtchnl_proto_hdr_type and virtchnl_proto_hdr_field.
1431 * @param hdr: a struct of virtchnl_proto_hdr
1432 * @param hdr_type: ETH/IPV4/TCP, etc
1433 * @param field: SRC/DST/TEID/SPI, etc
1435 #define VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, field) \
1436 ((hdr)->field_selector |= BIT((field) & PROTO_HDR_FIELD_MASK))
1437 #define VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, field) \
1438 ((hdr)->field_selector &= ~BIT((field) & PROTO_HDR_FIELD_MASK))
1439 #define VIRTCHNL_TEST_PROTO_HDR_FIELD(hdr, val) \
1440 ((hdr)->field_selector & BIT((val) & PROTO_HDR_FIELD_MASK))
1441 #define VIRTCHNL_GET_PROTO_HDR_FIELD(hdr) ((hdr)->field_selector)
1443 #define VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \
1444 (VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, \
1445 VIRTCHNL_PROTO_HDR_ ## hdr_type ## _ ## field))
1446 #define VIRTCHNL_DEL_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \
1447 (VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, \
1448 VIRTCHNL_PROTO_HDR_ ## hdr_type ## _ ## field))
1450 #define VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, hdr_type) \
1451 ((hdr)->type = VIRTCHNL_PROTO_HDR_ ## hdr_type)
1452 #define VIRTCHNL_GET_PROTO_HDR_TYPE(hdr) \
1453 (((hdr)->type) >> PROTO_HDR_SHIFT)
1454 #define VIRTCHNL_TEST_PROTO_HDR_TYPE(hdr, val) \
1455 ((hdr)->type == ((val) >> PROTO_HDR_SHIFT))
1456 #define VIRTCHNL_TEST_PROTO_HDR(hdr, val) \
1457 (VIRTCHNL_TEST_PROTO_HDR_TYPE(hdr, val) && \
1458 VIRTCHNL_TEST_PROTO_HDR_FIELD(hdr, val))
1460 /* Protocol header type within a packet segment. A segment consists of one or
1461 * more protocol headers that make up a logical group of protocol headers. Each
1462 * logical group of protocol headers encapsulates or is encapsulated using/by
1463 * tunneling or encapsulation protocols for network virtualization.
1465 enum virtchnl_proto_hdr_type {
1466 VIRTCHNL_PROTO_HDR_NONE,
1467 VIRTCHNL_PROTO_HDR_ETH,
1468 VIRTCHNL_PROTO_HDR_S_VLAN,
1469 VIRTCHNL_PROTO_HDR_C_VLAN,
1470 VIRTCHNL_PROTO_HDR_IPV4,
1471 VIRTCHNL_PROTO_HDR_IPV4_FRAG,
1472 VIRTCHNL_PROTO_HDR_IPV6,
1473 VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG,
1474 VIRTCHNL_PROTO_HDR_TCP,
1475 VIRTCHNL_PROTO_HDR_UDP,
1476 VIRTCHNL_PROTO_HDR_SCTP,
1477 VIRTCHNL_PROTO_HDR_GTPU_IP,
1478 VIRTCHNL_PROTO_HDR_GTPU_EH,
1479 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN,
1480 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP,
1481 VIRTCHNL_PROTO_HDR_PPPOE,
1482 VIRTCHNL_PROTO_HDR_L2TPV3,
1483 VIRTCHNL_PROTO_HDR_ESP,
1484 VIRTCHNL_PROTO_HDR_AH,
1485 VIRTCHNL_PROTO_HDR_PFCP,
1486 VIRTCHNL_PROTO_HDR_GTPC,
1487 VIRTCHNL_PROTO_HDR_ECPRI,
1488 VIRTCHNL_PROTO_HDR_L2TPV2,
1489 VIRTCHNL_PROTO_HDR_PPP,
1492 /* Protocol header field within a protocol header. */
1493 enum virtchnl_proto_hdr_field {
1495 VIRTCHNL_PROTO_HDR_ETH_SRC =
1496 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ETH),
1497 VIRTCHNL_PROTO_HDR_ETH_DST,
1498 VIRTCHNL_PROTO_HDR_ETH_ETHERTYPE,
1500 VIRTCHNL_PROTO_HDR_S_VLAN_ID =
1501 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_S_VLAN),
1503 VIRTCHNL_PROTO_HDR_C_VLAN_ID =
1504 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_C_VLAN),
1506 VIRTCHNL_PROTO_HDR_IPV4_SRC =
1507 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV4),
1508 VIRTCHNL_PROTO_HDR_IPV4_DST,
1509 VIRTCHNL_PROTO_HDR_IPV4_DSCP,
1510 VIRTCHNL_PROTO_HDR_IPV4_TTL,
1511 VIRTCHNL_PROTO_HDR_IPV4_PROT,
1512 VIRTCHNL_PROTO_HDR_IPV4_FRAG_PKID =
1513 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV4_FRAG),
1515 VIRTCHNL_PROTO_HDR_IPV6_SRC =
1516 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV6),
1517 VIRTCHNL_PROTO_HDR_IPV6_DST,
1518 VIRTCHNL_PROTO_HDR_IPV6_TC,
1519 VIRTCHNL_PROTO_HDR_IPV6_HOP_LIMIT,
1520 VIRTCHNL_PROTO_HDR_IPV6_PROT,
1522 VIRTCHNL_PROTO_HDR_IPV6_PREFIX32_SRC,
1523 VIRTCHNL_PROTO_HDR_IPV6_PREFIX32_DST,
1524 VIRTCHNL_PROTO_HDR_IPV6_PREFIX40_SRC,
1525 VIRTCHNL_PROTO_HDR_IPV6_PREFIX40_DST,
1526 VIRTCHNL_PROTO_HDR_IPV6_PREFIX48_SRC,
1527 VIRTCHNL_PROTO_HDR_IPV6_PREFIX48_DST,
1528 VIRTCHNL_PROTO_HDR_IPV6_PREFIX56_SRC,
1529 VIRTCHNL_PROTO_HDR_IPV6_PREFIX56_DST,
1530 VIRTCHNL_PROTO_HDR_IPV6_PREFIX64_SRC,
1531 VIRTCHNL_PROTO_HDR_IPV6_PREFIX64_DST,
1532 VIRTCHNL_PROTO_HDR_IPV6_PREFIX96_SRC,
1533 VIRTCHNL_PROTO_HDR_IPV6_PREFIX96_DST,
1534 /* IPv6 Extension Header Fragment */
1535 VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG_PKID =
1536 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG),
1538 VIRTCHNL_PROTO_HDR_TCP_SRC_PORT =
1539 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_TCP),
1540 VIRTCHNL_PROTO_HDR_TCP_DST_PORT,
1542 VIRTCHNL_PROTO_HDR_UDP_SRC_PORT =
1543 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_UDP),
1544 VIRTCHNL_PROTO_HDR_UDP_DST_PORT,
1546 VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT =
1547 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_SCTP),
1548 VIRTCHNL_PROTO_HDR_SCTP_DST_PORT,
1550 VIRTCHNL_PROTO_HDR_GTPU_IP_TEID =
1551 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_IP),
1553 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU =
1554 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH),
1555 VIRTCHNL_PROTO_HDR_GTPU_EH_QFI,
1557 VIRTCHNL_PROTO_HDR_PPPOE_SESS_ID =
1558 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_PPPOE),
1560 VIRTCHNL_PROTO_HDR_L2TPV3_SESS_ID =
1561 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_L2TPV3),
1563 VIRTCHNL_PROTO_HDR_ESP_SPI =
1564 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ESP),
1566 VIRTCHNL_PROTO_HDR_AH_SPI =
1567 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_AH),
1569 VIRTCHNL_PROTO_HDR_PFCP_S_FIELD =
1570 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_PFCP),
1571 VIRTCHNL_PROTO_HDR_PFCP_SEID,
1573 VIRTCHNL_PROTO_HDR_GTPC_TEID =
1574 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPC),
1576 VIRTCHNL_PROTO_HDR_ECPRI_MSG_TYPE =
1577 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ECPRI),
1578 VIRTCHNL_PROTO_HDR_ECPRI_PC_RTC_ID,
1581 struct virtchnl_proto_hdr {
1582 enum virtchnl_proto_hdr_type type;
1583 u32 field_selector; /* a bit mask to select field for header type */
1586 * binary buffer in network order for specific header type.
1587 * For example, if type = VIRTCHNL_PROTO_HDR_IPV4, a IPv4
1588 * header is expected to be copied into the buffer.
1592 VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_proto_hdr);
1594 struct virtchnl_proto_hdrs {
1597 * specify where protocol header start from.
1598 * 0 - from the outer layer
1599 * 1 - from the first inner layer
1600 * 2 - from the second inner layer
1603 int count; /* the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS */
1604 struct virtchnl_proto_hdr proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
1607 VIRTCHNL_CHECK_STRUCT_LEN(2312, virtchnl_proto_hdrs);
1609 struct virtchnl_rss_cfg {
1610 struct virtchnl_proto_hdrs proto_hdrs; /* protocol headers */
1611 enum virtchnl_rss_algorithm rss_algorithm; /* rss algorithm type */
1612 u8 reserved[128]; /* reserve for future */
1615 VIRTCHNL_CHECK_STRUCT_LEN(2444, virtchnl_rss_cfg);
1617 /* action configuration for FDIR */
1618 struct virtchnl_filter_action {
1619 enum virtchnl_action type;
1621 /* used for queue and qgroup action */
1626 /* used for count action */
1628 /* share counter ID with other flow rules */
1630 u32 id; /* counter ID */
1632 /* used for mark action */
1638 VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_filter_action);
1640 #define VIRTCHNL_MAX_NUM_ACTIONS 8
1642 struct virtchnl_filter_action_set {
1643 /* action number must be less then VIRTCHNL_MAX_NUM_ACTIONS */
1645 struct virtchnl_filter_action actions[VIRTCHNL_MAX_NUM_ACTIONS];
1648 VIRTCHNL_CHECK_STRUCT_LEN(292, virtchnl_filter_action_set);
1650 /* pattern and action for FDIR rule */
1651 struct virtchnl_fdir_rule {
1652 struct virtchnl_proto_hdrs proto_hdrs;
1653 struct virtchnl_filter_action_set action_set;
1656 VIRTCHNL_CHECK_STRUCT_LEN(2604, virtchnl_fdir_rule);
1658 /* query information to retrieve fdir rule counters.
1659 * PF will fill out this structure to reset counter.
1661 struct virtchnl_fdir_query_info {
1662 u32 match_packets_valid:1;
1663 u32 match_bytes_valid:1;
1664 u32 reserved:30; /* Reserved, must be zero. */
1666 u64 matched_packets; /* Number of packets for this rule. */
1667 u64 matched_bytes; /* Number of bytes through this rule. */
1670 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_fdir_query_info);
1672 /* Status returned to VF after VF requests FDIR commands
1673 * VIRTCHNL_FDIR_SUCCESS
1674 * VF FDIR related request is successfully done by PF
1675 * The request can be OP_ADD/DEL/QUERY_FDIR_FILTER.
1677 * VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE
1678 * OP_ADD_FDIR_FILTER request is failed due to no Hardware resource.
1680 * VIRTCHNL_FDIR_FAILURE_RULE_EXIST
1681 * OP_ADD_FDIR_FILTER request is failed due to the rule is already existed.
1683 * VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT
1684 * OP_ADD_FDIR_FILTER request is failed due to conflict with existing rule.
1686 * VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST
1687 * OP_DEL_FDIR_FILTER request is failed due to this rule doesn't exist.
1689 * VIRTCHNL_FDIR_FAILURE_RULE_INVALID
1690 * OP_ADD_FDIR_FILTER request is failed due to parameters validation
1691 * or HW doesn't support.
1693 * VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT
1694 * OP_ADD/DEL_FDIR_FILTER request is failed due to timing out
1697 * VIRTCHNL_FDIR_FAILURE_QUERY_INVALID
1698 * OP_QUERY_FDIR_FILTER request is failed due to parameters validation,
1699 * for example, VF query counter of a rule who has no counter action.
1701 enum virtchnl_fdir_prgm_status {
1702 VIRTCHNL_FDIR_SUCCESS = 0,
1703 VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE,
1704 VIRTCHNL_FDIR_FAILURE_RULE_EXIST,
1705 VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT,
1706 VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST,
1707 VIRTCHNL_FDIR_FAILURE_RULE_INVALID,
1708 VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT,
1709 VIRTCHNL_FDIR_FAILURE_QUERY_INVALID,
1712 /* VIRTCHNL_OP_ADD_FDIR_FILTER
1713 * VF sends this request to PF by filling out vsi_id,
1714 * validate_only and rule_cfg. PF will return flow_id
1715 * if the request is successfully done and return add_status to VF.
1717 struct virtchnl_fdir_add {
1718 u16 vsi_id; /* INPUT */
1720 * 1 for validating a fdir rule, 0 for creating a fdir rule.
1721 * Validate and create share one ops: VIRTCHNL_OP_ADD_FDIR_FILTER.
1723 u16 validate_only; /* INPUT */
1724 u32 flow_id; /* OUTPUT */
1725 struct virtchnl_fdir_rule rule_cfg; /* INPUT */
1726 enum virtchnl_fdir_prgm_status status; /* OUTPUT */
1729 VIRTCHNL_CHECK_STRUCT_LEN(2616, virtchnl_fdir_add);
1731 /* VIRTCHNL_OP_DEL_FDIR_FILTER
1732 * VF sends this request to PF by filling out vsi_id
1733 * and flow_id. PF will return del_status to VF.
1735 struct virtchnl_fdir_del {
1736 u16 vsi_id; /* INPUT */
1738 u32 flow_id; /* INPUT */
1739 enum virtchnl_fdir_prgm_status status; /* OUTPUT */
1742 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del);
1744 /* VIRTCHNL_OP_QUERY_FDIR_FILTER
1745 * VF sends this request to PF by filling out vsi_id,
1746 * flow_id and reset_counter. PF will return query_info
1747 * and query_status to VF.
1749 struct virtchnl_fdir_query {
1750 u16 vsi_id; /* INPUT */
1752 u32 flow_id; /* INPUT */
1753 u32 reset_counter:1; /* INPUT */
1754 struct virtchnl_fdir_query_info query_info; /* OUTPUT */
1755 enum virtchnl_fdir_prgm_status status; /* OUTPUT */
1759 VIRTCHNL_CHECK_STRUCT_LEN(48, virtchnl_fdir_query);
1761 /* TX and RX queue types are valid in legacy as well as split queue models.
1762 * With Split Queue model, 2 additional types are introduced - TX_COMPLETION
1763 * and RX_BUFFER. In split queue model, RX corresponds to the queue where HW
1764 * posts completions.
1766 enum virtchnl_queue_type {
1767 VIRTCHNL_QUEUE_TYPE_TX = 0,
1768 VIRTCHNL_QUEUE_TYPE_RX = 1,
1769 VIRTCHNL_QUEUE_TYPE_TX_COMPLETION = 2,
1770 VIRTCHNL_QUEUE_TYPE_RX_BUFFER = 3,
1771 VIRTCHNL_QUEUE_TYPE_CONFIG_TX = 4,
1772 VIRTCHNL_QUEUE_TYPE_CONFIG_RX = 5
1776 /* structure to specify a chunk of contiguous queues */
1777 struct virtchnl_queue_chunk {
1778 enum virtchnl_queue_type type;
1783 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_queue_chunk);
1785 /* structure to specify several chunks of contiguous queues */
1786 struct virtchnl_queue_chunks {
1789 struct virtchnl_queue_chunk chunks[1];
1792 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_chunks);
1795 /* VIRTCHNL_OP_ENABLE_QUEUES_V2
1796 * VIRTCHNL_OP_DISABLE_QUEUES_V2
1797 * VIRTCHNL_OP_DEL_QUEUES
1799 * If VIRTCHNL_CAP_EXT_FEATURES was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
1800 * then all of these ops are available.
1802 * If VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
1803 * then VIRTCHNL_OP_ENABLE_QUEUES_V2 and VIRTCHNL_OP_DISABLE_QUEUES_V2 are
1806 * PF sends these messages to enable, disable or delete queues specified in
1807 * chunks. PF sends virtchnl_del_ena_dis_queues struct to specify the queues
1808 * to be enabled/disabled/deleted. Also applicable to single queue RX or
1809 * TX. CP performs requested action and returns status.
1811 struct virtchnl_del_ena_dis_queues {
1814 struct virtchnl_queue_chunks chunks;
1817 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_del_ena_dis_queues);
1819 /* Virtchannel interrupt throttling rate index */
1820 enum virtchnl_itr_idx {
1821 VIRTCHNL_ITR_IDX_0 = 0,
1822 VIRTCHNL_ITR_IDX_1 = 1,
1823 VIRTCHNL_ITR_IDX_NO_ITR = 3,
1826 /* Queue to vector mapping */
1827 struct virtchnl_queue_vector {
1831 enum virtchnl_itr_idx itr_idx;
1832 enum virtchnl_queue_type queue_type;
1835 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_queue_vector);
1837 /* VIRTCHNL_OP_MAP_QUEUE_VECTOR
1838 * VIRTCHNL_OP_UNMAP_QUEUE_VECTOR
1840 * If VIRTCHNL_CAP_EXT_FEATURES was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
1841 * then all of these ops are available.
1843 * If VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
1844 * then only VIRTCHNL_OP_MAP_QUEUE_VECTOR is available.
1846 * PF sends this message to map or unmap queues to vectors and ITR index
1847 * registers. External data buffer contains virtchnl_queue_vector_maps structure
1848 * that contains num_qv_maps of virtchnl_queue_vector structures.
1849 * CP maps the requested queue vector maps after validating the queue and vector
1850 * ids and returns a status code.
1852 struct virtchnl_queue_vector_maps {
1856 struct virtchnl_queue_vector qv_maps[1];
1859 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_queue_vector_maps);
1862 /* Since VF messages are limited by u16 size, precalculate the maximum possible
1863 * values of nested elements in virtchnl structures that virtual channel can
1864 * possibly handle in a single message.
1866 enum virtchnl_vector_limits {
1867 VIRTCHNL_OP_CONFIG_VSI_QUEUES_MAX =
1868 ((u16)(~0) - sizeof(struct virtchnl_vsi_queue_config_info)) /
1869 sizeof(struct virtchnl_queue_pair_info),
1871 VIRTCHNL_OP_CONFIG_IRQ_MAP_MAX =
1872 ((u16)(~0) - sizeof(struct virtchnl_irq_map_info)) /
1873 sizeof(struct virtchnl_vector_map),
1875 VIRTCHNL_OP_ADD_DEL_ETH_ADDR_MAX =
1876 ((u16)(~0) - sizeof(struct virtchnl_ether_addr_list)) /
1877 sizeof(struct virtchnl_ether_addr),
1879 VIRTCHNL_OP_ADD_DEL_VLAN_MAX =
1880 ((u16)(~0) - sizeof(struct virtchnl_vlan_filter_list)) /
1884 VIRTCHNL_OP_ENABLE_CHANNELS_MAX =
1885 ((u16)(~0) - sizeof(struct virtchnl_tc_info)) /
1886 sizeof(struct virtchnl_channel_info),
1888 VIRTCHNL_OP_ENABLE_DISABLE_DEL_QUEUES_V2_MAX =
1889 ((u16)(~0) - sizeof(struct virtchnl_del_ena_dis_queues)) /
1890 sizeof(struct virtchnl_queue_chunk),
1892 VIRTCHNL_OP_MAP_UNMAP_QUEUE_VECTOR_MAX =
1893 ((u16)(~0) - sizeof(struct virtchnl_queue_vector_maps)) /
1894 sizeof(struct virtchnl_queue_vector),
1896 VIRTCHNL_OP_ADD_DEL_VLAN_V2_MAX =
1897 ((u16)(~0) - sizeof(struct virtchnl_vlan_filter_list_v2)) /
1898 sizeof(struct virtchnl_vlan_filter),
1902 * virtchnl_vc_validate_vf_msg
1903 * @ver: Virtchnl version info
1904 * @v_opcode: Opcode for the message
1905 * @msg: pointer to the msg buffer
1906 * @msglen: msg length
1908 * validate msg format against struct for each opcode
1911 virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
1912 u8 *msg, u16 msglen)
1914 bool err_msg_format = false;
1917 /* Validate message length. */
1919 case VIRTCHNL_OP_VERSION:
1920 valid_len = sizeof(struct virtchnl_version_info);
1922 case VIRTCHNL_OP_RESET_VF:
1924 case VIRTCHNL_OP_GET_VF_RESOURCES:
1926 valid_len = sizeof(u32);
1928 case VIRTCHNL_OP_CONFIG_TX_QUEUE:
1929 valid_len = sizeof(struct virtchnl_txq_info);
1931 case VIRTCHNL_OP_CONFIG_RX_QUEUE:
1932 valid_len = sizeof(struct virtchnl_rxq_info);
1934 case VIRTCHNL_OP_CONFIG_VSI_QUEUES:
1935 valid_len = sizeof(struct virtchnl_vsi_queue_config_info);
1936 if (msglen >= valid_len) {
1937 struct virtchnl_vsi_queue_config_info *vqc =
1938 (struct virtchnl_vsi_queue_config_info *)msg;
1940 if (vqc->num_queue_pairs == 0 || vqc->num_queue_pairs >
1941 VIRTCHNL_OP_CONFIG_VSI_QUEUES_MAX) {
1942 err_msg_format = true;
1946 valid_len += (vqc->num_queue_pairs *
1948 virtchnl_queue_pair_info));
1951 case VIRTCHNL_OP_CONFIG_IRQ_MAP:
1952 valid_len = sizeof(struct virtchnl_irq_map_info);
1953 if (msglen >= valid_len) {
1954 struct virtchnl_irq_map_info *vimi =
1955 (struct virtchnl_irq_map_info *)msg;
1957 if (vimi->num_vectors == 0 || vimi->num_vectors >
1958 VIRTCHNL_OP_CONFIG_IRQ_MAP_MAX) {
1959 err_msg_format = true;
1963 valid_len += (vimi->num_vectors *
1964 sizeof(struct virtchnl_vector_map));
1967 case VIRTCHNL_OP_ENABLE_QUEUES:
1968 case VIRTCHNL_OP_DISABLE_QUEUES:
1969 valid_len = sizeof(struct virtchnl_queue_select);
1971 case VIRTCHNL_OP_GET_MAX_RSS_QREGION:
1973 case VIRTCHNL_OP_ADD_ETH_ADDR:
1974 case VIRTCHNL_OP_DEL_ETH_ADDR:
1975 valid_len = sizeof(struct virtchnl_ether_addr_list);
1976 if (msglen >= valid_len) {
1977 struct virtchnl_ether_addr_list *veal =
1978 (struct virtchnl_ether_addr_list *)msg;
1980 if (veal->num_elements == 0 || veal->num_elements >
1981 VIRTCHNL_OP_ADD_DEL_ETH_ADDR_MAX) {
1982 err_msg_format = true;
1986 valid_len += veal->num_elements *
1987 sizeof(struct virtchnl_ether_addr);
1990 case VIRTCHNL_OP_ADD_VLAN:
1991 case VIRTCHNL_OP_DEL_VLAN:
1992 valid_len = sizeof(struct virtchnl_vlan_filter_list);
1993 if (msglen >= valid_len) {
1994 struct virtchnl_vlan_filter_list *vfl =
1995 (struct virtchnl_vlan_filter_list *)msg;
1997 if (vfl->num_elements == 0 || vfl->num_elements >
1998 VIRTCHNL_OP_ADD_DEL_VLAN_MAX) {
1999 err_msg_format = true;
2003 valid_len += vfl->num_elements * sizeof(u16);
2006 case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE:
2007 valid_len = sizeof(struct virtchnl_promisc_info);
2009 case VIRTCHNL_OP_GET_STATS:
2010 valid_len = sizeof(struct virtchnl_queue_select);
2012 case VIRTCHNL_OP_CONFIG_RSS_KEY:
2013 valid_len = sizeof(struct virtchnl_rss_key);
2014 if (msglen >= valid_len) {
2015 struct virtchnl_rss_key *vrk =
2016 (struct virtchnl_rss_key *)msg;
2018 if (vrk->key_len == 0) {
2019 /* zero length is allowed as input */
2023 valid_len += vrk->key_len - 1;
2026 case VIRTCHNL_OP_CONFIG_RSS_LUT:
2027 valid_len = sizeof(struct virtchnl_rss_lut);
2028 if (msglen >= valid_len) {
2029 struct virtchnl_rss_lut *vrl =
2030 (struct virtchnl_rss_lut *)msg;
2032 if (vrl->lut_entries == 0) {
2033 /* zero entries is allowed as input */
2037 valid_len += vrl->lut_entries - 1;
2040 case VIRTCHNL_OP_GET_RSS_HENA_CAPS:
2042 case VIRTCHNL_OP_SET_RSS_HENA:
2043 valid_len = sizeof(struct virtchnl_rss_hena);
2045 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING:
2046 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING:
2048 case VIRTCHNL_OP_REQUEST_QUEUES:
2049 valid_len = sizeof(struct virtchnl_vf_res_request);
2051 case VIRTCHNL_OP_ENABLE_CHANNELS:
2052 valid_len = sizeof(struct virtchnl_tc_info);
2053 if (msglen >= valid_len) {
2054 struct virtchnl_tc_info *vti =
2055 (struct virtchnl_tc_info *)msg;
2057 if (vti->num_tc == 0 || vti->num_tc >
2058 VIRTCHNL_OP_ENABLE_CHANNELS_MAX) {
2059 err_msg_format = true;
2063 valid_len += (vti->num_tc - 1) *
2064 sizeof(struct virtchnl_channel_info);
2067 case VIRTCHNL_OP_DISABLE_CHANNELS:
2069 case VIRTCHNL_OP_ADD_CLOUD_FILTER:
2070 case VIRTCHNL_OP_DEL_CLOUD_FILTER:
2071 valid_len = sizeof(struct virtchnl_filter);
2073 case VIRTCHNL_OP_DCF_VLAN_OFFLOAD:
2074 valid_len = sizeof(struct virtchnl_dcf_vlan_offload);
2076 case VIRTCHNL_OP_DCF_CMD_DESC:
2077 case VIRTCHNL_OP_DCF_CMD_BUFF:
2078 /* These two opcodes are specific to handle the AdminQ command,
2079 * so the validation needs to be done in PF's context.
2083 case VIRTCHNL_OP_DCF_DISABLE:
2084 case VIRTCHNL_OP_DCF_GET_VSI_MAP:
2085 case VIRTCHNL_OP_DCF_GET_PKG_INFO:
2087 case VIRTCHNL_OP_GET_SUPPORTED_RXDIDS:
2089 case VIRTCHNL_OP_ADD_RSS_CFG:
2090 case VIRTCHNL_OP_DEL_RSS_CFG:
2091 valid_len = sizeof(struct virtchnl_rss_cfg);
2093 case VIRTCHNL_OP_ADD_FDIR_FILTER:
2094 valid_len = sizeof(struct virtchnl_fdir_add);
2096 case VIRTCHNL_OP_DEL_FDIR_FILTER:
2097 valid_len = sizeof(struct virtchnl_fdir_del);
2099 case VIRTCHNL_OP_QUERY_FDIR_FILTER:
2100 valid_len = sizeof(struct virtchnl_fdir_query);
2102 case VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS:
2104 case VIRTCHNL_OP_ADD_VLAN_V2:
2105 case VIRTCHNL_OP_DEL_VLAN_V2:
2106 valid_len = sizeof(struct virtchnl_vlan_filter_list_v2);
2107 if (msglen >= valid_len) {
2108 struct virtchnl_vlan_filter_list_v2 *vfl =
2109 (struct virtchnl_vlan_filter_list_v2 *)msg;
2111 if (vfl->num_elements == 0 || vfl->num_elements >
2112 VIRTCHNL_OP_ADD_DEL_VLAN_V2_MAX) {
2113 err_msg_format = true;
2117 valid_len += (vfl->num_elements - 1) *
2118 sizeof(struct virtchnl_vlan_filter);
2121 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2:
2122 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2:
2123 case VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2:
2124 case VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2:
2125 case VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2:
2126 case VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2:
2127 valid_len = sizeof(struct virtchnl_vlan_setting);
2129 case VIRTCHNL_OP_ENABLE_QUEUES_V2:
2130 case VIRTCHNL_OP_DISABLE_QUEUES_V2:
2131 valid_len = sizeof(struct virtchnl_del_ena_dis_queues);
2132 if (msglen >= valid_len) {
2133 struct virtchnl_del_ena_dis_queues *qs =
2134 (struct virtchnl_del_ena_dis_queues *)msg;
2135 if (qs->chunks.num_chunks == 0 ||
2136 qs->chunks.num_chunks > VIRTCHNL_OP_ENABLE_DISABLE_DEL_QUEUES_V2_MAX) {
2137 err_msg_format = true;
2140 valid_len += (qs->chunks.num_chunks - 1) *
2141 sizeof(struct virtchnl_queue_chunk);
2144 case VIRTCHNL_OP_MAP_QUEUE_VECTOR:
2145 valid_len = sizeof(struct virtchnl_queue_vector_maps);
2146 if (msglen >= valid_len) {
2147 struct virtchnl_queue_vector_maps *v_qp =
2148 (struct virtchnl_queue_vector_maps *)msg;
2149 if (v_qp->num_qv_maps == 0 ||
2150 v_qp->num_qv_maps > VIRTCHNL_OP_MAP_UNMAP_QUEUE_VECTOR_MAX) {
2151 err_msg_format = true;
2154 valid_len += (v_qp->num_qv_maps - 1) *
2155 sizeof(struct virtchnl_queue_vector);
2158 /* These are always errors coming from the VF. */
2159 case VIRTCHNL_OP_EVENT:
2160 case VIRTCHNL_OP_UNKNOWN:
2162 return VIRTCHNL_STATUS_ERR_PARAM;
2164 /* few more checks */
2165 if (err_msg_format || valid_len != msglen)
2166 return VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH;
2170 #endif /* _VIRTCHNL_H_ */