1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2001-2021 Intel Corporation
9 * This header file describes the Virtual Function (VF) - Physical Function
10 * (PF) communication protocol used by the drivers for all devices starting
11 * from our 40G product line
13 * Admin queue buffer usage:
14 * desc->opcode is always aqc_opc_send_msg_to_pf
15 * flags, retval, datalen, and data addr are all used normally.
16 * The Firmware copies the cookie fields when sending messages between the
17 * PF and VF, but uses all other fields internally. Due to this limitation,
18 * we must send all messages as "indirect", i.e. using an external buffer.
20 * All the VSI indexes are relative to the VF. Each VF can have maximum of
21 * three VSIs. All the queue indexes are relative to the VSI. Each VF can
22 * have a maximum of sixteen queues for all of its VSIs.
24 * The PF is required to return a status code in v_retval for all messages
25 * except RESET_VF, which does not require any response. The returned value
26 * is of virtchnl_status_code type, defined in the shared type.h.
28 * In general, VF driver initialization should roughly follow the order of
29 * these opcodes. The VF driver must first validate the API version of the
30 * PF driver, then request a reset, then get resources, then configure
31 * queues and interrupts. After these operations are complete, the VF
32 * driver may start its queues, optionally add MAC and VLAN filters, and
36 /* START GENERIC DEFINES
37 * Need to ensure the following enums and defines hold the same meaning and
38 * value in current and future projects
41 #include "virtchnl_inline_ipsec.h"
44 enum virtchnl_status_code {
45 VIRTCHNL_STATUS_SUCCESS = 0,
46 VIRTCHNL_STATUS_ERR_PARAM = -5,
47 VIRTCHNL_STATUS_ERR_NO_MEMORY = -18,
48 VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH = -38,
49 VIRTCHNL_STATUS_ERR_CQP_COMPL_ERROR = -39,
50 VIRTCHNL_STATUS_ERR_INVALID_VF_ID = -40,
51 VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR = -53,
52 VIRTCHNL_STATUS_ERR_NOT_SUPPORTED = -64,
55 /* Backward compatibility */
56 #define VIRTCHNL_ERR_PARAM VIRTCHNL_STATUS_ERR_PARAM
57 #define VIRTCHNL_STATUS_NOT_SUPPORTED VIRTCHNL_STATUS_ERR_NOT_SUPPORTED
59 #define VIRTCHNL_LINK_SPEED_2_5GB_SHIFT 0x0
60 #define VIRTCHNL_LINK_SPEED_100MB_SHIFT 0x1
61 #define VIRTCHNL_LINK_SPEED_1000MB_SHIFT 0x2
62 #define VIRTCHNL_LINK_SPEED_10GB_SHIFT 0x3
63 #define VIRTCHNL_LINK_SPEED_40GB_SHIFT 0x4
64 #define VIRTCHNL_LINK_SPEED_20GB_SHIFT 0x5
65 #define VIRTCHNL_LINK_SPEED_25GB_SHIFT 0x6
66 #define VIRTCHNL_LINK_SPEED_5GB_SHIFT 0x7
68 enum virtchnl_link_speed {
69 VIRTCHNL_LINK_SPEED_UNKNOWN = 0,
70 VIRTCHNL_LINK_SPEED_100MB = BIT(VIRTCHNL_LINK_SPEED_100MB_SHIFT),
71 VIRTCHNL_LINK_SPEED_1GB = BIT(VIRTCHNL_LINK_SPEED_1000MB_SHIFT),
72 VIRTCHNL_LINK_SPEED_10GB = BIT(VIRTCHNL_LINK_SPEED_10GB_SHIFT),
73 VIRTCHNL_LINK_SPEED_40GB = BIT(VIRTCHNL_LINK_SPEED_40GB_SHIFT),
74 VIRTCHNL_LINK_SPEED_20GB = BIT(VIRTCHNL_LINK_SPEED_20GB_SHIFT),
75 VIRTCHNL_LINK_SPEED_25GB = BIT(VIRTCHNL_LINK_SPEED_25GB_SHIFT),
76 VIRTCHNL_LINK_SPEED_2_5GB = BIT(VIRTCHNL_LINK_SPEED_2_5GB_SHIFT),
77 VIRTCHNL_LINK_SPEED_5GB = BIT(VIRTCHNL_LINK_SPEED_5GB_SHIFT),
80 /* for hsplit_0 field of Rx HMC context */
81 /* deprecated with IAVF 1.0 */
82 enum virtchnl_rx_hsplit {
83 VIRTCHNL_RX_HSPLIT_NO_SPLIT = 0,
84 VIRTCHNL_RX_HSPLIT_SPLIT_L2 = 1,
85 VIRTCHNL_RX_HSPLIT_SPLIT_IP = 2,
86 VIRTCHNL_RX_HSPLIT_SPLIT_TCP_UDP = 4,
87 VIRTCHNL_RX_HSPLIT_SPLIT_SCTP = 8,
90 enum virtchnl_bw_limit_type {
91 VIRTCHNL_BW_SHAPER = 0,
94 #define VIRTCHNL_ETH_LENGTH_OF_ADDRESS 6
95 /* END GENERIC DEFINES */
97 /* Opcodes for VF-PF communication. These are placed in the v_opcode field
98 * of the virtchnl_msg structure.
101 /* The PF sends status change events to VFs using
102 * the VIRTCHNL_OP_EVENT opcode.
103 * VFs send requests to the PF using the other ops.
104 * Use of "advanced opcode" features must be negotiated as part of capabilities
105 * exchange and are not considered part of base mode feature set.
107 VIRTCHNL_OP_UNKNOWN = 0,
108 VIRTCHNL_OP_VERSION = 1, /* must ALWAYS be 1 */
109 VIRTCHNL_OP_RESET_VF = 2,
110 VIRTCHNL_OP_GET_VF_RESOURCES = 3,
111 VIRTCHNL_OP_CONFIG_TX_QUEUE = 4,
112 VIRTCHNL_OP_CONFIG_RX_QUEUE = 5,
113 VIRTCHNL_OP_CONFIG_VSI_QUEUES = 6,
114 VIRTCHNL_OP_CONFIG_IRQ_MAP = 7,
115 VIRTCHNL_OP_ENABLE_QUEUES = 8,
116 VIRTCHNL_OP_DISABLE_QUEUES = 9,
117 VIRTCHNL_OP_ADD_ETH_ADDR = 10,
118 VIRTCHNL_OP_DEL_ETH_ADDR = 11,
119 VIRTCHNL_OP_ADD_VLAN = 12,
120 VIRTCHNL_OP_DEL_VLAN = 13,
121 VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE = 14,
122 VIRTCHNL_OP_GET_STATS = 15,
123 VIRTCHNL_OP_RSVD = 16,
124 VIRTCHNL_OP_EVENT = 17, /* must ALWAYS be 17 */
125 /* opcode 19 is reserved */
126 /* opcodes 20, 21, and 22 are reserved */
127 VIRTCHNL_OP_CONFIG_RSS_KEY = 23,
128 VIRTCHNL_OP_CONFIG_RSS_LUT = 24,
129 VIRTCHNL_OP_GET_RSS_HENA_CAPS = 25,
130 VIRTCHNL_OP_SET_RSS_HENA = 26,
131 VIRTCHNL_OP_ENABLE_VLAN_STRIPPING = 27,
132 VIRTCHNL_OP_DISABLE_VLAN_STRIPPING = 28,
133 VIRTCHNL_OP_REQUEST_QUEUES = 29,
134 VIRTCHNL_OP_ENABLE_CHANNELS = 30,
135 VIRTCHNL_OP_DISABLE_CHANNELS = 31,
136 VIRTCHNL_OP_ADD_CLOUD_FILTER = 32,
137 VIRTCHNL_OP_DEL_CLOUD_FILTER = 33,
138 VIRTCHNL_OP_INLINE_IPSEC_CRYPTO = 34,
139 /* opcodes 35 and 36 are reserved */
140 VIRTCHNL_OP_DCF_CONFIG_BW = 37,
141 VIRTCHNL_OP_DCF_VLAN_OFFLOAD = 38,
142 VIRTCHNL_OP_DCF_CMD_DESC = 39,
143 VIRTCHNL_OP_DCF_CMD_BUFF = 40,
144 VIRTCHNL_OP_DCF_DISABLE = 41,
145 VIRTCHNL_OP_DCF_GET_VSI_MAP = 42,
146 VIRTCHNL_OP_DCF_GET_PKG_INFO = 43,
147 VIRTCHNL_OP_GET_SUPPORTED_RXDIDS = 44,
148 VIRTCHNL_OP_ADD_RSS_CFG = 45,
149 VIRTCHNL_OP_DEL_RSS_CFG = 46,
150 VIRTCHNL_OP_ADD_FDIR_FILTER = 47,
151 VIRTCHNL_OP_DEL_FDIR_FILTER = 48,
152 VIRTCHNL_OP_GET_MAX_RSS_QREGION = 50,
153 VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS = 51,
154 VIRTCHNL_OP_ADD_VLAN_V2 = 52,
155 VIRTCHNL_OP_DEL_VLAN_V2 = 53,
156 VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 = 54,
157 VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 = 55,
158 VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 = 56,
159 VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2 = 57,
160 VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2 = 58,
161 VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2 = 59,
162 VIRTCHNL_OP_GET_QOS_CAPS = 66,
163 VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP = 67,
164 VIRTCHNL_OP_ENABLE_QUEUES_V2 = 107,
165 VIRTCHNL_OP_DISABLE_QUEUES_V2 = 108,
166 VIRTCHNL_OP_MAP_QUEUE_VECTOR = 111,
170 static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)
173 case VIRTCHNL_OP_UNKNOWN:
174 return "VIRTCHNL_OP_UNKNOWN";
175 case VIRTCHNL_OP_VERSION:
176 return "VIRTCHNL_OP_VERSION";
177 case VIRTCHNL_OP_RESET_VF:
178 return "VIRTCHNL_OP_RESET_VF";
179 case VIRTCHNL_OP_GET_VF_RESOURCES:
180 return "VIRTCHNL_OP_GET_VF_RESOURCES";
181 case VIRTCHNL_OP_CONFIG_TX_QUEUE:
182 return "VIRTCHNL_OP_CONFIG_TX_QUEUE";
183 case VIRTCHNL_OP_CONFIG_RX_QUEUE:
184 return "VIRTCHNL_OP_CONFIG_RX_QUEUE";
185 case VIRTCHNL_OP_CONFIG_VSI_QUEUES:
186 return "VIRTCHNL_OP_CONFIG_VSI_QUEUES";
187 case VIRTCHNL_OP_CONFIG_IRQ_MAP:
188 return "VIRTCHNL_OP_CONFIG_IRQ_MAP";
189 case VIRTCHNL_OP_ENABLE_QUEUES:
190 return "VIRTCHNL_OP_ENABLE_QUEUES";
191 case VIRTCHNL_OP_DISABLE_QUEUES:
192 return "VIRTCHNL_OP_DISABLE_QUEUES";
193 case VIRTCHNL_OP_ADD_ETH_ADDR:
194 return "VIRTCHNL_OP_ADD_ETH_ADDR";
195 case VIRTCHNL_OP_DEL_ETH_ADDR:
196 return "VIRTCHNL_OP_DEL_ETH_ADDR";
197 case VIRTCHNL_OP_ADD_VLAN:
198 return "VIRTCHNL_OP_ADD_VLAN";
199 case VIRTCHNL_OP_DEL_VLAN:
200 return "VIRTCHNL_OP_DEL_VLAN";
201 case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE:
202 return "VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE";
203 case VIRTCHNL_OP_GET_STATS:
204 return "VIRTCHNL_OP_GET_STATS";
205 case VIRTCHNL_OP_RSVD:
206 return "VIRTCHNL_OP_RSVD";
207 case VIRTCHNL_OP_EVENT:
208 return "VIRTCHNL_OP_EVENT";
209 case VIRTCHNL_OP_CONFIG_RSS_KEY:
210 return "VIRTCHNL_OP_CONFIG_RSS_KEY";
211 case VIRTCHNL_OP_CONFIG_RSS_LUT:
212 return "VIRTCHNL_OP_CONFIG_RSS_LUT";
213 case VIRTCHNL_OP_GET_RSS_HENA_CAPS:
214 return "VIRTCHNL_OP_GET_RSS_HENA_CAPS";
215 case VIRTCHNL_OP_SET_RSS_HENA:
216 return "VIRTCHNL_OP_SET_RSS_HENA";
217 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING:
218 return "VIRTCHNL_OP_ENABLE_VLAN_STRIPPING";
219 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING:
220 return "VIRTCHNL_OP_DISABLE_VLAN_STRIPPING";
221 case VIRTCHNL_OP_REQUEST_QUEUES:
222 return "VIRTCHNL_OP_REQUEST_QUEUES";
223 case VIRTCHNL_OP_ENABLE_CHANNELS:
224 return "VIRTCHNL_OP_ENABLE_CHANNELS";
225 case VIRTCHNL_OP_DISABLE_CHANNELS:
226 return "VIRTCHNL_OP_DISABLE_CHANNELS";
227 case VIRTCHNL_OP_ADD_CLOUD_FILTER:
228 return "VIRTCHNL_OP_ADD_CLOUD_FILTER";
229 case VIRTCHNL_OP_DEL_CLOUD_FILTER:
230 return "VIRTCHNL_OP_DEL_CLOUD_FILTER";
231 case VIRTCHNL_OP_INLINE_IPSEC_CRYPTO:
232 return "VIRTCHNL_OP_INLINE_IPSEC_CRYPTO";
233 case VIRTCHNL_OP_DCF_CMD_DESC:
234 return "VIRTCHNL_OP_DCF_CMD_DESC";
235 case VIRTCHNL_OP_DCF_CMD_BUFF:
236 return "VIRTCHNL_OP_DCF_CMD_BUFF";
237 case VIRTCHNL_OP_DCF_DISABLE:
238 return "VIRTCHNL_OP_DCF_DISABLE";
239 case VIRTCHNL_OP_DCF_GET_VSI_MAP:
240 return "VIRTCHNL_OP_DCF_GET_VSI_MAP";
241 case VIRTCHNL_OP_GET_SUPPORTED_RXDIDS:
242 return "VIRTCHNL_OP_GET_SUPPORTED_RXDIDS";
243 case VIRTCHNL_OP_ADD_RSS_CFG:
244 return "VIRTCHNL_OP_ADD_RSS_CFG";
245 case VIRTCHNL_OP_DEL_RSS_CFG:
246 return "VIRTCHNL_OP_DEL_RSS_CFG";
247 case VIRTCHNL_OP_ADD_FDIR_FILTER:
248 return "VIRTCHNL_OP_ADD_FDIR_FILTER";
249 case VIRTCHNL_OP_DEL_FDIR_FILTER:
250 return "VIRTCHNL_OP_DEL_FDIR_FILTER";
251 case VIRTCHNL_OP_GET_MAX_RSS_QREGION:
252 return "VIRTCHNL_OP_GET_MAX_RSS_QREGION";
253 case VIRTCHNL_OP_ENABLE_QUEUES_V2:
254 return "VIRTCHNL_OP_ENABLE_QUEUES_V2";
255 case VIRTCHNL_OP_DISABLE_QUEUES_V2:
256 return "VIRTCHNL_OP_DISABLE_QUEUES_V2";
257 case VIRTCHNL_OP_MAP_QUEUE_VECTOR:
258 return "VIRTCHNL_OP_MAP_QUEUE_VECTOR";
259 case VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS:
260 return "VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS";
261 case VIRTCHNL_OP_ADD_VLAN_V2:
262 return "VIRTCHNL_OP_ADD_VLAN_V2";
263 case VIRTCHNL_OP_DEL_VLAN_V2:
264 return "VIRTCHNL_OP_DEL_VLAN_V2";
265 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2:
266 return "VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2";
267 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2:
268 return "VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2";
269 case VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2:
270 return "VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2";
271 case VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2:
272 return "VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2";
273 case VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2:
274 return "VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2";
275 case VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2:
276 return "VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2";
277 case VIRTCHNL_OP_MAX:
278 return "VIRTCHNL_OP_MAX";
280 return "Unsupported (update virtchnl.h)";
284 /* These macros are used to generate compilation errors if a structure/union
285 * is not exactly the correct length. It gives a divide by zero error if the
286 * structure/union is not of the correct size, otherwise it creates an enum
287 * that is never used.
289 #define VIRTCHNL_CHECK_STRUCT_LEN(n, X) enum virtchnl_static_assert_enum_##X \
290 { virtchnl_static_assert_##X = (n)/((sizeof(struct X) == (n)) ? 1 : 0) }
291 #define VIRTCHNL_CHECK_UNION_LEN(n, X) enum virtchnl_static_asset_enum_##X \
292 { virtchnl_static_assert_##X = (n)/((sizeof(union X) == (n)) ? 1 : 0) }
294 /* Virtual channel message descriptor. This overlays the admin queue
295 * descriptor. All other data is passed in external buffers.
298 struct virtchnl_msg {
299 u8 pad[8]; /* AQ flags/opcode/len/retval fields */
301 /* avoid confusion with desc->opcode */
302 enum virtchnl_ops v_opcode;
304 /* ditto for desc->retval */
305 enum virtchnl_status_code v_retval;
306 u32 vfid; /* used by PF when sending to VF */
309 VIRTCHNL_CHECK_STRUCT_LEN(20, virtchnl_msg);
311 /* Message descriptions and data structures. */
313 /* VIRTCHNL_OP_VERSION
314 * VF posts its version number to the PF. PF responds with its version number
315 * in the same format, along with a return code.
316 * Reply from PF has its major/minor versions also in param0 and param1.
317 * If there is a major version mismatch, then the VF cannot operate.
318 * If there is a minor version mismatch, then the VF can operate but should
319 * add a warning to the system log.
321 * This enum element MUST always be specified as == 1, regardless of other
322 * changes in the API. The PF must always respond to this message without
323 * error regardless of version mismatch.
325 #define VIRTCHNL_VERSION_MAJOR 1
326 #define VIRTCHNL_VERSION_MINOR 1
327 #define VIRTCHNL_VERSION_MINOR_NO_VF_CAPS 0
329 struct virtchnl_version_info {
334 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_version_info);
336 #define VF_IS_V10(_v) (((_v)->major == 1) && ((_v)->minor == 0))
337 #define VF_IS_V11(_ver) (((_ver)->major == 1) && ((_ver)->minor == 1))
339 /* VIRTCHNL_OP_RESET_VF
340 * VF sends this request to PF with no parameters
341 * PF does NOT respond! VF driver must delay then poll VFGEN_RSTAT register
342 * until reset completion is indicated. The admin queue must be reinitialized
343 * after this operation.
345 * When reset is complete, PF must ensure that all queues in all VSIs associated
346 * with the VF are stopped, all queue configurations in the HMC are set to 0,
347 * and all MAC and VLAN filters (except the default MAC address) on all VSIs
351 /* VSI types that use VIRTCHNL interface for VF-PF communication. VSI_SRIOV
352 * vsi_type should always be 6 for backward compatibility. Add other fields
355 enum virtchnl_vsi_type {
356 VIRTCHNL_VSI_TYPE_INVALID = 0,
357 VIRTCHNL_VSI_SRIOV = 6,
360 /* VIRTCHNL_OP_GET_VF_RESOURCES
361 * Version 1.0 VF sends this request to PF with no parameters
362 * Version 1.1 VF sends this request to PF with u32 bitmap of its capabilities
363 * PF responds with an indirect message containing
364 * virtchnl_vf_resource and one or more
365 * virtchnl_vsi_resource structures.
368 struct virtchnl_vsi_resource {
372 /* see enum virtchnl_vsi_type */
375 u8 default_mac_addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
378 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
380 /* VF capability flags
381 * VIRTCHNL_VF_OFFLOAD_L2 flag is inclusive of base mode L2 offloads including
382 * TX/RX Checksum offloading and TSO for non-tunnelled packets.
384 #define VIRTCHNL_VF_OFFLOAD_L2 BIT(0)
385 #define VIRTCHNL_VF_OFFLOAD_IWARP BIT(1)
386 #define VIRTCHNL_VF_OFFLOAD_RSVD BIT(2)
387 #define VIRTCHNL_VF_OFFLOAD_RSS_AQ BIT(3)
388 #define VIRTCHNL_VF_OFFLOAD_RSS_REG BIT(4)
389 #define VIRTCHNL_VF_OFFLOAD_WB_ON_ITR BIT(5)
390 #define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES BIT(6)
391 /* used to negotiate communicating link speeds in Mbps */
392 #define VIRTCHNL_VF_CAP_ADV_LINK_SPEED BIT(7)
393 #define VIRTCHNL_VF_OFFLOAD_INLINE_IPSEC_CRYPTO BIT(8)
394 #define VIRTCHNL_VF_LARGE_NUM_QPAIRS BIT(9)
395 #define VIRTCHNL_VF_OFFLOAD_CRC BIT(10)
396 #define VIRTCHNL_VF_OFFLOAD_VLAN_V2 BIT(15)
397 #define VIRTCHNL_VF_OFFLOAD_VLAN BIT(16)
398 #define VIRTCHNL_VF_OFFLOAD_RX_POLLING BIT(17)
399 #define VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 BIT(18)
400 #define VIRTCHNL_VF_OFFLOAD_RSS_PF BIT(19)
401 #define VIRTCHNL_VF_OFFLOAD_ENCAP BIT(20)
402 #define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM BIT(21)
403 #define VIRTCHNL_VF_OFFLOAD_RX_ENCAP_CSUM BIT(22)
404 #define VIRTCHNL_VF_OFFLOAD_ADQ BIT(23)
405 #define VIRTCHNL_VF_OFFLOAD_ADQ_V2 BIT(24)
406 #define VIRTCHNL_VF_OFFLOAD_USO BIT(25)
407 #define VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC BIT(26)
408 #define VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF BIT(27)
409 #define VIRTCHNL_VF_OFFLOAD_FDIR_PF BIT(28)
410 #define VIRTCHNL_VF_OFFLOAD_QOS BIT(29)
411 #define VIRTCHNL_VF_CAP_DCF BIT(30)
412 /* BIT(31) is reserved */
414 #define VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \
415 VIRTCHNL_VF_OFFLOAD_VLAN | \
416 VIRTCHNL_VF_OFFLOAD_RSS_PF)
418 struct virtchnl_vf_resource {
428 struct virtchnl_vsi_resource vsi_res[1];
431 VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_vf_resource);
433 /* VIRTCHNL_OP_CONFIG_TX_QUEUE
434 * VF sends this message to set up parameters for one TX queue.
435 * External data buffer contains one instance of virtchnl_txq_info.
436 * PF configures requested queue and returns a status code.
439 /* Tx queue config info */
440 struct virtchnl_txq_info {
443 u16 ring_len; /* number of descriptors, multiple of 8 */
444 u16 headwb_enabled; /* deprecated with AVF 1.0 */
446 u64 dma_headwb_addr; /* deprecated with AVF 1.0 */
449 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_txq_info);
451 /* RX descriptor IDs (range from 0 to 63) */
452 enum virtchnl_rx_desc_ids {
453 VIRTCHNL_RXDID_0_16B_BASE = 0,
454 /* 32B_BASE and FLEX_SPLITQ share desc ids as default descriptors
455 * because they can be differentiated based on queue model; e.g. single
456 * queue model can only use 32B_BASE and split queue model can only use
457 * FLEX_SPLITQ. Having these as 1 allows them to be used as default
458 * descriptors without negotiation.
460 VIRTCHNL_RXDID_1_32B_BASE = 1,
461 VIRTCHNL_RXDID_1_FLEX_SPLITQ = 1,
462 VIRTCHNL_RXDID_2_FLEX_SQ_NIC = 2,
463 VIRTCHNL_RXDID_3_FLEX_SQ_SW = 3,
464 VIRTCHNL_RXDID_4_FLEX_SQ_NIC_VEB = 4,
465 VIRTCHNL_RXDID_5_FLEX_SQ_NIC_ACL = 5,
466 VIRTCHNL_RXDID_6_FLEX_SQ_NIC_2 = 6,
467 VIRTCHNL_RXDID_7_HW_RSVD = 7,
468 /* 9 through 15 are reserved */
469 VIRTCHNL_RXDID_16_COMMS_GENERIC = 16,
470 VIRTCHNL_RXDID_17_COMMS_AUX_VLAN = 17,
471 VIRTCHNL_RXDID_18_COMMS_AUX_IPV4 = 18,
472 VIRTCHNL_RXDID_19_COMMS_AUX_IPV6 = 19,
473 VIRTCHNL_RXDID_20_COMMS_AUX_FLOW = 20,
474 VIRTCHNL_RXDID_21_COMMS_AUX_TCP = 21,
475 /* 22 through 63 are reserved */
478 /* RX descriptor ID bitmasks */
479 enum virtchnl_rx_desc_id_bitmasks {
480 VIRTCHNL_RXDID_0_16B_BASE_M = BIT(VIRTCHNL_RXDID_0_16B_BASE),
481 VIRTCHNL_RXDID_1_32B_BASE_M = BIT(VIRTCHNL_RXDID_1_32B_BASE),
482 VIRTCHNL_RXDID_1_FLEX_SPLITQ_M = BIT(VIRTCHNL_RXDID_1_FLEX_SPLITQ),
483 VIRTCHNL_RXDID_2_FLEX_SQ_NIC_M = BIT(VIRTCHNL_RXDID_2_FLEX_SQ_NIC),
484 VIRTCHNL_RXDID_3_FLEX_SQ_SW_M = BIT(VIRTCHNL_RXDID_3_FLEX_SQ_SW),
485 VIRTCHNL_RXDID_4_FLEX_SQ_NIC_VEB_M = BIT(VIRTCHNL_RXDID_4_FLEX_SQ_NIC_VEB),
486 VIRTCHNL_RXDID_5_FLEX_SQ_NIC_ACL_M = BIT(VIRTCHNL_RXDID_5_FLEX_SQ_NIC_ACL),
487 VIRTCHNL_RXDID_6_FLEX_SQ_NIC_2_M = BIT(VIRTCHNL_RXDID_6_FLEX_SQ_NIC_2),
488 VIRTCHNL_RXDID_7_HW_RSVD_M = BIT(VIRTCHNL_RXDID_7_HW_RSVD),
489 /* 9 through 15 are reserved */
490 VIRTCHNL_RXDID_16_COMMS_GENERIC_M = BIT(VIRTCHNL_RXDID_16_COMMS_GENERIC),
491 VIRTCHNL_RXDID_17_COMMS_AUX_VLAN_M = BIT(VIRTCHNL_RXDID_17_COMMS_AUX_VLAN),
492 VIRTCHNL_RXDID_18_COMMS_AUX_IPV4_M = BIT(VIRTCHNL_RXDID_18_COMMS_AUX_IPV4),
493 VIRTCHNL_RXDID_19_COMMS_AUX_IPV6_M = BIT(VIRTCHNL_RXDID_19_COMMS_AUX_IPV6),
494 VIRTCHNL_RXDID_20_COMMS_AUX_FLOW_M = BIT(VIRTCHNL_RXDID_20_COMMS_AUX_FLOW),
495 VIRTCHNL_RXDID_21_COMMS_AUX_TCP_M = BIT(VIRTCHNL_RXDID_21_COMMS_AUX_TCP),
496 /* 22 through 63 are reserved */
499 /* VIRTCHNL_OP_CONFIG_RX_QUEUE
500 * VF sends this message to set up parameters for one RX queue.
501 * External data buffer contains one instance of virtchnl_rxq_info.
502 * PF configures requested queue and returns a status code. The
503 * crc_disable flag disables CRC stripping on the VF. Setting
504 * the crc_disable flag to 1 will disable CRC stripping for each
505 * queue in the VF where the flag is set. The VIRTCHNL_VF_OFFLOAD_CRC
506 * offload must have been set prior to sending this info or the PF
507 * will ignore the request. This flag should be set the same for
508 * all of the queues for a VF.
511 /* Rx queue config info */
512 struct virtchnl_rxq_info {
515 u32 ring_len; /* number of descriptors, multiple of 32 */
517 u16 splithdr_enabled; /* deprecated with AVF 1.0 */
521 /* see enum virtchnl_rx_desc_ids;
522 * only used when VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC is supported. Note
523 * that when the offload is not supported, the descriptor format aligns
524 * with VIRTCHNL_RXDID_1_32B_BASE.
530 /* see enum virtchnl_rx_hsplit; deprecated with AVF 1.0 */
535 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_rxq_info);
537 /* VIRTCHNL_OP_CONFIG_VSI_QUEUES
538 * VF sends this message to set parameters for active TX and RX queues
539 * associated with the specified VSI.
540 * PF configures queues and returns status.
541 * If the number of queues specified is greater than the number of queues
542 * associated with the VSI, an error is returned and no queues are configured.
543 * NOTE: The VF is not required to configure all queues in a single request.
544 * It may send multiple messages. PF drivers must correctly handle all VF
547 struct virtchnl_queue_pair_info {
548 /* NOTE: vsi_id and queue_id should be identical for both queues. */
549 struct virtchnl_txq_info txq;
550 struct virtchnl_rxq_info rxq;
553 VIRTCHNL_CHECK_STRUCT_LEN(64, virtchnl_queue_pair_info);
555 struct virtchnl_vsi_queue_config_info {
559 struct virtchnl_queue_pair_info qpair[1];
562 VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_vsi_queue_config_info);
564 /* VIRTCHNL_OP_REQUEST_QUEUES
565 * VF sends this message to request the PF to allocate additional queues to
566 * this VF. Each VF gets a guaranteed number of queues on init but asking for
567 * additional queues must be negotiated. This is a best effort request as it
568 * is possible the PF does not have enough queues left to support the request.
569 * If the PF cannot support the number requested it will respond with the
570 * maximum number it is able to support. If the request is successful, PF will
571 * then reset the VF to institute required changes.
574 /* VF resource request */
575 struct virtchnl_vf_res_request {
579 /* VIRTCHNL_OP_CONFIG_IRQ_MAP
580 * VF uses this message to map vectors to queues.
581 * The rxq_map and txq_map fields are bitmaps used to indicate which queues
582 * are to be associated with the specified vector.
583 * The "other" causes are always mapped to vector 0. The VF may not request
584 * that vector 0 be used for traffic.
585 * PF configures interrupt mapping and returns status.
586 * NOTE: due to hardware requirements, all active queues (both TX and RX)
587 * should be mapped to interrupts, even if the driver intends to operate
588 * only in polling mode. In this case the interrupt may be disabled, but
589 * the ITR timer will still run to trigger writebacks.
591 struct virtchnl_vector_map {
600 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_vector_map);
602 struct virtchnl_irq_map_info {
604 struct virtchnl_vector_map vecmap[1];
607 VIRTCHNL_CHECK_STRUCT_LEN(14, virtchnl_irq_map_info);
609 /* VIRTCHNL_OP_ENABLE_QUEUES
610 * VIRTCHNL_OP_DISABLE_QUEUES
611 * VF sends these message to enable or disable TX/RX queue pairs.
612 * The queues fields are bitmaps indicating which queues to act upon.
613 * (Currently, we only support 16 queues per VF, but we make the field
614 * u32 to allow for expansion.)
615 * PF performs requested action and returns status.
616 * NOTE: The VF is not required to enable/disable all queues in a single
617 * request. It may send multiple messages.
618 * PF drivers must correctly handle all VF requests.
620 struct virtchnl_queue_select {
627 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_select);
629 /* VIRTCHNL_OP_GET_MAX_RSS_QREGION
631 * if VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
632 * then this op must be supported.
634 * VF sends this message in order to query the max RSS queue region
635 * size supported by PF, when VIRTCHNL_VF_LARGE_NUM_QPAIRS is enabled.
636 * This information should be used when configuring the RSS LUT and/or
637 * configuring queue region based filters.
639 * The maximum RSS queue region is 2^qregion_width. So, a qregion_width
640 * of 6 would inform the VF that the PF supports a maximum RSS queue region
643 * A queue region represents a range of queues that can be used to configure
644 * a RSS LUT. For example, if a VF is given 64 queues, but only a max queue
645 * region size of 16 (i.e. 2^qregion_width = 16) then it will only be able
646 * to configure the RSS LUT with queue indices from 0 to 15. However, other
647 * filters can be used to direct packets to queues >15 via specifying a queue
648 * base/offset and queue region width.
650 struct virtchnl_max_rss_qregion {
656 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_max_rss_qregion);
658 /* VIRTCHNL_OP_ADD_ETH_ADDR
659 * VF sends this message in order to add one or more unicast or multicast
660 * address filters for the specified VSI.
661 * PF adds the filters and returns status.
664 /* VIRTCHNL_OP_DEL_ETH_ADDR
665 * VF sends this message in order to remove one or more unicast or multicast
666 * filters for the specified VSI.
667 * PF removes the filters and returns status.
670 /* VIRTCHNL_ETHER_ADDR_LEGACY
671 * Prior to adding the @type member to virtchnl_ether_addr, there were 2 pad
672 * bytes. Moving forward all VF drivers should not set type to
673 * VIRTCHNL_ETHER_ADDR_LEGACY. This is only here to not break previous/legacy
674 * behavior. The control plane function (i.e. PF) can use a best effort method
675 * of tracking the primary/device unicast in this case, but there is no
676 * guarantee and functionality depends on the implementation of the PF.
679 /* VIRTCHNL_ETHER_ADDR_PRIMARY
680 * All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_PRIMARY for the
681 * primary/device unicast MAC address filter for VIRTCHNL_OP_ADD_ETH_ADDR and
682 * VIRTCHNL_OP_DEL_ETH_ADDR. This allows for the underlying control plane
683 * function (i.e. PF) to accurately track and use this MAC address for
684 * displaying on the host and for VM/function reset.
687 /* VIRTCHNL_ETHER_ADDR_EXTRA
688 * All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_EXTRA for any extra
689 * unicast and/or multicast filters that are being added/deleted via
690 * VIRTCHNL_OP_DEL_ETH_ADDR/VIRTCHNL_OP_ADD_ETH_ADDR respectively.
692 struct virtchnl_ether_addr {
693 u8 addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
695 #define VIRTCHNL_ETHER_ADDR_LEGACY 0
696 #define VIRTCHNL_ETHER_ADDR_PRIMARY 1
697 #define VIRTCHNL_ETHER_ADDR_EXTRA 2
698 #define VIRTCHNL_ETHER_ADDR_TYPE_MASK 3 /* first two bits of type are valid */
702 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_ether_addr);
704 struct virtchnl_ether_addr_list {
707 struct virtchnl_ether_addr list[1];
710 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_ether_addr_list);
712 /* VIRTCHNL_OP_ADD_VLAN
713 * VF sends this message to add one or more VLAN tag filters for receives.
714 * PF adds the filters and returns status.
715 * If a port VLAN is configured by the PF, this operation will return an
719 /* VIRTCHNL_OP_DEL_VLAN
720 * VF sends this message to remove one or more VLAN tag filters for receives.
721 * PF removes the filters and returns status.
722 * If a port VLAN is configured by the PF, this operation will return an
726 struct virtchnl_vlan_filter_list {
732 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_vlan_filter_list);
734 /* This enum is used for all of the VIRTCHNL_VF_OFFLOAD_VLAN_V2_CAPS related
735 * structures and opcodes.
737 * VIRTCHNL_VLAN_UNSUPPORTED - This field is not supported and if a VF driver
738 * populates it the PF should return VIRTCHNL_STATUS_ERR_NOT_SUPPORTED.
740 * VIRTCHNL_VLAN_ETHERTYPE_8100 - This field supports 0x8100 ethertype.
741 * VIRTCHNL_VLAN_ETHERTYPE_88A8 - This field supports 0x88A8 ethertype.
742 * VIRTCHNL_VLAN_ETHERTYPE_9100 - This field supports 0x9100 ethertype.
744 * VIRTCHNL_VLAN_ETHERTYPE_AND - Used when multiple ethertypes can be supported
745 * by the PF concurrently. For example, if the PF can support
746 * VIRTCHNL_VLAN_ETHERTYPE_8100 AND VIRTCHNL_VLAN_ETHERTYPE_88A8 filters it
747 * would OR the following bits:
749 * VIRTHCNL_VLAN_ETHERTYPE_8100 |
750 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
751 * VIRTCHNL_VLAN_ETHERTYPE_AND;
753 * The VF would interpret this as VLAN filtering can be supported on both 0x8100
754 * and 0x88A8 VLAN ethertypes.
756 * VIRTCHNL_ETHERTYPE_XOR - Used when only a single ethertype can be supported
757 * by the PF concurrently. For example if the PF can support
758 * VIRTCHNL_VLAN_ETHERTYPE_8100 XOR VIRTCHNL_VLAN_ETHERTYPE_88A8 stripping
759 * offload it would OR the following bits:
761 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
762 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
763 * VIRTCHNL_VLAN_ETHERTYPE_XOR;
765 * The VF would interpret this as VLAN stripping can be supported on either
766 * 0x8100 or 0x88a8 VLAN ethertypes. So when requesting VLAN stripping via
767 * VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 the specified ethertype will override
768 * the previously set value.
770 * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1 - Used to tell the VF to insert and/or
771 * strip the VLAN tag using the L2TAG1 field of the Tx/Rx descriptors.
773 * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 - Used to tell the VF to insert hardware
774 * offloaded VLAN tags using the L2TAG2 field of the Tx descriptor.
776 * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 - Used to tell the VF to strip hardware
777 * offloaded VLAN tags using the L2TAG2_2 field of the Rx descriptor.
779 * VIRTCHNL_VLAN_PRIO - This field supports VLAN priority bits. This is used for
780 * VLAN filtering if the underlying PF supports it.
782 * VIRTCHNL_VLAN_TOGGLE_ALLOWED - This field is used to say whether a
783 * certain VLAN capability can be toggled. For example if the underlying PF/CP
784 * allows the VF to toggle VLAN filtering, stripping, and/or insertion it should
785 * set this bit along with the supported ethertypes.
787 enum virtchnl_vlan_support {
788 VIRTCHNL_VLAN_UNSUPPORTED = 0,
789 VIRTCHNL_VLAN_ETHERTYPE_8100 = 0x00000001,
790 VIRTCHNL_VLAN_ETHERTYPE_88A8 = 0x00000002,
791 VIRTCHNL_VLAN_ETHERTYPE_9100 = 0x00000004,
792 VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1 = 0x00000100,
793 VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 = 0x00000200,
794 VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2_2 = 0x00000400,
795 VIRTCHNL_VLAN_PRIO = 0x01000000,
796 VIRTCHNL_VLAN_FILTER_MASK = 0x10000000,
797 VIRTCHNL_VLAN_ETHERTYPE_AND = 0x20000000,
798 VIRTCHNL_VLAN_ETHERTYPE_XOR = 0x40000000,
799 VIRTCHNL_VLAN_TOGGLE = 0x80000000
802 /* This structure is used as part of the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS
803 * for filtering, insertion, and stripping capabilities.
805 * If only outer capabilities are supported (for filtering, insertion, and/or
806 * stripping) then this refers to the outer most or single VLAN from the VF's
809 * If only inner capabilities are supported (for filtering, insertion, and/or
810 * stripping) then this refers to the outer most or single VLAN from the VF's
811 * perspective. Functionally this is the same as if only outer capabilities are
812 * supported. The VF driver is just forced to use the inner fields when
813 * adding/deleting filters and enabling/disabling offloads (if supported).
815 * If both outer and inner capabilities are supported (for filtering, insertion,
816 * and/or stripping) then outer refers to the outer most or single VLAN and
817 * inner refers to the second VLAN, if it exists, in the packet.
819 * There is no support for tunneled VLAN offloads, so outer or inner are never
820 * referring to a tunneled packet from the VF's perspective.
822 struct virtchnl_vlan_supported_caps {
827 /* The PF populates these fields based on the supported VLAN filtering. If a
828 * field is VIRTCHNL_VLAN_UNSUPPORTED then it's not supported and the PF will
829 * reject any VIRTCHNL_OP_ADD_VLAN_V2 or VIRTCHNL_OP_DEL_VLAN_V2 messages using
830 * the unsupported fields.
832 * Also, a VF is only allowed to toggle its VLAN filtering setting if the
833 * VIRTCHNL_VLAN_TOGGLE bit is set.
835 * The ethertype(s) specified in the ethertype_init field are the ethertypes
836 * enabled for VLAN filtering. VLAN filtering in this case refers to the outer
837 * most VLAN from the VF's perspective. If both inner and outer filtering are
838 * allowed then ethertype_init only refers to the outer most VLAN as only
839 * VLAN ethertype supported for inner VLAN filtering is
840 * VIRTCHNL_VLAN_ETHERTYPE_8100. By default, inner VLAN filtering is disabled
841 * when both inner and outer filtering are allowed.
843 * The max_filters field tells the VF how many VLAN filters it's allowed to have
844 * at any one time. If it exceeds this amount and tries to add another filter,
845 * then the request will be rejected by the PF. To prevent failures, the VF
846 * should keep track of how many VLAN filters it has added and not attempt to
847 * add more than max_filters.
849 struct virtchnl_vlan_filtering_caps {
850 struct virtchnl_vlan_supported_caps filtering_support;
856 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vlan_filtering_caps);
858 /* This enum is used for the virtchnl_vlan_offload_caps structure to specify
859 * if the PF supports a different ethertype for stripping and insertion.
861 * VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION - The ethertype(s) specified
862 * for stripping affect the ethertype(s) specified for insertion and visa versa
863 * as well. If the VF tries to configure VLAN stripping via
864 * VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 with VIRTCHNL_VLAN_ETHERTYPE_8100 then
865 * that will be the ethertype for both stripping and insertion.
867 * VIRTCHNL_ETHERTYPE_MATCH_NOT_REQUIRED - The ethertype(s) specified for
868 * stripping do not affect the ethertype(s) specified for insertion and visa
871 enum virtchnl_vlan_ethertype_match {
872 VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION = 0,
873 VIRTCHNL_ETHERTYPE_MATCH_NOT_REQUIRED = 1,
876 /* The PF populates these fields based on the supported VLAN offloads. If a
877 * field is VIRTCHNL_VLAN_UNSUPPORTED then it's not supported and the PF will
878 * reject any VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 or
879 * VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 messages using the unsupported fields.
881 * Also, a VF is only allowed to toggle its VLAN offload setting if the
882 * VIRTCHNL_VLAN_TOGGLE_ALLOWED bit is set.
884 * The VF driver needs to be aware of how the tags are stripped by hardware and
885 * inserted by the VF driver based on the level of offload support. The PF will
886 * populate these fields based on where the VLAN tags are expected to be
887 * offloaded via the VIRTHCNL_VLAN_TAG_LOCATION_* bits. The VF will need to
888 * interpret these fields. See the definition of the
889 * VIRTCHNL_VLAN_TAG_LOCATION_* bits above the virtchnl_vlan_support
892 struct virtchnl_vlan_offload_caps {
893 struct virtchnl_vlan_supported_caps stripping_support;
894 struct virtchnl_vlan_supported_caps insertion_support;
900 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_vlan_offload_caps);
902 /* VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS
903 * VF sends this message to determine its VLAN capabilities.
905 * PF will mark which capabilities it supports based on hardware support and
906 * current configuration. For example, if a port VLAN is configured the PF will
907 * not allow outer VLAN filtering, stripping, or insertion to be configured so
908 * it will block these features from the VF.
910 * The VF will need to cross reference its capabilities with the PFs
911 * capabilities in the response message from the PF to determine the VLAN
914 struct virtchnl_vlan_caps {
915 struct virtchnl_vlan_filtering_caps filtering;
916 struct virtchnl_vlan_offload_caps offloads;
919 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_vlan_caps);
921 struct virtchnl_vlan {
922 u16 tci; /* tci[15:13] = PCP and tci[11:0] = VID */
923 u16 tci_mask; /* only valid if VIRTCHNL_VLAN_FILTER_MASK set in
926 u16 tpid; /* 0x8100, 0x88a8, etc. and only type(s) set in
927 * filtering caps. Note that tpid here does not refer to
928 * VIRTCHNL_VLAN_ETHERTYPE_*, but it refers to the
929 * actual 2-byte VLAN TPID
934 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_vlan);
936 struct virtchnl_vlan_filter {
937 struct virtchnl_vlan inner;
938 struct virtchnl_vlan outer;
942 VIRTCHNL_CHECK_STRUCT_LEN(32, virtchnl_vlan_filter);
944 /* VIRTCHNL_OP_ADD_VLAN_V2
945 * VIRTCHNL_OP_DEL_VLAN_V2
947 * VF sends these messages to add/del one or more VLAN tag filters for Rx
950 * The PF attempts to add the filters and returns status.
952 * The VF should only ever attempt to add/del virtchnl_vlan_filter(s) using the
953 * supported fields negotiated via VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS.
955 struct virtchnl_vlan_filter_list_v2 {
959 struct virtchnl_vlan_filter filters[1];
962 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_vlan_filter_list_v2);
964 /* VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2
965 * VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2
966 * VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2
967 * VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2
969 * VF sends this message to enable or disable VLAN stripping or insertion. It
970 * also needs to specify an ethertype. The VF knows which VLAN ethertypes are
971 * allowed and whether or not it's allowed to enable/disable the specific
972 * offload via the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS message. The VF needs to
973 * parse the virtchnl_vlan_caps.offloads fields to determine which offload
974 * messages are allowed.
976 * For example, if the PF populates the virtchnl_vlan_caps.offloads in the
977 * following manner the VF will be allowed to enable and/or disable 0x8100 inner
978 * VLAN insertion and/or stripping via the opcodes listed above. Inner in this
979 * case means the outer most or single VLAN from the VF's perspective. This is
980 * because no outer offloads are supported. See the comments above the
981 * virtchnl_vlan_supported_caps structure for more details.
983 * virtchnl_vlan_caps.offloads.stripping_support.inner =
984 * VIRTCHNL_VLAN_TOGGLE |
985 * VIRTCHNL_VLAN_ETHERTYPE_8100;
987 * virtchnl_vlan_caps.offloads.insertion_support.inner =
988 * VIRTCHNL_VLAN_TOGGLE |
989 * VIRTCHNL_VLAN_ETHERTYPE_8100;
991 * In order to enable inner (again note that in this case inner is the outer
992 * most or single VLAN from the VF's perspective) VLAN stripping for 0x8100
993 * VLANs, the VF would populate the virtchnl_vlan_setting structure in the
994 * following manner and send the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 message.
996 * virtchnl_vlan_setting.inner_ethertype_setting =
997 * VIRTCHNL_VLAN_ETHERTYPE_8100;
999 * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on
1002 * The reason that VLAN TPID(s) are not being used for the
1003 * outer_ethertype_setting and inner_ethertype_setting fields is because it's
1004 * possible a device could support VLAN insertion and/or stripping offload on
1005 * multiple ethertypes concurrently, so this method allows a VF to request
1006 * multiple ethertypes in one message using the virtchnl_vlan_support
1009 * For example, if the PF populates the virtchnl_vlan_caps.offloads in the
1010 * following manner the VF will be allowed to enable 0x8100 and 0x88a8 outer
1011 * VLAN insertion and stripping simultaneously. The
1012 * virtchnl_vlan_caps.offloads.ethertype_match field will also have to be
1013 * populated based on what the PF can support.
1015 * virtchnl_vlan_caps.offloads.stripping_support.outer =
1016 * VIRTCHNL_VLAN_TOGGLE |
1017 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1018 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
1019 * VIRTCHNL_VLAN_ETHERTYPE_AND;
1021 * virtchnl_vlan_caps.offloads.insertion_support.outer =
1022 * VIRTCHNL_VLAN_TOGGLE |
1023 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1024 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
1025 * VIRTCHNL_VLAN_ETHERTYPE_AND;
1027 * In order to enable outer VLAN stripping for 0x8100 and 0x88a8 VLANs, the VF
1028 * would populate the virthcnl_vlan_offload_structure in the following manner
1029 * and send the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 message.
1031 * virtchnl_vlan_setting.outer_ethertype_setting =
1032 * VIRTHCNL_VLAN_ETHERTYPE_8100 |
1033 * VIRTHCNL_VLAN_ETHERTYPE_88A8;
1035 * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on
1038 * There is also the case where a PF and the underlying hardware can support
1039 * VLAN offloads on multiple ethertypes, but not concurrently. For example, if
1040 * the PF populates the virtchnl_vlan_caps.offloads in the following manner the
1041 * VF will be allowed to enable and/or disable 0x8100 XOR 0x88a8 outer VLAN
1042 * offloads. The ethertypes must match for stripping and insertion.
1044 * virtchnl_vlan_caps.offloads.stripping_support.outer =
1045 * VIRTCHNL_VLAN_TOGGLE |
1046 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1047 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
1048 * VIRTCHNL_VLAN_ETHERTYPE_XOR;
1050 * virtchnl_vlan_caps.offloads.insertion_support.outer =
1051 * VIRTCHNL_VLAN_TOGGLE |
1052 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1053 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
1054 * VIRTCHNL_VLAN_ETHERTYPE_XOR;
1056 * virtchnl_vlan_caps.offloads.ethertype_match =
1057 * VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION;
1059 * In order to enable outer VLAN stripping for 0x88a8 VLANs, the VF would
1060 * populate the virtchnl_vlan_setting structure in the following manner and send
1061 * the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2. Also, this will change the
1062 * ethertype for VLAN insertion if it's enabled. So, for completeness, a
1063 * VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 with the same ethertype should be sent.
1065 * virtchnl_vlan_setting.outer_ethertype_setting = VIRTHCNL_VLAN_ETHERTYPE_88A8;
1067 * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on
1070 * VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2
1071 * VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2
1073 * VF sends this message to enable or disable VLAN filtering. It also needs to
1074 * specify an ethertype. The VF knows which VLAN ethertypes are allowed and
1075 * whether or not it's allowed to enable/disable filtering via the
1076 * VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS message. The VF needs to
1077 * parse the virtchnl_vlan_caps.filtering fields to determine which, if any,
1078 * filtering messages are allowed.
1080 * For example, if the PF populates the virtchnl_vlan_caps.filtering in the
1081 * following manner the VF will be allowed to enable/disable 0x8100 and 0x88a8
1082 * outer VLAN filtering together. Note, that the VIRTCHNL_VLAN_ETHERTYPE_AND
1083 * means that all filtering ethertypes will to be enabled and disabled together
1084 * regardless of the request from the VF. This means that the underlying
1085 * hardware only supports VLAN filtering for all VLAN the specified ethertypes
1088 * virtchnl_vlan_caps.filtering.filtering_support.outer =
1089 * VIRTCHNL_VLAN_TOGGLE |
1090 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1091 * VIRTHCNL_VLAN_ETHERTYPE_88A8 |
1092 * VIRTCHNL_VLAN_ETHERTYPE_9100 |
1093 * VIRTCHNL_VLAN_ETHERTYPE_AND;
1095 * In order to enable outer VLAN filtering for 0x88a8 and 0x8100 VLANs (0x9100
1096 * VLANs aren't supported by the VF driver), the VF would populate the
1097 * virtchnl_vlan_setting structure in the following manner and send the
1098 * VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2. The same message format would be used
1099 * to disable outer VLAN filtering for 0x88a8 and 0x8100 VLANs, but the
1100 * VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2 opcode is used.
1102 * virtchnl_vlan_setting.outer_ethertype_setting =
1103 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1104 * VIRTCHNL_VLAN_ETHERTYPE_88A8;
1107 struct virtchnl_vlan_setting {
1108 u32 outer_ethertype_setting;
1109 u32 inner_ethertype_setting;
1114 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vlan_setting);
1116 /* VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE
1117 * VF sends VSI id and flags.
1118 * PF returns status code in retval.
1119 * Note: we assume that broadcast accept mode is always enabled.
1121 struct virtchnl_promisc_info {
1126 VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_promisc_info);
1128 #define FLAG_VF_UNICAST_PROMISC 0x00000001
1129 #define FLAG_VF_MULTICAST_PROMISC 0x00000002
1131 /* VIRTCHNL_OP_GET_STATS
1132 * VF sends this message to request stats for the selected VSI. VF uses
1133 * the virtchnl_queue_select struct to specify the VSI. The queue_id
1134 * field is ignored by the PF.
1136 * PF replies with struct virtchnl_eth_stats in an external buffer.
1139 struct virtchnl_eth_stats {
1140 u64 rx_bytes; /* received bytes */
1141 u64 rx_unicast; /* received unicast pkts */
1142 u64 rx_multicast; /* received multicast pkts */
1143 u64 rx_broadcast; /* received broadcast pkts */
1145 u64 rx_unknown_protocol;
1146 u64 tx_bytes; /* transmitted bytes */
1147 u64 tx_unicast; /* transmitted unicast pkts */
1148 u64 tx_multicast; /* transmitted multicast pkts */
1149 u64 tx_broadcast; /* transmitted broadcast pkts */
1154 /* VIRTCHNL_OP_CONFIG_RSS_KEY
1155 * VIRTCHNL_OP_CONFIG_RSS_LUT
1156 * VF sends these messages to configure RSS. Only supported if both PF
1157 * and VF drivers set the VIRTCHNL_VF_OFFLOAD_RSS_PF bit during
1158 * configuration negotiation. If this is the case, then the RSS fields in
1159 * the VF resource struct are valid.
1160 * Both the key and LUT are initialized to 0 by the PF, meaning that
1161 * RSS is effectively disabled until set up by the VF.
1163 struct virtchnl_rss_key {
1166 u8 key[1]; /* RSS hash key, packed bytes */
1169 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_rss_key);
1171 struct virtchnl_rss_lut {
1174 u8 lut[1]; /* RSS lookup table */
1177 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_rss_lut);
1179 /* VIRTCHNL_OP_GET_RSS_HENA_CAPS
1180 * VIRTCHNL_OP_SET_RSS_HENA
1181 * VF sends these messages to get and set the hash filter enable bits for RSS.
1182 * By default, the PF sets these to all possible traffic types that the
1183 * hardware supports. The VF can query this value if it wants to change the
1184 * traffic types that are hashed by the hardware.
1186 struct virtchnl_rss_hena {
1190 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_rss_hena);
1192 /* Type of RSS algorithm */
1193 enum virtchnl_rss_algorithm {
1194 VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC = 0,
1195 VIRTCHNL_RSS_ALG_XOR_ASYMMETRIC = 1,
1196 VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC = 2,
1197 VIRTCHNL_RSS_ALG_XOR_SYMMETRIC = 3,
1200 /* This is used by PF driver to enforce how many channels can be supported.
1201 * When ADQ_V2 capability is negotiated, it will allow 16 channels otherwise
1202 * PF driver will allow only max 4 channels
1204 #define VIRTCHNL_MAX_ADQ_CHANNELS 4
1205 #define VIRTCHNL_MAX_ADQ_V2_CHANNELS 16
1207 /* VIRTCHNL_OP_ENABLE_CHANNELS
1208 * VIRTCHNL_OP_DISABLE_CHANNELS
1209 * VF sends these messages to enable or disable channels based on
1210 * the user specified queue count and queue offset for each traffic class.
1211 * This struct encompasses all the information that the PF needs from
1212 * VF to create a channel.
1214 struct virtchnl_channel_info {
1215 u16 count; /* number of queues in a channel */
1216 u16 offset; /* queues in a channel start from 'offset' */
1221 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_channel_info);
1223 struct virtchnl_tc_info {
1226 struct virtchnl_channel_info list[1];
1229 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_tc_info);
1231 /* VIRTCHNL_ADD_CLOUD_FILTER
1232 * VIRTCHNL_DEL_CLOUD_FILTER
1233 * VF sends these messages to add or delete a cloud filter based on the
1234 * user specified match and action filters. These structures encompass
1235 * all the information that the PF needs from the VF to add/delete a
1239 struct virtchnl_l4_spec {
1240 u8 src_mac[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
1241 u8 dst_mac[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
1242 /* vlan_prio is part of this 16 bit field even from OS perspective
1243 * vlan_id:12 is actual vlan_id, then vlanid:bit14..12 is vlan_prio
1244 * in future, when decided to offload vlan_prio, pass that information
1245 * as part of the "vlan_id" field, Bit14..12
1248 __be16 pad; /* reserved for future use */
1255 VIRTCHNL_CHECK_STRUCT_LEN(52, virtchnl_l4_spec);
1257 union virtchnl_flow_spec {
1258 struct virtchnl_l4_spec tcp_spec;
1259 u8 buffer[128]; /* reserved for future use */
1262 VIRTCHNL_CHECK_UNION_LEN(128, virtchnl_flow_spec);
1264 enum virtchnl_action {
1266 VIRTCHNL_ACTION_DROP = 0,
1267 VIRTCHNL_ACTION_TC_REDIRECT,
1268 VIRTCHNL_ACTION_PASSTHRU,
1269 VIRTCHNL_ACTION_QUEUE,
1270 VIRTCHNL_ACTION_Q_REGION,
1271 VIRTCHNL_ACTION_MARK,
1272 VIRTCHNL_ACTION_COUNT,
1275 enum virtchnl_flow_type {
1277 VIRTCHNL_TCP_V4_FLOW = 0,
1278 VIRTCHNL_TCP_V6_FLOW,
1279 VIRTCHNL_UDP_V4_FLOW,
1280 VIRTCHNL_UDP_V6_FLOW,
1283 struct virtchnl_filter {
1284 union virtchnl_flow_spec data;
1285 union virtchnl_flow_spec mask;
1287 /* see enum virtchnl_flow_type */
1290 /* see enum virtchnl_action */
1296 VIRTCHNL_CHECK_STRUCT_LEN(272, virtchnl_filter);
1298 struct virtchnl_shaper_bw {
1304 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_shaper_bw);
1306 /* VIRTCHNL_OP_DCF_GET_VSI_MAP
1307 * VF sends this message to get VSI mapping table.
1308 * PF responds with an indirect message containing VF's
1310 * The index of vf_vsi array is the logical VF ID, the
1311 * value of vf_vsi array is the VF's HW VSI ID with its
1312 * valid configuration.
1314 struct virtchnl_dcf_vsi_map {
1315 u16 pf_vsi; /* PF's HW VSI ID */
1316 u16 num_vfs; /* The actual number of VFs allocated */
1317 #define VIRTCHNL_DCF_VF_VSI_ID_S 0
1318 #define VIRTCHNL_DCF_VF_VSI_ID_M (0xFFF << VIRTCHNL_DCF_VF_VSI_ID_S)
1319 #define VIRTCHNL_DCF_VF_VSI_VALID BIT(15)
1323 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_dcf_vsi_map);
1325 #define PKG_NAME_SIZE 32
1328 struct pkg_version {
1335 VIRTCHNL_CHECK_STRUCT_LEN(4, pkg_version);
1337 struct virtchnl_pkg_info {
1338 struct pkg_version pkg_ver;
1340 char pkg_name[PKG_NAME_SIZE];
1344 VIRTCHNL_CHECK_STRUCT_LEN(48, virtchnl_pkg_info);
1346 /* VIRTCHNL_OP_DCF_VLAN_OFFLOAD
1347 * DCF negotiates the VIRTCHNL_VF_OFFLOAD_VLAN_V2 capability firstly to get
1348 * the double VLAN configuration, then DCF sends this message to configure the
1349 * outer or inner VLAN offloads (insertion and strip) for the target VF.
1351 struct virtchnl_dcf_vlan_offload {
1355 #define VIRTCHNL_DCF_VLAN_TYPE_S 0
1356 #define VIRTCHNL_DCF_VLAN_TYPE_M \
1357 (0x1 << VIRTCHNL_DCF_VLAN_TYPE_S)
1358 #define VIRTCHNL_DCF_VLAN_TYPE_INNER 0x0
1359 #define VIRTCHNL_DCF_VLAN_TYPE_OUTER 0x1
1360 #define VIRTCHNL_DCF_VLAN_INSERT_MODE_S 1
1361 #define VIRTCHNL_DCF_VLAN_INSERT_MODE_M \
1362 (0x7 << VIRTCHNL_DCF_VLAN_INSERT_MODE_S)
1363 #define VIRTCHNL_DCF_VLAN_INSERT_DISABLE 0x1
1364 #define VIRTCHNL_DCF_VLAN_INSERT_PORT_BASED 0x2
1365 #define VIRTCHNL_DCF_VLAN_INSERT_VIA_TX_DESC 0x3
1366 #define VIRTCHNL_DCF_VLAN_STRIP_MODE_S 4
1367 #define VIRTCHNL_DCF_VLAN_STRIP_MODE_M \
1368 (0x7 << VIRTCHNL_DCF_VLAN_STRIP_MODE_S)
1369 #define VIRTCHNL_DCF_VLAN_STRIP_DISABLE 0x1
1370 #define VIRTCHNL_DCF_VLAN_STRIP_ONLY 0x2
1371 #define VIRTCHNL_DCF_VLAN_STRIP_INTO_RX_DESC 0x3
1376 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_dcf_vlan_offload);
1378 struct virtchnl_dcf_bw_cfg {
1380 #define VIRTCHNL_DCF_BW_CIR BIT(0)
1381 #define VIRTCHNL_DCF_BW_PIR BIT(1)
1384 enum virtchnl_bw_limit_type type;
1386 struct virtchnl_shaper_bw shaper;
1391 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_dcf_bw_cfg);
1393 /* VIRTCHNL_OP_DCF_CONFIG_BW
1394 * VF send this message to set the bandwidth configuration of each
1395 * TC with a specific vf id. The flag node_type is to indicate that
1396 * this message is to configure VSI node or TC node bandwidth.
1398 struct virtchnl_dcf_bw_cfg_list {
1401 #define VIRTCHNL_DCF_TARGET_TC_BW 0
1402 #define VIRTCHNL_DCF_TARGET_VF_BW 1
1404 struct virtchnl_dcf_bw_cfg cfg[1];
1407 VIRTCHNL_CHECK_STRUCT_LEN(44, virtchnl_dcf_bw_cfg_list);
1409 struct virtchnl_supported_rxdids {
1410 /* see enum virtchnl_rx_desc_id_bitmasks */
1411 u64 supported_rxdids;
1414 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_supported_rxdids);
1416 /* VIRTCHNL_OP_EVENT
1417 * PF sends this message to inform the VF driver of events that may affect it.
1418 * No direct response is expected from the VF, though it may generate other
1419 * messages in response to this one.
1421 enum virtchnl_event_codes {
1422 VIRTCHNL_EVENT_UNKNOWN = 0,
1423 VIRTCHNL_EVENT_LINK_CHANGE,
1424 VIRTCHNL_EVENT_RESET_IMPENDING,
1425 VIRTCHNL_EVENT_PF_DRIVER_CLOSE,
1426 VIRTCHNL_EVENT_DCF_VSI_MAP_UPDATE,
1429 #define PF_EVENT_SEVERITY_INFO 0
1430 #define PF_EVENT_SEVERITY_ATTENTION 1
1431 #define PF_EVENT_SEVERITY_ACTION_REQUIRED 2
1432 #define PF_EVENT_SEVERITY_CERTAIN_DOOM 255
1434 struct virtchnl_pf_event {
1435 /* see enum virtchnl_event_codes */
1438 /* If the PF driver does not support the new speed reporting
1439 * capabilities then use link_event else use link_event_adv to
1440 * get the speed and link information. The ability to understand
1441 * new speeds is indicated by setting the capability flag
1442 * VIRTCHNL_VF_CAP_ADV_LINK_SPEED in vf_cap_flags parameter
1443 * in virtchnl_vf_resource struct and can be used to determine
1444 * which link event struct to use below.
1447 enum virtchnl_link_speed link_speed;
1451 /* link_speed provided in Mbps */
1464 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_pf_event);
1467 /* VF reset states - these are written into the RSTAT register:
1468 * VFGEN_RSTAT on the VF
1469 * When the PF initiates a reset, it writes 0
1470 * When the reset is complete, it writes 1
1471 * When the PF detects that the VF has recovered, it writes 2
1472 * VF checks this register periodically to determine if a reset has occurred,
1473 * then polls it to know when the reset is complete.
1474 * If either the PF or VF reads the register while the hardware
1475 * is in a reset state, it will return DEADBEEF, which, when masked
1478 enum virtchnl_vfr_states {
1479 VIRTCHNL_VFR_INPROGRESS = 0,
1480 VIRTCHNL_VFR_COMPLETED,
1481 VIRTCHNL_VFR_VFACTIVE,
1484 #define VIRTCHNL_MAX_NUM_PROTO_HDRS 32
1485 #define PROTO_HDR_SHIFT 5
1486 #define PROTO_HDR_FIELD_START(proto_hdr_type) \
1487 (proto_hdr_type << PROTO_HDR_SHIFT)
1488 #define PROTO_HDR_FIELD_MASK ((1UL << PROTO_HDR_SHIFT) - 1)
1490 /* VF use these macros to configure each protocol header.
1491 * Specify which protocol headers and protocol header fields base on
1492 * virtchnl_proto_hdr_type and virtchnl_proto_hdr_field.
1493 * @param hdr: a struct of virtchnl_proto_hdr
1494 * @param hdr_type: ETH/IPV4/TCP, etc
1495 * @param field: SRC/DST/TEID/SPI, etc
1497 #define VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, field) \
1498 ((hdr)->field_selector |= BIT((field) & PROTO_HDR_FIELD_MASK))
1499 #define VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, field) \
1500 ((hdr)->field_selector &= ~BIT((field) & PROTO_HDR_FIELD_MASK))
1501 #define VIRTCHNL_TEST_PROTO_HDR_FIELD(hdr, val) \
1502 ((hdr)->field_selector & BIT((val) & PROTO_HDR_FIELD_MASK))
1503 #define VIRTCHNL_GET_PROTO_HDR_FIELD(hdr) ((hdr)->field_selector)
1505 #define VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \
1506 (VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, \
1507 VIRTCHNL_PROTO_HDR_ ## hdr_type ## _ ## field))
1508 #define VIRTCHNL_DEL_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \
1509 (VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, \
1510 VIRTCHNL_PROTO_HDR_ ## hdr_type ## _ ## field))
1512 #define VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, hdr_type) \
1513 ((hdr)->type = VIRTCHNL_PROTO_HDR_ ## hdr_type)
1514 #define VIRTCHNL_GET_PROTO_HDR_TYPE(hdr) \
1515 (((hdr)->type) >> PROTO_HDR_SHIFT)
1516 #define VIRTCHNL_TEST_PROTO_HDR_TYPE(hdr, val) \
1517 ((hdr)->type == ((val) >> PROTO_HDR_SHIFT))
1518 #define VIRTCHNL_TEST_PROTO_HDR(hdr, val) \
1519 (VIRTCHNL_TEST_PROTO_HDR_TYPE(hdr, val) && \
1520 VIRTCHNL_TEST_PROTO_HDR_FIELD(hdr, val))
1522 /* Protocol header type within a packet segment. A segment consists of one or
1523 * more protocol headers that make up a logical group of protocol headers. Each
1524 * logical group of protocol headers encapsulates or is encapsulated using/by
1525 * tunneling or encapsulation protocols for network virtualization.
1527 enum virtchnl_proto_hdr_type {
1528 VIRTCHNL_PROTO_HDR_NONE,
1529 VIRTCHNL_PROTO_HDR_ETH,
1530 VIRTCHNL_PROTO_HDR_S_VLAN,
1531 VIRTCHNL_PROTO_HDR_C_VLAN,
1532 VIRTCHNL_PROTO_HDR_IPV4,
1533 VIRTCHNL_PROTO_HDR_IPV6,
1534 VIRTCHNL_PROTO_HDR_TCP,
1535 VIRTCHNL_PROTO_HDR_UDP,
1536 VIRTCHNL_PROTO_HDR_SCTP,
1537 VIRTCHNL_PROTO_HDR_GTPU_IP,
1538 VIRTCHNL_PROTO_HDR_GTPU_EH,
1539 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN,
1540 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP,
1541 VIRTCHNL_PROTO_HDR_PPPOE,
1542 VIRTCHNL_PROTO_HDR_L2TPV3,
1543 VIRTCHNL_PROTO_HDR_ESP,
1544 VIRTCHNL_PROTO_HDR_AH,
1545 VIRTCHNL_PROTO_HDR_PFCP,
1546 VIRTCHNL_PROTO_HDR_GTPC,
1547 VIRTCHNL_PROTO_HDR_ECPRI,
1548 VIRTCHNL_PROTO_HDR_L2TPV2,
1549 VIRTCHNL_PROTO_HDR_PPP,
1550 /* IPv4 and IPv6 Fragment header types are only associated to
1551 * VIRTCHNL_PROTO_HDR_IPV4 and VIRTCHNL_PROTO_HDR_IPV6 respectively,
1552 * cannot be used independently.
1554 VIRTCHNL_PROTO_HDR_IPV4_FRAG,
1555 VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG,
1556 VIRTCHNL_PROTO_HDR_GRE,
1559 /* Protocol header field within a protocol header. */
1560 enum virtchnl_proto_hdr_field {
1562 VIRTCHNL_PROTO_HDR_ETH_SRC =
1563 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ETH),
1564 VIRTCHNL_PROTO_HDR_ETH_DST,
1565 VIRTCHNL_PROTO_HDR_ETH_ETHERTYPE,
1567 VIRTCHNL_PROTO_HDR_S_VLAN_ID =
1568 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_S_VLAN),
1570 VIRTCHNL_PROTO_HDR_C_VLAN_ID =
1571 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_C_VLAN),
1573 VIRTCHNL_PROTO_HDR_IPV4_SRC =
1574 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV4),
1575 VIRTCHNL_PROTO_HDR_IPV4_DST,
1576 VIRTCHNL_PROTO_HDR_IPV4_DSCP,
1577 VIRTCHNL_PROTO_HDR_IPV4_TTL,
1578 VIRTCHNL_PROTO_HDR_IPV4_PROT,
1579 VIRTCHNL_PROTO_HDR_IPV4_CHKSUM,
1581 VIRTCHNL_PROTO_HDR_IPV6_SRC =
1582 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV6),
1583 VIRTCHNL_PROTO_HDR_IPV6_DST,
1584 VIRTCHNL_PROTO_HDR_IPV6_TC,
1585 VIRTCHNL_PROTO_HDR_IPV6_HOP_LIMIT,
1586 VIRTCHNL_PROTO_HDR_IPV6_PROT,
1588 VIRTCHNL_PROTO_HDR_IPV6_PREFIX32_SRC,
1589 VIRTCHNL_PROTO_HDR_IPV6_PREFIX32_DST,
1590 VIRTCHNL_PROTO_HDR_IPV6_PREFIX40_SRC,
1591 VIRTCHNL_PROTO_HDR_IPV6_PREFIX40_DST,
1592 VIRTCHNL_PROTO_HDR_IPV6_PREFIX48_SRC,
1593 VIRTCHNL_PROTO_HDR_IPV6_PREFIX48_DST,
1594 VIRTCHNL_PROTO_HDR_IPV6_PREFIX56_SRC,
1595 VIRTCHNL_PROTO_HDR_IPV6_PREFIX56_DST,
1596 VIRTCHNL_PROTO_HDR_IPV6_PREFIX64_SRC,
1597 VIRTCHNL_PROTO_HDR_IPV6_PREFIX64_DST,
1598 VIRTCHNL_PROTO_HDR_IPV6_PREFIX96_SRC,
1599 VIRTCHNL_PROTO_HDR_IPV6_PREFIX96_DST,
1601 VIRTCHNL_PROTO_HDR_TCP_SRC_PORT =
1602 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_TCP),
1603 VIRTCHNL_PROTO_HDR_TCP_DST_PORT,
1604 VIRTCHNL_PROTO_HDR_TCP_CHKSUM,
1606 VIRTCHNL_PROTO_HDR_UDP_SRC_PORT =
1607 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_UDP),
1608 VIRTCHNL_PROTO_HDR_UDP_DST_PORT,
1609 VIRTCHNL_PROTO_HDR_UDP_CHKSUM,
1611 VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT =
1612 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_SCTP),
1613 VIRTCHNL_PROTO_HDR_SCTP_DST_PORT,
1614 VIRTCHNL_PROTO_HDR_SCTP_CHKSUM,
1616 VIRTCHNL_PROTO_HDR_GTPU_IP_TEID =
1617 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_IP),
1619 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU =
1620 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH),
1621 VIRTCHNL_PROTO_HDR_GTPU_EH_QFI,
1623 VIRTCHNL_PROTO_HDR_PPPOE_SESS_ID =
1624 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_PPPOE),
1626 VIRTCHNL_PROTO_HDR_L2TPV3_SESS_ID =
1627 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_L2TPV3),
1629 VIRTCHNL_PROTO_HDR_ESP_SPI =
1630 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ESP),
1632 VIRTCHNL_PROTO_HDR_AH_SPI =
1633 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_AH),
1635 VIRTCHNL_PROTO_HDR_PFCP_S_FIELD =
1636 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_PFCP),
1637 VIRTCHNL_PROTO_HDR_PFCP_SEID,
1639 VIRTCHNL_PROTO_HDR_GTPC_TEID =
1640 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPC),
1642 VIRTCHNL_PROTO_HDR_ECPRI_MSG_TYPE =
1643 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ECPRI),
1644 VIRTCHNL_PROTO_HDR_ECPRI_PC_RTC_ID,
1645 /* IPv4 Dummy Fragment */
1646 VIRTCHNL_PROTO_HDR_IPV4_FRAG_PKID =
1647 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV4_FRAG),
1648 /* IPv6 Extension Fragment */
1649 VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG_PKID =
1650 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG),
1652 VIRTCHNL_PROTO_HDR_GTPU_DWN_QFI =
1653 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN),
1654 VIRTCHNL_PROTO_HDR_GTPU_UP_QFI =
1655 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP),
1658 struct virtchnl_proto_hdr {
1659 /* see enum virtchnl_proto_hdr_type */
1661 u32 field_selector; /* a bit mask to select field for header type */
1664 * binary buffer in network order for specific header type.
1665 * For example, if type = VIRTCHNL_PROTO_HDR_IPV4, a IPv4
1666 * header is expected to be copied into the buffer.
1670 VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_proto_hdr);
1672 struct virtchnl_proto_hdrs {
1675 * specify where protocol header start from.
1676 * 0 - from the outer layer
1677 * 1 - from the first inner layer
1678 * 2 - from the second inner layer
1681 int count; /* the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS */
1682 struct virtchnl_proto_hdr proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
1685 VIRTCHNL_CHECK_STRUCT_LEN(2312, virtchnl_proto_hdrs);
1687 struct virtchnl_rss_cfg {
1688 struct virtchnl_proto_hdrs proto_hdrs; /* protocol headers */
1690 /* see enum virtchnl_rss_algorithm; rss algorithm type */
1692 u8 reserved[128]; /* reserve for future */
1695 VIRTCHNL_CHECK_STRUCT_LEN(2444, virtchnl_rss_cfg);
1697 /* action configuration for FDIR */
1698 struct virtchnl_filter_action {
1699 /* see enum virtchnl_action type */
1702 /* used for queue and qgroup action */
1707 /* used for count action */
1709 /* share counter ID with other flow rules */
1711 u32 id; /* counter ID */
1713 /* used for mark action */
1719 VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_filter_action);
1721 #define VIRTCHNL_MAX_NUM_ACTIONS 8
1723 struct virtchnl_filter_action_set {
1724 /* action number must be less then VIRTCHNL_MAX_NUM_ACTIONS */
1726 struct virtchnl_filter_action actions[VIRTCHNL_MAX_NUM_ACTIONS];
1729 VIRTCHNL_CHECK_STRUCT_LEN(292, virtchnl_filter_action_set);
1731 /* pattern and action for FDIR rule */
1732 struct virtchnl_fdir_rule {
1733 struct virtchnl_proto_hdrs proto_hdrs;
1734 struct virtchnl_filter_action_set action_set;
1737 VIRTCHNL_CHECK_STRUCT_LEN(2604, virtchnl_fdir_rule);
1739 /* Status returned to VF after VF requests FDIR commands
1740 * VIRTCHNL_FDIR_SUCCESS
1741 * VF FDIR related request is successfully done by PF
1742 * The request can be OP_ADD/DEL/QUERY_FDIR_FILTER.
1744 * VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE
1745 * OP_ADD_FDIR_FILTER request is failed due to no Hardware resource.
1747 * VIRTCHNL_FDIR_FAILURE_RULE_EXIST
1748 * OP_ADD_FDIR_FILTER request is failed due to the rule is already existed.
1750 * VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT
1751 * OP_ADD_FDIR_FILTER request is failed due to conflict with existing rule.
1753 * VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST
1754 * OP_DEL_FDIR_FILTER request is failed due to this rule doesn't exist.
1756 * VIRTCHNL_FDIR_FAILURE_RULE_INVALID
1757 * OP_ADD_FDIR_FILTER request is failed due to parameters validation
1758 * or HW doesn't support.
1760 * VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT
1761 * OP_ADD/DEL_FDIR_FILTER request is failed due to timing out
1764 * VIRTCHNL_FDIR_FAILURE_QUERY_INVALID
1765 * OP_QUERY_FDIR_FILTER request is failed due to parameters validation,
1766 * for example, VF query counter of a rule who has no counter action.
1768 enum virtchnl_fdir_prgm_status {
1769 VIRTCHNL_FDIR_SUCCESS = 0,
1770 VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE,
1771 VIRTCHNL_FDIR_FAILURE_RULE_EXIST,
1772 VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT,
1773 VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST,
1774 VIRTCHNL_FDIR_FAILURE_RULE_INVALID,
1775 VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT,
1776 VIRTCHNL_FDIR_FAILURE_QUERY_INVALID,
1779 /* VIRTCHNL_OP_ADD_FDIR_FILTER
1780 * VF sends this request to PF by filling out vsi_id,
1781 * validate_only and rule_cfg. PF will return flow_id
1782 * if the request is successfully done and return add_status to VF.
1784 struct virtchnl_fdir_add {
1785 u16 vsi_id; /* INPUT */
1787 * 1 for validating a fdir rule, 0 for creating a fdir rule.
1788 * Validate and create share one ops: VIRTCHNL_OP_ADD_FDIR_FILTER.
1790 u16 validate_only; /* INPUT */
1791 u32 flow_id; /* OUTPUT */
1792 struct virtchnl_fdir_rule rule_cfg; /* INPUT */
1794 /* see enum virtchnl_fdir_prgm_status; OUTPUT */
1798 VIRTCHNL_CHECK_STRUCT_LEN(2616, virtchnl_fdir_add);
1800 /* VIRTCHNL_OP_DEL_FDIR_FILTER
1801 * VF sends this request to PF by filling out vsi_id
1802 * and flow_id. PF will return del_status to VF.
1804 struct virtchnl_fdir_del {
1805 u16 vsi_id; /* INPUT */
1807 u32 flow_id; /* INPUT */
1809 /* see enum virtchnl_fdir_prgm_status; OUTPUT */
1813 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del);
1815 /* VIRTCHNL_OP_GET_QOS_CAPS
1816 * VF sends this message to get its QoS Caps, such as
1817 * TC number, Arbiter and Bandwidth.
1819 struct virtchnl_qos_cap_elem {
1822 #define VIRTCHNL_ABITER_STRICT 0
1823 #define VIRTCHNL_ABITER_ETS 2
1825 #define VIRTCHNL_STRICT_WEIGHT 1
1827 enum virtchnl_bw_limit_type type;
1829 struct virtchnl_shaper_bw shaper;
1834 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_qos_cap_elem);
1836 struct virtchnl_qos_cap_list {
1839 struct virtchnl_qos_cap_elem cap[1];
1842 VIRTCHNL_CHECK_STRUCT_LEN(44, virtchnl_qos_cap_list);
1844 /* VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP
1845 * VF sends message virtchnl_queue_tc_mapping to set queue to tc
1846 * mapping for all the Tx and Rx queues with a specified VSI, and
1847 * would get response about bitmap of valid user priorities
1848 * associated with queues.
1850 struct virtchnl_queue_tc_mapping {
1853 u16 num_queue_pairs;
1861 #define VIRTCHNL_USER_PRIO_TYPE_UP 0
1862 #define VIRTCHNL_USER_PRIO_TYPE_DSCP 1
1864 u16 valid_prio_bitmap;
1869 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_tc_mapping);
1872 /* TX and RX queue types are valid in legacy as well as split queue models.
1873 * With Split Queue model, 2 additional types are introduced - TX_COMPLETION
1874 * and RX_BUFFER. In split queue model, RX corresponds to the queue where HW
1875 * posts completions.
1877 enum virtchnl_queue_type {
1878 VIRTCHNL_QUEUE_TYPE_TX = 0,
1879 VIRTCHNL_QUEUE_TYPE_RX = 1,
1880 VIRTCHNL_QUEUE_TYPE_TX_COMPLETION = 2,
1881 VIRTCHNL_QUEUE_TYPE_RX_BUFFER = 3,
1882 VIRTCHNL_QUEUE_TYPE_CONFIG_TX = 4,
1883 VIRTCHNL_QUEUE_TYPE_CONFIG_RX = 5
1887 /* structure to specify a chunk of contiguous queues */
1888 struct virtchnl_queue_chunk {
1889 /* see enum virtchnl_queue_type */
1895 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_queue_chunk);
1897 /* structure to specify several chunks of contiguous queues */
1898 struct virtchnl_queue_chunks {
1901 struct virtchnl_queue_chunk chunks[1];
1904 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_chunks);
1907 /* VIRTCHNL_OP_ENABLE_QUEUES_V2
1908 * VIRTCHNL_OP_DISABLE_QUEUES_V2
1909 * VIRTCHNL_OP_DEL_QUEUES
1911 * If VIRTCHNL_CAP_EXT_FEATURES was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
1912 * then all of these ops are available.
1914 * If VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
1915 * then VIRTCHNL_OP_ENABLE_QUEUES_V2 and VIRTCHNL_OP_DISABLE_QUEUES_V2 are
1918 * PF sends these messages to enable, disable or delete queues specified in
1919 * chunks. PF sends virtchnl_del_ena_dis_queues struct to specify the queues
1920 * to be enabled/disabled/deleted. Also applicable to single queue RX or
1921 * TX. CP performs requested action and returns status.
1923 struct virtchnl_del_ena_dis_queues {
1926 struct virtchnl_queue_chunks chunks;
1929 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_del_ena_dis_queues);
1931 /* Virtchannel interrupt throttling rate index */
1932 enum virtchnl_itr_idx {
1933 VIRTCHNL_ITR_IDX_0 = 0,
1934 VIRTCHNL_ITR_IDX_1 = 1,
1935 VIRTCHNL_ITR_IDX_NO_ITR = 3,
1938 /* Queue to vector mapping */
1939 struct virtchnl_queue_vector {
1944 /* see enum virtchnl_itr_idx */
1947 /* see enum virtchnl_queue_type */
1951 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_queue_vector);
1953 /* VIRTCHNL_OP_MAP_QUEUE_VECTOR
1954 * VIRTCHNL_OP_UNMAP_QUEUE_VECTOR
1956 * If VIRTCHNL_CAP_EXT_FEATURES was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
1957 * then all of these ops are available.
1959 * If VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
1960 * then only VIRTCHNL_OP_MAP_QUEUE_VECTOR is available.
1962 * PF sends this message to map or unmap queues to vectors and ITR index
1963 * registers. External data buffer contains virtchnl_queue_vector_maps structure
1964 * that contains num_qv_maps of virtchnl_queue_vector structures.
1965 * CP maps the requested queue vector maps after validating the queue and vector
1966 * ids and returns a status code.
1968 struct virtchnl_queue_vector_maps {
1972 struct virtchnl_queue_vector qv_maps[1];
1975 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_queue_vector_maps);
1978 /* Since VF messages are limited by u16 size, precalculate the maximum possible
1979 * values of nested elements in virtchnl structures that virtual channel can
1980 * possibly handle in a single message.
1982 enum virtchnl_vector_limits {
1983 VIRTCHNL_OP_CONFIG_VSI_QUEUES_MAX =
1984 ((u16)(~0) - sizeof(struct virtchnl_vsi_queue_config_info)) /
1985 sizeof(struct virtchnl_queue_pair_info),
1987 VIRTCHNL_OP_CONFIG_IRQ_MAP_MAX =
1988 ((u16)(~0) - sizeof(struct virtchnl_irq_map_info)) /
1989 sizeof(struct virtchnl_vector_map),
1991 VIRTCHNL_OP_ADD_DEL_ETH_ADDR_MAX =
1992 ((u16)(~0) - sizeof(struct virtchnl_ether_addr_list)) /
1993 sizeof(struct virtchnl_ether_addr),
1995 VIRTCHNL_OP_ADD_DEL_VLAN_MAX =
1996 ((u16)(~0) - sizeof(struct virtchnl_vlan_filter_list)) /
2000 VIRTCHNL_OP_ENABLE_CHANNELS_MAX =
2001 ((u16)(~0) - sizeof(struct virtchnl_tc_info)) /
2002 sizeof(struct virtchnl_channel_info),
2004 VIRTCHNL_OP_ENABLE_DISABLE_DEL_QUEUES_V2_MAX =
2005 ((u16)(~0) - sizeof(struct virtchnl_del_ena_dis_queues)) /
2006 sizeof(struct virtchnl_queue_chunk),
2008 VIRTCHNL_OP_MAP_UNMAP_QUEUE_VECTOR_MAX =
2009 ((u16)(~0) - sizeof(struct virtchnl_queue_vector_maps)) /
2010 sizeof(struct virtchnl_queue_vector),
2012 VIRTCHNL_OP_ADD_DEL_VLAN_V2_MAX =
2013 ((u16)(~0) - sizeof(struct virtchnl_vlan_filter_list_v2)) /
2014 sizeof(struct virtchnl_vlan_filter),
2018 * virtchnl_vc_validate_vf_msg
2019 * @ver: Virtchnl version info
2020 * @v_opcode: Opcode for the message
2021 * @msg: pointer to the msg buffer
2022 * @msglen: msg length
2024 * validate msg format against struct for each opcode
2027 virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
2028 u8 *msg, u16 msglen)
2030 bool err_msg_format = false;
2033 /* Validate message length. */
2035 case VIRTCHNL_OP_VERSION:
2036 valid_len = sizeof(struct virtchnl_version_info);
2038 case VIRTCHNL_OP_RESET_VF:
2040 case VIRTCHNL_OP_GET_VF_RESOURCES:
2042 valid_len = sizeof(u32);
2044 case VIRTCHNL_OP_CONFIG_TX_QUEUE:
2045 valid_len = sizeof(struct virtchnl_txq_info);
2047 case VIRTCHNL_OP_CONFIG_RX_QUEUE:
2048 valid_len = sizeof(struct virtchnl_rxq_info);
2050 case VIRTCHNL_OP_CONFIG_VSI_QUEUES:
2051 valid_len = sizeof(struct virtchnl_vsi_queue_config_info);
2052 if (msglen >= valid_len) {
2053 struct virtchnl_vsi_queue_config_info *vqc =
2054 (struct virtchnl_vsi_queue_config_info *)msg;
2056 if (vqc->num_queue_pairs == 0 || vqc->num_queue_pairs >
2057 VIRTCHNL_OP_CONFIG_VSI_QUEUES_MAX) {
2058 err_msg_format = true;
2062 valid_len += (vqc->num_queue_pairs *
2064 virtchnl_queue_pair_info));
2067 case VIRTCHNL_OP_CONFIG_IRQ_MAP:
2068 valid_len = sizeof(struct virtchnl_irq_map_info);
2069 if (msglen >= valid_len) {
2070 struct virtchnl_irq_map_info *vimi =
2071 (struct virtchnl_irq_map_info *)msg;
2073 if (vimi->num_vectors == 0 || vimi->num_vectors >
2074 VIRTCHNL_OP_CONFIG_IRQ_MAP_MAX) {
2075 err_msg_format = true;
2079 valid_len += (vimi->num_vectors *
2080 sizeof(struct virtchnl_vector_map));
2083 case VIRTCHNL_OP_ENABLE_QUEUES:
2084 case VIRTCHNL_OP_DISABLE_QUEUES:
2085 valid_len = sizeof(struct virtchnl_queue_select);
2087 case VIRTCHNL_OP_GET_MAX_RSS_QREGION:
2089 case VIRTCHNL_OP_ADD_ETH_ADDR:
2090 case VIRTCHNL_OP_DEL_ETH_ADDR:
2091 valid_len = sizeof(struct virtchnl_ether_addr_list);
2092 if (msglen >= valid_len) {
2093 struct virtchnl_ether_addr_list *veal =
2094 (struct virtchnl_ether_addr_list *)msg;
2096 if (veal->num_elements == 0 || veal->num_elements >
2097 VIRTCHNL_OP_ADD_DEL_ETH_ADDR_MAX) {
2098 err_msg_format = true;
2102 valid_len += veal->num_elements *
2103 sizeof(struct virtchnl_ether_addr);
2106 case VIRTCHNL_OP_ADD_VLAN:
2107 case VIRTCHNL_OP_DEL_VLAN:
2108 valid_len = sizeof(struct virtchnl_vlan_filter_list);
2109 if (msglen >= valid_len) {
2110 struct virtchnl_vlan_filter_list *vfl =
2111 (struct virtchnl_vlan_filter_list *)msg;
2113 if (vfl->num_elements == 0 || vfl->num_elements >
2114 VIRTCHNL_OP_ADD_DEL_VLAN_MAX) {
2115 err_msg_format = true;
2119 valid_len += vfl->num_elements * sizeof(u16);
2122 case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE:
2123 valid_len = sizeof(struct virtchnl_promisc_info);
2125 case VIRTCHNL_OP_GET_STATS:
2126 valid_len = sizeof(struct virtchnl_queue_select);
2128 case VIRTCHNL_OP_CONFIG_RSS_KEY:
2129 valid_len = sizeof(struct virtchnl_rss_key);
2130 if (msglen >= valid_len) {
2131 struct virtchnl_rss_key *vrk =
2132 (struct virtchnl_rss_key *)msg;
2134 if (vrk->key_len == 0) {
2135 /* zero length is allowed as input */
2139 valid_len += vrk->key_len - 1;
2142 case VIRTCHNL_OP_CONFIG_RSS_LUT:
2143 valid_len = sizeof(struct virtchnl_rss_lut);
2144 if (msglen >= valid_len) {
2145 struct virtchnl_rss_lut *vrl =
2146 (struct virtchnl_rss_lut *)msg;
2148 if (vrl->lut_entries == 0) {
2149 /* zero entries is allowed as input */
2153 valid_len += vrl->lut_entries - 1;
2156 case VIRTCHNL_OP_GET_RSS_HENA_CAPS:
2158 case VIRTCHNL_OP_SET_RSS_HENA:
2159 valid_len = sizeof(struct virtchnl_rss_hena);
2161 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING:
2162 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING:
2164 case VIRTCHNL_OP_REQUEST_QUEUES:
2165 valid_len = sizeof(struct virtchnl_vf_res_request);
2167 case VIRTCHNL_OP_ENABLE_CHANNELS:
2168 valid_len = sizeof(struct virtchnl_tc_info);
2169 if (msglen >= valid_len) {
2170 struct virtchnl_tc_info *vti =
2171 (struct virtchnl_tc_info *)msg;
2173 if (vti->num_tc == 0 || vti->num_tc >
2174 VIRTCHNL_OP_ENABLE_CHANNELS_MAX) {
2175 err_msg_format = true;
2179 valid_len += (vti->num_tc - 1) *
2180 sizeof(struct virtchnl_channel_info);
2183 case VIRTCHNL_OP_DISABLE_CHANNELS:
2185 case VIRTCHNL_OP_ADD_CLOUD_FILTER:
2186 case VIRTCHNL_OP_DEL_CLOUD_FILTER:
2187 valid_len = sizeof(struct virtchnl_filter);
2189 case VIRTCHNL_OP_DCF_VLAN_OFFLOAD:
2190 valid_len = sizeof(struct virtchnl_dcf_vlan_offload);
2192 case VIRTCHNL_OP_DCF_CMD_DESC:
2193 case VIRTCHNL_OP_DCF_CMD_BUFF:
2194 /* These two opcodes are specific to handle the AdminQ command,
2195 * so the validation needs to be done in PF's context.
2199 case VIRTCHNL_OP_DCF_DISABLE:
2200 case VIRTCHNL_OP_DCF_GET_VSI_MAP:
2201 case VIRTCHNL_OP_DCF_GET_PKG_INFO:
2203 case VIRTCHNL_OP_DCF_CONFIG_BW:
2204 valid_len = sizeof(struct virtchnl_dcf_bw_cfg_list);
2205 if (msglen >= valid_len) {
2206 struct virtchnl_dcf_bw_cfg_list *cfg_list =
2207 (struct virtchnl_dcf_bw_cfg_list *)msg;
2208 if (cfg_list->num_elem == 0) {
2209 err_msg_format = true;
2212 valid_len += (cfg_list->num_elem - 1) *
2213 sizeof(struct virtchnl_dcf_bw_cfg);
2216 case VIRTCHNL_OP_GET_SUPPORTED_RXDIDS:
2218 case VIRTCHNL_OP_ADD_RSS_CFG:
2219 case VIRTCHNL_OP_DEL_RSS_CFG:
2220 valid_len = sizeof(struct virtchnl_rss_cfg);
2222 case VIRTCHNL_OP_ADD_FDIR_FILTER:
2223 valid_len = sizeof(struct virtchnl_fdir_add);
2225 case VIRTCHNL_OP_DEL_FDIR_FILTER:
2226 valid_len = sizeof(struct virtchnl_fdir_del);
2228 case VIRTCHNL_OP_GET_QOS_CAPS:
2230 case VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP:
2231 valid_len = sizeof(struct virtchnl_queue_tc_mapping);
2232 if (msglen >= valid_len) {
2233 struct virtchnl_queue_tc_mapping *q_tc =
2234 (struct virtchnl_queue_tc_mapping *)msg;
2235 if (q_tc->num_tc == 0) {
2236 err_msg_format = true;
2239 valid_len += (q_tc->num_tc - 1) *
2240 sizeof(q_tc->tc[0]);
2243 case VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS:
2245 case VIRTCHNL_OP_ADD_VLAN_V2:
2246 case VIRTCHNL_OP_DEL_VLAN_V2:
2247 valid_len = sizeof(struct virtchnl_vlan_filter_list_v2);
2248 if (msglen >= valid_len) {
2249 struct virtchnl_vlan_filter_list_v2 *vfl =
2250 (struct virtchnl_vlan_filter_list_v2 *)msg;
2252 if (vfl->num_elements == 0 || vfl->num_elements >
2253 VIRTCHNL_OP_ADD_DEL_VLAN_V2_MAX) {
2254 err_msg_format = true;
2258 valid_len += (vfl->num_elements - 1) *
2259 sizeof(struct virtchnl_vlan_filter);
2262 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2:
2263 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2:
2264 case VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2:
2265 case VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2:
2266 case VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2:
2267 case VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2:
2268 valid_len = sizeof(struct virtchnl_vlan_setting);
2270 case VIRTCHNL_OP_ENABLE_QUEUES_V2:
2271 case VIRTCHNL_OP_DISABLE_QUEUES_V2:
2272 valid_len = sizeof(struct virtchnl_del_ena_dis_queues);
2273 if (msglen >= valid_len) {
2274 struct virtchnl_del_ena_dis_queues *qs =
2275 (struct virtchnl_del_ena_dis_queues *)msg;
2276 if (qs->chunks.num_chunks == 0 ||
2277 qs->chunks.num_chunks > VIRTCHNL_OP_ENABLE_DISABLE_DEL_QUEUES_V2_MAX) {
2278 err_msg_format = true;
2281 valid_len += (qs->chunks.num_chunks - 1) *
2282 sizeof(struct virtchnl_queue_chunk);
2285 case VIRTCHNL_OP_MAP_QUEUE_VECTOR:
2286 valid_len = sizeof(struct virtchnl_queue_vector_maps);
2287 if (msglen >= valid_len) {
2288 struct virtchnl_queue_vector_maps *v_qp =
2289 (struct virtchnl_queue_vector_maps *)msg;
2290 if (v_qp->num_qv_maps == 0 ||
2291 v_qp->num_qv_maps > VIRTCHNL_OP_MAP_UNMAP_QUEUE_VECTOR_MAX) {
2292 err_msg_format = true;
2295 valid_len += (v_qp->num_qv_maps - 1) *
2296 sizeof(struct virtchnl_queue_vector);
2300 case VIRTCHNL_OP_INLINE_IPSEC_CRYPTO:
2302 struct inline_ipsec_msg *iim = (struct inline_ipsec_msg *)msg;
2304 virtchnl_inline_ipsec_val_msg_len(iim->ipsec_opcode);
2307 /* These are always errors coming from the VF. */
2308 case VIRTCHNL_OP_EVENT:
2309 case VIRTCHNL_OP_UNKNOWN:
2311 return VIRTCHNL_STATUS_ERR_PARAM;
2313 /* few more checks */
2314 if (err_msg_format || valid_len != msglen)
2315 return VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH;
2319 #endif /* _VIRTCHNL_H_ */