net/i40e: support getting all loaded DDP profiles
[dpdk.git] / drivers / net / i40e / rte_pmd_i40e.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright (c) 2017 Intel Corporation. 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
8  *   are met:
9  *
10  *     * Redistributions of source code must retain the above copyright
11  *       notice, this list of conditions and the following disclaimer.
12  *     * Redistributions in binary form must reproduce the above copyright
13  *       notice, this list of conditions and the following disclaimer in
14  *       the documentation and/or other materials provided with the
15  *       distribution.
16  *     * Neither the name of Intel Corporation nor the names of its
17  *       contributors may be used to endorse or promote products derived
18  *       from this software without specific prior written permission.
19  *
20  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 #ifndef _PMD_I40E_H_
34 #define _PMD_I40E_H_
35
36 /**
37  * @file rte_pmd_i40e.h
38  *
39  * i40e PMD specific functions.
40  *
41  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
42  *
43  */
44
45 #include <rte_ethdev.h>
46
47 /**
48  * Response sent back to i40e driver from user app after callback
49  */
50 enum rte_pmd_i40e_mb_event_rsp {
51         RTE_PMD_I40E_MB_EVENT_NOOP_ACK,  /**< skip mbox request and ACK */
52         RTE_PMD_I40E_MB_EVENT_NOOP_NACK, /**< skip mbox request and NACK */
53         RTE_PMD_I40E_MB_EVENT_PROCEED,  /**< proceed with mbox request  */
54         RTE_PMD_I40E_MB_EVENT_MAX       /**< max value of this enum */
55 };
56
57 /**
58  * Data sent to the user application when the callback is executed.
59  */
60 struct rte_pmd_i40e_mb_event_param {
61         uint16_t vfid;     /**< Virtual Function number */
62         uint16_t msg_type; /**< VF to PF message type, see i40e_virtchnl_ops */
63         uint16_t retval;   /**< return value */
64         void *msg;         /**< pointer to message */
65         uint16_t msglen;   /**< length of the message */
66 };
67
68 /**
69  * Option of package processing.
70  */
71 enum rte_pmd_i40e_package_op {
72         RTE_PMD_I40E_PKG_OP_UNDEFINED = 0,
73         RTE_PMD_I40E_PKG_OP_WR_ADD,   /**< load package and add to info list */
74         RTE_PMD_I40E_PKG_OP_MAX = 32
75 };
76
77 #define RTE_PMD_I40E_DDP_NAME_SIZE 32
78
79 /**
80  * Version for dynamic device personalization.
81  * Version in "major.minor.update.draft" format.
82  */
83 struct rte_pmd_i40e_ddp_version {
84         uint8_t major;
85         uint8_t minor;
86         uint8_t update;
87         uint8_t draft;
88 };
89
90 /**
91  * Profile information in profile info list.
92  */
93 struct rte_pmd_i40e_profile_info {
94         uint32_t track_id;
95         struct rte_pmd_i40e_ddp_version version;
96         uint8_t owner;
97         uint8_t reserved[7];
98         uint8_t name[RTE_PMD_I40E_DDP_NAME_SIZE];
99 };
100
101 /**
102  * Profile information list returned from HW.
103  */
104 struct rte_pmd_i40e_profile_list {
105         uint32_t p_count;
106         struct rte_pmd_i40e_profile_info p_info[1];
107 };
108
109 /**
110  * Notify VF when PF link status changes.
111  *
112  * @param port
113  *   The port identifier of the Ethernet device.
114  * @param vf
115  *   VF id.
116  * @return
117  *   - (0) if successful.
118  *   - (-ENODEV) if *port* invalid.
119  *   - (-EINVAL) if *vf* invalid.
120  */
121 int rte_pmd_i40e_ping_vfs(uint8_t port, uint16_t vf);
122
123 /**
124  * Enable/Disable VF MAC anti spoofing.
125  *
126  * @param port
127  *    The port identifier of the Ethernet device.
128  * @param vf_id
129  *    VF on which to set MAC anti spoofing.
130  * @param on
131  *    1 - Enable VFs MAC anti spoofing.
132  *    0 - Disable VFs MAC anti spoofing.
133  * @return
134  *   - (0) if successful.
135  *   - (-ENODEV) if *port* invalid.
136  *   - (-EINVAL) if bad parameter.
137  */
138 int rte_pmd_i40e_set_vf_mac_anti_spoof(uint8_t port,
139                                        uint16_t vf_id,
140                                        uint8_t on);
141
142 /**
143  * Enable/Disable VF VLAN anti spoofing.
144  *
145  * @param port
146  *    The port identifier of the Ethernet device.
147  * @param vf_id
148  *    VF on which to set VLAN anti spoofing.
149  * @param on
150  *    1 - Enable VFs VLAN anti spoofing.
151  *    0 - Disable VFs VLAN anti spoofing.
152  * @return
153  *   - (0) if successful.
154  *   - (-ENODEV) if *port* invalid.
155  *   - (-EINVAL) if bad parameter.
156  */
157 int rte_pmd_i40e_set_vf_vlan_anti_spoof(uint8_t port,
158                                         uint16_t vf_id,
159                                         uint8_t on);
160
161 /**
162  * Enable/Disable TX loopback on all the PF and VFs.
163  *
164  * @param port
165  *    The port identifier of the Ethernet device.
166  * @param on
167  *    1 - Enable TX loopback.
168  *    0 - Disable TX loopback.
169  * @return
170  *   - (0) if successful.
171  *   - (-ENODEV) if *port* invalid.
172  *   - (-EINVAL) if bad parameter.
173  */
174 int rte_pmd_i40e_set_tx_loopback(uint8_t port,
175                                  uint8_t on);
176
177 /**
178  * Enable/Disable VF unicast promiscuous mode.
179  *
180  * @param port
181  *    The port identifier of the Ethernet device.
182  * @param vf_id
183  *    VF on which to set.
184  * @param on
185  *    1 - Enable.
186  *    0 - Disable.
187  * @return
188  *   - (0) if successful.
189  *   - (-ENODEV) if *port* invalid.
190  *   - (-EINVAL) if bad parameter.
191  */
192 int rte_pmd_i40e_set_vf_unicast_promisc(uint8_t port,
193                                         uint16_t vf_id,
194                                         uint8_t on);
195
196 /**
197  * Enable/Disable VF multicast promiscuous mode.
198  *
199  * @param port
200  *    The port identifier of the Ethernet device.
201  * @param vf_id
202  *    VF on which to set.
203  * @param on
204  *    1 - Enable.
205  *    0 - Disable.
206  * @return
207  *   - (0) if successful.
208  *   - (-ENODEV) if *port* invalid.
209  *   - (-EINVAL) if bad parameter.
210  */
211 int rte_pmd_i40e_set_vf_multicast_promisc(uint8_t port,
212                                           uint16_t vf_id,
213                                           uint8_t on);
214
215 /**
216  * Set the VF MAC address.
217  *
218  * PF should set MAC address before VF initialized, if PF sets the MAC
219  * address after VF initialized, new MAC address won't be effective until
220  * VF reinitialize.
221  *
222  * This will remove all existing MAC filters.
223  *
224  * @param port
225  *   The port identifier of the Ethernet device.
226  * @param vf_id
227  *   VF id.
228  * @param mac_addr
229  *   VF MAC address.
230  * @return
231  *   - (0) if successful.
232  *   - (-ENODEV) if *port* invalid.
233  *   - (-EINVAL) if *vf* or *mac_addr* is invalid.
234  */
235 int rte_pmd_i40e_set_vf_mac_addr(uint8_t port, uint16_t vf_id,
236                                  struct ether_addr *mac_addr);
237
238 /**
239  * Enable/Disable vf vlan strip for all queues in a pool
240  *
241  * @param port
242  *    The port identifier of the Ethernet device.
243  * @param vf
244  *    ID specifying VF.
245  * @param on
246  *    1 - Enable VF's vlan strip on RX queues.
247  *    0 - Disable VF's vlan strip on RX queues.
248  *
249  * @return
250  *   - (0) if successful.
251  *   - (-ENODEV) if *port* invalid.
252  *   - (-EINVAL) if bad parameter.
253  */
254 int
255 rte_pmd_i40e_set_vf_vlan_stripq(uint8_t port, uint16_t vf, uint8_t on);
256
257 /**
258  * Enable/Disable vf vlan insert
259  *
260  * @param port
261  *    The port identifier of the Ethernet device.
262  * @param vf_id
263  *    ID specifying VF.
264  * @param vlan_id
265  *    0 - Disable VF's vlan insert.
266  *    n - Enable; n is inserted as the vlan id.
267  *
268  * @return
269  *   - (0) if successful.
270  *   - (-ENODEV) if *port* invalid.
271  *   - (-EINVAL) if bad parameter.
272  */
273 int rte_pmd_i40e_set_vf_vlan_insert(uint8_t port, uint16_t vf_id,
274                                     uint16_t vlan_id);
275
276 /**
277  * Enable/Disable vf broadcast mode
278  *
279  * @param port
280  *    The port identifier of the Ethernet device.
281  * @param vf_id
282  *    ID specifying VF.
283  * @param on
284  *    0 - Disable broadcast.
285  *    1 - Enable broadcast.
286  *
287  * @return
288  *   - (0) if successful.
289  *   - (-ENODEV) if *port* invalid.
290  *   - (-EINVAL) if bad parameter.
291  */
292 int rte_pmd_i40e_set_vf_broadcast(uint8_t port, uint16_t vf_id,
293                                   uint8_t on);
294
295 /**
296  * Enable/Disable vf vlan tag
297  *
298  * @param port
299  *    The port identifier of the Ethernet device.
300  * @param vf_id
301  *    ID specifying VF.
302  * @param on
303  *    0 - Disable VF's vlan tag.
304  *    n - Enable VF's vlan tag.
305  *
306  * @return
307  *   - (0) if successful.
308  *   - (-ENODEV) if *port* invalid.
309  *   - (-EINVAL) if bad parameter.
310  */
311 int rte_pmd_i40e_set_vf_vlan_tag(uint8_t port, uint16_t vf_id, uint8_t on);
312
313 /**
314  * Enable/Disable VF VLAN filter
315  *
316  * @param port
317  *    The port identifier of the Ethernet device.
318  * @param vlan_id
319  *    ID specifying VLAN
320  * @param vf_mask
321  *    Mask to filter VF's
322  * @param on
323  *    0 - Disable VF's VLAN filter.
324  *    1 - Enable VF's VLAN filter.
325  *
326  * @return
327  *   - (0) if successful.
328  *   - (-ENODEV) if *port* invalid.
329  *   - (-EINVAL) if bad parameter.
330  *   - (-ENOTSUP) not supported by firmware.
331  */
332 int rte_pmd_i40e_set_vf_vlan_filter(uint8_t port, uint16_t vlan_id,
333                                     uint64_t vf_mask, uint8_t on);
334
335 /**
336  * Get VF's statistics
337  *
338  * @param port
339  *    The port identifier of the Ethernet device.
340  * @param vf_id
341  *    VF on which to get.
342  * @param stats
343  *    A pointer to a structure of type *rte_eth_stats* to be filled with
344  *    the values of device counters for the following set of statistics:
345  *   - *ipackets* with the total of successfully received packets.
346  *   - *opackets* with the total of successfully transmitted packets.
347  *   - *ibytes*   with the total of successfully received bytes.
348  *   - *obytes*   with the total of successfully transmitted bytes.
349  *   - *ierrors*  with the total of erroneous received packets.
350  *   - *oerrors*  with the total of failed transmitted packets.
351  * @return
352  *   - (0) if successful.
353  *   - (-ENODEV) if *port* invalid.
354  *   - (-EINVAL) if bad parameter.
355  */
356
357 int rte_pmd_i40e_get_vf_stats(uint8_t port,
358                               uint16_t vf_id,
359                               struct rte_eth_stats *stats);
360
361 /**
362  * Clear VF's statistics
363  *
364  * @param port
365  *    The port identifier of the Ethernet device.
366  * @param vf_id
367  *    VF on which to get.
368  * @return
369  *   - (0) if successful.
370  *   - (-ENODEV) if *port* invalid.
371  *   - (-EINVAL) if bad parameter.
372  */
373 int rte_pmd_i40e_reset_vf_stats(uint8_t port,
374                                 uint16_t vf_id);
375
376 /**
377  * Set VF's max bandwidth.
378  *
379  * Per VF bandwidth limitation and per TC bandwidth limitation cannot
380  * be enabled in parallel. If per TC bandwidth is enabled, this function
381  * will disable it.
382  *
383  * @param port
384  *    The port identifier of the Ethernet device.
385  * @param vf_id
386  *    ID specifying VF.
387  * @param bw
388  *    Bandwidth for this VF.
389  * @return
390  *   - (0) if successful.
391  *   - (-ENODEV) if *port* invalid.
392  *   - (-EINVAL) if bad parameter.
393  *   - (-ENOTSUP) not supported by firmware.
394  */
395 int rte_pmd_i40e_set_vf_max_bw(uint8_t port,
396                                uint16_t vf_id,
397                                uint32_t bw);
398
399 /**
400  * Set all the TCs' bandwidth weight on a specific VF.
401  *
402  * The bw_weight means the percentage occupied by the TC.
403  * It can be taken as the relative min bandwidth setting.
404  *
405  * @param port
406  *    The port identifier of the Ethernet device.
407  * @param vf_id
408  *    ID specifying VF.
409  * @param tc_num
410  *    Number of TCs.
411  * @param bw_weight
412  *    An array of relative bandwidth weight for all the TCs.
413  *    The summary of the bw_weight should be 100.
414  * @return
415  *   - (0) if successful.
416  *   - (-ENODEV) if *port* invalid.
417  *   - (-EINVAL) if bad parameter.
418  *   - (-ENOTSUP) not supported by firmware.
419  */
420 int rte_pmd_i40e_set_vf_tc_bw_alloc(uint8_t port,
421                                     uint16_t vf_id,
422                                     uint8_t tc_num,
423                                     uint8_t *bw_weight);
424
425 /**
426  * Set a specific TC's max bandwidth on a specific VF.
427  *
428  * @param port
429  *    The port identifier of the Ethernet device.
430  * @param vf_id
431  *    ID specifying VF.
432  * @param tc_no
433  *    Number specifying TC.
434  * @param bw
435  *    Max bandwidth for this TC.
436  * @return
437  *   - (0) if successful.
438  *   - (-ENODEV) if *port* invalid.
439  *   - (-EINVAL) if bad parameter.
440  *   - (-ENOTSUP) not supported by firmware.
441  */
442 int rte_pmd_i40e_set_vf_tc_max_bw(uint8_t port,
443                                   uint16_t vf_id,
444                                   uint8_t tc_no,
445                                   uint32_t bw);
446
447 /**
448  * Set some TCs to strict priority mode on a physical port.
449  *
450  * @param port
451  *    The port identifier of the Ethernet device.
452  * @param tc_map
453  *    A bit map for the TCs.
454  * @return
455  *   - (0) if successful.
456  *   - (-ENODEV) if *port* invalid.
457  *   - (-EINVAL) if bad parameter.
458  *   - (-ENOTSUP) not supported by firmware.
459  */
460 int rte_pmd_i40e_set_tc_strict_prio(uint8_t port, uint8_t tc_map);
461
462 /**
463  * Load/Unload a ddp package
464  *
465  * @param port
466  *    The port identifier of the Ethernet device.
467  * @param buff
468  *    buffer of package.
469  * @param size
470  *    size of buffer.
471  * @param op
472  *   Operation of package processing
473  * @return
474  *   - (0) if successful.
475  *   - (-ENODEV) if *port* invalid.
476  *   - (-EINVAL) if bad parameter.
477  *   - (1) if profile exists.
478  */
479 int rte_pmd_i40e_process_ddp_package(uint8_t port, uint8_t *buff,
480                                      uint32_t size,
481                                      enum rte_pmd_i40e_package_op op);
482
483 /**
484  * rte_pmd_i40e_get_ddp_list - Get loaded profile list
485  * @param port
486  *    port id
487  * @param buff
488  *    buffer for response
489  * @param size
490  *    buffer size
491  * @return
492  *   - (0) if successful.
493  *   - (-ENODEV) if *port* invalid.
494  *   - (-EINVAL) if bad parameter.
495  */
496 int rte_pmd_i40e_get_ddp_list(uint8_t port, uint8_t *buff, uint32_t size);
497
498 #endif /* _PMD_I40E_H_ */