net/bnxt: update copyright year
[dpdk.git] / drivers / net / bnxt / rte_pmd_bnxt.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017-2021 Broadcom
3  * All rights reserved.
4  */
5
6 #ifndef _PMD_BNXT_H_
7 #define _PMD_BNXT_H_
8
9 #include <rte_ethdev.h>
10 #include <rte_ether.h>
11
12 /** mbuf dynamic field where CFA code is stored */
13 #define RTE_PMD_BNXT_CFA_CODE_DYNFIELD_NAME "rte_net_bnxt_dynfield_cfa_code"
14
15 /*
16  * Response sent back to the caller after callback
17  */
18 enum rte_pmd_bnxt_mb_event_rsp {
19         RTE_PMD_BNXT_MB_EVENT_NOOP_ACK,  /**< skip mbox request and ACK */
20         RTE_PMD_BNXT_MB_EVENT_NOOP_NACK, /**< skip mbox request and NACK */
21         RTE_PMD_BNXT_MB_EVENT_PROCEED,  /**< proceed with mbox request  */
22         RTE_PMD_BNXT_MB_EVENT_MAX       /**< max value of this enum */
23 };
24
25 /* mailbox message types */
26 #define BNXT_VF_RESET                   0x01 /* VF requests reset */
27 #define BNXT_VF_SET_MAC_ADDR    0x02 /* VF requests PF to set MAC addr */
28 #define BNXT_VF_SET_VLAN                0x03 /* VF requests PF to set VLAN */
29 #define BNXT_VF_SET_MTU                 0x04 /* VF requests PF to set MTU */
30 #define BNXT_VF_SET_MRU                 0x05 /* VF requests PF to set MRU */
31
32 /*
33  * Data sent to the caller when the callback is executed.
34  */
35 struct rte_pmd_bnxt_mb_event_param {
36         uint16_t vf_id; /* Virtual Function number */
37         int     retval; /* return value */
38         void    *msg;   /* pointer to message */
39 };
40
41 /**
42  * Enable/Disable VF MAC anti spoof
43  *
44  * @param port
45  *    The port identifier of the Ethernet device.
46  * @param vf
47  *   VF id.
48  * @param on
49  *    1 - Enable VF MAC anti spoof.
50  *    0 - Disable VF MAC anti spoof.
51  *
52  * @return
53  *   - (0) if successful.
54  *   - (-ENODEV) if *port* invalid.
55  *   - (-EINVAL) if bad parameter.
56  */
57 int rte_pmd_bnxt_set_vf_mac_anti_spoof(uint16_t port, uint16_t vf, uint8_t on);
58
59 /**
60  * Set the VF MAC address.
61  *
62  * @param port
63  *   The port identifier of the Ethernet device.
64  * @param vf
65  *   VF id.
66  * @param mac_addr
67  *   VF MAC address.
68  * @return
69  *   - (0) if successful.
70  *   - (-ENODEV) if *port* invalid.
71  *   - (-EINVAL) if *vf* or *mac_addr* is invalid.
72  */
73 int rte_pmd_bnxt_set_vf_mac_addr(uint16_t port, uint16_t vf,
74                 struct rte_ether_addr *mac_addr);
75
76 /**
77  * Enable/Disable vf vlan strip for all queues in a pool
78  *
79  * @param port
80  *    The port identifier of the Ethernet device.
81  * @param vf
82  *    ID specifying VF.
83  * @param on
84  *    1 - Enable VF's vlan strip on RX queues.
85  *    0 - Disable VF's vlan strip on RX queues.
86  *
87  * @return
88  *   - (0) if successful.
89  *   - (-ENOTSUP) if hardware doesn't support this feature.
90  *   - (-ENODEV) if *port* invalid.
91  *   - (-EINVAL) if bad parameter.
92  */
93 int
94 rte_pmd_bnxt_set_vf_vlan_stripq(uint16_t port, uint16_t vf, uint8_t on);
95
96 /**
97  * Enable/Disable vf vlan insert
98  *
99  * @param port
100  *    The port identifier of the Ethernet device.
101  * @param vf
102  *    ID specifying VF.
103  * @param vlan_id
104  *    0 - Disable VF's vlan insert.
105  *    n - Enable; n is inserted as the vlan id.
106  *
107  * @return
108  *   - (0) if successful.
109  *   - (-ENODEV) if *port* invalid.
110  *   - (-EINVAL) if bad parameter.
111  */
112 int
113 rte_pmd_bnxt_set_vf_vlan_insert(uint16_t port, uint16_t vf,
114                 uint16_t vlan_id);
115
116 /**
117  * Enable/Disable hardware VF VLAN filtering by an Ethernet device of
118  * received VLAN packets tagged with a given VLAN Tag Identifier.
119  *
120  * @param port
121  *   The port identifier of the Ethernet device.
122  * @param vlan
123  *   The VLAN Tag Identifier whose filtering must be enabled or disabled.
124  * @param vf_mask
125  *    Bitmap listing which VFs participate in the VLAN filtering.
126  * @param vlan_on
127  *    1 - Enable VFs VLAN filtering.
128  *    0 - Disable VFs VLAN filtering.
129  * @return
130  *   - (0) if successful.
131  *   - (-ENOTSUP) if hardware doesn't support.
132  *   - (-ENODEV) if *port_id* invalid.
133  *   - (-EINVAL) if bad parameter.
134  */
135 int rte_pmd_bnxt_set_vf_vlan_filter(uint16_t port, uint16_t vlan,
136                                     uint64_t vf_mask, uint8_t vlan_on);
137
138 /**
139  * Enable/Disable tx loopback
140  *
141  * @param port
142  *    The port identifier of the Ethernet device.
143  * @param on
144  *    1 - Enable tx loopback.
145  *    0 - Disable tx loopback.
146  *
147  * @return
148  *   - (0) if successful.
149  *   - (-ENODEV) if *port* invalid.
150  *   - (-EINVAL) if bad parameter.
151  */
152 int rte_pmd_bnxt_set_tx_loopback(uint16_t port, uint8_t on);
153
154 /**
155  * set all queues drop enable bit
156  *
157  * @param port
158  *    The port identifier of the Ethernet device.
159  * @param on
160  *    1 - set the queue drop enable bit for all pools.
161  *    0 - reset the queue drop enable bit for all pools.
162  *
163  * @return
164  *   - (0) if successful.
165  *   - (-ENODEV) if *port* invalid.
166  *   - (-EINVAL) if bad parameter.
167  */
168 int rte_pmd_bnxt_set_all_queues_drop_en(uint16_t port, uint8_t on);
169
170 /**
171  * Set the VF rate limit.
172  *
173  * @param port
174  *   The port identifier of the Ethernet device.
175  * @param vf
176  *   VF id.
177  * @param tx_rate
178  *   Tx rate for the VF
179  * @param q_msk
180  *   Mask of the Tx queue
181  * @return
182  *   - (0) if successful.
183  *   - (-ENODEV) if *port* invalid.
184  *   - (-EINVAL) if *vf* or *mac_addr* is invalid.
185  */
186 int rte_pmd_bnxt_set_vf_rate_limit(uint16_t port, uint16_t vf,
187                                 uint16_t tx_rate, uint64_t q_msk);
188
189 /**
190  * Get VF's statistics
191  *
192  * @param port
193  *    The port identifier of the Ethernet device.
194  * @param vf_id
195  *    VF on which to get.
196  * @param stats
197  *    A pointer to a structure of type *rte_eth_stats* to be filled with
198  *    the values of device counters supported statistics:
199  * @return
200  *   - (0) if successful.
201  *   - (-ENODEV) if *port* invalid.
202  *   - (-EINVAL) if bad parameter.
203  */
204
205 int rte_pmd_bnxt_get_vf_stats(uint16_t port,
206                               uint16_t vf_id,
207                               struct rte_eth_stats *stats);
208
209 /**
210  * Clear VF's statistics
211  *
212  * @param port
213  *    The port identifier of the Ethernet device.
214  * @param vf_id
215  *    VF on which to get.
216  * @return
217  *   - (0) if successful.
218  *   - (-ENODEV) if *port* invalid.
219  *   - (-EINVAL) if bad parameter.
220  */
221 int rte_pmd_bnxt_reset_vf_stats(uint16_t port,
222                                 uint16_t vf_id);
223
224 /**
225  * Enable/Disable VF VLAN anti spoof
226  *
227  * @param port
228  *    The port identifier of the Ethernet device.
229  * @param vf
230  *   VF id.
231  * @param on
232  *    1 - Enable VF VLAN anti spoof.
233  *    0 - Disable VF VLAN anti spoof.
234  *
235  * @return
236  *   - (0) if successful.
237  *   - (-ENODEV) if *port* invalid.
238  *   - (-EINVAL) if bad parameter.
239  */
240 int rte_pmd_bnxt_set_vf_vlan_anti_spoof(uint16_t port, uint16_t vf, uint8_t on);
241
242 /**
243  * Set RX L2 Filtering mode of a VF of an Ethernet device.
244  *
245  * @param port
246  *   The port identifier of the Ethernet device.
247  * @param vf
248  *   VF id.
249  * @param rx_mask
250  *    The RX mode mask
251  * @param on
252  *    1 - Enable a VF RX mode.
253  *    0 - Disable a VF RX mode.
254  * @return
255  *   - (0) if successful.
256  *   - (-ENODEV) if *port_id* invalid.
257  *   - (-EINVAL) if bad parameter.
258  */
259 int rte_pmd_bnxt_set_vf_rxmode(uint16_t port, uint16_t vf,
260                                 uint16_t rx_mask, uint8_t on);
261
262 /**
263  * Returns the number of default RX queues on a VF
264  *
265  * @param port
266  *    The port identifier of the Ethernet device.
267  * @param vf
268  *   VF id.
269  * @return
270  *   - Non-negative value - Number of default RX queues
271  *   - (-EINVAL) if bad parameter.
272  *   - (-ENOTSUP) if on a function without VFs
273  *   - (-ENOMEM) on an allocation failure
274  *   - (-1) firmware interface error
275  */
276 int rte_pmd_bnxt_get_vf_rx_status(uint16_t port, uint16_t vf_id);
277
278 /**
279  * Queries the TX drop counter for the function
280  *
281  * @param port
282  *    The port identifier of the Ethernet device.
283  * @param vf_id
284  *    VF on which to get.
285  * @param count
286  *    Pointer to a uint64_t that will be populated with the counter value.
287  * @return
288  *   - Positive Non-zero value - Error code from HWRM
289  *   - (-EINVAL) invalid vf_id specified.
290  *   - (-ENOTSUP) Ethernet device is not a PF
291  */
292 int rte_pmd_bnxt_get_vf_tx_drop_count(uint16_t port, uint16_t vf_id,
293                                       uint64_t *count);
294
295 /**
296  * Programs the MAC address for the function specified
297  *
298  * @param port
299  *    The port identifier of the Ethernet device.
300  * @param mac_addr
301  *    The MAC address to be programmed in the filter.
302  * @param vf_id
303  *    VF on which to get.
304  * @return
305  *   - Positive Non-zero value - Error code from HWRM
306  *   - (-EINVAL) invalid vf_id specified.
307  *   - (-ENOTSUP) Ethernet device is not a PF
308  *   - (-ENOMEM) on an allocation failure
309  */
310 int rte_pmd_bnxt_mac_addr_add(uint16_t port, struct rte_ether_addr *mac_addr,
311                                 uint32_t vf_id);
312
313 /**
314  * Enable/Disable VF statistics retention
315  *
316  * @param port
317  *    The port identifier of the Ethernet device.
318  * @param vf
319  *   VF id.
320  * @param on
321  *    1 - Prevent VF statistics from automatically resetting
322  *    0 - Allow VF statistics to automatically reset
323  *
324  * @return
325  *   - (0) if successful.
326  *   - (-ENODEV) if *port* invalid.
327  *   - (-EINVAL) if bad parameter.
328  */
329 int rte_pmd_bnxt_set_vf_persist_stats(uint16_t port, uint16_t vf, uint8_t on);
330 #endif /* _PMD_BNXT_H_ */