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