New upstream version 18.02
[deb_dpdk.git] / drivers / net / bnxt / rte_pmd_bnxt.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2017 Broadcom Limited.
5  *   All rights reserved.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of Broadcom Corporation nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #ifndef _PMD_BNXT_H_
35 #define _PMD_BNXT_H_
36
37 #include <rte_ethdev_driver.h>
38
39 /*
40  * Response sent back to the caller after callback
41  */
42 enum rte_pmd_bnxt_mb_event_rsp {
43         RTE_PMD_BNXT_MB_EVENT_NOOP_ACK,  /**< skip mbox request and ACK */
44         RTE_PMD_BNXT_MB_EVENT_NOOP_NACK, /**< skip mbox request and NACK */
45         RTE_PMD_BNXT_MB_EVENT_PROCEED,  /**< proceed with mbox request  */
46         RTE_PMD_BNXT_MB_EVENT_MAX       /**< max value of this enum */
47 };
48
49 /* mailbox message types */
50 #define BNXT_VF_RESET                   0x01 /* VF requests reset */
51 #define BNXT_VF_SET_MAC_ADDR    0x02 /* VF requests PF to set MAC addr */
52 #define BNXT_VF_SET_VLAN                0x03 /* VF requests PF to set VLAN */
53 #define BNXT_VF_SET_MTU                 0x04 /* VF requests PF to set MTU */
54 #define BNXT_VF_SET_MRU                 0x05 /* VF requests PF to set MRU */
55
56 /*
57  * Data sent to the caller when the callback is executed.
58  */
59 struct rte_pmd_bnxt_mb_event_param {
60         uint16_t vf_id; /* Virtual Function number */
61         int     retval; /* return value */
62         void    *msg;   /* pointer to message */
63 };
64
65 /**
66  * Enable/Disable VF MAC anti spoof
67  *
68  * @param port
69  *    The port identifier of the Ethernet device.
70  * @param vf
71  *   VF id.
72  * @param on
73  *    1 - Enable VF MAC anti spoof.
74  *    0 - Disable VF MAC anti spoof.
75  *
76  * @return
77  *   - (0) if successful.
78  *   - (-ENODEV) if *port* invalid.
79  *   - (-EINVAL) if bad parameter.
80  */
81 int rte_pmd_bnxt_set_vf_mac_anti_spoof(uint16_t port, uint16_t vf, uint8_t on);
82
83 /**
84  * Set the VF MAC address.
85  *
86  * @param port
87  *   The port identifier of the Ethernet device.
88  * @param vf
89  *   VF id.
90  * @param mac_addr
91  *   VF MAC address.
92  * @return
93  *   - (0) if successful.
94  *   - (-ENODEV) if *port* invalid.
95  *   - (-EINVAL) if *vf* or *mac_addr* is invalid.
96  */
97 int rte_pmd_bnxt_set_vf_mac_addr(uint16_t port, uint16_t vf,
98                 struct ether_addr *mac_addr);
99
100 /**
101  * Enable/Disable vf vlan strip for all queues in a pool
102  *
103  * @param port
104  *    The port identifier of the Ethernet device.
105  * @param vf
106  *    ID specifying VF.
107  * @param on
108  *    1 - Enable VF's vlan strip on RX queues.
109  *    0 - Disable VF's vlan strip on RX queues.
110  *
111  * @return
112  *   - (0) if successful.
113  *   - (-ENOTSUP) if hardware doesn't support this feature.
114  *   - (-ENODEV) if *port* invalid.
115  *   - (-EINVAL) if bad parameter.
116  */
117 int
118 rte_pmd_bnxt_set_vf_vlan_stripq(uint16_t port, uint16_t vf, uint8_t on);
119
120 /**
121  * Enable/Disable vf vlan insert
122  *
123  * @param port
124  *    The port identifier of the Ethernet device.
125  * @param vf
126  *    ID specifying VF.
127  * @param vlan_id
128  *    0 - Disable VF's vlan insert.
129  *    n - Enable; n is inserted as the vlan id.
130  *
131  * @return
132  *   - (0) if successful.
133  *   - (-ENODEV) if *port* invalid.
134  *   - (-EINVAL) if bad parameter.
135  */
136 int
137 rte_pmd_bnxt_set_vf_vlan_insert(uint16_t port, uint16_t vf,
138                 uint16_t vlan_id);
139
140 /**
141  * Enable/Disable hardware VF VLAN filtering by an Ethernet device of
142  * received VLAN packets tagged with a given VLAN Tag Identifier.
143  *
144  * @param port
145  *   The port identifier of the Ethernet device.
146  * @param vlan
147  *   The VLAN Tag Identifier whose filtering must be enabled or disabled.
148  * @param vf_mask
149  *    Bitmap listing which VFs participate in the VLAN filtering.
150  * @param vlan_on
151  *    1 - Enable VFs VLAN filtering.
152  *    0 - Disable VFs VLAN filtering.
153  * @return
154  *   - (0) if successful.
155  *   - (-ENOTSUP) if hardware doesn't support.
156  *   - (-ENODEV) if *port_id* invalid.
157  *   - (-EINVAL) if bad parameter.
158  */
159 int rte_pmd_bnxt_set_vf_vlan_filter(uint16_t port, uint16_t vlan,
160                                     uint64_t vf_mask, uint8_t vlan_on);
161
162 /**
163  * Enable/Disable tx loopback
164  *
165  * @param port
166  *    The port identifier of the Ethernet device.
167  * @param on
168  *    1 - Enable tx loopback.
169  *    0 - Disable tx loopback.
170  *
171  * @return
172  *   - (0) if successful.
173  *   - (-ENODEV) if *port* invalid.
174  *   - (-EINVAL) if bad parameter.
175  */
176 int rte_pmd_bnxt_set_tx_loopback(uint16_t port, uint8_t on);
177
178 /**
179  * set all queues drop enable bit
180  *
181  * @param port
182  *    The port identifier of the Ethernet device.
183  * @param on
184  *    1 - set the queue drop enable bit for all pools.
185  *    0 - reset the queue drop enable bit for all pools.
186  *
187  * @return
188  *   - (0) if successful.
189  *   - (-ENODEV) if *port* invalid.
190  *   - (-EINVAL) if bad parameter.
191  */
192 int rte_pmd_bnxt_set_all_queues_drop_en(uint16_t port, uint8_t on);
193
194 /**
195  * Set the VF rate limit.
196  *
197  * @param port
198  *   The port identifier of the Ethernet device.
199  * @param vf
200  *   VF id.
201  * @param tx_rate
202  *   Tx rate for the VF
203  * @param q_msk
204  *   Mask of the Tx queue
205  * @return
206  *   - (0) if successful.
207  *   - (-ENODEV) if *port* invalid.
208  *   - (-EINVAL) if *vf* or *mac_addr* is invalid.
209  */
210 int rte_pmd_bnxt_set_vf_rate_limit(uint16_t port, uint16_t vf,
211                                 uint16_t tx_rate, uint64_t q_msk);
212
213 /**
214  * Get VF's statistics
215  *
216  * @param port
217  *    The port identifier of the Ethernet device.
218  * @param vf_id
219  *    VF on which to get.
220  * @param stats
221  *    A pointer to a structure of type *rte_eth_stats* to be filled with
222  *    the values of device counters supported statistics:
223  * @return
224  *   - (0) if successful.
225  *   - (-ENODEV) if *port* invalid.
226  *   - (-EINVAL) if bad parameter.
227  */
228
229 int rte_pmd_bnxt_get_vf_stats(uint16_t port,
230                               uint16_t vf_id,
231                               struct rte_eth_stats *stats);
232
233 /**
234  * Clear VF's statistics
235  *
236  * @param port
237  *    The port identifier of the Ethernet device.
238  * @param vf_id
239  *    VF on which to get.
240  * @return
241  *   - (0) if successful.
242  *   - (-ENODEV) if *port* invalid.
243  *   - (-EINVAL) if bad parameter.
244  */
245 int rte_pmd_bnxt_reset_vf_stats(uint16_t port,
246                                 uint16_t vf_id);
247
248 /**
249  * Enable/Disable VF VLAN anti spoof
250  *
251  * @param port
252  *    The port identifier of the Ethernet device.
253  * @param vf
254  *   VF id.
255  * @param on
256  *    1 - Enable VF VLAN anti spoof.
257  *    0 - Disable VF VLAN anti spoof.
258  *
259  * @return
260  *   - (0) if successful.
261  *   - (-ENODEV) if *port* invalid.
262  *   - (-EINVAL) if bad parameter.
263  */
264 int rte_pmd_bnxt_set_vf_vlan_anti_spoof(uint16_t port, uint16_t vf, uint8_t on);
265
266 /**
267  * Set RX L2 Filtering mode of a VF of an Ethernet device.
268  *
269  * @param port
270  *   The port identifier of the Ethernet device.
271  * @param vf
272  *   VF id.
273  * @param rx_mask
274  *    The RX mode mask
275  * @param on
276  *    1 - Enable a VF RX mode.
277  *    0 - Disable a VF RX mode.
278  * @return
279  *   - (0) if successful.
280  *   - (-ENODEV) if *port_id* invalid.
281  *   - (-EINVAL) if bad parameter.
282  */
283 int rte_pmd_bnxt_set_vf_rxmode(uint16_t port, uint16_t vf,
284                                 uint16_t rx_mask, uint8_t on);
285
286 /**
287  * Returns the number of default RX queues on a VF
288  *
289  * @param port
290  *    The port identifier of the Ethernet device.
291  * @param vf
292  *   VF id.
293  * @return
294  *   - Non-negative value - Number of default RX queues
295  *   - (-EINVAL) if bad parameter.
296  *   - (-ENOTSUP) if on a function without VFs
297  *   - (-ENOMEM) on an allocation failure
298  *   - (-1) firmware interface error
299  */
300 int rte_pmd_bnxt_get_vf_rx_status(uint16_t port, uint16_t vf_id);
301
302 /**
303  * Queries the TX drop counter for the function
304  *
305  * @param port
306  *    The port identifier of the Ethernet device.
307  * @param vf_id
308  *    VF on which to get.
309  * @param count
310  *    Pointer to a uint64_t that will be populated with the counter value.
311  * @return
312  *   - Positive Non-zero value - Error code from HWRM
313  *   - (-EINVAL) invalid vf_id specified.
314  *   - (-ENOTSUP) Ethernet device is not a PF
315  */
316 int rte_pmd_bnxt_get_vf_tx_drop_count(uint16_t port, uint16_t vf_id,
317                                       uint64_t *count);
318
319 /**
320  * Programs the MAC address for the function specified
321  *
322  * @param port
323  *    The port identifier of the Ethernet device.
324  * @param mac_addr
325  *    The MAC address to be programmed in the filter.
326  * @param vf_id
327  *    VF on which to get.
328  * @return
329  *   - Positive Non-zero value - Error code from HWRM
330  *   - (-EINVAL) invalid vf_id specified.
331  *   - (-ENOTSUP) Ethernet device is not a PF
332  *   - (-ENOMEM) on an allocation failure
333  */
334 int rte_pmd_bnxt_mac_addr_add(uint16_t port, struct ether_addr *mac_addr,
335                                 uint32_t vf_id);
336
337 /**
338  * Enable/Disable VF statistics retention
339  *
340  * @param port
341  *    The port identifier of the Ethernet device.
342  * @param vf
343  *   VF id.
344  * @param on
345  *    1 - Prevent VF statistics from automatically resetting
346  *    0 - Allow VF statistics to automatically reset
347  *
348  * @return
349  *   - (0) if successful.
350  *   - (-ENODEV) if *port* invalid.
351  *   - (-EINVAL) if bad parameter.
352  */
353 int rte_pmd_bnxt_set_vf_persist_stats(uint16_t port, uint16_t vf, uint8_t on);
354 #endif /* _PMD_BNXT_H_ */