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
42 enum virtchnl_status_code {
43 VIRTCHNL_STATUS_SUCCESS = 0,
44 VIRTCHNL_STATUS_ERR_PARAM = -5,
45 VIRTCHNL_STATUS_ERR_NO_MEMORY = -18,
46 VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH = -38,
47 VIRTCHNL_STATUS_ERR_CQP_COMPL_ERROR = -39,
48 VIRTCHNL_STATUS_ERR_INVALID_VF_ID = -40,
49 VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR = -53,
50 VIRTCHNL_STATUS_ERR_NOT_SUPPORTED = -64,
53 /* Backward compatibility */
54 #define VIRTCHNL_ERR_PARAM VIRTCHNL_STATUS_ERR_PARAM
55 #define VIRTCHNL_STATUS_NOT_SUPPORTED VIRTCHNL_STATUS_ERR_NOT_SUPPORTED
57 #define VIRTCHNL_LINK_SPEED_2_5GB_SHIFT 0x0
58 #define VIRTCHNL_LINK_SPEED_100MB_SHIFT 0x1
59 #define VIRTCHNL_LINK_SPEED_1000MB_SHIFT 0x2
60 #define VIRTCHNL_LINK_SPEED_10GB_SHIFT 0x3
61 #define VIRTCHNL_LINK_SPEED_40GB_SHIFT 0x4
62 #define VIRTCHNL_LINK_SPEED_20GB_SHIFT 0x5
63 #define VIRTCHNL_LINK_SPEED_25GB_SHIFT 0x6
64 #define VIRTCHNL_LINK_SPEED_5GB_SHIFT 0x7
66 enum virtchnl_link_speed {
67 VIRTCHNL_LINK_SPEED_UNKNOWN = 0,
68 VIRTCHNL_LINK_SPEED_100MB = BIT(VIRTCHNL_LINK_SPEED_100MB_SHIFT),
69 VIRTCHNL_LINK_SPEED_1GB = BIT(VIRTCHNL_LINK_SPEED_1000MB_SHIFT),
70 VIRTCHNL_LINK_SPEED_10GB = BIT(VIRTCHNL_LINK_SPEED_10GB_SHIFT),
71 VIRTCHNL_LINK_SPEED_40GB = BIT(VIRTCHNL_LINK_SPEED_40GB_SHIFT),
72 VIRTCHNL_LINK_SPEED_20GB = BIT(VIRTCHNL_LINK_SPEED_20GB_SHIFT),
73 VIRTCHNL_LINK_SPEED_25GB = BIT(VIRTCHNL_LINK_SPEED_25GB_SHIFT),
74 VIRTCHNL_LINK_SPEED_2_5GB = BIT(VIRTCHNL_LINK_SPEED_2_5GB_SHIFT),
75 VIRTCHNL_LINK_SPEED_5GB = BIT(VIRTCHNL_LINK_SPEED_5GB_SHIFT),
78 /* for hsplit_0 field of Rx HMC context */
79 /* deprecated with IAVF 1.0 */
80 enum virtchnl_rx_hsplit {
81 VIRTCHNL_RX_HSPLIT_NO_SPLIT = 0,
82 VIRTCHNL_RX_HSPLIT_SPLIT_L2 = 1,
83 VIRTCHNL_RX_HSPLIT_SPLIT_IP = 2,
84 VIRTCHNL_RX_HSPLIT_SPLIT_TCP_UDP = 4,
85 VIRTCHNL_RX_HSPLIT_SPLIT_SCTP = 8,
88 enum virtchnl_bw_limit_type {
89 VIRTCHNL_BW_SHAPER = 0,
92 #define VIRTCHNL_ETH_LENGTH_OF_ADDRESS 6
93 /* END GENERIC DEFINES */
95 /* Opcodes for VF-PF communication. These are placed in the v_opcode field
96 * of the virtchnl_msg structure.
99 /* The PF sends status change events to VFs using
100 * the VIRTCHNL_OP_EVENT opcode.
101 * VFs send requests to the PF using the other ops.
102 * Use of "advanced opcode" features must be negotiated as part of capabilities
103 * exchange and are not considered part of base mode feature set.
105 VIRTCHNL_OP_UNKNOWN = 0,
106 VIRTCHNL_OP_VERSION = 1, /* must ALWAYS be 1 */
107 VIRTCHNL_OP_RESET_VF = 2,
108 VIRTCHNL_OP_GET_VF_RESOURCES = 3,
109 VIRTCHNL_OP_CONFIG_TX_QUEUE = 4,
110 VIRTCHNL_OP_CONFIG_RX_QUEUE = 5,
111 VIRTCHNL_OP_CONFIG_VSI_QUEUES = 6,
112 VIRTCHNL_OP_CONFIG_IRQ_MAP = 7,
113 VIRTCHNL_OP_ENABLE_QUEUES = 8,
114 VIRTCHNL_OP_DISABLE_QUEUES = 9,
115 VIRTCHNL_OP_ADD_ETH_ADDR = 10,
116 VIRTCHNL_OP_DEL_ETH_ADDR = 11,
117 VIRTCHNL_OP_ADD_VLAN = 12,
118 VIRTCHNL_OP_DEL_VLAN = 13,
119 VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE = 14,
120 VIRTCHNL_OP_GET_STATS = 15,
121 VIRTCHNL_OP_RSVD = 16,
122 VIRTCHNL_OP_EVENT = 17, /* must ALWAYS be 17 */
123 /* opcode 19 is reserved */
124 /* opcodes 20, 21, and 22 are reserved */
125 VIRTCHNL_OP_CONFIG_RSS_KEY = 23,
126 VIRTCHNL_OP_CONFIG_RSS_LUT = 24,
127 VIRTCHNL_OP_GET_RSS_HENA_CAPS = 25,
128 VIRTCHNL_OP_SET_RSS_HENA = 26,
129 VIRTCHNL_OP_ENABLE_VLAN_STRIPPING = 27,
130 VIRTCHNL_OP_DISABLE_VLAN_STRIPPING = 28,
131 VIRTCHNL_OP_REQUEST_QUEUES = 29,
132 VIRTCHNL_OP_ENABLE_CHANNELS = 30,
133 VIRTCHNL_OP_DISABLE_CHANNELS = 31,
134 VIRTCHNL_OP_ADD_CLOUD_FILTER = 32,
135 VIRTCHNL_OP_DEL_CLOUD_FILTER = 33,
136 /* opcodes 34, 35, 36, and 37 are reserved */
137 VIRTCHNL_OP_DCF_CONFIG_BW = 37,
138 VIRTCHNL_OP_DCF_VLAN_OFFLOAD = 38,
139 VIRTCHNL_OP_DCF_CMD_DESC = 39,
140 VIRTCHNL_OP_DCF_CMD_BUFF = 40,
141 VIRTCHNL_OP_DCF_DISABLE = 41,
142 VIRTCHNL_OP_DCF_GET_VSI_MAP = 42,
143 VIRTCHNL_OP_DCF_GET_PKG_INFO = 43,
144 VIRTCHNL_OP_GET_SUPPORTED_RXDIDS = 44,
145 VIRTCHNL_OP_ADD_RSS_CFG = 45,
146 VIRTCHNL_OP_DEL_RSS_CFG = 46,
147 VIRTCHNL_OP_ADD_FDIR_FILTER = 47,
148 VIRTCHNL_OP_DEL_FDIR_FILTER = 48,
149 VIRTCHNL_OP_GET_MAX_RSS_QREGION = 50,
150 VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS = 51,
151 VIRTCHNL_OP_ADD_VLAN_V2 = 52,
152 VIRTCHNL_OP_DEL_VLAN_V2 = 53,
153 VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 = 54,
154 VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 = 55,
155 VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 = 56,
156 VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2 = 57,
157 VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2 = 58,
158 VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2 = 59,
159 VIRTCHNL_OP_GET_QOS_CAPS = 66,
160 VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP = 67,
161 VIRTCHNL_OP_ENABLE_QUEUES_V2 = 107,
162 VIRTCHNL_OP_DISABLE_QUEUES_V2 = 108,
163 VIRTCHNL_OP_MAP_QUEUE_VECTOR = 111,
167 static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)
170 case VIRTCHNL_OP_UNKNOWN:
171 return "VIRTCHNL_OP_UNKNOWN";
172 case VIRTCHNL_OP_VERSION:
173 return "VIRTCHNL_OP_VERSION";
174 case VIRTCHNL_OP_RESET_VF:
175 return "VIRTCHNL_OP_RESET_VF";
176 case VIRTCHNL_OP_GET_VF_RESOURCES:
177 return "VIRTCHNL_OP_GET_VF_RESOURCES";
178 case VIRTCHNL_OP_CONFIG_TX_QUEUE:
179 return "VIRTCHNL_OP_CONFIG_TX_QUEUE";
180 case VIRTCHNL_OP_CONFIG_RX_QUEUE:
181 return "VIRTCHNL_OP_CONFIG_RX_QUEUE";
182 case VIRTCHNL_OP_CONFIG_VSI_QUEUES:
183 return "VIRTCHNL_OP_CONFIG_VSI_QUEUES";
184 case VIRTCHNL_OP_CONFIG_IRQ_MAP:
185 return "VIRTCHNL_OP_CONFIG_IRQ_MAP";
186 case VIRTCHNL_OP_ENABLE_QUEUES:
187 return "VIRTCHNL_OP_ENABLE_QUEUES";
188 case VIRTCHNL_OP_DISABLE_QUEUES:
189 return "VIRTCHNL_OP_DISABLE_QUEUES";
190 case VIRTCHNL_OP_ADD_ETH_ADDR:
191 return "VIRTCHNL_OP_ADD_ETH_ADDR";
192 case VIRTCHNL_OP_DEL_ETH_ADDR:
193 return "VIRTCHNL_OP_DEL_ETH_ADDR";
194 case VIRTCHNL_OP_ADD_VLAN:
195 return "VIRTCHNL_OP_ADD_VLAN";
196 case VIRTCHNL_OP_DEL_VLAN:
197 return "VIRTCHNL_OP_DEL_VLAN";
198 case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE:
199 return "VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE";
200 case VIRTCHNL_OP_GET_STATS:
201 return "VIRTCHNL_OP_GET_STATS";
202 case VIRTCHNL_OP_RSVD:
203 return "VIRTCHNL_OP_RSVD";
204 case VIRTCHNL_OP_EVENT:
205 return "VIRTCHNL_OP_EVENT";
206 case VIRTCHNL_OP_CONFIG_RSS_KEY:
207 return "VIRTCHNL_OP_CONFIG_RSS_KEY";
208 case VIRTCHNL_OP_CONFIG_RSS_LUT:
209 return "VIRTCHNL_OP_CONFIG_RSS_LUT";
210 case VIRTCHNL_OP_GET_RSS_HENA_CAPS:
211 return "VIRTCHNL_OP_GET_RSS_HENA_CAPS";
212 case VIRTCHNL_OP_SET_RSS_HENA:
213 return "VIRTCHNL_OP_SET_RSS_HENA";
214 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING:
215 return "VIRTCHNL_OP_ENABLE_VLAN_STRIPPING";
216 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING:
217 return "VIRTCHNL_OP_DISABLE_VLAN_STRIPPING";
218 case VIRTCHNL_OP_REQUEST_QUEUES:
219 return "VIRTCHNL_OP_REQUEST_QUEUES";
220 case VIRTCHNL_OP_ENABLE_CHANNELS:
221 return "VIRTCHNL_OP_ENABLE_CHANNELS";
222 case VIRTCHNL_OP_DISABLE_CHANNELS:
223 return "VIRTCHNL_OP_DISABLE_CHANNELS";
224 case VIRTCHNL_OP_ADD_CLOUD_FILTER:
225 return "VIRTCHNL_OP_ADD_CLOUD_FILTER";
226 case VIRTCHNL_OP_DEL_CLOUD_FILTER:
227 return "VIRTCHNL_OP_DEL_CLOUD_FILTER";
228 case VIRTCHNL_OP_DCF_CMD_DESC:
229 return "VIRTCHNL_OP_DCF_CMD_DESC";
230 case VIRTCHNL_OP_DCF_CMD_BUFF:
231 return "VIRTCHHNL_OP_DCF_CMD_BUFF";
232 case VIRTCHNL_OP_DCF_DISABLE:
233 return "VIRTCHNL_OP_DCF_DISABLE";
234 case VIRTCHNL_OP_DCF_GET_VSI_MAP:
235 return "VIRTCHNL_OP_DCF_GET_VSI_MAP";
236 case VIRTCHNL_OP_GET_SUPPORTED_RXDIDS:
237 return "VIRTCHNL_OP_GET_SUPPORTED_RXDIDS";
238 case VIRTCHNL_OP_ADD_RSS_CFG:
239 return "VIRTCHNL_OP_ADD_RSS_CFG";
240 case VIRTCHNL_OP_DEL_RSS_CFG:
241 return "VIRTCHNL_OP_DEL_RSS_CFG";
242 case VIRTCHNL_OP_ADD_FDIR_FILTER:
243 return "VIRTCHNL_OP_ADD_FDIR_FILTER";
244 case VIRTCHNL_OP_DEL_FDIR_FILTER:
245 return "VIRTCHNL_OP_DEL_FDIR_FILTER";
246 case VIRTCHNL_OP_GET_MAX_RSS_QREGION:
247 return "VIRTCHNL_OP_GET_MAX_RSS_QREGION";
248 case VIRTCHNL_OP_ENABLE_QUEUES_V2:
249 return "VIRTCHNL_OP_ENABLE_QUEUES_V2";
250 case VIRTCHNL_OP_DISABLE_QUEUES_V2:
251 return "VIRTCHNL_OP_DISABLE_QUEUES_V2";
252 case VIRTCHNL_OP_MAP_QUEUE_VECTOR:
253 return "VIRTCHNL_OP_MAP_QUEUE_VECTOR";
254 case VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS:
255 return "VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS";
256 case VIRTCHNL_OP_ADD_VLAN_V2:
257 return "VIRTCHNL_OP_ADD_VLAN_V2";
258 case VIRTCHNL_OP_DEL_VLAN_V2:
259 return "VIRTCHNL_OP_DEL_VLAN_V2";
260 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2:
261 return "VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2";
262 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2:
263 return "VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2";
264 case VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2:
265 return "VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2";
266 case VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2:
267 return "VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2";
268 case VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2:
269 return "VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2";
270 case VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2:
271 return "VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2";
272 case VIRTCHNL_OP_MAX:
273 return "VIRTCHNL_OP_MAX";
275 return "Unsupported (update virtchnl.h)";
279 /* These macros are used to generate compilation errors if a structure/union
280 * is not exactly the correct length. It gives a divide by zero error if the
281 * structure/union is not of the correct size, otherwise it creates an enum
282 * that is never used.
284 #define VIRTCHNL_CHECK_STRUCT_LEN(n, X) enum virtchnl_static_assert_enum_##X \
285 { virtchnl_static_assert_##X = (n)/((sizeof(struct X) == (n)) ? 1 : 0) }
286 #define VIRTCHNL_CHECK_UNION_LEN(n, X) enum virtchnl_static_asset_enum_##X \
287 { virtchnl_static_assert_##X = (n)/((sizeof(union X) == (n)) ? 1 : 0) }
289 /* Virtual channel message descriptor. This overlays the admin queue
290 * descriptor. All other data is passed in external buffers.
293 struct virtchnl_msg {
294 u8 pad[8]; /* AQ flags/opcode/len/retval fields */
296 /* avoid confusion with desc->opcode */
297 enum virtchnl_ops v_opcode;
299 /* ditto for desc->retval */
300 enum virtchnl_status_code v_retval;
301 u32 vfid; /* used by PF when sending to VF */
304 VIRTCHNL_CHECK_STRUCT_LEN(20, virtchnl_msg);
306 /* Message descriptions and data structures. */
308 /* VIRTCHNL_OP_VERSION
309 * VF posts its version number to the PF. PF responds with its version number
310 * in the same format, along with a return code.
311 * Reply from PF has its major/minor versions also in param0 and param1.
312 * If there is a major version mismatch, then the VF cannot operate.
313 * If there is a minor version mismatch, then the VF can operate but should
314 * add a warning to the system log.
316 * This enum element MUST always be specified as == 1, regardless of other
317 * changes in the API. The PF must always respond to this message without
318 * error regardless of version mismatch.
320 #define VIRTCHNL_VERSION_MAJOR 1
321 #define VIRTCHNL_VERSION_MINOR 1
322 #define VIRTCHNL_VERSION_MINOR_NO_VF_CAPS 0
324 struct virtchnl_version_info {
329 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_version_info);
331 #define VF_IS_V10(_v) (((_v)->major == 1) && ((_v)->minor == 0))
332 #define VF_IS_V11(_ver) (((_ver)->major == 1) && ((_ver)->minor == 1))
334 /* VIRTCHNL_OP_RESET_VF
335 * VF sends this request to PF with no parameters
336 * PF does NOT respond! VF driver must delay then poll VFGEN_RSTAT register
337 * until reset completion is indicated. The admin queue must be reinitialized
338 * after this operation.
340 * When reset is complete, PF must ensure that all queues in all VSIs associated
341 * with the VF are stopped, all queue configurations in the HMC are set to 0,
342 * and all MAC and VLAN filters (except the default MAC address) on all VSIs
346 /* VSI types that use VIRTCHNL interface for VF-PF communication. VSI_SRIOV
347 * vsi_type should always be 6 for backward compatibility. Add other fields
350 enum virtchnl_vsi_type {
351 VIRTCHNL_VSI_TYPE_INVALID = 0,
352 VIRTCHNL_VSI_SRIOV = 6,
355 /* VIRTCHNL_OP_GET_VF_RESOURCES
356 * Version 1.0 VF sends this request to PF with no parameters
357 * Version 1.1 VF sends this request to PF with u32 bitmap of its capabilities
358 * PF responds with an indirect message containing
359 * virtchnl_vf_resource and one or more
360 * virtchnl_vsi_resource structures.
363 struct virtchnl_vsi_resource {
367 /* see enum virtchnl_vsi_type */
370 u8 default_mac_addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
373 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
375 /* VF capability flags
376 * VIRTCHNL_VF_OFFLOAD_L2 flag is inclusive of base mode L2 offloads including
377 * TX/RX Checksum offloading and TSO for non-tunnelled packets.
379 #define VIRTCHNL_VF_OFFLOAD_L2 BIT(0)
380 #define VIRTCHNL_VF_OFFLOAD_IWARP BIT(1)
381 #define VIRTCHNL_VF_OFFLOAD_RSVD BIT(2)
382 #define VIRTCHNL_VF_OFFLOAD_RSS_AQ BIT(3)
383 #define VIRTCHNL_VF_OFFLOAD_RSS_REG BIT(4)
384 #define VIRTCHNL_VF_OFFLOAD_WB_ON_ITR BIT(5)
385 #define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES BIT(6)
386 /* used to negotiate communicating link speeds in Mbps */
387 #define VIRTCHNL_VF_CAP_ADV_LINK_SPEED BIT(7)
388 /* BIT(8) is reserved */
389 #define VIRTCHNL_VF_LARGE_NUM_QPAIRS BIT(9)
390 #define VIRTCHNL_VF_OFFLOAD_CRC BIT(10)
391 #define VIRTCHNL_VF_OFFLOAD_VLAN_V2 BIT(15)
392 #define VIRTCHNL_VF_OFFLOAD_VLAN BIT(16)
393 #define VIRTCHNL_VF_OFFLOAD_RX_POLLING BIT(17)
394 #define VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 BIT(18)
395 #define VIRTCHNL_VF_OFFLOAD_RSS_PF BIT(19)
396 #define VIRTCHNL_VF_OFFLOAD_ENCAP BIT(20)
397 #define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM BIT(21)
398 #define VIRTCHNL_VF_OFFLOAD_RX_ENCAP_CSUM BIT(22)
399 #define VIRTCHNL_VF_OFFLOAD_ADQ BIT(23)
400 #define VIRTCHNL_VF_OFFLOAD_ADQ_V2 BIT(24)
401 #define VIRTCHNL_VF_OFFLOAD_USO BIT(25)
402 #define VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC BIT(26)
403 #define VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF BIT(27)
404 #define VIRTCHNL_VF_OFFLOAD_FDIR_PF BIT(28)
405 #define VIRTCHNL_VF_OFFLOAD_QOS BIT(29)
406 #define VIRTCHNL_VF_CAP_DCF BIT(30)
407 /* BIT(31) is reserved */
409 #define VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \
410 VIRTCHNL_VF_OFFLOAD_VLAN | \
411 VIRTCHNL_VF_OFFLOAD_RSS_PF)
413 struct virtchnl_vf_resource {
423 struct virtchnl_vsi_resource vsi_res[1];
426 VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_vf_resource);
428 /* VIRTCHNL_OP_CONFIG_TX_QUEUE
429 * VF sends this message to set up parameters for one TX queue.
430 * External data buffer contains one instance of virtchnl_txq_info.
431 * PF configures requested queue and returns a status code.
434 /* Tx queue config info */
435 struct virtchnl_txq_info {
438 u16 ring_len; /* number of descriptors, multiple of 8 */
439 u16 headwb_enabled; /* deprecated with AVF 1.0 */
441 u64 dma_headwb_addr; /* deprecated with AVF 1.0 */
444 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_txq_info);
446 /* RX descriptor IDs (range from 0 to 63) */
447 enum virtchnl_rx_desc_ids {
448 VIRTCHNL_RXDID_0_16B_BASE = 0,
449 /* 32B_BASE and FLEX_SPLITQ share desc ids as default descriptors
450 * because they can be differentiated based on queue model; e.g. single
451 * queue model can only use 32B_BASE and split queue model can only use
452 * FLEX_SPLITQ. Having these as 1 allows them to be used as default
453 * descriptors without negotiation.
455 VIRTCHNL_RXDID_1_32B_BASE = 1,
456 VIRTCHNL_RXDID_1_FLEX_SPLITQ = 1,
457 VIRTCHNL_RXDID_2_FLEX_SQ_NIC = 2,
458 VIRTCHNL_RXDID_3_FLEX_SQ_SW = 3,
459 VIRTCHNL_RXDID_4_FLEX_SQ_NIC_VEB = 4,
460 VIRTCHNL_RXDID_5_FLEX_SQ_NIC_ACL = 5,
461 VIRTCHNL_RXDID_6_FLEX_SQ_NIC_2 = 6,
462 VIRTCHNL_RXDID_7_HW_RSVD = 7,
463 /* 9 through 15 are reserved */
464 VIRTCHNL_RXDID_16_COMMS_GENERIC = 16,
465 VIRTCHNL_RXDID_17_COMMS_AUX_VLAN = 17,
466 VIRTCHNL_RXDID_18_COMMS_AUX_IPV4 = 18,
467 VIRTCHNL_RXDID_19_COMMS_AUX_IPV6 = 19,
468 VIRTCHNL_RXDID_20_COMMS_AUX_FLOW = 20,
469 VIRTCHNL_RXDID_21_COMMS_AUX_TCP = 21,
470 /* 22 through 63 are reserved */
473 /* RX descriptor ID bitmasks */
474 enum virtchnl_rx_desc_id_bitmasks {
475 VIRTCHNL_RXDID_0_16B_BASE_M = BIT(VIRTCHNL_RXDID_0_16B_BASE),
476 VIRTCHNL_RXDID_1_32B_BASE_M = BIT(VIRTCHNL_RXDID_1_32B_BASE),
477 VIRTCHNL_RXDID_1_FLEX_SPLITQ_M = BIT(VIRTCHNL_RXDID_1_FLEX_SPLITQ),
478 VIRTCHNL_RXDID_2_FLEX_SQ_NIC_M = BIT(VIRTCHNL_RXDID_2_FLEX_SQ_NIC),
479 VIRTCHNL_RXDID_3_FLEX_SQ_SW_M = BIT(VIRTCHNL_RXDID_3_FLEX_SQ_SW),
480 VIRTCHNL_RXDID_4_FLEX_SQ_NIC_VEB_M = BIT(VIRTCHNL_RXDID_4_FLEX_SQ_NIC_VEB),
481 VIRTCHNL_RXDID_5_FLEX_SQ_NIC_ACL_M = BIT(VIRTCHNL_RXDID_5_FLEX_SQ_NIC_ACL),
482 VIRTCHNL_RXDID_6_FLEX_SQ_NIC_2_M = BIT(VIRTCHNL_RXDID_6_FLEX_SQ_NIC_2),
483 VIRTCHNL_RXDID_7_HW_RSVD_M = BIT(VIRTCHNL_RXDID_7_HW_RSVD),
484 /* 9 through 15 are reserved */
485 VIRTCHNL_RXDID_16_COMMS_GENERIC_M = BIT(VIRTCHNL_RXDID_16_COMMS_GENERIC),
486 VIRTCHNL_RXDID_17_COMMS_AUX_VLAN_M = BIT(VIRTCHNL_RXDID_17_COMMS_AUX_VLAN),
487 VIRTCHNL_RXDID_18_COMMS_AUX_IPV4_M = BIT(VIRTCHNL_RXDID_18_COMMS_AUX_IPV4),
488 VIRTCHNL_RXDID_19_COMMS_AUX_IPV6_M = BIT(VIRTCHNL_RXDID_19_COMMS_AUX_IPV6),
489 VIRTCHNL_RXDID_20_COMMS_AUX_FLOW_M = BIT(VIRTCHNL_RXDID_20_COMMS_AUX_FLOW),
490 VIRTCHNL_RXDID_21_COMMS_AUX_TCP_M = BIT(VIRTCHNL_RXDID_21_COMMS_AUX_TCP),
491 /* 22 through 63 are reserved */
494 /* VIRTCHNL_OP_CONFIG_RX_QUEUE
495 * VF sends this message to set up parameters for one RX queue.
496 * External data buffer contains one instance of virtchnl_rxq_info.
497 * PF configures requested queue and returns a status code. The
498 * crc_disable flag disables CRC stripping on the VF. Setting
499 * the crc_disable flag to 1 will disable CRC stripping for each
500 * queue in the VF where the flag is set. The VIRTCHNL_VF_OFFLOAD_CRC
501 * offload must have been set prior to sending this info or the PF
502 * will ignore the request. This flag should be set the same for
503 * all of the queues for a VF.
506 /* Rx queue config info */
507 struct virtchnl_rxq_info {
510 u32 ring_len; /* number of descriptors, multiple of 32 */
512 u16 splithdr_enabled; /* deprecated with AVF 1.0 */
516 /* see enum virtchnl_rx_desc_ids;
517 * only used when VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC is supported. Note
518 * that when the offload is not supported, the descriptor format aligns
519 * with VIRTCHNL_RXDID_1_32B_BASE.
525 /* see enum virtchnl_rx_hsplit; deprecated with AVF 1.0 */
530 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_rxq_info);
532 /* VIRTCHNL_OP_CONFIG_VSI_QUEUES
533 * VF sends this message to set parameters for active TX and RX queues
534 * associated with the specified VSI.
535 * PF configures queues and returns status.
536 * If the number of queues specified is greater than the number of queues
537 * associated with the VSI, an error is returned and no queues are configured.
538 * NOTE: The VF is not required to configure all queues in a single request.
539 * It may send multiple messages. PF drivers must correctly handle all VF
542 struct virtchnl_queue_pair_info {
543 /* NOTE: vsi_id and queue_id should be identical for both queues. */
544 struct virtchnl_txq_info txq;
545 struct virtchnl_rxq_info rxq;
548 VIRTCHNL_CHECK_STRUCT_LEN(64, virtchnl_queue_pair_info);
550 struct virtchnl_vsi_queue_config_info {
554 struct virtchnl_queue_pair_info qpair[1];
557 VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_vsi_queue_config_info);
559 /* VIRTCHNL_OP_REQUEST_QUEUES
560 * VF sends this message to request the PF to allocate additional queues to
561 * this VF. Each VF gets a guaranteed number of queues on init but asking for
562 * additional queues must be negotiated. This is a best effort request as it
563 * is possible the PF does not have enough queues left to support the request.
564 * If the PF cannot support the number requested it will respond with the
565 * maximum number it is able to support. If the request is successful, PF will
566 * then reset the VF to institute required changes.
569 /* VF resource request */
570 struct virtchnl_vf_res_request {
574 /* VIRTCHNL_OP_CONFIG_IRQ_MAP
575 * VF uses this message to map vectors to queues.
576 * The rxq_map and txq_map fields are bitmaps used to indicate which queues
577 * are to be associated with the specified vector.
578 * The "other" causes are always mapped to vector 0. The VF may not request
579 * that vector 0 be used for traffic.
580 * PF configures interrupt mapping and returns status.
581 * NOTE: due to hardware requirements, all active queues (both TX and RX)
582 * should be mapped to interrupts, even if the driver intends to operate
583 * only in polling mode. In this case the interrupt may be disabled, but
584 * the ITR timer will still run to trigger writebacks.
586 struct virtchnl_vector_map {
595 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_vector_map);
597 struct virtchnl_irq_map_info {
599 struct virtchnl_vector_map vecmap[1];
602 VIRTCHNL_CHECK_STRUCT_LEN(14, virtchnl_irq_map_info);
604 /* VIRTCHNL_OP_ENABLE_QUEUES
605 * VIRTCHNL_OP_DISABLE_QUEUES
606 * VF sends these message to enable or disable TX/RX queue pairs.
607 * The queues fields are bitmaps indicating which queues to act upon.
608 * (Currently, we only support 16 queues per VF, but we make the field
609 * u32 to allow for expansion.)
610 * PF performs requested action and returns status.
611 * NOTE: The VF is not required to enable/disable all queues in a single
612 * request. It may send multiple messages.
613 * PF drivers must correctly handle all VF requests.
615 struct virtchnl_queue_select {
622 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_select);
624 /* VIRTCHNL_OP_GET_MAX_RSS_QREGION
626 * if VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
627 * then this op must be supported.
629 * VF sends this message in order to query the max RSS queue region
630 * size supported by PF, when VIRTCHNL_VF_LARGE_NUM_QPAIRS is enabled.
631 * This information should be used when configuring the RSS LUT and/or
632 * configuring queue region based filters.
634 * The maximum RSS queue region is 2^qregion_width. So, a qregion_width
635 * of 6 would inform the VF that the PF supports a maximum RSS queue region
638 * A queue region represents a range of queues that can be used to configure
639 * a RSS LUT. For example, if a VF is given 64 queues, but only a max queue
640 * region size of 16 (i.e. 2^qregion_width = 16) then it will only be able
641 * to configure the RSS LUT with queue indices from 0 to 15. However, other
642 * filters can be used to direct packets to queues >15 via specifying a queue
643 * base/offset and queue region width.
645 struct virtchnl_max_rss_qregion {
651 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_max_rss_qregion);
653 /* VIRTCHNL_OP_ADD_ETH_ADDR
654 * VF sends this message in order to add one or more unicast or multicast
655 * address filters for the specified VSI.
656 * PF adds the filters and returns status.
659 /* VIRTCHNL_OP_DEL_ETH_ADDR
660 * VF sends this message in order to remove one or more unicast or multicast
661 * filters for the specified VSI.
662 * PF removes the filters and returns status.
665 /* VIRTCHNL_ETHER_ADDR_LEGACY
666 * Prior to adding the @type member to virtchnl_ether_addr, there were 2 pad
667 * bytes. Moving forward all VF drivers should not set type to
668 * VIRTCHNL_ETHER_ADDR_LEGACY. This is only here to not break previous/legacy
669 * behavior. The control plane function (i.e. PF) can use a best effort method
670 * of tracking the primary/device unicast in this case, but there is no
671 * guarantee and functionality depends on the implementation of the PF.
674 /* VIRTCHNL_ETHER_ADDR_PRIMARY
675 * All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_PRIMARY for the
676 * primary/device unicast MAC address filter for VIRTCHNL_OP_ADD_ETH_ADDR and
677 * VIRTCHNL_OP_DEL_ETH_ADDR. This allows for the underlying control plane
678 * function (i.e. PF) to accurately track and use this MAC address for
679 * displaying on the host and for VM/function reset.
682 /* VIRTCHNL_ETHER_ADDR_EXTRA
683 * All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_EXTRA for any extra
684 * unicast and/or multicast filters that are being added/deleted via
685 * VIRTCHNL_OP_DEL_ETH_ADDR/VIRTCHNL_OP_ADD_ETH_ADDR respectively.
687 struct virtchnl_ether_addr {
688 u8 addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
690 #define VIRTCHNL_ETHER_ADDR_LEGACY 0
691 #define VIRTCHNL_ETHER_ADDR_PRIMARY 1
692 #define VIRTCHNL_ETHER_ADDR_EXTRA 2
693 #define VIRTCHNL_ETHER_ADDR_TYPE_MASK 3 /* first two bits of type are valid */
697 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_ether_addr);
699 struct virtchnl_ether_addr_list {
702 struct virtchnl_ether_addr list[1];
705 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_ether_addr_list);
707 /* VIRTCHNL_OP_ADD_VLAN
708 * VF sends this message to add one or more VLAN tag filters for receives.
709 * PF adds the filters and returns status.
710 * If a port VLAN is configured by the PF, this operation will return an
714 /* VIRTCHNL_OP_DEL_VLAN
715 * VF sends this message to remove one or more VLAN tag filters for receives.
716 * PF removes the filters and returns status.
717 * If a port VLAN is configured by the PF, this operation will return an
721 struct virtchnl_vlan_filter_list {
727 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_vlan_filter_list);
729 /* This enum is used for all of the VIRTCHNL_VF_OFFLOAD_VLAN_V2_CAPS related
730 * structures and opcodes.
732 * VIRTCHNL_VLAN_UNSUPPORTED - This field is not supported and if a VF driver
733 * populates it the PF should return VIRTCHNL_STATUS_ERR_NOT_SUPPORTED.
735 * VIRTCHNL_VLAN_ETHERTYPE_8100 - This field supports 0x8100 ethertype.
736 * VIRTCHNL_VLAN_ETHERTYPE_88A8 - This field supports 0x88A8 ethertype.
737 * VIRTCHNL_VLAN_ETHERTYPE_9100 - This field supports 0x9100 ethertype.
739 * VIRTCHNL_VLAN_ETHERTYPE_AND - Used when multiple ethertypes can be supported
740 * by the PF concurrently. For example, if the PF can support
741 * VIRTCHNL_VLAN_ETHERTYPE_8100 AND VIRTCHNL_VLAN_ETHERTYPE_88A8 filters it
742 * would OR the following bits:
744 * VIRTHCNL_VLAN_ETHERTYPE_8100 |
745 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
746 * VIRTCHNL_VLAN_ETHERTYPE_AND;
748 * The VF would interpret this as VLAN filtering can be supported on both 0x8100
749 * and 0x88A8 VLAN ethertypes.
751 * VIRTCHNL_ETHERTYPE_XOR - Used when only a single ethertype can be supported
752 * by the PF concurrently. For example if the PF can support
753 * VIRTCHNL_VLAN_ETHERTYPE_8100 XOR VIRTCHNL_VLAN_ETHERTYPE_88A8 stripping
754 * offload it would OR the following bits:
756 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
757 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
758 * VIRTCHNL_VLAN_ETHERTYPE_XOR;
760 * The VF would interpret this as VLAN stripping can be supported on either
761 * 0x8100 or 0x88a8 VLAN ethertypes. So when requesting VLAN stripping via
762 * VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 the specified ethertype will override
763 * the previously set value.
765 * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1 - Used to tell the VF to insert and/or
766 * strip the VLAN tag using the L2TAG1 field of the Tx/Rx descriptors.
768 * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 - Used to tell the VF to insert hardware
769 * offloaded VLAN tags using the L2TAG2 field of the Tx descriptor.
771 * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 - Used to tell the VF to strip hardware
772 * offloaded VLAN tags using the L2TAG2_2 field of the Rx descriptor.
774 * VIRTCHNL_VLAN_PRIO - This field supports VLAN priority bits. This is used for
775 * VLAN filtering if the underlying PF supports it.
777 * VIRTCHNL_VLAN_TOGGLE_ALLOWED - This field is used to say whether a
778 * certain VLAN capability can be toggled. For example if the underlying PF/CP
779 * allows the VF to toggle VLAN filtering, stripping, and/or insertion it should
780 * set this bit along with the supported ethertypes.
782 enum virtchnl_vlan_support {
783 VIRTCHNL_VLAN_UNSUPPORTED = 0,
784 VIRTCHNL_VLAN_ETHERTYPE_8100 = 0x00000001,
785 VIRTCHNL_VLAN_ETHERTYPE_88A8 = 0x00000002,
786 VIRTCHNL_VLAN_ETHERTYPE_9100 = 0x00000004,
787 VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1 = 0x00000100,
788 VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 = 0x00000200,
789 VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2_2 = 0x00000400,
790 VIRTCHNL_VLAN_PRIO = 0x01000000,
791 VIRTCHNL_VLAN_FILTER_MASK = 0x10000000,
792 VIRTCHNL_VLAN_ETHERTYPE_AND = 0x20000000,
793 VIRTCHNL_VLAN_ETHERTYPE_XOR = 0x40000000,
794 VIRTCHNL_VLAN_TOGGLE = 0x80000000
797 /* This structure is used as part of the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS
798 * for filtering, insertion, and stripping capabilities.
800 * If only outer capabilities are supported (for filtering, insertion, and/or
801 * stripping) then this refers to the outer most or single VLAN from the VF's
804 * If only inner capabilities are supported (for filtering, insertion, and/or
805 * stripping) then this refers to the outer most or single VLAN from the VF's
806 * perspective. Functionally this is the same as if only outer capabilities are
807 * supported. The VF driver is just forced to use the inner fields when
808 * adding/deleting filters and enabling/disabling offloads (if supported).
810 * If both outer and inner capabilities are supported (for filtering, insertion,
811 * and/or stripping) then outer refers to the outer most or single VLAN and
812 * inner refers to the second VLAN, if it exists, in the packet.
814 * There is no support for tunneled VLAN offloads, so outer or inner are never
815 * referring to a tunneled packet from the VF's perspective.
817 struct virtchnl_vlan_supported_caps {
822 /* The PF populates these fields based on the supported VLAN filtering. If a
823 * field is VIRTCHNL_VLAN_UNSUPPORTED then it's not supported and the PF will
824 * reject any VIRTCHNL_OP_ADD_VLAN_V2 or VIRTCHNL_OP_DEL_VLAN_V2 messages using
825 * the unsupported fields.
827 * Also, a VF is only allowed to toggle its VLAN filtering setting if the
828 * VIRTCHNL_VLAN_TOGGLE bit is set.
830 * The ethertype(s) specified in the ethertype_init field are the ethertypes
831 * enabled for VLAN filtering. VLAN filtering in this case refers to the outer
832 * most VLAN from the VF's perspective. If both inner and outer filtering are
833 * allowed then ethertype_init only refers to the outer most VLAN as only
834 * VLAN ethertype supported for inner VLAN filtering is
835 * VIRTCHNL_VLAN_ETHERTYPE_8100. By default, inner VLAN filtering is disabled
836 * when both inner and outer filtering are allowed.
838 * The max_filters field tells the VF how many VLAN filters it's allowed to have
839 * at any one time. If it exceeds this amount and tries to add another filter,
840 * then the request will be rejected by the PF. To prevent failures, the VF
841 * should keep track of how many VLAN filters it has added and not attempt to
842 * add more than max_filters.
844 struct virtchnl_vlan_filtering_caps {
845 struct virtchnl_vlan_supported_caps filtering_support;
851 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vlan_filtering_caps);
853 /* This enum is used for the virtchnl_vlan_offload_caps structure to specify
854 * if the PF supports a different ethertype for stripping and insertion.
856 * VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION - The ethertype(s) specified
857 * for stripping affect the ethertype(s) specified for insertion and visa versa
858 * as well. If the VF tries to configure VLAN stripping via
859 * VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 with VIRTCHNL_VLAN_ETHERTYPE_8100 then
860 * that will be the ethertype for both stripping and insertion.
862 * VIRTCHNL_ETHERTYPE_MATCH_NOT_REQUIRED - The ethertype(s) specified for
863 * stripping do not affect the ethertype(s) specified for insertion and visa
866 enum virtchnl_vlan_ethertype_match {
867 VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION = 0,
868 VIRTCHNL_ETHERTYPE_MATCH_NOT_REQUIRED = 1,
871 /* The PF populates these fields based on the supported VLAN offloads. If a
872 * field is VIRTCHNL_VLAN_UNSUPPORTED then it's not supported and the PF will
873 * reject any VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 or
874 * VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 messages using the unsupported fields.
876 * Also, a VF is only allowed to toggle its VLAN offload setting if the
877 * VIRTCHNL_VLAN_TOGGLE_ALLOWED bit is set.
879 * The VF driver needs to be aware of how the tags are stripped by hardware and
880 * inserted by the VF driver based on the level of offload support. The PF will
881 * populate these fields based on where the VLAN tags are expected to be
882 * offloaded via the VIRTHCNL_VLAN_TAG_LOCATION_* bits. The VF will need to
883 * interpret these fields. See the definition of the
884 * VIRTCHNL_VLAN_TAG_LOCATION_* bits above the virtchnl_vlan_support
887 struct virtchnl_vlan_offload_caps {
888 struct virtchnl_vlan_supported_caps stripping_support;
889 struct virtchnl_vlan_supported_caps insertion_support;
895 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_vlan_offload_caps);
897 /* VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS
898 * VF sends this message to determine its VLAN capabilities.
900 * PF will mark which capabilities it supports based on hardware support and
901 * current configuration. For example, if a port VLAN is configured the PF will
902 * not allow outer VLAN filtering, stripping, or insertion to be configured so
903 * it will block these features from the VF.
905 * The VF will need to cross reference its capabilities with the PFs
906 * capabilities in the response message from the PF to determine the VLAN
909 struct virtchnl_vlan_caps {
910 struct virtchnl_vlan_filtering_caps filtering;
911 struct virtchnl_vlan_offload_caps offloads;
914 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_vlan_caps);
916 struct virtchnl_vlan {
917 u16 tci; /* tci[15:13] = PCP and tci[11:0] = VID */
918 u16 tci_mask; /* only valid if VIRTCHNL_VLAN_FILTER_MASK set in
921 u16 tpid; /* 0x8100, 0x88a8, etc. and only type(s) set in
922 * filtering caps. Note that tpid here does not refer to
923 * VIRTCHNL_VLAN_ETHERTYPE_*, but it refers to the
924 * actual 2-byte VLAN TPID
929 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_vlan);
931 struct virtchnl_vlan_filter {
932 struct virtchnl_vlan inner;
933 struct virtchnl_vlan outer;
937 VIRTCHNL_CHECK_STRUCT_LEN(32, virtchnl_vlan_filter);
939 /* VIRTCHNL_OP_ADD_VLAN_V2
940 * VIRTCHNL_OP_DEL_VLAN_V2
942 * VF sends these messages to add/del one or more VLAN tag filters for Rx
945 * The PF attempts to add the filters and returns status.
947 * The VF should only ever attempt to add/del virtchnl_vlan_filter(s) using the
948 * supported fields negotiated via VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS.
950 struct virtchnl_vlan_filter_list_v2 {
954 struct virtchnl_vlan_filter filters[1];
957 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_vlan_filter_list_v2);
959 /* VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2
960 * VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2
961 * VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2
962 * VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2
964 * VF sends this message to enable or disable VLAN stripping or insertion. It
965 * also needs to specify an ethertype. The VF knows which VLAN ethertypes are
966 * allowed and whether or not it's allowed to enable/disable the specific
967 * offload via the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS message. The VF needs to
968 * parse the virtchnl_vlan_caps.offloads fields to determine which offload
969 * messages are allowed.
971 * For example, if the PF populates the virtchnl_vlan_caps.offloads in the
972 * following manner the VF will be allowed to enable and/or disable 0x8100 inner
973 * VLAN insertion and/or stripping via the opcodes listed above. Inner in this
974 * case means the outer most or single VLAN from the VF's perspective. This is
975 * because no outer offloads are supported. See the comments above the
976 * virtchnl_vlan_supported_caps structure for more details.
978 * virtchnl_vlan_caps.offloads.stripping_support.inner =
979 * VIRTCHNL_VLAN_TOGGLE |
980 * VIRTCHNL_VLAN_ETHERTYPE_8100;
982 * virtchnl_vlan_caps.offloads.insertion_support.inner =
983 * VIRTCHNL_VLAN_TOGGLE |
984 * VIRTCHNL_VLAN_ETHERTYPE_8100;
986 * In order to enable inner (again note that in this case inner is the outer
987 * most or single VLAN from the VF's perspective) VLAN stripping for 0x8100
988 * VLANs, the VF would populate the virtchnl_vlan_setting structure in the
989 * following manner and send the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 message.
991 * virtchnl_vlan_setting.inner_ethertype_setting =
992 * VIRTCHNL_VLAN_ETHERTYPE_8100;
994 * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on
997 * The reason that VLAN TPID(s) are not being used for the
998 * outer_ethertype_setting and inner_ethertype_setting fields is because it's
999 * possible a device could support VLAN insertion and/or stripping offload on
1000 * multiple ethertypes concurrently, so this method allows a VF to request
1001 * multiple ethertypes in one message using the virtchnl_vlan_support
1004 * For example, if the PF populates the virtchnl_vlan_caps.offloads in the
1005 * following manner the VF will be allowed to enable 0x8100 and 0x88a8 outer
1006 * VLAN insertion and stripping simultaneously. The
1007 * virtchnl_vlan_caps.offloads.ethertype_match field will also have to be
1008 * populated based on what the PF can support.
1010 * virtchnl_vlan_caps.offloads.stripping_support.outer =
1011 * VIRTCHNL_VLAN_TOGGLE |
1012 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1013 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
1014 * VIRTCHNL_VLAN_ETHERTYPE_AND;
1016 * virtchnl_vlan_caps.offloads.insertion_support.outer =
1017 * VIRTCHNL_VLAN_TOGGLE |
1018 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1019 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
1020 * VIRTCHNL_VLAN_ETHERTYPE_AND;
1022 * In order to enable outer VLAN stripping for 0x8100 and 0x88a8 VLANs, the VF
1023 * would populate the virthcnl_vlan_offload_structure in the following manner
1024 * and send the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 message.
1026 * virtchnl_vlan_setting.outer_ethertype_setting =
1027 * VIRTHCNL_VLAN_ETHERTYPE_8100 |
1028 * VIRTHCNL_VLAN_ETHERTYPE_88A8;
1030 * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on
1033 * There is also the case where a PF and the underlying hardware can support
1034 * VLAN offloads on multiple ethertypes, but not concurrently. For example, if
1035 * the PF populates the virtchnl_vlan_caps.offloads in the following manner the
1036 * VF will be allowed to enable and/or disable 0x8100 XOR 0x88a8 outer VLAN
1037 * offloads. The ethertypes must match for stripping and insertion.
1039 * virtchnl_vlan_caps.offloads.stripping_support.outer =
1040 * VIRTCHNL_VLAN_TOGGLE |
1041 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1042 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
1043 * VIRTCHNL_VLAN_ETHERTYPE_XOR;
1045 * virtchnl_vlan_caps.offloads.insertion_support.outer =
1046 * VIRTCHNL_VLAN_TOGGLE |
1047 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1048 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
1049 * VIRTCHNL_VLAN_ETHERTYPE_XOR;
1051 * virtchnl_vlan_caps.offloads.ethertype_match =
1052 * VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION;
1054 * In order to enable outer VLAN stripping for 0x88a8 VLANs, the VF would
1055 * populate the virtchnl_vlan_setting structure in the following manner and send
1056 * the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2. Also, this will change the
1057 * ethertype for VLAN insertion if it's enabled. So, for completeness, a
1058 * VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 with the same ethertype should be sent.
1060 * virtchnl_vlan_setting.outer_ethertype_setting = VIRTHCNL_VLAN_ETHERTYPE_88A8;
1062 * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on
1065 * VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2
1066 * VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2
1068 * VF sends this message to enable or disable VLAN filtering. It also needs to
1069 * specify an ethertype. The VF knows which VLAN ethertypes are allowed and
1070 * whether or not it's allowed to enable/disable filtering via the
1071 * VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS message. The VF needs to
1072 * parse the virtchnl_vlan_caps.filtering fields to determine which, if any,
1073 * filtering messages are allowed.
1075 * For example, if the PF populates the virtchnl_vlan_caps.filtering in the
1076 * following manner the VF will be allowed to enable/disable 0x8100 and 0x88a8
1077 * outer VLAN filtering together. Note, that the VIRTCHNL_VLAN_ETHERTYPE_AND
1078 * means that all filtering ethertypes will to be enabled and disabled together
1079 * regardless of the request from the VF. This means that the underlying
1080 * hardware only supports VLAN filtering for all VLAN the specified ethertypes
1083 * virtchnl_vlan_caps.filtering.filtering_support.outer =
1084 * VIRTCHNL_VLAN_TOGGLE |
1085 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1086 * VIRTHCNL_VLAN_ETHERTYPE_88A8 |
1087 * VIRTCHNL_VLAN_ETHERTYPE_9100 |
1088 * VIRTCHNL_VLAN_ETHERTYPE_AND;
1090 * In order to enable outer VLAN filtering for 0x88a8 and 0x8100 VLANs (0x9100
1091 * VLANs aren't supported by the VF driver), the VF would populate the
1092 * virtchnl_vlan_setting structure in the following manner and send the
1093 * VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2. The same message format would be used
1094 * to disable outer VLAN filtering for 0x88a8 and 0x8100 VLANs, but the
1095 * VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2 opcode is used.
1097 * virtchnl_vlan_setting.outer_ethertype_setting =
1098 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1099 * VIRTCHNL_VLAN_ETHERTYPE_88A8;
1102 struct virtchnl_vlan_setting {
1103 u32 outer_ethertype_setting;
1104 u32 inner_ethertype_setting;
1109 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vlan_setting);
1111 /* VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE
1112 * VF sends VSI id and flags.
1113 * PF returns status code in retval.
1114 * Note: we assume that broadcast accept mode is always enabled.
1116 struct virtchnl_promisc_info {
1121 VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_promisc_info);
1123 #define FLAG_VF_UNICAST_PROMISC 0x00000001
1124 #define FLAG_VF_MULTICAST_PROMISC 0x00000002
1126 /* VIRTCHNL_OP_GET_STATS
1127 * VF sends this message to request stats for the selected VSI. VF uses
1128 * the virtchnl_queue_select struct to specify the VSI. The queue_id
1129 * field is ignored by the PF.
1131 * PF replies with struct virtchnl_eth_stats in an external buffer.
1134 struct virtchnl_eth_stats {
1135 u64 rx_bytes; /* received bytes */
1136 u64 rx_unicast; /* received unicast pkts */
1137 u64 rx_multicast; /* received multicast pkts */
1138 u64 rx_broadcast; /* received broadcast pkts */
1140 u64 rx_unknown_protocol;
1141 u64 tx_bytes; /* transmitted bytes */
1142 u64 tx_unicast; /* transmitted unicast pkts */
1143 u64 tx_multicast; /* transmitted multicast pkts */
1144 u64 tx_broadcast; /* transmitted broadcast pkts */
1149 /* VIRTCHNL_OP_CONFIG_RSS_KEY
1150 * VIRTCHNL_OP_CONFIG_RSS_LUT
1151 * VF sends these messages to configure RSS. Only supported if both PF
1152 * and VF drivers set the VIRTCHNL_VF_OFFLOAD_RSS_PF bit during
1153 * configuration negotiation. If this is the case, then the RSS fields in
1154 * the VF resource struct are valid.
1155 * Both the key and LUT are initialized to 0 by the PF, meaning that
1156 * RSS is effectively disabled until set up by the VF.
1158 struct virtchnl_rss_key {
1161 u8 key[1]; /* RSS hash key, packed bytes */
1164 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_rss_key);
1166 struct virtchnl_rss_lut {
1169 u8 lut[1]; /* RSS lookup table */
1172 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_rss_lut);
1174 /* VIRTCHNL_OP_GET_RSS_HENA_CAPS
1175 * VIRTCHNL_OP_SET_RSS_HENA
1176 * VF sends these messages to get and set the hash filter enable bits for RSS.
1177 * By default, the PF sets these to all possible traffic types that the
1178 * hardware supports. The VF can query this value if it wants to change the
1179 * traffic types that are hashed by the hardware.
1181 struct virtchnl_rss_hena {
1185 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_rss_hena);
1187 /* Type of RSS algorithm */
1188 enum virtchnl_rss_algorithm {
1189 VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC = 0,
1190 VIRTCHNL_RSS_ALG_XOR_ASYMMETRIC = 1,
1191 VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC = 2,
1192 VIRTCHNL_RSS_ALG_XOR_SYMMETRIC = 3,
1195 /* This is used by PF driver to enforce how many channels can be supported.
1196 * When ADQ_V2 capability is negotiated, it will allow 16 channels otherwise
1197 * PF driver will allow only max 4 channels
1199 #define VIRTCHNL_MAX_ADQ_CHANNELS 4
1200 #define VIRTCHNL_MAX_ADQ_V2_CHANNELS 16
1202 /* VIRTCHNL_OP_ENABLE_CHANNELS
1203 * VIRTCHNL_OP_DISABLE_CHANNELS
1204 * VF sends these messages to enable or disable channels based on
1205 * the user specified queue count and queue offset for each traffic class.
1206 * This struct encompasses all the information that the PF needs from
1207 * VF to create a channel.
1209 struct virtchnl_channel_info {
1210 u16 count; /* number of queues in a channel */
1211 u16 offset; /* queues in a channel start from 'offset' */
1216 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_channel_info);
1218 struct virtchnl_tc_info {
1221 struct virtchnl_channel_info list[1];
1224 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_tc_info);
1226 /* VIRTCHNL_ADD_CLOUD_FILTER
1227 * VIRTCHNL_DEL_CLOUD_FILTER
1228 * VF sends these messages to add or delete a cloud filter based on the
1229 * user specified match and action filters. These structures encompass
1230 * all the information that the PF needs from the VF to add/delete a
1234 struct virtchnl_l4_spec {
1235 u8 src_mac[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
1236 u8 dst_mac[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
1237 /* vlan_prio is part of this 16 bit field even from OS perspective
1238 * vlan_id:12 is actual vlan_id, then vlanid:bit14..12 is vlan_prio
1239 * in future, when decided to offload vlan_prio, pass that information
1240 * as part of the "vlan_id" field, Bit14..12
1243 __be16 pad; /* reserved for future use */
1250 VIRTCHNL_CHECK_STRUCT_LEN(52, virtchnl_l4_spec);
1252 union virtchnl_flow_spec {
1253 struct virtchnl_l4_spec tcp_spec;
1254 u8 buffer[128]; /* reserved for future use */
1257 VIRTCHNL_CHECK_UNION_LEN(128, virtchnl_flow_spec);
1259 enum virtchnl_action {
1261 VIRTCHNL_ACTION_DROP = 0,
1262 VIRTCHNL_ACTION_TC_REDIRECT,
1263 VIRTCHNL_ACTION_PASSTHRU,
1264 VIRTCHNL_ACTION_QUEUE,
1265 VIRTCHNL_ACTION_Q_REGION,
1266 VIRTCHNL_ACTION_MARK,
1267 VIRTCHNL_ACTION_COUNT,
1270 enum virtchnl_flow_type {
1272 VIRTCHNL_TCP_V4_FLOW = 0,
1273 VIRTCHNL_TCP_V6_FLOW,
1274 VIRTCHNL_UDP_V4_FLOW,
1275 VIRTCHNL_UDP_V6_FLOW,
1278 struct virtchnl_filter {
1279 union virtchnl_flow_spec data;
1280 union virtchnl_flow_spec mask;
1282 /* see enum virtchnl_flow_type */
1285 /* see enum virtchnl_action */
1291 VIRTCHNL_CHECK_STRUCT_LEN(272, virtchnl_filter);
1293 struct virtchnl_shaper_bw {
1299 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_shaper_bw);
1301 /* VIRTCHNL_OP_DCF_GET_VSI_MAP
1302 * VF sends this message to get VSI mapping table.
1303 * PF responds with an indirect message containing VF's
1305 * The index of vf_vsi array is the logical VF ID, the
1306 * value of vf_vsi array is the VF's HW VSI ID with its
1307 * valid configuration.
1309 struct virtchnl_dcf_vsi_map {
1310 u16 pf_vsi; /* PF's HW VSI ID */
1311 u16 num_vfs; /* The actual number of VFs allocated */
1312 #define VIRTCHNL_DCF_VF_VSI_ID_S 0
1313 #define VIRTCHNL_DCF_VF_VSI_ID_M (0xFFF << VIRTCHNL_DCF_VF_VSI_ID_S)
1314 #define VIRTCHNL_DCF_VF_VSI_VALID BIT(15)
1318 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_dcf_vsi_map);
1320 #define PKG_NAME_SIZE 32
1323 struct pkg_version {
1330 VIRTCHNL_CHECK_STRUCT_LEN(4, pkg_version);
1332 struct virtchnl_pkg_info {
1333 struct pkg_version pkg_ver;
1335 char pkg_name[PKG_NAME_SIZE];
1339 VIRTCHNL_CHECK_STRUCT_LEN(48, virtchnl_pkg_info);
1341 /* VIRTCHNL_OP_DCF_VLAN_OFFLOAD
1342 * DCF negotiates the VIRTCHNL_VF_OFFLOAD_VLAN_V2 capability firstly to get
1343 * the double VLAN configuration, then DCF sends this message to configure the
1344 * outer or inner VLAN offloads (insertion and strip) for the target VF.
1346 struct virtchnl_dcf_vlan_offload {
1350 #define VIRTCHNL_DCF_VLAN_TYPE_S 0
1351 #define VIRTCHNL_DCF_VLAN_TYPE_M \
1352 (0x1 << VIRTCHNL_DCF_VLAN_TYPE_S)
1353 #define VIRTCHNL_DCF_VLAN_TYPE_INNER 0x0
1354 #define VIRTCHNL_DCF_VLAN_TYPE_OUTER 0x1
1355 #define VIRTCHNL_DCF_VLAN_INSERT_MODE_S 1
1356 #define VIRTCHNL_DCF_VLAN_INSERT_MODE_M \
1357 (0x7 << VIRTCHNL_DCF_VLAN_INSERT_MODE_S)
1358 #define VIRTCHNL_DCF_VLAN_INSERT_DISABLE 0x1
1359 #define VIRTCHNL_DCF_VLAN_INSERT_PORT_BASED 0x2
1360 #define VIRTCHNL_DCF_VLAN_INSERT_VIA_TX_DESC 0x3
1361 #define VIRTCHNL_DCF_VLAN_STRIP_MODE_S 4
1362 #define VIRTCHNL_DCF_VLAN_STRIP_MODE_M \
1363 (0x7 << VIRTCHNL_DCF_VLAN_STRIP_MODE_S)
1364 #define VIRTCHNL_DCF_VLAN_STRIP_DISABLE 0x1
1365 #define VIRTCHNL_DCF_VLAN_STRIP_ONLY 0x2
1366 #define VIRTCHNL_DCF_VLAN_STRIP_INTO_RX_DESC 0x3
1371 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_dcf_vlan_offload);
1373 struct virtchnl_dcf_bw_cfg {
1375 #define VIRTCHNL_DCF_BW_CIR BIT(0)
1376 #define VIRTCHNL_DCF_BW_PIR BIT(1)
1379 enum virtchnl_bw_limit_type type;
1381 struct virtchnl_shaper_bw shaper;
1386 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_dcf_bw_cfg);
1388 /* VIRTCHNL_OP_DCF_CONFIG_BW
1389 * VF send this message to set the bandwidth configuration of each
1390 * TC with a specific vf id. The flag node_type is to indicate that
1391 * this message is to configure VSI node or TC node bandwidth.
1393 struct virtchnl_dcf_bw_cfg_list {
1396 #define VIRTCHNL_DCF_TARGET_TC_BW 0
1397 #define VIRTCHNL_DCF_TARGET_VF_BW 1
1399 struct virtchnl_dcf_bw_cfg cfg[1];
1402 VIRTCHNL_CHECK_STRUCT_LEN(44, virtchnl_dcf_bw_cfg_list);
1404 struct virtchnl_supported_rxdids {
1405 /* see enum virtchnl_rx_desc_id_bitmasks */
1406 u64 supported_rxdids;
1409 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_supported_rxdids);
1411 /* VIRTCHNL_OP_EVENT
1412 * PF sends this message to inform the VF driver of events that may affect it.
1413 * No direct response is expected from the VF, though it may generate other
1414 * messages in response to this one.
1416 enum virtchnl_event_codes {
1417 VIRTCHNL_EVENT_UNKNOWN = 0,
1418 VIRTCHNL_EVENT_LINK_CHANGE,
1419 VIRTCHNL_EVENT_RESET_IMPENDING,
1420 VIRTCHNL_EVENT_PF_DRIVER_CLOSE,
1421 VIRTCHNL_EVENT_DCF_VSI_MAP_UPDATE,
1424 #define PF_EVENT_SEVERITY_INFO 0
1425 #define PF_EVENT_SEVERITY_ATTENTION 1
1426 #define PF_EVENT_SEVERITY_ACTION_REQUIRED 2
1427 #define PF_EVENT_SEVERITY_CERTAIN_DOOM 255
1429 struct virtchnl_pf_event {
1430 /* see enum virtchnl_event_codes */
1433 /* If the PF driver does not support the new speed reporting
1434 * capabilities then use link_event else use link_event_adv to
1435 * get the speed and link information. The ability to understand
1436 * new speeds is indicated by setting the capability flag
1437 * VIRTCHNL_VF_CAP_ADV_LINK_SPEED in vf_cap_flags parameter
1438 * in virtchnl_vf_resource struct and can be used to determine
1439 * which link event struct to use below.
1442 enum virtchnl_link_speed link_speed;
1446 /* link_speed provided in Mbps */
1459 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_pf_event);
1462 /* VF reset states - these are written into the RSTAT register:
1463 * VFGEN_RSTAT on the VF
1464 * When the PF initiates a reset, it writes 0
1465 * When the reset is complete, it writes 1
1466 * When the PF detects that the VF has recovered, it writes 2
1467 * VF checks this register periodically to determine if a reset has occurred,
1468 * then polls it to know when the reset is complete.
1469 * If either the PF or VF reads the register while the hardware
1470 * is in a reset state, it will return DEADBEEF, which, when masked
1473 enum virtchnl_vfr_states {
1474 VIRTCHNL_VFR_INPROGRESS = 0,
1475 VIRTCHNL_VFR_COMPLETED,
1476 VIRTCHNL_VFR_VFACTIVE,
1479 #define VIRTCHNL_MAX_NUM_PROTO_HDRS 32
1480 #define PROTO_HDR_SHIFT 5
1481 #define PROTO_HDR_FIELD_START(proto_hdr_type) \
1482 (proto_hdr_type << PROTO_HDR_SHIFT)
1483 #define PROTO_HDR_FIELD_MASK ((1UL << PROTO_HDR_SHIFT) - 1)
1485 /* VF use these macros to configure each protocol header.
1486 * Specify which protocol headers and protocol header fields base on
1487 * virtchnl_proto_hdr_type and virtchnl_proto_hdr_field.
1488 * @param hdr: a struct of virtchnl_proto_hdr
1489 * @param hdr_type: ETH/IPV4/TCP, etc
1490 * @param field: SRC/DST/TEID/SPI, etc
1492 #define VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, field) \
1493 ((hdr)->field_selector |= BIT((field) & PROTO_HDR_FIELD_MASK))
1494 #define VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, field) \
1495 ((hdr)->field_selector &= ~BIT((field) & PROTO_HDR_FIELD_MASK))
1496 #define VIRTCHNL_TEST_PROTO_HDR_FIELD(hdr, val) \
1497 ((hdr)->field_selector & BIT((val) & PROTO_HDR_FIELD_MASK))
1498 #define VIRTCHNL_GET_PROTO_HDR_FIELD(hdr) ((hdr)->field_selector)
1500 #define VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \
1501 (VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, \
1502 VIRTCHNL_PROTO_HDR_ ## hdr_type ## _ ## field))
1503 #define VIRTCHNL_DEL_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \
1504 (VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, \
1505 VIRTCHNL_PROTO_HDR_ ## hdr_type ## _ ## field))
1507 #define VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, hdr_type) \
1508 ((hdr)->type = VIRTCHNL_PROTO_HDR_ ## hdr_type)
1509 #define VIRTCHNL_GET_PROTO_HDR_TYPE(hdr) \
1510 (((hdr)->type) >> PROTO_HDR_SHIFT)
1511 #define VIRTCHNL_TEST_PROTO_HDR_TYPE(hdr, val) \
1512 ((hdr)->type == ((val) >> PROTO_HDR_SHIFT))
1513 #define VIRTCHNL_TEST_PROTO_HDR(hdr, val) \
1514 (VIRTCHNL_TEST_PROTO_HDR_TYPE(hdr, val) && \
1515 VIRTCHNL_TEST_PROTO_HDR_FIELD(hdr, val))
1517 /* Protocol header type within a packet segment. A segment consists of one or
1518 * more protocol headers that make up a logical group of protocol headers. Each
1519 * logical group of protocol headers encapsulates or is encapsulated using/by
1520 * tunneling or encapsulation protocols for network virtualization.
1522 enum virtchnl_proto_hdr_type {
1523 VIRTCHNL_PROTO_HDR_NONE,
1524 VIRTCHNL_PROTO_HDR_ETH,
1525 VIRTCHNL_PROTO_HDR_S_VLAN,
1526 VIRTCHNL_PROTO_HDR_C_VLAN,
1527 VIRTCHNL_PROTO_HDR_IPV4,
1528 VIRTCHNL_PROTO_HDR_IPV6,
1529 VIRTCHNL_PROTO_HDR_TCP,
1530 VIRTCHNL_PROTO_HDR_UDP,
1531 VIRTCHNL_PROTO_HDR_SCTP,
1532 VIRTCHNL_PROTO_HDR_GTPU_IP,
1533 VIRTCHNL_PROTO_HDR_GTPU_EH,
1534 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN,
1535 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP,
1536 VIRTCHNL_PROTO_HDR_PPPOE,
1537 VIRTCHNL_PROTO_HDR_L2TPV3,
1538 VIRTCHNL_PROTO_HDR_ESP,
1539 VIRTCHNL_PROTO_HDR_AH,
1540 VIRTCHNL_PROTO_HDR_PFCP,
1541 VIRTCHNL_PROTO_HDR_GTPC,
1542 VIRTCHNL_PROTO_HDR_ECPRI,
1543 VIRTCHNL_PROTO_HDR_L2TPV2,
1544 VIRTCHNL_PROTO_HDR_PPP,
1545 /* IPv4 and IPv6 Fragment header types are only associated to
1546 * VIRTCHNL_PROTO_HDR_IPV4 and VIRTCHNL_PROTO_HDR_IPV6 respectively,
1547 * cannot be used independently.
1549 VIRTCHNL_PROTO_HDR_IPV4_FRAG,
1550 VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG,
1551 VIRTCHNL_PROTO_HDR_GRE,
1554 /* Protocol header field within a protocol header. */
1555 enum virtchnl_proto_hdr_field {
1557 VIRTCHNL_PROTO_HDR_ETH_SRC =
1558 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ETH),
1559 VIRTCHNL_PROTO_HDR_ETH_DST,
1560 VIRTCHNL_PROTO_HDR_ETH_ETHERTYPE,
1562 VIRTCHNL_PROTO_HDR_S_VLAN_ID =
1563 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_S_VLAN),
1565 VIRTCHNL_PROTO_HDR_C_VLAN_ID =
1566 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_C_VLAN),
1568 VIRTCHNL_PROTO_HDR_IPV4_SRC =
1569 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV4),
1570 VIRTCHNL_PROTO_HDR_IPV4_DST,
1571 VIRTCHNL_PROTO_HDR_IPV4_DSCP,
1572 VIRTCHNL_PROTO_HDR_IPV4_TTL,
1573 VIRTCHNL_PROTO_HDR_IPV4_PROT,
1574 VIRTCHNL_PROTO_HDR_IPV4_CHKSUM,
1576 VIRTCHNL_PROTO_HDR_IPV6_SRC =
1577 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV6),
1578 VIRTCHNL_PROTO_HDR_IPV6_DST,
1579 VIRTCHNL_PROTO_HDR_IPV6_TC,
1580 VIRTCHNL_PROTO_HDR_IPV6_HOP_LIMIT,
1581 VIRTCHNL_PROTO_HDR_IPV6_PROT,
1583 VIRTCHNL_PROTO_HDR_IPV6_PREFIX32_SRC,
1584 VIRTCHNL_PROTO_HDR_IPV6_PREFIX32_DST,
1585 VIRTCHNL_PROTO_HDR_IPV6_PREFIX40_SRC,
1586 VIRTCHNL_PROTO_HDR_IPV6_PREFIX40_DST,
1587 VIRTCHNL_PROTO_HDR_IPV6_PREFIX48_SRC,
1588 VIRTCHNL_PROTO_HDR_IPV6_PREFIX48_DST,
1589 VIRTCHNL_PROTO_HDR_IPV6_PREFIX56_SRC,
1590 VIRTCHNL_PROTO_HDR_IPV6_PREFIX56_DST,
1591 VIRTCHNL_PROTO_HDR_IPV6_PREFIX64_SRC,
1592 VIRTCHNL_PROTO_HDR_IPV6_PREFIX64_DST,
1593 VIRTCHNL_PROTO_HDR_IPV6_PREFIX96_SRC,
1594 VIRTCHNL_PROTO_HDR_IPV6_PREFIX96_DST,
1596 VIRTCHNL_PROTO_HDR_TCP_SRC_PORT =
1597 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_TCP),
1598 VIRTCHNL_PROTO_HDR_TCP_DST_PORT,
1599 VIRTCHNL_PROTO_HDR_TCP_CHKSUM,
1601 VIRTCHNL_PROTO_HDR_UDP_SRC_PORT =
1602 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_UDP),
1603 VIRTCHNL_PROTO_HDR_UDP_DST_PORT,
1604 VIRTCHNL_PROTO_HDR_UDP_CHKSUM,
1606 VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT =
1607 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_SCTP),
1608 VIRTCHNL_PROTO_HDR_SCTP_DST_PORT,
1609 VIRTCHNL_PROTO_HDR_SCTP_CHKSUM,
1611 VIRTCHNL_PROTO_HDR_GTPU_IP_TEID =
1612 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_IP),
1614 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU =
1615 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH),
1616 VIRTCHNL_PROTO_HDR_GTPU_EH_QFI,
1618 VIRTCHNL_PROTO_HDR_PPPOE_SESS_ID =
1619 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_PPPOE),
1621 VIRTCHNL_PROTO_HDR_L2TPV3_SESS_ID =
1622 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_L2TPV3),
1624 VIRTCHNL_PROTO_HDR_ESP_SPI =
1625 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ESP),
1627 VIRTCHNL_PROTO_HDR_AH_SPI =
1628 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_AH),
1630 VIRTCHNL_PROTO_HDR_PFCP_S_FIELD =
1631 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_PFCP),
1632 VIRTCHNL_PROTO_HDR_PFCP_SEID,
1634 VIRTCHNL_PROTO_HDR_GTPC_TEID =
1635 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPC),
1637 VIRTCHNL_PROTO_HDR_ECPRI_MSG_TYPE =
1638 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ECPRI),
1639 VIRTCHNL_PROTO_HDR_ECPRI_PC_RTC_ID,
1640 /* IPv4 Dummy Fragment */
1641 VIRTCHNL_PROTO_HDR_IPV4_FRAG_PKID =
1642 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV4_FRAG),
1643 /* IPv6 Extension Fragment */
1644 VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG_PKID =
1645 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG),
1647 VIRTCHNL_PROTO_HDR_GTPU_DWN_QFI =
1648 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN),
1649 VIRTCHNL_PROTO_HDR_GTPU_UP_QFI =
1650 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP),
1653 struct virtchnl_proto_hdr {
1654 /* see enum virtchnl_proto_hdr_type */
1656 u32 field_selector; /* a bit mask to select field for header type */
1659 * binary buffer in network order for specific header type.
1660 * For example, if type = VIRTCHNL_PROTO_HDR_IPV4, a IPv4
1661 * header is expected to be copied into the buffer.
1665 VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_proto_hdr);
1667 struct virtchnl_proto_hdrs {
1670 * specify where protocol header start from.
1671 * 0 - from the outer layer
1672 * 1 - from the first inner layer
1673 * 2 - from the second inner layer
1676 int count; /* the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS */
1677 struct virtchnl_proto_hdr proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
1680 VIRTCHNL_CHECK_STRUCT_LEN(2312, virtchnl_proto_hdrs);
1682 struct virtchnl_rss_cfg {
1683 struct virtchnl_proto_hdrs proto_hdrs; /* protocol headers */
1685 /* see enum virtchnl_rss_algorithm; rss algorithm type */
1687 u8 reserved[128]; /* reserve for future */
1690 VIRTCHNL_CHECK_STRUCT_LEN(2444, virtchnl_rss_cfg);
1692 /* action configuration for FDIR */
1693 struct virtchnl_filter_action {
1694 /* see enum virtchnl_action type */
1697 /* used for queue and qgroup action */
1702 /* used for count action */
1704 /* share counter ID with other flow rules */
1706 u32 id; /* counter ID */
1708 /* used for mark action */
1714 VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_filter_action);
1716 #define VIRTCHNL_MAX_NUM_ACTIONS 8
1718 struct virtchnl_filter_action_set {
1719 /* action number must be less then VIRTCHNL_MAX_NUM_ACTIONS */
1721 struct virtchnl_filter_action actions[VIRTCHNL_MAX_NUM_ACTIONS];
1724 VIRTCHNL_CHECK_STRUCT_LEN(292, virtchnl_filter_action_set);
1726 /* pattern and action for FDIR rule */
1727 struct virtchnl_fdir_rule {
1728 struct virtchnl_proto_hdrs proto_hdrs;
1729 struct virtchnl_filter_action_set action_set;
1732 VIRTCHNL_CHECK_STRUCT_LEN(2604, virtchnl_fdir_rule);
1734 /* Status returned to VF after VF requests FDIR commands
1735 * VIRTCHNL_FDIR_SUCCESS
1736 * VF FDIR related request is successfully done by PF
1737 * The request can be OP_ADD/DEL/QUERY_FDIR_FILTER.
1739 * VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE
1740 * OP_ADD_FDIR_FILTER request is failed due to no Hardware resource.
1742 * VIRTCHNL_FDIR_FAILURE_RULE_EXIST
1743 * OP_ADD_FDIR_FILTER request is failed due to the rule is already existed.
1745 * VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT
1746 * OP_ADD_FDIR_FILTER request is failed due to conflict with existing rule.
1748 * VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST
1749 * OP_DEL_FDIR_FILTER request is failed due to this rule doesn't exist.
1751 * VIRTCHNL_FDIR_FAILURE_RULE_INVALID
1752 * OP_ADD_FDIR_FILTER request is failed due to parameters validation
1753 * or HW doesn't support.
1755 * VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT
1756 * OP_ADD/DEL_FDIR_FILTER request is failed due to timing out
1759 * VIRTCHNL_FDIR_FAILURE_QUERY_INVALID
1760 * OP_QUERY_FDIR_FILTER request is failed due to parameters validation,
1761 * for example, VF query counter of a rule who has no counter action.
1763 enum virtchnl_fdir_prgm_status {
1764 VIRTCHNL_FDIR_SUCCESS = 0,
1765 VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE,
1766 VIRTCHNL_FDIR_FAILURE_RULE_EXIST,
1767 VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT,
1768 VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST,
1769 VIRTCHNL_FDIR_FAILURE_RULE_INVALID,
1770 VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT,
1771 VIRTCHNL_FDIR_FAILURE_QUERY_INVALID,
1774 /* VIRTCHNL_OP_ADD_FDIR_FILTER
1775 * VF sends this request to PF by filling out vsi_id,
1776 * validate_only and rule_cfg. PF will return flow_id
1777 * if the request is successfully done and return add_status to VF.
1779 struct virtchnl_fdir_add {
1780 u16 vsi_id; /* INPUT */
1782 * 1 for validating a fdir rule, 0 for creating a fdir rule.
1783 * Validate and create share one ops: VIRTCHNL_OP_ADD_FDIR_FILTER.
1785 u16 validate_only; /* INPUT */
1786 u32 flow_id; /* OUTPUT */
1787 struct virtchnl_fdir_rule rule_cfg; /* INPUT */
1789 /* see enum virtchnl_fdir_prgm_status; OUTPUT */
1793 VIRTCHNL_CHECK_STRUCT_LEN(2616, virtchnl_fdir_add);
1795 /* VIRTCHNL_OP_DEL_FDIR_FILTER
1796 * VF sends this request to PF by filling out vsi_id
1797 * and flow_id. PF will return del_status to VF.
1799 struct virtchnl_fdir_del {
1800 u16 vsi_id; /* INPUT */
1802 u32 flow_id; /* INPUT */
1804 /* see enum virtchnl_fdir_prgm_status; OUTPUT */
1808 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del);
1810 /* VIRTCHNL_OP_GET_QOS_CAPS
1811 * VF sends this message to get its QoS Caps, such as
1812 * TC number, Arbiter and Bandwidth.
1814 struct virtchnl_qos_cap_elem {
1817 #define VIRTCHNL_ABITER_STRICT 0
1818 #define VIRTCHNL_ABITER_ETS 2
1820 #define VIRTCHNL_STRICT_WEIGHT 1
1822 enum virtchnl_bw_limit_type type;
1824 struct virtchnl_shaper_bw shaper;
1829 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_qos_cap_elem);
1831 struct virtchnl_qos_cap_list {
1834 struct virtchnl_qos_cap_elem cap[1];
1837 VIRTCHNL_CHECK_STRUCT_LEN(44, virtchnl_qos_cap_list);
1839 /* VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP
1840 * VF sends message virtchnl_queue_tc_mapping to set queue to tc
1841 * mapping for all the Tx and Rx queues with a specified VSI, and
1842 * would get response about bitmap of valid user priorities
1843 * associated with queues.
1845 struct virtchnl_queue_tc_mapping {
1848 u16 num_queue_pairs;
1856 #define VIRTCHNL_USER_PRIO_TYPE_UP 0
1857 #define VIRTCHNL_USER_PRIO_TYPE_DSCP 1
1859 u16 valid_prio_bitmap;
1864 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_tc_mapping);
1867 /* TX and RX queue types are valid in legacy as well as split queue models.
1868 * With Split Queue model, 2 additional types are introduced - TX_COMPLETION
1869 * and RX_BUFFER. In split queue model, RX corresponds to the queue where HW
1870 * posts completions.
1872 enum virtchnl_queue_type {
1873 VIRTCHNL_QUEUE_TYPE_TX = 0,
1874 VIRTCHNL_QUEUE_TYPE_RX = 1,
1875 VIRTCHNL_QUEUE_TYPE_TX_COMPLETION = 2,
1876 VIRTCHNL_QUEUE_TYPE_RX_BUFFER = 3,
1877 VIRTCHNL_QUEUE_TYPE_CONFIG_TX = 4,
1878 VIRTCHNL_QUEUE_TYPE_CONFIG_RX = 5
1882 /* structure to specify a chunk of contiguous queues */
1883 struct virtchnl_queue_chunk {
1884 /* see enum virtchnl_queue_type */
1890 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_queue_chunk);
1892 /* structure to specify several chunks of contiguous queues */
1893 struct virtchnl_queue_chunks {
1896 struct virtchnl_queue_chunk chunks[1];
1899 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_chunks);
1902 /* VIRTCHNL_OP_ENABLE_QUEUES_V2
1903 * VIRTCHNL_OP_DISABLE_QUEUES_V2
1904 * VIRTCHNL_OP_DEL_QUEUES
1906 * If VIRTCHNL_CAP_EXT_FEATURES was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
1907 * then all of these ops are available.
1909 * If VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
1910 * then VIRTCHNL_OP_ENABLE_QUEUES_V2 and VIRTCHNL_OP_DISABLE_QUEUES_V2 are
1913 * PF sends these messages to enable, disable or delete queues specified in
1914 * chunks. PF sends virtchnl_del_ena_dis_queues struct to specify the queues
1915 * to be enabled/disabled/deleted. Also applicable to single queue RX or
1916 * TX. CP performs requested action and returns status.
1918 struct virtchnl_del_ena_dis_queues {
1921 struct virtchnl_queue_chunks chunks;
1924 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_del_ena_dis_queues);
1926 /* Virtchannel interrupt throttling rate index */
1927 enum virtchnl_itr_idx {
1928 VIRTCHNL_ITR_IDX_0 = 0,
1929 VIRTCHNL_ITR_IDX_1 = 1,
1930 VIRTCHNL_ITR_IDX_NO_ITR = 3,
1933 /* Queue to vector mapping */
1934 struct virtchnl_queue_vector {
1939 /* see enum virtchnl_itr_idx */
1942 /* see enum virtchnl_queue_type */
1946 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_queue_vector);
1948 /* VIRTCHNL_OP_MAP_QUEUE_VECTOR
1949 * VIRTCHNL_OP_UNMAP_QUEUE_VECTOR
1951 * If VIRTCHNL_CAP_EXT_FEATURES was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
1952 * then all of these ops are available.
1954 * If VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
1955 * then only VIRTCHNL_OP_MAP_QUEUE_VECTOR is available.
1957 * PF sends this message to map or unmap queues to vectors and ITR index
1958 * registers. External data buffer contains virtchnl_queue_vector_maps structure
1959 * that contains num_qv_maps of virtchnl_queue_vector structures.
1960 * CP maps the requested queue vector maps after validating the queue and vector
1961 * ids and returns a status code.
1963 struct virtchnl_queue_vector_maps {
1967 struct virtchnl_queue_vector qv_maps[1];
1970 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_queue_vector_maps);
1973 /* Since VF messages are limited by u16 size, precalculate the maximum possible
1974 * values of nested elements in virtchnl structures that virtual channel can
1975 * possibly handle in a single message.
1977 enum virtchnl_vector_limits {
1978 VIRTCHNL_OP_CONFIG_VSI_QUEUES_MAX =
1979 ((u16)(~0) - sizeof(struct virtchnl_vsi_queue_config_info)) /
1980 sizeof(struct virtchnl_queue_pair_info),
1982 VIRTCHNL_OP_CONFIG_IRQ_MAP_MAX =
1983 ((u16)(~0) - sizeof(struct virtchnl_irq_map_info)) /
1984 sizeof(struct virtchnl_vector_map),
1986 VIRTCHNL_OP_ADD_DEL_ETH_ADDR_MAX =
1987 ((u16)(~0) - sizeof(struct virtchnl_ether_addr_list)) /
1988 sizeof(struct virtchnl_ether_addr),
1990 VIRTCHNL_OP_ADD_DEL_VLAN_MAX =
1991 ((u16)(~0) - sizeof(struct virtchnl_vlan_filter_list)) /
1995 VIRTCHNL_OP_ENABLE_CHANNELS_MAX =
1996 ((u16)(~0) - sizeof(struct virtchnl_tc_info)) /
1997 sizeof(struct virtchnl_channel_info),
1999 VIRTCHNL_OP_ENABLE_DISABLE_DEL_QUEUES_V2_MAX =
2000 ((u16)(~0) - sizeof(struct virtchnl_del_ena_dis_queues)) /
2001 sizeof(struct virtchnl_queue_chunk),
2003 VIRTCHNL_OP_MAP_UNMAP_QUEUE_VECTOR_MAX =
2004 ((u16)(~0) - sizeof(struct virtchnl_queue_vector_maps)) /
2005 sizeof(struct virtchnl_queue_vector),
2007 VIRTCHNL_OP_ADD_DEL_VLAN_V2_MAX =
2008 ((u16)(~0) - sizeof(struct virtchnl_vlan_filter_list_v2)) /
2009 sizeof(struct virtchnl_vlan_filter),
2013 * virtchnl_vc_validate_vf_msg
2014 * @ver: Virtchnl version info
2015 * @v_opcode: Opcode for the message
2016 * @msg: pointer to the msg buffer
2017 * @msglen: msg length
2019 * validate msg format against struct for each opcode
2022 virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
2023 u8 *msg, u16 msglen)
2025 bool err_msg_format = false;
2028 /* Validate message length. */
2030 case VIRTCHNL_OP_VERSION:
2031 valid_len = sizeof(struct virtchnl_version_info);
2033 case VIRTCHNL_OP_RESET_VF:
2035 case VIRTCHNL_OP_GET_VF_RESOURCES:
2037 valid_len = sizeof(u32);
2039 case VIRTCHNL_OP_CONFIG_TX_QUEUE:
2040 valid_len = sizeof(struct virtchnl_txq_info);
2042 case VIRTCHNL_OP_CONFIG_RX_QUEUE:
2043 valid_len = sizeof(struct virtchnl_rxq_info);
2045 case VIRTCHNL_OP_CONFIG_VSI_QUEUES:
2046 valid_len = sizeof(struct virtchnl_vsi_queue_config_info);
2047 if (msglen >= valid_len) {
2048 struct virtchnl_vsi_queue_config_info *vqc =
2049 (struct virtchnl_vsi_queue_config_info *)msg;
2051 if (vqc->num_queue_pairs == 0 || vqc->num_queue_pairs >
2052 VIRTCHNL_OP_CONFIG_VSI_QUEUES_MAX) {
2053 err_msg_format = true;
2057 valid_len += (vqc->num_queue_pairs *
2059 virtchnl_queue_pair_info));
2062 case VIRTCHNL_OP_CONFIG_IRQ_MAP:
2063 valid_len = sizeof(struct virtchnl_irq_map_info);
2064 if (msglen >= valid_len) {
2065 struct virtchnl_irq_map_info *vimi =
2066 (struct virtchnl_irq_map_info *)msg;
2068 if (vimi->num_vectors == 0 || vimi->num_vectors >
2069 VIRTCHNL_OP_CONFIG_IRQ_MAP_MAX) {
2070 err_msg_format = true;
2074 valid_len += (vimi->num_vectors *
2075 sizeof(struct virtchnl_vector_map));
2078 case VIRTCHNL_OP_ENABLE_QUEUES:
2079 case VIRTCHNL_OP_DISABLE_QUEUES:
2080 valid_len = sizeof(struct virtchnl_queue_select);
2082 case VIRTCHNL_OP_GET_MAX_RSS_QREGION:
2084 case VIRTCHNL_OP_ADD_ETH_ADDR:
2085 case VIRTCHNL_OP_DEL_ETH_ADDR:
2086 valid_len = sizeof(struct virtchnl_ether_addr_list);
2087 if (msglen >= valid_len) {
2088 struct virtchnl_ether_addr_list *veal =
2089 (struct virtchnl_ether_addr_list *)msg;
2091 if (veal->num_elements == 0 || veal->num_elements >
2092 VIRTCHNL_OP_ADD_DEL_ETH_ADDR_MAX) {
2093 err_msg_format = true;
2097 valid_len += veal->num_elements *
2098 sizeof(struct virtchnl_ether_addr);
2101 case VIRTCHNL_OP_ADD_VLAN:
2102 case VIRTCHNL_OP_DEL_VLAN:
2103 valid_len = sizeof(struct virtchnl_vlan_filter_list);
2104 if (msglen >= valid_len) {
2105 struct virtchnl_vlan_filter_list *vfl =
2106 (struct virtchnl_vlan_filter_list *)msg;
2108 if (vfl->num_elements == 0 || vfl->num_elements >
2109 VIRTCHNL_OP_ADD_DEL_VLAN_MAX) {
2110 err_msg_format = true;
2114 valid_len += vfl->num_elements * sizeof(u16);
2117 case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE:
2118 valid_len = sizeof(struct virtchnl_promisc_info);
2120 case VIRTCHNL_OP_GET_STATS:
2121 valid_len = sizeof(struct virtchnl_queue_select);
2123 case VIRTCHNL_OP_CONFIG_RSS_KEY:
2124 valid_len = sizeof(struct virtchnl_rss_key);
2125 if (msglen >= valid_len) {
2126 struct virtchnl_rss_key *vrk =
2127 (struct virtchnl_rss_key *)msg;
2129 if (vrk->key_len == 0) {
2130 /* zero length is allowed as input */
2134 valid_len += vrk->key_len - 1;
2137 case VIRTCHNL_OP_CONFIG_RSS_LUT:
2138 valid_len = sizeof(struct virtchnl_rss_lut);
2139 if (msglen >= valid_len) {
2140 struct virtchnl_rss_lut *vrl =
2141 (struct virtchnl_rss_lut *)msg;
2143 if (vrl->lut_entries == 0) {
2144 /* zero entries is allowed as input */
2148 valid_len += vrl->lut_entries - 1;
2151 case VIRTCHNL_OP_GET_RSS_HENA_CAPS:
2153 case VIRTCHNL_OP_SET_RSS_HENA:
2154 valid_len = sizeof(struct virtchnl_rss_hena);
2156 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING:
2157 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING:
2159 case VIRTCHNL_OP_REQUEST_QUEUES:
2160 valid_len = sizeof(struct virtchnl_vf_res_request);
2162 case VIRTCHNL_OP_ENABLE_CHANNELS:
2163 valid_len = sizeof(struct virtchnl_tc_info);
2164 if (msglen >= valid_len) {
2165 struct virtchnl_tc_info *vti =
2166 (struct virtchnl_tc_info *)msg;
2168 if (vti->num_tc == 0 || vti->num_tc >
2169 VIRTCHNL_OP_ENABLE_CHANNELS_MAX) {
2170 err_msg_format = true;
2174 valid_len += (vti->num_tc - 1) *
2175 sizeof(struct virtchnl_channel_info);
2178 case VIRTCHNL_OP_DISABLE_CHANNELS:
2180 case VIRTCHNL_OP_ADD_CLOUD_FILTER:
2181 case VIRTCHNL_OP_DEL_CLOUD_FILTER:
2182 valid_len = sizeof(struct virtchnl_filter);
2184 case VIRTCHNL_OP_DCF_VLAN_OFFLOAD:
2185 valid_len = sizeof(struct virtchnl_dcf_vlan_offload);
2187 case VIRTCHNL_OP_DCF_CMD_DESC:
2188 case VIRTCHNL_OP_DCF_CMD_BUFF:
2189 /* These two opcodes are specific to handle the AdminQ command,
2190 * so the validation needs to be done in PF's context.
2194 case VIRTCHNL_OP_DCF_DISABLE:
2195 case VIRTCHNL_OP_DCF_GET_VSI_MAP:
2196 case VIRTCHNL_OP_DCF_GET_PKG_INFO:
2198 case VIRTCHNL_OP_DCF_CONFIG_BW:
2199 valid_len = sizeof(struct virtchnl_dcf_bw_cfg_list);
2200 if (msglen >= valid_len) {
2201 struct virtchnl_dcf_bw_cfg_list *cfg_list =
2202 (struct virtchnl_dcf_bw_cfg_list *)msg;
2203 if (cfg_list->num_elem == 0) {
2204 err_msg_format = true;
2207 valid_len += (cfg_list->num_elem - 1) *
2208 sizeof(struct virtchnl_dcf_bw_cfg);
2211 case VIRTCHNL_OP_GET_SUPPORTED_RXDIDS:
2213 case VIRTCHNL_OP_ADD_RSS_CFG:
2214 case VIRTCHNL_OP_DEL_RSS_CFG:
2215 valid_len = sizeof(struct virtchnl_rss_cfg);
2217 case VIRTCHNL_OP_ADD_FDIR_FILTER:
2218 valid_len = sizeof(struct virtchnl_fdir_add);
2220 case VIRTCHNL_OP_DEL_FDIR_FILTER:
2221 valid_len = sizeof(struct virtchnl_fdir_del);
2223 case VIRTCHNL_OP_GET_QOS_CAPS:
2225 case VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP:
2226 valid_len = sizeof(struct virtchnl_queue_tc_mapping);
2227 if (msglen >= valid_len) {
2228 struct virtchnl_queue_tc_mapping *q_tc =
2229 (struct virtchnl_queue_tc_mapping *)msg;
2230 if (q_tc->num_tc == 0) {
2231 err_msg_format = true;
2234 valid_len += (q_tc->num_tc - 1) *
2235 sizeof(q_tc->tc[0]);
2238 case VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS:
2240 case VIRTCHNL_OP_ADD_VLAN_V2:
2241 case VIRTCHNL_OP_DEL_VLAN_V2:
2242 valid_len = sizeof(struct virtchnl_vlan_filter_list_v2);
2243 if (msglen >= valid_len) {
2244 struct virtchnl_vlan_filter_list_v2 *vfl =
2245 (struct virtchnl_vlan_filter_list_v2 *)msg;
2247 if (vfl->num_elements == 0 || vfl->num_elements >
2248 VIRTCHNL_OP_ADD_DEL_VLAN_V2_MAX) {
2249 err_msg_format = true;
2253 valid_len += (vfl->num_elements - 1) *
2254 sizeof(struct virtchnl_vlan_filter);
2257 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2:
2258 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2:
2259 case VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2:
2260 case VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2:
2261 case VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2:
2262 case VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2:
2263 valid_len = sizeof(struct virtchnl_vlan_setting);
2265 case VIRTCHNL_OP_ENABLE_QUEUES_V2:
2266 case VIRTCHNL_OP_DISABLE_QUEUES_V2:
2267 valid_len = sizeof(struct virtchnl_del_ena_dis_queues);
2268 if (msglen >= valid_len) {
2269 struct virtchnl_del_ena_dis_queues *qs =
2270 (struct virtchnl_del_ena_dis_queues *)msg;
2271 if (qs->chunks.num_chunks == 0 ||
2272 qs->chunks.num_chunks > VIRTCHNL_OP_ENABLE_DISABLE_DEL_QUEUES_V2_MAX) {
2273 err_msg_format = true;
2276 valid_len += (qs->chunks.num_chunks - 1) *
2277 sizeof(struct virtchnl_queue_chunk);
2280 case VIRTCHNL_OP_MAP_QUEUE_VECTOR:
2281 valid_len = sizeof(struct virtchnl_queue_vector_maps);
2282 if (msglen >= valid_len) {
2283 struct virtchnl_queue_vector_maps *v_qp =
2284 (struct virtchnl_queue_vector_maps *)msg;
2285 if (v_qp->num_qv_maps == 0 ||
2286 v_qp->num_qv_maps > VIRTCHNL_OP_MAP_UNMAP_QUEUE_VECTOR_MAX) {
2287 err_msg_format = true;
2290 valid_len += (v_qp->num_qv_maps - 1) *
2291 sizeof(struct virtchnl_queue_vector);
2294 /* These are always errors coming from the VF. */
2295 case VIRTCHNL_OP_EVENT:
2296 case VIRTCHNL_OP_UNKNOWN:
2298 return VIRTCHNL_STATUS_ERR_PARAM;
2300 /* few more checks */
2301 if (err_msg_format || valid_len != msglen)
2302 return VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH;
2306 #endif /* _VIRTCHNL_H_ */