1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2001-2020 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, 37 and 38 are reserved */
132 VIRTCHNL_OP_DCF_CMD_DESC = 39,
133 VIRTCHNL_OP_DCF_CMD_BUFF = 40,
134 VIRTCHNL_OP_DCF_DISABLE = 41,
135 VIRTCHNL_OP_DCF_GET_VSI_MAP = 42,
136 VIRTCHNL_OP_DCF_GET_PKG_INFO = 43,
137 VIRTCHNL_OP_GET_SUPPORTED_RXDIDS = 44,
138 VIRTCHNL_OP_ADD_RSS_CFG = 45,
139 VIRTCHNL_OP_DEL_RSS_CFG = 46,
140 VIRTCHNL_OP_ADD_FDIR_FILTER = 47,
141 VIRTCHNL_OP_DEL_FDIR_FILTER = 48,
142 VIRTCHNL_OP_QUERY_FDIR_FILTER = 49,
143 VIRTCHNL_OP_GET_MAX_RSS_QREGION = 50,
144 VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS = 51,
145 VIRTCHNL_OP_ADD_VLAN_V2 = 52,
146 VIRTCHNL_OP_DEL_VLAN_V2 = 53,
147 VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 = 54,
148 VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 = 55,
149 VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 = 56,
150 VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2 = 57,
151 VIRTCHNL_OP_ENABLE_QUEUES_V2 = 107,
152 VIRTCHNL_OP_DISABLE_QUEUES_V2 = 108,
153 VIRTCHNL_OP_MAP_QUEUE_VECTOR = 111,
157 static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)
160 case VIRTCHNL_OP_UNKNOWN:
161 return "VIRTCHNL_OP_UNKNOWN";
162 case VIRTCHNL_OP_VERSION:
163 return "VIRTCHNL_OP_VERSION";
164 case VIRTCHNL_OP_RESET_VF:
165 return "VIRTCHNL_OP_RESET_VF";
166 case VIRTCHNL_OP_GET_VF_RESOURCES:
167 return "VIRTCHNL_OP_GET_VF_RESOURCES";
168 case VIRTCHNL_OP_CONFIG_TX_QUEUE:
169 return "VIRTCHNL_OP_CONFIG_TX_QUEUE";
170 case VIRTCHNL_OP_CONFIG_RX_QUEUE:
171 return "VIRTCHNL_OP_CONFIG_RX_QUEUE";
172 case VIRTCHNL_OP_CONFIG_VSI_QUEUES:
173 return "VIRTCHNL_OP_CONFIG_VSI_QUEUES";
174 case VIRTCHNL_OP_CONFIG_IRQ_MAP:
175 return "VIRTCHNL_OP_CONFIG_IRQ_MAP";
176 case VIRTCHNL_OP_ENABLE_QUEUES:
177 return "VIRTCHNL_OP_ENABLE_QUEUES";
178 case VIRTCHNL_OP_DISABLE_QUEUES:
179 return "VIRTCHNL_OP_DISABLE_QUEUES";
180 case VIRTCHNL_OP_ADD_ETH_ADDR:
181 return "VIRTCHNL_OP_ADD_ETH_ADDR";
182 case VIRTCHNL_OP_DEL_ETH_ADDR:
183 return "VIRTCHNL_OP_DEL_ETH_ADDR";
184 case VIRTCHNL_OP_ADD_VLAN:
185 return "VIRTCHNL_OP_ADD_VLAN";
186 case VIRTCHNL_OP_DEL_VLAN:
187 return "VIRTCHNL_OP_DEL_VLAN";
188 case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE:
189 return "VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE";
190 case VIRTCHNL_OP_GET_STATS:
191 return "VIRTCHNL_OP_GET_STATS";
192 case VIRTCHNL_OP_RSVD:
193 return "VIRTCHNL_OP_RSVD";
194 case VIRTCHNL_OP_EVENT:
195 return "VIRTCHNL_OP_EVENT";
196 case VIRTCHNL_OP_CONFIG_RSS_KEY:
197 return "VIRTCHNL_OP_CONFIG_RSS_KEY";
198 case VIRTCHNL_OP_CONFIG_RSS_LUT:
199 return "VIRTCHNL_OP_CONFIG_RSS_LUT";
200 case VIRTCHNL_OP_GET_RSS_HENA_CAPS:
201 return "VIRTCHNL_OP_GET_RSS_HENA_CAPS";
202 case VIRTCHNL_OP_SET_RSS_HENA:
203 return "VIRTCHNL_OP_SET_RSS_HENA";
204 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING:
205 return "VIRTCHNL_OP_ENABLE_VLAN_STRIPPING";
206 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING:
207 return "VIRTCHNL_OP_DISABLE_VLAN_STRIPPING";
208 case VIRTCHNL_OP_REQUEST_QUEUES:
209 return "VIRTCHNL_OP_REQUEST_QUEUES";
210 case VIRTCHNL_OP_ENABLE_CHANNELS:
211 return "VIRTCHNL_OP_ENABLE_CHANNELS";
212 case VIRTCHNL_OP_DISABLE_CHANNELS:
213 return "VIRTCHNL_OP_DISABLE_CHANNELS";
214 case VIRTCHNL_OP_ADD_CLOUD_FILTER:
215 return "VIRTCHNL_OP_ADD_CLOUD_FILTER";
216 case VIRTCHNL_OP_DEL_CLOUD_FILTER:
217 return "VIRTCHNL_OP_DEL_CLOUD_FILTER";
218 case VIRTCHNL_OP_DCF_CMD_DESC:
219 return "VIRTCHNL_OP_DCF_CMD_DESC";
220 case VIRTCHNL_OP_DCF_CMD_BUFF:
221 return "VIRTCHHNL_OP_DCF_CMD_BUFF";
222 case VIRTCHNL_OP_DCF_DISABLE:
223 return "VIRTCHNL_OP_DCF_DISABLE";
224 case VIRTCHNL_OP_DCF_GET_VSI_MAP:
225 return "VIRTCHNL_OP_DCF_GET_VSI_MAP";
226 case VIRTCHNL_OP_GET_SUPPORTED_RXDIDS:
227 return "VIRTCHNL_OP_GET_SUPPORTED_RXDIDS";
228 case VIRTCHNL_OP_ADD_RSS_CFG:
229 return "VIRTCHNL_OP_ADD_RSS_CFG";
230 case VIRTCHNL_OP_DEL_RSS_CFG:
231 return "VIRTCHNL_OP_DEL_RSS_CFG";
232 case VIRTCHNL_OP_ADD_FDIR_FILTER:
233 return "VIRTCHNL_OP_ADD_FDIR_FILTER";
234 case VIRTCHNL_OP_DEL_FDIR_FILTER:
235 return "VIRTCHNL_OP_DEL_FDIR_FILTER";
236 case VIRTCHNL_OP_QUERY_FDIR_FILTER:
237 return "VIRTCHNL_OP_QUERY_FDIR_FILTER";
238 case VIRTCHNL_OP_GET_MAX_RSS_QREGION:
239 return "VIRTCHNL_OP_GET_MAX_RSS_QREGION";
240 case VIRTCHNL_OP_ENABLE_QUEUES_V2:
241 return "VIRTCHNL_OP_ENABLE_QUEUES_V2";
242 case VIRTCHNL_OP_DISABLE_QUEUES_V2:
243 return "VIRTCHNL_OP_DISABLE_QUEUES_V2";
244 case VIRTCHNL_OP_MAP_QUEUE_VECTOR:
245 return "VIRTCHNL_OP_MAP_QUEUE_VECTOR";
246 case VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS:
247 return "VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS";
248 case VIRTCHNL_OP_ADD_VLAN_V2:
249 return "VIRTCHNL_OP_ADD_VLAN_V2";
250 case VIRTCHNL_OP_DEL_VLAN_V2:
251 return "VIRTCHNL_OP_DEL_VLAN_V2";
252 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2:
253 return "VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2";
254 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2:
255 return "VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2";
256 case VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2:
257 return "VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2";
258 case VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2:
259 return "VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2";
260 case VIRTCHNL_OP_MAX:
261 return "VIRTCHNL_OP_MAX";
263 return "Unsupported (update virtchnl.h)";
267 /* These macros are used to generate compilation errors if a structure/union
268 * is not exactly the correct length. It gives a divide by zero error if the
269 * structure/union is not of the correct size, otherwise it creates an enum
270 * that is never used.
272 #define VIRTCHNL_CHECK_STRUCT_LEN(n, X) enum virtchnl_static_assert_enum_##X \
273 { virtchnl_static_assert_##X = (n)/((sizeof(struct X) == (n)) ? 1 : 0) }
274 #define VIRTCHNL_CHECK_UNION_LEN(n, X) enum virtchnl_static_asset_enum_##X \
275 { virtchnl_static_assert_##X = (n)/((sizeof(union X) == (n)) ? 1 : 0) }
277 /* Virtual channel message descriptor. This overlays the admin queue
278 * descriptor. All other data is passed in external buffers.
281 struct virtchnl_msg {
282 u8 pad[8]; /* AQ flags/opcode/len/retval fields */
283 enum virtchnl_ops v_opcode; /* avoid confusion with desc->opcode */
284 enum virtchnl_status_code v_retval; /* ditto for desc->retval */
285 u32 vfid; /* used by PF when sending to VF */
288 VIRTCHNL_CHECK_STRUCT_LEN(20, virtchnl_msg);
290 /* Message descriptions and data structures. */
292 /* VIRTCHNL_OP_VERSION
293 * VF posts its version number to the PF. PF responds with its version number
294 * in the same format, along with a return code.
295 * Reply from PF has its major/minor versions also in param0 and param1.
296 * If there is a major version mismatch, then the VF cannot operate.
297 * If there is a minor version mismatch, then the VF can operate but should
298 * add a warning to the system log.
300 * This enum element MUST always be specified as == 1, regardless of other
301 * changes in the API. The PF must always respond to this message without
302 * error regardless of version mismatch.
304 #define VIRTCHNL_VERSION_MAJOR 1
305 #define VIRTCHNL_VERSION_MINOR 1
306 #define VIRTCHNL_VERSION_MINOR_NO_VF_CAPS 0
308 struct virtchnl_version_info {
313 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_version_info);
315 #define VF_IS_V10(_v) (((_v)->major == 1) && ((_v)->minor == 0))
316 #define VF_IS_V11(_ver) (((_ver)->major == 1) && ((_ver)->minor == 1))
318 /* VIRTCHNL_OP_RESET_VF
319 * VF sends this request to PF with no parameters
320 * PF does NOT respond! VF driver must delay then poll VFGEN_RSTAT register
321 * until reset completion is indicated. The admin queue must be reinitialized
322 * after this operation.
324 * When reset is complete, PF must ensure that all queues in all VSIs associated
325 * with the VF are stopped, all queue configurations in the HMC are set to 0,
326 * and all MAC and VLAN filters (except the default MAC address) on all VSIs
330 /* VSI types that use VIRTCHNL interface for VF-PF communication. VSI_SRIOV
331 * vsi_type should always be 6 for backward compatibility. Add other fields
334 enum virtchnl_vsi_type {
335 VIRTCHNL_VSI_TYPE_INVALID = 0,
336 VIRTCHNL_VSI_SRIOV = 6,
339 /* VIRTCHNL_OP_GET_VF_RESOURCES
340 * Version 1.0 VF sends this request to PF with no parameters
341 * Version 1.1 VF sends this request to PF with u32 bitmap of its capabilities
342 * PF responds with an indirect message containing
343 * virtchnl_vf_resource and one or more
344 * virtchnl_vsi_resource structures.
347 struct virtchnl_vsi_resource {
350 enum virtchnl_vsi_type vsi_type;
352 u8 default_mac_addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
355 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
357 /* VF capability flags
358 * VIRTCHNL_VF_OFFLOAD_L2 flag is inclusive of base mode L2 offloads including
359 * TX/RX Checksum offloading and TSO for non-tunnelled packets.
361 #define VIRTCHNL_VF_OFFLOAD_L2 0x00000001
362 #define VIRTCHNL_VF_OFFLOAD_IWARP 0x00000002
363 #define VIRTCHNL_VF_OFFLOAD_RSVD 0x00000004
364 #define VIRTCHNL_VF_OFFLOAD_RSS_AQ 0x00000008
365 #define VIRTCHNL_VF_OFFLOAD_RSS_REG 0x00000010
366 #define VIRTCHNL_VF_OFFLOAD_WB_ON_ITR 0x00000020
367 #define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES 0x00000040
368 #define VIRTCHNL_VF_OFFLOAD_CRC 0x00000080
369 /* 0X00000100 is reserved */
370 #define VIRTCHNL_VF_LARGE_NUM_QPAIRS 0x00000200
371 #define VIRTCHNL_VF_OFFLOAD_VLAN_V2 0x00008000
372 #define VIRTCHNL_VF_OFFLOAD_VLAN 0x00010000
373 #define VIRTCHNL_VF_OFFLOAD_RX_POLLING 0x00020000
374 #define VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 0x00040000
375 #define VIRTCHNL_VF_OFFLOAD_RSS_PF 0X00080000
376 #define VIRTCHNL_VF_OFFLOAD_ENCAP 0X00100000
377 #define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM 0X00200000
378 #define VIRTCHNL_VF_OFFLOAD_RX_ENCAP_CSUM 0X00400000
379 #define VIRTCHNL_VF_OFFLOAD_ADQ 0X00800000
380 #define VIRTCHNL_VF_OFFLOAD_ADQ_V2 0X01000000
381 #define VIRTCHNL_VF_OFFLOAD_USO 0X02000000
382 #define VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC 0X04000000
383 #define VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF 0X08000000
384 #define VIRTCHNL_VF_OFFLOAD_FDIR_PF 0X10000000
385 /* 0X20000000 is reserved */
386 #define VIRTCHNL_VF_CAP_DCF 0X40000000
387 /* 0X80000000 is reserved */
389 /* Define below the capability flags that are not offloads */
390 #define VIRTCHNL_VF_CAP_ADV_LINK_SPEED 0x00000080
391 #define VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \
392 VIRTCHNL_VF_OFFLOAD_VLAN | \
393 VIRTCHNL_VF_OFFLOAD_RSS_PF)
395 struct virtchnl_vf_resource {
405 struct virtchnl_vsi_resource vsi_res[1];
408 VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_vf_resource);
410 /* VIRTCHNL_OP_CONFIG_TX_QUEUE
411 * VF sends this message to set up parameters for one TX queue.
412 * External data buffer contains one instance of virtchnl_txq_info.
413 * PF configures requested queue and returns a status code.
416 /* Tx queue config info */
417 struct virtchnl_txq_info {
420 u16 ring_len; /* number of descriptors, multiple of 8 */
421 u16 headwb_enabled; /* deprecated with AVF 1.0 */
423 u64 dma_headwb_addr; /* deprecated with AVF 1.0 */
426 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_txq_info);
428 /* VIRTCHNL_OP_CONFIG_RX_QUEUE
429 * VF sends this message to set up parameters for one RX queue.
430 * External data buffer contains one instance of virtchnl_rxq_info.
431 * PF configures requested queue and returns a status code. The
432 * crc_disable flag disables CRC stripping on the VF. Setting
433 * the crc_disable flag to 1 will disable CRC stripping for each
434 * queue in the VF where the flag is set. The VIRTCHNL_VF_OFFLOAD_CRC
435 * offload must have been set prior to sending this info or the PF
436 * will ignore the request. This flag should be set the same for
437 * all of the queues for a VF.
440 /* Rx queue config info */
441 struct virtchnl_rxq_info {
444 u32 ring_len; /* number of descriptors, multiple of 32 */
446 u16 splithdr_enabled; /* deprecated with AVF 1.0 */
450 /* only used when VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC is supported */
454 enum virtchnl_rx_hsplit rx_split_pos; /* deprecated with AVF 1.0 */
458 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_rxq_info);
460 /* VIRTCHNL_OP_CONFIG_VSI_QUEUES
461 * VF sends this message to set parameters for active TX and RX queues
462 * associated with the specified VSI.
463 * PF configures queues and returns status.
464 * If the number of queues specified is greater than the number of queues
465 * associated with the VSI, an error is returned and no queues are configured.
466 * NOTE: The VF is not required to configure all queues in a single request.
467 * It may send multiple messages. PF drivers must correctly handle all VF
470 struct virtchnl_queue_pair_info {
471 /* NOTE: vsi_id and queue_id should be identical for both queues. */
472 struct virtchnl_txq_info txq;
473 struct virtchnl_rxq_info rxq;
476 VIRTCHNL_CHECK_STRUCT_LEN(64, virtchnl_queue_pair_info);
478 struct virtchnl_vsi_queue_config_info {
482 struct virtchnl_queue_pair_info qpair[1];
485 VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_vsi_queue_config_info);
487 /* VIRTCHNL_OP_REQUEST_QUEUES
488 * VF sends this message to request the PF to allocate additional queues to
489 * this VF. Each VF gets a guaranteed number of queues on init but asking for
490 * additional queues must be negotiated. This is a best effort request as it
491 * is possible the PF does not have enough queues left to support the request.
492 * If the PF cannot support the number requested it will respond with the
493 * maximum number it is able to support. If the request is successful, PF will
494 * then reset the VF to institute required changes.
497 /* VF resource request */
498 struct virtchnl_vf_res_request {
502 /* VIRTCHNL_OP_CONFIG_IRQ_MAP
503 * VF uses this message to map vectors to queues.
504 * The rxq_map and txq_map fields are bitmaps used to indicate which queues
505 * are to be associated with the specified vector.
506 * The "other" causes are always mapped to vector 0. The VF may not request
507 * that vector 0 be used for traffic.
508 * PF configures interrupt mapping and returns status.
509 * NOTE: due to hardware requirements, all active queues (both TX and RX)
510 * should be mapped to interrupts, even if the driver intends to operate
511 * only in polling mode. In this case the interrupt may be disabled, but
512 * the ITR timer will still run to trigger writebacks.
514 struct virtchnl_vector_map {
523 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_vector_map);
525 struct virtchnl_irq_map_info {
527 struct virtchnl_vector_map vecmap[1];
530 VIRTCHNL_CHECK_STRUCT_LEN(14, virtchnl_irq_map_info);
532 /* VIRTCHNL_OP_ENABLE_QUEUES
533 * VIRTCHNL_OP_DISABLE_QUEUES
534 * VF sends these message to enable or disable TX/RX queue pairs.
535 * The queues fields are bitmaps indicating which queues to act upon.
536 * (Currently, we only support 16 queues per VF, but we make the field
537 * u32 to allow for expansion.)
538 * PF performs requested action and returns status.
539 * NOTE: The VF is not required to enable/disable all queues in a single
540 * request. It may send multiple messages.
541 * PF drivers must correctly handle all VF requests.
543 struct virtchnl_queue_select {
550 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_select);
552 /* VIRTCHNL_OP_GET_MAX_RSS_QREGION
554 * if VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
555 * then this op must be supported.
557 * VF sends this message in order to query the max RSS queue region
558 * size supported by PF, when VIRTCHNL_VF_LARGE_NUM_QPAIRS is enabled.
559 * This information should be used when configuring the RSS LUT and/or
560 * configuring queue region based filters.
562 * The maximum RSS queue region is 2^qregion_width. So, a qregion_width
563 * of 6 would inform the VF that the PF supports a maximum RSS queue region
566 * A queue region represents a range of queues that can be used to configure
567 * a RSS LUT. For example, if a VF is given 64 queues, but only a max queue
568 * region size of 16 (i.e. 2^qregion_width = 16) then it will only be able
569 * to configure the RSS LUT with queue indices from 0 to 15. However, other
570 * filters can be used to direct packets to queues >15 via specifying a queue
571 * base/offset and queue region width.
573 struct virtchnl_max_rss_qregion {
579 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_max_rss_qregion);
581 /* VIRTCHNL_OP_ADD_ETH_ADDR
582 * VF sends this message in order to add one or more unicast or multicast
583 * address filters for the specified VSI.
584 * PF adds the filters and returns status.
587 /* VIRTCHNL_OP_DEL_ETH_ADDR
588 * VF sends this message in order to remove one or more unicast or multicast
589 * filters for the specified VSI.
590 * PF removes the filters and returns status.
593 /* VIRTCHNL_ETHER_ADDR_LEGACY
594 * Prior to adding the @type member to virtchnl_ether_addr, there were 2 pad
595 * bytes. Moving forward all VF drivers should not set type to
596 * VIRTCHNL_ETHER_ADDR_LEGACY. This is only here to not break previous/legacy
597 * behavior. The control plane function (i.e. PF) can use a best effort method
598 * of tracking the primary/device unicast in this case, but there is no
599 * guarantee and functionality depends on the implementation of the PF.
602 /* VIRTCHNL_ETHER_ADDR_PRIMARY
603 * All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_PRIMARY for the
604 * primary/device unicast MAC address filter for VIRTCHNL_OP_ADD_ETH_ADDR and
605 * VIRTCHNL_OP_DEL_ETH_ADDR. This allows for the underlying control plane
606 * function (i.e. PF) to accurately track and use this MAC address for
607 * displaying on the host and for VM/function reset.
610 /* VIRTCHNL_ETHER_ADDR_EXTRA
611 * All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_EXTRA for any extra
612 * unicast and/or multicast filters that are being added/deleted via
613 * VIRTCHNL_OP_DEL_ETH_ADDR/VIRTCHNL_OP_ADD_ETH_ADDR respectively.
615 struct virtchnl_ether_addr {
616 u8 addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
618 #define VIRTCHNL_ETHER_ADDR_LEGACY 0
619 #define VIRTCHNL_ETHER_ADDR_PRIMARY 1
620 #define VIRTCHNL_ETHER_ADDR_EXTRA 2
621 #define VIRTCHNL_ETHER_ADDR_TYPE_MASK 3 /* first two bits of type are valid */
625 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_ether_addr);
627 struct virtchnl_ether_addr_list {
630 struct virtchnl_ether_addr list[1];
633 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_ether_addr_list);
635 /* VIRTCHNL_OP_ADD_VLAN
636 * VF sends this message to add one or more VLAN tag filters for receives.
637 * PF adds the filters and returns status.
638 * If a port VLAN is configured by the PF, this operation will return an
642 /* VIRTCHNL_OP_DEL_VLAN
643 * VF sends this message to remove one or more VLAN tag filters for receives.
644 * PF removes the filters and returns status.
645 * If a port VLAN is configured by the PF, this operation will return an
649 struct virtchnl_vlan_filter_list {
655 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_vlan_filter_list);
657 /* This enum is used for all of the VIRTCHNL_VF_OFFLOAD_VLAN_V2_CAPS related
658 * structures and opcodes.
660 * VIRTCHNL_VLAN_UNSUPPORTED - This field is not supported and if a VF driver
661 * populates it the PF should return VIRTCHNL_STATUS_ERR_NOT_SUPPORTED.
663 * VIRTCHNL_VLAN_ETHERTYPE_8100 - This field supports 0x8100 ethertype.
664 * VIRTCHNL_VLAN_ETHERTYPE_88A8 - This field supports 0x88A8 ethertype.
665 * VIRTCHNL_VLAN_ETHERTYPE_9100 - This field supports 0x9100 ethertype.
667 * VIRTCHNL_VLAN_ETHERTYPE_AND - Used when multiple ethertypes can be supported
668 * by the PF concurrently. For example, if the PF can support
669 * VIRTCHNL_VLAN_ETHERTYPE_8100 AND VIRTCHNL_VLAN_ETHERTYPE_88A8 filters it
670 * would OR the following bits:
672 * VIRTHCNL_VLAN_ETHERTYPE_8100 |
673 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
674 * VIRTCHNL_VLAN_ETHERTYPE_AND;
676 * The VF would interpret this as VLAN filtering can be supported on both 0x8100
677 * and 0x88A8 VLAN ethertypes.
679 * VIRTCHNL_ETHERTYPE_XOR - Used when only a single ethertype can be supported
680 * by the PF concurrently. For example if the PF can support
681 * VIRTCHNL_VLAN_ETHERTYPE_8100 XOR VIRTCHNL_VLAN_ETHERTYPE_88A8 stripping
682 * offload it would OR the following bits:
684 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
685 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
686 * VIRTCHNL_VLAN_ETHERTYPE_XOR;
688 * The VF would interpret this as VLAN stripping can be supported on either
689 * 0x8100 or 0x88a8 VLAN ethertypes. So when requesting VLAN stripping via
690 * VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 the specified ethertype will override
691 * the previously set value.
693 * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1 - Used to tell the VF to insert and/or
694 * strip the VLAN tag using the L2TAG1 field of the Tx/Rx descriptors.
696 * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 - Used to tell the VF to insert hardware
697 * offloaded VLAN tags using the L2TAG2 field of the Tx descriptor.
699 * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 - Used to tell the VF to strip hardware
700 * offloaded VLAN tags using the L2TAG2_2 field of the Rx descriptor.
702 * VIRTCHNL_VLAN_PRIO - This field supports VLAN priority bits. This is used for
703 * VLAN filtering if the underlying PF supports it.
705 * VIRTCHNL_VLAN_TOGGLE_ALLOWED - This field is used to say whether a
706 * certain VLAN capability can be toggled. For example if the underlying PF/CP
707 * allows the VF to toggle VLAN filtering, stripping, and/or insertion it should
708 * set this bit along with the supported ethertypes.
710 enum virtchnl_vlan_support {
711 VIRTCHNL_VLAN_UNSUPPORTED = 0,
712 VIRTCHNL_VLAN_ETHERTYPE_8100 = 0x00000001,
713 VIRTCHNL_VLAN_ETHERTYPE_88A8 = 0x00000002,
714 VIRTCHNL_VLAN_ETHERTYPE_9100 = 0x00000004,
715 VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1 = 0x00000100,
716 VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 = 0x00000200,
717 VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2_2 = 0x00000400,
718 VIRTCHNL_VLAN_PRIO = 0x01000000,
719 VIRTCHNL_VLAN_FILTER_MASK = 0x10000000,
720 VIRTCHNL_VLAN_ETHERTYPE_AND = 0x20000000,
721 VIRTCHNL_VLAN_ETHERTYPE_XOR = 0x40000000,
722 VIRTCHNL_VLAN_TOGGLE = 0x80000000
725 /* This structure is used as part of the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS
726 * for filtering, insertion, and stripping capabilities.
728 * If only outer capabilities are supported (for filtering, insertion, and/or
729 * stripping) then this refers to the outer most or single VLAN from the VF's
732 * If only inner capabilities are supported (for filtering, insertion, and/or
733 * stripping) then this refers to the outer most or single VLAN from the VF's
734 * perspective. Functionally this is the same as if only outer capabilities are
735 * supported. The VF driver is just forced to use the inner fields when
736 * adding/deleting filters and enabling/disabling offloads (if supported).
738 * If both outer and inner capabilities are supported (for filtering, insertion,
739 * and/or stripping) then outer refers to the outer most or single VLAN and
740 * inner refers to the second VLAN, if it exists, in the packet.
742 * There is no support for tunneled VLAN offloads, so outer or inner are never
743 * referring to a tunneled packet from the VF's perspective.
745 struct virtchnl_vlan_supported_caps {
750 /* The PF populates these fields based on the supported VLAN filtering. If a
751 * field is VIRTCHNL_VLAN_UNSUPPORTED then it's not supported and the PF will
752 * reject any VIRTCHNL_OP_ADD_VLAN_V2 or VIRTCHNL_OP_DEL_VLAN_V2 messages using
753 * the unsupported fields.
755 * Also, a VF is only allowed to toggle its VLAN filtering setting if the
756 * VIRTCHNL_VLAN_TOGGLE bit is set.
758 * The ethertype(s) specified in the ethertype_init field are the ethertypes
759 * enabled for VLAN filtering. VLAN filtering in this case refers to the outer
760 * most VLAN from the VF's perspective. If both inner and outer filtering are
761 * allowed then ethertype_init only refers to the outer most VLAN as only
762 * VLAN ethertype supported for inner VLAN filtering is
763 * VIRTCHNL_VLAN_ETHERTYPE_8100. By default, inner VLAN filtering is disabled
764 * when both inner and outer filtering are allowed.
766 * The max_filters field tells the VF how many VLAN filters it's allowed to have
767 * at any one time. If it exceeds this amount and tries to add another filter,
768 * then the request will be rejected by the PF. To prevent failures, the VF
769 * should keep track of how many VLAN filters it has added and not attempt to
770 * add more than max_filters.
772 struct virtchnl_vlan_filtering_caps {
773 struct virtchnl_vlan_supported_caps filtering_support;
779 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vlan_filtering_caps);
781 /* This enum is used for the virtchnl_vlan_offload_caps structure to specify
782 * if the PF supports a different ethertype for stripping and insertion.
784 * VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION - The ethertype(s) specified
785 * for stripping affect the ethertype(s) specified for insertion and visa versa
786 * as well. If the VF tries to configure VLAN stripping via
787 * VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 with VIRTCHNL_VLAN_ETHERTYPE_8100 then
788 * that will be the ethertype for both stripping and insertion.
790 * VIRTCHNL_ETHERTYPE_MATCH_NOT_REQUIRED - The ethertype(s) specified for
791 * stripping do not affect the ethertype(s) specified for insertion and visa
794 enum virtchnl_vlan_ethertype_match {
795 VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION = 0,
796 VIRTCHNL_ETHERTYPE_MATCH_NOT_REQUIRED = 1,
799 /* The PF populates these fields based on the supported VLAN offloads. If a
800 * field is VIRTCHNL_VLAN_UNSUPPORTED then it's not supported and the PF will
801 * reject any VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 or
802 * VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 messages using the unsupported fields.
804 * Also, a VF is only allowed to toggle its VLAN offload setting if the
805 * VIRTCHNL_VLAN_TOGGLE_ALLOWED bit is set.
807 * The VF driver needs to be aware of how the tags are stripped by hardware and
808 * inserted by the VF driver based on the level of offload support. The PF will
809 * populate these fields based on where the VLAN tags are expected to be
810 * offloaded via the VIRTHCNL_VLAN_TAG_LOCATION_* bits. The VF will need to
811 * interpret these fields. See the definition of the
812 * VIRTCHNL_VLAN_TAG_LOCATION_* bits above the virtchnl_vlan_support
815 struct virtchnl_vlan_offload_caps {
816 struct virtchnl_vlan_supported_caps stripping_support;
817 struct virtchnl_vlan_supported_caps insertion_support;
823 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_vlan_offload_caps);
825 /* VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS
826 * VF sends this message to determine its VLAN capabilities.
828 * PF will mark which capabilities it supports based on hardware support and
829 * current configuration. For example, if a port VLAN is configured the PF will
830 * not allow outer VLAN filtering, stripping, or insertion to be configured so
831 * it will block these features from the VF.
833 * The VF will need to cross reference its capabilities with the PFs
834 * capabilities in the response message from the PF to determine the VLAN
837 struct virtchnl_vlan_caps {
838 struct virtchnl_vlan_filtering_caps filtering;
839 struct virtchnl_vlan_offload_caps offloads;
842 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_vlan_caps);
844 struct virtchnl_vlan {
845 u16 tci; /* tci[15:13] = PCP and tci[11:0] = VID */
846 u16 tci_mask; /* only valid if VIRTCHNL_VLAN_FILTER_MASK set in
849 u16 tpid; /* 0x8100, 0x88a8, etc. and only type(s) set in
850 * filtering caps. Note that tpid here does not refer to
851 * VIRTCHNL_VLAN_ETHERTYPE_*, but it refers to the
852 * actual 2-byte VLAN TPID
857 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_vlan);
859 struct virtchnl_vlan_filter {
860 struct virtchnl_vlan inner;
861 struct virtchnl_vlan outer;
865 VIRTCHNL_CHECK_STRUCT_LEN(32, virtchnl_vlan_filter);
867 /* VIRTCHNL_OP_ADD_VLAN_V2
868 * VIRTCHNL_OP_DEL_VLAN_V2
870 * VF sends these messages to add/del one or more VLAN tag filters for Rx
873 * The PF attempts to add the filters and returns status.
875 * The VF should only ever attempt to add/del virtchnl_vlan_filter(s) using the
876 * supported fields negotiated via VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS.
878 struct virtchnl_vlan_filter_list_v2 {
882 struct virtchnl_vlan_filter filters[1];
885 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_vlan_filter_list_v2);
887 /* VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2
888 * VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2
889 * VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2
890 * VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2
892 * VF sends this message to enable or disable VLAN stripping or insertion. It
893 * also needs to specify an ethertype. The VF knows which VLAN ethertypes are
894 * allowed and whether or not it's allowed to enable/disable the specific
895 * offload via the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS message. The VF needs to
896 * parse the virtchnl_vlan_caps.offloads fields to determine which offload
897 * messages are allowed.
899 * For example, if the PF populates the virtchnl_vlan_caps.offloads in the
900 * following manner the VF will be allowed to enable and/or disable 0x8100 inner
901 * VLAN insertion and/or stripping via the opcodes listed above. Inner in this
902 * case means the outer most or single VLAN from the VF's perspective. This is
903 * because no outer offloads are supported. See the comments above the
904 * virtchnl_vlan_supported_caps structure for more details.
906 * virtchnl_vlan_caps.offloads.stripping_support.inner =
907 * VIRTCHNL_VLAN_TOGGLE |
908 * VIRTCHNL_VLAN_ETHERTYPE_8100;
910 * virtchnl_vlan_caps.offloads.insertion_support.inner =
911 * VIRTCHNL_VLAN_TOGGLE |
912 * VIRTCHNL_VLAN_ETHERTYPE_8100;
914 * In order to enable inner (again note that in this case inner is the outer
915 * most or single VLAN from the VF's perspective) VLAN stripping for 0x8100
916 * VLANs, the VF would populate the virtchnl_vlan_offload structure in the
917 * following manner and send the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 message.
919 * virtchnl_vlan_offload.inner_ethertype_setting =
920 * VIRTCHNL_VLAN_ETHERTYPE_8100;
922 * virtchnl_vlan_offload.vport_id = vport_id or vsi_id assigned to the VF on
925 * The reason that VLAN TPID(s) are not being used for the
926 * outer_ethertype_setting and inner_ethertype_setting fields is because it's
927 * possible a device could support VLAN insertion and/or stripping offload on
928 * multiple ethertypes concurrently, so this method allows a VF to request
929 * multiple ethertypes in one message using the virtchnl_vlan_support
932 * For example, if the PF populates the virtchnl_vlan_caps.offloads in the
933 * following manner the VF will be allowed to enable 0x8100 and 0x88a8 outer
934 * VLAN insertion and stripping simultaneously. The
935 * virtchnl_vlan_caps.offloads.ethertype_match field will also have to be
936 * populated based on what the PF can support.
938 * virtchnl_vlan_caps.offloads.stripping_support.outer =
939 * VIRTCHNL_VLAN_TOGGLE |
940 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
941 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
942 * VIRTCHNL_VLAN_ETHERTYPE_AND;
944 * virtchnl_vlan_caps.offloads.insertion_support.outer =
945 * VIRTCHNL_VLAN_TOGGLE |
946 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
947 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
948 * VIRTCHNL_VLAN_ETHERTYPE_AND;
950 * In order to enable outer VLAN stripping for 0x8100 and 0x88a8 VLANs, the VF
951 * would populate the virthcnl_vlan_offload_structure in the following manner
952 * and send the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 message.
954 * virtchnl_vlan_offload.outer_ethertype_setting =
955 * VIRTHCNL_VLAN_ETHERTYPE_8100 |
956 * VIRTHCNL_VLAN_ETHERTYPE_88A8;
958 * virtchnl_vlan_offload.vport_id = vport_id or vsi_id assigned to the VF on
961 * There is also the case where a PF and the underlying hardware can support
962 * VLAN offloads on multiple ethertypes, but not concurrently. For example, if
963 * the PF populates the virtchnl_vlan_caps.offloads in the following manner the
964 * VF will be allowed to enable and/or disable 0x8100 XOR 0x88a8 outer VLAN
965 * offloads. The ethertypes must match for stripping and insertion.
967 * virtchnl_vlan_caps.offloads.stripping_support.outer =
968 * VIRTCHNL_VLAN_TOGGLE |
969 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
970 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
971 * VIRTCHNL_VLAN_ETHERTYPE_XOR;
973 * virtchnl_vlan_caps.offloads.insertion_support.outer =
974 * VIRTCHNL_VLAN_TOGGLE |
975 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
976 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
977 * VIRTCHNL_VLAN_ETHERTYPE_XOR;
979 * virtchnl_vlan_caps.offloads.ethertype_match =
980 * VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION;
982 * In order to enable outer VLAN stripping for 0x88a8 VLANs, the VF would
983 * populate the virtchnl_vlan_offload_structure in the following manner and send
984 * the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2. Also, this will change the
985 * ethertype for VLAN insertion if it's enabled. So, for completeness, a
986 * VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 with the same ethertype should be sent.
988 * virtchnl_vlan_offload.outer_ethertype_setting = VIRTHCNL_VLAN_ETHERTYPE_88A8;
990 * virtchnl_vlan_offload.vport_id = vport_id or vsi_id assigned to the VF on
993 struct virtchnl_vlan_offload {
994 u32 outer_ethertype_setting;
995 u32 inner_ethertype_setting;
1000 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vlan_offload);
1002 /* VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE
1003 * VF sends VSI id and flags.
1004 * PF returns status code in retval.
1005 * Note: we assume that broadcast accept mode is always enabled.
1007 struct virtchnl_promisc_info {
1012 VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_promisc_info);
1014 #define FLAG_VF_UNICAST_PROMISC 0x00000001
1015 #define FLAG_VF_MULTICAST_PROMISC 0x00000002
1017 /* VIRTCHNL_OP_GET_STATS
1018 * VF sends this message to request stats for the selected VSI. VF uses
1019 * the virtchnl_queue_select struct to specify the VSI. The queue_id
1020 * field is ignored by the PF.
1022 * PF replies with struct virtchnl_eth_stats in an external buffer.
1025 struct virtchnl_eth_stats {
1026 u64 rx_bytes; /* received bytes */
1027 u64 rx_unicast; /* received unicast pkts */
1028 u64 rx_multicast; /* received multicast pkts */
1029 u64 rx_broadcast; /* received broadcast pkts */
1031 u64 rx_unknown_protocol;
1032 u64 tx_bytes; /* transmitted bytes */
1033 u64 tx_unicast; /* transmitted unicast pkts */
1034 u64 tx_multicast; /* transmitted multicast pkts */
1035 u64 tx_broadcast; /* transmitted broadcast pkts */
1040 /* VIRTCHNL_OP_CONFIG_RSS_KEY
1041 * VIRTCHNL_OP_CONFIG_RSS_LUT
1042 * VF sends these messages to configure RSS. Only supported if both PF
1043 * and VF drivers set the VIRTCHNL_VF_OFFLOAD_RSS_PF bit during
1044 * configuration negotiation. If this is the case, then the RSS fields in
1045 * the VF resource struct are valid.
1046 * Both the key and LUT are initialized to 0 by the PF, meaning that
1047 * RSS is effectively disabled until set up by the VF.
1049 struct virtchnl_rss_key {
1052 u8 key[1]; /* RSS hash key, packed bytes */
1055 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_rss_key);
1057 struct virtchnl_rss_lut {
1060 u8 lut[1]; /* RSS lookup table */
1063 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_rss_lut);
1065 /* VIRTCHNL_OP_GET_RSS_HENA_CAPS
1066 * VIRTCHNL_OP_SET_RSS_HENA
1067 * VF sends these messages to get and set the hash filter enable bits for RSS.
1068 * By default, the PF sets these to all possible traffic types that the
1069 * hardware supports. The VF can query this value if it wants to change the
1070 * traffic types that are hashed by the hardware.
1072 struct virtchnl_rss_hena {
1076 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_rss_hena);
1078 /* Type of RSS algorithm */
1079 enum virtchnl_rss_algorithm {
1080 VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC = 0,
1081 VIRTCHNL_RSS_ALG_XOR_ASYMMETRIC = 1,
1082 VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC = 2,
1083 VIRTCHNL_RSS_ALG_XOR_SYMMETRIC = 3,
1086 /* This is used by PF driver to enforce how many channels can be supported.
1087 * When ADQ_V2 capability is negotiated, it will allow 16 channels otherwise
1088 * PF driver will allow only max 4 channels
1090 #define VIRTCHNL_MAX_ADQ_CHANNELS 4
1091 #define VIRTCHNL_MAX_ADQ_V2_CHANNELS 16
1093 /* VIRTCHNL_OP_ENABLE_CHANNELS
1094 * VIRTCHNL_OP_DISABLE_CHANNELS
1095 * VF sends these messages to enable or disable channels based on
1096 * the user specified queue count and queue offset for each traffic class.
1097 * This struct encompasses all the information that the PF needs from
1098 * VF to create a channel.
1100 struct virtchnl_channel_info {
1101 u16 count; /* number of queues in a channel */
1102 u16 offset; /* queues in a channel start from 'offset' */
1107 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_channel_info);
1109 struct virtchnl_tc_info {
1112 struct virtchnl_channel_info list[1];
1115 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_tc_info);
1117 /* VIRTCHNL_ADD_CLOUD_FILTER
1118 * VIRTCHNL_DEL_CLOUD_FILTER
1119 * VF sends these messages to add or delete a cloud filter based on the
1120 * user specified match and action filters. These structures encompass
1121 * all the information that the PF needs from the VF to add/delete a
1125 struct virtchnl_l4_spec {
1126 u8 src_mac[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
1127 u8 dst_mac[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
1128 /* vlan_prio is part of this 16 bit field even from OS perspective
1129 * vlan_id:12 is actual vlan_id, then vlanid:bit14..12 is vlan_prio
1130 * in future, when decided to offload vlan_prio, pass that information
1131 * as part of the "vlan_id" field, Bit14..12
1134 __be16 pad; /* reserved for future use */
1141 VIRTCHNL_CHECK_STRUCT_LEN(52, virtchnl_l4_spec);
1143 union virtchnl_flow_spec {
1144 struct virtchnl_l4_spec tcp_spec;
1145 u8 buffer[128]; /* reserved for future use */
1148 VIRTCHNL_CHECK_UNION_LEN(128, virtchnl_flow_spec);
1150 enum virtchnl_action {
1152 VIRTCHNL_ACTION_DROP = 0,
1153 VIRTCHNL_ACTION_TC_REDIRECT,
1154 VIRTCHNL_ACTION_PASSTHRU,
1155 VIRTCHNL_ACTION_QUEUE,
1156 VIRTCHNL_ACTION_Q_REGION,
1157 VIRTCHNL_ACTION_MARK,
1158 VIRTCHNL_ACTION_COUNT,
1161 enum virtchnl_flow_type {
1163 VIRTCHNL_TCP_V4_FLOW = 0,
1164 VIRTCHNL_TCP_V6_FLOW,
1165 VIRTCHNL_UDP_V4_FLOW,
1166 VIRTCHNL_UDP_V6_FLOW,
1169 struct virtchnl_filter {
1170 union virtchnl_flow_spec data;
1171 union virtchnl_flow_spec mask;
1172 enum virtchnl_flow_type flow_type;
1173 enum virtchnl_action action;
1178 VIRTCHNL_CHECK_STRUCT_LEN(272, virtchnl_filter);
1180 /* VIRTCHNL_OP_DCF_GET_VSI_MAP
1181 * VF sends this message to get VSI mapping table.
1182 * PF responds with an indirect message containing VF's
1184 * The index of vf_vsi array is the logical VF ID, the
1185 * value of vf_vsi array is the VF's HW VSI ID with its
1186 * valid configuration.
1188 struct virtchnl_dcf_vsi_map {
1189 u16 pf_vsi; /* PF's HW VSI ID */
1190 u16 num_vfs; /* The actual number of VFs allocated */
1191 #define VIRTCHNL_DCF_VF_VSI_ID_S 0
1192 #define VIRTCHNL_DCF_VF_VSI_ID_M (0xFFF << VIRTCHNL_DCF_VF_VSI_ID_S)
1193 #define VIRTCHNL_DCF_VF_VSI_VALID BIT(15)
1197 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_dcf_vsi_map);
1199 #define PKG_NAME_SIZE 32
1202 struct pkg_version {
1209 VIRTCHNL_CHECK_STRUCT_LEN(4, pkg_version);
1211 struct virtchnl_pkg_info {
1212 struct pkg_version pkg_ver;
1214 char pkg_name[PKG_NAME_SIZE];
1218 VIRTCHNL_CHECK_STRUCT_LEN(48, virtchnl_pkg_info);
1220 struct virtchnl_supported_rxdids {
1221 u64 supported_rxdids;
1224 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_supported_rxdids);
1226 /* VIRTCHNL_OP_EVENT
1227 * PF sends this message to inform the VF driver of events that may affect it.
1228 * No direct response is expected from the VF, though it may generate other
1229 * messages in response to this one.
1231 enum virtchnl_event_codes {
1232 VIRTCHNL_EVENT_UNKNOWN = 0,
1233 VIRTCHNL_EVENT_LINK_CHANGE,
1234 VIRTCHNL_EVENT_RESET_IMPENDING,
1235 VIRTCHNL_EVENT_PF_DRIVER_CLOSE,
1236 VIRTCHNL_EVENT_DCF_VSI_MAP_UPDATE,
1239 #define PF_EVENT_SEVERITY_INFO 0
1240 #define PF_EVENT_SEVERITY_ATTENTION 1
1241 #define PF_EVENT_SEVERITY_ACTION_REQUIRED 2
1242 #define PF_EVENT_SEVERITY_CERTAIN_DOOM 255
1244 struct virtchnl_pf_event {
1245 enum virtchnl_event_codes event;
1247 /* If the PF driver does not support the new speed reporting
1248 * capabilities then use link_event else use link_event_adv to
1249 * get the speed and link information. The ability to understand
1250 * new speeds is indicated by setting the capability flag
1251 * VIRTCHNL_VF_CAP_ADV_LINK_SPEED in vf_cap_flags parameter
1252 * in virtchnl_vf_resource struct and can be used to determine
1253 * which link event struct to use below.
1256 enum virtchnl_link_speed link_speed;
1260 /* link_speed provided in Mbps */
1273 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_pf_event);
1276 /* VF reset states - these are written into the RSTAT register:
1277 * VFGEN_RSTAT on the VF
1278 * When the PF initiates a reset, it writes 0
1279 * When the reset is complete, it writes 1
1280 * When the PF detects that the VF has recovered, it writes 2
1281 * VF checks this register periodically to determine if a reset has occurred,
1282 * then polls it to know when the reset is complete.
1283 * If either the PF or VF reads the register while the hardware
1284 * is in a reset state, it will return DEADBEEF, which, when masked
1287 enum virtchnl_vfr_states {
1288 VIRTCHNL_VFR_INPROGRESS = 0,
1289 VIRTCHNL_VFR_COMPLETED,
1290 VIRTCHNL_VFR_VFACTIVE,
1293 #define VIRTCHNL_MAX_NUM_PROTO_HDRS 32
1294 #define PROTO_HDR_SHIFT 5
1295 #define PROTO_HDR_FIELD_START(proto_hdr_type) \
1296 (proto_hdr_type << PROTO_HDR_SHIFT)
1297 #define PROTO_HDR_FIELD_MASK ((1UL << PROTO_HDR_SHIFT) - 1)
1299 /* VF use these macros to configure each protocol header.
1300 * Specify which protocol headers and protocol header fields base on
1301 * virtchnl_proto_hdr_type and virtchnl_proto_hdr_field.
1302 * @param hdr: a struct of virtchnl_proto_hdr
1303 * @param hdr_type: ETH/IPV4/TCP, etc
1304 * @param field: SRC/DST/TEID/SPI, etc
1306 #define VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, field) \
1307 ((hdr)->field_selector |= BIT((field) & PROTO_HDR_FIELD_MASK))
1308 #define VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, field) \
1309 ((hdr)->field_selector &= ~BIT((field) & PROTO_HDR_FIELD_MASK))
1310 #define VIRTCHNL_TEST_PROTO_HDR_FIELD(hdr, val) \
1311 ((hdr)->field_selector & BIT((val) & PROTO_HDR_FIELD_MASK))
1312 #define VIRTCHNL_GET_PROTO_HDR_FIELD(hdr) ((hdr)->field_selector)
1314 #define VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \
1315 (VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, \
1316 VIRTCHNL_PROTO_HDR_ ## hdr_type ## _ ## field))
1317 #define VIRTCHNL_DEL_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \
1318 (VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, \
1319 VIRTCHNL_PROTO_HDR_ ## hdr_type ## _ ## field))
1321 #define VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, hdr_type) \
1322 ((hdr)->type = VIRTCHNL_PROTO_HDR_ ## hdr_type)
1323 #define VIRTCHNL_GET_PROTO_HDR_TYPE(hdr) \
1324 (((hdr)->type) >> PROTO_HDR_SHIFT)
1325 #define VIRTCHNL_TEST_PROTO_HDR_TYPE(hdr, val) \
1326 ((hdr)->type == ((val) >> PROTO_HDR_SHIFT))
1327 #define VIRTCHNL_TEST_PROTO_HDR(hdr, val) \
1328 (VIRTCHNL_TEST_PROTO_HDR_TYPE(hdr, val) && \
1329 VIRTCHNL_TEST_PROTO_HDR_FIELD(hdr, val))
1331 /* Protocol header type within a packet segment. A segment consists of one or
1332 * more protocol headers that make up a logical group of protocol headers. Each
1333 * logical group of protocol headers encapsulates or is encapsulated using/by
1334 * tunneling or encapsulation protocols for network virtualization.
1336 enum virtchnl_proto_hdr_type {
1337 VIRTCHNL_PROTO_HDR_NONE,
1338 VIRTCHNL_PROTO_HDR_ETH,
1339 VIRTCHNL_PROTO_HDR_S_VLAN,
1340 VIRTCHNL_PROTO_HDR_C_VLAN,
1341 VIRTCHNL_PROTO_HDR_IPV4,
1342 VIRTCHNL_PROTO_HDR_IPV6,
1343 VIRTCHNL_PROTO_HDR_TCP,
1344 VIRTCHNL_PROTO_HDR_UDP,
1345 VIRTCHNL_PROTO_HDR_SCTP,
1346 VIRTCHNL_PROTO_HDR_GTPU_IP,
1347 VIRTCHNL_PROTO_HDR_GTPU_EH,
1348 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN,
1349 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP,
1350 VIRTCHNL_PROTO_HDR_PPPOE,
1351 VIRTCHNL_PROTO_HDR_L2TPV3,
1352 VIRTCHNL_PROTO_HDR_ESP,
1353 VIRTCHNL_PROTO_HDR_AH,
1354 VIRTCHNL_PROTO_HDR_PFCP,
1355 VIRTCHNL_PROTO_HDR_GTPC,
1356 VIRTCHNL_PROTO_HDR_ECPRI,
1359 /* Protocol header field within a protocol header. */
1360 enum virtchnl_proto_hdr_field {
1362 VIRTCHNL_PROTO_HDR_ETH_SRC =
1363 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ETH),
1364 VIRTCHNL_PROTO_HDR_ETH_DST,
1365 VIRTCHNL_PROTO_HDR_ETH_ETHERTYPE,
1367 VIRTCHNL_PROTO_HDR_S_VLAN_ID =
1368 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_S_VLAN),
1370 VIRTCHNL_PROTO_HDR_C_VLAN_ID =
1371 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_C_VLAN),
1373 VIRTCHNL_PROTO_HDR_IPV4_SRC =
1374 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV4),
1375 VIRTCHNL_PROTO_HDR_IPV4_DST,
1376 VIRTCHNL_PROTO_HDR_IPV4_DSCP,
1377 VIRTCHNL_PROTO_HDR_IPV4_TTL,
1378 VIRTCHNL_PROTO_HDR_IPV4_PROT,
1380 VIRTCHNL_PROTO_HDR_IPV6_SRC =
1381 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV6),
1382 VIRTCHNL_PROTO_HDR_IPV6_DST,
1383 VIRTCHNL_PROTO_HDR_IPV6_TC,
1384 VIRTCHNL_PROTO_HDR_IPV6_HOP_LIMIT,
1385 VIRTCHNL_PROTO_HDR_IPV6_PROT,
1387 VIRTCHNL_PROTO_HDR_IPV6_PREFIX32_SRC,
1388 VIRTCHNL_PROTO_HDR_IPV6_PREFIX32_DST,
1389 VIRTCHNL_PROTO_HDR_IPV6_PREFIX40_SRC,
1390 VIRTCHNL_PROTO_HDR_IPV6_PREFIX40_DST,
1391 VIRTCHNL_PROTO_HDR_IPV6_PREFIX48_SRC,
1392 VIRTCHNL_PROTO_HDR_IPV6_PREFIX48_DST,
1393 VIRTCHNL_PROTO_HDR_IPV6_PREFIX56_SRC,
1394 VIRTCHNL_PROTO_HDR_IPV6_PREFIX56_DST,
1395 VIRTCHNL_PROTO_HDR_IPV6_PREFIX64_SRC,
1396 VIRTCHNL_PROTO_HDR_IPV6_PREFIX64_DST,
1397 VIRTCHNL_PROTO_HDR_IPV6_PREFIX96_SRC,
1398 VIRTCHNL_PROTO_HDR_IPV6_PREFIX96_DST,
1400 VIRTCHNL_PROTO_HDR_TCP_SRC_PORT =
1401 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_TCP),
1402 VIRTCHNL_PROTO_HDR_TCP_DST_PORT,
1404 VIRTCHNL_PROTO_HDR_UDP_SRC_PORT =
1405 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_UDP),
1406 VIRTCHNL_PROTO_HDR_UDP_DST_PORT,
1408 VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT =
1409 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_SCTP),
1410 VIRTCHNL_PROTO_HDR_SCTP_DST_PORT,
1412 VIRTCHNL_PROTO_HDR_GTPU_IP_TEID =
1413 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_IP),
1415 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU =
1416 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH),
1417 VIRTCHNL_PROTO_HDR_GTPU_EH_QFI,
1419 VIRTCHNL_PROTO_HDR_PPPOE_SESS_ID =
1420 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_PPPOE),
1422 VIRTCHNL_PROTO_HDR_L2TPV3_SESS_ID =
1423 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_L2TPV3),
1425 VIRTCHNL_PROTO_HDR_ESP_SPI =
1426 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ESP),
1428 VIRTCHNL_PROTO_HDR_AH_SPI =
1429 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_AH),
1431 VIRTCHNL_PROTO_HDR_PFCP_S_FIELD =
1432 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_PFCP),
1433 VIRTCHNL_PROTO_HDR_PFCP_SEID,
1435 VIRTCHNL_PROTO_HDR_GTPC_TEID =
1436 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPC),
1438 VIRTCHNL_PROTO_HDR_ECPRI_MSG_TYPE =
1439 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ECPRI),
1440 VIRTCHNL_PROTO_HDR_ECPRI_PC_RTC_ID,
1443 struct virtchnl_proto_hdr {
1444 enum virtchnl_proto_hdr_type type;
1445 u32 field_selector; /* a bit mask to select field for header type */
1448 * binary buffer in network order for specific header type.
1449 * For example, if type = VIRTCHNL_PROTO_HDR_IPV4, a IPv4
1450 * header is expected to be copied into the buffer.
1454 VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_proto_hdr);
1456 struct virtchnl_proto_hdrs {
1459 * specify where protocol header start from.
1460 * 0 - from the outer layer
1461 * 1 - from the first inner layer
1462 * 2 - from the second inner layer
1465 int count; /* the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS */
1466 struct virtchnl_proto_hdr proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
1469 VIRTCHNL_CHECK_STRUCT_LEN(2312, virtchnl_proto_hdrs);
1471 struct virtchnl_rss_cfg {
1472 struct virtchnl_proto_hdrs proto_hdrs; /* protocol headers */
1473 enum virtchnl_rss_algorithm rss_algorithm; /* rss algorithm type */
1474 u8 reserved[128]; /* reserve for future */
1477 VIRTCHNL_CHECK_STRUCT_LEN(2444, virtchnl_rss_cfg);
1479 /* action configuration for FDIR */
1480 struct virtchnl_filter_action {
1481 enum virtchnl_action type;
1483 /* used for queue and qgroup action */
1488 /* used for count action */
1490 /* share counter ID with other flow rules */
1492 u32 id; /* counter ID */
1494 /* used for mark action */
1500 VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_filter_action);
1502 #define VIRTCHNL_MAX_NUM_ACTIONS 8
1504 struct virtchnl_filter_action_set {
1505 /* action number must be less then VIRTCHNL_MAX_NUM_ACTIONS */
1507 struct virtchnl_filter_action actions[VIRTCHNL_MAX_NUM_ACTIONS];
1510 VIRTCHNL_CHECK_STRUCT_LEN(292, virtchnl_filter_action_set);
1512 /* pattern and action for FDIR rule */
1513 struct virtchnl_fdir_rule {
1514 struct virtchnl_proto_hdrs proto_hdrs;
1515 struct virtchnl_filter_action_set action_set;
1518 VIRTCHNL_CHECK_STRUCT_LEN(2604, virtchnl_fdir_rule);
1520 /* query information to retrieve fdir rule counters.
1521 * PF will fill out this structure to reset counter.
1523 struct virtchnl_fdir_query_info {
1524 u32 match_packets_valid:1;
1525 u32 match_bytes_valid:1;
1526 u32 reserved:30; /* Reserved, must be zero. */
1528 u64 matched_packets; /* Number of packets for this rule. */
1529 u64 matched_bytes; /* Number of bytes through this rule. */
1532 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_fdir_query_info);
1534 /* Status returned to VF after VF requests FDIR commands
1535 * VIRTCHNL_FDIR_SUCCESS
1536 * VF FDIR related request is successfully done by PF
1537 * The request can be OP_ADD/DEL/QUERY_FDIR_FILTER.
1539 * VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE
1540 * OP_ADD_FDIR_FILTER request is failed due to no Hardware resource.
1542 * VIRTCHNL_FDIR_FAILURE_RULE_EXIST
1543 * OP_ADD_FDIR_FILTER request is failed due to the rule is already existed.
1545 * VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT
1546 * OP_ADD_FDIR_FILTER request is failed due to conflict with existing rule.
1548 * VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST
1549 * OP_DEL_FDIR_FILTER request is failed due to this rule doesn't exist.
1551 * VIRTCHNL_FDIR_FAILURE_RULE_INVALID
1552 * OP_ADD_FDIR_FILTER request is failed due to parameters validation
1553 * or HW doesn't support.
1555 * VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT
1556 * OP_ADD/DEL_FDIR_FILTER request is failed due to timing out
1559 * VIRTCHNL_FDIR_FAILURE_QUERY_INVALID
1560 * OP_QUERY_FDIR_FILTER request is failed due to parameters validation,
1561 * for example, VF query counter of a rule who has no counter action.
1563 enum virtchnl_fdir_prgm_status {
1564 VIRTCHNL_FDIR_SUCCESS = 0,
1565 VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE,
1566 VIRTCHNL_FDIR_FAILURE_RULE_EXIST,
1567 VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT,
1568 VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST,
1569 VIRTCHNL_FDIR_FAILURE_RULE_INVALID,
1570 VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT,
1571 VIRTCHNL_FDIR_FAILURE_QUERY_INVALID,
1574 /* VIRTCHNL_OP_ADD_FDIR_FILTER
1575 * VF sends this request to PF by filling out vsi_id,
1576 * validate_only and rule_cfg. PF will return flow_id
1577 * if the request is successfully done and return add_status to VF.
1579 struct virtchnl_fdir_add {
1580 u16 vsi_id; /* INPUT */
1582 * 1 for validating a fdir rule, 0 for creating a fdir rule.
1583 * Validate and create share one ops: VIRTCHNL_OP_ADD_FDIR_FILTER.
1585 u16 validate_only; /* INPUT */
1586 u32 flow_id; /* OUTPUT */
1587 struct virtchnl_fdir_rule rule_cfg; /* INPUT */
1588 enum virtchnl_fdir_prgm_status status; /* OUTPUT */
1591 VIRTCHNL_CHECK_STRUCT_LEN(2616, virtchnl_fdir_add);
1593 /* VIRTCHNL_OP_DEL_FDIR_FILTER
1594 * VF sends this request to PF by filling out vsi_id
1595 * and flow_id. PF will return del_status to VF.
1597 struct virtchnl_fdir_del {
1598 u16 vsi_id; /* INPUT */
1600 u32 flow_id; /* INPUT */
1601 enum virtchnl_fdir_prgm_status status; /* OUTPUT */
1604 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del);
1606 /* VIRTCHNL_OP_QUERY_FDIR_FILTER
1607 * VF sends this request to PF by filling out vsi_id,
1608 * flow_id and reset_counter. PF will return query_info
1609 * and query_status to VF.
1611 struct virtchnl_fdir_query {
1612 u16 vsi_id; /* INPUT */
1614 u32 flow_id; /* INPUT */
1615 u32 reset_counter:1; /* INPUT */
1616 struct virtchnl_fdir_query_info query_info; /* OUTPUT */
1617 enum virtchnl_fdir_prgm_status status; /* OUTPUT */
1621 VIRTCHNL_CHECK_STRUCT_LEN(48, virtchnl_fdir_query);
1623 /* TX and RX queue types are valid in legacy as well as split queue models.
1624 * With Split Queue model, 2 additional types are introduced - TX_COMPLETION
1625 * and RX_BUFFER. In split queue model, RX corresponds to the queue where HW
1626 * posts completions.
1628 enum virtchnl_queue_type {
1629 VIRTCHNL_QUEUE_TYPE_TX = 0,
1630 VIRTCHNL_QUEUE_TYPE_RX = 1,
1631 VIRTCHNL_QUEUE_TYPE_TX_COMPLETION = 2,
1632 VIRTCHNL_QUEUE_TYPE_RX_BUFFER = 3,
1633 VIRTCHNL_QUEUE_TYPE_CONFIG_TX = 4,
1634 VIRTCHNL_QUEUE_TYPE_CONFIG_RX = 5
1638 /* structure to specify a chunk of contiguous queues */
1639 struct virtchnl_queue_chunk {
1640 enum virtchnl_queue_type type;
1645 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_queue_chunk);
1647 /* structure to specify several chunks of contiguous queues */
1648 struct virtchnl_queue_chunks {
1651 struct virtchnl_queue_chunk chunks[1];
1654 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_chunks);
1657 /* VIRTCHNL_OP_ENABLE_QUEUES_V2
1658 * VIRTCHNL_OP_DISABLE_QUEUES_V2
1659 * VIRTCHNL_OP_DEL_QUEUES
1661 * If VIRTCHNL_CAP_EXT_FEATURES was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
1662 * then all of these ops are available.
1664 * If VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
1665 * then VIRTCHNL_OP_ENABLE_QUEUES_V2 and VIRTCHNL_OP_DISABLE_QUEUES_V2 are
1668 * PF sends these messages to enable, disable or delete queues specified in
1669 * chunks. PF sends virtchnl_del_ena_dis_queues struct to specify the queues
1670 * to be enabled/disabled/deleted. Also applicable to single queue RX or
1671 * TX. CP performs requested action and returns status.
1673 struct virtchnl_del_ena_dis_queues {
1676 struct virtchnl_queue_chunks chunks;
1679 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_del_ena_dis_queues);
1681 /* Virtchannel interrupt throttling rate index */
1682 enum virtchnl_itr_idx {
1683 VIRTCHNL_ITR_IDX_0 = 0,
1684 VIRTCHNL_ITR_IDX_1 = 1,
1685 VIRTCHNL_ITR_IDX_NO_ITR = 3,
1688 /* Queue to vector mapping */
1689 struct virtchnl_queue_vector {
1693 enum virtchnl_itr_idx itr_idx;
1694 enum virtchnl_queue_type queue_type;
1697 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_queue_vector);
1699 /* VIRTCHNL_OP_MAP_QUEUE_VECTOR
1700 * VIRTCHNL_OP_UNMAP_QUEUE_VECTOR
1702 * If VIRTCHNL_CAP_EXT_FEATURES was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
1703 * then all of these ops are available.
1705 * If VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
1706 * then only VIRTCHNL_OP_MAP_QUEUE_VECTOR is available.
1708 * PF sends this message to map or unmap queues to vectors and ITR index
1709 * registers. External data buffer contains virtchnl_queue_vector_maps structure
1710 * that contains num_qv_maps of virtchnl_queue_vector structures.
1711 * CP maps the requested queue vector maps after validating the queue and vector
1712 * ids and returns a status code.
1714 struct virtchnl_queue_vector_maps {
1718 struct virtchnl_queue_vector qv_maps[1];
1721 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_queue_vector_maps);
1724 /* Since VF messages are limited by u16 size, precalculate the maximum possible
1725 * values of nested elements in virtchnl structures that virtual channel can
1726 * possibly handle in a single message.
1728 enum virtchnl_vector_limits {
1729 VIRTCHNL_OP_CONFIG_VSI_QUEUES_MAX =
1730 ((u16)(~0) - sizeof(struct virtchnl_vsi_queue_config_info)) /
1731 sizeof(struct virtchnl_queue_pair_info),
1733 VIRTCHNL_OP_CONFIG_IRQ_MAP_MAX =
1734 ((u16)(~0) - sizeof(struct virtchnl_irq_map_info)) /
1735 sizeof(struct virtchnl_vector_map),
1737 VIRTCHNL_OP_ADD_DEL_ETH_ADDR_MAX =
1738 ((u16)(~0) - sizeof(struct virtchnl_ether_addr_list)) /
1739 sizeof(struct virtchnl_ether_addr),
1741 VIRTCHNL_OP_ADD_DEL_VLAN_MAX =
1742 ((u16)(~0) - sizeof(struct virtchnl_vlan_filter_list)) /
1746 VIRTCHNL_OP_ENABLE_CHANNELS_MAX =
1747 ((u16)(~0) - sizeof(struct virtchnl_tc_info)) /
1748 sizeof(struct virtchnl_channel_info),
1750 VIRTCHNL_OP_ENABLE_DISABLE_DEL_QUEUES_V2_MAX =
1751 ((u16)(~0) - sizeof(struct virtchnl_del_ena_dis_queues)) /
1752 sizeof(struct virtchnl_queue_chunk),
1754 VIRTCHNL_OP_MAP_UNMAP_QUEUE_VECTOR_MAX =
1755 ((u16)(~0) - sizeof(struct virtchnl_queue_vector_maps)) /
1756 sizeof(struct virtchnl_queue_vector),
1758 VIRTCHNL_OP_ADD_DEL_VLAN_V2_MAX =
1759 ((u16)(~0) - sizeof(struct virtchnl_vlan_filter_list_v2)) /
1760 sizeof(struct virtchnl_vlan_filter),
1764 * virtchnl_vc_validate_vf_msg
1765 * @ver: Virtchnl version info
1766 * @v_opcode: Opcode for the message
1767 * @msg: pointer to the msg buffer
1768 * @msglen: msg length
1770 * validate msg format against struct for each opcode
1773 virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
1774 u8 *msg, u16 msglen)
1776 bool err_msg_format = false;
1779 /* Validate message length. */
1781 case VIRTCHNL_OP_VERSION:
1782 valid_len = sizeof(struct virtchnl_version_info);
1784 case VIRTCHNL_OP_RESET_VF:
1786 case VIRTCHNL_OP_GET_VF_RESOURCES:
1788 valid_len = sizeof(u32);
1790 case VIRTCHNL_OP_CONFIG_TX_QUEUE:
1791 valid_len = sizeof(struct virtchnl_txq_info);
1793 case VIRTCHNL_OP_CONFIG_RX_QUEUE:
1794 valid_len = sizeof(struct virtchnl_rxq_info);
1796 case VIRTCHNL_OP_CONFIG_VSI_QUEUES:
1797 valid_len = sizeof(struct virtchnl_vsi_queue_config_info);
1798 if (msglen >= valid_len) {
1799 struct virtchnl_vsi_queue_config_info *vqc =
1800 (struct virtchnl_vsi_queue_config_info *)msg;
1802 if (vqc->num_queue_pairs == 0 || vqc->num_queue_pairs >
1803 VIRTCHNL_OP_CONFIG_VSI_QUEUES_MAX) {
1804 err_msg_format = true;
1808 valid_len += (vqc->num_queue_pairs *
1810 virtchnl_queue_pair_info));
1813 case VIRTCHNL_OP_CONFIG_IRQ_MAP:
1814 valid_len = sizeof(struct virtchnl_irq_map_info);
1815 if (msglen >= valid_len) {
1816 struct virtchnl_irq_map_info *vimi =
1817 (struct virtchnl_irq_map_info *)msg;
1819 if (vimi->num_vectors == 0 || vimi->num_vectors >
1820 VIRTCHNL_OP_CONFIG_IRQ_MAP_MAX) {
1821 err_msg_format = true;
1825 valid_len += (vimi->num_vectors *
1826 sizeof(struct virtchnl_vector_map));
1829 case VIRTCHNL_OP_ENABLE_QUEUES:
1830 case VIRTCHNL_OP_DISABLE_QUEUES:
1831 valid_len = sizeof(struct virtchnl_queue_select);
1833 case VIRTCHNL_OP_GET_MAX_RSS_QREGION:
1835 case VIRTCHNL_OP_ADD_ETH_ADDR:
1836 case VIRTCHNL_OP_DEL_ETH_ADDR:
1837 valid_len = sizeof(struct virtchnl_ether_addr_list);
1838 if (msglen >= valid_len) {
1839 struct virtchnl_ether_addr_list *veal =
1840 (struct virtchnl_ether_addr_list *)msg;
1842 if (veal->num_elements == 0 || veal->num_elements >
1843 VIRTCHNL_OP_ADD_DEL_ETH_ADDR_MAX) {
1844 err_msg_format = true;
1848 valid_len += veal->num_elements *
1849 sizeof(struct virtchnl_ether_addr);
1852 case VIRTCHNL_OP_ADD_VLAN:
1853 case VIRTCHNL_OP_DEL_VLAN:
1854 valid_len = sizeof(struct virtchnl_vlan_filter_list);
1855 if (msglen >= valid_len) {
1856 struct virtchnl_vlan_filter_list *vfl =
1857 (struct virtchnl_vlan_filter_list *)msg;
1859 if (vfl->num_elements == 0 || vfl->num_elements >
1860 VIRTCHNL_OP_ADD_DEL_VLAN_MAX) {
1861 err_msg_format = true;
1865 valid_len += vfl->num_elements * sizeof(u16);
1868 case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE:
1869 valid_len = sizeof(struct virtchnl_promisc_info);
1871 case VIRTCHNL_OP_GET_STATS:
1872 valid_len = sizeof(struct virtchnl_queue_select);
1874 case VIRTCHNL_OP_CONFIG_RSS_KEY:
1875 valid_len = sizeof(struct virtchnl_rss_key);
1876 if (msglen >= valid_len) {
1877 struct virtchnl_rss_key *vrk =
1878 (struct virtchnl_rss_key *)msg;
1880 if (vrk->key_len == 0) {
1881 /* zero length is allowed as input */
1885 valid_len += vrk->key_len - 1;
1888 case VIRTCHNL_OP_CONFIG_RSS_LUT:
1889 valid_len = sizeof(struct virtchnl_rss_lut);
1890 if (msglen >= valid_len) {
1891 struct virtchnl_rss_lut *vrl =
1892 (struct virtchnl_rss_lut *)msg;
1894 if (vrl->lut_entries == 0) {
1895 /* zero entries is allowed as input */
1899 valid_len += vrl->lut_entries - 1;
1902 case VIRTCHNL_OP_GET_RSS_HENA_CAPS:
1904 case VIRTCHNL_OP_SET_RSS_HENA:
1905 valid_len = sizeof(struct virtchnl_rss_hena);
1907 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING:
1908 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING:
1910 case VIRTCHNL_OP_REQUEST_QUEUES:
1911 valid_len = sizeof(struct virtchnl_vf_res_request);
1913 case VIRTCHNL_OP_ENABLE_CHANNELS:
1914 valid_len = sizeof(struct virtchnl_tc_info);
1915 if (msglen >= valid_len) {
1916 struct virtchnl_tc_info *vti =
1917 (struct virtchnl_tc_info *)msg;
1919 if (vti->num_tc == 0 || vti->num_tc >
1920 VIRTCHNL_OP_ENABLE_CHANNELS_MAX) {
1921 err_msg_format = true;
1925 valid_len += (vti->num_tc - 1) *
1926 sizeof(struct virtchnl_channel_info);
1929 case VIRTCHNL_OP_DISABLE_CHANNELS:
1931 case VIRTCHNL_OP_ADD_CLOUD_FILTER:
1932 case VIRTCHNL_OP_DEL_CLOUD_FILTER:
1933 valid_len = sizeof(struct virtchnl_filter);
1935 case VIRTCHNL_OP_DCF_CMD_DESC:
1936 case VIRTCHNL_OP_DCF_CMD_BUFF:
1937 /* These two opcodes are specific to handle the AdminQ command,
1938 * so the validation needs to be done in PF's context.
1942 case VIRTCHNL_OP_DCF_DISABLE:
1943 case VIRTCHNL_OP_DCF_GET_VSI_MAP:
1944 case VIRTCHNL_OP_DCF_GET_PKG_INFO:
1946 case VIRTCHNL_OP_GET_SUPPORTED_RXDIDS:
1948 case VIRTCHNL_OP_ADD_RSS_CFG:
1949 case VIRTCHNL_OP_DEL_RSS_CFG:
1950 valid_len = sizeof(struct virtchnl_rss_cfg);
1952 case VIRTCHNL_OP_ADD_FDIR_FILTER:
1953 valid_len = sizeof(struct virtchnl_fdir_add);
1955 case VIRTCHNL_OP_DEL_FDIR_FILTER:
1956 valid_len = sizeof(struct virtchnl_fdir_del);
1958 case VIRTCHNL_OP_QUERY_FDIR_FILTER:
1959 valid_len = sizeof(struct virtchnl_fdir_query);
1961 case VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS:
1963 case VIRTCHNL_OP_ADD_VLAN_V2:
1964 case VIRTCHNL_OP_DEL_VLAN_V2:
1965 valid_len = sizeof(struct virtchnl_vlan_filter_list_v2);
1966 if (msglen >= valid_len) {
1967 struct virtchnl_vlan_filter_list_v2 *vfl =
1968 (struct virtchnl_vlan_filter_list_v2 *)msg;
1970 if (vfl->num_elements == 0 || vfl->num_elements >
1971 VIRTCHNL_OP_ADD_DEL_VLAN_V2_MAX) {
1972 err_msg_format = true;
1976 valid_len += (vfl->num_elements - 1) *
1977 sizeof(struct virtchnl_vlan_filter);
1980 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2:
1981 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2:
1982 case VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2:
1983 case VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2:
1984 valid_len = sizeof(struct virtchnl_vlan_offload);
1986 case VIRTCHNL_OP_ENABLE_QUEUES_V2:
1987 case VIRTCHNL_OP_DISABLE_QUEUES_V2:
1988 valid_len = sizeof(struct virtchnl_del_ena_dis_queues);
1989 if (msglen >= valid_len) {
1990 struct virtchnl_del_ena_dis_queues *qs =
1991 (struct virtchnl_del_ena_dis_queues *)msg;
1992 if (qs->chunks.num_chunks == 0 ||
1993 qs->chunks.num_chunks > VIRTCHNL_OP_ENABLE_DISABLE_DEL_QUEUES_V2_MAX) {
1994 err_msg_format = true;
1997 valid_len += (qs->chunks.num_chunks - 1) *
1998 sizeof(struct virtchnl_queue_chunk);
2001 case VIRTCHNL_OP_MAP_QUEUE_VECTOR:
2002 valid_len = sizeof(struct virtchnl_queue_vector_maps);
2003 if (msglen >= valid_len) {
2004 struct virtchnl_queue_vector_maps *v_qp =
2005 (struct virtchnl_queue_vector_maps *)msg;
2006 if (v_qp->num_qv_maps == 0 ||
2007 v_qp->num_qv_maps > VIRTCHNL_OP_MAP_UNMAP_QUEUE_VECTOR_MAX) {
2008 err_msg_format = true;
2011 valid_len += (v_qp->num_qv_maps - 1) *
2012 sizeof(struct virtchnl_queue_vector);
2015 /* These are always errors coming from the VF. */
2016 case VIRTCHNL_OP_EVENT:
2017 case VIRTCHNL_OP_UNKNOWN:
2019 return VIRTCHNL_STATUS_ERR_PARAM;
2021 /* few more checks */
2022 if (err_msg_format || valid_len != msglen)
2023 return VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH;
2027 #endif /* _VIRTCHNL_H_ */