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_QUERY_FDIR_FILTER = 49,
150 VIRTCHNL_OP_GET_MAX_RSS_QREGION = 50,
151 VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS = 51,
152 VIRTCHNL_OP_ADD_VLAN_V2 = 52,
153 VIRTCHNL_OP_DEL_VLAN_V2 = 53,
154 VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 = 54,
155 VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 = 55,
156 VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 = 56,
157 VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2 = 57,
158 VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2 = 58,
159 VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2 = 59,
160 VIRTCHNL_OP_GET_QOS_CAPS = 66,
161 VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP = 67,
162 VIRTCHNL_OP_ENABLE_QUEUES_V2 = 107,
163 VIRTCHNL_OP_DISABLE_QUEUES_V2 = 108,
164 VIRTCHNL_OP_MAP_QUEUE_VECTOR = 111,
168 static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)
171 case VIRTCHNL_OP_UNKNOWN:
172 return "VIRTCHNL_OP_UNKNOWN";
173 case VIRTCHNL_OP_VERSION:
174 return "VIRTCHNL_OP_VERSION";
175 case VIRTCHNL_OP_RESET_VF:
176 return "VIRTCHNL_OP_RESET_VF";
177 case VIRTCHNL_OP_GET_VF_RESOURCES:
178 return "VIRTCHNL_OP_GET_VF_RESOURCES";
179 case VIRTCHNL_OP_CONFIG_TX_QUEUE:
180 return "VIRTCHNL_OP_CONFIG_TX_QUEUE";
181 case VIRTCHNL_OP_CONFIG_RX_QUEUE:
182 return "VIRTCHNL_OP_CONFIG_RX_QUEUE";
183 case VIRTCHNL_OP_CONFIG_VSI_QUEUES:
184 return "VIRTCHNL_OP_CONFIG_VSI_QUEUES";
185 case VIRTCHNL_OP_CONFIG_IRQ_MAP:
186 return "VIRTCHNL_OP_CONFIG_IRQ_MAP";
187 case VIRTCHNL_OP_ENABLE_QUEUES:
188 return "VIRTCHNL_OP_ENABLE_QUEUES";
189 case VIRTCHNL_OP_DISABLE_QUEUES:
190 return "VIRTCHNL_OP_DISABLE_QUEUES";
191 case VIRTCHNL_OP_ADD_ETH_ADDR:
192 return "VIRTCHNL_OP_ADD_ETH_ADDR";
193 case VIRTCHNL_OP_DEL_ETH_ADDR:
194 return "VIRTCHNL_OP_DEL_ETH_ADDR";
195 case VIRTCHNL_OP_ADD_VLAN:
196 return "VIRTCHNL_OP_ADD_VLAN";
197 case VIRTCHNL_OP_DEL_VLAN:
198 return "VIRTCHNL_OP_DEL_VLAN";
199 case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE:
200 return "VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE";
201 case VIRTCHNL_OP_GET_STATS:
202 return "VIRTCHNL_OP_GET_STATS";
203 case VIRTCHNL_OP_RSVD:
204 return "VIRTCHNL_OP_RSVD";
205 case VIRTCHNL_OP_EVENT:
206 return "VIRTCHNL_OP_EVENT";
207 case VIRTCHNL_OP_CONFIG_RSS_KEY:
208 return "VIRTCHNL_OP_CONFIG_RSS_KEY";
209 case VIRTCHNL_OP_CONFIG_RSS_LUT:
210 return "VIRTCHNL_OP_CONFIG_RSS_LUT";
211 case VIRTCHNL_OP_GET_RSS_HENA_CAPS:
212 return "VIRTCHNL_OP_GET_RSS_HENA_CAPS";
213 case VIRTCHNL_OP_SET_RSS_HENA:
214 return "VIRTCHNL_OP_SET_RSS_HENA";
215 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING:
216 return "VIRTCHNL_OP_ENABLE_VLAN_STRIPPING";
217 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING:
218 return "VIRTCHNL_OP_DISABLE_VLAN_STRIPPING";
219 case VIRTCHNL_OP_REQUEST_QUEUES:
220 return "VIRTCHNL_OP_REQUEST_QUEUES";
221 case VIRTCHNL_OP_ENABLE_CHANNELS:
222 return "VIRTCHNL_OP_ENABLE_CHANNELS";
223 case VIRTCHNL_OP_DISABLE_CHANNELS:
224 return "VIRTCHNL_OP_DISABLE_CHANNELS";
225 case VIRTCHNL_OP_ADD_CLOUD_FILTER:
226 return "VIRTCHNL_OP_ADD_CLOUD_FILTER";
227 case VIRTCHNL_OP_DEL_CLOUD_FILTER:
228 return "VIRTCHNL_OP_DEL_CLOUD_FILTER";
229 case VIRTCHNL_OP_DCF_CMD_DESC:
230 return "VIRTCHNL_OP_DCF_CMD_DESC";
231 case VIRTCHNL_OP_DCF_CMD_BUFF:
232 return "VIRTCHHNL_OP_DCF_CMD_BUFF";
233 case VIRTCHNL_OP_DCF_DISABLE:
234 return "VIRTCHNL_OP_DCF_DISABLE";
235 case VIRTCHNL_OP_DCF_GET_VSI_MAP:
236 return "VIRTCHNL_OP_DCF_GET_VSI_MAP";
237 case VIRTCHNL_OP_GET_SUPPORTED_RXDIDS:
238 return "VIRTCHNL_OP_GET_SUPPORTED_RXDIDS";
239 case VIRTCHNL_OP_ADD_RSS_CFG:
240 return "VIRTCHNL_OP_ADD_RSS_CFG";
241 case VIRTCHNL_OP_DEL_RSS_CFG:
242 return "VIRTCHNL_OP_DEL_RSS_CFG";
243 case VIRTCHNL_OP_ADD_FDIR_FILTER:
244 return "VIRTCHNL_OP_ADD_FDIR_FILTER";
245 case VIRTCHNL_OP_DEL_FDIR_FILTER:
246 return "VIRTCHNL_OP_DEL_FDIR_FILTER";
247 case VIRTCHNL_OP_QUERY_FDIR_FILTER:
248 return "VIRTCHNL_OP_QUERY_FDIR_FILTER";
249 case VIRTCHNL_OP_GET_MAX_RSS_QREGION:
250 return "VIRTCHNL_OP_GET_MAX_RSS_QREGION";
251 case VIRTCHNL_OP_ENABLE_QUEUES_V2:
252 return "VIRTCHNL_OP_ENABLE_QUEUES_V2";
253 case VIRTCHNL_OP_DISABLE_QUEUES_V2:
254 return "VIRTCHNL_OP_DISABLE_QUEUES_V2";
255 case VIRTCHNL_OP_MAP_QUEUE_VECTOR:
256 return "VIRTCHNL_OP_MAP_QUEUE_VECTOR";
257 case VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS:
258 return "VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS";
259 case VIRTCHNL_OP_ADD_VLAN_V2:
260 return "VIRTCHNL_OP_ADD_VLAN_V2";
261 case VIRTCHNL_OP_DEL_VLAN_V2:
262 return "VIRTCHNL_OP_DEL_VLAN_V2";
263 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2:
264 return "VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2";
265 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2:
266 return "VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2";
267 case VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2:
268 return "VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2";
269 case VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2:
270 return "VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2";
271 case VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2:
272 return "VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2";
273 case VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2:
274 return "VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2";
275 case VIRTCHNL_OP_MAX:
276 return "VIRTCHNL_OP_MAX";
278 return "Unsupported (update virtchnl.h)";
282 /* These macros are used to generate compilation errors if a structure/union
283 * is not exactly the correct length. It gives a divide by zero error if the
284 * structure/union is not of the correct size, otherwise it creates an enum
285 * that is never used.
287 #define VIRTCHNL_CHECK_STRUCT_LEN(n, X) enum virtchnl_static_assert_enum_##X \
288 { virtchnl_static_assert_##X = (n)/((sizeof(struct X) == (n)) ? 1 : 0) }
289 #define VIRTCHNL_CHECK_UNION_LEN(n, X) enum virtchnl_static_asset_enum_##X \
290 { virtchnl_static_assert_##X = (n)/((sizeof(union X) == (n)) ? 1 : 0) }
292 /* Virtual channel message descriptor. This overlays the admin queue
293 * descriptor. All other data is passed in external buffers.
296 struct virtchnl_msg {
297 u8 pad[8]; /* AQ flags/opcode/len/retval fields */
299 /* avoid confusion with desc->opcode */
300 enum virtchnl_ops v_opcode;
302 /* ditto for desc->retval */
303 enum virtchnl_status_code v_retval;
304 u32 vfid; /* used by PF when sending to VF */
307 VIRTCHNL_CHECK_STRUCT_LEN(20, virtchnl_msg);
309 /* Message descriptions and data structures. */
311 /* VIRTCHNL_OP_VERSION
312 * VF posts its version number to the PF. PF responds with its version number
313 * in the same format, along with a return code.
314 * Reply from PF has its major/minor versions also in param0 and param1.
315 * If there is a major version mismatch, then the VF cannot operate.
316 * If there is a minor version mismatch, then the VF can operate but should
317 * add a warning to the system log.
319 * This enum element MUST always be specified as == 1, regardless of other
320 * changes in the API. The PF must always respond to this message without
321 * error regardless of version mismatch.
323 #define VIRTCHNL_VERSION_MAJOR 1
324 #define VIRTCHNL_VERSION_MINOR 1
325 #define VIRTCHNL_VERSION_MINOR_NO_VF_CAPS 0
327 struct virtchnl_version_info {
332 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_version_info);
334 #define VF_IS_V10(_v) (((_v)->major == 1) && ((_v)->minor == 0))
335 #define VF_IS_V11(_ver) (((_ver)->major == 1) && ((_ver)->minor == 1))
337 /* VIRTCHNL_OP_RESET_VF
338 * VF sends this request to PF with no parameters
339 * PF does NOT respond! VF driver must delay then poll VFGEN_RSTAT register
340 * until reset completion is indicated. The admin queue must be reinitialized
341 * after this operation.
343 * When reset is complete, PF must ensure that all queues in all VSIs associated
344 * with the VF are stopped, all queue configurations in the HMC are set to 0,
345 * and all MAC and VLAN filters (except the default MAC address) on all VSIs
349 /* VSI types that use VIRTCHNL interface for VF-PF communication. VSI_SRIOV
350 * vsi_type should always be 6 for backward compatibility. Add other fields
353 enum virtchnl_vsi_type {
354 VIRTCHNL_VSI_TYPE_INVALID = 0,
355 VIRTCHNL_VSI_SRIOV = 6,
358 /* VIRTCHNL_OP_GET_VF_RESOURCES
359 * Version 1.0 VF sends this request to PF with no parameters
360 * Version 1.1 VF sends this request to PF with u32 bitmap of its capabilities
361 * PF responds with an indirect message containing
362 * virtchnl_vf_resource and one or more
363 * virtchnl_vsi_resource structures.
366 struct virtchnl_vsi_resource {
370 /* see enum virtchnl_vsi_type */
373 u8 default_mac_addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
376 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
378 /* VF capability flags
379 * VIRTCHNL_VF_OFFLOAD_L2 flag is inclusive of base mode L2 offloads including
380 * TX/RX Checksum offloading and TSO for non-tunnelled packets.
382 #define VIRTCHNL_VF_OFFLOAD_L2 BIT(0)
383 #define VIRTCHNL_VF_OFFLOAD_IWARP BIT(1)
384 #define VIRTCHNL_VF_OFFLOAD_RSVD BIT(2)
385 #define VIRTCHNL_VF_OFFLOAD_RSS_AQ BIT(3)
386 #define VIRTCHNL_VF_OFFLOAD_RSS_REG BIT(4)
387 #define VIRTCHNL_VF_OFFLOAD_WB_ON_ITR BIT(5)
388 #define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES BIT(6)
389 /* used to negotiate communicating link speeds in Mbps */
390 #define VIRTCHNL_VF_CAP_ADV_LINK_SPEED BIT(7)
391 /* BIT(8) is reserved */
392 #define VIRTCHNL_VF_LARGE_NUM_QPAIRS BIT(9)
393 #define VIRTCHNL_VF_OFFLOAD_CRC BIT(10)
394 #define VIRTCHNL_VF_OFFLOAD_VLAN_V2 BIT(15)
395 #define VIRTCHNL_VF_OFFLOAD_VLAN BIT(16)
396 #define VIRTCHNL_VF_OFFLOAD_RX_POLLING BIT(17)
397 #define VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 BIT(18)
398 #define VIRTCHNL_VF_OFFLOAD_RSS_PF BIT(19)
399 #define VIRTCHNL_VF_OFFLOAD_ENCAP BIT(20)
400 #define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM BIT(21)
401 #define VIRTCHNL_VF_OFFLOAD_RX_ENCAP_CSUM BIT(22)
402 #define VIRTCHNL_VF_OFFLOAD_ADQ BIT(23)
403 #define VIRTCHNL_VF_OFFLOAD_ADQ_V2 BIT(24)
404 #define VIRTCHNL_VF_OFFLOAD_USO BIT(25)
405 #define VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC BIT(26)
406 #define VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF BIT(27)
407 #define VIRTCHNL_VF_OFFLOAD_FDIR_PF BIT(28)
408 #define VIRTCHNL_VF_OFFLOAD_QOS BIT(29)
409 #define VIRTCHNL_VF_CAP_DCF BIT(30)
410 /* BIT(31) is reserved */
412 #define VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \
413 VIRTCHNL_VF_OFFLOAD_VLAN | \
414 VIRTCHNL_VF_OFFLOAD_RSS_PF)
416 struct virtchnl_vf_resource {
426 struct virtchnl_vsi_resource vsi_res[1];
429 VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_vf_resource);
431 /* VIRTCHNL_OP_CONFIG_TX_QUEUE
432 * VF sends this message to set up parameters for one TX queue.
433 * External data buffer contains one instance of virtchnl_txq_info.
434 * PF configures requested queue and returns a status code.
437 /* Tx queue config info */
438 struct virtchnl_txq_info {
441 u16 ring_len; /* number of descriptors, multiple of 8 */
442 u16 headwb_enabled; /* deprecated with AVF 1.0 */
444 u64 dma_headwb_addr; /* deprecated with AVF 1.0 */
447 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_txq_info);
449 /* RX descriptor IDs (range from 0 to 63) */
450 enum virtchnl_rx_desc_ids {
451 VIRTCHNL_RXDID_0_16B_BASE = 0,
452 /* 32B_BASE and FLEX_SPLITQ share desc ids as default descriptors
453 * because they can be differentiated based on queue model; e.g. single
454 * queue model can only use 32B_BASE and split queue model can only use
455 * FLEX_SPLITQ. Having these as 1 allows them to be used as default
456 * descriptors without negotiation.
458 VIRTCHNL_RXDID_1_32B_BASE = 1,
459 VIRTCHNL_RXDID_1_FLEX_SPLITQ = 1,
460 VIRTCHNL_RXDID_2_FLEX_SQ_NIC = 2,
461 VIRTCHNL_RXDID_3_FLEX_SQ_SW = 3,
462 VIRTCHNL_RXDID_4_FLEX_SQ_NIC_VEB = 4,
463 VIRTCHNL_RXDID_5_FLEX_SQ_NIC_ACL = 5,
464 VIRTCHNL_RXDID_6_FLEX_SQ_NIC_2 = 6,
465 VIRTCHNL_RXDID_7_HW_RSVD = 7,
466 /* 9 through 15 are reserved */
467 VIRTCHNL_RXDID_16_COMMS_GENERIC = 16,
468 VIRTCHNL_RXDID_17_COMMS_AUX_VLAN = 17,
469 VIRTCHNL_RXDID_18_COMMS_AUX_IPV4 = 18,
470 VIRTCHNL_RXDID_19_COMMS_AUX_IPV6 = 19,
471 VIRTCHNL_RXDID_20_COMMS_AUX_FLOW = 20,
472 VIRTCHNL_RXDID_21_COMMS_AUX_TCP = 21,
473 /* 22 through 63 are reserved */
476 /* RX descriptor ID bitmasks */
477 enum virtchnl_rx_desc_id_bitmasks {
478 VIRTCHNL_RXDID_0_16B_BASE_M = BIT(VIRTCHNL_RXDID_0_16B_BASE),
479 VIRTCHNL_RXDID_1_32B_BASE_M = BIT(VIRTCHNL_RXDID_1_32B_BASE),
480 VIRTCHNL_RXDID_1_FLEX_SPLITQ_M = BIT(VIRTCHNL_RXDID_1_FLEX_SPLITQ),
481 VIRTCHNL_RXDID_2_FLEX_SQ_NIC_M = BIT(VIRTCHNL_RXDID_2_FLEX_SQ_NIC),
482 VIRTCHNL_RXDID_3_FLEX_SQ_SW_M = BIT(VIRTCHNL_RXDID_3_FLEX_SQ_SW),
483 VIRTCHNL_RXDID_4_FLEX_SQ_NIC_VEB_M = BIT(VIRTCHNL_RXDID_4_FLEX_SQ_NIC_VEB),
484 VIRTCHNL_RXDID_5_FLEX_SQ_NIC_ACL_M = BIT(VIRTCHNL_RXDID_5_FLEX_SQ_NIC_ACL),
485 VIRTCHNL_RXDID_6_FLEX_SQ_NIC_2_M = BIT(VIRTCHNL_RXDID_6_FLEX_SQ_NIC_2),
486 VIRTCHNL_RXDID_7_HW_RSVD_M = BIT(VIRTCHNL_RXDID_7_HW_RSVD),
487 /* 9 through 15 are reserved */
488 VIRTCHNL_RXDID_16_COMMS_GENERIC_M = BIT(VIRTCHNL_RXDID_16_COMMS_GENERIC),
489 VIRTCHNL_RXDID_17_COMMS_AUX_VLAN_M = BIT(VIRTCHNL_RXDID_17_COMMS_AUX_VLAN),
490 VIRTCHNL_RXDID_18_COMMS_AUX_IPV4_M = BIT(VIRTCHNL_RXDID_18_COMMS_AUX_IPV4),
491 VIRTCHNL_RXDID_19_COMMS_AUX_IPV6_M = BIT(VIRTCHNL_RXDID_19_COMMS_AUX_IPV6),
492 VIRTCHNL_RXDID_20_COMMS_AUX_FLOW_M = BIT(VIRTCHNL_RXDID_20_COMMS_AUX_FLOW),
493 VIRTCHNL_RXDID_21_COMMS_AUX_TCP_M = BIT(VIRTCHNL_RXDID_21_COMMS_AUX_TCP),
494 /* 22 through 63 are reserved */
497 /* VIRTCHNL_OP_CONFIG_RX_QUEUE
498 * VF sends this message to set up parameters for one RX queue.
499 * External data buffer contains one instance of virtchnl_rxq_info.
500 * PF configures requested queue and returns a status code. The
501 * crc_disable flag disables CRC stripping on the VF. Setting
502 * the crc_disable flag to 1 will disable CRC stripping for each
503 * queue in the VF where the flag is set. The VIRTCHNL_VF_OFFLOAD_CRC
504 * offload must have been set prior to sending this info or the PF
505 * will ignore the request. This flag should be set the same for
506 * all of the queues for a VF.
509 /* Rx queue config info */
510 struct virtchnl_rxq_info {
513 u32 ring_len; /* number of descriptors, multiple of 32 */
515 u16 splithdr_enabled; /* deprecated with AVF 1.0 */
519 /* see enum virtchnl_rx_desc_ids;
520 * only used when VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC is supported. Note
521 * that when the offload is not supported, the descriptor format aligns
522 * with VIRTCHNL_RXDID_1_32B_BASE.
528 /* see enum virtchnl_rx_hsplit; deprecated with AVF 1.0 */
533 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_rxq_info);
535 /* VIRTCHNL_OP_CONFIG_VSI_QUEUES
536 * VF sends this message to set parameters for active TX and RX queues
537 * associated with the specified VSI.
538 * PF configures queues and returns status.
539 * If the number of queues specified is greater than the number of queues
540 * associated with the VSI, an error is returned and no queues are configured.
541 * NOTE: The VF is not required to configure all queues in a single request.
542 * It may send multiple messages. PF drivers must correctly handle all VF
545 struct virtchnl_queue_pair_info {
546 /* NOTE: vsi_id and queue_id should be identical for both queues. */
547 struct virtchnl_txq_info txq;
548 struct virtchnl_rxq_info rxq;
551 VIRTCHNL_CHECK_STRUCT_LEN(64, virtchnl_queue_pair_info);
553 struct virtchnl_vsi_queue_config_info {
557 struct virtchnl_queue_pair_info qpair[1];
560 VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_vsi_queue_config_info);
562 /* VIRTCHNL_OP_REQUEST_QUEUES
563 * VF sends this message to request the PF to allocate additional queues to
564 * this VF. Each VF gets a guaranteed number of queues on init but asking for
565 * additional queues must be negotiated. This is a best effort request as it
566 * is possible the PF does not have enough queues left to support the request.
567 * If the PF cannot support the number requested it will respond with the
568 * maximum number it is able to support. If the request is successful, PF will
569 * then reset the VF to institute required changes.
572 /* VF resource request */
573 struct virtchnl_vf_res_request {
577 /* VIRTCHNL_OP_CONFIG_IRQ_MAP
578 * VF uses this message to map vectors to queues.
579 * The rxq_map and txq_map fields are bitmaps used to indicate which queues
580 * are to be associated with the specified vector.
581 * The "other" causes are always mapped to vector 0. The VF may not request
582 * that vector 0 be used for traffic.
583 * PF configures interrupt mapping and returns status.
584 * NOTE: due to hardware requirements, all active queues (both TX and RX)
585 * should be mapped to interrupts, even if the driver intends to operate
586 * only in polling mode. In this case the interrupt may be disabled, but
587 * the ITR timer will still run to trigger writebacks.
589 struct virtchnl_vector_map {
598 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_vector_map);
600 struct virtchnl_irq_map_info {
602 struct virtchnl_vector_map vecmap[1];
605 VIRTCHNL_CHECK_STRUCT_LEN(14, virtchnl_irq_map_info);
607 /* VIRTCHNL_OP_ENABLE_QUEUES
608 * VIRTCHNL_OP_DISABLE_QUEUES
609 * VF sends these message to enable or disable TX/RX queue pairs.
610 * The queues fields are bitmaps indicating which queues to act upon.
611 * (Currently, we only support 16 queues per VF, but we make the field
612 * u32 to allow for expansion.)
613 * PF performs requested action and returns status.
614 * NOTE: The VF is not required to enable/disable all queues in a single
615 * request. It may send multiple messages.
616 * PF drivers must correctly handle all VF requests.
618 struct virtchnl_queue_select {
625 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_select);
627 /* VIRTCHNL_OP_GET_MAX_RSS_QREGION
629 * if VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
630 * then this op must be supported.
632 * VF sends this message in order to query the max RSS queue region
633 * size supported by PF, when VIRTCHNL_VF_LARGE_NUM_QPAIRS is enabled.
634 * This information should be used when configuring the RSS LUT and/or
635 * configuring queue region based filters.
637 * The maximum RSS queue region is 2^qregion_width. So, a qregion_width
638 * of 6 would inform the VF that the PF supports a maximum RSS queue region
641 * A queue region represents a range of queues that can be used to configure
642 * a RSS LUT. For example, if a VF is given 64 queues, but only a max queue
643 * region size of 16 (i.e. 2^qregion_width = 16) then it will only be able
644 * to configure the RSS LUT with queue indices from 0 to 15. However, other
645 * filters can be used to direct packets to queues >15 via specifying a queue
646 * base/offset and queue region width.
648 struct virtchnl_max_rss_qregion {
654 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_max_rss_qregion);
656 /* VIRTCHNL_OP_ADD_ETH_ADDR
657 * VF sends this message in order to add one or more unicast or multicast
658 * address filters for the specified VSI.
659 * PF adds the filters and returns status.
662 /* VIRTCHNL_OP_DEL_ETH_ADDR
663 * VF sends this message in order to remove one or more unicast or multicast
664 * filters for the specified VSI.
665 * PF removes the filters and returns status.
668 /* VIRTCHNL_ETHER_ADDR_LEGACY
669 * Prior to adding the @type member to virtchnl_ether_addr, there were 2 pad
670 * bytes. Moving forward all VF drivers should not set type to
671 * VIRTCHNL_ETHER_ADDR_LEGACY. This is only here to not break previous/legacy
672 * behavior. The control plane function (i.e. PF) can use a best effort method
673 * of tracking the primary/device unicast in this case, but there is no
674 * guarantee and functionality depends on the implementation of the PF.
677 /* VIRTCHNL_ETHER_ADDR_PRIMARY
678 * All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_PRIMARY for the
679 * primary/device unicast MAC address filter for VIRTCHNL_OP_ADD_ETH_ADDR and
680 * VIRTCHNL_OP_DEL_ETH_ADDR. This allows for the underlying control plane
681 * function (i.e. PF) to accurately track and use this MAC address for
682 * displaying on the host and for VM/function reset.
685 /* VIRTCHNL_ETHER_ADDR_EXTRA
686 * All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_EXTRA for any extra
687 * unicast and/or multicast filters that are being added/deleted via
688 * VIRTCHNL_OP_DEL_ETH_ADDR/VIRTCHNL_OP_ADD_ETH_ADDR respectively.
690 struct virtchnl_ether_addr {
691 u8 addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
693 #define VIRTCHNL_ETHER_ADDR_LEGACY 0
694 #define VIRTCHNL_ETHER_ADDR_PRIMARY 1
695 #define VIRTCHNL_ETHER_ADDR_EXTRA 2
696 #define VIRTCHNL_ETHER_ADDR_TYPE_MASK 3 /* first two bits of type are valid */
700 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_ether_addr);
702 struct virtchnl_ether_addr_list {
705 struct virtchnl_ether_addr list[1];
708 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_ether_addr_list);
710 /* VIRTCHNL_OP_ADD_VLAN
711 * VF sends this message to add one or more VLAN tag filters for receives.
712 * PF adds the filters and returns status.
713 * If a port VLAN is configured by the PF, this operation will return an
717 /* VIRTCHNL_OP_DEL_VLAN
718 * VF sends this message to remove one or more VLAN tag filters for receives.
719 * PF removes the filters and returns status.
720 * If a port VLAN is configured by the PF, this operation will return an
724 struct virtchnl_vlan_filter_list {
730 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_vlan_filter_list);
732 /* This enum is used for all of the VIRTCHNL_VF_OFFLOAD_VLAN_V2_CAPS related
733 * structures and opcodes.
735 * VIRTCHNL_VLAN_UNSUPPORTED - This field is not supported and if a VF driver
736 * populates it the PF should return VIRTCHNL_STATUS_ERR_NOT_SUPPORTED.
738 * VIRTCHNL_VLAN_ETHERTYPE_8100 - This field supports 0x8100 ethertype.
739 * VIRTCHNL_VLAN_ETHERTYPE_88A8 - This field supports 0x88A8 ethertype.
740 * VIRTCHNL_VLAN_ETHERTYPE_9100 - This field supports 0x9100 ethertype.
742 * VIRTCHNL_VLAN_ETHERTYPE_AND - Used when multiple ethertypes can be supported
743 * by the PF concurrently. For example, if the PF can support
744 * VIRTCHNL_VLAN_ETHERTYPE_8100 AND VIRTCHNL_VLAN_ETHERTYPE_88A8 filters it
745 * would OR the following bits:
747 * VIRTHCNL_VLAN_ETHERTYPE_8100 |
748 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
749 * VIRTCHNL_VLAN_ETHERTYPE_AND;
751 * The VF would interpret this as VLAN filtering can be supported on both 0x8100
752 * and 0x88A8 VLAN ethertypes.
754 * VIRTCHNL_ETHERTYPE_XOR - Used when only a single ethertype can be supported
755 * by the PF concurrently. For example if the PF can support
756 * VIRTCHNL_VLAN_ETHERTYPE_8100 XOR VIRTCHNL_VLAN_ETHERTYPE_88A8 stripping
757 * offload it would OR the following bits:
759 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
760 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
761 * VIRTCHNL_VLAN_ETHERTYPE_XOR;
763 * The VF would interpret this as VLAN stripping can be supported on either
764 * 0x8100 or 0x88a8 VLAN ethertypes. So when requesting VLAN stripping via
765 * VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 the specified ethertype will override
766 * the previously set value.
768 * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1 - Used to tell the VF to insert and/or
769 * strip the VLAN tag using the L2TAG1 field of the Tx/Rx descriptors.
771 * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 - Used to tell the VF to insert hardware
772 * offloaded VLAN tags using the L2TAG2 field of the Tx descriptor.
774 * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 - Used to tell the VF to strip hardware
775 * offloaded VLAN tags using the L2TAG2_2 field of the Rx descriptor.
777 * VIRTCHNL_VLAN_PRIO - This field supports VLAN priority bits. This is used for
778 * VLAN filtering if the underlying PF supports it.
780 * VIRTCHNL_VLAN_TOGGLE_ALLOWED - This field is used to say whether a
781 * certain VLAN capability can be toggled. For example if the underlying PF/CP
782 * allows the VF to toggle VLAN filtering, stripping, and/or insertion it should
783 * set this bit along with the supported ethertypes.
785 enum virtchnl_vlan_support {
786 VIRTCHNL_VLAN_UNSUPPORTED = 0,
787 VIRTCHNL_VLAN_ETHERTYPE_8100 = 0x00000001,
788 VIRTCHNL_VLAN_ETHERTYPE_88A8 = 0x00000002,
789 VIRTCHNL_VLAN_ETHERTYPE_9100 = 0x00000004,
790 VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1 = 0x00000100,
791 VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 = 0x00000200,
792 VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2_2 = 0x00000400,
793 VIRTCHNL_VLAN_PRIO = 0x01000000,
794 VIRTCHNL_VLAN_FILTER_MASK = 0x10000000,
795 VIRTCHNL_VLAN_ETHERTYPE_AND = 0x20000000,
796 VIRTCHNL_VLAN_ETHERTYPE_XOR = 0x40000000,
797 VIRTCHNL_VLAN_TOGGLE = 0x80000000
800 /* This structure is used as part of the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS
801 * for filtering, insertion, and stripping capabilities.
803 * If only outer capabilities are supported (for filtering, insertion, and/or
804 * stripping) then this refers to the outer most or single VLAN from the VF's
807 * If only inner capabilities are supported (for filtering, insertion, and/or
808 * stripping) then this refers to the outer most or single VLAN from the VF's
809 * perspective. Functionally this is the same as if only outer capabilities are
810 * supported. The VF driver is just forced to use the inner fields when
811 * adding/deleting filters and enabling/disabling offloads (if supported).
813 * If both outer and inner capabilities are supported (for filtering, insertion,
814 * and/or stripping) then outer refers to the outer most or single VLAN and
815 * inner refers to the second VLAN, if it exists, in the packet.
817 * There is no support for tunneled VLAN offloads, so outer or inner are never
818 * referring to a tunneled packet from the VF's perspective.
820 struct virtchnl_vlan_supported_caps {
825 /* The PF populates these fields based on the supported VLAN filtering. If a
826 * field is VIRTCHNL_VLAN_UNSUPPORTED then it's not supported and the PF will
827 * reject any VIRTCHNL_OP_ADD_VLAN_V2 or VIRTCHNL_OP_DEL_VLAN_V2 messages using
828 * the unsupported fields.
830 * Also, a VF is only allowed to toggle its VLAN filtering setting if the
831 * VIRTCHNL_VLAN_TOGGLE bit is set.
833 * The ethertype(s) specified in the ethertype_init field are the ethertypes
834 * enabled for VLAN filtering. VLAN filtering in this case refers to the outer
835 * most VLAN from the VF's perspective. If both inner and outer filtering are
836 * allowed then ethertype_init only refers to the outer most VLAN as only
837 * VLAN ethertype supported for inner VLAN filtering is
838 * VIRTCHNL_VLAN_ETHERTYPE_8100. By default, inner VLAN filtering is disabled
839 * when both inner and outer filtering are allowed.
841 * The max_filters field tells the VF how many VLAN filters it's allowed to have
842 * at any one time. If it exceeds this amount and tries to add another filter,
843 * then the request will be rejected by the PF. To prevent failures, the VF
844 * should keep track of how many VLAN filters it has added and not attempt to
845 * add more than max_filters.
847 struct virtchnl_vlan_filtering_caps {
848 struct virtchnl_vlan_supported_caps filtering_support;
854 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vlan_filtering_caps);
856 /* This enum is used for the virtchnl_vlan_offload_caps structure to specify
857 * if the PF supports a different ethertype for stripping and insertion.
859 * VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION - The ethertype(s) specified
860 * for stripping affect the ethertype(s) specified for insertion and visa versa
861 * as well. If the VF tries to configure VLAN stripping via
862 * VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 with VIRTCHNL_VLAN_ETHERTYPE_8100 then
863 * that will be the ethertype for both stripping and insertion.
865 * VIRTCHNL_ETHERTYPE_MATCH_NOT_REQUIRED - The ethertype(s) specified for
866 * stripping do not affect the ethertype(s) specified for insertion and visa
869 enum virtchnl_vlan_ethertype_match {
870 VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION = 0,
871 VIRTCHNL_ETHERTYPE_MATCH_NOT_REQUIRED = 1,
874 /* The PF populates these fields based on the supported VLAN offloads. If a
875 * field is VIRTCHNL_VLAN_UNSUPPORTED then it's not supported and the PF will
876 * reject any VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 or
877 * VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 messages using the unsupported fields.
879 * Also, a VF is only allowed to toggle its VLAN offload setting if the
880 * VIRTCHNL_VLAN_TOGGLE_ALLOWED bit is set.
882 * The VF driver needs to be aware of how the tags are stripped by hardware and
883 * inserted by the VF driver based on the level of offload support. The PF will
884 * populate these fields based on where the VLAN tags are expected to be
885 * offloaded via the VIRTHCNL_VLAN_TAG_LOCATION_* bits. The VF will need to
886 * interpret these fields. See the definition of the
887 * VIRTCHNL_VLAN_TAG_LOCATION_* bits above the virtchnl_vlan_support
890 struct virtchnl_vlan_offload_caps {
891 struct virtchnl_vlan_supported_caps stripping_support;
892 struct virtchnl_vlan_supported_caps insertion_support;
898 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_vlan_offload_caps);
900 /* VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS
901 * VF sends this message to determine its VLAN capabilities.
903 * PF will mark which capabilities it supports based on hardware support and
904 * current configuration. For example, if a port VLAN is configured the PF will
905 * not allow outer VLAN filtering, stripping, or insertion to be configured so
906 * it will block these features from the VF.
908 * The VF will need to cross reference its capabilities with the PFs
909 * capabilities in the response message from the PF to determine the VLAN
912 struct virtchnl_vlan_caps {
913 struct virtchnl_vlan_filtering_caps filtering;
914 struct virtchnl_vlan_offload_caps offloads;
917 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_vlan_caps);
919 struct virtchnl_vlan {
920 u16 tci; /* tci[15:13] = PCP and tci[11:0] = VID */
921 u16 tci_mask; /* only valid if VIRTCHNL_VLAN_FILTER_MASK set in
924 u16 tpid; /* 0x8100, 0x88a8, etc. and only type(s) set in
925 * filtering caps. Note that tpid here does not refer to
926 * VIRTCHNL_VLAN_ETHERTYPE_*, but it refers to the
927 * actual 2-byte VLAN TPID
932 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_vlan);
934 struct virtchnl_vlan_filter {
935 struct virtchnl_vlan inner;
936 struct virtchnl_vlan outer;
940 VIRTCHNL_CHECK_STRUCT_LEN(32, virtchnl_vlan_filter);
942 /* VIRTCHNL_OP_ADD_VLAN_V2
943 * VIRTCHNL_OP_DEL_VLAN_V2
945 * VF sends these messages to add/del one or more VLAN tag filters for Rx
948 * The PF attempts to add the filters and returns status.
950 * The VF should only ever attempt to add/del virtchnl_vlan_filter(s) using the
951 * supported fields negotiated via VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS.
953 struct virtchnl_vlan_filter_list_v2 {
957 struct virtchnl_vlan_filter filters[1];
960 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_vlan_filter_list_v2);
962 /* VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2
963 * VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2
964 * VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2
965 * VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2
967 * VF sends this message to enable or disable VLAN stripping or insertion. It
968 * also needs to specify an ethertype. The VF knows which VLAN ethertypes are
969 * allowed and whether or not it's allowed to enable/disable the specific
970 * offload via the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS message. The VF needs to
971 * parse the virtchnl_vlan_caps.offloads fields to determine which offload
972 * messages are allowed.
974 * For example, if the PF populates the virtchnl_vlan_caps.offloads in the
975 * following manner the VF will be allowed to enable and/or disable 0x8100 inner
976 * VLAN insertion and/or stripping via the opcodes listed above. Inner in this
977 * case means the outer most or single VLAN from the VF's perspective. This is
978 * because no outer offloads are supported. See the comments above the
979 * virtchnl_vlan_supported_caps structure for more details.
981 * virtchnl_vlan_caps.offloads.stripping_support.inner =
982 * VIRTCHNL_VLAN_TOGGLE |
983 * VIRTCHNL_VLAN_ETHERTYPE_8100;
985 * virtchnl_vlan_caps.offloads.insertion_support.inner =
986 * VIRTCHNL_VLAN_TOGGLE |
987 * VIRTCHNL_VLAN_ETHERTYPE_8100;
989 * In order to enable inner (again note that in this case inner is the outer
990 * most or single VLAN from the VF's perspective) VLAN stripping for 0x8100
991 * VLANs, the VF would populate the virtchnl_vlan_setting structure in the
992 * following manner and send the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 message.
994 * virtchnl_vlan_setting.inner_ethertype_setting =
995 * VIRTCHNL_VLAN_ETHERTYPE_8100;
997 * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on
1000 * The reason that VLAN TPID(s) are not being used for the
1001 * outer_ethertype_setting and inner_ethertype_setting fields is because it's
1002 * possible a device could support VLAN insertion and/or stripping offload on
1003 * multiple ethertypes concurrently, so this method allows a VF to request
1004 * multiple ethertypes in one message using the virtchnl_vlan_support
1007 * For example, if the PF populates the virtchnl_vlan_caps.offloads in the
1008 * following manner the VF will be allowed to enable 0x8100 and 0x88a8 outer
1009 * VLAN insertion and stripping simultaneously. The
1010 * virtchnl_vlan_caps.offloads.ethertype_match field will also have to be
1011 * populated based on what the PF can support.
1013 * virtchnl_vlan_caps.offloads.stripping_support.outer =
1014 * VIRTCHNL_VLAN_TOGGLE |
1015 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1016 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
1017 * VIRTCHNL_VLAN_ETHERTYPE_AND;
1019 * virtchnl_vlan_caps.offloads.insertion_support.outer =
1020 * VIRTCHNL_VLAN_TOGGLE |
1021 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1022 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
1023 * VIRTCHNL_VLAN_ETHERTYPE_AND;
1025 * In order to enable outer VLAN stripping for 0x8100 and 0x88a8 VLANs, the VF
1026 * would populate the virthcnl_vlan_offload_structure in the following manner
1027 * and send the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 message.
1029 * virtchnl_vlan_setting.outer_ethertype_setting =
1030 * VIRTHCNL_VLAN_ETHERTYPE_8100 |
1031 * VIRTHCNL_VLAN_ETHERTYPE_88A8;
1033 * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on
1036 * There is also the case where a PF and the underlying hardware can support
1037 * VLAN offloads on multiple ethertypes, but not concurrently. For example, if
1038 * the PF populates the virtchnl_vlan_caps.offloads in the following manner the
1039 * VF will be allowed to enable and/or disable 0x8100 XOR 0x88a8 outer VLAN
1040 * offloads. The ethertypes must match for stripping and insertion.
1042 * virtchnl_vlan_caps.offloads.stripping_support.outer =
1043 * VIRTCHNL_VLAN_TOGGLE |
1044 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1045 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
1046 * VIRTCHNL_VLAN_ETHERTYPE_XOR;
1048 * virtchnl_vlan_caps.offloads.insertion_support.outer =
1049 * VIRTCHNL_VLAN_TOGGLE |
1050 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1051 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
1052 * VIRTCHNL_VLAN_ETHERTYPE_XOR;
1054 * virtchnl_vlan_caps.offloads.ethertype_match =
1055 * VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION;
1057 * In order to enable outer VLAN stripping for 0x88a8 VLANs, the VF would
1058 * populate the virtchnl_vlan_setting structure in the following manner and send
1059 * the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2. Also, this will change the
1060 * ethertype for VLAN insertion if it's enabled. So, for completeness, a
1061 * VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 with the same ethertype should be sent.
1063 * virtchnl_vlan_setting.outer_ethertype_setting = VIRTHCNL_VLAN_ETHERTYPE_88A8;
1065 * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on
1068 * VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2
1069 * VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2
1071 * VF sends this message to enable or disable VLAN filtering. It also needs to
1072 * specify an ethertype. The VF knows which VLAN ethertypes are allowed and
1073 * whether or not it's allowed to enable/disable filtering via the
1074 * VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS message. The VF needs to
1075 * parse the virtchnl_vlan_caps.filtering fields to determine which, if any,
1076 * filtering messages are allowed.
1078 * For example, if the PF populates the virtchnl_vlan_caps.filtering in the
1079 * following manner the VF will be allowed to enable/disable 0x8100 and 0x88a8
1080 * outer VLAN filtering together. Note, that the VIRTCHNL_VLAN_ETHERTYPE_AND
1081 * means that all filtering ethertypes will to be enabled and disabled together
1082 * regardless of the request from the VF. This means that the underlying
1083 * hardware only supports VLAN filtering for all VLAN the specified ethertypes
1086 * virtchnl_vlan_caps.filtering.filtering_support.outer =
1087 * VIRTCHNL_VLAN_TOGGLE |
1088 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1089 * VIRTHCNL_VLAN_ETHERTYPE_88A8 |
1090 * VIRTCHNL_VLAN_ETHERTYPE_9100 |
1091 * VIRTCHNL_VLAN_ETHERTYPE_AND;
1093 * In order to enable outer VLAN filtering for 0x88a8 and 0x8100 VLANs (0x9100
1094 * VLANs aren't supported by the VF driver), the VF would populate the
1095 * virtchnl_vlan_setting structure in the following manner and send the
1096 * VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2. The same message format would be used
1097 * to disable outer VLAN filtering for 0x88a8 and 0x8100 VLANs, but the
1098 * VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2 opcode is used.
1100 * virtchnl_vlan_setting.outer_ethertype_setting =
1101 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1102 * VIRTCHNL_VLAN_ETHERTYPE_88A8;
1105 struct virtchnl_vlan_setting {
1106 u32 outer_ethertype_setting;
1107 u32 inner_ethertype_setting;
1112 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vlan_setting);
1114 /* VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE
1115 * VF sends VSI id and flags.
1116 * PF returns status code in retval.
1117 * Note: we assume that broadcast accept mode is always enabled.
1119 struct virtchnl_promisc_info {
1124 VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_promisc_info);
1126 #define FLAG_VF_UNICAST_PROMISC 0x00000001
1127 #define FLAG_VF_MULTICAST_PROMISC 0x00000002
1129 /* VIRTCHNL_OP_GET_STATS
1130 * VF sends this message to request stats for the selected VSI. VF uses
1131 * the virtchnl_queue_select struct to specify the VSI. The queue_id
1132 * field is ignored by the PF.
1134 * PF replies with struct virtchnl_eth_stats in an external buffer.
1137 struct virtchnl_eth_stats {
1138 u64 rx_bytes; /* received bytes */
1139 u64 rx_unicast; /* received unicast pkts */
1140 u64 rx_multicast; /* received multicast pkts */
1141 u64 rx_broadcast; /* received broadcast pkts */
1143 u64 rx_unknown_protocol;
1144 u64 tx_bytes; /* transmitted bytes */
1145 u64 tx_unicast; /* transmitted unicast pkts */
1146 u64 tx_multicast; /* transmitted multicast pkts */
1147 u64 tx_broadcast; /* transmitted broadcast pkts */
1152 /* VIRTCHNL_OP_CONFIG_RSS_KEY
1153 * VIRTCHNL_OP_CONFIG_RSS_LUT
1154 * VF sends these messages to configure RSS. Only supported if both PF
1155 * and VF drivers set the VIRTCHNL_VF_OFFLOAD_RSS_PF bit during
1156 * configuration negotiation. If this is the case, then the RSS fields in
1157 * the VF resource struct are valid.
1158 * Both the key and LUT are initialized to 0 by the PF, meaning that
1159 * RSS is effectively disabled until set up by the VF.
1161 struct virtchnl_rss_key {
1164 u8 key[1]; /* RSS hash key, packed bytes */
1167 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_rss_key);
1169 struct virtchnl_rss_lut {
1172 u8 lut[1]; /* RSS lookup table */
1175 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_rss_lut);
1177 /* VIRTCHNL_OP_GET_RSS_HENA_CAPS
1178 * VIRTCHNL_OP_SET_RSS_HENA
1179 * VF sends these messages to get and set the hash filter enable bits for RSS.
1180 * By default, the PF sets these to all possible traffic types that the
1181 * hardware supports. The VF can query this value if it wants to change the
1182 * traffic types that are hashed by the hardware.
1184 struct virtchnl_rss_hena {
1188 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_rss_hena);
1190 /* Type of RSS algorithm */
1191 enum virtchnl_rss_algorithm {
1192 VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC = 0,
1193 VIRTCHNL_RSS_ALG_XOR_ASYMMETRIC = 1,
1194 VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC = 2,
1195 VIRTCHNL_RSS_ALG_XOR_SYMMETRIC = 3,
1198 /* This is used by PF driver to enforce how many channels can be supported.
1199 * When ADQ_V2 capability is negotiated, it will allow 16 channels otherwise
1200 * PF driver will allow only max 4 channels
1202 #define VIRTCHNL_MAX_ADQ_CHANNELS 4
1203 #define VIRTCHNL_MAX_ADQ_V2_CHANNELS 16
1205 /* VIRTCHNL_OP_ENABLE_CHANNELS
1206 * VIRTCHNL_OP_DISABLE_CHANNELS
1207 * VF sends these messages to enable or disable channels based on
1208 * the user specified queue count and queue offset for each traffic class.
1209 * This struct encompasses all the information that the PF needs from
1210 * VF to create a channel.
1212 struct virtchnl_channel_info {
1213 u16 count; /* number of queues in a channel */
1214 u16 offset; /* queues in a channel start from 'offset' */
1219 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_channel_info);
1221 struct virtchnl_tc_info {
1224 struct virtchnl_channel_info list[1];
1227 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_tc_info);
1229 /* VIRTCHNL_ADD_CLOUD_FILTER
1230 * VIRTCHNL_DEL_CLOUD_FILTER
1231 * VF sends these messages to add or delete a cloud filter based on the
1232 * user specified match and action filters. These structures encompass
1233 * all the information that the PF needs from the VF to add/delete a
1237 struct virtchnl_l4_spec {
1238 u8 src_mac[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
1239 u8 dst_mac[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
1240 /* vlan_prio is part of this 16 bit field even from OS perspective
1241 * vlan_id:12 is actual vlan_id, then vlanid:bit14..12 is vlan_prio
1242 * in future, when decided to offload vlan_prio, pass that information
1243 * as part of the "vlan_id" field, Bit14..12
1246 __be16 pad; /* reserved for future use */
1253 VIRTCHNL_CHECK_STRUCT_LEN(52, virtchnl_l4_spec);
1255 union virtchnl_flow_spec {
1256 struct virtchnl_l4_spec tcp_spec;
1257 u8 buffer[128]; /* reserved for future use */
1260 VIRTCHNL_CHECK_UNION_LEN(128, virtchnl_flow_spec);
1262 enum virtchnl_action {
1264 VIRTCHNL_ACTION_DROP = 0,
1265 VIRTCHNL_ACTION_TC_REDIRECT,
1266 VIRTCHNL_ACTION_PASSTHRU,
1267 VIRTCHNL_ACTION_QUEUE,
1268 VIRTCHNL_ACTION_Q_REGION,
1269 VIRTCHNL_ACTION_MARK,
1270 VIRTCHNL_ACTION_COUNT,
1273 enum virtchnl_flow_type {
1275 VIRTCHNL_TCP_V4_FLOW = 0,
1276 VIRTCHNL_TCP_V6_FLOW,
1277 VIRTCHNL_UDP_V4_FLOW,
1278 VIRTCHNL_UDP_V6_FLOW,
1281 struct virtchnl_filter {
1282 union virtchnl_flow_spec data;
1283 union virtchnl_flow_spec mask;
1285 /* see enum virtchnl_flow_type */
1288 /* see enum virtchnl_action */
1294 VIRTCHNL_CHECK_STRUCT_LEN(272, virtchnl_filter);
1296 struct virtchnl_shaper_bw {
1302 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_shaper_bw);
1304 /* VIRTCHNL_OP_DCF_GET_VSI_MAP
1305 * VF sends this message to get VSI mapping table.
1306 * PF responds with an indirect message containing VF's
1308 * The index of vf_vsi array is the logical VF ID, the
1309 * value of vf_vsi array is the VF's HW VSI ID with its
1310 * valid configuration.
1312 struct virtchnl_dcf_vsi_map {
1313 u16 pf_vsi; /* PF's HW VSI ID */
1314 u16 num_vfs; /* The actual number of VFs allocated */
1315 #define VIRTCHNL_DCF_VF_VSI_ID_S 0
1316 #define VIRTCHNL_DCF_VF_VSI_ID_M (0xFFF << VIRTCHNL_DCF_VF_VSI_ID_S)
1317 #define VIRTCHNL_DCF_VF_VSI_VALID BIT(15)
1321 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_dcf_vsi_map);
1323 #define PKG_NAME_SIZE 32
1326 struct pkg_version {
1333 VIRTCHNL_CHECK_STRUCT_LEN(4, pkg_version);
1335 struct virtchnl_pkg_info {
1336 struct pkg_version pkg_ver;
1338 char pkg_name[PKG_NAME_SIZE];
1342 VIRTCHNL_CHECK_STRUCT_LEN(48, virtchnl_pkg_info);
1344 /* VIRTCHNL_OP_DCF_VLAN_OFFLOAD
1345 * DCF negotiates the VIRTCHNL_VF_OFFLOAD_VLAN_V2 capability firstly to get
1346 * the double VLAN configuration, then DCF sends this message to configure the
1347 * outer or inner VLAN offloads (insertion and strip) for the target VF.
1349 struct virtchnl_dcf_vlan_offload {
1353 #define VIRTCHNL_DCF_VLAN_TYPE_S 0
1354 #define VIRTCHNL_DCF_VLAN_TYPE_M \
1355 (0x1 << VIRTCHNL_DCF_VLAN_TYPE_S)
1356 #define VIRTCHNL_DCF_VLAN_TYPE_INNER 0x0
1357 #define VIRTCHNL_DCF_VLAN_TYPE_OUTER 0x1
1358 #define VIRTCHNL_DCF_VLAN_INSERT_MODE_S 1
1359 #define VIRTCHNL_DCF_VLAN_INSERT_MODE_M \
1360 (0x7 << VIRTCHNL_DCF_VLAN_INSERT_MODE_S)
1361 #define VIRTCHNL_DCF_VLAN_INSERT_DISABLE 0x1
1362 #define VIRTCHNL_DCF_VLAN_INSERT_PORT_BASED 0x2
1363 #define VIRTCHNL_DCF_VLAN_INSERT_VIA_TX_DESC 0x3
1364 #define VIRTCHNL_DCF_VLAN_STRIP_MODE_S 4
1365 #define VIRTCHNL_DCF_VLAN_STRIP_MODE_M \
1366 (0x7 << VIRTCHNL_DCF_VLAN_STRIP_MODE_S)
1367 #define VIRTCHNL_DCF_VLAN_STRIP_DISABLE 0x1
1368 #define VIRTCHNL_DCF_VLAN_STRIP_ONLY 0x2
1369 #define VIRTCHNL_DCF_VLAN_STRIP_INTO_RX_DESC 0x3
1374 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_dcf_vlan_offload);
1376 struct virtchnl_dcf_bw_cfg {
1378 #define VIRTCHNL_DCF_BW_CIR BIT(0)
1379 #define VIRTCHNL_DCF_BW_PIR BIT(1)
1382 enum virtchnl_bw_limit_type type;
1384 struct virtchnl_shaper_bw shaper;
1389 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_dcf_bw_cfg);
1391 /* VIRTCHNL_OP_DCF_CONFIG_BW
1392 * VF send this message to set the bandwidth configuration of each
1393 * TC with a specific vf id. The flag node_type is to indicate that
1394 * this message is to configure VSI node or TC node bandwidth.
1396 struct virtchnl_dcf_bw_cfg_list {
1399 #define VIRTCHNL_DCF_TARGET_TC_BW 0
1400 #define VIRTCHNL_DCF_TARGET_VF_BW 1
1402 struct virtchnl_dcf_bw_cfg cfg[1];
1405 VIRTCHNL_CHECK_STRUCT_LEN(44, virtchnl_dcf_bw_cfg_list);
1407 struct virtchnl_supported_rxdids {
1408 /* see enum virtchnl_rx_desc_id_bitmasks */
1409 u64 supported_rxdids;
1412 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_supported_rxdids);
1414 /* VIRTCHNL_OP_EVENT
1415 * PF sends this message to inform the VF driver of events that may affect it.
1416 * No direct response is expected from the VF, though it may generate other
1417 * messages in response to this one.
1419 enum virtchnl_event_codes {
1420 VIRTCHNL_EVENT_UNKNOWN = 0,
1421 VIRTCHNL_EVENT_LINK_CHANGE,
1422 VIRTCHNL_EVENT_RESET_IMPENDING,
1423 VIRTCHNL_EVENT_PF_DRIVER_CLOSE,
1424 VIRTCHNL_EVENT_DCF_VSI_MAP_UPDATE,
1427 #define PF_EVENT_SEVERITY_INFO 0
1428 #define PF_EVENT_SEVERITY_ATTENTION 1
1429 #define PF_EVENT_SEVERITY_ACTION_REQUIRED 2
1430 #define PF_EVENT_SEVERITY_CERTAIN_DOOM 255
1432 struct virtchnl_pf_event {
1433 /* see enum virtchnl_event_codes */
1436 /* If the PF driver does not support the new speed reporting
1437 * capabilities then use link_event else use link_event_adv to
1438 * get the speed and link information. The ability to understand
1439 * new speeds is indicated by setting the capability flag
1440 * VIRTCHNL_VF_CAP_ADV_LINK_SPEED in vf_cap_flags parameter
1441 * in virtchnl_vf_resource struct and can be used to determine
1442 * which link event struct to use below.
1445 enum virtchnl_link_speed link_speed;
1449 /* link_speed provided in Mbps */
1462 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_pf_event);
1465 /* VF reset states - these are written into the RSTAT register:
1466 * VFGEN_RSTAT on the VF
1467 * When the PF initiates a reset, it writes 0
1468 * When the reset is complete, it writes 1
1469 * When the PF detects that the VF has recovered, it writes 2
1470 * VF checks this register periodically to determine if a reset has occurred,
1471 * then polls it to know when the reset is complete.
1472 * If either the PF or VF reads the register while the hardware
1473 * is in a reset state, it will return DEADBEEF, which, when masked
1476 enum virtchnl_vfr_states {
1477 VIRTCHNL_VFR_INPROGRESS = 0,
1478 VIRTCHNL_VFR_COMPLETED,
1479 VIRTCHNL_VFR_VFACTIVE,
1482 #define VIRTCHNL_MAX_NUM_PROTO_HDRS 32
1483 #define PROTO_HDR_SHIFT 5
1484 #define PROTO_HDR_FIELD_START(proto_hdr_type) \
1485 (proto_hdr_type << PROTO_HDR_SHIFT)
1486 #define PROTO_HDR_FIELD_MASK ((1UL << PROTO_HDR_SHIFT) - 1)
1488 /* VF use these macros to configure each protocol header.
1489 * Specify which protocol headers and protocol header fields base on
1490 * virtchnl_proto_hdr_type and virtchnl_proto_hdr_field.
1491 * @param hdr: a struct of virtchnl_proto_hdr
1492 * @param hdr_type: ETH/IPV4/TCP, etc
1493 * @param field: SRC/DST/TEID/SPI, etc
1495 #define VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, field) \
1496 ((hdr)->field_selector |= BIT((field) & PROTO_HDR_FIELD_MASK))
1497 #define VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, field) \
1498 ((hdr)->field_selector &= ~BIT((field) & PROTO_HDR_FIELD_MASK))
1499 #define VIRTCHNL_TEST_PROTO_HDR_FIELD(hdr, val) \
1500 ((hdr)->field_selector & BIT((val) & PROTO_HDR_FIELD_MASK))
1501 #define VIRTCHNL_GET_PROTO_HDR_FIELD(hdr) ((hdr)->field_selector)
1503 #define VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \
1504 (VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, \
1505 VIRTCHNL_PROTO_HDR_ ## hdr_type ## _ ## field))
1506 #define VIRTCHNL_DEL_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \
1507 (VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, \
1508 VIRTCHNL_PROTO_HDR_ ## hdr_type ## _ ## field))
1510 #define VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, hdr_type) \
1511 ((hdr)->type = VIRTCHNL_PROTO_HDR_ ## hdr_type)
1512 #define VIRTCHNL_GET_PROTO_HDR_TYPE(hdr) \
1513 (((hdr)->type) >> PROTO_HDR_SHIFT)
1514 #define VIRTCHNL_TEST_PROTO_HDR_TYPE(hdr, val) \
1515 ((hdr)->type == ((val) >> PROTO_HDR_SHIFT))
1516 #define VIRTCHNL_TEST_PROTO_HDR(hdr, val) \
1517 (VIRTCHNL_TEST_PROTO_HDR_TYPE(hdr, val) && \
1518 VIRTCHNL_TEST_PROTO_HDR_FIELD(hdr, val))
1520 /* Protocol header type within a packet segment. A segment consists of one or
1521 * more protocol headers that make up a logical group of protocol headers. Each
1522 * logical group of protocol headers encapsulates or is encapsulated using/by
1523 * tunneling or encapsulation protocols for network virtualization.
1525 enum virtchnl_proto_hdr_type {
1526 VIRTCHNL_PROTO_HDR_NONE,
1527 VIRTCHNL_PROTO_HDR_ETH,
1528 VIRTCHNL_PROTO_HDR_S_VLAN,
1529 VIRTCHNL_PROTO_HDR_C_VLAN,
1530 VIRTCHNL_PROTO_HDR_IPV4,
1531 VIRTCHNL_PROTO_HDR_IPV6,
1532 VIRTCHNL_PROTO_HDR_TCP,
1533 VIRTCHNL_PROTO_HDR_UDP,
1534 VIRTCHNL_PROTO_HDR_SCTP,
1535 VIRTCHNL_PROTO_HDR_GTPU_IP,
1536 VIRTCHNL_PROTO_HDR_GTPU_EH,
1537 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN,
1538 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP,
1539 VIRTCHNL_PROTO_HDR_PPPOE,
1540 VIRTCHNL_PROTO_HDR_L2TPV3,
1541 VIRTCHNL_PROTO_HDR_ESP,
1542 VIRTCHNL_PROTO_HDR_AH,
1543 VIRTCHNL_PROTO_HDR_PFCP,
1544 VIRTCHNL_PROTO_HDR_GTPC,
1545 VIRTCHNL_PROTO_HDR_ECPRI,
1546 VIRTCHNL_PROTO_HDR_L2TPV2,
1547 VIRTCHNL_PROTO_HDR_PPP,
1548 /* IPv4 and IPv6 Fragment header types are only associated to
1549 * VIRTCHNL_PROTO_HDR_IPV4 and VIRTCHNL_PROTO_HDR_IPV6 respectively,
1550 * cannot be used independently.
1552 VIRTCHNL_PROTO_HDR_IPV4_FRAG,
1553 VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG,
1554 VIRTCHNL_PROTO_HDR_GRE,
1557 /* Protocol header field within a protocol header. */
1558 enum virtchnl_proto_hdr_field {
1560 VIRTCHNL_PROTO_HDR_ETH_SRC =
1561 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ETH),
1562 VIRTCHNL_PROTO_HDR_ETH_DST,
1563 VIRTCHNL_PROTO_HDR_ETH_ETHERTYPE,
1565 VIRTCHNL_PROTO_HDR_S_VLAN_ID =
1566 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_S_VLAN),
1568 VIRTCHNL_PROTO_HDR_C_VLAN_ID =
1569 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_C_VLAN),
1571 VIRTCHNL_PROTO_HDR_IPV4_SRC =
1572 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV4),
1573 VIRTCHNL_PROTO_HDR_IPV4_DST,
1574 VIRTCHNL_PROTO_HDR_IPV4_DSCP,
1575 VIRTCHNL_PROTO_HDR_IPV4_TTL,
1576 VIRTCHNL_PROTO_HDR_IPV4_PROT,
1578 VIRTCHNL_PROTO_HDR_IPV6_SRC =
1579 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV6),
1580 VIRTCHNL_PROTO_HDR_IPV6_DST,
1581 VIRTCHNL_PROTO_HDR_IPV6_TC,
1582 VIRTCHNL_PROTO_HDR_IPV6_HOP_LIMIT,
1583 VIRTCHNL_PROTO_HDR_IPV6_PROT,
1585 VIRTCHNL_PROTO_HDR_IPV6_PREFIX32_SRC,
1586 VIRTCHNL_PROTO_HDR_IPV6_PREFIX32_DST,
1587 VIRTCHNL_PROTO_HDR_IPV6_PREFIX40_SRC,
1588 VIRTCHNL_PROTO_HDR_IPV6_PREFIX40_DST,
1589 VIRTCHNL_PROTO_HDR_IPV6_PREFIX48_SRC,
1590 VIRTCHNL_PROTO_HDR_IPV6_PREFIX48_DST,
1591 VIRTCHNL_PROTO_HDR_IPV6_PREFIX56_SRC,
1592 VIRTCHNL_PROTO_HDR_IPV6_PREFIX56_DST,
1593 VIRTCHNL_PROTO_HDR_IPV6_PREFIX64_SRC,
1594 VIRTCHNL_PROTO_HDR_IPV6_PREFIX64_DST,
1595 VIRTCHNL_PROTO_HDR_IPV6_PREFIX96_SRC,
1596 VIRTCHNL_PROTO_HDR_IPV6_PREFIX96_DST,
1598 VIRTCHNL_PROTO_HDR_TCP_SRC_PORT =
1599 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_TCP),
1600 VIRTCHNL_PROTO_HDR_TCP_DST_PORT,
1602 VIRTCHNL_PROTO_HDR_UDP_SRC_PORT =
1603 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_UDP),
1604 VIRTCHNL_PROTO_HDR_UDP_DST_PORT,
1606 VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT =
1607 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_SCTP),
1608 VIRTCHNL_PROTO_HDR_SCTP_DST_PORT,
1610 VIRTCHNL_PROTO_HDR_GTPU_IP_TEID =
1611 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_IP),
1613 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU =
1614 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH),
1615 VIRTCHNL_PROTO_HDR_GTPU_EH_QFI,
1617 VIRTCHNL_PROTO_HDR_PPPOE_SESS_ID =
1618 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_PPPOE),
1620 VIRTCHNL_PROTO_HDR_L2TPV3_SESS_ID =
1621 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_L2TPV3),
1623 VIRTCHNL_PROTO_HDR_ESP_SPI =
1624 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ESP),
1626 VIRTCHNL_PROTO_HDR_AH_SPI =
1627 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_AH),
1629 VIRTCHNL_PROTO_HDR_PFCP_S_FIELD =
1630 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_PFCP),
1631 VIRTCHNL_PROTO_HDR_PFCP_SEID,
1633 VIRTCHNL_PROTO_HDR_GTPC_TEID =
1634 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPC),
1636 VIRTCHNL_PROTO_HDR_ECPRI_MSG_TYPE =
1637 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ECPRI),
1638 VIRTCHNL_PROTO_HDR_ECPRI_PC_RTC_ID,
1639 /* IPv4 Dummy Fragment */
1640 VIRTCHNL_PROTO_HDR_IPV4_FRAG_PKID =
1641 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV4_FRAG),
1642 /* IPv6 Extension Fragment */
1643 VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG_PKID =
1644 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG),
1647 struct virtchnl_proto_hdr {
1648 /* see enum virtchnl_proto_hdr_type */
1650 u32 field_selector; /* a bit mask to select field for header type */
1653 * binary buffer in network order for specific header type.
1654 * For example, if type = VIRTCHNL_PROTO_HDR_IPV4, a IPv4
1655 * header is expected to be copied into the buffer.
1659 VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_proto_hdr);
1661 struct virtchnl_proto_hdrs {
1664 * specify where protocol header start from.
1665 * 0 - from the outer layer
1666 * 1 - from the first inner layer
1667 * 2 - from the second inner layer
1670 int count; /* the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS */
1671 struct virtchnl_proto_hdr proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
1674 VIRTCHNL_CHECK_STRUCT_LEN(2312, virtchnl_proto_hdrs);
1676 struct virtchnl_rss_cfg {
1677 struct virtchnl_proto_hdrs proto_hdrs; /* protocol headers */
1679 /* see enum virtchnl_rss_algorithm; rss algorithm type */
1681 u8 reserved[128]; /* reserve for future */
1684 VIRTCHNL_CHECK_STRUCT_LEN(2444, virtchnl_rss_cfg);
1686 /* action configuration for FDIR */
1687 struct virtchnl_filter_action {
1688 /* see enum virtchnl_action type */
1691 /* used for queue and qgroup action */
1696 /* used for count action */
1698 /* share counter ID with other flow rules */
1700 u32 id; /* counter ID */
1702 /* used for mark action */
1708 VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_filter_action);
1710 #define VIRTCHNL_MAX_NUM_ACTIONS 8
1712 struct virtchnl_filter_action_set {
1713 /* action number must be less then VIRTCHNL_MAX_NUM_ACTIONS */
1715 struct virtchnl_filter_action actions[VIRTCHNL_MAX_NUM_ACTIONS];
1718 VIRTCHNL_CHECK_STRUCT_LEN(292, virtchnl_filter_action_set);
1720 /* pattern and action for FDIR rule */
1721 struct virtchnl_fdir_rule {
1722 struct virtchnl_proto_hdrs proto_hdrs;
1723 struct virtchnl_filter_action_set action_set;
1726 VIRTCHNL_CHECK_STRUCT_LEN(2604, virtchnl_fdir_rule);
1728 /* query information to retrieve fdir rule counters.
1729 * PF will fill out this structure to reset counter.
1731 struct virtchnl_fdir_query_info {
1732 u32 match_packets_valid:1;
1733 u32 match_bytes_valid:1;
1734 u32 reserved:30; /* Reserved, must be zero. */
1736 u64 matched_packets; /* Number of packets for this rule. */
1737 u64 matched_bytes; /* Number of bytes through this rule. */
1740 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_fdir_query_info);
1742 /* Status returned to VF after VF requests FDIR commands
1743 * VIRTCHNL_FDIR_SUCCESS
1744 * VF FDIR related request is successfully done by PF
1745 * The request can be OP_ADD/DEL/QUERY_FDIR_FILTER.
1747 * VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE
1748 * OP_ADD_FDIR_FILTER request is failed due to no Hardware resource.
1750 * VIRTCHNL_FDIR_FAILURE_RULE_EXIST
1751 * OP_ADD_FDIR_FILTER request is failed due to the rule is already existed.
1753 * VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT
1754 * OP_ADD_FDIR_FILTER request is failed due to conflict with existing rule.
1756 * VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST
1757 * OP_DEL_FDIR_FILTER request is failed due to this rule doesn't exist.
1759 * VIRTCHNL_FDIR_FAILURE_RULE_INVALID
1760 * OP_ADD_FDIR_FILTER request is failed due to parameters validation
1761 * or HW doesn't support.
1763 * VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT
1764 * OP_ADD/DEL_FDIR_FILTER request is failed due to timing out
1767 * VIRTCHNL_FDIR_FAILURE_QUERY_INVALID
1768 * OP_QUERY_FDIR_FILTER request is failed due to parameters validation,
1769 * for example, VF query counter of a rule who has no counter action.
1771 enum virtchnl_fdir_prgm_status {
1772 VIRTCHNL_FDIR_SUCCESS = 0,
1773 VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE,
1774 VIRTCHNL_FDIR_FAILURE_RULE_EXIST,
1775 VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT,
1776 VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST,
1777 VIRTCHNL_FDIR_FAILURE_RULE_INVALID,
1778 VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT,
1779 VIRTCHNL_FDIR_FAILURE_QUERY_INVALID,
1782 /* VIRTCHNL_OP_ADD_FDIR_FILTER
1783 * VF sends this request to PF by filling out vsi_id,
1784 * validate_only and rule_cfg. PF will return flow_id
1785 * if the request is successfully done and return add_status to VF.
1787 struct virtchnl_fdir_add {
1788 u16 vsi_id; /* INPUT */
1790 * 1 for validating a fdir rule, 0 for creating a fdir rule.
1791 * Validate and create share one ops: VIRTCHNL_OP_ADD_FDIR_FILTER.
1793 u16 validate_only; /* INPUT */
1794 u32 flow_id; /* OUTPUT */
1795 struct virtchnl_fdir_rule rule_cfg; /* INPUT */
1797 /* see enum virtchnl_fdir_prgm_status; OUTPUT */
1801 VIRTCHNL_CHECK_STRUCT_LEN(2616, virtchnl_fdir_add);
1803 /* VIRTCHNL_OP_DEL_FDIR_FILTER
1804 * VF sends this request to PF by filling out vsi_id
1805 * and flow_id. PF will return del_status to VF.
1807 struct virtchnl_fdir_del {
1808 u16 vsi_id; /* INPUT */
1810 u32 flow_id; /* INPUT */
1812 /* see enum virtchnl_fdir_prgm_status; OUTPUT */
1816 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del);
1818 /* VIRTCHNL_OP_GET_QOS_CAPS
1819 * VF sends this message to get its QoS Caps, such as
1820 * TC number, Arbiter and Bandwidth.
1822 struct virtchnl_qos_cap_elem {
1825 #define VIRTCHNL_ABITER_STRICT 0
1826 #define VIRTCHNL_ABITER_ETS 2
1828 #define VIRTCHNL_STRICT_WEIGHT 1
1830 enum virtchnl_bw_limit_type type;
1832 struct virtchnl_shaper_bw shaper;
1837 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_qos_cap_elem);
1839 struct virtchnl_qos_cap_list {
1842 struct virtchnl_qos_cap_elem cap[1];
1845 VIRTCHNL_CHECK_STRUCT_LEN(44, virtchnl_qos_cap_list);
1847 /* VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP
1848 * VF sends message virtchnl_queue_tc_mapping to set queue to tc
1849 * mapping for all the Tx and Rx queues with a specified VSI, and
1850 * would get response about bitmap of valid user priorities
1851 * associated with queues.
1853 struct virtchnl_queue_tc_mapping {
1856 u16 num_queue_pairs;
1864 #define VIRTCHNL_USER_PRIO_TYPE_UP 0
1865 #define VIRTCHNL_USER_PRIO_TYPE_DSCP 1
1867 u16 valid_prio_bitmap;
1872 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_tc_mapping);
1874 /* VIRTCHNL_OP_QUERY_FDIR_FILTER
1875 * VF sends this request to PF by filling out vsi_id,
1876 * flow_id and reset_counter. PF will return query_info
1877 * and query_status to VF.
1879 struct virtchnl_fdir_query {
1880 u16 vsi_id; /* INPUT */
1882 u32 flow_id; /* INPUT */
1883 u32 reset_counter:1; /* INPUT */
1884 struct virtchnl_fdir_query_info query_info; /* OUTPUT */
1886 /* see enum virtchnl_fdir_prgm_status; OUTPUT */
1891 VIRTCHNL_CHECK_STRUCT_LEN(48, virtchnl_fdir_query);
1893 /* TX and RX queue types are valid in legacy as well as split queue models.
1894 * With Split Queue model, 2 additional types are introduced - TX_COMPLETION
1895 * and RX_BUFFER. In split queue model, RX corresponds to the queue where HW
1896 * posts completions.
1898 enum virtchnl_queue_type {
1899 VIRTCHNL_QUEUE_TYPE_TX = 0,
1900 VIRTCHNL_QUEUE_TYPE_RX = 1,
1901 VIRTCHNL_QUEUE_TYPE_TX_COMPLETION = 2,
1902 VIRTCHNL_QUEUE_TYPE_RX_BUFFER = 3,
1903 VIRTCHNL_QUEUE_TYPE_CONFIG_TX = 4,
1904 VIRTCHNL_QUEUE_TYPE_CONFIG_RX = 5
1908 /* structure to specify a chunk of contiguous queues */
1909 struct virtchnl_queue_chunk {
1910 /* see enum virtchnl_queue_type */
1916 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_queue_chunk);
1918 /* structure to specify several chunks of contiguous queues */
1919 struct virtchnl_queue_chunks {
1922 struct virtchnl_queue_chunk chunks[1];
1925 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_chunks);
1928 /* VIRTCHNL_OP_ENABLE_QUEUES_V2
1929 * VIRTCHNL_OP_DISABLE_QUEUES_V2
1930 * VIRTCHNL_OP_DEL_QUEUES
1932 * If VIRTCHNL_CAP_EXT_FEATURES was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
1933 * then all of these ops are available.
1935 * If VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
1936 * then VIRTCHNL_OP_ENABLE_QUEUES_V2 and VIRTCHNL_OP_DISABLE_QUEUES_V2 are
1939 * PF sends these messages to enable, disable or delete queues specified in
1940 * chunks. PF sends virtchnl_del_ena_dis_queues struct to specify the queues
1941 * to be enabled/disabled/deleted. Also applicable to single queue RX or
1942 * TX. CP performs requested action and returns status.
1944 struct virtchnl_del_ena_dis_queues {
1947 struct virtchnl_queue_chunks chunks;
1950 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_del_ena_dis_queues);
1952 /* Virtchannel interrupt throttling rate index */
1953 enum virtchnl_itr_idx {
1954 VIRTCHNL_ITR_IDX_0 = 0,
1955 VIRTCHNL_ITR_IDX_1 = 1,
1956 VIRTCHNL_ITR_IDX_NO_ITR = 3,
1959 /* Queue to vector mapping */
1960 struct virtchnl_queue_vector {
1965 /* see enum virtchnl_itr_idx */
1968 /* see enum virtchnl_queue_type */
1972 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_queue_vector);
1974 /* VIRTCHNL_OP_MAP_QUEUE_VECTOR
1975 * VIRTCHNL_OP_UNMAP_QUEUE_VECTOR
1977 * If VIRTCHNL_CAP_EXT_FEATURES was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
1978 * then all of these ops are available.
1980 * If VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
1981 * then only VIRTCHNL_OP_MAP_QUEUE_VECTOR is available.
1983 * PF sends this message to map or unmap queues to vectors and ITR index
1984 * registers. External data buffer contains virtchnl_queue_vector_maps structure
1985 * that contains num_qv_maps of virtchnl_queue_vector structures.
1986 * CP maps the requested queue vector maps after validating the queue and vector
1987 * ids and returns a status code.
1989 struct virtchnl_queue_vector_maps {
1993 struct virtchnl_queue_vector qv_maps[1];
1996 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_queue_vector_maps);
1999 /* Since VF messages are limited by u16 size, precalculate the maximum possible
2000 * values of nested elements in virtchnl structures that virtual channel can
2001 * possibly handle in a single message.
2003 enum virtchnl_vector_limits {
2004 VIRTCHNL_OP_CONFIG_VSI_QUEUES_MAX =
2005 ((u16)(~0) - sizeof(struct virtchnl_vsi_queue_config_info)) /
2006 sizeof(struct virtchnl_queue_pair_info),
2008 VIRTCHNL_OP_CONFIG_IRQ_MAP_MAX =
2009 ((u16)(~0) - sizeof(struct virtchnl_irq_map_info)) /
2010 sizeof(struct virtchnl_vector_map),
2012 VIRTCHNL_OP_ADD_DEL_ETH_ADDR_MAX =
2013 ((u16)(~0) - sizeof(struct virtchnl_ether_addr_list)) /
2014 sizeof(struct virtchnl_ether_addr),
2016 VIRTCHNL_OP_ADD_DEL_VLAN_MAX =
2017 ((u16)(~0) - sizeof(struct virtchnl_vlan_filter_list)) /
2021 VIRTCHNL_OP_ENABLE_CHANNELS_MAX =
2022 ((u16)(~0) - sizeof(struct virtchnl_tc_info)) /
2023 sizeof(struct virtchnl_channel_info),
2025 VIRTCHNL_OP_ENABLE_DISABLE_DEL_QUEUES_V2_MAX =
2026 ((u16)(~0) - sizeof(struct virtchnl_del_ena_dis_queues)) /
2027 sizeof(struct virtchnl_queue_chunk),
2029 VIRTCHNL_OP_MAP_UNMAP_QUEUE_VECTOR_MAX =
2030 ((u16)(~0) - sizeof(struct virtchnl_queue_vector_maps)) /
2031 sizeof(struct virtchnl_queue_vector),
2033 VIRTCHNL_OP_ADD_DEL_VLAN_V2_MAX =
2034 ((u16)(~0) - sizeof(struct virtchnl_vlan_filter_list_v2)) /
2035 sizeof(struct virtchnl_vlan_filter),
2039 * virtchnl_vc_validate_vf_msg
2040 * @ver: Virtchnl version info
2041 * @v_opcode: Opcode for the message
2042 * @msg: pointer to the msg buffer
2043 * @msglen: msg length
2045 * validate msg format against struct for each opcode
2048 virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
2049 u8 *msg, u16 msglen)
2051 bool err_msg_format = false;
2054 /* Validate message length. */
2056 case VIRTCHNL_OP_VERSION:
2057 valid_len = sizeof(struct virtchnl_version_info);
2059 case VIRTCHNL_OP_RESET_VF:
2061 case VIRTCHNL_OP_GET_VF_RESOURCES:
2063 valid_len = sizeof(u32);
2065 case VIRTCHNL_OP_CONFIG_TX_QUEUE:
2066 valid_len = sizeof(struct virtchnl_txq_info);
2068 case VIRTCHNL_OP_CONFIG_RX_QUEUE:
2069 valid_len = sizeof(struct virtchnl_rxq_info);
2071 case VIRTCHNL_OP_CONFIG_VSI_QUEUES:
2072 valid_len = sizeof(struct virtchnl_vsi_queue_config_info);
2073 if (msglen >= valid_len) {
2074 struct virtchnl_vsi_queue_config_info *vqc =
2075 (struct virtchnl_vsi_queue_config_info *)msg;
2077 if (vqc->num_queue_pairs == 0 || vqc->num_queue_pairs >
2078 VIRTCHNL_OP_CONFIG_VSI_QUEUES_MAX) {
2079 err_msg_format = true;
2083 valid_len += (vqc->num_queue_pairs *
2085 virtchnl_queue_pair_info));
2088 case VIRTCHNL_OP_CONFIG_IRQ_MAP:
2089 valid_len = sizeof(struct virtchnl_irq_map_info);
2090 if (msglen >= valid_len) {
2091 struct virtchnl_irq_map_info *vimi =
2092 (struct virtchnl_irq_map_info *)msg;
2094 if (vimi->num_vectors == 0 || vimi->num_vectors >
2095 VIRTCHNL_OP_CONFIG_IRQ_MAP_MAX) {
2096 err_msg_format = true;
2100 valid_len += (vimi->num_vectors *
2101 sizeof(struct virtchnl_vector_map));
2104 case VIRTCHNL_OP_ENABLE_QUEUES:
2105 case VIRTCHNL_OP_DISABLE_QUEUES:
2106 valid_len = sizeof(struct virtchnl_queue_select);
2108 case VIRTCHNL_OP_GET_MAX_RSS_QREGION:
2110 case VIRTCHNL_OP_ADD_ETH_ADDR:
2111 case VIRTCHNL_OP_DEL_ETH_ADDR:
2112 valid_len = sizeof(struct virtchnl_ether_addr_list);
2113 if (msglen >= valid_len) {
2114 struct virtchnl_ether_addr_list *veal =
2115 (struct virtchnl_ether_addr_list *)msg;
2117 if (veal->num_elements == 0 || veal->num_elements >
2118 VIRTCHNL_OP_ADD_DEL_ETH_ADDR_MAX) {
2119 err_msg_format = true;
2123 valid_len += veal->num_elements *
2124 sizeof(struct virtchnl_ether_addr);
2127 case VIRTCHNL_OP_ADD_VLAN:
2128 case VIRTCHNL_OP_DEL_VLAN:
2129 valid_len = sizeof(struct virtchnl_vlan_filter_list);
2130 if (msglen >= valid_len) {
2131 struct virtchnl_vlan_filter_list *vfl =
2132 (struct virtchnl_vlan_filter_list *)msg;
2134 if (vfl->num_elements == 0 || vfl->num_elements >
2135 VIRTCHNL_OP_ADD_DEL_VLAN_MAX) {
2136 err_msg_format = true;
2140 valid_len += vfl->num_elements * sizeof(u16);
2143 case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE:
2144 valid_len = sizeof(struct virtchnl_promisc_info);
2146 case VIRTCHNL_OP_GET_STATS:
2147 valid_len = sizeof(struct virtchnl_queue_select);
2149 case VIRTCHNL_OP_CONFIG_RSS_KEY:
2150 valid_len = sizeof(struct virtchnl_rss_key);
2151 if (msglen >= valid_len) {
2152 struct virtchnl_rss_key *vrk =
2153 (struct virtchnl_rss_key *)msg;
2155 if (vrk->key_len == 0) {
2156 /* zero length is allowed as input */
2160 valid_len += vrk->key_len - 1;
2163 case VIRTCHNL_OP_CONFIG_RSS_LUT:
2164 valid_len = sizeof(struct virtchnl_rss_lut);
2165 if (msglen >= valid_len) {
2166 struct virtchnl_rss_lut *vrl =
2167 (struct virtchnl_rss_lut *)msg;
2169 if (vrl->lut_entries == 0) {
2170 /* zero entries is allowed as input */
2174 valid_len += vrl->lut_entries - 1;
2177 case VIRTCHNL_OP_GET_RSS_HENA_CAPS:
2179 case VIRTCHNL_OP_SET_RSS_HENA:
2180 valid_len = sizeof(struct virtchnl_rss_hena);
2182 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING:
2183 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING:
2185 case VIRTCHNL_OP_REQUEST_QUEUES:
2186 valid_len = sizeof(struct virtchnl_vf_res_request);
2188 case VIRTCHNL_OP_ENABLE_CHANNELS:
2189 valid_len = sizeof(struct virtchnl_tc_info);
2190 if (msglen >= valid_len) {
2191 struct virtchnl_tc_info *vti =
2192 (struct virtchnl_tc_info *)msg;
2194 if (vti->num_tc == 0 || vti->num_tc >
2195 VIRTCHNL_OP_ENABLE_CHANNELS_MAX) {
2196 err_msg_format = true;
2200 valid_len += (vti->num_tc - 1) *
2201 sizeof(struct virtchnl_channel_info);
2204 case VIRTCHNL_OP_DISABLE_CHANNELS:
2206 case VIRTCHNL_OP_ADD_CLOUD_FILTER:
2207 case VIRTCHNL_OP_DEL_CLOUD_FILTER:
2208 valid_len = sizeof(struct virtchnl_filter);
2210 case VIRTCHNL_OP_DCF_VLAN_OFFLOAD:
2211 valid_len = sizeof(struct virtchnl_dcf_vlan_offload);
2213 case VIRTCHNL_OP_DCF_CMD_DESC:
2214 case VIRTCHNL_OP_DCF_CMD_BUFF:
2215 /* These two opcodes are specific to handle the AdminQ command,
2216 * so the validation needs to be done in PF's context.
2220 case VIRTCHNL_OP_DCF_DISABLE:
2221 case VIRTCHNL_OP_DCF_GET_VSI_MAP:
2222 case VIRTCHNL_OP_DCF_GET_PKG_INFO:
2224 case VIRTCHNL_OP_DCF_CONFIG_BW:
2225 valid_len = sizeof(struct virtchnl_dcf_bw_cfg_list);
2226 if (msglen >= valid_len) {
2227 struct virtchnl_dcf_bw_cfg_list *cfg_list =
2228 (struct virtchnl_dcf_bw_cfg_list *)msg;
2229 if (cfg_list->num_elem == 0) {
2230 err_msg_format = true;
2233 valid_len += (cfg_list->num_elem - 1) *
2234 sizeof(struct virtchnl_dcf_bw_cfg);
2237 case VIRTCHNL_OP_GET_SUPPORTED_RXDIDS:
2239 case VIRTCHNL_OP_ADD_RSS_CFG:
2240 case VIRTCHNL_OP_DEL_RSS_CFG:
2241 valid_len = sizeof(struct virtchnl_rss_cfg);
2243 case VIRTCHNL_OP_ADD_FDIR_FILTER:
2244 valid_len = sizeof(struct virtchnl_fdir_add);
2246 case VIRTCHNL_OP_DEL_FDIR_FILTER:
2247 valid_len = sizeof(struct virtchnl_fdir_del);
2249 case VIRTCHNL_OP_QUERY_FDIR_FILTER:
2250 valid_len = sizeof(struct virtchnl_fdir_query);
2252 case VIRTCHNL_OP_GET_QOS_CAPS:
2254 case VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP:
2255 valid_len = sizeof(struct virtchnl_queue_tc_mapping);
2256 if (msglen >= valid_len) {
2257 struct virtchnl_queue_tc_mapping *q_tc =
2258 (struct virtchnl_queue_tc_mapping *)msg;
2259 if (q_tc->num_tc == 0) {
2260 err_msg_format = true;
2263 valid_len += (q_tc->num_tc - 1) *
2264 sizeof(q_tc->tc[0]);
2267 case VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS:
2269 case VIRTCHNL_OP_ADD_VLAN_V2:
2270 case VIRTCHNL_OP_DEL_VLAN_V2:
2271 valid_len = sizeof(struct virtchnl_vlan_filter_list_v2);
2272 if (msglen >= valid_len) {
2273 struct virtchnl_vlan_filter_list_v2 *vfl =
2274 (struct virtchnl_vlan_filter_list_v2 *)msg;
2276 if (vfl->num_elements == 0 || vfl->num_elements >
2277 VIRTCHNL_OP_ADD_DEL_VLAN_V2_MAX) {
2278 err_msg_format = true;
2282 valid_len += (vfl->num_elements - 1) *
2283 sizeof(struct virtchnl_vlan_filter);
2286 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2:
2287 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2:
2288 case VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2:
2289 case VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2:
2290 case VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2:
2291 case VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2:
2292 valid_len = sizeof(struct virtchnl_vlan_setting);
2294 case VIRTCHNL_OP_ENABLE_QUEUES_V2:
2295 case VIRTCHNL_OP_DISABLE_QUEUES_V2:
2296 valid_len = sizeof(struct virtchnl_del_ena_dis_queues);
2297 if (msglen >= valid_len) {
2298 struct virtchnl_del_ena_dis_queues *qs =
2299 (struct virtchnl_del_ena_dis_queues *)msg;
2300 if (qs->chunks.num_chunks == 0 ||
2301 qs->chunks.num_chunks > VIRTCHNL_OP_ENABLE_DISABLE_DEL_QUEUES_V2_MAX) {
2302 err_msg_format = true;
2305 valid_len += (qs->chunks.num_chunks - 1) *
2306 sizeof(struct virtchnl_queue_chunk);
2309 case VIRTCHNL_OP_MAP_QUEUE_VECTOR:
2310 valid_len = sizeof(struct virtchnl_queue_vector_maps);
2311 if (msglen >= valid_len) {
2312 struct virtchnl_queue_vector_maps *v_qp =
2313 (struct virtchnl_queue_vector_maps *)msg;
2314 if (v_qp->num_qv_maps == 0 ||
2315 v_qp->num_qv_maps > VIRTCHNL_OP_MAP_UNMAP_QUEUE_VECTOR_MAX) {
2316 err_msg_format = true;
2319 valid_len += (v_qp->num_qv_maps - 1) *
2320 sizeof(struct virtchnl_queue_vector);
2323 /* These are always errors coming from the VF. */
2324 case VIRTCHNL_OP_EVENT:
2325 case VIRTCHNL_OP_UNKNOWN:
2327 return VIRTCHNL_STATUS_ERR_PARAM;
2329 /* few more checks */
2330 if (err_msg_format || valid_len != msglen)
2331 return VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH;
2335 #endif /* _VIRTCHNL_H_ */