xref: /dpdk/lib/ethdev/rte_ethdev.h (revision f8dbaebb)
199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
299a2dd95SBruce Richardson  * Copyright(c) 2010-2017 Intel Corporation
399a2dd95SBruce Richardson  */
499a2dd95SBruce Richardson 
599a2dd95SBruce Richardson #ifndef _RTE_ETHDEV_H_
699a2dd95SBruce Richardson #define _RTE_ETHDEV_H_
799a2dd95SBruce Richardson 
899a2dd95SBruce Richardson /**
999a2dd95SBruce Richardson  * @file
1099a2dd95SBruce Richardson  *
1199a2dd95SBruce Richardson  * RTE Ethernet Device API
1299a2dd95SBruce Richardson  *
1399a2dd95SBruce Richardson  * The Ethernet Device API is composed of two parts:
1499a2dd95SBruce Richardson  *
1599a2dd95SBruce Richardson  * - The application-oriented Ethernet API that includes functions to setup
1609fd4227SAndrew Rybchenko  *   an Ethernet device (configure it, setup its Rx and Tx queues and start it),
1799a2dd95SBruce Richardson  *   to get its MAC address, the speed and the status of its physical link,
1899a2dd95SBruce Richardson  *   to receive and to transmit packets, and so on.
1999a2dd95SBruce Richardson  *
2099a2dd95SBruce Richardson  * - The driver-oriented Ethernet API that exports functions allowing
2199a2dd95SBruce Richardson  *   an Ethernet Poll Mode Driver (PMD) to allocate an Ethernet device instance,
2299a2dd95SBruce Richardson  *   create memzone for HW rings and process registered callbacks, and so on.
2399a2dd95SBruce Richardson  *   PMDs should include ethdev_driver.h instead of this header.
2499a2dd95SBruce Richardson  *
2599a2dd95SBruce Richardson  * By default, all the functions of the Ethernet Device API exported by a PMD
2699a2dd95SBruce Richardson  * are lock-free functions which assume to not be invoked in parallel on
2799a2dd95SBruce Richardson  * different logical cores to work on the same target object.  For instance,
2899a2dd95SBruce Richardson  * the receive function of a PMD cannot be invoked in parallel on two logical
2909fd4227SAndrew Rybchenko  * cores to poll the same Rx queue [of the same port]. Of course, this function
3009fd4227SAndrew Rybchenko  * can be invoked in parallel by different logical cores on different Rx queues.
3199a2dd95SBruce Richardson  * It is the responsibility of the upper level application to enforce this rule.
3299a2dd95SBruce Richardson  *
3399a2dd95SBruce Richardson  * If needed, parallel accesses by multiple logical cores to shared queues
3499a2dd95SBruce Richardson  * shall be explicitly protected by dedicated inline lock-aware functions
3599a2dd95SBruce Richardson  * built on top of their corresponding lock-free functions of the PMD API.
3699a2dd95SBruce Richardson  *
3799a2dd95SBruce Richardson  * In all functions of the Ethernet API, the Ethernet device is
3899a2dd95SBruce Richardson  * designated by an integer >= 0 named the device port identifier.
3999a2dd95SBruce Richardson  *
4099a2dd95SBruce Richardson  * At the Ethernet driver level, Ethernet devices are represented by a generic
4199a2dd95SBruce Richardson  * data structure of type *rte_eth_dev*.
4299a2dd95SBruce Richardson  *
4399a2dd95SBruce Richardson  * Ethernet devices are dynamically registered during the PCI probing phase
4499a2dd95SBruce Richardson  * performed at EAL initialization time.
4599a2dd95SBruce Richardson  * When an Ethernet device is being probed, an *rte_eth_dev* structure and
4699a2dd95SBruce Richardson  * a new port identifier are allocated for that device. Then, the eth_dev_init()
4799a2dd95SBruce Richardson  * function supplied by the Ethernet driver matching the probed PCI
4899a2dd95SBruce Richardson  * device is invoked to properly initialize the device.
4999a2dd95SBruce Richardson  *
5099a2dd95SBruce Richardson  * The role of the device init function consists of resetting the hardware,
5199a2dd95SBruce Richardson  * checking access to Non-volatile Memory (NVM), reading the MAC address
5299a2dd95SBruce Richardson  * from NVM etc.
5399a2dd95SBruce Richardson  *
5499a2dd95SBruce Richardson  * If the device init operation is successful, the correspondence between
5599a2dd95SBruce Richardson  * the port identifier assigned to the new device and its associated
5699a2dd95SBruce Richardson  * *rte_eth_dev* structure is effectively registered.
5799a2dd95SBruce Richardson  * Otherwise, both the *rte_eth_dev* structure and the port identifier are
5899a2dd95SBruce Richardson  * freed.
5999a2dd95SBruce Richardson  *
6099a2dd95SBruce Richardson  * The functions exported by the application Ethernet API to setup a device
6199a2dd95SBruce Richardson  * designated by its port identifier must be invoked in the following order:
6299a2dd95SBruce Richardson  *     - rte_eth_dev_configure()
6399a2dd95SBruce Richardson  *     - rte_eth_tx_queue_setup()
6499a2dd95SBruce Richardson  *     - rte_eth_rx_queue_setup()
6599a2dd95SBruce Richardson  *     - rte_eth_dev_start()
6699a2dd95SBruce Richardson  *
6799a2dd95SBruce Richardson  * Then, the network application can invoke, in any order, the functions
6899a2dd95SBruce Richardson  * exported by the Ethernet API to get the MAC address of a given device, to
6999a2dd95SBruce Richardson  * get the speed and the status of a device physical link, to receive/transmit
7099a2dd95SBruce Richardson  * [burst of] packets, and so on.
7199a2dd95SBruce Richardson  *
7299a2dd95SBruce Richardson  * If the application wants to change the configuration (i.e. call
7399a2dd95SBruce Richardson  * rte_eth_dev_configure(), rte_eth_tx_queue_setup(), or
7499a2dd95SBruce Richardson  * rte_eth_rx_queue_setup()), it must call rte_eth_dev_stop() first to stop the
7599a2dd95SBruce Richardson  * device and then do the reconfiguration before calling rte_eth_dev_start()
7699a2dd95SBruce Richardson  * again. The transmit and receive functions should not be invoked when the
7799a2dd95SBruce Richardson  * device is stopped.
7899a2dd95SBruce Richardson  *
7999a2dd95SBruce Richardson  * Please note that some configuration is not stored between calls to
8099a2dd95SBruce Richardson  * rte_eth_dev_stop()/rte_eth_dev_start(). The following configuration will
8199a2dd95SBruce Richardson  * be retained:
8299a2dd95SBruce Richardson  *
8399a2dd95SBruce Richardson  *     - MTU
8499a2dd95SBruce Richardson  *     - flow control settings
8599a2dd95SBruce Richardson  *     - receive mode configuration (promiscuous mode, all-multicast mode,
86064e90c4SAndrew Rybchenko  *       hardware checksum mode, RSS/VMDq settings etc.)
8799a2dd95SBruce Richardson  *     - VLAN filtering configuration
8899a2dd95SBruce Richardson  *     - default MAC address
8999a2dd95SBruce Richardson  *     - MAC addresses supplied to MAC address array
9099a2dd95SBruce Richardson  *     - flow director filtering mode (but not filtering rules)
9199a2dd95SBruce Richardson  *     - NIC queue statistics mappings
9299a2dd95SBruce Richardson  *
931d5a3d68SDmitry Kozlyuk  * The following configuration may be retained or not
941d5a3d68SDmitry Kozlyuk  * depending on the device capabilities:
951d5a3d68SDmitry Kozlyuk  *
961d5a3d68SDmitry Kozlyuk  *     - flow rules
972c9cd45dSDmitry Kozlyuk  *     - flow-related shared objects, e.g. indirect actions
981d5a3d68SDmitry Kozlyuk  *
9999a2dd95SBruce Richardson  * Any other configuration will not be stored and will need to be re-entered
10099a2dd95SBruce Richardson  * before a call to rte_eth_dev_start().
10199a2dd95SBruce Richardson  *
10299a2dd95SBruce Richardson  * Finally, a network application can close an Ethernet device by invoking the
10399a2dd95SBruce Richardson  * rte_eth_dev_close() function.
10499a2dd95SBruce Richardson  *
10599a2dd95SBruce Richardson  * Each function of the application Ethernet API invokes a specific function
10699a2dd95SBruce Richardson  * of the PMD that controls the target device designated by its port
10799a2dd95SBruce Richardson  * identifier.
10899a2dd95SBruce Richardson  * For this purpose, all device-specific functions of an Ethernet driver are
10999a2dd95SBruce Richardson  * supplied through a set of pointers contained in a generic structure of type
11099a2dd95SBruce Richardson  * *eth_dev_ops*.
11199a2dd95SBruce Richardson  * The address of the *eth_dev_ops* structure is stored in the *rte_eth_dev*
11299a2dd95SBruce Richardson  * structure by the device init function of the Ethernet driver, which is
11399a2dd95SBruce Richardson  * invoked during the PCI probing phase, as explained earlier.
11499a2dd95SBruce Richardson  *
11599a2dd95SBruce Richardson  * In other words, each function of the Ethernet API simply retrieves the
11699a2dd95SBruce Richardson  * *rte_eth_dev* structure associated with the device port identifier and
11799a2dd95SBruce Richardson  * performs an indirect invocation of the corresponding driver function
11899a2dd95SBruce Richardson  * supplied in the *eth_dev_ops* structure of the *rte_eth_dev* structure.
11999a2dd95SBruce Richardson  *
12009fd4227SAndrew Rybchenko  * For performance reasons, the address of the burst-oriented Rx and Tx
12199a2dd95SBruce Richardson  * functions of the Ethernet driver are not contained in the *eth_dev_ops*
12299a2dd95SBruce Richardson  * structure. Instead, they are directly stored at the beginning of the
12399a2dd95SBruce Richardson  * *rte_eth_dev* structure to avoid an extra indirect memory access during
12499a2dd95SBruce Richardson  * their invocation.
12599a2dd95SBruce Richardson  *
1260d9f56a8SAndrew Rybchenko  * RTE Ethernet device drivers do not use interrupts for transmitting or
12799a2dd95SBruce Richardson  * receiving. Instead, Ethernet drivers export Poll-Mode receive and transmit
12899a2dd95SBruce Richardson  * functions to applications.
12999a2dd95SBruce Richardson  * Both receive and transmit functions are packet-burst oriented to minimize
13099a2dd95SBruce Richardson  * their cost per packet through the following optimizations:
13199a2dd95SBruce Richardson  *
13299a2dd95SBruce Richardson  * - Sharing among multiple packets the incompressible cost of the
13399a2dd95SBruce Richardson  *   invocation of receive/transmit functions.
13499a2dd95SBruce Richardson  *
13599a2dd95SBruce Richardson  * - Enabling receive/transmit functions to take advantage of burst-oriented
13699a2dd95SBruce Richardson  *   hardware features (L1 cache, prefetch instructions, NIC head/tail
13799a2dd95SBruce Richardson  *   registers) to minimize the number of CPU cycles per packet, for instance,
13899a2dd95SBruce Richardson  *   by avoiding useless read memory accesses to ring descriptors, or by
13999a2dd95SBruce Richardson  *   systematically using arrays of pointers that exactly fit L1 cache line
14099a2dd95SBruce Richardson  *   boundaries and sizes.
14199a2dd95SBruce Richardson  *
14299a2dd95SBruce Richardson  * The burst-oriented receive function does not provide any error notification,
14399a2dd95SBruce Richardson  * to avoid the corresponding overhead. As a hint, the upper-level application
14499a2dd95SBruce Richardson  * might check the status of the device link once being systematically returned
14599a2dd95SBruce Richardson  * a 0 value by the receive function of the driver for a given number of tries.
14699a2dd95SBruce Richardson  */
14799a2dd95SBruce Richardson 
14899a2dd95SBruce Richardson #ifdef __cplusplus
14999a2dd95SBruce Richardson extern "C" {
15099a2dd95SBruce Richardson #endif
15199a2dd95SBruce Richardson 
15299a2dd95SBruce Richardson #include <stdint.h>
15399a2dd95SBruce Richardson 
15499a2dd95SBruce Richardson /* Use this macro to check if LRO API is supported */
15599a2dd95SBruce Richardson #define RTE_ETHDEV_HAS_LRO_SUPPORT
15699a2dd95SBruce Richardson 
15799a2dd95SBruce Richardson /* Alias RTE_LIBRTE_ETHDEV_DEBUG for backward compatibility. */
15899a2dd95SBruce Richardson #ifdef RTE_LIBRTE_ETHDEV_DEBUG
15999a2dd95SBruce Richardson #define RTE_ETHDEV_DEBUG_RX
16099a2dd95SBruce Richardson #define RTE_ETHDEV_DEBUG_TX
16199a2dd95SBruce Richardson #endif
16299a2dd95SBruce Richardson 
16399a2dd95SBruce Richardson #include <rte_compat.h>
16499a2dd95SBruce Richardson #include <rte_log.h>
16599a2dd95SBruce Richardson #include <rte_interrupts.h>
16699a2dd95SBruce Richardson #include <rte_dev.h>
16799a2dd95SBruce Richardson #include <rte_devargs.h>
168e1823e08SThomas Monjalon #include <rte_bitops.h>
16999a2dd95SBruce Richardson #include <rte_errno.h>
17099a2dd95SBruce Richardson #include <rte_common.h>
17199a2dd95SBruce Richardson #include <rte_config.h>
17299a2dd95SBruce Richardson #include <rte_ether.h>
17399a2dd95SBruce Richardson #include <rte_power_intrinsics.h>
17499a2dd95SBruce Richardson 
17599a2dd95SBruce Richardson #include "rte_ethdev_trace_fp.h"
17699a2dd95SBruce Richardson #include "rte_dev_info.h"
17799a2dd95SBruce Richardson 
17899a2dd95SBruce Richardson extern int rte_eth_dev_logtype;
17999a2dd95SBruce Richardson 
18099a2dd95SBruce Richardson #define RTE_ETHDEV_LOG(level, ...) \
18199a2dd95SBruce Richardson 	rte_log(RTE_LOG_ ## level, rte_eth_dev_logtype, "" __VA_ARGS__)
18299a2dd95SBruce Richardson 
18399a2dd95SBruce Richardson struct rte_mbuf;
18499a2dd95SBruce Richardson 
18599a2dd95SBruce Richardson /**
18699a2dd95SBruce Richardson  * Initializes a device iterator.
18799a2dd95SBruce Richardson  *
18899a2dd95SBruce Richardson  * This iterator allows accessing a list of devices matching some devargs.
18999a2dd95SBruce Richardson  *
19099a2dd95SBruce Richardson  * @param iter
19199a2dd95SBruce Richardson  *   Device iterator handle initialized by the function.
19299a2dd95SBruce Richardson  *   The fields bus_str and cls_str might be dynamically allocated,
19399a2dd95SBruce Richardson  *   and could be freed by calling rte_eth_iterator_cleanup().
19499a2dd95SBruce Richardson  *
19599a2dd95SBruce Richardson  * @param devargs
19699a2dd95SBruce Richardson  *   Device description string.
19799a2dd95SBruce Richardson  *
19899a2dd95SBruce Richardson  * @return
19999a2dd95SBruce Richardson  *   0 on successful initialization, negative otherwise.
20099a2dd95SBruce Richardson  */
20199a2dd95SBruce Richardson int rte_eth_iterator_init(struct rte_dev_iterator *iter, const char *devargs);
20299a2dd95SBruce Richardson 
20399a2dd95SBruce Richardson /**
20499a2dd95SBruce Richardson  * Iterates on devices with devargs filter.
20599a2dd95SBruce Richardson  * The ownership is not checked.
20699a2dd95SBruce Richardson  *
2075906be5aSAndrew Rybchenko  * The next port ID is returned, and the iterator is updated.
20899a2dd95SBruce Richardson  *
20999a2dd95SBruce Richardson  * @param iter
21099a2dd95SBruce Richardson  *   Device iterator handle initialized by rte_eth_iterator_init().
21199a2dd95SBruce Richardson  *   Some fields bus_str and cls_str might be freed when no more port is found,
21299a2dd95SBruce Richardson  *   by calling rte_eth_iterator_cleanup().
21399a2dd95SBruce Richardson  *
21499a2dd95SBruce Richardson  * @return
2155906be5aSAndrew Rybchenko  *   A port ID if found, RTE_MAX_ETHPORTS otherwise.
21699a2dd95SBruce Richardson  */
21799a2dd95SBruce Richardson uint16_t rte_eth_iterator_next(struct rte_dev_iterator *iter);
21899a2dd95SBruce Richardson 
21999a2dd95SBruce Richardson /**
22099a2dd95SBruce Richardson  * Free some allocated fields of the iterator.
22199a2dd95SBruce Richardson  *
22299a2dd95SBruce Richardson  * This function is automatically called by rte_eth_iterator_next()
22399a2dd95SBruce Richardson  * on the last iteration (i.e. when no more matching port is found).
22499a2dd95SBruce Richardson  *
22599a2dd95SBruce Richardson  * It is safe to call this function twice; it will do nothing more.
22699a2dd95SBruce Richardson  *
22799a2dd95SBruce Richardson  * @param iter
22899a2dd95SBruce Richardson  *   Device iterator handle initialized by rte_eth_iterator_init().
22999a2dd95SBruce Richardson  *   The fields bus_str and cls_str are freed if needed.
23099a2dd95SBruce Richardson  */
23199a2dd95SBruce Richardson void rte_eth_iterator_cleanup(struct rte_dev_iterator *iter);
23299a2dd95SBruce Richardson 
23399a2dd95SBruce Richardson /**
23499a2dd95SBruce Richardson  * Macro to iterate over all ethdev ports matching some devargs.
23599a2dd95SBruce Richardson  *
23699a2dd95SBruce Richardson  * If a break is done before the end of the loop,
23799a2dd95SBruce Richardson  * the function rte_eth_iterator_cleanup() must be called.
23899a2dd95SBruce Richardson  *
23999a2dd95SBruce Richardson  * @param id
2405906be5aSAndrew Rybchenko  *   Iterated port ID of type uint16_t.
24199a2dd95SBruce Richardson  * @param devargs
24299a2dd95SBruce Richardson  *   Device parameters input as string of type char*.
24399a2dd95SBruce Richardson  * @param iter
24499a2dd95SBruce Richardson  *   Iterator handle of type struct rte_dev_iterator, used internally.
24599a2dd95SBruce Richardson  */
24699a2dd95SBruce Richardson #define RTE_ETH_FOREACH_MATCHING_DEV(id, devargs, iter) \
24799a2dd95SBruce Richardson 	for (rte_eth_iterator_init(iter, devargs), \
24899a2dd95SBruce Richardson 	     id = rte_eth_iterator_next(iter); \
24999a2dd95SBruce Richardson 	     id != RTE_MAX_ETHPORTS; \
25099a2dd95SBruce Richardson 	     id = rte_eth_iterator_next(iter))
25199a2dd95SBruce Richardson 
25299a2dd95SBruce Richardson /**
25399a2dd95SBruce Richardson  * A structure used to retrieve statistics for an Ethernet port.
25499a2dd95SBruce Richardson  * Not all statistics fields in struct rte_eth_stats are supported
25599a2dd95SBruce Richardson  * by any type of network interface card (NIC). If any statistics
25699a2dd95SBruce Richardson  * field is not supported, its value is 0.
25799a2dd95SBruce Richardson  * All byte-related statistics do not include Ethernet FCS regardless
25899a2dd95SBruce Richardson  * of whether these bytes have been delivered to the application
259295968d1SFerruh Yigit  * (see RTE_ETH_RX_OFFLOAD_KEEP_CRC).
26099a2dd95SBruce Richardson  */
26199a2dd95SBruce Richardson struct rte_eth_stats {
26299a2dd95SBruce Richardson 	uint64_t ipackets;  /**< Total number of successfully received packets. */
26399a2dd95SBruce Richardson 	uint64_t opackets;  /**< Total number of successfully transmitted packets.*/
26499a2dd95SBruce Richardson 	uint64_t ibytes;    /**< Total number of successfully received bytes. */
26599a2dd95SBruce Richardson 	uint64_t obytes;    /**< Total number of successfully transmitted bytes. */
2663c2ca0a9SAndrew Rybchenko 	/**
26709fd4227SAndrew Rybchenko 	 * Total of Rx packets dropped by the HW,
26809fd4227SAndrew Rybchenko 	 * because there are no available buffer (i.e. Rx queues are full).
26999a2dd95SBruce Richardson 	 */
2703c2ca0a9SAndrew Rybchenko 	uint64_t imissed;
27199a2dd95SBruce Richardson 	uint64_t ierrors;   /**< Total number of erroneous received packets. */
27299a2dd95SBruce Richardson 	uint64_t oerrors;   /**< Total number of failed transmitted packets. */
27309fd4227SAndrew Rybchenko 	uint64_t rx_nombuf; /**< Total number of Rx mbuf allocation failures. */
27499a2dd95SBruce Richardson 	/* Queue stats are limited to max 256 queues */
27509fd4227SAndrew Rybchenko 	/** Total number of queue Rx packets. */
27699a2dd95SBruce Richardson 	uint64_t q_ipackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
27709fd4227SAndrew Rybchenko 	/** Total number of queue Tx packets. */
27899a2dd95SBruce Richardson 	uint64_t q_opackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
2793c2ca0a9SAndrew Rybchenko 	/** Total number of successfully received queue bytes. */
28099a2dd95SBruce Richardson 	uint64_t q_ibytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
2813c2ca0a9SAndrew Rybchenko 	/** Total number of successfully transmitted queue bytes. */
28299a2dd95SBruce Richardson 	uint64_t q_obytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
2833c2ca0a9SAndrew Rybchenko 	/** Total number of queue packets received that are dropped. */
28499a2dd95SBruce Richardson 	uint64_t q_errors[RTE_ETHDEV_QUEUE_STAT_CNTRS];
28599a2dd95SBruce Richardson };
28699a2dd95SBruce Richardson 
2870ce56b05SThomas Monjalon /**@{@name Link speed capabilities
28899a2dd95SBruce Richardson  * Device supported speeds bitmap flags
28999a2dd95SBruce Richardson  */
290295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_AUTONEG 0             /**< Autonegotiate (all speeds) */
291295968d1SFerruh Yigit #define ETH_LINK_SPEED_AUTONEG     RTE_ETH_LINK_SPEED_AUTONEG
292295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_FIXED   RTE_BIT32(0)  /**< Disable autoneg (fixed speed) */
293295968d1SFerruh Yigit #define ETH_LINK_SPEED_FIXED       RTE_ETH_LINK_SPEED_FIXED
294295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_10M_HD  RTE_BIT32(1)  /**<  10 Mbps half-duplex */
295295968d1SFerruh Yigit #define ETH_LINK_SPEED_10M_HD      RTE_ETH_LINK_SPEED_10M_HD
296295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_10M     RTE_BIT32(2)  /**<  10 Mbps full-duplex */
297295968d1SFerruh Yigit #define ETH_LINK_SPEED_10M         RTE_ETH_LINK_SPEED_10M
298295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_100M_HD RTE_BIT32(3)  /**< 100 Mbps half-duplex */
299295968d1SFerruh Yigit #define ETH_LINK_SPEED_100M_HD     RTE_ETH_LINK_SPEED_100M_HD
300295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_100M    RTE_BIT32(4)  /**< 100 Mbps full-duplex */
301295968d1SFerruh Yigit #define ETH_LINK_SPEED_100M        RTE_ETH_LINK_SPEED_100M
302295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_1G      RTE_BIT32(5)  /**<   1 Gbps */
303295968d1SFerruh Yigit #define ETH_LINK_SPEED_1G          RTE_ETH_LINK_SPEED_1G
304295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_2_5G    RTE_BIT32(6)  /**< 2.5 Gbps */
305295968d1SFerruh Yigit #define ETH_LINK_SPEED_2_5G        RTE_ETH_LINK_SPEED_2_5G
306295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_5G      RTE_BIT32(7)  /**<   5 Gbps */
307295968d1SFerruh Yigit #define ETH_LINK_SPEED_5G          RTE_ETH_LINK_SPEED_5G
308295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_10G     RTE_BIT32(8)  /**<  10 Gbps */
309295968d1SFerruh Yigit #define ETH_LINK_SPEED_10G         RTE_ETH_LINK_SPEED_10G
310295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_20G     RTE_BIT32(9)  /**<  20 Gbps */
311295968d1SFerruh Yigit #define ETH_LINK_SPEED_20G         RTE_ETH_LINK_SPEED_20G
312295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_25G     RTE_BIT32(10) /**<  25 Gbps */
313295968d1SFerruh Yigit #define ETH_LINK_SPEED_25G         RTE_ETH_LINK_SPEED_25G
314295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_40G     RTE_BIT32(11) /**<  40 Gbps */
315295968d1SFerruh Yigit #define ETH_LINK_SPEED_40G         RTE_ETH_LINK_SPEED_40G
316295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_50G     RTE_BIT32(12) /**<  50 Gbps */
317295968d1SFerruh Yigit #define ETH_LINK_SPEED_50G         RTE_ETH_LINK_SPEED_50G
318295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_56G     RTE_BIT32(13) /**<  56 Gbps */
319295968d1SFerruh Yigit #define ETH_LINK_SPEED_56G         RTE_ETH_LINK_SPEED_56G
320295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_100G    RTE_BIT32(14) /**< 100 Gbps */
321295968d1SFerruh Yigit #define ETH_LINK_SPEED_100G        RTE_ETH_LINK_SPEED_100G
322295968d1SFerruh Yigit #define RTE_ETH_LINK_SPEED_200G    RTE_BIT32(15) /**< 200 Gbps */
323295968d1SFerruh Yigit #define ETH_LINK_SPEED_200G        RTE_ETH_LINK_SPEED_200G
3240ce56b05SThomas Monjalon /**@}*/
32599a2dd95SBruce Richardson 
3260ce56b05SThomas Monjalon /**@{@name Link speed
32799a2dd95SBruce Richardson  * Ethernet numeric link speeds in Mbps
32899a2dd95SBruce Richardson  */
329295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_NONE         0 /**< Not defined */
330295968d1SFerruh Yigit #define ETH_SPEED_NUM_NONE        RTE_ETH_SPEED_NUM_NONE
331295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_10M         10 /**<  10 Mbps */
332295968d1SFerruh Yigit #define ETH_SPEED_NUM_10M         RTE_ETH_SPEED_NUM_10M
333295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_100M       100 /**< 100 Mbps */
334295968d1SFerruh Yigit #define ETH_SPEED_NUM_100M        RTE_ETH_SPEED_NUM_100M
335295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_1G        1000 /**<   1 Gbps */
336295968d1SFerruh Yigit #define ETH_SPEED_NUM_1G          RTE_ETH_SPEED_NUM_1G
337295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_2_5G      2500 /**< 2.5 Gbps */
338295968d1SFerruh Yigit #define ETH_SPEED_NUM_2_5G        RTE_ETH_SPEED_NUM_2_5G
339295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_5G        5000 /**<   5 Gbps */
340295968d1SFerruh Yigit #define ETH_SPEED_NUM_5G          RTE_ETH_SPEED_NUM_5G
341295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_10G      10000 /**<  10 Gbps */
342295968d1SFerruh Yigit #define ETH_SPEED_NUM_10G         RTE_ETH_SPEED_NUM_10G
343295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_20G      20000 /**<  20 Gbps */
344295968d1SFerruh Yigit #define ETH_SPEED_NUM_20G         RTE_ETH_SPEED_NUM_20G
345295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_25G      25000 /**<  25 Gbps */
346295968d1SFerruh Yigit #define ETH_SPEED_NUM_25G         RTE_ETH_SPEED_NUM_25G
347295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_40G      40000 /**<  40 Gbps */
348295968d1SFerruh Yigit #define ETH_SPEED_NUM_40G         RTE_ETH_SPEED_NUM_40G
349295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_50G      50000 /**<  50 Gbps */
350295968d1SFerruh Yigit #define ETH_SPEED_NUM_50G         RTE_ETH_SPEED_NUM_50G
351295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_56G      56000 /**<  56 Gbps */
352295968d1SFerruh Yigit #define ETH_SPEED_NUM_56G         RTE_ETH_SPEED_NUM_56G
353295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_100G    100000 /**< 100 Gbps */
354295968d1SFerruh Yigit #define ETH_SPEED_NUM_100G        RTE_ETH_SPEED_NUM_100G
355295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_200G    200000 /**< 200 Gbps */
356295968d1SFerruh Yigit #define ETH_SPEED_NUM_200G        RTE_ETH_SPEED_NUM_200G
357295968d1SFerruh Yigit #define RTE_ETH_SPEED_NUM_UNKNOWN UINT32_MAX /**< Unknown */
358295968d1SFerruh Yigit #define ETH_SPEED_NUM_UNKNOWN     RTE_ETH_SPEED_NUM_UNKNOWN
3590ce56b05SThomas Monjalon /**@}*/
36099a2dd95SBruce Richardson 
36199a2dd95SBruce Richardson /**
36299a2dd95SBruce Richardson  * A structure used to retrieve link-level information of an Ethernet port.
36399a2dd95SBruce Richardson  */
36499a2dd95SBruce Richardson __extension__
36599a2dd95SBruce Richardson struct rte_eth_link {
366295968d1SFerruh Yigit 	uint32_t link_speed;        /**< RTE_ETH_SPEED_NUM_ */
367295968d1SFerruh Yigit 	uint16_t link_duplex  : 1;  /**< RTE_ETH_LINK_[HALF/FULL]_DUPLEX */
368295968d1SFerruh Yigit 	uint16_t link_autoneg : 1;  /**< RTE_ETH_LINK_[AUTONEG/FIXED] */
369295968d1SFerruh Yigit 	uint16_t link_status  : 1;  /**< RTE_ETH_LINK_[DOWN/UP] */
37099a2dd95SBruce Richardson } __rte_aligned(8);      /**< aligned for atomic64 read/write */
37199a2dd95SBruce Richardson 
3720ce56b05SThomas Monjalon /**@{@name Link negotiation
3730ce56b05SThomas Monjalon  * Constants used in link management.
3740ce56b05SThomas Monjalon  */
375295968d1SFerruh Yigit #define RTE_ETH_LINK_HALF_DUPLEX 0 /**< Half-duplex connection (see link_duplex). */
376295968d1SFerruh Yigit #define ETH_LINK_HALF_DUPLEX     RTE_ETH_LINK_HALF_DUPLEX
377295968d1SFerruh Yigit #define RTE_ETH_LINK_FULL_DUPLEX 1 /**< Full-duplex connection (see link_duplex). */
378295968d1SFerruh Yigit #define ETH_LINK_FULL_DUPLEX     RTE_ETH_LINK_FULL_DUPLEX
379295968d1SFerruh Yigit #define RTE_ETH_LINK_DOWN        0 /**< Link is down (see link_status). */
380295968d1SFerruh Yigit #define ETH_LINK_DOWN            RTE_ETH_LINK_DOWN
381295968d1SFerruh Yigit #define RTE_ETH_LINK_UP          1 /**< Link is up (see link_status). */
382295968d1SFerruh Yigit #define ETH_LINK_UP              RTE_ETH_LINK_UP
383295968d1SFerruh Yigit #define RTE_ETH_LINK_FIXED       0 /**< No autonegotiation (see link_autoneg). */
384295968d1SFerruh Yigit #define ETH_LINK_FIXED           RTE_ETH_LINK_FIXED
385295968d1SFerruh Yigit #define RTE_ETH_LINK_AUTONEG     1 /**< Autonegotiated (see link_autoneg). */
386295968d1SFerruh Yigit #define ETH_LINK_AUTONEG         RTE_ETH_LINK_AUTONEG
38799a2dd95SBruce Richardson #define RTE_ETH_LINK_MAX_STR_LEN 40 /**< Max length of default link string. */
3880ce56b05SThomas Monjalon /**@}*/
38999a2dd95SBruce Richardson 
39099a2dd95SBruce Richardson /**
39109fd4227SAndrew Rybchenko  * A structure used to configure the ring threshold registers of an Rx/Tx
39299a2dd95SBruce Richardson  * queue for an Ethernet port.
39399a2dd95SBruce Richardson  */
39499a2dd95SBruce Richardson struct rte_eth_thresh {
39599a2dd95SBruce Richardson 	uint8_t pthresh; /**< Ring prefetch threshold. */
39699a2dd95SBruce Richardson 	uint8_t hthresh; /**< Ring host threshold. */
39799a2dd95SBruce Richardson 	uint8_t wthresh; /**< Ring writeback threshold. */
39899a2dd95SBruce Richardson };
39999a2dd95SBruce Richardson 
4000ce56b05SThomas Monjalon /**@{@name Multi-queue mode
4010ce56b05SThomas Monjalon  * @see rte_eth_conf.rxmode.mq_mode.
40299a2dd95SBruce Richardson  */
4034852c647SAndrew Rybchenko #define RTE_ETH_MQ_RX_RSS_FLAG  RTE_BIT32(0) /**< Enable RSS. @see rte_eth_rss_conf */
404295968d1SFerruh Yigit #define ETH_MQ_RX_RSS_FLAG      RTE_ETH_MQ_RX_RSS_FLAG
4054852c647SAndrew Rybchenko #define RTE_ETH_MQ_RX_DCB_FLAG  RTE_BIT32(1) /**< Enable DCB. */
406295968d1SFerruh Yigit #define ETH_MQ_RX_DCB_FLAG      RTE_ETH_MQ_RX_DCB_FLAG
4074852c647SAndrew Rybchenko #define RTE_ETH_MQ_RX_VMDQ_FLAG RTE_BIT32(2) /**< Enable VMDq. */
408295968d1SFerruh Yigit #define ETH_MQ_RX_VMDQ_FLAG     RTE_ETH_MQ_RX_VMDQ_FLAG
4090ce56b05SThomas Monjalon /**@}*/
41099a2dd95SBruce Richardson 
41199a2dd95SBruce Richardson /**
41299a2dd95SBruce Richardson  *  A set of values to identify what method is to be used to route
41399a2dd95SBruce Richardson  *  packets to multiple queues.
41499a2dd95SBruce Richardson  */
41599a2dd95SBruce Richardson enum rte_eth_rx_mq_mode {
416064e90c4SAndrew Rybchenko 	/** None of DCB, RSS or VMDq mode */
417295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_NONE = 0,
41899a2dd95SBruce Richardson 
41909fd4227SAndrew Rybchenko 	/** For Rx side, only RSS is on */
420295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_RSS = RTE_ETH_MQ_RX_RSS_FLAG,
42109fd4227SAndrew Rybchenko 	/** For Rx side,only DCB is on. */
422295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_DCB = RTE_ETH_MQ_RX_DCB_FLAG,
42399a2dd95SBruce Richardson 	/** Both DCB and RSS enable */
424295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_DCB_RSS = RTE_ETH_MQ_RX_RSS_FLAG | RTE_ETH_MQ_RX_DCB_FLAG,
42599a2dd95SBruce Richardson 
426064e90c4SAndrew Rybchenko 	/** Only VMDq, no RSS nor DCB */
427295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_VMDQ_ONLY = RTE_ETH_MQ_RX_VMDQ_FLAG,
428064e90c4SAndrew Rybchenko 	/** RSS mode with VMDq */
429295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_VMDQ_RSS = RTE_ETH_MQ_RX_RSS_FLAG | RTE_ETH_MQ_RX_VMDQ_FLAG,
430064e90c4SAndrew Rybchenko 	/** Use VMDq+DCB to route traffic to queues */
431295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_VMDQ_DCB = RTE_ETH_MQ_RX_VMDQ_FLAG | RTE_ETH_MQ_RX_DCB_FLAG,
432064e90c4SAndrew Rybchenko 	/** Enable both VMDq and DCB in VMDq */
433295968d1SFerruh Yigit 	RTE_ETH_MQ_RX_VMDQ_DCB_RSS = RTE_ETH_MQ_RX_RSS_FLAG | RTE_ETH_MQ_RX_DCB_FLAG |
434295968d1SFerruh Yigit 				 RTE_ETH_MQ_RX_VMDQ_FLAG,
43599a2dd95SBruce Richardson };
43699a2dd95SBruce Richardson 
437295968d1SFerruh Yigit #define ETH_MQ_RX_NONE		RTE_ETH_MQ_RX_NONE
438295968d1SFerruh Yigit #define ETH_MQ_RX_RSS		RTE_ETH_MQ_RX_RSS
439295968d1SFerruh Yigit #define ETH_MQ_RX_DCB		RTE_ETH_MQ_RX_DCB
440295968d1SFerruh Yigit #define ETH_MQ_RX_DCB_RSS	RTE_ETH_MQ_RX_DCB_RSS
441295968d1SFerruh Yigit #define ETH_MQ_RX_VMDQ_ONLY	RTE_ETH_MQ_RX_VMDQ_ONLY
442295968d1SFerruh Yigit #define ETH_MQ_RX_VMDQ_RSS	RTE_ETH_MQ_RX_VMDQ_RSS
443295968d1SFerruh Yigit #define ETH_MQ_RX_VMDQ_DCB	RTE_ETH_MQ_RX_VMDQ_DCB
444295968d1SFerruh Yigit #define ETH_MQ_RX_VMDQ_DCB_RSS	RTE_ETH_MQ_RX_VMDQ_DCB_RSS
44599a2dd95SBruce Richardson 
44699a2dd95SBruce Richardson /**
44799a2dd95SBruce Richardson  * A set of values to identify what method is to be used to transmit
44899a2dd95SBruce Richardson  * packets using multi-TCs.
44999a2dd95SBruce Richardson  */
45099a2dd95SBruce Richardson enum rte_eth_tx_mq_mode {
451295968d1SFerruh Yigit 	RTE_ETH_MQ_TX_NONE    = 0,  /**< It is in neither DCB nor VT mode. */
452295968d1SFerruh Yigit 	RTE_ETH_MQ_TX_DCB,          /**< For Tx side,only DCB is on. */
453295968d1SFerruh Yigit 	RTE_ETH_MQ_TX_VMDQ_DCB,     /**< For Tx side,both DCB and VT is on. */
454295968d1SFerruh Yigit 	RTE_ETH_MQ_TX_VMDQ_ONLY,    /**< Only VT on, no DCB */
45599a2dd95SBruce Richardson };
456295968d1SFerruh Yigit #define ETH_MQ_TX_NONE		RTE_ETH_MQ_TX_NONE
457295968d1SFerruh Yigit #define ETH_MQ_TX_DCB		RTE_ETH_MQ_TX_DCB
458295968d1SFerruh Yigit #define ETH_MQ_TX_VMDQ_DCB	RTE_ETH_MQ_TX_VMDQ_DCB
459295968d1SFerruh Yigit #define ETH_MQ_TX_VMDQ_ONLY	RTE_ETH_MQ_TX_VMDQ_ONLY
46099a2dd95SBruce Richardson 
46199a2dd95SBruce Richardson /**
46209fd4227SAndrew Rybchenko  * A structure used to configure the Rx features of an Ethernet port.
46399a2dd95SBruce Richardson  */
46499a2dd95SBruce Richardson struct rte_eth_rxmode {
46599a2dd95SBruce Richardson 	/** The multi-queue packet distribution mode to be used, e.g. RSS. */
46699a2dd95SBruce Richardson 	enum rte_eth_rx_mq_mode mq_mode;
4671bb4a528SFerruh Yigit 	uint32_t mtu;  /**< Requested MTU. */
46899a2dd95SBruce Richardson 	/** Maximum allowed size of LRO aggregated packet. */
46999a2dd95SBruce Richardson 	uint32_t max_lro_pkt_size;
47099a2dd95SBruce Richardson 	uint16_t split_hdr_size;  /**< hdr buf size (header_split enabled).*/
47199a2dd95SBruce Richardson 	/**
472295968d1SFerruh Yigit 	 * Per-port Rx offloads to be set using RTE_ETH_RX_OFFLOAD_* flags.
47399a2dd95SBruce Richardson 	 * Only offloads set on rx_offload_capa field on rte_eth_dev_info
47499a2dd95SBruce Richardson 	 * structure are allowed to be set.
47599a2dd95SBruce Richardson 	 */
47699a2dd95SBruce Richardson 	uint64_t offloads;
47799a2dd95SBruce Richardson 
47899a2dd95SBruce Richardson 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
47999a2dd95SBruce Richardson 	void *reserved_ptrs[2];   /**< Reserved for future fields */
48099a2dd95SBruce Richardson };
48199a2dd95SBruce Richardson 
48299a2dd95SBruce Richardson /**
48399a2dd95SBruce Richardson  * VLAN types to indicate if it is for single VLAN, inner VLAN or outer VLAN.
48499a2dd95SBruce Richardson  * Note that single VLAN is treated the same as inner VLAN.
48599a2dd95SBruce Richardson  */
48699a2dd95SBruce Richardson enum rte_vlan_type {
487295968d1SFerruh Yigit 	RTE_ETH_VLAN_TYPE_UNKNOWN = 0,
488295968d1SFerruh Yigit 	RTE_ETH_VLAN_TYPE_INNER, /**< Inner VLAN. */
489295968d1SFerruh Yigit 	RTE_ETH_VLAN_TYPE_OUTER, /**< Single VLAN, or outer VLAN. */
490295968d1SFerruh Yigit 	RTE_ETH_VLAN_TYPE_MAX,
49199a2dd95SBruce Richardson };
49299a2dd95SBruce Richardson 
493295968d1SFerruh Yigit #define ETH_VLAN_TYPE_UNKNOWN	RTE_ETH_VLAN_TYPE_UNKNOWN
494295968d1SFerruh Yigit #define ETH_VLAN_TYPE_INNER	RTE_ETH_VLAN_TYPE_INNER
495295968d1SFerruh Yigit #define ETH_VLAN_TYPE_OUTER	RTE_ETH_VLAN_TYPE_OUTER
496295968d1SFerruh Yigit #define ETH_VLAN_TYPE_MAX	RTE_ETH_VLAN_TYPE_MAX
497295968d1SFerruh Yigit 
49899a2dd95SBruce Richardson /**
4995b49ba65SAndrew Rybchenko  * A structure used to describe a VLAN filter.
50099a2dd95SBruce Richardson  * If the bit corresponding to a VID is set, such VID is on.
50199a2dd95SBruce Richardson  */
50299a2dd95SBruce Richardson struct rte_vlan_filter_conf {
50399a2dd95SBruce Richardson 	uint64_t ids[64];
50499a2dd95SBruce Richardson };
50599a2dd95SBruce Richardson 
50699a2dd95SBruce Richardson /**
50799a2dd95SBruce Richardson  * A structure used to configure the Receive Side Scaling (RSS) feature
50899a2dd95SBruce Richardson  * of an Ethernet port.
50999a2dd95SBruce Richardson  * If not NULL, the *rss_key* pointer of the *rss_conf* structure points
51099a2dd95SBruce Richardson  * to an array holding the RSS key to use for hashing specific header
51199a2dd95SBruce Richardson  * fields of received packets. The length of this array should be indicated
51299a2dd95SBruce Richardson  * by *rss_key_len* below. Otherwise, a default random hash key is used by
51399a2dd95SBruce Richardson  * the device driver.
51499a2dd95SBruce Richardson  *
51599a2dd95SBruce Richardson  * The *rss_key_len* field of the *rss_conf* structure indicates the length
51699a2dd95SBruce Richardson  * in bytes of the array pointed by *rss_key*. To be compatible, this length
51799a2dd95SBruce Richardson  * will be checked in i40e only. Others assume 40 bytes to be used as before.
51899a2dd95SBruce Richardson  *
51999a2dd95SBruce Richardson  * The *rss_hf* field of the *rss_conf* structure indicates the different
52099a2dd95SBruce Richardson  * types of IPv4/IPv6 packets to which the RSS hashing must be applied.
52199a2dd95SBruce Richardson  * Supplying an *rss_hf* equal to zero disables the RSS feature.
52299a2dd95SBruce Richardson  */
52399a2dd95SBruce Richardson struct rte_eth_rss_conf {
52499a2dd95SBruce Richardson 	uint8_t *rss_key;    /**< If not NULL, 40-byte hash key. */
52599a2dd95SBruce Richardson 	uint8_t rss_key_len; /**< hash key length in bytes. */
52699a2dd95SBruce Richardson 	uint64_t rss_hf;     /**< Hash functions to apply - see below. */
52799a2dd95SBruce Richardson };
52899a2dd95SBruce Richardson 
52999a2dd95SBruce Richardson /*
53099a2dd95SBruce Richardson  * A packet can be identified by hardware as different flow types. Different
53199a2dd95SBruce Richardson  * NIC hardware may support different flow types.
53299a2dd95SBruce Richardson  * Basically, the NIC hardware identifies the flow type as deep protocol as
53399a2dd95SBruce Richardson  * possible, and exclusively. For example, if a packet is identified as
53499a2dd95SBruce Richardson  * 'RTE_ETH_FLOW_NONFRAG_IPV4_TCP', it will not be any of other flow types,
53599a2dd95SBruce Richardson  * though it is an actual IPV4 packet.
53699a2dd95SBruce Richardson  */
53799a2dd95SBruce Richardson #define RTE_ETH_FLOW_UNKNOWN             0
53899a2dd95SBruce Richardson #define RTE_ETH_FLOW_RAW                 1
53999a2dd95SBruce Richardson #define RTE_ETH_FLOW_IPV4                2
54099a2dd95SBruce Richardson #define RTE_ETH_FLOW_FRAG_IPV4           3
54199a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV4_TCP    4
54299a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV4_UDP    5
54399a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV4_SCTP   6
54499a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV4_OTHER  7
54599a2dd95SBruce Richardson #define RTE_ETH_FLOW_IPV6                8
54699a2dd95SBruce Richardson #define RTE_ETH_FLOW_FRAG_IPV6           9
54799a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV6_TCP   10
54899a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV6_UDP   11
54999a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV6_SCTP  12
55099a2dd95SBruce Richardson #define RTE_ETH_FLOW_NONFRAG_IPV6_OTHER 13
55199a2dd95SBruce Richardson #define RTE_ETH_FLOW_L2_PAYLOAD         14
55299a2dd95SBruce Richardson #define RTE_ETH_FLOW_IPV6_EX            15
55399a2dd95SBruce Richardson #define RTE_ETH_FLOW_IPV6_TCP_EX        16
55499a2dd95SBruce Richardson #define RTE_ETH_FLOW_IPV6_UDP_EX        17
5553c2ca0a9SAndrew Rybchenko /** Consider device port number as a flow differentiator */
55699a2dd95SBruce Richardson #define RTE_ETH_FLOW_PORT               18
55799a2dd95SBruce Richardson #define RTE_ETH_FLOW_VXLAN              19 /**< VXLAN protocol based flow */
55899a2dd95SBruce Richardson #define RTE_ETH_FLOW_GENEVE             20 /**< GENEVE protocol based flow */
55999a2dd95SBruce Richardson #define RTE_ETH_FLOW_NVGRE              21 /**< NVGRE protocol based flow */
56099a2dd95SBruce Richardson #define RTE_ETH_FLOW_VXLAN_GPE          22 /**< VXLAN-GPE protocol based flow */
56199a2dd95SBruce Richardson #define RTE_ETH_FLOW_GTPU               23 /**< GTPU protocol based flow */
56299a2dd95SBruce Richardson #define RTE_ETH_FLOW_MAX                24
56399a2dd95SBruce Richardson 
56499a2dd95SBruce Richardson /*
56599a2dd95SBruce Richardson  * Below macros are defined for RSS offload types, they can be used to
56699a2dd95SBruce Richardson  * fill rte_eth_rss_conf.rss_hf or rte_flow_action_rss.types.
56799a2dd95SBruce Richardson  */
568295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV4               RTE_BIT64(2)
569295968d1SFerruh Yigit #define ETH_RSS_IPV4                   RTE_ETH_RSS_IPV4
570295968d1SFerruh Yigit #define RTE_ETH_RSS_FRAG_IPV4          RTE_BIT64(3)
571295968d1SFerruh Yigit #define ETH_RSS_FRAG_IPV4              RTE_ETH_RSS_FRAG_IPV4
572295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV4_TCP   RTE_BIT64(4)
573295968d1SFerruh Yigit #define ETH_RSS_NONFRAG_IPV4_TCP       RTE_ETH_RSS_NONFRAG_IPV4_TCP
574295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV4_UDP   RTE_BIT64(5)
575295968d1SFerruh Yigit #define ETH_RSS_NONFRAG_IPV4_UDP       RTE_ETH_RSS_NONFRAG_IPV4_UDP
576295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV4_SCTP  RTE_BIT64(6)
577295968d1SFerruh Yigit #define ETH_RSS_NONFRAG_IPV4_SCTP      RTE_ETH_RSS_NONFRAG_IPV4_SCTP
578295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV4_OTHER RTE_BIT64(7)
579295968d1SFerruh Yigit #define ETH_RSS_NONFRAG_IPV4_OTHER     RTE_ETH_RSS_NONFRAG_IPV4_OTHER
580295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6               RTE_BIT64(8)
581295968d1SFerruh Yigit #define ETH_RSS_IPV6                   RTE_ETH_RSS_IPV6
582295968d1SFerruh Yigit #define RTE_ETH_RSS_FRAG_IPV6          RTE_BIT64(9)
583295968d1SFerruh Yigit #define ETH_RSS_FRAG_IPV6              RTE_ETH_RSS_FRAG_IPV6
584295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV6_TCP   RTE_BIT64(10)
585295968d1SFerruh Yigit #define ETH_RSS_NONFRAG_IPV6_TCP       RTE_ETH_RSS_NONFRAG_IPV6_TCP
586295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV6_UDP   RTE_BIT64(11)
587295968d1SFerruh Yigit #define ETH_RSS_NONFRAG_IPV6_UDP       RTE_ETH_RSS_NONFRAG_IPV6_UDP
588295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV6_SCTP  RTE_BIT64(12)
589295968d1SFerruh Yigit #define ETH_RSS_NONFRAG_IPV6_SCTP      RTE_ETH_RSS_NONFRAG_IPV6_SCTP
590295968d1SFerruh Yigit #define RTE_ETH_RSS_NONFRAG_IPV6_OTHER RTE_BIT64(13)
591295968d1SFerruh Yigit #define ETH_RSS_NONFRAG_IPV6_OTHER     RTE_ETH_RSS_NONFRAG_IPV6_OTHER
592295968d1SFerruh Yigit #define RTE_ETH_RSS_L2_PAYLOAD         RTE_BIT64(14)
593295968d1SFerruh Yigit #define ETH_RSS_L2_PAYLOAD             RTE_ETH_RSS_L2_PAYLOAD
594295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_EX            RTE_BIT64(15)
595295968d1SFerruh Yigit #define ETH_RSS_IPV6_EX                RTE_ETH_RSS_IPV6_EX
596295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_TCP_EX        RTE_BIT64(16)
597295968d1SFerruh Yigit #define ETH_RSS_IPV6_TCP_EX            RTE_ETH_RSS_IPV6_TCP_EX
598295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_UDP_EX        RTE_BIT64(17)
599295968d1SFerruh Yigit #define ETH_RSS_IPV6_UDP_EX            RTE_ETH_RSS_IPV6_UDP_EX
600295968d1SFerruh Yigit #define RTE_ETH_RSS_PORT               RTE_BIT64(18)
601295968d1SFerruh Yigit #define ETH_RSS_PORT                   RTE_ETH_RSS_PORT
602295968d1SFerruh Yigit #define RTE_ETH_RSS_VXLAN              RTE_BIT64(19)
603295968d1SFerruh Yigit #define ETH_RSS_VXLAN                  RTE_ETH_RSS_VXLAN
604295968d1SFerruh Yigit #define RTE_ETH_RSS_GENEVE             RTE_BIT64(20)
605295968d1SFerruh Yigit #define ETH_RSS_GENEVE                 RTE_ETH_RSS_GENEVE
606295968d1SFerruh Yigit #define RTE_ETH_RSS_NVGRE              RTE_BIT64(21)
607295968d1SFerruh Yigit #define ETH_RSS_NVGRE                  RTE_ETH_RSS_NVGRE
608295968d1SFerruh Yigit #define RTE_ETH_RSS_GTPU               RTE_BIT64(23)
609295968d1SFerruh Yigit #define ETH_RSS_GTPU                   RTE_ETH_RSS_GTPU
610295968d1SFerruh Yigit #define RTE_ETH_RSS_ETH                RTE_BIT64(24)
611295968d1SFerruh Yigit #define ETH_RSS_ETH                    RTE_ETH_RSS_ETH
612295968d1SFerruh Yigit #define RTE_ETH_RSS_S_VLAN             RTE_BIT64(25)
613295968d1SFerruh Yigit #define ETH_RSS_S_VLAN                 RTE_ETH_RSS_S_VLAN
614295968d1SFerruh Yigit #define RTE_ETH_RSS_C_VLAN             RTE_BIT64(26)
615295968d1SFerruh Yigit #define ETH_RSS_C_VLAN                 RTE_ETH_RSS_C_VLAN
616295968d1SFerruh Yigit #define RTE_ETH_RSS_ESP                RTE_BIT64(27)
617295968d1SFerruh Yigit #define ETH_RSS_ESP                    RTE_ETH_RSS_ESP
618295968d1SFerruh Yigit #define RTE_ETH_RSS_AH                 RTE_BIT64(28)
619295968d1SFerruh Yigit #define ETH_RSS_AH                     RTE_ETH_RSS_AH
620295968d1SFerruh Yigit #define RTE_ETH_RSS_L2TPV3             RTE_BIT64(29)
621295968d1SFerruh Yigit #define ETH_RSS_L2TPV3                 RTE_ETH_RSS_L2TPV3
622295968d1SFerruh Yigit #define RTE_ETH_RSS_PFCP               RTE_BIT64(30)
623295968d1SFerruh Yigit #define ETH_RSS_PFCP                   RTE_ETH_RSS_PFCP
624295968d1SFerruh Yigit #define RTE_ETH_RSS_PPPOE              RTE_BIT64(31)
625295968d1SFerruh Yigit #define ETH_RSS_PPPOE                  RTE_ETH_RSS_PPPOE
626295968d1SFerruh Yigit #define RTE_ETH_RSS_ECPRI              RTE_BIT64(32)
627295968d1SFerruh Yigit #define ETH_RSS_ECPRI                  RTE_ETH_RSS_ECPRI
628295968d1SFerruh Yigit #define RTE_ETH_RSS_MPLS               RTE_BIT64(33)
629295968d1SFerruh Yigit #define ETH_RSS_MPLS                   RTE_ETH_RSS_MPLS
630295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV4_CHKSUM        RTE_BIT64(34)
631295968d1SFerruh Yigit #define ETH_RSS_IPV4_CHKSUM            RTE_ETH_RSS_IPV4_CHKSUM
63281b0fbb8SAlvin Zhang 
63381b0fbb8SAlvin Zhang /**
63481b0fbb8SAlvin Zhang  * The ETH_RSS_L4_CHKSUM works on checksum field of any L4 header.
63581b0fbb8SAlvin Zhang  * It is similar to ETH_RSS_PORT that they don't specify the specific type of
63681b0fbb8SAlvin Zhang  * L4 header. This macro is defined to replace some specific L4 (TCP/UDP/SCTP)
63781b0fbb8SAlvin Zhang  * checksum type for constructing the use of RSS offload bits.
63881b0fbb8SAlvin Zhang  *
63981b0fbb8SAlvin Zhang  * Due to above reason, some old APIs (and configuration) don't support
640295968d1SFerruh Yigit  * RTE_ETH_RSS_L4_CHKSUM. The rte_flow RSS API supports it.
64181b0fbb8SAlvin Zhang  *
64281b0fbb8SAlvin Zhang  * For the case that checksum is not used in an UDP header,
64381b0fbb8SAlvin Zhang  * it takes the reserved value 0 as input for the hash function.
64481b0fbb8SAlvin Zhang  */
645295968d1SFerruh Yigit #define RTE_ETH_RSS_L4_CHKSUM          RTE_BIT64(35)
646295968d1SFerruh Yigit #define ETH_RSS_L4_CHKSUM              RTE_ETH_RSS_L4_CHKSUM
64799a2dd95SBruce Richardson 
64899a2dd95SBruce Richardson /*
649295968d1SFerruh Yigit  * We use the following macros to combine with above RTE_ETH_RSS_* for
65099a2dd95SBruce Richardson  * more specific input set selection. These bits are defined starting
65199a2dd95SBruce Richardson  * from the high end of the 64 bits.
652295968d1SFerruh Yigit  * Note: If we use above RTE_ETH_RSS_* without SRC/DST_ONLY, it represents
65399a2dd95SBruce Richardson  * both SRC and DST are taken into account. If SRC_ONLY and DST_ONLY of
65499a2dd95SBruce Richardson  * the same level are used simultaneously, it is the same case as none of
65599a2dd95SBruce Richardson  * them are added.
65699a2dd95SBruce Richardson  */
657295968d1SFerruh Yigit #define RTE_ETH_RSS_L3_SRC_ONLY        RTE_BIT64(63)
658295968d1SFerruh Yigit #define ETH_RSS_L3_SRC_ONLY            RTE_ETH_RSS_L3_SRC_ONLY
659295968d1SFerruh Yigit #define RTE_ETH_RSS_L3_DST_ONLY        RTE_BIT64(62)
660295968d1SFerruh Yigit #define ETH_RSS_L3_DST_ONLY            RTE_ETH_RSS_L3_DST_ONLY
661295968d1SFerruh Yigit #define RTE_ETH_RSS_L4_SRC_ONLY        RTE_BIT64(61)
662295968d1SFerruh Yigit #define ETH_RSS_L4_SRC_ONLY            RTE_ETH_RSS_L4_SRC_ONLY
663295968d1SFerruh Yigit #define RTE_ETH_RSS_L4_DST_ONLY        RTE_BIT64(60)
664295968d1SFerruh Yigit #define ETH_RSS_L4_DST_ONLY            RTE_ETH_RSS_L4_DST_ONLY
665295968d1SFerruh Yigit #define RTE_ETH_RSS_L2_SRC_ONLY        RTE_BIT64(59)
666295968d1SFerruh Yigit #define ETH_RSS_L2_SRC_ONLY            RTE_ETH_RSS_L2_SRC_ONLY
667295968d1SFerruh Yigit #define RTE_ETH_RSS_L2_DST_ONLY        RTE_BIT64(58)
668295968d1SFerruh Yigit #define ETH_RSS_L2_DST_ONLY            RTE_ETH_RSS_L2_DST_ONLY
66999a2dd95SBruce Richardson 
67099a2dd95SBruce Richardson /*
67199a2dd95SBruce Richardson  * Only select IPV6 address prefix as RSS input set according to
672295968d1SFerruh Yigit  * https:tools.ietf.org/html/rfc6052
673295968d1SFerruh Yigit  * Must be combined with RTE_ETH_RSS_IPV6, RTE_ETH_RSS_NONFRAG_IPV6_UDP,
674295968d1SFerruh Yigit  * RTE_ETH_RSS_NONFRAG_IPV6_TCP, RTE_ETH_RSS_NONFRAG_IPV6_SCTP.
67599a2dd95SBruce Richardson  */
676e1823e08SThomas Monjalon #define RTE_ETH_RSS_L3_PRE32           RTE_BIT64(57)
677e1823e08SThomas Monjalon #define RTE_ETH_RSS_L3_PRE40           RTE_BIT64(56)
678e1823e08SThomas Monjalon #define RTE_ETH_RSS_L3_PRE48           RTE_BIT64(55)
679e1823e08SThomas Monjalon #define RTE_ETH_RSS_L3_PRE56           RTE_BIT64(54)
680e1823e08SThomas Monjalon #define RTE_ETH_RSS_L3_PRE64           RTE_BIT64(53)
681e1823e08SThomas Monjalon #define RTE_ETH_RSS_L3_PRE96           RTE_BIT64(52)
68299a2dd95SBruce Richardson 
68399a2dd95SBruce Richardson /*
68499a2dd95SBruce Richardson  * Use the following macros to combine with the above layers
68599a2dd95SBruce Richardson  * to choose inner and outer layers or both for RSS computation.
68699a2dd95SBruce Richardson  * Bits 50 and 51 are reserved for this.
68799a2dd95SBruce Richardson  */
68899a2dd95SBruce Richardson 
68999a2dd95SBruce Richardson /**
69099a2dd95SBruce Richardson  * level 0, requests the default behavior.
69199a2dd95SBruce Richardson  * Depending on the packet type, it can mean outermost, innermost,
69299a2dd95SBruce Richardson  * anything in between or even no RSS.
69399a2dd95SBruce Richardson  * It basically stands for the innermost encapsulation level RSS
69499a2dd95SBruce Richardson  * can be performed on according to PMD and device capabilities.
69599a2dd95SBruce Richardson  */
69668e8ca7bSAndrew Rybchenko #define RTE_ETH_RSS_LEVEL_PMD_DEFAULT  (UINT64_C(0) << 50)
697295968d1SFerruh Yigit #define ETH_RSS_LEVEL_PMD_DEFAULT      RTE_ETH_RSS_LEVEL_PMD_DEFAULT
69899a2dd95SBruce Richardson 
69999a2dd95SBruce Richardson /**
70099a2dd95SBruce Richardson  * level 1, requests RSS to be performed on the outermost packet
70199a2dd95SBruce Richardson  * encapsulation level.
70299a2dd95SBruce Richardson  */
70368e8ca7bSAndrew Rybchenko #define RTE_ETH_RSS_LEVEL_OUTERMOST    (UINT64_C(1) << 50)
704295968d1SFerruh Yigit #define ETH_RSS_LEVEL_OUTERMOST        RTE_ETH_RSS_LEVEL_OUTERMOST
70599a2dd95SBruce Richardson 
70699a2dd95SBruce Richardson /**
70799a2dd95SBruce Richardson  * level 2, requests RSS to be performed on the specified inner packet
70899a2dd95SBruce Richardson  * encapsulation level, from outermost to innermost (lower to higher values).
70999a2dd95SBruce Richardson  */
71068e8ca7bSAndrew Rybchenko #define RTE_ETH_RSS_LEVEL_INNERMOST    (UINT64_C(2) << 50)
711295968d1SFerruh Yigit #define ETH_RSS_LEVEL_INNERMOST        RTE_ETH_RSS_LEVEL_INNERMOST
71268e8ca7bSAndrew Rybchenko #define RTE_ETH_RSS_LEVEL_MASK         (UINT64_C(3) << 50)
713295968d1SFerruh Yigit #define ETH_RSS_LEVEL_MASK             RTE_ETH_RSS_LEVEL_MASK
71499a2dd95SBruce Richardson 
715295968d1SFerruh Yigit #define RTE_ETH_RSS_LEVEL(rss_hf) ((rss_hf & RTE_ETH_RSS_LEVEL_MASK) >> 50)
716295968d1SFerruh Yigit #define ETH_RSS_LEVEL(rss_hf)          RTE_ETH_RSS_LEVEL(rss_hf)
71799a2dd95SBruce Richardson 
71899a2dd95SBruce Richardson /**
71999a2dd95SBruce Richardson  * For input set change of hash filter, if SRC_ONLY and DST_ONLY of
72099a2dd95SBruce Richardson  * the same level are used simultaneously, it is the same case as
72199a2dd95SBruce Richardson  * none of them are added.
72299a2dd95SBruce Richardson  *
72399a2dd95SBruce Richardson  * @param rss_hf
72499a2dd95SBruce Richardson  *   RSS types with SRC/DST_ONLY.
72599a2dd95SBruce Richardson  * @return
72699a2dd95SBruce Richardson  *   RSS types.
72799a2dd95SBruce Richardson  */
72899a2dd95SBruce Richardson static inline uint64_t
72999a2dd95SBruce Richardson rte_eth_rss_hf_refine(uint64_t rss_hf)
73099a2dd95SBruce Richardson {
731295968d1SFerruh Yigit 	if ((rss_hf & RTE_ETH_RSS_L3_SRC_ONLY) && (rss_hf & RTE_ETH_RSS_L3_DST_ONLY))
732295968d1SFerruh Yigit 		rss_hf &= ~(RTE_ETH_RSS_L3_SRC_ONLY | RTE_ETH_RSS_L3_DST_ONLY);
73399a2dd95SBruce Richardson 
734295968d1SFerruh Yigit 	if ((rss_hf & RTE_ETH_RSS_L4_SRC_ONLY) && (rss_hf & RTE_ETH_RSS_L4_DST_ONLY))
735295968d1SFerruh Yigit 		rss_hf &= ~(RTE_ETH_RSS_L4_SRC_ONLY | RTE_ETH_RSS_L4_DST_ONLY);
73699a2dd95SBruce Richardson 
73799a2dd95SBruce Richardson 	return rss_hf;
73899a2dd95SBruce Richardson }
73999a2dd95SBruce Richardson 
740295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE32 ( \
741295968d1SFerruh Yigit 		RTE_ETH_RSS_IPV6 | \
74299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE32)
743295968d1SFerruh Yigit #define ETH_RSS_IPV6_PRE32	RTE_ETH_RSS_IPV6_PRE32
74499a2dd95SBruce Richardson 
745295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE40 ( \
746295968d1SFerruh Yigit 		RTE_ETH_RSS_IPV6 | \
74799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE40)
748295968d1SFerruh Yigit #define ETH_RSS_IPV6_PRE40	RTE_ETH_RSS_IPV6_PRE40
74999a2dd95SBruce Richardson 
750295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE48 ( \
751295968d1SFerruh Yigit 		RTE_ETH_RSS_IPV6 | \
75299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE48)
753295968d1SFerruh Yigit #define ETH_RSS_IPV6_PRE48	RTE_ETH_RSS_IPV6_PRE48
75499a2dd95SBruce Richardson 
755295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE56 ( \
756295968d1SFerruh Yigit 		RTE_ETH_RSS_IPV6 | \
75799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE56)
758295968d1SFerruh Yigit #define ETH_RSS_IPV6_PRE56	RTE_ETH_RSS_IPV6_PRE56
75999a2dd95SBruce Richardson 
760295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE64 ( \
761295968d1SFerruh Yigit 		RTE_ETH_RSS_IPV6 | \
76299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE64)
763295968d1SFerruh Yigit #define ETH_RSS_IPV6_PRE64	RTE_ETH_RSS_IPV6_PRE64
76499a2dd95SBruce Richardson 
765295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE96 ( \
766295968d1SFerruh Yigit 		RTE_ETH_RSS_IPV6 | \
76799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE96)
768295968d1SFerruh Yigit #define ETH_RSS_IPV6_PRE96	RTE_ETH_RSS_IPV6_PRE96
76999a2dd95SBruce Richardson 
770295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE32_UDP ( \
771295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
77299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE32)
773295968d1SFerruh Yigit #define ETH_RSS_IPV6_PRE32_UDP	RTE_ETH_RSS_IPV6_PRE32_UDP
77499a2dd95SBruce Richardson 
775295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE40_UDP ( \
776295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
77799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE40)
778295968d1SFerruh Yigit #define ETH_RSS_IPV6_PRE40_UDP	RTE_ETH_RSS_IPV6_PRE40_UDP
77999a2dd95SBruce Richardson 
780295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE48_UDP ( \
781295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
78299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE48)
783295968d1SFerruh Yigit #define ETH_RSS_IPV6_PRE48_UDP	RTE_ETH_RSS_IPV6_PRE48_UDP
78499a2dd95SBruce Richardson 
785295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE56_UDP ( \
786295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
78799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE56)
788295968d1SFerruh Yigit #define ETH_RSS_IPV6_PRE56_UDP	RTE_ETH_RSS_IPV6_PRE56_UDP
78999a2dd95SBruce Richardson 
790295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE64_UDP ( \
791295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
79299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE64)
793295968d1SFerruh Yigit #define ETH_RSS_IPV6_PRE64_UDP	RTE_ETH_RSS_IPV6_PRE64_UDP
79499a2dd95SBruce Richardson 
795295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE96_UDP ( \
796295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
79799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE96)
798295968d1SFerruh Yigit #define ETH_RSS_IPV6_PRE96_UDP	RTE_ETH_RSS_IPV6_PRE96_UDP
79999a2dd95SBruce Richardson 
800295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE32_TCP ( \
801295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
80299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE32)
803295968d1SFerruh Yigit #define ETH_RSS_IPV6_PRE32_TCP	RTE_ETH_RSS_IPV6_PRE32_TCP
80499a2dd95SBruce Richardson 
805295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE40_TCP ( \
806295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
80799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE40)
808295968d1SFerruh Yigit #define ETH_RSS_IPV6_PRE40_TCP	RTE_ETH_RSS_IPV6_PRE40_TCP
80999a2dd95SBruce Richardson 
810295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE48_TCP ( \
811295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
81299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE48)
813295968d1SFerruh Yigit #define ETH_RSS_IPV6_PRE48_TCP	RTE_ETH_RSS_IPV6_PRE48_TCP
81499a2dd95SBruce Richardson 
815295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE56_TCP ( \
816295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
81799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE56)
818295968d1SFerruh Yigit #define ETH_RSS_IPV6_PRE56_TCP	RTE_ETH_RSS_IPV6_PRE56_TCP
81999a2dd95SBruce Richardson 
820295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE64_TCP ( \
821295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
82299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE64)
823295968d1SFerruh Yigit #define ETH_RSS_IPV6_PRE64_TCP	RTE_ETH_RSS_IPV6_PRE64_TCP
82499a2dd95SBruce Richardson 
825295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE96_TCP ( \
826295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
82799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE96)
828295968d1SFerruh Yigit #define ETH_RSS_IPV6_PRE96_TCP	RTE_ETH_RSS_IPV6_PRE96_TCP
82999a2dd95SBruce Richardson 
830295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE32_SCTP ( \
831295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
83299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE32)
833295968d1SFerruh Yigit #define ETH_RSS_IPV6_PRE32_SCTP	RTE_ETH_RSS_IPV6_PRE32_SCTP
83499a2dd95SBruce Richardson 
835295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE40_SCTP ( \
836295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
83799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE40)
838295968d1SFerruh Yigit #define ETH_RSS_IPV6_PRE40_SCTP	RTE_ETH_RSS_IPV6_PRE40_SCTP
83999a2dd95SBruce Richardson 
840295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE48_SCTP ( \
841295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
84299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE48)
843295968d1SFerruh Yigit #define ETH_RSS_IPV6_PRE48_SCTP	RTE_ETH_RSS_IPV6_PRE48_SCTP
84499a2dd95SBruce Richardson 
845295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE56_SCTP ( \
846295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
84799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE56)
848295968d1SFerruh Yigit #define ETH_RSS_IPV6_PRE56_SCTP	RTE_ETH_RSS_IPV6_PRE56_SCTP
84999a2dd95SBruce Richardson 
850295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE64_SCTP ( \
851295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
85299a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE64)
853295968d1SFerruh Yigit #define ETH_RSS_IPV6_PRE64_SCTP	RTE_ETH_RSS_IPV6_PRE64_SCTP
85499a2dd95SBruce Richardson 
855295968d1SFerruh Yigit #define RTE_ETH_RSS_IPV6_PRE96_SCTP ( \
856295968d1SFerruh Yigit 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
85799a2dd95SBruce Richardson 		RTE_ETH_RSS_L3_PRE96)
858295968d1SFerruh Yigit #define ETH_RSS_IPV6_PRE96_SCTP	RTE_ETH_RSS_IPV6_PRE96_SCTP
85999a2dd95SBruce Richardson 
860295968d1SFerruh Yigit #define RTE_ETH_RSS_IP ( \
861295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV4 | \
862295968d1SFerruh Yigit 	RTE_ETH_RSS_FRAG_IPV4 | \
863295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_OTHER | \
864295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6 | \
865295968d1SFerruh Yigit 	RTE_ETH_RSS_FRAG_IPV6 | \
866295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \
867295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6_EX)
868295968d1SFerruh Yigit #define ETH_RSS_IP	RTE_ETH_RSS_IP
86999a2dd95SBruce Richardson 
870295968d1SFerruh Yigit #define RTE_ETH_RSS_UDP ( \
871295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
872295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
873295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6_UDP_EX)
874295968d1SFerruh Yigit #define ETH_RSS_UDP	RTE_ETH_RSS_UDP
87599a2dd95SBruce Richardson 
876295968d1SFerruh Yigit #define RTE_ETH_RSS_TCP ( \
877295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
878295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
879295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6_TCP_EX)
880295968d1SFerruh Yigit #define ETH_RSS_TCP	RTE_ETH_RSS_TCP
88199a2dd95SBruce Richardson 
882295968d1SFerruh Yigit #define RTE_ETH_RSS_SCTP ( \
883295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_SCTP | \
884295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_SCTP)
885295968d1SFerruh Yigit #define ETH_RSS_SCTP	RTE_ETH_RSS_SCTP
88699a2dd95SBruce Richardson 
887295968d1SFerruh Yigit #define RTE_ETH_RSS_TUNNEL ( \
888295968d1SFerruh Yigit 	RTE_ETH_RSS_VXLAN  | \
889295968d1SFerruh Yigit 	RTE_ETH_RSS_GENEVE | \
890295968d1SFerruh Yigit 	RTE_ETH_RSS_NVGRE)
891295968d1SFerruh Yigit #define ETH_RSS_TUNNEL	RTE_ETH_RSS_TUNNEL
89299a2dd95SBruce Richardson 
893295968d1SFerruh Yigit #define RTE_ETH_RSS_VLAN ( \
894295968d1SFerruh Yigit 	RTE_ETH_RSS_S_VLAN  | \
895295968d1SFerruh Yigit 	RTE_ETH_RSS_C_VLAN)
896295968d1SFerruh Yigit #define ETH_RSS_VLAN	RTE_ETH_RSS_VLAN
89799a2dd95SBruce Richardson 
8983c2ca0a9SAndrew Rybchenko /** Mask of valid RSS hash protocols */
899295968d1SFerruh Yigit #define RTE_ETH_RSS_PROTO_MASK ( \
900295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV4 | \
901295968d1SFerruh Yigit 	RTE_ETH_RSS_FRAG_IPV4 | \
902295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
903295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
904295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_SCTP | \
905295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV4_OTHER | \
906295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6 | \
907295968d1SFerruh Yigit 	RTE_ETH_RSS_FRAG_IPV6 | \
908295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
909295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
910295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
911295968d1SFerruh Yigit 	RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \
912295968d1SFerruh Yigit 	RTE_ETH_RSS_L2_PAYLOAD | \
913295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6_EX | \
914295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6_TCP_EX | \
915295968d1SFerruh Yigit 	RTE_ETH_RSS_IPV6_UDP_EX | \
916295968d1SFerruh Yigit 	RTE_ETH_RSS_PORT  | \
917295968d1SFerruh Yigit 	RTE_ETH_RSS_VXLAN | \
918295968d1SFerruh Yigit 	RTE_ETH_RSS_GENEVE | \
919295968d1SFerruh Yigit 	RTE_ETH_RSS_NVGRE | \
920295968d1SFerruh Yigit 	RTE_ETH_RSS_MPLS)
921295968d1SFerruh Yigit #define ETH_RSS_PROTO_MASK	RTE_ETH_RSS_PROTO_MASK
92299a2dd95SBruce Richardson 
92399a2dd95SBruce Richardson /*
92499a2dd95SBruce Richardson  * Definitions used for redirection table entry size.
92599a2dd95SBruce Richardson  * Some RSS RETA sizes may not be supported by some drivers, check the
92699a2dd95SBruce Richardson  * documentation or the description of relevant functions for more details.
92799a2dd95SBruce Richardson  */
928295968d1SFerruh Yigit #define RTE_ETH_RSS_RETA_SIZE_64  64
929295968d1SFerruh Yigit #define ETH_RSS_RETA_SIZE_64      RTE_ETH_RSS_RETA_SIZE_64
930295968d1SFerruh Yigit #define RTE_ETH_RSS_RETA_SIZE_128 128
931295968d1SFerruh Yigit #define ETH_RSS_RETA_SIZE_128     RTE_ETH_RSS_RETA_SIZE_128
932295968d1SFerruh Yigit #define RTE_ETH_RSS_RETA_SIZE_256 256
933295968d1SFerruh Yigit #define ETH_RSS_RETA_SIZE_256     RTE_ETH_RSS_RETA_SIZE_256
934295968d1SFerruh Yigit #define RTE_ETH_RSS_RETA_SIZE_512 512
935295968d1SFerruh Yigit #define ETH_RSS_RETA_SIZE_512     RTE_ETH_RSS_RETA_SIZE_512
936295968d1SFerruh Yigit #define RTE_ETH_RETA_GROUP_SIZE   64
937295968d1SFerruh Yigit #define RTE_RETA_GROUP_SIZE       RTE_ETH_RETA_GROUP_SIZE
93899a2dd95SBruce Richardson 
9390ce56b05SThomas Monjalon /**@{@name VMDq and DCB maximums */
940295968d1SFerruh Yigit #define RTE_ETH_VMDQ_MAX_VLAN_FILTERS   64 /**< Maximum nb. of VMDq VLAN filters. */
941295968d1SFerruh Yigit #define ETH_VMDQ_MAX_VLAN_FILTERS       RTE_ETH_VMDQ_MAX_VLAN_FILTERS
942295968d1SFerruh Yigit #define RTE_ETH_DCB_NUM_USER_PRIORITIES 8  /**< Maximum nb. of DCB priorities. */
943295968d1SFerruh Yigit #define ETH_DCB_NUM_USER_PRIORITIES     RTE_ETH_DCB_NUM_USER_PRIORITIES
944295968d1SFerruh Yigit #define RTE_ETH_VMDQ_DCB_NUM_QUEUES     128 /**< Maximum nb. of VMDq DCB queues. */
945295968d1SFerruh Yigit #define ETH_VMDQ_DCB_NUM_QUEUES         RTE_ETH_VMDQ_DCB_NUM_QUEUES
946295968d1SFerruh Yigit #define RTE_ETH_DCB_NUM_QUEUES          128 /**< Maximum nb. of DCB queues. */
947295968d1SFerruh Yigit #define ETH_DCB_NUM_QUEUES              RTE_ETH_DCB_NUM_QUEUES
9480ce56b05SThomas Monjalon /**@}*/
94999a2dd95SBruce Richardson 
9500ce56b05SThomas Monjalon /**@{@name DCB capabilities */
9514852c647SAndrew Rybchenko #define RTE_ETH_DCB_PG_SUPPORT      RTE_BIT32(0) /**< Priority Group(ETS) support. */
952295968d1SFerruh Yigit #define ETH_DCB_PG_SUPPORT          RTE_ETH_DCB_PG_SUPPORT
9534852c647SAndrew Rybchenko #define RTE_ETH_DCB_PFC_SUPPORT     RTE_BIT32(1) /**< Priority Flow Control support. */
954295968d1SFerruh Yigit #define ETH_DCB_PFC_SUPPORT         RTE_ETH_DCB_PFC_SUPPORT
9550ce56b05SThomas Monjalon /**@}*/
95699a2dd95SBruce Richardson 
9570ce56b05SThomas Monjalon /**@{@name VLAN offload bits */
958295968d1SFerruh Yigit #define RTE_ETH_VLAN_STRIP_OFFLOAD   0x0001 /**< VLAN Strip  On/Off */
959295968d1SFerruh Yigit #define ETH_VLAN_STRIP_OFFLOAD       RTE_ETH_VLAN_STRIP_OFFLOAD
960295968d1SFerruh Yigit #define RTE_ETH_VLAN_FILTER_OFFLOAD  0x0002 /**< VLAN Filter On/Off */
961295968d1SFerruh Yigit #define ETH_VLAN_FILTER_OFFLOAD      RTE_ETH_VLAN_FILTER_OFFLOAD
962295968d1SFerruh Yigit #define RTE_ETH_VLAN_EXTEND_OFFLOAD  0x0004 /**< VLAN Extend On/Off */
963295968d1SFerruh Yigit #define ETH_VLAN_EXTEND_OFFLOAD      RTE_ETH_VLAN_EXTEND_OFFLOAD
964295968d1SFerruh Yigit #define RTE_ETH_QINQ_STRIP_OFFLOAD   0x0008 /**< QINQ Strip On/Off */
965295968d1SFerruh Yigit #define ETH_QINQ_STRIP_OFFLOAD       RTE_ETH_QINQ_STRIP_OFFLOAD
96699a2dd95SBruce Richardson 
967295968d1SFerruh Yigit #define RTE_ETH_VLAN_STRIP_MASK      0x0001 /**< VLAN Strip  setting mask */
968295968d1SFerruh Yigit #define ETH_VLAN_STRIP_MASK          RTE_ETH_VLAN_STRIP_MASK
969295968d1SFerruh Yigit #define RTE_ETH_VLAN_FILTER_MASK     0x0002 /**< VLAN Filter  setting mask*/
970295968d1SFerruh Yigit #define ETH_VLAN_FILTER_MASK         RTE_ETH_VLAN_FILTER_MASK
971295968d1SFerruh Yigit #define RTE_ETH_VLAN_EXTEND_MASK     0x0004 /**< VLAN Extend  setting mask*/
972295968d1SFerruh Yigit #define ETH_VLAN_EXTEND_MASK         RTE_ETH_VLAN_EXTEND_MASK
973295968d1SFerruh Yigit #define RTE_ETH_QINQ_STRIP_MASK      0x0008 /**< QINQ Strip  setting mask */
974295968d1SFerruh Yigit #define ETH_QINQ_STRIP_MASK          RTE_ETH_QINQ_STRIP_MASK
975295968d1SFerruh Yigit #define RTE_ETH_VLAN_ID_MAX          0x0FFF /**< VLAN ID is in lower 12 bits*/
976295968d1SFerruh Yigit #define ETH_VLAN_ID_MAX              RTE_ETH_VLAN_ID_MAX
9770ce56b05SThomas Monjalon /**@}*/
97899a2dd95SBruce Richardson 
97999a2dd95SBruce Richardson /* Definitions used for receive MAC address   */
980295968d1SFerruh Yigit #define RTE_ETH_NUM_RECEIVE_MAC_ADDR   128 /**< Maximum nb. of receive mac addr. */
981295968d1SFerruh Yigit #define ETH_NUM_RECEIVE_MAC_ADDR       RTE_ETH_NUM_RECEIVE_MAC_ADDR
98299a2dd95SBruce Richardson 
98399a2dd95SBruce Richardson /* Definitions used for unicast hash  */
984295968d1SFerruh Yigit #define RTE_ETH_VMDQ_NUM_UC_HASH_ARRAY 128 /**< Maximum nb. of UC hash array. */
985295968d1SFerruh Yigit #define ETH_VMDQ_NUM_UC_HASH_ARRAY     RTE_ETH_VMDQ_NUM_UC_HASH_ARRAY
98699a2dd95SBruce Richardson 
9870ce56b05SThomas Monjalon /**@{@name VMDq Rx mode
9880ce56b05SThomas Monjalon  * @see rte_eth_vmdq_rx_conf.rx_mode
9890ce56b05SThomas Monjalon  */
9904852c647SAndrew Rybchenko /** Accept untagged packets. */
9914852c647SAndrew Rybchenko #define RTE_ETH_VMDQ_ACCEPT_UNTAG      RTE_BIT32(0)
992295968d1SFerruh Yigit #define ETH_VMDQ_ACCEPT_UNTAG          RTE_ETH_VMDQ_ACCEPT_UNTAG
9934852c647SAndrew Rybchenko /** Accept packets in multicast table. */
9944852c647SAndrew Rybchenko #define RTE_ETH_VMDQ_ACCEPT_HASH_MC    RTE_BIT32(1)
995295968d1SFerruh Yigit #define ETH_VMDQ_ACCEPT_HASH_MC        RTE_ETH_VMDQ_ACCEPT_HASH_MC
9964852c647SAndrew Rybchenko /** Accept packets in unicast table. */
9974852c647SAndrew Rybchenko #define RTE_ETH_VMDQ_ACCEPT_HASH_UC    RTE_BIT32(2)
998295968d1SFerruh Yigit #define ETH_VMDQ_ACCEPT_HASH_UC        RTE_ETH_VMDQ_ACCEPT_HASH_UC
9994852c647SAndrew Rybchenko /** Accept broadcast packets. */
10004852c647SAndrew Rybchenko #define RTE_ETH_VMDQ_ACCEPT_BROADCAST  RTE_BIT32(3)
1001295968d1SFerruh Yigit #define ETH_VMDQ_ACCEPT_BROADCAST      RTE_ETH_VMDQ_ACCEPT_BROADCAST
10024852c647SAndrew Rybchenko /** Multicast promiscuous. */
10034852c647SAndrew Rybchenko #define RTE_ETH_VMDQ_ACCEPT_MULTICAST  RTE_BIT32(4)
1004295968d1SFerruh Yigit #define ETH_VMDQ_ACCEPT_MULTICAST      RTE_ETH_VMDQ_ACCEPT_MULTICAST
10050ce56b05SThomas Monjalon /**@}*/
100699a2dd95SBruce Richardson 
100799a2dd95SBruce Richardson /**
100899a2dd95SBruce Richardson  * A structure used to configure 64 entries of Redirection Table of the
100999a2dd95SBruce Richardson  * Receive Side Scaling (RSS) feature of an Ethernet port. To configure
101099a2dd95SBruce Richardson  * more than 64 entries supported by hardware, an array of this structure
101199a2dd95SBruce Richardson  * is needed.
101299a2dd95SBruce Richardson  */
101399a2dd95SBruce Richardson struct rte_eth_rss_reta_entry64 {
10143c2ca0a9SAndrew Rybchenko 	/** Mask bits indicate which entries need to be updated/queried. */
101599a2dd95SBruce Richardson 	uint64_t mask;
10163c2ca0a9SAndrew Rybchenko 	/** Group of 64 redirection table entries. */
1017295968d1SFerruh Yigit 	uint16_t reta[RTE_ETH_RETA_GROUP_SIZE];
101899a2dd95SBruce Richardson };
101999a2dd95SBruce Richardson 
102099a2dd95SBruce Richardson /**
102199a2dd95SBruce Richardson  * This enum indicates the possible number of traffic classes
102299a2dd95SBruce Richardson  * in DCB configurations
102399a2dd95SBruce Richardson  */
102499a2dd95SBruce Richardson enum rte_eth_nb_tcs {
1025295968d1SFerruh Yigit 	RTE_ETH_4_TCS = 4, /**< 4 TCs with DCB. */
1026295968d1SFerruh Yigit 	RTE_ETH_8_TCS = 8  /**< 8 TCs with DCB. */
102799a2dd95SBruce Richardson };
1028295968d1SFerruh Yigit #define ETH_4_TCS RTE_ETH_4_TCS
1029295968d1SFerruh Yigit #define ETH_8_TCS RTE_ETH_8_TCS
103099a2dd95SBruce Richardson 
103199a2dd95SBruce Richardson /**
103299a2dd95SBruce Richardson  * This enum indicates the possible number of queue pools
1033064e90c4SAndrew Rybchenko  * in VMDq configurations.
103499a2dd95SBruce Richardson  */
103599a2dd95SBruce Richardson enum rte_eth_nb_pools {
1036295968d1SFerruh Yigit 	RTE_ETH_8_POOLS = 8,    /**< 8 VMDq pools. */
1037295968d1SFerruh Yigit 	RTE_ETH_16_POOLS = 16,  /**< 16 VMDq pools. */
1038295968d1SFerruh Yigit 	RTE_ETH_32_POOLS = 32,  /**< 32 VMDq pools. */
1039295968d1SFerruh Yigit 	RTE_ETH_64_POOLS = 64   /**< 64 VMDq pools. */
104099a2dd95SBruce Richardson };
1041295968d1SFerruh Yigit #define ETH_8_POOLS	RTE_ETH_8_POOLS
1042295968d1SFerruh Yigit #define ETH_16_POOLS	RTE_ETH_16_POOLS
1043295968d1SFerruh Yigit #define ETH_32_POOLS	RTE_ETH_32_POOLS
1044295968d1SFerruh Yigit #define ETH_64_POOLS	RTE_ETH_64_POOLS
104599a2dd95SBruce Richardson 
104699a2dd95SBruce Richardson /* This structure may be extended in future. */
104799a2dd95SBruce Richardson struct rte_eth_dcb_rx_conf {
104899a2dd95SBruce Richardson 	enum rte_eth_nb_tcs nb_tcs; /**< Possible DCB TCs, 4 or 8 TCs */
104999a2dd95SBruce Richardson 	/** Traffic class each UP mapped to. */
1050295968d1SFerruh Yigit 	uint8_t dcb_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES];
105199a2dd95SBruce Richardson };
105299a2dd95SBruce Richardson 
105399a2dd95SBruce Richardson struct rte_eth_vmdq_dcb_tx_conf {
105499a2dd95SBruce Richardson 	enum rte_eth_nb_pools nb_queue_pools; /**< With DCB, 16 or 32 pools. */
105599a2dd95SBruce Richardson 	/** Traffic class each UP mapped to. */
1056295968d1SFerruh Yigit 	uint8_t dcb_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES];
105799a2dd95SBruce Richardson };
105899a2dd95SBruce Richardson 
105999a2dd95SBruce Richardson struct rte_eth_dcb_tx_conf {
106099a2dd95SBruce Richardson 	enum rte_eth_nb_tcs nb_tcs; /**< Possible DCB TCs, 4 or 8 TCs. */
106199a2dd95SBruce Richardson 	/** Traffic class each UP mapped to. */
1062295968d1SFerruh Yigit 	uint8_t dcb_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES];
106399a2dd95SBruce Richardson };
106499a2dd95SBruce Richardson 
106599a2dd95SBruce Richardson struct rte_eth_vmdq_tx_conf {
106699a2dd95SBruce Richardson 	enum rte_eth_nb_pools nb_queue_pools; /**< VMDq mode, 64 pools. */
106799a2dd95SBruce Richardson };
106899a2dd95SBruce Richardson 
106999a2dd95SBruce Richardson /**
1070064e90c4SAndrew Rybchenko  * A structure used to configure the VMDq+DCB feature
107199a2dd95SBruce Richardson  * of an Ethernet port.
107299a2dd95SBruce Richardson  *
107399a2dd95SBruce Richardson  * Using this feature, packets are routed to a pool of queues, based
10745b49ba65SAndrew Rybchenko  * on the VLAN ID in the VLAN tag, and then to a specific queue within
10755b49ba65SAndrew Rybchenko  * that pool, using the user priority VLAN tag field.
107699a2dd95SBruce Richardson  *
107799a2dd95SBruce Richardson  * A default pool may be used, if desired, to route all traffic which
10785b49ba65SAndrew Rybchenko  * does not match the VLAN filter rules.
107999a2dd95SBruce Richardson  */
108099a2dd95SBruce Richardson struct rte_eth_vmdq_dcb_conf {
108199a2dd95SBruce Richardson 	enum rte_eth_nb_pools nb_queue_pools; /**< With DCB, 16 or 32 pools */
108299a2dd95SBruce Richardson 	uint8_t enable_default_pool; /**< If non-zero, use a default pool */
108399a2dd95SBruce Richardson 	uint8_t default_pool; /**< The default pool, if applicable */
108499a2dd95SBruce Richardson 	uint8_t nb_pool_maps; /**< We can have up to 64 filters/mappings */
108599a2dd95SBruce Richardson 	struct {
10865b49ba65SAndrew Rybchenko 		uint16_t vlan_id; /**< The VLAN ID of the received frame */
108709fd4227SAndrew Rybchenko 		uint64_t pools;   /**< Bitmask of pools for packet Rx */
1088295968d1SFerruh Yigit 	} pool_map[RTE_ETH_VMDQ_MAX_VLAN_FILTERS]; /**< VMDq VLAN pool maps. */
10893c2ca0a9SAndrew Rybchenko 	/** Selects a queue in a pool */
1090295968d1SFerruh Yigit 	uint8_t dcb_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES];
109199a2dd95SBruce Richardson };
109299a2dd95SBruce Richardson 
109399a2dd95SBruce Richardson /**
1094064e90c4SAndrew Rybchenko  * A structure used to configure the VMDq feature of an Ethernet port when
109599a2dd95SBruce Richardson  * not combined with the DCB feature.
109699a2dd95SBruce Richardson  *
109799a2dd95SBruce Richardson  * Using this feature, packets are routed to a pool of queues. By default,
10985b49ba65SAndrew Rybchenko  * the pool selection is based on the MAC address, the VLAN ID in the
10995b49ba65SAndrew Rybchenko  * VLAN tag as specified in the pool_map array.
1100295968d1SFerruh Yigit  * Passing the RTE_ETH_VMDQ_ACCEPT_UNTAG in the rx_mode field allows pool
110199a2dd95SBruce Richardson  * selection using only the MAC address. MAC address to pool mapping is done
110299a2dd95SBruce Richardson  * using the rte_eth_dev_mac_addr_add function, with the pool parameter
11035906be5aSAndrew Rybchenko  * corresponding to the pool ID.
110499a2dd95SBruce Richardson  *
110599a2dd95SBruce Richardson  * Queue selection within the selected pool will be done using RSS when
110699a2dd95SBruce Richardson  * it is enabled or revert to the first queue of the pool if not.
110799a2dd95SBruce Richardson  *
110899a2dd95SBruce Richardson  * A default pool may be used, if desired, to route all traffic which
11095b49ba65SAndrew Rybchenko  * does not match the VLAN filter rules or any pool MAC address.
111099a2dd95SBruce Richardson  */
111199a2dd95SBruce Richardson struct rte_eth_vmdq_rx_conf {
111299a2dd95SBruce Richardson 	enum rte_eth_nb_pools nb_queue_pools; /**< VMDq only mode, 8 or 64 pools */
111399a2dd95SBruce Richardson 	uint8_t enable_default_pool; /**< If non-zero, use a default pool */
111499a2dd95SBruce Richardson 	uint8_t default_pool; /**< The default pool, if applicable */
111599a2dd95SBruce Richardson 	uint8_t enable_loop_back; /**< Enable VT loop back */
111699a2dd95SBruce Richardson 	uint8_t nb_pool_maps; /**< We can have up to 64 filters/mappings */
111799a2dd95SBruce Richardson 	uint32_t rx_mode; /**< Flags from ETH_VMDQ_ACCEPT_* */
111899a2dd95SBruce Richardson 	struct {
11195b49ba65SAndrew Rybchenko 		uint16_t vlan_id; /**< The VLAN ID of the received frame */
112009fd4227SAndrew Rybchenko 		uint64_t pools;   /**< Bitmask of pools for packet Rx */
1121295968d1SFerruh Yigit 	} pool_map[RTE_ETH_VMDQ_MAX_VLAN_FILTERS]; /**< VMDq VLAN pool maps. */
112299a2dd95SBruce Richardson };
112399a2dd95SBruce Richardson 
112499a2dd95SBruce Richardson /**
112509fd4227SAndrew Rybchenko  * A structure used to configure the Tx features of an Ethernet port.
112699a2dd95SBruce Richardson  */
112799a2dd95SBruce Richardson struct rte_eth_txmode {
112809fd4227SAndrew Rybchenko 	enum rte_eth_tx_mq_mode mq_mode; /**< Tx multi-queues mode. */
112999a2dd95SBruce Richardson 	/**
1130295968d1SFerruh Yigit 	 * Per-port Tx offloads to be set using RTE_ETH_TX_OFFLOAD_* flags.
113199a2dd95SBruce Richardson 	 * Only offloads set on tx_offload_capa field on rte_eth_dev_info
113299a2dd95SBruce Richardson 	 * structure are allowed to be set.
113399a2dd95SBruce Richardson 	 */
113499a2dd95SBruce Richardson 	uint64_t offloads;
113599a2dd95SBruce Richardson 
113699a2dd95SBruce Richardson 	uint16_t pvid;
113799a2dd95SBruce Richardson 	__extension__
11383c2ca0a9SAndrew Rybchenko 	uint8_t /** If set, reject sending out tagged pkts */
11393c2ca0a9SAndrew Rybchenko 		hw_vlan_reject_tagged : 1,
11403c2ca0a9SAndrew Rybchenko 		/** If set, reject sending out untagged pkts */
114199a2dd95SBruce Richardson 		hw_vlan_reject_untagged : 1,
11423c2ca0a9SAndrew Rybchenko 		/** If set, enable port based VLAN insertion */
114399a2dd95SBruce Richardson 		hw_vlan_insert_pvid : 1;
114499a2dd95SBruce Richardson 
114599a2dd95SBruce Richardson 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
114699a2dd95SBruce Richardson 	void *reserved_ptrs[2];   /**< Reserved for future fields */
114799a2dd95SBruce Richardson };
114899a2dd95SBruce Richardson 
114999a2dd95SBruce Richardson /**
115099a2dd95SBruce Richardson  * @warning
115199a2dd95SBruce Richardson  * @b EXPERIMENTAL: this structure may change without prior notice.
115299a2dd95SBruce Richardson  *
115399a2dd95SBruce Richardson  * A structure used to configure an Rx packet segment to split.
115499a2dd95SBruce Richardson  *
115599a2dd95SBruce Richardson  * If RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag is set in offloads field,
115699a2dd95SBruce Richardson  * the PMD will split the received packets into multiple segments
115799a2dd95SBruce Richardson  * according to the specification in the description array:
115899a2dd95SBruce Richardson  *
115999a2dd95SBruce Richardson  * - The first network buffer will be allocated from the memory pool,
116099a2dd95SBruce Richardson  *   specified in the first array element, the second buffer, from the
116199a2dd95SBruce Richardson  *   pool in the second element, and so on.
116299a2dd95SBruce Richardson  *
116399a2dd95SBruce Richardson  * - The offsets from the segment description elements specify
116499a2dd95SBruce Richardson  *   the data offset from the buffer beginning except the first mbuf.
116599a2dd95SBruce Richardson  *   The first segment offset is added with RTE_PKTMBUF_HEADROOM.
116699a2dd95SBruce Richardson  *
116799a2dd95SBruce Richardson  * - The lengths in the elements define the maximal data amount
116899a2dd95SBruce Richardson  *   being received to each segment. The receiving starts with filling
116999a2dd95SBruce Richardson  *   up the first mbuf data buffer up to specified length. If the
117099a2dd95SBruce Richardson  *   there are data remaining (packet is longer than buffer in the first
117199a2dd95SBruce Richardson  *   mbuf) the following data will be pushed to the next segment
117299a2dd95SBruce Richardson  *   up to its own length, and so on.
117399a2dd95SBruce Richardson  *
117499a2dd95SBruce Richardson  * - If the length in the segment description element is zero
117599a2dd95SBruce Richardson  *   the actual buffer size will be deduced from the appropriate
117699a2dd95SBruce Richardson  *   memory pool properties.
117799a2dd95SBruce Richardson  *
117899a2dd95SBruce Richardson  * - If there is not enough elements to describe the buffer for entire
117999a2dd95SBruce Richardson  *   packet of maximal length the following parameters will be used
118099a2dd95SBruce Richardson  *   for the all remaining segments:
118199a2dd95SBruce Richardson  *     - pool from the last valid element
118299a2dd95SBruce Richardson  *     - the buffer size from this pool
118399a2dd95SBruce Richardson  *     - zero offset
118499a2dd95SBruce Richardson  */
118599a2dd95SBruce Richardson struct rte_eth_rxseg_split {
118699a2dd95SBruce Richardson 	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
118799a2dd95SBruce Richardson 	uint16_t length; /**< Segment data length, configures split point. */
118899a2dd95SBruce Richardson 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
118999a2dd95SBruce Richardson 	uint32_t reserved; /**< Reserved field. */
119099a2dd95SBruce Richardson };
119199a2dd95SBruce Richardson 
119299a2dd95SBruce Richardson /**
119399a2dd95SBruce Richardson  * @warning
119499a2dd95SBruce Richardson  * @b EXPERIMENTAL: this structure may change without prior notice.
119599a2dd95SBruce Richardson  *
119699a2dd95SBruce Richardson  * A common structure used to describe Rx packet segment properties.
119799a2dd95SBruce Richardson  */
119899a2dd95SBruce Richardson union rte_eth_rxseg {
119999a2dd95SBruce Richardson 	/* The settings for buffer split offload. */
120099a2dd95SBruce Richardson 	struct rte_eth_rxseg_split split;
120199a2dd95SBruce Richardson 	/* The other features settings should be added here. */
120299a2dd95SBruce Richardson };
120399a2dd95SBruce Richardson 
120499a2dd95SBruce Richardson /**
120509fd4227SAndrew Rybchenko  * A structure used to configure an Rx ring of an Ethernet port.
120699a2dd95SBruce Richardson  */
120799a2dd95SBruce Richardson struct rte_eth_rxconf {
120809fd4227SAndrew Rybchenko 	struct rte_eth_thresh rx_thresh; /**< Rx ring threshold registers. */
120909fd4227SAndrew Rybchenko 	uint16_t rx_free_thresh; /**< Drives the freeing of Rx descriptors. */
121099a2dd95SBruce Richardson 	uint8_t rx_drop_en; /**< Drop packets if no descriptors are available. */
121199a2dd95SBruce Richardson 	uint8_t rx_deferred_start; /**< Do not start queue with rte_eth_dev_start(). */
121299a2dd95SBruce Richardson 	uint16_t rx_nseg; /**< Number of descriptions in rx_seg array. */
121399a2dd95SBruce Richardson 	/**
1214dd22740cSXueming Li 	 * Share group index in Rx domain and switch domain.
1215dd22740cSXueming Li 	 * Non-zero value to enable Rx queue share, zero value disable share.
1216dd22740cSXueming Li 	 * PMD is responsible for Rx queue consistency checks to avoid member
1217dd22740cSXueming Li 	 * port's configuration contradict to each other.
1218dd22740cSXueming Li 	 */
1219dd22740cSXueming Li 	uint16_t share_group;
1220dd22740cSXueming Li 	uint16_t share_qid; /**< Shared Rx queue ID in group */
1221dd22740cSXueming Li 	/**
1222295968d1SFerruh Yigit 	 * Per-queue Rx offloads to be set using RTE_ETH_RX_OFFLOAD_* flags.
122399a2dd95SBruce Richardson 	 * Only offloads set on rx_queue_offload_capa or rx_offload_capa
122499a2dd95SBruce Richardson 	 * fields on rte_eth_dev_info structure are allowed to be set.
122599a2dd95SBruce Richardson 	 */
122699a2dd95SBruce Richardson 	uint64_t offloads;
122799a2dd95SBruce Richardson 	/**
122899a2dd95SBruce Richardson 	 * Points to the array of segment descriptions for an entire packet.
122999a2dd95SBruce Richardson 	 * Array elements are properties for consecutive Rx segments.
123099a2dd95SBruce Richardson 	 *
123199a2dd95SBruce Richardson 	 * The supported capabilities of receiving segmentation is reported
123299a2dd95SBruce Richardson 	 * in rte_eth_dev_info.rx_seg_capa field.
123399a2dd95SBruce Richardson 	 */
123499a2dd95SBruce Richardson 	union rte_eth_rxseg *rx_seg;
123599a2dd95SBruce Richardson 
123699a2dd95SBruce Richardson 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
123799a2dd95SBruce Richardson 	void *reserved_ptrs[2];   /**< Reserved for future fields */
123899a2dd95SBruce Richardson };
123999a2dd95SBruce Richardson 
124099a2dd95SBruce Richardson /**
124109fd4227SAndrew Rybchenko  * A structure used to configure a Tx ring of an Ethernet port.
124299a2dd95SBruce Richardson  */
124399a2dd95SBruce Richardson struct rte_eth_txconf {
124409fd4227SAndrew Rybchenko 	struct rte_eth_thresh tx_thresh; /**< Tx ring threshold registers. */
124599a2dd95SBruce Richardson 	uint16_t tx_rs_thresh; /**< Drives the setting of RS bit on TXDs. */
124609fd4227SAndrew Rybchenko 	uint16_t tx_free_thresh; /**< Start freeing Tx buffers if there are
124799a2dd95SBruce Richardson 				      less free descriptors than this value. */
124899a2dd95SBruce Richardson 
124999a2dd95SBruce Richardson 	uint8_t tx_deferred_start; /**< Do not start queue with rte_eth_dev_start(). */
125099a2dd95SBruce Richardson 	/**
1251295968d1SFerruh Yigit 	 * Per-queue Tx offloads to be set  using RTE_ETH_TX_OFFLOAD_* flags.
125299a2dd95SBruce Richardson 	 * Only offloads set on tx_queue_offload_capa or tx_offload_capa
125399a2dd95SBruce Richardson 	 * fields on rte_eth_dev_info structure are allowed to be set.
125499a2dd95SBruce Richardson 	 */
125599a2dd95SBruce Richardson 	uint64_t offloads;
125699a2dd95SBruce Richardson 
125799a2dd95SBruce Richardson 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
125899a2dd95SBruce Richardson 	void *reserved_ptrs[2];   /**< Reserved for future fields */
125999a2dd95SBruce Richardson };
126099a2dd95SBruce Richardson 
126199a2dd95SBruce Richardson /**
126299a2dd95SBruce Richardson  * @warning
126399a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
126499a2dd95SBruce Richardson  *
126599a2dd95SBruce Richardson  * A structure used to return the hairpin capabilities that are supported.
126699a2dd95SBruce Richardson  */
126799a2dd95SBruce Richardson struct rte_eth_hairpin_cap {
126899a2dd95SBruce Richardson 	/** The max number of hairpin queues (different bindings). */
126999a2dd95SBruce Richardson 	uint16_t max_nb_queues;
127099a2dd95SBruce Richardson 	/** Max number of Rx queues to be connected to one Tx queue. */
127199a2dd95SBruce Richardson 	uint16_t max_rx_2_tx;
127299a2dd95SBruce Richardson 	/** Max number of Tx queues to be connected to one Rx queue. */
127399a2dd95SBruce Richardson 	uint16_t max_tx_2_rx;
127499a2dd95SBruce Richardson 	uint16_t max_nb_desc; /**< The max num of descriptors. */
127599a2dd95SBruce Richardson };
127699a2dd95SBruce Richardson 
127799a2dd95SBruce Richardson #define RTE_ETH_MAX_HAIRPIN_PEERS 32
127899a2dd95SBruce Richardson 
127999a2dd95SBruce Richardson /**
128099a2dd95SBruce Richardson  * @warning
128199a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
128299a2dd95SBruce Richardson  *
128399a2dd95SBruce Richardson  * A structure used to hold hairpin peer data.
128499a2dd95SBruce Richardson  */
128599a2dd95SBruce Richardson struct rte_eth_hairpin_peer {
128699a2dd95SBruce Richardson 	uint16_t port; /**< Peer port. */
128799a2dd95SBruce Richardson 	uint16_t queue; /**< Peer queue. */
128899a2dd95SBruce Richardson };
128999a2dd95SBruce Richardson 
129099a2dd95SBruce Richardson /**
129199a2dd95SBruce Richardson  * @warning
129299a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
129399a2dd95SBruce Richardson  *
129499a2dd95SBruce Richardson  * A structure used to configure hairpin binding.
129599a2dd95SBruce Richardson  */
129699a2dd95SBruce Richardson struct rte_eth_hairpin_conf {
129799a2dd95SBruce Richardson 	uint32_t peer_count:16; /**< The number of peers. */
129899a2dd95SBruce Richardson 
129999a2dd95SBruce Richardson 	/**
130099a2dd95SBruce Richardson 	 * Explicit Tx flow rule mode.
130199a2dd95SBruce Richardson 	 * One hairpin pair of queues should have the same attribute.
130299a2dd95SBruce Richardson 	 *
130399a2dd95SBruce Richardson 	 * - When set, the user should be responsible for inserting the hairpin
130499a2dd95SBruce Richardson 	 *   Tx part flows and removing them.
130599a2dd95SBruce Richardson 	 * - When clear, the PMD will try to handle the Tx part of the flows,
130699a2dd95SBruce Richardson 	 *   e.g., by splitting one flow into two parts.
130799a2dd95SBruce Richardson 	 */
130899a2dd95SBruce Richardson 	uint32_t tx_explicit:1;
130999a2dd95SBruce Richardson 
131099a2dd95SBruce Richardson 	/**
131199a2dd95SBruce Richardson 	 * Manually bind hairpin queues.
131299a2dd95SBruce Richardson 	 * One hairpin pair of queues should have the same attribute.
131399a2dd95SBruce Richardson 	 *
131499a2dd95SBruce Richardson 	 * - When set, to enable hairpin, the user should call the hairpin bind
131599a2dd95SBruce Richardson 	 *   function after all the queues are set up properly and the ports are
131699a2dd95SBruce Richardson 	 *   started. Also, the hairpin unbind function should be called
131799a2dd95SBruce Richardson 	 *   accordingly before stopping a port that with hairpin configured.
131899a2dd95SBruce Richardson 	 * - When clear, the PMD will try to enable the hairpin with the queues
131999a2dd95SBruce Richardson 	 *   configured automatically during port start.
132099a2dd95SBruce Richardson 	 */
132199a2dd95SBruce Richardson 	uint32_t manual_bind:1;
132299a2dd95SBruce Richardson 	uint32_t reserved:14; /**< Reserved bits. */
132399a2dd95SBruce Richardson 	struct rte_eth_hairpin_peer peers[RTE_ETH_MAX_HAIRPIN_PEERS];
132499a2dd95SBruce Richardson };
132599a2dd95SBruce Richardson 
132699a2dd95SBruce Richardson /**
132799a2dd95SBruce Richardson  * A structure contains information about HW descriptor ring limitations.
132899a2dd95SBruce Richardson  */
132999a2dd95SBruce Richardson struct rte_eth_desc_lim {
133099a2dd95SBruce Richardson 	uint16_t nb_max;   /**< Max allowed number of descriptors. */
133199a2dd95SBruce Richardson 	uint16_t nb_min;   /**< Min allowed number of descriptors. */
133299a2dd95SBruce Richardson 	uint16_t nb_align; /**< Number of descriptors should be aligned to. */
133399a2dd95SBruce Richardson 
133499a2dd95SBruce Richardson 	/**
133599a2dd95SBruce Richardson 	 * Max allowed number of segments per whole packet.
133699a2dd95SBruce Richardson 	 *
133799a2dd95SBruce Richardson 	 * - For TSO packet this is the total number of data descriptors allowed
133899a2dd95SBruce Richardson 	 *   by device.
133999a2dd95SBruce Richardson 	 *
134099a2dd95SBruce Richardson 	 * @see nb_mtu_seg_max
134199a2dd95SBruce Richardson 	 */
134299a2dd95SBruce Richardson 	uint16_t nb_seg_max;
134399a2dd95SBruce Richardson 
134499a2dd95SBruce Richardson 	/**
134599a2dd95SBruce Richardson 	 * Max number of segments per one MTU.
134699a2dd95SBruce Richardson 	 *
134799a2dd95SBruce Richardson 	 * - For non-TSO packet, this is the maximum allowed number of segments
134899a2dd95SBruce Richardson 	 *   in a single transmit packet.
134999a2dd95SBruce Richardson 	 *
135099a2dd95SBruce Richardson 	 * - For TSO packet each segment within the TSO may span up to this
135199a2dd95SBruce Richardson 	 *   value.
135299a2dd95SBruce Richardson 	 *
135399a2dd95SBruce Richardson 	 * @see nb_seg_max
135499a2dd95SBruce Richardson 	 */
135599a2dd95SBruce Richardson 	uint16_t nb_mtu_seg_max;
135699a2dd95SBruce Richardson };
135799a2dd95SBruce Richardson 
135899a2dd95SBruce Richardson /**
135999a2dd95SBruce Richardson  * This enum indicates the flow control mode
136099a2dd95SBruce Richardson  */
136199a2dd95SBruce Richardson enum rte_eth_fc_mode {
1362295968d1SFerruh Yigit 	RTE_ETH_FC_NONE = 0, /**< Disable flow control. */
1363295968d1SFerruh Yigit 	RTE_ETH_FC_RX_PAUSE, /**< Rx pause frame, enable flowctrl on Tx side. */
1364295968d1SFerruh Yigit 	RTE_ETH_FC_TX_PAUSE, /**< Tx pause frame, enable flowctrl on Rx side. */
1365295968d1SFerruh Yigit 	RTE_ETH_FC_FULL      /**< Enable flow control on both side. */
136699a2dd95SBruce Richardson };
136799a2dd95SBruce Richardson 
1368295968d1SFerruh Yigit #define RTE_FC_NONE	RTE_ETH_FC_NONE
1369295968d1SFerruh Yigit #define RTE_FC_RX_PAUSE	RTE_ETH_FC_RX_PAUSE
1370295968d1SFerruh Yigit #define RTE_FC_TX_PAUSE	RTE_ETH_FC_TX_PAUSE
1371295968d1SFerruh Yigit #define RTE_FC_FULL	RTE_ETH_FC_FULL
1372295968d1SFerruh Yigit 
137399a2dd95SBruce Richardson /**
137499a2dd95SBruce Richardson  * A structure used to configure Ethernet flow control parameter.
137599a2dd95SBruce Richardson  * These parameters will be configured into the register of the NIC.
137699a2dd95SBruce Richardson  * Please refer to the corresponding data sheet for proper value.
137799a2dd95SBruce Richardson  */
137899a2dd95SBruce Richardson struct rte_eth_fc_conf {
137999a2dd95SBruce Richardson 	uint32_t high_water;  /**< High threshold value to trigger XOFF */
138099a2dd95SBruce Richardson 	uint32_t low_water;   /**< Low threshold value to trigger XON */
138199a2dd95SBruce Richardson 	uint16_t pause_time;  /**< Pause quota in the Pause frame */
138299a2dd95SBruce Richardson 	uint16_t send_xon;    /**< Is XON frame need be sent */
138399a2dd95SBruce Richardson 	enum rte_eth_fc_mode mode;  /**< Link flow control mode */
138499a2dd95SBruce Richardson 	uint8_t mac_ctrl_frame_fwd; /**< Forward MAC control frames */
138599a2dd95SBruce Richardson 	uint8_t autoneg;      /**< Use Pause autoneg */
138699a2dd95SBruce Richardson };
138799a2dd95SBruce Richardson 
138899a2dd95SBruce Richardson /**
138999a2dd95SBruce Richardson  * A structure used to configure Ethernet priority flow control parameter.
139099a2dd95SBruce Richardson  * These parameters will be configured into the register of the NIC.
139199a2dd95SBruce Richardson  * Please refer to the corresponding data sheet for proper value.
139299a2dd95SBruce Richardson  */
139399a2dd95SBruce Richardson struct rte_eth_pfc_conf {
139499a2dd95SBruce Richardson 	struct rte_eth_fc_conf fc; /**< General flow control parameter. */
139599a2dd95SBruce Richardson 	uint8_t priority;          /**< VLAN User Priority. */
139699a2dd95SBruce Richardson };
139799a2dd95SBruce Richardson 
139899a2dd95SBruce Richardson /**
139999a2dd95SBruce Richardson  * Tunnel type for device-specific classifier configuration.
140099a2dd95SBruce Richardson  * @see rte_eth_udp_tunnel
140199a2dd95SBruce Richardson  */
140299a2dd95SBruce Richardson enum rte_eth_tunnel_type {
1403295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_NONE = 0,
1404295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_VXLAN,
1405295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_GENEVE,
1406295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_TEREDO,
1407295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_NVGRE,
1408295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_IP_IN_GRE,
1409295968d1SFerruh Yigit 	RTE_ETH_L2_TUNNEL_TYPE_E_TAG,
1410295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_VXLAN_GPE,
1411295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_ECPRI,
1412295968d1SFerruh Yigit 	RTE_ETH_TUNNEL_TYPE_MAX,
141399a2dd95SBruce Richardson };
141499a2dd95SBruce Richardson 
1415295968d1SFerruh Yigit #define RTE_TUNNEL_TYPE_NONE		RTE_ETH_TUNNEL_TYPE_NONE
1416295968d1SFerruh Yigit #define RTE_TUNNEL_TYPE_VXLAN		RTE_ETH_TUNNEL_TYPE_VXLAN
1417295968d1SFerruh Yigit #define RTE_TUNNEL_TYPE_GENEVE		RTE_ETH_TUNNEL_TYPE_GENEVE
1418295968d1SFerruh Yigit #define RTE_TUNNEL_TYPE_TEREDO		RTE_ETH_TUNNEL_TYPE_TEREDO
1419295968d1SFerruh Yigit #define RTE_TUNNEL_TYPE_NVGRE		RTE_ETH_TUNNEL_TYPE_NVGRE
1420295968d1SFerruh Yigit #define RTE_TUNNEL_TYPE_IP_IN_GRE	RTE_ETH_TUNNEL_TYPE_IP_IN_GRE
1421295968d1SFerruh Yigit #define RTE_L2_TUNNEL_TYPE_E_TAG	RTE_ETH_L2_TUNNEL_TYPE_E_TAG
1422295968d1SFerruh Yigit #define RTE_TUNNEL_TYPE_VXLAN_GPE	RTE_ETH_TUNNEL_TYPE_VXLAN_GPE
1423295968d1SFerruh Yigit #define RTE_TUNNEL_TYPE_ECPRI		RTE_ETH_TUNNEL_TYPE_ECPRI
1424295968d1SFerruh Yigit #define RTE_TUNNEL_TYPE_MAX		RTE_ETH_TUNNEL_TYPE_MAX
1425295968d1SFerruh Yigit 
142699a2dd95SBruce Richardson /* Deprecated API file for rte_eth_dev_filter_* functions */
142799a2dd95SBruce Richardson #include "rte_eth_ctrl.h"
142899a2dd95SBruce Richardson 
142999a2dd95SBruce Richardson /**
143099a2dd95SBruce Richardson  *  Memory space that can be configured to store Flow Director filters
143199a2dd95SBruce Richardson  *  in the board memory.
143299a2dd95SBruce Richardson  */
1433295968d1SFerruh Yigit enum rte_eth_fdir_pballoc_type {
1434295968d1SFerruh Yigit 	RTE_ETH_FDIR_PBALLOC_64K = 0,  /**< 64k. */
1435295968d1SFerruh Yigit 	RTE_ETH_FDIR_PBALLOC_128K,     /**< 128k. */
1436295968d1SFerruh Yigit 	RTE_ETH_FDIR_PBALLOC_256K,     /**< 256k. */
143799a2dd95SBruce Richardson };
1438295968d1SFerruh Yigit #define rte_fdir_pballoc_type	rte_eth_fdir_pballoc_type
1439295968d1SFerruh Yigit 
1440295968d1SFerruh Yigit #define RTE_FDIR_PBALLOC_64K	RTE_ETH_FDIR_PBALLOC_64K
1441295968d1SFerruh Yigit #define RTE_FDIR_PBALLOC_128K	RTE_ETH_FDIR_PBALLOC_128K
1442295968d1SFerruh Yigit #define RTE_FDIR_PBALLOC_256K	RTE_ETH_FDIR_PBALLOC_256K
144399a2dd95SBruce Richardson 
144499a2dd95SBruce Richardson /**
144509fd4227SAndrew Rybchenko  *  Select report mode of FDIR hash information in Rx descriptors.
144699a2dd95SBruce Richardson  */
144799a2dd95SBruce Richardson enum rte_fdir_status_mode {
144899a2dd95SBruce Richardson 	RTE_FDIR_NO_REPORT_STATUS = 0, /**< Never report FDIR hash. */
144999a2dd95SBruce Richardson 	RTE_FDIR_REPORT_STATUS, /**< Only report FDIR hash for matching pkts. */
145099a2dd95SBruce Richardson 	RTE_FDIR_REPORT_STATUS_ALWAYS, /**< Always report FDIR hash. */
145199a2dd95SBruce Richardson };
145299a2dd95SBruce Richardson 
145399a2dd95SBruce Richardson /**
145499a2dd95SBruce Richardson  * A structure used to configure the Flow Director (FDIR) feature
145599a2dd95SBruce Richardson  * of an Ethernet port.
145699a2dd95SBruce Richardson  *
145799a2dd95SBruce Richardson  * If mode is RTE_FDIR_MODE_NONE, the pballoc value is ignored.
145899a2dd95SBruce Richardson  */
1459295968d1SFerruh Yigit struct rte_eth_fdir_conf {
146099a2dd95SBruce Richardson 	enum rte_fdir_mode mode; /**< Flow Director mode. */
1461295968d1SFerruh Yigit 	enum rte_eth_fdir_pballoc_type pballoc; /**< Space for FDIR filters. */
146299a2dd95SBruce Richardson 	enum rte_fdir_status_mode status;  /**< How to report FDIR hash. */
146309fd4227SAndrew Rybchenko 	/** Rx queue of packets matching a "drop" filter in perfect mode. */
146499a2dd95SBruce Richardson 	uint8_t drop_queue;
146599a2dd95SBruce Richardson 	struct rte_eth_fdir_masks mask;
14663c2ca0a9SAndrew Rybchenko 	/** Flex payload configuration. */
146799a2dd95SBruce Richardson 	struct rte_eth_fdir_flex_conf flex_conf;
146899a2dd95SBruce Richardson };
146999a2dd95SBruce Richardson 
1470295968d1SFerruh Yigit #define rte_fdir_conf rte_eth_fdir_conf
1471295968d1SFerruh Yigit 
147299a2dd95SBruce Richardson /**
147399a2dd95SBruce Richardson  * UDP tunneling configuration.
147499a2dd95SBruce Richardson  *
147599a2dd95SBruce Richardson  * Used to configure the classifier of a device,
147699a2dd95SBruce Richardson  * associating an UDP port with a type of tunnel.
147799a2dd95SBruce Richardson  *
147899a2dd95SBruce Richardson  * Some NICs may need such configuration to properly parse a tunnel
147999a2dd95SBruce Richardson  * with any standard or custom UDP port.
148099a2dd95SBruce Richardson  */
148199a2dd95SBruce Richardson struct rte_eth_udp_tunnel {
148299a2dd95SBruce Richardson 	uint16_t udp_port; /**< UDP port used for the tunnel. */
148399a2dd95SBruce Richardson 	uint8_t prot_type; /**< Tunnel type. @see rte_eth_tunnel_type */
148499a2dd95SBruce Richardson };
148599a2dd95SBruce Richardson 
148699a2dd95SBruce Richardson /**
148799a2dd95SBruce Richardson  * A structure used to enable/disable specific device interrupts.
148899a2dd95SBruce Richardson  */
1489295968d1SFerruh Yigit struct rte_eth_intr_conf {
149099a2dd95SBruce Richardson 	/** enable/disable lsc interrupt. 0 (default) - disable, 1 enable */
149199a2dd95SBruce Richardson 	uint32_t lsc:1;
149299a2dd95SBruce Richardson 	/** enable/disable rxq interrupt. 0 (default) - disable, 1 enable */
149399a2dd95SBruce Richardson 	uint32_t rxq:1;
149499a2dd95SBruce Richardson 	/** enable/disable rmv interrupt. 0 (default) - disable, 1 enable */
149599a2dd95SBruce Richardson 	uint32_t rmv:1;
149699a2dd95SBruce Richardson };
149799a2dd95SBruce Richardson 
1498295968d1SFerruh Yigit #define rte_intr_conf rte_eth_intr_conf
1499295968d1SFerruh Yigit 
150099a2dd95SBruce Richardson /**
150199a2dd95SBruce Richardson  * A structure used to configure an Ethernet port.
150209fd4227SAndrew Rybchenko  * Depending upon the Rx multi-queue mode, extra advanced
150399a2dd95SBruce Richardson  * configuration settings may be needed.
150499a2dd95SBruce Richardson  */
150599a2dd95SBruce Richardson struct rte_eth_conf {
1506295968d1SFerruh Yigit 	uint32_t link_speeds; /**< bitmap of RTE_ETH_LINK_SPEED_XXX of speeds to be
1507295968d1SFerruh Yigit 				used. RTE_ETH_LINK_SPEED_FIXED disables link
150899a2dd95SBruce Richardson 				autonegotiation, and a unique speed shall be
150999a2dd95SBruce Richardson 				set. Otherwise, the bitmap defines the set of
151099a2dd95SBruce Richardson 				speeds to be advertised. If the special value
1511295968d1SFerruh Yigit 				RTE_ETH_LINK_SPEED_AUTONEG (0) is used, all speeds
151299a2dd95SBruce Richardson 				supported are advertised. */
151309fd4227SAndrew Rybchenko 	struct rte_eth_rxmode rxmode; /**< Port Rx configuration. */
151409fd4227SAndrew Rybchenko 	struct rte_eth_txmode txmode; /**< Port Tx configuration. */
151599a2dd95SBruce Richardson 	uint32_t lpbk_mode; /**< Loopback operation mode. By default the value
151699a2dd95SBruce Richardson 			         is 0, meaning the loopback mode is disabled.
15170d9f56a8SAndrew Rybchenko 				 Read the datasheet of given Ethernet controller
151899a2dd95SBruce Richardson 				 for details. The possible values of this field
151999a2dd95SBruce Richardson 				 are defined in implementation of each driver. */
152099a2dd95SBruce Richardson 	struct {
152199a2dd95SBruce Richardson 		struct rte_eth_rss_conf rss_conf; /**< Port RSS configuration */
1522064e90c4SAndrew Rybchenko 		/** Port VMDq+DCB configuration. */
152399a2dd95SBruce Richardson 		struct rte_eth_vmdq_dcb_conf vmdq_dcb_conf;
1524064e90c4SAndrew Rybchenko 		/** Port DCB Rx configuration. */
152599a2dd95SBruce Richardson 		struct rte_eth_dcb_rx_conf dcb_rx_conf;
1526064e90c4SAndrew Rybchenko 		/** Port VMDq Rx configuration. */
152799a2dd95SBruce Richardson 		struct rte_eth_vmdq_rx_conf vmdq_rx_conf;
152809fd4227SAndrew Rybchenko 	} rx_adv_conf; /**< Port Rx filtering configuration. */
152999a2dd95SBruce Richardson 	union {
1530064e90c4SAndrew Rybchenko 		/** Port VMDq+DCB Tx configuration. */
153199a2dd95SBruce Richardson 		struct rte_eth_vmdq_dcb_tx_conf vmdq_dcb_tx_conf;
1532064e90c4SAndrew Rybchenko 		/** Port DCB Tx configuration. */
153399a2dd95SBruce Richardson 		struct rte_eth_dcb_tx_conf dcb_tx_conf;
1534064e90c4SAndrew Rybchenko 		/** Port VMDq Tx configuration. */
153599a2dd95SBruce Richardson 		struct rte_eth_vmdq_tx_conf vmdq_tx_conf;
153609fd4227SAndrew Rybchenko 	} tx_adv_conf; /**< Port Tx DCB configuration (union). */
153799a2dd95SBruce Richardson 	/** Currently,Priority Flow Control(PFC) are supported,if DCB with PFC
1538295968d1SFerruh Yigit 	    is needed,and the variable must be set RTE_ETH_DCB_PFC_SUPPORT. */
153999a2dd95SBruce Richardson 	uint32_t dcb_capability_en;
1540295968d1SFerruh Yigit 	struct rte_eth_fdir_conf fdir_conf; /**< FDIR configuration. DEPRECATED */
1541295968d1SFerruh Yigit 	struct rte_eth_intr_conf intr_conf; /**< Interrupt mode configuration. */
154299a2dd95SBruce Richardson };
154399a2dd95SBruce Richardson 
154499a2dd95SBruce Richardson /**
154509fd4227SAndrew Rybchenko  * Rx offload capabilities of a device.
154699a2dd95SBruce Richardson  */
15474852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_VLAN_STRIP       RTE_BIT64(0)
1548295968d1SFerruh Yigit #define DEV_RX_OFFLOAD_VLAN_STRIP           RTE_ETH_RX_OFFLOAD_VLAN_STRIP
15494852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_IPV4_CKSUM       RTE_BIT64(1)
1550295968d1SFerruh Yigit #define DEV_RX_OFFLOAD_IPV4_CKSUM           RTE_ETH_RX_OFFLOAD_IPV4_CKSUM
15514852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_UDP_CKSUM        RTE_BIT64(2)
1552295968d1SFerruh Yigit #define DEV_RX_OFFLOAD_UDP_CKSUM            RTE_ETH_RX_OFFLOAD_UDP_CKSUM
15534852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_TCP_CKSUM        RTE_BIT64(3)
1554295968d1SFerruh Yigit #define DEV_RX_OFFLOAD_TCP_CKSUM            RTE_ETH_RX_OFFLOAD_TCP_CKSUM
15554852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_TCP_LRO          RTE_BIT64(4)
1556295968d1SFerruh Yigit #define DEV_RX_OFFLOAD_TCP_LRO              RTE_ETH_RX_OFFLOAD_TCP_LRO
15574852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_QINQ_STRIP       RTE_BIT64(5)
1558295968d1SFerruh Yigit #define DEV_RX_OFFLOAD_QINQ_STRIP           RTE_ETH_RX_OFFLOAD_QINQ_STRIP
15594852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM RTE_BIT64(6)
1560295968d1SFerruh Yigit #define DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM     RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM
15614852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_MACSEC_STRIP     RTE_BIT64(7)
1562295968d1SFerruh Yigit #define DEV_RX_OFFLOAD_MACSEC_STRIP         RTE_ETH_RX_OFFLOAD_MACSEC_STRIP
15634852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_HEADER_SPLIT     RTE_BIT64(8)
1564295968d1SFerruh Yigit #define DEV_RX_OFFLOAD_HEADER_SPLIT         RTE_ETH_RX_OFFLOAD_HEADER_SPLIT
15654852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_VLAN_FILTER      RTE_BIT64(9)
1566295968d1SFerruh Yigit #define DEV_RX_OFFLOAD_VLAN_FILTER          RTE_ETH_RX_OFFLOAD_VLAN_FILTER
15674852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_VLAN_EXTEND      RTE_BIT64(10)
1568295968d1SFerruh Yigit #define DEV_RX_OFFLOAD_VLAN_EXTEND          RTE_ETH_RX_OFFLOAD_VLAN_EXTEND
15694852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_SCATTER          RTE_BIT64(13)
1570295968d1SFerruh Yigit #define DEV_RX_OFFLOAD_SCATTER              RTE_ETH_RX_OFFLOAD_SCATTER
157199a2dd95SBruce Richardson /**
157299a2dd95SBruce Richardson  * Timestamp is set by the driver in RTE_MBUF_DYNFIELD_TIMESTAMP_NAME
157399a2dd95SBruce Richardson  * and RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME is set in ol_flags.
157499a2dd95SBruce Richardson  * The mbuf field and flag are registered when the offload is configured.
157599a2dd95SBruce Richardson  */
15764852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_TIMESTAMP        RTE_BIT64(14)
1577295968d1SFerruh Yigit #define DEV_RX_OFFLOAD_TIMESTAMP            RTE_ETH_RX_OFFLOAD_TIMESTAMP
15784852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_SECURITY         RTE_BIT64(15)
1579295968d1SFerruh Yigit #define DEV_RX_OFFLOAD_SECURITY             RTE_ETH_RX_OFFLOAD_SECURITY
15804852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_KEEP_CRC         RTE_BIT64(16)
1581295968d1SFerruh Yigit #define DEV_RX_OFFLOAD_KEEP_CRC             RTE_ETH_RX_OFFLOAD_KEEP_CRC
15824852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_SCTP_CKSUM       RTE_BIT64(17)
1583295968d1SFerruh Yigit #define DEV_RX_OFFLOAD_SCTP_CKSUM           RTE_ETH_RX_OFFLOAD_SCTP_CKSUM
15844852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM  RTE_BIT64(18)
1585295968d1SFerruh Yigit #define DEV_RX_OFFLOAD_OUTER_UDP_CKSUM      RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM
15864852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_RSS_HASH         RTE_BIT64(19)
1587295968d1SFerruh Yigit #define DEV_RX_OFFLOAD_RSS_HASH             RTE_ETH_RX_OFFLOAD_RSS_HASH
15884852c647SAndrew Rybchenko #define RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT     RTE_BIT64(20)
158999a2dd95SBruce Richardson 
1590295968d1SFerruh Yigit #define RTE_ETH_RX_OFFLOAD_CHECKSUM (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | \
1591295968d1SFerruh Yigit 				 RTE_ETH_RX_OFFLOAD_UDP_CKSUM | \
1592295968d1SFerruh Yigit 				 RTE_ETH_RX_OFFLOAD_TCP_CKSUM)
1593295968d1SFerruh Yigit #define DEV_RX_OFFLOAD_CHECKSUM	RTE_ETH_RX_OFFLOAD_CHECKSUM
1594295968d1SFerruh Yigit #define RTE_ETH_RX_OFFLOAD_VLAN (RTE_ETH_RX_OFFLOAD_VLAN_STRIP | \
1595295968d1SFerruh Yigit 			     RTE_ETH_RX_OFFLOAD_VLAN_FILTER | \
1596295968d1SFerruh Yigit 			     RTE_ETH_RX_OFFLOAD_VLAN_EXTEND | \
1597295968d1SFerruh Yigit 			     RTE_ETH_RX_OFFLOAD_QINQ_STRIP)
1598295968d1SFerruh Yigit #define DEV_RX_OFFLOAD_VLAN	RTE_ETH_RX_OFFLOAD_VLAN
159999a2dd95SBruce Richardson 
160099a2dd95SBruce Richardson /*
160199a2dd95SBruce Richardson  * If new Rx offload capabilities are defined, they also must be
160299a2dd95SBruce Richardson  * mentioned in rte_rx_offload_names in rte_ethdev.c file.
160399a2dd95SBruce Richardson  */
160499a2dd95SBruce Richardson 
160599a2dd95SBruce Richardson /**
160609fd4227SAndrew Rybchenko  * Tx offload capabilities of a device.
160799a2dd95SBruce Richardson  */
16084852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_VLAN_INSERT      RTE_BIT64(0)
1609295968d1SFerruh Yigit #define DEV_TX_OFFLOAD_VLAN_INSERT          RTE_ETH_TX_OFFLOAD_VLAN_INSERT
16104852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_IPV4_CKSUM       RTE_BIT64(1)
1611295968d1SFerruh Yigit #define DEV_TX_OFFLOAD_IPV4_CKSUM           RTE_ETH_TX_OFFLOAD_IPV4_CKSUM
16124852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_UDP_CKSUM        RTE_BIT64(2)
1613295968d1SFerruh Yigit #define DEV_TX_OFFLOAD_UDP_CKSUM            RTE_ETH_TX_OFFLOAD_UDP_CKSUM
16144852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_TCP_CKSUM        RTE_BIT64(3)
1615295968d1SFerruh Yigit #define DEV_TX_OFFLOAD_TCP_CKSUM            RTE_ETH_TX_OFFLOAD_TCP_CKSUM
16164852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_SCTP_CKSUM       RTE_BIT64(4)
1617295968d1SFerruh Yigit #define DEV_TX_OFFLOAD_SCTP_CKSUM           RTE_ETH_TX_OFFLOAD_SCTP_CKSUM
16184852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_TCP_TSO          RTE_BIT64(5)
1619295968d1SFerruh Yigit #define DEV_TX_OFFLOAD_TCP_TSO              RTE_ETH_TX_OFFLOAD_TCP_TSO
16204852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_UDP_TSO          RTE_BIT64(6)
1621295968d1SFerruh Yigit #define DEV_TX_OFFLOAD_UDP_TSO              RTE_ETH_TX_OFFLOAD_UDP_TSO
16224852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM RTE_BIT64(7)  /**< Used for tunneling packet. */
1623295968d1SFerruh Yigit #define DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM     RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM
16244852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_QINQ_INSERT      RTE_BIT64(8)
1625295968d1SFerruh Yigit #define DEV_TX_OFFLOAD_QINQ_INSERT          RTE_ETH_TX_OFFLOAD_QINQ_INSERT
16264852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO    RTE_BIT64(9)  /**< Used for tunneling packet. */
1627295968d1SFerruh Yigit #define DEV_TX_OFFLOAD_VXLAN_TNL_TSO        RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO
16284852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO      RTE_BIT64(10) /**< Used for tunneling packet. */
1629295968d1SFerruh Yigit #define DEV_TX_OFFLOAD_GRE_TNL_TSO          RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO
16304852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO     RTE_BIT64(11) /**< Used for tunneling packet. */
1631295968d1SFerruh Yigit #define DEV_TX_OFFLOAD_IPIP_TNL_TSO         RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO
16324852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO   RTE_BIT64(12) /**< Used for tunneling packet. */
1633295968d1SFerruh Yigit #define DEV_TX_OFFLOAD_GENEVE_TNL_TSO       RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO
16344852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_MACSEC_INSERT    RTE_BIT64(13)
1635295968d1SFerruh Yigit #define DEV_TX_OFFLOAD_MACSEC_INSERT        RTE_ETH_TX_OFFLOAD_MACSEC_INSERT
16363c2ca0a9SAndrew Rybchenko /**
16373c2ca0a9SAndrew Rybchenko  * Multiple threads can invoke rte_eth_tx_burst() concurrently on the same
163809fd4227SAndrew Rybchenko  * Tx queue without SW lock.
163999a2dd95SBruce Richardson  */
16404852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_MT_LOCKFREE      RTE_BIT64(14)
1641295968d1SFerruh Yigit #define DEV_TX_OFFLOAD_MT_LOCKFREE          RTE_ETH_TX_OFFLOAD_MT_LOCKFREE
16423c2ca0a9SAndrew Rybchenko /** Device supports multi segment send. */
16434852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_MULTI_SEGS       RTE_BIT64(15)
1644295968d1SFerruh Yigit #define DEV_TX_OFFLOAD_MULTI_SEGS           RTE_ETH_TX_OFFLOAD_MULTI_SEGS
16453c2ca0a9SAndrew Rybchenko /**
16463c2ca0a9SAndrew Rybchenko  * Device supports optimization for fast release of mbufs.
164799a2dd95SBruce Richardson  * When set application must guarantee that per-queue all mbufs comes from
164899a2dd95SBruce Richardson  * the same mempool and has refcnt = 1.
164999a2dd95SBruce Richardson  */
16504852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE   RTE_BIT64(16)
1651295968d1SFerruh Yigit #define DEV_TX_OFFLOAD_MBUF_FAST_FREE       RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE
16524852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_SECURITY         RTE_BIT64(17)
1653295968d1SFerruh Yigit #define DEV_TX_OFFLOAD_SECURITY             RTE_ETH_TX_OFFLOAD_SECURITY
165499a2dd95SBruce Richardson /**
165599a2dd95SBruce Richardson  * Device supports generic UDP tunneled packet TSO.
1656daa02b5cSOlivier Matz  * Application must set RTE_MBUF_F_TX_TUNNEL_UDP and other mbuf fields required
165799a2dd95SBruce Richardson  * for tunnel TSO.
165899a2dd95SBruce Richardson  */
16594852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO      RTE_BIT64(18)
1660295968d1SFerruh Yigit #define DEV_TX_OFFLOAD_UDP_TNL_TSO          RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO
166199a2dd95SBruce Richardson /**
166299a2dd95SBruce Richardson  * Device supports generic IP tunneled packet TSO.
1663daa02b5cSOlivier Matz  * Application must set RTE_MBUF_F_TX_TUNNEL_IP and other mbuf fields required
166499a2dd95SBruce Richardson  * for tunnel TSO.
166599a2dd95SBruce Richardson  */
16664852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_IP_TNL_TSO       RTE_BIT64(19)
1667295968d1SFerruh Yigit #define DEV_TX_OFFLOAD_IP_TNL_TSO           RTE_ETH_TX_OFFLOAD_IP_TNL_TSO
166899a2dd95SBruce Richardson /** Device supports outer UDP checksum */
16694852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM  RTE_BIT64(20)
1670295968d1SFerruh Yigit #define DEV_TX_OFFLOAD_OUTER_UDP_CKSUM      RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM
167199a2dd95SBruce Richardson /**
167299a2dd95SBruce Richardson  * Device sends on time read from RTE_MBUF_DYNFIELD_TIMESTAMP_NAME
167399a2dd95SBruce Richardson  * if RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME is set in ol_flags.
167499a2dd95SBruce Richardson  * The mbuf field and flag are registered when the offload is configured.
167599a2dd95SBruce Richardson  */
16764852c647SAndrew Rybchenko #define RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP RTE_BIT64(21)
1677295968d1SFerruh Yigit #define DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP     RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP
167899a2dd95SBruce Richardson /*
167999a2dd95SBruce Richardson  * If new Tx offload capabilities are defined, they also must be
168099a2dd95SBruce Richardson  * mentioned in rte_tx_offload_names in rte_ethdev.c file.
168199a2dd95SBruce Richardson  */
168299a2dd95SBruce Richardson 
168399a2dd95SBruce Richardson /**@{@name Device capabilities
168499a2dd95SBruce Richardson  * Non-offload capabilities reported in rte_eth_dev_info.dev_capa.
168599a2dd95SBruce Richardson  */
168699a2dd95SBruce Richardson /** Device supports Rx queue setup after device started. */
16874852c647SAndrew Rybchenko #define RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP RTE_BIT64(0)
168899a2dd95SBruce Richardson /** Device supports Tx queue setup after device started. */
16894852c647SAndrew Rybchenko #define RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP RTE_BIT64(1)
1690dd22740cSXueming Li /**
1691dd22740cSXueming Li  * Device supports shared Rx queue among ports within Rx domain and
1692dd22740cSXueming Li  * switch domain. Mbufs are consumed by shared Rx queue instead of
1693dd22740cSXueming Li  * each queue. Multiple groups are supported by share_group of Rx
1694dd22740cSXueming Li  * queue configuration. Shared Rx queue is identified by PMD using
1695dd22740cSXueming Li  * share_qid of Rx queue configuration. Polling any port in the group
1696dd22740cSXueming Li  * receive packets of all member ports, source port identified by
1697dd22740cSXueming Li  * mbuf->port field.
1698dd22740cSXueming Li  */
1699dd22740cSXueming Li #define RTE_ETH_DEV_CAPA_RXQ_SHARE              RTE_BIT64(2)
17001d5a3d68SDmitry Kozlyuk /** Device supports keeping flow rules across restart. */
17011d5a3d68SDmitry Kozlyuk #define RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP         RTE_BIT64(3)
17022c9cd45dSDmitry Kozlyuk /** Device supports keeping shared flow objects across restart. */
17032c9cd45dSDmitry Kozlyuk #define RTE_ETH_DEV_CAPA_FLOW_SHARED_OBJECT_KEEP RTE_BIT64(4)
170499a2dd95SBruce Richardson /**@}*/
170599a2dd95SBruce Richardson 
170699a2dd95SBruce Richardson /*
170799a2dd95SBruce Richardson  * Fallback default preferred Rx/Tx port parameters.
170899a2dd95SBruce Richardson  * These are used if an application requests default parameters
170999a2dd95SBruce Richardson  * but the PMD does not provide preferred values.
171099a2dd95SBruce Richardson  */
171199a2dd95SBruce Richardson #define RTE_ETH_DEV_FALLBACK_RX_RINGSIZE 512
171299a2dd95SBruce Richardson #define RTE_ETH_DEV_FALLBACK_TX_RINGSIZE 512
171399a2dd95SBruce Richardson #define RTE_ETH_DEV_FALLBACK_RX_NBQUEUES 1
171499a2dd95SBruce Richardson #define RTE_ETH_DEV_FALLBACK_TX_NBQUEUES 1
171599a2dd95SBruce Richardson 
171699a2dd95SBruce Richardson /**
171799a2dd95SBruce Richardson  * Preferred Rx/Tx port parameters.
171899a2dd95SBruce Richardson  * There are separate instances of this structure for transmission
171999a2dd95SBruce Richardson  * and reception respectively.
172099a2dd95SBruce Richardson  */
172199a2dd95SBruce Richardson struct rte_eth_dev_portconf {
172299a2dd95SBruce Richardson 	uint16_t burst_size; /**< Device-preferred burst size */
172399a2dd95SBruce Richardson 	uint16_t ring_size; /**< Device-preferred size of queue rings */
172499a2dd95SBruce Richardson 	uint16_t nb_queues; /**< Device-preferred number of queues */
172599a2dd95SBruce Richardson };
172699a2dd95SBruce Richardson 
172799a2dd95SBruce Richardson /**
17285906be5aSAndrew Rybchenko  * Default values for switch domain ID when ethdev does not support switch
172999a2dd95SBruce Richardson  * domain definitions.
173099a2dd95SBruce Richardson  */
173199a2dd95SBruce Richardson #define RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID	(UINT16_MAX)
173299a2dd95SBruce Richardson 
173399a2dd95SBruce Richardson /**
173499a2dd95SBruce Richardson  * Ethernet device associated switch information
173599a2dd95SBruce Richardson  */
173699a2dd95SBruce Richardson struct rte_eth_switch_info {
173799a2dd95SBruce Richardson 	const char *name;	/**< switch name */
17385906be5aSAndrew Rybchenko 	uint16_t domain_id;	/**< switch domain ID */
17393c2ca0a9SAndrew Rybchenko 	/**
17403c2ca0a9SAndrew Rybchenko 	 * Mapping to the devices physical switch port as enumerated from the
174199a2dd95SBruce Richardson 	 * perspective of the embedded interconnect/switch. For SR-IOV enabled
174299a2dd95SBruce Richardson 	 * device this may correspond to the VF_ID of each virtual function,
174399a2dd95SBruce Richardson 	 * but each driver should explicitly define the mapping of switch
174499a2dd95SBruce Richardson 	 * port identifier to that physical interconnect/switch
174599a2dd95SBruce Richardson 	 */
17463c2ca0a9SAndrew Rybchenko 	uint16_t port_id;
1747dd22740cSXueming Li 	/**
1748dd22740cSXueming Li 	 * Shared Rx queue sub-domain boundary. Only ports in same Rx domain
1749dd22740cSXueming Li 	 * and switch domain can share Rx queue. Valid only if device advertised
1750dd22740cSXueming Li 	 * RTE_ETH_DEV_CAPA_RXQ_SHARE capability.
1751dd22740cSXueming Li 	 */
1752dd22740cSXueming Li 	uint16_t rx_domain;
175399a2dd95SBruce Richardson };
175499a2dd95SBruce Richardson 
175599a2dd95SBruce Richardson /**
175699a2dd95SBruce Richardson  * @warning
175799a2dd95SBruce Richardson  * @b EXPERIMENTAL: this structure may change without prior notice.
175899a2dd95SBruce Richardson  *
175999a2dd95SBruce Richardson  * Ethernet device Rx buffer segmentation capabilities.
176099a2dd95SBruce Richardson  */
176199a2dd95SBruce Richardson struct rte_eth_rxseg_capa {
176299a2dd95SBruce Richardson 	__extension__
176399a2dd95SBruce Richardson 	uint32_t multi_pools:1; /**< Supports receiving to multiple pools.*/
176499a2dd95SBruce Richardson 	uint32_t offset_allowed:1; /**< Supports buffer offsets. */
176599a2dd95SBruce Richardson 	uint32_t offset_align_log2:4; /**< Required offset alignment. */
176699a2dd95SBruce Richardson 	uint16_t max_nseg; /**< Maximum amount of segments to split. */
176799a2dd95SBruce Richardson 	uint16_t reserved; /**< Reserved field. */
176899a2dd95SBruce Richardson };
176999a2dd95SBruce Richardson 
177099a2dd95SBruce Richardson /**
177199a2dd95SBruce Richardson  * Ethernet device information
177299a2dd95SBruce Richardson  */
177399a2dd95SBruce Richardson 
177499a2dd95SBruce Richardson /**
177599a2dd95SBruce Richardson  * Ethernet device representor port type.
177699a2dd95SBruce Richardson  */
177799a2dd95SBruce Richardson enum rte_eth_representor_type {
177899a2dd95SBruce Richardson 	RTE_ETH_REPRESENTOR_NONE, /**< not a representor. */
177999a2dd95SBruce Richardson 	RTE_ETH_REPRESENTOR_VF,   /**< representor of Virtual Function. */
178099a2dd95SBruce Richardson 	RTE_ETH_REPRESENTOR_SF,   /**< representor of Sub Function. */
178199a2dd95SBruce Richardson 	RTE_ETH_REPRESENTOR_PF,   /**< representor of Physical Function. */
178299a2dd95SBruce Richardson };
178399a2dd95SBruce Richardson 
178499a2dd95SBruce Richardson /**
178599a2dd95SBruce Richardson  * A structure used to retrieve the contextual information of
178699a2dd95SBruce Richardson  * an Ethernet device, such as the controlling driver of the
178799a2dd95SBruce Richardson  * device, etc...
178899a2dd95SBruce Richardson  */
178999a2dd95SBruce Richardson struct rte_eth_dev_info {
179099a2dd95SBruce Richardson 	struct rte_device *device; /** Generic device information */
179199a2dd95SBruce Richardson 	const char *driver_name; /**< Device Driver name. */
179299a2dd95SBruce Richardson 	unsigned int if_index; /**< Index to bound host interface, or 0 if none.
179399a2dd95SBruce Richardson 		Use if_indextoname() to translate into an interface name. */
179499a2dd95SBruce Richardson 	uint16_t min_mtu;	/**< Minimum MTU allowed */
179599a2dd95SBruce Richardson 	uint16_t max_mtu;	/**< Maximum MTU allowed */
179699a2dd95SBruce Richardson 	const uint32_t *dev_flags; /**< Device flags */
179709fd4227SAndrew Rybchenko 	uint32_t min_rx_bufsize; /**< Minimum size of Rx buffer. */
179809fd4227SAndrew Rybchenko 	uint32_t max_rx_pktlen; /**< Maximum configurable length of Rx pkt. */
179999a2dd95SBruce Richardson 	/** Maximum configurable size of LRO aggregated packet. */
180099a2dd95SBruce Richardson 	uint32_t max_lro_pkt_size;
180109fd4227SAndrew Rybchenko 	uint16_t max_rx_queues; /**< Maximum number of Rx queues. */
180209fd4227SAndrew Rybchenko 	uint16_t max_tx_queues; /**< Maximum number of Tx queues. */
180399a2dd95SBruce Richardson 	uint32_t max_mac_addrs; /**< Maximum number of MAC addresses. */
180499a2dd95SBruce Richardson 	uint32_t max_hash_mac_addrs;
180599a2dd95SBruce Richardson 	/** Maximum number of hash MAC addresses for MTA and UTA. */
180699a2dd95SBruce Richardson 	uint16_t max_vfs; /**< Maximum number of VFs. */
180799a2dd95SBruce Richardson 	uint16_t max_vmdq_pools; /**< Maximum number of VMDq pools. */
180899a2dd95SBruce Richardson 	struct rte_eth_rxseg_capa rx_seg_capa; /**< Segmentation capability.*/
180909fd4227SAndrew Rybchenko 	/** All Rx offload capabilities including all per-queue ones */
181099a2dd95SBruce Richardson 	uint64_t rx_offload_capa;
181109fd4227SAndrew Rybchenko 	/** All Tx offload capabilities including all per-queue ones */
181299a2dd95SBruce Richardson 	uint64_t tx_offload_capa;
181309fd4227SAndrew Rybchenko 	/** Device per-queue Rx offload capabilities. */
181499a2dd95SBruce Richardson 	uint64_t rx_queue_offload_capa;
181509fd4227SAndrew Rybchenko 	/** Device per-queue Tx offload capabilities. */
181699a2dd95SBruce Richardson 	uint64_t tx_queue_offload_capa;
18173c2ca0a9SAndrew Rybchenko 	/** Device redirection table size, the total number of entries. */
181899a2dd95SBruce Richardson 	uint16_t reta_size;
181999a2dd95SBruce Richardson 	uint8_t hash_key_size; /**< Hash key size in bytes */
182099a2dd95SBruce Richardson 	/** Bit mask of RSS offloads, the bit offset also means flow type */
182199a2dd95SBruce Richardson 	uint64_t flow_type_rss_offloads;
182209fd4227SAndrew Rybchenko 	struct rte_eth_rxconf default_rxconf; /**< Default Rx configuration */
182309fd4227SAndrew Rybchenko 	struct rte_eth_txconf default_txconf; /**< Default Tx configuration */
1824064e90c4SAndrew Rybchenko 	uint16_t vmdq_queue_base; /**< First queue ID for VMDq pools. */
1825064e90c4SAndrew Rybchenko 	uint16_t vmdq_queue_num;  /**< Queue number for VMDq pools. */
1826064e90c4SAndrew Rybchenko 	uint16_t vmdq_pool_base;  /**< First ID of VMDq pools. */
182709fd4227SAndrew Rybchenko 	struct rte_eth_desc_lim rx_desc_lim;  /**< Rx descriptors limits */
182809fd4227SAndrew Rybchenko 	struct rte_eth_desc_lim tx_desc_lim;  /**< Tx descriptors limits */
1829295968d1SFerruh Yigit 	uint32_t speed_capa;  /**< Supported speeds bitmap (RTE_ETH_LINK_SPEED_). */
183009fd4227SAndrew Rybchenko 	/** Configured number of Rx/Tx queues */
183109fd4227SAndrew Rybchenko 	uint16_t nb_rx_queues; /**< Number of Rx queues. */
183209fd4227SAndrew Rybchenko 	uint16_t nb_tx_queues; /**< Number of Tx queues. */
183399a2dd95SBruce Richardson 	/** Rx parameter recommendations */
183499a2dd95SBruce Richardson 	struct rte_eth_dev_portconf default_rxportconf;
183599a2dd95SBruce Richardson 	/** Tx parameter recommendations */
183699a2dd95SBruce Richardson 	struct rte_eth_dev_portconf default_txportconf;
183799a2dd95SBruce Richardson 	/** Generic device capabilities (RTE_ETH_DEV_CAPA_). */
183899a2dd95SBruce Richardson 	uint64_t dev_capa;
183999a2dd95SBruce Richardson 	/**
184099a2dd95SBruce Richardson 	 * Switching information for ports on a device with a
184199a2dd95SBruce Richardson 	 * embedded managed interconnect/switch.
184299a2dd95SBruce Richardson 	 */
184399a2dd95SBruce Richardson 	struct rte_eth_switch_info switch_info;
184499a2dd95SBruce Richardson 
184599a2dd95SBruce Richardson 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
184699a2dd95SBruce Richardson 	void *reserved_ptrs[2];   /**< Reserved for future fields */
184799a2dd95SBruce Richardson };
184899a2dd95SBruce Richardson 
18490ce56b05SThomas Monjalon /**@{@name Rx/Tx queue states */
18500ce56b05SThomas Monjalon #define RTE_ETH_QUEUE_STATE_STOPPED 0 /**< Queue stopped. */
18510ce56b05SThomas Monjalon #define RTE_ETH_QUEUE_STATE_STARTED 1 /**< Queue started. */
18520ce56b05SThomas Monjalon #define RTE_ETH_QUEUE_STATE_HAIRPIN 2 /**< Queue used for hairpin. */
18530ce56b05SThomas Monjalon /**@}*/
18549ad9ff47SLijun Ou 
18559ad9ff47SLijun Ou /**
185609fd4227SAndrew Rybchenko  * Ethernet device Rx queue information structure.
185799a2dd95SBruce Richardson  * Used to retrieve information about configured queue.
185899a2dd95SBruce Richardson  */
185999a2dd95SBruce Richardson struct rte_eth_rxq_info {
186099a2dd95SBruce Richardson 	struct rte_mempool *mp;     /**< mempool used by that queue. */
186199a2dd95SBruce Richardson 	struct rte_eth_rxconf conf; /**< queue config parameters. */
186209fd4227SAndrew Rybchenko 	uint8_t scattered_rx;       /**< scattered packets Rx supported. */
18639ad9ff47SLijun Ou 	uint8_t queue_state;        /**< one of RTE_ETH_QUEUE_STATE_*. */
186499a2dd95SBruce Richardson 	uint16_t nb_desc;           /**< configured number of RXDs. */
186599a2dd95SBruce Richardson 	uint16_t rx_buf_size;       /**< hardware receive buffer size. */
186699a2dd95SBruce Richardson } __rte_cache_min_aligned;
186799a2dd95SBruce Richardson 
186899a2dd95SBruce Richardson /**
186909fd4227SAndrew Rybchenko  * Ethernet device Tx queue information structure.
187099a2dd95SBruce Richardson  * Used to retrieve information about configured queue.
187199a2dd95SBruce Richardson  */
187299a2dd95SBruce Richardson struct rte_eth_txq_info {
187399a2dd95SBruce Richardson 	struct rte_eth_txconf conf; /**< queue config parameters. */
187499a2dd95SBruce Richardson 	uint16_t nb_desc;           /**< configured number of TXDs. */
18759ad9ff47SLijun Ou 	uint8_t queue_state;        /**< one of RTE_ETH_QUEUE_STATE_*. */
187699a2dd95SBruce Richardson } __rte_cache_min_aligned;
187799a2dd95SBruce Richardson 
187899a2dd95SBruce Richardson /* Generic Burst mode flag definition, values can be ORed. */
187999a2dd95SBruce Richardson 
188099a2dd95SBruce Richardson /**
188199a2dd95SBruce Richardson  * If the queues have different burst mode description, this bit will be set
188299a2dd95SBruce Richardson  * by PMD, then the application can iterate to retrieve burst description for
188399a2dd95SBruce Richardson  * all other queues.
188499a2dd95SBruce Richardson  */
1885e1823e08SThomas Monjalon #define RTE_ETH_BURST_FLAG_PER_QUEUE RTE_BIT64(0)
188699a2dd95SBruce Richardson 
188799a2dd95SBruce Richardson /**
188809fd4227SAndrew Rybchenko  * Ethernet device Rx/Tx queue packet burst mode information structure.
188999a2dd95SBruce Richardson  * Used to retrieve information about packet burst mode setting.
189099a2dd95SBruce Richardson  */
189199a2dd95SBruce Richardson struct rte_eth_burst_mode {
189299a2dd95SBruce Richardson 	uint64_t flags; /**< The ORed values of RTE_ETH_BURST_FLAG_xxx */
189399a2dd95SBruce Richardson 
189499a2dd95SBruce Richardson #define RTE_ETH_BURST_MODE_INFO_SIZE 1024 /**< Maximum size for information */
189599a2dd95SBruce Richardson 	char info[RTE_ETH_BURST_MODE_INFO_SIZE]; /**< burst mode information */
189699a2dd95SBruce Richardson };
189799a2dd95SBruce Richardson 
189899a2dd95SBruce Richardson /** Maximum name length for extended statistics counters */
189999a2dd95SBruce Richardson #define RTE_ETH_XSTATS_NAME_SIZE 64
190099a2dd95SBruce Richardson 
190199a2dd95SBruce Richardson /**
190299a2dd95SBruce Richardson  * An Ethernet device extended statistic structure
190399a2dd95SBruce Richardson  *
190499a2dd95SBruce Richardson  * This structure is used by rte_eth_xstats_get() to provide
190599a2dd95SBruce Richardson  * statistics that are not provided in the generic *rte_eth_stats*
190699a2dd95SBruce Richardson  * structure.
19075906be5aSAndrew Rybchenko  * It maps a name ID, corresponding to an index in the array returned
190899a2dd95SBruce Richardson  * by rte_eth_xstats_get_names(), to a statistic value.
190999a2dd95SBruce Richardson  */
191099a2dd95SBruce Richardson struct rte_eth_xstat {
191199a2dd95SBruce Richardson 	uint64_t id;        /**< The index in xstats name array. */
191299a2dd95SBruce Richardson 	uint64_t value;     /**< The statistic counter value. */
191399a2dd95SBruce Richardson };
191499a2dd95SBruce Richardson 
191599a2dd95SBruce Richardson /**
191699a2dd95SBruce Richardson  * A name element for extended statistics.
191799a2dd95SBruce Richardson  *
191899a2dd95SBruce Richardson  * An array of this structure is returned by rte_eth_xstats_get_names().
191999a2dd95SBruce Richardson  * It lists the names of extended statistics for a PMD. The *rte_eth_xstat*
192099a2dd95SBruce Richardson  * structure references these names by their array index.
192199a2dd95SBruce Richardson  *
192299a2dd95SBruce Richardson  * The xstats should follow a common naming scheme.
192399a2dd95SBruce Richardson  * Some names are standardized in rte_stats_strings.
192499a2dd95SBruce Richardson  * Examples:
192599a2dd95SBruce Richardson  *     - rx_missed_errors
192699a2dd95SBruce Richardson  *     - tx_q3_bytes
192799a2dd95SBruce Richardson  *     - tx_size_128_to_255_packets
192899a2dd95SBruce Richardson  */
192999a2dd95SBruce Richardson struct rte_eth_xstat_name {
193099a2dd95SBruce Richardson 	char name[RTE_ETH_XSTATS_NAME_SIZE]; /**< The statistic name. */
193199a2dd95SBruce Richardson };
193299a2dd95SBruce Richardson 
1933295968d1SFerruh Yigit #define RTE_ETH_DCB_NUM_TCS    8
1934295968d1SFerruh Yigit #define ETH_DCB_NUM_TCS        RTE_ETH_DCB_NUM_TCS
1935295968d1SFerruh Yigit #define RTE_ETH_MAX_VMDQ_POOL  64
1936295968d1SFerruh Yigit #define ETH_MAX_VMDQ_POOL      RTE_ETH_MAX_VMDQ_POOL
193799a2dd95SBruce Richardson 
193899a2dd95SBruce Richardson /**
193999a2dd95SBruce Richardson  * A structure used to get the information of queue and
194009fd4227SAndrew Rybchenko  * TC mapping on both Tx and Rx paths.
194199a2dd95SBruce Richardson  */
194299a2dd95SBruce Richardson struct rte_eth_dcb_tc_queue_mapping {
194309fd4227SAndrew Rybchenko 	/** Rx queues assigned to tc per Pool */
194499a2dd95SBruce Richardson 	struct {
194599a2dd95SBruce Richardson 		uint16_t base;
194699a2dd95SBruce Richardson 		uint16_t nb_queue;
1947295968d1SFerruh Yigit 	} tc_rxq[RTE_ETH_MAX_VMDQ_POOL][RTE_ETH_DCB_NUM_TCS];
194809fd4227SAndrew Rybchenko 	/** Rx queues assigned to tc per Pool */
194999a2dd95SBruce Richardson 	struct {
195099a2dd95SBruce Richardson 		uint16_t base;
195199a2dd95SBruce Richardson 		uint16_t nb_queue;
1952295968d1SFerruh Yigit 	} tc_txq[RTE_ETH_MAX_VMDQ_POOL][RTE_ETH_DCB_NUM_TCS];
195399a2dd95SBruce Richardson };
195499a2dd95SBruce Richardson 
195599a2dd95SBruce Richardson /**
195699a2dd95SBruce Richardson  * A structure used to get the information of DCB.
195799a2dd95SBruce Richardson  * It includes TC UP mapping and queue TC mapping.
195899a2dd95SBruce Richardson  */
195999a2dd95SBruce Richardson struct rte_eth_dcb_info {
196099a2dd95SBruce Richardson 	uint8_t nb_tcs;        /**< number of TCs */
1961295968d1SFerruh Yigit 	uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES]; /**< Priority to tc */
1962295968d1SFerruh Yigit 	uint8_t tc_bws[RTE_ETH_DCB_NUM_TCS]; /**< Tx BW percentage for each TC */
196309fd4227SAndrew Rybchenko 	/** Rx queues assigned to tc */
196499a2dd95SBruce Richardson 	struct rte_eth_dcb_tc_queue_mapping tc_queue;
196599a2dd95SBruce Richardson };
196699a2dd95SBruce Richardson 
196799a2dd95SBruce Richardson /**
196899a2dd95SBruce Richardson  * This enum indicates the possible Forward Error Correction (FEC) modes
196999a2dd95SBruce Richardson  * of an ethdev port.
197099a2dd95SBruce Richardson  */
197199a2dd95SBruce Richardson enum rte_eth_fec_mode {
197299a2dd95SBruce Richardson 	RTE_ETH_FEC_NOFEC = 0,      /**< FEC is off */
197399a2dd95SBruce Richardson 	RTE_ETH_FEC_AUTO,	    /**< FEC autonegotiation modes */
197499a2dd95SBruce Richardson 	RTE_ETH_FEC_BASER,          /**< FEC using common algorithm */
197599a2dd95SBruce Richardson 	RTE_ETH_FEC_RS,             /**< FEC using RS algorithm */
197699a2dd95SBruce Richardson };
197799a2dd95SBruce Richardson 
197899a2dd95SBruce Richardson /* Translate from FEC mode to FEC capa */
1979e1823e08SThomas Monjalon #define RTE_ETH_FEC_MODE_TO_CAPA(x) RTE_BIT32(x)
198099a2dd95SBruce Richardson 
198199a2dd95SBruce Richardson /* This macro indicates FEC capa mask */
1982e1823e08SThomas Monjalon #define RTE_ETH_FEC_MODE_CAPA_MASK(x) RTE_BIT32(RTE_ETH_FEC_ ## x)
198399a2dd95SBruce Richardson 
198499a2dd95SBruce Richardson /* A structure used to get capabilities per link speed */
198599a2dd95SBruce Richardson struct rte_eth_fec_capa {
1986295968d1SFerruh Yigit 	uint32_t speed; /**< Link speed (see RTE_ETH_SPEED_NUM_*) */
198799a2dd95SBruce Richardson 	uint32_t capa;  /**< FEC capabilities bitmask */
198899a2dd95SBruce Richardson };
198999a2dd95SBruce Richardson 
199099a2dd95SBruce Richardson #define RTE_ETH_ALL RTE_MAX_ETHPORTS
199199a2dd95SBruce Richardson 
199299a2dd95SBruce Richardson /* Macros to check for valid port */
199399a2dd95SBruce Richardson #define RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, retval) do { \
199499a2dd95SBruce Richardson 	if (!rte_eth_dev_is_valid_port(port_id)) { \
199599a2dd95SBruce Richardson 		RTE_ETHDEV_LOG(ERR, "Invalid port_id=%u\n", port_id); \
199699a2dd95SBruce Richardson 		return retval; \
199799a2dd95SBruce Richardson 	} \
199899a2dd95SBruce Richardson } while (0)
199999a2dd95SBruce Richardson 
200099a2dd95SBruce Richardson #define RTE_ETH_VALID_PORTID_OR_RET(port_id) do { \
200199a2dd95SBruce Richardson 	if (!rte_eth_dev_is_valid_port(port_id)) { \
200299a2dd95SBruce Richardson 		RTE_ETHDEV_LOG(ERR, "Invalid port_id=%u\n", port_id); \
200399a2dd95SBruce Richardson 		return; \
200499a2dd95SBruce Richardson 	} \
200599a2dd95SBruce Richardson } while (0)
200699a2dd95SBruce Richardson 
200799a2dd95SBruce Richardson /**
200809fd4227SAndrew Rybchenko  * Function type used for Rx packet processing packet callbacks.
200999a2dd95SBruce Richardson  *
201009fd4227SAndrew Rybchenko  * The callback function is called on Rx with a burst of packets that have
201199a2dd95SBruce Richardson  * been received on the given port and queue.
201299a2dd95SBruce Richardson  *
201399a2dd95SBruce Richardson  * @param port_id
201409fd4227SAndrew Rybchenko  *   The Ethernet port on which Rx is being performed.
201599a2dd95SBruce Richardson  * @param queue
201699a2dd95SBruce Richardson  *   The queue on the Ethernet port which is being used to receive the packets.
201799a2dd95SBruce Richardson  * @param pkts
201899a2dd95SBruce Richardson  *   The burst of packets that have just been received.
201999a2dd95SBruce Richardson  * @param nb_pkts
202099a2dd95SBruce Richardson  *   The number of packets in the burst pointed to by "pkts".
202199a2dd95SBruce Richardson  * @param max_pkts
202299a2dd95SBruce Richardson  *   The max number of packets that can be stored in the "pkts" array.
202399a2dd95SBruce Richardson  * @param user_param
202499a2dd95SBruce Richardson  *   The arbitrary user parameter passed in by the application when the callback
202599a2dd95SBruce Richardson  *   was originally configured.
202699a2dd95SBruce Richardson  * @return
202799a2dd95SBruce Richardson  *   The number of packets returned to the user.
202899a2dd95SBruce Richardson  */
202999a2dd95SBruce Richardson typedef uint16_t (*rte_rx_callback_fn)(uint16_t port_id, uint16_t queue,
203099a2dd95SBruce Richardson 	struct rte_mbuf *pkts[], uint16_t nb_pkts, uint16_t max_pkts,
203199a2dd95SBruce Richardson 	void *user_param);
203299a2dd95SBruce Richardson 
203399a2dd95SBruce Richardson /**
203409fd4227SAndrew Rybchenko  * Function type used for Tx packet processing packet callbacks.
203599a2dd95SBruce Richardson  *
203609fd4227SAndrew Rybchenko  * The callback function is called on Tx with a burst of packets immediately
203799a2dd95SBruce Richardson  * before the packets are put onto the hardware queue for transmission.
203899a2dd95SBruce Richardson  *
203999a2dd95SBruce Richardson  * @param port_id
204009fd4227SAndrew Rybchenko  *   The Ethernet port on which Tx is being performed.
204199a2dd95SBruce Richardson  * @param queue
204299a2dd95SBruce Richardson  *   The queue on the Ethernet port which is being used to transmit the packets.
204399a2dd95SBruce Richardson  * @param pkts
204499a2dd95SBruce Richardson  *   The burst of packets that are about to be transmitted.
204599a2dd95SBruce Richardson  * @param nb_pkts
204699a2dd95SBruce Richardson  *   The number of packets in the burst pointed to by "pkts".
204799a2dd95SBruce Richardson  * @param user_param
204899a2dd95SBruce Richardson  *   The arbitrary user parameter passed in by the application when the callback
204999a2dd95SBruce Richardson  *   was originally configured.
205099a2dd95SBruce Richardson  * @return
205199a2dd95SBruce Richardson  *   The number of packets to be written to the NIC.
205299a2dd95SBruce Richardson  */
205399a2dd95SBruce Richardson typedef uint16_t (*rte_tx_callback_fn)(uint16_t port_id, uint16_t queue,
205499a2dd95SBruce Richardson 	struct rte_mbuf *pkts[], uint16_t nb_pkts, void *user_param);
205599a2dd95SBruce Richardson 
205699a2dd95SBruce Richardson /**
205799a2dd95SBruce Richardson  * Possible states of an ethdev port.
205899a2dd95SBruce Richardson  */
205999a2dd95SBruce Richardson enum rte_eth_dev_state {
206099a2dd95SBruce Richardson 	/** Device is unused before being probed. */
206199a2dd95SBruce Richardson 	RTE_ETH_DEV_UNUSED = 0,
206299a2dd95SBruce Richardson 	/** Device is attached when allocated in probing. */
206399a2dd95SBruce Richardson 	RTE_ETH_DEV_ATTACHED,
206499a2dd95SBruce Richardson 	/** Device is in removed state when plug-out is detected. */
206599a2dd95SBruce Richardson 	RTE_ETH_DEV_REMOVED,
206699a2dd95SBruce Richardson };
206799a2dd95SBruce Richardson 
206899a2dd95SBruce Richardson struct rte_eth_dev_sriov {
206999a2dd95SBruce Richardson 	uint8_t active;               /**< SRIOV is active with 16, 32 or 64 pools */
207009fd4227SAndrew Rybchenko 	uint8_t nb_q_per_pool;        /**< Rx queue number per pool */
207199a2dd95SBruce Richardson 	uint16_t def_vmdq_idx;        /**< Default pool num used for PF */
207299a2dd95SBruce Richardson 	uint16_t def_pool_q_idx;      /**< Default pool queue start reg index */
207399a2dd95SBruce Richardson };
207499a2dd95SBruce Richardson #define RTE_ETH_DEV_SRIOV(dev)         ((dev)->data->sriov)
207599a2dd95SBruce Richardson 
207699a2dd95SBruce Richardson #define RTE_ETH_NAME_MAX_LEN RTE_DEV_NAME_MAX_LEN
207799a2dd95SBruce Richardson 
207899a2dd95SBruce Richardson #define RTE_ETH_DEV_NO_OWNER 0
207999a2dd95SBruce Richardson 
208099a2dd95SBruce Richardson #define RTE_ETH_MAX_OWNER_NAME_LEN 64
208199a2dd95SBruce Richardson 
208299a2dd95SBruce Richardson struct rte_eth_dev_owner {
208399a2dd95SBruce Richardson 	uint64_t id; /**< The owner unique identifier. */
208499a2dd95SBruce Richardson 	char name[RTE_ETH_MAX_OWNER_NAME_LEN]; /**< The owner name. */
208599a2dd95SBruce Richardson };
208699a2dd95SBruce Richardson 
20870ce56b05SThomas Monjalon /**@{@name Device flags
20880ce56b05SThomas Monjalon  * Flags internally saved in rte_eth_dev_data.dev_flags
20890ce56b05SThomas Monjalon  * and reported in rte_eth_dev_info.dev_flags.
20900ce56b05SThomas Monjalon  */
209199a2dd95SBruce Richardson /** PMD supports thread-safe flow operations */
20924852c647SAndrew Rybchenko #define RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE  RTE_BIT32(0)
209399a2dd95SBruce Richardson /** Device supports link state interrupt */
20944852c647SAndrew Rybchenko #define RTE_ETH_DEV_INTR_LSC              RTE_BIT32(1)
209599a2dd95SBruce Richardson /** Device is a bonded slave */
20964852c647SAndrew Rybchenko #define RTE_ETH_DEV_BONDED_SLAVE          RTE_BIT32(2)
209799a2dd95SBruce Richardson /** Device supports device removal interrupt */
20984852c647SAndrew Rybchenko #define RTE_ETH_DEV_INTR_RMV              RTE_BIT32(3)
209999a2dd95SBruce Richardson /** Device is port representor */
21004852c647SAndrew Rybchenko #define RTE_ETH_DEV_REPRESENTOR           RTE_BIT32(4)
210199a2dd95SBruce Richardson /** Device does not support MAC change after started */
21024852c647SAndrew Rybchenko #define RTE_ETH_DEV_NOLIVE_MAC_ADDR       RTE_BIT32(5)
210399a2dd95SBruce Richardson /**
210499a2dd95SBruce Richardson  * Queue xstats filled automatically by ethdev layer.
210599a2dd95SBruce Richardson  * PMDs filling the queue xstats themselves should not set this flag
210699a2dd95SBruce Richardson  */
21074852c647SAndrew Rybchenko #define RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS RTE_BIT32(6)
21080ce56b05SThomas Monjalon /**@}*/
210999a2dd95SBruce Richardson 
211099a2dd95SBruce Richardson /**
211199a2dd95SBruce Richardson  * Iterates over valid ethdev ports owned by a specific owner.
211299a2dd95SBruce Richardson  *
211399a2dd95SBruce Richardson  * @param port_id
21145906be5aSAndrew Rybchenko  *   The ID of the next possible valid owned port.
211599a2dd95SBruce Richardson  * @param	owner_id
211699a2dd95SBruce Richardson  *  The owner identifier.
211799a2dd95SBruce Richardson  *  RTE_ETH_DEV_NO_OWNER means iterate over all valid ownerless ports.
211899a2dd95SBruce Richardson  * @return
21195906be5aSAndrew Rybchenko  *   Next valid port ID owned by owner_id, RTE_MAX_ETHPORTS if there is none.
212099a2dd95SBruce Richardson  */
212199a2dd95SBruce Richardson uint64_t rte_eth_find_next_owned_by(uint16_t port_id,
212299a2dd95SBruce Richardson 		const uint64_t owner_id);
212399a2dd95SBruce Richardson 
212499a2dd95SBruce Richardson /**
212599a2dd95SBruce Richardson  * Macro to iterate over all enabled ethdev ports owned by a specific owner.
212699a2dd95SBruce Richardson  */
212799a2dd95SBruce Richardson #define RTE_ETH_FOREACH_DEV_OWNED_BY(p, o) \
212899a2dd95SBruce Richardson 	for (p = rte_eth_find_next_owned_by(0, o); \
212999a2dd95SBruce Richardson 	     (unsigned int)p < (unsigned int)RTE_MAX_ETHPORTS; \
213099a2dd95SBruce Richardson 	     p = rte_eth_find_next_owned_by(p + 1, o))
213199a2dd95SBruce Richardson 
213299a2dd95SBruce Richardson /**
213399a2dd95SBruce Richardson  * Iterates over valid ethdev ports.
213499a2dd95SBruce Richardson  *
213599a2dd95SBruce Richardson  * @param port_id
21365906be5aSAndrew Rybchenko  *   The ID of the next possible valid port.
213799a2dd95SBruce Richardson  * @return
21385906be5aSAndrew Rybchenko  *   Next valid port ID, RTE_MAX_ETHPORTS if there is none.
213999a2dd95SBruce Richardson  */
214099a2dd95SBruce Richardson uint16_t rte_eth_find_next(uint16_t port_id);
214199a2dd95SBruce Richardson 
214299a2dd95SBruce Richardson /**
214399a2dd95SBruce Richardson  * Macro to iterate over all enabled and ownerless ethdev ports.
214499a2dd95SBruce Richardson  */
214599a2dd95SBruce Richardson #define RTE_ETH_FOREACH_DEV(p) \
214699a2dd95SBruce Richardson 	RTE_ETH_FOREACH_DEV_OWNED_BY(p, RTE_ETH_DEV_NO_OWNER)
214799a2dd95SBruce Richardson 
214899a2dd95SBruce Richardson /**
214999a2dd95SBruce Richardson  * Iterates over ethdev ports of a specified device.
215099a2dd95SBruce Richardson  *
215199a2dd95SBruce Richardson  * @param port_id_start
21525906be5aSAndrew Rybchenko  *   The ID of the next possible valid port.
215399a2dd95SBruce Richardson  * @param parent
215499a2dd95SBruce Richardson  *   The generic device behind the ports to iterate.
215599a2dd95SBruce Richardson  * @return
21565906be5aSAndrew Rybchenko  *   Next port ID of the device, possibly port_id_start,
215799a2dd95SBruce Richardson  *   RTE_MAX_ETHPORTS if there is none.
215899a2dd95SBruce Richardson  */
215999a2dd95SBruce Richardson uint16_t
216099a2dd95SBruce Richardson rte_eth_find_next_of(uint16_t port_id_start,
216199a2dd95SBruce Richardson 		const struct rte_device *parent);
216299a2dd95SBruce Richardson 
216399a2dd95SBruce Richardson /**
216499a2dd95SBruce Richardson  * Macro to iterate over all ethdev ports of a specified device.
216599a2dd95SBruce Richardson  *
216699a2dd95SBruce Richardson  * @param port_id
21675906be5aSAndrew Rybchenko  *   The ID of the matching port being iterated.
216899a2dd95SBruce Richardson  * @param parent
216999a2dd95SBruce Richardson  *   The rte_device pointer matching the iterated ports.
217099a2dd95SBruce Richardson  */
217199a2dd95SBruce Richardson #define RTE_ETH_FOREACH_DEV_OF(port_id, parent) \
217299a2dd95SBruce Richardson 	for (port_id = rte_eth_find_next_of(0, parent); \
217399a2dd95SBruce Richardson 		port_id < RTE_MAX_ETHPORTS; \
217499a2dd95SBruce Richardson 		port_id = rte_eth_find_next_of(port_id + 1, parent))
217599a2dd95SBruce Richardson 
217699a2dd95SBruce Richardson /**
217799a2dd95SBruce Richardson  * Iterates over sibling ethdev ports (i.e. sharing the same rte_device).
217899a2dd95SBruce Richardson  *
217999a2dd95SBruce Richardson  * @param port_id_start
21805906be5aSAndrew Rybchenko  *   The ID of the next possible valid sibling port.
218199a2dd95SBruce Richardson  * @param ref_port_id
21825906be5aSAndrew Rybchenko  *   The ID of a reference port to compare rte_device with.
218399a2dd95SBruce Richardson  * @return
21845906be5aSAndrew Rybchenko  *   Next sibling port ID, possibly port_id_start or ref_port_id itself,
218599a2dd95SBruce Richardson  *   RTE_MAX_ETHPORTS if there is none.
218699a2dd95SBruce Richardson  */
218799a2dd95SBruce Richardson uint16_t
218899a2dd95SBruce Richardson rte_eth_find_next_sibling(uint16_t port_id_start, uint16_t ref_port_id);
218999a2dd95SBruce Richardson 
219099a2dd95SBruce Richardson /**
219199a2dd95SBruce Richardson  * Macro to iterate over all ethdev ports sharing the same rte_device
219299a2dd95SBruce Richardson  * as the specified port.
219399a2dd95SBruce Richardson  * Note: the specified reference port is part of the loop iterations.
219499a2dd95SBruce Richardson  *
219599a2dd95SBruce Richardson  * @param port_id
21965906be5aSAndrew Rybchenko  *   The ID of the matching port being iterated.
219799a2dd95SBruce Richardson  * @param ref_port_id
21985906be5aSAndrew Rybchenko  *   The ID of the port being compared.
219999a2dd95SBruce Richardson  */
220099a2dd95SBruce Richardson #define RTE_ETH_FOREACH_DEV_SIBLING(port_id, ref_port_id) \
220199a2dd95SBruce Richardson 	for (port_id = rte_eth_find_next_sibling(0, ref_port_id); \
220299a2dd95SBruce Richardson 		port_id < RTE_MAX_ETHPORTS; \
220399a2dd95SBruce Richardson 		port_id = rte_eth_find_next_sibling(port_id + 1, ref_port_id))
220499a2dd95SBruce Richardson 
220599a2dd95SBruce Richardson /**
220699a2dd95SBruce Richardson  * @warning
220799a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
220899a2dd95SBruce Richardson  *
220999a2dd95SBruce Richardson  * Get a new unique owner identifier.
221099a2dd95SBruce Richardson  * An owner identifier is used to owns Ethernet devices by only one DPDK entity
221199a2dd95SBruce Richardson  * to avoid multiple management of device by different entities.
221299a2dd95SBruce Richardson  *
221399a2dd95SBruce Richardson  * @param	owner_id
221499a2dd95SBruce Richardson  *   Owner identifier pointer.
221599a2dd95SBruce Richardson  * @return
221699a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
221799a2dd95SBruce Richardson  */
221899a2dd95SBruce Richardson __rte_experimental
221999a2dd95SBruce Richardson int rte_eth_dev_owner_new(uint64_t *owner_id);
222099a2dd95SBruce Richardson 
222199a2dd95SBruce Richardson /**
222299a2dd95SBruce Richardson  * @warning
222399a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
222499a2dd95SBruce Richardson  *
222599a2dd95SBruce Richardson  * Set an Ethernet device owner.
222699a2dd95SBruce Richardson  *
222799a2dd95SBruce Richardson  * @param	port_id
222899a2dd95SBruce Richardson  *  The identifier of the port to own.
222999a2dd95SBruce Richardson  * @param	owner
223099a2dd95SBruce Richardson  *  The owner pointer.
223199a2dd95SBruce Richardson  * @return
223299a2dd95SBruce Richardson  *  Negative errno value on error, 0 on success.
223399a2dd95SBruce Richardson  */
223499a2dd95SBruce Richardson __rte_experimental
223599a2dd95SBruce Richardson int rte_eth_dev_owner_set(const uint16_t port_id,
223699a2dd95SBruce Richardson 		const struct rte_eth_dev_owner *owner);
223799a2dd95SBruce Richardson 
223899a2dd95SBruce Richardson /**
223999a2dd95SBruce Richardson  * @warning
224099a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
224199a2dd95SBruce Richardson  *
224299a2dd95SBruce Richardson  * Unset Ethernet device owner to make the device ownerless.
224399a2dd95SBruce Richardson  *
224499a2dd95SBruce Richardson  * @param	port_id
224599a2dd95SBruce Richardson  *  The identifier of port to make ownerless.
224699a2dd95SBruce Richardson  * @param	owner_id
224799a2dd95SBruce Richardson  *  The owner identifier.
224899a2dd95SBruce Richardson  * @return
224999a2dd95SBruce Richardson  *  0 on success, negative errno value on error.
225099a2dd95SBruce Richardson  */
225199a2dd95SBruce Richardson __rte_experimental
225299a2dd95SBruce Richardson int rte_eth_dev_owner_unset(const uint16_t port_id,
225399a2dd95SBruce Richardson 		const uint64_t owner_id);
225499a2dd95SBruce Richardson 
225599a2dd95SBruce Richardson /**
225699a2dd95SBruce Richardson  * @warning
225799a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
225899a2dd95SBruce Richardson  *
225999a2dd95SBruce Richardson  * Remove owner from all Ethernet devices owned by a specific owner.
226099a2dd95SBruce Richardson  *
226199a2dd95SBruce Richardson  * @param	owner_id
226299a2dd95SBruce Richardson  *  The owner identifier.
226399a2dd95SBruce Richardson  * @return
226499a2dd95SBruce Richardson  *  0 on success, negative errno value on error.
226599a2dd95SBruce Richardson  */
226699a2dd95SBruce Richardson __rte_experimental
226799a2dd95SBruce Richardson int rte_eth_dev_owner_delete(const uint64_t owner_id);
226899a2dd95SBruce Richardson 
226999a2dd95SBruce Richardson /**
227099a2dd95SBruce Richardson  * @warning
227199a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
227299a2dd95SBruce Richardson  *
227399a2dd95SBruce Richardson  * Get the owner of an Ethernet device.
227499a2dd95SBruce Richardson  *
227599a2dd95SBruce Richardson  * @param	port_id
227699a2dd95SBruce Richardson  *  The port identifier.
227799a2dd95SBruce Richardson  * @param	owner
227899a2dd95SBruce Richardson  *  The owner structure pointer to fill.
227999a2dd95SBruce Richardson  * @return
228099a2dd95SBruce Richardson  *  0 on success, negative errno value on error..
228199a2dd95SBruce Richardson  */
228299a2dd95SBruce Richardson __rte_experimental
228399a2dd95SBruce Richardson int rte_eth_dev_owner_get(const uint16_t port_id,
228499a2dd95SBruce Richardson 		struct rte_eth_dev_owner *owner);
228599a2dd95SBruce Richardson 
228699a2dd95SBruce Richardson /**
228799a2dd95SBruce Richardson  * Get the number of ports which are usable for the application.
228899a2dd95SBruce Richardson  *
228999a2dd95SBruce Richardson  * These devices must be iterated by using the macro
229099a2dd95SBruce Richardson  * ``RTE_ETH_FOREACH_DEV`` or ``RTE_ETH_FOREACH_DEV_OWNED_BY``
229199a2dd95SBruce Richardson  * to deal with non-contiguous ranges of devices.
229299a2dd95SBruce Richardson  *
229399a2dd95SBruce Richardson  * @return
229499a2dd95SBruce Richardson  *   The count of available Ethernet devices.
229599a2dd95SBruce Richardson  */
229699a2dd95SBruce Richardson uint16_t rte_eth_dev_count_avail(void);
229799a2dd95SBruce Richardson 
229899a2dd95SBruce Richardson /**
229999a2dd95SBruce Richardson  * Get the total number of ports which are allocated.
230099a2dd95SBruce Richardson  *
230199a2dd95SBruce Richardson  * Some devices may not be available for the application.
230299a2dd95SBruce Richardson  *
230399a2dd95SBruce Richardson  * @return
230499a2dd95SBruce Richardson  *   The total count of Ethernet devices.
230599a2dd95SBruce Richardson  */
230699a2dd95SBruce Richardson uint16_t rte_eth_dev_count_total(void);
230799a2dd95SBruce Richardson 
230899a2dd95SBruce Richardson /**
230999a2dd95SBruce Richardson  * Convert a numerical speed in Mbps to a bitmap flag that can be used in
231099a2dd95SBruce Richardson  * the bitmap link_speeds of the struct rte_eth_conf
231199a2dd95SBruce Richardson  *
231299a2dd95SBruce Richardson  * @param speed
231399a2dd95SBruce Richardson  *   Numerical speed value in Mbps
231499a2dd95SBruce Richardson  * @param duplex
2315295968d1SFerruh Yigit  *   RTE_ETH_LINK_[HALF/FULL]_DUPLEX (only for 10/100M speeds)
231699a2dd95SBruce Richardson  * @return
231799a2dd95SBruce Richardson  *   0 if the speed cannot be mapped
231899a2dd95SBruce Richardson  */
231999a2dd95SBruce Richardson uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex);
232099a2dd95SBruce Richardson 
232199a2dd95SBruce Richardson /**
2322295968d1SFerruh Yigit  * Get RTE_ETH_RX_OFFLOAD_* flag name.
232399a2dd95SBruce Richardson  *
232499a2dd95SBruce Richardson  * @param offload
232599a2dd95SBruce Richardson  *   Offload flag.
232699a2dd95SBruce Richardson  * @return
232799a2dd95SBruce Richardson  *   Offload name or 'UNKNOWN' if the flag cannot be recognised.
232899a2dd95SBruce Richardson  */
232999a2dd95SBruce Richardson const char *rte_eth_dev_rx_offload_name(uint64_t offload);
233099a2dd95SBruce Richardson 
233199a2dd95SBruce Richardson /**
2332295968d1SFerruh Yigit  * Get RTE_ETH_TX_OFFLOAD_* flag name.
233399a2dd95SBruce Richardson  *
233499a2dd95SBruce Richardson  * @param offload
233599a2dd95SBruce Richardson  *   Offload flag.
233699a2dd95SBruce Richardson  * @return
233799a2dd95SBruce Richardson  *   Offload name or 'UNKNOWN' if the flag cannot be recognised.
233899a2dd95SBruce Richardson  */
233999a2dd95SBruce Richardson const char *rte_eth_dev_tx_offload_name(uint64_t offload);
234099a2dd95SBruce Richardson 
234199a2dd95SBruce Richardson /**
234293e441c9SXueming Li  * @warning
234393e441c9SXueming Li  * @b EXPERIMENTAL: this API may change without prior notice.
234493e441c9SXueming Li  *
234593e441c9SXueming Li  * Get RTE_ETH_DEV_CAPA_* flag name.
234693e441c9SXueming Li  *
234793e441c9SXueming Li  * @param capability
234893e441c9SXueming Li  *   Capability flag.
234993e441c9SXueming Li  * @return
235093e441c9SXueming Li  *   Capability name or 'UNKNOWN' if the flag cannot be recognized.
235193e441c9SXueming Li  */
235293e441c9SXueming Li __rte_experimental
235393e441c9SXueming Li const char *rte_eth_dev_capability_name(uint64_t capability);
235493e441c9SXueming Li 
235593e441c9SXueming Li /**
235699a2dd95SBruce Richardson  * Configure an Ethernet device.
235799a2dd95SBruce Richardson  * This function must be invoked first before any other function in the
235899a2dd95SBruce Richardson  * Ethernet API. This function can also be re-invoked when a device is in the
235999a2dd95SBruce Richardson  * stopped state.
236099a2dd95SBruce Richardson  *
236199a2dd95SBruce Richardson  * @param port_id
236299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device to configure.
236399a2dd95SBruce Richardson  * @param nb_rx_queue
236499a2dd95SBruce Richardson  *   The number of receive queues to set up for the Ethernet device.
236599a2dd95SBruce Richardson  * @param nb_tx_queue
236699a2dd95SBruce Richardson  *   The number of transmit queues to set up for the Ethernet device.
236799a2dd95SBruce Richardson  * @param eth_conf
236899a2dd95SBruce Richardson  *   The pointer to the configuration data to be used for the Ethernet device.
236999a2dd95SBruce Richardson  *   The *rte_eth_conf* structure includes:
237099a2dd95SBruce Richardson  *     -  the hardware offload features to activate, with dedicated fields for
237199a2dd95SBruce Richardson  *        each statically configurable offload hardware feature provided by
237299a2dd95SBruce Richardson  *        Ethernet devices, such as IP checksum or VLAN tag stripping for
237399a2dd95SBruce Richardson  *        example.
237499a2dd95SBruce Richardson  *        The Rx offload bitfield API is obsolete and will be deprecated.
237599a2dd95SBruce Richardson  *        Applications should set the ignore_bitfield_offloads bit on *rxmode*
237699a2dd95SBruce Richardson  *        structure and use offloads field to set per-port offloads instead.
237799a2dd95SBruce Richardson  *     -  Any offloading set in eth_conf->[rt]xmode.offloads must be within
237899a2dd95SBruce Richardson  *        the [rt]x_offload_capa returned from rte_eth_dev_info_get().
237999a2dd95SBruce Richardson  *        Any type of device supported offloading set in the input argument
238099a2dd95SBruce Richardson  *        eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is enabled
238199a2dd95SBruce Richardson  *        on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup()
238209fd4227SAndrew Rybchenko  *     -  the Receive Side Scaling (RSS) configuration when using multiple Rx
238399a2dd95SBruce Richardson  *        queues per port. Any RSS hash function set in eth_conf->rss_conf.rss_hf
238499a2dd95SBruce Richardson  *        must be within the flow_type_rss_offloads provided by drivers via
238599a2dd95SBruce Richardson  *        rte_eth_dev_info_get() API.
238699a2dd95SBruce Richardson  *
238799a2dd95SBruce Richardson  *   Embedding all configuration information in a single data structure
238899a2dd95SBruce Richardson  *   is the more flexible method that allows the addition of new features
238999a2dd95SBruce Richardson  *   without changing the syntax of the API.
239099a2dd95SBruce Richardson  * @return
239199a2dd95SBruce Richardson  *   - 0: Success, device configured.
239299a2dd95SBruce Richardson  *   - <0: Error code returned by the driver configuration function.
239399a2dd95SBruce Richardson  */
239499a2dd95SBruce Richardson int rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_queue,
239599a2dd95SBruce Richardson 		uint16_t nb_tx_queue, const struct rte_eth_conf *eth_conf);
239699a2dd95SBruce Richardson 
239799a2dd95SBruce Richardson /**
239899a2dd95SBruce Richardson  * Check if an Ethernet device was physically removed.
239999a2dd95SBruce Richardson  *
240099a2dd95SBruce Richardson  * @param port_id
240199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
240299a2dd95SBruce Richardson  * @return
240399a2dd95SBruce Richardson  *   1 when the Ethernet device is removed, otherwise 0.
240499a2dd95SBruce Richardson  */
240599a2dd95SBruce Richardson int
240699a2dd95SBruce Richardson rte_eth_dev_is_removed(uint16_t port_id);
240799a2dd95SBruce Richardson 
240899a2dd95SBruce Richardson /**
240999a2dd95SBruce Richardson  * Allocate and set up a receive queue for an Ethernet device.
241099a2dd95SBruce Richardson  *
241199a2dd95SBruce Richardson  * The function allocates a contiguous block of memory for *nb_rx_desc*
241299a2dd95SBruce Richardson  * receive descriptors from a memory zone associated with *socket_id*
241399a2dd95SBruce Richardson  * and initializes each receive descriptor with a network buffer allocated
241499a2dd95SBruce Richardson  * from the memory pool *mb_pool*.
241599a2dd95SBruce Richardson  *
241699a2dd95SBruce Richardson  * @param port_id
241799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
241899a2dd95SBruce Richardson  * @param rx_queue_id
241999a2dd95SBruce Richardson  *   The index of the receive queue to set up.
242099a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
242199a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
242299a2dd95SBruce Richardson  * @param nb_rx_desc
242399a2dd95SBruce Richardson  *   The number of receive descriptors to allocate for the receive ring.
242499a2dd95SBruce Richardson  * @param socket_id
242599a2dd95SBruce Richardson  *   The *socket_id* argument is the socket identifier in case of NUMA.
242699a2dd95SBruce Richardson  *   The value can be *SOCKET_ID_ANY* if there is no NUMA constraint for
242799a2dd95SBruce Richardson  *   the DMA memory allocated for the receive descriptors of the ring.
242899a2dd95SBruce Richardson  * @param rx_conf
242999a2dd95SBruce Richardson  *   The pointer to the configuration data to be used for the receive queue.
243009fd4227SAndrew Rybchenko  *   NULL value is allowed, in which case default Rx configuration
243199a2dd95SBruce Richardson  *   will be used.
243299a2dd95SBruce Richardson  *   The *rx_conf* structure contains an *rx_thresh* structure with the values
243399a2dd95SBruce Richardson  *   of the Prefetch, Host, and Write-Back threshold registers of the receive
243499a2dd95SBruce Richardson  *   ring.
243599a2dd95SBruce Richardson  *   In addition it contains the hardware offloads features to activate using
2436295968d1SFerruh Yigit  *   the RTE_ETH_RX_OFFLOAD_* flags.
243799a2dd95SBruce Richardson  *   If an offloading set in rx_conf->offloads
243899a2dd95SBruce Richardson  *   hasn't been set in the input argument eth_conf->rxmode.offloads
243999a2dd95SBruce Richardson  *   to rte_eth_dev_configure(), it is a new added offloading, it must be
244099a2dd95SBruce Richardson  *   per-queue type and it is enabled for the queue.
244199a2dd95SBruce Richardson  *   No need to repeat any bit in rx_conf->offloads which has already been
244299a2dd95SBruce Richardson  *   enabled in rte_eth_dev_configure() at port level. An offloading enabled
244399a2dd95SBruce Richardson  *   at port level can't be disabled at queue level.
244499a2dd95SBruce Richardson  *   The configuration structure also contains the pointer to the array
244599a2dd95SBruce Richardson  *   of the receiving buffer segment descriptions, see rx_seg and rx_nseg
244699a2dd95SBruce Richardson  *   fields, this extended configuration might be used by split offloads like
244797d7b927SJoyce Kong  *   RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT. If mb_pool is not NULL,
244899a2dd95SBruce Richardson  *   the extended configuration fields must be set to NULL and zero.
244999a2dd95SBruce Richardson  * @param mb_pool
245099a2dd95SBruce Richardson  *   The pointer to the memory pool from which to allocate *rte_mbuf* network
245199a2dd95SBruce Richardson  *   memory buffers to populate each descriptor of the receive ring. There are
245299a2dd95SBruce Richardson  *   two options to provide Rx buffer configuration:
245399a2dd95SBruce Richardson  *   - single pool:
245499a2dd95SBruce Richardson  *     mb_pool is not NULL, rx_conf.rx_nseg is 0.
245599a2dd95SBruce Richardson  *   - multiple segments description:
245699a2dd95SBruce Richardson  *     mb_pool is NULL, rx_conf.rx_seg is not NULL, rx_conf.rx_nseg is not 0.
245799a2dd95SBruce Richardson  *     Taken only if flag RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is set in offloads.
245899a2dd95SBruce Richardson  *
245999a2dd95SBruce Richardson  * @return
246099a2dd95SBruce Richardson  *   - 0: Success, receive queue correctly set up.
246199a2dd95SBruce Richardson  *   - -EIO: if device is removed.
246299a2dd95SBruce Richardson  *   - -ENODEV: if *port_id* is invalid.
246399a2dd95SBruce Richardson  *   - -EINVAL: The memory pool pointer is null or the size of network buffers
246499a2dd95SBruce Richardson  *      which can be allocated from this memory pool does not fit the various
246599a2dd95SBruce Richardson  *      buffer sizes allowed by the device controller.
246699a2dd95SBruce Richardson  *   - -ENOMEM: Unable to allocate the receive ring descriptors or to
246799a2dd95SBruce Richardson  *      allocate network memory buffers from the memory pool when
246899a2dd95SBruce Richardson  *      initializing receive descriptors.
246999a2dd95SBruce Richardson  */
247099a2dd95SBruce Richardson int rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
247199a2dd95SBruce Richardson 		uint16_t nb_rx_desc, unsigned int socket_id,
247299a2dd95SBruce Richardson 		const struct rte_eth_rxconf *rx_conf,
247399a2dd95SBruce Richardson 		struct rte_mempool *mb_pool);
247499a2dd95SBruce Richardson 
247599a2dd95SBruce Richardson /**
247699a2dd95SBruce Richardson  * @warning
247799a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
247899a2dd95SBruce Richardson  *
247999a2dd95SBruce Richardson  * Allocate and set up a hairpin receive queue for an Ethernet device.
248099a2dd95SBruce Richardson  *
248199a2dd95SBruce Richardson  * The function set up the selected queue to be used in hairpin.
248299a2dd95SBruce Richardson  *
248399a2dd95SBruce Richardson  * @param port_id
248499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
248599a2dd95SBruce Richardson  * @param rx_queue_id
248699a2dd95SBruce Richardson  *   The index of the receive queue to set up.
248799a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
248899a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
248999a2dd95SBruce Richardson  * @param nb_rx_desc
249099a2dd95SBruce Richardson  *   The number of receive descriptors to allocate for the receive ring.
249199a2dd95SBruce Richardson  *   0 means the PMD will use default value.
249299a2dd95SBruce Richardson  * @param conf
249399a2dd95SBruce Richardson  *   The pointer to the hairpin configuration.
249499a2dd95SBruce Richardson  *
249599a2dd95SBruce Richardson  * @return
249699a2dd95SBruce Richardson  *   - (0) if successful.
249799a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
249899a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
249999a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
250099a2dd95SBruce Richardson  *   - (-ENOMEM) if unable to allocate the resources.
250199a2dd95SBruce Richardson  */
250299a2dd95SBruce Richardson __rte_experimental
250399a2dd95SBruce Richardson int rte_eth_rx_hairpin_queue_setup
250499a2dd95SBruce Richardson 	(uint16_t port_id, uint16_t rx_queue_id, uint16_t nb_rx_desc,
250599a2dd95SBruce Richardson 	 const struct rte_eth_hairpin_conf *conf);
250699a2dd95SBruce Richardson 
250799a2dd95SBruce Richardson /**
250899a2dd95SBruce Richardson  * Allocate and set up a transmit queue for an Ethernet device.
250999a2dd95SBruce Richardson  *
251099a2dd95SBruce Richardson  * @param port_id
251199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
251299a2dd95SBruce Richardson  * @param tx_queue_id
251399a2dd95SBruce Richardson  *   The index of the transmit queue to set up.
251499a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
251599a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
251699a2dd95SBruce Richardson  * @param nb_tx_desc
251799a2dd95SBruce Richardson  *   The number of transmit descriptors to allocate for the transmit ring.
251899a2dd95SBruce Richardson  * @param socket_id
251999a2dd95SBruce Richardson  *   The *socket_id* argument is the socket identifier in case of NUMA.
252099a2dd95SBruce Richardson  *   Its value can be *SOCKET_ID_ANY* if there is no NUMA constraint for
252199a2dd95SBruce Richardson  *   the DMA memory allocated for the transmit descriptors of the ring.
252299a2dd95SBruce Richardson  * @param tx_conf
252399a2dd95SBruce Richardson  *   The pointer to the configuration data to be used for the transmit queue.
252409fd4227SAndrew Rybchenko  *   NULL value is allowed, in which case default Tx configuration
252599a2dd95SBruce Richardson  *   will be used.
252699a2dd95SBruce Richardson  *   The *tx_conf* structure contains the following data:
252799a2dd95SBruce Richardson  *   - The *tx_thresh* structure with the values of the Prefetch, Host, and
252899a2dd95SBruce Richardson  *     Write-Back threshold registers of the transmit ring.
252999a2dd95SBruce Richardson  *     When setting Write-Back threshold to the value greater then zero,
253099a2dd95SBruce Richardson  *     *tx_rs_thresh* value should be explicitly set to one.
253199a2dd95SBruce Richardson  *   - The *tx_free_thresh* value indicates the [minimum] number of network
253299a2dd95SBruce Richardson  *     buffers that must be pending in the transmit ring to trigger their
253399a2dd95SBruce Richardson  *     [implicit] freeing by the driver transmit function.
253499a2dd95SBruce Richardson  *   - The *tx_rs_thresh* value indicates the [minimum] number of transmit
253599a2dd95SBruce Richardson  *     descriptors that must be pending in the transmit ring before setting the
253699a2dd95SBruce Richardson  *     RS bit on a descriptor by the driver transmit function.
253799a2dd95SBruce Richardson  *     The *tx_rs_thresh* value should be less or equal then
253899a2dd95SBruce Richardson  *     *tx_free_thresh* value, and both of them should be less then
253999a2dd95SBruce Richardson  *     *nb_tx_desc* - 3.
254099a2dd95SBruce Richardson  *   - The *offloads* member contains Tx offloads to be enabled.
254199a2dd95SBruce Richardson  *     If an offloading set in tx_conf->offloads
254299a2dd95SBruce Richardson  *     hasn't been set in the input argument eth_conf->txmode.offloads
254399a2dd95SBruce Richardson  *     to rte_eth_dev_configure(), it is a new added offloading, it must be
254499a2dd95SBruce Richardson  *     per-queue type and it is enabled for the queue.
254599a2dd95SBruce Richardson  *     No need to repeat any bit in tx_conf->offloads which has already been
254699a2dd95SBruce Richardson  *     enabled in rte_eth_dev_configure() at port level. An offloading enabled
254799a2dd95SBruce Richardson  *     at port level can't be disabled at queue level.
254899a2dd95SBruce Richardson  *
254999a2dd95SBruce Richardson  *     Note that setting *tx_free_thresh* or *tx_rs_thresh* value to 0 forces
255099a2dd95SBruce Richardson  *     the transmit function to use default values.
255199a2dd95SBruce Richardson  * @return
255299a2dd95SBruce Richardson  *   - 0: Success, the transmit queue is correctly set up.
255399a2dd95SBruce Richardson  *   - -ENOMEM: Unable to allocate the transmit ring descriptors.
255499a2dd95SBruce Richardson  */
255599a2dd95SBruce Richardson int rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
255699a2dd95SBruce Richardson 		uint16_t nb_tx_desc, unsigned int socket_id,
255799a2dd95SBruce Richardson 		const struct rte_eth_txconf *tx_conf);
255899a2dd95SBruce Richardson 
255999a2dd95SBruce Richardson /**
256099a2dd95SBruce Richardson  * @warning
256199a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
256299a2dd95SBruce Richardson  *
256399a2dd95SBruce Richardson  * Allocate and set up a transmit hairpin queue for an Ethernet device.
256499a2dd95SBruce Richardson  *
256599a2dd95SBruce Richardson  * @param port_id
256699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
256799a2dd95SBruce Richardson  * @param tx_queue_id
256899a2dd95SBruce Richardson  *   The index of the transmit queue to set up.
256999a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
257099a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
257199a2dd95SBruce Richardson  * @param nb_tx_desc
257299a2dd95SBruce Richardson  *   The number of transmit descriptors to allocate for the transmit ring.
257399a2dd95SBruce Richardson  *   0 to set default PMD value.
257499a2dd95SBruce Richardson  * @param conf
257599a2dd95SBruce Richardson  *   The hairpin configuration.
257699a2dd95SBruce Richardson  *
257799a2dd95SBruce Richardson  * @return
257899a2dd95SBruce Richardson  *   - (0) if successful.
257999a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
258099a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
258199a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
258299a2dd95SBruce Richardson  *   - (-ENOMEM) if unable to allocate the resources.
258399a2dd95SBruce Richardson  */
258499a2dd95SBruce Richardson __rte_experimental
258599a2dd95SBruce Richardson int rte_eth_tx_hairpin_queue_setup
258699a2dd95SBruce Richardson 	(uint16_t port_id, uint16_t tx_queue_id, uint16_t nb_tx_desc,
258799a2dd95SBruce Richardson 	 const struct rte_eth_hairpin_conf *conf);
258899a2dd95SBruce Richardson 
258999a2dd95SBruce Richardson /**
259099a2dd95SBruce Richardson  * @warning
259199a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
259299a2dd95SBruce Richardson  *
259399a2dd95SBruce Richardson  * Get all the hairpin peer Rx / Tx ports of the current port.
259499a2dd95SBruce Richardson  * The caller should ensure that the array is large enough to save the ports
259599a2dd95SBruce Richardson  * list.
259699a2dd95SBruce Richardson  *
259799a2dd95SBruce Richardson  * @param port_id
259899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
259999a2dd95SBruce Richardson  * @param peer_ports
260099a2dd95SBruce Richardson  *   Pointer to the array to store the peer ports list.
260199a2dd95SBruce Richardson  * @param len
260299a2dd95SBruce Richardson  *   Length of the array to store the port identifiers.
260399a2dd95SBruce Richardson  * @param direction
260499a2dd95SBruce Richardson  *   Current port to peer port direction
260599a2dd95SBruce Richardson  *   positive - current used as Tx to get all peer Rx ports.
260699a2dd95SBruce Richardson  *   zero - current used as Rx to get all peer Tx ports.
260799a2dd95SBruce Richardson  *
260899a2dd95SBruce Richardson  * @return
260999a2dd95SBruce Richardson  *   - (0 or positive) actual peer ports number.
261099a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
261199a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid
261299a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
2613*f8dbaebbSSean Morrissey  *   - Others detailed errors from PMDs.
261499a2dd95SBruce Richardson  */
261599a2dd95SBruce Richardson __rte_experimental
261699a2dd95SBruce Richardson int rte_eth_hairpin_get_peer_ports(uint16_t port_id, uint16_t *peer_ports,
261799a2dd95SBruce Richardson 				   size_t len, uint32_t direction);
261899a2dd95SBruce Richardson 
261999a2dd95SBruce Richardson /**
262099a2dd95SBruce Richardson  * @warning
262199a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
262299a2dd95SBruce Richardson  *
262399a2dd95SBruce Richardson  * Bind all hairpin Tx queues of one port to the Rx queues of the peer port.
262499a2dd95SBruce Richardson  * It is only allowed to call this function after all hairpin queues are
262599a2dd95SBruce Richardson  * configured properly and the devices are in started state.
262699a2dd95SBruce Richardson  *
262799a2dd95SBruce Richardson  * @param tx_port
262899a2dd95SBruce Richardson  *   The identifier of the Tx port.
262999a2dd95SBruce Richardson  * @param rx_port
263099a2dd95SBruce Richardson  *   The identifier of peer Rx port.
263199a2dd95SBruce Richardson  *   RTE_MAX_ETHPORTS is allowed for the traversal of all devices.
263299a2dd95SBruce Richardson  *   Rx port ID could have the same value as Tx port ID.
263399a2dd95SBruce Richardson  *
263499a2dd95SBruce Richardson  * @return
263599a2dd95SBruce Richardson  *   - (0) if successful.
263699a2dd95SBruce Richardson  *   - (-ENODEV) if Tx port ID is invalid.
263799a2dd95SBruce Richardson  *   - (-EBUSY) if device is not in started state.
263899a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
2639*f8dbaebbSSean Morrissey  *   - Others detailed errors from PMDs.
264099a2dd95SBruce Richardson  */
264199a2dd95SBruce Richardson __rte_experimental
264299a2dd95SBruce Richardson int rte_eth_hairpin_bind(uint16_t tx_port, uint16_t rx_port);
264399a2dd95SBruce Richardson 
264499a2dd95SBruce Richardson /**
264599a2dd95SBruce Richardson  * @warning
264699a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
264799a2dd95SBruce Richardson  *
264899a2dd95SBruce Richardson  * Unbind all hairpin Tx queues of one port from the Rx queues of the peer port.
264999a2dd95SBruce Richardson  * This should be called before closing the Tx or Rx devices, if the bind
265099a2dd95SBruce Richardson  * function is called before.
265199a2dd95SBruce Richardson  * After unbinding the hairpin ports pair, it is allowed to bind them again.
265299a2dd95SBruce Richardson  * Changing queues configuration should be after stopping the device(s).
265399a2dd95SBruce Richardson  *
265499a2dd95SBruce Richardson  * @param tx_port
265599a2dd95SBruce Richardson  *   The identifier of the Tx port.
265699a2dd95SBruce Richardson  * @param rx_port
265799a2dd95SBruce Richardson  *   The identifier of peer Rx port.
265899a2dd95SBruce Richardson  *   RTE_MAX_ETHPORTS is allowed for traversal of all devices.
265999a2dd95SBruce Richardson  *   Rx port ID could have the same value as Tx port ID.
266099a2dd95SBruce Richardson  *
266199a2dd95SBruce Richardson  * @return
266299a2dd95SBruce Richardson  *   - (0) if successful.
266399a2dd95SBruce Richardson  *   - (-ENODEV) if Tx port ID is invalid.
266499a2dd95SBruce Richardson  *   - (-EBUSY) if device is in stopped state.
266599a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
2666*f8dbaebbSSean Morrissey  *   - Others detailed errors from PMDs.
266799a2dd95SBruce Richardson  */
266899a2dd95SBruce Richardson __rte_experimental
266999a2dd95SBruce Richardson int rte_eth_hairpin_unbind(uint16_t tx_port, uint16_t rx_port);
267099a2dd95SBruce Richardson 
267199a2dd95SBruce Richardson /**
267299a2dd95SBruce Richardson  * Return the NUMA socket to which an Ethernet device is connected
267399a2dd95SBruce Richardson  *
267499a2dd95SBruce Richardson  * @param port_id
267599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device
267699a2dd95SBruce Richardson  * @return
26775906be5aSAndrew Rybchenko  *   The NUMA socket ID to which the Ethernet device is connected or
267899a2dd95SBruce Richardson  *   a default of zero if the socket could not be determined.
267999a2dd95SBruce Richardson  *   -1 is returned is the port_id value is out of range.
268099a2dd95SBruce Richardson  */
268199a2dd95SBruce Richardson int rte_eth_dev_socket_id(uint16_t port_id);
268299a2dd95SBruce Richardson 
268399a2dd95SBruce Richardson /**
268499a2dd95SBruce Richardson  * Check if port_id of device is attached
268599a2dd95SBruce Richardson  *
268699a2dd95SBruce Richardson  * @param port_id
268799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device
268899a2dd95SBruce Richardson  * @return
268999a2dd95SBruce Richardson  *   - 0 if port is out of range or not attached
269099a2dd95SBruce Richardson  *   - 1 if device is attached
269199a2dd95SBruce Richardson  */
269299a2dd95SBruce Richardson int rte_eth_dev_is_valid_port(uint16_t port_id);
269399a2dd95SBruce Richardson 
269499a2dd95SBruce Richardson /**
269509fd4227SAndrew Rybchenko  * Start specified Rx queue of a port. It is used when rx_deferred_start
269699a2dd95SBruce Richardson  * flag of the specified queue is true.
269799a2dd95SBruce Richardson  *
269899a2dd95SBruce Richardson  * @param port_id
269999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device
270099a2dd95SBruce Richardson  * @param rx_queue_id
270109fd4227SAndrew Rybchenko  *   The index of the Rx queue to update the ring.
270299a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
270399a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
270499a2dd95SBruce Richardson  * @return
270599a2dd95SBruce Richardson  *   - 0: Success, the receive queue is started.
270699a2dd95SBruce Richardson  *   - -ENODEV: if *port_id* is invalid.
270799a2dd95SBruce Richardson  *   - -EINVAL: The queue_id out of range or belong to hairpin.
270899a2dd95SBruce Richardson  *   - -EIO: if device is removed.
2709*f8dbaebbSSean Morrissey  *   - -ENOTSUP: The function not supported in PMD.
271099a2dd95SBruce Richardson  */
271199a2dd95SBruce Richardson int rte_eth_dev_rx_queue_start(uint16_t port_id, uint16_t rx_queue_id);
271299a2dd95SBruce Richardson 
271399a2dd95SBruce Richardson /**
271409fd4227SAndrew Rybchenko  * Stop specified Rx queue of a port
271599a2dd95SBruce Richardson  *
271699a2dd95SBruce Richardson  * @param port_id
271799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device
271899a2dd95SBruce Richardson  * @param rx_queue_id
271909fd4227SAndrew Rybchenko  *   The index of the Rx queue to update the ring.
272099a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
272199a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
272299a2dd95SBruce Richardson  * @return
272399a2dd95SBruce Richardson  *   - 0: Success, the receive queue is stopped.
272499a2dd95SBruce Richardson  *   - -ENODEV: if *port_id* is invalid.
272599a2dd95SBruce Richardson  *   - -EINVAL: The queue_id out of range or belong to hairpin.
272699a2dd95SBruce Richardson  *   - -EIO: if device is removed.
2727*f8dbaebbSSean Morrissey  *   - -ENOTSUP: The function not supported in PMD.
272899a2dd95SBruce Richardson  */
272999a2dd95SBruce Richardson int rte_eth_dev_rx_queue_stop(uint16_t port_id, uint16_t rx_queue_id);
273099a2dd95SBruce Richardson 
273199a2dd95SBruce Richardson /**
273209fd4227SAndrew Rybchenko  * Start Tx for specified queue of a port. It is used when tx_deferred_start
273399a2dd95SBruce Richardson  * flag of the specified queue is true.
273499a2dd95SBruce Richardson  *
273599a2dd95SBruce Richardson  * @param port_id
273699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device
273799a2dd95SBruce Richardson  * @param tx_queue_id
273809fd4227SAndrew Rybchenko  *   The index of the Tx queue to update the ring.
273999a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
274099a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
274199a2dd95SBruce Richardson  * @return
274299a2dd95SBruce Richardson  *   - 0: Success, the transmit queue is started.
274399a2dd95SBruce Richardson  *   - -ENODEV: if *port_id* is invalid.
274499a2dd95SBruce Richardson  *   - -EINVAL: The queue_id out of range or belong to hairpin.
274599a2dd95SBruce Richardson  *   - -EIO: if device is removed.
2746*f8dbaebbSSean Morrissey  *   - -ENOTSUP: The function not supported in PMD.
274799a2dd95SBruce Richardson  */
274899a2dd95SBruce Richardson int rte_eth_dev_tx_queue_start(uint16_t port_id, uint16_t tx_queue_id);
274999a2dd95SBruce Richardson 
275099a2dd95SBruce Richardson /**
275109fd4227SAndrew Rybchenko  * Stop specified Tx queue of a port
275299a2dd95SBruce Richardson  *
275399a2dd95SBruce Richardson  * @param port_id
275499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device
275599a2dd95SBruce Richardson  * @param tx_queue_id
275609fd4227SAndrew Rybchenko  *   The index of the Tx queue to update the ring.
275799a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
275899a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
275999a2dd95SBruce Richardson  * @return
276099a2dd95SBruce Richardson  *   - 0: Success, the transmit queue is stopped.
276199a2dd95SBruce Richardson  *   - -ENODEV: if *port_id* is invalid.
276299a2dd95SBruce Richardson  *   - -EINVAL: The queue_id out of range or belong to hairpin.
276399a2dd95SBruce Richardson  *   - -EIO: if device is removed.
2764*f8dbaebbSSean Morrissey  *   - -ENOTSUP: The function not supported in PMD.
276599a2dd95SBruce Richardson  */
276699a2dd95SBruce Richardson int rte_eth_dev_tx_queue_stop(uint16_t port_id, uint16_t tx_queue_id);
276799a2dd95SBruce Richardson 
276899a2dd95SBruce Richardson /**
276999a2dd95SBruce Richardson  * Start an Ethernet device.
277099a2dd95SBruce Richardson  *
277199a2dd95SBruce Richardson  * The device start step is the last one and consists of setting the configured
277299a2dd95SBruce Richardson  * offload features and in starting the transmit and the receive units of the
277399a2dd95SBruce Richardson  * device.
277499a2dd95SBruce Richardson  *
277599a2dd95SBruce Richardson  * Device RTE_ETH_DEV_NOLIVE_MAC_ADDR flag causes MAC address to be set before
277699a2dd95SBruce Richardson  * PMD port start callback function is invoked.
277799a2dd95SBruce Richardson  *
277899a2dd95SBruce Richardson  * On success, all basic functions exported by the Ethernet API (link status,
277999a2dd95SBruce Richardson  * receive/transmit, and so on) can be invoked.
278099a2dd95SBruce Richardson  *
278199a2dd95SBruce Richardson  * @param port_id
278299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
278399a2dd95SBruce Richardson  * @return
278499a2dd95SBruce Richardson  *   - 0: Success, Ethernet device started.
278599a2dd95SBruce Richardson  *   - <0: Error code of the driver device start function.
278699a2dd95SBruce Richardson  */
278799a2dd95SBruce Richardson int rte_eth_dev_start(uint16_t port_id);
278899a2dd95SBruce Richardson 
278999a2dd95SBruce Richardson /**
279099a2dd95SBruce Richardson  * Stop an Ethernet device. The device can be restarted with a call to
279199a2dd95SBruce Richardson  * rte_eth_dev_start()
279299a2dd95SBruce Richardson  *
279399a2dd95SBruce Richardson  * @param port_id
279499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
279599a2dd95SBruce Richardson  * @return
279699a2dd95SBruce Richardson  *   - 0: Success, Ethernet device stopped.
279799a2dd95SBruce Richardson  *   - <0: Error code of the driver device stop function.
279899a2dd95SBruce Richardson  */
279999a2dd95SBruce Richardson int rte_eth_dev_stop(uint16_t port_id);
280099a2dd95SBruce Richardson 
280199a2dd95SBruce Richardson /**
280299a2dd95SBruce Richardson  * Link up an Ethernet device.
280399a2dd95SBruce Richardson  *
280409fd4227SAndrew Rybchenko  * Set device link up will re-enable the device Rx/Tx
280599a2dd95SBruce Richardson  * functionality after it is previously set device linked down.
280699a2dd95SBruce Richardson  *
280799a2dd95SBruce Richardson  * @param port_id
280899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
280999a2dd95SBruce Richardson  * @return
281099a2dd95SBruce Richardson  *   - 0: Success, Ethernet device linked up.
281199a2dd95SBruce Richardson  *   - <0: Error code of the driver device link up function.
281299a2dd95SBruce Richardson  */
281399a2dd95SBruce Richardson int rte_eth_dev_set_link_up(uint16_t port_id);
281499a2dd95SBruce Richardson 
281599a2dd95SBruce Richardson /**
281699a2dd95SBruce Richardson  * Link down an Ethernet device.
281709fd4227SAndrew Rybchenko  * The device Rx/Tx functionality will be disabled if success,
281899a2dd95SBruce Richardson  * and it can be re-enabled with a call to
281999a2dd95SBruce Richardson  * rte_eth_dev_set_link_up()
282099a2dd95SBruce Richardson  *
282199a2dd95SBruce Richardson  * @param port_id
282299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
282399a2dd95SBruce Richardson  */
282499a2dd95SBruce Richardson int rte_eth_dev_set_link_down(uint16_t port_id);
282599a2dd95SBruce Richardson 
282699a2dd95SBruce Richardson /**
282799a2dd95SBruce Richardson  * Close a stopped Ethernet device. The device cannot be restarted!
282899a2dd95SBruce Richardson  * The function frees all port resources.
282999a2dd95SBruce Richardson  *
283099a2dd95SBruce Richardson  * @param port_id
283199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
283299a2dd95SBruce Richardson  * @return
283399a2dd95SBruce Richardson  *   - Zero if the port is closed successfully.
283499a2dd95SBruce Richardson  *   - Negative if something went wrong.
283599a2dd95SBruce Richardson  */
283699a2dd95SBruce Richardson int rte_eth_dev_close(uint16_t port_id);
283799a2dd95SBruce Richardson 
283899a2dd95SBruce Richardson /**
28395906be5aSAndrew Rybchenko  * Reset a Ethernet device and keep its port ID.
284099a2dd95SBruce Richardson  *
284199a2dd95SBruce Richardson  * When a port has to be reset passively, the DPDK application can invoke
284299a2dd95SBruce Richardson  * this function. For example when a PF is reset, all its VFs should also
284399a2dd95SBruce Richardson  * be reset. Normally a DPDK application can invoke this function when
284499a2dd95SBruce Richardson  * RTE_ETH_EVENT_INTR_RESET event is detected, but can also use it to start
284599a2dd95SBruce Richardson  * a port reset in other circumstances.
284699a2dd95SBruce Richardson  *
284799a2dd95SBruce Richardson  * When this function is called, it first stops the port and then calls the
284899a2dd95SBruce Richardson  * PMD specific dev_uninit( ) and dev_init( ) to return the port to initial
284999a2dd95SBruce Richardson  * state, in which no Tx and Rx queues are setup, as if the port has been
28505906be5aSAndrew Rybchenko  * reset and not started. The port keeps the port ID it had before the
285199a2dd95SBruce Richardson  * function call.
285299a2dd95SBruce Richardson  *
285399a2dd95SBruce Richardson  * After calling rte_eth_dev_reset( ), the application should use
285499a2dd95SBruce Richardson  * rte_eth_dev_configure( ), rte_eth_rx_queue_setup( ),
285599a2dd95SBruce Richardson  * rte_eth_tx_queue_setup( ), and rte_eth_dev_start( )
285699a2dd95SBruce Richardson  * to reconfigure the device as appropriate.
285799a2dd95SBruce Richardson  *
285899a2dd95SBruce Richardson  * Note: To avoid unexpected behavior, the application should stop calling
285999a2dd95SBruce Richardson  * Tx and Rx functions before calling rte_eth_dev_reset( ). For thread
286099a2dd95SBruce Richardson  * safety, all these controlling functions should be called from the same
286199a2dd95SBruce Richardson  * thread.
286299a2dd95SBruce Richardson  *
286399a2dd95SBruce Richardson  * @param port_id
286499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
286599a2dd95SBruce Richardson  *
286699a2dd95SBruce Richardson  * @return
286799a2dd95SBruce Richardson  *   - (0) if successful.
286899a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
286999a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support this function.
287099a2dd95SBruce Richardson  *   - (-EPERM) if not ran from the primary process.
287199a2dd95SBruce Richardson  *   - (-EIO) if re-initialisation failed or device is removed.
287299a2dd95SBruce Richardson  *   - (-ENOMEM) if the reset failed due to OOM.
287399a2dd95SBruce Richardson  *   - (-EAGAIN) if the reset temporarily failed and should be retried later.
287499a2dd95SBruce Richardson  */
287599a2dd95SBruce Richardson int rte_eth_dev_reset(uint16_t port_id);
287699a2dd95SBruce Richardson 
287799a2dd95SBruce Richardson /**
287899a2dd95SBruce Richardson  * Enable receipt in promiscuous mode for an Ethernet device.
287999a2dd95SBruce Richardson  *
288099a2dd95SBruce Richardson  * @param port_id
288199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
288299a2dd95SBruce Richardson  * @return
288399a2dd95SBruce Richardson  *   - (0) if successful.
288499a2dd95SBruce Richardson  *   - (-ENOTSUP) if support for promiscuous_enable() does not exist
288599a2dd95SBruce Richardson  *     for the device.
288699a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
288799a2dd95SBruce Richardson  */
288899a2dd95SBruce Richardson int rte_eth_promiscuous_enable(uint16_t port_id);
288999a2dd95SBruce Richardson 
289099a2dd95SBruce Richardson /**
289199a2dd95SBruce Richardson  * Disable receipt in promiscuous mode for an Ethernet device.
289299a2dd95SBruce Richardson  *
289399a2dd95SBruce Richardson  * @param port_id
289499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
289599a2dd95SBruce Richardson  * @return
289699a2dd95SBruce Richardson  *   - (0) if successful.
289799a2dd95SBruce Richardson  *   - (-ENOTSUP) if support for promiscuous_disable() does not exist
289899a2dd95SBruce Richardson  *     for the device.
289999a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
290099a2dd95SBruce Richardson  */
290199a2dd95SBruce Richardson int rte_eth_promiscuous_disable(uint16_t port_id);
290299a2dd95SBruce Richardson 
290399a2dd95SBruce Richardson /**
290499a2dd95SBruce Richardson  * Return the value of promiscuous mode for an Ethernet device.
290599a2dd95SBruce Richardson  *
290699a2dd95SBruce Richardson  * @param port_id
290799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
290899a2dd95SBruce Richardson  * @return
290999a2dd95SBruce Richardson  *   - (1) if promiscuous is enabled
291099a2dd95SBruce Richardson  *   - (0) if promiscuous is disabled.
291199a2dd95SBruce Richardson  *   - (-1) on error
291299a2dd95SBruce Richardson  */
291399a2dd95SBruce Richardson int rte_eth_promiscuous_get(uint16_t port_id);
291499a2dd95SBruce Richardson 
291599a2dd95SBruce Richardson /**
291699a2dd95SBruce Richardson  * Enable the receipt of any multicast frame by an Ethernet device.
291799a2dd95SBruce Richardson  *
291899a2dd95SBruce Richardson  * @param port_id
291999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
292099a2dd95SBruce Richardson  * @return
292199a2dd95SBruce Richardson  *   - (0) if successful.
292299a2dd95SBruce Richardson  *   - (-ENOTSUP) if support for allmulticast_enable() does not exist
292399a2dd95SBruce Richardson  *     for the device.
292499a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
292599a2dd95SBruce Richardson  */
292699a2dd95SBruce Richardson int rte_eth_allmulticast_enable(uint16_t port_id);
292799a2dd95SBruce Richardson 
292899a2dd95SBruce Richardson /**
292999a2dd95SBruce Richardson  * Disable the receipt of all multicast frames by an Ethernet device.
293099a2dd95SBruce Richardson  *
293199a2dd95SBruce Richardson  * @param port_id
293299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
293399a2dd95SBruce Richardson  * @return
293499a2dd95SBruce Richardson  *   - (0) if successful.
293599a2dd95SBruce Richardson  *   - (-ENOTSUP) if support for allmulticast_disable() does not exist
293699a2dd95SBruce Richardson  *     for the device.
293799a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
293899a2dd95SBruce Richardson  */
293999a2dd95SBruce Richardson int rte_eth_allmulticast_disable(uint16_t port_id);
294099a2dd95SBruce Richardson 
294199a2dd95SBruce Richardson /**
294299a2dd95SBruce Richardson  * Return the value of allmulticast mode for an Ethernet device.
294399a2dd95SBruce Richardson  *
294499a2dd95SBruce Richardson  * @param port_id
294599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
294699a2dd95SBruce Richardson  * @return
294799a2dd95SBruce Richardson  *   - (1) if allmulticast is enabled
294899a2dd95SBruce Richardson  *   - (0) if allmulticast is disabled.
294999a2dd95SBruce Richardson  *   - (-1) on error
295099a2dd95SBruce Richardson  */
295199a2dd95SBruce Richardson int rte_eth_allmulticast_get(uint16_t port_id);
295299a2dd95SBruce Richardson 
295399a2dd95SBruce Richardson /**
295499a2dd95SBruce Richardson  * Retrieve the link status (up/down), the duplex mode (half/full),
295599a2dd95SBruce Richardson  * the negotiation (auto/fixed), and if available, the speed (Mbps).
295699a2dd95SBruce Richardson  *
295799a2dd95SBruce Richardson  * It might need to wait up to 9 seconds.
295899a2dd95SBruce Richardson  * @see rte_eth_link_get_nowait.
295999a2dd95SBruce Richardson  *
296099a2dd95SBruce Richardson  * @param port_id
296199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
296299a2dd95SBruce Richardson  * @param link
296399a2dd95SBruce Richardson  *   Link information written back.
296499a2dd95SBruce Richardson  * @return
296599a2dd95SBruce Richardson  *   - (0) if successful.
2966*f8dbaebbSSean Morrissey  *   - (-ENOTSUP) if the function is not supported in PMD.
296799a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
296853ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
296999a2dd95SBruce Richardson  */
297099a2dd95SBruce Richardson int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link);
297199a2dd95SBruce Richardson 
297299a2dd95SBruce Richardson /**
297399a2dd95SBruce Richardson  * Retrieve the link status (up/down), the duplex mode (half/full),
297499a2dd95SBruce Richardson  * the negotiation (auto/fixed), and if available, the speed (Mbps).
297599a2dd95SBruce Richardson  *
297699a2dd95SBruce Richardson  * @param port_id
297799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
297899a2dd95SBruce Richardson  * @param link
297999a2dd95SBruce Richardson  *   Link information written back.
298099a2dd95SBruce Richardson  * @return
298199a2dd95SBruce Richardson  *   - (0) if successful.
2982*f8dbaebbSSean Morrissey  *   - (-ENOTSUP) if the function is not supported in PMD.
298399a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
298453ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
298599a2dd95SBruce Richardson  */
298699a2dd95SBruce Richardson int rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *link);
298799a2dd95SBruce Richardson 
298899a2dd95SBruce Richardson /**
298999a2dd95SBruce Richardson  * @warning
299099a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
299199a2dd95SBruce Richardson  *
299299a2dd95SBruce Richardson  * The function converts a link_speed to a string. It handles all special
299399a2dd95SBruce Richardson  * values like unknown or none speed.
299499a2dd95SBruce Richardson  *
299599a2dd95SBruce Richardson  * @param link_speed
299699a2dd95SBruce Richardson  *   link_speed of rte_eth_link struct
299799a2dd95SBruce Richardson  * @return
299899a2dd95SBruce Richardson  *   Link speed in textual format. It's pointer to immutable memory.
299999a2dd95SBruce Richardson  *   No free is required.
300099a2dd95SBruce Richardson  */
300199a2dd95SBruce Richardson __rte_experimental
300299a2dd95SBruce Richardson const char *rte_eth_link_speed_to_str(uint32_t link_speed);
300399a2dd95SBruce Richardson 
300499a2dd95SBruce Richardson /**
300599a2dd95SBruce Richardson  * @warning
300699a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
300799a2dd95SBruce Richardson  *
300899a2dd95SBruce Richardson  * The function converts a rte_eth_link struct representing a link status to
300999a2dd95SBruce Richardson  * a string.
301099a2dd95SBruce Richardson  *
301199a2dd95SBruce Richardson  * @param str
301299a2dd95SBruce Richardson  *   A pointer to a string to be filled with textual representation of
3013295968d1SFerruh Yigit  *   device status. At least RTE_ETH_LINK_MAX_STR_LEN bytes should be allocated to
301499a2dd95SBruce Richardson  *   store default link status text.
301599a2dd95SBruce Richardson  * @param len
301699a2dd95SBruce Richardson  *   Length of available memory at 'str' string.
301799a2dd95SBruce Richardson  * @param eth_link
301899a2dd95SBruce Richardson  *   Link status returned by rte_eth_link_get function
301999a2dd95SBruce Richardson  * @return
302053ef1b34SMin Hu (Connor)  *   Number of bytes written to str array or -EINVAL if bad parameter.
302199a2dd95SBruce Richardson  */
302299a2dd95SBruce Richardson __rte_experimental
302399a2dd95SBruce Richardson int rte_eth_link_to_str(char *str, size_t len,
302499a2dd95SBruce Richardson 			const struct rte_eth_link *eth_link);
302599a2dd95SBruce Richardson 
302699a2dd95SBruce Richardson /**
302799a2dd95SBruce Richardson  * Retrieve the general I/O statistics of an Ethernet device.
302899a2dd95SBruce Richardson  *
302999a2dd95SBruce Richardson  * @param port_id
303099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
303199a2dd95SBruce Richardson  * @param stats
303299a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_eth_stats* to be filled with
303399a2dd95SBruce Richardson  *   the values of device counters for the following set of statistics:
303499a2dd95SBruce Richardson  *   - *ipackets* with the total of successfully received packets.
303599a2dd95SBruce Richardson  *   - *opackets* with the total of successfully transmitted packets.
303699a2dd95SBruce Richardson  *   - *ibytes*   with the total of successfully received bytes.
303799a2dd95SBruce Richardson  *   - *obytes*   with the total of successfully transmitted bytes.
303899a2dd95SBruce Richardson  *   - *ierrors*  with the total of erroneous received packets.
303999a2dd95SBruce Richardson  *   - *oerrors*  with the total of failed transmitted packets.
304099a2dd95SBruce Richardson  * @return
304199a2dd95SBruce Richardson  *   Zero if successful. Non-zero otherwise.
304299a2dd95SBruce Richardson  */
304399a2dd95SBruce Richardson int rte_eth_stats_get(uint16_t port_id, struct rte_eth_stats *stats);
304499a2dd95SBruce Richardson 
304599a2dd95SBruce Richardson /**
304699a2dd95SBruce Richardson  * Reset the general I/O statistics of an Ethernet device.
304799a2dd95SBruce Richardson  *
304899a2dd95SBruce Richardson  * @param port_id
304999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
305099a2dd95SBruce Richardson  * @return
305199a2dd95SBruce Richardson  *   - (0) if device notified to reset stats.
305299a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
305399a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
305499a2dd95SBruce Richardson  *   - (<0): Error code of the driver stats reset function.
305599a2dd95SBruce Richardson  */
305699a2dd95SBruce Richardson int rte_eth_stats_reset(uint16_t port_id);
305799a2dd95SBruce Richardson 
305899a2dd95SBruce Richardson /**
305999a2dd95SBruce Richardson  * Retrieve names of extended statistics of an Ethernet device.
306099a2dd95SBruce Richardson  *
306199a2dd95SBruce Richardson  * There is an assumption that 'xstat_names' and 'xstats' arrays are matched
306299a2dd95SBruce Richardson  * by array index:
306399a2dd95SBruce Richardson  *  xstats_names[i].name => xstats[i].value
306499a2dd95SBruce Richardson  *
306599a2dd95SBruce Richardson  * And the array index is same with id field of 'struct rte_eth_xstat':
306699a2dd95SBruce Richardson  *  xstats[i].id == i
306799a2dd95SBruce Richardson  *
306899a2dd95SBruce Richardson  * This assumption makes key-value pair matching less flexible but simpler.
306999a2dd95SBruce Richardson  *
307099a2dd95SBruce Richardson  * @param port_id
307199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
307299a2dd95SBruce Richardson  * @param xstats_names
307399a2dd95SBruce Richardson  *   An rte_eth_xstat_name array of at least *size* elements to
307499a2dd95SBruce Richardson  *   be filled. If set to NULL, the function returns the required number
307599a2dd95SBruce Richardson  *   of elements.
307699a2dd95SBruce Richardson  * @param size
307799a2dd95SBruce Richardson  *   The size of the xstats_names array (number of elements).
307899a2dd95SBruce Richardson  * @return
307999a2dd95SBruce Richardson  *   - A positive value lower or equal to size: success. The return value
308099a2dd95SBruce Richardson  *     is the number of entries filled in the stats table.
308199a2dd95SBruce Richardson  *   - A positive value higher than size: error, the given statistics table
308299a2dd95SBruce Richardson  *     is too small. The return value corresponds to the size that should
308399a2dd95SBruce Richardson  *     be given to succeed. The entries in the table are not valid and
308499a2dd95SBruce Richardson  *     shall not be used by the caller.
30855906be5aSAndrew Rybchenko  *   - A negative value on error (invalid port ID).
308699a2dd95SBruce Richardson  */
308799a2dd95SBruce Richardson int rte_eth_xstats_get_names(uint16_t port_id,
308899a2dd95SBruce Richardson 		struct rte_eth_xstat_name *xstats_names,
308999a2dd95SBruce Richardson 		unsigned int size);
309099a2dd95SBruce Richardson 
309199a2dd95SBruce Richardson /**
309299a2dd95SBruce Richardson  * Retrieve extended statistics of an Ethernet device.
309399a2dd95SBruce Richardson  *
309499a2dd95SBruce Richardson  * There is an assumption that 'xstat_names' and 'xstats' arrays are matched
309599a2dd95SBruce Richardson  * by array index:
309699a2dd95SBruce Richardson  *  xstats_names[i].name => xstats[i].value
309799a2dd95SBruce Richardson  *
309899a2dd95SBruce Richardson  * And the array index is same with id field of 'struct rte_eth_xstat':
309999a2dd95SBruce Richardson  *  xstats[i].id == i
310099a2dd95SBruce Richardson  *
310199a2dd95SBruce Richardson  * This assumption makes key-value pair matching less flexible but simpler.
310299a2dd95SBruce Richardson  *
310399a2dd95SBruce Richardson  * @param port_id
310499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
310599a2dd95SBruce Richardson  * @param xstats
310699a2dd95SBruce Richardson  *   A pointer to a table of structure of type *rte_eth_xstat*
310799a2dd95SBruce Richardson  *   to be filled with device statistics ids and values.
310899a2dd95SBruce Richardson  *   This parameter can be set to NULL if n is 0.
310999a2dd95SBruce Richardson  * @param n
311099a2dd95SBruce Richardson  *   The size of the xstats array (number of elements).
311199a2dd95SBruce Richardson  * @return
311299a2dd95SBruce Richardson  *   - A positive value lower or equal to n: success. The return value
311399a2dd95SBruce Richardson  *     is the number of entries filled in the stats table.
311499a2dd95SBruce Richardson  *   - A positive value higher than n: error, the given statistics table
311599a2dd95SBruce Richardson  *     is too small. The return value corresponds to the size that should
311699a2dd95SBruce Richardson  *     be given to succeed. The entries in the table are not valid and
311799a2dd95SBruce Richardson  *     shall not be used by the caller.
31185906be5aSAndrew Rybchenko  *   - A negative value on error (invalid port ID).
311999a2dd95SBruce Richardson  */
312099a2dd95SBruce Richardson int rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats,
312199a2dd95SBruce Richardson 		unsigned int n);
312299a2dd95SBruce Richardson 
312399a2dd95SBruce Richardson /**
312499a2dd95SBruce Richardson  * Retrieve names of extended statistics of an Ethernet device.
312599a2dd95SBruce Richardson  *
312699a2dd95SBruce Richardson  * @param port_id
312799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
312899a2dd95SBruce Richardson  * @param xstats_names
3129bc5112caSIvan Ilchenko  *   Array to be filled in with names of requested device statistics.
3130bc5112caSIvan Ilchenko  *   Must not be NULL if @p ids are specified (not NULL).
313199a2dd95SBruce Richardson  * @param size
3132bc5112caSIvan Ilchenko  *   Number of elements in @p xstats_names array (if not NULL) and in
3133bc5112caSIvan Ilchenko  *   @p ids array (if not NULL). Must be 0 if both array pointers are NULL.
3134bc5112caSIvan Ilchenko  * @param ids
3135bc5112caSIvan Ilchenko  *   IDs array given by app to retrieve specific statistics. May be NULL to
3136bc5112caSIvan Ilchenko  *   retrieve names of all available statistics or, if @p xstats_names is
3137bc5112caSIvan Ilchenko  *   NULL as well, just the number of available statistics.
313899a2dd95SBruce Richardson  * @return
313999a2dd95SBruce Richardson  *   - A positive value lower or equal to size: success. The return value
314099a2dd95SBruce Richardson  *     is the number of entries filled in the stats table.
3141bc5112caSIvan Ilchenko  *   - A positive value higher than size: success. The given statistics table
314299a2dd95SBruce Richardson  *     is too small. The return value corresponds to the size that should
314399a2dd95SBruce Richardson  *     be given to succeed. The entries in the table are not valid and
314499a2dd95SBruce Richardson  *     shall not be used by the caller.
3145bc5112caSIvan Ilchenko  *   - A negative value on error.
314699a2dd95SBruce Richardson  */
314799a2dd95SBruce Richardson int
314899a2dd95SBruce Richardson rte_eth_xstats_get_names_by_id(uint16_t port_id,
314999a2dd95SBruce Richardson 	struct rte_eth_xstat_name *xstats_names, unsigned int size,
315099a2dd95SBruce Richardson 	uint64_t *ids);
315199a2dd95SBruce Richardson 
315299a2dd95SBruce Richardson /**
315399a2dd95SBruce Richardson  * Retrieve extended statistics of an Ethernet device.
315499a2dd95SBruce Richardson  *
315599a2dd95SBruce Richardson  * @param port_id
315699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
315799a2dd95SBruce Richardson  * @param ids
3158bc5112caSIvan Ilchenko  *   IDs array given by app to retrieve specific statistics. May be NULL to
3159bc5112caSIvan Ilchenko  *   retrieve all available statistics or, if @p values is NULL as well,
3160bc5112caSIvan Ilchenko  *   just the number of available statistics.
316199a2dd95SBruce Richardson  * @param values
3162bc5112caSIvan Ilchenko  *   Array to be filled in with requested device statistics.
3163bc5112caSIvan Ilchenko  *   Must not be NULL if ids are specified (not NULL).
316499a2dd95SBruce Richardson  * @param size
3165bc5112caSIvan Ilchenko  *   Number of elements in @p values array (if not NULL) and in @p ids
3166bc5112caSIvan Ilchenko  *   array (if not NULL). Must be 0 if both array pointers are NULL.
316799a2dd95SBruce Richardson  * @return
316899a2dd95SBruce Richardson  *   - A positive value lower or equal to size: success. The return value
316999a2dd95SBruce Richardson  *     is the number of entries filled in the stats table.
3170bc5112caSIvan Ilchenko  *   - A positive value higher than size: success: The given statistics table
317199a2dd95SBruce Richardson  *     is too small. The return value corresponds to the size that should
317299a2dd95SBruce Richardson  *     be given to succeed. The entries in the table are not valid and
317399a2dd95SBruce Richardson  *     shall not be used by the caller.
3174bc5112caSIvan Ilchenko  *   - A negative value on error.
317599a2dd95SBruce Richardson  */
317699a2dd95SBruce Richardson int rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,
317799a2dd95SBruce Richardson 			     uint64_t *values, unsigned int size);
317899a2dd95SBruce Richardson 
317999a2dd95SBruce Richardson /**
318099a2dd95SBruce Richardson  * Gets the ID of a statistic from its name.
318199a2dd95SBruce Richardson  *
318299a2dd95SBruce Richardson  * This function searches for the statistics using string compares, and
318399a2dd95SBruce Richardson  * as such should not be used on the fast-path. For fast-path retrieval of
318499a2dd95SBruce Richardson  * specific statistics, store the ID as provided in *id* from this function,
318599a2dd95SBruce Richardson  * and pass the ID to rte_eth_xstats_get()
318699a2dd95SBruce Richardson  *
318799a2dd95SBruce Richardson  * @param port_id The port to look up statistics from
318899a2dd95SBruce Richardson  * @param xstat_name The name of the statistic to return
318999a2dd95SBruce Richardson  * @param[out] id A pointer to an app-supplied uint64_t which should be
319099a2dd95SBruce Richardson  *                set to the ID of the stat if the stat exists.
319199a2dd95SBruce Richardson  * @return
319299a2dd95SBruce Richardson  *    0 on success
319399a2dd95SBruce Richardson  *    -ENODEV for invalid port_id,
319499a2dd95SBruce Richardson  *    -EIO if device is removed,
319599a2dd95SBruce Richardson  *    -EINVAL if the xstat_name doesn't exist in port_id
319653ef1b34SMin Hu (Connor)  *    -ENOMEM if bad parameter.
319799a2dd95SBruce Richardson  */
319899a2dd95SBruce Richardson int rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name,
319999a2dd95SBruce Richardson 		uint64_t *id);
320099a2dd95SBruce Richardson 
320199a2dd95SBruce Richardson /**
320299a2dd95SBruce Richardson  * Reset extended statistics of an Ethernet device.
320399a2dd95SBruce Richardson  *
320499a2dd95SBruce Richardson  * @param port_id
320599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
320699a2dd95SBruce Richardson  * @return
320799a2dd95SBruce Richardson  *   - (0) if device notified to reset extended stats.
320899a2dd95SBruce Richardson  *   - (-ENOTSUP) if pmd doesn't support both
320999a2dd95SBruce Richardson  *     extended stats and basic stats reset.
321099a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
321199a2dd95SBruce Richardson  *   - (<0): Error code of the driver xstats reset function.
321299a2dd95SBruce Richardson  */
321399a2dd95SBruce Richardson int rte_eth_xstats_reset(uint16_t port_id);
321499a2dd95SBruce Richardson 
321599a2dd95SBruce Richardson /**
321699a2dd95SBruce Richardson  *  Set a mapping for the specified transmit queue to the specified per-queue
321799a2dd95SBruce Richardson  *  statistics counter.
321899a2dd95SBruce Richardson  *
321999a2dd95SBruce Richardson  * @param port_id
322099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
322199a2dd95SBruce Richardson  * @param tx_queue_id
322299a2dd95SBruce Richardson  *   The index of the transmit queue for which a queue stats mapping is required.
322399a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
322499a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
322599a2dd95SBruce Richardson  * @param stat_idx
322699a2dd95SBruce Richardson  *   The per-queue packet statistics functionality number that the transmit
322799a2dd95SBruce Richardson  *   queue is to be assigned.
322899a2dd95SBruce Richardson  *   The value must be in the range [0, RTE_ETHDEV_QUEUE_STAT_CNTRS - 1].
322999a2dd95SBruce Richardson  *   Max RTE_ETHDEV_QUEUE_STAT_CNTRS being 256.
323099a2dd95SBruce Richardson  * @return
323199a2dd95SBruce Richardson  *   Zero if successful. Non-zero otherwise.
323299a2dd95SBruce Richardson  */
323399a2dd95SBruce Richardson int rte_eth_dev_set_tx_queue_stats_mapping(uint16_t port_id,
323499a2dd95SBruce Richardson 		uint16_t tx_queue_id, uint8_t stat_idx);
323599a2dd95SBruce Richardson 
323699a2dd95SBruce Richardson /**
323799a2dd95SBruce Richardson  *  Set a mapping for the specified receive queue to the specified per-queue
323899a2dd95SBruce Richardson  *  statistics counter.
323999a2dd95SBruce Richardson  *
324099a2dd95SBruce Richardson  * @param port_id
324199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
324299a2dd95SBruce Richardson  * @param rx_queue_id
324399a2dd95SBruce Richardson  *   The index of the receive queue for which a queue stats mapping is required.
324499a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
324599a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
324699a2dd95SBruce Richardson  * @param stat_idx
324799a2dd95SBruce Richardson  *   The per-queue packet statistics functionality number that the receive
324899a2dd95SBruce Richardson  *   queue is to be assigned.
324999a2dd95SBruce Richardson  *   The value must be in the range [0, RTE_ETHDEV_QUEUE_STAT_CNTRS - 1].
325099a2dd95SBruce Richardson  *   Max RTE_ETHDEV_QUEUE_STAT_CNTRS being 256.
325199a2dd95SBruce Richardson  * @return
325299a2dd95SBruce Richardson  *   Zero if successful. Non-zero otherwise.
325399a2dd95SBruce Richardson  */
325499a2dd95SBruce Richardson int rte_eth_dev_set_rx_queue_stats_mapping(uint16_t port_id,
325599a2dd95SBruce Richardson 					   uint16_t rx_queue_id,
325699a2dd95SBruce Richardson 					   uint8_t stat_idx);
325799a2dd95SBruce Richardson 
325899a2dd95SBruce Richardson /**
325999a2dd95SBruce Richardson  * Retrieve the Ethernet address of an Ethernet device.
326099a2dd95SBruce Richardson  *
326199a2dd95SBruce Richardson  * @param port_id
326299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
326399a2dd95SBruce Richardson  * @param mac_addr
326499a2dd95SBruce Richardson  *   A pointer to a structure of type *ether_addr* to be filled with
326599a2dd95SBruce Richardson  *   the Ethernet address of the Ethernet device.
326699a2dd95SBruce Richardson  * @return
326799a2dd95SBruce Richardson  *   - (0) if successful
326899a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
326953ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
327099a2dd95SBruce Richardson  */
327199a2dd95SBruce Richardson int rte_eth_macaddr_get(uint16_t port_id, struct rte_ether_addr *mac_addr);
327299a2dd95SBruce Richardson 
327399a2dd95SBruce Richardson /**
327427a300e6SKonstantin Ananyev  * @warning
327527a300e6SKonstantin Ananyev  * @b EXPERIMENTAL: this API may change without prior notice
327627a300e6SKonstantin Ananyev  *
327727a300e6SKonstantin Ananyev  * Retrieve the Ethernet addresses of an Ethernet device.
327827a300e6SKonstantin Ananyev  *
327927a300e6SKonstantin Ananyev  * @param port_id
328027a300e6SKonstantin Ananyev  *   The port identifier of the Ethernet device.
328127a300e6SKonstantin Ananyev  * @param ma
328227a300e6SKonstantin Ananyev  *   A pointer to an array of structures of type *ether_addr* to be filled with
328327a300e6SKonstantin Ananyev  *   the Ethernet addresses of the Ethernet device.
328427a300e6SKonstantin Ananyev  * @param num
328527a300e6SKonstantin Ananyev  *   Number of elements in the @p ma array.
328627a300e6SKonstantin Ananyev  *   Note that  rte_eth_dev_info::max_mac_addrs can be used to retrieve
328727a300e6SKonstantin Ananyev  *   max number of Ethernet addresses for given port.
328827a300e6SKonstantin Ananyev  * @return
328927a300e6SKonstantin Ananyev  *   - number of retrieved addresses if successful
329027a300e6SKonstantin Ananyev  *   - (-ENODEV) if *port_id* invalid.
329127a300e6SKonstantin Ananyev  *   - (-EINVAL) if bad parameter.
329227a300e6SKonstantin Ananyev  */
329327a300e6SKonstantin Ananyev __rte_experimental
329427a300e6SKonstantin Ananyev int rte_eth_macaddrs_get(uint16_t port_id, struct rte_ether_addr *ma,
329527a300e6SKonstantin Ananyev 	unsigned int num);
329627a300e6SKonstantin Ananyev 
329727a300e6SKonstantin Ananyev /**
329899a2dd95SBruce Richardson  * Retrieve the contextual information of an Ethernet device.
329999a2dd95SBruce Richardson  *
330099a2dd95SBruce Richardson  * As part of this function, a number of of fields in dev_info will be
330199a2dd95SBruce Richardson  * initialized as follows:
330299a2dd95SBruce Richardson  *
330399a2dd95SBruce Richardson  * rx_desc_lim = lim
330499a2dd95SBruce Richardson  * tx_desc_lim = lim
330599a2dd95SBruce Richardson  *
330699a2dd95SBruce Richardson  * Where lim is defined within the rte_eth_dev_info_get as
330799a2dd95SBruce Richardson  *
330899a2dd95SBruce Richardson  *  const struct rte_eth_desc_lim lim = {
330999a2dd95SBruce Richardson  *      .nb_max = UINT16_MAX,
331099a2dd95SBruce Richardson  *      .nb_min = 0,
331199a2dd95SBruce Richardson  *      .nb_align = 1,
331299a2dd95SBruce Richardson  *	.nb_seg_max = UINT16_MAX,
331399a2dd95SBruce Richardson  *	.nb_mtu_seg_max = UINT16_MAX,
331499a2dd95SBruce Richardson  *  };
331599a2dd95SBruce Richardson  *
331699a2dd95SBruce Richardson  * device = dev->device
3317990912e6SFerruh Yigit  * min_mtu = RTE_ETHER_MIN_LEN - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN
331899a2dd95SBruce Richardson  * max_mtu = UINT16_MAX
331999a2dd95SBruce Richardson  *
332099a2dd95SBruce Richardson  * The following fields will be populated if support for dev_infos_get()
332199a2dd95SBruce Richardson  * exists for the device and the rte_eth_dev 'dev' has been populated
332299a2dd95SBruce Richardson  * successfully with a call to it:
332399a2dd95SBruce Richardson  *
332499a2dd95SBruce Richardson  * driver_name = dev->device->driver->name
332599a2dd95SBruce Richardson  * nb_rx_queues = dev->data->nb_rx_queues
332699a2dd95SBruce Richardson  * nb_tx_queues = dev->data->nb_tx_queues
332799a2dd95SBruce Richardson  * dev_flags = &dev->data->dev_flags
332899a2dd95SBruce Richardson  *
332999a2dd95SBruce Richardson  * @param port_id
333099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
333199a2dd95SBruce Richardson  * @param dev_info
333299a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_eth_dev_info* to be filled with
333399a2dd95SBruce Richardson  *   the contextual information of the Ethernet device.
333499a2dd95SBruce Richardson  * @return
333599a2dd95SBruce Richardson  *   - (0) if successful.
333699a2dd95SBruce Richardson  *   - (-ENOTSUP) if support for dev_infos_get() does not exist for the device.
333799a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
333853ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
333999a2dd95SBruce Richardson  */
334099a2dd95SBruce Richardson int rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info);
334199a2dd95SBruce Richardson 
334299a2dd95SBruce Richardson /**
3343632be327SJie Wang  * @warning
3344632be327SJie Wang  * @b EXPERIMENTAL: this API may change without prior notice.
3345632be327SJie Wang  *
3346632be327SJie Wang  * Retrieve the configuration of an Ethernet device.
3347632be327SJie Wang  *
3348632be327SJie Wang  * @param port_id
3349632be327SJie Wang  *   The port identifier of the Ethernet device.
3350632be327SJie Wang  * @param dev_conf
3351632be327SJie Wang  *   Location for Ethernet device configuration to be filled in.
3352632be327SJie Wang  * @return
3353632be327SJie Wang  *   - (0) if successful.
3354632be327SJie Wang  *   - (-ENODEV) if *port_id* invalid.
3355632be327SJie Wang  *   - (-EINVAL) if bad parameter.
3356632be327SJie Wang  */
3357632be327SJie Wang __rte_experimental
3358632be327SJie Wang int rte_eth_dev_conf_get(uint16_t port_id, struct rte_eth_conf *dev_conf);
3359632be327SJie Wang 
3360632be327SJie Wang /**
336199a2dd95SBruce Richardson  * Retrieve the firmware version of a device.
336299a2dd95SBruce Richardson  *
336399a2dd95SBruce Richardson  * @param port_id
336499a2dd95SBruce Richardson  *   The port identifier of the device.
336599a2dd95SBruce Richardson  * @param fw_version
336699a2dd95SBruce Richardson  *   A pointer to a string array storing the firmware version of a device,
336799a2dd95SBruce Richardson  *   the string includes terminating null. This pointer is allocated by caller.
336899a2dd95SBruce Richardson  * @param fw_size
336999a2dd95SBruce Richardson  *   The size of the string array pointed by fw_version, which should be
337099a2dd95SBruce Richardson  *   large enough to store firmware version of the device.
337199a2dd95SBruce Richardson  * @return
337299a2dd95SBruce Richardson  *   - (0) if successful.
337399a2dd95SBruce Richardson  *   - (-ENOTSUP) if operation is not supported.
337499a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
337599a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
337653ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
337799a2dd95SBruce Richardson  *   - (>0) if *fw_size* is not enough to store firmware version, return
337899a2dd95SBruce Richardson  *          the size of the non truncated string.
337999a2dd95SBruce Richardson  */
338099a2dd95SBruce Richardson int rte_eth_dev_fw_version_get(uint16_t port_id,
338199a2dd95SBruce Richardson 			       char *fw_version, size_t fw_size);
338299a2dd95SBruce Richardson 
338399a2dd95SBruce Richardson /**
338499a2dd95SBruce Richardson  * Retrieve the supported packet types of an Ethernet device.
338599a2dd95SBruce Richardson  *
338699a2dd95SBruce Richardson  * When a packet type is announced as supported, it *must* be recognized by
338799a2dd95SBruce Richardson  * the PMD. For instance, if RTE_PTYPE_L2_ETHER, RTE_PTYPE_L2_ETHER_VLAN
338899a2dd95SBruce Richardson  * and RTE_PTYPE_L3_IPV4 are announced, the PMD must return the following
338999a2dd95SBruce Richardson  * packet types for these packets:
339099a2dd95SBruce Richardson  * - Ether/IPv4              -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4
33915b49ba65SAndrew Rybchenko  * - Ether/VLAN/IPv4         -> RTE_PTYPE_L2_ETHER_VLAN | RTE_PTYPE_L3_IPV4
339299a2dd95SBruce Richardson  * - Ether/[anything else]   -> RTE_PTYPE_L2_ETHER
33935b49ba65SAndrew Rybchenko  * - Ether/VLAN/[anything else] -> RTE_PTYPE_L2_ETHER_VLAN
339499a2dd95SBruce Richardson  *
339599a2dd95SBruce Richardson  * When a packet is received by a PMD, the most precise type must be
339699a2dd95SBruce Richardson  * returned among the ones supported. However a PMD is allowed to set
339799a2dd95SBruce Richardson  * packet type that is not in the supported list, at the condition that it
339899a2dd95SBruce Richardson  * is more precise. Therefore, a PMD announcing no supported packet types
339999a2dd95SBruce Richardson  * can still set a matching packet type in a received packet.
340099a2dd95SBruce Richardson  *
340199a2dd95SBruce Richardson  * @note
340209fd4227SAndrew Rybchenko  *   Better to invoke this API after the device is already started or Rx burst
340399a2dd95SBruce Richardson  *   function is decided, to obtain correct supported ptypes.
340499a2dd95SBruce Richardson  * @note
340599a2dd95SBruce Richardson  *   if a given PMD does not report what ptypes it supports, then the supported
340699a2dd95SBruce Richardson  *   ptype count is reported as 0.
340799a2dd95SBruce Richardson  * @param port_id
340899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
340999a2dd95SBruce Richardson  * @param ptype_mask
341099a2dd95SBruce Richardson  *   A hint of what kind of packet type which the caller is interested in.
341199a2dd95SBruce Richardson  * @param ptypes
341299a2dd95SBruce Richardson  *   An array pointer to store adequate packet types, allocated by caller.
341399a2dd95SBruce Richardson  * @param num
341499a2dd95SBruce Richardson  *  Size of the array pointed by param ptypes.
341599a2dd95SBruce Richardson  * @return
341699a2dd95SBruce Richardson  *   - (>=0) Number of supported ptypes. If the number of types exceeds num,
341799a2dd95SBruce Richardson  *           only num entries will be filled into the ptypes array, but the full
341899a2dd95SBruce Richardson  *           count of supported ptypes will be returned.
341999a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
342053ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
342199a2dd95SBruce Richardson  */
342299a2dd95SBruce Richardson int rte_eth_dev_get_supported_ptypes(uint16_t port_id, uint32_t ptype_mask,
342399a2dd95SBruce Richardson 				     uint32_t *ptypes, int num);
342499a2dd95SBruce Richardson /**
342599a2dd95SBruce Richardson  * Inform Ethernet device about reduced range of packet types to handle.
342699a2dd95SBruce Richardson  *
342799a2dd95SBruce Richardson  * Application can use this function to set only specific ptypes that it's
342899a2dd95SBruce Richardson  * interested. This information can be used by the PMD to optimize Rx path.
342999a2dd95SBruce Richardson  *
343099a2dd95SBruce Richardson  * The function accepts an array `set_ptypes` allocated by the caller to
343199a2dd95SBruce Richardson  * store the packet types set by the driver, the last element of the array
343299a2dd95SBruce Richardson  * is set to RTE_PTYPE_UNKNOWN. The size of the `set_ptype` array should be
343399a2dd95SBruce Richardson  * `rte_eth_dev_get_supported_ptypes() + 1` else it might only be filled
343499a2dd95SBruce Richardson  * partially.
343599a2dd95SBruce Richardson  *
343699a2dd95SBruce Richardson  * @param port_id
343799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
343899a2dd95SBruce Richardson  * @param ptype_mask
343999a2dd95SBruce Richardson  *   The ptype family that application is interested in should be bitwise OR of
344099a2dd95SBruce Richardson  *   RTE_PTYPE_*_MASK or 0.
344199a2dd95SBruce Richardson  * @param set_ptypes
344299a2dd95SBruce Richardson  *   An array pointer to store set packet types, allocated by caller. The
344399a2dd95SBruce Richardson  *   function marks the end of array with RTE_PTYPE_UNKNOWN.
344499a2dd95SBruce Richardson  * @param num
344599a2dd95SBruce Richardson  *   Size of the array pointed by param ptypes.
344699a2dd95SBruce Richardson  *   Should be rte_eth_dev_get_supported_ptypes() + 1 to accommodate the
344799a2dd95SBruce Richardson  *   set ptypes.
344899a2dd95SBruce Richardson  * @return
344999a2dd95SBruce Richardson  *   - (0) if Success.
345099a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
345199a2dd95SBruce Richardson  *   - (-EINVAL) if *ptype_mask* is invalid (or) set_ptypes is NULL and
345299a2dd95SBruce Richardson  *     num > 0.
345399a2dd95SBruce Richardson  */
345499a2dd95SBruce Richardson int rte_eth_dev_set_ptypes(uint16_t port_id, uint32_t ptype_mask,
345599a2dd95SBruce Richardson 			   uint32_t *set_ptypes, unsigned int num);
345699a2dd95SBruce Richardson 
345799a2dd95SBruce Richardson /**
345899a2dd95SBruce Richardson  * Retrieve the MTU of an Ethernet device.
345999a2dd95SBruce Richardson  *
346099a2dd95SBruce Richardson  * @param port_id
346199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
346299a2dd95SBruce Richardson  * @param mtu
346399a2dd95SBruce Richardson  *   A pointer to a uint16_t where the retrieved MTU is to be stored.
346499a2dd95SBruce Richardson  * @return
346599a2dd95SBruce Richardson  *   - (0) if successful.
346699a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
346753ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
346899a2dd95SBruce Richardson  */
346999a2dd95SBruce Richardson int rte_eth_dev_get_mtu(uint16_t port_id, uint16_t *mtu);
347099a2dd95SBruce Richardson 
347199a2dd95SBruce Richardson /**
347299a2dd95SBruce Richardson  * Change the MTU of an Ethernet device.
347399a2dd95SBruce Richardson  *
347499a2dd95SBruce Richardson  * @param port_id
347599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
347699a2dd95SBruce Richardson  * @param mtu
347799a2dd95SBruce Richardson  *   A uint16_t for the MTU to be applied.
347899a2dd95SBruce Richardson  * @return
347999a2dd95SBruce Richardson  *   - (0) if successful.
348099a2dd95SBruce Richardson  *   - (-ENOTSUP) if operation is not supported.
348199a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
348299a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
348399a2dd95SBruce Richardson  *   - (-EINVAL) if *mtu* invalid, validation of mtu can occur within
348499a2dd95SBruce Richardson  *     rte_eth_dev_set_mtu if dev_infos_get is supported by the device or
348599a2dd95SBruce Richardson  *     when the mtu is set using dev->dev_ops->mtu_set.
348699a2dd95SBruce Richardson  *   - (-EBUSY) if operation is not allowed when the port is running
348799a2dd95SBruce Richardson  */
348899a2dd95SBruce Richardson int rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu);
348999a2dd95SBruce Richardson 
349099a2dd95SBruce Richardson /**
349199a2dd95SBruce Richardson  * Enable/Disable hardware filtering by an Ethernet device of received
349299a2dd95SBruce Richardson  * VLAN packets tagged with a given VLAN Tag Identifier.
349399a2dd95SBruce Richardson  *
349499a2dd95SBruce Richardson  * @param port_id
349599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
349699a2dd95SBruce Richardson  * @param vlan_id
349799a2dd95SBruce Richardson  *   The VLAN Tag Identifier whose filtering must be enabled or disabled.
349899a2dd95SBruce Richardson  * @param on
349999a2dd95SBruce Richardson  *   If > 0, enable VLAN filtering of VLAN packets tagged with *vlan_id*.
350099a2dd95SBruce Richardson  *   Otherwise, disable VLAN filtering of VLAN packets tagged with *vlan_id*.
350199a2dd95SBruce Richardson  * @return
350299a2dd95SBruce Richardson  *   - (0) if successful.
350399a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware-assisted VLAN filtering not configured.
350499a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
350599a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
350699a2dd95SBruce Richardson  *   - (-ENOSYS) if VLAN filtering on *port_id* disabled.
350799a2dd95SBruce Richardson  *   - (-EINVAL) if *vlan_id* > 4095.
350899a2dd95SBruce Richardson  */
350999a2dd95SBruce Richardson int rte_eth_dev_vlan_filter(uint16_t port_id, uint16_t vlan_id, int on);
351099a2dd95SBruce Richardson 
351199a2dd95SBruce Richardson /**
351209fd4227SAndrew Rybchenko  * Enable/Disable hardware VLAN Strip by a Rx queue of an Ethernet device.
351399a2dd95SBruce Richardson  *
351499a2dd95SBruce Richardson  * @param port_id
351599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
351699a2dd95SBruce Richardson  * @param rx_queue_id
351799a2dd95SBruce Richardson  *   The index of the receive queue for which a queue stats mapping is required.
351899a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
351999a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
352099a2dd95SBruce Richardson  * @param on
352199a2dd95SBruce Richardson  *   If 1, Enable VLAN Stripping of the receive queue of the Ethernet port.
352299a2dd95SBruce Richardson  *   If 0, Disable VLAN Stripping of the receive queue of the Ethernet port.
352399a2dd95SBruce Richardson  * @return
352499a2dd95SBruce Richardson  *   - (0) if successful.
352599a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware-assisted VLAN stripping not configured.
352699a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
352799a2dd95SBruce Richardson  *   - (-EINVAL) if *rx_queue_id* invalid.
352899a2dd95SBruce Richardson  */
352999a2dd95SBruce Richardson int rte_eth_dev_set_vlan_strip_on_queue(uint16_t port_id, uint16_t rx_queue_id,
353099a2dd95SBruce Richardson 		int on);
353199a2dd95SBruce Richardson 
353299a2dd95SBruce Richardson /**
353399a2dd95SBruce Richardson  * Set the Outer VLAN Ether Type by an Ethernet device, it can be inserted to
353499a2dd95SBruce Richardson  * the VLAN header.
353599a2dd95SBruce Richardson  *
353699a2dd95SBruce Richardson  * @param port_id
353799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
353899a2dd95SBruce Richardson  * @param vlan_type
35395b49ba65SAndrew Rybchenko  *   The VLAN type.
354099a2dd95SBruce Richardson  * @param tag_type
354199a2dd95SBruce Richardson  *   The Tag Protocol ID
354299a2dd95SBruce Richardson  * @return
354399a2dd95SBruce Richardson  *   - (0) if successful.
354499a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware-assisted VLAN TPID setup is not supported.
354599a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
354699a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
354799a2dd95SBruce Richardson  */
354899a2dd95SBruce Richardson int rte_eth_dev_set_vlan_ether_type(uint16_t port_id,
354999a2dd95SBruce Richardson 				    enum rte_vlan_type vlan_type,
355099a2dd95SBruce Richardson 				    uint16_t tag_type);
355199a2dd95SBruce Richardson 
355299a2dd95SBruce Richardson /**
355399a2dd95SBruce Richardson  * Set VLAN offload configuration on an Ethernet device.
355499a2dd95SBruce Richardson  *
355599a2dd95SBruce Richardson  * @param port_id
355699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
355799a2dd95SBruce Richardson  * @param offload_mask
355899a2dd95SBruce Richardson  *   The VLAN Offload bit mask can be mixed use with "OR"
3559295968d1SFerruh Yigit  *       RTE_ETH_VLAN_STRIP_OFFLOAD
3560295968d1SFerruh Yigit  *       RTE_ETH_VLAN_FILTER_OFFLOAD
3561295968d1SFerruh Yigit  *       RTE_ETH_VLAN_EXTEND_OFFLOAD
3562295968d1SFerruh Yigit  *       RTE_ETH_QINQ_STRIP_OFFLOAD
356399a2dd95SBruce Richardson  * @return
356499a2dd95SBruce Richardson  *   - (0) if successful.
356599a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware-assisted VLAN filtering not configured.
356699a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
356799a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
356899a2dd95SBruce Richardson  */
356999a2dd95SBruce Richardson int rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask);
357099a2dd95SBruce Richardson 
357199a2dd95SBruce Richardson /**
357299a2dd95SBruce Richardson  * Read VLAN Offload configuration from an Ethernet device
357399a2dd95SBruce Richardson  *
357499a2dd95SBruce Richardson  * @param port_id
357599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
357699a2dd95SBruce Richardson  * @return
357799a2dd95SBruce Richardson  *   - (>0) if successful. Bit mask to indicate
3578295968d1SFerruh Yigit  *       RTE_ETH_VLAN_STRIP_OFFLOAD
3579295968d1SFerruh Yigit  *       RTE_ETH_VLAN_FILTER_OFFLOAD
3580295968d1SFerruh Yigit  *       RTE_ETH_VLAN_EXTEND_OFFLOAD
3581295968d1SFerruh Yigit  *       RTE_ETH_QINQ_STRIP_OFFLOAD
358299a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
358399a2dd95SBruce Richardson  */
358499a2dd95SBruce Richardson int rte_eth_dev_get_vlan_offload(uint16_t port_id);
358599a2dd95SBruce Richardson 
358699a2dd95SBruce Richardson /**
358709fd4227SAndrew Rybchenko  * Set port based Tx VLAN insertion on or off.
358899a2dd95SBruce Richardson  *
358999a2dd95SBruce Richardson  * @param port_id
359099a2dd95SBruce Richardson  *  The port identifier of the Ethernet device.
359199a2dd95SBruce Richardson  * @param pvid
359209fd4227SAndrew Rybchenko  *  Port based Tx VLAN identifier together with user priority.
359399a2dd95SBruce Richardson  * @param on
359409fd4227SAndrew Rybchenko  *  Turn on or off the port based Tx VLAN insertion.
359599a2dd95SBruce Richardson  *
359699a2dd95SBruce Richardson  * @return
359799a2dd95SBruce Richardson  *   - (0) if successful.
359899a2dd95SBruce Richardson  *   - negative if failed.
359999a2dd95SBruce Richardson  */
360099a2dd95SBruce Richardson int rte_eth_dev_set_vlan_pvid(uint16_t port_id, uint16_t pvid, int on);
360199a2dd95SBruce Richardson 
360299a2dd95SBruce Richardson typedef void (*buffer_tx_error_fn)(struct rte_mbuf **unsent, uint16_t count,
360399a2dd95SBruce Richardson 		void *userdata);
360499a2dd95SBruce Richardson 
360599a2dd95SBruce Richardson /**
360609fd4227SAndrew Rybchenko  * Structure used to buffer packets for future Tx
360799a2dd95SBruce Richardson  * Used by APIs rte_eth_tx_buffer and rte_eth_tx_buffer_flush
360899a2dd95SBruce Richardson  */
360999a2dd95SBruce Richardson struct rte_eth_dev_tx_buffer {
361099a2dd95SBruce Richardson 	buffer_tx_error_fn error_callback;
361199a2dd95SBruce Richardson 	void *error_userdata;
361209fd4227SAndrew Rybchenko 	uint16_t size;           /**< Size of buffer for buffered Tx */
361399a2dd95SBruce Richardson 	uint16_t length;         /**< Number of packets in the array */
36143c2ca0a9SAndrew Rybchenko 	/** Pending packets to be sent on explicit flush or when full */
361599a2dd95SBruce Richardson 	struct rte_mbuf *pkts[];
361699a2dd95SBruce Richardson };
361799a2dd95SBruce Richardson 
361899a2dd95SBruce Richardson /**
361909fd4227SAndrew Rybchenko  * Calculate the size of the Tx buffer.
362099a2dd95SBruce Richardson  *
362199a2dd95SBruce Richardson  * @param sz
362299a2dd95SBruce Richardson  *   Number of stored packets.
362399a2dd95SBruce Richardson  */
362499a2dd95SBruce Richardson #define RTE_ETH_TX_BUFFER_SIZE(sz) \
362599a2dd95SBruce Richardson 	(sizeof(struct rte_eth_dev_tx_buffer) + (sz) * sizeof(struct rte_mbuf *))
362699a2dd95SBruce Richardson 
362799a2dd95SBruce Richardson /**
362899a2dd95SBruce Richardson  * Initialize default values for buffered transmitting
362999a2dd95SBruce Richardson  *
363099a2dd95SBruce Richardson  * @param buffer
363199a2dd95SBruce Richardson  *   Tx buffer to be initialized.
363299a2dd95SBruce Richardson  * @param size
363399a2dd95SBruce Richardson  *   Buffer size
363499a2dd95SBruce Richardson  * @return
363599a2dd95SBruce Richardson  *   0 if no error
363699a2dd95SBruce Richardson  */
363799a2dd95SBruce Richardson int
363899a2dd95SBruce Richardson rte_eth_tx_buffer_init(struct rte_eth_dev_tx_buffer *buffer, uint16_t size);
363999a2dd95SBruce Richardson 
364099a2dd95SBruce Richardson /**
364199a2dd95SBruce Richardson  * Configure a callback for buffered packets which cannot be sent
364299a2dd95SBruce Richardson  *
364399a2dd95SBruce Richardson  * Register a specific callback to be called when an attempt is made to send
36440d9f56a8SAndrew Rybchenko  * all packets buffered on an Ethernet port, but not all packets can
364599a2dd95SBruce Richardson  * successfully be sent. The callback registered here will be called only
364699a2dd95SBruce Richardson  * from calls to rte_eth_tx_buffer() and rte_eth_tx_buffer_flush() APIs.
364799a2dd95SBruce Richardson  * The default callback configured for each queue by default just frees the
364899a2dd95SBruce Richardson  * packets back to the calling mempool. If additional behaviour is required,
364999a2dd95SBruce Richardson  * for example, to count dropped packets, or to retry transmission of packets
365099a2dd95SBruce Richardson  * which cannot be sent, this function should be used to register a suitable
365199a2dd95SBruce Richardson  * callback function to implement the desired behaviour.
365299a2dd95SBruce Richardson  * The example callback "rte_eth_count_unsent_packet_callback()" is also
365399a2dd95SBruce Richardson  * provided as reference.
365499a2dd95SBruce Richardson  *
365599a2dd95SBruce Richardson  * @param buffer
365699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
365799a2dd95SBruce Richardson  * @param callback
365899a2dd95SBruce Richardson  *   The function to be used as the callback.
365999a2dd95SBruce Richardson  * @param userdata
366099a2dd95SBruce Richardson  *   Arbitrary parameter to be passed to the callback function
366199a2dd95SBruce Richardson  * @return
366253ef1b34SMin Hu (Connor)  *   0 on success, or -EINVAL if bad parameter
366399a2dd95SBruce Richardson  */
366499a2dd95SBruce Richardson int
366599a2dd95SBruce Richardson rte_eth_tx_buffer_set_err_callback(struct rte_eth_dev_tx_buffer *buffer,
366699a2dd95SBruce Richardson 		buffer_tx_error_fn callback, void *userdata);
366799a2dd95SBruce Richardson 
366899a2dd95SBruce Richardson /**
366999a2dd95SBruce Richardson  * Callback function for silently dropping unsent buffered packets.
367099a2dd95SBruce Richardson  *
367199a2dd95SBruce Richardson  * This function can be passed to rte_eth_tx_buffer_set_err_callback() to
367299a2dd95SBruce Richardson  * adjust the default behavior when buffered packets cannot be sent. This
367309fd4227SAndrew Rybchenko  * function drops any unsent packets silently and is used by Tx buffered
367499a2dd95SBruce Richardson  * operations as default behavior.
367599a2dd95SBruce Richardson  *
367699a2dd95SBruce Richardson  * NOTE: this function should not be called directly, instead it should be used
367799a2dd95SBruce Richardson  *       as a callback for packet buffering.
367899a2dd95SBruce Richardson  *
367999a2dd95SBruce Richardson  * NOTE: when configuring this function as a callback with
368099a2dd95SBruce Richardson  *       rte_eth_tx_buffer_set_err_callback(), the final, userdata parameter
368199a2dd95SBruce Richardson  *       should point to an uint64_t value.
368299a2dd95SBruce Richardson  *
368399a2dd95SBruce Richardson  * @param pkts
368499a2dd95SBruce Richardson  *   The previously buffered packets which could not be sent
368599a2dd95SBruce Richardson  * @param unsent
368699a2dd95SBruce Richardson  *   The number of unsent packets in the pkts array
368799a2dd95SBruce Richardson  * @param userdata
368899a2dd95SBruce Richardson  *   Not used
368999a2dd95SBruce Richardson  */
369099a2dd95SBruce Richardson void
369199a2dd95SBruce Richardson rte_eth_tx_buffer_drop_callback(struct rte_mbuf **pkts, uint16_t unsent,
369299a2dd95SBruce Richardson 		void *userdata);
369399a2dd95SBruce Richardson 
369499a2dd95SBruce Richardson /**
369599a2dd95SBruce Richardson  * Callback function for tracking unsent buffered packets.
369699a2dd95SBruce Richardson  *
369799a2dd95SBruce Richardson  * This function can be passed to rte_eth_tx_buffer_set_err_callback() to
369899a2dd95SBruce Richardson  * adjust the default behavior when buffered packets cannot be sent. This
369999a2dd95SBruce Richardson  * function drops any unsent packets, but also updates a user-supplied counter
370099a2dd95SBruce Richardson  * to track the overall number of packets dropped. The counter should be an
370199a2dd95SBruce Richardson  * uint64_t variable.
370299a2dd95SBruce Richardson  *
370399a2dd95SBruce Richardson  * NOTE: this function should not be called directly, instead it should be used
370499a2dd95SBruce Richardson  *       as a callback for packet buffering.
370599a2dd95SBruce Richardson  *
370699a2dd95SBruce Richardson  * NOTE: when configuring this function as a callback with
370799a2dd95SBruce Richardson  *       rte_eth_tx_buffer_set_err_callback(), the final, userdata parameter
370899a2dd95SBruce Richardson  *       should point to an uint64_t value.
370999a2dd95SBruce Richardson  *
371099a2dd95SBruce Richardson  * @param pkts
371199a2dd95SBruce Richardson  *   The previously buffered packets which could not be sent
371299a2dd95SBruce Richardson  * @param unsent
371399a2dd95SBruce Richardson  *   The number of unsent packets in the pkts array
371499a2dd95SBruce Richardson  * @param userdata
371599a2dd95SBruce Richardson  *   Pointer to an uint64_t value, which will be incremented by unsent
371699a2dd95SBruce Richardson  */
371799a2dd95SBruce Richardson void
371899a2dd95SBruce Richardson rte_eth_tx_buffer_count_callback(struct rte_mbuf **pkts, uint16_t unsent,
371999a2dd95SBruce Richardson 		void *userdata);
372099a2dd95SBruce Richardson 
372199a2dd95SBruce Richardson /**
372299a2dd95SBruce Richardson  * Request the driver to free mbufs currently cached by the driver. The
372399a2dd95SBruce Richardson  * driver will only free the mbuf if it is no longer in use. It is the
372499a2dd95SBruce Richardson  * application's responsibility to ensure rte_eth_tx_buffer_flush(..) is
372599a2dd95SBruce Richardson  * called if needed.
372699a2dd95SBruce Richardson  *
372799a2dd95SBruce Richardson  * @param port_id
372899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
372999a2dd95SBruce Richardson  * @param queue_id
373099a2dd95SBruce Richardson  *   The index of the transmit queue through which output packets must be
373199a2dd95SBruce Richardson  *   sent.
373299a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
373399a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
373499a2dd95SBruce Richardson  * @param free_cnt
373599a2dd95SBruce Richardson  *   Maximum number of packets to free. Use 0 to indicate all possible packets
373699a2dd95SBruce Richardson  *   should be freed. Note that a packet may be using multiple mbufs.
373799a2dd95SBruce Richardson  * @return
373899a2dd95SBruce Richardson  *   Failure: < 0
373999a2dd95SBruce Richardson  *     -ENODEV: Invalid interface
374099a2dd95SBruce Richardson  *     -EIO: device is removed
374199a2dd95SBruce Richardson  *     -ENOTSUP: Driver does not support function
374299a2dd95SBruce Richardson  *   Success: >= 0
374399a2dd95SBruce Richardson  *     0-n: Number of packets freed. More packets may still remain in ring that
374499a2dd95SBruce Richardson  *     are in use.
374599a2dd95SBruce Richardson  */
374699a2dd95SBruce Richardson int
374799a2dd95SBruce Richardson rte_eth_tx_done_cleanup(uint16_t port_id, uint16_t queue_id, uint32_t free_cnt);
374899a2dd95SBruce Richardson 
374999a2dd95SBruce Richardson /**
375099a2dd95SBruce Richardson  * Subtypes for IPsec offload event(@ref RTE_ETH_EVENT_IPSEC) raised by
375199a2dd95SBruce Richardson  * eth device.
375299a2dd95SBruce Richardson  */
375399a2dd95SBruce Richardson enum rte_eth_event_ipsec_subtype {
37543c2ca0a9SAndrew Rybchenko 	/** Unknown event type */
375599a2dd95SBruce Richardson 	RTE_ETH_EVENT_IPSEC_UNKNOWN = 0,
37563c2ca0a9SAndrew Rybchenko 	/** Sequence number overflow */
375799a2dd95SBruce Richardson 	RTE_ETH_EVENT_IPSEC_ESN_OVERFLOW,
37583c2ca0a9SAndrew Rybchenko 	/** Soft time expiry of SA */
375999a2dd95SBruce Richardson 	RTE_ETH_EVENT_IPSEC_SA_TIME_EXPIRY,
37603c2ca0a9SAndrew Rybchenko 	/** Soft byte expiry of SA */
376199a2dd95SBruce Richardson 	RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY,
37623c2ca0a9SAndrew Rybchenko 	/** Max value of this enum */
376399a2dd95SBruce Richardson 	RTE_ETH_EVENT_IPSEC_MAX
376499a2dd95SBruce Richardson };
376599a2dd95SBruce Richardson 
376699a2dd95SBruce Richardson /**
376799a2dd95SBruce Richardson  * Descriptor for @ref RTE_ETH_EVENT_IPSEC event. Used by eth dev to send extra
376899a2dd95SBruce Richardson  * information of the IPsec offload event.
376999a2dd95SBruce Richardson  */
377099a2dd95SBruce Richardson struct rte_eth_event_ipsec_desc {
37713c2ca0a9SAndrew Rybchenko 	/** Type of RTE_ETH_EVENT_IPSEC_* event */
377299a2dd95SBruce Richardson 	enum rte_eth_event_ipsec_subtype subtype;
37733c2ca0a9SAndrew Rybchenko 	/**
37743c2ca0a9SAndrew Rybchenko 	 * Event specific metadata.
377599a2dd95SBruce Richardson 	 *
377699a2dd95SBruce Richardson 	 * For the following events, *userdata* registered
377799a2dd95SBruce Richardson 	 * with the *rte_security_session* would be returned
377899a2dd95SBruce Richardson 	 * as metadata,
377999a2dd95SBruce Richardson 	 *
378099a2dd95SBruce Richardson 	 * - @ref RTE_ETH_EVENT_IPSEC_ESN_OVERFLOW
378199a2dd95SBruce Richardson 	 * - @ref RTE_ETH_EVENT_IPSEC_SA_TIME_EXPIRY
378299a2dd95SBruce Richardson 	 * - @ref RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY
378399a2dd95SBruce Richardson 	 *
378499a2dd95SBruce Richardson 	 * @see struct rte_security_session_conf
378599a2dd95SBruce Richardson 	 *
378699a2dd95SBruce Richardson 	 */
37873c2ca0a9SAndrew Rybchenko 	uint64_t metadata;
378899a2dd95SBruce Richardson };
378999a2dd95SBruce Richardson 
379099a2dd95SBruce Richardson /**
379199a2dd95SBruce Richardson  * The eth device event type for interrupt, and maybe others in the future.
379299a2dd95SBruce Richardson  */
379399a2dd95SBruce Richardson enum rte_eth_event_type {
379499a2dd95SBruce Richardson 	RTE_ETH_EVENT_UNKNOWN,  /**< unknown event type */
379599a2dd95SBruce Richardson 	RTE_ETH_EVENT_INTR_LSC, /**< lsc interrupt event */
37963c2ca0a9SAndrew Rybchenko 	/** queue state event (enabled/disabled) */
379799a2dd95SBruce Richardson 	RTE_ETH_EVENT_QUEUE_STATE,
37983c2ca0a9SAndrew Rybchenko 	/** reset interrupt event, sent to VF on PF reset */
379999a2dd95SBruce Richardson 	RTE_ETH_EVENT_INTR_RESET,
380099a2dd95SBruce Richardson 	RTE_ETH_EVENT_VF_MBOX,  /**< message from the VF received by PF */
380199a2dd95SBruce Richardson 	RTE_ETH_EVENT_MACSEC,   /**< MACsec offload related event */
380299a2dd95SBruce Richardson 	RTE_ETH_EVENT_INTR_RMV, /**< device removal event */
380399a2dd95SBruce Richardson 	RTE_ETH_EVENT_NEW,      /**< port is probed */
380499a2dd95SBruce Richardson 	RTE_ETH_EVENT_DESTROY,  /**< port is released */
380599a2dd95SBruce Richardson 	RTE_ETH_EVENT_IPSEC,    /**< IPsec offload related event */
380699a2dd95SBruce Richardson 	RTE_ETH_EVENT_FLOW_AGED,/**< New aged-out flows is detected */
380799a2dd95SBruce Richardson 	RTE_ETH_EVENT_MAX       /**< max value of this enum */
380899a2dd95SBruce Richardson };
380999a2dd95SBruce Richardson 
38103c2ca0a9SAndrew Rybchenko /** User application callback to be registered for interrupts. */
381199a2dd95SBruce Richardson typedef int (*rte_eth_dev_cb_fn)(uint16_t port_id,
381299a2dd95SBruce Richardson 		enum rte_eth_event_type event, void *cb_arg, void *ret_param);
381399a2dd95SBruce Richardson 
381499a2dd95SBruce Richardson /**
381599a2dd95SBruce Richardson  * Register a callback function for port event.
381699a2dd95SBruce Richardson  *
381799a2dd95SBruce Richardson  * @param port_id
38185906be5aSAndrew Rybchenko  *  Port ID.
381999a2dd95SBruce Richardson  *  RTE_ETH_ALL means register the event for all port ids.
382099a2dd95SBruce Richardson  * @param event
382199a2dd95SBruce Richardson  *  Event interested.
382299a2dd95SBruce Richardson  * @param cb_fn
382399a2dd95SBruce Richardson  *  User supplied callback function to be called.
382499a2dd95SBruce Richardson  * @param cb_arg
382599a2dd95SBruce Richardson  *  Pointer to the parameters for the registered callback.
382699a2dd95SBruce Richardson  *
382799a2dd95SBruce Richardson  * @return
382899a2dd95SBruce Richardson  *  - On success, zero.
382999a2dd95SBruce Richardson  *  - On failure, a negative value.
383099a2dd95SBruce Richardson  */
383199a2dd95SBruce Richardson int rte_eth_dev_callback_register(uint16_t port_id,
383299a2dd95SBruce Richardson 			enum rte_eth_event_type event,
383399a2dd95SBruce Richardson 		rte_eth_dev_cb_fn cb_fn, void *cb_arg);
383499a2dd95SBruce Richardson 
383599a2dd95SBruce Richardson /**
383699a2dd95SBruce Richardson  * Unregister a callback function for port event.
383799a2dd95SBruce Richardson  *
383899a2dd95SBruce Richardson  * @param port_id
38395906be5aSAndrew Rybchenko  *  Port ID.
384099a2dd95SBruce Richardson  *  RTE_ETH_ALL means unregister the event for all port ids.
384199a2dd95SBruce Richardson  * @param event
384299a2dd95SBruce Richardson  *  Event interested.
384399a2dd95SBruce Richardson  * @param cb_fn
384499a2dd95SBruce Richardson  *  User supplied callback function to be called.
384599a2dd95SBruce Richardson  * @param cb_arg
384699a2dd95SBruce Richardson  *  Pointer to the parameters for the registered callback. -1 means to
384799a2dd95SBruce Richardson  *  remove all for the same callback address and same event.
384899a2dd95SBruce Richardson  *
384999a2dd95SBruce Richardson  * @return
385099a2dd95SBruce Richardson  *  - On success, zero.
385199a2dd95SBruce Richardson  *  - On failure, a negative value.
385299a2dd95SBruce Richardson  */
385399a2dd95SBruce Richardson int rte_eth_dev_callback_unregister(uint16_t port_id,
385499a2dd95SBruce Richardson 			enum rte_eth_event_type event,
385599a2dd95SBruce Richardson 		rte_eth_dev_cb_fn cb_fn, void *cb_arg);
385699a2dd95SBruce Richardson 
385799a2dd95SBruce Richardson /**
385809fd4227SAndrew Rybchenko  * When there is no Rx packet coming in Rx Queue for a long time, we can
385909fd4227SAndrew Rybchenko  * sleep lcore related to Rx Queue for power saving, and enable Rx interrupt
386099a2dd95SBruce Richardson  * to be triggered when Rx packet arrives.
386199a2dd95SBruce Richardson  *
386209fd4227SAndrew Rybchenko  * The rte_eth_dev_rx_intr_enable() function enables Rx queue
386309fd4227SAndrew Rybchenko  * interrupt on specific Rx queue of a port.
386499a2dd95SBruce Richardson  *
386599a2dd95SBruce Richardson  * @param port_id
386699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
386799a2dd95SBruce Richardson  * @param queue_id
386899a2dd95SBruce Richardson  *   The index of the receive queue from which to retrieve input packets.
386999a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
387099a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
387199a2dd95SBruce Richardson  * @return
387299a2dd95SBruce Richardson  *   - (0) if successful.
387399a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
387499a2dd95SBruce Richardson  *     that operation.
387599a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
387699a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
387799a2dd95SBruce Richardson  */
387899a2dd95SBruce Richardson int rte_eth_dev_rx_intr_enable(uint16_t port_id, uint16_t queue_id);
387999a2dd95SBruce Richardson 
388099a2dd95SBruce Richardson /**
388109fd4227SAndrew Rybchenko  * When lcore wakes up from Rx interrupt indicating packet coming, disable Rx
388299a2dd95SBruce Richardson  * interrupt and returns to polling mode.
388399a2dd95SBruce Richardson  *
388409fd4227SAndrew Rybchenko  * The rte_eth_dev_rx_intr_disable() function disables Rx queue
388509fd4227SAndrew Rybchenko  * interrupt on specific Rx queue of a port.
388699a2dd95SBruce Richardson  *
388799a2dd95SBruce Richardson  * @param port_id
388899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
388999a2dd95SBruce Richardson  * @param queue_id
389099a2dd95SBruce Richardson  *   The index of the receive queue from which to retrieve input packets.
389199a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
389299a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
389399a2dd95SBruce Richardson  * @return
389499a2dd95SBruce Richardson  *   - (0) if successful.
389599a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
389699a2dd95SBruce Richardson  *     that operation.
389799a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
389899a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
389999a2dd95SBruce Richardson  */
390099a2dd95SBruce Richardson int rte_eth_dev_rx_intr_disable(uint16_t port_id, uint16_t queue_id);
390199a2dd95SBruce Richardson 
390299a2dd95SBruce Richardson /**
390309fd4227SAndrew Rybchenko  * Rx Interrupt control per port.
390499a2dd95SBruce Richardson  *
390599a2dd95SBruce Richardson  * @param port_id
390699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
390799a2dd95SBruce Richardson  * @param epfd
390899a2dd95SBruce Richardson  *   Epoll instance fd which the intr vector associated to.
390999a2dd95SBruce Richardson  *   Using RTE_EPOLL_PER_THREAD allows to use per thread epoll instance.
391099a2dd95SBruce Richardson  * @param op
391199a2dd95SBruce Richardson  *   The operation be performed for the vector.
391299a2dd95SBruce Richardson  *   Operation type of {RTE_INTR_EVENT_ADD, RTE_INTR_EVENT_DEL}.
391399a2dd95SBruce Richardson  * @param data
391499a2dd95SBruce Richardson  *   User raw data.
391599a2dd95SBruce Richardson  * @return
391699a2dd95SBruce Richardson  *   - On success, zero.
391799a2dd95SBruce Richardson  *   - On failure, a negative value.
391899a2dd95SBruce Richardson  */
391999a2dd95SBruce Richardson int rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data);
392099a2dd95SBruce Richardson 
392199a2dd95SBruce Richardson /**
392209fd4227SAndrew Rybchenko  * Rx Interrupt control per queue.
392399a2dd95SBruce Richardson  *
392499a2dd95SBruce Richardson  * @param port_id
392599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
392699a2dd95SBruce Richardson  * @param queue_id
392799a2dd95SBruce Richardson  *   The index of the receive queue from which to retrieve input packets.
392899a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
392999a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
393099a2dd95SBruce Richardson  * @param epfd
393199a2dd95SBruce Richardson  *   Epoll instance fd which the intr vector associated to.
393299a2dd95SBruce Richardson  *   Using RTE_EPOLL_PER_THREAD allows to use per thread epoll instance.
393399a2dd95SBruce Richardson  * @param op
393499a2dd95SBruce Richardson  *   The operation be performed for the vector.
393599a2dd95SBruce Richardson  *   Operation type of {RTE_INTR_EVENT_ADD, RTE_INTR_EVENT_DEL}.
393699a2dd95SBruce Richardson  * @param data
393799a2dd95SBruce Richardson  *   User raw data.
393899a2dd95SBruce Richardson  * @return
393999a2dd95SBruce Richardson  *   - On success, zero.
394099a2dd95SBruce Richardson  *   - On failure, a negative value.
394199a2dd95SBruce Richardson  */
394299a2dd95SBruce Richardson int rte_eth_dev_rx_intr_ctl_q(uint16_t port_id, uint16_t queue_id,
394399a2dd95SBruce Richardson 			      int epfd, int op, void *data);
394499a2dd95SBruce Richardson 
394599a2dd95SBruce Richardson /**
394699a2dd95SBruce Richardson  * Get interrupt fd per Rx queue.
394799a2dd95SBruce Richardson  *
394899a2dd95SBruce Richardson  * @param port_id
394999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
395099a2dd95SBruce Richardson  * @param queue_id
395199a2dd95SBruce Richardson  *   The index of the receive queue from which to retrieve input packets.
395299a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
395399a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
395499a2dd95SBruce Richardson  * @return
395599a2dd95SBruce Richardson  *   - (>=0) the interrupt fd associated to the requested Rx queue if
395699a2dd95SBruce Richardson  *           successful.
395799a2dd95SBruce Richardson  *   - (-1) on error.
395899a2dd95SBruce Richardson  */
395999a2dd95SBruce Richardson int
396099a2dd95SBruce Richardson rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t queue_id);
396199a2dd95SBruce Richardson 
396299a2dd95SBruce Richardson /**
396399a2dd95SBruce Richardson  * Turn on the LED on the Ethernet device.
396499a2dd95SBruce Richardson  * This function turns on the LED on the Ethernet device.
396599a2dd95SBruce Richardson  *
396699a2dd95SBruce Richardson  * @param port_id
396799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
396899a2dd95SBruce Richardson  * @return
396999a2dd95SBruce Richardson  *   - (0) if successful.
397099a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
397199a2dd95SBruce Richardson  *     that operation.
397299a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
397399a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
397499a2dd95SBruce Richardson  */
397599a2dd95SBruce Richardson int  rte_eth_led_on(uint16_t port_id);
397699a2dd95SBruce Richardson 
397799a2dd95SBruce Richardson /**
397899a2dd95SBruce Richardson  * Turn off the LED on the Ethernet device.
397999a2dd95SBruce Richardson  * This function turns off the LED on the Ethernet device.
398099a2dd95SBruce Richardson  *
398199a2dd95SBruce Richardson  * @param port_id
398299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
398399a2dd95SBruce Richardson  * @return
398499a2dd95SBruce Richardson  *   - (0) if successful.
398599a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
398699a2dd95SBruce Richardson  *     that operation.
398799a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
398899a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
398999a2dd95SBruce Richardson  */
399099a2dd95SBruce Richardson int  rte_eth_led_off(uint16_t port_id);
399199a2dd95SBruce Richardson 
399299a2dd95SBruce Richardson /**
399399a2dd95SBruce Richardson  * @warning
399499a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
399599a2dd95SBruce Richardson  *
399699a2dd95SBruce Richardson  * Get Forward Error Correction(FEC) capability.
399799a2dd95SBruce Richardson  *
399899a2dd95SBruce Richardson  * @param port_id
399999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
400099a2dd95SBruce Richardson  * @param speed_fec_capa
400199a2dd95SBruce Richardson  *   speed_fec_capa is out only with per-speed capabilities.
400299a2dd95SBruce Richardson  *   If set to NULL, the function returns the required number
400399a2dd95SBruce Richardson  *   of required array entries.
400499a2dd95SBruce Richardson  * @param num
400599a2dd95SBruce Richardson  *   a number of elements in an speed_fec_capa array.
400699a2dd95SBruce Richardson  *
400799a2dd95SBruce Richardson  * @return
400899a2dd95SBruce Richardson  *   - A non-negative value lower or equal to num: success. The return value
400999a2dd95SBruce Richardson  *     is the number of entries filled in the fec capa array.
401099a2dd95SBruce Richardson  *   - A non-negative value higher than num: error, the given fec capa array
401199a2dd95SBruce Richardson  *     is too small. The return value corresponds to the num that should
401299a2dd95SBruce Richardson  *     be given to succeed. The entries in fec capa array are not valid and
401399a2dd95SBruce Richardson  *     shall not be used by the caller.
401499a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
401599a2dd95SBruce Richardson  *     that operation.
401699a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
401799a2dd95SBruce Richardson  *   - (-ENODEV)  if *port_id* invalid.
401899a2dd95SBruce Richardson  *   - (-EINVAL)  if *num* or *speed_fec_capa* invalid
401999a2dd95SBruce Richardson  */
402099a2dd95SBruce Richardson __rte_experimental
402199a2dd95SBruce Richardson int rte_eth_fec_get_capability(uint16_t port_id,
402299a2dd95SBruce Richardson 			       struct rte_eth_fec_capa *speed_fec_capa,
402399a2dd95SBruce Richardson 			       unsigned int num);
402499a2dd95SBruce Richardson 
402599a2dd95SBruce Richardson /**
402699a2dd95SBruce Richardson  * @warning
402799a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
402899a2dd95SBruce Richardson  *
402999a2dd95SBruce Richardson  * Get current Forward Error Correction(FEC) mode.
403099a2dd95SBruce Richardson  * If link is down and AUTO is enabled, AUTO is returned, otherwise,
403199a2dd95SBruce Richardson  * configured FEC mode is returned.
403299a2dd95SBruce Richardson  * If link is up, current FEC mode is returned.
403399a2dd95SBruce Richardson  *
403499a2dd95SBruce Richardson  * @param port_id
403599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
403699a2dd95SBruce Richardson  * @param fec_capa
403799a2dd95SBruce Richardson  *   A bitmask of enabled FEC modes. If AUTO bit is set, other
403899a2dd95SBruce Richardson  *   bits specify FEC modes which may be negotiated. If AUTO
403999a2dd95SBruce Richardson  *   bit is clear, specify FEC modes to be used (only one valid
404099a2dd95SBruce Richardson  *   mode per speed may be set).
404199a2dd95SBruce Richardson  * @return
404299a2dd95SBruce Richardson  *   - (0) if successful.
404399a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
404499a2dd95SBruce Richardson  *     that operation.
404599a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
404699a2dd95SBruce Richardson  *   - (-ENODEV)  if *port_id* invalid.
404799a2dd95SBruce Richardson  */
404899a2dd95SBruce Richardson __rte_experimental
404999a2dd95SBruce Richardson int rte_eth_fec_get(uint16_t port_id, uint32_t *fec_capa);
405099a2dd95SBruce Richardson 
405199a2dd95SBruce Richardson /**
405299a2dd95SBruce Richardson  * @warning
405399a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
405499a2dd95SBruce Richardson  *
405599a2dd95SBruce Richardson  * Set Forward Error Correction(FEC) mode.
405699a2dd95SBruce Richardson  *
405799a2dd95SBruce Richardson  * @param port_id
405899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
405999a2dd95SBruce Richardson  * @param fec_capa
406099a2dd95SBruce Richardson  *   A bitmask of allowed FEC modes. If AUTO bit is set, other
406199a2dd95SBruce Richardson  *   bits specify FEC modes which may be negotiated. If AUTO
406299a2dd95SBruce Richardson  *   bit is clear, specify FEC modes to be used (only one valid
406399a2dd95SBruce Richardson  *   mode per speed may be set).
406499a2dd95SBruce Richardson  * @return
406599a2dd95SBruce Richardson  *   - (0) if successful.
406699a2dd95SBruce Richardson  *   - (-EINVAL) if the FEC mode is not valid.
406799a2dd95SBruce Richardson  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
406899a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
406999a2dd95SBruce Richardson  *   - (-ENODEV)  if *port_id* invalid.
407099a2dd95SBruce Richardson  */
407199a2dd95SBruce Richardson __rte_experimental
407299a2dd95SBruce Richardson int rte_eth_fec_set(uint16_t port_id, uint32_t fec_capa);
407399a2dd95SBruce Richardson 
407499a2dd95SBruce Richardson /**
407599a2dd95SBruce Richardson  * Get current status of the Ethernet link flow control for Ethernet device
407699a2dd95SBruce Richardson  *
407799a2dd95SBruce Richardson  * @param port_id
407899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
407999a2dd95SBruce Richardson  * @param fc_conf
408099a2dd95SBruce Richardson  *   The pointer to the structure where to store the flow control parameters.
408199a2dd95SBruce Richardson  * @return
408299a2dd95SBruce Richardson  *   - (0) if successful.
408399a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support flow control.
408499a2dd95SBruce Richardson  *   - (-ENODEV)  if *port_id* invalid.
408599a2dd95SBruce Richardson  *   - (-EIO)  if device is removed.
408653ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
408799a2dd95SBruce Richardson  */
408899a2dd95SBruce Richardson int rte_eth_dev_flow_ctrl_get(uint16_t port_id,
408999a2dd95SBruce Richardson 			      struct rte_eth_fc_conf *fc_conf);
409099a2dd95SBruce Richardson 
409199a2dd95SBruce Richardson /**
409299a2dd95SBruce Richardson  * Configure the Ethernet link flow control for Ethernet device
409399a2dd95SBruce Richardson  *
409499a2dd95SBruce Richardson  * @param port_id
409599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
409699a2dd95SBruce Richardson  * @param fc_conf
409799a2dd95SBruce Richardson  *   The pointer to the structure of the flow control parameters.
409899a2dd95SBruce Richardson  * @return
409999a2dd95SBruce Richardson  *   - (0) if successful.
410099a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support flow control mode.
410199a2dd95SBruce Richardson  *   - (-ENODEV)  if *port_id* invalid.
410299a2dd95SBruce Richardson  *   - (-EINVAL)  if bad parameter
410399a2dd95SBruce Richardson  *   - (-EIO)     if flow control setup failure or device is removed.
410499a2dd95SBruce Richardson  */
410599a2dd95SBruce Richardson int rte_eth_dev_flow_ctrl_set(uint16_t port_id,
410699a2dd95SBruce Richardson 			      struct rte_eth_fc_conf *fc_conf);
410799a2dd95SBruce Richardson 
410899a2dd95SBruce Richardson /**
410999a2dd95SBruce Richardson  * Configure the Ethernet priority flow control under DCB environment
411099a2dd95SBruce Richardson  * for Ethernet device.
411199a2dd95SBruce Richardson  *
411299a2dd95SBruce Richardson  * @param port_id
411399a2dd95SBruce Richardson  * The port identifier of the Ethernet device.
411499a2dd95SBruce Richardson  * @param pfc_conf
411599a2dd95SBruce Richardson  * The pointer to the structure of the priority flow control parameters.
411699a2dd95SBruce Richardson  * @return
411799a2dd95SBruce Richardson  *   - (0) if successful.
411899a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support priority flow control mode.
411999a2dd95SBruce Richardson  *   - (-ENODEV)  if *port_id* invalid.
412099a2dd95SBruce Richardson  *   - (-EINVAL)  if bad parameter
412199a2dd95SBruce Richardson  *   - (-EIO)     if flow control setup failure or device is removed.
412299a2dd95SBruce Richardson  */
412399a2dd95SBruce Richardson int rte_eth_dev_priority_flow_ctrl_set(uint16_t port_id,
412499a2dd95SBruce Richardson 				struct rte_eth_pfc_conf *pfc_conf);
412599a2dd95SBruce Richardson 
412699a2dd95SBruce Richardson /**
412799a2dd95SBruce Richardson  * Add a MAC address to the set used for filtering incoming packets.
412899a2dd95SBruce Richardson  *
412999a2dd95SBruce Richardson  * @param port_id
413099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
413199a2dd95SBruce Richardson  * @param mac_addr
413299a2dd95SBruce Richardson  *   The MAC address to add.
413399a2dd95SBruce Richardson  * @param pool
413499a2dd95SBruce Richardson  *   VMDq pool index to associate address with (if VMDq is enabled). If VMDq is
413599a2dd95SBruce Richardson  *   not enabled, this should be set to 0.
413699a2dd95SBruce Richardson  * @return
413799a2dd95SBruce Richardson  *   - (0) if successfully added or *mac_addr* was already added.
413899a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support this feature.
413999a2dd95SBruce Richardson  *   - (-ENODEV) if *port* is invalid.
414099a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
414199a2dd95SBruce Richardson  *   - (-ENOSPC) if no more MAC addresses can be added.
414299a2dd95SBruce Richardson  *   - (-EINVAL) if MAC address is invalid.
414399a2dd95SBruce Richardson  */
414499a2dd95SBruce Richardson int rte_eth_dev_mac_addr_add(uint16_t port_id, struct rte_ether_addr *mac_addr,
414599a2dd95SBruce Richardson 				uint32_t pool);
414699a2dd95SBruce Richardson 
414799a2dd95SBruce Richardson /**
414899a2dd95SBruce Richardson  * Remove a MAC address from the internal array of addresses.
414999a2dd95SBruce Richardson  *
415099a2dd95SBruce Richardson  * @param port_id
415199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
415299a2dd95SBruce Richardson  * @param mac_addr
415399a2dd95SBruce Richardson  *   MAC address to remove.
415499a2dd95SBruce Richardson  * @return
415599a2dd95SBruce Richardson  *   - (0) if successful, or *mac_addr* didn't exist.
415699a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
415799a2dd95SBruce Richardson  *   - (-ENODEV) if *port* invalid.
415853ef1b34SMin Hu (Connor)  *   - (-EADDRINUSE) if attempting to remove the default MAC address.
415953ef1b34SMin Hu (Connor)  *   - (-EINVAL) if MAC address is invalid.
416099a2dd95SBruce Richardson  */
416199a2dd95SBruce Richardson int rte_eth_dev_mac_addr_remove(uint16_t port_id,
416299a2dd95SBruce Richardson 				struct rte_ether_addr *mac_addr);
416399a2dd95SBruce Richardson 
416499a2dd95SBruce Richardson /**
416599a2dd95SBruce Richardson  * Set the default MAC address.
416699a2dd95SBruce Richardson  *
416799a2dd95SBruce Richardson  * @param port_id
416899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
416999a2dd95SBruce Richardson  * @param mac_addr
417099a2dd95SBruce Richardson  *   New default MAC address.
417199a2dd95SBruce Richardson  * @return
417299a2dd95SBruce Richardson  *   - (0) if successful, or *mac_addr* didn't exist.
417399a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
417499a2dd95SBruce Richardson  *   - (-ENODEV) if *port* invalid.
417599a2dd95SBruce Richardson  *   - (-EINVAL) if MAC address is invalid.
417699a2dd95SBruce Richardson  */
417799a2dd95SBruce Richardson int rte_eth_dev_default_mac_addr_set(uint16_t port_id,
417899a2dd95SBruce Richardson 		struct rte_ether_addr *mac_addr);
417999a2dd95SBruce Richardson 
418099a2dd95SBruce Richardson /**
418199a2dd95SBruce Richardson  * Update Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
418299a2dd95SBruce Richardson  *
418399a2dd95SBruce Richardson  * @param port_id
418499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
418599a2dd95SBruce Richardson  * @param reta_conf
418699a2dd95SBruce Richardson  *   RETA to update.
418799a2dd95SBruce Richardson  * @param reta_size
418899a2dd95SBruce Richardson  *   Redirection table size. The table size can be queried by
418999a2dd95SBruce Richardson  *   rte_eth_dev_info_get().
419099a2dd95SBruce Richardson  * @return
419199a2dd95SBruce Richardson  *   - (0) if successful.
419299a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
419399a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
419499a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
419599a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
419699a2dd95SBruce Richardson  */
419799a2dd95SBruce Richardson int rte_eth_dev_rss_reta_update(uint16_t port_id,
419899a2dd95SBruce Richardson 				struct rte_eth_rss_reta_entry64 *reta_conf,
419999a2dd95SBruce Richardson 				uint16_t reta_size);
420099a2dd95SBruce Richardson 
420199a2dd95SBruce Richardson /**
420299a2dd95SBruce Richardson  * Query Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
420399a2dd95SBruce Richardson  *
420499a2dd95SBruce Richardson  * @param port_id
420599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
420699a2dd95SBruce Richardson  * @param reta_conf
420799a2dd95SBruce Richardson  *   RETA to query. For each requested reta entry, corresponding bit
420899a2dd95SBruce Richardson  *   in mask must be set.
420999a2dd95SBruce Richardson  * @param reta_size
421099a2dd95SBruce Richardson  *   Redirection table size. The table size can be queried by
421199a2dd95SBruce Richardson  *   rte_eth_dev_info_get().
421299a2dd95SBruce Richardson  * @return
421399a2dd95SBruce Richardson  *   - (0) if successful.
421499a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
421599a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
421699a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
421799a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
421899a2dd95SBruce Richardson  */
421999a2dd95SBruce Richardson int rte_eth_dev_rss_reta_query(uint16_t port_id,
422099a2dd95SBruce Richardson 			       struct rte_eth_rss_reta_entry64 *reta_conf,
422199a2dd95SBruce Richardson 			       uint16_t reta_size);
422299a2dd95SBruce Richardson 
422399a2dd95SBruce Richardson /**
422499a2dd95SBruce Richardson  * Updates unicast hash table for receiving packet with the given destination
422509fd4227SAndrew Rybchenko  * MAC address, and the packet is routed to all VFs for which the Rx mode is
422699a2dd95SBruce Richardson  * accept packets that match the unicast hash table.
422799a2dd95SBruce Richardson  *
422899a2dd95SBruce Richardson  * @param port_id
422999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
423099a2dd95SBruce Richardson  * @param addr
423199a2dd95SBruce Richardson  *   Unicast MAC address.
423299a2dd95SBruce Richardson  * @param on
423399a2dd95SBruce Richardson  *    1 - Set an unicast hash bit for receiving packets with the MAC address.
423499a2dd95SBruce Richardson  *    0 - Clear an unicast hash bit.
423599a2dd95SBruce Richardson  * @return
423699a2dd95SBruce Richardson  *   - (0) if successful.
423799a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
423899a2dd95SBruce Richardson   *  - (-ENODEV) if *port_id* invalid.
423999a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
424099a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
424199a2dd95SBruce Richardson  */
424299a2dd95SBruce Richardson int rte_eth_dev_uc_hash_table_set(uint16_t port_id, struct rte_ether_addr *addr,
424399a2dd95SBruce Richardson 				  uint8_t on);
424499a2dd95SBruce Richardson 
424599a2dd95SBruce Richardson /**
424699a2dd95SBruce Richardson  * Updates all unicast hash bitmaps for receiving packet with any Unicast
424709fd4227SAndrew Rybchenko  * Ethernet MAC addresses,the packet is routed to all VFs for which the Rx
424899a2dd95SBruce Richardson  * mode is accept packets that match the unicast hash table.
424999a2dd95SBruce Richardson  *
425099a2dd95SBruce Richardson  * @param port_id
425199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
425299a2dd95SBruce Richardson  * @param on
425399a2dd95SBruce Richardson  *    1 - Set all unicast hash bitmaps for receiving all the Ethernet
425499a2dd95SBruce Richardson  *         MAC addresses
425599a2dd95SBruce Richardson  *    0 - Clear all unicast hash bitmaps
425699a2dd95SBruce Richardson  * @return
425799a2dd95SBruce Richardson  *   - (0) if successful.
425899a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
425999a2dd95SBruce Richardson   *  - (-ENODEV) if *port_id* invalid.
426099a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
426199a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
426299a2dd95SBruce Richardson  */
426399a2dd95SBruce Richardson int rte_eth_dev_uc_all_hash_table_set(uint16_t port_id, uint8_t on);
426499a2dd95SBruce Richardson 
426599a2dd95SBruce Richardson /**
426699a2dd95SBruce Richardson  * Set the rate limitation for a queue on an Ethernet device.
426799a2dd95SBruce Richardson  *
426899a2dd95SBruce Richardson  * @param port_id
426999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
427099a2dd95SBruce Richardson  * @param queue_idx
42715906be5aSAndrew Rybchenko  *   The queue ID.
427299a2dd95SBruce Richardson  * @param tx_rate
427309fd4227SAndrew Rybchenko  *   The Tx rate in Mbps. Allocated from the total port link speed.
427499a2dd95SBruce Richardson  * @return
427599a2dd95SBruce Richardson  *   - (0) if successful.
427699a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support this feature.
427799a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
427899a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
427999a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
428099a2dd95SBruce Richardson  */
428199a2dd95SBruce Richardson int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx,
428299a2dd95SBruce Richardson 			uint16_t tx_rate);
428399a2dd95SBruce Richardson 
428499a2dd95SBruce Richardson /**
428599a2dd95SBruce Richardson  * Configuration of Receive Side Scaling hash computation of Ethernet device.
428699a2dd95SBruce Richardson  *
428799a2dd95SBruce Richardson  * @param port_id
428899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
428999a2dd95SBruce Richardson  * @param rss_conf
429099a2dd95SBruce Richardson  *   The new configuration to use for RSS hash computation on the port.
429199a2dd95SBruce Richardson  * @return
429299a2dd95SBruce Richardson  *   - (0) if successful.
429399a2dd95SBruce Richardson  *   - (-ENODEV) if port identifier is invalid.
429499a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
429599a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
429699a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
429799a2dd95SBruce Richardson  */
429899a2dd95SBruce Richardson int rte_eth_dev_rss_hash_update(uint16_t port_id,
429999a2dd95SBruce Richardson 				struct rte_eth_rss_conf *rss_conf);
430099a2dd95SBruce Richardson 
430199a2dd95SBruce Richardson /**
430299a2dd95SBruce Richardson  * Retrieve current configuration of Receive Side Scaling hash computation
430399a2dd95SBruce Richardson  * of Ethernet device.
430499a2dd95SBruce Richardson  *
430599a2dd95SBruce Richardson  * @param port_id
430699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
430799a2dd95SBruce Richardson  * @param rss_conf
430899a2dd95SBruce Richardson  *   Where to store the current RSS hash configuration of the Ethernet device.
430999a2dd95SBruce Richardson  * @return
431099a2dd95SBruce Richardson  *   - (0) if successful.
431199a2dd95SBruce Richardson  *   - (-ENODEV) if port identifier is invalid.
431299a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
431399a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support RSS.
431453ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
431599a2dd95SBruce Richardson  */
431699a2dd95SBruce Richardson int
431799a2dd95SBruce Richardson rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
431899a2dd95SBruce Richardson 			      struct rte_eth_rss_conf *rss_conf);
431999a2dd95SBruce Richardson 
432099a2dd95SBruce Richardson /**
432199a2dd95SBruce Richardson  * Add UDP tunneling port for a type of tunnel.
432299a2dd95SBruce Richardson  *
432399a2dd95SBruce Richardson  * Some NICs may require such configuration to properly parse a tunnel
432499a2dd95SBruce Richardson  * with any standard or custom UDP port.
432599a2dd95SBruce Richardson  * The packets with this UDP port will be parsed for this type of tunnel.
432699a2dd95SBruce Richardson  * The device parser will also check the rest of the tunnel headers
432799a2dd95SBruce Richardson  * before classifying the packet.
432899a2dd95SBruce Richardson  *
432999a2dd95SBruce Richardson  * With some devices, this API will affect packet classification, i.e.:
433099a2dd95SBruce Richardson  *     - mbuf.packet_type reported on Rx
433199a2dd95SBruce Richardson  *     - rte_flow rules with tunnel items
433299a2dd95SBruce Richardson  *
433399a2dd95SBruce Richardson  * @param port_id
433499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
433599a2dd95SBruce Richardson  * @param tunnel_udp
433699a2dd95SBruce Richardson  *   UDP tunneling configuration.
433799a2dd95SBruce Richardson  *
433899a2dd95SBruce Richardson  * @return
433999a2dd95SBruce Richardson  *   - (0) if successful.
434099a2dd95SBruce Richardson  *   - (-ENODEV) if port identifier is invalid.
434199a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
434299a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support tunnel type.
434399a2dd95SBruce Richardson  */
434499a2dd95SBruce Richardson int
434599a2dd95SBruce Richardson rte_eth_dev_udp_tunnel_port_add(uint16_t port_id,
434699a2dd95SBruce Richardson 				struct rte_eth_udp_tunnel *tunnel_udp);
434799a2dd95SBruce Richardson 
434899a2dd95SBruce Richardson /**
434999a2dd95SBruce Richardson  * Delete UDP tunneling port for a type of tunnel.
435099a2dd95SBruce Richardson  *
435199a2dd95SBruce Richardson  * The packets with this UDP port will not be classified as this type of tunnel
435299a2dd95SBruce Richardson  * anymore if the device use such mapping for tunnel packet classification.
435399a2dd95SBruce Richardson  *
435499a2dd95SBruce Richardson  * @see rte_eth_dev_udp_tunnel_port_add
435599a2dd95SBruce Richardson  *
435699a2dd95SBruce Richardson  * @param port_id
435799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
435899a2dd95SBruce Richardson  * @param tunnel_udp
435999a2dd95SBruce Richardson  *   UDP tunneling configuration.
436099a2dd95SBruce Richardson  *
436199a2dd95SBruce Richardson  * @return
436299a2dd95SBruce Richardson  *   - (0) if successful.
436399a2dd95SBruce Richardson  *   - (-ENODEV) if port identifier is invalid.
436499a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
436599a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support tunnel type.
436699a2dd95SBruce Richardson  */
436799a2dd95SBruce Richardson int
436899a2dd95SBruce Richardson rte_eth_dev_udp_tunnel_port_delete(uint16_t port_id,
436999a2dd95SBruce Richardson 				   struct rte_eth_udp_tunnel *tunnel_udp);
437099a2dd95SBruce Richardson 
437199a2dd95SBruce Richardson /**
437299a2dd95SBruce Richardson  * Get DCB information on an Ethernet device.
437399a2dd95SBruce Richardson  *
437499a2dd95SBruce Richardson  * @param port_id
437599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
437699a2dd95SBruce Richardson  * @param dcb_info
4377064e90c4SAndrew Rybchenko  *   DCB information.
437899a2dd95SBruce Richardson  * @return
437999a2dd95SBruce Richardson  *   - (0) if successful.
438099a2dd95SBruce Richardson  *   - (-ENODEV) if port identifier is invalid.
438199a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
438299a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
438353ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
438499a2dd95SBruce Richardson  */
438599a2dd95SBruce Richardson int rte_eth_dev_get_dcb_info(uint16_t port_id,
438699a2dd95SBruce Richardson 			     struct rte_eth_dcb_info *dcb_info);
438799a2dd95SBruce Richardson 
438899a2dd95SBruce Richardson struct rte_eth_rxtx_callback;
438999a2dd95SBruce Richardson 
439099a2dd95SBruce Richardson /**
439109fd4227SAndrew Rybchenko  * Add a callback to be called on packet Rx on a given port and queue.
439299a2dd95SBruce Richardson  *
439399a2dd95SBruce Richardson  * This API configures a function to be called for each burst of
439499a2dd95SBruce Richardson  * packets received on a given NIC port queue. The return value is a pointer
439599a2dd95SBruce Richardson  * that can be used to later remove the callback using
439699a2dd95SBruce Richardson  * rte_eth_remove_rx_callback().
439799a2dd95SBruce Richardson  *
439899a2dd95SBruce Richardson  * Multiple functions are called in the order that they are added.
439999a2dd95SBruce Richardson  *
440099a2dd95SBruce Richardson  * @param port_id
440199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
440299a2dd95SBruce Richardson  * @param queue_id
440399a2dd95SBruce Richardson  *   The queue on the Ethernet device on which the callback is to be added.
440499a2dd95SBruce Richardson  * @param fn
440599a2dd95SBruce Richardson  *   The callback function
440699a2dd95SBruce Richardson  * @param user_param
440799a2dd95SBruce Richardson  *   A generic pointer parameter which will be passed to each invocation of the
440899a2dd95SBruce Richardson  *   callback function on this port and queue. Inter-thread synchronization
440999a2dd95SBruce Richardson  *   of any user data changes is the responsibility of the user.
441099a2dd95SBruce Richardson  *
441199a2dd95SBruce Richardson  * @return
441299a2dd95SBruce Richardson  *   NULL on error.
441399a2dd95SBruce Richardson  *   On success, a pointer value which can later be used to remove the callback.
441499a2dd95SBruce Richardson  */
441599a2dd95SBruce Richardson const struct rte_eth_rxtx_callback *
441699a2dd95SBruce Richardson rte_eth_add_rx_callback(uint16_t port_id, uint16_t queue_id,
441799a2dd95SBruce Richardson 		rte_rx_callback_fn fn, void *user_param);
441899a2dd95SBruce Richardson 
441999a2dd95SBruce Richardson /**
442009fd4227SAndrew Rybchenko  * Add a callback that must be called first on packet Rx on a given port
442199a2dd95SBruce Richardson  * and queue.
442299a2dd95SBruce Richardson  *
442399a2dd95SBruce Richardson  * This API configures a first function to be called for each burst of
442499a2dd95SBruce Richardson  * packets received on a given NIC port queue. The return value is a pointer
442599a2dd95SBruce Richardson  * that can be used to later remove the callback using
442699a2dd95SBruce Richardson  * rte_eth_remove_rx_callback().
442799a2dd95SBruce Richardson  *
442899a2dd95SBruce Richardson  * Multiple functions are called in the order that they are added.
442999a2dd95SBruce Richardson  *
443099a2dd95SBruce Richardson  * @param port_id
443199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
443299a2dd95SBruce Richardson  * @param queue_id
443399a2dd95SBruce Richardson  *   The queue on the Ethernet device on which the callback is to be added.
443499a2dd95SBruce Richardson  * @param fn
443599a2dd95SBruce Richardson  *   The callback function
443699a2dd95SBruce Richardson  * @param user_param
443799a2dd95SBruce Richardson  *   A generic pointer parameter which will be passed to each invocation of the
443899a2dd95SBruce Richardson  *   callback function on this port and queue. Inter-thread synchronization
443999a2dd95SBruce Richardson  *   of any user data changes is the responsibility of the user.
444099a2dd95SBruce Richardson  *
444199a2dd95SBruce Richardson  * @return
444299a2dd95SBruce Richardson  *   NULL on error.
444399a2dd95SBruce Richardson  *   On success, a pointer value which can later be used to remove the callback.
444499a2dd95SBruce Richardson  */
444599a2dd95SBruce Richardson const struct rte_eth_rxtx_callback *
444699a2dd95SBruce Richardson rte_eth_add_first_rx_callback(uint16_t port_id, uint16_t queue_id,
444799a2dd95SBruce Richardson 		rte_rx_callback_fn fn, void *user_param);
444899a2dd95SBruce Richardson 
444999a2dd95SBruce Richardson /**
445009fd4227SAndrew Rybchenko  * Add a callback to be called on packet Tx on a given port and queue.
445199a2dd95SBruce Richardson  *
445299a2dd95SBruce Richardson  * This API configures a function to be called for each burst of
445399a2dd95SBruce Richardson  * packets sent on a given NIC port queue. The return value is a pointer
445499a2dd95SBruce Richardson  * that can be used to later remove the callback using
445599a2dd95SBruce Richardson  * rte_eth_remove_tx_callback().
445699a2dd95SBruce Richardson  *
445799a2dd95SBruce Richardson  * Multiple functions are called in the order that they are added.
445899a2dd95SBruce Richardson  *
445999a2dd95SBruce Richardson  * @param port_id
446099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
446199a2dd95SBruce Richardson  * @param queue_id
446299a2dd95SBruce Richardson  *   The queue on the Ethernet device on which the callback is to be added.
446399a2dd95SBruce Richardson  * @param fn
446499a2dd95SBruce Richardson  *   The callback function
446599a2dd95SBruce Richardson  * @param user_param
446699a2dd95SBruce Richardson  *   A generic pointer parameter which will be passed to each invocation of the
446799a2dd95SBruce Richardson  *   callback function on this port and queue. Inter-thread synchronization
446899a2dd95SBruce Richardson  *   of any user data changes is the responsibility of the user.
446999a2dd95SBruce Richardson  *
447099a2dd95SBruce Richardson  * @return
447199a2dd95SBruce Richardson  *   NULL on error.
447299a2dd95SBruce Richardson  *   On success, a pointer value which can later be used to remove the callback.
447399a2dd95SBruce Richardson  */
447499a2dd95SBruce Richardson const struct rte_eth_rxtx_callback *
447599a2dd95SBruce Richardson rte_eth_add_tx_callback(uint16_t port_id, uint16_t queue_id,
447699a2dd95SBruce Richardson 		rte_tx_callback_fn fn, void *user_param);
447799a2dd95SBruce Richardson 
447899a2dd95SBruce Richardson /**
447909fd4227SAndrew Rybchenko  * Remove an Rx packet callback from a given port and queue.
448099a2dd95SBruce Richardson  *
448199a2dd95SBruce Richardson  * This function is used to removed callbacks that were added to a NIC port
448299a2dd95SBruce Richardson  * queue using rte_eth_add_rx_callback().
448399a2dd95SBruce Richardson  *
448499a2dd95SBruce Richardson  * Note: the callback is removed from the callback list but it isn't freed
448599a2dd95SBruce Richardson  * since the it may still be in use. The memory for the callback can be
448699a2dd95SBruce Richardson  * subsequently freed back by the application by calling rte_free():
448799a2dd95SBruce Richardson  *
448899a2dd95SBruce Richardson  * - Immediately - if the port is stopped, or the user knows that no
448909fd4227SAndrew Rybchenko  *   callbacks are in flight e.g. if called from the thread doing Rx/Tx
449099a2dd95SBruce Richardson  *   on that queue.
449199a2dd95SBruce Richardson  *
449299a2dd95SBruce Richardson  * - After a short delay - where the delay is sufficient to allow any
449399a2dd95SBruce Richardson  *   in-flight callbacks to complete. Alternately, the RCU mechanism can be
449499a2dd95SBruce Richardson  *   used to detect when data plane threads have ceased referencing the
449599a2dd95SBruce Richardson  *   callback memory.
449699a2dd95SBruce Richardson  *
449799a2dd95SBruce Richardson  * @param port_id
449899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
449999a2dd95SBruce Richardson  * @param queue_id
450099a2dd95SBruce Richardson  *   The queue on the Ethernet device from which the callback is to be removed.
450199a2dd95SBruce Richardson  * @param user_cb
450299a2dd95SBruce Richardson  *   User supplied callback created via rte_eth_add_rx_callback().
450399a2dd95SBruce Richardson  *
450499a2dd95SBruce Richardson  * @return
450599a2dd95SBruce Richardson  *   - 0: Success. Callback was removed.
450699a2dd95SBruce Richardson  *   - -ENODEV:  If *port_id* is invalid.
450799a2dd95SBruce Richardson  *   - -ENOTSUP: Callback support is not available.
450899a2dd95SBruce Richardson  *   - -EINVAL:  The queue_id is out of range, or the callback
450999a2dd95SBruce Richardson  *               is NULL or not found for the port/queue.
451099a2dd95SBruce Richardson  */
451199a2dd95SBruce Richardson int rte_eth_remove_rx_callback(uint16_t port_id, uint16_t queue_id,
451299a2dd95SBruce Richardson 		const struct rte_eth_rxtx_callback *user_cb);
451399a2dd95SBruce Richardson 
451499a2dd95SBruce Richardson /**
451509fd4227SAndrew Rybchenko  * Remove a Tx packet callback from a given port and queue.
451699a2dd95SBruce Richardson  *
451799a2dd95SBruce Richardson  * This function is used to removed callbacks that were added to a NIC port
451899a2dd95SBruce Richardson  * queue using rte_eth_add_tx_callback().
451999a2dd95SBruce Richardson  *
452099a2dd95SBruce Richardson  * Note: the callback is removed from the callback list but it isn't freed
452199a2dd95SBruce Richardson  * since the it may still be in use. The memory for the callback can be
452299a2dd95SBruce Richardson  * subsequently freed back by the application by calling rte_free():
452399a2dd95SBruce Richardson  *
452499a2dd95SBruce Richardson  * - Immediately - if the port is stopped, or the user knows that no
452509fd4227SAndrew Rybchenko  *   callbacks are in flight e.g. if called from the thread doing Rx/Tx
452699a2dd95SBruce Richardson  *   on that queue.
452799a2dd95SBruce Richardson  *
452899a2dd95SBruce Richardson  * - After a short delay - where the delay is sufficient to allow any
452999a2dd95SBruce Richardson  *   in-flight callbacks to complete. Alternately, the RCU mechanism can be
453099a2dd95SBruce Richardson  *   used to detect when data plane threads have ceased referencing the
453199a2dd95SBruce Richardson  *   callback memory.
453299a2dd95SBruce Richardson  *
453399a2dd95SBruce Richardson  * @param port_id
453499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
453599a2dd95SBruce Richardson  * @param queue_id
453699a2dd95SBruce Richardson  *   The queue on the Ethernet device from which the callback is to be removed.
453799a2dd95SBruce Richardson  * @param user_cb
453899a2dd95SBruce Richardson  *   User supplied callback created via rte_eth_add_tx_callback().
453999a2dd95SBruce Richardson  *
454099a2dd95SBruce Richardson  * @return
454199a2dd95SBruce Richardson  *   - 0: Success. Callback was removed.
454299a2dd95SBruce Richardson  *   - -ENODEV:  If *port_id* is invalid.
454399a2dd95SBruce Richardson  *   - -ENOTSUP: Callback support is not available.
454499a2dd95SBruce Richardson  *   - -EINVAL:  The queue_id is out of range, or the callback
454599a2dd95SBruce Richardson  *               is NULL or not found for the port/queue.
454699a2dd95SBruce Richardson  */
454799a2dd95SBruce Richardson int rte_eth_remove_tx_callback(uint16_t port_id, uint16_t queue_id,
454899a2dd95SBruce Richardson 		const struct rte_eth_rxtx_callback *user_cb);
454999a2dd95SBruce Richardson 
455099a2dd95SBruce Richardson /**
455109fd4227SAndrew Rybchenko  * Retrieve information about given port's Rx queue.
455299a2dd95SBruce Richardson  *
455399a2dd95SBruce Richardson  * @param port_id
455499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
455599a2dd95SBruce Richardson  * @param queue_id
455609fd4227SAndrew Rybchenko  *   The Rx queue on the Ethernet device for which information
455799a2dd95SBruce Richardson  *   will be retrieved.
455899a2dd95SBruce Richardson  * @param qinfo
455999a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_eth_rxq_info_info* to be filled with
456099a2dd95SBruce Richardson  *   the information of the Ethernet device.
456199a2dd95SBruce Richardson  *
456299a2dd95SBruce Richardson  * @return
456399a2dd95SBruce Richardson  *   - 0: Success
456499a2dd95SBruce Richardson  *   - -ENODEV:  If *port_id* is invalid.
456599a2dd95SBruce Richardson  *   - -ENOTSUP: routine is not supported by the device PMD.
456699a2dd95SBruce Richardson  *   - -EINVAL:  The queue_id is out of range, or the queue
456799a2dd95SBruce Richardson  *               is hairpin queue.
456899a2dd95SBruce Richardson  */
456999a2dd95SBruce Richardson int rte_eth_rx_queue_info_get(uint16_t port_id, uint16_t queue_id,
457099a2dd95SBruce Richardson 	struct rte_eth_rxq_info *qinfo);
457199a2dd95SBruce Richardson 
457299a2dd95SBruce Richardson /**
457309fd4227SAndrew Rybchenko  * Retrieve information about given port's Tx queue.
457499a2dd95SBruce Richardson  *
457599a2dd95SBruce Richardson  * @param port_id
457699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
457799a2dd95SBruce Richardson  * @param queue_id
457809fd4227SAndrew Rybchenko  *   The Tx queue on the Ethernet device for which information
457999a2dd95SBruce Richardson  *   will be retrieved.
458099a2dd95SBruce Richardson  * @param qinfo
458199a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_eth_txq_info_info* to be filled with
458299a2dd95SBruce Richardson  *   the information of the Ethernet device.
458399a2dd95SBruce Richardson  *
458499a2dd95SBruce Richardson  * @return
458599a2dd95SBruce Richardson  *   - 0: Success
458699a2dd95SBruce Richardson  *   - -ENODEV:  If *port_id* is invalid.
458799a2dd95SBruce Richardson  *   - -ENOTSUP: routine is not supported by the device PMD.
458899a2dd95SBruce Richardson  *   - -EINVAL:  The queue_id is out of range, or the queue
458999a2dd95SBruce Richardson  *               is hairpin queue.
459099a2dd95SBruce Richardson  */
459199a2dd95SBruce Richardson int rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id,
459299a2dd95SBruce Richardson 	struct rte_eth_txq_info *qinfo);
459399a2dd95SBruce Richardson 
459499a2dd95SBruce Richardson /**
459599a2dd95SBruce Richardson  * Retrieve information about the Rx packet burst mode.
459699a2dd95SBruce Richardson  *
459799a2dd95SBruce Richardson  * @param port_id
459899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
459999a2dd95SBruce Richardson  * @param queue_id
460099a2dd95SBruce Richardson  *   The Rx queue on the Ethernet device for which information
460199a2dd95SBruce Richardson  *   will be retrieved.
460299a2dd95SBruce Richardson  * @param mode
460399a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_eth_burst_mode* to be filled
460499a2dd95SBruce Richardson  *   with the information of the packet burst mode.
460599a2dd95SBruce Richardson  *
460699a2dd95SBruce Richardson  * @return
460799a2dd95SBruce Richardson  *   - 0: Success
460899a2dd95SBruce Richardson  *   - -ENODEV:  If *port_id* is invalid.
460999a2dd95SBruce Richardson  *   - -ENOTSUP: routine is not supported by the device PMD.
461099a2dd95SBruce Richardson  *   - -EINVAL:  The queue_id is out of range.
461199a2dd95SBruce Richardson  */
461299a2dd95SBruce Richardson int rte_eth_rx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
461399a2dd95SBruce Richardson 	struct rte_eth_burst_mode *mode);
461499a2dd95SBruce Richardson 
461599a2dd95SBruce Richardson /**
461699a2dd95SBruce Richardson  * Retrieve information about the Tx packet burst mode.
461799a2dd95SBruce Richardson  *
461899a2dd95SBruce Richardson  * @param port_id
461999a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
462099a2dd95SBruce Richardson  * @param queue_id
462199a2dd95SBruce Richardson  *   The Tx queue on the Ethernet device for which information
462299a2dd95SBruce Richardson  *   will be retrieved.
462399a2dd95SBruce Richardson  * @param mode
462499a2dd95SBruce Richardson  *   A pointer to a structure of type *rte_eth_burst_mode* to be filled
462599a2dd95SBruce Richardson  *   with the information of the packet burst mode.
462699a2dd95SBruce Richardson  *
462799a2dd95SBruce Richardson  * @return
462899a2dd95SBruce Richardson  *   - 0: Success
462999a2dd95SBruce Richardson  *   - -ENODEV:  If *port_id* is invalid.
463099a2dd95SBruce Richardson  *   - -ENOTSUP: routine is not supported by the device PMD.
463199a2dd95SBruce Richardson  *   - -EINVAL:  The queue_id is out of range.
463299a2dd95SBruce Richardson  */
463399a2dd95SBruce Richardson int rte_eth_tx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
463499a2dd95SBruce Richardson 	struct rte_eth_burst_mode *mode);
463599a2dd95SBruce Richardson 
463699a2dd95SBruce Richardson /**
463799a2dd95SBruce Richardson  * @warning
463899a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
463999a2dd95SBruce Richardson  *
464099a2dd95SBruce Richardson  * Retrieve the monitor condition for a given receive queue.
464199a2dd95SBruce Richardson  *
464299a2dd95SBruce Richardson  * @param port_id
464399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
464499a2dd95SBruce Richardson  * @param queue_id
464599a2dd95SBruce Richardson  *   The Rx queue on the Ethernet device for which information
464699a2dd95SBruce Richardson  *   will be retrieved.
464799a2dd95SBruce Richardson  * @param pmc
464899a2dd95SBruce Richardson  *   The pointer to power-optimized monitoring condition structure.
464999a2dd95SBruce Richardson  *
465099a2dd95SBruce Richardson  * @return
465199a2dd95SBruce Richardson  *   - 0: Success.
465299a2dd95SBruce Richardson  *   -ENOTSUP: Operation not supported.
465399a2dd95SBruce Richardson  *   -EINVAL: Invalid parameters.
465499a2dd95SBruce Richardson  *   -ENODEV: Invalid port ID.
465599a2dd95SBruce Richardson  */
465699a2dd95SBruce Richardson __rte_experimental
465799a2dd95SBruce Richardson int rte_eth_get_monitor_addr(uint16_t port_id, uint16_t queue_id,
465899a2dd95SBruce Richardson 		struct rte_power_monitor_cond *pmc);
465999a2dd95SBruce Richardson 
466099a2dd95SBruce Richardson /**
466199a2dd95SBruce Richardson  * Retrieve device registers and register attributes (number of registers and
466299a2dd95SBruce Richardson  * register size)
466399a2dd95SBruce Richardson  *
466499a2dd95SBruce Richardson  * @param port_id
466599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
466699a2dd95SBruce Richardson  * @param info
466799a2dd95SBruce Richardson  *   Pointer to rte_dev_reg_info structure to fill in. If info->data is
466899a2dd95SBruce Richardson  *   NULL the function fills in the width and length fields. If non-NULL
466999a2dd95SBruce Richardson  *   the registers are put into the buffer pointed at by the data field.
467099a2dd95SBruce Richardson  * @return
467199a2dd95SBruce Richardson  *   - (0) if successful.
467299a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
467399a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
467499a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
467599a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
467699a2dd95SBruce Richardson  *   - others depends on the specific operations implementation.
467799a2dd95SBruce Richardson  */
467899a2dd95SBruce Richardson int rte_eth_dev_get_reg_info(uint16_t port_id, struct rte_dev_reg_info *info);
467999a2dd95SBruce Richardson 
468099a2dd95SBruce Richardson /**
468199a2dd95SBruce Richardson  * Retrieve size of device EEPROM
468299a2dd95SBruce Richardson  *
468399a2dd95SBruce Richardson  * @param port_id
468499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
468599a2dd95SBruce Richardson  * @return
468699a2dd95SBruce Richardson  *   - (>=0) EEPROM size if successful.
468799a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
468899a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
468999a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
469099a2dd95SBruce Richardson  *   - others depends on the specific operations implementation.
469199a2dd95SBruce Richardson  */
469299a2dd95SBruce Richardson int rte_eth_dev_get_eeprom_length(uint16_t port_id);
469399a2dd95SBruce Richardson 
469499a2dd95SBruce Richardson /**
469599a2dd95SBruce Richardson  * Retrieve EEPROM and EEPROM attribute
469699a2dd95SBruce Richardson  *
469799a2dd95SBruce Richardson  * @param port_id
469899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
469999a2dd95SBruce Richardson  * @param info
470099a2dd95SBruce Richardson  *   The template includes buffer for return EEPROM data and
470199a2dd95SBruce Richardson  *   EEPROM attributes to be filled.
470299a2dd95SBruce Richardson  * @return
470399a2dd95SBruce Richardson  *   - (0) if successful.
470499a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
470599a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
470699a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
470799a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
470899a2dd95SBruce Richardson  *   - others depends on the specific operations implementation.
470999a2dd95SBruce Richardson  */
471099a2dd95SBruce Richardson int rte_eth_dev_get_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
471199a2dd95SBruce Richardson 
471299a2dd95SBruce Richardson /**
471399a2dd95SBruce Richardson  * Program EEPROM with provided data
471499a2dd95SBruce Richardson  *
471599a2dd95SBruce Richardson  * @param port_id
471699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
471799a2dd95SBruce Richardson  * @param info
471899a2dd95SBruce Richardson  *   The template includes EEPROM data for programming and
471999a2dd95SBruce Richardson  *   EEPROM attributes to be filled
472099a2dd95SBruce Richardson  * @return
472199a2dd95SBruce Richardson  *   - (0) if successful.
472299a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
472399a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
472499a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
472599a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
472699a2dd95SBruce Richardson  *   - others depends on the specific operations implementation.
472799a2dd95SBruce Richardson  */
472899a2dd95SBruce Richardson int rte_eth_dev_set_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
472999a2dd95SBruce Richardson 
473099a2dd95SBruce Richardson /**
473199a2dd95SBruce Richardson  * @warning
473299a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
473399a2dd95SBruce Richardson  *
473499a2dd95SBruce Richardson  * Retrieve the type and size of plugin module EEPROM
473599a2dd95SBruce Richardson  *
473699a2dd95SBruce Richardson  * @param port_id
473799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
473899a2dd95SBruce Richardson  * @param modinfo
473999a2dd95SBruce Richardson  *   The type and size of plugin module EEPROM.
474099a2dd95SBruce Richardson  * @return
474199a2dd95SBruce Richardson  *   - (0) if successful.
474299a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
474399a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
474499a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
474599a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
474699a2dd95SBruce Richardson  *   - others depends on the specific operations implementation.
474799a2dd95SBruce Richardson  */
474899a2dd95SBruce Richardson __rte_experimental
474999a2dd95SBruce Richardson int
475099a2dd95SBruce Richardson rte_eth_dev_get_module_info(uint16_t port_id,
475199a2dd95SBruce Richardson 			    struct rte_eth_dev_module_info *modinfo);
475299a2dd95SBruce Richardson 
475399a2dd95SBruce Richardson /**
475499a2dd95SBruce Richardson  * @warning
475599a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
475699a2dd95SBruce Richardson  *
475799a2dd95SBruce Richardson  * Retrieve the data of plugin module EEPROM
475899a2dd95SBruce Richardson  *
475999a2dd95SBruce Richardson  * @param port_id
476099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
476199a2dd95SBruce Richardson  * @param info
476299a2dd95SBruce Richardson  *   The template includes the plugin module EEPROM attributes, and the
476399a2dd95SBruce Richardson  *   buffer for return plugin module EEPROM data.
476499a2dd95SBruce Richardson  * @return
476599a2dd95SBruce Richardson  *   - (0) if successful.
476699a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
476799a2dd95SBruce Richardson  *   - (-EINVAL) if bad parameter.
476899a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
476999a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
477099a2dd95SBruce Richardson  *   - others depends on the specific operations implementation.
477199a2dd95SBruce Richardson  */
477299a2dd95SBruce Richardson __rte_experimental
477399a2dd95SBruce Richardson int
477499a2dd95SBruce Richardson rte_eth_dev_get_module_eeprom(uint16_t port_id,
477599a2dd95SBruce Richardson 			      struct rte_dev_eeprom_info *info);
477699a2dd95SBruce Richardson 
477799a2dd95SBruce Richardson /**
477899a2dd95SBruce Richardson  * Set the list of multicast addresses to filter on an Ethernet device.
477999a2dd95SBruce Richardson  *
478099a2dd95SBruce Richardson  * @param port_id
478199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
478299a2dd95SBruce Richardson  * @param mc_addr_set
478399a2dd95SBruce Richardson  *   The array of multicast addresses to set. Equal to NULL when the function
478499a2dd95SBruce Richardson  *   is invoked to flush the set of filtered addresses.
478599a2dd95SBruce Richardson  * @param nb_mc_addr
478699a2dd95SBruce Richardson  *   The number of multicast addresses in the *mc_addr_set* array. Equal to 0
478799a2dd95SBruce Richardson  *   when the function is invoked to flush the set of filtered addresses.
478899a2dd95SBruce Richardson  * @return
478999a2dd95SBruce Richardson  *   - (0) if successful.
479099a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
479199a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
479299a2dd95SBruce Richardson  *   - (-ENOTSUP) if PMD of *port_id* doesn't support multicast filtering.
479399a2dd95SBruce Richardson  *   - (-ENOSPC) if *port_id* has not enough multicast filtering resources.
479453ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
479599a2dd95SBruce Richardson  */
479699a2dd95SBruce Richardson int rte_eth_dev_set_mc_addr_list(uint16_t port_id,
479799a2dd95SBruce Richardson 				 struct rte_ether_addr *mc_addr_set,
479899a2dd95SBruce Richardson 				 uint32_t nb_mc_addr);
479999a2dd95SBruce Richardson 
480099a2dd95SBruce Richardson /**
480199a2dd95SBruce Richardson  * Enable IEEE1588/802.1AS timestamping for an Ethernet device.
480299a2dd95SBruce Richardson  *
480399a2dd95SBruce Richardson  * @param port_id
480499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
480599a2dd95SBruce Richardson  *
480699a2dd95SBruce Richardson  * @return
480799a2dd95SBruce Richardson  *   - 0: Success.
480899a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
480999a2dd95SBruce Richardson  *   - -EIO: if device is removed.
481099a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
481199a2dd95SBruce Richardson  */
481299a2dd95SBruce Richardson int rte_eth_timesync_enable(uint16_t port_id);
481399a2dd95SBruce Richardson 
481499a2dd95SBruce Richardson /**
481599a2dd95SBruce Richardson  * Disable IEEE1588/802.1AS timestamping for an Ethernet device.
481699a2dd95SBruce Richardson  *
481799a2dd95SBruce Richardson  * @param port_id
481899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
481999a2dd95SBruce Richardson  *
482099a2dd95SBruce Richardson  * @return
482199a2dd95SBruce Richardson  *   - 0: Success.
482299a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
482399a2dd95SBruce Richardson  *   - -EIO: if device is removed.
482499a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
482599a2dd95SBruce Richardson  */
482699a2dd95SBruce Richardson int rte_eth_timesync_disable(uint16_t port_id);
482799a2dd95SBruce Richardson 
482899a2dd95SBruce Richardson /**
482909fd4227SAndrew Rybchenko  * Read an IEEE1588/802.1AS Rx timestamp from an Ethernet device.
483099a2dd95SBruce Richardson  *
483199a2dd95SBruce Richardson  * @param port_id
483299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
483399a2dd95SBruce Richardson  * @param timestamp
483499a2dd95SBruce Richardson  *   Pointer to the timestamp struct.
483599a2dd95SBruce Richardson  * @param flags
483609fd4227SAndrew Rybchenko  *   Device specific flags. Used to pass the Rx timesync register index to
483799a2dd95SBruce Richardson  *   i40e. Unused in igb/ixgbe, pass 0 instead.
483899a2dd95SBruce Richardson  *
483999a2dd95SBruce Richardson  * @return
484099a2dd95SBruce Richardson  *   - 0: Success.
484199a2dd95SBruce Richardson  *   - -EINVAL: No timestamp is available.
484299a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
484399a2dd95SBruce Richardson  *   - -EIO: if device is removed.
484499a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
484599a2dd95SBruce Richardson  */
484699a2dd95SBruce Richardson int rte_eth_timesync_read_rx_timestamp(uint16_t port_id,
484799a2dd95SBruce Richardson 		struct timespec *timestamp, uint32_t flags);
484899a2dd95SBruce Richardson 
484999a2dd95SBruce Richardson /**
485009fd4227SAndrew Rybchenko  * Read an IEEE1588/802.1AS Tx timestamp from an Ethernet device.
485199a2dd95SBruce Richardson  *
485299a2dd95SBruce Richardson  * @param port_id
485399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
485499a2dd95SBruce Richardson  * @param timestamp
485599a2dd95SBruce Richardson  *   Pointer to the timestamp struct.
485699a2dd95SBruce Richardson  *
485799a2dd95SBruce Richardson  * @return
485899a2dd95SBruce Richardson  *   - 0: Success.
485999a2dd95SBruce Richardson  *   - -EINVAL: No timestamp is available.
486099a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
486199a2dd95SBruce Richardson  *   - -EIO: if device is removed.
486299a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
486399a2dd95SBruce Richardson  */
486499a2dd95SBruce Richardson int rte_eth_timesync_read_tx_timestamp(uint16_t port_id,
486599a2dd95SBruce Richardson 		struct timespec *timestamp);
486699a2dd95SBruce Richardson 
486799a2dd95SBruce Richardson /**
486899a2dd95SBruce Richardson  * Adjust the timesync clock on an Ethernet device.
486999a2dd95SBruce Richardson  *
487099a2dd95SBruce Richardson  * This is usually used in conjunction with other Ethdev timesync functions to
487199a2dd95SBruce Richardson  * synchronize the device time using the IEEE1588/802.1AS protocol.
487299a2dd95SBruce Richardson  *
487399a2dd95SBruce Richardson  * @param port_id
487499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
487599a2dd95SBruce Richardson  * @param delta
487699a2dd95SBruce Richardson  *   The adjustment in nanoseconds.
487799a2dd95SBruce Richardson  *
487899a2dd95SBruce Richardson  * @return
487999a2dd95SBruce Richardson  *   - 0: Success.
488099a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
488199a2dd95SBruce Richardson  *   - -EIO: if device is removed.
488299a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
488399a2dd95SBruce Richardson  */
488499a2dd95SBruce Richardson int rte_eth_timesync_adjust_time(uint16_t port_id, int64_t delta);
488599a2dd95SBruce Richardson 
488699a2dd95SBruce Richardson /**
488799a2dd95SBruce Richardson  * Read the time from the timesync clock on an Ethernet device.
488899a2dd95SBruce Richardson  *
488999a2dd95SBruce Richardson  * This is usually used in conjunction with other Ethdev timesync functions to
489099a2dd95SBruce Richardson  * synchronize the device time using the IEEE1588/802.1AS protocol.
489199a2dd95SBruce Richardson  *
489299a2dd95SBruce Richardson  * @param port_id
489399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
489499a2dd95SBruce Richardson  * @param time
489599a2dd95SBruce Richardson  *   Pointer to the timespec struct that holds the time.
489699a2dd95SBruce Richardson  *
489799a2dd95SBruce Richardson  * @return
489899a2dd95SBruce Richardson  *   - 0: Success.
489953ef1b34SMin Hu (Connor)  *   - -EINVAL: Bad parameter.
490099a2dd95SBruce Richardson  */
490199a2dd95SBruce Richardson int rte_eth_timesync_read_time(uint16_t port_id, struct timespec *time);
490299a2dd95SBruce Richardson 
490399a2dd95SBruce Richardson /**
490499a2dd95SBruce Richardson  * Set the time of the timesync clock on an Ethernet device.
490599a2dd95SBruce Richardson  *
490699a2dd95SBruce Richardson  * This is usually used in conjunction with other Ethdev timesync functions to
490799a2dd95SBruce Richardson  * synchronize the device time using the IEEE1588/802.1AS protocol.
490899a2dd95SBruce Richardson  *
490999a2dd95SBruce Richardson  * @param port_id
491099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
491199a2dd95SBruce Richardson  * @param time
491299a2dd95SBruce Richardson  *   Pointer to the timespec struct that holds the time.
491399a2dd95SBruce Richardson  *
491499a2dd95SBruce Richardson  * @return
491599a2dd95SBruce Richardson  *   - 0: Success.
491699a2dd95SBruce Richardson  *   - -EINVAL: No timestamp is available.
491799a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
491899a2dd95SBruce Richardson  *   - -EIO: if device is removed.
491999a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
492099a2dd95SBruce Richardson  */
492199a2dd95SBruce Richardson int rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *time);
492299a2dd95SBruce Richardson 
492399a2dd95SBruce Richardson /**
492499a2dd95SBruce Richardson  * @warning
492599a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change without prior notice.
492699a2dd95SBruce Richardson  *
492799a2dd95SBruce Richardson  * Read the current clock counter of an Ethernet device
492899a2dd95SBruce Richardson  *
492999a2dd95SBruce Richardson  * This returns the current raw clock value of an Ethernet device. It is
493099a2dd95SBruce Richardson  * a raw amount of ticks, with no given time reference.
493199a2dd95SBruce Richardson  * The value returned here is from the same clock than the one
493299a2dd95SBruce Richardson  * filling timestamp field of Rx packets when using hardware timestamp
493399a2dd95SBruce Richardson  * offload. Therefore it can be used to compute a precise conversion of
493499a2dd95SBruce Richardson  * the device clock to the real time.
493599a2dd95SBruce Richardson  *
493699a2dd95SBruce Richardson  * E.g, a simple heuristic to derivate the frequency would be:
493799a2dd95SBruce Richardson  * uint64_t start, end;
493899a2dd95SBruce Richardson  * rte_eth_read_clock(port, start);
493999a2dd95SBruce Richardson  * rte_delay_ms(100);
494099a2dd95SBruce Richardson  * rte_eth_read_clock(port, end);
494199a2dd95SBruce Richardson  * double freq = (end - start) * 10;
494299a2dd95SBruce Richardson  *
494399a2dd95SBruce Richardson  * Compute a common reference with:
494499a2dd95SBruce Richardson  * uint64_t base_time_sec = current_time();
494599a2dd95SBruce Richardson  * uint64_t base_clock;
494699a2dd95SBruce Richardson  * rte_eth_read_clock(port, base_clock);
494799a2dd95SBruce Richardson  *
494899a2dd95SBruce Richardson  * Then, convert the raw mbuf timestamp with:
494999a2dd95SBruce Richardson  * base_time_sec + (double)(*timestamp_dynfield(mbuf) - base_clock) / freq;
495099a2dd95SBruce Richardson  *
495199a2dd95SBruce Richardson  * This simple example will not provide a very good accuracy. One must
495299a2dd95SBruce Richardson  * at least measure multiple times the frequency and do a regression.
495399a2dd95SBruce Richardson  * To avoid deviation from the system time, the common reference can
495499a2dd95SBruce Richardson  * be repeated from time to time. The integer division can also be
495599a2dd95SBruce Richardson  * converted by a multiplication and a shift for better performance.
495699a2dd95SBruce Richardson  *
495799a2dd95SBruce Richardson  * @param port_id
495899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
495999a2dd95SBruce Richardson  * @param clock
496099a2dd95SBruce Richardson  *   Pointer to the uint64_t that holds the raw clock value.
496199a2dd95SBruce Richardson  *
496299a2dd95SBruce Richardson  * @return
496399a2dd95SBruce Richardson  *   - 0: Success.
496499a2dd95SBruce Richardson  *   - -ENODEV: The port ID is invalid.
496599a2dd95SBruce Richardson  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
496653ef1b34SMin Hu (Connor)  *   - -EINVAL: if bad parameter.
496799a2dd95SBruce Richardson  */
496899a2dd95SBruce Richardson __rte_experimental
496999a2dd95SBruce Richardson int
497099a2dd95SBruce Richardson rte_eth_read_clock(uint16_t port_id, uint64_t *clock);
497199a2dd95SBruce Richardson 
497299a2dd95SBruce Richardson /**
49735906be5aSAndrew Rybchenko * Get the port ID from device name. The device name should be specified
497499a2dd95SBruce Richardson * as below:
497599a2dd95SBruce Richardson * - PCIe address (Domain:Bus:Device.Function), for example- 0000:2:00.0
497699a2dd95SBruce Richardson * - SoC device name, for example- fsl-gmac0
497799a2dd95SBruce Richardson * - vdev dpdk name, for example- net_[pcap0|null0|tap0]
497899a2dd95SBruce Richardson *
497999a2dd95SBruce Richardson * @param name
498099a2dd95SBruce Richardson *  pci address or name of the device
498199a2dd95SBruce Richardson * @param port_id
498299a2dd95SBruce Richardson *   pointer to port identifier of the device
498399a2dd95SBruce Richardson * @return
498499a2dd95SBruce Richardson *   - (0) if successful and port_id is filled.
498599a2dd95SBruce Richardson *   - (-ENODEV or -EINVAL) on failure.
498699a2dd95SBruce Richardson */
498799a2dd95SBruce Richardson int
498899a2dd95SBruce Richardson rte_eth_dev_get_port_by_name(const char *name, uint16_t *port_id);
498999a2dd95SBruce Richardson 
499099a2dd95SBruce Richardson /**
49915906be5aSAndrew Rybchenko * Get the device name from port ID. The device name is specified as below:
499299a2dd95SBruce Richardson * - PCIe address (Domain:Bus:Device.Function), for example- 0000:02:00.0
499399a2dd95SBruce Richardson * - SoC device name, for example- fsl-gmac0
499499a2dd95SBruce Richardson * - vdev dpdk name, for example- net_[pcap0|null0|tun0|tap0]
499599a2dd95SBruce Richardson *
499699a2dd95SBruce Richardson * @param port_id
499799a2dd95SBruce Richardson *   Port identifier of the device.
499899a2dd95SBruce Richardson * @param name
499999a2dd95SBruce Richardson *   Buffer of size RTE_ETH_NAME_MAX_LEN to store the name.
500099a2dd95SBruce Richardson * @return
500199a2dd95SBruce Richardson *   - (0) if successful.
500299a2dd95SBruce Richardson *   - (-ENODEV) if *port_id* is invalid.
500399a2dd95SBruce Richardson *   - (-EINVAL) on failure.
500499a2dd95SBruce Richardson */
500599a2dd95SBruce Richardson int
500699a2dd95SBruce Richardson rte_eth_dev_get_name_by_port(uint16_t port_id, char *name);
500799a2dd95SBruce Richardson 
500899a2dd95SBruce Richardson /**
500999a2dd95SBruce Richardson  * Check that numbers of Rx and Tx descriptors satisfy descriptors limits from
50100d9f56a8SAndrew Rybchenko  * the Ethernet device information, otherwise adjust them to boundaries.
501199a2dd95SBruce Richardson  *
501299a2dd95SBruce Richardson  * @param port_id
501399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
501499a2dd95SBruce Richardson  * @param nb_rx_desc
501599a2dd95SBruce Richardson  *   A pointer to a uint16_t where the number of receive
501699a2dd95SBruce Richardson  *   descriptors stored.
501799a2dd95SBruce Richardson  * @param nb_tx_desc
501899a2dd95SBruce Richardson  *   A pointer to a uint16_t where the number of transmit
501999a2dd95SBruce Richardson  *   descriptors stored.
502099a2dd95SBruce Richardson  * @return
502199a2dd95SBruce Richardson  *   - (0) if successful.
502299a2dd95SBruce Richardson  *   - (-ENOTSUP, -ENODEV or -EINVAL) on failure.
502399a2dd95SBruce Richardson  */
502499a2dd95SBruce Richardson int rte_eth_dev_adjust_nb_rx_tx_desc(uint16_t port_id,
502599a2dd95SBruce Richardson 				     uint16_t *nb_rx_desc,
502699a2dd95SBruce Richardson 				     uint16_t *nb_tx_desc);
502799a2dd95SBruce Richardson 
502899a2dd95SBruce Richardson /**
502999a2dd95SBruce Richardson  * Test if a port supports specific mempool ops.
503099a2dd95SBruce Richardson  *
503199a2dd95SBruce Richardson  * @param port_id
503299a2dd95SBruce Richardson  *   Port identifier of the Ethernet device.
503399a2dd95SBruce Richardson  * @param [in] pool
503499a2dd95SBruce Richardson  *   The name of the pool operations to test.
503599a2dd95SBruce Richardson  * @return
503699a2dd95SBruce Richardson  *   - 0: best mempool ops choice for this port.
503799a2dd95SBruce Richardson  *   - 1: mempool ops are supported for this port.
503899a2dd95SBruce Richardson  *   - -ENOTSUP: mempool ops not supported for this port.
503999a2dd95SBruce Richardson  *   - -ENODEV: Invalid port Identifier.
504099a2dd95SBruce Richardson  *   - -EINVAL: Pool param is null.
504199a2dd95SBruce Richardson  */
504299a2dd95SBruce Richardson int
504399a2dd95SBruce Richardson rte_eth_dev_pool_ops_supported(uint16_t port_id, const char *pool);
504499a2dd95SBruce Richardson 
504599a2dd95SBruce Richardson /**
504699a2dd95SBruce Richardson  * Get the security context for the Ethernet device.
504799a2dd95SBruce Richardson  *
504899a2dd95SBruce Richardson  * @param port_id
504999a2dd95SBruce Richardson  *   Port identifier of the Ethernet device
505099a2dd95SBruce Richardson  * @return
505199a2dd95SBruce Richardson  *   - NULL on error.
505299a2dd95SBruce Richardson  *   - pointer to security context on success.
505399a2dd95SBruce Richardson  */
505499a2dd95SBruce Richardson void *
505599a2dd95SBruce Richardson rte_eth_dev_get_sec_ctx(uint16_t port_id);
505699a2dd95SBruce Richardson 
505799a2dd95SBruce Richardson /**
505899a2dd95SBruce Richardson  * @warning
505999a2dd95SBruce Richardson  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
506099a2dd95SBruce Richardson  *
506199a2dd95SBruce Richardson  * Query the device hairpin capabilities.
506299a2dd95SBruce Richardson  *
506399a2dd95SBruce Richardson  * @param port_id
506499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
506599a2dd95SBruce Richardson  * @param cap
506699a2dd95SBruce Richardson  *   Pointer to a structure that will hold the hairpin capabilities.
506799a2dd95SBruce Richardson  * @return
506899a2dd95SBruce Richardson  *   - (0) if successful.
506999a2dd95SBruce Richardson  *   - (-ENOTSUP) if hardware doesn't support.
507053ef1b34SMin Hu (Connor)  *   - (-EINVAL) if bad parameter.
507199a2dd95SBruce Richardson  */
507299a2dd95SBruce Richardson __rte_experimental
507399a2dd95SBruce Richardson int rte_eth_dev_hairpin_capability_get(uint16_t port_id,
507499a2dd95SBruce Richardson 				       struct rte_eth_hairpin_cap *cap);
507599a2dd95SBruce Richardson 
507699a2dd95SBruce Richardson /**
507799a2dd95SBruce Richardson  * @warning
507899a2dd95SBruce Richardson  * @b EXPERIMENTAL: this structure may change without prior notice.
507999a2dd95SBruce Richardson  *
50800d9f56a8SAndrew Rybchenko  * Ethernet device representor ID range entry
508199a2dd95SBruce Richardson  */
508299a2dd95SBruce Richardson struct rte_eth_representor_range {
508399a2dd95SBruce Richardson 	enum rte_eth_representor_type type; /**< Representor type */
508499a2dd95SBruce Richardson 	int controller; /**< Controller index */
508599a2dd95SBruce Richardson 	int pf; /**< Physical function index */
508699a2dd95SBruce Richardson 	__extension__
508799a2dd95SBruce Richardson 	union {
508899a2dd95SBruce Richardson 		int vf; /**< VF start index */
508999a2dd95SBruce Richardson 		int sf; /**< SF start index */
509099a2dd95SBruce Richardson 	};
509199a2dd95SBruce Richardson 	uint32_t id_base; /**< Representor ID start index */
509299a2dd95SBruce Richardson 	uint32_t id_end;  /**< Representor ID end index */
509399a2dd95SBruce Richardson 	char name[RTE_DEV_NAME_MAX_LEN]; /**< Representor name */
509499a2dd95SBruce Richardson };
509599a2dd95SBruce Richardson 
509699a2dd95SBruce Richardson /**
509799a2dd95SBruce Richardson  * @warning
509899a2dd95SBruce Richardson  * @b EXPERIMENTAL: this structure may change without prior notice.
509999a2dd95SBruce Richardson  *
510099a2dd95SBruce Richardson  * Ethernet device representor information
510199a2dd95SBruce Richardson  */
510299a2dd95SBruce Richardson struct rte_eth_representor_info {
510399a2dd95SBruce Richardson 	uint16_t controller; /**< Controller ID of caller device. */
510499a2dd95SBruce Richardson 	uint16_t pf; /**< Physical function ID of caller device. */
510510eaf41dSViacheslav Galaktionov 	uint32_t nb_ranges_alloc; /**< Size of the ranges array. */
510610eaf41dSViacheslav Galaktionov 	uint32_t nb_ranges; /**< Number of initialized ranges. */
510799a2dd95SBruce Richardson 	struct rte_eth_representor_range ranges[];/**< Representor ID range. */
510899a2dd95SBruce Richardson };
510999a2dd95SBruce Richardson 
511099a2dd95SBruce Richardson /**
511199a2dd95SBruce Richardson  * Retrieve the representor info of the device.
511299a2dd95SBruce Richardson  *
511399a2dd95SBruce Richardson  * Get device representor info to be able to calculate a unique
511499a2dd95SBruce Richardson  * representor ID. @see rte_eth_representor_id_get helper.
511599a2dd95SBruce Richardson  *
511699a2dd95SBruce Richardson  * @param port_id
511799a2dd95SBruce Richardson  *   The port identifier of the device.
511899a2dd95SBruce Richardson  * @param info
511999a2dd95SBruce Richardson  *   A pointer to a representor info structure.
512099a2dd95SBruce Richardson  *   NULL to return number of range entries and allocate memory
512199a2dd95SBruce Richardson  *   for next call to store detail.
512210eaf41dSViacheslav Galaktionov  *   The number of ranges that were written into this structure
512310eaf41dSViacheslav Galaktionov  *   will be placed into its nb_ranges field. This number cannot be
512410eaf41dSViacheslav Galaktionov  *   larger than the nb_ranges_alloc that by the user before calling
512510eaf41dSViacheslav Galaktionov  *   this function. It can be smaller than the value returned by the
512610eaf41dSViacheslav Galaktionov  *   function, however.
512799a2dd95SBruce Richardson  * @return
512899a2dd95SBruce Richardson  *   - (-ENOTSUP) if operation is not supported.
512999a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* invalid.
513099a2dd95SBruce Richardson  *   - (-EIO) if device is removed.
513110eaf41dSViacheslav Galaktionov  *   - (>=0) number of available representor range entries.
513299a2dd95SBruce Richardson  */
513399a2dd95SBruce Richardson __rte_experimental
513499a2dd95SBruce Richardson int rte_eth_representor_info_get(uint16_t port_id,
513599a2dd95SBruce Richardson 				 struct rte_eth_representor_info *info);
513699a2dd95SBruce Richardson 
5137f6d8a6d3SIvan Malov /** The NIC is able to deliver flag (if set) with packets to the PMD. */
5138e1823e08SThomas Monjalon #define RTE_ETH_RX_METADATA_USER_FLAG RTE_BIT64(0)
5139f6d8a6d3SIvan Malov 
5140f6d8a6d3SIvan Malov /** The NIC is able to deliver mark ID with packets to the PMD. */
5141e1823e08SThomas Monjalon #define RTE_ETH_RX_METADATA_USER_MARK RTE_BIT64(1)
5142f6d8a6d3SIvan Malov 
5143f6d8a6d3SIvan Malov /** The NIC is able to deliver tunnel ID with packets to the PMD. */
5144e1823e08SThomas Monjalon #define RTE_ETH_RX_METADATA_TUNNEL_ID RTE_BIT64(2)
5145f6d8a6d3SIvan Malov 
5146f6d8a6d3SIvan Malov /**
5147f6d8a6d3SIvan Malov  * @warning
5148f6d8a6d3SIvan Malov  * @b EXPERIMENTAL: this API may change without prior notice
5149f6d8a6d3SIvan Malov  *
5150f6d8a6d3SIvan Malov  * Negotiate the NIC's ability to deliver specific kinds of metadata to the PMD.
5151f6d8a6d3SIvan Malov  *
5152f6d8a6d3SIvan Malov  * Invoke this API before the first rte_eth_dev_configure() invocation
5153f6d8a6d3SIvan Malov  * to let the PMD make preparations that are inconvenient to do later.
5154f6d8a6d3SIvan Malov  *
5155f6d8a6d3SIvan Malov  * The negotiation process is as follows:
5156f6d8a6d3SIvan Malov  *
5157f6d8a6d3SIvan Malov  * - the application requests features intending to use at least some of them;
5158f6d8a6d3SIvan Malov  * - the PMD responds with the guaranteed subset of the requested feature set;
5159f6d8a6d3SIvan Malov  * - the application can retry negotiation with another set of features;
5160f6d8a6d3SIvan Malov  * - the application can pass zero to clear the negotiation result;
5161f6d8a6d3SIvan Malov  * - the last negotiated result takes effect upon
5162f6d8a6d3SIvan Malov  *   the ethdev configure and start.
5163f6d8a6d3SIvan Malov  *
5164f6d8a6d3SIvan Malov  * @note
5165f6d8a6d3SIvan Malov  *   The PMD is supposed to first consider enabling the requested feature set
5166f6d8a6d3SIvan Malov  *   in its entirety. Only if it fails to do so, does it have the right to
5167f6d8a6d3SIvan Malov  *   respond with a smaller set of the originally requested features.
5168f6d8a6d3SIvan Malov  *
5169f6d8a6d3SIvan Malov  * @note
5170f6d8a6d3SIvan Malov  *   Return code (-ENOTSUP) does not necessarily mean that the requested
5171f6d8a6d3SIvan Malov  *   features are unsupported. In this case, the application should just
5172f6d8a6d3SIvan Malov  *   assume that these features can be used without prior negotiations.
5173f6d8a6d3SIvan Malov  *
5174f6d8a6d3SIvan Malov  * @param port_id
5175f6d8a6d3SIvan Malov  *   Port (ethdev) identifier
5176f6d8a6d3SIvan Malov  *
5177f6d8a6d3SIvan Malov  * @param[inout] features
5178f6d8a6d3SIvan Malov  *   Feature selection buffer
5179f6d8a6d3SIvan Malov  *
5180f6d8a6d3SIvan Malov  * @return
5181f6d8a6d3SIvan Malov  *   - (-EBUSY) if the port can't handle this in its current state;
5182f6d8a6d3SIvan Malov  *   - (-ENOTSUP) if the method itself is not supported by the PMD;
5183f6d8a6d3SIvan Malov  *   - (-ENODEV) if *port_id* is invalid;
5184f6d8a6d3SIvan Malov  *   - (-EINVAL) if *features* is NULL;
5185f6d8a6d3SIvan Malov  *   - (-EIO) if the device is removed;
5186f6d8a6d3SIvan Malov  *   - (0) on success
5187f6d8a6d3SIvan Malov  */
5188f6d8a6d3SIvan Malov __rte_experimental
5189f6d8a6d3SIvan Malov int rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features);
5190f6d8a6d3SIvan Malov 
519199a2dd95SBruce Richardson #include <rte_ethdev_core.h>
519299a2dd95SBruce Richardson 
519399a2dd95SBruce Richardson /**
51947a093523SKonstantin Ananyev  * @internal
51957a093523SKonstantin Ananyev  * Helper routine for rte_eth_rx_burst().
51967a093523SKonstantin Ananyev  * Should be called at exit from PMD's rte_eth_rx_bulk implementation.
51977a093523SKonstantin Ananyev  * Does necessary post-processing - invokes Rx callbacks if any, etc.
51987a093523SKonstantin Ananyev  *
51997a093523SKonstantin Ananyev  * @param port_id
52007a093523SKonstantin Ananyev  *  The port identifier of the Ethernet device.
52017a093523SKonstantin Ananyev  * @param queue_id
52027a093523SKonstantin Ananyev  *  The index of the receive queue from which to retrieve input packets.
52037a093523SKonstantin Ananyev  * @param rx_pkts
52047a093523SKonstantin Ananyev  *   The address of an array of pointers to *rte_mbuf* structures that
52057a093523SKonstantin Ananyev  *   have been retrieved from the device.
52067a093523SKonstantin Ananyev  * @param nb_rx
52077a093523SKonstantin Ananyev  *   The number of packets that were retrieved from the device.
52087a093523SKonstantin Ananyev  * @param nb_pkts
52097a093523SKonstantin Ananyev  *   The number of elements in @p rx_pkts array.
52107a093523SKonstantin Ananyev  * @param opaque
52117a093523SKonstantin Ananyev  *   Opaque pointer of Rx queue callback related data.
52127a093523SKonstantin Ananyev  *
52137a093523SKonstantin Ananyev  * @return
52147a093523SKonstantin Ananyev  *  The number of packets effectively supplied to the @p rx_pkts array.
52157a093523SKonstantin Ananyev  */
52167a093523SKonstantin Ananyev uint16_t rte_eth_call_rx_callbacks(uint16_t port_id, uint16_t queue_id,
52177a093523SKonstantin Ananyev 		struct rte_mbuf **rx_pkts, uint16_t nb_rx, uint16_t nb_pkts,
52187a093523SKonstantin Ananyev 		void *opaque);
52197a093523SKonstantin Ananyev 
52207a093523SKonstantin Ananyev /**
522199a2dd95SBruce Richardson  *
522299a2dd95SBruce Richardson  * Retrieve a burst of input packets from a receive queue of an Ethernet
522399a2dd95SBruce Richardson  * device. The retrieved packets are stored in *rte_mbuf* structures whose
522499a2dd95SBruce Richardson  * pointers are supplied in the *rx_pkts* array.
522599a2dd95SBruce Richardson  *
522609fd4227SAndrew Rybchenko  * The rte_eth_rx_burst() function loops, parsing the Rx ring of the
522709fd4227SAndrew Rybchenko  * receive queue, up to *nb_pkts* packets, and for each completed Rx
522899a2dd95SBruce Richardson  * descriptor in the ring, it performs the following operations:
522999a2dd95SBruce Richardson  *
523099a2dd95SBruce Richardson  * - Initialize the *rte_mbuf* data structure associated with the
523109fd4227SAndrew Rybchenko  *   Rx descriptor according to the information provided by the NIC into
523209fd4227SAndrew Rybchenko  *   that Rx descriptor.
523399a2dd95SBruce Richardson  *
523499a2dd95SBruce Richardson  * - Store the *rte_mbuf* data structure into the next entry of the
523599a2dd95SBruce Richardson  *   *rx_pkts* array.
523699a2dd95SBruce Richardson  *
523709fd4227SAndrew Rybchenko  * - Replenish the Rx descriptor with a new *rte_mbuf* buffer
523899a2dd95SBruce Richardson  *   allocated from the memory pool associated with the receive queue at
523999a2dd95SBruce Richardson  *   initialization time.
524099a2dd95SBruce Richardson  *
524199a2dd95SBruce Richardson  * When retrieving an input packet that was scattered by the controller
524299a2dd95SBruce Richardson  * into multiple receive descriptors, the rte_eth_rx_burst() function
524399a2dd95SBruce Richardson  * appends the associated *rte_mbuf* buffers to the first buffer of the
524499a2dd95SBruce Richardson  * packet.
524599a2dd95SBruce Richardson  *
524699a2dd95SBruce Richardson  * The rte_eth_rx_burst() function returns the number of packets
524799a2dd95SBruce Richardson  * actually retrieved, which is the number of *rte_mbuf* data structures
524899a2dd95SBruce Richardson  * effectively supplied into the *rx_pkts* array.
524909fd4227SAndrew Rybchenko  * A return value equal to *nb_pkts* indicates that the Rx queue contained
525099a2dd95SBruce Richardson  * at least *rx_pkts* packets, and this is likely to signify that other
525199a2dd95SBruce Richardson  * received packets remain in the input queue. Applications implementing
525299a2dd95SBruce Richardson  * a "retrieve as much received packets as possible" policy can check this
525399a2dd95SBruce Richardson  * specific case and keep invoking the rte_eth_rx_burst() function until
525499a2dd95SBruce Richardson  * a value less than *nb_pkts* is returned.
525599a2dd95SBruce Richardson  *
525699a2dd95SBruce Richardson  * This receive method has the following advantages:
525799a2dd95SBruce Richardson  *
525899a2dd95SBruce Richardson  * - It allows a run-to-completion network stack engine to retrieve and
525999a2dd95SBruce Richardson  *   to immediately process received packets in a fast burst-oriented
526099a2dd95SBruce Richardson  *   approach, avoiding the overhead of unnecessary intermediate packet
526199a2dd95SBruce Richardson  *   queue/dequeue operations.
526299a2dd95SBruce Richardson  *
526399a2dd95SBruce Richardson  * - Conversely, it also allows an asynchronous-oriented processing
526499a2dd95SBruce Richardson  *   method to retrieve bursts of received packets and to immediately
526599a2dd95SBruce Richardson  *   queue them for further parallel processing by another logical core,
526699a2dd95SBruce Richardson  *   for instance. However, instead of having received packets being
526799a2dd95SBruce Richardson  *   individually queued by the driver, this approach allows the caller
526899a2dd95SBruce Richardson  *   of the rte_eth_rx_burst() function to queue a burst of retrieved
526999a2dd95SBruce Richardson  *   packets at a time and therefore dramatically reduce the cost of
527099a2dd95SBruce Richardson  *   enqueue/dequeue operations per packet.
527199a2dd95SBruce Richardson  *
527299a2dd95SBruce Richardson  * - It allows the rte_eth_rx_burst() function of the driver to take
527399a2dd95SBruce Richardson  *   advantage of burst-oriented hardware features (CPU cache,
527499a2dd95SBruce Richardson  *   prefetch instructions, and so on) to minimize the number of CPU
527599a2dd95SBruce Richardson  *   cycles per packet.
527699a2dd95SBruce Richardson  *
527799a2dd95SBruce Richardson  * To summarize, the proposed receive API enables many
527899a2dd95SBruce Richardson  * burst-oriented optimizations in both synchronous and asynchronous
527999a2dd95SBruce Richardson  * packet processing environments with no overhead in both cases.
528099a2dd95SBruce Richardson  *
528199a2dd95SBruce Richardson  * @note
528299a2dd95SBruce Richardson  *   Some drivers using vector instructions require that *nb_pkts* is
528399a2dd95SBruce Richardson  *   divisible by 4 or 8, depending on the driver implementation.
528499a2dd95SBruce Richardson  *
528599a2dd95SBruce Richardson  * The rte_eth_rx_burst() function does not provide any error
528699a2dd95SBruce Richardson  * notification to avoid the corresponding overhead. As a hint, the
528799a2dd95SBruce Richardson  * upper-level application might check the status of the device link once
528899a2dd95SBruce Richardson  * being systematically returned a 0 value for a given number of tries.
528999a2dd95SBruce Richardson  *
529099a2dd95SBruce Richardson  * @param port_id
529199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
529299a2dd95SBruce Richardson  * @param queue_id
529399a2dd95SBruce Richardson  *   The index of the receive queue from which to retrieve input packets.
529499a2dd95SBruce Richardson  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
529599a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
529699a2dd95SBruce Richardson  * @param rx_pkts
529799a2dd95SBruce Richardson  *   The address of an array of pointers to *rte_mbuf* structures that
529899a2dd95SBruce Richardson  *   must be large enough to store *nb_pkts* pointers in it.
529999a2dd95SBruce Richardson  * @param nb_pkts
530099a2dd95SBruce Richardson  *   The maximum number of packets to retrieve.
530199a2dd95SBruce Richardson  *   The value must be divisible by 8 in order to work with any driver.
530299a2dd95SBruce Richardson  * @return
530399a2dd95SBruce Richardson  *   The number of packets actually retrieved, which is the number
530499a2dd95SBruce Richardson  *   of pointers to *rte_mbuf* structures effectively supplied to the
530599a2dd95SBruce Richardson  *   *rx_pkts* array.
530699a2dd95SBruce Richardson  */
530799a2dd95SBruce Richardson static inline uint16_t
530899a2dd95SBruce Richardson rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id,
530999a2dd95SBruce Richardson 		 struct rte_mbuf **rx_pkts, const uint16_t nb_pkts)
531099a2dd95SBruce Richardson {
531199a2dd95SBruce Richardson 	uint16_t nb_rx;
53127a093523SKonstantin Ananyev 	struct rte_eth_fp_ops *p;
53137a093523SKonstantin Ananyev 	void *qd;
531499a2dd95SBruce Richardson 
531599a2dd95SBruce Richardson #ifdef RTE_ETHDEV_DEBUG_RX
53167a093523SKonstantin Ananyev 	if (port_id >= RTE_MAX_ETHPORTS ||
53177a093523SKonstantin Ananyev 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
53187a093523SKonstantin Ananyev 		RTE_ETHDEV_LOG(ERR,
53197a093523SKonstantin Ananyev 			"Invalid port_id=%u or queue_id=%u\n",
53207a093523SKonstantin Ananyev 			port_id, queue_id);
532199a2dd95SBruce Richardson 		return 0;
532299a2dd95SBruce Richardson 	}
532399a2dd95SBruce Richardson #endif
53247a093523SKonstantin Ananyev 
53257a093523SKonstantin Ananyev 	/* fetch pointer to queue data */
53267a093523SKonstantin Ananyev 	p = &rte_eth_fp_ops[port_id];
53277a093523SKonstantin Ananyev 	qd = p->rxq.data[queue_id];
53287a093523SKonstantin Ananyev 
53297a093523SKonstantin Ananyev #ifdef RTE_ETHDEV_DEBUG_RX
53307a093523SKonstantin Ananyev 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
53317a093523SKonstantin Ananyev 
53327a093523SKonstantin Ananyev 	if (qd == NULL) {
533309fd4227SAndrew Rybchenko 		RTE_ETHDEV_LOG(ERR, "Invalid Rx queue_id=%u for port_id=%u\n",
53347a093523SKonstantin Ananyev 			queue_id, port_id);
53357a093523SKonstantin Ananyev 		return 0;
53367a093523SKonstantin Ananyev 	}
53377a093523SKonstantin Ananyev #endif
53387a093523SKonstantin Ananyev 
53397a093523SKonstantin Ananyev 	nb_rx = p->rx_pkt_burst(qd, rx_pkts, nb_pkts);
534099a2dd95SBruce Richardson 
534199a2dd95SBruce Richardson #ifdef RTE_ETHDEV_RXTX_CALLBACKS
53427a093523SKonstantin Ananyev 	{
53437a093523SKonstantin Ananyev 		void *cb;
534499a2dd95SBruce Richardson 
534599a2dd95SBruce Richardson 		/* __ATOMIC_RELEASE memory order was used when the
534699a2dd95SBruce Richardson 		 * call back was inserted into the list.
534799a2dd95SBruce Richardson 		 * Since there is a clear dependency between loading
534899a2dd95SBruce Richardson 		 * cb and cb->fn/cb->next, __ATOMIC_ACQUIRE memory order is
534999a2dd95SBruce Richardson 		 * not required.
535099a2dd95SBruce Richardson 		 */
53517a093523SKonstantin Ananyev 		cb = __atomic_load_n((void **)&p->rxq.clbk[queue_id],
535299a2dd95SBruce Richardson 				__ATOMIC_RELAXED);
53537a093523SKonstantin Ananyev 		if (unlikely(cb != NULL))
53547a093523SKonstantin Ananyev 			nb_rx = rte_eth_call_rx_callbacks(port_id, queue_id,
53557a093523SKonstantin Ananyev 					rx_pkts, nb_rx, nb_pkts, cb);
535699a2dd95SBruce Richardson 	}
535799a2dd95SBruce Richardson #endif
535899a2dd95SBruce Richardson 
535999a2dd95SBruce Richardson 	rte_ethdev_trace_rx_burst(port_id, queue_id, (void **)rx_pkts, nb_rx);
536099a2dd95SBruce Richardson 	return nb_rx;
536199a2dd95SBruce Richardson }
536299a2dd95SBruce Richardson 
536399a2dd95SBruce Richardson /**
536409fd4227SAndrew Rybchenko  * Get the number of used descriptors of a Rx queue
536599a2dd95SBruce Richardson  *
536699a2dd95SBruce Richardson  * @param port_id
536799a2dd95SBruce Richardson  *  The port identifier of the Ethernet device.
536899a2dd95SBruce Richardson  * @param queue_id
53695906be5aSAndrew Rybchenko  *  The queue ID on the specific port.
537099a2dd95SBruce Richardson  * @return
537199a2dd95SBruce Richardson  *  The number of used descriptors in the specific queue, or:
537299a2dd95SBruce Richardson  *   - (-ENODEV) if *port_id* is invalid.
537399a2dd95SBruce Richardson  *     (-EINVAL) if *queue_id* is invalid
537499a2dd95SBruce Richardson  *     (-ENOTSUP) if the device does not support this function
537599a2dd95SBruce Richardson  */
537699a2dd95SBruce Richardson static inline int
537799a2dd95SBruce Richardson rte_eth_rx_queue_count(uint16_t port_id, uint16_t queue_id)
537899a2dd95SBruce Richardson {
53797a093523SKonstantin Ananyev 	struct rte_eth_fp_ops *p;
53807a093523SKonstantin Ananyev 	void *qd;
53817a093523SKonstantin Ananyev 
53827a093523SKonstantin Ananyev 	if (port_id >= RTE_MAX_ETHPORTS ||
53837a093523SKonstantin Ananyev 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
53847a093523SKonstantin Ananyev 		RTE_ETHDEV_LOG(ERR,
53857a093523SKonstantin Ananyev 			"Invalid port_id=%u or queue_id=%u\n",
53867a093523SKonstantin Ananyev 			port_id, queue_id);
53877a093523SKonstantin Ananyev 		return -EINVAL;
53887a093523SKonstantin Ananyev 	}
53897a093523SKonstantin Ananyev 
53907a093523SKonstantin Ananyev 	/* fetch pointer to queue data */
53917a093523SKonstantin Ananyev 	p = &rte_eth_fp_ops[port_id];
53927a093523SKonstantin Ananyev 	qd = p->rxq.data[queue_id];
539399a2dd95SBruce Richardson 
539499a2dd95SBruce Richardson 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
53957a093523SKonstantin Ananyev 	RTE_FUNC_PTR_OR_ERR_RET(*p->rx_queue_count, -ENOTSUP);
53967a093523SKonstantin Ananyev 	if (qd == NULL)
539799a2dd95SBruce Richardson 		return -EINVAL;
539899a2dd95SBruce Richardson 
53997a093523SKonstantin Ananyev 	return (int)(*p->rx_queue_count)(qd);
540099a2dd95SBruce Richardson }
540199a2dd95SBruce Richardson 
54020ce56b05SThomas Monjalon /**@{@name Rx hardware descriptor states
54030ce56b05SThomas Monjalon  * @see rte_eth_rx_descriptor_status
54040ce56b05SThomas Monjalon  */
540599a2dd95SBruce Richardson #define RTE_ETH_RX_DESC_AVAIL    0 /**< Desc available for hw. */
540699a2dd95SBruce Richardson #define RTE_ETH_RX_DESC_DONE     1 /**< Desc done, filled by hw. */
540799a2dd95SBruce Richardson #define RTE_ETH_RX_DESC_UNAVAIL  2 /**< Desc used by driver or hw. */
54080ce56b05SThomas Monjalon /**@}*/
540999a2dd95SBruce Richardson 
541099a2dd95SBruce Richardson /**
541199a2dd95SBruce Richardson  * Check the status of a Rx descriptor in the queue
541299a2dd95SBruce Richardson  *
541399a2dd95SBruce Richardson  * It should be called in a similar context than the Rx function:
541499a2dd95SBruce Richardson  * - on a dataplane core
541599a2dd95SBruce Richardson  * - not concurrently on the same queue
541699a2dd95SBruce Richardson  *
541799a2dd95SBruce Richardson  * Since it's a dataplane function, no check is performed on port_id and
541899a2dd95SBruce Richardson  * queue_id. The caller must therefore ensure that the port is enabled
541999a2dd95SBruce Richardson  * and the queue is configured and running.
542099a2dd95SBruce Richardson  *
542199a2dd95SBruce Richardson  * Note: accessing to a random descriptor in the ring may trigger cache
542299a2dd95SBruce Richardson  * misses and have a performance impact.
542399a2dd95SBruce Richardson  *
542499a2dd95SBruce Richardson  * @param port_id
542599a2dd95SBruce Richardson  *  A valid port identifier of the Ethernet device which.
542699a2dd95SBruce Richardson  * @param queue_id
542799a2dd95SBruce Richardson  *  A valid Rx queue identifier on this port.
542899a2dd95SBruce Richardson  * @param offset
542999a2dd95SBruce Richardson  *  The offset of the descriptor starting from tail (0 is the next
543099a2dd95SBruce Richardson  *  packet to be received by the driver).
543199a2dd95SBruce Richardson  *
543299a2dd95SBruce Richardson  * @return
543399a2dd95SBruce Richardson  *  - (RTE_ETH_RX_DESC_AVAIL): Descriptor is available for the hardware to
543499a2dd95SBruce Richardson  *    receive a packet.
543599a2dd95SBruce Richardson  *  - (RTE_ETH_RX_DESC_DONE): Descriptor is done, it is filled by hw, but
543699a2dd95SBruce Richardson  *    not yet processed by the driver (i.e. in the receive queue).
543799a2dd95SBruce Richardson  *  - (RTE_ETH_RX_DESC_UNAVAIL): Descriptor is unavailable, either hold by
543899a2dd95SBruce Richardson  *    the driver and not yet returned to hw, or reserved by the hw.
543999a2dd95SBruce Richardson  *  - (-EINVAL) bad descriptor offset.
544099a2dd95SBruce Richardson  *  - (-ENOTSUP) if the device does not support this function.
544199a2dd95SBruce Richardson  *  - (-ENODEV) bad port or queue (only if compiled with debug).
544299a2dd95SBruce Richardson  */
544399a2dd95SBruce Richardson static inline int
544499a2dd95SBruce Richardson rte_eth_rx_descriptor_status(uint16_t port_id, uint16_t queue_id,
544599a2dd95SBruce Richardson 	uint16_t offset)
544699a2dd95SBruce Richardson {
54477a093523SKonstantin Ananyev 	struct rte_eth_fp_ops *p;
54487a093523SKonstantin Ananyev 	void *qd;
54497a093523SKonstantin Ananyev 
54507a093523SKonstantin Ananyev #ifdef RTE_ETHDEV_DEBUG_RX
54517a093523SKonstantin Ananyev 	if (port_id >= RTE_MAX_ETHPORTS ||
54527a093523SKonstantin Ananyev 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
54537a093523SKonstantin Ananyev 		RTE_ETHDEV_LOG(ERR,
54547a093523SKonstantin Ananyev 			"Invalid port_id=%u or queue_id=%u\n",
54557a093523SKonstantin Ananyev 			port_id, queue_id);
54567a093523SKonstantin Ananyev 		return -EINVAL;
54577a093523SKonstantin Ananyev 	}
54587a093523SKonstantin Ananyev #endif
54597a093523SKonstantin Ananyev 
54607a093523SKonstantin Ananyev 	/* fetch pointer to queue data */
54617a093523SKonstantin Ananyev 	p = &rte_eth_fp_ops[port_id];
54627a093523SKonstantin Ananyev 	qd = p->rxq.data[queue_id];
546399a2dd95SBruce Richardson 
546499a2dd95SBruce Richardson #ifdef RTE_ETHDEV_DEBUG_RX
546599a2dd95SBruce Richardson 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
54667a093523SKonstantin Ananyev 	if (qd == NULL)
546799a2dd95SBruce Richardson 		return -ENODEV;
546899a2dd95SBruce Richardson #endif
54697a093523SKonstantin Ananyev 	RTE_FUNC_PTR_OR_ERR_RET(*p->rx_descriptor_status, -ENOTSUP);
54707a093523SKonstantin Ananyev 	return (*p->rx_descriptor_status)(qd, offset);
547199a2dd95SBruce Richardson }
547299a2dd95SBruce Richardson 
54730ce56b05SThomas Monjalon /**@{@name Tx hardware descriptor states
54740ce56b05SThomas Monjalon  * @see rte_eth_tx_descriptor_status
54750ce56b05SThomas Monjalon  */
547699a2dd95SBruce Richardson #define RTE_ETH_TX_DESC_FULL    0 /**< Desc filled for hw, waiting xmit. */
547799a2dd95SBruce Richardson #define RTE_ETH_TX_DESC_DONE    1 /**< Desc done, packet is transmitted. */
547899a2dd95SBruce Richardson #define RTE_ETH_TX_DESC_UNAVAIL 2 /**< Desc used by driver or hw. */
54790ce56b05SThomas Monjalon /**@}*/
548099a2dd95SBruce Richardson 
548199a2dd95SBruce Richardson /**
548299a2dd95SBruce Richardson  * Check the status of a Tx descriptor in the queue.
548399a2dd95SBruce Richardson  *
548499a2dd95SBruce Richardson  * It should be called in a similar context than the Tx function:
548599a2dd95SBruce Richardson  * - on a dataplane core
548699a2dd95SBruce Richardson  * - not concurrently on the same queue
548799a2dd95SBruce Richardson  *
548899a2dd95SBruce Richardson  * Since it's a dataplane function, no check is performed on port_id and
548999a2dd95SBruce Richardson  * queue_id. The caller must therefore ensure that the port is enabled
549099a2dd95SBruce Richardson  * and the queue is configured and running.
549199a2dd95SBruce Richardson  *
549299a2dd95SBruce Richardson  * Note: accessing to a random descriptor in the ring may trigger cache
549399a2dd95SBruce Richardson  * misses and have a performance impact.
549499a2dd95SBruce Richardson  *
549599a2dd95SBruce Richardson  * @param port_id
549699a2dd95SBruce Richardson  *  A valid port identifier of the Ethernet device which.
549799a2dd95SBruce Richardson  * @param queue_id
549899a2dd95SBruce Richardson  *  A valid Tx queue identifier on this port.
549999a2dd95SBruce Richardson  * @param offset
550099a2dd95SBruce Richardson  *  The offset of the descriptor starting from tail (0 is the place where
550199a2dd95SBruce Richardson  *  the next packet will be send).
550299a2dd95SBruce Richardson  *
550399a2dd95SBruce Richardson  * @return
550499a2dd95SBruce Richardson  *  - (RTE_ETH_TX_DESC_FULL) Descriptor is being processed by the hw, i.e.
550599a2dd95SBruce Richardson  *    in the transmit queue.
550699a2dd95SBruce Richardson  *  - (RTE_ETH_TX_DESC_DONE) Hardware is done with this descriptor, it can
550799a2dd95SBruce Richardson  *    be reused by the driver.
550899a2dd95SBruce Richardson  *  - (RTE_ETH_TX_DESC_UNAVAIL): Descriptor is unavailable, reserved by the
550999a2dd95SBruce Richardson  *    driver or the hardware.
551099a2dd95SBruce Richardson  *  - (-EINVAL) bad descriptor offset.
551199a2dd95SBruce Richardson  *  - (-ENOTSUP) if the device does not support this function.
551299a2dd95SBruce Richardson  *  - (-ENODEV) bad port or queue (only if compiled with debug).
551399a2dd95SBruce Richardson  */
551499a2dd95SBruce Richardson static inline int rte_eth_tx_descriptor_status(uint16_t port_id,
551599a2dd95SBruce Richardson 	uint16_t queue_id, uint16_t offset)
551699a2dd95SBruce Richardson {
55177a093523SKonstantin Ananyev 	struct rte_eth_fp_ops *p;
55187a093523SKonstantin Ananyev 	void *qd;
55197a093523SKonstantin Ananyev 
55207a093523SKonstantin Ananyev #ifdef RTE_ETHDEV_DEBUG_TX
55217a093523SKonstantin Ananyev 	if (port_id >= RTE_MAX_ETHPORTS ||
55227a093523SKonstantin Ananyev 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
55237a093523SKonstantin Ananyev 		RTE_ETHDEV_LOG(ERR,
55247a093523SKonstantin Ananyev 			"Invalid port_id=%u or queue_id=%u\n",
55257a093523SKonstantin Ananyev 			port_id, queue_id);
55267a093523SKonstantin Ananyev 		return -EINVAL;
55277a093523SKonstantin Ananyev 	}
55287a093523SKonstantin Ananyev #endif
55297a093523SKonstantin Ananyev 
55307a093523SKonstantin Ananyev 	/* fetch pointer to queue data */
55317a093523SKonstantin Ananyev 	p = &rte_eth_fp_ops[port_id];
55327a093523SKonstantin Ananyev 	qd = p->txq.data[queue_id];
553399a2dd95SBruce Richardson 
553499a2dd95SBruce Richardson #ifdef RTE_ETHDEV_DEBUG_TX
553599a2dd95SBruce Richardson 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
55367a093523SKonstantin Ananyev 	if (qd == NULL)
553799a2dd95SBruce Richardson 		return -ENODEV;
553899a2dd95SBruce Richardson #endif
55397a093523SKonstantin Ananyev 	RTE_FUNC_PTR_OR_ERR_RET(*p->tx_descriptor_status, -ENOTSUP);
55407a093523SKonstantin Ananyev 	return (*p->tx_descriptor_status)(qd, offset);
554199a2dd95SBruce Richardson }
554299a2dd95SBruce Richardson 
554399a2dd95SBruce Richardson /**
55447a093523SKonstantin Ananyev  * @internal
55457a093523SKonstantin Ananyev  * Helper routine for rte_eth_tx_burst().
55467a093523SKonstantin Ananyev  * Should be called before entry PMD's rte_eth_tx_bulk implementation.
55477a093523SKonstantin Ananyev  * Does necessary pre-processing - invokes Tx callbacks if any, etc.
55487a093523SKonstantin Ananyev  *
55497a093523SKonstantin Ananyev  * @param port_id
55507a093523SKonstantin Ananyev  *   The port identifier of the Ethernet device.
55517a093523SKonstantin Ananyev  * @param queue_id
55527a093523SKonstantin Ananyev  *   The index of the transmit queue through which output packets must be
55537a093523SKonstantin Ananyev  *   sent.
55547a093523SKonstantin Ananyev  * @param tx_pkts
55557a093523SKonstantin Ananyev  *   The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
55567a093523SKonstantin Ananyev  *   which contain the output packets.
55577a093523SKonstantin Ananyev  * @param nb_pkts
55587a093523SKonstantin Ananyev  *   The maximum number of packets to transmit.
55597a093523SKonstantin Ananyev  * @return
55607a093523SKonstantin Ananyev  *   The number of output packets to transmit.
55617a093523SKonstantin Ananyev  */
55627a093523SKonstantin Ananyev uint16_t rte_eth_call_tx_callbacks(uint16_t port_id, uint16_t queue_id,
55637a093523SKonstantin Ananyev 	struct rte_mbuf **tx_pkts, uint16_t nb_pkts, void *opaque);
55647a093523SKonstantin Ananyev 
55657a093523SKonstantin Ananyev /**
556699a2dd95SBruce Richardson  * Send a burst of output packets on a transmit queue of an Ethernet device.
556799a2dd95SBruce Richardson  *
556899a2dd95SBruce Richardson  * The rte_eth_tx_burst() function is invoked to transmit output packets
556999a2dd95SBruce Richardson  * on the output queue *queue_id* of the Ethernet device designated by its
557099a2dd95SBruce Richardson  * *port_id*.
557199a2dd95SBruce Richardson  * The *nb_pkts* parameter is the number of packets to send which are
557299a2dd95SBruce Richardson  * supplied in the *tx_pkts* array of *rte_mbuf* structures, each of them
557399a2dd95SBruce Richardson  * allocated from a pool created with rte_pktmbuf_pool_create().
557499a2dd95SBruce Richardson  * The rte_eth_tx_burst() function loops, sending *nb_pkts* packets,
557509fd4227SAndrew Rybchenko  * up to the number of transmit descriptors available in the Tx ring of the
557699a2dd95SBruce Richardson  * transmit queue.
557799a2dd95SBruce Richardson  * For each packet to send, the rte_eth_tx_burst() function performs
557899a2dd95SBruce Richardson  * the following operations:
557999a2dd95SBruce Richardson  *
558099a2dd95SBruce Richardson  * - Pick up the next available descriptor in the transmit ring.
558199a2dd95SBruce Richardson  *
558299a2dd95SBruce Richardson  * - Free the network buffer previously sent with that descriptor, if any.
558399a2dd95SBruce Richardson  *
558499a2dd95SBruce Richardson  * - Initialize the transmit descriptor with the information provided
558599a2dd95SBruce Richardson  *   in the *rte_mbuf data structure.
558699a2dd95SBruce Richardson  *
558799a2dd95SBruce Richardson  * In the case of a segmented packet composed of a list of *rte_mbuf* buffers,
558899a2dd95SBruce Richardson  * the rte_eth_tx_burst() function uses several transmit descriptors
558999a2dd95SBruce Richardson  * of the ring.
559099a2dd95SBruce Richardson  *
559199a2dd95SBruce Richardson  * The rte_eth_tx_burst() function returns the number of packets it
559299a2dd95SBruce Richardson  * actually sent. A return value equal to *nb_pkts* means that all packets
559399a2dd95SBruce Richardson  * have been sent, and this is likely to signify that other output packets
559499a2dd95SBruce Richardson  * could be immediately transmitted again. Applications that implement a
559599a2dd95SBruce Richardson  * "send as many packets to transmit as possible" policy can check this
559699a2dd95SBruce Richardson  * specific case and keep invoking the rte_eth_tx_burst() function until
559799a2dd95SBruce Richardson  * a value less than *nb_pkts* is returned.
559899a2dd95SBruce Richardson  *
559999a2dd95SBruce Richardson  * It is the responsibility of the rte_eth_tx_burst() function to
560099a2dd95SBruce Richardson  * transparently free the memory buffers of packets previously sent.
560199a2dd95SBruce Richardson  * This feature is driven by the *tx_free_thresh* value supplied to the
560299a2dd95SBruce Richardson  * rte_eth_dev_configure() function at device configuration time.
560309fd4227SAndrew Rybchenko  * When the number of free Tx descriptors drops below this threshold, the
560499a2dd95SBruce Richardson  * rte_eth_tx_burst() function must [attempt to] free the *rte_mbuf*  buffers
560599a2dd95SBruce Richardson  * of those packets whose transmission was effectively completed.
560699a2dd95SBruce Richardson  *
5607295968d1SFerruh Yigit  * If the PMD is RTE_ETH_TX_OFFLOAD_MT_LOCKFREE capable, multiple threads can
560809fd4227SAndrew Rybchenko  * invoke this function concurrently on the same Tx queue without SW lock.
560999a2dd95SBruce Richardson  * @see rte_eth_dev_info_get, struct rte_eth_txconf::offloads
561099a2dd95SBruce Richardson  *
561199a2dd95SBruce Richardson  * @see rte_eth_tx_prepare to perform some prior checks or adjustments
561299a2dd95SBruce Richardson  * for offloads.
561399a2dd95SBruce Richardson  *
561499a2dd95SBruce Richardson  * @param port_id
561599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
561699a2dd95SBruce Richardson  * @param queue_id
561799a2dd95SBruce Richardson  *   The index of the transmit queue through which output packets must be
561899a2dd95SBruce Richardson  *   sent.
561999a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
562099a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
562199a2dd95SBruce Richardson  * @param tx_pkts
562299a2dd95SBruce Richardson  *   The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
562399a2dd95SBruce Richardson  *   which contain the output packets.
562499a2dd95SBruce Richardson  * @param nb_pkts
562599a2dd95SBruce Richardson  *   The maximum number of packets to transmit.
562699a2dd95SBruce Richardson  * @return
562799a2dd95SBruce Richardson  *   The number of output packets actually stored in transmit descriptors of
562899a2dd95SBruce Richardson  *   the transmit ring. The return value can be less than the value of the
562999a2dd95SBruce Richardson  *   *tx_pkts* parameter when the transmit ring is full or has been filled up.
563099a2dd95SBruce Richardson  */
563199a2dd95SBruce Richardson static inline uint16_t
563299a2dd95SBruce Richardson rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
563399a2dd95SBruce Richardson 		 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
563499a2dd95SBruce Richardson {
56357a093523SKonstantin Ananyev 	struct rte_eth_fp_ops *p;
56367a093523SKonstantin Ananyev 	void *qd;
56377a093523SKonstantin Ananyev 
56387a093523SKonstantin Ananyev #ifdef RTE_ETHDEV_DEBUG_TX
56397a093523SKonstantin Ananyev 	if (port_id >= RTE_MAX_ETHPORTS ||
56407a093523SKonstantin Ananyev 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
56417a093523SKonstantin Ananyev 		RTE_ETHDEV_LOG(ERR,
56427a093523SKonstantin Ananyev 			"Invalid port_id=%u or queue_id=%u\n",
56437a093523SKonstantin Ananyev 			port_id, queue_id);
56447a093523SKonstantin Ananyev 		return 0;
56457a093523SKonstantin Ananyev 	}
56467a093523SKonstantin Ananyev #endif
56477a093523SKonstantin Ananyev 
56487a093523SKonstantin Ananyev 	/* fetch pointer to queue data */
56497a093523SKonstantin Ananyev 	p = &rte_eth_fp_ops[port_id];
56507a093523SKonstantin Ananyev 	qd = p->txq.data[queue_id];
565199a2dd95SBruce Richardson 
565299a2dd95SBruce Richardson #ifdef RTE_ETHDEV_DEBUG_TX
565399a2dd95SBruce Richardson 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
565499a2dd95SBruce Richardson 
56557a093523SKonstantin Ananyev 	if (qd == NULL) {
565609fd4227SAndrew Rybchenko 		RTE_ETHDEV_LOG(ERR, "Invalid Tx queue_id=%u for port_id=%u\n",
56577a093523SKonstantin Ananyev 			queue_id, port_id);
565899a2dd95SBruce Richardson 		return 0;
565999a2dd95SBruce Richardson 	}
566099a2dd95SBruce Richardson #endif
566199a2dd95SBruce Richardson 
566299a2dd95SBruce Richardson #ifdef RTE_ETHDEV_RXTX_CALLBACKS
56637a093523SKonstantin Ananyev 	{
56647a093523SKonstantin Ananyev 		void *cb;
566599a2dd95SBruce Richardson 
566699a2dd95SBruce Richardson 		/* __ATOMIC_RELEASE memory order was used when the
566799a2dd95SBruce Richardson 		 * call back was inserted into the list.
566899a2dd95SBruce Richardson 		 * Since there is a clear dependency between loading
566999a2dd95SBruce Richardson 		 * cb and cb->fn/cb->next, __ATOMIC_ACQUIRE memory order is
567099a2dd95SBruce Richardson 		 * not required.
567199a2dd95SBruce Richardson 		 */
56727a093523SKonstantin Ananyev 		cb = __atomic_load_n((void **)&p->txq.clbk[queue_id],
567399a2dd95SBruce Richardson 				__ATOMIC_RELAXED);
56747a093523SKonstantin Ananyev 		if (unlikely(cb != NULL))
56757a093523SKonstantin Ananyev 			nb_pkts = rte_eth_call_tx_callbacks(port_id, queue_id,
56767a093523SKonstantin Ananyev 					tx_pkts, nb_pkts, cb);
567799a2dd95SBruce Richardson 	}
567899a2dd95SBruce Richardson #endif
567999a2dd95SBruce Richardson 
56807a093523SKonstantin Ananyev 	nb_pkts = p->tx_pkt_burst(qd, tx_pkts, nb_pkts);
56817a093523SKonstantin Ananyev 
56827a093523SKonstantin Ananyev 	rte_ethdev_trace_tx_burst(port_id, queue_id, (void **)tx_pkts, nb_pkts);
56837a093523SKonstantin Ananyev 	return nb_pkts;
568499a2dd95SBruce Richardson }
568599a2dd95SBruce Richardson 
568699a2dd95SBruce Richardson /**
568799a2dd95SBruce Richardson  * Process a burst of output packets on a transmit queue of an Ethernet device.
568899a2dd95SBruce Richardson  *
568999a2dd95SBruce Richardson  * The rte_eth_tx_prepare() function is invoked to prepare output packets to be
569099a2dd95SBruce Richardson  * transmitted on the output queue *queue_id* of the Ethernet device designated
569199a2dd95SBruce Richardson  * by its *port_id*.
569299a2dd95SBruce Richardson  * The *nb_pkts* parameter is the number of packets to be prepared which are
569399a2dd95SBruce Richardson  * supplied in the *tx_pkts* array of *rte_mbuf* structures, each of them
569499a2dd95SBruce Richardson  * allocated from a pool created with rte_pktmbuf_pool_create().
569599a2dd95SBruce Richardson  * For each packet to send, the rte_eth_tx_prepare() function performs
569699a2dd95SBruce Richardson  * the following operations:
569799a2dd95SBruce Richardson  *
569809fd4227SAndrew Rybchenko  * - Check if packet meets devices requirements for Tx offloads.
569999a2dd95SBruce Richardson  *
570099a2dd95SBruce Richardson  * - Check limitations about number of segments.
570199a2dd95SBruce Richardson  *
570299a2dd95SBruce Richardson  * - Check additional requirements when debug is enabled.
570399a2dd95SBruce Richardson  *
570409fd4227SAndrew Rybchenko  * - Update and/or reset required checksums when Tx offload is set for packet.
570599a2dd95SBruce Richardson  *
570699a2dd95SBruce Richardson  * Since this function can modify packet data, provided mbufs must be safely
570799a2dd95SBruce Richardson  * writable (e.g. modified data cannot be in shared segment).
570899a2dd95SBruce Richardson  *
570999a2dd95SBruce Richardson  * The rte_eth_tx_prepare() function returns the number of packets ready to be
571099a2dd95SBruce Richardson  * sent. A return value equal to *nb_pkts* means that all packets are valid and
571199a2dd95SBruce Richardson  * ready to be sent, otherwise stops processing on the first invalid packet and
571299a2dd95SBruce Richardson  * leaves the rest packets untouched.
571399a2dd95SBruce Richardson  *
571499a2dd95SBruce Richardson  * When this functionality is not implemented in the driver, all packets are
571599a2dd95SBruce Richardson  * are returned untouched.
571699a2dd95SBruce Richardson  *
571799a2dd95SBruce Richardson  * @param port_id
571899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
57195906be5aSAndrew Rybchenko  *   The value must be a valid port ID.
572099a2dd95SBruce Richardson  * @param queue_id
572199a2dd95SBruce Richardson  *   The index of the transmit queue through which output packets must be
572299a2dd95SBruce Richardson  *   sent.
572399a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
572499a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
572599a2dd95SBruce Richardson  * @param tx_pkts
572699a2dd95SBruce Richardson  *   The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
572799a2dd95SBruce Richardson  *   which contain the output packets.
572899a2dd95SBruce Richardson  * @param nb_pkts
572999a2dd95SBruce Richardson  *   The maximum number of packets to process.
573099a2dd95SBruce Richardson  * @return
573199a2dd95SBruce Richardson  *   The number of packets correct and ready to be sent. The return value can be
573299a2dd95SBruce Richardson  *   less than the value of the *tx_pkts* parameter when some packet doesn't
573399a2dd95SBruce Richardson  *   meet devices requirements with rte_errno set appropriately:
573499a2dd95SBruce Richardson  *   - EINVAL: offload flags are not correctly set
573599a2dd95SBruce Richardson  *   - ENOTSUP: the offload feature is not supported by the hardware
573699a2dd95SBruce Richardson  *   - ENODEV: if *port_id* is invalid (with debug enabled only)
573799a2dd95SBruce Richardson  *
573899a2dd95SBruce Richardson  */
573999a2dd95SBruce Richardson 
574099a2dd95SBruce Richardson #ifndef RTE_ETHDEV_TX_PREPARE_NOOP
574199a2dd95SBruce Richardson 
574299a2dd95SBruce Richardson static inline uint16_t
574399a2dd95SBruce Richardson rte_eth_tx_prepare(uint16_t port_id, uint16_t queue_id,
574499a2dd95SBruce Richardson 		struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
574599a2dd95SBruce Richardson {
57467a093523SKonstantin Ananyev 	struct rte_eth_fp_ops *p;
57477a093523SKonstantin Ananyev 	void *qd;
57487a093523SKonstantin Ananyev 
57497a093523SKonstantin Ananyev #ifdef RTE_ETHDEV_DEBUG_TX
57507a093523SKonstantin Ananyev 	if (port_id >= RTE_MAX_ETHPORTS ||
57517a093523SKonstantin Ananyev 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
57527a093523SKonstantin Ananyev 		RTE_ETHDEV_LOG(ERR,
57537a093523SKonstantin Ananyev 			"Invalid port_id=%u or queue_id=%u\n",
57547a093523SKonstantin Ananyev 			port_id, queue_id);
57557a093523SKonstantin Ananyev 		rte_errno = ENODEV;
57567a093523SKonstantin Ananyev 		return 0;
57577a093523SKonstantin Ananyev 	}
57587a093523SKonstantin Ananyev #endif
57597a093523SKonstantin Ananyev 
57607a093523SKonstantin Ananyev 	/* fetch pointer to queue data */
57617a093523SKonstantin Ananyev 	p = &rte_eth_fp_ops[port_id];
57627a093523SKonstantin Ananyev 	qd = p->txq.data[queue_id];
576399a2dd95SBruce Richardson 
576499a2dd95SBruce Richardson #ifdef RTE_ETHDEV_DEBUG_TX
576599a2dd95SBruce Richardson 	if (!rte_eth_dev_is_valid_port(port_id)) {
576609fd4227SAndrew Rybchenko 		RTE_ETHDEV_LOG(ERR, "Invalid Tx port_id=%u\n", port_id);
576799a2dd95SBruce Richardson 		rte_errno = ENODEV;
576899a2dd95SBruce Richardson 		return 0;
576999a2dd95SBruce Richardson 	}
57707a093523SKonstantin Ananyev 	if (qd == NULL) {
577109fd4227SAndrew Rybchenko 		RTE_ETHDEV_LOG(ERR, "Invalid Tx queue_id=%u for port_id=%u\n",
57727a093523SKonstantin Ananyev 			queue_id, port_id);
577399a2dd95SBruce Richardson 		rte_errno = EINVAL;
577499a2dd95SBruce Richardson 		return 0;
577599a2dd95SBruce Richardson 	}
577699a2dd95SBruce Richardson #endif
577799a2dd95SBruce Richardson 
57787a093523SKonstantin Ananyev 	if (!p->tx_pkt_prepare)
577999a2dd95SBruce Richardson 		return nb_pkts;
578099a2dd95SBruce Richardson 
57817a093523SKonstantin Ananyev 	return p->tx_pkt_prepare(qd, tx_pkts, nb_pkts);
578299a2dd95SBruce Richardson }
578399a2dd95SBruce Richardson 
578499a2dd95SBruce Richardson #else
578599a2dd95SBruce Richardson 
578699a2dd95SBruce Richardson /*
578799a2dd95SBruce Richardson  * Native NOOP operation for compilation targets which doesn't require any
578899a2dd95SBruce Richardson  * preparations steps, and functional NOOP may introduce unnecessary performance
578999a2dd95SBruce Richardson  * drop.
579099a2dd95SBruce Richardson  *
579199a2dd95SBruce Richardson  * Generally this is not a good idea to turn it on globally and didn't should
579299a2dd95SBruce Richardson  * be used if behavior of tx_preparation can change.
579399a2dd95SBruce Richardson  */
579499a2dd95SBruce Richardson 
579599a2dd95SBruce Richardson static inline uint16_t
579699a2dd95SBruce Richardson rte_eth_tx_prepare(__rte_unused uint16_t port_id,
579799a2dd95SBruce Richardson 		__rte_unused uint16_t queue_id,
579899a2dd95SBruce Richardson 		__rte_unused struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
579999a2dd95SBruce Richardson {
580099a2dd95SBruce Richardson 	return nb_pkts;
580199a2dd95SBruce Richardson }
580299a2dd95SBruce Richardson 
580399a2dd95SBruce Richardson #endif
580499a2dd95SBruce Richardson 
580599a2dd95SBruce Richardson /**
580699a2dd95SBruce Richardson  * Send any packets queued up for transmission on a port and HW queue
580799a2dd95SBruce Richardson  *
580899a2dd95SBruce Richardson  * This causes an explicit flush of packets previously buffered via the
580999a2dd95SBruce Richardson  * rte_eth_tx_buffer() function. It returns the number of packets successfully
581099a2dd95SBruce Richardson  * sent to the NIC, and calls the error callback for any unsent packets. Unless
581199a2dd95SBruce Richardson  * explicitly set up otherwise, the default callback simply frees the unsent
581299a2dd95SBruce Richardson  * packets back to the owning mempool.
581399a2dd95SBruce Richardson  *
581499a2dd95SBruce Richardson  * @param port_id
581599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
581699a2dd95SBruce Richardson  * @param queue_id
581799a2dd95SBruce Richardson  *   The index of the transmit queue through which output packets must be
581899a2dd95SBruce Richardson  *   sent.
581999a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
582099a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
582199a2dd95SBruce Richardson  * @param buffer
582299a2dd95SBruce Richardson  *   Buffer of packets to be transmit.
582399a2dd95SBruce Richardson  * @return
582499a2dd95SBruce Richardson  *   The number of packets successfully sent to the Ethernet device. The error
582599a2dd95SBruce Richardson  *   callback is called for any packets which could not be sent.
582699a2dd95SBruce Richardson  */
582799a2dd95SBruce Richardson static inline uint16_t
582899a2dd95SBruce Richardson rte_eth_tx_buffer_flush(uint16_t port_id, uint16_t queue_id,
582999a2dd95SBruce Richardson 		struct rte_eth_dev_tx_buffer *buffer)
583099a2dd95SBruce Richardson {
583199a2dd95SBruce Richardson 	uint16_t sent;
583299a2dd95SBruce Richardson 	uint16_t to_send = buffer->length;
583399a2dd95SBruce Richardson 
583499a2dd95SBruce Richardson 	if (to_send == 0)
583599a2dd95SBruce Richardson 		return 0;
583699a2dd95SBruce Richardson 
583799a2dd95SBruce Richardson 	sent = rte_eth_tx_burst(port_id, queue_id, buffer->pkts, to_send);
583899a2dd95SBruce Richardson 
583999a2dd95SBruce Richardson 	buffer->length = 0;
584099a2dd95SBruce Richardson 
584199a2dd95SBruce Richardson 	/* All packets sent, or to be dealt with by callback below */
584299a2dd95SBruce Richardson 	if (unlikely(sent != to_send))
584399a2dd95SBruce Richardson 		buffer->error_callback(&buffer->pkts[sent],
584499a2dd95SBruce Richardson 				       (uint16_t)(to_send - sent),
584599a2dd95SBruce Richardson 				       buffer->error_userdata);
584699a2dd95SBruce Richardson 
584799a2dd95SBruce Richardson 	return sent;
584899a2dd95SBruce Richardson }
584999a2dd95SBruce Richardson 
585099a2dd95SBruce Richardson /**
585199a2dd95SBruce Richardson  * Buffer a single packet for future transmission on a port and queue
585299a2dd95SBruce Richardson  *
585399a2dd95SBruce Richardson  * This function takes a single mbuf/packet and buffers it for later
585499a2dd95SBruce Richardson  * transmission on the particular port and queue specified. Once the buffer is
585599a2dd95SBruce Richardson  * full of packets, an attempt will be made to transmit all the buffered
585699a2dd95SBruce Richardson  * packets. In case of error, where not all packets can be transmitted, a
585799a2dd95SBruce Richardson  * callback is called with the unsent packets as a parameter. If no callback
585899a2dd95SBruce Richardson  * is explicitly set up, the unsent packets are just freed back to the owning
585999a2dd95SBruce Richardson  * mempool. The function returns the number of packets actually sent i.e.
586099a2dd95SBruce Richardson  * 0 if no buffer flush occurred, otherwise the number of packets successfully
586199a2dd95SBruce Richardson  * flushed
586299a2dd95SBruce Richardson  *
586399a2dd95SBruce Richardson  * @param port_id
586499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
586599a2dd95SBruce Richardson  * @param queue_id
586699a2dd95SBruce Richardson  *   The index of the transmit queue through which output packets must be
586799a2dd95SBruce Richardson  *   sent.
586899a2dd95SBruce Richardson  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
586999a2dd95SBruce Richardson  *   to rte_eth_dev_configure().
587099a2dd95SBruce Richardson  * @param buffer
587199a2dd95SBruce Richardson  *   Buffer used to collect packets to be sent.
587299a2dd95SBruce Richardson  * @param tx_pkt
587399a2dd95SBruce Richardson  *   Pointer to the packet mbuf to be sent.
587499a2dd95SBruce Richardson  * @return
587599a2dd95SBruce Richardson  *   0 = packet has been buffered for later transmission
587699a2dd95SBruce Richardson  *   N > 0 = packet has been buffered, and the buffer was subsequently flushed,
587799a2dd95SBruce Richardson  *     causing N packets to be sent, and the error callback to be called for
587899a2dd95SBruce Richardson  *     the rest.
587999a2dd95SBruce Richardson  */
588099a2dd95SBruce Richardson static __rte_always_inline uint16_t
588199a2dd95SBruce Richardson rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id,
588299a2dd95SBruce Richardson 		struct rte_eth_dev_tx_buffer *buffer, struct rte_mbuf *tx_pkt)
588399a2dd95SBruce Richardson {
588499a2dd95SBruce Richardson 	buffer->pkts[buffer->length++] = tx_pkt;
588599a2dd95SBruce Richardson 	if (buffer->length < buffer->size)
588699a2dd95SBruce Richardson 		return 0;
588799a2dd95SBruce Richardson 
588899a2dd95SBruce Richardson 	return rte_eth_tx_buffer_flush(port_id, queue_id, buffer);
588999a2dd95SBruce Richardson }
589099a2dd95SBruce Richardson 
589199a2dd95SBruce Richardson #ifdef __cplusplus
589299a2dd95SBruce Richardson }
589399a2dd95SBruce Richardson #endif
589499a2dd95SBruce Richardson 
589599a2dd95SBruce Richardson #endif /* _RTE_ETHDEV_H_ */
5896