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:
22 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
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 various i40e drivers.
34 * Admin queue buffer usage:
35 * desc->opcode is always i40e_aqc_opc_send_msg_to_pf
36 * flags, retval, datalen, and data addr are all used normally.
37 * Firmware copies the cookie fields when sending messages between the PF and
38 * VF, but uses all other fields internally. Due to this limitation, we
39 * 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 is of
47 * i40e_status_code type, defined in the i40e_type.h.
49 * In general, VF driver initialization should roughly follow the order of these
50 * opcodes. The VF driver must first validate the API version of the PF driver,
51 * then request a reset, then get resources, then configure queues and
52 * interrupts. After these operations are complete, the VF driver may start
53 * its queues, optionally add MAC and VLAN filters, and process traffic.
56 /* START GENERIC DEFINES
57 * Need to ensure the following enums and defines hold the same meaning and
58 * value in current and future projects
62 enum virtchnl_status_code {
63 VIRTCHNL_STATUS_SUCCESS = 0,
64 VIRTCHNL_ERR_PARAM = -5,
65 VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH = -38,
66 VIRTCHNL_STATUS_ERR_CQP_COMPL_ERROR = -39,
67 VIRTCHNL_STATUS_ERR_INVALID_VF_ID = -40,
68 VIRTCHNL_STATUS_NOT_SUPPORTED = -64,
71 /* END GENERIC DEFINES */
73 /* Opcodes for VF-PF communication. These are placed in the v_opcode field
74 * of the virtchnl_msg structure.
77 /* The PF sends status change events to VFs using
78 * the VIRTCHNL_OP_EVENT opcode.
79 * VFs send requests to the PF using the other ops.
81 VIRTCHNL_OP_UNKNOWN = 0,
82 VIRTCHNL_OP_VERSION = 1, /* must ALWAYS be 1 */
83 VIRTCHNL_OP_RESET_VF = 2,
84 VIRTCHNL_OP_GET_VF_RESOURCES = 3,
85 VIRTCHNL_OP_CONFIG_TX_QUEUE = 4,
86 VIRTCHNL_OP_CONFIG_RX_QUEUE = 5,
87 VIRTCHNL_OP_CONFIG_VSI_QUEUES = 6,
88 VIRTCHNL_OP_CONFIG_IRQ_MAP = 7,
89 VIRTCHNL_OP_ENABLE_QUEUES = 8,
90 VIRTCHNL_OP_DISABLE_QUEUES = 9,
91 VIRTCHNL_OP_ADD_ETH_ADDR = 10,
92 VIRTCHNL_OP_DEL_ETH_ADDR = 11,
93 VIRTCHNL_OP_ADD_VLAN = 12,
94 VIRTCHNL_OP_DEL_VLAN = 13,
95 VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE = 14,
96 VIRTCHNL_OP_GET_STATS = 15,
97 VIRTCHNL_OP_RSVD = 16,
98 VIRTCHNL_OP_EVENT = 17, /* must ALWAYS be 17 */
99 VIRTCHNL_OP_IWARP = 20,
100 VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP = 21,
101 VIRTCHNL_OP_RELEASE_IWARP_IRQ_MAP = 22,
102 VIRTCHNL_OP_CONFIG_RSS_KEY = 23,
103 VIRTCHNL_OP_CONFIG_RSS_LUT = 24,
104 VIRTCHNL_OP_GET_RSS_HENA_CAPS = 25,
105 VIRTCHNL_OP_SET_RSS_HENA = 26,
109 /* Virtual channel message descriptor. This overlays the admin queue
110 * descriptor. All other data is passed in external buffers.
113 struct virtchnl_msg {
114 u8 pad[8]; /* AQ flags/opcode/len/retval fields */
115 enum virtchnl_ops v_opcode; /* avoid confusion with desc->opcode */
116 i40e_status v_retval; /* ditto for desc->retval */
117 u32 vfid; /* used by PF when sending to VF */
120 /* Message descriptions and data structures.*/
122 /* VIRTCHNL_OP_VERSION
123 * VF posts its version number to the PF. PF responds with its version number
124 * in the same format, along with a return code.
125 * Reply from PF has its major/minor versions also in param0 and param1.
126 * If there is a major version mismatch, then the VF cannot operate.
127 * If there is a minor version mismatch, then the VF can operate but should
128 * add a warning to the system log.
130 * This enum element MUST always be specified as == 1, regardless of other
131 * changes in the API. The PF must always respond to this message without
132 * error regardless of version mismatch.
134 #define VIRTCHNL_VERSION_MAJOR 1
135 #define VIRTCHNL_VERSION_MINOR 1
136 #define VIRTCHNL_VERSION_MINOR_NO_VF_CAPS 0
138 struct virtchnl_version_info {
143 #define VF_IS_V10(_v) (((_v)->major == 1) && ((_v)->minor == 0))
144 #define VF_IS_V11(_ver) (((_ver)->major == 1) && ((_ver)->minor == 1))
146 /* VIRTCHNL_OP_RESET_VF
147 * VF sends this request to PF with no parameters
148 * PF does NOT respond! VF driver must delay then poll VFGEN_RSTAT register
149 * until reset completion is indicated. The admin queue must be reinitialized
150 * after this operation.
152 * When reset is complete, PF must ensure that all queues in all VSIs associated
153 * with the VF are stopped, all queue configurations in the HMC are set to 0,
154 * and all MAC and VLAN filters (except the default MAC address) on all VSIs
158 /* VIRTCHNL_OP_GET_VF_RESOURCES
159 * Version 1.0 VF sends this request to PF with no parameters
160 * Version 1.1 VF sends this request to PF with u32 bitmap of its capabilities
161 * PF responds with an indirect message containing
162 * virtchnl_vf_resource and one or more
163 * virtchnl_vsi_resource structures.
166 struct virtchnl_vsi_resource {
169 enum i40e_vsi_type vsi_type;
171 u8 default_mac_addr[ETH_ALEN];
173 /* VF offload flags */
174 #define VIRTCHNL_VF_OFFLOAD_L2 0x00000001
175 #define VIRTCHNL_VF_OFFLOAD_IWARP 0x00000002
176 #define VIRTCHNL_VF_OFFLOAD_FCOE 0x00000004
177 #define VIRTCHNL_VF_OFFLOAD_RSS_AQ 0x00000008
178 #define VIRTCHNL_VF_OFFLOAD_RSS_REG 0x00000010
179 #define VIRTCHNL_VF_OFFLOAD_WB_ON_ITR 0x00000020
180 #define VIRTCHNL_VF_OFFLOAD_VLAN 0x00010000
181 #define VIRTCHNL_VF_OFFLOAD_RX_POLLING 0x00020000
182 #define VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 0x00040000
183 #define VIRTCHNL_VF_OFFLOAD_RSS_PF 0X00080000
184 #define VIRTCHNL_VF_OFFLOAD_ENCAP 0X00100000
185 #define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM 0X00200000
187 #define I40E_VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \
188 VIRTCHNL_VF_OFFLOAD_VLAN | \
189 VIRTCHNL_VF_OFFLOAD_RSS_PF)
191 struct virtchnl_vf_resource {
197 u32 vf_offload_flags;
201 struct virtchnl_vsi_resource vsi_res[1];
204 /* VIRTCHNL_OP_CONFIG_TX_QUEUE
205 * VF sends this message to set up parameters for one TX queue.
206 * External data buffer contains one instance of virtchnl_txq_info.
207 * PF configures requested queue and returns a status code.
210 /* Tx queue config info */
211 struct virtchnl_txq_info {
214 u16 ring_len; /* number of descriptors, multiple of 8 */
220 /* VIRTCHNL_OP_CONFIG_RX_QUEUE
221 * VF sends this message to set up parameters for one RX queue.
222 * External data buffer contains one instance of virtchnl_rxq_info.
223 * PF configures requested queue and returns a status code.
226 /* Rx queue config info */
227 struct virtchnl_rxq_info {
230 u32 ring_len; /* number of descriptors, multiple of 32 */
232 u16 splithdr_enabled;
236 enum i40e_hmc_obj_rx_hsplit_0 rx_split_pos;
239 /* VIRTCHNL_OP_CONFIG_VSI_QUEUES
240 * VF sends this message to set parameters for all active TX and RX queues
241 * associated with the specified VSI.
242 * PF configures queues and returns status.
243 * If the number of queues specified is greater than the number of queues
244 * associated with the VSI, an error is returned and no queues are configured.
246 struct virtchnl_queue_pair_info {
247 /* NOTE: vsi_id and queue_id should be identical for both queues. */
248 struct virtchnl_txq_info txq;
249 struct virtchnl_rxq_info rxq;
252 struct virtchnl_vsi_queue_config_info {
255 struct virtchnl_queue_pair_info qpair[1];
258 /* VIRTCHNL_OP_CONFIG_IRQ_MAP
259 * VF uses this message to map vectors to queues.
260 * The rxq_map and txq_map fields are bitmaps used to indicate which queues
261 * are to be associated with the specified vector.
262 * The "other" causes are always mapped to vector 0.
263 * PF configures interrupt mapping and returns status.
265 struct virtchnl_vector_map {
274 struct virtchnl_irq_map_info {
276 struct virtchnl_vector_map vecmap[1];
279 /* VIRTCHNL_OP_ENABLE_QUEUES
280 * VIRTCHNL_OP_DISABLE_QUEUES
281 * VF sends these message to enable or disable TX/RX queue pairs.
282 * The queues fields are bitmaps indicating which queues to act upon.
283 * (Currently, we only support 16 queues per VF, but we make the field
284 * u32 to allow for expansion.)
285 * PF performs requested action and returns status.
287 struct virtchnl_queue_select {
294 /* VIRTCHNL_OP_ADD_ETH_ADDR
295 * VF sends this message in order to add one or more unicast or multicast
296 * address filters for the specified VSI.
297 * PF adds the filters and returns status.
300 /* VIRTCHNL_OP_DEL_ETH_ADDR
301 * VF sends this message in order to remove one or more unicast or multicast
302 * filters for the specified VSI.
303 * PF removes the filters and returns status.
306 struct virtchnl_ether_addr {
311 struct virtchnl_ether_addr_list {
314 struct virtchnl_ether_addr list[1];
317 /* VIRTCHNL_OP_ADD_VLAN
318 * VF sends this message to add one or more VLAN tag filters for receives.
319 * PF adds the filters and returns status.
320 * If a port VLAN is configured by the PF, this operation will return an
324 /* VIRTCHNL_OP_DEL_VLAN
325 * VF sends this message to remove one or more VLAN tag filters for receives.
326 * PF removes the filters and returns status.
327 * If a port VLAN is configured by the PF, this operation will return an
331 struct virtchnl_vlan_filter_list {
337 /* VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE
338 * VF sends VSI id and flags.
339 * PF returns status code in retval.
340 * Note: we assume that broadcast accept mode is always enabled.
342 struct virtchnl_promisc_info {
347 #define I40E_FLAG_VF_UNICAST_PROMISC 0x00000001
348 #define I40E_FLAG_VF_MULTICAST_PROMISC 0x00000002
350 /* VIRTCHNL_OP_GET_STATS
351 * VF sends this message to request stats for the selected VSI. VF uses
352 * the virtchnl_queue_select struct to specify the VSI. The queue_id
353 * field is ignored by the PF.
355 * PF replies with struct i40e_eth_stats in an external buffer.
358 /* VIRTCHNL_OP_CONFIG_RSS_KEY
359 * VIRTCHNL_OP_CONFIG_RSS_LUT
360 * VF sends these messages to configure RSS. Only supported if both PF
361 * and VF drivers set the VIRTCHNL_VF_OFFLOAD_RSS_PF bit during
362 * configuration negotiation. If this is the case, then the RSS fields in
363 * the VF resource struct are valid.
364 * Both the key and LUT are initialized to 0 by the PF, meaning that
365 * RSS is effectively disabled until set up by the VF.
367 struct virtchnl_rss_key {
370 u8 key[1]; /* RSS hash key, packed bytes */
373 struct virtchnl_rss_lut {
376 u8 lut[1]; /* RSS lookup table*/
379 /* VIRTCHNL_OP_GET_RSS_HENA_CAPS
380 * VIRTCHNL_OP_SET_RSS_HENA
381 * VF sends these messages to get and set the hash filter enable bits for RSS.
382 * By default, the PF sets these to all possible traffic types that the
383 * hardware supports. The VF can query this value if it wants to change the
384 * traffic types that are hashed by the hardware.
385 * Traffic types are defined in the i40e_filter_pctype enum in i40e_type.h
387 struct virtchnl_rss_hena {
392 * PF sends this message to inform the VF driver of events that may affect it.
393 * No direct response is expected from the VF, though it may generate other
394 * messages in response to this one.
396 enum virtchnl_event_codes {
397 VIRTCHNL_EVENT_UNKNOWN = 0,
398 VIRTCHNL_EVENT_LINK_CHANGE,
399 VIRTCHNL_EVENT_RESET_IMPENDING,
400 VIRTCHNL_EVENT_PF_DRIVER_CLOSE,
402 #define I40E_PF_EVENT_SEVERITY_INFO 0
403 #define I40E_PF_EVENT_SEVERITY_CERTAIN_DOOM 255
405 struct virtchnl_pf_event {
406 enum virtchnl_event_codes event;
409 enum i40e_aq_link_speed link_speed;
417 /* VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP
418 * VF uses this message to request PF to map IWARP vectors to IWARP queues.
419 * The request for this originates from the VF IWARP driver through
420 * a client interface between VF LAN and VF IWARP driver.
421 * A vector could have an AEQ and CEQ attached to it although
422 * there is a single AEQ per VF IWARP instance in which case
423 * most vectors will have an INVALID_IDX for aeq and valid idx for ceq.
424 * There will never be a case where there will be multiple CEQs attached
425 * to a single vector.
426 * PF configures interrupt mapping and returns status.
429 /* HW does not define a type value for AEQ; only for RX/TX and CEQ.
430 * In order for us to keep the interface simple, SW will define a
431 * unique type value for AEQ.
433 #define I40E_QUEUE_TYPE_PE_AEQ 0x80
434 #define I40E_QUEUE_INVALID_IDX 0xFFFF
436 struct virtchnl_iwarp_qv_info {
437 u32 v_idx; /* msix_vector */
443 struct virtchnl_iwarp_qvlist_info {
445 struct virtchnl_iwarp_qv_info qv_info[1];
448 /* VF reset states - these are written into the RSTAT register:
449 * I40E_VFGEN_RSTAT1 on the PF
450 * I40E_VFGEN_RSTAT on the VF
451 * When the PF initiates a reset, it writes 0
452 * When the reset is complete, it writes 1
453 * When the PF detects that the VF has recovered, it writes 2
454 * VF checks this register periodically to determine if a reset has occurred,
455 * then polls it to know when the reset is complete.
456 * If either the PF or VF reads the register while the hardware
457 * is in a reset state, it will return DEADBEEF, which, when masked
460 enum virtchnl_vfr_states {
461 VIRTCHNL_VFR_INPROGRESS = 0,
462 VIRTCHNL_VFR_COMPLETED,
463 VIRTCHNL_VFR_VFACTIVE,
464 VIRTCHNL_VFR_UNKNOWN,
467 #endif /* _VIRTCHNL_H_ */