net/bnxt: configure a default VF VLAN
[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.h>
38
39 /**
40  * Enable/Disable VF MAC anti spoof
41  *
42  * @param port
43  *    The port identifier of the Ethernet device.
44  * @param vf
45  *   VF id.
46  * @param on
47  *    1 - Enable VF MAC anti spoof.
48  *    0 - Disable VF MAC anti spoof.
49  *
50  * @return
51  *   - (0) if successful.
52  *   - (-ENODEV) if *port* invalid.
53  *   - (-EINVAL) if bad parameter.
54  */
55 int rte_pmd_bnxt_set_vf_mac_anti_spoof(uint8_t port, uint16_t vf, uint8_t on);
56
57 /**
58  * Set the VF MAC address.
59  *
60  * @param port
61  *   The port identifier of the Ethernet device.
62  * @param vf
63  *   VF id.
64  * @param mac_addr
65  *   VF MAC address.
66  * @return
67  *   - (0) if successful.
68  *   - (-ENODEV) if *port* invalid.
69  *   - (-EINVAL) if *vf* or *mac_addr* is invalid.
70  */
71 int rte_pmd_bnxt_set_vf_mac_addr(uint8_t port, uint16_t vf,
72                 struct ether_addr *mac_addr);
73
74 /**
75  * Enable/Disable vf vlan strip for all queues in a pool
76  *
77  * @param port
78  *    The port identifier of the Ethernet device.
79  * @param vf
80  *    ID specifying VF.
81  * @param on
82  *    1 - Enable VF's vlan strip on RX queues.
83  *    0 - Disable VF's vlan strip on RX queues.
84  *
85  * @return
86  *   - (0) if successful.
87  *   - (-ENOTSUP) if hardware doesn't support this feature.
88  *   - (-ENODEV) if *port* invalid.
89  *   - (-EINVAL) if bad parameter.
90  */
91 int
92 rte_pmd_bnxt_set_vf_vlan_stripq(uint8_t port, uint16_t vf, uint8_t on);
93
94 /**
95  * Enable/Disable vf vlan insert
96  *
97  * @param port
98  *    The port identifier of the Ethernet device.
99  * @param vf
100  *    ID specifying VF.
101  * @param vlan_id
102  *    0 - Disable VF's vlan insert.
103  *    n - Enable; n is inserted as the vlan id.
104  *
105  * @return
106  *   - (0) if successful.
107  *   - (-ENODEV) if *port* invalid.
108  *   - (-EINVAL) if bad parameter.
109  */
110 int
111 rte_pmd_bnxt_set_vf_vlan_insert(uint8_t port, uint16_t vf,
112                 uint16_t vlan_id);
113
114 /**
115  * Enable/Disable hardware VF VLAN filtering by an Ethernet device of
116  * received VLAN packets tagged with a given VLAN Tag Identifier.
117  *
118  * @param port
119  *   The port identifier of the Ethernet device.
120  * @param vlan
121  *   The VLAN Tag Identifier whose filtering must be enabled or disabled.
122  * @param vf_mask
123  *    Bitmap listing which VFs participate in the VLAN filtering.
124  * @param vlan_on
125  *    1 - Enable VFs VLAN filtering.
126  *    0 - Disable VFs VLAN filtering.
127  * @return
128  *   - (0) if successful.
129  *   - (-ENOTSUP) if hardware doesn't support.
130  *   - (-ENODEV) if *port_id* invalid.
131  *   - (-EINVAL) if bad parameter.
132  */
133 int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan,
134                                     uint64_t vf_mask, uint8_t vlan_on);
135
136 /**
137  * Enable/Disable tx loopback
138  *
139  * @param port
140  *    The port identifier of the Ethernet device.
141  * @param on
142  *    1 - Enable tx loopback.
143  *    0 - Disable tx loopback.
144  *
145  * @return
146  *   - (0) if successful.
147  *   - (-ENODEV) if *port* invalid.
148  *   - (-EINVAL) if bad parameter.
149  */
150 int rte_pmd_bnxt_set_tx_loopback(uint8_t port, uint8_t on);
151
152 /**
153  * set all queues drop enable bit
154  *
155  * @param port
156  *    The port identifier of the Ethernet device.
157  * @param on
158  *    1 - set the queue drop enable bit for all pools.
159  *    0 - reset the queue drop enable bit for all pools.
160  *
161  * @return
162  *   - (0) if successful.
163  *   - (-ENODEV) if *port* invalid.
164  *   - (-EINVAL) if bad parameter.
165  */
166 int rte_pmd_bnxt_set_all_queues_drop_en(uint8_t port, uint8_t on);
167
168 /**
169  * Set the VF rate limit.
170  *
171  * @param port
172  *   The port identifier of the Ethernet device.
173  * @param vf
174  *   VF id.
175  * @param tx_rate
176  *   Tx rate for the VF
177  * @param q_msk
178  *   Mask of the Tx queue
179  * @return
180  *   - (0) if successful.
181  *   - (-ENODEV) if *port* invalid.
182  *   - (-EINVAL) if *vf* or *mac_addr* is invalid.
183  */
184 int rte_pmd_bnxt_set_vf_rate_limit(uint8_t port, uint16_t vf,
185                                 uint16_t tx_rate, uint64_t q_msk);
186
187 /**
188  * Get VF's statistics
189  *
190  * @param port
191  *    The port identifier of the Ethernet device.
192  * @param vf_id
193  *    VF on which to get.
194  * @param stats
195  *    A pointer to a structure of type *rte_eth_stats* to be filled with
196  *    the values of device counters supported statistics:
197  * @return
198  *   - (0) if successful.
199  *   - (-ENODEV) if *port* invalid.
200  *   - (-EINVAL) if bad parameter.
201  */
202
203 int rte_pmd_bnxt_get_vf_stats(uint8_t port,
204                               uint16_t vf_id,
205                               struct rte_eth_stats *stats);
206
207 /**
208  * Clear VF's statistics
209  *
210  * @param port
211  *    The port identifier of the Ethernet device.
212  * @param vf_id
213  *    VF on which to get.
214  * @return
215  *   - (0) if successful.
216  *   - (-ENODEV) if *port* invalid.
217  *   - (-EINVAL) if bad parameter.
218  */
219 int rte_pmd_bnxt_reset_vf_stats(uint8_t port,
220                                 uint16_t vf_id);
221
222 /**
223  * Enable/Disable VF VLAN anti spoof
224  *
225  * @param port
226  *    The port identifier of the Ethernet device.
227  * @param vf
228  *   VF id.
229  * @param on
230  *    1 - Enable VF VLAN anti spoof.
231  *    0 - Disable VF VLAN anti spoof.
232  *
233  * @return
234  *   - (0) if successful.
235  *   - (-ENODEV) if *port* invalid.
236  *   - (-EINVAL) if bad parameter.
237  */
238 int rte_pmd_bnxt_set_vf_vlan_anti_spoof(uint8_t port, uint16_t vf, uint8_t on);
239
240
241 /**
242  * Returns the number of default RX queues on a VF
243  *
244  * @param port
245  *    The port identifier of the Ethernet device.
246  * @param vf
247  *   VF id.
248  * @return
249  *   - Non-negative value - Number of default RX queues
250  *   - (-EINVAL) if bad parameter.
251  *   - (-ENOTSUP) if on a function without VFs
252  *   - (-ENOMEM) on an allocation failure
253  *   - (-1) firmware interface error
254  */
255 int rte_pmd_bnxt_get_vf_rx_status(uint8_t port, uint16_t vf_id);
256
257 /**
258  * Queries the TX drop counter for the function
259  *
260  * @param port
261  *    The port identifier of the Ethernet device.
262  * @param vf_id
263  *    VF on which to get.
264  * @param count
265  *    Pointer to a uint64_t that will be populated with the counter value.
266  * @return
267  *   - Positive Non-zero value - Error code from HWRM
268  *   - (-EINVAL) invalid vf_id specified.
269  *   - (-ENOTSUP) Ethernet device is not a PF
270  */
271 int rte_pmd_bnxt_get_vf_tx_drop_count(uint8_t port, uint16_t vf_id,
272                                       uint64_t *count);
273
274 /**
275  * Programs the MAC address for the function specified
276  *
277  * @param port
278  *    The port identifier of the Ethernet device.
279  * @param mac_addr
280  *    The MAC address to be programmed in the filter.
281  * @param vf_id
282  *    VF on which to get.
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  *   - (-ENOMEM) on an allocation failure
288  */
289 int rte_pmd_bnxt_mac_addr_add(uint8_t port, struct ether_addr *mac_addr,
290                                 uint32_t vf_id);
291 #endif /* _PMD_BNXT_H_ */