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