xref: /dpdk/lib/ethdev/rte_ethdev.h (revision 1ff8b9a6ef248dddebd07a8df7b47f4de9ffab62)
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
77b77d3318SDmitry Kozlyuk  * device or the queue 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 #include <stdint.h>
14999a2dd95SBruce Richardson 
15099a2dd95SBruce Richardson /* Use this macro to check if LRO API is supported */
15199a2dd95SBruce Richardson #define RTE_ETHDEV_HAS_LRO_SUPPORT
15299a2dd95SBruce Richardson 
15399a2dd95SBruce Richardson /* Alias RTE_LIBRTE_ETHDEV_DEBUG for backward compatibility. */
15499a2dd95SBruce Richardson #ifdef RTE_LIBRTE_ETHDEV_DEBUG
15599a2dd95SBruce Richardson #define RTE_ETHDEV_DEBUG_RX
15699a2dd95SBruce Richardson #define RTE_ETHDEV_DEBUG_TX
15799a2dd95SBruce Richardson #endif
15899a2dd95SBruce Richardson 
1596b81dddbSJerin Jacob #include <rte_cman.h>
16099a2dd95SBruce Richardson #include <rte_compat.h>
16199a2dd95SBruce Richardson #include <rte_log.h>
16299a2dd95SBruce Richardson #include <rte_interrupts.h>
16399a2dd95SBruce Richardson #include <rte_dev.h>
16499a2dd95SBruce Richardson #include <rte_devargs.h>
165e1823e08SThomas Monjalon #include <rte_bitops.h>
16699a2dd95SBruce Richardson #include <rte_errno.h>
16799a2dd95SBruce Richardson #include <rte_common.h>
16899a2dd95SBruce Richardson #include <rte_config.h>
16999a2dd95SBruce Richardson #include <rte_power_intrinsics.h>
17099a2dd95SBruce Richardson 
17199a2dd95SBruce Richardson #include "rte_ethdev_trace_fp.h"
17299a2dd95SBruce Richardson #include "rte_dev_info.h"
17399a2dd95SBruce Richardson 
17420387ebcSDavid Marchand #ifdef __cplusplus
17520387ebcSDavid Marchand extern "C" {
17620387ebcSDavid Marchand #endif
17720387ebcSDavid Marchand 
17899a2dd95SBruce Richardson extern int rte_eth_dev_logtype;
1790e21c7c0SDavid Marchand #define RTE_LOGTYPE_ETHDEV rte_eth_dev_logtype
18099a2dd95SBruce Richardson 
1810e21c7c0SDavid Marchand #define RTE_ETHDEV_LOG_LINE(level, ...) \
18297433132SDavid Marchand 	RTE_LOG_LINE(level, ETHDEV, "" __VA_ARGS__)
18399a2dd95SBruce Richardson 
18499a2dd95SBruce Richardson struct rte_mbuf;
18599a2dd95SBruce Richardson 
18699a2dd95SBruce Richardson /**
18799a2dd95SBruce Richardson  * Initializes a device iterator.
18899a2dd95SBruce Richardson  *
18999a2dd95SBruce Richardson  * This iterator allows accessing a list of devices matching some devargs.
19099a2dd95SBruce Richardson  *
19199a2dd95SBruce Richardson  * @param iter
19299a2dd95SBruce Richardson  *   Device iterator handle initialized by the function.
19399a2dd95SBruce Richardson  *   The fields bus_str and cls_str might be dynamically allocated,
19499a2dd95SBruce Richardson  *   and could be freed by calling rte_eth_iterator_cleanup().
19599a2dd95SBruce Richardson  *
19699a2dd95SBruce Richardson  * @param devargs
19799a2dd95SBruce Richardson  *   Device description string.
19899a2dd95SBruce Richardson  *
19999a2dd95SBruce Richardson  * @return
20099a2dd95SBruce Richardson  *   0 on successful initialization, negative otherwise.
20199a2dd95SBruce Richardson  */
20299a2dd95SBruce Richardson int rte_eth_iterator_init(struct rte_dev_iterator *iter, const char *devargs);
20399a2dd95SBruce Richardson 
20499a2dd95SBruce Richardson /**
20599a2dd95SBruce Richardson  * Iterates on devices with devargs filter.
20699a2dd95SBruce Richardson  * The ownership is not checked.
20799a2dd95SBruce Richardson  *
2085906be5aSAndrew Rybchenko  * The next port ID is returned, and the iterator is updated.
20999a2dd95SBruce Richardson  *
21099a2dd95SBruce Richardson  * @param iter
21199a2dd95SBruce Richardson  *   Device iterator handle initialized by rte_eth_iterator_init().
21299a2dd95SBruce Richardson  *   Some fields bus_str and cls_str might be freed when no more port is found,
21399a2dd95SBruce Richardson  *   by calling rte_eth_iterator_cleanup().
21499a2dd95SBruce Richardson  *
21599a2dd95SBruce Richardson  * @return
2165906be5aSAndrew Rybchenko  *   A port ID if found, RTE_MAX_ETHPORTS otherwise.
21799a2dd95SBruce Richardson  */
21899a2dd95SBruce Richardson uint16_t rte_eth_iterator_next(struct rte_dev_iterator *iter);
21999a2dd95SBruce Richardson 
22099a2dd95SBruce Richardson /**
22199a2dd95SBruce Richardson  * Free some allocated fields of the iterator.
22299a2dd95SBruce Richardson  *
22399a2dd95SBruce Richardson  * This function is automatically called by rte_eth_iterator_next()
22499a2dd95SBruce Richardson  * on the last iteration (i.e. when no more matching port is found).
22599a2dd95SBruce Richardson  *
22699a2dd95SBruce Richardson  * It is safe to call this function twice; it will do nothing more.
22799a2dd95SBruce Richardson  *
22899a2dd95SBruce Richardson  * @param iter
22999a2dd95SBruce Richardson  *   Device iterator handle initialized by rte_eth_iterator_init().
23099a2dd95SBruce Richardson  *   The fields bus_str and cls_str are freed if needed.
23199a2dd95SBruce Richardson  */
23299a2dd95SBruce Richardson void rte_eth_iterator_cleanup(struct rte_dev_iterator *iter);
23399a2dd95SBruce Richardson 
23499a2dd95SBruce Richardson /**
23599a2dd95SBruce Richardson  * Macro to iterate over all ethdev ports matching some devargs.
23699a2dd95SBruce Richardson  *
23799a2dd95SBruce Richardson  * If a break is done before the end of the loop,
23899a2dd95SBruce Richardson  * the function rte_eth_iterator_cleanup() must be called.
23999a2dd95SBruce Richardson  *
24099a2dd95SBruce Richardson  * @param id
2415906be5aSAndrew Rybchenko  *   Iterated port ID of type uint16_t.
24299a2dd95SBruce Richardson  * @param devargs
24399a2dd95SBruce Richardson  *   Device parameters input as string of type char*.
24499a2dd95SBruce Richardson  * @param iter
24599a2dd95SBruce Richardson  *   Iterator handle of type struct rte_dev_iterator, used internally.
24699a2dd95SBruce Richardson  */
24799a2dd95SBruce Richardson #define RTE_ETH_FOREACH_MATCHING_DEV(id, devargs, iter) \
24899a2dd95SBruce Richardson 	for (rte_eth_iterator_init(iter, devargs), \
24999a2dd95SBruce Richardson 	     id = rte_eth_iterator_next(iter); \
25099a2dd95SBruce Richardson 	     id != RTE_MAX_ETHPORTS; \
25199a2dd95SBruce Richardson 	     id = rte_eth_iterator_next(iter))
25299a2dd95SBruce Richardson 
25399a2dd95SBruce Richardson /**
25499a2dd95SBruce Richardson  * A structure used to retrieve statistics for an Ethernet port.
25599a2dd95SBruce Richardson  * Not all statistics fields in struct rte_eth_stats are supported
25699a2dd95SBruce Richardson  * by any type of network interface card (NIC). If any statistics
25799a2dd95SBruce Richardson  * field is not supported, its value is 0.
25899a2dd95SBruce Richardson  * All byte-related statistics do not include Ethernet FCS regardless
25999a2dd95SBruce Richardson  * of whether these bytes have been delivered to the application
260295968d1SFerruh Yigit  * (see RTE_ETH_RX_OFFLOAD_KEEP_CRC).
26199a2dd95SBruce Richardson  */
26299a2dd95SBruce Richardson struct rte_eth_stats {
26399a2dd95SBruce Richardson 	uint64_t ipackets;  /**< Total number of successfully received packets. */
26499a2dd95SBruce Richardson 	uint64_t opackets;  /**< Total number of successfully transmitted packets.*/
26599a2dd95SBruce Richardson 	uint64_t ibytes;    /**< Total number of successfully received bytes. */
26699a2dd95SBruce Richardson 	uint64_t obytes;    /**< Total number of successfully transmitted bytes. */
2673c2ca0a9SAndrew Rybchenko 	/**
26809fd4227SAndrew Rybchenko 	 * Total of Rx packets dropped by the HW,
26909fd4227SAndrew Rybchenko 	 * because there are no available buffer (i.e. Rx queues are full).
27099a2dd95SBruce Richardson 	 */
2713c2ca0a9SAndrew Rybchenko 	uint64_t imissed;
27299a2dd95SBruce Richardson 	uint64_t ierrors;   /**< Total number of erroneous received packets. */
27399a2dd95SBruce Richardson 	uint64_t oerrors;   /**< Total number of failed transmitted packets. */
27409fd4227SAndrew Rybchenko 	uint64_t rx_nombuf; /**< Total number of Rx mbuf allocation failures. */
27599a2dd95SBruce Richardson 	/* Queue stats are limited to max 256 queues */
27609fd4227SAndrew Rybchenko 	/** Total number of queue Rx packets. */
27799a2dd95SBruce Richardson 	uint64_t q_ipackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
27809fd4227SAndrew Rybchenko 	/** Total number of queue Tx packets. */
27999a2dd95SBruce Richardson 	uint64_t q_opackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
2803c2ca0a9SAndrew Rybchenko 	/** Total number of successfully received queue bytes. */
28199a2dd95SBruce Richardson 	uint64_t q_ibytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
2823c2ca0a9SAndrew Rybchenko 	/** Total number of successfully transmitted queue bytes. */
28399a2dd95SBruce Richardson 	uint64_t q_obytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
2843c2ca0a9SAndrew Rybchenko 	/** Total number of queue packets received that are dropped. */
28599a2dd95SBruce Richardson 	uint64_t q_errors[RTE_ETHDEV_QUEUE_STAT_CNTRS];
28699a2dd95SBruce Richardson };
28799a2dd95SBruce Richardson 
2880ce56b05SThomas Monjalon /**@{@name Link speed capabilities
28999a2dd95SBruce Richardson  * Device supported speeds bitmap flags
29099a2dd95SBruce Richardson  */
291295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_AUTONEG 0             /**< Autonegotiate (all speeds) */
292295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_FIXED   RTE_BIT32(0)  /**< Disable autoneg (fixed speed) */
293295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_10M_HD  RTE_BIT32(1)  /**<  10 Mbps half-duplex */
294295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_10M     RTE_BIT32(2)  /**<  10 Mbps full-duplex */
295295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_100M_HD RTE_BIT32(3)  /**< 100 Mbps half-duplex */
296295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_100M    RTE_BIT32(4)  /**< 100 Mbps full-duplex */
297295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_1G      RTE_BIT32(5)  /**<   1 Gbps */
298295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_2_5G    RTE_BIT32(6)  /**< 2.5 Gbps */
299295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_5G      RTE_BIT32(7)  /**<   5 Gbps */
300295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_10G     RTE_BIT32(8)  /**<  10 Gbps */
301295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_20G     RTE_BIT32(9)  /**<  20 Gbps */
302295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_25G     RTE_BIT32(10) /**<  25 Gbps */
303295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_40G     RTE_BIT32(11) /**<  40 Gbps */
304295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_50G     RTE_BIT32(12) /**<  50 Gbps */
305295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_56G     RTE_BIT32(13) /**<  56 Gbps */
306295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_100G    RTE_BIT32(14) /**< 100 Gbps */
307295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_200G    RTE_BIT32(15) /**< 200 Gbps */
308a131d9ecSThomas Monjalon #define RTE_ETH_LINK_SPEED_400G    RTE_BIT32(16) /**< 400 Gbps */
3090ce56b05SThomas Monjalon /**@}*/
31099a2dd95SBruce Richardson 
3110ce56b05SThomas Monjalon /**@{@name Link speed
31299a2dd95SBruce Richardson  * Ethernet numeric link speeds in Mbps
31399a2dd95SBruce Richardson  */
314295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_NONE         0 /**< Not defined */
315295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_10M         10 /**<  10 Mbps */
316295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_100M       100 /**< 100 Mbps */
317295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_1G        1000 /**<   1 Gbps */
318295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_2_5G      2500 /**< 2.5 Gbps */
319295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_5G        5000 /**<   5 Gbps */
320295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_10G      10000 /**<  10 Gbps */
321295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_20G      20000 /**<  20 Gbps */
322295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_25G      25000 /**<  25 Gbps */
323295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_40G      40000 /**<  40 Gbps */
324295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_50G      50000 /**<  50 Gbps */
325295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_56G      56000 /**<  56 Gbps */
326295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_100G    100000 /**< 100 Gbps */
327295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_200G    200000 /**< 200 Gbps */
328a131d9ecSThomas Monjalon #define RTE_ETH_SPEED_NUM_400G    400000 /**< 400 Gbps */
329295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_UNKNOWN UINT32_MAX /**< Unknown */
3300ce56b05SThomas Monjalon /**@}*/
33199a2dd95SBruce Richardson 
33299a2dd95SBruce Richardson /**
33399a2dd95SBruce Richardson  * A structure used to retrieve link-level information of an Ethernet port.
33499a2dd95SBruce Richardson  */
335b9a87346SChengwen Feng struct rte_eth_link {
336b9a87346SChengwen Feng 	union {
337b9a87346SChengwen Feng 		RTE_ATOMIC(uint64_t) val64; /**< used for atomic64 read/write */
33899a2dd95SBruce Richardson 		__extension__
339b9a87346SChengwen Feng 		struct {
340295968d1SFerruh Yigit 			uint32_t link_speed;	    /**< RTE_ETH_SPEED_NUM_ */
341295968d1SFerruh Yigit 			uint16_t link_duplex  : 1;  /**< RTE_ETH_LINK_[HALF/FULL]_DUPLEX */
342295968d1SFerruh Yigit 			uint16_t link_autoneg : 1;  /**< RTE_ETH_LINK_[AUTONEG/FIXED] */
343295968d1SFerruh Yigit 			uint16_t link_status  : 1;  /**< RTE_ETH_LINK_[DOWN/UP] */
344c6552d9aSTyler Retzlaff 		};
345b9a87346SChengwen Feng 	};
346b9a87346SChengwen Feng };
34799a2dd95SBruce Richardson 
3480ce56b05SThomas Monjalon /**@{@name Link negotiation
3490ce56b05SThomas Monjalon  * Constants used in link management.
3500ce56b05SThomas Monjalon  */
351295968d1SFerruh Yigit #define RTE_ETH_LINK_HALF_DUPLEX 0 /**< Half-duplex connection (see link_duplex). */
352295968d1SFerruh Yigit #define RTE_ETH_LINK_FULL_DUPLEX 1 /**< Full-duplex connection (see link_duplex). */
353295968d1SFerruh Yigit #define RTE_ETH_LINK_DOWN        0 /**< Link is down (see link_status). */
354295968d1SFerruh Yigit #define RTE_ETH_LINK_UP          1 /**< Link is up (see link_status). */
355295968d1SFerruh Yigit #define RTE_ETH_LINK_FIXED       0 /**< No autonegotiation (see link_autoneg). */
356295968d1SFerruh Yigit #define RTE_ETH_LINK_AUTONEG     1 /**< Autonegotiated (see link_autoneg). */
35799a2dd95SBruce Richardson #define RTE_ETH_LINK_MAX_STR_LEN 40 /**< Max length of default link string. */
3580ce56b05SThomas Monjalon /**@}*/
35999a2dd95SBruce Richardson 
36060bac722SDamodharam Ammepalli /** Translate from link speed lanes to speed lanes capabilities. */
36160bac722SDamodharam Ammepalli #define RTE_ETH_SPEED_LANES_TO_CAPA(x) RTE_BIT32(x)
36260bac722SDamodharam Ammepalli 
36360bac722SDamodharam Ammepalli /** A structure used to get and set lanes capabilities per link speed. */
36460bac722SDamodharam Ammepalli struct rte_eth_speed_lanes_capa {
36560bac722SDamodharam Ammepalli 	uint32_t speed;
36660bac722SDamodharam Ammepalli 	uint32_t capa;
36760bac722SDamodharam Ammepalli };
36860bac722SDamodharam Ammepalli 
36999a2dd95SBruce Richardson /**
37009fd4227SAndrew Rybchenko  * A structure used to configure the ring threshold registers of an Rx/Tx
37199a2dd95SBruce Richardson  * queue for an Ethernet port.
37299a2dd95SBruce Richardson  */
37399a2dd95SBruce Richardson struct rte_eth_thresh {
37499a2dd95SBruce Richardson 	uint8_t pthresh; /**< Ring prefetch threshold. */
37599a2dd95SBruce Richardson 	uint8_t hthresh; /**< Ring host threshold. */
37699a2dd95SBruce Richardson 	uint8_t wthresh; /**< Ring writeback threshold. */
37799a2dd95SBruce Richardson };
37899a2dd95SBruce Richardson 
3790ce56b05SThomas Monjalon /**@{@name Multi-queue mode
3800ce56b05SThomas Monjalon  * @see rte_eth_conf.rxmode.mq_mode.
38199a2dd95SBruce Richardson  */
3824852c647SAndrew Rybchenko #define RTE_ETH_MQ_RX_RSS_FLAG  RTE_BIT32(0) /**< Enable RSS. @see rte_eth_rss_conf */
3834852c647SAndrew Rybchenko #define RTE_ETH_MQ_RX_DCB_FLAG  RTE_BIT32(1) /**< Enable DCB. */
3844852c647SAndrew Rybchenko #define RTE_ETH_MQ_RX_VMDQ_FLAG RTE_BIT32(2) /**< Enable VMDq. */
3850ce56b05SThomas Monjalon /**@}*/
38699a2dd95SBruce Richardson 
38799a2dd95SBruce Richardson /**
38899a2dd95SBruce Richardson  *  A set of values to identify what method is to be used to route
38999a2dd95SBruce Richardson  *  packets to multiple queues.
39099a2dd95SBruce Richardson  */
39199a2dd95SBruce Richardson enum rte_eth_rx_mq_mode {
392064e90c4SAndrew Rybchenko 	/** None of DCB, RSS or VMDq mode */
393295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_NONE = 0,
39499a2dd95SBruce Richardson 
39509fd4227SAndrew Rybchenko 	/** For Rx side, only RSS is on */
396295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_RSS = RTE_ETH_MQ_RX_RSS_FLAG,
39709fd4227SAndrew Rybchenko 	/** For Rx side,only DCB is on. */
398295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_DCB = RTE_ETH_MQ_RX_DCB_FLAG,
39999a2dd95SBruce Richardson 	/** Both DCB and RSS enable */
400295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_DCB_RSS = RTE_ETH_MQ_RX_RSS_FLAG | RTE_ETH_MQ_RX_DCB_FLAG,
40199a2dd95SBruce Richardson 
402064e90c4SAndrew Rybchenko 	/** Only VMDq, no RSS nor DCB */
403295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_VMDQ_ONLY = RTE_ETH_MQ_RX_VMDQ_FLAG,
404064e90c4SAndrew Rybchenko 	/** RSS mode with VMDq */
405295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_VMDQ_RSS = RTE_ETH_MQ_RX_RSS_FLAG | RTE_ETH_MQ_RX_VMDQ_FLAG,
406064e90c4SAndrew Rybchenko 	/** Use VMDq+DCB to route traffic to queues */
407295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_VMDQ_DCB = RTE_ETH_MQ_RX_VMDQ_FLAG | RTE_ETH_MQ_RX_DCB_FLAG,
408064e90c4SAndrew Rybchenko 	/** Enable both VMDq and DCB in VMDq */
409295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_VMDQ_DCB_RSS = RTE_ETH_MQ_RX_RSS_FLAG | RTE_ETH_MQ_RX_DCB_FLAG |
410295968d1SFerruh Yigit 				 RTE_ETH_MQ_RX_VMDQ_FLAG,
41199a2dd95SBruce Richardson };
41299a2dd95SBruce Richardson 
41399a2dd95SBruce Richardson /**
41499a2dd95SBruce Richardson  * A set of values to identify what method is to be used to transmit
41599a2dd95SBruce Richardson  * packets using multi-TCs.
41699a2dd95SBruce Richardson  */
41799a2dd95SBruce Richardson enum rte_eth_tx_mq_mode {
418295968d1SFerruh Yigit 	RTE_ETH_MQ_TX_NONE    = 0,  /**< It is in neither DCB nor VT mode. */
419295968d1SFerruh Yigit 	RTE_ETH_MQ_TX_DCB,          /**< For Tx side,only DCB is on. */
420295968d1SFerruh Yigit 	RTE_ETH_MQ_TX_VMDQ_DCB,     /**< For Tx side,both DCB and VT is on. */
421295968d1SFerruh Yigit 	RTE_ETH_MQ_TX_VMDQ_ONLY,    /**< Only VT on, no DCB */
42299a2dd95SBruce Richardson };
423b1cb3035SFerruh Yigit 
42499a2dd95SBruce Richardson /**
42509fd4227SAndrew Rybchenko  * A structure used to configure the Rx features of an Ethernet port.
42699a2dd95SBruce Richardson  */
42799a2dd95SBruce Richardson struct rte_eth_rxmode {
42899a2dd95SBruce Richardson 	/** The multi-queue packet distribution mode to be used, e.g. RSS. */
42999a2dd95SBruce Richardson 	enum rte_eth_rx_mq_mode mq_mode;
4301bb4a528SFerruh Yigit 	uint32_t mtu;  /**< Requested MTU. */
43199a2dd95SBruce Richardson 	/** Maximum allowed size of LRO aggregated packet. */
43299a2dd95SBruce Richardson 	uint32_t max_lro_pkt_size;
43399a2dd95SBruce Richardson 	/**
434295968d1SFerruh Yigit 	 * Per-port Rx offloads to be set using RTE_ETH_RX_OFFLOAD_* flags.
43599a2dd95SBruce Richardson 	 * Only offloads set on rx_offload_capa field on rte_eth_dev_info
43699a2dd95SBruce Richardson 	 * structure are allowed to be set.
43799a2dd95SBruce Richardson 	 */
43899a2dd95SBruce Richardson 	uint64_t offloads;
43999a2dd95SBruce Richardson 
44099a2dd95SBruce Richardson 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
44199a2dd95SBruce Richardson 	void *reserved_ptrs[2];   /**< Reserved for future fields */
44299a2dd95SBruce Richardson };
44399a2dd95SBruce Richardson 
44499a2dd95SBruce Richardson /**
44599a2dd95SBruce Richardson  * VLAN types to indicate if it is for single VLAN, inner VLAN or outer VLAN.
44699a2dd95SBruce Richardson  * Note that single VLAN is treated the same as inner VLAN.
44799a2dd95SBruce Richardson  */
44899a2dd95SBruce Richardson enum rte_vlan_type {
449295968d1SFerruh Yigit 	RTE_ETH_VLAN_TYPE_UNKNOWN = 0,
450295968d1SFerruh Yigit 	RTE_ETH_VLAN_TYPE_INNER, /**< Inner VLAN. */
451295968d1SFerruh Yigit 	RTE_ETH_VLAN_TYPE_OUTER, /**< Single VLAN, or outer VLAN. */
452295968d1SFerruh Yigit 	RTE_ETH_VLAN_TYPE_MAX,
45399a2dd95SBruce Richardson };
45499a2dd95SBruce Richardson 
45599a2dd95SBruce Richardson /**
4565b49ba65SAndrew Rybchenko  * A structure used to describe a VLAN filter.
45799a2dd95SBruce Richardson  * If the bit corresponding to a VID is set, such VID is on.
45899a2dd95SBruce Richardson  */
45999a2dd95SBruce Richardson struct rte_vlan_filter_conf {
46099a2dd95SBruce Richardson 	uint64_t ids[64];
46199a2dd95SBruce Richardson };
46299a2dd95SBruce Richardson 
46399a2dd95SBruce Richardson /**
46434ff088cSJie Hai  * Hash function types.
46534ff088cSJie Hai  */
46634ff088cSJie Hai enum rte_eth_hash_function {
46734ff088cSJie Hai 	/** DEFAULT means driver decides which hash algorithm to pick. */
46834ff088cSJie Hai 	RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
46934ff088cSJie Hai 	RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
47034ff088cSJie Hai 	RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
47134ff088cSJie Hai 	/**
47234ff088cSJie Hai 	 * Symmetric Toeplitz: src, dst will be replaced by
47334ff088cSJie Hai 	 * xor(src, dst). For the case with src/dst only,
47434ff088cSJie Hai 	 * src or dst address will xor with zero pair.
47534ff088cSJie Hai 	 */
47634ff088cSJie Hai 	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
47734ff088cSJie Hai 	/**
47834ff088cSJie Hai 	 * Symmetric Toeplitz: L3 and L4 fields are sorted prior to
47934ff088cSJie Hai 	 * the hash function.
48034ff088cSJie Hai 	 *  If src_ip > dst_ip, swap src_ip and dst_ip.
48134ff088cSJie Hai 	 *  If src_port > dst_port, swap src_port and dst_port.
48234ff088cSJie Hai 	 */
48334ff088cSJie Hai 	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT,
48434ff088cSJie Hai 	RTE_ETH_HASH_FUNCTION_MAX,
48534ff088cSJie Hai };
48634ff088cSJie Hai 
48734ff088cSJie Hai #define RTE_ETH_HASH_ALGO_TO_CAPA(x) RTE_BIT32(x)
48834ff088cSJie Hai #define RTE_ETH_HASH_ALGO_CAPA_MASK(x) RTE_BIT32(RTE_ETH_HASH_FUNCTION_ ## x)
48934ff088cSJie Hai 
49034ff088cSJie Hai /**
49199a2dd95SBruce Richardson  * A structure used to configure the Receive Side Scaling (RSS) feature
49299a2dd95SBruce Richardson  * of an Ethernet port.
49399a2dd95SBruce Richardson  */
49499a2dd95SBruce Richardson struct rte_eth_rss_conf {
495bae3cfa5SJie Hai 	/**
496bae3cfa5SJie Hai 	 * In rte_eth_dev_rss_hash_conf_get(), the *rss_key_len* should be
497bae3cfa5SJie Hai 	 * greater than or equal to the *hash_key_size* which get from
498bae3cfa5SJie Hai 	 * rte_eth_dev_info_get() API. And the *rss_key* should contain at least
499bae3cfa5SJie Hai 	 * *hash_key_size* bytes. If not meet these requirements, the query
500bae3cfa5SJie Hai 	 * result is unreliable even if the operation returns success.
501bae3cfa5SJie Hai 	 *
502bae3cfa5SJie Hai 	 * In rte_eth_dev_rss_hash_update() or rte_eth_dev_configure(), if
503bae3cfa5SJie Hai 	 * *rss_key* is not NULL, the *rss_key_len* indicates the length of the
504bae3cfa5SJie Hai 	 * *rss_key* in bytes and it should be equal to *hash_key_size*.
505bae3cfa5SJie Hai 	 * If *rss_key* is NULL, drivers are free to use a random or a default key.
506bae3cfa5SJie Hai 	 */
507bae3cfa5SJie Hai 	uint8_t *rss_key;
50899a2dd95SBruce Richardson 	uint8_t rss_key_len; /**< hash key length in bytes. */
509bae3cfa5SJie Hai 	/**
510bae3cfa5SJie Hai 	 * Indicates the type of packets or the specific part of packets to
511bae3cfa5SJie Hai 	 * which RSS hashing is to be applied.
512bae3cfa5SJie Hai 	 */
513bae3cfa5SJie Hai 	uint64_t rss_hf;
51434ff088cSJie Hai 	enum rte_eth_hash_function algorithm;	/**< Hash algorithm. */
51599a2dd95SBruce Richardson };
51699a2dd95SBruce Richardson 
51799a2dd95SBruce Richardson /*
51899a2dd95SBruce Richardson  * A packet can be identified by hardware as different flow types. Different
51999a2dd95SBruce Richardson  * NIC hardware may support different flow types.
52099a2dd95SBruce Richardson  * Basically, the NIC hardware identifies the flow type as deep protocol as
52199a2dd95SBruce Richardson  * possible, and exclusively. For example, if a packet is identified as
52299a2dd95SBruce Richardson  * 'RTE_ETH_FLOW_NONFRAG_IPV4_TCP', it will not be any of other flow types,
52399a2dd95SBruce Richardson  * though it is an actual IPV4 packet.
52499a2dd95SBruce Richardson  */
52599a2dd95SBruce Richardson #define RTE_ETH_FLOW_UNKNOWN             0
52699a2dd95SBruce Richardson #define RTE_ETH_FLOW_RAW                 1
52799a2dd95SBruce Richardson #define RTE_ETH_FLOW_IPV4                2
52899a2dd95SBruce Richardson #define RTE_ETH_FLOW_FRAG_IPV4           3
52999a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV4_TCP    4
53099a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV4_UDP    5
53199a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV4_SCTP   6
53299a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV4_OTHER  7
53399a2dd95SBruce Richardson #define RTE_ETH_FLOW_IPV6                8
53499a2dd95SBruce Richardson #define RTE_ETH_FLOW_FRAG_IPV6           9
53599a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV6_TCP   10
53699a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV6_UDP   11
53799a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV6_SCTP  12
53899a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV6_OTHER 13
53999a2dd95SBruce Richardson #define RTE_ETH_FLOW_L2_PAYLOAD         14
54099a2dd95SBruce Richardson #define RTE_ETH_FLOW_IPV6_EX            15
54199a2dd95SBruce Richardson #define RTE_ETH_FLOW_IPV6_TCP_EX        16
54299a2dd95SBruce Richardson #define RTE_ETH_FLOW_IPV6_UDP_EX        17
5433c2ca0a9SAndrew Rybchenko /** Consider device port number as a flow differentiator */
54499a2dd95SBruce Richardson #define RTE_ETH_FLOW_PORT               18
54599a2dd95SBruce Richardson #define RTE_ETH_FLOW_VXLAN              19 /**< VXLAN protocol based flow */
54699a2dd95SBruce Richardson #define RTE_ETH_FLOW_GENEVE             20 /**< GENEVE protocol based flow */
54799a2dd95SBruce Richardson #define RTE_ETH_FLOW_NVGRE              21 /**< NVGRE protocol based flow */
54899a2dd95SBruce Richardson #define RTE_ETH_FLOW_VXLAN_GPE          22 /**< VXLAN-GPE protocol based flow */
54999a2dd95SBruce Richardson #define RTE_ETH_FLOW_GTPU               23 /**< GTPU protocol based flow */
55099a2dd95SBruce Richardson #define RTE_ETH_FLOW_MAX                24
55199a2dd95SBruce Richardson 
55299a2dd95SBruce Richardson /*
55399a2dd95SBruce Richardson  * Below macros are defined for RSS offload types, they can be used to
55499a2dd95SBruce Richardson  * fill rte_eth_rss_conf.rss_hf or rte_flow_action_rss.types.
55599a2dd95SBruce Richardson  */
556295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV4               RTE_BIT64(2)
557295968d1SFerruh Yigit #define RTE_ETH_RSS_FRAG_IPV4          RTE_BIT64(3)
558295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV4_TCP   RTE_BIT64(4)
559295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV4_UDP   RTE_BIT64(5)
560295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV4_SCTP  RTE_BIT64(6)
561295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV4_OTHER RTE_BIT64(7)
562295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6               RTE_BIT64(8)
563295968d1SFerruh Yigit #define RTE_ETH_RSS_FRAG_IPV6          RTE_BIT64(9)
564295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV6_TCP   RTE_BIT64(10)
565295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV6_UDP   RTE_BIT64(11)
566295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV6_SCTP  RTE_BIT64(12)
567295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV6_OTHER RTE_BIT64(13)
568295968d1SFerruh Yigit #define RTE_ETH_RSS_L2_PAYLOAD         RTE_BIT64(14)
569295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_EX            RTE_BIT64(15)
570295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_TCP_EX        RTE_BIT64(16)
571295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_UDP_EX        RTE_BIT64(17)
572295968d1SFerruh Yigit #define RTE_ETH_RSS_PORT               RTE_BIT64(18)
573295968d1SFerruh Yigit #define RTE_ETH_RSS_VXLAN              RTE_BIT64(19)
574295968d1SFerruh Yigit #define RTE_ETH_RSS_GENEVE             RTE_BIT64(20)
575295968d1SFerruh Yigit #define RTE_ETH_RSS_NVGRE              RTE_BIT64(21)
576295968d1SFerruh Yigit #define RTE_ETH_RSS_GTPU               RTE_BIT64(23)
577295968d1SFerruh Yigit #define RTE_ETH_RSS_ETH                RTE_BIT64(24)
578295968d1SFerruh Yigit #define RTE_ETH_RSS_S_VLAN             RTE_BIT64(25)
579295968d1SFerruh Yigit #define RTE_ETH_RSS_C_VLAN             RTE_BIT64(26)
580295968d1SFerruh Yigit #define RTE_ETH_RSS_ESP                RTE_BIT64(27)
581295968d1SFerruh Yigit #define RTE_ETH_RSS_AH                 RTE_BIT64(28)
582295968d1SFerruh Yigit #define RTE_ETH_RSS_L2TPV3             RTE_BIT64(29)
583295968d1SFerruh Yigit #define RTE_ETH_RSS_PFCP               RTE_BIT64(30)
584295968d1SFerruh Yigit #define RTE_ETH_RSS_PPPOE              RTE_BIT64(31)
585295968d1SFerruh Yigit #define RTE_ETH_RSS_ECPRI              RTE_BIT64(32)
586295968d1SFerruh Yigit #define RTE_ETH_RSS_MPLS               RTE_BIT64(33)
587295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV4_CHKSUM        RTE_BIT64(34)
588b1cb3035SFerruh Yigit 
58981b0fbb8SAlvin Zhang /**
590683f93efSAndrew Rybchenko  * The RTE_ETH_RSS_L4_CHKSUM works on checksum field of any L4 header.
591683f93efSAndrew Rybchenko  * It is similar to RTE_ETH_RSS_PORT that they don't specify the specific type of
59281b0fbb8SAlvin Zhang  * L4 header. This macro is defined to replace some specific L4 (TCP/UDP/SCTP)
59381b0fbb8SAlvin Zhang  * checksum type for constructing the use of RSS offload bits.
59481b0fbb8SAlvin Zhang  *
59581b0fbb8SAlvin Zhang  * Due to above reason, some old APIs (and configuration) don't support
596295968d1SFerruh Yigit  * RTE_ETH_RSS_L4_CHKSUM. The rte_flow RSS API supports it.
59781b0fbb8SAlvin Zhang  *
59881b0fbb8SAlvin Zhang  * For the case that checksum is not used in an UDP header,
59981b0fbb8SAlvin Zhang  * it takes the reserved value 0 as input for the hash function.
60081b0fbb8SAlvin Zhang  */
601295968d1SFerruh Yigit #define RTE_ETH_RSS_L4_CHKSUM          RTE_BIT64(35)
60299a2dd95SBruce Richardson 
603f840cf77SJie Wang #define RTE_ETH_RSS_L2TPV2             RTE_BIT64(36)
60442392190SAjit Khaparde #define RTE_ETH_RSS_IPV6_FLOW_LABEL    RTE_BIT64(37)
605f840cf77SJie Wang 
60699a2dd95SBruce Richardson /*
607295968d1SFerruh Yigit  * We use the following macros to combine with above RTE_ETH_RSS_* for
60899a2dd95SBruce Richardson  * more specific input set selection. These bits are defined starting
60999a2dd95SBruce Richardson  * from the high end of the 64 bits.
610295968d1SFerruh Yigit  * Note: If we use above RTE_ETH_RSS_* without SRC/DST_ONLY, it represents
61199a2dd95SBruce Richardson  * both SRC and DST are taken into account. If SRC_ONLY and DST_ONLY of
61299a2dd95SBruce Richardson  * the same level are used simultaneously, it is the same case as none of
61399a2dd95SBruce Richardson  * them are added.
61499a2dd95SBruce Richardson  */
615295968d1SFerruh Yigit #define RTE_ETH_RSS_L3_SRC_ONLY        RTE_BIT64(63)
616295968d1SFerruh Yigit #define RTE_ETH_RSS_L3_DST_ONLY        RTE_BIT64(62)
617295968d1SFerruh Yigit #define RTE_ETH_RSS_L4_SRC_ONLY        RTE_BIT64(61)
618295968d1SFerruh Yigit #define RTE_ETH_RSS_L4_DST_ONLY        RTE_BIT64(60)
619295968d1SFerruh Yigit #define RTE_ETH_RSS_L2_SRC_ONLY        RTE_BIT64(59)
620295968d1SFerruh Yigit #define RTE_ETH_RSS_L2_DST_ONLY        RTE_BIT64(58)
621b1cb3035SFerruh Yigit 
62299a2dd95SBruce Richardson /*
62399a2dd95SBruce Richardson  * Only select IPV6 address prefix as RSS input set according to
624b1cb3035SFerruh Yigit  * https://tools.ietf.org/html/rfc6052
625295968d1SFerruh Yigit  * Must be combined with RTE_ETH_RSS_IPV6, RTE_ETH_RSS_NONFRAG_IPV6_UDP,
626295968d1SFerruh Yigit  * RTE_ETH_RSS_NONFRAG_IPV6_TCP, RTE_ETH_RSS_NONFRAG_IPV6_SCTP.
62799a2dd95SBruce Richardson  */
628e1823e08SThomas Monjalon #define RTE_ETH_RSS_L3_PRE32           RTE_BIT64(57)
629e1823e08SThomas Monjalon #define RTE_ETH_RSS_L3_PRE40           RTE_BIT64(56)
630e1823e08SThomas Monjalon #define RTE_ETH_RSS_L3_PRE48           RTE_BIT64(55)
631e1823e08SThomas Monjalon #define RTE_ETH_RSS_L3_PRE56           RTE_BIT64(54)
632e1823e08SThomas Monjalon #define RTE_ETH_RSS_L3_PRE64           RTE_BIT64(53)
633e1823e08SThomas Monjalon #define RTE_ETH_RSS_L3_PRE96           RTE_BIT64(52)
63499a2dd95SBruce Richardson 
63599a2dd95SBruce Richardson /*
63699a2dd95SBruce Richardson  * Use the following macros to combine with the above layers
63799a2dd95SBruce Richardson  * to choose inner and outer layers or both for RSS computation.
63899a2dd95SBruce Richardson  * Bits 50 and 51 are reserved for this.
63999a2dd95SBruce Richardson  */
64099a2dd95SBruce Richardson 
64199a2dd95SBruce Richardson /**
64299a2dd95SBruce Richardson  * level 0, requests the default behavior.
64399a2dd95SBruce Richardson  * Depending on the packet type, it can mean outermost, innermost,
64499a2dd95SBruce Richardson  * anything in between or even no RSS.
64599a2dd95SBruce Richardson  * It basically stands for the innermost encapsulation level RSS
64699a2dd95SBruce Richardson  * can be performed on according to PMD and device capabilities.
64799a2dd95SBruce Richardson  */
64868e8ca7bSAndrew Rybchenko #define RTE_ETH_RSS_LEVEL_PMD_DEFAULT  (UINT64_C(0) << 50)
64999a2dd95SBruce Richardson 
65099a2dd95SBruce Richardson /**
65199a2dd95SBruce Richardson  * level 1, requests RSS to be performed on the outermost packet
65299a2dd95SBruce Richardson  * encapsulation level.
65399a2dd95SBruce Richardson  */
65468e8ca7bSAndrew Rybchenko #define RTE_ETH_RSS_LEVEL_OUTERMOST    (UINT64_C(1) << 50)
65599a2dd95SBruce Richardson 
65699a2dd95SBruce Richardson /**
65799a2dd95SBruce Richardson  * level 2, requests RSS to be performed on the specified inner packet
65899a2dd95SBruce Richardson  * encapsulation level, from outermost to innermost (lower to higher values).
65999a2dd95SBruce Richardson  */
66068e8ca7bSAndrew Rybchenko #define RTE_ETH_RSS_LEVEL_INNERMOST    (UINT64_C(2) << 50)
66168e8ca7bSAndrew Rybchenko #define RTE_ETH_RSS_LEVEL_MASK         (UINT64_C(3) << 50)
662b1cb3035SFerruh Yigit 
663295968d1SFerruh Yigit #define RTE_ETH_RSS_LEVEL(rss_hf) ((rss_hf & RTE_ETH_RSS_LEVEL_MASK) >> 50)
66499a2dd95SBruce Richardson 
66599a2dd95SBruce Richardson /**
66699a2dd95SBruce Richardson  * For input set change of hash filter, if SRC_ONLY and DST_ONLY of
66799a2dd95SBruce Richardson  * the same level are used simultaneously, it is the same case as
66899a2dd95SBruce Richardson  * none of them are added.
66999a2dd95SBruce Richardson  *
67099a2dd95SBruce Richardson  * @param rss_hf
67199a2dd95SBruce Richardson  *   RSS types with SRC/DST_ONLY.
67299a2dd95SBruce Richardson  * @return
67399a2dd95SBruce Richardson  *   RSS types.
67499a2dd95SBruce Richardson  */
67599a2dd95SBruce Richardson static inline uint64_t
67699a2dd95SBruce Richardson rte_eth_rss_hf_refine(uint64_t rss_hf)
67799a2dd95SBruce Richardson {
678295968d1SFerruh Yigit 	if ((rss_hf & RTE_ETH_RSS_L3_SRC_ONLY) && (rss_hf & RTE_ETH_RSS_L3_DST_ONLY))
679295968d1SFerruh Yigit 		rss_hf &= ~(RTE_ETH_RSS_L3_SRC_ONLY | RTE_ETH_RSS_L3_DST_ONLY);
68099a2dd95SBruce Richardson 
681295968d1SFerruh Yigit 	if ((rss_hf & RTE_ETH_RSS_L4_SRC_ONLY) && (rss_hf & RTE_ETH_RSS_L4_DST_ONLY))
682295968d1SFerruh Yigit 		rss_hf &= ~(RTE_ETH_RSS_L4_SRC_ONLY | RTE_ETH_RSS_L4_DST_ONLY);
68399a2dd95SBruce Richardson 
68499a2dd95SBruce Richardson 	return rss_hf;
68599a2dd95SBruce Richardson }
68699a2dd95SBruce Richardson 
687295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE32 ( \
688295968d1SFerruh Yigit 		RTE_ETH_RSS_IPV6 | \
68999a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE32)
69099a2dd95SBruce Richardson 
691295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE40 ( \
692295968d1SFerruh Yigit 		RTE_ETH_RSS_IPV6 | \
69399a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE40)
69499a2dd95SBruce Richardson 
695295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE48 ( \
696295968d1SFerruh Yigit 		RTE_ETH_RSS_IPV6 | \
69799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE48)
69899a2dd95SBruce Richardson 
699295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE56 ( \
700295968d1SFerruh Yigit 		RTE_ETH_RSS_IPV6 | \
70199a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE56)
70299a2dd95SBruce Richardson 
703295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE64 ( \
704295968d1SFerruh Yigit 		RTE_ETH_RSS_IPV6 | \
70599a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE64)
70699a2dd95SBruce Richardson 
707295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE96 ( \
708295968d1SFerruh Yigit 		RTE_ETH_RSS_IPV6 | \
70999a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE96)
71099a2dd95SBruce Richardson 
711295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE32_UDP ( \
712295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
71399a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE32)
71499a2dd95SBruce Richardson 
715295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE40_UDP ( \
716295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
71799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE40)
71899a2dd95SBruce Richardson 
719295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE48_UDP ( \
720295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
72199a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE48)
72299a2dd95SBruce Richardson 
723295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE56_UDP ( \
724295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
72599a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE56)
72699a2dd95SBruce Richardson 
727295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE64_UDP ( \
728295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
72999a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE64)
73099a2dd95SBruce Richardson 
731295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE96_UDP ( \
732295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
73399a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE96)
73499a2dd95SBruce Richardson 
735295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE32_TCP ( \
736295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
73799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE32)
73899a2dd95SBruce Richardson 
739295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE40_TCP ( \
740295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
74199a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE40)
74299a2dd95SBruce Richardson 
743295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE48_TCP ( \
744295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
74599a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE48)
74699a2dd95SBruce Richardson 
747295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE56_TCP ( \
748295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
74999a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE56)
75099a2dd95SBruce Richardson 
751295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE64_TCP ( \
752295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
75399a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE64)
75499a2dd95SBruce Richardson 
755295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE96_TCP ( \
756295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
75799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE96)
75899a2dd95SBruce Richardson 
759295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE32_SCTP ( \
760295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
76199a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE32)
76299a2dd95SBruce Richardson 
763295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE40_SCTP ( \
764295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
76599a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE40)
76699a2dd95SBruce Richardson 
767295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE48_SCTP ( \
768295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
76999a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE48)
77099a2dd95SBruce Richardson 
771295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE56_SCTP ( \
772295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
77399a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE56)
77499a2dd95SBruce Richardson 
775295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE64_SCTP ( \
776295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
77799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE64)
77899a2dd95SBruce Richardson 
779295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE96_SCTP ( \
780295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
78199a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE96)
78299a2dd95SBruce Richardson 
783295968d1SFerruh Yigit #define RTE_ETH_RSS_IP ( \
784295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV4 | \
785295968d1SFerruh Yigit 	RTE_ETH_RSS_FRAG_IPV4 | \
786295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_OTHER | \
787295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6 | \
788295968d1SFerruh Yigit 	RTE_ETH_RSS_FRAG_IPV6 | \
789295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \
790295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6_EX)
79199a2dd95SBruce Richardson 
792295968d1SFerruh Yigit #define RTE_ETH_RSS_UDP ( \
793295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
794295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
795295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6_UDP_EX)
79699a2dd95SBruce Richardson 
797295968d1SFerruh Yigit #define RTE_ETH_RSS_TCP ( \
798295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
799295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
800295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6_TCP_EX)
80199a2dd95SBruce Richardson 
802295968d1SFerruh Yigit #define RTE_ETH_RSS_SCTP ( \
803295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_SCTP | \
804295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_SCTP)
80599a2dd95SBruce Richardson 
806295968d1SFerruh Yigit #define RTE_ETH_RSS_TUNNEL ( \
807295968d1SFerruh Yigit 	RTE_ETH_RSS_VXLAN  | \
808295968d1SFerruh Yigit 	RTE_ETH_RSS_GENEVE | \
809295968d1SFerruh Yigit 	RTE_ETH_RSS_NVGRE)
81099a2dd95SBruce Richardson 
811295968d1SFerruh Yigit #define RTE_ETH_RSS_VLAN ( \
812295968d1SFerruh Yigit 	RTE_ETH_RSS_S_VLAN  | \
813295968d1SFerruh Yigit 	RTE_ETH_RSS_C_VLAN)
81499a2dd95SBruce Richardson 
8153c2ca0a9SAndrew Rybchenko /** Mask of valid RSS hash protocols */
816295968d1SFerruh Yigit #define RTE_ETH_RSS_PROTO_MASK ( \
817295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV4 | \
818295968d1SFerruh Yigit 	RTE_ETH_RSS_FRAG_IPV4 | \
819295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
820295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
821295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_SCTP | \
822295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_OTHER | \
823295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6 | \
824295968d1SFerruh Yigit 	RTE_ETH_RSS_FRAG_IPV6 | \
825295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
826295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
827295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
828295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \
829295968d1SFerruh Yigit 	RTE_ETH_RSS_L2_PAYLOAD | \
830295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6_EX | \
831295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6_TCP_EX | \
832295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6_UDP_EX | \
833295968d1SFerruh Yigit 	RTE_ETH_RSS_PORT  | \
834295968d1SFerruh Yigit 	RTE_ETH_RSS_VXLAN | \
835295968d1SFerruh Yigit 	RTE_ETH_RSS_GENEVE | \
836295968d1SFerruh Yigit 	RTE_ETH_RSS_NVGRE | \
837295968d1SFerruh Yigit 	RTE_ETH_RSS_MPLS)
83899a2dd95SBruce Richardson 
83999a2dd95SBruce Richardson /*
84099a2dd95SBruce Richardson  * Definitions used for redirection table entry size.
84199a2dd95SBruce Richardson  * Some RSS RETA sizes may not be supported by some drivers, check the
84299a2dd95SBruce Richardson  * documentation or the description of relevant functions for more details.
84399a2dd95SBruce Richardson  */
844295968d1SFerruh Yigit #define RTE_ETH_RSS_RETA_SIZE_64  64
845295968d1SFerruh Yigit #define RTE_ETH_RSS_RETA_SIZE_128 128
846295968d1SFerruh Yigit #define RTE_ETH_RSS_RETA_SIZE_256 256
847295968d1SFerruh Yigit #define RTE_ETH_RSS_RETA_SIZE_512 512
848295968d1SFerruh Yigit #define RTE_ETH_RETA_GROUP_SIZE   64
849b1cb3035SFerruh Yigit 
8500ce56b05SThomas Monjalon /**@{@name VMDq and DCB maximums */
851295968d1SFerruh Yigit #define RTE_ETH_VMDQ_MAX_VLAN_FILTERS   64 /**< Maximum nb. of VMDq VLAN filters. */
852295968d1SFerruh Yigit #define RTE_ETH_DCB_NUM_USER_PRIORITIES 8  /**< Maximum nb. of DCB priorities. */
853295968d1SFerruh Yigit #define RTE_ETH_VMDQ_DCB_NUM_QUEUES     128 /**< Maximum nb. of VMDq DCB queues. */
854295968d1SFerruh Yigit #define RTE_ETH_DCB_NUM_QUEUES          128 /**< Maximum nb. of DCB queues. */
8550ce56b05SThomas Monjalon /**@}*/
85699a2dd95SBruce Richardson 
8570ce56b05SThomas Monjalon /**@{@name DCB capabilities */
8584852c647SAndrew Rybchenko #define RTE_ETH_DCB_PG_SUPPORT      RTE_BIT32(0) /**< Priority Group(ETS) support. */
8594852c647SAndrew Rybchenko #define RTE_ETH_DCB_PFC_SUPPORT     RTE_BIT32(1) /**< Priority Flow Control support. */
8600ce56b05SThomas Monjalon /**@}*/
86199a2dd95SBruce Richardson 
8620ce56b05SThomas Monjalon /**@{@name VLAN offload bits */
863295968d1SFerruh Yigit #define RTE_ETH_VLAN_STRIP_OFFLOAD   0x0001 /**< VLAN Strip  On/Off */
864295968d1SFerruh Yigit #define RTE_ETH_VLAN_FILTER_OFFLOAD  0x0002 /**< VLAN Filter On/Off */
865295968d1SFerruh Yigit #define RTE_ETH_VLAN_EXTEND_OFFLOAD  0x0004 /**< VLAN Extend On/Off */
866295968d1SFerruh Yigit #define RTE_ETH_QINQ_STRIP_OFFLOAD   0x0008 /**< QINQ Strip On/Off */
867b1cb3035SFerruh Yigit 
868295968d1SFerruh Yigit #define RTE_ETH_VLAN_STRIP_MASK      0x0001 /**< VLAN Strip  setting mask */
869295968d1SFerruh Yigit #define RTE_ETH_VLAN_FILTER_MASK     0x0002 /**< VLAN Filter  setting mask*/
870295968d1SFerruh Yigit #define RTE_ETH_VLAN_EXTEND_MASK     0x0004 /**< VLAN Extend  setting mask*/
871295968d1SFerruh Yigit #define RTE_ETH_QINQ_STRIP_MASK      0x0008 /**< QINQ Strip  setting mask */
872295968d1SFerruh Yigit #define RTE_ETH_VLAN_ID_MAX          0x0FFF /**< VLAN ID is in lower 12 bits*/
8730ce56b05SThomas Monjalon /**@}*/
87499a2dd95SBruce Richardson 
87599a2dd95SBruce Richardson /* Definitions used for receive MAC address */
876295968d1SFerruh Yigit #define RTE_ETH_NUM_RECEIVE_MAC_ADDR   128 /**< Maximum nb. of receive mac addr. */
87799a2dd95SBruce Richardson 
87899a2dd95SBruce Richardson /* Definitions used for unicast hash */
879295968d1SFerruh Yigit #define RTE_ETH_VMDQ_NUM_UC_HASH_ARRAY 128 /**< Maximum nb. of UC hash array. */
88099a2dd95SBruce Richardson 
8810ce56b05SThomas Monjalon /**@{@name VMDq Rx mode
8820ce56b05SThomas Monjalon  * @see rte_eth_vmdq_rx_conf.rx_mode
8830ce56b05SThomas Monjalon  */
8844852c647SAndrew Rybchenko /** Accept untagged packets. */
8854852c647SAndrew Rybchenko #define RTE_ETH_VMDQ_ACCEPT_UNTAG      RTE_BIT32(0)
8864852c647SAndrew Rybchenko /** Accept packets in multicast table. */
8874852c647SAndrew Rybchenko #define RTE_ETH_VMDQ_ACCEPT_HASH_MC    RTE_BIT32(1)
8884852c647SAndrew Rybchenko /** Accept packets in unicast table. */
8894852c647SAndrew Rybchenko #define RTE_ETH_VMDQ_ACCEPT_HASH_UC    RTE_BIT32(2)
8904852c647SAndrew Rybchenko /** Accept broadcast packets. */
8914852c647SAndrew Rybchenko #define RTE_ETH_VMDQ_ACCEPT_BROADCAST  RTE_BIT32(3)
8924852c647SAndrew Rybchenko /** Multicast promiscuous. */
8934852c647SAndrew Rybchenko #define RTE_ETH_VMDQ_ACCEPT_MULTICAST  RTE_BIT32(4)
8940ce56b05SThomas Monjalon /**@}*/
89599a2dd95SBruce Richardson 
89699a2dd95SBruce Richardson /**
89799a2dd95SBruce Richardson  * A structure used to configure 64 entries of Redirection Table of the
89899a2dd95SBruce Richardson  * Receive Side Scaling (RSS) feature of an Ethernet port. To configure
89999a2dd95SBruce Richardson  * more than 64 entries supported by hardware, an array of this structure
90099a2dd95SBruce Richardson  * is needed.
90199a2dd95SBruce Richardson  */
90299a2dd95SBruce Richardson struct rte_eth_rss_reta_entry64 {
9033c2ca0a9SAndrew Rybchenko 	/** Mask bits indicate which entries need to be updated/queried. */
90499a2dd95SBruce Richardson 	uint64_t mask;
9053c2ca0a9SAndrew Rybchenko 	/** Group of 64 redirection table entries. */
906295968d1SFerruh Yigit 	uint16_t reta[RTE_ETH_RETA_GROUP_SIZE];
90799a2dd95SBruce Richardson };
90899a2dd95SBruce Richardson 
90999a2dd95SBruce Richardson /**
91099a2dd95SBruce Richardson  * This enum indicates the possible number of traffic classes
91199a2dd95SBruce Richardson  * in DCB configurations
91299a2dd95SBruce Richardson  */
91399a2dd95SBruce Richardson enum rte_eth_nb_tcs {
914295968d1SFerruh Yigit 	RTE_ETH_4_TCS = 4, /**< 4 TCs with DCB. */
915295968d1SFerruh Yigit 	RTE_ETH_8_TCS = 8  /**< 8 TCs with DCB. */
91699a2dd95SBruce Richardson };
91799a2dd95SBruce Richardson 
91899a2dd95SBruce Richardson /**
91999a2dd95SBruce Richardson  * This enum indicates the possible number of queue pools
920064e90c4SAndrew Rybchenko  * in VMDq configurations.
92199a2dd95SBruce Richardson  */
92299a2dd95SBruce Richardson enum rte_eth_nb_pools {
923295968d1SFerruh Yigit 	RTE_ETH_8_POOLS = 8,    /**< 8 VMDq pools. */
924295968d1SFerruh Yigit 	RTE_ETH_16_POOLS = 16,  /**< 16 VMDq pools. */
925295968d1SFerruh Yigit 	RTE_ETH_32_POOLS = 32,  /**< 32 VMDq pools. */
926295968d1SFerruh Yigit 	RTE_ETH_64_POOLS = 64   /**< 64 VMDq pools. */
92799a2dd95SBruce Richardson };
92899a2dd95SBruce Richardson 
92999a2dd95SBruce Richardson /* This structure may be extended in future. */
93099a2dd95SBruce Richardson struct rte_eth_dcb_rx_conf {
93199a2dd95SBruce Richardson 	enum rte_eth_nb_tcs nb_tcs; /**< Possible DCB TCs, 4 or 8 TCs */
93299a2dd95SBruce Richardson 	/** Traffic class each UP mapped to. */
933295968d1SFerruh Yigit 	uint8_t dcb_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES];
93499a2dd95SBruce Richardson };
93599a2dd95SBruce Richardson 
93699a2dd95SBruce Richardson struct rte_eth_vmdq_dcb_tx_conf {
93799a2dd95SBruce Richardson 	enum rte_eth_nb_pools nb_queue_pools; /**< With DCB, 16 or 32 pools. */
93899a2dd95SBruce Richardson 	/** Traffic class each UP mapped to. */
939295968d1SFerruh Yigit 	uint8_t dcb_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES];
94099a2dd95SBruce Richardson };
94199a2dd95SBruce Richardson 
94299a2dd95SBruce Richardson struct rte_eth_dcb_tx_conf {
94399a2dd95SBruce Richardson 	enum rte_eth_nb_tcs nb_tcs; /**< Possible DCB TCs, 4 or 8 TCs. */
94499a2dd95SBruce Richardson 	/** Traffic class each UP mapped to. */
945295968d1SFerruh Yigit 	uint8_t dcb_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES];
94699a2dd95SBruce Richardson };
94799a2dd95SBruce Richardson 
94899a2dd95SBruce Richardson struct rte_eth_vmdq_tx_conf {
94999a2dd95SBruce Richardson 	enum rte_eth_nb_pools nb_queue_pools; /**< VMDq mode, 64 pools. */
95099a2dd95SBruce Richardson };
95199a2dd95SBruce Richardson 
95299a2dd95SBruce Richardson /**
953064e90c4SAndrew Rybchenko  * A structure used to configure the VMDq+DCB feature
95499a2dd95SBruce Richardson  * of an Ethernet port.
95599a2dd95SBruce Richardson  *
95699a2dd95SBruce Richardson  * Using this feature, packets are routed to a pool of queues, based
9575b49ba65SAndrew Rybchenko  * on the VLAN ID in the VLAN tag, and then to a specific queue within
9585b49ba65SAndrew Rybchenko  * that pool, using the user priority VLAN tag field.
95999a2dd95SBruce Richardson  *
96099a2dd95SBruce Richardson  * A default pool may be used, if desired, to route all traffic which
9615b49ba65SAndrew Rybchenko  * does not match the VLAN filter rules.
96299a2dd95SBruce Richardson  */
96399a2dd95SBruce Richardson struct rte_eth_vmdq_dcb_conf {
96499a2dd95SBruce Richardson 	enum rte_eth_nb_pools nb_queue_pools; /**< With DCB, 16 or 32 pools */
96599a2dd95SBruce Richardson 	uint8_t enable_default_pool; /**< If non-zero, use a default pool */
96699a2dd95SBruce Richardson 	uint8_t default_pool; /**< The default pool, if applicable */
96799a2dd95SBruce Richardson 	uint8_t nb_pool_maps; /**< We can have up to 64 filters/mappings */
96899a2dd95SBruce Richardson 	struct {
9695b49ba65SAndrew Rybchenko 		uint16_t vlan_id; /**< The VLAN ID of the received frame */
97009fd4227SAndrew Rybchenko 		uint64_t pools;   /**< Bitmask of pools for packet Rx */
971295968d1SFerruh Yigit 	} pool_map[RTE_ETH_VMDQ_MAX_VLAN_FILTERS]; /**< VMDq VLAN pool maps. */
9723c2ca0a9SAndrew Rybchenko 	/** Selects a queue in a pool */
973295968d1SFerruh Yigit 	uint8_t dcb_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES];
97499a2dd95SBruce Richardson };
97599a2dd95SBruce Richardson 
97699a2dd95SBruce Richardson /**
977064e90c4SAndrew Rybchenko  * A structure used to configure the VMDq feature of an Ethernet port when
97899a2dd95SBruce Richardson  * not combined with the DCB feature.
97999a2dd95SBruce Richardson  *
98099a2dd95SBruce Richardson  * Using this feature, packets are routed to a pool of queues. By default,
9815b49ba65SAndrew Rybchenko  * the pool selection is based on the MAC address, the VLAN ID in the
9825b49ba65SAndrew Rybchenko  * VLAN tag as specified in the pool_map array.
983295968d1SFerruh Yigit  * Passing the RTE_ETH_VMDQ_ACCEPT_UNTAG in the rx_mode field allows pool
98499a2dd95SBruce Richardson  * selection using only the MAC address. MAC address to pool mapping is done
98599a2dd95SBruce Richardson  * using the rte_eth_dev_mac_addr_add function, with the pool parameter
9865906be5aSAndrew Rybchenko  * corresponding to the pool ID.
98799a2dd95SBruce Richardson  *
98899a2dd95SBruce Richardson  * Queue selection within the selected pool will be done using RSS when
98999a2dd95SBruce Richardson  * it is enabled or revert to the first queue of the pool if not.
99099a2dd95SBruce Richardson  *
99199a2dd95SBruce Richardson  * A default pool may be used, if desired, to route all traffic which
9925b49ba65SAndrew Rybchenko  * does not match the VLAN filter rules or any pool MAC address.
99399a2dd95SBruce Richardson  */
99499a2dd95SBruce Richardson struct rte_eth_vmdq_rx_conf {
99599a2dd95SBruce Richardson 	enum rte_eth_nb_pools nb_queue_pools; /**< VMDq only mode, 8 or 64 pools */
99699a2dd95SBruce Richardson 	uint8_t enable_default_pool; /**< If non-zero, use a default pool */
99799a2dd95SBruce Richardson 	uint8_t default_pool; /**< The default pool, if applicable */
99899a2dd95SBruce Richardson 	uint8_t enable_loop_back; /**< Enable VT loop back */
99999a2dd95SBruce Richardson 	uint8_t nb_pool_maps; /**< We can have up to 64 filters/mappings */
1000935b9a43SAndrew Rybchenko 	uint32_t rx_mode; /**< Flags from RTE_ETH_VMDQ_ACCEPT_* */
100199a2dd95SBruce Richardson 	struct {
10025b49ba65SAndrew Rybchenko 		uint16_t vlan_id; /**< The VLAN ID of the received frame */
100309fd4227SAndrew Rybchenko 		uint64_t pools;   /**< Bitmask of pools for packet Rx */
1004295968d1SFerruh Yigit 	} pool_map[RTE_ETH_VMDQ_MAX_VLAN_FILTERS]; /**< VMDq VLAN pool maps. */
100599a2dd95SBruce Richardson };
100699a2dd95SBruce Richardson 
100799a2dd95SBruce Richardson /**
100809fd4227SAndrew Rybchenko  * A structure used to configure the Tx features of an Ethernet port.
100999a2dd95SBruce Richardson  */
101099a2dd95SBruce Richardson struct rte_eth_txmode {
101109fd4227SAndrew Rybchenko 	enum rte_eth_tx_mq_mode mq_mode; /**< Tx multi-queues mode. */
101299a2dd95SBruce Richardson 	/**
1013295968d1SFerruh Yigit 	 * Per-port Tx offloads to be set using RTE_ETH_TX_OFFLOAD_* flags.
101499a2dd95SBruce Richardson 	 * Only offloads set on tx_offload_capa field on rte_eth_dev_info
101599a2dd95SBruce Richardson 	 * structure are allowed to be set.
101699a2dd95SBruce Richardson 	 */
101799a2dd95SBruce Richardson 	uint64_t offloads;
101899a2dd95SBruce Richardson 
101999a2dd95SBruce Richardson 	uint16_t pvid;
102099a2dd95SBruce Richardson 	__extension__
10213c2ca0a9SAndrew Rybchenko 	uint8_t /** If set, reject sending out tagged pkts */
10223c2ca0a9SAndrew Rybchenko 		hw_vlan_reject_tagged : 1,
10233c2ca0a9SAndrew Rybchenko 		/** If set, reject sending out untagged pkts */
102499a2dd95SBruce Richardson 		hw_vlan_reject_untagged : 1,
10253c2ca0a9SAndrew Rybchenko 		/** If set, enable port based VLAN insertion */
102699a2dd95SBruce Richardson 		hw_vlan_insert_pvid : 1;
102799a2dd95SBruce Richardson 
102899a2dd95SBruce Richardson 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
102999a2dd95SBruce Richardson 	void *reserved_ptrs[2];   /**< Reserved for future fields */
103099a2dd95SBruce Richardson };
103199a2dd95SBruce Richardson 
103299a2dd95SBruce Richardson /**
103399a2dd95SBruce Richardson  * @warning
103499a2dd95SBruce Richardson  * @b EXPERIMENTAL: this structure may change without prior notice.
103599a2dd95SBruce Richardson  *
103699a2dd95SBruce Richardson  * A structure used to configure an Rx packet segment to split.
103799a2dd95SBruce Richardson  *
103899a2dd95SBruce Richardson  * If RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag is set in offloads field,
103999a2dd95SBruce Richardson  * the PMD will split the received packets into multiple segments
104099a2dd95SBruce Richardson  * according to the specification in the description array:
104199a2dd95SBruce Richardson  *
104299a2dd95SBruce Richardson  * - The first network buffer will be allocated from the memory pool,
104399a2dd95SBruce Richardson  *   specified in the first array element, the second buffer, from the
104499a2dd95SBruce Richardson  *   pool in the second element, and so on.
104599a2dd95SBruce Richardson  *
1046605975b8SYuan Wang  * - The proto_hdrs in the elements define the split position of
1047605975b8SYuan Wang  *   received packets.
1048605975b8SYuan Wang  *
104999a2dd95SBruce Richardson  * - The offsets from the segment description elements specify
105099a2dd95SBruce Richardson  *   the data offset from the buffer beginning except the first mbuf.
105199a2dd95SBruce Richardson  *   The first segment offset is added with RTE_PKTMBUF_HEADROOM.
105299a2dd95SBruce Richardson  *
105399a2dd95SBruce Richardson  * - The lengths in the elements define the maximal data amount
105499a2dd95SBruce Richardson  *   being received to each segment. The receiving starts with filling
105599a2dd95SBruce Richardson  *   up the first mbuf data buffer up to specified length. If the
105699a2dd95SBruce Richardson  *   there are data remaining (packet is longer than buffer in the first
105799a2dd95SBruce Richardson  *   mbuf) the following data will be pushed to the next segment
105899a2dd95SBruce Richardson  *   up to its own length, and so on.
105999a2dd95SBruce Richardson  *
106099a2dd95SBruce Richardson  * - If the length in the segment description element is zero
106199a2dd95SBruce Richardson  *   the actual buffer size will be deduced from the appropriate
106299a2dd95SBruce Richardson  *   memory pool properties.
106399a2dd95SBruce Richardson  *
106499a2dd95SBruce Richardson  * - If there is not enough elements to describe the buffer for entire
106599a2dd95SBruce Richardson  *   packet of maximal length the following parameters will be used
106699a2dd95SBruce Richardson  *   for the all remaining segments:
106799a2dd95SBruce Richardson  *     - pool from the last valid element
106899a2dd95SBruce Richardson  *     - the buffer size from this pool
106999a2dd95SBruce Richardson  *     - zero offset
1070605975b8SYuan Wang  *
1071605975b8SYuan Wang  * - Length based buffer split:
1072605975b8SYuan Wang  *     - mp, length, offset should be configured.
1073605975b8SYuan Wang  *     - The proto_hdr field must be 0.
1074605975b8SYuan Wang  *
1075605975b8SYuan Wang  * - Protocol header based buffer split:
1076605975b8SYuan Wang  *     - mp, offset, proto_hdr should be configured.
1077605975b8SYuan Wang  *     - The length field must be 0.
1078605975b8SYuan Wang  *     - The proto_hdr field in the last segment should be 0.
1079605975b8SYuan Wang  *
1080605975b8SYuan Wang  * - When protocol header split is enabled, NIC may receive packets
1081605975b8SYuan Wang  *   which do not match all the protocol headers within the Rx segments.
1082605975b8SYuan Wang  *   At this point, NIC will have two possible split behaviors according to
1083605975b8SYuan Wang  *   matching results, one is exact match, another is longest match.
1084605975b8SYuan Wang  *   The split result of NIC must belong to one of them.
1085605975b8SYuan Wang  *   The exact match means NIC only do split when the packets exactly match all
1086605975b8SYuan Wang  *   the protocol headers in the segments.
1087605975b8SYuan Wang  *   Otherwise, the whole packet will be put into the last valid mempool.
1088605975b8SYuan Wang  *   The longest match means NIC will do split until packets mismatch
1089605975b8SYuan Wang  *   the protocol header in the segments.
1090605975b8SYuan Wang  *   The rest will be put into the last valid pool.
109199a2dd95SBruce Richardson  */
109299a2dd95SBruce Richardson struct rte_eth_rxseg_split {
109399a2dd95SBruce Richardson 	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
109499a2dd95SBruce Richardson 	uint16_t length; /**< Segment data length, configures split point. */
109599a2dd95SBruce Richardson 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
1096605975b8SYuan Wang 	/**
1097605975b8SYuan Wang 	 * proto_hdr defines a bit mask of the protocol sequence as RTE_PTYPE_*.
1098605975b8SYuan Wang 	 * The last RTE_PTYPE* in the mask indicates the split position.
1099605975b8SYuan Wang 	 *
1100605975b8SYuan Wang 	 * If one protocol header is defined to split packets into two segments,
1101605975b8SYuan Wang 	 * for non-tunneling packets, the complete protocol sequence should be defined.
1102605975b8SYuan Wang 	 * For tunneling packets, for simplicity, only the tunnel and inner part of
1103605975b8SYuan Wang 	 * complete protocol sequence is required.
1104605975b8SYuan Wang 	 * If several protocol headers are defined to split packets into multi-segments,
1105605975b8SYuan Wang 	 * the repeated parts of adjacent segments should be omitted.
1106605975b8SYuan Wang 	 */
1107605975b8SYuan Wang 	uint32_t proto_hdr;
110899a2dd95SBruce Richardson };
110999a2dd95SBruce Richardson 
111099a2dd95SBruce Richardson /**
111199a2dd95SBruce Richardson  * @warning
111299a2dd95SBruce Richardson  * @b EXPERIMENTAL: this structure may change without prior notice.
111399a2dd95SBruce Richardson  *
111499a2dd95SBruce Richardson  * A common structure used to describe Rx packet segment properties.
111599a2dd95SBruce Richardson  */
111699a2dd95SBruce Richardson union rte_eth_rxseg {
111799a2dd95SBruce Richardson 	/* The settings for buffer split offload. */
111899a2dd95SBruce Richardson 	struct rte_eth_rxseg_split split;
111999a2dd95SBruce Richardson 	/* The other features settings should be added here. */
112099a2dd95SBruce Richardson };
112199a2dd95SBruce Richardson 
112299a2dd95SBruce Richardson /**
112309fd4227SAndrew Rybchenko  * A structure used to configure an Rx ring of an Ethernet port.
112499a2dd95SBruce Richardson  */
112599a2dd95SBruce Richardson struct rte_eth_rxconf {
112609fd4227SAndrew Rybchenko 	struct rte_eth_thresh rx_thresh; /**< Rx ring threshold registers. */
112709fd4227SAndrew Rybchenko 	uint16_t rx_free_thresh; /**< Drives the freeing of Rx descriptors. */
112899a2dd95SBruce Richardson 	uint8_t rx_drop_en; /**< Drop packets if no descriptors are available. */
112999a2dd95SBruce Richardson 	uint8_t rx_deferred_start; /**< Do not start queue with rte_eth_dev_start(). */
113099a2dd95SBruce Richardson 	uint16_t rx_nseg; /**< Number of descriptions in rx_seg array. */
113199a2dd95SBruce Richardson 	/**
1132dd22740cSXueming Li 	 * Share group index in Rx domain and switch domain.
1133dd22740cSXueming Li 	 * Non-zero value to enable Rx queue share, zero value disable share.
1134dd22740cSXueming Li 	 * PMD is responsible for Rx queue consistency checks to avoid member
1135dd22740cSXueming Li 	 * port's configuration contradict to each other.
1136dd22740cSXueming Li 	 */
1137dd22740cSXueming Li 	uint16_t share_group;
1138dd22740cSXueming Li 	uint16_t share_qid; /**< Shared Rx queue ID in group */
1139dd22740cSXueming Li 	/**
1140295968d1SFerruh Yigit 	 * Per-queue Rx offloads to be set using RTE_ETH_RX_OFFLOAD_* flags.
114199a2dd95SBruce Richardson 	 * Only offloads set on rx_queue_offload_capa or rx_offload_capa
114299a2dd95SBruce Richardson 	 * fields on rte_eth_dev_info structure are allowed to be set.
114399a2dd95SBruce Richardson 	 */
114499a2dd95SBruce Richardson 	uint64_t offloads;
114599a2dd95SBruce Richardson 	/**
114699a2dd95SBruce Richardson 	 * Points to the array of segment descriptions for an entire packet.
114799a2dd95SBruce Richardson 	 * Array elements are properties for consecutive Rx segments.
114899a2dd95SBruce Richardson 	 *
114999a2dd95SBruce Richardson 	 * The supported capabilities of receiving segmentation is reported
115099a2dd95SBruce Richardson 	 * in rte_eth_dev_info.rx_seg_capa field.
115199a2dd95SBruce Richardson 	 */
115299a2dd95SBruce Richardson 	union rte_eth_rxseg *rx_seg;
115399a2dd95SBruce Richardson 
1154458485ebSHanumanth Pothula 	/**
1155458485ebSHanumanth Pothula 	 * Array of mempools to allocate Rx buffers from.
1156458485ebSHanumanth Pothula 	 *
1157458485ebSHanumanth Pothula 	 * This provides support for multiple mbuf pools per Rx queue.
1158458485ebSHanumanth Pothula 	 * The capability is reported in device info via positive
1159458485ebSHanumanth Pothula 	 * max_rx_mempools.
1160458485ebSHanumanth Pothula 	 *
1161458485ebSHanumanth Pothula 	 * It could be useful for more efficient usage of memory when an
1162458485ebSHanumanth Pothula 	 * application creates different mempools to steer the specific
1163458485ebSHanumanth Pothula 	 * size of the packet.
1164458485ebSHanumanth Pothula 	 *
1165458485ebSHanumanth Pothula 	 * If many mempools are specified, packets received using Rx
1166458485ebSHanumanth Pothula 	 * burst may belong to any provided mempool. From ethdev user point
1167458485ebSHanumanth Pothula 	 * of view it is undefined how PMD/NIC chooses mempool for a packet.
1168458485ebSHanumanth Pothula 	 *
1169458485ebSHanumanth Pothula 	 * If Rx scatter is enabled, a packet may be delivered using a chain
1170458485ebSHanumanth Pothula 	 * of mbufs obtained from single mempool or multiple mempools based
1171458485ebSHanumanth Pothula 	 * on the NIC implementation.
1172458485ebSHanumanth Pothula 	 */
1173458485ebSHanumanth Pothula 	struct rte_mempool **rx_mempools;
1174458485ebSHanumanth Pothula 	uint16_t rx_nmempool; /** < Number of Rx mempools */
1175458485ebSHanumanth Pothula 
117699a2dd95SBruce Richardson 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
117799a2dd95SBruce Richardson 	void *reserved_ptrs[2];   /**< Reserved for future fields */
117899a2dd95SBruce Richardson };
117999a2dd95SBruce Richardson 
118099a2dd95SBruce Richardson /**
118109fd4227SAndrew Rybchenko  * A structure used to configure a Tx ring of an Ethernet port.
118299a2dd95SBruce Richardson  */
118399a2dd95SBruce Richardson struct rte_eth_txconf {
118409fd4227SAndrew Rybchenko 	struct rte_eth_thresh tx_thresh; /**< Tx ring threshold registers. */
118599a2dd95SBruce Richardson 	uint16_t tx_rs_thresh; /**< Drives the setting of RS bit on TXDs. */
118609fd4227SAndrew Rybchenko 	uint16_t tx_free_thresh; /**< Start freeing Tx buffers if there are
118799a2dd95SBruce Richardson 				      less free descriptors than this value. */
118899a2dd95SBruce Richardson 
118999a2dd95SBruce Richardson 	uint8_t tx_deferred_start; /**< Do not start queue with rte_eth_dev_start(). */
119099a2dd95SBruce Richardson 	/**
1191295968d1SFerruh Yigit 	 * Per-queue Tx offloads to be set  using RTE_ETH_TX_OFFLOAD_* flags.
119299a2dd95SBruce Richardson 	 * Only offloads set on tx_queue_offload_capa or tx_offload_capa
119399a2dd95SBruce Richardson 	 * fields on rte_eth_dev_info structure are allowed to be set.
119499a2dd95SBruce Richardson 	 */
119599a2dd95SBruce Richardson 	uint64_t offloads;
119699a2dd95SBruce Richardson 
119799a2dd95SBruce Richardson 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
119899a2dd95SBruce Richardson 	void *reserved_ptrs[2];   /**< Reserved for future fields */
119999a2dd95SBruce Richardson };
120099a2dd95SBruce Richardson 
120199a2dd95SBruce Richardson /**
120299a2dd95SBruce Richardson  * @warning
120399a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
120499a2dd95SBruce Richardson  *
1205bc705061SDariusz Sosnowski  * A structure used to return the Tx or Rx hairpin queue capabilities.
1206bc705061SDariusz Sosnowski  */
1207bc705061SDariusz Sosnowski struct rte_eth_hairpin_queue_cap {
1208bc705061SDariusz Sosnowski 	/**
1209bc705061SDariusz Sosnowski 	 * When set, PMD supports placing descriptors and/or data buffers
1210bc705061SDariusz Sosnowski 	 * in dedicated device memory.
1211bc705061SDariusz Sosnowski 	 */
1212bc705061SDariusz Sosnowski 	uint32_t locked_device_memory:1;
1213bc705061SDariusz Sosnowski 
1214bc705061SDariusz Sosnowski 	/**
1215bc705061SDariusz Sosnowski 	 * When set, PMD supports placing descriptors and/or data buffers
1216bc705061SDariusz Sosnowski 	 * in host memory managed by DPDK.
1217bc705061SDariusz Sosnowski 	 */
1218bc705061SDariusz Sosnowski 	uint32_t rte_memory:1;
1219bc705061SDariusz Sosnowski 
1220bc705061SDariusz Sosnowski 	uint32_t reserved:30; /**< Reserved for future fields */
1221bc705061SDariusz Sosnowski };
1222bc705061SDariusz Sosnowski 
1223bc705061SDariusz Sosnowski /**
1224bc705061SDariusz Sosnowski  * @warning
1225bc705061SDariusz Sosnowski  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
1226bc705061SDariusz Sosnowski  *
122799a2dd95SBruce Richardson  * A structure used to return the hairpin capabilities that are supported.
122899a2dd95SBruce Richardson  */
122999a2dd95SBruce Richardson struct rte_eth_hairpin_cap {
123099a2dd95SBruce Richardson 	/** The max number of hairpin queues (different bindings). */
123199a2dd95SBruce Richardson 	uint16_t max_nb_queues;
123299a2dd95SBruce Richardson 	/** Max number of Rx queues to be connected to one Tx queue. */
123399a2dd95SBruce Richardson 	uint16_t max_rx_2_tx;
123499a2dd95SBruce Richardson 	/** Max number of Tx queues to be connected to one Rx queue. */
123599a2dd95SBruce Richardson 	uint16_t max_tx_2_rx;
123699a2dd95SBruce Richardson 	uint16_t max_nb_desc; /**< The max num of descriptors. */
1237bc705061SDariusz Sosnowski 	struct rte_eth_hairpin_queue_cap rx_cap; /**< Rx hairpin queue capabilities. */
1238bc705061SDariusz Sosnowski 	struct rte_eth_hairpin_queue_cap tx_cap; /**< Tx hairpin queue capabilities. */
123999a2dd95SBruce Richardson };
124099a2dd95SBruce Richardson 
124199a2dd95SBruce Richardson #define RTE_ETH_MAX_HAIRPIN_PEERS 32
124299a2dd95SBruce Richardson 
124399a2dd95SBruce Richardson /**
124499a2dd95SBruce Richardson  * @warning
124599a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
124699a2dd95SBruce Richardson  *
124799a2dd95SBruce Richardson  * A structure used to hold hairpin peer data.
124899a2dd95SBruce Richardson  */
124999a2dd95SBruce Richardson struct rte_eth_hairpin_peer {
125099a2dd95SBruce Richardson 	uint16_t port; /**< Peer port. */
125199a2dd95SBruce Richardson 	uint16_t queue; /**< Peer queue. */
125299a2dd95SBruce Richardson };
125399a2dd95SBruce Richardson 
125499a2dd95SBruce Richardson /**
125599a2dd95SBruce Richardson  * @warning
125699a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
125799a2dd95SBruce Richardson  *
125899a2dd95SBruce Richardson  * A structure used to configure hairpin binding.
125999a2dd95SBruce Richardson  */
126099a2dd95SBruce Richardson struct rte_eth_hairpin_conf {
126199a2dd95SBruce Richardson 	uint32_t peer_count:16; /**< The number of peers. */
126299a2dd95SBruce Richardson 
126399a2dd95SBruce Richardson 	/**
126499a2dd95SBruce Richardson 	 * Explicit Tx flow rule mode.
126599a2dd95SBruce Richardson 	 * One hairpin pair of queues should have the same attribute.
126699a2dd95SBruce Richardson 	 *
126799a2dd95SBruce Richardson 	 * - When set, the user should be responsible for inserting the hairpin
126899a2dd95SBruce Richardson 	 *   Tx part flows and removing them.
126999a2dd95SBruce Richardson 	 * - When clear, the PMD will try to handle the Tx part of the flows,
127099a2dd95SBruce Richardson 	 *   e.g., by splitting one flow into two parts.
127199a2dd95SBruce Richardson 	 */
127299a2dd95SBruce Richardson 	uint32_t tx_explicit:1;
127399a2dd95SBruce Richardson 
127499a2dd95SBruce Richardson 	/**
127599a2dd95SBruce Richardson 	 * Manually bind hairpin queues.
127699a2dd95SBruce Richardson 	 * One hairpin pair of queues should have the same attribute.
127799a2dd95SBruce Richardson 	 *
127899a2dd95SBruce Richardson 	 * - When set, to enable hairpin, the user should call the hairpin bind
127999a2dd95SBruce Richardson 	 *   function after all the queues are set up properly and the ports are
128099a2dd95SBruce Richardson 	 *   started. Also, the hairpin unbind function should be called
128199a2dd95SBruce Richardson 	 *   accordingly before stopping a port that with hairpin configured.
1282bc705061SDariusz Sosnowski 	 * - When cleared, the PMD will try to enable the hairpin with the queues
128399a2dd95SBruce Richardson 	 *   configured automatically during port start.
128499a2dd95SBruce Richardson 	 */
128599a2dd95SBruce Richardson 	uint32_t manual_bind:1;
1286bc705061SDariusz Sosnowski 
1287bc705061SDariusz Sosnowski 	/**
1288bc705061SDariusz Sosnowski 	 * Use locked device memory as a backing storage.
1289bc705061SDariusz Sosnowski 	 *
1290bc705061SDariusz Sosnowski 	 * - When set, PMD will attempt place descriptors and/or data buffers
1291bc705061SDariusz Sosnowski 	 *   in dedicated device memory.
1292bc705061SDariusz Sosnowski 	 * - When cleared, PMD will use default memory type as a backing storage.
1293bc705061SDariusz Sosnowski 	 *   Please refer to PMD documentation for details.
1294bc705061SDariusz Sosnowski 	 *
1295bc705061SDariusz Sosnowski 	 * API user should check if PMD supports this configuration flag using
1296bc705061SDariusz Sosnowski 	 * @see rte_eth_dev_hairpin_capability_get.
1297bc705061SDariusz Sosnowski 	 */
1298bc705061SDariusz Sosnowski 	uint32_t use_locked_device_memory:1;
1299bc705061SDariusz Sosnowski 
1300bc705061SDariusz Sosnowski 	/**
1301bc705061SDariusz Sosnowski 	 * Use DPDK memory as backing storage.
1302bc705061SDariusz Sosnowski 	 *
1303bc705061SDariusz Sosnowski 	 * - When set, PMD will attempt place descriptors and/or data buffers
1304bc705061SDariusz Sosnowski 	 *   in host memory managed by DPDK.
1305bc705061SDariusz Sosnowski 	 * - When cleared, PMD will use default memory type as a backing storage.
1306bc705061SDariusz Sosnowski 	 *   Please refer to PMD documentation for details.
1307bc705061SDariusz Sosnowski 	 *
1308bc705061SDariusz Sosnowski 	 * API user should check if PMD supports this configuration flag using
1309bc705061SDariusz Sosnowski 	 * @see rte_eth_dev_hairpin_capability_get.
1310bc705061SDariusz Sosnowski 	 */
1311bc705061SDariusz Sosnowski 	uint32_t use_rte_memory:1;
1312bc705061SDariusz Sosnowski 
1313bc705061SDariusz Sosnowski 	/**
1314bc705061SDariusz Sosnowski 	 * Force usage of hairpin memory configuration.
1315bc705061SDariusz Sosnowski 	 *
1316bc705061SDariusz Sosnowski 	 * - When set, PMD will attempt to use specified memory settings.
1317bc705061SDariusz Sosnowski 	 *   If resource allocation fails, then hairpin queue allocation
1318bc705061SDariusz Sosnowski 	 *   will result in an error.
1319bc705061SDariusz Sosnowski 	 * - When clear, PMD will attempt to use specified memory settings.
1320bc705061SDariusz Sosnowski 	 *   If resource allocation fails, then PMD will retry
1321bc705061SDariusz Sosnowski 	 *   allocation with default configuration.
1322bc705061SDariusz Sosnowski 	 */
1323bc705061SDariusz Sosnowski 	uint32_t force_memory:1;
1324bc705061SDariusz Sosnowski 
1325bc705061SDariusz Sosnowski 	uint32_t reserved:11; /**< Reserved bits. */
1326bc705061SDariusz Sosnowski 
132799a2dd95SBruce Richardson 	struct rte_eth_hairpin_peer peers[RTE_ETH_MAX_HAIRPIN_PEERS];
132899a2dd95SBruce Richardson };
132999a2dd95SBruce Richardson 
133099a2dd95SBruce Richardson /**
133199a2dd95SBruce Richardson  * A structure contains information about HW descriptor ring limitations.
133299a2dd95SBruce Richardson  */
133399a2dd95SBruce Richardson struct rte_eth_desc_lim {
133499a2dd95SBruce Richardson 	uint16_t nb_max;   /**< Max allowed number of descriptors. */
133599a2dd95SBruce Richardson 	uint16_t nb_min;   /**< Min allowed number of descriptors. */
133699a2dd95SBruce Richardson 	uint16_t nb_align; /**< Number of descriptors should be aligned to. */
133799a2dd95SBruce Richardson 
133899a2dd95SBruce Richardson 	/**
133999a2dd95SBruce Richardson 	 * Max allowed number of segments per whole packet.
134099a2dd95SBruce Richardson 	 *
134199a2dd95SBruce Richardson 	 * - For TSO packet this is the total number of data descriptors allowed
134299a2dd95SBruce Richardson 	 *   by device.
134399a2dd95SBruce Richardson 	 *
134499a2dd95SBruce Richardson 	 * @see nb_mtu_seg_max
134599a2dd95SBruce Richardson 	 */
134699a2dd95SBruce Richardson 	uint16_t nb_seg_max;
134799a2dd95SBruce Richardson 
134899a2dd95SBruce Richardson 	/**
134999a2dd95SBruce Richardson 	 * Max number of segments per one MTU.
135099a2dd95SBruce Richardson 	 *
135199a2dd95SBruce Richardson 	 * - For non-TSO packet, this is the maximum allowed number of segments
135299a2dd95SBruce Richardson 	 *   in a single transmit packet.
135399a2dd95SBruce Richardson 	 *
135499a2dd95SBruce Richardson 	 * - For TSO packet each segment within the TSO may span up to this
135599a2dd95SBruce Richardson 	 *   value.
135699a2dd95SBruce Richardson 	 *
135799a2dd95SBruce Richardson 	 * @see nb_seg_max
135899a2dd95SBruce Richardson 	 */
135999a2dd95SBruce Richardson 	uint16_t nb_mtu_seg_max;
136099a2dd95SBruce Richardson };
136199a2dd95SBruce Richardson 
136299a2dd95SBruce Richardson /**
136399a2dd95SBruce Richardson  * This enum indicates the flow control mode
136499a2dd95SBruce Richardson  */
136599a2dd95SBruce Richardson enum rte_eth_fc_mode {
1366295968d1SFerruh Yigit 	RTE_ETH_FC_NONE = 0, /**< Disable flow control. */
1367295968d1SFerruh Yigit 	RTE_ETH_FC_RX_PAUSE, /**< Rx pause frame, enable flowctrl on Tx side. */
1368295968d1SFerruh Yigit 	RTE_ETH_FC_TX_PAUSE, /**< Tx pause frame, enable flowctrl on Rx side. */
1369295968d1SFerruh Yigit 	RTE_ETH_FC_FULL      /**< Enable flow control on both side. */
137099a2dd95SBruce Richardson };
1371295968d1SFerruh Yigit 
137299a2dd95SBruce Richardson /**
137399a2dd95SBruce Richardson  * A structure used to configure Ethernet flow control parameter.
137499a2dd95SBruce Richardson  * These parameters will be configured into the register of the NIC.
137599a2dd95SBruce Richardson  * Please refer to the corresponding data sheet for proper value.
137699a2dd95SBruce Richardson  */
137799a2dd95SBruce Richardson struct rte_eth_fc_conf {
137899a2dd95SBruce Richardson 	uint32_t high_water;  /**< High threshold value to trigger XOFF */
137999a2dd95SBruce Richardson 	uint32_t low_water;   /**< Low threshold value to trigger XON */
138099a2dd95SBruce Richardson 	uint16_t pause_time;  /**< Pause quota in the Pause frame */
138199a2dd95SBruce Richardson 	uint16_t send_xon;    /**< Is XON frame need be sent */
138299a2dd95SBruce Richardson 	enum rte_eth_fc_mode mode;  /**< Link flow control mode */
138399a2dd95SBruce Richardson 	uint8_t mac_ctrl_frame_fwd; /**< Forward MAC control frames */
138499a2dd95SBruce Richardson 	uint8_t autoneg;      /**< Use Pause autoneg */
138599a2dd95SBruce Richardson };
138699a2dd95SBruce Richardson 
138799a2dd95SBruce Richardson /**
138899a2dd95SBruce Richardson  * A structure used to configure Ethernet priority flow control parameter.
138999a2dd95SBruce Richardson  * These parameters will be configured into the register of the NIC.
139099a2dd95SBruce Richardson  * Please refer to the corresponding data sheet for proper value.
139199a2dd95SBruce Richardson  */
139299a2dd95SBruce Richardson struct rte_eth_pfc_conf {
139399a2dd95SBruce Richardson 	struct rte_eth_fc_conf fc; /**< General flow control parameter. */
139499a2dd95SBruce Richardson 	uint8_t priority;          /**< VLAN User Priority. */
139599a2dd95SBruce Richardson };
139699a2dd95SBruce Richardson 
139799a2dd95SBruce Richardson /**
13980de345e9SJerin Jacob  * @warning
13990de345e9SJerin Jacob  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
14000de345e9SJerin Jacob  *
14010de345e9SJerin Jacob  * A structure used to retrieve information of queue based PFC.
14020de345e9SJerin Jacob  */
14030de345e9SJerin Jacob struct rte_eth_pfc_queue_info {
14040de345e9SJerin Jacob 	/**
14050de345e9SJerin Jacob 	 * Maximum supported traffic class as per PFC (802.1Qbb) specification.
14060de345e9SJerin Jacob 	 */
14070de345e9SJerin Jacob 	uint8_t tc_max;
14080de345e9SJerin Jacob 	/** PFC queue mode capabilities. */
14090de345e9SJerin Jacob 	enum rte_eth_fc_mode mode_capa;
14100de345e9SJerin Jacob };
14110de345e9SJerin Jacob 
14120de345e9SJerin Jacob /**
14130de345e9SJerin Jacob  * @warning
14140de345e9SJerin Jacob  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
14150de345e9SJerin Jacob  *
14160de345e9SJerin Jacob  * A structure used to configure Ethernet priority flow control parameters for
14170de345e9SJerin Jacob  * ethdev queues.
14180de345e9SJerin Jacob  *
14190de345e9SJerin Jacob  * rte_eth_pfc_queue_conf::rx_pause structure shall be used to configure given
14200de345e9SJerin Jacob  * tx_qid with corresponding tc. When ethdev device receives PFC frame with
14210de345e9SJerin Jacob  * rte_eth_pfc_queue_conf::rx_pause::tc, traffic will be paused on
14220de345e9SJerin Jacob  * rte_eth_pfc_queue_conf::rx_pause::tx_qid for that tc.
14230de345e9SJerin Jacob  *
14240de345e9SJerin Jacob  * rte_eth_pfc_queue_conf::tx_pause structure shall be used to configure given
14250de345e9SJerin Jacob  * rx_qid. When rx_qid is congested, PFC frames are generated with
14260de345e9SJerin Jacob  * rte_eth_pfc_queue_conf::rx_pause::tc and
14270de345e9SJerin Jacob  * rte_eth_pfc_queue_conf::rx_pause::pause_time to the peer.
14280de345e9SJerin Jacob  */
14290de345e9SJerin Jacob struct rte_eth_pfc_queue_conf {
14300de345e9SJerin Jacob 	enum rte_eth_fc_mode mode; /**< Link flow control mode */
14310de345e9SJerin Jacob 
14320de345e9SJerin Jacob 	struct {
14330de345e9SJerin Jacob 		uint16_t tx_qid; /**< Tx queue ID */
14340de345e9SJerin Jacob 		/** Traffic class as per PFC (802.1Qbb) spec. The value must be
14350de345e9SJerin Jacob 		 * in the range [0, rte_eth_pfc_queue_info::tx_max - 1]
14360de345e9SJerin Jacob 		 */
14370de345e9SJerin Jacob 		uint8_t tc;
14380de345e9SJerin Jacob 	} rx_pause; /* Valid when (mode == FC_RX_PAUSE || mode == FC_FULL) */
14390de345e9SJerin Jacob 
14400de345e9SJerin Jacob 	struct {
14410de345e9SJerin Jacob 		uint16_t pause_time; /**< Pause quota in the Pause frame */
14420de345e9SJerin Jacob 		uint16_t rx_qid;     /**< Rx queue ID */
14430de345e9SJerin Jacob 		/** Traffic class as per PFC (802.1Qbb) spec. The value must be
14440de345e9SJerin Jacob 		 * in the range [0, rte_eth_pfc_queue_info::tx_max - 1]
14450de345e9SJerin Jacob 		 */
14460de345e9SJerin Jacob 		uint8_t tc;
14470de345e9SJerin Jacob 	} tx_pause; /* Valid when (mode == FC_TX_PAUSE || mode == FC_FULL) */
14480de345e9SJerin Jacob };
14490de345e9SJerin Jacob 
14500de345e9SJerin Jacob /**
145199a2dd95SBruce Richardson  * Tunnel type for device-specific classifier configuration.
145299a2dd95SBruce Richardson  * @see rte_eth_udp_tunnel
145399a2dd95SBruce Richardson  */
145499a2dd95SBruce Richardson enum rte_eth_tunnel_type {
1455295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_NONE = 0,
1456295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_VXLAN,
1457295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_GENEVE,
1458295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_TEREDO,
1459295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_NVGRE,
1460295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_IP_IN_GRE,
1461295968d1SFerruh Yigit 	RTE_ETH_L2_TUNNEL_TYPE_E_TAG,
1462295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_VXLAN_GPE,
1463295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_ECPRI,
1464295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_MAX,
146599a2dd95SBruce Richardson };
1466295968d1SFerruh Yigit 
146720387ebcSDavid Marchand #ifdef __cplusplus
146820387ebcSDavid Marchand }
146920387ebcSDavid Marchand #endif
147020387ebcSDavid Marchand 
147199a2dd95SBruce Richardson /* Deprecated API file for rte_eth_dev_filter_* functions */
147299a2dd95SBruce Richardson #include "rte_eth_ctrl.h"
147399a2dd95SBruce Richardson 
147420387ebcSDavid Marchand #ifdef __cplusplus
147520387ebcSDavid Marchand extern "C" {
147620387ebcSDavid Marchand #endif
147720387ebcSDavid Marchand 
147899a2dd95SBruce Richardson /**
147999a2dd95SBruce Richardson  * UDP tunneling configuration.
148099a2dd95SBruce Richardson  *
148199a2dd95SBruce Richardson  * Used to configure the classifier of a device,
148299a2dd95SBruce Richardson  * associating an UDP port with a type of tunnel.
148399a2dd95SBruce Richardson  *
148499a2dd95SBruce Richardson  * Some NICs may need such configuration to properly parse a tunnel
148599a2dd95SBruce Richardson  * with any standard or custom UDP port.
148699a2dd95SBruce Richardson  */
148799a2dd95SBruce Richardson struct rte_eth_udp_tunnel {
148899a2dd95SBruce Richardson 	uint16_t udp_port; /**< UDP port used for the tunnel. */
148999a2dd95SBruce Richardson 	uint8_t prot_type; /**< Tunnel type. @see rte_eth_tunnel_type */
149099a2dd95SBruce Richardson };
149199a2dd95SBruce Richardson 
149299a2dd95SBruce Richardson /**
149399a2dd95SBruce Richardson  * A structure used to enable/disable specific device interrupts.
149499a2dd95SBruce Richardson  */
1495295968d1SFerruh Yigit struct rte_eth_intr_conf {
149699a2dd95SBruce Richardson 	/** enable/disable lsc interrupt. 0 (default) - disable, 1 enable */
149799a2dd95SBruce Richardson 	uint32_t lsc:1;
149899a2dd95SBruce Richardson 	/** enable/disable rxq interrupt. 0 (default) - disable, 1 enable */
149999a2dd95SBruce Richardson 	uint32_t rxq:1;
150099a2dd95SBruce Richardson 	/** enable/disable rmv interrupt. 0 (default) - disable, 1 enable */
150199a2dd95SBruce Richardson 	uint32_t rmv:1;
150299a2dd95SBruce Richardson };
150399a2dd95SBruce Richardson 
1504295968d1SFerruh Yigit #define rte_intr_conf rte_eth_intr_conf
1505295968d1SFerruh Yigit 
150699a2dd95SBruce Richardson /**
150799a2dd95SBruce Richardson  * A structure used to configure an Ethernet port.
150809fd4227SAndrew Rybchenko  * Depending upon the Rx multi-queue mode, extra advanced
150999a2dd95SBruce Richardson  * configuration settings may be needed.
151099a2dd95SBruce Richardson  */
151199a2dd95SBruce Richardson struct rte_eth_conf {
1512295968d1SFerruh Yigit 	uint32_t link_speeds; /**< bitmap of RTE_ETH_LINK_SPEED_XXX of speeds to be
1513295968d1SFerruh Yigit 				used. RTE_ETH_LINK_SPEED_FIXED disables link
151499a2dd95SBruce Richardson 				autonegotiation, and a unique speed shall be
151599a2dd95SBruce Richardson 				set. Otherwise, the bitmap defines the set of
151699a2dd95SBruce Richardson 				speeds to be advertised. If the special value
1517295968d1SFerruh Yigit 				RTE_ETH_LINK_SPEED_AUTONEG (0) is used, all speeds
151899a2dd95SBruce Richardson 				supported are advertised. */
151909fd4227SAndrew Rybchenko 	struct rte_eth_rxmode rxmode; /**< Port Rx configuration. */
152009fd4227SAndrew Rybchenko 	struct rte_eth_txmode txmode; /**< Port Tx configuration. */
152199a2dd95SBruce Richardson 	uint32_t lpbk_mode; /**< Loopback operation mode. By default the value
152299a2dd95SBruce Richardson 			         is 0, meaning the loopback mode is disabled.
15230d9f56a8SAndrew Rybchenko 				 Read the datasheet of given Ethernet controller
152499a2dd95SBruce Richardson 				 for details. The possible values of this field
152599a2dd95SBruce Richardson 				 are defined in implementation of each driver. */
152699a2dd95SBruce Richardson 	struct {
152799a2dd95SBruce Richardson 		struct rte_eth_rss_conf rss_conf; /**< Port RSS configuration */
1528064e90c4SAndrew Rybchenko 		/** Port VMDq+DCB configuration. */
152999a2dd95SBruce Richardson 		struct rte_eth_vmdq_dcb_conf vmdq_dcb_conf;
1530064e90c4SAndrew Rybchenko 		/** Port DCB Rx configuration. */
153199a2dd95SBruce Richardson 		struct rte_eth_dcb_rx_conf dcb_rx_conf;
1532064e90c4SAndrew Rybchenko 		/** Port VMDq Rx configuration. */
153399a2dd95SBruce Richardson 		struct rte_eth_vmdq_rx_conf vmdq_rx_conf;
153409fd4227SAndrew Rybchenko 	} rx_adv_conf; /**< Port Rx filtering configuration. */
153599a2dd95SBruce Richardson 	union {
1536064e90c4SAndrew Rybchenko 		/** Port VMDq+DCB Tx configuration. */
153799a2dd95SBruce Richardson 		struct rte_eth_vmdq_dcb_tx_conf vmdq_dcb_tx_conf;
1538064e90c4SAndrew Rybchenko 		/** Port DCB Tx configuration. */
153999a2dd95SBruce Richardson 		struct rte_eth_dcb_tx_conf dcb_tx_conf;
1540064e90c4SAndrew Rybchenko 		/** Port VMDq Tx configuration. */
154199a2dd95SBruce Richardson 		struct rte_eth_vmdq_tx_conf vmdq_tx_conf;
154209fd4227SAndrew Rybchenko 	} tx_adv_conf; /**< Port Tx DCB configuration (union). */
154399a2dd95SBruce Richardson 	/** Currently,Priority Flow Control(PFC) are supported,if DCB with PFC
1544295968d1SFerruh Yigit 	    is needed,and the variable must be set RTE_ETH_DCB_PFC_SUPPORT. */
154599a2dd95SBruce Richardson 	uint32_t dcb_capability_en;
1546295968d1SFerruh Yigit 	struct rte_eth_intr_conf intr_conf; /**< Interrupt mode configuration. */
154799a2dd95SBruce Richardson };
154899a2dd95SBruce Richardson 
154999a2dd95SBruce Richardson /**
155009fd4227SAndrew Rybchenko  * Rx offload capabilities of a device.
155199a2dd95SBruce Richardson  */
15524852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_VLAN_STRIP       RTE_BIT64(0)
15534852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_IPV4_CKSUM       RTE_BIT64(1)
15544852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_UDP_CKSUM        RTE_BIT64(2)
15554852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_TCP_CKSUM        RTE_BIT64(3)
15564852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_TCP_LRO          RTE_BIT64(4)
15574852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_QINQ_STRIP       RTE_BIT64(5)
15584852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM RTE_BIT64(6)
15594852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_MACSEC_STRIP     RTE_BIT64(7)
15604852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_VLAN_FILTER      RTE_BIT64(9)
15614852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_VLAN_EXTEND      RTE_BIT64(10)
15624852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_SCATTER          RTE_BIT64(13)
156399a2dd95SBruce Richardson /**
156499a2dd95SBruce Richardson  * Timestamp is set by the driver in RTE_MBUF_DYNFIELD_TIMESTAMP_NAME
156599a2dd95SBruce Richardson  * and RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME is set in ol_flags.
156699a2dd95SBruce Richardson  * The mbuf field and flag are registered when the offload is configured.
156799a2dd95SBruce Richardson  */
15684852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_TIMESTAMP        RTE_BIT64(14)
15694852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_SECURITY         RTE_BIT64(15)
15704852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_KEEP_CRC         RTE_BIT64(16)
15714852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_SCTP_CKSUM       RTE_BIT64(17)
15724852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM  RTE_BIT64(18)
15734852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_RSS_HASH         RTE_BIT64(19)
15744852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT     RTE_BIT64(20)
157599a2dd95SBruce Richardson 
1576295968d1SFerruh Yigit #define RTE_ETH_RX_OFFLOAD_CHECKSUM (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | \
1577295968d1SFerruh Yigit 				 RTE_ETH_RX_OFFLOAD_UDP_CKSUM | \
1578295968d1SFerruh Yigit 				 RTE_ETH_RX_OFFLOAD_TCP_CKSUM)
1579295968d1SFerruh Yigit #define RTE_ETH_RX_OFFLOAD_VLAN (RTE_ETH_RX_OFFLOAD_VLAN_STRIP | \
1580295968d1SFerruh Yigit 			     RTE_ETH_RX_OFFLOAD_VLAN_FILTER | \
1581295968d1SFerruh Yigit 			     RTE_ETH_RX_OFFLOAD_VLAN_EXTEND | \
1582295968d1SFerruh Yigit 			     RTE_ETH_RX_OFFLOAD_QINQ_STRIP)
158399a2dd95SBruce Richardson 
158499a2dd95SBruce Richardson /*
158599a2dd95SBruce Richardson  * If new Rx offload capabilities are defined, they also must be
158699a2dd95SBruce Richardson  * mentioned in rte_rx_offload_names in rte_ethdev.c file.
158799a2dd95SBruce Richardson  */
158899a2dd95SBruce Richardson 
158999a2dd95SBruce Richardson /**
159009fd4227SAndrew Rybchenko  * Tx offload capabilities of a device.
159199a2dd95SBruce Richardson  */
15924852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_VLAN_INSERT      RTE_BIT64(0)
15934852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_IPV4_CKSUM       RTE_BIT64(1)
15944852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_UDP_CKSUM        RTE_BIT64(2)
15954852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_TCP_CKSUM        RTE_BIT64(3)
15964852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_SCTP_CKSUM       RTE_BIT64(4)
15974852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_TCP_TSO          RTE_BIT64(5)
15984852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_UDP_TSO          RTE_BIT64(6)
15994852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM RTE_BIT64(7)  /**< Used for tunneling packet. */
16004852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_QINQ_INSERT      RTE_BIT64(8)
16014852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO    RTE_BIT64(9)  /**< Used for tunneling packet. */
16024852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO      RTE_BIT64(10) /**< Used for tunneling packet. */
16034852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO     RTE_BIT64(11) /**< Used for tunneling packet. */
16044852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO   RTE_BIT64(12) /**< Used for tunneling packet. */
16054852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_MACSEC_INSERT    RTE_BIT64(13)
16063c2ca0a9SAndrew Rybchenko /**
16073c2ca0a9SAndrew Rybchenko  * Multiple threads can invoke rte_eth_tx_burst() concurrently on the same
160809fd4227SAndrew Rybchenko  * Tx queue without SW lock.
160999a2dd95SBruce Richardson  */
16104852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_MT_LOCKFREE      RTE_BIT64(14)
16113c2ca0a9SAndrew Rybchenko /** Device supports multi segment send. */
16124852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_MULTI_SEGS       RTE_BIT64(15)
16133c2ca0a9SAndrew Rybchenko /**
16143c2ca0a9SAndrew Rybchenko  * Device supports optimization for fast release of mbufs.
161599a2dd95SBruce Richardson  * When set application must guarantee that per-queue all mbufs comes from
161699a2dd95SBruce Richardson  * the same mempool and has refcnt = 1.
161799a2dd95SBruce Richardson  */
16184852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE   RTE_BIT64(16)
16194852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_SECURITY         RTE_BIT64(17)
162099a2dd95SBruce Richardson /**
162199a2dd95SBruce Richardson  * Device supports generic UDP tunneled packet TSO.
1622daa02b5cSOlivier Matz  * Application must set RTE_MBUF_F_TX_TUNNEL_UDP and other mbuf fields required
162399a2dd95SBruce Richardson  * for tunnel TSO.
162499a2dd95SBruce Richardson  */
16254852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO      RTE_BIT64(18)
162699a2dd95SBruce Richardson /**
162799a2dd95SBruce Richardson  * Device supports generic IP tunneled packet TSO.
1628daa02b5cSOlivier Matz  * Application must set RTE_MBUF_F_TX_TUNNEL_IP and other mbuf fields required
162999a2dd95SBruce Richardson  * for tunnel TSO.
163099a2dd95SBruce Richardson  */
16314852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_IP_TNL_TSO       RTE_BIT64(19)
163299a2dd95SBruce Richardson /** Device supports outer UDP checksum */
16334852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM  RTE_BIT64(20)
163499a2dd95SBruce Richardson /**
163599a2dd95SBruce Richardson  * Device sends on time read from RTE_MBUF_DYNFIELD_TIMESTAMP_NAME
163699a2dd95SBruce Richardson  * if RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME is set in ol_flags.
163799a2dd95SBruce Richardson  * The mbuf field and flag are registered when the offload is configured.
163899a2dd95SBruce Richardson  */
16394852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP RTE_BIT64(21)
164099a2dd95SBruce Richardson /*
164199a2dd95SBruce Richardson  * If new Tx offload capabilities are defined, they also must be
164299a2dd95SBruce Richardson  * mentioned in rte_tx_offload_names in rte_ethdev.c file.
164399a2dd95SBruce Richardson  */
164499a2dd95SBruce Richardson 
164599a2dd95SBruce Richardson /**@{@name Device capabilities
164699a2dd95SBruce Richardson  * Non-offload capabilities reported in rte_eth_dev_info.dev_capa.
164799a2dd95SBruce Richardson  */
164899a2dd95SBruce Richardson /** Device supports Rx queue setup after device started. */
16494852c647SAndrew Rybchenko #define RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP RTE_BIT64(0)
165099a2dd95SBruce Richardson /** Device supports Tx queue setup after device started. */
16514852c647SAndrew Rybchenko #define RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP RTE_BIT64(1)
1652dd22740cSXueming Li /**
1653dd22740cSXueming Li  * Device supports shared Rx queue among ports within Rx domain and
1654dd22740cSXueming Li  * switch domain. Mbufs are consumed by shared Rx queue instead of
1655dd22740cSXueming Li  * each queue. Multiple groups are supported by share_group of Rx
1656dd22740cSXueming Li  * queue configuration. Shared Rx queue is identified by PMD using
1657dd22740cSXueming Li  * share_qid of Rx queue configuration. Polling any port in the group
1658dd22740cSXueming Li  * receive packets of all member ports, source port identified by
1659dd22740cSXueming Li  * mbuf->port field.
1660dd22740cSXueming Li  */
1661dd22740cSXueming Li #define RTE_ETH_DEV_CAPA_RXQ_SHARE              RTE_BIT64(2)
16621d5a3d68SDmitry Kozlyuk /** Device supports keeping flow rules across restart. */
16631d5a3d68SDmitry Kozlyuk #define RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP         RTE_BIT64(3)
16642c9cd45dSDmitry Kozlyuk /** Device supports keeping shared flow objects across restart. */
16652c9cd45dSDmitry Kozlyuk #define RTE_ETH_DEV_CAPA_FLOW_SHARED_OBJECT_KEEP RTE_BIT64(4)
166699a2dd95SBruce Richardson /**@}*/
166799a2dd95SBruce Richardson 
166899a2dd95SBruce Richardson /*
166999a2dd95SBruce Richardson  * Fallback default preferred Rx/Tx port parameters.
167099a2dd95SBruce Richardson  * These are used if an application requests default parameters
167199a2dd95SBruce Richardson  * but the PMD does not provide preferred values.
167299a2dd95SBruce Richardson  */
167399a2dd95SBruce Richardson #define RTE_ETH_DEV_FALLBACK_RX_RINGSIZE 512
167499a2dd95SBruce Richardson #define RTE_ETH_DEV_FALLBACK_TX_RINGSIZE 512
167599a2dd95SBruce Richardson #define RTE_ETH_DEV_FALLBACK_RX_NBQUEUES 1
167699a2dd95SBruce Richardson #define RTE_ETH_DEV_FALLBACK_TX_NBQUEUES 1
167799a2dd95SBruce Richardson 
167899a2dd95SBruce Richardson /**
167999a2dd95SBruce Richardson  * Preferred Rx/Tx port parameters.
168099a2dd95SBruce Richardson  * There are separate instances of this structure for transmission
168199a2dd95SBruce Richardson  * and reception respectively.
168299a2dd95SBruce Richardson  */
168399a2dd95SBruce Richardson struct rte_eth_dev_portconf {
168499a2dd95SBruce Richardson 	uint16_t burst_size; /**< Device-preferred burst size */
168599a2dd95SBruce Richardson 	uint16_t ring_size; /**< Device-preferred size of queue rings */
168699a2dd95SBruce Richardson 	uint16_t nb_queues; /**< Device-preferred number of queues */
168799a2dd95SBruce Richardson };
168899a2dd95SBruce Richardson 
168999a2dd95SBruce Richardson /**
16905906be5aSAndrew Rybchenko  * Default values for switch domain ID when ethdev does not support switch
169199a2dd95SBruce Richardson  * domain definitions.
169299a2dd95SBruce Richardson  */
169399a2dd95SBruce Richardson #define RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID	(UINT16_MAX)
169499a2dd95SBruce Richardson 
169599a2dd95SBruce Richardson /**
169699a2dd95SBruce Richardson  * Ethernet device associated switch information
169799a2dd95SBruce Richardson  */
169899a2dd95SBruce Richardson struct rte_eth_switch_info {
169999a2dd95SBruce Richardson 	const char *name;	/**< switch name */
17005906be5aSAndrew Rybchenko 	uint16_t domain_id;	/**< switch domain ID */
17013c2ca0a9SAndrew Rybchenko 	/**
17023c2ca0a9SAndrew Rybchenko 	 * Mapping to the devices physical switch port as enumerated from the
170399a2dd95SBruce Richardson 	 * perspective of the embedded interconnect/switch. For SR-IOV enabled
170499a2dd95SBruce Richardson 	 * device this may correspond to the VF_ID of each virtual function,
170599a2dd95SBruce Richardson 	 * but each driver should explicitly define the mapping of switch
170699a2dd95SBruce Richardson 	 * port identifier to that physical interconnect/switch
170799a2dd95SBruce Richardson 	 */
17083c2ca0a9SAndrew Rybchenko 	uint16_t port_id;
1709dd22740cSXueming Li 	/**
1710dd22740cSXueming Li 	 * Shared Rx queue sub-domain boundary. Only ports in same Rx domain
1711dd22740cSXueming Li 	 * and switch domain can share Rx queue. Valid only if device advertised
1712dd22740cSXueming Li 	 * RTE_ETH_DEV_CAPA_RXQ_SHARE capability.
1713dd22740cSXueming Li 	 */
1714dd22740cSXueming Li 	uint16_t rx_domain;
171599a2dd95SBruce Richardson };
171699a2dd95SBruce Richardson 
171799a2dd95SBruce Richardson /**
171899a2dd95SBruce Richardson  * @warning
171999a2dd95SBruce Richardson  * @b EXPERIMENTAL: this structure may change without prior notice.
172099a2dd95SBruce Richardson  *
172199a2dd95SBruce Richardson  * Ethernet device Rx buffer segmentation capabilities.
172299a2dd95SBruce Richardson  */
172399a2dd95SBruce Richardson struct rte_eth_rxseg_capa {
172499a2dd95SBruce Richardson 	__extension__
172599a2dd95SBruce Richardson 	uint32_t multi_pools:1; /**< Supports receiving to multiple pools.*/
172699a2dd95SBruce Richardson 	uint32_t offset_allowed:1; /**< Supports buffer offsets. */
172799a2dd95SBruce Richardson 	uint32_t offset_align_log2:4; /**< Required offset alignment. */
172899a2dd95SBruce Richardson 	uint16_t max_nseg; /**< Maximum amount of segments to split. */
172999a2dd95SBruce Richardson 	uint16_t reserved; /**< Reserved field. */
173099a2dd95SBruce Richardson };
173199a2dd95SBruce Richardson 
173299a2dd95SBruce Richardson /**
173399a2dd95SBruce Richardson  * Ethernet device information
173499a2dd95SBruce Richardson  */
173599a2dd95SBruce Richardson 
173699a2dd95SBruce Richardson /**
173799a2dd95SBruce Richardson  * Ethernet device representor port type.
173899a2dd95SBruce Richardson  */
173999a2dd95SBruce Richardson enum rte_eth_representor_type {
174099a2dd95SBruce Richardson 	RTE_ETH_REPRESENTOR_NONE, /**< not a representor. */
174199a2dd95SBruce Richardson 	RTE_ETH_REPRESENTOR_VF,   /**< representor of Virtual Function. */
174299a2dd95SBruce Richardson 	RTE_ETH_REPRESENTOR_SF,   /**< representor of Sub Function. */
174399a2dd95SBruce Richardson 	RTE_ETH_REPRESENTOR_PF,   /**< representor of Physical Function. */
174499a2dd95SBruce Richardson };
174599a2dd95SBruce Richardson 
174699a2dd95SBruce Richardson /**
17470d5c38baSChengwen Feng  * @warning
17480d5c38baSChengwen Feng  * @b EXPERIMENTAL: this enumeration may change without prior notice.
17490d5c38baSChengwen Feng  *
17500d5c38baSChengwen Feng  * Ethernet device error handling mode.
17510d5c38baSChengwen Feng  */
17520d5c38baSChengwen Feng enum rte_eth_err_handle_mode {
17530d5c38baSChengwen Feng 	/** No error handling modes are supported. */
17540d5c38baSChengwen Feng 	RTE_ETH_ERROR_HANDLE_MODE_NONE,
17550d5c38baSChengwen Feng 	/** Passive error handling, after the PMD detects that a reset is required,
17560d5c38baSChengwen Feng 	 * the PMD reports @see RTE_ETH_EVENT_INTR_RESET event,
17570d5c38baSChengwen Feng 	 * and the application invokes @see rte_eth_dev_reset to recover the port.
17580d5c38baSChengwen Feng 	 */
17590d5c38baSChengwen Feng 	RTE_ETH_ERROR_HANDLE_MODE_PASSIVE,
1760eb0d471aSKalesh AP 	/** Proactive error handling, after the PMD detects that a reset is required,
1761eb0d471aSKalesh AP 	 * the PMD reports @see RTE_ETH_EVENT_ERR_RECOVERING event,
1762eb0d471aSKalesh AP 	 * do recovery internally, and finally reports the recovery result event
1763eb0d471aSKalesh AP 	 * (@see RTE_ETH_EVENT_RECOVERY_*).
1764eb0d471aSKalesh AP 	 */
1765eb0d471aSKalesh AP 	RTE_ETH_ERROR_HANDLE_MODE_PROACTIVE,
17660d5c38baSChengwen Feng };
17670d5c38baSChengwen Feng 
17680d5c38baSChengwen Feng /**
176999a2dd95SBruce Richardson  * A structure used to retrieve the contextual information of
177099a2dd95SBruce Richardson  * an Ethernet device, such as the controlling driver of the
177199a2dd95SBruce Richardson  * device, etc...
177299a2dd95SBruce Richardson  */
177399a2dd95SBruce Richardson struct rte_eth_dev_info {
17743b358e33SFerruh Yigit 	struct rte_device *device; /**< Generic device information */
177599a2dd95SBruce Richardson 	const char *driver_name; /**< Device Driver name. */
177699a2dd95SBruce Richardson 	unsigned int if_index; /**< Index to bound host interface, or 0 if none.
177799a2dd95SBruce Richardson 		Use if_indextoname() to translate into an interface name. */
177899a2dd95SBruce Richardson 	uint16_t min_mtu;	/**< Minimum MTU allowed */
177999a2dd95SBruce Richardson 	uint16_t max_mtu;	/**< Maximum MTU allowed */
178099a2dd95SBruce Richardson 	const uint32_t *dev_flags; /**< Device flags */
178175c7849aSHuisong Li 	/** Minimum Rx buffer size per descriptor supported by HW. */
178275c7849aSHuisong Li 	uint32_t min_rx_bufsize;
178375c7849aSHuisong Li 	/**
178475c7849aSHuisong Li 	 * Maximum Rx buffer size per descriptor supported by HW.
178575c7849aSHuisong Li 	 * The value is not enforced, information only to application to
178675c7849aSHuisong Li 	 * optimize mbuf size.
178775c7849aSHuisong Li 	 * Its value is UINT32_MAX when not specified by the driver.
178875c7849aSHuisong Li 	 */
178975c7849aSHuisong Li 	uint32_t max_rx_bufsize;
179009fd4227SAndrew Rybchenko 	uint32_t max_rx_pktlen; /**< Maximum configurable length of Rx pkt. */
179199a2dd95SBruce Richardson 	/** Maximum configurable size of LRO aggregated packet. */
179299a2dd95SBruce Richardson 	uint32_t max_lro_pkt_size;
179309fd4227SAndrew Rybchenko 	uint16_t max_rx_queues; /**< Maximum number of Rx queues. */
179409fd4227SAndrew Rybchenko 	uint16_t max_tx_queues; /**< Maximum number of Tx queues. */
179599a2dd95SBruce Richardson 	uint32_t max_mac_addrs; /**< Maximum number of MAC addresses. */
179699a2dd95SBruce Richardson 	/** Maximum number of hash MAC addresses for MTA and UTA. */
17973b358e33SFerruh Yigit 	uint32_t max_hash_mac_addrs;
179899a2dd95SBruce Richardson 	uint16_t max_vfs; /**< Maximum number of VFs. */
179999a2dd95SBruce Richardson 	uint16_t max_vmdq_pools; /**< Maximum number of VMDq pools. */
180099a2dd95SBruce Richardson 	struct rte_eth_rxseg_capa rx_seg_capa; /**< Segmentation capability.*/
180109fd4227SAndrew Rybchenko 	/** All Rx offload capabilities including all per-queue ones */
180299a2dd95SBruce Richardson 	uint64_t rx_offload_capa;
180309fd4227SAndrew Rybchenko 	/** All Tx offload capabilities including all per-queue ones */
180499a2dd95SBruce Richardson 	uint64_t tx_offload_capa;
180509fd4227SAndrew Rybchenko 	/** Device per-queue Rx offload capabilities. */
180699a2dd95SBruce Richardson 	uint64_t rx_queue_offload_capa;
180709fd4227SAndrew Rybchenko 	/** Device per-queue Tx offload capabilities. */
180899a2dd95SBruce Richardson 	uint64_t tx_queue_offload_capa;
18093c2ca0a9SAndrew Rybchenko 	/** Device redirection table size, the total number of entries. */
181099a2dd95SBruce Richardson 	uint16_t reta_size;
181199a2dd95SBruce Richardson 	uint8_t hash_key_size; /**< Hash key size in bytes */
181234ff088cSJie Hai 	uint32_t rss_algo_capa; /** RSS hash algorithms capabilities */
181399a2dd95SBruce Richardson 	/** Bit mask of RSS offloads, the bit offset also means flow type */
181499a2dd95SBruce Richardson 	uint64_t flow_type_rss_offloads;
181509fd4227SAndrew Rybchenko 	struct rte_eth_rxconf default_rxconf; /**< Default Rx configuration */
181609fd4227SAndrew Rybchenko 	struct rte_eth_txconf default_txconf; /**< Default Tx configuration */
1817064e90c4SAndrew Rybchenko 	uint16_t vmdq_queue_base; /**< First queue ID for VMDq pools. */
1818064e90c4SAndrew Rybchenko 	uint16_t vmdq_queue_num;  /**< Queue number for VMDq pools. */
1819064e90c4SAndrew Rybchenko 	uint16_t vmdq_pool_base;  /**< First ID of VMDq pools. */
182009fd4227SAndrew Rybchenko 	struct rte_eth_desc_lim rx_desc_lim;  /**< Rx descriptors limits */
182109fd4227SAndrew Rybchenko 	struct rte_eth_desc_lim tx_desc_lim;  /**< Tx descriptors limits */
1822295968d1SFerruh Yigit 	uint32_t speed_capa;  /**< Supported speeds bitmap (RTE_ETH_LINK_SPEED_). */
182309fd4227SAndrew Rybchenko 	/** Configured number of Rx/Tx queues */
182409fd4227SAndrew Rybchenko 	uint16_t nb_rx_queues; /**< Number of Rx queues. */
182509fd4227SAndrew Rybchenko 	uint16_t nb_tx_queues; /**< Number of Tx queues. */
1826458485ebSHanumanth Pothula 	/**
1827458485ebSHanumanth Pothula 	 * Maximum number of Rx mempools supported per Rx queue.
1828458485ebSHanumanth Pothula 	 *
1829458485ebSHanumanth Pothula 	 * Value greater than 0 means that the driver supports Rx queue
1830458485ebSHanumanth Pothula 	 * mempools specification via rx_conf->rx_mempools.
1831458485ebSHanumanth Pothula 	 */
1832458485ebSHanumanth Pothula 	uint16_t max_rx_mempools;
183399a2dd95SBruce Richardson 	/** Rx parameter recommendations */
183499a2dd95SBruce Richardson 	struct rte_eth_dev_portconf default_rxportconf;
183599a2dd95SBruce Richardson 	/** Tx parameter recommendations */
183699a2dd95SBruce Richardson 	struct rte_eth_dev_portconf default_txportconf;
183799a2dd95SBruce Richardson 	/** Generic device capabilities (RTE_ETH_DEV_CAPA_). */
183899a2dd95SBruce Richardson 	uint64_t dev_capa;
183999a2dd95SBruce Richardson 	/**
184099a2dd95SBruce Richardson 	 * Switching information for ports on a device with a
184199a2dd95SBruce Richardson 	 * embedded managed interconnect/switch.
184299a2dd95SBruce Richardson 	 */
184399a2dd95SBruce Richardson 	struct rte_eth_switch_info switch_info;
18440d5c38baSChengwen Feng 	/** Supported error handling mode. */
18450d5c38baSChengwen Feng 	enum rte_eth_err_handle_mode err_handle_mode;
184699a2dd95SBruce Richardson 
184799a2dd95SBruce Richardson 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
184899a2dd95SBruce Richardson 	void *reserved_ptrs[2];   /**< Reserved for future fields */
184999a2dd95SBruce Richardson };
185099a2dd95SBruce Richardson 
18510ce56b05SThomas Monjalon /**@{@name Rx/Tx queue states */
18520ce56b05SThomas Monjalon #define RTE_ETH_QUEUE_STATE_STOPPED 0 /**< Queue stopped. */
18530ce56b05SThomas Monjalon #define RTE_ETH_QUEUE_STATE_STARTED 1 /**< Queue started. */
18540ce56b05SThomas Monjalon #define RTE_ETH_QUEUE_STATE_HAIRPIN 2 /**< Queue used for hairpin. */
18550ce56b05SThomas Monjalon /**@}*/
18569ad9ff47SLijun Ou 
18579ad9ff47SLijun Ou /**
185809fd4227SAndrew Rybchenko  * Ethernet device Rx queue information structure.
185999a2dd95SBruce Richardson  * Used to retrieve information about configured queue.
186099a2dd95SBruce Richardson  */
1861c6552d9aSTyler Retzlaff struct __rte_cache_min_aligned rte_eth_rxq_info {
186299a2dd95SBruce Richardson 	struct rte_mempool *mp;     /**< mempool used by that queue. */
186399a2dd95SBruce Richardson 	struct rte_eth_rxconf conf; /**< queue config parameters. */
186409fd4227SAndrew Rybchenko 	uint8_t scattered_rx;       /**< scattered packets Rx supported. */
18659ad9ff47SLijun Ou 	uint8_t queue_state;        /**< one of RTE_ETH_QUEUE_STATE_*. */
186699a2dd95SBruce Richardson 	uint16_t nb_desc;           /**< configured number of RXDs. */
186799a2dd95SBruce Richardson 	uint16_t rx_buf_size;       /**< hardware receive buffer size. */
1868bc70e559SSpike Du 	/**
1869bc70e559SSpike Du 	 * Available Rx descriptors threshold defined as percentage
1870bc70e559SSpike Du 	 * of Rx queue size. If number of available descriptors is lower,
1871bc70e559SSpike Du 	 * the event RTE_ETH_EVENT_RX_AVAIL_THESH is generated.
1872bc70e559SSpike Du 	 * Value 0 means that the threshold monitoring is disabled.
1873bc70e559SSpike Du 	 */
1874bc70e559SSpike Du 	uint8_t avail_thresh;
1875c6552d9aSTyler Retzlaff };
187699a2dd95SBruce Richardson 
187799a2dd95SBruce Richardson /**
187809fd4227SAndrew Rybchenko  * Ethernet device Tx queue information structure.
187999a2dd95SBruce Richardson  * Used to retrieve information about configured queue.
188099a2dd95SBruce Richardson  */
1881c6552d9aSTyler Retzlaff struct __rte_cache_min_aligned rte_eth_txq_info {
188299a2dd95SBruce Richardson 	struct rte_eth_txconf conf; /**< queue config parameters. */
188399a2dd95SBruce Richardson 	uint16_t nb_desc;           /**< configured number of TXDs. */
18849ad9ff47SLijun Ou 	uint8_t queue_state;        /**< one of RTE_ETH_QUEUE_STATE_*. */
1885c6552d9aSTyler Retzlaff };
188699a2dd95SBruce Richardson 
1887e43d2b89SFeifei Wang /**
1888e43d2b89SFeifei Wang  * @warning
1889e43d2b89SFeifei Wang  * @b EXPERIMENTAL: this structure may change without prior notice.
1890e43d2b89SFeifei Wang  *
1891e43d2b89SFeifei Wang  * Ethernet device Rx queue information structure for recycling mbufs.
1892e43d2b89SFeifei Wang  * Used to retrieve Rx queue information when Tx queue reusing mbufs and moving
1893e43d2b89SFeifei Wang  * them into Rx mbuf ring.
1894e43d2b89SFeifei Wang  */
1895c6552d9aSTyler Retzlaff struct __rte_cache_min_aligned rte_eth_recycle_rxq_info {
1896e43d2b89SFeifei Wang 	struct rte_mbuf **mbuf_ring; /**< mbuf ring of Rx queue. */
1897e43d2b89SFeifei Wang 	struct rte_mempool *mp;     /**< mempool of Rx queue. */
1898e43d2b89SFeifei Wang 	uint16_t *refill_head;      /**< head of Rx queue refilling mbufs. */
1899e43d2b89SFeifei Wang 	uint16_t *receive_tail;     /**< tail of Rx queue receiving pkts. */
1900e43d2b89SFeifei Wang 	uint16_t mbuf_ring_size;     /**< configured number of mbuf ring size. */
1901e43d2b89SFeifei Wang 	/**
1902e43d2b89SFeifei Wang 	 * Requirement on mbuf refilling batch size of Rx mbuf ring.
1903e43d2b89SFeifei Wang 	 * For some PMD drivers, the number of Rx mbuf ring refilling mbufs
1904e43d2b89SFeifei Wang 	 * should be aligned with mbuf ring size, in order to simplify
1905e43d2b89SFeifei Wang 	 * ring wrapping around.
1906e43d2b89SFeifei Wang 	 * Value 0 means that PMD drivers have no requirement for this.
1907e43d2b89SFeifei Wang 	 */
1908e43d2b89SFeifei Wang 	uint16_t refill_requirement;
1909c6552d9aSTyler Retzlaff };
1910e43d2b89SFeifei Wang 
191199a2dd95SBruce Richardson /* Generic Burst mode flag definition, values can be ORed. */
191299a2dd95SBruce Richardson 
191399a2dd95SBruce Richardson /**
191499a2dd95SBruce Richardson  * If the queues have different burst mode description, this bit will be set
191599a2dd95SBruce Richardson  * by PMD, then the application can iterate to retrieve burst description for
191699a2dd95SBruce Richardson  * all other queues.
191799a2dd95SBruce Richardson  */
1918e1823e08SThomas Monjalon #define RTE_ETH_BURST_FLAG_PER_QUEUE RTE_BIT64(0)
191999a2dd95SBruce Richardson 
192099a2dd95SBruce Richardson /**
192109fd4227SAndrew Rybchenko  * Ethernet device Rx/Tx queue packet burst mode information structure.
192299a2dd95SBruce Richardson  * Used to retrieve information about packet burst mode setting.
192399a2dd95SBruce Richardson  */
192499a2dd95SBruce Richardson struct rte_eth_burst_mode {
192599a2dd95SBruce Richardson 	uint64_t flags; /**< The ORed values of RTE_ETH_BURST_FLAG_xxx */
192699a2dd95SBruce Richardson 
192799a2dd95SBruce Richardson #define RTE_ETH_BURST_MODE_INFO_SIZE 1024 /**< Maximum size for information */
192899a2dd95SBruce Richardson 	char info[RTE_ETH_BURST_MODE_INFO_SIZE]; /**< burst mode information */
192999a2dd95SBruce Richardson };
193099a2dd95SBruce Richardson 
193199a2dd95SBruce Richardson /** Maximum name length for extended statistics counters */
193299a2dd95SBruce Richardson #define RTE_ETH_XSTATS_NAME_SIZE 64
193399a2dd95SBruce Richardson 
193499a2dd95SBruce Richardson /**
193599a2dd95SBruce Richardson  * An Ethernet device extended statistic structure
193699a2dd95SBruce Richardson  *
193799a2dd95SBruce Richardson  * This structure is used by rte_eth_xstats_get() to provide
193899a2dd95SBruce Richardson  * statistics that are not provided in the generic *rte_eth_stats*
193999a2dd95SBruce Richardson  * structure.
19405906be5aSAndrew Rybchenko  * It maps a name ID, corresponding to an index in the array returned
194199a2dd95SBruce Richardson  * by rte_eth_xstats_get_names(), to a statistic value.
194299a2dd95SBruce Richardson  */
194399a2dd95SBruce Richardson struct rte_eth_xstat {
194499a2dd95SBruce Richardson 	uint64_t id;        /**< The index in xstats name array. */
194599a2dd95SBruce Richardson 	uint64_t value;     /**< The statistic counter value. */
194699a2dd95SBruce Richardson };
194799a2dd95SBruce Richardson 
194899a2dd95SBruce Richardson /**
194999a2dd95SBruce Richardson  * A name element for extended statistics.
195099a2dd95SBruce Richardson  *
195199a2dd95SBruce Richardson  * An array of this structure is returned by rte_eth_xstats_get_names().
195299a2dd95SBruce Richardson  * It lists the names of extended statistics for a PMD. The *rte_eth_xstat*
195399a2dd95SBruce Richardson  * structure references these names by their array index.
195499a2dd95SBruce Richardson  *
195599a2dd95SBruce Richardson  * The xstats should follow a common naming scheme.
195699a2dd95SBruce Richardson  * Some names are standardized in rte_stats_strings.
195799a2dd95SBruce Richardson  * Examples:
195899a2dd95SBruce Richardson  *     - rx_missed_errors
195999a2dd95SBruce Richardson  *     - tx_q3_bytes
196099a2dd95SBruce Richardson  *     - tx_size_128_to_255_packets
196199a2dd95SBruce Richardson  */
196299a2dd95SBruce Richardson struct rte_eth_xstat_name {
196399a2dd95SBruce Richardson 	char name[RTE_ETH_XSTATS_NAME_SIZE]; /**< The statistic name. */
196499a2dd95SBruce Richardson };
196599a2dd95SBruce Richardson 
1966295968d1SFerruh Yigit #define RTE_ETH_DCB_NUM_TCS    8
1967295968d1SFerruh Yigit #define RTE_ETH_MAX_VMDQ_POOL  64
1968b1cb3035SFerruh Yigit 
196999a2dd95SBruce Richardson /**
197099a2dd95SBruce Richardson  * A structure used to get the information of queue and
197109fd4227SAndrew Rybchenko  * TC mapping on both Tx and Rx paths.
197299a2dd95SBruce Richardson  */
197399a2dd95SBruce Richardson struct rte_eth_dcb_tc_queue_mapping {
197409fd4227SAndrew Rybchenko 	/** Rx queues assigned to tc per Pool */
197599a2dd95SBruce Richardson 	struct {
197699a2dd95SBruce Richardson 		uint16_t base;
197799a2dd95SBruce Richardson 		uint16_t nb_queue;
1978295968d1SFerruh Yigit 	} tc_rxq[RTE_ETH_MAX_VMDQ_POOL][RTE_ETH_DCB_NUM_TCS];
197909fd4227SAndrew Rybchenko 	/** Rx queues assigned to tc per Pool */
198099a2dd95SBruce Richardson 	struct {
198199a2dd95SBruce Richardson 		uint16_t base;
198299a2dd95SBruce Richardson 		uint16_t nb_queue;
1983295968d1SFerruh Yigit 	} tc_txq[RTE_ETH_MAX_VMDQ_POOL][RTE_ETH_DCB_NUM_TCS];
198499a2dd95SBruce Richardson };
198599a2dd95SBruce Richardson 
198699a2dd95SBruce Richardson /**
198799a2dd95SBruce Richardson  * A structure used to get the information of DCB.
198899a2dd95SBruce Richardson  * It includes TC UP mapping and queue TC mapping.
198999a2dd95SBruce Richardson  */
199099a2dd95SBruce Richardson struct rte_eth_dcb_info {
199199a2dd95SBruce Richardson 	uint8_t nb_tcs;        /**< number of TCs */
1992295968d1SFerruh Yigit 	uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES]; /**< Priority to tc */
1993295968d1SFerruh Yigit 	uint8_t tc_bws[RTE_ETH_DCB_NUM_TCS]; /**< Tx BW percentage for each TC */
199409fd4227SAndrew Rybchenko 	/** Rx queues assigned to tc */
199599a2dd95SBruce Richardson 	struct rte_eth_dcb_tc_queue_mapping tc_queue;
199699a2dd95SBruce Richardson };
199799a2dd95SBruce Richardson 
199899a2dd95SBruce Richardson /**
199999a2dd95SBruce Richardson  * This enum indicates the possible Forward Error Correction (FEC) modes
200099a2dd95SBruce Richardson  * of an ethdev port.
200199a2dd95SBruce Richardson  */
200299a2dd95SBruce Richardson enum rte_eth_fec_mode {
200399a2dd95SBruce Richardson 	RTE_ETH_FEC_NOFEC = 0,      /**< FEC is off */
200499a2dd95SBruce Richardson 	RTE_ETH_FEC_AUTO,	    /**< FEC autonegotiation modes */
200599a2dd95SBruce Richardson 	RTE_ETH_FEC_BASER,          /**< FEC using common algorithm */
200699a2dd95SBruce Richardson 	RTE_ETH_FEC_RS,             /**< FEC using RS algorithm */
2007e30aa525SJie Hai 	RTE_ETH_FEC_LLRS,           /**< FEC using LLRS algorithm */
200899a2dd95SBruce Richardson };
200999a2dd95SBruce Richardson 
201099a2dd95SBruce Richardson /* Translate from FEC mode to FEC capa */
2011e1823e08SThomas Monjalon #define RTE_ETH_FEC_MODE_TO_CAPA(x) RTE_BIT32(x)
201299a2dd95SBruce Richardson 
201399a2dd95SBruce Richardson /* This macro indicates FEC capa mask */
2014e1823e08SThomas Monjalon #define RTE_ETH_FEC_MODE_CAPA_MASK(x) RTE_BIT32(RTE_ETH_FEC_ ## x)
201599a2dd95SBruce Richardson 
201699a2dd95SBruce Richardson /* A structure used to get capabilities per link speed */
201799a2dd95SBruce Richardson struct rte_eth_fec_capa {
2018295968d1SFerruh Yigit 	uint32_t speed; /**< Link speed (see RTE_ETH_SPEED_NUM_*) */
201999a2dd95SBruce Richardson 	uint32_t capa;  /**< FEC capabilities bitmask */
202099a2dd95SBruce Richardson };
202199a2dd95SBruce Richardson 
202299a2dd95SBruce Richardson #define RTE_ETH_ALL RTE_MAX_ETHPORTS
202399a2dd95SBruce Richardson 
202499a2dd95SBruce Richardson /* Macros to check for valid port */
202599a2dd95SBruce Richardson #define RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, retval) do { \
202699a2dd95SBruce Richardson 	if (!rte_eth_dev_is_valid_port(port_id)) { \
20270e21c7c0SDavid Marchand 		RTE_ETHDEV_LOG_LINE(ERR, "Invalid port_id=%u", port_id); \
202899a2dd95SBruce Richardson 		return retval; \
202999a2dd95SBruce Richardson 	} \
203099a2dd95SBruce Richardson } while (0)
203199a2dd95SBruce Richardson 
203299a2dd95SBruce Richardson #define RTE_ETH_VALID_PORTID_OR_RET(port_id) do { \
203399a2dd95SBruce Richardson 	if (!rte_eth_dev_is_valid_port(port_id)) { \
20340e21c7c0SDavid Marchand 		RTE_ETHDEV_LOG_LINE(ERR, "Invalid port_id=%u", port_id); \
203599a2dd95SBruce Richardson 		return; \
203699a2dd95SBruce Richardson 	} \
203799a2dd95SBruce Richardson } while (0)
203899a2dd95SBruce Richardson 
203999a2dd95SBruce Richardson /**
204009fd4227SAndrew Rybchenko  * Function type used for Rx packet processing packet callbacks.
204199a2dd95SBruce Richardson  *
204209fd4227SAndrew Rybchenko  * The callback function is called on Rx with a burst of packets that have
204399a2dd95SBruce Richardson  * been received on the given port and queue.
204499a2dd95SBruce Richardson  *
204599a2dd95SBruce Richardson  * @param port_id
204609fd4227SAndrew Rybchenko  *   The Ethernet port on which Rx is being performed.
204799a2dd95SBruce Richardson  * @param queue
204899a2dd95SBruce Richardson  *   The queue on the Ethernet port which is being used to receive the packets.
204999a2dd95SBruce Richardson  * @param pkts
205099a2dd95SBruce Richardson  *   The burst of packets that have just been received.
205199a2dd95SBruce Richardson  * @param nb_pkts
205299a2dd95SBruce Richardson  *   The number of packets in the burst pointed to by "pkts".
205399a2dd95SBruce Richardson  * @param max_pkts
205499a2dd95SBruce Richardson  *   The max number of packets that can be stored in the "pkts" array.
205599a2dd95SBruce Richardson  * @param user_param
205699a2dd95SBruce Richardson  *   The arbitrary user parameter passed in by the application when the callback
205799a2dd95SBruce Richardson  *   was originally configured.
205899a2dd95SBruce Richardson  * @return
205999a2dd95SBruce Richardson  *   The number of packets returned to the user.
206099a2dd95SBruce Richardson  */
206199a2dd95SBruce Richardson typedef uint16_t (*rte_rx_callback_fn)(uint16_t port_id, uint16_t queue,
206299a2dd95SBruce Richardson 	struct rte_mbuf *pkts[], uint16_t nb_pkts, uint16_t max_pkts,
206399a2dd95SBruce Richardson 	void *user_param);
206499a2dd95SBruce Richardson 
206599a2dd95SBruce Richardson /**
206609fd4227SAndrew Rybchenko  * Function type used for Tx packet processing packet callbacks.
206799a2dd95SBruce Richardson  *
206809fd4227SAndrew Rybchenko  * The callback function is called on Tx with a burst of packets immediately
206999a2dd95SBruce Richardson  * before the packets are put onto the hardware queue for transmission.
207099a2dd95SBruce Richardson  *
207199a2dd95SBruce Richardson  * @param port_id
207209fd4227SAndrew Rybchenko  *   The Ethernet port on which Tx is being performed.
207399a2dd95SBruce Richardson  * @param queue
207499a2dd95SBruce Richardson  *   The queue on the Ethernet port which is being used to transmit the packets.
207599a2dd95SBruce Richardson  * @param pkts
207699a2dd95SBruce Richardson  *   The burst of packets that are about to be transmitted.
207799a2dd95SBruce Richardson  * @param nb_pkts
207899a2dd95SBruce Richardson  *   The number of packets in the burst pointed to by "pkts".
207999a2dd95SBruce Richardson  * @param user_param
208099a2dd95SBruce Richardson  *   The arbitrary user parameter passed in by the application when the callback
208199a2dd95SBruce Richardson  *   was originally configured.
208299a2dd95SBruce Richardson  * @return
208399a2dd95SBruce Richardson  *   The number of packets to be written to the NIC.
208499a2dd95SBruce Richardson  */
208599a2dd95SBruce Richardson typedef uint16_t (*rte_tx_callback_fn)(uint16_t port_id, uint16_t queue,
208699a2dd95SBruce Richardson 	struct rte_mbuf *pkts[], uint16_t nb_pkts, void *user_param);
208799a2dd95SBruce Richardson 
208899a2dd95SBruce Richardson /**
208999a2dd95SBruce Richardson  * Possible states of an ethdev port.
209099a2dd95SBruce Richardson  */
209199a2dd95SBruce Richardson enum rte_eth_dev_state {
209299a2dd95SBruce Richardson 	/** Device is unused before being probed. */
209399a2dd95SBruce Richardson 	RTE_ETH_DEV_UNUSED = 0,
209499a2dd95SBruce Richardson 	/** Device is attached when allocated in probing. */
209599a2dd95SBruce Richardson 	RTE_ETH_DEV_ATTACHED,
209699a2dd95SBruce Richardson 	/** Device is in removed state when plug-out is detected. */
209799a2dd95SBruce Richardson 	RTE_ETH_DEV_REMOVED,
209899a2dd95SBruce Richardson };
209999a2dd95SBruce Richardson 
210099a2dd95SBruce Richardson struct rte_eth_dev_sriov {
210199a2dd95SBruce Richardson 	uint8_t active;               /**< SRIOV is active with 16, 32 or 64 pools */
210209fd4227SAndrew Rybchenko 	uint8_t nb_q_per_pool;        /**< Rx queue number per pool */
210399a2dd95SBruce Richardson 	uint16_t def_vmdq_idx;        /**< Default pool num used for PF */
210499a2dd95SBruce Richardson 	uint16_t def_pool_q_idx;      /**< Default pool queue start reg index */
210599a2dd95SBruce Richardson };
210699a2dd95SBruce Richardson #define RTE_ETH_DEV_SRIOV(dev)         ((dev)->data->sriov)
210799a2dd95SBruce Richardson 
210899a2dd95SBruce Richardson #define RTE_ETH_NAME_MAX_LEN RTE_DEV_NAME_MAX_LEN
210999a2dd95SBruce Richardson 
211099a2dd95SBruce Richardson #define RTE_ETH_DEV_NO_OWNER 0
211199a2dd95SBruce Richardson 
211299a2dd95SBruce Richardson #define RTE_ETH_MAX_OWNER_NAME_LEN 64
211399a2dd95SBruce Richardson 
211499a2dd95SBruce Richardson struct rte_eth_dev_owner {
211599a2dd95SBruce Richardson 	uint64_t id; /**< The owner unique identifier. */
211699a2dd95SBruce Richardson 	char name[RTE_ETH_MAX_OWNER_NAME_LEN]; /**< The owner name. */
211799a2dd95SBruce Richardson };
211899a2dd95SBruce Richardson 
21190ce56b05SThomas Monjalon /**@{@name Device flags
21200ce56b05SThomas Monjalon  * Flags internally saved in rte_eth_dev_data.dev_flags
21210ce56b05SThomas Monjalon  * and reported in rte_eth_dev_info.dev_flags.
21220ce56b05SThomas Monjalon  */
212399a2dd95SBruce Richardson /** PMD supports thread-safe flow operations */
21244852c647SAndrew Rybchenko #define RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE  RTE_BIT32(0)
212599a2dd95SBruce Richardson /** Device supports link state interrupt */
21264852c647SAndrew Rybchenko #define RTE_ETH_DEV_INTR_LSC              RTE_BIT32(1)
21273084aa90SLong Wu /** Device is a bonding member */
21283084aa90SLong Wu #define RTE_ETH_DEV_BONDING_MEMBER        RTE_BIT32(2)
212999a2dd95SBruce Richardson /** Device supports device removal interrupt */
21304852c647SAndrew Rybchenko #define RTE_ETH_DEV_INTR_RMV              RTE_BIT32(3)
213199a2dd95SBruce Richardson /** Device is port representor */
21324852c647SAndrew Rybchenko #define RTE_ETH_DEV_REPRESENTOR           RTE_BIT32(4)
213399a2dd95SBruce Richardson /** Device does not support MAC change after started */
21344852c647SAndrew Rybchenko #define RTE_ETH_DEV_NOLIVE_MAC_ADDR       RTE_BIT32(5)
213599a2dd95SBruce Richardson /**
213699a2dd95SBruce Richardson  * Queue xstats filled automatically by ethdev layer.
213799a2dd95SBruce Richardson  * PMDs filling the queue xstats themselves should not set this flag
213899a2dd95SBruce Richardson  */
21394852c647SAndrew Rybchenko #define RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS RTE_BIT32(6)
21400ce56b05SThomas Monjalon /**@}*/
214199a2dd95SBruce Richardson 
214299a2dd95SBruce Richardson /**
214399a2dd95SBruce Richardson  * Iterates over valid ethdev ports owned by a specific owner.
214499a2dd95SBruce Richardson  *
214599a2dd95SBruce Richardson  * @param port_id
21465906be5aSAndrew Rybchenko  *   The ID of the next possible valid owned port.
214799a2dd95SBruce Richardson  * @param	owner_id
214899a2dd95SBruce Richardson  *  The owner identifier.
214999a2dd95SBruce Richardson  *  RTE_ETH_DEV_NO_OWNER means iterate over all valid ownerless ports.
215099a2dd95SBruce Richardson  * @return
21515906be5aSAndrew Rybchenko  *   Next valid port ID owned by owner_id, RTE_MAX_ETHPORTS if there is none.
215299a2dd95SBruce Richardson  */
215399a2dd95SBruce Richardson uint64_t rte_eth_find_next_owned_by(uint16_t port_id,
215499a2dd95SBruce Richardson 		const uint64_t owner_id);
215599a2dd95SBruce Richardson 
215699a2dd95SBruce Richardson /**
215799a2dd95SBruce Richardson  * Macro to iterate over all enabled ethdev ports owned by a specific owner.
215899a2dd95SBruce Richardson  */
215999a2dd95SBruce Richardson #define RTE_ETH_FOREACH_DEV_OWNED_BY(p, o) \
216099a2dd95SBruce Richardson 	for (p = rte_eth_find_next_owned_by(0, o); \
216199a2dd95SBruce Richardson 	     (unsigned int)p < (unsigned int)RTE_MAX_ETHPORTS; \
216299a2dd95SBruce Richardson 	     p = rte_eth_find_next_owned_by(p + 1, o))
216399a2dd95SBruce Richardson 
216499a2dd95SBruce Richardson /**
216599a2dd95SBruce Richardson  * Iterates over valid ethdev ports.
216699a2dd95SBruce Richardson  *
216799a2dd95SBruce Richardson  * @param port_id
21685906be5aSAndrew Rybchenko  *   The ID of the next possible valid port.
216999a2dd95SBruce Richardson  * @return
21705906be5aSAndrew Rybchenko  *   Next valid port ID, RTE_MAX_ETHPORTS if there is none.
217199a2dd95SBruce Richardson  */
217299a2dd95SBruce Richardson uint16_t rte_eth_find_next(uint16_t port_id);
217399a2dd95SBruce Richardson 
217499a2dd95SBruce Richardson /**
217599a2dd95SBruce Richardson  * Macro to iterate over all enabled and ownerless ethdev ports.
217699a2dd95SBruce Richardson  */
217799a2dd95SBruce Richardson #define RTE_ETH_FOREACH_DEV(p) \
217899a2dd95SBruce Richardson 	RTE_ETH_FOREACH_DEV_OWNED_BY(p, RTE_ETH_DEV_NO_OWNER)
217999a2dd95SBruce Richardson 
218099a2dd95SBruce Richardson /**
218199a2dd95SBruce Richardson  * Iterates over ethdev ports of a specified device.
218299a2dd95SBruce Richardson  *
218399a2dd95SBruce Richardson  * @param port_id_start
21845906be5aSAndrew Rybchenko  *   The ID of the next possible valid port.
218599a2dd95SBruce Richardson  * @param parent
218699a2dd95SBruce Richardson  *   The generic device behind the ports to iterate.
218799a2dd95SBruce Richardson  * @return
21885906be5aSAndrew Rybchenko  *   Next port ID of the device, possibly port_id_start,
218999a2dd95SBruce Richardson  *   RTE_MAX_ETHPORTS if there is none.
219099a2dd95SBruce Richardson  */
219199a2dd95SBruce Richardson uint16_t
219299a2dd95SBruce Richardson rte_eth_find_next_of(uint16_t port_id_start,
219399a2dd95SBruce Richardson 		const struct rte_device *parent);
219499a2dd95SBruce Richardson 
219599a2dd95SBruce Richardson /**
219699a2dd95SBruce Richardson  * Macro to iterate over all ethdev ports of a specified device.
219799a2dd95SBruce Richardson  *
219899a2dd95SBruce Richardson  * @param port_id
21995906be5aSAndrew Rybchenko  *   The ID of the matching port being iterated.
220099a2dd95SBruce Richardson  * @param parent
220199a2dd95SBruce Richardson  *   The rte_device pointer matching the iterated ports.
220299a2dd95SBruce Richardson  */
220399a2dd95SBruce Richardson #define RTE_ETH_FOREACH_DEV_OF(port_id, parent) \
220499a2dd95SBruce Richardson 	for (port_id = rte_eth_find_next_of(0, parent); \
220599a2dd95SBruce Richardson 		port_id < RTE_MAX_ETHPORTS; \
220699a2dd95SBruce Richardson 		port_id = rte_eth_find_next_of(port_id + 1, parent))
220799a2dd95SBruce Richardson 
220899a2dd95SBruce Richardson /**
220999a2dd95SBruce Richardson  * Iterates over sibling ethdev ports (i.e. sharing the same rte_device).
221099a2dd95SBruce Richardson  *
221199a2dd95SBruce Richardson  * @param port_id_start
22125906be5aSAndrew Rybchenko  *   The ID of the next possible valid sibling port.
221399a2dd95SBruce Richardson  * @param ref_port_id
22145906be5aSAndrew Rybchenko  *   The ID of a reference port to compare rte_device with.
221599a2dd95SBruce Richardson  * @return
22165906be5aSAndrew Rybchenko  *   Next sibling port ID, possibly port_id_start or ref_port_id itself,
221799a2dd95SBruce Richardson  *   RTE_MAX_ETHPORTS if there is none.
221899a2dd95SBruce Richardson  */
221999a2dd95SBruce Richardson uint16_t
222099a2dd95SBruce Richardson rte_eth_find_next_sibling(uint16_t port_id_start, uint16_t ref_port_id);
222199a2dd95SBruce Richardson 
222299a2dd95SBruce Richardson /**
222399a2dd95SBruce Richardson  * Macro to iterate over all ethdev ports sharing the same rte_device
222499a2dd95SBruce Richardson  * as the specified port.
222599a2dd95SBruce Richardson  * Note: the specified reference port is part of the loop iterations.
222699a2dd95SBruce Richardson  *
222799a2dd95SBruce Richardson  * @param port_id
22285906be5aSAndrew Rybchenko  *   The ID of the matching port being iterated.
222999a2dd95SBruce Richardson  * @param ref_port_id
22305906be5aSAndrew Rybchenko  *   The ID of the port being compared.
223199a2dd95SBruce Richardson  */
223299a2dd95SBruce Richardson #define RTE_ETH_FOREACH_DEV_SIBLING(port_id, ref_port_id) \
223399a2dd95SBruce Richardson 	for (port_id = rte_eth_find_next_sibling(0, ref_port_id); \
223499a2dd95SBruce Richardson 		port_id < RTE_MAX_ETHPORTS; \
223599a2dd95SBruce Richardson 		port_id = rte_eth_find_next_sibling(port_id + 1, ref_port_id))
223699a2dd95SBruce Richardson 
223799a2dd95SBruce Richardson /**
223899a2dd95SBruce Richardson  * Get a new unique owner identifier.
223999a2dd95SBruce Richardson  * An owner identifier is used to owns Ethernet devices by only one DPDK entity
224099a2dd95SBruce Richardson  * to avoid multiple management of device by different entities.
224199a2dd95SBruce Richardson  *
224299a2dd95SBruce Richardson  * @param	owner_id
224399a2dd95SBruce Richardson  *   Owner identifier pointer.
224499a2dd95SBruce Richardson  * @return
224599a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
224699a2dd95SBruce Richardson  */
224799a2dd95SBruce Richardson int rte_eth_dev_owner_new(uint64_t *owner_id);
224899a2dd95SBruce Richardson 
224999a2dd95SBruce Richardson /**
225099a2dd95SBruce Richardson  * Set an Ethernet device owner.
225199a2dd95SBruce Richardson  *
225299a2dd95SBruce Richardson  * @param	port_id
225399a2dd95SBruce Richardson  *  The identifier of the port to own.
225499a2dd95SBruce Richardson  * @param	owner
225599a2dd95SBruce Richardson  *  The owner pointer.
225699a2dd95SBruce Richardson  * @return
225799a2dd95SBruce Richardson  *  Negative errno value on error, 0 on success.
225899a2dd95SBruce Richardson  */
225999a2dd95SBruce Richardson int rte_eth_dev_owner_set(const uint16_t port_id,
226099a2dd95SBruce Richardson 		const struct rte_eth_dev_owner *owner);
226199a2dd95SBruce Richardson 
226299a2dd95SBruce Richardson /**
226399a2dd95SBruce Richardson  * Unset Ethernet device owner to make the device ownerless.
226499a2dd95SBruce Richardson  *
226599a2dd95SBruce Richardson  * @param	port_id
226699a2dd95SBruce Richardson  *  The identifier of port to make ownerless.
226799a2dd95SBruce Richardson  * @param	owner_id
226899a2dd95SBruce Richardson  *  The owner identifier.
226999a2dd95SBruce Richardson  * @return
227099a2dd95SBruce Richardson  *  0 on success, negative errno value on error.
227199a2dd95SBruce Richardson  */
227299a2dd95SBruce Richardson int rte_eth_dev_owner_unset(const uint16_t port_id,
227399a2dd95SBruce Richardson 		const uint64_t owner_id);
227499a2dd95SBruce Richardson 
227599a2dd95SBruce Richardson /**
227699a2dd95SBruce Richardson  * Remove owner from all Ethernet devices owned by a specific owner.
227799a2dd95SBruce Richardson  *
227899a2dd95SBruce Richardson  * @param	owner_id
227999a2dd95SBruce Richardson  *  The owner identifier.
228099a2dd95SBruce Richardson  * @return
228199a2dd95SBruce Richardson  *  0 on success, negative errno value on error.
228299a2dd95SBruce Richardson  */
228399a2dd95SBruce Richardson int rte_eth_dev_owner_delete(const uint64_t owner_id);
228499a2dd95SBruce Richardson 
228599a2dd95SBruce Richardson /**
228699a2dd95SBruce Richardson  * Get the owner of an Ethernet device.
228799a2dd95SBruce Richardson  *
228899a2dd95SBruce Richardson  * @param	port_id
228999a2dd95SBruce Richardson  *  The port identifier.
229099a2dd95SBruce Richardson  * @param	owner
229199a2dd95SBruce Richardson  *  The owner structure pointer to fill.
229299a2dd95SBruce Richardson  * @return
229399a2dd95SBruce Richardson  *  0 on success, negative errno value on error..
229499a2dd95SBruce Richardson  */
229599a2dd95SBruce Richardson int rte_eth_dev_owner_get(const uint16_t port_id,
229699a2dd95SBruce Richardson 		struct rte_eth_dev_owner *owner);
229799a2dd95SBruce Richardson 
229899a2dd95SBruce Richardson /**
229999a2dd95SBruce Richardson  * Get the number of ports which are usable for the application.
230099a2dd95SBruce Richardson  *
230199a2dd95SBruce Richardson  * These devices must be iterated by using the macro
230299a2dd95SBruce Richardson  * ``RTE_ETH_FOREACH_DEV`` or ``RTE_ETH_FOREACH_DEV_OWNED_BY``
230399a2dd95SBruce Richardson  * to deal with non-contiguous ranges of devices.
230499a2dd95SBruce Richardson  *
230599a2dd95SBruce Richardson  * @return
230699a2dd95SBruce Richardson  *   The count of available Ethernet devices.
230799a2dd95SBruce Richardson  */
230899a2dd95SBruce Richardson uint16_t rte_eth_dev_count_avail(void);
230999a2dd95SBruce Richardson 
231099a2dd95SBruce Richardson /**
231199a2dd95SBruce Richardson  * Get the total number of ports which are allocated.
231299a2dd95SBruce Richardson  *
231399a2dd95SBruce Richardson  * Some devices may not be available for the application.
231499a2dd95SBruce Richardson  *
231599a2dd95SBruce Richardson  * @return
231699a2dd95SBruce Richardson  *   The total count of Ethernet devices.
231799a2dd95SBruce Richardson  */
231899a2dd95SBruce Richardson uint16_t rte_eth_dev_count_total(void);
231999a2dd95SBruce Richardson 
232099a2dd95SBruce Richardson /**
232199a2dd95SBruce Richardson  * Convert a numerical speed in Mbps to a bitmap flag that can be used in
232299a2dd95SBruce Richardson  * the bitmap link_speeds of the struct rte_eth_conf
232399a2dd95SBruce Richardson  *
232499a2dd95SBruce Richardson  * @param speed
232599a2dd95SBruce Richardson  *   Numerical speed value in Mbps
232699a2dd95SBruce Richardson  * @param duplex
2327295968d1SFerruh Yigit  *   RTE_ETH_LINK_[HALF/FULL]_DUPLEX (only for 10/100M speeds)
232899a2dd95SBruce Richardson  * @return
232999a2dd95SBruce Richardson  *   0 if the speed cannot be mapped
233099a2dd95SBruce Richardson  */
233199a2dd95SBruce Richardson uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex);
233299a2dd95SBruce Richardson 
233399a2dd95SBruce Richardson /**
2334295968d1SFerruh Yigit  * Get RTE_ETH_RX_OFFLOAD_* flag name.
233599a2dd95SBruce Richardson  *
233699a2dd95SBruce Richardson  * @param offload
233799a2dd95SBruce Richardson  *   Offload flag.
233899a2dd95SBruce Richardson  * @return
233999a2dd95SBruce Richardson  *   Offload name or 'UNKNOWN' if the flag cannot be recognised.
234099a2dd95SBruce Richardson  */
234199a2dd95SBruce Richardson const char *rte_eth_dev_rx_offload_name(uint64_t offload);
234299a2dd95SBruce Richardson 
234399a2dd95SBruce Richardson /**
2344295968d1SFerruh Yigit  * Get RTE_ETH_TX_OFFLOAD_* flag name.
234599a2dd95SBruce Richardson  *
234699a2dd95SBruce Richardson  * @param offload
234799a2dd95SBruce Richardson  *   Offload flag.
234899a2dd95SBruce Richardson  * @return
234999a2dd95SBruce Richardson  *   Offload name or 'UNKNOWN' if the flag cannot be recognised.
235099a2dd95SBruce Richardson  */
235199a2dd95SBruce Richardson const char *rte_eth_dev_tx_offload_name(uint64_t offload);
235299a2dd95SBruce Richardson 
235399a2dd95SBruce Richardson /**
235493e441c9SXueming Li  * @warning
235593e441c9SXueming Li  * @b EXPERIMENTAL: this API may change without prior notice.
235693e441c9SXueming Li  *
235793e441c9SXueming Li  * Get RTE_ETH_DEV_CAPA_* flag name.
235893e441c9SXueming Li  *
235993e441c9SXueming Li  * @param capability
236093e441c9SXueming Li  *   Capability flag.
236193e441c9SXueming Li  * @return
236293e441c9SXueming Li  *   Capability name or 'UNKNOWN' if the flag cannot be recognized.
236393e441c9SXueming Li  */
236493e441c9SXueming Li __rte_experimental
236593e441c9SXueming Li const char *rte_eth_dev_capability_name(uint64_t capability);
236693e441c9SXueming Li 
236793e441c9SXueming Li /**
236899a2dd95SBruce Richardson  * Configure an Ethernet device.
236999a2dd95SBruce Richardson  * This function must be invoked first before any other function in the
237099a2dd95SBruce Richardson  * Ethernet API. This function can also be re-invoked when a device is in the
237199a2dd95SBruce Richardson  * stopped state.
237299a2dd95SBruce Richardson  *
237399a2dd95SBruce Richardson  * @param port_id
237499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device to configure.
237599a2dd95SBruce Richardson  * @param nb_rx_queue
237699a2dd95SBruce Richardson  *   The number of receive queues to set up for the Ethernet device.
237799a2dd95SBruce Richardson  * @param nb_tx_queue
237899a2dd95SBruce Richardson  *   The number of transmit queues to set up for the Ethernet device.
237999a2dd95SBruce Richardson  * @param eth_conf
238099a2dd95SBruce Richardson  *   The pointer to the configuration data to be used for the Ethernet device.
238199a2dd95SBruce Richardson  *   The *rte_eth_conf* structure includes:
238299a2dd95SBruce Richardson  *     -  the hardware offload features to activate, with dedicated fields for
238399a2dd95SBruce Richardson  *        each statically configurable offload hardware feature provided by
238499a2dd95SBruce Richardson  *        Ethernet devices, such as IP checksum or VLAN tag stripping for
238599a2dd95SBruce Richardson  *        example.
238699a2dd95SBruce Richardson  *        The Rx offload bitfield API is obsolete and will be deprecated.
238799a2dd95SBruce Richardson  *        Applications should set the ignore_bitfield_offloads bit on *rxmode*
238899a2dd95SBruce Richardson  *        structure and use offloads field to set per-port offloads instead.
238999a2dd95SBruce Richardson  *     -  Any offloading set in eth_conf->[rt]xmode.offloads must be within
239099a2dd95SBruce Richardson  *        the [rt]x_offload_capa returned from rte_eth_dev_info_get().
239199a2dd95SBruce Richardson  *        Any type of device supported offloading set in the input argument
239299a2dd95SBruce Richardson  *        eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is enabled
239399a2dd95SBruce Richardson  *        on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup()
239409fd4227SAndrew Rybchenko  *     -  the Receive Side Scaling (RSS) configuration when using multiple Rx
239599a2dd95SBruce Richardson  *        queues per port. Any RSS hash function set in eth_conf->rss_conf.rss_hf
239699a2dd95SBruce Richardson  *        must be within the flow_type_rss_offloads provided by drivers via
239799a2dd95SBruce Richardson  *        rte_eth_dev_info_get() API.
239899a2dd95SBruce Richardson  *
239999a2dd95SBruce Richardson  *   Embedding all configuration information in a single data structure
240099a2dd95SBruce Richardson  *   is the more flexible method that allows the addition of new features
240199a2dd95SBruce Richardson  *   without changing the syntax of the API.
240299a2dd95SBruce Richardson  * @return
240399a2dd95SBruce Richardson  *   - 0: Success, device configured.
240499a2dd95SBruce Richardson  *   - <0: Error code returned by the driver configuration function.
240599a2dd95SBruce Richardson  */
240699a2dd95SBruce Richardson int rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_queue,
240799a2dd95SBruce Richardson 		uint16_t nb_tx_queue, const struct rte_eth_conf *eth_conf);
240899a2dd95SBruce Richardson 
240999a2dd95SBruce Richardson /**
241099a2dd95SBruce Richardson  * Check if an Ethernet device was physically removed.
241199a2dd95SBruce Richardson  *
241299a2dd95SBruce Richardson  * @param port_id
241399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
241499a2dd95SBruce Richardson  * @return
241599a2dd95SBruce Richardson  *   1 when the Ethernet device is removed, otherwise 0.
241699a2dd95SBruce Richardson  */
241799a2dd95SBruce Richardson int
241899a2dd95SBruce Richardson rte_eth_dev_is_removed(uint16_t port_id);
241999a2dd95SBruce Richardson 
242099a2dd95SBruce Richardson /**
242199a2dd95SBruce Richardson  * Allocate and set up a receive queue for an Ethernet device.
242299a2dd95SBruce Richardson  *
242399a2dd95SBruce Richardson  * The function allocates a contiguous block of memory for *nb_rx_desc*
242499a2dd95SBruce Richardson  * receive descriptors from a memory zone associated with *socket_id*
242599a2dd95SBruce Richardson  * and initializes each receive descriptor with a network buffer allocated
242699a2dd95SBruce Richardson  * from the memory pool *mb_pool*.
242799a2dd95SBruce Richardson  *
242899a2dd95SBruce Richardson  * @param port_id
242999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
243099a2dd95SBruce Richardson  * @param rx_queue_id
243199a2dd95SBruce Richardson  *   The index of the receive queue to set up.
243299a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
243399a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
243499a2dd95SBruce Richardson  * @param nb_rx_desc
243599a2dd95SBruce Richardson  *   The number of receive descriptors to allocate for the receive ring.
243699a2dd95SBruce Richardson  * @param socket_id
243799a2dd95SBruce Richardson  *   The *socket_id* argument is the socket identifier in case of NUMA.
243899a2dd95SBruce Richardson  *   The value can be *SOCKET_ID_ANY* if there is no NUMA constraint for
243999a2dd95SBruce Richardson  *   the DMA memory allocated for the receive descriptors of the ring.
244099a2dd95SBruce Richardson  * @param rx_conf
244199a2dd95SBruce Richardson  *   The pointer to the configuration data to be used for the receive queue.
244209fd4227SAndrew Rybchenko  *   NULL value is allowed, in which case default Rx configuration
244399a2dd95SBruce Richardson  *   will be used.
244499a2dd95SBruce Richardson  *   The *rx_conf* structure contains an *rx_thresh* structure with the values
244599a2dd95SBruce Richardson  *   of the Prefetch, Host, and Write-Back threshold registers of the receive
244699a2dd95SBruce Richardson  *   ring.
244799a2dd95SBruce Richardson  *   In addition it contains the hardware offloads features to activate using
2448295968d1SFerruh Yigit  *   the RTE_ETH_RX_OFFLOAD_* flags.
244999a2dd95SBruce Richardson  *   If an offloading set in rx_conf->offloads
245099a2dd95SBruce Richardson  *   hasn't been set in the input argument eth_conf->rxmode.offloads
245199a2dd95SBruce Richardson  *   to rte_eth_dev_configure(), it is a new added offloading, it must be
245299a2dd95SBruce Richardson  *   per-queue type and it is enabled for the queue.
245399a2dd95SBruce Richardson  *   No need to repeat any bit in rx_conf->offloads which has already been
245499a2dd95SBruce Richardson  *   enabled in rte_eth_dev_configure() at port level. An offloading enabled
245599a2dd95SBruce Richardson  *   at port level can't be disabled at queue level.
245699a2dd95SBruce Richardson  *   The configuration structure also contains the pointer to the array
245799a2dd95SBruce Richardson  *   of the receiving buffer segment descriptions, see rx_seg and rx_nseg
245899a2dd95SBruce Richardson  *   fields, this extended configuration might be used by split offloads like
245997d7b927SJoyce Kong  *   RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT. If mb_pool is not NULL,
246099a2dd95SBruce Richardson  *   the extended configuration fields must be set to NULL and zero.
246199a2dd95SBruce Richardson  * @param mb_pool
246299a2dd95SBruce Richardson  *   The pointer to the memory pool from which to allocate *rte_mbuf* network
246399a2dd95SBruce Richardson  *   memory buffers to populate each descriptor of the receive ring. There are
246499a2dd95SBruce Richardson  *   two options to provide Rx buffer configuration:
246599a2dd95SBruce Richardson  *   - single pool:
246699a2dd95SBruce Richardson  *     mb_pool is not NULL, rx_conf.rx_nseg is 0.
246799a2dd95SBruce Richardson  *   - multiple segments description:
246899a2dd95SBruce Richardson  *     mb_pool is NULL, rx_conf.rx_seg is not NULL, rx_conf.rx_nseg is not 0.
246999a2dd95SBruce Richardson  *     Taken only if flag RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is set in offloads.
247099a2dd95SBruce Richardson  *
247199a2dd95SBruce Richardson  * @return
247299a2dd95SBruce Richardson  *   - 0: Success, receive queue correctly set up.
247399a2dd95SBruce Richardson  *   - -EIO: if device is removed.
247499a2dd95SBruce Richardson  *   - -ENODEV: if *port_id* is invalid.
247599a2dd95SBruce Richardson  *   - -EINVAL: The memory pool pointer is null or the size of network buffers
247699a2dd95SBruce Richardson  *      which can be allocated from this memory pool does not fit the various
247799a2dd95SBruce Richardson  *      buffer sizes allowed by the device controller.
247899a2dd95SBruce Richardson  *   - -ENOMEM: Unable to allocate the receive ring descriptors or to
247999a2dd95SBruce Richardson  *      allocate network memory buffers from the memory pool when
248099a2dd95SBruce Richardson  *      initializing receive descriptors.
248199a2dd95SBruce Richardson  */
248299a2dd95SBruce Richardson int rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
248399a2dd95SBruce Richardson 		uint16_t nb_rx_desc, unsigned int socket_id,
248499a2dd95SBruce Richardson 		const struct rte_eth_rxconf *rx_conf,
248599a2dd95SBruce Richardson 		struct rte_mempool *mb_pool);
248699a2dd95SBruce Richardson 
248799a2dd95SBruce Richardson /**
248899a2dd95SBruce Richardson  * @warning
248999a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
249099a2dd95SBruce Richardson  *
249199a2dd95SBruce Richardson  * Allocate and set up a hairpin receive queue for an Ethernet device.
249299a2dd95SBruce Richardson  *
249399a2dd95SBruce Richardson  * The function set up the selected queue to be used in hairpin.
249499a2dd95SBruce Richardson  *
249599a2dd95SBruce Richardson  * @param port_id
249699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
249799a2dd95SBruce Richardson  * @param rx_queue_id
249899a2dd95SBruce Richardson  *   The index of the receive queue to set up.
249999a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
250099a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
250199a2dd95SBruce Richardson  * @param nb_rx_desc
250299a2dd95SBruce Richardson  *   The number of receive descriptors to allocate for the receive ring.
250399a2dd95SBruce Richardson  *   0 means the PMD will use default value.
250499a2dd95SBruce Richardson  * @param conf
250599a2dd95SBruce Richardson  *   The pointer to the hairpin configuration.
250699a2dd95SBruce Richardson  *
250799a2dd95SBruce Richardson  * @return
250899a2dd95SBruce Richardson  *   - (0) if successful.
250999a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
251099a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
251199a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
251299a2dd95SBruce Richardson  *   - (-ENOMEM) if unable to allocate the resources.
251399a2dd95SBruce Richardson  */
251499a2dd95SBruce Richardson __rte_experimental
251599a2dd95SBruce Richardson int rte_eth_rx_hairpin_queue_setup
251699a2dd95SBruce Richardson 	(uint16_t port_id, uint16_t rx_queue_id, uint16_t nb_rx_desc,
251799a2dd95SBruce Richardson 	 const struct rte_eth_hairpin_conf *conf);
251899a2dd95SBruce Richardson 
251999a2dd95SBruce Richardson /**
252099a2dd95SBruce Richardson  * Allocate and set up a transmit queue for an Ethernet device.
252199a2dd95SBruce Richardson  *
252299a2dd95SBruce Richardson  * @param port_id
252399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
252499a2dd95SBruce Richardson  * @param tx_queue_id
252599a2dd95SBruce Richardson  *   The index of the transmit queue to set up.
252699a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
252799a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
252899a2dd95SBruce Richardson  * @param nb_tx_desc
252999a2dd95SBruce Richardson  *   The number of transmit descriptors to allocate for the transmit ring.
253099a2dd95SBruce Richardson  * @param socket_id
253199a2dd95SBruce Richardson  *   The *socket_id* argument is the socket identifier in case of NUMA.
253299a2dd95SBruce Richardson  *   Its value can be *SOCKET_ID_ANY* if there is no NUMA constraint for
253399a2dd95SBruce Richardson  *   the DMA memory allocated for the transmit descriptors of the ring.
253499a2dd95SBruce Richardson  * @param tx_conf
253599a2dd95SBruce Richardson  *   The pointer to the configuration data to be used for the transmit queue.
253609fd4227SAndrew Rybchenko  *   NULL value is allowed, in which case default Tx configuration
253799a2dd95SBruce Richardson  *   will be used.
253899a2dd95SBruce Richardson  *   The *tx_conf* structure contains the following data:
253999a2dd95SBruce Richardson  *   - The *tx_thresh* structure with the values of the Prefetch, Host, and
254099a2dd95SBruce Richardson  *     Write-Back threshold registers of the transmit ring.
254199a2dd95SBruce Richardson  *     When setting Write-Back threshold to the value greater then zero,
254299a2dd95SBruce Richardson  *     *tx_rs_thresh* value should be explicitly set to one.
254399a2dd95SBruce Richardson  *   - The *tx_free_thresh* value indicates the [minimum] number of network
254499a2dd95SBruce Richardson  *     buffers that must be pending in the transmit ring to trigger their
254599a2dd95SBruce Richardson  *     [implicit] freeing by the driver transmit function.
254699a2dd95SBruce Richardson  *   - The *tx_rs_thresh* value indicates the [minimum] number of transmit
254799a2dd95SBruce Richardson  *     descriptors that must be pending in the transmit ring before setting the
254899a2dd95SBruce Richardson  *     RS bit on a descriptor by the driver transmit function.
254999a2dd95SBruce Richardson  *     The *tx_rs_thresh* value should be less or equal then
255099a2dd95SBruce Richardson  *     *tx_free_thresh* value, and both of them should be less then
255199a2dd95SBruce Richardson  *     *nb_tx_desc* - 3.
255299a2dd95SBruce Richardson  *   - The *offloads* member contains Tx offloads to be enabled.
255399a2dd95SBruce Richardson  *     If an offloading set in tx_conf->offloads
255499a2dd95SBruce Richardson  *     hasn't been set in the input argument eth_conf->txmode.offloads
255599a2dd95SBruce Richardson  *     to rte_eth_dev_configure(), it is a new added offloading, it must be
255699a2dd95SBruce Richardson  *     per-queue type and it is enabled for the queue.
255799a2dd95SBruce Richardson  *     No need to repeat any bit in tx_conf->offloads which has already been
255899a2dd95SBruce Richardson  *     enabled in rte_eth_dev_configure() at port level. An offloading enabled
255999a2dd95SBruce Richardson  *     at port level can't be disabled at queue level.
256099a2dd95SBruce Richardson  *
256199a2dd95SBruce Richardson  *     Note that setting *tx_free_thresh* or *tx_rs_thresh* value to 0 forces
256299a2dd95SBruce Richardson  *     the transmit function to use default values.
256399a2dd95SBruce Richardson  * @return
256499a2dd95SBruce Richardson  *   - 0: Success, the transmit queue is correctly set up.
256599a2dd95SBruce Richardson  *   - -ENOMEM: Unable to allocate the transmit ring descriptors.
256699a2dd95SBruce Richardson  */
256799a2dd95SBruce Richardson int rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
256899a2dd95SBruce Richardson 		uint16_t nb_tx_desc, unsigned int socket_id,
256999a2dd95SBruce Richardson 		const struct rte_eth_txconf *tx_conf);
257099a2dd95SBruce Richardson 
257199a2dd95SBruce Richardson /**
257299a2dd95SBruce Richardson  * @warning
257399a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
257499a2dd95SBruce Richardson  *
257599a2dd95SBruce Richardson  * Allocate and set up a transmit hairpin queue for an Ethernet device.
257699a2dd95SBruce Richardson  *
257799a2dd95SBruce Richardson  * @param port_id
257899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
257999a2dd95SBruce Richardson  * @param tx_queue_id
258099a2dd95SBruce Richardson  *   The index of the transmit queue to set up.
258199a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
258299a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
258399a2dd95SBruce Richardson  * @param nb_tx_desc
258499a2dd95SBruce Richardson  *   The number of transmit descriptors to allocate for the transmit ring.
258599a2dd95SBruce Richardson  *   0 to set default PMD value.
258699a2dd95SBruce Richardson  * @param conf
258799a2dd95SBruce Richardson  *   The hairpin configuration.
258899a2dd95SBruce Richardson  *
258999a2dd95SBruce Richardson  * @return
259099a2dd95SBruce Richardson  *   - (0) if successful.
259199a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
259299a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
259399a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
259499a2dd95SBruce Richardson  *   - (-ENOMEM) if unable to allocate the resources.
259599a2dd95SBruce Richardson  */
259699a2dd95SBruce Richardson __rte_experimental
259799a2dd95SBruce Richardson int rte_eth_tx_hairpin_queue_setup
259899a2dd95SBruce Richardson 	(uint16_t port_id, uint16_t tx_queue_id, uint16_t nb_tx_desc,
259999a2dd95SBruce Richardson 	 const struct rte_eth_hairpin_conf *conf);
260099a2dd95SBruce Richardson 
260199a2dd95SBruce Richardson /**
260299a2dd95SBruce Richardson  * @warning
260399a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
260499a2dd95SBruce Richardson  *
260599a2dd95SBruce Richardson  * Get all the hairpin peer Rx / Tx ports of the current port.
260699a2dd95SBruce Richardson  * The caller should ensure that the array is large enough to save the ports
260799a2dd95SBruce Richardson  * list.
260899a2dd95SBruce Richardson  *
260999a2dd95SBruce Richardson  * @param port_id
261099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
261199a2dd95SBruce Richardson  * @param peer_ports
261299a2dd95SBruce Richardson  *   Pointer to the array to store the peer ports list.
261399a2dd95SBruce Richardson  * @param len
261499a2dd95SBruce Richardson  *   Length of the array to store the port identifiers.
261599a2dd95SBruce Richardson  * @param direction
261699a2dd95SBruce Richardson  *   Current port to peer port direction
261799a2dd95SBruce Richardson  *   positive - current used as Tx to get all peer Rx ports.
261899a2dd95SBruce Richardson  *   zero - current used as Rx to get all peer Tx ports.
261999a2dd95SBruce Richardson  *
262099a2dd95SBruce Richardson  * @return
262199a2dd95SBruce Richardson  *   - (0 or positive) actual peer ports number.
262299a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
262399a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid
262499a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
2625f8dbaebbSSean Morrissey  *   - Others detailed errors from PMDs.
262699a2dd95SBruce Richardson  */
262799a2dd95SBruce Richardson __rte_experimental
262899a2dd95SBruce Richardson int rte_eth_hairpin_get_peer_ports(uint16_t port_id, uint16_t *peer_ports,
262999a2dd95SBruce Richardson 				   size_t len, uint32_t direction);
263099a2dd95SBruce Richardson 
263199a2dd95SBruce Richardson /**
263299a2dd95SBruce Richardson  * @warning
263399a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
263499a2dd95SBruce Richardson  *
263599a2dd95SBruce Richardson  * Bind all hairpin Tx queues of one port to the Rx queues of the peer port.
263699a2dd95SBruce Richardson  * It is only allowed to call this function after all hairpin queues are
263799a2dd95SBruce Richardson  * configured properly and the devices are in started state.
263899a2dd95SBruce Richardson  *
263999a2dd95SBruce Richardson  * @param tx_port
264099a2dd95SBruce Richardson  *   The identifier of the Tx port.
264199a2dd95SBruce Richardson  * @param rx_port
264299a2dd95SBruce Richardson  *   The identifier of peer Rx port.
264399a2dd95SBruce Richardson  *   RTE_MAX_ETHPORTS is allowed for the traversal of all devices.
264499a2dd95SBruce Richardson  *   Rx port ID could have the same value as Tx port ID.
264599a2dd95SBruce Richardson  *
264699a2dd95SBruce Richardson  * @return
264799a2dd95SBruce Richardson  *   - (0) if successful.
264899a2dd95SBruce Richardson  *   - (-ENODEV) if Tx port ID is invalid.
264999a2dd95SBruce Richardson  *   - (-EBUSY) if device is not in started state.
265099a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
2651f8dbaebbSSean Morrissey  *   - Others detailed errors from PMDs.
265299a2dd95SBruce Richardson  */
265399a2dd95SBruce Richardson __rte_experimental
265499a2dd95SBruce Richardson int rte_eth_hairpin_bind(uint16_t tx_port, uint16_t rx_port);
265599a2dd95SBruce Richardson 
265699a2dd95SBruce Richardson /**
265799a2dd95SBruce Richardson  * @warning
265899a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
265999a2dd95SBruce Richardson  *
266099a2dd95SBruce Richardson  * Unbind all hairpin Tx queues of one port from the Rx queues of the peer port.
266199a2dd95SBruce Richardson  * This should be called before closing the Tx or Rx devices, if the bind
266299a2dd95SBruce Richardson  * function is called before.
266399a2dd95SBruce Richardson  * After unbinding the hairpin ports pair, it is allowed to bind them again.
266499a2dd95SBruce Richardson  * Changing queues configuration should be after stopping the device(s).
266599a2dd95SBruce Richardson  *
266699a2dd95SBruce Richardson  * @param tx_port
266799a2dd95SBruce Richardson  *   The identifier of the Tx port.
266899a2dd95SBruce Richardson  * @param rx_port
266999a2dd95SBruce Richardson  *   The identifier of peer Rx port.
267099a2dd95SBruce Richardson  *   RTE_MAX_ETHPORTS is allowed for traversal of all devices.
267199a2dd95SBruce Richardson  *   Rx port ID could have the same value as Tx port ID.
267299a2dd95SBruce Richardson  *
267399a2dd95SBruce Richardson  * @return
267499a2dd95SBruce Richardson  *   - (0) if successful.
267599a2dd95SBruce Richardson  *   - (-ENODEV) if Tx port ID is invalid.
267699a2dd95SBruce Richardson  *   - (-EBUSY) if device is in stopped state.
267799a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
2678f8dbaebbSSean Morrissey  *   - Others detailed errors from PMDs.
267999a2dd95SBruce Richardson  */
268099a2dd95SBruce Richardson __rte_experimental
268199a2dd95SBruce Richardson int rte_eth_hairpin_unbind(uint16_t tx_port, uint16_t rx_port);
268299a2dd95SBruce Richardson 
268399a2dd95SBruce Richardson /**
268406ea5479SJiawei Wang  * @warning
268506ea5479SJiawei Wang  * @b EXPERIMENTAL: this API may change without prior notice.
268606ea5479SJiawei Wang  *
268706ea5479SJiawei Wang  *  Get the number of aggregated ports of the DPDK port (specified with port_id).
268806ea5479SJiawei Wang  *  It is used when multiple ports are aggregated into a single one.
268906ea5479SJiawei Wang  *
269006ea5479SJiawei Wang  *  For the regular physical port doesn't have aggregated ports,
269106ea5479SJiawei Wang  *  the number of aggregated ports is reported as 0.
269206ea5479SJiawei Wang  *
269306ea5479SJiawei Wang  * @param port_id
269406ea5479SJiawei Wang  *   The port identifier of the Ethernet device.
269506ea5479SJiawei Wang  * @return
269606ea5479SJiawei Wang  *   - (>=0) the number of aggregated port if success.
269706ea5479SJiawei Wang  */
269806ea5479SJiawei Wang __rte_experimental
269906ea5479SJiawei Wang int rte_eth_dev_count_aggr_ports(uint16_t port_id);
270006ea5479SJiawei Wang 
270106ea5479SJiawei Wang /**
270206ea5479SJiawei Wang  * @warning
270306ea5479SJiawei Wang  * @b EXPERIMENTAL: this API may change without prior notice.
270406ea5479SJiawei Wang  *
270506ea5479SJiawei Wang  *  Map a Tx queue with an aggregated port of the DPDK port (specified with port_id).
270606ea5479SJiawei Wang  *  When multiple ports are aggregated into a single one,
270706ea5479SJiawei Wang  *  it allows to choose which port to use for Tx via a queue.
270806ea5479SJiawei Wang  *
270906ea5479SJiawei Wang  *  The application should use rte_eth_dev_map_aggr_tx_affinity()
271006ea5479SJiawei Wang  *  after rte_eth_dev_configure(), rte_eth_tx_queue_setup(), and
271106ea5479SJiawei Wang  *  before rte_eth_dev_start().
271206ea5479SJiawei Wang  *
271306ea5479SJiawei Wang  * @param port_id
271406ea5479SJiawei Wang  *   The identifier of the port used in rte_eth_tx_burst().
271506ea5479SJiawei Wang  * @param tx_queue_id
271606ea5479SJiawei Wang  *   The index of the transmit queue used in rte_eth_tx_burst().
271706ea5479SJiawei Wang  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
271806ea5479SJiawei Wang  *   to rte_eth_dev_configure().
271906ea5479SJiawei Wang  * @param affinity
272006ea5479SJiawei Wang  *   The number of the aggregated port.
272106ea5479SJiawei Wang  *   Value 0 means no affinity and traffic could be routed to any aggregated port.
272206ea5479SJiawei Wang  *   The first aggregated port is number 1 and so on.
272306ea5479SJiawei Wang  *   The maximum number is given by rte_eth_dev_count_aggr_ports().
272406ea5479SJiawei Wang  *
272506ea5479SJiawei Wang  * @return
272606ea5479SJiawei Wang  *   Zero if successful. Non-zero otherwise.
272706ea5479SJiawei Wang  */
272806ea5479SJiawei Wang __rte_experimental
272906ea5479SJiawei Wang int rte_eth_dev_map_aggr_tx_affinity(uint16_t port_id, uint16_t tx_queue_id,
273006ea5479SJiawei Wang 				     uint8_t affinity);
273106ea5479SJiawei Wang 
273206ea5479SJiawei Wang /**
273399a2dd95SBruce Richardson  * Return the NUMA socket to which an Ethernet device is connected
273499a2dd95SBruce Richardson  *
273599a2dd95SBruce Richardson  * @param port_id
273699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device
273799a2dd95SBruce Richardson  * @return
27387dcd73e3SOlivier Matz  *   - The NUMA socket ID which the Ethernet device is connected to.
27397dcd73e3SOlivier Matz  *   - -1 (which translates to SOCKET_ID_ANY) if the socket could not be
27407dcd73e3SOlivier Matz  *     determined. rte_errno is then set to:
27417dcd73e3SOlivier Matz  *     - EINVAL is the port_id is invalid,
27427dcd73e3SOlivier Matz  *     - 0 is the socket could not be determined,
274399a2dd95SBruce Richardson  */
274499a2dd95SBruce Richardson int rte_eth_dev_socket_id(uint16_t port_id);
274599a2dd95SBruce Richardson 
274699a2dd95SBruce Richardson /**
274799a2dd95SBruce Richardson  * Check if port_id of device is attached
274899a2dd95SBruce Richardson  *
274999a2dd95SBruce Richardson  * @param port_id
275099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device
275199a2dd95SBruce Richardson  * @return
275299a2dd95SBruce Richardson  *   - 0 if port is out of range or not attached
275399a2dd95SBruce Richardson  *   - 1 if device is attached
275499a2dd95SBruce Richardson  */
275599a2dd95SBruce Richardson int rte_eth_dev_is_valid_port(uint16_t port_id);
275699a2dd95SBruce Richardson 
275799a2dd95SBruce Richardson /**
27587ea7e0cdSDengdui Huang  * @warning
27597ea7e0cdSDengdui Huang  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice.
27607ea7e0cdSDengdui Huang  *
27617ea7e0cdSDengdui Huang  * Check if Rx queue is valid.
27627ea7e0cdSDengdui Huang  * If the queue has been setup, it is considered valid.
27637ea7e0cdSDengdui Huang  *
27647ea7e0cdSDengdui Huang  * @param port_id
27657ea7e0cdSDengdui Huang  *   The port identifier of the Ethernet device.
27667ea7e0cdSDengdui Huang  * @param queue_id
27677ea7e0cdSDengdui Huang  *   The index of the receive queue.
27687ea7e0cdSDengdui Huang  * @return
27697ea7e0cdSDengdui Huang  *   - -ENODEV: if port_id is invalid.
27707ea7e0cdSDengdui Huang  *   - -EINVAL: if queue_id is out of range or queue has not been setup.
27717ea7e0cdSDengdui Huang  *   - 0 if Rx queue is valid.
27727ea7e0cdSDengdui Huang  */
27737ea7e0cdSDengdui Huang __rte_experimental
277466a1e115SThomas Monjalon int rte_eth_rx_queue_is_valid(uint16_t port_id, uint16_t queue_id);
27757ea7e0cdSDengdui Huang 
27767ea7e0cdSDengdui Huang /**
27777ea7e0cdSDengdui Huang  * @warning
27787ea7e0cdSDengdui Huang  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice.
27797ea7e0cdSDengdui Huang  *
27807ea7e0cdSDengdui Huang  * Check if Tx queue is valid.
27817ea7e0cdSDengdui Huang  * If the queue has been setup, it is considered valid.
27827ea7e0cdSDengdui Huang  *
27837ea7e0cdSDengdui Huang  * @param port_id
27847ea7e0cdSDengdui Huang  *   The port identifier of the Ethernet device.
27857ea7e0cdSDengdui Huang  * @param queue_id
27867ea7e0cdSDengdui Huang  *   The index of the transmit queue.
27877ea7e0cdSDengdui Huang  * @return
27887ea7e0cdSDengdui Huang  *   - -ENODEV: if port_id is invalid.
27897ea7e0cdSDengdui Huang  *   - -EINVAL: if queue_id is out of range or queue has not been setup.
27907ea7e0cdSDengdui Huang  *   - 0 if Tx queue is valid.
27917ea7e0cdSDengdui Huang  */
27927ea7e0cdSDengdui Huang __rte_experimental
279366a1e115SThomas Monjalon int rte_eth_tx_queue_is_valid(uint16_t port_id, uint16_t queue_id);
27947ea7e0cdSDengdui Huang 
27957ea7e0cdSDengdui Huang /**
279609fd4227SAndrew Rybchenko  * Start specified Rx queue of a port. It is used when rx_deferred_start
279799a2dd95SBruce Richardson  * flag of the specified queue is true.
279899a2dd95SBruce Richardson  *
279999a2dd95SBruce Richardson  * @param port_id
280099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device
280199a2dd95SBruce Richardson  * @param rx_queue_id
280209fd4227SAndrew Rybchenko  *   The index of the Rx queue to update the ring.
280399a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
280499a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
280599a2dd95SBruce Richardson  * @return
280699a2dd95SBruce Richardson  *   - 0: Success, the receive queue is started.
280799a2dd95SBruce Richardson  *   - -ENODEV: if *port_id* is invalid.
280899a2dd95SBruce Richardson  *   - -EINVAL: The queue_id out of range or belong to hairpin.
280999a2dd95SBruce Richardson  *   - -EIO: if device is removed.
2810f8dbaebbSSean Morrissey  *   - -ENOTSUP: The function not supported in PMD.
281199a2dd95SBruce Richardson  */
281299a2dd95SBruce Richardson int rte_eth_dev_rx_queue_start(uint16_t port_id, uint16_t rx_queue_id);
281399a2dd95SBruce Richardson 
281499a2dd95SBruce Richardson /**
281509fd4227SAndrew Rybchenko  * Stop specified Rx queue of a port
281699a2dd95SBruce Richardson  *
281799a2dd95SBruce Richardson  * @param port_id
281899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device
281999a2dd95SBruce Richardson  * @param rx_queue_id
282009fd4227SAndrew Rybchenko  *   The index of the Rx queue to update the ring.
282199a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
282299a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
282399a2dd95SBruce Richardson  * @return
282499a2dd95SBruce Richardson  *   - 0: Success, the receive queue is stopped.
282599a2dd95SBruce Richardson  *   - -ENODEV: if *port_id* is invalid.
282699a2dd95SBruce Richardson  *   - -EINVAL: The queue_id out of range or belong to hairpin.
282799a2dd95SBruce Richardson  *   - -EIO: if device is removed.
2828f8dbaebbSSean Morrissey  *   - -ENOTSUP: The function not supported in PMD.
282999a2dd95SBruce Richardson  */
283099a2dd95SBruce Richardson int rte_eth_dev_rx_queue_stop(uint16_t port_id, uint16_t rx_queue_id);
283199a2dd95SBruce Richardson 
283299a2dd95SBruce Richardson /**
283309fd4227SAndrew Rybchenko  * Start Tx for specified queue of a port. It is used when tx_deferred_start
283499a2dd95SBruce Richardson  * flag of the specified queue is true.
283599a2dd95SBruce Richardson  *
283699a2dd95SBruce Richardson  * @param port_id
283799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device
283899a2dd95SBruce Richardson  * @param tx_queue_id
283909fd4227SAndrew Rybchenko  *   The index of the Tx queue to update the ring.
284099a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
284199a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
284299a2dd95SBruce Richardson  * @return
284399a2dd95SBruce Richardson  *   - 0: Success, the transmit queue is started.
284499a2dd95SBruce Richardson  *   - -ENODEV: if *port_id* is invalid.
284599a2dd95SBruce Richardson  *   - -EINVAL: The queue_id out of range or belong to hairpin.
284699a2dd95SBruce Richardson  *   - -EIO: if device is removed.
2847f8dbaebbSSean Morrissey  *   - -ENOTSUP: The function not supported in PMD.
284899a2dd95SBruce Richardson  */
284999a2dd95SBruce Richardson int rte_eth_dev_tx_queue_start(uint16_t port_id, uint16_t tx_queue_id);
285099a2dd95SBruce Richardson 
285199a2dd95SBruce Richardson /**
285209fd4227SAndrew Rybchenko  * Stop specified Tx queue of a port
285399a2dd95SBruce Richardson  *
285499a2dd95SBruce Richardson  * @param port_id
285599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device
285699a2dd95SBruce Richardson  * @param tx_queue_id
285709fd4227SAndrew Rybchenko  *   The index of the Tx queue to update the ring.
285899a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
285999a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
286099a2dd95SBruce Richardson  * @return
286199a2dd95SBruce Richardson  *   - 0: Success, the transmit queue is stopped.
286299a2dd95SBruce Richardson  *   - -ENODEV: if *port_id* is invalid.
286399a2dd95SBruce Richardson  *   - -EINVAL: The queue_id out of range or belong to hairpin.
286499a2dd95SBruce Richardson  *   - -EIO: if device is removed.
2865f8dbaebbSSean Morrissey  *   - -ENOTSUP: The function not supported in PMD.
286699a2dd95SBruce Richardson  */
286799a2dd95SBruce Richardson int rte_eth_dev_tx_queue_stop(uint16_t port_id, uint16_t tx_queue_id);
286899a2dd95SBruce Richardson 
286999a2dd95SBruce Richardson /**
287099a2dd95SBruce Richardson  * Start an Ethernet device.
287199a2dd95SBruce Richardson  *
287299a2dd95SBruce Richardson  * The device start step is the last one and consists of setting the configured
287399a2dd95SBruce Richardson  * offload features and in starting the transmit and the receive units of the
287499a2dd95SBruce Richardson  * device.
287599a2dd95SBruce Richardson  *
287699a2dd95SBruce Richardson  * Device RTE_ETH_DEV_NOLIVE_MAC_ADDR flag causes MAC address to be set before
287799a2dd95SBruce Richardson  * PMD port start callback function is invoked.
287899a2dd95SBruce Richardson  *
28792834e6ddSFerruh Yigit  * All device queues (except form deferred start queues) status should be
28802834e6ddSFerruh Yigit  * `RTE_ETH_QUEUE_STATE_STARTED` after start.
28812834e6ddSFerruh Yigit  *
288299a2dd95SBruce Richardson  * On success, all basic functions exported by the Ethernet API (link status,
288399a2dd95SBruce Richardson  * receive/transmit, and so on) can be invoked.
288499a2dd95SBruce Richardson  *
288599a2dd95SBruce Richardson  * @param port_id
288699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
288799a2dd95SBruce Richardson  * @return
288899a2dd95SBruce Richardson  *   - 0: Success, Ethernet device started.
288947a4e1fbSDariusz Sosnowski  *   - -EAGAIN: If start operation must be retried.
289099a2dd95SBruce Richardson  *   - <0: Error code of the driver device start function.
289199a2dd95SBruce Richardson  */
289299a2dd95SBruce Richardson int rte_eth_dev_start(uint16_t port_id);
289399a2dd95SBruce Richardson 
289499a2dd95SBruce Richardson /**
289599a2dd95SBruce Richardson  * Stop an Ethernet device. The device can be restarted with a call to
289699a2dd95SBruce Richardson  * rte_eth_dev_start()
289799a2dd95SBruce Richardson  *
28982834e6ddSFerruh Yigit  * All device queues status should be `RTE_ETH_QUEUE_STATE_STOPPED` after stop.
28992834e6ddSFerruh Yigit  *
290099a2dd95SBruce Richardson  * @param port_id
290199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
290299a2dd95SBruce Richardson  * @return
290399a2dd95SBruce Richardson  *   - 0: Success, Ethernet device stopped.
290447a4e1fbSDariusz Sosnowski  *   - -EBUSY: If stopping the port is not allowed in current state.
290599a2dd95SBruce Richardson  *   - <0: Error code of the driver device stop function.
290699a2dd95SBruce Richardson  */
290799a2dd95SBruce Richardson int rte_eth_dev_stop(uint16_t port_id);
290899a2dd95SBruce Richardson 
290999a2dd95SBruce Richardson /**
291099a2dd95SBruce Richardson  * Link up an Ethernet device.
291199a2dd95SBruce Richardson  *
291209fd4227SAndrew Rybchenko  * Set device link up will re-enable the device Rx/Tx
291399a2dd95SBruce Richardson  * functionality after it is previously set device linked down.
291499a2dd95SBruce Richardson  *
291599a2dd95SBruce Richardson  * @param port_id
291699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
291799a2dd95SBruce Richardson  * @return
291899a2dd95SBruce Richardson  *   - 0: Success, Ethernet device linked up.
291999a2dd95SBruce Richardson  *   - <0: Error code of the driver device link up function.
292099a2dd95SBruce Richardson  */
292199a2dd95SBruce Richardson int rte_eth_dev_set_link_up(uint16_t port_id);
292299a2dd95SBruce Richardson 
292399a2dd95SBruce Richardson /**
292499a2dd95SBruce Richardson  * Link down an Ethernet device.
292509fd4227SAndrew Rybchenko  * The device Rx/Tx functionality will be disabled if success,
292699a2dd95SBruce Richardson  * and it can be re-enabled with a call to
292799a2dd95SBruce Richardson  * rte_eth_dev_set_link_up()
292899a2dd95SBruce Richardson  *
292999a2dd95SBruce Richardson  * @param port_id
293099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
293199a2dd95SBruce Richardson  */
293299a2dd95SBruce Richardson int rte_eth_dev_set_link_down(uint16_t port_id);
293399a2dd95SBruce Richardson 
293499a2dd95SBruce Richardson /**
293599a2dd95SBruce Richardson  * Close a stopped Ethernet device. The device cannot be restarted!
293699a2dd95SBruce Richardson  * The function frees all port resources.
293799a2dd95SBruce Richardson  *
293899a2dd95SBruce Richardson  * @param port_id
293999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
294099a2dd95SBruce Richardson  * @return
294199a2dd95SBruce Richardson  *   - Zero if the port is closed successfully.
294299a2dd95SBruce Richardson  *   - Negative if something went wrong.
294399a2dd95SBruce Richardson  */
294499a2dd95SBruce Richardson int rte_eth_dev_close(uint16_t port_id);
294599a2dd95SBruce Richardson 
294699a2dd95SBruce Richardson /**
29475906be5aSAndrew Rybchenko  * Reset a Ethernet device and keep its port ID.
294899a2dd95SBruce Richardson  *
294999a2dd95SBruce Richardson  * When a port has to be reset passively, the DPDK application can invoke
295099a2dd95SBruce Richardson  * this function. For example when a PF is reset, all its VFs should also
295199a2dd95SBruce Richardson  * be reset. Normally a DPDK application can invoke this function when
295299a2dd95SBruce Richardson  * RTE_ETH_EVENT_INTR_RESET event is detected, but can also use it to start
295399a2dd95SBruce Richardson  * a port reset in other circumstances.
295499a2dd95SBruce Richardson  *
295599a2dd95SBruce Richardson  * When this function is called, it first stops the port and then calls the
295699a2dd95SBruce Richardson  * PMD specific dev_uninit( ) and dev_init( ) to return the port to initial
295799a2dd95SBruce Richardson  * state, in which no Tx and Rx queues are setup, as if the port has been
29585906be5aSAndrew Rybchenko  * reset and not started. The port keeps the port ID it had before the
295999a2dd95SBruce Richardson  * function call.
296099a2dd95SBruce Richardson  *
296199a2dd95SBruce Richardson  * After calling rte_eth_dev_reset( ), the application should use
296299a2dd95SBruce Richardson  * rte_eth_dev_configure( ), rte_eth_rx_queue_setup( ),
296399a2dd95SBruce Richardson  * rte_eth_tx_queue_setup( ), and rte_eth_dev_start( )
296499a2dd95SBruce Richardson  * to reconfigure the device as appropriate.
296599a2dd95SBruce Richardson  *
296699a2dd95SBruce Richardson  * Note: To avoid unexpected behavior, the application should stop calling
296799a2dd95SBruce Richardson  * Tx and Rx functions before calling rte_eth_dev_reset( ). For thread
296899a2dd95SBruce Richardson  * safety, all these controlling functions should be called from the same
296999a2dd95SBruce Richardson  * thread.
297099a2dd95SBruce Richardson  *
297199a2dd95SBruce Richardson  * @param port_id
297299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
297399a2dd95SBruce Richardson  *
297499a2dd95SBruce Richardson  * @return
297599a2dd95SBruce Richardson  *   - (0) if successful.
297699a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
297799a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support this function.
297899a2dd95SBruce Richardson  *   - (-EPERM) if not ran from the primary process.
297999a2dd95SBruce Richardson  *   - (-EIO) if re-initialisation failed or device is removed.
298099a2dd95SBruce Richardson  *   - (-ENOMEM) if the reset failed due to OOM.
298199a2dd95SBruce Richardson  *   - (-EAGAIN) if the reset temporarily failed and should be retried later.
298299a2dd95SBruce Richardson  */
298399a2dd95SBruce Richardson int rte_eth_dev_reset(uint16_t port_id);
298499a2dd95SBruce Richardson 
298599a2dd95SBruce Richardson /**
298699a2dd95SBruce Richardson  * Enable receipt in promiscuous mode for an Ethernet device.
298799a2dd95SBruce Richardson  *
298899a2dd95SBruce Richardson  * @param port_id
298999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
299099a2dd95SBruce Richardson  * @return
299199a2dd95SBruce Richardson  *   - (0) if successful.
299299a2dd95SBruce Richardson  *   - (-ENOTSUP) if support for promiscuous_enable() does not exist
299399a2dd95SBruce Richardson  *     for the device.
299499a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
299599a2dd95SBruce Richardson  */
299699a2dd95SBruce Richardson int rte_eth_promiscuous_enable(uint16_t port_id);
299799a2dd95SBruce Richardson 
299899a2dd95SBruce Richardson /**
299999a2dd95SBruce Richardson  * Disable receipt in promiscuous mode for an Ethernet device.
300099a2dd95SBruce Richardson  *
300199a2dd95SBruce Richardson  * @param port_id
300299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
300399a2dd95SBruce Richardson  * @return
300499a2dd95SBruce Richardson  *   - (0) if successful.
300599a2dd95SBruce Richardson  *   - (-ENOTSUP) if support for promiscuous_disable() does not exist
300699a2dd95SBruce Richardson  *     for the device.
300799a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
300899a2dd95SBruce Richardson  */
300999a2dd95SBruce Richardson int rte_eth_promiscuous_disable(uint16_t port_id);
301099a2dd95SBruce Richardson 
301199a2dd95SBruce Richardson /**
301299a2dd95SBruce Richardson  * Return the value of promiscuous mode for an Ethernet device.
301399a2dd95SBruce Richardson  *
301499a2dd95SBruce Richardson  * @param port_id
301599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
301699a2dd95SBruce Richardson  * @return
301799a2dd95SBruce Richardson  *   - (1) if promiscuous is enabled
301899a2dd95SBruce Richardson  *   - (0) if promiscuous is disabled.
301999a2dd95SBruce Richardson  *   - (-1) on error
302099a2dd95SBruce Richardson  */
302199a2dd95SBruce Richardson int rte_eth_promiscuous_get(uint16_t port_id);
302299a2dd95SBruce Richardson 
302399a2dd95SBruce Richardson /**
302499a2dd95SBruce Richardson  * Enable the receipt of any multicast frame by an Ethernet device.
302599a2dd95SBruce Richardson  *
302699a2dd95SBruce Richardson  * @param port_id
302799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
302899a2dd95SBruce Richardson  * @return
302999a2dd95SBruce Richardson  *   - (0) if successful.
303099a2dd95SBruce Richardson  *   - (-ENOTSUP) if support for allmulticast_enable() does not exist
303199a2dd95SBruce Richardson  *     for the device.
303299a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
303399a2dd95SBruce Richardson  */
303499a2dd95SBruce Richardson int rte_eth_allmulticast_enable(uint16_t port_id);
303599a2dd95SBruce Richardson 
303699a2dd95SBruce Richardson /**
303799a2dd95SBruce Richardson  * Disable the receipt of all multicast frames by an Ethernet device.
303899a2dd95SBruce Richardson  *
303999a2dd95SBruce Richardson  * @param port_id
304099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
304199a2dd95SBruce Richardson  * @return
304299a2dd95SBruce Richardson  *   - (0) if successful.
304399a2dd95SBruce Richardson  *   - (-ENOTSUP) if support for allmulticast_disable() does not exist
304499a2dd95SBruce Richardson  *     for the device.
304599a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
304699a2dd95SBruce Richardson  */
304799a2dd95SBruce Richardson int rte_eth_allmulticast_disable(uint16_t port_id);
304899a2dd95SBruce Richardson 
304999a2dd95SBruce Richardson /**
305099a2dd95SBruce Richardson  * Return the value of allmulticast mode for an Ethernet device.
305199a2dd95SBruce Richardson  *
305299a2dd95SBruce Richardson  * @param port_id
305399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
305499a2dd95SBruce Richardson  * @return
305599a2dd95SBruce Richardson  *   - (1) if allmulticast is enabled
305699a2dd95SBruce Richardson  *   - (0) if allmulticast is disabled.
305799a2dd95SBruce Richardson  *   - (-1) on error
305899a2dd95SBruce Richardson  */
305999a2dd95SBruce Richardson int rte_eth_allmulticast_get(uint16_t port_id);
306099a2dd95SBruce Richardson 
306199a2dd95SBruce Richardson /**
306299a2dd95SBruce Richardson  * Retrieve the link status (up/down), the duplex mode (half/full),
306399a2dd95SBruce Richardson  * the negotiation (auto/fixed), and if available, the speed (Mbps).
306499a2dd95SBruce Richardson  *
306599a2dd95SBruce Richardson  * It might need to wait up to 9 seconds.
306699a2dd95SBruce Richardson  * @see rte_eth_link_get_nowait.
306799a2dd95SBruce Richardson  *
306899a2dd95SBruce Richardson  * @param port_id
306999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
307099a2dd95SBruce Richardson  * @param link
307199a2dd95SBruce Richardson  *   Link information written back.
307299a2dd95SBruce Richardson  * @return
307399a2dd95SBruce Richardson  *   - (0) if successful.
3074f8dbaebbSSean Morrissey  *   - (-ENOTSUP) if the function is not supported in PMD.
307599a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
307653ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
307799a2dd95SBruce Richardson  */
3078*1ff8b9a6SStephen Hemminger int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link)
3079*1ff8b9a6SStephen Hemminger 	__rte_warn_unused_result;
308099a2dd95SBruce Richardson 
308199a2dd95SBruce Richardson /**
308299a2dd95SBruce Richardson  * Retrieve the link status (up/down), the duplex mode (half/full),
308399a2dd95SBruce Richardson  * the negotiation (auto/fixed), and if available, the speed (Mbps).
308499a2dd95SBruce Richardson  *
308599a2dd95SBruce Richardson  * @param port_id
308699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
308799a2dd95SBruce Richardson  * @param link
308899a2dd95SBruce Richardson  *   Link information written back.
308999a2dd95SBruce Richardson  * @return
309099a2dd95SBruce Richardson  *   - (0) if successful.
3091f8dbaebbSSean Morrissey  *   - (-ENOTSUP) if the function is not supported in PMD.
309299a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
309353ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
309499a2dd95SBruce Richardson  */
3095*1ff8b9a6SStephen Hemminger int rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *link)
3096*1ff8b9a6SStephen Hemminger 	__rte_warn_unused_result;
309799a2dd95SBruce Richardson 
309899a2dd95SBruce Richardson /**
309999a2dd95SBruce Richardson  * @warning
310099a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
310199a2dd95SBruce Richardson  *
310299a2dd95SBruce Richardson  * The function converts a link_speed to a string. It handles all special
310399a2dd95SBruce Richardson  * values like unknown or none speed.
310499a2dd95SBruce Richardson  *
310599a2dd95SBruce Richardson  * @param link_speed
310699a2dd95SBruce Richardson  *   link_speed of rte_eth_link struct
310799a2dd95SBruce Richardson  * @return
310899a2dd95SBruce Richardson  *   Link speed in textual format. It's pointer to immutable memory.
310999a2dd95SBruce Richardson  *   No free is required.
311099a2dd95SBruce Richardson  */
311199a2dd95SBruce Richardson __rte_experimental
311299a2dd95SBruce Richardson const char *rte_eth_link_speed_to_str(uint32_t link_speed);
311399a2dd95SBruce Richardson 
311499a2dd95SBruce Richardson /**
311599a2dd95SBruce Richardson  * @warning
311699a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
311799a2dd95SBruce Richardson  *
311899a2dd95SBruce Richardson  * The function converts a rte_eth_link struct representing a link status to
311999a2dd95SBruce Richardson  * a string.
312099a2dd95SBruce Richardson  *
312199a2dd95SBruce Richardson  * @param str
312299a2dd95SBruce Richardson  *   A pointer to a string to be filled with textual representation of
3123295968d1SFerruh Yigit  *   device status. At least RTE_ETH_LINK_MAX_STR_LEN bytes should be allocated to
312499a2dd95SBruce Richardson  *   store default link status text.
312599a2dd95SBruce Richardson  * @param len
312699a2dd95SBruce Richardson  *   Length of available memory at 'str' string.
312799a2dd95SBruce Richardson  * @param eth_link
312899a2dd95SBruce Richardson  *   Link status returned by rte_eth_link_get function
312999a2dd95SBruce Richardson  * @return
313053ef1b34SMin Hu (Connor)  *   Number of bytes written to str array or -EINVAL if bad parameter.
313199a2dd95SBruce Richardson  */
313299a2dd95SBruce Richardson __rte_experimental
313399a2dd95SBruce Richardson int rte_eth_link_to_str(char *str, size_t len,
313499a2dd95SBruce Richardson 			const struct rte_eth_link *eth_link);
313599a2dd95SBruce Richardson 
313699a2dd95SBruce Richardson /**
313760bac722SDamodharam Ammepalli  * @warning
313860bac722SDamodharam Ammepalli  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
313960bac722SDamodharam Ammepalli  *
314060bac722SDamodharam Ammepalli  * Get Active lanes.
314160bac722SDamodharam Ammepalli  *
314260bac722SDamodharam Ammepalli  * @param port_id
314360bac722SDamodharam Ammepalli  *   The port identifier of the Ethernet device.
314460bac722SDamodharam Ammepalli  * @param lanes
314560bac722SDamodharam Ammepalli  *   Driver updates lanes with the number of active lanes.
314660bac722SDamodharam Ammepalli  *   On a supported NIC on link up, lanes will be a non-zero value irrespective whether the
314760bac722SDamodharam Ammepalli  *   link is Autonegotiated or Fixed speed. No information is displayed for error.
314860bac722SDamodharam Ammepalli  *
314960bac722SDamodharam Ammepalli  * @return
315060bac722SDamodharam Ammepalli  *   - (0) if successful.
315160bac722SDamodharam Ammepalli  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
315260bac722SDamodharam Ammepalli  *     that operation.
315360bac722SDamodharam Ammepalli  *   - (-EIO) if device is removed.
315460bac722SDamodharam Ammepalli  *   - (-ENODEV)  if *port_id* invalid.
315560bac722SDamodharam Ammepalli  */
315660bac722SDamodharam Ammepalli __rte_experimental
315760bac722SDamodharam Ammepalli int rte_eth_speed_lanes_get(uint16_t port_id, uint32_t *lanes);
315860bac722SDamodharam Ammepalli 
315960bac722SDamodharam Ammepalli /**
316060bac722SDamodharam Ammepalli  * @warning
316160bac722SDamodharam Ammepalli  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
316260bac722SDamodharam Ammepalli  *
316360bac722SDamodharam Ammepalli  * Set speed lanes supported by the NIC.
316460bac722SDamodharam Ammepalli  *
316560bac722SDamodharam Ammepalli  * @param port_id
316660bac722SDamodharam Ammepalli  *   The port identifier of the Ethernet device.
316760bac722SDamodharam Ammepalli  * @param speed_lanes
316860bac722SDamodharam Ammepalli  *   A non-zero number of speed lanes, that will be applied to the ethernet PHY
316960bac722SDamodharam Ammepalli  *   along with the fixed speed configuration. Driver returns error if the user
317060bac722SDamodharam Ammepalli  *   lanes is not in speeds capability list.
317160bac722SDamodharam Ammepalli  *
317260bac722SDamodharam Ammepalli  * @return
317360bac722SDamodharam Ammepalli  *   - (0) if successful.
317460bac722SDamodharam Ammepalli  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
317560bac722SDamodharam Ammepalli  *     that operation.
317660bac722SDamodharam Ammepalli  *   - (-EIO) if device is removed.
317760bac722SDamodharam Ammepalli  *   - (-ENODEV)  if *port_id* invalid.
317860bac722SDamodharam Ammepalli  *   - (-EINVAL)  if *lanes* count not in speeds capability list.
317960bac722SDamodharam Ammepalli  */
318060bac722SDamodharam Ammepalli __rte_experimental
318160bac722SDamodharam Ammepalli int rte_eth_speed_lanes_set(uint16_t port_id, uint32_t speed_lanes);
318260bac722SDamodharam Ammepalli 
318360bac722SDamodharam Ammepalli /**
318460bac722SDamodharam Ammepalli  * @warning
318560bac722SDamodharam Ammepalli  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
318660bac722SDamodharam Ammepalli  *
318760bac722SDamodharam Ammepalli  * Get speed lanes supported by the NIC.
318860bac722SDamodharam Ammepalli  *
318960bac722SDamodharam Ammepalli  * @param port_id
319060bac722SDamodharam Ammepalli  *   The port identifier of the Ethernet device.
319160bac722SDamodharam Ammepalli  * @param speed_lanes_capa
319260bac722SDamodharam Ammepalli  *   An array of supported speed and its supported lanes.
319360bac722SDamodharam Ammepalli  * @param num
319460bac722SDamodharam Ammepalli  *   Size of the speed_lanes_capa array. The size is equal to the supported speeds list size.
319560bac722SDamodharam Ammepalli  *   Value of num is derived by calling this api with speed_lanes_capa=NULL and num=0
319660bac722SDamodharam Ammepalli  *
319760bac722SDamodharam Ammepalli  * @return
319860bac722SDamodharam Ammepalli  *   - (0) if successful.
319960bac722SDamodharam Ammepalli  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
320060bac722SDamodharam Ammepalli  *     that operation.
320160bac722SDamodharam Ammepalli  *   - (-EIO) if device is removed.
320260bac722SDamodharam Ammepalli  *   - (-ENODEV)  if *port_id* invalid.
320360bac722SDamodharam Ammepalli  *   - (-EINVAL)  if *speed_lanes* invalid
320460bac722SDamodharam Ammepalli  */
320560bac722SDamodharam Ammepalli __rte_experimental
320660bac722SDamodharam Ammepalli int rte_eth_speed_lanes_get_capability(uint16_t port_id,
320760bac722SDamodharam Ammepalli 				       struct rte_eth_speed_lanes_capa *speed_lanes_capa,
320860bac722SDamodharam Ammepalli 				       unsigned int num);
320960bac722SDamodharam Ammepalli 
321060bac722SDamodharam Ammepalli /**
321199a2dd95SBruce Richardson  * Retrieve the general I/O statistics of an Ethernet device.
321299a2dd95SBruce Richardson  *
321399a2dd95SBruce Richardson  * @param port_id
321499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
321599a2dd95SBruce Richardson  * @param stats
321699a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_eth_stats* to be filled with
321799a2dd95SBruce Richardson  *   the values of device counters for the following set of statistics:
321899a2dd95SBruce Richardson  *   - *ipackets* with the total of successfully received packets.
321999a2dd95SBruce Richardson  *   - *opackets* with the total of successfully transmitted packets.
322099a2dd95SBruce Richardson  *   - *ibytes*   with the total of successfully received bytes.
322199a2dd95SBruce Richardson  *   - *obytes*   with the total of successfully transmitted bytes.
322299a2dd95SBruce Richardson  *   - *ierrors*  with the total of erroneous received packets.
322399a2dd95SBruce Richardson  *   - *oerrors*  with the total of failed transmitted packets.
322499a2dd95SBruce Richardson  * @return
322599a2dd95SBruce Richardson  *   Zero if successful. Non-zero otherwise.
322699a2dd95SBruce Richardson  */
322799a2dd95SBruce Richardson int rte_eth_stats_get(uint16_t port_id, struct rte_eth_stats *stats);
322899a2dd95SBruce Richardson 
322999a2dd95SBruce Richardson /**
323099a2dd95SBruce Richardson  * Reset the general I/O statistics of an Ethernet device.
323199a2dd95SBruce Richardson  *
323299a2dd95SBruce Richardson  * @param port_id
323399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
323499a2dd95SBruce Richardson  * @return
323599a2dd95SBruce Richardson  *   - (0) if device notified to reset stats.
323699a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
323799a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
323899a2dd95SBruce Richardson  *   - (<0): Error code of the driver stats reset function.
323999a2dd95SBruce Richardson  */
324099a2dd95SBruce Richardson int rte_eth_stats_reset(uint16_t port_id);
324199a2dd95SBruce Richardson 
324299a2dd95SBruce Richardson /**
324399a2dd95SBruce Richardson  * Retrieve names of extended statistics of an Ethernet device.
324499a2dd95SBruce Richardson  *
324599a2dd95SBruce Richardson  * There is an assumption that 'xstat_names' and 'xstats' arrays are matched
324699a2dd95SBruce Richardson  * by array index:
324799a2dd95SBruce Richardson  *  xstats_names[i].name => xstats[i].value
324899a2dd95SBruce Richardson  *
324999a2dd95SBruce Richardson  * And the array index is same with id field of 'struct rte_eth_xstat':
325099a2dd95SBruce Richardson  *  xstats[i].id == i
325199a2dd95SBruce Richardson  *
325299a2dd95SBruce Richardson  * This assumption makes key-value pair matching less flexible but simpler.
325399a2dd95SBruce Richardson  *
325499a2dd95SBruce Richardson  * @param port_id
325599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
325699a2dd95SBruce Richardson  * @param xstats_names
325799a2dd95SBruce Richardson  *   An rte_eth_xstat_name array of at least *size* elements to
325899a2dd95SBruce Richardson  *   be filled. If set to NULL, the function returns the required number
325999a2dd95SBruce Richardson  *   of elements.
326099a2dd95SBruce Richardson  * @param size
326199a2dd95SBruce Richardson  *   The size of the xstats_names array (number of elements).
326299a2dd95SBruce Richardson  * @return
326399a2dd95SBruce Richardson  *   - A positive value lower or equal to size: success. The return value
326499a2dd95SBruce Richardson  *     is the number of entries filled in the stats table.
326599a2dd95SBruce Richardson  *   - A positive value higher than size: error, the given statistics table
326699a2dd95SBruce Richardson  *     is too small. The return value corresponds to the size that should
326799a2dd95SBruce Richardson  *     be given to succeed. The entries in the table are not valid and
326899a2dd95SBruce Richardson  *     shall not be used by the caller.
32695906be5aSAndrew Rybchenko  *   - A negative value on error (invalid port ID).
327099a2dd95SBruce Richardson  */
327199a2dd95SBruce Richardson int rte_eth_xstats_get_names(uint16_t port_id,
327299a2dd95SBruce Richardson 		struct rte_eth_xstat_name *xstats_names,
327399a2dd95SBruce Richardson 		unsigned int size);
327499a2dd95SBruce Richardson 
327599a2dd95SBruce Richardson /**
327699a2dd95SBruce Richardson  * Retrieve extended statistics of an Ethernet device.
327799a2dd95SBruce Richardson  *
327899a2dd95SBruce Richardson  * There is an assumption that 'xstat_names' and 'xstats' arrays are matched
327999a2dd95SBruce Richardson  * by array index:
328099a2dd95SBruce Richardson  *  xstats_names[i].name => xstats[i].value
328199a2dd95SBruce Richardson  *
328299a2dd95SBruce Richardson  * And the array index is same with id field of 'struct rte_eth_xstat':
328399a2dd95SBruce Richardson  *  xstats[i].id == i
328499a2dd95SBruce Richardson  *
328599a2dd95SBruce Richardson  * This assumption makes key-value pair matching less flexible but simpler.
328699a2dd95SBruce Richardson  *
328799a2dd95SBruce Richardson  * @param port_id
328899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
328999a2dd95SBruce Richardson  * @param xstats
329099a2dd95SBruce Richardson  *   A pointer to a table of structure of type *rte_eth_xstat*
329199a2dd95SBruce Richardson  *   to be filled with device statistics ids and values.
3292485df884SChengwen Feng  *   This parameter can be set to NULL if and only if n is 0.
329399a2dd95SBruce Richardson  * @param n
329499a2dd95SBruce Richardson  *   The size of the xstats array (number of elements).
3295485df884SChengwen Feng  *   If lower than the required number of elements, the function returns
3296485df884SChengwen Feng  *   the required number of elements.
3297485df884SChengwen Feng  *   If equal to zero, the xstats must be NULL, the function returns the
3298485df884SChengwen Feng  *   required number of elements.
329999a2dd95SBruce Richardson  * @return
330099a2dd95SBruce Richardson  *   - A positive value lower or equal to n: success. The return value
330199a2dd95SBruce Richardson  *     is the number of entries filled in the stats table.
330299a2dd95SBruce Richardson  *   - A positive value higher than n: error, the given statistics table
330399a2dd95SBruce Richardson  *     is too small. The return value corresponds to the size that should
330499a2dd95SBruce Richardson  *     be given to succeed. The entries in the table are not valid and
330599a2dd95SBruce Richardson  *     shall not be used by the caller.
33065906be5aSAndrew Rybchenko  *   - A negative value on error (invalid port ID).
330799a2dd95SBruce Richardson  */
330899a2dd95SBruce Richardson int rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats,
330999a2dd95SBruce Richardson 		unsigned int n);
331099a2dd95SBruce Richardson 
331199a2dd95SBruce Richardson /**
331299a2dd95SBruce Richardson  * Retrieve names of extended statistics of an Ethernet device.
331399a2dd95SBruce Richardson  *
331499a2dd95SBruce Richardson  * @param port_id
331599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
331699a2dd95SBruce Richardson  * @param xstats_names
3317bc5112caSIvan Ilchenko  *   Array to be filled in with names of requested device statistics.
3318bc5112caSIvan Ilchenko  *   Must not be NULL if @p ids are specified (not NULL).
331999a2dd95SBruce Richardson  * @param size
3320bc5112caSIvan Ilchenko  *   Number of elements in @p xstats_names array (if not NULL) and in
3321bc5112caSIvan Ilchenko  *   @p ids array (if not NULL). Must be 0 if both array pointers are NULL.
3322bc5112caSIvan Ilchenko  * @param ids
3323bc5112caSIvan Ilchenko  *   IDs array given by app to retrieve specific statistics. May be NULL to
3324bc5112caSIvan Ilchenko  *   retrieve names of all available statistics or, if @p xstats_names is
3325bc5112caSIvan Ilchenko  *   NULL as well, just the number of available statistics.
332699a2dd95SBruce Richardson  * @return
332799a2dd95SBruce Richardson  *   - A positive value lower or equal to size: success. The return value
332899a2dd95SBruce Richardson  *     is the number of entries filled in the stats table.
3329bc5112caSIvan Ilchenko  *   - A positive value higher than size: success. The given statistics table
333099a2dd95SBruce Richardson  *     is too small. The return value corresponds to the size that should
333199a2dd95SBruce Richardson  *     be given to succeed. The entries in the table are not valid and
333299a2dd95SBruce Richardson  *     shall not be used by the caller.
3333bc5112caSIvan Ilchenko  *   - A negative value on error.
333499a2dd95SBruce Richardson  */
333599a2dd95SBruce Richardson int
333699a2dd95SBruce Richardson rte_eth_xstats_get_names_by_id(uint16_t port_id,
333799a2dd95SBruce Richardson 	struct rte_eth_xstat_name *xstats_names, unsigned int size,
333899a2dd95SBruce Richardson 	uint64_t *ids);
333999a2dd95SBruce Richardson 
334099a2dd95SBruce Richardson /**
334199a2dd95SBruce Richardson  * Retrieve extended statistics of an Ethernet device.
334299a2dd95SBruce Richardson  *
334399a2dd95SBruce Richardson  * @param port_id
334499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
334599a2dd95SBruce Richardson  * @param ids
3346bc5112caSIvan Ilchenko  *   IDs array given by app to retrieve specific statistics. May be NULL to
3347bc5112caSIvan Ilchenko  *   retrieve all available statistics or, if @p values is NULL as well,
3348bc5112caSIvan Ilchenko  *   just the number of available statistics.
334999a2dd95SBruce Richardson  * @param values
3350bc5112caSIvan Ilchenko  *   Array to be filled in with requested device statistics.
3351bc5112caSIvan Ilchenko  *   Must not be NULL if ids are specified (not NULL).
335299a2dd95SBruce Richardson  * @param size
3353bc5112caSIvan Ilchenko  *   Number of elements in @p values array (if not NULL) and in @p ids
3354bc5112caSIvan Ilchenko  *   array (if not NULL). Must be 0 if both array pointers are NULL.
335599a2dd95SBruce Richardson  * @return
335699a2dd95SBruce Richardson  *   - A positive value lower or equal to size: success. The return value
335799a2dd95SBruce Richardson  *     is the number of entries filled in the stats table.
3358bc5112caSIvan Ilchenko  *   - A positive value higher than size: success: The given statistics table
335999a2dd95SBruce Richardson  *     is too small. The return value corresponds to the size that should
336099a2dd95SBruce Richardson  *     be given to succeed. The entries in the table are not valid and
336199a2dd95SBruce Richardson  *     shall not be used by the caller.
3362bc5112caSIvan Ilchenko  *   - A negative value on error.
336399a2dd95SBruce Richardson  */
336499a2dd95SBruce Richardson int rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,
336599a2dd95SBruce Richardson 			     uint64_t *values, unsigned int size);
336699a2dd95SBruce Richardson 
336799a2dd95SBruce Richardson /**
336899a2dd95SBruce Richardson  * Gets the ID of a statistic from its name.
336999a2dd95SBruce Richardson  *
337099a2dd95SBruce Richardson  * This function searches for the statistics using string compares, and
337199a2dd95SBruce Richardson  * as such should not be used on the fast-path. For fast-path retrieval of
337299a2dd95SBruce Richardson  * specific statistics, store the ID as provided in *id* from this function,
337399a2dd95SBruce Richardson  * and pass the ID to rte_eth_xstats_get()
337499a2dd95SBruce Richardson  *
337599a2dd95SBruce Richardson  * @param port_id The port to look up statistics from
337699a2dd95SBruce Richardson  * @param xstat_name The name of the statistic to return
337799a2dd95SBruce Richardson  * @param[out] id A pointer to an app-supplied uint64_t which should be
337899a2dd95SBruce Richardson  *                set to the ID of the stat if the stat exists.
337999a2dd95SBruce Richardson  * @return
338099a2dd95SBruce Richardson  *    0 on success
338199a2dd95SBruce Richardson  *    -ENODEV for invalid port_id,
338299a2dd95SBruce Richardson  *    -EIO if device is removed,
338399a2dd95SBruce Richardson  *    -EINVAL if the xstat_name doesn't exist in port_id
338453ef1b34SMin Hu (Connor)  *    -ENOMEM if bad parameter.
338599a2dd95SBruce Richardson  */
338699a2dd95SBruce Richardson int rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name,
338799a2dd95SBruce Richardson 		uint64_t *id);
338899a2dd95SBruce Richardson 
338999a2dd95SBruce Richardson /**
339099a2dd95SBruce Richardson  * Reset extended statistics of an Ethernet device.
339199a2dd95SBruce Richardson  *
339299a2dd95SBruce Richardson  * @param port_id
339399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
339499a2dd95SBruce Richardson  * @return
339599a2dd95SBruce Richardson  *   - (0) if device notified to reset extended stats.
339699a2dd95SBruce Richardson  *   - (-ENOTSUP) if pmd doesn't support both
339799a2dd95SBruce Richardson  *     extended stats and basic stats reset.
339899a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
339999a2dd95SBruce Richardson  *   - (<0): Error code of the driver xstats reset function.
340099a2dd95SBruce Richardson  */
340199a2dd95SBruce Richardson int rte_eth_xstats_reset(uint16_t port_id);
340299a2dd95SBruce Richardson 
340399a2dd95SBruce Richardson /**
340499a2dd95SBruce Richardson  *  Set a mapping for the specified transmit queue to the specified per-queue
340599a2dd95SBruce Richardson  *  statistics counter.
340699a2dd95SBruce Richardson  *
340799a2dd95SBruce Richardson  * @param port_id
340899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
340999a2dd95SBruce Richardson  * @param tx_queue_id
341099a2dd95SBruce Richardson  *   The index of the transmit queue for which a queue stats mapping is required.
341199a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
341299a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
341399a2dd95SBruce Richardson  * @param stat_idx
341499a2dd95SBruce Richardson  *   The per-queue packet statistics functionality number that the transmit
341599a2dd95SBruce Richardson  *   queue is to be assigned.
341699a2dd95SBruce Richardson  *   The value must be in the range [0, RTE_ETHDEV_QUEUE_STAT_CNTRS - 1].
341799a2dd95SBruce Richardson  *   Max RTE_ETHDEV_QUEUE_STAT_CNTRS being 256.
341899a2dd95SBruce Richardson  * @return
341999a2dd95SBruce Richardson  *   Zero if successful. Non-zero otherwise.
342099a2dd95SBruce Richardson  */
342199a2dd95SBruce Richardson int rte_eth_dev_set_tx_queue_stats_mapping(uint16_t port_id,
342299a2dd95SBruce Richardson 		uint16_t tx_queue_id, uint8_t stat_idx);
342399a2dd95SBruce Richardson 
342499a2dd95SBruce Richardson /**
342599a2dd95SBruce Richardson  *  Set a mapping for the specified receive queue to the specified per-queue
342699a2dd95SBruce Richardson  *  statistics counter.
342799a2dd95SBruce Richardson  *
342899a2dd95SBruce Richardson  * @param port_id
342999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
343099a2dd95SBruce Richardson  * @param rx_queue_id
343199a2dd95SBruce Richardson  *   The index of the receive queue for which a queue stats mapping is required.
343299a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
343399a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
343499a2dd95SBruce Richardson  * @param stat_idx
343599a2dd95SBruce Richardson  *   The per-queue packet statistics functionality number that the receive
343699a2dd95SBruce Richardson  *   queue is to be assigned.
343799a2dd95SBruce Richardson  *   The value must be in the range [0, RTE_ETHDEV_QUEUE_STAT_CNTRS - 1].
343899a2dd95SBruce Richardson  *   Max RTE_ETHDEV_QUEUE_STAT_CNTRS being 256.
343999a2dd95SBruce Richardson  * @return
344099a2dd95SBruce Richardson  *   Zero if successful. Non-zero otherwise.
344199a2dd95SBruce Richardson  */
344299a2dd95SBruce Richardson int rte_eth_dev_set_rx_queue_stats_mapping(uint16_t port_id,
344399a2dd95SBruce Richardson 					   uint16_t rx_queue_id,
344499a2dd95SBruce Richardson 					   uint8_t stat_idx);
344599a2dd95SBruce Richardson 
344699a2dd95SBruce Richardson /**
344799a2dd95SBruce Richardson  * Retrieve the Ethernet address of an Ethernet device.
344899a2dd95SBruce Richardson  *
344999a2dd95SBruce Richardson  * @param port_id
345099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
345199a2dd95SBruce Richardson  * @param mac_addr
345299a2dd95SBruce Richardson  *   A pointer to a structure of type *ether_addr* to be filled with
345399a2dd95SBruce Richardson  *   the Ethernet address of the Ethernet device.
345499a2dd95SBruce Richardson  * @return
345599a2dd95SBruce Richardson  *   - (0) if successful
345699a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
345753ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
345899a2dd95SBruce Richardson  */
345999a2dd95SBruce Richardson int rte_eth_macaddr_get(uint16_t port_id, struct rte_ether_addr *mac_addr);
346099a2dd95SBruce Richardson 
346199a2dd95SBruce Richardson /**
346227a300e6SKonstantin Ananyev  * @warning
346327a300e6SKonstantin Ananyev  * @b EXPERIMENTAL: this API may change without prior notice
346427a300e6SKonstantin Ananyev  *
346527a300e6SKonstantin Ananyev  * Retrieve the Ethernet addresses of an Ethernet device.
346627a300e6SKonstantin Ananyev  *
346727a300e6SKonstantin Ananyev  * @param port_id
346827a300e6SKonstantin Ananyev  *   The port identifier of the Ethernet device.
346927a300e6SKonstantin Ananyev  * @param ma
347027a300e6SKonstantin Ananyev  *   A pointer to an array of structures of type *ether_addr* to be filled with
347127a300e6SKonstantin Ananyev  *   the Ethernet addresses of the Ethernet device.
347227a300e6SKonstantin Ananyev  * @param num
347327a300e6SKonstantin Ananyev  *   Number of elements in the @p ma array.
347427a300e6SKonstantin Ananyev  *   Note that  rte_eth_dev_info::max_mac_addrs can be used to retrieve
347527a300e6SKonstantin Ananyev  *   max number of Ethernet addresses for given port.
347627a300e6SKonstantin Ananyev  * @return
347727a300e6SKonstantin Ananyev  *   - number of retrieved addresses if successful
347827a300e6SKonstantin Ananyev  *   - (-ENODEV) if *port_id* invalid.
347927a300e6SKonstantin Ananyev  *   - (-EINVAL) if bad parameter.
348027a300e6SKonstantin Ananyev  */
348127a300e6SKonstantin Ananyev __rte_experimental
348227a300e6SKonstantin Ananyev int rte_eth_macaddrs_get(uint16_t port_id, struct rte_ether_addr *ma,
348327a300e6SKonstantin Ananyev 	unsigned int num);
348427a300e6SKonstantin Ananyev 
348527a300e6SKonstantin Ananyev /**
348699a2dd95SBruce Richardson  * Retrieve the contextual information of an Ethernet device.
348799a2dd95SBruce Richardson  *
3488f92c5652SStephen Hemminger  * This function returns the Ethernet device information based
3489f92c5652SStephen Hemminger  * on the values stored internally in the device specific data.
3490f92c5652SStephen Hemminger  * For example: number of queues, descriptor limits, device
3491f92c5652SStephen Hemminger  * capabilities and offload flags.
349299a2dd95SBruce Richardson  *
349399a2dd95SBruce Richardson  * @param port_id
349499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
349599a2dd95SBruce Richardson  * @param dev_info
349699a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_eth_dev_info* to be filled with
349799a2dd95SBruce Richardson  *   the contextual information of the Ethernet device.
349899a2dd95SBruce Richardson  * @return
349999a2dd95SBruce Richardson  *   - (0) if successful.
350099a2dd95SBruce Richardson  *   - (-ENOTSUP) if support for dev_infos_get() does not exist for the device.
350199a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
350253ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
350399a2dd95SBruce Richardson  */
3504*1ff8b9a6SStephen Hemminger int rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info)
3505*1ff8b9a6SStephen Hemminger 	__rte_warn_unused_result;
350699a2dd95SBruce Richardson 
350799a2dd95SBruce Richardson /**
3508632be327SJie Wang  * @warning
3509632be327SJie Wang  * @b EXPERIMENTAL: this API may change without prior notice.
3510632be327SJie Wang  *
3511632be327SJie Wang  * Retrieve the configuration of an Ethernet device.
3512632be327SJie Wang  *
3513632be327SJie Wang  * @param port_id
3514632be327SJie Wang  *   The port identifier of the Ethernet device.
3515632be327SJie Wang  * @param dev_conf
3516632be327SJie Wang  *   Location for Ethernet device configuration to be filled in.
3517632be327SJie Wang  * @return
3518632be327SJie Wang  *   - (0) if successful.
3519632be327SJie Wang  *   - (-ENODEV) if *port_id* invalid.
3520632be327SJie Wang  *   - (-EINVAL) if bad parameter.
3521632be327SJie Wang  */
3522632be327SJie Wang __rte_experimental
3523*1ff8b9a6SStephen Hemminger int rte_eth_dev_conf_get(uint16_t port_id, struct rte_eth_conf *dev_conf)
3524*1ff8b9a6SStephen Hemminger 	__rte_warn_unused_result;
3525632be327SJie Wang 
3526632be327SJie Wang /**
352799a2dd95SBruce Richardson  * Retrieve the firmware version of a device.
352899a2dd95SBruce Richardson  *
352999a2dd95SBruce Richardson  * @param port_id
353099a2dd95SBruce Richardson  *   The port identifier of the device.
353199a2dd95SBruce Richardson  * @param fw_version
353299a2dd95SBruce Richardson  *   A pointer to a string array storing the firmware version of a device,
353399a2dd95SBruce Richardson  *   the string includes terminating null. This pointer is allocated by caller.
353499a2dd95SBruce Richardson  * @param fw_size
353599a2dd95SBruce Richardson  *   The size of the string array pointed by fw_version, which should be
353699a2dd95SBruce Richardson  *   large enough to store firmware version of the device.
353799a2dd95SBruce Richardson  * @return
353899a2dd95SBruce Richardson  *   - (0) if successful.
353999a2dd95SBruce Richardson  *   - (-ENOTSUP) if operation is not supported.
354099a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
354199a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
354253ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
354399a2dd95SBruce Richardson  *   - (>0) if *fw_size* is not enough to store firmware version, return
354499a2dd95SBruce Richardson  *          the size of the non truncated string.
354599a2dd95SBruce Richardson  */
3546*1ff8b9a6SStephen Hemminger int rte_eth_dev_fw_version_get(uint16_t port_id, char *fw_version, size_t fw_size)
3547*1ff8b9a6SStephen Hemminger 	__rte_warn_unused_result;
354899a2dd95SBruce Richardson 
354999a2dd95SBruce Richardson /**
355099a2dd95SBruce Richardson  * Retrieve the supported packet types of an Ethernet device.
355199a2dd95SBruce Richardson  *
355299a2dd95SBruce Richardson  * When a packet type is announced as supported, it *must* be recognized by
355399a2dd95SBruce Richardson  * the PMD. For instance, if RTE_PTYPE_L2_ETHER, RTE_PTYPE_L2_ETHER_VLAN
355499a2dd95SBruce Richardson  * and RTE_PTYPE_L3_IPV4 are announced, the PMD must return the following
355599a2dd95SBruce Richardson  * packet types for these packets:
355699a2dd95SBruce Richardson  * - Ether/IPv4              -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4
35575b49ba65SAndrew Rybchenko  * - Ether/VLAN/IPv4         -> RTE_PTYPE_L2_ETHER_VLAN | RTE_PTYPE_L3_IPV4
355899a2dd95SBruce Richardson  * - Ether/[anything else]   -> RTE_PTYPE_L2_ETHER
35595b49ba65SAndrew Rybchenko  * - Ether/VLAN/[anything else] -> RTE_PTYPE_L2_ETHER_VLAN
356099a2dd95SBruce Richardson  *
356199a2dd95SBruce Richardson  * When a packet is received by a PMD, the most precise type must be
356299a2dd95SBruce Richardson  * returned among the ones supported. However a PMD is allowed to set
356399a2dd95SBruce Richardson  * packet type that is not in the supported list, at the condition that it
356499a2dd95SBruce Richardson  * is more precise. Therefore, a PMD announcing no supported packet types
356599a2dd95SBruce Richardson  * can still set a matching packet type in a received packet.
356699a2dd95SBruce Richardson  *
356799a2dd95SBruce Richardson  * @note
356809fd4227SAndrew Rybchenko  *   Better to invoke this API after the device is already started or Rx burst
356999a2dd95SBruce Richardson  *   function is decided, to obtain correct supported ptypes.
357099a2dd95SBruce Richardson  * @note
357199a2dd95SBruce Richardson  *   if a given PMD does not report what ptypes it supports, then the supported
357299a2dd95SBruce Richardson  *   ptype count is reported as 0.
357399a2dd95SBruce Richardson  * @param port_id
357499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
357599a2dd95SBruce Richardson  * @param ptype_mask
357699a2dd95SBruce Richardson  *   A hint of what kind of packet type which the caller is interested in.
357799a2dd95SBruce Richardson  * @param ptypes
357899a2dd95SBruce Richardson  *   An array pointer to store adequate packet types, allocated by caller.
357999a2dd95SBruce Richardson  * @param num
358099a2dd95SBruce Richardson  *  Size of the array pointed by param ptypes.
358199a2dd95SBruce Richardson  * @return
358299a2dd95SBruce Richardson  *   - (>=0) Number of supported ptypes. If the number of types exceeds num,
358399a2dd95SBruce Richardson  *           only num entries will be filled into the ptypes array, but the full
358499a2dd95SBruce Richardson  *           count of supported ptypes will be returned.
358599a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
358653ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
358799a2dd95SBruce Richardson  */
358899a2dd95SBruce Richardson int rte_eth_dev_get_supported_ptypes(uint16_t port_id, uint32_t ptype_mask,
3589*1ff8b9a6SStephen Hemminger 				     uint32_t *ptypes, int num)
3590*1ff8b9a6SStephen Hemminger 	__rte_warn_unused_result;
3591*1ff8b9a6SStephen Hemminger 
359299a2dd95SBruce Richardson /**
359399a2dd95SBruce Richardson  * Inform Ethernet device about reduced range of packet types to handle.
359499a2dd95SBruce Richardson  *
359599a2dd95SBruce Richardson  * Application can use this function to set only specific ptypes that it's
359699a2dd95SBruce Richardson  * interested. This information can be used by the PMD to optimize Rx path.
359799a2dd95SBruce Richardson  *
359899a2dd95SBruce Richardson  * The function accepts an array `set_ptypes` allocated by the caller to
359999a2dd95SBruce Richardson  * store the packet types set by the driver, the last element of the array
360099a2dd95SBruce Richardson  * is set to RTE_PTYPE_UNKNOWN. The size of the `set_ptype` array should be
360199a2dd95SBruce Richardson  * `rte_eth_dev_get_supported_ptypes() + 1` else it might only be filled
360299a2dd95SBruce Richardson  * partially.
360399a2dd95SBruce Richardson  *
360499a2dd95SBruce Richardson  * @param port_id
360599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
360699a2dd95SBruce Richardson  * @param ptype_mask
360799a2dd95SBruce Richardson  *   The ptype family that application is interested in should be bitwise OR of
360899a2dd95SBruce Richardson  *   RTE_PTYPE_*_MASK or 0.
360999a2dd95SBruce Richardson  * @param set_ptypes
361099a2dd95SBruce Richardson  *   An array pointer to store set packet types, allocated by caller. The
361199a2dd95SBruce Richardson  *   function marks the end of array with RTE_PTYPE_UNKNOWN.
361299a2dd95SBruce Richardson  * @param num
361399a2dd95SBruce Richardson  *   Size of the array pointed by param ptypes.
361499a2dd95SBruce Richardson  *   Should be rte_eth_dev_get_supported_ptypes() + 1 to accommodate the
361599a2dd95SBruce Richardson  *   set ptypes.
361699a2dd95SBruce Richardson  * @return
361799a2dd95SBruce Richardson  *   - (0) if Success.
361899a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
361999a2dd95SBruce Richardson  *   - (-EINVAL) if *ptype_mask* is invalid (or) set_ptypes is NULL and
362099a2dd95SBruce Richardson  *     num > 0.
362199a2dd95SBruce Richardson  */
362299a2dd95SBruce Richardson int rte_eth_dev_set_ptypes(uint16_t port_id, uint32_t ptype_mask,
362399a2dd95SBruce Richardson 			   uint32_t *set_ptypes, unsigned int num);
362499a2dd95SBruce Richardson 
362599a2dd95SBruce Richardson /**
362699a2dd95SBruce Richardson  * Retrieve the MTU of an Ethernet device.
362799a2dd95SBruce Richardson  *
362899a2dd95SBruce Richardson  * @param port_id
362999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
363099a2dd95SBruce Richardson  * @param mtu
363199a2dd95SBruce Richardson  *   A pointer to a uint16_t where the retrieved MTU is to be stored.
363299a2dd95SBruce Richardson  * @return
363399a2dd95SBruce Richardson  *   - (0) if successful.
363499a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
363553ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
363699a2dd95SBruce Richardson  */
363799a2dd95SBruce Richardson int rte_eth_dev_get_mtu(uint16_t port_id, uint16_t *mtu);
363899a2dd95SBruce Richardson 
363999a2dd95SBruce Richardson /**
364099a2dd95SBruce Richardson  * Change the MTU of an Ethernet device.
364199a2dd95SBruce Richardson  *
364299a2dd95SBruce Richardson  * @param port_id
364399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
364499a2dd95SBruce Richardson  * @param mtu
364599a2dd95SBruce Richardson  *   A uint16_t for the MTU to be applied.
364699a2dd95SBruce Richardson  * @return
364799a2dd95SBruce Richardson  *   - (0) if successful.
364899a2dd95SBruce Richardson  *   - (-ENOTSUP) if operation is not supported.
364999a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
365099a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
365199a2dd95SBruce Richardson  *   - (-EINVAL) if *mtu* invalid, validation of mtu can occur within
365299a2dd95SBruce Richardson  *     rte_eth_dev_set_mtu if dev_infos_get is supported by the device or
365399a2dd95SBruce Richardson  *     when the mtu is set using dev->dev_ops->mtu_set.
365499a2dd95SBruce Richardson  *   - (-EBUSY) if operation is not allowed when the port is running
365599a2dd95SBruce Richardson  */
365699a2dd95SBruce Richardson int rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu);
365799a2dd95SBruce Richardson 
365899a2dd95SBruce Richardson /**
365999a2dd95SBruce Richardson  * Enable/Disable hardware filtering by an Ethernet device of received
366099a2dd95SBruce Richardson  * VLAN packets tagged with a given VLAN Tag Identifier.
366199a2dd95SBruce Richardson  *
366299a2dd95SBruce Richardson  * @param port_id
366399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
366499a2dd95SBruce Richardson  * @param vlan_id
366599a2dd95SBruce Richardson  *   The VLAN Tag Identifier whose filtering must be enabled or disabled.
366699a2dd95SBruce Richardson  * @param on
366799a2dd95SBruce Richardson  *   If > 0, enable VLAN filtering of VLAN packets tagged with *vlan_id*.
366899a2dd95SBruce Richardson  *   Otherwise, disable VLAN filtering of VLAN packets tagged with *vlan_id*.
366999a2dd95SBruce Richardson  * @return
367099a2dd95SBruce Richardson  *   - (0) if successful.
367199a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware-assisted VLAN filtering not configured.
367299a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
367399a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
367499a2dd95SBruce Richardson  *   - (-ENOSYS) if VLAN filtering on *port_id* disabled.
367599a2dd95SBruce Richardson  *   - (-EINVAL) if *vlan_id* > 4095.
367699a2dd95SBruce Richardson  */
367799a2dd95SBruce Richardson int rte_eth_dev_vlan_filter(uint16_t port_id, uint16_t vlan_id, int on);
367899a2dd95SBruce Richardson 
367999a2dd95SBruce Richardson /**
368009fd4227SAndrew Rybchenko  * Enable/Disable hardware VLAN Strip by a Rx queue of an Ethernet device.
368199a2dd95SBruce Richardson  *
368299a2dd95SBruce Richardson  * @param port_id
368399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
368499a2dd95SBruce Richardson  * @param rx_queue_id
368599a2dd95SBruce Richardson  *   The index of the receive queue for which a queue stats mapping is required.
368699a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
368799a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
368899a2dd95SBruce Richardson  * @param on
368999a2dd95SBruce Richardson  *   If 1, Enable VLAN Stripping of the receive queue of the Ethernet port.
369099a2dd95SBruce Richardson  *   If 0, Disable VLAN Stripping of the receive queue of the Ethernet port.
369199a2dd95SBruce Richardson  * @return
369299a2dd95SBruce Richardson  *   - (0) if successful.
369399a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware-assisted VLAN stripping not configured.
369499a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
369599a2dd95SBruce Richardson  *   - (-EINVAL) if *rx_queue_id* invalid.
369699a2dd95SBruce Richardson  */
369799a2dd95SBruce Richardson int rte_eth_dev_set_vlan_strip_on_queue(uint16_t port_id, uint16_t rx_queue_id,
369899a2dd95SBruce Richardson 		int on);
369999a2dd95SBruce Richardson 
370099a2dd95SBruce Richardson /**
370199a2dd95SBruce Richardson  * Set the Outer VLAN Ether Type by an Ethernet device, it can be inserted to
370299a2dd95SBruce Richardson  * the VLAN header.
370399a2dd95SBruce Richardson  *
370499a2dd95SBruce Richardson  * @param port_id
370599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
370699a2dd95SBruce Richardson  * @param vlan_type
37075b49ba65SAndrew Rybchenko  *   The VLAN type.
370899a2dd95SBruce Richardson  * @param tag_type
370999a2dd95SBruce Richardson  *   The Tag Protocol ID
371099a2dd95SBruce Richardson  * @return
371199a2dd95SBruce Richardson  *   - (0) if successful.
371299a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware-assisted VLAN TPID setup is not supported.
371399a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
371499a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
371599a2dd95SBruce Richardson  */
371699a2dd95SBruce Richardson int rte_eth_dev_set_vlan_ether_type(uint16_t port_id,
371799a2dd95SBruce Richardson 				    enum rte_vlan_type vlan_type,
371899a2dd95SBruce Richardson 				    uint16_t tag_type);
371999a2dd95SBruce Richardson 
372099a2dd95SBruce Richardson /**
372199a2dd95SBruce Richardson  * Set VLAN offload configuration on an Ethernet device.
372299a2dd95SBruce Richardson  *
372399a2dd95SBruce Richardson  * @param port_id
372499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
372599a2dd95SBruce Richardson  * @param offload_mask
372699a2dd95SBruce Richardson  *   The VLAN Offload bit mask can be mixed use with "OR"
3727295968d1SFerruh Yigit  *       RTE_ETH_VLAN_STRIP_OFFLOAD
3728295968d1SFerruh Yigit  *       RTE_ETH_VLAN_FILTER_OFFLOAD
3729295968d1SFerruh Yigit  *       RTE_ETH_VLAN_EXTEND_OFFLOAD
3730295968d1SFerruh Yigit  *       RTE_ETH_QINQ_STRIP_OFFLOAD
373199a2dd95SBruce Richardson  * @return
373299a2dd95SBruce Richardson  *   - (0) if successful.
373399a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware-assisted VLAN filtering not configured.
373499a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
373599a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
373699a2dd95SBruce Richardson  */
373799a2dd95SBruce Richardson int rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask);
373899a2dd95SBruce Richardson 
373999a2dd95SBruce Richardson /**
374099a2dd95SBruce Richardson  * Read VLAN Offload configuration from an Ethernet device
374199a2dd95SBruce Richardson  *
374299a2dd95SBruce Richardson  * @param port_id
374399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
374499a2dd95SBruce Richardson  * @return
374599a2dd95SBruce Richardson  *   - (>0) if successful. Bit mask to indicate
3746295968d1SFerruh Yigit  *       RTE_ETH_VLAN_STRIP_OFFLOAD
3747295968d1SFerruh Yigit  *       RTE_ETH_VLAN_FILTER_OFFLOAD
3748295968d1SFerruh Yigit  *       RTE_ETH_VLAN_EXTEND_OFFLOAD
3749295968d1SFerruh Yigit  *       RTE_ETH_QINQ_STRIP_OFFLOAD
375099a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
375199a2dd95SBruce Richardson  */
375299a2dd95SBruce Richardson int rte_eth_dev_get_vlan_offload(uint16_t port_id);
375399a2dd95SBruce Richardson 
375499a2dd95SBruce Richardson /**
375509fd4227SAndrew Rybchenko  * Set port based Tx VLAN insertion on or off.
375699a2dd95SBruce Richardson  *
375799a2dd95SBruce Richardson  * @param port_id
375899a2dd95SBruce Richardson  *  The port identifier of the Ethernet device.
375999a2dd95SBruce Richardson  * @param pvid
376009fd4227SAndrew Rybchenko  *  Port based Tx VLAN identifier together with user priority.
376199a2dd95SBruce Richardson  * @param on
376209fd4227SAndrew Rybchenko  *  Turn on or off the port based Tx VLAN insertion.
376399a2dd95SBruce Richardson  *
376499a2dd95SBruce Richardson  * @return
376599a2dd95SBruce Richardson  *   - (0) if successful.
376699a2dd95SBruce Richardson  *   - negative if failed.
376799a2dd95SBruce Richardson  */
376899a2dd95SBruce Richardson int rte_eth_dev_set_vlan_pvid(uint16_t port_id, uint16_t pvid, int on);
376999a2dd95SBruce Richardson 
3770bc70e559SSpike Du /**
3771bc70e559SSpike Du  * @warning
3772bc70e559SSpike Du  * @b EXPERIMENTAL: this API may change without prior notice.
3773bc70e559SSpike Du  *
3774bc70e559SSpike Du  * Set Rx queue available descriptors threshold.
3775bc70e559SSpike Du  *
3776bc70e559SSpike Du  * @param port_id
3777bc70e559SSpike Du  *  The port identifier of the Ethernet device.
3778bc70e559SSpike Du  * @param queue_id
3779bc70e559SSpike Du  *  The index of the receive queue.
3780bc70e559SSpike Du  * @param avail_thresh
3781bc70e559SSpike Du  *  The available descriptors threshold is percentage of Rx queue size
3782bc70e559SSpike Du  *  which describes the availability of Rx queue for hardware.
3783bc70e559SSpike Du  *  If the Rx queue availability is below it,
3784bc70e559SSpike Du  *  the event RTE_ETH_EVENT_RX_AVAIL_THRESH is triggered.
3785bc70e559SSpike Du  *  [1-99] to set a new available descriptors threshold.
3786bc70e559SSpike Du  *  0 to disable threshold monitoring.
3787bc70e559SSpike Du  *
3788bc70e559SSpike Du  * @return
3789bc70e559SSpike Du  *   - 0 if successful.
3790bc70e559SSpike Du  *   - (-ENODEV) if @p port_id is invalid.
3791bc70e559SSpike Du  *   - (-EINVAL) if bad parameter.
3792bc70e559SSpike Du  *   - (-ENOTSUP) if available Rx descriptors threshold is not supported.
3793bc70e559SSpike Du  *   - (-EIO) if device is removed.
3794bc70e559SSpike Du  */
3795bc70e559SSpike Du __rte_experimental
3796bc70e559SSpike Du int rte_eth_rx_avail_thresh_set(uint16_t port_id, uint16_t queue_id,
3797bc70e559SSpike Du 			       uint8_t avail_thresh);
3798bc70e559SSpike Du 
3799bc70e559SSpike Du /**
3800bc70e559SSpike Du  * @warning
3801bc70e559SSpike Du  * @b EXPERIMENTAL: this API may change without prior notice.
3802bc70e559SSpike Du  *
3803bc70e559SSpike Du  * Find Rx queue with RTE_ETH_EVENT_RX_AVAIL_THRESH event pending.
3804bc70e559SSpike Du  *
3805bc70e559SSpike Du  * @param port_id
3806bc70e559SSpike Du  *  The port identifier of the Ethernet device.
3807bc70e559SSpike Du  * @param[inout] queue_id
3808bc70e559SSpike Du  *  On input starting Rx queue index to search from.
3809bc70e559SSpike Du  *  If the queue_id is bigger than maximum queue ID of the port,
3810bc70e559SSpike Du  *  search is started from 0. So that application can keep calling
3811bc70e559SSpike Du  *  this function to handle all pending events with a simple increment
3812bc70e559SSpike Du  *  of queue_id on the next call.
3813bc70e559SSpike Du  *  On output if return value is 1, Rx queue index with the event pending.
3814bc70e559SSpike Du  * @param[out] avail_thresh
3815bc70e559SSpike Du  *  Location for available descriptors threshold of the found Rx queue.
3816bc70e559SSpike Du  *
3817bc70e559SSpike Du  * @return
3818bc70e559SSpike Du  *   - 1 if an Rx queue with pending event is found.
3819bc70e559SSpike Du  *   - 0 if no Rx queue with pending event is found.
3820bc70e559SSpike Du  *   - (-ENODEV) if @p port_id is invalid.
3821bc70e559SSpike Du  *   - (-EINVAL) if bad parameter (e.g. @p queue_id is NULL).
3822bc70e559SSpike Du  *   - (-ENOTSUP) if operation is not supported.
3823bc70e559SSpike Du  *   - (-EIO) if device is removed.
3824bc70e559SSpike Du  */
3825bc70e559SSpike Du __rte_experimental
3826bc70e559SSpike Du int rte_eth_rx_avail_thresh_query(uint16_t port_id, uint16_t *queue_id,
3827bc70e559SSpike Du 				 uint8_t *avail_thresh);
3828bc70e559SSpike Du 
382999a2dd95SBruce Richardson typedef void (*buffer_tx_error_fn)(struct rte_mbuf **unsent, uint16_t count,
383099a2dd95SBruce Richardson 		void *userdata);
383199a2dd95SBruce Richardson 
383299a2dd95SBruce Richardson /**
383309fd4227SAndrew Rybchenko  * Structure used to buffer packets for future Tx
383499a2dd95SBruce Richardson  * Used by APIs rte_eth_tx_buffer and rte_eth_tx_buffer_flush
383599a2dd95SBruce Richardson  */
383699a2dd95SBruce Richardson struct rte_eth_dev_tx_buffer {
383799a2dd95SBruce Richardson 	buffer_tx_error_fn error_callback;
383899a2dd95SBruce Richardson 	void *error_userdata;
383909fd4227SAndrew Rybchenko 	uint16_t size;           /**< Size of buffer for buffered Tx */
384099a2dd95SBruce Richardson 	uint16_t length;         /**< Number of packets in the array */
38413c2ca0a9SAndrew Rybchenko 	/** Pending packets to be sent on explicit flush or when full */
384299a2dd95SBruce Richardson 	struct rte_mbuf *pkts[];
384399a2dd95SBruce Richardson };
384499a2dd95SBruce Richardson 
384599a2dd95SBruce Richardson /**
384609fd4227SAndrew Rybchenko  * Calculate the size of the Tx buffer.
384799a2dd95SBruce Richardson  *
384899a2dd95SBruce Richardson  * @param sz
384999a2dd95SBruce Richardson  *   Number of stored packets.
385099a2dd95SBruce Richardson  */
385199a2dd95SBruce Richardson #define RTE_ETH_TX_BUFFER_SIZE(sz) \
385299a2dd95SBruce Richardson 	(sizeof(struct rte_eth_dev_tx_buffer) + (sz) * sizeof(struct rte_mbuf *))
385399a2dd95SBruce Richardson 
385499a2dd95SBruce Richardson /**
385599a2dd95SBruce Richardson  * Initialize default values for buffered transmitting
385699a2dd95SBruce Richardson  *
385799a2dd95SBruce Richardson  * @param buffer
385899a2dd95SBruce Richardson  *   Tx buffer to be initialized.
385999a2dd95SBruce Richardson  * @param size
386099a2dd95SBruce Richardson  *   Buffer size
386199a2dd95SBruce Richardson  * @return
386299a2dd95SBruce Richardson  *   0 if no error
386399a2dd95SBruce Richardson  */
386499a2dd95SBruce Richardson int
386599a2dd95SBruce Richardson rte_eth_tx_buffer_init(struct rte_eth_dev_tx_buffer *buffer, uint16_t size);
386699a2dd95SBruce Richardson 
386799a2dd95SBruce Richardson /**
386899a2dd95SBruce Richardson  * Configure a callback for buffered packets which cannot be sent
386999a2dd95SBruce Richardson  *
387099a2dd95SBruce Richardson  * Register a specific callback to be called when an attempt is made to send
38710d9f56a8SAndrew Rybchenko  * all packets buffered on an Ethernet port, but not all packets can
387299a2dd95SBruce Richardson  * successfully be sent. The callback registered here will be called only
387399a2dd95SBruce Richardson  * from calls to rte_eth_tx_buffer() and rte_eth_tx_buffer_flush() APIs.
387499a2dd95SBruce Richardson  * The default callback configured for each queue by default just frees the
387599a2dd95SBruce Richardson  * packets back to the calling mempool. If additional behaviour is required,
387699a2dd95SBruce Richardson  * for example, to count dropped packets, or to retry transmission of packets
387799a2dd95SBruce Richardson  * which cannot be sent, this function should be used to register a suitable
387899a2dd95SBruce Richardson  * callback function to implement the desired behaviour.
38794b98bef7SBruce Richardson  * The example callback "rte_eth_tx_buffer_count_callback()" is also
388099a2dd95SBruce Richardson  * provided as reference.
388199a2dd95SBruce Richardson  *
388299a2dd95SBruce Richardson  * @param buffer
388399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
388499a2dd95SBruce Richardson  * @param callback
388599a2dd95SBruce Richardson  *   The function to be used as the callback.
388699a2dd95SBruce Richardson  * @param userdata
388799a2dd95SBruce Richardson  *   Arbitrary parameter to be passed to the callback function
388899a2dd95SBruce Richardson  * @return
388953ef1b34SMin Hu (Connor)  *   0 on success, or -EINVAL if bad parameter
389099a2dd95SBruce Richardson  */
389199a2dd95SBruce Richardson int
389299a2dd95SBruce Richardson rte_eth_tx_buffer_set_err_callback(struct rte_eth_dev_tx_buffer *buffer,
389399a2dd95SBruce Richardson 		buffer_tx_error_fn callback, void *userdata);
389499a2dd95SBruce Richardson 
389599a2dd95SBruce Richardson /**
389699a2dd95SBruce Richardson  * Callback function for silently dropping unsent buffered packets.
389799a2dd95SBruce Richardson  *
389899a2dd95SBruce Richardson  * This function can be passed to rte_eth_tx_buffer_set_err_callback() to
389999a2dd95SBruce Richardson  * adjust the default behavior when buffered packets cannot be sent. This
390009fd4227SAndrew Rybchenko  * function drops any unsent packets silently and is used by Tx buffered
390199a2dd95SBruce Richardson  * operations as default behavior.
390299a2dd95SBruce Richardson  *
390399a2dd95SBruce Richardson  * NOTE: this function should not be called directly, instead it should be used
390499a2dd95SBruce Richardson  *       as a callback for packet buffering.
390599a2dd95SBruce Richardson  *
390699a2dd95SBruce Richardson  * NOTE: when configuring this function as a callback with
390799a2dd95SBruce Richardson  *       rte_eth_tx_buffer_set_err_callback(), the final, userdata parameter
390899a2dd95SBruce Richardson  *       should point to an uint64_t value.
390999a2dd95SBruce Richardson  *
391099a2dd95SBruce Richardson  * @param pkts
391199a2dd95SBruce Richardson  *   The previously buffered packets which could not be sent
391299a2dd95SBruce Richardson  * @param unsent
391399a2dd95SBruce Richardson  *   The number of unsent packets in the pkts array
391499a2dd95SBruce Richardson  * @param userdata
391599a2dd95SBruce Richardson  *   Not used
391699a2dd95SBruce Richardson  */
391799a2dd95SBruce Richardson void
391899a2dd95SBruce Richardson rte_eth_tx_buffer_drop_callback(struct rte_mbuf **pkts, uint16_t unsent,
391999a2dd95SBruce Richardson 		void *userdata);
392099a2dd95SBruce Richardson 
392199a2dd95SBruce Richardson /**
392299a2dd95SBruce Richardson  * Callback function for tracking unsent buffered packets.
392399a2dd95SBruce Richardson  *
392499a2dd95SBruce Richardson  * This function can be passed to rte_eth_tx_buffer_set_err_callback() to
392599a2dd95SBruce Richardson  * adjust the default behavior when buffered packets cannot be sent. This
392699a2dd95SBruce Richardson  * function drops any unsent packets, but also updates a user-supplied counter
392799a2dd95SBruce Richardson  * to track the overall number of packets dropped. The counter should be an
392899a2dd95SBruce Richardson  * uint64_t variable.
392999a2dd95SBruce Richardson  *
393099a2dd95SBruce Richardson  * NOTE: this function should not be called directly, instead it should be used
393199a2dd95SBruce Richardson  *       as a callback for packet buffering.
393299a2dd95SBruce Richardson  *
393399a2dd95SBruce Richardson  * NOTE: when configuring this function as a callback with
393499a2dd95SBruce Richardson  *       rte_eth_tx_buffer_set_err_callback(), the final, userdata parameter
393599a2dd95SBruce Richardson  *       should point to an uint64_t value.
393699a2dd95SBruce Richardson  *
393799a2dd95SBruce Richardson  * @param pkts
393899a2dd95SBruce Richardson  *   The previously buffered packets which could not be sent
393999a2dd95SBruce Richardson  * @param unsent
394099a2dd95SBruce Richardson  *   The number of unsent packets in the pkts array
394199a2dd95SBruce Richardson  * @param userdata
394299a2dd95SBruce Richardson  *   Pointer to an uint64_t value, which will be incremented by unsent
394399a2dd95SBruce Richardson  */
394499a2dd95SBruce Richardson void
394599a2dd95SBruce Richardson rte_eth_tx_buffer_count_callback(struct rte_mbuf **pkts, uint16_t unsent,
394699a2dd95SBruce Richardson 		void *userdata);
394799a2dd95SBruce Richardson 
394899a2dd95SBruce Richardson /**
394999a2dd95SBruce Richardson  * Request the driver to free mbufs currently cached by the driver. The
395099a2dd95SBruce Richardson  * driver will only free the mbuf if it is no longer in use. It is the
395199a2dd95SBruce Richardson  * application's responsibility to ensure rte_eth_tx_buffer_flush(..) is
395299a2dd95SBruce Richardson  * called if needed.
395399a2dd95SBruce Richardson  *
395499a2dd95SBruce Richardson  * @param port_id
395599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
395699a2dd95SBruce Richardson  * @param queue_id
395799a2dd95SBruce Richardson  *   The index of the transmit queue through which output packets must be
395899a2dd95SBruce Richardson  *   sent.
395999a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
396099a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
396199a2dd95SBruce Richardson  * @param free_cnt
396299a2dd95SBruce Richardson  *   Maximum number of packets to free. Use 0 to indicate all possible packets
396399a2dd95SBruce Richardson  *   should be freed. Note that a packet may be using multiple mbufs.
396499a2dd95SBruce Richardson  * @return
396599a2dd95SBruce Richardson  *   Failure: < 0
396699a2dd95SBruce Richardson  *     -ENODEV: Invalid interface
396799a2dd95SBruce Richardson  *     -EIO: device is removed
396899a2dd95SBruce Richardson  *     -ENOTSUP: Driver does not support function
396999a2dd95SBruce Richardson  *   Success: >= 0
397099a2dd95SBruce Richardson  *     0-n: Number of packets freed. More packets may still remain in ring that
397199a2dd95SBruce Richardson  *     are in use.
397299a2dd95SBruce Richardson  */
397399a2dd95SBruce Richardson int
397499a2dd95SBruce Richardson rte_eth_tx_done_cleanup(uint16_t port_id, uint16_t queue_id, uint32_t free_cnt);
397599a2dd95SBruce Richardson 
397699a2dd95SBruce Richardson /**
39770aaf0975SAkhil Goyal  * Subtypes for MACsec offload event (@ref RTE_ETH_EVENT_MACSEC)
39780aaf0975SAkhil Goyal  * raised by Ethernet device.
39790aaf0975SAkhil Goyal  */
39800aaf0975SAkhil Goyal enum rte_eth_event_macsec_subtype {
39810aaf0975SAkhil Goyal 	/** Notifies unknown MACsec subevent. */
39820aaf0975SAkhil Goyal 	RTE_ETH_SUBEVENT_MACSEC_UNKNOWN,
39830aaf0975SAkhil Goyal 	/**
39840aaf0975SAkhil Goyal 	 * Subevent of RTE_ETH_EVENT_MACSEC_SECTAG_VAL_ERR sectag validation events
39850aaf0975SAkhil Goyal 	 *	Validation check: SecTag.TCI.V = 1
39860aaf0975SAkhil Goyal 	 */
39870aaf0975SAkhil Goyal 	RTE_ETH_SUBEVENT_MACSEC_RX_SECTAG_V_EQ1,
39880aaf0975SAkhil Goyal 	/**
39890aaf0975SAkhil Goyal 	 * Subevent of RTE_ETH_EVENT_MACSEC_SECTAG_VAL_ERR sectag validation events
39900aaf0975SAkhil Goyal 	 *	Validation check: SecTag.TCI.E = 0 && SecTag.TCI.C = 1
39910aaf0975SAkhil Goyal 	 */
39920aaf0975SAkhil Goyal 	RTE_ETH_SUBEVENT_MACSEC_RX_SECTAG_E_EQ0_C_EQ1,
39930aaf0975SAkhil Goyal 	/**
39940aaf0975SAkhil Goyal 	 * Subevent of RTE_ETH_EVENT_MACSEC_SECTAG_VAL_ERR sectag validation events
39950aaf0975SAkhil Goyal 	 *	Validation check: SecTag.SL >= 'd48
39960aaf0975SAkhil Goyal 	 */
39970aaf0975SAkhil Goyal 	RTE_ETH_SUBEVENT_MACSEC_RX_SECTAG_SL_GTE48,
39980aaf0975SAkhil Goyal 	/**
39990aaf0975SAkhil Goyal 	 * Subevent of RTE_ETH_EVENT_MACSEC_SECTAG_VAL_ERR sectag validation events
40000aaf0975SAkhil Goyal 	 *	Validation check: SecTag.TCI.ES = 1 && SecTag.TCI.SC = 1
40010aaf0975SAkhil Goyal 	 */
40020aaf0975SAkhil Goyal 	RTE_ETH_SUBEVENT_MACSEC_RX_SECTAG_ES_EQ1_SC_EQ1,
40030aaf0975SAkhil Goyal 	/**
40040aaf0975SAkhil Goyal 	 * Subevent of RTE_ETH_EVENT_MACSEC_SECTAG_VAL_ERR sectag validation events
40050aaf0975SAkhil Goyal 	 *	Validation check: SecTag.TCI.SC = 1 && SecTag.TCI.SCB = 1
40060aaf0975SAkhil Goyal 	 */
40070aaf0975SAkhil Goyal 	RTE_ETH_SUBEVENT_MACSEC_RX_SECTAG_SC_EQ1_SCB_EQ1,
40080aaf0975SAkhil Goyal };
40090aaf0975SAkhil Goyal 
40100aaf0975SAkhil Goyal /**
40110aaf0975SAkhil Goyal  * Event types for MACsec offload event (@ref RTE_ETH_EVENT_MACSEC)
40120aaf0975SAkhil Goyal  * raised by eth device.
40130aaf0975SAkhil Goyal  */
40140aaf0975SAkhil Goyal enum rte_eth_event_macsec_type {
40150aaf0975SAkhil Goyal 	/** Notifies unknown MACsec event. */
40160aaf0975SAkhil Goyal 	RTE_ETH_EVENT_MACSEC_UNKNOWN,
40170aaf0975SAkhil Goyal 	/** Notifies Sectag validation failure events. */
40180aaf0975SAkhil Goyal 	RTE_ETH_EVENT_MACSEC_SECTAG_VAL_ERR,
40190aaf0975SAkhil Goyal 	/** Notifies Rx SA hard expiry events. */
40200aaf0975SAkhil Goyal 	RTE_ETH_EVENT_MACSEC_RX_SA_PN_HARD_EXP,
40210aaf0975SAkhil Goyal 	/** Notifies Rx SA soft expiry events. */
40220aaf0975SAkhil Goyal 	RTE_ETH_EVENT_MACSEC_RX_SA_PN_SOFT_EXP,
40230aaf0975SAkhil Goyal 	/** Notifies Tx SA hard expiry events. */
40240aaf0975SAkhil Goyal 	RTE_ETH_EVENT_MACSEC_TX_SA_PN_HARD_EXP,
40250aaf0975SAkhil Goyal 	/** Notifies Tx SA soft events. */
40260aaf0975SAkhil Goyal 	RTE_ETH_EVENT_MACSEC_TX_SA_PN_SOFT_EXP,
40270aaf0975SAkhil Goyal 	/** Notifies Invalid SA event. */
40280aaf0975SAkhil Goyal 	RTE_ETH_EVENT_MACSEC_SA_NOT_VALID,
40290aaf0975SAkhil Goyal };
40300aaf0975SAkhil Goyal 
40310aaf0975SAkhil Goyal /**
40320aaf0975SAkhil Goyal  * Descriptor for @ref RTE_ETH_EVENT_MACSEC event.
40330aaf0975SAkhil Goyal  * Used by ethdev to send extra information of the MACsec offload event.
40340aaf0975SAkhil Goyal  */
40350aaf0975SAkhil Goyal struct rte_eth_event_macsec_desc {
40360aaf0975SAkhil Goyal 	/** Type of RTE_ETH_EVENT_MACSEC_* event. */
40370aaf0975SAkhil Goyal 	enum rte_eth_event_macsec_type type;
40380aaf0975SAkhil Goyal 	/** Type of RTE_ETH_SUBEVENT_MACSEC_* subevent. */
40390aaf0975SAkhil Goyal 	enum rte_eth_event_macsec_subtype subtype;
40400aaf0975SAkhil Goyal 	/**
40410aaf0975SAkhil Goyal 	 * Event specific metadata.
40420aaf0975SAkhil Goyal 	 *
40430aaf0975SAkhil Goyal 	 * For the following events, *userdata* registered
40440aaf0975SAkhil Goyal 	 * with the *rte_security_session* would be returned
40450aaf0975SAkhil Goyal 	 * as metadata.
40460aaf0975SAkhil Goyal 	 *
40470aaf0975SAkhil Goyal 	 * @see struct rte_security_session_conf
40480aaf0975SAkhil Goyal 	 */
40490aaf0975SAkhil Goyal 	uint64_t metadata;
40500aaf0975SAkhil Goyal };
40510aaf0975SAkhil Goyal 
40520aaf0975SAkhil Goyal /**
405399a2dd95SBruce Richardson  * Subtypes for IPsec offload event(@ref RTE_ETH_EVENT_IPSEC) raised by
405499a2dd95SBruce Richardson  * eth device.
405599a2dd95SBruce Richardson  */
405699a2dd95SBruce Richardson enum rte_eth_event_ipsec_subtype {
405787ec050bSNithin Dabilpuram 	/**  PMD specific error start */
405887ec050bSNithin Dabilpuram 	RTE_ETH_EVENT_IPSEC_PMD_ERROR_START = -256,
405987ec050bSNithin Dabilpuram 	/**  PMD specific error end */
406087ec050bSNithin Dabilpuram 	RTE_ETH_EVENT_IPSEC_PMD_ERROR_END = -1,
40613c2ca0a9SAndrew Rybchenko 	/** Unknown event type */
406299a2dd95SBruce Richardson 	RTE_ETH_EVENT_IPSEC_UNKNOWN = 0,
40633c2ca0a9SAndrew Rybchenko 	/** Sequence number overflow */
406499a2dd95SBruce Richardson 	RTE_ETH_EVENT_IPSEC_ESN_OVERFLOW,
40653c2ca0a9SAndrew Rybchenko 	/** Soft time expiry of SA */
406699a2dd95SBruce Richardson 	RTE_ETH_EVENT_IPSEC_SA_TIME_EXPIRY,
4067d1ce79d1SVamsi Attunuru 	/**
4068d1ce79d1SVamsi Attunuru 	 * Soft byte expiry of SA determined by
4069d1ce79d1SVamsi Attunuru 	 * @ref rte_security_ipsec_lifetime::bytes_soft_limit
4070d1ce79d1SVamsi Attunuru 	 */
407199a2dd95SBruce Richardson 	RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY,
4072d1ce79d1SVamsi Attunuru 	/**
4073d1ce79d1SVamsi Attunuru 	 * Soft packet expiry of SA determined by
4074d1ce79d1SVamsi Attunuru 	 * @ref rte_security_ipsec_lifetime::packets_soft_limit
4075d1ce79d1SVamsi Attunuru 	 */
4076d1ce79d1SVamsi Attunuru 	RTE_ETH_EVENT_IPSEC_SA_PKT_EXPIRY,
4077d1ce79d1SVamsi Attunuru 	/**
4078d1ce79d1SVamsi Attunuru 	 * Hard byte expiry of SA determined by
4079d1ce79d1SVamsi Attunuru 	 * @ref rte_security_ipsec_lifetime::bytes_hard_limit
4080d1ce79d1SVamsi Attunuru 	 */
4081d1ce79d1SVamsi Attunuru 	RTE_ETH_EVENT_IPSEC_SA_BYTE_HARD_EXPIRY,
4082d1ce79d1SVamsi Attunuru 	/**
4083d1ce79d1SVamsi Attunuru 	 * Hard packet expiry of SA determined by
4084d1ce79d1SVamsi Attunuru 	 * @ref rte_security_ipsec_lifetime::packets_hard_limit
4085d1ce79d1SVamsi Attunuru 	 */
4086d1ce79d1SVamsi Attunuru 	RTE_ETH_EVENT_IPSEC_SA_PKT_HARD_EXPIRY,
40873c2ca0a9SAndrew Rybchenko 	/** Max value of this enum */
408899a2dd95SBruce Richardson 	RTE_ETH_EVENT_IPSEC_MAX
408999a2dd95SBruce Richardson };
409099a2dd95SBruce Richardson 
409199a2dd95SBruce Richardson /**
409299a2dd95SBruce Richardson  * Descriptor for @ref RTE_ETH_EVENT_IPSEC event. Used by eth dev to send extra
409399a2dd95SBruce Richardson  * information of the IPsec offload event.
409499a2dd95SBruce Richardson  */
409599a2dd95SBruce Richardson struct rte_eth_event_ipsec_desc {
40963c2ca0a9SAndrew Rybchenko 	/** Type of RTE_ETH_EVENT_IPSEC_* event */
409799a2dd95SBruce Richardson 	enum rte_eth_event_ipsec_subtype subtype;
40983c2ca0a9SAndrew Rybchenko 	/**
40993c2ca0a9SAndrew Rybchenko 	 * Event specific metadata.
410099a2dd95SBruce Richardson 	 *
410199a2dd95SBruce Richardson 	 * For the following events, *userdata* registered
410299a2dd95SBruce Richardson 	 * with the *rte_security_session* would be returned
410399a2dd95SBruce Richardson 	 * as metadata,
410499a2dd95SBruce Richardson 	 *
410599a2dd95SBruce Richardson 	 * - @ref RTE_ETH_EVENT_IPSEC_ESN_OVERFLOW
410699a2dd95SBruce Richardson 	 * - @ref RTE_ETH_EVENT_IPSEC_SA_TIME_EXPIRY
410799a2dd95SBruce Richardson 	 * - @ref RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY
4108d1ce79d1SVamsi Attunuru 	 * - @ref RTE_ETH_EVENT_IPSEC_SA_PKT_EXPIRY
4109d1ce79d1SVamsi Attunuru 	 * - @ref RTE_ETH_EVENT_IPSEC_SA_BYTE_HARD_EXPIRY
4110d1ce79d1SVamsi Attunuru 	 * - @ref RTE_ETH_EVENT_IPSEC_SA_PKT_HARD_EXPIRY
411199a2dd95SBruce Richardson 	 *
411299a2dd95SBruce Richardson 	 * @see struct rte_security_session_conf
411399a2dd95SBruce Richardson 	 *
411499a2dd95SBruce Richardson 	 */
41153c2ca0a9SAndrew Rybchenko 	uint64_t metadata;
411699a2dd95SBruce Richardson };
411799a2dd95SBruce Richardson 
411899a2dd95SBruce Richardson /**
411999a2dd95SBruce Richardson  * The eth device event type for interrupt, and maybe others in the future.
412099a2dd95SBruce Richardson  */
412199a2dd95SBruce Richardson enum rte_eth_event_type {
412299a2dd95SBruce Richardson 	RTE_ETH_EVENT_UNKNOWN,  /**< unknown event type */
412399a2dd95SBruce Richardson 	RTE_ETH_EVENT_INTR_LSC, /**< lsc interrupt event */
41243c2ca0a9SAndrew Rybchenko 	/** queue state event (enabled/disabled) */
412599a2dd95SBruce Richardson 	RTE_ETH_EVENT_QUEUE_STATE,
41263c2ca0a9SAndrew Rybchenko 	/** reset interrupt event, sent to VF on PF reset */
412799a2dd95SBruce Richardson 	RTE_ETH_EVENT_INTR_RESET,
412899a2dd95SBruce Richardson 	RTE_ETH_EVENT_VF_MBOX,  /**< message from the VF received by PF */
412999a2dd95SBruce Richardson 	RTE_ETH_EVENT_MACSEC,   /**< MACsec offload related event */
413099a2dd95SBruce Richardson 	RTE_ETH_EVENT_INTR_RMV, /**< device removal event */
413199a2dd95SBruce Richardson 	RTE_ETH_EVENT_NEW,      /**< port is probed */
413299a2dd95SBruce Richardson 	RTE_ETH_EVENT_DESTROY,  /**< port is released */
413399a2dd95SBruce Richardson 	RTE_ETH_EVENT_IPSEC,    /**< IPsec offload related event */
413499a2dd95SBruce Richardson 	RTE_ETH_EVENT_FLOW_AGED,/**< New aged-out flows is detected */
4135bc70e559SSpike Du 	/**
4136bc70e559SSpike Du 	 * Number of available Rx descriptors is smaller than the threshold.
4137bc70e559SSpike Du 	 * @see rte_eth_rx_avail_thresh_set()
4138bc70e559SSpike Du 	 */
4139bc70e559SSpike Du 	RTE_ETH_EVENT_RX_AVAIL_THRESH,
4140eb0d471aSKalesh AP 	/** Port recovering from a hardware or firmware error.
4141eb0d471aSKalesh AP 	 * If PMD supports proactive error recovery,
4142eb0d471aSKalesh AP 	 * it should trigger this event to notify application
4143eb0d471aSKalesh AP 	 * that it detected an error and the recovery is being started.
4144eb0d471aSKalesh AP 	 * Upon receiving the event, the application should not invoke any control path API
4145eb0d471aSKalesh AP 	 * (such as rte_eth_dev_configure/rte_eth_dev_stop...) until receiving
4146eb0d471aSKalesh AP 	 * RTE_ETH_EVENT_RECOVERY_SUCCESS or RTE_ETH_EVENT_RECOVERY_FAILED event.
4147eb0d471aSKalesh AP 	 * The PMD will set the data path pointers to dummy functions,
4148eb0d471aSKalesh AP 	 * and re-set the data path pointers to non-dummy functions
4149eb0d471aSKalesh AP 	 * before reporting RTE_ETH_EVENT_RECOVERY_SUCCESS event.
4150eb0d471aSKalesh AP 	 * It means that the application cannot send or receive any packets
4151eb0d471aSKalesh AP 	 * during this period.
4152eb0d471aSKalesh AP 	 * @note Before the PMD reports the recovery result,
4153eb0d471aSKalesh AP 	 * the PMD may report the RTE_ETH_EVENT_ERR_RECOVERING event again,
4154eb0d471aSKalesh AP 	 * because a larger error may occur during the recovery.
4155eb0d471aSKalesh AP 	 */
4156eb0d471aSKalesh AP 	RTE_ETH_EVENT_ERR_RECOVERING,
4157eb0d471aSKalesh AP 	/** Port recovers successfully from the error.
4158eb0d471aSKalesh AP 	 * The PMD already re-configured the port,
4159eb0d471aSKalesh AP 	 * and the effect is the same as a restart operation.
4160eb0d471aSKalesh AP 	 * a) The following operation will be retained: (alphabetically)
4161eb0d471aSKalesh AP 	 *    - DCB configuration
4162eb0d471aSKalesh AP 	 *    - FEC configuration
4163eb0d471aSKalesh AP 	 *    - Flow control configuration
4164eb0d471aSKalesh AP 	 *    - LRO configuration
4165eb0d471aSKalesh AP 	 *    - LSC configuration
4166eb0d471aSKalesh AP 	 *    - MTU
4167eb0d471aSKalesh AP 	 *    - MAC address (default and those supplied by MAC address array)
4168eb0d471aSKalesh AP 	 *    - Promiscuous and allmulticast mode
4169eb0d471aSKalesh AP 	 *    - PTP configuration
4170eb0d471aSKalesh AP 	 *    - Queue (Rx/Tx) settings
4171eb0d471aSKalesh AP 	 *    - Queue statistics mappings
4172eb0d471aSKalesh AP 	 *    - RSS configuration by rte_eth_dev_rss_xxx() family
4173eb0d471aSKalesh AP 	 *    - Rx checksum configuration
4174eb0d471aSKalesh AP 	 *    - Rx interrupt settings
4175eb0d471aSKalesh AP 	 *    - Traffic management configuration
4176eb0d471aSKalesh AP 	 *    - VLAN configuration (including filtering, tpid, strip, pvid)
4177eb0d471aSKalesh AP 	 *    - VMDq configuration
4178eb0d471aSKalesh AP 	 * b) The following configuration maybe retained
4179eb0d471aSKalesh AP 	 *    or not depending on the device capabilities:
4180eb0d471aSKalesh AP 	 *    - flow rules
4181eb0d471aSKalesh AP 	 *      (@see RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP)
4182eb0d471aSKalesh AP 	 *    - shared flow objects
4183eb0d471aSKalesh AP 	 *      (@see RTE_ETH_DEV_CAPA_FLOW_SHARED_OBJECT_KEEP)
4184eb0d471aSKalesh AP 	 * c) Any other configuration will not be stored
4185eb0d471aSKalesh AP 	 *    and will need to be re-configured.
4186eb0d471aSKalesh AP 	 */
4187eb0d471aSKalesh AP 	RTE_ETH_EVENT_RECOVERY_SUCCESS,
4188eb0d471aSKalesh AP 	/** Port recovery failed.
4189eb0d471aSKalesh AP 	 * It means that the port should not be usable anymore.
4190eb0d471aSKalesh AP 	 * The application should close the port.
4191eb0d471aSKalesh AP 	 */
4192eb0d471aSKalesh AP 	RTE_ETH_EVENT_RECOVERY_FAILED,
419399a2dd95SBruce Richardson 	RTE_ETH_EVENT_MAX       /**< max value of this enum */
419499a2dd95SBruce Richardson };
419599a2dd95SBruce Richardson 
419605ec4ee5SDavid Marchand /**
419705ec4ee5SDavid Marchand  * User application callback to be registered for interrupts.
419805ec4ee5SDavid Marchand  *
419905ec4ee5SDavid Marchand  * Note: there is no guarantee in the DPDK drivers that a callback won't be
420005ec4ee5SDavid Marchand  *       called in the middle of other parts of the ethdev API. For example,
420105ec4ee5SDavid Marchand  *       imagine that thread A calls rte_eth_dev_start() and as part of this
420205ec4ee5SDavid Marchand  *       call, a RTE_ETH_EVENT_INTR_RESET event gets generated and the
420305ec4ee5SDavid Marchand  *       associated callback is ran on thread A. In that example, if the
420405ec4ee5SDavid Marchand  *       application protects its internal data using locks before calling
420505ec4ee5SDavid Marchand  *       rte_eth_dev_start(), and the callback takes a same lock, a deadlock
420605ec4ee5SDavid Marchand  *       occurs. Because of this, it is highly recommended NOT to take locks in
420705ec4ee5SDavid Marchand  *       those callbacks.
420805ec4ee5SDavid Marchand  */
420999a2dd95SBruce Richardson typedef int (*rte_eth_dev_cb_fn)(uint16_t port_id,
421099a2dd95SBruce Richardson 		enum rte_eth_event_type event, void *cb_arg, void *ret_param);
421199a2dd95SBruce Richardson 
421299a2dd95SBruce Richardson /**
421399a2dd95SBruce Richardson  * Register a callback function for port event.
421499a2dd95SBruce Richardson  *
421599a2dd95SBruce Richardson  * @param port_id
42165906be5aSAndrew Rybchenko  *  Port ID.
421799a2dd95SBruce Richardson  *  RTE_ETH_ALL means register the event for all port ids.
421899a2dd95SBruce Richardson  * @param event
421999a2dd95SBruce Richardson  *  Event interested.
422099a2dd95SBruce Richardson  * @param cb_fn
422199a2dd95SBruce Richardson  *  User supplied callback function to be called.
422299a2dd95SBruce Richardson  * @param cb_arg
422399a2dd95SBruce Richardson  *  Pointer to the parameters for the registered callback.
422499a2dd95SBruce Richardson  *
422599a2dd95SBruce Richardson  * @return
422699a2dd95SBruce Richardson  *  - On success, zero.
422799a2dd95SBruce Richardson  *  - On failure, a negative value.
422899a2dd95SBruce Richardson  */
422999a2dd95SBruce Richardson int rte_eth_dev_callback_register(uint16_t port_id,
423099a2dd95SBruce Richardson 			enum rte_eth_event_type event,
423199a2dd95SBruce Richardson 		rte_eth_dev_cb_fn cb_fn, void *cb_arg);
423299a2dd95SBruce Richardson 
423399a2dd95SBruce Richardson /**
423499a2dd95SBruce Richardson  * Unregister a callback function for port event.
423599a2dd95SBruce Richardson  *
423699a2dd95SBruce Richardson  * @param port_id
42375906be5aSAndrew Rybchenko  *  Port ID.
423899a2dd95SBruce Richardson  *  RTE_ETH_ALL means unregister the event for all port ids.
423999a2dd95SBruce Richardson  * @param event
424099a2dd95SBruce Richardson  *  Event interested.
424199a2dd95SBruce Richardson  * @param cb_fn
424299a2dd95SBruce Richardson  *  User supplied callback function to be called.
424399a2dd95SBruce Richardson  * @param cb_arg
424499a2dd95SBruce Richardson  *  Pointer to the parameters for the registered callback. -1 means to
424599a2dd95SBruce Richardson  *  remove all for the same callback address and same event.
424699a2dd95SBruce Richardson  *
424799a2dd95SBruce Richardson  * @return
424899a2dd95SBruce Richardson  *  - On success, zero.
424999a2dd95SBruce Richardson  *  - On failure, a negative value.
425099a2dd95SBruce Richardson  */
425199a2dd95SBruce Richardson int rte_eth_dev_callback_unregister(uint16_t port_id,
425299a2dd95SBruce Richardson 			enum rte_eth_event_type event,
425399a2dd95SBruce Richardson 		rte_eth_dev_cb_fn cb_fn, void *cb_arg);
425499a2dd95SBruce Richardson 
425599a2dd95SBruce Richardson /**
425609fd4227SAndrew Rybchenko  * When there is no Rx packet coming in Rx Queue for a long time, we can
425709fd4227SAndrew Rybchenko  * sleep lcore related to Rx Queue for power saving, and enable Rx interrupt
425899a2dd95SBruce Richardson  * to be triggered when Rx packet arrives.
425999a2dd95SBruce Richardson  *
426009fd4227SAndrew Rybchenko  * The rte_eth_dev_rx_intr_enable() function enables Rx queue
426109fd4227SAndrew Rybchenko  * interrupt on specific Rx queue of a port.
426299a2dd95SBruce Richardson  *
426399a2dd95SBruce Richardson  * @param port_id
426499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
426599a2dd95SBruce Richardson  * @param queue_id
426699a2dd95SBruce Richardson  *   The index of the receive queue from which to retrieve input packets.
426799a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
426899a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
426999a2dd95SBruce Richardson  * @return
427099a2dd95SBruce Richardson  *   - (0) if successful.
427199a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
427299a2dd95SBruce Richardson  *     that operation.
427399a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
427499a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
427599a2dd95SBruce Richardson  */
427699a2dd95SBruce Richardson int rte_eth_dev_rx_intr_enable(uint16_t port_id, uint16_t queue_id);
427799a2dd95SBruce Richardson 
427899a2dd95SBruce Richardson /**
427909fd4227SAndrew Rybchenko  * When lcore wakes up from Rx interrupt indicating packet coming, disable Rx
428099a2dd95SBruce Richardson  * interrupt and returns to polling mode.
428199a2dd95SBruce Richardson  *
428209fd4227SAndrew Rybchenko  * The rte_eth_dev_rx_intr_disable() function disables Rx queue
428309fd4227SAndrew Rybchenko  * interrupt on specific Rx queue of a port.
428499a2dd95SBruce Richardson  *
428599a2dd95SBruce Richardson  * @param port_id
428699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
428799a2dd95SBruce Richardson  * @param queue_id
428899a2dd95SBruce Richardson  *   The index of the receive queue from which to retrieve input packets.
428999a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
429099a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
429199a2dd95SBruce Richardson  * @return
429299a2dd95SBruce Richardson  *   - (0) if successful.
429399a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
429499a2dd95SBruce Richardson  *     that operation.
429599a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
429699a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
429799a2dd95SBruce Richardson  */
429899a2dd95SBruce Richardson int rte_eth_dev_rx_intr_disable(uint16_t port_id, uint16_t queue_id);
429999a2dd95SBruce Richardson 
430099a2dd95SBruce Richardson /**
430109fd4227SAndrew Rybchenko  * Rx Interrupt control per port.
430299a2dd95SBruce Richardson  *
430399a2dd95SBruce Richardson  * @param port_id
430499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
430599a2dd95SBruce Richardson  * @param epfd
430699a2dd95SBruce Richardson  *   Epoll instance fd which the intr vector associated to.
430799a2dd95SBruce Richardson  *   Using RTE_EPOLL_PER_THREAD allows to use per thread epoll instance.
430899a2dd95SBruce Richardson  * @param op
430999a2dd95SBruce Richardson  *   The operation be performed for the vector.
431099a2dd95SBruce Richardson  *   Operation type of {RTE_INTR_EVENT_ADD, RTE_INTR_EVENT_DEL}.
431199a2dd95SBruce Richardson  * @param data
431299a2dd95SBruce Richardson  *   User raw data.
431399a2dd95SBruce Richardson  * @return
431499a2dd95SBruce Richardson  *   - On success, zero.
431599a2dd95SBruce Richardson  *   - On failure, a negative value.
431699a2dd95SBruce Richardson  */
431799a2dd95SBruce Richardson int rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data);
431899a2dd95SBruce Richardson 
431999a2dd95SBruce Richardson /**
432009fd4227SAndrew Rybchenko  * Rx Interrupt control per queue.
432199a2dd95SBruce Richardson  *
432299a2dd95SBruce Richardson  * @param port_id
432399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
432499a2dd95SBruce Richardson  * @param queue_id
432599a2dd95SBruce Richardson  *   The index of the receive queue from which to retrieve input packets.
432699a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
432799a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
432899a2dd95SBruce Richardson  * @param epfd
432999a2dd95SBruce Richardson  *   Epoll instance fd which the intr vector associated to.
433099a2dd95SBruce Richardson  *   Using RTE_EPOLL_PER_THREAD allows to use per thread epoll instance.
433199a2dd95SBruce Richardson  * @param op
433299a2dd95SBruce Richardson  *   The operation be performed for the vector.
433399a2dd95SBruce Richardson  *   Operation type of {RTE_INTR_EVENT_ADD, RTE_INTR_EVENT_DEL}.
433499a2dd95SBruce Richardson  * @param data
433599a2dd95SBruce Richardson  *   User raw data.
433699a2dd95SBruce Richardson  * @return
433799a2dd95SBruce Richardson  *   - On success, zero.
433899a2dd95SBruce Richardson  *   - On failure, a negative value.
433999a2dd95SBruce Richardson  */
434099a2dd95SBruce Richardson int rte_eth_dev_rx_intr_ctl_q(uint16_t port_id, uint16_t queue_id,
434199a2dd95SBruce Richardson 			      int epfd, int op, void *data);
434299a2dd95SBruce Richardson 
434399a2dd95SBruce Richardson /**
434499a2dd95SBruce Richardson  * Get interrupt fd per Rx queue.
434599a2dd95SBruce Richardson  *
434699a2dd95SBruce Richardson  * @param port_id
434799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
434899a2dd95SBruce Richardson  * @param queue_id
434999a2dd95SBruce Richardson  *   The index of the receive queue from which to retrieve input packets.
435099a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
435199a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
435299a2dd95SBruce Richardson  * @return
435399a2dd95SBruce Richardson  *   - (>=0) the interrupt fd associated to the requested Rx queue if
435499a2dd95SBruce Richardson  *           successful.
435599a2dd95SBruce Richardson  *   - (-1) on error.
435699a2dd95SBruce Richardson  */
435799a2dd95SBruce Richardson int
435899a2dd95SBruce Richardson rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t queue_id);
435999a2dd95SBruce Richardson 
436099a2dd95SBruce Richardson /**
436199a2dd95SBruce Richardson  * Turn on the LED on the Ethernet device.
436299a2dd95SBruce Richardson  * This function turns on the LED on the Ethernet device.
436399a2dd95SBruce Richardson  *
436499a2dd95SBruce Richardson  * @param port_id
436599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
436699a2dd95SBruce Richardson  * @return
436799a2dd95SBruce Richardson  *   - (0) if successful.
436899a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
436999a2dd95SBruce Richardson  *     that operation.
437099a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
437199a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
437299a2dd95SBruce Richardson  */
437399a2dd95SBruce Richardson int  rte_eth_led_on(uint16_t port_id);
437499a2dd95SBruce Richardson 
437599a2dd95SBruce Richardson /**
437699a2dd95SBruce Richardson  * Turn off the LED on the Ethernet device.
437799a2dd95SBruce Richardson  * This function turns off the LED on the Ethernet device.
437899a2dd95SBruce Richardson  *
437999a2dd95SBruce Richardson  * @param port_id
438099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
438199a2dd95SBruce Richardson  * @return
438299a2dd95SBruce Richardson  *   - (0) if successful.
438399a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
438499a2dd95SBruce Richardson  *     that operation.
438599a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
438699a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
438799a2dd95SBruce Richardson  */
438899a2dd95SBruce Richardson int  rte_eth_led_off(uint16_t port_id);
438999a2dd95SBruce Richardson 
439099a2dd95SBruce Richardson /**
439199a2dd95SBruce Richardson  * @warning
439299a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
439399a2dd95SBruce Richardson  *
439499a2dd95SBruce Richardson  * Get Forward Error Correction(FEC) capability.
439599a2dd95SBruce Richardson  *
439699a2dd95SBruce Richardson  * @param port_id
439799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
439899a2dd95SBruce Richardson  * @param speed_fec_capa
439999a2dd95SBruce Richardson  *   speed_fec_capa is out only with per-speed capabilities.
440099a2dd95SBruce Richardson  *   If set to NULL, the function returns the required number
440199a2dd95SBruce Richardson  *   of required array entries.
440299a2dd95SBruce Richardson  * @param num
440399a2dd95SBruce Richardson  *   a number of elements in an speed_fec_capa array.
440499a2dd95SBruce Richardson  *
440599a2dd95SBruce Richardson  * @return
440699a2dd95SBruce Richardson  *   - A non-negative value lower or equal to num: success. The return value
440799a2dd95SBruce Richardson  *     is the number of entries filled in the fec capa array.
440899a2dd95SBruce Richardson  *   - A non-negative value higher than num: error, the given fec capa array
440999a2dd95SBruce Richardson  *     is too small. The return value corresponds to the num that should
441099a2dd95SBruce Richardson  *     be given to succeed. The entries in fec capa array are not valid and
441199a2dd95SBruce Richardson  *     shall not be used by the caller.
441299a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
441399a2dd95SBruce Richardson  *     that operation.
441499a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
441599a2dd95SBruce Richardson  *   - (-ENODEV)  if *port_id* invalid.
441699a2dd95SBruce Richardson  *   - (-EINVAL)  if *num* or *speed_fec_capa* invalid
441799a2dd95SBruce Richardson  */
441899a2dd95SBruce Richardson __rte_experimental
441999a2dd95SBruce Richardson int rte_eth_fec_get_capability(uint16_t port_id,
442099a2dd95SBruce Richardson 			       struct rte_eth_fec_capa *speed_fec_capa,
442199a2dd95SBruce Richardson 			       unsigned int num);
442299a2dd95SBruce Richardson 
442399a2dd95SBruce Richardson /**
442499a2dd95SBruce Richardson  * @warning
442599a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
442699a2dd95SBruce Richardson  *
442799a2dd95SBruce Richardson  * Get current Forward Error Correction(FEC) mode.
442899a2dd95SBruce Richardson  * If link is down and AUTO is enabled, AUTO is returned, otherwise,
442999a2dd95SBruce Richardson  * configured FEC mode is returned.
443099a2dd95SBruce Richardson  * If link is up, current FEC mode is returned.
443199a2dd95SBruce Richardson  *
443299a2dd95SBruce Richardson  * @param port_id
443399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
443499a2dd95SBruce Richardson  * @param fec_capa
44359e5c9e18SDenis Pryazhennikov  *   A bitmask with the current FEC mode.
443699a2dd95SBruce Richardson  * @return
443799a2dd95SBruce Richardson  *   - (0) if successful.
443899a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
443999a2dd95SBruce Richardson  *     that operation.
444099a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
444199a2dd95SBruce Richardson  *   - (-ENODEV)  if *port_id* invalid.
444299a2dd95SBruce Richardson  */
444399a2dd95SBruce Richardson __rte_experimental
444499a2dd95SBruce Richardson int rte_eth_fec_get(uint16_t port_id, uint32_t *fec_capa);
444599a2dd95SBruce Richardson 
444699a2dd95SBruce Richardson /**
444799a2dd95SBruce Richardson  * @warning
444899a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
444999a2dd95SBruce Richardson  *
445099a2dd95SBruce Richardson  * Set Forward Error Correction(FEC) mode.
445199a2dd95SBruce Richardson  *
445299a2dd95SBruce Richardson  * @param port_id
445399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
445499a2dd95SBruce Richardson  * @param fec_capa
44556af24dc3SDenis Pryazhennikov  *   A bitmask of allowed FEC modes.
44566af24dc3SDenis Pryazhennikov  *   If only the AUTO bit is set, the decision on which FEC
44576af24dc3SDenis Pryazhennikov  *   mode to use will be made by HW/FW or driver.
44586af24dc3SDenis Pryazhennikov  *   If the AUTO bit is set with some FEC modes, only specified
44596af24dc3SDenis Pryazhennikov  *   FEC modes can be set.
44606af24dc3SDenis Pryazhennikov  *   If AUTO bit is clear, specify FEC mode to be used
44616af24dc3SDenis Pryazhennikov  *   (only one valid mode per speed may be set).
446299a2dd95SBruce Richardson  * @return
446399a2dd95SBruce Richardson  *   - (0) if successful.
446499a2dd95SBruce Richardson  *   - (-EINVAL) if the FEC mode is not valid.
446599a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
446699a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
446799a2dd95SBruce Richardson  *   - (-ENODEV)  if *port_id* invalid.
446899a2dd95SBruce Richardson  */
446999a2dd95SBruce Richardson __rte_experimental
447099a2dd95SBruce Richardson int rte_eth_fec_set(uint16_t port_id, uint32_t fec_capa);
447199a2dd95SBruce Richardson 
447299a2dd95SBruce Richardson /**
447399a2dd95SBruce Richardson  * Get current status of the Ethernet link flow control for Ethernet device
447499a2dd95SBruce Richardson  *
447599a2dd95SBruce Richardson  * @param port_id
447699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
447799a2dd95SBruce Richardson  * @param fc_conf
447899a2dd95SBruce Richardson  *   The pointer to the structure where to store the flow control parameters.
447999a2dd95SBruce Richardson  * @return
448099a2dd95SBruce Richardson  *   - (0) if successful.
448199a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support flow control.
448299a2dd95SBruce Richardson  *   - (-ENODEV)  if *port_id* invalid.
448399a2dd95SBruce Richardson  *   - (-EIO)  if device is removed.
448453ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
448599a2dd95SBruce Richardson  */
448699a2dd95SBruce Richardson int rte_eth_dev_flow_ctrl_get(uint16_t port_id,
448799a2dd95SBruce Richardson 			      struct rte_eth_fc_conf *fc_conf);
448899a2dd95SBruce Richardson 
448999a2dd95SBruce Richardson /**
449099a2dd95SBruce Richardson  * Configure the Ethernet link flow control for Ethernet device
449199a2dd95SBruce Richardson  *
449299a2dd95SBruce Richardson  * @param port_id
449399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
449499a2dd95SBruce Richardson  * @param fc_conf
449599a2dd95SBruce Richardson  *   The pointer to the structure of the flow control parameters.
449699a2dd95SBruce Richardson  * @return
449799a2dd95SBruce Richardson  *   - (0) if successful.
449899a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support flow control mode.
449999a2dd95SBruce Richardson  *   - (-ENODEV)  if *port_id* invalid.
450099a2dd95SBruce Richardson  *   - (-EINVAL)  if bad parameter
450199a2dd95SBruce Richardson  *   - (-EIO)     if flow control setup failure or device is removed.
450299a2dd95SBruce Richardson  */
450399a2dd95SBruce Richardson int rte_eth_dev_flow_ctrl_set(uint16_t port_id,
450499a2dd95SBruce Richardson 			      struct rte_eth_fc_conf *fc_conf);
450599a2dd95SBruce Richardson 
450699a2dd95SBruce Richardson /**
450799a2dd95SBruce Richardson  * Configure the Ethernet priority flow control under DCB environment
450899a2dd95SBruce Richardson  * for Ethernet device.
450999a2dd95SBruce Richardson  *
451099a2dd95SBruce Richardson  * @param port_id
451199a2dd95SBruce Richardson  * The port identifier of the Ethernet device.
451299a2dd95SBruce Richardson  * @param pfc_conf
451399a2dd95SBruce Richardson  * The pointer to the structure of the priority flow control parameters.
451499a2dd95SBruce Richardson  * @return
451599a2dd95SBruce Richardson  *   - (0) if successful.
451699a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support priority flow control mode.
451799a2dd95SBruce Richardson  *   - (-ENODEV)  if *port_id* invalid.
451899a2dd95SBruce Richardson  *   - (-EINVAL)  if bad parameter
451999a2dd95SBruce Richardson  *   - (-EIO)     if flow control setup failure or device is removed.
452099a2dd95SBruce Richardson  */
452199a2dd95SBruce Richardson int rte_eth_dev_priority_flow_ctrl_set(uint16_t port_id,
452299a2dd95SBruce Richardson 				struct rte_eth_pfc_conf *pfc_conf);
452399a2dd95SBruce Richardson 
452499a2dd95SBruce Richardson /**
452599a2dd95SBruce Richardson  * Add a MAC address to the set used for filtering incoming packets.
452699a2dd95SBruce Richardson  *
452799a2dd95SBruce Richardson  * @param port_id
452899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
452999a2dd95SBruce Richardson  * @param mac_addr
453099a2dd95SBruce Richardson  *   The MAC address to add.
453199a2dd95SBruce Richardson  * @param pool
453299a2dd95SBruce Richardson  *   VMDq pool index to associate address with (if VMDq is enabled). If VMDq is
453399a2dd95SBruce Richardson  *   not enabled, this should be set to 0.
453499a2dd95SBruce Richardson  * @return
453599a2dd95SBruce Richardson  *   - (0) if successfully added or *mac_addr* was already added.
453699a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support this feature.
453799a2dd95SBruce Richardson  *   - (-ENODEV) if *port* is invalid.
453899a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
453999a2dd95SBruce Richardson  *   - (-ENOSPC) if no more MAC addresses can be added.
454099a2dd95SBruce Richardson  *   - (-EINVAL) if MAC address is invalid.
454199a2dd95SBruce Richardson  */
454299a2dd95SBruce Richardson int rte_eth_dev_mac_addr_add(uint16_t port_id, struct rte_ether_addr *mac_addr,
454399a2dd95SBruce Richardson 				uint32_t pool);
454499a2dd95SBruce Richardson 
454599a2dd95SBruce Richardson /**
45460de345e9SJerin Jacob  * @warning
45470de345e9SJerin Jacob  * @b EXPERIMENTAL: this API may change without prior notice.
45480de345e9SJerin Jacob  *
45490de345e9SJerin Jacob  * Retrieve the information for queue based PFC.
45500de345e9SJerin Jacob  *
45510de345e9SJerin Jacob  * @param port_id
45520de345e9SJerin Jacob  *   The port identifier of the Ethernet device.
45530de345e9SJerin Jacob  * @param pfc_queue_info
45540de345e9SJerin Jacob  *   A pointer to a structure of type *rte_eth_pfc_queue_info* to be filled with
45550de345e9SJerin Jacob  *   the information about queue based PFC.
45560de345e9SJerin Jacob  * @return
45570de345e9SJerin Jacob  *   - (0) if successful.
45580de345e9SJerin Jacob  *   - (-ENOTSUP) if support for priority_flow_ctrl_queue_info_get does not exist.
45590de345e9SJerin Jacob  *   - (-ENODEV) if *port_id* invalid.
45600de345e9SJerin Jacob  *   - (-EINVAL) if bad parameter.
45610de345e9SJerin Jacob  */
45620de345e9SJerin Jacob __rte_experimental
45630de345e9SJerin Jacob int rte_eth_dev_priority_flow_ctrl_queue_info_get(uint16_t port_id,
45640de345e9SJerin Jacob 		struct rte_eth_pfc_queue_info *pfc_queue_info);
45650de345e9SJerin Jacob 
45660de345e9SJerin Jacob /**
45670de345e9SJerin Jacob  * @warning
45680de345e9SJerin Jacob  * @b EXPERIMENTAL: this API may change without prior notice.
45690de345e9SJerin Jacob  *
45700de345e9SJerin Jacob  * Configure the queue based priority flow control for a given queue
45710de345e9SJerin Jacob  * for Ethernet device.
45720de345e9SJerin Jacob  *
45730de345e9SJerin Jacob  * @note When an ethdev port switches to queue based PFC mode, the
45740de345e9SJerin Jacob  * unconfigured queues shall be configured by the driver with
45750de345e9SJerin Jacob  * default values such as lower priority value for TC etc.
45760de345e9SJerin Jacob  *
45770de345e9SJerin Jacob  * @param port_id
45780de345e9SJerin Jacob  *   The port identifier of the Ethernet device.
45790de345e9SJerin Jacob  * @param pfc_queue_conf
45800de345e9SJerin Jacob  *   The pointer to the structure of the priority flow control parameters
45810de345e9SJerin Jacob  *   for the queue.
45820de345e9SJerin Jacob  * @return
45830de345e9SJerin Jacob  *   - (0) if successful.
45840de345e9SJerin Jacob  *   - (-ENOTSUP) if hardware doesn't support queue based PFC mode.
45850de345e9SJerin Jacob  *   - (-ENODEV)  if *port_id* invalid.
45860de345e9SJerin Jacob  *   - (-EINVAL)  if bad parameter
45870de345e9SJerin Jacob  *   - (-EIO)     if flow control setup queue failure
45880de345e9SJerin Jacob  */
45890de345e9SJerin Jacob __rte_experimental
45900de345e9SJerin Jacob int rte_eth_dev_priority_flow_ctrl_queue_configure(uint16_t port_id,
45910de345e9SJerin Jacob 		struct rte_eth_pfc_queue_conf *pfc_queue_conf);
45920de345e9SJerin Jacob 
45930de345e9SJerin Jacob /**
459499a2dd95SBruce Richardson  * Remove a MAC address from the internal array of addresses.
459599a2dd95SBruce Richardson  *
459699a2dd95SBruce Richardson  * @param port_id
459799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
459899a2dd95SBruce Richardson  * @param mac_addr
459999a2dd95SBruce Richardson  *   MAC address to remove.
460099a2dd95SBruce Richardson  * @return
460199a2dd95SBruce Richardson  *   - (0) if successful, or *mac_addr* didn't exist.
460299a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
460399a2dd95SBruce Richardson  *   - (-ENODEV) if *port* invalid.
460453ef1b34SMin Hu (Connor)  *   - (-EADDRINUSE) if attempting to remove the default MAC address.
460553ef1b34SMin Hu (Connor)  *   - (-EINVAL) if MAC address is invalid.
460699a2dd95SBruce Richardson  */
460799a2dd95SBruce Richardson int rte_eth_dev_mac_addr_remove(uint16_t port_id,
460899a2dd95SBruce Richardson 				struct rte_ether_addr *mac_addr);
460999a2dd95SBruce Richardson 
461099a2dd95SBruce Richardson /**
461199a2dd95SBruce Richardson  * Set the default MAC address.
46128f02f472SHuisong Li  * It replaces the address at index 0 of the MAC address list.
46138f02f472SHuisong Li  * If the address was already in the MAC address list,
46148f02f472SHuisong Li  * please remove it first.
461599a2dd95SBruce Richardson  *
461699a2dd95SBruce Richardson  * @param port_id
461799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
461899a2dd95SBruce Richardson  * @param mac_addr
461999a2dd95SBruce Richardson  *   New default MAC address.
462099a2dd95SBruce Richardson  * @return
462199a2dd95SBruce Richardson  *   - (0) if successful, or *mac_addr* didn't exist.
462299a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
462399a2dd95SBruce Richardson  *   - (-ENODEV) if *port* invalid.
462499a2dd95SBruce Richardson  *   - (-EINVAL) if MAC address is invalid.
46258f02f472SHuisong Li  *   - (-EEXIST) if MAC address was already in the address list.
462699a2dd95SBruce Richardson  */
462799a2dd95SBruce Richardson int rte_eth_dev_default_mac_addr_set(uint16_t port_id,
462899a2dd95SBruce Richardson 		struct rte_ether_addr *mac_addr);
462999a2dd95SBruce Richardson 
463099a2dd95SBruce Richardson /**
463199a2dd95SBruce Richardson  * Update Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
463299a2dd95SBruce Richardson  *
463399a2dd95SBruce Richardson  * @param port_id
463499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
463599a2dd95SBruce Richardson  * @param reta_conf
463699a2dd95SBruce Richardson  *   RETA to update.
463799a2dd95SBruce Richardson  * @param reta_size
463899a2dd95SBruce Richardson  *   Redirection table size. The table size can be queried by
463999a2dd95SBruce Richardson  *   rte_eth_dev_info_get().
464099a2dd95SBruce Richardson  * @return
464199a2dd95SBruce Richardson  *   - (0) if successful.
464299a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
464399a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
464499a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
464599a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
464699a2dd95SBruce Richardson  */
464799a2dd95SBruce Richardson int rte_eth_dev_rss_reta_update(uint16_t port_id,
464899a2dd95SBruce Richardson 				struct rte_eth_rss_reta_entry64 *reta_conf,
464999a2dd95SBruce Richardson 				uint16_t reta_size);
465099a2dd95SBruce Richardson 
465199a2dd95SBruce Richardson /**
465299a2dd95SBruce Richardson  * Query Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
465399a2dd95SBruce Richardson  *
465499a2dd95SBruce Richardson  * @param port_id
465599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
465699a2dd95SBruce Richardson  * @param reta_conf
465799a2dd95SBruce Richardson  *   RETA to query. For each requested reta entry, corresponding bit
465899a2dd95SBruce Richardson  *   in mask must be set.
465999a2dd95SBruce Richardson  * @param reta_size
466099a2dd95SBruce Richardson  *   Redirection table size. The table size can be queried by
466199a2dd95SBruce Richardson  *   rte_eth_dev_info_get().
466299a2dd95SBruce Richardson  * @return
466399a2dd95SBruce Richardson  *   - (0) if successful.
466499a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
466599a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
466699a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
466799a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
466899a2dd95SBruce Richardson  */
466999a2dd95SBruce Richardson int rte_eth_dev_rss_reta_query(uint16_t port_id,
467099a2dd95SBruce Richardson 			       struct rte_eth_rss_reta_entry64 *reta_conf,
467199a2dd95SBruce Richardson 			       uint16_t reta_size);
467299a2dd95SBruce Richardson 
467399a2dd95SBruce Richardson /**
467499a2dd95SBruce Richardson  * Updates unicast hash table for receiving packet with the given destination
467509fd4227SAndrew Rybchenko  * MAC address, and the packet is routed to all VFs for which the Rx mode is
467699a2dd95SBruce Richardson  * accept packets that match the unicast hash table.
467799a2dd95SBruce Richardson  *
467899a2dd95SBruce Richardson  * @param port_id
467999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
468099a2dd95SBruce Richardson  * @param addr
468199a2dd95SBruce Richardson  *   Unicast MAC address.
468299a2dd95SBruce Richardson  * @param on
468399a2dd95SBruce Richardson  *    1 - Set an unicast hash bit for receiving packets with the MAC address.
468499a2dd95SBruce Richardson  *    0 - Clear an unicast hash bit.
468599a2dd95SBruce Richardson  * @return
468699a2dd95SBruce Richardson  *   - (0) if successful.
468799a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
468899a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
468999a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
469099a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
469199a2dd95SBruce Richardson  */
469299a2dd95SBruce Richardson int rte_eth_dev_uc_hash_table_set(uint16_t port_id, struct rte_ether_addr *addr,
469399a2dd95SBruce Richardson 				  uint8_t on);
469499a2dd95SBruce Richardson 
469599a2dd95SBruce Richardson /**
469699a2dd95SBruce Richardson  * Updates all unicast hash bitmaps for receiving packet with any Unicast
469709fd4227SAndrew Rybchenko  * Ethernet MAC addresses,the packet is routed to all VFs for which the Rx
469899a2dd95SBruce Richardson  * mode is accept packets that match the unicast hash table.
469999a2dd95SBruce Richardson  *
470099a2dd95SBruce Richardson  * @param port_id
470199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
470299a2dd95SBruce Richardson  * @param on
470399a2dd95SBruce Richardson  *    1 - Set all unicast hash bitmaps for receiving all the Ethernet
470499a2dd95SBruce Richardson  *         MAC addresses
470599a2dd95SBruce Richardson  *    0 - Clear all unicast hash bitmaps
470699a2dd95SBruce Richardson  * @return
470799a2dd95SBruce Richardson  *   - (0) if successful.
470899a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
470999a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
471099a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
471199a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
471299a2dd95SBruce Richardson  */
471399a2dd95SBruce Richardson int rte_eth_dev_uc_all_hash_table_set(uint16_t port_id, uint8_t on);
471499a2dd95SBruce Richardson 
471599a2dd95SBruce Richardson /**
471699a2dd95SBruce Richardson  * Set the rate limitation for a queue on an Ethernet device.
471799a2dd95SBruce Richardson  *
471899a2dd95SBruce Richardson  * @param port_id
471999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
472099a2dd95SBruce Richardson  * @param queue_idx
47215906be5aSAndrew Rybchenko  *   The queue ID.
472299a2dd95SBruce Richardson  * @param tx_rate
472309fd4227SAndrew Rybchenko  *   The Tx rate in Mbps. Allocated from the total port link speed.
472499a2dd95SBruce Richardson  * @return
472599a2dd95SBruce Richardson  *   - (0) if successful.
472699a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support this feature.
472799a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
472899a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
472999a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
473099a2dd95SBruce Richardson  */
473199a2dd95SBruce Richardson int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx,
47323a26e41eSSatha Rao 			uint32_t tx_rate);
473399a2dd95SBruce Richardson 
473499a2dd95SBruce Richardson /**
473599a2dd95SBruce Richardson  * Configuration of Receive Side Scaling hash computation of Ethernet device.
473699a2dd95SBruce Richardson  *
473799a2dd95SBruce Richardson  * @param port_id
473899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
473999a2dd95SBruce Richardson  * @param rss_conf
474099a2dd95SBruce Richardson  *   The new configuration to use for RSS hash computation on the port.
474199a2dd95SBruce Richardson  * @return
474299a2dd95SBruce Richardson  *   - (0) if successful.
474399a2dd95SBruce Richardson  *   - (-ENODEV) if port identifier is invalid.
474499a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
474599a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
474699a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
474799a2dd95SBruce Richardson  */
474899a2dd95SBruce Richardson int rte_eth_dev_rss_hash_update(uint16_t port_id,
474999a2dd95SBruce Richardson 				struct rte_eth_rss_conf *rss_conf);
475099a2dd95SBruce Richardson 
475199a2dd95SBruce Richardson /**
475299a2dd95SBruce Richardson  * Retrieve current configuration of Receive Side Scaling hash computation
475399a2dd95SBruce Richardson  * of Ethernet device.
475499a2dd95SBruce Richardson  *
475599a2dd95SBruce Richardson  * @param port_id
475699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
475799a2dd95SBruce Richardson  * @param rss_conf
475899a2dd95SBruce Richardson  *   Where to store the current RSS hash configuration of the Ethernet device.
475999a2dd95SBruce Richardson  * @return
476099a2dd95SBruce Richardson  *   - (0) if successful.
476199a2dd95SBruce Richardson  *   - (-ENODEV) if port identifier is invalid.
476299a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
476399a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support RSS.
476453ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
476599a2dd95SBruce Richardson  */
476699a2dd95SBruce Richardson int
476799a2dd95SBruce Richardson rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
476899a2dd95SBruce Richardson 			      struct rte_eth_rss_conf *rss_conf);
476999a2dd95SBruce Richardson 
477099a2dd95SBruce Richardson /**
477192628e2bSJie Hai  * @warning
477292628e2bSJie Hai  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice.
477392628e2bSJie Hai  *
477492628e2bSJie Hai  *  Get the name of RSS hash algorithm.
477592628e2bSJie Hai  *
477692628e2bSJie Hai  * @param rss_algo
477792628e2bSJie Hai  *   Hash algorithm.
477892628e2bSJie Hai  *
477992628e2bSJie Hai  * @return
478092628e2bSJie Hai  *   Hash algorithm name or 'UNKNOWN' if the rss_algo cannot be recognized.
478192628e2bSJie Hai  */
478292628e2bSJie Hai __rte_experimental
478392628e2bSJie Hai const char *
478492628e2bSJie Hai rte_eth_dev_rss_algo_name(enum rte_eth_hash_function rss_algo);
478592628e2bSJie Hai 
478692628e2bSJie Hai /**
4787c9884dfbSJie Hai  * @warning
4788c9884dfbSJie Hai  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice.
4789c9884dfbSJie Hai  *
4790c9884dfbSJie Hai  * Get RSS hash algorithm by its name.
4791c9884dfbSJie Hai  *
4792c9884dfbSJie Hai  * @param name
4793c9884dfbSJie Hai  *   RSS hash algorithm.
4794c9884dfbSJie Hai  *
4795c9884dfbSJie Hai  * @param algo
4796c9884dfbSJie Hai  *   Return the RSS hash algorithm found, @see rte_eth_hash_function.
4797c9884dfbSJie Hai  *
4798c9884dfbSJie Hai  * @return
4799c9884dfbSJie Hai  *   - (0) if successful.
4800c9884dfbSJie Hai  *   - (-EINVAL) if not found.
4801c9884dfbSJie Hai  */
4802c9884dfbSJie Hai __rte_experimental
4803c9884dfbSJie Hai int
4804c9884dfbSJie Hai rte_eth_find_rss_algo(const char *name, uint32_t *algo);
4805c9884dfbSJie Hai 
4806c9884dfbSJie Hai /**
480799a2dd95SBruce Richardson  * Add UDP tunneling port for a type of tunnel.
480899a2dd95SBruce Richardson  *
480999a2dd95SBruce Richardson  * Some NICs may require such configuration to properly parse a tunnel
481099a2dd95SBruce Richardson  * with any standard or custom UDP port.
481199a2dd95SBruce Richardson  * The packets with this UDP port will be parsed for this type of tunnel.
481299a2dd95SBruce Richardson  * The device parser will also check the rest of the tunnel headers
481399a2dd95SBruce Richardson  * before classifying the packet.
481499a2dd95SBruce Richardson  *
481599a2dd95SBruce Richardson  * With some devices, this API will affect packet classification, i.e.:
481699a2dd95SBruce Richardson  *     - mbuf.packet_type reported on Rx
481799a2dd95SBruce Richardson  *     - rte_flow rules with tunnel items
481899a2dd95SBruce Richardson  *
481999a2dd95SBruce Richardson  * @param port_id
482099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
482199a2dd95SBruce Richardson  * @param tunnel_udp
482299a2dd95SBruce Richardson  *   UDP tunneling configuration.
482399a2dd95SBruce Richardson  *
482499a2dd95SBruce Richardson  * @return
482599a2dd95SBruce Richardson  *   - (0) if successful.
482699a2dd95SBruce Richardson  *   - (-ENODEV) if port identifier is invalid.
482799a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
482899a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support tunnel type.
482999a2dd95SBruce Richardson  */
483099a2dd95SBruce Richardson int
483199a2dd95SBruce Richardson rte_eth_dev_udp_tunnel_port_add(uint16_t port_id,
483299a2dd95SBruce Richardson 				struct rte_eth_udp_tunnel *tunnel_udp);
483399a2dd95SBruce Richardson 
483499a2dd95SBruce Richardson /**
483599a2dd95SBruce Richardson  * Delete UDP tunneling port for a type of tunnel.
483699a2dd95SBruce Richardson  *
483799a2dd95SBruce Richardson  * The packets with this UDP port will not be classified as this type of tunnel
483899a2dd95SBruce Richardson  * anymore if the device use such mapping for tunnel packet classification.
483999a2dd95SBruce Richardson  *
484099a2dd95SBruce Richardson  * @see rte_eth_dev_udp_tunnel_port_add
484199a2dd95SBruce Richardson  *
484299a2dd95SBruce Richardson  * @param port_id
484399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
484499a2dd95SBruce Richardson  * @param tunnel_udp
484599a2dd95SBruce Richardson  *   UDP tunneling configuration.
484699a2dd95SBruce Richardson  *
484799a2dd95SBruce Richardson  * @return
484899a2dd95SBruce Richardson  *   - (0) if successful.
484999a2dd95SBruce Richardson  *   - (-ENODEV) if port identifier is invalid.
485099a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
485199a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support tunnel type.
485299a2dd95SBruce Richardson  */
485399a2dd95SBruce Richardson int
485499a2dd95SBruce Richardson rte_eth_dev_udp_tunnel_port_delete(uint16_t port_id,
485599a2dd95SBruce Richardson 				   struct rte_eth_udp_tunnel *tunnel_udp);
485699a2dd95SBruce Richardson 
485799a2dd95SBruce Richardson /**
485899a2dd95SBruce Richardson  * Get DCB information on an Ethernet device.
485999a2dd95SBruce Richardson  *
486099a2dd95SBruce Richardson  * @param port_id
486199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
486299a2dd95SBruce Richardson  * @param dcb_info
4863064e90c4SAndrew Rybchenko  *   DCB information.
486499a2dd95SBruce Richardson  * @return
486599a2dd95SBruce Richardson  *   - (0) if successful.
486699a2dd95SBruce Richardson  *   - (-ENODEV) if port identifier is invalid.
486799a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
486899a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
486953ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
487099a2dd95SBruce Richardson  */
487199a2dd95SBruce Richardson int rte_eth_dev_get_dcb_info(uint16_t port_id,
487299a2dd95SBruce Richardson 			     struct rte_eth_dcb_info *dcb_info);
487399a2dd95SBruce Richardson 
487499a2dd95SBruce Richardson struct rte_eth_rxtx_callback;
487599a2dd95SBruce Richardson 
487699a2dd95SBruce Richardson /**
487709fd4227SAndrew Rybchenko  * Add a callback to be called on packet Rx on a given port and queue.
487899a2dd95SBruce Richardson  *
487999a2dd95SBruce Richardson  * This API configures a function to be called for each burst of
488099a2dd95SBruce Richardson  * packets received on a given NIC port queue. The return value is a pointer
488199a2dd95SBruce Richardson  * that can be used to later remove the callback using
488299a2dd95SBruce Richardson  * rte_eth_remove_rx_callback().
488399a2dd95SBruce Richardson  *
488499a2dd95SBruce Richardson  * Multiple functions are called in the order that they are added.
488599a2dd95SBruce Richardson  *
488699a2dd95SBruce Richardson  * @param port_id
488799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
488899a2dd95SBruce Richardson  * @param queue_id
488999a2dd95SBruce Richardson  *   The queue on the Ethernet device on which the callback is to be added.
489099a2dd95SBruce Richardson  * @param fn
489199a2dd95SBruce Richardson  *   The callback function
489299a2dd95SBruce Richardson  * @param user_param
489399a2dd95SBruce Richardson  *   A generic pointer parameter which will be passed to each invocation of the
489499a2dd95SBruce Richardson  *   callback function on this port and queue. Inter-thread synchronization
489599a2dd95SBruce Richardson  *   of any user data changes is the responsibility of the user.
489699a2dd95SBruce Richardson  *
489799a2dd95SBruce Richardson  * @return
489899a2dd95SBruce Richardson  *   NULL on error.
489999a2dd95SBruce Richardson  *   On success, a pointer value which can later be used to remove the callback.
490099a2dd95SBruce Richardson  */
490199a2dd95SBruce Richardson const struct rte_eth_rxtx_callback *
490299a2dd95SBruce Richardson rte_eth_add_rx_callback(uint16_t port_id, uint16_t queue_id,
490399a2dd95SBruce Richardson 		rte_rx_callback_fn fn, void *user_param);
490499a2dd95SBruce Richardson 
490599a2dd95SBruce Richardson /**
490609fd4227SAndrew Rybchenko  * Add a callback that must be called first on packet Rx on a given port
490799a2dd95SBruce Richardson  * and queue.
490899a2dd95SBruce Richardson  *
490999a2dd95SBruce Richardson  * This API configures a first function to be called for each burst of
491099a2dd95SBruce Richardson  * packets received on a given NIC port queue. The return value is a pointer
491199a2dd95SBruce Richardson  * that can be used to later remove the callback using
491299a2dd95SBruce Richardson  * rte_eth_remove_rx_callback().
491399a2dd95SBruce Richardson  *
491499a2dd95SBruce Richardson  * Multiple functions are called in the order that they are added.
491599a2dd95SBruce Richardson  *
491699a2dd95SBruce Richardson  * @param port_id
491799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
491899a2dd95SBruce Richardson  * @param queue_id
491999a2dd95SBruce Richardson  *   The queue on the Ethernet device on which the callback is to be added.
492099a2dd95SBruce Richardson  * @param fn
492199a2dd95SBruce Richardson  *   The callback function
492299a2dd95SBruce Richardson  * @param user_param
492399a2dd95SBruce Richardson  *   A generic pointer parameter which will be passed to each invocation of the
492499a2dd95SBruce Richardson  *   callback function on this port and queue. Inter-thread synchronization
492599a2dd95SBruce Richardson  *   of any user data changes is the responsibility of the user.
492699a2dd95SBruce Richardson  *
492799a2dd95SBruce Richardson  * @return
492899a2dd95SBruce Richardson  *   NULL on error.
492999a2dd95SBruce Richardson  *   On success, a pointer value which can later be used to remove the callback.
493099a2dd95SBruce Richardson  */
493199a2dd95SBruce Richardson const struct rte_eth_rxtx_callback *
493299a2dd95SBruce Richardson rte_eth_add_first_rx_callback(uint16_t port_id, uint16_t queue_id,
493399a2dd95SBruce Richardson 		rte_rx_callback_fn fn, void *user_param);
493499a2dd95SBruce Richardson 
493599a2dd95SBruce Richardson /**
493609fd4227SAndrew Rybchenko  * Add a callback to be called on packet Tx on a given port and queue.
493799a2dd95SBruce Richardson  *
493899a2dd95SBruce Richardson  * This API configures a function to be called for each burst of
493999a2dd95SBruce Richardson  * packets sent on a given NIC port queue. The return value is a pointer
494099a2dd95SBruce Richardson  * that can be used to later remove the callback using
494199a2dd95SBruce Richardson  * rte_eth_remove_tx_callback().
494299a2dd95SBruce Richardson  *
494399a2dd95SBruce Richardson  * Multiple functions are called in the order that they are added.
494499a2dd95SBruce Richardson  *
494599a2dd95SBruce Richardson  * @param port_id
494699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
494799a2dd95SBruce Richardson  * @param queue_id
494899a2dd95SBruce Richardson  *   The queue on the Ethernet device on which the callback is to be added.
494999a2dd95SBruce Richardson  * @param fn
495099a2dd95SBruce Richardson  *   The callback function
495199a2dd95SBruce Richardson  * @param user_param
495299a2dd95SBruce Richardson  *   A generic pointer parameter which will be passed to each invocation of the
495399a2dd95SBruce Richardson  *   callback function on this port and queue. Inter-thread synchronization
495499a2dd95SBruce Richardson  *   of any user data changes is the responsibility of the user.
495599a2dd95SBruce Richardson  *
495699a2dd95SBruce Richardson  * @return
495799a2dd95SBruce Richardson  *   NULL on error.
495899a2dd95SBruce Richardson  *   On success, a pointer value which can later be used to remove the callback.
495999a2dd95SBruce Richardson  */
496099a2dd95SBruce Richardson const struct rte_eth_rxtx_callback *
496199a2dd95SBruce Richardson rte_eth_add_tx_callback(uint16_t port_id, uint16_t queue_id,
496299a2dd95SBruce Richardson 		rte_tx_callback_fn fn, void *user_param);
496399a2dd95SBruce Richardson 
496499a2dd95SBruce Richardson /**
496509fd4227SAndrew Rybchenko  * Remove an Rx packet callback from a given port and queue.
496699a2dd95SBruce Richardson  *
496799a2dd95SBruce Richardson  * This function is used to removed callbacks that were added to a NIC port
496899a2dd95SBruce Richardson  * queue using rte_eth_add_rx_callback().
496999a2dd95SBruce Richardson  *
497099a2dd95SBruce Richardson  * Note: the callback is removed from the callback list but it isn't freed
497199a2dd95SBruce Richardson  * since the it may still be in use. The memory for the callback can be
497299a2dd95SBruce Richardson  * subsequently freed back by the application by calling rte_free():
497399a2dd95SBruce Richardson  *
497499a2dd95SBruce Richardson  * - Immediately - if the port is stopped, or the user knows that no
497509fd4227SAndrew Rybchenko  *   callbacks are in flight e.g. if called from the thread doing Rx/Tx
497699a2dd95SBruce Richardson  *   on that queue.
497799a2dd95SBruce Richardson  *
497899a2dd95SBruce Richardson  * - After a short delay - where the delay is sufficient to allow any
497999a2dd95SBruce Richardson  *   in-flight callbacks to complete. Alternately, the RCU mechanism can be
498099a2dd95SBruce Richardson  *   used to detect when data plane threads have ceased referencing the
498199a2dd95SBruce Richardson  *   callback memory.
498299a2dd95SBruce Richardson  *
498399a2dd95SBruce Richardson  * @param port_id
498499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
498599a2dd95SBruce Richardson  * @param queue_id
498699a2dd95SBruce Richardson  *   The queue on the Ethernet device from which the callback is to be removed.
498799a2dd95SBruce Richardson  * @param user_cb
498899a2dd95SBruce Richardson  *   User supplied callback created via rte_eth_add_rx_callback().
498999a2dd95SBruce Richardson  *
499099a2dd95SBruce Richardson  * @return
499199a2dd95SBruce Richardson  *   - 0: Success. Callback was removed.
499299a2dd95SBruce Richardson  *   - -ENODEV:  If *port_id* is invalid.
499399a2dd95SBruce Richardson  *   - -ENOTSUP: Callback support is not available.
499499a2dd95SBruce Richardson  *   - -EINVAL:  The queue_id is out of range, or the callback
499599a2dd95SBruce Richardson  *               is NULL or not found for the port/queue.
499699a2dd95SBruce Richardson  */
499799a2dd95SBruce Richardson int rte_eth_remove_rx_callback(uint16_t port_id, uint16_t queue_id,
499899a2dd95SBruce Richardson 		const struct rte_eth_rxtx_callback *user_cb);
499999a2dd95SBruce Richardson 
500099a2dd95SBruce Richardson /**
500109fd4227SAndrew Rybchenko  * Remove a Tx packet callback from a given port and queue.
500299a2dd95SBruce Richardson  *
500399a2dd95SBruce Richardson  * This function is used to removed callbacks that were added to a NIC port
500499a2dd95SBruce Richardson  * queue using rte_eth_add_tx_callback().
500599a2dd95SBruce Richardson  *
500699a2dd95SBruce Richardson  * Note: the callback is removed from the callback list but it isn't freed
500799a2dd95SBruce Richardson  * since the it may still be in use. The memory for the callback can be
500899a2dd95SBruce Richardson  * subsequently freed back by the application by calling rte_free():
500999a2dd95SBruce Richardson  *
501099a2dd95SBruce Richardson  * - Immediately - if the port is stopped, or the user knows that no
501109fd4227SAndrew Rybchenko  *   callbacks are in flight e.g. if called from the thread doing Rx/Tx
501299a2dd95SBruce Richardson  *   on that queue.
501399a2dd95SBruce Richardson  *
501499a2dd95SBruce Richardson  * - After a short delay - where the delay is sufficient to allow any
501599a2dd95SBruce Richardson  *   in-flight callbacks to complete. Alternately, the RCU mechanism can be
501699a2dd95SBruce Richardson  *   used to detect when data plane threads have ceased referencing the
501799a2dd95SBruce Richardson  *   callback memory.
501899a2dd95SBruce Richardson  *
501999a2dd95SBruce Richardson  * @param port_id
502099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
502199a2dd95SBruce Richardson  * @param queue_id
502299a2dd95SBruce Richardson  *   The queue on the Ethernet device from which the callback is to be removed.
502399a2dd95SBruce Richardson  * @param user_cb
502499a2dd95SBruce Richardson  *   User supplied callback created via rte_eth_add_tx_callback().
502599a2dd95SBruce Richardson  *
502699a2dd95SBruce Richardson  * @return
502799a2dd95SBruce Richardson  *   - 0: Success. Callback was removed.
502899a2dd95SBruce Richardson  *   - -ENODEV:  If *port_id* is invalid.
502999a2dd95SBruce Richardson  *   - -ENOTSUP: Callback support is not available.
503099a2dd95SBruce Richardson  *   - -EINVAL:  The queue_id is out of range, or the callback
503199a2dd95SBruce Richardson  *               is NULL or not found for the port/queue.
503299a2dd95SBruce Richardson  */
503399a2dd95SBruce Richardson int rte_eth_remove_tx_callback(uint16_t port_id, uint16_t queue_id,
503499a2dd95SBruce Richardson 		const struct rte_eth_rxtx_callback *user_cb);
503599a2dd95SBruce Richardson 
503699a2dd95SBruce Richardson /**
503709fd4227SAndrew Rybchenko  * Retrieve information about given port's Rx queue.
503899a2dd95SBruce Richardson  *
503999a2dd95SBruce Richardson  * @param port_id
504099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
504199a2dd95SBruce Richardson  * @param queue_id
504209fd4227SAndrew Rybchenko  *   The Rx queue on the Ethernet device for which information
504399a2dd95SBruce Richardson  *   will be retrieved.
504499a2dd95SBruce Richardson  * @param qinfo
504599a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_eth_rxq_info_info* to be filled with
504699a2dd95SBruce Richardson  *   the information of the Ethernet device.
504799a2dd95SBruce Richardson  *
504899a2dd95SBruce Richardson  * @return
504999a2dd95SBruce Richardson  *   - 0: Success
505099a2dd95SBruce Richardson  *   - -ENODEV:  If *port_id* is invalid.
505199a2dd95SBruce Richardson  *   - -ENOTSUP: routine is not supported by the device PMD.
505299a2dd95SBruce Richardson  *   - -EINVAL:  The queue_id is out of range, or the queue
505399a2dd95SBruce Richardson  *               is hairpin queue.
505499a2dd95SBruce Richardson  */
505599a2dd95SBruce Richardson int rte_eth_rx_queue_info_get(uint16_t port_id, uint16_t queue_id,
505699a2dd95SBruce Richardson 	struct rte_eth_rxq_info *qinfo);
505799a2dd95SBruce Richardson 
505899a2dd95SBruce Richardson /**
505909fd4227SAndrew Rybchenko  * Retrieve information about given port's Tx queue.
506099a2dd95SBruce Richardson  *
506199a2dd95SBruce Richardson  * @param port_id
506299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
506399a2dd95SBruce Richardson  * @param queue_id
506409fd4227SAndrew Rybchenko  *   The Tx queue on the Ethernet device for which information
506599a2dd95SBruce Richardson  *   will be retrieved.
506699a2dd95SBruce Richardson  * @param qinfo
506799a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_eth_txq_info_info* to be filled with
506899a2dd95SBruce Richardson  *   the information of the Ethernet device.
506999a2dd95SBruce Richardson  *
507099a2dd95SBruce Richardson  * @return
507199a2dd95SBruce Richardson  *   - 0: Success
507299a2dd95SBruce Richardson  *   - -ENODEV:  If *port_id* is invalid.
507399a2dd95SBruce Richardson  *   - -ENOTSUP: routine is not supported by the device PMD.
507499a2dd95SBruce Richardson  *   - -EINVAL:  The queue_id is out of range, or the queue
507599a2dd95SBruce Richardson  *               is hairpin queue.
507699a2dd95SBruce Richardson  */
507799a2dd95SBruce Richardson int rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id,
507899a2dd95SBruce Richardson 	struct rte_eth_txq_info *qinfo);
507999a2dd95SBruce Richardson 
508099a2dd95SBruce Richardson /**
5081e43d2b89SFeifei Wang  * @warning
5082e43d2b89SFeifei Wang  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
5083e43d2b89SFeifei Wang  *
5084e43d2b89SFeifei Wang  * Retrieve information about given ports's Rx queue for recycling mbufs.
5085e43d2b89SFeifei Wang  *
5086e43d2b89SFeifei Wang  * @param port_id
5087e43d2b89SFeifei Wang  *   The port identifier of the Ethernet device.
5088e43d2b89SFeifei Wang  * @param queue_id
5089e43d2b89SFeifei Wang  *   The Rx queue on the Ethernet devicefor which information
5090e43d2b89SFeifei Wang  *   will be retrieved.
5091e43d2b89SFeifei Wang  * @param recycle_rxq_info
5092e43d2b89SFeifei Wang  *   A pointer to a structure of type *rte_eth_recycle_rxq_info* to be filled.
5093e43d2b89SFeifei Wang  *
5094e43d2b89SFeifei Wang  * @return
5095e43d2b89SFeifei Wang  *   - 0: Success
5096e43d2b89SFeifei Wang  *   - -ENODEV:  If *port_id* is invalid.
5097e43d2b89SFeifei Wang  *   - -ENOTSUP: routine is not supported by the device PMD.
5098e43d2b89SFeifei Wang  *   - -EINVAL:  The queue_id is out of range.
5099e43d2b89SFeifei Wang  */
5100e43d2b89SFeifei Wang __rte_experimental
5101e43d2b89SFeifei Wang int rte_eth_recycle_rx_queue_info_get(uint16_t port_id,
5102e43d2b89SFeifei Wang 		uint16_t queue_id,
5103e43d2b89SFeifei Wang 		struct rte_eth_recycle_rxq_info *recycle_rxq_info);
5104e43d2b89SFeifei Wang 
5105e43d2b89SFeifei Wang /**
510699a2dd95SBruce Richardson  * Retrieve information about the Rx packet burst mode.
510799a2dd95SBruce Richardson  *
510899a2dd95SBruce Richardson  * @param port_id
510999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
511099a2dd95SBruce Richardson  * @param queue_id
511199a2dd95SBruce Richardson  *   The Rx queue on the Ethernet device for which information
511299a2dd95SBruce Richardson  *   will be retrieved.
511399a2dd95SBruce Richardson  * @param mode
511499a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_eth_burst_mode* to be filled
511599a2dd95SBruce Richardson  *   with the information of the packet burst mode.
511699a2dd95SBruce Richardson  *
511799a2dd95SBruce Richardson  * @return
511899a2dd95SBruce Richardson  *   - 0: Success
511999a2dd95SBruce Richardson  *   - -ENODEV:  If *port_id* is invalid.
512099a2dd95SBruce Richardson  *   - -ENOTSUP: routine is not supported by the device PMD.
512199a2dd95SBruce Richardson  *   - -EINVAL:  The queue_id is out of range.
512299a2dd95SBruce Richardson  */
512399a2dd95SBruce Richardson int rte_eth_rx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
512499a2dd95SBruce Richardson 	struct rte_eth_burst_mode *mode);
512599a2dd95SBruce Richardson 
512699a2dd95SBruce Richardson /**
512799a2dd95SBruce Richardson  * Retrieve information about the Tx packet burst mode.
512899a2dd95SBruce Richardson  *
512999a2dd95SBruce Richardson  * @param port_id
513099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
513199a2dd95SBruce Richardson  * @param queue_id
513299a2dd95SBruce Richardson  *   The Tx queue on the Ethernet device for which information
513399a2dd95SBruce Richardson  *   will be retrieved.
513499a2dd95SBruce Richardson  * @param mode
513599a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_eth_burst_mode* to be filled
513699a2dd95SBruce Richardson  *   with the information of the packet burst mode.
513799a2dd95SBruce Richardson  *
513899a2dd95SBruce Richardson  * @return
513999a2dd95SBruce Richardson  *   - 0: Success
514099a2dd95SBruce Richardson  *   - -ENODEV:  If *port_id* is invalid.
514199a2dd95SBruce Richardson  *   - -ENOTSUP: routine is not supported by the device PMD.
514299a2dd95SBruce Richardson  *   - -EINVAL:  The queue_id is out of range.
514399a2dd95SBruce Richardson  */
514499a2dd95SBruce Richardson int rte_eth_tx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
514599a2dd95SBruce Richardson 	struct rte_eth_burst_mode *mode);
514699a2dd95SBruce Richardson 
514799a2dd95SBruce Richardson /**
514899a2dd95SBruce Richardson  * @warning
514999a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
515099a2dd95SBruce Richardson  *
515199a2dd95SBruce Richardson  * Retrieve the monitor condition for a given receive queue.
515299a2dd95SBruce Richardson  *
515399a2dd95SBruce Richardson  * @param port_id
515499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
515599a2dd95SBruce Richardson  * @param queue_id
515699a2dd95SBruce Richardson  *   The Rx queue on the Ethernet device for which information
515799a2dd95SBruce Richardson  *   will be retrieved.
515899a2dd95SBruce Richardson  * @param pmc
515999a2dd95SBruce Richardson  *   The pointer to power-optimized monitoring condition structure.
516099a2dd95SBruce Richardson  *
516199a2dd95SBruce Richardson  * @return
516299a2dd95SBruce Richardson  *   - 0: Success.
516399a2dd95SBruce Richardson  *   -ENOTSUP: Operation not supported.
516499a2dd95SBruce Richardson  *   -EINVAL: Invalid parameters.
516599a2dd95SBruce Richardson  *   -ENODEV: Invalid port ID.
516699a2dd95SBruce Richardson  */
516799a2dd95SBruce Richardson __rte_experimental
516899a2dd95SBruce Richardson int rte_eth_get_monitor_addr(uint16_t port_id, uint16_t queue_id,
516999a2dd95SBruce Richardson 		struct rte_power_monitor_cond *pmc);
517099a2dd95SBruce Richardson 
517199a2dd95SBruce Richardson /**
5172083db2edSJie Hai  * Retrieve the filtered device registers (values and names) and
5173083db2edSJie Hai  * register attributes (number of registers and register size)
5174083db2edSJie Hai  *
5175083db2edSJie Hai  * @param port_id
5176083db2edSJie Hai  *   The port identifier of the Ethernet device.
5177083db2edSJie Hai  * @param info
5178083db2edSJie Hai  *   Pointer to rte_dev_reg_info structure to fill in.
5179083db2edSJie Hai  *   - If info->filter is NULL, return info for all registers (seen as filter
5180083db2edSJie Hai  *     none).
5181083db2edSJie Hai  *   - If info->filter is not NULL, return error if the driver does not support
5182083db2edSJie Hai  *     filter. Fill the length field with filtered register number.
5183083db2edSJie Hai  *   - If info->data is NULL, the function fills in the width and length fields.
5184083db2edSJie Hai  *   - If info->data is not NULL, ethdev considers there are enough spaces to
5185083db2edSJie Hai  *     store the registers, and the values of registers with the filter string
5186083db2edSJie Hai  *     as the module name are put into the buffer pointed at by info->data.
5187083db2edSJie Hai  *   - If info->names is not NULL, drivers should fill it or the ethdev fills it
5188083db2edSJie Hai  *     with default names.
5189083db2edSJie Hai  * @return
5190083db2edSJie Hai  *   - (0) if successful.
5191083db2edSJie Hai  *   - (-ENOTSUP) if hardware doesn't support.
5192083db2edSJie Hai  *   - (-EINVAL) if bad parameter.
5193083db2edSJie Hai  *   - (-ENODEV) if *port_id* invalid.
5194083db2edSJie Hai  *   - (-EIO) if device is removed.
5195083db2edSJie Hai  *   - others depends on the specific operations implementation.
5196083db2edSJie Hai  */
5197083db2edSJie Hai __rte_experimental
5198083db2edSJie Hai int rte_eth_dev_get_reg_info_ext(uint16_t port_id, struct rte_dev_reg_info *info);
5199083db2edSJie Hai 
5200083db2edSJie Hai /**
520199a2dd95SBruce Richardson  * Retrieve device registers and register attributes (number of registers and
520299a2dd95SBruce Richardson  * register size)
520399a2dd95SBruce Richardson  *
520499a2dd95SBruce Richardson  * @param port_id
520599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
520699a2dd95SBruce Richardson  * @param info
520799a2dd95SBruce Richardson  *   Pointer to rte_dev_reg_info structure to fill in. If info->data is
520899a2dd95SBruce Richardson  *   NULL the function fills in the width and length fields. If non-NULL
520999a2dd95SBruce Richardson  *   the registers are put into the buffer pointed at by the data field.
521099a2dd95SBruce Richardson  * @return
521199a2dd95SBruce Richardson  *   - (0) if successful.
521299a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
521399a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
521499a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
521599a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
521699a2dd95SBruce Richardson  *   - others depends on the specific operations implementation.
521799a2dd95SBruce Richardson  */
5218*1ff8b9a6SStephen Hemminger int rte_eth_dev_get_reg_info(uint16_t port_id, struct rte_dev_reg_info *info)
5219*1ff8b9a6SStephen Hemminger 	__rte_warn_unused_result;
522099a2dd95SBruce Richardson 
522199a2dd95SBruce Richardson /**
522299a2dd95SBruce Richardson  * Retrieve size of device EEPROM
522399a2dd95SBruce Richardson  *
522499a2dd95SBruce Richardson  * @param port_id
522599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
522699a2dd95SBruce Richardson  * @return
522799a2dd95SBruce Richardson  *   - (>=0) EEPROM size if successful.
522899a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
522999a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
523099a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
523199a2dd95SBruce Richardson  *   - others depends on the specific operations implementation.
523299a2dd95SBruce Richardson  */
523399a2dd95SBruce Richardson int rte_eth_dev_get_eeprom_length(uint16_t port_id);
523499a2dd95SBruce Richardson 
523599a2dd95SBruce Richardson /**
523699a2dd95SBruce Richardson  * Retrieve EEPROM and EEPROM attribute
523799a2dd95SBruce Richardson  *
523899a2dd95SBruce Richardson  * @param port_id
523999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
524099a2dd95SBruce Richardson  * @param info
524199a2dd95SBruce Richardson  *   The template includes buffer for return EEPROM data and
524299a2dd95SBruce Richardson  *   EEPROM attributes to be filled.
524399a2dd95SBruce Richardson  * @return
524499a2dd95SBruce Richardson  *   - (0) if successful.
524599a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
524699a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
524799a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
524899a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
524999a2dd95SBruce Richardson  *   - others depends on the specific operations implementation.
525099a2dd95SBruce Richardson  */
525199a2dd95SBruce Richardson int rte_eth_dev_get_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
525299a2dd95SBruce Richardson 
525399a2dd95SBruce Richardson /**
525499a2dd95SBruce Richardson  * Program EEPROM with provided data
525599a2dd95SBruce Richardson  *
525699a2dd95SBruce Richardson  * @param port_id
525799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
525899a2dd95SBruce Richardson  * @param info
525999a2dd95SBruce Richardson  *   The template includes EEPROM data for programming and
526099a2dd95SBruce Richardson  *   EEPROM attributes to be filled
526199a2dd95SBruce Richardson  * @return
526299a2dd95SBruce Richardson  *   - (0) if successful.
526399a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
526499a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
526599a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
526699a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
526799a2dd95SBruce Richardson  *   - others depends on the specific operations implementation.
526899a2dd95SBruce Richardson  */
526999a2dd95SBruce Richardson int rte_eth_dev_set_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
527099a2dd95SBruce Richardson 
527199a2dd95SBruce Richardson /**
527299a2dd95SBruce Richardson  * @warning
527399a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
527499a2dd95SBruce Richardson  *
527599a2dd95SBruce Richardson  * Retrieve the type and size of plugin module EEPROM
527699a2dd95SBruce Richardson  *
527799a2dd95SBruce Richardson  * @param port_id
527899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
527999a2dd95SBruce Richardson  * @param modinfo
528099a2dd95SBruce Richardson  *   The type and size of plugin module EEPROM.
528199a2dd95SBruce Richardson  * @return
528299a2dd95SBruce Richardson  *   - (0) if successful.
528399a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
528499a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
528599a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
528699a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
528799a2dd95SBruce Richardson  *   - others depends on the specific operations implementation.
528899a2dd95SBruce Richardson  */
528999a2dd95SBruce Richardson __rte_experimental
529099a2dd95SBruce Richardson int
5291*1ff8b9a6SStephen Hemminger rte_eth_dev_get_module_info(uint16_t port_id, struct rte_eth_dev_module_info *modinfo)
5292*1ff8b9a6SStephen Hemminger 	__rte_warn_unused_result;
529399a2dd95SBruce Richardson 
529499a2dd95SBruce Richardson /**
529599a2dd95SBruce Richardson  * @warning
529699a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
529799a2dd95SBruce Richardson  *
529899a2dd95SBruce Richardson  * Retrieve the data of plugin module EEPROM
529999a2dd95SBruce Richardson  *
530099a2dd95SBruce Richardson  * @param port_id
530199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
530299a2dd95SBruce Richardson  * @param info
530399a2dd95SBruce Richardson  *   The template includes the plugin module EEPROM attributes, and the
530499a2dd95SBruce Richardson  *   buffer for return plugin module EEPROM data.
530599a2dd95SBruce Richardson  * @return
530699a2dd95SBruce Richardson  *   - (0) if successful.
530799a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
530899a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
530999a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
531099a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
531199a2dd95SBruce Richardson  *   - others depends on the specific operations implementation.
531299a2dd95SBruce Richardson  */
531399a2dd95SBruce Richardson __rte_experimental
531499a2dd95SBruce Richardson int
5315*1ff8b9a6SStephen Hemminger rte_eth_dev_get_module_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info)
5316*1ff8b9a6SStephen Hemminger 	__rte_warn_unused_result;
531799a2dd95SBruce Richardson 
531899a2dd95SBruce Richardson /**
531999a2dd95SBruce Richardson  * Set the list of multicast addresses to filter on an Ethernet device.
532099a2dd95SBruce Richardson  *
532199a2dd95SBruce Richardson  * @param port_id
532299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
532399a2dd95SBruce Richardson  * @param mc_addr_set
532499a2dd95SBruce Richardson  *   The array of multicast addresses to set. Equal to NULL when the function
532599a2dd95SBruce Richardson  *   is invoked to flush the set of filtered addresses.
532699a2dd95SBruce Richardson  * @param nb_mc_addr
532799a2dd95SBruce Richardson  *   The number of multicast addresses in the *mc_addr_set* array. Equal to 0
532899a2dd95SBruce Richardson  *   when the function is invoked to flush the set of filtered addresses.
532999a2dd95SBruce Richardson  * @return
533099a2dd95SBruce Richardson  *   - (0) if successful.
533199a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
533299a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
533399a2dd95SBruce Richardson  *   - (-ENOTSUP) if PMD of *port_id* doesn't support multicast filtering.
533499a2dd95SBruce Richardson  *   - (-ENOSPC) if *port_id* has not enough multicast filtering resources.
533553ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
533699a2dd95SBruce Richardson  */
533799a2dd95SBruce Richardson int rte_eth_dev_set_mc_addr_list(uint16_t port_id,
533899a2dd95SBruce Richardson 				 struct rte_ether_addr *mc_addr_set,
533999a2dd95SBruce Richardson 				 uint32_t nb_mc_addr);
534099a2dd95SBruce Richardson 
534199a2dd95SBruce Richardson /**
534299a2dd95SBruce Richardson  * Enable IEEE1588/802.1AS timestamping for an Ethernet device.
534399a2dd95SBruce Richardson  *
534499a2dd95SBruce Richardson  * @param port_id
534599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
534699a2dd95SBruce Richardson  *
534799a2dd95SBruce Richardson  * @return
534899a2dd95SBruce Richardson  *   - 0: Success.
534999a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
535099a2dd95SBruce Richardson  *   - -EIO: if device is removed.
535199a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
535299a2dd95SBruce Richardson  */
535399a2dd95SBruce Richardson int rte_eth_timesync_enable(uint16_t port_id);
535499a2dd95SBruce Richardson 
535599a2dd95SBruce Richardson /**
535699a2dd95SBruce Richardson  * Disable IEEE1588/802.1AS timestamping for an Ethernet device.
535799a2dd95SBruce Richardson  *
535899a2dd95SBruce Richardson  * @param port_id
535999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
536099a2dd95SBruce Richardson  *
536199a2dd95SBruce Richardson  * @return
536299a2dd95SBruce Richardson  *   - 0: Success.
536399a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
536499a2dd95SBruce Richardson  *   - -EIO: if device is removed.
536599a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
536699a2dd95SBruce Richardson  */
536799a2dd95SBruce Richardson int rte_eth_timesync_disable(uint16_t port_id);
536899a2dd95SBruce Richardson 
536999a2dd95SBruce Richardson /**
537009fd4227SAndrew Rybchenko  * Read an IEEE1588/802.1AS Rx timestamp from an Ethernet device.
537199a2dd95SBruce Richardson  *
537299a2dd95SBruce Richardson  * @param port_id
537399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
537499a2dd95SBruce Richardson  * @param timestamp
537599a2dd95SBruce Richardson  *   Pointer to the timestamp struct.
537699a2dd95SBruce Richardson  * @param flags
537709fd4227SAndrew Rybchenko  *   Device specific flags. Used to pass the Rx timesync register index to
537899a2dd95SBruce Richardson  *   i40e. Unused in igb/ixgbe, pass 0 instead.
537999a2dd95SBruce Richardson  *
538099a2dd95SBruce Richardson  * @return
538199a2dd95SBruce Richardson  *   - 0: Success.
538299a2dd95SBruce Richardson  *   - -EINVAL: No timestamp is available.
538399a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
538499a2dd95SBruce Richardson  *   - -EIO: if device is removed.
538599a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
538699a2dd95SBruce Richardson  */
538799a2dd95SBruce Richardson int rte_eth_timesync_read_rx_timestamp(uint16_t port_id,
538899a2dd95SBruce Richardson 		struct timespec *timestamp, uint32_t flags);
538999a2dd95SBruce Richardson 
539099a2dd95SBruce Richardson /**
539109fd4227SAndrew Rybchenko  * Read an IEEE1588/802.1AS Tx timestamp from an Ethernet device.
539299a2dd95SBruce Richardson  *
539399a2dd95SBruce Richardson  * @param port_id
539499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
539599a2dd95SBruce Richardson  * @param timestamp
539699a2dd95SBruce Richardson  *   Pointer to the timestamp struct.
539799a2dd95SBruce Richardson  *
539899a2dd95SBruce Richardson  * @return
539999a2dd95SBruce Richardson  *   - 0: Success.
540099a2dd95SBruce Richardson  *   - -EINVAL: No timestamp is available.
540199a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
540299a2dd95SBruce Richardson  *   - -EIO: if device is removed.
540399a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
540499a2dd95SBruce Richardson  */
540599a2dd95SBruce Richardson int rte_eth_timesync_read_tx_timestamp(uint16_t port_id,
540699a2dd95SBruce Richardson 		struct timespec *timestamp);
540799a2dd95SBruce Richardson 
540899a2dd95SBruce Richardson /**
540999a2dd95SBruce Richardson  * Adjust the timesync clock on an Ethernet device.
541099a2dd95SBruce Richardson  *
541199a2dd95SBruce Richardson  * This is usually used in conjunction with other Ethdev timesync functions to
541299a2dd95SBruce Richardson  * synchronize the device time using the IEEE1588/802.1AS protocol.
541399a2dd95SBruce Richardson  *
541499a2dd95SBruce Richardson  * @param port_id
541599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
541699a2dd95SBruce Richardson  * @param delta
541799a2dd95SBruce Richardson  *   The adjustment in nanoseconds.
541899a2dd95SBruce Richardson  *
541999a2dd95SBruce Richardson  * @return
542099a2dd95SBruce Richardson  *   - 0: Success.
542199a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
542299a2dd95SBruce Richardson  *   - -EIO: if device is removed.
542399a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
542499a2dd95SBruce Richardson  */
542599a2dd95SBruce Richardson int rte_eth_timesync_adjust_time(uint16_t port_id, int64_t delta);
542699a2dd95SBruce Richardson 
542799a2dd95SBruce Richardson /**
5428be86a682SMingjin Ye  * Adjust the clock frequency on an Ethernet device.
5429be86a682SMingjin Ye  *
5430be86a682SMingjin Ye  * Adjusts the base frequency by a specified percentage of ppm (parts per
5431be86a682SMingjin Ye  * million). This is usually used in conjunction with other Ethdev timesync
5432be86a682SMingjin Ye  * functions to synchronize the device time using the IEEE1588/802.1AS
5433be86a682SMingjin Ye  * protocol.
5434be86a682SMingjin Ye  *
5435be86a682SMingjin Ye  * The clock is subject to frequency deviation and rate of change drift due to
5436be86a682SMingjin Ye  * the environment. The upper layer APP calculates the frequency compensation
5437be86a682SMingjin Ye  * value of the slave clock relative to the master clock via a servo algorithm
5438be86a682SMingjin Ye  * and adjusts the device clock frequency via "rte_eth_timesync_adjust_freq()".
5439be86a682SMingjin Ye  * Commonly used servo algorithms are pi/linreg/ntpshm, for implementation
5440be86a682SMingjin Ye  * see: https://github.com/nxp-archive/openil_linuxptp.git.
5441be86a682SMingjin Ye  *
5442be86a682SMingjin Ye  * The adjustment value obtained by the servo algorithm is usually in
5443be86a682SMingjin Ye  * ppb (parts per billion). For consistency with the kernel driver .adjfine,
5444be86a682SMingjin Ye  * the tuning values are in ppm. Note that 1 ppb is approximately 65.536 scaled
5445be86a682SMingjin Ye  * ppm, see Linux kernel upstream commit 1060707e3809 (‘ptp: introduce helpers
5446be86a682SMingjin Ye  * to adjust by scaled parts per million’).
5447be86a682SMingjin Ye  *
5448be86a682SMingjin Ye  * In addition, the device reference frequency is usually also the stepping
5449be86a682SMingjin Ye  * threshold for the servo algorithm, and the frequency up and down adjustment
5450be86a682SMingjin Ye  * range is limited by the device. The device clock frequency should be
5451be86a682SMingjin Ye  * adjusted with "rte_eth_timesync_adjust_freq()" every time the clock is
5452be86a682SMingjin Ye  * synchronised. Also use ‘rte_eth_timesync_adjust_time()’ to update the device
5453be86a682SMingjin Ye  * clock only if the absolute value of the master/slave clock offset is greater than
5454be86a682SMingjin Ye  * or equal to the step threshold.
5455be86a682SMingjin Ye  *
5456be86a682SMingjin Ye  * @param port_id
5457be86a682SMingjin Ye  *  The port identifier of the Ethernet device.
5458be86a682SMingjin Ye  * @param ppm
5459be86a682SMingjin Ye  *  Parts per million with 16-bit fractional field
5460be86a682SMingjin Ye  *
5461be86a682SMingjin Ye  * @return
5462be86a682SMingjin Ye  *   - 0: Success.
5463be86a682SMingjin Ye  *   - -ENODEV: The port ID is invalid.
5464be86a682SMingjin Ye  *   - -EIO: if device is removed.
5465be86a682SMingjin Ye  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
5466be86a682SMingjin Ye  */
5467be86a682SMingjin Ye __rte_experimental
5468be86a682SMingjin Ye int rte_eth_timesync_adjust_freq(uint16_t port_id, int64_t ppm);
5469be86a682SMingjin Ye 
5470be86a682SMingjin Ye /**
547199a2dd95SBruce Richardson  * Read the time from the timesync clock on an Ethernet device.
547299a2dd95SBruce Richardson  *
547399a2dd95SBruce Richardson  * This is usually used in conjunction with other Ethdev timesync functions to
547499a2dd95SBruce Richardson  * synchronize the device time using the IEEE1588/802.1AS protocol.
547599a2dd95SBruce Richardson  *
547699a2dd95SBruce Richardson  * @param port_id
547799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
547899a2dd95SBruce Richardson  * @param time
547999a2dd95SBruce Richardson  *   Pointer to the timespec struct that holds the time.
548099a2dd95SBruce Richardson  *
548199a2dd95SBruce Richardson  * @return
548299a2dd95SBruce Richardson  *   - 0: Success.
548353ef1b34SMin Hu (Connor)  *   - -EINVAL: Bad parameter.
548499a2dd95SBruce Richardson  */
548599a2dd95SBruce Richardson int rte_eth_timesync_read_time(uint16_t port_id, struct timespec *time);
548699a2dd95SBruce Richardson 
548799a2dd95SBruce Richardson /**
548899a2dd95SBruce Richardson  * Set the time of the timesync clock on an Ethernet device.
548999a2dd95SBruce Richardson  *
549099a2dd95SBruce Richardson  * This is usually used in conjunction with other Ethdev timesync functions to
549199a2dd95SBruce Richardson  * synchronize the device time using the IEEE1588/802.1AS protocol.
549299a2dd95SBruce Richardson  *
549399a2dd95SBruce Richardson  * @param port_id
549499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
549599a2dd95SBruce Richardson  * @param time
549699a2dd95SBruce Richardson  *   Pointer to the timespec struct that holds the time.
549799a2dd95SBruce Richardson  *
549899a2dd95SBruce Richardson  * @return
549999a2dd95SBruce Richardson  *   - 0: Success.
550099a2dd95SBruce Richardson  *   - -EINVAL: No timestamp is available.
550199a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
550299a2dd95SBruce Richardson  *   - -EIO: if device is removed.
550399a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
550499a2dd95SBruce Richardson  */
550599a2dd95SBruce Richardson int rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *time);
550699a2dd95SBruce Richardson 
550799a2dd95SBruce Richardson /**
550899a2dd95SBruce Richardson  * @warning
550999a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
551099a2dd95SBruce Richardson  *
551199a2dd95SBruce Richardson  * Read the current clock counter of an Ethernet device
551299a2dd95SBruce Richardson  *
551399a2dd95SBruce Richardson  * This returns the current raw clock value of an Ethernet device. It is
551499a2dd95SBruce Richardson  * a raw amount of ticks, with no given time reference.
551599a2dd95SBruce Richardson  * The value returned here is from the same clock than the one
551699a2dd95SBruce Richardson  * filling timestamp field of Rx packets when using hardware timestamp
551799a2dd95SBruce Richardson  * offload. Therefore it can be used to compute a precise conversion of
551899a2dd95SBruce Richardson  * the device clock to the real time.
551999a2dd95SBruce Richardson  *
552099a2dd95SBruce Richardson  * E.g, a simple heuristic to derivate the frequency would be:
552199a2dd95SBruce Richardson  * uint64_t start, end;
552299a2dd95SBruce Richardson  * rte_eth_read_clock(port, start);
552399a2dd95SBruce Richardson  * rte_delay_ms(100);
552499a2dd95SBruce Richardson  * rte_eth_read_clock(port, end);
552599a2dd95SBruce Richardson  * double freq = (end - start) * 10;
552699a2dd95SBruce Richardson  *
552799a2dd95SBruce Richardson  * Compute a common reference with:
552899a2dd95SBruce Richardson  * uint64_t base_time_sec = current_time();
552999a2dd95SBruce Richardson  * uint64_t base_clock;
553099a2dd95SBruce Richardson  * rte_eth_read_clock(port, base_clock);
553199a2dd95SBruce Richardson  *
553299a2dd95SBruce Richardson  * Then, convert the raw mbuf timestamp with:
553399a2dd95SBruce Richardson  * base_time_sec + (double)(*timestamp_dynfield(mbuf) - base_clock) / freq;
553499a2dd95SBruce Richardson  *
553599a2dd95SBruce Richardson  * This simple example will not provide a very good accuracy. One must
553699a2dd95SBruce Richardson  * at least measure multiple times the frequency and do a regression.
553799a2dd95SBruce Richardson  * To avoid deviation from the system time, the common reference can
553899a2dd95SBruce Richardson  * be repeated from time to time. The integer division can also be
553999a2dd95SBruce Richardson  * converted by a multiplication and a shift for better performance.
554099a2dd95SBruce Richardson  *
554199a2dd95SBruce Richardson  * @param port_id
554299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
554399a2dd95SBruce Richardson  * @param clock
554499a2dd95SBruce Richardson  *   Pointer to the uint64_t that holds the raw clock value.
554599a2dd95SBruce Richardson  *
554699a2dd95SBruce Richardson  * @return
554799a2dd95SBruce Richardson  *   - 0: Success.
554899a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
554999a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
555053ef1b34SMin Hu (Connor)  *   - -EINVAL: if bad parameter.
555199a2dd95SBruce Richardson  */
555299a2dd95SBruce Richardson __rte_experimental
555399a2dd95SBruce Richardson int
555499a2dd95SBruce Richardson rte_eth_read_clock(uint16_t port_id, uint64_t *clock);
555599a2dd95SBruce Richardson 
555699a2dd95SBruce Richardson /**
5557d5d13ef9SThomas Monjalon  * Get the port ID from device name.
5558d5d13ef9SThomas Monjalon  * The device name should be specified as below:
555999a2dd95SBruce Richardson  * - PCIe address (Domain:Bus:Device.Function), for example- 0000:2:00.0
556099a2dd95SBruce Richardson  * - SoC device name, for example- fsl-gmac0
556199a2dd95SBruce Richardson  * - vdev dpdk name, for example- net_[pcap0|null0|tap0]
556299a2dd95SBruce Richardson  *
556399a2dd95SBruce Richardson  * @param name
5564d5d13ef9SThomas Monjalon  *   PCI address or name of the device.
556599a2dd95SBruce Richardson  * @param port_id
5566d5d13ef9SThomas Monjalon  *   Pointer to port identifier of the device.
556799a2dd95SBruce Richardson  * @return
556899a2dd95SBruce Richardson  *   - (0) if successful and port_id is filled.
556999a2dd95SBruce Richardson  *   - (-ENODEV or -EINVAL) on failure.
557099a2dd95SBruce Richardson  */
557199a2dd95SBruce Richardson int
557299a2dd95SBruce Richardson rte_eth_dev_get_port_by_name(const char *name, uint16_t *port_id);
557399a2dd95SBruce Richardson 
557499a2dd95SBruce Richardson /**
5575d5d13ef9SThomas Monjalon  * Get the device name from port ID.
5576d5d13ef9SThomas Monjalon  * The device name is specified as below:
557799a2dd95SBruce Richardson  * - PCIe address (Domain:Bus:Device.Function), for example- 0000:02:00.0
557899a2dd95SBruce Richardson  * - SoC device name, for example- fsl-gmac0
557999a2dd95SBruce Richardson  * - vdev dpdk name, for example- net_[pcap0|null0|tun0|tap0]
558099a2dd95SBruce Richardson  *
558199a2dd95SBruce Richardson  * @param port_id
558299a2dd95SBruce Richardson  *   Port identifier of the device.
558399a2dd95SBruce Richardson  * @param name
558499a2dd95SBruce Richardson  *   Buffer of size RTE_ETH_NAME_MAX_LEN to store the name.
558599a2dd95SBruce Richardson  * @return
558699a2dd95SBruce Richardson  *   - (0) if successful.
558799a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
558899a2dd95SBruce Richardson  *   - (-EINVAL) on failure.
558999a2dd95SBruce Richardson  */
559099a2dd95SBruce Richardson int
559199a2dd95SBruce Richardson rte_eth_dev_get_name_by_port(uint16_t port_id, char *name);
559299a2dd95SBruce Richardson 
559399a2dd95SBruce Richardson /**
559499a2dd95SBruce Richardson  * Check that numbers of Rx and Tx descriptors satisfy descriptors limits from
55950d9f56a8SAndrew Rybchenko  * the Ethernet device information, otherwise adjust them to boundaries.
559699a2dd95SBruce Richardson  *
559799a2dd95SBruce Richardson  * @param port_id
559899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
559999a2dd95SBruce Richardson  * @param nb_rx_desc
560099a2dd95SBruce Richardson  *   A pointer to a uint16_t where the number of receive
560199a2dd95SBruce Richardson  *   descriptors stored.
560299a2dd95SBruce Richardson  * @param nb_tx_desc
560399a2dd95SBruce Richardson  *   A pointer to a uint16_t where the number of transmit
560499a2dd95SBruce Richardson  *   descriptors stored.
560599a2dd95SBruce Richardson  * @return
560699a2dd95SBruce Richardson  *   - (0) if successful.
560799a2dd95SBruce Richardson  *   - (-ENOTSUP, -ENODEV or -EINVAL) on failure.
560899a2dd95SBruce Richardson  */
560999a2dd95SBruce Richardson int rte_eth_dev_adjust_nb_rx_tx_desc(uint16_t port_id,
561099a2dd95SBruce Richardson 				     uint16_t *nb_rx_desc,
561199a2dd95SBruce Richardson 				     uint16_t *nb_tx_desc);
561299a2dd95SBruce Richardson 
561399a2dd95SBruce Richardson /**
561499a2dd95SBruce Richardson  * Test if a port supports specific mempool ops.
561599a2dd95SBruce Richardson  *
561699a2dd95SBruce Richardson  * @param port_id
561799a2dd95SBruce Richardson  *   Port identifier of the Ethernet device.
561899a2dd95SBruce Richardson  * @param [in] pool
561999a2dd95SBruce Richardson  *   The name of the pool operations to test.
562099a2dd95SBruce Richardson  * @return
562199a2dd95SBruce Richardson  *   - 0: best mempool ops choice for this port.
562299a2dd95SBruce Richardson  *   - 1: mempool ops are supported for this port.
562399a2dd95SBruce Richardson  *   - -ENOTSUP: mempool ops not supported for this port.
562499a2dd95SBruce Richardson  *   - -ENODEV: Invalid port Identifier.
562599a2dd95SBruce Richardson  *   - -EINVAL: Pool param is null.
562699a2dd95SBruce Richardson  */
562799a2dd95SBruce Richardson int
562899a2dd95SBruce Richardson rte_eth_dev_pool_ops_supported(uint16_t port_id, const char *pool);
562999a2dd95SBruce Richardson 
563099a2dd95SBruce Richardson /**
563199a2dd95SBruce Richardson  * Get the security context for the Ethernet device.
563299a2dd95SBruce Richardson  *
563399a2dd95SBruce Richardson  * @param port_id
563499a2dd95SBruce Richardson  *   Port identifier of the Ethernet device
563599a2dd95SBruce Richardson  * @return
563699a2dd95SBruce Richardson  *   - NULL on error.
563799a2dd95SBruce Richardson  *   - pointer to security context on success.
563899a2dd95SBruce Richardson  */
563999a2dd95SBruce Richardson void *
564099a2dd95SBruce Richardson rte_eth_dev_get_sec_ctx(uint16_t port_id);
564199a2dd95SBruce Richardson 
564299a2dd95SBruce Richardson /**
564399a2dd95SBruce Richardson  * @warning
564499a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
564599a2dd95SBruce Richardson  *
564699a2dd95SBruce Richardson  * Query the device hairpin capabilities.
564799a2dd95SBruce Richardson  *
564899a2dd95SBruce Richardson  * @param port_id
564999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
565099a2dd95SBruce Richardson  * @param cap
565199a2dd95SBruce Richardson  *   Pointer to a structure that will hold the hairpin capabilities.
565299a2dd95SBruce Richardson  * @return
565399a2dd95SBruce Richardson  *   - (0) if successful.
565499a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
565553ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
565699a2dd95SBruce Richardson  */
565799a2dd95SBruce Richardson __rte_experimental
565899a2dd95SBruce Richardson int rte_eth_dev_hairpin_capability_get(uint16_t port_id,
565999a2dd95SBruce Richardson 				       struct rte_eth_hairpin_cap *cap);
566099a2dd95SBruce Richardson 
566199a2dd95SBruce Richardson /**
566299a2dd95SBruce Richardson  * @warning
566399a2dd95SBruce Richardson  * @b EXPERIMENTAL: this structure may change without prior notice.
566499a2dd95SBruce Richardson  *
56650d9f56a8SAndrew Rybchenko  * Ethernet device representor ID range entry
566699a2dd95SBruce Richardson  */
566799a2dd95SBruce Richardson struct rte_eth_representor_range {
566899a2dd95SBruce Richardson 	enum rte_eth_representor_type type; /**< Representor type */
566999a2dd95SBruce Richardson 	int controller; /**< Controller index */
567099a2dd95SBruce Richardson 	int pf; /**< Physical function index */
567199a2dd95SBruce Richardson 	__extension__
567299a2dd95SBruce Richardson 	union {
567399a2dd95SBruce Richardson 		int vf; /**< VF start index */
567499a2dd95SBruce Richardson 		int sf; /**< SF start index */
567599a2dd95SBruce Richardson 	};
567699a2dd95SBruce Richardson 	uint32_t id_base; /**< Representor ID start index */
567799a2dd95SBruce Richardson 	uint32_t id_end;  /**< Representor ID end index */
567899a2dd95SBruce Richardson 	char name[RTE_DEV_NAME_MAX_LEN]; /**< Representor name */
567999a2dd95SBruce Richardson };
568099a2dd95SBruce Richardson 
568199a2dd95SBruce Richardson /**
568299a2dd95SBruce Richardson  * @warning
568399a2dd95SBruce Richardson  * @b EXPERIMENTAL: this structure may change without prior notice.
568499a2dd95SBruce Richardson  *
568599a2dd95SBruce Richardson  * Ethernet device representor information
568699a2dd95SBruce Richardson  */
568799a2dd95SBruce Richardson struct rte_eth_representor_info {
568899a2dd95SBruce Richardson 	uint16_t controller; /**< Controller ID of caller device. */
568999a2dd95SBruce Richardson 	uint16_t pf; /**< Physical function ID of caller device. */
569010eaf41dSViacheslav Galaktionov 	uint32_t nb_ranges_alloc; /**< Size of the ranges array. */
569110eaf41dSViacheslav Galaktionov 	uint32_t nb_ranges; /**< Number of initialized ranges. */
569299a2dd95SBruce Richardson 	struct rte_eth_representor_range ranges[];/**< Representor ID range. */
569399a2dd95SBruce Richardson };
569499a2dd95SBruce Richardson 
569599a2dd95SBruce Richardson /**
569699a2dd95SBruce Richardson  * Retrieve the representor info of the device.
569799a2dd95SBruce Richardson  *
569899a2dd95SBruce Richardson  * Get device representor info to be able to calculate a unique
569999a2dd95SBruce Richardson  * representor ID. @see rte_eth_representor_id_get helper.
570099a2dd95SBruce Richardson  *
570199a2dd95SBruce Richardson  * @param port_id
570299a2dd95SBruce Richardson  *   The port identifier of the device.
570399a2dd95SBruce Richardson  * @param info
570499a2dd95SBruce Richardson  *   A pointer to a representor info structure.
570599a2dd95SBruce Richardson  *   NULL to return number of range entries and allocate memory
570699a2dd95SBruce Richardson  *   for next call to store detail.
570710eaf41dSViacheslav Galaktionov  *   The number of ranges that were written into this structure
570810eaf41dSViacheslav Galaktionov  *   will be placed into its nb_ranges field. This number cannot be
570910eaf41dSViacheslav Galaktionov  *   larger than the nb_ranges_alloc that by the user before calling
571010eaf41dSViacheslav Galaktionov  *   this function. It can be smaller than the value returned by the
571110eaf41dSViacheslav Galaktionov  *   function, however.
571299a2dd95SBruce Richardson  * @return
571399a2dd95SBruce Richardson  *   - (-ENOTSUP) if operation is not supported.
571499a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
571599a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
571610eaf41dSViacheslav Galaktionov  *   - (>=0) number of available representor range entries.
571799a2dd95SBruce Richardson  */
571899a2dd95SBruce Richardson __rte_experimental
571999a2dd95SBruce Richardson int rte_eth_representor_info_get(uint16_t port_id,
572099a2dd95SBruce Richardson 				 struct rte_eth_representor_info *info);
572199a2dd95SBruce Richardson 
5722f6d8a6d3SIvan Malov /** The NIC is able to deliver flag (if set) with packets to the PMD. */
5723e1823e08SThomas Monjalon #define RTE_ETH_RX_METADATA_USER_FLAG RTE_BIT64(0)
5724f6d8a6d3SIvan Malov 
5725f6d8a6d3SIvan Malov /** The NIC is able to deliver mark ID with packets to the PMD. */
5726e1823e08SThomas Monjalon #define RTE_ETH_RX_METADATA_USER_MARK RTE_BIT64(1)
5727f6d8a6d3SIvan Malov 
5728f6d8a6d3SIvan Malov /** The NIC is able to deliver tunnel ID with packets to the PMD. */
5729e1823e08SThomas Monjalon #define RTE_ETH_RX_METADATA_TUNNEL_ID RTE_BIT64(2)
5730f6d8a6d3SIvan Malov 
5731f6d8a6d3SIvan Malov /**
5732f6d8a6d3SIvan Malov  * Negotiate the NIC's ability to deliver specific kinds of metadata to the PMD.
5733f6d8a6d3SIvan Malov  *
5734f6d8a6d3SIvan Malov  * Invoke this API before the first rte_eth_dev_configure() invocation
5735f6d8a6d3SIvan Malov  * to let the PMD make preparations that are inconvenient to do later.
5736f6d8a6d3SIvan Malov  *
5737f6d8a6d3SIvan Malov  * The negotiation process is as follows:
5738f6d8a6d3SIvan Malov  *
5739f6d8a6d3SIvan Malov  * - the application requests features intending to use at least some of them;
5740f6d8a6d3SIvan Malov  * - the PMD responds with the guaranteed subset of the requested feature set;
5741f6d8a6d3SIvan Malov  * - the application can retry negotiation with another set of features;
5742f6d8a6d3SIvan Malov  * - the application can pass zero to clear the negotiation result;
5743f6d8a6d3SIvan Malov  * - the last negotiated result takes effect upon
5744f6d8a6d3SIvan Malov  *   the ethdev configure and start.
5745f6d8a6d3SIvan Malov  *
5746f6d8a6d3SIvan Malov  * @note
5747f6d8a6d3SIvan Malov  *   The PMD is supposed to first consider enabling the requested feature set
5748f6d8a6d3SIvan Malov  *   in its entirety. Only if it fails to do so, does it have the right to
5749f6d8a6d3SIvan Malov  *   respond with a smaller set of the originally requested features.
5750f6d8a6d3SIvan Malov  *
5751f6d8a6d3SIvan Malov  * @note
5752f6d8a6d3SIvan Malov  *   Return code (-ENOTSUP) does not necessarily mean that the requested
5753f6d8a6d3SIvan Malov  *   features are unsupported. In this case, the application should just
5754f6d8a6d3SIvan Malov  *   assume that these features can be used without prior negotiations.
5755f6d8a6d3SIvan Malov  *
5756f6d8a6d3SIvan Malov  * @param port_id
5757f6d8a6d3SIvan Malov  *   Port (ethdev) identifier
5758f6d8a6d3SIvan Malov  *
5759f6d8a6d3SIvan Malov  * @param[inout] features
5760f6d8a6d3SIvan Malov  *   Feature selection buffer
5761f6d8a6d3SIvan Malov  *
5762f6d8a6d3SIvan Malov  * @return
5763f6d8a6d3SIvan Malov  *   - (-EBUSY) if the port can't handle this in its current state;
5764f6d8a6d3SIvan Malov  *   - (-ENOTSUP) if the method itself is not supported by the PMD;
5765f6d8a6d3SIvan Malov  *   - (-ENODEV) if *port_id* is invalid;
5766f6d8a6d3SIvan Malov  *   - (-EINVAL) if *features* is NULL;
5767f6d8a6d3SIvan Malov  *   - (-EIO) if the device is removed;
5768f6d8a6d3SIvan Malov  *   - (0) on success
5769f6d8a6d3SIvan Malov  */
5770f6d8a6d3SIvan Malov int rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features);
5771f6d8a6d3SIvan Malov 
5772a75ab6e5SAkhil Goyal /** Flag to offload IP reassembly for IPv4 packets. */
5773a75ab6e5SAkhil Goyal #define RTE_ETH_DEV_REASSEMBLY_F_IPV4 (RTE_BIT32(0))
5774a75ab6e5SAkhil Goyal /** Flag to offload IP reassembly for IPv6 packets. */
5775a75ab6e5SAkhil Goyal #define RTE_ETH_DEV_REASSEMBLY_F_IPV6 (RTE_BIT32(1))
5776a75ab6e5SAkhil Goyal 
5777a75ab6e5SAkhil Goyal /**
5778a75ab6e5SAkhil Goyal  * A structure used to get/set IP reassembly configuration. It is also used
5779a75ab6e5SAkhil Goyal  * to get the maximum capability values that a PMD can support.
5780a75ab6e5SAkhil Goyal  *
5781a75ab6e5SAkhil Goyal  * If rte_eth_ip_reassembly_capability_get() returns 0, IP reassembly can be
5782a75ab6e5SAkhil Goyal  * enabled using rte_eth_ip_reassembly_conf_set() and params values lower than
5783a75ab6e5SAkhil Goyal  * capability params can be set in the PMD.
5784a75ab6e5SAkhil Goyal  */
5785a75ab6e5SAkhil Goyal struct rte_eth_ip_reassembly_params {
5786a75ab6e5SAkhil Goyal 	/** Maximum time in ms which PMD can wait for other fragments. */
5787a75ab6e5SAkhil Goyal 	uint32_t timeout_ms;
5788a75ab6e5SAkhil Goyal 	/** Maximum number of fragments that can be reassembled. */
5789a75ab6e5SAkhil Goyal 	uint16_t max_frags;
5790a75ab6e5SAkhil Goyal 	/**
5791a75ab6e5SAkhil Goyal 	 * Flags to enable reassembly of packet types -
5792a75ab6e5SAkhil Goyal 	 * RTE_ETH_DEV_REASSEMBLY_F_xxx.
5793a75ab6e5SAkhil Goyal 	 */
5794a75ab6e5SAkhil Goyal 	uint16_t flags;
5795a75ab6e5SAkhil Goyal };
5796a75ab6e5SAkhil Goyal 
5797a75ab6e5SAkhil Goyal /**
5798a75ab6e5SAkhil Goyal  * @warning
5799a75ab6e5SAkhil Goyal  * @b EXPERIMENTAL: this API may change without prior notice
5800a75ab6e5SAkhil Goyal  *
5801a75ab6e5SAkhil Goyal  * Get IP reassembly capabilities supported by the PMD. This is the first API
5802a75ab6e5SAkhil Goyal  * to be called for enabling the IP reassembly offload feature. PMD will return
5803a75ab6e5SAkhil Goyal  * the maximum values of parameters that PMD can support and user can call
5804a75ab6e5SAkhil Goyal  * rte_eth_ip_reassembly_conf_set() with param values lower than capability.
5805a75ab6e5SAkhil Goyal  *
5806a75ab6e5SAkhil Goyal  * @param port_id
5807a75ab6e5SAkhil Goyal  *   The port identifier of the device.
5808a75ab6e5SAkhil Goyal  * @param capa
5809a75ab6e5SAkhil Goyal  *   A pointer to rte_eth_ip_reassembly_params structure.
5810a75ab6e5SAkhil Goyal  * @return
5811a75ab6e5SAkhil Goyal  *   - (-ENOTSUP) if offload configuration is not supported by device.
5812a75ab6e5SAkhil Goyal  *   - (-ENODEV) if *port_id* invalid.
5813a75ab6e5SAkhil Goyal  *   - (-EIO) if device is removed.
5814a75ab6e5SAkhil Goyal  *   - (-EINVAL) if device is not configured or *capa* passed is NULL.
5815a75ab6e5SAkhil Goyal  *   - (0) on success.
5816a75ab6e5SAkhil Goyal  */
5817a75ab6e5SAkhil Goyal __rte_experimental
5818a75ab6e5SAkhil Goyal int rte_eth_ip_reassembly_capability_get(uint16_t port_id,
5819a75ab6e5SAkhil Goyal 		struct rte_eth_ip_reassembly_params *capa);
5820a75ab6e5SAkhil Goyal 
5821a75ab6e5SAkhil Goyal /**
5822a75ab6e5SAkhil Goyal  * @warning
5823a75ab6e5SAkhil Goyal  * @b EXPERIMENTAL: this API may change without prior notice
5824a75ab6e5SAkhil Goyal  *
5825a75ab6e5SAkhil Goyal  * Get IP reassembly configuration parameters currently set in PMD.
5826a75ab6e5SAkhil Goyal  * The API will return error if the configuration is not already
5827a75ab6e5SAkhil Goyal  * set using rte_eth_ip_reassembly_conf_set() before calling this API or if
5828a75ab6e5SAkhil Goyal  * the device is not configured.
5829a75ab6e5SAkhil Goyal  *
5830a75ab6e5SAkhil Goyal  * @param port_id
5831a75ab6e5SAkhil Goyal  *   The port identifier of the device.
5832a75ab6e5SAkhil Goyal  * @param conf
5833a75ab6e5SAkhil Goyal  *   A pointer to rte_eth_ip_reassembly_params structure.
5834a75ab6e5SAkhil Goyal  * @return
5835a75ab6e5SAkhil Goyal  *   - (-ENOTSUP) if offload configuration is not supported by device.
5836a75ab6e5SAkhil Goyal  *   - (-ENODEV) if *port_id* invalid.
5837a75ab6e5SAkhil Goyal  *   - (-EIO) if device is removed.
5838a75ab6e5SAkhil Goyal  *   - (-EINVAL) if device is not configured or if *conf* passed is NULL or if
5839a75ab6e5SAkhil Goyal  *              configuration is not set using rte_eth_ip_reassembly_conf_set().
5840a75ab6e5SAkhil Goyal  *   - (0) on success.
5841a75ab6e5SAkhil Goyal  */
5842a75ab6e5SAkhil Goyal __rte_experimental
5843a75ab6e5SAkhil Goyal int rte_eth_ip_reassembly_conf_get(uint16_t port_id,
5844a75ab6e5SAkhil Goyal 		struct rte_eth_ip_reassembly_params *conf);
5845a75ab6e5SAkhil Goyal 
5846a75ab6e5SAkhil Goyal /**
5847a75ab6e5SAkhil Goyal  * @warning
5848a75ab6e5SAkhil Goyal  * @b EXPERIMENTAL: this API may change without prior notice
5849a75ab6e5SAkhil Goyal  *
5850a75ab6e5SAkhil Goyal  * Set IP reassembly configuration parameters if the PMD supports IP reassembly
5851a75ab6e5SAkhil Goyal  * offload. User should first call rte_eth_ip_reassembly_capability_get() to
5852a75ab6e5SAkhil Goyal  * check the maximum values supported by the PMD before setting the
5853a75ab6e5SAkhil Goyal  * configuration. The use of this API is mandatory to enable this feature and
5854a75ab6e5SAkhil Goyal  * should be called before rte_eth_dev_start().
5855a75ab6e5SAkhil Goyal  *
58563c059b2cSAkhil Goyal  * In datapath, PMD cannot guarantee that IP reassembly is always successful.
58573c059b2cSAkhil Goyal  * Hence, PMD shall register mbuf dynamic field and dynamic flag using
58583c059b2cSAkhil Goyal  * rte_eth_ip_reassembly_dynfield_register() to denote incomplete IP reassembly.
58593c059b2cSAkhil Goyal  * If dynfield is not successfully registered, error will be returned and
58603c059b2cSAkhil Goyal  * IP reassembly offload cannot be used.
58613c059b2cSAkhil Goyal  *
5862a75ab6e5SAkhil Goyal  * @param port_id
5863a75ab6e5SAkhil Goyal  *   The port identifier of the device.
5864a75ab6e5SAkhil Goyal  * @param conf
5865a75ab6e5SAkhil Goyal  *   A pointer to rte_eth_ip_reassembly_params structure.
5866a75ab6e5SAkhil Goyal  * @return
5867a75ab6e5SAkhil Goyal  *   - (-ENOTSUP) if offload configuration is not supported by device.
5868a75ab6e5SAkhil Goyal  *   - (-ENODEV) if *port_id* invalid.
5869a75ab6e5SAkhil Goyal  *   - (-EIO) if device is removed.
5870a75ab6e5SAkhil Goyal  *   - (-EINVAL) if device is not configured or if device is already started or
58713c059b2cSAkhil Goyal  *               if *conf* passed is NULL or if mbuf dynfield is not registered
58723c059b2cSAkhil Goyal  *               successfully by the PMD.
5873a75ab6e5SAkhil Goyal  *   - (0) on success.
5874a75ab6e5SAkhil Goyal  */
5875a75ab6e5SAkhil Goyal __rte_experimental
5876a75ab6e5SAkhil Goyal int rte_eth_ip_reassembly_conf_set(uint16_t port_id,
5877a75ab6e5SAkhil Goyal 		const struct rte_eth_ip_reassembly_params *conf);
5878a75ab6e5SAkhil Goyal 
58793c059b2cSAkhil Goyal /**
58803c059b2cSAkhil Goyal  * In case of IP reassembly offload failure, packet will be updated with
58813c059b2cSAkhil Goyal  * dynamic flag - RTE_MBUF_DYNFLAG_IP_REASSEMBLY_INCOMPLETE_NAME and packets
58823c059b2cSAkhil Goyal  * will be returned without alteration.
58833c059b2cSAkhil Goyal  * The application can retrieve the attached fragments using mbuf dynamic field
58843c059b2cSAkhil Goyal  * RTE_MBUF_DYNFIELD_IP_REASSEMBLY_NAME.
58853c059b2cSAkhil Goyal  */
58863c059b2cSAkhil Goyal typedef struct {
58873c059b2cSAkhil Goyal 	/**
58883c059b2cSAkhil Goyal 	 * Next fragment packet. Application should fetch dynamic field of
58893c059b2cSAkhil Goyal 	 * each fragment until a NULL is received and nb_frags is 0.
58903c059b2cSAkhil Goyal 	 */
58913c059b2cSAkhil Goyal 	struct rte_mbuf *next_frag;
58923c059b2cSAkhil Goyal 	/** Time spent(in ms) by HW in waiting for further fragments. */
58933c059b2cSAkhil Goyal 	uint16_t time_spent;
58943c059b2cSAkhil Goyal 	/** Number of more fragments attached in mbuf dynamic fields. */
58953c059b2cSAkhil Goyal 	uint16_t nb_frags;
58963c059b2cSAkhil Goyal } rte_eth_ip_reassembly_dynfield_t;
58973c059b2cSAkhil Goyal 
5898edcf22c6SMin Hu (Connor) /**
5899edcf22c6SMin Hu (Connor)  * @warning
5900edcf22c6SMin Hu (Connor)  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
5901edcf22c6SMin Hu (Connor)  *
5902edcf22c6SMin Hu (Connor)  * Dump private info from device to a file. Provided data and the order depends
5903edcf22c6SMin Hu (Connor)  * on the PMD.
5904edcf22c6SMin Hu (Connor)  *
5905edcf22c6SMin Hu (Connor)  * @param port_id
5906edcf22c6SMin Hu (Connor)  *   The port identifier of the Ethernet device.
5907edcf22c6SMin Hu (Connor)  * @param file
5908edcf22c6SMin Hu (Connor)  *   A pointer to a file for output.
5909edcf22c6SMin Hu (Connor)  * @return
5910edcf22c6SMin Hu (Connor)  *   - (0) on success.
5911edcf22c6SMin Hu (Connor)  *   - (-ENODEV) if *port_id* is invalid.
5912edcf22c6SMin Hu (Connor)  *   - (-EINVAL) if null file.
5913edcf22c6SMin Hu (Connor)  *   - (-ENOTSUP) if the device does not support this function.
5914edcf22c6SMin Hu (Connor)  *   - (-EIO) if device is removed.
5915edcf22c6SMin Hu (Connor)  */
5916edcf22c6SMin Hu (Connor) __rte_experimental
5917edcf22c6SMin Hu (Connor) int rte_eth_dev_priv_dump(uint16_t port_id, FILE *file);
5918a75ab6e5SAkhil Goyal 
5919092b701fSDongdong Liu /**
5920092b701fSDongdong Liu  * @warning
5921092b701fSDongdong Liu  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
5922092b701fSDongdong Liu  *
5923092b701fSDongdong Liu  * Dump ethdev Rx descriptor info to a file.
5924092b701fSDongdong Liu  *
5925092b701fSDongdong Liu  * This API is used for debugging, not a dataplane API.
5926092b701fSDongdong Liu  *
5927092b701fSDongdong Liu  * @param port_id
5928092b701fSDongdong Liu  *   The port identifier of the Ethernet device.
5929092b701fSDongdong Liu  * @param queue_id
5930092b701fSDongdong Liu  *   A Rx queue identifier on this port.
5931092b701fSDongdong Liu  * @param offset
5932092b701fSDongdong Liu  *  The offset of the descriptor starting from tail. (0 is the next
5933092b701fSDongdong Liu  *  packet to be received by the driver).
5934092b701fSDongdong Liu  * @param num
5935092b701fSDongdong Liu  *   The number of the descriptors to dump.
5936092b701fSDongdong Liu  * @param file
5937092b701fSDongdong Liu  *   A pointer to a file for output.
5938092b701fSDongdong Liu  * @return
5939092b701fSDongdong Liu  *   - On success, zero.
5940092b701fSDongdong Liu  *   - On failure, a negative value.
5941092b701fSDongdong Liu  */
5942092b701fSDongdong Liu __rte_experimental
5943092b701fSDongdong Liu int rte_eth_rx_descriptor_dump(uint16_t port_id, uint16_t queue_id,
5944092b701fSDongdong Liu 			       uint16_t offset, uint16_t num, FILE *file);
5945092b701fSDongdong Liu 
5946092b701fSDongdong Liu /**
5947092b701fSDongdong Liu  * @warning
5948092b701fSDongdong Liu  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
5949092b701fSDongdong Liu  *
5950092b701fSDongdong Liu  * Dump ethdev Tx descriptor info to a file.
5951092b701fSDongdong Liu  *
5952092b701fSDongdong Liu  * This API is used for debugging, not a dataplane API.
5953092b701fSDongdong Liu  *
5954092b701fSDongdong Liu  * @param port_id
5955092b701fSDongdong Liu  *   The port identifier of the Ethernet device.
5956092b701fSDongdong Liu  * @param queue_id
5957092b701fSDongdong Liu  *   A Tx queue identifier on this port.
5958092b701fSDongdong Liu  * @param offset
5959092b701fSDongdong Liu  *  The offset of the descriptor starting from tail. (0 is the place where
5960092b701fSDongdong Liu  *  the next packet will be send).
5961092b701fSDongdong Liu  * @param num
5962092b701fSDongdong Liu  *   The number of the descriptors to dump.
5963092b701fSDongdong Liu  * @param file
5964092b701fSDongdong Liu  *   A pointer to a file for output.
5965092b701fSDongdong Liu  * @return
5966092b701fSDongdong Liu  *   - On success, zero.
5967092b701fSDongdong Liu  *   - On failure, a negative value.
5968092b701fSDongdong Liu  */
5969092b701fSDongdong Liu __rte_experimental
5970092b701fSDongdong Liu int rte_eth_tx_descriptor_dump(uint16_t port_id, uint16_t queue_id,
5971092b701fSDongdong Liu 			       uint16_t offset, uint16_t num, FILE *file);
5972092b701fSDongdong Liu 
5973092b701fSDongdong Liu 
59746b81dddbSJerin Jacob /* Congestion management */
59756b81dddbSJerin Jacob 
59766b81dddbSJerin Jacob /** Enumerate list of ethdev congestion management objects */
59776b81dddbSJerin Jacob enum rte_eth_cman_obj {
59786b81dddbSJerin Jacob 	/** Congestion management based on Rx queue depth */
59796b81dddbSJerin Jacob 	RTE_ETH_CMAN_OBJ_RX_QUEUE = RTE_BIT32(0),
59806b81dddbSJerin Jacob 	/**
59816b81dddbSJerin Jacob 	 * Congestion management based on mempool depth associated with Rx queue
59826b81dddbSJerin Jacob 	 * @see rte_eth_rx_queue_setup()
59836b81dddbSJerin Jacob 	 */
59846b81dddbSJerin Jacob 	RTE_ETH_CMAN_OBJ_RX_QUEUE_MEMPOOL = RTE_BIT32(1),
59856b81dddbSJerin Jacob };
59866b81dddbSJerin Jacob 
59876b81dddbSJerin Jacob /**
59886b81dddbSJerin Jacob  * @warning
59896b81dddbSJerin Jacob  * @b EXPERIMENTAL: this structure may change, or be removed, without prior notice
59906b81dddbSJerin Jacob  *
59916b81dddbSJerin Jacob  * A structure used to retrieve information of ethdev congestion management.
59926b81dddbSJerin Jacob  */
59936b81dddbSJerin Jacob struct rte_eth_cman_info {
59946b81dddbSJerin Jacob 	/**
59956b81dddbSJerin Jacob 	 * Set of supported congestion management modes
59966b81dddbSJerin Jacob 	 * @see enum rte_cman_mode
59976b81dddbSJerin Jacob 	 */
59986b81dddbSJerin Jacob 	uint64_t modes_supported;
59996b81dddbSJerin Jacob 	/**
60006b81dddbSJerin Jacob 	 * Set of supported congestion management objects
60016b81dddbSJerin Jacob 	 * @see enum rte_eth_cman_obj
60026b81dddbSJerin Jacob 	 */
60036b81dddbSJerin Jacob 	uint64_t objs_supported;
60046b81dddbSJerin Jacob 	/**
60056b81dddbSJerin Jacob 	 * Reserved for future fields. Always returned as 0 when
60066b81dddbSJerin Jacob 	 * rte_eth_cman_info_get() is invoked
60076b81dddbSJerin Jacob 	 */
60086b81dddbSJerin Jacob 	uint8_t rsvd[8];
60096b81dddbSJerin Jacob };
60106b81dddbSJerin Jacob 
60116b81dddbSJerin Jacob /**
60126b81dddbSJerin Jacob  * @warning
60136b81dddbSJerin Jacob  * @b EXPERIMENTAL: this structure may change, or be removed, without prior notice
60146b81dddbSJerin Jacob  *
60156b81dddbSJerin Jacob  * A structure used to configure the ethdev congestion management.
60166b81dddbSJerin Jacob  */
60176b81dddbSJerin Jacob struct rte_eth_cman_config {
60186b81dddbSJerin Jacob 	/** Congestion management object */
60196b81dddbSJerin Jacob 	enum rte_eth_cman_obj obj;
60206b81dddbSJerin Jacob 	/** Congestion management mode */
60216b81dddbSJerin Jacob 	enum rte_cman_mode mode;
60226b81dddbSJerin Jacob 	union {
60236b81dddbSJerin Jacob 		/**
60246b81dddbSJerin Jacob 		 * Rx queue to configure congestion management.
60256b81dddbSJerin Jacob 		 *
60266b81dddbSJerin Jacob 		 * Valid when object is RTE_ETH_CMAN_OBJ_RX_QUEUE or
60276b81dddbSJerin Jacob 		 * RTE_ETH_CMAN_OBJ_RX_QUEUE_MEMPOOL.
60286b81dddbSJerin Jacob 		 */
60296b81dddbSJerin Jacob 		uint16_t rx_queue;
60306b81dddbSJerin Jacob 		/**
60316b81dddbSJerin Jacob 		 * Reserved for future fields.
60326b81dddbSJerin Jacob 		 * It must be set to 0 when rte_eth_cman_config_set() is invoked
60336b81dddbSJerin Jacob 		 * and will be returned as 0 when rte_eth_cman_config_get() is
60346b81dddbSJerin Jacob 		 * invoked.
60356b81dddbSJerin Jacob 		 */
60366b81dddbSJerin Jacob 		uint8_t rsvd_obj_params[4];
60376b81dddbSJerin Jacob 	} obj_param;
60386b81dddbSJerin Jacob 	union {
60396b81dddbSJerin Jacob 		/**
60406b81dddbSJerin Jacob 		 * RED configuration parameters.
60416b81dddbSJerin Jacob 		 *
60426b81dddbSJerin Jacob 		 * Valid when mode is RTE_CMAN_RED.
60436b81dddbSJerin Jacob 		 */
60446b81dddbSJerin Jacob 		struct rte_cman_red_params red;
60456b81dddbSJerin Jacob 		/**
60466b81dddbSJerin Jacob 		 * Reserved for future fields.
60476b81dddbSJerin Jacob 		 * It must be set to 0 when rte_eth_cman_config_set() is invoked
60486b81dddbSJerin Jacob 		 * and will be returned as 0 when rte_eth_cman_config_get() is
60496b81dddbSJerin Jacob 		 * invoked.
60506b81dddbSJerin Jacob 		 */
60516b81dddbSJerin Jacob 		uint8_t rsvd_mode_params[4];
60526b81dddbSJerin Jacob 	} mode_param;
60536b81dddbSJerin Jacob };
60546b81dddbSJerin Jacob 
60556b81dddbSJerin Jacob /**
60566b81dddbSJerin Jacob  * @warning
60576b81dddbSJerin Jacob  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
60586b81dddbSJerin Jacob  *
60596b81dddbSJerin Jacob  * Retrieve the information for ethdev congestion management
60606b81dddbSJerin Jacob  *
60616b81dddbSJerin Jacob  * @param port_id
60626b81dddbSJerin Jacob  *   The port identifier of the Ethernet device.
60636b81dddbSJerin Jacob  * @param info
60646b81dddbSJerin Jacob  *   A pointer to a structure of type *rte_eth_cman_info* to be filled with
60656b81dddbSJerin Jacob  *   the information about congestion management.
60666b81dddbSJerin Jacob  * @return
60676b81dddbSJerin Jacob  *   - (0) if successful.
60686b81dddbSJerin Jacob  *   - (-ENOTSUP) if support for cman_info_get does not exist.
60696b81dddbSJerin Jacob  *   - (-ENODEV) if *port_id* invalid.
60706b81dddbSJerin Jacob  *   - (-EINVAL) if bad parameter.
60716b81dddbSJerin Jacob  */
60726b81dddbSJerin Jacob __rte_experimental
60736b81dddbSJerin Jacob int rte_eth_cman_info_get(uint16_t port_id, struct rte_eth_cman_info *info);
60746b81dddbSJerin Jacob 
60756b81dddbSJerin Jacob /**
60766b81dddbSJerin Jacob  * @warning
60776b81dddbSJerin Jacob  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
60786b81dddbSJerin Jacob  *
60796b81dddbSJerin Jacob  * Initialize the ethdev congestion management configuration structure with default values.
60806b81dddbSJerin Jacob  *
60816b81dddbSJerin Jacob  * @param port_id
60826b81dddbSJerin Jacob  *   The port identifier of the Ethernet device.
60836b81dddbSJerin Jacob  * @param config
60846b81dddbSJerin Jacob  *   A pointer to a structure of type *rte_eth_cman_config* to be initialized
60856b81dddbSJerin Jacob  *   with default value.
60866b81dddbSJerin Jacob  * @return
60876b81dddbSJerin Jacob  *   - (0) if successful.
60886b81dddbSJerin Jacob  *   - (-ENOTSUP) if support for cman_config_init does not exist.
60896b81dddbSJerin Jacob  *   - (-ENODEV) if *port_id* invalid.
60906b81dddbSJerin Jacob  *   - (-EINVAL) if bad parameter.
60916b81dddbSJerin Jacob  */
60926b81dddbSJerin Jacob __rte_experimental
60936b81dddbSJerin Jacob int rte_eth_cman_config_init(uint16_t port_id, struct rte_eth_cman_config *config);
60946b81dddbSJerin Jacob 
60956b81dddbSJerin Jacob /**
60966b81dddbSJerin Jacob  * @warning
60976b81dddbSJerin Jacob  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
60986b81dddbSJerin Jacob  *
60996b81dddbSJerin Jacob  * Configure ethdev congestion management
61006b81dddbSJerin Jacob  *
61016b81dddbSJerin Jacob  * @param port_id
61026b81dddbSJerin Jacob  *   The port identifier of the Ethernet device.
61036b81dddbSJerin Jacob  * @param config
61046b81dddbSJerin Jacob  *   A pointer to a structure of type *rte_eth_cman_config* to be configured.
61056b81dddbSJerin Jacob  * @return
61066b81dddbSJerin Jacob  *   - (0) if successful.
61076b81dddbSJerin Jacob  *   - (-ENOTSUP) if support for cman_config_set does not exist.
61086b81dddbSJerin Jacob  *   - (-ENODEV) if *port_id* invalid.
61096b81dddbSJerin Jacob  *   - (-EINVAL) if bad parameter.
61106b81dddbSJerin Jacob  */
61116b81dddbSJerin Jacob __rte_experimental
61126b81dddbSJerin Jacob int rte_eth_cman_config_set(uint16_t port_id, const struct rte_eth_cman_config *config);
61136b81dddbSJerin Jacob 
61146b81dddbSJerin Jacob /**
61156b81dddbSJerin Jacob  * @warning
61166b81dddbSJerin Jacob  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
61176b81dddbSJerin Jacob  *
61186b81dddbSJerin Jacob  * Retrieve the applied ethdev congestion management parameters for the given port.
61196b81dddbSJerin Jacob  *
61206b81dddbSJerin Jacob  * @param port_id
61216b81dddbSJerin Jacob  *   The port identifier of the Ethernet device.
61226b81dddbSJerin Jacob  * @param config
61236b81dddbSJerin Jacob  *   A pointer to a structure of type *rte_eth_cman_config* to retrieve
61246b81dddbSJerin Jacob  *   congestion management parameters for the given object.
61256b81dddbSJerin Jacob  *   Application must fill all parameters except mode_param parameter in
61266b81dddbSJerin Jacob  *   struct rte_eth_cman_config.
61276b81dddbSJerin Jacob  *
61286b81dddbSJerin Jacob  * @return
61296b81dddbSJerin Jacob  *   - (0) if successful.
61306b81dddbSJerin Jacob  *   - (-ENOTSUP) if support for cman_config_get does not exist.
61316b81dddbSJerin Jacob  *   - (-ENODEV) if *port_id* invalid.
61326b81dddbSJerin Jacob  *   - (-EINVAL) if bad parameter.
61336b81dddbSJerin Jacob  */
61346b81dddbSJerin Jacob __rte_experimental
61356b81dddbSJerin Jacob int rte_eth_cman_config_get(uint16_t port_id, struct rte_eth_cman_config *config);
61366b81dddbSJerin Jacob 
613720387ebcSDavid Marchand #ifdef __cplusplus
613820387ebcSDavid Marchand }
613920387ebcSDavid Marchand #endif
614020387ebcSDavid Marchand 
614199a2dd95SBruce Richardson #include <rte_ethdev_core.h>
614299a2dd95SBruce Richardson 
6143719834a6SMattias Rönnblom #ifdef __cplusplus
6144719834a6SMattias Rönnblom extern "C" {
6145719834a6SMattias Rönnblom #endif
6146719834a6SMattias Rönnblom 
614799a2dd95SBruce Richardson /**
61487a093523SKonstantin Ananyev  * @internal
61497a093523SKonstantin Ananyev  * Helper routine for rte_eth_rx_burst().
61507a093523SKonstantin Ananyev  * Should be called at exit from PMD's rte_eth_rx_bulk implementation.
61517a093523SKonstantin Ananyev  * Does necessary post-processing - invokes Rx callbacks if any, etc.
61527a093523SKonstantin Ananyev  *
61537a093523SKonstantin Ananyev  * @param port_id
61547a093523SKonstantin Ananyev  *  The port identifier of the Ethernet device.
61557a093523SKonstantin Ananyev  * @param queue_id
61567a093523SKonstantin Ananyev  *  The index of the receive queue from which to retrieve input packets.
61577a093523SKonstantin Ananyev  * @param rx_pkts
61587a093523SKonstantin Ananyev  *   The address of an array of pointers to *rte_mbuf* structures that
61597a093523SKonstantin Ananyev  *   have been retrieved from the device.
61607a093523SKonstantin Ananyev  * @param nb_rx
61617a093523SKonstantin Ananyev  *   The number of packets that were retrieved from the device.
61627a093523SKonstantin Ananyev  * @param nb_pkts
61637a093523SKonstantin Ananyev  *   The number of elements in @p rx_pkts array.
61647a093523SKonstantin Ananyev  * @param opaque
61657a093523SKonstantin Ananyev  *   Opaque pointer of Rx queue callback related data.
61667a093523SKonstantin Ananyev  *
61677a093523SKonstantin Ananyev  * @return
61687a093523SKonstantin Ananyev  *  The number of packets effectively supplied to the @p rx_pkts array.
61697a093523SKonstantin Ananyev  */
61707a093523SKonstantin Ananyev uint16_t rte_eth_call_rx_callbacks(uint16_t port_id, uint16_t queue_id,
61717a093523SKonstantin Ananyev 		struct rte_mbuf **rx_pkts, uint16_t nb_rx, uint16_t nb_pkts,
61727a093523SKonstantin Ananyev 		void *opaque);
61737a093523SKonstantin Ananyev 
61747a093523SKonstantin Ananyev /**
617599a2dd95SBruce Richardson  *
617699a2dd95SBruce Richardson  * Retrieve a burst of input packets from a receive queue of an Ethernet
617799a2dd95SBruce Richardson  * device. The retrieved packets are stored in *rte_mbuf* structures whose
617899a2dd95SBruce Richardson  * pointers are supplied in the *rx_pkts* array.
617999a2dd95SBruce Richardson  *
618009fd4227SAndrew Rybchenko  * The rte_eth_rx_burst() function loops, parsing the Rx ring of the
618109fd4227SAndrew Rybchenko  * receive queue, up to *nb_pkts* packets, and for each completed Rx
618299a2dd95SBruce Richardson  * descriptor in the ring, it performs the following operations:
618399a2dd95SBruce Richardson  *
618499a2dd95SBruce Richardson  * - Initialize the *rte_mbuf* data structure associated with the
618509fd4227SAndrew Rybchenko  *   Rx descriptor according to the information provided by the NIC into
618609fd4227SAndrew Rybchenko  *   that Rx descriptor.
618799a2dd95SBruce Richardson  *
618899a2dd95SBruce Richardson  * - Store the *rte_mbuf* data structure into the next entry of the
618999a2dd95SBruce Richardson  *   *rx_pkts* array.
619099a2dd95SBruce Richardson  *
619109fd4227SAndrew Rybchenko  * - Replenish the Rx descriptor with a new *rte_mbuf* buffer
619299a2dd95SBruce Richardson  *   allocated from the memory pool associated with the receive queue at
619399a2dd95SBruce Richardson  *   initialization time.
619499a2dd95SBruce Richardson  *
619599a2dd95SBruce Richardson  * When retrieving an input packet that was scattered by the controller
619699a2dd95SBruce Richardson  * into multiple receive descriptors, the rte_eth_rx_burst() function
619799a2dd95SBruce Richardson  * appends the associated *rte_mbuf* buffers to the first buffer of the
619899a2dd95SBruce Richardson  * packet.
619999a2dd95SBruce Richardson  *
620099a2dd95SBruce Richardson  * The rte_eth_rx_burst() function returns the number of packets
620199a2dd95SBruce Richardson  * actually retrieved, which is the number of *rte_mbuf* data structures
620299a2dd95SBruce Richardson  * effectively supplied into the *rx_pkts* array.
620309fd4227SAndrew Rybchenko  * A return value equal to *nb_pkts* indicates that the Rx queue contained
620499a2dd95SBruce Richardson  * at least *rx_pkts* packets, and this is likely to signify that other
620599a2dd95SBruce Richardson  * received packets remain in the input queue. Applications implementing
620699a2dd95SBruce Richardson  * a "retrieve as much received packets as possible" policy can check this
620799a2dd95SBruce Richardson  * specific case and keep invoking the rte_eth_rx_burst() function until
620899a2dd95SBruce Richardson  * a value less than *nb_pkts* is returned.
620999a2dd95SBruce Richardson  *
621099a2dd95SBruce Richardson  * This receive method has the following advantages:
621199a2dd95SBruce Richardson  *
621299a2dd95SBruce Richardson  * - It allows a run-to-completion network stack engine to retrieve and
621399a2dd95SBruce Richardson  *   to immediately process received packets in a fast burst-oriented
621499a2dd95SBruce Richardson  *   approach, avoiding the overhead of unnecessary intermediate packet
621599a2dd95SBruce Richardson  *   queue/dequeue operations.
621699a2dd95SBruce Richardson  *
621799a2dd95SBruce Richardson  * - Conversely, it also allows an asynchronous-oriented processing
621899a2dd95SBruce Richardson  *   method to retrieve bursts of received packets and to immediately
621999a2dd95SBruce Richardson  *   queue them for further parallel processing by another logical core,
622099a2dd95SBruce Richardson  *   for instance. However, instead of having received packets being
622199a2dd95SBruce Richardson  *   individually queued by the driver, this approach allows the caller
622299a2dd95SBruce Richardson  *   of the rte_eth_rx_burst() function to queue a burst of retrieved
622399a2dd95SBruce Richardson  *   packets at a time and therefore dramatically reduce the cost of
622499a2dd95SBruce Richardson  *   enqueue/dequeue operations per packet.
622599a2dd95SBruce Richardson  *
622699a2dd95SBruce Richardson  * - It allows the rte_eth_rx_burst() function of the driver to take
622799a2dd95SBruce Richardson  *   advantage of burst-oriented hardware features (CPU cache,
622899a2dd95SBruce Richardson  *   prefetch instructions, and so on) to minimize the number of CPU
622999a2dd95SBruce Richardson  *   cycles per packet.
623099a2dd95SBruce Richardson  *
623199a2dd95SBruce Richardson  * To summarize, the proposed receive API enables many
623299a2dd95SBruce Richardson  * burst-oriented optimizations in both synchronous and asynchronous
623399a2dd95SBruce Richardson  * packet processing environments with no overhead in both cases.
623499a2dd95SBruce Richardson  *
623599a2dd95SBruce Richardson  * @note
623699a2dd95SBruce Richardson  *   Some drivers using vector instructions require that *nb_pkts* is
623799a2dd95SBruce Richardson  *   divisible by 4 or 8, depending on the driver implementation.
623899a2dd95SBruce Richardson  *
623999a2dd95SBruce Richardson  * The rte_eth_rx_burst() function does not provide any error
624099a2dd95SBruce Richardson  * notification to avoid the corresponding overhead. As a hint, the
624199a2dd95SBruce Richardson  * upper-level application might check the status of the device link once
624299a2dd95SBruce Richardson  * being systematically returned a 0 value for a given number of tries.
624399a2dd95SBruce Richardson  *
624499a2dd95SBruce Richardson  * @param port_id
624599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
624699a2dd95SBruce Richardson  * @param queue_id
624799a2dd95SBruce Richardson  *   The index of the receive queue from which to retrieve input packets.
624899a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
624999a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
625099a2dd95SBruce Richardson  * @param rx_pkts
625199a2dd95SBruce Richardson  *   The address of an array of pointers to *rte_mbuf* structures that
625299a2dd95SBruce Richardson  *   must be large enough to store *nb_pkts* pointers in it.
625399a2dd95SBruce Richardson  * @param nb_pkts
625499a2dd95SBruce Richardson  *   The maximum number of packets to retrieve.
625599a2dd95SBruce Richardson  *   The value must be divisible by 8 in order to work with any driver.
625699a2dd95SBruce Richardson  * @return
625799a2dd95SBruce Richardson  *   The number of packets actually retrieved, which is the number
625899a2dd95SBruce Richardson  *   of pointers to *rte_mbuf* structures effectively supplied to the
625999a2dd95SBruce Richardson  *   *rx_pkts* array.
626099a2dd95SBruce Richardson  */
626199a2dd95SBruce Richardson static inline uint16_t
626299a2dd95SBruce Richardson rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id,
626399a2dd95SBruce Richardson 		 struct rte_mbuf **rx_pkts, const uint16_t nb_pkts)
626499a2dd95SBruce Richardson {
626599a2dd95SBruce Richardson 	uint16_t nb_rx;
62667a093523SKonstantin Ananyev 	struct rte_eth_fp_ops *p;
62677a093523SKonstantin Ananyev 	void *qd;
626899a2dd95SBruce Richardson 
626999a2dd95SBruce Richardson #ifdef RTE_ETHDEV_DEBUG_RX
62707a093523SKonstantin Ananyev 	if (port_id >= RTE_MAX_ETHPORTS ||
62717a093523SKonstantin Ananyev 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
62720e21c7c0SDavid Marchand 		RTE_ETHDEV_LOG_LINE(ERR,
62730e21c7c0SDavid Marchand 			"Invalid port_id=%u or queue_id=%u",
62747a093523SKonstantin Ananyev 			port_id, queue_id);
627599a2dd95SBruce Richardson 		return 0;
627699a2dd95SBruce Richardson 	}
627799a2dd95SBruce Richardson #endif
62787a093523SKonstantin Ananyev 
62797a093523SKonstantin Ananyev 	/* fetch pointer to queue data */
62807a093523SKonstantin Ananyev 	p = &rte_eth_fp_ops[port_id];
62817a093523SKonstantin Ananyev 	qd = p->rxq.data[queue_id];
62827a093523SKonstantin Ananyev 
62837a093523SKonstantin Ananyev #ifdef RTE_ETHDEV_DEBUG_RX
62847a093523SKonstantin Ananyev 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
62857a093523SKonstantin Ananyev 
62867a093523SKonstantin Ananyev 	if (qd == NULL) {
62870e21c7c0SDavid Marchand 		RTE_ETHDEV_LOG_LINE(ERR, "Invalid Rx queue_id=%u for port_id=%u",
62887a093523SKonstantin Ananyev 			queue_id, port_id);
62897a093523SKonstantin Ananyev 		return 0;
62907a093523SKonstantin Ananyev 	}
62917a093523SKonstantin Ananyev #endif
62927a093523SKonstantin Ananyev 
62937a093523SKonstantin Ananyev 	nb_rx = p->rx_pkt_burst(qd, rx_pkts, nb_pkts);
629499a2dd95SBruce Richardson 
629599a2dd95SBruce Richardson #ifdef RTE_ETHDEV_RXTX_CALLBACKS
62967a093523SKonstantin Ananyev 	{
62977a093523SKonstantin Ananyev 		void *cb;
629899a2dd95SBruce Richardson 
6299f7053f01STyler Retzlaff 		/* rte_memory_order_release memory order was used when the
630099a2dd95SBruce Richardson 		 * call back was inserted into the list.
630199a2dd95SBruce Richardson 		 * Since there is a clear dependency between loading
6302f7053f01STyler Retzlaff 		 * cb and cb->fn/cb->next, rte_memory_order_acquire memory order is
630399a2dd95SBruce Richardson 		 * not required.
630499a2dd95SBruce Richardson 		 */
6305f7053f01STyler Retzlaff 		cb = rte_atomic_load_explicit(&p->rxq.clbk[queue_id],
6306f7053f01STyler Retzlaff 				rte_memory_order_relaxed);
63077a093523SKonstantin Ananyev 		if (unlikely(cb != NULL))
63087a093523SKonstantin Ananyev 			nb_rx = rte_eth_call_rx_callbacks(port_id, queue_id,
63097a093523SKonstantin Ananyev 					rx_pkts, nb_rx, nb_pkts, cb);
631099a2dd95SBruce Richardson 	}
631199a2dd95SBruce Richardson #endif
631299a2dd95SBruce Richardson 
6313e075ca1dSAdel Belkhiri 	if (unlikely(nb_rx))
6314e075ca1dSAdel Belkhiri 		rte_ethdev_trace_rx_burst_nonempty(port_id, queue_id, (void **)rx_pkts, nb_rx);
6315e075ca1dSAdel Belkhiri 	else
6316e075ca1dSAdel Belkhiri 		rte_ethdev_trace_rx_burst_empty(port_id, queue_id, (void **)rx_pkts);
631799a2dd95SBruce Richardson 	return nb_rx;
631899a2dd95SBruce Richardson }
631999a2dd95SBruce Richardson 
632099a2dd95SBruce Richardson /**
632109fd4227SAndrew Rybchenko  * Get the number of used descriptors of a Rx queue
632299a2dd95SBruce Richardson  *
63233f9acb5cSMorten Brørup  * Since it's a dataplane function, no check is performed on port_id and
63243f9acb5cSMorten Brørup  * queue_id. The caller must therefore ensure that the port is enabled
63253f9acb5cSMorten Brørup  * and the queue is configured and running.
63263f9acb5cSMorten Brørup  *
632799a2dd95SBruce Richardson  * @param port_id
632899a2dd95SBruce Richardson  *  The port identifier of the Ethernet device.
632999a2dd95SBruce Richardson  * @param queue_id
63305906be5aSAndrew Rybchenko  *  The queue ID on the specific port.
633199a2dd95SBruce Richardson  * @return
633299a2dd95SBruce Richardson  *  The number of used descriptors in the specific queue, or:
633399a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
63343f9acb5cSMorten Brørup  *   - (-EINVAL) if *queue_id* is invalid
63353f9acb5cSMorten Brørup  *   - (-ENOTSUP) if the device does not support this function
633699a2dd95SBruce Richardson  */
633799a2dd95SBruce Richardson static inline int
633899a2dd95SBruce Richardson rte_eth_rx_queue_count(uint16_t port_id, uint16_t queue_id)
633999a2dd95SBruce Richardson {
63407a093523SKonstantin Ananyev 	struct rte_eth_fp_ops *p;
63417a093523SKonstantin Ananyev 	void *qd;
63427a093523SKonstantin Ananyev 
63433f9acb5cSMorten Brørup #ifdef RTE_ETHDEV_DEBUG_RX
63447a093523SKonstantin Ananyev 	if (port_id >= RTE_MAX_ETHPORTS ||
63457a093523SKonstantin Ananyev 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
63460e21c7c0SDavid Marchand 		RTE_ETHDEV_LOG_LINE(ERR,
63470e21c7c0SDavid Marchand 			"Invalid port_id=%u or queue_id=%u",
63487a093523SKonstantin Ananyev 			port_id, queue_id);
63497a093523SKonstantin Ananyev 		return -EINVAL;
63507a093523SKonstantin Ananyev 	}
63513f9acb5cSMorten Brørup #endif
63527a093523SKonstantin Ananyev 
63537a093523SKonstantin Ananyev 	/* fetch pointer to queue data */
63547a093523SKonstantin Ananyev 	p = &rte_eth_fp_ops[port_id];
63557a093523SKonstantin Ananyev 	qd = p->rxq.data[queue_id];
635699a2dd95SBruce Richardson 
63573f9acb5cSMorten Brørup #ifdef RTE_ETHDEV_DEBUG_RX
635899a2dd95SBruce Richardson 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
63597a093523SKonstantin Ananyev 	if (qd == NULL)
636099a2dd95SBruce Richardson 		return -EINVAL;
63613f9acb5cSMorten Brørup #endif
636299a2dd95SBruce Richardson 
63633f9acb5cSMorten Brørup 	if (*p->rx_queue_count == NULL)
63643f9acb5cSMorten Brørup 		return -ENOTSUP;
63657a093523SKonstantin Ananyev 	return (int)(*p->rx_queue_count)(qd);
636699a2dd95SBruce Richardson }
636799a2dd95SBruce Richardson 
63680ce56b05SThomas Monjalon /**@{@name Rx hardware descriptor states
63690ce56b05SThomas Monjalon  * @see rte_eth_rx_descriptor_status
63700ce56b05SThomas Monjalon  */
637199a2dd95SBruce Richardson #define RTE_ETH_RX_DESC_AVAIL    0 /**< Desc available for hw. */
637299a2dd95SBruce Richardson #define RTE_ETH_RX_DESC_DONE     1 /**< Desc done, filled by hw. */
637399a2dd95SBruce Richardson #define RTE_ETH_RX_DESC_UNAVAIL  2 /**< Desc used by driver or hw. */
63740ce56b05SThomas Monjalon /**@}*/
637599a2dd95SBruce Richardson 
637699a2dd95SBruce Richardson /**
637799a2dd95SBruce Richardson  * Check the status of a Rx descriptor in the queue
637899a2dd95SBruce Richardson  *
637999a2dd95SBruce Richardson  * It should be called in a similar context than the Rx function:
638099a2dd95SBruce Richardson  * - on a dataplane core
638199a2dd95SBruce Richardson  * - not concurrently on the same queue
638299a2dd95SBruce Richardson  *
638399a2dd95SBruce Richardson  * Since it's a dataplane function, no check is performed on port_id and
638499a2dd95SBruce Richardson  * queue_id. The caller must therefore ensure that the port is enabled
638599a2dd95SBruce Richardson  * and the queue is configured and running.
638699a2dd95SBruce Richardson  *
638799a2dd95SBruce Richardson  * Note: accessing to a random descriptor in the ring may trigger cache
638899a2dd95SBruce Richardson  * misses and have a performance impact.
638999a2dd95SBruce Richardson  *
639099a2dd95SBruce Richardson  * @param port_id
639199a2dd95SBruce Richardson  *  A valid port identifier of the Ethernet device which.
639299a2dd95SBruce Richardson  * @param queue_id
639399a2dd95SBruce Richardson  *  A valid Rx queue identifier on this port.
639499a2dd95SBruce Richardson  * @param offset
639599a2dd95SBruce Richardson  *  The offset of the descriptor starting from tail (0 is the next
639699a2dd95SBruce Richardson  *  packet to be received by the driver).
639799a2dd95SBruce Richardson  *
639899a2dd95SBruce Richardson  * @return
639999a2dd95SBruce Richardson  *  - (RTE_ETH_RX_DESC_AVAIL): Descriptor is available for the hardware to
640099a2dd95SBruce Richardson  *    receive a packet.
640199a2dd95SBruce Richardson  *  - (RTE_ETH_RX_DESC_DONE): Descriptor is done, it is filled by hw, but
640299a2dd95SBruce Richardson  *    not yet processed by the driver (i.e. in the receive queue).
640399a2dd95SBruce Richardson  *  - (RTE_ETH_RX_DESC_UNAVAIL): Descriptor is unavailable, either hold by
640499a2dd95SBruce Richardson  *    the driver and not yet returned to hw, or reserved by the hw.
640599a2dd95SBruce Richardson  *  - (-EINVAL) bad descriptor offset.
640699a2dd95SBruce Richardson  *  - (-ENOTSUP) if the device does not support this function.
640799a2dd95SBruce Richardson  *  - (-ENODEV) bad port or queue (only if compiled with debug).
640899a2dd95SBruce Richardson  */
640999a2dd95SBruce Richardson static inline int
641099a2dd95SBruce Richardson rte_eth_rx_descriptor_status(uint16_t port_id, uint16_t queue_id,
641199a2dd95SBruce Richardson 	uint16_t offset)
641299a2dd95SBruce Richardson {
64137a093523SKonstantin Ananyev 	struct rte_eth_fp_ops *p;
64147a093523SKonstantin Ananyev 	void *qd;
64157a093523SKonstantin Ananyev 
64167a093523SKonstantin Ananyev #ifdef RTE_ETHDEV_DEBUG_RX
64177a093523SKonstantin Ananyev 	if (port_id >= RTE_MAX_ETHPORTS ||
64187a093523SKonstantin Ananyev 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
64190e21c7c0SDavid Marchand 		RTE_ETHDEV_LOG_LINE(ERR,
64200e21c7c0SDavid Marchand 			"Invalid port_id=%u or queue_id=%u",
64217a093523SKonstantin Ananyev 			port_id, queue_id);
64227a093523SKonstantin Ananyev 		return -EINVAL;
64237a093523SKonstantin Ananyev 	}
64247a093523SKonstantin Ananyev #endif
64257a093523SKonstantin Ananyev 
64267a093523SKonstantin Ananyev 	/* fetch pointer to queue data */
64277a093523SKonstantin Ananyev 	p = &rte_eth_fp_ops[port_id];
64287a093523SKonstantin Ananyev 	qd = p->rxq.data[queue_id];
642999a2dd95SBruce Richardson 
643099a2dd95SBruce Richardson #ifdef RTE_ETHDEV_DEBUG_RX
643199a2dd95SBruce Richardson 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
64327a093523SKonstantin Ananyev 	if (qd == NULL)
643399a2dd95SBruce Richardson 		return -ENODEV;
643499a2dd95SBruce Richardson #endif
64358f1d23ecSDavid Marchand 	if (*p->rx_descriptor_status == NULL)
64368f1d23ecSDavid Marchand 		return -ENOTSUP;
64377a093523SKonstantin Ananyev 	return (*p->rx_descriptor_status)(qd, offset);
643899a2dd95SBruce Richardson }
643999a2dd95SBruce Richardson 
64400ce56b05SThomas Monjalon /**@{@name Tx hardware descriptor states
64410ce56b05SThomas Monjalon  * @see rte_eth_tx_descriptor_status
64420ce56b05SThomas Monjalon  */
644399a2dd95SBruce Richardson #define RTE_ETH_TX_DESC_FULL    0 /**< Desc filled for hw, waiting xmit. */
644499a2dd95SBruce Richardson #define RTE_ETH_TX_DESC_DONE    1 /**< Desc done, packet is transmitted. */
644599a2dd95SBruce Richardson #define RTE_ETH_TX_DESC_UNAVAIL 2 /**< Desc used by driver or hw. */
64460ce56b05SThomas Monjalon /**@}*/
644799a2dd95SBruce Richardson 
644899a2dd95SBruce Richardson /**
644999a2dd95SBruce Richardson  * Check the status of a Tx descriptor in the queue.
645099a2dd95SBruce Richardson  *
645199a2dd95SBruce Richardson  * It should be called in a similar context than the Tx function:
645299a2dd95SBruce Richardson  * - on a dataplane core
645399a2dd95SBruce Richardson  * - not concurrently on the same queue
645499a2dd95SBruce Richardson  *
645599a2dd95SBruce Richardson  * Since it's a dataplane function, no check is performed on port_id and
645699a2dd95SBruce Richardson  * queue_id. The caller must therefore ensure that the port is enabled
645799a2dd95SBruce Richardson  * and the queue is configured and running.
645899a2dd95SBruce Richardson  *
645999a2dd95SBruce Richardson  * Note: accessing to a random descriptor in the ring may trigger cache
646099a2dd95SBruce Richardson  * misses and have a performance impact.
646199a2dd95SBruce Richardson  *
646299a2dd95SBruce Richardson  * @param port_id
646399a2dd95SBruce Richardson  *  A valid port identifier of the Ethernet device which.
646499a2dd95SBruce Richardson  * @param queue_id
646599a2dd95SBruce Richardson  *  A valid Tx queue identifier on this port.
646699a2dd95SBruce Richardson  * @param offset
646799a2dd95SBruce Richardson  *  The offset of the descriptor starting from tail (0 is the place where
646899a2dd95SBruce Richardson  *  the next packet will be send).
646999a2dd95SBruce Richardson  *
647099a2dd95SBruce Richardson  * @return
647199a2dd95SBruce Richardson  *  - (RTE_ETH_TX_DESC_FULL) Descriptor is being processed by the hw, i.e.
647299a2dd95SBruce Richardson  *    in the transmit queue.
647399a2dd95SBruce Richardson  *  - (RTE_ETH_TX_DESC_DONE) Hardware is done with this descriptor, it can
647499a2dd95SBruce Richardson  *    be reused by the driver.
647599a2dd95SBruce Richardson  *  - (RTE_ETH_TX_DESC_UNAVAIL): Descriptor is unavailable, reserved by the
647699a2dd95SBruce Richardson  *    driver or the hardware.
647799a2dd95SBruce Richardson  *  - (-EINVAL) bad descriptor offset.
647899a2dd95SBruce Richardson  *  - (-ENOTSUP) if the device does not support this function.
647999a2dd95SBruce Richardson  *  - (-ENODEV) bad port or queue (only if compiled with debug).
648099a2dd95SBruce Richardson  */
648199a2dd95SBruce Richardson static inline int rte_eth_tx_descriptor_status(uint16_t port_id,
648299a2dd95SBruce Richardson 	uint16_t queue_id, uint16_t offset)
648399a2dd95SBruce Richardson {
64847a093523SKonstantin Ananyev 	struct rte_eth_fp_ops *p;
64857a093523SKonstantin Ananyev 	void *qd;
64867a093523SKonstantin Ananyev 
64877a093523SKonstantin Ananyev #ifdef RTE_ETHDEV_DEBUG_TX
64887a093523SKonstantin Ananyev 	if (port_id >= RTE_MAX_ETHPORTS ||
64897a093523SKonstantin Ananyev 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
64900e21c7c0SDavid Marchand 		RTE_ETHDEV_LOG_LINE(ERR,
64910e21c7c0SDavid Marchand 			"Invalid port_id=%u or queue_id=%u",
64927a093523SKonstantin Ananyev 			port_id, queue_id);
64937a093523SKonstantin Ananyev 		return -EINVAL;
64947a093523SKonstantin Ananyev 	}
64957a093523SKonstantin Ananyev #endif
64967a093523SKonstantin Ananyev 
64977a093523SKonstantin Ananyev 	/* fetch pointer to queue data */
64987a093523SKonstantin Ananyev 	p = &rte_eth_fp_ops[port_id];
64997a093523SKonstantin Ananyev 	qd = p->txq.data[queue_id];
650099a2dd95SBruce Richardson 
650199a2dd95SBruce Richardson #ifdef RTE_ETHDEV_DEBUG_TX
650299a2dd95SBruce Richardson 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
65037a093523SKonstantin Ananyev 	if (qd == NULL)
650499a2dd95SBruce Richardson 		return -ENODEV;
650599a2dd95SBruce Richardson #endif
65068f1d23ecSDavid Marchand 	if (*p->tx_descriptor_status == NULL)
65078f1d23ecSDavid Marchand 		return -ENOTSUP;
65087a093523SKonstantin Ananyev 	return (*p->tx_descriptor_status)(qd, offset);
650999a2dd95SBruce Richardson }
651099a2dd95SBruce Richardson 
651199a2dd95SBruce Richardson /**
65127a093523SKonstantin Ananyev  * @internal
65137a093523SKonstantin Ananyev  * Helper routine for rte_eth_tx_burst().
65147a093523SKonstantin Ananyev  * Should be called before entry PMD's rte_eth_tx_bulk implementation.
65157a093523SKonstantin Ananyev  * Does necessary pre-processing - invokes Tx callbacks if any, etc.
65167a093523SKonstantin Ananyev  *
65177a093523SKonstantin Ananyev  * @param port_id
65187a093523SKonstantin Ananyev  *   The port identifier of the Ethernet device.
65197a093523SKonstantin Ananyev  * @param queue_id
65207a093523SKonstantin Ananyev  *   The index of the transmit queue through which output packets must be
65217a093523SKonstantin Ananyev  *   sent.
65227a093523SKonstantin Ananyev  * @param tx_pkts
65237a093523SKonstantin Ananyev  *   The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
65247a093523SKonstantin Ananyev  *   which contain the output packets.
65257a093523SKonstantin Ananyev  * @param nb_pkts
65267a093523SKonstantin Ananyev  *   The maximum number of packets to transmit.
65277a093523SKonstantin Ananyev  * @return
65287a093523SKonstantin Ananyev  *   The number of output packets to transmit.
65297a093523SKonstantin Ananyev  */
65307a093523SKonstantin Ananyev uint16_t rte_eth_call_tx_callbacks(uint16_t port_id, uint16_t queue_id,
65317a093523SKonstantin Ananyev 	struct rte_mbuf **tx_pkts, uint16_t nb_pkts, void *opaque);
65327a093523SKonstantin Ananyev 
65337a093523SKonstantin Ananyev /**
653499a2dd95SBruce Richardson  * Send a burst of output packets on a transmit queue of an Ethernet device.
653599a2dd95SBruce Richardson  *
653699a2dd95SBruce Richardson  * The rte_eth_tx_burst() function is invoked to transmit output packets
653799a2dd95SBruce Richardson  * on the output queue *queue_id* of the Ethernet device designated by its
653899a2dd95SBruce Richardson  * *port_id*.
653999a2dd95SBruce Richardson  * The *nb_pkts* parameter is the number of packets to send which are
654099a2dd95SBruce Richardson  * supplied in the *tx_pkts* array of *rte_mbuf* structures, each of them
654199a2dd95SBruce Richardson  * allocated from a pool created with rte_pktmbuf_pool_create().
654299a2dd95SBruce Richardson  * The rte_eth_tx_burst() function loops, sending *nb_pkts* packets,
654309fd4227SAndrew Rybchenko  * up to the number of transmit descriptors available in the Tx ring of the
654499a2dd95SBruce Richardson  * transmit queue.
654599a2dd95SBruce Richardson  * For each packet to send, the rte_eth_tx_burst() function performs
654699a2dd95SBruce Richardson  * the following operations:
654799a2dd95SBruce Richardson  *
654899a2dd95SBruce Richardson  * - Pick up the next available descriptor in the transmit ring.
654999a2dd95SBruce Richardson  *
655099a2dd95SBruce Richardson  * - Free the network buffer previously sent with that descriptor, if any.
655199a2dd95SBruce Richardson  *
655299a2dd95SBruce Richardson  * - Initialize the transmit descriptor with the information provided
655399a2dd95SBruce Richardson  *   in the *rte_mbuf data structure.
655499a2dd95SBruce Richardson  *
655599a2dd95SBruce Richardson  * In the case of a segmented packet composed of a list of *rte_mbuf* buffers,
655699a2dd95SBruce Richardson  * the rte_eth_tx_burst() function uses several transmit descriptors
655799a2dd95SBruce Richardson  * of the ring.
655899a2dd95SBruce Richardson  *
655999a2dd95SBruce Richardson  * The rte_eth_tx_burst() function returns the number of packets it
656099a2dd95SBruce Richardson  * actually sent. A return value equal to *nb_pkts* means that all packets
656199a2dd95SBruce Richardson  * have been sent, and this is likely to signify that other output packets
656299a2dd95SBruce Richardson  * could be immediately transmitted again. Applications that implement a
656399a2dd95SBruce Richardson  * "send as many packets to transmit as possible" policy can check this
656499a2dd95SBruce Richardson  * specific case and keep invoking the rte_eth_tx_burst() function until
656599a2dd95SBruce Richardson  * a value less than *nb_pkts* is returned.
656699a2dd95SBruce Richardson  *
656799a2dd95SBruce Richardson  * It is the responsibility of the rte_eth_tx_burst() function to
656899a2dd95SBruce Richardson  * transparently free the memory buffers of packets previously sent.
656999a2dd95SBruce Richardson  * This feature is driven by the *tx_free_thresh* value supplied to the
657099a2dd95SBruce Richardson  * rte_eth_dev_configure() function at device configuration time.
657109fd4227SAndrew Rybchenko  * When the number of free Tx descriptors drops below this threshold, the
657299a2dd95SBruce Richardson  * rte_eth_tx_burst() function must [attempt to] free the *rte_mbuf*  buffers
657399a2dd95SBruce Richardson  * of those packets whose transmission was effectively completed.
657499a2dd95SBruce Richardson  *
6575295968d1SFerruh Yigit  * If the PMD is RTE_ETH_TX_OFFLOAD_MT_LOCKFREE capable, multiple threads can
657609fd4227SAndrew Rybchenko  * invoke this function concurrently on the same Tx queue without SW lock.
657799a2dd95SBruce Richardson  * @see rte_eth_dev_info_get, struct rte_eth_txconf::offloads
657899a2dd95SBruce Richardson  *
657999a2dd95SBruce Richardson  * @see rte_eth_tx_prepare to perform some prior checks or adjustments
658099a2dd95SBruce Richardson  * for offloads.
658199a2dd95SBruce Richardson  *
6582c622735dSChengwen Feng  * @note This function must not modify mbufs (including packets data)
6583c622735dSChengwen Feng  * unless the refcnt is 1.
6584c622735dSChengwen Feng  * An exception is the bonding PMD, which does not have "Tx prepare" support,
6585c622735dSChengwen Feng  * in this case, mbufs may be modified.
6586c622735dSChengwen Feng  *
658799a2dd95SBruce Richardson  * @param port_id
658899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
658999a2dd95SBruce Richardson  * @param queue_id
659099a2dd95SBruce Richardson  *   The index of the transmit queue through which output packets must be
659199a2dd95SBruce Richardson  *   sent.
659299a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
659399a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
659499a2dd95SBruce Richardson  * @param tx_pkts
659599a2dd95SBruce Richardson  *   The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
659699a2dd95SBruce Richardson  *   which contain the output packets.
659799a2dd95SBruce Richardson  * @param nb_pkts
659899a2dd95SBruce Richardson  *   The maximum number of packets to transmit.
659999a2dd95SBruce Richardson  * @return
660099a2dd95SBruce Richardson  *   The number of output packets actually stored in transmit descriptors of
660199a2dd95SBruce Richardson  *   the transmit ring. The return value can be less than the value of the
660299a2dd95SBruce Richardson  *   *tx_pkts* parameter when the transmit ring is full or has been filled up.
660399a2dd95SBruce Richardson  */
660499a2dd95SBruce Richardson static inline uint16_t
660599a2dd95SBruce Richardson rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
660699a2dd95SBruce Richardson 		 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
660799a2dd95SBruce Richardson {
66087a093523SKonstantin Ananyev 	struct rte_eth_fp_ops *p;
66097a093523SKonstantin Ananyev 	void *qd;
66107a093523SKonstantin Ananyev 
66117a093523SKonstantin Ananyev #ifdef RTE_ETHDEV_DEBUG_TX
66127a093523SKonstantin Ananyev 	if (port_id >= RTE_MAX_ETHPORTS ||
66137a093523SKonstantin Ananyev 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
66140e21c7c0SDavid Marchand 		RTE_ETHDEV_LOG_LINE(ERR,
66150e21c7c0SDavid Marchand 			"Invalid port_id=%u or queue_id=%u",
66167a093523SKonstantin Ananyev 			port_id, queue_id);
66177a093523SKonstantin Ananyev 		return 0;
66187a093523SKonstantin Ananyev 	}
66197a093523SKonstantin Ananyev #endif
66207a093523SKonstantin Ananyev 
66217a093523SKonstantin Ananyev 	/* fetch pointer to queue data */
66227a093523SKonstantin Ananyev 	p = &rte_eth_fp_ops[port_id];
66237a093523SKonstantin Ananyev 	qd = p->txq.data[queue_id];
662499a2dd95SBruce Richardson 
662599a2dd95SBruce Richardson #ifdef RTE_ETHDEV_DEBUG_TX
662699a2dd95SBruce Richardson 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
662799a2dd95SBruce Richardson 
66287a093523SKonstantin Ananyev 	if (qd == NULL) {
66290e21c7c0SDavid Marchand 		RTE_ETHDEV_LOG_LINE(ERR, "Invalid Tx queue_id=%u for port_id=%u",
66307a093523SKonstantin Ananyev 			queue_id, port_id);
663199a2dd95SBruce Richardson 		return 0;
663299a2dd95SBruce Richardson 	}
663399a2dd95SBruce Richardson #endif
663499a2dd95SBruce Richardson 
663599a2dd95SBruce Richardson #ifdef RTE_ETHDEV_RXTX_CALLBACKS
66367a093523SKonstantin Ananyev 	{
66377a093523SKonstantin Ananyev 		void *cb;
663899a2dd95SBruce Richardson 
6639f7053f01STyler Retzlaff 		/* rte_memory_order_release memory order was used when the
664099a2dd95SBruce Richardson 		 * call back was inserted into the list.
664199a2dd95SBruce Richardson 		 * Since there is a clear dependency between loading
6642f7053f01STyler Retzlaff 		 * cb and cb->fn/cb->next, rte_memory_order_acquire memory order is
664399a2dd95SBruce Richardson 		 * not required.
664499a2dd95SBruce Richardson 		 */
6645f7053f01STyler Retzlaff 		cb = rte_atomic_load_explicit(&p->txq.clbk[queue_id],
6646f7053f01STyler Retzlaff 				rte_memory_order_relaxed);
66477a093523SKonstantin Ananyev 		if (unlikely(cb != NULL))
66487a093523SKonstantin Ananyev 			nb_pkts = rte_eth_call_tx_callbacks(port_id, queue_id,
66497a093523SKonstantin Ananyev 					tx_pkts, nb_pkts, cb);
665099a2dd95SBruce Richardson 	}
665199a2dd95SBruce Richardson #endif
665299a2dd95SBruce Richardson 
66537a093523SKonstantin Ananyev 	nb_pkts = p->tx_pkt_burst(qd, tx_pkts, nb_pkts);
66547a093523SKonstantin Ananyev 
66557a093523SKonstantin Ananyev 	rte_ethdev_trace_tx_burst(port_id, queue_id, (void **)tx_pkts, nb_pkts);
66567a093523SKonstantin Ananyev 	return nb_pkts;
665799a2dd95SBruce Richardson }
665899a2dd95SBruce Richardson 
665999a2dd95SBruce Richardson /**
666099a2dd95SBruce Richardson  * Process a burst of output packets on a transmit queue of an Ethernet device.
666199a2dd95SBruce Richardson  *
666299a2dd95SBruce Richardson  * The rte_eth_tx_prepare() function is invoked to prepare output packets to be
666399a2dd95SBruce Richardson  * transmitted on the output queue *queue_id* of the Ethernet device designated
666499a2dd95SBruce Richardson  * by its *port_id*.
666599a2dd95SBruce Richardson  * The *nb_pkts* parameter is the number of packets to be prepared which are
666699a2dd95SBruce Richardson  * supplied in the *tx_pkts* array of *rte_mbuf* structures, each of them
666799a2dd95SBruce Richardson  * allocated from a pool created with rte_pktmbuf_pool_create().
666899a2dd95SBruce Richardson  * For each packet to send, the rte_eth_tx_prepare() function performs
666999a2dd95SBruce Richardson  * the following operations:
667099a2dd95SBruce Richardson  *
667109fd4227SAndrew Rybchenko  * - Check if packet meets devices requirements for Tx offloads.
667299a2dd95SBruce Richardson  *
667399a2dd95SBruce Richardson  * - Check limitations about number of segments.
667499a2dd95SBruce Richardson  *
667599a2dd95SBruce Richardson  * - Check additional requirements when debug is enabled.
667699a2dd95SBruce Richardson  *
667709fd4227SAndrew Rybchenko  * - Update and/or reset required checksums when Tx offload is set for packet.
667899a2dd95SBruce Richardson  *
667999a2dd95SBruce Richardson  * Since this function can modify packet data, provided mbufs must be safely
668099a2dd95SBruce Richardson  * writable (e.g. modified data cannot be in shared segment).
668199a2dd95SBruce Richardson  *
668299a2dd95SBruce Richardson  * The rte_eth_tx_prepare() function returns the number of packets ready to be
668399a2dd95SBruce Richardson  * sent. A return value equal to *nb_pkts* means that all packets are valid and
668499a2dd95SBruce Richardson  * ready to be sent, otherwise stops processing on the first invalid packet and
668599a2dd95SBruce Richardson  * leaves the rest packets untouched.
668699a2dd95SBruce Richardson  *
668799a2dd95SBruce Richardson  * When this functionality is not implemented in the driver, all packets are
668899a2dd95SBruce Richardson  * are returned untouched.
668999a2dd95SBruce Richardson  *
669099a2dd95SBruce Richardson  * @param port_id
669199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
66925906be5aSAndrew Rybchenko  *   The value must be a valid port ID.
669399a2dd95SBruce Richardson  * @param queue_id
669499a2dd95SBruce Richardson  *   The index of the transmit queue through which output packets must be
669599a2dd95SBruce Richardson  *   sent.
669699a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
669799a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
669899a2dd95SBruce Richardson  * @param tx_pkts
669999a2dd95SBruce Richardson  *   The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
670099a2dd95SBruce Richardson  *   which contain the output packets.
670199a2dd95SBruce Richardson  * @param nb_pkts
670299a2dd95SBruce Richardson  *   The maximum number of packets to process.
670399a2dd95SBruce Richardson  * @return
670499a2dd95SBruce Richardson  *   The number of packets correct and ready to be sent. The return value can be
670599a2dd95SBruce Richardson  *   less than the value of the *tx_pkts* parameter when some packet doesn't
670699a2dd95SBruce Richardson  *   meet devices requirements with rte_errno set appropriately:
670799a2dd95SBruce Richardson  *   - EINVAL: offload flags are not correctly set
670899a2dd95SBruce Richardson  *   - ENOTSUP: the offload feature is not supported by the hardware
670999a2dd95SBruce Richardson  *   - ENODEV: if *port_id* is invalid (with debug enabled only)
671099a2dd95SBruce Richardson  */
671199a2dd95SBruce Richardson 
671299a2dd95SBruce Richardson #ifndef RTE_ETHDEV_TX_PREPARE_NOOP
671399a2dd95SBruce Richardson 
671499a2dd95SBruce Richardson static inline uint16_t
671599a2dd95SBruce Richardson rte_eth_tx_prepare(uint16_t port_id, uint16_t queue_id,
671699a2dd95SBruce Richardson 		struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
671799a2dd95SBruce Richardson {
67187a093523SKonstantin Ananyev 	struct rte_eth_fp_ops *p;
67197a093523SKonstantin Ananyev 	void *qd;
67207a093523SKonstantin Ananyev 
67217a093523SKonstantin Ananyev #ifdef RTE_ETHDEV_DEBUG_TX
67227a093523SKonstantin Ananyev 	if (port_id >= RTE_MAX_ETHPORTS ||
67237a093523SKonstantin Ananyev 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
67240e21c7c0SDavid Marchand 		RTE_ETHDEV_LOG_LINE(ERR,
67250e21c7c0SDavid Marchand 			"Invalid port_id=%u or queue_id=%u",
67267a093523SKonstantin Ananyev 			port_id, queue_id);
67277a093523SKonstantin Ananyev 		rte_errno = ENODEV;
67287a093523SKonstantin Ananyev 		return 0;
67297a093523SKonstantin Ananyev 	}
67307a093523SKonstantin Ananyev #endif
67317a093523SKonstantin Ananyev 
67327a093523SKonstantin Ananyev 	/* fetch pointer to queue data */
67337a093523SKonstantin Ananyev 	p = &rte_eth_fp_ops[port_id];
67347a093523SKonstantin Ananyev 	qd = p->txq.data[queue_id];
673599a2dd95SBruce Richardson 
673699a2dd95SBruce Richardson #ifdef RTE_ETHDEV_DEBUG_TX
673799a2dd95SBruce Richardson 	if (!rte_eth_dev_is_valid_port(port_id)) {
67380e21c7c0SDavid Marchand 		RTE_ETHDEV_LOG_LINE(ERR, "Invalid Tx port_id=%u", port_id);
673999a2dd95SBruce Richardson 		rte_errno = ENODEV;
674099a2dd95SBruce Richardson 		return 0;
674199a2dd95SBruce Richardson 	}
67427a093523SKonstantin Ananyev 	if (qd == NULL) {
67430e21c7c0SDavid Marchand 		RTE_ETHDEV_LOG_LINE(ERR, "Invalid Tx queue_id=%u for port_id=%u",
67447a093523SKonstantin Ananyev 			queue_id, port_id);
674599a2dd95SBruce Richardson 		rte_errno = EINVAL;
674699a2dd95SBruce Richardson 		return 0;
674799a2dd95SBruce Richardson 	}
674899a2dd95SBruce Richardson #endif
674999a2dd95SBruce Richardson 
67507a093523SKonstantin Ananyev 	if (!p->tx_pkt_prepare)
675199a2dd95SBruce Richardson 		return nb_pkts;
675299a2dd95SBruce Richardson 
67537a093523SKonstantin Ananyev 	return p->tx_pkt_prepare(qd, tx_pkts, nb_pkts);
675499a2dd95SBruce Richardson }
675599a2dd95SBruce Richardson 
675699a2dd95SBruce Richardson #else
675799a2dd95SBruce Richardson 
675899a2dd95SBruce Richardson /*
675999a2dd95SBruce Richardson  * Native NOOP operation for compilation targets which doesn't require any
676099a2dd95SBruce Richardson  * preparations steps, and functional NOOP may introduce unnecessary performance
676199a2dd95SBruce Richardson  * drop.
676299a2dd95SBruce Richardson  *
676399a2dd95SBruce Richardson  * Generally this is not a good idea to turn it on globally and didn't should
676499a2dd95SBruce Richardson  * be used if behavior of tx_preparation can change.
676599a2dd95SBruce Richardson  */
676699a2dd95SBruce Richardson 
676799a2dd95SBruce Richardson static inline uint16_t
676899a2dd95SBruce Richardson rte_eth_tx_prepare(__rte_unused uint16_t port_id,
676999a2dd95SBruce Richardson 		__rte_unused uint16_t queue_id,
677099a2dd95SBruce Richardson 		__rte_unused struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
677199a2dd95SBruce Richardson {
677299a2dd95SBruce Richardson 	return nb_pkts;
677399a2dd95SBruce Richardson }
677499a2dd95SBruce Richardson 
677599a2dd95SBruce Richardson #endif
677699a2dd95SBruce Richardson 
677799a2dd95SBruce Richardson /**
677899a2dd95SBruce Richardson  * Send any packets queued up for transmission on a port and HW queue
677999a2dd95SBruce Richardson  *
678099a2dd95SBruce Richardson  * This causes an explicit flush of packets previously buffered via the
678199a2dd95SBruce Richardson  * rte_eth_tx_buffer() function. It returns the number of packets successfully
678299a2dd95SBruce Richardson  * sent to the NIC, and calls the error callback for any unsent packets. Unless
678399a2dd95SBruce Richardson  * explicitly set up otherwise, the default callback simply frees the unsent
678499a2dd95SBruce Richardson  * packets back to the owning mempool.
678599a2dd95SBruce Richardson  *
678699a2dd95SBruce Richardson  * @param port_id
678799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
678899a2dd95SBruce Richardson  * @param queue_id
678999a2dd95SBruce Richardson  *   The index of the transmit queue through which output packets must be
679099a2dd95SBruce Richardson  *   sent.
679199a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
679299a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
679399a2dd95SBruce Richardson  * @param buffer
679499a2dd95SBruce Richardson  *   Buffer of packets to be transmit.
679599a2dd95SBruce Richardson  * @return
679699a2dd95SBruce Richardson  *   The number of packets successfully sent to the Ethernet device. The error
679799a2dd95SBruce Richardson  *   callback is called for any packets which could not be sent.
679899a2dd95SBruce Richardson  */
679999a2dd95SBruce Richardson static inline uint16_t
680099a2dd95SBruce Richardson rte_eth_tx_buffer_flush(uint16_t port_id, uint16_t queue_id,
680199a2dd95SBruce Richardson 		struct rte_eth_dev_tx_buffer *buffer)
680299a2dd95SBruce Richardson {
680399a2dd95SBruce Richardson 	uint16_t sent;
680499a2dd95SBruce Richardson 	uint16_t to_send = buffer->length;
680599a2dd95SBruce Richardson 
680699a2dd95SBruce Richardson 	if (to_send == 0)
680799a2dd95SBruce Richardson 		return 0;
680899a2dd95SBruce Richardson 
680999a2dd95SBruce Richardson 	sent = rte_eth_tx_burst(port_id, queue_id, buffer->pkts, to_send);
681099a2dd95SBruce Richardson 
681199a2dd95SBruce Richardson 	buffer->length = 0;
681299a2dd95SBruce Richardson 
681399a2dd95SBruce Richardson 	/* All packets sent, or to be dealt with by callback below */
681499a2dd95SBruce Richardson 	if (unlikely(sent != to_send))
681599a2dd95SBruce Richardson 		buffer->error_callback(&buffer->pkts[sent],
681699a2dd95SBruce Richardson 				       (uint16_t)(to_send - sent),
681799a2dd95SBruce Richardson 				       buffer->error_userdata);
681899a2dd95SBruce Richardson 
681999a2dd95SBruce Richardson 	return sent;
682099a2dd95SBruce Richardson }
682199a2dd95SBruce Richardson 
682299a2dd95SBruce Richardson /**
682399a2dd95SBruce Richardson  * Buffer a single packet for future transmission on a port and queue
682499a2dd95SBruce Richardson  *
682599a2dd95SBruce Richardson  * This function takes a single mbuf/packet and buffers it for later
682699a2dd95SBruce Richardson  * transmission on the particular port and queue specified. Once the buffer is
682799a2dd95SBruce Richardson  * full of packets, an attempt will be made to transmit all the buffered
682899a2dd95SBruce Richardson  * packets. In case of error, where not all packets can be transmitted, a
682999a2dd95SBruce Richardson  * callback is called with the unsent packets as a parameter. If no callback
683099a2dd95SBruce Richardson  * is explicitly set up, the unsent packets are just freed back to the owning
683199a2dd95SBruce Richardson  * mempool. The function returns the number of packets actually sent i.e.
683299a2dd95SBruce Richardson  * 0 if no buffer flush occurred, otherwise the number of packets successfully
683399a2dd95SBruce Richardson  * flushed
683499a2dd95SBruce Richardson  *
683599a2dd95SBruce Richardson  * @param port_id
683699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
683799a2dd95SBruce Richardson  * @param queue_id
683899a2dd95SBruce Richardson  *   The index of the transmit queue through which output packets must be
683999a2dd95SBruce Richardson  *   sent.
684099a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
684199a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
684299a2dd95SBruce Richardson  * @param buffer
684399a2dd95SBruce Richardson  *   Buffer used to collect packets to be sent.
684499a2dd95SBruce Richardson  * @param tx_pkt
684599a2dd95SBruce Richardson  *   Pointer to the packet mbuf to be sent.
684699a2dd95SBruce Richardson  * @return
684799a2dd95SBruce Richardson  *   0 = packet has been buffered for later transmission
684899a2dd95SBruce Richardson  *   N > 0 = packet has been buffered, and the buffer was subsequently flushed,
684999a2dd95SBruce Richardson  *     causing N packets to be sent, and the error callback to be called for
685099a2dd95SBruce Richardson  *     the rest.
685199a2dd95SBruce Richardson  */
685299a2dd95SBruce Richardson static __rte_always_inline uint16_t
685399a2dd95SBruce Richardson rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id,
685499a2dd95SBruce Richardson 		struct rte_eth_dev_tx_buffer *buffer, struct rte_mbuf *tx_pkt)
685599a2dd95SBruce Richardson {
685699a2dd95SBruce Richardson 	buffer->pkts[buffer->length++] = tx_pkt;
685799a2dd95SBruce Richardson 	if (buffer->length < buffer->size)
685899a2dd95SBruce Richardson 		return 0;
685999a2dd95SBruce Richardson 
686099a2dd95SBruce Richardson 	return rte_eth_tx_buffer_flush(port_id, queue_id, buffer);
686199a2dd95SBruce Richardson }
686299a2dd95SBruce Richardson 
6863e4e6f4cbSYuan Wang /**
6864e4e6f4cbSYuan Wang  * @warning
6865e43d2b89SFeifei Wang  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
6866e43d2b89SFeifei Wang  *
6867e43d2b89SFeifei Wang  * Recycle used mbufs from a transmit queue of an Ethernet device, and move
6868e43d2b89SFeifei Wang  * these mbufs into a mbuf ring for a receive queue of an Ethernet device.
6869e43d2b89SFeifei Wang  * This can bypass mempool path to save CPU cycles.
6870e43d2b89SFeifei Wang  *
6871e43d2b89SFeifei Wang  * The rte_eth_recycle_mbufs() function loops, with rte_eth_rx_burst() and
6872e43d2b89SFeifei Wang  * rte_eth_tx_burst() functions, freeing Tx used mbufs and replenishing Rx
6873e43d2b89SFeifei Wang  * descriptors. The number of recycling mbufs depends on the request of Rx mbuf
6874e43d2b89SFeifei Wang  * ring, with the constraint of enough used mbufs from Tx mbuf ring.
6875e43d2b89SFeifei Wang  *
6876e43d2b89SFeifei Wang  * For each recycling mbufs, the rte_eth_recycle_mbufs() function performs the
6877e43d2b89SFeifei Wang  * following operations:
6878e43d2b89SFeifei Wang  *
6879e43d2b89SFeifei Wang  * - Copy used *rte_mbuf* buffer pointers from Tx mbuf ring into Rx mbuf ring.
6880e43d2b89SFeifei Wang  *
6881e43d2b89SFeifei Wang  * - Replenish the Rx descriptors with the recycling *rte_mbuf* mbufs freed
6882e43d2b89SFeifei Wang  *   from the Tx mbuf ring.
6883e43d2b89SFeifei Wang  *
6884e43d2b89SFeifei Wang  * This function spilts Rx and Tx path with different callback functions. The
6885e43d2b89SFeifei Wang  * callback function recycle_tx_mbufs_reuse is for Tx driver. The callback
6886e43d2b89SFeifei Wang  * function recycle_rx_descriptors_refill is for Rx driver. rte_eth_recycle_mbufs()
6887e43d2b89SFeifei Wang  * can support the case that Rx Ethernet device is different from Tx Ethernet device.
6888e43d2b89SFeifei Wang  *
6889e43d2b89SFeifei Wang  * It is the responsibility of users to select the Rx/Tx queue pair to recycle
6890e43d2b89SFeifei Wang  * mbufs. Before call this function, users must call rte_eth_recycle_rxq_info_get
6891e43d2b89SFeifei Wang  * function to retrieve selected Rx queue information.
6892e43d2b89SFeifei Wang  * @see rte_eth_recycle_rxq_info_get, struct rte_eth_recycle_rxq_info
6893e43d2b89SFeifei Wang  *
6894e43d2b89SFeifei Wang  * Currently, the rte_eth_recycle_mbufs() function can support to feed 1 Rx queue from
6895e43d2b89SFeifei Wang  * 2 Tx queues in the same thread. Do not pair the Rx queue and Tx queue in different
6896e43d2b89SFeifei Wang  * threads, in order to avoid memory error rewriting.
6897e43d2b89SFeifei Wang  *
6898e43d2b89SFeifei Wang  * @param rx_port_id
6899e43d2b89SFeifei Wang  *   Port identifying the receive side.
6900e43d2b89SFeifei Wang  * @param rx_queue_id
6901e43d2b89SFeifei Wang  *   The index of the receive queue identifying the receive side.
6902e43d2b89SFeifei Wang  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
6903e43d2b89SFeifei Wang  *   to rte_eth_dev_configure().
6904e43d2b89SFeifei Wang  * @param tx_port_id
6905e43d2b89SFeifei Wang  *   Port identifying the transmit side.
6906e43d2b89SFeifei Wang  * @param tx_queue_id
6907e43d2b89SFeifei Wang  *   The index of the transmit queue identifying the transmit side.
6908e43d2b89SFeifei Wang  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
6909e43d2b89SFeifei Wang  *   to rte_eth_dev_configure().
6910e43d2b89SFeifei Wang  * @param recycle_rxq_info
6911e43d2b89SFeifei Wang  *   A pointer to a structure of type *rte_eth_recycle_rxq_info* which contains
6912e43d2b89SFeifei Wang  *   the information of the Rx queue mbuf ring.
6913e43d2b89SFeifei Wang  * @return
6914e43d2b89SFeifei Wang  *   The number of recycling mbufs.
6915e43d2b89SFeifei Wang  */
6916e43d2b89SFeifei Wang __rte_experimental
6917e43d2b89SFeifei Wang static inline uint16_t
6918e43d2b89SFeifei Wang rte_eth_recycle_mbufs(uint16_t rx_port_id, uint16_t rx_queue_id,
6919e43d2b89SFeifei Wang 		uint16_t tx_port_id, uint16_t tx_queue_id,
6920e43d2b89SFeifei Wang 		struct rte_eth_recycle_rxq_info *recycle_rxq_info)
6921e43d2b89SFeifei Wang {
6922e43d2b89SFeifei Wang 	struct rte_eth_fp_ops *p1, *p2;
6923e43d2b89SFeifei Wang 	void *qd1, *qd2;
6924e43d2b89SFeifei Wang 	uint16_t nb_mbufs;
6925e43d2b89SFeifei Wang 
6926e43d2b89SFeifei Wang #ifdef RTE_ETHDEV_DEBUG_TX
6927e43d2b89SFeifei Wang 	if (tx_port_id >= RTE_MAX_ETHPORTS ||
6928e43d2b89SFeifei Wang 			tx_queue_id >= RTE_MAX_QUEUES_PER_PORT) {
69290e21c7c0SDavid Marchand 		RTE_ETHDEV_LOG_LINE(ERR,
69300e21c7c0SDavid Marchand 				"Invalid tx_port_id=%u or tx_queue_id=%u",
6931e43d2b89SFeifei Wang 				tx_port_id, tx_queue_id);
6932e43d2b89SFeifei Wang 		return 0;
6933e43d2b89SFeifei Wang 	}
6934e43d2b89SFeifei Wang #endif
6935e43d2b89SFeifei Wang 
6936e43d2b89SFeifei Wang 	/* fetch pointer to Tx queue data */
6937e43d2b89SFeifei Wang 	p1 = &rte_eth_fp_ops[tx_port_id];
6938e43d2b89SFeifei Wang 	qd1 = p1->txq.data[tx_queue_id];
6939e43d2b89SFeifei Wang 
6940e43d2b89SFeifei Wang #ifdef RTE_ETHDEV_DEBUG_TX
6941e43d2b89SFeifei Wang 	RTE_ETH_VALID_PORTID_OR_ERR_RET(tx_port_id, 0);
6942e43d2b89SFeifei Wang 
6943e43d2b89SFeifei Wang 	if (qd1 == NULL) {
69440e21c7c0SDavid Marchand 		RTE_ETHDEV_LOG_LINE(ERR, "Invalid Tx queue_id=%u for port_id=%u",
6945e43d2b89SFeifei Wang 				tx_queue_id, tx_port_id);
6946e43d2b89SFeifei Wang 		return 0;
6947e43d2b89SFeifei Wang 	}
6948e43d2b89SFeifei Wang #endif
6949e43d2b89SFeifei Wang 	if (p1->recycle_tx_mbufs_reuse == NULL)
6950e43d2b89SFeifei Wang 		return 0;
6951e43d2b89SFeifei Wang 
6952e43d2b89SFeifei Wang #ifdef RTE_ETHDEV_DEBUG_RX
6953e43d2b89SFeifei Wang 	if (rx_port_id >= RTE_MAX_ETHPORTS ||
6954e43d2b89SFeifei Wang 			rx_queue_id >= RTE_MAX_QUEUES_PER_PORT) {
69550e21c7c0SDavid Marchand 		RTE_ETHDEV_LOG_LINE(ERR, "Invalid rx_port_id=%u or rx_queue_id=%u",
6956e43d2b89SFeifei Wang 				rx_port_id, rx_queue_id);
6957e43d2b89SFeifei Wang 		return 0;
6958e43d2b89SFeifei Wang 	}
6959e43d2b89SFeifei Wang #endif
6960e43d2b89SFeifei Wang 
6961e43d2b89SFeifei Wang 	/* fetch pointer to Rx queue data */
6962e43d2b89SFeifei Wang 	p2 = &rte_eth_fp_ops[rx_port_id];
6963e43d2b89SFeifei Wang 	qd2 = p2->rxq.data[rx_queue_id];
6964e43d2b89SFeifei Wang 
6965e43d2b89SFeifei Wang #ifdef RTE_ETHDEV_DEBUG_RX
6966e43d2b89SFeifei Wang 	RTE_ETH_VALID_PORTID_OR_ERR_RET(rx_port_id, 0);
6967e43d2b89SFeifei Wang 
6968e43d2b89SFeifei Wang 	if (qd2 == NULL) {
69690e21c7c0SDavid Marchand 		RTE_ETHDEV_LOG_LINE(ERR, "Invalid Rx queue_id=%u for port_id=%u",
6970e43d2b89SFeifei Wang 				rx_queue_id, rx_port_id);
6971e43d2b89SFeifei Wang 		return 0;
6972e43d2b89SFeifei Wang 	}
6973e43d2b89SFeifei Wang #endif
6974e43d2b89SFeifei Wang 	if (p2->recycle_rx_descriptors_refill == NULL)
6975e43d2b89SFeifei Wang 		return 0;
6976e43d2b89SFeifei Wang 
6977e43d2b89SFeifei Wang 	/* Copy used *rte_mbuf* buffer pointers from Tx mbuf ring
6978e43d2b89SFeifei Wang 	 * into Rx mbuf ring.
6979e43d2b89SFeifei Wang 	 */
6980e43d2b89SFeifei Wang 	nb_mbufs = p1->recycle_tx_mbufs_reuse(qd1, recycle_rxq_info);
6981e43d2b89SFeifei Wang 
6982e43d2b89SFeifei Wang 	/* If no recycling mbufs, return 0. */
6983e43d2b89SFeifei Wang 	if (nb_mbufs == 0)
6984e43d2b89SFeifei Wang 		return 0;
6985e43d2b89SFeifei Wang 
6986e43d2b89SFeifei Wang 	/* Replenish the Rx descriptors with the recycling
6987e43d2b89SFeifei Wang 	 * into Rx mbuf ring.
6988e43d2b89SFeifei Wang 	 */
6989e43d2b89SFeifei Wang 	p2->recycle_rx_descriptors_refill(qd2, nb_mbufs);
6990e43d2b89SFeifei Wang 
6991e43d2b89SFeifei Wang 	return nb_mbufs;
6992e43d2b89SFeifei Wang }
6993e43d2b89SFeifei Wang 
6994e43d2b89SFeifei Wang /**
6995e43d2b89SFeifei Wang  * @warning
6996e4e6f4cbSYuan Wang  * @b EXPERIMENTAL: this API may change without prior notice
6997e4e6f4cbSYuan Wang  *
6998e4e6f4cbSYuan Wang  * Get supported header protocols to split on Rx.
6999e4e6f4cbSYuan Wang  *
7000e4e6f4cbSYuan Wang  * When a packet type is announced to be split,
7001e4e6f4cbSYuan Wang  * it *must* be supported by the PMD.
7002e4e6f4cbSYuan Wang  * For instance, if eth-ipv4, eth-ipv4-udp is announced,
7003e4e6f4cbSYuan Wang  * the PMD must return the following packet types for these packets:
7004e4e6f4cbSYuan Wang  * - Ether/IPv4             -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4
7005e4e6f4cbSYuan Wang  * - Ether/IPv4/UDP         -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP
7006e4e6f4cbSYuan Wang  *
7007e4e6f4cbSYuan Wang  * @param port_id
7008e4e6f4cbSYuan Wang  *   The port identifier of the device.
7009e4e6f4cbSYuan Wang  * @param[out] ptypes
7010e4e6f4cbSYuan Wang  *   An array pointer to store supported protocol headers, allocated by caller.
7011e4e6f4cbSYuan Wang  *   These ptypes are composed with RTE_PTYPE_*.
7012e4e6f4cbSYuan Wang  * @param num
7013e4e6f4cbSYuan Wang  *   Size of the array pointed by param ptypes.
7014e4e6f4cbSYuan Wang  * @return
7015e4e6f4cbSYuan Wang  *   - (>=0) Number of supported ptypes. If the number of types exceeds num,
7016e4e6f4cbSYuan Wang  *           only num entries will be filled into the ptypes array,
7017e4e6f4cbSYuan Wang  *           but the full count of supported ptypes will be returned.
7018e4e6f4cbSYuan Wang  *   - (-ENOTSUP) if header protocol is not supported by device.
7019e4e6f4cbSYuan Wang  *   - (-ENODEV) if *port_id* invalid.
7020e4e6f4cbSYuan Wang  *   - (-EINVAL) if bad parameter.
7021e4e6f4cbSYuan Wang  */
7022e4e6f4cbSYuan Wang __rte_experimental
7023*1ff8b9a6SStephen Hemminger int rte_eth_buffer_split_get_supported_hdr_ptypes(uint16_t port_id, uint32_t *ptypes, int num)
7024*1ff8b9a6SStephen Hemminger 	__rte_warn_unused_result;
7025e4e6f4cbSYuan Wang 
7026d4b9235fSJerin Jacob /**
7027d4b9235fSJerin Jacob  * @warning
7028d4b9235fSJerin Jacob  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice.
7029d4b9235fSJerin Jacob  *
7030d4b9235fSJerin Jacob  * Get the number of used descriptors of a Tx queue.
7031d4b9235fSJerin Jacob  *
7032d4b9235fSJerin Jacob  * This function retrieves the number of used descriptors of a transmit queue.
7033d4b9235fSJerin Jacob  * Applications can use this API in the fast path to inspect Tx queue occupancy
7034d4b9235fSJerin Jacob  * and take appropriate actions based on the available free descriptors.
7035d4b9235fSJerin Jacob  * An example action could be implementing Random Early Discard (RED).
7036d4b9235fSJerin Jacob  *
7037d4b9235fSJerin Jacob  * Since it's a fast-path function, no check is performed on port_id and queue_id.
7038d4b9235fSJerin Jacob  * The caller must therefore ensure that the port is enabled
7039d4b9235fSJerin Jacob  * and the queue is configured and running.
7040d4b9235fSJerin Jacob  *
7041d4b9235fSJerin Jacob  * @param port_id
7042d4b9235fSJerin Jacob  *   The port identifier of the device.
7043d4b9235fSJerin Jacob  * @param queue_id
7044d4b9235fSJerin Jacob  *   The index of the transmit queue.
7045d4b9235fSJerin Jacob  *   The value must be in the range [0, nb_tx_queue - 1]
7046d4b9235fSJerin Jacob  *   previously supplied to rte_eth_dev_configure().
7047d4b9235fSJerin Jacob  * @return
7048d4b9235fSJerin Jacob  *   The number of used descriptors in the specific queue, or:
7049d4b9235fSJerin Jacob  *   - (-ENODEV) if *port_id* is invalid. Enabled only when RTE_ETHDEV_DEBUG_TX is enabled.
7050d4b9235fSJerin Jacob  *   - (-EINVAL) if *queue_id* is invalid. Enabled only when RTE_ETHDEV_DEBUG_TX is enabled.
7051d4b9235fSJerin Jacob  *   - (-ENOTSUP) if the device does not support this function.
7052d4b9235fSJerin Jacob  *
7053d4b9235fSJerin Jacob  * @note This function is designed for fast-path use.
7054d4b9235fSJerin Jacob  * @note There is no requirement to call this function before rte_eth_tx_burst() invocation.
7055d4b9235fSJerin Jacob  * @note Utilize this function exclusively when the caller needs to determine
7056d4b9235fSJerin Jacob  * the used queue count across all descriptors of a Tx queue.
7057d4b9235fSJerin Jacob  * If the use case only involves checking the status of a specific descriptor slot,
7058d4b9235fSJerin Jacob  * opt for rte_eth_tx_descriptor_status() instead.
7059d4b9235fSJerin Jacob  */
7060d4b9235fSJerin Jacob __rte_experimental
7061d4b9235fSJerin Jacob static inline int
7062d4b9235fSJerin Jacob rte_eth_tx_queue_count(uint16_t port_id, uint16_t queue_id)
7063d4b9235fSJerin Jacob {
7064d4b9235fSJerin Jacob 	struct rte_eth_fp_ops *fops;
7065d4b9235fSJerin Jacob 	void *qd;
7066d4b9235fSJerin Jacob 	int rc;
7067d4b9235fSJerin Jacob 
7068d4b9235fSJerin Jacob #ifdef RTE_ETHDEV_DEBUG_TX
7069d4b9235fSJerin Jacob 	if (port_id >= RTE_MAX_ETHPORTS || !rte_eth_dev_is_valid_port(port_id)) {
7070d4b9235fSJerin Jacob 		RTE_ETHDEV_LOG_LINE(ERR, "Invalid port_id=%u", port_id);
7071d4b9235fSJerin Jacob 		rc = -ENODEV;
7072d4b9235fSJerin Jacob 		goto out;
7073d4b9235fSJerin Jacob 	}
7074d4b9235fSJerin Jacob 
7075d4b9235fSJerin Jacob 	if (queue_id >= RTE_MAX_QUEUES_PER_PORT) {
7076d4b9235fSJerin Jacob 		RTE_ETHDEV_LOG_LINE(ERR, "Invalid queue_id=%u for port_id=%u",
7077d4b9235fSJerin Jacob 				    queue_id, port_id);
7078d4b9235fSJerin Jacob 		rc = -EINVAL;
7079d4b9235fSJerin Jacob 		goto out;
7080d4b9235fSJerin Jacob 	}
7081d4b9235fSJerin Jacob #endif
7082d4b9235fSJerin Jacob 
7083d4b9235fSJerin Jacob 	/* Fetch pointer to Tx queue data */
7084d4b9235fSJerin Jacob 	fops = &rte_eth_fp_ops[port_id];
7085d4b9235fSJerin Jacob 	qd = fops->txq.data[queue_id];
7086d4b9235fSJerin Jacob 
7087d4b9235fSJerin Jacob #ifdef RTE_ETHDEV_DEBUG_TX
7088d4b9235fSJerin Jacob 	if (qd == NULL) {
7089d4b9235fSJerin Jacob 		RTE_ETHDEV_LOG_LINE(ERR, "Invalid queue_id=%u for port_id=%u",
7090d4b9235fSJerin Jacob 				    queue_id, port_id);
7091d4b9235fSJerin Jacob 		rc = -EINVAL;
7092d4b9235fSJerin Jacob 		goto out;
7093d4b9235fSJerin Jacob 	}
7094d4b9235fSJerin Jacob #endif
7095d4b9235fSJerin Jacob 	if (fops->tx_queue_count == NULL) {
7096d4b9235fSJerin Jacob 		rc = -ENOTSUP;
7097d4b9235fSJerin Jacob 		goto out;
7098d4b9235fSJerin Jacob 	}
7099d4b9235fSJerin Jacob 
7100d4b9235fSJerin Jacob 	rc = fops->tx_queue_count(qd);
7101d4b9235fSJerin Jacob 
7102d4b9235fSJerin Jacob out:
7103d4b9235fSJerin Jacob 	rte_eth_trace_tx_queue_count(port_id, queue_id, rc);
7104d4b9235fSJerin Jacob 	return rc;
7105d4b9235fSJerin Jacob }
7106d4b9235fSJerin Jacob 
710799a2dd95SBruce Richardson #ifdef __cplusplus
710899a2dd95SBruce Richardson }
710999a2dd95SBruce Richardson #endif
711099a2dd95SBruce Richardson 
711199a2dd95SBruce Richardson #endif /* _RTE_ETHDEV_H_ */
7112