1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright (c) 2021, Intel Corporation
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the Intel Corporation nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
37 * This header file describes the Virtual Function (VF) - Physical Function
38 * (PF) communication protocol used by the drivers for all devices starting
39 * from our 40G product line
41 * Admin queue buffer usage:
42 * desc->opcode is always aqc_opc_send_msg_to_pf
43 * flags, retval, datalen, and data addr are all used normally.
44 * The Firmware copies the cookie fields when sending messages between the
45 * PF and VF, but uses all other fields internally. Due to this limitation,
46 * we must send all messages as "indirect", i.e. using an external buffer.
48 * All the VSI indexes are relative to the VF. Each VF can have maximum of
49 * three VSIs. All the queue indexes are relative to the VSI. Each VF can
50 * have a maximum of sixteen queues for all of its VSIs.
52 * The PF is required to return a status code in v_retval for all messages
53 * except RESET_VF, which does not require any response. The returned value
54 * is of virtchnl_status_code type, defined here.
56 * In general, VF driver initialization should roughly follow the order of
57 * these opcodes. The VF driver must first validate the API version of the
58 * PF driver, then request a reset, then get resources, then configure
59 * queues and interrupts. After these operations are complete, the VF
60 * driver may start its queues, optionally add MAC and VLAN filters, and
64 /* START GENERIC DEFINES
65 * Need to ensure the following enums and defines hold the same meaning and
66 * value in current and future projects
69 #define VIRTCHNL_ETH_LENGTH_OF_ADDRESS 6
71 /* These macros are used to generate compilation errors if a structure/union
72 * is not exactly the correct length. It gives a divide by zero error if the
73 * structure/union is not of the correct size, otherwise it creates an enum
76 #define VIRTCHNL_CHECK_STRUCT_LEN(n, X) enum virtchnl_static_assert_enum_##X \
77 { virtchnl_static_assert_##X = (n)/((sizeof(struct X) == (n)) ? 1 : 0) }
78 #define VIRTCHNL_CHECK_UNION_LEN(n, X) enum virtchnl_static_asset_enum_##X \
79 { virtchnl_static_assert_##X = (n)/((sizeof(union X) == (n)) ? 1 : 0) }
82 * Note that many older versions of various iAVF drivers convert the reported
83 * status code directly into an iavf_status enumeration. For this reason, it
84 * is important that the values of these enumerations line up.
86 enum virtchnl_status_code {
87 VIRTCHNL_STATUS_SUCCESS = 0,
88 VIRTCHNL_STATUS_ERR_PARAM = -5,
89 VIRTCHNL_STATUS_ERR_NO_MEMORY = -18,
90 VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH = -38,
91 VIRTCHNL_STATUS_ERR_CQP_COMPL_ERROR = -39,
92 VIRTCHNL_STATUS_ERR_INVALID_VF_ID = -40,
93 VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR = -53,
94 VIRTCHNL_STATUS_ERR_NOT_SUPPORTED = -64,
97 /* Backward compatibility */
98 #define VIRTCHNL_ERR_PARAM VIRTCHNL_STATUS_ERR_PARAM
99 #define VIRTCHNL_STATUS_NOT_SUPPORTED VIRTCHNL_STATUS_ERR_NOT_SUPPORTED
101 #define VIRTCHNL_LINK_SPEED_2_5GB_SHIFT 0x0
102 #define VIRTCHNL_LINK_SPEED_100MB_SHIFT 0x1
103 #define VIRTCHNL_LINK_SPEED_1000MB_SHIFT 0x2
104 #define VIRTCHNL_LINK_SPEED_10GB_SHIFT 0x3
105 #define VIRTCHNL_LINK_SPEED_40GB_SHIFT 0x4
106 #define VIRTCHNL_LINK_SPEED_20GB_SHIFT 0x5
107 #define VIRTCHNL_LINK_SPEED_25GB_SHIFT 0x6
108 #define VIRTCHNL_LINK_SPEED_5GB_SHIFT 0x7
110 enum virtchnl_link_speed {
111 VIRTCHNL_LINK_SPEED_UNKNOWN = 0,
112 VIRTCHNL_LINK_SPEED_100MB = BIT(VIRTCHNL_LINK_SPEED_100MB_SHIFT),
113 VIRTCHNL_LINK_SPEED_1GB = BIT(VIRTCHNL_LINK_SPEED_1000MB_SHIFT),
114 VIRTCHNL_LINK_SPEED_10GB = BIT(VIRTCHNL_LINK_SPEED_10GB_SHIFT),
115 VIRTCHNL_LINK_SPEED_40GB = BIT(VIRTCHNL_LINK_SPEED_40GB_SHIFT),
116 VIRTCHNL_LINK_SPEED_20GB = BIT(VIRTCHNL_LINK_SPEED_20GB_SHIFT),
117 VIRTCHNL_LINK_SPEED_25GB = BIT(VIRTCHNL_LINK_SPEED_25GB_SHIFT),
118 VIRTCHNL_LINK_SPEED_2_5GB = BIT(VIRTCHNL_LINK_SPEED_2_5GB_SHIFT),
119 VIRTCHNL_LINK_SPEED_5GB = BIT(VIRTCHNL_LINK_SPEED_5GB_SHIFT),
122 /* for hsplit_0 field of Rx HMC context */
123 /* deprecated with AVF 1.0 */
124 enum virtchnl_rx_hsplit {
125 VIRTCHNL_RX_HSPLIT_NO_SPLIT = 0,
126 VIRTCHNL_RX_HSPLIT_SPLIT_L2 = 1,
127 VIRTCHNL_RX_HSPLIT_SPLIT_IP = 2,
128 VIRTCHNL_RX_HSPLIT_SPLIT_TCP_UDP = 4,
129 VIRTCHNL_RX_HSPLIT_SPLIT_SCTP = 8,
132 enum virtchnl_bw_limit_type {
133 VIRTCHNL_BW_SHAPER = 0,
135 /* END GENERIC DEFINES */
137 /* Opcodes for VF-PF communication. These are placed in the v_opcode field
138 * of the virtchnl_msg structure.
141 /* The PF sends status change events to VFs using
142 * the VIRTCHNL_OP_EVENT opcode.
143 * VFs send requests to the PF using the other ops.
144 * Use of "advanced opcode" features must be negotiated as part of capabilities
145 * exchange and are not considered part of base mode feature set.
148 VIRTCHNL_OP_UNKNOWN = 0,
149 VIRTCHNL_OP_VERSION = 1, /* must ALWAYS be 1 */
150 VIRTCHNL_OP_RESET_VF = 2,
151 VIRTCHNL_OP_GET_VF_RESOURCES = 3,
152 VIRTCHNL_OP_CONFIG_TX_QUEUE = 4,
153 VIRTCHNL_OP_CONFIG_RX_QUEUE = 5,
154 VIRTCHNL_OP_CONFIG_VSI_QUEUES = 6,
155 VIRTCHNL_OP_CONFIG_IRQ_MAP = 7,
156 VIRTCHNL_OP_ENABLE_QUEUES = 8,
157 VIRTCHNL_OP_DISABLE_QUEUES = 9,
158 VIRTCHNL_OP_ADD_ETH_ADDR = 10,
159 VIRTCHNL_OP_DEL_ETH_ADDR = 11,
160 VIRTCHNL_OP_ADD_VLAN = 12,
161 VIRTCHNL_OP_DEL_VLAN = 13,
162 VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE = 14,
163 VIRTCHNL_OP_GET_STATS = 15,
164 VIRTCHNL_OP_RSVD = 16,
165 VIRTCHNL_OP_EVENT = 17, /* must ALWAYS be 17 */
166 /* opcode 19 is reserved */
167 /* opcodes 20, 21, and 22 are reserved */
168 VIRTCHNL_OP_CONFIG_RSS_KEY = 23,
169 VIRTCHNL_OP_CONFIG_RSS_LUT = 24,
170 VIRTCHNL_OP_GET_RSS_HENA_CAPS = 25,
171 VIRTCHNL_OP_SET_RSS_HENA = 26,
172 VIRTCHNL_OP_ENABLE_VLAN_STRIPPING = 27,
173 VIRTCHNL_OP_DISABLE_VLAN_STRIPPING = 28,
174 VIRTCHNL_OP_REQUEST_QUEUES = 29,
175 VIRTCHNL_OP_ENABLE_CHANNELS = 30,
176 VIRTCHNL_OP_DISABLE_CHANNELS = 31,
177 VIRTCHNL_OP_ADD_CLOUD_FILTER = 32,
178 VIRTCHNL_OP_DEL_CLOUD_FILTER = 33,
179 /* opcode 34 is reserved */
180 /* opcodes 38, 39, 40, 41, 42 and 43 are reserved */
181 /* opcode 44 is reserved */
182 VIRTCHNL_OP_ADD_RSS_CFG = 45,
183 VIRTCHNL_OP_DEL_RSS_CFG = 46,
184 VIRTCHNL_OP_ADD_FDIR_FILTER = 47,
185 VIRTCHNL_OP_DEL_FDIR_FILTER = 48,
186 VIRTCHNL_OP_GET_MAX_RSS_QREGION = 50,
187 VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS = 51,
188 VIRTCHNL_OP_ADD_VLAN_V2 = 52,
189 VIRTCHNL_OP_DEL_VLAN_V2 = 53,
190 VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 = 54,
191 VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 = 55,
192 VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 = 56,
193 VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2 = 57,
194 VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2 = 58,
195 VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2 = 59,
196 /* opcodes 60 through 65 are reserved */
197 VIRTCHNL_OP_GET_QOS_CAPS = 66,
198 VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP = 67,
199 /* opcode 68, 69 are reserved */
200 VIRTCHNL_OP_ENABLE_QUEUES_V2 = 107,
201 VIRTCHNL_OP_DISABLE_QUEUES_V2 = 108,
202 VIRTCHNL_OP_MAP_QUEUE_VECTOR = 111,
206 static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)
209 case VIRTCHNL_OP_UNKNOWN:
210 return "VIRTCHNL_OP_UNKNOWN";
211 case VIRTCHNL_OP_VERSION:
212 return "VIRTCHNL_OP_VERSION";
213 case VIRTCHNL_OP_RESET_VF:
214 return "VIRTCHNL_OP_RESET_VF";
215 case VIRTCHNL_OP_GET_VF_RESOURCES:
216 return "VIRTCHNL_OP_GET_VF_RESOURCES";
217 case VIRTCHNL_OP_CONFIG_TX_QUEUE:
218 return "VIRTCHNL_OP_CONFIG_TX_QUEUE";
219 case VIRTCHNL_OP_CONFIG_RX_QUEUE:
220 return "VIRTCHNL_OP_CONFIG_RX_QUEUE";
221 case VIRTCHNL_OP_CONFIG_VSI_QUEUES:
222 return "VIRTCHNL_OP_CONFIG_VSI_QUEUES";
223 case VIRTCHNL_OP_CONFIG_IRQ_MAP:
224 return "VIRTCHNL_OP_CONFIG_IRQ_MAP";
225 case VIRTCHNL_OP_ENABLE_QUEUES:
226 return "VIRTCHNL_OP_ENABLE_QUEUES";
227 case VIRTCHNL_OP_DISABLE_QUEUES:
228 return "VIRTCHNL_OP_DISABLE_QUEUES";
229 case VIRTCHNL_OP_ADD_ETH_ADDR:
230 return "VIRTCHNL_OP_ADD_ETH_ADDR";
231 case VIRTCHNL_OP_DEL_ETH_ADDR:
232 return "VIRTCHNL_OP_DEL_ETH_ADDR";
233 case VIRTCHNL_OP_ADD_VLAN:
234 return "VIRTCHNL_OP_ADD_VLAN";
235 case VIRTCHNL_OP_DEL_VLAN:
236 return "VIRTCHNL_OP_DEL_VLAN";
237 case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE:
238 return "VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE";
239 case VIRTCHNL_OP_GET_STATS:
240 return "VIRTCHNL_OP_GET_STATS";
241 case VIRTCHNL_OP_RSVD:
242 return "VIRTCHNL_OP_RSVD";
243 case VIRTCHNL_OP_EVENT:
244 return "VIRTCHNL_OP_EVENT";
245 case VIRTCHNL_OP_CONFIG_RSS_KEY:
246 return "VIRTCHNL_OP_CONFIG_RSS_KEY";
247 case VIRTCHNL_OP_CONFIG_RSS_LUT:
248 return "VIRTCHNL_OP_CONFIG_RSS_LUT";
249 case VIRTCHNL_OP_GET_RSS_HENA_CAPS:
250 return "VIRTCHNL_OP_GET_RSS_HENA_CAPS";
251 case VIRTCHNL_OP_SET_RSS_HENA:
252 return "VIRTCHNL_OP_SET_RSS_HENA";
253 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING:
254 return "VIRTCHNL_OP_ENABLE_VLAN_STRIPPING";
255 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING:
256 return "VIRTCHNL_OP_DISABLE_VLAN_STRIPPING";
257 case VIRTCHNL_OP_REQUEST_QUEUES:
258 return "VIRTCHNL_OP_REQUEST_QUEUES";
259 case VIRTCHNL_OP_ENABLE_CHANNELS:
260 return "VIRTCHNL_OP_ENABLE_CHANNELS";
261 case VIRTCHNL_OP_DISABLE_CHANNELS:
262 return "VIRTCHNL_OP_DISABLE_CHANNELS";
263 case VIRTCHNL_OP_ADD_CLOUD_FILTER:
264 return "VIRTCHNL_OP_ADD_CLOUD_FILTER";
265 case VIRTCHNL_OP_DEL_CLOUD_FILTER:
266 return "VIRTCHNL_OP_DEL_CLOUD_FILTER";
267 case VIRTCHNL_OP_ADD_RSS_CFG:
268 return "VIRTCHNL_OP_ADD_RSS_CFG";
269 case VIRTCHNL_OP_DEL_RSS_CFG:
270 return "VIRTCHNL_OP_DEL_RSS_CFG";
271 case VIRTCHNL_OP_ADD_FDIR_FILTER:
272 return "VIRTCHNL_OP_ADD_FDIR_FILTER";
273 case VIRTCHNL_OP_DEL_FDIR_FILTER:
274 return "VIRTCHNL_OP_DEL_FDIR_FILTER";
275 case VIRTCHNL_OP_GET_MAX_RSS_QREGION:
276 return "VIRTCHNL_OP_GET_MAX_RSS_QREGION";
277 case VIRTCHNL_OP_ENABLE_QUEUES_V2:
278 return "VIRTCHNL_OP_ENABLE_QUEUES_V2";
279 case VIRTCHNL_OP_DISABLE_QUEUES_V2:
280 return "VIRTCHNL_OP_DISABLE_QUEUES_V2";
281 case VIRTCHNL_OP_MAP_QUEUE_VECTOR:
282 return "VIRTCHNL_OP_MAP_QUEUE_VECTOR";
283 case VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS:
284 return "VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS";
285 case VIRTCHNL_OP_ADD_VLAN_V2:
286 return "VIRTCHNL_OP_ADD_VLAN_V2";
287 case VIRTCHNL_OP_DEL_VLAN_V2:
288 return "VIRTCHNL_OP_DEL_VLAN_V2";
289 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2:
290 return "VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2";
291 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2:
292 return "VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2";
293 case VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2:
294 return "VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2";
295 case VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2:
296 return "VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2";
297 case VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2:
298 return "VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2";
299 case VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2:
300 return "VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2";
301 case VIRTCHNL_OP_MAX:
302 return "VIRTCHNL_OP_MAX";
304 return "Unsupported (update virtchnl.h)";
308 static inline const char *virtchnl_stat_str(enum virtchnl_status_code v_status)
311 case VIRTCHNL_STATUS_SUCCESS:
312 return "VIRTCHNL_STATUS_SUCCESS";
313 case VIRTCHNL_STATUS_ERR_PARAM:
314 return "VIRTCHNL_STATUS_ERR_PARAM";
315 case VIRTCHNL_STATUS_ERR_NO_MEMORY:
316 return "VIRTCHNL_STATUS_ERR_NO_MEMORY";
317 case VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH:
318 return "VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH";
319 case VIRTCHNL_STATUS_ERR_CQP_COMPL_ERROR:
320 return "VIRTCHNL_STATUS_ERR_CQP_COMPL_ERROR";
321 case VIRTCHNL_STATUS_ERR_INVALID_VF_ID:
322 return "VIRTCHNL_STATUS_ERR_INVALID_VF_ID";
323 case VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR:
324 return "VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR";
325 case VIRTCHNL_STATUS_ERR_NOT_SUPPORTED:
326 return "VIRTCHNL_STATUS_ERR_NOT_SUPPORTED";
328 return "Unknown status code (update virtchnl.h)";
332 /* Virtual channel message descriptor. This overlays the admin queue
333 * descriptor. All other data is passed in external buffers.
336 struct virtchnl_msg {
337 u8 pad[8]; /* AQ flags/opcode/len/retval fields */
339 /* avoid confusion with desc->opcode */
340 enum virtchnl_ops v_opcode;
342 /* ditto for desc->retval */
343 enum virtchnl_status_code v_retval;
344 u32 vfid; /* used by PF when sending to VF */
347 VIRTCHNL_CHECK_STRUCT_LEN(20, virtchnl_msg);
349 /* Message descriptions and data structures. */
351 /* VIRTCHNL_OP_VERSION
352 * VF posts its version number to the PF. PF responds with its version number
353 * in the same format, along with a return code.
354 * Reply from PF has its major/minor versions also in param0 and param1.
355 * If there is a major version mismatch, then the VF cannot operate.
356 * If there is a minor version mismatch, then the VF can operate but should
357 * add a warning to the system log.
359 * This enum element MUST always be specified as == 1, regardless of other
360 * changes in the API. The PF must always respond to this message without
361 * error regardless of version mismatch.
363 #define VIRTCHNL_VERSION_MAJOR 1
364 #define VIRTCHNL_VERSION_MINOR 1
365 #define VIRTCHNL_VERSION_MAJOR_2 2
366 #define VIRTCHNL_VERSION_MINOR_0 0
367 #define VIRTCHNL_VERSION_MINOR_NO_VF_CAPS 0
369 struct virtchnl_version_info {
374 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_version_info);
376 #define VF_IS_V10(_ver) (((_ver)->major == 1) && ((_ver)->minor == 0))
377 #define VF_IS_V11(_ver) (((_ver)->major == 1) && ((_ver)->minor == 1))
378 #define VF_IS_V20(_ver) (((_ver)->major == 2) && ((_ver)->minor == 0))
380 /* VIRTCHNL_OP_RESET_VF
381 * VF sends this request to PF with no parameters
382 * PF does NOT respond! VF driver must delay then poll VFGEN_RSTAT register
383 * until reset completion is indicated. The admin queue must be reinitialized
384 * after this operation.
386 * When reset is complete, PF must ensure that all queues in all VSIs associated
387 * with the VF are stopped, all queue configurations in the HMC are set to 0,
388 * and all MAC and VLAN filters (except the default MAC address) on all VSIs
392 /* VSI types that use VIRTCHNL interface for VF-PF communication. VSI_SRIOV
393 * vsi_type should always be 6 for backward compatibility. Add other fields
396 enum virtchnl_vsi_type {
397 VIRTCHNL_VSI_TYPE_INVALID = 0,
398 VIRTCHNL_VSI_SRIOV = 6,
401 /* VIRTCHNL_OP_GET_VF_RESOURCES
402 * Version 1.0 VF sends this request to PF with no parameters
403 * Version 1.1 VF sends this request to PF with u32 bitmap of its capabilities
404 * PF responds with an indirect message containing
405 * virtchnl_vf_resource and one or more
406 * virtchnl_vsi_resource structures.
409 struct virtchnl_vsi_resource {
413 /* see enum virtchnl_vsi_type */
416 u8 default_mac_addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
419 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
421 /* VF capability flags
422 * VIRTCHNL_VF_OFFLOAD_L2 flag is inclusive of base mode L2 offloads including
423 * TX/RX Checksum offloading and TSO for non-tunnelled packets.
425 #define VIRTCHNL_VF_OFFLOAD_L2 BIT(0)
426 #define VIRTCHNL_VF_OFFLOAD_IWARP BIT(1)
427 #define VIRTCHNL_VF_CAP_RDMA VIRTCHNL_VF_OFFLOAD_IWARP
428 #define VIRTCHNL_VF_OFFLOAD_RSS_AQ BIT(3)
429 #define VIRTCHNL_VF_OFFLOAD_RSS_REG BIT(4)
430 #define VIRTCHNL_VF_OFFLOAD_WB_ON_ITR BIT(5)
431 #define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES BIT(6)
432 /* used to negotiate communicating link speeds in Mbps */
433 #define VIRTCHNL_VF_CAP_ADV_LINK_SPEED BIT(7)
434 /* BIT(8) is reserved */
435 #define VIRTCHNL_VF_LARGE_NUM_QPAIRS BIT(9)
436 #define VIRTCHNL_VF_OFFLOAD_CRC BIT(10)
437 #define VIRTCHNL_VF_OFFLOAD_VLAN_V2 BIT(15)
438 #define VIRTCHNL_VF_OFFLOAD_VLAN BIT(16)
439 #define VIRTCHNL_VF_OFFLOAD_RX_POLLING BIT(17)
440 #define VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 BIT(18)
441 #define VIRTCHNL_VF_OFFLOAD_RSS_PF BIT(19)
442 #define VIRTCHNL_VF_OFFLOAD_ENCAP BIT(20)
443 #define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM BIT(21)
444 #define VIRTCHNL_VF_OFFLOAD_RX_ENCAP_CSUM BIT(22)
445 #define VIRTCHNL_VF_OFFLOAD_ADQ BIT(23)
446 #define VIRTCHNL_VF_OFFLOAD_ADQ_V2 BIT(24)
447 #define VIRTCHNL_VF_OFFLOAD_USO BIT(25)
448 /* BIT(26) is reserved */
449 #define VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF BIT(27)
450 #define VIRTCHNL_VF_OFFLOAD_FDIR_PF BIT(28)
451 #define VIRTCHNL_VF_OFFLOAD_QOS BIT(29)
452 /* BIT(30) is reserved */
453 /* BIT(31) is reserved */
455 #define VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \
456 VIRTCHNL_VF_OFFLOAD_VLAN | \
457 VIRTCHNL_VF_OFFLOAD_RSS_PF)
459 struct virtchnl_vf_resource {
469 struct virtchnl_vsi_resource vsi_res[1];
472 VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_vf_resource);
474 /* VIRTCHNL_OP_CONFIG_TX_QUEUE
475 * VF sends this message to set up parameters for one TX queue.
476 * External data buffer contains one instance of virtchnl_txq_info.
477 * PF configures requested queue and returns a status code.
480 /* Tx queue config info */
481 struct virtchnl_txq_info {
484 u16 ring_len; /* number of descriptors, multiple of 8 */
485 u16 headwb_enabled; /* deprecated with AVF 1.0 */
487 u64 dma_headwb_addr; /* deprecated with AVF 1.0 */
490 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_txq_info);
492 /* RX descriptor IDs (range from 0 to 63) */
493 enum virtchnl_rx_desc_ids {
494 VIRTCHNL_RXDID_0_16B_BASE = 0,
495 /* 32B_BASE and FLEX_SPLITQ share desc ids as default descriptors
496 * because they can be differentiated based on queue model; e.g. single
497 * queue model can only use 32B_BASE and split queue model can only use
498 * FLEX_SPLITQ. Having these as 1 allows them to be used as default
499 * descriptors without negotiation.
501 VIRTCHNL_RXDID_1_32B_BASE = 1,
502 VIRTCHNL_RXDID_1_FLEX_SPLITQ = 1,
503 VIRTCHNL_RXDID_2_FLEX_SQ_NIC = 2,
504 VIRTCHNL_RXDID_3_FLEX_SQ_SW = 3,
505 VIRTCHNL_RXDID_4_FLEX_SQ_NIC_VEB = 4,
506 VIRTCHNL_RXDID_5_FLEX_SQ_NIC_ACL = 5,
507 VIRTCHNL_RXDID_6_FLEX_SQ_NIC_2 = 6,
508 VIRTCHNL_RXDID_7_HW_RSVD = 7,
509 /* 9 through 15 are reserved */
510 VIRTCHNL_RXDID_16_COMMS_GENERIC = 16,
511 VIRTCHNL_RXDID_17_COMMS_AUX_VLAN = 17,
512 VIRTCHNL_RXDID_18_COMMS_AUX_IPV4 = 18,
513 VIRTCHNL_RXDID_19_COMMS_AUX_IPV6 = 19,
514 VIRTCHNL_RXDID_20_COMMS_AUX_FLOW = 20,
515 VIRTCHNL_RXDID_21_COMMS_AUX_TCP = 21,
516 /* 22 through 63 are reserved */
519 /* RX descriptor ID bitmasks */
520 enum virtchnl_rx_desc_id_bitmasks {
521 VIRTCHNL_RXDID_0_16B_BASE_M = BIT(VIRTCHNL_RXDID_0_16B_BASE),
522 VIRTCHNL_RXDID_1_32B_BASE_M = BIT(VIRTCHNL_RXDID_1_32B_BASE),
523 VIRTCHNL_RXDID_1_FLEX_SPLITQ_M = BIT(VIRTCHNL_RXDID_1_FLEX_SPLITQ),
524 VIRTCHNL_RXDID_2_FLEX_SQ_NIC_M = BIT(VIRTCHNL_RXDID_2_FLEX_SQ_NIC),
525 VIRTCHNL_RXDID_3_FLEX_SQ_SW_M = BIT(VIRTCHNL_RXDID_3_FLEX_SQ_SW),
526 VIRTCHNL_RXDID_4_FLEX_SQ_NIC_VEB_M = BIT(VIRTCHNL_RXDID_4_FLEX_SQ_NIC_VEB),
527 VIRTCHNL_RXDID_5_FLEX_SQ_NIC_ACL_M = BIT(VIRTCHNL_RXDID_5_FLEX_SQ_NIC_ACL),
528 VIRTCHNL_RXDID_6_FLEX_SQ_NIC_2_M = BIT(VIRTCHNL_RXDID_6_FLEX_SQ_NIC_2),
529 VIRTCHNL_RXDID_7_HW_RSVD_M = BIT(VIRTCHNL_RXDID_7_HW_RSVD),
530 /* 9 through 15 are reserved */
531 VIRTCHNL_RXDID_16_COMMS_GENERIC_M = BIT(VIRTCHNL_RXDID_16_COMMS_GENERIC),
532 VIRTCHNL_RXDID_17_COMMS_AUX_VLAN_M = BIT(VIRTCHNL_RXDID_17_COMMS_AUX_VLAN),
533 VIRTCHNL_RXDID_18_COMMS_AUX_IPV4_M = BIT(VIRTCHNL_RXDID_18_COMMS_AUX_IPV4),
534 VIRTCHNL_RXDID_19_COMMS_AUX_IPV6_M = BIT(VIRTCHNL_RXDID_19_COMMS_AUX_IPV6),
535 VIRTCHNL_RXDID_20_COMMS_AUX_FLOW_M = BIT(VIRTCHNL_RXDID_20_COMMS_AUX_FLOW),
536 VIRTCHNL_RXDID_21_COMMS_AUX_TCP_M = BIT(VIRTCHNL_RXDID_21_COMMS_AUX_TCP),
537 /* 22 through 63 are reserved */
540 /* VIRTCHNL_OP_CONFIG_RX_QUEUE
541 * VF sends this message to set up parameters for one RX queue.
542 * External data buffer contains one instance of virtchnl_rxq_info.
543 * PF configures requested queue and returns a status code. The
544 * crc_disable flag disables CRC stripping on the VF. Setting
545 * the crc_disable flag to 1 will disable CRC stripping for each
546 * queue in the VF where the flag is set. The VIRTCHNL_VF_OFFLOAD_CRC
547 * offload must have been set prior to sending this info or the PF
548 * will ignore the request. This flag should be set the same for
549 * all of the queues for a VF.
552 /* Rx queue config info */
553 struct virtchnl_rxq_info {
556 u32 ring_len; /* number of descriptors, multiple of 32 */
558 u16 splithdr_enabled; /* deprecated with AVF 1.0 */
565 /* see enum virtchnl_rx_hsplit; deprecated with AVF 1.0 */
570 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_rxq_info);
572 /* VIRTCHNL_OP_CONFIG_VSI_QUEUES
573 * VF sends this message to set parameters for active TX and RX queues
574 * associated with the specified VSI.
575 * PF configures queues and returns status.
576 * If the number of queues specified is greater than the number of queues
577 * associated with the VSI, an error is returned and no queues are configured.
578 * NOTE: The VF is not required to configure all queues in a single request.
579 * It may send multiple messages. PF drivers must correctly handle all VF
582 struct virtchnl_queue_pair_info {
583 /* NOTE: vsi_id and queue_id should be identical for both queues. */
584 struct virtchnl_txq_info txq;
585 struct virtchnl_rxq_info rxq;
588 VIRTCHNL_CHECK_STRUCT_LEN(64, virtchnl_queue_pair_info);
590 struct virtchnl_vsi_queue_config_info {
594 struct virtchnl_queue_pair_info qpair[1];
597 VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_vsi_queue_config_info);
599 /* VIRTCHNL_OP_REQUEST_QUEUES
600 * VF sends this message to request the PF to allocate additional queues to
601 * this VF. Each VF gets a guaranteed number of queues on init but asking for
602 * additional queues must be negotiated. This is a best effort request as it
603 * is possible the PF does not have enough queues left to support the request.
604 * If the PF cannot support the number requested it will respond with the
605 * maximum number it is able to support. If the request is successful, PF will
606 * then reset the VF to institute required changes.
609 /* VF resource request */
610 struct virtchnl_vf_res_request {
614 /* VIRTCHNL_OP_CONFIG_IRQ_MAP
615 * VF uses this message to map vectors to queues.
616 * The rxq_map and txq_map fields are bitmaps used to indicate which queues
617 * are to be associated with the specified vector.
618 * The "other" causes are always mapped to vector 0. The VF may not request
619 * that vector 0 be used for traffic.
620 * PF configures interrupt mapping and returns status.
621 * NOTE: due to hardware requirements, all active queues (both TX and RX)
622 * should be mapped to interrupts, even if the driver intends to operate
623 * only in polling mode. In this case the interrupt may be disabled, but
624 * the ITR timer will still run to trigger writebacks.
626 struct virtchnl_vector_map {
635 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_vector_map);
637 struct virtchnl_irq_map_info {
639 struct virtchnl_vector_map vecmap[1];
642 VIRTCHNL_CHECK_STRUCT_LEN(14, virtchnl_irq_map_info);
644 /* VIRTCHNL_OP_ENABLE_QUEUES
645 * VIRTCHNL_OP_DISABLE_QUEUES
646 * VF sends these message to enable or disable TX/RX queue pairs.
647 * The queues fields are bitmaps indicating which queues to act upon.
648 * (Currently, we only support 16 queues per VF, but we make the field
649 * u32 to allow for expansion.)
650 * PF performs requested action and returns status.
651 * NOTE: The VF is not required to enable/disable all queues in a single
652 * request. It may send multiple messages.
653 * PF drivers must correctly handle all VF requests.
655 struct virtchnl_queue_select {
662 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_select);
664 /* VIRTCHNL_OP_GET_MAX_RSS_QREGION
666 * if VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
667 * then this op must be supported.
669 * VF sends this message in order to query the max RSS queue region
670 * size supported by PF, when VIRTCHNL_VF_LARGE_NUM_QPAIRS is enabled.
671 * This information should be used when configuring the RSS LUT and/or
672 * configuring queue region based filters.
674 * The maximum RSS queue region is 2^qregion_width. So, a qregion_width
675 * of 6 would inform the VF that the PF supports a maximum RSS queue region
678 * A queue region represents a range of queues that can be used to configure
679 * a RSS LUT. For example, if a VF is given 64 queues, but only a max queue
680 * region size of 16 (i.e. 2^qregion_width = 16) then it will only be able
681 * to configure the RSS LUT with queue indices from 0 to 15. However, other
682 * filters can be used to direct packets to queues >15 via specifying a queue
683 * base/offset and queue region width.
685 struct virtchnl_max_rss_qregion {
691 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_max_rss_qregion);
693 /* VIRTCHNL_OP_ADD_ETH_ADDR
694 * VF sends this message in order to add one or more unicast or multicast
695 * address filters for the specified VSI.
696 * PF adds the filters and returns status.
699 /* VIRTCHNL_OP_DEL_ETH_ADDR
700 * VF sends this message in order to remove one or more unicast or multicast
701 * filters for the specified VSI.
702 * PF removes the filters and returns status.
705 /* VIRTCHNL_ETHER_ADDR_LEGACY
706 * Prior to adding the @type member to virtchnl_ether_addr, there were 2 pad
707 * bytes. Moving forward all VF drivers should not set type to
708 * VIRTCHNL_ETHER_ADDR_LEGACY. This is only here to not break previous/legacy
709 * behavior. The control plane function (i.e. PF) can use a best effort method
710 * of tracking the primary/device unicast in this case, but there is no
711 * guarantee and functionality depends on the implementation of the PF.
714 /* VIRTCHNL_ETHER_ADDR_PRIMARY
715 * All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_PRIMARY for the
716 * primary/device unicast MAC address filter for VIRTCHNL_OP_ADD_ETH_ADDR and
717 * VIRTCHNL_OP_DEL_ETH_ADDR. This allows for the underlying control plane
718 * function (i.e. PF) to accurately track and use this MAC address for
719 * displaying on the host and for VM/function reset.
722 /* VIRTCHNL_ETHER_ADDR_EXTRA
723 * All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_EXTRA for any extra
724 * unicast and/or multicast filters that are being added/deleted via
725 * VIRTCHNL_OP_DEL_ETH_ADDR/VIRTCHNL_OP_ADD_ETH_ADDR respectively.
727 struct virtchnl_ether_addr {
728 u8 addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
730 #define VIRTCHNL_ETHER_ADDR_LEGACY 0
731 #define VIRTCHNL_ETHER_ADDR_PRIMARY 1
732 #define VIRTCHNL_ETHER_ADDR_EXTRA 2
733 #define VIRTCHNL_ETHER_ADDR_TYPE_MASK 3 /* first two bits of type are valid */
737 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_ether_addr);
739 struct virtchnl_ether_addr_list {
742 struct virtchnl_ether_addr list[1];
745 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_ether_addr_list);
747 /* VIRTCHNL_OP_ADD_VLAN
748 * VF sends this message to add one or more VLAN tag filters for receives.
749 * PF adds the filters and returns status.
750 * If a port VLAN is configured by the PF, this operation will return an
754 /* VIRTCHNL_OP_DEL_VLAN
755 * VF sends this message to remove one or more VLAN tag filters for receives.
756 * PF removes the filters and returns status.
757 * If a port VLAN is configured by the PF, this operation will return an
761 struct virtchnl_vlan_filter_list {
767 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_vlan_filter_list);
769 /* This enum is used for all of the VIRTCHNL_VF_OFFLOAD_VLAN_V2_CAPS related
770 * structures and opcodes.
772 * VIRTCHNL_VLAN_UNSUPPORTED - This field is not supported and if a VF driver
773 * populates it the PF should return VIRTCHNL_STATUS_ERR_NOT_SUPPORTED.
775 * VIRTCHNL_VLAN_ETHERTYPE_8100 - This field supports 0x8100 ethertype.
776 * VIRTCHNL_VLAN_ETHERTYPE_88A8 - This field supports 0x88A8 ethertype.
777 * VIRTCHNL_VLAN_ETHERTYPE_9100 - This field supports 0x9100 ethertype.
779 * VIRTCHNL_VLAN_ETHERTYPE_AND - Used when multiple ethertypes can be supported
780 * by the PF concurrently. For example, if the PF can support
781 * VIRTCHNL_VLAN_ETHERTYPE_8100 AND VIRTCHNL_VLAN_ETHERTYPE_88A8 filters it
782 * would OR the following bits:
784 * VIRTHCNL_VLAN_ETHERTYPE_8100 |
785 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
786 * VIRTCHNL_VLAN_ETHERTYPE_AND;
788 * The VF would interpret this as VLAN filtering can be supported on both 0x8100
789 * and 0x88A8 VLAN ethertypes.
791 * VIRTCHNL_ETHERTYPE_XOR - Used when only a single ethertype can be supported
792 * by the PF concurrently. For example if the PF can support
793 * VIRTCHNL_VLAN_ETHERTYPE_8100 XOR VIRTCHNL_VLAN_ETHERTYPE_88A8 stripping
794 * offload it would OR the following bits:
796 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
797 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
798 * VIRTCHNL_VLAN_ETHERTYPE_XOR;
800 * The VF would interpret this as VLAN stripping can be supported on either
801 * 0x8100 or 0x88a8 VLAN ethertypes. So when requesting VLAN stripping via
802 * VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 the specified ethertype will override
803 * the previously set value.
805 * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1 - Used to tell the VF to insert and/or
806 * strip the VLAN tag using the L2TAG1 field of the Tx/Rx descriptors.
808 * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 - Used to tell the VF to insert hardware
809 * offloaded VLAN tags using the L2TAG2 field of the Tx descriptor.
811 * VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 - Used to tell the VF to strip hardware
812 * offloaded VLAN tags using the L2TAG2_2 field of the Rx descriptor.
814 * VIRTCHNL_VLAN_PRIO - This field supports VLAN priority bits. This is used for
815 * VLAN filtering if the underlying PF supports it.
817 * VIRTCHNL_VLAN_TOGGLE_ALLOWED - This field is used to say whether a
818 * certain VLAN capability can be toggled. For example if the underlying PF/CP
819 * allows the VF to toggle VLAN filtering, stripping, and/or insertion it should
820 * set this bit along with the supported ethertypes.
822 enum virtchnl_vlan_support {
823 VIRTCHNL_VLAN_UNSUPPORTED = 0,
824 VIRTCHNL_VLAN_ETHERTYPE_8100 = 0x00000001,
825 VIRTCHNL_VLAN_ETHERTYPE_88A8 = 0x00000002,
826 VIRTCHNL_VLAN_ETHERTYPE_9100 = 0x00000004,
827 VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1 = 0x00000100,
828 VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 = 0x00000200,
829 VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2_2 = 0x00000400,
830 VIRTCHNL_VLAN_PRIO = 0x01000000,
831 VIRTCHNL_VLAN_FILTER_MASK = 0x10000000,
832 VIRTCHNL_VLAN_ETHERTYPE_AND = 0x20000000,
833 VIRTCHNL_VLAN_ETHERTYPE_XOR = 0x40000000,
834 VIRTCHNL_VLAN_TOGGLE = 0x80000000
837 /* This structure is used as part of the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS
838 * for filtering, insertion, and stripping capabilities.
840 * If only outer capabilities are supported (for filtering, insertion, and/or
841 * stripping) then this refers to the outer most or single VLAN from the VF's
844 * If only inner capabilities are supported (for filtering, insertion, and/or
845 * stripping) then this refers to the outer most or single VLAN from the VF's
846 * perspective. Functionally this is the same as if only outer capabilities are
847 * supported. The VF driver is just forced to use the inner fields when
848 * adding/deleting filters and enabling/disabling offloads (if supported).
850 * If both outer and inner capabilities are supported (for filtering, insertion,
851 * and/or stripping) then outer refers to the outer most or single VLAN and
852 * inner refers to the second VLAN, if it exists, in the packet.
854 * There is no support for tunneled VLAN offloads, so outer or inner are never
855 * referring to a tunneled packet from the VF's perspective.
857 struct virtchnl_vlan_supported_caps {
862 /* The PF populates these fields based on the supported VLAN filtering. If a
863 * field is VIRTCHNL_VLAN_UNSUPPORTED then it's not supported and the PF will
864 * reject any VIRTCHNL_OP_ADD_VLAN_V2 or VIRTCHNL_OP_DEL_VLAN_V2 messages using
865 * the unsupported fields.
867 * Also, a VF is only allowed to toggle its VLAN filtering setting if the
868 * VIRTCHNL_VLAN_TOGGLE bit is set.
870 * The ethertype(s) specified in the ethertype_init field are the ethertypes
871 * enabled for VLAN filtering. VLAN filtering in this case refers to the outer
872 * most VLAN from the VF's perspective. If both inner and outer filtering are
873 * allowed then ethertype_init only refers to the outer most VLAN as only
874 * VLAN ethertype supported for inner VLAN filtering is
875 * VIRTCHNL_VLAN_ETHERTYPE_8100. By default, inner VLAN filtering is disabled
876 * when both inner and outer filtering are allowed.
878 * The max_filters field tells the VF how many VLAN filters it's allowed to have
879 * at any one time. If it exceeds this amount and tries to add another filter,
880 * then the request will be rejected by the PF. To prevent failures, the VF
881 * should keep track of how many VLAN filters it has added and not attempt to
882 * add more than max_filters.
884 struct virtchnl_vlan_filtering_caps {
885 struct virtchnl_vlan_supported_caps filtering_support;
891 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vlan_filtering_caps);
893 /* This enum is used for the virtchnl_vlan_offload_caps structure to specify
894 * if the PF supports a different ethertype for stripping and insertion.
896 * VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION - The ethertype(s) specified
897 * for stripping affect the ethertype(s) specified for insertion and visa versa
898 * as well. If the VF tries to configure VLAN stripping via
899 * VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 with VIRTCHNL_VLAN_ETHERTYPE_8100 then
900 * that will be the ethertype for both stripping and insertion.
902 * VIRTCHNL_ETHERTYPE_MATCH_NOT_REQUIRED - The ethertype(s) specified for
903 * stripping do not affect the ethertype(s) specified for insertion and visa
906 enum virtchnl_vlan_ethertype_match {
907 VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION = 0,
908 VIRTCHNL_ETHERTYPE_MATCH_NOT_REQUIRED = 1,
911 /* The PF populates these fields based on the supported VLAN offloads. If a
912 * field is VIRTCHNL_VLAN_UNSUPPORTED then it's not supported and the PF will
913 * reject any VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 or
914 * VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 messages using the unsupported fields.
916 * Also, a VF is only allowed to toggle its VLAN offload setting if the
917 * VIRTCHNL_VLAN_TOGGLE_ALLOWED bit is set.
919 * The VF driver needs to be aware of how the tags are stripped by hardware and
920 * inserted by the VF driver based on the level of offload support. The PF will
921 * populate these fields based on where the VLAN tags are expected to be
922 * offloaded via the VIRTHCNL_VLAN_TAG_LOCATION_* bits. The VF will need to
923 * interpret these fields. See the definition of the
924 * VIRTCHNL_VLAN_TAG_LOCATION_* bits above the virtchnl_vlan_support
927 struct virtchnl_vlan_offload_caps {
928 struct virtchnl_vlan_supported_caps stripping_support;
929 struct virtchnl_vlan_supported_caps insertion_support;
935 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_vlan_offload_caps);
937 /* VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS
938 * VF sends this message to determine its VLAN capabilities.
940 * PF will mark which capabilities it supports based on hardware support and
941 * current configuration. For example, if a port VLAN is configured the PF will
942 * not allow outer VLAN filtering, stripping, or insertion to be configured so
943 * it will block these features from the VF.
945 * The VF will need to cross reference its capabilities with the PFs
946 * capabilities in the response message from the PF to determine the VLAN
949 struct virtchnl_vlan_caps {
950 struct virtchnl_vlan_filtering_caps filtering;
951 struct virtchnl_vlan_offload_caps offloads;
954 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_vlan_caps);
956 struct virtchnl_vlan {
957 u16 tci; /* tci[15:13] = PCP and tci[11:0] = VID */
958 u16 tci_mask; /* only valid if VIRTCHNL_VLAN_FILTER_MASK set in
961 u16 tpid; /* 0x8100, 0x88a8, etc. and only type(s) set in
962 * filtering caps. Note that tpid here does not refer to
963 * VIRTCHNL_VLAN_ETHERTYPE_*, but it refers to the
964 * actual 2-byte VLAN TPID
969 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_vlan);
971 struct virtchnl_vlan_filter {
972 struct virtchnl_vlan inner;
973 struct virtchnl_vlan outer;
977 VIRTCHNL_CHECK_STRUCT_LEN(32, virtchnl_vlan_filter);
979 /* VIRTCHNL_OP_ADD_VLAN_V2
980 * VIRTCHNL_OP_DEL_VLAN_V2
982 * VF sends these messages to add/del one or more VLAN tag filters for Rx
985 * The PF attempts to add the filters and returns status.
987 * The VF should only ever attempt to add/del virtchnl_vlan_filter(s) using the
988 * supported fields negotiated via VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS.
990 struct virtchnl_vlan_filter_list_v2 {
994 struct virtchnl_vlan_filter filters[1];
997 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_vlan_filter_list_v2);
999 /* VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2
1000 * VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2
1001 * VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2
1002 * VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2
1004 * VF sends this message to enable or disable VLAN stripping or insertion. It
1005 * also needs to specify an ethertype. The VF knows which VLAN ethertypes are
1006 * allowed and whether or not it's allowed to enable/disable the specific
1007 * offload via the VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS message. The VF needs to
1008 * parse the virtchnl_vlan_caps.offloads fields to determine which offload
1009 * messages are allowed.
1011 * For example, if the PF populates the virtchnl_vlan_caps.offloads in the
1012 * following manner the VF will be allowed to enable and/or disable 0x8100 inner
1013 * VLAN insertion and/or stripping via the opcodes listed above. Inner in this
1014 * case means the outer most or single VLAN from the VF's perspective. This is
1015 * because no outer offloads are supported. See the comments above the
1016 * virtchnl_vlan_supported_caps structure for more details.
1018 * virtchnl_vlan_caps.offloads.stripping_support.inner =
1019 * VIRTCHNL_VLAN_TOGGLE |
1020 * VIRTCHNL_VLAN_ETHERTYPE_8100;
1022 * virtchnl_vlan_caps.offloads.insertion_support.inner =
1023 * VIRTCHNL_VLAN_TOGGLE |
1024 * VIRTCHNL_VLAN_ETHERTYPE_8100;
1026 * In order to enable inner (again note that in this case inner is the outer
1027 * most or single VLAN from the VF's perspective) VLAN stripping for 0x8100
1028 * VLANs, the VF would populate the virtchnl_vlan_setting structure in the
1029 * following manner and send the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 message.
1031 * virtchnl_vlan_setting.inner_ethertype_setting =
1032 * VIRTCHNL_VLAN_ETHERTYPE_8100;
1034 * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on
1037 * The reason that VLAN TPID(s) are not being used for the
1038 * outer_ethertype_setting and inner_ethertype_setting fields is because it's
1039 * possible a device could support VLAN insertion and/or stripping offload on
1040 * multiple ethertypes concurrently, so this method allows a VF to request
1041 * multiple ethertypes in one message using the virtchnl_vlan_support
1044 * For example, if the PF populates the virtchnl_vlan_caps.offloads in the
1045 * following manner the VF will be allowed to enable 0x8100 and 0x88a8 outer
1046 * VLAN insertion and stripping simultaneously. The
1047 * virtchnl_vlan_caps.offloads.ethertype_match field will also have to be
1048 * populated based on what the PF can support.
1050 * virtchnl_vlan_caps.offloads.stripping_support.outer =
1051 * VIRTCHNL_VLAN_TOGGLE |
1052 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1053 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
1054 * VIRTCHNL_VLAN_ETHERTYPE_AND;
1056 * virtchnl_vlan_caps.offloads.insertion_support.outer =
1057 * VIRTCHNL_VLAN_TOGGLE |
1058 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1059 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
1060 * VIRTCHNL_VLAN_ETHERTYPE_AND;
1062 * In order to enable outer VLAN stripping for 0x8100 and 0x88a8 VLANs, the VF
1063 * would populate the virthcnl_vlan_offload_structure in the following manner
1064 * and send the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 message.
1066 * virtchnl_vlan_setting.outer_ethertype_setting =
1067 * VIRTHCNL_VLAN_ETHERTYPE_8100 |
1068 * VIRTHCNL_VLAN_ETHERTYPE_88A8;
1070 * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on
1073 * There is also the case where a PF and the underlying hardware can support
1074 * VLAN offloads on multiple ethertypes, but not concurrently. For example, if
1075 * the PF populates the virtchnl_vlan_caps.offloads in the following manner the
1076 * VF will be allowed to enable and/or disable 0x8100 XOR 0x88a8 outer VLAN
1077 * offloads. The ethertypes must match for stripping and insertion.
1079 * virtchnl_vlan_caps.offloads.stripping_support.outer =
1080 * VIRTCHNL_VLAN_TOGGLE |
1081 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1082 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
1083 * VIRTCHNL_VLAN_ETHERTYPE_XOR;
1085 * virtchnl_vlan_caps.offloads.insertion_support.outer =
1086 * VIRTCHNL_VLAN_TOGGLE |
1087 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1088 * VIRTCHNL_VLAN_ETHERTYPE_88A8 |
1089 * VIRTCHNL_VLAN_ETHERTYPE_XOR;
1091 * virtchnl_vlan_caps.offloads.ethertype_match =
1092 * VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION;
1094 * In order to enable outer VLAN stripping for 0x88a8 VLANs, the VF would
1095 * populate the virtchnl_vlan_setting structure in the following manner and send
1096 * the VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2. Also, this will change the
1097 * ethertype for VLAN insertion if it's enabled. So, for completeness, a
1098 * VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 with the same ethertype should be sent.
1100 * virtchnl_vlan_setting.outer_ethertype_setting = VIRTHCNL_VLAN_ETHERTYPE_88A8;
1102 * virtchnl_vlan_setting.vport_id = vport_id or vsi_id assigned to the VF on
1105 * VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2
1106 * VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2
1108 * VF sends this message to enable or disable VLAN filtering. It also needs to
1109 * specify an ethertype. The VF knows which VLAN ethertypes are allowed and
1110 * whether or not it's allowed to enable/disable filtering via the
1111 * VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS message. The VF needs to
1112 * parse the virtchnl_vlan_caps.filtering fields to determine which, if any,
1113 * filtering messages are allowed.
1115 * For example, if the PF populates the virtchnl_vlan_caps.filtering in the
1116 * following manner the VF will be allowed to enable/disable 0x8100 and 0x88a8
1117 * outer VLAN filtering together. Note, that the VIRTCHNL_VLAN_ETHERTYPE_AND
1118 * means that all filtering ethertypes will to be enabled and disabled together
1119 * regardless of the request from the VF. This means that the underlying
1120 * hardware only supports VLAN filtering for all VLAN the specified ethertypes
1123 * virtchnl_vlan_caps.filtering.filtering_support.outer =
1124 * VIRTCHNL_VLAN_TOGGLE |
1125 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1126 * VIRTHCNL_VLAN_ETHERTYPE_88A8 |
1127 * VIRTCHNL_VLAN_ETHERTYPE_9100 |
1128 * VIRTCHNL_VLAN_ETHERTYPE_AND;
1130 * In order to enable outer VLAN filtering for 0x88a8 and 0x8100 VLANs (0x9100
1131 * VLANs aren't supported by the VF driver), the VF would populate the
1132 * virtchnl_vlan_setting structure in the following manner and send the
1133 * VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2. The same message format would be used
1134 * to disable outer VLAN filtering for 0x88a8 and 0x8100 VLANs, but the
1135 * VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2 opcode is used.
1137 * virtchnl_vlan_setting.outer_ethertype_setting =
1138 * VIRTCHNL_VLAN_ETHERTYPE_8100 |
1139 * VIRTCHNL_VLAN_ETHERTYPE_88A8;
1142 struct virtchnl_vlan_setting {
1143 u32 outer_ethertype_setting;
1144 u32 inner_ethertype_setting;
1149 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vlan_setting);
1151 /* VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE
1152 * VF sends VSI id and flags.
1153 * PF returns status code in retval.
1154 * Note: we assume that broadcast accept mode is always enabled.
1156 struct virtchnl_promisc_info {
1161 VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_promisc_info);
1163 #define FLAG_VF_UNICAST_PROMISC 0x00000001
1164 #define FLAG_VF_MULTICAST_PROMISC 0x00000002
1166 /* VIRTCHNL_OP_GET_STATS
1167 * VF sends this message to request stats for the selected VSI. VF uses
1168 * the virtchnl_queue_select struct to specify the VSI. The queue_id
1169 * field is ignored by the PF.
1171 * PF replies with struct virtchnl_eth_stats in an external buffer.
1174 struct virtchnl_eth_stats {
1175 u64 rx_bytes; /* received bytes */
1176 u64 rx_unicast; /* received unicast pkts */
1177 u64 rx_multicast; /* received multicast pkts */
1178 u64 rx_broadcast; /* received broadcast pkts */
1180 u64 rx_unknown_protocol;
1181 u64 tx_bytes; /* transmitted bytes */
1182 u64 tx_unicast; /* transmitted unicast pkts */
1183 u64 tx_multicast; /* transmitted multicast pkts */
1184 u64 tx_broadcast; /* transmitted broadcast pkts */
1189 /* VIRTCHNL_OP_CONFIG_RSS_KEY
1190 * VIRTCHNL_OP_CONFIG_RSS_LUT
1191 * VF sends these messages to configure RSS. Only supported if both PF
1192 * and VF drivers set the VIRTCHNL_VF_OFFLOAD_RSS_PF bit during
1193 * configuration negotiation. If this is the case, then the RSS fields in
1194 * the VF resource struct are valid.
1195 * Both the key and LUT are initialized to 0 by the PF, meaning that
1196 * RSS is effectively disabled until set up by the VF.
1198 struct virtchnl_rss_key {
1201 u8 key[1]; /* RSS hash key, packed bytes */
1204 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_rss_key);
1206 struct virtchnl_rss_lut {
1209 u8 lut[1]; /* RSS lookup table */
1212 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_rss_lut);
1214 /* VIRTCHNL_OP_GET_RSS_HENA_CAPS
1215 * VIRTCHNL_OP_SET_RSS_HENA
1216 * VF sends these messages to get and set the hash filter enable bits for RSS.
1217 * By default, the PF sets these to all possible traffic types that the
1218 * hardware supports. The VF can query this value if it wants to change the
1219 * traffic types that are hashed by the hardware.
1221 struct virtchnl_rss_hena {
1225 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_rss_hena);
1227 /* Type of RSS algorithm */
1228 enum virtchnl_rss_algorithm {
1229 VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC = 0,
1230 VIRTCHNL_RSS_ALG_R_ASYMMETRIC = 1,
1231 VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC = 2,
1232 VIRTCHNL_RSS_ALG_XOR_SYMMETRIC = 3,
1235 /* This is used by PF driver to enforce how many channels can be supported.
1236 * When ADQ_V2 capability is negotiated, it will allow 16 channels otherwise
1237 * PF driver will allow only max 4 channels
1239 #define VIRTCHNL_MAX_ADQ_CHANNELS 4
1240 #define VIRTCHNL_MAX_ADQ_V2_CHANNELS 16
1242 /* VIRTCHNL_OP_ENABLE_CHANNELS
1243 * VIRTCHNL_OP_DISABLE_CHANNELS
1244 * VF sends these messages to enable or disable channels based on
1245 * the user specified queue count and queue offset for each traffic class.
1246 * This struct encompasses all the information that the PF needs from
1247 * VF to create a channel.
1249 struct virtchnl_channel_info {
1250 u16 count; /* number of queues in a channel */
1251 u16 offset; /* queues in a channel start from 'offset' */
1256 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_channel_info);
1258 struct virtchnl_tc_info {
1261 struct virtchnl_channel_info list[1];
1264 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_tc_info);
1266 /* VIRTCHNL_ADD_CLOUD_FILTER
1267 * VIRTCHNL_DEL_CLOUD_FILTER
1268 * VF sends these messages to add or delete a cloud filter based on the
1269 * user specified match and action filters. These structures encompass
1270 * all the information that the PF needs from the VF to add/delete a
1274 struct virtchnl_l4_spec {
1275 u8 src_mac[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
1276 u8 dst_mac[VIRTCHNL_ETH_LENGTH_OF_ADDRESS];
1277 /* vlan_prio is part of this 16 bit field even from OS perspective
1278 * vlan_id:12 is actual vlan_id, then vlanid:bit14..12 is vlan_prio
1279 * in future, when decided to offload vlan_prio, pass that information
1280 * as part of the "vlan_id" field, Bit14..12
1283 __be16 pad; /* reserved for future use */
1290 VIRTCHNL_CHECK_STRUCT_LEN(52, virtchnl_l4_spec);
1292 union virtchnl_flow_spec {
1293 struct virtchnl_l4_spec tcp_spec;
1294 u8 buffer[128]; /* reserved for future use */
1297 VIRTCHNL_CHECK_UNION_LEN(128, virtchnl_flow_spec);
1299 enum virtchnl_action {
1301 VIRTCHNL_ACTION_DROP = 0,
1302 VIRTCHNL_ACTION_TC_REDIRECT,
1303 VIRTCHNL_ACTION_PASSTHRU,
1304 VIRTCHNL_ACTION_QUEUE,
1305 VIRTCHNL_ACTION_Q_REGION,
1306 VIRTCHNL_ACTION_MARK,
1307 VIRTCHNL_ACTION_COUNT,
1310 enum virtchnl_flow_type {
1312 VIRTCHNL_TCP_V4_FLOW = 0,
1313 VIRTCHNL_TCP_V6_FLOW,
1314 VIRTCHNL_UDP_V4_FLOW,
1315 VIRTCHNL_UDP_V6_FLOW,
1318 struct virtchnl_filter {
1319 union virtchnl_flow_spec data;
1320 union virtchnl_flow_spec mask;
1322 /* see enum virtchnl_flow_type */
1325 /* see enum virtchnl_action */
1331 VIRTCHNL_CHECK_STRUCT_LEN(272, virtchnl_filter);
1333 struct virtchnl_shaper_bw {
1339 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_shaper_bw);
1341 /* VIRTCHNL_OP_EVENT
1342 * PF sends this message to inform the VF driver of events that may affect it.
1343 * No direct response is expected from the VF, though it may generate other
1344 * messages in response to this one.
1346 enum virtchnl_event_codes {
1347 VIRTCHNL_EVENT_UNKNOWN = 0,
1348 VIRTCHNL_EVENT_LINK_CHANGE,
1349 VIRTCHNL_EVENT_RESET_IMPENDING,
1350 VIRTCHNL_EVENT_PF_DRIVER_CLOSE,
1353 #define PF_EVENT_SEVERITY_INFO 0
1354 #define PF_EVENT_SEVERITY_ATTENTION 1
1355 #define PF_EVENT_SEVERITY_ACTION_REQUIRED 2
1356 #define PF_EVENT_SEVERITY_CERTAIN_DOOM 255
1358 struct virtchnl_pf_event {
1359 /* see enum virtchnl_event_codes */
1362 /* If the PF driver does not support the new speed reporting
1363 * capabilities then use link_event else use link_event_adv to
1364 * get the speed and link information. The ability to understand
1365 * new speeds is indicated by setting the capability flag
1366 * VIRTCHNL_VF_CAP_ADV_LINK_SPEED in vf_cap_flags parameter
1367 * in virtchnl_vf_resource struct and can be used to determine
1368 * which link event struct to use below.
1371 enum virtchnl_link_speed link_speed;
1376 /* link_speed provided in Mbps */
1382 /* link_speed provided in Mbps */
1387 } link_event_adv_vport;
1393 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_pf_event);
1395 /* VF reset states - these are written into the RSTAT register:
1396 * VFGEN_RSTAT on the VF
1397 * When the PF initiates a reset, it writes 0
1398 * When the reset is complete, it writes 1
1399 * When the PF detects that the VF has recovered, it writes 2
1400 * VF checks this register periodically to determine if a reset has occurred,
1401 * then polls it to know when the reset is complete.
1402 * If either the PF or VF reads the register while the hardware
1403 * is in a reset state, it will return DEADBEEF, which, when masked
1406 enum virtchnl_vfr_states {
1407 VIRTCHNL_VFR_INPROGRESS = 0,
1408 VIRTCHNL_VFR_COMPLETED,
1409 VIRTCHNL_VFR_VFACTIVE,
1412 #define VIRTCHNL_MAX_NUM_PROTO_HDRS 32
1413 #define PROTO_HDR_SHIFT 5
1414 #define PROTO_HDR_FIELD_START(proto_hdr_type) \
1415 (proto_hdr_type << PROTO_HDR_SHIFT)
1416 #define PROTO_HDR_FIELD_MASK ((1UL << PROTO_HDR_SHIFT) - 1)
1418 /* VF use these macros to configure each protocol header.
1419 * Specify which protocol headers and protocol header fields base on
1420 * virtchnl_proto_hdr_type and virtchnl_proto_hdr_field.
1421 * @param hdr: a struct of virtchnl_proto_hdr
1422 * @param hdr_type: ETH/IPV4/TCP, etc
1423 * @param field: SRC/DST/TEID/SPI, etc
1425 #define VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, field) \
1426 ((hdr)->field_selector |= BIT((field) & PROTO_HDR_FIELD_MASK))
1427 #define VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, field) \
1428 ((hdr)->field_selector &= ~BIT((field) & PROTO_HDR_FIELD_MASK))
1429 #define VIRTCHNL_TEST_PROTO_HDR_FIELD(hdr, val) \
1430 ((hdr)->field_selector & BIT((val) & PROTO_HDR_FIELD_MASK))
1431 #define VIRTCHNL_GET_PROTO_HDR_FIELD(hdr) ((hdr)->field_selector)
1433 #define VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \
1434 (VIRTCHNL_ADD_PROTO_HDR_FIELD(hdr, \
1435 VIRTCHNL_PROTO_HDR_ ## hdr_type ## _ ## field))
1436 #define VIRTCHNL_DEL_PROTO_HDR_FIELD_BIT(hdr, hdr_type, field) \
1437 (VIRTCHNL_DEL_PROTO_HDR_FIELD(hdr, \
1438 VIRTCHNL_PROTO_HDR_ ## hdr_type ## _ ## field))
1440 #define VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, hdr_type) \
1441 ((hdr)->type = VIRTCHNL_PROTO_HDR_ ## hdr_type)
1442 #define VIRTCHNL_GET_PROTO_HDR_TYPE(hdr) \
1443 (((hdr)->type) >> PROTO_HDR_SHIFT)
1444 #define VIRTCHNL_TEST_PROTO_HDR_TYPE(hdr, val) \
1445 ((hdr)->type == ((s32)((val) >> PROTO_HDR_SHIFT)))
1446 #define VIRTCHNL_TEST_PROTO_HDR(hdr, val) \
1447 (VIRTCHNL_TEST_PROTO_HDR_TYPE(hdr, val) && \
1448 VIRTCHNL_TEST_PROTO_HDR_FIELD(hdr, val))
1450 /* Protocol header type within a packet segment. A segment consists of one or
1451 * more protocol headers that make up a logical group of protocol headers. Each
1452 * logical group of protocol headers encapsulates or is encapsulated using/by
1453 * tunneling or encapsulation protocols for network virtualization.
1455 enum virtchnl_proto_hdr_type {
1456 VIRTCHNL_PROTO_HDR_NONE,
1457 VIRTCHNL_PROTO_HDR_ETH,
1458 VIRTCHNL_PROTO_HDR_S_VLAN,
1459 VIRTCHNL_PROTO_HDR_C_VLAN,
1460 VIRTCHNL_PROTO_HDR_IPV4,
1461 VIRTCHNL_PROTO_HDR_IPV6,
1462 VIRTCHNL_PROTO_HDR_TCP,
1463 VIRTCHNL_PROTO_HDR_UDP,
1464 VIRTCHNL_PROTO_HDR_SCTP,
1465 VIRTCHNL_PROTO_HDR_GTPU_IP,
1466 VIRTCHNL_PROTO_HDR_GTPU_EH,
1467 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN,
1468 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP,
1469 VIRTCHNL_PROTO_HDR_PPPOE,
1470 VIRTCHNL_PROTO_HDR_L2TPV3,
1471 VIRTCHNL_PROTO_HDR_ESP,
1472 VIRTCHNL_PROTO_HDR_AH,
1473 VIRTCHNL_PROTO_HDR_PFCP,
1474 VIRTCHNL_PROTO_HDR_GTPC,
1475 VIRTCHNL_PROTO_HDR_ECPRI,
1476 VIRTCHNL_PROTO_HDR_L2TPV2,
1477 VIRTCHNL_PROTO_HDR_PPP,
1478 /* IPv4 and IPv6 Fragment header types are only associated to
1479 * VIRTCHNL_PROTO_HDR_IPV4 and VIRTCHNL_PROTO_HDR_IPV6 respectively,
1480 * cannot be used independently.
1482 VIRTCHNL_PROTO_HDR_IPV4_FRAG,
1483 VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG,
1484 VIRTCHNL_PROTO_HDR_GRE,
1487 /* Protocol header field within a protocol header. */
1488 enum virtchnl_proto_hdr_field {
1490 VIRTCHNL_PROTO_HDR_ETH_SRC =
1491 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ETH),
1492 VIRTCHNL_PROTO_HDR_ETH_DST,
1493 VIRTCHNL_PROTO_HDR_ETH_ETHERTYPE,
1495 VIRTCHNL_PROTO_HDR_S_VLAN_ID =
1496 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_S_VLAN),
1498 VIRTCHNL_PROTO_HDR_C_VLAN_ID =
1499 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_C_VLAN),
1501 VIRTCHNL_PROTO_HDR_IPV4_SRC =
1502 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV4),
1503 VIRTCHNL_PROTO_HDR_IPV4_DST,
1504 VIRTCHNL_PROTO_HDR_IPV4_DSCP,
1505 VIRTCHNL_PROTO_HDR_IPV4_TTL,
1506 VIRTCHNL_PROTO_HDR_IPV4_PROT,
1507 VIRTCHNL_PROTO_HDR_IPV4_CHKSUM,
1509 VIRTCHNL_PROTO_HDR_IPV6_SRC =
1510 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV6),
1511 VIRTCHNL_PROTO_HDR_IPV6_DST,
1512 VIRTCHNL_PROTO_HDR_IPV6_TC,
1513 VIRTCHNL_PROTO_HDR_IPV6_HOP_LIMIT,
1514 VIRTCHNL_PROTO_HDR_IPV6_PROT,
1516 VIRTCHNL_PROTO_HDR_IPV6_PREFIX32_SRC,
1517 VIRTCHNL_PROTO_HDR_IPV6_PREFIX32_DST,
1518 VIRTCHNL_PROTO_HDR_IPV6_PREFIX40_SRC,
1519 VIRTCHNL_PROTO_HDR_IPV6_PREFIX40_DST,
1520 VIRTCHNL_PROTO_HDR_IPV6_PREFIX48_SRC,
1521 VIRTCHNL_PROTO_HDR_IPV6_PREFIX48_DST,
1522 VIRTCHNL_PROTO_HDR_IPV6_PREFIX56_SRC,
1523 VIRTCHNL_PROTO_HDR_IPV6_PREFIX56_DST,
1524 VIRTCHNL_PROTO_HDR_IPV6_PREFIX64_SRC,
1525 VIRTCHNL_PROTO_HDR_IPV6_PREFIX64_DST,
1526 VIRTCHNL_PROTO_HDR_IPV6_PREFIX96_SRC,
1527 VIRTCHNL_PROTO_HDR_IPV6_PREFIX96_DST,
1529 VIRTCHNL_PROTO_HDR_TCP_SRC_PORT =
1530 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_TCP),
1531 VIRTCHNL_PROTO_HDR_TCP_DST_PORT,
1532 VIRTCHNL_PROTO_HDR_TCP_CHKSUM,
1534 VIRTCHNL_PROTO_HDR_UDP_SRC_PORT =
1535 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_UDP),
1536 VIRTCHNL_PROTO_HDR_UDP_DST_PORT,
1537 VIRTCHNL_PROTO_HDR_UDP_CHKSUM,
1539 VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT =
1540 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_SCTP),
1541 VIRTCHNL_PROTO_HDR_SCTP_DST_PORT,
1542 VIRTCHNL_PROTO_HDR_SCTP_CHKSUM,
1544 VIRTCHNL_PROTO_HDR_GTPU_IP_TEID =
1545 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_IP),
1547 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU =
1548 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH),
1549 VIRTCHNL_PROTO_HDR_GTPU_EH_QFI,
1551 VIRTCHNL_PROTO_HDR_PPPOE_SESS_ID =
1552 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_PPPOE),
1554 VIRTCHNL_PROTO_HDR_L2TPV3_SESS_ID =
1555 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_L2TPV3),
1557 VIRTCHNL_PROTO_HDR_ESP_SPI =
1558 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ESP),
1560 VIRTCHNL_PROTO_HDR_AH_SPI =
1561 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_AH),
1563 VIRTCHNL_PROTO_HDR_PFCP_S_FIELD =
1564 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_PFCP),
1565 VIRTCHNL_PROTO_HDR_PFCP_SEID,
1567 VIRTCHNL_PROTO_HDR_GTPC_TEID =
1568 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPC),
1570 VIRTCHNL_PROTO_HDR_ECPRI_MSG_TYPE =
1571 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_ECPRI),
1572 VIRTCHNL_PROTO_HDR_ECPRI_PC_RTC_ID,
1573 /* IPv4 Dummy Fragment */
1574 VIRTCHNL_PROTO_HDR_IPV4_FRAG_PKID =
1575 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV4_FRAG),
1576 /* IPv6 Extension Fragment */
1577 VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG_PKID =
1578 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG),
1580 VIRTCHNL_PROTO_HDR_GTPU_DWN_QFI =
1581 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN),
1582 VIRTCHNL_PROTO_HDR_GTPU_UP_QFI =
1583 PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP),
1586 struct virtchnl_proto_hdr {
1587 /* see enum virtchnl_proto_hdr_type */
1589 u32 field_selector; /* a bit mask to select field for header type */
1592 * binary buffer in network order for specific header type.
1593 * For example, if type = VIRTCHNL_PROTO_HDR_IPV4, a IPv4
1594 * header is expected to be copied into the buffer.
1598 VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_proto_hdr);
1600 struct virtchnl_proto_hdrs {
1603 * specify where protocol header start from.
1604 * 0 - from the outer layer
1605 * 1 - from the first inner layer
1606 * 2 - from the second inner layer
1609 int count; /* the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS */
1610 struct virtchnl_proto_hdr proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
1613 VIRTCHNL_CHECK_STRUCT_LEN(2312, virtchnl_proto_hdrs);
1615 struct virtchnl_rss_cfg {
1616 struct virtchnl_proto_hdrs proto_hdrs; /* protocol headers */
1618 /* see enum virtchnl_rss_algorithm; rss algorithm type */
1620 u8 reserved[128]; /* reserve for future */
1623 VIRTCHNL_CHECK_STRUCT_LEN(2444, virtchnl_rss_cfg);
1625 /* action configuration for FDIR */
1626 struct virtchnl_filter_action {
1627 /* see enum virtchnl_action type */
1630 /* used for queue and qgroup action */
1635 /* used for count action */
1637 /* share counter ID with other flow rules */
1639 u32 id; /* counter ID */
1641 /* used for mark action */
1647 VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_filter_action);
1649 #define VIRTCHNL_MAX_NUM_ACTIONS 8
1651 struct virtchnl_filter_action_set {
1652 /* action number must be less then VIRTCHNL_MAX_NUM_ACTIONS */
1654 struct virtchnl_filter_action actions[VIRTCHNL_MAX_NUM_ACTIONS];
1657 VIRTCHNL_CHECK_STRUCT_LEN(292, virtchnl_filter_action_set);
1659 /* pattern and action for FDIR rule */
1660 struct virtchnl_fdir_rule {
1661 struct virtchnl_proto_hdrs proto_hdrs;
1662 struct virtchnl_filter_action_set action_set;
1665 VIRTCHNL_CHECK_STRUCT_LEN(2604, virtchnl_fdir_rule);
1667 /* Status returned to VF after VF requests FDIR commands
1668 * VIRTCHNL_FDIR_SUCCESS
1669 * VF FDIR related request is successfully done by PF
1670 * The request can be OP_ADD/DEL/QUERY_FDIR_FILTER.
1672 * VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE
1673 * OP_ADD_FDIR_FILTER request is failed due to no Hardware resource.
1675 * VIRTCHNL_FDIR_FAILURE_RULE_EXIST
1676 * OP_ADD_FDIR_FILTER request is failed due to the rule is already existed.
1678 * VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT
1679 * OP_ADD_FDIR_FILTER request is failed due to conflict with existing rule.
1681 * VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST
1682 * OP_DEL_FDIR_FILTER request is failed due to this rule doesn't exist.
1684 * VIRTCHNL_FDIR_FAILURE_RULE_INVALID
1685 * OP_ADD_FDIR_FILTER request is failed due to parameters validation
1686 * or HW doesn't support.
1688 * VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT
1689 * OP_ADD/DEL_FDIR_FILTER request is failed due to timing out
1692 * VIRTCHNL_FDIR_FAILURE_QUERY_INVALID
1693 * OP_QUERY_FDIR_FILTER request is failed due to parameters validation,
1694 * for example, VF query counter of a rule who has no counter action.
1696 enum virtchnl_fdir_prgm_status {
1697 VIRTCHNL_FDIR_SUCCESS = 0,
1698 VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE,
1699 VIRTCHNL_FDIR_FAILURE_RULE_EXIST,
1700 VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT,
1701 VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST,
1702 VIRTCHNL_FDIR_FAILURE_RULE_INVALID,
1703 VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT,
1704 VIRTCHNL_FDIR_FAILURE_QUERY_INVALID,
1707 /* VIRTCHNL_OP_ADD_FDIR_FILTER
1708 * VF sends this request to PF by filling out vsi_id,
1709 * validate_only and rule_cfg. PF will return flow_id
1710 * if the request is successfully done and return add_status to VF.
1712 struct virtchnl_fdir_add {
1713 u16 vsi_id; /* INPUT */
1715 * 1 for validating a fdir rule, 0 for creating a fdir rule.
1716 * Validate and create share one ops: VIRTCHNL_OP_ADD_FDIR_FILTER.
1718 u16 validate_only; /* INPUT */
1719 u32 flow_id; /* OUTPUT */
1720 struct virtchnl_fdir_rule rule_cfg; /* INPUT */
1722 /* see enum virtchnl_fdir_prgm_status; OUTPUT */
1726 VIRTCHNL_CHECK_STRUCT_LEN(2616, virtchnl_fdir_add);
1728 /* VIRTCHNL_OP_DEL_FDIR_FILTER
1729 * VF sends this request to PF by filling out vsi_id
1730 * and flow_id. PF will return del_status to VF.
1732 struct virtchnl_fdir_del {
1733 u16 vsi_id; /* INPUT */
1735 u32 flow_id; /* INPUT */
1737 /* see enum virtchnl_fdir_prgm_status; OUTPUT */
1741 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del);
1743 /* VIRTCHNL_OP_GET_QOS_CAPS
1744 * VF sends this message to get its QoS Caps, such as
1745 * TC number, Arbiter and Bandwidth.
1747 struct virtchnl_qos_cap_elem {
1750 #define VIRTCHNL_ABITER_STRICT 0
1751 #define VIRTCHNL_ABITER_ETS 2
1753 #define VIRTCHNL_STRICT_WEIGHT 1
1755 enum virtchnl_bw_limit_type type;
1757 struct virtchnl_shaper_bw shaper;
1762 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_qos_cap_elem);
1764 struct virtchnl_qos_cap_list {
1767 struct virtchnl_qos_cap_elem cap[1];
1770 VIRTCHNL_CHECK_STRUCT_LEN(44, virtchnl_qos_cap_list);
1772 /* VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP
1773 * VF sends message virtchnl_queue_tc_mapping to set queue to tc
1774 * mapping for all the Tx and Rx queues with a specified VSI, and
1775 * would get response about bitmap of valid user priorities
1776 * associated with queues.
1778 struct virtchnl_queue_tc_mapping {
1781 u16 num_queue_pairs;
1789 #define VIRTCHNL_USER_PRIO_TYPE_UP 0
1790 #define VIRTCHNL_USER_PRIO_TYPE_DSCP 1
1792 u16 valid_prio_bitmap;
1797 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_tc_mapping);
1799 /* TX and RX queue types are valid in legacy as well as split queue models.
1800 * With Split Queue model, 2 additional types are introduced - TX_COMPLETION
1801 * and RX_BUFFER. In split queue model, RX corresponds to the queue where HW
1802 * posts completions.
1804 enum virtchnl_queue_type {
1805 VIRTCHNL_QUEUE_TYPE_TX = 0,
1806 VIRTCHNL_QUEUE_TYPE_RX = 1,
1807 VIRTCHNL_QUEUE_TYPE_TX_COMPLETION = 2,
1808 VIRTCHNL_QUEUE_TYPE_RX_BUFFER = 3,
1809 VIRTCHNL_QUEUE_TYPE_CONFIG_TX = 4,
1810 VIRTCHNL_QUEUE_TYPE_CONFIG_RX = 5
1813 /* structure to specify a chunk of contiguous queues */
1814 struct virtchnl_queue_chunk {
1815 /* see enum virtchnl_queue_type */
1821 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_queue_chunk);
1823 /* structure to specify several chunks of contiguous queues */
1824 struct virtchnl_queue_chunks {
1827 struct virtchnl_queue_chunk chunks[1];
1830 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_chunks);
1832 /* VIRTCHNL_OP_ENABLE_QUEUES_V2
1833 * VIRTCHNL_OP_DISABLE_QUEUES_V2
1834 * VIRTCHNL_OP_DEL_QUEUES
1836 * If VIRTCHNL version was negotiated in VIRTCHNL_OP_VERSION as 2.0
1837 * then all of these ops are available.
1839 * If VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
1840 * then VIRTCHNL_OP_ENABLE_QUEUES_V2 and VIRTCHNL_OP_DISABLE_QUEUES_V2 are
1843 * PF sends these messages to enable, disable or delete queues specified in
1844 * chunks. PF sends virtchnl_del_ena_dis_queues struct to specify the queues
1845 * to be enabled/disabled/deleted. Also applicable to single queue RX or
1846 * TX. CP performs requested action and returns status.
1848 struct virtchnl_del_ena_dis_queues {
1851 struct virtchnl_queue_chunks chunks;
1854 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_del_ena_dis_queues);
1856 /* Virtchannel interrupt throttling rate index */
1857 enum virtchnl_itr_idx {
1858 VIRTCHNL_ITR_IDX_0 = 0,
1859 VIRTCHNL_ITR_IDX_1 = 1,
1860 VIRTCHNL_ITR_IDX_NO_ITR = 3,
1863 /* Queue to vector mapping */
1864 struct virtchnl_queue_vector {
1869 /* see enum virtchnl_itr_idx */
1872 /* see enum virtchnl_queue_type */
1876 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_queue_vector);
1878 /* VIRTCHNL_OP_MAP_QUEUE_VECTOR
1880 * If VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in VIRTCHNL_OP_GET_VF_RESOURCES
1881 * then only VIRTCHNL_OP_MAP_QUEUE_VECTOR is available.
1883 * PF sends this message to map or unmap queues to vectors and ITR index
1884 * registers. External data buffer contains virtchnl_queue_vector_maps structure
1885 * that contains num_qv_maps of virtchnl_queue_vector structures.
1886 * CP maps the requested queue vector maps after validating the queue and vector
1887 * ids and returns a status code.
1889 struct virtchnl_queue_vector_maps {
1893 struct virtchnl_queue_vector qv_maps[1];
1896 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_queue_vector_maps);
1898 /* Since VF messages are limited by u16 size, precalculate the maximum possible
1899 * values of nested elements in virtchnl structures that virtual channel can
1900 * possibly handle in a single message.
1902 enum virtchnl_vector_limits {
1903 VIRTCHNL_OP_CONFIG_VSI_QUEUES_MAX =
1904 ((u16)(~0) - sizeof(struct virtchnl_vsi_queue_config_info)) /
1905 sizeof(struct virtchnl_queue_pair_info),
1907 VIRTCHNL_OP_CONFIG_IRQ_MAP_MAX =
1908 ((u16)(~0) - sizeof(struct virtchnl_irq_map_info)) /
1909 sizeof(struct virtchnl_vector_map),
1911 VIRTCHNL_OP_ADD_DEL_ETH_ADDR_MAX =
1912 ((u16)(~0) - sizeof(struct virtchnl_ether_addr_list)) /
1913 sizeof(struct virtchnl_ether_addr),
1915 VIRTCHNL_OP_ADD_DEL_VLAN_MAX =
1916 ((u16)(~0) - sizeof(struct virtchnl_vlan_filter_list)) /
1919 VIRTCHNL_OP_ENABLE_CHANNELS_MAX =
1920 ((u16)(~0) - sizeof(struct virtchnl_tc_info)) /
1921 sizeof(struct virtchnl_channel_info),
1923 VIRTCHNL_OP_ENABLE_DISABLE_DEL_QUEUES_V2_MAX =
1924 ((u16)(~0) - sizeof(struct virtchnl_del_ena_dis_queues)) /
1925 sizeof(struct virtchnl_queue_chunk),
1927 VIRTCHNL_OP_MAP_UNMAP_QUEUE_VECTOR_MAX =
1928 ((u16)(~0) - sizeof(struct virtchnl_queue_vector_maps)) /
1929 sizeof(struct virtchnl_queue_vector),
1931 VIRTCHNL_OP_ADD_DEL_VLAN_V2_MAX =
1932 ((u16)(~0) - sizeof(struct virtchnl_vlan_filter_list_v2)) /
1933 sizeof(struct virtchnl_vlan_filter),
1937 * virtchnl_vc_validate_vf_msg
1938 * @ver: Virtchnl version info
1939 * @v_opcode: Opcode for the message
1940 * @msg: pointer to the msg buffer
1941 * @msglen: msg length
1943 * validate msg format against struct for each opcode
1946 virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
1947 u8 *msg, u16 msglen)
1949 bool err_msg_format = false;
1952 /* Validate message length. */
1954 case VIRTCHNL_OP_VERSION:
1955 valid_len = sizeof(struct virtchnl_version_info);
1957 case VIRTCHNL_OP_RESET_VF:
1959 case VIRTCHNL_OP_GET_VF_RESOURCES:
1961 valid_len = sizeof(u32);
1963 case VIRTCHNL_OP_CONFIG_TX_QUEUE:
1964 valid_len = sizeof(struct virtchnl_txq_info);
1966 case VIRTCHNL_OP_CONFIG_RX_QUEUE:
1967 valid_len = sizeof(struct virtchnl_rxq_info);
1969 case VIRTCHNL_OP_CONFIG_VSI_QUEUES:
1970 valid_len = sizeof(struct virtchnl_vsi_queue_config_info);
1971 if (msglen >= valid_len) {
1972 struct virtchnl_vsi_queue_config_info *vqc =
1973 (struct virtchnl_vsi_queue_config_info *)msg;
1975 if (vqc->num_queue_pairs == 0 || vqc->num_queue_pairs >
1976 VIRTCHNL_OP_CONFIG_VSI_QUEUES_MAX) {
1977 err_msg_format = true;
1981 valid_len += (vqc->num_queue_pairs *
1983 virtchnl_queue_pair_info));
1986 case VIRTCHNL_OP_CONFIG_IRQ_MAP:
1987 valid_len = sizeof(struct virtchnl_irq_map_info);
1988 if (msglen >= valid_len) {
1989 struct virtchnl_irq_map_info *vimi =
1990 (struct virtchnl_irq_map_info *)msg;
1992 if (vimi->num_vectors == 0 || vimi->num_vectors >
1993 VIRTCHNL_OP_CONFIG_IRQ_MAP_MAX) {
1994 err_msg_format = true;
1998 valid_len += (vimi->num_vectors *
1999 sizeof(struct virtchnl_vector_map));
2002 case VIRTCHNL_OP_ENABLE_QUEUES:
2003 case VIRTCHNL_OP_DISABLE_QUEUES:
2004 valid_len = sizeof(struct virtchnl_queue_select);
2006 case VIRTCHNL_OP_GET_MAX_RSS_QREGION:
2008 case VIRTCHNL_OP_ADD_ETH_ADDR:
2009 case VIRTCHNL_OP_DEL_ETH_ADDR:
2010 valid_len = sizeof(struct virtchnl_ether_addr_list);
2011 if (msglen >= valid_len) {
2012 struct virtchnl_ether_addr_list *veal =
2013 (struct virtchnl_ether_addr_list *)msg;
2015 if (veal->num_elements == 0 || veal->num_elements >
2016 VIRTCHNL_OP_ADD_DEL_ETH_ADDR_MAX) {
2017 err_msg_format = true;
2021 valid_len += veal->num_elements *
2022 sizeof(struct virtchnl_ether_addr);
2025 case VIRTCHNL_OP_ADD_VLAN:
2026 case VIRTCHNL_OP_DEL_VLAN:
2027 valid_len = sizeof(struct virtchnl_vlan_filter_list);
2028 if (msglen >= valid_len) {
2029 struct virtchnl_vlan_filter_list *vfl =
2030 (struct virtchnl_vlan_filter_list *)msg;
2032 if (vfl->num_elements == 0 || vfl->num_elements >
2033 VIRTCHNL_OP_ADD_DEL_VLAN_MAX) {
2034 err_msg_format = true;
2038 valid_len += vfl->num_elements * sizeof(u16);
2041 case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE:
2042 valid_len = sizeof(struct virtchnl_promisc_info);
2044 case VIRTCHNL_OP_GET_STATS:
2045 valid_len = sizeof(struct virtchnl_queue_select);
2047 case VIRTCHNL_OP_CONFIG_RSS_KEY:
2048 valid_len = sizeof(struct virtchnl_rss_key);
2049 if (msglen >= valid_len) {
2050 struct virtchnl_rss_key *vrk =
2051 (struct virtchnl_rss_key *)msg;
2053 if (vrk->key_len == 0) {
2054 /* zero length is allowed as input */
2058 valid_len += vrk->key_len - 1;
2061 case VIRTCHNL_OP_CONFIG_RSS_LUT:
2062 valid_len = sizeof(struct virtchnl_rss_lut);
2063 if (msglen >= valid_len) {
2064 struct virtchnl_rss_lut *vrl =
2065 (struct virtchnl_rss_lut *)msg;
2067 if (vrl->lut_entries == 0) {
2068 /* zero entries is allowed as input */
2072 valid_len += vrl->lut_entries - 1;
2075 case VIRTCHNL_OP_GET_RSS_HENA_CAPS:
2077 case VIRTCHNL_OP_SET_RSS_HENA:
2078 valid_len = sizeof(struct virtchnl_rss_hena);
2080 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING:
2081 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING:
2083 case VIRTCHNL_OP_REQUEST_QUEUES:
2084 valid_len = sizeof(struct virtchnl_vf_res_request);
2086 case VIRTCHNL_OP_ENABLE_CHANNELS:
2087 valid_len = sizeof(struct virtchnl_tc_info);
2088 if (msglen >= valid_len) {
2089 struct virtchnl_tc_info *vti =
2090 (struct virtchnl_tc_info *)msg;
2092 if (vti->num_tc == 0 || vti->num_tc >
2093 VIRTCHNL_OP_ENABLE_CHANNELS_MAX) {
2094 err_msg_format = true;
2098 valid_len += (vti->num_tc - 1) *
2099 sizeof(struct virtchnl_channel_info);
2102 case VIRTCHNL_OP_DISABLE_CHANNELS:
2104 case VIRTCHNL_OP_ADD_CLOUD_FILTER:
2105 case VIRTCHNL_OP_DEL_CLOUD_FILTER:
2106 valid_len = sizeof(struct virtchnl_filter);
2108 case VIRTCHNL_OP_ADD_RSS_CFG:
2109 case VIRTCHNL_OP_DEL_RSS_CFG:
2110 valid_len = sizeof(struct virtchnl_rss_cfg);
2112 case VIRTCHNL_OP_ADD_FDIR_FILTER:
2113 valid_len = sizeof(struct virtchnl_fdir_add);
2115 case VIRTCHNL_OP_DEL_FDIR_FILTER:
2116 valid_len = sizeof(struct virtchnl_fdir_del);
2118 case VIRTCHNL_OP_GET_QOS_CAPS:
2120 case VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP:
2121 valid_len = sizeof(struct virtchnl_queue_tc_mapping);
2122 if (msglen >= valid_len) {
2123 struct virtchnl_queue_tc_mapping *q_tc =
2124 (struct virtchnl_queue_tc_mapping *)msg;
2125 if (q_tc->num_tc == 0) {
2126 err_msg_format = true;
2129 valid_len += (q_tc->num_tc - 1) *
2130 sizeof(q_tc->tc[0]);
2133 case VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS:
2135 case VIRTCHNL_OP_ADD_VLAN_V2:
2136 case VIRTCHNL_OP_DEL_VLAN_V2:
2137 valid_len = sizeof(struct virtchnl_vlan_filter_list_v2);
2138 if (msglen >= valid_len) {
2139 struct virtchnl_vlan_filter_list_v2 *vfl =
2140 (struct virtchnl_vlan_filter_list_v2 *)msg;
2142 if (vfl->num_elements == 0 || vfl->num_elements >
2143 VIRTCHNL_OP_ADD_DEL_VLAN_V2_MAX) {
2144 err_msg_format = true;
2148 valid_len += (vfl->num_elements - 1) *
2149 sizeof(struct virtchnl_vlan_filter);
2152 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2:
2153 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2:
2154 case VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2:
2155 case VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2:
2156 case VIRTCHNL_OP_ENABLE_VLAN_FILTERING_V2:
2157 case VIRTCHNL_OP_DISABLE_VLAN_FILTERING_V2:
2158 valid_len = sizeof(struct virtchnl_vlan_setting);
2160 case VIRTCHNL_OP_ENABLE_QUEUES_V2:
2161 case VIRTCHNL_OP_DISABLE_QUEUES_V2:
2162 valid_len = sizeof(struct virtchnl_del_ena_dis_queues);
2163 if (msglen >= valid_len) {
2164 struct virtchnl_del_ena_dis_queues *qs =
2165 (struct virtchnl_del_ena_dis_queues *)msg;
2166 if (qs->chunks.num_chunks == 0 ||
2167 qs->chunks.num_chunks > VIRTCHNL_OP_ENABLE_DISABLE_DEL_QUEUES_V2_MAX) {
2168 err_msg_format = true;
2171 valid_len += (qs->chunks.num_chunks - 1) *
2172 sizeof(struct virtchnl_queue_chunk);
2175 case VIRTCHNL_OP_MAP_QUEUE_VECTOR:
2176 valid_len = sizeof(struct virtchnl_queue_vector_maps);
2177 if (msglen >= valid_len) {
2178 struct virtchnl_queue_vector_maps *v_qp =
2179 (struct virtchnl_queue_vector_maps *)msg;
2180 if (v_qp->num_qv_maps == 0 ||
2181 v_qp->num_qv_maps > VIRTCHNL_OP_MAP_UNMAP_QUEUE_VECTOR_MAX) {
2182 err_msg_format = true;
2185 valid_len += (v_qp->num_qv_maps - 1) *
2186 sizeof(struct virtchnl_queue_vector);
2189 /* These are always errors coming from the VF. */
2190 case VIRTCHNL_OP_EVENT:
2191 case VIRTCHNL_OP_UNKNOWN:
2193 return VIRTCHNL_STATUS_ERR_PARAM;
2195 /* few more checks */
2196 if (err_msg_format || valid_len != msglen)
2197 return VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH;
2201 #endif /* _VIRTCHNL_H_ */