]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - sys/dev/ixl/i40e_virtchnl.h
MFC r283119: Remove executable property from ixl
[FreeBSD/stable/10.git] / sys / dev / ixl / i40e_virtchnl.h
1 /******************************************************************************
2
3   Copyright (c) 2013-2014, 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 /*$FreeBSD$*/
34
35 #ifndef _I40E_VIRTCHNL_H_
36 #define _I40E_VIRTCHNL_H_
37
38 #include "i40e_type.h"
39
40 /* Description:
41  * This header file describes the VF-PF communication protocol used
42  * by the various i40e drivers.
43  *
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.
50  *
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.
54  *
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.
58  *
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.
64  */
65
66 /* Opcodes for VF-PF communication. These are placed in the v_opcode field
67  * of the virtchnl_msg structure.
68  */
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.
73  */
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,
92         I40E_VIRTCHNL_OP_CONFIG_RSS = 18,
93 };
94
95 /* Virtual channel message descriptor. This overlays the admin queue
96  * descriptor. All other data is passed in external buffers.
97  */
98
99 struct i40e_virtchnl_msg {
100         u8 pad[8];                       /* AQ flags/opcode/len/retval fields */
101         enum i40e_virtchnl_ops v_opcode; /* avoid confusion with desc->opcode */
102         enum i40e_status_code v_retval;  /* ditto for desc->retval */
103         u32 vfid;                        /* used by PF when sending to VF */
104 };
105
106 /* Message descriptions and data structures.*/
107
108 /* I40E_VIRTCHNL_OP_VERSION
109  * VF posts its version number to the PF. PF responds with its version number
110  * in the same format, along with a return code.
111  * Reply from PF has its major/minor versions also in param0 and param1.
112  * If there is a major version mismatch, then the VF cannot operate.
113  * If there is a minor version mismatch, then the VF can operate but should
114  * add a warning to the system log.
115  *
116  * This enum element MUST always be specified as == 1, regardless of other
117  * changes in the API. The PF must always respond to this message without
118  * error regardless of version mismatch.
119  */
120 #define I40E_VIRTCHNL_VERSION_MAJOR             1
121 #define I40E_VIRTCHNL_VERSION_MINOR             0
122 struct i40e_virtchnl_version_info {
123         u32 major;
124         u32 minor;
125 };
126
127 /* I40E_VIRTCHNL_OP_RESET_VF
128  * VF sends this request to PF with no parameters
129  * PF does NOT respond! VF driver must delay then poll VFGEN_RSTAT register
130  * until reset completion is indicated. The admin queue must be reinitialized
131  * after this operation.
132  *
133  * When reset is complete, PF must ensure that all queues in all VSIs associated
134  * with the VF are stopped, all queue configurations in the HMC are set to 0,
135  * and all MAC and VLAN filters (except the default MAC address) on all VSIs
136  * are cleared.
137  */
138
139 /* I40E_VIRTCHNL_OP_GET_VF_RESOURCES
140  * VF sends this request to PF with no parameters
141  * PF responds with an indirect message containing
142  * i40e_virtchnl_vf_resource and one or more
143  * i40e_virtchnl_vsi_resource structures.
144  */
145
146 struct i40e_virtchnl_vsi_resource {
147         u16 vsi_id;
148         u16 num_queue_pairs;
149         enum i40e_vsi_type vsi_type;
150         u16 qset_handle;
151         u8 default_mac_addr[I40E_ETH_LENGTH_OF_ADDRESS];
152 };
153 /* VF offload flags */
154 #define I40E_VIRTCHNL_VF_OFFLOAD_L2     0x00000001
155 #define I40E_VIRTCHNL_VF_OFFLOAD_IWARP  0x00000002
156 #define I40E_VIRTCHNL_VF_OFFLOAD_FCOE   0x00000004
157 #define I40E_VIRTCHNL_VF_OFFLOAD_VLAN   0x00010000
158
159 struct i40e_virtchnl_vf_resource {
160         u16 num_vsis;
161         u16 num_queue_pairs;
162         u16 max_vectors;
163         u16 max_mtu;
164
165         u32 vf_offload_flags;
166         u32 max_fcoe_contexts;
167         u32 max_fcoe_filters;
168
169         struct i40e_virtchnl_vsi_resource vsi_res[1];
170 };
171
172 /* I40E_VIRTCHNL_OP_CONFIG_TX_QUEUE
173  * VF sends this message to set up parameters for one TX queue.
174  * External data buffer contains one instance of i40e_virtchnl_txq_info.
175  * PF configures requested queue and returns a status code.
176  */
177
178 /* Tx queue config info */
179 struct i40e_virtchnl_txq_info {
180         u16 vsi_id;
181         u16 queue_id;
182         u16 ring_len;           /* number of descriptors, multiple of 8 */
183         u16 headwb_enabled;
184         u64 dma_ring_addr;
185         u64 dma_headwb_addr;
186 };
187
188 /* I40E_VIRTCHNL_OP_CONFIG_RX_QUEUE
189  * VF sends this message to set up parameters for one RX queue.
190  * External data buffer contains one instance of i40e_virtchnl_rxq_info.
191  * PF configures requested queue and returns a status code.
192  */
193
194 /* Rx queue config info */
195 struct i40e_virtchnl_rxq_info {
196         u16 vsi_id;
197         u16 queue_id;
198         u32 ring_len;           /* number of descriptors, multiple of 32 */
199         u16 hdr_size;
200         u16 splithdr_enabled;
201         u32 databuffer_size;
202         u32 max_pkt_size;
203         u64 dma_ring_addr;
204         enum i40e_hmc_obj_rx_hsplit_0 rx_split_pos;
205 };
206
207 /* I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES
208  * VF sends this message to set parameters for all active TX and RX queues
209  * associated with the specified VSI.
210  * PF configures queues and returns status.
211  * If the number of queues specified is greater than the number of queues
212  * associated with the VSI, an error is returned and no queues are configured.
213  */
214 struct i40e_virtchnl_queue_pair_info {
215         /* NOTE: vsi_id and queue_id should be identical for both queues. */
216         struct i40e_virtchnl_txq_info txq;
217         struct i40e_virtchnl_rxq_info rxq;
218 };
219
220 struct i40e_virtchnl_vsi_queue_config_info {
221         u16 vsi_id;
222         u16 num_queue_pairs;
223         struct i40e_virtchnl_queue_pair_info qpair[1];
224 };
225
226 /* I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP
227  * VF uses this message to map vectors to queues.
228  * The rxq_map and txq_map fields are bitmaps used to indicate which queues
229  * are to be associated with the specified vector.
230  * The "other" causes are always mapped to vector 0.
231  * PF configures interrupt mapping and returns status.
232  */
233 struct i40e_virtchnl_vector_map {
234         u16 vsi_id;
235         u16 vector_id;
236         u16 rxq_map;
237         u16 txq_map;
238         u16 rxitr_idx;
239         u16 txitr_idx;
240 };
241
242 struct i40e_virtchnl_irq_map_info {
243         u16 num_vectors;
244         struct i40e_virtchnl_vector_map vecmap[1];
245 };
246
247 /* I40E_VIRTCHNL_OP_ENABLE_QUEUES
248  * I40E_VIRTCHNL_OP_DISABLE_QUEUES
249  * VF sends these message to enable or disable TX/RX queue pairs.
250  * The queues fields are bitmaps indicating which queues to act upon.
251  * (Currently, we only support 16 queues per VF, but we make the field
252  * u32 to allow for expansion.)
253  * PF performs requested action and returns status.
254  */
255 struct i40e_virtchnl_queue_select {
256         u16 vsi_id;
257         u16 pad;
258         u32 rx_queues;
259         u32 tx_queues;
260 };
261
262 /* I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS
263  * VF sends this message in order to add one or more unicast or multicast
264  * address filters for the specified VSI.
265  * PF adds the filters and returns status.
266  */
267
268 /* I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS
269  * VF sends this message in order to remove one or more unicast or multicast
270  * filters for the specified VSI.
271  * PF removes the filters and returns status.
272  */
273
274 struct i40e_virtchnl_ether_addr {
275         u8 addr[I40E_ETH_LENGTH_OF_ADDRESS];
276         u8 pad[2];
277 };
278
279 struct i40e_virtchnl_ether_addr_list {
280         u16 vsi_id;
281         u16 num_elements;
282         struct i40e_virtchnl_ether_addr list[1];
283 };
284
285 /* I40E_VIRTCHNL_OP_ADD_VLAN
286  * VF sends this message to add one or more VLAN tag filters for receives.
287  * PF adds the filters and returns status.
288  * If a port VLAN is configured by the PF, this operation will return an
289  * error to the VF.
290  */
291
292 /* I40E_VIRTCHNL_OP_DEL_VLAN
293  * VF sends this message to remove one or more VLAN tag filters for receives.
294  * PF removes the filters and returns status.
295  * If a port VLAN is configured by the PF, this operation will return an
296  * error to the VF.
297  */
298
299 struct i40e_virtchnl_vlan_filter_list {
300         u16 vsi_id;
301         u16 num_elements;
302         u16 vlan_id[1];
303 };
304
305 /* I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE
306  * VF sends VSI id and flags.
307  * PF returns status code in retval.
308  * Note: we assume that broadcast accept mode is always enabled.
309  */
310 struct i40e_virtchnl_promisc_info {
311         u16 vsi_id;
312         u16 flags;
313 };
314
315 #define I40E_FLAG_VF_UNICAST_PROMISC    0x00000001
316 #define I40E_FLAG_VF_MULTICAST_PROMISC  0x00000002
317
318 /* I40E_VIRTCHNL_OP_GET_STATS
319  * VF sends this message to request stats for the selected VSI. VF uses
320  * the i40e_virtchnl_queue_select struct to specify the VSI. The queue_id
321  * field is ignored by the PF.
322  *
323  * PF replies with struct i40e_eth_stats in an external buffer.
324  */
325
326 /* I40E_VIRTCHNL_OP_EVENT
327  * PF sends this message to inform the VF driver of events that may affect it.
328  * No direct response is expected from the VF, though it may generate other
329  * messages in response to this one.
330  */
331 enum i40e_virtchnl_event_codes {
332         I40E_VIRTCHNL_EVENT_UNKNOWN = 0,
333         I40E_VIRTCHNL_EVENT_LINK_CHANGE,
334         I40E_VIRTCHNL_EVENT_RESET_IMPENDING,
335         I40E_VIRTCHNL_EVENT_PF_DRIVER_CLOSE,
336 };
337 #define I40E_PF_EVENT_SEVERITY_INFO             0
338 #define I40E_PF_EVENT_SEVERITY_ATTENTION        1
339 #define I40E_PF_EVENT_SEVERITY_ACTION_REQUIRED  2
340 #define I40E_PF_EVENT_SEVERITY_CERTAIN_DOOM     255
341
342 struct i40e_virtchnl_pf_event {
343         enum i40e_virtchnl_event_codes event;
344         union {
345                 struct {
346                         enum i40e_aq_link_speed link_speed;
347                         bool link_status;
348                 } link_event;
349         } event_data;
350
351         int severity;
352 };
353
354 /* VF reset states - these are written into the RSTAT register:
355  * I40E_VFGEN_RSTAT1 on the PF
356  * I40E_VFGEN_RSTAT on the VF
357  * When the PF initiates a reset, it writes 0
358  * When the reset is complete, it writes 1
359  * When the PF detects that the VF has recovered, it writes 2
360  * VF checks this register periodically to determine if a reset has occurred,
361  * then polls it to know when the reset is complete.
362  * If either the PF or VF reads the register while the hardware
363  * is in a reset state, it will return DEADBEEF, which, when masked
364  * will result in 3.
365  */
366 enum i40e_vfr_states {
367         I40E_VFR_INPROGRESS = 0,
368         I40E_VFR_COMPLETED,
369         I40E_VFR_VFACTIVE,
370         I40E_VFR_UNKNOWN,
371 };
372
373 #endif /* _I40E_VIRTCHNL_H_ */