1f2b1bd791243e3a0d7395fec3ed2acfe083f7b4
[deb_dpdk.git] / drivers / net / ixgbe / rte_pmd_ixgbe.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright (c) 2016 Intel Corporation. All rights reserved.
5  *
6  *   Redistribution and use in source and binary forms, with or without
7  *   modification, are permitted provided that the following conditions
8  *   are met:
9  *
10  *     * Redistributions of source code must retain the above copyright
11  *       notice, this list of conditions and the following disclaimer.
12  *     * Redistributions in binary form must reproduce the above copyright
13  *       notice, this list of conditions and the following disclaimer in
14  *       the documentation and/or other materials provided with the
15  *       distribution.
16  *     * Neither the name of Intel Corporation nor the names of its
17  *       contributors may be used to endorse or promote products derived
18  *       from this software without specific prior written permission.
19  *
20  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 /**
34  * @file rte_pmd_ixgbe.h
35  * ixgbe PMD specific functions.
36  *
37  **/
38
39 #ifndef _PMD_IXGBE_H_
40 #define _PMD_IXGBE_H_
41
42 #include <rte_ethdev.h>
43
44 /**
45  * Notify VF when PF link status changes.
46  *
47  * @param port
48  *   The port identifier of the Ethernet device.
49  * @param vf
50  *   VF id.
51  * @return
52  *   - (0) if successful.
53  *   - (-ENODEV) if *port* invalid.
54  *   - (-EINVAL) if *vf* invalid.
55  */
56 int rte_pmd_ixgbe_ping_vf(uint8_t port, uint16_t vf);
57
58 /**
59  * Set the VF MAC address.
60  *
61  * @param port
62  *   The port identifier of the Ethernet device.
63  * @param vf
64  *   VF id.
65  * @param mac_addr
66  *   VF MAC address.
67  * @return
68  *   - (0) if successful.
69  *   - (-ENODEV) if *port* invalid.
70  *   - (-EINVAL) if *vf* or *mac_addr* is invalid.
71  */
72 int rte_pmd_ixgbe_set_vf_mac_addr(uint8_t port, uint16_t vf,
73                 struct ether_addr *mac_addr);
74
75 /**
76  * Enable/Disable VF VLAN anti spoofing.
77  *
78  * @param port
79  *    The port identifier of the Ethernet device.
80  * @param vf
81  *    VF on which to set VLAN anti spoofing.
82  * @param on
83  *    1 - Enable VFs VLAN anti spoofing.
84  *    0 - Disable VFs VLAN anti spoofing.
85  * @return
86  *   - (0) if successful.
87  *   - (-ENODEV) if *port* invalid.
88  *   - (-EINVAL) if bad parameter.
89  */
90 int rte_pmd_ixgbe_set_vf_vlan_anti_spoof(uint8_t port, uint16_t vf, uint8_t on);
91
92 /**
93  * Enable/Disable VF MAC anti spoofing.
94  *
95  * @param port
96  *    The port identifier of the Ethernet device.
97  * @param vf
98  *    VF on which to set MAC anti spoofing.
99  * @param on
100  *    1 - Enable VFs MAC anti spoofing.
101  *    0 - Disable VFs MAC anti spoofing.
102  * @return
103  *   - (0) if successful.
104  *   - (-ENODEV) if *port* invalid.
105  *   - (-EINVAL) if bad parameter.
106  */
107 int rte_pmd_ixgbe_set_vf_mac_anti_spoof(uint8_t port, uint16_t vf, uint8_t on);
108
109 /**
110  * Enable/Disable vf vlan insert
111  *
112  * @param port
113  *    The port identifier of the Ethernet device.
114  * @param vf
115  *    ID specifying VF.
116  * @param vlan_id
117  *    0 - Disable VF's vlan insert.
118  *    n - Enable; n is inserted as the vlan id.
119  *
120  * @return
121  *   - (0) if successful.
122  *   - (-ENODEV) if *port* invalid.
123  *   - (-EINVAL) if bad parameter.
124  */
125 int rte_pmd_ixgbe_set_vf_vlan_insert(uint8_t port, uint16_t vf,
126                 uint16_t vlan_id);
127
128 /**
129  * Enable/Disable tx loopback
130  *
131  * @param port
132  *    The port identifier of the Ethernet device.
133  * @param on
134  *    1 - Enable tx loopback.
135  *    0 - Disable tx loopback.
136  *
137  * @return
138  *   - (0) if successful.
139  *   - (-ENODEV) if *port* invalid.
140  *   - (-EINVAL) if bad parameter.
141  */
142 int rte_pmd_ixgbe_set_tx_loopback(uint8_t port, uint8_t on);
143
144 /**
145  * set all queues drop enable bit
146  *
147  * @param port
148  *    The port identifier of the Ethernet device.
149  * @param on
150  *    1 - set the queue drop enable bit for all pools.
151  *    0 - reset the queue drop enable bit for all pools.
152  *
153  * @return
154  *   - (0) if successful.
155  *   - (-ENODEV) if *port* invalid.
156  *   - (-EINVAL) if bad parameter.
157  */
158 int rte_pmd_ixgbe_set_all_queues_drop_en(uint8_t port, uint8_t on);
159
160 /**
161  * set drop enable bit in the VF split rx control register
162  *
163  * @param port
164  *    The port identifier of the Ethernet device.
165  * @param vf
166  *    ID specifying VF.
167  * @param on
168  *    1 - set the drop enable bit in the split rx control register.
169  *    0 - reset the drop enable bit in the split rx control register.
170  *
171  * @return
172  *   - (0) if successful.
173  *   - (-ENODEV) if *port* invalid.
174  *   - (-EINVAL) if bad parameter.
175  */
176
177 int rte_pmd_ixgbe_set_vf_split_drop_en(uint8_t port, uint16_t vf, uint8_t on);
178
179 /**
180  * Enable/Disable vf vlan strip for all queues in a pool
181  *
182  * @param port
183  *    The port identifier of the Ethernet device.
184  * @param vf
185  *    ID specifying VF.
186  * @param on
187  *    1 - Enable VF's vlan strip on RX queues.
188  *    0 - Disable VF's vlan strip on RX queues.
189  *
190  * @return
191  *   - (0) if successful.
192  *   - (-ENOTSUP) if hardware doesn't support this feature.
193  *   - (-ENODEV) if *port* invalid.
194  *   - (-EINVAL) if bad parameter.
195  */
196 int
197 rte_pmd_ixgbe_set_vf_vlan_stripq(uint8_t port, uint16_t vf, uint8_t on);
198
199 /**
200  * Enable MACsec offload.
201  *
202  * @param port
203  *   The port identifier of the Ethernet device.
204  * @param en
205  *    1 - Enable encryption (encrypt and add integrity signature).
206  *    0 - Disable encryption (only add integrity signature).
207  * @param rp
208  *    1 - Enable replay protection.
209  *    0 - Disable replay protection.
210  * @return
211  *   - (0) if successful.
212  *   - (-ENODEV) if *port* invalid.
213  *   - (-ENOTSUP) if hardware doesn't support this feature.
214  */
215 int rte_pmd_ixgbe_macsec_enable(uint8_t port, uint8_t en, uint8_t rp);
216
217 /**
218  * Disable MACsec offload.
219  *
220  * @param port
221  *   The port identifier of the Ethernet device.
222  * @return
223  *   - (0) if successful.
224  *   - (-ENODEV) if *port* invalid.
225  *   - (-ENOTSUP) if hardware doesn't support this feature.
226  */
227 int rte_pmd_ixgbe_macsec_disable(uint8_t port);
228
229 /**
230  * Configure Tx SC (Secure Connection).
231  *
232  * @param port
233  *   The port identifier of the Ethernet device.
234  * @param mac
235  *   The MAC address on the local side.
236  * @return
237  *   - (0) if successful.
238  *   - (-ENODEV) if *port* invalid.
239  *   - (-ENOTSUP) if hardware doesn't support this feature.
240  */
241 int rte_pmd_ixgbe_macsec_config_txsc(uint8_t port, uint8_t *mac);
242
243 /**
244  * Configure Rx SC (Secure Connection).
245  *
246  * @param port
247  *   The port identifier of the Ethernet device.
248  * @param mac
249  *   The MAC address on the remote side.
250  * @param pi
251  *   The PI (port identifier) on the remote side.
252  * @return
253  *   - (0) if successful.
254  *   - (-ENODEV) if *port* invalid.
255  *   - (-ENOTSUP) if hardware doesn't support this feature.
256  */
257 int rte_pmd_ixgbe_macsec_config_rxsc(uint8_t port, uint8_t *mac, uint16_t pi);
258
259 /**
260  * Enable Tx SA (Secure Association).
261  *
262  * @param port
263  *   The port identifier of the Ethernet device.
264  * @param idx
265  *   The SA to be enabled (0 or 1).
266  * @param an
267  *   The association number on the local side.
268  * @param pn
269  *   The packet number on the local side.
270  * @param key
271  *   The key on the local side.
272  * @return
273  *   - (0) if successful.
274  *   - (-ENODEV) if *port* invalid.
275  *   - (-ENOTSUP) if hardware doesn't support this feature.
276  *   - (-EINVAL) if bad parameter.
277  */
278 int rte_pmd_ixgbe_macsec_select_txsa(uint8_t port, uint8_t idx, uint8_t an,
279                 uint32_t pn, uint8_t *key);
280
281 /**
282  * Enable Rx SA (Secure Association).
283  *
284  * @param port
285  *   The port identifier of the Ethernet device.
286  * @param idx
287  *   The SA to be enabled (0 or 1)
288  * @param an
289  *   The association number on the remote side.
290  * @param pn
291  *   The packet number on the remote side.
292  * @param key
293  *   The key on the remote side.
294  * @return
295  *   - (0) if successful.
296  *   - (-ENODEV) if *port* invalid.
297  *   - (-ENOTSUP) if hardware doesn't support this feature.
298  *   - (-EINVAL) if bad parameter.
299  */
300 int rte_pmd_ixgbe_macsec_select_rxsa(uint8_t port, uint8_t idx, uint8_t an,
301                 uint32_t pn, uint8_t *key);
302
303 /**
304 * Set RX L2 Filtering mode of a VF of an Ethernet device.
305 *
306 * @param port
307 *   The port identifier of the Ethernet device.
308 * @param vf
309 *   VF id.
310 * @param rx_mask
311 *    The RX mode mask, which is one or more of accepting Untagged Packets,
312 *    packets that match the PFUTA table, Broadcast and Multicast Promiscuous.
313 *    ETH_VMDQ_ACCEPT_UNTAG,ETH_VMDQ_ACCEPT_HASH_UC,
314 *    ETH_VMDQ_ACCEPT_BROADCAST and ETH_VMDQ_ACCEPT_MULTICAST will be used
315 *    in rx_mode.
316 * @param on
317 *    1 - Enable a VF RX mode.
318 *    0 - Disable a VF RX mode.
319 * @return
320 *   - (0) if successful.
321 *   - (-ENOTSUP) if hardware doesn't support.
322 *   - (-ENODEV) if *port_id* invalid.
323 *   - (-EINVAL) if bad parameter.
324 */
325 int
326 rte_pmd_ixgbe_set_vf_rxmode(uint8_t port, uint16_t vf, uint16_t rx_mask, uint8_t on);
327
328 /**
329 * Enable or disable a VF traffic receive of an Ethernet device.
330 *
331 * @param port
332 *   The port identifier of the Ethernet device.
333 * @param vf
334 *   VF id.
335 * @param on
336 *    1 - Enable a VF traffic receive.
337 *    0 - Disable a VF traffic receive.
338 * @return
339 *   - (0) if successful.
340 *   - (-ENOTSUP) if hardware doesn't support.
341 *   - (-ENODEV) if *port_id* invalid.
342 *   - (-EINVAL) if bad parameter.
343 */
344 int
345 rte_pmd_ixgbe_set_vf_rx(uint8_t port, uint16_t vf, uint8_t on);
346
347 /**
348 * Enable or disable a VF traffic transmit of the Ethernet device.
349 *
350 * @param port
351 *   The port identifier of the Ethernet device.
352 * @param vf
353 *   VF id.
354 * @param on
355 *    1 - Enable a VF traffic transmit.
356 *    0 - Disable a VF traffic transmit.
357 * @return
358 *   - (0) if successful.
359 *   - (-ENODEV) if *port_id* invalid.
360 *   - (-ENOTSUP) if hardware doesn't support.
361 *   - (-EINVAL) if bad parameter.
362 */
363 int
364 rte_pmd_ixgbe_set_vf_tx(uint8_t port, uint16_t vf, uint8_t on);
365
366 /**
367 * Enable/Disable hardware VF VLAN filtering by an Ethernet device of
368 * received VLAN packets tagged with a given VLAN Tag Identifier.
369 *
370 * @param port
371 *   The port identifier of the Ethernet device.
372 * @param vlan
373 *   The VLAN Tag Identifier whose filtering must be enabled or disabled.
374 * @param vf_mask
375 *    Bitmap listing which VFs participate in the VLAN filtering.
376 * @param vlan_on
377 *    1 - Enable VFs VLAN filtering.
378 *    0 - Disable VFs VLAN filtering.
379 * @return
380 *   - (0) if successful.
381 *   - (-ENOTSUP) if hardware doesn't support.
382 *   - (-ENODEV) if *port_id* invalid.
383 *   - (-EINVAL) if bad parameter.
384 */
385 int
386 rte_pmd_ixgbe_set_vf_vlan_filter(uint8_t port, uint16_t vlan, uint64_t vf_mask, uint8_t vlan_on);
387
388 /**
389  * Set the rate limitation for a vf on an Ethernet device.
390  *
391  * @param port
392  *   The port identifier of the Ethernet device.
393  * @param vf
394  *   VF id.
395  * @param tx_rate
396  *   The tx rate allocated from the total link speed for this VF id.
397  * @param q_msk
398  *   The queue mask which need to set the rate.
399  * @return
400  *   - (0) if successful.
401  *   - (-ENOTSUP) if hardware doesn't support this feature.
402  *   - (-ENODEV) if *port_id* invalid.
403  *   - (-EINVAL) if bad parameter.
404  */
405 int rte_pmd_ixgbe_set_vf_rate_limit(uint8_t port, uint16_t vf, uint16_t tx_rate, uint64_t q_msk);
406
407 /**
408  * Set all the TCs' bandwidth weight.
409  *
410  * The bw_weight means the percentage occupied by the TC.
411  * It can be taken as the relative min bandwidth setting.
412  *
413  * @param port
414  *    The port identifier of the Ethernet device.
415  * @param tc_num
416  *    Number of TCs.
417  * @param bw_weight
418  *    An array of relative bandwidth weight for all the TCs.
419  *    The summary of the bw_weight should be 100.
420  * @return
421  *   - (0) if successful.
422  *   - (-ENODEV) if *port* invalid.
423  *   - (-EINVAL) if bad parameter.
424  *   - (-ENOTSUP) not supported by firmware.
425  */
426 int rte_pmd_ixgbe_set_tc_bw_alloc(uint8_t port,
427                                   uint8_t tc_num,
428                                   uint8_t *bw_weight);
429
430 /**
431  * Response sent back to ixgbe driver from user app after callback
432  */
433 enum rte_pmd_ixgbe_mb_event_rsp {
434         RTE_PMD_IXGBE_MB_EVENT_NOOP_ACK,  /**< skip mbox request and ACK */
435         RTE_PMD_IXGBE_MB_EVENT_NOOP_NACK, /**< skip mbox request and NACK */
436         RTE_PMD_IXGBE_MB_EVENT_PROCEED,  /**< proceed with mbox request  */
437         RTE_PMD_IXGBE_MB_EVENT_MAX       /**< max value of this enum */
438 };
439
440 /**
441  * Data sent to the user application when the callback is executed.
442  */
443 struct rte_pmd_ixgbe_mb_event_param {
444         uint16_t vfid;     /**< Virtual Function number */
445         uint16_t msg_type; /**< VF to PF message type, defined in ixgbe_mbx.h */
446         uint16_t retval;   /**< return value */
447         void *msg;         /**< pointer to message */
448 };
449 #endif /* _PMD_IXGBE_H_ */