net/i40e: set VF max bandwidth from PF
[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  * Notify VF when PF link status changes.
70  *
71  * @param port
72  *   The port identifier of the Ethernet device.
73  * @param vf
74  *   VF id.
75  * @return
76  *   - (0) if successful.
77  *   - (-ENODEV) if *port* invalid.
78  *   - (-EINVAL) if *vf* invalid.
79  */
80 int rte_pmd_i40e_ping_vfs(uint8_t port, uint16_t vf);
81
82 /**
83  * Enable/Disable VF MAC anti spoofing.
84  *
85  * @param port
86  *    The port identifier of the Ethernet device.
87  * @param vf_id
88  *    VF on which to set MAC anti spoofing.
89  * @param on
90  *    1 - Enable VFs MAC anti spoofing.
91  *    0 - Disable VFs MAC anti spoofing.
92  * @return
93  *   - (0) if successful.
94  *   - (-ENODEV) if *port* invalid.
95  *   - (-EINVAL) if bad parameter.
96  */
97 int rte_pmd_i40e_set_vf_mac_anti_spoof(uint8_t port,
98                                        uint16_t vf_id,
99                                        uint8_t on);
100
101 /**
102  * Enable/Disable VF VLAN anti spoofing.
103  *
104  * @param port
105  *    The port identifier of the Ethernet device.
106  * @param vf_id
107  *    VF on which to set VLAN anti spoofing.
108  * @param on
109  *    1 - Enable VFs VLAN anti spoofing.
110  *    0 - Disable VFs VLAN anti spoofing.
111  * @return
112  *   - (0) if successful.
113  *   - (-ENODEV) if *port* invalid.
114  *   - (-EINVAL) if bad parameter.
115  */
116 int rte_pmd_i40e_set_vf_vlan_anti_spoof(uint8_t port,
117                                         uint16_t vf_id,
118                                         uint8_t on);
119
120 /**
121  * Enable/Disable TX loopback on all the PF and VFs.
122  *
123  * @param port
124  *    The port identifier of the Ethernet device.
125  * @param on
126  *    1 - Enable TX loopback.
127  *    0 - Disable TX loopback.
128  * @return
129  *   - (0) if successful.
130  *   - (-ENODEV) if *port* invalid.
131  *   - (-EINVAL) if bad parameter.
132  */
133 int rte_pmd_i40e_set_tx_loopback(uint8_t port,
134                                  uint8_t on);
135
136 /**
137  * Enable/Disable VF unicast promiscuous mode.
138  *
139  * @param port
140  *    The port identifier of the Ethernet device.
141  * @param vf_id
142  *    VF on which to set.
143  * @param on
144  *    1 - Enable.
145  *    0 - Disable.
146  * @return
147  *   - (0) if successful.
148  *   - (-ENODEV) if *port* invalid.
149  *   - (-EINVAL) if bad parameter.
150  */
151 int rte_pmd_i40e_set_vf_unicast_promisc(uint8_t port,
152                                         uint16_t vf_id,
153                                         uint8_t on);
154
155 /**
156  * Enable/Disable VF multicast promiscuous mode.
157  *
158  * @param port
159  *    The port identifier of the Ethernet device.
160  * @param vf_id
161  *    VF on which to set.
162  * @param on
163  *    1 - Enable.
164  *    0 - Disable.
165  * @return
166  *   - (0) if successful.
167  *   - (-ENODEV) if *port* invalid.
168  *   - (-EINVAL) if bad parameter.
169  */
170 int rte_pmd_i40e_set_vf_multicast_promisc(uint8_t port,
171                                           uint16_t vf_id,
172                                           uint8_t on);
173
174 /**
175  * Set the VF MAC address.
176  *
177  * PF should set MAC address before VF initialized, if PF sets the MAC
178  * address after VF initialized, new MAC address won't be effective until
179  * VF reinitialize.
180  *
181  * This will remove all existing MAC filters.
182  *
183  * @param port
184  *   The port identifier of the Ethernet device.
185  * @param vf_id
186  *   VF id.
187  * @param mac_addr
188  *   VF MAC address.
189  * @return
190  *   - (0) if successful.
191  *   - (-ENODEV) if *port* invalid.
192  *   - (-EINVAL) if *vf* or *mac_addr* is invalid.
193  */
194 int rte_pmd_i40e_set_vf_mac_addr(uint8_t port, uint16_t vf_id,
195                                  struct ether_addr *mac_addr);
196
197 /**
198  * Enable/Disable vf vlan strip for all queues in a pool
199  *
200  * @param port
201  *    The port identifier of the Ethernet device.
202  * @param vf
203  *    ID specifying VF.
204  * @param on
205  *    1 - Enable VF's vlan strip on RX queues.
206  *    0 - Disable VF's vlan strip on RX queues.
207  *
208  * @return
209  *   - (0) if successful.
210  *   - (-ENODEV) if *port* invalid.
211  *   - (-EINVAL) if bad parameter.
212  */
213 int
214 rte_pmd_i40e_set_vf_vlan_stripq(uint8_t port, uint16_t vf, uint8_t on);
215
216 /**
217  * Enable/Disable vf vlan insert
218  *
219  * @param port
220  *    The port identifier of the Ethernet device.
221  * @param vf_id
222  *    ID specifying VF.
223  * @param vlan_id
224  *    0 - Disable VF's vlan insert.
225  *    n - Enable; n is inserted as the vlan id.
226  *
227  * @return
228  *   - (0) if successful.
229  *   - (-ENODEV) if *port* invalid.
230  *   - (-EINVAL) if bad parameter.
231  */
232 int rte_pmd_i40e_set_vf_vlan_insert(uint8_t port, uint16_t vf_id,
233                                     uint16_t vlan_id);
234
235 /**
236  * Enable/Disable vf broadcast mode
237  *
238  * @param port
239  *    The port identifier of the Ethernet device.
240  * @param vf_id
241  *    ID specifying VF.
242  * @param on
243  *    0 - Disable broadcast.
244  *    1 - Enable broadcast.
245  *
246  * @return
247  *   - (0) if successful.
248  *   - (-ENODEV) if *port* invalid.
249  *   - (-EINVAL) if bad parameter.
250  */
251 int rte_pmd_i40e_set_vf_broadcast(uint8_t port, uint16_t vf_id,
252                                   uint8_t on);
253
254 /**
255  * Enable/Disable vf vlan tag
256  *
257  * @param port
258  *    The port identifier of the Ethernet device.
259  * @param vf_id
260  *    ID specifying VF.
261  * @param on
262  *    0 - Disable VF's vlan tag.
263  *    n - Enable VF's vlan tag.
264  *
265  * @return
266  *   - (0) if successful.
267  *   - (-ENODEV) if *port* invalid.
268  *   - (-EINVAL) if bad parameter.
269  */
270 int rte_pmd_i40e_set_vf_vlan_tag(uint8_t port, uint16_t vf_id, uint8_t on);
271
272 /**
273  * Enable/Disable VF VLAN filter
274  *
275  * @param port
276  *    The port identifier of the Ethernet device.
277  * @param vlan_id
278  *    ID specifying VLAN
279  * @param vf_mask
280  *    Mask to filter VF's
281  * @param on
282  *    0 - Disable VF's VLAN filter.
283  *    1 - Enable VF's VLAN filter.
284  *
285  * @return
286  *   - (0) if successful.
287  *   - (-ENODEV) if *port* invalid.
288  *   - (-EINVAL) if bad parameter.
289  *   - (-ENOTSUP) not supported by firmware.
290  */
291 int rte_pmd_i40e_set_vf_vlan_filter(uint8_t port, uint16_t vlan_id,
292                                     uint64_t vf_mask, uint8_t on);
293
294 /**
295  * Get VF's statistics
296  *
297  * @param port
298  *    The port identifier of the Ethernet device.
299  * @param vf_id
300  *    VF on which to get.
301  * @param stats
302  *    A pointer to a structure of type *rte_eth_stats* to be filled with
303  *    the values of device counters for the following set of statistics:
304  *   - *ipackets* with the total of successfully received packets.
305  *   - *opackets* with the total of successfully transmitted packets.
306  *   - *ibytes*   with the total of successfully received bytes.
307  *   - *obytes*   with the total of successfully transmitted bytes.
308  *   - *ierrors*  with the total of erroneous received packets.
309  *   - *oerrors*  with the total of failed transmitted packets.
310  * @return
311  *   - (0) if successful.
312  *   - (-ENODEV) if *port* invalid.
313  *   - (-EINVAL) if bad parameter.
314  */
315
316 int rte_pmd_i40e_get_vf_stats(uint8_t port,
317                               uint16_t vf_id,
318                               struct rte_eth_stats *stats);
319
320 /**
321  * Clear VF's statistics
322  *
323  * @param port
324  *    The port identifier of the Ethernet device.
325  * @param vf_id
326  *    VF on which to get.
327  * @return
328  *   - (0) if successful.
329  *   - (-ENODEV) if *port* invalid.
330  *   - (-EINVAL) if bad parameter.
331  */
332 int rte_pmd_i40e_reset_vf_stats(uint8_t port,
333                                 uint16_t vf_id);
334
335 /**
336  * Set VF's max bandwidth.
337  *
338  * Per VF bandwidth limitation and per TC bandwidth limitation cannot
339  * be enabled in parallel. If per TC bandwidth is enabled, this function
340  * will disable it.
341  *
342  * @param port
343  *    The port identifier of the Ethernet device.
344  * @param vf_id
345  *    ID specifying VF.
346  * @param bw
347  *    Bandwidth for this VF.
348  * @return
349  *   - (0) if successful.
350  *   - (-ENODEV) if *port* invalid.
351  *   - (-EINVAL) if bad parameter.
352  *   - (-ENOTSUP) not supported by firmware.
353  */
354 int rte_pmd_i40e_set_vf_max_bw(uint8_t port,
355                                uint16_t vf_id,
356                                uint32_t bw);
357
358 #endif /* _PMD_I40E_H_ */