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