1 /******************************************************************************
3 Copyright (c) 2013-2015, Intel Corporation
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
16 3. Neither the name of the Intel Corporation nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
32 ******************************************************************************/
35 #ifndef _I40E_VIRTCHNL_H_
36 #define _I40E_VIRTCHNL_H_
38 #include "i40e_type.h"
41 * This header file describes the VF-PF communication protocol used
42 * by the various i40e drivers.
44 * Admin queue buffer usage:
45 * desc->opcode is always i40e_aqc_opc_send_msg_to_pf
46 * flags, retval, datalen, and data addr are all used normally.
47 * Firmware copies the cookie fields when sending messages between the PF and
48 * VF, but uses all other fields internally. Due to this limitation, we
49 * must send all messages as "indirect", i.e. using an external buffer.
51 * All the vsi indexes are relative to the VF. Each VF can have maximum of
52 * three VSIs. All the queue indexes are relative to the VSI. Each VF can
53 * have a maximum of sixteen queues for all of its VSIs.
55 * The PF is required to return a status code in v_retval for all messages
56 * except RESET_VF, which does not require any response. The return value is of
57 * i40e_status_code type, defined in the i40e_type.h.
59 * In general, VF driver initialization should roughly follow the order of these
60 * opcodes. The VF driver must first validate the API version of the PF driver,
61 * then request a reset, then get resources, then configure queues and
62 * interrupts. After these operations are complete, the VF driver may start
63 * its queues, optionally add MAC and VLAN filters, and process traffic.
66 /* Opcodes for VF-PF communication. These are placed in the v_opcode field
67 * of the virtchnl_msg structure.
69 enum i40e_virtchnl_ops {
70 /* The PF sends status change events to VFs using
71 * the I40E_VIRTCHNL_OP_EVENT opcode.
72 * VFs send requests to the PF using the other ops.
74 I40E_VIRTCHNL_OP_UNKNOWN = 0,
75 I40E_VIRTCHNL_OP_VERSION = 1, /* must ALWAYS be 1 */
76 I40E_VIRTCHNL_OP_RESET_VF = 2,
77 I40E_VIRTCHNL_OP_GET_VF_RESOURCES = 3,
78 I40E_VIRTCHNL_OP_CONFIG_TX_QUEUE = 4,
79 I40E_VIRTCHNL_OP_CONFIG_RX_QUEUE = 5,
80 I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES = 6,
81 I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP = 7,
82 I40E_VIRTCHNL_OP_ENABLE_QUEUES = 8,
83 I40E_VIRTCHNL_OP_DISABLE_QUEUES = 9,
84 I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS = 10,
85 I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS = 11,
86 I40E_VIRTCHNL_OP_ADD_VLAN = 12,
87 I40E_VIRTCHNL_OP_DEL_VLAN = 13,
88 I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE = 14,
89 I40E_VIRTCHNL_OP_GET_STATS = 15,
90 I40E_VIRTCHNL_OP_FCOE = 16,
91 I40E_VIRTCHNL_OP_EVENT = 17, /* must ALWAYS be 17 */
92 I40E_VIRTCHNL_OP_CONFIG_RSS_KEY = 23,
93 I40E_VIRTCHNL_OP_CONFIG_RSS_LUT = 24,
94 I40E_VIRTCHNL_OP_GET_RSS_HENA_CAPS = 25,
95 I40E_VIRTCHNL_OP_SET_RSS_HENA = 26,
99 /* Virtual channel message descriptor. This overlays the admin queue
100 * descriptor. All other data is passed in external buffers.
103 struct i40e_virtchnl_msg {
104 u8 pad[8]; /* AQ flags/opcode/len/retval fields */
105 enum i40e_virtchnl_ops v_opcode; /* avoid confusion with desc->opcode */
106 enum i40e_status_code v_retval; /* ditto for desc->retval */
107 u32 vfid; /* used by PF when sending to VF */
110 /* Message descriptions and data structures.*/
112 /* I40E_VIRTCHNL_OP_VERSION
113 * VF posts its version number to the PF. PF responds with its version number
114 * in the same format, along with a return code.
115 * Reply from PF has its major/minor versions also in param0 and param1.
116 * If there is a major version mismatch, then the VF cannot operate.
117 * If there is a minor version mismatch, then the VF can operate but should
118 * add a warning to the system log.
120 * This enum element MUST always be specified as == 1, regardless of other
121 * changes in the API. The PF must always respond to this message without
122 * error regardless of version mismatch.
124 #define I40E_VIRTCHNL_VERSION_MAJOR 1
125 #define I40E_VIRTCHNL_VERSION_MINOR 1
126 #define I40E_VIRTCHNL_VERSION_MINOR_NO_VF_CAPS 0
128 struct i40e_virtchnl_version_info {
133 /* I40E_VIRTCHNL_OP_RESET_VF
134 * VF sends this request to PF with no parameters
135 * PF does NOT respond! VF driver must delay then poll VFGEN_RSTAT register
136 * until reset completion is indicated. The admin queue must be reinitialized
137 * after this operation.
139 * When reset is complete, PF must ensure that all queues in all VSIs associated
140 * with the VF are stopped, all queue configurations in the HMC are set to 0,
141 * and all MAC and VLAN filters (except the default MAC address) on all VSIs
145 /* I40E_VIRTCHNL_OP_GET_VF_RESOURCES
146 * Version 1.0 VF sends this request to PF with no parameters
147 * Version 1.1 VF sends this request to PF with u32 bitmap of its capabilities
148 * PF responds with an indirect message containing
149 * i40e_virtchnl_vf_resource and one or more
150 * i40e_virtchnl_vsi_resource structures.
153 struct i40e_virtchnl_vsi_resource {
156 enum i40e_vsi_type vsi_type;
158 u8 default_mac_addr[I40E_ETH_LENGTH_OF_ADDRESS];
160 /* VF offload flags */
161 #define I40E_VIRTCHNL_VF_OFFLOAD_L2 0x00000001
162 #define I40E_VIRTCHNL_VF_OFFLOAD_IWARP 0x00000002
163 #define I40E_VIRTCHNL_VF_OFFLOAD_FCOE 0x00000004
164 #define I40E_VIRTCHNL_VF_OFFLOAD_RSS_AQ 0x00000008
165 #define I40E_VIRTCHNL_VF_OFFLOAD_RSS_REG 0x00000010
166 #define I40E_VIRTCHNL_VF_OFFLOAD_WB_ON_ITR 0x00000020
167 #define I40E_VIRTCHNL_VF_OFFLOAD_VLAN 0x00010000
168 #define I40E_VIRTCHNL_VF_OFFLOAD_RX_POLLING 0x00020000
169 #define I40E_VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 0x00040000
170 #define I40E_VIRTCHNL_VF_OFFLOAD_RSS_PF 0X00080000
171 #define I40E_VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM 0X00100000
173 #define I40E_VF_BASE_MODE_OFFLOADS (I40E_VIRTCHNL_VF_OFFLOAD_L2 | \
174 I40E_VIRTCHNL_VF_OFFLOAD_VLAN | \
175 I40E_VIRTCHNL_VF_OFFLOAD_RSS_PF)
177 struct i40e_virtchnl_vf_resource {
183 u32 vf_offload_flags;
187 struct i40e_virtchnl_vsi_resource vsi_res[1];
190 /* I40E_VIRTCHNL_OP_CONFIG_TX_QUEUE
191 * VF sends this message to set up parameters for one TX queue.
192 * External data buffer contains one instance of i40e_virtchnl_txq_info.
193 * PF configures requested queue and returns a status code.
196 /* Tx queue config info */
197 struct i40e_virtchnl_txq_info {
200 u16 ring_len; /* number of descriptors, multiple of 8 */
206 /* I40E_VIRTCHNL_OP_CONFIG_RX_QUEUE
207 * VF sends this message to set up parameters for one RX queue.
208 * External data buffer contains one instance of i40e_virtchnl_rxq_info.
209 * PF configures requested queue and returns a status code.
212 /* Rx queue config info */
213 struct i40e_virtchnl_rxq_info {
216 u32 ring_len; /* number of descriptors, multiple of 32 */
218 u16 splithdr_enabled;
222 enum i40e_hmc_obj_rx_hsplit_0 rx_split_pos;
225 /* I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES
226 * VF sends this message to set parameters for all active TX and RX queues
227 * associated with the specified VSI.
228 * PF configures queues and returns status.
229 * If the number of queues specified is greater than the number of queues
230 * associated with the VSI, an error is returned and no queues are configured.
232 struct i40e_virtchnl_queue_pair_info {
233 /* NOTE: vsi_id and queue_id should be identical for both queues. */
234 struct i40e_virtchnl_txq_info txq;
235 struct i40e_virtchnl_rxq_info rxq;
238 struct i40e_virtchnl_vsi_queue_config_info {
241 struct i40e_virtchnl_queue_pair_info qpair[1];
244 /* I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP
245 * VF uses this message to map vectors to queues.
246 * The rxq_map and txq_map fields are bitmaps used to indicate which queues
247 * are to be associated with the specified vector.
248 * The "other" causes are always mapped to vector 0.
249 * PF configures interrupt mapping and returns status.
251 struct i40e_virtchnl_vector_map {
260 struct i40e_virtchnl_irq_map_info {
262 struct i40e_virtchnl_vector_map vecmap[1];
265 /* I40E_VIRTCHNL_OP_ENABLE_QUEUES
266 * I40E_VIRTCHNL_OP_DISABLE_QUEUES
267 * VF sends these message to enable or disable TX/RX queue pairs.
268 * The queues fields are bitmaps indicating which queues to act upon.
269 * (Currently, we only support 16 queues per VF, but we make the field
270 * u32 to allow for expansion.)
271 * PF performs requested action and returns status.
273 struct i40e_virtchnl_queue_select {
280 /* I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS
281 * VF sends this message in order to add one or more unicast or multicast
282 * address filters for the specified VSI.
283 * PF adds the filters and returns status.
286 /* I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS
287 * VF sends this message in order to remove one or more unicast or multicast
288 * filters for the specified VSI.
289 * PF removes the filters and returns status.
292 struct i40e_virtchnl_ether_addr {
293 u8 addr[I40E_ETH_LENGTH_OF_ADDRESS];
297 struct i40e_virtchnl_ether_addr_list {
300 struct i40e_virtchnl_ether_addr list[1];
303 /* I40E_VIRTCHNL_OP_ADD_VLAN
304 * VF sends this message to add one or more VLAN tag filters for receives.
305 * PF adds the filters and returns status.
306 * If a port VLAN is configured by the PF, this operation will return an
310 /* I40E_VIRTCHNL_OP_DEL_VLAN
311 * VF sends this message to remove one or more VLAN tag filters for receives.
312 * PF removes the filters and returns status.
313 * If a port VLAN is configured by the PF, this operation will return an
317 struct i40e_virtchnl_vlan_filter_list {
323 /* I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE
324 * VF sends VSI id and flags.
325 * PF returns status code in retval.
326 * Note: we assume that broadcast accept mode is always enabled.
328 struct i40e_virtchnl_promisc_info {
333 #define I40E_FLAG_VF_UNICAST_PROMISC 0x00000001
334 #define I40E_FLAG_VF_MULTICAST_PROMISC 0x00000002
336 /* I40E_VIRTCHNL_OP_GET_STATS
337 * VF sends this message to request stats for the selected VSI. VF uses
338 * the i40e_virtchnl_queue_select struct to specify the VSI. The queue_id
339 * field is ignored by the PF.
341 * PF replies with struct i40e_eth_stats in an external buffer.
344 /* I40E_VIRTCHNL_OP_CONFIG_RSS_KEY
345 * I40E_VIRTCHNL_OP_CONFIG_RSS_LUT
346 * VF sends these messages to configure RSS. Only supported if both PF
347 * and VF drivers set the I40E_VIRTCHNL_VF_OFFLOAD_RSS_PF bit during
348 * configuration negotiation. If this is the case, then the rss fields in
349 * the vf resource struct are valid.
350 * Both the key and LUT are initialized to 0 by the PF, meaning that
351 * RSS is effectively disabled until set up by the VF.
353 struct i40e_virtchnl_rss_key {
356 u8 key[1]; /* RSS hash key, packed bytes */
359 struct i40e_virtchnl_rss_lut {
362 u8 lut[1]; /* RSS lookup table*/
365 /* I40E_VIRTCHNL_OP_GET_RSS_HENA_CAPS
366 * I40E_VIRTCHNL_OP_SET_RSS_HENA
367 * VF sends these messages to get and set the hash filter enable bits for RSS.
368 * By default, the PF sets these to all possible traffic types that the
369 * hardware supports. The VF can query this value if it wants to change the
370 * traffic types that are hashed by the hardware.
371 * Traffic types are defined in the i40e_filter_pctype enum in i40e_type.h
373 struct i40e_virtchnl_rss_hena {
377 /* I40E_VIRTCHNL_OP_EVENT
378 * PF sends this message to inform the VF driver of events that may affect it.
379 * No direct response is expected from the VF, though it may generate other
380 * messages in response to this one.
382 enum i40e_virtchnl_event_codes {
383 I40E_VIRTCHNL_EVENT_UNKNOWN = 0,
384 I40E_VIRTCHNL_EVENT_LINK_CHANGE,
385 I40E_VIRTCHNL_EVENT_RESET_IMPENDING,
386 I40E_VIRTCHNL_EVENT_PF_DRIVER_CLOSE,
388 #define I40E_PF_EVENT_SEVERITY_INFO 0
389 #define I40E_PF_EVENT_SEVERITY_ATTENTION 1
390 #define I40E_PF_EVENT_SEVERITY_ACTION_REQUIRED 2
391 #define I40E_PF_EVENT_SEVERITY_CERTAIN_DOOM 255
393 struct i40e_virtchnl_pf_event {
394 enum i40e_virtchnl_event_codes event;
397 enum i40e_aq_link_speed link_speed;
405 /* VF reset states - these are written into the RSTAT register:
406 * I40E_VFGEN_RSTAT1 on the PF
407 * I40E_VFGEN_RSTAT on the VF
408 * When the PF initiates a reset, it writes 0
409 * When the reset is complete, it writes 1
410 * When the PF detects that the VF has recovered, it writes 2
411 * VF checks this register periodically to determine if a reset has occurred,
412 * then polls it to know when the reset is complete.
413 * If either the PF or VF reads the register while the hardware
414 * is in a reset state, it will return DEADBEEF, which, when masked
417 enum i40e_vfr_states {
418 I40E_VFR_INPROGRESS = 0,
424 #endif /* _I40E_VIRTCHNL_H_ */