xref: /f-stack/dpdk/lib/librte_ethdev/rte_ethdev.h (revision 2d9fd380)
1d30ea906Sjfb8856606 /* SPDX-License-Identifier: BSD-3-Clause
2d30ea906Sjfb8856606  * Copyright(c) 2010-2017 Intel Corporation
3d30ea906Sjfb8856606  */
4d30ea906Sjfb8856606 
5d30ea906Sjfb8856606 #ifndef _RTE_ETHDEV_H_
6d30ea906Sjfb8856606 #define _RTE_ETHDEV_H_
7d30ea906Sjfb8856606 
8d30ea906Sjfb8856606 /**
9d30ea906Sjfb8856606  * @file
10d30ea906Sjfb8856606  *
11d30ea906Sjfb8856606  * RTE Ethernet Device API
12d30ea906Sjfb8856606  *
13d30ea906Sjfb8856606  * The Ethernet Device API is composed of two parts:
14d30ea906Sjfb8856606  *
15d30ea906Sjfb8856606  * - The application-oriented Ethernet API that includes functions to setup
16d30ea906Sjfb8856606  *   an Ethernet device (configure it, setup its RX and TX queues and start it),
17d30ea906Sjfb8856606  *   to get its MAC address, the speed and the status of its physical link,
18d30ea906Sjfb8856606  *   to receive and to transmit packets, and so on.
19d30ea906Sjfb8856606  *
20d30ea906Sjfb8856606  * - The driver-oriented Ethernet API that exports functions allowing
21d30ea906Sjfb8856606  *   an Ethernet Poll Mode Driver (PMD) to allocate an Ethernet device instance,
22d30ea906Sjfb8856606  *   create memzone for HW rings and process registered callbacks, and so on.
23d30ea906Sjfb8856606  *   PMDs should include rte_ethdev_driver.h instead of this header.
24d30ea906Sjfb8856606  *
25d30ea906Sjfb8856606  * By default, all the functions of the Ethernet Device API exported by a PMD
26d30ea906Sjfb8856606  * are lock-free functions which assume to not be invoked in parallel on
27d30ea906Sjfb8856606  * different logical cores to work on the same target object.  For instance,
28d30ea906Sjfb8856606  * the receive function of a PMD cannot be invoked in parallel on two logical
29d30ea906Sjfb8856606  * cores to poll the same RX queue [of the same port]. Of course, this function
30d30ea906Sjfb8856606  * can be invoked in parallel by different logical cores on different RX queues.
31d30ea906Sjfb8856606  * It is the responsibility of the upper level application to enforce this rule.
32d30ea906Sjfb8856606  *
33d30ea906Sjfb8856606  * If needed, parallel accesses by multiple logical cores to shared queues
34d30ea906Sjfb8856606  * shall be explicitly protected by dedicated inline lock-aware functions
35d30ea906Sjfb8856606  * built on top of their corresponding lock-free functions of the PMD API.
36d30ea906Sjfb8856606  *
37d30ea906Sjfb8856606  * In all functions of the Ethernet API, the Ethernet device is
38d30ea906Sjfb8856606  * designated by an integer >= 0 named the device port identifier.
39d30ea906Sjfb8856606  *
40d30ea906Sjfb8856606  * At the Ethernet driver level, Ethernet devices are represented by a generic
41d30ea906Sjfb8856606  * data structure of type *rte_eth_dev*.
42d30ea906Sjfb8856606  *
43d30ea906Sjfb8856606  * Ethernet devices are dynamically registered during the PCI probing phase
44d30ea906Sjfb8856606  * performed at EAL initialization time.
45d30ea906Sjfb8856606  * When an Ethernet device is being probed, an *rte_eth_dev* structure and
46d30ea906Sjfb8856606  * a new port identifier are allocated for that device. Then, the eth_dev_init()
47d30ea906Sjfb8856606  * function supplied by the Ethernet driver matching the probed PCI
48d30ea906Sjfb8856606  * device is invoked to properly initialize the device.
49d30ea906Sjfb8856606  *
50d30ea906Sjfb8856606  * The role of the device init function consists of resetting the hardware,
51d30ea906Sjfb8856606  * checking access to Non-volatile Memory (NVM), reading the MAC address
52d30ea906Sjfb8856606  * from NVM etc.
53d30ea906Sjfb8856606  *
54d30ea906Sjfb8856606  * If the device init operation is successful, the correspondence between
55d30ea906Sjfb8856606  * the port identifier assigned to the new device and its associated
56d30ea906Sjfb8856606  * *rte_eth_dev* structure is effectively registered.
57d30ea906Sjfb8856606  * Otherwise, both the *rte_eth_dev* structure and the port identifier are
58d30ea906Sjfb8856606  * freed.
59d30ea906Sjfb8856606  *
60d30ea906Sjfb8856606  * The functions exported by the application Ethernet API to setup a device
61d30ea906Sjfb8856606  * designated by its port identifier must be invoked in the following order:
62d30ea906Sjfb8856606  *     - rte_eth_dev_configure()
63d30ea906Sjfb8856606  *     - rte_eth_tx_queue_setup()
64d30ea906Sjfb8856606  *     - rte_eth_rx_queue_setup()
65d30ea906Sjfb8856606  *     - rte_eth_dev_start()
66d30ea906Sjfb8856606  *
67d30ea906Sjfb8856606  * Then, the network application can invoke, in any order, the functions
68d30ea906Sjfb8856606  * exported by the Ethernet API to get the MAC address of a given device, to
69d30ea906Sjfb8856606  * get the speed and the status of a device physical link, to receive/transmit
70d30ea906Sjfb8856606  * [burst of] packets, and so on.
71d30ea906Sjfb8856606  *
72d30ea906Sjfb8856606  * If the application wants to change the configuration (i.e. call
73d30ea906Sjfb8856606  * rte_eth_dev_configure(), rte_eth_tx_queue_setup(), or
74d30ea906Sjfb8856606  * rte_eth_rx_queue_setup()), it must call rte_eth_dev_stop() first to stop the
75d30ea906Sjfb8856606  * device and then do the reconfiguration before calling rte_eth_dev_start()
76d30ea906Sjfb8856606  * again. The transmit and receive functions should not be invoked when the
77d30ea906Sjfb8856606  * device is stopped.
78d30ea906Sjfb8856606  *
79d30ea906Sjfb8856606  * Please note that some configuration is not stored between calls to
80d30ea906Sjfb8856606  * rte_eth_dev_stop()/rte_eth_dev_start(). The following configuration will
81d30ea906Sjfb8856606  * be retained:
82d30ea906Sjfb8856606  *
834418919fSjohnjiang  *     - MTU
84d30ea906Sjfb8856606  *     - flow control settings
854418919fSjohnjiang  *     - receive mode configuration (promiscuous mode, all-multicast mode,
864418919fSjohnjiang  *       hardware checksum mode, RSS/VMDQ settings etc.)
87d30ea906Sjfb8856606  *     - VLAN filtering configuration
884418919fSjohnjiang  *     - default MAC address
89d30ea906Sjfb8856606  *     - MAC addresses supplied to MAC address array
90d30ea906Sjfb8856606  *     - flow director filtering mode (but not filtering rules)
91d30ea906Sjfb8856606  *     - NIC queue statistics mappings
92d30ea906Sjfb8856606  *
93d30ea906Sjfb8856606  * Any other configuration will not be stored and will need to be re-entered
94d30ea906Sjfb8856606  * before a call to rte_eth_dev_start().
95d30ea906Sjfb8856606  *
96d30ea906Sjfb8856606  * Finally, a network application can close an Ethernet device by invoking the
97d30ea906Sjfb8856606  * rte_eth_dev_close() function.
98d30ea906Sjfb8856606  *
99d30ea906Sjfb8856606  * Each function of the application Ethernet API invokes a specific function
100d30ea906Sjfb8856606  * of the PMD that controls the target device designated by its port
101d30ea906Sjfb8856606  * identifier.
102d30ea906Sjfb8856606  * For this purpose, all device-specific functions of an Ethernet driver are
103d30ea906Sjfb8856606  * supplied through a set of pointers contained in a generic structure of type
104d30ea906Sjfb8856606  * *eth_dev_ops*.
105d30ea906Sjfb8856606  * The address of the *eth_dev_ops* structure is stored in the *rte_eth_dev*
106d30ea906Sjfb8856606  * structure by the device init function of the Ethernet driver, which is
107d30ea906Sjfb8856606  * invoked during the PCI probing phase, as explained earlier.
108d30ea906Sjfb8856606  *
109d30ea906Sjfb8856606  * In other words, each function of the Ethernet API simply retrieves the
110d30ea906Sjfb8856606  * *rte_eth_dev* structure associated with the device port identifier and
111d30ea906Sjfb8856606  * performs an indirect invocation of the corresponding driver function
112d30ea906Sjfb8856606  * supplied in the *eth_dev_ops* structure of the *rte_eth_dev* structure.
113d30ea906Sjfb8856606  *
114d30ea906Sjfb8856606  * For performance reasons, the address of the burst-oriented RX and TX
115d30ea906Sjfb8856606  * functions of the Ethernet driver are not contained in the *eth_dev_ops*
116d30ea906Sjfb8856606  * structure. Instead, they are directly stored at the beginning of the
117d30ea906Sjfb8856606  * *rte_eth_dev* structure to avoid an extra indirect memory access during
118d30ea906Sjfb8856606  * their invocation.
119d30ea906Sjfb8856606  *
120d30ea906Sjfb8856606  * RTE ethernet device drivers do not use interrupts for transmitting or
121d30ea906Sjfb8856606  * receiving. Instead, Ethernet drivers export Poll-Mode receive and transmit
122d30ea906Sjfb8856606  * functions to applications.
123d30ea906Sjfb8856606  * Both receive and transmit functions are packet-burst oriented to minimize
124d30ea906Sjfb8856606  * their cost per packet through the following optimizations:
125d30ea906Sjfb8856606  *
126d30ea906Sjfb8856606  * - Sharing among multiple packets the incompressible cost of the
127d30ea906Sjfb8856606  *   invocation of receive/transmit functions.
128d30ea906Sjfb8856606  *
129d30ea906Sjfb8856606  * - Enabling receive/transmit functions to take advantage of burst-oriented
130d30ea906Sjfb8856606  *   hardware features (L1 cache, prefetch instructions, NIC head/tail
131d30ea906Sjfb8856606  *   registers) to minimize the number of CPU cycles per packet, for instance,
132d30ea906Sjfb8856606  *   by avoiding useless read memory accesses to ring descriptors, or by
133d30ea906Sjfb8856606  *   systematically using arrays of pointers that exactly fit L1 cache line
134d30ea906Sjfb8856606  *   boundaries and sizes.
135d30ea906Sjfb8856606  *
136d30ea906Sjfb8856606  * The burst-oriented receive function does not provide any error notification,
137d30ea906Sjfb8856606  * to avoid the corresponding overhead. As a hint, the upper-level application
138d30ea906Sjfb8856606  * might check the status of the device link once being systematically returned
139d30ea906Sjfb8856606  * a 0 value by the receive function of the driver for a given number of tries.
140d30ea906Sjfb8856606  */
141d30ea906Sjfb8856606 
142d30ea906Sjfb8856606 #ifdef __cplusplus
143d30ea906Sjfb8856606 extern "C" {
144d30ea906Sjfb8856606 #endif
145d30ea906Sjfb8856606 
146d30ea906Sjfb8856606 #include <stdint.h>
147d30ea906Sjfb8856606 
148d30ea906Sjfb8856606 /* Use this macro to check if LRO API is supported */
149d30ea906Sjfb8856606 #define RTE_ETHDEV_HAS_LRO_SUPPORT
150d30ea906Sjfb8856606 
151d30ea906Sjfb8856606 #include <rte_compat.h>
152d30ea906Sjfb8856606 #include <rte_log.h>
153d30ea906Sjfb8856606 #include <rte_interrupts.h>
154d30ea906Sjfb8856606 #include <rte_dev.h>
155d30ea906Sjfb8856606 #include <rte_devargs.h>
156d30ea906Sjfb8856606 #include <rte_errno.h>
157d30ea906Sjfb8856606 #include <rte_common.h>
158d30ea906Sjfb8856606 #include <rte_config.h>
1594418919fSjohnjiang #include <rte_ether.h>
160d30ea906Sjfb8856606 
161*2d9fd380Sjfb8856606 #include "rte_ethdev_trace_fp.h"
162d30ea906Sjfb8856606 #include "rte_dev_info.h"
163d30ea906Sjfb8856606 
164d30ea906Sjfb8856606 extern int rte_eth_dev_logtype;
165d30ea906Sjfb8856606 
166d30ea906Sjfb8856606 #define RTE_ETHDEV_LOG(level, ...) \
167d30ea906Sjfb8856606 	rte_log(RTE_LOG_ ## level, rte_eth_dev_logtype, "" __VA_ARGS__)
168d30ea906Sjfb8856606 
169d30ea906Sjfb8856606 struct rte_mbuf;
170d30ea906Sjfb8856606 
171d30ea906Sjfb8856606 /**
172d30ea906Sjfb8856606  * Initializes a device iterator.
173d30ea906Sjfb8856606  *
174d30ea906Sjfb8856606  * This iterator allows accessing a list of devices matching some devargs.
175d30ea906Sjfb8856606  *
176d30ea906Sjfb8856606  * @param iter
177d30ea906Sjfb8856606  *   Device iterator handle initialized by the function.
178d30ea906Sjfb8856606  *   The fields bus_str and cls_str might be dynamically allocated,
179d30ea906Sjfb8856606  *   and could be freed by calling rte_eth_iterator_cleanup().
180d30ea906Sjfb8856606  *
181d30ea906Sjfb8856606  * @param devargs
182d30ea906Sjfb8856606  *   Device description string.
183d30ea906Sjfb8856606  *
184d30ea906Sjfb8856606  * @return
185d30ea906Sjfb8856606  *   0 on successful initialization, negative otherwise.
186d30ea906Sjfb8856606  */
187d30ea906Sjfb8856606 int rte_eth_iterator_init(struct rte_dev_iterator *iter, const char *devargs);
188d30ea906Sjfb8856606 
189d30ea906Sjfb8856606 /**
190d30ea906Sjfb8856606  * Iterates on devices with devargs filter.
191d30ea906Sjfb8856606  * The ownership is not checked.
192d30ea906Sjfb8856606  *
193d30ea906Sjfb8856606  * The next port id is returned, and the iterator is updated.
194d30ea906Sjfb8856606  *
195d30ea906Sjfb8856606  * @param iter
196d30ea906Sjfb8856606  *   Device iterator handle initialized by rte_eth_iterator_init().
197d30ea906Sjfb8856606  *   Some fields bus_str and cls_str might be freed when no more port is found,
198d30ea906Sjfb8856606  *   by calling rte_eth_iterator_cleanup().
199d30ea906Sjfb8856606  *
200d30ea906Sjfb8856606  * @return
201d30ea906Sjfb8856606  *   A port id if found, RTE_MAX_ETHPORTS otherwise.
202d30ea906Sjfb8856606  */
203d30ea906Sjfb8856606 uint16_t rte_eth_iterator_next(struct rte_dev_iterator *iter);
204d30ea906Sjfb8856606 
205d30ea906Sjfb8856606 /**
206d30ea906Sjfb8856606  * Free some allocated fields of the iterator.
207d30ea906Sjfb8856606  *
208d30ea906Sjfb8856606  * This function is automatically called by rte_eth_iterator_next()
209d30ea906Sjfb8856606  * on the last iteration (i.e. when no more matching port is found).
210d30ea906Sjfb8856606  *
211d30ea906Sjfb8856606  * It is safe to call this function twice; it will do nothing more.
212d30ea906Sjfb8856606  *
213d30ea906Sjfb8856606  * @param iter
214d30ea906Sjfb8856606  *   Device iterator handle initialized by rte_eth_iterator_init().
215d30ea906Sjfb8856606  *   The fields bus_str and cls_str are freed if needed.
216d30ea906Sjfb8856606  */
217d30ea906Sjfb8856606 void rte_eth_iterator_cleanup(struct rte_dev_iterator *iter);
218d30ea906Sjfb8856606 
219d30ea906Sjfb8856606 /**
220d30ea906Sjfb8856606  * Macro to iterate over all ethdev ports matching some devargs.
221d30ea906Sjfb8856606  *
222d30ea906Sjfb8856606  * If a break is done before the end of the loop,
223d30ea906Sjfb8856606  * the function rte_eth_iterator_cleanup() must be called.
224d30ea906Sjfb8856606  *
225d30ea906Sjfb8856606  * @param id
226d30ea906Sjfb8856606  *   Iterated port id of type uint16_t.
227d30ea906Sjfb8856606  * @param devargs
228d30ea906Sjfb8856606  *   Device parameters input as string of type char*.
229d30ea906Sjfb8856606  * @param iter
230d30ea906Sjfb8856606  *   Iterator handle of type struct rte_dev_iterator, used internally.
231d30ea906Sjfb8856606  */
232d30ea906Sjfb8856606 #define RTE_ETH_FOREACH_MATCHING_DEV(id, devargs, iter) \
233d30ea906Sjfb8856606 	for (rte_eth_iterator_init(iter, devargs), \
234d30ea906Sjfb8856606 	     id = rte_eth_iterator_next(iter); \
235d30ea906Sjfb8856606 	     id != RTE_MAX_ETHPORTS; \
236d30ea906Sjfb8856606 	     id = rte_eth_iterator_next(iter))
237d30ea906Sjfb8856606 
238d30ea906Sjfb8856606 /**
239d30ea906Sjfb8856606  * A structure used to retrieve statistics for an Ethernet port.
240d30ea906Sjfb8856606  * Not all statistics fields in struct rte_eth_stats are supported
241d30ea906Sjfb8856606  * by any type of network interface card (NIC). If any statistics
242d30ea906Sjfb8856606  * field is not supported, its value is 0.
243d30ea906Sjfb8856606  */
244d30ea906Sjfb8856606 struct rte_eth_stats {
245d30ea906Sjfb8856606 	uint64_t ipackets;  /**< Total number of successfully received packets. */
246d30ea906Sjfb8856606 	uint64_t opackets;  /**< Total number of successfully transmitted packets.*/
247d30ea906Sjfb8856606 	uint64_t ibytes;    /**< Total number of successfully received bytes. */
248d30ea906Sjfb8856606 	uint64_t obytes;    /**< Total number of successfully transmitted bytes. */
249d30ea906Sjfb8856606 	uint64_t imissed;
250d30ea906Sjfb8856606 	/**< Total of RX packets dropped by the HW,
251d30ea906Sjfb8856606 	 * because there are no available buffer (i.e. RX queues are full).
252d30ea906Sjfb8856606 	 */
253d30ea906Sjfb8856606 	uint64_t ierrors;   /**< Total number of erroneous received packets. */
254d30ea906Sjfb8856606 	uint64_t oerrors;   /**< Total number of failed transmitted packets. */
255d30ea906Sjfb8856606 	uint64_t rx_nombuf; /**< Total number of RX mbuf allocation failures. */
256*2d9fd380Sjfb8856606 	/* Queue stats are limited to max 256 queues */
257d30ea906Sjfb8856606 	uint64_t q_ipackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
258d30ea906Sjfb8856606 	/**< Total number of queue RX packets. */
259d30ea906Sjfb8856606 	uint64_t q_opackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
260d30ea906Sjfb8856606 	/**< Total number of queue TX packets. */
261d30ea906Sjfb8856606 	uint64_t q_ibytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
262d30ea906Sjfb8856606 	/**< Total number of successfully received queue bytes. */
263d30ea906Sjfb8856606 	uint64_t q_obytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
264d30ea906Sjfb8856606 	/**< Total number of successfully transmitted queue bytes. */
265d30ea906Sjfb8856606 	uint64_t q_errors[RTE_ETHDEV_QUEUE_STAT_CNTRS];
266d30ea906Sjfb8856606 	/**< Total number of queue packets received that are dropped. */
267d30ea906Sjfb8856606 };
268d30ea906Sjfb8856606 
269d30ea906Sjfb8856606 /**
270d30ea906Sjfb8856606  * Device supported speeds bitmap flags
271d30ea906Sjfb8856606  */
272d30ea906Sjfb8856606 #define ETH_LINK_SPEED_AUTONEG  (0 <<  0)  /**< Autonegotiate (all speeds) */
273d30ea906Sjfb8856606 #define ETH_LINK_SPEED_FIXED    (1 <<  0)  /**< Disable autoneg (fixed speed) */
274d30ea906Sjfb8856606 #define ETH_LINK_SPEED_10M_HD   (1 <<  1)  /**<  10 Mbps half-duplex */
275d30ea906Sjfb8856606 #define ETH_LINK_SPEED_10M      (1 <<  2)  /**<  10 Mbps full-duplex */
276d30ea906Sjfb8856606 #define ETH_LINK_SPEED_100M_HD  (1 <<  3)  /**< 100 Mbps half-duplex */
277d30ea906Sjfb8856606 #define ETH_LINK_SPEED_100M     (1 <<  4)  /**< 100 Mbps full-duplex */
278d30ea906Sjfb8856606 #define ETH_LINK_SPEED_1G       (1 <<  5)  /**<   1 Gbps */
279d30ea906Sjfb8856606 #define ETH_LINK_SPEED_2_5G     (1 <<  6)  /**< 2.5 Gbps */
280d30ea906Sjfb8856606 #define ETH_LINK_SPEED_5G       (1 <<  7)  /**<   5 Gbps */
281d30ea906Sjfb8856606 #define ETH_LINK_SPEED_10G      (1 <<  8)  /**<  10 Gbps */
282d30ea906Sjfb8856606 #define ETH_LINK_SPEED_20G      (1 <<  9)  /**<  20 Gbps */
283d30ea906Sjfb8856606 #define ETH_LINK_SPEED_25G      (1 << 10)  /**<  25 Gbps */
284d30ea906Sjfb8856606 #define ETH_LINK_SPEED_40G      (1 << 11)  /**<  40 Gbps */
285d30ea906Sjfb8856606 #define ETH_LINK_SPEED_50G      (1 << 12)  /**<  50 Gbps */
286d30ea906Sjfb8856606 #define ETH_LINK_SPEED_56G      (1 << 13)  /**<  56 Gbps */
287d30ea906Sjfb8856606 #define ETH_LINK_SPEED_100G     (1 << 14)  /**< 100 Gbps */
288*2d9fd380Sjfb8856606 #define ETH_LINK_SPEED_200G     (1 << 15)  /**< 200 Gbps */
289d30ea906Sjfb8856606 
290d30ea906Sjfb8856606 /**
291d30ea906Sjfb8856606  * Ethernet numeric link speeds in Mbps
292d30ea906Sjfb8856606  */
293d30ea906Sjfb8856606 #define ETH_SPEED_NUM_NONE         0 /**< Not defined */
294d30ea906Sjfb8856606 #define ETH_SPEED_NUM_10M         10 /**<  10 Mbps */
295d30ea906Sjfb8856606 #define ETH_SPEED_NUM_100M       100 /**< 100 Mbps */
296d30ea906Sjfb8856606 #define ETH_SPEED_NUM_1G        1000 /**<   1 Gbps */
297d30ea906Sjfb8856606 #define ETH_SPEED_NUM_2_5G      2500 /**< 2.5 Gbps */
298d30ea906Sjfb8856606 #define ETH_SPEED_NUM_5G        5000 /**<   5 Gbps */
299d30ea906Sjfb8856606 #define ETH_SPEED_NUM_10G      10000 /**<  10 Gbps */
300d30ea906Sjfb8856606 #define ETH_SPEED_NUM_20G      20000 /**<  20 Gbps */
301d30ea906Sjfb8856606 #define ETH_SPEED_NUM_25G      25000 /**<  25 Gbps */
302d30ea906Sjfb8856606 #define ETH_SPEED_NUM_40G      40000 /**<  40 Gbps */
303d30ea906Sjfb8856606 #define ETH_SPEED_NUM_50G      50000 /**<  50 Gbps */
304d30ea906Sjfb8856606 #define ETH_SPEED_NUM_56G      56000 /**<  56 Gbps */
305d30ea906Sjfb8856606 #define ETH_SPEED_NUM_100G    100000 /**< 100 Gbps */
306*2d9fd380Sjfb8856606 #define ETH_SPEED_NUM_200G    200000 /**< 200 Gbps */
307*2d9fd380Sjfb8856606 #define ETH_SPEED_NUM_UNKNOWN UINT32_MAX /**< Unknown */
308d30ea906Sjfb8856606 
309d30ea906Sjfb8856606 /**
310d30ea906Sjfb8856606  * A structure used to retrieve link-level information of an Ethernet port.
311d30ea906Sjfb8856606  */
312d30ea906Sjfb8856606 __extension__
313d30ea906Sjfb8856606 struct rte_eth_link {
314d30ea906Sjfb8856606 	uint32_t link_speed;        /**< ETH_SPEED_NUM_ */
315d30ea906Sjfb8856606 	uint16_t link_duplex  : 1;  /**< ETH_LINK_[HALF/FULL]_DUPLEX */
316d30ea906Sjfb8856606 	uint16_t link_autoneg : 1;  /**< ETH_LINK_[AUTONEG/FIXED] */
317d30ea906Sjfb8856606 	uint16_t link_status  : 1;  /**< ETH_LINK_[DOWN/UP] */
318*2d9fd380Sjfb8856606 } __rte_aligned(8);      /**< aligned for atomic64 read/write */
319d30ea906Sjfb8856606 
320d30ea906Sjfb8856606 /* Utility constants */
321d30ea906Sjfb8856606 #define ETH_LINK_HALF_DUPLEX 0 /**< Half-duplex connection (see link_duplex). */
322d30ea906Sjfb8856606 #define ETH_LINK_FULL_DUPLEX 1 /**< Full-duplex connection (see link_duplex). */
323d30ea906Sjfb8856606 #define ETH_LINK_DOWN        0 /**< Link is down (see link_status). */
324d30ea906Sjfb8856606 #define ETH_LINK_UP          1 /**< Link is up (see link_status). */
325d30ea906Sjfb8856606 #define ETH_LINK_FIXED       0 /**< No autonegotiation (see link_autoneg). */
326d30ea906Sjfb8856606 #define ETH_LINK_AUTONEG     1 /**< Autonegotiated (see link_autoneg). */
327*2d9fd380Sjfb8856606 #define RTE_ETH_LINK_MAX_STR_LEN 40 /**< Max length of default link string. */
328d30ea906Sjfb8856606 
329d30ea906Sjfb8856606 /**
330d30ea906Sjfb8856606  * A structure used to configure the ring threshold registers of an RX/TX
331d30ea906Sjfb8856606  * queue for an Ethernet port.
332d30ea906Sjfb8856606  */
333d30ea906Sjfb8856606 struct rte_eth_thresh {
334d30ea906Sjfb8856606 	uint8_t pthresh; /**< Ring prefetch threshold. */
335d30ea906Sjfb8856606 	uint8_t hthresh; /**< Ring host threshold. */
336d30ea906Sjfb8856606 	uint8_t wthresh; /**< Ring writeback threshold. */
337d30ea906Sjfb8856606 };
338d30ea906Sjfb8856606 
339d30ea906Sjfb8856606 /**
340d30ea906Sjfb8856606  *  Simple flags are used for rte_eth_conf.rxmode.mq_mode.
341d30ea906Sjfb8856606  */
342d30ea906Sjfb8856606 #define ETH_MQ_RX_RSS_FLAG  0x1
343d30ea906Sjfb8856606 #define ETH_MQ_RX_DCB_FLAG  0x2
344d30ea906Sjfb8856606 #define ETH_MQ_RX_VMDQ_FLAG 0x4
345d30ea906Sjfb8856606 
346d30ea906Sjfb8856606 /**
347d30ea906Sjfb8856606  *  A set of values to identify what method is to be used to route
348d30ea906Sjfb8856606  *  packets to multiple queues.
349d30ea906Sjfb8856606  */
350d30ea906Sjfb8856606 enum rte_eth_rx_mq_mode {
351d30ea906Sjfb8856606 	/** None of DCB,RSS or VMDQ mode */
352d30ea906Sjfb8856606 	ETH_MQ_RX_NONE = 0,
353d30ea906Sjfb8856606 
354d30ea906Sjfb8856606 	/** For RX side, only RSS is on */
355d30ea906Sjfb8856606 	ETH_MQ_RX_RSS = ETH_MQ_RX_RSS_FLAG,
356d30ea906Sjfb8856606 	/** For RX side,only DCB is on. */
357d30ea906Sjfb8856606 	ETH_MQ_RX_DCB = ETH_MQ_RX_DCB_FLAG,
358d30ea906Sjfb8856606 	/** Both DCB and RSS enable */
359d30ea906Sjfb8856606 	ETH_MQ_RX_DCB_RSS = ETH_MQ_RX_RSS_FLAG | ETH_MQ_RX_DCB_FLAG,
360d30ea906Sjfb8856606 
361d30ea906Sjfb8856606 	/** Only VMDQ, no RSS nor DCB */
362d30ea906Sjfb8856606 	ETH_MQ_RX_VMDQ_ONLY = ETH_MQ_RX_VMDQ_FLAG,
363d30ea906Sjfb8856606 	/** RSS mode with VMDQ */
364d30ea906Sjfb8856606 	ETH_MQ_RX_VMDQ_RSS = ETH_MQ_RX_RSS_FLAG | ETH_MQ_RX_VMDQ_FLAG,
365d30ea906Sjfb8856606 	/** Use VMDQ+DCB to route traffic to queues */
366d30ea906Sjfb8856606 	ETH_MQ_RX_VMDQ_DCB = ETH_MQ_RX_VMDQ_FLAG | ETH_MQ_RX_DCB_FLAG,
367d30ea906Sjfb8856606 	/** Enable both VMDQ and DCB in VMDq */
368d30ea906Sjfb8856606 	ETH_MQ_RX_VMDQ_DCB_RSS = ETH_MQ_RX_RSS_FLAG | ETH_MQ_RX_DCB_FLAG |
369d30ea906Sjfb8856606 				 ETH_MQ_RX_VMDQ_FLAG,
370d30ea906Sjfb8856606 };
371d30ea906Sjfb8856606 
372d30ea906Sjfb8856606 /**
373d30ea906Sjfb8856606  * for rx mq mode backward compatible
374d30ea906Sjfb8856606  */
375d30ea906Sjfb8856606 #define ETH_RSS                       ETH_MQ_RX_RSS
376d30ea906Sjfb8856606 #define VMDQ_DCB                      ETH_MQ_RX_VMDQ_DCB
377d30ea906Sjfb8856606 #define ETH_DCB_RX                    ETH_MQ_RX_DCB
378d30ea906Sjfb8856606 
379d30ea906Sjfb8856606 /**
380d30ea906Sjfb8856606  * A set of values to identify what method is to be used to transmit
381d30ea906Sjfb8856606  * packets using multi-TCs.
382d30ea906Sjfb8856606  */
383d30ea906Sjfb8856606 enum rte_eth_tx_mq_mode {
384d30ea906Sjfb8856606 	ETH_MQ_TX_NONE    = 0,  /**< It is in neither DCB nor VT mode. */
385d30ea906Sjfb8856606 	ETH_MQ_TX_DCB,          /**< For TX side,only DCB is on. */
386d30ea906Sjfb8856606 	ETH_MQ_TX_VMDQ_DCB,	/**< For TX side,both DCB and VT is on. */
387d30ea906Sjfb8856606 	ETH_MQ_TX_VMDQ_ONLY,    /**< Only VT on, no DCB */
388d30ea906Sjfb8856606 };
389d30ea906Sjfb8856606 
390d30ea906Sjfb8856606 /**
391d30ea906Sjfb8856606  * for tx mq mode backward compatible
392d30ea906Sjfb8856606  */
393d30ea906Sjfb8856606 #define ETH_DCB_NONE                ETH_MQ_TX_NONE
394d30ea906Sjfb8856606 #define ETH_VMDQ_DCB_TX             ETH_MQ_TX_VMDQ_DCB
395d30ea906Sjfb8856606 #define ETH_DCB_TX                  ETH_MQ_TX_DCB
396d30ea906Sjfb8856606 
397d30ea906Sjfb8856606 /**
398d30ea906Sjfb8856606  * A structure used to configure the RX features of an Ethernet port.
399d30ea906Sjfb8856606  */
400d30ea906Sjfb8856606 struct rte_eth_rxmode {
401d30ea906Sjfb8856606 	/** The multi-queue packet distribution mode to be used, e.g. RSS. */
402d30ea906Sjfb8856606 	enum rte_eth_rx_mq_mode mq_mode;
403d30ea906Sjfb8856606 	uint32_t max_rx_pkt_len;  /**< Only used if JUMBO_FRAME enabled. */
4044418919fSjohnjiang 	/** Maximum allowed size of LRO aggregated packet. */
4054418919fSjohnjiang 	uint32_t max_lro_pkt_size;
406d30ea906Sjfb8856606 	uint16_t split_hdr_size;  /**< hdr buf size (header_split enabled).*/
407d30ea906Sjfb8856606 	/**
408d30ea906Sjfb8856606 	 * Per-port Rx offloads to be set using DEV_RX_OFFLOAD_* flags.
409d30ea906Sjfb8856606 	 * Only offloads set on rx_offload_capa field on rte_eth_dev_info
410d30ea906Sjfb8856606 	 * structure are allowed to be set.
411d30ea906Sjfb8856606 	 */
412d30ea906Sjfb8856606 	uint64_t offloads;
4134418919fSjohnjiang 
4144418919fSjohnjiang 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
4154418919fSjohnjiang 	void *reserved_ptrs[2];   /**< Reserved for future fields */
416d30ea906Sjfb8856606 };
417d30ea906Sjfb8856606 
418d30ea906Sjfb8856606 /**
419d30ea906Sjfb8856606  * VLAN types to indicate if it is for single VLAN, inner VLAN or outer VLAN.
420d30ea906Sjfb8856606  * Note that single VLAN is treated the same as inner VLAN.
421d30ea906Sjfb8856606  */
422d30ea906Sjfb8856606 enum rte_vlan_type {
423d30ea906Sjfb8856606 	ETH_VLAN_TYPE_UNKNOWN = 0,
424d30ea906Sjfb8856606 	ETH_VLAN_TYPE_INNER, /**< Inner VLAN. */
425d30ea906Sjfb8856606 	ETH_VLAN_TYPE_OUTER, /**< Single VLAN, or outer VLAN. */
426d30ea906Sjfb8856606 	ETH_VLAN_TYPE_MAX,
427d30ea906Sjfb8856606 };
428d30ea906Sjfb8856606 
429d30ea906Sjfb8856606 /**
430d30ea906Sjfb8856606  * A structure used to describe a vlan filter.
431d30ea906Sjfb8856606  * If the bit corresponding to a VID is set, such VID is on.
432d30ea906Sjfb8856606  */
433d30ea906Sjfb8856606 struct rte_vlan_filter_conf {
434d30ea906Sjfb8856606 	uint64_t ids[64];
435d30ea906Sjfb8856606 };
436d30ea906Sjfb8856606 
437d30ea906Sjfb8856606 /**
438d30ea906Sjfb8856606  * A structure used to configure the Receive Side Scaling (RSS) feature
439d30ea906Sjfb8856606  * of an Ethernet port.
440d30ea906Sjfb8856606  * If not NULL, the *rss_key* pointer of the *rss_conf* structure points
441d30ea906Sjfb8856606  * to an array holding the RSS key to use for hashing specific header
442d30ea906Sjfb8856606  * fields of received packets. The length of this array should be indicated
443d30ea906Sjfb8856606  * by *rss_key_len* below. Otherwise, a default random hash key is used by
444d30ea906Sjfb8856606  * the device driver.
445d30ea906Sjfb8856606  *
446d30ea906Sjfb8856606  * The *rss_key_len* field of the *rss_conf* structure indicates the length
447d30ea906Sjfb8856606  * in bytes of the array pointed by *rss_key*. To be compatible, this length
448d30ea906Sjfb8856606  * will be checked in i40e only. Others assume 40 bytes to be used as before.
449d30ea906Sjfb8856606  *
450d30ea906Sjfb8856606  * The *rss_hf* field of the *rss_conf* structure indicates the different
451d30ea906Sjfb8856606  * types of IPv4/IPv6 packets to which the RSS hashing must be applied.
452d30ea906Sjfb8856606  * Supplying an *rss_hf* equal to zero disables the RSS feature.
453d30ea906Sjfb8856606  */
454d30ea906Sjfb8856606 struct rte_eth_rss_conf {
455d30ea906Sjfb8856606 	uint8_t *rss_key;    /**< If not NULL, 40-byte hash key. */
456d30ea906Sjfb8856606 	uint8_t rss_key_len; /**< hash key length in bytes. */
457d30ea906Sjfb8856606 	uint64_t rss_hf;     /**< Hash functions to apply - see below. */
458d30ea906Sjfb8856606 };
459d30ea906Sjfb8856606 
460d30ea906Sjfb8856606 /*
4614418919fSjohnjiang  * A packet can be identified by hardware as different flow types. Different
4624418919fSjohnjiang  * NIC hardware may support different flow types.
4634418919fSjohnjiang  * Basically, the NIC hardware identifies the flow type as deep protocol as
4644418919fSjohnjiang  * possible, and exclusively. For example, if a packet is identified as
4654418919fSjohnjiang  * 'RTE_ETH_FLOW_NONFRAG_IPV4_TCP', it will not be any of other flow types,
4664418919fSjohnjiang  * though it is an actual IPV4 packet.
467d30ea906Sjfb8856606  */
4684418919fSjohnjiang #define RTE_ETH_FLOW_UNKNOWN             0
4694418919fSjohnjiang #define RTE_ETH_FLOW_RAW                 1
4704418919fSjohnjiang #define RTE_ETH_FLOW_IPV4                2
4714418919fSjohnjiang #define RTE_ETH_FLOW_FRAG_IPV4           3
4724418919fSjohnjiang #define RTE_ETH_FLOW_NONFRAG_IPV4_TCP    4
4734418919fSjohnjiang #define RTE_ETH_FLOW_NONFRAG_IPV4_UDP    5
4744418919fSjohnjiang #define RTE_ETH_FLOW_NONFRAG_IPV4_SCTP   6
4754418919fSjohnjiang #define RTE_ETH_FLOW_NONFRAG_IPV4_OTHER  7
4764418919fSjohnjiang #define RTE_ETH_FLOW_IPV6                8
4774418919fSjohnjiang #define RTE_ETH_FLOW_FRAG_IPV6           9
4784418919fSjohnjiang #define RTE_ETH_FLOW_NONFRAG_IPV6_TCP   10
4794418919fSjohnjiang #define RTE_ETH_FLOW_NONFRAG_IPV6_UDP   11
4804418919fSjohnjiang #define RTE_ETH_FLOW_NONFRAG_IPV6_SCTP  12
4814418919fSjohnjiang #define RTE_ETH_FLOW_NONFRAG_IPV6_OTHER 13
4824418919fSjohnjiang #define RTE_ETH_FLOW_L2_PAYLOAD         14
4834418919fSjohnjiang #define RTE_ETH_FLOW_IPV6_EX            15
4844418919fSjohnjiang #define RTE_ETH_FLOW_IPV6_TCP_EX        16
4854418919fSjohnjiang #define RTE_ETH_FLOW_IPV6_UDP_EX        17
4864418919fSjohnjiang #define RTE_ETH_FLOW_PORT               18
4874418919fSjohnjiang 	/**< Consider device port number as a flow differentiator */
4884418919fSjohnjiang #define RTE_ETH_FLOW_VXLAN              19 /**< VXLAN protocol based flow */
4894418919fSjohnjiang #define RTE_ETH_FLOW_GENEVE             20 /**< GENEVE protocol based flow */
4904418919fSjohnjiang #define RTE_ETH_FLOW_NVGRE              21 /**< NVGRE protocol based flow */
4914418919fSjohnjiang #define RTE_ETH_FLOW_VXLAN_GPE          22 /**< VXLAN-GPE protocol based flow */
4924418919fSjohnjiang #define RTE_ETH_FLOW_GTPU               23 /**< GTPU protocol based flow */
4934418919fSjohnjiang #define RTE_ETH_FLOW_MAX                24
4944418919fSjohnjiang 
4954418919fSjohnjiang /*
4964418919fSjohnjiang  * Below macros are defined for RSS offload types, they can be used to
4974418919fSjohnjiang  * fill rte_eth_rss_conf.rss_hf or rte_flow_action_rss.types.
4984418919fSjohnjiang  */
4994418919fSjohnjiang #define ETH_RSS_IPV4               (1ULL << 2)
5004418919fSjohnjiang #define ETH_RSS_FRAG_IPV4          (1ULL << 3)
5014418919fSjohnjiang #define ETH_RSS_NONFRAG_IPV4_TCP   (1ULL << 4)
5024418919fSjohnjiang #define ETH_RSS_NONFRAG_IPV4_UDP   (1ULL << 5)
5034418919fSjohnjiang #define ETH_RSS_NONFRAG_IPV4_SCTP  (1ULL << 6)
5044418919fSjohnjiang #define ETH_RSS_NONFRAG_IPV4_OTHER (1ULL << 7)
5054418919fSjohnjiang #define ETH_RSS_IPV6               (1ULL << 8)
5064418919fSjohnjiang #define ETH_RSS_FRAG_IPV6          (1ULL << 9)
5074418919fSjohnjiang #define ETH_RSS_NONFRAG_IPV6_TCP   (1ULL << 10)
5084418919fSjohnjiang #define ETH_RSS_NONFRAG_IPV6_UDP   (1ULL << 11)
5094418919fSjohnjiang #define ETH_RSS_NONFRAG_IPV6_SCTP  (1ULL << 12)
5104418919fSjohnjiang #define ETH_RSS_NONFRAG_IPV6_OTHER (1ULL << 13)
5114418919fSjohnjiang #define ETH_RSS_L2_PAYLOAD         (1ULL << 14)
5124418919fSjohnjiang #define ETH_RSS_IPV6_EX            (1ULL << 15)
5134418919fSjohnjiang #define ETH_RSS_IPV6_TCP_EX        (1ULL << 16)
5144418919fSjohnjiang #define ETH_RSS_IPV6_UDP_EX        (1ULL << 17)
5154418919fSjohnjiang #define ETH_RSS_PORT               (1ULL << 18)
5164418919fSjohnjiang #define ETH_RSS_VXLAN              (1ULL << 19)
5174418919fSjohnjiang #define ETH_RSS_GENEVE             (1ULL << 20)
5184418919fSjohnjiang #define ETH_RSS_NVGRE              (1ULL << 21)
5194418919fSjohnjiang #define ETH_RSS_GTPU               (1ULL << 23)
520*2d9fd380Sjfb8856606 #define ETH_RSS_ETH                (1ULL << 24)
521*2d9fd380Sjfb8856606 #define ETH_RSS_S_VLAN             (1ULL << 25)
522*2d9fd380Sjfb8856606 #define ETH_RSS_C_VLAN             (1ULL << 26)
523*2d9fd380Sjfb8856606 #define ETH_RSS_ESP                (1ULL << 27)
524*2d9fd380Sjfb8856606 #define ETH_RSS_AH                 (1ULL << 28)
525*2d9fd380Sjfb8856606 #define ETH_RSS_L2TPV3             (1ULL << 29)
526*2d9fd380Sjfb8856606 #define ETH_RSS_PFCP               (1ULL << 30)
527*2d9fd380Sjfb8856606 #define ETH_RSS_PPPOE		   (1ULL << 31)
528*2d9fd380Sjfb8856606 #define ETH_RSS_ECPRI		   (1ULL << 32)
5294418919fSjohnjiang 
5304418919fSjohnjiang /*
5314418919fSjohnjiang  * We use the following macros to combine with above ETH_RSS_* for
5324418919fSjohnjiang  * more specific input set selection. These bits are defined starting
5334418919fSjohnjiang  * from the high end of the 64 bits.
5344418919fSjohnjiang  * Note: If we use above ETH_RSS_* without SRC/DST_ONLY, it represents
5354418919fSjohnjiang  * both SRC and DST are taken into account. If SRC_ONLY and DST_ONLY of
5364418919fSjohnjiang  * the same level are used simultaneously, it is the same case as none of
5374418919fSjohnjiang  * them are added.
5384418919fSjohnjiang  */
5394418919fSjohnjiang #define ETH_RSS_L3_SRC_ONLY        (1ULL << 63)
5404418919fSjohnjiang #define ETH_RSS_L3_DST_ONLY        (1ULL << 62)
5414418919fSjohnjiang #define ETH_RSS_L4_SRC_ONLY        (1ULL << 61)
5424418919fSjohnjiang #define ETH_RSS_L4_DST_ONLY        (1ULL << 60)
543*2d9fd380Sjfb8856606 #define ETH_RSS_L2_SRC_ONLY        (1ULL << 59)
544*2d9fd380Sjfb8856606 #define ETH_RSS_L2_DST_ONLY        (1ULL << 58)
545*2d9fd380Sjfb8856606 
546*2d9fd380Sjfb8856606 /*
547*2d9fd380Sjfb8856606  * Only select IPV6 address prefix as RSS input set according to
548*2d9fd380Sjfb8856606  * https://tools.ietf.org/html/rfc6052
549*2d9fd380Sjfb8856606  * Must be combined with ETH_RSS_IPV6, ETH_RSS_NONFRAG_IPV6_UDP,
550*2d9fd380Sjfb8856606  * ETH_RSS_NONFRAG_IPV6_TCP, ETH_RSS_NONFRAG_IPV6_SCTP.
551*2d9fd380Sjfb8856606  */
552*2d9fd380Sjfb8856606 #define RTE_ETH_RSS_L3_PRE32	   (1ULL << 57)
553*2d9fd380Sjfb8856606 #define RTE_ETH_RSS_L3_PRE40	   (1ULL << 56)
554*2d9fd380Sjfb8856606 #define RTE_ETH_RSS_L3_PRE48	   (1ULL << 55)
555*2d9fd380Sjfb8856606 #define RTE_ETH_RSS_L3_PRE56	   (1ULL << 54)
556*2d9fd380Sjfb8856606 #define RTE_ETH_RSS_L3_PRE64	   (1ULL << 53)
557*2d9fd380Sjfb8856606 #define RTE_ETH_RSS_L3_PRE96	   (1ULL << 52)
558*2d9fd380Sjfb8856606 
559*2d9fd380Sjfb8856606 /*
560*2d9fd380Sjfb8856606  * Use the following macros to combine with the above layers
561*2d9fd380Sjfb8856606  * to choose inner and outer layers or both for RSS computation.
562*2d9fd380Sjfb8856606  * Bits 50 and 51 are reserved for this.
563*2d9fd380Sjfb8856606  */
564*2d9fd380Sjfb8856606 
565*2d9fd380Sjfb8856606 /**
566*2d9fd380Sjfb8856606  * level 0, requests the default behavior.
567*2d9fd380Sjfb8856606  * Depending on the packet type, it can mean outermost, innermost,
568*2d9fd380Sjfb8856606  * anything in between or even no RSS.
569*2d9fd380Sjfb8856606  * It basically stands for the innermost encapsulation level RSS
570*2d9fd380Sjfb8856606  * can be performed on according to PMD and device capabilities.
571*2d9fd380Sjfb8856606  */
572*2d9fd380Sjfb8856606 #define ETH_RSS_LEVEL_PMD_DEFAULT       (0ULL << 50)
573*2d9fd380Sjfb8856606 
574*2d9fd380Sjfb8856606 /**
575*2d9fd380Sjfb8856606  * level 1, requests RSS to be performed on the outermost packet
576*2d9fd380Sjfb8856606  * encapsulation level.
577*2d9fd380Sjfb8856606  */
578*2d9fd380Sjfb8856606 #define ETH_RSS_LEVEL_OUTERMOST         (1ULL << 50)
579*2d9fd380Sjfb8856606 
580*2d9fd380Sjfb8856606 /**
581*2d9fd380Sjfb8856606  * level 2, requests RSS to be performed on the specified inner packet
582*2d9fd380Sjfb8856606  * encapsulation level, from outermost to innermost (lower to higher values).
583*2d9fd380Sjfb8856606  */
584*2d9fd380Sjfb8856606 #define ETH_RSS_LEVEL_INNERMOST         (2ULL << 50)
585*2d9fd380Sjfb8856606 #define ETH_RSS_LEVEL_MASK              (3ULL << 50)
586*2d9fd380Sjfb8856606 
587*2d9fd380Sjfb8856606 #define ETH_RSS_LEVEL(rss_hf) ((rss_hf & ETH_RSS_LEVEL_MASK) >> 50)
5884418919fSjohnjiang 
5894418919fSjohnjiang /**
5904418919fSjohnjiang  * For input set change of hash filter, if SRC_ONLY and DST_ONLY of
5914418919fSjohnjiang  * the same level are used simultaneously, it is the same case as
5924418919fSjohnjiang  * none of them are added.
5934418919fSjohnjiang  *
5944418919fSjohnjiang  * @param rss_hf
5954418919fSjohnjiang  *   RSS types with SRC/DST_ONLY.
5964418919fSjohnjiang  * @return
5974418919fSjohnjiang  *   RSS types.
5984418919fSjohnjiang  */
5994418919fSjohnjiang static inline uint64_t
rte_eth_rss_hf_refine(uint64_t rss_hf)6004418919fSjohnjiang rte_eth_rss_hf_refine(uint64_t rss_hf)
6014418919fSjohnjiang {
6024418919fSjohnjiang 	if ((rss_hf & ETH_RSS_L3_SRC_ONLY) && (rss_hf & ETH_RSS_L3_DST_ONLY))
6034418919fSjohnjiang 		rss_hf &= ~(ETH_RSS_L3_SRC_ONLY | ETH_RSS_L3_DST_ONLY);
6044418919fSjohnjiang 
6054418919fSjohnjiang 	if ((rss_hf & ETH_RSS_L4_SRC_ONLY) && (rss_hf & ETH_RSS_L4_DST_ONLY))
6064418919fSjohnjiang 		rss_hf &= ~(ETH_RSS_L4_SRC_ONLY | ETH_RSS_L4_DST_ONLY);
6074418919fSjohnjiang 
6084418919fSjohnjiang 	return rss_hf;
6094418919fSjohnjiang }
610d30ea906Sjfb8856606 
611*2d9fd380Sjfb8856606 #define ETH_RSS_IPV6_PRE32 ( \
612*2d9fd380Sjfb8856606 		ETH_RSS_IPV6 | \
613*2d9fd380Sjfb8856606 		RTE_ETH_RSS_L3_PRE32)
614*2d9fd380Sjfb8856606 
615*2d9fd380Sjfb8856606 #define ETH_RSS_IPV6_PRE40 ( \
616*2d9fd380Sjfb8856606 		ETH_RSS_IPV6 | \
617*2d9fd380Sjfb8856606 		RTE_ETH_RSS_L3_PRE40)
618*2d9fd380Sjfb8856606 
619*2d9fd380Sjfb8856606 #define ETH_RSS_IPV6_PRE48 ( \
620*2d9fd380Sjfb8856606 		ETH_RSS_IPV6 | \
621*2d9fd380Sjfb8856606 		RTE_ETH_RSS_L3_PRE48)
622*2d9fd380Sjfb8856606 
623*2d9fd380Sjfb8856606 #define ETH_RSS_IPV6_PRE56 ( \
624*2d9fd380Sjfb8856606 		ETH_RSS_IPV6 | \
625*2d9fd380Sjfb8856606 		RTE_ETH_RSS_L3_PRE56)
626*2d9fd380Sjfb8856606 
627*2d9fd380Sjfb8856606 #define ETH_RSS_IPV6_PRE64 ( \
628*2d9fd380Sjfb8856606 		ETH_RSS_IPV6 | \
629*2d9fd380Sjfb8856606 		RTE_ETH_RSS_L3_PRE64)
630*2d9fd380Sjfb8856606 
631*2d9fd380Sjfb8856606 #define ETH_RSS_IPV6_PRE96 ( \
632*2d9fd380Sjfb8856606 		ETH_RSS_IPV6 | \
633*2d9fd380Sjfb8856606 		RTE_ETH_RSS_L3_PRE96)
634*2d9fd380Sjfb8856606 
635*2d9fd380Sjfb8856606 #define ETH_RSS_IPV6_PRE32_UDP ( \
636*2d9fd380Sjfb8856606 		ETH_RSS_NONFRAG_IPV6_UDP | \
637*2d9fd380Sjfb8856606 		RTE_ETH_RSS_L3_PRE32)
638*2d9fd380Sjfb8856606 
639*2d9fd380Sjfb8856606 #define ETH_RSS_IPV6_PRE40_UDP ( \
640*2d9fd380Sjfb8856606 		ETH_RSS_NONFRAG_IPV6_UDP | \
641*2d9fd380Sjfb8856606 		RTE_ETH_RSS_L3_PRE40)
642*2d9fd380Sjfb8856606 
643*2d9fd380Sjfb8856606 #define ETH_RSS_IPV6_PRE48_UDP ( \
644*2d9fd380Sjfb8856606 		ETH_RSS_NONFRAG_IPV6_UDP | \
645*2d9fd380Sjfb8856606 		RTE_ETH_RSS_L3_PRE48)
646*2d9fd380Sjfb8856606 
647*2d9fd380Sjfb8856606 #define ETH_RSS_IPV6_PRE56_UDP ( \
648*2d9fd380Sjfb8856606 		ETH_RSS_NONFRAG_IPV6_UDP | \
649*2d9fd380Sjfb8856606 		RTE_ETH_RSS_L3_PRE56)
650*2d9fd380Sjfb8856606 
651*2d9fd380Sjfb8856606 #define ETH_RSS_IPV6_PRE64_UDP ( \
652*2d9fd380Sjfb8856606 		ETH_RSS_NONFRAG_IPV6_UDP | \
653*2d9fd380Sjfb8856606 		RTE_ETH_RSS_L3_PRE64)
654*2d9fd380Sjfb8856606 
655*2d9fd380Sjfb8856606 #define ETH_RSS_IPV6_PRE96_UDP ( \
656*2d9fd380Sjfb8856606 		ETH_RSS_NONFRAG_IPV6_UDP | \
657*2d9fd380Sjfb8856606 		RTE_ETH_RSS_L3_PRE96)
658*2d9fd380Sjfb8856606 
659*2d9fd380Sjfb8856606 #define ETH_RSS_IPV6_PRE32_TCP ( \
660*2d9fd380Sjfb8856606 		ETH_RSS_NONFRAG_IPV6_TCP | \
661*2d9fd380Sjfb8856606 		RTE_ETH_RSS_L3_PRE32)
662*2d9fd380Sjfb8856606 
663*2d9fd380Sjfb8856606 #define ETH_RSS_IPV6_PRE40_TCP ( \
664*2d9fd380Sjfb8856606 		ETH_RSS_NONFRAG_IPV6_TCP | \
665*2d9fd380Sjfb8856606 		RTE_ETH_RSS_L3_PRE40)
666*2d9fd380Sjfb8856606 
667*2d9fd380Sjfb8856606 #define ETH_RSS_IPV6_PRE48_TCP ( \
668*2d9fd380Sjfb8856606 		ETH_RSS_NONFRAG_IPV6_TCP | \
669*2d9fd380Sjfb8856606 		RTE_ETH_RSS_L3_PRE48)
670*2d9fd380Sjfb8856606 
671*2d9fd380Sjfb8856606 #define ETH_RSS_IPV6_PRE56_TCP ( \
672*2d9fd380Sjfb8856606 		ETH_RSS_NONFRAG_IPV6_TCP | \
673*2d9fd380Sjfb8856606 		RTE_ETH_RSS_L3_PRE56)
674*2d9fd380Sjfb8856606 
675*2d9fd380Sjfb8856606 #define ETH_RSS_IPV6_PRE64_TCP ( \
676*2d9fd380Sjfb8856606 		ETH_RSS_NONFRAG_IPV6_TCP | \
677*2d9fd380Sjfb8856606 		RTE_ETH_RSS_L3_PRE64)
678*2d9fd380Sjfb8856606 
679*2d9fd380Sjfb8856606 #define ETH_RSS_IPV6_PRE96_TCP ( \
680*2d9fd380Sjfb8856606 		ETH_RSS_NONFRAG_IPV6_TCP | \
681*2d9fd380Sjfb8856606 		RTE_ETH_RSS_L3_PRE96)
682*2d9fd380Sjfb8856606 
683*2d9fd380Sjfb8856606 #define ETH_RSS_IPV6_PRE32_SCTP ( \
684*2d9fd380Sjfb8856606 		ETH_RSS_NONFRAG_IPV6_SCTP | \
685*2d9fd380Sjfb8856606 		RTE_ETH_RSS_L3_PRE32)
686*2d9fd380Sjfb8856606 
687*2d9fd380Sjfb8856606 #define ETH_RSS_IPV6_PRE40_SCTP ( \
688*2d9fd380Sjfb8856606 		ETH_RSS_NONFRAG_IPV6_SCTP | \
689*2d9fd380Sjfb8856606 		RTE_ETH_RSS_L3_PRE40)
690*2d9fd380Sjfb8856606 
691*2d9fd380Sjfb8856606 #define ETH_RSS_IPV6_PRE48_SCTP ( \
692*2d9fd380Sjfb8856606 		ETH_RSS_NONFRAG_IPV6_SCTP | \
693*2d9fd380Sjfb8856606 		RTE_ETH_RSS_L3_PRE48)
694*2d9fd380Sjfb8856606 
695*2d9fd380Sjfb8856606 #define ETH_RSS_IPV6_PRE56_SCTP ( \
696*2d9fd380Sjfb8856606 		ETH_RSS_NONFRAG_IPV6_SCTP | \
697*2d9fd380Sjfb8856606 		RTE_ETH_RSS_L3_PRE56)
698*2d9fd380Sjfb8856606 
699*2d9fd380Sjfb8856606 #define ETH_RSS_IPV6_PRE64_SCTP ( \
700*2d9fd380Sjfb8856606 		ETH_RSS_NONFRAG_IPV6_SCTP | \
701*2d9fd380Sjfb8856606 		RTE_ETH_RSS_L3_PRE64)
702*2d9fd380Sjfb8856606 
703*2d9fd380Sjfb8856606 #define ETH_RSS_IPV6_PRE96_SCTP ( \
704*2d9fd380Sjfb8856606 		ETH_RSS_NONFRAG_IPV6_SCTP | \
705*2d9fd380Sjfb8856606 		RTE_ETH_RSS_L3_PRE96)
706*2d9fd380Sjfb8856606 
707d30ea906Sjfb8856606 #define ETH_RSS_IP ( \
708d30ea906Sjfb8856606 	ETH_RSS_IPV4 | \
709d30ea906Sjfb8856606 	ETH_RSS_FRAG_IPV4 | \
710d30ea906Sjfb8856606 	ETH_RSS_NONFRAG_IPV4_OTHER | \
711d30ea906Sjfb8856606 	ETH_RSS_IPV6 | \
712d30ea906Sjfb8856606 	ETH_RSS_FRAG_IPV6 | \
713d30ea906Sjfb8856606 	ETH_RSS_NONFRAG_IPV6_OTHER | \
714d30ea906Sjfb8856606 	ETH_RSS_IPV6_EX)
715d30ea906Sjfb8856606 
716d30ea906Sjfb8856606 #define ETH_RSS_UDP ( \
717d30ea906Sjfb8856606 	ETH_RSS_NONFRAG_IPV4_UDP | \
718d30ea906Sjfb8856606 	ETH_RSS_NONFRAG_IPV6_UDP | \
719d30ea906Sjfb8856606 	ETH_RSS_IPV6_UDP_EX)
720d30ea906Sjfb8856606 
721d30ea906Sjfb8856606 #define ETH_RSS_TCP ( \
722d30ea906Sjfb8856606 	ETH_RSS_NONFRAG_IPV4_TCP | \
723d30ea906Sjfb8856606 	ETH_RSS_NONFRAG_IPV6_TCP | \
724d30ea906Sjfb8856606 	ETH_RSS_IPV6_TCP_EX)
725d30ea906Sjfb8856606 
726d30ea906Sjfb8856606 #define ETH_RSS_SCTP ( \
727d30ea906Sjfb8856606 	ETH_RSS_NONFRAG_IPV4_SCTP | \
728d30ea906Sjfb8856606 	ETH_RSS_NONFRAG_IPV6_SCTP)
729d30ea906Sjfb8856606 
730d30ea906Sjfb8856606 #define ETH_RSS_TUNNEL ( \
731d30ea906Sjfb8856606 	ETH_RSS_VXLAN  | \
732d30ea906Sjfb8856606 	ETH_RSS_GENEVE | \
733d30ea906Sjfb8856606 	ETH_RSS_NVGRE)
734d30ea906Sjfb8856606 
735*2d9fd380Sjfb8856606 #define ETH_RSS_VLAN ( \
736*2d9fd380Sjfb8856606 	ETH_RSS_S_VLAN  | \
737*2d9fd380Sjfb8856606 	ETH_RSS_C_VLAN)
738*2d9fd380Sjfb8856606 
739d30ea906Sjfb8856606 /**< Mask of valid RSS hash protocols */
740d30ea906Sjfb8856606 #define ETH_RSS_PROTO_MASK ( \
741d30ea906Sjfb8856606 	ETH_RSS_IPV4 | \
742d30ea906Sjfb8856606 	ETH_RSS_FRAG_IPV4 | \
743d30ea906Sjfb8856606 	ETH_RSS_NONFRAG_IPV4_TCP | \
744d30ea906Sjfb8856606 	ETH_RSS_NONFRAG_IPV4_UDP | \
745d30ea906Sjfb8856606 	ETH_RSS_NONFRAG_IPV4_SCTP | \
746d30ea906Sjfb8856606 	ETH_RSS_NONFRAG_IPV4_OTHER | \
747d30ea906Sjfb8856606 	ETH_RSS_IPV6 | \
748d30ea906Sjfb8856606 	ETH_RSS_FRAG_IPV6 | \
749d30ea906Sjfb8856606 	ETH_RSS_NONFRAG_IPV6_TCP | \
750d30ea906Sjfb8856606 	ETH_RSS_NONFRAG_IPV6_UDP | \
751d30ea906Sjfb8856606 	ETH_RSS_NONFRAG_IPV6_SCTP | \
752d30ea906Sjfb8856606 	ETH_RSS_NONFRAG_IPV6_OTHER | \
753d30ea906Sjfb8856606 	ETH_RSS_L2_PAYLOAD | \
754d30ea906Sjfb8856606 	ETH_RSS_IPV6_EX | \
755d30ea906Sjfb8856606 	ETH_RSS_IPV6_TCP_EX | \
756d30ea906Sjfb8856606 	ETH_RSS_IPV6_UDP_EX | \
757d30ea906Sjfb8856606 	ETH_RSS_PORT  | \
758d30ea906Sjfb8856606 	ETH_RSS_VXLAN | \
759d30ea906Sjfb8856606 	ETH_RSS_GENEVE | \
760d30ea906Sjfb8856606 	ETH_RSS_NVGRE)
761d30ea906Sjfb8856606 
762d30ea906Sjfb8856606 /*
763d30ea906Sjfb8856606  * Definitions used for redirection table entry size.
764d30ea906Sjfb8856606  * Some RSS RETA sizes may not be supported by some drivers, check the
765d30ea906Sjfb8856606  * documentation or the description of relevant functions for more details.
766d30ea906Sjfb8856606  */
767d30ea906Sjfb8856606 #define ETH_RSS_RETA_SIZE_64  64
768d30ea906Sjfb8856606 #define ETH_RSS_RETA_SIZE_128 128
769d30ea906Sjfb8856606 #define ETH_RSS_RETA_SIZE_256 256
770d30ea906Sjfb8856606 #define ETH_RSS_RETA_SIZE_512 512
771d30ea906Sjfb8856606 #define RTE_RETA_GROUP_SIZE   64
772d30ea906Sjfb8856606 
773d30ea906Sjfb8856606 /* Definitions used for VMDQ and DCB functionality */
774d30ea906Sjfb8856606 #define ETH_VMDQ_MAX_VLAN_FILTERS   64 /**< Maximum nb. of VMDQ vlan filters. */
775d30ea906Sjfb8856606 #define ETH_DCB_NUM_USER_PRIORITIES 8  /**< Maximum nb. of DCB priorities. */
776d30ea906Sjfb8856606 #define ETH_VMDQ_DCB_NUM_QUEUES     128 /**< Maximum nb. of VMDQ DCB queues. */
777d30ea906Sjfb8856606 #define ETH_DCB_NUM_QUEUES          128 /**< Maximum nb. of DCB queues. */
778d30ea906Sjfb8856606 
779d30ea906Sjfb8856606 /* DCB capability defines */
780d30ea906Sjfb8856606 #define ETH_DCB_PG_SUPPORT      0x00000001 /**< Priority Group(ETS) support. */
781d30ea906Sjfb8856606 #define ETH_DCB_PFC_SUPPORT     0x00000002 /**< Priority Flow Control support. */
782d30ea906Sjfb8856606 
783d30ea906Sjfb8856606 /* Definitions used for VLAN Offload functionality */
784d30ea906Sjfb8856606 #define ETH_VLAN_STRIP_OFFLOAD   0x0001 /**< VLAN Strip  On/Off */
785d30ea906Sjfb8856606 #define ETH_VLAN_FILTER_OFFLOAD  0x0002 /**< VLAN Filter On/Off */
786d30ea906Sjfb8856606 #define ETH_VLAN_EXTEND_OFFLOAD  0x0004 /**< VLAN Extend On/Off */
7874418919fSjohnjiang #define ETH_QINQ_STRIP_OFFLOAD   0x0008 /**< QINQ Strip On/Off */
788d30ea906Sjfb8856606 
789d30ea906Sjfb8856606 /* Definitions used for mask VLAN setting */
790d30ea906Sjfb8856606 #define ETH_VLAN_STRIP_MASK   0x0001 /**< VLAN Strip  setting mask */
791d30ea906Sjfb8856606 #define ETH_VLAN_FILTER_MASK  0x0002 /**< VLAN Filter  setting mask*/
792d30ea906Sjfb8856606 #define ETH_VLAN_EXTEND_MASK  0x0004 /**< VLAN Extend  setting mask*/
7934418919fSjohnjiang #define ETH_QINQ_STRIP_MASK   0x0008 /**< QINQ Strip  setting mask */
794d30ea906Sjfb8856606 #define ETH_VLAN_ID_MAX       0x0FFF /**< VLAN ID is in lower 12 bits*/
795d30ea906Sjfb8856606 
796d30ea906Sjfb8856606 /* Definitions used for receive MAC address   */
797d30ea906Sjfb8856606 #define ETH_NUM_RECEIVE_MAC_ADDR  128 /**< Maximum nb. of receive mac addr. */
798d30ea906Sjfb8856606 
799d30ea906Sjfb8856606 /* Definitions used for unicast hash  */
800d30ea906Sjfb8856606 #define ETH_VMDQ_NUM_UC_HASH_ARRAY  128 /**< Maximum nb. of UC hash array. */
801d30ea906Sjfb8856606 
802d30ea906Sjfb8856606 /* Definitions used for VMDQ pool rx mode setting */
803d30ea906Sjfb8856606 #define ETH_VMDQ_ACCEPT_UNTAG   0x0001 /**< accept untagged packets. */
804d30ea906Sjfb8856606 #define ETH_VMDQ_ACCEPT_HASH_MC 0x0002 /**< accept packets in multicast table . */
805d30ea906Sjfb8856606 #define ETH_VMDQ_ACCEPT_HASH_UC 0x0004 /**< accept packets in unicast table. */
806d30ea906Sjfb8856606 #define ETH_VMDQ_ACCEPT_BROADCAST   0x0008 /**< accept broadcast packets. */
807d30ea906Sjfb8856606 #define ETH_VMDQ_ACCEPT_MULTICAST   0x0010 /**< multicast promiscuous. */
808d30ea906Sjfb8856606 
809d30ea906Sjfb8856606 /** Maximum nb. of vlan per mirror rule */
810d30ea906Sjfb8856606 #define ETH_MIRROR_MAX_VLANS       64
811d30ea906Sjfb8856606 
812d30ea906Sjfb8856606 #define ETH_MIRROR_VIRTUAL_POOL_UP     0x01  /**< Virtual Pool uplink Mirroring. */
813d30ea906Sjfb8856606 #define ETH_MIRROR_UPLINK_PORT         0x02  /**< Uplink Port Mirroring. */
814d30ea906Sjfb8856606 #define ETH_MIRROR_DOWNLINK_PORT       0x04  /**< Downlink Port Mirroring. */
815d30ea906Sjfb8856606 #define ETH_MIRROR_VLAN                0x08  /**< VLAN Mirroring. */
816d30ea906Sjfb8856606 #define ETH_MIRROR_VIRTUAL_POOL_DOWN   0x10  /**< Virtual Pool downlink Mirroring. */
817d30ea906Sjfb8856606 
818d30ea906Sjfb8856606 /**
819d30ea906Sjfb8856606  * A structure used to configure VLAN traffic mirror of an Ethernet port.
820d30ea906Sjfb8856606  */
821d30ea906Sjfb8856606 struct rte_eth_vlan_mirror {
822d30ea906Sjfb8856606 	uint64_t vlan_mask; /**< mask for valid VLAN ID. */
823d30ea906Sjfb8856606 	/** VLAN ID list for vlan mirroring. */
824d30ea906Sjfb8856606 	uint16_t vlan_id[ETH_MIRROR_MAX_VLANS];
825d30ea906Sjfb8856606 };
826d30ea906Sjfb8856606 
827d30ea906Sjfb8856606 /**
828d30ea906Sjfb8856606  * A structure used to configure traffic mirror of an Ethernet port.
829d30ea906Sjfb8856606  */
830d30ea906Sjfb8856606 struct rte_eth_mirror_conf {
831d30ea906Sjfb8856606 	uint8_t rule_type; /**< Mirroring rule type */
832d30ea906Sjfb8856606 	uint8_t dst_pool;  /**< Destination pool for this mirror rule. */
833d30ea906Sjfb8856606 	uint64_t pool_mask; /**< Bitmap of pool for pool mirroring */
834d30ea906Sjfb8856606 	/** VLAN ID setting for VLAN mirroring. */
835d30ea906Sjfb8856606 	struct rte_eth_vlan_mirror vlan;
836d30ea906Sjfb8856606 };
837d30ea906Sjfb8856606 
838d30ea906Sjfb8856606 /**
839d30ea906Sjfb8856606  * A structure used to configure 64 entries of Redirection Table of the
840d30ea906Sjfb8856606  * Receive Side Scaling (RSS) feature of an Ethernet port. To configure
841d30ea906Sjfb8856606  * more than 64 entries supported by hardware, an array of this structure
842d30ea906Sjfb8856606  * is needed.
843d30ea906Sjfb8856606  */
844d30ea906Sjfb8856606 struct rte_eth_rss_reta_entry64 {
845d30ea906Sjfb8856606 	uint64_t mask;
846d30ea906Sjfb8856606 	/**< Mask bits indicate which entries need to be updated/queried. */
847d30ea906Sjfb8856606 	uint16_t reta[RTE_RETA_GROUP_SIZE];
848d30ea906Sjfb8856606 	/**< Group of 64 redirection table entries. */
849d30ea906Sjfb8856606 };
850d30ea906Sjfb8856606 
851d30ea906Sjfb8856606 /**
852d30ea906Sjfb8856606  * This enum indicates the possible number of traffic classes
853d30ea906Sjfb8856606  * in DCB configurations
854d30ea906Sjfb8856606  */
855d30ea906Sjfb8856606 enum rte_eth_nb_tcs {
856d30ea906Sjfb8856606 	ETH_4_TCS = 4, /**< 4 TCs with DCB. */
857d30ea906Sjfb8856606 	ETH_8_TCS = 8  /**< 8 TCs with DCB. */
858d30ea906Sjfb8856606 };
859d30ea906Sjfb8856606 
860d30ea906Sjfb8856606 /**
861d30ea906Sjfb8856606  * This enum indicates the possible number of queue pools
862d30ea906Sjfb8856606  * in VMDQ configurations.
863d30ea906Sjfb8856606  */
864d30ea906Sjfb8856606 enum rte_eth_nb_pools {
865d30ea906Sjfb8856606 	ETH_8_POOLS = 8,    /**< 8 VMDq pools. */
866d30ea906Sjfb8856606 	ETH_16_POOLS = 16,  /**< 16 VMDq pools. */
867d30ea906Sjfb8856606 	ETH_32_POOLS = 32,  /**< 32 VMDq pools. */
868d30ea906Sjfb8856606 	ETH_64_POOLS = 64   /**< 64 VMDq pools. */
869d30ea906Sjfb8856606 };
870d30ea906Sjfb8856606 
871d30ea906Sjfb8856606 /* This structure may be extended in future. */
872d30ea906Sjfb8856606 struct rte_eth_dcb_rx_conf {
873d30ea906Sjfb8856606 	enum rte_eth_nb_tcs nb_tcs; /**< Possible DCB TCs, 4 or 8 TCs */
874d30ea906Sjfb8856606 	/** Traffic class each UP mapped to. */
875d30ea906Sjfb8856606 	uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES];
876d30ea906Sjfb8856606 };
877d30ea906Sjfb8856606 
878d30ea906Sjfb8856606 struct rte_eth_vmdq_dcb_tx_conf {
879d30ea906Sjfb8856606 	enum rte_eth_nb_pools nb_queue_pools; /**< With DCB, 16 or 32 pools. */
880d30ea906Sjfb8856606 	/** Traffic class each UP mapped to. */
881d30ea906Sjfb8856606 	uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES];
882d30ea906Sjfb8856606 };
883d30ea906Sjfb8856606 
884d30ea906Sjfb8856606 struct rte_eth_dcb_tx_conf {
885d30ea906Sjfb8856606 	enum rte_eth_nb_tcs nb_tcs; /**< Possible DCB TCs, 4 or 8 TCs. */
886d30ea906Sjfb8856606 	/** Traffic class each UP mapped to. */
887d30ea906Sjfb8856606 	uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES];
888d30ea906Sjfb8856606 };
889d30ea906Sjfb8856606 
890d30ea906Sjfb8856606 struct rte_eth_vmdq_tx_conf {
891d30ea906Sjfb8856606 	enum rte_eth_nb_pools nb_queue_pools; /**< VMDq mode, 64 pools. */
892d30ea906Sjfb8856606 };
893d30ea906Sjfb8856606 
894d30ea906Sjfb8856606 /**
895d30ea906Sjfb8856606  * A structure used to configure the VMDQ+DCB feature
896d30ea906Sjfb8856606  * of an Ethernet port.
897d30ea906Sjfb8856606  *
898d30ea906Sjfb8856606  * Using this feature, packets are routed to a pool of queues, based
899d30ea906Sjfb8856606  * on the vlan id in the vlan tag, and then to a specific queue within
900d30ea906Sjfb8856606  * that pool, using the user priority vlan tag field.
901d30ea906Sjfb8856606  *
902d30ea906Sjfb8856606  * A default pool may be used, if desired, to route all traffic which
903d30ea906Sjfb8856606  * does not match the vlan filter rules.
904d30ea906Sjfb8856606  */
905d30ea906Sjfb8856606 struct rte_eth_vmdq_dcb_conf {
906d30ea906Sjfb8856606 	enum rte_eth_nb_pools nb_queue_pools; /**< With DCB, 16 or 32 pools */
907d30ea906Sjfb8856606 	uint8_t enable_default_pool; /**< If non-zero, use a default pool */
908d30ea906Sjfb8856606 	uint8_t default_pool; /**< The default pool, if applicable */
909d30ea906Sjfb8856606 	uint8_t nb_pool_maps; /**< We can have up to 64 filters/mappings */
910d30ea906Sjfb8856606 	struct {
911d30ea906Sjfb8856606 		uint16_t vlan_id; /**< The vlan id of the received frame */
912d30ea906Sjfb8856606 		uint64_t pools;   /**< Bitmask of pools for packet rx */
913d30ea906Sjfb8856606 	} pool_map[ETH_VMDQ_MAX_VLAN_FILTERS]; /**< VMDq vlan pool maps. */
914d30ea906Sjfb8856606 	uint8_t dcb_tc[ETH_DCB_NUM_USER_PRIORITIES];
915d30ea906Sjfb8856606 	/**< Selects a queue in a pool */
916d30ea906Sjfb8856606 };
917d30ea906Sjfb8856606 
918d30ea906Sjfb8856606 /**
919d30ea906Sjfb8856606  * A structure used to configure the VMDQ feature of an Ethernet port when
920d30ea906Sjfb8856606  * not combined with the DCB feature.
921d30ea906Sjfb8856606  *
922d30ea906Sjfb8856606  * Using this feature, packets are routed to a pool of queues. By default,
923d30ea906Sjfb8856606  * the pool selection is based on the MAC address, the vlan id in the
924d30ea906Sjfb8856606  * vlan tag as specified in the pool_map array.
925d30ea906Sjfb8856606  * Passing the ETH_VMDQ_ACCEPT_UNTAG in the rx_mode field allows pool
926d30ea906Sjfb8856606  * selection using only the MAC address. MAC address to pool mapping is done
927d30ea906Sjfb8856606  * using the rte_eth_dev_mac_addr_add function, with the pool parameter
928d30ea906Sjfb8856606  * corresponding to the pool id.
929d30ea906Sjfb8856606  *
930d30ea906Sjfb8856606  * Queue selection within the selected pool will be done using RSS when
931d30ea906Sjfb8856606  * it is enabled or revert to the first queue of the pool if not.
932d30ea906Sjfb8856606  *
933d30ea906Sjfb8856606  * A default pool may be used, if desired, to route all traffic which
934d30ea906Sjfb8856606  * does not match the vlan filter rules or any pool MAC address.
935d30ea906Sjfb8856606  */
936d30ea906Sjfb8856606 struct rte_eth_vmdq_rx_conf {
937d30ea906Sjfb8856606 	enum rte_eth_nb_pools nb_queue_pools; /**< VMDq only mode, 8 or 64 pools */
938d30ea906Sjfb8856606 	uint8_t enable_default_pool; /**< If non-zero, use a default pool */
939d30ea906Sjfb8856606 	uint8_t default_pool; /**< The default pool, if applicable */
940d30ea906Sjfb8856606 	uint8_t enable_loop_back; /**< Enable VT loop back */
941d30ea906Sjfb8856606 	uint8_t nb_pool_maps; /**< We can have up to 64 filters/mappings */
942d30ea906Sjfb8856606 	uint32_t rx_mode; /**< Flags from ETH_VMDQ_ACCEPT_* */
943d30ea906Sjfb8856606 	struct {
944d30ea906Sjfb8856606 		uint16_t vlan_id; /**< The vlan id of the received frame */
945d30ea906Sjfb8856606 		uint64_t pools;   /**< Bitmask of pools for packet rx */
946d30ea906Sjfb8856606 	} pool_map[ETH_VMDQ_MAX_VLAN_FILTERS]; /**< VMDq vlan pool maps. */
947d30ea906Sjfb8856606 };
948d30ea906Sjfb8856606 
949d30ea906Sjfb8856606 /**
950d30ea906Sjfb8856606  * A structure used to configure the TX features of an Ethernet port.
951d30ea906Sjfb8856606  */
952d30ea906Sjfb8856606 struct rte_eth_txmode {
953d30ea906Sjfb8856606 	enum rte_eth_tx_mq_mode mq_mode; /**< TX multi-queues mode. */
954d30ea906Sjfb8856606 	/**
955d30ea906Sjfb8856606 	 * Per-port Tx offloads to be set using DEV_TX_OFFLOAD_* flags.
956d30ea906Sjfb8856606 	 * Only offloads set on tx_offload_capa field on rte_eth_dev_info
957d30ea906Sjfb8856606 	 * structure are allowed to be set.
958d30ea906Sjfb8856606 	 */
959d30ea906Sjfb8856606 	uint64_t offloads;
960d30ea906Sjfb8856606 
961d30ea906Sjfb8856606 	uint16_t pvid;
962d30ea906Sjfb8856606 	__extension__
963d30ea906Sjfb8856606 	uint8_t hw_vlan_reject_tagged : 1,
964d30ea906Sjfb8856606 		/**< If set, reject sending out tagged pkts */
965d30ea906Sjfb8856606 		hw_vlan_reject_untagged : 1,
966d30ea906Sjfb8856606 		/**< If set, reject sending out untagged pkts */
967d30ea906Sjfb8856606 		hw_vlan_insert_pvid : 1;
968d30ea906Sjfb8856606 		/**< If set, enable port based VLAN insertion */
9694418919fSjohnjiang 
9704418919fSjohnjiang 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
9714418919fSjohnjiang 	void *reserved_ptrs[2];   /**< Reserved for future fields */
972d30ea906Sjfb8856606 };
973d30ea906Sjfb8856606 
974d30ea906Sjfb8856606 /**
975*2d9fd380Sjfb8856606  * @warning
976*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this structure may change without prior notice.
977*2d9fd380Sjfb8856606  *
978*2d9fd380Sjfb8856606  * A structure used to configure an Rx packet segment to split.
979*2d9fd380Sjfb8856606  *
980*2d9fd380Sjfb8856606  * If RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag is set in offloads field,
981*2d9fd380Sjfb8856606  * the PMD will split the received packets into multiple segments
982*2d9fd380Sjfb8856606  * according to the specification in the description array:
983*2d9fd380Sjfb8856606  *
984*2d9fd380Sjfb8856606  * - The first network buffer will be allocated from the memory pool,
985*2d9fd380Sjfb8856606  *   specified in the first array element, the second buffer, from the
986*2d9fd380Sjfb8856606  *   pool in the second element, and so on.
987*2d9fd380Sjfb8856606  *
988*2d9fd380Sjfb8856606  * - The offsets from the segment description elements specify
989*2d9fd380Sjfb8856606  *   the data offset from the buffer beginning except the first mbuf.
990*2d9fd380Sjfb8856606  *   The first segment offset is added with RTE_PKTMBUF_HEADROOM.
991*2d9fd380Sjfb8856606  *
992*2d9fd380Sjfb8856606  * - The lengths in the elements define the maximal data amount
993*2d9fd380Sjfb8856606  *   being received to each segment. The receiving starts with filling
994*2d9fd380Sjfb8856606  *   up the first mbuf data buffer up to specified length. If the
995*2d9fd380Sjfb8856606  *   there are data remaining (packet is longer than buffer in the first
996*2d9fd380Sjfb8856606  *   mbuf) the following data will be pushed to the next segment
997*2d9fd380Sjfb8856606  *   up to its own length, and so on.
998*2d9fd380Sjfb8856606  *
999*2d9fd380Sjfb8856606  * - If the length in the segment description element is zero
1000*2d9fd380Sjfb8856606  *   the actual buffer size will be deduced from the appropriate
1001*2d9fd380Sjfb8856606  *   memory pool properties.
1002*2d9fd380Sjfb8856606  *
1003*2d9fd380Sjfb8856606  * - If there is not enough elements to describe the buffer for entire
1004*2d9fd380Sjfb8856606  *   packet of maximal length the following parameters will be used
1005*2d9fd380Sjfb8856606  *   for the all remaining segments:
1006*2d9fd380Sjfb8856606  *     - pool from the last valid element
1007*2d9fd380Sjfb8856606  *     - the buffer size from this pool
1008*2d9fd380Sjfb8856606  *     - zero offset
1009*2d9fd380Sjfb8856606  */
1010*2d9fd380Sjfb8856606 struct rte_eth_rxseg_split {
1011*2d9fd380Sjfb8856606 	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
1012*2d9fd380Sjfb8856606 	uint16_t length; /**< Segment data length, configures split point. */
1013*2d9fd380Sjfb8856606 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
1014*2d9fd380Sjfb8856606 	uint32_t reserved; /**< Reserved field. */
1015*2d9fd380Sjfb8856606 };
1016*2d9fd380Sjfb8856606 
1017*2d9fd380Sjfb8856606 /**
1018*2d9fd380Sjfb8856606  * @warning
1019*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this structure may change without prior notice.
1020*2d9fd380Sjfb8856606  *
1021*2d9fd380Sjfb8856606  * A common structure used to describe Rx packet segment properties.
1022*2d9fd380Sjfb8856606  */
1023*2d9fd380Sjfb8856606 union rte_eth_rxseg {
1024*2d9fd380Sjfb8856606 	/* The settings for buffer split offload. */
1025*2d9fd380Sjfb8856606 	struct rte_eth_rxseg_split split;
1026*2d9fd380Sjfb8856606 	/* The other features settings should be added here. */
1027*2d9fd380Sjfb8856606 };
1028*2d9fd380Sjfb8856606 
1029*2d9fd380Sjfb8856606 /**
1030d30ea906Sjfb8856606  * A structure used to configure an RX ring of an Ethernet port.
1031d30ea906Sjfb8856606  */
1032d30ea906Sjfb8856606 struct rte_eth_rxconf {
1033d30ea906Sjfb8856606 	struct rte_eth_thresh rx_thresh; /**< RX ring threshold registers. */
1034d30ea906Sjfb8856606 	uint16_t rx_free_thresh; /**< Drives the freeing of RX descriptors. */
1035d30ea906Sjfb8856606 	uint8_t rx_drop_en; /**< Drop packets if no descriptors are available. */
1036d30ea906Sjfb8856606 	uint8_t rx_deferred_start; /**< Do not start queue with rte_eth_dev_start(). */
1037*2d9fd380Sjfb8856606 	uint16_t rx_nseg; /**< Number of descriptions in rx_seg array. */
1038d30ea906Sjfb8856606 	/**
1039d30ea906Sjfb8856606 	 * Per-queue Rx offloads to be set using DEV_RX_OFFLOAD_* flags.
1040d30ea906Sjfb8856606 	 * Only offloads set on rx_queue_offload_capa or rx_offload_capa
1041d30ea906Sjfb8856606 	 * fields on rte_eth_dev_info structure are allowed to be set.
1042d30ea906Sjfb8856606 	 */
1043d30ea906Sjfb8856606 	uint64_t offloads;
1044*2d9fd380Sjfb8856606 	/**
1045*2d9fd380Sjfb8856606 	 * Points to the array of segment descriptions for an entire packet.
1046*2d9fd380Sjfb8856606 	 * Array elements are properties for consecutive Rx segments.
1047*2d9fd380Sjfb8856606 	 *
1048*2d9fd380Sjfb8856606 	 * The supported capabilities of receiving segmentation is reported
1049*2d9fd380Sjfb8856606 	 * in rte_eth_dev_info.rx_seg_capa field.
1050*2d9fd380Sjfb8856606 	 */
1051*2d9fd380Sjfb8856606 	union rte_eth_rxseg *rx_seg;
10524418919fSjohnjiang 
10534418919fSjohnjiang 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
10544418919fSjohnjiang 	void *reserved_ptrs[2];   /**< Reserved for future fields */
1055d30ea906Sjfb8856606 };
1056d30ea906Sjfb8856606 
1057d30ea906Sjfb8856606 /**
1058d30ea906Sjfb8856606  * A structure used to configure a TX ring of an Ethernet port.
1059d30ea906Sjfb8856606  */
1060d30ea906Sjfb8856606 struct rte_eth_txconf {
1061d30ea906Sjfb8856606 	struct rte_eth_thresh tx_thresh; /**< TX ring threshold registers. */
1062d30ea906Sjfb8856606 	uint16_t tx_rs_thresh; /**< Drives the setting of RS bit on TXDs. */
1063d30ea906Sjfb8856606 	uint16_t tx_free_thresh; /**< Start freeing TX buffers if there are
1064d30ea906Sjfb8856606 				      less free descriptors than this value. */
1065d30ea906Sjfb8856606 
1066d30ea906Sjfb8856606 	uint8_t tx_deferred_start; /**< Do not start queue with rte_eth_dev_start(). */
1067d30ea906Sjfb8856606 	/**
1068d30ea906Sjfb8856606 	 * Per-queue Tx offloads to be set  using DEV_TX_OFFLOAD_* flags.
1069d30ea906Sjfb8856606 	 * Only offloads set on tx_queue_offload_capa or tx_offload_capa
1070d30ea906Sjfb8856606 	 * fields on rte_eth_dev_info structure are allowed to be set.
1071d30ea906Sjfb8856606 	 */
1072d30ea906Sjfb8856606 	uint64_t offloads;
10734418919fSjohnjiang 
10744418919fSjohnjiang 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
10754418919fSjohnjiang 	void *reserved_ptrs[2];   /**< Reserved for future fields */
10764418919fSjohnjiang };
10774418919fSjohnjiang 
10784418919fSjohnjiang /**
10794418919fSjohnjiang  * @warning
10804418919fSjohnjiang  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
10814418919fSjohnjiang  *
10824418919fSjohnjiang  * A structure used to return the hairpin capabilities that are supported.
10834418919fSjohnjiang  */
10844418919fSjohnjiang struct rte_eth_hairpin_cap {
10854418919fSjohnjiang 	/** The max number of hairpin queues (different bindings). */
10864418919fSjohnjiang 	uint16_t max_nb_queues;
10874418919fSjohnjiang 	/** Max number of Rx queues to be connected to one Tx queue. */
10884418919fSjohnjiang 	uint16_t max_rx_2_tx;
10894418919fSjohnjiang 	/** Max number of Tx queues to be connected to one Rx queue. */
10904418919fSjohnjiang 	uint16_t max_tx_2_rx;
10914418919fSjohnjiang 	uint16_t max_nb_desc; /**< The max num of descriptors. */
10924418919fSjohnjiang };
10934418919fSjohnjiang 
10944418919fSjohnjiang #define RTE_ETH_MAX_HAIRPIN_PEERS 32
10954418919fSjohnjiang 
10964418919fSjohnjiang /**
10974418919fSjohnjiang  * @warning
10984418919fSjohnjiang  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
10994418919fSjohnjiang  *
11004418919fSjohnjiang  * A structure used to hold hairpin peer data.
11014418919fSjohnjiang  */
11024418919fSjohnjiang struct rte_eth_hairpin_peer {
11034418919fSjohnjiang 	uint16_t port; /**< Peer port. */
11044418919fSjohnjiang 	uint16_t queue; /**< Peer queue. */
11054418919fSjohnjiang };
11064418919fSjohnjiang 
11074418919fSjohnjiang /**
11084418919fSjohnjiang  * @warning
11094418919fSjohnjiang  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
11104418919fSjohnjiang  *
11114418919fSjohnjiang  * A structure used to configure hairpin binding.
11124418919fSjohnjiang  */
11134418919fSjohnjiang struct rte_eth_hairpin_conf {
1114*2d9fd380Sjfb8856606 	uint32_t peer_count:16; /**< The number of peers. */
1115*2d9fd380Sjfb8856606 
1116*2d9fd380Sjfb8856606 	/**
1117*2d9fd380Sjfb8856606 	 * Explicit Tx flow rule mode.
1118*2d9fd380Sjfb8856606 	 * One hairpin pair of queues should have the same attribute.
1119*2d9fd380Sjfb8856606 	 *
1120*2d9fd380Sjfb8856606 	 * - When set, the user should be responsible for inserting the hairpin
1121*2d9fd380Sjfb8856606 	 *   Tx part flows and removing them.
1122*2d9fd380Sjfb8856606 	 * - When clear, the PMD will try to handle the Tx part of the flows,
1123*2d9fd380Sjfb8856606 	 *   e.g., by splitting one flow into two parts.
1124*2d9fd380Sjfb8856606 	 */
1125*2d9fd380Sjfb8856606 	uint32_t tx_explicit:1;
1126*2d9fd380Sjfb8856606 
1127*2d9fd380Sjfb8856606 	/**
1128*2d9fd380Sjfb8856606 	 * Manually bind hairpin queues.
1129*2d9fd380Sjfb8856606 	 * One hairpin pair of queues should have the same attribute.
1130*2d9fd380Sjfb8856606 	 *
1131*2d9fd380Sjfb8856606 	 * - When set, to enable hairpin, the user should call the hairpin bind
1132*2d9fd380Sjfb8856606 	 *   function after all the queues are set up properly and the ports are
1133*2d9fd380Sjfb8856606 	 *   started. Also, the hairpin unbind function should be called
1134*2d9fd380Sjfb8856606 	 *   accordingly before stopping a port that with hairpin configured.
1135*2d9fd380Sjfb8856606 	 * - When clear, the PMD will try to enable the hairpin with the queues
1136*2d9fd380Sjfb8856606 	 *   configured automatically during port start.
1137*2d9fd380Sjfb8856606 	 */
1138*2d9fd380Sjfb8856606 	uint32_t manual_bind:1;
1139*2d9fd380Sjfb8856606 	uint32_t reserved:14; /**< Reserved bits. */
11404418919fSjohnjiang 	struct rte_eth_hairpin_peer peers[RTE_ETH_MAX_HAIRPIN_PEERS];
1141d30ea906Sjfb8856606 };
1142d30ea906Sjfb8856606 
1143d30ea906Sjfb8856606 /**
1144d30ea906Sjfb8856606  * A structure contains information about HW descriptor ring limitations.
1145d30ea906Sjfb8856606  */
1146d30ea906Sjfb8856606 struct rte_eth_desc_lim {
1147d30ea906Sjfb8856606 	uint16_t nb_max;   /**< Max allowed number of descriptors. */
1148d30ea906Sjfb8856606 	uint16_t nb_min;   /**< Min allowed number of descriptors. */
1149d30ea906Sjfb8856606 	uint16_t nb_align; /**< Number of descriptors should be aligned to. */
1150d30ea906Sjfb8856606 
1151d30ea906Sjfb8856606 	/**
1152d30ea906Sjfb8856606 	 * Max allowed number of segments per whole packet.
1153d30ea906Sjfb8856606 	 *
1154d30ea906Sjfb8856606 	 * - For TSO packet this is the total number of data descriptors allowed
1155d30ea906Sjfb8856606 	 *   by device.
1156d30ea906Sjfb8856606 	 *
1157d30ea906Sjfb8856606 	 * @see nb_mtu_seg_max
1158d30ea906Sjfb8856606 	 */
1159d30ea906Sjfb8856606 	uint16_t nb_seg_max;
1160d30ea906Sjfb8856606 
1161d30ea906Sjfb8856606 	/**
1162d30ea906Sjfb8856606 	 * Max number of segments per one MTU.
1163d30ea906Sjfb8856606 	 *
1164d30ea906Sjfb8856606 	 * - For non-TSO packet, this is the maximum allowed number of segments
1165d30ea906Sjfb8856606 	 *   in a single transmit packet.
1166d30ea906Sjfb8856606 	 *
1167d30ea906Sjfb8856606 	 * - For TSO packet each segment within the TSO may span up to this
1168d30ea906Sjfb8856606 	 *   value.
1169d30ea906Sjfb8856606 	 *
1170d30ea906Sjfb8856606 	 * @see nb_seg_max
1171d30ea906Sjfb8856606 	 */
1172d30ea906Sjfb8856606 	uint16_t nb_mtu_seg_max;
1173d30ea906Sjfb8856606 };
1174d30ea906Sjfb8856606 
1175d30ea906Sjfb8856606 /**
1176d30ea906Sjfb8856606  * This enum indicates the flow control mode
1177d30ea906Sjfb8856606  */
1178d30ea906Sjfb8856606 enum rte_eth_fc_mode {
1179d30ea906Sjfb8856606 	RTE_FC_NONE = 0, /**< Disable flow control. */
1180d30ea906Sjfb8856606 	RTE_FC_RX_PAUSE, /**< RX pause frame, enable flowctrl on TX side. */
1181d30ea906Sjfb8856606 	RTE_FC_TX_PAUSE, /**< TX pause frame, enable flowctrl on RX side. */
1182d30ea906Sjfb8856606 	RTE_FC_FULL      /**< Enable flow control on both side. */
1183d30ea906Sjfb8856606 };
1184d30ea906Sjfb8856606 
1185d30ea906Sjfb8856606 /**
1186d30ea906Sjfb8856606  * A structure used to configure Ethernet flow control parameter.
1187d30ea906Sjfb8856606  * These parameters will be configured into the register of the NIC.
1188d30ea906Sjfb8856606  * Please refer to the corresponding data sheet for proper value.
1189d30ea906Sjfb8856606  */
1190d30ea906Sjfb8856606 struct rte_eth_fc_conf {
1191d30ea906Sjfb8856606 	uint32_t high_water;  /**< High threshold value to trigger XOFF */
1192d30ea906Sjfb8856606 	uint32_t low_water;   /**< Low threshold value to trigger XON */
1193d30ea906Sjfb8856606 	uint16_t pause_time;  /**< Pause quota in the Pause frame */
1194d30ea906Sjfb8856606 	uint16_t send_xon;    /**< Is XON frame need be sent */
1195d30ea906Sjfb8856606 	enum rte_eth_fc_mode mode;  /**< Link flow control mode */
1196d30ea906Sjfb8856606 	uint8_t mac_ctrl_frame_fwd; /**< Forward MAC control frames */
1197d30ea906Sjfb8856606 	uint8_t autoneg;      /**< Use Pause autoneg */
1198d30ea906Sjfb8856606 };
1199d30ea906Sjfb8856606 
1200d30ea906Sjfb8856606 /**
1201d30ea906Sjfb8856606  * A structure used to configure Ethernet priority flow control parameter.
1202d30ea906Sjfb8856606  * These parameters will be configured into the register of the NIC.
1203d30ea906Sjfb8856606  * Please refer to the corresponding data sheet for proper value.
1204d30ea906Sjfb8856606  */
1205d30ea906Sjfb8856606 struct rte_eth_pfc_conf {
1206d30ea906Sjfb8856606 	struct rte_eth_fc_conf fc; /**< General flow control parameter. */
1207d30ea906Sjfb8856606 	uint8_t priority;          /**< VLAN User Priority. */
1208d30ea906Sjfb8856606 };
1209d30ea906Sjfb8856606 
1210d30ea906Sjfb8856606 /**
12114418919fSjohnjiang  * Tunneled type.
12124418919fSjohnjiang  */
12134418919fSjohnjiang enum rte_eth_tunnel_type {
12144418919fSjohnjiang 	RTE_TUNNEL_TYPE_NONE = 0,
12154418919fSjohnjiang 	RTE_TUNNEL_TYPE_VXLAN,
12164418919fSjohnjiang 	RTE_TUNNEL_TYPE_GENEVE,
12174418919fSjohnjiang 	RTE_TUNNEL_TYPE_TEREDO,
12184418919fSjohnjiang 	RTE_TUNNEL_TYPE_NVGRE,
12194418919fSjohnjiang 	RTE_TUNNEL_TYPE_IP_IN_GRE,
12204418919fSjohnjiang 	RTE_L2_TUNNEL_TYPE_E_TAG,
12214418919fSjohnjiang 	RTE_TUNNEL_TYPE_VXLAN_GPE,
12224418919fSjohnjiang 	RTE_TUNNEL_TYPE_MAX,
12234418919fSjohnjiang };
12244418919fSjohnjiang 
12254418919fSjohnjiang /* Deprecated API file for rte_eth_dev_filter_* functions */
12264418919fSjohnjiang #include "rte_eth_ctrl.h"
12274418919fSjohnjiang 
12284418919fSjohnjiang /**
1229d30ea906Sjfb8856606  *  Memory space that can be configured to store Flow Director filters
1230d30ea906Sjfb8856606  *  in the board memory.
1231d30ea906Sjfb8856606  */
1232d30ea906Sjfb8856606 enum rte_fdir_pballoc_type {
1233d30ea906Sjfb8856606 	RTE_FDIR_PBALLOC_64K = 0,  /**< 64k. */
1234d30ea906Sjfb8856606 	RTE_FDIR_PBALLOC_128K,     /**< 128k. */
1235d30ea906Sjfb8856606 	RTE_FDIR_PBALLOC_256K,     /**< 256k. */
1236d30ea906Sjfb8856606 };
1237d30ea906Sjfb8856606 
1238d30ea906Sjfb8856606 /**
1239d30ea906Sjfb8856606  *  Select report mode of FDIR hash information in RX descriptors.
1240d30ea906Sjfb8856606  */
1241d30ea906Sjfb8856606 enum rte_fdir_status_mode {
1242d30ea906Sjfb8856606 	RTE_FDIR_NO_REPORT_STATUS = 0, /**< Never report FDIR hash. */
1243d30ea906Sjfb8856606 	RTE_FDIR_REPORT_STATUS, /**< Only report FDIR hash for matching pkts. */
1244d30ea906Sjfb8856606 	RTE_FDIR_REPORT_STATUS_ALWAYS, /**< Always report FDIR hash. */
1245d30ea906Sjfb8856606 };
1246d30ea906Sjfb8856606 
1247d30ea906Sjfb8856606 /**
1248d30ea906Sjfb8856606  * A structure used to configure the Flow Director (FDIR) feature
1249d30ea906Sjfb8856606  * of an Ethernet port.
1250d30ea906Sjfb8856606  *
12514418919fSjohnjiang  * If mode is RTE_FDIR_MODE_NONE, the pballoc value is ignored.
1252d30ea906Sjfb8856606  */
1253d30ea906Sjfb8856606 struct rte_fdir_conf {
1254d30ea906Sjfb8856606 	enum rte_fdir_mode mode; /**< Flow Director mode. */
1255d30ea906Sjfb8856606 	enum rte_fdir_pballoc_type pballoc; /**< Space for FDIR filters. */
1256d30ea906Sjfb8856606 	enum rte_fdir_status_mode status;  /**< How to report FDIR hash. */
1257d30ea906Sjfb8856606 	/** RX queue of packets matching a "drop" filter in perfect mode. */
1258d30ea906Sjfb8856606 	uint8_t drop_queue;
1259d30ea906Sjfb8856606 	struct rte_eth_fdir_masks mask;
1260d30ea906Sjfb8856606 	struct rte_eth_fdir_flex_conf flex_conf;
1261d30ea906Sjfb8856606 	/**< Flex payload configuration. */
1262d30ea906Sjfb8856606 };
1263d30ea906Sjfb8856606 
1264d30ea906Sjfb8856606 /**
1265d30ea906Sjfb8856606  * UDP tunneling configuration.
1266d30ea906Sjfb8856606  * Used to config the UDP port for a type of tunnel.
1267d30ea906Sjfb8856606  * NICs need the UDP port to identify the tunnel type.
1268d30ea906Sjfb8856606  * Normally a type of tunnel has a default UDP port, this structure can be used
1269d30ea906Sjfb8856606  * in case if the users want to change or support more UDP port.
1270d30ea906Sjfb8856606  */
1271d30ea906Sjfb8856606 struct rte_eth_udp_tunnel {
1272d30ea906Sjfb8856606 	uint16_t udp_port; /**< UDP port used for the tunnel. */
1273d30ea906Sjfb8856606 	uint8_t prot_type; /**< Tunnel type. Defined in rte_eth_tunnel_type. */
1274d30ea906Sjfb8856606 };
1275d30ea906Sjfb8856606 
1276d30ea906Sjfb8856606 /**
1277d30ea906Sjfb8856606  * A structure used to enable/disable specific device interrupts.
1278d30ea906Sjfb8856606  */
1279d30ea906Sjfb8856606 struct rte_intr_conf {
1280d30ea906Sjfb8856606 	/** enable/disable lsc interrupt. 0 (default) - disable, 1 enable */
1281d30ea906Sjfb8856606 	uint32_t lsc:1;
1282d30ea906Sjfb8856606 	/** enable/disable rxq interrupt. 0 (default) - disable, 1 enable */
1283d30ea906Sjfb8856606 	uint32_t rxq:1;
1284d30ea906Sjfb8856606 	/** enable/disable rmv interrupt. 0 (default) - disable, 1 enable */
1285d30ea906Sjfb8856606 	uint32_t rmv:1;
1286d30ea906Sjfb8856606 };
1287d30ea906Sjfb8856606 
1288d30ea906Sjfb8856606 /**
1289d30ea906Sjfb8856606  * A structure used to configure an Ethernet port.
1290d30ea906Sjfb8856606  * Depending upon the RX multi-queue mode, extra advanced
1291d30ea906Sjfb8856606  * configuration settings may be needed.
1292d30ea906Sjfb8856606  */
1293d30ea906Sjfb8856606 struct rte_eth_conf {
1294d30ea906Sjfb8856606 	uint32_t link_speeds; /**< bitmap of ETH_LINK_SPEED_XXX of speeds to be
1295d30ea906Sjfb8856606 				used. ETH_LINK_SPEED_FIXED disables link
1296d30ea906Sjfb8856606 				autonegotiation, and a unique speed shall be
1297d30ea906Sjfb8856606 				set. Otherwise, the bitmap defines the set of
1298d30ea906Sjfb8856606 				speeds to be advertised. If the special value
1299d30ea906Sjfb8856606 				ETH_LINK_SPEED_AUTONEG (0) is used, all speeds
1300d30ea906Sjfb8856606 				supported are advertised. */
1301d30ea906Sjfb8856606 	struct rte_eth_rxmode rxmode; /**< Port RX configuration. */
1302d30ea906Sjfb8856606 	struct rte_eth_txmode txmode; /**< Port TX configuration. */
1303d30ea906Sjfb8856606 	uint32_t lpbk_mode; /**< Loopback operation mode. By default the value
1304d30ea906Sjfb8856606 			         is 0, meaning the loopback mode is disabled.
1305d30ea906Sjfb8856606 				 Read the datasheet of given ethernet controller
1306d30ea906Sjfb8856606 				 for details. The possible values of this field
1307d30ea906Sjfb8856606 				 are defined in implementation of each driver. */
1308d30ea906Sjfb8856606 	struct {
1309d30ea906Sjfb8856606 		struct rte_eth_rss_conf rss_conf; /**< Port RSS configuration */
1310d30ea906Sjfb8856606 		struct rte_eth_vmdq_dcb_conf vmdq_dcb_conf;
1311d30ea906Sjfb8856606 		/**< Port vmdq+dcb configuration. */
1312d30ea906Sjfb8856606 		struct rte_eth_dcb_rx_conf dcb_rx_conf;
1313d30ea906Sjfb8856606 		/**< Port dcb RX configuration. */
1314d30ea906Sjfb8856606 		struct rte_eth_vmdq_rx_conf vmdq_rx_conf;
1315d30ea906Sjfb8856606 		/**< Port vmdq RX configuration. */
1316d30ea906Sjfb8856606 	} rx_adv_conf; /**< Port RX filtering configuration. */
1317d30ea906Sjfb8856606 	union {
1318d30ea906Sjfb8856606 		struct rte_eth_vmdq_dcb_tx_conf vmdq_dcb_tx_conf;
1319d30ea906Sjfb8856606 		/**< Port vmdq+dcb TX configuration. */
1320d30ea906Sjfb8856606 		struct rte_eth_dcb_tx_conf dcb_tx_conf;
1321d30ea906Sjfb8856606 		/**< Port dcb TX configuration. */
1322d30ea906Sjfb8856606 		struct rte_eth_vmdq_tx_conf vmdq_tx_conf;
1323d30ea906Sjfb8856606 		/**< Port vmdq TX configuration. */
1324d30ea906Sjfb8856606 	} tx_adv_conf; /**< Port TX DCB configuration (union). */
1325d30ea906Sjfb8856606 	/** Currently,Priority Flow Control(PFC) are supported,if DCB with PFC
1326d30ea906Sjfb8856606 	    is needed,and the variable must be set ETH_DCB_PFC_SUPPORT. */
1327d30ea906Sjfb8856606 	uint32_t dcb_capability_en;
13284418919fSjohnjiang 	struct rte_fdir_conf fdir_conf; /**< FDIR configuration. DEPRECATED */
1329d30ea906Sjfb8856606 	struct rte_intr_conf intr_conf; /**< Interrupt mode configuration. */
1330d30ea906Sjfb8856606 };
1331d30ea906Sjfb8856606 
1332d30ea906Sjfb8856606 /**
1333d30ea906Sjfb8856606  * RX offload capabilities of a device.
1334d30ea906Sjfb8856606  */
1335d30ea906Sjfb8856606 #define DEV_RX_OFFLOAD_VLAN_STRIP  0x00000001
1336d30ea906Sjfb8856606 #define DEV_RX_OFFLOAD_IPV4_CKSUM  0x00000002
1337d30ea906Sjfb8856606 #define DEV_RX_OFFLOAD_UDP_CKSUM   0x00000004
1338d30ea906Sjfb8856606 #define DEV_RX_OFFLOAD_TCP_CKSUM   0x00000008
1339d30ea906Sjfb8856606 #define DEV_RX_OFFLOAD_TCP_LRO     0x00000010
1340d30ea906Sjfb8856606 #define DEV_RX_OFFLOAD_QINQ_STRIP  0x00000020
1341d30ea906Sjfb8856606 #define DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM 0x00000040
1342d30ea906Sjfb8856606 #define DEV_RX_OFFLOAD_MACSEC_STRIP     0x00000080
1343d30ea906Sjfb8856606 #define DEV_RX_OFFLOAD_HEADER_SPLIT	0x00000100
1344d30ea906Sjfb8856606 #define DEV_RX_OFFLOAD_VLAN_FILTER	0x00000200
1345d30ea906Sjfb8856606 #define DEV_RX_OFFLOAD_VLAN_EXTEND	0x00000400
1346d30ea906Sjfb8856606 #define DEV_RX_OFFLOAD_JUMBO_FRAME	0x00000800
1347d30ea906Sjfb8856606 #define DEV_RX_OFFLOAD_SCATTER		0x00002000
1348*2d9fd380Sjfb8856606 /**
1349*2d9fd380Sjfb8856606  * Timestamp is set by the driver in RTE_MBUF_DYNFIELD_TIMESTAMP_NAME
1350*2d9fd380Sjfb8856606  * and RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME is set in ol_flags.
1351*2d9fd380Sjfb8856606  * The mbuf field and flag are registered when the offload is configured.
1352*2d9fd380Sjfb8856606  */
1353d30ea906Sjfb8856606 #define DEV_RX_OFFLOAD_TIMESTAMP	0x00004000
1354d30ea906Sjfb8856606 #define DEV_RX_OFFLOAD_SECURITY         0x00008000
1355d30ea906Sjfb8856606 #define DEV_RX_OFFLOAD_KEEP_CRC		0x00010000
1356d30ea906Sjfb8856606 #define DEV_RX_OFFLOAD_SCTP_CKSUM	0x00020000
1357d30ea906Sjfb8856606 #define DEV_RX_OFFLOAD_OUTER_UDP_CKSUM  0x00040000
13584418919fSjohnjiang #define DEV_RX_OFFLOAD_RSS_HASH		0x00080000
1359*2d9fd380Sjfb8856606 #define RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT 0x00100000
1360d30ea906Sjfb8856606 
1361d30ea906Sjfb8856606 #define DEV_RX_OFFLOAD_CHECKSUM (DEV_RX_OFFLOAD_IPV4_CKSUM | \
1362d30ea906Sjfb8856606 				 DEV_RX_OFFLOAD_UDP_CKSUM | \
1363d30ea906Sjfb8856606 				 DEV_RX_OFFLOAD_TCP_CKSUM)
1364d30ea906Sjfb8856606 #define DEV_RX_OFFLOAD_VLAN (DEV_RX_OFFLOAD_VLAN_STRIP | \
1365d30ea906Sjfb8856606 			     DEV_RX_OFFLOAD_VLAN_FILTER | \
13664418919fSjohnjiang 			     DEV_RX_OFFLOAD_VLAN_EXTEND | \
13674418919fSjohnjiang 			     DEV_RX_OFFLOAD_QINQ_STRIP)
1368d30ea906Sjfb8856606 
1369d30ea906Sjfb8856606 /*
1370d30ea906Sjfb8856606  * If new Rx offload capabilities are defined, they also must be
1371d30ea906Sjfb8856606  * mentioned in rte_rx_offload_names in rte_ethdev.c file.
1372d30ea906Sjfb8856606  */
1373d30ea906Sjfb8856606 
1374d30ea906Sjfb8856606 /**
1375d30ea906Sjfb8856606  * TX offload capabilities of a device.
1376d30ea906Sjfb8856606  */
1377d30ea906Sjfb8856606 #define DEV_TX_OFFLOAD_VLAN_INSERT 0x00000001
1378d30ea906Sjfb8856606 #define DEV_TX_OFFLOAD_IPV4_CKSUM  0x00000002
1379d30ea906Sjfb8856606 #define DEV_TX_OFFLOAD_UDP_CKSUM   0x00000004
1380d30ea906Sjfb8856606 #define DEV_TX_OFFLOAD_TCP_CKSUM   0x00000008
1381d30ea906Sjfb8856606 #define DEV_TX_OFFLOAD_SCTP_CKSUM  0x00000010
1382d30ea906Sjfb8856606 #define DEV_TX_OFFLOAD_TCP_TSO     0x00000020
1383d30ea906Sjfb8856606 #define DEV_TX_OFFLOAD_UDP_TSO     0x00000040
1384d30ea906Sjfb8856606 #define DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM 0x00000080 /**< Used for tunneling packet. */
1385d30ea906Sjfb8856606 #define DEV_TX_OFFLOAD_QINQ_INSERT 0x00000100
1386d30ea906Sjfb8856606 #define DEV_TX_OFFLOAD_VXLAN_TNL_TSO    0x00000200    /**< Used for tunneling packet. */
1387d30ea906Sjfb8856606 #define DEV_TX_OFFLOAD_GRE_TNL_TSO      0x00000400    /**< Used for tunneling packet. */
1388d30ea906Sjfb8856606 #define DEV_TX_OFFLOAD_IPIP_TNL_TSO     0x00000800    /**< Used for tunneling packet. */
1389d30ea906Sjfb8856606 #define DEV_TX_OFFLOAD_GENEVE_TNL_TSO   0x00001000    /**< Used for tunneling packet. */
1390d30ea906Sjfb8856606 #define DEV_TX_OFFLOAD_MACSEC_INSERT    0x00002000
1391d30ea906Sjfb8856606 #define DEV_TX_OFFLOAD_MT_LOCKFREE      0x00004000
1392d30ea906Sjfb8856606 /**< Multiple threads can invoke rte_eth_tx_burst() concurrently on the same
1393d30ea906Sjfb8856606  * tx queue without SW lock.
1394d30ea906Sjfb8856606  */
1395d30ea906Sjfb8856606 #define DEV_TX_OFFLOAD_MULTI_SEGS	0x00008000
1396d30ea906Sjfb8856606 /**< Device supports multi segment send. */
1397d30ea906Sjfb8856606 #define DEV_TX_OFFLOAD_MBUF_FAST_FREE	0x00010000
1398d30ea906Sjfb8856606 /**< Device supports optimization for fast release of mbufs.
1399d30ea906Sjfb8856606  *   When set application must guarantee that per-queue all mbufs comes from
1400d30ea906Sjfb8856606  *   the same mempool and has refcnt = 1.
1401d30ea906Sjfb8856606  */
1402d30ea906Sjfb8856606 #define DEV_TX_OFFLOAD_SECURITY         0x00020000
1403d30ea906Sjfb8856606 /**
1404d30ea906Sjfb8856606  * Device supports generic UDP tunneled packet TSO.
1405d30ea906Sjfb8856606  * Application must set PKT_TX_TUNNEL_UDP and other mbuf fields required
1406d30ea906Sjfb8856606  * for tunnel TSO.
1407d30ea906Sjfb8856606  */
1408d30ea906Sjfb8856606 #define DEV_TX_OFFLOAD_UDP_TNL_TSO      0x00040000
1409d30ea906Sjfb8856606 /**
1410d30ea906Sjfb8856606  * Device supports generic IP tunneled packet TSO.
1411d30ea906Sjfb8856606  * Application must set PKT_TX_TUNNEL_IP and other mbuf fields required
1412d30ea906Sjfb8856606  * for tunnel TSO.
1413d30ea906Sjfb8856606  */
1414d30ea906Sjfb8856606 #define DEV_TX_OFFLOAD_IP_TNL_TSO       0x00080000
1415d30ea906Sjfb8856606 /** Device supports outer UDP checksum */
1416d30ea906Sjfb8856606 #define DEV_TX_OFFLOAD_OUTER_UDP_CKSUM  0x00100000
1417*2d9fd380Sjfb8856606 /**
1418*2d9fd380Sjfb8856606  * Device sends on time read from RTE_MBUF_DYNFIELD_TIMESTAMP_NAME
1419*2d9fd380Sjfb8856606  * if RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME is set in ol_flags.
1420*2d9fd380Sjfb8856606  * The mbuf field and flag are registered when the offload is configured.
1421*2d9fd380Sjfb8856606  */
1422*2d9fd380Sjfb8856606 #define DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP 0x00200000
1423d30ea906Sjfb8856606 /*
1424d30ea906Sjfb8856606  * If new Tx offload capabilities are defined, they also must be
1425d30ea906Sjfb8856606  * mentioned in rte_tx_offload_names in rte_ethdev.c file.
1426d30ea906Sjfb8856606  */
1427d30ea906Sjfb8856606 
14280c6bd470Sfengbojiang /**@{@name Device capabilities
14290c6bd470Sfengbojiang  * Non-offload capabilities reported in rte_eth_dev_info.dev_capa.
14300c6bd470Sfengbojiang  */
14310c6bd470Sfengbojiang /** Device supports Rx queue setup after device started. */
14320c6bd470Sfengbojiang #define RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP 0x00000001
14330c6bd470Sfengbojiang /** Device supports Tx queue setup after device started. */
14340c6bd470Sfengbojiang #define RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP 0x00000002
14350c6bd470Sfengbojiang /**@}*/
14360c6bd470Sfengbojiang 
1437d30ea906Sjfb8856606 /*
1438d30ea906Sjfb8856606  * Fallback default preferred Rx/Tx port parameters.
1439d30ea906Sjfb8856606  * These are used if an application requests default parameters
1440d30ea906Sjfb8856606  * but the PMD does not provide preferred values.
1441d30ea906Sjfb8856606  */
1442d30ea906Sjfb8856606 #define RTE_ETH_DEV_FALLBACK_RX_RINGSIZE 512
1443d30ea906Sjfb8856606 #define RTE_ETH_DEV_FALLBACK_TX_RINGSIZE 512
1444d30ea906Sjfb8856606 #define RTE_ETH_DEV_FALLBACK_RX_NBQUEUES 1
1445d30ea906Sjfb8856606 #define RTE_ETH_DEV_FALLBACK_TX_NBQUEUES 1
1446d30ea906Sjfb8856606 
1447d30ea906Sjfb8856606 /**
1448d30ea906Sjfb8856606  * Preferred Rx/Tx port parameters.
1449d30ea906Sjfb8856606  * There are separate instances of this structure for transmission
1450d30ea906Sjfb8856606  * and reception respectively.
1451d30ea906Sjfb8856606  */
1452d30ea906Sjfb8856606 struct rte_eth_dev_portconf {
1453d30ea906Sjfb8856606 	uint16_t burst_size; /**< Device-preferred burst size */
1454d30ea906Sjfb8856606 	uint16_t ring_size; /**< Device-preferred size of queue rings */
1455d30ea906Sjfb8856606 	uint16_t nb_queues; /**< Device-preferred number of queues */
1456d30ea906Sjfb8856606 };
1457d30ea906Sjfb8856606 
1458d30ea906Sjfb8856606 /**
1459d30ea906Sjfb8856606  * Default values for switch domain id when ethdev does not support switch
1460d30ea906Sjfb8856606  * domain definitions.
1461d30ea906Sjfb8856606  */
14624418919fSjohnjiang #define RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID	(UINT16_MAX)
1463d30ea906Sjfb8856606 
1464d30ea906Sjfb8856606 /**
1465d30ea906Sjfb8856606  * Ethernet device associated switch information
1466d30ea906Sjfb8856606  */
1467d30ea906Sjfb8856606 struct rte_eth_switch_info {
1468d30ea906Sjfb8856606 	const char *name;	/**< switch name */
1469d30ea906Sjfb8856606 	uint16_t domain_id;	/**< switch domain id */
1470d30ea906Sjfb8856606 	uint16_t port_id;
1471d30ea906Sjfb8856606 	/**<
1472d30ea906Sjfb8856606 	 * mapping to the devices physical switch port as enumerated from the
1473d30ea906Sjfb8856606 	 * perspective of the embedded interconnect/switch. For SR-IOV enabled
1474d30ea906Sjfb8856606 	 * device this may correspond to the VF_ID of each virtual function,
1475d30ea906Sjfb8856606 	 * but each driver should explicitly define the mapping of switch
1476d30ea906Sjfb8856606 	 * port identifier to that physical interconnect/switch
1477d30ea906Sjfb8856606 	 */
1478d30ea906Sjfb8856606 };
1479d30ea906Sjfb8856606 
1480d30ea906Sjfb8856606 /**
1481*2d9fd380Sjfb8856606  * @warning
1482*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this structure may change without prior notice.
1483*2d9fd380Sjfb8856606  *
1484*2d9fd380Sjfb8856606  * Ethernet device Rx buffer segmentation capabilities.
1485*2d9fd380Sjfb8856606  */
1486*2d9fd380Sjfb8856606 struct rte_eth_rxseg_capa {
1487*2d9fd380Sjfb8856606 	__extension__
1488*2d9fd380Sjfb8856606 	uint32_t multi_pools:1; /**< Supports receiving to multiple pools.*/
1489*2d9fd380Sjfb8856606 	uint32_t offset_allowed:1; /**< Supports buffer offsets. */
1490*2d9fd380Sjfb8856606 	uint32_t offset_align_log2:4; /**< Required offset alignment. */
1491*2d9fd380Sjfb8856606 	uint16_t max_nseg; /**< Maximum amount of segments to split. */
1492*2d9fd380Sjfb8856606 	uint16_t reserved; /**< Reserved field. */
1493*2d9fd380Sjfb8856606 };
1494*2d9fd380Sjfb8856606 
1495*2d9fd380Sjfb8856606 /**
1496d30ea906Sjfb8856606  * Ethernet device information
1497d30ea906Sjfb8856606  */
1498d30ea906Sjfb8856606 
1499d30ea906Sjfb8856606 /**
1500d30ea906Sjfb8856606  * A structure used to retrieve the contextual information of
1501d30ea906Sjfb8856606  * an Ethernet device, such as the controlling driver of the
1502d30ea906Sjfb8856606  * device, etc...
1503d30ea906Sjfb8856606  */
1504d30ea906Sjfb8856606 struct rte_eth_dev_info {
1505d30ea906Sjfb8856606 	struct rte_device *device; /** Generic device information */
1506d30ea906Sjfb8856606 	const char *driver_name; /**< Device Driver name. */
1507d30ea906Sjfb8856606 	unsigned int if_index; /**< Index to bound host interface, or 0 if none.
1508d30ea906Sjfb8856606 		Use if_indextoname() to translate into an interface name. */
15094418919fSjohnjiang 	uint16_t min_mtu;	/**< Minimum MTU allowed */
15104418919fSjohnjiang 	uint16_t max_mtu;	/**< Maximum MTU allowed */
1511d30ea906Sjfb8856606 	const uint32_t *dev_flags; /**< Device flags */
1512d30ea906Sjfb8856606 	uint32_t min_rx_bufsize; /**< Minimum size of RX buffer. */
1513d30ea906Sjfb8856606 	uint32_t max_rx_pktlen; /**< Maximum configurable length of RX pkt. */
15144418919fSjohnjiang 	/** Maximum configurable size of LRO aggregated packet. */
15154418919fSjohnjiang 	uint32_t max_lro_pkt_size;
1516d30ea906Sjfb8856606 	uint16_t max_rx_queues; /**< Maximum number of RX queues. */
1517d30ea906Sjfb8856606 	uint16_t max_tx_queues; /**< Maximum number of TX queues. */
1518d30ea906Sjfb8856606 	uint32_t max_mac_addrs; /**< Maximum number of MAC addresses. */
1519d30ea906Sjfb8856606 	uint32_t max_hash_mac_addrs;
1520d30ea906Sjfb8856606 	/** Maximum number of hash MAC addresses for MTA and UTA. */
1521d30ea906Sjfb8856606 	uint16_t max_vfs; /**< Maximum number of VFs. */
1522d30ea906Sjfb8856606 	uint16_t max_vmdq_pools; /**< Maximum number of VMDq pools. */
1523*2d9fd380Sjfb8856606 	struct rte_eth_rxseg_capa rx_seg_capa; /**< Segmentation capability.*/
1524d30ea906Sjfb8856606 	uint64_t rx_offload_capa;
1525d30ea906Sjfb8856606 	/**< All RX offload capabilities including all per-queue ones */
1526d30ea906Sjfb8856606 	uint64_t tx_offload_capa;
1527d30ea906Sjfb8856606 	/**< All TX offload capabilities including all per-queue ones */
1528d30ea906Sjfb8856606 	uint64_t rx_queue_offload_capa;
1529d30ea906Sjfb8856606 	/**< Device per-queue RX offload capabilities. */
1530d30ea906Sjfb8856606 	uint64_t tx_queue_offload_capa;
1531d30ea906Sjfb8856606 	/**< Device per-queue TX offload capabilities. */
1532d30ea906Sjfb8856606 	uint16_t reta_size;
1533d30ea906Sjfb8856606 	/**< Device redirection table size, the total number of entries. */
1534d30ea906Sjfb8856606 	uint8_t hash_key_size; /**< Hash key size in bytes */
1535d30ea906Sjfb8856606 	/** Bit mask of RSS offloads, the bit offset also means flow type */
1536d30ea906Sjfb8856606 	uint64_t flow_type_rss_offloads;
1537d30ea906Sjfb8856606 	struct rte_eth_rxconf default_rxconf; /**< Default RX configuration */
1538d30ea906Sjfb8856606 	struct rte_eth_txconf default_txconf; /**< Default TX configuration */
1539d30ea906Sjfb8856606 	uint16_t vmdq_queue_base; /**< First queue ID for VMDQ pools. */
1540d30ea906Sjfb8856606 	uint16_t vmdq_queue_num;  /**< Queue number for VMDQ pools. */
1541d30ea906Sjfb8856606 	uint16_t vmdq_pool_base;  /**< First ID of VMDQ pools. */
1542d30ea906Sjfb8856606 	struct rte_eth_desc_lim rx_desc_lim;  /**< RX descriptors limits */
1543d30ea906Sjfb8856606 	struct rte_eth_desc_lim tx_desc_lim;  /**< TX descriptors limits */
1544d30ea906Sjfb8856606 	uint32_t speed_capa;  /**< Supported speeds bitmap (ETH_LINK_SPEED_). */
1545d30ea906Sjfb8856606 	/** Configured number of rx/tx queues */
1546d30ea906Sjfb8856606 	uint16_t nb_rx_queues; /**< Number of RX queues. */
1547d30ea906Sjfb8856606 	uint16_t nb_tx_queues; /**< Number of TX queues. */
1548d30ea906Sjfb8856606 	/** Rx parameter recommendations */
1549d30ea906Sjfb8856606 	struct rte_eth_dev_portconf default_rxportconf;
1550d30ea906Sjfb8856606 	/** Tx parameter recommendations */
1551d30ea906Sjfb8856606 	struct rte_eth_dev_portconf default_txportconf;
1552d30ea906Sjfb8856606 	/** Generic device capabilities (RTE_ETH_DEV_CAPA_). */
1553d30ea906Sjfb8856606 	uint64_t dev_capa;
1554d30ea906Sjfb8856606 	/**
1555d30ea906Sjfb8856606 	 * Switching information for ports on a device with a
1556d30ea906Sjfb8856606 	 * embedded managed interconnect/switch.
1557d30ea906Sjfb8856606 	 */
1558d30ea906Sjfb8856606 	struct rte_eth_switch_info switch_info;
15594418919fSjohnjiang 
15604418919fSjohnjiang 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
15614418919fSjohnjiang 	void *reserved_ptrs[2];   /**< Reserved for future fields */
1562d30ea906Sjfb8856606 };
1563d30ea906Sjfb8856606 
1564d30ea906Sjfb8856606 /**
1565d30ea906Sjfb8856606  * Ethernet device RX queue information structure.
15661646932aSjfb8856606  * Used to retrieve information about configured queue.
1567d30ea906Sjfb8856606  */
1568d30ea906Sjfb8856606 struct rte_eth_rxq_info {
1569d30ea906Sjfb8856606 	struct rte_mempool *mp;     /**< mempool used by that queue. */
1570d30ea906Sjfb8856606 	struct rte_eth_rxconf conf; /**< queue config parameters. */
1571d30ea906Sjfb8856606 	uint8_t scattered_rx;       /**< scattered packets RX supported. */
1572d30ea906Sjfb8856606 	uint16_t nb_desc;           /**< configured number of RXDs. */
1573*2d9fd380Sjfb8856606 	uint16_t rx_buf_size;       /**< hardware receive buffer size. */
1574d30ea906Sjfb8856606 } __rte_cache_min_aligned;
1575d30ea906Sjfb8856606 
1576d30ea906Sjfb8856606 /**
1577d30ea906Sjfb8856606  * Ethernet device TX queue information structure.
1578d30ea906Sjfb8856606  * Used to retrieve information about configured queue.
1579d30ea906Sjfb8856606  */
1580d30ea906Sjfb8856606 struct rte_eth_txq_info {
1581d30ea906Sjfb8856606 	struct rte_eth_txconf conf; /**< queue config parameters. */
1582d30ea906Sjfb8856606 	uint16_t nb_desc;           /**< configured number of TXDs. */
1583d30ea906Sjfb8856606 } __rte_cache_min_aligned;
1584d30ea906Sjfb8856606 
15854418919fSjohnjiang /* Generic Burst mode flag definition, values can be ORed. */
15864418919fSjohnjiang 
15874418919fSjohnjiang /**
15884418919fSjohnjiang  * If the queues have different burst mode description, this bit will be set
15894418919fSjohnjiang  * by PMD, then the application can iterate to retrieve burst description for
15904418919fSjohnjiang  * all other queues.
15914418919fSjohnjiang  */
15924418919fSjohnjiang #define RTE_ETH_BURST_FLAG_PER_QUEUE     (1ULL << 0)
15934418919fSjohnjiang 
15944418919fSjohnjiang /**
15954418919fSjohnjiang  * Ethernet device RX/TX queue packet burst mode information structure.
15964418919fSjohnjiang  * Used to retrieve information about packet burst mode setting.
15974418919fSjohnjiang  */
15984418919fSjohnjiang struct rte_eth_burst_mode {
15994418919fSjohnjiang 	uint64_t flags; /**< The ORed values of RTE_ETH_BURST_FLAG_xxx */
16004418919fSjohnjiang 
16014418919fSjohnjiang #define RTE_ETH_BURST_MODE_INFO_SIZE 1024 /**< Maximum size for information */
16024418919fSjohnjiang 	char info[RTE_ETH_BURST_MODE_INFO_SIZE]; /**< burst mode information */
16034418919fSjohnjiang };
16044418919fSjohnjiang 
1605d30ea906Sjfb8856606 /** Maximum name length for extended statistics counters */
1606d30ea906Sjfb8856606 #define RTE_ETH_XSTATS_NAME_SIZE 64
1607d30ea906Sjfb8856606 
1608d30ea906Sjfb8856606 /**
1609d30ea906Sjfb8856606  * An Ethernet device extended statistic structure
1610d30ea906Sjfb8856606  *
1611d30ea906Sjfb8856606  * This structure is used by rte_eth_xstats_get() to provide
1612d30ea906Sjfb8856606  * statistics that are not provided in the generic *rte_eth_stats*
1613d30ea906Sjfb8856606  * structure.
1614d30ea906Sjfb8856606  * It maps a name id, corresponding to an index in the array returned
1615d30ea906Sjfb8856606  * by rte_eth_xstats_get_names(), to a statistic value.
1616d30ea906Sjfb8856606  */
1617d30ea906Sjfb8856606 struct rte_eth_xstat {
1618d30ea906Sjfb8856606 	uint64_t id;        /**< The index in xstats name array. */
1619d30ea906Sjfb8856606 	uint64_t value;     /**< The statistic counter value. */
1620d30ea906Sjfb8856606 };
1621d30ea906Sjfb8856606 
1622d30ea906Sjfb8856606 /**
1623d30ea906Sjfb8856606  * A name element for extended statistics.
1624d30ea906Sjfb8856606  *
1625d30ea906Sjfb8856606  * An array of this structure is returned by rte_eth_xstats_get_names().
1626d30ea906Sjfb8856606  * It lists the names of extended statistics for a PMD. The *rte_eth_xstat*
1627d30ea906Sjfb8856606  * structure references these names by their array index.
1628*2d9fd380Sjfb8856606  *
1629*2d9fd380Sjfb8856606  * The xstats should follow a common naming scheme.
1630*2d9fd380Sjfb8856606  * Some names are standardized in rte_stats_strings.
1631*2d9fd380Sjfb8856606  * Examples:
1632*2d9fd380Sjfb8856606  *     - rx_missed_errors
1633*2d9fd380Sjfb8856606  *     - tx_q3_bytes
1634*2d9fd380Sjfb8856606  *     - tx_size_128_to_255_packets
1635d30ea906Sjfb8856606  */
1636d30ea906Sjfb8856606 struct rte_eth_xstat_name {
1637d30ea906Sjfb8856606 	char name[RTE_ETH_XSTATS_NAME_SIZE]; /**< The statistic name. */
1638d30ea906Sjfb8856606 };
1639d30ea906Sjfb8856606 
1640d30ea906Sjfb8856606 #define ETH_DCB_NUM_TCS    8
1641d30ea906Sjfb8856606 #define ETH_MAX_VMDQ_POOL  64
1642d30ea906Sjfb8856606 
1643d30ea906Sjfb8856606 /**
1644d30ea906Sjfb8856606  * A structure used to get the information of queue and
1645d30ea906Sjfb8856606  * TC mapping on both TX and RX paths.
1646d30ea906Sjfb8856606  */
1647d30ea906Sjfb8856606 struct rte_eth_dcb_tc_queue_mapping {
1648d30ea906Sjfb8856606 	/** rx queues assigned to tc per Pool */
1649d30ea906Sjfb8856606 	struct {
1650*2d9fd380Sjfb8856606 		uint16_t base;
1651*2d9fd380Sjfb8856606 		uint16_t nb_queue;
1652d30ea906Sjfb8856606 	} tc_rxq[ETH_MAX_VMDQ_POOL][ETH_DCB_NUM_TCS];
1653d30ea906Sjfb8856606 	/** rx queues assigned to tc per Pool */
1654d30ea906Sjfb8856606 	struct {
1655*2d9fd380Sjfb8856606 		uint16_t base;
1656*2d9fd380Sjfb8856606 		uint16_t nb_queue;
1657d30ea906Sjfb8856606 	} tc_txq[ETH_MAX_VMDQ_POOL][ETH_DCB_NUM_TCS];
1658d30ea906Sjfb8856606 };
1659d30ea906Sjfb8856606 
1660d30ea906Sjfb8856606 /**
1661d30ea906Sjfb8856606  * A structure used to get the information of DCB.
1662d30ea906Sjfb8856606  * It includes TC UP mapping and queue TC mapping.
1663d30ea906Sjfb8856606  */
1664d30ea906Sjfb8856606 struct rte_eth_dcb_info {
1665d30ea906Sjfb8856606 	uint8_t nb_tcs;        /**< number of TCs */
1666d30ea906Sjfb8856606 	uint8_t prio_tc[ETH_DCB_NUM_USER_PRIORITIES]; /**< Priority to tc */
1667d30ea906Sjfb8856606 	uint8_t tc_bws[ETH_DCB_NUM_TCS]; /**< TX BW percentage for each TC */
1668d30ea906Sjfb8856606 	/** rx queues assigned to tc */
1669d30ea906Sjfb8856606 	struct rte_eth_dcb_tc_queue_mapping tc_queue;
1670d30ea906Sjfb8856606 };
1671d30ea906Sjfb8856606 
1672*2d9fd380Sjfb8856606 /**
1673*2d9fd380Sjfb8856606  * This enum indicates the possible Forward Error Correction (FEC) modes
1674*2d9fd380Sjfb8856606  * of an ethdev port.
1675*2d9fd380Sjfb8856606  */
1676*2d9fd380Sjfb8856606 enum rte_eth_fec_mode {
1677*2d9fd380Sjfb8856606 	RTE_ETH_FEC_NOFEC = 0,      /**< FEC is off */
1678*2d9fd380Sjfb8856606 	RTE_ETH_FEC_AUTO,	    /**< FEC autonegotiation modes */
1679*2d9fd380Sjfb8856606 	RTE_ETH_FEC_BASER,          /**< FEC using common algorithm */
1680*2d9fd380Sjfb8856606 	RTE_ETH_FEC_RS,             /**< FEC using RS algorithm */
1681*2d9fd380Sjfb8856606 };
1682*2d9fd380Sjfb8856606 
1683*2d9fd380Sjfb8856606 /* Translate from FEC mode to FEC capa */
1684*2d9fd380Sjfb8856606 #define RTE_ETH_FEC_MODE_TO_CAPA(x)	(1U << (x))
1685*2d9fd380Sjfb8856606 
1686*2d9fd380Sjfb8856606 /* This macro indicates FEC capa mask */
1687*2d9fd380Sjfb8856606 #define RTE_ETH_FEC_MODE_CAPA_MASK(x)	(1U << (RTE_ETH_FEC_ ## x))
1688*2d9fd380Sjfb8856606 
1689*2d9fd380Sjfb8856606 /* A structure used to get capabilities per link speed */
1690*2d9fd380Sjfb8856606 struct rte_eth_fec_capa {
1691*2d9fd380Sjfb8856606 	uint32_t speed; /**< Link speed (see ETH_SPEED_NUM_*) */
1692*2d9fd380Sjfb8856606 	uint32_t capa;  /**< FEC capabilities bitmask */
1693*2d9fd380Sjfb8856606 };
1694*2d9fd380Sjfb8856606 
1695d30ea906Sjfb8856606 #define RTE_ETH_ALL RTE_MAX_ETHPORTS
1696d30ea906Sjfb8856606 
1697d30ea906Sjfb8856606 /* Macros to check for valid port */
1698d30ea906Sjfb8856606 #define RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, retval) do { \
1699d30ea906Sjfb8856606 	if (!rte_eth_dev_is_valid_port(port_id)) { \
1700d30ea906Sjfb8856606 		RTE_ETHDEV_LOG(ERR, "Invalid port_id=%u\n", port_id); \
1701d30ea906Sjfb8856606 		return retval; \
1702d30ea906Sjfb8856606 	} \
1703d30ea906Sjfb8856606 } while (0)
1704d30ea906Sjfb8856606 
1705d30ea906Sjfb8856606 #define RTE_ETH_VALID_PORTID_OR_RET(port_id) do { \
1706d30ea906Sjfb8856606 	if (!rte_eth_dev_is_valid_port(port_id)) { \
1707d30ea906Sjfb8856606 		RTE_ETHDEV_LOG(ERR, "Invalid port_id=%u\n", port_id); \
1708d30ea906Sjfb8856606 		return; \
1709d30ea906Sjfb8856606 	} \
1710d30ea906Sjfb8856606 } while (0)
1711d30ea906Sjfb8856606 
1712d30ea906Sjfb8856606 /**
1713d30ea906Sjfb8856606  * l2 tunnel configuration.
1714d30ea906Sjfb8856606  */
1715d30ea906Sjfb8856606 
1716d30ea906Sjfb8856606 /**< l2 tunnel enable mask */
1717d30ea906Sjfb8856606 #define ETH_L2_TUNNEL_ENABLE_MASK       0x00000001
1718d30ea906Sjfb8856606 /**< l2 tunnel insertion mask */
1719d30ea906Sjfb8856606 #define ETH_L2_TUNNEL_INSERTION_MASK    0x00000002
1720d30ea906Sjfb8856606 /**< l2 tunnel stripping mask */
1721d30ea906Sjfb8856606 #define ETH_L2_TUNNEL_STRIPPING_MASK    0x00000004
1722d30ea906Sjfb8856606 /**< l2 tunnel forwarding mask */
1723d30ea906Sjfb8856606 #define ETH_L2_TUNNEL_FORWARDING_MASK   0x00000008
1724d30ea906Sjfb8856606 
1725d30ea906Sjfb8856606 /**
1726d30ea906Sjfb8856606  * Function type used for RX packet processing packet callbacks.
1727d30ea906Sjfb8856606  *
1728d30ea906Sjfb8856606  * The callback function is called on RX with a burst of packets that have
1729d30ea906Sjfb8856606  * been received on the given port and queue.
1730d30ea906Sjfb8856606  *
1731d30ea906Sjfb8856606  * @param port_id
1732d30ea906Sjfb8856606  *   The Ethernet port on which RX is being performed.
1733d30ea906Sjfb8856606  * @param queue
1734d30ea906Sjfb8856606  *   The queue on the Ethernet port which is being used to receive the packets.
1735d30ea906Sjfb8856606  * @param pkts
1736d30ea906Sjfb8856606  *   The burst of packets that have just been received.
1737d30ea906Sjfb8856606  * @param nb_pkts
1738d30ea906Sjfb8856606  *   The number of packets in the burst pointed to by "pkts".
1739d30ea906Sjfb8856606  * @param max_pkts
1740d30ea906Sjfb8856606  *   The max number of packets that can be stored in the "pkts" array.
1741d30ea906Sjfb8856606  * @param user_param
1742d30ea906Sjfb8856606  *   The arbitrary user parameter passed in by the application when the callback
1743d30ea906Sjfb8856606  *   was originally configured.
1744d30ea906Sjfb8856606  * @return
1745d30ea906Sjfb8856606  *   The number of packets returned to the user.
1746d30ea906Sjfb8856606  */
1747d30ea906Sjfb8856606 typedef uint16_t (*rte_rx_callback_fn)(uint16_t port_id, uint16_t queue,
1748d30ea906Sjfb8856606 	struct rte_mbuf *pkts[], uint16_t nb_pkts, uint16_t max_pkts,
1749d30ea906Sjfb8856606 	void *user_param);
1750d30ea906Sjfb8856606 
1751d30ea906Sjfb8856606 /**
1752d30ea906Sjfb8856606  * Function type used for TX packet processing packet callbacks.
1753d30ea906Sjfb8856606  *
1754d30ea906Sjfb8856606  * The callback function is called on TX with a burst of packets immediately
1755d30ea906Sjfb8856606  * before the packets are put onto the hardware queue for transmission.
1756d30ea906Sjfb8856606  *
1757d30ea906Sjfb8856606  * @param port_id
1758d30ea906Sjfb8856606  *   The Ethernet port on which TX is being performed.
1759d30ea906Sjfb8856606  * @param queue
1760d30ea906Sjfb8856606  *   The queue on the Ethernet port which is being used to transmit the packets.
1761d30ea906Sjfb8856606  * @param pkts
1762d30ea906Sjfb8856606  *   The burst of packets that are about to be transmitted.
1763d30ea906Sjfb8856606  * @param nb_pkts
1764d30ea906Sjfb8856606  *   The number of packets in the burst pointed to by "pkts".
1765d30ea906Sjfb8856606  * @param user_param
1766d30ea906Sjfb8856606  *   The arbitrary user parameter passed in by the application when the callback
1767d30ea906Sjfb8856606  *   was originally configured.
1768d30ea906Sjfb8856606  * @return
1769d30ea906Sjfb8856606  *   The number of packets to be written to the NIC.
1770d30ea906Sjfb8856606  */
1771d30ea906Sjfb8856606 typedef uint16_t (*rte_tx_callback_fn)(uint16_t port_id, uint16_t queue,
1772d30ea906Sjfb8856606 	struct rte_mbuf *pkts[], uint16_t nb_pkts, void *user_param);
1773d30ea906Sjfb8856606 
1774d30ea906Sjfb8856606 /**
1775d30ea906Sjfb8856606  * Possible states of an ethdev port.
1776d30ea906Sjfb8856606  */
1777d30ea906Sjfb8856606 enum rte_eth_dev_state {
1778d30ea906Sjfb8856606 	/** Device is unused before being probed. */
1779d30ea906Sjfb8856606 	RTE_ETH_DEV_UNUSED = 0,
1780d30ea906Sjfb8856606 	/** Device is attached when allocated in probing. */
1781d30ea906Sjfb8856606 	RTE_ETH_DEV_ATTACHED,
1782d30ea906Sjfb8856606 	/** Device is in removed state when plug-out is detected. */
1783d30ea906Sjfb8856606 	RTE_ETH_DEV_REMOVED,
1784d30ea906Sjfb8856606 };
1785d30ea906Sjfb8856606 
1786d30ea906Sjfb8856606 struct rte_eth_dev_sriov {
1787d30ea906Sjfb8856606 	uint8_t active;               /**< SRIOV is active with 16, 32 or 64 pools */
1788d30ea906Sjfb8856606 	uint8_t nb_q_per_pool;        /**< rx queue number per pool */
1789d30ea906Sjfb8856606 	uint16_t def_vmdq_idx;        /**< Default pool num used for PF */
1790d30ea906Sjfb8856606 	uint16_t def_pool_q_idx;      /**< Default pool queue start reg index */
1791d30ea906Sjfb8856606 };
1792d30ea906Sjfb8856606 #define RTE_ETH_DEV_SRIOV(dev)         ((dev)->data->sriov)
1793d30ea906Sjfb8856606 
1794d30ea906Sjfb8856606 #define RTE_ETH_NAME_MAX_LEN RTE_DEV_NAME_MAX_LEN
1795d30ea906Sjfb8856606 
1796d30ea906Sjfb8856606 #define RTE_ETH_DEV_NO_OWNER 0
1797d30ea906Sjfb8856606 
1798d30ea906Sjfb8856606 #define RTE_ETH_MAX_OWNER_NAME_LEN 64
1799d30ea906Sjfb8856606 
1800d30ea906Sjfb8856606 struct rte_eth_dev_owner {
1801d30ea906Sjfb8856606 	uint64_t id; /**< The owner unique identifier. */
1802d30ea906Sjfb8856606 	char name[RTE_ETH_MAX_OWNER_NAME_LEN]; /**< The owner name. */
1803d30ea906Sjfb8856606 };
1804d30ea906Sjfb8856606 
1805*2d9fd380Sjfb8856606 /** PMD supports thread-safe flow operations */
1806*2d9fd380Sjfb8856606 #define RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE  0x0001
1807d30ea906Sjfb8856606 /** Device supports link state interrupt */
1808d30ea906Sjfb8856606 #define RTE_ETH_DEV_INTR_LSC     0x0002
1809d30ea906Sjfb8856606 /** Device is a bonded slave */
1810d30ea906Sjfb8856606 #define RTE_ETH_DEV_BONDED_SLAVE 0x0004
1811d30ea906Sjfb8856606 /** Device supports device removal interrupt */
1812d30ea906Sjfb8856606 #define RTE_ETH_DEV_INTR_RMV     0x0008
1813d30ea906Sjfb8856606 /** Device is port representor */
1814d30ea906Sjfb8856606 #define RTE_ETH_DEV_REPRESENTOR  0x0010
1815d30ea906Sjfb8856606 /** Device does not support MAC change after started */
1816d30ea906Sjfb8856606 #define RTE_ETH_DEV_NOLIVE_MAC_ADDR  0x0020
1817*2d9fd380Sjfb8856606 /**
1818*2d9fd380Sjfb8856606  * Queue xstats filled automatically by ethdev layer.
1819*2d9fd380Sjfb8856606  * PMDs filling the queue xstats themselves should not set this flag
1820*2d9fd380Sjfb8856606  */
1821*2d9fd380Sjfb8856606 #define RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS 0x0040
1822d30ea906Sjfb8856606 
1823d30ea906Sjfb8856606 /**
1824d30ea906Sjfb8856606  * Iterates over valid ethdev ports owned by a specific owner.
1825d30ea906Sjfb8856606  *
1826d30ea906Sjfb8856606  * @param port_id
1827d30ea906Sjfb8856606  *   The id of the next possible valid owned port.
1828d30ea906Sjfb8856606  * @param	owner_id
1829d30ea906Sjfb8856606  *  The owner identifier.
1830d30ea906Sjfb8856606  *  RTE_ETH_DEV_NO_OWNER means iterate over all valid ownerless ports.
1831d30ea906Sjfb8856606  * @return
1832d30ea906Sjfb8856606  *   Next valid port id owned by owner_id, RTE_MAX_ETHPORTS if there is none.
1833d30ea906Sjfb8856606  */
1834d30ea906Sjfb8856606 uint64_t rte_eth_find_next_owned_by(uint16_t port_id,
1835d30ea906Sjfb8856606 		const uint64_t owner_id);
1836d30ea906Sjfb8856606 
1837d30ea906Sjfb8856606 /**
1838d30ea906Sjfb8856606  * Macro to iterate over all enabled ethdev ports owned by a specific owner.
1839d30ea906Sjfb8856606  */
1840d30ea906Sjfb8856606 #define RTE_ETH_FOREACH_DEV_OWNED_BY(p, o) \
1841d30ea906Sjfb8856606 	for (p = rte_eth_find_next_owned_by(0, o); \
1842d30ea906Sjfb8856606 	     (unsigned int)p < (unsigned int)RTE_MAX_ETHPORTS; \
1843d30ea906Sjfb8856606 	     p = rte_eth_find_next_owned_by(p + 1, o))
1844d30ea906Sjfb8856606 
1845d30ea906Sjfb8856606 /**
1846d30ea906Sjfb8856606  * Iterates over valid ethdev ports.
1847d30ea906Sjfb8856606  *
1848d30ea906Sjfb8856606  * @param port_id
1849d30ea906Sjfb8856606  *   The id of the next possible valid port.
1850d30ea906Sjfb8856606  * @return
1851d30ea906Sjfb8856606  *   Next valid port id, RTE_MAX_ETHPORTS if there is none.
1852d30ea906Sjfb8856606  */
1853d30ea906Sjfb8856606 uint16_t rte_eth_find_next(uint16_t port_id);
1854d30ea906Sjfb8856606 
1855d30ea906Sjfb8856606 /**
1856d30ea906Sjfb8856606  * Macro to iterate over all enabled and ownerless ethdev ports.
1857d30ea906Sjfb8856606  */
1858d30ea906Sjfb8856606 #define RTE_ETH_FOREACH_DEV(p) \
1859d30ea906Sjfb8856606 	RTE_ETH_FOREACH_DEV_OWNED_BY(p, RTE_ETH_DEV_NO_OWNER)
1860d30ea906Sjfb8856606 
18614418919fSjohnjiang /**
18624418919fSjohnjiang  * @warning
18634418919fSjohnjiang  * @b EXPERIMENTAL: this API may change without prior notice.
18644418919fSjohnjiang  *
18654418919fSjohnjiang  * Iterates over ethdev ports of a specified device.
18664418919fSjohnjiang  *
18674418919fSjohnjiang  * @param port_id_start
18684418919fSjohnjiang  *   The id of the next possible valid port.
18694418919fSjohnjiang  * @param parent
18704418919fSjohnjiang  *   The generic device behind the ports to iterate.
18714418919fSjohnjiang  * @return
18724418919fSjohnjiang  *   Next port id of the device, possibly port_id_start,
18734418919fSjohnjiang  *   RTE_MAX_ETHPORTS if there is none.
18744418919fSjohnjiang  */
18754418919fSjohnjiang __rte_experimental
18764418919fSjohnjiang uint16_t
18774418919fSjohnjiang rte_eth_find_next_of(uint16_t port_id_start,
18784418919fSjohnjiang 		const struct rte_device *parent);
18794418919fSjohnjiang 
18804418919fSjohnjiang /**
18814418919fSjohnjiang  * Macro to iterate over all ethdev ports of a specified device.
18824418919fSjohnjiang  *
18834418919fSjohnjiang  * @param port_id
18844418919fSjohnjiang  *   The id of the matching port being iterated.
18854418919fSjohnjiang  * @param parent
18864418919fSjohnjiang  *   The rte_device pointer matching the iterated ports.
18874418919fSjohnjiang  */
18884418919fSjohnjiang #define RTE_ETH_FOREACH_DEV_OF(port_id, parent) \
18894418919fSjohnjiang 	for (port_id = rte_eth_find_next_of(0, parent); \
18904418919fSjohnjiang 		port_id < RTE_MAX_ETHPORTS; \
18914418919fSjohnjiang 		port_id = rte_eth_find_next_of(port_id + 1, parent))
18924418919fSjohnjiang 
18934418919fSjohnjiang /**
18944418919fSjohnjiang  * @warning
18954418919fSjohnjiang  * @b EXPERIMENTAL: this API may change without prior notice.
18964418919fSjohnjiang  *
18974418919fSjohnjiang  * Iterates over sibling ethdev ports (i.e. sharing the same rte_device).
18984418919fSjohnjiang  *
18994418919fSjohnjiang  * @param port_id_start
19004418919fSjohnjiang  *   The id of the next possible valid sibling port.
19014418919fSjohnjiang  * @param ref_port_id
19024418919fSjohnjiang  *   The id of a reference port to compare rte_device with.
19034418919fSjohnjiang  * @return
19044418919fSjohnjiang  *   Next sibling port id, possibly port_id_start or ref_port_id itself,
19054418919fSjohnjiang  *   RTE_MAX_ETHPORTS if there is none.
19064418919fSjohnjiang  */
19074418919fSjohnjiang __rte_experimental
19084418919fSjohnjiang uint16_t
1909*2d9fd380Sjfb8856606 rte_eth_find_next_sibling(uint16_t port_id_start, uint16_t ref_port_id);
19104418919fSjohnjiang 
19114418919fSjohnjiang /**
19124418919fSjohnjiang  * Macro to iterate over all ethdev ports sharing the same rte_device
19134418919fSjohnjiang  * as the specified port.
19144418919fSjohnjiang  * Note: the specified reference port is part of the loop iterations.
19154418919fSjohnjiang  *
19164418919fSjohnjiang  * @param port_id
19174418919fSjohnjiang  *   The id of the matching port being iterated.
19184418919fSjohnjiang  * @param ref_port_id
19194418919fSjohnjiang  *   The id of the port being compared.
19204418919fSjohnjiang  */
19214418919fSjohnjiang #define RTE_ETH_FOREACH_DEV_SIBLING(port_id, ref_port_id) \
19224418919fSjohnjiang 	for (port_id = rte_eth_find_next_sibling(0, ref_port_id); \
19234418919fSjohnjiang 		port_id < RTE_MAX_ETHPORTS; \
19244418919fSjohnjiang 		port_id = rte_eth_find_next_sibling(port_id + 1, ref_port_id))
1925d30ea906Sjfb8856606 
1926d30ea906Sjfb8856606 /**
1927d30ea906Sjfb8856606  * @warning
1928d30ea906Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
1929d30ea906Sjfb8856606  *
1930d30ea906Sjfb8856606  * Get a new unique owner identifier.
1931d30ea906Sjfb8856606  * An owner identifier is used to owns Ethernet devices by only one DPDK entity
1932d30ea906Sjfb8856606  * to avoid multiple management of device by different entities.
1933d30ea906Sjfb8856606  *
1934d30ea906Sjfb8856606  * @param	owner_id
1935d30ea906Sjfb8856606  *   Owner identifier pointer.
1936d30ea906Sjfb8856606  * @return
1937d30ea906Sjfb8856606  *   Negative errno value on error, 0 on success.
1938d30ea906Sjfb8856606  */
19394418919fSjohnjiang __rte_experimental
19404418919fSjohnjiang int rte_eth_dev_owner_new(uint64_t *owner_id);
1941d30ea906Sjfb8856606 
1942d30ea906Sjfb8856606 /**
1943d30ea906Sjfb8856606  * @warning
1944d30ea906Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
1945d30ea906Sjfb8856606  *
1946d30ea906Sjfb8856606  * Set an Ethernet device owner.
1947d30ea906Sjfb8856606  *
1948d30ea906Sjfb8856606  * @param	port_id
1949d30ea906Sjfb8856606  *  The identifier of the port to own.
1950d30ea906Sjfb8856606  * @param	owner
1951d30ea906Sjfb8856606  *  The owner pointer.
1952d30ea906Sjfb8856606  * @return
1953d30ea906Sjfb8856606  *  Negative errno value on error, 0 on success.
1954d30ea906Sjfb8856606  */
19554418919fSjohnjiang __rte_experimental
19564418919fSjohnjiang int rte_eth_dev_owner_set(const uint16_t port_id,
1957d30ea906Sjfb8856606 		const struct rte_eth_dev_owner *owner);
1958d30ea906Sjfb8856606 
1959d30ea906Sjfb8856606 /**
1960d30ea906Sjfb8856606  * @warning
1961d30ea906Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
1962d30ea906Sjfb8856606  *
1963d30ea906Sjfb8856606  * Unset Ethernet device owner to make the device ownerless.
1964d30ea906Sjfb8856606  *
1965d30ea906Sjfb8856606  * @param	port_id
1966d30ea906Sjfb8856606  *  The identifier of port to make ownerless.
1967d30ea906Sjfb8856606  * @param	owner_id
1968d30ea906Sjfb8856606  *  The owner identifier.
1969d30ea906Sjfb8856606  * @return
1970d30ea906Sjfb8856606  *  0 on success, negative errno value on error.
1971d30ea906Sjfb8856606  */
19724418919fSjohnjiang __rte_experimental
19734418919fSjohnjiang int rte_eth_dev_owner_unset(const uint16_t port_id,
1974d30ea906Sjfb8856606 		const uint64_t owner_id);
1975d30ea906Sjfb8856606 
1976d30ea906Sjfb8856606 /**
1977d30ea906Sjfb8856606  * @warning
1978d30ea906Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
1979d30ea906Sjfb8856606  *
1980d30ea906Sjfb8856606  * Remove owner from all Ethernet devices owned by a specific owner.
1981d30ea906Sjfb8856606  *
1982d30ea906Sjfb8856606  * @param	owner_id
1983d30ea906Sjfb8856606  *  The owner identifier.
19844418919fSjohnjiang  * @return
19854418919fSjohnjiang  *  0 on success, negative errno value on error.
1986d30ea906Sjfb8856606  */
19874418919fSjohnjiang __rte_experimental
19884418919fSjohnjiang int rte_eth_dev_owner_delete(const uint64_t owner_id);
1989d30ea906Sjfb8856606 
1990d30ea906Sjfb8856606 /**
1991d30ea906Sjfb8856606  * @warning
1992d30ea906Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
1993d30ea906Sjfb8856606  *
1994d30ea906Sjfb8856606  * Get the owner of an Ethernet device.
1995d30ea906Sjfb8856606  *
1996d30ea906Sjfb8856606  * @param	port_id
1997d30ea906Sjfb8856606  *  The port identifier.
1998d30ea906Sjfb8856606  * @param	owner
1999d30ea906Sjfb8856606  *  The owner structure pointer to fill.
2000d30ea906Sjfb8856606  * @return
2001d30ea906Sjfb8856606  *  0 on success, negative errno value on error..
2002d30ea906Sjfb8856606  */
20034418919fSjohnjiang __rte_experimental
20044418919fSjohnjiang int rte_eth_dev_owner_get(const uint16_t port_id,
2005d30ea906Sjfb8856606 		struct rte_eth_dev_owner *owner);
2006d30ea906Sjfb8856606 
2007d30ea906Sjfb8856606 /**
2008d30ea906Sjfb8856606  * Get the number of ports which are usable for the application.
2009d30ea906Sjfb8856606  *
2010d30ea906Sjfb8856606  * These devices must be iterated by using the macro
2011d30ea906Sjfb8856606  * ``RTE_ETH_FOREACH_DEV`` or ``RTE_ETH_FOREACH_DEV_OWNED_BY``
2012d30ea906Sjfb8856606  * to deal with non-contiguous ranges of devices.
2013d30ea906Sjfb8856606  *
2014d30ea906Sjfb8856606  * @return
2015d30ea906Sjfb8856606  *   The count of available Ethernet devices.
2016d30ea906Sjfb8856606  */
2017d30ea906Sjfb8856606 uint16_t rte_eth_dev_count_avail(void);
2018d30ea906Sjfb8856606 
2019d30ea906Sjfb8856606 /**
2020d30ea906Sjfb8856606  * Get the total number of ports which are allocated.
2021d30ea906Sjfb8856606  *
2022d30ea906Sjfb8856606  * Some devices may not be available for the application.
2023d30ea906Sjfb8856606  *
2024d30ea906Sjfb8856606  * @return
2025d30ea906Sjfb8856606  *   The total count of Ethernet devices.
2026d30ea906Sjfb8856606  */
20274418919fSjohnjiang uint16_t rte_eth_dev_count_total(void);
2028d30ea906Sjfb8856606 
2029d30ea906Sjfb8856606 /**
2030d30ea906Sjfb8856606  * Convert a numerical speed in Mbps to a bitmap flag that can be used in
2031d30ea906Sjfb8856606  * the bitmap link_speeds of the struct rte_eth_conf
2032d30ea906Sjfb8856606  *
2033d30ea906Sjfb8856606  * @param speed
2034d30ea906Sjfb8856606  *   Numerical speed value in Mbps
2035d30ea906Sjfb8856606  * @param duplex
2036d30ea906Sjfb8856606  *   ETH_LINK_[HALF/FULL]_DUPLEX (only for 10/100M speeds)
2037d30ea906Sjfb8856606  * @return
2038d30ea906Sjfb8856606  *   0 if the speed cannot be mapped
2039d30ea906Sjfb8856606  */
2040d30ea906Sjfb8856606 uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex);
2041d30ea906Sjfb8856606 
2042d30ea906Sjfb8856606 /**
2043d30ea906Sjfb8856606  * Get DEV_RX_OFFLOAD_* flag name.
2044d30ea906Sjfb8856606  *
2045d30ea906Sjfb8856606  * @param offload
2046d30ea906Sjfb8856606  *   Offload flag.
2047d30ea906Sjfb8856606  * @return
2048d30ea906Sjfb8856606  *   Offload name or 'UNKNOWN' if the flag cannot be recognised.
2049d30ea906Sjfb8856606  */
2050d30ea906Sjfb8856606 const char *rte_eth_dev_rx_offload_name(uint64_t offload);
2051d30ea906Sjfb8856606 
2052d30ea906Sjfb8856606 /**
2053d30ea906Sjfb8856606  * Get DEV_TX_OFFLOAD_* flag name.
2054d30ea906Sjfb8856606  *
2055d30ea906Sjfb8856606  * @param offload
2056d30ea906Sjfb8856606  *   Offload flag.
2057d30ea906Sjfb8856606  * @return
2058d30ea906Sjfb8856606  *   Offload name or 'UNKNOWN' if the flag cannot be recognised.
2059d30ea906Sjfb8856606  */
2060d30ea906Sjfb8856606 const char *rte_eth_dev_tx_offload_name(uint64_t offload);
2061d30ea906Sjfb8856606 
2062d30ea906Sjfb8856606 /**
2063d30ea906Sjfb8856606  * Configure an Ethernet device.
2064d30ea906Sjfb8856606  * This function must be invoked first before any other function in the
2065d30ea906Sjfb8856606  * Ethernet API. This function can also be re-invoked when a device is in the
2066d30ea906Sjfb8856606  * stopped state.
2067d30ea906Sjfb8856606  *
2068d30ea906Sjfb8856606  * @param port_id
2069d30ea906Sjfb8856606  *   The port identifier of the Ethernet device to configure.
2070d30ea906Sjfb8856606  * @param nb_rx_queue
2071d30ea906Sjfb8856606  *   The number of receive queues to set up for the Ethernet device.
2072d30ea906Sjfb8856606  * @param nb_tx_queue
2073d30ea906Sjfb8856606  *   The number of transmit queues to set up for the Ethernet device.
2074d30ea906Sjfb8856606  * @param eth_conf
2075d30ea906Sjfb8856606  *   The pointer to the configuration data to be used for the Ethernet device.
2076d30ea906Sjfb8856606  *   The *rte_eth_conf* structure includes:
2077d30ea906Sjfb8856606  *     -  the hardware offload features to activate, with dedicated fields for
2078d30ea906Sjfb8856606  *        each statically configurable offload hardware feature provided by
2079d30ea906Sjfb8856606  *        Ethernet devices, such as IP checksum or VLAN tag stripping for
2080d30ea906Sjfb8856606  *        example.
2081d30ea906Sjfb8856606  *        The Rx offload bitfield API is obsolete and will be deprecated.
2082d30ea906Sjfb8856606  *        Applications should set the ignore_bitfield_offloads bit on *rxmode*
2083d30ea906Sjfb8856606  *        structure and use offloads field to set per-port offloads instead.
2084d30ea906Sjfb8856606  *     -  Any offloading set in eth_conf->[rt]xmode.offloads must be within
20851646932aSjfb8856606  *        the [rt]x_offload_capa returned from rte_eth_dev_info_get().
2086d30ea906Sjfb8856606  *        Any type of device supported offloading set in the input argument
2087d30ea906Sjfb8856606  *        eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is enabled
2088d30ea906Sjfb8856606  *        on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup()
2089d30ea906Sjfb8856606  *     -  the Receive Side Scaling (RSS) configuration when using multiple RX
2090d30ea906Sjfb8856606  *        queues per port. Any RSS hash function set in eth_conf->rss_conf.rss_hf
2091d30ea906Sjfb8856606  *        must be within the flow_type_rss_offloads provided by drivers via
20921646932aSjfb8856606  *        rte_eth_dev_info_get() API.
2093d30ea906Sjfb8856606  *
2094d30ea906Sjfb8856606  *   Embedding all configuration information in a single data structure
2095d30ea906Sjfb8856606  *   is the more flexible method that allows the addition of new features
2096d30ea906Sjfb8856606  *   without changing the syntax of the API.
2097d30ea906Sjfb8856606  * @return
2098d30ea906Sjfb8856606  *   - 0: Success, device configured.
2099d30ea906Sjfb8856606  *   - <0: Error code returned by the driver configuration function.
2100d30ea906Sjfb8856606  */
2101d30ea906Sjfb8856606 int rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_queue,
2102d30ea906Sjfb8856606 		uint16_t nb_tx_queue, const struct rte_eth_conf *eth_conf);
2103d30ea906Sjfb8856606 
2104d30ea906Sjfb8856606 /**
2105d30ea906Sjfb8856606  * @warning
2106d30ea906Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
2107d30ea906Sjfb8856606  *
2108d30ea906Sjfb8856606  * Check if an Ethernet device was physically removed.
2109d30ea906Sjfb8856606  *
2110d30ea906Sjfb8856606  * @param port_id
2111d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
2112d30ea906Sjfb8856606  * @return
2113d30ea906Sjfb8856606  *   1 when the Ethernet device is removed, otherwise 0.
2114d30ea906Sjfb8856606  */
21154418919fSjohnjiang __rte_experimental
21164418919fSjohnjiang int
2117d30ea906Sjfb8856606 rte_eth_dev_is_removed(uint16_t port_id);
2118d30ea906Sjfb8856606 
2119d30ea906Sjfb8856606 /**
2120d30ea906Sjfb8856606  * Allocate and set up a receive queue for an Ethernet device.
2121d30ea906Sjfb8856606  *
2122d30ea906Sjfb8856606  * The function allocates a contiguous block of memory for *nb_rx_desc*
2123d30ea906Sjfb8856606  * receive descriptors from a memory zone associated with *socket_id*
2124d30ea906Sjfb8856606  * and initializes each receive descriptor with a network buffer allocated
2125d30ea906Sjfb8856606  * from the memory pool *mb_pool*.
2126d30ea906Sjfb8856606  *
2127d30ea906Sjfb8856606  * @param port_id
2128d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
2129d30ea906Sjfb8856606  * @param rx_queue_id
2130d30ea906Sjfb8856606  *   The index of the receive queue to set up.
2131d30ea906Sjfb8856606  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
2132d30ea906Sjfb8856606  *   to rte_eth_dev_configure().
2133d30ea906Sjfb8856606  * @param nb_rx_desc
2134d30ea906Sjfb8856606  *   The number of receive descriptors to allocate for the receive ring.
2135d30ea906Sjfb8856606  * @param socket_id
2136d30ea906Sjfb8856606  *   The *socket_id* argument is the socket identifier in case of NUMA.
2137d30ea906Sjfb8856606  *   The value can be *SOCKET_ID_ANY* if there is no NUMA constraint for
2138d30ea906Sjfb8856606  *   the DMA memory allocated for the receive descriptors of the ring.
2139d30ea906Sjfb8856606  * @param rx_conf
2140d30ea906Sjfb8856606  *   The pointer to the configuration data to be used for the receive queue.
2141d30ea906Sjfb8856606  *   NULL value is allowed, in which case default RX configuration
2142d30ea906Sjfb8856606  *   will be used.
2143d30ea906Sjfb8856606  *   The *rx_conf* structure contains an *rx_thresh* structure with the values
2144d30ea906Sjfb8856606  *   of the Prefetch, Host, and Write-Back threshold registers of the receive
2145d30ea906Sjfb8856606  *   ring.
2146d30ea906Sjfb8856606  *   In addition it contains the hardware offloads features to activate using
2147d30ea906Sjfb8856606  *   the DEV_RX_OFFLOAD_* flags.
2148d30ea906Sjfb8856606  *   If an offloading set in rx_conf->offloads
2149d30ea906Sjfb8856606  *   hasn't been set in the input argument eth_conf->rxmode.offloads
2150d30ea906Sjfb8856606  *   to rte_eth_dev_configure(), it is a new added offloading, it must be
2151d30ea906Sjfb8856606  *   per-queue type and it is enabled for the queue.
2152d30ea906Sjfb8856606  *   No need to repeat any bit in rx_conf->offloads which has already been
2153d30ea906Sjfb8856606  *   enabled in rte_eth_dev_configure() at port level. An offloading enabled
2154d30ea906Sjfb8856606  *   at port level can't be disabled at queue level.
2155*2d9fd380Sjfb8856606  *   The configuration structure also contains the pointer to the array
2156*2d9fd380Sjfb8856606  *   of the receiving buffer segment descriptions, see rx_seg and rx_nseg
2157*2d9fd380Sjfb8856606  *   fields, this extended configuration might be used by split offloads like
2158*2d9fd380Sjfb8856606  *   RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT. If mp_pool is not NULL,
2159*2d9fd380Sjfb8856606  *   the extended configuration fields must be set to NULL and zero.
2160d30ea906Sjfb8856606  * @param mb_pool
2161d30ea906Sjfb8856606  *   The pointer to the memory pool from which to allocate *rte_mbuf* network
2162*2d9fd380Sjfb8856606  *   memory buffers to populate each descriptor of the receive ring. There are
2163*2d9fd380Sjfb8856606  *   two options to provide Rx buffer configuration:
2164*2d9fd380Sjfb8856606  *   - single pool:
2165*2d9fd380Sjfb8856606  *     mb_pool is not NULL, rx_conf.rx_nseg is 0.
2166*2d9fd380Sjfb8856606  *   - multiple segments description:
2167*2d9fd380Sjfb8856606  *     mb_pool is NULL, rx_conf.rx_seg is not NULL, rx_conf.rx_nseg is not 0.
2168*2d9fd380Sjfb8856606  *     Taken only if flag RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is set in offloads.
2169*2d9fd380Sjfb8856606  *
2170d30ea906Sjfb8856606  * @return
2171d30ea906Sjfb8856606  *   - 0: Success, receive queue correctly set up.
2172d30ea906Sjfb8856606  *   - -EIO: if device is removed.
2173*2d9fd380Sjfb8856606  *   - -ENODEV: if *port_id* is invalid.
21744418919fSjohnjiang  *   - -EINVAL: The memory pool pointer is null or the size of network buffers
21754418919fSjohnjiang  *      which can be allocated from this memory pool does not fit the various
21764418919fSjohnjiang  *      buffer sizes allowed by the device controller.
2177d30ea906Sjfb8856606  *   - -ENOMEM: Unable to allocate the receive ring descriptors or to
2178d30ea906Sjfb8856606  *      allocate network memory buffers from the memory pool when
2179d30ea906Sjfb8856606  *      initializing receive descriptors.
2180d30ea906Sjfb8856606  */
2181d30ea906Sjfb8856606 int rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
2182d30ea906Sjfb8856606 		uint16_t nb_rx_desc, unsigned int socket_id,
2183d30ea906Sjfb8856606 		const struct rte_eth_rxconf *rx_conf,
2184d30ea906Sjfb8856606 		struct rte_mempool *mb_pool);
2185d30ea906Sjfb8856606 
2186d30ea906Sjfb8856606 /**
21874418919fSjohnjiang  * @warning
21884418919fSjohnjiang  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
21894418919fSjohnjiang  *
21904418919fSjohnjiang  * Allocate and set up a hairpin receive queue for an Ethernet device.
21914418919fSjohnjiang  *
21924418919fSjohnjiang  * The function set up the selected queue to be used in hairpin.
21934418919fSjohnjiang  *
21944418919fSjohnjiang  * @param port_id
21954418919fSjohnjiang  *   The port identifier of the Ethernet device.
21964418919fSjohnjiang  * @param rx_queue_id
21974418919fSjohnjiang  *   The index of the receive queue to set up.
21984418919fSjohnjiang  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
21994418919fSjohnjiang  *   to rte_eth_dev_configure().
22004418919fSjohnjiang  * @param nb_rx_desc
22014418919fSjohnjiang  *   The number of receive descriptors to allocate for the receive ring.
22024418919fSjohnjiang  *   0 means the PMD will use default value.
22034418919fSjohnjiang  * @param conf
22044418919fSjohnjiang  *   The pointer to the hairpin configuration.
22054418919fSjohnjiang  *
22064418919fSjohnjiang  * @return
22074418919fSjohnjiang  *   - (0) if successful.
2208*2d9fd380Sjfb8856606  *   - (-ENODEV) if *port_id* is invalid.
22094418919fSjohnjiang  *   - (-ENOTSUP) if hardware doesn't support.
22104418919fSjohnjiang  *   - (-EINVAL) if bad parameter.
22114418919fSjohnjiang  *   - (-ENOMEM) if unable to allocate the resources.
22124418919fSjohnjiang  */
22134418919fSjohnjiang __rte_experimental
22144418919fSjohnjiang int rte_eth_rx_hairpin_queue_setup
22154418919fSjohnjiang 	(uint16_t port_id, uint16_t rx_queue_id, uint16_t nb_rx_desc,
22164418919fSjohnjiang 	 const struct rte_eth_hairpin_conf *conf);
22174418919fSjohnjiang 
22184418919fSjohnjiang /**
2219d30ea906Sjfb8856606  * Allocate and set up a transmit queue for an Ethernet device.
2220d30ea906Sjfb8856606  *
2221d30ea906Sjfb8856606  * @param port_id
2222d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
2223d30ea906Sjfb8856606  * @param tx_queue_id
2224d30ea906Sjfb8856606  *   The index of the transmit queue to set up.
2225d30ea906Sjfb8856606  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
2226d30ea906Sjfb8856606  *   to rte_eth_dev_configure().
2227d30ea906Sjfb8856606  * @param nb_tx_desc
2228d30ea906Sjfb8856606  *   The number of transmit descriptors to allocate for the transmit ring.
2229d30ea906Sjfb8856606  * @param socket_id
2230d30ea906Sjfb8856606  *   The *socket_id* argument is the socket identifier in case of NUMA.
2231d30ea906Sjfb8856606  *   Its value can be *SOCKET_ID_ANY* if there is no NUMA constraint for
2232d30ea906Sjfb8856606  *   the DMA memory allocated for the transmit descriptors of the ring.
2233d30ea906Sjfb8856606  * @param tx_conf
2234d30ea906Sjfb8856606  *   The pointer to the configuration data to be used for the transmit queue.
2235d30ea906Sjfb8856606  *   NULL value is allowed, in which case default TX configuration
2236d30ea906Sjfb8856606  *   will be used.
2237d30ea906Sjfb8856606  *   The *tx_conf* structure contains the following data:
2238d30ea906Sjfb8856606  *   - The *tx_thresh* structure with the values of the Prefetch, Host, and
2239d30ea906Sjfb8856606  *     Write-Back threshold registers of the transmit ring.
2240d30ea906Sjfb8856606  *     When setting Write-Back threshold to the value greater then zero,
2241d30ea906Sjfb8856606  *     *tx_rs_thresh* value should be explicitly set to one.
2242d30ea906Sjfb8856606  *   - The *tx_free_thresh* value indicates the [minimum] number of network
2243d30ea906Sjfb8856606  *     buffers that must be pending in the transmit ring to trigger their
2244d30ea906Sjfb8856606  *     [implicit] freeing by the driver transmit function.
2245d30ea906Sjfb8856606  *   - The *tx_rs_thresh* value indicates the [minimum] number of transmit
2246d30ea906Sjfb8856606  *     descriptors that must be pending in the transmit ring before setting the
2247d30ea906Sjfb8856606  *     RS bit on a descriptor by the driver transmit function.
2248d30ea906Sjfb8856606  *     The *tx_rs_thresh* value should be less or equal then
2249d30ea906Sjfb8856606  *     *tx_free_thresh* value, and both of them should be less then
2250d30ea906Sjfb8856606  *     *nb_tx_desc* - 3.
2251d30ea906Sjfb8856606  *   - The *offloads* member contains Tx offloads to be enabled.
2252d30ea906Sjfb8856606  *     If an offloading set in tx_conf->offloads
2253d30ea906Sjfb8856606  *     hasn't been set in the input argument eth_conf->txmode.offloads
2254d30ea906Sjfb8856606  *     to rte_eth_dev_configure(), it is a new added offloading, it must be
2255d30ea906Sjfb8856606  *     per-queue type and it is enabled for the queue.
2256d30ea906Sjfb8856606  *     No need to repeat any bit in tx_conf->offloads which has already been
2257d30ea906Sjfb8856606  *     enabled in rte_eth_dev_configure() at port level. An offloading enabled
2258d30ea906Sjfb8856606  *     at port level can't be disabled at queue level.
2259d30ea906Sjfb8856606  *
2260d30ea906Sjfb8856606  *     Note that setting *tx_free_thresh* or *tx_rs_thresh* value to 0 forces
2261d30ea906Sjfb8856606  *     the transmit function to use default values.
2262d30ea906Sjfb8856606  * @return
2263d30ea906Sjfb8856606  *   - 0: Success, the transmit queue is correctly set up.
2264d30ea906Sjfb8856606  *   - -ENOMEM: Unable to allocate the transmit ring descriptors.
2265d30ea906Sjfb8856606  */
2266d30ea906Sjfb8856606 int rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
2267d30ea906Sjfb8856606 		uint16_t nb_tx_desc, unsigned int socket_id,
2268d30ea906Sjfb8856606 		const struct rte_eth_txconf *tx_conf);
2269d30ea906Sjfb8856606 
2270d30ea906Sjfb8856606 /**
22714418919fSjohnjiang  * @warning
22724418919fSjohnjiang  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
22734418919fSjohnjiang  *
22744418919fSjohnjiang  * Allocate and set up a transmit hairpin queue for an Ethernet device.
22754418919fSjohnjiang  *
22764418919fSjohnjiang  * @param port_id
22774418919fSjohnjiang  *   The port identifier of the Ethernet device.
22784418919fSjohnjiang  * @param tx_queue_id
22794418919fSjohnjiang  *   The index of the transmit queue to set up.
22804418919fSjohnjiang  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
22814418919fSjohnjiang  *   to rte_eth_dev_configure().
22824418919fSjohnjiang  * @param nb_tx_desc
22834418919fSjohnjiang  *   The number of transmit descriptors to allocate for the transmit ring.
22844418919fSjohnjiang  *   0 to set default PMD value.
22854418919fSjohnjiang  * @param conf
22864418919fSjohnjiang  *   The hairpin configuration.
22874418919fSjohnjiang  *
22884418919fSjohnjiang  * @return
22894418919fSjohnjiang  *   - (0) if successful.
2290*2d9fd380Sjfb8856606  *   - (-ENODEV) if *port_id* is invalid.
22914418919fSjohnjiang  *   - (-ENOTSUP) if hardware doesn't support.
22924418919fSjohnjiang  *   - (-EINVAL) if bad parameter.
22934418919fSjohnjiang  *   - (-ENOMEM) if unable to allocate the resources.
22944418919fSjohnjiang  */
22954418919fSjohnjiang __rte_experimental
22964418919fSjohnjiang int rte_eth_tx_hairpin_queue_setup
22974418919fSjohnjiang 	(uint16_t port_id, uint16_t tx_queue_id, uint16_t nb_tx_desc,
22984418919fSjohnjiang 	 const struct rte_eth_hairpin_conf *conf);
22994418919fSjohnjiang 
23004418919fSjohnjiang /**
2301*2d9fd380Sjfb8856606  * @warning
2302*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
2303*2d9fd380Sjfb8856606  *
2304*2d9fd380Sjfb8856606  * Get all the hairpin peer Rx / Tx ports of the current port.
2305*2d9fd380Sjfb8856606  * The caller should ensure that the array is large enough to save the ports
2306*2d9fd380Sjfb8856606  * list.
2307*2d9fd380Sjfb8856606  *
2308*2d9fd380Sjfb8856606  * @param port_id
2309*2d9fd380Sjfb8856606  *   The port identifier of the Ethernet device.
2310*2d9fd380Sjfb8856606  * @param peer_ports
2311*2d9fd380Sjfb8856606  *   Pointer to the array to store the peer ports list.
2312*2d9fd380Sjfb8856606  * @param len
2313*2d9fd380Sjfb8856606  *   Length of the array to store the port identifiers.
2314*2d9fd380Sjfb8856606  * @param direction
2315*2d9fd380Sjfb8856606  *   Current port to peer port direction
2316*2d9fd380Sjfb8856606  *   positive - current used as Tx to get all peer Rx ports.
2317*2d9fd380Sjfb8856606  *   zero - current used as Rx to get all peer Tx ports.
2318*2d9fd380Sjfb8856606  *
2319*2d9fd380Sjfb8856606  * @return
2320*2d9fd380Sjfb8856606  *   - (0 or positive) actual peer ports number.
2321*2d9fd380Sjfb8856606  *   - (-EINVAL) if bad parameter.
2322*2d9fd380Sjfb8856606  *   - (-ENODEV) if *port_id* invalid
2323*2d9fd380Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support.
2324*2d9fd380Sjfb8856606  *   - Others detailed errors from PMD drivers.
2325*2d9fd380Sjfb8856606  */
2326*2d9fd380Sjfb8856606 __rte_experimental
2327*2d9fd380Sjfb8856606 int rte_eth_hairpin_get_peer_ports(uint16_t port_id, uint16_t *peer_ports,
2328*2d9fd380Sjfb8856606 				   size_t len, uint32_t direction);
2329*2d9fd380Sjfb8856606 
2330*2d9fd380Sjfb8856606 /**
2331*2d9fd380Sjfb8856606  * @warning
2332*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
2333*2d9fd380Sjfb8856606  *
2334*2d9fd380Sjfb8856606  * Bind all hairpin Tx queues of one port to the Rx queues of the peer port.
2335*2d9fd380Sjfb8856606  * It is only allowed to call this function after all hairpin queues are
2336*2d9fd380Sjfb8856606  * configured properly and the devices are in started state.
2337*2d9fd380Sjfb8856606  *
2338*2d9fd380Sjfb8856606  * @param tx_port
2339*2d9fd380Sjfb8856606  *   The identifier of the Tx port.
2340*2d9fd380Sjfb8856606  * @param rx_port
2341*2d9fd380Sjfb8856606  *   The identifier of peer Rx port.
2342*2d9fd380Sjfb8856606  *   RTE_MAX_ETHPORTS is allowed for the traversal of all devices.
2343*2d9fd380Sjfb8856606  *   Rx port ID could have the same value as Tx port ID.
2344*2d9fd380Sjfb8856606  *
2345*2d9fd380Sjfb8856606  * @return
2346*2d9fd380Sjfb8856606  *   - (0) if successful.
2347*2d9fd380Sjfb8856606  *   - (-ENODEV) if Tx port ID is invalid.
2348*2d9fd380Sjfb8856606  *   - (-EBUSY) if device is not in started state.
2349*2d9fd380Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support.
2350*2d9fd380Sjfb8856606  *   - Others detailed errors from PMD drivers.
2351*2d9fd380Sjfb8856606  */
2352*2d9fd380Sjfb8856606 __rte_experimental
2353*2d9fd380Sjfb8856606 int rte_eth_hairpin_bind(uint16_t tx_port, uint16_t rx_port);
2354*2d9fd380Sjfb8856606 
2355*2d9fd380Sjfb8856606 /**
2356*2d9fd380Sjfb8856606  * @warning
2357*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
2358*2d9fd380Sjfb8856606  *
2359*2d9fd380Sjfb8856606  * Unbind all hairpin Tx queues of one port from the Rx queues of the peer port.
2360*2d9fd380Sjfb8856606  * This should be called before closing the Tx or Rx devices, if the bind
2361*2d9fd380Sjfb8856606  * function is called before.
2362*2d9fd380Sjfb8856606  * After unbinding the hairpin ports pair, it is allowed to bind them again.
2363*2d9fd380Sjfb8856606  * Changing queues configuration should be after stopping the device(s).
2364*2d9fd380Sjfb8856606  *
2365*2d9fd380Sjfb8856606  * @param tx_port
2366*2d9fd380Sjfb8856606  *   The identifier of the Tx port.
2367*2d9fd380Sjfb8856606  * @param rx_port
2368*2d9fd380Sjfb8856606  *   The identifier of peer Rx port.
2369*2d9fd380Sjfb8856606  *   RTE_MAX_ETHPORTS is allowed for traversal of all devices.
2370*2d9fd380Sjfb8856606  *   Rx port ID could have the same value as Tx port ID.
2371*2d9fd380Sjfb8856606  *
2372*2d9fd380Sjfb8856606  * @return
2373*2d9fd380Sjfb8856606  *   - (0) if successful.
2374*2d9fd380Sjfb8856606  *   - (-ENODEV) if Tx port ID is invalid.
2375*2d9fd380Sjfb8856606  *   - (-EBUSY) if device is in stopped state.
2376*2d9fd380Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support.
2377*2d9fd380Sjfb8856606  *   - Others detailed errors from PMD drivers.
2378*2d9fd380Sjfb8856606  */
2379*2d9fd380Sjfb8856606 __rte_experimental
2380*2d9fd380Sjfb8856606 int rte_eth_hairpin_unbind(uint16_t tx_port, uint16_t rx_port);
2381*2d9fd380Sjfb8856606 
2382*2d9fd380Sjfb8856606 /**
2383d30ea906Sjfb8856606  * Return the NUMA socket to which an Ethernet device is connected
2384d30ea906Sjfb8856606  *
2385d30ea906Sjfb8856606  * @param port_id
2386d30ea906Sjfb8856606  *   The port identifier of the Ethernet device
2387d30ea906Sjfb8856606  * @return
2388d30ea906Sjfb8856606  *   The NUMA socket id to which the Ethernet device is connected or
2389d30ea906Sjfb8856606  *   a default of zero if the socket could not be determined.
2390d30ea906Sjfb8856606  *   -1 is returned is the port_id value is out of range.
2391d30ea906Sjfb8856606  */
2392d30ea906Sjfb8856606 int rte_eth_dev_socket_id(uint16_t port_id);
2393d30ea906Sjfb8856606 
2394d30ea906Sjfb8856606 /**
2395d30ea906Sjfb8856606  * Check if port_id of device is attached
2396d30ea906Sjfb8856606  *
2397d30ea906Sjfb8856606  * @param port_id
2398d30ea906Sjfb8856606  *   The port identifier of the Ethernet device
2399d30ea906Sjfb8856606  * @return
2400d30ea906Sjfb8856606  *   - 0 if port is out of range or not attached
2401d30ea906Sjfb8856606  *   - 1 if device is attached
2402d30ea906Sjfb8856606  */
2403d30ea906Sjfb8856606 int rte_eth_dev_is_valid_port(uint16_t port_id);
2404d30ea906Sjfb8856606 
2405d30ea906Sjfb8856606 /**
2406d30ea906Sjfb8856606  * Start specified RX queue of a port. It is used when rx_deferred_start
2407d30ea906Sjfb8856606  * flag of the specified queue is true.
2408d30ea906Sjfb8856606  *
2409d30ea906Sjfb8856606  * @param port_id
2410d30ea906Sjfb8856606  *   The port identifier of the Ethernet device
2411d30ea906Sjfb8856606  * @param rx_queue_id
2412d30ea906Sjfb8856606  *   The index of the rx queue to update the ring.
2413d30ea906Sjfb8856606  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
2414d30ea906Sjfb8856606  *   to rte_eth_dev_configure().
2415d30ea906Sjfb8856606  * @return
2416d30ea906Sjfb8856606  *   - 0: Success, the receive queue is started.
2417*2d9fd380Sjfb8856606  *   - -ENODEV: if *port_id* is invalid.
2418*2d9fd380Sjfb8856606  *   - -EINVAL: The queue_id out of range or belong to hairpin.
2419d30ea906Sjfb8856606  *   - -EIO: if device is removed.
2420d30ea906Sjfb8856606  *   - -ENOTSUP: The function not supported in PMD driver.
2421d30ea906Sjfb8856606  */
2422d30ea906Sjfb8856606 int rte_eth_dev_rx_queue_start(uint16_t port_id, uint16_t rx_queue_id);
2423d30ea906Sjfb8856606 
2424d30ea906Sjfb8856606 /**
2425d30ea906Sjfb8856606  * Stop specified RX queue of a port
2426d30ea906Sjfb8856606  *
2427d30ea906Sjfb8856606  * @param port_id
2428d30ea906Sjfb8856606  *   The port identifier of the Ethernet device
2429d30ea906Sjfb8856606  * @param rx_queue_id
2430d30ea906Sjfb8856606  *   The index of the rx queue to update the ring.
2431d30ea906Sjfb8856606  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
2432d30ea906Sjfb8856606  *   to rte_eth_dev_configure().
2433d30ea906Sjfb8856606  * @return
2434d30ea906Sjfb8856606  *   - 0: Success, the receive queue is stopped.
2435*2d9fd380Sjfb8856606  *   - -ENODEV: if *port_id* is invalid.
2436*2d9fd380Sjfb8856606  *   - -EINVAL: The queue_id out of range or belong to hairpin.
2437d30ea906Sjfb8856606  *   - -EIO: if device is removed.
2438d30ea906Sjfb8856606  *   - -ENOTSUP: The function not supported in PMD driver.
2439d30ea906Sjfb8856606  */
2440d30ea906Sjfb8856606 int rte_eth_dev_rx_queue_stop(uint16_t port_id, uint16_t rx_queue_id);
2441d30ea906Sjfb8856606 
2442d30ea906Sjfb8856606 /**
2443d30ea906Sjfb8856606  * Start TX for specified queue of a port. It is used when tx_deferred_start
2444d30ea906Sjfb8856606  * flag of the specified queue is true.
2445d30ea906Sjfb8856606  *
2446d30ea906Sjfb8856606  * @param port_id
2447d30ea906Sjfb8856606  *   The port identifier of the Ethernet device
2448d30ea906Sjfb8856606  * @param tx_queue_id
2449d30ea906Sjfb8856606  *   The index of the tx queue to update the ring.
2450d30ea906Sjfb8856606  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
2451d30ea906Sjfb8856606  *   to rte_eth_dev_configure().
2452d30ea906Sjfb8856606  * @return
2453d30ea906Sjfb8856606  *   - 0: Success, the transmit queue is started.
2454*2d9fd380Sjfb8856606  *   - -ENODEV: if *port_id* is invalid.
2455*2d9fd380Sjfb8856606  *   - -EINVAL: The queue_id out of range or belong to hairpin.
2456d30ea906Sjfb8856606  *   - -EIO: if device is removed.
2457d30ea906Sjfb8856606  *   - -ENOTSUP: The function not supported in PMD driver.
2458d30ea906Sjfb8856606  */
2459d30ea906Sjfb8856606 int rte_eth_dev_tx_queue_start(uint16_t port_id, uint16_t tx_queue_id);
2460d30ea906Sjfb8856606 
2461d30ea906Sjfb8856606 /**
2462d30ea906Sjfb8856606  * Stop specified TX queue of a port
2463d30ea906Sjfb8856606  *
2464d30ea906Sjfb8856606  * @param port_id
2465d30ea906Sjfb8856606  *   The port identifier of the Ethernet device
2466d30ea906Sjfb8856606  * @param tx_queue_id
2467d30ea906Sjfb8856606  *   The index of the tx queue to update the ring.
2468d30ea906Sjfb8856606  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
2469d30ea906Sjfb8856606  *   to rte_eth_dev_configure().
2470d30ea906Sjfb8856606  * @return
2471d30ea906Sjfb8856606  *   - 0: Success, the transmit queue is stopped.
2472*2d9fd380Sjfb8856606  *   - -ENODEV: if *port_id* is invalid.
2473*2d9fd380Sjfb8856606  *   - -EINVAL: The queue_id out of range or belong to hairpin.
2474d30ea906Sjfb8856606  *   - -EIO: if device is removed.
2475d30ea906Sjfb8856606  *   - -ENOTSUP: The function not supported in PMD driver.
2476d30ea906Sjfb8856606  */
2477d30ea906Sjfb8856606 int rte_eth_dev_tx_queue_stop(uint16_t port_id, uint16_t tx_queue_id);
2478d30ea906Sjfb8856606 
2479d30ea906Sjfb8856606 /**
2480d30ea906Sjfb8856606  * Start an Ethernet device.
2481d30ea906Sjfb8856606  *
2482d30ea906Sjfb8856606  * The device start step is the last one and consists of setting the configured
2483d30ea906Sjfb8856606  * offload features and in starting the transmit and the receive units of the
2484d30ea906Sjfb8856606  * device.
2485d30ea906Sjfb8856606  *
2486d30ea906Sjfb8856606  * Device RTE_ETH_DEV_NOLIVE_MAC_ADDR flag causes MAC address to be set before
2487d30ea906Sjfb8856606  * PMD port start callback function is invoked.
2488d30ea906Sjfb8856606  *
2489d30ea906Sjfb8856606  * On success, all basic functions exported by the Ethernet API (link status,
2490d30ea906Sjfb8856606  * receive/transmit, and so on) can be invoked.
2491d30ea906Sjfb8856606  *
2492d30ea906Sjfb8856606  * @param port_id
2493d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
2494d30ea906Sjfb8856606  * @return
2495d30ea906Sjfb8856606  *   - 0: Success, Ethernet device started.
2496d30ea906Sjfb8856606  *   - <0: Error code of the driver device start function.
2497d30ea906Sjfb8856606  */
2498d30ea906Sjfb8856606 int rte_eth_dev_start(uint16_t port_id);
2499d30ea906Sjfb8856606 
2500d30ea906Sjfb8856606 /**
2501d30ea906Sjfb8856606  * Stop an Ethernet device. The device can be restarted with a call to
2502d30ea906Sjfb8856606  * rte_eth_dev_start()
2503d30ea906Sjfb8856606  *
2504d30ea906Sjfb8856606  * @param port_id
2505d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
2506*2d9fd380Sjfb8856606  * @return
2507*2d9fd380Sjfb8856606  *   - 0: Success, Ethernet device stopped.
2508*2d9fd380Sjfb8856606  *   - <0: Error code of the driver device stop function.
2509d30ea906Sjfb8856606  */
2510*2d9fd380Sjfb8856606 int rte_eth_dev_stop(uint16_t port_id);
2511d30ea906Sjfb8856606 
2512d30ea906Sjfb8856606 /**
2513d30ea906Sjfb8856606  * Link up an Ethernet device.
2514d30ea906Sjfb8856606  *
2515d30ea906Sjfb8856606  * Set device link up will re-enable the device rx/tx
2516d30ea906Sjfb8856606  * functionality after it is previously set device linked down.
2517d30ea906Sjfb8856606  *
2518d30ea906Sjfb8856606  * @param port_id
2519d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
2520d30ea906Sjfb8856606  * @return
2521d30ea906Sjfb8856606  *   - 0: Success, Ethernet device linked up.
2522d30ea906Sjfb8856606  *   - <0: Error code of the driver device link up function.
2523d30ea906Sjfb8856606  */
2524d30ea906Sjfb8856606 int rte_eth_dev_set_link_up(uint16_t port_id);
2525d30ea906Sjfb8856606 
2526d30ea906Sjfb8856606 /**
2527d30ea906Sjfb8856606  * Link down an Ethernet device.
2528d30ea906Sjfb8856606  * The device rx/tx functionality will be disabled if success,
2529d30ea906Sjfb8856606  * and it can be re-enabled with a call to
2530d30ea906Sjfb8856606  * rte_eth_dev_set_link_up()
2531d30ea906Sjfb8856606  *
2532d30ea906Sjfb8856606  * @param port_id
2533d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
2534d30ea906Sjfb8856606  */
2535d30ea906Sjfb8856606 int rte_eth_dev_set_link_down(uint16_t port_id);
2536d30ea906Sjfb8856606 
2537d30ea906Sjfb8856606 /**
2538d30ea906Sjfb8856606  * Close a stopped Ethernet device. The device cannot be restarted!
2539*2d9fd380Sjfb8856606  * The function frees all port resources.
2540d30ea906Sjfb8856606  *
2541d30ea906Sjfb8856606  * @param port_id
2542d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
2543*2d9fd380Sjfb8856606  * @return
2544*2d9fd380Sjfb8856606  *   - Zero if the port is closed successfully.
2545*2d9fd380Sjfb8856606  *   - Negative if something went wrong.
2546d30ea906Sjfb8856606  */
2547*2d9fd380Sjfb8856606 int rte_eth_dev_close(uint16_t port_id);
2548d30ea906Sjfb8856606 
2549d30ea906Sjfb8856606 /**
2550d30ea906Sjfb8856606  * Reset a Ethernet device and keep its port id.
2551d30ea906Sjfb8856606  *
2552d30ea906Sjfb8856606  * When a port has to be reset passively, the DPDK application can invoke
2553d30ea906Sjfb8856606  * this function. For example when a PF is reset, all its VFs should also
2554d30ea906Sjfb8856606  * be reset. Normally a DPDK application can invoke this function when
2555d30ea906Sjfb8856606  * RTE_ETH_EVENT_INTR_RESET event is detected, but can also use it to start
2556d30ea906Sjfb8856606  * a port reset in other circumstances.
2557d30ea906Sjfb8856606  *
2558d30ea906Sjfb8856606  * When this function is called, it first stops the port and then calls the
2559d30ea906Sjfb8856606  * PMD specific dev_uninit( ) and dev_init( ) to return the port to initial
2560d30ea906Sjfb8856606  * state, in which no Tx and Rx queues are setup, as if the port has been
2561d30ea906Sjfb8856606  * reset and not started. The port keeps the port id it had before the
2562d30ea906Sjfb8856606  * function call.
2563d30ea906Sjfb8856606  *
2564d30ea906Sjfb8856606  * After calling rte_eth_dev_reset( ), the application should use
2565d30ea906Sjfb8856606  * rte_eth_dev_configure( ), rte_eth_rx_queue_setup( ),
2566d30ea906Sjfb8856606  * rte_eth_tx_queue_setup( ), and rte_eth_dev_start( )
2567d30ea906Sjfb8856606  * to reconfigure the device as appropriate.
2568d30ea906Sjfb8856606  *
2569d30ea906Sjfb8856606  * Note: To avoid unexpected behavior, the application should stop calling
2570d30ea906Sjfb8856606  * Tx and Rx functions before calling rte_eth_dev_reset( ). For thread
2571d30ea906Sjfb8856606  * safety, all these controlling functions should be called from the same
2572d30ea906Sjfb8856606  * thread.
2573d30ea906Sjfb8856606  *
2574d30ea906Sjfb8856606  * @param port_id
2575d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
2576d30ea906Sjfb8856606  *
2577d30ea906Sjfb8856606  * @return
2578d30ea906Sjfb8856606  *   - (0) if successful.
2579*2d9fd380Sjfb8856606  *   - (-ENODEV) if *port_id* is invalid.
2580d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support this function.
2581d30ea906Sjfb8856606  *   - (-EPERM) if not ran from the primary process.
2582d30ea906Sjfb8856606  *   - (-EIO) if re-initialisation failed or device is removed.
2583d30ea906Sjfb8856606  *   - (-ENOMEM) if the reset failed due to OOM.
2584d30ea906Sjfb8856606  *   - (-EAGAIN) if the reset temporarily failed and should be retried later.
2585d30ea906Sjfb8856606  */
2586d30ea906Sjfb8856606 int rte_eth_dev_reset(uint16_t port_id);
2587d30ea906Sjfb8856606 
2588d30ea906Sjfb8856606 /**
2589d30ea906Sjfb8856606  * Enable receipt in promiscuous mode for an Ethernet device.
2590d30ea906Sjfb8856606  *
2591d30ea906Sjfb8856606  * @param port_id
2592d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
25934418919fSjohnjiang  * @return
25944418919fSjohnjiang  *   - (0) if successful.
25954418919fSjohnjiang  *   - (-ENOTSUP) if support for promiscuous_enable() does not exist
25964418919fSjohnjiang  *     for the device.
25974418919fSjohnjiang  *   - (-ENODEV) if *port_id* invalid.
2598d30ea906Sjfb8856606  */
25994418919fSjohnjiang int rte_eth_promiscuous_enable(uint16_t port_id);
2600d30ea906Sjfb8856606 
2601d30ea906Sjfb8856606 /**
2602d30ea906Sjfb8856606  * Disable receipt in promiscuous mode for an Ethernet device.
2603d30ea906Sjfb8856606  *
2604d30ea906Sjfb8856606  * @param port_id
2605d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
26064418919fSjohnjiang  * @return
26074418919fSjohnjiang  *   - (0) if successful.
26084418919fSjohnjiang  *   - (-ENOTSUP) if support for promiscuous_disable() does not exist
26094418919fSjohnjiang  *     for the device.
26104418919fSjohnjiang  *   - (-ENODEV) if *port_id* invalid.
2611d30ea906Sjfb8856606  */
26124418919fSjohnjiang int rte_eth_promiscuous_disable(uint16_t port_id);
2613d30ea906Sjfb8856606 
2614d30ea906Sjfb8856606 /**
2615d30ea906Sjfb8856606  * Return the value of promiscuous mode for an Ethernet device.
2616d30ea906Sjfb8856606  *
2617d30ea906Sjfb8856606  * @param port_id
2618d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
2619d30ea906Sjfb8856606  * @return
2620d30ea906Sjfb8856606  *   - (1) if promiscuous is enabled
2621d30ea906Sjfb8856606  *   - (0) if promiscuous is disabled.
2622d30ea906Sjfb8856606  *   - (-1) on error
2623d30ea906Sjfb8856606  */
2624d30ea906Sjfb8856606 int rte_eth_promiscuous_get(uint16_t port_id);
2625d30ea906Sjfb8856606 
2626d30ea906Sjfb8856606 /**
2627d30ea906Sjfb8856606  * Enable the receipt of any multicast frame by an Ethernet device.
2628d30ea906Sjfb8856606  *
2629d30ea906Sjfb8856606  * @param port_id
2630d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
26314418919fSjohnjiang  * @return
26324418919fSjohnjiang  *   - (0) if successful.
26334418919fSjohnjiang  *   - (-ENOTSUP) if support for allmulticast_enable() does not exist
26344418919fSjohnjiang  *     for the device.
26354418919fSjohnjiang  *   - (-ENODEV) if *port_id* invalid.
2636d30ea906Sjfb8856606  */
26374418919fSjohnjiang int rte_eth_allmulticast_enable(uint16_t port_id);
2638d30ea906Sjfb8856606 
2639d30ea906Sjfb8856606 /**
2640d30ea906Sjfb8856606  * Disable the receipt of all multicast frames by an Ethernet device.
2641d30ea906Sjfb8856606  *
2642d30ea906Sjfb8856606  * @param port_id
2643d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
26444418919fSjohnjiang  * @return
26454418919fSjohnjiang  *   - (0) if successful.
26464418919fSjohnjiang  *   - (-ENOTSUP) if support for allmulticast_disable() does not exist
26474418919fSjohnjiang  *     for the device.
26484418919fSjohnjiang  *   - (-ENODEV) if *port_id* invalid.
2649d30ea906Sjfb8856606  */
26504418919fSjohnjiang int rte_eth_allmulticast_disable(uint16_t port_id);
2651d30ea906Sjfb8856606 
2652d30ea906Sjfb8856606 /**
2653d30ea906Sjfb8856606  * Return the value of allmulticast mode for an Ethernet device.
2654d30ea906Sjfb8856606  *
2655d30ea906Sjfb8856606  * @param port_id
2656d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
2657d30ea906Sjfb8856606  * @return
2658d30ea906Sjfb8856606  *   - (1) if allmulticast is enabled
2659d30ea906Sjfb8856606  *   - (0) if allmulticast is disabled.
2660d30ea906Sjfb8856606  *   - (-1) on error
2661d30ea906Sjfb8856606  */
2662d30ea906Sjfb8856606 int rte_eth_allmulticast_get(uint16_t port_id);
2663d30ea906Sjfb8856606 
2664d30ea906Sjfb8856606 /**
2665*2d9fd380Sjfb8856606  * Retrieve the link status (up/down), the duplex mode (half/full),
2666*2d9fd380Sjfb8856606  * the negotiation (auto/fixed), and if available, the speed (Mbps).
2667*2d9fd380Sjfb8856606  *
2668*2d9fd380Sjfb8856606  * It might need to wait up to 9 seconds.
2669*2d9fd380Sjfb8856606  * @see rte_eth_link_get_nowait.
2670d30ea906Sjfb8856606  *
2671d30ea906Sjfb8856606  * @param port_id
2672d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
2673d30ea906Sjfb8856606  * @param link
2674*2d9fd380Sjfb8856606  *   Link information written back.
26754418919fSjohnjiang  * @return
26764418919fSjohnjiang  *   - (0) if successful.
26774418919fSjohnjiang  *   - (-ENOTSUP) if the function is not supported in PMD driver.
26784418919fSjohnjiang  *   - (-ENODEV) if *port_id* invalid.
2679d30ea906Sjfb8856606  */
26804418919fSjohnjiang int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link);
2681d30ea906Sjfb8856606 
2682d30ea906Sjfb8856606 /**
2683*2d9fd380Sjfb8856606  * Retrieve the link status (up/down), the duplex mode (half/full),
2684*2d9fd380Sjfb8856606  * the negotiation (auto/fixed), and if available, the speed (Mbps).
2685d30ea906Sjfb8856606  *
2686d30ea906Sjfb8856606  * @param port_id
2687d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
2688d30ea906Sjfb8856606  * @param link
2689*2d9fd380Sjfb8856606  *   Link information written back.
26904418919fSjohnjiang  * @return
26914418919fSjohnjiang  *   - (0) if successful.
26924418919fSjohnjiang  *   - (-ENOTSUP) if the function is not supported in PMD driver.
26934418919fSjohnjiang  *   - (-ENODEV) if *port_id* invalid.
2694d30ea906Sjfb8856606  */
26954418919fSjohnjiang int rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *link);
2696d30ea906Sjfb8856606 
2697d30ea906Sjfb8856606 /**
2698*2d9fd380Sjfb8856606  * @warning
2699*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
2700*2d9fd380Sjfb8856606  *
2701*2d9fd380Sjfb8856606  * The function converts a link_speed to a string. It handles all special
2702*2d9fd380Sjfb8856606  * values like unknown or none speed.
2703*2d9fd380Sjfb8856606  *
2704*2d9fd380Sjfb8856606  * @param link_speed
2705*2d9fd380Sjfb8856606  *   link_speed of rte_eth_link struct
2706*2d9fd380Sjfb8856606  * @return
2707*2d9fd380Sjfb8856606  *   Link speed in textual format. It's pointer to immutable memory.
2708*2d9fd380Sjfb8856606  *   No free is required.
2709*2d9fd380Sjfb8856606  */
2710*2d9fd380Sjfb8856606 __rte_experimental
2711*2d9fd380Sjfb8856606 const char *rte_eth_link_speed_to_str(uint32_t link_speed);
2712*2d9fd380Sjfb8856606 
2713*2d9fd380Sjfb8856606 /**
2714*2d9fd380Sjfb8856606  * @warning
2715*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
2716*2d9fd380Sjfb8856606  *
2717*2d9fd380Sjfb8856606  * The function converts a rte_eth_link struct representing a link status to
2718*2d9fd380Sjfb8856606  * a string.
2719*2d9fd380Sjfb8856606  *
2720*2d9fd380Sjfb8856606  * @param str
2721*2d9fd380Sjfb8856606  *   A pointer to a string to be filled with textual representation of
2722*2d9fd380Sjfb8856606  *   device status. At least ETH_LINK_MAX_STR_LEN bytes should be allocated to
2723*2d9fd380Sjfb8856606  *   store default link status text.
2724*2d9fd380Sjfb8856606  * @param len
2725*2d9fd380Sjfb8856606  *   Length of available memory at 'str' string.
2726*2d9fd380Sjfb8856606  * @param eth_link
2727*2d9fd380Sjfb8856606  *   Link status returned by rte_eth_link_get function
2728*2d9fd380Sjfb8856606  * @return
2729*2d9fd380Sjfb8856606  *   Number of bytes written to str array.
2730*2d9fd380Sjfb8856606  */
2731*2d9fd380Sjfb8856606 __rte_experimental
2732*2d9fd380Sjfb8856606 int rte_eth_link_to_str(char *str, size_t len,
2733*2d9fd380Sjfb8856606 			const struct rte_eth_link *eth_link);
2734*2d9fd380Sjfb8856606 
2735*2d9fd380Sjfb8856606 /**
2736d30ea906Sjfb8856606  * Retrieve the general I/O statistics of an Ethernet device.
2737d30ea906Sjfb8856606  *
2738d30ea906Sjfb8856606  * @param port_id
2739d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
2740d30ea906Sjfb8856606  * @param stats
2741d30ea906Sjfb8856606  *   A pointer to a structure of type *rte_eth_stats* to be filled with
2742d30ea906Sjfb8856606  *   the values of device counters for the following set of statistics:
2743d30ea906Sjfb8856606  *   - *ipackets* with the total of successfully received packets.
2744d30ea906Sjfb8856606  *   - *opackets* with the total of successfully transmitted packets.
2745d30ea906Sjfb8856606  *   - *ibytes*   with the total of successfully received bytes.
2746d30ea906Sjfb8856606  *   - *obytes*   with the total of successfully transmitted bytes.
2747d30ea906Sjfb8856606  *   - *ierrors*  with the total of erroneous received packets.
2748d30ea906Sjfb8856606  *   - *oerrors*  with the total of failed transmitted packets.
2749d30ea906Sjfb8856606  * @return
2750d30ea906Sjfb8856606  *   Zero if successful. Non-zero otherwise.
2751d30ea906Sjfb8856606  */
2752d30ea906Sjfb8856606 int rte_eth_stats_get(uint16_t port_id, struct rte_eth_stats *stats);
2753d30ea906Sjfb8856606 
2754d30ea906Sjfb8856606 /**
2755d30ea906Sjfb8856606  * Reset the general I/O statistics of an Ethernet device.
2756d30ea906Sjfb8856606  *
2757d30ea906Sjfb8856606  * @param port_id
2758d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
2759d30ea906Sjfb8856606  * @return
2760d30ea906Sjfb8856606  *   - (0) if device notified to reset stats.
2761d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support.
2762d30ea906Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
27634418919fSjohnjiang  *   - (<0): Error code of the driver stats reset function.
2764d30ea906Sjfb8856606  */
2765d30ea906Sjfb8856606 int rte_eth_stats_reset(uint16_t port_id);
2766d30ea906Sjfb8856606 
2767d30ea906Sjfb8856606 /**
2768d30ea906Sjfb8856606  * Retrieve names of extended statistics of an Ethernet device.
2769d30ea906Sjfb8856606  *
2770d30ea906Sjfb8856606  * There is an assumption that 'xstat_names' and 'xstats' arrays are matched
2771d30ea906Sjfb8856606  * by array index:
2772d30ea906Sjfb8856606  *  xstats_names[i].name => xstats[i].value
2773d30ea906Sjfb8856606  *
2774d30ea906Sjfb8856606  * And the array index is same with id field of 'struct rte_eth_xstat':
2775d30ea906Sjfb8856606  *  xstats[i].id == i
2776d30ea906Sjfb8856606  *
2777d30ea906Sjfb8856606  * This assumption makes key-value pair matching less flexible but simpler.
2778d30ea906Sjfb8856606  *
2779d30ea906Sjfb8856606  * @param port_id
2780d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
2781d30ea906Sjfb8856606  * @param xstats_names
2782d30ea906Sjfb8856606  *   An rte_eth_xstat_name array of at least *size* elements to
2783d30ea906Sjfb8856606  *   be filled. If set to NULL, the function returns the required number
2784d30ea906Sjfb8856606  *   of elements.
2785d30ea906Sjfb8856606  * @param size
2786d30ea906Sjfb8856606  *   The size of the xstats_names array (number of elements).
2787d30ea906Sjfb8856606  * @return
2788d30ea906Sjfb8856606  *   - A positive value lower or equal to size: success. The return value
2789d30ea906Sjfb8856606  *     is the number of entries filled in the stats table.
2790d30ea906Sjfb8856606  *   - A positive value higher than size: error, the given statistics table
2791d30ea906Sjfb8856606  *     is too small. The return value corresponds to the size that should
2792d30ea906Sjfb8856606  *     be given to succeed. The entries in the table are not valid and
2793d30ea906Sjfb8856606  *     shall not be used by the caller.
2794d30ea906Sjfb8856606  *   - A negative value on error (invalid port id).
2795d30ea906Sjfb8856606  */
2796d30ea906Sjfb8856606 int rte_eth_xstats_get_names(uint16_t port_id,
2797d30ea906Sjfb8856606 		struct rte_eth_xstat_name *xstats_names,
2798d30ea906Sjfb8856606 		unsigned int size);
2799d30ea906Sjfb8856606 
2800d30ea906Sjfb8856606 /**
2801d30ea906Sjfb8856606  * Retrieve extended statistics of an Ethernet device.
2802d30ea906Sjfb8856606  *
2803d30ea906Sjfb8856606  * There is an assumption that 'xstat_names' and 'xstats' arrays are matched
2804d30ea906Sjfb8856606  * by array index:
2805d30ea906Sjfb8856606  *  xstats_names[i].name => xstats[i].value
2806d30ea906Sjfb8856606  *
2807d30ea906Sjfb8856606  * And the array index is same with id field of 'struct rte_eth_xstat':
2808d30ea906Sjfb8856606  *  xstats[i].id == i
2809d30ea906Sjfb8856606  *
2810d30ea906Sjfb8856606  * This assumption makes key-value pair matching less flexible but simpler.
2811d30ea906Sjfb8856606  *
2812d30ea906Sjfb8856606  * @param port_id
2813d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
2814d30ea906Sjfb8856606  * @param xstats
2815d30ea906Sjfb8856606  *   A pointer to a table of structure of type *rte_eth_xstat*
2816d30ea906Sjfb8856606  *   to be filled with device statistics ids and values.
2817d30ea906Sjfb8856606  *   This parameter can be set to NULL if n is 0.
2818d30ea906Sjfb8856606  * @param n
2819d30ea906Sjfb8856606  *   The size of the xstats array (number of elements).
2820d30ea906Sjfb8856606  * @return
2821d30ea906Sjfb8856606  *   - A positive value lower or equal to n: success. The return value
2822d30ea906Sjfb8856606  *     is the number of entries filled in the stats table.
2823d30ea906Sjfb8856606  *   - A positive value higher than n: error, the given statistics table
2824d30ea906Sjfb8856606  *     is too small. The return value corresponds to the size that should
2825d30ea906Sjfb8856606  *     be given to succeed. The entries in the table are not valid and
2826d30ea906Sjfb8856606  *     shall not be used by the caller.
2827d30ea906Sjfb8856606  *   - A negative value on error (invalid port id).
2828d30ea906Sjfb8856606  */
2829d30ea906Sjfb8856606 int rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats,
2830d30ea906Sjfb8856606 		unsigned int n);
2831d30ea906Sjfb8856606 
2832d30ea906Sjfb8856606 /**
2833d30ea906Sjfb8856606  * Retrieve names of extended statistics of an Ethernet device.
2834d30ea906Sjfb8856606  *
2835d30ea906Sjfb8856606  * @param port_id
2836d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
2837d30ea906Sjfb8856606  * @param xstats_names
2838d30ea906Sjfb8856606  *   An rte_eth_xstat_name array of at least *size* elements to
2839d30ea906Sjfb8856606  *   be filled. If set to NULL, the function returns the required number
2840d30ea906Sjfb8856606  *   of elements.
2841d30ea906Sjfb8856606  * @param ids
2842d30ea906Sjfb8856606  *   IDs array given by app to retrieve specific statistics
2843d30ea906Sjfb8856606  * @param size
2844d30ea906Sjfb8856606  *   The size of the xstats_names array (number of elements).
2845d30ea906Sjfb8856606  * @return
2846d30ea906Sjfb8856606  *   - A positive value lower or equal to size: success. The return value
2847d30ea906Sjfb8856606  *     is the number of entries filled in the stats table.
2848d30ea906Sjfb8856606  *   - A positive value higher than size: error, the given statistics table
2849d30ea906Sjfb8856606  *     is too small. The return value corresponds to the size that should
2850d30ea906Sjfb8856606  *     be given to succeed. The entries in the table are not valid and
2851d30ea906Sjfb8856606  *     shall not be used by the caller.
2852d30ea906Sjfb8856606  *   - A negative value on error (invalid port id).
2853d30ea906Sjfb8856606  */
2854d30ea906Sjfb8856606 int
2855d30ea906Sjfb8856606 rte_eth_xstats_get_names_by_id(uint16_t port_id,
2856d30ea906Sjfb8856606 	struct rte_eth_xstat_name *xstats_names, unsigned int size,
2857d30ea906Sjfb8856606 	uint64_t *ids);
2858d30ea906Sjfb8856606 
2859d30ea906Sjfb8856606 /**
2860d30ea906Sjfb8856606  * Retrieve extended statistics of an Ethernet device.
2861d30ea906Sjfb8856606  *
2862d30ea906Sjfb8856606  * @param port_id
2863d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
2864d30ea906Sjfb8856606  * @param ids
2865d30ea906Sjfb8856606  *   A pointer to an ids array passed by application. This tells which
2866d30ea906Sjfb8856606  *   statistics values function should retrieve. This parameter
2867d30ea906Sjfb8856606  *   can be set to NULL if size is 0. In this case function will retrieve
28681646932aSjfb8856606  *   all available statistics.
2869d30ea906Sjfb8856606  * @param values
2870d30ea906Sjfb8856606  *   A pointer to a table to be filled with device statistics values.
2871d30ea906Sjfb8856606  * @param size
2872d30ea906Sjfb8856606  *   The size of the ids array (number of elements).
2873d30ea906Sjfb8856606  * @return
2874d30ea906Sjfb8856606  *   - A positive value lower or equal to size: success. The return value
2875d30ea906Sjfb8856606  *     is the number of entries filled in the stats table.
2876d30ea906Sjfb8856606  *   - A positive value higher than size: error, the given statistics table
2877d30ea906Sjfb8856606  *     is too small. The return value corresponds to the size that should
2878d30ea906Sjfb8856606  *     be given to succeed. The entries in the table are not valid and
2879d30ea906Sjfb8856606  *     shall not be used by the caller.
2880d30ea906Sjfb8856606  *   - A negative value on error (invalid port id).
2881d30ea906Sjfb8856606  */
2882d30ea906Sjfb8856606 int rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,
2883d30ea906Sjfb8856606 			     uint64_t *values, unsigned int size);
2884d30ea906Sjfb8856606 
2885d30ea906Sjfb8856606 /**
2886d30ea906Sjfb8856606  * Gets the ID of a statistic from its name.
2887d30ea906Sjfb8856606  *
2888d30ea906Sjfb8856606  * This function searches for the statistics using string compares, and
2889d30ea906Sjfb8856606  * as such should not be used on the fast-path. For fast-path retrieval of
2890d30ea906Sjfb8856606  * specific statistics, store the ID as provided in *id* from this function,
2891d30ea906Sjfb8856606  * and pass the ID to rte_eth_xstats_get()
2892d30ea906Sjfb8856606  *
2893d30ea906Sjfb8856606  * @param port_id The port to look up statistics from
2894d30ea906Sjfb8856606  * @param xstat_name The name of the statistic to return
2895d30ea906Sjfb8856606  * @param[out] id A pointer to an app-supplied uint64_t which should be
2896d30ea906Sjfb8856606  *                set to the ID of the stat if the stat exists.
2897d30ea906Sjfb8856606  * @return
2898d30ea906Sjfb8856606  *    0 on success
2899d30ea906Sjfb8856606  *    -ENODEV for invalid port_id,
2900d30ea906Sjfb8856606  *    -EIO if device is removed,
2901d30ea906Sjfb8856606  *    -EINVAL if the xstat_name doesn't exist in port_id
2902d30ea906Sjfb8856606  */
2903d30ea906Sjfb8856606 int rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name,
2904d30ea906Sjfb8856606 		uint64_t *id);
2905d30ea906Sjfb8856606 
2906d30ea906Sjfb8856606 /**
2907d30ea906Sjfb8856606  * Reset extended statistics of an Ethernet device.
2908d30ea906Sjfb8856606  *
2909d30ea906Sjfb8856606  * @param port_id
2910d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
29114418919fSjohnjiang  * @return
29124418919fSjohnjiang  *   - (0) if device notified to reset extended stats.
29134418919fSjohnjiang  *   - (-ENOTSUP) if pmd doesn't support both
29144418919fSjohnjiang  *     extended stats and basic stats reset.
29154418919fSjohnjiang  *   - (-ENODEV) if *port_id* invalid.
29164418919fSjohnjiang  *   - (<0): Error code of the driver xstats reset function.
2917d30ea906Sjfb8856606  */
29184418919fSjohnjiang int rte_eth_xstats_reset(uint16_t port_id);
2919d30ea906Sjfb8856606 
2920d30ea906Sjfb8856606 /**
2921d30ea906Sjfb8856606  *  Set a mapping for the specified transmit queue to the specified per-queue
2922d30ea906Sjfb8856606  *  statistics counter.
2923d30ea906Sjfb8856606  *
2924d30ea906Sjfb8856606  * @param port_id
2925d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
2926d30ea906Sjfb8856606  * @param tx_queue_id
2927d30ea906Sjfb8856606  *   The index of the transmit queue for which a queue stats mapping is required.
2928d30ea906Sjfb8856606  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
2929d30ea906Sjfb8856606  *   to rte_eth_dev_configure().
2930d30ea906Sjfb8856606  * @param stat_idx
2931d30ea906Sjfb8856606  *   The per-queue packet statistics functionality number that the transmit
2932d30ea906Sjfb8856606  *   queue is to be assigned.
2933d30ea906Sjfb8856606  *   The value must be in the range [0, RTE_ETHDEV_QUEUE_STAT_CNTRS - 1].
2934*2d9fd380Sjfb8856606  *   Max RTE_ETHDEV_QUEUE_STAT_CNTRS being 256.
2935d30ea906Sjfb8856606  * @return
2936d30ea906Sjfb8856606  *   Zero if successful. Non-zero otherwise.
2937d30ea906Sjfb8856606  */
2938d30ea906Sjfb8856606 int rte_eth_dev_set_tx_queue_stats_mapping(uint16_t port_id,
2939d30ea906Sjfb8856606 		uint16_t tx_queue_id, uint8_t stat_idx);
2940d30ea906Sjfb8856606 
2941d30ea906Sjfb8856606 /**
2942d30ea906Sjfb8856606  *  Set a mapping for the specified receive queue to the specified per-queue
2943d30ea906Sjfb8856606  *  statistics counter.
2944d30ea906Sjfb8856606  *
2945d30ea906Sjfb8856606  * @param port_id
2946d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
2947d30ea906Sjfb8856606  * @param rx_queue_id
2948d30ea906Sjfb8856606  *   The index of the receive queue for which a queue stats mapping is required.
2949d30ea906Sjfb8856606  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
2950d30ea906Sjfb8856606  *   to rte_eth_dev_configure().
2951d30ea906Sjfb8856606  * @param stat_idx
2952d30ea906Sjfb8856606  *   The per-queue packet statistics functionality number that the receive
2953d30ea906Sjfb8856606  *   queue is to be assigned.
2954d30ea906Sjfb8856606  *   The value must be in the range [0, RTE_ETHDEV_QUEUE_STAT_CNTRS - 1].
2955*2d9fd380Sjfb8856606  *   Max RTE_ETHDEV_QUEUE_STAT_CNTRS being 256.
2956d30ea906Sjfb8856606  * @return
2957d30ea906Sjfb8856606  *   Zero if successful. Non-zero otherwise.
2958d30ea906Sjfb8856606  */
2959d30ea906Sjfb8856606 int rte_eth_dev_set_rx_queue_stats_mapping(uint16_t port_id,
2960d30ea906Sjfb8856606 					   uint16_t rx_queue_id,
2961d30ea906Sjfb8856606 					   uint8_t stat_idx);
2962d30ea906Sjfb8856606 
2963d30ea906Sjfb8856606 /**
2964d30ea906Sjfb8856606  * Retrieve the Ethernet address of an Ethernet device.
2965d30ea906Sjfb8856606  *
2966d30ea906Sjfb8856606  * @param port_id
2967d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
2968d30ea906Sjfb8856606  * @param mac_addr
2969d30ea906Sjfb8856606  *   A pointer to a structure of type *ether_addr* to be filled with
2970d30ea906Sjfb8856606  *   the Ethernet address of the Ethernet device.
29714418919fSjohnjiang  * @return
29724418919fSjohnjiang  *   - (0) if successful
29734418919fSjohnjiang  *   - (-ENODEV) if *port_id* invalid.
2974d30ea906Sjfb8856606  */
29754418919fSjohnjiang int rte_eth_macaddr_get(uint16_t port_id, struct rte_ether_addr *mac_addr);
2976d30ea906Sjfb8856606 
2977d30ea906Sjfb8856606 /**
2978d30ea906Sjfb8856606  * Retrieve the contextual information of an Ethernet device.
2979d30ea906Sjfb8856606  *
29804418919fSjohnjiang  * As part of this function, a number of of fields in dev_info will be
29814418919fSjohnjiang  * initialized as follows:
29824418919fSjohnjiang  *
29834418919fSjohnjiang  * rx_desc_lim = lim
29844418919fSjohnjiang  * tx_desc_lim = lim
29854418919fSjohnjiang  *
29864418919fSjohnjiang  * Where lim is defined within the rte_eth_dev_info_get as
29874418919fSjohnjiang  *
29884418919fSjohnjiang  *  const struct rte_eth_desc_lim lim = {
29894418919fSjohnjiang  *      .nb_max = UINT16_MAX,
29904418919fSjohnjiang  *      .nb_min = 0,
29914418919fSjohnjiang  *      .nb_align = 1,
29924418919fSjohnjiang  *	.nb_seg_max = UINT16_MAX,
29934418919fSjohnjiang  *	.nb_mtu_seg_max = UINT16_MAX,
29944418919fSjohnjiang  *  };
29954418919fSjohnjiang  *
29964418919fSjohnjiang  * device = dev->device
29974418919fSjohnjiang  * min_mtu = RTE_ETHER_MIN_MTU
29984418919fSjohnjiang  * max_mtu = UINT16_MAX
29994418919fSjohnjiang  *
30004418919fSjohnjiang  * The following fields will be populated if support for dev_infos_get()
30014418919fSjohnjiang  * exists for the device and the rte_eth_dev 'dev' has been populated
30024418919fSjohnjiang  * successfully with a call to it:
30034418919fSjohnjiang  *
30044418919fSjohnjiang  * driver_name = dev->device->driver->name
30054418919fSjohnjiang  * nb_rx_queues = dev->data->nb_rx_queues
30064418919fSjohnjiang  * nb_tx_queues = dev->data->nb_tx_queues
30074418919fSjohnjiang  * dev_flags = &dev->data->dev_flags
30084418919fSjohnjiang  *
3009d30ea906Sjfb8856606  * @param port_id
3010d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3011d30ea906Sjfb8856606  * @param dev_info
3012d30ea906Sjfb8856606  *   A pointer to a structure of type *rte_eth_dev_info* to be filled with
3013d30ea906Sjfb8856606  *   the contextual information of the Ethernet device.
30144418919fSjohnjiang  * @return
30154418919fSjohnjiang  *   - (0) if successful.
30164418919fSjohnjiang  *   - (-ENOTSUP) if support for dev_infos_get() does not exist for the device.
30174418919fSjohnjiang  *   - (-ENODEV) if *port_id* invalid.
3018d30ea906Sjfb8856606  */
30194418919fSjohnjiang int rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info);
3020d30ea906Sjfb8856606 
3021d30ea906Sjfb8856606 /**
3022d30ea906Sjfb8856606  * Retrieve the firmware version of a device.
3023d30ea906Sjfb8856606  *
3024d30ea906Sjfb8856606  * @param port_id
3025d30ea906Sjfb8856606  *   The port identifier of the device.
3026d30ea906Sjfb8856606  * @param fw_version
3027d30ea906Sjfb8856606  *   A pointer to a string array storing the firmware version of a device,
3028d30ea906Sjfb8856606  *   the string includes terminating null. This pointer is allocated by caller.
3029d30ea906Sjfb8856606  * @param fw_size
3030d30ea906Sjfb8856606  *   The size of the string array pointed by fw_version, which should be
3031d30ea906Sjfb8856606  *   large enough to store firmware version of the device.
3032d30ea906Sjfb8856606  * @return
3033d30ea906Sjfb8856606  *   - (0) if successful.
3034d30ea906Sjfb8856606  *   - (-ENOTSUP) if operation is not supported.
3035d30ea906Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
3036d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
3037d30ea906Sjfb8856606  *   - (>0) if *fw_size* is not enough to store firmware version, return
3038d30ea906Sjfb8856606  *          the size of the non truncated string.
3039d30ea906Sjfb8856606  */
3040d30ea906Sjfb8856606 int rte_eth_dev_fw_version_get(uint16_t port_id,
3041d30ea906Sjfb8856606 			       char *fw_version, size_t fw_size);
3042d30ea906Sjfb8856606 
3043d30ea906Sjfb8856606 /**
3044d30ea906Sjfb8856606  * Retrieve the supported packet types of an Ethernet device.
3045d30ea906Sjfb8856606  *
3046d30ea906Sjfb8856606  * When a packet type is announced as supported, it *must* be recognized by
3047d30ea906Sjfb8856606  * the PMD. For instance, if RTE_PTYPE_L2_ETHER, RTE_PTYPE_L2_ETHER_VLAN
3048d30ea906Sjfb8856606  * and RTE_PTYPE_L3_IPV4 are announced, the PMD must return the following
3049d30ea906Sjfb8856606  * packet types for these packets:
3050d30ea906Sjfb8856606  * - Ether/IPv4              -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4
3051d30ea906Sjfb8856606  * - Ether/Vlan/IPv4         -> RTE_PTYPE_L2_ETHER_VLAN | RTE_PTYPE_L3_IPV4
3052d30ea906Sjfb8856606  * - Ether/[anything else]   -> RTE_PTYPE_L2_ETHER
3053d30ea906Sjfb8856606  * - Ether/Vlan/[anything else] -> RTE_PTYPE_L2_ETHER_VLAN
3054d30ea906Sjfb8856606  *
3055d30ea906Sjfb8856606  * When a packet is received by a PMD, the most precise type must be
3056d30ea906Sjfb8856606  * returned among the ones supported. However a PMD is allowed to set
3057d30ea906Sjfb8856606  * packet type that is not in the supported list, at the condition that it
3058d30ea906Sjfb8856606  * is more precise. Therefore, a PMD announcing no supported packet types
3059d30ea906Sjfb8856606  * can still set a matching packet type in a received packet.
3060d30ea906Sjfb8856606  *
3061d30ea906Sjfb8856606  * @note
3062d30ea906Sjfb8856606  *   Better to invoke this API after the device is already started or rx burst
3063d30ea906Sjfb8856606  *   function is decided, to obtain correct supported ptypes.
3064d30ea906Sjfb8856606  * @note
3065d30ea906Sjfb8856606  *   if a given PMD does not report what ptypes it supports, then the supported
3066d30ea906Sjfb8856606  *   ptype count is reported as 0.
3067d30ea906Sjfb8856606  * @param port_id
3068d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3069d30ea906Sjfb8856606  * @param ptype_mask
3070d30ea906Sjfb8856606  *   A hint of what kind of packet type which the caller is interested in.
3071d30ea906Sjfb8856606  * @param ptypes
3072d30ea906Sjfb8856606  *   An array pointer to store adequate packet types, allocated by caller.
3073d30ea906Sjfb8856606  * @param num
3074d30ea906Sjfb8856606  *  Size of the array pointed by param ptypes.
3075d30ea906Sjfb8856606  * @return
3076d30ea906Sjfb8856606  *   - (>=0) Number of supported ptypes. If the number of types exceeds num,
3077d30ea906Sjfb8856606  *           only num entries will be filled into the ptypes array, but the full
3078d30ea906Sjfb8856606  *           count of supported ptypes will be returned.
3079d30ea906Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
3080d30ea906Sjfb8856606  */
3081d30ea906Sjfb8856606 int rte_eth_dev_get_supported_ptypes(uint16_t port_id, uint32_t ptype_mask,
3082d30ea906Sjfb8856606 				     uint32_t *ptypes, int num);
30834418919fSjohnjiang /**
30844418919fSjohnjiang  * @warning
30854418919fSjohnjiang  * @b EXPERIMENTAL: this API may change without prior notice.
30864418919fSjohnjiang  *
30874418919fSjohnjiang  * Inform Ethernet device about reduced range of packet types to handle.
30884418919fSjohnjiang  *
30894418919fSjohnjiang  * Application can use this function to set only specific ptypes that it's
30904418919fSjohnjiang  * interested. This information can be used by the PMD to optimize Rx path.
30914418919fSjohnjiang  *
30924418919fSjohnjiang  * The function accepts an array `set_ptypes` allocated by the caller to
30934418919fSjohnjiang  * store the packet types set by the driver, the last element of the array
30944418919fSjohnjiang  * is set to RTE_PTYPE_UNKNOWN. The size of the `set_ptype` array should be
30954418919fSjohnjiang  * `rte_eth_dev_get_supported_ptypes() + 1` else it might only be filled
30964418919fSjohnjiang  * partially.
30974418919fSjohnjiang  *
30984418919fSjohnjiang  * @param port_id
30994418919fSjohnjiang  *   The port identifier of the Ethernet device.
31004418919fSjohnjiang  * @param ptype_mask
31014418919fSjohnjiang  *   The ptype family that application is interested in should be bitwise OR of
31024418919fSjohnjiang  *   RTE_PTYPE_*_MASK or 0.
31034418919fSjohnjiang  * @param set_ptypes
31044418919fSjohnjiang  *   An array pointer to store set packet types, allocated by caller. The
31054418919fSjohnjiang  *   function marks the end of array with RTE_PTYPE_UNKNOWN.
31064418919fSjohnjiang  * @param num
31074418919fSjohnjiang  *   Size of the array pointed by param ptypes.
31084418919fSjohnjiang  *   Should be rte_eth_dev_get_supported_ptypes() + 1 to accommodate the
31094418919fSjohnjiang  *   set ptypes.
31104418919fSjohnjiang  * @return
31114418919fSjohnjiang  *   - (0) if Success.
31124418919fSjohnjiang  *   - (-ENODEV) if *port_id* invalid.
31134418919fSjohnjiang  *   - (-EINVAL) if *ptype_mask* is invalid (or) set_ptypes is NULL and
31144418919fSjohnjiang  *     num > 0.
31154418919fSjohnjiang  */
31164418919fSjohnjiang __rte_experimental
31174418919fSjohnjiang int rte_eth_dev_set_ptypes(uint16_t port_id, uint32_t ptype_mask,
31184418919fSjohnjiang 			   uint32_t *set_ptypes, unsigned int num);
3119d30ea906Sjfb8856606 
3120d30ea906Sjfb8856606 /**
3121d30ea906Sjfb8856606  * Retrieve the MTU of an Ethernet device.
3122d30ea906Sjfb8856606  *
3123d30ea906Sjfb8856606  * @param port_id
3124d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3125d30ea906Sjfb8856606  * @param mtu
3126d30ea906Sjfb8856606  *   A pointer to a uint16_t where the retrieved MTU is to be stored.
3127d30ea906Sjfb8856606  * @return
3128d30ea906Sjfb8856606  *   - (0) if successful.
3129d30ea906Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
3130d30ea906Sjfb8856606  */
3131d30ea906Sjfb8856606 int rte_eth_dev_get_mtu(uint16_t port_id, uint16_t *mtu);
3132d30ea906Sjfb8856606 
3133d30ea906Sjfb8856606 /**
3134d30ea906Sjfb8856606  * Change the MTU of an Ethernet device.
3135d30ea906Sjfb8856606  *
3136d30ea906Sjfb8856606  * @param port_id
3137d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3138d30ea906Sjfb8856606  * @param mtu
3139d30ea906Sjfb8856606  *   A uint16_t for the MTU to be applied.
3140d30ea906Sjfb8856606  * @return
3141d30ea906Sjfb8856606  *   - (0) if successful.
3142d30ea906Sjfb8856606  *   - (-ENOTSUP) if operation is not supported.
3143d30ea906Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
3144d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
31454418919fSjohnjiang  *   - (-EINVAL) if *mtu* invalid, validation of mtu can occur within
31464418919fSjohnjiang  *     rte_eth_dev_set_mtu if dev_infos_get is supported by the device or
31474418919fSjohnjiang  *     when the mtu is set using dev->dev_ops->mtu_set.
3148d30ea906Sjfb8856606  *   - (-EBUSY) if operation is not allowed when the port is running
3149d30ea906Sjfb8856606  */
3150d30ea906Sjfb8856606 int rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu);
3151d30ea906Sjfb8856606 
3152d30ea906Sjfb8856606 /**
3153d30ea906Sjfb8856606  * Enable/Disable hardware filtering by an Ethernet device of received
3154d30ea906Sjfb8856606  * VLAN packets tagged with a given VLAN Tag Identifier.
3155d30ea906Sjfb8856606  *
3156d30ea906Sjfb8856606  * @param port_id
3157d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3158d30ea906Sjfb8856606  * @param vlan_id
3159d30ea906Sjfb8856606  *   The VLAN Tag Identifier whose filtering must be enabled or disabled.
3160d30ea906Sjfb8856606  * @param on
3161d30ea906Sjfb8856606  *   If > 0, enable VLAN filtering of VLAN packets tagged with *vlan_id*.
3162d30ea906Sjfb8856606  *   Otherwise, disable VLAN filtering of VLAN packets tagged with *vlan_id*.
3163d30ea906Sjfb8856606  * @return
3164d30ea906Sjfb8856606  *   - (0) if successful.
31654418919fSjohnjiang  *   - (-ENOTSUP) if hardware-assisted VLAN filtering not configured.
3166d30ea906Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
3167d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
3168d30ea906Sjfb8856606  *   - (-ENOSYS) if VLAN filtering on *port_id* disabled.
3169d30ea906Sjfb8856606  *   - (-EINVAL) if *vlan_id* > 4095.
3170d30ea906Sjfb8856606  */
3171d30ea906Sjfb8856606 int rte_eth_dev_vlan_filter(uint16_t port_id, uint16_t vlan_id, int on);
3172d30ea906Sjfb8856606 
3173d30ea906Sjfb8856606 /**
3174d30ea906Sjfb8856606  * Enable/Disable hardware VLAN Strip by a rx queue of an Ethernet device.
3175d30ea906Sjfb8856606  *
3176d30ea906Sjfb8856606  * @param port_id
3177d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3178d30ea906Sjfb8856606  * @param rx_queue_id
3179d30ea906Sjfb8856606  *   The index of the receive queue for which a queue stats mapping is required.
3180d30ea906Sjfb8856606  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
3181d30ea906Sjfb8856606  *   to rte_eth_dev_configure().
3182d30ea906Sjfb8856606  * @param on
3183d30ea906Sjfb8856606  *   If 1, Enable VLAN Stripping of the receive queue of the Ethernet port.
3184d30ea906Sjfb8856606  *   If 0, Disable VLAN Stripping of the receive queue of the Ethernet port.
3185d30ea906Sjfb8856606  * @return
3186d30ea906Sjfb8856606  *   - (0) if successful.
31874418919fSjohnjiang  *   - (-ENOTSUP) if hardware-assisted VLAN stripping not configured.
3188d30ea906Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
3189d30ea906Sjfb8856606  *   - (-EINVAL) if *rx_queue_id* invalid.
3190d30ea906Sjfb8856606  */
3191d30ea906Sjfb8856606 int rte_eth_dev_set_vlan_strip_on_queue(uint16_t port_id, uint16_t rx_queue_id,
3192d30ea906Sjfb8856606 		int on);
3193d30ea906Sjfb8856606 
3194d30ea906Sjfb8856606 /**
3195d30ea906Sjfb8856606  * Set the Outer VLAN Ether Type by an Ethernet device, it can be inserted to
3196*2d9fd380Sjfb8856606  * the VLAN header.
3197d30ea906Sjfb8856606  *
3198d30ea906Sjfb8856606  * @param port_id
3199d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3200d30ea906Sjfb8856606  * @param vlan_type
3201d30ea906Sjfb8856606  *   The vlan type.
3202d30ea906Sjfb8856606  * @param tag_type
3203d30ea906Sjfb8856606  *   The Tag Protocol ID
3204d30ea906Sjfb8856606  * @return
3205d30ea906Sjfb8856606  *   - (0) if successful.
32064418919fSjohnjiang  *   - (-ENOTSUP) if hardware-assisted VLAN TPID setup is not supported.
3207d30ea906Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
3208d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
3209d30ea906Sjfb8856606  */
3210d30ea906Sjfb8856606 int rte_eth_dev_set_vlan_ether_type(uint16_t port_id,
3211d30ea906Sjfb8856606 				    enum rte_vlan_type vlan_type,
3212d30ea906Sjfb8856606 				    uint16_t tag_type);
3213d30ea906Sjfb8856606 
3214d30ea906Sjfb8856606 /**
3215*2d9fd380Sjfb8856606  * Set VLAN offload configuration on an Ethernet device.
3216d30ea906Sjfb8856606  *
3217d30ea906Sjfb8856606  * @param port_id
3218d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3219d30ea906Sjfb8856606  * @param offload_mask
3220d30ea906Sjfb8856606  *   The VLAN Offload bit mask can be mixed use with "OR"
3221d30ea906Sjfb8856606  *       ETH_VLAN_STRIP_OFFLOAD
3222d30ea906Sjfb8856606  *       ETH_VLAN_FILTER_OFFLOAD
3223d30ea906Sjfb8856606  *       ETH_VLAN_EXTEND_OFFLOAD
32244418919fSjohnjiang  *       ETH_QINQ_STRIP_OFFLOAD
3225d30ea906Sjfb8856606  * @return
3226d30ea906Sjfb8856606  *   - (0) if successful.
32274418919fSjohnjiang  *   - (-ENOTSUP) if hardware-assisted VLAN filtering not configured.
3228d30ea906Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
3229d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
3230d30ea906Sjfb8856606  */
3231d30ea906Sjfb8856606 int rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask);
3232d30ea906Sjfb8856606 
3233d30ea906Sjfb8856606 /**
3234d30ea906Sjfb8856606  * Read VLAN Offload configuration from an Ethernet device
3235d30ea906Sjfb8856606  *
3236d30ea906Sjfb8856606  * @param port_id
3237d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3238d30ea906Sjfb8856606  * @return
3239d30ea906Sjfb8856606  *   - (>0) if successful. Bit mask to indicate
3240d30ea906Sjfb8856606  *       ETH_VLAN_STRIP_OFFLOAD
3241d30ea906Sjfb8856606  *       ETH_VLAN_FILTER_OFFLOAD
3242d30ea906Sjfb8856606  *       ETH_VLAN_EXTEND_OFFLOAD
32434418919fSjohnjiang  *       ETH_QINQ_STRIP_OFFLOAD
3244d30ea906Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
3245d30ea906Sjfb8856606  */
3246d30ea906Sjfb8856606 int rte_eth_dev_get_vlan_offload(uint16_t port_id);
3247d30ea906Sjfb8856606 
3248d30ea906Sjfb8856606 /**
3249d30ea906Sjfb8856606  * Set port based TX VLAN insertion on or off.
3250d30ea906Sjfb8856606  *
3251d30ea906Sjfb8856606  * @param port_id
3252d30ea906Sjfb8856606  *  The port identifier of the Ethernet device.
3253d30ea906Sjfb8856606  * @param pvid
3254d30ea906Sjfb8856606  *  Port based TX VLAN identifier together with user priority.
3255d30ea906Sjfb8856606  * @param on
3256d30ea906Sjfb8856606  *  Turn on or off the port based TX VLAN insertion.
3257d30ea906Sjfb8856606  *
3258d30ea906Sjfb8856606  * @return
3259d30ea906Sjfb8856606  *   - (0) if successful.
3260d30ea906Sjfb8856606  *   - negative if failed.
3261d30ea906Sjfb8856606  */
3262d30ea906Sjfb8856606 int rte_eth_dev_set_vlan_pvid(uint16_t port_id, uint16_t pvid, int on);
3263d30ea906Sjfb8856606 
3264d30ea906Sjfb8856606 typedef void (*buffer_tx_error_fn)(struct rte_mbuf **unsent, uint16_t count,
3265d30ea906Sjfb8856606 		void *userdata);
3266d30ea906Sjfb8856606 
3267d30ea906Sjfb8856606 /**
3268d30ea906Sjfb8856606  * Structure used to buffer packets for future TX
3269d30ea906Sjfb8856606  * Used by APIs rte_eth_tx_buffer and rte_eth_tx_buffer_flush
3270d30ea906Sjfb8856606  */
3271d30ea906Sjfb8856606 struct rte_eth_dev_tx_buffer {
3272d30ea906Sjfb8856606 	buffer_tx_error_fn error_callback;
3273d30ea906Sjfb8856606 	void *error_userdata;
3274d30ea906Sjfb8856606 	uint16_t size;           /**< Size of buffer for buffered tx */
3275d30ea906Sjfb8856606 	uint16_t length;         /**< Number of packets in the array */
3276d30ea906Sjfb8856606 	struct rte_mbuf *pkts[];
3277d30ea906Sjfb8856606 	/**< Pending packets to be sent on explicit flush or when full */
3278d30ea906Sjfb8856606 };
3279d30ea906Sjfb8856606 
3280d30ea906Sjfb8856606 /**
3281d30ea906Sjfb8856606  * Calculate the size of the tx buffer.
3282d30ea906Sjfb8856606  *
3283d30ea906Sjfb8856606  * @param sz
3284d30ea906Sjfb8856606  *   Number of stored packets.
3285d30ea906Sjfb8856606  */
3286d30ea906Sjfb8856606 #define RTE_ETH_TX_BUFFER_SIZE(sz) \
3287d30ea906Sjfb8856606 	(sizeof(struct rte_eth_dev_tx_buffer) + (sz) * sizeof(struct rte_mbuf *))
3288d30ea906Sjfb8856606 
3289d30ea906Sjfb8856606 /**
3290d30ea906Sjfb8856606  * Initialize default values for buffered transmitting
3291d30ea906Sjfb8856606  *
3292d30ea906Sjfb8856606  * @param buffer
3293d30ea906Sjfb8856606  *   Tx buffer to be initialized.
3294d30ea906Sjfb8856606  * @param size
3295d30ea906Sjfb8856606  *   Buffer size
3296d30ea906Sjfb8856606  * @return
3297d30ea906Sjfb8856606  *   0 if no error
3298d30ea906Sjfb8856606  */
3299d30ea906Sjfb8856606 int
3300d30ea906Sjfb8856606 rte_eth_tx_buffer_init(struct rte_eth_dev_tx_buffer *buffer, uint16_t size);
3301d30ea906Sjfb8856606 
3302d30ea906Sjfb8856606 /**
3303d30ea906Sjfb8856606  * Configure a callback for buffered packets which cannot be sent
3304d30ea906Sjfb8856606  *
3305d30ea906Sjfb8856606  * Register a specific callback to be called when an attempt is made to send
3306d30ea906Sjfb8856606  * all packets buffered on an ethernet port, but not all packets can
3307d30ea906Sjfb8856606  * successfully be sent. The callback registered here will be called only
3308d30ea906Sjfb8856606  * from calls to rte_eth_tx_buffer() and rte_eth_tx_buffer_flush() APIs.
3309d30ea906Sjfb8856606  * The default callback configured for each queue by default just frees the
3310d30ea906Sjfb8856606  * packets back to the calling mempool. If additional behaviour is required,
3311d30ea906Sjfb8856606  * for example, to count dropped packets, or to retry transmission of packets
3312d30ea906Sjfb8856606  * which cannot be sent, this function should be used to register a suitable
3313d30ea906Sjfb8856606  * callback function to implement the desired behaviour.
3314d30ea906Sjfb8856606  * The example callback "rte_eth_count_unsent_packet_callback()" is also
3315d30ea906Sjfb8856606  * provided as reference.
3316d30ea906Sjfb8856606  *
3317d30ea906Sjfb8856606  * @param buffer
3318d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3319d30ea906Sjfb8856606  * @param callback
3320d30ea906Sjfb8856606  *   The function to be used as the callback.
3321d30ea906Sjfb8856606  * @param userdata
3322d30ea906Sjfb8856606  *   Arbitrary parameter to be passed to the callback function
3323d30ea906Sjfb8856606  * @return
3324d30ea906Sjfb8856606  *   0 on success, or -1 on error with rte_errno set appropriately
3325d30ea906Sjfb8856606  */
3326d30ea906Sjfb8856606 int
3327d30ea906Sjfb8856606 rte_eth_tx_buffer_set_err_callback(struct rte_eth_dev_tx_buffer *buffer,
3328d30ea906Sjfb8856606 		buffer_tx_error_fn callback, void *userdata);
3329d30ea906Sjfb8856606 
3330d30ea906Sjfb8856606 /**
3331d30ea906Sjfb8856606  * Callback function for silently dropping unsent buffered packets.
3332d30ea906Sjfb8856606  *
3333d30ea906Sjfb8856606  * This function can be passed to rte_eth_tx_buffer_set_err_callback() to
3334d30ea906Sjfb8856606  * adjust the default behavior when buffered packets cannot be sent. This
3335d30ea906Sjfb8856606  * function drops any unsent packets silently and is used by tx buffered
3336d30ea906Sjfb8856606  * operations as default behavior.
3337d30ea906Sjfb8856606  *
3338d30ea906Sjfb8856606  * NOTE: this function should not be called directly, instead it should be used
3339d30ea906Sjfb8856606  *       as a callback for packet buffering.
3340d30ea906Sjfb8856606  *
3341d30ea906Sjfb8856606  * NOTE: when configuring this function as a callback with
3342d30ea906Sjfb8856606  *       rte_eth_tx_buffer_set_err_callback(), the final, userdata parameter
3343d30ea906Sjfb8856606  *       should point to an uint64_t value.
3344d30ea906Sjfb8856606  *
3345d30ea906Sjfb8856606  * @param pkts
3346d30ea906Sjfb8856606  *   The previously buffered packets which could not be sent
3347d30ea906Sjfb8856606  * @param unsent
3348d30ea906Sjfb8856606  *   The number of unsent packets in the pkts array
3349d30ea906Sjfb8856606  * @param userdata
3350d30ea906Sjfb8856606  *   Not used
3351d30ea906Sjfb8856606  */
3352d30ea906Sjfb8856606 void
3353d30ea906Sjfb8856606 rte_eth_tx_buffer_drop_callback(struct rte_mbuf **pkts, uint16_t unsent,
3354d30ea906Sjfb8856606 		void *userdata);
3355d30ea906Sjfb8856606 
3356d30ea906Sjfb8856606 /**
3357d30ea906Sjfb8856606  * Callback function for tracking unsent buffered packets.
3358d30ea906Sjfb8856606  *
3359d30ea906Sjfb8856606  * This function can be passed to rte_eth_tx_buffer_set_err_callback() to
3360d30ea906Sjfb8856606  * adjust the default behavior when buffered packets cannot be sent. This
3361d30ea906Sjfb8856606  * function drops any unsent packets, but also updates a user-supplied counter
3362d30ea906Sjfb8856606  * to track the overall number of packets dropped. The counter should be an
3363d30ea906Sjfb8856606  * uint64_t variable.
3364d30ea906Sjfb8856606  *
3365d30ea906Sjfb8856606  * NOTE: this function should not be called directly, instead it should be used
3366d30ea906Sjfb8856606  *       as a callback for packet buffering.
3367d30ea906Sjfb8856606  *
3368d30ea906Sjfb8856606  * NOTE: when configuring this function as a callback with
3369d30ea906Sjfb8856606  *       rte_eth_tx_buffer_set_err_callback(), the final, userdata parameter
3370d30ea906Sjfb8856606  *       should point to an uint64_t value.
3371d30ea906Sjfb8856606  *
3372d30ea906Sjfb8856606  * @param pkts
3373d30ea906Sjfb8856606  *   The previously buffered packets which could not be sent
3374d30ea906Sjfb8856606  * @param unsent
3375d30ea906Sjfb8856606  *   The number of unsent packets in the pkts array
3376d30ea906Sjfb8856606  * @param userdata
3377d30ea906Sjfb8856606  *   Pointer to an uint64_t value, which will be incremented by unsent
3378d30ea906Sjfb8856606  */
3379d30ea906Sjfb8856606 void
3380d30ea906Sjfb8856606 rte_eth_tx_buffer_count_callback(struct rte_mbuf **pkts, uint16_t unsent,
3381d30ea906Sjfb8856606 		void *userdata);
3382d30ea906Sjfb8856606 
3383d30ea906Sjfb8856606 /**
3384d30ea906Sjfb8856606  * Request the driver to free mbufs currently cached by the driver. The
3385d30ea906Sjfb8856606  * driver will only free the mbuf if it is no longer in use. It is the
33861646932aSjfb8856606  * application's responsibility to ensure rte_eth_tx_buffer_flush(..) is
3387d30ea906Sjfb8856606  * called if needed.
3388d30ea906Sjfb8856606  *
3389d30ea906Sjfb8856606  * @param port_id
3390d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3391d30ea906Sjfb8856606  * @param queue_id
3392d30ea906Sjfb8856606  *   The index of the transmit queue through which output packets must be
3393d30ea906Sjfb8856606  *   sent.
3394d30ea906Sjfb8856606  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
3395d30ea906Sjfb8856606  *   to rte_eth_dev_configure().
3396d30ea906Sjfb8856606  * @param free_cnt
3397d30ea906Sjfb8856606  *   Maximum number of packets to free. Use 0 to indicate all possible packets
3398d30ea906Sjfb8856606  *   should be freed. Note that a packet may be using multiple mbufs.
3399d30ea906Sjfb8856606  * @return
3400d30ea906Sjfb8856606  *   Failure: < 0
3401d30ea906Sjfb8856606  *     -ENODEV: Invalid interface
3402d30ea906Sjfb8856606  *     -EIO: device is removed
3403d30ea906Sjfb8856606  *     -ENOTSUP: Driver does not support function
3404d30ea906Sjfb8856606  *   Success: >= 0
3405d30ea906Sjfb8856606  *     0-n: Number of packets freed. More packets may still remain in ring that
3406d30ea906Sjfb8856606  *     are in use.
3407d30ea906Sjfb8856606  */
3408d30ea906Sjfb8856606 int
3409d30ea906Sjfb8856606 rte_eth_tx_done_cleanup(uint16_t port_id, uint16_t queue_id, uint32_t free_cnt);
3410d30ea906Sjfb8856606 
3411d30ea906Sjfb8856606 /**
3412d30ea906Sjfb8856606  * Subtypes for IPsec offload event(@ref RTE_ETH_EVENT_IPSEC) raised by
3413d30ea906Sjfb8856606  * eth device.
3414d30ea906Sjfb8856606  */
3415d30ea906Sjfb8856606 enum rte_eth_event_ipsec_subtype {
3416d30ea906Sjfb8856606 	RTE_ETH_EVENT_IPSEC_UNKNOWN = 0,
3417d30ea906Sjfb8856606 			/**< Unknown event type */
3418d30ea906Sjfb8856606 	RTE_ETH_EVENT_IPSEC_ESN_OVERFLOW,
3419d30ea906Sjfb8856606 			/**< Sequence number overflow */
3420d30ea906Sjfb8856606 	RTE_ETH_EVENT_IPSEC_SA_TIME_EXPIRY,
3421d30ea906Sjfb8856606 			/**< Soft time expiry of SA */
3422d30ea906Sjfb8856606 	RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY,
3423d30ea906Sjfb8856606 			/**< Soft byte expiry of SA */
3424d30ea906Sjfb8856606 	RTE_ETH_EVENT_IPSEC_MAX
3425d30ea906Sjfb8856606 			/**< Max value of this enum */
3426d30ea906Sjfb8856606 };
3427d30ea906Sjfb8856606 
3428d30ea906Sjfb8856606 /**
3429d30ea906Sjfb8856606  * Descriptor for @ref RTE_ETH_EVENT_IPSEC event. Used by eth dev to send extra
3430d30ea906Sjfb8856606  * information of the IPsec offload event.
3431d30ea906Sjfb8856606  */
3432d30ea906Sjfb8856606 struct rte_eth_event_ipsec_desc {
3433d30ea906Sjfb8856606 	enum rte_eth_event_ipsec_subtype subtype;
3434d30ea906Sjfb8856606 			/**< Type of RTE_ETH_EVENT_IPSEC_* event */
3435d30ea906Sjfb8856606 	uint64_t metadata;
3436d30ea906Sjfb8856606 			/**< Event specific metadata
3437d30ea906Sjfb8856606 			 *
3438d30ea906Sjfb8856606 			 * For the following events, *userdata* registered
3439d30ea906Sjfb8856606 			 * with the *rte_security_session* would be returned
3440d30ea906Sjfb8856606 			 * as metadata,
3441d30ea906Sjfb8856606 			 *
3442d30ea906Sjfb8856606 			 * - @ref RTE_ETH_EVENT_IPSEC_ESN_OVERFLOW
3443d30ea906Sjfb8856606 			 * - @ref RTE_ETH_EVENT_IPSEC_SA_TIME_EXPIRY
3444d30ea906Sjfb8856606 			 * - @ref RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY
3445d30ea906Sjfb8856606 			 *
3446d30ea906Sjfb8856606 			 * @see struct rte_security_session_conf
3447d30ea906Sjfb8856606 			 *
3448d30ea906Sjfb8856606 			 */
3449d30ea906Sjfb8856606 };
3450d30ea906Sjfb8856606 
3451d30ea906Sjfb8856606 /**
3452d30ea906Sjfb8856606  * The eth device event type for interrupt, and maybe others in the future.
3453d30ea906Sjfb8856606  */
3454d30ea906Sjfb8856606 enum rte_eth_event_type {
3455d30ea906Sjfb8856606 	RTE_ETH_EVENT_UNKNOWN,  /**< unknown event type */
3456d30ea906Sjfb8856606 	RTE_ETH_EVENT_INTR_LSC, /**< lsc interrupt event */
3457d30ea906Sjfb8856606 	RTE_ETH_EVENT_QUEUE_STATE,
3458d30ea906Sjfb8856606 				/**< queue state event (enabled/disabled) */
3459d30ea906Sjfb8856606 	RTE_ETH_EVENT_INTR_RESET,
3460d30ea906Sjfb8856606 			/**< reset interrupt event, sent to VF on PF reset */
3461d30ea906Sjfb8856606 	RTE_ETH_EVENT_VF_MBOX,  /**< message from the VF received by PF */
3462d30ea906Sjfb8856606 	RTE_ETH_EVENT_MACSEC,   /**< MACsec offload related event */
3463d30ea906Sjfb8856606 	RTE_ETH_EVENT_INTR_RMV, /**< device removal event */
3464d30ea906Sjfb8856606 	RTE_ETH_EVENT_NEW,      /**< port is probed */
3465d30ea906Sjfb8856606 	RTE_ETH_EVENT_DESTROY,  /**< port is released */
3466d30ea906Sjfb8856606 	RTE_ETH_EVENT_IPSEC,    /**< IPsec offload related event */
3467*2d9fd380Sjfb8856606 	RTE_ETH_EVENT_FLOW_AGED,/**< New aged-out flows is detected */
3468d30ea906Sjfb8856606 	RTE_ETH_EVENT_MAX       /**< max value of this enum */
3469d30ea906Sjfb8856606 };
3470d30ea906Sjfb8856606 
3471d30ea906Sjfb8856606 typedef int (*rte_eth_dev_cb_fn)(uint16_t port_id,
3472d30ea906Sjfb8856606 		enum rte_eth_event_type event, void *cb_arg, void *ret_param);
3473d30ea906Sjfb8856606 /**< user application callback to be registered for interrupts */
3474d30ea906Sjfb8856606 
3475d30ea906Sjfb8856606 /**
3476d30ea906Sjfb8856606  * Register a callback function for port event.
3477d30ea906Sjfb8856606  *
3478d30ea906Sjfb8856606  * @param port_id
3479d30ea906Sjfb8856606  *  Port id.
3480d30ea906Sjfb8856606  *  RTE_ETH_ALL means register the event for all port ids.
3481d30ea906Sjfb8856606  * @param event
3482d30ea906Sjfb8856606  *  Event interested.
3483d30ea906Sjfb8856606  * @param cb_fn
3484d30ea906Sjfb8856606  *  User supplied callback function to be called.
3485d30ea906Sjfb8856606  * @param cb_arg
3486d30ea906Sjfb8856606  *  Pointer to the parameters for the registered callback.
3487d30ea906Sjfb8856606  *
3488d30ea906Sjfb8856606  * @return
3489d30ea906Sjfb8856606  *  - On success, zero.
3490d30ea906Sjfb8856606  *  - On failure, a negative value.
3491d30ea906Sjfb8856606  */
3492d30ea906Sjfb8856606 int rte_eth_dev_callback_register(uint16_t port_id,
3493d30ea906Sjfb8856606 			enum rte_eth_event_type event,
3494d30ea906Sjfb8856606 		rte_eth_dev_cb_fn cb_fn, void *cb_arg);
3495d30ea906Sjfb8856606 
3496d30ea906Sjfb8856606 /**
3497d30ea906Sjfb8856606  * Unregister a callback function for port event.
3498d30ea906Sjfb8856606  *
3499d30ea906Sjfb8856606  * @param port_id
3500d30ea906Sjfb8856606  *  Port id.
3501d30ea906Sjfb8856606  *  RTE_ETH_ALL means unregister the event for all port ids.
3502d30ea906Sjfb8856606  * @param event
3503d30ea906Sjfb8856606  *  Event interested.
3504d30ea906Sjfb8856606  * @param cb_fn
3505d30ea906Sjfb8856606  *  User supplied callback function to be called.
3506d30ea906Sjfb8856606  * @param cb_arg
3507d30ea906Sjfb8856606  *  Pointer to the parameters for the registered callback. -1 means to
3508d30ea906Sjfb8856606  *  remove all for the same callback address and same event.
3509d30ea906Sjfb8856606  *
3510d30ea906Sjfb8856606  * @return
3511d30ea906Sjfb8856606  *  - On success, zero.
3512d30ea906Sjfb8856606  *  - On failure, a negative value.
3513d30ea906Sjfb8856606  */
3514d30ea906Sjfb8856606 int rte_eth_dev_callback_unregister(uint16_t port_id,
3515d30ea906Sjfb8856606 			enum rte_eth_event_type event,
3516d30ea906Sjfb8856606 		rte_eth_dev_cb_fn cb_fn, void *cb_arg);
3517d30ea906Sjfb8856606 
3518d30ea906Sjfb8856606 /**
3519d30ea906Sjfb8856606  * When there is no rx packet coming in Rx Queue for a long time, we can
3520d30ea906Sjfb8856606  * sleep lcore related to RX Queue for power saving, and enable rx interrupt
3521d30ea906Sjfb8856606  * to be triggered when Rx packet arrives.
3522d30ea906Sjfb8856606  *
3523d30ea906Sjfb8856606  * The rte_eth_dev_rx_intr_enable() function enables rx queue
3524d30ea906Sjfb8856606  * interrupt on specific rx queue of a port.
3525d30ea906Sjfb8856606  *
3526d30ea906Sjfb8856606  * @param port_id
3527d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3528d30ea906Sjfb8856606  * @param queue_id
3529d30ea906Sjfb8856606  *   The index of the receive queue from which to retrieve input packets.
3530d30ea906Sjfb8856606  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
3531d30ea906Sjfb8856606  *   to rte_eth_dev_configure().
3532d30ea906Sjfb8856606  * @return
3533d30ea906Sjfb8856606  *   - (0) if successful.
3534d30ea906Sjfb8856606  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
3535d30ea906Sjfb8856606  *     that operation.
3536d30ea906Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
3537d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
3538d30ea906Sjfb8856606  */
3539d30ea906Sjfb8856606 int rte_eth_dev_rx_intr_enable(uint16_t port_id, uint16_t queue_id);
3540d30ea906Sjfb8856606 
3541d30ea906Sjfb8856606 /**
3542d30ea906Sjfb8856606  * When lcore wakes up from rx interrupt indicating packet coming, disable rx
3543d30ea906Sjfb8856606  * interrupt and returns to polling mode.
3544d30ea906Sjfb8856606  *
3545d30ea906Sjfb8856606  * The rte_eth_dev_rx_intr_disable() function disables rx queue
3546d30ea906Sjfb8856606  * interrupt on specific rx queue of a port.
3547d30ea906Sjfb8856606  *
3548d30ea906Sjfb8856606  * @param port_id
3549d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3550d30ea906Sjfb8856606  * @param queue_id
3551d30ea906Sjfb8856606  *   The index of the receive queue from which to retrieve input packets.
3552d30ea906Sjfb8856606  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
3553d30ea906Sjfb8856606  *   to rte_eth_dev_configure().
3554d30ea906Sjfb8856606  * @return
3555d30ea906Sjfb8856606  *   - (0) if successful.
3556d30ea906Sjfb8856606  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
3557d30ea906Sjfb8856606  *     that operation.
3558d30ea906Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
3559d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
3560d30ea906Sjfb8856606  */
3561d30ea906Sjfb8856606 int rte_eth_dev_rx_intr_disable(uint16_t port_id, uint16_t queue_id);
3562d30ea906Sjfb8856606 
3563d30ea906Sjfb8856606 /**
3564d30ea906Sjfb8856606  * RX Interrupt control per port.
3565d30ea906Sjfb8856606  *
3566d30ea906Sjfb8856606  * @param port_id
3567d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3568d30ea906Sjfb8856606  * @param epfd
3569d30ea906Sjfb8856606  *   Epoll instance fd which the intr vector associated to.
3570d30ea906Sjfb8856606  *   Using RTE_EPOLL_PER_THREAD allows to use per thread epoll instance.
3571d30ea906Sjfb8856606  * @param op
3572d30ea906Sjfb8856606  *   The operation be performed for the vector.
3573d30ea906Sjfb8856606  *   Operation type of {RTE_INTR_EVENT_ADD, RTE_INTR_EVENT_DEL}.
3574d30ea906Sjfb8856606  * @param data
3575d30ea906Sjfb8856606  *   User raw data.
3576d30ea906Sjfb8856606  * @return
3577d30ea906Sjfb8856606  *   - On success, zero.
3578d30ea906Sjfb8856606  *   - On failure, a negative value.
3579d30ea906Sjfb8856606  */
3580d30ea906Sjfb8856606 int rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data);
3581d30ea906Sjfb8856606 
3582d30ea906Sjfb8856606 /**
3583d30ea906Sjfb8856606  * RX Interrupt control per queue.
3584d30ea906Sjfb8856606  *
3585d30ea906Sjfb8856606  * @param port_id
3586d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3587d30ea906Sjfb8856606  * @param queue_id
3588d30ea906Sjfb8856606  *   The index of the receive queue from which to retrieve input packets.
3589d30ea906Sjfb8856606  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
3590d30ea906Sjfb8856606  *   to rte_eth_dev_configure().
3591d30ea906Sjfb8856606  * @param epfd
3592d30ea906Sjfb8856606  *   Epoll instance fd which the intr vector associated to.
3593d30ea906Sjfb8856606  *   Using RTE_EPOLL_PER_THREAD allows to use per thread epoll instance.
3594d30ea906Sjfb8856606  * @param op
3595d30ea906Sjfb8856606  *   The operation be performed for the vector.
3596d30ea906Sjfb8856606  *   Operation type of {RTE_INTR_EVENT_ADD, RTE_INTR_EVENT_DEL}.
3597d30ea906Sjfb8856606  * @param data
3598d30ea906Sjfb8856606  *   User raw data.
3599d30ea906Sjfb8856606  * @return
3600d30ea906Sjfb8856606  *   - On success, zero.
3601d30ea906Sjfb8856606  *   - On failure, a negative value.
3602d30ea906Sjfb8856606  */
3603d30ea906Sjfb8856606 int rte_eth_dev_rx_intr_ctl_q(uint16_t port_id, uint16_t queue_id,
3604d30ea906Sjfb8856606 			      int epfd, int op, void *data);
3605d30ea906Sjfb8856606 
3606d30ea906Sjfb8856606 /**
3607d30ea906Sjfb8856606  * @warning
3608d30ea906Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
3609d30ea906Sjfb8856606  *
3610d30ea906Sjfb8856606  * Get interrupt fd per Rx queue.
3611d30ea906Sjfb8856606  *
3612d30ea906Sjfb8856606  * @param port_id
3613d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3614d30ea906Sjfb8856606  * @param queue_id
3615d30ea906Sjfb8856606  *   The index of the receive queue from which to retrieve input packets.
3616d30ea906Sjfb8856606  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
3617d30ea906Sjfb8856606  *   to rte_eth_dev_configure().
3618d30ea906Sjfb8856606  * @return
3619d30ea906Sjfb8856606  *   - (>=0) the interrupt fd associated to the requested Rx queue if
3620d30ea906Sjfb8856606  *           successful.
3621d30ea906Sjfb8856606  *   - (-1) on error.
3622d30ea906Sjfb8856606  */
36234418919fSjohnjiang __rte_experimental
36244418919fSjohnjiang int
3625d30ea906Sjfb8856606 rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t queue_id);
3626d30ea906Sjfb8856606 
3627d30ea906Sjfb8856606 /**
3628d30ea906Sjfb8856606  * Turn on the LED on the Ethernet device.
3629d30ea906Sjfb8856606  * This function turns on the LED on the Ethernet device.
3630d30ea906Sjfb8856606  *
3631d30ea906Sjfb8856606  * @param port_id
3632d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3633d30ea906Sjfb8856606  * @return
3634d30ea906Sjfb8856606  *   - (0) if successful.
3635d30ea906Sjfb8856606  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
3636d30ea906Sjfb8856606  *     that operation.
3637d30ea906Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
3638d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
3639d30ea906Sjfb8856606  */
3640d30ea906Sjfb8856606 int  rte_eth_led_on(uint16_t port_id);
3641d30ea906Sjfb8856606 
3642d30ea906Sjfb8856606 /**
3643d30ea906Sjfb8856606  * Turn off the LED on the Ethernet device.
3644d30ea906Sjfb8856606  * This function turns off the LED on the Ethernet device.
3645d30ea906Sjfb8856606  *
3646d30ea906Sjfb8856606  * @param port_id
3647d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3648d30ea906Sjfb8856606  * @return
3649d30ea906Sjfb8856606  *   - (0) if successful.
3650d30ea906Sjfb8856606  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
3651d30ea906Sjfb8856606  *     that operation.
3652d30ea906Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
3653d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
3654d30ea906Sjfb8856606  */
3655d30ea906Sjfb8856606 int  rte_eth_led_off(uint16_t port_id);
3656d30ea906Sjfb8856606 
3657d30ea906Sjfb8856606 /**
3658*2d9fd380Sjfb8856606  * @warning
3659*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
3660*2d9fd380Sjfb8856606  *
3661*2d9fd380Sjfb8856606  * Get Forward Error Correction(FEC) capability.
3662*2d9fd380Sjfb8856606  *
3663*2d9fd380Sjfb8856606  * @param port_id
3664*2d9fd380Sjfb8856606  *   The port identifier of the Ethernet device.
3665*2d9fd380Sjfb8856606  * @param speed_fec_capa
3666*2d9fd380Sjfb8856606  *   speed_fec_capa is out only with per-speed capabilities.
3667*2d9fd380Sjfb8856606  *   If set to NULL, the function returns the required number
3668*2d9fd380Sjfb8856606  *   of required array entries.
3669*2d9fd380Sjfb8856606  * @param num
3670*2d9fd380Sjfb8856606  *   a number of elements in an speed_fec_capa array.
3671*2d9fd380Sjfb8856606  *
3672*2d9fd380Sjfb8856606  * @return
3673*2d9fd380Sjfb8856606  *   - A non-negative value lower or equal to num: success. The return value
3674*2d9fd380Sjfb8856606  *     is the number of entries filled in the fec capa array.
3675*2d9fd380Sjfb8856606  *   - A non-negative value higher than num: error, the given fec capa array
3676*2d9fd380Sjfb8856606  *     is too small. The return value corresponds to the num that should
3677*2d9fd380Sjfb8856606  *     be given to succeed. The entries in fec capa array are not valid and
3678*2d9fd380Sjfb8856606  *     shall not be used by the caller.
3679*2d9fd380Sjfb8856606  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
3680*2d9fd380Sjfb8856606  *     that operation.
3681*2d9fd380Sjfb8856606  *   - (-EIO) if device is removed.
3682*2d9fd380Sjfb8856606  *   - (-ENODEV)  if *port_id* invalid.
3683*2d9fd380Sjfb8856606  *   - (-EINVAL)  if *num* or *speed_fec_capa* invalid
3684*2d9fd380Sjfb8856606  */
3685*2d9fd380Sjfb8856606 __rte_experimental
3686*2d9fd380Sjfb8856606 int rte_eth_fec_get_capability(uint16_t port_id,
3687*2d9fd380Sjfb8856606 			       struct rte_eth_fec_capa *speed_fec_capa,
3688*2d9fd380Sjfb8856606 			       unsigned int num);
3689*2d9fd380Sjfb8856606 
3690*2d9fd380Sjfb8856606 /**
3691*2d9fd380Sjfb8856606  * @warning
3692*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
3693*2d9fd380Sjfb8856606  *
3694*2d9fd380Sjfb8856606  * Get current Forward Error Correction(FEC) mode.
3695*2d9fd380Sjfb8856606  * If link is down and AUTO is enabled, AUTO is returned, otherwise,
3696*2d9fd380Sjfb8856606  * configured FEC mode is returned.
3697*2d9fd380Sjfb8856606  * If link is up, current FEC mode is returned.
3698*2d9fd380Sjfb8856606  *
3699*2d9fd380Sjfb8856606  * @param port_id
3700*2d9fd380Sjfb8856606  *   The port identifier of the Ethernet device.
3701*2d9fd380Sjfb8856606  * @param fec_capa
3702*2d9fd380Sjfb8856606  *   A bitmask of enabled FEC modes. If AUTO bit is set, other
3703*2d9fd380Sjfb8856606  *   bits specify FEC modes which may be negotiated. If AUTO
3704*2d9fd380Sjfb8856606  *   bit is clear, specify FEC modes to be used (only one valid
3705*2d9fd380Sjfb8856606  *   mode per speed may be set).
3706*2d9fd380Sjfb8856606  * @return
3707*2d9fd380Sjfb8856606  *   - (0) if successful.
3708*2d9fd380Sjfb8856606  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
3709*2d9fd380Sjfb8856606  *     that operation.
3710*2d9fd380Sjfb8856606  *   - (-EIO) if device is removed.
3711*2d9fd380Sjfb8856606  *   - (-ENODEV)  if *port_id* invalid.
3712*2d9fd380Sjfb8856606  */
3713*2d9fd380Sjfb8856606 __rte_experimental
3714*2d9fd380Sjfb8856606 int rte_eth_fec_get(uint16_t port_id, uint32_t *fec_capa);
3715*2d9fd380Sjfb8856606 
3716*2d9fd380Sjfb8856606 /**
3717*2d9fd380Sjfb8856606  * @warning
3718*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
3719*2d9fd380Sjfb8856606  *
3720*2d9fd380Sjfb8856606  * Set Forward Error Correction(FEC) mode.
3721*2d9fd380Sjfb8856606  *
3722*2d9fd380Sjfb8856606  * @param port_id
3723*2d9fd380Sjfb8856606  *   The port identifier of the Ethernet device.
3724*2d9fd380Sjfb8856606  * @param fec_capa
3725*2d9fd380Sjfb8856606  *   A bitmask of allowed FEC modes. If AUTO bit is set, other
3726*2d9fd380Sjfb8856606  *   bits specify FEC modes which may be negotiated. If AUTO
3727*2d9fd380Sjfb8856606  *   bit is clear, specify FEC modes to be used (only one valid
3728*2d9fd380Sjfb8856606  *   mode per speed may be set).
3729*2d9fd380Sjfb8856606  * @return
3730*2d9fd380Sjfb8856606  *   - (0) if successful.
3731*2d9fd380Sjfb8856606  *   - (-EINVAL) if the FEC mode is not valid.
3732*2d9fd380Sjfb8856606  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
3733*2d9fd380Sjfb8856606  *   - (-EIO) if device is removed.
3734*2d9fd380Sjfb8856606  *   - (-ENODEV)  if *port_id* invalid.
3735*2d9fd380Sjfb8856606  */
3736*2d9fd380Sjfb8856606 __rte_experimental
3737*2d9fd380Sjfb8856606 int rte_eth_fec_set(uint16_t port_id, uint32_t fec_capa);
3738*2d9fd380Sjfb8856606 
3739*2d9fd380Sjfb8856606 /**
3740d30ea906Sjfb8856606  * Get current status of the Ethernet link flow control for Ethernet device
3741d30ea906Sjfb8856606  *
3742d30ea906Sjfb8856606  * @param port_id
3743d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3744d30ea906Sjfb8856606  * @param fc_conf
3745d30ea906Sjfb8856606  *   The pointer to the structure where to store the flow control parameters.
3746d30ea906Sjfb8856606  * @return
3747d30ea906Sjfb8856606  *   - (0) if successful.
3748d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support flow control.
3749d30ea906Sjfb8856606  *   - (-ENODEV)  if *port_id* invalid.
3750d30ea906Sjfb8856606  *   - (-EIO)  if device is removed.
3751d30ea906Sjfb8856606  */
3752d30ea906Sjfb8856606 int rte_eth_dev_flow_ctrl_get(uint16_t port_id,
3753d30ea906Sjfb8856606 			      struct rte_eth_fc_conf *fc_conf);
3754d30ea906Sjfb8856606 
3755d30ea906Sjfb8856606 /**
3756d30ea906Sjfb8856606  * Configure the Ethernet link flow control for Ethernet device
3757d30ea906Sjfb8856606  *
3758d30ea906Sjfb8856606  * @param port_id
3759d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3760d30ea906Sjfb8856606  * @param fc_conf
3761d30ea906Sjfb8856606  *   The pointer to the structure of the flow control parameters.
3762d30ea906Sjfb8856606  * @return
3763d30ea906Sjfb8856606  *   - (0) if successful.
3764d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support flow control mode.
3765d30ea906Sjfb8856606  *   - (-ENODEV)  if *port_id* invalid.
3766d30ea906Sjfb8856606  *   - (-EINVAL)  if bad parameter
3767d30ea906Sjfb8856606  *   - (-EIO)     if flow control setup failure or device is removed.
3768d30ea906Sjfb8856606  */
3769d30ea906Sjfb8856606 int rte_eth_dev_flow_ctrl_set(uint16_t port_id,
3770d30ea906Sjfb8856606 			      struct rte_eth_fc_conf *fc_conf);
3771d30ea906Sjfb8856606 
3772d30ea906Sjfb8856606 /**
3773d30ea906Sjfb8856606  * Configure the Ethernet priority flow control under DCB environment
3774d30ea906Sjfb8856606  * for Ethernet device.
3775d30ea906Sjfb8856606  *
3776d30ea906Sjfb8856606  * @param port_id
3777d30ea906Sjfb8856606  * The port identifier of the Ethernet device.
3778d30ea906Sjfb8856606  * @param pfc_conf
3779d30ea906Sjfb8856606  * The pointer to the structure of the priority flow control parameters.
3780d30ea906Sjfb8856606  * @return
3781d30ea906Sjfb8856606  *   - (0) if successful.
3782d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support priority flow control mode.
3783d30ea906Sjfb8856606  *   - (-ENODEV)  if *port_id* invalid.
3784d30ea906Sjfb8856606  *   - (-EINVAL)  if bad parameter
3785d30ea906Sjfb8856606  *   - (-EIO)     if flow control setup failure or device is removed.
3786d30ea906Sjfb8856606  */
3787d30ea906Sjfb8856606 int rte_eth_dev_priority_flow_ctrl_set(uint16_t port_id,
3788d30ea906Sjfb8856606 				struct rte_eth_pfc_conf *pfc_conf);
3789d30ea906Sjfb8856606 
3790d30ea906Sjfb8856606 /**
3791*2d9fd380Sjfb8856606  * Add a MAC address to the set used for filtering incoming packets.
3792d30ea906Sjfb8856606  *
3793d30ea906Sjfb8856606  * @param port_id
3794d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3795d30ea906Sjfb8856606  * @param mac_addr
3796d30ea906Sjfb8856606  *   The MAC address to add.
3797d30ea906Sjfb8856606  * @param pool
3798d30ea906Sjfb8856606  *   VMDq pool index to associate address with (if VMDq is enabled). If VMDq is
3799d30ea906Sjfb8856606  *   not enabled, this should be set to 0.
3800d30ea906Sjfb8856606  * @return
3801d30ea906Sjfb8856606  *   - (0) if successfully added or *mac_addr* was already added.
3802d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support this feature.
3803d30ea906Sjfb8856606  *   - (-ENODEV) if *port* is invalid.
3804d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
3805d30ea906Sjfb8856606  *   - (-ENOSPC) if no more MAC addresses can be added.
3806d30ea906Sjfb8856606  *   - (-EINVAL) if MAC address is invalid.
3807d30ea906Sjfb8856606  */
38084418919fSjohnjiang int rte_eth_dev_mac_addr_add(uint16_t port_id, struct rte_ether_addr *mac_addr,
3809d30ea906Sjfb8856606 				uint32_t pool);
3810d30ea906Sjfb8856606 
3811d30ea906Sjfb8856606 /**
3812d30ea906Sjfb8856606  * Remove a MAC address from the internal array of addresses.
3813d30ea906Sjfb8856606  *
3814d30ea906Sjfb8856606  * @param port_id
3815d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3816d30ea906Sjfb8856606  * @param mac_addr
3817d30ea906Sjfb8856606  *   MAC address to remove.
3818d30ea906Sjfb8856606  * @return
3819d30ea906Sjfb8856606  *   - (0) if successful, or *mac_addr* didn't exist.
3820d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support.
3821d30ea906Sjfb8856606  *   - (-ENODEV) if *port* invalid.
3822d30ea906Sjfb8856606  *   - (-EADDRINUSE) if attempting to remove the default MAC address
3823d30ea906Sjfb8856606  */
38244418919fSjohnjiang int rte_eth_dev_mac_addr_remove(uint16_t port_id,
38254418919fSjohnjiang 				struct rte_ether_addr *mac_addr);
3826d30ea906Sjfb8856606 
3827d30ea906Sjfb8856606 /**
3828d30ea906Sjfb8856606  * Set the default MAC address.
3829d30ea906Sjfb8856606  *
3830d30ea906Sjfb8856606  * @param port_id
3831d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3832d30ea906Sjfb8856606  * @param mac_addr
3833d30ea906Sjfb8856606  *   New default MAC address.
3834d30ea906Sjfb8856606  * @return
3835d30ea906Sjfb8856606  *   - (0) if successful, or *mac_addr* didn't exist.
3836d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support.
3837d30ea906Sjfb8856606  *   - (-ENODEV) if *port* invalid.
3838d30ea906Sjfb8856606  *   - (-EINVAL) if MAC address is invalid.
3839d30ea906Sjfb8856606  */
3840d30ea906Sjfb8856606 int rte_eth_dev_default_mac_addr_set(uint16_t port_id,
38414418919fSjohnjiang 		struct rte_ether_addr *mac_addr);
3842d30ea906Sjfb8856606 
3843d30ea906Sjfb8856606 /**
3844d30ea906Sjfb8856606  * Update Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
3845d30ea906Sjfb8856606  *
3846d30ea906Sjfb8856606  * @param port_id
3847d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3848d30ea906Sjfb8856606  * @param reta_conf
3849d30ea906Sjfb8856606  *   RETA to update.
3850d30ea906Sjfb8856606  * @param reta_size
3851d30ea906Sjfb8856606  *   Redirection table size. The table size can be queried by
3852d30ea906Sjfb8856606  *   rte_eth_dev_info_get().
3853d30ea906Sjfb8856606  * @return
3854d30ea906Sjfb8856606  *   - (0) if successful.
3855*2d9fd380Sjfb8856606  *   - (-ENODEV) if *port_id* is invalid.
3856d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support.
3857d30ea906Sjfb8856606  *   - (-EINVAL) if bad parameter.
3858d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
3859d30ea906Sjfb8856606  */
3860d30ea906Sjfb8856606 int rte_eth_dev_rss_reta_update(uint16_t port_id,
3861d30ea906Sjfb8856606 				struct rte_eth_rss_reta_entry64 *reta_conf,
3862d30ea906Sjfb8856606 				uint16_t reta_size);
3863d30ea906Sjfb8856606 
3864d30ea906Sjfb8856606  /**
3865d30ea906Sjfb8856606  * Query Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
3866d30ea906Sjfb8856606  *
3867d30ea906Sjfb8856606  * @param port_id
3868d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3869d30ea906Sjfb8856606  * @param reta_conf
38704418919fSjohnjiang  *   RETA to query. For each requested reta entry, corresponding bit
38714418919fSjohnjiang  *   in mask must be set.
3872d30ea906Sjfb8856606  * @param reta_size
3873d30ea906Sjfb8856606  *   Redirection table size. The table size can be queried by
3874d30ea906Sjfb8856606  *   rte_eth_dev_info_get().
3875d30ea906Sjfb8856606  * @return
3876d30ea906Sjfb8856606  *   - (0) if successful.
3877*2d9fd380Sjfb8856606  *   - (-ENODEV) if *port_id* is invalid.
3878d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support.
3879d30ea906Sjfb8856606  *   - (-EINVAL) if bad parameter.
3880d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
3881d30ea906Sjfb8856606  */
3882d30ea906Sjfb8856606 int rte_eth_dev_rss_reta_query(uint16_t port_id,
3883d30ea906Sjfb8856606 			       struct rte_eth_rss_reta_entry64 *reta_conf,
3884d30ea906Sjfb8856606 			       uint16_t reta_size);
3885d30ea906Sjfb8856606 
3886d30ea906Sjfb8856606  /**
3887d30ea906Sjfb8856606  * Updates unicast hash table for receiving packet with the given destination
3888d30ea906Sjfb8856606  * MAC address, and the packet is routed to all VFs for which the RX mode is
3889d30ea906Sjfb8856606  * accept packets that match the unicast hash table.
3890d30ea906Sjfb8856606  *
3891d30ea906Sjfb8856606  * @param port_id
3892d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3893d30ea906Sjfb8856606  * @param addr
3894d30ea906Sjfb8856606  *   Unicast MAC address.
3895d30ea906Sjfb8856606  * @param on
3896d30ea906Sjfb8856606  *    1 - Set an unicast hash bit for receiving packets with the MAC address.
3897d30ea906Sjfb8856606  *    0 - Clear an unicast hash bit.
3898d30ea906Sjfb8856606  * @return
3899d30ea906Sjfb8856606  *   - (0) if successful.
3900d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support.
3901d30ea906Sjfb8856606   *  - (-ENODEV) if *port_id* invalid.
3902d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
3903d30ea906Sjfb8856606  *   - (-EINVAL) if bad parameter.
3904d30ea906Sjfb8856606  */
39054418919fSjohnjiang int rte_eth_dev_uc_hash_table_set(uint16_t port_id, struct rte_ether_addr *addr,
3906d30ea906Sjfb8856606 				  uint8_t on);
3907d30ea906Sjfb8856606 
3908d30ea906Sjfb8856606  /**
3909d30ea906Sjfb8856606  * Updates all unicast hash bitmaps for receiving packet with any Unicast
3910d30ea906Sjfb8856606  * Ethernet MAC addresses,the packet is routed to all VFs for which the RX
3911d30ea906Sjfb8856606  * mode is accept packets that match the unicast hash table.
3912d30ea906Sjfb8856606  *
3913d30ea906Sjfb8856606  * @param port_id
3914d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3915d30ea906Sjfb8856606  * @param on
3916d30ea906Sjfb8856606  *    1 - Set all unicast hash bitmaps for receiving all the Ethernet
3917d30ea906Sjfb8856606  *         MAC addresses
3918d30ea906Sjfb8856606  *    0 - Clear all unicast hash bitmaps
3919d30ea906Sjfb8856606  * @return
3920d30ea906Sjfb8856606  *   - (0) if successful.
3921d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support.
3922d30ea906Sjfb8856606   *  - (-ENODEV) if *port_id* invalid.
3923d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
3924d30ea906Sjfb8856606  *   - (-EINVAL) if bad parameter.
3925d30ea906Sjfb8856606  */
3926d30ea906Sjfb8856606 int rte_eth_dev_uc_all_hash_table_set(uint16_t port_id, uint8_t on);
3927d30ea906Sjfb8856606 
3928d30ea906Sjfb8856606 /**
3929d30ea906Sjfb8856606  * Set a traffic mirroring rule on an Ethernet device
3930d30ea906Sjfb8856606  *
3931d30ea906Sjfb8856606  * @param port_id
3932d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3933d30ea906Sjfb8856606  * @param mirror_conf
3934d30ea906Sjfb8856606  *   The pointer to the traffic mirroring structure describing the mirroring rule.
3935d30ea906Sjfb8856606  *   The *rte_eth_vm_mirror_conf* structure includes the type of mirroring rule,
3936d30ea906Sjfb8856606  *   destination pool and the value of rule if enable vlan or pool mirroring.
3937d30ea906Sjfb8856606  *
3938d30ea906Sjfb8856606  * @param rule_id
3939d30ea906Sjfb8856606  *   The index of traffic mirroring rule, we support four separated rules.
3940d30ea906Sjfb8856606  * @param on
3941d30ea906Sjfb8856606  *   1 - Enable a mirroring rule.
3942d30ea906Sjfb8856606  *   0 - Disable a mirroring rule.
3943d30ea906Sjfb8856606  * @return
3944d30ea906Sjfb8856606  *   - (0) if successful.
3945d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support this feature.
3946d30ea906Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
3947d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
3948d30ea906Sjfb8856606  *   - (-EINVAL) if the mr_conf information is not correct.
3949d30ea906Sjfb8856606  */
3950d30ea906Sjfb8856606 int rte_eth_mirror_rule_set(uint16_t port_id,
3951d30ea906Sjfb8856606 			struct rte_eth_mirror_conf *mirror_conf,
3952d30ea906Sjfb8856606 			uint8_t rule_id,
3953d30ea906Sjfb8856606 			uint8_t on);
3954d30ea906Sjfb8856606 
3955d30ea906Sjfb8856606 /**
3956d30ea906Sjfb8856606  * Reset a traffic mirroring rule on an Ethernet device.
3957d30ea906Sjfb8856606  *
3958d30ea906Sjfb8856606  * @param port_id
3959d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3960d30ea906Sjfb8856606  * @param rule_id
3961d30ea906Sjfb8856606  *   The index of traffic mirroring rule, we support four separated rules.
3962d30ea906Sjfb8856606  * @return
3963d30ea906Sjfb8856606  *   - (0) if successful.
3964d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support this feature.
3965d30ea906Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
3966d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
3967d30ea906Sjfb8856606  *   - (-EINVAL) if bad parameter.
3968d30ea906Sjfb8856606  */
3969d30ea906Sjfb8856606 int rte_eth_mirror_rule_reset(uint16_t port_id,
3970d30ea906Sjfb8856606 					 uint8_t rule_id);
3971d30ea906Sjfb8856606 
3972d30ea906Sjfb8856606 /**
3973d30ea906Sjfb8856606  * Set the rate limitation for a queue on an Ethernet device.
3974d30ea906Sjfb8856606  *
3975d30ea906Sjfb8856606  * @param port_id
3976d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3977d30ea906Sjfb8856606  * @param queue_idx
3978d30ea906Sjfb8856606  *   The queue id.
3979d30ea906Sjfb8856606  * @param tx_rate
3980d30ea906Sjfb8856606  *   The tx rate in Mbps. Allocated from the total port link speed.
3981d30ea906Sjfb8856606  * @return
3982d30ea906Sjfb8856606  *   - (0) if successful.
3983d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support this feature.
3984d30ea906Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
3985d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
3986d30ea906Sjfb8856606  *   - (-EINVAL) if bad parameter.
3987d30ea906Sjfb8856606  */
3988d30ea906Sjfb8856606 int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx,
3989d30ea906Sjfb8856606 			uint16_t tx_rate);
3990d30ea906Sjfb8856606 
3991d30ea906Sjfb8856606  /**
3992d30ea906Sjfb8856606  * Configuration of Receive Side Scaling hash computation of Ethernet device.
3993d30ea906Sjfb8856606  *
3994d30ea906Sjfb8856606  * @param port_id
3995d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
3996d30ea906Sjfb8856606  * @param rss_conf
3997d30ea906Sjfb8856606  *   The new configuration to use for RSS hash computation on the port.
3998d30ea906Sjfb8856606  * @return
3999d30ea906Sjfb8856606  *   - (0) if successful.
4000d30ea906Sjfb8856606  *   - (-ENODEV) if port identifier is invalid.
4001d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
4002d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support.
4003d30ea906Sjfb8856606  *   - (-EINVAL) if bad parameter.
4004d30ea906Sjfb8856606  */
4005d30ea906Sjfb8856606 int rte_eth_dev_rss_hash_update(uint16_t port_id,
4006d30ea906Sjfb8856606 				struct rte_eth_rss_conf *rss_conf);
4007d30ea906Sjfb8856606 
4008d30ea906Sjfb8856606  /**
4009d30ea906Sjfb8856606  * Retrieve current configuration of Receive Side Scaling hash computation
4010d30ea906Sjfb8856606  * of Ethernet device.
4011d30ea906Sjfb8856606  *
4012d30ea906Sjfb8856606  * @param port_id
4013d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4014d30ea906Sjfb8856606  * @param rss_conf
4015d30ea906Sjfb8856606  *   Where to store the current RSS hash configuration of the Ethernet device.
4016d30ea906Sjfb8856606  * @return
4017d30ea906Sjfb8856606  *   - (0) if successful.
4018d30ea906Sjfb8856606  *   - (-ENODEV) if port identifier is invalid.
4019d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
4020d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support RSS.
4021d30ea906Sjfb8856606  */
4022d30ea906Sjfb8856606 int
4023d30ea906Sjfb8856606 rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
4024d30ea906Sjfb8856606 			      struct rte_eth_rss_conf *rss_conf);
4025d30ea906Sjfb8856606 
4026d30ea906Sjfb8856606  /**
4027d30ea906Sjfb8856606  * Add UDP tunneling port for a specific type of tunnel.
4028d30ea906Sjfb8856606  * The packets with this UDP port will be identified as this type of tunnel.
4029d30ea906Sjfb8856606  * Before enabling any offloading function for a tunnel, users can call this API
4030d30ea906Sjfb8856606  * to change or add more UDP port for the tunnel. So the offloading function
4031d30ea906Sjfb8856606  * can take effect on the packets with the specific UDP port.
4032d30ea906Sjfb8856606  *
4033d30ea906Sjfb8856606  * @param port_id
4034d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4035d30ea906Sjfb8856606  * @param tunnel_udp
4036d30ea906Sjfb8856606  *   UDP tunneling configuration.
4037d30ea906Sjfb8856606  *
4038d30ea906Sjfb8856606  * @return
4039d30ea906Sjfb8856606  *   - (0) if successful.
4040d30ea906Sjfb8856606  *   - (-ENODEV) if port identifier is invalid.
4041d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
4042d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support tunnel type.
4043d30ea906Sjfb8856606  */
4044d30ea906Sjfb8856606 int
4045d30ea906Sjfb8856606 rte_eth_dev_udp_tunnel_port_add(uint16_t port_id,
4046d30ea906Sjfb8856606 				struct rte_eth_udp_tunnel *tunnel_udp);
4047d30ea906Sjfb8856606 
4048d30ea906Sjfb8856606  /**
4049d30ea906Sjfb8856606  * Delete UDP tunneling port a specific type of tunnel.
4050d30ea906Sjfb8856606  * The packets with this UDP port will not be identified as this type of tunnel
4051d30ea906Sjfb8856606  * any more.
4052d30ea906Sjfb8856606  * Before enabling any offloading function for a tunnel, users can call this API
4053d30ea906Sjfb8856606  * to delete a UDP port for the tunnel. So the offloading function will not take
4054d30ea906Sjfb8856606  * effect on the packets with the specific UDP port.
4055d30ea906Sjfb8856606  *
4056d30ea906Sjfb8856606  * @param port_id
4057d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4058d30ea906Sjfb8856606  * @param tunnel_udp
4059d30ea906Sjfb8856606  *   UDP tunneling configuration.
4060d30ea906Sjfb8856606  *
4061d30ea906Sjfb8856606  * @return
4062d30ea906Sjfb8856606  *   - (0) if successful.
4063d30ea906Sjfb8856606  *   - (-ENODEV) if port identifier is invalid.
4064d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
4065d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support tunnel type.
4066d30ea906Sjfb8856606  */
4067d30ea906Sjfb8856606 int
4068d30ea906Sjfb8856606 rte_eth_dev_udp_tunnel_port_delete(uint16_t port_id,
4069d30ea906Sjfb8856606 				   struct rte_eth_udp_tunnel *tunnel_udp);
4070d30ea906Sjfb8856606 
4071d30ea906Sjfb8856606 /**
4072d30ea906Sjfb8856606  * Get DCB information on an Ethernet device.
4073d30ea906Sjfb8856606  *
4074d30ea906Sjfb8856606  * @param port_id
4075d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4076d30ea906Sjfb8856606  * @param dcb_info
4077d30ea906Sjfb8856606  *   dcb information.
4078d30ea906Sjfb8856606  * @return
4079d30ea906Sjfb8856606  *   - (0) if successful.
4080d30ea906Sjfb8856606  *   - (-ENODEV) if port identifier is invalid.
4081d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
4082d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support.
4083d30ea906Sjfb8856606  */
4084d30ea906Sjfb8856606 int rte_eth_dev_get_dcb_info(uint16_t port_id,
4085d30ea906Sjfb8856606 			     struct rte_eth_dcb_info *dcb_info);
4086d30ea906Sjfb8856606 
4087d30ea906Sjfb8856606 struct rte_eth_rxtx_callback;
4088d30ea906Sjfb8856606 
4089d30ea906Sjfb8856606 /**
4090d30ea906Sjfb8856606  * Add a callback to be called on packet RX on a given port and queue.
4091d30ea906Sjfb8856606  *
4092d30ea906Sjfb8856606  * This API configures a function to be called for each burst of
4093d30ea906Sjfb8856606  * packets received on a given NIC port queue. The return value is a pointer
4094d30ea906Sjfb8856606  * that can be used to later remove the callback using
4095d30ea906Sjfb8856606  * rte_eth_remove_rx_callback().
4096d30ea906Sjfb8856606  *
4097d30ea906Sjfb8856606  * Multiple functions are called in the order that they are added.
4098d30ea906Sjfb8856606  *
4099d30ea906Sjfb8856606  * @param port_id
4100d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4101d30ea906Sjfb8856606  * @param queue_id
4102d30ea906Sjfb8856606  *   The queue on the Ethernet device on which the callback is to be added.
4103d30ea906Sjfb8856606  * @param fn
4104d30ea906Sjfb8856606  *   The callback function
4105d30ea906Sjfb8856606  * @param user_param
4106d30ea906Sjfb8856606  *   A generic pointer parameter which will be passed to each invocation of the
41070c6bd470Sfengbojiang  *   callback function on this port and queue. Inter-thread synchronization
41080c6bd470Sfengbojiang  *   of any user data changes is the responsibility of the user.
4109d30ea906Sjfb8856606  *
4110d30ea906Sjfb8856606  * @return
4111d30ea906Sjfb8856606  *   NULL on error.
4112d30ea906Sjfb8856606  *   On success, a pointer value which can later be used to remove the callback.
4113d30ea906Sjfb8856606  */
4114d30ea906Sjfb8856606 const struct rte_eth_rxtx_callback *
4115d30ea906Sjfb8856606 rte_eth_add_rx_callback(uint16_t port_id, uint16_t queue_id,
4116d30ea906Sjfb8856606 		rte_rx_callback_fn fn, void *user_param);
4117d30ea906Sjfb8856606 
4118d30ea906Sjfb8856606 /**
4119d30ea906Sjfb8856606  * Add a callback that must be called first on packet RX on a given port
4120d30ea906Sjfb8856606  * and queue.
4121d30ea906Sjfb8856606  *
4122d30ea906Sjfb8856606  * This API configures a first function to be called for each burst of
4123d30ea906Sjfb8856606  * packets received on a given NIC port queue. The return value is a pointer
4124d30ea906Sjfb8856606  * that can be used to later remove the callback using
4125d30ea906Sjfb8856606  * rte_eth_remove_rx_callback().
4126d30ea906Sjfb8856606  *
4127d30ea906Sjfb8856606  * Multiple functions are called in the order that they are added.
4128d30ea906Sjfb8856606  *
4129d30ea906Sjfb8856606  * @param port_id
4130d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4131d30ea906Sjfb8856606  * @param queue_id
4132d30ea906Sjfb8856606  *   The queue on the Ethernet device on which the callback is to be added.
4133d30ea906Sjfb8856606  * @param fn
4134d30ea906Sjfb8856606  *   The callback function
4135d30ea906Sjfb8856606  * @param user_param
4136d30ea906Sjfb8856606  *   A generic pointer parameter which will be passed to each invocation of the
41370c6bd470Sfengbojiang  *   callback function on this port and queue. Inter-thread synchronization
41380c6bd470Sfengbojiang  *   of any user data changes is the responsibility of the user.
4139d30ea906Sjfb8856606  *
4140d30ea906Sjfb8856606  * @return
4141d30ea906Sjfb8856606  *   NULL on error.
4142d30ea906Sjfb8856606  *   On success, a pointer value which can later be used to remove the callback.
4143d30ea906Sjfb8856606  */
4144d30ea906Sjfb8856606 const struct rte_eth_rxtx_callback *
4145d30ea906Sjfb8856606 rte_eth_add_first_rx_callback(uint16_t port_id, uint16_t queue_id,
4146d30ea906Sjfb8856606 		rte_rx_callback_fn fn, void *user_param);
4147d30ea906Sjfb8856606 
4148d30ea906Sjfb8856606 /**
4149d30ea906Sjfb8856606  * Add a callback to be called on packet TX on a given port and queue.
4150d30ea906Sjfb8856606  *
4151d30ea906Sjfb8856606  * This API configures a function to be called for each burst of
4152d30ea906Sjfb8856606  * packets sent on a given NIC port queue. The return value is a pointer
4153d30ea906Sjfb8856606  * that can be used to later remove the callback using
4154d30ea906Sjfb8856606  * rte_eth_remove_tx_callback().
4155d30ea906Sjfb8856606  *
4156d30ea906Sjfb8856606  * Multiple functions are called in the order that they are added.
4157d30ea906Sjfb8856606  *
4158d30ea906Sjfb8856606  * @param port_id
4159d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4160d30ea906Sjfb8856606  * @param queue_id
4161d30ea906Sjfb8856606  *   The queue on the Ethernet device on which the callback is to be added.
4162d30ea906Sjfb8856606  * @param fn
4163d30ea906Sjfb8856606  *   The callback function
4164d30ea906Sjfb8856606  * @param user_param
4165d30ea906Sjfb8856606  *   A generic pointer parameter which will be passed to each invocation of the
41660c6bd470Sfengbojiang  *   callback function on this port and queue. Inter-thread synchronization
41670c6bd470Sfengbojiang  *   of any user data changes is the responsibility of the user.
4168d30ea906Sjfb8856606  *
4169d30ea906Sjfb8856606  * @return
4170d30ea906Sjfb8856606  *   NULL on error.
4171d30ea906Sjfb8856606  *   On success, a pointer value which can later be used to remove the callback.
4172d30ea906Sjfb8856606  */
4173d30ea906Sjfb8856606 const struct rte_eth_rxtx_callback *
4174d30ea906Sjfb8856606 rte_eth_add_tx_callback(uint16_t port_id, uint16_t queue_id,
4175d30ea906Sjfb8856606 		rte_tx_callback_fn fn, void *user_param);
4176d30ea906Sjfb8856606 
4177d30ea906Sjfb8856606 /**
4178d30ea906Sjfb8856606  * Remove an RX packet callback from a given port and queue.
4179d30ea906Sjfb8856606  *
4180d30ea906Sjfb8856606  * This function is used to removed callbacks that were added to a NIC port
4181d30ea906Sjfb8856606  * queue using rte_eth_add_rx_callback().
4182d30ea906Sjfb8856606  *
4183d30ea906Sjfb8856606  * Note: the callback is removed from the callback list but it isn't freed
4184d30ea906Sjfb8856606  * since the it may still be in use. The memory for the callback can be
4185d30ea906Sjfb8856606  * subsequently freed back by the application by calling rte_free():
4186d30ea906Sjfb8856606  *
4187d30ea906Sjfb8856606  * - Immediately - if the port is stopped, or the user knows that no
4188d30ea906Sjfb8856606  *   callbacks are in flight e.g. if called from the thread doing RX/TX
4189d30ea906Sjfb8856606  *   on that queue.
4190d30ea906Sjfb8856606  *
4191d30ea906Sjfb8856606  * - After a short delay - where the delay is sufficient to allow any
41920c6bd470Sfengbojiang  *   in-flight callbacks to complete. Alternately, the RCU mechanism can be
41930c6bd470Sfengbojiang  *   used to detect when data plane threads have ceased referencing the
41940c6bd470Sfengbojiang  *   callback memory.
4195d30ea906Sjfb8856606  *
4196d30ea906Sjfb8856606  * @param port_id
4197d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4198d30ea906Sjfb8856606  * @param queue_id
4199d30ea906Sjfb8856606  *   The queue on the Ethernet device from which the callback is to be removed.
4200d30ea906Sjfb8856606  * @param user_cb
4201d30ea906Sjfb8856606  *   User supplied callback created via rte_eth_add_rx_callback().
4202d30ea906Sjfb8856606  *
4203d30ea906Sjfb8856606  * @return
4204d30ea906Sjfb8856606  *   - 0: Success. Callback was removed.
4205*2d9fd380Sjfb8856606  *   - -ENODEV:  If *port_id* is invalid.
4206d30ea906Sjfb8856606  *   - -ENOTSUP: Callback support is not available.
4207*2d9fd380Sjfb8856606  *   - -EINVAL:  The queue_id is out of range, or the callback
4208d30ea906Sjfb8856606  *               is NULL or not found for the port/queue.
4209d30ea906Sjfb8856606  */
4210d30ea906Sjfb8856606 int rte_eth_remove_rx_callback(uint16_t port_id, uint16_t queue_id,
4211d30ea906Sjfb8856606 		const struct rte_eth_rxtx_callback *user_cb);
4212d30ea906Sjfb8856606 
4213d30ea906Sjfb8856606 /**
4214d30ea906Sjfb8856606  * Remove a TX packet callback from a given port and queue.
4215d30ea906Sjfb8856606  *
4216d30ea906Sjfb8856606  * This function is used to removed callbacks that were added to a NIC port
4217d30ea906Sjfb8856606  * queue using rte_eth_add_tx_callback().
4218d30ea906Sjfb8856606  *
4219d30ea906Sjfb8856606  * Note: the callback is removed from the callback list but it isn't freed
4220d30ea906Sjfb8856606  * since the it may still be in use. The memory for the callback can be
4221d30ea906Sjfb8856606  * subsequently freed back by the application by calling rte_free():
4222d30ea906Sjfb8856606  *
4223d30ea906Sjfb8856606  * - Immediately - if the port is stopped, or the user knows that no
4224d30ea906Sjfb8856606  *   callbacks are in flight e.g. if called from the thread doing RX/TX
4225d30ea906Sjfb8856606  *   on that queue.
4226d30ea906Sjfb8856606  *
4227d30ea906Sjfb8856606  * - After a short delay - where the delay is sufficient to allow any
42280c6bd470Sfengbojiang  *   in-flight callbacks to complete. Alternately, the RCU mechanism can be
42290c6bd470Sfengbojiang  *   used to detect when data plane threads have ceased referencing the
42300c6bd470Sfengbojiang  *   callback memory.
4231d30ea906Sjfb8856606  *
4232d30ea906Sjfb8856606  * @param port_id
4233d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4234d30ea906Sjfb8856606  * @param queue_id
4235d30ea906Sjfb8856606  *   The queue on the Ethernet device from which the callback is to be removed.
4236d30ea906Sjfb8856606  * @param user_cb
4237d30ea906Sjfb8856606  *   User supplied callback created via rte_eth_add_tx_callback().
4238d30ea906Sjfb8856606  *
4239d30ea906Sjfb8856606  * @return
4240d30ea906Sjfb8856606  *   - 0: Success. Callback was removed.
4241*2d9fd380Sjfb8856606  *   - -ENODEV:  If *port_id* is invalid.
4242d30ea906Sjfb8856606  *   - -ENOTSUP: Callback support is not available.
4243*2d9fd380Sjfb8856606  *   - -EINVAL:  The queue_id is out of range, or the callback
4244d30ea906Sjfb8856606  *               is NULL or not found for the port/queue.
4245d30ea906Sjfb8856606  */
4246d30ea906Sjfb8856606 int rte_eth_remove_tx_callback(uint16_t port_id, uint16_t queue_id,
4247d30ea906Sjfb8856606 		const struct rte_eth_rxtx_callback *user_cb);
4248d30ea906Sjfb8856606 
4249d30ea906Sjfb8856606 /**
4250d30ea906Sjfb8856606  * Retrieve information about given port's RX queue.
4251d30ea906Sjfb8856606  *
4252d30ea906Sjfb8856606  * @param port_id
4253d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4254d30ea906Sjfb8856606  * @param queue_id
4255d30ea906Sjfb8856606  *   The RX queue on the Ethernet device for which information
4256d30ea906Sjfb8856606  *   will be retrieved.
4257d30ea906Sjfb8856606  * @param qinfo
4258d30ea906Sjfb8856606  *   A pointer to a structure of type *rte_eth_rxq_info_info* to be filled with
4259d30ea906Sjfb8856606  *   the information of the Ethernet device.
4260d30ea906Sjfb8856606  *
4261d30ea906Sjfb8856606  * @return
4262d30ea906Sjfb8856606  *   - 0: Success
4263*2d9fd380Sjfb8856606  *   - -ENODEV:  If *port_id* is invalid.
4264d30ea906Sjfb8856606  *   - -ENOTSUP: routine is not supported by the device PMD.
4265*2d9fd380Sjfb8856606  *   - -EINVAL:  The queue_id is out of range, or the queue
42664418919fSjohnjiang  *               is hairpin queue.
4267d30ea906Sjfb8856606  */
4268d30ea906Sjfb8856606 int rte_eth_rx_queue_info_get(uint16_t port_id, uint16_t queue_id,
4269d30ea906Sjfb8856606 	struct rte_eth_rxq_info *qinfo);
4270d30ea906Sjfb8856606 
4271d30ea906Sjfb8856606 /**
4272d30ea906Sjfb8856606  * Retrieve information about given port's TX queue.
4273d30ea906Sjfb8856606  *
4274d30ea906Sjfb8856606  * @param port_id
4275d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4276d30ea906Sjfb8856606  * @param queue_id
4277d30ea906Sjfb8856606  *   The TX queue on the Ethernet device for which information
4278d30ea906Sjfb8856606  *   will be retrieved.
4279d30ea906Sjfb8856606  * @param qinfo
4280d30ea906Sjfb8856606  *   A pointer to a structure of type *rte_eth_txq_info_info* to be filled with
4281d30ea906Sjfb8856606  *   the information of the Ethernet device.
4282d30ea906Sjfb8856606  *
4283d30ea906Sjfb8856606  * @return
4284d30ea906Sjfb8856606  *   - 0: Success
4285*2d9fd380Sjfb8856606  *   - -ENODEV:  If *port_id* is invalid.
4286d30ea906Sjfb8856606  *   - -ENOTSUP: routine is not supported by the device PMD.
4287*2d9fd380Sjfb8856606  *   - -EINVAL:  The queue_id is out of range, or the queue
42884418919fSjohnjiang  *               is hairpin queue.
4289d30ea906Sjfb8856606  */
4290d30ea906Sjfb8856606 int rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id,
4291d30ea906Sjfb8856606 	struct rte_eth_txq_info *qinfo);
4292d30ea906Sjfb8856606 
4293d30ea906Sjfb8856606 /**
42944418919fSjohnjiang  * Retrieve information about the Rx packet burst mode.
42954418919fSjohnjiang  *
42964418919fSjohnjiang  * @param port_id
42974418919fSjohnjiang  *   The port identifier of the Ethernet device.
42984418919fSjohnjiang  * @param queue_id
42994418919fSjohnjiang  *   The Rx queue on the Ethernet device for which information
43004418919fSjohnjiang  *   will be retrieved.
43014418919fSjohnjiang  * @param mode
43024418919fSjohnjiang  *   A pointer to a structure of type *rte_eth_burst_mode* to be filled
43034418919fSjohnjiang  *   with the information of the packet burst mode.
43044418919fSjohnjiang  *
43054418919fSjohnjiang  * @return
43064418919fSjohnjiang  *   - 0: Success
4307*2d9fd380Sjfb8856606  *   - -ENODEV:  If *port_id* is invalid.
43084418919fSjohnjiang  *   - -ENOTSUP: routine is not supported by the device PMD.
4309*2d9fd380Sjfb8856606  *   - -EINVAL:  The queue_id is out of range.
43104418919fSjohnjiang  */
43114418919fSjohnjiang __rte_experimental
43124418919fSjohnjiang int rte_eth_rx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
43134418919fSjohnjiang 	struct rte_eth_burst_mode *mode);
43144418919fSjohnjiang 
43154418919fSjohnjiang /**
43164418919fSjohnjiang  * Retrieve information about the Tx packet burst mode.
43174418919fSjohnjiang  *
43184418919fSjohnjiang  * @param port_id
43194418919fSjohnjiang  *   The port identifier of the Ethernet device.
43204418919fSjohnjiang  * @param queue_id
43214418919fSjohnjiang  *   The Tx queue on the Ethernet device for which information
43224418919fSjohnjiang  *   will be retrieved.
43234418919fSjohnjiang  * @param mode
43244418919fSjohnjiang  *   A pointer to a structure of type *rte_eth_burst_mode* to be filled
43254418919fSjohnjiang  *   with the information of the packet burst mode.
43264418919fSjohnjiang  *
43274418919fSjohnjiang  * @return
43284418919fSjohnjiang  *   - 0: Success
4329*2d9fd380Sjfb8856606  *   - -ENODEV:  If *port_id* is invalid.
43304418919fSjohnjiang  *   - -ENOTSUP: routine is not supported by the device PMD.
4331*2d9fd380Sjfb8856606  *   - -EINVAL:  The queue_id is out of range.
43324418919fSjohnjiang  */
43334418919fSjohnjiang __rte_experimental
43344418919fSjohnjiang int rte_eth_tx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
43354418919fSjohnjiang 	struct rte_eth_burst_mode *mode);
43364418919fSjohnjiang 
43374418919fSjohnjiang /**
4338d30ea906Sjfb8856606  * Retrieve device registers and register attributes (number of registers and
4339d30ea906Sjfb8856606  * register size)
4340d30ea906Sjfb8856606  *
4341d30ea906Sjfb8856606  * @param port_id
4342d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4343d30ea906Sjfb8856606  * @param info
4344d30ea906Sjfb8856606  *   Pointer to rte_dev_reg_info structure to fill in. If info->data is
4345d30ea906Sjfb8856606  *   NULL the function fills in the width and length fields. If non-NULL
4346d30ea906Sjfb8856606  *   the registers are put into the buffer pointed at by the data field.
4347d30ea906Sjfb8856606  * @return
4348d30ea906Sjfb8856606  *   - (0) if successful.
4349d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support.
4350d30ea906Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
4351d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
4352d30ea906Sjfb8856606  *   - others depends on the specific operations implementation.
4353d30ea906Sjfb8856606  */
4354d30ea906Sjfb8856606 int rte_eth_dev_get_reg_info(uint16_t port_id, struct rte_dev_reg_info *info);
4355d30ea906Sjfb8856606 
4356d30ea906Sjfb8856606 /**
4357d30ea906Sjfb8856606  * Retrieve size of device EEPROM
4358d30ea906Sjfb8856606  *
4359d30ea906Sjfb8856606  * @param port_id
4360d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4361d30ea906Sjfb8856606  * @return
4362d30ea906Sjfb8856606  *   - (>=0) EEPROM size if successful.
4363d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support.
4364d30ea906Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
4365d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
4366d30ea906Sjfb8856606  *   - others depends on the specific operations implementation.
4367d30ea906Sjfb8856606  */
4368d30ea906Sjfb8856606 int rte_eth_dev_get_eeprom_length(uint16_t port_id);
4369d30ea906Sjfb8856606 
4370d30ea906Sjfb8856606 /**
4371d30ea906Sjfb8856606  * Retrieve EEPROM and EEPROM attribute
4372d30ea906Sjfb8856606  *
4373d30ea906Sjfb8856606  * @param port_id
4374d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4375d30ea906Sjfb8856606  * @param info
4376d30ea906Sjfb8856606  *   The template includes buffer for return EEPROM data and
4377d30ea906Sjfb8856606  *   EEPROM attributes to be filled.
4378d30ea906Sjfb8856606  * @return
4379d30ea906Sjfb8856606  *   - (0) if successful.
4380d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support.
4381d30ea906Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
4382d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
4383d30ea906Sjfb8856606  *   - others depends on the specific operations implementation.
4384d30ea906Sjfb8856606  */
4385d30ea906Sjfb8856606 int rte_eth_dev_get_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
4386d30ea906Sjfb8856606 
4387d30ea906Sjfb8856606 /**
4388d30ea906Sjfb8856606  * Program EEPROM with provided data
4389d30ea906Sjfb8856606  *
4390d30ea906Sjfb8856606  * @param port_id
4391d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4392d30ea906Sjfb8856606  * @param info
4393d30ea906Sjfb8856606  *   The template includes EEPROM data for programming and
4394d30ea906Sjfb8856606  *   EEPROM attributes to be filled
4395d30ea906Sjfb8856606  * @return
4396d30ea906Sjfb8856606  *   - (0) if successful.
4397d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support.
4398d30ea906Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
4399d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
4400d30ea906Sjfb8856606  *   - others depends on the specific operations implementation.
4401d30ea906Sjfb8856606  */
4402d30ea906Sjfb8856606 int rte_eth_dev_set_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
4403d30ea906Sjfb8856606 
4404d30ea906Sjfb8856606 /**
4405d30ea906Sjfb8856606  * @warning
4406d30ea906Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
4407d30ea906Sjfb8856606  *
4408d30ea906Sjfb8856606  * Retrieve the type and size of plugin module EEPROM
4409d30ea906Sjfb8856606  *
4410d30ea906Sjfb8856606  * @param port_id
4411d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4412d30ea906Sjfb8856606  * @param modinfo
4413d30ea906Sjfb8856606  *   The type and size of plugin module EEPROM.
4414d30ea906Sjfb8856606  * @return
4415d30ea906Sjfb8856606  *   - (0) if successful.
4416d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support.
4417d30ea906Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
4418d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
4419d30ea906Sjfb8856606  *   - others depends on the specific operations implementation.
4420d30ea906Sjfb8856606  */
44214418919fSjohnjiang __rte_experimental
44224418919fSjohnjiang int
4423d30ea906Sjfb8856606 rte_eth_dev_get_module_info(uint16_t port_id,
4424d30ea906Sjfb8856606 			    struct rte_eth_dev_module_info *modinfo);
4425d30ea906Sjfb8856606 
4426d30ea906Sjfb8856606 /**
4427d30ea906Sjfb8856606  * @warning
4428d30ea906Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
4429d30ea906Sjfb8856606  *
4430d30ea906Sjfb8856606  * Retrieve the data of plugin module EEPROM
4431d30ea906Sjfb8856606  *
4432d30ea906Sjfb8856606  * @param port_id
4433d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4434d30ea906Sjfb8856606  * @param info
4435d30ea906Sjfb8856606  *   The template includes the plugin module EEPROM attributes, and the
4436d30ea906Sjfb8856606  *   buffer for return plugin module EEPROM data.
4437d30ea906Sjfb8856606  * @return
4438d30ea906Sjfb8856606  *   - (0) if successful.
4439d30ea906Sjfb8856606  *   - (-ENOTSUP) if hardware doesn't support.
4440d30ea906Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
4441d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
4442d30ea906Sjfb8856606  *   - others depends on the specific operations implementation.
4443d30ea906Sjfb8856606  */
44444418919fSjohnjiang __rte_experimental
44454418919fSjohnjiang int
4446d30ea906Sjfb8856606 rte_eth_dev_get_module_eeprom(uint16_t port_id,
4447d30ea906Sjfb8856606 			      struct rte_dev_eeprom_info *info);
4448d30ea906Sjfb8856606 
4449d30ea906Sjfb8856606 /**
4450d30ea906Sjfb8856606  * Set the list of multicast addresses to filter on an Ethernet device.
4451d30ea906Sjfb8856606  *
4452d30ea906Sjfb8856606  * @param port_id
4453d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4454d30ea906Sjfb8856606  * @param mc_addr_set
4455d30ea906Sjfb8856606  *   The array of multicast addresses to set. Equal to NULL when the function
4456d30ea906Sjfb8856606  *   is invoked to flush the set of filtered addresses.
4457d30ea906Sjfb8856606  * @param nb_mc_addr
4458d30ea906Sjfb8856606  *   The number of multicast addresses in the *mc_addr_set* array. Equal to 0
4459d30ea906Sjfb8856606  *   when the function is invoked to flush the set of filtered addresses.
4460d30ea906Sjfb8856606  * @return
4461d30ea906Sjfb8856606  *   - (0) if successful.
4462d30ea906Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
4463d30ea906Sjfb8856606  *   - (-EIO) if device is removed.
4464d30ea906Sjfb8856606  *   - (-ENOTSUP) if PMD of *port_id* doesn't support multicast filtering.
4465d30ea906Sjfb8856606  *   - (-ENOSPC) if *port_id* has not enough multicast filtering resources.
4466d30ea906Sjfb8856606  */
4467d30ea906Sjfb8856606 int rte_eth_dev_set_mc_addr_list(uint16_t port_id,
44684418919fSjohnjiang 				 struct rte_ether_addr *mc_addr_set,
4469d30ea906Sjfb8856606 				 uint32_t nb_mc_addr);
4470d30ea906Sjfb8856606 
4471d30ea906Sjfb8856606 /**
4472d30ea906Sjfb8856606  * Enable IEEE1588/802.1AS timestamping for an Ethernet device.
4473d30ea906Sjfb8856606  *
4474d30ea906Sjfb8856606  * @param port_id
4475d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4476d30ea906Sjfb8856606  *
4477d30ea906Sjfb8856606  * @return
4478d30ea906Sjfb8856606  *   - 0: Success.
4479d30ea906Sjfb8856606  *   - -ENODEV: The port ID is invalid.
4480d30ea906Sjfb8856606  *   - -EIO: if device is removed.
4481d30ea906Sjfb8856606  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
4482d30ea906Sjfb8856606  */
4483d30ea906Sjfb8856606 int rte_eth_timesync_enable(uint16_t port_id);
4484d30ea906Sjfb8856606 
4485d30ea906Sjfb8856606 /**
4486d30ea906Sjfb8856606  * Disable IEEE1588/802.1AS timestamping for an Ethernet device.
4487d30ea906Sjfb8856606  *
4488d30ea906Sjfb8856606  * @param port_id
4489d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4490d30ea906Sjfb8856606  *
4491d30ea906Sjfb8856606  * @return
4492d30ea906Sjfb8856606  *   - 0: Success.
4493d30ea906Sjfb8856606  *   - -ENODEV: The port ID is invalid.
4494d30ea906Sjfb8856606  *   - -EIO: if device is removed.
4495d30ea906Sjfb8856606  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
4496d30ea906Sjfb8856606  */
4497d30ea906Sjfb8856606 int rte_eth_timesync_disable(uint16_t port_id);
4498d30ea906Sjfb8856606 
4499d30ea906Sjfb8856606 /**
4500d30ea906Sjfb8856606  * Read an IEEE1588/802.1AS RX timestamp from an Ethernet device.
4501d30ea906Sjfb8856606  *
4502d30ea906Sjfb8856606  * @param port_id
4503d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4504d30ea906Sjfb8856606  * @param timestamp
4505d30ea906Sjfb8856606  *   Pointer to the timestamp struct.
4506d30ea906Sjfb8856606  * @param flags
4507d30ea906Sjfb8856606  *   Device specific flags. Used to pass the RX timesync register index to
4508d30ea906Sjfb8856606  *   i40e. Unused in igb/ixgbe, pass 0 instead.
4509d30ea906Sjfb8856606  *
4510d30ea906Sjfb8856606  * @return
4511d30ea906Sjfb8856606  *   - 0: Success.
4512d30ea906Sjfb8856606  *   - -EINVAL: No timestamp is available.
4513d30ea906Sjfb8856606  *   - -ENODEV: The port ID is invalid.
4514d30ea906Sjfb8856606  *   - -EIO: if device is removed.
4515d30ea906Sjfb8856606  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
4516d30ea906Sjfb8856606  */
4517d30ea906Sjfb8856606 int rte_eth_timesync_read_rx_timestamp(uint16_t port_id,
4518d30ea906Sjfb8856606 		struct timespec *timestamp, uint32_t flags);
4519d30ea906Sjfb8856606 
4520d30ea906Sjfb8856606 /**
4521d30ea906Sjfb8856606  * Read an IEEE1588/802.1AS TX timestamp from an Ethernet device.
4522d30ea906Sjfb8856606  *
4523d30ea906Sjfb8856606  * @param port_id
4524d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4525d30ea906Sjfb8856606  * @param timestamp
4526d30ea906Sjfb8856606  *   Pointer to the timestamp struct.
4527d30ea906Sjfb8856606  *
4528d30ea906Sjfb8856606  * @return
4529d30ea906Sjfb8856606  *   - 0: Success.
4530d30ea906Sjfb8856606  *   - -EINVAL: No timestamp is available.
4531d30ea906Sjfb8856606  *   - -ENODEV: The port ID is invalid.
4532d30ea906Sjfb8856606  *   - -EIO: if device is removed.
4533d30ea906Sjfb8856606  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
4534d30ea906Sjfb8856606  */
4535d30ea906Sjfb8856606 int rte_eth_timesync_read_tx_timestamp(uint16_t port_id,
4536d30ea906Sjfb8856606 		struct timespec *timestamp);
4537d30ea906Sjfb8856606 
4538d30ea906Sjfb8856606 /**
4539d30ea906Sjfb8856606  * Adjust the timesync clock on an Ethernet device.
4540d30ea906Sjfb8856606  *
4541d30ea906Sjfb8856606  * This is usually used in conjunction with other Ethdev timesync functions to
4542d30ea906Sjfb8856606  * synchronize the device time using the IEEE1588/802.1AS protocol.
4543d30ea906Sjfb8856606  *
4544d30ea906Sjfb8856606  * @param port_id
4545d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4546d30ea906Sjfb8856606  * @param delta
4547d30ea906Sjfb8856606  *   The adjustment in nanoseconds.
4548d30ea906Sjfb8856606  *
4549d30ea906Sjfb8856606  * @return
4550d30ea906Sjfb8856606  *   - 0: Success.
4551d30ea906Sjfb8856606  *   - -ENODEV: The port ID is invalid.
4552d30ea906Sjfb8856606  *   - -EIO: if device is removed.
4553d30ea906Sjfb8856606  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
4554d30ea906Sjfb8856606  */
4555d30ea906Sjfb8856606 int rte_eth_timesync_adjust_time(uint16_t port_id, int64_t delta);
4556d30ea906Sjfb8856606 
4557d30ea906Sjfb8856606 /**
4558d30ea906Sjfb8856606  * Read the time from the timesync clock on an Ethernet device.
4559d30ea906Sjfb8856606  *
4560d30ea906Sjfb8856606  * This is usually used in conjunction with other Ethdev timesync functions to
4561d30ea906Sjfb8856606  * synchronize the device time using the IEEE1588/802.1AS protocol.
4562d30ea906Sjfb8856606  *
4563d30ea906Sjfb8856606  * @param port_id
4564d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4565d30ea906Sjfb8856606  * @param time
4566d30ea906Sjfb8856606  *   Pointer to the timespec struct that holds the time.
4567d30ea906Sjfb8856606  *
4568d30ea906Sjfb8856606  * @return
4569d30ea906Sjfb8856606  *   - 0: Success.
4570d30ea906Sjfb8856606  */
4571d30ea906Sjfb8856606 int rte_eth_timesync_read_time(uint16_t port_id, struct timespec *time);
4572d30ea906Sjfb8856606 
4573d30ea906Sjfb8856606 /**
4574d30ea906Sjfb8856606  * Set the time of the timesync clock on an Ethernet device.
4575d30ea906Sjfb8856606  *
4576d30ea906Sjfb8856606  * This is usually used in conjunction with other Ethdev timesync functions to
4577d30ea906Sjfb8856606  * synchronize the device time using the IEEE1588/802.1AS protocol.
4578d30ea906Sjfb8856606  *
4579d30ea906Sjfb8856606  * @param port_id
4580d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4581d30ea906Sjfb8856606  * @param time
4582d30ea906Sjfb8856606  *   Pointer to the timespec struct that holds the time.
4583d30ea906Sjfb8856606  *
4584d30ea906Sjfb8856606  * @return
4585d30ea906Sjfb8856606  *   - 0: Success.
4586d30ea906Sjfb8856606  *   - -EINVAL: No timestamp is available.
4587d30ea906Sjfb8856606  *   - -ENODEV: The port ID is invalid.
4588d30ea906Sjfb8856606  *   - -EIO: if device is removed.
4589d30ea906Sjfb8856606  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
4590d30ea906Sjfb8856606  */
4591d30ea906Sjfb8856606 int rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *time);
4592d30ea906Sjfb8856606 
4593d30ea906Sjfb8856606 /**
45944418919fSjohnjiang  * @warning
45954418919fSjohnjiang  * @b EXPERIMENTAL: this API may change without prior notice.
45964418919fSjohnjiang  *
45974418919fSjohnjiang  * Read the current clock counter of an Ethernet device
45984418919fSjohnjiang  *
45994418919fSjohnjiang  * This returns the current raw clock value of an Ethernet device. It is
46004418919fSjohnjiang  * a raw amount of ticks, with no given time reference.
46014418919fSjohnjiang  * The value returned here is from the same clock than the one
46024418919fSjohnjiang  * filling timestamp field of Rx packets when using hardware timestamp
46034418919fSjohnjiang  * offload. Therefore it can be used to compute a precise conversion of
46044418919fSjohnjiang  * the device clock to the real time.
46054418919fSjohnjiang  *
46064418919fSjohnjiang  * E.g, a simple heuristic to derivate the frequency would be:
46074418919fSjohnjiang  * uint64_t start, end;
46084418919fSjohnjiang  * rte_eth_read_clock(port, start);
46094418919fSjohnjiang  * rte_delay_ms(100);
46104418919fSjohnjiang  * rte_eth_read_clock(port, end);
46114418919fSjohnjiang  * double freq = (end - start) * 10;
46124418919fSjohnjiang  *
46134418919fSjohnjiang  * Compute a common reference with:
46144418919fSjohnjiang  * uint64_t base_time_sec = current_time();
46154418919fSjohnjiang  * uint64_t base_clock;
46164418919fSjohnjiang  * rte_eth_read_clock(port, base_clock);
46174418919fSjohnjiang  *
46184418919fSjohnjiang  * Then, convert the raw mbuf timestamp with:
4619*2d9fd380Sjfb8856606  * base_time_sec + (double)(*timestamp_dynfield(mbuf) - base_clock) / freq;
46204418919fSjohnjiang  *
46214418919fSjohnjiang  * This simple example will not provide a very good accuracy. One must
46224418919fSjohnjiang  * at least measure multiple times the frequency and do a regression.
46234418919fSjohnjiang  * To avoid deviation from the system time, the common reference can
46244418919fSjohnjiang  * be repeated from time to time. The integer division can also be
46254418919fSjohnjiang  * converted by a multiplication and a shift for better performance.
46264418919fSjohnjiang  *
46274418919fSjohnjiang  * @param port_id
46284418919fSjohnjiang  *   The port identifier of the Ethernet device.
46294418919fSjohnjiang  * @param clock
46304418919fSjohnjiang  *   Pointer to the uint64_t that holds the raw clock value.
46314418919fSjohnjiang  *
46324418919fSjohnjiang  * @return
46334418919fSjohnjiang  *   - 0: Success.
46344418919fSjohnjiang  *   - -ENODEV: The port ID is invalid.
46354418919fSjohnjiang  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
46364418919fSjohnjiang  */
46374418919fSjohnjiang __rte_experimental
46384418919fSjohnjiang int
46394418919fSjohnjiang rte_eth_read_clock(uint16_t port_id, uint64_t *clock);
46404418919fSjohnjiang 
46414418919fSjohnjiang /**
4642d30ea906Sjfb8856606 * Get the port id from device name. The device name should be specified
4643d30ea906Sjfb8856606 * as below:
4644d30ea906Sjfb8856606 * - PCIe address (Domain:Bus:Device.Function), for example- 0000:2:00.0
4645d30ea906Sjfb8856606 * - SoC device name, for example- fsl-gmac0
4646d30ea906Sjfb8856606 * - vdev dpdk name, for example- net_[pcap0|null0|tap0]
4647d30ea906Sjfb8856606 *
4648d30ea906Sjfb8856606 * @param name
4649d30ea906Sjfb8856606 *  pci address or name of the device
4650d30ea906Sjfb8856606 * @param port_id
4651d30ea906Sjfb8856606 *   pointer to port identifier of the device
4652d30ea906Sjfb8856606 * @return
4653d30ea906Sjfb8856606 *   - (0) if successful and port_id is filled.
4654d30ea906Sjfb8856606 *   - (-ENODEV or -EINVAL) on failure.
4655d30ea906Sjfb8856606 */
4656d30ea906Sjfb8856606 int
4657d30ea906Sjfb8856606 rte_eth_dev_get_port_by_name(const char *name, uint16_t *port_id);
4658d30ea906Sjfb8856606 
4659d30ea906Sjfb8856606 /**
4660d30ea906Sjfb8856606 * Get the device name from port id. The device name is specified as below:
4661d30ea906Sjfb8856606 * - PCIe address (Domain:Bus:Device.Function), for example- 0000:02:00.0
4662d30ea906Sjfb8856606 * - SoC device name, for example- fsl-gmac0
4663d30ea906Sjfb8856606 * - vdev dpdk name, for example- net_[pcap0|null0|tun0|tap0]
4664d30ea906Sjfb8856606 *
4665d30ea906Sjfb8856606 * @param port_id
4666d30ea906Sjfb8856606 *   Port identifier of the device.
4667d30ea906Sjfb8856606 * @param name
4668d30ea906Sjfb8856606 *   Buffer of size RTE_ETH_NAME_MAX_LEN to store the name.
4669d30ea906Sjfb8856606 * @return
4670d30ea906Sjfb8856606 *   - (0) if successful.
4671*2d9fd380Sjfb8856606 *   - (-ENODEV) if *port_id* is invalid.
4672d30ea906Sjfb8856606 *   - (-EINVAL) on failure.
4673d30ea906Sjfb8856606 */
4674d30ea906Sjfb8856606 int
4675d30ea906Sjfb8856606 rte_eth_dev_get_name_by_port(uint16_t port_id, char *name);
4676d30ea906Sjfb8856606 
4677d30ea906Sjfb8856606 /**
4678d30ea906Sjfb8856606  * Check that numbers of Rx and Tx descriptors satisfy descriptors limits from
4679d30ea906Sjfb8856606  * the ethernet device information, otherwise adjust them to boundaries.
4680d30ea906Sjfb8856606  *
4681d30ea906Sjfb8856606  * @param port_id
4682d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4683d30ea906Sjfb8856606  * @param nb_rx_desc
4684d30ea906Sjfb8856606  *   A pointer to a uint16_t where the number of receive
4685d30ea906Sjfb8856606  *   descriptors stored.
4686d30ea906Sjfb8856606  * @param nb_tx_desc
4687d30ea906Sjfb8856606  *   A pointer to a uint16_t where the number of transmit
4688d30ea906Sjfb8856606  *   descriptors stored.
4689d30ea906Sjfb8856606  * @return
4690d30ea906Sjfb8856606  *   - (0) if successful.
4691d30ea906Sjfb8856606  *   - (-ENOTSUP, -ENODEV or -EINVAL) on failure.
4692d30ea906Sjfb8856606  */
4693d30ea906Sjfb8856606 int rte_eth_dev_adjust_nb_rx_tx_desc(uint16_t port_id,
4694d30ea906Sjfb8856606 				     uint16_t *nb_rx_desc,
4695d30ea906Sjfb8856606 				     uint16_t *nb_tx_desc);
4696d30ea906Sjfb8856606 
4697d30ea906Sjfb8856606 /**
4698d30ea906Sjfb8856606  * Test if a port supports specific mempool ops.
4699d30ea906Sjfb8856606  *
4700d30ea906Sjfb8856606  * @param port_id
4701d30ea906Sjfb8856606  *   Port identifier of the Ethernet device.
4702d30ea906Sjfb8856606  * @param [in] pool
4703d30ea906Sjfb8856606  *   The name of the pool operations to test.
4704d30ea906Sjfb8856606  * @return
4705d30ea906Sjfb8856606  *   - 0: best mempool ops choice for this port.
4706d30ea906Sjfb8856606  *   - 1: mempool ops are supported for this port.
4707d30ea906Sjfb8856606  *   - -ENOTSUP: mempool ops not supported for this port.
4708d30ea906Sjfb8856606  *   - -ENODEV: Invalid port Identifier.
4709d30ea906Sjfb8856606  *   - -EINVAL: Pool param is null.
4710d30ea906Sjfb8856606  */
4711d30ea906Sjfb8856606 int
4712d30ea906Sjfb8856606 rte_eth_dev_pool_ops_supported(uint16_t port_id, const char *pool);
4713d30ea906Sjfb8856606 
4714d30ea906Sjfb8856606 /**
4715d30ea906Sjfb8856606  * Get the security context for the Ethernet device.
4716d30ea906Sjfb8856606  *
4717d30ea906Sjfb8856606  * @param port_id
4718d30ea906Sjfb8856606  *   Port identifier of the Ethernet device
4719d30ea906Sjfb8856606  * @return
4720d30ea906Sjfb8856606  *   - NULL on error.
4721d30ea906Sjfb8856606  *   - pointer to security context on success.
4722d30ea906Sjfb8856606  */
4723d30ea906Sjfb8856606 void *
4724d30ea906Sjfb8856606 rte_eth_dev_get_sec_ctx(uint16_t port_id);
4725d30ea906Sjfb8856606 
47264418919fSjohnjiang /**
47274418919fSjohnjiang  * @warning
47284418919fSjohnjiang  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
47294418919fSjohnjiang  *
47304418919fSjohnjiang  * Query the device hairpin capabilities.
47314418919fSjohnjiang  *
47324418919fSjohnjiang  * @param port_id
47334418919fSjohnjiang  *   The port identifier of the Ethernet device.
47344418919fSjohnjiang  * @param cap
47354418919fSjohnjiang  *   Pointer to a structure that will hold the hairpin capabilities.
47364418919fSjohnjiang  * @return
47374418919fSjohnjiang  *   - (0) if successful.
47384418919fSjohnjiang  *   - (-ENOTSUP) if hardware doesn't support.
47394418919fSjohnjiang  */
47404418919fSjohnjiang __rte_experimental
47414418919fSjohnjiang int rte_eth_dev_hairpin_capability_get(uint16_t port_id,
47424418919fSjohnjiang 				       struct rte_eth_hairpin_cap *cap);
4743d30ea906Sjfb8856606 
4744d30ea906Sjfb8856606 #include <rte_ethdev_core.h>
4745d30ea906Sjfb8856606 
4746d30ea906Sjfb8856606 /**
4747d30ea906Sjfb8856606  *
4748d30ea906Sjfb8856606  * Retrieve a burst of input packets from a receive queue of an Ethernet
4749d30ea906Sjfb8856606  * device. The retrieved packets are stored in *rte_mbuf* structures whose
4750d30ea906Sjfb8856606  * pointers are supplied in the *rx_pkts* array.
4751d30ea906Sjfb8856606  *
4752d30ea906Sjfb8856606  * The rte_eth_rx_burst() function loops, parsing the RX ring of the
4753d30ea906Sjfb8856606  * receive queue, up to *nb_pkts* packets, and for each completed RX
4754d30ea906Sjfb8856606  * descriptor in the ring, it performs the following operations:
4755d30ea906Sjfb8856606  *
4756d30ea906Sjfb8856606  * - Initialize the *rte_mbuf* data structure associated with the
4757d30ea906Sjfb8856606  *   RX descriptor according to the information provided by the NIC into
4758d30ea906Sjfb8856606  *   that RX descriptor.
4759d30ea906Sjfb8856606  *
4760d30ea906Sjfb8856606  * - Store the *rte_mbuf* data structure into the next entry of the
4761d30ea906Sjfb8856606  *   *rx_pkts* array.
4762d30ea906Sjfb8856606  *
4763d30ea906Sjfb8856606  * - Replenish the RX descriptor with a new *rte_mbuf* buffer
4764d30ea906Sjfb8856606  *   allocated from the memory pool associated with the receive queue at
4765d30ea906Sjfb8856606  *   initialization time.
4766d30ea906Sjfb8856606  *
4767d30ea906Sjfb8856606  * When retrieving an input packet that was scattered by the controller
4768d30ea906Sjfb8856606  * into multiple receive descriptors, the rte_eth_rx_burst() function
4769d30ea906Sjfb8856606  * appends the associated *rte_mbuf* buffers to the first buffer of the
4770d30ea906Sjfb8856606  * packet.
4771d30ea906Sjfb8856606  *
4772d30ea906Sjfb8856606  * The rte_eth_rx_burst() function returns the number of packets
4773d30ea906Sjfb8856606  * actually retrieved, which is the number of *rte_mbuf* data structures
4774d30ea906Sjfb8856606  * effectively supplied into the *rx_pkts* array.
4775d30ea906Sjfb8856606  * A return value equal to *nb_pkts* indicates that the RX queue contained
4776d30ea906Sjfb8856606  * at least *rx_pkts* packets, and this is likely to signify that other
4777d30ea906Sjfb8856606  * received packets remain in the input queue. Applications implementing
4778d30ea906Sjfb8856606  * a "retrieve as much received packets as possible" policy can check this
4779d30ea906Sjfb8856606  * specific case and keep invoking the rte_eth_rx_burst() function until
4780d30ea906Sjfb8856606  * a value less than *nb_pkts* is returned.
4781d30ea906Sjfb8856606  *
4782d30ea906Sjfb8856606  * This receive method has the following advantages:
4783d30ea906Sjfb8856606  *
4784d30ea906Sjfb8856606  * - It allows a run-to-completion network stack engine to retrieve and
4785d30ea906Sjfb8856606  *   to immediately process received packets in a fast burst-oriented
4786d30ea906Sjfb8856606  *   approach, avoiding the overhead of unnecessary intermediate packet
4787d30ea906Sjfb8856606  *   queue/dequeue operations.
4788d30ea906Sjfb8856606  *
4789d30ea906Sjfb8856606  * - Conversely, it also allows an asynchronous-oriented processing
4790d30ea906Sjfb8856606  *   method to retrieve bursts of received packets and to immediately
4791d30ea906Sjfb8856606  *   queue them for further parallel processing by another logical core,
4792d30ea906Sjfb8856606  *   for instance. However, instead of having received packets being
4793d30ea906Sjfb8856606  *   individually queued by the driver, this approach allows the caller
4794d30ea906Sjfb8856606  *   of the rte_eth_rx_burst() function to queue a burst of retrieved
4795d30ea906Sjfb8856606  *   packets at a time and therefore dramatically reduce the cost of
4796d30ea906Sjfb8856606  *   enqueue/dequeue operations per packet.
4797d30ea906Sjfb8856606  *
4798d30ea906Sjfb8856606  * - It allows the rte_eth_rx_burst() function of the driver to take
4799d30ea906Sjfb8856606  *   advantage of burst-oriented hardware features (CPU cache,
4800d30ea906Sjfb8856606  *   prefetch instructions, and so on) to minimize the number of CPU
4801d30ea906Sjfb8856606  *   cycles per packet.
4802d30ea906Sjfb8856606  *
4803d30ea906Sjfb8856606  * To summarize, the proposed receive API enables many
4804d30ea906Sjfb8856606  * burst-oriented optimizations in both synchronous and asynchronous
4805d30ea906Sjfb8856606  * packet processing environments with no overhead in both cases.
4806d30ea906Sjfb8856606  *
4807*2d9fd380Sjfb8856606  * @note
4808*2d9fd380Sjfb8856606  *   Some drivers using vector instructions require that *nb_pkts* is
4809*2d9fd380Sjfb8856606  *   divisible by 4 or 8, depending on the driver implementation.
4810*2d9fd380Sjfb8856606  *
4811d30ea906Sjfb8856606  * The rte_eth_rx_burst() function does not provide any error
4812d30ea906Sjfb8856606  * notification to avoid the corresponding overhead. As a hint, the
4813d30ea906Sjfb8856606  * upper-level application might check the status of the device link once
4814d30ea906Sjfb8856606  * being systematically returned a 0 value for a given number of tries.
4815d30ea906Sjfb8856606  *
4816d30ea906Sjfb8856606  * @param port_id
4817d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
4818d30ea906Sjfb8856606  * @param queue_id
4819d30ea906Sjfb8856606  *   The index of the receive queue from which to retrieve input packets.
4820d30ea906Sjfb8856606  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
4821d30ea906Sjfb8856606  *   to rte_eth_dev_configure().
4822d30ea906Sjfb8856606  * @param rx_pkts
4823d30ea906Sjfb8856606  *   The address of an array of pointers to *rte_mbuf* structures that
4824d30ea906Sjfb8856606  *   must be large enough to store *nb_pkts* pointers in it.
4825d30ea906Sjfb8856606  * @param nb_pkts
4826d30ea906Sjfb8856606  *   The maximum number of packets to retrieve.
4827*2d9fd380Sjfb8856606  *   The value must be divisible by 8 in order to work with any driver.
4828d30ea906Sjfb8856606  * @return
4829d30ea906Sjfb8856606  *   The number of packets actually retrieved, which is the number
4830d30ea906Sjfb8856606  *   of pointers to *rte_mbuf* structures effectively supplied to the
4831d30ea906Sjfb8856606  *   *rx_pkts* array.
4832d30ea906Sjfb8856606  */
4833d30ea906Sjfb8856606 static inline uint16_t
rte_eth_rx_burst(uint16_t port_id,uint16_t queue_id,struct rte_mbuf ** rx_pkts,const uint16_t nb_pkts)4834d30ea906Sjfb8856606 rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id,
4835d30ea906Sjfb8856606 		 struct rte_mbuf **rx_pkts, const uint16_t nb_pkts)
4836d30ea906Sjfb8856606 {
4837d30ea906Sjfb8856606 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
4838d30ea906Sjfb8856606 	uint16_t nb_rx;
4839d30ea906Sjfb8856606 
4840d30ea906Sjfb8856606 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
4841d30ea906Sjfb8856606 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
4842d30ea906Sjfb8856606 	RTE_FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, 0);
4843d30ea906Sjfb8856606 
4844d30ea906Sjfb8856606 	if (queue_id >= dev->data->nb_rx_queues) {
4845d30ea906Sjfb8856606 		RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n", queue_id);
4846d30ea906Sjfb8856606 		return 0;
4847d30ea906Sjfb8856606 	}
4848d30ea906Sjfb8856606 #endif
4849d30ea906Sjfb8856606 	nb_rx = (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
4850d30ea906Sjfb8856606 				     rx_pkts, nb_pkts);
4851d30ea906Sjfb8856606 
4852d30ea906Sjfb8856606 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
48530c6bd470Sfengbojiang 	struct rte_eth_rxtx_callback *cb;
4854d30ea906Sjfb8856606 
48550c6bd470Sfengbojiang 	/* __ATOMIC_RELEASE memory order was used when the
48560c6bd470Sfengbojiang 	 * call back was inserted into the list.
48570c6bd470Sfengbojiang 	 * Since there is a clear dependency between loading
48580c6bd470Sfengbojiang 	 * cb and cb->fn/cb->next, __ATOMIC_ACQUIRE memory order is
48590c6bd470Sfengbojiang 	 * not required.
48600c6bd470Sfengbojiang 	 */
48610c6bd470Sfengbojiang 	cb = __atomic_load_n(&dev->post_rx_burst_cbs[queue_id],
48620c6bd470Sfengbojiang 				__ATOMIC_RELAXED);
48630c6bd470Sfengbojiang 
48640c6bd470Sfengbojiang 	if (unlikely(cb != NULL)) {
4865d30ea906Sjfb8856606 		do {
4866d30ea906Sjfb8856606 			nb_rx = cb->fn.rx(port_id, queue_id, rx_pkts, nb_rx,
4867d30ea906Sjfb8856606 						nb_pkts, cb->param);
4868d30ea906Sjfb8856606 			cb = cb->next;
4869d30ea906Sjfb8856606 		} while (cb != NULL);
4870d30ea906Sjfb8856606 	}
4871d30ea906Sjfb8856606 #endif
4872d30ea906Sjfb8856606 
4873*2d9fd380Sjfb8856606 	rte_ethdev_trace_rx_burst(port_id, queue_id, (void **)rx_pkts, nb_rx);
4874d30ea906Sjfb8856606 	return nb_rx;
4875d30ea906Sjfb8856606 }
4876d30ea906Sjfb8856606 
4877d30ea906Sjfb8856606 /**
4878d30ea906Sjfb8856606  * Get the number of used descriptors of a rx queue
4879d30ea906Sjfb8856606  *
4880d30ea906Sjfb8856606  * @param port_id
4881d30ea906Sjfb8856606  *  The port identifier of the Ethernet device.
4882d30ea906Sjfb8856606  * @param queue_id
4883d30ea906Sjfb8856606  *  The queue id on the specific port.
4884d30ea906Sjfb8856606  * @return
4885d30ea906Sjfb8856606  *  The number of used descriptors in the specific queue, or:
4886*2d9fd380Sjfb8856606  *   - (-ENODEV) if *port_id* is invalid.
4887*2d9fd380Sjfb8856606  *     (-EINVAL) if *queue_id* is invalid
4888d30ea906Sjfb8856606  *     (-ENOTSUP) if the device does not support this function
4889d30ea906Sjfb8856606  */
4890d30ea906Sjfb8856606 static inline int
rte_eth_rx_queue_count(uint16_t port_id,uint16_t queue_id)4891d30ea906Sjfb8856606 rte_eth_rx_queue_count(uint16_t port_id, uint16_t queue_id)
4892d30ea906Sjfb8856606 {
4893d30ea906Sjfb8856606 	struct rte_eth_dev *dev;
4894d30ea906Sjfb8856606 
4895*2d9fd380Sjfb8856606 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
4896d30ea906Sjfb8856606 	dev = &rte_eth_devices[port_id];
4897*2d9fd380Sjfb8856606 	RTE_FUNC_PTR_OR_ERR_RET(*dev->rx_queue_count, -ENOTSUP);
4898*2d9fd380Sjfb8856606 	if (queue_id >= dev->data->nb_rx_queues ||
4899*2d9fd380Sjfb8856606 	    dev->data->rx_queues[queue_id] == NULL)
4900d30ea906Sjfb8856606 		return -EINVAL;
4901d30ea906Sjfb8856606 
4902*2d9fd380Sjfb8856606 	return (int)(*dev->rx_queue_count)(dev, queue_id);
4903d30ea906Sjfb8856606 }
4904d30ea906Sjfb8856606 
4905d30ea906Sjfb8856606 /**
4906d30ea906Sjfb8856606  * Check if the DD bit of the specific RX descriptor in the queue has been set
4907d30ea906Sjfb8856606  *
4908d30ea906Sjfb8856606  * @param port_id
4909d30ea906Sjfb8856606  *  The port identifier of the Ethernet device.
4910d30ea906Sjfb8856606  * @param queue_id
4911d30ea906Sjfb8856606  *  The queue id on the specific port.
4912d30ea906Sjfb8856606  * @param offset
4913d30ea906Sjfb8856606  *  The offset of the descriptor ID from tail.
4914d30ea906Sjfb8856606  * @return
4915d30ea906Sjfb8856606  *  - (1) if the specific DD bit is set.
4916d30ea906Sjfb8856606  *  - (0) if the specific DD bit is not set.
4917d30ea906Sjfb8856606  *  - (-ENODEV) if *port_id* invalid.
4918d30ea906Sjfb8856606  *  - (-ENOTSUP) if the device does not support this function
4919d30ea906Sjfb8856606  */
4920*2d9fd380Sjfb8856606 __rte_deprecated
4921d30ea906Sjfb8856606 static inline int
rte_eth_rx_descriptor_done(uint16_t port_id,uint16_t queue_id,uint16_t offset)4922d30ea906Sjfb8856606 rte_eth_rx_descriptor_done(uint16_t port_id, uint16_t queue_id, uint16_t offset)
4923d30ea906Sjfb8856606 {
4924d30ea906Sjfb8856606 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
4925d30ea906Sjfb8856606 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
4926*2d9fd380Sjfb8856606 	RTE_FUNC_PTR_OR_ERR_RET(*dev->rx_descriptor_done, -ENOTSUP);
4927*2d9fd380Sjfb8856606 	return (*dev->rx_descriptor_done)(dev->data->rx_queues[queue_id], offset);
4928d30ea906Sjfb8856606 }
4929d30ea906Sjfb8856606 
4930d30ea906Sjfb8856606 #define RTE_ETH_RX_DESC_AVAIL    0 /**< Desc available for hw. */
4931d30ea906Sjfb8856606 #define RTE_ETH_RX_DESC_DONE     1 /**< Desc done, filled by hw. */
4932d30ea906Sjfb8856606 #define RTE_ETH_RX_DESC_UNAVAIL  2 /**< Desc used by driver or hw. */
4933d30ea906Sjfb8856606 
4934d30ea906Sjfb8856606 /**
4935d30ea906Sjfb8856606  * Check the status of a Rx descriptor in the queue
4936d30ea906Sjfb8856606  *
4937d30ea906Sjfb8856606  * It should be called in a similar context than the Rx function:
4938d30ea906Sjfb8856606  * - on a dataplane core
4939d30ea906Sjfb8856606  * - not concurrently on the same queue
4940d30ea906Sjfb8856606  *
4941d30ea906Sjfb8856606  * Since it's a dataplane function, no check is performed on port_id and
4942d30ea906Sjfb8856606  * queue_id. The caller must therefore ensure that the port is enabled
4943d30ea906Sjfb8856606  * and the queue is configured and running.
4944d30ea906Sjfb8856606  *
4945d30ea906Sjfb8856606  * Note: accessing to a random descriptor in the ring may trigger cache
4946d30ea906Sjfb8856606  * misses and have a performance impact.
4947d30ea906Sjfb8856606  *
4948d30ea906Sjfb8856606  * @param port_id
4949d30ea906Sjfb8856606  *  A valid port identifier of the Ethernet device which.
4950d30ea906Sjfb8856606  * @param queue_id
4951d30ea906Sjfb8856606  *  A valid Rx queue identifier on this port.
4952d30ea906Sjfb8856606  * @param offset
4953d30ea906Sjfb8856606  *  The offset of the descriptor starting from tail (0 is the next
4954d30ea906Sjfb8856606  *  packet to be received by the driver).
4955d30ea906Sjfb8856606  *
4956d30ea906Sjfb8856606  * @return
4957d30ea906Sjfb8856606  *  - (RTE_ETH_RX_DESC_AVAIL): Descriptor is available for the hardware to
4958d30ea906Sjfb8856606  *    receive a packet.
4959d30ea906Sjfb8856606  *  - (RTE_ETH_RX_DESC_DONE): Descriptor is done, it is filled by hw, but
4960d30ea906Sjfb8856606  *    not yet processed by the driver (i.e. in the receive queue).
4961d30ea906Sjfb8856606  *  - (RTE_ETH_RX_DESC_UNAVAIL): Descriptor is unavailable, either hold by
4962d30ea906Sjfb8856606  *    the driver and not yet returned to hw, or reserved by the hw.
4963d30ea906Sjfb8856606  *  - (-EINVAL) bad descriptor offset.
4964d30ea906Sjfb8856606  *  - (-ENOTSUP) if the device does not support this function.
4965d30ea906Sjfb8856606  *  - (-ENODEV) bad port or queue (only if compiled with debug).
4966d30ea906Sjfb8856606  */
4967d30ea906Sjfb8856606 static inline int
rte_eth_rx_descriptor_status(uint16_t port_id,uint16_t queue_id,uint16_t offset)4968d30ea906Sjfb8856606 rte_eth_rx_descriptor_status(uint16_t port_id, uint16_t queue_id,
4969d30ea906Sjfb8856606 	uint16_t offset)
4970d30ea906Sjfb8856606 {
4971d30ea906Sjfb8856606 	struct rte_eth_dev *dev;
4972d30ea906Sjfb8856606 	void *rxq;
4973d30ea906Sjfb8856606 
4974d30ea906Sjfb8856606 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
4975d30ea906Sjfb8856606 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
4976d30ea906Sjfb8856606 #endif
4977d30ea906Sjfb8856606 	dev = &rte_eth_devices[port_id];
4978d30ea906Sjfb8856606 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
4979d30ea906Sjfb8856606 	if (queue_id >= dev->data->nb_rx_queues)
4980d30ea906Sjfb8856606 		return -ENODEV;
4981d30ea906Sjfb8856606 #endif
4982*2d9fd380Sjfb8856606 	RTE_FUNC_PTR_OR_ERR_RET(*dev->rx_descriptor_status, -ENOTSUP);
4983d30ea906Sjfb8856606 	rxq = dev->data->rx_queues[queue_id];
4984d30ea906Sjfb8856606 
4985*2d9fd380Sjfb8856606 	return (*dev->rx_descriptor_status)(rxq, offset);
4986d30ea906Sjfb8856606 }
4987d30ea906Sjfb8856606 
4988d30ea906Sjfb8856606 #define RTE_ETH_TX_DESC_FULL    0 /**< Desc filled for hw, waiting xmit. */
4989d30ea906Sjfb8856606 #define RTE_ETH_TX_DESC_DONE    1 /**< Desc done, packet is transmitted. */
4990d30ea906Sjfb8856606 #define RTE_ETH_TX_DESC_UNAVAIL 2 /**< Desc used by driver or hw. */
4991d30ea906Sjfb8856606 
4992d30ea906Sjfb8856606 /**
4993d30ea906Sjfb8856606  * Check the status of a Tx descriptor in the queue.
4994d30ea906Sjfb8856606  *
4995d30ea906Sjfb8856606  * It should be called in a similar context than the Tx function:
4996d30ea906Sjfb8856606  * - on a dataplane core
4997d30ea906Sjfb8856606  * - not concurrently on the same queue
4998d30ea906Sjfb8856606  *
4999d30ea906Sjfb8856606  * Since it's a dataplane function, no check is performed on port_id and
5000d30ea906Sjfb8856606  * queue_id. The caller must therefore ensure that the port is enabled
5001d30ea906Sjfb8856606  * and the queue is configured and running.
5002d30ea906Sjfb8856606  *
5003d30ea906Sjfb8856606  * Note: accessing to a random descriptor in the ring may trigger cache
5004d30ea906Sjfb8856606  * misses and have a performance impact.
5005d30ea906Sjfb8856606  *
5006d30ea906Sjfb8856606  * @param port_id
5007d30ea906Sjfb8856606  *  A valid port identifier of the Ethernet device which.
5008d30ea906Sjfb8856606  * @param queue_id
5009d30ea906Sjfb8856606  *  A valid Tx queue identifier on this port.
5010d30ea906Sjfb8856606  * @param offset
5011d30ea906Sjfb8856606  *  The offset of the descriptor starting from tail (0 is the place where
5012d30ea906Sjfb8856606  *  the next packet will be send).
5013d30ea906Sjfb8856606  *
5014d30ea906Sjfb8856606  * @return
5015d30ea906Sjfb8856606  *  - (RTE_ETH_TX_DESC_FULL) Descriptor is being processed by the hw, i.e.
5016d30ea906Sjfb8856606  *    in the transmit queue.
5017d30ea906Sjfb8856606  *  - (RTE_ETH_TX_DESC_DONE) Hardware is done with this descriptor, it can
5018d30ea906Sjfb8856606  *    be reused by the driver.
5019d30ea906Sjfb8856606  *  - (RTE_ETH_TX_DESC_UNAVAIL): Descriptor is unavailable, reserved by the
5020d30ea906Sjfb8856606  *    driver or the hardware.
5021d30ea906Sjfb8856606  *  - (-EINVAL) bad descriptor offset.
5022d30ea906Sjfb8856606  *  - (-ENOTSUP) if the device does not support this function.
5023d30ea906Sjfb8856606  *  - (-ENODEV) bad port or queue (only if compiled with debug).
5024d30ea906Sjfb8856606  */
rte_eth_tx_descriptor_status(uint16_t port_id,uint16_t queue_id,uint16_t offset)5025d30ea906Sjfb8856606 static inline int rte_eth_tx_descriptor_status(uint16_t port_id,
5026d30ea906Sjfb8856606 	uint16_t queue_id, uint16_t offset)
5027d30ea906Sjfb8856606 {
5028d30ea906Sjfb8856606 	struct rte_eth_dev *dev;
5029d30ea906Sjfb8856606 	void *txq;
5030d30ea906Sjfb8856606 
5031d30ea906Sjfb8856606 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
5032d30ea906Sjfb8856606 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
5033d30ea906Sjfb8856606 #endif
5034d30ea906Sjfb8856606 	dev = &rte_eth_devices[port_id];
5035d30ea906Sjfb8856606 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
5036d30ea906Sjfb8856606 	if (queue_id >= dev->data->nb_tx_queues)
5037d30ea906Sjfb8856606 		return -ENODEV;
5038d30ea906Sjfb8856606 #endif
5039*2d9fd380Sjfb8856606 	RTE_FUNC_PTR_OR_ERR_RET(*dev->tx_descriptor_status, -ENOTSUP);
5040d30ea906Sjfb8856606 	txq = dev->data->tx_queues[queue_id];
5041d30ea906Sjfb8856606 
5042*2d9fd380Sjfb8856606 	return (*dev->tx_descriptor_status)(txq, offset);
5043d30ea906Sjfb8856606 }
5044d30ea906Sjfb8856606 
5045d30ea906Sjfb8856606 /**
5046d30ea906Sjfb8856606  * Send a burst of output packets on a transmit queue of an Ethernet device.
5047d30ea906Sjfb8856606  *
5048d30ea906Sjfb8856606  * The rte_eth_tx_burst() function is invoked to transmit output packets
5049d30ea906Sjfb8856606  * on the output queue *queue_id* of the Ethernet device designated by its
5050d30ea906Sjfb8856606  * *port_id*.
5051d30ea906Sjfb8856606  * The *nb_pkts* parameter is the number of packets to send which are
5052d30ea906Sjfb8856606  * supplied in the *tx_pkts* array of *rte_mbuf* structures, each of them
5053d30ea906Sjfb8856606  * allocated from a pool created with rte_pktmbuf_pool_create().
5054d30ea906Sjfb8856606  * The rte_eth_tx_burst() function loops, sending *nb_pkts* packets,
5055d30ea906Sjfb8856606  * up to the number of transmit descriptors available in the TX ring of the
5056d30ea906Sjfb8856606  * transmit queue.
5057d30ea906Sjfb8856606  * For each packet to send, the rte_eth_tx_burst() function performs
5058d30ea906Sjfb8856606  * the following operations:
5059d30ea906Sjfb8856606  *
5060d30ea906Sjfb8856606  * - Pick up the next available descriptor in the transmit ring.
5061d30ea906Sjfb8856606  *
5062d30ea906Sjfb8856606  * - Free the network buffer previously sent with that descriptor, if any.
5063d30ea906Sjfb8856606  *
5064d30ea906Sjfb8856606  * - Initialize the transmit descriptor with the information provided
5065d30ea906Sjfb8856606  *   in the *rte_mbuf data structure.
5066d30ea906Sjfb8856606  *
5067d30ea906Sjfb8856606  * In the case of a segmented packet composed of a list of *rte_mbuf* buffers,
5068d30ea906Sjfb8856606  * the rte_eth_tx_burst() function uses several transmit descriptors
5069d30ea906Sjfb8856606  * of the ring.
5070d30ea906Sjfb8856606  *
5071d30ea906Sjfb8856606  * The rte_eth_tx_burst() function returns the number of packets it
5072d30ea906Sjfb8856606  * actually sent. A return value equal to *nb_pkts* means that all packets
5073d30ea906Sjfb8856606  * have been sent, and this is likely to signify that other output packets
5074d30ea906Sjfb8856606  * could be immediately transmitted again. Applications that implement a
5075d30ea906Sjfb8856606  * "send as many packets to transmit as possible" policy can check this
5076d30ea906Sjfb8856606  * specific case and keep invoking the rte_eth_tx_burst() function until
5077d30ea906Sjfb8856606  * a value less than *nb_pkts* is returned.
5078d30ea906Sjfb8856606  *
5079d30ea906Sjfb8856606  * It is the responsibility of the rte_eth_tx_burst() function to
5080d30ea906Sjfb8856606  * transparently free the memory buffers of packets previously sent.
5081d30ea906Sjfb8856606  * This feature is driven by the *tx_free_thresh* value supplied to the
5082d30ea906Sjfb8856606  * rte_eth_dev_configure() function at device configuration time.
5083d30ea906Sjfb8856606  * When the number of free TX descriptors drops below this threshold, the
5084d30ea906Sjfb8856606  * rte_eth_tx_burst() function must [attempt to] free the *rte_mbuf*  buffers
5085d30ea906Sjfb8856606  * of those packets whose transmission was effectively completed.
5086d30ea906Sjfb8856606  *
5087d30ea906Sjfb8856606  * If the PMD is DEV_TX_OFFLOAD_MT_LOCKFREE capable, multiple threads can
5088d30ea906Sjfb8856606  * invoke this function concurrently on the same tx queue without SW lock.
5089d30ea906Sjfb8856606  * @see rte_eth_dev_info_get, struct rte_eth_txconf::offloads
5090d30ea906Sjfb8856606  *
5091d30ea906Sjfb8856606  * @see rte_eth_tx_prepare to perform some prior checks or adjustments
5092d30ea906Sjfb8856606  * for offloads.
5093d30ea906Sjfb8856606  *
5094d30ea906Sjfb8856606  * @param port_id
5095d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
5096d30ea906Sjfb8856606  * @param queue_id
5097d30ea906Sjfb8856606  *   The index of the transmit queue through which output packets must be
5098d30ea906Sjfb8856606  *   sent.
5099d30ea906Sjfb8856606  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
5100d30ea906Sjfb8856606  *   to rte_eth_dev_configure().
5101d30ea906Sjfb8856606  * @param tx_pkts
5102d30ea906Sjfb8856606  *   The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
5103d30ea906Sjfb8856606  *   which contain the output packets.
5104d30ea906Sjfb8856606  * @param nb_pkts
5105d30ea906Sjfb8856606  *   The maximum number of packets to transmit.
5106d30ea906Sjfb8856606  * @return
5107d30ea906Sjfb8856606  *   The number of output packets actually stored in transmit descriptors of
5108d30ea906Sjfb8856606  *   the transmit ring. The return value can be less than the value of the
5109d30ea906Sjfb8856606  *   *tx_pkts* parameter when the transmit ring is full or has been filled up.
5110d30ea906Sjfb8856606  */
5111d30ea906Sjfb8856606 static inline uint16_t
rte_eth_tx_burst(uint16_t port_id,uint16_t queue_id,struct rte_mbuf ** tx_pkts,uint16_t nb_pkts)5112d30ea906Sjfb8856606 rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
5113d30ea906Sjfb8856606 		 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
5114d30ea906Sjfb8856606 {
5115d30ea906Sjfb8856606 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
5116d30ea906Sjfb8856606 
5117d30ea906Sjfb8856606 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
5118d30ea906Sjfb8856606 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
5119d30ea906Sjfb8856606 	RTE_FUNC_PTR_OR_ERR_RET(*dev->tx_pkt_burst, 0);
5120d30ea906Sjfb8856606 
5121d30ea906Sjfb8856606 	if (queue_id >= dev->data->nb_tx_queues) {
5122d30ea906Sjfb8856606 		RTE_ETHDEV_LOG(ERR, "Invalid TX queue_id=%u\n", queue_id);
5123d30ea906Sjfb8856606 		return 0;
5124d30ea906Sjfb8856606 	}
5125d30ea906Sjfb8856606 #endif
5126d30ea906Sjfb8856606 
5127d30ea906Sjfb8856606 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
51280c6bd470Sfengbojiang 	struct rte_eth_rxtx_callback *cb;
51290c6bd470Sfengbojiang 
51300c6bd470Sfengbojiang 	/* __ATOMIC_RELEASE memory order was used when the
51310c6bd470Sfengbojiang 	 * call back was inserted into the list.
51320c6bd470Sfengbojiang 	 * Since there is a clear dependency between loading
51330c6bd470Sfengbojiang 	 * cb and cb->fn/cb->next, __ATOMIC_ACQUIRE memory order is
51340c6bd470Sfengbojiang 	 * not required.
51350c6bd470Sfengbojiang 	 */
51360c6bd470Sfengbojiang 	cb = __atomic_load_n(&dev->pre_tx_burst_cbs[queue_id],
51370c6bd470Sfengbojiang 				__ATOMIC_RELAXED);
5138d30ea906Sjfb8856606 
5139d30ea906Sjfb8856606 	if (unlikely(cb != NULL)) {
5140d30ea906Sjfb8856606 		do {
5141d30ea906Sjfb8856606 			nb_pkts = cb->fn.tx(port_id, queue_id, tx_pkts, nb_pkts,
5142d30ea906Sjfb8856606 					cb->param);
5143d30ea906Sjfb8856606 			cb = cb->next;
5144d30ea906Sjfb8856606 		} while (cb != NULL);
5145d30ea906Sjfb8856606 	}
5146d30ea906Sjfb8856606 #endif
5147d30ea906Sjfb8856606 
5148*2d9fd380Sjfb8856606 	rte_ethdev_trace_tx_burst(port_id, queue_id, (void **)tx_pkts,
5149*2d9fd380Sjfb8856606 		nb_pkts);
5150d30ea906Sjfb8856606 	return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id], tx_pkts, nb_pkts);
5151d30ea906Sjfb8856606 }
5152d30ea906Sjfb8856606 
5153d30ea906Sjfb8856606 /**
5154d30ea906Sjfb8856606  * Process a burst of output packets on a transmit queue of an Ethernet device.
5155d30ea906Sjfb8856606  *
5156d30ea906Sjfb8856606  * The rte_eth_tx_prepare() function is invoked to prepare output packets to be
5157d30ea906Sjfb8856606  * transmitted on the output queue *queue_id* of the Ethernet device designated
5158d30ea906Sjfb8856606  * by its *port_id*.
5159d30ea906Sjfb8856606  * The *nb_pkts* parameter is the number of packets to be prepared which are
5160d30ea906Sjfb8856606  * supplied in the *tx_pkts* array of *rte_mbuf* structures, each of them
5161d30ea906Sjfb8856606  * allocated from a pool created with rte_pktmbuf_pool_create().
5162d30ea906Sjfb8856606  * For each packet to send, the rte_eth_tx_prepare() function performs
5163d30ea906Sjfb8856606  * the following operations:
5164d30ea906Sjfb8856606  *
5165d30ea906Sjfb8856606  * - Check if packet meets devices requirements for tx offloads.
5166d30ea906Sjfb8856606  *
5167d30ea906Sjfb8856606  * - Check limitations about number of segments.
5168d30ea906Sjfb8856606  *
5169d30ea906Sjfb8856606  * - Check additional requirements when debug is enabled.
5170d30ea906Sjfb8856606  *
5171d30ea906Sjfb8856606  * - Update and/or reset required checksums when tx offload is set for packet.
5172d30ea906Sjfb8856606  *
5173d30ea906Sjfb8856606  * Since this function can modify packet data, provided mbufs must be safely
5174d30ea906Sjfb8856606  * writable (e.g. modified data cannot be in shared segment).
5175d30ea906Sjfb8856606  *
5176d30ea906Sjfb8856606  * The rte_eth_tx_prepare() function returns the number of packets ready to be
5177d30ea906Sjfb8856606  * sent. A return value equal to *nb_pkts* means that all packets are valid and
5178d30ea906Sjfb8856606  * ready to be sent, otherwise stops processing on the first invalid packet and
5179d30ea906Sjfb8856606  * leaves the rest packets untouched.
5180d30ea906Sjfb8856606  *
5181d30ea906Sjfb8856606  * When this functionality is not implemented in the driver, all packets are
5182d30ea906Sjfb8856606  * are returned untouched.
5183d30ea906Sjfb8856606  *
5184d30ea906Sjfb8856606  * @param port_id
5185d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
5186d30ea906Sjfb8856606  *   The value must be a valid port id.
5187d30ea906Sjfb8856606  * @param queue_id
5188d30ea906Sjfb8856606  *   The index of the transmit queue through which output packets must be
5189d30ea906Sjfb8856606  *   sent.
5190d30ea906Sjfb8856606  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
5191d30ea906Sjfb8856606  *   to rte_eth_dev_configure().
5192d30ea906Sjfb8856606  * @param tx_pkts
5193d30ea906Sjfb8856606  *   The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
5194d30ea906Sjfb8856606  *   which contain the output packets.
5195d30ea906Sjfb8856606  * @param nb_pkts
5196d30ea906Sjfb8856606  *   The maximum number of packets to process.
5197d30ea906Sjfb8856606  * @return
5198d30ea906Sjfb8856606  *   The number of packets correct and ready to be sent. The return value can be
5199d30ea906Sjfb8856606  *   less than the value of the *tx_pkts* parameter when some packet doesn't
5200d30ea906Sjfb8856606  *   meet devices requirements with rte_errno set appropriately:
52014b05018fSfengbojiang  *   - EINVAL: offload flags are not correctly set
52024b05018fSfengbojiang  *   - ENOTSUP: the offload feature is not supported by the hardware
5203*2d9fd380Sjfb8856606  *   - ENODEV: if *port_id* is invalid (with debug enabled only)
5204d30ea906Sjfb8856606  *
5205d30ea906Sjfb8856606  */
5206d30ea906Sjfb8856606 
5207d30ea906Sjfb8856606 #ifndef RTE_ETHDEV_TX_PREPARE_NOOP
5208d30ea906Sjfb8856606 
5209d30ea906Sjfb8856606 static inline uint16_t
rte_eth_tx_prepare(uint16_t port_id,uint16_t queue_id,struct rte_mbuf ** tx_pkts,uint16_t nb_pkts)5210d30ea906Sjfb8856606 rte_eth_tx_prepare(uint16_t port_id, uint16_t queue_id,
5211d30ea906Sjfb8856606 		struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
5212d30ea906Sjfb8856606 {
5213d30ea906Sjfb8856606 	struct rte_eth_dev *dev;
5214d30ea906Sjfb8856606 
5215d30ea906Sjfb8856606 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
5216d30ea906Sjfb8856606 	if (!rte_eth_dev_is_valid_port(port_id)) {
5217d30ea906Sjfb8856606 		RTE_ETHDEV_LOG(ERR, "Invalid TX port_id=%u\n", port_id);
5218*2d9fd380Sjfb8856606 		rte_errno = ENODEV;
5219d30ea906Sjfb8856606 		return 0;
5220d30ea906Sjfb8856606 	}
5221d30ea906Sjfb8856606 #endif
5222d30ea906Sjfb8856606 
5223d30ea906Sjfb8856606 	dev = &rte_eth_devices[port_id];
5224d30ea906Sjfb8856606 
5225d30ea906Sjfb8856606 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
5226d30ea906Sjfb8856606 	if (queue_id >= dev->data->nb_tx_queues) {
5227d30ea906Sjfb8856606 		RTE_ETHDEV_LOG(ERR, "Invalid TX queue_id=%u\n", queue_id);
52281646932aSjfb8856606 		rte_errno = EINVAL;
5229d30ea906Sjfb8856606 		return 0;
5230d30ea906Sjfb8856606 	}
5231d30ea906Sjfb8856606 #endif
5232d30ea906Sjfb8856606 
5233d30ea906Sjfb8856606 	if (!dev->tx_pkt_prepare)
5234d30ea906Sjfb8856606 		return nb_pkts;
5235d30ea906Sjfb8856606 
5236d30ea906Sjfb8856606 	return (*dev->tx_pkt_prepare)(dev->data->tx_queues[queue_id],
5237d30ea906Sjfb8856606 			tx_pkts, nb_pkts);
5238d30ea906Sjfb8856606 }
5239d30ea906Sjfb8856606 
5240d30ea906Sjfb8856606 #else
5241d30ea906Sjfb8856606 
5242d30ea906Sjfb8856606 /*
5243d30ea906Sjfb8856606  * Native NOOP operation for compilation targets which doesn't require any
5244d30ea906Sjfb8856606  * preparations steps, and functional NOOP may introduce unnecessary performance
5245d30ea906Sjfb8856606  * drop.
5246d30ea906Sjfb8856606  *
5247d30ea906Sjfb8856606  * Generally this is not a good idea to turn it on globally and didn't should
5248d30ea906Sjfb8856606  * be used if behavior of tx_preparation can change.
5249d30ea906Sjfb8856606  */
5250d30ea906Sjfb8856606 
5251d30ea906Sjfb8856606 static inline uint16_t
rte_eth_tx_prepare(__rte_unused uint16_t port_id,__rte_unused uint16_t queue_id,__rte_unused struct rte_mbuf ** tx_pkts,uint16_t nb_pkts)5252d30ea906Sjfb8856606 rte_eth_tx_prepare(__rte_unused uint16_t port_id,
5253d30ea906Sjfb8856606 		__rte_unused uint16_t queue_id,
5254d30ea906Sjfb8856606 		__rte_unused struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
5255d30ea906Sjfb8856606 {
5256d30ea906Sjfb8856606 	return nb_pkts;
5257d30ea906Sjfb8856606 }
5258d30ea906Sjfb8856606 
5259d30ea906Sjfb8856606 #endif
5260d30ea906Sjfb8856606 
5261d30ea906Sjfb8856606 /**
5262d30ea906Sjfb8856606  * Send any packets queued up for transmission on a port and HW queue
5263d30ea906Sjfb8856606  *
5264d30ea906Sjfb8856606  * This causes an explicit flush of packets previously buffered via the
5265d30ea906Sjfb8856606  * rte_eth_tx_buffer() function. It returns the number of packets successfully
5266d30ea906Sjfb8856606  * sent to the NIC, and calls the error callback for any unsent packets. Unless
5267d30ea906Sjfb8856606  * explicitly set up otherwise, the default callback simply frees the unsent
5268d30ea906Sjfb8856606  * packets back to the owning mempool.
5269d30ea906Sjfb8856606  *
5270d30ea906Sjfb8856606  * @param port_id
5271d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
5272d30ea906Sjfb8856606  * @param queue_id
5273d30ea906Sjfb8856606  *   The index of the transmit queue through which output packets must be
5274d30ea906Sjfb8856606  *   sent.
5275d30ea906Sjfb8856606  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
5276d30ea906Sjfb8856606  *   to rte_eth_dev_configure().
5277d30ea906Sjfb8856606  * @param buffer
5278d30ea906Sjfb8856606  *   Buffer of packets to be transmit.
5279d30ea906Sjfb8856606  * @return
5280d30ea906Sjfb8856606  *   The number of packets successfully sent to the Ethernet device. The error
5281d30ea906Sjfb8856606  *   callback is called for any packets which could not be sent.
5282d30ea906Sjfb8856606  */
5283d30ea906Sjfb8856606 static inline uint16_t
rte_eth_tx_buffer_flush(uint16_t port_id,uint16_t queue_id,struct rte_eth_dev_tx_buffer * buffer)5284d30ea906Sjfb8856606 rte_eth_tx_buffer_flush(uint16_t port_id, uint16_t queue_id,
5285d30ea906Sjfb8856606 		struct rte_eth_dev_tx_buffer *buffer)
5286d30ea906Sjfb8856606 {
5287d30ea906Sjfb8856606 	uint16_t sent;
5288d30ea906Sjfb8856606 	uint16_t to_send = buffer->length;
5289d30ea906Sjfb8856606 
5290d30ea906Sjfb8856606 	if (to_send == 0)
5291d30ea906Sjfb8856606 		return 0;
5292d30ea906Sjfb8856606 
5293d30ea906Sjfb8856606 	sent = rte_eth_tx_burst(port_id, queue_id, buffer->pkts, to_send);
5294d30ea906Sjfb8856606 
5295d30ea906Sjfb8856606 	buffer->length = 0;
5296d30ea906Sjfb8856606 
5297d30ea906Sjfb8856606 	/* All packets sent, or to be dealt with by callback below */
5298d30ea906Sjfb8856606 	if (unlikely(sent != to_send))
5299d30ea906Sjfb8856606 		buffer->error_callback(&buffer->pkts[sent],
5300d30ea906Sjfb8856606 				       (uint16_t)(to_send - sent),
5301d30ea906Sjfb8856606 				       buffer->error_userdata);
5302d30ea906Sjfb8856606 
5303d30ea906Sjfb8856606 	return sent;
5304d30ea906Sjfb8856606 }
5305d30ea906Sjfb8856606 
5306d30ea906Sjfb8856606 /**
5307d30ea906Sjfb8856606  * Buffer a single packet for future transmission on a port and queue
5308d30ea906Sjfb8856606  *
5309d30ea906Sjfb8856606  * This function takes a single mbuf/packet and buffers it for later
5310d30ea906Sjfb8856606  * transmission on the particular port and queue specified. Once the buffer is
5311d30ea906Sjfb8856606  * full of packets, an attempt will be made to transmit all the buffered
5312d30ea906Sjfb8856606  * packets. In case of error, where not all packets can be transmitted, a
5313d30ea906Sjfb8856606  * callback is called with the unsent packets as a parameter. If no callback
5314d30ea906Sjfb8856606  * is explicitly set up, the unsent packets are just freed back to the owning
5315d30ea906Sjfb8856606  * mempool. The function returns the number of packets actually sent i.e.
5316d30ea906Sjfb8856606  * 0 if no buffer flush occurred, otherwise the number of packets successfully
5317d30ea906Sjfb8856606  * flushed
5318d30ea906Sjfb8856606  *
5319d30ea906Sjfb8856606  * @param port_id
5320d30ea906Sjfb8856606  *   The port identifier of the Ethernet device.
5321d30ea906Sjfb8856606  * @param queue_id
5322d30ea906Sjfb8856606  *   The index of the transmit queue through which output packets must be
5323d30ea906Sjfb8856606  *   sent.
5324d30ea906Sjfb8856606  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
5325d30ea906Sjfb8856606  *   to rte_eth_dev_configure().
5326d30ea906Sjfb8856606  * @param buffer
5327d30ea906Sjfb8856606  *   Buffer used to collect packets to be sent.
5328d30ea906Sjfb8856606  * @param tx_pkt
5329d30ea906Sjfb8856606  *   Pointer to the packet mbuf to be sent.
5330d30ea906Sjfb8856606  * @return
5331d30ea906Sjfb8856606  *   0 = packet has been buffered for later transmission
5332d30ea906Sjfb8856606  *   N > 0 = packet has been buffered, and the buffer was subsequently flushed,
5333d30ea906Sjfb8856606  *     causing N packets to be sent, and the error callback to be called for
5334d30ea906Sjfb8856606  *     the rest.
5335d30ea906Sjfb8856606  */
5336d30ea906Sjfb8856606 static __rte_always_inline uint16_t
rte_eth_tx_buffer(uint16_t port_id,uint16_t queue_id,struct rte_eth_dev_tx_buffer * buffer,struct rte_mbuf * tx_pkt)5337d30ea906Sjfb8856606 rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id,
5338d30ea906Sjfb8856606 		struct rte_eth_dev_tx_buffer *buffer, struct rte_mbuf *tx_pkt)
5339d30ea906Sjfb8856606 {
5340d30ea906Sjfb8856606 	buffer->pkts[buffer->length++] = tx_pkt;
5341d30ea906Sjfb8856606 	if (buffer->length < buffer->size)
5342d30ea906Sjfb8856606 		return 0;
5343d30ea906Sjfb8856606 
5344d30ea906Sjfb8856606 	return rte_eth_tx_buffer_flush(port_id, queue_id, buffer);
5345d30ea906Sjfb8856606 }
5346d30ea906Sjfb8856606 
5347d30ea906Sjfb8856606 #ifdef __cplusplus
5348d30ea906Sjfb8856606 }
5349d30ea906Sjfb8856606 #endif
5350d30ea906Sjfb8856606 
5351d30ea906Sjfb8856606 #endif /* _RTE_ETHDEV_H_ */
5352