1 /*******************************************************************************
3 * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver
4 * Copyright(c) 2013 - 2014 Intel Corporation.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along
16 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 * The full GNU General Public License is included in this distribution in
19 * the file called "COPYING".
21 * Contact Information:
23 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 ******************************************************************************/
31 * This header file describes the VF-PF communication protocol used
32 * by the drivers for all devices starting from our 40G product line
34 * Admin queue buffer usage:
35 * desc->opcode is always aqc_opc_send_msg_to_pf
36 * flags, retval, datalen, and data addr are all used normally.
37 * The Firmware copies the cookie fields when sending messages between the
38 * PF and VF, but uses all other fields internally. Due to this limitation,
39 * we must send all messages as "indirect", i.e. using an external buffer.
41 * All the VSI indexes are relative to the VF. Each VF can have maximum of
42 * three VSIs. All the queue indexes are relative to the VSI. Each VF can
43 * have a maximum of sixteen queues for all of its VSIs.
45 * The PF is required to return a status code in v_retval for all messages
46 * except RESET_VF, which does not require any response. The return value
47 * is of status_code type, defined in the shared type.h.
49 * In general, VF driver initialization should roughly follow the order of
50 * these opcodes. The VF driver must first validate the API version of the
51 * PF driver, then request a reset, then get resources, then configure
52 * queues and interrupts. After these operations are complete, the VF
53 * driver may start its queues, optionally add MAC and VLAN filters, and
57 /* START GENERIC DEFINES
58 * Need to ensure the following enums and defines hold the same meaning and
59 * value in current and future projects
63 enum virtchnl_status_code {
64 VIRTCHNL_STATUS_SUCCESS = 0,
65 VIRTCHNL_STATUS_ERR_PARAM = -5,
66 VIRTCHNL_STATUS_ERR_NO_MEMORY = -18,
67 VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH = -38,
68 VIRTCHNL_STATUS_ERR_CQP_COMPL_ERROR = -39,
69 VIRTCHNL_STATUS_ERR_INVALID_VF_ID = -40,
70 VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR = -53,
71 VIRTCHNL_STATUS_ERR_NOT_SUPPORTED = -64,
74 /* Backward compatibility */
75 #define VIRTCHNL_ERR_PARAM VIRTCHNL_STATUS_ERR_PARAM
76 #define VIRTCHNL_STATUS_NOT_SUPPORTED VIRTCHNL_STATUS_ERR_NOT_SUPPORTED
78 #define VIRTCHNL_LINK_SPEED_100MB_SHIFT 0x1
79 #define VIRTCHNL_LINK_SPEED_1000MB_SHIFT 0x2
80 #define VIRTCHNL_LINK_SPEED_10GB_SHIFT 0x3
81 #define VIRTCHNL_LINK_SPEED_40GB_SHIFT 0x4
82 #define VIRTCHNL_LINK_SPEED_20GB_SHIFT 0x5
83 #define VIRTCHNL_LINK_SPEED_25GB_SHIFT 0x6
85 enum virtchnl_link_speed {
86 VIRTCHNL_LINK_SPEED_UNKNOWN = 0,
87 VIRTCHNL_LINK_SPEED_100MB = BIT(VIRTCHNL_LINK_SPEED_100MB_SHIFT),
88 VIRTCHNL_LINK_SPEED_1GB = BIT(VIRTCHNL_LINK_SPEED_1000MB_SHIFT),
89 VIRTCHNL_LINK_SPEED_10GB = BIT(VIRTCHNL_LINK_SPEED_10GB_SHIFT),
90 VIRTCHNL_LINK_SPEED_40GB = BIT(VIRTCHNL_LINK_SPEED_40GB_SHIFT),
91 VIRTCHNL_LINK_SPEED_20GB = BIT(VIRTCHNL_LINK_SPEED_20GB_SHIFT),
92 VIRTCHNL_LINK_SPEED_25GB = BIT(VIRTCHNL_LINK_SPEED_25GB_SHIFT),
95 /* for hsplit_0 field of Rx HMC context */
96 /* deprecated with AVF 1.0 */
97 enum virtchnl_rx_hsplit {
98 VIRTCHNL_RX_HSPLIT_NO_SPLIT = 0,
99 VIRTCHNL_RX_HSPLIT_SPLIT_L2 = 1,
100 VIRTCHNL_RX_HSPLIT_SPLIT_IP = 2,
101 VIRTCHNL_RX_HSPLIT_SPLIT_TCP_UDP = 4,
102 VIRTCHNL_RX_HSPLIT_SPLIT_SCTP = 8,
105 /* END GENERIC DEFINES */
107 /* Opcodes for VF-PF communication. These are placed in the v_opcode field
108 * of the virtchnl_msg structure.
111 /* The PF sends status change events to VFs using
112 * the VIRTCHNL_OP_EVENT opcode.
113 * VFs send requests to the PF using the other ops.
114 * Use of "advanced opcode" features must be negotiated as part of capabilities
115 * exchange and are not considered part of base mode feature set.
117 VIRTCHNL_OP_UNKNOWN = 0,
118 VIRTCHNL_OP_VERSION = 1, /* must ALWAYS be 1 */
119 VIRTCHNL_OP_RESET_VF = 2,
120 VIRTCHNL_OP_GET_VF_RESOURCES = 3,
121 VIRTCHNL_OP_CONFIG_TX_QUEUE = 4,
122 VIRTCHNL_OP_CONFIG_RX_QUEUE = 5,
123 VIRTCHNL_OP_CONFIG_VSI_QUEUES = 6,
124 VIRTCHNL_OP_CONFIG_IRQ_MAP = 7,
125 VIRTCHNL_OP_ENABLE_QUEUES = 8,
126 VIRTCHNL_OP_DISABLE_QUEUES = 9,
127 VIRTCHNL_OP_ADD_ETH_ADDR = 10,
128 VIRTCHNL_OP_DEL_ETH_ADDR = 11,
129 VIRTCHNL_OP_ADD_VLAN = 12,
130 VIRTCHNL_OP_DEL_VLAN = 13,
131 VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE = 14,
132 VIRTCHNL_OP_GET_STATS = 15,
133 VIRTCHNL_OP_RSVD = 16,
134 VIRTCHNL_OP_EVENT = 17, /* must ALWAYS be 17 */
135 VIRTCHNL_OP_IWARP = 20, /* advanced opcode */
136 VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP = 21, /* advanced opcode */
137 VIRTCHNL_OP_RELEASE_IWARP_IRQ_MAP = 22, /* advanced opcode */
138 VIRTCHNL_OP_CONFIG_RSS_KEY = 23,
139 VIRTCHNL_OP_CONFIG_RSS_LUT = 24,
140 VIRTCHNL_OP_GET_RSS_HENA_CAPS = 25,
141 VIRTCHNL_OP_SET_RSS_HENA = 26,
142 VIRTCHNL_OP_ENABLE_VLAN_STRIPPING = 27,
143 VIRTCHNL_OP_DISABLE_VLAN_STRIPPING = 28,
144 VIRTCHNL_OP_REQUEST_QUEUES = 29,
145 VIRTCHNL_OP_ENABLE_CHANNELS = 30,
146 VIRTCHNL_OP_DISABLE_CHANNELS = 31,
147 VIRTCHNL_OP_ADD_CLOUD_FILTER = 32,
148 VIRTCHNL_OP_DEL_CLOUD_FILTER = 33,
151 /* These macros are used to generate compilation errors if a structure/union
152 * is not exactly the correct length. It gives a divide by zero error if the
153 * structure/union is not of the correct size, otherwise it creates an enum
154 * that is never used.
156 #define VIRTCHNL_CHECK_STRUCT_LEN(n, X) enum virtchnl_static_assert_enum_##X \
157 { virtchnl_static_assert_##X = (n)/((sizeof(struct X) == (n)) ? 1 : 0) }
158 #define VIRTCHNL_CHECK_UNION_LEN(n, X) enum virtchnl_static_asset_enum_##X \
159 { virtchnl_static_assert_##X = (n)/((sizeof(union X) == (n)) ? 1 : 0) }
161 /* Virtual channel message descriptor. This overlays the admin queue
162 * descriptor. All other data is passed in external buffers.
165 struct virtchnl_msg {
166 u8 pad[8]; /* AQ flags/opcode/len/retval fields */
167 enum virtchnl_ops v_opcode; /* avoid confusion with desc->opcode */
168 enum virtchnl_status_code v_retval; /* ditto for desc->retval */
169 u32 vfid; /* used by PF when sending to VF */
172 VIRTCHNL_CHECK_STRUCT_LEN(20, virtchnl_msg);
174 /* Message descriptions and data structures.*/
176 /* VIRTCHNL_OP_VERSION
177 * VF posts its version number to the PF. PF responds with its version number
178 * in the same format, along with a return code.
179 * Reply from PF has its major/minor versions also in param0 and param1.
180 * If there is a major version mismatch, then the VF cannot operate.
181 * If there is a minor version mismatch, then the VF can operate but should
182 * add a warning to the system log.
184 * This enum element MUST always be specified as == 1, regardless of other
185 * changes in the API. The PF must always respond to this message without
186 * error regardless of version mismatch.
188 #define VIRTCHNL_VERSION_MAJOR 1
189 #define VIRTCHNL_VERSION_MINOR 1
190 #define VIRTCHNL_VERSION_MINOR_NO_VF_CAPS 0
192 struct virtchnl_version_info {
197 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_version_info);
199 #define VF_IS_V10(_v) (((_v)->major == 1) && ((_v)->minor == 0))
200 #define VF_IS_V11(_ver) (((_ver)->major == 1) && ((_ver)->minor == 1))
202 /* VIRTCHNL_OP_RESET_VF
203 * VF sends this request to PF with no parameters
204 * PF does NOT respond! VF driver must delay then poll VFGEN_RSTAT register
205 * until reset completion is indicated. The admin queue must be reinitialized
206 * after this operation.
208 * When reset is complete, PF must ensure that all queues in all VSIs associated
209 * with the VF are stopped, all queue configurations in the HMC are set to 0,
210 * and all MAC and VLAN filters (except the default MAC address) on all VSIs
214 /* VSI types that use VIRTCHNL interface for VF-PF communication. VSI_SRIOV
215 * vsi_type should always be 6 for backward compatibility. Add other fields
218 enum virtchnl_vsi_type {
219 VIRTCHNL_VSI_TYPE_INVALID = 0,
220 VIRTCHNL_VSI_SRIOV = 6,
223 /* VIRTCHNL_OP_GET_VF_RESOURCES
224 * Version 1.0 VF sends this request to PF with no parameters
225 * Version 1.1 VF sends this request to PF with u32 bitmap of its capabilities
226 * PF responds with an indirect message containing
227 * virtchnl_vf_resource and one or more
228 * virtchnl_vsi_resource structures.
231 struct virtchnl_vsi_resource {
234 enum virtchnl_vsi_type vsi_type;
236 u8 default_mac_addr[ETH_ALEN];
239 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
241 /* VF capability flags
242 * VIRTCHNL_VF_OFFLOAD_L2 flag is inclusive of base mode L2 offloads including
243 * TX/RX Checksum offloading and TSO for non-tunnelled packets.
245 #define VIRTCHNL_VF_OFFLOAD_L2 0x00000001
246 #define VIRTCHNL_VF_OFFLOAD_IWARP 0x00000002
247 #define VIRTCHNL_VF_OFFLOAD_RSVD 0x00000004
248 #define VIRTCHNL_VF_OFFLOAD_RSS_AQ 0x00000008
249 #define VIRTCHNL_VF_OFFLOAD_RSS_REG 0x00000010
250 #define VIRTCHNL_VF_OFFLOAD_WB_ON_ITR 0x00000020
251 #define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES 0x00000040
252 #define VIRTCHNL_VF_OFFLOAD_VLAN 0x00010000
253 #define VIRTCHNL_VF_OFFLOAD_RX_POLLING 0x00020000
254 #define VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 0x00040000
255 #define VIRTCHNL_VF_OFFLOAD_RSS_PF 0X00080000
256 #define VIRTCHNL_VF_OFFLOAD_ENCAP 0X00100000
257 #define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM 0X00200000
258 #define VIRTCHNL_VF_OFFLOAD_RX_ENCAP_CSUM 0X00400000
259 #define VIRTCHNL_VF_OFFLOAD_ADQ 0X00800000
261 /* Define below the capability flags that are not offloads */
262 #define VIRTCHNL_VF_CAP_ADV_LINK_SPEED 0x00000080
263 #define VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \
264 VIRTCHNL_VF_OFFLOAD_VLAN | \
265 VIRTCHNL_VF_OFFLOAD_RSS_PF)
267 struct virtchnl_vf_resource {
277 struct virtchnl_vsi_resource vsi_res[1];
280 VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_vf_resource);
282 /* VIRTCHNL_OP_CONFIG_TX_QUEUE
283 * VF sends this message to set up parameters for one TX queue.
284 * External data buffer contains one instance of virtchnl_txq_info.
285 * PF configures requested queue and returns a status code.
288 /* Tx queue config info */
289 struct virtchnl_txq_info {
292 u16 ring_len; /* number of descriptors, multiple of 8 */
293 u16 headwb_enabled; /* deprecated with AVF 1.0 */
295 u64 dma_headwb_addr; /* deprecated with AVF 1.0 */
298 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_txq_info);
300 /* VIRTCHNL_OP_CONFIG_RX_QUEUE
301 * VF sends this message to set up parameters for one RX queue.
302 * External data buffer contains one instance of virtchnl_rxq_info.
303 * PF configures requested queue and returns a status code.
306 /* Rx queue config info */
307 struct virtchnl_rxq_info {
310 u32 ring_len; /* number of descriptors, multiple of 32 */
312 u16 splithdr_enabled; /* deprecated with AVF 1.0 */
317 enum virtchnl_rx_hsplit rx_split_pos; /* deprecated with AVF 1.0 */
321 VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_rxq_info);
323 /* VIRTCHNL_OP_CONFIG_VSI_QUEUES
324 * VF sends this message to set parameters for all active TX and RX queues
325 * associated with the specified VSI.
326 * PF configures queues and returns status.
327 * If the number of queues specified is greater than the number of queues
328 * associated with the VSI, an error is returned and no queues are configured.
330 struct virtchnl_queue_pair_info {
331 /* NOTE: vsi_id and queue_id should be identical for both queues. */
332 struct virtchnl_txq_info txq;
333 struct virtchnl_rxq_info rxq;
336 VIRTCHNL_CHECK_STRUCT_LEN(64, virtchnl_queue_pair_info);
338 struct virtchnl_vsi_queue_config_info {
342 struct virtchnl_queue_pair_info qpair[1];
345 /* VIRTCHNL_OP_REQUEST_QUEUES
346 * VF sends this message to request the PF to allocate additional queues to
347 * this VF. Each VF gets a guaranteed number of queues on init but asking for
348 * additional queues must be negotiated. This is a best effort request as it
349 * is possible the PF does not have enough queues left to support the request.
350 * If the PF cannot support the number requested it will respond with the
351 * maximum number it is able to support. If the request is successful, PF will
352 * then reset the VF to institute required changes.
355 /* VF resource request */
356 struct virtchnl_vf_res_request {
360 VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_vsi_queue_config_info);
362 /* VIRTCHNL_OP_CONFIG_IRQ_MAP
363 * VF uses this message to map vectors to queues.
364 * The rxq_map and txq_map fields are bitmaps used to indicate which queues
365 * are to be associated with the specified vector.
366 * The "other" causes are always mapped to vector 0.
367 * PF configures interrupt mapping and returns status.
369 struct virtchnl_vector_map {
378 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_vector_map);
380 struct virtchnl_irq_map_info {
382 struct virtchnl_vector_map vecmap[1];
385 VIRTCHNL_CHECK_STRUCT_LEN(14, virtchnl_irq_map_info);
387 /* VIRTCHNL_OP_ENABLE_QUEUES
388 * VIRTCHNL_OP_DISABLE_QUEUES
389 * VF sends these message to enable or disable TX/RX queue pairs.
390 * The queues fields are bitmaps indicating which queues to act upon.
391 * (Currently, we only support 16 queues per VF, but we make the field
392 * u32 to allow for expansion.)
393 * PF performs requested action and returns status.
395 struct virtchnl_queue_select {
402 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_select);
404 /* VIRTCHNL_OP_ADD_ETH_ADDR
405 * VF sends this message in order to add one or more unicast or multicast
406 * address filters for the specified VSI.
407 * PF adds the filters and returns status.
410 /* VIRTCHNL_OP_DEL_ETH_ADDR
411 * VF sends this message in order to remove one or more unicast or multicast
412 * filters for the specified VSI.
413 * PF removes the filters and returns status.
416 struct virtchnl_ether_addr {
421 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_ether_addr);
423 struct virtchnl_ether_addr_list {
426 struct virtchnl_ether_addr list[1];
429 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_ether_addr_list);
431 /* VIRTCHNL_OP_ADD_VLAN
432 * VF sends this message to add one or more VLAN tag filters for receives.
433 * PF adds the filters and returns status.
434 * If a port VLAN is configured by the PF, this operation will return an
438 /* VIRTCHNL_OP_DEL_VLAN
439 * VF sends this message to remove one or more VLAN tag filters for receives.
440 * PF removes the filters and returns status.
441 * If a port VLAN is configured by the PF, this operation will return an
445 struct virtchnl_vlan_filter_list {
451 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_vlan_filter_list);
453 /* VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE
454 * VF sends VSI id and flags.
455 * PF returns status code in retval.
456 * Note: we assume that broadcast accept mode is always enabled.
458 struct virtchnl_promisc_info {
463 VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_promisc_info);
465 #define FLAG_VF_UNICAST_PROMISC 0x00000001
466 #define FLAG_VF_MULTICAST_PROMISC 0x00000002
468 /* VIRTCHNL_OP_GET_STATS
469 * VF sends this message to request stats for the selected VSI. VF uses
470 * the virtchnl_queue_select struct to specify the VSI. The queue_id
471 * field is ignored by the PF.
473 * PF replies with struct eth_stats in an external buffer.
476 /* VIRTCHNL_OP_CONFIG_RSS_KEY
477 * VIRTCHNL_OP_CONFIG_RSS_LUT
478 * VF sends these messages to configure RSS. Only supported if both PF
479 * and VF drivers set the VIRTCHNL_VF_OFFLOAD_RSS_PF bit during
480 * configuration negotiation. If this is the case, then the RSS fields in
481 * the VF resource struct are valid.
482 * Both the key and LUT are initialized to 0 by the PF, meaning that
483 * RSS is effectively disabled until set up by the VF.
485 struct virtchnl_rss_key {
488 u8 key[1]; /* RSS hash key, packed bytes */
491 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_rss_key);
493 struct virtchnl_rss_lut {
496 u8 lut[1]; /* RSS lookup table */
499 VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_rss_lut);
501 /* VIRTCHNL_OP_GET_RSS_HENA_CAPS
502 * VIRTCHNL_OP_SET_RSS_HENA
503 * VF sends these messages to get and set the hash filter enable bits for RSS.
504 * By default, the PF sets these to all possible traffic types that the
505 * hardware supports. The VF can query this value if it wants to change the
506 * traffic types that are hashed by the hardware.
508 struct virtchnl_rss_hena {
512 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_rss_hena);
514 /* VIRTCHNL_OP_ENABLE_CHANNELS
515 * VIRTCHNL_OP_DISABLE_CHANNELS
516 * VF sends these messages to enable or disable channels based on
517 * the user specified queue count and queue offset for each traffic class.
518 * This struct encompasses all the information that the PF needs from
519 * VF to create a channel.
521 struct virtchnl_channel_info {
522 u16 count; /* number of queues in a channel */
523 u16 offset; /* queues in a channel start from 'offset' */
528 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_channel_info);
530 struct virtchnl_tc_info {
533 struct virtchnl_channel_info list[1];
536 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_tc_info);
538 /* VIRTCHNL_ADD_CLOUD_FILTER
539 * VIRTCHNL_DEL_CLOUD_FILTER
540 * VF sends these messages to add or delete a cloud filter based on the
541 * user specified match and action filters. These structures encompass
542 * all the information that the PF needs from the VF to add/delete a
546 struct virtchnl_l4_spec {
547 u8 src_mac[ETH_ALEN];
548 u8 dst_mac[ETH_ALEN];
550 __be16 pad; /* reserved for future use */
557 VIRTCHNL_CHECK_STRUCT_LEN(52, virtchnl_l4_spec);
559 union virtchnl_flow_spec {
560 struct virtchnl_l4_spec tcp_spec;
561 u8 buffer[128]; /* reserved for future use */
564 VIRTCHNL_CHECK_UNION_LEN(128, virtchnl_flow_spec);
566 enum virtchnl_action {
568 VIRTCHNL_ACTION_DROP = 0,
569 VIRTCHNL_ACTION_TC_REDIRECT,
572 enum virtchnl_flow_type {
574 VIRTCHNL_TCP_V4_FLOW = 0,
575 VIRTCHNL_TCP_V6_FLOW,
578 struct virtchnl_filter {
579 union virtchnl_flow_spec data;
580 union virtchnl_flow_spec mask;
581 enum virtchnl_flow_type flow_type;
582 enum virtchnl_action action;
587 VIRTCHNL_CHECK_STRUCT_LEN(272, virtchnl_filter);
590 * PF sends this message to inform the VF driver of events that may affect it.
591 * No direct response is expected from the VF, though it may generate other
592 * messages in response to this one.
594 enum virtchnl_event_codes {
595 VIRTCHNL_EVENT_UNKNOWN = 0,
596 VIRTCHNL_EVENT_LINK_CHANGE,
597 VIRTCHNL_EVENT_RESET_IMPENDING,
598 VIRTCHNL_EVENT_PF_DRIVER_CLOSE,
601 #define PF_EVENT_SEVERITY_INFO 0
602 #define PF_EVENT_SEVERITY_CERTAIN_DOOM 255
604 struct virtchnl_pf_event {
605 enum virtchnl_event_codes event;
607 /* If the PF driver does not support the new speed reporting
608 * capabilities then use link_event else use link_event_adv to
609 * get the speed and link information. The ability to understand
610 * new speeds is indicated by setting the capability flag
611 * VIRTCHNL_VF_CAP_ADV_LINK_SPEED in vf_cap_flags parameter
612 * in virtchnl_vf_resource struct and can be used to determine
613 * which link event struct to use below.
616 enum virtchnl_link_speed link_speed;
620 /* link_speed provided in Mbps */
629 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_pf_event);
631 /* VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP
632 * VF uses this message to request PF to map IWARP vectors to IWARP queues.
633 * The request for this originates from the VF IWARP driver through
634 * a client interface between VF LAN and VF IWARP driver.
635 * A vector could have an AEQ and CEQ attached to it although
636 * there is a single AEQ per VF IWARP instance in which case
637 * most vectors will have an INVALID_IDX for aeq and valid idx for ceq.
638 * There will never be a case where there will be multiple CEQs attached
639 * to a single vector.
640 * PF configures interrupt mapping and returns status.
643 struct virtchnl_iwarp_qv_info {
644 u32 v_idx; /* msix_vector */
650 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_iwarp_qv_info);
652 struct virtchnl_iwarp_qvlist_info {
654 struct virtchnl_iwarp_qv_info qv_info[1];
657 VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_iwarp_qvlist_info);
659 /* VF reset states - these are written into the RSTAT register:
660 * VFGEN_RSTAT on the VF
661 * When the PF initiates a reset, it writes 0
662 * When the reset is complete, it writes 1
663 * When the PF detects that the VF has recovered, it writes 2
664 * VF checks this register periodically to determine if a reset has occurred,
665 * then polls it to know when the reset is complete.
666 * If either the PF or VF reads the register while the hardware
667 * is in a reset state, it will return DEADBEEF, which, when masked
670 enum virtchnl_vfr_states {
671 VIRTCHNL_VFR_INPROGRESS = 0,
672 VIRTCHNL_VFR_COMPLETED,
673 VIRTCHNL_VFR_VFACTIVE,
677 * virtchnl_vc_validate_vf_msg
678 * @ver: Virtchnl version info
679 * @v_opcode: Opcode for the message
680 * @msg: pointer to the msg buffer
681 * @msglen: msg length
683 * validate msg format against struct for each opcode
686 virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
689 bool err_msg_format = false;
692 /* Validate message length. */
694 case VIRTCHNL_OP_VERSION:
695 valid_len = sizeof(struct virtchnl_version_info);
697 case VIRTCHNL_OP_RESET_VF:
699 case VIRTCHNL_OP_GET_VF_RESOURCES:
701 valid_len = sizeof(u32);
703 case VIRTCHNL_OP_CONFIG_TX_QUEUE:
704 valid_len = sizeof(struct virtchnl_txq_info);
706 case VIRTCHNL_OP_CONFIG_RX_QUEUE:
707 valid_len = sizeof(struct virtchnl_rxq_info);
709 case VIRTCHNL_OP_CONFIG_VSI_QUEUES:
710 valid_len = sizeof(struct virtchnl_vsi_queue_config_info);
711 if (msglen >= valid_len) {
712 struct virtchnl_vsi_queue_config_info *vqc =
713 (struct virtchnl_vsi_queue_config_info *)msg;
714 valid_len += (vqc->num_queue_pairs *
716 virtchnl_queue_pair_info));
717 if (vqc->num_queue_pairs == 0)
718 err_msg_format = true;
721 case VIRTCHNL_OP_CONFIG_IRQ_MAP:
722 valid_len = sizeof(struct virtchnl_irq_map_info);
723 if (msglen >= valid_len) {
724 struct virtchnl_irq_map_info *vimi =
725 (struct virtchnl_irq_map_info *)msg;
726 valid_len += (vimi->num_vectors *
727 sizeof(struct virtchnl_vector_map));
728 if (vimi->num_vectors == 0)
729 err_msg_format = true;
732 case VIRTCHNL_OP_ENABLE_QUEUES:
733 case VIRTCHNL_OP_DISABLE_QUEUES:
734 valid_len = sizeof(struct virtchnl_queue_select);
736 case VIRTCHNL_OP_ADD_ETH_ADDR:
737 case VIRTCHNL_OP_DEL_ETH_ADDR:
738 valid_len = sizeof(struct virtchnl_ether_addr_list);
739 if (msglen >= valid_len) {
740 struct virtchnl_ether_addr_list *veal =
741 (struct virtchnl_ether_addr_list *)msg;
742 valid_len += veal->num_elements *
743 sizeof(struct virtchnl_ether_addr);
744 if (veal->num_elements == 0)
745 err_msg_format = true;
748 case VIRTCHNL_OP_ADD_VLAN:
749 case VIRTCHNL_OP_DEL_VLAN:
750 valid_len = sizeof(struct virtchnl_vlan_filter_list);
751 if (msglen >= valid_len) {
752 struct virtchnl_vlan_filter_list *vfl =
753 (struct virtchnl_vlan_filter_list *)msg;
754 valid_len += vfl->num_elements * sizeof(u16);
755 if (vfl->num_elements == 0)
756 err_msg_format = true;
759 case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE:
760 valid_len = sizeof(struct virtchnl_promisc_info);
762 case VIRTCHNL_OP_GET_STATS:
763 valid_len = sizeof(struct virtchnl_queue_select);
765 case VIRTCHNL_OP_IWARP:
766 /* These messages are opaque to us and will be validated in
767 * the RDMA client code. We just need to check for nonzero
768 * length. The firmware will enforce max length restrictions.
773 err_msg_format = true;
775 case VIRTCHNL_OP_RELEASE_IWARP_IRQ_MAP:
777 case VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP:
778 valid_len = sizeof(struct virtchnl_iwarp_qvlist_info);
779 if (msglen >= valid_len) {
780 struct virtchnl_iwarp_qvlist_info *qv =
781 (struct virtchnl_iwarp_qvlist_info *)msg;
782 if (qv->num_vectors == 0) {
783 err_msg_format = true;
786 valid_len += ((qv->num_vectors - 1) *
787 sizeof(struct virtchnl_iwarp_qv_info));
790 case VIRTCHNL_OP_CONFIG_RSS_KEY:
791 valid_len = sizeof(struct virtchnl_rss_key);
792 if (msglen >= valid_len) {
793 struct virtchnl_rss_key *vrk =
794 (struct virtchnl_rss_key *)msg;
795 valid_len += vrk->key_len - 1;
798 case VIRTCHNL_OP_CONFIG_RSS_LUT:
799 valid_len = sizeof(struct virtchnl_rss_lut);
800 if (msglen >= valid_len) {
801 struct virtchnl_rss_lut *vrl =
802 (struct virtchnl_rss_lut *)msg;
803 valid_len += vrl->lut_entries - 1;
806 case VIRTCHNL_OP_GET_RSS_HENA_CAPS:
808 case VIRTCHNL_OP_SET_RSS_HENA:
809 valid_len = sizeof(struct virtchnl_rss_hena);
811 case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING:
812 case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING:
814 case VIRTCHNL_OP_REQUEST_QUEUES:
815 valid_len = sizeof(struct virtchnl_vf_res_request);
817 case VIRTCHNL_OP_ENABLE_CHANNELS:
818 valid_len = sizeof(struct virtchnl_tc_info);
819 if (msglen >= valid_len) {
820 struct virtchnl_tc_info *vti =
821 (struct virtchnl_tc_info *)msg;
822 valid_len += vti->num_tc *
823 sizeof(struct virtchnl_channel_info);
824 if (vti->num_tc == 0)
825 err_msg_format = true;
828 case VIRTCHNL_OP_DISABLE_CHANNELS:
830 case VIRTCHNL_OP_ADD_CLOUD_FILTER:
831 valid_len = sizeof(struct virtchnl_filter);
833 case VIRTCHNL_OP_DEL_CLOUD_FILTER:
834 valid_len = sizeof(struct virtchnl_filter);
836 /* These are always errors coming from the VF. */
837 case VIRTCHNL_OP_EVENT:
838 case VIRTCHNL_OP_UNKNOWN:
840 return VIRTCHNL_STATUS_ERR_PARAM;
842 /* few more checks */
843 if (err_msg_format || valid_len != msglen)
844 return VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH;
848 #endif /* _VIRTCHNL_H_ */