blob: a7ab463b44746a5f74f6d7339b060df9c235c4be [file] [log] [blame]
Jesse Brandeburg5c3c48a2013-09-11 08:40:07 +00001/*******************************************************************************
2 *
3 * Intel Ethernet Controller XL710 Family Linux Driver
Greg Rosedc641b72013-12-18 13:45:51 +00004 * Copyright(c) 2013 - 2014 Intel Corporation.
Jesse Brandeburg5c3c48a2013-09-11 08:40:07 +00005 *
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.
9 *
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
13 * more details.
14 *
Greg Rosedc641b72013-12-18 13:45:51 +000015 * 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/>.
Jesse Brandeburg5c3c48a2013-09-11 08:40:07 +000017 *
18 * The full GNU General Public License is included in this distribution in
19 * the file called "COPYING".
20 *
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
24 *
25 ******************************************************************************/
26
27#ifndef _I40E_VIRTCHNL_H_
28#define _I40E_VIRTCHNL_H_
29
30#include "i40e_type.h"
31
32/* Description:
33 * This header file describes the VF-PF communication protocol used
34 * by the various i40e drivers.
35 *
36 * Admin queue buffer usage:
37 * desc->opcode is always i40e_aqc_opc_send_msg_to_pf
38 * flags, retval, datalen, and data addr are all used normally.
39 * Firmware copies the cookie fields when sending messages between the PF and
40 * VF, but uses all other fields internally. Due to this limitation, we
41 * must send all messages as "indirect", i.e. using an external buffer.
42 *
43 * All the vsi indexes are relative to the VF. Each VF can have maximum of
44 * three VSIs. All the queue indexes are relative to the VSI. Each VF can
45 * have a maximum of sixteen queues for all of its VSIs.
46 *
47 * The PF is required to return a status code in v_retval for all messages
48 * except RESET_VF, which does not require any response. The return value is of
49 * i40e_status_code type, defined in the i40e_type.h.
50 *
51 * In general, VF driver initialization should roughly follow the order of these
52 * opcodes. The VF driver must first validate the API version of the PF driver,
53 * then request a reset, then get resources, then configure queues and
54 * interrupts. After these operations are complete, the VF driver may start
55 * its queues, optionally add MAC and VLAN filters, and process traffic.
56 */
57
58/* Opcodes for VF-PF communication. These are placed in the v_opcode field
59 * of the virtchnl_msg structure.
60 */
61enum i40e_virtchnl_ops {
Nicholas Nunley396642a2015-01-24 09:58:37 +000062/* The PF sends status change events to VFs using
63 * the I40E_VIRTCHNL_OP_EVENT opcode.
64 * VFs send requests to the PF using the other ops.
Jesse Brandeburg5c3c48a2013-09-11 08:40:07 +000065 */
66 I40E_VIRTCHNL_OP_UNKNOWN = 0,
67 I40E_VIRTCHNL_OP_VERSION = 1, /* must ALWAYS be 1 */
Nicholas Nunley396642a2015-01-24 09:58:37 +000068 I40E_VIRTCHNL_OP_RESET_VF = 2,
69 I40E_VIRTCHNL_OP_GET_VF_RESOURCES = 3,
70 I40E_VIRTCHNL_OP_CONFIG_TX_QUEUE = 4,
71 I40E_VIRTCHNL_OP_CONFIG_RX_QUEUE = 5,
72 I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES = 6,
73 I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP = 7,
74 I40E_VIRTCHNL_OP_ENABLE_QUEUES = 8,
75 I40E_VIRTCHNL_OP_DISABLE_QUEUES = 9,
76 I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS = 10,
77 I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS = 11,
78 I40E_VIRTCHNL_OP_ADD_VLAN = 12,
79 I40E_VIRTCHNL_OP_DEL_VLAN = 13,
80 I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE = 14,
81 I40E_VIRTCHNL_OP_GET_STATS = 15,
82 I40E_VIRTCHNL_OP_FCOE = 16,
83 I40E_VIRTCHNL_OP_EVENT = 17,
84 I40E_VIRTCHNL_OP_CONFIG_RSS = 18,
Jesse Brandeburg5c3c48a2013-09-11 08:40:07 +000085};
86
87/* Virtual channel message descriptor. This overlays the admin queue
88 * descriptor. All other data is passed in external buffers.
89 */
90
91struct i40e_virtchnl_msg {
92 u8 pad[8]; /* AQ flags/opcode/len/retval fields */
93 enum i40e_virtchnl_ops v_opcode; /* avoid confusion with desc->opcode */
94 i40e_status v_retval; /* ditto for desc->retval */
95 u32 vfid; /* used by PF when sending to VF */
96};
97
98/* Message descriptions and data structures.*/
99
100/* I40E_VIRTCHNL_OP_VERSION
101 * VF posts its version number to the PF. PF responds with its version number
102 * in the same format, along with a return code.
103 * Reply from PF has its major/minor versions also in param0 and param1.
104 * If there is a major version mismatch, then the VF cannot operate.
105 * If there is a minor version mismatch, then the VF can operate but should
106 * add a warning to the system log.
107 *
108 * This enum element MUST always be specified as == 1, regardless of other
109 * changes in the API. The PF must always respond to this message without
110 * error regardless of version mismatch.
111 */
112#define I40E_VIRTCHNL_VERSION_MAJOR 1
Mitch Williams1b53c2f2015-06-04 16:23:55 -0400113#define I40E_VIRTCHNL_VERSION_MINOR 1
114#define I40E_VIRTCHNL_VERSION_MINOR_NO_VF_CAPS 0
115
Jesse Brandeburg5c3c48a2013-09-11 08:40:07 +0000116struct i40e_virtchnl_version_info {
117 u32 major;
118 u32 minor;
119};
120
121/* I40E_VIRTCHNL_OP_RESET_VF
122 * VF sends this request to PF with no parameters
123 * PF does NOT respond! VF driver must delay then poll VFGEN_RSTAT register
124 * until reset completion is indicated. The admin queue must be reinitialized
125 * after this operation.
126 *
127 * When reset is complete, PF must ensure that all queues in all VSIs associated
128 * with the VF are stopped, all queue configurations in the HMC are set to 0,
129 * and all MAC and VLAN filters (except the default MAC address) on all VSIs
130 * are cleared.
131 */
132
133/* I40E_VIRTCHNL_OP_GET_VF_RESOURCES
Mitch Williams1b53c2f2015-06-04 16:23:55 -0400134 * Version 1.0 VF sends this request to PF with no parameters
135 * Version 1.1 VF sends this request to PF with u32 bitmap of its capabilities
Jesse Brandeburg5c3c48a2013-09-11 08:40:07 +0000136 * PF responds with an indirect message containing
137 * i40e_virtchnl_vf_resource and one or more
138 * i40e_virtchnl_vsi_resource structures.
139 */
140
141struct i40e_virtchnl_vsi_resource {
142 u16 vsi_id;
143 u16 num_queue_pairs;
144 enum i40e_vsi_type vsi_type;
145 u16 qset_handle;
Jesse Brandeburgc02e0fd2013-12-18 13:45:50 +0000146 u8 default_mac_addr[ETH_ALEN];
Jesse Brandeburg5c3c48a2013-09-11 08:40:07 +0000147};
148/* VF offload flags */
Mitch Williams1b53c2f2015-06-04 16:23:55 -0400149#define I40E_VIRTCHNL_VF_OFFLOAD_L2 0x00000001
150#define I40E_VIRTCHNL_VF_OFFLOAD_IWARP 0x00000002
151#define I40E_VIRTCHNL_VF_OFFLOAD_FCOE 0x00000004
152#define I40E_VIRTCHNL_VF_OFFLOAD_RSS_AQ 0x00000008
153#define I40E_VIRTCHNL_VF_OFFLOAD_RSS_REG 0x00000010
154#define I40E_VIRTCHNL_VF_OFFLOAD_VLAN 0x00010000
Jesse Brandeburg5c3c48a2013-09-11 08:40:07 +0000155
156struct i40e_virtchnl_vf_resource {
157 u16 num_vsis;
158 u16 num_queue_pairs;
159 u16 max_vectors;
160 u16 max_mtu;
161
162 u32 vf_offload_flags;
163 u32 max_fcoe_contexts;
164 u32 max_fcoe_filters;
165
166 struct i40e_virtchnl_vsi_resource vsi_res[1];
167};
168
169/* I40E_VIRTCHNL_OP_CONFIG_TX_QUEUE
170 * VF sends this message to set up parameters for one TX queue.
171 * External data buffer contains one instance of i40e_virtchnl_txq_info.
172 * PF configures requested queue and returns a status code.
173 */
174
175/* Tx queue config info */
176struct i40e_virtchnl_txq_info {
177 u16 vsi_id;
178 u16 queue_id;
179 u16 ring_len; /* number of descriptors, multiple of 8 */
180 u16 headwb_enabled;
181 u64 dma_ring_addr;
182 u64 dma_headwb_addr;
183};
184
185/* I40E_VIRTCHNL_OP_CONFIG_RX_QUEUE
186 * VF sends this message to set up parameters for one RX queue.
187 * External data buffer contains one instance of i40e_virtchnl_rxq_info.
188 * PF configures requested queue and returns a status code.
189 */
190
191/* Rx queue config info */
192struct i40e_virtchnl_rxq_info {
193 u16 vsi_id;
194 u16 queue_id;
195 u32 ring_len; /* number of descriptors, multiple of 32 */
196 u16 hdr_size;
197 u16 splithdr_enabled;
198 u32 databuffer_size;
199 u32 max_pkt_size;
200 u64 dma_ring_addr;
201 enum i40e_hmc_obj_rx_hsplit_0 rx_split_pos;
202};
203
204/* I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES
205 * VF sends this message to set parameters for all active TX and RX queues
206 * associated with the specified VSI.
207 * PF configures queues and returns status.
208 * If the number of queues specified is greater than the number of queues
209 * associated with the VSI, an error is returned and no queues are configured.
210 */
211struct i40e_virtchnl_queue_pair_info {
212 /* NOTE: vsi_id and queue_id should be identical for both queues. */
213 struct i40e_virtchnl_txq_info txq;
214 struct i40e_virtchnl_rxq_info rxq;
215};
216
217struct i40e_virtchnl_vsi_queue_config_info {
218 u16 vsi_id;
219 u16 num_queue_pairs;
220 struct i40e_virtchnl_queue_pair_info qpair[1];
221};
222
223/* I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP
224 * VF uses this message to map vectors to queues.
225 * The rxq_map and txq_map fields are bitmaps used to indicate which queues
226 * are to be associated with the specified vector.
227 * The "other" causes are always mapped to vector 0.
228 * PF configures interrupt mapping and returns status.
229 */
230struct i40e_virtchnl_vector_map {
231 u16 vsi_id;
232 u16 vector_id;
233 u16 rxq_map;
234 u16 txq_map;
235 u16 rxitr_idx;
236 u16 txitr_idx;
237};
238
239struct i40e_virtchnl_irq_map_info {
240 u16 num_vectors;
241 struct i40e_virtchnl_vector_map vecmap[1];
242};
243
244/* I40E_VIRTCHNL_OP_ENABLE_QUEUES
245 * I40E_VIRTCHNL_OP_DISABLE_QUEUES
246 * VF sends these message to enable or disable TX/RX queue pairs.
247 * The queues fields are bitmaps indicating which queues to act upon.
248 * (Currently, we only support 16 queues per VF, but we make the field
249 * u32 to allow for expansion.)
250 * PF performs requested action and returns status.
251 */
252struct i40e_virtchnl_queue_select {
253 u16 vsi_id;
254 u16 pad;
255 u32 rx_queues;
256 u32 tx_queues;
257};
258
259/* I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS
260 * VF sends this message in order to add one or more unicast or multicast
261 * address filters for the specified VSI.
262 * PF adds the filters and returns status.
263 */
264
265/* I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS
266 * VF sends this message in order to remove one or more unicast or multicast
267 * filters for the specified VSI.
268 * PF removes the filters and returns status.
269 */
270
271struct i40e_virtchnl_ether_addr {
Jesse Brandeburgc02e0fd2013-12-18 13:45:50 +0000272 u8 addr[ETH_ALEN];
Jesse Brandeburg5c3c48a2013-09-11 08:40:07 +0000273 u8 pad[2];
274};
275
276struct i40e_virtchnl_ether_addr_list {
277 u16 vsi_id;
278 u16 num_elements;
279 struct i40e_virtchnl_ether_addr list[1];
280};
281
282/* I40E_VIRTCHNL_OP_ADD_VLAN
283 * VF sends this message to add one or more VLAN tag filters for receives.
284 * PF adds the filters and returns status.
285 * If a port VLAN is configured by the PF, this operation will return an
286 * error to the VF.
287 */
288
289/* I40E_VIRTCHNL_OP_DEL_VLAN
290 * VF sends this message to remove one or more VLAN tag filters for receives.
291 * PF removes the filters and returns status.
292 * If a port VLAN is configured by the PF, this operation will return an
293 * error to the VF.
294 */
295
296struct i40e_virtchnl_vlan_filter_list {
297 u16 vsi_id;
298 u16 num_elements;
299 u16 vlan_id[1];
300};
301
302/* I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE
303 * VF sends VSI id and flags.
304 * PF returns status code in retval.
305 * Note: we assume that broadcast accept mode is always enabled.
306 */
307struct i40e_virtchnl_promisc_info {
308 u16 vsi_id;
309 u16 flags;
310};
311
312#define I40E_FLAG_VF_UNICAST_PROMISC 0x00000001
313#define I40E_FLAG_VF_MULTICAST_PROMISC 0x00000002
314
315/* I40E_VIRTCHNL_OP_GET_STATS
316 * VF sends this message to request stats for the selected VSI. VF uses
317 * the i40e_virtchnl_queue_select struct to specify the VSI. The queue_id
318 * field is ignored by the PF.
319 *
320 * PF replies with struct i40e_eth_stats in an external buffer.
321 */
322
323/* I40E_VIRTCHNL_OP_EVENT
324 * PF sends this message to inform the VF driver of events that may affect it.
325 * No direct response is expected from the VF, though it may generate other
326 * messages in response to this one.
327 */
328enum i40e_virtchnl_event_codes {
329 I40E_VIRTCHNL_EVENT_UNKNOWN = 0,
330 I40E_VIRTCHNL_EVENT_LINK_CHANGE,
331 I40E_VIRTCHNL_EVENT_RESET_IMPENDING,
332 I40E_VIRTCHNL_EVENT_PF_DRIVER_CLOSE,
333};
334#define I40E_PF_EVENT_SEVERITY_INFO 0
335#define I40E_PF_EVENT_SEVERITY_CERTAIN_DOOM 255
336
337struct i40e_virtchnl_pf_event {
338 enum i40e_virtchnl_event_codes event;
339 union {
340 struct {
341 enum i40e_aq_link_speed link_speed;
342 bool link_status;
343 } link_event;
344 } event_data;
345
346 int severity;
347};
348
Jesse Brandeburg5c3c48a2013-09-11 08:40:07 +0000349/* VF reset states - these are written into the RSTAT register:
350 * I40E_VFGEN_RSTAT1 on the PF
351 * I40E_VFGEN_RSTAT on the VF
352 * When the PF initiates a reset, it writes 0
353 * When the reset is complete, it writes 1
354 * When the PF detects that the VF has recovered, it writes 2
355 * VF checks this register periodically to determine if a reset has occurred,
356 * then polls it to know when the reset is complete.
357 * If either the PF or VF reads the register while the hardware
358 * is in a reset state, it will return DEADBEEF, which, when masked
359 * will result in 3.
360 */
361enum i40e_vfr_states {
362 I40E_VFR_INPROGRESS = 0,
363 I40E_VFR_COMPLETED,
364 I40E_VFR_VFACTIVE,
365 I40E_VFR_UNKNOWN,
366};
367
368#endif /* _I40E_VIRTCHNL_H_ */