Add the rt linux 4.1.3-rt3 as base
[kvmfornfv.git] / kernel / drivers / net / ethernet / intel / i40evf / i40e_virtchnl.h
1 /*******************************************************************************
2  *
3  * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver
4  * Copyright(c) 2013 - 2014 Intel Corporation.
5  *
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  *
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/>.
17  *
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  */
61 enum i40e_virtchnl_ops {
62 /* 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.
65  */
66         I40E_VIRTCHNL_OP_UNKNOWN = 0,
67         I40E_VIRTCHNL_OP_VERSION = 1, /* must ALWAYS be 1 */
68         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,
85 };
86
87 /* Virtual channel message descriptor. This overlays the admin queue
88  * descriptor. All other data is passed in external buffers.
89  */
90
91 struct 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
113 #define I40E_VIRTCHNL_VERSION_MINOR             0
114 struct i40e_virtchnl_version_info {
115         u32 major;
116         u32 minor;
117 };
118
119 /* I40E_VIRTCHNL_OP_RESET_VF
120  * VF sends this request to PF with no parameters
121  * PF does NOT respond! VF driver must delay then poll VFGEN_RSTAT register
122  * until reset completion is indicated. The admin queue must be reinitialized
123  * after this operation.
124  *
125  * When reset is complete, PF must ensure that all queues in all VSIs associated
126  * with the VF are stopped, all queue configurations in the HMC are set to 0,
127  * and all MAC and VLAN filters (except the default MAC address) on all VSIs
128  * are cleared.
129  */
130
131 /* I40E_VIRTCHNL_OP_GET_VF_RESOURCES
132  * VF sends this request to PF with no parameters
133  * PF responds with an indirect message containing
134  * i40e_virtchnl_vf_resource and one or more
135  * i40e_virtchnl_vsi_resource structures.
136  */
137
138 struct i40e_virtchnl_vsi_resource {
139         u16 vsi_id;
140         u16 num_queue_pairs;
141         enum i40e_vsi_type vsi_type;
142         u16 qset_handle;
143         u8 default_mac_addr[ETH_ALEN];
144 };
145 /* VF offload flags */
146 #define I40E_VIRTCHNL_VF_OFFLOAD_L2     0x00000001
147 #define I40E_VIRTCHNL_VF_OFFLOAD_FCOE   0x00000004
148 #define I40E_VIRTCHNL_VF_OFFLOAD_VLAN   0x00010000
149
150 struct i40e_virtchnl_vf_resource {
151         u16 num_vsis;
152         u16 num_queue_pairs;
153         u16 max_vectors;
154         u16 max_mtu;
155
156         u32 vf_offload_flags;
157         u32 max_fcoe_contexts;
158         u32 max_fcoe_filters;
159
160         struct i40e_virtchnl_vsi_resource vsi_res[1];
161 };
162
163 /* I40E_VIRTCHNL_OP_CONFIG_TX_QUEUE
164  * VF sends this message to set up parameters for one TX queue.
165  * External data buffer contains one instance of i40e_virtchnl_txq_info.
166  * PF configures requested queue and returns a status code.
167  */
168
169 /* Tx queue config info */
170 struct i40e_virtchnl_txq_info {
171         u16 vsi_id;
172         u16 queue_id;
173         u16 ring_len;           /* number of descriptors, multiple of 8 */
174         u16 headwb_enabled;
175         u64 dma_ring_addr;
176         u64 dma_headwb_addr;
177 };
178
179 /* I40E_VIRTCHNL_OP_CONFIG_RX_QUEUE
180  * VF sends this message to set up parameters for one RX queue.
181  * External data buffer contains one instance of i40e_virtchnl_rxq_info.
182  * PF configures requested queue and returns a status code.
183  */
184
185 /* Rx queue config info */
186 struct i40e_virtchnl_rxq_info {
187         u16 vsi_id;
188         u16 queue_id;
189         u32 ring_len;           /* number of descriptors, multiple of 32 */
190         u16 hdr_size;
191         u16 splithdr_enabled;
192         u32 databuffer_size;
193         u32 max_pkt_size;
194         u64 dma_ring_addr;
195         enum i40e_hmc_obj_rx_hsplit_0 rx_split_pos;
196 };
197
198 /* I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES
199  * VF sends this message to set parameters for all active TX and RX queues
200  * associated with the specified VSI.
201  * PF configures queues and returns status.
202  * If the number of queues specified is greater than the number of queues
203  * associated with the VSI, an error is returned and no queues are configured.
204  */
205 struct i40e_virtchnl_queue_pair_info {
206         /* NOTE: vsi_id and queue_id should be identical for both queues. */
207         struct i40e_virtchnl_txq_info txq;
208         struct i40e_virtchnl_rxq_info rxq;
209 };
210
211 struct i40e_virtchnl_vsi_queue_config_info {
212         u16 vsi_id;
213         u16 num_queue_pairs;
214         struct i40e_virtchnl_queue_pair_info qpair[1];
215 };
216
217 /* I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP
218  * VF uses this message to map vectors to queues.
219  * The rxq_map and txq_map fields are bitmaps used to indicate which queues
220  * are to be associated with the specified vector.
221  * The "other" causes are always mapped to vector 0.
222  * PF configures interrupt mapping and returns status.
223  */
224 struct i40e_virtchnl_vector_map {
225         u16 vsi_id;
226         u16 vector_id;
227         u16 rxq_map;
228         u16 txq_map;
229         u16 rxitr_idx;
230         u16 txitr_idx;
231 };
232
233 struct i40e_virtchnl_irq_map_info {
234         u16 num_vectors;
235         struct i40e_virtchnl_vector_map vecmap[1];
236 };
237
238 /* I40E_VIRTCHNL_OP_ENABLE_QUEUES
239  * I40E_VIRTCHNL_OP_DISABLE_QUEUES
240  * VF sends these message to enable or disable TX/RX queue pairs.
241  * The queues fields are bitmaps indicating which queues to act upon.
242  * (Currently, we only support 16 queues per VF, but we make the field
243  * u32 to allow for expansion.)
244  * PF performs requested action and returns status.
245  */
246 struct i40e_virtchnl_queue_select {
247         u16 vsi_id;
248         u16 pad;
249         u32 rx_queues;
250         u32 tx_queues;
251 };
252
253 /* I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS
254  * VF sends this message in order to add one or more unicast or multicast
255  * address filters for the specified VSI.
256  * PF adds the filters and returns status.
257  */
258
259 /* I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS
260  * VF sends this message in order to remove one or more unicast or multicast
261  * filters for the specified VSI.
262  * PF removes the filters and returns status.
263  */
264
265 struct i40e_virtchnl_ether_addr {
266         u8 addr[ETH_ALEN];
267         u8 pad[2];
268 };
269
270 struct i40e_virtchnl_ether_addr_list {
271         u16 vsi_id;
272         u16 num_elements;
273         struct i40e_virtchnl_ether_addr list[1];
274 };
275
276 /* I40E_VIRTCHNL_OP_ADD_VLAN
277  * VF sends this message to add one or more VLAN tag filters for receives.
278  * PF adds the filters and returns status.
279  * If a port VLAN is configured by the PF, this operation will return an
280  * error to the VF.
281  */
282
283 /* I40E_VIRTCHNL_OP_DEL_VLAN
284  * VF sends this message to remove one or more VLAN tag filters for receives.
285  * PF removes the filters and returns status.
286  * If a port VLAN is configured by the PF, this operation will return an
287  * error to the VF.
288  */
289
290 struct i40e_virtchnl_vlan_filter_list {
291         u16 vsi_id;
292         u16 num_elements;
293         u16 vlan_id[1];
294 };
295
296 /* I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE
297  * VF sends VSI id and flags.
298  * PF returns status code in retval.
299  * Note: we assume that broadcast accept mode is always enabled.
300  */
301 struct i40e_virtchnl_promisc_info {
302         u16 vsi_id;
303         u16 flags;
304 };
305
306 #define I40E_FLAG_VF_UNICAST_PROMISC    0x00000001
307 #define I40E_FLAG_VF_MULTICAST_PROMISC  0x00000002
308
309 /* I40E_VIRTCHNL_OP_GET_STATS
310  * VF sends this message to request stats for the selected VSI. VF uses
311  * the i40e_virtchnl_queue_select struct to specify the VSI. The queue_id
312  * field is ignored by the PF.
313  *
314  * PF replies with struct i40e_eth_stats in an external buffer.
315  */
316
317 /* I40E_VIRTCHNL_OP_EVENT
318  * PF sends this message to inform the VF driver of events that may affect it.
319  * No direct response is expected from the VF, though it may generate other
320  * messages in response to this one.
321  */
322 enum i40e_virtchnl_event_codes {
323         I40E_VIRTCHNL_EVENT_UNKNOWN = 0,
324         I40E_VIRTCHNL_EVENT_LINK_CHANGE,
325         I40E_VIRTCHNL_EVENT_RESET_IMPENDING,
326         I40E_VIRTCHNL_EVENT_PF_DRIVER_CLOSE,
327 };
328 #define I40E_PF_EVENT_SEVERITY_INFO             0
329 #define I40E_PF_EVENT_SEVERITY_CERTAIN_DOOM     255
330
331 struct i40e_virtchnl_pf_event {
332         enum i40e_virtchnl_event_codes event;
333         union {
334                 struct {
335                         enum i40e_aq_link_speed link_speed;
336                         bool link_status;
337                 } link_event;
338         } event_data;
339
340         int severity;
341 };
342
343 /* VF reset states - these are written into the RSTAT register:
344  * I40E_VFGEN_RSTAT1 on the PF
345  * I40E_VFGEN_RSTAT on the VF
346  * When the PF initiates a reset, it writes 0
347  * When the reset is complete, it writes 1
348  * When the PF detects that the VF has recovered, it writes 2
349  * VF checks this register periodically to determine if a reset has occurred,
350  * then polls it to know when the reset is complete.
351  * If either the PF or VF reads the register while the hardware
352  * is in a reset state, it will return DEADBEEF, which, when masked
353  * will result in 3.
354  */
355 enum i40e_vfr_states {
356         I40E_VFR_INPROGRESS = 0,
357         I40E_VFR_COMPLETED,
358         I40E_VFR_VFACTIVE,
359         I40E_VFR_UNKNOWN,
360 };
361
362 #endif /* _I40E_VIRTCHNL_H_ */