xref: /dpdk/lib/ethdev/rte_ethdev.h (revision 3b358e33)
199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
299a2dd95SBruce Richardson  * Copyright(c) 2010-2017 Intel Corporation
399a2dd95SBruce Richardson  */
499a2dd95SBruce Richardson 
599a2dd95SBruce Richardson #ifndef _RTE_ETHDEV_H_
699a2dd95SBruce Richardson #define _RTE_ETHDEV_H_
799a2dd95SBruce Richardson 
899a2dd95SBruce Richardson /**
999a2dd95SBruce Richardson  * @file
1099a2dd95SBruce Richardson  *
1199a2dd95SBruce Richardson  * RTE Ethernet Device API
1299a2dd95SBruce Richardson  *
1399a2dd95SBruce Richardson  * The Ethernet Device API is composed of two parts:
1499a2dd95SBruce Richardson  *
1599a2dd95SBruce Richardson  * - The application-oriented Ethernet API that includes functions to setup
1609fd4227SAndrew Rybchenko  *   an Ethernet device (configure it, setup its Rx and Tx queues and start it),
1799a2dd95SBruce Richardson  *   to get its MAC address, the speed and the status of its physical link,
1899a2dd95SBruce Richardson  *   to receive and to transmit packets, and so on.
1999a2dd95SBruce Richardson  *
2099a2dd95SBruce Richardson  * - The driver-oriented Ethernet API that exports functions allowing
2199a2dd95SBruce Richardson  *   an Ethernet Poll Mode Driver (PMD) to allocate an Ethernet device instance,
2299a2dd95SBruce Richardson  *   create memzone for HW rings and process registered callbacks, and so on.
2399a2dd95SBruce Richardson  *   PMDs should include ethdev_driver.h instead of this header.
2499a2dd95SBruce Richardson  *
2599a2dd95SBruce Richardson  * By default, all the functions of the Ethernet Device API exported by a PMD
2699a2dd95SBruce Richardson  * are lock-free functions which assume to not be invoked in parallel on
2799a2dd95SBruce Richardson  * different logical cores to work on the same target object.  For instance,
2899a2dd95SBruce Richardson  * the receive function of a PMD cannot be invoked in parallel on two logical
2909fd4227SAndrew Rybchenko  * cores to poll the same Rx queue [of the same port]. Of course, this function
3009fd4227SAndrew Rybchenko  * can be invoked in parallel by different logical cores on different Rx queues.
3199a2dd95SBruce Richardson  * It is the responsibility of the upper level application to enforce this rule.
3299a2dd95SBruce Richardson  *
3399a2dd95SBruce Richardson  * If needed, parallel accesses by multiple logical cores to shared queues
3499a2dd95SBruce Richardson  * shall be explicitly protected by dedicated inline lock-aware functions
3599a2dd95SBruce Richardson  * built on top of their corresponding lock-free functions of the PMD API.
3699a2dd95SBruce Richardson  *
3799a2dd95SBruce Richardson  * In all functions of the Ethernet API, the Ethernet device is
3899a2dd95SBruce Richardson  * designated by an integer >= 0 named the device port identifier.
3999a2dd95SBruce Richardson  *
4099a2dd95SBruce Richardson  * At the Ethernet driver level, Ethernet devices are represented by a generic
4199a2dd95SBruce Richardson  * data structure of type *rte_eth_dev*.
4299a2dd95SBruce Richardson  *
4399a2dd95SBruce Richardson  * Ethernet devices are dynamically registered during the PCI probing phase
4499a2dd95SBruce Richardson  * performed at EAL initialization time.
4599a2dd95SBruce Richardson  * When an Ethernet device is being probed, an *rte_eth_dev* structure and
4699a2dd95SBruce Richardson  * a new port identifier are allocated for that device. Then, the eth_dev_init()
4799a2dd95SBruce Richardson  * function supplied by the Ethernet driver matching the probed PCI
4899a2dd95SBruce Richardson  * device is invoked to properly initialize the device.
4999a2dd95SBruce Richardson  *
5099a2dd95SBruce Richardson  * The role of the device init function consists of resetting the hardware,
5199a2dd95SBruce Richardson  * checking access to Non-volatile Memory (NVM), reading the MAC address
5299a2dd95SBruce Richardson  * from NVM etc.
5399a2dd95SBruce Richardson  *
5499a2dd95SBruce Richardson  * If the device init operation is successful, the correspondence between
5599a2dd95SBruce Richardson  * the port identifier assigned to the new device and its associated
5699a2dd95SBruce Richardson  * *rte_eth_dev* structure is effectively registered.
5799a2dd95SBruce Richardson  * Otherwise, both the *rte_eth_dev* structure and the port identifier are
5899a2dd95SBruce Richardson  * freed.
5999a2dd95SBruce Richardson  *
6099a2dd95SBruce Richardson  * The functions exported by the application Ethernet API to setup a device
6199a2dd95SBruce Richardson  * designated by its port identifier must be invoked in the following order:
6299a2dd95SBruce Richardson  *     - rte_eth_dev_configure()
6399a2dd95SBruce Richardson  *     - rte_eth_tx_queue_setup()
6499a2dd95SBruce Richardson  *     - rte_eth_rx_queue_setup()
6599a2dd95SBruce Richardson  *     - rte_eth_dev_start()
6699a2dd95SBruce Richardson  *
6799a2dd95SBruce Richardson  * Then, the network application can invoke, in any order, the functions
6899a2dd95SBruce Richardson  * exported by the Ethernet API to get the MAC address of a given device, to
6999a2dd95SBruce Richardson  * get the speed and the status of a device physical link, to receive/transmit
7099a2dd95SBruce Richardson  * [burst of] packets, and so on.
7199a2dd95SBruce Richardson  *
7299a2dd95SBruce Richardson  * If the application wants to change the configuration (i.e. call
7399a2dd95SBruce Richardson  * rte_eth_dev_configure(), rte_eth_tx_queue_setup(), or
7499a2dd95SBruce Richardson  * rte_eth_rx_queue_setup()), it must call rte_eth_dev_stop() first to stop the
7599a2dd95SBruce Richardson  * device and then do the reconfiguration before calling rte_eth_dev_start()
7699a2dd95SBruce Richardson  * again. The transmit and receive functions should not be invoked when the
7799a2dd95SBruce Richardson  * device is stopped.
7899a2dd95SBruce Richardson  *
7999a2dd95SBruce Richardson  * Please note that some configuration is not stored between calls to
8099a2dd95SBruce Richardson  * rte_eth_dev_stop()/rte_eth_dev_start(). The following configuration will
8199a2dd95SBruce Richardson  * be retained:
8299a2dd95SBruce Richardson  *
8399a2dd95SBruce Richardson  *     - MTU
8499a2dd95SBruce Richardson  *     - flow control settings
8599a2dd95SBruce Richardson  *     - receive mode configuration (promiscuous mode, all-multicast mode,
86064e90c4SAndrew Rybchenko  *       hardware checksum mode, RSS/VMDq settings etc.)
8799a2dd95SBruce Richardson  *     - VLAN filtering configuration
8899a2dd95SBruce Richardson  *     - default MAC address
8999a2dd95SBruce Richardson  *     - MAC addresses supplied to MAC address array
9099a2dd95SBruce Richardson  *     - flow director filtering mode (but not filtering rules)
9199a2dd95SBruce Richardson  *     - NIC queue statistics mappings
9299a2dd95SBruce Richardson  *
931d5a3d68SDmitry Kozlyuk  * The following configuration may be retained or not
941d5a3d68SDmitry Kozlyuk  * depending on the device capabilities:
951d5a3d68SDmitry Kozlyuk  *
961d5a3d68SDmitry Kozlyuk  *     - flow rules
972c9cd45dSDmitry Kozlyuk  *     - flow-related shared objects, e.g. indirect actions
981d5a3d68SDmitry Kozlyuk  *
9999a2dd95SBruce Richardson  * Any other configuration will not be stored and will need to be re-entered
10099a2dd95SBruce Richardson  * before a call to rte_eth_dev_start().
10199a2dd95SBruce Richardson  *
10299a2dd95SBruce Richardson  * Finally, a network application can close an Ethernet device by invoking the
10399a2dd95SBruce Richardson  * rte_eth_dev_close() function.
10499a2dd95SBruce Richardson  *
10599a2dd95SBruce Richardson  * Each function of the application Ethernet API invokes a specific function
10699a2dd95SBruce Richardson  * of the PMD that controls the target device designated by its port
10799a2dd95SBruce Richardson  * identifier.
10899a2dd95SBruce Richardson  * For this purpose, all device-specific functions of an Ethernet driver are
10999a2dd95SBruce Richardson  * supplied through a set of pointers contained in a generic structure of type
11099a2dd95SBruce Richardson  * *eth_dev_ops*.
11199a2dd95SBruce Richardson  * The address of the *eth_dev_ops* structure is stored in the *rte_eth_dev*
11299a2dd95SBruce Richardson  * structure by the device init function of the Ethernet driver, which is
11399a2dd95SBruce Richardson  * invoked during the PCI probing phase, as explained earlier.
11499a2dd95SBruce Richardson  *
11599a2dd95SBruce Richardson  * In other words, each function of the Ethernet API simply retrieves the
11699a2dd95SBruce Richardson  * *rte_eth_dev* structure associated with the device port identifier and
11799a2dd95SBruce Richardson  * performs an indirect invocation of the corresponding driver function
11899a2dd95SBruce Richardson  * supplied in the *eth_dev_ops* structure of the *rte_eth_dev* structure.
11999a2dd95SBruce Richardson  *
12009fd4227SAndrew Rybchenko  * For performance reasons, the address of the burst-oriented Rx and Tx
12199a2dd95SBruce Richardson  * functions of the Ethernet driver are not contained in the *eth_dev_ops*
12299a2dd95SBruce Richardson  * structure. Instead, they are directly stored at the beginning of the
12399a2dd95SBruce Richardson  * *rte_eth_dev* structure to avoid an extra indirect memory access during
12499a2dd95SBruce Richardson  * their invocation.
12599a2dd95SBruce Richardson  *
1260d9f56a8SAndrew Rybchenko  * RTE Ethernet device drivers do not use interrupts for transmitting or
12799a2dd95SBruce Richardson  * receiving. Instead, Ethernet drivers export Poll-Mode receive and transmit
12899a2dd95SBruce Richardson  * functions to applications.
12999a2dd95SBruce Richardson  * Both receive and transmit functions are packet-burst oriented to minimize
13099a2dd95SBruce Richardson  * their cost per packet through the following optimizations:
13199a2dd95SBruce Richardson  *
13299a2dd95SBruce Richardson  * - Sharing among multiple packets the incompressible cost of the
13399a2dd95SBruce Richardson  *   invocation of receive/transmit functions.
13499a2dd95SBruce Richardson  *
13599a2dd95SBruce Richardson  * - Enabling receive/transmit functions to take advantage of burst-oriented
13699a2dd95SBruce Richardson  *   hardware features (L1 cache, prefetch instructions, NIC head/tail
13799a2dd95SBruce Richardson  *   registers) to minimize the number of CPU cycles per packet, for instance,
13899a2dd95SBruce Richardson  *   by avoiding useless read memory accesses to ring descriptors, or by
13999a2dd95SBruce Richardson  *   systematically using arrays of pointers that exactly fit L1 cache line
14099a2dd95SBruce Richardson  *   boundaries and sizes.
14199a2dd95SBruce Richardson  *
14299a2dd95SBruce Richardson  * The burst-oriented receive function does not provide any error notification,
14399a2dd95SBruce Richardson  * to avoid the corresponding overhead. As a hint, the upper-level application
14499a2dd95SBruce Richardson  * might check the status of the device link once being systematically returned
14599a2dd95SBruce Richardson  * a 0 value by the receive function of the driver for a given number of tries.
14699a2dd95SBruce Richardson  */
14799a2dd95SBruce Richardson 
14899a2dd95SBruce Richardson #ifdef __cplusplus
14999a2dd95SBruce Richardson extern "C" {
15099a2dd95SBruce Richardson #endif
15199a2dd95SBruce Richardson 
15299a2dd95SBruce Richardson #include <stdint.h>
15399a2dd95SBruce Richardson 
15499a2dd95SBruce Richardson /* Use this macro to check if LRO API is supported */
15599a2dd95SBruce Richardson #define RTE_ETHDEV_HAS_LRO_SUPPORT
15699a2dd95SBruce Richardson 
15799a2dd95SBruce Richardson /* Alias RTE_LIBRTE_ETHDEV_DEBUG for backward compatibility. */
15899a2dd95SBruce Richardson #ifdef RTE_LIBRTE_ETHDEV_DEBUG
15999a2dd95SBruce Richardson #define RTE_ETHDEV_DEBUG_RX
16099a2dd95SBruce Richardson #define RTE_ETHDEV_DEBUG_TX
16199a2dd95SBruce Richardson #endif
16299a2dd95SBruce Richardson 
16399a2dd95SBruce Richardson #include <rte_compat.h>
16499a2dd95SBruce Richardson #include <rte_log.h>
16599a2dd95SBruce Richardson #include <rte_interrupts.h>
16699a2dd95SBruce Richardson #include <rte_dev.h>
16799a2dd95SBruce Richardson #include <rte_devargs.h>
168e1823e08SThomas Monjalon #include <rte_bitops.h>
16999a2dd95SBruce Richardson #include <rte_errno.h>
17099a2dd95SBruce Richardson #include <rte_common.h>
17199a2dd95SBruce Richardson #include <rte_config.h>
17299a2dd95SBruce Richardson #include <rte_ether.h>
17399a2dd95SBruce Richardson #include <rte_power_intrinsics.h>
17499a2dd95SBruce Richardson 
17599a2dd95SBruce Richardson #include "rte_ethdev_trace_fp.h"
17699a2dd95SBruce Richardson #include "rte_dev_info.h"
17799a2dd95SBruce Richardson 
17899a2dd95SBruce Richardson extern int rte_eth_dev_logtype;
17999a2dd95SBruce Richardson 
18099a2dd95SBruce Richardson #define RTE_ETHDEV_LOG(level, ...) \
18199a2dd95SBruce Richardson 	rte_log(RTE_LOG_ ## level, rte_eth_dev_logtype, "" __VA_ARGS__)
18299a2dd95SBruce Richardson 
18399a2dd95SBruce Richardson struct rte_mbuf;
18499a2dd95SBruce Richardson 
18599a2dd95SBruce Richardson /**
18699a2dd95SBruce Richardson  * Initializes a device iterator.
18799a2dd95SBruce Richardson  *
18899a2dd95SBruce Richardson  * This iterator allows accessing a list of devices matching some devargs.
18999a2dd95SBruce Richardson  *
19099a2dd95SBruce Richardson  * @param iter
19199a2dd95SBruce Richardson  *   Device iterator handle initialized by the function.
19299a2dd95SBruce Richardson  *   The fields bus_str and cls_str might be dynamically allocated,
19399a2dd95SBruce Richardson  *   and could be freed by calling rte_eth_iterator_cleanup().
19499a2dd95SBruce Richardson  *
19599a2dd95SBruce Richardson  * @param devargs
19699a2dd95SBruce Richardson  *   Device description string.
19799a2dd95SBruce Richardson  *
19899a2dd95SBruce Richardson  * @return
19999a2dd95SBruce Richardson  *   0 on successful initialization, negative otherwise.
20099a2dd95SBruce Richardson  */
20199a2dd95SBruce Richardson int rte_eth_iterator_init(struct rte_dev_iterator *iter, const char *devargs);
20299a2dd95SBruce Richardson 
20399a2dd95SBruce Richardson /**
20499a2dd95SBruce Richardson  * Iterates on devices with devargs filter.
20599a2dd95SBruce Richardson  * The ownership is not checked.
20699a2dd95SBruce Richardson  *
2075906be5aSAndrew Rybchenko  * The next port ID is returned, and the iterator is updated.
20899a2dd95SBruce Richardson  *
20999a2dd95SBruce Richardson  * @param iter
21099a2dd95SBruce Richardson  *   Device iterator handle initialized by rte_eth_iterator_init().
21199a2dd95SBruce Richardson  *   Some fields bus_str and cls_str might be freed when no more port is found,
21299a2dd95SBruce Richardson  *   by calling rte_eth_iterator_cleanup().
21399a2dd95SBruce Richardson  *
21499a2dd95SBruce Richardson  * @return
2155906be5aSAndrew Rybchenko  *   A port ID if found, RTE_MAX_ETHPORTS otherwise.
21699a2dd95SBruce Richardson  */
21799a2dd95SBruce Richardson uint16_t rte_eth_iterator_next(struct rte_dev_iterator *iter);
21899a2dd95SBruce Richardson 
21999a2dd95SBruce Richardson /**
22099a2dd95SBruce Richardson  * Free some allocated fields of the iterator.
22199a2dd95SBruce Richardson  *
22299a2dd95SBruce Richardson  * This function is automatically called by rte_eth_iterator_next()
22399a2dd95SBruce Richardson  * on the last iteration (i.e. when no more matching port is found).
22499a2dd95SBruce Richardson  *
22599a2dd95SBruce Richardson  * It is safe to call this function twice; it will do nothing more.
22699a2dd95SBruce Richardson  *
22799a2dd95SBruce Richardson  * @param iter
22899a2dd95SBruce Richardson  *   Device iterator handle initialized by rte_eth_iterator_init().
22999a2dd95SBruce Richardson  *   The fields bus_str and cls_str are freed if needed.
23099a2dd95SBruce Richardson  */
23199a2dd95SBruce Richardson void rte_eth_iterator_cleanup(struct rte_dev_iterator *iter);
23299a2dd95SBruce Richardson 
23399a2dd95SBruce Richardson /**
23499a2dd95SBruce Richardson  * Macro to iterate over all ethdev ports matching some devargs.
23599a2dd95SBruce Richardson  *
23699a2dd95SBruce Richardson  * If a break is done before the end of the loop,
23799a2dd95SBruce Richardson  * the function rte_eth_iterator_cleanup() must be called.
23899a2dd95SBruce Richardson  *
23999a2dd95SBruce Richardson  * @param id
2405906be5aSAndrew Rybchenko  *   Iterated port ID of type uint16_t.
24199a2dd95SBruce Richardson  * @param devargs
24299a2dd95SBruce Richardson  *   Device parameters input as string of type char*.
24399a2dd95SBruce Richardson  * @param iter
24499a2dd95SBruce Richardson  *   Iterator handle of type struct rte_dev_iterator, used internally.
24599a2dd95SBruce Richardson  */
24699a2dd95SBruce Richardson #define RTE_ETH_FOREACH_MATCHING_DEV(id, devargs, iter) \
24799a2dd95SBruce Richardson 	for (rte_eth_iterator_init(iter, devargs), \
24899a2dd95SBruce Richardson 	     id = rte_eth_iterator_next(iter); \
24999a2dd95SBruce Richardson 	     id != RTE_MAX_ETHPORTS; \
25099a2dd95SBruce Richardson 	     id = rte_eth_iterator_next(iter))
25199a2dd95SBruce Richardson 
25299a2dd95SBruce Richardson /**
25399a2dd95SBruce Richardson  * A structure used to retrieve statistics for an Ethernet port.
25499a2dd95SBruce Richardson  * Not all statistics fields in struct rte_eth_stats are supported
25599a2dd95SBruce Richardson  * by any type of network interface card (NIC). If any statistics
25699a2dd95SBruce Richardson  * field is not supported, its value is 0.
25799a2dd95SBruce Richardson  * All byte-related statistics do not include Ethernet FCS regardless
25899a2dd95SBruce Richardson  * of whether these bytes have been delivered to the application
259295968d1SFerruh Yigit  * (see RTE_ETH_RX_OFFLOAD_KEEP_CRC).
26099a2dd95SBruce Richardson  */
26199a2dd95SBruce Richardson struct rte_eth_stats {
26299a2dd95SBruce Richardson 	uint64_t ipackets;  /**< Total number of successfully received packets. */
26399a2dd95SBruce Richardson 	uint64_t opackets;  /**< Total number of successfully transmitted packets.*/
26499a2dd95SBruce Richardson 	uint64_t ibytes;    /**< Total number of successfully received bytes. */
26599a2dd95SBruce Richardson 	uint64_t obytes;    /**< Total number of successfully transmitted bytes. */
2663c2ca0a9SAndrew Rybchenko 	/**
26709fd4227SAndrew Rybchenko 	 * Total of Rx packets dropped by the HW,
26809fd4227SAndrew Rybchenko 	 * because there are no available buffer (i.e. Rx queues are full).
26999a2dd95SBruce Richardson 	 */
2703c2ca0a9SAndrew Rybchenko 	uint64_t imissed;
27199a2dd95SBruce Richardson 	uint64_t ierrors;   /**< Total number of erroneous received packets. */
27299a2dd95SBruce Richardson 	uint64_t oerrors;   /**< Total number of failed transmitted packets. */
27309fd4227SAndrew Rybchenko 	uint64_t rx_nombuf; /**< Total number of Rx mbuf allocation failures. */
27499a2dd95SBruce Richardson 	/* Queue stats are limited to max 256 queues */
27509fd4227SAndrew Rybchenko 	/** Total number of queue Rx packets. */
27699a2dd95SBruce Richardson 	uint64_t q_ipackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
27709fd4227SAndrew Rybchenko 	/** Total number of queue Tx packets. */
27899a2dd95SBruce Richardson 	uint64_t q_opackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
2793c2ca0a9SAndrew Rybchenko 	/** Total number of successfully received queue bytes. */
28099a2dd95SBruce Richardson 	uint64_t q_ibytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
2813c2ca0a9SAndrew Rybchenko 	/** Total number of successfully transmitted queue bytes. */
28299a2dd95SBruce Richardson 	uint64_t q_obytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
2833c2ca0a9SAndrew Rybchenko 	/** Total number of queue packets received that are dropped. */
28499a2dd95SBruce Richardson 	uint64_t q_errors[RTE_ETHDEV_QUEUE_STAT_CNTRS];
28599a2dd95SBruce Richardson };
28699a2dd95SBruce Richardson 
2870ce56b05SThomas Monjalon /**@{@name Link speed capabilities
28899a2dd95SBruce Richardson  * Device supported speeds bitmap flags
28999a2dd95SBruce Richardson  */
290295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_AUTONEG 0             /**< Autonegotiate (all speeds) */
291295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_FIXED   RTE_BIT32(0)  /**< Disable autoneg (fixed speed) */
292295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_10M_HD  RTE_BIT32(1)  /**<  10 Mbps half-duplex */
293295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_10M     RTE_BIT32(2)  /**<  10 Mbps full-duplex */
294295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_100M_HD RTE_BIT32(3)  /**< 100 Mbps half-duplex */
295295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_100M    RTE_BIT32(4)  /**< 100 Mbps full-duplex */
296295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_1G      RTE_BIT32(5)  /**<   1 Gbps */
297295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_2_5G    RTE_BIT32(6)  /**< 2.5 Gbps */
298295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_5G      RTE_BIT32(7)  /**<   5 Gbps */
299295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_10G     RTE_BIT32(8)  /**<  10 Gbps */
300295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_20G     RTE_BIT32(9)  /**<  20 Gbps */
301295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_25G     RTE_BIT32(10) /**<  25 Gbps */
302295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_40G     RTE_BIT32(11) /**<  40 Gbps */
303295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_50G     RTE_BIT32(12) /**<  50 Gbps */
304295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_56G     RTE_BIT32(13) /**<  56 Gbps */
305295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_100G    RTE_BIT32(14) /**< 100 Gbps */
306295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_200G    RTE_BIT32(15) /**< 200 Gbps */
3070ce56b05SThomas Monjalon /**@}*/
30899a2dd95SBruce Richardson 
309b1cb3035SFerruh Yigit #define ETH_LINK_SPEED_AUTONEG RTE_DEPRECATED(ETH_LINK_SPEED_AUTONEG) RTE_ETH_LINK_SPEED_AUTONEG
310b1cb3035SFerruh Yigit #define ETH_LINK_SPEED_FIXED   RTE_DEPRECATED(ETH_LINK_SPEED_FIXED)   RTE_ETH_LINK_SPEED_FIXED
311b1cb3035SFerruh Yigit #define ETH_LINK_SPEED_10M_HD  RTE_DEPRECATED(ETH_LINK_SPEED_10M_HD)  RTE_ETH_LINK_SPEED_10M_HD
312b1cb3035SFerruh Yigit #define ETH_LINK_SPEED_10M     RTE_DEPRECATED(ETH_LINK_SPEED_10M)     RTE_ETH_LINK_SPEED_10M
313b1cb3035SFerruh Yigit #define ETH_LINK_SPEED_100M_HD RTE_DEPRECATED(ETH_LINK_SPEED_100M_HD) RTE_ETH_LINK_SPEED_100M_HD
314b1cb3035SFerruh Yigit #define ETH_LINK_SPEED_100M    RTE_DEPRECATED(ETH_LINK_SPEED_100M)    RTE_ETH_LINK_SPEED_100M
315b1cb3035SFerruh Yigit #define ETH_LINK_SPEED_1G      RTE_DEPRECATED(ETH_LINK_SPEED_1G)      RTE_ETH_LINK_SPEED_1G
316b1cb3035SFerruh Yigit #define ETH_LINK_SPEED_2_5G    RTE_DEPRECATED(ETH_LINK_SPEED_2_5G)    RTE_ETH_LINK_SPEED_2_5G
317b1cb3035SFerruh Yigit #define ETH_LINK_SPEED_5G      RTE_DEPRECATED(ETH_LINK_SPEED_5G)      RTE_ETH_LINK_SPEED_5G
318b1cb3035SFerruh Yigit #define ETH_LINK_SPEED_10G     RTE_DEPRECATED(ETH_LINK_SPEED_10G)     RTE_ETH_LINK_SPEED_10G
319b1cb3035SFerruh Yigit #define ETH_LINK_SPEED_20G     RTE_DEPRECATED(ETH_LINK_SPEED_20G)     RTE_ETH_LINK_SPEED_20G
320b1cb3035SFerruh Yigit #define ETH_LINK_SPEED_25G     RTE_DEPRECATED(ETH_LINK_SPEED_25G)     RTE_ETH_LINK_SPEED_25G
321b1cb3035SFerruh Yigit #define ETH_LINK_SPEED_40G     RTE_DEPRECATED(ETH_LINK_SPEED_40G)     RTE_ETH_LINK_SPEED_40G
322b1cb3035SFerruh Yigit #define ETH_LINK_SPEED_50G     RTE_DEPRECATED(ETH_LINK_SPEED_50G)     RTE_ETH_LINK_SPEED_50G
323b1cb3035SFerruh Yigit #define ETH_LINK_SPEED_56G     RTE_DEPRECATED(ETH_LINK_SPEED_56G)     RTE_ETH_LINK_SPEED_56G
324b1cb3035SFerruh Yigit #define ETH_LINK_SPEED_100G    RTE_DEPRECATED(ETH_LINK_SPEED_100G)    RTE_ETH_LINK_SPEED_100G
325b1cb3035SFerruh Yigit #define ETH_LINK_SPEED_200G    RTE_DEPRECATED(ETH_LINK_SPEED_200G)    RTE_ETH_LINK_SPEED_200G
326b1cb3035SFerruh Yigit 
3270ce56b05SThomas Monjalon /**@{@name Link speed
32899a2dd95SBruce Richardson  * Ethernet numeric link speeds in Mbps
32999a2dd95SBruce Richardson  */
330295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_NONE         0 /**< Not defined */
331295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_10M         10 /**<  10 Mbps */
332295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_100M       100 /**< 100 Mbps */
333295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_1G        1000 /**<   1 Gbps */
334295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_2_5G      2500 /**< 2.5 Gbps */
335295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_5G        5000 /**<   5 Gbps */
336295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_10G      10000 /**<  10 Gbps */
337295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_20G      20000 /**<  20 Gbps */
338295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_25G      25000 /**<  25 Gbps */
339295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_40G      40000 /**<  40 Gbps */
340295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_50G      50000 /**<  50 Gbps */
341295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_56G      56000 /**<  56 Gbps */
342295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_100G    100000 /**< 100 Gbps */
343295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_200G    200000 /**< 200 Gbps */
344295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_UNKNOWN UINT32_MAX /**< Unknown */
3450ce56b05SThomas Monjalon /**@}*/
34699a2dd95SBruce Richardson 
347b1cb3035SFerruh Yigit #define ETH_SPEED_NUM_NONE    RTE_DEPRECATED(ETH_SPEED_NUM_NONE)    RTE_ETH_SPEED_NUM_NONE
348b1cb3035SFerruh Yigit #define ETH_SPEED_NUM_10M     RTE_DEPRECATED(ETH_SPEED_NUM_10M)     RTE_ETH_SPEED_NUM_10M
349b1cb3035SFerruh Yigit #define ETH_SPEED_NUM_100M    RTE_DEPRECATED(ETH_SPEED_NUM_100M)    RTE_ETH_SPEED_NUM_100M
350b1cb3035SFerruh Yigit #define ETH_SPEED_NUM_1G      RTE_DEPRECATED(ETH_SPEED_NUM_1G)      RTE_ETH_SPEED_NUM_1G
351b1cb3035SFerruh Yigit #define ETH_SPEED_NUM_2_5G    RTE_DEPRECATED(ETH_SPEED_NUM_2_5G)    RTE_ETH_SPEED_NUM_2_5G
352b1cb3035SFerruh Yigit #define ETH_SPEED_NUM_5G      RTE_DEPRECATED(ETH_SPEED_NUM_5G)      RTE_ETH_SPEED_NUM_5G
353b1cb3035SFerruh Yigit #define ETH_SPEED_NUM_10G     RTE_DEPRECATED(ETH_SPEED_NUM_10G)     RTE_ETH_SPEED_NUM_10G
354b1cb3035SFerruh Yigit #define ETH_SPEED_NUM_20G     RTE_DEPRECATED(ETH_SPEED_NUM_20G)     RTE_ETH_SPEED_NUM_20G
355b1cb3035SFerruh Yigit #define ETH_SPEED_NUM_25G     RTE_DEPRECATED(ETH_SPEED_NUM_25G)     RTE_ETH_SPEED_NUM_25G
356b1cb3035SFerruh Yigit #define ETH_SPEED_NUM_40G     RTE_DEPRECATED(ETH_SPEED_NUM_40G)     RTE_ETH_SPEED_NUM_40G
357b1cb3035SFerruh Yigit #define ETH_SPEED_NUM_50G     RTE_DEPRECATED(ETH_SPEED_NUM_50G)     RTE_ETH_SPEED_NUM_50G
358b1cb3035SFerruh Yigit #define ETH_SPEED_NUM_56G     RTE_DEPRECATED(ETH_SPEED_NUM_56G)     RTE_ETH_SPEED_NUM_56G
359b1cb3035SFerruh Yigit #define ETH_SPEED_NUM_100G    RTE_DEPRECATED(ETH_SPEED_NUM_100G)    RTE_ETH_SPEED_NUM_100G
360b1cb3035SFerruh Yigit #define ETH_SPEED_NUM_200G    RTE_DEPRECATED(ETH_SPEED_NUM_200G)    RTE_ETH_SPEED_NUM_200G
361b1cb3035SFerruh Yigit #define ETH_SPEED_NUM_UNKNOWN RTE_DEPRECATED(ETH_SPEED_NUM_UNKNOWN) RTE_ETH_SPEED_NUM_UNKNOWN
362b1cb3035SFerruh Yigit 
36399a2dd95SBruce Richardson /**
36499a2dd95SBruce Richardson  * A structure used to retrieve link-level information of an Ethernet port.
36599a2dd95SBruce Richardson  */
36699a2dd95SBruce Richardson __extension__
36799a2dd95SBruce Richardson struct rte_eth_link {
368295968d1SFerruh Yigit 	uint32_t link_speed;        /**< RTE_ETH_SPEED_NUM_ */
369295968d1SFerruh Yigit 	uint16_t link_duplex  : 1;  /**< RTE_ETH_LINK_[HALF/FULL]_DUPLEX */
370295968d1SFerruh Yigit 	uint16_t link_autoneg : 1;  /**< RTE_ETH_LINK_[AUTONEG/FIXED] */
371295968d1SFerruh Yigit 	uint16_t link_status  : 1;  /**< RTE_ETH_LINK_[DOWN/UP] */
37299a2dd95SBruce Richardson } __rte_aligned(8);      /**< aligned for atomic64 read/write */
37399a2dd95SBruce Richardson 
3740ce56b05SThomas Monjalon /**@{@name Link negotiation
3750ce56b05SThomas Monjalon  * Constants used in link management.
3760ce56b05SThomas Monjalon  */
377295968d1SFerruh Yigit #define RTE_ETH_LINK_HALF_DUPLEX 0 /**< Half-duplex connection (see link_duplex). */
378295968d1SFerruh Yigit #define RTE_ETH_LINK_FULL_DUPLEX 1 /**< Full-duplex connection (see link_duplex). */
379295968d1SFerruh Yigit #define RTE_ETH_LINK_DOWN        0 /**< Link is down (see link_status). */
380295968d1SFerruh Yigit #define RTE_ETH_LINK_UP          1 /**< Link is up (see link_status). */
381295968d1SFerruh Yigit #define RTE_ETH_LINK_FIXED       0 /**< No autonegotiation (see link_autoneg). */
382295968d1SFerruh Yigit #define RTE_ETH_LINK_AUTONEG     1 /**< Autonegotiated (see link_autoneg). */
38399a2dd95SBruce Richardson #define RTE_ETH_LINK_MAX_STR_LEN 40 /**< Max length of default link string. */
3840ce56b05SThomas Monjalon /**@}*/
38599a2dd95SBruce Richardson 
386b1cb3035SFerruh Yigit #define ETH_LINK_HALF_DUPLEX RTE_DEPRECATED(ETH_LINK_HALF_DUPLEX) RTE_ETH_LINK_HALF_DUPLEX
387b1cb3035SFerruh Yigit #define ETH_LINK_FULL_DUPLEX RTE_DEPRECATED(ETH_LINK_FULL_DUPLEX) RTE_ETH_LINK_FULL_DUPLEX
388b1cb3035SFerruh Yigit #define ETH_LINK_DOWN        RTE_DEPRECATED(ETH_LINK_DOWN)        RTE_ETH_LINK_DOWN
389b1cb3035SFerruh Yigit #define ETH_LINK_UP          RTE_DEPRECATED(ETH_LINK_UP)          RTE_ETH_LINK_UP
390b1cb3035SFerruh Yigit #define ETH_LINK_FIXED       RTE_DEPRECATED(ETH_LINK_FIXED)       RTE_ETH_LINK_FIXED
391b1cb3035SFerruh Yigit #define ETH_LINK_AUTONEG     RTE_DEPRECATED(ETH_LINK_AUTONEG)     RTE_ETH_LINK_AUTONEG
392b1cb3035SFerruh Yigit 
39399a2dd95SBruce Richardson /**
39409fd4227SAndrew Rybchenko  * A structure used to configure the ring threshold registers of an Rx/Tx
39599a2dd95SBruce Richardson  * queue for an Ethernet port.
39699a2dd95SBruce Richardson  */
39799a2dd95SBruce Richardson struct rte_eth_thresh {
39899a2dd95SBruce Richardson 	uint8_t pthresh; /**< Ring prefetch threshold. */
39999a2dd95SBruce Richardson 	uint8_t hthresh; /**< Ring host threshold. */
40099a2dd95SBruce Richardson 	uint8_t wthresh; /**< Ring writeback threshold. */
40199a2dd95SBruce Richardson };
40299a2dd95SBruce Richardson 
4030ce56b05SThomas Monjalon /**@{@name Multi-queue mode
4040ce56b05SThomas Monjalon  * @see rte_eth_conf.rxmode.mq_mode.
40599a2dd95SBruce Richardson  */
4064852c647SAndrew Rybchenko #define RTE_ETH_MQ_RX_RSS_FLAG  RTE_BIT32(0) /**< Enable RSS. @see rte_eth_rss_conf */
4074852c647SAndrew Rybchenko #define RTE_ETH_MQ_RX_DCB_FLAG  RTE_BIT32(1) /**< Enable DCB. */
4084852c647SAndrew Rybchenko #define RTE_ETH_MQ_RX_VMDQ_FLAG RTE_BIT32(2) /**< Enable VMDq. */
4090ce56b05SThomas Monjalon /**@}*/
41099a2dd95SBruce Richardson 
411b1cb3035SFerruh Yigit #define ETH_MQ_RX_RSS_FLAG  RTE_DEPRECATED(ETH_MQ_RX_RSS_FLAG)  RTE_ETH_MQ_RX_RSS_FLAG
412b1cb3035SFerruh Yigit #define ETH_MQ_RX_DCB_FLAG  RTE_DEPRECATED(ETH_MQ_RX_DCB_FLAG)  RTE_ETH_MQ_RX_DCB_FLAG
413b1cb3035SFerruh Yigit #define ETH_MQ_RX_VMDQ_FLAG RTE_DEPRECATED(ETH_MQ_RX_VMDQ_FLAG) RTE_ETH_MQ_RX_VMDQ_FLAG
414b1cb3035SFerruh Yigit 
41599a2dd95SBruce Richardson /**
41699a2dd95SBruce Richardson  *  A set of values to identify what method is to be used to route
41799a2dd95SBruce Richardson  *  packets to multiple queues.
41899a2dd95SBruce Richardson  */
41999a2dd95SBruce Richardson enum rte_eth_rx_mq_mode {
420064e90c4SAndrew Rybchenko 	/** None of DCB, RSS or VMDq mode */
421295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_NONE = 0,
42299a2dd95SBruce Richardson 
42309fd4227SAndrew Rybchenko 	/** For Rx side, only RSS is on */
424295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_RSS = RTE_ETH_MQ_RX_RSS_FLAG,
42509fd4227SAndrew Rybchenko 	/** For Rx side,only DCB is on. */
426295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_DCB = RTE_ETH_MQ_RX_DCB_FLAG,
42799a2dd95SBruce Richardson 	/** Both DCB and RSS enable */
428295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_DCB_RSS = RTE_ETH_MQ_RX_RSS_FLAG | RTE_ETH_MQ_RX_DCB_FLAG,
42999a2dd95SBruce Richardson 
430064e90c4SAndrew Rybchenko 	/** Only VMDq, no RSS nor DCB */
431295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_VMDQ_ONLY = RTE_ETH_MQ_RX_VMDQ_FLAG,
432064e90c4SAndrew Rybchenko 	/** RSS mode with VMDq */
433295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_VMDQ_RSS = RTE_ETH_MQ_RX_RSS_FLAG | RTE_ETH_MQ_RX_VMDQ_FLAG,
434064e90c4SAndrew Rybchenko 	/** Use VMDq+DCB to route traffic to queues */
435295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_VMDQ_DCB = RTE_ETH_MQ_RX_VMDQ_FLAG | RTE_ETH_MQ_RX_DCB_FLAG,
436064e90c4SAndrew Rybchenko 	/** Enable both VMDq and DCB in VMDq */
437295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_VMDQ_DCB_RSS = RTE_ETH_MQ_RX_RSS_FLAG | RTE_ETH_MQ_RX_DCB_FLAG |
438295968d1SFerruh Yigit 				 RTE_ETH_MQ_RX_VMDQ_FLAG,
43999a2dd95SBruce Richardson };
44099a2dd95SBruce Richardson 
441b1cb3035SFerruh Yigit #define ETH_MQ_RX_NONE         RTE_DEPRECATED(ETH_MQ_RX_NONE)         RTE_ETH_MQ_RX_NONE
442b1cb3035SFerruh Yigit #define ETH_MQ_RX_RSS          RTE_DEPRECATED(ETH_MQ_RX_RSS)          RTE_ETH_MQ_RX_RSS
443b1cb3035SFerruh Yigit #define ETH_MQ_RX_DCB          RTE_DEPRECATED(ETH_MQ_RX_DCB)          RTE_ETH_MQ_RX_DCB
444b1cb3035SFerruh Yigit #define ETH_MQ_RX_DCB_RSS      RTE_DEPRECATED(ETH_MQ_RX_DCB_RSS)      RTE_ETH_MQ_RX_DCB_RSS
445b1cb3035SFerruh Yigit #define ETH_MQ_RX_VMDQ_ONLY    RTE_DEPRECATED(ETH_MQ_RX_VMDQ_ONLY)    RTE_ETH_MQ_RX_VMDQ_ONLY
446b1cb3035SFerruh Yigit #define ETH_MQ_RX_VMDQ_RSS     RTE_DEPRECATED(ETH_MQ_RX_VMDQ_RSS)     RTE_ETH_MQ_RX_VMDQ_RSS
447b1cb3035SFerruh Yigit #define ETH_MQ_RX_VMDQ_DCB     RTE_DEPRECATED(ETH_MQ_RX_VMDQ_DCB)     RTE_ETH_MQ_RX_VMDQ_DCB
448b1cb3035SFerruh Yigit #define ETH_MQ_RX_VMDQ_DCB_RSS RTE_DEPRECATED(ETH_MQ_RX_VMDQ_DCB_RSS) RTE_ETH_MQ_RX_VMDQ_DCB_RSS
44999a2dd95SBruce Richardson 
45099a2dd95SBruce Richardson /**
45199a2dd95SBruce Richardson  * A set of values to identify what method is to be used to transmit
45299a2dd95SBruce Richardson  * packets using multi-TCs.
45399a2dd95SBruce Richardson  */
45499a2dd95SBruce Richardson enum rte_eth_tx_mq_mode {
455295968d1SFerruh Yigit 	RTE_ETH_MQ_TX_NONE    = 0,  /**< It is in neither DCB nor VT mode. */
456295968d1SFerruh Yigit 	RTE_ETH_MQ_TX_DCB,          /**< For Tx side,only DCB is on. */
457295968d1SFerruh Yigit 	RTE_ETH_MQ_TX_VMDQ_DCB,     /**< For Tx side,both DCB and VT is on. */
458295968d1SFerruh Yigit 	RTE_ETH_MQ_TX_VMDQ_ONLY,    /**< Only VT on, no DCB */
45999a2dd95SBruce Richardson };
460b1cb3035SFerruh Yigit 
461b1cb3035SFerruh Yigit #define ETH_MQ_TX_NONE      RTE_DEPRECATED(ETH_MQ_TX_NONE)      RTE_ETH_MQ_TX_NONE
462b1cb3035SFerruh Yigit #define ETH_MQ_TX_DCB       RTE_DEPRECATED(ETH_MQ_TX_DCB)       RTE_ETH_MQ_TX_DCB
463b1cb3035SFerruh Yigit #define ETH_MQ_TX_VMDQ_DCB  RTE_DEPRECATED(ETH_MQ_TX_VMDQ_DCB)  RTE_ETH_MQ_TX_VMDQ_DCB
464b1cb3035SFerruh Yigit #define ETH_MQ_TX_VMDQ_ONLY RTE_DEPRECATED(ETH_MQ_TX_VMDQ_ONLY) RTE_ETH_MQ_TX_VMDQ_ONLY
46599a2dd95SBruce Richardson 
46699a2dd95SBruce Richardson /**
46709fd4227SAndrew Rybchenko  * A structure used to configure the Rx features of an Ethernet port.
46899a2dd95SBruce Richardson  */
46999a2dd95SBruce Richardson struct rte_eth_rxmode {
47099a2dd95SBruce Richardson 	/** The multi-queue packet distribution mode to be used, e.g. RSS. */
47199a2dd95SBruce Richardson 	enum rte_eth_rx_mq_mode mq_mode;
4721bb4a528SFerruh Yigit 	uint32_t mtu;  /**< Requested MTU. */
47399a2dd95SBruce Richardson 	/** Maximum allowed size of LRO aggregated packet. */
47499a2dd95SBruce Richardson 	uint32_t max_lro_pkt_size;
47599a2dd95SBruce Richardson 	uint16_t split_hdr_size;  /**< hdr buf size (header_split enabled).*/
47699a2dd95SBruce Richardson 	/**
477295968d1SFerruh Yigit 	 * Per-port Rx offloads to be set using RTE_ETH_RX_OFFLOAD_* flags.
47899a2dd95SBruce Richardson 	 * Only offloads set on rx_offload_capa field on rte_eth_dev_info
47999a2dd95SBruce Richardson 	 * structure are allowed to be set.
48099a2dd95SBruce Richardson 	 */
48199a2dd95SBruce Richardson 	uint64_t offloads;
48299a2dd95SBruce Richardson 
48399a2dd95SBruce Richardson 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
48499a2dd95SBruce Richardson 	void *reserved_ptrs[2];   /**< Reserved for future fields */
48599a2dd95SBruce Richardson };
48699a2dd95SBruce Richardson 
48799a2dd95SBruce Richardson /**
48899a2dd95SBruce Richardson  * VLAN types to indicate if it is for single VLAN, inner VLAN or outer VLAN.
48999a2dd95SBruce Richardson  * Note that single VLAN is treated the same as inner VLAN.
49099a2dd95SBruce Richardson  */
49199a2dd95SBruce Richardson enum rte_vlan_type {
492295968d1SFerruh Yigit 	RTE_ETH_VLAN_TYPE_UNKNOWN = 0,
493295968d1SFerruh Yigit 	RTE_ETH_VLAN_TYPE_INNER, /**< Inner VLAN. */
494295968d1SFerruh Yigit 	RTE_ETH_VLAN_TYPE_OUTER, /**< Single VLAN, or outer VLAN. */
495295968d1SFerruh Yigit 	RTE_ETH_VLAN_TYPE_MAX,
49699a2dd95SBruce Richardson };
49799a2dd95SBruce Richardson 
498b1cb3035SFerruh Yigit #define ETH_VLAN_TYPE_UNKNOWN RTE_DEPRECATED(ETH_VLAN_TYPE_UNKNOWN) RTE_ETH_VLAN_TYPE_UNKNOWN
499b1cb3035SFerruh Yigit #define ETH_VLAN_TYPE_INNER   RTE_DEPRECATED(ETH_VLAN_TYPE_INNER)   RTE_ETH_VLAN_TYPE_INNER
500b1cb3035SFerruh Yigit #define ETH_VLAN_TYPE_OUTER   RTE_DEPRECATED(ETH_VLAN_TYPE_OUTER)   RTE_ETH_VLAN_TYPE_OUTER
501b1cb3035SFerruh Yigit #define ETH_VLAN_TYPE_MAX     RTE_DEPRECATED(ETH_VLAN_TYPE_MAX)     RTE_ETH_VLAN_TYPE_MAX
502295968d1SFerruh Yigit 
50399a2dd95SBruce Richardson /**
5045b49ba65SAndrew Rybchenko  * A structure used to describe a VLAN filter.
50599a2dd95SBruce Richardson  * If the bit corresponding to a VID is set, such VID is on.
50699a2dd95SBruce Richardson  */
50799a2dd95SBruce Richardson struct rte_vlan_filter_conf {
50899a2dd95SBruce Richardson 	uint64_t ids[64];
50999a2dd95SBruce Richardson };
51099a2dd95SBruce Richardson 
51199a2dd95SBruce Richardson /**
51299a2dd95SBruce Richardson  * A structure used to configure the Receive Side Scaling (RSS) feature
51399a2dd95SBruce Richardson  * of an Ethernet port.
51499a2dd95SBruce Richardson  * If not NULL, the *rss_key* pointer of the *rss_conf* structure points
51599a2dd95SBruce Richardson  * to an array holding the RSS key to use for hashing specific header
51699a2dd95SBruce Richardson  * fields of received packets. The length of this array should be indicated
51799a2dd95SBruce Richardson  * by *rss_key_len* below. Otherwise, a default random hash key is used by
51899a2dd95SBruce Richardson  * the device driver.
51999a2dd95SBruce Richardson  *
52099a2dd95SBruce Richardson  * The *rss_key_len* field of the *rss_conf* structure indicates the length
52199a2dd95SBruce Richardson  * in bytes of the array pointed by *rss_key*. To be compatible, this length
52299a2dd95SBruce Richardson  * will be checked in i40e only. Others assume 40 bytes to be used as before.
52399a2dd95SBruce Richardson  *
52499a2dd95SBruce Richardson  * The *rss_hf* field of the *rss_conf* structure indicates the different
52599a2dd95SBruce Richardson  * types of IPv4/IPv6 packets to which the RSS hashing must be applied.
52699a2dd95SBruce Richardson  * Supplying an *rss_hf* equal to zero disables the RSS feature.
52799a2dd95SBruce Richardson  */
52899a2dd95SBruce Richardson struct rte_eth_rss_conf {
52999a2dd95SBruce Richardson 	uint8_t *rss_key;    /**< If not NULL, 40-byte hash key. */
53099a2dd95SBruce Richardson 	uint8_t rss_key_len; /**< hash key length in bytes. */
53199a2dd95SBruce Richardson 	uint64_t rss_hf;     /**< Hash functions to apply - see below. */
53299a2dd95SBruce Richardson };
53399a2dd95SBruce Richardson 
53499a2dd95SBruce Richardson /*
53599a2dd95SBruce Richardson  * A packet can be identified by hardware as different flow types. Different
53699a2dd95SBruce Richardson  * NIC hardware may support different flow types.
53799a2dd95SBruce Richardson  * Basically, the NIC hardware identifies the flow type as deep protocol as
53899a2dd95SBruce Richardson  * possible, and exclusively. For example, if a packet is identified as
53999a2dd95SBruce Richardson  * 'RTE_ETH_FLOW_NONFRAG_IPV4_TCP', it will not be any of other flow types,
54099a2dd95SBruce Richardson  * though it is an actual IPV4 packet.
54199a2dd95SBruce Richardson  */
54299a2dd95SBruce Richardson #define RTE_ETH_FLOW_UNKNOWN             0
54399a2dd95SBruce Richardson #define RTE_ETH_FLOW_RAW                 1
54499a2dd95SBruce Richardson #define RTE_ETH_FLOW_IPV4                2
54599a2dd95SBruce Richardson #define RTE_ETH_FLOW_FRAG_IPV4           3
54699a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV4_TCP    4
54799a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV4_UDP    5
54899a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV4_SCTP   6
54999a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV4_OTHER  7
55099a2dd95SBruce Richardson #define RTE_ETH_FLOW_IPV6                8
55199a2dd95SBruce Richardson #define RTE_ETH_FLOW_FRAG_IPV6           9
55299a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV6_TCP   10
55399a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV6_UDP   11
55499a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV6_SCTP  12
55599a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV6_OTHER 13
55699a2dd95SBruce Richardson #define RTE_ETH_FLOW_L2_PAYLOAD         14
55799a2dd95SBruce Richardson #define RTE_ETH_FLOW_IPV6_EX            15
55899a2dd95SBruce Richardson #define RTE_ETH_FLOW_IPV6_TCP_EX        16
55999a2dd95SBruce Richardson #define RTE_ETH_FLOW_IPV6_UDP_EX        17
5603c2ca0a9SAndrew Rybchenko /** Consider device port number as a flow differentiator */
56199a2dd95SBruce Richardson #define RTE_ETH_FLOW_PORT               18
56299a2dd95SBruce Richardson #define RTE_ETH_FLOW_VXLAN              19 /**< VXLAN protocol based flow */
56399a2dd95SBruce Richardson #define RTE_ETH_FLOW_GENEVE             20 /**< GENEVE protocol based flow */
56499a2dd95SBruce Richardson #define RTE_ETH_FLOW_NVGRE              21 /**< NVGRE protocol based flow */
56599a2dd95SBruce Richardson #define RTE_ETH_FLOW_VXLAN_GPE          22 /**< VXLAN-GPE protocol based flow */
56699a2dd95SBruce Richardson #define RTE_ETH_FLOW_GTPU               23 /**< GTPU protocol based flow */
56799a2dd95SBruce Richardson #define RTE_ETH_FLOW_MAX                24
56899a2dd95SBruce Richardson 
56999a2dd95SBruce Richardson /*
57099a2dd95SBruce Richardson  * Below macros are defined for RSS offload types, they can be used to
57199a2dd95SBruce Richardson  * fill rte_eth_rss_conf.rss_hf or rte_flow_action_rss.types.
57299a2dd95SBruce Richardson  */
573295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV4               RTE_BIT64(2)
574295968d1SFerruh Yigit #define RTE_ETH_RSS_FRAG_IPV4          RTE_BIT64(3)
575295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV4_TCP   RTE_BIT64(4)
576295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV4_UDP   RTE_BIT64(5)
577295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV4_SCTP  RTE_BIT64(6)
578295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV4_OTHER RTE_BIT64(7)
579295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6               RTE_BIT64(8)
580295968d1SFerruh Yigit #define RTE_ETH_RSS_FRAG_IPV6          RTE_BIT64(9)
581295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV6_TCP   RTE_BIT64(10)
582295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV6_UDP   RTE_BIT64(11)
583295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV6_SCTP  RTE_BIT64(12)
584295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV6_OTHER RTE_BIT64(13)
585295968d1SFerruh Yigit #define RTE_ETH_RSS_L2_PAYLOAD         RTE_BIT64(14)
586295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_EX            RTE_BIT64(15)
587295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_TCP_EX        RTE_BIT64(16)
588295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_UDP_EX        RTE_BIT64(17)
589295968d1SFerruh Yigit #define RTE_ETH_RSS_PORT               RTE_BIT64(18)
590295968d1SFerruh Yigit #define RTE_ETH_RSS_VXLAN              RTE_BIT64(19)
591295968d1SFerruh Yigit #define RTE_ETH_RSS_GENEVE             RTE_BIT64(20)
592295968d1SFerruh Yigit #define RTE_ETH_RSS_NVGRE              RTE_BIT64(21)
593295968d1SFerruh Yigit #define RTE_ETH_RSS_GTPU               RTE_BIT64(23)
594295968d1SFerruh Yigit #define RTE_ETH_RSS_ETH                RTE_BIT64(24)
595295968d1SFerruh Yigit #define RTE_ETH_RSS_S_VLAN             RTE_BIT64(25)
596295968d1SFerruh Yigit #define RTE_ETH_RSS_C_VLAN             RTE_BIT64(26)
597295968d1SFerruh Yigit #define RTE_ETH_RSS_ESP                RTE_BIT64(27)
598295968d1SFerruh Yigit #define RTE_ETH_RSS_AH                 RTE_BIT64(28)
599295968d1SFerruh Yigit #define RTE_ETH_RSS_L2TPV3             RTE_BIT64(29)
600295968d1SFerruh Yigit #define RTE_ETH_RSS_PFCP               RTE_BIT64(30)
601295968d1SFerruh Yigit #define RTE_ETH_RSS_PPPOE              RTE_BIT64(31)
602295968d1SFerruh Yigit #define RTE_ETH_RSS_ECPRI              RTE_BIT64(32)
603295968d1SFerruh Yigit #define RTE_ETH_RSS_MPLS               RTE_BIT64(33)
604295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV4_CHKSUM        RTE_BIT64(34)
605b1cb3035SFerruh Yigit 
606b1cb3035SFerruh Yigit #define ETH_RSS_IPV4               RTE_DEPRECATED(ETH_RSS_IPV4)               RTE_ETH_RSS_IPV4
607b1cb3035SFerruh Yigit #define ETH_RSS_FRAG_IPV4          RTE_DEPRECATED(ETH_RSS_FRAG_IPV4)          RTE_ETH_RSS_FRAG_IPV4
608b1cb3035SFerruh Yigit #define ETH_RSS_NONFRAG_IPV4_TCP   RTE_DEPRECATED(ETH_RSS_NONFRAG_IPV4_TCP)   RTE_ETH_RSS_NONFRAG_IPV4_TCP
609b1cb3035SFerruh Yigit #define ETH_RSS_NONFRAG_IPV4_UDP   RTE_DEPRECATED(ETH_RSS_NONFRAG_IPV4_UDP)   RTE_ETH_RSS_NONFRAG_IPV4_UDP
610b1cb3035SFerruh Yigit #define ETH_RSS_NONFRAG_IPV4_SCTP  RTE_DEPRECATED(ETH_RSS_NONFRAG_IPV4_SCTP)  RTE_ETH_RSS_NONFRAG_IPV4_SCTP
611b1cb3035SFerruh Yigit #define ETH_RSS_NONFRAG_IPV4_OTHER RTE_DEPRECATED(ETH_RSS_NONFRAG_IPV4_OTHER) RTE_ETH_RSS_NONFRAG_IPV4_OTHER
612b1cb3035SFerruh Yigit #define ETH_RSS_IPV6               RTE_DEPRECATED(ETH_RSS_IPV6)               RTE_ETH_RSS_IPV6
613b1cb3035SFerruh Yigit #define ETH_RSS_FRAG_IPV6          RTE_DEPRECATED(ETH_RSS_FRAG_IPV6)          RTE_ETH_RSS_FRAG_IPV6
614b1cb3035SFerruh Yigit #define ETH_RSS_NONFRAG_IPV6_TCP   RTE_DEPRECATED(ETH_RSS_NONFRAG_IPV6_TCP)   RTE_ETH_RSS_NONFRAG_IPV6_TCP
615b1cb3035SFerruh Yigit #define ETH_RSS_NONFRAG_IPV6_UDP   RTE_DEPRECATED(ETH_RSS_NONFRAG_IPV6_UDP)   RTE_ETH_RSS_NONFRAG_IPV6_UDP
616b1cb3035SFerruh Yigit #define ETH_RSS_NONFRAG_IPV6_SCTP  RTE_DEPRECATED(ETH_RSS_NONFRAG_IPV6_SCTP)  RTE_ETH_RSS_NONFRAG_IPV6_SCTP
617b1cb3035SFerruh Yigit #define ETH_RSS_NONFRAG_IPV6_OTHER RTE_DEPRECATED(ETH_RSS_NONFRAG_IPV6_OTHER) RTE_ETH_RSS_NONFRAG_IPV6_OTHER
618b1cb3035SFerruh Yigit #define ETH_RSS_L2_PAYLOAD         RTE_DEPRECATED(ETH_RSS_L2_PAYLOAD)         RTE_ETH_RSS_L2_PAYLOAD
619b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_EX            RTE_DEPRECATED(ETH_RSS_IPV6_EX)            RTE_ETH_RSS_IPV6_EX
620b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_TCP_EX        RTE_DEPRECATED(ETH_RSS_IPV6_TCP_EX)        RTE_ETH_RSS_IPV6_TCP_EX
621b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_UDP_EX        RTE_DEPRECATED(ETH_RSS_IPV6_UDP_EX)        RTE_ETH_RSS_IPV6_UDP_EX
622b1cb3035SFerruh Yigit #define ETH_RSS_PORT               RTE_DEPRECATED(ETH_RSS_PORT)               RTE_ETH_RSS_PORT
623b1cb3035SFerruh Yigit #define ETH_RSS_VXLAN              RTE_DEPRECATED(ETH_RSS_VXLAN)              RTE_ETH_RSS_VXLAN
624b1cb3035SFerruh Yigit #define ETH_RSS_GENEVE             RTE_DEPRECATED(ETH_RSS_GENEVE)             RTE_ETH_RSS_GENEVE
625b1cb3035SFerruh Yigit #define ETH_RSS_NVGRE              RTE_DEPRECATED(ETH_RSS_NVGRE)              RTE_ETH_RSS_NVGRE
626b1cb3035SFerruh Yigit #define ETH_RSS_GTPU               RTE_DEPRECATED(ETH_RSS_GTPU)               RTE_ETH_RSS_GTPU
627b1cb3035SFerruh Yigit #define ETH_RSS_ETH                RTE_DEPRECATED(ETH_RSS_ETH)                RTE_ETH_RSS_ETH
628b1cb3035SFerruh Yigit #define ETH_RSS_S_VLAN             RTE_DEPRECATED(ETH_RSS_S_VLAN)             RTE_ETH_RSS_S_VLAN
629b1cb3035SFerruh Yigit #define ETH_RSS_C_VLAN             RTE_DEPRECATED(ETH_RSS_C_VLAN)             RTE_ETH_RSS_C_VLAN
630b1cb3035SFerruh Yigit #define ETH_RSS_ESP                RTE_DEPRECATED(ETH_RSS_ESP)                RTE_ETH_RSS_ESP
631b1cb3035SFerruh Yigit #define ETH_RSS_AH                 RTE_DEPRECATED(ETH_RSS_AH)                 RTE_ETH_RSS_AH
632b1cb3035SFerruh Yigit #define ETH_RSS_L2TPV3             RTE_DEPRECATED(ETH_RSS_L2TPV3)             RTE_ETH_RSS_L2TPV3
633b1cb3035SFerruh Yigit #define ETH_RSS_PFCP               RTE_DEPRECATED(ETH_RSS_PFCP)               RTE_ETH_RSS_PFCP
634b1cb3035SFerruh Yigit #define ETH_RSS_PPPOE              RTE_DEPRECATED(ETH_RSS_PPPOE)              RTE_ETH_RSS_PPPOE
635b1cb3035SFerruh Yigit #define ETH_RSS_ECPRI              RTE_DEPRECATED(ETH_RSS_ECPRI)              RTE_ETH_RSS_ECPRI
636b1cb3035SFerruh Yigit #define ETH_RSS_MPLS               RTE_DEPRECATED(ETH_RSS_MPLS)               RTE_ETH_RSS_MPLS
637b1cb3035SFerruh Yigit #define ETH_RSS_IPV4_CHKSUM        RTE_DEPRECATED(ETH_RSS_IPV4_CHKSUM)        RTE_ETH_RSS_IPV4_CHKSUM
63881b0fbb8SAlvin Zhang 
63981b0fbb8SAlvin Zhang /**
64081b0fbb8SAlvin Zhang  * The ETH_RSS_L4_CHKSUM works on checksum field of any L4 header.
64181b0fbb8SAlvin Zhang  * It is similar to ETH_RSS_PORT that they don't specify the specific type of
64281b0fbb8SAlvin Zhang  * L4 header. This macro is defined to replace some specific L4 (TCP/UDP/SCTP)
64381b0fbb8SAlvin Zhang  * checksum type for constructing the use of RSS offload bits.
64481b0fbb8SAlvin Zhang  *
64581b0fbb8SAlvin Zhang  * Due to above reason, some old APIs (and configuration) don't support
646295968d1SFerruh Yigit  * RTE_ETH_RSS_L4_CHKSUM. The rte_flow RSS API supports it.
64781b0fbb8SAlvin Zhang  *
64881b0fbb8SAlvin Zhang  * For the case that checksum is not used in an UDP header,
64981b0fbb8SAlvin Zhang  * it takes the reserved value 0 as input for the hash function.
65081b0fbb8SAlvin Zhang  */
651295968d1SFerruh Yigit #define RTE_ETH_RSS_L4_CHKSUM          RTE_BIT64(35)
652b1cb3035SFerruh Yigit #define ETH_RSS_L4_CHKSUM RTE_DEPRECATED(ETH_RSS_L4_CHKSUM) RTE_ETH_RSS_L4_CHKSUM
65399a2dd95SBruce Richardson 
654f840cf77SJie Wang #define RTE_ETH_RSS_L2TPV2             RTE_BIT64(36)
655f840cf77SJie Wang 
65699a2dd95SBruce Richardson /*
657295968d1SFerruh Yigit  * We use the following macros to combine with above RTE_ETH_RSS_* for
65899a2dd95SBruce Richardson  * more specific input set selection. These bits are defined starting
65999a2dd95SBruce Richardson  * from the high end of the 64 bits.
660295968d1SFerruh Yigit  * Note: If we use above RTE_ETH_RSS_* without SRC/DST_ONLY, it represents
66199a2dd95SBruce Richardson  * both SRC and DST are taken into account. If SRC_ONLY and DST_ONLY of
66299a2dd95SBruce Richardson  * the same level are used simultaneously, it is the same case as none of
66399a2dd95SBruce Richardson  * them are added.
66499a2dd95SBruce Richardson  */
665295968d1SFerruh Yigit #define RTE_ETH_RSS_L3_SRC_ONLY        RTE_BIT64(63)
666295968d1SFerruh Yigit #define RTE_ETH_RSS_L3_DST_ONLY        RTE_BIT64(62)
667295968d1SFerruh Yigit #define RTE_ETH_RSS_L4_SRC_ONLY        RTE_BIT64(61)
668295968d1SFerruh Yigit #define RTE_ETH_RSS_L4_DST_ONLY        RTE_BIT64(60)
669295968d1SFerruh Yigit #define RTE_ETH_RSS_L2_SRC_ONLY        RTE_BIT64(59)
670295968d1SFerruh Yigit #define RTE_ETH_RSS_L2_DST_ONLY        RTE_BIT64(58)
671b1cb3035SFerruh Yigit 
672b1cb3035SFerruh Yigit #define ETH_RSS_L3_SRC_ONLY RTE_DEPRECATED(ETH_RSS_L3_SRC_ONLY) RTE_ETH_RSS_L3_SRC_ONLY
673b1cb3035SFerruh Yigit #define ETH_RSS_L3_DST_ONLY RTE_DEPRECATED(ETH_RSS_L3_DST_ONLY) RTE_ETH_RSS_L3_DST_ONLY
674b1cb3035SFerruh Yigit #define ETH_RSS_L4_SRC_ONLY RTE_DEPRECATED(ETH_RSS_L4_SRC_ONLY) RTE_ETH_RSS_L4_SRC_ONLY
675b1cb3035SFerruh Yigit #define ETH_RSS_L4_DST_ONLY RTE_DEPRECATED(ETH_RSS_L4_DST_ONLY) RTE_ETH_RSS_L4_DST_ONLY
676b1cb3035SFerruh Yigit #define ETH_RSS_L2_SRC_ONLY RTE_DEPRECATED(ETH_RSS_L2_SRC_ONLY) RTE_ETH_RSS_L2_SRC_ONLY
677b1cb3035SFerruh Yigit #define ETH_RSS_L2_DST_ONLY RTE_DEPRECATED(ETH_RSS_L2_DST_ONLY) RTE_ETH_RSS_L2_DST_ONLY
67899a2dd95SBruce Richardson 
67999a2dd95SBruce Richardson /*
68099a2dd95SBruce Richardson  * Only select IPV6 address prefix as RSS input set according to
681b1cb3035SFerruh Yigit  * https://tools.ietf.org/html/rfc6052
682295968d1SFerruh Yigit  * Must be combined with RTE_ETH_RSS_IPV6, RTE_ETH_RSS_NONFRAG_IPV6_UDP,
683295968d1SFerruh Yigit  * RTE_ETH_RSS_NONFRAG_IPV6_TCP, RTE_ETH_RSS_NONFRAG_IPV6_SCTP.
68499a2dd95SBruce Richardson  */
685e1823e08SThomas Monjalon #define RTE_ETH_RSS_L3_PRE32           RTE_BIT64(57)
686e1823e08SThomas Monjalon #define RTE_ETH_RSS_L3_PRE40           RTE_BIT64(56)
687e1823e08SThomas Monjalon #define RTE_ETH_RSS_L3_PRE48           RTE_BIT64(55)
688e1823e08SThomas Monjalon #define RTE_ETH_RSS_L3_PRE56           RTE_BIT64(54)
689e1823e08SThomas Monjalon #define RTE_ETH_RSS_L3_PRE64           RTE_BIT64(53)
690e1823e08SThomas Monjalon #define RTE_ETH_RSS_L3_PRE96           RTE_BIT64(52)
69199a2dd95SBruce Richardson 
69299a2dd95SBruce Richardson /*
69399a2dd95SBruce Richardson  * Use the following macros to combine with the above layers
69499a2dd95SBruce Richardson  * to choose inner and outer layers or both for RSS computation.
69599a2dd95SBruce Richardson  * Bits 50 and 51 are reserved for this.
69699a2dd95SBruce Richardson  */
69799a2dd95SBruce Richardson 
69899a2dd95SBruce Richardson /**
69999a2dd95SBruce Richardson  * level 0, requests the default behavior.
70099a2dd95SBruce Richardson  * Depending on the packet type, it can mean outermost, innermost,
70199a2dd95SBruce Richardson  * anything in between or even no RSS.
70299a2dd95SBruce Richardson  * It basically stands for the innermost encapsulation level RSS
70399a2dd95SBruce Richardson  * can be performed on according to PMD and device capabilities.
70499a2dd95SBruce Richardson  */
70568e8ca7bSAndrew Rybchenko #define RTE_ETH_RSS_LEVEL_PMD_DEFAULT  (UINT64_C(0) << 50)
706b1cb3035SFerruh Yigit #define ETH_RSS_LEVEL_PMD_DEFAULT RTE_DEPRECATED(ETH_RSS_LEVEL_PMD_DEFAULT) RTE_ETH_RSS_LEVEL_PMD_DEFAULT
70799a2dd95SBruce Richardson 
70899a2dd95SBruce Richardson /**
70999a2dd95SBruce Richardson  * level 1, requests RSS to be performed on the outermost packet
71099a2dd95SBruce Richardson  * encapsulation level.
71199a2dd95SBruce Richardson  */
71268e8ca7bSAndrew Rybchenko #define RTE_ETH_RSS_LEVEL_OUTERMOST    (UINT64_C(1) << 50)
713b1cb3035SFerruh Yigit #define ETH_RSS_LEVEL_OUTERMOST RTE_DEPRECATED(ETH_RSS_LEVEL_OUTERMOST) RTE_ETH_RSS_LEVEL_OUTERMOST
71499a2dd95SBruce Richardson 
71599a2dd95SBruce Richardson /**
71699a2dd95SBruce Richardson  * level 2, requests RSS to be performed on the specified inner packet
71799a2dd95SBruce Richardson  * encapsulation level, from outermost to innermost (lower to higher values).
71899a2dd95SBruce Richardson  */
71968e8ca7bSAndrew Rybchenko #define RTE_ETH_RSS_LEVEL_INNERMOST    (UINT64_C(2) << 50)
72068e8ca7bSAndrew Rybchenko #define RTE_ETH_RSS_LEVEL_MASK         (UINT64_C(3) << 50)
721b1cb3035SFerruh Yigit 
722b1cb3035SFerruh Yigit #define ETH_RSS_LEVEL_INNERMOST RTE_DEPRECATED(ETH_RSS_LEVEL_INNERMOST) RTE_ETH_RSS_LEVEL_INNERMOST
723b1cb3035SFerruh Yigit #define ETH_RSS_LEVEL_MASK      RTE_DEPRECATED(ETH_RSS_LEVEL_MASK)      RTE_ETH_RSS_LEVEL_MASK
72499a2dd95SBruce Richardson 
725295968d1SFerruh Yigit #define RTE_ETH_RSS_LEVEL(rss_hf) ((rss_hf & RTE_ETH_RSS_LEVEL_MASK) >> 50)
726b1cb3035SFerruh Yigit #define ETH_RSS_LEVEL(rss_hf) RTE_DEPRECATED(ETH_RSS_LEVEL(rss_hf)) RTE_ETH_RSS_LEVEL(rss_hf)
72799a2dd95SBruce Richardson 
72899a2dd95SBruce Richardson /**
72999a2dd95SBruce Richardson  * For input set change of hash filter, if SRC_ONLY and DST_ONLY of
73099a2dd95SBruce Richardson  * the same level are used simultaneously, it is the same case as
73199a2dd95SBruce Richardson  * none of them are added.
73299a2dd95SBruce Richardson  *
73399a2dd95SBruce Richardson  * @param rss_hf
73499a2dd95SBruce Richardson  *   RSS types with SRC/DST_ONLY.
73599a2dd95SBruce Richardson  * @return
73699a2dd95SBruce Richardson  *   RSS types.
73799a2dd95SBruce Richardson  */
73899a2dd95SBruce Richardson static inline uint64_t
rte_eth_rss_hf_refine(uint64_t rss_hf)73999a2dd95SBruce Richardson rte_eth_rss_hf_refine(uint64_t rss_hf)
74099a2dd95SBruce Richardson {
741295968d1SFerruh Yigit 	if ((rss_hf & RTE_ETH_RSS_L3_SRC_ONLY) && (rss_hf & RTE_ETH_RSS_L3_DST_ONLY))
742295968d1SFerruh Yigit 		rss_hf &= ~(RTE_ETH_RSS_L3_SRC_ONLY | RTE_ETH_RSS_L3_DST_ONLY);
74399a2dd95SBruce Richardson 
744295968d1SFerruh Yigit 	if ((rss_hf & RTE_ETH_RSS_L4_SRC_ONLY) && (rss_hf & RTE_ETH_RSS_L4_DST_ONLY))
745295968d1SFerruh Yigit 		rss_hf &= ~(RTE_ETH_RSS_L4_SRC_ONLY | RTE_ETH_RSS_L4_DST_ONLY);
74699a2dd95SBruce Richardson 
74799a2dd95SBruce Richardson 	return rss_hf;
74899a2dd95SBruce Richardson }
74999a2dd95SBruce Richardson 
750295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE32 ( \
751295968d1SFerruh Yigit 		RTE_ETH_RSS_IPV6 | \
75299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE32)
753b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_PRE32 RTE_DEPRECATED(ETH_RSS_IPV6_PRE32) RTE_ETH_RSS_IPV6_PRE32
75499a2dd95SBruce Richardson 
755295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE40 ( \
756295968d1SFerruh Yigit 		RTE_ETH_RSS_IPV6 | \
75799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE40)
758b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_PRE40 RTE_DEPRECATED(ETH_RSS_IPV6_PRE40) RTE_ETH_RSS_IPV6_PRE40
75999a2dd95SBruce Richardson 
760295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE48 ( \
761295968d1SFerruh Yigit 		RTE_ETH_RSS_IPV6 | \
76299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE48)
763b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_PRE48 RTE_DEPRECATED(ETH_RSS_IPV6_PRE48) RTE_ETH_RSS_IPV6_PRE48
76499a2dd95SBruce Richardson 
765295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE56 ( \
766295968d1SFerruh Yigit 		RTE_ETH_RSS_IPV6 | \
76799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE56)
768b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_PRE56 RTE_DEPRECATED(ETH_RSS_IPV6_PRE56) RTE_ETH_RSS_IPV6_PRE56
76999a2dd95SBruce Richardson 
770295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE64 ( \
771295968d1SFerruh Yigit 		RTE_ETH_RSS_IPV6 | \
77299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE64)
773b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_PRE64 RTE_DEPRECATED(ETH_RSS_IPV6_PRE64) RTE_ETH_RSS_IPV6_PRE64
77499a2dd95SBruce Richardson 
775295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE96 ( \
776295968d1SFerruh Yigit 		RTE_ETH_RSS_IPV6 | \
77799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE96)
778b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_PRE96 RTE_DEPRECATED(ETH_RSS_IPV6_PRE96) RTE_ETH_RSS_IPV6_PRE96
77999a2dd95SBruce Richardson 
780295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE32_UDP ( \
781295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
78299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE32)
783b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_PRE32_UDP RTE_DEPRECATED(ETH_RSS_IPV6_PRE32_UDP) RTE_ETH_RSS_IPV6_PRE32_UDP
78499a2dd95SBruce Richardson 
785295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE40_UDP ( \
786295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
78799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE40)
788b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_PRE40_UDP RTE_DEPRECATED(ETH_RSS_IPV6_PRE40_UDP) RTE_ETH_RSS_IPV6_PRE40_UDP
78999a2dd95SBruce Richardson 
790295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE48_UDP ( \
791295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
79299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE48)
793b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_PRE48_UDP RTE_DEPRECATED(ETH_RSS_IPV6_PRE48_UDP) RTE_ETH_RSS_IPV6_PRE48_UDP
79499a2dd95SBruce Richardson 
795295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE56_UDP ( \
796295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
79799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE56)
798b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_PRE56_UDP RTE_DEPRECATED(ETH_RSS_IPV6_PRE56_UDP) RTE_ETH_RSS_IPV6_PRE56_UDP
79999a2dd95SBruce Richardson 
800295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE64_UDP ( \
801295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
80299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE64)
803b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_PRE64_UDP RTE_DEPRECATED(ETH_RSS_IPV6_PRE64_UDP) RTE_ETH_RSS_IPV6_PRE64_UDP
80499a2dd95SBruce Richardson 
805295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE96_UDP ( \
806295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
80799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE96)
808b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_PRE96_UDP RTE_DEPRECATED(ETH_RSS_IPV6_PRE96_UDP) RTE_ETH_RSS_IPV6_PRE96_UDP
80999a2dd95SBruce Richardson 
810295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE32_TCP ( \
811295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
81299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE32)
813b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_PRE32_TCP RTE_DEPRECATED(ETH_RSS_IPV6_PRE32_TCP) RTE_ETH_RSS_IPV6_PRE32_TCP
81499a2dd95SBruce Richardson 
815295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE40_TCP ( \
816295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
81799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE40)
818b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_PRE40_TCP RTE_DEPRECATED(ETH_RSS_IPV6_PRE40_TCP) RTE_ETH_RSS_IPV6_PRE40_TCP
81999a2dd95SBruce Richardson 
820295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE48_TCP ( \
821295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
82299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE48)
823b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_PRE48_TCP RTE_DEPRECATED(ETH_RSS_IPV6_PRE48_TCP) RTE_ETH_RSS_IPV6_PRE48_TCP
82499a2dd95SBruce Richardson 
825295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE56_TCP ( \
826295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
82799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE56)
828b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_PRE56_TCP RTE_DEPRECATED(ETH_RSS_IPV6_PRE56_TCP) RTE_ETH_RSS_IPV6_PRE56_TCP
82999a2dd95SBruce Richardson 
830295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE64_TCP ( \
831295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
83299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE64)
833b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_PRE64_TCP RTE_DEPRECATED(ETH_RSS_IPV6_PRE64_TCP) RTE_ETH_RSS_IPV6_PRE64_TCP
83499a2dd95SBruce Richardson 
835295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE96_TCP ( \
836295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
83799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE96)
838b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_PRE96_TCP RTE_DEPRECATED(ETH_RSS_IPV6_PRE96_TCP) RTE_ETH_RSS_IPV6_PRE96_TCP
83999a2dd95SBruce Richardson 
840295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE32_SCTP ( \
841295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
84299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE32)
843b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_PRE32_SCTP RTE_DEPRECATED(ETH_RSS_IPV6_PRE32_SCTP) RTE_ETH_RSS_IPV6_PRE32_SCTP
84499a2dd95SBruce Richardson 
845295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE40_SCTP ( \
846295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
84799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE40)
848b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_PRE40_SCTP RTE_DEPRECATED(ETH_RSS_IPV6_PRE40_SCTP) RTE_ETH_RSS_IPV6_PRE40_SCTP
84999a2dd95SBruce Richardson 
850295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE48_SCTP ( \
851295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
85299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE48)
853b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_PRE48_SCTP RTE_DEPRECATED(ETH_RSS_IPV6_PRE48_SCTP) RTE_ETH_RSS_IPV6_PRE48_SCTP
85499a2dd95SBruce Richardson 
855295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE56_SCTP ( \
856295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
85799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE56)
858b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_PRE56_SCTP RTE_DEPRECATED(ETH_RSS_IPV6_PRE56_SCTP) RTE_ETH_RSS_IPV6_PRE56_SCTP
85999a2dd95SBruce Richardson 
860295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE64_SCTP ( \
861295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
86299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE64)
863b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_PRE64_SCTP RTE_DEPRECATED(ETH_RSS_IPV6_PRE64_SCTP) RTE_ETH_RSS_IPV6_PRE64_SCTP
86499a2dd95SBruce Richardson 
865295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE96_SCTP ( \
866295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
86799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE96)
868b1cb3035SFerruh Yigit #define ETH_RSS_IPV6_PRE96_SCTP RTE_DEPRECATED(ETH_RSS_IPV6_PRE96_SCTP) RTE_ETH_RSS_IPV6_PRE96_SCTP
86999a2dd95SBruce Richardson 
870295968d1SFerruh Yigit #define RTE_ETH_RSS_IP ( \
871295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV4 | \
872295968d1SFerruh Yigit 	RTE_ETH_RSS_FRAG_IPV4 | \
873295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_OTHER | \
874295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6 | \
875295968d1SFerruh Yigit 	RTE_ETH_RSS_FRAG_IPV6 | \
876295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \
877295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6_EX)
878b1cb3035SFerruh Yigit #define ETH_RSS_IP RTE_DEPRECATED(ETH_RSS_IP) RTE_ETH_RSS_IP
87999a2dd95SBruce Richardson 
880295968d1SFerruh Yigit #define RTE_ETH_RSS_UDP ( \
881295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
882295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
883295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6_UDP_EX)
884b1cb3035SFerruh Yigit #define ETH_RSS_UDP RTE_DEPRECATED(ETH_RSS_UDP) RTE_ETH_RSS_UDP
88599a2dd95SBruce Richardson 
886295968d1SFerruh Yigit #define RTE_ETH_RSS_TCP ( \
887295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
888295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
889295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6_TCP_EX)
890b1cb3035SFerruh Yigit #define ETH_RSS_TCP RTE_DEPRECATED(ETH_RSS_TCP) RTE_ETH_RSS_TCP
89199a2dd95SBruce Richardson 
892295968d1SFerruh Yigit #define RTE_ETH_RSS_SCTP ( \
893295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_SCTP | \
894295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_SCTP)
895b1cb3035SFerruh Yigit #define ETH_RSS_SCTP RTE_DEPRECATED(ETH_RSS_SCTP) RTE_ETH_RSS_SCTP
89699a2dd95SBruce Richardson 
897295968d1SFerruh Yigit #define RTE_ETH_RSS_TUNNEL ( \
898295968d1SFerruh Yigit 	RTE_ETH_RSS_VXLAN  | \
899295968d1SFerruh Yigit 	RTE_ETH_RSS_GENEVE | \
900295968d1SFerruh Yigit 	RTE_ETH_RSS_NVGRE)
901b1cb3035SFerruh Yigit #define ETH_RSS_TUNNEL RTE_DEPRECATED(ETH_RSS_TUNNEL) RTE_ETH_RSS_TUNNEL
90299a2dd95SBruce Richardson 
903295968d1SFerruh Yigit #define RTE_ETH_RSS_VLAN ( \
904295968d1SFerruh Yigit 	RTE_ETH_RSS_S_VLAN  | \
905295968d1SFerruh Yigit 	RTE_ETH_RSS_C_VLAN)
906b1cb3035SFerruh Yigit #define ETH_RSS_VLAN RTE_DEPRECATED(ETH_RSS_VLAN) RTE_ETH_RSS_VLAN
90799a2dd95SBruce Richardson 
9083c2ca0a9SAndrew Rybchenko /** Mask of valid RSS hash protocols */
909295968d1SFerruh Yigit #define RTE_ETH_RSS_PROTO_MASK ( \
910295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV4 | \
911295968d1SFerruh Yigit 	RTE_ETH_RSS_FRAG_IPV4 | \
912295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
913295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
914295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_SCTP | \
915295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_OTHER | \
916295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6 | \
917295968d1SFerruh Yigit 	RTE_ETH_RSS_FRAG_IPV6 | \
918295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
919295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
920295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
921295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \
922295968d1SFerruh Yigit 	RTE_ETH_RSS_L2_PAYLOAD | \
923295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6_EX | \
924295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6_TCP_EX | \
925295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6_UDP_EX | \
926295968d1SFerruh Yigit 	RTE_ETH_RSS_PORT  | \
927295968d1SFerruh Yigit 	RTE_ETH_RSS_VXLAN | \
928295968d1SFerruh Yigit 	RTE_ETH_RSS_GENEVE | \
929295968d1SFerruh Yigit 	RTE_ETH_RSS_NVGRE | \
930295968d1SFerruh Yigit 	RTE_ETH_RSS_MPLS)
931b1cb3035SFerruh Yigit #define ETH_RSS_PROTO_MASK RTE_DEPRECATED(ETH_RSS_PROTO_MASK) RTE_ETH_RSS_PROTO_MASK
93299a2dd95SBruce Richardson 
93399a2dd95SBruce Richardson /*
93499a2dd95SBruce Richardson  * Definitions used for redirection table entry size.
93599a2dd95SBruce Richardson  * Some RSS RETA sizes may not be supported by some drivers, check the
93699a2dd95SBruce Richardson  * documentation or the description of relevant functions for more details.
93799a2dd95SBruce Richardson  */
938295968d1SFerruh Yigit #define RTE_ETH_RSS_RETA_SIZE_64  64
939295968d1SFerruh Yigit #define RTE_ETH_RSS_RETA_SIZE_128 128
940295968d1SFerruh Yigit #define RTE_ETH_RSS_RETA_SIZE_256 256
941295968d1SFerruh Yigit #define RTE_ETH_RSS_RETA_SIZE_512 512
942295968d1SFerruh Yigit #define RTE_ETH_RETA_GROUP_SIZE   64
943b1cb3035SFerruh Yigit 
944b1cb3035SFerruh Yigit #define ETH_RSS_RETA_SIZE_64  RTE_DEPRECATED(ETH_RSS_RETA_SIZE_64)  RTE_ETH_RSS_RETA_SIZE_64
945b1cb3035SFerruh Yigit #define ETH_RSS_RETA_SIZE_128 RTE_DEPRECATED(ETH_RSS_RETA_SIZE_128) RTE_ETH_RSS_RETA_SIZE_128
946b1cb3035SFerruh Yigit #define ETH_RSS_RETA_SIZE_256 RTE_DEPRECATED(ETH_RSS_RETA_SIZE_256) RTE_ETH_RSS_RETA_SIZE_256
947b1cb3035SFerruh Yigit #define ETH_RSS_RETA_SIZE_512 RTE_DEPRECATED(ETH_RSS_RETA_SIZE_512) RTE_ETH_RSS_RETA_SIZE_512
948b1cb3035SFerruh Yigit #define RTE_RETA_GROUP_SIZE   RTE_DEPRECATED(RTE_RETA_GROUP_SIZE)   RTE_ETH_RETA_GROUP_SIZE
94999a2dd95SBruce Richardson 
9500ce56b05SThomas Monjalon /**@{@name VMDq and DCB maximums */
951295968d1SFerruh Yigit #define RTE_ETH_VMDQ_MAX_VLAN_FILTERS   64 /**< Maximum nb. of VMDq VLAN filters. */
952295968d1SFerruh Yigit #define RTE_ETH_DCB_NUM_USER_PRIORITIES 8  /**< Maximum nb. of DCB priorities. */
953295968d1SFerruh Yigit #define RTE_ETH_VMDQ_DCB_NUM_QUEUES     128 /**< Maximum nb. of VMDq DCB queues. */
954295968d1SFerruh Yigit #define RTE_ETH_DCB_NUM_QUEUES          128 /**< Maximum nb. of DCB queues. */
9550ce56b05SThomas Monjalon /**@}*/
95699a2dd95SBruce Richardson 
957b1cb3035SFerruh Yigit #define ETH_VMDQ_MAX_VLAN_FILTERS   RTE_DEPRECATED(ETH_VMDQ_MAX_VLAN_FILTERS)   RTE_ETH_VMDQ_MAX_VLAN_FILTERS
958b1cb3035SFerruh Yigit #define ETH_DCB_NUM_USER_PRIORITIES RTE_DEPRECATED(ETH_DCB_NUM_USER_PRIORITIES) RTE_ETH_DCB_NUM_USER_PRIORITIES
959b1cb3035SFerruh Yigit #define ETH_VMDQ_DCB_NUM_QUEUES     RTE_DEPRECATED(ETH_VMDQ_DCB_NUM_QUEUES)     RTE_ETH_VMDQ_DCB_NUM_QUEUES
960b1cb3035SFerruh Yigit #define ETH_DCB_NUM_QUEUES          RTE_DEPRECATED(ETH_DCB_NUM_QUEUES)          RTE_ETH_DCB_NUM_QUEUES
961b1cb3035SFerruh Yigit 
9620ce56b05SThomas Monjalon /**@{@name DCB capabilities */
9634852c647SAndrew Rybchenko #define RTE_ETH_DCB_PG_SUPPORT      RTE_BIT32(0) /**< Priority Group(ETS) support. */
9644852c647SAndrew Rybchenko #define RTE_ETH_DCB_PFC_SUPPORT     RTE_BIT32(1) /**< Priority Flow Control support. */
9650ce56b05SThomas Monjalon /**@}*/
96699a2dd95SBruce Richardson 
967b1cb3035SFerruh Yigit #define ETH_DCB_PG_SUPPORT  RTE_DEPRECATED(ETH_DCB_PG_SUPPORT)  RTE_ETH_DCB_PG_SUPPORT
968b1cb3035SFerruh Yigit #define ETH_DCB_PFC_SUPPORT RTE_DEPRECATED(ETH_DCB_PFC_SUPPORT) RTE_ETH_DCB_PFC_SUPPORT
969b1cb3035SFerruh Yigit 
9700ce56b05SThomas Monjalon /**@{@name VLAN offload bits */
971295968d1SFerruh Yigit #define RTE_ETH_VLAN_STRIP_OFFLOAD   0x0001 /**< VLAN Strip  On/Off */
972295968d1SFerruh Yigit #define RTE_ETH_VLAN_FILTER_OFFLOAD  0x0002 /**< VLAN Filter On/Off */
973295968d1SFerruh Yigit #define RTE_ETH_VLAN_EXTEND_OFFLOAD  0x0004 /**< VLAN Extend On/Off */
974295968d1SFerruh Yigit #define RTE_ETH_QINQ_STRIP_OFFLOAD   0x0008 /**< QINQ Strip On/Off */
975b1cb3035SFerruh Yigit 
976b1cb3035SFerruh Yigit #define ETH_VLAN_STRIP_OFFLOAD  RTE_DEPRECATED(ETH_VLAN_STRIP_OFFLOAD)  RTE_ETH_VLAN_STRIP_OFFLOAD
977b1cb3035SFerruh Yigit #define ETH_VLAN_FILTER_OFFLOAD RTE_DEPRECATED(ETH_VLAN_FILTER_OFFLOAD) RTE_ETH_VLAN_FILTER_OFFLOAD
978b1cb3035SFerruh Yigit #define ETH_VLAN_EXTEND_OFFLOAD RTE_DEPRECATED(ETH_VLAN_EXTEND_OFFLOAD) RTE_ETH_VLAN_EXTEND_OFFLOAD
979b1cb3035SFerruh Yigit #define ETH_QINQ_STRIP_OFFLOAD  RTE_DEPRECATED(ETH_QINQ_STRIP_OFFLOAD)  RTE_ETH_QINQ_STRIP_OFFLOAD
98099a2dd95SBruce Richardson 
981295968d1SFerruh Yigit #define RTE_ETH_VLAN_STRIP_MASK      0x0001 /**< VLAN Strip  setting mask */
982295968d1SFerruh Yigit #define RTE_ETH_VLAN_FILTER_MASK     0x0002 /**< VLAN Filter  setting mask*/
983295968d1SFerruh Yigit #define RTE_ETH_VLAN_EXTEND_MASK     0x0004 /**< VLAN Extend  setting mask*/
984295968d1SFerruh Yigit #define RTE_ETH_QINQ_STRIP_MASK      0x0008 /**< QINQ Strip  setting mask */
985295968d1SFerruh Yigit #define RTE_ETH_VLAN_ID_MAX          0x0FFF /**< VLAN ID is in lower 12 bits*/
9860ce56b05SThomas Monjalon /**@}*/
98799a2dd95SBruce Richardson 
988b1cb3035SFerruh Yigit #define ETH_VLAN_STRIP_MASK  RTE_DEPRECATED(ETH_VLAN_STRIP_MASK)  RTE_ETH_VLAN_STRIP_MASK
989b1cb3035SFerruh Yigit #define ETH_VLAN_FILTER_MASK RTE_DEPRECATED(ETH_VLAN_FILTER_MASK) RTE_ETH_VLAN_FILTER_MASK
990b1cb3035SFerruh Yigit #define ETH_VLAN_EXTEND_MASK RTE_DEPRECATED(ETH_VLAN_EXTEND_MASK) RTE_ETH_VLAN_EXTEND_MASK
991b1cb3035SFerruh Yigit #define ETH_QINQ_STRIP_MASK  RTE_DEPRECATED(ETH_QINQ_STRIP_MASK)  RTE_ETH_QINQ_STRIP_MASK
992b1cb3035SFerruh Yigit #define ETH_VLAN_ID_MAX      RTE_DEPRECATED(ETH_VLAN_ID_MAX)      RTE_ETH_VLAN_ID_MAX
993b1cb3035SFerruh Yigit 
99499a2dd95SBruce Richardson /* Definitions used for receive MAC address   */
995295968d1SFerruh Yigit #define RTE_ETH_NUM_RECEIVE_MAC_ADDR   128 /**< Maximum nb. of receive mac addr. */
996b1cb3035SFerruh Yigit #define ETH_NUM_RECEIVE_MAC_ADDR RTE_DEPRECATED(ETH_NUM_RECEIVE_MAC_ADDR) RTE_ETH_NUM_RECEIVE_MAC_ADDR
99799a2dd95SBruce Richardson 
99899a2dd95SBruce Richardson /* Definitions used for unicast hash  */
999295968d1SFerruh Yigit #define RTE_ETH_VMDQ_NUM_UC_HASH_ARRAY 128 /**< Maximum nb. of UC hash array. */
1000b1cb3035SFerruh Yigit #define ETH_VMDQ_NUM_UC_HASH_ARRAY RTE_DEPRECATED(ETH_VMDQ_NUM_UC_HASH_ARRAY) RTE_ETH_VMDQ_NUM_UC_HASH_ARRAY
100199a2dd95SBruce Richardson 
10020ce56b05SThomas Monjalon /**@{@name VMDq Rx mode
10030ce56b05SThomas Monjalon  * @see rte_eth_vmdq_rx_conf.rx_mode
10040ce56b05SThomas Monjalon  */
10054852c647SAndrew Rybchenko /** Accept untagged packets. */
10064852c647SAndrew Rybchenko #define RTE_ETH_VMDQ_ACCEPT_UNTAG      RTE_BIT32(0)
10074852c647SAndrew Rybchenko /** Accept packets in multicast table. */
10084852c647SAndrew Rybchenko #define RTE_ETH_VMDQ_ACCEPT_HASH_MC    RTE_BIT32(1)
10094852c647SAndrew Rybchenko /** Accept packets in unicast table. */
10104852c647SAndrew Rybchenko #define RTE_ETH_VMDQ_ACCEPT_HASH_UC    RTE_BIT32(2)
10114852c647SAndrew Rybchenko /** Accept broadcast packets. */
10124852c647SAndrew Rybchenko #define RTE_ETH_VMDQ_ACCEPT_BROADCAST  RTE_BIT32(3)
10134852c647SAndrew Rybchenko /** Multicast promiscuous. */
10144852c647SAndrew Rybchenko #define RTE_ETH_VMDQ_ACCEPT_MULTICAST  RTE_BIT32(4)
10150ce56b05SThomas Monjalon /**@}*/
101699a2dd95SBruce Richardson 
1017b1cb3035SFerruh Yigit #define ETH_VMDQ_ACCEPT_UNTAG     RTE_DEPRECATED(ETH_VMDQ_ACCEPT_UNTAG)     RTE_ETH_VMDQ_ACCEPT_UNTAG
1018b1cb3035SFerruh Yigit #define ETH_VMDQ_ACCEPT_HASH_MC   RTE_DEPRECATED(ETH_VMDQ_ACCEPT_HASH_MC)   RTE_ETH_VMDQ_ACCEPT_HASH_MC
1019b1cb3035SFerruh Yigit #define ETH_VMDQ_ACCEPT_HASH_UC   RTE_DEPRECATED(ETH_VMDQ_ACCEPT_HASH_UC)   RTE_ETH_VMDQ_ACCEPT_HASH_UC
1020b1cb3035SFerruh Yigit #define ETH_VMDQ_ACCEPT_BROADCAST RTE_DEPRECATED(ETH_VMDQ_ACCEPT_BROADCAST) RTE_ETH_VMDQ_ACCEPT_BROADCAST
1021b1cb3035SFerruh Yigit #define ETH_VMDQ_ACCEPT_MULTICAST RTE_DEPRECATED(ETH_VMDQ_ACCEPT_MULTICAST) RTE_ETH_VMDQ_ACCEPT_MULTICAST
1022b1cb3035SFerruh Yigit 
102399a2dd95SBruce Richardson /**
102499a2dd95SBruce Richardson  * A structure used to configure 64 entries of Redirection Table of the
102599a2dd95SBruce Richardson  * Receive Side Scaling (RSS) feature of an Ethernet port. To configure
102699a2dd95SBruce Richardson  * more than 64 entries supported by hardware, an array of this structure
102799a2dd95SBruce Richardson  * is needed.
102899a2dd95SBruce Richardson  */
102999a2dd95SBruce Richardson struct rte_eth_rss_reta_entry64 {
10303c2ca0a9SAndrew Rybchenko 	/** Mask bits indicate which entries need to be updated/queried. */
103199a2dd95SBruce Richardson 	uint64_t mask;
10323c2ca0a9SAndrew Rybchenko 	/** Group of 64 redirection table entries. */
1033295968d1SFerruh Yigit 	uint16_t reta[RTE_ETH_RETA_GROUP_SIZE];
103499a2dd95SBruce Richardson };
103599a2dd95SBruce Richardson 
103699a2dd95SBruce Richardson /**
103799a2dd95SBruce Richardson  * This enum indicates the possible number of traffic classes
103899a2dd95SBruce Richardson  * in DCB configurations
103999a2dd95SBruce Richardson  */
104099a2dd95SBruce Richardson enum rte_eth_nb_tcs {
1041295968d1SFerruh Yigit 	RTE_ETH_4_TCS = 4, /**< 4 TCs with DCB. */
1042295968d1SFerruh Yigit 	RTE_ETH_8_TCS = 8  /**< 8 TCs with DCB. */
104399a2dd95SBruce Richardson };
1044b1cb3035SFerruh Yigit #define ETH_4_TCS RTE_DEPRECATED(ETH_4_TCS) RTE_ETH_4_TCS
1045b1cb3035SFerruh Yigit #define ETH_8_TCS RTE_DEPRECATED(ETH_8_TCS) RTE_ETH_8_TCS
104699a2dd95SBruce Richardson 
104799a2dd95SBruce Richardson /**
104899a2dd95SBruce Richardson  * This enum indicates the possible number of queue pools
1049064e90c4SAndrew Rybchenko  * in VMDq configurations.
105099a2dd95SBruce Richardson  */
105199a2dd95SBruce Richardson enum rte_eth_nb_pools {
1052295968d1SFerruh Yigit 	RTE_ETH_8_POOLS = 8,    /**< 8 VMDq pools. */
1053295968d1SFerruh Yigit 	RTE_ETH_16_POOLS = 16,  /**< 16 VMDq pools. */
1054295968d1SFerruh Yigit 	RTE_ETH_32_POOLS = 32,  /**< 32 VMDq pools. */
1055295968d1SFerruh Yigit 	RTE_ETH_64_POOLS = 64   /**< 64 VMDq pools. */
105699a2dd95SBruce Richardson };
1057b1cb3035SFerruh Yigit #define ETH_8_POOLS  RTE_DEPRECATED(ETH_8_POOLS)  RTE_ETH_8_POOLS
1058b1cb3035SFerruh Yigit #define ETH_16_POOLS RTE_DEPRECATED(ETH_16_POOLS) RTE_ETH_16_POOLS
1059b1cb3035SFerruh Yigit #define ETH_32_POOLS RTE_DEPRECATED(ETH_32_POOLS) RTE_ETH_32_POOLS
1060b1cb3035SFerruh Yigit #define ETH_64_POOLS RTE_DEPRECATED(ETH_64_POOLS) RTE_ETH_64_POOLS
106199a2dd95SBruce Richardson 
106299a2dd95SBruce Richardson /* This structure may be extended in future. */
106399a2dd95SBruce Richardson struct rte_eth_dcb_rx_conf {
106499a2dd95SBruce Richardson 	enum rte_eth_nb_tcs nb_tcs; /**< Possible DCB TCs, 4 or 8 TCs */
106599a2dd95SBruce Richardson 	/** Traffic class each UP mapped to. */
1066295968d1SFerruh Yigit 	uint8_t dcb_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES];
106799a2dd95SBruce Richardson };
106899a2dd95SBruce Richardson 
106999a2dd95SBruce Richardson struct rte_eth_vmdq_dcb_tx_conf {
107099a2dd95SBruce Richardson 	enum rte_eth_nb_pools nb_queue_pools; /**< With DCB, 16 or 32 pools. */
107199a2dd95SBruce Richardson 	/** Traffic class each UP mapped to. */
1072295968d1SFerruh Yigit 	uint8_t dcb_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES];
107399a2dd95SBruce Richardson };
107499a2dd95SBruce Richardson 
107599a2dd95SBruce Richardson struct rte_eth_dcb_tx_conf {
107699a2dd95SBruce Richardson 	enum rte_eth_nb_tcs nb_tcs; /**< Possible DCB TCs, 4 or 8 TCs. */
107799a2dd95SBruce Richardson 	/** Traffic class each UP mapped to. */
1078295968d1SFerruh Yigit 	uint8_t dcb_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES];
107999a2dd95SBruce Richardson };
108099a2dd95SBruce Richardson 
108199a2dd95SBruce Richardson struct rte_eth_vmdq_tx_conf {
108299a2dd95SBruce Richardson 	enum rte_eth_nb_pools nb_queue_pools; /**< VMDq mode, 64 pools. */
108399a2dd95SBruce Richardson };
108499a2dd95SBruce Richardson 
108599a2dd95SBruce Richardson /**
1086064e90c4SAndrew Rybchenko  * A structure used to configure the VMDq+DCB feature
108799a2dd95SBruce Richardson  * of an Ethernet port.
108899a2dd95SBruce Richardson  *
108999a2dd95SBruce Richardson  * Using this feature, packets are routed to a pool of queues, based
10905b49ba65SAndrew Rybchenko  * on the VLAN ID in the VLAN tag, and then to a specific queue within
10915b49ba65SAndrew Rybchenko  * that pool, using the user priority VLAN tag field.
109299a2dd95SBruce Richardson  *
109399a2dd95SBruce Richardson  * A default pool may be used, if desired, to route all traffic which
10945b49ba65SAndrew Rybchenko  * does not match the VLAN filter rules.
109599a2dd95SBruce Richardson  */
109699a2dd95SBruce Richardson struct rte_eth_vmdq_dcb_conf {
109799a2dd95SBruce Richardson 	enum rte_eth_nb_pools nb_queue_pools; /**< With DCB, 16 or 32 pools */
109899a2dd95SBruce Richardson 	uint8_t enable_default_pool; /**< If non-zero, use a default pool */
109999a2dd95SBruce Richardson 	uint8_t default_pool; /**< The default pool, if applicable */
110099a2dd95SBruce Richardson 	uint8_t nb_pool_maps; /**< We can have up to 64 filters/mappings */
110199a2dd95SBruce Richardson 	struct {
11025b49ba65SAndrew Rybchenko 		uint16_t vlan_id; /**< The VLAN ID of the received frame */
110309fd4227SAndrew Rybchenko 		uint64_t pools;   /**< Bitmask of pools for packet Rx */
1104295968d1SFerruh Yigit 	} pool_map[RTE_ETH_VMDQ_MAX_VLAN_FILTERS]; /**< VMDq VLAN pool maps. */
11053c2ca0a9SAndrew Rybchenko 	/** Selects a queue in a pool */
1106295968d1SFerruh Yigit 	uint8_t dcb_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES];
110799a2dd95SBruce Richardson };
110899a2dd95SBruce Richardson 
110999a2dd95SBruce Richardson /**
1110064e90c4SAndrew Rybchenko  * A structure used to configure the VMDq feature of an Ethernet port when
111199a2dd95SBruce Richardson  * not combined with the DCB feature.
111299a2dd95SBruce Richardson  *
111399a2dd95SBruce Richardson  * Using this feature, packets are routed to a pool of queues. By default,
11145b49ba65SAndrew Rybchenko  * the pool selection is based on the MAC address, the VLAN ID in the
11155b49ba65SAndrew Rybchenko  * VLAN tag as specified in the pool_map array.
1116295968d1SFerruh Yigit  * Passing the RTE_ETH_VMDQ_ACCEPT_UNTAG in the rx_mode field allows pool
111799a2dd95SBruce Richardson  * selection using only the MAC address. MAC address to pool mapping is done
111899a2dd95SBruce Richardson  * using the rte_eth_dev_mac_addr_add function, with the pool parameter
11195906be5aSAndrew Rybchenko  * corresponding to the pool ID.
112099a2dd95SBruce Richardson  *
112199a2dd95SBruce Richardson  * Queue selection within the selected pool will be done using RSS when
112299a2dd95SBruce Richardson  * it is enabled or revert to the first queue of the pool if not.
112399a2dd95SBruce Richardson  *
112499a2dd95SBruce Richardson  * A default pool may be used, if desired, to route all traffic which
11255b49ba65SAndrew Rybchenko  * does not match the VLAN filter rules or any pool MAC address.
112699a2dd95SBruce Richardson  */
112799a2dd95SBruce Richardson struct rte_eth_vmdq_rx_conf {
112899a2dd95SBruce Richardson 	enum rte_eth_nb_pools nb_queue_pools; /**< VMDq only mode, 8 or 64 pools */
112999a2dd95SBruce Richardson 	uint8_t enable_default_pool; /**< If non-zero, use a default pool */
113099a2dd95SBruce Richardson 	uint8_t default_pool; /**< The default pool, if applicable */
113199a2dd95SBruce Richardson 	uint8_t enable_loop_back; /**< Enable VT loop back */
113299a2dd95SBruce Richardson 	uint8_t nb_pool_maps; /**< We can have up to 64 filters/mappings */
113399a2dd95SBruce Richardson 	uint32_t rx_mode; /**< Flags from ETH_VMDQ_ACCEPT_* */
113499a2dd95SBruce Richardson 	struct {
11355b49ba65SAndrew Rybchenko 		uint16_t vlan_id; /**< The VLAN ID of the received frame */
113609fd4227SAndrew Rybchenko 		uint64_t pools;   /**< Bitmask of pools for packet Rx */
1137295968d1SFerruh Yigit 	} pool_map[RTE_ETH_VMDQ_MAX_VLAN_FILTERS]; /**< VMDq VLAN pool maps. */
113899a2dd95SBruce Richardson };
113999a2dd95SBruce Richardson 
114099a2dd95SBruce Richardson /**
114109fd4227SAndrew Rybchenko  * A structure used to configure the Tx features of an Ethernet port.
114299a2dd95SBruce Richardson  */
114399a2dd95SBruce Richardson struct rte_eth_txmode {
114409fd4227SAndrew Rybchenko 	enum rte_eth_tx_mq_mode mq_mode; /**< Tx multi-queues mode. */
114599a2dd95SBruce Richardson 	/**
1146295968d1SFerruh Yigit 	 * Per-port Tx offloads to be set using RTE_ETH_TX_OFFLOAD_* flags.
114799a2dd95SBruce Richardson 	 * Only offloads set on tx_offload_capa field on rte_eth_dev_info
114899a2dd95SBruce Richardson 	 * structure are allowed to be set.
114999a2dd95SBruce Richardson 	 */
115099a2dd95SBruce Richardson 	uint64_t offloads;
115199a2dd95SBruce Richardson 
115299a2dd95SBruce Richardson 	uint16_t pvid;
115399a2dd95SBruce Richardson 	__extension__
11543c2ca0a9SAndrew Rybchenko 	uint8_t /** If set, reject sending out tagged pkts */
11553c2ca0a9SAndrew Rybchenko 		hw_vlan_reject_tagged : 1,
11563c2ca0a9SAndrew Rybchenko 		/** If set, reject sending out untagged pkts */
115799a2dd95SBruce Richardson 		hw_vlan_reject_untagged : 1,
11583c2ca0a9SAndrew Rybchenko 		/** If set, enable port based VLAN insertion */
115999a2dd95SBruce Richardson 		hw_vlan_insert_pvid : 1;
116099a2dd95SBruce Richardson 
116199a2dd95SBruce Richardson 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
116299a2dd95SBruce Richardson 	void *reserved_ptrs[2];   /**< Reserved for future fields */
116399a2dd95SBruce Richardson };
116499a2dd95SBruce Richardson 
116599a2dd95SBruce Richardson /**
116699a2dd95SBruce Richardson  * @warning
116799a2dd95SBruce Richardson  * @b EXPERIMENTAL: this structure may change without prior notice.
116899a2dd95SBruce Richardson  *
116999a2dd95SBruce Richardson  * A structure used to configure an Rx packet segment to split.
117099a2dd95SBruce Richardson  *
117199a2dd95SBruce Richardson  * If RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag is set in offloads field,
117299a2dd95SBruce Richardson  * the PMD will split the received packets into multiple segments
117399a2dd95SBruce Richardson  * according to the specification in the description array:
117499a2dd95SBruce Richardson  *
117599a2dd95SBruce Richardson  * - The first network buffer will be allocated from the memory pool,
117699a2dd95SBruce Richardson  *   specified in the first array element, the second buffer, from the
117799a2dd95SBruce Richardson  *   pool in the second element, and so on.
117899a2dd95SBruce Richardson  *
117999a2dd95SBruce Richardson  * - The offsets from the segment description elements specify
118099a2dd95SBruce Richardson  *   the data offset from the buffer beginning except the first mbuf.
118199a2dd95SBruce Richardson  *   The first segment offset is added with RTE_PKTMBUF_HEADROOM.
118299a2dd95SBruce Richardson  *
118399a2dd95SBruce Richardson  * - The lengths in the elements define the maximal data amount
118499a2dd95SBruce Richardson  *   being received to each segment. The receiving starts with filling
118599a2dd95SBruce Richardson  *   up the first mbuf data buffer up to specified length. If the
118699a2dd95SBruce Richardson  *   there are data remaining (packet is longer than buffer in the first
118799a2dd95SBruce Richardson  *   mbuf) the following data will be pushed to the next segment
118899a2dd95SBruce Richardson  *   up to its own length, and so on.
118999a2dd95SBruce Richardson  *
119099a2dd95SBruce Richardson  * - If the length in the segment description element is zero
119199a2dd95SBruce Richardson  *   the actual buffer size will be deduced from the appropriate
119299a2dd95SBruce Richardson  *   memory pool properties.
119399a2dd95SBruce Richardson  *
119499a2dd95SBruce Richardson  * - If there is not enough elements to describe the buffer for entire
119599a2dd95SBruce Richardson  *   packet of maximal length the following parameters will be used
119699a2dd95SBruce Richardson  *   for the all remaining segments:
119799a2dd95SBruce Richardson  *     - pool from the last valid element
119899a2dd95SBruce Richardson  *     - the buffer size from this pool
119999a2dd95SBruce Richardson  *     - zero offset
120099a2dd95SBruce Richardson  */
120199a2dd95SBruce Richardson struct rte_eth_rxseg_split {
120299a2dd95SBruce Richardson 	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
120399a2dd95SBruce Richardson 	uint16_t length; /**< Segment data length, configures split point. */
120499a2dd95SBruce Richardson 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
120599a2dd95SBruce Richardson 	uint32_t reserved; /**< Reserved field. */
120699a2dd95SBruce Richardson };
120799a2dd95SBruce Richardson 
120899a2dd95SBruce Richardson /**
120999a2dd95SBruce Richardson  * @warning
121099a2dd95SBruce Richardson  * @b EXPERIMENTAL: this structure may change without prior notice.
121199a2dd95SBruce Richardson  *
121299a2dd95SBruce Richardson  * A common structure used to describe Rx packet segment properties.
121399a2dd95SBruce Richardson  */
121499a2dd95SBruce Richardson union rte_eth_rxseg {
121599a2dd95SBruce Richardson 	/* The settings for buffer split offload. */
121699a2dd95SBruce Richardson 	struct rte_eth_rxseg_split split;
121799a2dd95SBruce Richardson 	/* The other features settings should be added here. */
121899a2dd95SBruce Richardson };
121999a2dd95SBruce Richardson 
122099a2dd95SBruce Richardson /**
122109fd4227SAndrew Rybchenko  * A structure used to configure an Rx ring of an Ethernet port.
122299a2dd95SBruce Richardson  */
122399a2dd95SBruce Richardson struct rte_eth_rxconf {
122409fd4227SAndrew Rybchenko 	struct rte_eth_thresh rx_thresh; /**< Rx ring threshold registers. */
122509fd4227SAndrew Rybchenko 	uint16_t rx_free_thresh; /**< Drives the freeing of Rx descriptors. */
122699a2dd95SBruce Richardson 	uint8_t rx_drop_en; /**< Drop packets if no descriptors are available. */
122799a2dd95SBruce Richardson 	uint8_t rx_deferred_start; /**< Do not start queue with rte_eth_dev_start(). */
122899a2dd95SBruce Richardson 	uint16_t rx_nseg; /**< Number of descriptions in rx_seg array. */
122999a2dd95SBruce Richardson 	/**
1230dd22740cSXueming Li 	 * Share group index in Rx domain and switch domain.
1231dd22740cSXueming Li 	 * Non-zero value to enable Rx queue share, zero value disable share.
1232dd22740cSXueming Li 	 * PMD is responsible for Rx queue consistency checks to avoid member
1233dd22740cSXueming Li 	 * port's configuration contradict to each other.
1234dd22740cSXueming Li 	 */
1235dd22740cSXueming Li 	uint16_t share_group;
1236dd22740cSXueming Li 	uint16_t share_qid; /**< Shared Rx queue ID in group */
1237dd22740cSXueming Li 	/**
1238295968d1SFerruh Yigit 	 * Per-queue Rx offloads to be set using RTE_ETH_RX_OFFLOAD_* flags.
123999a2dd95SBruce Richardson 	 * Only offloads set on rx_queue_offload_capa or rx_offload_capa
124099a2dd95SBruce Richardson 	 * fields on rte_eth_dev_info structure are allowed to be set.
124199a2dd95SBruce Richardson 	 */
124299a2dd95SBruce Richardson 	uint64_t offloads;
124399a2dd95SBruce Richardson 	/**
124499a2dd95SBruce Richardson 	 * Points to the array of segment descriptions for an entire packet.
124599a2dd95SBruce Richardson 	 * Array elements are properties for consecutive Rx segments.
124699a2dd95SBruce Richardson 	 *
124799a2dd95SBruce Richardson 	 * The supported capabilities of receiving segmentation is reported
124899a2dd95SBruce Richardson 	 * in rte_eth_dev_info.rx_seg_capa field.
124999a2dd95SBruce Richardson 	 */
125099a2dd95SBruce Richardson 	union rte_eth_rxseg *rx_seg;
125199a2dd95SBruce Richardson 
125299a2dd95SBruce Richardson 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
125399a2dd95SBruce Richardson 	void *reserved_ptrs[2];   /**< Reserved for future fields */
125499a2dd95SBruce Richardson };
125599a2dd95SBruce Richardson 
125699a2dd95SBruce Richardson /**
125709fd4227SAndrew Rybchenko  * A structure used to configure a Tx ring of an Ethernet port.
125899a2dd95SBruce Richardson  */
125999a2dd95SBruce Richardson struct rte_eth_txconf {
126009fd4227SAndrew Rybchenko 	struct rte_eth_thresh tx_thresh; /**< Tx ring threshold registers. */
126199a2dd95SBruce Richardson 	uint16_t tx_rs_thresh; /**< Drives the setting of RS bit on TXDs. */
126209fd4227SAndrew Rybchenko 	uint16_t tx_free_thresh; /**< Start freeing Tx buffers if there are
126399a2dd95SBruce Richardson 				      less free descriptors than this value. */
126499a2dd95SBruce Richardson 
126599a2dd95SBruce Richardson 	uint8_t tx_deferred_start; /**< Do not start queue with rte_eth_dev_start(). */
126699a2dd95SBruce Richardson 	/**
1267295968d1SFerruh Yigit 	 * Per-queue Tx offloads to be set  using RTE_ETH_TX_OFFLOAD_* flags.
126899a2dd95SBruce Richardson 	 * Only offloads set on tx_queue_offload_capa or tx_offload_capa
126999a2dd95SBruce Richardson 	 * fields on rte_eth_dev_info structure are allowed to be set.
127099a2dd95SBruce Richardson 	 */
127199a2dd95SBruce Richardson 	uint64_t offloads;
127299a2dd95SBruce Richardson 
127399a2dd95SBruce Richardson 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
127499a2dd95SBruce Richardson 	void *reserved_ptrs[2];   /**< Reserved for future fields */
127599a2dd95SBruce Richardson };
127699a2dd95SBruce Richardson 
127799a2dd95SBruce Richardson /**
127899a2dd95SBruce Richardson  * @warning
127999a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
128099a2dd95SBruce Richardson  *
128199a2dd95SBruce Richardson  * A structure used to return the hairpin capabilities that are supported.
128299a2dd95SBruce Richardson  */
128399a2dd95SBruce Richardson struct rte_eth_hairpin_cap {
128499a2dd95SBruce Richardson 	/** The max number of hairpin queues (different bindings). */
128599a2dd95SBruce Richardson 	uint16_t max_nb_queues;
128699a2dd95SBruce Richardson 	/** Max number of Rx queues to be connected to one Tx queue. */
128799a2dd95SBruce Richardson 	uint16_t max_rx_2_tx;
128899a2dd95SBruce Richardson 	/** Max number of Tx queues to be connected to one Rx queue. */
128999a2dd95SBruce Richardson 	uint16_t max_tx_2_rx;
129099a2dd95SBruce Richardson 	uint16_t max_nb_desc; /**< The max num of descriptors. */
129199a2dd95SBruce Richardson };
129299a2dd95SBruce Richardson 
129399a2dd95SBruce Richardson #define RTE_ETH_MAX_HAIRPIN_PEERS 32
129499a2dd95SBruce Richardson 
129599a2dd95SBruce Richardson /**
129699a2dd95SBruce Richardson  * @warning
129799a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
129899a2dd95SBruce Richardson  *
129999a2dd95SBruce Richardson  * A structure used to hold hairpin peer data.
130099a2dd95SBruce Richardson  */
130199a2dd95SBruce Richardson struct rte_eth_hairpin_peer {
130299a2dd95SBruce Richardson 	uint16_t port; /**< Peer port. */
130399a2dd95SBruce Richardson 	uint16_t queue; /**< Peer queue. */
130499a2dd95SBruce Richardson };
130599a2dd95SBruce Richardson 
130699a2dd95SBruce Richardson /**
130799a2dd95SBruce Richardson  * @warning
130899a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
130999a2dd95SBruce Richardson  *
131099a2dd95SBruce Richardson  * A structure used to configure hairpin binding.
131199a2dd95SBruce Richardson  */
131299a2dd95SBruce Richardson struct rte_eth_hairpin_conf {
131399a2dd95SBruce Richardson 	uint32_t peer_count:16; /**< The number of peers. */
131499a2dd95SBruce Richardson 
131599a2dd95SBruce Richardson 	/**
131699a2dd95SBruce Richardson 	 * Explicit Tx flow rule mode.
131799a2dd95SBruce Richardson 	 * One hairpin pair of queues should have the same attribute.
131899a2dd95SBruce Richardson 	 *
131999a2dd95SBruce Richardson 	 * - When set, the user should be responsible for inserting the hairpin
132099a2dd95SBruce Richardson 	 *   Tx part flows and removing them.
132199a2dd95SBruce Richardson 	 * - When clear, the PMD will try to handle the Tx part of the flows,
132299a2dd95SBruce Richardson 	 *   e.g., by splitting one flow into two parts.
132399a2dd95SBruce Richardson 	 */
132499a2dd95SBruce Richardson 	uint32_t tx_explicit:1;
132599a2dd95SBruce Richardson 
132699a2dd95SBruce Richardson 	/**
132799a2dd95SBruce Richardson 	 * Manually bind hairpin queues.
132899a2dd95SBruce Richardson 	 * One hairpin pair of queues should have the same attribute.
132999a2dd95SBruce Richardson 	 *
133099a2dd95SBruce Richardson 	 * - When set, to enable hairpin, the user should call the hairpin bind
133199a2dd95SBruce Richardson 	 *   function after all the queues are set up properly and the ports are
133299a2dd95SBruce Richardson 	 *   started. Also, the hairpin unbind function should be called
133399a2dd95SBruce Richardson 	 *   accordingly before stopping a port that with hairpin configured.
133499a2dd95SBruce Richardson 	 * - When clear, the PMD will try to enable the hairpin with the queues
133599a2dd95SBruce Richardson 	 *   configured automatically during port start.
133699a2dd95SBruce Richardson 	 */
133799a2dd95SBruce Richardson 	uint32_t manual_bind:1;
133899a2dd95SBruce Richardson 	uint32_t reserved:14; /**< Reserved bits. */
133999a2dd95SBruce Richardson 	struct rte_eth_hairpin_peer peers[RTE_ETH_MAX_HAIRPIN_PEERS];
134099a2dd95SBruce Richardson };
134199a2dd95SBruce Richardson 
134299a2dd95SBruce Richardson /**
134399a2dd95SBruce Richardson  * A structure contains information about HW descriptor ring limitations.
134499a2dd95SBruce Richardson  */
134599a2dd95SBruce Richardson struct rte_eth_desc_lim {
134699a2dd95SBruce Richardson 	uint16_t nb_max;   /**< Max allowed number of descriptors. */
134799a2dd95SBruce Richardson 	uint16_t nb_min;   /**< Min allowed number of descriptors. */
134899a2dd95SBruce Richardson 	uint16_t nb_align; /**< Number of descriptors should be aligned to. */
134999a2dd95SBruce Richardson 
135099a2dd95SBruce Richardson 	/**
135199a2dd95SBruce Richardson 	 * Max allowed number of segments per whole packet.
135299a2dd95SBruce Richardson 	 *
135399a2dd95SBruce Richardson 	 * - For TSO packet this is the total number of data descriptors allowed
135499a2dd95SBruce Richardson 	 *   by device.
135599a2dd95SBruce Richardson 	 *
135699a2dd95SBruce Richardson 	 * @see nb_mtu_seg_max
135799a2dd95SBruce Richardson 	 */
135899a2dd95SBruce Richardson 	uint16_t nb_seg_max;
135999a2dd95SBruce Richardson 
136099a2dd95SBruce Richardson 	/**
136199a2dd95SBruce Richardson 	 * Max number of segments per one MTU.
136299a2dd95SBruce Richardson 	 *
136399a2dd95SBruce Richardson 	 * - For non-TSO packet, this is the maximum allowed number of segments
136499a2dd95SBruce Richardson 	 *   in a single transmit packet.
136599a2dd95SBruce Richardson 	 *
136699a2dd95SBruce Richardson 	 * - For TSO packet each segment within the TSO may span up to this
136799a2dd95SBruce Richardson 	 *   value.
136899a2dd95SBruce Richardson 	 *
136999a2dd95SBruce Richardson 	 * @see nb_seg_max
137099a2dd95SBruce Richardson 	 */
137199a2dd95SBruce Richardson 	uint16_t nb_mtu_seg_max;
137299a2dd95SBruce Richardson };
137399a2dd95SBruce Richardson 
137499a2dd95SBruce Richardson /**
137599a2dd95SBruce Richardson  * This enum indicates the flow control mode
137699a2dd95SBruce Richardson  */
137799a2dd95SBruce Richardson enum rte_eth_fc_mode {
1378295968d1SFerruh Yigit 	RTE_ETH_FC_NONE = 0, /**< Disable flow control. */
1379295968d1SFerruh Yigit 	RTE_ETH_FC_RX_PAUSE, /**< Rx pause frame, enable flowctrl on Tx side. */
1380295968d1SFerruh Yigit 	RTE_ETH_FC_TX_PAUSE, /**< Tx pause frame, enable flowctrl on Rx side. */
1381295968d1SFerruh Yigit 	RTE_ETH_FC_FULL      /**< Enable flow control on both side. */
138299a2dd95SBruce Richardson };
1383b1cb3035SFerruh Yigit #define RTE_FC_NONE     RTE_DEPRECATED(RTE_FC_NONE)     RTE_ETH_FC_NONE
1384b1cb3035SFerruh Yigit #define RTE_FC_RX_PAUSE RTE_DEPRECATED(RTE_FC_RX_PAUSE) RTE_ETH_FC_RX_PAUSE
1385b1cb3035SFerruh Yigit #define RTE_FC_TX_PAUSE RTE_DEPRECATED(RTE_FC_TX_PAUSE) RTE_ETH_FC_TX_PAUSE
1386b1cb3035SFerruh Yigit #define RTE_FC_FULL     RTE_DEPRECATED(RTE_FC_FULL)     RTE_ETH_FC_FULL
1387295968d1SFerruh Yigit 
138899a2dd95SBruce Richardson /**
138999a2dd95SBruce Richardson  * A structure used to configure Ethernet flow control parameter.
139099a2dd95SBruce Richardson  * These parameters will be configured into the register of the NIC.
139199a2dd95SBruce Richardson  * Please refer to the corresponding data sheet for proper value.
139299a2dd95SBruce Richardson  */
139399a2dd95SBruce Richardson struct rte_eth_fc_conf {
139499a2dd95SBruce Richardson 	uint32_t high_water;  /**< High threshold value to trigger XOFF */
139599a2dd95SBruce Richardson 	uint32_t low_water;   /**< Low threshold value to trigger XON */
139699a2dd95SBruce Richardson 	uint16_t pause_time;  /**< Pause quota in the Pause frame */
139799a2dd95SBruce Richardson 	uint16_t send_xon;    /**< Is XON frame need be sent */
139899a2dd95SBruce Richardson 	enum rte_eth_fc_mode mode;  /**< Link flow control mode */
139999a2dd95SBruce Richardson 	uint8_t mac_ctrl_frame_fwd; /**< Forward MAC control frames */
140099a2dd95SBruce Richardson 	uint8_t autoneg;      /**< Use Pause autoneg */
140199a2dd95SBruce Richardson };
140299a2dd95SBruce Richardson 
140399a2dd95SBruce Richardson /**
140499a2dd95SBruce Richardson  * A structure used to configure Ethernet priority flow control parameter.
140599a2dd95SBruce Richardson  * These parameters will be configured into the register of the NIC.
140699a2dd95SBruce Richardson  * Please refer to the corresponding data sheet for proper value.
140799a2dd95SBruce Richardson  */
140899a2dd95SBruce Richardson struct rte_eth_pfc_conf {
140999a2dd95SBruce Richardson 	struct rte_eth_fc_conf fc; /**< General flow control parameter. */
141099a2dd95SBruce Richardson 	uint8_t priority;          /**< VLAN User Priority. */
141199a2dd95SBruce Richardson };
141299a2dd95SBruce Richardson 
141399a2dd95SBruce Richardson /**
14140de345e9SJerin Jacob  * @warning
14150de345e9SJerin Jacob  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
14160de345e9SJerin Jacob  *
14170de345e9SJerin Jacob  * A structure used to retrieve information of queue based PFC.
14180de345e9SJerin Jacob  */
14190de345e9SJerin Jacob struct rte_eth_pfc_queue_info {
14200de345e9SJerin Jacob 	/**
14210de345e9SJerin Jacob 	 * Maximum supported traffic class as per PFC (802.1Qbb) specification.
14220de345e9SJerin Jacob 	 */
14230de345e9SJerin Jacob 	uint8_t tc_max;
14240de345e9SJerin Jacob 	/** PFC queue mode capabilities. */
14250de345e9SJerin Jacob 	enum rte_eth_fc_mode mode_capa;
14260de345e9SJerin Jacob };
14270de345e9SJerin Jacob 
14280de345e9SJerin Jacob /**
14290de345e9SJerin Jacob  * @warning
14300de345e9SJerin Jacob  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
14310de345e9SJerin Jacob  *
14320de345e9SJerin Jacob  * A structure used to configure Ethernet priority flow control parameters for
14330de345e9SJerin Jacob  * ethdev queues.
14340de345e9SJerin Jacob  *
14350de345e9SJerin Jacob  * rte_eth_pfc_queue_conf::rx_pause structure shall be used to configure given
14360de345e9SJerin Jacob  * tx_qid with corresponding tc. When ethdev device receives PFC frame with
14370de345e9SJerin Jacob  * rte_eth_pfc_queue_conf::rx_pause::tc, traffic will be paused on
14380de345e9SJerin Jacob  * rte_eth_pfc_queue_conf::rx_pause::tx_qid for that tc.
14390de345e9SJerin Jacob  *
14400de345e9SJerin Jacob  * rte_eth_pfc_queue_conf::tx_pause structure shall be used to configure given
14410de345e9SJerin Jacob  * rx_qid. When rx_qid is congested, PFC frames are generated with
14420de345e9SJerin Jacob  * rte_eth_pfc_queue_conf::rx_pause::tc and
14430de345e9SJerin Jacob  * rte_eth_pfc_queue_conf::rx_pause::pause_time to the peer.
14440de345e9SJerin Jacob  */
14450de345e9SJerin Jacob struct rte_eth_pfc_queue_conf {
14460de345e9SJerin Jacob 	enum rte_eth_fc_mode mode; /**< Link flow control mode */
14470de345e9SJerin Jacob 
14480de345e9SJerin Jacob 	struct {
14490de345e9SJerin Jacob 		uint16_t tx_qid; /**< Tx queue ID */
14500de345e9SJerin Jacob 		/** Traffic class as per PFC (802.1Qbb) spec. The value must be
14510de345e9SJerin Jacob 		 * in the range [0, rte_eth_pfc_queue_info::tx_max - 1]
14520de345e9SJerin Jacob 		 */
14530de345e9SJerin Jacob 		uint8_t tc;
14540de345e9SJerin Jacob 	} rx_pause; /* Valid when (mode == FC_RX_PAUSE || mode == FC_FULL) */
14550de345e9SJerin Jacob 
14560de345e9SJerin Jacob 	struct {
14570de345e9SJerin Jacob 		uint16_t pause_time; /**< Pause quota in the Pause frame */
14580de345e9SJerin Jacob 		uint16_t rx_qid;     /**< Rx queue ID */
14590de345e9SJerin Jacob 		/** Traffic class as per PFC (802.1Qbb) spec. The value must be
14600de345e9SJerin Jacob 		 * in the range [0, rte_eth_pfc_queue_info::tx_max - 1]
14610de345e9SJerin Jacob 		 */
14620de345e9SJerin Jacob 		uint8_t tc;
14630de345e9SJerin Jacob 	} tx_pause; /* Valid when (mode == FC_TX_PAUSE || mode == FC_FULL) */
14640de345e9SJerin Jacob };
14650de345e9SJerin Jacob 
14660de345e9SJerin Jacob /**
146799a2dd95SBruce Richardson  * Tunnel type for device-specific classifier configuration.
146899a2dd95SBruce Richardson  * @see rte_eth_udp_tunnel
146999a2dd95SBruce Richardson  */
147099a2dd95SBruce Richardson enum rte_eth_tunnel_type {
1471295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_NONE = 0,
1472295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_VXLAN,
1473295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_GENEVE,
1474295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_TEREDO,
1475295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_NVGRE,
1476295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_IP_IN_GRE,
1477295968d1SFerruh Yigit 	RTE_ETH_L2_TUNNEL_TYPE_E_TAG,
1478295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_VXLAN_GPE,
1479295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_ECPRI,
1480295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_MAX,
148199a2dd95SBruce Richardson };
1482b1cb3035SFerruh Yigit #define RTE_TUNNEL_TYPE_NONE      RTE_DEPRECATED(RTE_TUNNEL_TYPE_NONE)      RTE_ETH_TUNNEL_TYPE_NONE
1483b1cb3035SFerruh Yigit #define RTE_TUNNEL_TYPE_VXLAN     RTE_DEPRECATED(RTE_TUNNEL_TYPE_VXLAN)     RTE_ETH_TUNNEL_TYPE_VXLAN
1484b1cb3035SFerruh Yigit #define RTE_TUNNEL_TYPE_GENEVE    RTE_DEPRECATED(RTE_TUNNEL_TYPE_GENEVE)    RTE_ETH_TUNNEL_TYPE_GENEVE
1485b1cb3035SFerruh Yigit #define RTE_TUNNEL_TYPE_TEREDO    RTE_DEPRECATED(RTE_TUNNEL_TYPE_TEREDO)    RTE_ETH_TUNNEL_TYPE_TEREDO
1486b1cb3035SFerruh Yigit #define RTE_TUNNEL_TYPE_NVGRE     RTE_DEPRECATED(RTE_TUNNEL_TYPE_NVGRE)     RTE_ETH_TUNNEL_TYPE_NVGRE
1487b1cb3035SFerruh Yigit #define RTE_TUNNEL_TYPE_IP_IN_GRE RTE_DEPRECATED(RTE_TUNNEL_TYPE_IP_IN_GRE) RTE_ETH_TUNNEL_TYPE_IP_IN_GRE
1488b1cb3035SFerruh Yigit #define RTE_L2_TUNNEL_TYPE_E_TAG  RTE_DEPRECATED(RTE_L2_TUNNEL_TYPE_E_TAG)  RTE_ETH_L2_TUNNEL_TYPE_E_TAG
1489b1cb3035SFerruh Yigit #define RTE_TUNNEL_TYPE_VXLAN_GPE RTE_DEPRECATED(RTE_TUNNEL_TYPE_VXLAN_GPE) RTE_ETH_TUNNEL_TYPE_VXLAN_GPE
1490b1cb3035SFerruh Yigit #define RTE_TUNNEL_TYPE_ECPRI     RTE_DEPRECATED(RTE_TUNNEL_TYPE_ECPRI)     RTE_ETH_TUNNEL_TYPE_ECPRI
1491b1cb3035SFerruh Yigit #define RTE_TUNNEL_TYPE_MAX       RTE_DEPRECATED(RTE_TUNNEL_TYPE_MAX)       RTE_ETH_TUNNEL_TYPE_MAX
1492295968d1SFerruh Yigit 
149399a2dd95SBruce Richardson /* Deprecated API file for rte_eth_dev_filter_* functions */
149499a2dd95SBruce Richardson #include "rte_eth_ctrl.h"
149599a2dd95SBruce Richardson 
149699a2dd95SBruce Richardson /**
149799a2dd95SBruce Richardson  *  Memory space that can be configured to store Flow Director filters
149899a2dd95SBruce Richardson  *  in the board memory.
149999a2dd95SBruce Richardson  */
1500295968d1SFerruh Yigit enum rte_eth_fdir_pballoc_type {
1501295968d1SFerruh Yigit 	RTE_ETH_FDIR_PBALLOC_64K = 0,  /**< 64k. */
1502295968d1SFerruh Yigit 	RTE_ETH_FDIR_PBALLOC_128K,     /**< 128k. */
1503295968d1SFerruh Yigit 	RTE_ETH_FDIR_PBALLOC_256K,     /**< 256k. */
150499a2dd95SBruce Richardson };
1505295968d1SFerruh Yigit #define rte_fdir_pballoc_type	rte_eth_fdir_pballoc_type
1506295968d1SFerruh Yigit 
1507b1cb3035SFerruh Yigit #define RTE_FDIR_PBALLOC_64K  RTE_DEPRECATED(RTE_FDIR_PBALLOC_64K)  RTE_ETH_FDIR_PBALLOC_64K
1508b1cb3035SFerruh Yigit #define RTE_FDIR_PBALLOC_128K RTE_DEPRECATED(RTE_FDIR_PBALLOC_128K) RTE_ETH_FDIR_PBALLOC_128K
1509b1cb3035SFerruh Yigit #define RTE_FDIR_PBALLOC_256K RTE_DEPRECATED(RTE_FDIR_PBALLOC_256K) RTE_ETH_FDIR_PBALLOC_256K
151099a2dd95SBruce Richardson 
151199a2dd95SBruce Richardson /**
151209fd4227SAndrew Rybchenko  *  Select report mode of FDIR hash information in Rx descriptors.
151399a2dd95SBruce Richardson  */
151499a2dd95SBruce Richardson enum rte_fdir_status_mode {
151599a2dd95SBruce Richardson 	RTE_FDIR_NO_REPORT_STATUS = 0, /**< Never report FDIR hash. */
151699a2dd95SBruce Richardson 	RTE_FDIR_REPORT_STATUS, /**< Only report FDIR hash for matching pkts. */
151799a2dd95SBruce Richardson 	RTE_FDIR_REPORT_STATUS_ALWAYS, /**< Always report FDIR hash. */
151899a2dd95SBruce Richardson };
151999a2dd95SBruce Richardson 
152099a2dd95SBruce Richardson /**
152199a2dd95SBruce Richardson  * A structure used to configure the Flow Director (FDIR) feature
152299a2dd95SBruce Richardson  * of an Ethernet port.
152399a2dd95SBruce Richardson  *
152499a2dd95SBruce Richardson  * If mode is RTE_FDIR_MODE_NONE, the pballoc value is ignored.
152599a2dd95SBruce Richardson  */
1526295968d1SFerruh Yigit struct rte_eth_fdir_conf {
152799a2dd95SBruce Richardson 	enum rte_fdir_mode mode; /**< Flow Director mode. */
1528295968d1SFerruh Yigit 	enum rte_eth_fdir_pballoc_type pballoc; /**< Space for FDIR filters. */
152999a2dd95SBruce Richardson 	enum rte_fdir_status_mode status;  /**< How to report FDIR hash. */
153009fd4227SAndrew Rybchenko 	/** Rx queue of packets matching a "drop" filter in perfect mode. */
153199a2dd95SBruce Richardson 	uint8_t drop_queue;
153299a2dd95SBruce Richardson 	struct rte_eth_fdir_masks mask;
15333c2ca0a9SAndrew Rybchenko 	/** Flex payload configuration. */
153499a2dd95SBruce Richardson 	struct rte_eth_fdir_flex_conf flex_conf;
153599a2dd95SBruce Richardson };
1536295968d1SFerruh Yigit #define rte_fdir_conf rte_eth_fdir_conf
1537295968d1SFerruh Yigit 
153899a2dd95SBruce Richardson /**
153999a2dd95SBruce Richardson  * UDP tunneling configuration.
154099a2dd95SBruce Richardson  *
154199a2dd95SBruce Richardson  * Used to configure the classifier of a device,
154299a2dd95SBruce Richardson  * associating an UDP port with a type of tunnel.
154399a2dd95SBruce Richardson  *
154499a2dd95SBruce Richardson  * Some NICs may need such configuration to properly parse a tunnel
154599a2dd95SBruce Richardson  * with any standard or custom UDP port.
154699a2dd95SBruce Richardson  */
154799a2dd95SBruce Richardson struct rte_eth_udp_tunnel {
154899a2dd95SBruce Richardson 	uint16_t udp_port; /**< UDP port used for the tunnel. */
154999a2dd95SBruce Richardson 	uint8_t prot_type; /**< Tunnel type. @see rte_eth_tunnel_type */
155099a2dd95SBruce Richardson };
155199a2dd95SBruce Richardson 
155299a2dd95SBruce Richardson /**
155399a2dd95SBruce Richardson  * A structure used to enable/disable specific device interrupts.
155499a2dd95SBruce Richardson  */
1555295968d1SFerruh Yigit struct rte_eth_intr_conf {
155699a2dd95SBruce Richardson 	/** enable/disable lsc interrupt. 0 (default) - disable, 1 enable */
155799a2dd95SBruce Richardson 	uint32_t lsc:1;
155899a2dd95SBruce Richardson 	/** enable/disable rxq interrupt. 0 (default) - disable, 1 enable */
155999a2dd95SBruce Richardson 	uint32_t rxq:1;
156099a2dd95SBruce Richardson 	/** enable/disable rmv interrupt. 0 (default) - disable, 1 enable */
156199a2dd95SBruce Richardson 	uint32_t rmv:1;
156299a2dd95SBruce Richardson };
156399a2dd95SBruce Richardson 
1564295968d1SFerruh Yigit #define rte_intr_conf rte_eth_intr_conf
1565295968d1SFerruh Yigit 
156699a2dd95SBruce Richardson /**
156799a2dd95SBruce Richardson  * A structure used to configure an Ethernet port.
156809fd4227SAndrew Rybchenko  * Depending upon the Rx multi-queue mode, extra advanced
156999a2dd95SBruce Richardson  * configuration settings may be needed.
157099a2dd95SBruce Richardson  */
157199a2dd95SBruce Richardson struct rte_eth_conf {
1572295968d1SFerruh Yigit 	uint32_t link_speeds; /**< bitmap of RTE_ETH_LINK_SPEED_XXX of speeds to be
1573295968d1SFerruh Yigit 				used. RTE_ETH_LINK_SPEED_FIXED disables link
157499a2dd95SBruce Richardson 				autonegotiation, and a unique speed shall be
157599a2dd95SBruce Richardson 				set. Otherwise, the bitmap defines the set of
157699a2dd95SBruce Richardson 				speeds to be advertised. If the special value
1577295968d1SFerruh Yigit 				RTE_ETH_LINK_SPEED_AUTONEG (0) is used, all speeds
157899a2dd95SBruce Richardson 				supported are advertised. */
157909fd4227SAndrew Rybchenko 	struct rte_eth_rxmode rxmode; /**< Port Rx configuration. */
158009fd4227SAndrew Rybchenko 	struct rte_eth_txmode txmode; /**< Port Tx configuration. */
158199a2dd95SBruce Richardson 	uint32_t lpbk_mode; /**< Loopback operation mode. By default the value
158299a2dd95SBruce Richardson 			         is 0, meaning the loopback mode is disabled.
15830d9f56a8SAndrew Rybchenko 				 Read the datasheet of given Ethernet controller
158499a2dd95SBruce Richardson 				 for details. The possible values of this field
158599a2dd95SBruce Richardson 				 are defined in implementation of each driver. */
158699a2dd95SBruce Richardson 	struct {
158799a2dd95SBruce Richardson 		struct rte_eth_rss_conf rss_conf; /**< Port RSS configuration */
1588064e90c4SAndrew Rybchenko 		/** Port VMDq+DCB configuration. */
158999a2dd95SBruce Richardson 		struct rte_eth_vmdq_dcb_conf vmdq_dcb_conf;
1590064e90c4SAndrew Rybchenko 		/** Port DCB Rx configuration. */
159199a2dd95SBruce Richardson 		struct rte_eth_dcb_rx_conf dcb_rx_conf;
1592064e90c4SAndrew Rybchenko 		/** Port VMDq Rx configuration. */
159399a2dd95SBruce Richardson 		struct rte_eth_vmdq_rx_conf vmdq_rx_conf;
159409fd4227SAndrew Rybchenko 	} rx_adv_conf; /**< Port Rx filtering configuration. */
159599a2dd95SBruce Richardson 	union {
1596064e90c4SAndrew Rybchenko 		/** Port VMDq+DCB Tx configuration. */
159799a2dd95SBruce Richardson 		struct rte_eth_vmdq_dcb_tx_conf vmdq_dcb_tx_conf;
1598064e90c4SAndrew Rybchenko 		/** Port DCB Tx configuration. */
159999a2dd95SBruce Richardson 		struct rte_eth_dcb_tx_conf dcb_tx_conf;
1600064e90c4SAndrew Rybchenko 		/** Port VMDq Tx configuration. */
160199a2dd95SBruce Richardson 		struct rte_eth_vmdq_tx_conf vmdq_tx_conf;
160209fd4227SAndrew Rybchenko 	} tx_adv_conf; /**< Port Tx DCB configuration (union). */
160399a2dd95SBruce Richardson 	/** Currently,Priority Flow Control(PFC) are supported,if DCB with PFC
1604295968d1SFerruh Yigit 	    is needed,and the variable must be set RTE_ETH_DCB_PFC_SUPPORT. */
160599a2dd95SBruce Richardson 	uint32_t dcb_capability_en;
1606295968d1SFerruh Yigit 	struct rte_eth_fdir_conf fdir_conf; /**< FDIR configuration. DEPRECATED */
1607295968d1SFerruh Yigit 	struct rte_eth_intr_conf intr_conf; /**< Interrupt mode configuration. */
160899a2dd95SBruce Richardson };
160999a2dd95SBruce Richardson 
161099a2dd95SBruce Richardson /**
161109fd4227SAndrew Rybchenko  * Rx offload capabilities of a device.
161299a2dd95SBruce Richardson  */
16134852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_VLAN_STRIP       RTE_BIT64(0)
16144852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_IPV4_CKSUM       RTE_BIT64(1)
16154852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_UDP_CKSUM        RTE_BIT64(2)
16164852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_TCP_CKSUM        RTE_BIT64(3)
16174852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_TCP_LRO          RTE_BIT64(4)
16184852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_QINQ_STRIP       RTE_BIT64(5)
16194852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM RTE_BIT64(6)
16204852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_MACSEC_STRIP     RTE_BIT64(7)
16214852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_HEADER_SPLIT     RTE_BIT64(8)
16224852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_VLAN_FILTER      RTE_BIT64(9)
16234852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_VLAN_EXTEND      RTE_BIT64(10)
16244852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_SCATTER          RTE_BIT64(13)
162599a2dd95SBruce Richardson /**
162699a2dd95SBruce Richardson  * Timestamp is set by the driver in RTE_MBUF_DYNFIELD_TIMESTAMP_NAME
162799a2dd95SBruce Richardson  * and RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME is set in ol_flags.
162899a2dd95SBruce Richardson  * The mbuf field and flag are registered when the offload is configured.
162999a2dd95SBruce Richardson  */
16304852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_TIMESTAMP        RTE_BIT64(14)
16314852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_SECURITY         RTE_BIT64(15)
16324852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_KEEP_CRC         RTE_BIT64(16)
16334852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_SCTP_CKSUM       RTE_BIT64(17)
16344852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM  RTE_BIT64(18)
16354852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_RSS_HASH         RTE_BIT64(19)
16364852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT     RTE_BIT64(20)
163799a2dd95SBruce Richardson 
1638b1cb3035SFerruh Yigit #define DEV_RX_OFFLOAD_VLAN_STRIP       RTE_DEPRECATED(DEV_RX_OFFLOAD_VLAN_STRIP)       RTE_ETH_RX_OFFLOAD_VLAN_STRIP
1639b1cb3035SFerruh Yigit #define DEV_RX_OFFLOAD_IPV4_CKSUM       RTE_DEPRECATED(DEV_RX_OFFLOAD_IPV4_CKSUM)       RTE_ETH_RX_OFFLOAD_IPV4_CKSUM
1640b1cb3035SFerruh Yigit #define DEV_RX_OFFLOAD_UDP_CKSUM        RTE_DEPRECATED(DEV_RX_OFFLOAD_UDP_CKSUM)        RTE_ETH_RX_OFFLOAD_UDP_CKSUM
1641b1cb3035SFerruh Yigit #define DEV_RX_OFFLOAD_TCP_CKSUM        RTE_DEPRECATED(DEV_RX_OFFLOAD_TCP_CKSUM)        RTE_ETH_RX_OFFLOAD_TCP_CKSUM
1642b1cb3035SFerruh Yigit #define DEV_RX_OFFLOAD_TCP_LRO          RTE_DEPRECATED(DEV_RX_OFFLOAD_TCP_LRO)          RTE_ETH_RX_OFFLOAD_TCP_LRO
1643b1cb3035SFerruh Yigit #define DEV_RX_OFFLOAD_QINQ_STRIP       RTE_DEPRECATED(DEV_RX_OFFLOAD_QINQ_STRIP)       RTE_ETH_RX_OFFLOAD_QINQ_STRIP
1644b1cb3035SFerruh Yigit #define DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM RTE_DEPRECATED(DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM) RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM
1645b1cb3035SFerruh Yigit #define DEV_RX_OFFLOAD_MACSEC_STRIP     RTE_DEPRECATED(DEV_RX_OFFLOAD_MACSEC_STRIP)     RTE_ETH_RX_OFFLOAD_MACSEC_STRIP
1646b1cb3035SFerruh Yigit #define DEV_RX_OFFLOAD_HEADER_SPLIT     RTE_DEPRECATED(DEV_RX_OFFLOAD_HEADER_SPLIT)     RTE_ETH_RX_OFFLOAD_HEADER_SPLIT
1647b1cb3035SFerruh Yigit #define DEV_RX_OFFLOAD_VLAN_FILTER      RTE_DEPRECATED(DEV_RX_OFFLOAD_VLAN_FILTER)      RTE_ETH_RX_OFFLOAD_VLAN_FILTER
1648b1cb3035SFerruh Yigit #define DEV_RX_OFFLOAD_VLAN_EXTEND      RTE_DEPRECATED(DEV_RX_OFFLOAD_VLAN_EXTEND)      RTE_ETH_RX_OFFLOAD_VLAN_EXTEND
1649b1cb3035SFerruh Yigit #define DEV_RX_OFFLOAD_SCATTER          RTE_DEPRECATED(DEV_RX_OFFLOAD_SCATTER)          RTE_ETH_RX_OFFLOAD_SCATTER
1650b1cb3035SFerruh Yigit #define DEV_RX_OFFLOAD_TIMESTAMP        RTE_DEPRECATED(DEV_RX_OFFLOAD_TIMESTAMP)        RTE_ETH_RX_OFFLOAD_TIMESTAMP
1651b1cb3035SFerruh Yigit #define DEV_RX_OFFLOAD_SECURITY         RTE_DEPRECATED(DEV_RX_OFFLOAD_SECURITY)         RTE_ETH_RX_OFFLOAD_SECURITY
1652b1cb3035SFerruh Yigit #define DEV_RX_OFFLOAD_KEEP_CRC         RTE_DEPRECATED(DEV_RX_OFFLOAD_KEEP_CRC)         RTE_ETH_RX_OFFLOAD_KEEP_CRC
1653b1cb3035SFerruh Yigit #define DEV_RX_OFFLOAD_SCTP_CKSUM       RTE_DEPRECATED(DEV_RX_OFFLOAD_SCTP_CKSUM)       RTE_ETH_RX_OFFLOAD_SCTP_CKSUM
1654b1cb3035SFerruh Yigit #define DEV_RX_OFFLOAD_OUTER_UDP_CKSUM  RTE_DEPRECATED(DEV_RX_OFFLOAD_OUTER_UDP_CKSUM)  RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM
1655b1cb3035SFerruh Yigit #define DEV_RX_OFFLOAD_RSS_HASH         RTE_DEPRECATED(DEV_RX_OFFLOAD_RSS_HASH)         RTE_ETH_RX_OFFLOAD_RSS_HASH
1656b1cb3035SFerruh Yigit 
1657295968d1SFerruh Yigit #define RTE_ETH_RX_OFFLOAD_CHECKSUM (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | \
1658295968d1SFerruh Yigit 				 RTE_ETH_RX_OFFLOAD_UDP_CKSUM | \
1659295968d1SFerruh Yigit 				 RTE_ETH_RX_OFFLOAD_TCP_CKSUM)
1660b1cb3035SFerruh Yigit #define DEV_RX_OFFLOAD_CHECKSUM RTE_DEPRECATED(DEV_RX_OFFLOAD_CHECKSUM) RTE_ETH_RX_OFFLOAD_CHECKSUM
1661295968d1SFerruh Yigit #define RTE_ETH_RX_OFFLOAD_VLAN (RTE_ETH_RX_OFFLOAD_VLAN_STRIP | \
1662295968d1SFerruh Yigit 			     RTE_ETH_RX_OFFLOAD_VLAN_FILTER | \
1663295968d1SFerruh Yigit 			     RTE_ETH_RX_OFFLOAD_VLAN_EXTEND | \
1664295968d1SFerruh Yigit 			     RTE_ETH_RX_OFFLOAD_QINQ_STRIP)
1665b1cb3035SFerruh Yigit #define DEV_RX_OFFLOAD_VLAN RTE_DEPRECATED(DEV_RX_OFFLOAD_VLAN) RTE_ETH_RX_OFFLOAD_VLAN
166699a2dd95SBruce Richardson 
166799a2dd95SBruce Richardson /*
166899a2dd95SBruce Richardson  * If new Rx offload capabilities are defined, they also must be
166999a2dd95SBruce Richardson  * mentioned in rte_rx_offload_names in rte_ethdev.c file.
167099a2dd95SBruce Richardson  */
167199a2dd95SBruce Richardson 
167299a2dd95SBruce Richardson /**
167309fd4227SAndrew Rybchenko  * Tx offload capabilities of a device.
167499a2dd95SBruce Richardson  */
16754852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_VLAN_INSERT      RTE_BIT64(0)
16764852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_IPV4_CKSUM       RTE_BIT64(1)
16774852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_UDP_CKSUM        RTE_BIT64(2)
16784852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_TCP_CKSUM        RTE_BIT64(3)
16794852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_SCTP_CKSUM       RTE_BIT64(4)
16804852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_TCP_TSO          RTE_BIT64(5)
16814852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_UDP_TSO          RTE_BIT64(6)
16824852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM RTE_BIT64(7)  /**< Used for tunneling packet. */
16834852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_QINQ_INSERT      RTE_BIT64(8)
16844852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO    RTE_BIT64(9)  /**< Used for tunneling packet. */
16854852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO      RTE_BIT64(10) /**< Used for tunneling packet. */
16864852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO     RTE_BIT64(11) /**< Used for tunneling packet. */
16874852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO   RTE_BIT64(12) /**< Used for tunneling packet. */
16884852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_MACSEC_INSERT    RTE_BIT64(13)
16893c2ca0a9SAndrew Rybchenko /**
16903c2ca0a9SAndrew Rybchenko  * Multiple threads can invoke rte_eth_tx_burst() concurrently on the same
169109fd4227SAndrew Rybchenko  * Tx queue without SW lock.
169299a2dd95SBruce Richardson  */
16934852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_MT_LOCKFREE      RTE_BIT64(14)
16943c2ca0a9SAndrew Rybchenko /** Device supports multi segment send. */
16954852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_MULTI_SEGS       RTE_BIT64(15)
16963c2ca0a9SAndrew Rybchenko /**
16973c2ca0a9SAndrew Rybchenko  * Device supports optimization for fast release of mbufs.
169899a2dd95SBruce Richardson  * When set application must guarantee that per-queue all mbufs comes from
169999a2dd95SBruce Richardson  * the same mempool and has refcnt = 1.
170099a2dd95SBruce Richardson  */
17014852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE   RTE_BIT64(16)
17024852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_SECURITY         RTE_BIT64(17)
170399a2dd95SBruce Richardson /**
170499a2dd95SBruce Richardson  * Device supports generic UDP tunneled packet TSO.
1705daa02b5cSOlivier Matz  * Application must set RTE_MBUF_F_TX_TUNNEL_UDP and other mbuf fields required
170699a2dd95SBruce Richardson  * for tunnel TSO.
170799a2dd95SBruce Richardson  */
17084852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO      RTE_BIT64(18)
170999a2dd95SBruce Richardson /**
171099a2dd95SBruce Richardson  * Device supports generic IP tunneled packet TSO.
1711daa02b5cSOlivier Matz  * Application must set RTE_MBUF_F_TX_TUNNEL_IP and other mbuf fields required
171299a2dd95SBruce Richardson  * for tunnel TSO.
171399a2dd95SBruce Richardson  */
17144852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_IP_TNL_TSO       RTE_BIT64(19)
171599a2dd95SBruce Richardson /** Device supports outer UDP checksum */
17164852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM  RTE_BIT64(20)
171799a2dd95SBruce Richardson /**
171899a2dd95SBruce Richardson  * Device sends on time read from RTE_MBUF_DYNFIELD_TIMESTAMP_NAME
171999a2dd95SBruce Richardson  * if RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME is set in ol_flags.
172099a2dd95SBruce Richardson  * The mbuf field and flag are registered when the offload is configured.
172199a2dd95SBruce Richardson  */
17224852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP RTE_BIT64(21)
172399a2dd95SBruce Richardson /*
172499a2dd95SBruce Richardson  * If new Tx offload capabilities are defined, they also must be
172599a2dd95SBruce Richardson  * mentioned in rte_tx_offload_names in rte_ethdev.c file.
172699a2dd95SBruce Richardson  */
172799a2dd95SBruce Richardson 
1728b1cb3035SFerruh Yigit #define DEV_TX_OFFLOAD_VLAN_INSERT       RTE_DEPRECATED(DEV_TX_OFFLOAD_VLAN_INSERT)       RTE_ETH_TX_OFFLOAD_VLAN_INSERT
1729b1cb3035SFerruh Yigit #define DEV_TX_OFFLOAD_IPV4_CKSUM        RTE_DEPRECATED(DEV_TX_OFFLOAD_IPV4_CKSUM)        RTE_ETH_TX_OFFLOAD_IPV4_CKSUM
1730b1cb3035SFerruh Yigit #define DEV_TX_OFFLOAD_UDP_CKSUM         RTE_DEPRECATED(DEV_TX_OFFLOAD_UDP_CKSUM)         RTE_ETH_TX_OFFLOAD_UDP_CKSUM
1731b1cb3035SFerruh Yigit #define DEV_TX_OFFLOAD_TCP_CKSUM         RTE_DEPRECATED(DEV_TX_OFFLOAD_TCP_CKSUM)         RTE_ETH_TX_OFFLOAD_TCP_CKSUM
1732b1cb3035SFerruh Yigit #define DEV_TX_OFFLOAD_SCTP_CKSUM        RTE_DEPRECATED(DEV_TX_OFFLOAD_SCTP_CKSUM)        RTE_ETH_TX_OFFLOAD_SCTP_CKSUM
1733b1cb3035SFerruh Yigit #define DEV_TX_OFFLOAD_TCP_TSO           RTE_DEPRECATED(DEV_TX_OFFLOAD_TCP_TSO)           RTE_ETH_TX_OFFLOAD_TCP_TSO
1734b1cb3035SFerruh Yigit #define DEV_TX_OFFLOAD_UDP_TSO           RTE_DEPRECATED(DEV_TX_OFFLOAD_UDP_TSO)           RTE_ETH_TX_OFFLOAD_UDP_TSO
1735b1cb3035SFerruh Yigit #define DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM  RTE_DEPRECATED(DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)  RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM
1736b1cb3035SFerruh Yigit #define DEV_TX_OFFLOAD_QINQ_INSERT       RTE_DEPRECATED(DEV_TX_OFFLOAD_QINQ_INSERT)       RTE_ETH_TX_OFFLOAD_QINQ_INSERT
1737b1cb3035SFerruh Yigit #define DEV_TX_OFFLOAD_VXLAN_TNL_TSO     RTE_DEPRECATED(DEV_TX_OFFLOAD_VXLAN_TNL_TSO)     RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO
1738b1cb3035SFerruh Yigit #define DEV_TX_OFFLOAD_GRE_TNL_TSO       RTE_DEPRECATED(DEV_TX_OFFLOAD_GRE_TNL_TSO)       RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO
1739b1cb3035SFerruh Yigit #define DEV_TX_OFFLOAD_IPIP_TNL_TSO      RTE_DEPRECATED(DEV_TX_OFFLOAD_IPIP_TNL_TSO)      RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO
1740b1cb3035SFerruh Yigit #define DEV_TX_OFFLOAD_GENEVE_TNL_TSO    RTE_DEPRECATED(DEV_TX_OFFLOAD_GENEVE_TNL_TSO)    RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO
1741b1cb3035SFerruh Yigit #define DEV_TX_OFFLOAD_MACSEC_INSERT     RTE_DEPRECATED(DEV_TX_OFFLOAD_MACSEC_INSERT)     RTE_ETH_TX_OFFLOAD_MACSEC_INSERT
1742b1cb3035SFerruh Yigit #define DEV_TX_OFFLOAD_MT_LOCKFREE       RTE_DEPRECATED(DEV_TX_OFFLOAD_MT_LOCKFREE)       RTE_ETH_TX_OFFLOAD_MT_LOCKFREE
1743b1cb3035SFerruh Yigit #define DEV_TX_OFFLOAD_MULTI_SEGS        RTE_DEPRECATED(DEV_TX_OFFLOAD_MULTI_SEGS)        RTE_ETH_TX_OFFLOAD_MULTI_SEGS
1744b1cb3035SFerruh Yigit #define DEV_TX_OFFLOAD_MBUF_FAST_FREE    RTE_DEPRECATED(DEV_TX_OFFLOAD_MBUF_FAST_FREE)    RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE
1745b1cb3035SFerruh Yigit #define DEV_TX_OFFLOAD_SECURITY          RTE_DEPRECATED(DEV_TX_OFFLOAD_SECURITY)          RTE_ETH_TX_OFFLOAD_SECURITY
1746b1cb3035SFerruh Yigit #define DEV_TX_OFFLOAD_UDP_TNL_TSO       RTE_DEPRECATED(DEV_TX_OFFLOAD_UDP_TNL_TSO)       RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO
1747b1cb3035SFerruh Yigit #define DEV_TX_OFFLOAD_IP_TNL_TSO        RTE_DEPRECATED(DEV_TX_OFFLOAD_IP_TNL_TSO)        RTE_ETH_TX_OFFLOAD_IP_TNL_TSO
1748b1cb3035SFerruh Yigit #define DEV_TX_OFFLOAD_OUTER_UDP_CKSUM   RTE_DEPRECATED(DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)   RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM
1749b1cb3035SFerruh Yigit #define DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP RTE_DEPRECATED(DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP) RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP
1750b1cb3035SFerruh Yigit 
175199a2dd95SBruce Richardson /**@{@name Device capabilities
175299a2dd95SBruce Richardson  * Non-offload capabilities reported in rte_eth_dev_info.dev_capa.
175399a2dd95SBruce Richardson  */
175499a2dd95SBruce Richardson /** Device supports Rx queue setup after device started. */
17554852c647SAndrew Rybchenko #define RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP RTE_BIT64(0)
175699a2dd95SBruce Richardson /** Device supports Tx queue setup after device started. */
17574852c647SAndrew Rybchenko #define RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP RTE_BIT64(1)
1758dd22740cSXueming Li /**
1759dd22740cSXueming Li  * Device supports shared Rx queue among ports within Rx domain and
1760dd22740cSXueming Li  * switch domain. Mbufs are consumed by shared Rx queue instead of
1761dd22740cSXueming Li  * each queue. Multiple groups are supported by share_group of Rx
1762dd22740cSXueming Li  * queue configuration. Shared Rx queue is identified by PMD using
1763dd22740cSXueming Li  * share_qid of Rx queue configuration. Polling any port in the group
1764dd22740cSXueming Li  * receive packets of all member ports, source port identified by
1765dd22740cSXueming Li  * mbuf->port field.
1766dd22740cSXueming Li  */
1767dd22740cSXueming Li #define RTE_ETH_DEV_CAPA_RXQ_SHARE              RTE_BIT64(2)
17681d5a3d68SDmitry Kozlyuk /** Device supports keeping flow rules across restart. */
17691d5a3d68SDmitry Kozlyuk #define RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP         RTE_BIT64(3)
17702c9cd45dSDmitry Kozlyuk /** Device supports keeping shared flow objects across restart. */
17712c9cd45dSDmitry Kozlyuk #define RTE_ETH_DEV_CAPA_FLOW_SHARED_OBJECT_KEEP RTE_BIT64(4)
177299a2dd95SBruce Richardson /**@}*/
177399a2dd95SBruce Richardson 
177499a2dd95SBruce Richardson /*
177599a2dd95SBruce Richardson  * Fallback default preferred Rx/Tx port parameters.
177699a2dd95SBruce Richardson  * These are used if an application requests default parameters
177799a2dd95SBruce Richardson  * but the PMD does not provide preferred values.
177899a2dd95SBruce Richardson  */
177999a2dd95SBruce Richardson #define RTE_ETH_DEV_FALLBACK_RX_RINGSIZE 512
178099a2dd95SBruce Richardson #define RTE_ETH_DEV_FALLBACK_TX_RINGSIZE 512
178199a2dd95SBruce Richardson #define RTE_ETH_DEV_FALLBACK_RX_NBQUEUES 1
178299a2dd95SBruce Richardson #define RTE_ETH_DEV_FALLBACK_TX_NBQUEUES 1
178399a2dd95SBruce Richardson 
178499a2dd95SBruce Richardson /**
178599a2dd95SBruce Richardson  * Preferred Rx/Tx port parameters.
178699a2dd95SBruce Richardson  * There are separate instances of this structure for transmission
178799a2dd95SBruce Richardson  * and reception respectively.
178899a2dd95SBruce Richardson  */
178999a2dd95SBruce Richardson struct rte_eth_dev_portconf {
179099a2dd95SBruce Richardson 	uint16_t burst_size; /**< Device-preferred burst size */
179199a2dd95SBruce Richardson 	uint16_t ring_size; /**< Device-preferred size of queue rings */
179299a2dd95SBruce Richardson 	uint16_t nb_queues; /**< Device-preferred number of queues */
179399a2dd95SBruce Richardson };
179499a2dd95SBruce Richardson 
179599a2dd95SBruce Richardson /**
17965906be5aSAndrew Rybchenko  * Default values for switch domain ID when ethdev does not support switch
179799a2dd95SBruce Richardson  * domain definitions.
179899a2dd95SBruce Richardson  */
179999a2dd95SBruce Richardson #define RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID	(UINT16_MAX)
180099a2dd95SBruce Richardson 
180199a2dd95SBruce Richardson /**
180299a2dd95SBruce Richardson  * Ethernet device associated switch information
180399a2dd95SBruce Richardson  */
180499a2dd95SBruce Richardson struct rte_eth_switch_info {
180599a2dd95SBruce Richardson 	const char *name;	/**< switch name */
18065906be5aSAndrew Rybchenko 	uint16_t domain_id;	/**< switch domain ID */
18073c2ca0a9SAndrew Rybchenko 	/**
18083c2ca0a9SAndrew Rybchenko 	 * Mapping to the devices physical switch port as enumerated from the
180999a2dd95SBruce Richardson 	 * perspective of the embedded interconnect/switch. For SR-IOV enabled
181099a2dd95SBruce Richardson 	 * device this may correspond to the VF_ID of each virtual function,
181199a2dd95SBruce Richardson 	 * but each driver should explicitly define the mapping of switch
181299a2dd95SBruce Richardson 	 * port identifier to that physical interconnect/switch
181399a2dd95SBruce Richardson 	 */
18143c2ca0a9SAndrew Rybchenko 	uint16_t port_id;
1815dd22740cSXueming Li 	/**
1816dd22740cSXueming Li 	 * Shared Rx queue sub-domain boundary. Only ports in same Rx domain
1817dd22740cSXueming Li 	 * and switch domain can share Rx queue. Valid only if device advertised
1818dd22740cSXueming Li 	 * RTE_ETH_DEV_CAPA_RXQ_SHARE capability.
1819dd22740cSXueming Li 	 */
1820dd22740cSXueming Li 	uint16_t rx_domain;
182199a2dd95SBruce Richardson };
182299a2dd95SBruce Richardson 
182399a2dd95SBruce Richardson /**
182499a2dd95SBruce Richardson  * @warning
182599a2dd95SBruce Richardson  * @b EXPERIMENTAL: this structure may change without prior notice.
182699a2dd95SBruce Richardson  *
182799a2dd95SBruce Richardson  * Ethernet device Rx buffer segmentation capabilities.
182899a2dd95SBruce Richardson  */
182999a2dd95SBruce Richardson struct rte_eth_rxseg_capa {
183099a2dd95SBruce Richardson 	__extension__
183199a2dd95SBruce Richardson 	uint32_t multi_pools:1; /**< Supports receiving to multiple pools.*/
183299a2dd95SBruce Richardson 	uint32_t offset_allowed:1; /**< Supports buffer offsets. */
183399a2dd95SBruce Richardson 	uint32_t offset_align_log2:4; /**< Required offset alignment. */
183499a2dd95SBruce Richardson 	uint16_t max_nseg; /**< Maximum amount of segments to split. */
183599a2dd95SBruce Richardson 	uint16_t reserved; /**< Reserved field. */
183699a2dd95SBruce Richardson };
183799a2dd95SBruce Richardson 
183899a2dd95SBruce Richardson /**
183999a2dd95SBruce Richardson  * Ethernet device information
184099a2dd95SBruce Richardson  */
184199a2dd95SBruce Richardson 
184299a2dd95SBruce Richardson /**
184399a2dd95SBruce Richardson  * Ethernet device representor port type.
184499a2dd95SBruce Richardson  */
184599a2dd95SBruce Richardson enum rte_eth_representor_type {
184699a2dd95SBruce Richardson 	RTE_ETH_REPRESENTOR_NONE, /**< not a representor. */
184799a2dd95SBruce Richardson 	RTE_ETH_REPRESENTOR_VF,   /**< representor of Virtual Function. */
184899a2dd95SBruce Richardson 	RTE_ETH_REPRESENTOR_SF,   /**< representor of Sub Function. */
184999a2dd95SBruce Richardson 	RTE_ETH_REPRESENTOR_PF,   /**< representor of Physical Function. */
185099a2dd95SBruce Richardson };
185199a2dd95SBruce Richardson 
185299a2dd95SBruce Richardson /**
185399a2dd95SBruce Richardson  * A structure used to retrieve the contextual information of
185499a2dd95SBruce Richardson  * an Ethernet device, such as the controlling driver of the
185599a2dd95SBruce Richardson  * device, etc...
185699a2dd95SBruce Richardson  */
185799a2dd95SBruce Richardson struct rte_eth_dev_info {
1858*3b358e33SFerruh Yigit 	struct rte_device *device; /**< Generic device information */
185999a2dd95SBruce Richardson 	const char *driver_name; /**< Device Driver name. */
186099a2dd95SBruce Richardson 	unsigned int if_index; /**< Index to bound host interface, or 0 if none.
186199a2dd95SBruce Richardson 		Use if_indextoname() to translate into an interface name. */
186299a2dd95SBruce Richardson 	uint16_t min_mtu;	/**< Minimum MTU allowed */
186399a2dd95SBruce Richardson 	uint16_t max_mtu;	/**< Maximum MTU allowed */
186499a2dd95SBruce Richardson 	const uint32_t *dev_flags; /**< Device flags */
186509fd4227SAndrew Rybchenko 	uint32_t min_rx_bufsize; /**< Minimum size of Rx buffer. */
186609fd4227SAndrew Rybchenko 	uint32_t max_rx_pktlen; /**< Maximum configurable length of Rx pkt. */
186799a2dd95SBruce Richardson 	/** Maximum configurable size of LRO aggregated packet. */
186899a2dd95SBruce Richardson 	uint32_t max_lro_pkt_size;
186909fd4227SAndrew Rybchenko 	uint16_t max_rx_queues; /**< Maximum number of Rx queues. */
187009fd4227SAndrew Rybchenko 	uint16_t max_tx_queues; /**< Maximum number of Tx queues. */
187199a2dd95SBruce Richardson 	uint32_t max_mac_addrs; /**< Maximum number of MAC addresses. */
187299a2dd95SBruce Richardson 	/** Maximum number of hash MAC addresses for MTA and UTA. */
1873*3b358e33SFerruh Yigit 	uint32_t max_hash_mac_addrs;
187499a2dd95SBruce Richardson 	uint16_t max_vfs; /**< Maximum number of VFs. */
187599a2dd95SBruce Richardson 	uint16_t max_vmdq_pools; /**< Maximum number of VMDq pools. */
187699a2dd95SBruce Richardson 	struct rte_eth_rxseg_capa rx_seg_capa; /**< Segmentation capability.*/
187709fd4227SAndrew Rybchenko 	/** All Rx offload capabilities including all per-queue ones */
187899a2dd95SBruce Richardson 	uint64_t rx_offload_capa;
187909fd4227SAndrew Rybchenko 	/** All Tx offload capabilities including all per-queue ones */
188099a2dd95SBruce Richardson 	uint64_t tx_offload_capa;
188109fd4227SAndrew Rybchenko 	/** Device per-queue Rx offload capabilities. */
188299a2dd95SBruce Richardson 	uint64_t rx_queue_offload_capa;
188309fd4227SAndrew Rybchenko 	/** Device per-queue Tx offload capabilities. */
188499a2dd95SBruce Richardson 	uint64_t tx_queue_offload_capa;
18853c2ca0a9SAndrew Rybchenko 	/** Device redirection table size, the total number of entries. */
188699a2dd95SBruce Richardson 	uint16_t reta_size;
188799a2dd95SBruce Richardson 	uint8_t hash_key_size; /**< Hash key size in bytes */
188899a2dd95SBruce Richardson 	/** Bit mask of RSS offloads, the bit offset also means flow type */
188999a2dd95SBruce Richardson 	uint64_t flow_type_rss_offloads;
189009fd4227SAndrew Rybchenko 	struct rte_eth_rxconf default_rxconf; /**< Default Rx configuration */
189109fd4227SAndrew Rybchenko 	struct rte_eth_txconf default_txconf; /**< Default Tx configuration */
1892064e90c4SAndrew Rybchenko 	uint16_t vmdq_queue_base; /**< First queue ID for VMDq pools. */
1893064e90c4SAndrew Rybchenko 	uint16_t vmdq_queue_num;  /**< Queue number for VMDq pools. */
1894064e90c4SAndrew Rybchenko 	uint16_t vmdq_pool_base;  /**< First ID of VMDq pools. */
189509fd4227SAndrew Rybchenko 	struct rte_eth_desc_lim rx_desc_lim;  /**< Rx descriptors limits */
189609fd4227SAndrew Rybchenko 	struct rte_eth_desc_lim tx_desc_lim;  /**< Tx descriptors limits */
1897295968d1SFerruh Yigit 	uint32_t speed_capa;  /**< Supported speeds bitmap (RTE_ETH_LINK_SPEED_). */
189809fd4227SAndrew Rybchenko 	/** Configured number of Rx/Tx queues */
189909fd4227SAndrew Rybchenko 	uint16_t nb_rx_queues; /**< Number of Rx queues. */
190009fd4227SAndrew Rybchenko 	uint16_t nb_tx_queues; /**< Number of Tx queues. */
190199a2dd95SBruce Richardson 	/** Rx parameter recommendations */
190299a2dd95SBruce Richardson 	struct rte_eth_dev_portconf default_rxportconf;
190399a2dd95SBruce Richardson 	/** Tx parameter recommendations */
190499a2dd95SBruce Richardson 	struct rte_eth_dev_portconf default_txportconf;
190599a2dd95SBruce Richardson 	/** Generic device capabilities (RTE_ETH_DEV_CAPA_). */
190699a2dd95SBruce Richardson 	uint64_t dev_capa;
190799a2dd95SBruce Richardson 	/**
190899a2dd95SBruce Richardson 	 * Switching information for ports on a device with a
190999a2dd95SBruce Richardson 	 * embedded managed interconnect/switch.
191099a2dd95SBruce Richardson 	 */
191199a2dd95SBruce Richardson 	struct rte_eth_switch_info switch_info;
191299a2dd95SBruce Richardson 
191399a2dd95SBruce Richardson 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
191499a2dd95SBruce Richardson 	void *reserved_ptrs[2];   /**< Reserved for future fields */
191599a2dd95SBruce Richardson };
191699a2dd95SBruce Richardson 
19170ce56b05SThomas Monjalon /**@{@name Rx/Tx queue states */
19180ce56b05SThomas Monjalon #define RTE_ETH_QUEUE_STATE_STOPPED 0 /**< Queue stopped. */
19190ce56b05SThomas Monjalon #define RTE_ETH_QUEUE_STATE_STARTED 1 /**< Queue started. */
19200ce56b05SThomas Monjalon #define RTE_ETH_QUEUE_STATE_HAIRPIN 2 /**< Queue used for hairpin. */
19210ce56b05SThomas Monjalon /**@}*/
19229ad9ff47SLijun Ou 
19239ad9ff47SLijun Ou /**
192409fd4227SAndrew Rybchenko  * Ethernet device Rx queue information structure.
192599a2dd95SBruce Richardson  * Used to retrieve information about configured queue.
192699a2dd95SBruce Richardson  */
192799a2dd95SBruce Richardson struct rte_eth_rxq_info {
192899a2dd95SBruce Richardson 	struct rte_mempool *mp;     /**< mempool used by that queue. */
192999a2dd95SBruce Richardson 	struct rte_eth_rxconf conf; /**< queue config parameters. */
193009fd4227SAndrew Rybchenko 	uint8_t scattered_rx;       /**< scattered packets Rx supported. */
19319ad9ff47SLijun Ou 	uint8_t queue_state;        /**< one of RTE_ETH_QUEUE_STATE_*. */
193299a2dd95SBruce Richardson 	uint16_t nb_desc;           /**< configured number of RXDs. */
193399a2dd95SBruce Richardson 	uint16_t rx_buf_size;       /**< hardware receive buffer size. */
193499a2dd95SBruce Richardson } __rte_cache_min_aligned;
193599a2dd95SBruce Richardson 
193699a2dd95SBruce Richardson /**
193709fd4227SAndrew Rybchenko  * Ethernet device Tx queue information structure.
193899a2dd95SBruce Richardson  * Used to retrieve information about configured queue.
193999a2dd95SBruce Richardson  */
194099a2dd95SBruce Richardson struct rte_eth_txq_info {
194199a2dd95SBruce Richardson 	struct rte_eth_txconf conf; /**< queue config parameters. */
194299a2dd95SBruce Richardson 	uint16_t nb_desc;           /**< configured number of TXDs. */
19439ad9ff47SLijun Ou 	uint8_t queue_state;        /**< one of RTE_ETH_QUEUE_STATE_*. */
194499a2dd95SBruce Richardson } __rte_cache_min_aligned;
194599a2dd95SBruce Richardson 
194699a2dd95SBruce Richardson /* Generic Burst mode flag definition, values can be ORed. */
194799a2dd95SBruce Richardson 
194899a2dd95SBruce Richardson /**
194999a2dd95SBruce Richardson  * If the queues have different burst mode description, this bit will be set
195099a2dd95SBruce Richardson  * by PMD, then the application can iterate to retrieve burst description for
195199a2dd95SBruce Richardson  * all other queues.
195299a2dd95SBruce Richardson  */
1953e1823e08SThomas Monjalon #define RTE_ETH_BURST_FLAG_PER_QUEUE RTE_BIT64(0)
195499a2dd95SBruce Richardson 
195599a2dd95SBruce Richardson /**
195609fd4227SAndrew Rybchenko  * Ethernet device Rx/Tx queue packet burst mode information structure.
195799a2dd95SBruce Richardson  * Used to retrieve information about packet burst mode setting.
195899a2dd95SBruce Richardson  */
195999a2dd95SBruce Richardson struct rte_eth_burst_mode {
196099a2dd95SBruce Richardson 	uint64_t flags; /**< The ORed values of RTE_ETH_BURST_FLAG_xxx */
196199a2dd95SBruce Richardson 
196299a2dd95SBruce Richardson #define RTE_ETH_BURST_MODE_INFO_SIZE 1024 /**< Maximum size for information */
196399a2dd95SBruce Richardson 	char info[RTE_ETH_BURST_MODE_INFO_SIZE]; /**< burst mode information */
196499a2dd95SBruce Richardson };
196599a2dd95SBruce Richardson 
196699a2dd95SBruce Richardson /** Maximum name length for extended statistics counters */
196799a2dd95SBruce Richardson #define RTE_ETH_XSTATS_NAME_SIZE 64
196899a2dd95SBruce Richardson 
196999a2dd95SBruce Richardson /**
197099a2dd95SBruce Richardson  * An Ethernet device extended statistic structure
197199a2dd95SBruce Richardson  *
197299a2dd95SBruce Richardson  * This structure is used by rte_eth_xstats_get() to provide
197399a2dd95SBruce Richardson  * statistics that are not provided in the generic *rte_eth_stats*
197499a2dd95SBruce Richardson  * structure.
19755906be5aSAndrew Rybchenko  * It maps a name ID, corresponding to an index in the array returned
197699a2dd95SBruce Richardson  * by rte_eth_xstats_get_names(), to a statistic value.
197799a2dd95SBruce Richardson  */
197899a2dd95SBruce Richardson struct rte_eth_xstat {
197999a2dd95SBruce Richardson 	uint64_t id;        /**< The index in xstats name array. */
198099a2dd95SBruce Richardson 	uint64_t value;     /**< The statistic counter value. */
198199a2dd95SBruce Richardson };
198299a2dd95SBruce Richardson 
198399a2dd95SBruce Richardson /**
198499a2dd95SBruce Richardson  * A name element for extended statistics.
198599a2dd95SBruce Richardson  *
198699a2dd95SBruce Richardson  * An array of this structure is returned by rte_eth_xstats_get_names().
198799a2dd95SBruce Richardson  * It lists the names of extended statistics for a PMD. The *rte_eth_xstat*
198899a2dd95SBruce Richardson  * structure references these names by their array index.
198999a2dd95SBruce Richardson  *
199099a2dd95SBruce Richardson  * The xstats should follow a common naming scheme.
199199a2dd95SBruce Richardson  * Some names are standardized in rte_stats_strings.
199299a2dd95SBruce Richardson  * Examples:
199399a2dd95SBruce Richardson  *     - rx_missed_errors
199499a2dd95SBruce Richardson  *     - tx_q3_bytes
199599a2dd95SBruce Richardson  *     - tx_size_128_to_255_packets
199699a2dd95SBruce Richardson  */
199799a2dd95SBruce Richardson struct rte_eth_xstat_name {
199899a2dd95SBruce Richardson 	char name[RTE_ETH_XSTATS_NAME_SIZE]; /**< The statistic name. */
199999a2dd95SBruce Richardson };
200099a2dd95SBruce Richardson 
2001295968d1SFerruh Yigit #define RTE_ETH_DCB_NUM_TCS    8
2002295968d1SFerruh Yigit #define RTE_ETH_MAX_VMDQ_POOL  64
2003b1cb3035SFerruh Yigit 
2004b1cb3035SFerruh Yigit #define ETH_DCB_NUM_TCS   RTE_DEPRECATED(ETH_DCB_NUM_TCS)   RTE_ETH_DCB_NUM_TCS
2005b1cb3035SFerruh Yigit #define ETH_MAX_VMDQ_POOL RTE_DEPRECATED(ETH_MAX_VMDQ_POOL) RTE_ETH_MAX_VMDQ_POOL
200699a2dd95SBruce Richardson 
200799a2dd95SBruce Richardson /**
200899a2dd95SBruce Richardson  * A structure used to get the information of queue and
200909fd4227SAndrew Rybchenko  * TC mapping on both Tx and Rx paths.
201099a2dd95SBruce Richardson  */
201199a2dd95SBruce Richardson struct rte_eth_dcb_tc_queue_mapping {
201209fd4227SAndrew Rybchenko 	/** Rx queues assigned to tc per Pool */
201399a2dd95SBruce Richardson 	struct {
201499a2dd95SBruce Richardson 		uint16_t base;
201599a2dd95SBruce Richardson 		uint16_t nb_queue;
2016295968d1SFerruh Yigit 	} tc_rxq[RTE_ETH_MAX_VMDQ_POOL][RTE_ETH_DCB_NUM_TCS];
201709fd4227SAndrew Rybchenko 	/** Rx queues assigned to tc per Pool */
201899a2dd95SBruce Richardson 	struct {
201999a2dd95SBruce Richardson 		uint16_t base;
202099a2dd95SBruce Richardson 		uint16_t nb_queue;
2021295968d1SFerruh Yigit 	} tc_txq[RTE_ETH_MAX_VMDQ_POOL][RTE_ETH_DCB_NUM_TCS];
202299a2dd95SBruce Richardson };
202399a2dd95SBruce Richardson 
202499a2dd95SBruce Richardson /**
202599a2dd95SBruce Richardson  * A structure used to get the information of DCB.
202699a2dd95SBruce Richardson  * It includes TC UP mapping and queue TC mapping.
202799a2dd95SBruce Richardson  */
202899a2dd95SBruce Richardson struct rte_eth_dcb_info {
202999a2dd95SBruce Richardson 	uint8_t nb_tcs;        /**< number of TCs */
2030295968d1SFerruh Yigit 	uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES]; /**< Priority to tc */
2031295968d1SFerruh Yigit 	uint8_t tc_bws[RTE_ETH_DCB_NUM_TCS]; /**< Tx BW percentage for each TC */
203209fd4227SAndrew Rybchenko 	/** Rx queues assigned to tc */
203399a2dd95SBruce Richardson 	struct rte_eth_dcb_tc_queue_mapping tc_queue;
203499a2dd95SBruce Richardson };
203599a2dd95SBruce Richardson 
203699a2dd95SBruce Richardson /**
203799a2dd95SBruce Richardson  * This enum indicates the possible Forward Error Correction (FEC) modes
203899a2dd95SBruce Richardson  * of an ethdev port.
203999a2dd95SBruce Richardson  */
204099a2dd95SBruce Richardson enum rte_eth_fec_mode {
204199a2dd95SBruce Richardson 	RTE_ETH_FEC_NOFEC = 0,      /**< FEC is off */
204299a2dd95SBruce Richardson 	RTE_ETH_FEC_AUTO,	    /**< FEC autonegotiation modes */
204399a2dd95SBruce Richardson 	RTE_ETH_FEC_BASER,          /**< FEC using common algorithm */
204499a2dd95SBruce Richardson 	RTE_ETH_FEC_RS,             /**< FEC using RS algorithm */
204599a2dd95SBruce Richardson };
204699a2dd95SBruce Richardson 
204799a2dd95SBruce Richardson /* Translate from FEC mode to FEC capa */
2048e1823e08SThomas Monjalon #define RTE_ETH_FEC_MODE_TO_CAPA(x) RTE_BIT32(x)
204999a2dd95SBruce Richardson 
205099a2dd95SBruce Richardson /* This macro indicates FEC capa mask */
2051e1823e08SThomas Monjalon #define RTE_ETH_FEC_MODE_CAPA_MASK(x) RTE_BIT32(RTE_ETH_FEC_ ## x)
205299a2dd95SBruce Richardson 
205399a2dd95SBruce Richardson /* A structure used to get capabilities per link speed */
205499a2dd95SBruce Richardson struct rte_eth_fec_capa {
2055295968d1SFerruh Yigit 	uint32_t speed; /**< Link speed (see RTE_ETH_SPEED_NUM_*) */
205699a2dd95SBruce Richardson 	uint32_t capa;  /**< FEC capabilities bitmask */
205799a2dd95SBruce Richardson };
205899a2dd95SBruce Richardson 
205999a2dd95SBruce Richardson #define RTE_ETH_ALL RTE_MAX_ETHPORTS
206099a2dd95SBruce Richardson 
206199a2dd95SBruce Richardson /* Macros to check for valid port */
206299a2dd95SBruce Richardson #define RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, retval) do { \
206399a2dd95SBruce Richardson 	if (!rte_eth_dev_is_valid_port(port_id)) { \
206499a2dd95SBruce Richardson 		RTE_ETHDEV_LOG(ERR, "Invalid port_id=%u\n", port_id); \
206599a2dd95SBruce Richardson 		return retval; \
206699a2dd95SBruce Richardson 	} \
206799a2dd95SBruce Richardson } while (0)
206899a2dd95SBruce Richardson 
206999a2dd95SBruce Richardson #define RTE_ETH_VALID_PORTID_OR_RET(port_id) do { \
207099a2dd95SBruce Richardson 	if (!rte_eth_dev_is_valid_port(port_id)) { \
207199a2dd95SBruce Richardson 		RTE_ETHDEV_LOG(ERR, "Invalid port_id=%u\n", port_id); \
207299a2dd95SBruce Richardson 		return; \
207399a2dd95SBruce Richardson 	} \
207499a2dd95SBruce Richardson } while (0)
207599a2dd95SBruce Richardson 
207699a2dd95SBruce Richardson /**
207709fd4227SAndrew Rybchenko  * Function type used for Rx packet processing packet callbacks.
207899a2dd95SBruce Richardson  *
207909fd4227SAndrew Rybchenko  * The callback function is called on Rx with a burst of packets that have
208099a2dd95SBruce Richardson  * been received on the given port and queue.
208199a2dd95SBruce Richardson  *
208299a2dd95SBruce Richardson  * @param port_id
208309fd4227SAndrew Rybchenko  *   The Ethernet port on which Rx is being performed.
208499a2dd95SBruce Richardson  * @param queue
208599a2dd95SBruce Richardson  *   The queue on the Ethernet port which is being used to receive the packets.
208699a2dd95SBruce Richardson  * @param pkts
208799a2dd95SBruce Richardson  *   The burst of packets that have just been received.
208899a2dd95SBruce Richardson  * @param nb_pkts
208999a2dd95SBruce Richardson  *   The number of packets in the burst pointed to by "pkts".
209099a2dd95SBruce Richardson  * @param max_pkts
209199a2dd95SBruce Richardson  *   The max number of packets that can be stored in the "pkts" array.
209299a2dd95SBruce Richardson  * @param user_param
209399a2dd95SBruce Richardson  *   The arbitrary user parameter passed in by the application when the callback
209499a2dd95SBruce Richardson  *   was originally configured.
209599a2dd95SBruce Richardson  * @return
209699a2dd95SBruce Richardson  *   The number of packets returned to the user.
209799a2dd95SBruce Richardson  */
209899a2dd95SBruce Richardson typedef uint16_t (*rte_rx_callback_fn)(uint16_t port_id, uint16_t queue,
209999a2dd95SBruce Richardson 	struct rte_mbuf *pkts[], uint16_t nb_pkts, uint16_t max_pkts,
210099a2dd95SBruce Richardson 	void *user_param);
210199a2dd95SBruce Richardson 
210299a2dd95SBruce Richardson /**
210309fd4227SAndrew Rybchenko  * Function type used for Tx packet processing packet callbacks.
210499a2dd95SBruce Richardson  *
210509fd4227SAndrew Rybchenko  * The callback function is called on Tx with a burst of packets immediately
210699a2dd95SBruce Richardson  * before the packets are put onto the hardware queue for transmission.
210799a2dd95SBruce Richardson  *
210899a2dd95SBruce Richardson  * @param port_id
210909fd4227SAndrew Rybchenko  *   The Ethernet port on which Tx is being performed.
211099a2dd95SBruce Richardson  * @param queue
211199a2dd95SBruce Richardson  *   The queue on the Ethernet port which is being used to transmit the packets.
211299a2dd95SBruce Richardson  * @param pkts
211399a2dd95SBruce Richardson  *   The burst of packets that are about to be transmitted.
211499a2dd95SBruce Richardson  * @param nb_pkts
211599a2dd95SBruce Richardson  *   The number of packets in the burst pointed to by "pkts".
211699a2dd95SBruce Richardson  * @param user_param
211799a2dd95SBruce Richardson  *   The arbitrary user parameter passed in by the application when the callback
211899a2dd95SBruce Richardson  *   was originally configured.
211999a2dd95SBruce Richardson  * @return
212099a2dd95SBruce Richardson  *   The number of packets to be written to the NIC.
212199a2dd95SBruce Richardson  */
212299a2dd95SBruce Richardson typedef uint16_t (*rte_tx_callback_fn)(uint16_t port_id, uint16_t queue,
212399a2dd95SBruce Richardson 	struct rte_mbuf *pkts[], uint16_t nb_pkts, void *user_param);
212499a2dd95SBruce Richardson 
212599a2dd95SBruce Richardson /**
212699a2dd95SBruce Richardson  * Possible states of an ethdev port.
212799a2dd95SBruce Richardson  */
212899a2dd95SBruce Richardson enum rte_eth_dev_state {
212999a2dd95SBruce Richardson 	/** Device is unused before being probed. */
213099a2dd95SBruce Richardson 	RTE_ETH_DEV_UNUSED = 0,
213199a2dd95SBruce Richardson 	/** Device is attached when allocated in probing. */
213299a2dd95SBruce Richardson 	RTE_ETH_DEV_ATTACHED,
213399a2dd95SBruce Richardson 	/** Device is in removed state when plug-out is detected. */
213499a2dd95SBruce Richardson 	RTE_ETH_DEV_REMOVED,
213599a2dd95SBruce Richardson };
213699a2dd95SBruce Richardson 
213799a2dd95SBruce Richardson struct rte_eth_dev_sriov {
213899a2dd95SBruce Richardson 	uint8_t active;               /**< SRIOV is active with 16, 32 or 64 pools */
213909fd4227SAndrew Rybchenko 	uint8_t nb_q_per_pool;        /**< Rx queue number per pool */
214099a2dd95SBruce Richardson 	uint16_t def_vmdq_idx;        /**< Default pool num used for PF */
214199a2dd95SBruce Richardson 	uint16_t def_pool_q_idx;      /**< Default pool queue start reg index */
214299a2dd95SBruce Richardson };
214399a2dd95SBruce Richardson #define RTE_ETH_DEV_SRIOV(dev)         ((dev)->data->sriov)
214499a2dd95SBruce Richardson 
214599a2dd95SBruce Richardson #define RTE_ETH_NAME_MAX_LEN RTE_DEV_NAME_MAX_LEN
214699a2dd95SBruce Richardson 
214799a2dd95SBruce Richardson #define RTE_ETH_DEV_NO_OWNER 0
214899a2dd95SBruce Richardson 
214999a2dd95SBruce Richardson #define RTE_ETH_MAX_OWNER_NAME_LEN 64
215099a2dd95SBruce Richardson 
215199a2dd95SBruce Richardson struct rte_eth_dev_owner {
215299a2dd95SBruce Richardson 	uint64_t id; /**< The owner unique identifier. */
215399a2dd95SBruce Richardson 	char name[RTE_ETH_MAX_OWNER_NAME_LEN]; /**< The owner name. */
215499a2dd95SBruce Richardson };
215599a2dd95SBruce Richardson 
21560ce56b05SThomas Monjalon /**@{@name Device flags
21570ce56b05SThomas Monjalon  * Flags internally saved in rte_eth_dev_data.dev_flags
21580ce56b05SThomas Monjalon  * and reported in rte_eth_dev_info.dev_flags.
21590ce56b05SThomas Monjalon  */
216099a2dd95SBruce Richardson /** PMD supports thread-safe flow operations */
21614852c647SAndrew Rybchenko #define RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE  RTE_BIT32(0)
216299a2dd95SBruce Richardson /** Device supports link state interrupt */
21634852c647SAndrew Rybchenko #define RTE_ETH_DEV_INTR_LSC              RTE_BIT32(1)
216499a2dd95SBruce Richardson /** Device is a bonded slave */
21654852c647SAndrew Rybchenko #define RTE_ETH_DEV_BONDED_SLAVE          RTE_BIT32(2)
216699a2dd95SBruce Richardson /** Device supports device removal interrupt */
21674852c647SAndrew Rybchenko #define RTE_ETH_DEV_INTR_RMV              RTE_BIT32(3)
216899a2dd95SBruce Richardson /** Device is port representor */
21694852c647SAndrew Rybchenko #define RTE_ETH_DEV_REPRESENTOR           RTE_BIT32(4)
217099a2dd95SBruce Richardson /** Device does not support MAC change after started */
21714852c647SAndrew Rybchenko #define RTE_ETH_DEV_NOLIVE_MAC_ADDR       RTE_BIT32(5)
217299a2dd95SBruce Richardson /**
217399a2dd95SBruce Richardson  * Queue xstats filled automatically by ethdev layer.
217499a2dd95SBruce Richardson  * PMDs filling the queue xstats themselves should not set this flag
217599a2dd95SBruce Richardson  */
21764852c647SAndrew Rybchenko #define RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS RTE_BIT32(6)
21770ce56b05SThomas Monjalon /**@}*/
217899a2dd95SBruce Richardson 
217999a2dd95SBruce Richardson /**
218099a2dd95SBruce Richardson  * Iterates over valid ethdev ports owned by a specific owner.
218199a2dd95SBruce Richardson  *
218299a2dd95SBruce Richardson  * @param port_id
21835906be5aSAndrew Rybchenko  *   The ID of the next possible valid owned port.
218499a2dd95SBruce Richardson  * @param	owner_id
218599a2dd95SBruce Richardson  *  The owner identifier.
218699a2dd95SBruce Richardson  *  RTE_ETH_DEV_NO_OWNER means iterate over all valid ownerless ports.
218799a2dd95SBruce Richardson  * @return
21885906be5aSAndrew Rybchenko  *   Next valid port ID owned by owner_id, RTE_MAX_ETHPORTS if there is none.
218999a2dd95SBruce Richardson  */
219099a2dd95SBruce Richardson uint64_t rte_eth_find_next_owned_by(uint16_t port_id,
219199a2dd95SBruce Richardson 		const uint64_t owner_id);
219299a2dd95SBruce Richardson 
219399a2dd95SBruce Richardson /**
219499a2dd95SBruce Richardson  * Macro to iterate over all enabled ethdev ports owned by a specific owner.
219599a2dd95SBruce Richardson  */
219699a2dd95SBruce Richardson #define RTE_ETH_FOREACH_DEV_OWNED_BY(p, o) \
219799a2dd95SBruce Richardson 	for (p = rte_eth_find_next_owned_by(0, o); \
219899a2dd95SBruce Richardson 	     (unsigned int)p < (unsigned int)RTE_MAX_ETHPORTS; \
219999a2dd95SBruce Richardson 	     p = rte_eth_find_next_owned_by(p + 1, o))
220099a2dd95SBruce Richardson 
220199a2dd95SBruce Richardson /**
220299a2dd95SBruce Richardson  * Iterates over valid ethdev ports.
220399a2dd95SBruce Richardson  *
220499a2dd95SBruce Richardson  * @param port_id
22055906be5aSAndrew Rybchenko  *   The ID of the next possible valid port.
220699a2dd95SBruce Richardson  * @return
22075906be5aSAndrew Rybchenko  *   Next valid port ID, RTE_MAX_ETHPORTS if there is none.
220899a2dd95SBruce Richardson  */
220999a2dd95SBruce Richardson uint16_t rte_eth_find_next(uint16_t port_id);
221099a2dd95SBruce Richardson 
221199a2dd95SBruce Richardson /**
221299a2dd95SBruce Richardson  * Macro to iterate over all enabled and ownerless ethdev ports.
221399a2dd95SBruce Richardson  */
221499a2dd95SBruce Richardson #define RTE_ETH_FOREACH_DEV(p) \
221599a2dd95SBruce Richardson 	RTE_ETH_FOREACH_DEV_OWNED_BY(p, RTE_ETH_DEV_NO_OWNER)
221699a2dd95SBruce Richardson 
221799a2dd95SBruce Richardson /**
221899a2dd95SBruce Richardson  * Iterates over ethdev ports of a specified device.
221999a2dd95SBruce Richardson  *
222099a2dd95SBruce Richardson  * @param port_id_start
22215906be5aSAndrew Rybchenko  *   The ID of the next possible valid port.
222299a2dd95SBruce Richardson  * @param parent
222399a2dd95SBruce Richardson  *   The generic device behind the ports to iterate.
222499a2dd95SBruce Richardson  * @return
22255906be5aSAndrew Rybchenko  *   Next port ID of the device, possibly port_id_start,
222699a2dd95SBruce Richardson  *   RTE_MAX_ETHPORTS if there is none.
222799a2dd95SBruce Richardson  */
222899a2dd95SBruce Richardson uint16_t
222999a2dd95SBruce Richardson rte_eth_find_next_of(uint16_t port_id_start,
223099a2dd95SBruce Richardson 		const struct rte_device *parent);
223199a2dd95SBruce Richardson 
223299a2dd95SBruce Richardson /**
223399a2dd95SBruce Richardson  * Macro to iterate over all ethdev ports of a specified device.
223499a2dd95SBruce Richardson  *
223599a2dd95SBruce Richardson  * @param port_id
22365906be5aSAndrew Rybchenko  *   The ID of the matching port being iterated.
223799a2dd95SBruce Richardson  * @param parent
223899a2dd95SBruce Richardson  *   The rte_device pointer matching the iterated ports.
223999a2dd95SBruce Richardson  */
224099a2dd95SBruce Richardson #define RTE_ETH_FOREACH_DEV_OF(port_id, parent) \
224199a2dd95SBruce Richardson 	for (port_id = rte_eth_find_next_of(0, parent); \
224299a2dd95SBruce Richardson 		port_id < RTE_MAX_ETHPORTS; \
224399a2dd95SBruce Richardson 		port_id = rte_eth_find_next_of(port_id + 1, parent))
224499a2dd95SBruce Richardson 
224599a2dd95SBruce Richardson /**
224699a2dd95SBruce Richardson  * Iterates over sibling ethdev ports (i.e. sharing the same rte_device).
224799a2dd95SBruce Richardson  *
224899a2dd95SBruce Richardson  * @param port_id_start
22495906be5aSAndrew Rybchenko  *   The ID of the next possible valid sibling port.
225099a2dd95SBruce Richardson  * @param ref_port_id
22515906be5aSAndrew Rybchenko  *   The ID of a reference port to compare rte_device with.
225299a2dd95SBruce Richardson  * @return
22535906be5aSAndrew Rybchenko  *   Next sibling port ID, possibly port_id_start or ref_port_id itself,
225499a2dd95SBruce Richardson  *   RTE_MAX_ETHPORTS if there is none.
225599a2dd95SBruce Richardson  */
225699a2dd95SBruce Richardson uint16_t
225799a2dd95SBruce Richardson rte_eth_find_next_sibling(uint16_t port_id_start, uint16_t ref_port_id);
225899a2dd95SBruce Richardson 
225999a2dd95SBruce Richardson /**
226099a2dd95SBruce Richardson  * Macro to iterate over all ethdev ports sharing the same rte_device
226199a2dd95SBruce Richardson  * as the specified port.
226299a2dd95SBruce Richardson  * Note: the specified reference port is part of the loop iterations.
226399a2dd95SBruce Richardson  *
226499a2dd95SBruce Richardson  * @param port_id
22655906be5aSAndrew Rybchenko  *   The ID of the matching port being iterated.
226699a2dd95SBruce Richardson  * @param ref_port_id
22675906be5aSAndrew Rybchenko  *   The ID of the port being compared.
226899a2dd95SBruce Richardson  */
226999a2dd95SBruce Richardson #define RTE_ETH_FOREACH_DEV_SIBLING(port_id, ref_port_id) \
227099a2dd95SBruce Richardson 	for (port_id = rte_eth_find_next_sibling(0, ref_port_id); \
227199a2dd95SBruce Richardson 		port_id < RTE_MAX_ETHPORTS; \
227299a2dd95SBruce Richardson 		port_id = rte_eth_find_next_sibling(port_id + 1, ref_port_id))
227399a2dd95SBruce Richardson 
227499a2dd95SBruce Richardson /**
227599a2dd95SBruce Richardson  * @warning
227699a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
227799a2dd95SBruce Richardson  *
227899a2dd95SBruce Richardson  * Get a new unique owner identifier.
227999a2dd95SBruce Richardson  * An owner identifier is used to owns Ethernet devices by only one DPDK entity
228099a2dd95SBruce Richardson  * to avoid multiple management of device by different entities.
228199a2dd95SBruce Richardson  *
228299a2dd95SBruce Richardson  * @param	owner_id
228399a2dd95SBruce Richardson  *   Owner identifier pointer.
228499a2dd95SBruce Richardson  * @return
228599a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
228699a2dd95SBruce Richardson  */
228799a2dd95SBruce Richardson __rte_experimental
228899a2dd95SBruce Richardson int rte_eth_dev_owner_new(uint64_t *owner_id);
228999a2dd95SBruce Richardson 
229099a2dd95SBruce Richardson /**
229199a2dd95SBruce Richardson  * @warning
229299a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
229399a2dd95SBruce Richardson  *
229499a2dd95SBruce Richardson  * Set an Ethernet device owner.
229599a2dd95SBruce Richardson  *
229699a2dd95SBruce Richardson  * @param	port_id
229799a2dd95SBruce Richardson  *  The identifier of the port to own.
229899a2dd95SBruce Richardson  * @param	owner
229999a2dd95SBruce Richardson  *  The owner pointer.
230099a2dd95SBruce Richardson  * @return
230199a2dd95SBruce Richardson  *  Negative errno value on error, 0 on success.
230299a2dd95SBruce Richardson  */
230399a2dd95SBruce Richardson __rte_experimental
230499a2dd95SBruce Richardson int rte_eth_dev_owner_set(const uint16_t port_id,
230599a2dd95SBruce Richardson 		const struct rte_eth_dev_owner *owner);
230699a2dd95SBruce Richardson 
230799a2dd95SBruce Richardson /**
230899a2dd95SBruce Richardson  * @warning
230999a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
231099a2dd95SBruce Richardson  *
231199a2dd95SBruce Richardson  * Unset Ethernet device owner to make the device ownerless.
231299a2dd95SBruce Richardson  *
231399a2dd95SBruce Richardson  * @param	port_id
231499a2dd95SBruce Richardson  *  The identifier of port to make ownerless.
231599a2dd95SBruce Richardson  * @param	owner_id
231699a2dd95SBruce Richardson  *  The owner identifier.
231799a2dd95SBruce Richardson  * @return
231899a2dd95SBruce Richardson  *  0 on success, negative errno value on error.
231999a2dd95SBruce Richardson  */
232099a2dd95SBruce Richardson __rte_experimental
232199a2dd95SBruce Richardson int rte_eth_dev_owner_unset(const uint16_t port_id,
232299a2dd95SBruce Richardson 		const uint64_t owner_id);
232399a2dd95SBruce Richardson 
232499a2dd95SBruce Richardson /**
232599a2dd95SBruce Richardson  * @warning
232699a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
232799a2dd95SBruce Richardson  *
232899a2dd95SBruce Richardson  * Remove owner from all Ethernet devices owned by a specific owner.
232999a2dd95SBruce Richardson  *
233099a2dd95SBruce Richardson  * @param	owner_id
233199a2dd95SBruce Richardson  *  The owner identifier.
233299a2dd95SBruce Richardson  * @return
233399a2dd95SBruce Richardson  *  0 on success, negative errno value on error.
233499a2dd95SBruce Richardson  */
233599a2dd95SBruce Richardson __rte_experimental
233699a2dd95SBruce Richardson int rte_eth_dev_owner_delete(const uint64_t owner_id);
233799a2dd95SBruce Richardson 
233899a2dd95SBruce Richardson /**
233999a2dd95SBruce Richardson  * @warning
234099a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
234199a2dd95SBruce Richardson  *
234299a2dd95SBruce Richardson  * Get the owner of an Ethernet device.
234399a2dd95SBruce Richardson  *
234499a2dd95SBruce Richardson  * @param	port_id
234599a2dd95SBruce Richardson  *  The port identifier.
234699a2dd95SBruce Richardson  * @param	owner
234799a2dd95SBruce Richardson  *  The owner structure pointer to fill.
234899a2dd95SBruce Richardson  * @return
234999a2dd95SBruce Richardson  *  0 on success, negative errno value on error..
235099a2dd95SBruce Richardson  */
235199a2dd95SBruce Richardson __rte_experimental
235299a2dd95SBruce Richardson int rte_eth_dev_owner_get(const uint16_t port_id,
235399a2dd95SBruce Richardson 		struct rte_eth_dev_owner *owner);
235499a2dd95SBruce Richardson 
235599a2dd95SBruce Richardson /**
235699a2dd95SBruce Richardson  * Get the number of ports which are usable for the application.
235799a2dd95SBruce Richardson  *
235899a2dd95SBruce Richardson  * These devices must be iterated by using the macro
235999a2dd95SBruce Richardson  * ``RTE_ETH_FOREACH_DEV`` or ``RTE_ETH_FOREACH_DEV_OWNED_BY``
236099a2dd95SBruce Richardson  * to deal with non-contiguous ranges of devices.
236199a2dd95SBruce Richardson  *
236299a2dd95SBruce Richardson  * @return
236399a2dd95SBruce Richardson  *   The count of available Ethernet devices.
236499a2dd95SBruce Richardson  */
236599a2dd95SBruce Richardson uint16_t rte_eth_dev_count_avail(void);
236699a2dd95SBruce Richardson 
236799a2dd95SBruce Richardson /**
236899a2dd95SBruce Richardson  * Get the total number of ports which are allocated.
236999a2dd95SBruce Richardson  *
237099a2dd95SBruce Richardson  * Some devices may not be available for the application.
237199a2dd95SBruce Richardson  *
237299a2dd95SBruce Richardson  * @return
237399a2dd95SBruce Richardson  *   The total count of Ethernet devices.
237499a2dd95SBruce Richardson  */
237599a2dd95SBruce Richardson uint16_t rte_eth_dev_count_total(void);
237699a2dd95SBruce Richardson 
237799a2dd95SBruce Richardson /**
237899a2dd95SBruce Richardson  * Convert a numerical speed in Mbps to a bitmap flag that can be used in
237999a2dd95SBruce Richardson  * the bitmap link_speeds of the struct rte_eth_conf
238099a2dd95SBruce Richardson  *
238199a2dd95SBruce Richardson  * @param speed
238299a2dd95SBruce Richardson  *   Numerical speed value in Mbps
238399a2dd95SBruce Richardson  * @param duplex
2384295968d1SFerruh Yigit  *   RTE_ETH_LINK_[HALF/FULL]_DUPLEX (only for 10/100M speeds)
238599a2dd95SBruce Richardson  * @return
238699a2dd95SBruce Richardson  *   0 if the speed cannot be mapped
238799a2dd95SBruce Richardson  */
238899a2dd95SBruce Richardson uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex);
238999a2dd95SBruce Richardson 
239099a2dd95SBruce Richardson /**
2391295968d1SFerruh Yigit  * Get RTE_ETH_RX_OFFLOAD_* flag name.
239299a2dd95SBruce Richardson  *
239399a2dd95SBruce Richardson  * @param offload
239499a2dd95SBruce Richardson  *   Offload flag.
239599a2dd95SBruce Richardson  * @return
239699a2dd95SBruce Richardson  *   Offload name or 'UNKNOWN' if the flag cannot be recognised.
239799a2dd95SBruce Richardson  */
239899a2dd95SBruce Richardson const char *rte_eth_dev_rx_offload_name(uint64_t offload);
239999a2dd95SBruce Richardson 
240099a2dd95SBruce Richardson /**
2401295968d1SFerruh Yigit  * Get RTE_ETH_TX_OFFLOAD_* flag name.
240299a2dd95SBruce Richardson  *
240399a2dd95SBruce Richardson  * @param offload
240499a2dd95SBruce Richardson  *   Offload flag.
240599a2dd95SBruce Richardson  * @return
240699a2dd95SBruce Richardson  *   Offload name or 'UNKNOWN' if the flag cannot be recognised.
240799a2dd95SBruce Richardson  */
240899a2dd95SBruce Richardson const char *rte_eth_dev_tx_offload_name(uint64_t offload);
240999a2dd95SBruce Richardson 
241099a2dd95SBruce Richardson /**
241193e441c9SXueming Li  * @warning
241293e441c9SXueming Li  * @b EXPERIMENTAL: this API may change without prior notice.
241393e441c9SXueming Li  *
241493e441c9SXueming Li  * Get RTE_ETH_DEV_CAPA_* flag name.
241593e441c9SXueming Li  *
241693e441c9SXueming Li  * @param capability
241793e441c9SXueming Li  *   Capability flag.
241893e441c9SXueming Li  * @return
241993e441c9SXueming Li  *   Capability name or 'UNKNOWN' if the flag cannot be recognized.
242093e441c9SXueming Li  */
242193e441c9SXueming Li __rte_experimental
242293e441c9SXueming Li const char *rte_eth_dev_capability_name(uint64_t capability);
242393e441c9SXueming Li 
242493e441c9SXueming Li /**
242599a2dd95SBruce Richardson  * Configure an Ethernet device.
242699a2dd95SBruce Richardson  * This function must be invoked first before any other function in the
242799a2dd95SBruce Richardson  * Ethernet API. This function can also be re-invoked when a device is in the
242899a2dd95SBruce Richardson  * stopped state.
242999a2dd95SBruce Richardson  *
243099a2dd95SBruce Richardson  * @param port_id
243199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device to configure.
243299a2dd95SBruce Richardson  * @param nb_rx_queue
243399a2dd95SBruce Richardson  *   The number of receive queues to set up for the Ethernet device.
243499a2dd95SBruce Richardson  * @param nb_tx_queue
243599a2dd95SBruce Richardson  *   The number of transmit queues to set up for the Ethernet device.
243699a2dd95SBruce Richardson  * @param eth_conf
243799a2dd95SBruce Richardson  *   The pointer to the configuration data to be used for the Ethernet device.
243899a2dd95SBruce Richardson  *   The *rte_eth_conf* structure includes:
243999a2dd95SBruce Richardson  *     -  the hardware offload features to activate, with dedicated fields for
244099a2dd95SBruce Richardson  *        each statically configurable offload hardware feature provided by
244199a2dd95SBruce Richardson  *        Ethernet devices, such as IP checksum or VLAN tag stripping for
244299a2dd95SBruce Richardson  *        example.
244399a2dd95SBruce Richardson  *        The Rx offload bitfield API is obsolete and will be deprecated.
244499a2dd95SBruce Richardson  *        Applications should set the ignore_bitfield_offloads bit on *rxmode*
244599a2dd95SBruce Richardson  *        structure and use offloads field to set per-port offloads instead.
244699a2dd95SBruce Richardson  *     -  Any offloading set in eth_conf->[rt]xmode.offloads must be within
244799a2dd95SBruce Richardson  *        the [rt]x_offload_capa returned from rte_eth_dev_info_get().
244899a2dd95SBruce Richardson  *        Any type of device supported offloading set in the input argument
244999a2dd95SBruce Richardson  *        eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is enabled
245099a2dd95SBruce Richardson  *        on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup()
245109fd4227SAndrew Rybchenko  *     -  the Receive Side Scaling (RSS) configuration when using multiple Rx
245299a2dd95SBruce Richardson  *        queues per port. Any RSS hash function set in eth_conf->rss_conf.rss_hf
245399a2dd95SBruce Richardson  *        must be within the flow_type_rss_offloads provided by drivers via
245499a2dd95SBruce Richardson  *        rte_eth_dev_info_get() API.
245599a2dd95SBruce Richardson  *
245699a2dd95SBruce Richardson  *   Embedding all configuration information in a single data structure
245799a2dd95SBruce Richardson  *   is the more flexible method that allows the addition of new features
245899a2dd95SBruce Richardson  *   without changing the syntax of the API.
245999a2dd95SBruce Richardson  * @return
246099a2dd95SBruce Richardson  *   - 0: Success, device configured.
246199a2dd95SBruce Richardson  *   - <0: Error code returned by the driver configuration function.
246299a2dd95SBruce Richardson  */
246399a2dd95SBruce Richardson int rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_queue,
246499a2dd95SBruce Richardson 		uint16_t nb_tx_queue, const struct rte_eth_conf *eth_conf);
246599a2dd95SBruce Richardson 
246699a2dd95SBruce Richardson /**
246799a2dd95SBruce Richardson  * Check if an Ethernet device was physically removed.
246899a2dd95SBruce Richardson  *
246999a2dd95SBruce Richardson  * @param port_id
247099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
247199a2dd95SBruce Richardson  * @return
247299a2dd95SBruce Richardson  *   1 when the Ethernet device is removed, otherwise 0.
247399a2dd95SBruce Richardson  */
247499a2dd95SBruce Richardson int
247599a2dd95SBruce Richardson rte_eth_dev_is_removed(uint16_t port_id);
247699a2dd95SBruce Richardson 
247799a2dd95SBruce Richardson /**
247899a2dd95SBruce Richardson  * Allocate and set up a receive queue for an Ethernet device.
247999a2dd95SBruce Richardson  *
248099a2dd95SBruce Richardson  * The function allocates a contiguous block of memory for *nb_rx_desc*
248199a2dd95SBruce Richardson  * receive descriptors from a memory zone associated with *socket_id*
248299a2dd95SBruce Richardson  * and initializes each receive descriptor with a network buffer allocated
248399a2dd95SBruce Richardson  * from the memory pool *mb_pool*.
248499a2dd95SBruce Richardson  *
248599a2dd95SBruce Richardson  * @param port_id
248699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
248799a2dd95SBruce Richardson  * @param rx_queue_id
248899a2dd95SBruce Richardson  *   The index of the receive queue to set up.
248999a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
249099a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
249199a2dd95SBruce Richardson  * @param nb_rx_desc
249299a2dd95SBruce Richardson  *   The number of receive descriptors to allocate for the receive ring.
249399a2dd95SBruce Richardson  * @param socket_id
249499a2dd95SBruce Richardson  *   The *socket_id* argument is the socket identifier in case of NUMA.
249599a2dd95SBruce Richardson  *   The value can be *SOCKET_ID_ANY* if there is no NUMA constraint for
249699a2dd95SBruce Richardson  *   the DMA memory allocated for the receive descriptors of the ring.
249799a2dd95SBruce Richardson  * @param rx_conf
249899a2dd95SBruce Richardson  *   The pointer to the configuration data to be used for the receive queue.
249909fd4227SAndrew Rybchenko  *   NULL value is allowed, in which case default Rx configuration
250099a2dd95SBruce Richardson  *   will be used.
250199a2dd95SBruce Richardson  *   The *rx_conf* structure contains an *rx_thresh* structure with the values
250299a2dd95SBruce Richardson  *   of the Prefetch, Host, and Write-Back threshold registers of the receive
250399a2dd95SBruce Richardson  *   ring.
250499a2dd95SBruce Richardson  *   In addition it contains the hardware offloads features to activate using
2505295968d1SFerruh Yigit  *   the RTE_ETH_RX_OFFLOAD_* flags.
250699a2dd95SBruce Richardson  *   If an offloading set in rx_conf->offloads
250799a2dd95SBruce Richardson  *   hasn't been set in the input argument eth_conf->rxmode.offloads
250899a2dd95SBruce Richardson  *   to rte_eth_dev_configure(), it is a new added offloading, it must be
250999a2dd95SBruce Richardson  *   per-queue type and it is enabled for the queue.
251099a2dd95SBruce Richardson  *   No need to repeat any bit in rx_conf->offloads which has already been
251199a2dd95SBruce Richardson  *   enabled in rte_eth_dev_configure() at port level. An offloading enabled
251299a2dd95SBruce Richardson  *   at port level can't be disabled at queue level.
251399a2dd95SBruce Richardson  *   The configuration structure also contains the pointer to the array
251499a2dd95SBruce Richardson  *   of the receiving buffer segment descriptions, see rx_seg and rx_nseg
251599a2dd95SBruce Richardson  *   fields, this extended configuration might be used by split offloads like
251697d7b927SJoyce Kong  *   RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT. If mb_pool is not NULL,
251799a2dd95SBruce Richardson  *   the extended configuration fields must be set to NULL and zero.
251899a2dd95SBruce Richardson  * @param mb_pool
251999a2dd95SBruce Richardson  *   The pointer to the memory pool from which to allocate *rte_mbuf* network
252099a2dd95SBruce Richardson  *   memory buffers to populate each descriptor of the receive ring. There are
252199a2dd95SBruce Richardson  *   two options to provide Rx buffer configuration:
252299a2dd95SBruce Richardson  *   - single pool:
252399a2dd95SBruce Richardson  *     mb_pool is not NULL, rx_conf.rx_nseg is 0.
252499a2dd95SBruce Richardson  *   - multiple segments description:
252599a2dd95SBruce Richardson  *     mb_pool is NULL, rx_conf.rx_seg is not NULL, rx_conf.rx_nseg is not 0.
252699a2dd95SBruce Richardson  *     Taken only if flag RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is set in offloads.
252799a2dd95SBruce Richardson  *
252899a2dd95SBruce Richardson  * @return
252999a2dd95SBruce Richardson  *   - 0: Success, receive queue correctly set up.
253099a2dd95SBruce Richardson  *   - -EIO: if device is removed.
253199a2dd95SBruce Richardson  *   - -ENODEV: if *port_id* is invalid.
253299a2dd95SBruce Richardson  *   - -EINVAL: The memory pool pointer is null or the size of network buffers
253399a2dd95SBruce Richardson  *      which can be allocated from this memory pool does not fit the various
253499a2dd95SBruce Richardson  *      buffer sizes allowed by the device controller.
253599a2dd95SBruce Richardson  *   - -ENOMEM: Unable to allocate the receive ring descriptors or to
253699a2dd95SBruce Richardson  *      allocate network memory buffers from the memory pool when
253799a2dd95SBruce Richardson  *      initializing receive descriptors.
253899a2dd95SBruce Richardson  */
253999a2dd95SBruce Richardson int rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
254099a2dd95SBruce Richardson 		uint16_t nb_rx_desc, unsigned int socket_id,
254199a2dd95SBruce Richardson 		const struct rte_eth_rxconf *rx_conf,
254299a2dd95SBruce Richardson 		struct rte_mempool *mb_pool);
254399a2dd95SBruce Richardson 
254499a2dd95SBruce Richardson /**
254599a2dd95SBruce Richardson  * @warning
254699a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
254799a2dd95SBruce Richardson  *
254899a2dd95SBruce Richardson  * Allocate and set up a hairpin receive queue for an Ethernet device.
254999a2dd95SBruce Richardson  *
255099a2dd95SBruce Richardson  * The function set up the selected queue to be used in hairpin.
255199a2dd95SBruce Richardson  *
255299a2dd95SBruce Richardson  * @param port_id
255399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
255499a2dd95SBruce Richardson  * @param rx_queue_id
255599a2dd95SBruce Richardson  *   The index of the receive queue to set up.
255699a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
255799a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
255899a2dd95SBruce Richardson  * @param nb_rx_desc
255999a2dd95SBruce Richardson  *   The number of receive descriptors to allocate for the receive ring.
256099a2dd95SBruce Richardson  *   0 means the PMD will use default value.
256199a2dd95SBruce Richardson  * @param conf
256299a2dd95SBruce Richardson  *   The pointer to the hairpin configuration.
256399a2dd95SBruce Richardson  *
256499a2dd95SBruce Richardson  * @return
256599a2dd95SBruce Richardson  *   - (0) if successful.
256699a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
256799a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
256899a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
256999a2dd95SBruce Richardson  *   - (-ENOMEM) if unable to allocate the resources.
257099a2dd95SBruce Richardson  */
257199a2dd95SBruce Richardson __rte_experimental
257299a2dd95SBruce Richardson int rte_eth_rx_hairpin_queue_setup
257399a2dd95SBruce Richardson 	(uint16_t port_id, uint16_t rx_queue_id, uint16_t nb_rx_desc,
257499a2dd95SBruce Richardson 	 const struct rte_eth_hairpin_conf *conf);
257599a2dd95SBruce Richardson 
257699a2dd95SBruce Richardson /**
257799a2dd95SBruce Richardson  * Allocate and set up a transmit queue for an Ethernet device.
257899a2dd95SBruce Richardson  *
257999a2dd95SBruce Richardson  * @param port_id
258099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
258199a2dd95SBruce Richardson  * @param tx_queue_id
258299a2dd95SBruce Richardson  *   The index of the transmit queue to set up.
258399a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
258499a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
258599a2dd95SBruce Richardson  * @param nb_tx_desc
258699a2dd95SBruce Richardson  *   The number of transmit descriptors to allocate for the transmit ring.
258799a2dd95SBruce Richardson  * @param socket_id
258899a2dd95SBruce Richardson  *   The *socket_id* argument is the socket identifier in case of NUMA.
258999a2dd95SBruce Richardson  *   Its value can be *SOCKET_ID_ANY* if there is no NUMA constraint for
259099a2dd95SBruce Richardson  *   the DMA memory allocated for the transmit descriptors of the ring.
259199a2dd95SBruce Richardson  * @param tx_conf
259299a2dd95SBruce Richardson  *   The pointer to the configuration data to be used for the transmit queue.
259309fd4227SAndrew Rybchenko  *   NULL value is allowed, in which case default Tx configuration
259499a2dd95SBruce Richardson  *   will be used.
259599a2dd95SBruce Richardson  *   The *tx_conf* structure contains the following data:
259699a2dd95SBruce Richardson  *   - The *tx_thresh* structure with the values of the Prefetch, Host, and
259799a2dd95SBruce Richardson  *     Write-Back threshold registers of the transmit ring.
259899a2dd95SBruce Richardson  *     When setting Write-Back threshold to the value greater then zero,
259999a2dd95SBruce Richardson  *     *tx_rs_thresh* value should be explicitly set to one.
260099a2dd95SBruce Richardson  *   - The *tx_free_thresh* value indicates the [minimum] number of network
260199a2dd95SBruce Richardson  *     buffers that must be pending in the transmit ring to trigger their
260299a2dd95SBruce Richardson  *     [implicit] freeing by the driver transmit function.
260399a2dd95SBruce Richardson  *   - The *tx_rs_thresh* value indicates the [minimum] number of transmit
260499a2dd95SBruce Richardson  *     descriptors that must be pending in the transmit ring before setting the
260599a2dd95SBruce Richardson  *     RS bit on a descriptor by the driver transmit function.
260699a2dd95SBruce Richardson  *     The *tx_rs_thresh* value should be less or equal then
260799a2dd95SBruce Richardson  *     *tx_free_thresh* value, and both of them should be less then
260899a2dd95SBruce Richardson  *     *nb_tx_desc* - 3.
260999a2dd95SBruce Richardson  *   - The *offloads* member contains Tx offloads to be enabled.
261099a2dd95SBruce Richardson  *     If an offloading set in tx_conf->offloads
261199a2dd95SBruce Richardson  *     hasn't been set in the input argument eth_conf->txmode.offloads
261299a2dd95SBruce Richardson  *     to rte_eth_dev_configure(), it is a new added offloading, it must be
261399a2dd95SBruce Richardson  *     per-queue type and it is enabled for the queue.
261499a2dd95SBruce Richardson  *     No need to repeat any bit in tx_conf->offloads which has already been
261599a2dd95SBruce Richardson  *     enabled in rte_eth_dev_configure() at port level. An offloading enabled
261699a2dd95SBruce Richardson  *     at port level can't be disabled at queue level.
261799a2dd95SBruce Richardson  *
261899a2dd95SBruce Richardson  *     Note that setting *tx_free_thresh* or *tx_rs_thresh* value to 0 forces
261999a2dd95SBruce Richardson  *     the transmit function to use default values.
262099a2dd95SBruce Richardson  * @return
262199a2dd95SBruce Richardson  *   - 0: Success, the transmit queue is correctly set up.
262299a2dd95SBruce Richardson  *   - -ENOMEM: Unable to allocate the transmit ring descriptors.
262399a2dd95SBruce Richardson  */
262499a2dd95SBruce Richardson int rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
262599a2dd95SBruce Richardson 		uint16_t nb_tx_desc, unsigned int socket_id,
262699a2dd95SBruce Richardson 		const struct rte_eth_txconf *tx_conf);
262799a2dd95SBruce Richardson 
262899a2dd95SBruce Richardson /**
262999a2dd95SBruce Richardson  * @warning
263099a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
263199a2dd95SBruce Richardson  *
263299a2dd95SBruce Richardson  * Allocate and set up a transmit hairpin queue for an Ethernet device.
263399a2dd95SBruce Richardson  *
263499a2dd95SBruce Richardson  * @param port_id
263599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
263699a2dd95SBruce Richardson  * @param tx_queue_id
263799a2dd95SBruce Richardson  *   The index of the transmit queue to set up.
263899a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
263999a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
264099a2dd95SBruce Richardson  * @param nb_tx_desc
264199a2dd95SBruce Richardson  *   The number of transmit descriptors to allocate for the transmit ring.
264299a2dd95SBruce Richardson  *   0 to set default PMD value.
264399a2dd95SBruce Richardson  * @param conf
264499a2dd95SBruce Richardson  *   The hairpin configuration.
264599a2dd95SBruce Richardson  *
264699a2dd95SBruce Richardson  * @return
264799a2dd95SBruce Richardson  *   - (0) if successful.
264899a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
264999a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
265099a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
265199a2dd95SBruce Richardson  *   - (-ENOMEM) if unable to allocate the resources.
265299a2dd95SBruce Richardson  */
265399a2dd95SBruce Richardson __rte_experimental
265499a2dd95SBruce Richardson int rte_eth_tx_hairpin_queue_setup
265599a2dd95SBruce Richardson 	(uint16_t port_id, uint16_t tx_queue_id, uint16_t nb_tx_desc,
265699a2dd95SBruce Richardson 	 const struct rte_eth_hairpin_conf *conf);
265799a2dd95SBruce Richardson 
265899a2dd95SBruce Richardson /**
265999a2dd95SBruce Richardson  * @warning
266099a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
266199a2dd95SBruce Richardson  *
266299a2dd95SBruce Richardson  * Get all the hairpin peer Rx / Tx ports of the current port.
266399a2dd95SBruce Richardson  * The caller should ensure that the array is large enough to save the ports
266499a2dd95SBruce Richardson  * list.
266599a2dd95SBruce Richardson  *
266699a2dd95SBruce Richardson  * @param port_id
266799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
266899a2dd95SBruce Richardson  * @param peer_ports
266999a2dd95SBruce Richardson  *   Pointer to the array to store the peer ports list.
267099a2dd95SBruce Richardson  * @param len
267199a2dd95SBruce Richardson  *   Length of the array to store the port identifiers.
267299a2dd95SBruce Richardson  * @param direction
267399a2dd95SBruce Richardson  *   Current port to peer port direction
267499a2dd95SBruce Richardson  *   positive - current used as Tx to get all peer Rx ports.
267599a2dd95SBruce Richardson  *   zero - current used as Rx to get all peer Tx ports.
267699a2dd95SBruce Richardson  *
267799a2dd95SBruce Richardson  * @return
267899a2dd95SBruce Richardson  *   - (0 or positive) actual peer ports number.
267999a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
268099a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid
268199a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
2682f8dbaebbSSean Morrissey  *   - Others detailed errors from PMDs.
268399a2dd95SBruce Richardson  */
268499a2dd95SBruce Richardson __rte_experimental
268599a2dd95SBruce Richardson int rte_eth_hairpin_get_peer_ports(uint16_t port_id, uint16_t *peer_ports,
268699a2dd95SBruce Richardson 				   size_t len, uint32_t direction);
268799a2dd95SBruce Richardson 
268899a2dd95SBruce Richardson /**
268999a2dd95SBruce Richardson  * @warning
269099a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
269199a2dd95SBruce Richardson  *
269299a2dd95SBruce Richardson  * Bind all hairpin Tx queues of one port to the Rx queues of the peer port.
269399a2dd95SBruce Richardson  * It is only allowed to call this function after all hairpin queues are
269499a2dd95SBruce Richardson  * configured properly and the devices are in started state.
269599a2dd95SBruce Richardson  *
269699a2dd95SBruce Richardson  * @param tx_port
269799a2dd95SBruce Richardson  *   The identifier of the Tx port.
269899a2dd95SBruce Richardson  * @param rx_port
269999a2dd95SBruce Richardson  *   The identifier of peer Rx port.
270099a2dd95SBruce Richardson  *   RTE_MAX_ETHPORTS is allowed for the traversal of all devices.
270199a2dd95SBruce Richardson  *   Rx port ID could have the same value as Tx port ID.
270299a2dd95SBruce Richardson  *
270399a2dd95SBruce Richardson  * @return
270499a2dd95SBruce Richardson  *   - (0) if successful.
270599a2dd95SBruce Richardson  *   - (-ENODEV) if Tx port ID is invalid.
270699a2dd95SBruce Richardson  *   - (-EBUSY) if device is not in started state.
270799a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
2708f8dbaebbSSean Morrissey  *   - Others detailed errors from PMDs.
270999a2dd95SBruce Richardson  */
271099a2dd95SBruce Richardson __rte_experimental
271199a2dd95SBruce Richardson int rte_eth_hairpin_bind(uint16_t tx_port, uint16_t rx_port);
271299a2dd95SBruce Richardson 
271399a2dd95SBruce Richardson /**
271499a2dd95SBruce Richardson  * @warning
271599a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
271699a2dd95SBruce Richardson  *
271799a2dd95SBruce Richardson  * Unbind all hairpin Tx queues of one port from the Rx queues of the peer port.
271899a2dd95SBruce Richardson  * This should be called before closing the Tx or Rx devices, if the bind
271999a2dd95SBruce Richardson  * function is called before.
272099a2dd95SBruce Richardson  * After unbinding the hairpin ports pair, it is allowed to bind them again.
272199a2dd95SBruce Richardson  * Changing queues configuration should be after stopping the device(s).
272299a2dd95SBruce Richardson  *
272399a2dd95SBruce Richardson  * @param tx_port
272499a2dd95SBruce Richardson  *   The identifier of the Tx port.
272599a2dd95SBruce Richardson  * @param rx_port
272699a2dd95SBruce Richardson  *   The identifier of peer Rx port.
272799a2dd95SBruce Richardson  *   RTE_MAX_ETHPORTS is allowed for traversal of all devices.
272899a2dd95SBruce Richardson  *   Rx port ID could have the same value as Tx port ID.
272999a2dd95SBruce Richardson  *
273099a2dd95SBruce Richardson  * @return
273199a2dd95SBruce Richardson  *   - (0) if successful.
273299a2dd95SBruce Richardson  *   - (-ENODEV) if Tx port ID is invalid.
273399a2dd95SBruce Richardson  *   - (-EBUSY) if device is in stopped state.
273499a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
2735f8dbaebbSSean Morrissey  *   - Others detailed errors from PMDs.
273699a2dd95SBruce Richardson  */
273799a2dd95SBruce Richardson __rte_experimental
273899a2dd95SBruce Richardson int rte_eth_hairpin_unbind(uint16_t tx_port, uint16_t rx_port);
273999a2dd95SBruce Richardson 
274099a2dd95SBruce Richardson /**
274199a2dd95SBruce Richardson  * Return the NUMA socket to which an Ethernet device is connected
274299a2dd95SBruce Richardson  *
274399a2dd95SBruce Richardson  * @param port_id
274499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device
274599a2dd95SBruce Richardson  * @return
27465906be5aSAndrew Rybchenko  *   The NUMA socket ID to which the Ethernet device is connected or
274799a2dd95SBruce Richardson  *   a default of zero if the socket could not be determined.
274899a2dd95SBruce Richardson  *   -1 is returned is the port_id value is out of range.
274999a2dd95SBruce Richardson  */
275099a2dd95SBruce Richardson int rte_eth_dev_socket_id(uint16_t port_id);
275199a2dd95SBruce Richardson 
275299a2dd95SBruce Richardson /**
275399a2dd95SBruce Richardson  * Check if port_id of device is attached
275499a2dd95SBruce Richardson  *
275599a2dd95SBruce Richardson  * @param port_id
275699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device
275799a2dd95SBruce Richardson  * @return
275899a2dd95SBruce Richardson  *   - 0 if port is out of range or not attached
275999a2dd95SBruce Richardson  *   - 1 if device is attached
276099a2dd95SBruce Richardson  */
276199a2dd95SBruce Richardson int rte_eth_dev_is_valid_port(uint16_t port_id);
276299a2dd95SBruce Richardson 
276399a2dd95SBruce Richardson /**
276409fd4227SAndrew Rybchenko  * Start specified Rx queue of a port. It is used when rx_deferred_start
276599a2dd95SBruce Richardson  * flag of the specified queue is true.
276699a2dd95SBruce Richardson  *
276799a2dd95SBruce Richardson  * @param port_id
276899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device
276999a2dd95SBruce Richardson  * @param rx_queue_id
277009fd4227SAndrew Rybchenko  *   The index of the Rx queue to update the ring.
277199a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
277299a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
277399a2dd95SBruce Richardson  * @return
277499a2dd95SBruce Richardson  *   - 0: Success, the receive queue is started.
277599a2dd95SBruce Richardson  *   - -ENODEV: if *port_id* is invalid.
277699a2dd95SBruce Richardson  *   - -EINVAL: The queue_id out of range or belong to hairpin.
277799a2dd95SBruce Richardson  *   - -EIO: if device is removed.
2778f8dbaebbSSean Morrissey  *   - -ENOTSUP: The function not supported in PMD.
277999a2dd95SBruce Richardson  */
278099a2dd95SBruce Richardson int rte_eth_dev_rx_queue_start(uint16_t port_id, uint16_t rx_queue_id);
278199a2dd95SBruce Richardson 
278299a2dd95SBruce Richardson /**
278309fd4227SAndrew Rybchenko  * Stop specified Rx queue of a port
278499a2dd95SBruce Richardson  *
278599a2dd95SBruce Richardson  * @param port_id
278699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device
278799a2dd95SBruce Richardson  * @param rx_queue_id
278809fd4227SAndrew Rybchenko  *   The index of the Rx queue to update the ring.
278999a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
279099a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
279199a2dd95SBruce Richardson  * @return
279299a2dd95SBruce Richardson  *   - 0: Success, the receive queue is stopped.
279399a2dd95SBruce Richardson  *   - -ENODEV: if *port_id* is invalid.
279499a2dd95SBruce Richardson  *   - -EINVAL: The queue_id out of range or belong to hairpin.
279599a2dd95SBruce Richardson  *   - -EIO: if device is removed.
2796f8dbaebbSSean Morrissey  *   - -ENOTSUP: The function not supported in PMD.
279799a2dd95SBruce Richardson  */
279899a2dd95SBruce Richardson int rte_eth_dev_rx_queue_stop(uint16_t port_id, uint16_t rx_queue_id);
279999a2dd95SBruce Richardson 
280099a2dd95SBruce Richardson /**
280109fd4227SAndrew Rybchenko  * Start Tx for specified queue of a port. It is used when tx_deferred_start
280299a2dd95SBruce Richardson  * flag of the specified queue is true.
280399a2dd95SBruce Richardson  *
280499a2dd95SBruce Richardson  * @param port_id
280599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device
280699a2dd95SBruce Richardson  * @param tx_queue_id
280709fd4227SAndrew Rybchenko  *   The index of the Tx queue to update the ring.
280899a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
280999a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
281099a2dd95SBruce Richardson  * @return
281199a2dd95SBruce Richardson  *   - 0: Success, the transmit queue is started.
281299a2dd95SBruce Richardson  *   - -ENODEV: if *port_id* is invalid.
281399a2dd95SBruce Richardson  *   - -EINVAL: The queue_id out of range or belong to hairpin.
281499a2dd95SBruce Richardson  *   - -EIO: if device is removed.
2815f8dbaebbSSean Morrissey  *   - -ENOTSUP: The function not supported in PMD.
281699a2dd95SBruce Richardson  */
281799a2dd95SBruce Richardson int rte_eth_dev_tx_queue_start(uint16_t port_id, uint16_t tx_queue_id);
281899a2dd95SBruce Richardson 
281999a2dd95SBruce Richardson /**
282009fd4227SAndrew Rybchenko  * Stop specified Tx queue of a port
282199a2dd95SBruce Richardson  *
282299a2dd95SBruce Richardson  * @param port_id
282399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device
282499a2dd95SBruce Richardson  * @param tx_queue_id
282509fd4227SAndrew Rybchenko  *   The index of the Tx queue to update the ring.
282699a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
282799a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
282899a2dd95SBruce Richardson  * @return
282999a2dd95SBruce Richardson  *   - 0: Success, the transmit queue is stopped.
283099a2dd95SBruce Richardson  *   - -ENODEV: if *port_id* is invalid.
283199a2dd95SBruce Richardson  *   - -EINVAL: The queue_id out of range or belong to hairpin.
283299a2dd95SBruce Richardson  *   - -EIO: if device is removed.
2833f8dbaebbSSean Morrissey  *   - -ENOTSUP: The function not supported in PMD.
283499a2dd95SBruce Richardson  */
283599a2dd95SBruce Richardson int rte_eth_dev_tx_queue_stop(uint16_t port_id, uint16_t tx_queue_id);
283699a2dd95SBruce Richardson 
283799a2dd95SBruce Richardson /**
283899a2dd95SBruce Richardson  * Start an Ethernet device.
283999a2dd95SBruce Richardson  *
284099a2dd95SBruce Richardson  * The device start step is the last one and consists of setting the configured
284199a2dd95SBruce Richardson  * offload features and in starting the transmit and the receive units of the
284299a2dd95SBruce Richardson  * device.
284399a2dd95SBruce Richardson  *
284499a2dd95SBruce Richardson  * Device RTE_ETH_DEV_NOLIVE_MAC_ADDR flag causes MAC address to be set before
284599a2dd95SBruce Richardson  * PMD port start callback function is invoked.
284699a2dd95SBruce Richardson  *
284799a2dd95SBruce Richardson  * On success, all basic functions exported by the Ethernet API (link status,
284899a2dd95SBruce Richardson  * receive/transmit, and so on) can be invoked.
284999a2dd95SBruce Richardson  *
285099a2dd95SBruce Richardson  * @param port_id
285199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
285299a2dd95SBruce Richardson  * @return
285399a2dd95SBruce Richardson  *   - 0: Success, Ethernet device started.
285499a2dd95SBruce Richardson  *   - <0: Error code of the driver device start function.
285599a2dd95SBruce Richardson  */
285699a2dd95SBruce Richardson int rte_eth_dev_start(uint16_t port_id);
285799a2dd95SBruce Richardson 
285899a2dd95SBruce Richardson /**
285999a2dd95SBruce Richardson  * Stop an Ethernet device. The device can be restarted with a call to
286099a2dd95SBruce Richardson  * rte_eth_dev_start()
286199a2dd95SBruce Richardson  *
286299a2dd95SBruce Richardson  * @param port_id
286399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
286499a2dd95SBruce Richardson  * @return
286599a2dd95SBruce Richardson  *   - 0: Success, Ethernet device stopped.
286699a2dd95SBruce Richardson  *   - <0: Error code of the driver device stop function.
286799a2dd95SBruce Richardson  */
286899a2dd95SBruce Richardson int rte_eth_dev_stop(uint16_t port_id);
286999a2dd95SBruce Richardson 
287099a2dd95SBruce Richardson /**
287199a2dd95SBruce Richardson  * Link up an Ethernet device.
287299a2dd95SBruce Richardson  *
287309fd4227SAndrew Rybchenko  * Set device link up will re-enable the device Rx/Tx
287499a2dd95SBruce Richardson  * functionality after it is previously set device linked down.
287599a2dd95SBruce Richardson  *
287699a2dd95SBruce Richardson  * @param port_id
287799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
287899a2dd95SBruce Richardson  * @return
287999a2dd95SBruce Richardson  *   - 0: Success, Ethernet device linked up.
288099a2dd95SBruce Richardson  *   - <0: Error code of the driver device link up function.
288199a2dd95SBruce Richardson  */
288299a2dd95SBruce Richardson int rte_eth_dev_set_link_up(uint16_t port_id);
288399a2dd95SBruce Richardson 
288499a2dd95SBruce Richardson /**
288599a2dd95SBruce Richardson  * Link down an Ethernet device.
288609fd4227SAndrew Rybchenko  * The device Rx/Tx functionality will be disabled if success,
288799a2dd95SBruce Richardson  * and it can be re-enabled with a call to
288899a2dd95SBruce Richardson  * rte_eth_dev_set_link_up()
288999a2dd95SBruce Richardson  *
289099a2dd95SBruce Richardson  * @param port_id
289199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
289299a2dd95SBruce Richardson  */
289399a2dd95SBruce Richardson int rte_eth_dev_set_link_down(uint16_t port_id);
289499a2dd95SBruce Richardson 
289599a2dd95SBruce Richardson /**
289699a2dd95SBruce Richardson  * Close a stopped Ethernet device. The device cannot be restarted!
289799a2dd95SBruce Richardson  * The function frees all port resources.
289899a2dd95SBruce Richardson  *
289999a2dd95SBruce Richardson  * @param port_id
290099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
290199a2dd95SBruce Richardson  * @return
290299a2dd95SBruce Richardson  *   - Zero if the port is closed successfully.
290399a2dd95SBruce Richardson  *   - Negative if something went wrong.
290499a2dd95SBruce Richardson  */
290599a2dd95SBruce Richardson int rte_eth_dev_close(uint16_t port_id);
290699a2dd95SBruce Richardson 
290799a2dd95SBruce Richardson /**
29085906be5aSAndrew Rybchenko  * Reset a Ethernet device and keep its port ID.
290999a2dd95SBruce Richardson  *
291099a2dd95SBruce Richardson  * When a port has to be reset passively, the DPDK application can invoke
291199a2dd95SBruce Richardson  * this function. For example when a PF is reset, all its VFs should also
291299a2dd95SBruce Richardson  * be reset. Normally a DPDK application can invoke this function when
291399a2dd95SBruce Richardson  * RTE_ETH_EVENT_INTR_RESET event is detected, but can also use it to start
291499a2dd95SBruce Richardson  * a port reset in other circumstances.
291599a2dd95SBruce Richardson  *
291699a2dd95SBruce Richardson  * When this function is called, it first stops the port and then calls the
291799a2dd95SBruce Richardson  * PMD specific dev_uninit( ) and dev_init( ) to return the port to initial
291899a2dd95SBruce Richardson  * state, in which no Tx and Rx queues are setup, as if the port has been
29195906be5aSAndrew Rybchenko  * reset and not started. The port keeps the port ID it had before the
292099a2dd95SBruce Richardson  * function call.
292199a2dd95SBruce Richardson  *
292299a2dd95SBruce Richardson  * After calling rte_eth_dev_reset( ), the application should use
292399a2dd95SBruce Richardson  * rte_eth_dev_configure( ), rte_eth_rx_queue_setup( ),
292499a2dd95SBruce Richardson  * rte_eth_tx_queue_setup( ), and rte_eth_dev_start( )
292599a2dd95SBruce Richardson  * to reconfigure the device as appropriate.
292699a2dd95SBruce Richardson  *
292799a2dd95SBruce Richardson  * Note: To avoid unexpected behavior, the application should stop calling
292899a2dd95SBruce Richardson  * Tx and Rx functions before calling rte_eth_dev_reset( ). For thread
292999a2dd95SBruce Richardson  * safety, all these controlling functions should be called from the same
293099a2dd95SBruce Richardson  * thread.
293199a2dd95SBruce Richardson  *
293299a2dd95SBruce Richardson  * @param port_id
293399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
293499a2dd95SBruce Richardson  *
293599a2dd95SBruce Richardson  * @return
293699a2dd95SBruce Richardson  *   - (0) if successful.
293799a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
293899a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support this function.
293999a2dd95SBruce Richardson  *   - (-EPERM) if not ran from the primary process.
294099a2dd95SBruce Richardson  *   - (-EIO) if re-initialisation failed or device is removed.
294199a2dd95SBruce Richardson  *   - (-ENOMEM) if the reset failed due to OOM.
294299a2dd95SBruce Richardson  *   - (-EAGAIN) if the reset temporarily failed and should be retried later.
294399a2dd95SBruce Richardson  */
294499a2dd95SBruce Richardson int rte_eth_dev_reset(uint16_t port_id);
294599a2dd95SBruce Richardson 
294699a2dd95SBruce Richardson /**
294799a2dd95SBruce Richardson  * Enable receipt in promiscuous mode for an Ethernet device.
294899a2dd95SBruce Richardson  *
294999a2dd95SBruce Richardson  * @param port_id
295099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
295199a2dd95SBruce Richardson  * @return
295299a2dd95SBruce Richardson  *   - (0) if successful.
295399a2dd95SBruce Richardson  *   - (-ENOTSUP) if support for promiscuous_enable() does not exist
295499a2dd95SBruce Richardson  *     for the device.
295599a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
295699a2dd95SBruce Richardson  */
295799a2dd95SBruce Richardson int rte_eth_promiscuous_enable(uint16_t port_id);
295899a2dd95SBruce Richardson 
295999a2dd95SBruce Richardson /**
296099a2dd95SBruce Richardson  * Disable receipt in promiscuous mode for an Ethernet device.
296199a2dd95SBruce Richardson  *
296299a2dd95SBruce Richardson  * @param port_id
296399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
296499a2dd95SBruce Richardson  * @return
296599a2dd95SBruce Richardson  *   - (0) if successful.
296699a2dd95SBruce Richardson  *   - (-ENOTSUP) if support for promiscuous_disable() does not exist
296799a2dd95SBruce Richardson  *     for the device.
296899a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
296999a2dd95SBruce Richardson  */
297099a2dd95SBruce Richardson int rte_eth_promiscuous_disable(uint16_t port_id);
297199a2dd95SBruce Richardson 
297299a2dd95SBruce Richardson /**
297399a2dd95SBruce Richardson  * Return the value of promiscuous mode for an Ethernet device.
297499a2dd95SBruce Richardson  *
297599a2dd95SBruce Richardson  * @param port_id
297699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
297799a2dd95SBruce Richardson  * @return
297899a2dd95SBruce Richardson  *   - (1) if promiscuous is enabled
297999a2dd95SBruce Richardson  *   - (0) if promiscuous is disabled.
298099a2dd95SBruce Richardson  *   - (-1) on error
298199a2dd95SBruce Richardson  */
298299a2dd95SBruce Richardson int rte_eth_promiscuous_get(uint16_t port_id);
298399a2dd95SBruce Richardson 
298499a2dd95SBruce Richardson /**
298599a2dd95SBruce Richardson  * Enable the receipt of any multicast frame by an Ethernet device.
298699a2dd95SBruce Richardson  *
298799a2dd95SBruce Richardson  * @param port_id
298899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
298999a2dd95SBruce Richardson  * @return
299099a2dd95SBruce Richardson  *   - (0) if successful.
299199a2dd95SBruce Richardson  *   - (-ENOTSUP) if support for allmulticast_enable() does not exist
299299a2dd95SBruce Richardson  *     for the device.
299399a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
299499a2dd95SBruce Richardson  */
299599a2dd95SBruce Richardson int rte_eth_allmulticast_enable(uint16_t port_id);
299699a2dd95SBruce Richardson 
299799a2dd95SBruce Richardson /**
299899a2dd95SBruce Richardson  * Disable the receipt of all multicast frames by an Ethernet device.
299999a2dd95SBruce Richardson  *
300099a2dd95SBruce Richardson  * @param port_id
300199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
300299a2dd95SBruce Richardson  * @return
300399a2dd95SBruce Richardson  *   - (0) if successful.
300499a2dd95SBruce Richardson  *   - (-ENOTSUP) if support for allmulticast_disable() does not exist
300599a2dd95SBruce Richardson  *     for the device.
300699a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
300799a2dd95SBruce Richardson  */
300899a2dd95SBruce Richardson int rte_eth_allmulticast_disable(uint16_t port_id);
300999a2dd95SBruce Richardson 
301099a2dd95SBruce Richardson /**
301199a2dd95SBruce Richardson  * Return the value of allmulticast mode for an Ethernet device.
301299a2dd95SBruce Richardson  *
301399a2dd95SBruce Richardson  * @param port_id
301499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
301599a2dd95SBruce Richardson  * @return
301699a2dd95SBruce Richardson  *   - (1) if allmulticast is enabled
301799a2dd95SBruce Richardson  *   - (0) if allmulticast is disabled.
301899a2dd95SBruce Richardson  *   - (-1) on error
301999a2dd95SBruce Richardson  */
302099a2dd95SBruce Richardson int rte_eth_allmulticast_get(uint16_t port_id);
302199a2dd95SBruce Richardson 
302299a2dd95SBruce Richardson /**
302399a2dd95SBruce Richardson  * Retrieve the link status (up/down), the duplex mode (half/full),
302499a2dd95SBruce Richardson  * the negotiation (auto/fixed), and if available, the speed (Mbps).
302599a2dd95SBruce Richardson  *
302699a2dd95SBruce Richardson  * It might need to wait up to 9 seconds.
302799a2dd95SBruce Richardson  * @see rte_eth_link_get_nowait.
302899a2dd95SBruce Richardson  *
302999a2dd95SBruce Richardson  * @param port_id
303099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
303199a2dd95SBruce Richardson  * @param link
303299a2dd95SBruce Richardson  *   Link information written back.
303399a2dd95SBruce Richardson  * @return
303499a2dd95SBruce Richardson  *   - (0) if successful.
3035f8dbaebbSSean Morrissey  *   - (-ENOTSUP) if the function is not supported in PMD.
303699a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
303753ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
303899a2dd95SBruce Richardson  */
303999a2dd95SBruce Richardson int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link);
304099a2dd95SBruce Richardson 
304199a2dd95SBruce Richardson /**
304299a2dd95SBruce Richardson  * Retrieve the link status (up/down), the duplex mode (half/full),
304399a2dd95SBruce Richardson  * the negotiation (auto/fixed), and if available, the speed (Mbps).
304499a2dd95SBruce Richardson  *
304599a2dd95SBruce Richardson  * @param port_id
304699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
304799a2dd95SBruce Richardson  * @param link
304899a2dd95SBruce Richardson  *   Link information written back.
304999a2dd95SBruce Richardson  * @return
305099a2dd95SBruce Richardson  *   - (0) if successful.
3051f8dbaebbSSean Morrissey  *   - (-ENOTSUP) if the function is not supported in PMD.
305299a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
305353ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
305499a2dd95SBruce Richardson  */
305599a2dd95SBruce Richardson int rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *link);
305699a2dd95SBruce Richardson 
305799a2dd95SBruce Richardson /**
305899a2dd95SBruce Richardson  * @warning
305999a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
306099a2dd95SBruce Richardson  *
306199a2dd95SBruce Richardson  * The function converts a link_speed to a string. It handles all special
306299a2dd95SBruce Richardson  * values like unknown or none speed.
306399a2dd95SBruce Richardson  *
306499a2dd95SBruce Richardson  * @param link_speed
306599a2dd95SBruce Richardson  *   link_speed of rte_eth_link struct
306699a2dd95SBruce Richardson  * @return
306799a2dd95SBruce Richardson  *   Link speed in textual format. It's pointer to immutable memory.
306899a2dd95SBruce Richardson  *   No free is required.
306999a2dd95SBruce Richardson  */
307099a2dd95SBruce Richardson __rte_experimental
307199a2dd95SBruce Richardson const char *rte_eth_link_speed_to_str(uint32_t link_speed);
307299a2dd95SBruce Richardson 
307399a2dd95SBruce Richardson /**
307499a2dd95SBruce Richardson  * @warning
307599a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
307699a2dd95SBruce Richardson  *
307799a2dd95SBruce Richardson  * The function converts a rte_eth_link struct representing a link status to
307899a2dd95SBruce Richardson  * a string.
307999a2dd95SBruce Richardson  *
308099a2dd95SBruce Richardson  * @param str
308199a2dd95SBruce Richardson  *   A pointer to a string to be filled with textual representation of
3082295968d1SFerruh Yigit  *   device status. At least RTE_ETH_LINK_MAX_STR_LEN bytes should be allocated to
308399a2dd95SBruce Richardson  *   store default link status text.
308499a2dd95SBruce Richardson  * @param len
308599a2dd95SBruce Richardson  *   Length of available memory at 'str' string.
308699a2dd95SBruce Richardson  * @param eth_link
308799a2dd95SBruce Richardson  *   Link status returned by rte_eth_link_get function
308899a2dd95SBruce Richardson  * @return
308953ef1b34SMin Hu (Connor)  *   Number of bytes written to str array or -EINVAL if bad parameter.
309099a2dd95SBruce Richardson  */
309199a2dd95SBruce Richardson __rte_experimental
309299a2dd95SBruce Richardson int rte_eth_link_to_str(char *str, size_t len,
309399a2dd95SBruce Richardson 			const struct rte_eth_link *eth_link);
309499a2dd95SBruce Richardson 
309599a2dd95SBruce Richardson /**
309699a2dd95SBruce Richardson  * Retrieve the general I/O statistics of an Ethernet device.
309799a2dd95SBruce Richardson  *
309899a2dd95SBruce Richardson  * @param port_id
309999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
310099a2dd95SBruce Richardson  * @param stats
310199a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_eth_stats* to be filled with
310299a2dd95SBruce Richardson  *   the values of device counters for the following set of statistics:
310399a2dd95SBruce Richardson  *   - *ipackets* with the total of successfully received packets.
310499a2dd95SBruce Richardson  *   - *opackets* with the total of successfully transmitted packets.
310599a2dd95SBruce Richardson  *   - *ibytes*   with the total of successfully received bytes.
310699a2dd95SBruce Richardson  *   - *obytes*   with the total of successfully transmitted bytes.
310799a2dd95SBruce Richardson  *   - *ierrors*  with the total of erroneous received packets.
310899a2dd95SBruce Richardson  *   - *oerrors*  with the total of failed transmitted packets.
310999a2dd95SBruce Richardson  * @return
311099a2dd95SBruce Richardson  *   Zero if successful. Non-zero otherwise.
311199a2dd95SBruce Richardson  */
311299a2dd95SBruce Richardson int rte_eth_stats_get(uint16_t port_id, struct rte_eth_stats *stats);
311399a2dd95SBruce Richardson 
311499a2dd95SBruce Richardson /**
311599a2dd95SBruce Richardson  * Reset the general I/O statistics of an Ethernet device.
311699a2dd95SBruce Richardson  *
311799a2dd95SBruce Richardson  * @param port_id
311899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
311999a2dd95SBruce Richardson  * @return
312099a2dd95SBruce Richardson  *   - (0) if device notified to reset stats.
312199a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
312299a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
312399a2dd95SBruce Richardson  *   - (<0): Error code of the driver stats reset function.
312499a2dd95SBruce Richardson  */
312599a2dd95SBruce Richardson int rte_eth_stats_reset(uint16_t port_id);
312699a2dd95SBruce Richardson 
312799a2dd95SBruce Richardson /**
312899a2dd95SBruce Richardson  * Retrieve names of extended statistics of an Ethernet device.
312999a2dd95SBruce Richardson  *
313099a2dd95SBruce Richardson  * There is an assumption that 'xstat_names' and 'xstats' arrays are matched
313199a2dd95SBruce Richardson  * by array index:
313299a2dd95SBruce Richardson  *  xstats_names[i].name => xstats[i].value
313399a2dd95SBruce Richardson  *
313499a2dd95SBruce Richardson  * And the array index is same with id field of 'struct rte_eth_xstat':
313599a2dd95SBruce Richardson  *  xstats[i].id == i
313699a2dd95SBruce Richardson  *
313799a2dd95SBruce Richardson  * This assumption makes key-value pair matching less flexible but simpler.
313899a2dd95SBruce Richardson  *
313999a2dd95SBruce Richardson  * @param port_id
314099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
314199a2dd95SBruce Richardson  * @param xstats_names
314299a2dd95SBruce Richardson  *   An rte_eth_xstat_name array of at least *size* elements to
314399a2dd95SBruce Richardson  *   be filled. If set to NULL, the function returns the required number
314499a2dd95SBruce Richardson  *   of elements.
314599a2dd95SBruce Richardson  * @param size
314699a2dd95SBruce Richardson  *   The size of the xstats_names array (number of elements).
314799a2dd95SBruce Richardson  * @return
314899a2dd95SBruce Richardson  *   - A positive value lower or equal to size: success. The return value
314999a2dd95SBruce Richardson  *     is the number of entries filled in the stats table.
315099a2dd95SBruce Richardson  *   - A positive value higher than size: error, the given statistics table
315199a2dd95SBruce Richardson  *     is too small. The return value corresponds to the size that should
315299a2dd95SBruce Richardson  *     be given to succeed. The entries in the table are not valid and
315399a2dd95SBruce Richardson  *     shall not be used by the caller.
31545906be5aSAndrew Rybchenko  *   - A negative value on error (invalid port ID).
315599a2dd95SBruce Richardson  */
315699a2dd95SBruce Richardson int rte_eth_xstats_get_names(uint16_t port_id,
315799a2dd95SBruce Richardson 		struct rte_eth_xstat_name *xstats_names,
315899a2dd95SBruce Richardson 		unsigned int size);
315999a2dd95SBruce Richardson 
316099a2dd95SBruce Richardson /**
316199a2dd95SBruce Richardson  * Retrieve extended statistics of an Ethernet device.
316299a2dd95SBruce Richardson  *
316399a2dd95SBruce Richardson  * There is an assumption that 'xstat_names' and 'xstats' arrays are matched
316499a2dd95SBruce Richardson  * by array index:
316599a2dd95SBruce Richardson  *  xstats_names[i].name => xstats[i].value
316699a2dd95SBruce Richardson  *
316799a2dd95SBruce Richardson  * And the array index is same with id field of 'struct rte_eth_xstat':
316899a2dd95SBruce Richardson  *  xstats[i].id == i
316999a2dd95SBruce Richardson  *
317099a2dd95SBruce Richardson  * This assumption makes key-value pair matching less flexible but simpler.
317199a2dd95SBruce Richardson  *
317299a2dd95SBruce Richardson  * @param port_id
317399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
317499a2dd95SBruce Richardson  * @param xstats
317599a2dd95SBruce Richardson  *   A pointer to a table of structure of type *rte_eth_xstat*
317699a2dd95SBruce Richardson  *   to be filled with device statistics ids and values.
317799a2dd95SBruce Richardson  *   This parameter can be set to NULL if n is 0.
317899a2dd95SBruce Richardson  * @param n
317999a2dd95SBruce Richardson  *   The size of the xstats array (number of elements).
318099a2dd95SBruce Richardson  * @return
318199a2dd95SBruce Richardson  *   - A positive value lower or equal to n: success. The return value
318299a2dd95SBruce Richardson  *     is the number of entries filled in the stats table.
318399a2dd95SBruce Richardson  *   - A positive value higher than n: error, the given statistics table
318499a2dd95SBruce Richardson  *     is too small. The return value corresponds to the size that should
318599a2dd95SBruce Richardson  *     be given to succeed. The entries in the table are not valid and
318699a2dd95SBruce Richardson  *     shall not be used by the caller.
31875906be5aSAndrew Rybchenko  *   - A negative value on error (invalid port ID).
318899a2dd95SBruce Richardson  */
318999a2dd95SBruce Richardson int rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats,
319099a2dd95SBruce Richardson 		unsigned int n);
319199a2dd95SBruce Richardson 
319299a2dd95SBruce Richardson /**
319399a2dd95SBruce Richardson  * Retrieve names of extended statistics of an Ethernet device.
319499a2dd95SBruce Richardson  *
319599a2dd95SBruce Richardson  * @param port_id
319699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
319799a2dd95SBruce Richardson  * @param xstats_names
3198bc5112caSIvan Ilchenko  *   Array to be filled in with names of requested device statistics.
3199bc5112caSIvan Ilchenko  *   Must not be NULL if @p ids are specified (not NULL).
320099a2dd95SBruce Richardson  * @param size
3201bc5112caSIvan Ilchenko  *   Number of elements in @p xstats_names array (if not NULL) and in
3202bc5112caSIvan Ilchenko  *   @p ids array (if not NULL). Must be 0 if both array pointers are NULL.
3203bc5112caSIvan Ilchenko  * @param ids
3204bc5112caSIvan Ilchenko  *   IDs array given by app to retrieve specific statistics. May be NULL to
3205bc5112caSIvan Ilchenko  *   retrieve names of all available statistics or, if @p xstats_names is
3206bc5112caSIvan Ilchenko  *   NULL as well, just the number of available statistics.
320799a2dd95SBruce Richardson  * @return
320899a2dd95SBruce Richardson  *   - A positive value lower or equal to size: success. The return value
320999a2dd95SBruce Richardson  *     is the number of entries filled in the stats table.
3210bc5112caSIvan Ilchenko  *   - A positive value higher than size: success. The given statistics table
321199a2dd95SBruce Richardson  *     is too small. The return value corresponds to the size that should
321299a2dd95SBruce Richardson  *     be given to succeed. The entries in the table are not valid and
321399a2dd95SBruce Richardson  *     shall not be used by the caller.
3214bc5112caSIvan Ilchenko  *   - A negative value on error.
321599a2dd95SBruce Richardson  */
321699a2dd95SBruce Richardson int
321799a2dd95SBruce Richardson rte_eth_xstats_get_names_by_id(uint16_t port_id,
321899a2dd95SBruce Richardson 	struct rte_eth_xstat_name *xstats_names, unsigned int size,
321999a2dd95SBruce Richardson 	uint64_t *ids);
322099a2dd95SBruce Richardson 
322199a2dd95SBruce Richardson /**
322299a2dd95SBruce Richardson  * Retrieve extended statistics of an Ethernet device.
322399a2dd95SBruce Richardson  *
322499a2dd95SBruce Richardson  * @param port_id
322599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
322699a2dd95SBruce Richardson  * @param ids
3227bc5112caSIvan Ilchenko  *   IDs array given by app to retrieve specific statistics. May be NULL to
3228bc5112caSIvan Ilchenko  *   retrieve all available statistics or, if @p values is NULL as well,
3229bc5112caSIvan Ilchenko  *   just the number of available statistics.
323099a2dd95SBruce Richardson  * @param values
3231bc5112caSIvan Ilchenko  *   Array to be filled in with requested device statistics.
3232bc5112caSIvan Ilchenko  *   Must not be NULL if ids are specified (not NULL).
323399a2dd95SBruce Richardson  * @param size
3234bc5112caSIvan Ilchenko  *   Number of elements in @p values array (if not NULL) and in @p ids
3235bc5112caSIvan Ilchenko  *   array (if not NULL). Must be 0 if both array pointers are NULL.
323699a2dd95SBruce Richardson  * @return
323799a2dd95SBruce Richardson  *   - A positive value lower or equal to size: success. The return value
323899a2dd95SBruce Richardson  *     is the number of entries filled in the stats table.
3239bc5112caSIvan Ilchenko  *   - A positive value higher than size: success: The given statistics table
324099a2dd95SBruce Richardson  *     is too small. The return value corresponds to the size that should
324199a2dd95SBruce Richardson  *     be given to succeed. The entries in the table are not valid and
324299a2dd95SBruce Richardson  *     shall not be used by the caller.
3243bc5112caSIvan Ilchenko  *   - A negative value on error.
324499a2dd95SBruce Richardson  */
324599a2dd95SBruce Richardson int rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,
324699a2dd95SBruce Richardson 			     uint64_t *values, unsigned int size);
324799a2dd95SBruce Richardson 
324899a2dd95SBruce Richardson /**
324999a2dd95SBruce Richardson  * Gets the ID of a statistic from its name.
325099a2dd95SBruce Richardson  *
325199a2dd95SBruce Richardson  * This function searches for the statistics using string compares, and
325299a2dd95SBruce Richardson  * as such should not be used on the fast-path. For fast-path retrieval of
325399a2dd95SBruce Richardson  * specific statistics, store the ID as provided in *id* from this function,
325499a2dd95SBruce Richardson  * and pass the ID to rte_eth_xstats_get()
325599a2dd95SBruce Richardson  *
325699a2dd95SBruce Richardson  * @param port_id The port to look up statistics from
325799a2dd95SBruce Richardson  * @param xstat_name The name of the statistic to return
325899a2dd95SBruce Richardson  * @param[out] id A pointer to an app-supplied uint64_t which should be
325999a2dd95SBruce Richardson  *                set to the ID of the stat if the stat exists.
326099a2dd95SBruce Richardson  * @return
326199a2dd95SBruce Richardson  *    0 on success
326299a2dd95SBruce Richardson  *    -ENODEV for invalid port_id,
326399a2dd95SBruce Richardson  *    -EIO if device is removed,
326499a2dd95SBruce Richardson  *    -EINVAL if the xstat_name doesn't exist in port_id
326553ef1b34SMin Hu (Connor)  *    -ENOMEM if bad parameter.
326699a2dd95SBruce Richardson  */
326799a2dd95SBruce Richardson int rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name,
326899a2dd95SBruce Richardson 		uint64_t *id);
326999a2dd95SBruce Richardson 
327099a2dd95SBruce Richardson /**
327199a2dd95SBruce Richardson  * Reset extended statistics of an Ethernet device.
327299a2dd95SBruce Richardson  *
327399a2dd95SBruce Richardson  * @param port_id
327499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
327599a2dd95SBruce Richardson  * @return
327699a2dd95SBruce Richardson  *   - (0) if device notified to reset extended stats.
327799a2dd95SBruce Richardson  *   - (-ENOTSUP) if pmd doesn't support both
327899a2dd95SBruce Richardson  *     extended stats and basic stats reset.
327999a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
328099a2dd95SBruce Richardson  *   - (<0): Error code of the driver xstats reset function.
328199a2dd95SBruce Richardson  */
328299a2dd95SBruce Richardson int rte_eth_xstats_reset(uint16_t port_id);
328399a2dd95SBruce Richardson 
328499a2dd95SBruce Richardson /**
328599a2dd95SBruce Richardson  *  Set a mapping for the specified transmit queue to the specified per-queue
328699a2dd95SBruce Richardson  *  statistics counter.
328799a2dd95SBruce Richardson  *
328899a2dd95SBruce Richardson  * @param port_id
328999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
329099a2dd95SBruce Richardson  * @param tx_queue_id
329199a2dd95SBruce Richardson  *   The index of the transmit queue for which a queue stats mapping is required.
329299a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
329399a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
329499a2dd95SBruce Richardson  * @param stat_idx
329599a2dd95SBruce Richardson  *   The per-queue packet statistics functionality number that the transmit
329699a2dd95SBruce Richardson  *   queue is to be assigned.
329799a2dd95SBruce Richardson  *   The value must be in the range [0, RTE_ETHDEV_QUEUE_STAT_CNTRS - 1].
329899a2dd95SBruce Richardson  *   Max RTE_ETHDEV_QUEUE_STAT_CNTRS being 256.
329999a2dd95SBruce Richardson  * @return
330099a2dd95SBruce Richardson  *   Zero if successful. Non-zero otherwise.
330199a2dd95SBruce Richardson  */
330299a2dd95SBruce Richardson int rte_eth_dev_set_tx_queue_stats_mapping(uint16_t port_id,
330399a2dd95SBruce Richardson 		uint16_t tx_queue_id, uint8_t stat_idx);
330499a2dd95SBruce Richardson 
330599a2dd95SBruce Richardson /**
330699a2dd95SBruce Richardson  *  Set a mapping for the specified receive queue to the specified per-queue
330799a2dd95SBruce Richardson  *  statistics counter.
330899a2dd95SBruce Richardson  *
330999a2dd95SBruce Richardson  * @param port_id
331099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
331199a2dd95SBruce Richardson  * @param rx_queue_id
331299a2dd95SBruce Richardson  *   The index of the receive queue for which a queue stats mapping is required.
331399a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
331499a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
331599a2dd95SBruce Richardson  * @param stat_idx
331699a2dd95SBruce Richardson  *   The per-queue packet statistics functionality number that the receive
331799a2dd95SBruce Richardson  *   queue is to be assigned.
331899a2dd95SBruce Richardson  *   The value must be in the range [0, RTE_ETHDEV_QUEUE_STAT_CNTRS - 1].
331999a2dd95SBruce Richardson  *   Max RTE_ETHDEV_QUEUE_STAT_CNTRS being 256.
332099a2dd95SBruce Richardson  * @return
332199a2dd95SBruce Richardson  *   Zero if successful. Non-zero otherwise.
332299a2dd95SBruce Richardson  */
332399a2dd95SBruce Richardson int rte_eth_dev_set_rx_queue_stats_mapping(uint16_t port_id,
332499a2dd95SBruce Richardson 					   uint16_t rx_queue_id,
332599a2dd95SBruce Richardson 					   uint8_t stat_idx);
332699a2dd95SBruce Richardson 
332799a2dd95SBruce Richardson /**
332899a2dd95SBruce Richardson  * Retrieve the Ethernet address of an Ethernet device.
332999a2dd95SBruce Richardson  *
333099a2dd95SBruce Richardson  * @param port_id
333199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
333299a2dd95SBruce Richardson  * @param mac_addr
333399a2dd95SBruce Richardson  *   A pointer to a structure of type *ether_addr* to be filled with
333499a2dd95SBruce Richardson  *   the Ethernet address of the Ethernet device.
333599a2dd95SBruce Richardson  * @return
333699a2dd95SBruce Richardson  *   - (0) if successful
333799a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
333853ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
333999a2dd95SBruce Richardson  */
334099a2dd95SBruce Richardson int rte_eth_macaddr_get(uint16_t port_id, struct rte_ether_addr *mac_addr);
334199a2dd95SBruce Richardson 
334299a2dd95SBruce Richardson /**
334327a300e6SKonstantin Ananyev  * @warning
334427a300e6SKonstantin Ananyev  * @b EXPERIMENTAL: this API may change without prior notice
334527a300e6SKonstantin Ananyev  *
334627a300e6SKonstantin Ananyev  * Retrieve the Ethernet addresses of an Ethernet device.
334727a300e6SKonstantin Ananyev  *
334827a300e6SKonstantin Ananyev  * @param port_id
334927a300e6SKonstantin Ananyev  *   The port identifier of the Ethernet device.
335027a300e6SKonstantin Ananyev  * @param ma
335127a300e6SKonstantin Ananyev  *   A pointer to an array of structures of type *ether_addr* to be filled with
335227a300e6SKonstantin Ananyev  *   the Ethernet addresses of the Ethernet device.
335327a300e6SKonstantin Ananyev  * @param num
335427a300e6SKonstantin Ananyev  *   Number of elements in the @p ma array.
335527a300e6SKonstantin Ananyev  *   Note that  rte_eth_dev_info::max_mac_addrs can be used to retrieve
335627a300e6SKonstantin Ananyev  *   max number of Ethernet addresses for given port.
335727a300e6SKonstantin Ananyev  * @return
335827a300e6SKonstantin Ananyev  *   - number of retrieved addresses if successful
335927a300e6SKonstantin Ananyev  *   - (-ENODEV) if *port_id* invalid.
336027a300e6SKonstantin Ananyev  *   - (-EINVAL) if bad parameter.
336127a300e6SKonstantin Ananyev  */
336227a300e6SKonstantin Ananyev __rte_experimental
336327a300e6SKonstantin Ananyev int rte_eth_macaddrs_get(uint16_t port_id, struct rte_ether_addr *ma,
336427a300e6SKonstantin Ananyev 	unsigned int num);
336527a300e6SKonstantin Ananyev 
336627a300e6SKonstantin Ananyev /**
336799a2dd95SBruce Richardson  * Retrieve the contextual information of an Ethernet device.
336899a2dd95SBruce Richardson  *
336999a2dd95SBruce Richardson  * As part of this function, a number of of fields in dev_info will be
337099a2dd95SBruce Richardson  * initialized as follows:
337199a2dd95SBruce Richardson  *
337299a2dd95SBruce Richardson  * rx_desc_lim = lim
337399a2dd95SBruce Richardson  * tx_desc_lim = lim
337499a2dd95SBruce Richardson  *
337599a2dd95SBruce Richardson  * Where lim is defined within the rte_eth_dev_info_get as
337699a2dd95SBruce Richardson  *
337799a2dd95SBruce Richardson  *  const struct rte_eth_desc_lim lim = {
337899a2dd95SBruce Richardson  *      .nb_max = UINT16_MAX,
337999a2dd95SBruce Richardson  *      .nb_min = 0,
338099a2dd95SBruce Richardson  *      .nb_align = 1,
338199a2dd95SBruce Richardson  *	.nb_seg_max = UINT16_MAX,
338299a2dd95SBruce Richardson  *	.nb_mtu_seg_max = UINT16_MAX,
338399a2dd95SBruce Richardson  *  };
338499a2dd95SBruce Richardson  *
338599a2dd95SBruce Richardson  * device = dev->device
3386990912e6SFerruh Yigit  * min_mtu = RTE_ETHER_MIN_LEN - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN
338799a2dd95SBruce Richardson  * max_mtu = UINT16_MAX
338899a2dd95SBruce Richardson  *
338999a2dd95SBruce Richardson  * The following fields will be populated if support for dev_infos_get()
339099a2dd95SBruce Richardson  * exists for the device and the rte_eth_dev 'dev' has been populated
339199a2dd95SBruce Richardson  * successfully with a call to it:
339299a2dd95SBruce Richardson  *
339399a2dd95SBruce Richardson  * driver_name = dev->device->driver->name
339499a2dd95SBruce Richardson  * nb_rx_queues = dev->data->nb_rx_queues
339599a2dd95SBruce Richardson  * nb_tx_queues = dev->data->nb_tx_queues
339699a2dd95SBruce Richardson  * dev_flags = &dev->data->dev_flags
339799a2dd95SBruce Richardson  *
339899a2dd95SBruce Richardson  * @param port_id
339999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
340099a2dd95SBruce Richardson  * @param dev_info
340199a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_eth_dev_info* to be filled with
340299a2dd95SBruce Richardson  *   the contextual information of the Ethernet device.
340399a2dd95SBruce Richardson  * @return
340499a2dd95SBruce Richardson  *   - (0) if successful.
340599a2dd95SBruce Richardson  *   - (-ENOTSUP) if support for dev_infos_get() does not exist for the device.
340699a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
340753ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
340899a2dd95SBruce Richardson  */
340999a2dd95SBruce Richardson int rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info);
341099a2dd95SBruce Richardson 
341199a2dd95SBruce Richardson /**
3412632be327SJie Wang  * @warning
3413632be327SJie Wang  * @b EXPERIMENTAL: this API may change without prior notice.
3414632be327SJie Wang  *
3415632be327SJie Wang  * Retrieve the configuration of an Ethernet device.
3416632be327SJie Wang  *
3417632be327SJie Wang  * @param port_id
3418632be327SJie Wang  *   The port identifier of the Ethernet device.
3419632be327SJie Wang  * @param dev_conf
3420632be327SJie Wang  *   Location for Ethernet device configuration to be filled in.
3421632be327SJie Wang  * @return
3422632be327SJie Wang  *   - (0) if successful.
3423632be327SJie Wang  *   - (-ENODEV) if *port_id* invalid.
3424632be327SJie Wang  *   - (-EINVAL) if bad parameter.
3425632be327SJie Wang  */
3426632be327SJie Wang __rte_experimental
3427632be327SJie Wang int rte_eth_dev_conf_get(uint16_t port_id, struct rte_eth_conf *dev_conf);
3428632be327SJie Wang 
3429632be327SJie Wang /**
343099a2dd95SBruce Richardson  * Retrieve the firmware version of a device.
343199a2dd95SBruce Richardson  *
343299a2dd95SBruce Richardson  * @param port_id
343399a2dd95SBruce Richardson  *   The port identifier of the device.
343499a2dd95SBruce Richardson  * @param fw_version
343599a2dd95SBruce Richardson  *   A pointer to a string array storing the firmware version of a device,
343699a2dd95SBruce Richardson  *   the string includes terminating null. This pointer is allocated by caller.
343799a2dd95SBruce Richardson  * @param fw_size
343899a2dd95SBruce Richardson  *   The size of the string array pointed by fw_version, which should be
343999a2dd95SBruce Richardson  *   large enough to store firmware version of the device.
344099a2dd95SBruce Richardson  * @return
344199a2dd95SBruce Richardson  *   - (0) if successful.
344299a2dd95SBruce Richardson  *   - (-ENOTSUP) if operation is not supported.
344399a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
344499a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
344553ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
344699a2dd95SBruce Richardson  *   - (>0) if *fw_size* is not enough to store firmware version, return
344799a2dd95SBruce Richardson  *          the size of the non truncated string.
344899a2dd95SBruce Richardson  */
344999a2dd95SBruce Richardson int rte_eth_dev_fw_version_get(uint16_t port_id,
345099a2dd95SBruce Richardson 			       char *fw_version, size_t fw_size);
345199a2dd95SBruce Richardson 
345299a2dd95SBruce Richardson /**
345399a2dd95SBruce Richardson  * Retrieve the supported packet types of an Ethernet device.
345499a2dd95SBruce Richardson  *
345599a2dd95SBruce Richardson  * When a packet type is announced as supported, it *must* be recognized by
345699a2dd95SBruce Richardson  * the PMD. For instance, if RTE_PTYPE_L2_ETHER, RTE_PTYPE_L2_ETHER_VLAN
345799a2dd95SBruce Richardson  * and RTE_PTYPE_L3_IPV4 are announced, the PMD must return the following
345899a2dd95SBruce Richardson  * packet types for these packets:
345999a2dd95SBruce Richardson  * - Ether/IPv4              -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4
34605b49ba65SAndrew Rybchenko  * - Ether/VLAN/IPv4         -> RTE_PTYPE_L2_ETHER_VLAN | RTE_PTYPE_L3_IPV4
346199a2dd95SBruce Richardson  * - Ether/[anything else]   -> RTE_PTYPE_L2_ETHER
34625b49ba65SAndrew Rybchenko  * - Ether/VLAN/[anything else] -> RTE_PTYPE_L2_ETHER_VLAN
346399a2dd95SBruce Richardson  *
346499a2dd95SBruce Richardson  * When a packet is received by a PMD, the most precise type must be
346599a2dd95SBruce Richardson  * returned among the ones supported. However a PMD is allowed to set
346699a2dd95SBruce Richardson  * packet type that is not in the supported list, at the condition that it
346799a2dd95SBruce Richardson  * is more precise. Therefore, a PMD announcing no supported packet types
346899a2dd95SBruce Richardson  * can still set a matching packet type in a received packet.
346999a2dd95SBruce Richardson  *
347099a2dd95SBruce Richardson  * @note
347109fd4227SAndrew Rybchenko  *   Better to invoke this API after the device is already started or Rx burst
347299a2dd95SBruce Richardson  *   function is decided, to obtain correct supported ptypes.
347399a2dd95SBruce Richardson  * @note
347499a2dd95SBruce Richardson  *   if a given PMD does not report what ptypes it supports, then the supported
347599a2dd95SBruce Richardson  *   ptype count is reported as 0.
347699a2dd95SBruce Richardson  * @param port_id
347799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
347899a2dd95SBruce Richardson  * @param ptype_mask
347999a2dd95SBruce Richardson  *   A hint of what kind of packet type which the caller is interested in.
348099a2dd95SBruce Richardson  * @param ptypes
348199a2dd95SBruce Richardson  *   An array pointer to store adequate packet types, allocated by caller.
348299a2dd95SBruce Richardson  * @param num
348399a2dd95SBruce Richardson  *  Size of the array pointed by param ptypes.
348499a2dd95SBruce Richardson  * @return
348599a2dd95SBruce Richardson  *   - (>=0) Number of supported ptypes. If the number of types exceeds num,
348699a2dd95SBruce Richardson  *           only num entries will be filled into the ptypes array, but the full
348799a2dd95SBruce Richardson  *           count of supported ptypes will be returned.
348899a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
348953ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
349099a2dd95SBruce Richardson  */
349199a2dd95SBruce Richardson int rte_eth_dev_get_supported_ptypes(uint16_t port_id, uint32_t ptype_mask,
349299a2dd95SBruce Richardson 				     uint32_t *ptypes, int num);
349399a2dd95SBruce Richardson /**
349499a2dd95SBruce Richardson  * Inform Ethernet device about reduced range of packet types to handle.
349599a2dd95SBruce Richardson  *
349699a2dd95SBruce Richardson  * Application can use this function to set only specific ptypes that it's
349799a2dd95SBruce Richardson  * interested. This information can be used by the PMD to optimize Rx path.
349899a2dd95SBruce Richardson  *
349999a2dd95SBruce Richardson  * The function accepts an array `set_ptypes` allocated by the caller to
350099a2dd95SBruce Richardson  * store the packet types set by the driver, the last element of the array
350199a2dd95SBruce Richardson  * is set to RTE_PTYPE_UNKNOWN. The size of the `set_ptype` array should be
350299a2dd95SBruce Richardson  * `rte_eth_dev_get_supported_ptypes() + 1` else it might only be filled
350399a2dd95SBruce Richardson  * partially.
350499a2dd95SBruce Richardson  *
350599a2dd95SBruce Richardson  * @param port_id
350699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
350799a2dd95SBruce Richardson  * @param ptype_mask
350899a2dd95SBruce Richardson  *   The ptype family that application is interested in should be bitwise OR of
350999a2dd95SBruce Richardson  *   RTE_PTYPE_*_MASK or 0.
351099a2dd95SBruce Richardson  * @param set_ptypes
351199a2dd95SBruce Richardson  *   An array pointer to store set packet types, allocated by caller. The
351299a2dd95SBruce Richardson  *   function marks the end of array with RTE_PTYPE_UNKNOWN.
351399a2dd95SBruce Richardson  * @param num
351499a2dd95SBruce Richardson  *   Size of the array pointed by param ptypes.
351599a2dd95SBruce Richardson  *   Should be rte_eth_dev_get_supported_ptypes() + 1 to accommodate the
351699a2dd95SBruce Richardson  *   set ptypes.
351799a2dd95SBruce Richardson  * @return
351899a2dd95SBruce Richardson  *   - (0) if Success.
351999a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
352099a2dd95SBruce Richardson  *   - (-EINVAL) if *ptype_mask* is invalid (or) set_ptypes is NULL and
352199a2dd95SBruce Richardson  *     num > 0.
352299a2dd95SBruce Richardson  */
352399a2dd95SBruce Richardson int rte_eth_dev_set_ptypes(uint16_t port_id, uint32_t ptype_mask,
352499a2dd95SBruce Richardson 			   uint32_t *set_ptypes, unsigned int num);
352599a2dd95SBruce Richardson 
352699a2dd95SBruce Richardson /**
352799a2dd95SBruce Richardson  * Retrieve the MTU of an Ethernet device.
352899a2dd95SBruce Richardson  *
352999a2dd95SBruce Richardson  * @param port_id
353099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
353199a2dd95SBruce Richardson  * @param mtu
353299a2dd95SBruce Richardson  *   A pointer to a uint16_t where the retrieved MTU is to be stored.
353399a2dd95SBruce Richardson  * @return
353499a2dd95SBruce Richardson  *   - (0) if successful.
353599a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
353653ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
353799a2dd95SBruce Richardson  */
353899a2dd95SBruce Richardson int rte_eth_dev_get_mtu(uint16_t port_id, uint16_t *mtu);
353999a2dd95SBruce Richardson 
354099a2dd95SBruce Richardson /**
354199a2dd95SBruce Richardson  * Change the MTU of an Ethernet device.
354299a2dd95SBruce Richardson  *
354399a2dd95SBruce Richardson  * @param port_id
354499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
354599a2dd95SBruce Richardson  * @param mtu
354699a2dd95SBruce Richardson  *   A uint16_t for the MTU to be applied.
354799a2dd95SBruce Richardson  * @return
354899a2dd95SBruce Richardson  *   - (0) if successful.
354999a2dd95SBruce Richardson  *   - (-ENOTSUP) if operation is not supported.
355099a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
355199a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
355299a2dd95SBruce Richardson  *   - (-EINVAL) if *mtu* invalid, validation of mtu can occur within
355399a2dd95SBruce Richardson  *     rte_eth_dev_set_mtu if dev_infos_get is supported by the device or
355499a2dd95SBruce Richardson  *     when the mtu is set using dev->dev_ops->mtu_set.
355599a2dd95SBruce Richardson  *   - (-EBUSY) if operation is not allowed when the port is running
355699a2dd95SBruce Richardson  */
355799a2dd95SBruce Richardson int rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu);
355899a2dd95SBruce Richardson 
355999a2dd95SBruce Richardson /**
356099a2dd95SBruce Richardson  * Enable/Disable hardware filtering by an Ethernet device of received
356199a2dd95SBruce Richardson  * VLAN packets tagged with a given VLAN Tag Identifier.
356299a2dd95SBruce Richardson  *
356399a2dd95SBruce Richardson  * @param port_id
356499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
356599a2dd95SBruce Richardson  * @param vlan_id
356699a2dd95SBruce Richardson  *   The VLAN Tag Identifier whose filtering must be enabled or disabled.
356799a2dd95SBruce Richardson  * @param on
356899a2dd95SBruce Richardson  *   If > 0, enable VLAN filtering of VLAN packets tagged with *vlan_id*.
356999a2dd95SBruce Richardson  *   Otherwise, disable VLAN filtering of VLAN packets tagged with *vlan_id*.
357099a2dd95SBruce Richardson  * @return
357199a2dd95SBruce Richardson  *   - (0) if successful.
357299a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware-assisted VLAN filtering not configured.
357399a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
357499a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
357599a2dd95SBruce Richardson  *   - (-ENOSYS) if VLAN filtering on *port_id* disabled.
357699a2dd95SBruce Richardson  *   - (-EINVAL) if *vlan_id* > 4095.
357799a2dd95SBruce Richardson  */
357899a2dd95SBruce Richardson int rte_eth_dev_vlan_filter(uint16_t port_id, uint16_t vlan_id, int on);
357999a2dd95SBruce Richardson 
358099a2dd95SBruce Richardson /**
358109fd4227SAndrew Rybchenko  * Enable/Disable hardware VLAN Strip by a Rx queue of an Ethernet device.
358299a2dd95SBruce Richardson  *
358399a2dd95SBruce Richardson  * @param port_id
358499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
358599a2dd95SBruce Richardson  * @param rx_queue_id
358699a2dd95SBruce Richardson  *   The index of the receive queue for which a queue stats mapping is required.
358799a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
358899a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
358999a2dd95SBruce Richardson  * @param on
359099a2dd95SBruce Richardson  *   If 1, Enable VLAN Stripping of the receive queue of the Ethernet port.
359199a2dd95SBruce Richardson  *   If 0, Disable VLAN Stripping of the receive queue of the Ethernet port.
359299a2dd95SBruce Richardson  * @return
359399a2dd95SBruce Richardson  *   - (0) if successful.
359499a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware-assisted VLAN stripping not configured.
359599a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
359699a2dd95SBruce Richardson  *   - (-EINVAL) if *rx_queue_id* invalid.
359799a2dd95SBruce Richardson  */
359899a2dd95SBruce Richardson int rte_eth_dev_set_vlan_strip_on_queue(uint16_t port_id, uint16_t rx_queue_id,
359999a2dd95SBruce Richardson 		int on);
360099a2dd95SBruce Richardson 
360199a2dd95SBruce Richardson /**
360299a2dd95SBruce Richardson  * Set the Outer VLAN Ether Type by an Ethernet device, it can be inserted to
360399a2dd95SBruce Richardson  * the VLAN header.
360499a2dd95SBruce Richardson  *
360599a2dd95SBruce Richardson  * @param port_id
360699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
360799a2dd95SBruce Richardson  * @param vlan_type
36085b49ba65SAndrew Rybchenko  *   The VLAN type.
360999a2dd95SBruce Richardson  * @param tag_type
361099a2dd95SBruce Richardson  *   The Tag Protocol ID
361199a2dd95SBruce Richardson  * @return
361299a2dd95SBruce Richardson  *   - (0) if successful.
361399a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware-assisted VLAN TPID setup is not supported.
361499a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
361599a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
361699a2dd95SBruce Richardson  */
361799a2dd95SBruce Richardson int rte_eth_dev_set_vlan_ether_type(uint16_t port_id,
361899a2dd95SBruce Richardson 				    enum rte_vlan_type vlan_type,
361999a2dd95SBruce Richardson 				    uint16_t tag_type);
362099a2dd95SBruce Richardson 
362199a2dd95SBruce Richardson /**
362299a2dd95SBruce Richardson  * Set VLAN offload configuration on an Ethernet device.
362399a2dd95SBruce Richardson  *
362499a2dd95SBruce Richardson  * @param port_id
362599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
362699a2dd95SBruce Richardson  * @param offload_mask
362799a2dd95SBruce Richardson  *   The VLAN Offload bit mask can be mixed use with "OR"
3628295968d1SFerruh Yigit  *       RTE_ETH_VLAN_STRIP_OFFLOAD
3629295968d1SFerruh Yigit  *       RTE_ETH_VLAN_FILTER_OFFLOAD
3630295968d1SFerruh Yigit  *       RTE_ETH_VLAN_EXTEND_OFFLOAD
3631295968d1SFerruh Yigit  *       RTE_ETH_QINQ_STRIP_OFFLOAD
363299a2dd95SBruce Richardson  * @return
363399a2dd95SBruce Richardson  *   - (0) if successful.
363499a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware-assisted VLAN filtering not configured.
363599a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
363699a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
363799a2dd95SBruce Richardson  */
363899a2dd95SBruce Richardson int rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask);
363999a2dd95SBruce Richardson 
364099a2dd95SBruce Richardson /**
364199a2dd95SBruce Richardson  * Read VLAN Offload configuration from an Ethernet device
364299a2dd95SBruce Richardson  *
364399a2dd95SBruce Richardson  * @param port_id
364499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
364599a2dd95SBruce Richardson  * @return
364699a2dd95SBruce Richardson  *   - (>0) if successful. Bit mask to indicate
3647295968d1SFerruh Yigit  *       RTE_ETH_VLAN_STRIP_OFFLOAD
3648295968d1SFerruh Yigit  *       RTE_ETH_VLAN_FILTER_OFFLOAD
3649295968d1SFerruh Yigit  *       RTE_ETH_VLAN_EXTEND_OFFLOAD
3650295968d1SFerruh Yigit  *       RTE_ETH_QINQ_STRIP_OFFLOAD
365199a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
365299a2dd95SBruce Richardson  */
365399a2dd95SBruce Richardson int rte_eth_dev_get_vlan_offload(uint16_t port_id);
365499a2dd95SBruce Richardson 
365599a2dd95SBruce Richardson /**
365609fd4227SAndrew Rybchenko  * Set port based Tx VLAN insertion on or off.
365799a2dd95SBruce Richardson  *
365899a2dd95SBruce Richardson  * @param port_id
365999a2dd95SBruce Richardson  *  The port identifier of the Ethernet device.
366099a2dd95SBruce Richardson  * @param pvid
366109fd4227SAndrew Rybchenko  *  Port based Tx VLAN identifier together with user priority.
366299a2dd95SBruce Richardson  * @param on
366309fd4227SAndrew Rybchenko  *  Turn on or off the port based Tx VLAN insertion.
366499a2dd95SBruce Richardson  *
366599a2dd95SBruce Richardson  * @return
366699a2dd95SBruce Richardson  *   - (0) if successful.
366799a2dd95SBruce Richardson  *   - negative if failed.
366899a2dd95SBruce Richardson  */
366999a2dd95SBruce Richardson int rte_eth_dev_set_vlan_pvid(uint16_t port_id, uint16_t pvid, int on);
367099a2dd95SBruce Richardson 
367199a2dd95SBruce Richardson typedef void (*buffer_tx_error_fn)(struct rte_mbuf **unsent, uint16_t count,
367299a2dd95SBruce Richardson 		void *userdata);
367399a2dd95SBruce Richardson 
367499a2dd95SBruce Richardson /**
367509fd4227SAndrew Rybchenko  * Structure used to buffer packets for future Tx
367699a2dd95SBruce Richardson  * Used by APIs rte_eth_tx_buffer and rte_eth_tx_buffer_flush
367799a2dd95SBruce Richardson  */
367899a2dd95SBruce Richardson struct rte_eth_dev_tx_buffer {
367999a2dd95SBruce Richardson 	buffer_tx_error_fn error_callback;
368099a2dd95SBruce Richardson 	void *error_userdata;
368109fd4227SAndrew Rybchenko 	uint16_t size;           /**< Size of buffer for buffered Tx */
368299a2dd95SBruce Richardson 	uint16_t length;         /**< Number of packets in the array */
36833c2ca0a9SAndrew Rybchenko 	/** Pending packets to be sent on explicit flush or when full */
368499a2dd95SBruce Richardson 	struct rte_mbuf *pkts[];
368599a2dd95SBruce Richardson };
368699a2dd95SBruce Richardson 
368799a2dd95SBruce Richardson /**
368809fd4227SAndrew Rybchenko  * Calculate the size of the Tx buffer.
368999a2dd95SBruce Richardson  *
369099a2dd95SBruce Richardson  * @param sz
369199a2dd95SBruce Richardson  *   Number of stored packets.
369299a2dd95SBruce Richardson  */
369399a2dd95SBruce Richardson #define RTE_ETH_TX_BUFFER_SIZE(sz) \
369499a2dd95SBruce Richardson 	(sizeof(struct rte_eth_dev_tx_buffer) + (sz) * sizeof(struct rte_mbuf *))
369599a2dd95SBruce Richardson 
369699a2dd95SBruce Richardson /**
369799a2dd95SBruce Richardson  * Initialize default values for buffered transmitting
369899a2dd95SBruce Richardson  *
369999a2dd95SBruce Richardson  * @param buffer
370099a2dd95SBruce Richardson  *   Tx buffer to be initialized.
370199a2dd95SBruce Richardson  * @param size
370299a2dd95SBruce Richardson  *   Buffer size
370399a2dd95SBruce Richardson  * @return
370499a2dd95SBruce Richardson  *   0 if no error
370599a2dd95SBruce Richardson  */
370699a2dd95SBruce Richardson int
370799a2dd95SBruce Richardson rte_eth_tx_buffer_init(struct rte_eth_dev_tx_buffer *buffer, uint16_t size);
370899a2dd95SBruce Richardson 
370999a2dd95SBruce Richardson /**
371099a2dd95SBruce Richardson  * Configure a callback for buffered packets which cannot be sent
371199a2dd95SBruce Richardson  *
371299a2dd95SBruce Richardson  * Register a specific callback to be called when an attempt is made to send
37130d9f56a8SAndrew Rybchenko  * all packets buffered on an Ethernet port, but not all packets can
371499a2dd95SBruce Richardson  * successfully be sent. The callback registered here will be called only
371599a2dd95SBruce Richardson  * from calls to rte_eth_tx_buffer() and rte_eth_tx_buffer_flush() APIs.
371699a2dd95SBruce Richardson  * The default callback configured for each queue by default just frees the
371799a2dd95SBruce Richardson  * packets back to the calling mempool. If additional behaviour is required,
371899a2dd95SBruce Richardson  * for example, to count dropped packets, or to retry transmission of packets
371999a2dd95SBruce Richardson  * which cannot be sent, this function should be used to register a suitable
372099a2dd95SBruce Richardson  * callback function to implement the desired behaviour.
372199a2dd95SBruce Richardson  * The example callback "rte_eth_count_unsent_packet_callback()" is also
372299a2dd95SBruce Richardson  * provided as reference.
372399a2dd95SBruce Richardson  *
372499a2dd95SBruce Richardson  * @param buffer
372599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
372699a2dd95SBruce Richardson  * @param callback
372799a2dd95SBruce Richardson  *   The function to be used as the callback.
372899a2dd95SBruce Richardson  * @param userdata
372999a2dd95SBruce Richardson  *   Arbitrary parameter to be passed to the callback function
373099a2dd95SBruce Richardson  * @return
373153ef1b34SMin Hu (Connor)  *   0 on success, or -EINVAL if bad parameter
373299a2dd95SBruce Richardson  */
373399a2dd95SBruce Richardson int
373499a2dd95SBruce Richardson rte_eth_tx_buffer_set_err_callback(struct rte_eth_dev_tx_buffer *buffer,
373599a2dd95SBruce Richardson 		buffer_tx_error_fn callback, void *userdata);
373699a2dd95SBruce Richardson 
373799a2dd95SBruce Richardson /**
373899a2dd95SBruce Richardson  * Callback function for silently dropping unsent buffered packets.
373999a2dd95SBruce Richardson  *
374099a2dd95SBruce Richardson  * This function can be passed to rte_eth_tx_buffer_set_err_callback() to
374199a2dd95SBruce Richardson  * adjust the default behavior when buffered packets cannot be sent. This
374209fd4227SAndrew Rybchenko  * function drops any unsent packets silently and is used by Tx buffered
374399a2dd95SBruce Richardson  * operations as default behavior.
374499a2dd95SBruce Richardson  *
374599a2dd95SBruce Richardson  * NOTE: this function should not be called directly, instead it should be used
374699a2dd95SBruce Richardson  *       as a callback for packet buffering.
374799a2dd95SBruce Richardson  *
374899a2dd95SBruce Richardson  * NOTE: when configuring this function as a callback with
374999a2dd95SBruce Richardson  *       rte_eth_tx_buffer_set_err_callback(), the final, userdata parameter
375099a2dd95SBruce Richardson  *       should point to an uint64_t value.
375199a2dd95SBruce Richardson  *
375299a2dd95SBruce Richardson  * @param pkts
375399a2dd95SBruce Richardson  *   The previously buffered packets which could not be sent
375499a2dd95SBruce Richardson  * @param unsent
375599a2dd95SBruce Richardson  *   The number of unsent packets in the pkts array
375699a2dd95SBruce Richardson  * @param userdata
375799a2dd95SBruce Richardson  *   Not used
375899a2dd95SBruce Richardson  */
375999a2dd95SBruce Richardson void
376099a2dd95SBruce Richardson rte_eth_tx_buffer_drop_callback(struct rte_mbuf **pkts, uint16_t unsent,
376199a2dd95SBruce Richardson 		void *userdata);
376299a2dd95SBruce Richardson 
376399a2dd95SBruce Richardson /**
376499a2dd95SBruce Richardson  * Callback function for tracking unsent buffered packets.
376599a2dd95SBruce Richardson  *
376699a2dd95SBruce Richardson  * This function can be passed to rte_eth_tx_buffer_set_err_callback() to
376799a2dd95SBruce Richardson  * adjust the default behavior when buffered packets cannot be sent. This
376899a2dd95SBruce Richardson  * function drops any unsent packets, but also updates a user-supplied counter
376999a2dd95SBruce Richardson  * to track the overall number of packets dropped. The counter should be an
377099a2dd95SBruce Richardson  * uint64_t variable.
377199a2dd95SBruce Richardson  *
377299a2dd95SBruce Richardson  * NOTE: this function should not be called directly, instead it should be used
377399a2dd95SBruce Richardson  *       as a callback for packet buffering.
377499a2dd95SBruce Richardson  *
377599a2dd95SBruce Richardson  * NOTE: when configuring this function as a callback with
377699a2dd95SBruce Richardson  *       rte_eth_tx_buffer_set_err_callback(), the final, userdata parameter
377799a2dd95SBruce Richardson  *       should point to an uint64_t value.
377899a2dd95SBruce Richardson  *
377999a2dd95SBruce Richardson  * @param pkts
378099a2dd95SBruce Richardson  *   The previously buffered packets which could not be sent
378199a2dd95SBruce Richardson  * @param unsent
378299a2dd95SBruce Richardson  *   The number of unsent packets in the pkts array
378399a2dd95SBruce Richardson  * @param userdata
378499a2dd95SBruce Richardson  *   Pointer to an uint64_t value, which will be incremented by unsent
378599a2dd95SBruce Richardson  */
378699a2dd95SBruce Richardson void
378799a2dd95SBruce Richardson rte_eth_tx_buffer_count_callback(struct rte_mbuf **pkts, uint16_t unsent,
378899a2dd95SBruce Richardson 		void *userdata);
378999a2dd95SBruce Richardson 
379099a2dd95SBruce Richardson /**
379199a2dd95SBruce Richardson  * Request the driver to free mbufs currently cached by the driver. The
379299a2dd95SBruce Richardson  * driver will only free the mbuf if it is no longer in use. It is the
379399a2dd95SBruce Richardson  * application's responsibility to ensure rte_eth_tx_buffer_flush(..) is
379499a2dd95SBruce Richardson  * called if needed.
379599a2dd95SBruce Richardson  *
379699a2dd95SBruce Richardson  * @param port_id
379799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
379899a2dd95SBruce Richardson  * @param queue_id
379999a2dd95SBruce Richardson  *   The index of the transmit queue through which output packets must be
380099a2dd95SBruce Richardson  *   sent.
380199a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
380299a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
380399a2dd95SBruce Richardson  * @param free_cnt
380499a2dd95SBruce Richardson  *   Maximum number of packets to free. Use 0 to indicate all possible packets
380599a2dd95SBruce Richardson  *   should be freed. Note that a packet may be using multiple mbufs.
380699a2dd95SBruce Richardson  * @return
380799a2dd95SBruce Richardson  *   Failure: < 0
380899a2dd95SBruce Richardson  *     -ENODEV: Invalid interface
380999a2dd95SBruce Richardson  *     -EIO: device is removed
381099a2dd95SBruce Richardson  *     -ENOTSUP: Driver does not support function
381199a2dd95SBruce Richardson  *   Success: >= 0
381299a2dd95SBruce Richardson  *     0-n: Number of packets freed. More packets may still remain in ring that
381399a2dd95SBruce Richardson  *     are in use.
381499a2dd95SBruce Richardson  */
381599a2dd95SBruce Richardson int
381699a2dd95SBruce Richardson rte_eth_tx_done_cleanup(uint16_t port_id, uint16_t queue_id, uint32_t free_cnt);
381799a2dd95SBruce Richardson 
381899a2dd95SBruce Richardson /**
381999a2dd95SBruce Richardson  * Subtypes for IPsec offload event(@ref RTE_ETH_EVENT_IPSEC) raised by
382099a2dd95SBruce Richardson  * eth device.
382199a2dd95SBruce Richardson  */
382299a2dd95SBruce Richardson enum rte_eth_event_ipsec_subtype {
38233c2ca0a9SAndrew Rybchenko 	/** Unknown event type */
382499a2dd95SBruce Richardson 	RTE_ETH_EVENT_IPSEC_UNKNOWN = 0,
38253c2ca0a9SAndrew Rybchenko 	/** Sequence number overflow */
382699a2dd95SBruce Richardson 	RTE_ETH_EVENT_IPSEC_ESN_OVERFLOW,
38273c2ca0a9SAndrew Rybchenko 	/** Soft time expiry of SA */
382899a2dd95SBruce Richardson 	RTE_ETH_EVENT_IPSEC_SA_TIME_EXPIRY,
38293c2ca0a9SAndrew Rybchenko 	/** Soft byte expiry of SA */
383099a2dd95SBruce Richardson 	RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY,
38313c2ca0a9SAndrew Rybchenko 	/** Max value of this enum */
383299a2dd95SBruce Richardson 	RTE_ETH_EVENT_IPSEC_MAX
383399a2dd95SBruce Richardson };
383499a2dd95SBruce Richardson 
383599a2dd95SBruce Richardson /**
383699a2dd95SBruce Richardson  * Descriptor for @ref RTE_ETH_EVENT_IPSEC event. Used by eth dev to send extra
383799a2dd95SBruce Richardson  * information of the IPsec offload event.
383899a2dd95SBruce Richardson  */
383999a2dd95SBruce Richardson struct rte_eth_event_ipsec_desc {
38403c2ca0a9SAndrew Rybchenko 	/** Type of RTE_ETH_EVENT_IPSEC_* event */
384199a2dd95SBruce Richardson 	enum rte_eth_event_ipsec_subtype subtype;
38423c2ca0a9SAndrew Rybchenko 	/**
38433c2ca0a9SAndrew Rybchenko 	 * Event specific metadata.
384499a2dd95SBruce Richardson 	 *
384599a2dd95SBruce Richardson 	 * For the following events, *userdata* registered
384699a2dd95SBruce Richardson 	 * with the *rte_security_session* would be returned
384799a2dd95SBruce Richardson 	 * as metadata,
384899a2dd95SBruce Richardson 	 *
384999a2dd95SBruce Richardson 	 * - @ref RTE_ETH_EVENT_IPSEC_ESN_OVERFLOW
385099a2dd95SBruce Richardson 	 * - @ref RTE_ETH_EVENT_IPSEC_SA_TIME_EXPIRY
385199a2dd95SBruce Richardson 	 * - @ref RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY
385299a2dd95SBruce Richardson 	 *
385399a2dd95SBruce Richardson 	 * @see struct rte_security_session_conf
385499a2dd95SBruce Richardson 	 *
385599a2dd95SBruce Richardson 	 */
38563c2ca0a9SAndrew Rybchenko 	uint64_t metadata;
385799a2dd95SBruce Richardson };
385899a2dd95SBruce Richardson 
385999a2dd95SBruce Richardson /**
386099a2dd95SBruce Richardson  * The eth device event type for interrupt, and maybe others in the future.
386199a2dd95SBruce Richardson  */
386299a2dd95SBruce Richardson enum rte_eth_event_type {
386399a2dd95SBruce Richardson 	RTE_ETH_EVENT_UNKNOWN,  /**< unknown event type */
386499a2dd95SBruce Richardson 	RTE_ETH_EVENT_INTR_LSC, /**< lsc interrupt event */
38653c2ca0a9SAndrew Rybchenko 	/** queue state event (enabled/disabled) */
386699a2dd95SBruce Richardson 	RTE_ETH_EVENT_QUEUE_STATE,
38673c2ca0a9SAndrew Rybchenko 	/** reset interrupt event, sent to VF on PF reset */
386899a2dd95SBruce Richardson 	RTE_ETH_EVENT_INTR_RESET,
386999a2dd95SBruce Richardson 	RTE_ETH_EVENT_VF_MBOX,  /**< message from the VF received by PF */
387099a2dd95SBruce Richardson 	RTE_ETH_EVENT_MACSEC,   /**< MACsec offload related event */
387199a2dd95SBruce Richardson 	RTE_ETH_EVENT_INTR_RMV, /**< device removal event */
387299a2dd95SBruce Richardson 	RTE_ETH_EVENT_NEW,      /**< port is probed */
387399a2dd95SBruce Richardson 	RTE_ETH_EVENT_DESTROY,  /**< port is released */
387499a2dd95SBruce Richardson 	RTE_ETH_EVENT_IPSEC,    /**< IPsec offload related event */
387599a2dd95SBruce Richardson 	RTE_ETH_EVENT_FLOW_AGED,/**< New aged-out flows is detected */
387699a2dd95SBruce Richardson 	RTE_ETH_EVENT_MAX       /**< max value of this enum */
387799a2dd95SBruce Richardson };
387899a2dd95SBruce Richardson 
38793c2ca0a9SAndrew Rybchenko /** User application callback to be registered for interrupts. */
388099a2dd95SBruce Richardson typedef int (*rte_eth_dev_cb_fn)(uint16_t port_id,
388199a2dd95SBruce Richardson 		enum rte_eth_event_type event, void *cb_arg, void *ret_param);
388299a2dd95SBruce Richardson 
388399a2dd95SBruce Richardson /**
388499a2dd95SBruce Richardson  * Register a callback function for port event.
388599a2dd95SBruce Richardson  *
388699a2dd95SBruce Richardson  * @param port_id
38875906be5aSAndrew Rybchenko  *  Port ID.
388899a2dd95SBruce Richardson  *  RTE_ETH_ALL means register the event for all port ids.
388999a2dd95SBruce Richardson  * @param event
389099a2dd95SBruce Richardson  *  Event interested.
389199a2dd95SBruce Richardson  * @param cb_fn
389299a2dd95SBruce Richardson  *  User supplied callback function to be called.
389399a2dd95SBruce Richardson  * @param cb_arg
389499a2dd95SBruce Richardson  *  Pointer to the parameters for the registered callback.
389599a2dd95SBruce Richardson  *
389699a2dd95SBruce Richardson  * @return
389799a2dd95SBruce Richardson  *  - On success, zero.
389899a2dd95SBruce Richardson  *  - On failure, a negative value.
389999a2dd95SBruce Richardson  */
390099a2dd95SBruce Richardson int rte_eth_dev_callback_register(uint16_t port_id,
390199a2dd95SBruce Richardson 			enum rte_eth_event_type event,
390299a2dd95SBruce Richardson 		rte_eth_dev_cb_fn cb_fn, void *cb_arg);
390399a2dd95SBruce Richardson 
390499a2dd95SBruce Richardson /**
390599a2dd95SBruce Richardson  * Unregister a callback function for port event.
390699a2dd95SBruce Richardson  *
390799a2dd95SBruce Richardson  * @param port_id
39085906be5aSAndrew Rybchenko  *  Port ID.
390999a2dd95SBruce Richardson  *  RTE_ETH_ALL means unregister the event for all port ids.
391099a2dd95SBruce Richardson  * @param event
391199a2dd95SBruce Richardson  *  Event interested.
391299a2dd95SBruce Richardson  * @param cb_fn
391399a2dd95SBruce Richardson  *  User supplied callback function to be called.
391499a2dd95SBruce Richardson  * @param cb_arg
391599a2dd95SBruce Richardson  *  Pointer to the parameters for the registered callback. -1 means to
391699a2dd95SBruce Richardson  *  remove all for the same callback address and same event.
391799a2dd95SBruce Richardson  *
391899a2dd95SBruce Richardson  * @return
391999a2dd95SBruce Richardson  *  - On success, zero.
392099a2dd95SBruce Richardson  *  - On failure, a negative value.
392199a2dd95SBruce Richardson  */
392299a2dd95SBruce Richardson int rte_eth_dev_callback_unregister(uint16_t port_id,
392399a2dd95SBruce Richardson 			enum rte_eth_event_type event,
392499a2dd95SBruce Richardson 		rte_eth_dev_cb_fn cb_fn, void *cb_arg);
392599a2dd95SBruce Richardson 
392699a2dd95SBruce Richardson /**
392709fd4227SAndrew Rybchenko  * When there is no Rx packet coming in Rx Queue for a long time, we can
392809fd4227SAndrew Rybchenko  * sleep lcore related to Rx Queue for power saving, and enable Rx interrupt
392999a2dd95SBruce Richardson  * to be triggered when Rx packet arrives.
393099a2dd95SBruce Richardson  *
393109fd4227SAndrew Rybchenko  * The rte_eth_dev_rx_intr_enable() function enables Rx queue
393209fd4227SAndrew Rybchenko  * interrupt on specific Rx queue of a port.
393399a2dd95SBruce Richardson  *
393499a2dd95SBruce Richardson  * @param port_id
393599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
393699a2dd95SBruce Richardson  * @param queue_id
393799a2dd95SBruce Richardson  *   The index of the receive queue from which to retrieve input packets.
393899a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
393999a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
394099a2dd95SBruce Richardson  * @return
394199a2dd95SBruce Richardson  *   - (0) if successful.
394299a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
394399a2dd95SBruce Richardson  *     that operation.
394499a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
394599a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
394699a2dd95SBruce Richardson  */
394799a2dd95SBruce Richardson int rte_eth_dev_rx_intr_enable(uint16_t port_id, uint16_t queue_id);
394899a2dd95SBruce Richardson 
394999a2dd95SBruce Richardson /**
395009fd4227SAndrew Rybchenko  * When lcore wakes up from Rx interrupt indicating packet coming, disable Rx
395199a2dd95SBruce Richardson  * interrupt and returns to polling mode.
395299a2dd95SBruce Richardson  *
395309fd4227SAndrew Rybchenko  * The rte_eth_dev_rx_intr_disable() function disables Rx queue
395409fd4227SAndrew Rybchenko  * interrupt on specific Rx queue of a port.
395599a2dd95SBruce Richardson  *
395699a2dd95SBruce Richardson  * @param port_id
395799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
395899a2dd95SBruce Richardson  * @param queue_id
395999a2dd95SBruce Richardson  *   The index of the receive queue from which to retrieve input packets.
396099a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
396199a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
396299a2dd95SBruce Richardson  * @return
396399a2dd95SBruce Richardson  *   - (0) if successful.
396499a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
396599a2dd95SBruce Richardson  *     that operation.
396699a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
396799a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
396899a2dd95SBruce Richardson  */
396999a2dd95SBruce Richardson int rte_eth_dev_rx_intr_disable(uint16_t port_id, uint16_t queue_id);
397099a2dd95SBruce Richardson 
397199a2dd95SBruce Richardson /**
397209fd4227SAndrew Rybchenko  * Rx Interrupt control per port.
397399a2dd95SBruce Richardson  *
397499a2dd95SBruce Richardson  * @param port_id
397599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
397699a2dd95SBruce Richardson  * @param epfd
397799a2dd95SBruce Richardson  *   Epoll instance fd which the intr vector associated to.
397899a2dd95SBruce Richardson  *   Using RTE_EPOLL_PER_THREAD allows to use per thread epoll instance.
397999a2dd95SBruce Richardson  * @param op
398099a2dd95SBruce Richardson  *   The operation be performed for the vector.
398199a2dd95SBruce Richardson  *   Operation type of {RTE_INTR_EVENT_ADD, RTE_INTR_EVENT_DEL}.
398299a2dd95SBruce Richardson  * @param data
398399a2dd95SBruce Richardson  *   User raw data.
398499a2dd95SBruce Richardson  * @return
398599a2dd95SBruce Richardson  *   - On success, zero.
398699a2dd95SBruce Richardson  *   - On failure, a negative value.
398799a2dd95SBruce Richardson  */
398899a2dd95SBruce Richardson int rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data);
398999a2dd95SBruce Richardson 
399099a2dd95SBruce Richardson /**
399109fd4227SAndrew Rybchenko  * Rx Interrupt control per queue.
399299a2dd95SBruce Richardson  *
399399a2dd95SBruce Richardson  * @param port_id
399499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
399599a2dd95SBruce Richardson  * @param queue_id
399699a2dd95SBruce Richardson  *   The index of the receive queue from which to retrieve input packets.
399799a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
399899a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
399999a2dd95SBruce Richardson  * @param epfd
400099a2dd95SBruce Richardson  *   Epoll instance fd which the intr vector associated to.
400199a2dd95SBruce Richardson  *   Using RTE_EPOLL_PER_THREAD allows to use per thread epoll instance.
400299a2dd95SBruce Richardson  * @param op
400399a2dd95SBruce Richardson  *   The operation be performed for the vector.
400499a2dd95SBruce Richardson  *   Operation type of {RTE_INTR_EVENT_ADD, RTE_INTR_EVENT_DEL}.
400599a2dd95SBruce Richardson  * @param data
400699a2dd95SBruce Richardson  *   User raw data.
400799a2dd95SBruce Richardson  * @return
400899a2dd95SBruce Richardson  *   - On success, zero.
400999a2dd95SBruce Richardson  *   - On failure, a negative value.
401099a2dd95SBruce Richardson  */
401199a2dd95SBruce Richardson int rte_eth_dev_rx_intr_ctl_q(uint16_t port_id, uint16_t queue_id,
401299a2dd95SBruce Richardson 			      int epfd, int op, void *data);
401399a2dd95SBruce Richardson 
401499a2dd95SBruce Richardson /**
401599a2dd95SBruce Richardson  * Get interrupt fd per Rx queue.
401699a2dd95SBruce Richardson  *
401799a2dd95SBruce Richardson  * @param port_id
401899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
401999a2dd95SBruce Richardson  * @param queue_id
402099a2dd95SBruce Richardson  *   The index of the receive queue from which to retrieve input packets.
402199a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
402299a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
402399a2dd95SBruce Richardson  * @return
402499a2dd95SBruce Richardson  *   - (>=0) the interrupt fd associated to the requested Rx queue if
402599a2dd95SBruce Richardson  *           successful.
402699a2dd95SBruce Richardson  *   - (-1) on error.
402799a2dd95SBruce Richardson  */
402899a2dd95SBruce Richardson int
402999a2dd95SBruce Richardson rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t queue_id);
403099a2dd95SBruce Richardson 
403199a2dd95SBruce Richardson /**
403299a2dd95SBruce Richardson  * Turn on the LED on the Ethernet device.
403399a2dd95SBruce Richardson  * This function turns on the LED on the Ethernet device.
403499a2dd95SBruce Richardson  *
403599a2dd95SBruce Richardson  * @param port_id
403699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
403799a2dd95SBruce Richardson  * @return
403899a2dd95SBruce Richardson  *   - (0) if successful.
403999a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
404099a2dd95SBruce Richardson  *     that operation.
404199a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
404299a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
404399a2dd95SBruce Richardson  */
404499a2dd95SBruce Richardson int  rte_eth_led_on(uint16_t port_id);
404599a2dd95SBruce Richardson 
404699a2dd95SBruce Richardson /**
404799a2dd95SBruce Richardson  * Turn off the LED on the Ethernet device.
404899a2dd95SBruce Richardson  * This function turns off the LED on the Ethernet device.
404999a2dd95SBruce Richardson  *
405099a2dd95SBruce Richardson  * @param port_id
405199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
405299a2dd95SBruce Richardson  * @return
405399a2dd95SBruce Richardson  *   - (0) if successful.
405499a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
405599a2dd95SBruce Richardson  *     that operation.
405699a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
405799a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
405899a2dd95SBruce Richardson  */
405999a2dd95SBruce Richardson int  rte_eth_led_off(uint16_t port_id);
406099a2dd95SBruce Richardson 
406199a2dd95SBruce Richardson /**
406299a2dd95SBruce Richardson  * @warning
406399a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
406499a2dd95SBruce Richardson  *
406599a2dd95SBruce Richardson  * Get Forward Error Correction(FEC) capability.
406699a2dd95SBruce Richardson  *
406799a2dd95SBruce Richardson  * @param port_id
406899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
406999a2dd95SBruce Richardson  * @param speed_fec_capa
407099a2dd95SBruce Richardson  *   speed_fec_capa is out only with per-speed capabilities.
407199a2dd95SBruce Richardson  *   If set to NULL, the function returns the required number
407299a2dd95SBruce Richardson  *   of required array entries.
407399a2dd95SBruce Richardson  * @param num
407499a2dd95SBruce Richardson  *   a number of elements in an speed_fec_capa array.
407599a2dd95SBruce Richardson  *
407699a2dd95SBruce Richardson  * @return
407799a2dd95SBruce Richardson  *   - A non-negative value lower or equal to num: success. The return value
407899a2dd95SBruce Richardson  *     is the number of entries filled in the fec capa array.
407999a2dd95SBruce Richardson  *   - A non-negative value higher than num: error, the given fec capa array
408099a2dd95SBruce Richardson  *     is too small. The return value corresponds to the num that should
408199a2dd95SBruce Richardson  *     be given to succeed. The entries in fec capa array are not valid and
408299a2dd95SBruce Richardson  *     shall not be used by the caller.
408399a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
408499a2dd95SBruce Richardson  *     that operation.
408599a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
408699a2dd95SBruce Richardson  *   - (-ENODEV)  if *port_id* invalid.
408799a2dd95SBruce Richardson  *   - (-EINVAL)  if *num* or *speed_fec_capa* invalid
408899a2dd95SBruce Richardson  */
408999a2dd95SBruce Richardson __rte_experimental
409099a2dd95SBruce Richardson int rte_eth_fec_get_capability(uint16_t port_id,
409199a2dd95SBruce Richardson 			       struct rte_eth_fec_capa *speed_fec_capa,
409299a2dd95SBruce Richardson 			       unsigned int num);
409399a2dd95SBruce Richardson 
409499a2dd95SBruce Richardson /**
409599a2dd95SBruce Richardson  * @warning
409699a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
409799a2dd95SBruce Richardson  *
409899a2dd95SBruce Richardson  * Get current Forward Error Correction(FEC) mode.
409999a2dd95SBruce Richardson  * If link is down and AUTO is enabled, AUTO is returned, otherwise,
410099a2dd95SBruce Richardson  * configured FEC mode is returned.
410199a2dd95SBruce Richardson  * If link is up, current FEC mode is returned.
410299a2dd95SBruce Richardson  *
410399a2dd95SBruce Richardson  * @param port_id
410499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
410599a2dd95SBruce Richardson  * @param fec_capa
410699a2dd95SBruce Richardson  *   A bitmask of enabled FEC modes. If AUTO bit is set, other
410799a2dd95SBruce Richardson  *   bits specify FEC modes which may be negotiated. If AUTO
410899a2dd95SBruce Richardson  *   bit is clear, specify FEC modes to be used (only one valid
410999a2dd95SBruce Richardson  *   mode per speed may be set).
411099a2dd95SBruce Richardson  * @return
411199a2dd95SBruce Richardson  *   - (0) if successful.
411299a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
411399a2dd95SBruce Richardson  *     that operation.
411499a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
411599a2dd95SBruce Richardson  *   - (-ENODEV)  if *port_id* invalid.
411699a2dd95SBruce Richardson  */
411799a2dd95SBruce Richardson __rte_experimental
411899a2dd95SBruce Richardson int rte_eth_fec_get(uint16_t port_id, uint32_t *fec_capa);
411999a2dd95SBruce Richardson 
412099a2dd95SBruce Richardson /**
412199a2dd95SBruce Richardson  * @warning
412299a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
412399a2dd95SBruce Richardson  *
412499a2dd95SBruce Richardson  * Set Forward Error Correction(FEC) mode.
412599a2dd95SBruce Richardson  *
412699a2dd95SBruce Richardson  * @param port_id
412799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
412899a2dd95SBruce Richardson  * @param fec_capa
412999a2dd95SBruce Richardson  *   A bitmask of allowed FEC modes. If AUTO bit is set, other
413099a2dd95SBruce Richardson  *   bits specify FEC modes which may be negotiated. If AUTO
413199a2dd95SBruce Richardson  *   bit is clear, specify FEC modes to be used (only one valid
413299a2dd95SBruce Richardson  *   mode per speed may be set).
413399a2dd95SBruce Richardson  * @return
413499a2dd95SBruce Richardson  *   - (0) if successful.
413599a2dd95SBruce Richardson  *   - (-EINVAL) if the FEC mode is not valid.
413699a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
413799a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
413899a2dd95SBruce Richardson  *   - (-ENODEV)  if *port_id* invalid.
413999a2dd95SBruce Richardson  */
414099a2dd95SBruce Richardson __rte_experimental
414199a2dd95SBruce Richardson int rte_eth_fec_set(uint16_t port_id, uint32_t fec_capa);
414299a2dd95SBruce Richardson 
414399a2dd95SBruce Richardson /**
414499a2dd95SBruce Richardson  * Get current status of the Ethernet link flow control for Ethernet device
414599a2dd95SBruce Richardson  *
414699a2dd95SBruce Richardson  * @param port_id
414799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
414899a2dd95SBruce Richardson  * @param fc_conf
414999a2dd95SBruce Richardson  *   The pointer to the structure where to store the flow control parameters.
415099a2dd95SBruce Richardson  * @return
415199a2dd95SBruce Richardson  *   - (0) if successful.
415299a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support flow control.
415399a2dd95SBruce Richardson  *   - (-ENODEV)  if *port_id* invalid.
415499a2dd95SBruce Richardson  *   - (-EIO)  if device is removed.
415553ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
415699a2dd95SBruce Richardson  */
415799a2dd95SBruce Richardson int rte_eth_dev_flow_ctrl_get(uint16_t port_id,
415899a2dd95SBruce Richardson 			      struct rte_eth_fc_conf *fc_conf);
415999a2dd95SBruce Richardson 
416099a2dd95SBruce Richardson /**
416199a2dd95SBruce Richardson  * Configure the Ethernet link flow control for Ethernet device
416299a2dd95SBruce Richardson  *
416399a2dd95SBruce Richardson  * @param port_id
416499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
416599a2dd95SBruce Richardson  * @param fc_conf
416699a2dd95SBruce Richardson  *   The pointer to the structure of the flow control parameters.
416799a2dd95SBruce Richardson  * @return
416899a2dd95SBruce Richardson  *   - (0) if successful.
416999a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support flow control mode.
417099a2dd95SBruce Richardson  *   - (-ENODEV)  if *port_id* invalid.
417199a2dd95SBruce Richardson  *   - (-EINVAL)  if bad parameter
417299a2dd95SBruce Richardson  *   - (-EIO)     if flow control setup failure or device is removed.
417399a2dd95SBruce Richardson  */
417499a2dd95SBruce Richardson int rte_eth_dev_flow_ctrl_set(uint16_t port_id,
417599a2dd95SBruce Richardson 			      struct rte_eth_fc_conf *fc_conf);
417699a2dd95SBruce Richardson 
417799a2dd95SBruce Richardson /**
417899a2dd95SBruce Richardson  * Configure the Ethernet priority flow control under DCB environment
417999a2dd95SBruce Richardson  * for Ethernet device.
418099a2dd95SBruce Richardson  *
418199a2dd95SBruce Richardson  * @param port_id
418299a2dd95SBruce Richardson  * The port identifier of the Ethernet device.
418399a2dd95SBruce Richardson  * @param pfc_conf
418499a2dd95SBruce Richardson  * The pointer to the structure of the priority flow control parameters.
418599a2dd95SBruce Richardson  * @return
418699a2dd95SBruce Richardson  *   - (0) if successful.
418799a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support priority flow control mode.
418899a2dd95SBruce Richardson  *   - (-ENODEV)  if *port_id* invalid.
418999a2dd95SBruce Richardson  *   - (-EINVAL)  if bad parameter
419099a2dd95SBruce Richardson  *   - (-EIO)     if flow control setup failure or device is removed.
419199a2dd95SBruce Richardson  */
419299a2dd95SBruce Richardson int rte_eth_dev_priority_flow_ctrl_set(uint16_t port_id,
419399a2dd95SBruce Richardson 				struct rte_eth_pfc_conf *pfc_conf);
419499a2dd95SBruce Richardson 
419599a2dd95SBruce Richardson /**
419699a2dd95SBruce Richardson  * Add a MAC address to the set used for filtering incoming packets.
419799a2dd95SBruce Richardson  *
419899a2dd95SBruce Richardson  * @param port_id
419999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
420099a2dd95SBruce Richardson  * @param mac_addr
420199a2dd95SBruce Richardson  *   The MAC address to add.
420299a2dd95SBruce Richardson  * @param pool
420399a2dd95SBruce Richardson  *   VMDq pool index to associate address with (if VMDq is enabled). If VMDq is
420499a2dd95SBruce Richardson  *   not enabled, this should be set to 0.
420599a2dd95SBruce Richardson  * @return
420699a2dd95SBruce Richardson  *   - (0) if successfully added or *mac_addr* was already added.
420799a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support this feature.
420899a2dd95SBruce Richardson  *   - (-ENODEV) if *port* is invalid.
420999a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
421099a2dd95SBruce Richardson  *   - (-ENOSPC) if no more MAC addresses can be added.
421199a2dd95SBruce Richardson  *   - (-EINVAL) if MAC address is invalid.
421299a2dd95SBruce Richardson  */
421399a2dd95SBruce Richardson int rte_eth_dev_mac_addr_add(uint16_t port_id, struct rte_ether_addr *mac_addr,
421499a2dd95SBruce Richardson 				uint32_t pool);
421599a2dd95SBruce Richardson 
421699a2dd95SBruce Richardson /**
42170de345e9SJerin Jacob  * @warning
42180de345e9SJerin Jacob  * @b EXPERIMENTAL: this API may change without prior notice.
42190de345e9SJerin Jacob  *
42200de345e9SJerin Jacob  * Retrieve the information for queue based PFC.
42210de345e9SJerin Jacob  *
42220de345e9SJerin Jacob  * @param port_id
42230de345e9SJerin Jacob  *   The port identifier of the Ethernet device.
42240de345e9SJerin Jacob  * @param pfc_queue_info
42250de345e9SJerin Jacob  *   A pointer to a structure of type *rte_eth_pfc_queue_info* to be filled with
42260de345e9SJerin Jacob  *   the information about queue based PFC.
42270de345e9SJerin Jacob  * @return
42280de345e9SJerin Jacob  *   - (0) if successful.
42290de345e9SJerin Jacob  *   - (-ENOTSUP) if support for priority_flow_ctrl_queue_info_get does not exist.
42300de345e9SJerin Jacob  *   - (-ENODEV) if *port_id* invalid.
42310de345e9SJerin Jacob  *   - (-EINVAL) if bad parameter.
42320de345e9SJerin Jacob  */
42330de345e9SJerin Jacob __rte_experimental
42340de345e9SJerin Jacob int rte_eth_dev_priority_flow_ctrl_queue_info_get(uint16_t port_id,
42350de345e9SJerin Jacob 		struct rte_eth_pfc_queue_info *pfc_queue_info);
42360de345e9SJerin Jacob 
42370de345e9SJerin Jacob /**
42380de345e9SJerin Jacob  * @warning
42390de345e9SJerin Jacob  * @b EXPERIMENTAL: this API may change without prior notice.
42400de345e9SJerin Jacob  *
42410de345e9SJerin Jacob  * Configure the queue based priority flow control for a given queue
42420de345e9SJerin Jacob  * for Ethernet device.
42430de345e9SJerin Jacob  *
42440de345e9SJerin Jacob  * @note When an ethdev port switches to queue based PFC mode, the
42450de345e9SJerin Jacob  * unconfigured queues shall be configured by the driver with
42460de345e9SJerin Jacob  * default values such as lower priority value for TC etc.
42470de345e9SJerin Jacob  *
42480de345e9SJerin Jacob  * @param port_id
42490de345e9SJerin Jacob  *   The port identifier of the Ethernet device.
42500de345e9SJerin Jacob  * @param pfc_queue_conf
42510de345e9SJerin Jacob  *   The pointer to the structure of the priority flow control parameters
42520de345e9SJerin Jacob  *   for the queue.
42530de345e9SJerin Jacob  * @return
42540de345e9SJerin Jacob  *   - (0) if successful.
42550de345e9SJerin Jacob  *   - (-ENOTSUP) if hardware doesn't support queue based PFC mode.
42560de345e9SJerin Jacob  *   - (-ENODEV)  if *port_id* invalid.
42570de345e9SJerin Jacob  *   - (-EINVAL)  if bad parameter
42580de345e9SJerin Jacob  *   - (-EIO)     if flow control setup queue failure
42590de345e9SJerin Jacob  */
42600de345e9SJerin Jacob __rte_experimental
42610de345e9SJerin Jacob int rte_eth_dev_priority_flow_ctrl_queue_configure(uint16_t port_id,
42620de345e9SJerin Jacob 		struct rte_eth_pfc_queue_conf *pfc_queue_conf);
42630de345e9SJerin Jacob 
42640de345e9SJerin Jacob /**
426599a2dd95SBruce Richardson  * Remove a MAC address from the internal array of addresses.
426699a2dd95SBruce Richardson  *
426799a2dd95SBruce Richardson  * @param port_id
426899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
426999a2dd95SBruce Richardson  * @param mac_addr
427099a2dd95SBruce Richardson  *   MAC address to remove.
427199a2dd95SBruce Richardson  * @return
427299a2dd95SBruce Richardson  *   - (0) if successful, or *mac_addr* didn't exist.
427399a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
427499a2dd95SBruce Richardson  *   - (-ENODEV) if *port* invalid.
427553ef1b34SMin Hu (Connor)  *   - (-EADDRINUSE) if attempting to remove the default MAC address.
427653ef1b34SMin Hu (Connor)  *   - (-EINVAL) if MAC address is invalid.
427799a2dd95SBruce Richardson  */
427899a2dd95SBruce Richardson int rte_eth_dev_mac_addr_remove(uint16_t port_id,
427999a2dd95SBruce Richardson 				struct rte_ether_addr *mac_addr);
428099a2dd95SBruce Richardson 
428199a2dd95SBruce Richardson /**
428299a2dd95SBruce Richardson  * Set the default MAC address.
428399a2dd95SBruce Richardson  *
428499a2dd95SBruce Richardson  * @param port_id
428599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
428699a2dd95SBruce Richardson  * @param mac_addr
428799a2dd95SBruce Richardson  *   New default MAC address.
428899a2dd95SBruce Richardson  * @return
428999a2dd95SBruce Richardson  *   - (0) if successful, or *mac_addr* didn't exist.
429099a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
429199a2dd95SBruce Richardson  *   - (-ENODEV) if *port* invalid.
429299a2dd95SBruce Richardson  *   - (-EINVAL) if MAC address is invalid.
429399a2dd95SBruce Richardson  */
429499a2dd95SBruce Richardson int rte_eth_dev_default_mac_addr_set(uint16_t port_id,
429599a2dd95SBruce Richardson 		struct rte_ether_addr *mac_addr);
429699a2dd95SBruce Richardson 
429799a2dd95SBruce Richardson /**
429899a2dd95SBruce Richardson  * Update Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
429999a2dd95SBruce Richardson  *
430099a2dd95SBruce Richardson  * @param port_id
430199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
430299a2dd95SBruce Richardson  * @param reta_conf
430399a2dd95SBruce Richardson  *   RETA to update.
430499a2dd95SBruce Richardson  * @param reta_size
430599a2dd95SBruce Richardson  *   Redirection table size. The table size can be queried by
430699a2dd95SBruce Richardson  *   rte_eth_dev_info_get().
430799a2dd95SBruce Richardson  * @return
430899a2dd95SBruce Richardson  *   - (0) if successful.
430999a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
431099a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
431199a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
431299a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
431399a2dd95SBruce Richardson  */
431499a2dd95SBruce Richardson int rte_eth_dev_rss_reta_update(uint16_t port_id,
431599a2dd95SBruce Richardson 				struct rte_eth_rss_reta_entry64 *reta_conf,
431699a2dd95SBruce Richardson 				uint16_t reta_size);
431799a2dd95SBruce Richardson 
431899a2dd95SBruce Richardson /**
431999a2dd95SBruce Richardson  * Query Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
432099a2dd95SBruce Richardson  *
432199a2dd95SBruce Richardson  * @param port_id
432299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
432399a2dd95SBruce Richardson  * @param reta_conf
432499a2dd95SBruce Richardson  *   RETA to query. For each requested reta entry, corresponding bit
432599a2dd95SBruce Richardson  *   in mask must be set.
432699a2dd95SBruce Richardson  * @param reta_size
432799a2dd95SBruce Richardson  *   Redirection table size. The table size can be queried by
432899a2dd95SBruce Richardson  *   rte_eth_dev_info_get().
432999a2dd95SBruce Richardson  * @return
433099a2dd95SBruce Richardson  *   - (0) if successful.
433199a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
433299a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
433399a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
433499a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
433599a2dd95SBruce Richardson  */
433699a2dd95SBruce Richardson int rte_eth_dev_rss_reta_query(uint16_t port_id,
433799a2dd95SBruce Richardson 			       struct rte_eth_rss_reta_entry64 *reta_conf,
433899a2dd95SBruce Richardson 			       uint16_t reta_size);
433999a2dd95SBruce Richardson 
434099a2dd95SBruce Richardson /**
434199a2dd95SBruce Richardson  * Updates unicast hash table for receiving packet with the given destination
434209fd4227SAndrew Rybchenko  * MAC address, and the packet is routed to all VFs for which the Rx mode is
434399a2dd95SBruce Richardson  * accept packets that match the unicast hash table.
434499a2dd95SBruce Richardson  *
434599a2dd95SBruce Richardson  * @param port_id
434699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
434799a2dd95SBruce Richardson  * @param addr
434899a2dd95SBruce Richardson  *   Unicast MAC address.
434999a2dd95SBruce Richardson  * @param on
435099a2dd95SBruce Richardson  *    1 - Set an unicast hash bit for receiving packets with the MAC address.
435199a2dd95SBruce Richardson  *    0 - Clear an unicast hash bit.
435299a2dd95SBruce Richardson  * @return
435399a2dd95SBruce Richardson  *   - (0) if successful.
435499a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
435599a2dd95SBruce Richardson   *  - (-ENODEV) if *port_id* invalid.
435699a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
435799a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
435899a2dd95SBruce Richardson  */
435999a2dd95SBruce Richardson int rte_eth_dev_uc_hash_table_set(uint16_t port_id, struct rte_ether_addr *addr,
436099a2dd95SBruce Richardson 				  uint8_t on);
436199a2dd95SBruce Richardson 
436299a2dd95SBruce Richardson /**
436399a2dd95SBruce Richardson  * Updates all unicast hash bitmaps for receiving packet with any Unicast
436409fd4227SAndrew Rybchenko  * Ethernet MAC addresses,the packet is routed to all VFs for which the Rx
436599a2dd95SBruce Richardson  * mode is accept packets that match the unicast hash table.
436699a2dd95SBruce Richardson  *
436799a2dd95SBruce Richardson  * @param port_id
436899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
436999a2dd95SBruce Richardson  * @param on
437099a2dd95SBruce Richardson  *    1 - Set all unicast hash bitmaps for receiving all the Ethernet
437199a2dd95SBruce Richardson  *         MAC addresses
437299a2dd95SBruce Richardson  *    0 - Clear all unicast hash bitmaps
437399a2dd95SBruce Richardson  * @return
437499a2dd95SBruce Richardson  *   - (0) if successful.
437599a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
437699a2dd95SBruce Richardson   *  - (-ENODEV) if *port_id* invalid.
437799a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
437899a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
437999a2dd95SBruce Richardson  */
438099a2dd95SBruce Richardson int rte_eth_dev_uc_all_hash_table_set(uint16_t port_id, uint8_t on);
438199a2dd95SBruce Richardson 
438299a2dd95SBruce Richardson /**
438399a2dd95SBruce Richardson  * Set the rate limitation for a queue on an Ethernet device.
438499a2dd95SBruce Richardson  *
438599a2dd95SBruce Richardson  * @param port_id
438699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
438799a2dd95SBruce Richardson  * @param queue_idx
43885906be5aSAndrew Rybchenko  *   The queue ID.
438999a2dd95SBruce Richardson  * @param tx_rate
439009fd4227SAndrew Rybchenko  *   The Tx rate in Mbps. Allocated from the total port link speed.
439199a2dd95SBruce Richardson  * @return
439299a2dd95SBruce Richardson  *   - (0) if successful.
439399a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support this feature.
439499a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
439599a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
439699a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
439799a2dd95SBruce Richardson  */
439899a2dd95SBruce Richardson int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx,
439999a2dd95SBruce Richardson 			uint16_t tx_rate);
440099a2dd95SBruce Richardson 
440199a2dd95SBruce Richardson /**
440299a2dd95SBruce Richardson  * Configuration of Receive Side Scaling hash computation of Ethernet device.
440399a2dd95SBruce Richardson  *
440499a2dd95SBruce Richardson  * @param port_id
440599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
440699a2dd95SBruce Richardson  * @param rss_conf
440799a2dd95SBruce Richardson  *   The new configuration to use for RSS hash computation on the port.
440899a2dd95SBruce Richardson  * @return
440999a2dd95SBruce Richardson  *   - (0) if successful.
441099a2dd95SBruce Richardson  *   - (-ENODEV) if port identifier is invalid.
441199a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
441299a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
441399a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
441499a2dd95SBruce Richardson  */
441599a2dd95SBruce Richardson int rte_eth_dev_rss_hash_update(uint16_t port_id,
441699a2dd95SBruce Richardson 				struct rte_eth_rss_conf *rss_conf);
441799a2dd95SBruce Richardson 
441899a2dd95SBruce Richardson /**
441999a2dd95SBruce Richardson  * Retrieve current configuration of Receive Side Scaling hash computation
442099a2dd95SBruce Richardson  * of Ethernet device.
442199a2dd95SBruce Richardson  *
442299a2dd95SBruce Richardson  * @param port_id
442399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
442499a2dd95SBruce Richardson  * @param rss_conf
442599a2dd95SBruce Richardson  *   Where to store the current RSS hash configuration of the Ethernet device.
442699a2dd95SBruce Richardson  * @return
442799a2dd95SBruce Richardson  *   - (0) if successful.
442899a2dd95SBruce Richardson  *   - (-ENODEV) if port identifier is invalid.
442999a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
443099a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support RSS.
443153ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
443299a2dd95SBruce Richardson  */
443399a2dd95SBruce Richardson int
443499a2dd95SBruce Richardson rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
443599a2dd95SBruce Richardson 			      struct rte_eth_rss_conf *rss_conf);
443699a2dd95SBruce Richardson 
443799a2dd95SBruce Richardson /**
443899a2dd95SBruce Richardson  * Add UDP tunneling port for a type of tunnel.
443999a2dd95SBruce Richardson  *
444099a2dd95SBruce Richardson  * Some NICs may require such configuration to properly parse a tunnel
444199a2dd95SBruce Richardson  * with any standard or custom UDP port.
444299a2dd95SBruce Richardson  * The packets with this UDP port will be parsed for this type of tunnel.
444399a2dd95SBruce Richardson  * The device parser will also check the rest of the tunnel headers
444499a2dd95SBruce Richardson  * before classifying the packet.
444599a2dd95SBruce Richardson  *
444699a2dd95SBruce Richardson  * With some devices, this API will affect packet classification, i.e.:
444799a2dd95SBruce Richardson  *     - mbuf.packet_type reported on Rx
444899a2dd95SBruce Richardson  *     - rte_flow rules with tunnel items
444999a2dd95SBruce Richardson  *
445099a2dd95SBruce Richardson  * @param port_id
445199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
445299a2dd95SBruce Richardson  * @param tunnel_udp
445399a2dd95SBruce Richardson  *   UDP tunneling configuration.
445499a2dd95SBruce Richardson  *
445599a2dd95SBruce Richardson  * @return
445699a2dd95SBruce Richardson  *   - (0) if successful.
445799a2dd95SBruce Richardson  *   - (-ENODEV) if port identifier is invalid.
445899a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
445999a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support tunnel type.
446099a2dd95SBruce Richardson  */
446199a2dd95SBruce Richardson int
446299a2dd95SBruce Richardson rte_eth_dev_udp_tunnel_port_add(uint16_t port_id,
446399a2dd95SBruce Richardson 				struct rte_eth_udp_tunnel *tunnel_udp);
446499a2dd95SBruce Richardson 
446599a2dd95SBruce Richardson /**
446699a2dd95SBruce Richardson  * Delete UDP tunneling port for a type of tunnel.
446799a2dd95SBruce Richardson  *
446899a2dd95SBruce Richardson  * The packets with this UDP port will not be classified as this type of tunnel
446999a2dd95SBruce Richardson  * anymore if the device use such mapping for tunnel packet classification.
447099a2dd95SBruce Richardson  *
447199a2dd95SBruce Richardson  * @see rte_eth_dev_udp_tunnel_port_add
447299a2dd95SBruce Richardson  *
447399a2dd95SBruce Richardson  * @param port_id
447499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
447599a2dd95SBruce Richardson  * @param tunnel_udp
447699a2dd95SBruce Richardson  *   UDP tunneling configuration.
447799a2dd95SBruce Richardson  *
447899a2dd95SBruce Richardson  * @return
447999a2dd95SBruce Richardson  *   - (0) if successful.
448099a2dd95SBruce Richardson  *   - (-ENODEV) if port identifier is invalid.
448199a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
448299a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support tunnel type.
448399a2dd95SBruce Richardson  */
448499a2dd95SBruce Richardson int
448599a2dd95SBruce Richardson rte_eth_dev_udp_tunnel_port_delete(uint16_t port_id,
448699a2dd95SBruce Richardson 				   struct rte_eth_udp_tunnel *tunnel_udp);
448799a2dd95SBruce Richardson 
448899a2dd95SBruce Richardson /**
448999a2dd95SBruce Richardson  * Get DCB information on an Ethernet device.
449099a2dd95SBruce Richardson  *
449199a2dd95SBruce Richardson  * @param port_id
449299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
449399a2dd95SBruce Richardson  * @param dcb_info
4494064e90c4SAndrew Rybchenko  *   DCB information.
449599a2dd95SBruce Richardson  * @return
449699a2dd95SBruce Richardson  *   - (0) if successful.
449799a2dd95SBruce Richardson  *   - (-ENODEV) if port identifier is invalid.
449899a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
449999a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
450053ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
450199a2dd95SBruce Richardson  */
450299a2dd95SBruce Richardson int rte_eth_dev_get_dcb_info(uint16_t port_id,
450399a2dd95SBruce Richardson 			     struct rte_eth_dcb_info *dcb_info);
450499a2dd95SBruce Richardson 
450599a2dd95SBruce Richardson struct rte_eth_rxtx_callback;
450699a2dd95SBruce Richardson 
450799a2dd95SBruce Richardson /**
450809fd4227SAndrew Rybchenko  * Add a callback to be called on packet Rx on a given port and queue.
450999a2dd95SBruce Richardson  *
451099a2dd95SBruce Richardson  * This API configures a function to be called for each burst of
451199a2dd95SBruce Richardson  * packets received on a given NIC port queue. The return value is a pointer
451299a2dd95SBruce Richardson  * that can be used to later remove the callback using
451399a2dd95SBruce Richardson  * rte_eth_remove_rx_callback().
451499a2dd95SBruce Richardson  *
451599a2dd95SBruce Richardson  * Multiple functions are called in the order that they are added.
451699a2dd95SBruce Richardson  *
451799a2dd95SBruce Richardson  * @param port_id
451899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
451999a2dd95SBruce Richardson  * @param queue_id
452099a2dd95SBruce Richardson  *   The queue on the Ethernet device on which the callback is to be added.
452199a2dd95SBruce Richardson  * @param fn
452299a2dd95SBruce Richardson  *   The callback function
452399a2dd95SBruce Richardson  * @param user_param
452499a2dd95SBruce Richardson  *   A generic pointer parameter which will be passed to each invocation of the
452599a2dd95SBruce Richardson  *   callback function on this port and queue. Inter-thread synchronization
452699a2dd95SBruce Richardson  *   of any user data changes is the responsibility of the user.
452799a2dd95SBruce Richardson  *
452899a2dd95SBruce Richardson  * @return
452999a2dd95SBruce Richardson  *   NULL on error.
453099a2dd95SBruce Richardson  *   On success, a pointer value which can later be used to remove the callback.
453199a2dd95SBruce Richardson  */
453299a2dd95SBruce Richardson const struct rte_eth_rxtx_callback *
453399a2dd95SBruce Richardson rte_eth_add_rx_callback(uint16_t port_id, uint16_t queue_id,
453499a2dd95SBruce Richardson 		rte_rx_callback_fn fn, void *user_param);
453599a2dd95SBruce Richardson 
453699a2dd95SBruce Richardson /**
453709fd4227SAndrew Rybchenko  * Add a callback that must be called first on packet Rx on a given port
453899a2dd95SBruce Richardson  * and queue.
453999a2dd95SBruce Richardson  *
454099a2dd95SBruce Richardson  * This API configures a first function to be called for each burst of
454199a2dd95SBruce Richardson  * packets received on a given NIC port queue. The return value is a pointer
454299a2dd95SBruce Richardson  * that can be used to later remove the callback using
454399a2dd95SBruce Richardson  * rte_eth_remove_rx_callback().
454499a2dd95SBruce Richardson  *
454599a2dd95SBruce Richardson  * Multiple functions are called in the order that they are added.
454699a2dd95SBruce Richardson  *
454799a2dd95SBruce Richardson  * @param port_id
454899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
454999a2dd95SBruce Richardson  * @param queue_id
455099a2dd95SBruce Richardson  *   The queue on the Ethernet device on which the callback is to be added.
455199a2dd95SBruce Richardson  * @param fn
455299a2dd95SBruce Richardson  *   The callback function
455399a2dd95SBruce Richardson  * @param user_param
455499a2dd95SBruce Richardson  *   A generic pointer parameter which will be passed to each invocation of the
455599a2dd95SBruce Richardson  *   callback function on this port and queue. Inter-thread synchronization
455699a2dd95SBruce Richardson  *   of any user data changes is the responsibility of the user.
455799a2dd95SBruce Richardson  *
455899a2dd95SBruce Richardson  * @return
455999a2dd95SBruce Richardson  *   NULL on error.
456099a2dd95SBruce Richardson  *   On success, a pointer value which can later be used to remove the callback.
456199a2dd95SBruce Richardson  */
456299a2dd95SBruce Richardson const struct rte_eth_rxtx_callback *
456399a2dd95SBruce Richardson rte_eth_add_first_rx_callback(uint16_t port_id, uint16_t queue_id,
456499a2dd95SBruce Richardson 		rte_rx_callback_fn fn, void *user_param);
456599a2dd95SBruce Richardson 
456699a2dd95SBruce Richardson /**
456709fd4227SAndrew Rybchenko  * Add a callback to be called on packet Tx on a given port and queue.
456899a2dd95SBruce Richardson  *
456999a2dd95SBruce Richardson  * This API configures a function to be called for each burst of
457099a2dd95SBruce Richardson  * packets sent on a given NIC port queue. The return value is a pointer
457199a2dd95SBruce Richardson  * that can be used to later remove the callback using
457299a2dd95SBruce Richardson  * rte_eth_remove_tx_callback().
457399a2dd95SBruce Richardson  *
457499a2dd95SBruce Richardson  * Multiple functions are called in the order that they are added.
457599a2dd95SBruce Richardson  *
457699a2dd95SBruce Richardson  * @param port_id
457799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
457899a2dd95SBruce Richardson  * @param queue_id
457999a2dd95SBruce Richardson  *   The queue on the Ethernet device on which the callback is to be added.
458099a2dd95SBruce Richardson  * @param fn
458199a2dd95SBruce Richardson  *   The callback function
458299a2dd95SBruce Richardson  * @param user_param
458399a2dd95SBruce Richardson  *   A generic pointer parameter which will be passed to each invocation of the
458499a2dd95SBruce Richardson  *   callback function on this port and queue. Inter-thread synchronization
458599a2dd95SBruce Richardson  *   of any user data changes is the responsibility of the user.
458699a2dd95SBruce Richardson  *
458799a2dd95SBruce Richardson  * @return
458899a2dd95SBruce Richardson  *   NULL on error.
458999a2dd95SBruce Richardson  *   On success, a pointer value which can later be used to remove the callback.
459099a2dd95SBruce Richardson  */
459199a2dd95SBruce Richardson const struct rte_eth_rxtx_callback *
459299a2dd95SBruce Richardson rte_eth_add_tx_callback(uint16_t port_id, uint16_t queue_id,
459399a2dd95SBruce Richardson 		rte_tx_callback_fn fn, void *user_param);
459499a2dd95SBruce Richardson 
459599a2dd95SBruce Richardson /**
459609fd4227SAndrew Rybchenko  * Remove an Rx packet callback from a given port and queue.
459799a2dd95SBruce Richardson  *
459899a2dd95SBruce Richardson  * This function is used to removed callbacks that were added to a NIC port
459999a2dd95SBruce Richardson  * queue using rte_eth_add_rx_callback().
460099a2dd95SBruce Richardson  *
460199a2dd95SBruce Richardson  * Note: the callback is removed from the callback list but it isn't freed
460299a2dd95SBruce Richardson  * since the it may still be in use. The memory for the callback can be
460399a2dd95SBruce Richardson  * subsequently freed back by the application by calling rte_free():
460499a2dd95SBruce Richardson  *
460599a2dd95SBruce Richardson  * - Immediately - if the port is stopped, or the user knows that no
460609fd4227SAndrew Rybchenko  *   callbacks are in flight e.g. if called from the thread doing Rx/Tx
460799a2dd95SBruce Richardson  *   on that queue.
460899a2dd95SBruce Richardson  *
460999a2dd95SBruce Richardson  * - After a short delay - where the delay is sufficient to allow any
461099a2dd95SBruce Richardson  *   in-flight callbacks to complete. Alternately, the RCU mechanism can be
461199a2dd95SBruce Richardson  *   used to detect when data plane threads have ceased referencing the
461299a2dd95SBruce Richardson  *   callback memory.
461399a2dd95SBruce Richardson  *
461499a2dd95SBruce Richardson  * @param port_id
461599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
461699a2dd95SBruce Richardson  * @param queue_id
461799a2dd95SBruce Richardson  *   The queue on the Ethernet device from which the callback is to be removed.
461899a2dd95SBruce Richardson  * @param user_cb
461999a2dd95SBruce Richardson  *   User supplied callback created via rte_eth_add_rx_callback().
462099a2dd95SBruce Richardson  *
462199a2dd95SBruce Richardson  * @return
462299a2dd95SBruce Richardson  *   - 0: Success. Callback was removed.
462399a2dd95SBruce Richardson  *   - -ENODEV:  If *port_id* is invalid.
462499a2dd95SBruce Richardson  *   - -ENOTSUP: Callback support is not available.
462599a2dd95SBruce Richardson  *   - -EINVAL:  The queue_id is out of range, or the callback
462699a2dd95SBruce Richardson  *               is NULL or not found for the port/queue.
462799a2dd95SBruce Richardson  */
462899a2dd95SBruce Richardson int rte_eth_remove_rx_callback(uint16_t port_id, uint16_t queue_id,
462999a2dd95SBruce Richardson 		const struct rte_eth_rxtx_callback *user_cb);
463099a2dd95SBruce Richardson 
463199a2dd95SBruce Richardson /**
463209fd4227SAndrew Rybchenko  * Remove a Tx packet callback from a given port and queue.
463399a2dd95SBruce Richardson  *
463499a2dd95SBruce Richardson  * This function is used to removed callbacks that were added to a NIC port
463599a2dd95SBruce Richardson  * queue using rte_eth_add_tx_callback().
463699a2dd95SBruce Richardson  *
463799a2dd95SBruce Richardson  * Note: the callback is removed from the callback list but it isn't freed
463899a2dd95SBruce Richardson  * since the it may still be in use. The memory for the callback can be
463999a2dd95SBruce Richardson  * subsequently freed back by the application by calling rte_free():
464099a2dd95SBruce Richardson  *
464199a2dd95SBruce Richardson  * - Immediately - if the port is stopped, or the user knows that no
464209fd4227SAndrew Rybchenko  *   callbacks are in flight e.g. if called from the thread doing Rx/Tx
464399a2dd95SBruce Richardson  *   on that queue.
464499a2dd95SBruce Richardson  *
464599a2dd95SBruce Richardson  * - After a short delay - where the delay is sufficient to allow any
464699a2dd95SBruce Richardson  *   in-flight callbacks to complete. Alternately, the RCU mechanism can be
464799a2dd95SBruce Richardson  *   used to detect when data plane threads have ceased referencing the
464899a2dd95SBruce Richardson  *   callback memory.
464999a2dd95SBruce Richardson  *
465099a2dd95SBruce Richardson  * @param port_id
465199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
465299a2dd95SBruce Richardson  * @param queue_id
465399a2dd95SBruce Richardson  *   The queue on the Ethernet device from which the callback is to be removed.
465499a2dd95SBruce Richardson  * @param user_cb
465599a2dd95SBruce Richardson  *   User supplied callback created via rte_eth_add_tx_callback().
465699a2dd95SBruce Richardson  *
465799a2dd95SBruce Richardson  * @return
465899a2dd95SBruce Richardson  *   - 0: Success. Callback was removed.
465999a2dd95SBruce Richardson  *   - -ENODEV:  If *port_id* is invalid.
466099a2dd95SBruce Richardson  *   - -ENOTSUP: Callback support is not available.
466199a2dd95SBruce Richardson  *   - -EINVAL:  The queue_id is out of range, or the callback
466299a2dd95SBruce Richardson  *               is NULL or not found for the port/queue.
466399a2dd95SBruce Richardson  */
466499a2dd95SBruce Richardson int rte_eth_remove_tx_callback(uint16_t port_id, uint16_t queue_id,
466599a2dd95SBruce Richardson 		const struct rte_eth_rxtx_callback *user_cb);
466699a2dd95SBruce Richardson 
466799a2dd95SBruce Richardson /**
466809fd4227SAndrew Rybchenko  * Retrieve information about given port's Rx queue.
466999a2dd95SBruce Richardson  *
467099a2dd95SBruce Richardson  * @param port_id
467199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
467299a2dd95SBruce Richardson  * @param queue_id
467309fd4227SAndrew Rybchenko  *   The Rx queue on the Ethernet device for which information
467499a2dd95SBruce Richardson  *   will be retrieved.
467599a2dd95SBruce Richardson  * @param qinfo
467699a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_eth_rxq_info_info* to be filled with
467799a2dd95SBruce Richardson  *   the information of the Ethernet device.
467899a2dd95SBruce Richardson  *
467999a2dd95SBruce Richardson  * @return
468099a2dd95SBruce Richardson  *   - 0: Success
468199a2dd95SBruce Richardson  *   - -ENODEV:  If *port_id* is invalid.
468299a2dd95SBruce Richardson  *   - -ENOTSUP: routine is not supported by the device PMD.
468399a2dd95SBruce Richardson  *   - -EINVAL:  The queue_id is out of range, or the queue
468499a2dd95SBruce Richardson  *               is hairpin queue.
468599a2dd95SBruce Richardson  */
468699a2dd95SBruce Richardson int rte_eth_rx_queue_info_get(uint16_t port_id, uint16_t queue_id,
468799a2dd95SBruce Richardson 	struct rte_eth_rxq_info *qinfo);
468899a2dd95SBruce Richardson 
468999a2dd95SBruce Richardson /**
469009fd4227SAndrew Rybchenko  * Retrieve information about given port's Tx queue.
469199a2dd95SBruce Richardson  *
469299a2dd95SBruce Richardson  * @param port_id
469399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
469499a2dd95SBruce Richardson  * @param queue_id
469509fd4227SAndrew Rybchenko  *   The Tx queue on the Ethernet device for which information
469699a2dd95SBruce Richardson  *   will be retrieved.
469799a2dd95SBruce Richardson  * @param qinfo
469899a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_eth_txq_info_info* to be filled with
469999a2dd95SBruce Richardson  *   the information of the Ethernet device.
470099a2dd95SBruce Richardson  *
470199a2dd95SBruce Richardson  * @return
470299a2dd95SBruce Richardson  *   - 0: Success
470399a2dd95SBruce Richardson  *   - -ENODEV:  If *port_id* is invalid.
470499a2dd95SBruce Richardson  *   - -ENOTSUP: routine is not supported by the device PMD.
470599a2dd95SBruce Richardson  *   - -EINVAL:  The queue_id is out of range, or the queue
470699a2dd95SBruce Richardson  *               is hairpin queue.
470799a2dd95SBruce Richardson  */
470899a2dd95SBruce Richardson int rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id,
470999a2dd95SBruce Richardson 	struct rte_eth_txq_info *qinfo);
471099a2dd95SBruce Richardson 
471199a2dd95SBruce Richardson /**
471299a2dd95SBruce Richardson  * Retrieve information about the Rx packet burst mode.
471399a2dd95SBruce Richardson  *
471499a2dd95SBruce Richardson  * @param port_id
471599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
471699a2dd95SBruce Richardson  * @param queue_id
471799a2dd95SBruce Richardson  *   The Rx queue on the Ethernet device for which information
471899a2dd95SBruce Richardson  *   will be retrieved.
471999a2dd95SBruce Richardson  * @param mode
472099a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_eth_burst_mode* to be filled
472199a2dd95SBruce Richardson  *   with the information of the packet burst mode.
472299a2dd95SBruce Richardson  *
472399a2dd95SBruce Richardson  * @return
472499a2dd95SBruce Richardson  *   - 0: Success
472599a2dd95SBruce Richardson  *   - -ENODEV:  If *port_id* is invalid.
472699a2dd95SBruce Richardson  *   - -ENOTSUP: routine is not supported by the device PMD.
472799a2dd95SBruce Richardson  *   - -EINVAL:  The queue_id is out of range.
472899a2dd95SBruce Richardson  */
472999a2dd95SBruce Richardson int rte_eth_rx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
473099a2dd95SBruce Richardson 	struct rte_eth_burst_mode *mode);
473199a2dd95SBruce Richardson 
473299a2dd95SBruce Richardson /**
473399a2dd95SBruce Richardson  * Retrieve information about the Tx packet burst mode.
473499a2dd95SBruce Richardson  *
473599a2dd95SBruce Richardson  * @param port_id
473699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
473799a2dd95SBruce Richardson  * @param queue_id
473899a2dd95SBruce Richardson  *   The Tx queue on the Ethernet device for which information
473999a2dd95SBruce Richardson  *   will be retrieved.
474099a2dd95SBruce Richardson  * @param mode
474199a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_eth_burst_mode* to be filled
474299a2dd95SBruce Richardson  *   with the information of the packet burst mode.
474399a2dd95SBruce Richardson  *
474499a2dd95SBruce Richardson  * @return
474599a2dd95SBruce Richardson  *   - 0: Success
474699a2dd95SBruce Richardson  *   - -ENODEV:  If *port_id* is invalid.
474799a2dd95SBruce Richardson  *   - -ENOTSUP: routine is not supported by the device PMD.
474899a2dd95SBruce Richardson  *   - -EINVAL:  The queue_id is out of range.
474999a2dd95SBruce Richardson  */
475099a2dd95SBruce Richardson int rte_eth_tx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
475199a2dd95SBruce Richardson 	struct rte_eth_burst_mode *mode);
475299a2dd95SBruce Richardson 
475399a2dd95SBruce Richardson /**
475499a2dd95SBruce Richardson  * @warning
475599a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
475699a2dd95SBruce Richardson  *
475799a2dd95SBruce Richardson  * Retrieve the monitor condition for a given receive queue.
475899a2dd95SBruce Richardson  *
475999a2dd95SBruce Richardson  * @param port_id
476099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
476199a2dd95SBruce Richardson  * @param queue_id
476299a2dd95SBruce Richardson  *   The Rx queue on the Ethernet device for which information
476399a2dd95SBruce Richardson  *   will be retrieved.
476499a2dd95SBruce Richardson  * @param pmc
476599a2dd95SBruce Richardson  *   The pointer to power-optimized monitoring condition structure.
476699a2dd95SBruce Richardson  *
476799a2dd95SBruce Richardson  * @return
476899a2dd95SBruce Richardson  *   - 0: Success.
476999a2dd95SBruce Richardson  *   -ENOTSUP: Operation not supported.
477099a2dd95SBruce Richardson  *   -EINVAL: Invalid parameters.
477199a2dd95SBruce Richardson  *   -ENODEV: Invalid port ID.
477299a2dd95SBruce Richardson  */
477399a2dd95SBruce Richardson __rte_experimental
477499a2dd95SBruce Richardson int rte_eth_get_monitor_addr(uint16_t port_id, uint16_t queue_id,
477599a2dd95SBruce Richardson 		struct rte_power_monitor_cond *pmc);
477699a2dd95SBruce Richardson 
477799a2dd95SBruce Richardson /**
477899a2dd95SBruce Richardson  * Retrieve device registers and register attributes (number of registers and
477999a2dd95SBruce Richardson  * register size)
478099a2dd95SBruce Richardson  *
478199a2dd95SBruce Richardson  * @param port_id
478299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
478399a2dd95SBruce Richardson  * @param info
478499a2dd95SBruce Richardson  *   Pointer to rte_dev_reg_info structure to fill in. If info->data is
478599a2dd95SBruce Richardson  *   NULL the function fills in the width and length fields. If non-NULL
478699a2dd95SBruce Richardson  *   the registers are put into the buffer pointed at by the data field.
478799a2dd95SBruce Richardson  * @return
478899a2dd95SBruce Richardson  *   - (0) if successful.
478999a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
479099a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
479199a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
479299a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
479399a2dd95SBruce Richardson  *   - others depends on the specific operations implementation.
479499a2dd95SBruce Richardson  */
479599a2dd95SBruce Richardson int rte_eth_dev_get_reg_info(uint16_t port_id, struct rte_dev_reg_info *info);
479699a2dd95SBruce Richardson 
479799a2dd95SBruce Richardson /**
479899a2dd95SBruce Richardson  * Retrieve size of device EEPROM
479999a2dd95SBruce Richardson  *
480099a2dd95SBruce Richardson  * @param port_id
480199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
480299a2dd95SBruce Richardson  * @return
480399a2dd95SBruce Richardson  *   - (>=0) EEPROM size if successful.
480499a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
480599a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
480699a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
480799a2dd95SBruce Richardson  *   - others depends on the specific operations implementation.
480899a2dd95SBruce Richardson  */
480999a2dd95SBruce Richardson int rte_eth_dev_get_eeprom_length(uint16_t port_id);
481099a2dd95SBruce Richardson 
481199a2dd95SBruce Richardson /**
481299a2dd95SBruce Richardson  * Retrieve EEPROM and EEPROM attribute
481399a2dd95SBruce Richardson  *
481499a2dd95SBruce Richardson  * @param port_id
481599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
481699a2dd95SBruce Richardson  * @param info
481799a2dd95SBruce Richardson  *   The template includes buffer for return EEPROM data and
481899a2dd95SBruce Richardson  *   EEPROM attributes to be filled.
481999a2dd95SBruce Richardson  * @return
482099a2dd95SBruce Richardson  *   - (0) if successful.
482199a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
482299a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
482399a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
482499a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
482599a2dd95SBruce Richardson  *   - others depends on the specific operations implementation.
482699a2dd95SBruce Richardson  */
482799a2dd95SBruce Richardson int rte_eth_dev_get_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
482899a2dd95SBruce Richardson 
482999a2dd95SBruce Richardson /**
483099a2dd95SBruce Richardson  * Program EEPROM with provided data
483199a2dd95SBruce Richardson  *
483299a2dd95SBruce Richardson  * @param port_id
483399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
483499a2dd95SBruce Richardson  * @param info
483599a2dd95SBruce Richardson  *   The template includes EEPROM data for programming and
483699a2dd95SBruce Richardson  *   EEPROM attributes to be filled
483799a2dd95SBruce Richardson  * @return
483899a2dd95SBruce Richardson  *   - (0) if successful.
483999a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
484099a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
484199a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
484299a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
484399a2dd95SBruce Richardson  *   - others depends on the specific operations implementation.
484499a2dd95SBruce Richardson  */
484599a2dd95SBruce Richardson int rte_eth_dev_set_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
484699a2dd95SBruce Richardson 
484799a2dd95SBruce Richardson /**
484899a2dd95SBruce Richardson  * @warning
484999a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
485099a2dd95SBruce Richardson  *
485199a2dd95SBruce Richardson  * Retrieve the type and size of plugin module EEPROM
485299a2dd95SBruce Richardson  *
485399a2dd95SBruce Richardson  * @param port_id
485499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
485599a2dd95SBruce Richardson  * @param modinfo
485699a2dd95SBruce Richardson  *   The type and size of plugin module EEPROM.
485799a2dd95SBruce Richardson  * @return
485899a2dd95SBruce Richardson  *   - (0) if successful.
485999a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
486099a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
486199a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
486299a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
486399a2dd95SBruce Richardson  *   - others depends on the specific operations implementation.
486499a2dd95SBruce Richardson  */
486599a2dd95SBruce Richardson __rte_experimental
486699a2dd95SBruce Richardson int
486799a2dd95SBruce Richardson rte_eth_dev_get_module_info(uint16_t port_id,
486899a2dd95SBruce Richardson 			    struct rte_eth_dev_module_info *modinfo);
486999a2dd95SBruce Richardson 
487099a2dd95SBruce Richardson /**
487199a2dd95SBruce Richardson  * @warning
487299a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
487399a2dd95SBruce Richardson  *
487499a2dd95SBruce Richardson  * Retrieve the data of plugin module EEPROM
487599a2dd95SBruce Richardson  *
487699a2dd95SBruce Richardson  * @param port_id
487799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
487899a2dd95SBruce Richardson  * @param info
487999a2dd95SBruce Richardson  *   The template includes the plugin module EEPROM attributes, and the
488099a2dd95SBruce Richardson  *   buffer for return plugin module EEPROM data.
488199a2dd95SBruce Richardson  * @return
488299a2dd95SBruce Richardson  *   - (0) if successful.
488399a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
488499a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
488599a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
488699a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
488799a2dd95SBruce Richardson  *   - others depends on the specific operations implementation.
488899a2dd95SBruce Richardson  */
488999a2dd95SBruce Richardson __rte_experimental
489099a2dd95SBruce Richardson int
489199a2dd95SBruce Richardson rte_eth_dev_get_module_eeprom(uint16_t port_id,
489299a2dd95SBruce Richardson 			      struct rte_dev_eeprom_info *info);
489399a2dd95SBruce Richardson 
489499a2dd95SBruce Richardson /**
489599a2dd95SBruce Richardson  * Set the list of multicast addresses to filter on an Ethernet device.
489699a2dd95SBruce Richardson  *
489799a2dd95SBruce Richardson  * @param port_id
489899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
489999a2dd95SBruce Richardson  * @param mc_addr_set
490099a2dd95SBruce Richardson  *   The array of multicast addresses to set. Equal to NULL when the function
490199a2dd95SBruce Richardson  *   is invoked to flush the set of filtered addresses.
490299a2dd95SBruce Richardson  * @param nb_mc_addr
490399a2dd95SBruce Richardson  *   The number of multicast addresses in the *mc_addr_set* array. Equal to 0
490499a2dd95SBruce Richardson  *   when the function is invoked to flush the set of filtered addresses.
490599a2dd95SBruce Richardson  * @return
490699a2dd95SBruce Richardson  *   - (0) if successful.
490799a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
490899a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
490999a2dd95SBruce Richardson  *   - (-ENOTSUP) if PMD of *port_id* doesn't support multicast filtering.
491099a2dd95SBruce Richardson  *   - (-ENOSPC) if *port_id* has not enough multicast filtering resources.
491153ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
491299a2dd95SBruce Richardson  */
491399a2dd95SBruce Richardson int rte_eth_dev_set_mc_addr_list(uint16_t port_id,
491499a2dd95SBruce Richardson 				 struct rte_ether_addr *mc_addr_set,
491599a2dd95SBruce Richardson 				 uint32_t nb_mc_addr);
491699a2dd95SBruce Richardson 
491799a2dd95SBruce Richardson /**
491899a2dd95SBruce Richardson  * Enable IEEE1588/802.1AS timestamping for an Ethernet device.
491999a2dd95SBruce Richardson  *
492099a2dd95SBruce Richardson  * @param port_id
492199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
492299a2dd95SBruce Richardson  *
492399a2dd95SBruce Richardson  * @return
492499a2dd95SBruce Richardson  *   - 0: Success.
492599a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
492699a2dd95SBruce Richardson  *   - -EIO: if device is removed.
492799a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
492899a2dd95SBruce Richardson  */
492999a2dd95SBruce Richardson int rte_eth_timesync_enable(uint16_t port_id);
493099a2dd95SBruce Richardson 
493199a2dd95SBruce Richardson /**
493299a2dd95SBruce Richardson  * Disable IEEE1588/802.1AS timestamping for an Ethernet device.
493399a2dd95SBruce Richardson  *
493499a2dd95SBruce Richardson  * @param port_id
493599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
493699a2dd95SBruce Richardson  *
493799a2dd95SBruce Richardson  * @return
493899a2dd95SBruce Richardson  *   - 0: Success.
493999a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
494099a2dd95SBruce Richardson  *   - -EIO: if device is removed.
494199a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
494299a2dd95SBruce Richardson  */
494399a2dd95SBruce Richardson int rte_eth_timesync_disable(uint16_t port_id);
494499a2dd95SBruce Richardson 
494599a2dd95SBruce Richardson /**
494609fd4227SAndrew Rybchenko  * Read an IEEE1588/802.1AS Rx timestamp from an Ethernet device.
494799a2dd95SBruce Richardson  *
494899a2dd95SBruce Richardson  * @param port_id
494999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
495099a2dd95SBruce Richardson  * @param timestamp
495199a2dd95SBruce Richardson  *   Pointer to the timestamp struct.
495299a2dd95SBruce Richardson  * @param flags
495309fd4227SAndrew Rybchenko  *   Device specific flags. Used to pass the Rx timesync register index to
495499a2dd95SBruce Richardson  *   i40e. Unused in igb/ixgbe, pass 0 instead.
495599a2dd95SBruce Richardson  *
495699a2dd95SBruce Richardson  * @return
495799a2dd95SBruce Richardson  *   - 0: Success.
495899a2dd95SBruce Richardson  *   - -EINVAL: No timestamp is available.
495999a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
496099a2dd95SBruce Richardson  *   - -EIO: if device is removed.
496199a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
496299a2dd95SBruce Richardson  */
496399a2dd95SBruce Richardson int rte_eth_timesync_read_rx_timestamp(uint16_t port_id,
496499a2dd95SBruce Richardson 		struct timespec *timestamp, uint32_t flags);
496599a2dd95SBruce Richardson 
496699a2dd95SBruce Richardson /**
496709fd4227SAndrew Rybchenko  * Read an IEEE1588/802.1AS Tx timestamp from an Ethernet device.
496899a2dd95SBruce Richardson  *
496999a2dd95SBruce Richardson  * @param port_id
497099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
497199a2dd95SBruce Richardson  * @param timestamp
497299a2dd95SBruce Richardson  *   Pointer to the timestamp struct.
497399a2dd95SBruce Richardson  *
497499a2dd95SBruce Richardson  * @return
497599a2dd95SBruce Richardson  *   - 0: Success.
497699a2dd95SBruce Richardson  *   - -EINVAL: No timestamp is available.
497799a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
497899a2dd95SBruce Richardson  *   - -EIO: if device is removed.
497999a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
498099a2dd95SBruce Richardson  */
498199a2dd95SBruce Richardson int rte_eth_timesync_read_tx_timestamp(uint16_t port_id,
498299a2dd95SBruce Richardson 		struct timespec *timestamp);
498399a2dd95SBruce Richardson 
498499a2dd95SBruce Richardson /**
498599a2dd95SBruce Richardson  * Adjust the timesync clock on an Ethernet device.
498699a2dd95SBruce Richardson  *
498799a2dd95SBruce Richardson  * This is usually used in conjunction with other Ethdev timesync functions to
498899a2dd95SBruce Richardson  * synchronize the device time using the IEEE1588/802.1AS protocol.
498999a2dd95SBruce Richardson  *
499099a2dd95SBruce Richardson  * @param port_id
499199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
499299a2dd95SBruce Richardson  * @param delta
499399a2dd95SBruce Richardson  *   The adjustment in nanoseconds.
499499a2dd95SBruce Richardson  *
499599a2dd95SBruce Richardson  * @return
499699a2dd95SBruce Richardson  *   - 0: Success.
499799a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
499899a2dd95SBruce Richardson  *   - -EIO: if device is removed.
499999a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
500099a2dd95SBruce Richardson  */
500199a2dd95SBruce Richardson int rte_eth_timesync_adjust_time(uint16_t port_id, int64_t delta);
500299a2dd95SBruce Richardson 
500399a2dd95SBruce Richardson /**
500499a2dd95SBruce Richardson  * Read the time from the timesync clock on an Ethernet device.
500599a2dd95SBruce Richardson  *
500699a2dd95SBruce Richardson  * This is usually used in conjunction with other Ethdev timesync functions to
500799a2dd95SBruce Richardson  * synchronize the device time using the IEEE1588/802.1AS protocol.
500899a2dd95SBruce Richardson  *
500999a2dd95SBruce Richardson  * @param port_id
501099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
501199a2dd95SBruce Richardson  * @param time
501299a2dd95SBruce Richardson  *   Pointer to the timespec struct that holds the time.
501399a2dd95SBruce Richardson  *
501499a2dd95SBruce Richardson  * @return
501599a2dd95SBruce Richardson  *   - 0: Success.
501653ef1b34SMin Hu (Connor)  *   - -EINVAL: Bad parameter.
501799a2dd95SBruce Richardson  */
501899a2dd95SBruce Richardson int rte_eth_timesync_read_time(uint16_t port_id, struct timespec *time);
501999a2dd95SBruce Richardson 
502099a2dd95SBruce Richardson /**
502199a2dd95SBruce Richardson  * Set the time of the timesync clock on an Ethernet device.
502299a2dd95SBruce Richardson  *
502399a2dd95SBruce Richardson  * This is usually used in conjunction with other Ethdev timesync functions to
502499a2dd95SBruce Richardson  * synchronize the device time using the IEEE1588/802.1AS protocol.
502599a2dd95SBruce Richardson  *
502699a2dd95SBruce Richardson  * @param port_id
502799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
502899a2dd95SBruce Richardson  * @param time
502999a2dd95SBruce Richardson  *   Pointer to the timespec struct that holds the time.
503099a2dd95SBruce Richardson  *
503199a2dd95SBruce Richardson  * @return
503299a2dd95SBruce Richardson  *   - 0: Success.
503399a2dd95SBruce Richardson  *   - -EINVAL: No timestamp is available.
503499a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
503599a2dd95SBruce Richardson  *   - -EIO: if device is removed.
503699a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
503799a2dd95SBruce Richardson  */
503899a2dd95SBruce Richardson int rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *time);
503999a2dd95SBruce Richardson 
504099a2dd95SBruce Richardson /**
504199a2dd95SBruce Richardson  * @warning
504299a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
504399a2dd95SBruce Richardson  *
504499a2dd95SBruce Richardson  * Read the current clock counter of an Ethernet device
504599a2dd95SBruce Richardson  *
504699a2dd95SBruce Richardson  * This returns the current raw clock value of an Ethernet device. It is
504799a2dd95SBruce Richardson  * a raw amount of ticks, with no given time reference.
504899a2dd95SBruce Richardson  * The value returned here is from the same clock than the one
504999a2dd95SBruce Richardson  * filling timestamp field of Rx packets when using hardware timestamp
505099a2dd95SBruce Richardson  * offload. Therefore it can be used to compute a precise conversion of
505199a2dd95SBruce Richardson  * the device clock to the real time.
505299a2dd95SBruce Richardson  *
505399a2dd95SBruce Richardson  * E.g, a simple heuristic to derivate the frequency would be:
505499a2dd95SBruce Richardson  * uint64_t start, end;
505599a2dd95SBruce Richardson  * rte_eth_read_clock(port, start);
505699a2dd95SBruce Richardson  * rte_delay_ms(100);
505799a2dd95SBruce Richardson  * rte_eth_read_clock(port, end);
505899a2dd95SBruce Richardson  * double freq = (end - start) * 10;
505999a2dd95SBruce Richardson  *
506099a2dd95SBruce Richardson  * Compute a common reference with:
506199a2dd95SBruce Richardson  * uint64_t base_time_sec = current_time();
506299a2dd95SBruce Richardson  * uint64_t base_clock;
506399a2dd95SBruce Richardson  * rte_eth_read_clock(port, base_clock);
506499a2dd95SBruce Richardson  *
506599a2dd95SBruce Richardson  * Then, convert the raw mbuf timestamp with:
506699a2dd95SBruce Richardson  * base_time_sec + (double)(*timestamp_dynfield(mbuf) - base_clock) / freq;
506799a2dd95SBruce Richardson  *
506899a2dd95SBruce Richardson  * This simple example will not provide a very good accuracy. One must
506999a2dd95SBruce Richardson  * at least measure multiple times the frequency and do a regression.
507099a2dd95SBruce Richardson  * To avoid deviation from the system time, the common reference can
507199a2dd95SBruce Richardson  * be repeated from time to time. The integer division can also be
507299a2dd95SBruce Richardson  * converted by a multiplication and a shift for better performance.
507399a2dd95SBruce Richardson  *
507499a2dd95SBruce Richardson  * @param port_id
507599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
507699a2dd95SBruce Richardson  * @param clock
507799a2dd95SBruce Richardson  *   Pointer to the uint64_t that holds the raw clock value.
507899a2dd95SBruce Richardson  *
507999a2dd95SBruce Richardson  * @return
508099a2dd95SBruce Richardson  *   - 0: Success.
508199a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
508299a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
508353ef1b34SMin Hu (Connor)  *   - -EINVAL: if bad parameter.
508499a2dd95SBruce Richardson  */
508599a2dd95SBruce Richardson __rte_experimental
508699a2dd95SBruce Richardson int
508799a2dd95SBruce Richardson rte_eth_read_clock(uint16_t port_id, uint64_t *clock);
508899a2dd95SBruce Richardson 
508999a2dd95SBruce Richardson /**
50905906be5aSAndrew Rybchenko * Get the port ID from device name. The device name should be specified
509199a2dd95SBruce Richardson * as below:
509299a2dd95SBruce Richardson * - PCIe address (Domain:Bus:Device.Function), for example- 0000:2:00.0
509399a2dd95SBruce Richardson * - SoC device name, for example- fsl-gmac0
509499a2dd95SBruce Richardson * - vdev dpdk name, for example- net_[pcap0|null0|tap0]
509599a2dd95SBruce Richardson *
509699a2dd95SBruce Richardson * @param name
509799a2dd95SBruce Richardson *  pci address or name of the device
509899a2dd95SBruce Richardson * @param port_id
509999a2dd95SBruce Richardson *   pointer to port identifier of the device
510099a2dd95SBruce Richardson * @return
510199a2dd95SBruce Richardson *   - (0) if successful and port_id is filled.
510299a2dd95SBruce Richardson *   - (-ENODEV or -EINVAL) on failure.
510399a2dd95SBruce Richardson */
510499a2dd95SBruce Richardson int
510599a2dd95SBruce Richardson rte_eth_dev_get_port_by_name(const char *name, uint16_t *port_id);
510699a2dd95SBruce Richardson 
510799a2dd95SBruce Richardson /**
51085906be5aSAndrew Rybchenko * Get the device name from port ID. The device name is specified as below:
510999a2dd95SBruce Richardson * - PCIe address (Domain:Bus:Device.Function), for example- 0000:02:00.0
511099a2dd95SBruce Richardson * - SoC device name, for example- fsl-gmac0
511199a2dd95SBruce Richardson * - vdev dpdk name, for example- net_[pcap0|null0|tun0|tap0]
511299a2dd95SBruce Richardson *
511399a2dd95SBruce Richardson * @param port_id
511499a2dd95SBruce Richardson *   Port identifier of the device.
511599a2dd95SBruce Richardson * @param name
511699a2dd95SBruce Richardson *   Buffer of size RTE_ETH_NAME_MAX_LEN to store the name.
511799a2dd95SBruce Richardson * @return
511899a2dd95SBruce Richardson *   - (0) if successful.
511999a2dd95SBruce Richardson *   - (-ENODEV) if *port_id* is invalid.
512099a2dd95SBruce Richardson *   - (-EINVAL) on failure.
512199a2dd95SBruce Richardson */
512299a2dd95SBruce Richardson int
512399a2dd95SBruce Richardson rte_eth_dev_get_name_by_port(uint16_t port_id, char *name);
512499a2dd95SBruce Richardson 
512599a2dd95SBruce Richardson /**
512699a2dd95SBruce Richardson  * Check that numbers of Rx and Tx descriptors satisfy descriptors limits from
51270d9f56a8SAndrew Rybchenko  * the Ethernet device information, otherwise adjust them to boundaries.
512899a2dd95SBruce Richardson  *
512999a2dd95SBruce Richardson  * @param port_id
513099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
513199a2dd95SBruce Richardson  * @param nb_rx_desc
513299a2dd95SBruce Richardson  *   A pointer to a uint16_t where the number of receive
513399a2dd95SBruce Richardson  *   descriptors stored.
513499a2dd95SBruce Richardson  * @param nb_tx_desc
513599a2dd95SBruce Richardson  *   A pointer to a uint16_t where the number of transmit
513699a2dd95SBruce Richardson  *   descriptors stored.
513799a2dd95SBruce Richardson  * @return
513899a2dd95SBruce Richardson  *   - (0) if successful.
513999a2dd95SBruce Richardson  *   - (-ENOTSUP, -ENODEV or -EINVAL) on failure.
514099a2dd95SBruce Richardson  */
514199a2dd95SBruce Richardson int rte_eth_dev_adjust_nb_rx_tx_desc(uint16_t port_id,
514299a2dd95SBruce Richardson 				     uint16_t *nb_rx_desc,
514399a2dd95SBruce Richardson 				     uint16_t *nb_tx_desc);
514499a2dd95SBruce Richardson 
514599a2dd95SBruce Richardson /**
514699a2dd95SBruce Richardson  * Test if a port supports specific mempool ops.
514799a2dd95SBruce Richardson  *
514899a2dd95SBruce Richardson  * @param port_id
514999a2dd95SBruce Richardson  *   Port identifier of the Ethernet device.
515099a2dd95SBruce Richardson  * @param [in] pool
515199a2dd95SBruce Richardson  *   The name of the pool operations to test.
515299a2dd95SBruce Richardson  * @return
515399a2dd95SBruce Richardson  *   - 0: best mempool ops choice for this port.
515499a2dd95SBruce Richardson  *   - 1: mempool ops are supported for this port.
515599a2dd95SBruce Richardson  *   - -ENOTSUP: mempool ops not supported for this port.
515699a2dd95SBruce Richardson  *   - -ENODEV: Invalid port Identifier.
515799a2dd95SBruce Richardson  *   - -EINVAL: Pool param is null.
515899a2dd95SBruce Richardson  */
515999a2dd95SBruce Richardson int
516099a2dd95SBruce Richardson rte_eth_dev_pool_ops_supported(uint16_t port_id, const char *pool);
516199a2dd95SBruce Richardson 
516299a2dd95SBruce Richardson /**
516399a2dd95SBruce Richardson  * Get the security context for the Ethernet device.
516499a2dd95SBruce Richardson  *
516599a2dd95SBruce Richardson  * @param port_id
516699a2dd95SBruce Richardson  *   Port identifier of the Ethernet device
516799a2dd95SBruce Richardson  * @return
516899a2dd95SBruce Richardson  *   - NULL on error.
516999a2dd95SBruce Richardson  *   - pointer to security context on success.
517099a2dd95SBruce Richardson  */
517199a2dd95SBruce Richardson void *
517299a2dd95SBruce Richardson rte_eth_dev_get_sec_ctx(uint16_t port_id);
517399a2dd95SBruce Richardson 
517499a2dd95SBruce Richardson /**
517599a2dd95SBruce Richardson  * @warning
517699a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
517799a2dd95SBruce Richardson  *
517899a2dd95SBruce Richardson  * Query the device hairpin capabilities.
517999a2dd95SBruce Richardson  *
518099a2dd95SBruce Richardson  * @param port_id
518199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
518299a2dd95SBruce Richardson  * @param cap
518399a2dd95SBruce Richardson  *   Pointer to a structure that will hold the hairpin capabilities.
518499a2dd95SBruce Richardson  * @return
518599a2dd95SBruce Richardson  *   - (0) if successful.
518699a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
518753ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
518899a2dd95SBruce Richardson  */
518999a2dd95SBruce Richardson __rte_experimental
519099a2dd95SBruce Richardson int rte_eth_dev_hairpin_capability_get(uint16_t port_id,
519199a2dd95SBruce Richardson 				       struct rte_eth_hairpin_cap *cap);
519299a2dd95SBruce Richardson 
519399a2dd95SBruce Richardson /**
519499a2dd95SBruce Richardson  * @warning
519599a2dd95SBruce Richardson  * @b EXPERIMENTAL: this structure may change without prior notice.
519699a2dd95SBruce Richardson  *
51970d9f56a8SAndrew Rybchenko  * Ethernet device representor ID range entry
519899a2dd95SBruce Richardson  */
519999a2dd95SBruce Richardson struct rte_eth_representor_range {
520099a2dd95SBruce Richardson 	enum rte_eth_representor_type type; /**< Representor type */
520199a2dd95SBruce Richardson 	int controller; /**< Controller index */
520299a2dd95SBruce Richardson 	int pf; /**< Physical function index */
520399a2dd95SBruce Richardson 	__extension__
520499a2dd95SBruce Richardson 	union {
520599a2dd95SBruce Richardson 		int vf; /**< VF start index */
520699a2dd95SBruce Richardson 		int sf; /**< SF start index */
520799a2dd95SBruce Richardson 	};
520899a2dd95SBruce Richardson 	uint32_t id_base; /**< Representor ID start index */
520999a2dd95SBruce Richardson 	uint32_t id_end;  /**< Representor ID end index */
521099a2dd95SBruce Richardson 	char name[RTE_DEV_NAME_MAX_LEN]; /**< Representor name */
521199a2dd95SBruce Richardson };
521299a2dd95SBruce Richardson 
521399a2dd95SBruce Richardson /**
521499a2dd95SBruce Richardson  * @warning
521599a2dd95SBruce Richardson  * @b EXPERIMENTAL: this structure may change without prior notice.
521699a2dd95SBruce Richardson  *
521799a2dd95SBruce Richardson  * Ethernet device representor information
521899a2dd95SBruce Richardson  */
521999a2dd95SBruce Richardson struct rte_eth_representor_info {
522099a2dd95SBruce Richardson 	uint16_t controller; /**< Controller ID of caller device. */
522199a2dd95SBruce Richardson 	uint16_t pf; /**< Physical function ID of caller device. */
522210eaf41dSViacheslav Galaktionov 	uint32_t nb_ranges_alloc; /**< Size of the ranges array. */
522310eaf41dSViacheslav Galaktionov 	uint32_t nb_ranges; /**< Number of initialized ranges. */
522499a2dd95SBruce Richardson 	struct rte_eth_representor_range ranges[];/**< Representor ID range. */
522599a2dd95SBruce Richardson };
522699a2dd95SBruce Richardson 
522799a2dd95SBruce Richardson /**
522899a2dd95SBruce Richardson  * Retrieve the representor info of the device.
522999a2dd95SBruce Richardson  *
523099a2dd95SBruce Richardson  * Get device representor info to be able to calculate a unique
523199a2dd95SBruce Richardson  * representor ID. @see rte_eth_representor_id_get helper.
523299a2dd95SBruce Richardson  *
523399a2dd95SBruce Richardson  * @param port_id
523499a2dd95SBruce Richardson  *   The port identifier of the device.
523599a2dd95SBruce Richardson  * @param info
523699a2dd95SBruce Richardson  *   A pointer to a representor info structure.
523799a2dd95SBruce Richardson  *   NULL to return number of range entries and allocate memory
523899a2dd95SBruce Richardson  *   for next call to store detail.
523910eaf41dSViacheslav Galaktionov  *   The number of ranges that were written into this structure
524010eaf41dSViacheslav Galaktionov  *   will be placed into its nb_ranges field. This number cannot be
524110eaf41dSViacheslav Galaktionov  *   larger than the nb_ranges_alloc that by the user before calling
524210eaf41dSViacheslav Galaktionov  *   this function. It can be smaller than the value returned by the
524310eaf41dSViacheslav Galaktionov  *   function, however.
524499a2dd95SBruce Richardson  * @return
524599a2dd95SBruce Richardson  *   - (-ENOTSUP) if operation is not supported.
524699a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
524799a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
524810eaf41dSViacheslav Galaktionov  *   - (>=0) number of available representor range entries.
524999a2dd95SBruce Richardson  */
525099a2dd95SBruce Richardson __rte_experimental
525199a2dd95SBruce Richardson int rte_eth_representor_info_get(uint16_t port_id,
525299a2dd95SBruce Richardson 				 struct rte_eth_representor_info *info);
525399a2dd95SBruce Richardson 
5254f6d8a6d3SIvan Malov /** The NIC is able to deliver flag (if set) with packets to the PMD. */
5255e1823e08SThomas Monjalon #define RTE_ETH_RX_METADATA_USER_FLAG RTE_BIT64(0)
5256f6d8a6d3SIvan Malov 
5257f6d8a6d3SIvan Malov /** The NIC is able to deliver mark ID with packets to the PMD. */
5258e1823e08SThomas Monjalon #define RTE_ETH_RX_METADATA_USER_MARK RTE_BIT64(1)
5259f6d8a6d3SIvan Malov 
5260f6d8a6d3SIvan Malov /** The NIC is able to deliver tunnel ID with packets to the PMD. */
5261e1823e08SThomas Monjalon #define RTE_ETH_RX_METADATA_TUNNEL_ID RTE_BIT64(2)
5262f6d8a6d3SIvan Malov 
5263f6d8a6d3SIvan Malov /**
5264f6d8a6d3SIvan Malov  * @warning
5265f6d8a6d3SIvan Malov  * @b EXPERIMENTAL: this API may change without prior notice
5266f6d8a6d3SIvan Malov  *
5267f6d8a6d3SIvan Malov  * Negotiate the NIC's ability to deliver specific kinds of metadata to the PMD.
5268f6d8a6d3SIvan Malov  *
5269f6d8a6d3SIvan Malov  * Invoke this API before the first rte_eth_dev_configure() invocation
5270f6d8a6d3SIvan Malov  * to let the PMD make preparations that are inconvenient to do later.
5271f6d8a6d3SIvan Malov  *
5272f6d8a6d3SIvan Malov  * The negotiation process is as follows:
5273f6d8a6d3SIvan Malov  *
5274f6d8a6d3SIvan Malov  * - the application requests features intending to use at least some of them;
5275f6d8a6d3SIvan Malov  * - the PMD responds with the guaranteed subset of the requested feature set;
5276f6d8a6d3SIvan Malov  * - the application can retry negotiation with another set of features;
5277f6d8a6d3SIvan Malov  * - the application can pass zero to clear the negotiation result;
5278f6d8a6d3SIvan Malov  * - the last negotiated result takes effect upon
5279f6d8a6d3SIvan Malov  *   the ethdev configure and start.
5280f6d8a6d3SIvan Malov  *
5281f6d8a6d3SIvan Malov  * @note
5282f6d8a6d3SIvan Malov  *   The PMD is supposed to first consider enabling the requested feature set
5283f6d8a6d3SIvan Malov  *   in its entirety. Only if it fails to do so, does it have the right to
5284f6d8a6d3SIvan Malov  *   respond with a smaller set of the originally requested features.
5285f6d8a6d3SIvan Malov  *
5286f6d8a6d3SIvan Malov  * @note
5287f6d8a6d3SIvan Malov  *   Return code (-ENOTSUP) does not necessarily mean that the requested
5288f6d8a6d3SIvan Malov  *   features are unsupported. In this case, the application should just
5289f6d8a6d3SIvan Malov  *   assume that these features can be used without prior negotiations.
5290f6d8a6d3SIvan Malov  *
5291f6d8a6d3SIvan Malov  * @param port_id
5292f6d8a6d3SIvan Malov  *   Port (ethdev) identifier
5293f6d8a6d3SIvan Malov  *
5294f6d8a6d3SIvan Malov  * @param[inout] features
5295f6d8a6d3SIvan Malov  *   Feature selection buffer
5296f6d8a6d3SIvan Malov  *
5297f6d8a6d3SIvan Malov  * @return
5298f6d8a6d3SIvan Malov  *   - (-EBUSY) if the port can't handle this in its current state;
5299f6d8a6d3SIvan Malov  *   - (-ENOTSUP) if the method itself is not supported by the PMD;
5300f6d8a6d3SIvan Malov  *   - (-ENODEV) if *port_id* is invalid;
5301f6d8a6d3SIvan Malov  *   - (-EINVAL) if *features* is NULL;
5302f6d8a6d3SIvan Malov  *   - (-EIO) if the device is removed;
5303f6d8a6d3SIvan Malov  *   - (0) on success
5304f6d8a6d3SIvan Malov  */
5305f6d8a6d3SIvan Malov __rte_experimental
5306f6d8a6d3SIvan Malov int rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features);
5307f6d8a6d3SIvan Malov 
5308a75ab6e5SAkhil Goyal /** Flag to offload IP reassembly for IPv4 packets. */
5309a75ab6e5SAkhil Goyal #define RTE_ETH_DEV_REASSEMBLY_F_IPV4 (RTE_BIT32(0))
5310a75ab6e5SAkhil Goyal /** Flag to offload IP reassembly for IPv6 packets. */
5311a75ab6e5SAkhil Goyal #define RTE_ETH_DEV_REASSEMBLY_F_IPV6 (RTE_BIT32(1))
5312a75ab6e5SAkhil Goyal 
5313a75ab6e5SAkhil Goyal /**
5314a75ab6e5SAkhil Goyal  * A structure used to get/set IP reassembly configuration. It is also used
5315a75ab6e5SAkhil Goyal  * to get the maximum capability values that a PMD can support.
5316a75ab6e5SAkhil Goyal  *
5317a75ab6e5SAkhil Goyal  * If rte_eth_ip_reassembly_capability_get() returns 0, IP reassembly can be
5318a75ab6e5SAkhil Goyal  * enabled using rte_eth_ip_reassembly_conf_set() and params values lower than
5319a75ab6e5SAkhil Goyal  * capability params can be set in the PMD.
5320a75ab6e5SAkhil Goyal  */
5321a75ab6e5SAkhil Goyal struct rte_eth_ip_reassembly_params {
5322a75ab6e5SAkhil Goyal 	/** Maximum time in ms which PMD can wait for other fragments. */
5323a75ab6e5SAkhil Goyal 	uint32_t timeout_ms;
5324a75ab6e5SAkhil Goyal 	/** Maximum number of fragments that can be reassembled. */
5325a75ab6e5SAkhil Goyal 	uint16_t max_frags;
5326a75ab6e5SAkhil Goyal 	/**
5327a75ab6e5SAkhil Goyal 	 * Flags to enable reassembly of packet types -
5328a75ab6e5SAkhil Goyal 	 * RTE_ETH_DEV_REASSEMBLY_F_xxx.
5329a75ab6e5SAkhil Goyal 	 */
5330a75ab6e5SAkhil Goyal 	uint16_t flags;
5331a75ab6e5SAkhil Goyal };
5332a75ab6e5SAkhil Goyal 
5333a75ab6e5SAkhil Goyal /**
5334a75ab6e5SAkhil Goyal  * @warning
5335a75ab6e5SAkhil Goyal  * @b EXPERIMENTAL: this API may change without prior notice
5336a75ab6e5SAkhil Goyal  *
5337a75ab6e5SAkhil Goyal  * Get IP reassembly capabilities supported by the PMD. This is the first API
5338a75ab6e5SAkhil Goyal  * to be called for enabling the IP reassembly offload feature. PMD will return
5339a75ab6e5SAkhil Goyal  * the maximum values of parameters that PMD can support and user can call
5340a75ab6e5SAkhil Goyal  * rte_eth_ip_reassembly_conf_set() with param values lower than capability.
5341a75ab6e5SAkhil Goyal  *
5342a75ab6e5SAkhil Goyal  * @param port_id
5343a75ab6e5SAkhil Goyal  *   The port identifier of the device.
5344a75ab6e5SAkhil Goyal  * @param capa
5345a75ab6e5SAkhil Goyal  *   A pointer to rte_eth_ip_reassembly_params structure.
5346a75ab6e5SAkhil Goyal  * @return
5347a75ab6e5SAkhil Goyal  *   - (-ENOTSUP) if offload configuration is not supported by device.
5348a75ab6e5SAkhil Goyal  *   - (-ENODEV) if *port_id* invalid.
5349a75ab6e5SAkhil Goyal  *   - (-EIO) if device is removed.
5350a75ab6e5SAkhil Goyal  *   - (-EINVAL) if device is not configured or *capa* passed is NULL.
5351a75ab6e5SAkhil Goyal  *   - (0) on success.
5352a75ab6e5SAkhil Goyal  */
5353a75ab6e5SAkhil Goyal __rte_experimental
5354a75ab6e5SAkhil Goyal int rte_eth_ip_reassembly_capability_get(uint16_t port_id,
5355a75ab6e5SAkhil Goyal 		struct rte_eth_ip_reassembly_params *capa);
5356a75ab6e5SAkhil Goyal 
5357a75ab6e5SAkhil Goyal /**
5358a75ab6e5SAkhil Goyal  * @warning
5359a75ab6e5SAkhil Goyal  * @b EXPERIMENTAL: this API may change without prior notice
5360a75ab6e5SAkhil Goyal  *
5361a75ab6e5SAkhil Goyal  * Get IP reassembly configuration parameters currently set in PMD.
5362a75ab6e5SAkhil Goyal  * The API will return error if the configuration is not already
5363a75ab6e5SAkhil Goyal  * set using rte_eth_ip_reassembly_conf_set() before calling this API or if
5364a75ab6e5SAkhil Goyal  * the device is not configured.
5365a75ab6e5SAkhil Goyal  *
5366a75ab6e5SAkhil Goyal  * @param port_id
5367a75ab6e5SAkhil Goyal  *   The port identifier of the device.
5368a75ab6e5SAkhil Goyal  * @param conf
5369a75ab6e5SAkhil Goyal  *   A pointer to rte_eth_ip_reassembly_params structure.
5370a75ab6e5SAkhil Goyal  * @return
5371a75ab6e5SAkhil Goyal  *   - (-ENOTSUP) if offload configuration is not supported by device.
5372a75ab6e5SAkhil Goyal  *   - (-ENODEV) if *port_id* invalid.
5373a75ab6e5SAkhil Goyal  *   - (-EIO) if device is removed.
5374a75ab6e5SAkhil Goyal  *   - (-EINVAL) if device is not configured or if *conf* passed is NULL or if
5375a75ab6e5SAkhil Goyal  *              configuration is not set using rte_eth_ip_reassembly_conf_set().
5376a75ab6e5SAkhil Goyal  *   - (0) on success.
5377a75ab6e5SAkhil Goyal  */
5378a75ab6e5SAkhil Goyal __rte_experimental
5379a75ab6e5SAkhil Goyal int rte_eth_ip_reassembly_conf_get(uint16_t port_id,
5380a75ab6e5SAkhil Goyal 		struct rte_eth_ip_reassembly_params *conf);
5381a75ab6e5SAkhil Goyal 
5382a75ab6e5SAkhil Goyal /**
5383a75ab6e5SAkhil Goyal  * @warning
5384a75ab6e5SAkhil Goyal  * @b EXPERIMENTAL: this API may change without prior notice
5385a75ab6e5SAkhil Goyal  *
5386a75ab6e5SAkhil Goyal  * Set IP reassembly configuration parameters if the PMD supports IP reassembly
5387a75ab6e5SAkhil Goyal  * offload. User should first call rte_eth_ip_reassembly_capability_get() to
5388a75ab6e5SAkhil Goyal  * check the maximum values supported by the PMD before setting the
5389a75ab6e5SAkhil Goyal  * configuration. The use of this API is mandatory to enable this feature and
5390a75ab6e5SAkhil Goyal  * should be called before rte_eth_dev_start().
5391a75ab6e5SAkhil Goyal  *
53923c059b2cSAkhil Goyal  * In datapath, PMD cannot guarantee that IP reassembly is always successful.
53933c059b2cSAkhil Goyal  * Hence, PMD shall register mbuf dynamic field and dynamic flag using
53943c059b2cSAkhil Goyal  * rte_eth_ip_reassembly_dynfield_register() to denote incomplete IP reassembly.
53953c059b2cSAkhil Goyal  * If dynfield is not successfully registered, error will be returned and
53963c059b2cSAkhil Goyal  * IP reassembly offload cannot be used.
53973c059b2cSAkhil Goyal  *
5398a75ab6e5SAkhil Goyal  * @param port_id
5399a75ab6e5SAkhil Goyal  *   The port identifier of the device.
5400a75ab6e5SAkhil Goyal  * @param conf
5401a75ab6e5SAkhil Goyal  *   A pointer to rte_eth_ip_reassembly_params structure.
5402a75ab6e5SAkhil Goyal  * @return
5403a75ab6e5SAkhil Goyal  *   - (-ENOTSUP) if offload configuration is not supported by device.
5404a75ab6e5SAkhil Goyal  *   - (-ENODEV) if *port_id* invalid.
5405a75ab6e5SAkhil Goyal  *   - (-EIO) if device is removed.
5406a75ab6e5SAkhil Goyal  *   - (-EINVAL) if device is not configured or if device is already started or
54073c059b2cSAkhil Goyal  *               if *conf* passed is NULL or if mbuf dynfield is not registered
54083c059b2cSAkhil Goyal  *               successfully by the PMD.
5409a75ab6e5SAkhil Goyal  *   - (0) on success.
5410a75ab6e5SAkhil Goyal  */
5411a75ab6e5SAkhil Goyal __rte_experimental
5412a75ab6e5SAkhil Goyal int rte_eth_ip_reassembly_conf_set(uint16_t port_id,
5413a75ab6e5SAkhil Goyal 		const struct rte_eth_ip_reassembly_params *conf);
5414a75ab6e5SAkhil Goyal 
54153c059b2cSAkhil Goyal /**
54163c059b2cSAkhil Goyal  * In case of IP reassembly offload failure, packet will be updated with
54173c059b2cSAkhil Goyal  * dynamic flag - RTE_MBUF_DYNFLAG_IP_REASSEMBLY_INCOMPLETE_NAME and packets
54183c059b2cSAkhil Goyal  * will be returned without alteration.
54193c059b2cSAkhil Goyal  * The application can retrieve the attached fragments using mbuf dynamic field
54203c059b2cSAkhil Goyal  * RTE_MBUF_DYNFIELD_IP_REASSEMBLY_NAME.
54213c059b2cSAkhil Goyal  */
54223c059b2cSAkhil Goyal typedef struct {
54233c059b2cSAkhil Goyal 	/**
54243c059b2cSAkhil Goyal 	 * Next fragment packet. Application should fetch dynamic field of
54253c059b2cSAkhil Goyal 	 * each fragment until a NULL is received and nb_frags is 0.
54263c059b2cSAkhil Goyal 	 */
54273c059b2cSAkhil Goyal 	struct rte_mbuf *next_frag;
54283c059b2cSAkhil Goyal 	/** Time spent(in ms) by HW in waiting for further fragments. */
54293c059b2cSAkhil Goyal 	uint16_t time_spent;
54303c059b2cSAkhil Goyal 	/** Number of more fragments attached in mbuf dynamic fields. */
54313c059b2cSAkhil Goyal 	uint16_t nb_frags;
54323c059b2cSAkhil Goyal } rte_eth_ip_reassembly_dynfield_t;
54333c059b2cSAkhil Goyal 
5434edcf22c6SMin Hu (Connor) /**
5435edcf22c6SMin Hu (Connor)  * @warning
5436edcf22c6SMin Hu (Connor)  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
5437edcf22c6SMin Hu (Connor)  *
5438edcf22c6SMin Hu (Connor)  * Dump private info from device to a file. Provided data and the order depends
5439edcf22c6SMin Hu (Connor)  * on the PMD.
5440edcf22c6SMin Hu (Connor)  *
5441edcf22c6SMin Hu (Connor)  * @param port_id
5442edcf22c6SMin Hu (Connor)  *   The port identifier of the Ethernet device.
5443edcf22c6SMin Hu (Connor)  * @param file
5444edcf22c6SMin Hu (Connor)  *   A pointer to a file for output.
5445edcf22c6SMin Hu (Connor)  * @return
5446edcf22c6SMin Hu (Connor)  *   - (0) on success.
5447edcf22c6SMin Hu (Connor)  *   - (-ENODEV) if *port_id* is invalid.
5448edcf22c6SMin Hu (Connor)  *   - (-EINVAL) if null file.
5449edcf22c6SMin Hu (Connor)  *   - (-ENOTSUP) if the device does not support this function.
5450edcf22c6SMin Hu (Connor)  *   - (-EIO) if device is removed.
5451edcf22c6SMin Hu (Connor)  */
5452edcf22c6SMin Hu (Connor) __rte_experimental
5453edcf22c6SMin Hu (Connor) int rte_eth_dev_priv_dump(uint16_t port_id, FILE *file);
5454a75ab6e5SAkhil Goyal 
545599a2dd95SBruce Richardson #include <rte_ethdev_core.h>
545699a2dd95SBruce Richardson 
545799a2dd95SBruce Richardson /**
54587a093523SKonstantin Ananyev  * @internal
54597a093523SKonstantin Ananyev  * Helper routine for rte_eth_rx_burst().
54607a093523SKonstantin Ananyev  * Should be called at exit from PMD's rte_eth_rx_bulk implementation.
54617a093523SKonstantin Ananyev  * Does necessary post-processing - invokes Rx callbacks if any, etc.
54627a093523SKonstantin Ananyev  *
54637a093523SKonstantin Ananyev  * @param port_id
54647a093523SKonstantin Ananyev  *  The port identifier of the Ethernet device.
54657a093523SKonstantin Ananyev  * @param queue_id
54667a093523SKonstantin Ananyev  *  The index of the receive queue from which to retrieve input packets.
54677a093523SKonstantin Ananyev  * @param rx_pkts
54687a093523SKonstantin Ananyev  *   The address of an array of pointers to *rte_mbuf* structures that
54697a093523SKonstantin Ananyev  *   have been retrieved from the device.
54707a093523SKonstantin Ananyev  * @param nb_rx
54717a093523SKonstantin Ananyev  *   The number of packets that were retrieved from the device.
54727a093523SKonstantin Ananyev  * @param nb_pkts
54737a093523SKonstantin Ananyev  *   The number of elements in @p rx_pkts array.
54747a093523SKonstantin Ananyev  * @param opaque
54757a093523SKonstantin Ananyev  *   Opaque pointer of Rx queue callback related data.
54767a093523SKonstantin Ananyev  *
54777a093523SKonstantin Ananyev  * @return
54787a093523SKonstantin Ananyev  *  The number of packets effectively supplied to the @p rx_pkts array.
54797a093523SKonstantin Ananyev  */
54807a093523SKonstantin Ananyev uint16_t rte_eth_call_rx_callbacks(uint16_t port_id, uint16_t queue_id,
54817a093523SKonstantin Ananyev 		struct rte_mbuf **rx_pkts, uint16_t nb_rx, uint16_t nb_pkts,
54827a093523SKonstantin Ananyev 		void *opaque);
54837a093523SKonstantin Ananyev 
54847a093523SKonstantin Ananyev /**
548599a2dd95SBruce Richardson  *
548699a2dd95SBruce Richardson  * Retrieve a burst of input packets from a receive queue of an Ethernet
548799a2dd95SBruce Richardson  * device. The retrieved packets are stored in *rte_mbuf* structures whose
548899a2dd95SBruce Richardson  * pointers are supplied in the *rx_pkts* array.
548999a2dd95SBruce Richardson  *
549009fd4227SAndrew Rybchenko  * The rte_eth_rx_burst() function loops, parsing the Rx ring of the
549109fd4227SAndrew Rybchenko  * receive queue, up to *nb_pkts* packets, and for each completed Rx
549299a2dd95SBruce Richardson  * descriptor in the ring, it performs the following operations:
549399a2dd95SBruce Richardson  *
549499a2dd95SBruce Richardson  * - Initialize the *rte_mbuf* data structure associated with the
549509fd4227SAndrew Rybchenko  *   Rx descriptor according to the information provided by the NIC into
549609fd4227SAndrew Rybchenko  *   that Rx descriptor.
549799a2dd95SBruce Richardson  *
549899a2dd95SBruce Richardson  * - Store the *rte_mbuf* data structure into the next entry of the
549999a2dd95SBruce Richardson  *   *rx_pkts* array.
550099a2dd95SBruce Richardson  *
550109fd4227SAndrew Rybchenko  * - Replenish the Rx descriptor with a new *rte_mbuf* buffer
550299a2dd95SBruce Richardson  *   allocated from the memory pool associated with the receive queue at
550399a2dd95SBruce Richardson  *   initialization time.
550499a2dd95SBruce Richardson  *
550599a2dd95SBruce Richardson  * When retrieving an input packet that was scattered by the controller
550699a2dd95SBruce Richardson  * into multiple receive descriptors, the rte_eth_rx_burst() function
550799a2dd95SBruce Richardson  * appends the associated *rte_mbuf* buffers to the first buffer of the
550899a2dd95SBruce Richardson  * packet.
550999a2dd95SBruce Richardson  *
551099a2dd95SBruce Richardson  * The rte_eth_rx_burst() function returns the number of packets
551199a2dd95SBruce Richardson  * actually retrieved, which is the number of *rte_mbuf* data structures
551299a2dd95SBruce Richardson  * effectively supplied into the *rx_pkts* array.
551309fd4227SAndrew Rybchenko  * A return value equal to *nb_pkts* indicates that the Rx queue contained
551499a2dd95SBruce Richardson  * at least *rx_pkts* packets, and this is likely to signify that other
551599a2dd95SBruce Richardson  * received packets remain in the input queue. Applications implementing
551699a2dd95SBruce Richardson  * a "retrieve as much received packets as possible" policy can check this
551799a2dd95SBruce Richardson  * specific case and keep invoking the rte_eth_rx_burst() function until
551899a2dd95SBruce Richardson  * a value less than *nb_pkts* is returned.
551999a2dd95SBruce Richardson  *
552099a2dd95SBruce Richardson  * This receive method has the following advantages:
552199a2dd95SBruce Richardson  *
552299a2dd95SBruce Richardson  * - It allows a run-to-completion network stack engine to retrieve and
552399a2dd95SBruce Richardson  *   to immediately process received packets in a fast burst-oriented
552499a2dd95SBruce Richardson  *   approach, avoiding the overhead of unnecessary intermediate packet
552599a2dd95SBruce Richardson  *   queue/dequeue operations.
552699a2dd95SBruce Richardson  *
552799a2dd95SBruce Richardson  * - Conversely, it also allows an asynchronous-oriented processing
552899a2dd95SBruce Richardson  *   method to retrieve bursts of received packets and to immediately
552999a2dd95SBruce Richardson  *   queue them for further parallel processing by another logical core,
553099a2dd95SBruce Richardson  *   for instance. However, instead of having received packets being
553199a2dd95SBruce Richardson  *   individually queued by the driver, this approach allows the caller
553299a2dd95SBruce Richardson  *   of the rte_eth_rx_burst() function to queue a burst of retrieved
553399a2dd95SBruce Richardson  *   packets at a time and therefore dramatically reduce the cost of
553499a2dd95SBruce Richardson  *   enqueue/dequeue operations per packet.
553599a2dd95SBruce Richardson  *
553699a2dd95SBruce Richardson  * - It allows the rte_eth_rx_burst() function of the driver to take
553799a2dd95SBruce Richardson  *   advantage of burst-oriented hardware features (CPU cache,
553899a2dd95SBruce Richardson  *   prefetch instructions, and so on) to minimize the number of CPU
553999a2dd95SBruce Richardson  *   cycles per packet.
554099a2dd95SBruce Richardson  *
554199a2dd95SBruce Richardson  * To summarize, the proposed receive API enables many
554299a2dd95SBruce Richardson  * burst-oriented optimizations in both synchronous and asynchronous
554399a2dd95SBruce Richardson  * packet processing environments with no overhead in both cases.
554499a2dd95SBruce Richardson  *
554599a2dd95SBruce Richardson  * @note
554699a2dd95SBruce Richardson  *   Some drivers using vector instructions require that *nb_pkts* is
554799a2dd95SBruce Richardson  *   divisible by 4 or 8, depending on the driver implementation.
554899a2dd95SBruce Richardson  *
554999a2dd95SBruce Richardson  * The rte_eth_rx_burst() function does not provide any error
555099a2dd95SBruce Richardson  * notification to avoid the corresponding overhead. As a hint, the
555199a2dd95SBruce Richardson  * upper-level application might check the status of the device link once
555299a2dd95SBruce Richardson  * being systematically returned a 0 value for a given number of tries.
555399a2dd95SBruce Richardson  *
555499a2dd95SBruce Richardson  * @param port_id
555599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
555699a2dd95SBruce Richardson  * @param queue_id
555799a2dd95SBruce Richardson  *   The index of the receive queue from which to retrieve input packets.
555899a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
555999a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
556099a2dd95SBruce Richardson  * @param rx_pkts
556199a2dd95SBruce Richardson  *   The address of an array of pointers to *rte_mbuf* structures that
556299a2dd95SBruce Richardson  *   must be large enough to store *nb_pkts* pointers in it.
556399a2dd95SBruce Richardson  * @param nb_pkts
556499a2dd95SBruce Richardson  *   The maximum number of packets to retrieve.
556599a2dd95SBruce Richardson  *   The value must be divisible by 8 in order to work with any driver.
556699a2dd95SBruce Richardson  * @return
556799a2dd95SBruce Richardson  *   The number of packets actually retrieved, which is the number
556899a2dd95SBruce Richardson  *   of pointers to *rte_mbuf* structures effectively supplied to the
556999a2dd95SBruce Richardson  *   *rx_pkts* array.
557099a2dd95SBruce Richardson  */
557199a2dd95SBruce Richardson static inline uint16_t
rte_eth_rx_burst(uint16_t port_id,uint16_t queue_id,struct rte_mbuf ** rx_pkts,const uint16_t nb_pkts)557299a2dd95SBruce Richardson rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id,
557399a2dd95SBruce Richardson 		 struct rte_mbuf **rx_pkts, const uint16_t nb_pkts)
557499a2dd95SBruce Richardson {
557599a2dd95SBruce Richardson 	uint16_t nb_rx;
55767a093523SKonstantin Ananyev 	struct rte_eth_fp_ops *p;
55777a093523SKonstantin Ananyev 	void *qd;
557899a2dd95SBruce Richardson 
557999a2dd95SBruce Richardson #ifdef RTE_ETHDEV_DEBUG_RX
55807a093523SKonstantin Ananyev 	if (port_id >= RTE_MAX_ETHPORTS ||
55817a093523SKonstantin Ananyev 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
55827a093523SKonstantin Ananyev 		RTE_ETHDEV_LOG(ERR,
55837a093523SKonstantin Ananyev 			"Invalid port_id=%u or queue_id=%u\n",
55847a093523SKonstantin Ananyev 			port_id, queue_id);
558599a2dd95SBruce Richardson 		return 0;
558699a2dd95SBruce Richardson 	}
558799a2dd95SBruce Richardson #endif
55887a093523SKonstantin Ananyev 
55897a093523SKonstantin Ananyev 	/* fetch pointer to queue data */
55907a093523SKonstantin Ananyev 	p = &rte_eth_fp_ops[port_id];
55917a093523SKonstantin Ananyev 	qd = p->rxq.data[queue_id];
55927a093523SKonstantin Ananyev 
55937a093523SKonstantin Ananyev #ifdef RTE_ETHDEV_DEBUG_RX
55947a093523SKonstantin Ananyev 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
55957a093523SKonstantin Ananyev 
55967a093523SKonstantin Ananyev 	if (qd == NULL) {
559709fd4227SAndrew Rybchenko 		RTE_ETHDEV_LOG(ERR, "Invalid Rx queue_id=%u for port_id=%u\n",
55987a093523SKonstantin Ananyev 			queue_id, port_id);
55997a093523SKonstantin Ananyev 		return 0;
56007a093523SKonstantin Ananyev 	}
56017a093523SKonstantin Ananyev #endif
56027a093523SKonstantin Ananyev 
56037a093523SKonstantin Ananyev 	nb_rx = p->rx_pkt_burst(qd, rx_pkts, nb_pkts);
560499a2dd95SBruce Richardson 
560599a2dd95SBruce Richardson #ifdef RTE_ETHDEV_RXTX_CALLBACKS
56067a093523SKonstantin Ananyev 	{
56077a093523SKonstantin Ananyev 		void *cb;
560899a2dd95SBruce Richardson 
560999a2dd95SBruce Richardson 		/* __ATOMIC_RELEASE memory order was used when the
561099a2dd95SBruce Richardson 		 * call back was inserted into the list.
561199a2dd95SBruce Richardson 		 * Since there is a clear dependency between loading
561299a2dd95SBruce Richardson 		 * cb and cb->fn/cb->next, __ATOMIC_ACQUIRE memory order is
561399a2dd95SBruce Richardson 		 * not required.
561499a2dd95SBruce Richardson 		 */
56157a093523SKonstantin Ananyev 		cb = __atomic_load_n((void **)&p->rxq.clbk[queue_id],
561699a2dd95SBruce Richardson 				__ATOMIC_RELAXED);
56177a093523SKonstantin Ananyev 		if (unlikely(cb != NULL))
56187a093523SKonstantin Ananyev 			nb_rx = rte_eth_call_rx_callbacks(port_id, queue_id,
56197a093523SKonstantin Ananyev 					rx_pkts, nb_rx, nb_pkts, cb);
562099a2dd95SBruce Richardson 	}
562199a2dd95SBruce Richardson #endif
562299a2dd95SBruce Richardson 
562399a2dd95SBruce Richardson 	rte_ethdev_trace_rx_burst(port_id, queue_id, (void **)rx_pkts, nb_rx);
562499a2dd95SBruce Richardson 	return nb_rx;
562599a2dd95SBruce Richardson }
562699a2dd95SBruce Richardson 
562799a2dd95SBruce Richardson /**
562809fd4227SAndrew Rybchenko  * Get the number of used descriptors of a Rx queue
562999a2dd95SBruce Richardson  *
563099a2dd95SBruce Richardson  * @param port_id
563199a2dd95SBruce Richardson  *  The port identifier of the Ethernet device.
563299a2dd95SBruce Richardson  * @param queue_id
56335906be5aSAndrew Rybchenko  *  The queue ID on the specific port.
563499a2dd95SBruce Richardson  * @return
563599a2dd95SBruce Richardson  *  The number of used descriptors in the specific queue, or:
563699a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
563799a2dd95SBruce Richardson  *     (-EINVAL) if *queue_id* is invalid
563899a2dd95SBruce Richardson  *     (-ENOTSUP) if the device does not support this function
563999a2dd95SBruce Richardson  */
564099a2dd95SBruce Richardson static inline int
rte_eth_rx_queue_count(uint16_t port_id,uint16_t queue_id)564199a2dd95SBruce Richardson rte_eth_rx_queue_count(uint16_t port_id, uint16_t queue_id)
564299a2dd95SBruce Richardson {
56437a093523SKonstantin Ananyev 	struct rte_eth_fp_ops *p;
56447a093523SKonstantin Ananyev 	void *qd;
56457a093523SKonstantin Ananyev 
56467a093523SKonstantin Ananyev 	if (port_id >= RTE_MAX_ETHPORTS ||
56477a093523SKonstantin Ananyev 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
56487a093523SKonstantin Ananyev 		RTE_ETHDEV_LOG(ERR,
56497a093523SKonstantin Ananyev 			"Invalid port_id=%u or queue_id=%u\n",
56507a093523SKonstantin Ananyev 			port_id, queue_id);
56517a093523SKonstantin Ananyev 		return -EINVAL;
56527a093523SKonstantin Ananyev 	}
56537a093523SKonstantin Ananyev 
56547a093523SKonstantin Ananyev 	/* fetch pointer to queue data */
56557a093523SKonstantin Ananyev 	p = &rte_eth_fp_ops[port_id];
56567a093523SKonstantin Ananyev 	qd = p->rxq.data[queue_id];
565799a2dd95SBruce Richardson 
565899a2dd95SBruce Richardson 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
56597a093523SKonstantin Ananyev 	RTE_FUNC_PTR_OR_ERR_RET(*p->rx_queue_count, -ENOTSUP);
56607a093523SKonstantin Ananyev 	if (qd == NULL)
566199a2dd95SBruce Richardson 		return -EINVAL;
566299a2dd95SBruce Richardson 
56637a093523SKonstantin Ananyev 	return (int)(*p->rx_queue_count)(qd);
566499a2dd95SBruce Richardson }
566599a2dd95SBruce Richardson 
56660ce56b05SThomas Monjalon /**@{@name Rx hardware descriptor states
56670ce56b05SThomas Monjalon  * @see rte_eth_rx_descriptor_status
56680ce56b05SThomas Monjalon  */
566999a2dd95SBruce Richardson #define RTE_ETH_RX_DESC_AVAIL    0 /**< Desc available for hw. */
567099a2dd95SBruce Richardson #define RTE_ETH_RX_DESC_DONE     1 /**< Desc done, filled by hw. */
567199a2dd95SBruce Richardson #define RTE_ETH_RX_DESC_UNAVAIL  2 /**< Desc used by driver or hw. */
56720ce56b05SThomas Monjalon /**@}*/
567399a2dd95SBruce Richardson 
567499a2dd95SBruce Richardson /**
567599a2dd95SBruce Richardson  * Check the status of a Rx descriptor in the queue
567699a2dd95SBruce Richardson  *
567799a2dd95SBruce Richardson  * It should be called in a similar context than the Rx function:
567899a2dd95SBruce Richardson  * - on a dataplane core
567999a2dd95SBruce Richardson  * - not concurrently on the same queue
568099a2dd95SBruce Richardson  *
568199a2dd95SBruce Richardson  * Since it's a dataplane function, no check is performed on port_id and
568299a2dd95SBruce Richardson  * queue_id. The caller must therefore ensure that the port is enabled
568399a2dd95SBruce Richardson  * and the queue is configured and running.
568499a2dd95SBruce Richardson  *
568599a2dd95SBruce Richardson  * Note: accessing to a random descriptor in the ring may trigger cache
568699a2dd95SBruce Richardson  * misses and have a performance impact.
568799a2dd95SBruce Richardson  *
568899a2dd95SBruce Richardson  * @param port_id
568999a2dd95SBruce Richardson  *  A valid port identifier of the Ethernet device which.
569099a2dd95SBruce Richardson  * @param queue_id
569199a2dd95SBruce Richardson  *  A valid Rx queue identifier on this port.
569299a2dd95SBruce Richardson  * @param offset
569399a2dd95SBruce Richardson  *  The offset of the descriptor starting from tail (0 is the next
569499a2dd95SBruce Richardson  *  packet to be received by the driver).
569599a2dd95SBruce Richardson  *
569699a2dd95SBruce Richardson  * @return
569799a2dd95SBruce Richardson  *  - (RTE_ETH_RX_DESC_AVAIL): Descriptor is available for the hardware to
569899a2dd95SBruce Richardson  *    receive a packet.
569999a2dd95SBruce Richardson  *  - (RTE_ETH_RX_DESC_DONE): Descriptor is done, it is filled by hw, but
570099a2dd95SBruce Richardson  *    not yet processed by the driver (i.e. in the receive queue).
570199a2dd95SBruce Richardson  *  - (RTE_ETH_RX_DESC_UNAVAIL): Descriptor is unavailable, either hold by
570299a2dd95SBruce Richardson  *    the driver and not yet returned to hw, or reserved by the hw.
570399a2dd95SBruce Richardson  *  - (-EINVAL) bad descriptor offset.
570499a2dd95SBruce Richardson  *  - (-ENOTSUP) if the device does not support this function.
570599a2dd95SBruce Richardson  *  - (-ENODEV) bad port or queue (only if compiled with debug).
570699a2dd95SBruce Richardson  */
570799a2dd95SBruce Richardson static inline int
rte_eth_rx_descriptor_status(uint16_t port_id,uint16_t queue_id,uint16_t offset)570899a2dd95SBruce Richardson rte_eth_rx_descriptor_status(uint16_t port_id, uint16_t queue_id,
570999a2dd95SBruce Richardson 	uint16_t offset)
571099a2dd95SBruce Richardson {
57117a093523SKonstantin Ananyev 	struct rte_eth_fp_ops *p;
57127a093523SKonstantin Ananyev 	void *qd;
57137a093523SKonstantin Ananyev 
57147a093523SKonstantin Ananyev #ifdef RTE_ETHDEV_DEBUG_RX
57157a093523SKonstantin Ananyev 	if (port_id >= RTE_MAX_ETHPORTS ||
57167a093523SKonstantin Ananyev 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
57177a093523SKonstantin Ananyev 		RTE_ETHDEV_LOG(ERR,
57187a093523SKonstantin Ananyev 			"Invalid port_id=%u or queue_id=%u\n",
57197a093523SKonstantin Ananyev 			port_id, queue_id);
57207a093523SKonstantin Ananyev 		return -EINVAL;
57217a093523SKonstantin Ananyev 	}
57227a093523SKonstantin Ananyev #endif
57237a093523SKonstantin Ananyev 
57247a093523SKonstantin Ananyev 	/* fetch pointer to queue data */
57257a093523SKonstantin Ananyev 	p = &rte_eth_fp_ops[port_id];
57267a093523SKonstantin Ananyev 	qd = p->rxq.data[queue_id];
572799a2dd95SBruce Richardson 
572899a2dd95SBruce Richardson #ifdef RTE_ETHDEV_DEBUG_RX
572999a2dd95SBruce Richardson 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
57307a093523SKonstantin Ananyev 	if (qd == NULL)
573199a2dd95SBruce Richardson 		return -ENODEV;
573299a2dd95SBruce Richardson #endif
57337a093523SKonstantin Ananyev 	RTE_FUNC_PTR_OR_ERR_RET(*p->rx_descriptor_status, -ENOTSUP);
57347a093523SKonstantin Ananyev 	return (*p->rx_descriptor_status)(qd, offset);
573599a2dd95SBruce Richardson }
573699a2dd95SBruce Richardson 
57370ce56b05SThomas Monjalon /**@{@name Tx hardware descriptor states
57380ce56b05SThomas Monjalon  * @see rte_eth_tx_descriptor_status
57390ce56b05SThomas Monjalon  */
574099a2dd95SBruce Richardson #define RTE_ETH_TX_DESC_FULL    0 /**< Desc filled for hw, waiting xmit. */
574199a2dd95SBruce Richardson #define RTE_ETH_TX_DESC_DONE    1 /**< Desc done, packet is transmitted. */
574299a2dd95SBruce Richardson #define RTE_ETH_TX_DESC_UNAVAIL 2 /**< Desc used by driver or hw. */
57430ce56b05SThomas Monjalon /**@}*/
574499a2dd95SBruce Richardson 
574599a2dd95SBruce Richardson /**
574699a2dd95SBruce Richardson  * Check the status of a Tx descriptor in the queue.
574799a2dd95SBruce Richardson  *
574899a2dd95SBruce Richardson  * It should be called in a similar context than the Tx function:
574999a2dd95SBruce Richardson  * - on a dataplane core
575099a2dd95SBruce Richardson  * - not concurrently on the same queue
575199a2dd95SBruce Richardson  *
575299a2dd95SBruce Richardson  * Since it's a dataplane function, no check is performed on port_id and
575399a2dd95SBruce Richardson  * queue_id. The caller must therefore ensure that the port is enabled
575499a2dd95SBruce Richardson  * and the queue is configured and running.
575599a2dd95SBruce Richardson  *
575699a2dd95SBruce Richardson  * Note: accessing to a random descriptor in the ring may trigger cache
575799a2dd95SBruce Richardson  * misses and have a performance impact.
575899a2dd95SBruce Richardson  *
575999a2dd95SBruce Richardson  * @param port_id
576099a2dd95SBruce Richardson  *  A valid port identifier of the Ethernet device which.
576199a2dd95SBruce Richardson  * @param queue_id
576299a2dd95SBruce Richardson  *  A valid Tx queue identifier on this port.
576399a2dd95SBruce Richardson  * @param offset
576499a2dd95SBruce Richardson  *  The offset of the descriptor starting from tail (0 is the place where
576599a2dd95SBruce Richardson  *  the next packet will be send).
576699a2dd95SBruce Richardson  *
576799a2dd95SBruce Richardson  * @return
576899a2dd95SBruce Richardson  *  - (RTE_ETH_TX_DESC_FULL) Descriptor is being processed by the hw, i.e.
576999a2dd95SBruce Richardson  *    in the transmit queue.
577099a2dd95SBruce Richardson  *  - (RTE_ETH_TX_DESC_DONE) Hardware is done with this descriptor, it can
577199a2dd95SBruce Richardson  *    be reused by the driver.
577299a2dd95SBruce Richardson  *  - (RTE_ETH_TX_DESC_UNAVAIL): Descriptor is unavailable, reserved by the
577399a2dd95SBruce Richardson  *    driver or the hardware.
577499a2dd95SBruce Richardson  *  - (-EINVAL) bad descriptor offset.
577599a2dd95SBruce Richardson  *  - (-ENOTSUP) if the device does not support this function.
577699a2dd95SBruce Richardson  *  - (-ENODEV) bad port or queue (only if compiled with debug).
577799a2dd95SBruce Richardson  */
rte_eth_tx_descriptor_status(uint16_t port_id,uint16_t queue_id,uint16_t offset)577899a2dd95SBruce Richardson static inline int rte_eth_tx_descriptor_status(uint16_t port_id,
577999a2dd95SBruce Richardson 	uint16_t queue_id, uint16_t offset)
578099a2dd95SBruce Richardson {
57817a093523SKonstantin Ananyev 	struct rte_eth_fp_ops *p;
57827a093523SKonstantin Ananyev 	void *qd;
57837a093523SKonstantin Ananyev 
57847a093523SKonstantin Ananyev #ifdef RTE_ETHDEV_DEBUG_TX
57857a093523SKonstantin Ananyev 	if (port_id >= RTE_MAX_ETHPORTS ||
57867a093523SKonstantin Ananyev 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
57877a093523SKonstantin Ananyev 		RTE_ETHDEV_LOG(ERR,
57887a093523SKonstantin Ananyev 			"Invalid port_id=%u or queue_id=%u\n",
57897a093523SKonstantin Ananyev 			port_id, queue_id);
57907a093523SKonstantin Ananyev 		return -EINVAL;
57917a093523SKonstantin Ananyev 	}
57927a093523SKonstantin Ananyev #endif
57937a093523SKonstantin Ananyev 
57947a093523SKonstantin Ananyev 	/* fetch pointer to queue data */
57957a093523SKonstantin Ananyev 	p = &rte_eth_fp_ops[port_id];
57967a093523SKonstantin Ananyev 	qd = p->txq.data[queue_id];
579799a2dd95SBruce Richardson 
579899a2dd95SBruce Richardson #ifdef RTE_ETHDEV_DEBUG_TX
579999a2dd95SBruce Richardson 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
58007a093523SKonstantin Ananyev 	if (qd == NULL)
580199a2dd95SBruce Richardson 		return -ENODEV;
580299a2dd95SBruce Richardson #endif
58037a093523SKonstantin Ananyev 	RTE_FUNC_PTR_OR_ERR_RET(*p->tx_descriptor_status, -ENOTSUP);
58047a093523SKonstantin Ananyev 	return (*p->tx_descriptor_status)(qd, offset);
580599a2dd95SBruce Richardson }
580699a2dd95SBruce Richardson 
580799a2dd95SBruce Richardson /**
58087a093523SKonstantin Ananyev  * @internal
58097a093523SKonstantin Ananyev  * Helper routine for rte_eth_tx_burst().
58107a093523SKonstantin Ananyev  * Should be called before entry PMD's rte_eth_tx_bulk implementation.
58117a093523SKonstantin Ananyev  * Does necessary pre-processing - invokes Tx callbacks if any, etc.
58127a093523SKonstantin Ananyev  *
58137a093523SKonstantin Ananyev  * @param port_id
58147a093523SKonstantin Ananyev  *   The port identifier of the Ethernet device.
58157a093523SKonstantin Ananyev  * @param queue_id
58167a093523SKonstantin Ananyev  *   The index of the transmit queue through which output packets must be
58177a093523SKonstantin Ananyev  *   sent.
58187a093523SKonstantin Ananyev  * @param tx_pkts
58197a093523SKonstantin Ananyev  *   The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
58207a093523SKonstantin Ananyev  *   which contain the output packets.
58217a093523SKonstantin Ananyev  * @param nb_pkts
58227a093523SKonstantin Ananyev  *   The maximum number of packets to transmit.
58237a093523SKonstantin Ananyev  * @return
58247a093523SKonstantin Ananyev  *   The number of output packets to transmit.
58257a093523SKonstantin Ananyev  */
58267a093523SKonstantin Ananyev uint16_t rte_eth_call_tx_callbacks(uint16_t port_id, uint16_t queue_id,
58277a093523SKonstantin Ananyev 	struct rte_mbuf **tx_pkts, uint16_t nb_pkts, void *opaque);
58287a093523SKonstantin Ananyev 
58297a093523SKonstantin Ananyev /**
583099a2dd95SBruce Richardson  * Send a burst of output packets on a transmit queue of an Ethernet device.
583199a2dd95SBruce Richardson  *
583299a2dd95SBruce Richardson  * The rte_eth_tx_burst() function is invoked to transmit output packets
583399a2dd95SBruce Richardson  * on the output queue *queue_id* of the Ethernet device designated by its
583499a2dd95SBruce Richardson  * *port_id*.
583599a2dd95SBruce Richardson  * The *nb_pkts* parameter is the number of packets to send which are
583699a2dd95SBruce Richardson  * supplied in the *tx_pkts* array of *rte_mbuf* structures, each of them
583799a2dd95SBruce Richardson  * allocated from a pool created with rte_pktmbuf_pool_create().
583899a2dd95SBruce Richardson  * The rte_eth_tx_burst() function loops, sending *nb_pkts* packets,
583909fd4227SAndrew Rybchenko  * up to the number of transmit descriptors available in the Tx ring of the
584099a2dd95SBruce Richardson  * transmit queue.
584199a2dd95SBruce Richardson  * For each packet to send, the rte_eth_tx_burst() function performs
584299a2dd95SBruce Richardson  * the following operations:
584399a2dd95SBruce Richardson  *
584499a2dd95SBruce Richardson  * - Pick up the next available descriptor in the transmit ring.
584599a2dd95SBruce Richardson  *
584699a2dd95SBruce Richardson  * - Free the network buffer previously sent with that descriptor, if any.
584799a2dd95SBruce Richardson  *
584899a2dd95SBruce Richardson  * - Initialize the transmit descriptor with the information provided
584999a2dd95SBruce Richardson  *   in the *rte_mbuf data structure.
585099a2dd95SBruce Richardson  *
585199a2dd95SBruce Richardson  * In the case of a segmented packet composed of a list of *rte_mbuf* buffers,
585299a2dd95SBruce Richardson  * the rte_eth_tx_burst() function uses several transmit descriptors
585399a2dd95SBruce Richardson  * of the ring.
585499a2dd95SBruce Richardson  *
585599a2dd95SBruce Richardson  * The rte_eth_tx_burst() function returns the number of packets it
585699a2dd95SBruce Richardson  * actually sent. A return value equal to *nb_pkts* means that all packets
585799a2dd95SBruce Richardson  * have been sent, and this is likely to signify that other output packets
585899a2dd95SBruce Richardson  * could be immediately transmitted again. Applications that implement a
585999a2dd95SBruce Richardson  * "send as many packets to transmit as possible" policy can check this
586099a2dd95SBruce Richardson  * specific case and keep invoking the rte_eth_tx_burst() function until
586199a2dd95SBruce Richardson  * a value less than *nb_pkts* is returned.
586299a2dd95SBruce Richardson  *
586399a2dd95SBruce Richardson  * It is the responsibility of the rte_eth_tx_burst() function to
586499a2dd95SBruce Richardson  * transparently free the memory buffers of packets previously sent.
586599a2dd95SBruce Richardson  * This feature is driven by the *tx_free_thresh* value supplied to the
586699a2dd95SBruce Richardson  * rte_eth_dev_configure() function at device configuration time.
586709fd4227SAndrew Rybchenko  * When the number of free Tx descriptors drops below this threshold, the
586899a2dd95SBruce Richardson  * rte_eth_tx_burst() function must [attempt to] free the *rte_mbuf*  buffers
586999a2dd95SBruce Richardson  * of those packets whose transmission was effectively completed.
587099a2dd95SBruce Richardson  *
5871295968d1SFerruh Yigit  * If the PMD is RTE_ETH_TX_OFFLOAD_MT_LOCKFREE capable, multiple threads can
587209fd4227SAndrew Rybchenko  * invoke this function concurrently on the same Tx queue without SW lock.
587399a2dd95SBruce Richardson  * @see rte_eth_dev_info_get, struct rte_eth_txconf::offloads
587499a2dd95SBruce Richardson  *
587599a2dd95SBruce Richardson  * @see rte_eth_tx_prepare to perform some prior checks or adjustments
587699a2dd95SBruce Richardson  * for offloads.
587799a2dd95SBruce Richardson  *
587899a2dd95SBruce Richardson  * @param port_id
587999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
588099a2dd95SBruce Richardson  * @param queue_id
588199a2dd95SBruce Richardson  *   The index of the transmit queue through which output packets must be
588299a2dd95SBruce Richardson  *   sent.
588399a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
588499a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
588599a2dd95SBruce Richardson  * @param tx_pkts
588699a2dd95SBruce Richardson  *   The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
588799a2dd95SBruce Richardson  *   which contain the output packets.
588899a2dd95SBruce Richardson  * @param nb_pkts
588999a2dd95SBruce Richardson  *   The maximum number of packets to transmit.
589099a2dd95SBruce Richardson  * @return
589199a2dd95SBruce Richardson  *   The number of output packets actually stored in transmit descriptors of
589299a2dd95SBruce Richardson  *   the transmit ring. The return value can be less than the value of the
589399a2dd95SBruce Richardson  *   *tx_pkts* parameter when the transmit ring is full or has been filled up.
589499a2dd95SBruce Richardson  */
589599a2dd95SBruce Richardson static inline uint16_t
rte_eth_tx_burst(uint16_t port_id,uint16_t queue_id,struct rte_mbuf ** tx_pkts,uint16_t nb_pkts)589699a2dd95SBruce Richardson rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
589799a2dd95SBruce Richardson 		 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
589899a2dd95SBruce Richardson {
58997a093523SKonstantin Ananyev 	struct rte_eth_fp_ops *p;
59007a093523SKonstantin Ananyev 	void *qd;
59017a093523SKonstantin Ananyev 
59027a093523SKonstantin Ananyev #ifdef RTE_ETHDEV_DEBUG_TX
59037a093523SKonstantin Ananyev 	if (port_id >= RTE_MAX_ETHPORTS ||
59047a093523SKonstantin Ananyev 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
59057a093523SKonstantin Ananyev 		RTE_ETHDEV_LOG(ERR,
59067a093523SKonstantin Ananyev 			"Invalid port_id=%u or queue_id=%u\n",
59077a093523SKonstantin Ananyev 			port_id, queue_id);
59087a093523SKonstantin Ananyev 		return 0;
59097a093523SKonstantin Ananyev 	}
59107a093523SKonstantin Ananyev #endif
59117a093523SKonstantin Ananyev 
59127a093523SKonstantin Ananyev 	/* fetch pointer to queue data */
59137a093523SKonstantin Ananyev 	p = &rte_eth_fp_ops[port_id];
59147a093523SKonstantin Ananyev 	qd = p->txq.data[queue_id];
591599a2dd95SBruce Richardson 
591699a2dd95SBruce Richardson #ifdef RTE_ETHDEV_DEBUG_TX
591799a2dd95SBruce Richardson 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
591899a2dd95SBruce Richardson 
59197a093523SKonstantin Ananyev 	if (qd == NULL) {
592009fd4227SAndrew Rybchenko 		RTE_ETHDEV_LOG(ERR, "Invalid Tx queue_id=%u for port_id=%u\n",
59217a093523SKonstantin Ananyev 			queue_id, port_id);
592299a2dd95SBruce Richardson 		return 0;
592399a2dd95SBruce Richardson 	}
592499a2dd95SBruce Richardson #endif
592599a2dd95SBruce Richardson 
592699a2dd95SBruce Richardson #ifdef RTE_ETHDEV_RXTX_CALLBACKS
59277a093523SKonstantin Ananyev 	{
59287a093523SKonstantin Ananyev 		void *cb;
592999a2dd95SBruce Richardson 
593099a2dd95SBruce Richardson 		/* __ATOMIC_RELEASE memory order was used when the
593199a2dd95SBruce Richardson 		 * call back was inserted into the list.
593299a2dd95SBruce Richardson 		 * Since there is a clear dependency between loading
593399a2dd95SBruce Richardson 		 * cb and cb->fn/cb->next, __ATOMIC_ACQUIRE memory order is
593499a2dd95SBruce Richardson 		 * not required.
593599a2dd95SBruce Richardson 		 */
59367a093523SKonstantin Ananyev 		cb = __atomic_load_n((void **)&p->txq.clbk[queue_id],
593799a2dd95SBruce Richardson 				__ATOMIC_RELAXED);
59387a093523SKonstantin Ananyev 		if (unlikely(cb != NULL))
59397a093523SKonstantin Ananyev 			nb_pkts = rte_eth_call_tx_callbacks(port_id, queue_id,
59407a093523SKonstantin Ananyev 					tx_pkts, nb_pkts, cb);
594199a2dd95SBruce Richardson 	}
594299a2dd95SBruce Richardson #endif
594399a2dd95SBruce Richardson 
59447a093523SKonstantin Ananyev 	nb_pkts = p->tx_pkt_burst(qd, tx_pkts, nb_pkts);
59457a093523SKonstantin Ananyev 
59467a093523SKonstantin Ananyev 	rte_ethdev_trace_tx_burst(port_id, queue_id, (void **)tx_pkts, nb_pkts);
59477a093523SKonstantin Ananyev 	return nb_pkts;
594899a2dd95SBruce Richardson }
594999a2dd95SBruce Richardson 
595099a2dd95SBruce Richardson /**
595199a2dd95SBruce Richardson  * Process a burst of output packets on a transmit queue of an Ethernet device.
595299a2dd95SBruce Richardson  *
595399a2dd95SBruce Richardson  * The rte_eth_tx_prepare() function is invoked to prepare output packets to be
595499a2dd95SBruce Richardson  * transmitted on the output queue *queue_id* of the Ethernet device designated
595599a2dd95SBruce Richardson  * by its *port_id*.
595699a2dd95SBruce Richardson  * The *nb_pkts* parameter is the number of packets to be prepared which are
595799a2dd95SBruce Richardson  * supplied in the *tx_pkts* array of *rte_mbuf* structures, each of them
595899a2dd95SBruce Richardson  * allocated from a pool created with rte_pktmbuf_pool_create().
595999a2dd95SBruce Richardson  * For each packet to send, the rte_eth_tx_prepare() function performs
596099a2dd95SBruce Richardson  * the following operations:
596199a2dd95SBruce Richardson  *
596209fd4227SAndrew Rybchenko  * - Check if packet meets devices requirements for Tx offloads.
596399a2dd95SBruce Richardson  *
596499a2dd95SBruce Richardson  * - Check limitations about number of segments.
596599a2dd95SBruce Richardson  *
596699a2dd95SBruce Richardson  * - Check additional requirements when debug is enabled.
596799a2dd95SBruce Richardson  *
596809fd4227SAndrew Rybchenko  * - Update and/or reset required checksums when Tx offload is set for packet.
596999a2dd95SBruce Richardson  *
597099a2dd95SBruce Richardson  * Since this function can modify packet data, provided mbufs must be safely
597199a2dd95SBruce Richardson  * writable (e.g. modified data cannot be in shared segment).
597299a2dd95SBruce Richardson  *
597399a2dd95SBruce Richardson  * The rte_eth_tx_prepare() function returns the number of packets ready to be
597499a2dd95SBruce Richardson  * sent. A return value equal to *nb_pkts* means that all packets are valid and
597599a2dd95SBruce Richardson  * ready to be sent, otherwise stops processing on the first invalid packet and
597699a2dd95SBruce Richardson  * leaves the rest packets untouched.
597799a2dd95SBruce Richardson  *
597899a2dd95SBruce Richardson  * When this functionality is not implemented in the driver, all packets are
597999a2dd95SBruce Richardson  * are returned untouched.
598099a2dd95SBruce Richardson  *
598199a2dd95SBruce Richardson  * @param port_id
598299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
59835906be5aSAndrew Rybchenko  *   The value must be a valid port ID.
598499a2dd95SBruce Richardson  * @param queue_id
598599a2dd95SBruce Richardson  *   The index of the transmit queue through which output packets must be
598699a2dd95SBruce Richardson  *   sent.
598799a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
598899a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
598999a2dd95SBruce Richardson  * @param tx_pkts
599099a2dd95SBruce Richardson  *   The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
599199a2dd95SBruce Richardson  *   which contain the output packets.
599299a2dd95SBruce Richardson  * @param nb_pkts
599399a2dd95SBruce Richardson  *   The maximum number of packets to process.
599499a2dd95SBruce Richardson  * @return
599599a2dd95SBruce Richardson  *   The number of packets correct and ready to be sent. The return value can be
599699a2dd95SBruce Richardson  *   less than the value of the *tx_pkts* parameter when some packet doesn't
599799a2dd95SBruce Richardson  *   meet devices requirements with rte_errno set appropriately:
599899a2dd95SBruce Richardson  *   - EINVAL: offload flags are not correctly set
599999a2dd95SBruce Richardson  *   - ENOTSUP: the offload feature is not supported by the hardware
600099a2dd95SBruce Richardson  *   - ENODEV: if *port_id* is invalid (with debug enabled only)
600199a2dd95SBruce Richardson  *
600299a2dd95SBruce Richardson  */
600399a2dd95SBruce Richardson 
600499a2dd95SBruce Richardson #ifndef RTE_ETHDEV_TX_PREPARE_NOOP
600599a2dd95SBruce Richardson 
600699a2dd95SBruce Richardson static inline uint16_t
rte_eth_tx_prepare(uint16_t port_id,uint16_t queue_id,struct rte_mbuf ** tx_pkts,uint16_t nb_pkts)600799a2dd95SBruce Richardson rte_eth_tx_prepare(uint16_t port_id, uint16_t queue_id,
600899a2dd95SBruce Richardson 		struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
600999a2dd95SBruce Richardson {
60107a093523SKonstantin Ananyev 	struct rte_eth_fp_ops *p;
60117a093523SKonstantin Ananyev 	void *qd;
60127a093523SKonstantin Ananyev 
60137a093523SKonstantin Ananyev #ifdef RTE_ETHDEV_DEBUG_TX
60147a093523SKonstantin Ananyev 	if (port_id >= RTE_MAX_ETHPORTS ||
60157a093523SKonstantin Ananyev 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
60167a093523SKonstantin Ananyev 		RTE_ETHDEV_LOG(ERR,
60177a093523SKonstantin Ananyev 			"Invalid port_id=%u or queue_id=%u\n",
60187a093523SKonstantin Ananyev 			port_id, queue_id);
60197a093523SKonstantin Ananyev 		rte_errno = ENODEV;
60207a093523SKonstantin Ananyev 		return 0;
60217a093523SKonstantin Ananyev 	}
60227a093523SKonstantin Ananyev #endif
60237a093523SKonstantin Ananyev 
60247a093523SKonstantin Ananyev 	/* fetch pointer to queue data */
60257a093523SKonstantin Ananyev 	p = &rte_eth_fp_ops[port_id];
60267a093523SKonstantin Ananyev 	qd = p->txq.data[queue_id];
602799a2dd95SBruce Richardson 
602899a2dd95SBruce Richardson #ifdef RTE_ETHDEV_DEBUG_TX
602999a2dd95SBruce Richardson 	if (!rte_eth_dev_is_valid_port(port_id)) {
603009fd4227SAndrew Rybchenko 		RTE_ETHDEV_LOG(ERR, "Invalid Tx port_id=%u\n", port_id);
603199a2dd95SBruce Richardson 		rte_errno = ENODEV;
603299a2dd95SBruce Richardson 		return 0;
603399a2dd95SBruce Richardson 	}
60347a093523SKonstantin Ananyev 	if (qd == NULL) {
603509fd4227SAndrew Rybchenko 		RTE_ETHDEV_LOG(ERR, "Invalid Tx queue_id=%u for port_id=%u\n",
60367a093523SKonstantin Ananyev 			queue_id, port_id);
603799a2dd95SBruce Richardson 		rte_errno = EINVAL;
603899a2dd95SBruce Richardson 		return 0;
603999a2dd95SBruce Richardson 	}
604099a2dd95SBruce Richardson #endif
604199a2dd95SBruce Richardson 
60427a093523SKonstantin Ananyev 	if (!p->tx_pkt_prepare)
604399a2dd95SBruce Richardson 		return nb_pkts;
604499a2dd95SBruce Richardson 
60457a093523SKonstantin Ananyev 	return p->tx_pkt_prepare(qd, tx_pkts, nb_pkts);
604699a2dd95SBruce Richardson }
604799a2dd95SBruce Richardson 
604899a2dd95SBruce Richardson #else
604999a2dd95SBruce Richardson 
605099a2dd95SBruce Richardson /*
605199a2dd95SBruce Richardson  * Native NOOP operation for compilation targets which doesn't require any
605299a2dd95SBruce Richardson  * preparations steps, and functional NOOP may introduce unnecessary performance
605399a2dd95SBruce Richardson  * drop.
605499a2dd95SBruce Richardson  *
605599a2dd95SBruce Richardson  * Generally this is not a good idea to turn it on globally and didn't should
605699a2dd95SBruce Richardson  * be used if behavior of tx_preparation can change.
605799a2dd95SBruce Richardson  */
605899a2dd95SBruce Richardson 
605999a2dd95SBruce Richardson static inline uint16_t
rte_eth_tx_prepare(__rte_unused uint16_t port_id,__rte_unused uint16_t queue_id,__rte_unused struct rte_mbuf ** tx_pkts,uint16_t nb_pkts)606099a2dd95SBruce Richardson rte_eth_tx_prepare(__rte_unused uint16_t port_id,
606199a2dd95SBruce Richardson 		__rte_unused uint16_t queue_id,
606299a2dd95SBruce Richardson 		__rte_unused struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
606399a2dd95SBruce Richardson {
606499a2dd95SBruce Richardson 	return nb_pkts;
606599a2dd95SBruce Richardson }
606699a2dd95SBruce Richardson 
606799a2dd95SBruce Richardson #endif
606899a2dd95SBruce Richardson 
606999a2dd95SBruce Richardson /**
607099a2dd95SBruce Richardson  * Send any packets queued up for transmission on a port and HW queue
607199a2dd95SBruce Richardson  *
607299a2dd95SBruce Richardson  * This causes an explicit flush of packets previously buffered via the
607399a2dd95SBruce Richardson  * rte_eth_tx_buffer() function. It returns the number of packets successfully
607499a2dd95SBruce Richardson  * sent to the NIC, and calls the error callback for any unsent packets. Unless
607599a2dd95SBruce Richardson  * explicitly set up otherwise, the default callback simply frees the unsent
607699a2dd95SBruce Richardson  * packets back to the owning mempool.
607799a2dd95SBruce Richardson  *
607899a2dd95SBruce Richardson  * @param port_id
607999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
608099a2dd95SBruce Richardson  * @param queue_id
608199a2dd95SBruce Richardson  *   The index of the transmit queue through which output packets must be
608299a2dd95SBruce Richardson  *   sent.
608399a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
608499a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
608599a2dd95SBruce Richardson  * @param buffer
608699a2dd95SBruce Richardson  *   Buffer of packets to be transmit.
608799a2dd95SBruce Richardson  * @return
608899a2dd95SBruce Richardson  *   The number of packets successfully sent to the Ethernet device. The error
608999a2dd95SBruce Richardson  *   callback is called for any packets which could not be sent.
609099a2dd95SBruce Richardson  */
609199a2dd95SBruce Richardson static inline uint16_t
rte_eth_tx_buffer_flush(uint16_t port_id,uint16_t queue_id,struct rte_eth_dev_tx_buffer * buffer)609299a2dd95SBruce Richardson rte_eth_tx_buffer_flush(uint16_t port_id, uint16_t queue_id,
609399a2dd95SBruce Richardson 		struct rte_eth_dev_tx_buffer *buffer)
609499a2dd95SBruce Richardson {
609599a2dd95SBruce Richardson 	uint16_t sent;
609699a2dd95SBruce Richardson 	uint16_t to_send = buffer->length;
609799a2dd95SBruce Richardson 
609899a2dd95SBruce Richardson 	if (to_send == 0)
609999a2dd95SBruce Richardson 		return 0;
610099a2dd95SBruce Richardson 
610199a2dd95SBruce Richardson 	sent = rte_eth_tx_burst(port_id, queue_id, buffer->pkts, to_send);
610299a2dd95SBruce Richardson 
610399a2dd95SBruce Richardson 	buffer->length = 0;
610499a2dd95SBruce Richardson 
610599a2dd95SBruce Richardson 	/* All packets sent, or to be dealt with by callback below */
610699a2dd95SBruce Richardson 	if (unlikely(sent != to_send))
610799a2dd95SBruce Richardson 		buffer->error_callback(&buffer->pkts[sent],
610899a2dd95SBruce Richardson 				       (uint16_t)(to_send - sent),
610999a2dd95SBruce Richardson 				       buffer->error_userdata);
611099a2dd95SBruce Richardson 
611199a2dd95SBruce Richardson 	return sent;
611299a2dd95SBruce Richardson }
611399a2dd95SBruce Richardson 
611499a2dd95SBruce Richardson /**
611599a2dd95SBruce Richardson  * Buffer a single packet for future transmission on a port and queue
611699a2dd95SBruce Richardson  *
611799a2dd95SBruce Richardson  * This function takes a single mbuf/packet and buffers it for later
611899a2dd95SBruce Richardson  * transmission on the particular port and queue specified. Once the buffer is
611999a2dd95SBruce Richardson  * full of packets, an attempt will be made to transmit all the buffered
612099a2dd95SBruce Richardson  * packets. In case of error, where not all packets can be transmitted, a
612199a2dd95SBruce Richardson  * callback is called with the unsent packets as a parameter. If no callback
612299a2dd95SBruce Richardson  * is explicitly set up, the unsent packets are just freed back to the owning
612399a2dd95SBruce Richardson  * mempool. The function returns the number of packets actually sent i.e.
612499a2dd95SBruce Richardson  * 0 if no buffer flush occurred, otherwise the number of packets successfully
612599a2dd95SBruce Richardson  * flushed
612699a2dd95SBruce Richardson  *
612799a2dd95SBruce Richardson  * @param port_id
612899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
612999a2dd95SBruce Richardson  * @param queue_id
613099a2dd95SBruce Richardson  *   The index of the transmit queue through which output packets must be
613199a2dd95SBruce Richardson  *   sent.
613299a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
613399a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
613499a2dd95SBruce Richardson  * @param buffer
613599a2dd95SBruce Richardson  *   Buffer used to collect packets to be sent.
613699a2dd95SBruce Richardson  * @param tx_pkt
613799a2dd95SBruce Richardson  *   Pointer to the packet mbuf to be sent.
613899a2dd95SBruce Richardson  * @return
613999a2dd95SBruce Richardson  *   0 = packet has been buffered for later transmission
614099a2dd95SBruce Richardson  *   N > 0 = packet has been buffered, and the buffer was subsequently flushed,
614199a2dd95SBruce Richardson  *     causing N packets to be sent, and the error callback to be called for
614299a2dd95SBruce Richardson  *     the rest.
614399a2dd95SBruce Richardson  */
614499a2dd95SBruce Richardson static __rte_always_inline uint16_t
rte_eth_tx_buffer(uint16_t port_id,uint16_t queue_id,struct rte_eth_dev_tx_buffer * buffer,struct rte_mbuf * tx_pkt)614599a2dd95SBruce Richardson rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id,
614699a2dd95SBruce Richardson 		struct rte_eth_dev_tx_buffer *buffer, struct rte_mbuf *tx_pkt)
614799a2dd95SBruce Richardson {
614899a2dd95SBruce Richardson 	buffer->pkts[buffer->length++] = tx_pkt;
614999a2dd95SBruce Richardson 	if (buffer->length < buffer->size)
615099a2dd95SBruce Richardson 		return 0;
615199a2dd95SBruce Richardson 
615299a2dd95SBruce Richardson 	return rte_eth_tx_buffer_flush(port_id, queue_id, buffer);
615399a2dd95SBruce Richardson }
615499a2dd95SBruce Richardson 
615599a2dd95SBruce Richardson #ifdef __cplusplus
615699a2dd95SBruce Richardson }
615799a2dd95SBruce Richardson #endif
615899a2dd95SBruce Richardson 
615999a2dd95SBruce Richardson #endif /* _RTE_ETHDEV_H_ */
6160