xref: /dpdk/lib/ethdev/rte_ethdev.h (revision d1ce79d14ba18471db0a84c55c8b51fc1c254570)
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 #ifdef __cplusplus
14999a2dd95SBruce Richardson extern "C" {
15099a2dd95SBruce Richardson #endif
15199a2dd95SBruce Richardson 
15299a2dd95SBruce Richardson #include <stdint.h>
15399a2dd95SBruce Richardson 
15499a2dd95SBruce Richardson /* Use this macro to check if LRO API is supported */
15599a2dd95SBruce Richardson #define RTE_ETHDEV_HAS_LRO_SUPPORT
15699a2dd95SBruce Richardson 
15799a2dd95SBruce Richardson /* Alias RTE_LIBRTE_ETHDEV_DEBUG for backward compatibility. */
15899a2dd95SBruce Richardson #ifdef RTE_LIBRTE_ETHDEV_DEBUG
15999a2dd95SBruce Richardson #define RTE_ETHDEV_DEBUG_RX
16099a2dd95SBruce Richardson #define RTE_ETHDEV_DEBUG_TX
16199a2dd95SBruce Richardson #endif
16299a2dd95SBruce Richardson 
16399a2dd95SBruce Richardson #include <rte_compat.h>
16499a2dd95SBruce Richardson #include <rte_log.h>
16599a2dd95SBruce Richardson #include <rte_interrupts.h>
16699a2dd95SBruce Richardson #include <rte_dev.h>
16799a2dd95SBruce Richardson #include <rte_devargs.h>
168e1823e08SThomas Monjalon #include <rte_bitops.h>
16999a2dd95SBruce Richardson #include <rte_errno.h>
17099a2dd95SBruce Richardson #include <rte_common.h>
17199a2dd95SBruce Richardson #include <rte_config.h>
17299a2dd95SBruce Richardson #include <rte_power_intrinsics.h>
17399a2dd95SBruce Richardson 
17499a2dd95SBruce Richardson #include "rte_ethdev_trace_fp.h"
17599a2dd95SBruce Richardson #include "rte_dev_info.h"
17699a2dd95SBruce Richardson 
17799a2dd95SBruce Richardson extern int rte_eth_dev_logtype;
17899a2dd95SBruce Richardson 
17999a2dd95SBruce Richardson #define RTE_ETHDEV_LOG(level, ...) \
18099a2dd95SBruce Richardson 	rte_log(RTE_LOG_ ## level, rte_eth_dev_logtype, "" __VA_ARGS__)
18199a2dd95SBruce Richardson 
18299a2dd95SBruce Richardson struct rte_mbuf;
18399a2dd95SBruce Richardson 
18499a2dd95SBruce Richardson /**
18599a2dd95SBruce Richardson  * Initializes a device iterator.
18699a2dd95SBruce Richardson  *
18799a2dd95SBruce Richardson  * This iterator allows accessing a list of devices matching some devargs.
18899a2dd95SBruce Richardson  *
18999a2dd95SBruce Richardson  * @param iter
19099a2dd95SBruce Richardson  *   Device iterator handle initialized by the function.
19199a2dd95SBruce Richardson  *   The fields bus_str and cls_str might be dynamically allocated,
19299a2dd95SBruce Richardson  *   and could be freed by calling rte_eth_iterator_cleanup().
19399a2dd95SBruce Richardson  *
19499a2dd95SBruce Richardson  * @param devargs
19599a2dd95SBruce Richardson  *   Device description string.
19699a2dd95SBruce Richardson  *
19799a2dd95SBruce Richardson  * @return
19899a2dd95SBruce Richardson  *   0 on successful initialization, negative otherwise.
19999a2dd95SBruce Richardson  */
20099a2dd95SBruce Richardson int rte_eth_iterator_init(struct rte_dev_iterator *iter, const char *devargs);
20199a2dd95SBruce Richardson 
20299a2dd95SBruce Richardson /**
20399a2dd95SBruce Richardson  * Iterates on devices with devargs filter.
20499a2dd95SBruce Richardson  * The ownership is not checked.
20599a2dd95SBruce Richardson  *
2065906be5aSAndrew Rybchenko  * The next port ID is returned, and the iterator is updated.
20799a2dd95SBruce Richardson  *
20899a2dd95SBruce Richardson  * @param iter
20999a2dd95SBruce Richardson  *   Device iterator handle initialized by rte_eth_iterator_init().
21099a2dd95SBruce Richardson  *   Some fields bus_str and cls_str might be freed when no more port is found,
21199a2dd95SBruce Richardson  *   by calling rte_eth_iterator_cleanup().
21299a2dd95SBruce Richardson  *
21399a2dd95SBruce Richardson  * @return
2145906be5aSAndrew Rybchenko  *   A port ID if found, RTE_MAX_ETHPORTS otherwise.
21599a2dd95SBruce Richardson  */
21699a2dd95SBruce Richardson uint16_t rte_eth_iterator_next(struct rte_dev_iterator *iter);
21799a2dd95SBruce Richardson 
21899a2dd95SBruce Richardson /**
21999a2dd95SBruce Richardson  * Free some allocated fields of the iterator.
22099a2dd95SBruce Richardson  *
22199a2dd95SBruce Richardson  * This function is automatically called by rte_eth_iterator_next()
22299a2dd95SBruce Richardson  * on the last iteration (i.e. when no more matching port is found).
22399a2dd95SBruce Richardson  *
22499a2dd95SBruce Richardson  * It is safe to call this function twice; it will do nothing more.
22599a2dd95SBruce Richardson  *
22699a2dd95SBruce Richardson  * @param iter
22799a2dd95SBruce Richardson  *   Device iterator handle initialized by rte_eth_iterator_init().
22899a2dd95SBruce Richardson  *   The fields bus_str and cls_str are freed if needed.
22999a2dd95SBruce Richardson  */
23099a2dd95SBruce Richardson void rte_eth_iterator_cleanup(struct rte_dev_iterator *iter);
23199a2dd95SBruce Richardson 
23299a2dd95SBruce Richardson /**
23399a2dd95SBruce Richardson  * Macro to iterate over all ethdev ports matching some devargs.
23499a2dd95SBruce Richardson  *
23599a2dd95SBruce Richardson  * If a break is done before the end of the loop,
23699a2dd95SBruce Richardson  * the function rte_eth_iterator_cleanup() must be called.
23799a2dd95SBruce Richardson  *
23899a2dd95SBruce Richardson  * @param id
2395906be5aSAndrew Rybchenko  *   Iterated port ID of type uint16_t.
24099a2dd95SBruce Richardson  * @param devargs
24199a2dd95SBruce Richardson  *   Device parameters input as string of type char*.
24299a2dd95SBruce Richardson  * @param iter
24399a2dd95SBruce Richardson  *   Iterator handle of type struct rte_dev_iterator, used internally.
24499a2dd95SBruce Richardson  */
24599a2dd95SBruce Richardson #define RTE_ETH_FOREACH_MATCHING_DEV(id, devargs, iter) \
24699a2dd95SBruce Richardson 	for (rte_eth_iterator_init(iter, devargs), \
24799a2dd95SBruce Richardson 	     id = rte_eth_iterator_next(iter); \
24899a2dd95SBruce Richardson 	     id != RTE_MAX_ETHPORTS; \
24999a2dd95SBruce Richardson 	     id = rte_eth_iterator_next(iter))
25099a2dd95SBruce Richardson 
25199a2dd95SBruce Richardson /**
25299a2dd95SBruce Richardson  * A structure used to retrieve statistics for an Ethernet port.
25399a2dd95SBruce Richardson  * Not all statistics fields in struct rte_eth_stats are supported
25499a2dd95SBruce Richardson  * by any type of network interface card (NIC). If any statistics
25599a2dd95SBruce Richardson  * field is not supported, its value is 0.
25699a2dd95SBruce Richardson  * All byte-related statistics do not include Ethernet FCS regardless
25799a2dd95SBruce Richardson  * of whether these bytes have been delivered to the application
258295968d1SFerruh Yigit  * (see RTE_ETH_RX_OFFLOAD_KEEP_CRC).
25999a2dd95SBruce Richardson  */
26099a2dd95SBruce Richardson struct rte_eth_stats {
26199a2dd95SBruce Richardson 	uint64_t ipackets;  /**< Total number of successfully received packets. */
26299a2dd95SBruce Richardson 	uint64_t opackets;  /**< Total number of successfully transmitted packets.*/
26399a2dd95SBruce Richardson 	uint64_t ibytes;    /**< Total number of successfully received bytes. */
26499a2dd95SBruce Richardson 	uint64_t obytes;    /**< Total number of successfully transmitted bytes. */
2653c2ca0a9SAndrew Rybchenko 	/**
26609fd4227SAndrew Rybchenko 	 * Total of Rx packets dropped by the HW,
26709fd4227SAndrew Rybchenko 	 * because there are no available buffer (i.e. Rx queues are full).
26899a2dd95SBruce Richardson 	 */
2693c2ca0a9SAndrew Rybchenko 	uint64_t imissed;
27099a2dd95SBruce Richardson 	uint64_t ierrors;   /**< Total number of erroneous received packets. */
27199a2dd95SBruce Richardson 	uint64_t oerrors;   /**< Total number of failed transmitted packets. */
27209fd4227SAndrew Rybchenko 	uint64_t rx_nombuf; /**< Total number of Rx mbuf allocation failures. */
27399a2dd95SBruce Richardson 	/* Queue stats are limited to max 256 queues */
27409fd4227SAndrew Rybchenko 	/** Total number of queue Rx packets. */
27599a2dd95SBruce Richardson 	uint64_t q_ipackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
27609fd4227SAndrew Rybchenko 	/** Total number of queue Tx packets. */
27799a2dd95SBruce Richardson 	uint64_t q_opackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
2783c2ca0a9SAndrew Rybchenko 	/** Total number of successfully received queue bytes. */
27999a2dd95SBruce Richardson 	uint64_t q_ibytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
2803c2ca0a9SAndrew Rybchenko 	/** Total number of successfully transmitted queue bytes. */
28199a2dd95SBruce Richardson 	uint64_t q_obytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
2823c2ca0a9SAndrew Rybchenko 	/** Total number of queue packets received that are dropped. */
28399a2dd95SBruce Richardson 	uint64_t q_errors[RTE_ETHDEV_QUEUE_STAT_CNTRS];
28499a2dd95SBruce Richardson };
28599a2dd95SBruce Richardson 
2860ce56b05SThomas Monjalon /**@{@name Link speed capabilities
28799a2dd95SBruce Richardson  * Device supported speeds bitmap flags
28899a2dd95SBruce Richardson  */
289295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_AUTONEG 0             /**< Autonegotiate (all speeds) */
290295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_FIXED   RTE_BIT32(0)  /**< Disable autoneg (fixed speed) */
291295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_10M_HD  RTE_BIT32(1)  /**<  10 Mbps half-duplex */
292295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_10M     RTE_BIT32(2)  /**<  10 Mbps full-duplex */
293295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_100M_HD RTE_BIT32(3)  /**< 100 Mbps half-duplex */
294295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_100M    RTE_BIT32(4)  /**< 100 Mbps full-duplex */
295295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_1G      RTE_BIT32(5)  /**<   1 Gbps */
296295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_2_5G    RTE_BIT32(6)  /**< 2.5 Gbps */
297295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_5G      RTE_BIT32(7)  /**<   5 Gbps */
298295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_10G     RTE_BIT32(8)  /**<  10 Gbps */
299295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_20G     RTE_BIT32(9)  /**<  20 Gbps */
300295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_25G     RTE_BIT32(10) /**<  25 Gbps */
301295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_40G     RTE_BIT32(11) /**<  40 Gbps */
302295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_50G     RTE_BIT32(12) /**<  50 Gbps */
303295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_56G     RTE_BIT32(13) /**<  56 Gbps */
304295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_100G    RTE_BIT32(14) /**< 100 Gbps */
305295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_200G    RTE_BIT32(15) /**< 200 Gbps */
3060ce56b05SThomas Monjalon /**@}*/
30799a2dd95SBruce Richardson 
3080ce56b05SThomas Monjalon /**@{@name Link speed
30999a2dd95SBruce Richardson  * Ethernet numeric link speeds in Mbps
31099a2dd95SBruce Richardson  */
311295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_NONE         0 /**< Not defined */
312295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_10M         10 /**<  10 Mbps */
313295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_100M       100 /**< 100 Mbps */
314295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_1G        1000 /**<   1 Gbps */
315295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_2_5G      2500 /**< 2.5 Gbps */
316295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_5G        5000 /**<   5 Gbps */
317295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_10G      10000 /**<  10 Gbps */
318295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_20G      20000 /**<  20 Gbps */
319295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_25G      25000 /**<  25 Gbps */
320295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_40G      40000 /**<  40 Gbps */
321295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_50G      50000 /**<  50 Gbps */
322295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_56G      56000 /**<  56 Gbps */
323295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_100G    100000 /**< 100 Gbps */
324295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_200G    200000 /**< 200 Gbps */
325295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_UNKNOWN UINT32_MAX /**< Unknown */
3260ce56b05SThomas Monjalon /**@}*/
32799a2dd95SBruce Richardson 
32899a2dd95SBruce Richardson /**
32999a2dd95SBruce Richardson  * A structure used to retrieve link-level information of an Ethernet port.
33099a2dd95SBruce Richardson  */
33199a2dd95SBruce Richardson __extension__
33299a2dd95SBruce Richardson struct rte_eth_link {
333295968d1SFerruh Yigit 	uint32_t link_speed;        /**< RTE_ETH_SPEED_NUM_ */
334295968d1SFerruh Yigit 	uint16_t link_duplex  : 1;  /**< RTE_ETH_LINK_[HALF/FULL]_DUPLEX */
335295968d1SFerruh Yigit 	uint16_t link_autoneg : 1;  /**< RTE_ETH_LINK_[AUTONEG/FIXED] */
336295968d1SFerruh Yigit 	uint16_t link_status  : 1;  /**< RTE_ETH_LINK_[DOWN/UP] */
33799a2dd95SBruce Richardson } __rte_aligned(8);      /**< aligned for atomic64 read/write */
33899a2dd95SBruce Richardson 
3390ce56b05SThomas Monjalon /**@{@name Link negotiation
3400ce56b05SThomas Monjalon  * Constants used in link management.
3410ce56b05SThomas Monjalon  */
342295968d1SFerruh Yigit #define RTE_ETH_LINK_HALF_DUPLEX 0 /**< Half-duplex connection (see link_duplex). */
343295968d1SFerruh Yigit #define RTE_ETH_LINK_FULL_DUPLEX 1 /**< Full-duplex connection (see link_duplex). */
344295968d1SFerruh Yigit #define RTE_ETH_LINK_DOWN        0 /**< Link is down (see link_status). */
345295968d1SFerruh Yigit #define RTE_ETH_LINK_UP          1 /**< Link is up (see link_status). */
346295968d1SFerruh Yigit #define RTE_ETH_LINK_FIXED       0 /**< No autonegotiation (see link_autoneg). */
347295968d1SFerruh Yigit #define RTE_ETH_LINK_AUTONEG     1 /**< Autonegotiated (see link_autoneg). */
34899a2dd95SBruce Richardson #define RTE_ETH_LINK_MAX_STR_LEN 40 /**< Max length of default link string. */
3490ce56b05SThomas Monjalon /**@}*/
35099a2dd95SBruce Richardson 
35199a2dd95SBruce Richardson /**
35209fd4227SAndrew Rybchenko  * A structure used to configure the ring threshold registers of an Rx/Tx
35399a2dd95SBruce Richardson  * queue for an Ethernet port.
35499a2dd95SBruce Richardson  */
35599a2dd95SBruce Richardson struct rte_eth_thresh {
35699a2dd95SBruce Richardson 	uint8_t pthresh; /**< Ring prefetch threshold. */
35799a2dd95SBruce Richardson 	uint8_t hthresh; /**< Ring host threshold. */
35899a2dd95SBruce Richardson 	uint8_t wthresh; /**< Ring writeback threshold. */
35999a2dd95SBruce Richardson };
36099a2dd95SBruce Richardson 
3610ce56b05SThomas Monjalon /**@{@name Multi-queue mode
3620ce56b05SThomas Monjalon  * @see rte_eth_conf.rxmode.mq_mode.
36399a2dd95SBruce Richardson  */
3644852c647SAndrew Rybchenko #define RTE_ETH_MQ_RX_RSS_FLAG  RTE_BIT32(0) /**< Enable RSS. @see rte_eth_rss_conf */
3654852c647SAndrew Rybchenko #define RTE_ETH_MQ_RX_DCB_FLAG  RTE_BIT32(1) /**< Enable DCB. */
3664852c647SAndrew Rybchenko #define RTE_ETH_MQ_RX_VMDQ_FLAG RTE_BIT32(2) /**< Enable VMDq. */
3670ce56b05SThomas Monjalon /**@}*/
36899a2dd95SBruce Richardson 
36999a2dd95SBruce Richardson /**
37099a2dd95SBruce Richardson  *  A set of values to identify what method is to be used to route
37199a2dd95SBruce Richardson  *  packets to multiple queues.
37299a2dd95SBruce Richardson  */
37399a2dd95SBruce Richardson enum rte_eth_rx_mq_mode {
374064e90c4SAndrew Rybchenko 	/** None of DCB, RSS or VMDq mode */
375295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_NONE = 0,
37699a2dd95SBruce Richardson 
37709fd4227SAndrew Rybchenko 	/** For Rx side, only RSS is on */
378295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_RSS = RTE_ETH_MQ_RX_RSS_FLAG,
37909fd4227SAndrew Rybchenko 	/** For Rx side,only DCB is on. */
380295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_DCB = RTE_ETH_MQ_RX_DCB_FLAG,
38199a2dd95SBruce Richardson 	/** Both DCB and RSS enable */
382295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_DCB_RSS = RTE_ETH_MQ_RX_RSS_FLAG | RTE_ETH_MQ_RX_DCB_FLAG,
38399a2dd95SBruce Richardson 
384064e90c4SAndrew Rybchenko 	/** Only VMDq, no RSS nor DCB */
385295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_VMDQ_ONLY = RTE_ETH_MQ_RX_VMDQ_FLAG,
386064e90c4SAndrew Rybchenko 	/** RSS mode with VMDq */
387295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_VMDQ_RSS = RTE_ETH_MQ_RX_RSS_FLAG | RTE_ETH_MQ_RX_VMDQ_FLAG,
388064e90c4SAndrew Rybchenko 	/** Use VMDq+DCB to route traffic to queues */
389295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_VMDQ_DCB = RTE_ETH_MQ_RX_VMDQ_FLAG | RTE_ETH_MQ_RX_DCB_FLAG,
390064e90c4SAndrew Rybchenko 	/** Enable both VMDq and DCB in VMDq */
391295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_VMDQ_DCB_RSS = RTE_ETH_MQ_RX_RSS_FLAG | RTE_ETH_MQ_RX_DCB_FLAG |
392295968d1SFerruh Yigit 				 RTE_ETH_MQ_RX_VMDQ_FLAG,
39399a2dd95SBruce Richardson };
39499a2dd95SBruce Richardson 
39599a2dd95SBruce Richardson /**
39699a2dd95SBruce Richardson  * A set of values to identify what method is to be used to transmit
39799a2dd95SBruce Richardson  * packets using multi-TCs.
39899a2dd95SBruce Richardson  */
39999a2dd95SBruce Richardson enum rte_eth_tx_mq_mode {
400295968d1SFerruh Yigit 	RTE_ETH_MQ_TX_NONE    = 0,  /**< It is in neither DCB nor VT mode. */
401295968d1SFerruh Yigit 	RTE_ETH_MQ_TX_DCB,          /**< For Tx side,only DCB is on. */
402295968d1SFerruh Yigit 	RTE_ETH_MQ_TX_VMDQ_DCB,     /**< For Tx side,both DCB and VT is on. */
403295968d1SFerruh Yigit 	RTE_ETH_MQ_TX_VMDQ_ONLY,    /**< Only VT on, no DCB */
40499a2dd95SBruce Richardson };
405b1cb3035SFerruh Yigit 
40699a2dd95SBruce Richardson /**
40709fd4227SAndrew Rybchenko  * A structure used to configure the Rx features of an Ethernet port.
40899a2dd95SBruce Richardson  */
40999a2dd95SBruce Richardson struct rte_eth_rxmode {
41099a2dd95SBruce Richardson 	/** The multi-queue packet distribution mode to be used, e.g. RSS. */
41199a2dd95SBruce Richardson 	enum rte_eth_rx_mq_mode mq_mode;
4121bb4a528SFerruh Yigit 	uint32_t mtu;  /**< Requested MTU. */
41399a2dd95SBruce Richardson 	/** Maximum allowed size of LRO aggregated packet. */
41499a2dd95SBruce Richardson 	uint32_t max_lro_pkt_size;
41599a2dd95SBruce Richardson 	uint16_t split_hdr_size;  /**< hdr buf size (header_split enabled).*/
41699a2dd95SBruce Richardson 	/**
417295968d1SFerruh Yigit 	 * Per-port Rx offloads to be set using RTE_ETH_RX_OFFLOAD_* flags.
41899a2dd95SBruce Richardson 	 * Only offloads set on rx_offload_capa field on rte_eth_dev_info
41999a2dd95SBruce Richardson 	 * structure are allowed to be set.
42099a2dd95SBruce Richardson 	 */
42199a2dd95SBruce Richardson 	uint64_t offloads;
42299a2dd95SBruce Richardson 
42399a2dd95SBruce Richardson 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
42499a2dd95SBruce Richardson 	void *reserved_ptrs[2];   /**< Reserved for future fields */
42599a2dd95SBruce Richardson };
42699a2dd95SBruce Richardson 
42799a2dd95SBruce Richardson /**
42899a2dd95SBruce Richardson  * VLAN types to indicate if it is for single VLAN, inner VLAN or outer VLAN.
42999a2dd95SBruce Richardson  * Note that single VLAN is treated the same as inner VLAN.
43099a2dd95SBruce Richardson  */
43199a2dd95SBruce Richardson enum rte_vlan_type {
432295968d1SFerruh Yigit 	RTE_ETH_VLAN_TYPE_UNKNOWN = 0,
433295968d1SFerruh Yigit 	RTE_ETH_VLAN_TYPE_INNER, /**< Inner VLAN. */
434295968d1SFerruh Yigit 	RTE_ETH_VLAN_TYPE_OUTER, /**< Single VLAN, or outer VLAN. */
435295968d1SFerruh Yigit 	RTE_ETH_VLAN_TYPE_MAX,
43699a2dd95SBruce Richardson };
43799a2dd95SBruce Richardson 
43899a2dd95SBruce Richardson /**
4395b49ba65SAndrew Rybchenko  * A structure used to describe a VLAN filter.
44099a2dd95SBruce Richardson  * If the bit corresponding to a VID is set, such VID is on.
44199a2dd95SBruce Richardson  */
44299a2dd95SBruce Richardson struct rte_vlan_filter_conf {
44399a2dd95SBruce Richardson 	uint64_t ids[64];
44499a2dd95SBruce Richardson };
44599a2dd95SBruce Richardson 
44699a2dd95SBruce Richardson /**
44799a2dd95SBruce Richardson  * A structure used to configure the Receive Side Scaling (RSS) feature
44899a2dd95SBruce Richardson  * of an Ethernet port.
44999a2dd95SBruce Richardson  * If not NULL, the *rss_key* pointer of the *rss_conf* structure points
45099a2dd95SBruce Richardson  * to an array holding the RSS key to use for hashing specific header
45199a2dd95SBruce Richardson  * fields of received packets. The length of this array should be indicated
45299a2dd95SBruce Richardson  * by *rss_key_len* below. Otherwise, a default random hash key is used by
45399a2dd95SBruce Richardson  * the device driver.
45499a2dd95SBruce Richardson  *
45599a2dd95SBruce Richardson  * The *rss_key_len* field of the *rss_conf* structure indicates the length
45699a2dd95SBruce Richardson  * in bytes of the array pointed by *rss_key*. To be compatible, this length
45799a2dd95SBruce Richardson  * will be checked in i40e only. Others assume 40 bytes to be used as before.
45899a2dd95SBruce Richardson  *
45999a2dd95SBruce Richardson  * The *rss_hf* field of the *rss_conf* structure indicates the different
46099a2dd95SBruce Richardson  * types of IPv4/IPv6 packets to which the RSS hashing must be applied.
46199a2dd95SBruce Richardson  * Supplying an *rss_hf* equal to zero disables the RSS feature.
46299a2dd95SBruce Richardson  */
46399a2dd95SBruce Richardson struct rte_eth_rss_conf {
46499a2dd95SBruce Richardson 	uint8_t *rss_key;    /**< If not NULL, 40-byte hash key. */
46599a2dd95SBruce Richardson 	uint8_t rss_key_len; /**< hash key length in bytes. */
46699a2dd95SBruce Richardson 	uint64_t rss_hf;     /**< Hash functions to apply - see below. */
46799a2dd95SBruce Richardson };
46899a2dd95SBruce Richardson 
46999a2dd95SBruce Richardson /*
47099a2dd95SBruce Richardson  * A packet can be identified by hardware as different flow types. Different
47199a2dd95SBruce Richardson  * NIC hardware may support different flow types.
47299a2dd95SBruce Richardson  * Basically, the NIC hardware identifies the flow type as deep protocol as
47399a2dd95SBruce Richardson  * possible, and exclusively. For example, if a packet is identified as
47499a2dd95SBruce Richardson  * 'RTE_ETH_FLOW_NONFRAG_IPV4_TCP', it will not be any of other flow types,
47599a2dd95SBruce Richardson  * though it is an actual IPV4 packet.
47699a2dd95SBruce Richardson  */
47799a2dd95SBruce Richardson #define RTE_ETH_FLOW_UNKNOWN             0
47899a2dd95SBruce Richardson #define RTE_ETH_FLOW_RAW                 1
47999a2dd95SBruce Richardson #define RTE_ETH_FLOW_IPV4                2
48099a2dd95SBruce Richardson #define RTE_ETH_FLOW_FRAG_IPV4           3
48199a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV4_TCP    4
48299a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV4_UDP    5
48399a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV4_SCTP   6
48499a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV4_OTHER  7
48599a2dd95SBruce Richardson #define RTE_ETH_FLOW_IPV6                8
48699a2dd95SBruce Richardson #define RTE_ETH_FLOW_FRAG_IPV6           9
48799a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV6_TCP   10
48899a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV6_UDP   11
48999a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV6_SCTP  12
49099a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV6_OTHER 13
49199a2dd95SBruce Richardson #define RTE_ETH_FLOW_L2_PAYLOAD         14
49299a2dd95SBruce Richardson #define RTE_ETH_FLOW_IPV6_EX            15
49399a2dd95SBruce Richardson #define RTE_ETH_FLOW_IPV6_TCP_EX        16
49499a2dd95SBruce Richardson #define RTE_ETH_FLOW_IPV6_UDP_EX        17
4953c2ca0a9SAndrew Rybchenko /** Consider device port number as a flow differentiator */
49699a2dd95SBruce Richardson #define RTE_ETH_FLOW_PORT               18
49799a2dd95SBruce Richardson #define RTE_ETH_FLOW_VXLAN              19 /**< VXLAN protocol based flow */
49899a2dd95SBruce Richardson #define RTE_ETH_FLOW_GENEVE             20 /**< GENEVE protocol based flow */
49999a2dd95SBruce Richardson #define RTE_ETH_FLOW_NVGRE              21 /**< NVGRE protocol based flow */
50099a2dd95SBruce Richardson #define RTE_ETH_FLOW_VXLAN_GPE          22 /**< VXLAN-GPE protocol based flow */
50199a2dd95SBruce Richardson #define RTE_ETH_FLOW_GTPU               23 /**< GTPU protocol based flow */
50299a2dd95SBruce Richardson #define RTE_ETH_FLOW_MAX                24
50399a2dd95SBruce Richardson 
50499a2dd95SBruce Richardson /*
50599a2dd95SBruce Richardson  * Below macros are defined for RSS offload types, they can be used to
50699a2dd95SBruce Richardson  * fill rte_eth_rss_conf.rss_hf or rte_flow_action_rss.types.
50799a2dd95SBruce Richardson  */
508295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV4               RTE_BIT64(2)
509295968d1SFerruh Yigit #define RTE_ETH_RSS_FRAG_IPV4          RTE_BIT64(3)
510295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV4_TCP   RTE_BIT64(4)
511295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV4_UDP   RTE_BIT64(5)
512295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV4_SCTP  RTE_BIT64(6)
513295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV4_OTHER RTE_BIT64(7)
514295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6               RTE_BIT64(8)
515295968d1SFerruh Yigit #define RTE_ETH_RSS_FRAG_IPV6          RTE_BIT64(9)
516295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV6_TCP   RTE_BIT64(10)
517295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV6_UDP   RTE_BIT64(11)
518295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV6_SCTP  RTE_BIT64(12)
519295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV6_OTHER RTE_BIT64(13)
520295968d1SFerruh Yigit #define RTE_ETH_RSS_L2_PAYLOAD         RTE_BIT64(14)
521295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_EX            RTE_BIT64(15)
522295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_TCP_EX        RTE_BIT64(16)
523295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_UDP_EX        RTE_BIT64(17)
524295968d1SFerruh Yigit #define RTE_ETH_RSS_PORT               RTE_BIT64(18)
525295968d1SFerruh Yigit #define RTE_ETH_RSS_VXLAN              RTE_BIT64(19)
526295968d1SFerruh Yigit #define RTE_ETH_RSS_GENEVE             RTE_BIT64(20)
527295968d1SFerruh Yigit #define RTE_ETH_RSS_NVGRE              RTE_BIT64(21)
528295968d1SFerruh Yigit #define RTE_ETH_RSS_GTPU               RTE_BIT64(23)
529295968d1SFerruh Yigit #define RTE_ETH_RSS_ETH                RTE_BIT64(24)
530295968d1SFerruh Yigit #define RTE_ETH_RSS_S_VLAN             RTE_BIT64(25)
531295968d1SFerruh Yigit #define RTE_ETH_RSS_C_VLAN             RTE_BIT64(26)
532295968d1SFerruh Yigit #define RTE_ETH_RSS_ESP                RTE_BIT64(27)
533295968d1SFerruh Yigit #define RTE_ETH_RSS_AH                 RTE_BIT64(28)
534295968d1SFerruh Yigit #define RTE_ETH_RSS_L2TPV3             RTE_BIT64(29)
535295968d1SFerruh Yigit #define RTE_ETH_RSS_PFCP               RTE_BIT64(30)
536295968d1SFerruh Yigit #define RTE_ETH_RSS_PPPOE              RTE_BIT64(31)
537295968d1SFerruh Yigit #define RTE_ETH_RSS_ECPRI              RTE_BIT64(32)
538295968d1SFerruh Yigit #define RTE_ETH_RSS_MPLS               RTE_BIT64(33)
539295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV4_CHKSUM        RTE_BIT64(34)
540b1cb3035SFerruh Yigit 
54181b0fbb8SAlvin Zhang /**
542683f93efSAndrew Rybchenko  * The RTE_ETH_RSS_L4_CHKSUM works on checksum field of any L4 header.
543683f93efSAndrew Rybchenko  * It is similar to RTE_ETH_RSS_PORT that they don't specify the specific type of
54481b0fbb8SAlvin Zhang  * L4 header. This macro is defined to replace some specific L4 (TCP/UDP/SCTP)
54581b0fbb8SAlvin Zhang  * checksum type for constructing the use of RSS offload bits.
54681b0fbb8SAlvin Zhang  *
54781b0fbb8SAlvin Zhang  * Due to above reason, some old APIs (and configuration) don't support
548295968d1SFerruh Yigit  * RTE_ETH_RSS_L4_CHKSUM. The rte_flow RSS API supports it.
54981b0fbb8SAlvin Zhang  *
55081b0fbb8SAlvin Zhang  * For the case that checksum is not used in an UDP header,
55181b0fbb8SAlvin Zhang  * it takes the reserved value 0 as input for the hash function.
55281b0fbb8SAlvin Zhang  */
553295968d1SFerruh Yigit #define RTE_ETH_RSS_L4_CHKSUM          RTE_BIT64(35)
55499a2dd95SBruce Richardson 
555f840cf77SJie Wang #define RTE_ETH_RSS_L2TPV2             RTE_BIT64(36)
556f840cf77SJie Wang 
55799a2dd95SBruce Richardson /*
558295968d1SFerruh Yigit  * We use the following macros to combine with above RTE_ETH_RSS_* for
55999a2dd95SBruce Richardson  * more specific input set selection. These bits are defined starting
56099a2dd95SBruce Richardson  * from the high end of the 64 bits.
561295968d1SFerruh Yigit  * Note: If we use above RTE_ETH_RSS_* without SRC/DST_ONLY, it represents
56299a2dd95SBruce Richardson  * both SRC and DST are taken into account. If SRC_ONLY and DST_ONLY of
56399a2dd95SBruce Richardson  * the same level are used simultaneously, it is the same case as none of
56499a2dd95SBruce Richardson  * them are added.
56599a2dd95SBruce Richardson  */
566295968d1SFerruh Yigit #define RTE_ETH_RSS_L3_SRC_ONLY        RTE_BIT64(63)
567295968d1SFerruh Yigit #define RTE_ETH_RSS_L3_DST_ONLY        RTE_BIT64(62)
568295968d1SFerruh Yigit #define RTE_ETH_RSS_L4_SRC_ONLY        RTE_BIT64(61)
569295968d1SFerruh Yigit #define RTE_ETH_RSS_L4_DST_ONLY        RTE_BIT64(60)
570295968d1SFerruh Yigit #define RTE_ETH_RSS_L2_SRC_ONLY        RTE_BIT64(59)
571295968d1SFerruh Yigit #define RTE_ETH_RSS_L2_DST_ONLY        RTE_BIT64(58)
572b1cb3035SFerruh Yigit 
57399a2dd95SBruce Richardson /*
57499a2dd95SBruce Richardson  * Only select IPV6 address prefix as RSS input set according to
575b1cb3035SFerruh Yigit  * https://tools.ietf.org/html/rfc6052
576295968d1SFerruh Yigit  * Must be combined with RTE_ETH_RSS_IPV6, RTE_ETH_RSS_NONFRAG_IPV6_UDP,
577295968d1SFerruh Yigit  * RTE_ETH_RSS_NONFRAG_IPV6_TCP, RTE_ETH_RSS_NONFRAG_IPV6_SCTP.
57899a2dd95SBruce Richardson  */
579e1823e08SThomas Monjalon #define RTE_ETH_RSS_L3_PRE32           RTE_BIT64(57)
580e1823e08SThomas Monjalon #define RTE_ETH_RSS_L3_PRE40           RTE_BIT64(56)
581e1823e08SThomas Monjalon #define RTE_ETH_RSS_L3_PRE48           RTE_BIT64(55)
582e1823e08SThomas Monjalon #define RTE_ETH_RSS_L3_PRE56           RTE_BIT64(54)
583e1823e08SThomas Monjalon #define RTE_ETH_RSS_L3_PRE64           RTE_BIT64(53)
584e1823e08SThomas Monjalon #define RTE_ETH_RSS_L3_PRE96           RTE_BIT64(52)
58599a2dd95SBruce Richardson 
58699a2dd95SBruce Richardson /*
58799a2dd95SBruce Richardson  * Use the following macros to combine with the above layers
58899a2dd95SBruce Richardson  * to choose inner and outer layers or both for RSS computation.
58999a2dd95SBruce Richardson  * Bits 50 and 51 are reserved for this.
59099a2dd95SBruce Richardson  */
59199a2dd95SBruce Richardson 
59299a2dd95SBruce Richardson /**
59399a2dd95SBruce Richardson  * level 0, requests the default behavior.
59499a2dd95SBruce Richardson  * Depending on the packet type, it can mean outermost, innermost,
59599a2dd95SBruce Richardson  * anything in between or even no RSS.
59699a2dd95SBruce Richardson  * It basically stands for the innermost encapsulation level RSS
59799a2dd95SBruce Richardson  * can be performed on according to PMD and device capabilities.
59899a2dd95SBruce Richardson  */
59968e8ca7bSAndrew Rybchenko #define RTE_ETH_RSS_LEVEL_PMD_DEFAULT  (UINT64_C(0) << 50)
60099a2dd95SBruce Richardson 
60199a2dd95SBruce Richardson /**
60299a2dd95SBruce Richardson  * level 1, requests RSS to be performed on the outermost packet
60399a2dd95SBruce Richardson  * encapsulation level.
60499a2dd95SBruce Richardson  */
60568e8ca7bSAndrew Rybchenko #define RTE_ETH_RSS_LEVEL_OUTERMOST    (UINT64_C(1) << 50)
60699a2dd95SBruce Richardson 
60799a2dd95SBruce Richardson /**
60899a2dd95SBruce Richardson  * level 2, requests RSS to be performed on the specified inner packet
60999a2dd95SBruce Richardson  * encapsulation level, from outermost to innermost (lower to higher values).
61099a2dd95SBruce Richardson  */
61168e8ca7bSAndrew Rybchenko #define RTE_ETH_RSS_LEVEL_INNERMOST    (UINT64_C(2) << 50)
61268e8ca7bSAndrew Rybchenko #define RTE_ETH_RSS_LEVEL_MASK         (UINT64_C(3) << 50)
613b1cb3035SFerruh Yigit 
614295968d1SFerruh Yigit #define RTE_ETH_RSS_LEVEL(rss_hf) ((rss_hf & RTE_ETH_RSS_LEVEL_MASK) >> 50)
61599a2dd95SBruce Richardson 
61699a2dd95SBruce Richardson /**
61799a2dd95SBruce Richardson  * For input set change of hash filter, if SRC_ONLY and DST_ONLY of
61899a2dd95SBruce Richardson  * the same level are used simultaneously, it is the same case as
61999a2dd95SBruce Richardson  * none of them are added.
62099a2dd95SBruce Richardson  *
62199a2dd95SBruce Richardson  * @param rss_hf
62299a2dd95SBruce Richardson  *   RSS types with SRC/DST_ONLY.
62399a2dd95SBruce Richardson  * @return
62499a2dd95SBruce Richardson  *   RSS types.
62599a2dd95SBruce Richardson  */
62699a2dd95SBruce Richardson static inline uint64_t
62799a2dd95SBruce Richardson rte_eth_rss_hf_refine(uint64_t rss_hf)
62899a2dd95SBruce Richardson {
629295968d1SFerruh Yigit 	if ((rss_hf & RTE_ETH_RSS_L3_SRC_ONLY) && (rss_hf & RTE_ETH_RSS_L3_DST_ONLY))
630295968d1SFerruh Yigit 		rss_hf &= ~(RTE_ETH_RSS_L3_SRC_ONLY | RTE_ETH_RSS_L3_DST_ONLY);
63199a2dd95SBruce Richardson 
632295968d1SFerruh Yigit 	if ((rss_hf & RTE_ETH_RSS_L4_SRC_ONLY) && (rss_hf & RTE_ETH_RSS_L4_DST_ONLY))
633295968d1SFerruh Yigit 		rss_hf &= ~(RTE_ETH_RSS_L4_SRC_ONLY | RTE_ETH_RSS_L4_DST_ONLY);
63499a2dd95SBruce Richardson 
63599a2dd95SBruce Richardson 	return rss_hf;
63699a2dd95SBruce Richardson }
63799a2dd95SBruce Richardson 
638295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE32 ( \
639295968d1SFerruh Yigit 		RTE_ETH_RSS_IPV6 | \
64099a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE32)
64199a2dd95SBruce Richardson 
642295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE40 ( \
643295968d1SFerruh Yigit 		RTE_ETH_RSS_IPV6 | \
64499a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE40)
64599a2dd95SBruce Richardson 
646295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE48 ( \
647295968d1SFerruh Yigit 		RTE_ETH_RSS_IPV6 | \
64899a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE48)
64999a2dd95SBruce Richardson 
650295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE56 ( \
651295968d1SFerruh Yigit 		RTE_ETH_RSS_IPV6 | \
65299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE56)
65399a2dd95SBruce Richardson 
654295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE64 ( \
655295968d1SFerruh Yigit 		RTE_ETH_RSS_IPV6 | \
65699a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE64)
65799a2dd95SBruce Richardson 
658295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE96 ( \
659295968d1SFerruh Yigit 		RTE_ETH_RSS_IPV6 | \
66099a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE96)
66199a2dd95SBruce Richardson 
662295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE32_UDP ( \
663295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
66499a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE32)
66599a2dd95SBruce Richardson 
666295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE40_UDP ( \
667295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
66899a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE40)
66999a2dd95SBruce Richardson 
670295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE48_UDP ( \
671295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
67299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE48)
67399a2dd95SBruce Richardson 
674295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE56_UDP ( \
675295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
67699a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE56)
67799a2dd95SBruce Richardson 
678295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE64_UDP ( \
679295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
68099a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE64)
68199a2dd95SBruce Richardson 
682295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE96_UDP ( \
683295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
68499a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE96)
68599a2dd95SBruce Richardson 
686295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE32_TCP ( \
687295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
68899a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE32)
68999a2dd95SBruce Richardson 
690295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE40_TCP ( \
691295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
69299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE40)
69399a2dd95SBruce Richardson 
694295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE48_TCP ( \
695295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
69699a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE48)
69799a2dd95SBruce Richardson 
698295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE56_TCP ( \
699295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
70099a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE56)
70199a2dd95SBruce Richardson 
702295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE64_TCP ( \
703295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
70499a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE64)
70599a2dd95SBruce Richardson 
706295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE96_TCP ( \
707295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
70899a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE96)
70999a2dd95SBruce Richardson 
710295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE32_SCTP ( \
711295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
71299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE32)
71399a2dd95SBruce Richardson 
714295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE40_SCTP ( \
715295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
71699a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE40)
71799a2dd95SBruce Richardson 
718295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE48_SCTP ( \
719295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
72099a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE48)
72199a2dd95SBruce Richardson 
722295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE56_SCTP ( \
723295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
72499a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE56)
72599a2dd95SBruce Richardson 
726295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE64_SCTP ( \
727295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
72899a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE64)
72999a2dd95SBruce Richardson 
730295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE96_SCTP ( \
731295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
73299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE96)
73399a2dd95SBruce Richardson 
734295968d1SFerruh Yigit #define RTE_ETH_RSS_IP ( \
735295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV4 | \
736295968d1SFerruh Yigit 	RTE_ETH_RSS_FRAG_IPV4 | \
737295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_OTHER | \
738295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6 | \
739295968d1SFerruh Yigit 	RTE_ETH_RSS_FRAG_IPV6 | \
740295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \
741295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6_EX)
74299a2dd95SBruce Richardson 
743295968d1SFerruh Yigit #define RTE_ETH_RSS_UDP ( \
744295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
745295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
746295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6_UDP_EX)
74799a2dd95SBruce Richardson 
748295968d1SFerruh Yigit #define RTE_ETH_RSS_TCP ( \
749295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
750295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
751295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6_TCP_EX)
75299a2dd95SBruce Richardson 
753295968d1SFerruh Yigit #define RTE_ETH_RSS_SCTP ( \
754295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_SCTP | \
755295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_SCTP)
75699a2dd95SBruce Richardson 
757295968d1SFerruh Yigit #define RTE_ETH_RSS_TUNNEL ( \
758295968d1SFerruh Yigit 	RTE_ETH_RSS_VXLAN  | \
759295968d1SFerruh Yigit 	RTE_ETH_RSS_GENEVE | \
760295968d1SFerruh Yigit 	RTE_ETH_RSS_NVGRE)
76199a2dd95SBruce Richardson 
762295968d1SFerruh Yigit #define RTE_ETH_RSS_VLAN ( \
763295968d1SFerruh Yigit 	RTE_ETH_RSS_S_VLAN  | \
764295968d1SFerruh Yigit 	RTE_ETH_RSS_C_VLAN)
76599a2dd95SBruce Richardson 
7663c2ca0a9SAndrew Rybchenko /** Mask of valid RSS hash protocols */
767295968d1SFerruh Yigit #define RTE_ETH_RSS_PROTO_MASK ( \
768295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV4 | \
769295968d1SFerruh Yigit 	RTE_ETH_RSS_FRAG_IPV4 | \
770295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
771295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
772295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_SCTP | \
773295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_OTHER | \
774295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6 | \
775295968d1SFerruh Yigit 	RTE_ETH_RSS_FRAG_IPV6 | \
776295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
777295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
778295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
779295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \
780295968d1SFerruh Yigit 	RTE_ETH_RSS_L2_PAYLOAD | \
781295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6_EX | \
782295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6_TCP_EX | \
783295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6_UDP_EX | \
784295968d1SFerruh Yigit 	RTE_ETH_RSS_PORT  | \
785295968d1SFerruh Yigit 	RTE_ETH_RSS_VXLAN | \
786295968d1SFerruh Yigit 	RTE_ETH_RSS_GENEVE | \
787295968d1SFerruh Yigit 	RTE_ETH_RSS_NVGRE | \
788295968d1SFerruh Yigit 	RTE_ETH_RSS_MPLS)
78999a2dd95SBruce Richardson 
79099a2dd95SBruce Richardson /*
79199a2dd95SBruce Richardson  * Definitions used for redirection table entry size.
79299a2dd95SBruce Richardson  * Some RSS RETA sizes may not be supported by some drivers, check the
79399a2dd95SBruce Richardson  * documentation or the description of relevant functions for more details.
79499a2dd95SBruce Richardson  */
795295968d1SFerruh Yigit #define RTE_ETH_RSS_RETA_SIZE_64  64
796295968d1SFerruh Yigit #define RTE_ETH_RSS_RETA_SIZE_128 128
797295968d1SFerruh Yigit #define RTE_ETH_RSS_RETA_SIZE_256 256
798295968d1SFerruh Yigit #define RTE_ETH_RSS_RETA_SIZE_512 512
799295968d1SFerruh Yigit #define RTE_ETH_RETA_GROUP_SIZE   64
800b1cb3035SFerruh Yigit 
8010ce56b05SThomas Monjalon /**@{@name VMDq and DCB maximums */
802295968d1SFerruh Yigit #define RTE_ETH_VMDQ_MAX_VLAN_FILTERS   64 /**< Maximum nb. of VMDq VLAN filters. */
803295968d1SFerruh Yigit #define RTE_ETH_DCB_NUM_USER_PRIORITIES 8  /**< Maximum nb. of DCB priorities. */
804295968d1SFerruh Yigit #define RTE_ETH_VMDQ_DCB_NUM_QUEUES     128 /**< Maximum nb. of VMDq DCB queues. */
805295968d1SFerruh Yigit #define RTE_ETH_DCB_NUM_QUEUES          128 /**< Maximum nb. of DCB queues. */
8060ce56b05SThomas Monjalon /**@}*/
80799a2dd95SBruce Richardson 
8080ce56b05SThomas Monjalon /**@{@name DCB capabilities */
8094852c647SAndrew Rybchenko #define RTE_ETH_DCB_PG_SUPPORT      RTE_BIT32(0) /**< Priority Group(ETS) support. */
8104852c647SAndrew Rybchenko #define RTE_ETH_DCB_PFC_SUPPORT     RTE_BIT32(1) /**< Priority Flow Control support. */
8110ce56b05SThomas Monjalon /**@}*/
81299a2dd95SBruce Richardson 
8130ce56b05SThomas Monjalon /**@{@name VLAN offload bits */
814295968d1SFerruh Yigit #define RTE_ETH_VLAN_STRIP_OFFLOAD   0x0001 /**< VLAN Strip  On/Off */
815295968d1SFerruh Yigit #define RTE_ETH_VLAN_FILTER_OFFLOAD  0x0002 /**< VLAN Filter On/Off */
816295968d1SFerruh Yigit #define RTE_ETH_VLAN_EXTEND_OFFLOAD  0x0004 /**< VLAN Extend On/Off */
817295968d1SFerruh Yigit #define RTE_ETH_QINQ_STRIP_OFFLOAD   0x0008 /**< QINQ Strip On/Off */
818b1cb3035SFerruh Yigit 
819295968d1SFerruh Yigit #define RTE_ETH_VLAN_STRIP_MASK      0x0001 /**< VLAN Strip  setting mask */
820295968d1SFerruh Yigit #define RTE_ETH_VLAN_FILTER_MASK     0x0002 /**< VLAN Filter  setting mask*/
821295968d1SFerruh Yigit #define RTE_ETH_VLAN_EXTEND_MASK     0x0004 /**< VLAN Extend  setting mask*/
822295968d1SFerruh Yigit #define RTE_ETH_QINQ_STRIP_MASK      0x0008 /**< QINQ Strip  setting mask */
823295968d1SFerruh Yigit #define RTE_ETH_VLAN_ID_MAX          0x0FFF /**< VLAN ID is in lower 12 bits*/
8240ce56b05SThomas Monjalon /**@}*/
82599a2dd95SBruce Richardson 
82699a2dd95SBruce Richardson /* Definitions used for receive MAC address   */
827295968d1SFerruh Yigit #define RTE_ETH_NUM_RECEIVE_MAC_ADDR   128 /**< Maximum nb. of receive mac addr. */
82899a2dd95SBruce Richardson 
82999a2dd95SBruce Richardson /* Definitions used for unicast hash  */
830295968d1SFerruh Yigit #define RTE_ETH_VMDQ_NUM_UC_HASH_ARRAY 128 /**< Maximum nb. of UC hash array. */
83199a2dd95SBruce Richardson 
8320ce56b05SThomas Monjalon /**@{@name VMDq Rx mode
8330ce56b05SThomas Monjalon  * @see rte_eth_vmdq_rx_conf.rx_mode
8340ce56b05SThomas Monjalon  */
8354852c647SAndrew Rybchenko /** Accept untagged packets. */
8364852c647SAndrew Rybchenko #define RTE_ETH_VMDQ_ACCEPT_UNTAG      RTE_BIT32(0)
8374852c647SAndrew Rybchenko /** Accept packets in multicast table. */
8384852c647SAndrew Rybchenko #define RTE_ETH_VMDQ_ACCEPT_HASH_MC    RTE_BIT32(1)
8394852c647SAndrew Rybchenko /** Accept packets in unicast table. */
8404852c647SAndrew Rybchenko #define RTE_ETH_VMDQ_ACCEPT_HASH_UC    RTE_BIT32(2)
8414852c647SAndrew Rybchenko /** Accept broadcast packets. */
8424852c647SAndrew Rybchenko #define RTE_ETH_VMDQ_ACCEPT_BROADCAST  RTE_BIT32(3)
8434852c647SAndrew Rybchenko /** Multicast promiscuous. */
8444852c647SAndrew Rybchenko #define RTE_ETH_VMDQ_ACCEPT_MULTICAST  RTE_BIT32(4)
8450ce56b05SThomas Monjalon /**@}*/
84699a2dd95SBruce Richardson 
84799a2dd95SBruce Richardson /**
84899a2dd95SBruce Richardson  * A structure used to configure 64 entries of Redirection Table of the
84999a2dd95SBruce Richardson  * Receive Side Scaling (RSS) feature of an Ethernet port. To configure
85099a2dd95SBruce Richardson  * more than 64 entries supported by hardware, an array of this structure
85199a2dd95SBruce Richardson  * is needed.
85299a2dd95SBruce Richardson  */
85399a2dd95SBruce Richardson struct rte_eth_rss_reta_entry64 {
8543c2ca0a9SAndrew Rybchenko 	/** Mask bits indicate which entries need to be updated/queried. */
85599a2dd95SBruce Richardson 	uint64_t mask;
8563c2ca0a9SAndrew Rybchenko 	/** Group of 64 redirection table entries. */
857295968d1SFerruh Yigit 	uint16_t reta[RTE_ETH_RETA_GROUP_SIZE];
85899a2dd95SBruce Richardson };
85999a2dd95SBruce Richardson 
86099a2dd95SBruce Richardson /**
86199a2dd95SBruce Richardson  * This enum indicates the possible number of traffic classes
86299a2dd95SBruce Richardson  * in DCB configurations
86399a2dd95SBruce Richardson  */
86499a2dd95SBruce Richardson enum rte_eth_nb_tcs {
865295968d1SFerruh Yigit 	RTE_ETH_4_TCS = 4, /**< 4 TCs with DCB. */
866295968d1SFerruh Yigit 	RTE_ETH_8_TCS = 8  /**< 8 TCs with DCB. */
86799a2dd95SBruce Richardson };
86899a2dd95SBruce Richardson 
86999a2dd95SBruce Richardson /**
87099a2dd95SBruce Richardson  * This enum indicates the possible number of queue pools
871064e90c4SAndrew Rybchenko  * in VMDq configurations.
87299a2dd95SBruce Richardson  */
87399a2dd95SBruce Richardson enum rte_eth_nb_pools {
874295968d1SFerruh Yigit 	RTE_ETH_8_POOLS = 8,    /**< 8 VMDq pools. */
875295968d1SFerruh Yigit 	RTE_ETH_16_POOLS = 16,  /**< 16 VMDq pools. */
876295968d1SFerruh Yigit 	RTE_ETH_32_POOLS = 32,  /**< 32 VMDq pools. */
877295968d1SFerruh Yigit 	RTE_ETH_64_POOLS = 64   /**< 64 VMDq pools. */
87899a2dd95SBruce Richardson };
87999a2dd95SBruce Richardson 
88099a2dd95SBruce Richardson /* This structure may be extended in future. */
88199a2dd95SBruce Richardson struct rte_eth_dcb_rx_conf {
88299a2dd95SBruce Richardson 	enum rte_eth_nb_tcs nb_tcs; /**< Possible DCB TCs, 4 or 8 TCs */
88399a2dd95SBruce Richardson 	/** Traffic class each UP mapped to. */
884295968d1SFerruh Yigit 	uint8_t dcb_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES];
88599a2dd95SBruce Richardson };
88699a2dd95SBruce Richardson 
88799a2dd95SBruce Richardson struct rte_eth_vmdq_dcb_tx_conf {
88899a2dd95SBruce Richardson 	enum rte_eth_nb_pools nb_queue_pools; /**< With DCB, 16 or 32 pools. */
88999a2dd95SBruce Richardson 	/** Traffic class each UP mapped to. */
890295968d1SFerruh Yigit 	uint8_t dcb_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES];
89199a2dd95SBruce Richardson };
89299a2dd95SBruce Richardson 
89399a2dd95SBruce Richardson struct rte_eth_dcb_tx_conf {
89499a2dd95SBruce Richardson 	enum rte_eth_nb_tcs nb_tcs; /**< Possible DCB TCs, 4 or 8 TCs. */
89599a2dd95SBruce Richardson 	/** Traffic class each UP mapped to. */
896295968d1SFerruh Yigit 	uint8_t dcb_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES];
89799a2dd95SBruce Richardson };
89899a2dd95SBruce Richardson 
89999a2dd95SBruce Richardson struct rte_eth_vmdq_tx_conf {
90099a2dd95SBruce Richardson 	enum rte_eth_nb_pools nb_queue_pools; /**< VMDq mode, 64 pools. */
90199a2dd95SBruce Richardson };
90299a2dd95SBruce Richardson 
90399a2dd95SBruce Richardson /**
904064e90c4SAndrew Rybchenko  * A structure used to configure the VMDq+DCB feature
90599a2dd95SBruce Richardson  * of an Ethernet port.
90699a2dd95SBruce Richardson  *
90799a2dd95SBruce Richardson  * Using this feature, packets are routed to a pool of queues, based
9085b49ba65SAndrew Rybchenko  * on the VLAN ID in the VLAN tag, and then to a specific queue within
9095b49ba65SAndrew Rybchenko  * that pool, using the user priority VLAN tag field.
91099a2dd95SBruce Richardson  *
91199a2dd95SBruce Richardson  * A default pool may be used, if desired, to route all traffic which
9125b49ba65SAndrew Rybchenko  * does not match the VLAN filter rules.
91399a2dd95SBruce Richardson  */
91499a2dd95SBruce Richardson struct rte_eth_vmdq_dcb_conf {
91599a2dd95SBruce Richardson 	enum rte_eth_nb_pools nb_queue_pools; /**< With DCB, 16 or 32 pools */
91699a2dd95SBruce Richardson 	uint8_t enable_default_pool; /**< If non-zero, use a default pool */
91799a2dd95SBruce Richardson 	uint8_t default_pool; /**< The default pool, if applicable */
91899a2dd95SBruce Richardson 	uint8_t nb_pool_maps; /**< We can have up to 64 filters/mappings */
91999a2dd95SBruce Richardson 	struct {
9205b49ba65SAndrew Rybchenko 		uint16_t vlan_id; /**< The VLAN ID of the received frame */
92109fd4227SAndrew Rybchenko 		uint64_t pools;   /**< Bitmask of pools for packet Rx */
922295968d1SFerruh Yigit 	} pool_map[RTE_ETH_VMDQ_MAX_VLAN_FILTERS]; /**< VMDq VLAN pool maps. */
9233c2ca0a9SAndrew Rybchenko 	/** Selects a queue in a pool */
924295968d1SFerruh Yigit 	uint8_t dcb_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES];
92599a2dd95SBruce Richardson };
92699a2dd95SBruce Richardson 
92799a2dd95SBruce Richardson /**
928064e90c4SAndrew Rybchenko  * A structure used to configure the VMDq feature of an Ethernet port when
92999a2dd95SBruce Richardson  * not combined with the DCB feature.
93099a2dd95SBruce Richardson  *
93199a2dd95SBruce Richardson  * Using this feature, packets are routed to a pool of queues. By default,
9325b49ba65SAndrew Rybchenko  * the pool selection is based on the MAC address, the VLAN ID in the
9335b49ba65SAndrew Rybchenko  * VLAN tag as specified in the pool_map array.
934295968d1SFerruh Yigit  * Passing the RTE_ETH_VMDQ_ACCEPT_UNTAG in the rx_mode field allows pool
93599a2dd95SBruce Richardson  * selection using only the MAC address. MAC address to pool mapping is done
93699a2dd95SBruce Richardson  * using the rte_eth_dev_mac_addr_add function, with the pool parameter
9375906be5aSAndrew Rybchenko  * corresponding to the pool ID.
93899a2dd95SBruce Richardson  *
93999a2dd95SBruce Richardson  * Queue selection within the selected pool will be done using RSS when
94099a2dd95SBruce Richardson  * it is enabled or revert to the first queue of the pool if not.
94199a2dd95SBruce Richardson  *
94299a2dd95SBruce Richardson  * A default pool may be used, if desired, to route all traffic which
9435b49ba65SAndrew Rybchenko  * does not match the VLAN filter rules or any pool MAC address.
94499a2dd95SBruce Richardson  */
94599a2dd95SBruce Richardson struct rte_eth_vmdq_rx_conf {
94699a2dd95SBruce Richardson 	enum rte_eth_nb_pools nb_queue_pools; /**< VMDq only mode, 8 or 64 pools */
94799a2dd95SBruce Richardson 	uint8_t enable_default_pool; /**< If non-zero, use a default pool */
94899a2dd95SBruce Richardson 	uint8_t default_pool; /**< The default pool, if applicable */
94999a2dd95SBruce Richardson 	uint8_t enable_loop_back; /**< Enable VT loop back */
95099a2dd95SBruce Richardson 	uint8_t nb_pool_maps; /**< We can have up to 64 filters/mappings */
951935b9a43SAndrew Rybchenko 	uint32_t rx_mode; /**< Flags from RTE_ETH_VMDQ_ACCEPT_* */
95299a2dd95SBruce Richardson 	struct {
9535b49ba65SAndrew Rybchenko 		uint16_t vlan_id; /**< The VLAN ID of the received frame */
95409fd4227SAndrew Rybchenko 		uint64_t pools;   /**< Bitmask of pools for packet Rx */
955295968d1SFerruh Yigit 	} pool_map[RTE_ETH_VMDQ_MAX_VLAN_FILTERS]; /**< VMDq VLAN pool maps. */
95699a2dd95SBruce Richardson };
95799a2dd95SBruce Richardson 
95899a2dd95SBruce Richardson /**
95909fd4227SAndrew Rybchenko  * A structure used to configure the Tx features of an Ethernet port.
96099a2dd95SBruce Richardson  */
96199a2dd95SBruce Richardson struct rte_eth_txmode {
96209fd4227SAndrew Rybchenko 	enum rte_eth_tx_mq_mode mq_mode; /**< Tx multi-queues mode. */
96399a2dd95SBruce Richardson 	/**
964295968d1SFerruh Yigit 	 * Per-port Tx offloads to be set using RTE_ETH_TX_OFFLOAD_* flags.
96599a2dd95SBruce Richardson 	 * Only offloads set on tx_offload_capa field on rte_eth_dev_info
96699a2dd95SBruce Richardson 	 * structure are allowed to be set.
96799a2dd95SBruce Richardson 	 */
96899a2dd95SBruce Richardson 	uint64_t offloads;
96999a2dd95SBruce Richardson 
97099a2dd95SBruce Richardson 	uint16_t pvid;
97199a2dd95SBruce Richardson 	__extension__
9723c2ca0a9SAndrew Rybchenko 	uint8_t /** If set, reject sending out tagged pkts */
9733c2ca0a9SAndrew Rybchenko 		hw_vlan_reject_tagged : 1,
9743c2ca0a9SAndrew Rybchenko 		/** If set, reject sending out untagged pkts */
97599a2dd95SBruce Richardson 		hw_vlan_reject_untagged : 1,
9763c2ca0a9SAndrew Rybchenko 		/** If set, enable port based VLAN insertion */
97799a2dd95SBruce Richardson 		hw_vlan_insert_pvid : 1;
97899a2dd95SBruce Richardson 
97999a2dd95SBruce Richardson 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
98099a2dd95SBruce Richardson 	void *reserved_ptrs[2];   /**< Reserved for future fields */
98199a2dd95SBruce Richardson };
98299a2dd95SBruce Richardson 
98399a2dd95SBruce Richardson /**
98499a2dd95SBruce Richardson  * @warning
98599a2dd95SBruce Richardson  * @b EXPERIMENTAL: this structure may change without prior notice.
98699a2dd95SBruce Richardson  *
98799a2dd95SBruce Richardson  * A structure used to configure an Rx packet segment to split.
98899a2dd95SBruce Richardson  *
98999a2dd95SBruce Richardson  * If RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag is set in offloads field,
99099a2dd95SBruce Richardson  * the PMD will split the received packets into multiple segments
99199a2dd95SBruce Richardson  * according to the specification in the description array:
99299a2dd95SBruce Richardson  *
99399a2dd95SBruce Richardson  * - The first network buffer will be allocated from the memory pool,
99499a2dd95SBruce Richardson  *   specified in the first array element, the second buffer, from the
99599a2dd95SBruce Richardson  *   pool in the second element, and so on.
99699a2dd95SBruce Richardson  *
99799a2dd95SBruce Richardson  * - The offsets from the segment description elements specify
99899a2dd95SBruce Richardson  *   the data offset from the buffer beginning except the first mbuf.
99999a2dd95SBruce Richardson  *   The first segment offset is added with RTE_PKTMBUF_HEADROOM.
100099a2dd95SBruce Richardson  *
100199a2dd95SBruce Richardson  * - The lengths in the elements define the maximal data amount
100299a2dd95SBruce Richardson  *   being received to each segment. The receiving starts with filling
100399a2dd95SBruce Richardson  *   up the first mbuf data buffer up to specified length. If the
100499a2dd95SBruce Richardson  *   there are data remaining (packet is longer than buffer in the first
100599a2dd95SBruce Richardson  *   mbuf) the following data will be pushed to the next segment
100699a2dd95SBruce Richardson  *   up to its own length, and so on.
100799a2dd95SBruce Richardson  *
100899a2dd95SBruce Richardson  * - If the length in the segment description element is zero
100999a2dd95SBruce Richardson  *   the actual buffer size will be deduced from the appropriate
101099a2dd95SBruce Richardson  *   memory pool properties.
101199a2dd95SBruce Richardson  *
101299a2dd95SBruce Richardson  * - If there is not enough elements to describe the buffer for entire
101399a2dd95SBruce Richardson  *   packet of maximal length the following parameters will be used
101499a2dd95SBruce Richardson  *   for the all remaining segments:
101599a2dd95SBruce Richardson  *     - pool from the last valid element
101699a2dd95SBruce Richardson  *     - the buffer size from this pool
101799a2dd95SBruce Richardson  *     - zero offset
101899a2dd95SBruce Richardson  */
101999a2dd95SBruce Richardson struct rte_eth_rxseg_split {
102099a2dd95SBruce Richardson 	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
102199a2dd95SBruce Richardson 	uint16_t length; /**< Segment data length, configures split point. */
102299a2dd95SBruce Richardson 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
102399a2dd95SBruce Richardson 	uint32_t reserved; /**< Reserved field. */
102499a2dd95SBruce Richardson };
102599a2dd95SBruce Richardson 
102699a2dd95SBruce Richardson /**
102799a2dd95SBruce Richardson  * @warning
102899a2dd95SBruce Richardson  * @b EXPERIMENTAL: this structure may change without prior notice.
102999a2dd95SBruce Richardson  *
103099a2dd95SBruce Richardson  * A common structure used to describe Rx packet segment properties.
103199a2dd95SBruce Richardson  */
103299a2dd95SBruce Richardson union rte_eth_rxseg {
103399a2dd95SBruce Richardson 	/* The settings for buffer split offload. */
103499a2dd95SBruce Richardson 	struct rte_eth_rxseg_split split;
103599a2dd95SBruce Richardson 	/* The other features settings should be added here. */
103699a2dd95SBruce Richardson };
103799a2dd95SBruce Richardson 
103899a2dd95SBruce Richardson /**
103909fd4227SAndrew Rybchenko  * A structure used to configure an Rx ring of an Ethernet port.
104099a2dd95SBruce Richardson  */
104199a2dd95SBruce Richardson struct rte_eth_rxconf {
104209fd4227SAndrew Rybchenko 	struct rte_eth_thresh rx_thresh; /**< Rx ring threshold registers. */
104309fd4227SAndrew Rybchenko 	uint16_t rx_free_thresh; /**< Drives the freeing of Rx descriptors. */
104499a2dd95SBruce Richardson 	uint8_t rx_drop_en; /**< Drop packets if no descriptors are available. */
104599a2dd95SBruce Richardson 	uint8_t rx_deferred_start; /**< Do not start queue with rte_eth_dev_start(). */
104699a2dd95SBruce Richardson 	uint16_t rx_nseg; /**< Number of descriptions in rx_seg array. */
104799a2dd95SBruce Richardson 	/**
1048dd22740cSXueming Li 	 * Share group index in Rx domain and switch domain.
1049dd22740cSXueming Li 	 * Non-zero value to enable Rx queue share, zero value disable share.
1050dd22740cSXueming Li 	 * PMD is responsible for Rx queue consistency checks to avoid member
1051dd22740cSXueming Li 	 * port's configuration contradict to each other.
1052dd22740cSXueming Li 	 */
1053dd22740cSXueming Li 	uint16_t share_group;
1054dd22740cSXueming Li 	uint16_t share_qid; /**< Shared Rx queue ID in group */
1055dd22740cSXueming Li 	/**
1056295968d1SFerruh Yigit 	 * Per-queue Rx offloads to be set using RTE_ETH_RX_OFFLOAD_* flags.
105799a2dd95SBruce Richardson 	 * Only offloads set on rx_queue_offload_capa or rx_offload_capa
105899a2dd95SBruce Richardson 	 * fields on rte_eth_dev_info structure are allowed to be set.
105999a2dd95SBruce Richardson 	 */
106099a2dd95SBruce Richardson 	uint64_t offloads;
106199a2dd95SBruce Richardson 	/**
106299a2dd95SBruce Richardson 	 * Points to the array of segment descriptions for an entire packet.
106399a2dd95SBruce Richardson 	 * Array elements are properties for consecutive Rx segments.
106499a2dd95SBruce Richardson 	 *
106599a2dd95SBruce Richardson 	 * The supported capabilities of receiving segmentation is reported
106699a2dd95SBruce Richardson 	 * in rte_eth_dev_info.rx_seg_capa field.
106799a2dd95SBruce Richardson 	 */
106899a2dd95SBruce Richardson 	union rte_eth_rxseg *rx_seg;
106999a2dd95SBruce Richardson 
107099a2dd95SBruce Richardson 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
107199a2dd95SBruce Richardson 	void *reserved_ptrs[2];   /**< Reserved for future fields */
107299a2dd95SBruce Richardson };
107399a2dd95SBruce Richardson 
107499a2dd95SBruce Richardson /**
107509fd4227SAndrew Rybchenko  * A structure used to configure a Tx ring of an Ethernet port.
107699a2dd95SBruce Richardson  */
107799a2dd95SBruce Richardson struct rte_eth_txconf {
107809fd4227SAndrew Rybchenko 	struct rte_eth_thresh tx_thresh; /**< Tx ring threshold registers. */
107999a2dd95SBruce Richardson 	uint16_t tx_rs_thresh; /**< Drives the setting of RS bit on TXDs. */
108009fd4227SAndrew Rybchenko 	uint16_t tx_free_thresh; /**< Start freeing Tx buffers if there are
108199a2dd95SBruce Richardson 				      less free descriptors than this value. */
108299a2dd95SBruce Richardson 
108399a2dd95SBruce Richardson 	uint8_t tx_deferred_start; /**< Do not start queue with rte_eth_dev_start(). */
108499a2dd95SBruce Richardson 	/**
1085295968d1SFerruh Yigit 	 * Per-queue Tx offloads to be set  using RTE_ETH_TX_OFFLOAD_* flags.
108699a2dd95SBruce Richardson 	 * Only offloads set on tx_queue_offload_capa or tx_offload_capa
108799a2dd95SBruce Richardson 	 * fields on rte_eth_dev_info structure are allowed to be set.
108899a2dd95SBruce Richardson 	 */
108999a2dd95SBruce Richardson 	uint64_t offloads;
109099a2dd95SBruce Richardson 
109199a2dd95SBruce Richardson 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
109299a2dd95SBruce Richardson 	void *reserved_ptrs[2];   /**< Reserved for future fields */
109399a2dd95SBruce Richardson };
109499a2dd95SBruce Richardson 
109599a2dd95SBruce Richardson /**
109699a2dd95SBruce Richardson  * @warning
109799a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
109899a2dd95SBruce Richardson  *
109999a2dd95SBruce Richardson  * A structure used to return the hairpin capabilities that are supported.
110099a2dd95SBruce Richardson  */
110199a2dd95SBruce Richardson struct rte_eth_hairpin_cap {
110299a2dd95SBruce Richardson 	/** The max number of hairpin queues (different bindings). */
110399a2dd95SBruce Richardson 	uint16_t max_nb_queues;
110499a2dd95SBruce Richardson 	/** Max number of Rx queues to be connected to one Tx queue. */
110599a2dd95SBruce Richardson 	uint16_t max_rx_2_tx;
110699a2dd95SBruce Richardson 	/** Max number of Tx queues to be connected to one Rx queue. */
110799a2dd95SBruce Richardson 	uint16_t max_tx_2_rx;
110899a2dd95SBruce Richardson 	uint16_t max_nb_desc; /**< The max num of descriptors. */
110999a2dd95SBruce Richardson };
111099a2dd95SBruce Richardson 
111199a2dd95SBruce Richardson #define RTE_ETH_MAX_HAIRPIN_PEERS 32
111299a2dd95SBruce Richardson 
111399a2dd95SBruce Richardson /**
111499a2dd95SBruce Richardson  * @warning
111599a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
111699a2dd95SBruce Richardson  *
111799a2dd95SBruce Richardson  * A structure used to hold hairpin peer data.
111899a2dd95SBruce Richardson  */
111999a2dd95SBruce Richardson struct rte_eth_hairpin_peer {
112099a2dd95SBruce Richardson 	uint16_t port; /**< Peer port. */
112199a2dd95SBruce Richardson 	uint16_t queue; /**< Peer queue. */
112299a2dd95SBruce Richardson };
112399a2dd95SBruce Richardson 
112499a2dd95SBruce Richardson /**
112599a2dd95SBruce Richardson  * @warning
112699a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
112799a2dd95SBruce Richardson  *
112899a2dd95SBruce Richardson  * A structure used to configure hairpin binding.
112999a2dd95SBruce Richardson  */
113099a2dd95SBruce Richardson struct rte_eth_hairpin_conf {
113199a2dd95SBruce Richardson 	uint32_t peer_count:16; /**< The number of peers. */
113299a2dd95SBruce Richardson 
113399a2dd95SBruce Richardson 	/**
113499a2dd95SBruce Richardson 	 * Explicit Tx flow rule mode.
113599a2dd95SBruce Richardson 	 * One hairpin pair of queues should have the same attribute.
113699a2dd95SBruce Richardson 	 *
113799a2dd95SBruce Richardson 	 * - When set, the user should be responsible for inserting the hairpin
113899a2dd95SBruce Richardson 	 *   Tx part flows and removing them.
113999a2dd95SBruce Richardson 	 * - When clear, the PMD will try to handle the Tx part of the flows,
114099a2dd95SBruce Richardson 	 *   e.g., by splitting one flow into two parts.
114199a2dd95SBruce Richardson 	 */
114299a2dd95SBruce Richardson 	uint32_t tx_explicit:1;
114399a2dd95SBruce Richardson 
114499a2dd95SBruce Richardson 	/**
114599a2dd95SBruce Richardson 	 * Manually bind hairpin queues.
114699a2dd95SBruce Richardson 	 * One hairpin pair of queues should have the same attribute.
114799a2dd95SBruce Richardson 	 *
114899a2dd95SBruce Richardson 	 * - When set, to enable hairpin, the user should call the hairpin bind
114999a2dd95SBruce Richardson 	 *   function after all the queues are set up properly and the ports are
115099a2dd95SBruce Richardson 	 *   started. Also, the hairpin unbind function should be called
115199a2dd95SBruce Richardson 	 *   accordingly before stopping a port that with hairpin configured.
115299a2dd95SBruce Richardson 	 * - When clear, the PMD will try to enable the hairpin with the queues
115399a2dd95SBruce Richardson 	 *   configured automatically during port start.
115499a2dd95SBruce Richardson 	 */
115599a2dd95SBruce Richardson 	uint32_t manual_bind:1;
115699a2dd95SBruce Richardson 	uint32_t reserved:14; /**< Reserved bits. */
115799a2dd95SBruce Richardson 	struct rte_eth_hairpin_peer peers[RTE_ETH_MAX_HAIRPIN_PEERS];
115899a2dd95SBruce Richardson };
115999a2dd95SBruce Richardson 
116099a2dd95SBruce Richardson /**
116199a2dd95SBruce Richardson  * A structure contains information about HW descriptor ring limitations.
116299a2dd95SBruce Richardson  */
116399a2dd95SBruce Richardson struct rte_eth_desc_lim {
116499a2dd95SBruce Richardson 	uint16_t nb_max;   /**< Max allowed number of descriptors. */
116599a2dd95SBruce Richardson 	uint16_t nb_min;   /**< Min allowed number of descriptors. */
116699a2dd95SBruce Richardson 	uint16_t nb_align; /**< Number of descriptors should be aligned to. */
116799a2dd95SBruce Richardson 
116899a2dd95SBruce Richardson 	/**
116999a2dd95SBruce Richardson 	 * Max allowed number of segments per whole packet.
117099a2dd95SBruce Richardson 	 *
117199a2dd95SBruce Richardson 	 * - For TSO packet this is the total number of data descriptors allowed
117299a2dd95SBruce Richardson 	 *   by device.
117399a2dd95SBruce Richardson 	 *
117499a2dd95SBruce Richardson 	 * @see nb_mtu_seg_max
117599a2dd95SBruce Richardson 	 */
117699a2dd95SBruce Richardson 	uint16_t nb_seg_max;
117799a2dd95SBruce Richardson 
117899a2dd95SBruce Richardson 	/**
117999a2dd95SBruce Richardson 	 * Max number of segments per one MTU.
118099a2dd95SBruce Richardson 	 *
118199a2dd95SBruce Richardson 	 * - For non-TSO packet, this is the maximum allowed number of segments
118299a2dd95SBruce Richardson 	 *   in a single transmit packet.
118399a2dd95SBruce Richardson 	 *
118499a2dd95SBruce Richardson 	 * - For TSO packet each segment within the TSO may span up to this
118599a2dd95SBruce Richardson 	 *   value.
118699a2dd95SBruce Richardson 	 *
118799a2dd95SBruce Richardson 	 * @see nb_seg_max
118899a2dd95SBruce Richardson 	 */
118999a2dd95SBruce Richardson 	uint16_t nb_mtu_seg_max;
119099a2dd95SBruce Richardson };
119199a2dd95SBruce Richardson 
119299a2dd95SBruce Richardson /**
119399a2dd95SBruce Richardson  * This enum indicates the flow control mode
119499a2dd95SBruce Richardson  */
119599a2dd95SBruce Richardson enum rte_eth_fc_mode {
1196295968d1SFerruh Yigit 	RTE_ETH_FC_NONE = 0, /**< Disable flow control. */
1197295968d1SFerruh Yigit 	RTE_ETH_FC_RX_PAUSE, /**< Rx pause frame, enable flowctrl on Tx side. */
1198295968d1SFerruh Yigit 	RTE_ETH_FC_TX_PAUSE, /**< Tx pause frame, enable flowctrl on Rx side. */
1199295968d1SFerruh Yigit 	RTE_ETH_FC_FULL      /**< Enable flow control on both side. */
120099a2dd95SBruce Richardson };
1201295968d1SFerruh Yigit 
120299a2dd95SBruce Richardson /**
120399a2dd95SBruce Richardson  * A structure used to configure Ethernet flow control parameter.
120499a2dd95SBruce Richardson  * These parameters will be configured into the register of the NIC.
120599a2dd95SBruce Richardson  * Please refer to the corresponding data sheet for proper value.
120699a2dd95SBruce Richardson  */
120799a2dd95SBruce Richardson struct rte_eth_fc_conf {
120899a2dd95SBruce Richardson 	uint32_t high_water;  /**< High threshold value to trigger XOFF */
120999a2dd95SBruce Richardson 	uint32_t low_water;   /**< Low threshold value to trigger XON */
121099a2dd95SBruce Richardson 	uint16_t pause_time;  /**< Pause quota in the Pause frame */
121199a2dd95SBruce Richardson 	uint16_t send_xon;    /**< Is XON frame need be sent */
121299a2dd95SBruce Richardson 	enum rte_eth_fc_mode mode;  /**< Link flow control mode */
121399a2dd95SBruce Richardson 	uint8_t mac_ctrl_frame_fwd; /**< Forward MAC control frames */
121499a2dd95SBruce Richardson 	uint8_t autoneg;      /**< Use Pause autoneg */
121599a2dd95SBruce Richardson };
121699a2dd95SBruce Richardson 
121799a2dd95SBruce Richardson /**
121899a2dd95SBruce Richardson  * A structure used to configure Ethernet priority flow control parameter.
121999a2dd95SBruce Richardson  * These parameters will be configured into the register of the NIC.
122099a2dd95SBruce Richardson  * Please refer to the corresponding data sheet for proper value.
122199a2dd95SBruce Richardson  */
122299a2dd95SBruce Richardson struct rte_eth_pfc_conf {
122399a2dd95SBruce Richardson 	struct rte_eth_fc_conf fc; /**< General flow control parameter. */
122499a2dd95SBruce Richardson 	uint8_t priority;          /**< VLAN User Priority. */
122599a2dd95SBruce Richardson };
122699a2dd95SBruce Richardson 
122799a2dd95SBruce Richardson /**
12280de345e9SJerin Jacob  * @warning
12290de345e9SJerin Jacob  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
12300de345e9SJerin Jacob  *
12310de345e9SJerin Jacob  * A structure used to retrieve information of queue based PFC.
12320de345e9SJerin Jacob  */
12330de345e9SJerin Jacob struct rte_eth_pfc_queue_info {
12340de345e9SJerin Jacob 	/**
12350de345e9SJerin Jacob 	 * Maximum supported traffic class as per PFC (802.1Qbb) specification.
12360de345e9SJerin Jacob 	 */
12370de345e9SJerin Jacob 	uint8_t tc_max;
12380de345e9SJerin Jacob 	/** PFC queue mode capabilities. */
12390de345e9SJerin Jacob 	enum rte_eth_fc_mode mode_capa;
12400de345e9SJerin Jacob };
12410de345e9SJerin Jacob 
12420de345e9SJerin Jacob /**
12430de345e9SJerin Jacob  * @warning
12440de345e9SJerin Jacob  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
12450de345e9SJerin Jacob  *
12460de345e9SJerin Jacob  * A structure used to configure Ethernet priority flow control parameters for
12470de345e9SJerin Jacob  * ethdev queues.
12480de345e9SJerin Jacob  *
12490de345e9SJerin Jacob  * rte_eth_pfc_queue_conf::rx_pause structure shall be used to configure given
12500de345e9SJerin Jacob  * tx_qid with corresponding tc. When ethdev device receives PFC frame with
12510de345e9SJerin Jacob  * rte_eth_pfc_queue_conf::rx_pause::tc, traffic will be paused on
12520de345e9SJerin Jacob  * rte_eth_pfc_queue_conf::rx_pause::tx_qid for that tc.
12530de345e9SJerin Jacob  *
12540de345e9SJerin Jacob  * rte_eth_pfc_queue_conf::tx_pause structure shall be used to configure given
12550de345e9SJerin Jacob  * rx_qid. When rx_qid is congested, PFC frames are generated with
12560de345e9SJerin Jacob  * rte_eth_pfc_queue_conf::rx_pause::tc and
12570de345e9SJerin Jacob  * rte_eth_pfc_queue_conf::rx_pause::pause_time to the peer.
12580de345e9SJerin Jacob  */
12590de345e9SJerin Jacob struct rte_eth_pfc_queue_conf {
12600de345e9SJerin Jacob 	enum rte_eth_fc_mode mode; /**< Link flow control mode */
12610de345e9SJerin Jacob 
12620de345e9SJerin Jacob 	struct {
12630de345e9SJerin Jacob 		uint16_t tx_qid; /**< Tx queue ID */
12640de345e9SJerin Jacob 		/** Traffic class as per PFC (802.1Qbb) spec. The value must be
12650de345e9SJerin Jacob 		 * in the range [0, rte_eth_pfc_queue_info::tx_max - 1]
12660de345e9SJerin Jacob 		 */
12670de345e9SJerin Jacob 		uint8_t tc;
12680de345e9SJerin Jacob 	} rx_pause; /* Valid when (mode == FC_RX_PAUSE || mode == FC_FULL) */
12690de345e9SJerin Jacob 
12700de345e9SJerin Jacob 	struct {
12710de345e9SJerin Jacob 		uint16_t pause_time; /**< Pause quota in the Pause frame */
12720de345e9SJerin Jacob 		uint16_t rx_qid;     /**< Rx queue ID */
12730de345e9SJerin Jacob 		/** Traffic class as per PFC (802.1Qbb) spec. The value must be
12740de345e9SJerin Jacob 		 * in the range [0, rte_eth_pfc_queue_info::tx_max - 1]
12750de345e9SJerin Jacob 		 */
12760de345e9SJerin Jacob 		uint8_t tc;
12770de345e9SJerin Jacob 	} tx_pause; /* Valid when (mode == FC_TX_PAUSE || mode == FC_FULL) */
12780de345e9SJerin Jacob };
12790de345e9SJerin Jacob 
12800de345e9SJerin Jacob /**
128199a2dd95SBruce Richardson  * Tunnel type for device-specific classifier configuration.
128299a2dd95SBruce Richardson  * @see rte_eth_udp_tunnel
128399a2dd95SBruce Richardson  */
128499a2dd95SBruce Richardson enum rte_eth_tunnel_type {
1285295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_NONE = 0,
1286295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_VXLAN,
1287295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_GENEVE,
1288295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_TEREDO,
1289295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_NVGRE,
1290295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_IP_IN_GRE,
1291295968d1SFerruh Yigit 	RTE_ETH_L2_TUNNEL_TYPE_E_TAG,
1292295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_VXLAN_GPE,
1293295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_ECPRI,
1294295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_MAX,
129599a2dd95SBruce Richardson };
1296295968d1SFerruh Yigit 
129799a2dd95SBruce Richardson /* Deprecated API file for rte_eth_dev_filter_* functions */
129899a2dd95SBruce Richardson #include "rte_eth_ctrl.h"
129999a2dd95SBruce Richardson 
130099a2dd95SBruce Richardson /**
130199a2dd95SBruce Richardson  * UDP tunneling configuration.
130299a2dd95SBruce Richardson  *
130399a2dd95SBruce Richardson  * Used to configure the classifier of a device,
130499a2dd95SBruce Richardson  * associating an UDP port with a type of tunnel.
130599a2dd95SBruce Richardson  *
130699a2dd95SBruce Richardson  * Some NICs may need such configuration to properly parse a tunnel
130799a2dd95SBruce Richardson  * with any standard or custom UDP port.
130899a2dd95SBruce Richardson  */
130999a2dd95SBruce Richardson struct rte_eth_udp_tunnel {
131099a2dd95SBruce Richardson 	uint16_t udp_port; /**< UDP port used for the tunnel. */
131199a2dd95SBruce Richardson 	uint8_t prot_type; /**< Tunnel type. @see rte_eth_tunnel_type */
131299a2dd95SBruce Richardson };
131399a2dd95SBruce Richardson 
131499a2dd95SBruce Richardson /**
131599a2dd95SBruce Richardson  * A structure used to enable/disable specific device interrupts.
131699a2dd95SBruce Richardson  */
1317295968d1SFerruh Yigit struct rte_eth_intr_conf {
131899a2dd95SBruce Richardson 	/** enable/disable lsc interrupt. 0 (default) - disable, 1 enable */
131999a2dd95SBruce Richardson 	uint32_t lsc:1;
132099a2dd95SBruce Richardson 	/** enable/disable rxq interrupt. 0 (default) - disable, 1 enable */
132199a2dd95SBruce Richardson 	uint32_t rxq:1;
132299a2dd95SBruce Richardson 	/** enable/disable rmv interrupt. 0 (default) - disable, 1 enable */
132399a2dd95SBruce Richardson 	uint32_t rmv:1;
132499a2dd95SBruce Richardson };
132599a2dd95SBruce Richardson 
1326295968d1SFerruh Yigit #define rte_intr_conf rte_eth_intr_conf
1327295968d1SFerruh Yigit 
132899a2dd95SBruce Richardson /**
132999a2dd95SBruce Richardson  * A structure used to configure an Ethernet port.
133009fd4227SAndrew Rybchenko  * Depending upon the Rx multi-queue mode, extra advanced
133199a2dd95SBruce Richardson  * configuration settings may be needed.
133299a2dd95SBruce Richardson  */
133399a2dd95SBruce Richardson struct rte_eth_conf {
1334295968d1SFerruh Yigit 	uint32_t link_speeds; /**< bitmap of RTE_ETH_LINK_SPEED_XXX of speeds to be
1335295968d1SFerruh Yigit 				used. RTE_ETH_LINK_SPEED_FIXED disables link
133699a2dd95SBruce Richardson 				autonegotiation, and a unique speed shall be
133799a2dd95SBruce Richardson 				set. Otherwise, the bitmap defines the set of
133899a2dd95SBruce Richardson 				speeds to be advertised. If the special value
1339295968d1SFerruh Yigit 				RTE_ETH_LINK_SPEED_AUTONEG (0) is used, all speeds
134099a2dd95SBruce Richardson 				supported are advertised. */
134109fd4227SAndrew Rybchenko 	struct rte_eth_rxmode rxmode; /**< Port Rx configuration. */
134209fd4227SAndrew Rybchenko 	struct rte_eth_txmode txmode; /**< Port Tx configuration. */
134399a2dd95SBruce Richardson 	uint32_t lpbk_mode; /**< Loopback operation mode. By default the value
134499a2dd95SBruce Richardson 			         is 0, meaning the loopback mode is disabled.
13450d9f56a8SAndrew Rybchenko 				 Read the datasheet of given Ethernet controller
134699a2dd95SBruce Richardson 				 for details. The possible values of this field
134799a2dd95SBruce Richardson 				 are defined in implementation of each driver. */
134899a2dd95SBruce Richardson 	struct {
134999a2dd95SBruce Richardson 		struct rte_eth_rss_conf rss_conf; /**< Port RSS configuration */
1350064e90c4SAndrew Rybchenko 		/** Port VMDq+DCB configuration. */
135199a2dd95SBruce Richardson 		struct rte_eth_vmdq_dcb_conf vmdq_dcb_conf;
1352064e90c4SAndrew Rybchenko 		/** Port DCB Rx configuration. */
135399a2dd95SBruce Richardson 		struct rte_eth_dcb_rx_conf dcb_rx_conf;
1354064e90c4SAndrew Rybchenko 		/** Port VMDq Rx configuration. */
135599a2dd95SBruce Richardson 		struct rte_eth_vmdq_rx_conf vmdq_rx_conf;
135609fd4227SAndrew Rybchenko 	} rx_adv_conf; /**< Port Rx filtering configuration. */
135799a2dd95SBruce Richardson 	union {
1358064e90c4SAndrew Rybchenko 		/** Port VMDq+DCB Tx configuration. */
135999a2dd95SBruce Richardson 		struct rte_eth_vmdq_dcb_tx_conf vmdq_dcb_tx_conf;
1360064e90c4SAndrew Rybchenko 		/** Port DCB Tx configuration. */
136199a2dd95SBruce Richardson 		struct rte_eth_dcb_tx_conf dcb_tx_conf;
1362064e90c4SAndrew Rybchenko 		/** Port VMDq Tx configuration. */
136399a2dd95SBruce Richardson 		struct rte_eth_vmdq_tx_conf vmdq_tx_conf;
136409fd4227SAndrew Rybchenko 	} tx_adv_conf; /**< Port Tx DCB configuration (union). */
136599a2dd95SBruce Richardson 	/** Currently,Priority Flow Control(PFC) are supported,if DCB with PFC
1366295968d1SFerruh Yigit 	    is needed,and the variable must be set RTE_ETH_DCB_PFC_SUPPORT. */
136799a2dd95SBruce Richardson 	uint32_t dcb_capability_en;
1368295968d1SFerruh Yigit 	struct rte_eth_intr_conf intr_conf; /**< Interrupt mode configuration. */
136999a2dd95SBruce Richardson };
137099a2dd95SBruce Richardson 
137199a2dd95SBruce Richardson /**
137209fd4227SAndrew Rybchenko  * Rx offload capabilities of a device.
137399a2dd95SBruce Richardson  */
13744852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_VLAN_STRIP       RTE_BIT64(0)
13754852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_IPV4_CKSUM       RTE_BIT64(1)
13764852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_UDP_CKSUM        RTE_BIT64(2)
13774852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_TCP_CKSUM        RTE_BIT64(3)
13784852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_TCP_LRO          RTE_BIT64(4)
13794852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_QINQ_STRIP       RTE_BIT64(5)
13804852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM RTE_BIT64(6)
13814852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_MACSEC_STRIP     RTE_BIT64(7)
13824852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_HEADER_SPLIT     RTE_BIT64(8)
13834852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_VLAN_FILTER      RTE_BIT64(9)
13844852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_VLAN_EXTEND      RTE_BIT64(10)
13854852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_SCATTER          RTE_BIT64(13)
138699a2dd95SBruce Richardson /**
138799a2dd95SBruce Richardson  * Timestamp is set by the driver in RTE_MBUF_DYNFIELD_TIMESTAMP_NAME
138899a2dd95SBruce Richardson  * and RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME is set in ol_flags.
138999a2dd95SBruce Richardson  * The mbuf field and flag are registered when the offload is configured.
139099a2dd95SBruce Richardson  */
13914852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_TIMESTAMP        RTE_BIT64(14)
13924852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_SECURITY         RTE_BIT64(15)
13934852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_KEEP_CRC         RTE_BIT64(16)
13944852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_SCTP_CKSUM       RTE_BIT64(17)
13954852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM  RTE_BIT64(18)
13964852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_RSS_HASH         RTE_BIT64(19)
13974852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT     RTE_BIT64(20)
139899a2dd95SBruce Richardson 
1399295968d1SFerruh Yigit #define RTE_ETH_RX_OFFLOAD_CHECKSUM (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | \
1400295968d1SFerruh Yigit 				 RTE_ETH_RX_OFFLOAD_UDP_CKSUM | \
1401295968d1SFerruh Yigit 				 RTE_ETH_RX_OFFLOAD_TCP_CKSUM)
1402295968d1SFerruh Yigit #define RTE_ETH_RX_OFFLOAD_VLAN (RTE_ETH_RX_OFFLOAD_VLAN_STRIP | \
1403295968d1SFerruh Yigit 			     RTE_ETH_RX_OFFLOAD_VLAN_FILTER | \
1404295968d1SFerruh Yigit 			     RTE_ETH_RX_OFFLOAD_VLAN_EXTEND | \
1405295968d1SFerruh Yigit 			     RTE_ETH_RX_OFFLOAD_QINQ_STRIP)
140699a2dd95SBruce Richardson 
140799a2dd95SBruce Richardson /*
140899a2dd95SBruce Richardson  * If new Rx offload capabilities are defined, they also must be
140999a2dd95SBruce Richardson  * mentioned in rte_rx_offload_names in rte_ethdev.c file.
141099a2dd95SBruce Richardson  */
141199a2dd95SBruce Richardson 
141299a2dd95SBruce Richardson /**
141309fd4227SAndrew Rybchenko  * Tx offload capabilities of a device.
141499a2dd95SBruce Richardson  */
14154852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_VLAN_INSERT      RTE_BIT64(0)
14164852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_IPV4_CKSUM       RTE_BIT64(1)
14174852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_UDP_CKSUM        RTE_BIT64(2)
14184852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_TCP_CKSUM        RTE_BIT64(3)
14194852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_SCTP_CKSUM       RTE_BIT64(4)
14204852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_TCP_TSO          RTE_BIT64(5)
14214852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_UDP_TSO          RTE_BIT64(6)
14224852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM RTE_BIT64(7)  /**< Used for tunneling packet. */
14234852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_QINQ_INSERT      RTE_BIT64(8)
14244852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO    RTE_BIT64(9)  /**< Used for tunneling packet. */
14254852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO      RTE_BIT64(10) /**< Used for tunneling packet. */
14264852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO     RTE_BIT64(11) /**< Used for tunneling packet. */
14274852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO   RTE_BIT64(12) /**< Used for tunneling packet. */
14284852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_MACSEC_INSERT    RTE_BIT64(13)
14293c2ca0a9SAndrew Rybchenko /**
14303c2ca0a9SAndrew Rybchenko  * Multiple threads can invoke rte_eth_tx_burst() concurrently on the same
143109fd4227SAndrew Rybchenko  * Tx queue without SW lock.
143299a2dd95SBruce Richardson  */
14334852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_MT_LOCKFREE      RTE_BIT64(14)
14343c2ca0a9SAndrew Rybchenko /** Device supports multi segment send. */
14354852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_MULTI_SEGS       RTE_BIT64(15)
14363c2ca0a9SAndrew Rybchenko /**
14373c2ca0a9SAndrew Rybchenko  * Device supports optimization for fast release of mbufs.
143899a2dd95SBruce Richardson  * When set application must guarantee that per-queue all mbufs comes from
143999a2dd95SBruce Richardson  * the same mempool and has refcnt = 1.
144099a2dd95SBruce Richardson  */
14414852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE   RTE_BIT64(16)
14424852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_SECURITY         RTE_BIT64(17)
144399a2dd95SBruce Richardson /**
144499a2dd95SBruce Richardson  * Device supports generic UDP tunneled packet TSO.
1445daa02b5cSOlivier Matz  * Application must set RTE_MBUF_F_TX_TUNNEL_UDP and other mbuf fields required
144699a2dd95SBruce Richardson  * for tunnel TSO.
144799a2dd95SBruce Richardson  */
14484852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO      RTE_BIT64(18)
144999a2dd95SBruce Richardson /**
145099a2dd95SBruce Richardson  * Device supports generic IP tunneled packet TSO.
1451daa02b5cSOlivier Matz  * Application must set RTE_MBUF_F_TX_TUNNEL_IP and other mbuf fields required
145299a2dd95SBruce Richardson  * for tunnel TSO.
145399a2dd95SBruce Richardson  */
14544852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_IP_TNL_TSO       RTE_BIT64(19)
145599a2dd95SBruce Richardson /** Device supports outer UDP checksum */
14564852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM  RTE_BIT64(20)
145799a2dd95SBruce Richardson /**
145899a2dd95SBruce Richardson  * Device sends on time read from RTE_MBUF_DYNFIELD_TIMESTAMP_NAME
145999a2dd95SBruce Richardson  * if RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME is set in ol_flags.
146099a2dd95SBruce Richardson  * The mbuf field and flag are registered when the offload is configured.
146199a2dd95SBruce Richardson  */
14624852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP RTE_BIT64(21)
146399a2dd95SBruce Richardson /*
146499a2dd95SBruce Richardson  * If new Tx offload capabilities are defined, they also must be
146599a2dd95SBruce Richardson  * mentioned in rte_tx_offload_names in rte_ethdev.c file.
146699a2dd95SBruce Richardson  */
146799a2dd95SBruce Richardson 
146899a2dd95SBruce Richardson /**@{@name Device capabilities
146999a2dd95SBruce Richardson  * Non-offload capabilities reported in rte_eth_dev_info.dev_capa.
147099a2dd95SBruce Richardson  */
147199a2dd95SBruce Richardson /** Device supports Rx queue setup after device started. */
14724852c647SAndrew Rybchenko #define RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP RTE_BIT64(0)
147399a2dd95SBruce Richardson /** Device supports Tx queue setup after device started. */
14744852c647SAndrew Rybchenko #define RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP RTE_BIT64(1)
1475dd22740cSXueming Li /**
1476dd22740cSXueming Li  * Device supports shared Rx queue among ports within Rx domain and
1477dd22740cSXueming Li  * switch domain. Mbufs are consumed by shared Rx queue instead of
1478dd22740cSXueming Li  * each queue. Multiple groups are supported by share_group of Rx
1479dd22740cSXueming Li  * queue configuration. Shared Rx queue is identified by PMD using
1480dd22740cSXueming Li  * share_qid of Rx queue configuration. Polling any port in the group
1481dd22740cSXueming Li  * receive packets of all member ports, source port identified by
1482dd22740cSXueming Li  * mbuf->port field.
1483dd22740cSXueming Li  */
1484dd22740cSXueming Li #define RTE_ETH_DEV_CAPA_RXQ_SHARE              RTE_BIT64(2)
14851d5a3d68SDmitry Kozlyuk /** Device supports keeping flow rules across restart. */
14861d5a3d68SDmitry Kozlyuk #define RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP         RTE_BIT64(3)
14872c9cd45dSDmitry Kozlyuk /** Device supports keeping shared flow objects across restart. */
14882c9cd45dSDmitry Kozlyuk #define RTE_ETH_DEV_CAPA_FLOW_SHARED_OBJECT_KEEP RTE_BIT64(4)
148999a2dd95SBruce Richardson /**@}*/
149099a2dd95SBruce Richardson 
149199a2dd95SBruce Richardson /*
149299a2dd95SBruce Richardson  * Fallback default preferred Rx/Tx port parameters.
149399a2dd95SBruce Richardson  * These are used if an application requests default parameters
149499a2dd95SBruce Richardson  * but the PMD does not provide preferred values.
149599a2dd95SBruce Richardson  */
149699a2dd95SBruce Richardson #define RTE_ETH_DEV_FALLBACK_RX_RINGSIZE 512
149799a2dd95SBruce Richardson #define RTE_ETH_DEV_FALLBACK_TX_RINGSIZE 512
149899a2dd95SBruce Richardson #define RTE_ETH_DEV_FALLBACK_RX_NBQUEUES 1
149999a2dd95SBruce Richardson #define RTE_ETH_DEV_FALLBACK_TX_NBQUEUES 1
150099a2dd95SBruce Richardson 
150199a2dd95SBruce Richardson /**
150299a2dd95SBruce Richardson  * Preferred Rx/Tx port parameters.
150399a2dd95SBruce Richardson  * There are separate instances of this structure for transmission
150499a2dd95SBruce Richardson  * and reception respectively.
150599a2dd95SBruce Richardson  */
150699a2dd95SBruce Richardson struct rte_eth_dev_portconf {
150799a2dd95SBruce Richardson 	uint16_t burst_size; /**< Device-preferred burst size */
150899a2dd95SBruce Richardson 	uint16_t ring_size; /**< Device-preferred size of queue rings */
150999a2dd95SBruce Richardson 	uint16_t nb_queues; /**< Device-preferred number of queues */
151099a2dd95SBruce Richardson };
151199a2dd95SBruce Richardson 
151299a2dd95SBruce Richardson /**
15135906be5aSAndrew Rybchenko  * Default values for switch domain ID when ethdev does not support switch
151499a2dd95SBruce Richardson  * domain definitions.
151599a2dd95SBruce Richardson  */
151699a2dd95SBruce Richardson #define RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID	(UINT16_MAX)
151799a2dd95SBruce Richardson 
151899a2dd95SBruce Richardson /**
151999a2dd95SBruce Richardson  * Ethernet device associated switch information
152099a2dd95SBruce Richardson  */
152199a2dd95SBruce Richardson struct rte_eth_switch_info {
152299a2dd95SBruce Richardson 	const char *name;	/**< switch name */
15235906be5aSAndrew Rybchenko 	uint16_t domain_id;	/**< switch domain ID */
15243c2ca0a9SAndrew Rybchenko 	/**
15253c2ca0a9SAndrew Rybchenko 	 * Mapping to the devices physical switch port as enumerated from the
152699a2dd95SBruce Richardson 	 * perspective of the embedded interconnect/switch. For SR-IOV enabled
152799a2dd95SBruce Richardson 	 * device this may correspond to the VF_ID of each virtual function,
152899a2dd95SBruce Richardson 	 * but each driver should explicitly define the mapping of switch
152999a2dd95SBruce Richardson 	 * port identifier to that physical interconnect/switch
153099a2dd95SBruce Richardson 	 */
15313c2ca0a9SAndrew Rybchenko 	uint16_t port_id;
1532dd22740cSXueming Li 	/**
1533dd22740cSXueming Li 	 * Shared Rx queue sub-domain boundary. Only ports in same Rx domain
1534dd22740cSXueming Li 	 * and switch domain can share Rx queue. Valid only if device advertised
1535dd22740cSXueming Li 	 * RTE_ETH_DEV_CAPA_RXQ_SHARE capability.
1536dd22740cSXueming Li 	 */
1537dd22740cSXueming Li 	uint16_t rx_domain;
153899a2dd95SBruce Richardson };
153999a2dd95SBruce Richardson 
154099a2dd95SBruce Richardson /**
154199a2dd95SBruce Richardson  * @warning
154299a2dd95SBruce Richardson  * @b EXPERIMENTAL: this structure may change without prior notice.
154399a2dd95SBruce Richardson  *
154499a2dd95SBruce Richardson  * Ethernet device Rx buffer segmentation capabilities.
154599a2dd95SBruce Richardson  */
154699a2dd95SBruce Richardson struct rte_eth_rxseg_capa {
154799a2dd95SBruce Richardson 	__extension__
154899a2dd95SBruce Richardson 	uint32_t multi_pools:1; /**< Supports receiving to multiple pools.*/
154999a2dd95SBruce Richardson 	uint32_t offset_allowed:1; /**< Supports buffer offsets. */
155099a2dd95SBruce Richardson 	uint32_t offset_align_log2:4; /**< Required offset alignment. */
155199a2dd95SBruce Richardson 	uint16_t max_nseg; /**< Maximum amount of segments to split. */
155299a2dd95SBruce Richardson 	uint16_t reserved; /**< Reserved field. */
155399a2dd95SBruce Richardson };
155499a2dd95SBruce Richardson 
155599a2dd95SBruce Richardson /**
155699a2dd95SBruce Richardson  * Ethernet device information
155799a2dd95SBruce Richardson  */
155899a2dd95SBruce Richardson 
155999a2dd95SBruce Richardson /**
156099a2dd95SBruce Richardson  * Ethernet device representor port type.
156199a2dd95SBruce Richardson  */
156299a2dd95SBruce Richardson enum rte_eth_representor_type {
156399a2dd95SBruce Richardson 	RTE_ETH_REPRESENTOR_NONE, /**< not a representor. */
156499a2dd95SBruce Richardson 	RTE_ETH_REPRESENTOR_VF,   /**< representor of Virtual Function. */
156599a2dd95SBruce Richardson 	RTE_ETH_REPRESENTOR_SF,   /**< representor of Sub Function. */
156699a2dd95SBruce Richardson 	RTE_ETH_REPRESENTOR_PF,   /**< representor of Physical Function. */
156799a2dd95SBruce Richardson };
156899a2dd95SBruce Richardson 
156999a2dd95SBruce Richardson /**
157099a2dd95SBruce Richardson  * A structure used to retrieve the contextual information of
157199a2dd95SBruce Richardson  * an Ethernet device, such as the controlling driver of the
157299a2dd95SBruce Richardson  * device, etc...
157399a2dd95SBruce Richardson  */
157499a2dd95SBruce Richardson struct rte_eth_dev_info {
15753b358e33SFerruh Yigit 	struct rte_device *device; /**< Generic device information */
157699a2dd95SBruce Richardson 	const char *driver_name; /**< Device Driver name. */
157799a2dd95SBruce Richardson 	unsigned int if_index; /**< Index to bound host interface, or 0 if none.
157899a2dd95SBruce Richardson 		Use if_indextoname() to translate into an interface name. */
157999a2dd95SBruce Richardson 	uint16_t min_mtu;	/**< Minimum MTU allowed */
158099a2dd95SBruce Richardson 	uint16_t max_mtu;	/**< Maximum MTU allowed */
158199a2dd95SBruce Richardson 	const uint32_t *dev_flags; /**< Device flags */
158209fd4227SAndrew Rybchenko 	uint32_t min_rx_bufsize; /**< Minimum size of Rx buffer. */
158309fd4227SAndrew Rybchenko 	uint32_t max_rx_pktlen; /**< Maximum configurable length of Rx pkt. */
158499a2dd95SBruce Richardson 	/** Maximum configurable size of LRO aggregated packet. */
158599a2dd95SBruce Richardson 	uint32_t max_lro_pkt_size;
158609fd4227SAndrew Rybchenko 	uint16_t max_rx_queues; /**< Maximum number of Rx queues. */
158709fd4227SAndrew Rybchenko 	uint16_t max_tx_queues; /**< Maximum number of Tx queues. */
158899a2dd95SBruce Richardson 	uint32_t max_mac_addrs; /**< Maximum number of MAC addresses. */
158999a2dd95SBruce Richardson 	/** Maximum number of hash MAC addresses for MTA and UTA. */
15903b358e33SFerruh Yigit 	uint32_t max_hash_mac_addrs;
159199a2dd95SBruce Richardson 	uint16_t max_vfs; /**< Maximum number of VFs. */
159299a2dd95SBruce Richardson 	uint16_t max_vmdq_pools; /**< Maximum number of VMDq pools. */
159399a2dd95SBruce Richardson 	struct rte_eth_rxseg_capa rx_seg_capa; /**< Segmentation capability.*/
159409fd4227SAndrew Rybchenko 	/** All Rx offload capabilities including all per-queue ones */
159599a2dd95SBruce Richardson 	uint64_t rx_offload_capa;
159609fd4227SAndrew Rybchenko 	/** All Tx offload capabilities including all per-queue ones */
159799a2dd95SBruce Richardson 	uint64_t tx_offload_capa;
159809fd4227SAndrew Rybchenko 	/** Device per-queue Rx offload capabilities. */
159999a2dd95SBruce Richardson 	uint64_t rx_queue_offload_capa;
160009fd4227SAndrew Rybchenko 	/** Device per-queue Tx offload capabilities. */
160199a2dd95SBruce Richardson 	uint64_t tx_queue_offload_capa;
16023c2ca0a9SAndrew Rybchenko 	/** Device redirection table size, the total number of entries. */
160399a2dd95SBruce Richardson 	uint16_t reta_size;
160499a2dd95SBruce Richardson 	uint8_t hash_key_size; /**< Hash key size in bytes */
160599a2dd95SBruce Richardson 	/** Bit mask of RSS offloads, the bit offset also means flow type */
160699a2dd95SBruce Richardson 	uint64_t flow_type_rss_offloads;
160709fd4227SAndrew Rybchenko 	struct rte_eth_rxconf default_rxconf; /**< Default Rx configuration */
160809fd4227SAndrew Rybchenko 	struct rte_eth_txconf default_txconf; /**< Default Tx configuration */
1609064e90c4SAndrew Rybchenko 	uint16_t vmdq_queue_base; /**< First queue ID for VMDq pools. */
1610064e90c4SAndrew Rybchenko 	uint16_t vmdq_queue_num;  /**< Queue number for VMDq pools. */
1611064e90c4SAndrew Rybchenko 	uint16_t vmdq_pool_base;  /**< First ID of VMDq pools. */
161209fd4227SAndrew Rybchenko 	struct rte_eth_desc_lim rx_desc_lim;  /**< Rx descriptors limits */
161309fd4227SAndrew Rybchenko 	struct rte_eth_desc_lim tx_desc_lim;  /**< Tx descriptors limits */
1614295968d1SFerruh Yigit 	uint32_t speed_capa;  /**< Supported speeds bitmap (RTE_ETH_LINK_SPEED_). */
161509fd4227SAndrew Rybchenko 	/** Configured number of Rx/Tx queues */
161609fd4227SAndrew Rybchenko 	uint16_t nb_rx_queues; /**< Number of Rx queues. */
161709fd4227SAndrew Rybchenko 	uint16_t nb_tx_queues; /**< Number of Tx queues. */
161899a2dd95SBruce Richardson 	/** Rx parameter recommendations */
161999a2dd95SBruce Richardson 	struct rte_eth_dev_portconf default_rxportconf;
162099a2dd95SBruce Richardson 	/** Tx parameter recommendations */
162199a2dd95SBruce Richardson 	struct rte_eth_dev_portconf default_txportconf;
162299a2dd95SBruce Richardson 	/** Generic device capabilities (RTE_ETH_DEV_CAPA_). */
162399a2dd95SBruce Richardson 	uint64_t dev_capa;
162499a2dd95SBruce Richardson 	/**
162599a2dd95SBruce Richardson 	 * Switching information for ports on a device with a
162699a2dd95SBruce Richardson 	 * embedded managed interconnect/switch.
162799a2dd95SBruce Richardson 	 */
162899a2dd95SBruce Richardson 	struct rte_eth_switch_info switch_info;
162999a2dd95SBruce Richardson 
163099a2dd95SBruce Richardson 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
163199a2dd95SBruce Richardson 	void *reserved_ptrs[2];   /**< Reserved for future fields */
163299a2dd95SBruce Richardson };
163399a2dd95SBruce Richardson 
16340ce56b05SThomas Monjalon /**@{@name Rx/Tx queue states */
16350ce56b05SThomas Monjalon #define RTE_ETH_QUEUE_STATE_STOPPED 0 /**< Queue stopped. */
16360ce56b05SThomas Monjalon #define RTE_ETH_QUEUE_STATE_STARTED 1 /**< Queue started. */
16370ce56b05SThomas Monjalon #define RTE_ETH_QUEUE_STATE_HAIRPIN 2 /**< Queue used for hairpin. */
16380ce56b05SThomas Monjalon /**@}*/
16399ad9ff47SLijun Ou 
16409ad9ff47SLijun Ou /**
164109fd4227SAndrew Rybchenko  * Ethernet device Rx queue information structure.
164299a2dd95SBruce Richardson  * Used to retrieve information about configured queue.
164399a2dd95SBruce Richardson  */
164499a2dd95SBruce Richardson struct rte_eth_rxq_info {
164599a2dd95SBruce Richardson 	struct rte_mempool *mp;     /**< mempool used by that queue. */
164699a2dd95SBruce Richardson 	struct rte_eth_rxconf conf; /**< queue config parameters. */
164709fd4227SAndrew Rybchenko 	uint8_t scattered_rx;       /**< scattered packets Rx supported. */
16489ad9ff47SLijun Ou 	uint8_t queue_state;        /**< one of RTE_ETH_QUEUE_STATE_*. */
164999a2dd95SBruce Richardson 	uint16_t nb_desc;           /**< configured number of RXDs. */
165099a2dd95SBruce Richardson 	uint16_t rx_buf_size;       /**< hardware receive buffer size. */
1651bc70e559SSpike Du 	/**
1652bc70e559SSpike Du 	 * Available Rx descriptors threshold defined as percentage
1653bc70e559SSpike Du 	 * of Rx queue size. If number of available descriptors is lower,
1654bc70e559SSpike Du 	 * the event RTE_ETH_EVENT_RX_AVAIL_THESH is generated.
1655bc70e559SSpike Du 	 * Value 0 means that the threshold monitoring is disabled.
1656bc70e559SSpike Du 	 */
1657bc70e559SSpike Du 	uint8_t avail_thresh;
165899a2dd95SBruce Richardson } __rte_cache_min_aligned;
165999a2dd95SBruce Richardson 
166099a2dd95SBruce Richardson /**
166109fd4227SAndrew Rybchenko  * Ethernet device Tx queue information structure.
166299a2dd95SBruce Richardson  * Used to retrieve information about configured queue.
166399a2dd95SBruce Richardson  */
166499a2dd95SBruce Richardson struct rte_eth_txq_info {
166599a2dd95SBruce Richardson 	struct rte_eth_txconf conf; /**< queue config parameters. */
166699a2dd95SBruce Richardson 	uint16_t nb_desc;           /**< configured number of TXDs. */
16679ad9ff47SLijun Ou 	uint8_t queue_state;        /**< one of RTE_ETH_QUEUE_STATE_*. */
166899a2dd95SBruce Richardson } __rte_cache_min_aligned;
166999a2dd95SBruce Richardson 
167099a2dd95SBruce Richardson /* Generic Burst mode flag definition, values can be ORed. */
167199a2dd95SBruce Richardson 
167299a2dd95SBruce Richardson /**
167399a2dd95SBruce Richardson  * If the queues have different burst mode description, this bit will be set
167499a2dd95SBruce Richardson  * by PMD, then the application can iterate to retrieve burst description for
167599a2dd95SBruce Richardson  * all other queues.
167699a2dd95SBruce Richardson  */
1677e1823e08SThomas Monjalon #define RTE_ETH_BURST_FLAG_PER_QUEUE RTE_BIT64(0)
167899a2dd95SBruce Richardson 
167999a2dd95SBruce Richardson /**
168009fd4227SAndrew Rybchenko  * Ethernet device Rx/Tx queue packet burst mode information structure.
168199a2dd95SBruce Richardson  * Used to retrieve information about packet burst mode setting.
168299a2dd95SBruce Richardson  */
168399a2dd95SBruce Richardson struct rte_eth_burst_mode {
168499a2dd95SBruce Richardson 	uint64_t flags; /**< The ORed values of RTE_ETH_BURST_FLAG_xxx */
168599a2dd95SBruce Richardson 
168699a2dd95SBruce Richardson #define RTE_ETH_BURST_MODE_INFO_SIZE 1024 /**< Maximum size for information */
168799a2dd95SBruce Richardson 	char info[RTE_ETH_BURST_MODE_INFO_SIZE]; /**< burst mode information */
168899a2dd95SBruce Richardson };
168999a2dd95SBruce Richardson 
169099a2dd95SBruce Richardson /** Maximum name length for extended statistics counters */
169199a2dd95SBruce Richardson #define RTE_ETH_XSTATS_NAME_SIZE 64
169299a2dd95SBruce Richardson 
169399a2dd95SBruce Richardson /**
169499a2dd95SBruce Richardson  * An Ethernet device extended statistic structure
169599a2dd95SBruce Richardson  *
169699a2dd95SBruce Richardson  * This structure is used by rte_eth_xstats_get() to provide
169799a2dd95SBruce Richardson  * statistics that are not provided in the generic *rte_eth_stats*
169899a2dd95SBruce Richardson  * structure.
16995906be5aSAndrew Rybchenko  * It maps a name ID, corresponding to an index in the array returned
170099a2dd95SBruce Richardson  * by rte_eth_xstats_get_names(), to a statistic value.
170199a2dd95SBruce Richardson  */
170299a2dd95SBruce Richardson struct rte_eth_xstat {
170399a2dd95SBruce Richardson 	uint64_t id;        /**< The index in xstats name array. */
170499a2dd95SBruce Richardson 	uint64_t value;     /**< The statistic counter value. */
170599a2dd95SBruce Richardson };
170699a2dd95SBruce Richardson 
170799a2dd95SBruce Richardson /**
170899a2dd95SBruce Richardson  * A name element for extended statistics.
170999a2dd95SBruce Richardson  *
171099a2dd95SBruce Richardson  * An array of this structure is returned by rte_eth_xstats_get_names().
171199a2dd95SBruce Richardson  * It lists the names of extended statistics for a PMD. The *rte_eth_xstat*
171299a2dd95SBruce Richardson  * structure references these names by their array index.
171399a2dd95SBruce Richardson  *
171499a2dd95SBruce Richardson  * The xstats should follow a common naming scheme.
171599a2dd95SBruce Richardson  * Some names are standardized in rte_stats_strings.
171699a2dd95SBruce Richardson  * Examples:
171799a2dd95SBruce Richardson  *     - rx_missed_errors
171899a2dd95SBruce Richardson  *     - tx_q3_bytes
171999a2dd95SBruce Richardson  *     - tx_size_128_to_255_packets
172099a2dd95SBruce Richardson  */
172199a2dd95SBruce Richardson struct rte_eth_xstat_name {
172299a2dd95SBruce Richardson 	char name[RTE_ETH_XSTATS_NAME_SIZE]; /**< The statistic name. */
172399a2dd95SBruce Richardson };
172499a2dd95SBruce Richardson 
1725295968d1SFerruh Yigit #define RTE_ETH_DCB_NUM_TCS    8
1726295968d1SFerruh Yigit #define RTE_ETH_MAX_VMDQ_POOL  64
1727b1cb3035SFerruh Yigit 
172899a2dd95SBruce Richardson /**
172999a2dd95SBruce Richardson  * A structure used to get the information of queue and
173009fd4227SAndrew Rybchenko  * TC mapping on both Tx and Rx paths.
173199a2dd95SBruce Richardson  */
173299a2dd95SBruce Richardson struct rte_eth_dcb_tc_queue_mapping {
173309fd4227SAndrew Rybchenko 	/** Rx queues assigned to tc per Pool */
173499a2dd95SBruce Richardson 	struct {
173599a2dd95SBruce Richardson 		uint16_t base;
173699a2dd95SBruce Richardson 		uint16_t nb_queue;
1737295968d1SFerruh Yigit 	} tc_rxq[RTE_ETH_MAX_VMDQ_POOL][RTE_ETH_DCB_NUM_TCS];
173809fd4227SAndrew Rybchenko 	/** Rx queues assigned to tc per Pool */
173999a2dd95SBruce Richardson 	struct {
174099a2dd95SBruce Richardson 		uint16_t base;
174199a2dd95SBruce Richardson 		uint16_t nb_queue;
1742295968d1SFerruh Yigit 	} tc_txq[RTE_ETH_MAX_VMDQ_POOL][RTE_ETH_DCB_NUM_TCS];
174399a2dd95SBruce Richardson };
174499a2dd95SBruce Richardson 
174599a2dd95SBruce Richardson /**
174699a2dd95SBruce Richardson  * A structure used to get the information of DCB.
174799a2dd95SBruce Richardson  * It includes TC UP mapping and queue TC mapping.
174899a2dd95SBruce Richardson  */
174999a2dd95SBruce Richardson struct rte_eth_dcb_info {
175099a2dd95SBruce Richardson 	uint8_t nb_tcs;        /**< number of TCs */
1751295968d1SFerruh Yigit 	uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES]; /**< Priority to tc */
1752295968d1SFerruh Yigit 	uint8_t tc_bws[RTE_ETH_DCB_NUM_TCS]; /**< Tx BW percentage for each TC */
175309fd4227SAndrew Rybchenko 	/** Rx queues assigned to tc */
175499a2dd95SBruce Richardson 	struct rte_eth_dcb_tc_queue_mapping tc_queue;
175599a2dd95SBruce Richardson };
175699a2dd95SBruce Richardson 
175799a2dd95SBruce Richardson /**
175899a2dd95SBruce Richardson  * This enum indicates the possible Forward Error Correction (FEC) modes
175999a2dd95SBruce Richardson  * of an ethdev port.
176099a2dd95SBruce Richardson  */
176199a2dd95SBruce Richardson enum rte_eth_fec_mode {
176299a2dd95SBruce Richardson 	RTE_ETH_FEC_NOFEC = 0,      /**< FEC is off */
176399a2dd95SBruce Richardson 	RTE_ETH_FEC_AUTO,	    /**< FEC autonegotiation modes */
176499a2dd95SBruce Richardson 	RTE_ETH_FEC_BASER,          /**< FEC using common algorithm */
176599a2dd95SBruce Richardson 	RTE_ETH_FEC_RS,             /**< FEC using RS algorithm */
176699a2dd95SBruce Richardson };
176799a2dd95SBruce Richardson 
176899a2dd95SBruce Richardson /* Translate from FEC mode to FEC capa */
1769e1823e08SThomas Monjalon #define RTE_ETH_FEC_MODE_TO_CAPA(x) RTE_BIT32(x)
177099a2dd95SBruce Richardson 
177199a2dd95SBruce Richardson /* This macro indicates FEC capa mask */
1772e1823e08SThomas Monjalon #define RTE_ETH_FEC_MODE_CAPA_MASK(x) RTE_BIT32(RTE_ETH_FEC_ ## x)
177399a2dd95SBruce Richardson 
177499a2dd95SBruce Richardson /* A structure used to get capabilities per link speed */
177599a2dd95SBruce Richardson struct rte_eth_fec_capa {
1776295968d1SFerruh Yigit 	uint32_t speed; /**< Link speed (see RTE_ETH_SPEED_NUM_*) */
177799a2dd95SBruce Richardson 	uint32_t capa;  /**< FEC capabilities bitmask */
177899a2dd95SBruce Richardson };
177999a2dd95SBruce Richardson 
178099a2dd95SBruce Richardson #define RTE_ETH_ALL RTE_MAX_ETHPORTS
178199a2dd95SBruce Richardson 
178299a2dd95SBruce Richardson /* Macros to check for valid port */
178399a2dd95SBruce Richardson #define RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, retval) do { \
178499a2dd95SBruce Richardson 	if (!rte_eth_dev_is_valid_port(port_id)) { \
178599a2dd95SBruce Richardson 		RTE_ETHDEV_LOG(ERR, "Invalid port_id=%u\n", port_id); \
178699a2dd95SBruce Richardson 		return retval; \
178799a2dd95SBruce Richardson 	} \
178899a2dd95SBruce Richardson } while (0)
178999a2dd95SBruce Richardson 
179099a2dd95SBruce Richardson #define RTE_ETH_VALID_PORTID_OR_RET(port_id) do { \
179199a2dd95SBruce Richardson 	if (!rte_eth_dev_is_valid_port(port_id)) { \
179299a2dd95SBruce Richardson 		RTE_ETHDEV_LOG(ERR, "Invalid port_id=%u\n", port_id); \
179399a2dd95SBruce Richardson 		return; \
179499a2dd95SBruce Richardson 	} \
179599a2dd95SBruce Richardson } while (0)
179699a2dd95SBruce Richardson 
179799a2dd95SBruce Richardson /**
179809fd4227SAndrew Rybchenko  * Function type used for Rx packet processing packet callbacks.
179999a2dd95SBruce Richardson  *
180009fd4227SAndrew Rybchenko  * The callback function is called on Rx with a burst of packets that have
180199a2dd95SBruce Richardson  * been received on the given port and queue.
180299a2dd95SBruce Richardson  *
180399a2dd95SBruce Richardson  * @param port_id
180409fd4227SAndrew Rybchenko  *   The Ethernet port on which Rx is being performed.
180599a2dd95SBruce Richardson  * @param queue
180699a2dd95SBruce Richardson  *   The queue on the Ethernet port which is being used to receive the packets.
180799a2dd95SBruce Richardson  * @param pkts
180899a2dd95SBruce Richardson  *   The burst of packets that have just been received.
180999a2dd95SBruce Richardson  * @param nb_pkts
181099a2dd95SBruce Richardson  *   The number of packets in the burst pointed to by "pkts".
181199a2dd95SBruce Richardson  * @param max_pkts
181299a2dd95SBruce Richardson  *   The max number of packets that can be stored in the "pkts" array.
181399a2dd95SBruce Richardson  * @param user_param
181499a2dd95SBruce Richardson  *   The arbitrary user parameter passed in by the application when the callback
181599a2dd95SBruce Richardson  *   was originally configured.
181699a2dd95SBruce Richardson  * @return
181799a2dd95SBruce Richardson  *   The number of packets returned to the user.
181899a2dd95SBruce Richardson  */
181999a2dd95SBruce Richardson typedef uint16_t (*rte_rx_callback_fn)(uint16_t port_id, uint16_t queue,
182099a2dd95SBruce Richardson 	struct rte_mbuf *pkts[], uint16_t nb_pkts, uint16_t max_pkts,
182199a2dd95SBruce Richardson 	void *user_param);
182299a2dd95SBruce Richardson 
182399a2dd95SBruce Richardson /**
182409fd4227SAndrew Rybchenko  * Function type used for Tx packet processing packet callbacks.
182599a2dd95SBruce Richardson  *
182609fd4227SAndrew Rybchenko  * The callback function is called on Tx with a burst of packets immediately
182799a2dd95SBruce Richardson  * before the packets are put onto the hardware queue for transmission.
182899a2dd95SBruce Richardson  *
182999a2dd95SBruce Richardson  * @param port_id
183009fd4227SAndrew Rybchenko  *   The Ethernet port on which Tx is being performed.
183199a2dd95SBruce Richardson  * @param queue
183299a2dd95SBruce Richardson  *   The queue on the Ethernet port which is being used to transmit the packets.
183399a2dd95SBruce Richardson  * @param pkts
183499a2dd95SBruce Richardson  *   The burst of packets that are about to be transmitted.
183599a2dd95SBruce Richardson  * @param nb_pkts
183699a2dd95SBruce Richardson  *   The number of packets in the burst pointed to by "pkts".
183799a2dd95SBruce Richardson  * @param user_param
183899a2dd95SBruce Richardson  *   The arbitrary user parameter passed in by the application when the callback
183999a2dd95SBruce Richardson  *   was originally configured.
184099a2dd95SBruce Richardson  * @return
184199a2dd95SBruce Richardson  *   The number of packets to be written to the NIC.
184299a2dd95SBruce Richardson  */
184399a2dd95SBruce Richardson typedef uint16_t (*rte_tx_callback_fn)(uint16_t port_id, uint16_t queue,
184499a2dd95SBruce Richardson 	struct rte_mbuf *pkts[], uint16_t nb_pkts, void *user_param);
184599a2dd95SBruce Richardson 
184699a2dd95SBruce Richardson /**
184799a2dd95SBruce Richardson  * Possible states of an ethdev port.
184899a2dd95SBruce Richardson  */
184999a2dd95SBruce Richardson enum rte_eth_dev_state {
185099a2dd95SBruce Richardson 	/** Device is unused before being probed. */
185199a2dd95SBruce Richardson 	RTE_ETH_DEV_UNUSED = 0,
185299a2dd95SBruce Richardson 	/** Device is attached when allocated in probing. */
185399a2dd95SBruce Richardson 	RTE_ETH_DEV_ATTACHED,
185499a2dd95SBruce Richardson 	/** Device is in removed state when plug-out is detected. */
185599a2dd95SBruce Richardson 	RTE_ETH_DEV_REMOVED,
185699a2dd95SBruce Richardson };
185799a2dd95SBruce Richardson 
185899a2dd95SBruce Richardson struct rte_eth_dev_sriov {
185999a2dd95SBruce Richardson 	uint8_t active;               /**< SRIOV is active with 16, 32 or 64 pools */
186009fd4227SAndrew Rybchenko 	uint8_t nb_q_per_pool;        /**< Rx queue number per pool */
186199a2dd95SBruce Richardson 	uint16_t def_vmdq_idx;        /**< Default pool num used for PF */
186299a2dd95SBruce Richardson 	uint16_t def_pool_q_idx;      /**< Default pool queue start reg index */
186399a2dd95SBruce Richardson };
186499a2dd95SBruce Richardson #define RTE_ETH_DEV_SRIOV(dev)         ((dev)->data->sriov)
186599a2dd95SBruce Richardson 
186699a2dd95SBruce Richardson #define RTE_ETH_NAME_MAX_LEN RTE_DEV_NAME_MAX_LEN
186799a2dd95SBruce Richardson 
186899a2dd95SBruce Richardson #define RTE_ETH_DEV_NO_OWNER 0
186999a2dd95SBruce Richardson 
187099a2dd95SBruce Richardson #define RTE_ETH_MAX_OWNER_NAME_LEN 64
187199a2dd95SBruce Richardson 
187299a2dd95SBruce Richardson struct rte_eth_dev_owner {
187399a2dd95SBruce Richardson 	uint64_t id; /**< The owner unique identifier. */
187499a2dd95SBruce Richardson 	char name[RTE_ETH_MAX_OWNER_NAME_LEN]; /**< The owner name. */
187599a2dd95SBruce Richardson };
187699a2dd95SBruce Richardson 
18770ce56b05SThomas Monjalon /**@{@name Device flags
18780ce56b05SThomas Monjalon  * Flags internally saved in rte_eth_dev_data.dev_flags
18790ce56b05SThomas Monjalon  * and reported in rte_eth_dev_info.dev_flags.
18800ce56b05SThomas Monjalon  */
188199a2dd95SBruce Richardson /** PMD supports thread-safe flow operations */
18824852c647SAndrew Rybchenko #define RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE  RTE_BIT32(0)
188399a2dd95SBruce Richardson /** Device supports link state interrupt */
18844852c647SAndrew Rybchenko #define RTE_ETH_DEV_INTR_LSC              RTE_BIT32(1)
188599a2dd95SBruce Richardson /** Device is a bonded slave */
18864852c647SAndrew Rybchenko #define RTE_ETH_DEV_BONDED_SLAVE          RTE_BIT32(2)
188799a2dd95SBruce Richardson /** Device supports device removal interrupt */
18884852c647SAndrew Rybchenko #define RTE_ETH_DEV_INTR_RMV              RTE_BIT32(3)
188999a2dd95SBruce Richardson /** Device is port representor */
18904852c647SAndrew Rybchenko #define RTE_ETH_DEV_REPRESENTOR           RTE_BIT32(4)
189199a2dd95SBruce Richardson /** Device does not support MAC change after started */
18924852c647SAndrew Rybchenko #define RTE_ETH_DEV_NOLIVE_MAC_ADDR       RTE_BIT32(5)
189399a2dd95SBruce Richardson /**
189499a2dd95SBruce Richardson  * Queue xstats filled automatically by ethdev layer.
189599a2dd95SBruce Richardson  * PMDs filling the queue xstats themselves should not set this flag
189699a2dd95SBruce Richardson  */
18974852c647SAndrew Rybchenko #define RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS RTE_BIT32(6)
18980ce56b05SThomas Monjalon /**@}*/
189999a2dd95SBruce Richardson 
190099a2dd95SBruce Richardson /**
190199a2dd95SBruce Richardson  * Iterates over valid ethdev ports owned by a specific owner.
190299a2dd95SBruce Richardson  *
190399a2dd95SBruce Richardson  * @param port_id
19045906be5aSAndrew Rybchenko  *   The ID of the next possible valid owned port.
190599a2dd95SBruce Richardson  * @param	owner_id
190699a2dd95SBruce Richardson  *  The owner identifier.
190799a2dd95SBruce Richardson  *  RTE_ETH_DEV_NO_OWNER means iterate over all valid ownerless ports.
190899a2dd95SBruce Richardson  * @return
19095906be5aSAndrew Rybchenko  *   Next valid port ID owned by owner_id, RTE_MAX_ETHPORTS if there is none.
191099a2dd95SBruce Richardson  */
191199a2dd95SBruce Richardson uint64_t rte_eth_find_next_owned_by(uint16_t port_id,
191299a2dd95SBruce Richardson 		const uint64_t owner_id);
191399a2dd95SBruce Richardson 
191499a2dd95SBruce Richardson /**
191599a2dd95SBruce Richardson  * Macro to iterate over all enabled ethdev ports owned by a specific owner.
191699a2dd95SBruce Richardson  */
191799a2dd95SBruce Richardson #define RTE_ETH_FOREACH_DEV_OWNED_BY(p, o) \
191899a2dd95SBruce Richardson 	for (p = rte_eth_find_next_owned_by(0, o); \
191999a2dd95SBruce Richardson 	     (unsigned int)p < (unsigned int)RTE_MAX_ETHPORTS; \
192099a2dd95SBruce Richardson 	     p = rte_eth_find_next_owned_by(p + 1, o))
192199a2dd95SBruce Richardson 
192299a2dd95SBruce Richardson /**
192399a2dd95SBruce Richardson  * Iterates over valid ethdev ports.
192499a2dd95SBruce Richardson  *
192599a2dd95SBruce Richardson  * @param port_id
19265906be5aSAndrew Rybchenko  *   The ID of the next possible valid port.
192799a2dd95SBruce Richardson  * @return
19285906be5aSAndrew Rybchenko  *   Next valid port ID, RTE_MAX_ETHPORTS if there is none.
192999a2dd95SBruce Richardson  */
193099a2dd95SBruce Richardson uint16_t rte_eth_find_next(uint16_t port_id);
193199a2dd95SBruce Richardson 
193299a2dd95SBruce Richardson /**
193399a2dd95SBruce Richardson  * Macro to iterate over all enabled and ownerless ethdev ports.
193499a2dd95SBruce Richardson  */
193599a2dd95SBruce Richardson #define RTE_ETH_FOREACH_DEV(p) \
193699a2dd95SBruce Richardson 	RTE_ETH_FOREACH_DEV_OWNED_BY(p, RTE_ETH_DEV_NO_OWNER)
193799a2dd95SBruce Richardson 
193899a2dd95SBruce Richardson /**
193999a2dd95SBruce Richardson  * Iterates over ethdev ports of a specified device.
194099a2dd95SBruce Richardson  *
194199a2dd95SBruce Richardson  * @param port_id_start
19425906be5aSAndrew Rybchenko  *   The ID of the next possible valid port.
194399a2dd95SBruce Richardson  * @param parent
194499a2dd95SBruce Richardson  *   The generic device behind the ports to iterate.
194599a2dd95SBruce Richardson  * @return
19465906be5aSAndrew Rybchenko  *   Next port ID of the device, possibly port_id_start,
194799a2dd95SBruce Richardson  *   RTE_MAX_ETHPORTS if there is none.
194899a2dd95SBruce Richardson  */
194999a2dd95SBruce Richardson uint16_t
195099a2dd95SBruce Richardson rte_eth_find_next_of(uint16_t port_id_start,
195199a2dd95SBruce Richardson 		const struct rte_device *parent);
195299a2dd95SBruce Richardson 
195399a2dd95SBruce Richardson /**
195499a2dd95SBruce Richardson  * Macro to iterate over all ethdev ports of a specified device.
195599a2dd95SBruce Richardson  *
195699a2dd95SBruce Richardson  * @param port_id
19575906be5aSAndrew Rybchenko  *   The ID of the matching port being iterated.
195899a2dd95SBruce Richardson  * @param parent
195999a2dd95SBruce Richardson  *   The rte_device pointer matching the iterated ports.
196099a2dd95SBruce Richardson  */
196199a2dd95SBruce Richardson #define RTE_ETH_FOREACH_DEV_OF(port_id, parent) \
196299a2dd95SBruce Richardson 	for (port_id = rte_eth_find_next_of(0, parent); \
196399a2dd95SBruce Richardson 		port_id < RTE_MAX_ETHPORTS; \
196499a2dd95SBruce Richardson 		port_id = rte_eth_find_next_of(port_id + 1, parent))
196599a2dd95SBruce Richardson 
196699a2dd95SBruce Richardson /**
196799a2dd95SBruce Richardson  * Iterates over sibling ethdev ports (i.e. sharing the same rte_device).
196899a2dd95SBruce Richardson  *
196999a2dd95SBruce Richardson  * @param port_id_start
19705906be5aSAndrew Rybchenko  *   The ID of the next possible valid sibling port.
197199a2dd95SBruce Richardson  * @param ref_port_id
19725906be5aSAndrew Rybchenko  *   The ID of a reference port to compare rte_device with.
197399a2dd95SBruce Richardson  * @return
19745906be5aSAndrew Rybchenko  *   Next sibling port ID, possibly port_id_start or ref_port_id itself,
197599a2dd95SBruce Richardson  *   RTE_MAX_ETHPORTS if there is none.
197699a2dd95SBruce Richardson  */
197799a2dd95SBruce Richardson uint16_t
197899a2dd95SBruce Richardson rte_eth_find_next_sibling(uint16_t port_id_start, uint16_t ref_port_id);
197999a2dd95SBruce Richardson 
198099a2dd95SBruce Richardson /**
198199a2dd95SBruce Richardson  * Macro to iterate over all ethdev ports sharing the same rte_device
198299a2dd95SBruce Richardson  * as the specified port.
198399a2dd95SBruce Richardson  * Note: the specified reference port is part of the loop iterations.
198499a2dd95SBruce Richardson  *
198599a2dd95SBruce Richardson  * @param port_id
19865906be5aSAndrew Rybchenko  *   The ID of the matching port being iterated.
198799a2dd95SBruce Richardson  * @param ref_port_id
19885906be5aSAndrew Rybchenko  *   The ID of the port being compared.
198999a2dd95SBruce Richardson  */
199099a2dd95SBruce Richardson #define RTE_ETH_FOREACH_DEV_SIBLING(port_id, ref_port_id) \
199199a2dd95SBruce Richardson 	for (port_id = rte_eth_find_next_sibling(0, ref_port_id); \
199299a2dd95SBruce Richardson 		port_id < RTE_MAX_ETHPORTS; \
199399a2dd95SBruce Richardson 		port_id = rte_eth_find_next_sibling(port_id + 1, ref_port_id))
199499a2dd95SBruce Richardson 
199599a2dd95SBruce Richardson /**
199699a2dd95SBruce Richardson  * Get a new unique owner identifier.
199799a2dd95SBruce Richardson  * An owner identifier is used to owns Ethernet devices by only one DPDK entity
199899a2dd95SBruce Richardson  * to avoid multiple management of device by different entities.
199999a2dd95SBruce Richardson  *
200099a2dd95SBruce Richardson  * @param	owner_id
200199a2dd95SBruce Richardson  *   Owner identifier pointer.
200299a2dd95SBruce Richardson  * @return
200399a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
200499a2dd95SBruce Richardson  */
200599a2dd95SBruce Richardson int rte_eth_dev_owner_new(uint64_t *owner_id);
200699a2dd95SBruce Richardson 
200799a2dd95SBruce Richardson /**
200899a2dd95SBruce Richardson  * Set an Ethernet device owner.
200999a2dd95SBruce Richardson  *
201099a2dd95SBruce Richardson  * @param	port_id
201199a2dd95SBruce Richardson  *  The identifier of the port to own.
201299a2dd95SBruce Richardson  * @param	owner
201399a2dd95SBruce Richardson  *  The owner pointer.
201499a2dd95SBruce Richardson  * @return
201599a2dd95SBruce Richardson  *  Negative errno value on error, 0 on success.
201699a2dd95SBruce Richardson  */
201799a2dd95SBruce Richardson int rte_eth_dev_owner_set(const uint16_t port_id,
201899a2dd95SBruce Richardson 		const struct rte_eth_dev_owner *owner);
201999a2dd95SBruce Richardson 
202099a2dd95SBruce Richardson /**
202199a2dd95SBruce Richardson  * Unset Ethernet device owner to make the device ownerless.
202299a2dd95SBruce Richardson  *
202399a2dd95SBruce Richardson  * @param	port_id
202499a2dd95SBruce Richardson  *  The identifier of port to make ownerless.
202599a2dd95SBruce Richardson  * @param	owner_id
202699a2dd95SBruce Richardson  *  The owner identifier.
202799a2dd95SBruce Richardson  * @return
202899a2dd95SBruce Richardson  *  0 on success, negative errno value on error.
202999a2dd95SBruce Richardson  */
203099a2dd95SBruce Richardson int rte_eth_dev_owner_unset(const uint16_t port_id,
203199a2dd95SBruce Richardson 		const uint64_t owner_id);
203299a2dd95SBruce Richardson 
203399a2dd95SBruce Richardson /**
203499a2dd95SBruce Richardson  * Remove owner from all Ethernet devices owned by a specific owner.
203599a2dd95SBruce Richardson  *
203699a2dd95SBruce Richardson  * @param	owner_id
203799a2dd95SBruce Richardson  *  The owner identifier.
203899a2dd95SBruce Richardson  * @return
203999a2dd95SBruce Richardson  *  0 on success, negative errno value on error.
204099a2dd95SBruce Richardson  */
204199a2dd95SBruce Richardson int rte_eth_dev_owner_delete(const uint64_t owner_id);
204299a2dd95SBruce Richardson 
204399a2dd95SBruce Richardson /**
204499a2dd95SBruce Richardson  * Get the owner of an Ethernet device.
204599a2dd95SBruce Richardson  *
204699a2dd95SBruce Richardson  * @param	port_id
204799a2dd95SBruce Richardson  *  The port identifier.
204899a2dd95SBruce Richardson  * @param	owner
204999a2dd95SBruce Richardson  *  The owner structure pointer to fill.
205099a2dd95SBruce Richardson  * @return
205199a2dd95SBruce Richardson  *  0 on success, negative errno value on error..
205299a2dd95SBruce Richardson  */
205399a2dd95SBruce Richardson int rte_eth_dev_owner_get(const uint16_t port_id,
205499a2dd95SBruce Richardson 		struct rte_eth_dev_owner *owner);
205599a2dd95SBruce Richardson 
205699a2dd95SBruce Richardson /**
205799a2dd95SBruce Richardson  * Get the number of ports which are usable for the application.
205899a2dd95SBruce Richardson  *
205999a2dd95SBruce Richardson  * These devices must be iterated by using the macro
206099a2dd95SBruce Richardson  * ``RTE_ETH_FOREACH_DEV`` or ``RTE_ETH_FOREACH_DEV_OWNED_BY``
206199a2dd95SBruce Richardson  * to deal with non-contiguous ranges of devices.
206299a2dd95SBruce Richardson  *
206399a2dd95SBruce Richardson  * @return
206499a2dd95SBruce Richardson  *   The count of available Ethernet devices.
206599a2dd95SBruce Richardson  */
206699a2dd95SBruce Richardson uint16_t rte_eth_dev_count_avail(void);
206799a2dd95SBruce Richardson 
206899a2dd95SBruce Richardson /**
206999a2dd95SBruce Richardson  * Get the total number of ports which are allocated.
207099a2dd95SBruce Richardson  *
207199a2dd95SBruce Richardson  * Some devices may not be available for the application.
207299a2dd95SBruce Richardson  *
207399a2dd95SBruce Richardson  * @return
207499a2dd95SBruce Richardson  *   The total count of Ethernet devices.
207599a2dd95SBruce Richardson  */
207699a2dd95SBruce Richardson uint16_t rte_eth_dev_count_total(void);
207799a2dd95SBruce Richardson 
207899a2dd95SBruce Richardson /**
207999a2dd95SBruce Richardson  * Convert a numerical speed in Mbps to a bitmap flag that can be used in
208099a2dd95SBruce Richardson  * the bitmap link_speeds of the struct rte_eth_conf
208199a2dd95SBruce Richardson  *
208299a2dd95SBruce Richardson  * @param speed
208399a2dd95SBruce Richardson  *   Numerical speed value in Mbps
208499a2dd95SBruce Richardson  * @param duplex
2085295968d1SFerruh Yigit  *   RTE_ETH_LINK_[HALF/FULL]_DUPLEX (only for 10/100M speeds)
208699a2dd95SBruce Richardson  * @return
208799a2dd95SBruce Richardson  *   0 if the speed cannot be mapped
208899a2dd95SBruce Richardson  */
208999a2dd95SBruce Richardson uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex);
209099a2dd95SBruce Richardson 
209199a2dd95SBruce Richardson /**
2092295968d1SFerruh Yigit  * Get RTE_ETH_RX_OFFLOAD_* flag name.
209399a2dd95SBruce Richardson  *
209499a2dd95SBruce Richardson  * @param offload
209599a2dd95SBruce Richardson  *   Offload flag.
209699a2dd95SBruce Richardson  * @return
209799a2dd95SBruce Richardson  *   Offload name or 'UNKNOWN' if the flag cannot be recognised.
209899a2dd95SBruce Richardson  */
209999a2dd95SBruce Richardson const char *rte_eth_dev_rx_offload_name(uint64_t offload);
210099a2dd95SBruce Richardson 
210199a2dd95SBruce Richardson /**
2102295968d1SFerruh Yigit  * Get RTE_ETH_TX_OFFLOAD_* flag name.
210399a2dd95SBruce Richardson  *
210499a2dd95SBruce Richardson  * @param offload
210599a2dd95SBruce Richardson  *   Offload flag.
210699a2dd95SBruce Richardson  * @return
210799a2dd95SBruce Richardson  *   Offload name or 'UNKNOWN' if the flag cannot be recognised.
210899a2dd95SBruce Richardson  */
210999a2dd95SBruce Richardson const char *rte_eth_dev_tx_offload_name(uint64_t offload);
211099a2dd95SBruce Richardson 
211199a2dd95SBruce Richardson /**
211293e441c9SXueming Li  * @warning
211393e441c9SXueming Li  * @b EXPERIMENTAL: this API may change without prior notice.
211493e441c9SXueming Li  *
211593e441c9SXueming Li  * Get RTE_ETH_DEV_CAPA_* flag name.
211693e441c9SXueming Li  *
211793e441c9SXueming Li  * @param capability
211893e441c9SXueming Li  *   Capability flag.
211993e441c9SXueming Li  * @return
212093e441c9SXueming Li  *   Capability name or 'UNKNOWN' if the flag cannot be recognized.
212193e441c9SXueming Li  */
212293e441c9SXueming Li __rte_experimental
212393e441c9SXueming Li const char *rte_eth_dev_capability_name(uint64_t capability);
212493e441c9SXueming Li 
212593e441c9SXueming Li /**
212699a2dd95SBruce Richardson  * Configure an Ethernet device.
212799a2dd95SBruce Richardson  * This function must be invoked first before any other function in the
212899a2dd95SBruce Richardson  * Ethernet API. This function can also be re-invoked when a device is in the
212999a2dd95SBruce Richardson  * stopped state.
213099a2dd95SBruce Richardson  *
213199a2dd95SBruce Richardson  * @param port_id
213299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device to configure.
213399a2dd95SBruce Richardson  * @param nb_rx_queue
213499a2dd95SBruce Richardson  *   The number of receive queues to set up for the Ethernet device.
213599a2dd95SBruce Richardson  * @param nb_tx_queue
213699a2dd95SBruce Richardson  *   The number of transmit queues to set up for the Ethernet device.
213799a2dd95SBruce Richardson  * @param eth_conf
213899a2dd95SBruce Richardson  *   The pointer to the configuration data to be used for the Ethernet device.
213999a2dd95SBruce Richardson  *   The *rte_eth_conf* structure includes:
214099a2dd95SBruce Richardson  *     -  the hardware offload features to activate, with dedicated fields for
214199a2dd95SBruce Richardson  *        each statically configurable offload hardware feature provided by
214299a2dd95SBruce Richardson  *        Ethernet devices, such as IP checksum or VLAN tag stripping for
214399a2dd95SBruce Richardson  *        example.
214499a2dd95SBruce Richardson  *        The Rx offload bitfield API is obsolete and will be deprecated.
214599a2dd95SBruce Richardson  *        Applications should set the ignore_bitfield_offloads bit on *rxmode*
214699a2dd95SBruce Richardson  *        structure and use offloads field to set per-port offloads instead.
214799a2dd95SBruce Richardson  *     -  Any offloading set in eth_conf->[rt]xmode.offloads must be within
214899a2dd95SBruce Richardson  *        the [rt]x_offload_capa returned from rte_eth_dev_info_get().
214999a2dd95SBruce Richardson  *        Any type of device supported offloading set in the input argument
215099a2dd95SBruce Richardson  *        eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is enabled
215199a2dd95SBruce Richardson  *        on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup()
215209fd4227SAndrew Rybchenko  *     -  the Receive Side Scaling (RSS) configuration when using multiple Rx
215399a2dd95SBruce Richardson  *        queues per port. Any RSS hash function set in eth_conf->rss_conf.rss_hf
215499a2dd95SBruce Richardson  *        must be within the flow_type_rss_offloads provided by drivers via
215599a2dd95SBruce Richardson  *        rte_eth_dev_info_get() API.
215699a2dd95SBruce Richardson  *
215799a2dd95SBruce Richardson  *   Embedding all configuration information in a single data structure
215899a2dd95SBruce Richardson  *   is the more flexible method that allows the addition of new features
215999a2dd95SBruce Richardson  *   without changing the syntax of the API.
216099a2dd95SBruce Richardson  * @return
216199a2dd95SBruce Richardson  *   - 0: Success, device configured.
216299a2dd95SBruce Richardson  *   - <0: Error code returned by the driver configuration function.
216399a2dd95SBruce Richardson  */
216499a2dd95SBruce Richardson int rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_queue,
216599a2dd95SBruce Richardson 		uint16_t nb_tx_queue, const struct rte_eth_conf *eth_conf);
216699a2dd95SBruce Richardson 
216799a2dd95SBruce Richardson /**
216899a2dd95SBruce Richardson  * Check if an Ethernet device was physically removed.
216999a2dd95SBruce Richardson  *
217099a2dd95SBruce Richardson  * @param port_id
217199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
217299a2dd95SBruce Richardson  * @return
217399a2dd95SBruce Richardson  *   1 when the Ethernet device is removed, otherwise 0.
217499a2dd95SBruce Richardson  */
217599a2dd95SBruce Richardson int
217699a2dd95SBruce Richardson rte_eth_dev_is_removed(uint16_t port_id);
217799a2dd95SBruce Richardson 
217899a2dd95SBruce Richardson /**
217999a2dd95SBruce Richardson  * Allocate and set up a receive queue for an Ethernet device.
218099a2dd95SBruce Richardson  *
218199a2dd95SBruce Richardson  * The function allocates a contiguous block of memory for *nb_rx_desc*
218299a2dd95SBruce Richardson  * receive descriptors from a memory zone associated with *socket_id*
218399a2dd95SBruce Richardson  * and initializes each receive descriptor with a network buffer allocated
218499a2dd95SBruce Richardson  * from the memory pool *mb_pool*.
218599a2dd95SBruce Richardson  *
218699a2dd95SBruce Richardson  * @param port_id
218799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
218899a2dd95SBruce Richardson  * @param rx_queue_id
218999a2dd95SBruce Richardson  *   The index of the receive queue to set up.
219099a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
219199a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
219299a2dd95SBruce Richardson  * @param nb_rx_desc
219399a2dd95SBruce Richardson  *   The number of receive descriptors to allocate for the receive ring.
219499a2dd95SBruce Richardson  * @param socket_id
219599a2dd95SBruce Richardson  *   The *socket_id* argument is the socket identifier in case of NUMA.
219699a2dd95SBruce Richardson  *   The value can be *SOCKET_ID_ANY* if there is no NUMA constraint for
219799a2dd95SBruce Richardson  *   the DMA memory allocated for the receive descriptors of the ring.
219899a2dd95SBruce Richardson  * @param rx_conf
219999a2dd95SBruce Richardson  *   The pointer to the configuration data to be used for the receive queue.
220009fd4227SAndrew Rybchenko  *   NULL value is allowed, in which case default Rx configuration
220199a2dd95SBruce Richardson  *   will be used.
220299a2dd95SBruce Richardson  *   The *rx_conf* structure contains an *rx_thresh* structure with the values
220399a2dd95SBruce Richardson  *   of the Prefetch, Host, and Write-Back threshold registers of the receive
220499a2dd95SBruce Richardson  *   ring.
220599a2dd95SBruce Richardson  *   In addition it contains the hardware offloads features to activate using
2206295968d1SFerruh Yigit  *   the RTE_ETH_RX_OFFLOAD_* flags.
220799a2dd95SBruce Richardson  *   If an offloading set in rx_conf->offloads
220899a2dd95SBruce Richardson  *   hasn't been set in the input argument eth_conf->rxmode.offloads
220999a2dd95SBruce Richardson  *   to rte_eth_dev_configure(), it is a new added offloading, it must be
221099a2dd95SBruce Richardson  *   per-queue type and it is enabled for the queue.
221199a2dd95SBruce Richardson  *   No need to repeat any bit in rx_conf->offloads which has already been
221299a2dd95SBruce Richardson  *   enabled in rte_eth_dev_configure() at port level. An offloading enabled
221399a2dd95SBruce Richardson  *   at port level can't be disabled at queue level.
221499a2dd95SBruce Richardson  *   The configuration structure also contains the pointer to the array
221599a2dd95SBruce Richardson  *   of the receiving buffer segment descriptions, see rx_seg and rx_nseg
221699a2dd95SBruce Richardson  *   fields, this extended configuration might be used by split offloads like
221797d7b927SJoyce Kong  *   RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT. If mb_pool is not NULL,
221899a2dd95SBruce Richardson  *   the extended configuration fields must be set to NULL and zero.
221999a2dd95SBruce Richardson  * @param mb_pool
222099a2dd95SBruce Richardson  *   The pointer to the memory pool from which to allocate *rte_mbuf* network
222199a2dd95SBruce Richardson  *   memory buffers to populate each descriptor of the receive ring. There are
222299a2dd95SBruce Richardson  *   two options to provide Rx buffer configuration:
222399a2dd95SBruce Richardson  *   - single pool:
222499a2dd95SBruce Richardson  *     mb_pool is not NULL, rx_conf.rx_nseg is 0.
222599a2dd95SBruce Richardson  *   - multiple segments description:
222699a2dd95SBruce Richardson  *     mb_pool is NULL, rx_conf.rx_seg is not NULL, rx_conf.rx_nseg is not 0.
222799a2dd95SBruce Richardson  *     Taken only if flag RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is set in offloads.
222899a2dd95SBruce Richardson  *
222999a2dd95SBruce Richardson  * @return
223099a2dd95SBruce Richardson  *   - 0: Success, receive queue correctly set up.
223199a2dd95SBruce Richardson  *   - -EIO: if device is removed.
223299a2dd95SBruce Richardson  *   - -ENODEV: if *port_id* is invalid.
223399a2dd95SBruce Richardson  *   - -EINVAL: The memory pool pointer is null or the size of network buffers
223499a2dd95SBruce Richardson  *      which can be allocated from this memory pool does not fit the various
223599a2dd95SBruce Richardson  *      buffer sizes allowed by the device controller.
223699a2dd95SBruce Richardson  *   - -ENOMEM: Unable to allocate the receive ring descriptors or to
223799a2dd95SBruce Richardson  *      allocate network memory buffers from the memory pool when
223899a2dd95SBruce Richardson  *      initializing receive descriptors.
223999a2dd95SBruce Richardson  */
224099a2dd95SBruce Richardson int rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
224199a2dd95SBruce Richardson 		uint16_t nb_rx_desc, unsigned int socket_id,
224299a2dd95SBruce Richardson 		const struct rte_eth_rxconf *rx_conf,
224399a2dd95SBruce Richardson 		struct rte_mempool *mb_pool);
224499a2dd95SBruce Richardson 
224599a2dd95SBruce Richardson /**
224699a2dd95SBruce Richardson  * @warning
224799a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
224899a2dd95SBruce Richardson  *
224999a2dd95SBruce Richardson  * Allocate and set up a hairpin receive queue for an Ethernet device.
225099a2dd95SBruce Richardson  *
225199a2dd95SBruce Richardson  * The function set up the selected queue to be used in hairpin.
225299a2dd95SBruce Richardson  *
225399a2dd95SBruce Richardson  * @param port_id
225499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
225599a2dd95SBruce Richardson  * @param rx_queue_id
225699a2dd95SBruce Richardson  *   The index of the receive queue to set up.
225799a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
225899a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
225999a2dd95SBruce Richardson  * @param nb_rx_desc
226099a2dd95SBruce Richardson  *   The number of receive descriptors to allocate for the receive ring.
226199a2dd95SBruce Richardson  *   0 means the PMD will use default value.
226299a2dd95SBruce Richardson  * @param conf
226399a2dd95SBruce Richardson  *   The pointer to the hairpin configuration.
226499a2dd95SBruce Richardson  *
226599a2dd95SBruce Richardson  * @return
226699a2dd95SBruce Richardson  *   - (0) if successful.
226799a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
226899a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
226999a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
227099a2dd95SBruce Richardson  *   - (-ENOMEM) if unable to allocate the resources.
227199a2dd95SBruce Richardson  */
227299a2dd95SBruce Richardson __rte_experimental
227399a2dd95SBruce Richardson int rte_eth_rx_hairpin_queue_setup
227499a2dd95SBruce Richardson 	(uint16_t port_id, uint16_t rx_queue_id, uint16_t nb_rx_desc,
227599a2dd95SBruce Richardson 	 const struct rte_eth_hairpin_conf *conf);
227699a2dd95SBruce Richardson 
227799a2dd95SBruce Richardson /**
227899a2dd95SBruce Richardson  * Allocate and set up a transmit queue for an Ethernet device.
227999a2dd95SBruce Richardson  *
228099a2dd95SBruce Richardson  * @param port_id
228199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
228299a2dd95SBruce Richardson  * @param tx_queue_id
228399a2dd95SBruce Richardson  *   The index of the transmit queue to set up.
228499a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
228599a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
228699a2dd95SBruce Richardson  * @param nb_tx_desc
228799a2dd95SBruce Richardson  *   The number of transmit descriptors to allocate for the transmit ring.
228899a2dd95SBruce Richardson  * @param socket_id
228999a2dd95SBruce Richardson  *   The *socket_id* argument is the socket identifier in case of NUMA.
229099a2dd95SBruce Richardson  *   Its value can be *SOCKET_ID_ANY* if there is no NUMA constraint for
229199a2dd95SBruce Richardson  *   the DMA memory allocated for the transmit descriptors of the ring.
229299a2dd95SBruce Richardson  * @param tx_conf
229399a2dd95SBruce Richardson  *   The pointer to the configuration data to be used for the transmit queue.
229409fd4227SAndrew Rybchenko  *   NULL value is allowed, in which case default Tx configuration
229599a2dd95SBruce Richardson  *   will be used.
229699a2dd95SBruce Richardson  *   The *tx_conf* structure contains the following data:
229799a2dd95SBruce Richardson  *   - The *tx_thresh* structure with the values of the Prefetch, Host, and
229899a2dd95SBruce Richardson  *     Write-Back threshold registers of the transmit ring.
229999a2dd95SBruce Richardson  *     When setting Write-Back threshold to the value greater then zero,
230099a2dd95SBruce Richardson  *     *tx_rs_thresh* value should be explicitly set to one.
230199a2dd95SBruce Richardson  *   - The *tx_free_thresh* value indicates the [minimum] number of network
230299a2dd95SBruce Richardson  *     buffers that must be pending in the transmit ring to trigger their
230399a2dd95SBruce Richardson  *     [implicit] freeing by the driver transmit function.
230499a2dd95SBruce Richardson  *   - The *tx_rs_thresh* value indicates the [minimum] number of transmit
230599a2dd95SBruce Richardson  *     descriptors that must be pending in the transmit ring before setting the
230699a2dd95SBruce Richardson  *     RS bit on a descriptor by the driver transmit function.
230799a2dd95SBruce Richardson  *     The *tx_rs_thresh* value should be less or equal then
230899a2dd95SBruce Richardson  *     *tx_free_thresh* value, and both of them should be less then
230999a2dd95SBruce Richardson  *     *nb_tx_desc* - 3.
231099a2dd95SBruce Richardson  *   - The *offloads* member contains Tx offloads to be enabled.
231199a2dd95SBruce Richardson  *     If an offloading set in tx_conf->offloads
231299a2dd95SBruce Richardson  *     hasn't been set in the input argument eth_conf->txmode.offloads
231399a2dd95SBruce Richardson  *     to rte_eth_dev_configure(), it is a new added offloading, it must be
231499a2dd95SBruce Richardson  *     per-queue type and it is enabled for the queue.
231599a2dd95SBruce Richardson  *     No need to repeat any bit in tx_conf->offloads which has already been
231699a2dd95SBruce Richardson  *     enabled in rte_eth_dev_configure() at port level. An offloading enabled
231799a2dd95SBruce Richardson  *     at port level can't be disabled at queue level.
231899a2dd95SBruce Richardson  *
231999a2dd95SBruce Richardson  *     Note that setting *tx_free_thresh* or *tx_rs_thresh* value to 0 forces
232099a2dd95SBruce Richardson  *     the transmit function to use default values.
232199a2dd95SBruce Richardson  * @return
232299a2dd95SBruce Richardson  *   - 0: Success, the transmit queue is correctly set up.
232399a2dd95SBruce Richardson  *   - -ENOMEM: Unable to allocate the transmit ring descriptors.
232499a2dd95SBruce Richardson  */
232599a2dd95SBruce Richardson int rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
232699a2dd95SBruce Richardson 		uint16_t nb_tx_desc, unsigned int socket_id,
232799a2dd95SBruce Richardson 		const struct rte_eth_txconf *tx_conf);
232899a2dd95SBruce Richardson 
232999a2dd95SBruce Richardson /**
233099a2dd95SBruce Richardson  * @warning
233199a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
233299a2dd95SBruce Richardson  *
233399a2dd95SBruce Richardson  * Allocate and set up a transmit hairpin queue for an Ethernet device.
233499a2dd95SBruce Richardson  *
233599a2dd95SBruce Richardson  * @param port_id
233699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
233799a2dd95SBruce Richardson  * @param tx_queue_id
233899a2dd95SBruce Richardson  *   The index of the transmit queue to set up.
233999a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
234099a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
234199a2dd95SBruce Richardson  * @param nb_tx_desc
234299a2dd95SBruce Richardson  *   The number of transmit descriptors to allocate for the transmit ring.
234399a2dd95SBruce Richardson  *   0 to set default PMD value.
234499a2dd95SBruce Richardson  * @param conf
234599a2dd95SBruce Richardson  *   The hairpin configuration.
234699a2dd95SBruce Richardson  *
234799a2dd95SBruce Richardson  * @return
234899a2dd95SBruce Richardson  *   - (0) if successful.
234999a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
235099a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
235199a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
235299a2dd95SBruce Richardson  *   - (-ENOMEM) if unable to allocate the resources.
235399a2dd95SBruce Richardson  */
235499a2dd95SBruce Richardson __rte_experimental
235599a2dd95SBruce Richardson int rte_eth_tx_hairpin_queue_setup
235699a2dd95SBruce Richardson 	(uint16_t port_id, uint16_t tx_queue_id, uint16_t nb_tx_desc,
235799a2dd95SBruce Richardson 	 const struct rte_eth_hairpin_conf *conf);
235899a2dd95SBruce Richardson 
235999a2dd95SBruce Richardson /**
236099a2dd95SBruce Richardson  * @warning
236199a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
236299a2dd95SBruce Richardson  *
236399a2dd95SBruce Richardson  * Get all the hairpin peer Rx / Tx ports of the current port.
236499a2dd95SBruce Richardson  * The caller should ensure that the array is large enough to save the ports
236599a2dd95SBruce Richardson  * list.
236699a2dd95SBruce Richardson  *
236799a2dd95SBruce Richardson  * @param port_id
236899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
236999a2dd95SBruce Richardson  * @param peer_ports
237099a2dd95SBruce Richardson  *   Pointer to the array to store the peer ports list.
237199a2dd95SBruce Richardson  * @param len
237299a2dd95SBruce Richardson  *   Length of the array to store the port identifiers.
237399a2dd95SBruce Richardson  * @param direction
237499a2dd95SBruce Richardson  *   Current port to peer port direction
237599a2dd95SBruce Richardson  *   positive - current used as Tx to get all peer Rx ports.
237699a2dd95SBruce Richardson  *   zero - current used as Rx to get all peer Tx ports.
237799a2dd95SBruce Richardson  *
237899a2dd95SBruce Richardson  * @return
237999a2dd95SBruce Richardson  *   - (0 or positive) actual peer ports number.
238099a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
238199a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid
238299a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
2383f8dbaebbSSean Morrissey  *   - Others detailed errors from PMDs.
238499a2dd95SBruce Richardson  */
238599a2dd95SBruce Richardson __rte_experimental
238699a2dd95SBruce Richardson int rte_eth_hairpin_get_peer_ports(uint16_t port_id, uint16_t *peer_ports,
238799a2dd95SBruce Richardson 				   size_t len, uint32_t direction);
238899a2dd95SBruce Richardson 
238999a2dd95SBruce Richardson /**
239099a2dd95SBruce Richardson  * @warning
239199a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
239299a2dd95SBruce Richardson  *
239399a2dd95SBruce Richardson  * Bind all hairpin Tx queues of one port to the Rx queues of the peer port.
239499a2dd95SBruce Richardson  * It is only allowed to call this function after all hairpin queues are
239599a2dd95SBruce Richardson  * configured properly and the devices are in started state.
239699a2dd95SBruce Richardson  *
239799a2dd95SBruce Richardson  * @param tx_port
239899a2dd95SBruce Richardson  *   The identifier of the Tx port.
239999a2dd95SBruce Richardson  * @param rx_port
240099a2dd95SBruce Richardson  *   The identifier of peer Rx port.
240199a2dd95SBruce Richardson  *   RTE_MAX_ETHPORTS is allowed for the traversal of all devices.
240299a2dd95SBruce Richardson  *   Rx port ID could have the same value as Tx port ID.
240399a2dd95SBruce Richardson  *
240499a2dd95SBruce Richardson  * @return
240599a2dd95SBruce Richardson  *   - (0) if successful.
240699a2dd95SBruce Richardson  *   - (-ENODEV) if Tx port ID is invalid.
240799a2dd95SBruce Richardson  *   - (-EBUSY) if device is not in started state.
240899a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
2409f8dbaebbSSean Morrissey  *   - Others detailed errors from PMDs.
241099a2dd95SBruce Richardson  */
241199a2dd95SBruce Richardson __rte_experimental
241299a2dd95SBruce Richardson int rte_eth_hairpin_bind(uint16_t tx_port, uint16_t rx_port);
241399a2dd95SBruce Richardson 
241499a2dd95SBruce Richardson /**
241599a2dd95SBruce Richardson  * @warning
241699a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
241799a2dd95SBruce Richardson  *
241899a2dd95SBruce Richardson  * Unbind all hairpin Tx queues of one port from the Rx queues of the peer port.
241999a2dd95SBruce Richardson  * This should be called before closing the Tx or Rx devices, if the bind
242099a2dd95SBruce Richardson  * function is called before.
242199a2dd95SBruce Richardson  * After unbinding the hairpin ports pair, it is allowed to bind them again.
242299a2dd95SBruce Richardson  * Changing queues configuration should be after stopping the device(s).
242399a2dd95SBruce Richardson  *
242499a2dd95SBruce Richardson  * @param tx_port
242599a2dd95SBruce Richardson  *   The identifier of the Tx port.
242699a2dd95SBruce Richardson  * @param rx_port
242799a2dd95SBruce Richardson  *   The identifier of peer Rx port.
242899a2dd95SBruce Richardson  *   RTE_MAX_ETHPORTS is allowed for traversal of all devices.
242999a2dd95SBruce Richardson  *   Rx port ID could have the same value as Tx port ID.
243099a2dd95SBruce Richardson  *
243199a2dd95SBruce Richardson  * @return
243299a2dd95SBruce Richardson  *   - (0) if successful.
243399a2dd95SBruce Richardson  *   - (-ENODEV) if Tx port ID is invalid.
243499a2dd95SBruce Richardson  *   - (-EBUSY) if device is in stopped state.
243599a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
2436f8dbaebbSSean Morrissey  *   - Others detailed errors from PMDs.
243799a2dd95SBruce Richardson  */
243899a2dd95SBruce Richardson __rte_experimental
243999a2dd95SBruce Richardson int rte_eth_hairpin_unbind(uint16_t tx_port, uint16_t rx_port);
244099a2dd95SBruce Richardson 
244199a2dd95SBruce Richardson /**
244299a2dd95SBruce Richardson  * Return the NUMA socket to which an Ethernet device is connected
244399a2dd95SBruce Richardson  *
244499a2dd95SBruce Richardson  * @param port_id
244599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device
244699a2dd95SBruce Richardson  * @return
24475906be5aSAndrew Rybchenko  *   The NUMA socket ID to which the Ethernet device is connected or
244899a2dd95SBruce Richardson  *   a default of zero if the socket could not be determined.
244999a2dd95SBruce Richardson  *   -1 is returned is the port_id value is out of range.
245099a2dd95SBruce Richardson  */
245199a2dd95SBruce Richardson int rte_eth_dev_socket_id(uint16_t port_id);
245299a2dd95SBruce Richardson 
245399a2dd95SBruce Richardson /**
245499a2dd95SBruce Richardson  * Check if port_id of device is attached
245599a2dd95SBruce Richardson  *
245699a2dd95SBruce Richardson  * @param port_id
245799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device
245899a2dd95SBruce Richardson  * @return
245999a2dd95SBruce Richardson  *   - 0 if port is out of range or not attached
246099a2dd95SBruce Richardson  *   - 1 if device is attached
246199a2dd95SBruce Richardson  */
246299a2dd95SBruce Richardson int rte_eth_dev_is_valid_port(uint16_t port_id);
246399a2dd95SBruce Richardson 
246499a2dd95SBruce Richardson /**
246509fd4227SAndrew Rybchenko  * Start specified Rx queue of a port. It is used when rx_deferred_start
246699a2dd95SBruce Richardson  * flag of the specified queue is true.
246799a2dd95SBruce Richardson  *
246899a2dd95SBruce Richardson  * @param port_id
246999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device
247099a2dd95SBruce Richardson  * @param rx_queue_id
247109fd4227SAndrew Rybchenko  *   The index of the Rx queue to update the ring.
247299a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
247399a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
247499a2dd95SBruce Richardson  * @return
247599a2dd95SBruce Richardson  *   - 0: Success, the receive queue is started.
247699a2dd95SBruce Richardson  *   - -ENODEV: if *port_id* is invalid.
247799a2dd95SBruce Richardson  *   - -EINVAL: The queue_id out of range or belong to hairpin.
247899a2dd95SBruce Richardson  *   - -EIO: if device is removed.
2479f8dbaebbSSean Morrissey  *   - -ENOTSUP: The function not supported in PMD.
248099a2dd95SBruce Richardson  */
248199a2dd95SBruce Richardson int rte_eth_dev_rx_queue_start(uint16_t port_id, uint16_t rx_queue_id);
248299a2dd95SBruce Richardson 
248399a2dd95SBruce Richardson /**
248409fd4227SAndrew Rybchenko  * Stop specified Rx queue of a port
248599a2dd95SBruce Richardson  *
248699a2dd95SBruce Richardson  * @param port_id
248799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device
248899a2dd95SBruce Richardson  * @param rx_queue_id
248909fd4227SAndrew Rybchenko  *   The index of the Rx queue to update the ring.
249099a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
249199a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
249299a2dd95SBruce Richardson  * @return
249399a2dd95SBruce Richardson  *   - 0: Success, the receive queue is stopped.
249499a2dd95SBruce Richardson  *   - -ENODEV: if *port_id* is invalid.
249599a2dd95SBruce Richardson  *   - -EINVAL: The queue_id out of range or belong to hairpin.
249699a2dd95SBruce Richardson  *   - -EIO: if device is removed.
2497f8dbaebbSSean Morrissey  *   - -ENOTSUP: The function not supported in PMD.
249899a2dd95SBruce Richardson  */
249999a2dd95SBruce Richardson int rte_eth_dev_rx_queue_stop(uint16_t port_id, uint16_t rx_queue_id);
250099a2dd95SBruce Richardson 
250199a2dd95SBruce Richardson /**
250209fd4227SAndrew Rybchenko  * Start Tx for specified queue of a port. It is used when tx_deferred_start
250399a2dd95SBruce Richardson  * flag of the specified queue is true.
250499a2dd95SBruce Richardson  *
250599a2dd95SBruce Richardson  * @param port_id
250699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device
250799a2dd95SBruce Richardson  * @param tx_queue_id
250809fd4227SAndrew Rybchenko  *   The index of the Tx queue to update the ring.
250999a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
251099a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
251199a2dd95SBruce Richardson  * @return
251299a2dd95SBruce Richardson  *   - 0: Success, the transmit queue is started.
251399a2dd95SBruce Richardson  *   - -ENODEV: if *port_id* is invalid.
251499a2dd95SBruce Richardson  *   - -EINVAL: The queue_id out of range or belong to hairpin.
251599a2dd95SBruce Richardson  *   - -EIO: if device is removed.
2516f8dbaebbSSean Morrissey  *   - -ENOTSUP: The function not supported in PMD.
251799a2dd95SBruce Richardson  */
251899a2dd95SBruce Richardson int rte_eth_dev_tx_queue_start(uint16_t port_id, uint16_t tx_queue_id);
251999a2dd95SBruce Richardson 
252099a2dd95SBruce Richardson /**
252109fd4227SAndrew Rybchenko  * Stop specified Tx queue of a port
252299a2dd95SBruce Richardson  *
252399a2dd95SBruce Richardson  * @param port_id
252499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device
252599a2dd95SBruce Richardson  * @param tx_queue_id
252609fd4227SAndrew Rybchenko  *   The index of the Tx queue to update the ring.
252799a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
252899a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
252999a2dd95SBruce Richardson  * @return
253099a2dd95SBruce Richardson  *   - 0: Success, the transmit queue is stopped.
253199a2dd95SBruce Richardson  *   - -ENODEV: if *port_id* is invalid.
253299a2dd95SBruce Richardson  *   - -EINVAL: The queue_id out of range or belong to hairpin.
253399a2dd95SBruce Richardson  *   - -EIO: if device is removed.
2534f8dbaebbSSean Morrissey  *   - -ENOTSUP: The function not supported in PMD.
253599a2dd95SBruce Richardson  */
253699a2dd95SBruce Richardson int rte_eth_dev_tx_queue_stop(uint16_t port_id, uint16_t tx_queue_id);
253799a2dd95SBruce Richardson 
253899a2dd95SBruce Richardson /**
253999a2dd95SBruce Richardson  * Start an Ethernet device.
254099a2dd95SBruce Richardson  *
254199a2dd95SBruce Richardson  * The device start step is the last one and consists of setting the configured
254299a2dd95SBruce Richardson  * offload features and in starting the transmit and the receive units of the
254399a2dd95SBruce Richardson  * device.
254499a2dd95SBruce Richardson  *
254599a2dd95SBruce Richardson  * Device RTE_ETH_DEV_NOLIVE_MAC_ADDR flag causes MAC address to be set before
254699a2dd95SBruce Richardson  * PMD port start callback function is invoked.
254799a2dd95SBruce Richardson  *
254899a2dd95SBruce Richardson  * On success, all basic functions exported by the Ethernet API (link status,
254999a2dd95SBruce Richardson  * receive/transmit, and so on) can be invoked.
255099a2dd95SBruce Richardson  *
255199a2dd95SBruce Richardson  * @param port_id
255299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
255399a2dd95SBruce Richardson  * @return
255499a2dd95SBruce Richardson  *   - 0: Success, Ethernet device started.
255599a2dd95SBruce Richardson  *   - <0: Error code of the driver device start function.
255699a2dd95SBruce Richardson  */
255799a2dd95SBruce Richardson int rte_eth_dev_start(uint16_t port_id);
255899a2dd95SBruce Richardson 
255999a2dd95SBruce Richardson /**
256099a2dd95SBruce Richardson  * Stop an Ethernet device. The device can be restarted with a call to
256199a2dd95SBruce Richardson  * rte_eth_dev_start()
256299a2dd95SBruce Richardson  *
256399a2dd95SBruce Richardson  * @param port_id
256499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
256599a2dd95SBruce Richardson  * @return
256699a2dd95SBruce Richardson  *   - 0: Success, Ethernet device stopped.
256799a2dd95SBruce Richardson  *   - <0: Error code of the driver device stop function.
256899a2dd95SBruce Richardson  */
256999a2dd95SBruce Richardson int rte_eth_dev_stop(uint16_t port_id);
257099a2dd95SBruce Richardson 
257199a2dd95SBruce Richardson /**
257299a2dd95SBruce Richardson  * Link up an Ethernet device.
257399a2dd95SBruce Richardson  *
257409fd4227SAndrew Rybchenko  * Set device link up will re-enable the device Rx/Tx
257599a2dd95SBruce Richardson  * functionality after it is previously set device linked down.
257699a2dd95SBruce Richardson  *
257799a2dd95SBruce Richardson  * @param port_id
257899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
257999a2dd95SBruce Richardson  * @return
258099a2dd95SBruce Richardson  *   - 0: Success, Ethernet device linked up.
258199a2dd95SBruce Richardson  *   - <0: Error code of the driver device link up function.
258299a2dd95SBruce Richardson  */
258399a2dd95SBruce Richardson int rte_eth_dev_set_link_up(uint16_t port_id);
258499a2dd95SBruce Richardson 
258599a2dd95SBruce Richardson /**
258699a2dd95SBruce Richardson  * Link down an Ethernet device.
258709fd4227SAndrew Rybchenko  * The device Rx/Tx functionality will be disabled if success,
258899a2dd95SBruce Richardson  * and it can be re-enabled with a call to
258999a2dd95SBruce Richardson  * rte_eth_dev_set_link_up()
259099a2dd95SBruce Richardson  *
259199a2dd95SBruce Richardson  * @param port_id
259299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
259399a2dd95SBruce Richardson  */
259499a2dd95SBruce Richardson int rte_eth_dev_set_link_down(uint16_t port_id);
259599a2dd95SBruce Richardson 
259699a2dd95SBruce Richardson /**
259799a2dd95SBruce Richardson  * Close a stopped Ethernet device. The device cannot be restarted!
259899a2dd95SBruce Richardson  * The function frees all port resources.
259999a2dd95SBruce Richardson  *
260099a2dd95SBruce Richardson  * @param port_id
260199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
260299a2dd95SBruce Richardson  * @return
260399a2dd95SBruce Richardson  *   - Zero if the port is closed successfully.
260499a2dd95SBruce Richardson  *   - Negative if something went wrong.
260599a2dd95SBruce Richardson  */
260699a2dd95SBruce Richardson int rte_eth_dev_close(uint16_t port_id);
260799a2dd95SBruce Richardson 
260899a2dd95SBruce Richardson /**
26095906be5aSAndrew Rybchenko  * Reset a Ethernet device and keep its port ID.
261099a2dd95SBruce Richardson  *
261199a2dd95SBruce Richardson  * When a port has to be reset passively, the DPDK application can invoke
261299a2dd95SBruce Richardson  * this function. For example when a PF is reset, all its VFs should also
261399a2dd95SBruce Richardson  * be reset. Normally a DPDK application can invoke this function when
261499a2dd95SBruce Richardson  * RTE_ETH_EVENT_INTR_RESET event is detected, but can also use it to start
261599a2dd95SBruce Richardson  * a port reset in other circumstances.
261699a2dd95SBruce Richardson  *
261799a2dd95SBruce Richardson  * When this function is called, it first stops the port and then calls the
261899a2dd95SBruce Richardson  * PMD specific dev_uninit( ) and dev_init( ) to return the port to initial
261999a2dd95SBruce Richardson  * state, in which no Tx and Rx queues are setup, as if the port has been
26205906be5aSAndrew Rybchenko  * reset and not started. The port keeps the port ID it had before the
262199a2dd95SBruce Richardson  * function call.
262299a2dd95SBruce Richardson  *
262399a2dd95SBruce Richardson  * After calling rte_eth_dev_reset( ), the application should use
262499a2dd95SBruce Richardson  * rte_eth_dev_configure( ), rte_eth_rx_queue_setup( ),
262599a2dd95SBruce Richardson  * rte_eth_tx_queue_setup( ), and rte_eth_dev_start( )
262699a2dd95SBruce Richardson  * to reconfigure the device as appropriate.
262799a2dd95SBruce Richardson  *
262899a2dd95SBruce Richardson  * Note: To avoid unexpected behavior, the application should stop calling
262999a2dd95SBruce Richardson  * Tx and Rx functions before calling rte_eth_dev_reset( ). For thread
263099a2dd95SBruce Richardson  * safety, all these controlling functions should be called from the same
263199a2dd95SBruce Richardson  * thread.
263299a2dd95SBruce Richardson  *
263399a2dd95SBruce Richardson  * @param port_id
263499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
263599a2dd95SBruce Richardson  *
263699a2dd95SBruce Richardson  * @return
263799a2dd95SBruce Richardson  *   - (0) if successful.
263899a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
263999a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support this function.
264099a2dd95SBruce Richardson  *   - (-EPERM) if not ran from the primary process.
264199a2dd95SBruce Richardson  *   - (-EIO) if re-initialisation failed or device is removed.
264299a2dd95SBruce Richardson  *   - (-ENOMEM) if the reset failed due to OOM.
264399a2dd95SBruce Richardson  *   - (-EAGAIN) if the reset temporarily failed and should be retried later.
264499a2dd95SBruce Richardson  */
264599a2dd95SBruce Richardson int rte_eth_dev_reset(uint16_t port_id);
264699a2dd95SBruce Richardson 
264799a2dd95SBruce Richardson /**
264899a2dd95SBruce Richardson  * Enable receipt in promiscuous mode for an Ethernet device.
264999a2dd95SBruce Richardson  *
265099a2dd95SBruce Richardson  * @param port_id
265199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
265299a2dd95SBruce Richardson  * @return
265399a2dd95SBruce Richardson  *   - (0) if successful.
265499a2dd95SBruce Richardson  *   - (-ENOTSUP) if support for promiscuous_enable() does not exist
265599a2dd95SBruce Richardson  *     for the device.
265699a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
265799a2dd95SBruce Richardson  */
265899a2dd95SBruce Richardson int rte_eth_promiscuous_enable(uint16_t port_id);
265999a2dd95SBruce Richardson 
266099a2dd95SBruce Richardson /**
266199a2dd95SBruce Richardson  * Disable receipt in promiscuous mode for an Ethernet device.
266299a2dd95SBruce Richardson  *
266399a2dd95SBruce Richardson  * @param port_id
266499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
266599a2dd95SBruce Richardson  * @return
266699a2dd95SBruce Richardson  *   - (0) if successful.
266799a2dd95SBruce Richardson  *   - (-ENOTSUP) if support for promiscuous_disable() does not exist
266899a2dd95SBruce Richardson  *     for the device.
266999a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
267099a2dd95SBruce Richardson  */
267199a2dd95SBruce Richardson int rte_eth_promiscuous_disable(uint16_t port_id);
267299a2dd95SBruce Richardson 
267399a2dd95SBruce Richardson /**
267499a2dd95SBruce Richardson  * Return the value of promiscuous mode for an Ethernet device.
267599a2dd95SBruce Richardson  *
267699a2dd95SBruce Richardson  * @param port_id
267799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
267899a2dd95SBruce Richardson  * @return
267999a2dd95SBruce Richardson  *   - (1) if promiscuous is enabled
268099a2dd95SBruce Richardson  *   - (0) if promiscuous is disabled.
268199a2dd95SBruce Richardson  *   - (-1) on error
268299a2dd95SBruce Richardson  */
268399a2dd95SBruce Richardson int rte_eth_promiscuous_get(uint16_t port_id);
268499a2dd95SBruce Richardson 
268599a2dd95SBruce Richardson /**
268699a2dd95SBruce Richardson  * Enable the receipt of any multicast frame by an Ethernet device.
268799a2dd95SBruce Richardson  *
268899a2dd95SBruce Richardson  * @param port_id
268999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
269099a2dd95SBruce Richardson  * @return
269199a2dd95SBruce Richardson  *   - (0) if successful.
269299a2dd95SBruce Richardson  *   - (-ENOTSUP) if support for allmulticast_enable() does not exist
269399a2dd95SBruce Richardson  *     for the device.
269499a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
269599a2dd95SBruce Richardson  */
269699a2dd95SBruce Richardson int rte_eth_allmulticast_enable(uint16_t port_id);
269799a2dd95SBruce Richardson 
269899a2dd95SBruce Richardson /**
269999a2dd95SBruce Richardson  * Disable the receipt of all multicast frames by an Ethernet device.
270099a2dd95SBruce Richardson  *
270199a2dd95SBruce Richardson  * @param port_id
270299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
270399a2dd95SBruce Richardson  * @return
270499a2dd95SBruce Richardson  *   - (0) if successful.
270599a2dd95SBruce Richardson  *   - (-ENOTSUP) if support for allmulticast_disable() does not exist
270699a2dd95SBruce Richardson  *     for the device.
270799a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
270899a2dd95SBruce Richardson  */
270999a2dd95SBruce Richardson int rte_eth_allmulticast_disable(uint16_t port_id);
271099a2dd95SBruce Richardson 
271199a2dd95SBruce Richardson /**
271299a2dd95SBruce Richardson  * Return the value of allmulticast mode for an Ethernet device.
271399a2dd95SBruce Richardson  *
271499a2dd95SBruce Richardson  * @param port_id
271599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
271699a2dd95SBruce Richardson  * @return
271799a2dd95SBruce Richardson  *   - (1) if allmulticast is enabled
271899a2dd95SBruce Richardson  *   - (0) if allmulticast is disabled.
271999a2dd95SBruce Richardson  *   - (-1) on error
272099a2dd95SBruce Richardson  */
272199a2dd95SBruce Richardson int rte_eth_allmulticast_get(uint16_t port_id);
272299a2dd95SBruce Richardson 
272399a2dd95SBruce Richardson /**
272499a2dd95SBruce Richardson  * Retrieve the link status (up/down), the duplex mode (half/full),
272599a2dd95SBruce Richardson  * the negotiation (auto/fixed), and if available, the speed (Mbps).
272699a2dd95SBruce Richardson  *
272799a2dd95SBruce Richardson  * It might need to wait up to 9 seconds.
272899a2dd95SBruce Richardson  * @see rte_eth_link_get_nowait.
272999a2dd95SBruce Richardson  *
273099a2dd95SBruce Richardson  * @param port_id
273199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
273299a2dd95SBruce Richardson  * @param link
273399a2dd95SBruce Richardson  *   Link information written back.
273499a2dd95SBruce Richardson  * @return
273599a2dd95SBruce Richardson  *   - (0) if successful.
2736f8dbaebbSSean Morrissey  *   - (-ENOTSUP) if the function is not supported in PMD.
273799a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
273853ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
273999a2dd95SBruce Richardson  */
274099a2dd95SBruce Richardson int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link);
274199a2dd95SBruce Richardson 
274299a2dd95SBruce Richardson /**
274399a2dd95SBruce Richardson  * Retrieve the link status (up/down), the duplex mode (half/full),
274499a2dd95SBruce Richardson  * the negotiation (auto/fixed), and if available, the speed (Mbps).
274599a2dd95SBruce Richardson  *
274699a2dd95SBruce Richardson  * @param port_id
274799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
274899a2dd95SBruce Richardson  * @param link
274999a2dd95SBruce Richardson  *   Link information written back.
275099a2dd95SBruce Richardson  * @return
275199a2dd95SBruce Richardson  *   - (0) if successful.
2752f8dbaebbSSean Morrissey  *   - (-ENOTSUP) if the function is not supported in PMD.
275399a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
275453ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
275599a2dd95SBruce Richardson  */
275699a2dd95SBruce Richardson int rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *link);
275799a2dd95SBruce Richardson 
275899a2dd95SBruce Richardson /**
275999a2dd95SBruce Richardson  * @warning
276099a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
276199a2dd95SBruce Richardson  *
276299a2dd95SBruce Richardson  * The function converts a link_speed to a string. It handles all special
276399a2dd95SBruce Richardson  * values like unknown or none speed.
276499a2dd95SBruce Richardson  *
276599a2dd95SBruce Richardson  * @param link_speed
276699a2dd95SBruce Richardson  *   link_speed of rte_eth_link struct
276799a2dd95SBruce Richardson  * @return
276899a2dd95SBruce Richardson  *   Link speed in textual format. It's pointer to immutable memory.
276999a2dd95SBruce Richardson  *   No free is required.
277099a2dd95SBruce Richardson  */
277199a2dd95SBruce Richardson __rte_experimental
277299a2dd95SBruce Richardson const char *rte_eth_link_speed_to_str(uint32_t link_speed);
277399a2dd95SBruce Richardson 
277499a2dd95SBruce Richardson /**
277599a2dd95SBruce Richardson  * @warning
277699a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
277799a2dd95SBruce Richardson  *
277899a2dd95SBruce Richardson  * The function converts a rte_eth_link struct representing a link status to
277999a2dd95SBruce Richardson  * a string.
278099a2dd95SBruce Richardson  *
278199a2dd95SBruce Richardson  * @param str
278299a2dd95SBruce Richardson  *   A pointer to a string to be filled with textual representation of
2783295968d1SFerruh Yigit  *   device status. At least RTE_ETH_LINK_MAX_STR_LEN bytes should be allocated to
278499a2dd95SBruce Richardson  *   store default link status text.
278599a2dd95SBruce Richardson  * @param len
278699a2dd95SBruce Richardson  *   Length of available memory at 'str' string.
278799a2dd95SBruce Richardson  * @param eth_link
278899a2dd95SBruce Richardson  *   Link status returned by rte_eth_link_get function
278999a2dd95SBruce Richardson  * @return
279053ef1b34SMin Hu (Connor)  *   Number of bytes written to str array or -EINVAL if bad parameter.
279199a2dd95SBruce Richardson  */
279299a2dd95SBruce Richardson __rte_experimental
279399a2dd95SBruce Richardson int rte_eth_link_to_str(char *str, size_t len,
279499a2dd95SBruce Richardson 			const struct rte_eth_link *eth_link);
279599a2dd95SBruce Richardson 
279699a2dd95SBruce Richardson /**
279799a2dd95SBruce Richardson  * Retrieve the general I/O statistics of an Ethernet device.
279899a2dd95SBruce Richardson  *
279999a2dd95SBruce Richardson  * @param port_id
280099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
280199a2dd95SBruce Richardson  * @param stats
280299a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_eth_stats* to be filled with
280399a2dd95SBruce Richardson  *   the values of device counters for the following set of statistics:
280499a2dd95SBruce Richardson  *   - *ipackets* with the total of successfully received packets.
280599a2dd95SBruce Richardson  *   - *opackets* with the total of successfully transmitted packets.
280699a2dd95SBruce Richardson  *   - *ibytes*   with the total of successfully received bytes.
280799a2dd95SBruce Richardson  *   - *obytes*   with the total of successfully transmitted bytes.
280899a2dd95SBruce Richardson  *   - *ierrors*  with the total of erroneous received packets.
280999a2dd95SBruce Richardson  *   - *oerrors*  with the total of failed transmitted packets.
281099a2dd95SBruce Richardson  * @return
281199a2dd95SBruce Richardson  *   Zero if successful. Non-zero otherwise.
281299a2dd95SBruce Richardson  */
281399a2dd95SBruce Richardson int rte_eth_stats_get(uint16_t port_id, struct rte_eth_stats *stats);
281499a2dd95SBruce Richardson 
281599a2dd95SBruce Richardson /**
281699a2dd95SBruce Richardson  * Reset the general I/O statistics of an Ethernet device.
281799a2dd95SBruce Richardson  *
281899a2dd95SBruce Richardson  * @param port_id
281999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
282099a2dd95SBruce Richardson  * @return
282199a2dd95SBruce Richardson  *   - (0) if device notified to reset stats.
282299a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
282399a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
282499a2dd95SBruce Richardson  *   - (<0): Error code of the driver stats reset function.
282599a2dd95SBruce Richardson  */
282699a2dd95SBruce Richardson int rte_eth_stats_reset(uint16_t port_id);
282799a2dd95SBruce Richardson 
282899a2dd95SBruce Richardson /**
282999a2dd95SBruce Richardson  * Retrieve names of extended statistics of an Ethernet device.
283099a2dd95SBruce Richardson  *
283199a2dd95SBruce Richardson  * There is an assumption that 'xstat_names' and 'xstats' arrays are matched
283299a2dd95SBruce Richardson  * by array index:
283399a2dd95SBruce Richardson  *  xstats_names[i].name => xstats[i].value
283499a2dd95SBruce Richardson  *
283599a2dd95SBruce Richardson  * And the array index is same with id field of 'struct rte_eth_xstat':
283699a2dd95SBruce Richardson  *  xstats[i].id == i
283799a2dd95SBruce Richardson  *
283899a2dd95SBruce Richardson  * This assumption makes key-value pair matching less flexible but simpler.
283999a2dd95SBruce Richardson  *
284099a2dd95SBruce Richardson  * @param port_id
284199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
284299a2dd95SBruce Richardson  * @param xstats_names
284399a2dd95SBruce Richardson  *   An rte_eth_xstat_name array of at least *size* elements to
284499a2dd95SBruce Richardson  *   be filled. If set to NULL, the function returns the required number
284599a2dd95SBruce Richardson  *   of elements.
284699a2dd95SBruce Richardson  * @param size
284799a2dd95SBruce Richardson  *   The size of the xstats_names array (number of elements).
284899a2dd95SBruce Richardson  * @return
284999a2dd95SBruce Richardson  *   - A positive value lower or equal to size: success. The return value
285099a2dd95SBruce Richardson  *     is the number of entries filled in the stats table.
285199a2dd95SBruce Richardson  *   - A positive value higher than size: error, the given statistics table
285299a2dd95SBruce Richardson  *     is too small. The return value corresponds to the size that should
285399a2dd95SBruce Richardson  *     be given to succeed. The entries in the table are not valid and
285499a2dd95SBruce Richardson  *     shall not be used by the caller.
28555906be5aSAndrew Rybchenko  *   - A negative value on error (invalid port ID).
285699a2dd95SBruce Richardson  */
285799a2dd95SBruce Richardson int rte_eth_xstats_get_names(uint16_t port_id,
285899a2dd95SBruce Richardson 		struct rte_eth_xstat_name *xstats_names,
285999a2dd95SBruce Richardson 		unsigned int size);
286099a2dd95SBruce Richardson 
286199a2dd95SBruce Richardson /**
286299a2dd95SBruce Richardson  * Retrieve extended statistics of an Ethernet device.
286399a2dd95SBruce Richardson  *
286499a2dd95SBruce Richardson  * There is an assumption that 'xstat_names' and 'xstats' arrays are matched
286599a2dd95SBruce Richardson  * by array index:
286699a2dd95SBruce Richardson  *  xstats_names[i].name => xstats[i].value
286799a2dd95SBruce Richardson  *
286899a2dd95SBruce Richardson  * And the array index is same with id field of 'struct rte_eth_xstat':
286999a2dd95SBruce Richardson  *  xstats[i].id == i
287099a2dd95SBruce Richardson  *
287199a2dd95SBruce Richardson  * This assumption makes key-value pair matching less flexible but simpler.
287299a2dd95SBruce Richardson  *
287399a2dd95SBruce Richardson  * @param port_id
287499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
287599a2dd95SBruce Richardson  * @param xstats
287699a2dd95SBruce Richardson  *   A pointer to a table of structure of type *rte_eth_xstat*
287799a2dd95SBruce Richardson  *   to be filled with device statistics ids and values.
2878485df884SChengwen Feng  *   This parameter can be set to NULL if and only if n is 0.
287999a2dd95SBruce Richardson  * @param n
288099a2dd95SBruce Richardson  *   The size of the xstats array (number of elements).
2881485df884SChengwen Feng  *   If lower than the required number of elements, the function returns
2882485df884SChengwen Feng  *   the required number of elements.
2883485df884SChengwen Feng  *   If equal to zero, the xstats must be NULL, the function returns the
2884485df884SChengwen Feng  *   required number of elements.
288599a2dd95SBruce Richardson  * @return
288699a2dd95SBruce Richardson  *   - A positive value lower or equal to n: success. The return value
288799a2dd95SBruce Richardson  *     is the number of entries filled in the stats table.
288899a2dd95SBruce Richardson  *   - A positive value higher than n: error, the given statistics table
288999a2dd95SBruce Richardson  *     is too small. The return value corresponds to the size that should
289099a2dd95SBruce Richardson  *     be given to succeed. The entries in the table are not valid and
289199a2dd95SBruce Richardson  *     shall not be used by the caller.
28925906be5aSAndrew Rybchenko  *   - A negative value on error (invalid port ID).
289399a2dd95SBruce Richardson  */
289499a2dd95SBruce Richardson int rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats,
289599a2dd95SBruce Richardson 		unsigned int n);
289699a2dd95SBruce Richardson 
289799a2dd95SBruce Richardson /**
289899a2dd95SBruce Richardson  * Retrieve names of extended statistics of an Ethernet device.
289999a2dd95SBruce Richardson  *
290099a2dd95SBruce Richardson  * @param port_id
290199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
290299a2dd95SBruce Richardson  * @param xstats_names
2903bc5112caSIvan Ilchenko  *   Array to be filled in with names of requested device statistics.
2904bc5112caSIvan Ilchenko  *   Must not be NULL if @p ids are specified (not NULL).
290599a2dd95SBruce Richardson  * @param size
2906bc5112caSIvan Ilchenko  *   Number of elements in @p xstats_names array (if not NULL) and in
2907bc5112caSIvan Ilchenko  *   @p ids array (if not NULL). Must be 0 if both array pointers are NULL.
2908bc5112caSIvan Ilchenko  * @param ids
2909bc5112caSIvan Ilchenko  *   IDs array given by app to retrieve specific statistics. May be NULL to
2910bc5112caSIvan Ilchenko  *   retrieve names of all available statistics or, if @p xstats_names is
2911bc5112caSIvan Ilchenko  *   NULL as well, just the number of available statistics.
291299a2dd95SBruce Richardson  * @return
291399a2dd95SBruce Richardson  *   - A positive value lower or equal to size: success. The return value
291499a2dd95SBruce Richardson  *     is the number of entries filled in the stats table.
2915bc5112caSIvan Ilchenko  *   - A positive value higher than size: success. The given statistics table
291699a2dd95SBruce Richardson  *     is too small. The return value corresponds to the size that should
291799a2dd95SBruce Richardson  *     be given to succeed. The entries in the table are not valid and
291899a2dd95SBruce Richardson  *     shall not be used by the caller.
2919bc5112caSIvan Ilchenko  *   - A negative value on error.
292099a2dd95SBruce Richardson  */
292199a2dd95SBruce Richardson int
292299a2dd95SBruce Richardson rte_eth_xstats_get_names_by_id(uint16_t port_id,
292399a2dd95SBruce Richardson 	struct rte_eth_xstat_name *xstats_names, unsigned int size,
292499a2dd95SBruce Richardson 	uint64_t *ids);
292599a2dd95SBruce Richardson 
292699a2dd95SBruce Richardson /**
292799a2dd95SBruce Richardson  * Retrieve extended statistics of an Ethernet device.
292899a2dd95SBruce Richardson  *
292999a2dd95SBruce Richardson  * @param port_id
293099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
293199a2dd95SBruce Richardson  * @param ids
2932bc5112caSIvan Ilchenko  *   IDs array given by app to retrieve specific statistics. May be NULL to
2933bc5112caSIvan Ilchenko  *   retrieve all available statistics or, if @p values is NULL as well,
2934bc5112caSIvan Ilchenko  *   just the number of available statistics.
293599a2dd95SBruce Richardson  * @param values
2936bc5112caSIvan Ilchenko  *   Array to be filled in with requested device statistics.
2937bc5112caSIvan Ilchenko  *   Must not be NULL if ids are specified (not NULL).
293899a2dd95SBruce Richardson  * @param size
2939bc5112caSIvan Ilchenko  *   Number of elements in @p values array (if not NULL) and in @p ids
2940bc5112caSIvan Ilchenko  *   array (if not NULL). Must be 0 if both array pointers are NULL.
294199a2dd95SBruce Richardson  * @return
294299a2dd95SBruce Richardson  *   - A positive value lower or equal to size: success. The return value
294399a2dd95SBruce Richardson  *     is the number of entries filled in the stats table.
2944bc5112caSIvan Ilchenko  *   - A positive value higher than size: success: The given statistics table
294599a2dd95SBruce Richardson  *     is too small. The return value corresponds to the size that should
294699a2dd95SBruce Richardson  *     be given to succeed. The entries in the table are not valid and
294799a2dd95SBruce Richardson  *     shall not be used by the caller.
2948bc5112caSIvan Ilchenko  *   - A negative value on error.
294999a2dd95SBruce Richardson  */
295099a2dd95SBruce Richardson int rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,
295199a2dd95SBruce Richardson 			     uint64_t *values, unsigned int size);
295299a2dd95SBruce Richardson 
295399a2dd95SBruce Richardson /**
295499a2dd95SBruce Richardson  * Gets the ID of a statistic from its name.
295599a2dd95SBruce Richardson  *
295699a2dd95SBruce Richardson  * This function searches for the statistics using string compares, and
295799a2dd95SBruce Richardson  * as such should not be used on the fast-path. For fast-path retrieval of
295899a2dd95SBruce Richardson  * specific statistics, store the ID as provided in *id* from this function,
295999a2dd95SBruce Richardson  * and pass the ID to rte_eth_xstats_get()
296099a2dd95SBruce Richardson  *
296199a2dd95SBruce Richardson  * @param port_id The port to look up statistics from
296299a2dd95SBruce Richardson  * @param xstat_name The name of the statistic to return
296399a2dd95SBruce Richardson  * @param[out] id A pointer to an app-supplied uint64_t which should be
296499a2dd95SBruce Richardson  *                set to the ID of the stat if the stat exists.
296599a2dd95SBruce Richardson  * @return
296699a2dd95SBruce Richardson  *    0 on success
296799a2dd95SBruce Richardson  *    -ENODEV for invalid port_id,
296899a2dd95SBruce Richardson  *    -EIO if device is removed,
296999a2dd95SBruce Richardson  *    -EINVAL if the xstat_name doesn't exist in port_id
297053ef1b34SMin Hu (Connor)  *    -ENOMEM if bad parameter.
297199a2dd95SBruce Richardson  */
297299a2dd95SBruce Richardson int rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name,
297399a2dd95SBruce Richardson 		uint64_t *id);
297499a2dd95SBruce Richardson 
297599a2dd95SBruce Richardson /**
297699a2dd95SBruce Richardson  * Reset extended statistics of an Ethernet device.
297799a2dd95SBruce Richardson  *
297899a2dd95SBruce Richardson  * @param port_id
297999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
298099a2dd95SBruce Richardson  * @return
298199a2dd95SBruce Richardson  *   - (0) if device notified to reset extended stats.
298299a2dd95SBruce Richardson  *   - (-ENOTSUP) if pmd doesn't support both
298399a2dd95SBruce Richardson  *     extended stats and basic stats reset.
298499a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
298599a2dd95SBruce Richardson  *   - (<0): Error code of the driver xstats reset function.
298699a2dd95SBruce Richardson  */
298799a2dd95SBruce Richardson int rte_eth_xstats_reset(uint16_t port_id);
298899a2dd95SBruce Richardson 
298999a2dd95SBruce Richardson /**
299099a2dd95SBruce Richardson  *  Set a mapping for the specified transmit queue to the specified per-queue
299199a2dd95SBruce Richardson  *  statistics counter.
299299a2dd95SBruce Richardson  *
299399a2dd95SBruce Richardson  * @param port_id
299499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
299599a2dd95SBruce Richardson  * @param tx_queue_id
299699a2dd95SBruce Richardson  *   The index of the transmit queue for which a queue stats mapping is required.
299799a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
299899a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
299999a2dd95SBruce Richardson  * @param stat_idx
300099a2dd95SBruce Richardson  *   The per-queue packet statistics functionality number that the transmit
300199a2dd95SBruce Richardson  *   queue is to be assigned.
300299a2dd95SBruce Richardson  *   The value must be in the range [0, RTE_ETHDEV_QUEUE_STAT_CNTRS - 1].
300399a2dd95SBruce Richardson  *   Max RTE_ETHDEV_QUEUE_STAT_CNTRS being 256.
300499a2dd95SBruce Richardson  * @return
300599a2dd95SBruce Richardson  *   Zero if successful. Non-zero otherwise.
300699a2dd95SBruce Richardson  */
300799a2dd95SBruce Richardson int rte_eth_dev_set_tx_queue_stats_mapping(uint16_t port_id,
300899a2dd95SBruce Richardson 		uint16_t tx_queue_id, uint8_t stat_idx);
300999a2dd95SBruce Richardson 
301099a2dd95SBruce Richardson /**
301199a2dd95SBruce Richardson  *  Set a mapping for the specified receive queue to the specified per-queue
301299a2dd95SBruce Richardson  *  statistics counter.
301399a2dd95SBruce Richardson  *
301499a2dd95SBruce Richardson  * @param port_id
301599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
301699a2dd95SBruce Richardson  * @param rx_queue_id
301799a2dd95SBruce Richardson  *   The index of the receive queue for which a queue stats mapping is required.
301899a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
301999a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
302099a2dd95SBruce Richardson  * @param stat_idx
302199a2dd95SBruce Richardson  *   The per-queue packet statistics functionality number that the receive
302299a2dd95SBruce Richardson  *   queue is to be assigned.
302399a2dd95SBruce Richardson  *   The value must be in the range [0, RTE_ETHDEV_QUEUE_STAT_CNTRS - 1].
302499a2dd95SBruce Richardson  *   Max RTE_ETHDEV_QUEUE_STAT_CNTRS being 256.
302599a2dd95SBruce Richardson  * @return
302699a2dd95SBruce Richardson  *   Zero if successful. Non-zero otherwise.
302799a2dd95SBruce Richardson  */
302899a2dd95SBruce Richardson int rte_eth_dev_set_rx_queue_stats_mapping(uint16_t port_id,
302999a2dd95SBruce Richardson 					   uint16_t rx_queue_id,
303099a2dd95SBruce Richardson 					   uint8_t stat_idx);
303199a2dd95SBruce Richardson 
303299a2dd95SBruce Richardson /**
303399a2dd95SBruce Richardson  * Retrieve the Ethernet address of an Ethernet device.
303499a2dd95SBruce Richardson  *
303599a2dd95SBruce Richardson  * @param port_id
303699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
303799a2dd95SBruce Richardson  * @param mac_addr
303899a2dd95SBruce Richardson  *   A pointer to a structure of type *ether_addr* to be filled with
303999a2dd95SBruce Richardson  *   the Ethernet address of the Ethernet device.
304099a2dd95SBruce Richardson  * @return
304199a2dd95SBruce Richardson  *   - (0) if successful
304299a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
304353ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
304499a2dd95SBruce Richardson  */
304599a2dd95SBruce Richardson int rte_eth_macaddr_get(uint16_t port_id, struct rte_ether_addr *mac_addr);
304699a2dd95SBruce Richardson 
304799a2dd95SBruce Richardson /**
304827a300e6SKonstantin Ananyev  * @warning
304927a300e6SKonstantin Ananyev  * @b EXPERIMENTAL: this API may change without prior notice
305027a300e6SKonstantin Ananyev  *
305127a300e6SKonstantin Ananyev  * Retrieve the Ethernet addresses of an Ethernet device.
305227a300e6SKonstantin Ananyev  *
305327a300e6SKonstantin Ananyev  * @param port_id
305427a300e6SKonstantin Ananyev  *   The port identifier of the Ethernet device.
305527a300e6SKonstantin Ananyev  * @param ma
305627a300e6SKonstantin Ananyev  *   A pointer to an array of structures of type *ether_addr* to be filled with
305727a300e6SKonstantin Ananyev  *   the Ethernet addresses of the Ethernet device.
305827a300e6SKonstantin Ananyev  * @param num
305927a300e6SKonstantin Ananyev  *   Number of elements in the @p ma array.
306027a300e6SKonstantin Ananyev  *   Note that  rte_eth_dev_info::max_mac_addrs can be used to retrieve
306127a300e6SKonstantin Ananyev  *   max number of Ethernet addresses for given port.
306227a300e6SKonstantin Ananyev  * @return
306327a300e6SKonstantin Ananyev  *   - number of retrieved addresses if successful
306427a300e6SKonstantin Ananyev  *   - (-ENODEV) if *port_id* invalid.
306527a300e6SKonstantin Ananyev  *   - (-EINVAL) if bad parameter.
306627a300e6SKonstantin Ananyev  */
306727a300e6SKonstantin Ananyev __rte_experimental
306827a300e6SKonstantin Ananyev int rte_eth_macaddrs_get(uint16_t port_id, struct rte_ether_addr *ma,
306927a300e6SKonstantin Ananyev 	unsigned int num);
307027a300e6SKonstantin Ananyev 
307127a300e6SKonstantin Ananyev /**
307299a2dd95SBruce Richardson  * Retrieve the contextual information of an Ethernet device.
307399a2dd95SBruce Richardson  *
307499a2dd95SBruce Richardson  * As part of this function, a number of of fields in dev_info will be
307599a2dd95SBruce Richardson  * initialized as follows:
307699a2dd95SBruce Richardson  *
307799a2dd95SBruce Richardson  * rx_desc_lim = lim
307899a2dd95SBruce Richardson  * tx_desc_lim = lim
307999a2dd95SBruce Richardson  *
308099a2dd95SBruce Richardson  * Where lim is defined within the rte_eth_dev_info_get as
308199a2dd95SBruce Richardson  *
308299a2dd95SBruce Richardson  *  const struct rte_eth_desc_lim lim = {
308399a2dd95SBruce Richardson  *      .nb_max = UINT16_MAX,
308499a2dd95SBruce Richardson  *      .nb_min = 0,
308599a2dd95SBruce Richardson  *      .nb_align = 1,
308699a2dd95SBruce Richardson  *	.nb_seg_max = UINT16_MAX,
308799a2dd95SBruce Richardson  *	.nb_mtu_seg_max = UINT16_MAX,
308899a2dd95SBruce Richardson  *  };
308999a2dd95SBruce Richardson  *
309099a2dd95SBruce Richardson  * device = dev->device
3091990912e6SFerruh Yigit  * min_mtu = RTE_ETHER_MIN_LEN - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN
309299a2dd95SBruce Richardson  * max_mtu = UINT16_MAX
309399a2dd95SBruce Richardson  *
309499a2dd95SBruce Richardson  * The following fields will be populated if support for dev_infos_get()
309599a2dd95SBruce Richardson  * exists for the device and the rte_eth_dev 'dev' has been populated
309699a2dd95SBruce Richardson  * successfully with a call to it:
309799a2dd95SBruce Richardson  *
3098ec5ecd7eSDavid Marchand  * driver_name = rte_driver_name(rte_dev_driver(dev->device));
309999a2dd95SBruce Richardson  * nb_rx_queues = dev->data->nb_rx_queues
310099a2dd95SBruce Richardson  * nb_tx_queues = dev->data->nb_tx_queues
310199a2dd95SBruce Richardson  * dev_flags = &dev->data->dev_flags
310299a2dd95SBruce Richardson  *
310399a2dd95SBruce Richardson  * @param port_id
310499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
310599a2dd95SBruce Richardson  * @param dev_info
310699a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_eth_dev_info* to be filled with
310799a2dd95SBruce Richardson  *   the contextual information of the Ethernet device.
310899a2dd95SBruce Richardson  * @return
310999a2dd95SBruce Richardson  *   - (0) if successful.
311099a2dd95SBruce Richardson  *   - (-ENOTSUP) if support for dev_infos_get() does not exist for the device.
311199a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
311253ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
311399a2dd95SBruce Richardson  */
311499a2dd95SBruce Richardson int rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info);
311599a2dd95SBruce Richardson 
311699a2dd95SBruce Richardson /**
3117632be327SJie Wang  * @warning
3118632be327SJie Wang  * @b EXPERIMENTAL: this API may change without prior notice.
3119632be327SJie Wang  *
3120632be327SJie Wang  * Retrieve the configuration of an Ethernet device.
3121632be327SJie Wang  *
3122632be327SJie Wang  * @param port_id
3123632be327SJie Wang  *   The port identifier of the Ethernet device.
3124632be327SJie Wang  * @param dev_conf
3125632be327SJie Wang  *   Location for Ethernet device configuration to be filled in.
3126632be327SJie Wang  * @return
3127632be327SJie Wang  *   - (0) if successful.
3128632be327SJie Wang  *   - (-ENODEV) if *port_id* invalid.
3129632be327SJie Wang  *   - (-EINVAL) if bad parameter.
3130632be327SJie Wang  */
3131632be327SJie Wang __rte_experimental
3132632be327SJie Wang int rte_eth_dev_conf_get(uint16_t port_id, struct rte_eth_conf *dev_conf);
3133632be327SJie Wang 
3134632be327SJie Wang /**
313599a2dd95SBruce Richardson  * Retrieve the firmware version of a device.
313699a2dd95SBruce Richardson  *
313799a2dd95SBruce Richardson  * @param port_id
313899a2dd95SBruce Richardson  *   The port identifier of the device.
313999a2dd95SBruce Richardson  * @param fw_version
314099a2dd95SBruce Richardson  *   A pointer to a string array storing the firmware version of a device,
314199a2dd95SBruce Richardson  *   the string includes terminating null. This pointer is allocated by caller.
314299a2dd95SBruce Richardson  * @param fw_size
314399a2dd95SBruce Richardson  *   The size of the string array pointed by fw_version, which should be
314499a2dd95SBruce Richardson  *   large enough to store firmware version of the device.
314599a2dd95SBruce Richardson  * @return
314699a2dd95SBruce Richardson  *   - (0) if successful.
314799a2dd95SBruce Richardson  *   - (-ENOTSUP) if operation is not supported.
314899a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
314999a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
315053ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
315199a2dd95SBruce Richardson  *   - (>0) if *fw_size* is not enough to store firmware version, return
315299a2dd95SBruce Richardson  *          the size of the non truncated string.
315399a2dd95SBruce Richardson  */
315499a2dd95SBruce Richardson int rte_eth_dev_fw_version_get(uint16_t port_id,
315599a2dd95SBruce Richardson 			       char *fw_version, size_t fw_size);
315699a2dd95SBruce Richardson 
315799a2dd95SBruce Richardson /**
315899a2dd95SBruce Richardson  * Retrieve the supported packet types of an Ethernet device.
315999a2dd95SBruce Richardson  *
316099a2dd95SBruce Richardson  * When a packet type is announced as supported, it *must* be recognized by
316199a2dd95SBruce Richardson  * the PMD. For instance, if RTE_PTYPE_L2_ETHER, RTE_PTYPE_L2_ETHER_VLAN
316299a2dd95SBruce Richardson  * and RTE_PTYPE_L3_IPV4 are announced, the PMD must return the following
316399a2dd95SBruce Richardson  * packet types for these packets:
316499a2dd95SBruce Richardson  * - Ether/IPv4              -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4
31655b49ba65SAndrew Rybchenko  * - Ether/VLAN/IPv4         -> RTE_PTYPE_L2_ETHER_VLAN | RTE_PTYPE_L3_IPV4
316699a2dd95SBruce Richardson  * - Ether/[anything else]   -> RTE_PTYPE_L2_ETHER
31675b49ba65SAndrew Rybchenko  * - Ether/VLAN/[anything else] -> RTE_PTYPE_L2_ETHER_VLAN
316899a2dd95SBruce Richardson  *
316999a2dd95SBruce Richardson  * When a packet is received by a PMD, the most precise type must be
317099a2dd95SBruce Richardson  * returned among the ones supported. However a PMD is allowed to set
317199a2dd95SBruce Richardson  * packet type that is not in the supported list, at the condition that it
317299a2dd95SBruce Richardson  * is more precise. Therefore, a PMD announcing no supported packet types
317399a2dd95SBruce Richardson  * can still set a matching packet type in a received packet.
317499a2dd95SBruce Richardson  *
317599a2dd95SBruce Richardson  * @note
317609fd4227SAndrew Rybchenko  *   Better to invoke this API after the device is already started or Rx burst
317799a2dd95SBruce Richardson  *   function is decided, to obtain correct supported ptypes.
317899a2dd95SBruce Richardson  * @note
317999a2dd95SBruce Richardson  *   if a given PMD does not report what ptypes it supports, then the supported
318099a2dd95SBruce Richardson  *   ptype count is reported as 0.
318199a2dd95SBruce Richardson  * @param port_id
318299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
318399a2dd95SBruce Richardson  * @param ptype_mask
318499a2dd95SBruce Richardson  *   A hint of what kind of packet type which the caller is interested in.
318599a2dd95SBruce Richardson  * @param ptypes
318699a2dd95SBruce Richardson  *   An array pointer to store adequate packet types, allocated by caller.
318799a2dd95SBruce Richardson  * @param num
318899a2dd95SBruce Richardson  *  Size of the array pointed by param ptypes.
318999a2dd95SBruce Richardson  * @return
319099a2dd95SBruce Richardson  *   - (>=0) Number of supported ptypes. If the number of types exceeds num,
319199a2dd95SBruce Richardson  *           only num entries will be filled into the ptypes array, but the full
319299a2dd95SBruce Richardson  *           count of supported ptypes will be returned.
319399a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
319453ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
319599a2dd95SBruce Richardson  */
319699a2dd95SBruce Richardson int rte_eth_dev_get_supported_ptypes(uint16_t port_id, uint32_t ptype_mask,
319799a2dd95SBruce Richardson 				     uint32_t *ptypes, int num);
319899a2dd95SBruce Richardson /**
319999a2dd95SBruce Richardson  * Inform Ethernet device about reduced range of packet types to handle.
320099a2dd95SBruce Richardson  *
320199a2dd95SBruce Richardson  * Application can use this function to set only specific ptypes that it's
320299a2dd95SBruce Richardson  * interested. This information can be used by the PMD to optimize Rx path.
320399a2dd95SBruce Richardson  *
320499a2dd95SBruce Richardson  * The function accepts an array `set_ptypes` allocated by the caller to
320599a2dd95SBruce Richardson  * store the packet types set by the driver, the last element of the array
320699a2dd95SBruce Richardson  * is set to RTE_PTYPE_UNKNOWN. The size of the `set_ptype` array should be
320799a2dd95SBruce Richardson  * `rte_eth_dev_get_supported_ptypes() + 1` else it might only be filled
320899a2dd95SBruce Richardson  * partially.
320999a2dd95SBruce Richardson  *
321099a2dd95SBruce Richardson  * @param port_id
321199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
321299a2dd95SBruce Richardson  * @param ptype_mask
321399a2dd95SBruce Richardson  *   The ptype family that application is interested in should be bitwise OR of
321499a2dd95SBruce Richardson  *   RTE_PTYPE_*_MASK or 0.
321599a2dd95SBruce Richardson  * @param set_ptypes
321699a2dd95SBruce Richardson  *   An array pointer to store set packet types, allocated by caller. The
321799a2dd95SBruce Richardson  *   function marks the end of array with RTE_PTYPE_UNKNOWN.
321899a2dd95SBruce Richardson  * @param num
321999a2dd95SBruce Richardson  *   Size of the array pointed by param ptypes.
322099a2dd95SBruce Richardson  *   Should be rte_eth_dev_get_supported_ptypes() + 1 to accommodate the
322199a2dd95SBruce Richardson  *   set ptypes.
322299a2dd95SBruce Richardson  * @return
322399a2dd95SBruce Richardson  *   - (0) if Success.
322499a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
322599a2dd95SBruce Richardson  *   - (-EINVAL) if *ptype_mask* is invalid (or) set_ptypes is NULL and
322699a2dd95SBruce Richardson  *     num > 0.
322799a2dd95SBruce Richardson  */
322899a2dd95SBruce Richardson int rte_eth_dev_set_ptypes(uint16_t port_id, uint32_t ptype_mask,
322999a2dd95SBruce Richardson 			   uint32_t *set_ptypes, unsigned int num);
323099a2dd95SBruce Richardson 
323199a2dd95SBruce Richardson /**
323299a2dd95SBruce Richardson  * Retrieve the MTU of an Ethernet device.
323399a2dd95SBruce Richardson  *
323499a2dd95SBruce Richardson  * @param port_id
323599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
323699a2dd95SBruce Richardson  * @param mtu
323799a2dd95SBruce Richardson  *   A pointer to a uint16_t where the retrieved MTU is to be stored.
323899a2dd95SBruce Richardson  * @return
323999a2dd95SBruce Richardson  *   - (0) if successful.
324099a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
324153ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
324299a2dd95SBruce Richardson  */
324399a2dd95SBruce Richardson int rte_eth_dev_get_mtu(uint16_t port_id, uint16_t *mtu);
324499a2dd95SBruce Richardson 
324599a2dd95SBruce Richardson /**
324699a2dd95SBruce Richardson  * Change the MTU of an Ethernet device.
324799a2dd95SBruce Richardson  *
324899a2dd95SBruce Richardson  * @param port_id
324999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
325099a2dd95SBruce Richardson  * @param mtu
325199a2dd95SBruce Richardson  *   A uint16_t for the MTU to be applied.
325299a2dd95SBruce Richardson  * @return
325399a2dd95SBruce Richardson  *   - (0) if successful.
325499a2dd95SBruce Richardson  *   - (-ENOTSUP) if operation is not supported.
325599a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
325699a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
325799a2dd95SBruce Richardson  *   - (-EINVAL) if *mtu* invalid, validation of mtu can occur within
325899a2dd95SBruce Richardson  *     rte_eth_dev_set_mtu if dev_infos_get is supported by the device or
325999a2dd95SBruce Richardson  *     when the mtu is set using dev->dev_ops->mtu_set.
326099a2dd95SBruce Richardson  *   - (-EBUSY) if operation is not allowed when the port is running
326199a2dd95SBruce Richardson  */
326299a2dd95SBruce Richardson int rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu);
326399a2dd95SBruce Richardson 
326499a2dd95SBruce Richardson /**
326599a2dd95SBruce Richardson  * Enable/Disable hardware filtering by an Ethernet device of received
326699a2dd95SBruce Richardson  * VLAN packets tagged with a given VLAN Tag Identifier.
326799a2dd95SBruce Richardson  *
326899a2dd95SBruce Richardson  * @param port_id
326999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
327099a2dd95SBruce Richardson  * @param vlan_id
327199a2dd95SBruce Richardson  *   The VLAN Tag Identifier whose filtering must be enabled or disabled.
327299a2dd95SBruce Richardson  * @param on
327399a2dd95SBruce Richardson  *   If > 0, enable VLAN filtering of VLAN packets tagged with *vlan_id*.
327499a2dd95SBruce Richardson  *   Otherwise, disable VLAN filtering of VLAN packets tagged with *vlan_id*.
327599a2dd95SBruce Richardson  * @return
327699a2dd95SBruce Richardson  *   - (0) if successful.
327799a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware-assisted VLAN filtering not configured.
327899a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
327999a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
328099a2dd95SBruce Richardson  *   - (-ENOSYS) if VLAN filtering on *port_id* disabled.
328199a2dd95SBruce Richardson  *   - (-EINVAL) if *vlan_id* > 4095.
328299a2dd95SBruce Richardson  */
328399a2dd95SBruce Richardson int rte_eth_dev_vlan_filter(uint16_t port_id, uint16_t vlan_id, int on);
328499a2dd95SBruce Richardson 
328599a2dd95SBruce Richardson /**
328609fd4227SAndrew Rybchenko  * Enable/Disable hardware VLAN Strip by a Rx queue of an Ethernet device.
328799a2dd95SBruce Richardson  *
328899a2dd95SBruce Richardson  * @param port_id
328999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
329099a2dd95SBruce Richardson  * @param rx_queue_id
329199a2dd95SBruce Richardson  *   The index of the receive queue for which a queue stats mapping is required.
329299a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
329399a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
329499a2dd95SBruce Richardson  * @param on
329599a2dd95SBruce Richardson  *   If 1, Enable VLAN Stripping of the receive queue of the Ethernet port.
329699a2dd95SBruce Richardson  *   If 0, Disable VLAN Stripping of the receive queue of the Ethernet port.
329799a2dd95SBruce Richardson  * @return
329899a2dd95SBruce Richardson  *   - (0) if successful.
329999a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware-assisted VLAN stripping not configured.
330099a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
330199a2dd95SBruce Richardson  *   - (-EINVAL) if *rx_queue_id* invalid.
330299a2dd95SBruce Richardson  */
330399a2dd95SBruce Richardson int rte_eth_dev_set_vlan_strip_on_queue(uint16_t port_id, uint16_t rx_queue_id,
330499a2dd95SBruce Richardson 		int on);
330599a2dd95SBruce Richardson 
330699a2dd95SBruce Richardson /**
330799a2dd95SBruce Richardson  * Set the Outer VLAN Ether Type by an Ethernet device, it can be inserted to
330899a2dd95SBruce Richardson  * the VLAN header.
330999a2dd95SBruce Richardson  *
331099a2dd95SBruce Richardson  * @param port_id
331199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
331299a2dd95SBruce Richardson  * @param vlan_type
33135b49ba65SAndrew Rybchenko  *   The VLAN type.
331499a2dd95SBruce Richardson  * @param tag_type
331599a2dd95SBruce Richardson  *   The Tag Protocol ID
331699a2dd95SBruce Richardson  * @return
331799a2dd95SBruce Richardson  *   - (0) if successful.
331899a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware-assisted VLAN TPID setup is not supported.
331999a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
332099a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
332199a2dd95SBruce Richardson  */
332299a2dd95SBruce Richardson int rte_eth_dev_set_vlan_ether_type(uint16_t port_id,
332399a2dd95SBruce Richardson 				    enum rte_vlan_type vlan_type,
332499a2dd95SBruce Richardson 				    uint16_t tag_type);
332599a2dd95SBruce Richardson 
332699a2dd95SBruce Richardson /**
332799a2dd95SBruce Richardson  * Set VLAN offload configuration on an Ethernet device.
332899a2dd95SBruce Richardson  *
332999a2dd95SBruce Richardson  * @param port_id
333099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
333199a2dd95SBruce Richardson  * @param offload_mask
333299a2dd95SBruce Richardson  *   The VLAN Offload bit mask can be mixed use with "OR"
3333295968d1SFerruh Yigit  *       RTE_ETH_VLAN_STRIP_OFFLOAD
3334295968d1SFerruh Yigit  *       RTE_ETH_VLAN_FILTER_OFFLOAD
3335295968d1SFerruh Yigit  *       RTE_ETH_VLAN_EXTEND_OFFLOAD
3336295968d1SFerruh Yigit  *       RTE_ETH_QINQ_STRIP_OFFLOAD
333799a2dd95SBruce Richardson  * @return
333899a2dd95SBruce Richardson  *   - (0) if successful.
333999a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware-assisted VLAN filtering not configured.
334099a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
334199a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
334299a2dd95SBruce Richardson  */
334399a2dd95SBruce Richardson int rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask);
334499a2dd95SBruce Richardson 
334599a2dd95SBruce Richardson /**
334699a2dd95SBruce Richardson  * Read VLAN Offload configuration from an Ethernet device
334799a2dd95SBruce Richardson  *
334899a2dd95SBruce Richardson  * @param port_id
334999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
335099a2dd95SBruce Richardson  * @return
335199a2dd95SBruce Richardson  *   - (>0) if successful. Bit mask to indicate
3352295968d1SFerruh Yigit  *       RTE_ETH_VLAN_STRIP_OFFLOAD
3353295968d1SFerruh Yigit  *       RTE_ETH_VLAN_FILTER_OFFLOAD
3354295968d1SFerruh Yigit  *       RTE_ETH_VLAN_EXTEND_OFFLOAD
3355295968d1SFerruh Yigit  *       RTE_ETH_QINQ_STRIP_OFFLOAD
335699a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
335799a2dd95SBruce Richardson  */
335899a2dd95SBruce Richardson int rte_eth_dev_get_vlan_offload(uint16_t port_id);
335999a2dd95SBruce Richardson 
336099a2dd95SBruce Richardson /**
336109fd4227SAndrew Rybchenko  * Set port based Tx VLAN insertion on or off.
336299a2dd95SBruce Richardson  *
336399a2dd95SBruce Richardson  * @param port_id
336499a2dd95SBruce Richardson  *  The port identifier of the Ethernet device.
336599a2dd95SBruce Richardson  * @param pvid
336609fd4227SAndrew Rybchenko  *  Port based Tx VLAN identifier together with user priority.
336799a2dd95SBruce Richardson  * @param on
336809fd4227SAndrew Rybchenko  *  Turn on or off the port based Tx VLAN insertion.
336999a2dd95SBruce Richardson  *
337099a2dd95SBruce Richardson  * @return
337199a2dd95SBruce Richardson  *   - (0) if successful.
337299a2dd95SBruce Richardson  *   - negative if failed.
337399a2dd95SBruce Richardson  */
337499a2dd95SBruce Richardson int rte_eth_dev_set_vlan_pvid(uint16_t port_id, uint16_t pvid, int on);
337599a2dd95SBruce Richardson 
3376bc70e559SSpike Du /**
3377bc70e559SSpike Du  * @warning
3378bc70e559SSpike Du  * @b EXPERIMENTAL: this API may change without prior notice.
3379bc70e559SSpike Du  *
3380bc70e559SSpike Du  * Set Rx queue available descriptors threshold.
3381bc70e559SSpike Du  *
3382bc70e559SSpike Du  * @param port_id
3383bc70e559SSpike Du  *  The port identifier of the Ethernet device.
3384bc70e559SSpike Du  * @param queue_id
3385bc70e559SSpike Du  *  The index of the receive queue.
3386bc70e559SSpike Du  * @param avail_thresh
3387bc70e559SSpike Du  *  The available descriptors threshold is percentage of Rx queue size
3388bc70e559SSpike Du  *  which describes the availability of Rx queue for hardware.
3389bc70e559SSpike Du  *  If the Rx queue availability is below it,
3390bc70e559SSpike Du  *  the event RTE_ETH_EVENT_RX_AVAIL_THRESH is triggered.
3391bc70e559SSpike Du  *  [1-99] to set a new available descriptors threshold.
3392bc70e559SSpike Du  *  0 to disable threshold monitoring.
3393bc70e559SSpike Du  *
3394bc70e559SSpike Du  * @return
3395bc70e559SSpike Du  *   - 0 if successful.
3396bc70e559SSpike Du  *   - (-ENODEV) if @p port_id is invalid.
3397bc70e559SSpike Du  *   - (-EINVAL) if bad parameter.
3398bc70e559SSpike Du  *   - (-ENOTSUP) if available Rx descriptors threshold is not supported.
3399bc70e559SSpike Du  *   - (-EIO) if device is removed.
3400bc70e559SSpike Du  */
3401bc70e559SSpike Du __rte_experimental
3402bc70e559SSpike Du int rte_eth_rx_avail_thresh_set(uint16_t port_id, uint16_t queue_id,
3403bc70e559SSpike Du 			       uint8_t avail_thresh);
3404bc70e559SSpike Du 
3405bc70e559SSpike Du /**
3406bc70e559SSpike Du  * @warning
3407bc70e559SSpike Du  * @b EXPERIMENTAL: this API may change without prior notice.
3408bc70e559SSpike Du  *
3409bc70e559SSpike Du  * Find Rx queue with RTE_ETH_EVENT_RX_AVAIL_THRESH event pending.
3410bc70e559SSpike Du  *
3411bc70e559SSpike Du  * @param port_id
3412bc70e559SSpike Du  *  The port identifier of the Ethernet device.
3413bc70e559SSpike Du  * @param[inout] queue_id
3414bc70e559SSpike Du  *  On input starting Rx queue index to search from.
3415bc70e559SSpike Du  *  If the queue_id is bigger than maximum queue ID of the port,
3416bc70e559SSpike Du  *  search is started from 0. So that application can keep calling
3417bc70e559SSpike Du  *  this function to handle all pending events with a simple increment
3418bc70e559SSpike Du  *  of queue_id on the next call.
3419bc70e559SSpike Du  *  On output if return value is 1, Rx queue index with the event pending.
3420bc70e559SSpike Du  * @param[out] avail_thresh
3421bc70e559SSpike Du  *  Location for available descriptors threshold of the found Rx queue.
3422bc70e559SSpike Du  *
3423bc70e559SSpike Du  * @return
3424bc70e559SSpike Du  *   - 1 if an Rx queue with pending event is found.
3425bc70e559SSpike Du  *   - 0 if no Rx queue with pending event is found.
3426bc70e559SSpike Du  *   - (-ENODEV) if @p port_id is invalid.
3427bc70e559SSpike Du  *   - (-EINVAL) if bad parameter (e.g. @p queue_id is NULL).
3428bc70e559SSpike Du  *   - (-ENOTSUP) if operation is not supported.
3429bc70e559SSpike Du  *   - (-EIO) if device is removed.
3430bc70e559SSpike Du  */
3431bc70e559SSpike Du __rte_experimental
3432bc70e559SSpike Du int rte_eth_rx_avail_thresh_query(uint16_t port_id, uint16_t *queue_id,
3433bc70e559SSpike Du 				 uint8_t *avail_thresh);
3434bc70e559SSpike Du 
343599a2dd95SBruce Richardson typedef void (*buffer_tx_error_fn)(struct rte_mbuf **unsent, uint16_t count,
343699a2dd95SBruce Richardson 		void *userdata);
343799a2dd95SBruce Richardson 
343899a2dd95SBruce Richardson /**
343909fd4227SAndrew Rybchenko  * Structure used to buffer packets for future Tx
344099a2dd95SBruce Richardson  * Used by APIs rte_eth_tx_buffer and rte_eth_tx_buffer_flush
344199a2dd95SBruce Richardson  */
344299a2dd95SBruce Richardson struct rte_eth_dev_tx_buffer {
344399a2dd95SBruce Richardson 	buffer_tx_error_fn error_callback;
344499a2dd95SBruce Richardson 	void *error_userdata;
344509fd4227SAndrew Rybchenko 	uint16_t size;           /**< Size of buffer for buffered Tx */
344699a2dd95SBruce Richardson 	uint16_t length;         /**< Number of packets in the array */
34473c2ca0a9SAndrew Rybchenko 	/** Pending packets to be sent on explicit flush or when full */
344899a2dd95SBruce Richardson 	struct rte_mbuf *pkts[];
344999a2dd95SBruce Richardson };
345099a2dd95SBruce Richardson 
345199a2dd95SBruce Richardson /**
345209fd4227SAndrew Rybchenko  * Calculate the size of the Tx buffer.
345399a2dd95SBruce Richardson  *
345499a2dd95SBruce Richardson  * @param sz
345599a2dd95SBruce Richardson  *   Number of stored packets.
345699a2dd95SBruce Richardson  */
345799a2dd95SBruce Richardson #define RTE_ETH_TX_BUFFER_SIZE(sz) \
345899a2dd95SBruce Richardson 	(sizeof(struct rte_eth_dev_tx_buffer) + (sz) * sizeof(struct rte_mbuf *))
345999a2dd95SBruce Richardson 
346099a2dd95SBruce Richardson /**
346199a2dd95SBruce Richardson  * Initialize default values for buffered transmitting
346299a2dd95SBruce Richardson  *
346399a2dd95SBruce Richardson  * @param buffer
346499a2dd95SBruce Richardson  *   Tx buffer to be initialized.
346599a2dd95SBruce Richardson  * @param size
346699a2dd95SBruce Richardson  *   Buffer size
346799a2dd95SBruce Richardson  * @return
346899a2dd95SBruce Richardson  *   0 if no error
346999a2dd95SBruce Richardson  */
347099a2dd95SBruce Richardson int
347199a2dd95SBruce Richardson rte_eth_tx_buffer_init(struct rte_eth_dev_tx_buffer *buffer, uint16_t size);
347299a2dd95SBruce Richardson 
347399a2dd95SBruce Richardson /**
347499a2dd95SBruce Richardson  * Configure a callback for buffered packets which cannot be sent
347599a2dd95SBruce Richardson  *
347699a2dd95SBruce Richardson  * Register a specific callback to be called when an attempt is made to send
34770d9f56a8SAndrew Rybchenko  * all packets buffered on an Ethernet port, but not all packets can
347899a2dd95SBruce Richardson  * successfully be sent. The callback registered here will be called only
347999a2dd95SBruce Richardson  * from calls to rte_eth_tx_buffer() and rte_eth_tx_buffer_flush() APIs.
348099a2dd95SBruce Richardson  * The default callback configured for each queue by default just frees the
348199a2dd95SBruce Richardson  * packets back to the calling mempool. If additional behaviour is required,
348299a2dd95SBruce Richardson  * for example, to count dropped packets, or to retry transmission of packets
348399a2dd95SBruce Richardson  * which cannot be sent, this function should be used to register a suitable
348499a2dd95SBruce Richardson  * callback function to implement the desired behaviour.
348599a2dd95SBruce Richardson  * The example callback "rte_eth_count_unsent_packet_callback()" is also
348699a2dd95SBruce Richardson  * provided as reference.
348799a2dd95SBruce Richardson  *
348899a2dd95SBruce Richardson  * @param buffer
348999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
349099a2dd95SBruce Richardson  * @param callback
349199a2dd95SBruce Richardson  *   The function to be used as the callback.
349299a2dd95SBruce Richardson  * @param userdata
349399a2dd95SBruce Richardson  *   Arbitrary parameter to be passed to the callback function
349499a2dd95SBruce Richardson  * @return
349553ef1b34SMin Hu (Connor)  *   0 on success, or -EINVAL if bad parameter
349699a2dd95SBruce Richardson  */
349799a2dd95SBruce Richardson int
349899a2dd95SBruce Richardson rte_eth_tx_buffer_set_err_callback(struct rte_eth_dev_tx_buffer *buffer,
349999a2dd95SBruce Richardson 		buffer_tx_error_fn callback, void *userdata);
350099a2dd95SBruce Richardson 
350199a2dd95SBruce Richardson /**
350299a2dd95SBruce Richardson  * Callback function for silently dropping unsent buffered packets.
350399a2dd95SBruce Richardson  *
350499a2dd95SBruce Richardson  * This function can be passed to rte_eth_tx_buffer_set_err_callback() to
350599a2dd95SBruce Richardson  * adjust the default behavior when buffered packets cannot be sent. This
350609fd4227SAndrew Rybchenko  * function drops any unsent packets silently and is used by Tx buffered
350799a2dd95SBruce Richardson  * operations as default behavior.
350899a2dd95SBruce Richardson  *
350999a2dd95SBruce Richardson  * NOTE: this function should not be called directly, instead it should be used
351099a2dd95SBruce Richardson  *       as a callback for packet buffering.
351199a2dd95SBruce Richardson  *
351299a2dd95SBruce Richardson  * NOTE: when configuring this function as a callback with
351399a2dd95SBruce Richardson  *       rte_eth_tx_buffer_set_err_callback(), the final, userdata parameter
351499a2dd95SBruce Richardson  *       should point to an uint64_t value.
351599a2dd95SBruce Richardson  *
351699a2dd95SBruce Richardson  * @param pkts
351799a2dd95SBruce Richardson  *   The previously buffered packets which could not be sent
351899a2dd95SBruce Richardson  * @param unsent
351999a2dd95SBruce Richardson  *   The number of unsent packets in the pkts array
352099a2dd95SBruce Richardson  * @param userdata
352199a2dd95SBruce Richardson  *   Not used
352299a2dd95SBruce Richardson  */
352399a2dd95SBruce Richardson void
352499a2dd95SBruce Richardson rte_eth_tx_buffer_drop_callback(struct rte_mbuf **pkts, uint16_t unsent,
352599a2dd95SBruce Richardson 		void *userdata);
352699a2dd95SBruce Richardson 
352799a2dd95SBruce Richardson /**
352899a2dd95SBruce Richardson  * Callback function for tracking unsent buffered packets.
352999a2dd95SBruce Richardson  *
353099a2dd95SBruce Richardson  * This function can be passed to rte_eth_tx_buffer_set_err_callback() to
353199a2dd95SBruce Richardson  * adjust the default behavior when buffered packets cannot be sent. This
353299a2dd95SBruce Richardson  * function drops any unsent packets, but also updates a user-supplied counter
353399a2dd95SBruce Richardson  * to track the overall number of packets dropped. The counter should be an
353499a2dd95SBruce Richardson  * uint64_t variable.
353599a2dd95SBruce Richardson  *
353699a2dd95SBruce Richardson  * NOTE: this function should not be called directly, instead it should be used
353799a2dd95SBruce Richardson  *       as a callback for packet buffering.
353899a2dd95SBruce Richardson  *
353999a2dd95SBruce Richardson  * NOTE: when configuring this function as a callback with
354099a2dd95SBruce Richardson  *       rte_eth_tx_buffer_set_err_callback(), the final, userdata parameter
354199a2dd95SBruce Richardson  *       should point to an uint64_t value.
354299a2dd95SBruce Richardson  *
354399a2dd95SBruce Richardson  * @param pkts
354499a2dd95SBruce Richardson  *   The previously buffered packets which could not be sent
354599a2dd95SBruce Richardson  * @param unsent
354699a2dd95SBruce Richardson  *   The number of unsent packets in the pkts array
354799a2dd95SBruce Richardson  * @param userdata
354899a2dd95SBruce Richardson  *   Pointer to an uint64_t value, which will be incremented by unsent
354999a2dd95SBruce Richardson  */
355099a2dd95SBruce Richardson void
355199a2dd95SBruce Richardson rte_eth_tx_buffer_count_callback(struct rte_mbuf **pkts, uint16_t unsent,
355299a2dd95SBruce Richardson 		void *userdata);
355399a2dd95SBruce Richardson 
355499a2dd95SBruce Richardson /**
355599a2dd95SBruce Richardson  * Request the driver to free mbufs currently cached by the driver. The
355699a2dd95SBruce Richardson  * driver will only free the mbuf if it is no longer in use. It is the
355799a2dd95SBruce Richardson  * application's responsibility to ensure rte_eth_tx_buffer_flush(..) is
355899a2dd95SBruce Richardson  * called if needed.
355999a2dd95SBruce Richardson  *
356099a2dd95SBruce Richardson  * @param port_id
356199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
356299a2dd95SBruce Richardson  * @param queue_id
356399a2dd95SBruce Richardson  *   The index of the transmit queue through which output packets must be
356499a2dd95SBruce Richardson  *   sent.
356599a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
356699a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
356799a2dd95SBruce Richardson  * @param free_cnt
356899a2dd95SBruce Richardson  *   Maximum number of packets to free. Use 0 to indicate all possible packets
356999a2dd95SBruce Richardson  *   should be freed. Note that a packet may be using multiple mbufs.
357099a2dd95SBruce Richardson  * @return
357199a2dd95SBruce Richardson  *   Failure: < 0
357299a2dd95SBruce Richardson  *     -ENODEV: Invalid interface
357399a2dd95SBruce Richardson  *     -EIO: device is removed
357499a2dd95SBruce Richardson  *     -ENOTSUP: Driver does not support function
357599a2dd95SBruce Richardson  *   Success: >= 0
357699a2dd95SBruce Richardson  *     0-n: Number of packets freed. More packets may still remain in ring that
357799a2dd95SBruce Richardson  *     are in use.
357899a2dd95SBruce Richardson  */
357999a2dd95SBruce Richardson int
358099a2dd95SBruce Richardson rte_eth_tx_done_cleanup(uint16_t port_id, uint16_t queue_id, uint32_t free_cnt);
358199a2dd95SBruce Richardson 
358299a2dd95SBruce Richardson /**
358399a2dd95SBruce Richardson  * Subtypes for IPsec offload event(@ref RTE_ETH_EVENT_IPSEC) raised by
358499a2dd95SBruce Richardson  * eth device.
358599a2dd95SBruce Richardson  */
358699a2dd95SBruce Richardson enum rte_eth_event_ipsec_subtype {
35873c2ca0a9SAndrew Rybchenko 	/** Unknown event type */
358899a2dd95SBruce Richardson 	RTE_ETH_EVENT_IPSEC_UNKNOWN = 0,
35893c2ca0a9SAndrew Rybchenko 	/** Sequence number overflow */
359099a2dd95SBruce Richardson 	RTE_ETH_EVENT_IPSEC_ESN_OVERFLOW,
35913c2ca0a9SAndrew Rybchenko 	/** Soft time expiry of SA */
359299a2dd95SBruce Richardson 	RTE_ETH_EVENT_IPSEC_SA_TIME_EXPIRY,
3593*d1ce79d1SVamsi Attunuru 	/**
3594*d1ce79d1SVamsi Attunuru 	 * Soft byte expiry of SA determined by
3595*d1ce79d1SVamsi Attunuru 	 * @ref rte_security_ipsec_lifetime::bytes_soft_limit
3596*d1ce79d1SVamsi Attunuru 	 */
359799a2dd95SBruce Richardson 	RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY,
3598*d1ce79d1SVamsi Attunuru 	/**
3599*d1ce79d1SVamsi Attunuru 	 * Soft packet expiry of SA determined by
3600*d1ce79d1SVamsi Attunuru 	 * @ref rte_security_ipsec_lifetime::packets_soft_limit
3601*d1ce79d1SVamsi Attunuru 	 */
3602*d1ce79d1SVamsi Attunuru 	RTE_ETH_EVENT_IPSEC_SA_PKT_EXPIRY,
3603*d1ce79d1SVamsi Attunuru 	/**
3604*d1ce79d1SVamsi Attunuru 	 * Hard byte expiry of SA determined by
3605*d1ce79d1SVamsi Attunuru 	 * @ref rte_security_ipsec_lifetime::bytes_hard_limit
3606*d1ce79d1SVamsi Attunuru 	 */
3607*d1ce79d1SVamsi Attunuru 	RTE_ETH_EVENT_IPSEC_SA_BYTE_HARD_EXPIRY,
3608*d1ce79d1SVamsi Attunuru 	/**
3609*d1ce79d1SVamsi Attunuru 	 * Hard packet expiry of SA determined by
3610*d1ce79d1SVamsi Attunuru 	 * @ref rte_security_ipsec_lifetime::packets_hard_limit
3611*d1ce79d1SVamsi Attunuru 	 */
3612*d1ce79d1SVamsi Attunuru 	RTE_ETH_EVENT_IPSEC_SA_PKT_HARD_EXPIRY,
36133c2ca0a9SAndrew Rybchenko 	/** Max value of this enum */
361499a2dd95SBruce Richardson 	RTE_ETH_EVENT_IPSEC_MAX
361599a2dd95SBruce Richardson };
361699a2dd95SBruce Richardson 
361799a2dd95SBruce Richardson /**
361899a2dd95SBruce Richardson  * Descriptor for @ref RTE_ETH_EVENT_IPSEC event. Used by eth dev to send extra
361999a2dd95SBruce Richardson  * information of the IPsec offload event.
362099a2dd95SBruce Richardson  */
362199a2dd95SBruce Richardson struct rte_eth_event_ipsec_desc {
36223c2ca0a9SAndrew Rybchenko 	/** Type of RTE_ETH_EVENT_IPSEC_* event */
362399a2dd95SBruce Richardson 	enum rte_eth_event_ipsec_subtype subtype;
36243c2ca0a9SAndrew Rybchenko 	/**
36253c2ca0a9SAndrew Rybchenko 	 * Event specific metadata.
362699a2dd95SBruce Richardson 	 *
362799a2dd95SBruce Richardson 	 * For the following events, *userdata* registered
362899a2dd95SBruce Richardson 	 * with the *rte_security_session* would be returned
362999a2dd95SBruce Richardson 	 * as metadata,
363099a2dd95SBruce Richardson 	 *
363199a2dd95SBruce Richardson 	 * - @ref RTE_ETH_EVENT_IPSEC_ESN_OVERFLOW
363299a2dd95SBruce Richardson 	 * - @ref RTE_ETH_EVENT_IPSEC_SA_TIME_EXPIRY
363399a2dd95SBruce Richardson 	 * - @ref RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY
3634*d1ce79d1SVamsi Attunuru 	 * - @ref RTE_ETH_EVENT_IPSEC_SA_PKT_EXPIRY
3635*d1ce79d1SVamsi Attunuru 	 * - @ref RTE_ETH_EVENT_IPSEC_SA_BYTE_HARD_EXPIRY
3636*d1ce79d1SVamsi Attunuru 	 * - @ref RTE_ETH_EVENT_IPSEC_SA_PKT_HARD_EXPIRY
363799a2dd95SBruce Richardson 	 *
363899a2dd95SBruce Richardson 	 * @see struct rte_security_session_conf
363999a2dd95SBruce Richardson 	 *
364099a2dd95SBruce Richardson 	 */
36413c2ca0a9SAndrew Rybchenko 	uint64_t metadata;
364299a2dd95SBruce Richardson };
364399a2dd95SBruce Richardson 
364499a2dd95SBruce Richardson /**
364599a2dd95SBruce Richardson  * The eth device event type for interrupt, and maybe others in the future.
364699a2dd95SBruce Richardson  */
364799a2dd95SBruce Richardson enum rte_eth_event_type {
364899a2dd95SBruce Richardson 	RTE_ETH_EVENT_UNKNOWN,  /**< unknown event type */
364999a2dd95SBruce Richardson 	RTE_ETH_EVENT_INTR_LSC, /**< lsc interrupt event */
36503c2ca0a9SAndrew Rybchenko 	/** queue state event (enabled/disabled) */
365199a2dd95SBruce Richardson 	RTE_ETH_EVENT_QUEUE_STATE,
36523c2ca0a9SAndrew Rybchenko 	/** reset interrupt event, sent to VF on PF reset */
365399a2dd95SBruce Richardson 	RTE_ETH_EVENT_INTR_RESET,
365499a2dd95SBruce Richardson 	RTE_ETH_EVENT_VF_MBOX,  /**< message from the VF received by PF */
365599a2dd95SBruce Richardson 	RTE_ETH_EVENT_MACSEC,   /**< MACsec offload related event */
365699a2dd95SBruce Richardson 	RTE_ETH_EVENT_INTR_RMV, /**< device removal event */
365799a2dd95SBruce Richardson 	RTE_ETH_EVENT_NEW,      /**< port is probed */
365899a2dd95SBruce Richardson 	RTE_ETH_EVENT_DESTROY,  /**< port is released */
365999a2dd95SBruce Richardson 	RTE_ETH_EVENT_IPSEC,    /**< IPsec offload related event */
366099a2dd95SBruce Richardson 	RTE_ETH_EVENT_FLOW_AGED,/**< New aged-out flows is detected */
3661bc70e559SSpike Du 	/**
3662bc70e559SSpike Du 	 * Number of available Rx descriptors is smaller than the threshold.
3663bc70e559SSpike Du 	 * @see rte_eth_rx_avail_thresh_set()
3664bc70e559SSpike Du 	 */
3665bc70e559SSpike Du 	RTE_ETH_EVENT_RX_AVAIL_THRESH,
366699a2dd95SBruce Richardson 	RTE_ETH_EVENT_MAX       /**< max value of this enum */
366799a2dd95SBruce Richardson };
366899a2dd95SBruce Richardson 
36693c2ca0a9SAndrew Rybchenko /** User application callback to be registered for interrupts. */
367099a2dd95SBruce Richardson typedef int (*rte_eth_dev_cb_fn)(uint16_t port_id,
367199a2dd95SBruce Richardson 		enum rte_eth_event_type event, void *cb_arg, void *ret_param);
367299a2dd95SBruce Richardson 
367399a2dd95SBruce Richardson /**
367499a2dd95SBruce Richardson  * Register a callback function for port event.
367599a2dd95SBruce Richardson  *
367699a2dd95SBruce Richardson  * @param port_id
36775906be5aSAndrew Rybchenko  *  Port ID.
367899a2dd95SBruce Richardson  *  RTE_ETH_ALL means register the event for all port ids.
367999a2dd95SBruce Richardson  * @param event
368099a2dd95SBruce Richardson  *  Event interested.
368199a2dd95SBruce Richardson  * @param cb_fn
368299a2dd95SBruce Richardson  *  User supplied callback function to be called.
368399a2dd95SBruce Richardson  * @param cb_arg
368499a2dd95SBruce Richardson  *  Pointer to the parameters for the registered callback.
368599a2dd95SBruce Richardson  *
368699a2dd95SBruce Richardson  * @return
368799a2dd95SBruce Richardson  *  - On success, zero.
368899a2dd95SBruce Richardson  *  - On failure, a negative value.
368999a2dd95SBruce Richardson  */
369099a2dd95SBruce Richardson int rte_eth_dev_callback_register(uint16_t port_id,
369199a2dd95SBruce Richardson 			enum rte_eth_event_type event,
369299a2dd95SBruce Richardson 		rte_eth_dev_cb_fn cb_fn, void *cb_arg);
369399a2dd95SBruce Richardson 
369499a2dd95SBruce Richardson /**
369599a2dd95SBruce Richardson  * Unregister a callback function for port event.
369699a2dd95SBruce Richardson  *
369799a2dd95SBruce Richardson  * @param port_id
36985906be5aSAndrew Rybchenko  *  Port ID.
369999a2dd95SBruce Richardson  *  RTE_ETH_ALL means unregister the event for all port ids.
370099a2dd95SBruce Richardson  * @param event
370199a2dd95SBruce Richardson  *  Event interested.
370299a2dd95SBruce Richardson  * @param cb_fn
370399a2dd95SBruce Richardson  *  User supplied callback function to be called.
370499a2dd95SBruce Richardson  * @param cb_arg
370599a2dd95SBruce Richardson  *  Pointer to the parameters for the registered callback. -1 means to
370699a2dd95SBruce Richardson  *  remove all for the same callback address and same event.
370799a2dd95SBruce Richardson  *
370899a2dd95SBruce Richardson  * @return
370999a2dd95SBruce Richardson  *  - On success, zero.
371099a2dd95SBruce Richardson  *  - On failure, a negative value.
371199a2dd95SBruce Richardson  */
371299a2dd95SBruce Richardson int rte_eth_dev_callback_unregister(uint16_t port_id,
371399a2dd95SBruce Richardson 			enum rte_eth_event_type event,
371499a2dd95SBruce Richardson 		rte_eth_dev_cb_fn cb_fn, void *cb_arg);
371599a2dd95SBruce Richardson 
371699a2dd95SBruce Richardson /**
371709fd4227SAndrew Rybchenko  * When there is no Rx packet coming in Rx Queue for a long time, we can
371809fd4227SAndrew Rybchenko  * sleep lcore related to Rx Queue for power saving, and enable Rx interrupt
371999a2dd95SBruce Richardson  * to be triggered when Rx packet arrives.
372099a2dd95SBruce Richardson  *
372109fd4227SAndrew Rybchenko  * The rte_eth_dev_rx_intr_enable() function enables Rx queue
372209fd4227SAndrew Rybchenko  * interrupt on specific Rx queue of a port.
372399a2dd95SBruce Richardson  *
372499a2dd95SBruce Richardson  * @param port_id
372599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
372699a2dd95SBruce Richardson  * @param queue_id
372799a2dd95SBruce Richardson  *   The index of the receive queue from which to retrieve input packets.
372899a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
372999a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
373099a2dd95SBruce Richardson  * @return
373199a2dd95SBruce Richardson  *   - (0) if successful.
373299a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
373399a2dd95SBruce Richardson  *     that operation.
373499a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
373599a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
373699a2dd95SBruce Richardson  */
373799a2dd95SBruce Richardson int rte_eth_dev_rx_intr_enable(uint16_t port_id, uint16_t queue_id);
373899a2dd95SBruce Richardson 
373999a2dd95SBruce Richardson /**
374009fd4227SAndrew Rybchenko  * When lcore wakes up from Rx interrupt indicating packet coming, disable Rx
374199a2dd95SBruce Richardson  * interrupt and returns to polling mode.
374299a2dd95SBruce Richardson  *
374309fd4227SAndrew Rybchenko  * The rte_eth_dev_rx_intr_disable() function disables Rx queue
374409fd4227SAndrew Rybchenko  * interrupt on specific Rx queue of a port.
374599a2dd95SBruce Richardson  *
374699a2dd95SBruce Richardson  * @param port_id
374799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
374899a2dd95SBruce Richardson  * @param queue_id
374999a2dd95SBruce Richardson  *   The index of the receive queue from which to retrieve input packets.
375099a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
375199a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
375299a2dd95SBruce Richardson  * @return
375399a2dd95SBruce Richardson  *   - (0) if successful.
375499a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
375599a2dd95SBruce Richardson  *     that operation.
375699a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
375799a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
375899a2dd95SBruce Richardson  */
375999a2dd95SBruce Richardson int rte_eth_dev_rx_intr_disable(uint16_t port_id, uint16_t queue_id);
376099a2dd95SBruce Richardson 
376199a2dd95SBruce Richardson /**
376209fd4227SAndrew Rybchenko  * Rx Interrupt control per port.
376399a2dd95SBruce Richardson  *
376499a2dd95SBruce Richardson  * @param port_id
376599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
376699a2dd95SBruce Richardson  * @param epfd
376799a2dd95SBruce Richardson  *   Epoll instance fd which the intr vector associated to.
376899a2dd95SBruce Richardson  *   Using RTE_EPOLL_PER_THREAD allows to use per thread epoll instance.
376999a2dd95SBruce Richardson  * @param op
377099a2dd95SBruce Richardson  *   The operation be performed for the vector.
377199a2dd95SBruce Richardson  *   Operation type of {RTE_INTR_EVENT_ADD, RTE_INTR_EVENT_DEL}.
377299a2dd95SBruce Richardson  * @param data
377399a2dd95SBruce Richardson  *   User raw data.
377499a2dd95SBruce Richardson  * @return
377599a2dd95SBruce Richardson  *   - On success, zero.
377699a2dd95SBruce Richardson  *   - On failure, a negative value.
377799a2dd95SBruce Richardson  */
377899a2dd95SBruce Richardson int rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data);
377999a2dd95SBruce Richardson 
378099a2dd95SBruce Richardson /**
378109fd4227SAndrew Rybchenko  * Rx Interrupt control per queue.
378299a2dd95SBruce Richardson  *
378399a2dd95SBruce Richardson  * @param port_id
378499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
378599a2dd95SBruce Richardson  * @param queue_id
378699a2dd95SBruce Richardson  *   The index of the receive queue from which to retrieve input packets.
378799a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
378899a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
378999a2dd95SBruce Richardson  * @param epfd
379099a2dd95SBruce Richardson  *   Epoll instance fd which the intr vector associated to.
379199a2dd95SBruce Richardson  *   Using RTE_EPOLL_PER_THREAD allows to use per thread epoll instance.
379299a2dd95SBruce Richardson  * @param op
379399a2dd95SBruce Richardson  *   The operation be performed for the vector.
379499a2dd95SBruce Richardson  *   Operation type of {RTE_INTR_EVENT_ADD, RTE_INTR_EVENT_DEL}.
379599a2dd95SBruce Richardson  * @param data
379699a2dd95SBruce Richardson  *   User raw data.
379799a2dd95SBruce Richardson  * @return
379899a2dd95SBruce Richardson  *   - On success, zero.
379999a2dd95SBruce Richardson  *   - On failure, a negative value.
380099a2dd95SBruce Richardson  */
380199a2dd95SBruce Richardson int rte_eth_dev_rx_intr_ctl_q(uint16_t port_id, uint16_t queue_id,
380299a2dd95SBruce Richardson 			      int epfd, int op, void *data);
380399a2dd95SBruce Richardson 
380499a2dd95SBruce Richardson /**
380599a2dd95SBruce Richardson  * Get interrupt fd per Rx queue.
380699a2dd95SBruce Richardson  *
380799a2dd95SBruce Richardson  * @param port_id
380899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
380999a2dd95SBruce Richardson  * @param queue_id
381099a2dd95SBruce Richardson  *   The index of the receive queue from which to retrieve input packets.
381199a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
381299a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
381399a2dd95SBruce Richardson  * @return
381499a2dd95SBruce Richardson  *   - (>=0) the interrupt fd associated to the requested Rx queue if
381599a2dd95SBruce Richardson  *           successful.
381699a2dd95SBruce Richardson  *   - (-1) on error.
381799a2dd95SBruce Richardson  */
381899a2dd95SBruce Richardson int
381999a2dd95SBruce Richardson rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t queue_id);
382099a2dd95SBruce Richardson 
382199a2dd95SBruce Richardson /**
382299a2dd95SBruce Richardson  * Turn on the LED on the Ethernet device.
382399a2dd95SBruce Richardson  * This function turns on the LED on the Ethernet device.
382499a2dd95SBruce Richardson  *
382599a2dd95SBruce Richardson  * @param port_id
382699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
382799a2dd95SBruce Richardson  * @return
382899a2dd95SBruce Richardson  *   - (0) if successful.
382999a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
383099a2dd95SBruce Richardson  *     that operation.
383199a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
383299a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
383399a2dd95SBruce Richardson  */
383499a2dd95SBruce Richardson int  rte_eth_led_on(uint16_t port_id);
383599a2dd95SBruce Richardson 
383699a2dd95SBruce Richardson /**
383799a2dd95SBruce Richardson  * Turn off the LED on the Ethernet device.
383899a2dd95SBruce Richardson  * This function turns off the LED on the Ethernet device.
383999a2dd95SBruce Richardson  *
384099a2dd95SBruce Richardson  * @param port_id
384199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
384299a2dd95SBruce Richardson  * @return
384399a2dd95SBruce Richardson  *   - (0) if successful.
384499a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
384599a2dd95SBruce Richardson  *     that operation.
384699a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
384799a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
384899a2dd95SBruce Richardson  */
384999a2dd95SBruce Richardson int  rte_eth_led_off(uint16_t port_id);
385099a2dd95SBruce Richardson 
385199a2dd95SBruce Richardson /**
385299a2dd95SBruce Richardson  * @warning
385399a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
385499a2dd95SBruce Richardson  *
385599a2dd95SBruce Richardson  * Get Forward Error Correction(FEC) capability.
385699a2dd95SBruce Richardson  *
385799a2dd95SBruce Richardson  * @param port_id
385899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
385999a2dd95SBruce Richardson  * @param speed_fec_capa
386099a2dd95SBruce Richardson  *   speed_fec_capa is out only with per-speed capabilities.
386199a2dd95SBruce Richardson  *   If set to NULL, the function returns the required number
386299a2dd95SBruce Richardson  *   of required array entries.
386399a2dd95SBruce Richardson  * @param num
386499a2dd95SBruce Richardson  *   a number of elements in an speed_fec_capa array.
386599a2dd95SBruce Richardson  *
386699a2dd95SBruce Richardson  * @return
386799a2dd95SBruce Richardson  *   - A non-negative value lower or equal to num: success. The return value
386899a2dd95SBruce Richardson  *     is the number of entries filled in the fec capa array.
386999a2dd95SBruce Richardson  *   - A non-negative value higher than num: error, the given fec capa array
387099a2dd95SBruce Richardson  *     is too small. The return value corresponds to the num that should
387199a2dd95SBruce Richardson  *     be given to succeed. The entries in fec capa array are not valid and
387299a2dd95SBruce Richardson  *     shall not be used by the caller.
387399a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
387499a2dd95SBruce Richardson  *     that operation.
387599a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
387699a2dd95SBruce Richardson  *   - (-ENODEV)  if *port_id* invalid.
387799a2dd95SBruce Richardson  *   - (-EINVAL)  if *num* or *speed_fec_capa* invalid
387899a2dd95SBruce Richardson  */
387999a2dd95SBruce Richardson __rte_experimental
388099a2dd95SBruce Richardson int rte_eth_fec_get_capability(uint16_t port_id,
388199a2dd95SBruce Richardson 			       struct rte_eth_fec_capa *speed_fec_capa,
388299a2dd95SBruce Richardson 			       unsigned int num);
388399a2dd95SBruce Richardson 
388499a2dd95SBruce Richardson /**
388599a2dd95SBruce Richardson  * @warning
388699a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
388799a2dd95SBruce Richardson  *
388899a2dd95SBruce Richardson  * Get current Forward Error Correction(FEC) mode.
388999a2dd95SBruce Richardson  * If link is down and AUTO is enabled, AUTO is returned, otherwise,
389099a2dd95SBruce Richardson  * configured FEC mode is returned.
389199a2dd95SBruce Richardson  * If link is up, current FEC mode is returned.
389299a2dd95SBruce Richardson  *
389399a2dd95SBruce Richardson  * @param port_id
389499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
389599a2dd95SBruce Richardson  * @param fec_capa
389699a2dd95SBruce Richardson  *   A bitmask of enabled FEC modes. If AUTO bit is set, other
389799a2dd95SBruce Richardson  *   bits specify FEC modes which may be negotiated. If AUTO
389899a2dd95SBruce Richardson  *   bit is clear, specify FEC modes to be used (only one valid
389999a2dd95SBruce Richardson  *   mode per speed may be set).
390099a2dd95SBruce Richardson  * @return
390199a2dd95SBruce Richardson  *   - (0) if successful.
390299a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
390399a2dd95SBruce Richardson  *     that operation.
390499a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
390599a2dd95SBruce Richardson  *   - (-ENODEV)  if *port_id* invalid.
390699a2dd95SBruce Richardson  */
390799a2dd95SBruce Richardson __rte_experimental
390899a2dd95SBruce Richardson int rte_eth_fec_get(uint16_t port_id, uint32_t *fec_capa);
390999a2dd95SBruce Richardson 
391099a2dd95SBruce Richardson /**
391199a2dd95SBruce Richardson  * @warning
391299a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
391399a2dd95SBruce Richardson  *
391499a2dd95SBruce Richardson  * Set Forward Error Correction(FEC) mode.
391599a2dd95SBruce Richardson  *
391699a2dd95SBruce Richardson  * @param port_id
391799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
391899a2dd95SBruce Richardson  * @param fec_capa
391999a2dd95SBruce Richardson  *   A bitmask of allowed FEC modes. If AUTO bit is set, other
392099a2dd95SBruce Richardson  *   bits specify FEC modes which may be negotiated. If AUTO
392199a2dd95SBruce Richardson  *   bit is clear, specify FEC modes to be used (only one valid
392299a2dd95SBruce Richardson  *   mode per speed may be set).
392399a2dd95SBruce Richardson  * @return
392499a2dd95SBruce Richardson  *   - (0) if successful.
392599a2dd95SBruce Richardson  *   - (-EINVAL) if the FEC mode is not valid.
392699a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
392799a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
392899a2dd95SBruce Richardson  *   - (-ENODEV)  if *port_id* invalid.
392999a2dd95SBruce Richardson  */
393099a2dd95SBruce Richardson __rte_experimental
393199a2dd95SBruce Richardson int rte_eth_fec_set(uint16_t port_id, uint32_t fec_capa);
393299a2dd95SBruce Richardson 
393399a2dd95SBruce Richardson /**
393499a2dd95SBruce Richardson  * Get current status of the Ethernet link flow control for Ethernet device
393599a2dd95SBruce Richardson  *
393699a2dd95SBruce Richardson  * @param port_id
393799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
393899a2dd95SBruce Richardson  * @param fc_conf
393999a2dd95SBruce Richardson  *   The pointer to the structure where to store the flow control parameters.
394099a2dd95SBruce Richardson  * @return
394199a2dd95SBruce Richardson  *   - (0) if successful.
394299a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support flow control.
394399a2dd95SBruce Richardson  *   - (-ENODEV)  if *port_id* invalid.
394499a2dd95SBruce Richardson  *   - (-EIO)  if device is removed.
394553ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
394699a2dd95SBruce Richardson  */
394799a2dd95SBruce Richardson int rte_eth_dev_flow_ctrl_get(uint16_t port_id,
394899a2dd95SBruce Richardson 			      struct rte_eth_fc_conf *fc_conf);
394999a2dd95SBruce Richardson 
395099a2dd95SBruce Richardson /**
395199a2dd95SBruce Richardson  * Configure the Ethernet link flow control for Ethernet device
395299a2dd95SBruce Richardson  *
395399a2dd95SBruce Richardson  * @param port_id
395499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
395599a2dd95SBruce Richardson  * @param fc_conf
395699a2dd95SBruce Richardson  *   The pointer to the structure of the flow control parameters.
395799a2dd95SBruce Richardson  * @return
395899a2dd95SBruce Richardson  *   - (0) if successful.
395999a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support flow control mode.
396099a2dd95SBruce Richardson  *   - (-ENODEV)  if *port_id* invalid.
396199a2dd95SBruce Richardson  *   - (-EINVAL)  if bad parameter
396299a2dd95SBruce Richardson  *   - (-EIO)     if flow control setup failure or device is removed.
396399a2dd95SBruce Richardson  */
396499a2dd95SBruce Richardson int rte_eth_dev_flow_ctrl_set(uint16_t port_id,
396599a2dd95SBruce Richardson 			      struct rte_eth_fc_conf *fc_conf);
396699a2dd95SBruce Richardson 
396799a2dd95SBruce Richardson /**
396899a2dd95SBruce Richardson  * Configure the Ethernet priority flow control under DCB environment
396999a2dd95SBruce Richardson  * for Ethernet device.
397099a2dd95SBruce Richardson  *
397199a2dd95SBruce Richardson  * @param port_id
397299a2dd95SBruce Richardson  * The port identifier of the Ethernet device.
397399a2dd95SBruce Richardson  * @param pfc_conf
397499a2dd95SBruce Richardson  * The pointer to the structure of the priority flow control parameters.
397599a2dd95SBruce Richardson  * @return
397699a2dd95SBruce Richardson  *   - (0) if successful.
397799a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support priority flow control mode.
397899a2dd95SBruce Richardson  *   - (-ENODEV)  if *port_id* invalid.
397999a2dd95SBruce Richardson  *   - (-EINVAL)  if bad parameter
398099a2dd95SBruce Richardson  *   - (-EIO)     if flow control setup failure or device is removed.
398199a2dd95SBruce Richardson  */
398299a2dd95SBruce Richardson int rte_eth_dev_priority_flow_ctrl_set(uint16_t port_id,
398399a2dd95SBruce Richardson 				struct rte_eth_pfc_conf *pfc_conf);
398499a2dd95SBruce Richardson 
398599a2dd95SBruce Richardson /**
398699a2dd95SBruce Richardson  * Add a MAC address to the set used for filtering incoming packets.
398799a2dd95SBruce Richardson  *
398899a2dd95SBruce Richardson  * @param port_id
398999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
399099a2dd95SBruce Richardson  * @param mac_addr
399199a2dd95SBruce Richardson  *   The MAC address to add.
399299a2dd95SBruce Richardson  * @param pool
399399a2dd95SBruce Richardson  *   VMDq pool index to associate address with (if VMDq is enabled). If VMDq is
399499a2dd95SBruce Richardson  *   not enabled, this should be set to 0.
399599a2dd95SBruce Richardson  * @return
399699a2dd95SBruce Richardson  *   - (0) if successfully added or *mac_addr* was already added.
399799a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support this feature.
399899a2dd95SBruce Richardson  *   - (-ENODEV) if *port* is invalid.
399999a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
400099a2dd95SBruce Richardson  *   - (-ENOSPC) if no more MAC addresses can be added.
400199a2dd95SBruce Richardson  *   - (-EINVAL) if MAC address is invalid.
400299a2dd95SBruce Richardson  */
400399a2dd95SBruce Richardson int rte_eth_dev_mac_addr_add(uint16_t port_id, struct rte_ether_addr *mac_addr,
400499a2dd95SBruce Richardson 				uint32_t pool);
400599a2dd95SBruce Richardson 
400699a2dd95SBruce Richardson /**
40070de345e9SJerin Jacob  * @warning
40080de345e9SJerin Jacob  * @b EXPERIMENTAL: this API may change without prior notice.
40090de345e9SJerin Jacob  *
40100de345e9SJerin Jacob  * Retrieve the information for queue based PFC.
40110de345e9SJerin Jacob  *
40120de345e9SJerin Jacob  * @param port_id
40130de345e9SJerin Jacob  *   The port identifier of the Ethernet device.
40140de345e9SJerin Jacob  * @param pfc_queue_info
40150de345e9SJerin Jacob  *   A pointer to a structure of type *rte_eth_pfc_queue_info* to be filled with
40160de345e9SJerin Jacob  *   the information about queue based PFC.
40170de345e9SJerin Jacob  * @return
40180de345e9SJerin Jacob  *   - (0) if successful.
40190de345e9SJerin Jacob  *   - (-ENOTSUP) if support for priority_flow_ctrl_queue_info_get does not exist.
40200de345e9SJerin Jacob  *   - (-ENODEV) if *port_id* invalid.
40210de345e9SJerin Jacob  *   - (-EINVAL) if bad parameter.
40220de345e9SJerin Jacob  */
40230de345e9SJerin Jacob __rte_experimental
40240de345e9SJerin Jacob int rte_eth_dev_priority_flow_ctrl_queue_info_get(uint16_t port_id,
40250de345e9SJerin Jacob 		struct rte_eth_pfc_queue_info *pfc_queue_info);
40260de345e9SJerin Jacob 
40270de345e9SJerin Jacob /**
40280de345e9SJerin Jacob  * @warning
40290de345e9SJerin Jacob  * @b EXPERIMENTAL: this API may change without prior notice.
40300de345e9SJerin Jacob  *
40310de345e9SJerin Jacob  * Configure the queue based priority flow control for a given queue
40320de345e9SJerin Jacob  * for Ethernet device.
40330de345e9SJerin Jacob  *
40340de345e9SJerin Jacob  * @note When an ethdev port switches to queue based PFC mode, the
40350de345e9SJerin Jacob  * unconfigured queues shall be configured by the driver with
40360de345e9SJerin Jacob  * default values such as lower priority value for TC etc.
40370de345e9SJerin Jacob  *
40380de345e9SJerin Jacob  * @param port_id
40390de345e9SJerin Jacob  *   The port identifier of the Ethernet device.
40400de345e9SJerin Jacob  * @param pfc_queue_conf
40410de345e9SJerin Jacob  *   The pointer to the structure of the priority flow control parameters
40420de345e9SJerin Jacob  *   for the queue.
40430de345e9SJerin Jacob  * @return
40440de345e9SJerin Jacob  *   - (0) if successful.
40450de345e9SJerin Jacob  *   - (-ENOTSUP) if hardware doesn't support queue based PFC mode.
40460de345e9SJerin Jacob  *   - (-ENODEV)  if *port_id* invalid.
40470de345e9SJerin Jacob  *   - (-EINVAL)  if bad parameter
40480de345e9SJerin Jacob  *   - (-EIO)     if flow control setup queue failure
40490de345e9SJerin Jacob  */
40500de345e9SJerin Jacob __rte_experimental
40510de345e9SJerin Jacob int rte_eth_dev_priority_flow_ctrl_queue_configure(uint16_t port_id,
40520de345e9SJerin Jacob 		struct rte_eth_pfc_queue_conf *pfc_queue_conf);
40530de345e9SJerin Jacob 
40540de345e9SJerin Jacob /**
405599a2dd95SBruce Richardson  * Remove a MAC address from the internal array of addresses.
405699a2dd95SBruce Richardson  *
405799a2dd95SBruce Richardson  * @param port_id
405899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
405999a2dd95SBruce Richardson  * @param mac_addr
406099a2dd95SBruce Richardson  *   MAC address to remove.
406199a2dd95SBruce Richardson  * @return
406299a2dd95SBruce Richardson  *   - (0) if successful, or *mac_addr* didn't exist.
406399a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
406499a2dd95SBruce Richardson  *   - (-ENODEV) if *port* invalid.
406553ef1b34SMin Hu (Connor)  *   - (-EADDRINUSE) if attempting to remove the default MAC address.
406653ef1b34SMin Hu (Connor)  *   - (-EINVAL) if MAC address is invalid.
406799a2dd95SBruce Richardson  */
406899a2dd95SBruce Richardson int rte_eth_dev_mac_addr_remove(uint16_t port_id,
406999a2dd95SBruce Richardson 				struct rte_ether_addr *mac_addr);
407099a2dd95SBruce Richardson 
407199a2dd95SBruce Richardson /**
407299a2dd95SBruce Richardson  * Set the default MAC address.
407399a2dd95SBruce Richardson  *
407499a2dd95SBruce Richardson  * @param port_id
407599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
407699a2dd95SBruce Richardson  * @param mac_addr
407799a2dd95SBruce Richardson  *   New default MAC address.
407899a2dd95SBruce Richardson  * @return
407999a2dd95SBruce Richardson  *   - (0) if successful, or *mac_addr* didn't exist.
408099a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
408199a2dd95SBruce Richardson  *   - (-ENODEV) if *port* invalid.
408299a2dd95SBruce Richardson  *   - (-EINVAL) if MAC address is invalid.
408399a2dd95SBruce Richardson  */
408499a2dd95SBruce Richardson int rte_eth_dev_default_mac_addr_set(uint16_t port_id,
408599a2dd95SBruce Richardson 		struct rte_ether_addr *mac_addr);
408699a2dd95SBruce Richardson 
408799a2dd95SBruce Richardson /**
408899a2dd95SBruce Richardson  * Update Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
408999a2dd95SBruce Richardson  *
409099a2dd95SBruce Richardson  * @param port_id
409199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
409299a2dd95SBruce Richardson  * @param reta_conf
409399a2dd95SBruce Richardson  *   RETA to update.
409499a2dd95SBruce Richardson  * @param reta_size
409599a2dd95SBruce Richardson  *   Redirection table size. The table size can be queried by
409699a2dd95SBruce Richardson  *   rte_eth_dev_info_get().
409799a2dd95SBruce Richardson  * @return
409899a2dd95SBruce Richardson  *   - (0) if successful.
409999a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
410099a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
410199a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
410299a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
410399a2dd95SBruce Richardson  */
410499a2dd95SBruce Richardson int rte_eth_dev_rss_reta_update(uint16_t port_id,
410599a2dd95SBruce Richardson 				struct rte_eth_rss_reta_entry64 *reta_conf,
410699a2dd95SBruce Richardson 				uint16_t reta_size);
410799a2dd95SBruce Richardson 
410899a2dd95SBruce Richardson /**
410999a2dd95SBruce Richardson  * Query Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
411099a2dd95SBruce Richardson  *
411199a2dd95SBruce Richardson  * @param port_id
411299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
411399a2dd95SBruce Richardson  * @param reta_conf
411499a2dd95SBruce Richardson  *   RETA to query. For each requested reta entry, corresponding bit
411599a2dd95SBruce Richardson  *   in mask must be set.
411699a2dd95SBruce Richardson  * @param reta_size
411799a2dd95SBruce Richardson  *   Redirection table size. The table size can be queried by
411899a2dd95SBruce Richardson  *   rte_eth_dev_info_get().
411999a2dd95SBruce Richardson  * @return
412099a2dd95SBruce Richardson  *   - (0) if successful.
412199a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
412299a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
412399a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
412499a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
412599a2dd95SBruce Richardson  */
412699a2dd95SBruce Richardson int rte_eth_dev_rss_reta_query(uint16_t port_id,
412799a2dd95SBruce Richardson 			       struct rte_eth_rss_reta_entry64 *reta_conf,
412899a2dd95SBruce Richardson 			       uint16_t reta_size);
412999a2dd95SBruce Richardson 
413099a2dd95SBruce Richardson /**
413199a2dd95SBruce Richardson  * Updates unicast hash table for receiving packet with the given destination
413209fd4227SAndrew Rybchenko  * MAC address, and the packet is routed to all VFs for which the Rx mode is
413399a2dd95SBruce Richardson  * accept packets that match the unicast hash table.
413499a2dd95SBruce Richardson  *
413599a2dd95SBruce Richardson  * @param port_id
413699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
413799a2dd95SBruce Richardson  * @param addr
413899a2dd95SBruce Richardson  *   Unicast MAC address.
413999a2dd95SBruce Richardson  * @param on
414099a2dd95SBruce Richardson  *    1 - Set an unicast hash bit for receiving packets with the MAC address.
414199a2dd95SBruce Richardson  *    0 - Clear an unicast hash bit.
414299a2dd95SBruce Richardson  * @return
414399a2dd95SBruce Richardson  *   - (0) if successful.
414499a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
414599a2dd95SBruce Richardson   *  - (-ENODEV) if *port_id* invalid.
414699a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
414799a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
414899a2dd95SBruce Richardson  */
414999a2dd95SBruce Richardson int rte_eth_dev_uc_hash_table_set(uint16_t port_id, struct rte_ether_addr *addr,
415099a2dd95SBruce Richardson 				  uint8_t on);
415199a2dd95SBruce Richardson 
415299a2dd95SBruce Richardson /**
415399a2dd95SBruce Richardson  * Updates all unicast hash bitmaps for receiving packet with any Unicast
415409fd4227SAndrew Rybchenko  * Ethernet MAC addresses,the packet is routed to all VFs for which the Rx
415599a2dd95SBruce Richardson  * mode is accept packets that match the unicast hash table.
415699a2dd95SBruce Richardson  *
415799a2dd95SBruce Richardson  * @param port_id
415899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
415999a2dd95SBruce Richardson  * @param on
416099a2dd95SBruce Richardson  *    1 - Set all unicast hash bitmaps for receiving all the Ethernet
416199a2dd95SBruce Richardson  *         MAC addresses
416299a2dd95SBruce Richardson  *    0 - Clear all unicast hash bitmaps
416399a2dd95SBruce Richardson  * @return
416499a2dd95SBruce Richardson  *   - (0) if successful.
416599a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
416699a2dd95SBruce Richardson   *  - (-ENODEV) if *port_id* invalid.
416799a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
416899a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
416999a2dd95SBruce Richardson  */
417099a2dd95SBruce Richardson int rte_eth_dev_uc_all_hash_table_set(uint16_t port_id, uint8_t on);
417199a2dd95SBruce Richardson 
417299a2dd95SBruce Richardson /**
417399a2dd95SBruce Richardson  * Set the rate limitation for a queue on an Ethernet device.
417499a2dd95SBruce Richardson  *
417599a2dd95SBruce Richardson  * @param port_id
417699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
417799a2dd95SBruce Richardson  * @param queue_idx
41785906be5aSAndrew Rybchenko  *   The queue ID.
417999a2dd95SBruce Richardson  * @param tx_rate
418009fd4227SAndrew Rybchenko  *   The Tx rate in Mbps. Allocated from the total port link speed.
418199a2dd95SBruce Richardson  * @return
418299a2dd95SBruce Richardson  *   - (0) if successful.
418399a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support this feature.
418499a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
418599a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
418699a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
418799a2dd95SBruce Richardson  */
418899a2dd95SBruce Richardson int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx,
418999a2dd95SBruce Richardson 			uint16_t tx_rate);
419099a2dd95SBruce Richardson 
419199a2dd95SBruce Richardson /**
419299a2dd95SBruce Richardson  * Configuration of Receive Side Scaling hash computation of Ethernet device.
419399a2dd95SBruce Richardson  *
419499a2dd95SBruce Richardson  * @param port_id
419599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
419699a2dd95SBruce Richardson  * @param rss_conf
419799a2dd95SBruce Richardson  *   The new configuration to use for RSS hash computation on the port.
419899a2dd95SBruce Richardson  * @return
419999a2dd95SBruce Richardson  *   - (0) if successful.
420099a2dd95SBruce Richardson  *   - (-ENODEV) if port identifier is invalid.
420199a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
420299a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
420399a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
420499a2dd95SBruce Richardson  */
420599a2dd95SBruce Richardson int rte_eth_dev_rss_hash_update(uint16_t port_id,
420699a2dd95SBruce Richardson 				struct rte_eth_rss_conf *rss_conf);
420799a2dd95SBruce Richardson 
420899a2dd95SBruce Richardson /**
420999a2dd95SBruce Richardson  * Retrieve current configuration of Receive Side Scaling hash computation
421099a2dd95SBruce Richardson  * of Ethernet device.
421199a2dd95SBruce Richardson  *
421299a2dd95SBruce Richardson  * @param port_id
421399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
421499a2dd95SBruce Richardson  * @param rss_conf
421599a2dd95SBruce Richardson  *   Where to store the current RSS hash configuration of the Ethernet device.
421699a2dd95SBruce Richardson  * @return
421799a2dd95SBruce Richardson  *   - (0) if successful.
421899a2dd95SBruce Richardson  *   - (-ENODEV) if port identifier is invalid.
421999a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
422099a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support RSS.
422153ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
422299a2dd95SBruce Richardson  */
422399a2dd95SBruce Richardson int
422499a2dd95SBruce Richardson rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
422599a2dd95SBruce Richardson 			      struct rte_eth_rss_conf *rss_conf);
422699a2dd95SBruce Richardson 
422799a2dd95SBruce Richardson /**
422899a2dd95SBruce Richardson  * Add UDP tunneling port for a type of tunnel.
422999a2dd95SBruce Richardson  *
423099a2dd95SBruce Richardson  * Some NICs may require such configuration to properly parse a tunnel
423199a2dd95SBruce Richardson  * with any standard or custom UDP port.
423299a2dd95SBruce Richardson  * The packets with this UDP port will be parsed for this type of tunnel.
423399a2dd95SBruce Richardson  * The device parser will also check the rest of the tunnel headers
423499a2dd95SBruce Richardson  * before classifying the packet.
423599a2dd95SBruce Richardson  *
423699a2dd95SBruce Richardson  * With some devices, this API will affect packet classification, i.e.:
423799a2dd95SBruce Richardson  *     - mbuf.packet_type reported on Rx
423899a2dd95SBruce Richardson  *     - rte_flow rules with tunnel items
423999a2dd95SBruce Richardson  *
424099a2dd95SBruce Richardson  * @param port_id
424199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
424299a2dd95SBruce Richardson  * @param tunnel_udp
424399a2dd95SBruce Richardson  *   UDP tunneling configuration.
424499a2dd95SBruce Richardson  *
424599a2dd95SBruce Richardson  * @return
424699a2dd95SBruce Richardson  *   - (0) if successful.
424799a2dd95SBruce Richardson  *   - (-ENODEV) if port identifier is invalid.
424899a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
424999a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support tunnel type.
425099a2dd95SBruce Richardson  */
425199a2dd95SBruce Richardson int
425299a2dd95SBruce Richardson rte_eth_dev_udp_tunnel_port_add(uint16_t port_id,
425399a2dd95SBruce Richardson 				struct rte_eth_udp_tunnel *tunnel_udp);
425499a2dd95SBruce Richardson 
425599a2dd95SBruce Richardson /**
425699a2dd95SBruce Richardson  * Delete UDP tunneling port for a type of tunnel.
425799a2dd95SBruce Richardson  *
425899a2dd95SBruce Richardson  * The packets with this UDP port will not be classified as this type of tunnel
425999a2dd95SBruce Richardson  * anymore if the device use such mapping for tunnel packet classification.
426099a2dd95SBruce Richardson  *
426199a2dd95SBruce Richardson  * @see rte_eth_dev_udp_tunnel_port_add
426299a2dd95SBruce Richardson  *
426399a2dd95SBruce Richardson  * @param port_id
426499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
426599a2dd95SBruce Richardson  * @param tunnel_udp
426699a2dd95SBruce Richardson  *   UDP tunneling configuration.
426799a2dd95SBruce Richardson  *
426899a2dd95SBruce Richardson  * @return
426999a2dd95SBruce Richardson  *   - (0) if successful.
427099a2dd95SBruce Richardson  *   - (-ENODEV) if port identifier is invalid.
427199a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
427299a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support tunnel type.
427399a2dd95SBruce Richardson  */
427499a2dd95SBruce Richardson int
427599a2dd95SBruce Richardson rte_eth_dev_udp_tunnel_port_delete(uint16_t port_id,
427699a2dd95SBruce Richardson 				   struct rte_eth_udp_tunnel *tunnel_udp);
427799a2dd95SBruce Richardson 
427899a2dd95SBruce Richardson /**
427999a2dd95SBruce Richardson  * Get DCB information on an Ethernet device.
428099a2dd95SBruce Richardson  *
428199a2dd95SBruce Richardson  * @param port_id
428299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
428399a2dd95SBruce Richardson  * @param dcb_info
4284064e90c4SAndrew Rybchenko  *   DCB information.
428599a2dd95SBruce Richardson  * @return
428699a2dd95SBruce Richardson  *   - (0) if successful.
428799a2dd95SBruce Richardson  *   - (-ENODEV) if port identifier is invalid.
428899a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
428999a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
429053ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
429199a2dd95SBruce Richardson  */
429299a2dd95SBruce Richardson int rte_eth_dev_get_dcb_info(uint16_t port_id,
429399a2dd95SBruce Richardson 			     struct rte_eth_dcb_info *dcb_info);
429499a2dd95SBruce Richardson 
429599a2dd95SBruce Richardson struct rte_eth_rxtx_callback;
429699a2dd95SBruce Richardson 
429799a2dd95SBruce Richardson /**
429809fd4227SAndrew Rybchenko  * Add a callback to be called on packet Rx on a given port and queue.
429999a2dd95SBruce Richardson  *
430099a2dd95SBruce Richardson  * This API configures a function to be called for each burst of
430199a2dd95SBruce Richardson  * packets received on a given NIC port queue. The return value is a pointer
430299a2dd95SBruce Richardson  * that can be used to later remove the callback using
430399a2dd95SBruce Richardson  * rte_eth_remove_rx_callback().
430499a2dd95SBruce Richardson  *
430599a2dd95SBruce Richardson  * Multiple functions are called in the order that they are added.
430699a2dd95SBruce Richardson  *
430799a2dd95SBruce Richardson  * @param port_id
430899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
430999a2dd95SBruce Richardson  * @param queue_id
431099a2dd95SBruce Richardson  *   The queue on the Ethernet device on which the callback is to be added.
431199a2dd95SBruce Richardson  * @param fn
431299a2dd95SBruce Richardson  *   The callback function
431399a2dd95SBruce Richardson  * @param user_param
431499a2dd95SBruce Richardson  *   A generic pointer parameter which will be passed to each invocation of the
431599a2dd95SBruce Richardson  *   callback function on this port and queue. Inter-thread synchronization
431699a2dd95SBruce Richardson  *   of any user data changes is the responsibility of the user.
431799a2dd95SBruce Richardson  *
431899a2dd95SBruce Richardson  * @return
431999a2dd95SBruce Richardson  *   NULL on error.
432099a2dd95SBruce Richardson  *   On success, a pointer value which can later be used to remove the callback.
432199a2dd95SBruce Richardson  */
432299a2dd95SBruce Richardson const struct rte_eth_rxtx_callback *
432399a2dd95SBruce Richardson rte_eth_add_rx_callback(uint16_t port_id, uint16_t queue_id,
432499a2dd95SBruce Richardson 		rte_rx_callback_fn fn, void *user_param);
432599a2dd95SBruce Richardson 
432699a2dd95SBruce Richardson /**
432709fd4227SAndrew Rybchenko  * Add a callback that must be called first on packet Rx on a given port
432899a2dd95SBruce Richardson  * and queue.
432999a2dd95SBruce Richardson  *
433099a2dd95SBruce Richardson  * This API configures a first function to be called for each burst of
433199a2dd95SBruce Richardson  * packets received on a given NIC port queue. The return value is a pointer
433299a2dd95SBruce Richardson  * that can be used to later remove the callback using
433399a2dd95SBruce Richardson  * rte_eth_remove_rx_callback().
433499a2dd95SBruce Richardson  *
433599a2dd95SBruce Richardson  * Multiple functions are called in the order that they are added.
433699a2dd95SBruce Richardson  *
433799a2dd95SBruce Richardson  * @param port_id
433899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
433999a2dd95SBruce Richardson  * @param queue_id
434099a2dd95SBruce Richardson  *   The queue on the Ethernet device on which the callback is to be added.
434199a2dd95SBruce Richardson  * @param fn
434299a2dd95SBruce Richardson  *   The callback function
434399a2dd95SBruce Richardson  * @param user_param
434499a2dd95SBruce Richardson  *   A generic pointer parameter which will be passed to each invocation of the
434599a2dd95SBruce Richardson  *   callback function on this port and queue. Inter-thread synchronization
434699a2dd95SBruce Richardson  *   of any user data changes is the responsibility of the user.
434799a2dd95SBruce Richardson  *
434899a2dd95SBruce Richardson  * @return
434999a2dd95SBruce Richardson  *   NULL on error.
435099a2dd95SBruce Richardson  *   On success, a pointer value which can later be used to remove the callback.
435199a2dd95SBruce Richardson  */
435299a2dd95SBruce Richardson const struct rte_eth_rxtx_callback *
435399a2dd95SBruce Richardson rte_eth_add_first_rx_callback(uint16_t port_id, uint16_t queue_id,
435499a2dd95SBruce Richardson 		rte_rx_callback_fn fn, void *user_param);
435599a2dd95SBruce Richardson 
435699a2dd95SBruce Richardson /**
435709fd4227SAndrew Rybchenko  * Add a callback to be called on packet Tx on a given port and queue.
435899a2dd95SBruce Richardson  *
435999a2dd95SBruce Richardson  * This API configures a function to be called for each burst of
436099a2dd95SBruce Richardson  * packets sent on a given NIC port queue. The return value is a pointer
436199a2dd95SBruce Richardson  * that can be used to later remove the callback using
436299a2dd95SBruce Richardson  * rte_eth_remove_tx_callback().
436399a2dd95SBruce Richardson  *
436499a2dd95SBruce Richardson  * Multiple functions are called in the order that they are added.
436599a2dd95SBruce Richardson  *
436699a2dd95SBruce Richardson  * @param port_id
436799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
436899a2dd95SBruce Richardson  * @param queue_id
436999a2dd95SBruce Richardson  *   The queue on the Ethernet device on which the callback is to be added.
437099a2dd95SBruce Richardson  * @param fn
437199a2dd95SBruce Richardson  *   The callback function
437299a2dd95SBruce Richardson  * @param user_param
437399a2dd95SBruce Richardson  *   A generic pointer parameter which will be passed to each invocation of the
437499a2dd95SBruce Richardson  *   callback function on this port and queue. Inter-thread synchronization
437599a2dd95SBruce Richardson  *   of any user data changes is the responsibility of the user.
437699a2dd95SBruce Richardson  *
437799a2dd95SBruce Richardson  * @return
437899a2dd95SBruce Richardson  *   NULL on error.
437999a2dd95SBruce Richardson  *   On success, a pointer value which can later be used to remove the callback.
438099a2dd95SBruce Richardson  */
438199a2dd95SBruce Richardson const struct rte_eth_rxtx_callback *
438299a2dd95SBruce Richardson rte_eth_add_tx_callback(uint16_t port_id, uint16_t queue_id,
438399a2dd95SBruce Richardson 		rte_tx_callback_fn fn, void *user_param);
438499a2dd95SBruce Richardson 
438599a2dd95SBruce Richardson /**
438609fd4227SAndrew Rybchenko  * Remove an Rx packet callback from a given port and queue.
438799a2dd95SBruce Richardson  *
438899a2dd95SBruce Richardson  * This function is used to removed callbacks that were added to a NIC port
438999a2dd95SBruce Richardson  * queue using rte_eth_add_rx_callback().
439099a2dd95SBruce Richardson  *
439199a2dd95SBruce Richardson  * Note: the callback is removed from the callback list but it isn't freed
439299a2dd95SBruce Richardson  * since the it may still be in use. The memory for the callback can be
439399a2dd95SBruce Richardson  * subsequently freed back by the application by calling rte_free():
439499a2dd95SBruce Richardson  *
439599a2dd95SBruce Richardson  * - Immediately - if the port is stopped, or the user knows that no
439609fd4227SAndrew Rybchenko  *   callbacks are in flight e.g. if called from the thread doing Rx/Tx
439799a2dd95SBruce Richardson  *   on that queue.
439899a2dd95SBruce Richardson  *
439999a2dd95SBruce Richardson  * - After a short delay - where the delay is sufficient to allow any
440099a2dd95SBruce Richardson  *   in-flight callbacks to complete. Alternately, the RCU mechanism can be
440199a2dd95SBruce Richardson  *   used to detect when data plane threads have ceased referencing the
440299a2dd95SBruce Richardson  *   callback memory.
440399a2dd95SBruce Richardson  *
440499a2dd95SBruce Richardson  * @param port_id
440599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
440699a2dd95SBruce Richardson  * @param queue_id
440799a2dd95SBruce Richardson  *   The queue on the Ethernet device from which the callback is to be removed.
440899a2dd95SBruce Richardson  * @param user_cb
440999a2dd95SBruce Richardson  *   User supplied callback created via rte_eth_add_rx_callback().
441099a2dd95SBruce Richardson  *
441199a2dd95SBruce Richardson  * @return
441299a2dd95SBruce Richardson  *   - 0: Success. Callback was removed.
441399a2dd95SBruce Richardson  *   - -ENODEV:  If *port_id* is invalid.
441499a2dd95SBruce Richardson  *   - -ENOTSUP: Callback support is not available.
441599a2dd95SBruce Richardson  *   - -EINVAL:  The queue_id is out of range, or the callback
441699a2dd95SBruce Richardson  *               is NULL or not found for the port/queue.
441799a2dd95SBruce Richardson  */
441899a2dd95SBruce Richardson int rte_eth_remove_rx_callback(uint16_t port_id, uint16_t queue_id,
441999a2dd95SBruce Richardson 		const struct rte_eth_rxtx_callback *user_cb);
442099a2dd95SBruce Richardson 
442199a2dd95SBruce Richardson /**
442209fd4227SAndrew Rybchenko  * Remove a Tx packet callback from a given port and queue.
442399a2dd95SBruce Richardson  *
442499a2dd95SBruce Richardson  * This function is used to removed callbacks that were added to a NIC port
442599a2dd95SBruce Richardson  * queue using rte_eth_add_tx_callback().
442699a2dd95SBruce Richardson  *
442799a2dd95SBruce Richardson  * Note: the callback is removed from the callback list but it isn't freed
442899a2dd95SBruce Richardson  * since the it may still be in use. The memory for the callback can be
442999a2dd95SBruce Richardson  * subsequently freed back by the application by calling rte_free():
443099a2dd95SBruce Richardson  *
443199a2dd95SBruce Richardson  * - Immediately - if the port is stopped, or the user knows that no
443209fd4227SAndrew Rybchenko  *   callbacks are in flight e.g. if called from the thread doing Rx/Tx
443399a2dd95SBruce Richardson  *   on that queue.
443499a2dd95SBruce Richardson  *
443599a2dd95SBruce Richardson  * - After a short delay - where the delay is sufficient to allow any
443699a2dd95SBruce Richardson  *   in-flight callbacks to complete. Alternately, the RCU mechanism can be
443799a2dd95SBruce Richardson  *   used to detect when data plane threads have ceased referencing the
443899a2dd95SBruce Richardson  *   callback memory.
443999a2dd95SBruce Richardson  *
444099a2dd95SBruce Richardson  * @param port_id
444199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
444299a2dd95SBruce Richardson  * @param queue_id
444399a2dd95SBruce Richardson  *   The queue on the Ethernet device from which the callback is to be removed.
444499a2dd95SBruce Richardson  * @param user_cb
444599a2dd95SBruce Richardson  *   User supplied callback created via rte_eth_add_tx_callback().
444699a2dd95SBruce Richardson  *
444799a2dd95SBruce Richardson  * @return
444899a2dd95SBruce Richardson  *   - 0: Success. Callback was removed.
444999a2dd95SBruce Richardson  *   - -ENODEV:  If *port_id* is invalid.
445099a2dd95SBruce Richardson  *   - -ENOTSUP: Callback support is not available.
445199a2dd95SBruce Richardson  *   - -EINVAL:  The queue_id is out of range, or the callback
445299a2dd95SBruce Richardson  *               is NULL or not found for the port/queue.
445399a2dd95SBruce Richardson  */
445499a2dd95SBruce Richardson int rte_eth_remove_tx_callback(uint16_t port_id, uint16_t queue_id,
445599a2dd95SBruce Richardson 		const struct rte_eth_rxtx_callback *user_cb);
445699a2dd95SBruce Richardson 
445799a2dd95SBruce Richardson /**
445809fd4227SAndrew Rybchenko  * Retrieve information about given port's Rx queue.
445999a2dd95SBruce Richardson  *
446099a2dd95SBruce Richardson  * @param port_id
446199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
446299a2dd95SBruce Richardson  * @param queue_id
446309fd4227SAndrew Rybchenko  *   The Rx queue on the Ethernet device for which information
446499a2dd95SBruce Richardson  *   will be retrieved.
446599a2dd95SBruce Richardson  * @param qinfo
446699a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_eth_rxq_info_info* to be filled with
446799a2dd95SBruce Richardson  *   the information of the Ethernet device.
446899a2dd95SBruce Richardson  *
446999a2dd95SBruce Richardson  * @return
447099a2dd95SBruce Richardson  *   - 0: Success
447199a2dd95SBruce Richardson  *   - -ENODEV:  If *port_id* is invalid.
447299a2dd95SBruce Richardson  *   - -ENOTSUP: routine is not supported by the device PMD.
447399a2dd95SBruce Richardson  *   - -EINVAL:  The queue_id is out of range, or the queue
447499a2dd95SBruce Richardson  *               is hairpin queue.
447599a2dd95SBruce Richardson  */
447699a2dd95SBruce Richardson int rte_eth_rx_queue_info_get(uint16_t port_id, uint16_t queue_id,
447799a2dd95SBruce Richardson 	struct rte_eth_rxq_info *qinfo);
447899a2dd95SBruce Richardson 
447999a2dd95SBruce Richardson /**
448009fd4227SAndrew Rybchenko  * Retrieve information about given port's Tx queue.
448199a2dd95SBruce Richardson  *
448299a2dd95SBruce Richardson  * @param port_id
448399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
448499a2dd95SBruce Richardson  * @param queue_id
448509fd4227SAndrew Rybchenko  *   The Tx queue on the Ethernet device for which information
448699a2dd95SBruce Richardson  *   will be retrieved.
448799a2dd95SBruce Richardson  * @param qinfo
448899a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_eth_txq_info_info* to be filled with
448999a2dd95SBruce Richardson  *   the information of the Ethernet device.
449099a2dd95SBruce Richardson  *
449199a2dd95SBruce Richardson  * @return
449299a2dd95SBruce Richardson  *   - 0: Success
449399a2dd95SBruce Richardson  *   - -ENODEV:  If *port_id* is invalid.
449499a2dd95SBruce Richardson  *   - -ENOTSUP: routine is not supported by the device PMD.
449599a2dd95SBruce Richardson  *   - -EINVAL:  The queue_id is out of range, or the queue
449699a2dd95SBruce Richardson  *               is hairpin queue.
449799a2dd95SBruce Richardson  */
449899a2dd95SBruce Richardson int rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id,
449999a2dd95SBruce Richardson 	struct rte_eth_txq_info *qinfo);
450099a2dd95SBruce Richardson 
450199a2dd95SBruce Richardson /**
450299a2dd95SBruce Richardson  * Retrieve information about the Rx packet burst mode.
450399a2dd95SBruce Richardson  *
450499a2dd95SBruce Richardson  * @param port_id
450599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
450699a2dd95SBruce Richardson  * @param queue_id
450799a2dd95SBruce Richardson  *   The Rx queue on the Ethernet device for which information
450899a2dd95SBruce Richardson  *   will be retrieved.
450999a2dd95SBruce Richardson  * @param mode
451099a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_eth_burst_mode* to be filled
451199a2dd95SBruce Richardson  *   with the information of the packet burst mode.
451299a2dd95SBruce Richardson  *
451399a2dd95SBruce Richardson  * @return
451499a2dd95SBruce Richardson  *   - 0: Success
451599a2dd95SBruce Richardson  *   - -ENODEV:  If *port_id* is invalid.
451699a2dd95SBruce Richardson  *   - -ENOTSUP: routine is not supported by the device PMD.
451799a2dd95SBruce Richardson  *   - -EINVAL:  The queue_id is out of range.
451899a2dd95SBruce Richardson  */
451999a2dd95SBruce Richardson int rte_eth_rx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
452099a2dd95SBruce Richardson 	struct rte_eth_burst_mode *mode);
452199a2dd95SBruce Richardson 
452299a2dd95SBruce Richardson /**
452399a2dd95SBruce Richardson  * Retrieve information about the Tx packet burst mode.
452499a2dd95SBruce Richardson  *
452599a2dd95SBruce Richardson  * @param port_id
452699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
452799a2dd95SBruce Richardson  * @param queue_id
452899a2dd95SBruce Richardson  *   The Tx queue on the Ethernet device for which information
452999a2dd95SBruce Richardson  *   will be retrieved.
453099a2dd95SBruce Richardson  * @param mode
453199a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_eth_burst_mode* to be filled
453299a2dd95SBruce Richardson  *   with the information of the packet burst mode.
453399a2dd95SBruce Richardson  *
453499a2dd95SBruce Richardson  * @return
453599a2dd95SBruce Richardson  *   - 0: Success
453699a2dd95SBruce Richardson  *   - -ENODEV:  If *port_id* is invalid.
453799a2dd95SBruce Richardson  *   - -ENOTSUP: routine is not supported by the device PMD.
453899a2dd95SBruce Richardson  *   - -EINVAL:  The queue_id is out of range.
453999a2dd95SBruce Richardson  */
454099a2dd95SBruce Richardson int rte_eth_tx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
454199a2dd95SBruce Richardson 	struct rte_eth_burst_mode *mode);
454299a2dd95SBruce Richardson 
454399a2dd95SBruce Richardson /**
454499a2dd95SBruce Richardson  * @warning
454599a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
454699a2dd95SBruce Richardson  *
454799a2dd95SBruce Richardson  * Retrieve the monitor condition for a given receive queue.
454899a2dd95SBruce Richardson  *
454999a2dd95SBruce Richardson  * @param port_id
455099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
455199a2dd95SBruce Richardson  * @param queue_id
455299a2dd95SBruce Richardson  *   The Rx queue on the Ethernet device for which information
455399a2dd95SBruce Richardson  *   will be retrieved.
455499a2dd95SBruce Richardson  * @param pmc
455599a2dd95SBruce Richardson  *   The pointer to power-optimized monitoring condition structure.
455699a2dd95SBruce Richardson  *
455799a2dd95SBruce Richardson  * @return
455899a2dd95SBruce Richardson  *   - 0: Success.
455999a2dd95SBruce Richardson  *   -ENOTSUP: Operation not supported.
456099a2dd95SBruce Richardson  *   -EINVAL: Invalid parameters.
456199a2dd95SBruce Richardson  *   -ENODEV: Invalid port ID.
456299a2dd95SBruce Richardson  */
456399a2dd95SBruce Richardson __rte_experimental
456499a2dd95SBruce Richardson int rte_eth_get_monitor_addr(uint16_t port_id, uint16_t queue_id,
456599a2dd95SBruce Richardson 		struct rte_power_monitor_cond *pmc);
456699a2dd95SBruce Richardson 
456799a2dd95SBruce Richardson /**
456899a2dd95SBruce Richardson  * Retrieve device registers and register attributes (number of registers and
456999a2dd95SBruce Richardson  * register size)
457099a2dd95SBruce Richardson  *
457199a2dd95SBruce Richardson  * @param port_id
457299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
457399a2dd95SBruce Richardson  * @param info
457499a2dd95SBruce Richardson  *   Pointer to rte_dev_reg_info structure to fill in. If info->data is
457599a2dd95SBruce Richardson  *   NULL the function fills in the width and length fields. If non-NULL
457699a2dd95SBruce Richardson  *   the registers are put into the buffer pointed at by the data field.
457799a2dd95SBruce Richardson  * @return
457899a2dd95SBruce Richardson  *   - (0) if successful.
457999a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
458099a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
458199a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
458299a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
458399a2dd95SBruce Richardson  *   - others depends on the specific operations implementation.
458499a2dd95SBruce Richardson  */
458599a2dd95SBruce Richardson int rte_eth_dev_get_reg_info(uint16_t port_id, struct rte_dev_reg_info *info);
458699a2dd95SBruce Richardson 
458799a2dd95SBruce Richardson /**
458899a2dd95SBruce Richardson  * Retrieve size of device EEPROM
458999a2dd95SBruce Richardson  *
459099a2dd95SBruce Richardson  * @param port_id
459199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
459299a2dd95SBruce Richardson  * @return
459399a2dd95SBruce Richardson  *   - (>=0) EEPROM size if successful.
459499a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
459599a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
459699a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
459799a2dd95SBruce Richardson  *   - others depends on the specific operations implementation.
459899a2dd95SBruce Richardson  */
459999a2dd95SBruce Richardson int rte_eth_dev_get_eeprom_length(uint16_t port_id);
460099a2dd95SBruce Richardson 
460199a2dd95SBruce Richardson /**
460299a2dd95SBruce Richardson  * Retrieve EEPROM and EEPROM attribute
460399a2dd95SBruce Richardson  *
460499a2dd95SBruce Richardson  * @param port_id
460599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
460699a2dd95SBruce Richardson  * @param info
460799a2dd95SBruce Richardson  *   The template includes buffer for return EEPROM data and
460899a2dd95SBruce Richardson  *   EEPROM attributes to be filled.
460999a2dd95SBruce Richardson  * @return
461099a2dd95SBruce Richardson  *   - (0) if successful.
461199a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
461299a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
461399a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
461499a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
461599a2dd95SBruce Richardson  *   - others depends on the specific operations implementation.
461699a2dd95SBruce Richardson  */
461799a2dd95SBruce Richardson int rte_eth_dev_get_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
461899a2dd95SBruce Richardson 
461999a2dd95SBruce Richardson /**
462099a2dd95SBruce Richardson  * Program EEPROM with provided data
462199a2dd95SBruce Richardson  *
462299a2dd95SBruce Richardson  * @param port_id
462399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
462499a2dd95SBruce Richardson  * @param info
462599a2dd95SBruce Richardson  *   The template includes EEPROM data for programming and
462699a2dd95SBruce Richardson  *   EEPROM attributes to be filled
462799a2dd95SBruce Richardson  * @return
462899a2dd95SBruce Richardson  *   - (0) if successful.
462999a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
463099a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
463199a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
463299a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
463399a2dd95SBruce Richardson  *   - others depends on the specific operations implementation.
463499a2dd95SBruce Richardson  */
463599a2dd95SBruce Richardson int rte_eth_dev_set_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
463699a2dd95SBruce Richardson 
463799a2dd95SBruce Richardson /**
463899a2dd95SBruce Richardson  * @warning
463999a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
464099a2dd95SBruce Richardson  *
464199a2dd95SBruce Richardson  * Retrieve the type and size of plugin module EEPROM
464299a2dd95SBruce Richardson  *
464399a2dd95SBruce Richardson  * @param port_id
464499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
464599a2dd95SBruce Richardson  * @param modinfo
464699a2dd95SBruce Richardson  *   The type and size of plugin module EEPROM.
464799a2dd95SBruce Richardson  * @return
464899a2dd95SBruce Richardson  *   - (0) if successful.
464999a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
465099a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
465199a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
465299a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
465399a2dd95SBruce Richardson  *   - others depends on the specific operations implementation.
465499a2dd95SBruce Richardson  */
465599a2dd95SBruce Richardson __rte_experimental
465699a2dd95SBruce Richardson int
465799a2dd95SBruce Richardson rte_eth_dev_get_module_info(uint16_t port_id,
465899a2dd95SBruce Richardson 			    struct rte_eth_dev_module_info *modinfo);
465999a2dd95SBruce Richardson 
466099a2dd95SBruce Richardson /**
466199a2dd95SBruce Richardson  * @warning
466299a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
466399a2dd95SBruce Richardson  *
466499a2dd95SBruce Richardson  * Retrieve the data of plugin module EEPROM
466599a2dd95SBruce Richardson  *
466699a2dd95SBruce Richardson  * @param port_id
466799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
466899a2dd95SBruce Richardson  * @param info
466999a2dd95SBruce Richardson  *   The template includes the plugin module EEPROM attributes, and the
467099a2dd95SBruce Richardson  *   buffer for return plugin module EEPROM data.
467199a2dd95SBruce Richardson  * @return
467299a2dd95SBruce Richardson  *   - (0) if successful.
467399a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
467499a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
467599a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
467699a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
467799a2dd95SBruce Richardson  *   - others depends on the specific operations implementation.
467899a2dd95SBruce Richardson  */
467999a2dd95SBruce Richardson __rte_experimental
468099a2dd95SBruce Richardson int
468199a2dd95SBruce Richardson rte_eth_dev_get_module_eeprom(uint16_t port_id,
468299a2dd95SBruce Richardson 			      struct rte_dev_eeprom_info *info);
468399a2dd95SBruce Richardson 
468499a2dd95SBruce Richardson /**
468599a2dd95SBruce Richardson  * Set the list of multicast addresses to filter on an Ethernet device.
468699a2dd95SBruce Richardson  *
468799a2dd95SBruce Richardson  * @param port_id
468899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
468999a2dd95SBruce Richardson  * @param mc_addr_set
469099a2dd95SBruce Richardson  *   The array of multicast addresses to set. Equal to NULL when the function
469199a2dd95SBruce Richardson  *   is invoked to flush the set of filtered addresses.
469299a2dd95SBruce Richardson  * @param nb_mc_addr
469399a2dd95SBruce Richardson  *   The number of multicast addresses in the *mc_addr_set* array. Equal to 0
469499a2dd95SBruce Richardson  *   when the function is invoked to flush the set of filtered addresses.
469599a2dd95SBruce Richardson  * @return
469699a2dd95SBruce Richardson  *   - (0) if successful.
469799a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
469899a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
469999a2dd95SBruce Richardson  *   - (-ENOTSUP) if PMD of *port_id* doesn't support multicast filtering.
470099a2dd95SBruce Richardson  *   - (-ENOSPC) if *port_id* has not enough multicast filtering resources.
470153ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
470299a2dd95SBruce Richardson  */
470399a2dd95SBruce Richardson int rte_eth_dev_set_mc_addr_list(uint16_t port_id,
470499a2dd95SBruce Richardson 				 struct rte_ether_addr *mc_addr_set,
470599a2dd95SBruce Richardson 				 uint32_t nb_mc_addr);
470699a2dd95SBruce Richardson 
470799a2dd95SBruce Richardson /**
470899a2dd95SBruce Richardson  * Enable IEEE1588/802.1AS timestamping for an Ethernet device.
470999a2dd95SBruce Richardson  *
471099a2dd95SBruce Richardson  * @param port_id
471199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
471299a2dd95SBruce Richardson  *
471399a2dd95SBruce Richardson  * @return
471499a2dd95SBruce Richardson  *   - 0: Success.
471599a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
471699a2dd95SBruce Richardson  *   - -EIO: if device is removed.
471799a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
471899a2dd95SBruce Richardson  */
471999a2dd95SBruce Richardson int rte_eth_timesync_enable(uint16_t port_id);
472099a2dd95SBruce Richardson 
472199a2dd95SBruce Richardson /**
472299a2dd95SBruce Richardson  * Disable IEEE1588/802.1AS timestamping for an Ethernet device.
472399a2dd95SBruce Richardson  *
472499a2dd95SBruce Richardson  * @param port_id
472599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
472699a2dd95SBruce Richardson  *
472799a2dd95SBruce Richardson  * @return
472899a2dd95SBruce Richardson  *   - 0: Success.
472999a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
473099a2dd95SBruce Richardson  *   - -EIO: if device is removed.
473199a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
473299a2dd95SBruce Richardson  */
473399a2dd95SBruce Richardson int rte_eth_timesync_disable(uint16_t port_id);
473499a2dd95SBruce Richardson 
473599a2dd95SBruce Richardson /**
473609fd4227SAndrew Rybchenko  * Read an IEEE1588/802.1AS Rx timestamp from an Ethernet device.
473799a2dd95SBruce Richardson  *
473899a2dd95SBruce Richardson  * @param port_id
473999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
474099a2dd95SBruce Richardson  * @param timestamp
474199a2dd95SBruce Richardson  *   Pointer to the timestamp struct.
474299a2dd95SBruce Richardson  * @param flags
474309fd4227SAndrew Rybchenko  *   Device specific flags. Used to pass the Rx timesync register index to
474499a2dd95SBruce Richardson  *   i40e. Unused in igb/ixgbe, pass 0 instead.
474599a2dd95SBruce Richardson  *
474699a2dd95SBruce Richardson  * @return
474799a2dd95SBruce Richardson  *   - 0: Success.
474899a2dd95SBruce Richardson  *   - -EINVAL: No timestamp is available.
474999a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
475099a2dd95SBruce Richardson  *   - -EIO: if device is removed.
475199a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
475299a2dd95SBruce Richardson  */
475399a2dd95SBruce Richardson int rte_eth_timesync_read_rx_timestamp(uint16_t port_id,
475499a2dd95SBruce Richardson 		struct timespec *timestamp, uint32_t flags);
475599a2dd95SBruce Richardson 
475699a2dd95SBruce Richardson /**
475709fd4227SAndrew Rybchenko  * Read an IEEE1588/802.1AS Tx timestamp from an Ethernet device.
475899a2dd95SBruce Richardson  *
475999a2dd95SBruce Richardson  * @param port_id
476099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
476199a2dd95SBruce Richardson  * @param timestamp
476299a2dd95SBruce Richardson  *   Pointer to the timestamp struct.
476399a2dd95SBruce Richardson  *
476499a2dd95SBruce Richardson  * @return
476599a2dd95SBruce Richardson  *   - 0: Success.
476699a2dd95SBruce Richardson  *   - -EINVAL: No timestamp is available.
476799a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
476899a2dd95SBruce Richardson  *   - -EIO: if device is removed.
476999a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
477099a2dd95SBruce Richardson  */
477199a2dd95SBruce Richardson int rte_eth_timesync_read_tx_timestamp(uint16_t port_id,
477299a2dd95SBruce Richardson 		struct timespec *timestamp);
477399a2dd95SBruce Richardson 
477499a2dd95SBruce Richardson /**
477599a2dd95SBruce Richardson  * Adjust the timesync clock on an Ethernet device.
477699a2dd95SBruce Richardson  *
477799a2dd95SBruce Richardson  * This is usually used in conjunction with other Ethdev timesync functions to
477899a2dd95SBruce Richardson  * synchronize the device time using the IEEE1588/802.1AS protocol.
477999a2dd95SBruce Richardson  *
478099a2dd95SBruce Richardson  * @param port_id
478199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
478299a2dd95SBruce Richardson  * @param delta
478399a2dd95SBruce Richardson  *   The adjustment in nanoseconds.
478499a2dd95SBruce Richardson  *
478599a2dd95SBruce Richardson  * @return
478699a2dd95SBruce Richardson  *   - 0: Success.
478799a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
478899a2dd95SBruce Richardson  *   - -EIO: if device is removed.
478999a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
479099a2dd95SBruce Richardson  */
479199a2dd95SBruce Richardson int rte_eth_timesync_adjust_time(uint16_t port_id, int64_t delta);
479299a2dd95SBruce Richardson 
479399a2dd95SBruce Richardson /**
479499a2dd95SBruce Richardson  * Read the time from the timesync clock on an Ethernet device.
479599a2dd95SBruce Richardson  *
479699a2dd95SBruce Richardson  * This is usually used in conjunction with other Ethdev timesync functions to
479799a2dd95SBruce Richardson  * synchronize the device time using the IEEE1588/802.1AS protocol.
479899a2dd95SBruce Richardson  *
479999a2dd95SBruce Richardson  * @param port_id
480099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
480199a2dd95SBruce Richardson  * @param time
480299a2dd95SBruce Richardson  *   Pointer to the timespec struct that holds the time.
480399a2dd95SBruce Richardson  *
480499a2dd95SBruce Richardson  * @return
480599a2dd95SBruce Richardson  *   - 0: Success.
480653ef1b34SMin Hu (Connor)  *   - -EINVAL: Bad parameter.
480799a2dd95SBruce Richardson  */
480899a2dd95SBruce Richardson int rte_eth_timesync_read_time(uint16_t port_id, struct timespec *time);
480999a2dd95SBruce Richardson 
481099a2dd95SBruce Richardson /**
481199a2dd95SBruce Richardson  * Set the time of the timesync clock on an Ethernet device.
481299a2dd95SBruce Richardson  *
481399a2dd95SBruce Richardson  * This is usually used in conjunction with other Ethdev timesync functions to
481499a2dd95SBruce Richardson  * synchronize the device time using the IEEE1588/802.1AS protocol.
481599a2dd95SBruce Richardson  *
481699a2dd95SBruce Richardson  * @param port_id
481799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
481899a2dd95SBruce Richardson  * @param time
481999a2dd95SBruce Richardson  *   Pointer to the timespec struct that holds the time.
482099a2dd95SBruce Richardson  *
482199a2dd95SBruce Richardson  * @return
482299a2dd95SBruce Richardson  *   - 0: Success.
482399a2dd95SBruce Richardson  *   - -EINVAL: No timestamp is available.
482499a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
482599a2dd95SBruce Richardson  *   - -EIO: if device is removed.
482699a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
482799a2dd95SBruce Richardson  */
482899a2dd95SBruce Richardson int rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *time);
482999a2dd95SBruce Richardson 
483099a2dd95SBruce Richardson /**
483199a2dd95SBruce Richardson  * @warning
483299a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
483399a2dd95SBruce Richardson  *
483499a2dd95SBruce Richardson  * Read the current clock counter of an Ethernet device
483599a2dd95SBruce Richardson  *
483699a2dd95SBruce Richardson  * This returns the current raw clock value of an Ethernet device. It is
483799a2dd95SBruce Richardson  * a raw amount of ticks, with no given time reference.
483899a2dd95SBruce Richardson  * The value returned here is from the same clock than the one
483999a2dd95SBruce Richardson  * filling timestamp field of Rx packets when using hardware timestamp
484099a2dd95SBruce Richardson  * offload. Therefore it can be used to compute a precise conversion of
484199a2dd95SBruce Richardson  * the device clock to the real time.
484299a2dd95SBruce Richardson  *
484399a2dd95SBruce Richardson  * E.g, a simple heuristic to derivate the frequency would be:
484499a2dd95SBruce Richardson  * uint64_t start, end;
484599a2dd95SBruce Richardson  * rte_eth_read_clock(port, start);
484699a2dd95SBruce Richardson  * rte_delay_ms(100);
484799a2dd95SBruce Richardson  * rte_eth_read_clock(port, end);
484899a2dd95SBruce Richardson  * double freq = (end - start) * 10;
484999a2dd95SBruce Richardson  *
485099a2dd95SBruce Richardson  * Compute a common reference with:
485199a2dd95SBruce Richardson  * uint64_t base_time_sec = current_time();
485299a2dd95SBruce Richardson  * uint64_t base_clock;
485399a2dd95SBruce Richardson  * rte_eth_read_clock(port, base_clock);
485499a2dd95SBruce Richardson  *
485599a2dd95SBruce Richardson  * Then, convert the raw mbuf timestamp with:
485699a2dd95SBruce Richardson  * base_time_sec + (double)(*timestamp_dynfield(mbuf) - base_clock) / freq;
485799a2dd95SBruce Richardson  *
485899a2dd95SBruce Richardson  * This simple example will not provide a very good accuracy. One must
485999a2dd95SBruce Richardson  * at least measure multiple times the frequency and do a regression.
486099a2dd95SBruce Richardson  * To avoid deviation from the system time, the common reference can
486199a2dd95SBruce Richardson  * be repeated from time to time. The integer division can also be
486299a2dd95SBruce Richardson  * converted by a multiplication and a shift for better performance.
486399a2dd95SBruce Richardson  *
486499a2dd95SBruce Richardson  * @param port_id
486599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
486699a2dd95SBruce Richardson  * @param clock
486799a2dd95SBruce Richardson  *   Pointer to the uint64_t that holds the raw clock value.
486899a2dd95SBruce Richardson  *
486999a2dd95SBruce Richardson  * @return
487099a2dd95SBruce Richardson  *   - 0: Success.
487199a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
487299a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
487353ef1b34SMin Hu (Connor)  *   - -EINVAL: if bad parameter.
487499a2dd95SBruce Richardson  */
487599a2dd95SBruce Richardson __rte_experimental
487699a2dd95SBruce Richardson int
487799a2dd95SBruce Richardson rte_eth_read_clock(uint16_t port_id, uint64_t *clock);
487899a2dd95SBruce Richardson 
487999a2dd95SBruce Richardson /**
48805906be5aSAndrew Rybchenko * Get the port ID from device name. The device name should be specified
488199a2dd95SBruce Richardson * as below:
488299a2dd95SBruce Richardson * - PCIe address (Domain:Bus:Device.Function), for example- 0000:2:00.0
488399a2dd95SBruce Richardson * - SoC device name, for example- fsl-gmac0
488499a2dd95SBruce Richardson * - vdev dpdk name, for example- net_[pcap0|null0|tap0]
488599a2dd95SBruce Richardson *
488699a2dd95SBruce Richardson * @param name
488799a2dd95SBruce Richardson *  pci address or name of the device
488899a2dd95SBruce Richardson * @param port_id
488999a2dd95SBruce Richardson *   pointer to port identifier of the device
489099a2dd95SBruce Richardson * @return
489199a2dd95SBruce Richardson *   - (0) if successful and port_id is filled.
489299a2dd95SBruce Richardson *   - (-ENODEV or -EINVAL) on failure.
489399a2dd95SBruce Richardson */
489499a2dd95SBruce Richardson int
489599a2dd95SBruce Richardson rte_eth_dev_get_port_by_name(const char *name, uint16_t *port_id);
489699a2dd95SBruce Richardson 
489799a2dd95SBruce Richardson /**
48985906be5aSAndrew Rybchenko * Get the device name from port ID. The device name is specified as below:
489999a2dd95SBruce Richardson * - PCIe address (Domain:Bus:Device.Function), for example- 0000:02:00.0
490099a2dd95SBruce Richardson * - SoC device name, for example- fsl-gmac0
490199a2dd95SBruce Richardson * - vdev dpdk name, for example- net_[pcap0|null0|tun0|tap0]
490299a2dd95SBruce Richardson *
490399a2dd95SBruce Richardson * @param port_id
490499a2dd95SBruce Richardson *   Port identifier of the device.
490599a2dd95SBruce Richardson * @param name
490699a2dd95SBruce Richardson *   Buffer of size RTE_ETH_NAME_MAX_LEN to store the name.
490799a2dd95SBruce Richardson * @return
490899a2dd95SBruce Richardson *   - (0) if successful.
490999a2dd95SBruce Richardson *   - (-ENODEV) if *port_id* is invalid.
491099a2dd95SBruce Richardson *   - (-EINVAL) on failure.
491199a2dd95SBruce Richardson */
491299a2dd95SBruce Richardson int
491399a2dd95SBruce Richardson rte_eth_dev_get_name_by_port(uint16_t port_id, char *name);
491499a2dd95SBruce Richardson 
491599a2dd95SBruce Richardson /**
491699a2dd95SBruce Richardson  * Check that numbers of Rx and Tx descriptors satisfy descriptors limits from
49170d9f56a8SAndrew Rybchenko  * the Ethernet device information, otherwise adjust them to boundaries.
491899a2dd95SBruce Richardson  *
491999a2dd95SBruce Richardson  * @param port_id
492099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
492199a2dd95SBruce Richardson  * @param nb_rx_desc
492299a2dd95SBruce Richardson  *   A pointer to a uint16_t where the number of receive
492399a2dd95SBruce Richardson  *   descriptors stored.
492499a2dd95SBruce Richardson  * @param nb_tx_desc
492599a2dd95SBruce Richardson  *   A pointer to a uint16_t where the number of transmit
492699a2dd95SBruce Richardson  *   descriptors stored.
492799a2dd95SBruce Richardson  * @return
492899a2dd95SBruce Richardson  *   - (0) if successful.
492999a2dd95SBruce Richardson  *   - (-ENOTSUP, -ENODEV or -EINVAL) on failure.
493099a2dd95SBruce Richardson  */
493199a2dd95SBruce Richardson int rte_eth_dev_adjust_nb_rx_tx_desc(uint16_t port_id,
493299a2dd95SBruce Richardson 				     uint16_t *nb_rx_desc,
493399a2dd95SBruce Richardson 				     uint16_t *nb_tx_desc);
493499a2dd95SBruce Richardson 
493599a2dd95SBruce Richardson /**
493699a2dd95SBruce Richardson  * Test if a port supports specific mempool ops.
493799a2dd95SBruce Richardson  *
493899a2dd95SBruce Richardson  * @param port_id
493999a2dd95SBruce Richardson  *   Port identifier of the Ethernet device.
494099a2dd95SBruce Richardson  * @param [in] pool
494199a2dd95SBruce Richardson  *   The name of the pool operations to test.
494299a2dd95SBruce Richardson  * @return
494399a2dd95SBruce Richardson  *   - 0: best mempool ops choice for this port.
494499a2dd95SBruce Richardson  *   - 1: mempool ops are supported for this port.
494599a2dd95SBruce Richardson  *   - -ENOTSUP: mempool ops not supported for this port.
494699a2dd95SBruce Richardson  *   - -ENODEV: Invalid port Identifier.
494799a2dd95SBruce Richardson  *   - -EINVAL: Pool param is null.
494899a2dd95SBruce Richardson  */
494999a2dd95SBruce Richardson int
495099a2dd95SBruce Richardson rte_eth_dev_pool_ops_supported(uint16_t port_id, const char *pool);
495199a2dd95SBruce Richardson 
495299a2dd95SBruce Richardson /**
495399a2dd95SBruce Richardson  * Get the security context for the Ethernet device.
495499a2dd95SBruce Richardson  *
495599a2dd95SBruce Richardson  * @param port_id
495699a2dd95SBruce Richardson  *   Port identifier of the Ethernet device
495799a2dd95SBruce Richardson  * @return
495899a2dd95SBruce Richardson  *   - NULL on error.
495999a2dd95SBruce Richardson  *   - pointer to security context on success.
496099a2dd95SBruce Richardson  */
496199a2dd95SBruce Richardson void *
496299a2dd95SBruce Richardson rte_eth_dev_get_sec_ctx(uint16_t port_id);
496399a2dd95SBruce Richardson 
496499a2dd95SBruce Richardson /**
496599a2dd95SBruce Richardson  * @warning
496699a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
496799a2dd95SBruce Richardson  *
496899a2dd95SBruce Richardson  * Query the device hairpin capabilities.
496999a2dd95SBruce Richardson  *
497099a2dd95SBruce Richardson  * @param port_id
497199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
497299a2dd95SBruce Richardson  * @param cap
497399a2dd95SBruce Richardson  *   Pointer to a structure that will hold the hairpin capabilities.
497499a2dd95SBruce Richardson  * @return
497599a2dd95SBruce Richardson  *   - (0) if successful.
497699a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
497753ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
497899a2dd95SBruce Richardson  */
497999a2dd95SBruce Richardson __rte_experimental
498099a2dd95SBruce Richardson int rte_eth_dev_hairpin_capability_get(uint16_t port_id,
498199a2dd95SBruce Richardson 				       struct rte_eth_hairpin_cap *cap);
498299a2dd95SBruce Richardson 
498399a2dd95SBruce Richardson /**
498499a2dd95SBruce Richardson  * @warning
498599a2dd95SBruce Richardson  * @b EXPERIMENTAL: this structure may change without prior notice.
498699a2dd95SBruce Richardson  *
49870d9f56a8SAndrew Rybchenko  * Ethernet device representor ID range entry
498899a2dd95SBruce Richardson  */
498999a2dd95SBruce Richardson struct rte_eth_representor_range {
499099a2dd95SBruce Richardson 	enum rte_eth_representor_type type; /**< Representor type */
499199a2dd95SBruce Richardson 	int controller; /**< Controller index */
499299a2dd95SBruce Richardson 	int pf; /**< Physical function index */
499399a2dd95SBruce Richardson 	__extension__
499499a2dd95SBruce Richardson 	union {
499599a2dd95SBruce Richardson 		int vf; /**< VF start index */
499699a2dd95SBruce Richardson 		int sf; /**< SF start index */
499799a2dd95SBruce Richardson 	};
499899a2dd95SBruce Richardson 	uint32_t id_base; /**< Representor ID start index */
499999a2dd95SBruce Richardson 	uint32_t id_end;  /**< Representor ID end index */
500099a2dd95SBruce Richardson 	char name[RTE_DEV_NAME_MAX_LEN]; /**< Representor name */
500199a2dd95SBruce Richardson };
500299a2dd95SBruce Richardson 
500399a2dd95SBruce Richardson /**
500499a2dd95SBruce Richardson  * @warning
500599a2dd95SBruce Richardson  * @b EXPERIMENTAL: this structure may change without prior notice.
500699a2dd95SBruce Richardson  *
500799a2dd95SBruce Richardson  * Ethernet device representor information
500899a2dd95SBruce Richardson  */
500999a2dd95SBruce Richardson struct rte_eth_representor_info {
501099a2dd95SBruce Richardson 	uint16_t controller; /**< Controller ID of caller device. */
501199a2dd95SBruce Richardson 	uint16_t pf; /**< Physical function ID of caller device. */
501210eaf41dSViacheslav Galaktionov 	uint32_t nb_ranges_alloc; /**< Size of the ranges array. */
501310eaf41dSViacheslav Galaktionov 	uint32_t nb_ranges; /**< Number of initialized ranges. */
501499a2dd95SBruce Richardson 	struct rte_eth_representor_range ranges[];/**< Representor ID range. */
501599a2dd95SBruce Richardson };
501699a2dd95SBruce Richardson 
501799a2dd95SBruce Richardson /**
501899a2dd95SBruce Richardson  * Retrieve the representor info of the device.
501999a2dd95SBruce Richardson  *
502099a2dd95SBruce Richardson  * Get device representor info to be able to calculate a unique
502199a2dd95SBruce Richardson  * representor ID. @see rte_eth_representor_id_get helper.
502299a2dd95SBruce Richardson  *
502399a2dd95SBruce Richardson  * @param port_id
502499a2dd95SBruce Richardson  *   The port identifier of the device.
502599a2dd95SBruce Richardson  * @param info
502699a2dd95SBruce Richardson  *   A pointer to a representor info structure.
502799a2dd95SBruce Richardson  *   NULL to return number of range entries and allocate memory
502899a2dd95SBruce Richardson  *   for next call to store detail.
502910eaf41dSViacheslav Galaktionov  *   The number of ranges that were written into this structure
503010eaf41dSViacheslav Galaktionov  *   will be placed into its nb_ranges field. This number cannot be
503110eaf41dSViacheslav Galaktionov  *   larger than the nb_ranges_alloc that by the user before calling
503210eaf41dSViacheslav Galaktionov  *   this function. It can be smaller than the value returned by the
503310eaf41dSViacheslav Galaktionov  *   function, however.
503499a2dd95SBruce Richardson  * @return
503599a2dd95SBruce Richardson  *   - (-ENOTSUP) if operation is not supported.
503699a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
503799a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
503810eaf41dSViacheslav Galaktionov  *   - (>=0) number of available representor range entries.
503999a2dd95SBruce Richardson  */
504099a2dd95SBruce Richardson __rte_experimental
504199a2dd95SBruce Richardson int rte_eth_representor_info_get(uint16_t port_id,
504299a2dd95SBruce Richardson 				 struct rte_eth_representor_info *info);
504399a2dd95SBruce Richardson 
5044f6d8a6d3SIvan Malov /** The NIC is able to deliver flag (if set) with packets to the PMD. */
5045e1823e08SThomas Monjalon #define RTE_ETH_RX_METADATA_USER_FLAG RTE_BIT64(0)
5046f6d8a6d3SIvan Malov 
5047f6d8a6d3SIvan Malov /** The NIC is able to deliver mark ID with packets to the PMD. */
5048e1823e08SThomas Monjalon #define RTE_ETH_RX_METADATA_USER_MARK RTE_BIT64(1)
5049f6d8a6d3SIvan Malov 
5050f6d8a6d3SIvan Malov /** The NIC is able to deliver tunnel ID with packets to the PMD. */
5051e1823e08SThomas Monjalon #define RTE_ETH_RX_METADATA_TUNNEL_ID RTE_BIT64(2)
5052f6d8a6d3SIvan Malov 
5053f6d8a6d3SIvan Malov /**
5054f6d8a6d3SIvan Malov  * Negotiate the NIC's ability to deliver specific kinds of metadata to the PMD.
5055f6d8a6d3SIvan Malov  *
5056f6d8a6d3SIvan Malov  * Invoke this API before the first rte_eth_dev_configure() invocation
5057f6d8a6d3SIvan Malov  * to let the PMD make preparations that are inconvenient to do later.
5058f6d8a6d3SIvan Malov  *
5059f6d8a6d3SIvan Malov  * The negotiation process is as follows:
5060f6d8a6d3SIvan Malov  *
5061f6d8a6d3SIvan Malov  * - the application requests features intending to use at least some of them;
5062f6d8a6d3SIvan Malov  * - the PMD responds with the guaranteed subset of the requested feature set;
5063f6d8a6d3SIvan Malov  * - the application can retry negotiation with another set of features;
5064f6d8a6d3SIvan Malov  * - the application can pass zero to clear the negotiation result;
5065f6d8a6d3SIvan Malov  * - the last negotiated result takes effect upon
5066f6d8a6d3SIvan Malov  *   the ethdev configure and start.
5067f6d8a6d3SIvan Malov  *
5068f6d8a6d3SIvan Malov  * @note
5069f6d8a6d3SIvan Malov  *   The PMD is supposed to first consider enabling the requested feature set
5070f6d8a6d3SIvan Malov  *   in its entirety. Only if it fails to do so, does it have the right to
5071f6d8a6d3SIvan Malov  *   respond with a smaller set of the originally requested features.
5072f6d8a6d3SIvan Malov  *
5073f6d8a6d3SIvan Malov  * @note
5074f6d8a6d3SIvan Malov  *   Return code (-ENOTSUP) does not necessarily mean that the requested
5075f6d8a6d3SIvan Malov  *   features are unsupported. In this case, the application should just
5076f6d8a6d3SIvan Malov  *   assume that these features can be used without prior negotiations.
5077f6d8a6d3SIvan Malov  *
5078f6d8a6d3SIvan Malov  * @param port_id
5079f6d8a6d3SIvan Malov  *   Port (ethdev) identifier
5080f6d8a6d3SIvan Malov  *
5081f6d8a6d3SIvan Malov  * @param[inout] features
5082f6d8a6d3SIvan Malov  *   Feature selection buffer
5083f6d8a6d3SIvan Malov  *
5084f6d8a6d3SIvan Malov  * @return
5085f6d8a6d3SIvan Malov  *   - (-EBUSY) if the port can't handle this in its current state;
5086f6d8a6d3SIvan Malov  *   - (-ENOTSUP) if the method itself is not supported by the PMD;
5087f6d8a6d3SIvan Malov  *   - (-ENODEV) if *port_id* is invalid;
5088f6d8a6d3SIvan Malov  *   - (-EINVAL) if *features* is NULL;
5089f6d8a6d3SIvan Malov  *   - (-EIO) if the device is removed;
5090f6d8a6d3SIvan Malov  *   - (0) on success
5091f6d8a6d3SIvan Malov  */
5092f6d8a6d3SIvan Malov int rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features);
5093f6d8a6d3SIvan Malov 
5094a75ab6e5SAkhil Goyal /** Flag to offload IP reassembly for IPv4 packets. */
5095a75ab6e5SAkhil Goyal #define RTE_ETH_DEV_REASSEMBLY_F_IPV4 (RTE_BIT32(0))
5096a75ab6e5SAkhil Goyal /** Flag to offload IP reassembly for IPv6 packets. */
5097a75ab6e5SAkhil Goyal #define RTE_ETH_DEV_REASSEMBLY_F_IPV6 (RTE_BIT32(1))
5098a75ab6e5SAkhil Goyal 
5099a75ab6e5SAkhil Goyal /**
5100a75ab6e5SAkhil Goyal  * A structure used to get/set IP reassembly configuration. It is also used
5101a75ab6e5SAkhil Goyal  * to get the maximum capability values that a PMD can support.
5102a75ab6e5SAkhil Goyal  *
5103a75ab6e5SAkhil Goyal  * If rte_eth_ip_reassembly_capability_get() returns 0, IP reassembly can be
5104a75ab6e5SAkhil Goyal  * enabled using rte_eth_ip_reassembly_conf_set() and params values lower than
5105a75ab6e5SAkhil Goyal  * capability params can be set in the PMD.
5106a75ab6e5SAkhil Goyal  */
5107a75ab6e5SAkhil Goyal struct rte_eth_ip_reassembly_params {
5108a75ab6e5SAkhil Goyal 	/** Maximum time in ms which PMD can wait for other fragments. */
5109a75ab6e5SAkhil Goyal 	uint32_t timeout_ms;
5110a75ab6e5SAkhil Goyal 	/** Maximum number of fragments that can be reassembled. */
5111a75ab6e5SAkhil Goyal 	uint16_t max_frags;
5112a75ab6e5SAkhil Goyal 	/**
5113a75ab6e5SAkhil Goyal 	 * Flags to enable reassembly of packet types -
5114a75ab6e5SAkhil Goyal 	 * RTE_ETH_DEV_REASSEMBLY_F_xxx.
5115a75ab6e5SAkhil Goyal 	 */
5116a75ab6e5SAkhil Goyal 	uint16_t flags;
5117a75ab6e5SAkhil Goyal };
5118a75ab6e5SAkhil Goyal 
5119a75ab6e5SAkhil Goyal /**
5120a75ab6e5SAkhil Goyal  * @warning
5121a75ab6e5SAkhil Goyal  * @b EXPERIMENTAL: this API may change without prior notice
5122a75ab6e5SAkhil Goyal  *
5123a75ab6e5SAkhil Goyal  * Get IP reassembly capabilities supported by the PMD. This is the first API
5124a75ab6e5SAkhil Goyal  * to be called for enabling the IP reassembly offload feature. PMD will return
5125a75ab6e5SAkhil Goyal  * the maximum values of parameters that PMD can support and user can call
5126a75ab6e5SAkhil Goyal  * rte_eth_ip_reassembly_conf_set() with param values lower than capability.
5127a75ab6e5SAkhil Goyal  *
5128a75ab6e5SAkhil Goyal  * @param port_id
5129a75ab6e5SAkhil Goyal  *   The port identifier of the device.
5130a75ab6e5SAkhil Goyal  * @param capa
5131a75ab6e5SAkhil Goyal  *   A pointer to rte_eth_ip_reassembly_params structure.
5132a75ab6e5SAkhil Goyal  * @return
5133a75ab6e5SAkhil Goyal  *   - (-ENOTSUP) if offload configuration is not supported by device.
5134a75ab6e5SAkhil Goyal  *   - (-ENODEV) if *port_id* invalid.
5135a75ab6e5SAkhil Goyal  *   - (-EIO) if device is removed.
5136a75ab6e5SAkhil Goyal  *   - (-EINVAL) if device is not configured or *capa* passed is NULL.
5137a75ab6e5SAkhil Goyal  *   - (0) on success.
5138a75ab6e5SAkhil Goyal  */
5139a75ab6e5SAkhil Goyal __rte_experimental
5140a75ab6e5SAkhil Goyal int rte_eth_ip_reassembly_capability_get(uint16_t port_id,
5141a75ab6e5SAkhil Goyal 		struct rte_eth_ip_reassembly_params *capa);
5142a75ab6e5SAkhil Goyal 
5143a75ab6e5SAkhil Goyal /**
5144a75ab6e5SAkhil Goyal  * @warning
5145a75ab6e5SAkhil Goyal  * @b EXPERIMENTAL: this API may change without prior notice
5146a75ab6e5SAkhil Goyal  *
5147a75ab6e5SAkhil Goyal  * Get IP reassembly configuration parameters currently set in PMD.
5148a75ab6e5SAkhil Goyal  * The API will return error if the configuration is not already
5149a75ab6e5SAkhil Goyal  * set using rte_eth_ip_reassembly_conf_set() before calling this API or if
5150a75ab6e5SAkhil Goyal  * the device is not configured.
5151a75ab6e5SAkhil Goyal  *
5152a75ab6e5SAkhil Goyal  * @param port_id
5153a75ab6e5SAkhil Goyal  *   The port identifier of the device.
5154a75ab6e5SAkhil Goyal  * @param conf
5155a75ab6e5SAkhil Goyal  *   A pointer to rte_eth_ip_reassembly_params structure.
5156a75ab6e5SAkhil Goyal  * @return
5157a75ab6e5SAkhil Goyal  *   - (-ENOTSUP) if offload configuration is not supported by device.
5158a75ab6e5SAkhil Goyal  *   - (-ENODEV) if *port_id* invalid.
5159a75ab6e5SAkhil Goyal  *   - (-EIO) if device is removed.
5160a75ab6e5SAkhil Goyal  *   - (-EINVAL) if device is not configured or if *conf* passed is NULL or if
5161a75ab6e5SAkhil Goyal  *              configuration is not set using rte_eth_ip_reassembly_conf_set().
5162a75ab6e5SAkhil Goyal  *   - (0) on success.
5163a75ab6e5SAkhil Goyal  */
5164a75ab6e5SAkhil Goyal __rte_experimental
5165a75ab6e5SAkhil Goyal int rte_eth_ip_reassembly_conf_get(uint16_t port_id,
5166a75ab6e5SAkhil Goyal 		struct rte_eth_ip_reassembly_params *conf);
5167a75ab6e5SAkhil Goyal 
5168a75ab6e5SAkhil Goyal /**
5169a75ab6e5SAkhil Goyal  * @warning
5170a75ab6e5SAkhil Goyal  * @b EXPERIMENTAL: this API may change without prior notice
5171a75ab6e5SAkhil Goyal  *
5172a75ab6e5SAkhil Goyal  * Set IP reassembly configuration parameters if the PMD supports IP reassembly
5173a75ab6e5SAkhil Goyal  * offload. User should first call rte_eth_ip_reassembly_capability_get() to
5174a75ab6e5SAkhil Goyal  * check the maximum values supported by the PMD before setting the
5175a75ab6e5SAkhil Goyal  * configuration. The use of this API is mandatory to enable this feature and
5176a75ab6e5SAkhil Goyal  * should be called before rte_eth_dev_start().
5177a75ab6e5SAkhil Goyal  *
51783c059b2cSAkhil Goyal  * In datapath, PMD cannot guarantee that IP reassembly is always successful.
51793c059b2cSAkhil Goyal  * Hence, PMD shall register mbuf dynamic field and dynamic flag using
51803c059b2cSAkhil Goyal  * rte_eth_ip_reassembly_dynfield_register() to denote incomplete IP reassembly.
51813c059b2cSAkhil Goyal  * If dynfield is not successfully registered, error will be returned and
51823c059b2cSAkhil Goyal  * IP reassembly offload cannot be used.
51833c059b2cSAkhil Goyal  *
5184a75ab6e5SAkhil Goyal  * @param port_id
5185a75ab6e5SAkhil Goyal  *   The port identifier of the device.
5186a75ab6e5SAkhil Goyal  * @param conf
5187a75ab6e5SAkhil Goyal  *   A pointer to rte_eth_ip_reassembly_params structure.
5188a75ab6e5SAkhil Goyal  * @return
5189a75ab6e5SAkhil Goyal  *   - (-ENOTSUP) if offload configuration is not supported by device.
5190a75ab6e5SAkhil Goyal  *   - (-ENODEV) if *port_id* invalid.
5191a75ab6e5SAkhil Goyal  *   - (-EIO) if device is removed.
5192a75ab6e5SAkhil Goyal  *   - (-EINVAL) if device is not configured or if device is already started or
51933c059b2cSAkhil Goyal  *               if *conf* passed is NULL or if mbuf dynfield is not registered
51943c059b2cSAkhil Goyal  *               successfully by the PMD.
5195a75ab6e5SAkhil Goyal  *   - (0) on success.
5196a75ab6e5SAkhil Goyal  */
5197a75ab6e5SAkhil Goyal __rte_experimental
5198a75ab6e5SAkhil Goyal int rte_eth_ip_reassembly_conf_set(uint16_t port_id,
5199a75ab6e5SAkhil Goyal 		const struct rte_eth_ip_reassembly_params *conf);
5200a75ab6e5SAkhil Goyal 
52013c059b2cSAkhil Goyal /**
52023c059b2cSAkhil Goyal  * In case of IP reassembly offload failure, packet will be updated with
52033c059b2cSAkhil Goyal  * dynamic flag - RTE_MBUF_DYNFLAG_IP_REASSEMBLY_INCOMPLETE_NAME and packets
52043c059b2cSAkhil Goyal  * will be returned without alteration.
52053c059b2cSAkhil Goyal  * The application can retrieve the attached fragments using mbuf dynamic field
52063c059b2cSAkhil Goyal  * RTE_MBUF_DYNFIELD_IP_REASSEMBLY_NAME.
52073c059b2cSAkhil Goyal  */
52083c059b2cSAkhil Goyal typedef struct {
52093c059b2cSAkhil Goyal 	/**
52103c059b2cSAkhil Goyal 	 * Next fragment packet. Application should fetch dynamic field of
52113c059b2cSAkhil Goyal 	 * each fragment until a NULL is received and nb_frags is 0.
52123c059b2cSAkhil Goyal 	 */
52133c059b2cSAkhil Goyal 	struct rte_mbuf *next_frag;
52143c059b2cSAkhil Goyal 	/** Time spent(in ms) by HW in waiting for further fragments. */
52153c059b2cSAkhil Goyal 	uint16_t time_spent;
52163c059b2cSAkhil Goyal 	/** Number of more fragments attached in mbuf dynamic fields. */
52173c059b2cSAkhil Goyal 	uint16_t nb_frags;
52183c059b2cSAkhil Goyal } rte_eth_ip_reassembly_dynfield_t;
52193c059b2cSAkhil Goyal 
5220edcf22c6SMin Hu (Connor) /**
5221edcf22c6SMin Hu (Connor)  * @warning
5222edcf22c6SMin Hu (Connor)  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
5223edcf22c6SMin Hu (Connor)  *
5224edcf22c6SMin Hu (Connor)  * Dump private info from device to a file. Provided data and the order depends
5225edcf22c6SMin Hu (Connor)  * on the PMD.
5226edcf22c6SMin Hu (Connor)  *
5227edcf22c6SMin Hu (Connor)  * @param port_id
5228edcf22c6SMin Hu (Connor)  *   The port identifier of the Ethernet device.
5229edcf22c6SMin Hu (Connor)  * @param file
5230edcf22c6SMin Hu (Connor)  *   A pointer to a file for output.
5231edcf22c6SMin Hu (Connor)  * @return
5232edcf22c6SMin Hu (Connor)  *   - (0) on success.
5233edcf22c6SMin Hu (Connor)  *   - (-ENODEV) if *port_id* is invalid.
5234edcf22c6SMin Hu (Connor)  *   - (-EINVAL) if null file.
5235edcf22c6SMin Hu (Connor)  *   - (-ENOTSUP) if the device does not support this function.
5236edcf22c6SMin Hu (Connor)  *   - (-EIO) if device is removed.
5237edcf22c6SMin Hu (Connor)  */
5238edcf22c6SMin Hu (Connor) __rte_experimental
5239edcf22c6SMin Hu (Connor) int rte_eth_dev_priv_dump(uint16_t port_id, FILE *file);
5240a75ab6e5SAkhil Goyal 
524199a2dd95SBruce Richardson #include <rte_ethdev_core.h>
524299a2dd95SBruce Richardson 
524399a2dd95SBruce Richardson /**
52447a093523SKonstantin Ananyev  * @internal
52457a093523SKonstantin Ananyev  * Helper routine for rte_eth_rx_burst().
52467a093523SKonstantin Ananyev  * Should be called at exit from PMD's rte_eth_rx_bulk implementation.
52477a093523SKonstantin Ananyev  * Does necessary post-processing - invokes Rx callbacks if any, etc.
52487a093523SKonstantin Ananyev  *
52497a093523SKonstantin Ananyev  * @param port_id
52507a093523SKonstantin Ananyev  *  The port identifier of the Ethernet device.
52517a093523SKonstantin Ananyev  * @param queue_id
52527a093523SKonstantin Ananyev  *  The index of the receive queue from which to retrieve input packets.
52537a093523SKonstantin Ananyev  * @param rx_pkts
52547a093523SKonstantin Ananyev  *   The address of an array of pointers to *rte_mbuf* structures that
52557a093523SKonstantin Ananyev  *   have been retrieved from the device.
52567a093523SKonstantin Ananyev  * @param nb_rx
52577a093523SKonstantin Ananyev  *   The number of packets that were retrieved from the device.
52587a093523SKonstantin Ananyev  * @param nb_pkts
52597a093523SKonstantin Ananyev  *   The number of elements in @p rx_pkts array.
52607a093523SKonstantin Ananyev  * @param opaque
52617a093523SKonstantin Ananyev  *   Opaque pointer of Rx queue callback related data.
52627a093523SKonstantin Ananyev  *
52637a093523SKonstantin Ananyev  * @return
52647a093523SKonstantin Ananyev  *  The number of packets effectively supplied to the @p rx_pkts array.
52657a093523SKonstantin Ananyev  */
52667a093523SKonstantin Ananyev uint16_t rte_eth_call_rx_callbacks(uint16_t port_id, uint16_t queue_id,
52677a093523SKonstantin Ananyev 		struct rte_mbuf **rx_pkts, uint16_t nb_rx, uint16_t nb_pkts,
52687a093523SKonstantin Ananyev 		void *opaque);
52697a093523SKonstantin Ananyev 
52707a093523SKonstantin Ananyev /**
527199a2dd95SBruce Richardson  *
527299a2dd95SBruce Richardson  * Retrieve a burst of input packets from a receive queue of an Ethernet
527399a2dd95SBruce Richardson  * device. The retrieved packets are stored in *rte_mbuf* structures whose
527499a2dd95SBruce Richardson  * pointers are supplied in the *rx_pkts* array.
527599a2dd95SBruce Richardson  *
527609fd4227SAndrew Rybchenko  * The rte_eth_rx_burst() function loops, parsing the Rx ring of the
527709fd4227SAndrew Rybchenko  * receive queue, up to *nb_pkts* packets, and for each completed Rx
527899a2dd95SBruce Richardson  * descriptor in the ring, it performs the following operations:
527999a2dd95SBruce Richardson  *
528099a2dd95SBruce Richardson  * - Initialize the *rte_mbuf* data structure associated with the
528109fd4227SAndrew Rybchenko  *   Rx descriptor according to the information provided by the NIC into
528209fd4227SAndrew Rybchenko  *   that Rx descriptor.
528399a2dd95SBruce Richardson  *
528499a2dd95SBruce Richardson  * - Store the *rte_mbuf* data structure into the next entry of the
528599a2dd95SBruce Richardson  *   *rx_pkts* array.
528699a2dd95SBruce Richardson  *
528709fd4227SAndrew Rybchenko  * - Replenish the Rx descriptor with a new *rte_mbuf* buffer
528899a2dd95SBruce Richardson  *   allocated from the memory pool associated with the receive queue at
528999a2dd95SBruce Richardson  *   initialization time.
529099a2dd95SBruce Richardson  *
529199a2dd95SBruce Richardson  * When retrieving an input packet that was scattered by the controller
529299a2dd95SBruce Richardson  * into multiple receive descriptors, the rte_eth_rx_burst() function
529399a2dd95SBruce Richardson  * appends the associated *rte_mbuf* buffers to the first buffer of the
529499a2dd95SBruce Richardson  * packet.
529599a2dd95SBruce Richardson  *
529699a2dd95SBruce Richardson  * The rte_eth_rx_burst() function returns the number of packets
529799a2dd95SBruce Richardson  * actually retrieved, which is the number of *rte_mbuf* data structures
529899a2dd95SBruce Richardson  * effectively supplied into the *rx_pkts* array.
529909fd4227SAndrew Rybchenko  * A return value equal to *nb_pkts* indicates that the Rx queue contained
530099a2dd95SBruce Richardson  * at least *rx_pkts* packets, and this is likely to signify that other
530199a2dd95SBruce Richardson  * received packets remain in the input queue. Applications implementing
530299a2dd95SBruce Richardson  * a "retrieve as much received packets as possible" policy can check this
530399a2dd95SBruce Richardson  * specific case and keep invoking the rte_eth_rx_burst() function until
530499a2dd95SBruce Richardson  * a value less than *nb_pkts* is returned.
530599a2dd95SBruce Richardson  *
530699a2dd95SBruce Richardson  * This receive method has the following advantages:
530799a2dd95SBruce Richardson  *
530899a2dd95SBruce Richardson  * - It allows a run-to-completion network stack engine to retrieve and
530999a2dd95SBruce Richardson  *   to immediately process received packets in a fast burst-oriented
531099a2dd95SBruce Richardson  *   approach, avoiding the overhead of unnecessary intermediate packet
531199a2dd95SBruce Richardson  *   queue/dequeue operations.
531299a2dd95SBruce Richardson  *
531399a2dd95SBruce Richardson  * - Conversely, it also allows an asynchronous-oriented processing
531499a2dd95SBruce Richardson  *   method to retrieve bursts of received packets and to immediately
531599a2dd95SBruce Richardson  *   queue them for further parallel processing by another logical core,
531699a2dd95SBruce Richardson  *   for instance. However, instead of having received packets being
531799a2dd95SBruce Richardson  *   individually queued by the driver, this approach allows the caller
531899a2dd95SBruce Richardson  *   of the rte_eth_rx_burst() function to queue a burst of retrieved
531999a2dd95SBruce Richardson  *   packets at a time and therefore dramatically reduce the cost of
532099a2dd95SBruce Richardson  *   enqueue/dequeue operations per packet.
532199a2dd95SBruce Richardson  *
532299a2dd95SBruce Richardson  * - It allows the rte_eth_rx_burst() function of the driver to take
532399a2dd95SBruce Richardson  *   advantage of burst-oriented hardware features (CPU cache,
532499a2dd95SBruce Richardson  *   prefetch instructions, and so on) to minimize the number of CPU
532599a2dd95SBruce Richardson  *   cycles per packet.
532699a2dd95SBruce Richardson  *
532799a2dd95SBruce Richardson  * To summarize, the proposed receive API enables many
532899a2dd95SBruce Richardson  * burst-oriented optimizations in both synchronous and asynchronous
532999a2dd95SBruce Richardson  * packet processing environments with no overhead in both cases.
533099a2dd95SBruce Richardson  *
533199a2dd95SBruce Richardson  * @note
533299a2dd95SBruce Richardson  *   Some drivers using vector instructions require that *nb_pkts* is
533399a2dd95SBruce Richardson  *   divisible by 4 or 8, depending on the driver implementation.
533499a2dd95SBruce Richardson  *
533599a2dd95SBruce Richardson  * The rte_eth_rx_burst() function does not provide any error
533699a2dd95SBruce Richardson  * notification to avoid the corresponding overhead. As a hint, the
533799a2dd95SBruce Richardson  * upper-level application might check the status of the device link once
533899a2dd95SBruce Richardson  * being systematically returned a 0 value for a given number of tries.
533999a2dd95SBruce Richardson  *
534099a2dd95SBruce Richardson  * @param port_id
534199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
534299a2dd95SBruce Richardson  * @param queue_id
534399a2dd95SBruce Richardson  *   The index of the receive queue from which to retrieve input packets.
534499a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
534599a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
534699a2dd95SBruce Richardson  * @param rx_pkts
534799a2dd95SBruce Richardson  *   The address of an array of pointers to *rte_mbuf* structures that
534899a2dd95SBruce Richardson  *   must be large enough to store *nb_pkts* pointers in it.
534999a2dd95SBruce Richardson  * @param nb_pkts
535099a2dd95SBruce Richardson  *   The maximum number of packets to retrieve.
535199a2dd95SBruce Richardson  *   The value must be divisible by 8 in order to work with any driver.
535299a2dd95SBruce Richardson  * @return
535399a2dd95SBruce Richardson  *   The number of packets actually retrieved, which is the number
535499a2dd95SBruce Richardson  *   of pointers to *rte_mbuf* structures effectively supplied to the
535599a2dd95SBruce Richardson  *   *rx_pkts* array.
535699a2dd95SBruce Richardson  */
535799a2dd95SBruce Richardson static inline uint16_t
535899a2dd95SBruce Richardson rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id,
535999a2dd95SBruce Richardson 		 struct rte_mbuf **rx_pkts, const uint16_t nb_pkts)
536099a2dd95SBruce Richardson {
536199a2dd95SBruce Richardson 	uint16_t nb_rx;
53627a093523SKonstantin Ananyev 	struct rte_eth_fp_ops *p;
53637a093523SKonstantin Ananyev 	void *qd;
536499a2dd95SBruce Richardson 
536599a2dd95SBruce Richardson #ifdef RTE_ETHDEV_DEBUG_RX
53667a093523SKonstantin Ananyev 	if (port_id >= RTE_MAX_ETHPORTS ||
53677a093523SKonstantin Ananyev 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
53687a093523SKonstantin Ananyev 		RTE_ETHDEV_LOG(ERR,
53697a093523SKonstantin Ananyev 			"Invalid port_id=%u or queue_id=%u\n",
53707a093523SKonstantin Ananyev 			port_id, queue_id);
537199a2dd95SBruce Richardson 		return 0;
537299a2dd95SBruce Richardson 	}
537399a2dd95SBruce Richardson #endif
53747a093523SKonstantin Ananyev 
53757a093523SKonstantin Ananyev 	/* fetch pointer to queue data */
53767a093523SKonstantin Ananyev 	p = &rte_eth_fp_ops[port_id];
53777a093523SKonstantin Ananyev 	qd = p->rxq.data[queue_id];
53787a093523SKonstantin Ananyev 
53797a093523SKonstantin Ananyev #ifdef RTE_ETHDEV_DEBUG_RX
53807a093523SKonstantin Ananyev 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
53817a093523SKonstantin Ananyev 
53827a093523SKonstantin Ananyev 	if (qd == NULL) {
538309fd4227SAndrew Rybchenko 		RTE_ETHDEV_LOG(ERR, "Invalid Rx queue_id=%u for port_id=%u\n",
53847a093523SKonstantin Ananyev 			queue_id, port_id);
53857a093523SKonstantin Ananyev 		return 0;
53867a093523SKonstantin Ananyev 	}
53877a093523SKonstantin Ananyev #endif
53887a093523SKonstantin Ananyev 
53897a093523SKonstantin Ananyev 	nb_rx = p->rx_pkt_burst(qd, rx_pkts, nb_pkts);
539099a2dd95SBruce Richardson 
539199a2dd95SBruce Richardson #ifdef RTE_ETHDEV_RXTX_CALLBACKS
53927a093523SKonstantin Ananyev 	{
53937a093523SKonstantin Ananyev 		void *cb;
539499a2dd95SBruce Richardson 
539599a2dd95SBruce Richardson 		/* __ATOMIC_RELEASE memory order was used when the
539699a2dd95SBruce Richardson 		 * call back was inserted into the list.
539799a2dd95SBruce Richardson 		 * Since there is a clear dependency between loading
539899a2dd95SBruce Richardson 		 * cb and cb->fn/cb->next, __ATOMIC_ACQUIRE memory order is
539999a2dd95SBruce Richardson 		 * not required.
540099a2dd95SBruce Richardson 		 */
54017a093523SKonstantin Ananyev 		cb = __atomic_load_n((void **)&p->rxq.clbk[queue_id],
540299a2dd95SBruce Richardson 				__ATOMIC_RELAXED);
54037a093523SKonstantin Ananyev 		if (unlikely(cb != NULL))
54047a093523SKonstantin Ananyev 			nb_rx = rte_eth_call_rx_callbacks(port_id, queue_id,
54057a093523SKonstantin Ananyev 					rx_pkts, nb_rx, nb_pkts, cb);
540699a2dd95SBruce Richardson 	}
540799a2dd95SBruce Richardson #endif
540899a2dd95SBruce Richardson 
540999a2dd95SBruce Richardson 	rte_ethdev_trace_rx_burst(port_id, queue_id, (void **)rx_pkts, nb_rx);
541099a2dd95SBruce Richardson 	return nb_rx;
541199a2dd95SBruce Richardson }
541299a2dd95SBruce Richardson 
541399a2dd95SBruce Richardson /**
541409fd4227SAndrew Rybchenko  * Get the number of used descriptors of a Rx queue
541599a2dd95SBruce Richardson  *
541699a2dd95SBruce Richardson  * @param port_id
541799a2dd95SBruce Richardson  *  The port identifier of the Ethernet device.
541899a2dd95SBruce Richardson  * @param queue_id
54195906be5aSAndrew Rybchenko  *  The queue ID on the specific port.
542099a2dd95SBruce Richardson  * @return
542199a2dd95SBruce Richardson  *  The number of used descriptors in the specific queue, or:
542299a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
542399a2dd95SBruce Richardson  *     (-EINVAL) if *queue_id* is invalid
542499a2dd95SBruce Richardson  *     (-ENOTSUP) if the device does not support this function
542599a2dd95SBruce Richardson  */
542699a2dd95SBruce Richardson static inline int
542799a2dd95SBruce Richardson rte_eth_rx_queue_count(uint16_t port_id, uint16_t queue_id)
542899a2dd95SBruce Richardson {
54297a093523SKonstantin Ananyev 	struct rte_eth_fp_ops *p;
54307a093523SKonstantin Ananyev 	void *qd;
54317a093523SKonstantin Ananyev 
54327a093523SKonstantin Ananyev 	if (port_id >= RTE_MAX_ETHPORTS ||
54337a093523SKonstantin Ananyev 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
54347a093523SKonstantin Ananyev 		RTE_ETHDEV_LOG(ERR,
54357a093523SKonstantin Ananyev 			"Invalid port_id=%u or queue_id=%u\n",
54367a093523SKonstantin Ananyev 			port_id, queue_id);
54377a093523SKonstantin Ananyev 		return -EINVAL;
54387a093523SKonstantin Ananyev 	}
54397a093523SKonstantin Ananyev 
54407a093523SKonstantin Ananyev 	/* fetch pointer to queue data */
54417a093523SKonstantin Ananyev 	p = &rte_eth_fp_ops[port_id];
54427a093523SKonstantin Ananyev 	qd = p->rxq.data[queue_id];
544399a2dd95SBruce Richardson 
544499a2dd95SBruce Richardson 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
54458f1d23ecSDavid Marchand 	if (*p->rx_queue_count == NULL)
54468f1d23ecSDavid Marchand 		return -ENOTSUP;
54477a093523SKonstantin Ananyev 	if (qd == NULL)
544899a2dd95SBruce Richardson 		return -EINVAL;
544999a2dd95SBruce Richardson 
54507a093523SKonstantin Ananyev 	return (int)(*p->rx_queue_count)(qd);
545199a2dd95SBruce Richardson }
545299a2dd95SBruce Richardson 
54530ce56b05SThomas Monjalon /**@{@name Rx hardware descriptor states
54540ce56b05SThomas Monjalon  * @see rte_eth_rx_descriptor_status
54550ce56b05SThomas Monjalon  */
545699a2dd95SBruce Richardson #define RTE_ETH_RX_DESC_AVAIL    0 /**< Desc available for hw. */
545799a2dd95SBruce Richardson #define RTE_ETH_RX_DESC_DONE     1 /**< Desc done, filled by hw. */
545899a2dd95SBruce Richardson #define RTE_ETH_RX_DESC_UNAVAIL  2 /**< Desc used by driver or hw. */
54590ce56b05SThomas Monjalon /**@}*/
546099a2dd95SBruce Richardson 
546199a2dd95SBruce Richardson /**
546299a2dd95SBruce Richardson  * Check the status of a Rx descriptor in the queue
546399a2dd95SBruce Richardson  *
546499a2dd95SBruce Richardson  * It should be called in a similar context than the Rx function:
546599a2dd95SBruce Richardson  * - on a dataplane core
546699a2dd95SBruce Richardson  * - not concurrently on the same queue
546799a2dd95SBruce Richardson  *
546899a2dd95SBruce Richardson  * Since it's a dataplane function, no check is performed on port_id and
546999a2dd95SBruce Richardson  * queue_id. The caller must therefore ensure that the port is enabled
547099a2dd95SBruce Richardson  * and the queue is configured and running.
547199a2dd95SBruce Richardson  *
547299a2dd95SBruce Richardson  * Note: accessing to a random descriptor in the ring may trigger cache
547399a2dd95SBruce Richardson  * misses and have a performance impact.
547499a2dd95SBruce Richardson  *
547599a2dd95SBruce Richardson  * @param port_id
547699a2dd95SBruce Richardson  *  A valid port identifier of the Ethernet device which.
547799a2dd95SBruce Richardson  * @param queue_id
547899a2dd95SBruce Richardson  *  A valid Rx queue identifier on this port.
547999a2dd95SBruce Richardson  * @param offset
548099a2dd95SBruce Richardson  *  The offset of the descriptor starting from tail (0 is the next
548199a2dd95SBruce Richardson  *  packet to be received by the driver).
548299a2dd95SBruce Richardson  *
548399a2dd95SBruce Richardson  * @return
548499a2dd95SBruce Richardson  *  - (RTE_ETH_RX_DESC_AVAIL): Descriptor is available for the hardware to
548599a2dd95SBruce Richardson  *    receive a packet.
548699a2dd95SBruce Richardson  *  - (RTE_ETH_RX_DESC_DONE): Descriptor is done, it is filled by hw, but
548799a2dd95SBruce Richardson  *    not yet processed by the driver (i.e. in the receive queue).
548899a2dd95SBruce Richardson  *  - (RTE_ETH_RX_DESC_UNAVAIL): Descriptor is unavailable, either hold by
548999a2dd95SBruce Richardson  *    the driver and not yet returned to hw, or reserved by the hw.
549099a2dd95SBruce Richardson  *  - (-EINVAL) bad descriptor offset.
549199a2dd95SBruce Richardson  *  - (-ENOTSUP) if the device does not support this function.
549299a2dd95SBruce Richardson  *  - (-ENODEV) bad port or queue (only if compiled with debug).
549399a2dd95SBruce Richardson  */
549499a2dd95SBruce Richardson static inline int
549599a2dd95SBruce Richardson rte_eth_rx_descriptor_status(uint16_t port_id, uint16_t queue_id,
549699a2dd95SBruce Richardson 	uint16_t offset)
549799a2dd95SBruce Richardson {
54987a093523SKonstantin Ananyev 	struct rte_eth_fp_ops *p;
54997a093523SKonstantin Ananyev 	void *qd;
55007a093523SKonstantin Ananyev 
55017a093523SKonstantin Ananyev #ifdef RTE_ETHDEV_DEBUG_RX
55027a093523SKonstantin Ananyev 	if (port_id >= RTE_MAX_ETHPORTS ||
55037a093523SKonstantin Ananyev 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
55047a093523SKonstantin Ananyev 		RTE_ETHDEV_LOG(ERR,
55057a093523SKonstantin Ananyev 			"Invalid port_id=%u or queue_id=%u\n",
55067a093523SKonstantin Ananyev 			port_id, queue_id);
55077a093523SKonstantin Ananyev 		return -EINVAL;
55087a093523SKonstantin Ananyev 	}
55097a093523SKonstantin Ananyev #endif
55107a093523SKonstantin Ananyev 
55117a093523SKonstantin Ananyev 	/* fetch pointer to queue data */
55127a093523SKonstantin Ananyev 	p = &rte_eth_fp_ops[port_id];
55137a093523SKonstantin Ananyev 	qd = p->rxq.data[queue_id];
551499a2dd95SBruce Richardson 
551599a2dd95SBruce Richardson #ifdef RTE_ETHDEV_DEBUG_RX
551699a2dd95SBruce Richardson 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
55177a093523SKonstantin Ananyev 	if (qd == NULL)
551899a2dd95SBruce Richardson 		return -ENODEV;
551999a2dd95SBruce Richardson #endif
55208f1d23ecSDavid Marchand 	if (*p->rx_descriptor_status == NULL)
55218f1d23ecSDavid Marchand 		return -ENOTSUP;
55227a093523SKonstantin Ananyev 	return (*p->rx_descriptor_status)(qd, offset);
552399a2dd95SBruce Richardson }
552499a2dd95SBruce Richardson 
55250ce56b05SThomas Monjalon /**@{@name Tx hardware descriptor states
55260ce56b05SThomas Monjalon  * @see rte_eth_tx_descriptor_status
55270ce56b05SThomas Monjalon  */
552899a2dd95SBruce Richardson #define RTE_ETH_TX_DESC_FULL    0 /**< Desc filled for hw, waiting xmit. */
552999a2dd95SBruce Richardson #define RTE_ETH_TX_DESC_DONE    1 /**< Desc done, packet is transmitted. */
553099a2dd95SBruce Richardson #define RTE_ETH_TX_DESC_UNAVAIL 2 /**< Desc used by driver or hw. */
55310ce56b05SThomas Monjalon /**@}*/
553299a2dd95SBruce Richardson 
553399a2dd95SBruce Richardson /**
553499a2dd95SBruce Richardson  * Check the status of a Tx descriptor in the queue.
553599a2dd95SBruce Richardson  *
553699a2dd95SBruce Richardson  * It should be called in a similar context than the Tx function:
553799a2dd95SBruce Richardson  * - on a dataplane core
553899a2dd95SBruce Richardson  * - not concurrently on the same queue
553999a2dd95SBruce Richardson  *
554099a2dd95SBruce Richardson  * Since it's a dataplane function, no check is performed on port_id and
554199a2dd95SBruce Richardson  * queue_id. The caller must therefore ensure that the port is enabled
554299a2dd95SBruce Richardson  * and the queue is configured and running.
554399a2dd95SBruce Richardson  *
554499a2dd95SBruce Richardson  * Note: accessing to a random descriptor in the ring may trigger cache
554599a2dd95SBruce Richardson  * misses and have a performance impact.
554699a2dd95SBruce Richardson  *
554799a2dd95SBruce Richardson  * @param port_id
554899a2dd95SBruce Richardson  *  A valid port identifier of the Ethernet device which.
554999a2dd95SBruce Richardson  * @param queue_id
555099a2dd95SBruce Richardson  *  A valid Tx queue identifier on this port.
555199a2dd95SBruce Richardson  * @param offset
555299a2dd95SBruce Richardson  *  The offset of the descriptor starting from tail (0 is the place where
555399a2dd95SBruce Richardson  *  the next packet will be send).
555499a2dd95SBruce Richardson  *
555599a2dd95SBruce Richardson  * @return
555699a2dd95SBruce Richardson  *  - (RTE_ETH_TX_DESC_FULL) Descriptor is being processed by the hw, i.e.
555799a2dd95SBruce Richardson  *    in the transmit queue.
555899a2dd95SBruce Richardson  *  - (RTE_ETH_TX_DESC_DONE) Hardware is done with this descriptor, it can
555999a2dd95SBruce Richardson  *    be reused by the driver.
556099a2dd95SBruce Richardson  *  - (RTE_ETH_TX_DESC_UNAVAIL): Descriptor is unavailable, reserved by the
556199a2dd95SBruce Richardson  *    driver or the hardware.
556299a2dd95SBruce Richardson  *  - (-EINVAL) bad descriptor offset.
556399a2dd95SBruce Richardson  *  - (-ENOTSUP) if the device does not support this function.
556499a2dd95SBruce Richardson  *  - (-ENODEV) bad port or queue (only if compiled with debug).
556599a2dd95SBruce Richardson  */
556699a2dd95SBruce Richardson static inline int rte_eth_tx_descriptor_status(uint16_t port_id,
556799a2dd95SBruce Richardson 	uint16_t queue_id, uint16_t offset)
556899a2dd95SBruce Richardson {
55697a093523SKonstantin Ananyev 	struct rte_eth_fp_ops *p;
55707a093523SKonstantin Ananyev 	void *qd;
55717a093523SKonstantin Ananyev 
55727a093523SKonstantin Ananyev #ifdef RTE_ETHDEV_DEBUG_TX
55737a093523SKonstantin Ananyev 	if (port_id >= RTE_MAX_ETHPORTS ||
55747a093523SKonstantin Ananyev 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
55757a093523SKonstantin Ananyev 		RTE_ETHDEV_LOG(ERR,
55767a093523SKonstantin Ananyev 			"Invalid port_id=%u or queue_id=%u\n",
55777a093523SKonstantin Ananyev 			port_id, queue_id);
55787a093523SKonstantin Ananyev 		return -EINVAL;
55797a093523SKonstantin Ananyev 	}
55807a093523SKonstantin Ananyev #endif
55817a093523SKonstantin Ananyev 
55827a093523SKonstantin Ananyev 	/* fetch pointer to queue data */
55837a093523SKonstantin Ananyev 	p = &rte_eth_fp_ops[port_id];
55847a093523SKonstantin Ananyev 	qd = p->txq.data[queue_id];
558599a2dd95SBruce Richardson 
558699a2dd95SBruce Richardson #ifdef RTE_ETHDEV_DEBUG_TX
558799a2dd95SBruce Richardson 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
55887a093523SKonstantin Ananyev 	if (qd == NULL)
558999a2dd95SBruce Richardson 		return -ENODEV;
559099a2dd95SBruce Richardson #endif
55918f1d23ecSDavid Marchand 	if (*p->tx_descriptor_status == NULL)
55928f1d23ecSDavid Marchand 		return -ENOTSUP;
55937a093523SKonstantin Ananyev 	return (*p->tx_descriptor_status)(qd, offset);
559499a2dd95SBruce Richardson }
559599a2dd95SBruce Richardson 
559699a2dd95SBruce Richardson /**
55977a093523SKonstantin Ananyev  * @internal
55987a093523SKonstantin Ananyev  * Helper routine for rte_eth_tx_burst().
55997a093523SKonstantin Ananyev  * Should be called before entry PMD's rte_eth_tx_bulk implementation.
56007a093523SKonstantin Ananyev  * Does necessary pre-processing - invokes Tx callbacks if any, etc.
56017a093523SKonstantin Ananyev  *
56027a093523SKonstantin Ananyev  * @param port_id
56037a093523SKonstantin Ananyev  *   The port identifier of the Ethernet device.
56047a093523SKonstantin Ananyev  * @param queue_id
56057a093523SKonstantin Ananyev  *   The index of the transmit queue through which output packets must be
56067a093523SKonstantin Ananyev  *   sent.
56077a093523SKonstantin Ananyev  * @param tx_pkts
56087a093523SKonstantin Ananyev  *   The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
56097a093523SKonstantin Ananyev  *   which contain the output packets.
56107a093523SKonstantin Ananyev  * @param nb_pkts
56117a093523SKonstantin Ananyev  *   The maximum number of packets to transmit.
56127a093523SKonstantin Ananyev  * @return
56137a093523SKonstantin Ananyev  *   The number of output packets to transmit.
56147a093523SKonstantin Ananyev  */
56157a093523SKonstantin Ananyev uint16_t rte_eth_call_tx_callbacks(uint16_t port_id, uint16_t queue_id,
56167a093523SKonstantin Ananyev 	struct rte_mbuf **tx_pkts, uint16_t nb_pkts, void *opaque);
56177a093523SKonstantin Ananyev 
56187a093523SKonstantin Ananyev /**
561999a2dd95SBruce Richardson  * Send a burst of output packets on a transmit queue of an Ethernet device.
562099a2dd95SBruce Richardson  *
562199a2dd95SBruce Richardson  * The rte_eth_tx_burst() function is invoked to transmit output packets
562299a2dd95SBruce Richardson  * on the output queue *queue_id* of the Ethernet device designated by its
562399a2dd95SBruce Richardson  * *port_id*.
562499a2dd95SBruce Richardson  * The *nb_pkts* parameter is the number of packets to send which are
562599a2dd95SBruce Richardson  * supplied in the *tx_pkts* array of *rte_mbuf* structures, each of them
562699a2dd95SBruce Richardson  * allocated from a pool created with rte_pktmbuf_pool_create().
562799a2dd95SBruce Richardson  * The rte_eth_tx_burst() function loops, sending *nb_pkts* packets,
562809fd4227SAndrew Rybchenko  * up to the number of transmit descriptors available in the Tx ring of the
562999a2dd95SBruce Richardson  * transmit queue.
563099a2dd95SBruce Richardson  * For each packet to send, the rte_eth_tx_burst() function performs
563199a2dd95SBruce Richardson  * the following operations:
563299a2dd95SBruce Richardson  *
563399a2dd95SBruce Richardson  * - Pick up the next available descriptor in the transmit ring.
563499a2dd95SBruce Richardson  *
563599a2dd95SBruce Richardson  * - Free the network buffer previously sent with that descriptor, if any.
563699a2dd95SBruce Richardson  *
563799a2dd95SBruce Richardson  * - Initialize the transmit descriptor with the information provided
563899a2dd95SBruce Richardson  *   in the *rte_mbuf data structure.
563999a2dd95SBruce Richardson  *
564099a2dd95SBruce Richardson  * In the case of a segmented packet composed of a list of *rte_mbuf* buffers,
564199a2dd95SBruce Richardson  * the rte_eth_tx_burst() function uses several transmit descriptors
564299a2dd95SBruce Richardson  * of the ring.
564399a2dd95SBruce Richardson  *
564499a2dd95SBruce Richardson  * The rte_eth_tx_burst() function returns the number of packets it
564599a2dd95SBruce Richardson  * actually sent. A return value equal to *nb_pkts* means that all packets
564699a2dd95SBruce Richardson  * have been sent, and this is likely to signify that other output packets
564799a2dd95SBruce Richardson  * could be immediately transmitted again. Applications that implement a
564899a2dd95SBruce Richardson  * "send as many packets to transmit as possible" policy can check this
564999a2dd95SBruce Richardson  * specific case and keep invoking the rte_eth_tx_burst() function until
565099a2dd95SBruce Richardson  * a value less than *nb_pkts* is returned.
565199a2dd95SBruce Richardson  *
565299a2dd95SBruce Richardson  * It is the responsibility of the rte_eth_tx_burst() function to
565399a2dd95SBruce Richardson  * transparently free the memory buffers of packets previously sent.
565499a2dd95SBruce Richardson  * This feature is driven by the *tx_free_thresh* value supplied to the
565599a2dd95SBruce Richardson  * rte_eth_dev_configure() function at device configuration time.
565609fd4227SAndrew Rybchenko  * When the number of free Tx descriptors drops below this threshold, the
565799a2dd95SBruce Richardson  * rte_eth_tx_burst() function must [attempt to] free the *rte_mbuf*  buffers
565899a2dd95SBruce Richardson  * of those packets whose transmission was effectively completed.
565999a2dd95SBruce Richardson  *
5660295968d1SFerruh Yigit  * If the PMD is RTE_ETH_TX_OFFLOAD_MT_LOCKFREE capable, multiple threads can
566109fd4227SAndrew Rybchenko  * invoke this function concurrently on the same Tx queue without SW lock.
566299a2dd95SBruce Richardson  * @see rte_eth_dev_info_get, struct rte_eth_txconf::offloads
566399a2dd95SBruce Richardson  *
566499a2dd95SBruce Richardson  * @see rte_eth_tx_prepare to perform some prior checks or adjustments
566599a2dd95SBruce Richardson  * for offloads.
566699a2dd95SBruce Richardson  *
566799a2dd95SBruce Richardson  * @param port_id
566899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
566999a2dd95SBruce Richardson  * @param queue_id
567099a2dd95SBruce Richardson  *   The index of the transmit queue through which output packets must be
567199a2dd95SBruce Richardson  *   sent.
567299a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
567399a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
567499a2dd95SBruce Richardson  * @param tx_pkts
567599a2dd95SBruce Richardson  *   The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
567699a2dd95SBruce Richardson  *   which contain the output packets.
567799a2dd95SBruce Richardson  * @param nb_pkts
567899a2dd95SBruce Richardson  *   The maximum number of packets to transmit.
567999a2dd95SBruce Richardson  * @return
568099a2dd95SBruce Richardson  *   The number of output packets actually stored in transmit descriptors of
568199a2dd95SBruce Richardson  *   the transmit ring. The return value can be less than the value of the
568299a2dd95SBruce Richardson  *   *tx_pkts* parameter when the transmit ring is full or has been filled up.
568399a2dd95SBruce Richardson  */
568499a2dd95SBruce Richardson static inline uint16_t
568599a2dd95SBruce Richardson rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
568699a2dd95SBruce Richardson 		 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
568799a2dd95SBruce Richardson {
56887a093523SKonstantin Ananyev 	struct rte_eth_fp_ops *p;
56897a093523SKonstantin Ananyev 	void *qd;
56907a093523SKonstantin Ananyev 
56917a093523SKonstantin Ananyev #ifdef RTE_ETHDEV_DEBUG_TX
56927a093523SKonstantin Ananyev 	if (port_id >= RTE_MAX_ETHPORTS ||
56937a093523SKonstantin Ananyev 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
56947a093523SKonstantin Ananyev 		RTE_ETHDEV_LOG(ERR,
56957a093523SKonstantin Ananyev 			"Invalid port_id=%u or queue_id=%u\n",
56967a093523SKonstantin Ananyev 			port_id, queue_id);
56977a093523SKonstantin Ananyev 		return 0;
56987a093523SKonstantin Ananyev 	}
56997a093523SKonstantin Ananyev #endif
57007a093523SKonstantin Ananyev 
57017a093523SKonstantin Ananyev 	/* fetch pointer to queue data */
57027a093523SKonstantin Ananyev 	p = &rte_eth_fp_ops[port_id];
57037a093523SKonstantin Ananyev 	qd = p->txq.data[queue_id];
570499a2dd95SBruce Richardson 
570599a2dd95SBruce Richardson #ifdef RTE_ETHDEV_DEBUG_TX
570699a2dd95SBruce Richardson 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
570799a2dd95SBruce Richardson 
57087a093523SKonstantin Ananyev 	if (qd == NULL) {
570909fd4227SAndrew Rybchenko 		RTE_ETHDEV_LOG(ERR, "Invalid Tx queue_id=%u for port_id=%u\n",
57107a093523SKonstantin Ananyev 			queue_id, port_id);
571199a2dd95SBruce Richardson 		return 0;
571299a2dd95SBruce Richardson 	}
571399a2dd95SBruce Richardson #endif
571499a2dd95SBruce Richardson 
571599a2dd95SBruce Richardson #ifdef RTE_ETHDEV_RXTX_CALLBACKS
57167a093523SKonstantin Ananyev 	{
57177a093523SKonstantin Ananyev 		void *cb;
571899a2dd95SBruce Richardson 
571999a2dd95SBruce Richardson 		/* __ATOMIC_RELEASE memory order was used when the
572099a2dd95SBruce Richardson 		 * call back was inserted into the list.
572199a2dd95SBruce Richardson 		 * Since there is a clear dependency between loading
572299a2dd95SBruce Richardson 		 * cb and cb->fn/cb->next, __ATOMIC_ACQUIRE memory order is
572399a2dd95SBruce Richardson 		 * not required.
572499a2dd95SBruce Richardson 		 */
57257a093523SKonstantin Ananyev 		cb = __atomic_load_n((void **)&p->txq.clbk[queue_id],
572699a2dd95SBruce Richardson 				__ATOMIC_RELAXED);
57277a093523SKonstantin Ananyev 		if (unlikely(cb != NULL))
57287a093523SKonstantin Ananyev 			nb_pkts = rte_eth_call_tx_callbacks(port_id, queue_id,
57297a093523SKonstantin Ananyev 					tx_pkts, nb_pkts, cb);
573099a2dd95SBruce Richardson 	}
573199a2dd95SBruce Richardson #endif
573299a2dd95SBruce Richardson 
57337a093523SKonstantin Ananyev 	nb_pkts = p->tx_pkt_burst(qd, tx_pkts, nb_pkts);
57347a093523SKonstantin Ananyev 
57357a093523SKonstantin Ananyev 	rte_ethdev_trace_tx_burst(port_id, queue_id, (void **)tx_pkts, nb_pkts);
57367a093523SKonstantin Ananyev 	return nb_pkts;
573799a2dd95SBruce Richardson }
573899a2dd95SBruce Richardson 
573999a2dd95SBruce Richardson /**
574099a2dd95SBruce Richardson  * Process a burst of output packets on a transmit queue of an Ethernet device.
574199a2dd95SBruce Richardson  *
574299a2dd95SBruce Richardson  * The rte_eth_tx_prepare() function is invoked to prepare output packets to be
574399a2dd95SBruce Richardson  * transmitted on the output queue *queue_id* of the Ethernet device designated
574499a2dd95SBruce Richardson  * by its *port_id*.
574599a2dd95SBruce Richardson  * The *nb_pkts* parameter is the number of packets to be prepared which are
574699a2dd95SBruce Richardson  * supplied in the *tx_pkts* array of *rte_mbuf* structures, each of them
574799a2dd95SBruce Richardson  * allocated from a pool created with rte_pktmbuf_pool_create().
574899a2dd95SBruce Richardson  * For each packet to send, the rte_eth_tx_prepare() function performs
574999a2dd95SBruce Richardson  * the following operations:
575099a2dd95SBruce Richardson  *
575109fd4227SAndrew Rybchenko  * - Check if packet meets devices requirements for Tx offloads.
575299a2dd95SBruce Richardson  *
575399a2dd95SBruce Richardson  * - Check limitations about number of segments.
575499a2dd95SBruce Richardson  *
575599a2dd95SBruce Richardson  * - Check additional requirements when debug is enabled.
575699a2dd95SBruce Richardson  *
575709fd4227SAndrew Rybchenko  * - Update and/or reset required checksums when Tx offload is set for packet.
575899a2dd95SBruce Richardson  *
575999a2dd95SBruce Richardson  * Since this function can modify packet data, provided mbufs must be safely
576099a2dd95SBruce Richardson  * writable (e.g. modified data cannot be in shared segment).
576199a2dd95SBruce Richardson  *
576299a2dd95SBruce Richardson  * The rte_eth_tx_prepare() function returns the number of packets ready to be
576399a2dd95SBruce Richardson  * sent. A return value equal to *nb_pkts* means that all packets are valid and
576499a2dd95SBruce Richardson  * ready to be sent, otherwise stops processing on the first invalid packet and
576599a2dd95SBruce Richardson  * leaves the rest packets untouched.
576699a2dd95SBruce Richardson  *
576799a2dd95SBruce Richardson  * When this functionality is not implemented in the driver, all packets are
576899a2dd95SBruce Richardson  * are returned untouched.
576999a2dd95SBruce Richardson  *
577099a2dd95SBruce Richardson  * @param port_id
577199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
57725906be5aSAndrew Rybchenko  *   The value must be a valid port ID.
577399a2dd95SBruce Richardson  * @param queue_id
577499a2dd95SBruce Richardson  *   The index of the transmit queue through which output packets must be
577599a2dd95SBruce Richardson  *   sent.
577699a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
577799a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
577899a2dd95SBruce Richardson  * @param tx_pkts
577999a2dd95SBruce Richardson  *   The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
578099a2dd95SBruce Richardson  *   which contain the output packets.
578199a2dd95SBruce Richardson  * @param nb_pkts
578299a2dd95SBruce Richardson  *   The maximum number of packets to process.
578399a2dd95SBruce Richardson  * @return
578499a2dd95SBruce Richardson  *   The number of packets correct and ready to be sent. The return value can be
578599a2dd95SBruce Richardson  *   less than the value of the *tx_pkts* parameter when some packet doesn't
578699a2dd95SBruce Richardson  *   meet devices requirements with rte_errno set appropriately:
578799a2dd95SBruce Richardson  *   - EINVAL: offload flags are not correctly set
578899a2dd95SBruce Richardson  *   - ENOTSUP: the offload feature is not supported by the hardware
578999a2dd95SBruce Richardson  *   - ENODEV: if *port_id* is invalid (with debug enabled only)
579099a2dd95SBruce Richardson  *
579199a2dd95SBruce Richardson  */
579299a2dd95SBruce Richardson 
579399a2dd95SBruce Richardson #ifndef RTE_ETHDEV_TX_PREPARE_NOOP
579499a2dd95SBruce Richardson 
579599a2dd95SBruce Richardson static inline uint16_t
579699a2dd95SBruce Richardson rte_eth_tx_prepare(uint16_t port_id, uint16_t queue_id,
579799a2dd95SBruce Richardson 		struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
579899a2dd95SBruce Richardson {
57997a093523SKonstantin Ananyev 	struct rte_eth_fp_ops *p;
58007a093523SKonstantin Ananyev 	void *qd;
58017a093523SKonstantin Ananyev 
58027a093523SKonstantin Ananyev #ifdef RTE_ETHDEV_DEBUG_TX
58037a093523SKonstantin Ananyev 	if (port_id >= RTE_MAX_ETHPORTS ||
58047a093523SKonstantin Ananyev 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
58057a093523SKonstantin Ananyev 		RTE_ETHDEV_LOG(ERR,
58067a093523SKonstantin Ananyev 			"Invalid port_id=%u or queue_id=%u\n",
58077a093523SKonstantin Ananyev 			port_id, queue_id);
58087a093523SKonstantin Ananyev 		rte_errno = ENODEV;
58097a093523SKonstantin Ananyev 		return 0;
58107a093523SKonstantin Ananyev 	}
58117a093523SKonstantin Ananyev #endif
58127a093523SKonstantin Ananyev 
58137a093523SKonstantin Ananyev 	/* fetch pointer to queue data */
58147a093523SKonstantin Ananyev 	p = &rte_eth_fp_ops[port_id];
58157a093523SKonstantin Ananyev 	qd = p->txq.data[queue_id];
581699a2dd95SBruce Richardson 
581799a2dd95SBruce Richardson #ifdef RTE_ETHDEV_DEBUG_TX
581899a2dd95SBruce Richardson 	if (!rte_eth_dev_is_valid_port(port_id)) {
581909fd4227SAndrew Rybchenko 		RTE_ETHDEV_LOG(ERR, "Invalid Tx port_id=%u\n", port_id);
582099a2dd95SBruce Richardson 		rte_errno = ENODEV;
582199a2dd95SBruce Richardson 		return 0;
582299a2dd95SBruce Richardson 	}
58237a093523SKonstantin Ananyev 	if (qd == NULL) {
582409fd4227SAndrew Rybchenko 		RTE_ETHDEV_LOG(ERR, "Invalid Tx queue_id=%u for port_id=%u\n",
58257a093523SKonstantin Ananyev 			queue_id, port_id);
582699a2dd95SBruce Richardson 		rte_errno = EINVAL;
582799a2dd95SBruce Richardson 		return 0;
582899a2dd95SBruce Richardson 	}
582999a2dd95SBruce Richardson #endif
583099a2dd95SBruce Richardson 
58317a093523SKonstantin Ananyev 	if (!p->tx_pkt_prepare)
583299a2dd95SBruce Richardson 		return nb_pkts;
583399a2dd95SBruce Richardson 
58347a093523SKonstantin Ananyev 	return p->tx_pkt_prepare(qd, tx_pkts, nb_pkts);
583599a2dd95SBruce Richardson }
583699a2dd95SBruce Richardson 
583799a2dd95SBruce Richardson #else
583899a2dd95SBruce Richardson 
583999a2dd95SBruce Richardson /*
584099a2dd95SBruce Richardson  * Native NOOP operation for compilation targets which doesn't require any
584199a2dd95SBruce Richardson  * preparations steps, and functional NOOP may introduce unnecessary performance
584299a2dd95SBruce Richardson  * drop.
584399a2dd95SBruce Richardson  *
584499a2dd95SBruce Richardson  * Generally this is not a good idea to turn it on globally and didn't should
584599a2dd95SBruce Richardson  * be used if behavior of tx_preparation can change.
584699a2dd95SBruce Richardson  */
584799a2dd95SBruce Richardson 
584899a2dd95SBruce Richardson static inline uint16_t
584999a2dd95SBruce Richardson rte_eth_tx_prepare(__rte_unused uint16_t port_id,
585099a2dd95SBruce Richardson 		__rte_unused uint16_t queue_id,
585199a2dd95SBruce Richardson 		__rte_unused struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
585299a2dd95SBruce Richardson {
585399a2dd95SBruce Richardson 	return nb_pkts;
585499a2dd95SBruce Richardson }
585599a2dd95SBruce Richardson 
585699a2dd95SBruce Richardson #endif
585799a2dd95SBruce Richardson 
585899a2dd95SBruce Richardson /**
585999a2dd95SBruce Richardson  * Send any packets queued up for transmission on a port and HW queue
586099a2dd95SBruce Richardson  *
586199a2dd95SBruce Richardson  * This causes an explicit flush of packets previously buffered via the
586299a2dd95SBruce Richardson  * rte_eth_tx_buffer() function. It returns the number of packets successfully
586399a2dd95SBruce Richardson  * sent to the NIC, and calls the error callback for any unsent packets. Unless
586499a2dd95SBruce Richardson  * explicitly set up otherwise, the default callback simply frees the unsent
586599a2dd95SBruce Richardson  * packets back to the owning mempool.
586699a2dd95SBruce Richardson  *
586799a2dd95SBruce Richardson  * @param port_id
586899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
586999a2dd95SBruce Richardson  * @param queue_id
587099a2dd95SBruce Richardson  *   The index of the transmit queue through which output packets must be
587199a2dd95SBruce Richardson  *   sent.
587299a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
587399a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
587499a2dd95SBruce Richardson  * @param buffer
587599a2dd95SBruce Richardson  *   Buffer of packets to be transmit.
587699a2dd95SBruce Richardson  * @return
587799a2dd95SBruce Richardson  *   The number of packets successfully sent to the Ethernet device. The error
587899a2dd95SBruce Richardson  *   callback is called for any packets which could not be sent.
587999a2dd95SBruce Richardson  */
588099a2dd95SBruce Richardson static inline uint16_t
588199a2dd95SBruce Richardson rte_eth_tx_buffer_flush(uint16_t port_id, uint16_t queue_id,
588299a2dd95SBruce Richardson 		struct rte_eth_dev_tx_buffer *buffer)
588399a2dd95SBruce Richardson {
588499a2dd95SBruce Richardson 	uint16_t sent;
588599a2dd95SBruce Richardson 	uint16_t to_send = buffer->length;
588699a2dd95SBruce Richardson 
588799a2dd95SBruce Richardson 	if (to_send == 0)
588899a2dd95SBruce Richardson 		return 0;
588999a2dd95SBruce Richardson 
589099a2dd95SBruce Richardson 	sent = rte_eth_tx_burst(port_id, queue_id, buffer->pkts, to_send);
589199a2dd95SBruce Richardson 
589299a2dd95SBruce Richardson 	buffer->length = 0;
589399a2dd95SBruce Richardson 
589499a2dd95SBruce Richardson 	/* All packets sent, or to be dealt with by callback below */
589599a2dd95SBruce Richardson 	if (unlikely(sent != to_send))
589699a2dd95SBruce Richardson 		buffer->error_callback(&buffer->pkts[sent],
589799a2dd95SBruce Richardson 				       (uint16_t)(to_send - sent),
589899a2dd95SBruce Richardson 				       buffer->error_userdata);
589999a2dd95SBruce Richardson 
590099a2dd95SBruce Richardson 	return sent;
590199a2dd95SBruce Richardson }
590299a2dd95SBruce Richardson 
590399a2dd95SBruce Richardson /**
590499a2dd95SBruce Richardson  * Buffer a single packet for future transmission on a port and queue
590599a2dd95SBruce Richardson  *
590699a2dd95SBruce Richardson  * This function takes a single mbuf/packet and buffers it for later
590799a2dd95SBruce Richardson  * transmission on the particular port and queue specified. Once the buffer is
590899a2dd95SBruce Richardson  * full of packets, an attempt will be made to transmit all the buffered
590999a2dd95SBruce Richardson  * packets. In case of error, where not all packets can be transmitted, a
591099a2dd95SBruce Richardson  * callback is called with the unsent packets as a parameter. If no callback
591199a2dd95SBruce Richardson  * is explicitly set up, the unsent packets are just freed back to the owning
591299a2dd95SBruce Richardson  * mempool. The function returns the number of packets actually sent i.e.
591399a2dd95SBruce Richardson  * 0 if no buffer flush occurred, otherwise the number of packets successfully
591499a2dd95SBruce Richardson  * flushed
591599a2dd95SBruce Richardson  *
591699a2dd95SBruce Richardson  * @param port_id
591799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
591899a2dd95SBruce Richardson  * @param queue_id
591999a2dd95SBruce Richardson  *   The index of the transmit queue through which output packets must be
592099a2dd95SBruce Richardson  *   sent.
592199a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
592299a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
592399a2dd95SBruce Richardson  * @param buffer
592499a2dd95SBruce Richardson  *   Buffer used to collect packets to be sent.
592599a2dd95SBruce Richardson  * @param tx_pkt
592699a2dd95SBruce Richardson  *   Pointer to the packet mbuf to be sent.
592799a2dd95SBruce Richardson  * @return
592899a2dd95SBruce Richardson  *   0 = packet has been buffered for later transmission
592999a2dd95SBruce Richardson  *   N > 0 = packet has been buffered, and the buffer was subsequently flushed,
593099a2dd95SBruce Richardson  *     causing N packets to be sent, and the error callback to be called for
593199a2dd95SBruce Richardson  *     the rest.
593299a2dd95SBruce Richardson  */
593399a2dd95SBruce Richardson static __rte_always_inline uint16_t
593499a2dd95SBruce Richardson rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id,
593599a2dd95SBruce Richardson 		struct rte_eth_dev_tx_buffer *buffer, struct rte_mbuf *tx_pkt)
593699a2dd95SBruce Richardson {
593799a2dd95SBruce Richardson 	buffer->pkts[buffer->length++] = tx_pkt;
593899a2dd95SBruce Richardson 	if (buffer->length < buffer->size)
593999a2dd95SBruce Richardson 		return 0;
594099a2dd95SBruce Richardson 
594199a2dd95SBruce Richardson 	return rte_eth_tx_buffer_flush(port_id, queue_id, buffer);
594299a2dd95SBruce Richardson }
594399a2dd95SBruce Richardson 
594499a2dd95SBruce Richardson #ifdef __cplusplus
594599a2dd95SBruce Richardson }
594699a2dd95SBruce Richardson #endif
594799a2dd95SBruce Richardson 
594899a2dd95SBruce Richardson #endif /* _RTE_ETHDEV_H_ */
5949