xref: /dpdk/lib/ethdev/rte_ethdev.h (revision 1fbb3977cb4cc95a88a383825b188398659883ea)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2017 Intel Corporation
3  */
4 
5 #ifndef _RTE_ETHDEV_H_
6 #define _RTE_ETHDEV_H_
7 
8 /**
9  * @file
10  *
11  * RTE Ethernet Device API
12  *
13  * The Ethernet Device API is composed of two parts:
14  *
15  * - The application-oriented Ethernet API that includes functions to setup
16  *   an Ethernet device (configure it, setup its Rx and Tx queues and start it),
17  *   to get its MAC address, the speed and the status of its physical link,
18  *   to receive and to transmit packets, and so on.
19  *
20  * - The driver-oriented Ethernet API that exports functions allowing
21  *   an Ethernet Poll Mode Driver (PMD) to allocate an Ethernet device instance,
22  *   create memzone for HW rings and process registered callbacks, and so on.
23  *   PMDs should include ethdev_driver.h instead of this header.
24  *
25  * By default, all the functions of the Ethernet Device API exported by a PMD
26  * are lock-free functions which assume to not be invoked in parallel on
27  * different logical cores to work on the same target object.  For instance,
28  * the receive function of a PMD cannot be invoked in parallel on two logical
29  * cores to poll the same Rx queue [of the same port]. Of course, this function
30  * can be invoked in parallel by different logical cores on different Rx queues.
31  * It is the responsibility of the upper level application to enforce this rule.
32  *
33  * If needed, parallel accesses by multiple logical cores to shared queues
34  * shall be explicitly protected by dedicated inline lock-aware functions
35  * built on top of their corresponding lock-free functions of the PMD API.
36  *
37  * In all functions of the Ethernet API, the Ethernet device is
38  * designated by an integer >= 0 named the device port identifier.
39  *
40  * At the Ethernet driver level, Ethernet devices are represented by a generic
41  * data structure of type *rte_eth_dev*.
42  *
43  * Ethernet devices are dynamically registered during the PCI probing phase
44  * performed at EAL initialization time.
45  * When an Ethernet device is being probed, an *rte_eth_dev* structure and
46  * a new port identifier are allocated for that device. Then, the eth_dev_init()
47  * function supplied by the Ethernet driver matching the probed PCI
48  * device is invoked to properly initialize the device.
49  *
50  * The role of the device init function consists of resetting the hardware,
51  * checking access to Non-volatile Memory (NVM), reading the MAC address
52  * from NVM etc.
53  *
54  * If the device init operation is successful, the correspondence between
55  * the port identifier assigned to the new device and its associated
56  * *rte_eth_dev* structure is effectively registered.
57  * Otherwise, both the *rte_eth_dev* structure and the port identifier are
58  * freed.
59  *
60  * The functions exported by the application Ethernet API to setup a device
61  * designated by its port identifier must be invoked in the following order:
62  *     - rte_eth_dev_configure()
63  *     - rte_eth_tx_queue_setup()
64  *     - rte_eth_rx_queue_setup()
65  *     - rte_eth_dev_start()
66  *
67  * Then, the network application can invoke, in any order, the functions
68  * exported by the Ethernet API to get the MAC address of a given device, to
69  * get the speed and the status of a device physical link, to receive/transmit
70  * [burst of] packets, and so on.
71  *
72  * If the application wants to change the configuration (i.e. call
73  * rte_eth_dev_configure(), rte_eth_tx_queue_setup(), or
74  * rte_eth_rx_queue_setup()), it must call rte_eth_dev_stop() first to stop the
75  * device and then do the reconfiguration before calling rte_eth_dev_start()
76  * again. The transmit and receive functions should not be invoked when the
77  * device or the queue is stopped.
78  *
79  * Please note that some configuration is not stored between calls to
80  * rte_eth_dev_stop()/rte_eth_dev_start(). The following configuration will
81  * be retained:
82  *
83  *     - MTU
84  *     - flow control settings
85  *     - receive mode configuration (promiscuous mode, all-multicast mode,
86  *       hardware checksum mode, RSS/VMDq settings etc.)
87  *     - VLAN filtering configuration
88  *     - default MAC address
89  *     - MAC addresses supplied to MAC address array
90  *     - flow director filtering mode (but not filtering rules)
91  *     - NIC queue statistics mappings
92  *
93  * The following configuration may be retained or not
94  * depending on the device capabilities:
95  *
96  *     - flow rules
97  *     - flow-related shared objects, e.g. indirect actions
98  *
99  * Any other configuration will not be stored and will need to be re-entered
100  * before a call to rte_eth_dev_start().
101  *
102  * Finally, a network application can close an Ethernet device by invoking the
103  * rte_eth_dev_close() function.
104  *
105  * Each function of the application Ethernet API invokes a specific function
106  * of the PMD that controls the target device designated by its port
107  * identifier.
108  * For this purpose, all device-specific functions of an Ethernet driver are
109  * supplied through a set of pointers contained in a generic structure of type
110  * *eth_dev_ops*.
111  * The address of the *eth_dev_ops* structure is stored in the *rte_eth_dev*
112  * structure by the device init function of the Ethernet driver, which is
113  * invoked during the PCI probing phase, as explained earlier.
114  *
115  * In other words, each function of the Ethernet API simply retrieves the
116  * *rte_eth_dev* structure associated with the device port identifier and
117  * performs an indirect invocation of the corresponding driver function
118  * supplied in the *eth_dev_ops* structure of the *rte_eth_dev* structure.
119  *
120  * For performance reasons, the address of the burst-oriented Rx and Tx
121  * functions of the Ethernet driver are not contained in the *eth_dev_ops*
122  * structure. Instead, they are directly stored at the beginning of the
123  * *rte_eth_dev* structure to avoid an extra indirect memory access during
124  * their invocation.
125  *
126  * RTE Ethernet device drivers do not use interrupts for transmitting or
127  * receiving. Instead, Ethernet drivers export Poll-Mode receive and transmit
128  * functions to applications.
129  * Both receive and transmit functions are packet-burst oriented to minimize
130  * their cost per packet through the following optimizations:
131  *
132  * - Sharing among multiple packets the incompressible cost of the
133  *   invocation of receive/transmit functions.
134  *
135  * - Enabling receive/transmit functions to take advantage of burst-oriented
136  *   hardware features (L1 cache, prefetch instructions, NIC head/tail
137  *   registers) to minimize the number of CPU cycles per packet, for instance,
138  *   by avoiding useless read memory accesses to ring descriptors, or by
139  *   systematically using arrays of pointers that exactly fit L1 cache line
140  *   boundaries and sizes.
141  *
142  * The burst-oriented receive function does not provide any error notification,
143  * to avoid the corresponding overhead. As a hint, the upper-level application
144  * might check the status of the device link once being systematically returned
145  * a 0 value by the receive function of the driver for a given number of tries.
146  */
147 
148 #ifdef __cplusplus
149 extern "C" {
150 #endif
151 
152 #include <stdint.h>
153 
154 /* Use this macro to check if LRO API is supported */
155 #define RTE_ETHDEV_HAS_LRO_SUPPORT
156 
157 /* Alias RTE_LIBRTE_ETHDEV_DEBUG for backward compatibility. */
158 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
159 #define RTE_ETHDEV_DEBUG_RX
160 #define RTE_ETHDEV_DEBUG_TX
161 #endif
162 
163 #include <rte_cman.h>
164 #include <rte_compat.h>
165 #include <rte_log.h>
166 #include <rte_interrupts.h>
167 #include <rte_dev.h>
168 #include <rte_devargs.h>
169 #include <rte_bitops.h>
170 #include <rte_errno.h>
171 #include <rte_common.h>
172 #include <rte_config.h>
173 #include <rte_power_intrinsics.h>
174 
175 #include "rte_ethdev_trace_fp.h"
176 #include "rte_dev_info.h"
177 
178 extern int rte_eth_dev_logtype;
179 #define RTE_LOGTYPE_ETHDEV rte_eth_dev_logtype
180 
181 #define RTE_ETHDEV_LOG_LINE(level, ...) \
182 	RTE_LOG_LINE(level, ETHDEV, "" __VA_ARGS__)
183 
184 struct rte_mbuf;
185 
186 /**
187  * Initializes a device iterator.
188  *
189  * This iterator allows accessing a list of devices matching some devargs.
190  *
191  * @param iter
192  *   Device iterator handle initialized by the function.
193  *   The fields bus_str and cls_str might be dynamically allocated,
194  *   and could be freed by calling rte_eth_iterator_cleanup().
195  *
196  * @param devargs
197  *   Device description string.
198  *
199  * @return
200  *   0 on successful initialization, negative otherwise.
201  */
202 int rte_eth_iterator_init(struct rte_dev_iterator *iter, const char *devargs);
203 
204 /**
205  * Iterates on devices with devargs filter.
206  * The ownership is not checked.
207  *
208  * The next port ID is returned, and the iterator is updated.
209  *
210  * @param iter
211  *   Device iterator handle initialized by rte_eth_iterator_init().
212  *   Some fields bus_str and cls_str might be freed when no more port is found,
213  *   by calling rte_eth_iterator_cleanup().
214  *
215  * @return
216  *   A port ID if found, RTE_MAX_ETHPORTS otherwise.
217  */
218 uint16_t rte_eth_iterator_next(struct rte_dev_iterator *iter);
219 
220 /**
221  * Free some allocated fields of the iterator.
222  *
223  * This function is automatically called by rte_eth_iterator_next()
224  * on the last iteration (i.e. when no more matching port is found).
225  *
226  * It is safe to call this function twice; it will do nothing more.
227  *
228  * @param iter
229  *   Device iterator handle initialized by rte_eth_iterator_init().
230  *   The fields bus_str and cls_str are freed if needed.
231  */
232 void rte_eth_iterator_cleanup(struct rte_dev_iterator *iter);
233 
234 /**
235  * Macro to iterate over all ethdev ports matching some devargs.
236  *
237  * If a break is done before the end of the loop,
238  * the function rte_eth_iterator_cleanup() must be called.
239  *
240  * @param id
241  *   Iterated port ID of type uint16_t.
242  * @param devargs
243  *   Device parameters input as string of type char*.
244  * @param iter
245  *   Iterator handle of type struct rte_dev_iterator, used internally.
246  */
247 #define RTE_ETH_FOREACH_MATCHING_DEV(id, devargs, iter) \
248 	for (rte_eth_iterator_init(iter, devargs), \
249 	     id = rte_eth_iterator_next(iter); \
250 	     id != RTE_MAX_ETHPORTS; \
251 	     id = rte_eth_iterator_next(iter))
252 
253 /**
254  * A structure used to retrieve statistics for an Ethernet port.
255  * Not all statistics fields in struct rte_eth_stats are supported
256  * by any type of network interface card (NIC). If any statistics
257  * field is not supported, its value is 0.
258  * All byte-related statistics do not include Ethernet FCS regardless
259  * of whether these bytes have been delivered to the application
260  * (see RTE_ETH_RX_OFFLOAD_KEEP_CRC).
261  */
262 struct rte_eth_stats {
263 	uint64_t ipackets;  /**< Total number of successfully received packets. */
264 	uint64_t opackets;  /**< Total number of successfully transmitted packets.*/
265 	uint64_t ibytes;    /**< Total number of successfully received bytes. */
266 	uint64_t obytes;    /**< Total number of successfully transmitted bytes. */
267 	/**
268 	 * Total of Rx packets dropped by the HW,
269 	 * because there are no available buffer (i.e. Rx queues are full).
270 	 */
271 	uint64_t imissed;
272 	uint64_t ierrors;   /**< Total number of erroneous received packets. */
273 	uint64_t oerrors;   /**< Total number of failed transmitted packets. */
274 	uint64_t rx_nombuf; /**< Total number of Rx mbuf allocation failures. */
275 	/* Queue stats are limited to max 256 queues */
276 	/** Total number of queue Rx packets. */
277 	uint64_t q_ipackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
278 	/** Total number of queue Tx packets. */
279 	uint64_t q_opackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
280 	/** Total number of successfully received queue bytes. */
281 	uint64_t q_ibytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
282 	/** Total number of successfully transmitted queue bytes. */
283 	uint64_t q_obytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
284 	/** Total number of queue packets received that are dropped. */
285 	uint64_t q_errors[RTE_ETHDEV_QUEUE_STAT_CNTRS];
286 };
287 
288 /**@{@name Link speed capabilities
289  * Device supported speeds bitmap flags
290  */
291 #define RTE_ETH_LINK_SPEED_AUTONEG 0             /**< Autonegotiate (all speeds) */
292 #define RTE_ETH_LINK_SPEED_FIXED   RTE_BIT32(0)  /**< Disable autoneg (fixed speed) */
293 #define RTE_ETH_LINK_SPEED_10M_HD  RTE_BIT32(1)  /**<  10 Mbps half-duplex */
294 #define RTE_ETH_LINK_SPEED_10M     RTE_BIT32(2)  /**<  10 Mbps full-duplex */
295 #define RTE_ETH_LINK_SPEED_100M_HD RTE_BIT32(3)  /**< 100 Mbps half-duplex */
296 #define RTE_ETH_LINK_SPEED_100M    RTE_BIT32(4)  /**< 100 Mbps full-duplex */
297 #define RTE_ETH_LINK_SPEED_1G      RTE_BIT32(5)  /**<   1 Gbps */
298 #define RTE_ETH_LINK_SPEED_2_5G    RTE_BIT32(6)  /**< 2.5 Gbps */
299 #define RTE_ETH_LINK_SPEED_5G      RTE_BIT32(7)  /**<   5 Gbps */
300 #define RTE_ETH_LINK_SPEED_10G     RTE_BIT32(8)  /**<  10 Gbps */
301 #define RTE_ETH_LINK_SPEED_20G     RTE_BIT32(9)  /**<  20 Gbps */
302 #define RTE_ETH_LINK_SPEED_25G     RTE_BIT32(10) /**<  25 Gbps */
303 #define RTE_ETH_LINK_SPEED_40G     RTE_BIT32(11) /**<  40 Gbps */
304 #define RTE_ETH_LINK_SPEED_50G     RTE_BIT32(12) /**<  50 Gbps */
305 #define RTE_ETH_LINK_SPEED_56G     RTE_BIT32(13) /**<  56 Gbps */
306 #define RTE_ETH_LINK_SPEED_100G    RTE_BIT32(14) /**< 100 Gbps */
307 #define RTE_ETH_LINK_SPEED_200G    RTE_BIT32(15) /**< 200 Gbps */
308 #define RTE_ETH_LINK_SPEED_400G    RTE_BIT32(16) /**< 400 Gbps */
309 /**@}*/
310 
311 /**@{@name Link speed
312  * Ethernet numeric link speeds in Mbps
313  */
314 #define RTE_ETH_SPEED_NUM_NONE         0 /**< Not defined */
315 #define RTE_ETH_SPEED_NUM_10M         10 /**<  10 Mbps */
316 #define RTE_ETH_SPEED_NUM_100M       100 /**< 100 Mbps */
317 #define RTE_ETH_SPEED_NUM_1G        1000 /**<   1 Gbps */
318 #define RTE_ETH_SPEED_NUM_2_5G      2500 /**< 2.5 Gbps */
319 #define RTE_ETH_SPEED_NUM_5G        5000 /**<   5 Gbps */
320 #define RTE_ETH_SPEED_NUM_10G      10000 /**<  10 Gbps */
321 #define RTE_ETH_SPEED_NUM_20G      20000 /**<  20 Gbps */
322 #define RTE_ETH_SPEED_NUM_25G      25000 /**<  25 Gbps */
323 #define RTE_ETH_SPEED_NUM_40G      40000 /**<  40 Gbps */
324 #define RTE_ETH_SPEED_NUM_50G      50000 /**<  50 Gbps */
325 #define RTE_ETH_SPEED_NUM_56G      56000 /**<  56 Gbps */
326 #define RTE_ETH_SPEED_NUM_100G    100000 /**< 100 Gbps */
327 #define RTE_ETH_SPEED_NUM_200G    200000 /**< 200 Gbps */
328 #define RTE_ETH_SPEED_NUM_400G    400000 /**< 400 Gbps */
329 #define RTE_ETH_SPEED_NUM_UNKNOWN UINT32_MAX /**< Unknown */
330 /**@}*/
331 
332 /**
333  * A structure used to retrieve link-level information of an Ethernet port.
334  */
335 __extension__
336 struct __rte_aligned(8) rte_eth_link { /**< aligned for atomic64 read/write */
337 	uint32_t link_speed;        /**< RTE_ETH_SPEED_NUM_ */
338 	uint16_t link_duplex  : 1;  /**< RTE_ETH_LINK_[HALF/FULL]_DUPLEX */
339 	uint16_t link_autoneg : 1;  /**< RTE_ETH_LINK_[AUTONEG/FIXED] */
340 	uint16_t link_status  : 1;  /**< RTE_ETH_LINK_[DOWN/UP] */
341 };
342 
343 /**@{@name Link negotiation
344  * Constants used in link management.
345  */
346 #define RTE_ETH_LINK_HALF_DUPLEX 0 /**< Half-duplex connection (see link_duplex). */
347 #define RTE_ETH_LINK_FULL_DUPLEX 1 /**< Full-duplex connection (see link_duplex). */
348 #define RTE_ETH_LINK_DOWN        0 /**< Link is down (see link_status). */
349 #define RTE_ETH_LINK_UP          1 /**< Link is up (see link_status). */
350 #define RTE_ETH_LINK_FIXED       0 /**< No autonegotiation (see link_autoneg). */
351 #define RTE_ETH_LINK_AUTONEG     1 /**< Autonegotiated (see link_autoneg). */
352 #define RTE_ETH_LINK_MAX_STR_LEN 40 /**< Max length of default link string. */
353 /**@}*/
354 
355 /**
356  * A structure used to configure the ring threshold registers of an Rx/Tx
357  * queue for an Ethernet port.
358  */
359 struct rte_eth_thresh {
360 	uint8_t pthresh; /**< Ring prefetch threshold. */
361 	uint8_t hthresh; /**< Ring host threshold. */
362 	uint8_t wthresh; /**< Ring writeback threshold. */
363 };
364 
365 /**@{@name Multi-queue mode
366  * @see rte_eth_conf.rxmode.mq_mode.
367  */
368 #define RTE_ETH_MQ_RX_RSS_FLAG  RTE_BIT32(0) /**< Enable RSS. @see rte_eth_rss_conf */
369 #define RTE_ETH_MQ_RX_DCB_FLAG  RTE_BIT32(1) /**< Enable DCB. */
370 #define RTE_ETH_MQ_RX_VMDQ_FLAG RTE_BIT32(2) /**< Enable VMDq. */
371 /**@}*/
372 
373 /**
374  *  A set of values to identify what method is to be used to route
375  *  packets to multiple queues.
376  */
377 enum rte_eth_rx_mq_mode {
378 	/** None of DCB, RSS or VMDq mode */
379 	RTE_ETH_MQ_RX_NONE = 0,
380 
381 	/** For Rx side, only RSS is on */
382 	RTE_ETH_MQ_RX_RSS = RTE_ETH_MQ_RX_RSS_FLAG,
383 	/** For Rx side,only DCB is on. */
384 	RTE_ETH_MQ_RX_DCB = RTE_ETH_MQ_RX_DCB_FLAG,
385 	/** Both DCB and RSS enable */
386 	RTE_ETH_MQ_RX_DCB_RSS = RTE_ETH_MQ_RX_RSS_FLAG | RTE_ETH_MQ_RX_DCB_FLAG,
387 
388 	/** Only VMDq, no RSS nor DCB */
389 	RTE_ETH_MQ_RX_VMDQ_ONLY = RTE_ETH_MQ_RX_VMDQ_FLAG,
390 	/** RSS mode with VMDq */
391 	RTE_ETH_MQ_RX_VMDQ_RSS = RTE_ETH_MQ_RX_RSS_FLAG | RTE_ETH_MQ_RX_VMDQ_FLAG,
392 	/** Use VMDq+DCB to route traffic to queues */
393 	RTE_ETH_MQ_RX_VMDQ_DCB = RTE_ETH_MQ_RX_VMDQ_FLAG | RTE_ETH_MQ_RX_DCB_FLAG,
394 	/** Enable both VMDq and DCB in VMDq */
395 	RTE_ETH_MQ_RX_VMDQ_DCB_RSS = RTE_ETH_MQ_RX_RSS_FLAG | RTE_ETH_MQ_RX_DCB_FLAG |
396 				 RTE_ETH_MQ_RX_VMDQ_FLAG,
397 };
398 
399 /**
400  * A set of values to identify what method is to be used to transmit
401  * packets using multi-TCs.
402  */
403 enum rte_eth_tx_mq_mode {
404 	RTE_ETH_MQ_TX_NONE    = 0,  /**< It is in neither DCB nor VT mode. */
405 	RTE_ETH_MQ_TX_DCB,          /**< For Tx side,only DCB is on. */
406 	RTE_ETH_MQ_TX_VMDQ_DCB,     /**< For Tx side,both DCB and VT is on. */
407 	RTE_ETH_MQ_TX_VMDQ_ONLY,    /**< Only VT on, no DCB */
408 };
409 
410 /**
411  * A structure used to configure the Rx features of an Ethernet port.
412  */
413 struct rte_eth_rxmode {
414 	/** The multi-queue packet distribution mode to be used, e.g. RSS. */
415 	enum rte_eth_rx_mq_mode mq_mode;
416 	uint32_t mtu;  /**< Requested MTU. */
417 	/** Maximum allowed size of LRO aggregated packet. */
418 	uint32_t max_lro_pkt_size;
419 	/**
420 	 * Per-port Rx offloads to be set using RTE_ETH_RX_OFFLOAD_* flags.
421 	 * Only offloads set on rx_offload_capa field on rte_eth_dev_info
422 	 * structure are allowed to be set.
423 	 */
424 	uint64_t offloads;
425 
426 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
427 	void *reserved_ptrs[2];   /**< Reserved for future fields */
428 };
429 
430 /**
431  * VLAN types to indicate if it is for single VLAN, inner VLAN or outer VLAN.
432  * Note that single VLAN is treated the same as inner VLAN.
433  */
434 enum rte_vlan_type {
435 	RTE_ETH_VLAN_TYPE_UNKNOWN = 0,
436 	RTE_ETH_VLAN_TYPE_INNER, /**< Inner VLAN. */
437 	RTE_ETH_VLAN_TYPE_OUTER, /**< Single VLAN, or outer VLAN. */
438 	RTE_ETH_VLAN_TYPE_MAX,
439 };
440 
441 /**
442  * A structure used to describe a VLAN filter.
443  * If the bit corresponding to a VID is set, such VID is on.
444  */
445 struct rte_vlan_filter_conf {
446 	uint64_t ids[64];
447 };
448 
449 /**
450  * Hash function types.
451  */
452 enum rte_eth_hash_function {
453 	/** DEFAULT means driver decides which hash algorithm to pick. */
454 	RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
455 	RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
456 	RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
457 	/**
458 	 * Symmetric Toeplitz: src, dst will be replaced by
459 	 * xor(src, dst). For the case with src/dst only,
460 	 * src or dst address will xor with zero pair.
461 	 */
462 	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
463 	/**
464 	 * Symmetric Toeplitz: L3 and L4 fields are sorted prior to
465 	 * the hash function.
466 	 *  If src_ip > dst_ip, swap src_ip and dst_ip.
467 	 *  If src_port > dst_port, swap src_port and dst_port.
468 	 */
469 	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT,
470 	RTE_ETH_HASH_FUNCTION_MAX,
471 };
472 
473 #define RTE_ETH_HASH_ALGO_TO_CAPA(x) RTE_BIT32(x)
474 #define RTE_ETH_HASH_ALGO_CAPA_MASK(x) RTE_BIT32(RTE_ETH_HASH_FUNCTION_ ## x)
475 
476 /**
477  * A structure used to configure the Receive Side Scaling (RSS) feature
478  * of an Ethernet port.
479  */
480 struct rte_eth_rss_conf {
481 	/**
482 	 * In rte_eth_dev_rss_hash_conf_get(), the *rss_key_len* should be
483 	 * greater than or equal to the *hash_key_size* which get from
484 	 * rte_eth_dev_info_get() API. And the *rss_key* should contain at least
485 	 * *hash_key_size* bytes. If not meet these requirements, the query
486 	 * result is unreliable even if the operation returns success.
487 	 *
488 	 * In rte_eth_dev_rss_hash_update() or rte_eth_dev_configure(), if
489 	 * *rss_key* is not NULL, the *rss_key_len* indicates the length of the
490 	 * *rss_key* in bytes and it should be equal to *hash_key_size*.
491 	 * If *rss_key* is NULL, drivers are free to use a random or a default key.
492 	 */
493 	uint8_t *rss_key;
494 	uint8_t rss_key_len; /**< hash key length in bytes. */
495 	/**
496 	 * Indicates the type of packets or the specific part of packets to
497 	 * which RSS hashing is to be applied.
498 	 */
499 	uint64_t rss_hf;
500 	enum rte_eth_hash_function algorithm;	/**< Hash algorithm. */
501 };
502 
503 /*
504  * A packet can be identified by hardware as different flow types. Different
505  * NIC hardware may support different flow types.
506  * Basically, the NIC hardware identifies the flow type as deep protocol as
507  * possible, and exclusively. For example, if a packet is identified as
508  * 'RTE_ETH_FLOW_NONFRAG_IPV4_TCP', it will not be any of other flow types,
509  * though it is an actual IPV4 packet.
510  */
511 #define RTE_ETH_FLOW_UNKNOWN             0
512 #define RTE_ETH_FLOW_RAW                 1
513 #define RTE_ETH_FLOW_IPV4                2
514 #define RTE_ETH_FLOW_FRAG_IPV4           3
515 #define RTE_ETH_FLOW_NONFRAG_IPV4_TCP    4
516 #define RTE_ETH_FLOW_NONFRAG_IPV4_UDP    5
517 #define RTE_ETH_FLOW_NONFRAG_IPV4_SCTP   6
518 #define RTE_ETH_FLOW_NONFRAG_IPV4_OTHER  7
519 #define RTE_ETH_FLOW_IPV6                8
520 #define RTE_ETH_FLOW_FRAG_IPV6           9
521 #define RTE_ETH_FLOW_NONFRAG_IPV6_TCP   10
522 #define RTE_ETH_FLOW_NONFRAG_IPV6_UDP   11
523 #define RTE_ETH_FLOW_NONFRAG_IPV6_SCTP  12
524 #define RTE_ETH_FLOW_NONFRAG_IPV6_OTHER 13
525 #define RTE_ETH_FLOW_L2_PAYLOAD         14
526 #define RTE_ETH_FLOW_IPV6_EX            15
527 #define RTE_ETH_FLOW_IPV6_TCP_EX        16
528 #define RTE_ETH_FLOW_IPV6_UDP_EX        17
529 /** Consider device port number as a flow differentiator */
530 #define RTE_ETH_FLOW_PORT               18
531 #define RTE_ETH_FLOW_VXLAN              19 /**< VXLAN protocol based flow */
532 #define RTE_ETH_FLOW_GENEVE             20 /**< GENEVE protocol based flow */
533 #define RTE_ETH_FLOW_NVGRE              21 /**< NVGRE protocol based flow */
534 #define RTE_ETH_FLOW_VXLAN_GPE          22 /**< VXLAN-GPE protocol based flow */
535 #define RTE_ETH_FLOW_GTPU               23 /**< GTPU protocol based flow */
536 #define RTE_ETH_FLOW_MAX                24
537 
538 /*
539  * Below macros are defined for RSS offload types, they can be used to
540  * fill rte_eth_rss_conf.rss_hf or rte_flow_action_rss.types.
541  */
542 #define RTE_ETH_RSS_IPV4               RTE_BIT64(2)
543 #define RTE_ETH_RSS_FRAG_IPV4          RTE_BIT64(3)
544 #define RTE_ETH_RSS_NONFRAG_IPV4_TCP   RTE_BIT64(4)
545 #define RTE_ETH_RSS_NONFRAG_IPV4_UDP   RTE_BIT64(5)
546 #define RTE_ETH_RSS_NONFRAG_IPV4_SCTP  RTE_BIT64(6)
547 #define RTE_ETH_RSS_NONFRAG_IPV4_OTHER RTE_BIT64(7)
548 #define RTE_ETH_RSS_IPV6               RTE_BIT64(8)
549 #define RTE_ETH_RSS_FRAG_IPV6          RTE_BIT64(9)
550 #define RTE_ETH_RSS_NONFRAG_IPV6_TCP   RTE_BIT64(10)
551 #define RTE_ETH_RSS_NONFRAG_IPV6_UDP   RTE_BIT64(11)
552 #define RTE_ETH_RSS_NONFRAG_IPV6_SCTP  RTE_BIT64(12)
553 #define RTE_ETH_RSS_NONFRAG_IPV6_OTHER RTE_BIT64(13)
554 #define RTE_ETH_RSS_L2_PAYLOAD         RTE_BIT64(14)
555 #define RTE_ETH_RSS_IPV6_EX            RTE_BIT64(15)
556 #define RTE_ETH_RSS_IPV6_TCP_EX        RTE_BIT64(16)
557 #define RTE_ETH_RSS_IPV6_UDP_EX        RTE_BIT64(17)
558 #define RTE_ETH_RSS_PORT               RTE_BIT64(18)
559 #define RTE_ETH_RSS_VXLAN              RTE_BIT64(19)
560 #define RTE_ETH_RSS_GENEVE             RTE_BIT64(20)
561 #define RTE_ETH_RSS_NVGRE              RTE_BIT64(21)
562 #define RTE_ETH_RSS_GTPU               RTE_BIT64(23)
563 #define RTE_ETH_RSS_ETH                RTE_BIT64(24)
564 #define RTE_ETH_RSS_S_VLAN             RTE_BIT64(25)
565 #define RTE_ETH_RSS_C_VLAN             RTE_BIT64(26)
566 #define RTE_ETH_RSS_ESP                RTE_BIT64(27)
567 #define RTE_ETH_RSS_AH                 RTE_BIT64(28)
568 #define RTE_ETH_RSS_L2TPV3             RTE_BIT64(29)
569 #define RTE_ETH_RSS_PFCP               RTE_BIT64(30)
570 #define RTE_ETH_RSS_PPPOE              RTE_BIT64(31)
571 #define RTE_ETH_RSS_ECPRI              RTE_BIT64(32)
572 #define RTE_ETH_RSS_MPLS               RTE_BIT64(33)
573 #define RTE_ETH_RSS_IPV4_CHKSUM        RTE_BIT64(34)
574 
575 /**
576  * The RTE_ETH_RSS_L4_CHKSUM works on checksum field of any L4 header.
577  * It is similar to RTE_ETH_RSS_PORT that they don't specify the specific type of
578  * L4 header. This macro is defined to replace some specific L4 (TCP/UDP/SCTP)
579  * checksum type for constructing the use of RSS offload bits.
580  *
581  * Due to above reason, some old APIs (and configuration) don't support
582  * RTE_ETH_RSS_L4_CHKSUM. The rte_flow RSS API supports it.
583  *
584  * For the case that checksum is not used in an UDP header,
585  * it takes the reserved value 0 as input for the hash function.
586  */
587 #define RTE_ETH_RSS_L4_CHKSUM          RTE_BIT64(35)
588 
589 #define RTE_ETH_RSS_L2TPV2             RTE_BIT64(36)
590 #define RTE_ETH_RSS_IPV6_FLOW_LABEL    RTE_BIT64(37)
591 
592 /*
593  * We use the following macros to combine with above RTE_ETH_RSS_* for
594  * more specific input set selection. These bits are defined starting
595  * from the high end of the 64 bits.
596  * Note: If we use above RTE_ETH_RSS_* without SRC/DST_ONLY, it represents
597  * both SRC and DST are taken into account. If SRC_ONLY and DST_ONLY of
598  * the same level are used simultaneously, it is the same case as none of
599  * them are added.
600  */
601 #define RTE_ETH_RSS_L3_SRC_ONLY        RTE_BIT64(63)
602 #define RTE_ETH_RSS_L3_DST_ONLY        RTE_BIT64(62)
603 #define RTE_ETH_RSS_L4_SRC_ONLY        RTE_BIT64(61)
604 #define RTE_ETH_RSS_L4_DST_ONLY        RTE_BIT64(60)
605 #define RTE_ETH_RSS_L2_SRC_ONLY        RTE_BIT64(59)
606 #define RTE_ETH_RSS_L2_DST_ONLY        RTE_BIT64(58)
607 
608 /*
609  * Only select IPV6 address prefix as RSS input set according to
610  * https://tools.ietf.org/html/rfc6052
611  * Must be combined with RTE_ETH_RSS_IPV6, RTE_ETH_RSS_NONFRAG_IPV6_UDP,
612  * RTE_ETH_RSS_NONFRAG_IPV6_TCP, RTE_ETH_RSS_NONFRAG_IPV6_SCTP.
613  */
614 #define RTE_ETH_RSS_L3_PRE32           RTE_BIT64(57)
615 #define RTE_ETH_RSS_L3_PRE40           RTE_BIT64(56)
616 #define RTE_ETH_RSS_L3_PRE48           RTE_BIT64(55)
617 #define RTE_ETH_RSS_L3_PRE56           RTE_BIT64(54)
618 #define RTE_ETH_RSS_L3_PRE64           RTE_BIT64(53)
619 #define RTE_ETH_RSS_L3_PRE96           RTE_BIT64(52)
620 
621 /*
622  * Use the following macros to combine with the above layers
623  * to choose inner and outer layers or both for RSS computation.
624  * Bits 50 and 51 are reserved for this.
625  */
626 
627 /**
628  * level 0, requests the default behavior.
629  * Depending on the packet type, it can mean outermost, innermost,
630  * anything in between or even no RSS.
631  * It basically stands for the innermost encapsulation level RSS
632  * can be performed on according to PMD and device capabilities.
633  */
634 #define RTE_ETH_RSS_LEVEL_PMD_DEFAULT  (UINT64_C(0) << 50)
635 
636 /**
637  * level 1, requests RSS to be performed on the outermost packet
638  * encapsulation level.
639  */
640 #define RTE_ETH_RSS_LEVEL_OUTERMOST    (UINT64_C(1) << 50)
641 
642 /**
643  * level 2, requests RSS to be performed on the specified inner packet
644  * encapsulation level, from outermost to innermost (lower to higher values).
645  */
646 #define RTE_ETH_RSS_LEVEL_INNERMOST    (UINT64_C(2) << 50)
647 #define RTE_ETH_RSS_LEVEL_MASK         (UINT64_C(3) << 50)
648 
649 #define RTE_ETH_RSS_LEVEL(rss_hf) ((rss_hf & RTE_ETH_RSS_LEVEL_MASK) >> 50)
650 
651 /**
652  * For input set change of hash filter, if SRC_ONLY and DST_ONLY of
653  * the same level are used simultaneously, it is the same case as
654  * none of them are added.
655  *
656  * @param rss_hf
657  *   RSS types with SRC/DST_ONLY.
658  * @return
659  *   RSS types.
660  */
661 static inline uint64_t
662 rte_eth_rss_hf_refine(uint64_t rss_hf)
663 {
664 	if ((rss_hf & RTE_ETH_RSS_L3_SRC_ONLY) && (rss_hf & RTE_ETH_RSS_L3_DST_ONLY))
665 		rss_hf &= ~(RTE_ETH_RSS_L3_SRC_ONLY | RTE_ETH_RSS_L3_DST_ONLY);
666 
667 	if ((rss_hf & RTE_ETH_RSS_L4_SRC_ONLY) && (rss_hf & RTE_ETH_RSS_L4_DST_ONLY))
668 		rss_hf &= ~(RTE_ETH_RSS_L4_SRC_ONLY | RTE_ETH_RSS_L4_DST_ONLY);
669 
670 	return rss_hf;
671 }
672 
673 #define RTE_ETH_RSS_IPV6_PRE32 ( \
674 		RTE_ETH_RSS_IPV6 | \
675 		RTE_ETH_RSS_L3_PRE32)
676 
677 #define RTE_ETH_RSS_IPV6_PRE40 ( \
678 		RTE_ETH_RSS_IPV6 | \
679 		RTE_ETH_RSS_L3_PRE40)
680 
681 #define RTE_ETH_RSS_IPV6_PRE48 ( \
682 		RTE_ETH_RSS_IPV6 | \
683 		RTE_ETH_RSS_L3_PRE48)
684 
685 #define RTE_ETH_RSS_IPV6_PRE56 ( \
686 		RTE_ETH_RSS_IPV6 | \
687 		RTE_ETH_RSS_L3_PRE56)
688 
689 #define RTE_ETH_RSS_IPV6_PRE64 ( \
690 		RTE_ETH_RSS_IPV6 | \
691 		RTE_ETH_RSS_L3_PRE64)
692 
693 #define RTE_ETH_RSS_IPV6_PRE96 ( \
694 		RTE_ETH_RSS_IPV6 | \
695 		RTE_ETH_RSS_L3_PRE96)
696 
697 #define RTE_ETH_RSS_IPV6_PRE32_UDP ( \
698 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
699 		RTE_ETH_RSS_L3_PRE32)
700 
701 #define RTE_ETH_RSS_IPV6_PRE40_UDP ( \
702 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
703 		RTE_ETH_RSS_L3_PRE40)
704 
705 #define RTE_ETH_RSS_IPV6_PRE48_UDP ( \
706 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
707 		RTE_ETH_RSS_L3_PRE48)
708 
709 #define RTE_ETH_RSS_IPV6_PRE56_UDP ( \
710 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
711 		RTE_ETH_RSS_L3_PRE56)
712 
713 #define RTE_ETH_RSS_IPV6_PRE64_UDP ( \
714 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
715 		RTE_ETH_RSS_L3_PRE64)
716 
717 #define RTE_ETH_RSS_IPV6_PRE96_UDP ( \
718 		RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
719 		RTE_ETH_RSS_L3_PRE96)
720 
721 #define RTE_ETH_RSS_IPV6_PRE32_TCP ( \
722 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
723 		RTE_ETH_RSS_L3_PRE32)
724 
725 #define RTE_ETH_RSS_IPV6_PRE40_TCP ( \
726 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
727 		RTE_ETH_RSS_L3_PRE40)
728 
729 #define RTE_ETH_RSS_IPV6_PRE48_TCP ( \
730 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
731 		RTE_ETH_RSS_L3_PRE48)
732 
733 #define RTE_ETH_RSS_IPV6_PRE56_TCP ( \
734 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
735 		RTE_ETH_RSS_L3_PRE56)
736 
737 #define RTE_ETH_RSS_IPV6_PRE64_TCP ( \
738 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
739 		RTE_ETH_RSS_L3_PRE64)
740 
741 #define RTE_ETH_RSS_IPV6_PRE96_TCP ( \
742 		RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
743 		RTE_ETH_RSS_L3_PRE96)
744 
745 #define RTE_ETH_RSS_IPV6_PRE32_SCTP ( \
746 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
747 		RTE_ETH_RSS_L3_PRE32)
748 
749 #define RTE_ETH_RSS_IPV6_PRE40_SCTP ( \
750 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
751 		RTE_ETH_RSS_L3_PRE40)
752 
753 #define RTE_ETH_RSS_IPV6_PRE48_SCTP ( \
754 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
755 		RTE_ETH_RSS_L3_PRE48)
756 
757 #define RTE_ETH_RSS_IPV6_PRE56_SCTP ( \
758 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
759 		RTE_ETH_RSS_L3_PRE56)
760 
761 #define RTE_ETH_RSS_IPV6_PRE64_SCTP ( \
762 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
763 		RTE_ETH_RSS_L3_PRE64)
764 
765 #define RTE_ETH_RSS_IPV6_PRE96_SCTP ( \
766 		RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
767 		RTE_ETH_RSS_L3_PRE96)
768 
769 #define RTE_ETH_RSS_IP ( \
770 	RTE_ETH_RSS_IPV4 | \
771 	RTE_ETH_RSS_FRAG_IPV4 | \
772 	RTE_ETH_RSS_NONFRAG_IPV4_OTHER | \
773 	RTE_ETH_RSS_IPV6 | \
774 	RTE_ETH_RSS_FRAG_IPV6 | \
775 	RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \
776 	RTE_ETH_RSS_IPV6_EX)
777 
778 #define RTE_ETH_RSS_UDP ( \
779 	RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
780 	RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
781 	RTE_ETH_RSS_IPV6_UDP_EX)
782 
783 #define RTE_ETH_RSS_TCP ( \
784 	RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
785 	RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
786 	RTE_ETH_RSS_IPV6_TCP_EX)
787 
788 #define RTE_ETH_RSS_SCTP ( \
789 	RTE_ETH_RSS_NONFRAG_IPV4_SCTP | \
790 	RTE_ETH_RSS_NONFRAG_IPV6_SCTP)
791 
792 #define RTE_ETH_RSS_TUNNEL ( \
793 	RTE_ETH_RSS_VXLAN  | \
794 	RTE_ETH_RSS_GENEVE | \
795 	RTE_ETH_RSS_NVGRE)
796 
797 #define RTE_ETH_RSS_VLAN ( \
798 	RTE_ETH_RSS_S_VLAN  | \
799 	RTE_ETH_RSS_C_VLAN)
800 
801 /** Mask of valid RSS hash protocols */
802 #define RTE_ETH_RSS_PROTO_MASK ( \
803 	RTE_ETH_RSS_IPV4 | \
804 	RTE_ETH_RSS_FRAG_IPV4 | \
805 	RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
806 	RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
807 	RTE_ETH_RSS_NONFRAG_IPV4_SCTP | \
808 	RTE_ETH_RSS_NONFRAG_IPV4_OTHER | \
809 	RTE_ETH_RSS_IPV6 | \
810 	RTE_ETH_RSS_FRAG_IPV6 | \
811 	RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
812 	RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
813 	RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
814 	RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \
815 	RTE_ETH_RSS_L2_PAYLOAD | \
816 	RTE_ETH_RSS_IPV6_EX | \
817 	RTE_ETH_RSS_IPV6_TCP_EX | \
818 	RTE_ETH_RSS_IPV6_UDP_EX | \
819 	RTE_ETH_RSS_PORT  | \
820 	RTE_ETH_RSS_VXLAN | \
821 	RTE_ETH_RSS_GENEVE | \
822 	RTE_ETH_RSS_NVGRE | \
823 	RTE_ETH_RSS_MPLS)
824 
825 /*
826  * Definitions used for redirection table entry size.
827  * Some RSS RETA sizes may not be supported by some drivers, check the
828  * documentation or the description of relevant functions for more details.
829  */
830 #define RTE_ETH_RSS_RETA_SIZE_64  64
831 #define RTE_ETH_RSS_RETA_SIZE_128 128
832 #define RTE_ETH_RSS_RETA_SIZE_256 256
833 #define RTE_ETH_RSS_RETA_SIZE_512 512
834 #define RTE_ETH_RETA_GROUP_SIZE   64
835 
836 /**@{@name VMDq and DCB maximums */
837 #define RTE_ETH_VMDQ_MAX_VLAN_FILTERS   64 /**< Maximum nb. of VMDq VLAN filters. */
838 #define RTE_ETH_DCB_NUM_USER_PRIORITIES 8  /**< Maximum nb. of DCB priorities. */
839 #define RTE_ETH_VMDQ_DCB_NUM_QUEUES     128 /**< Maximum nb. of VMDq DCB queues. */
840 #define RTE_ETH_DCB_NUM_QUEUES          128 /**< Maximum nb. of DCB queues. */
841 /**@}*/
842 
843 /**@{@name DCB capabilities */
844 #define RTE_ETH_DCB_PG_SUPPORT      RTE_BIT32(0) /**< Priority Group(ETS) support. */
845 #define RTE_ETH_DCB_PFC_SUPPORT     RTE_BIT32(1) /**< Priority Flow Control support. */
846 /**@}*/
847 
848 /**@{@name VLAN offload bits */
849 #define RTE_ETH_VLAN_STRIP_OFFLOAD   0x0001 /**< VLAN Strip  On/Off */
850 #define RTE_ETH_VLAN_FILTER_OFFLOAD  0x0002 /**< VLAN Filter On/Off */
851 #define RTE_ETH_VLAN_EXTEND_OFFLOAD  0x0004 /**< VLAN Extend On/Off */
852 #define RTE_ETH_QINQ_STRIP_OFFLOAD   0x0008 /**< QINQ Strip On/Off */
853 
854 #define RTE_ETH_VLAN_STRIP_MASK      0x0001 /**< VLAN Strip  setting mask */
855 #define RTE_ETH_VLAN_FILTER_MASK     0x0002 /**< VLAN Filter  setting mask*/
856 #define RTE_ETH_VLAN_EXTEND_MASK     0x0004 /**< VLAN Extend  setting mask*/
857 #define RTE_ETH_QINQ_STRIP_MASK      0x0008 /**< QINQ Strip  setting mask */
858 #define RTE_ETH_VLAN_ID_MAX          0x0FFF /**< VLAN ID is in lower 12 bits*/
859 /**@}*/
860 
861 /* Definitions used for receive MAC address */
862 #define RTE_ETH_NUM_RECEIVE_MAC_ADDR   128 /**< Maximum nb. of receive mac addr. */
863 
864 /* Definitions used for unicast hash */
865 #define RTE_ETH_VMDQ_NUM_UC_HASH_ARRAY 128 /**< Maximum nb. of UC hash array. */
866 
867 /**@{@name VMDq Rx mode
868  * @see rte_eth_vmdq_rx_conf.rx_mode
869  */
870 /** Accept untagged packets. */
871 #define RTE_ETH_VMDQ_ACCEPT_UNTAG      RTE_BIT32(0)
872 /** Accept packets in multicast table. */
873 #define RTE_ETH_VMDQ_ACCEPT_HASH_MC    RTE_BIT32(1)
874 /** Accept packets in unicast table. */
875 #define RTE_ETH_VMDQ_ACCEPT_HASH_UC    RTE_BIT32(2)
876 /** Accept broadcast packets. */
877 #define RTE_ETH_VMDQ_ACCEPT_BROADCAST  RTE_BIT32(3)
878 /** Multicast promiscuous. */
879 #define RTE_ETH_VMDQ_ACCEPT_MULTICAST  RTE_BIT32(4)
880 /**@}*/
881 
882 /**
883  * A structure used to configure 64 entries of Redirection Table of the
884  * Receive Side Scaling (RSS) feature of an Ethernet port. To configure
885  * more than 64 entries supported by hardware, an array of this structure
886  * is needed.
887  */
888 struct rte_eth_rss_reta_entry64 {
889 	/** Mask bits indicate which entries need to be updated/queried. */
890 	uint64_t mask;
891 	/** Group of 64 redirection table entries. */
892 	uint16_t reta[RTE_ETH_RETA_GROUP_SIZE];
893 };
894 
895 /**
896  * This enum indicates the possible number of traffic classes
897  * in DCB configurations
898  */
899 enum rte_eth_nb_tcs {
900 	RTE_ETH_4_TCS = 4, /**< 4 TCs with DCB. */
901 	RTE_ETH_8_TCS = 8  /**< 8 TCs with DCB. */
902 };
903 
904 /**
905  * This enum indicates the possible number of queue pools
906  * in VMDq configurations.
907  */
908 enum rte_eth_nb_pools {
909 	RTE_ETH_8_POOLS = 8,    /**< 8 VMDq pools. */
910 	RTE_ETH_16_POOLS = 16,  /**< 16 VMDq pools. */
911 	RTE_ETH_32_POOLS = 32,  /**< 32 VMDq pools. */
912 	RTE_ETH_64_POOLS = 64   /**< 64 VMDq pools. */
913 };
914 
915 /* This structure may be extended in future. */
916 struct rte_eth_dcb_rx_conf {
917 	enum rte_eth_nb_tcs nb_tcs; /**< Possible DCB TCs, 4 or 8 TCs */
918 	/** Traffic class each UP mapped to. */
919 	uint8_t dcb_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES];
920 };
921 
922 struct rte_eth_vmdq_dcb_tx_conf {
923 	enum rte_eth_nb_pools nb_queue_pools; /**< With DCB, 16 or 32 pools. */
924 	/** Traffic class each UP mapped to. */
925 	uint8_t dcb_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES];
926 };
927 
928 struct rte_eth_dcb_tx_conf {
929 	enum rte_eth_nb_tcs nb_tcs; /**< Possible DCB TCs, 4 or 8 TCs. */
930 	/** Traffic class each UP mapped to. */
931 	uint8_t dcb_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES];
932 };
933 
934 struct rte_eth_vmdq_tx_conf {
935 	enum rte_eth_nb_pools nb_queue_pools; /**< VMDq mode, 64 pools. */
936 };
937 
938 /**
939  * A structure used to configure the VMDq+DCB feature
940  * of an Ethernet port.
941  *
942  * Using this feature, packets are routed to a pool of queues, based
943  * on the VLAN ID in the VLAN tag, and then to a specific queue within
944  * that pool, using the user priority VLAN tag field.
945  *
946  * A default pool may be used, if desired, to route all traffic which
947  * does not match the VLAN filter rules.
948  */
949 struct rte_eth_vmdq_dcb_conf {
950 	enum rte_eth_nb_pools nb_queue_pools; /**< With DCB, 16 or 32 pools */
951 	uint8_t enable_default_pool; /**< If non-zero, use a default pool */
952 	uint8_t default_pool; /**< The default pool, if applicable */
953 	uint8_t nb_pool_maps; /**< We can have up to 64 filters/mappings */
954 	struct {
955 		uint16_t vlan_id; /**< The VLAN ID of the received frame */
956 		uint64_t pools;   /**< Bitmask of pools for packet Rx */
957 	} pool_map[RTE_ETH_VMDQ_MAX_VLAN_FILTERS]; /**< VMDq VLAN pool maps. */
958 	/** Selects a queue in a pool */
959 	uint8_t dcb_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES];
960 };
961 
962 /**
963  * A structure used to configure the VMDq feature of an Ethernet port when
964  * not combined with the DCB feature.
965  *
966  * Using this feature, packets are routed to a pool of queues. By default,
967  * the pool selection is based on the MAC address, the VLAN ID in the
968  * VLAN tag as specified in the pool_map array.
969  * Passing the RTE_ETH_VMDQ_ACCEPT_UNTAG in the rx_mode field allows pool
970  * selection using only the MAC address. MAC address to pool mapping is done
971  * using the rte_eth_dev_mac_addr_add function, with the pool parameter
972  * corresponding to the pool ID.
973  *
974  * Queue selection within the selected pool will be done using RSS when
975  * it is enabled or revert to the first queue of the pool if not.
976  *
977  * A default pool may be used, if desired, to route all traffic which
978  * does not match the VLAN filter rules or any pool MAC address.
979  */
980 struct rte_eth_vmdq_rx_conf {
981 	enum rte_eth_nb_pools nb_queue_pools; /**< VMDq only mode, 8 or 64 pools */
982 	uint8_t enable_default_pool; /**< If non-zero, use a default pool */
983 	uint8_t default_pool; /**< The default pool, if applicable */
984 	uint8_t enable_loop_back; /**< Enable VT loop back */
985 	uint8_t nb_pool_maps; /**< We can have up to 64 filters/mappings */
986 	uint32_t rx_mode; /**< Flags from RTE_ETH_VMDQ_ACCEPT_* */
987 	struct {
988 		uint16_t vlan_id; /**< The VLAN ID of the received frame */
989 		uint64_t pools;   /**< Bitmask of pools for packet Rx */
990 	} pool_map[RTE_ETH_VMDQ_MAX_VLAN_FILTERS]; /**< VMDq VLAN pool maps. */
991 };
992 
993 /**
994  * A structure used to configure the Tx features of an Ethernet port.
995  */
996 struct rte_eth_txmode {
997 	enum rte_eth_tx_mq_mode mq_mode; /**< Tx multi-queues mode. */
998 	/**
999 	 * Per-port Tx offloads to be set using RTE_ETH_TX_OFFLOAD_* flags.
1000 	 * Only offloads set on tx_offload_capa field on rte_eth_dev_info
1001 	 * structure are allowed to be set.
1002 	 */
1003 	uint64_t offloads;
1004 
1005 	uint16_t pvid;
1006 	__extension__
1007 	uint8_t /** If set, reject sending out tagged pkts */
1008 		hw_vlan_reject_tagged : 1,
1009 		/** If set, reject sending out untagged pkts */
1010 		hw_vlan_reject_untagged : 1,
1011 		/** If set, enable port based VLAN insertion */
1012 		hw_vlan_insert_pvid : 1;
1013 
1014 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
1015 	void *reserved_ptrs[2];   /**< Reserved for future fields */
1016 };
1017 
1018 /**
1019  * @warning
1020  * @b EXPERIMENTAL: this structure may change without prior notice.
1021  *
1022  * A structure used to configure an Rx packet segment to split.
1023  *
1024  * If RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag is set in offloads field,
1025  * the PMD will split the received packets into multiple segments
1026  * according to the specification in the description array:
1027  *
1028  * - The first network buffer will be allocated from the memory pool,
1029  *   specified in the first array element, the second buffer, from the
1030  *   pool in the second element, and so on.
1031  *
1032  * - The proto_hdrs in the elements define the split position of
1033  *   received packets.
1034  *
1035  * - The offsets from the segment description elements specify
1036  *   the data offset from the buffer beginning except the first mbuf.
1037  *   The first segment offset is added with RTE_PKTMBUF_HEADROOM.
1038  *
1039  * - The lengths in the elements define the maximal data amount
1040  *   being received to each segment. The receiving starts with filling
1041  *   up the first mbuf data buffer up to specified length. If the
1042  *   there are data remaining (packet is longer than buffer in the first
1043  *   mbuf) the following data will be pushed to the next segment
1044  *   up to its own length, and so on.
1045  *
1046  * - If the length in the segment description element is zero
1047  *   the actual buffer size will be deduced from the appropriate
1048  *   memory pool properties.
1049  *
1050  * - If there is not enough elements to describe the buffer for entire
1051  *   packet of maximal length the following parameters will be used
1052  *   for the all remaining segments:
1053  *     - pool from the last valid element
1054  *     - the buffer size from this pool
1055  *     - zero offset
1056  *
1057  * - Length based buffer split:
1058  *     - mp, length, offset should be configured.
1059  *     - The proto_hdr field must be 0.
1060  *
1061  * - Protocol header based buffer split:
1062  *     - mp, offset, proto_hdr should be configured.
1063  *     - The length field must be 0.
1064  *     - The proto_hdr field in the last segment should be 0.
1065  *
1066  * - When protocol header split is enabled, NIC may receive packets
1067  *   which do not match all the protocol headers within the Rx segments.
1068  *   At this point, NIC will have two possible split behaviors according to
1069  *   matching results, one is exact match, another is longest match.
1070  *   The split result of NIC must belong to one of them.
1071  *   The exact match means NIC only do split when the packets exactly match all
1072  *   the protocol headers in the segments.
1073  *   Otherwise, the whole packet will be put into the last valid mempool.
1074  *   The longest match means NIC will do split until packets mismatch
1075  *   the protocol header in the segments.
1076  *   The rest will be put into the last valid pool.
1077  */
1078 struct rte_eth_rxseg_split {
1079 	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
1080 	uint16_t length; /**< Segment data length, configures split point. */
1081 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
1082 	/**
1083 	 * proto_hdr defines a bit mask of the protocol sequence as RTE_PTYPE_*.
1084 	 * The last RTE_PTYPE* in the mask indicates the split position.
1085 	 *
1086 	 * If one protocol header is defined to split packets into two segments,
1087 	 * for non-tunneling packets, the complete protocol sequence should be defined.
1088 	 * For tunneling packets, for simplicity, only the tunnel and inner part of
1089 	 * complete protocol sequence is required.
1090 	 * If several protocol headers are defined to split packets into multi-segments,
1091 	 * the repeated parts of adjacent segments should be omitted.
1092 	 */
1093 	uint32_t proto_hdr;
1094 };
1095 
1096 /**
1097  * @warning
1098  * @b EXPERIMENTAL: this structure may change without prior notice.
1099  *
1100  * A common structure used to describe Rx packet segment properties.
1101  */
1102 union rte_eth_rxseg {
1103 	/* The settings for buffer split offload. */
1104 	struct rte_eth_rxseg_split split;
1105 	/* The other features settings should be added here. */
1106 };
1107 
1108 /**
1109  * A structure used to configure an Rx ring of an Ethernet port.
1110  */
1111 struct rte_eth_rxconf {
1112 	struct rte_eth_thresh rx_thresh; /**< Rx ring threshold registers. */
1113 	uint16_t rx_free_thresh; /**< Drives the freeing of Rx descriptors. */
1114 	uint8_t rx_drop_en; /**< Drop packets if no descriptors are available. */
1115 	uint8_t rx_deferred_start; /**< Do not start queue with rte_eth_dev_start(). */
1116 	uint16_t rx_nseg; /**< Number of descriptions in rx_seg array. */
1117 	/**
1118 	 * Share group index in Rx domain and switch domain.
1119 	 * Non-zero value to enable Rx queue share, zero value disable share.
1120 	 * PMD is responsible for Rx queue consistency checks to avoid member
1121 	 * port's configuration contradict to each other.
1122 	 */
1123 	uint16_t share_group;
1124 	uint16_t share_qid; /**< Shared Rx queue ID in group */
1125 	/**
1126 	 * Per-queue Rx offloads to be set using RTE_ETH_RX_OFFLOAD_* flags.
1127 	 * Only offloads set on rx_queue_offload_capa or rx_offload_capa
1128 	 * fields on rte_eth_dev_info structure are allowed to be set.
1129 	 */
1130 	uint64_t offloads;
1131 	/**
1132 	 * Points to the array of segment descriptions for an entire packet.
1133 	 * Array elements are properties for consecutive Rx segments.
1134 	 *
1135 	 * The supported capabilities of receiving segmentation is reported
1136 	 * in rte_eth_dev_info.rx_seg_capa field.
1137 	 */
1138 	union rte_eth_rxseg *rx_seg;
1139 
1140 	/**
1141 	 * Array of mempools to allocate Rx buffers from.
1142 	 *
1143 	 * This provides support for multiple mbuf pools per Rx queue.
1144 	 * The capability is reported in device info via positive
1145 	 * max_rx_mempools.
1146 	 *
1147 	 * It could be useful for more efficient usage of memory when an
1148 	 * application creates different mempools to steer the specific
1149 	 * size of the packet.
1150 	 *
1151 	 * If many mempools are specified, packets received using Rx
1152 	 * burst may belong to any provided mempool. From ethdev user point
1153 	 * of view it is undefined how PMD/NIC chooses mempool for a packet.
1154 	 *
1155 	 * If Rx scatter is enabled, a packet may be delivered using a chain
1156 	 * of mbufs obtained from single mempool or multiple mempools based
1157 	 * on the NIC implementation.
1158 	 */
1159 	struct rte_mempool **rx_mempools;
1160 	uint16_t rx_nmempool; /** < Number of Rx mempools */
1161 
1162 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
1163 	void *reserved_ptrs[2];   /**< Reserved for future fields */
1164 };
1165 
1166 /**
1167  * A structure used to configure a Tx ring of an Ethernet port.
1168  */
1169 struct rte_eth_txconf {
1170 	struct rte_eth_thresh tx_thresh; /**< Tx ring threshold registers. */
1171 	uint16_t tx_rs_thresh; /**< Drives the setting of RS bit on TXDs. */
1172 	uint16_t tx_free_thresh; /**< Start freeing Tx buffers if there are
1173 				      less free descriptors than this value. */
1174 
1175 	uint8_t tx_deferred_start; /**< Do not start queue with rte_eth_dev_start(). */
1176 	/**
1177 	 * Per-queue Tx offloads to be set  using RTE_ETH_TX_OFFLOAD_* flags.
1178 	 * Only offloads set on tx_queue_offload_capa or tx_offload_capa
1179 	 * fields on rte_eth_dev_info structure are allowed to be set.
1180 	 */
1181 	uint64_t offloads;
1182 
1183 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
1184 	void *reserved_ptrs[2];   /**< Reserved for future fields */
1185 };
1186 
1187 /**
1188  * @warning
1189  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
1190  *
1191  * A structure used to return the Tx or Rx hairpin queue capabilities.
1192  */
1193 struct rte_eth_hairpin_queue_cap {
1194 	/**
1195 	 * When set, PMD supports placing descriptors and/or data buffers
1196 	 * in dedicated device memory.
1197 	 */
1198 	uint32_t locked_device_memory:1;
1199 
1200 	/**
1201 	 * When set, PMD supports placing descriptors and/or data buffers
1202 	 * in host memory managed by DPDK.
1203 	 */
1204 	uint32_t rte_memory:1;
1205 
1206 	uint32_t reserved:30; /**< Reserved for future fields */
1207 };
1208 
1209 /**
1210  * @warning
1211  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
1212  *
1213  * A structure used to return the hairpin capabilities that are supported.
1214  */
1215 struct rte_eth_hairpin_cap {
1216 	/** The max number of hairpin queues (different bindings). */
1217 	uint16_t max_nb_queues;
1218 	/** Max number of Rx queues to be connected to one Tx queue. */
1219 	uint16_t max_rx_2_tx;
1220 	/** Max number of Tx queues to be connected to one Rx queue. */
1221 	uint16_t max_tx_2_rx;
1222 	uint16_t max_nb_desc; /**< The max num of descriptors. */
1223 	struct rte_eth_hairpin_queue_cap rx_cap; /**< Rx hairpin queue capabilities. */
1224 	struct rte_eth_hairpin_queue_cap tx_cap; /**< Tx hairpin queue capabilities. */
1225 };
1226 
1227 #define RTE_ETH_MAX_HAIRPIN_PEERS 32
1228 
1229 /**
1230  * @warning
1231  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
1232  *
1233  * A structure used to hold hairpin peer data.
1234  */
1235 struct rte_eth_hairpin_peer {
1236 	uint16_t port; /**< Peer port. */
1237 	uint16_t queue; /**< Peer queue. */
1238 };
1239 
1240 /**
1241  * @warning
1242  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
1243  *
1244  * A structure used to configure hairpin binding.
1245  */
1246 struct rte_eth_hairpin_conf {
1247 	uint32_t peer_count:16; /**< The number of peers. */
1248 
1249 	/**
1250 	 * Explicit Tx flow rule mode.
1251 	 * One hairpin pair of queues should have the same attribute.
1252 	 *
1253 	 * - When set, the user should be responsible for inserting the hairpin
1254 	 *   Tx part flows and removing them.
1255 	 * - When clear, the PMD will try to handle the Tx part of the flows,
1256 	 *   e.g., by splitting one flow into two parts.
1257 	 */
1258 	uint32_t tx_explicit:1;
1259 
1260 	/**
1261 	 * Manually bind hairpin queues.
1262 	 * One hairpin pair of queues should have the same attribute.
1263 	 *
1264 	 * - When set, to enable hairpin, the user should call the hairpin bind
1265 	 *   function after all the queues are set up properly and the ports are
1266 	 *   started. Also, the hairpin unbind function should be called
1267 	 *   accordingly before stopping a port that with hairpin configured.
1268 	 * - When cleared, the PMD will try to enable the hairpin with the queues
1269 	 *   configured automatically during port start.
1270 	 */
1271 	uint32_t manual_bind:1;
1272 
1273 	/**
1274 	 * Use locked device memory as a backing storage.
1275 	 *
1276 	 * - When set, PMD will attempt place descriptors and/or data buffers
1277 	 *   in dedicated device memory.
1278 	 * - When cleared, PMD will use default memory type as a backing storage.
1279 	 *   Please refer to PMD documentation for details.
1280 	 *
1281 	 * API user should check if PMD supports this configuration flag using
1282 	 * @see rte_eth_dev_hairpin_capability_get.
1283 	 */
1284 	uint32_t use_locked_device_memory:1;
1285 
1286 	/**
1287 	 * Use DPDK memory as backing storage.
1288 	 *
1289 	 * - When set, PMD will attempt place descriptors and/or data buffers
1290 	 *   in host memory managed by DPDK.
1291 	 * - When cleared, PMD will use default memory type as a backing storage.
1292 	 *   Please refer to PMD documentation for details.
1293 	 *
1294 	 * API user should check if PMD supports this configuration flag using
1295 	 * @see rte_eth_dev_hairpin_capability_get.
1296 	 */
1297 	uint32_t use_rte_memory:1;
1298 
1299 	/**
1300 	 * Force usage of hairpin memory configuration.
1301 	 *
1302 	 * - When set, PMD will attempt to use specified memory settings.
1303 	 *   If resource allocation fails, then hairpin queue allocation
1304 	 *   will result in an error.
1305 	 * - When clear, PMD will attempt to use specified memory settings.
1306 	 *   If resource allocation fails, then PMD will retry
1307 	 *   allocation with default configuration.
1308 	 */
1309 	uint32_t force_memory:1;
1310 
1311 	uint32_t reserved:11; /**< Reserved bits. */
1312 
1313 	struct rte_eth_hairpin_peer peers[RTE_ETH_MAX_HAIRPIN_PEERS];
1314 };
1315 
1316 /**
1317  * A structure contains information about HW descriptor ring limitations.
1318  */
1319 struct rte_eth_desc_lim {
1320 	uint16_t nb_max;   /**< Max allowed number of descriptors. */
1321 	uint16_t nb_min;   /**< Min allowed number of descriptors. */
1322 	uint16_t nb_align; /**< Number of descriptors should be aligned to. */
1323 
1324 	/**
1325 	 * Max allowed number of segments per whole packet.
1326 	 *
1327 	 * - For TSO packet this is the total number of data descriptors allowed
1328 	 *   by device.
1329 	 *
1330 	 * @see nb_mtu_seg_max
1331 	 */
1332 	uint16_t nb_seg_max;
1333 
1334 	/**
1335 	 * Max number of segments per one MTU.
1336 	 *
1337 	 * - For non-TSO packet, this is the maximum allowed number of segments
1338 	 *   in a single transmit packet.
1339 	 *
1340 	 * - For TSO packet each segment within the TSO may span up to this
1341 	 *   value.
1342 	 *
1343 	 * @see nb_seg_max
1344 	 */
1345 	uint16_t nb_mtu_seg_max;
1346 };
1347 
1348 /**
1349  * This enum indicates the flow control mode
1350  */
1351 enum rte_eth_fc_mode {
1352 	RTE_ETH_FC_NONE = 0, /**< Disable flow control. */
1353 	RTE_ETH_FC_RX_PAUSE, /**< Rx pause frame, enable flowctrl on Tx side. */
1354 	RTE_ETH_FC_TX_PAUSE, /**< Tx pause frame, enable flowctrl on Rx side. */
1355 	RTE_ETH_FC_FULL      /**< Enable flow control on both side. */
1356 };
1357 
1358 /**
1359  * A structure used to configure Ethernet flow control parameter.
1360  * These parameters will be configured into the register of the NIC.
1361  * Please refer to the corresponding data sheet for proper value.
1362  */
1363 struct rte_eth_fc_conf {
1364 	uint32_t high_water;  /**< High threshold value to trigger XOFF */
1365 	uint32_t low_water;   /**< Low threshold value to trigger XON */
1366 	uint16_t pause_time;  /**< Pause quota in the Pause frame */
1367 	uint16_t send_xon;    /**< Is XON frame need be sent */
1368 	enum rte_eth_fc_mode mode;  /**< Link flow control mode */
1369 	uint8_t mac_ctrl_frame_fwd; /**< Forward MAC control frames */
1370 	uint8_t autoneg;      /**< Use Pause autoneg */
1371 };
1372 
1373 /**
1374  * A structure used to configure Ethernet priority flow control parameter.
1375  * These parameters will be configured into the register of the NIC.
1376  * Please refer to the corresponding data sheet for proper value.
1377  */
1378 struct rte_eth_pfc_conf {
1379 	struct rte_eth_fc_conf fc; /**< General flow control parameter. */
1380 	uint8_t priority;          /**< VLAN User Priority. */
1381 };
1382 
1383 /**
1384  * @warning
1385  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
1386  *
1387  * A structure used to retrieve information of queue based PFC.
1388  */
1389 struct rte_eth_pfc_queue_info {
1390 	/**
1391 	 * Maximum supported traffic class as per PFC (802.1Qbb) specification.
1392 	 */
1393 	uint8_t tc_max;
1394 	/** PFC queue mode capabilities. */
1395 	enum rte_eth_fc_mode mode_capa;
1396 };
1397 
1398 /**
1399  * @warning
1400  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
1401  *
1402  * A structure used to configure Ethernet priority flow control parameters for
1403  * ethdev queues.
1404  *
1405  * rte_eth_pfc_queue_conf::rx_pause structure shall be used to configure given
1406  * tx_qid with corresponding tc. When ethdev device receives PFC frame with
1407  * rte_eth_pfc_queue_conf::rx_pause::tc, traffic will be paused on
1408  * rte_eth_pfc_queue_conf::rx_pause::tx_qid for that tc.
1409  *
1410  * rte_eth_pfc_queue_conf::tx_pause structure shall be used to configure given
1411  * rx_qid. When rx_qid is congested, PFC frames are generated with
1412  * rte_eth_pfc_queue_conf::rx_pause::tc and
1413  * rte_eth_pfc_queue_conf::rx_pause::pause_time to the peer.
1414  */
1415 struct rte_eth_pfc_queue_conf {
1416 	enum rte_eth_fc_mode mode; /**< Link flow control mode */
1417 
1418 	struct {
1419 		uint16_t tx_qid; /**< Tx queue ID */
1420 		/** Traffic class as per PFC (802.1Qbb) spec. The value must be
1421 		 * in the range [0, rte_eth_pfc_queue_info::tx_max - 1]
1422 		 */
1423 		uint8_t tc;
1424 	} rx_pause; /* Valid when (mode == FC_RX_PAUSE || mode == FC_FULL) */
1425 
1426 	struct {
1427 		uint16_t pause_time; /**< Pause quota in the Pause frame */
1428 		uint16_t rx_qid;     /**< Rx queue ID */
1429 		/** Traffic class as per PFC (802.1Qbb) spec. The value must be
1430 		 * in the range [0, rte_eth_pfc_queue_info::tx_max - 1]
1431 		 */
1432 		uint8_t tc;
1433 	} tx_pause; /* Valid when (mode == FC_TX_PAUSE || mode == FC_FULL) */
1434 };
1435 
1436 /**
1437  * Tunnel type for device-specific classifier configuration.
1438  * @see rte_eth_udp_tunnel
1439  */
1440 enum rte_eth_tunnel_type {
1441 	RTE_ETH_TUNNEL_TYPE_NONE = 0,
1442 	RTE_ETH_TUNNEL_TYPE_VXLAN,
1443 	RTE_ETH_TUNNEL_TYPE_GENEVE,
1444 	RTE_ETH_TUNNEL_TYPE_TEREDO,
1445 	RTE_ETH_TUNNEL_TYPE_NVGRE,
1446 	RTE_ETH_TUNNEL_TYPE_IP_IN_GRE,
1447 	RTE_ETH_L2_TUNNEL_TYPE_E_TAG,
1448 	RTE_ETH_TUNNEL_TYPE_VXLAN_GPE,
1449 	RTE_ETH_TUNNEL_TYPE_ECPRI,
1450 	RTE_ETH_TUNNEL_TYPE_MAX,
1451 };
1452 
1453 /* Deprecated API file for rte_eth_dev_filter_* functions */
1454 #include "rte_eth_ctrl.h"
1455 
1456 /**
1457  * UDP tunneling configuration.
1458  *
1459  * Used to configure the classifier of a device,
1460  * associating an UDP port with a type of tunnel.
1461  *
1462  * Some NICs may need such configuration to properly parse a tunnel
1463  * with any standard or custom UDP port.
1464  */
1465 struct rte_eth_udp_tunnel {
1466 	uint16_t udp_port; /**< UDP port used for the tunnel. */
1467 	uint8_t prot_type; /**< Tunnel type. @see rte_eth_tunnel_type */
1468 };
1469 
1470 /**
1471  * A structure used to enable/disable specific device interrupts.
1472  */
1473 struct rte_eth_intr_conf {
1474 	/** enable/disable lsc interrupt. 0 (default) - disable, 1 enable */
1475 	uint32_t lsc:1;
1476 	/** enable/disable rxq interrupt. 0 (default) - disable, 1 enable */
1477 	uint32_t rxq:1;
1478 	/** enable/disable rmv interrupt. 0 (default) - disable, 1 enable */
1479 	uint32_t rmv:1;
1480 };
1481 
1482 #define rte_intr_conf rte_eth_intr_conf
1483 
1484 /**
1485  * A structure used to configure an Ethernet port.
1486  * Depending upon the Rx multi-queue mode, extra advanced
1487  * configuration settings may be needed.
1488  */
1489 struct rte_eth_conf {
1490 	uint32_t link_speeds; /**< bitmap of RTE_ETH_LINK_SPEED_XXX of speeds to be
1491 				used. RTE_ETH_LINK_SPEED_FIXED disables link
1492 				autonegotiation, and a unique speed shall be
1493 				set. Otherwise, the bitmap defines the set of
1494 				speeds to be advertised. If the special value
1495 				RTE_ETH_LINK_SPEED_AUTONEG (0) is used, all speeds
1496 				supported are advertised. */
1497 	struct rte_eth_rxmode rxmode; /**< Port Rx configuration. */
1498 	struct rte_eth_txmode txmode; /**< Port Tx configuration. */
1499 	uint32_t lpbk_mode; /**< Loopback operation mode. By default the value
1500 			         is 0, meaning the loopback mode is disabled.
1501 				 Read the datasheet of given Ethernet controller
1502 				 for details. The possible values of this field
1503 				 are defined in implementation of each driver. */
1504 	struct {
1505 		struct rte_eth_rss_conf rss_conf; /**< Port RSS configuration */
1506 		/** Port VMDq+DCB configuration. */
1507 		struct rte_eth_vmdq_dcb_conf vmdq_dcb_conf;
1508 		/** Port DCB Rx configuration. */
1509 		struct rte_eth_dcb_rx_conf dcb_rx_conf;
1510 		/** Port VMDq Rx configuration. */
1511 		struct rte_eth_vmdq_rx_conf vmdq_rx_conf;
1512 	} rx_adv_conf; /**< Port Rx filtering configuration. */
1513 	union {
1514 		/** Port VMDq+DCB Tx configuration. */
1515 		struct rte_eth_vmdq_dcb_tx_conf vmdq_dcb_tx_conf;
1516 		/** Port DCB Tx configuration. */
1517 		struct rte_eth_dcb_tx_conf dcb_tx_conf;
1518 		/** Port VMDq Tx configuration. */
1519 		struct rte_eth_vmdq_tx_conf vmdq_tx_conf;
1520 	} tx_adv_conf; /**< Port Tx DCB configuration (union). */
1521 	/** Currently,Priority Flow Control(PFC) are supported,if DCB with PFC
1522 	    is needed,and the variable must be set RTE_ETH_DCB_PFC_SUPPORT. */
1523 	uint32_t dcb_capability_en;
1524 	struct rte_eth_intr_conf intr_conf; /**< Interrupt mode configuration. */
1525 };
1526 
1527 /**
1528  * Rx offload capabilities of a device.
1529  */
1530 #define RTE_ETH_RX_OFFLOAD_VLAN_STRIP       RTE_BIT64(0)
1531 #define RTE_ETH_RX_OFFLOAD_IPV4_CKSUM       RTE_BIT64(1)
1532 #define RTE_ETH_RX_OFFLOAD_UDP_CKSUM        RTE_BIT64(2)
1533 #define RTE_ETH_RX_OFFLOAD_TCP_CKSUM        RTE_BIT64(3)
1534 #define RTE_ETH_RX_OFFLOAD_TCP_LRO          RTE_BIT64(4)
1535 #define RTE_ETH_RX_OFFLOAD_QINQ_STRIP       RTE_BIT64(5)
1536 #define RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM RTE_BIT64(6)
1537 #define RTE_ETH_RX_OFFLOAD_MACSEC_STRIP     RTE_BIT64(7)
1538 #define RTE_ETH_RX_OFFLOAD_VLAN_FILTER      RTE_BIT64(9)
1539 #define RTE_ETH_RX_OFFLOAD_VLAN_EXTEND      RTE_BIT64(10)
1540 #define RTE_ETH_RX_OFFLOAD_SCATTER          RTE_BIT64(13)
1541 /**
1542  * Timestamp is set by the driver in RTE_MBUF_DYNFIELD_TIMESTAMP_NAME
1543  * and RTE_MBUF_DYNFLAG_RX_TIMESTAMP_NAME is set in ol_flags.
1544  * The mbuf field and flag are registered when the offload is configured.
1545  */
1546 #define RTE_ETH_RX_OFFLOAD_TIMESTAMP        RTE_BIT64(14)
1547 #define RTE_ETH_RX_OFFLOAD_SECURITY         RTE_BIT64(15)
1548 #define RTE_ETH_RX_OFFLOAD_KEEP_CRC         RTE_BIT64(16)
1549 #define RTE_ETH_RX_OFFLOAD_SCTP_CKSUM       RTE_BIT64(17)
1550 #define RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM  RTE_BIT64(18)
1551 #define RTE_ETH_RX_OFFLOAD_RSS_HASH         RTE_BIT64(19)
1552 #define RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT     RTE_BIT64(20)
1553 
1554 #define RTE_ETH_RX_OFFLOAD_CHECKSUM (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | \
1555 				 RTE_ETH_RX_OFFLOAD_UDP_CKSUM | \
1556 				 RTE_ETH_RX_OFFLOAD_TCP_CKSUM)
1557 #define RTE_ETH_RX_OFFLOAD_VLAN (RTE_ETH_RX_OFFLOAD_VLAN_STRIP | \
1558 			     RTE_ETH_RX_OFFLOAD_VLAN_FILTER | \
1559 			     RTE_ETH_RX_OFFLOAD_VLAN_EXTEND | \
1560 			     RTE_ETH_RX_OFFLOAD_QINQ_STRIP)
1561 
1562 /*
1563  * If new Rx offload capabilities are defined, they also must be
1564  * mentioned in rte_rx_offload_names in rte_ethdev.c file.
1565  */
1566 
1567 /**
1568  * Tx offload capabilities of a device.
1569  */
1570 #define RTE_ETH_TX_OFFLOAD_VLAN_INSERT      RTE_BIT64(0)
1571 #define RTE_ETH_TX_OFFLOAD_IPV4_CKSUM       RTE_BIT64(1)
1572 #define RTE_ETH_TX_OFFLOAD_UDP_CKSUM        RTE_BIT64(2)
1573 #define RTE_ETH_TX_OFFLOAD_TCP_CKSUM        RTE_BIT64(3)
1574 #define RTE_ETH_TX_OFFLOAD_SCTP_CKSUM       RTE_BIT64(4)
1575 #define RTE_ETH_TX_OFFLOAD_TCP_TSO          RTE_BIT64(5)
1576 #define RTE_ETH_TX_OFFLOAD_UDP_TSO          RTE_BIT64(6)
1577 #define RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM RTE_BIT64(7)  /**< Used for tunneling packet. */
1578 #define RTE_ETH_TX_OFFLOAD_QINQ_INSERT      RTE_BIT64(8)
1579 #define RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO    RTE_BIT64(9)  /**< Used for tunneling packet. */
1580 #define RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO      RTE_BIT64(10) /**< Used for tunneling packet. */
1581 #define RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO     RTE_BIT64(11) /**< Used for tunneling packet. */
1582 #define RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO   RTE_BIT64(12) /**< Used for tunneling packet. */
1583 #define RTE_ETH_TX_OFFLOAD_MACSEC_INSERT    RTE_BIT64(13)
1584 /**
1585  * Multiple threads can invoke rte_eth_tx_burst() concurrently on the same
1586  * Tx queue without SW lock.
1587  */
1588 #define RTE_ETH_TX_OFFLOAD_MT_LOCKFREE      RTE_BIT64(14)
1589 /** Device supports multi segment send. */
1590 #define RTE_ETH_TX_OFFLOAD_MULTI_SEGS       RTE_BIT64(15)
1591 /**
1592  * Device supports optimization for fast release of mbufs.
1593  * When set application must guarantee that per-queue all mbufs comes from
1594  * the same mempool and has refcnt = 1.
1595  */
1596 #define RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE   RTE_BIT64(16)
1597 #define RTE_ETH_TX_OFFLOAD_SECURITY         RTE_BIT64(17)
1598 /**
1599  * Device supports generic UDP tunneled packet TSO.
1600  * Application must set RTE_MBUF_F_TX_TUNNEL_UDP and other mbuf fields required
1601  * for tunnel TSO.
1602  */
1603 #define RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO      RTE_BIT64(18)
1604 /**
1605  * Device supports generic IP tunneled packet TSO.
1606  * Application must set RTE_MBUF_F_TX_TUNNEL_IP and other mbuf fields required
1607  * for tunnel TSO.
1608  */
1609 #define RTE_ETH_TX_OFFLOAD_IP_TNL_TSO       RTE_BIT64(19)
1610 /** Device supports outer UDP checksum */
1611 #define RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM  RTE_BIT64(20)
1612 /**
1613  * Device sends on time read from RTE_MBUF_DYNFIELD_TIMESTAMP_NAME
1614  * if RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME is set in ol_flags.
1615  * The mbuf field and flag are registered when the offload is configured.
1616  */
1617 #define RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP RTE_BIT64(21)
1618 /*
1619  * If new Tx offload capabilities are defined, they also must be
1620  * mentioned in rte_tx_offload_names in rte_ethdev.c file.
1621  */
1622 
1623 /**@{@name Device capabilities
1624  * Non-offload capabilities reported in rte_eth_dev_info.dev_capa.
1625  */
1626 /** Device supports Rx queue setup after device started. */
1627 #define RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP RTE_BIT64(0)
1628 /** Device supports Tx queue setup after device started. */
1629 #define RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP RTE_BIT64(1)
1630 /**
1631  * Device supports shared Rx queue among ports within Rx domain and
1632  * switch domain. Mbufs are consumed by shared Rx queue instead of
1633  * each queue. Multiple groups are supported by share_group of Rx
1634  * queue configuration. Shared Rx queue is identified by PMD using
1635  * share_qid of Rx queue configuration. Polling any port in the group
1636  * receive packets of all member ports, source port identified by
1637  * mbuf->port field.
1638  */
1639 #define RTE_ETH_DEV_CAPA_RXQ_SHARE              RTE_BIT64(2)
1640 /** Device supports keeping flow rules across restart. */
1641 #define RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP         RTE_BIT64(3)
1642 /** Device supports keeping shared flow objects across restart. */
1643 #define RTE_ETH_DEV_CAPA_FLOW_SHARED_OBJECT_KEEP RTE_BIT64(4)
1644 /**@}*/
1645 
1646 /*
1647  * Fallback default preferred Rx/Tx port parameters.
1648  * These are used if an application requests default parameters
1649  * but the PMD does not provide preferred values.
1650  */
1651 #define RTE_ETH_DEV_FALLBACK_RX_RINGSIZE 512
1652 #define RTE_ETH_DEV_FALLBACK_TX_RINGSIZE 512
1653 #define RTE_ETH_DEV_FALLBACK_RX_NBQUEUES 1
1654 #define RTE_ETH_DEV_FALLBACK_TX_NBQUEUES 1
1655 
1656 /**
1657  * Preferred Rx/Tx port parameters.
1658  * There are separate instances of this structure for transmission
1659  * and reception respectively.
1660  */
1661 struct rte_eth_dev_portconf {
1662 	uint16_t burst_size; /**< Device-preferred burst size */
1663 	uint16_t ring_size; /**< Device-preferred size of queue rings */
1664 	uint16_t nb_queues; /**< Device-preferred number of queues */
1665 };
1666 
1667 /**
1668  * Default values for switch domain ID when ethdev does not support switch
1669  * domain definitions.
1670  */
1671 #define RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID	(UINT16_MAX)
1672 
1673 /**
1674  * Ethernet device associated switch information
1675  */
1676 struct rte_eth_switch_info {
1677 	const char *name;	/**< switch name */
1678 	uint16_t domain_id;	/**< switch domain ID */
1679 	/**
1680 	 * Mapping to the devices physical switch port as enumerated from the
1681 	 * perspective of the embedded interconnect/switch. For SR-IOV enabled
1682 	 * device this may correspond to the VF_ID of each virtual function,
1683 	 * but each driver should explicitly define the mapping of switch
1684 	 * port identifier to that physical interconnect/switch
1685 	 */
1686 	uint16_t port_id;
1687 	/**
1688 	 * Shared Rx queue sub-domain boundary. Only ports in same Rx domain
1689 	 * and switch domain can share Rx queue. Valid only if device advertised
1690 	 * RTE_ETH_DEV_CAPA_RXQ_SHARE capability.
1691 	 */
1692 	uint16_t rx_domain;
1693 };
1694 
1695 /**
1696  * @warning
1697  * @b EXPERIMENTAL: this structure may change without prior notice.
1698  *
1699  * Ethernet device Rx buffer segmentation capabilities.
1700  */
1701 struct rte_eth_rxseg_capa {
1702 	__extension__
1703 	uint32_t multi_pools:1; /**< Supports receiving to multiple pools.*/
1704 	uint32_t offset_allowed:1; /**< Supports buffer offsets. */
1705 	uint32_t offset_align_log2:4; /**< Required offset alignment. */
1706 	uint16_t max_nseg; /**< Maximum amount of segments to split. */
1707 	uint16_t reserved; /**< Reserved field. */
1708 };
1709 
1710 /**
1711  * Ethernet device information
1712  */
1713 
1714 /**
1715  * Ethernet device representor port type.
1716  */
1717 enum rte_eth_representor_type {
1718 	RTE_ETH_REPRESENTOR_NONE, /**< not a representor. */
1719 	RTE_ETH_REPRESENTOR_VF,   /**< representor of Virtual Function. */
1720 	RTE_ETH_REPRESENTOR_SF,   /**< representor of Sub Function. */
1721 	RTE_ETH_REPRESENTOR_PF,   /**< representor of Physical Function. */
1722 };
1723 
1724 /**
1725  * @warning
1726  * @b EXPERIMENTAL: this enumeration may change without prior notice.
1727  *
1728  * Ethernet device error handling mode.
1729  */
1730 enum rte_eth_err_handle_mode {
1731 	/** No error handling modes are supported. */
1732 	RTE_ETH_ERROR_HANDLE_MODE_NONE,
1733 	/** Passive error handling, after the PMD detects that a reset is required,
1734 	 * the PMD reports @see RTE_ETH_EVENT_INTR_RESET event,
1735 	 * and the application invokes @see rte_eth_dev_reset to recover the port.
1736 	 */
1737 	RTE_ETH_ERROR_HANDLE_MODE_PASSIVE,
1738 	/** Proactive error handling, after the PMD detects that a reset is required,
1739 	 * the PMD reports @see RTE_ETH_EVENT_ERR_RECOVERING event,
1740 	 * do recovery internally, and finally reports the recovery result event
1741 	 * (@see RTE_ETH_EVENT_RECOVERY_*).
1742 	 */
1743 	RTE_ETH_ERROR_HANDLE_MODE_PROACTIVE,
1744 };
1745 
1746 /**
1747  * A structure used to retrieve the contextual information of
1748  * an Ethernet device, such as the controlling driver of the
1749  * device, etc...
1750  */
1751 struct rte_eth_dev_info {
1752 	struct rte_device *device; /**< Generic device information */
1753 	const char *driver_name; /**< Device Driver name. */
1754 	unsigned int if_index; /**< Index to bound host interface, or 0 if none.
1755 		Use if_indextoname() to translate into an interface name. */
1756 	uint16_t min_mtu;	/**< Minimum MTU allowed */
1757 	uint16_t max_mtu;	/**< Maximum MTU allowed */
1758 	const uint32_t *dev_flags; /**< Device flags */
1759 	/** Minimum Rx buffer size per descriptor supported by HW. */
1760 	uint32_t min_rx_bufsize;
1761 	/**
1762 	 * Maximum Rx buffer size per descriptor supported by HW.
1763 	 * The value is not enforced, information only to application to
1764 	 * optimize mbuf size.
1765 	 * Its value is UINT32_MAX when not specified by the driver.
1766 	 */
1767 	uint32_t max_rx_bufsize;
1768 	uint32_t max_rx_pktlen; /**< Maximum configurable length of Rx pkt. */
1769 	/** Maximum configurable size of LRO aggregated packet. */
1770 	uint32_t max_lro_pkt_size;
1771 	uint16_t max_rx_queues; /**< Maximum number of Rx queues. */
1772 	uint16_t max_tx_queues; /**< Maximum number of Tx queues. */
1773 	uint32_t max_mac_addrs; /**< Maximum number of MAC addresses. */
1774 	/** Maximum number of hash MAC addresses for MTA and UTA. */
1775 	uint32_t max_hash_mac_addrs;
1776 	uint16_t max_vfs; /**< Maximum number of VFs. */
1777 	uint16_t max_vmdq_pools; /**< Maximum number of VMDq pools. */
1778 	struct rte_eth_rxseg_capa rx_seg_capa; /**< Segmentation capability.*/
1779 	/** All Rx offload capabilities including all per-queue ones */
1780 	uint64_t rx_offload_capa;
1781 	/** All Tx offload capabilities including all per-queue ones */
1782 	uint64_t tx_offload_capa;
1783 	/** Device per-queue Rx offload capabilities. */
1784 	uint64_t rx_queue_offload_capa;
1785 	/** Device per-queue Tx offload capabilities. */
1786 	uint64_t tx_queue_offload_capa;
1787 	/** Device redirection table size, the total number of entries. */
1788 	uint16_t reta_size;
1789 	uint8_t hash_key_size; /**< Hash key size in bytes */
1790 	uint32_t rss_algo_capa; /** RSS hash algorithms capabilities */
1791 	/** Bit mask of RSS offloads, the bit offset also means flow type */
1792 	uint64_t flow_type_rss_offloads;
1793 	struct rte_eth_rxconf default_rxconf; /**< Default Rx configuration */
1794 	struct rte_eth_txconf default_txconf; /**< Default Tx configuration */
1795 	uint16_t vmdq_queue_base; /**< First queue ID for VMDq pools. */
1796 	uint16_t vmdq_queue_num;  /**< Queue number for VMDq pools. */
1797 	uint16_t vmdq_pool_base;  /**< First ID of VMDq pools. */
1798 	struct rte_eth_desc_lim rx_desc_lim;  /**< Rx descriptors limits */
1799 	struct rte_eth_desc_lim tx_desc_lim;  /**< Tx descriptors limits */
1800 	uint32_t speed_capa;  /**< Supported speeds bitmap (RTE_ETH_LINK_SPEED_). */
1801 	/** Configured number of Rx/Tx queues */
1802 	uint16_t nb_rx_queues; /**< Number of Rx queues. */
1803 	uint16_t nb_tx_queues; /**< Number of Tx queues. */
1804 	/**
1805 	 * Maximum number of Rx mempools supported per Rx queue.
1806 	 *
1807 	 * Value greater than 0 means that the driver supports Rx queue
1808 	 * mempools specification via rx_conf->rx_mempools.
1809 	 */
1810 	uint16_t max_rx_mempools;
1811 	/** Rx parameter recommendations */
1812 	struct rte_eth_dev_portconf default_rxportconf;
1813 	/** Tx parameter recommendations */
1814 	struct rte_eth_dev_portconf default_txportconf;
1815 	/** Generic device capabilities (RTE_ETH_DEV_CAPA_). */
1816 	uint64_t dev_capa;
1817 	/**
1818 	 * Switching information for ports on a device with a
1819 	 * embedded managed interconnect/switch.
1820 	 */
1821 	struct rte_eth_switch_info switch_info;
1822 	/** Supported error handling mode. */
1823 	enum rte_eth_err_handle_mode err_handle_mode;
1824 
1825 	uint64_t reserved_64s[2]; /**< Reserved for future fields */
1826 	void *reserved_ptrs[2];   /**< Reserved for future fields */
1827 };
1828 
1829 /**@{@name Rx/Tx queue states */
1830 #define RTE_ETH_QUEUE_STATE_STOPPED 0 /**< Queue stopped. */
1831 #define RTE_ETH_QUEUE_STATE_STARTED 1 /**< Queue started. */
1832 #define RTE_ETH_QUEUE_STATE_HAIRPIN 2 /**< Queue used for hairpin. */
1833 /**@}*/
1834 
1835 /**
1836  * Ethernet device Rx queue information structure.
1837  * Used to retrieve information about configured queue.
1838  */
1839 struct __rte_cache_min_aligned rte_eth_rxq_info {
1840 	struct rte_mempool *mp;     /**< mempool used by that queue. */
1841 	struct rte_eth_rxconf conf; /**< queue config parameters. */
1842 	uint8_t scattered_rx;       /**< scattered packets Rx supported. */
1843 	uint8_t queue_state;        /**< one of RTE_ETH_QUEUE_STATE_*. */
1844 	uint16_t nb_desc;           /**< configured number of RXDs. */
1845 	uint16_t rx_buf_size;       /**< hardware receive buffer size. */
1846 	/**
1847 	 * Available Rx descriptors threshold defined as percentage
1848 	 * of Rx queue size. If number of available descriptors is lower,
1849 	 * the event RTE_ETH_EVENT_RX_AVAIL_THESH is generated.
1850 	 * Value 0 means that the threshold monitoring is disabled.
1851 	 */
1852 	uint8_t avail_thresh;
1853 };
1854 
1855 /**
1856  * Ethernet device Tx queue information structure.
1857  * Used to retrieve information about configured queue.
1858  */
1859 struct __rte_cache_min_aligned rte_eth_txq_info {
1860 	struct rte_eth_txconf conf; /**< queue config parameters. */
1861 	uint16_t nb_desc;           /**< configured number of TXDs. */
1862 	uint8_t queue_state;        /**< one of RTE_ETH_QUEUE_STATE_*. */
1863 };
1864 
1865 /**
1866  * @warning
1867  * @b EXPERIMENTAL: this structure may change without prior notice.
1868  *
1869  * Ethernet device Rx queue information structure for recycling mbufs.
1870  * Used to retrieve Rx queue information when Tx queue reusing mbufs and moving
1871  * them into Rx mbuf ring.
1872  */
1873 struct __rte_cache_min_aligned rte_eth_recycle_rxq_info {
1874 	struct rte_mbuf **mbuf_ring; /**< mbuf ring of Rx queue. */
1875 	struct rte_mempool *mp;     /**< mempool of Rx queue. */
1876 	uint16_t *refill_head;      /**< head of Rx queue refilling mbufs. */
1877 	uint16_t *receive_tail;     /**< tail of Rx queue receiving pkts. */
1878 	uint16_t mbuf_ring_size;     /**< configured number of mbuf ring size. */
1879 	/**
1880 	 * Requirement on mbuf refilling batch size of Rx mbuf ring.
1881 	 * For some PMD drivers, the number of Rx mbuf ring refilling mbufs
1882 	 * should be aligned with mbuf ring size, in order to simplify
1883 	 * ring wrapping around.
1884 	 * Value 0 means that PMD drivers have no requirement for this.
1885 	 */
1886 	uint16_t refill_requirement;
1887 };
1888 
1889 /* Generic Burst mode flag definition, values can be ORed. */
1890 
1891 /**
1892  * If the queues have different burst mode description, this bit will be set
1893  * by PMD, then the application can iterate to retrieve burst description for
1894  * all other queues.
1895  */
1896 #define RTE_ETH_BURST_FLAG_PER_QUEUE RTE_BIT64(0)
1897 
1898 /**
1899  * Ethernet device Rx/Tx queue packet burst mode information structure.
1900  * Used to retrieve information about packet burst mode setting.
1901  */
1902 struct rte_eth_burst_mode {
1903 	uint64_t flags; /**< The ORed values of RTE_ETH_BURST_FLAG_xxx */
1904 
1905 #define RTE_ETH_BURST_MODE_INFO_SIZE 1024 /**< Maximum size for information */
1906 	char info[RTE_ETH_BURST_MODE_INFO_SIZE]; /**< burst mode information */
1907 };
1908 
1909 /** Maximum name length for extended statistics counters */
1910 #define RTE_ETH_XSTATS_NAME_SIZE 64
1911 
1912 /**
1913  * An Ethernet device extended statistic structure
1914  *
1915  * This structure is used by rte_eth_xstats_get() to provide
1916  * statistics that are not provided in the generic *rte_eth_stats*
1917  * structure.
1918  * It maps a name ID, corresponding to an index in the array returned
1919  * by rte_eth_xstats_get_names(), to a statistic value.
1920  */
1921 struct rte_eth_xstat {
1922 	uint64_t id;        /**< The index in xstats name array. */
1923 	uint64_t value;     /**< The statistic counter value. */
1924 };
1925 
1926 /**
1927  * A name element for extended statistics.
1928  *
1929  * An array of this structure is returned by rte_eth_xstats_get_names().
1930  * It lists the names of extended statistics for a PMD. The *rte_eth_xstat*
1931  * structure references these names by their array index.
1932  *
1933  * The xstats should follow a common naming scheme.
1934  * Some names are standardized in rte_stats_strings.
1935  * Examples:
1936  *     - rx_missed_errors
1937  *     - tx_q3_bytes
1938  *     - tx_size_128_to_255_packets
1939  */
1940 struct rte_eth_xstat_name {
1941 	char name[RTE_ETH_XSTATS_NAME_SIZE]; /**< The statistic name. */
1942 };
1943 
1944 #define RTE_ETH_DCB_NUM_TCS    8
1945 #define RTE_ETH_MAX_VMDQ_POOL  64
1946 
1947 /**
1948  * A structure used to get the information of queue and
1949  * TC mapping on both Tx and Rx paths.
1950  */
1951 struct rte_eth_dcb_tc_queue_mapping {
1952 	/** Rx queues assigned to tc per Pool */
1953 	struct {
1954 		uint16_t base;
1955 		uint16_t nb_queue;
1956 	} tc_rxq[RTE_ETH_MAX_VMDQ_POOL][RTE_ETH_DCB_NUM_TCS];
1957 	/** Rx queues assigned to tc per Pool */
1958 	struct {
1959 		uint16_t base;
1960 		uint16_t nb_queue;
1961 	} tc_txq[RTE_ETH_MAX_VMDQ_POOL][RTE_ETH_DCB_NUM_TCS];
1962 };
1963 
1964 /**
1965  * A structure used to get the information of DCB.
1966  * It includes TC UP mapping and queue TC mapping.
1967  */
1968 struct rte_eth_dcb_info {
1969 	uint8_t nb_tcs;        /**< number of TCs */
1970 	uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES]; /**< Priority to tc */
1971 	uint8_t tc_bws[RTE_ETH_DCB_NUM_TCS]; /**< Tx BW percentage for each TC */
1972 	/** Rx queues assigned to tc */
1973 	struct rte_eth_dcb_tc_queue_mapping tc_queue;
1974 };
1975 
1976 /**
1977  * This enum indicates the possible Forward Error Correction (FEC) modes
1978  * of an ethdev port.
1979  */
1980 enum rte_eth_fec_mode {
1981 	RTE_ETH_FEC_NOFEC = 0,      /**< FEC is off */
1982 	RTE_ETH_FEC_AUTO,	    /**< FEC autonegotiation modes */
1983 	RTE_ETH_FEC_BASER,          /**< FEC using common algorithm */
1984 	RTE_ETH_FEC_RS,             /**< FEC using RS algorithm */
1985 	RTE_ETH_FEC_LLRS,           /**< FEC using LLRS algorithm */
1986 };
1987 
1988 /* Translate from FEC mode to FEC capa */
1989 #define RTE_ETH_FEC_MODE_TO_CAPA(x) RTE_BIT32(x)
1990 
1991 /* This macro indicates FEC capa mask */
1992 #define RTE_ETH_FEC_MODE_CAPA_MASK(x) RTE_BIT32(RTE_ETH_FEC_ ## x)
1993 
1994 /* A structure used to get capabilities per link speed */
1995 struct rte_eth_fec_capa {
1996 	uint32_t speed; /**< Link speed (see RTE_ETH_SPEED_NUM_*) */
1997 	uint32_t capa;  /**< FEC capabilities bitmask */
1998 };
1999 
2000 #define RTE_ETH_ALL RTE_MAX_ETHPORTS
2001 
2002 /* Macros to check for valid port */
2003 #define RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, retval) do { \
2004 	if (!rte_eth_dev_is_valid_port(port_id)) { \
2005 		RTE_ETHDEV_LOG_LINE(ERR, "Invalid port_id=%u", port_id); \
2006 		return retval; \
2007 	} \
2008 } while (0)
2009 
2010 #define RTE_ETH_VALID_PORTID_OR_RET(port_id) do { \
2011 	if (!rte_eth_dev_is_valid_port(port_id)) { \
2012 		RTE_ETHDEV_LOG_LINE(ERR, "Invalid port_id=%u", port_id); \
2013 		return; \
2014 	} \
2015 } while (0)
2016 
2017 /**
2018  * Function type used for Rx packet processing packet callbacks.
2019  *
2020  * The callback function is called on Rx with a burst of packets that have
2021  * been received on the given port and queue.
2022  *
2023  * @param port_id
2024  *   The Ethernet port on which Rx is being performed.
2025  * @param queue
2026  *   The queue on the Ethernet port which is being used to receive the packets.
2027  * @param pkts
2028  *   The burst of packets that have just been received.
2029  * @param nb_pkts
2030  *   The number of packets in the burst pointed to by "pkts".
2031  * @param max_pkts
2032  *   The max number of packets that can be stored in the "pkts" array.
2033  * @param user_param
2034  *   The arbitrary user parameter passed in by the application when the callback
2035  *   was originally configured.
2036  * @return
2037  *   The number of packets returned to the user.
2038  */
2039 typedef uint16_t (*rte_rx_callback_fn)(uint16_t port_id, uint16_t queue,
2040 	struct rte_mbuf *pkts[], uint16_t nb_pkts, uint16_t max_pkts,
2041 	void *user_param);
2042 
2043 /**
2044  * Function type used for Tx packet processing packet callbacks.
2045  *
2046  * The callback function is called on Tx with a burst of packets immediately
2047  * before the packets are put onto the hardware queue for transmission.
2048  *
2049  * @param port_id
2050  *   The Ethernet port on which Tx is being performed.
2051  * @param queue
2052  *   The queue on the Ethernet port which is being used to transmit the packets.
2053  * @param pkts
2054  *   The burst of packets that are about to be transmitted.
2055  * @param nb_pkts
2056  *   The number of packets in the burst pointed to by "pkts".
2057  * @param user_param
2058  *   The arbitrary user parameter passed in by the application when the callback
2059  *   was originally configured.
2060  * @return
2061  *   The number of packets to be written to the NIC.
2062  */
2063 typedef uint16_t (*rte_tx_callback_fn)(uint16_t port_id, uint16_t queue,
2064 	struct rte_mbuf *pkts[], uint16_t nb_pkts, void *user_param);
2065 
2066 /**
2067  * Possible states of an ethdev port.
2068  */
2069 enum rte_eth_dev_state {
2070 	/** Device is unused before being probed. */
2071 	RTE_ETH_DEV_UNUSED = 0,
2072 	/** Device is attached when allocated in probing. */
2073 	RTE_ETH_DEV_ATTACHED,
2074 	/** Device is in removed state when plug-out is detected. */
2075 	RTE_ETH_DEV_REMOVED,
2076 };
2077 
2078 struct rte_eth_dev_sriov {
2079 	uint8_t active;               /**< SRIOV is active with 16, 32 or 64 pools */
2080 	uint8_t nb_q_per_pool;        /**< Rx queue number per pool */
2081 	uint16_t def_vmdq_idx;        /**< Default pool num used for PF */
2082 	uint16_t def_pool_q_idx;      /**< Default pool queue start reg index */
2083 };
2084 #define RTE_ETH_DEV_SRIOV(dev)         ((dev)->data->sriov)
2085 
2086 #define RTE_ETH_NAME_MAX_LEN RTE_DEV_NAME_MAX_LEN
2087 
2088 #define RTE_ETH_DEV_NO_OWNER 0
2089 
2090 #define RTE_ETH_MAX_OWNER_NAME_LEN 64
2091 
2092 struct rte_eth_dev_owner {
2093 	uint64_t id; /**< The owner unique identifier. */
2094 	char name[RTE_ETH_MAX_OWNER_NAME_LEN]; /**< The owner name. */
2095 };
2096 
2097 /**@{@name Device flags
2098  * Flags internally saved in rte_eth_dev_data.dev_flags
2099  * and reported in rte_eth_dev_info.dev_flags.
2100  */
2101 /** PMD supports thread-safe flow operations */
2102 #define RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE  RTE_BIT32(0)
2103 /** Device supports link state interrupt */
2104 #define RTE_ETH_DEV_INTR_LSC              RTE_BIT32(1)
2105 /** Device is a bonding member */
2106 #define RTE_ETH_DEV_BONDING_MEMBER        RTE_BIT32(2)
2107 /** Device supports device removal interrupt */
2108 #define RTE_ETH_DEV_INTR_RMV              RTE_BIT32(3)
2109 /** Device is port representor */
2110 #define RTE_ETH_DEV_REPRESENTOR           RTE_BIT32(4)
2111 /** Device does not support MAC change after started */
2112 #define RTE_ETH_DEV_NOLIVE_MAC_ADDR       RTE_BIT32(5)
2113 /**
2114  * Queue xstats filled automatically by ethdev layer.
2115  * PMDs filling the queue xstats themselves should not set this flag
2116  */
2117 #define RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS RTE_BIT32(6)
2118 /**@}*/
2119 
2120 /**
2121  * Iterates over valid ethdev ports owned by a specific owner.
2122  *
2123  * @param port_id
2124  *   The ID of the next possible valid owned port.
2125  * @param	owner_id
2126  *  The owner identifier.
2127  *  RTE_ETH_DEV_NO_OWNER means iterate over all valid ownerless ports.
2128  * @return
2129  *   Next valid port ID owned by owner_id, RTE_MAX_ETHPORTS if there is none.
2130  */
2131 uint64_t rte_eth_find_next_owned_by(uint16_t port_id,
2132 		const uint64_t owner_id);
2133 
2134 /**
2135  * Macro to iterate over all enabled ethdev ports owned by a specific owner.
2136  */
2137 #define RTE_ETH_FOREACH_DEV_OWNED_BY(p, o) \
2138 	for (p = rte_eth_find_next_owned_by(0, o); \
2139 	     (unsigned int)p < (unsigned int)RTE_MAX_ETHPORTS; \
2140 	     p = rte_eth_find_next_owned_by(p + 1, o))
2141 
2142 /**
2143  * Iterates over valid ethdev ports.
2144  *
2145  * @param port_id
2146  *   The ID of the next possible valid port.
2147  * @return
2148  *   Next valid port ID, RTE_MAX_ETHPORTS if there is none.
2149  */
2150 uint16_t rte_eth_find_next(uint16_t port_id);
2151 
2152 /**
2153  * Macro to iterate over all enabled and ownerless ethdev ports.
2154  */
2155 #define RTE_ETH_FOREACH_DEV(p) \
2156 	RTE_ETH_FOREACH_DEV_OWNED_BY(p, RTE_ETH_DEV_NO_OWNER)
2157 
2158 /**
2159  * Iterates over ethdev ports of a specified device.
2160  *
2161  * @param port_id_start
2162  *   The ID of the next possible valid port.
2163  * @param parent
2164  *   The generic device behind the ports to iterate.
2165  * @return
2166  *   Next port ID of the device, possibly port_id_start,
2167  *   RTE_MAX_ETHPORTS if there is none.
2168  */
2169 uint16_t
2170 rte_eth_find_next_of(uint16_t port_id_start,
2171 		const struct rte_device *parent);
2172 
2173 /**
2174  * Macro to iterate over all ethdev ports of a specified device.
2175  *
2176  * @param port_id
2177  *   The ID of the matching port being iterated.
2178  * @param parent
2179  *   The rte_device pointer matching the iterated ports.
2180  */
2181 #define RTE_ETH_FOREACH_DEV_OF(port_id, parent) \
2182 	for (port_id = rte_eth_find_next_of(0, parent); \
2183 		port_id < RTE_MAX_ETHPORTS; \
2184 		port_id = rte_eth_find_next_of(port_id + 1, parent))
2185 
2186 /**
2187  * Iterates over sibling ethdev ports (i.e. sharing the same rte_device).
2188  *
2189  * @param port_id_start
2190  *   The ID of the next possible valid sibling port.
2191  * @param ref_port_id
2192  *   The ID of a reference port to compare rte_device with.
2193  * @return
2194  *   Next sibling port ID, possibly port_id_start or ref_port_id itself,
2195  *   RTE_MAX_ETHPORTS if there is none.
2196  */
2197 uint16_t
2198 rte_eth_find_next_sibling(uint16_t port_id_start, uint16_t ref_port_id);
2199 
2200 /**
2201  * Macro to iterate over all ethdev ports sharing the same rte_device
2202  * as the specified port.
2203  * Note: the specified reference port is part of the loop iterations.
2204  *
2205  * @param port_id
2206  *   The ID of the matching port being iterated.
2207  * @param ref_port_id
2208  *   The ID of the port being compared.
2209  */
2210 #define RTE_ETH_FOREACH_DEV_SIBLING(port_id, ref_port_id) \
2211 	for (port_id = rte_eth_find_next_sibling(0, ref_port_id); \
2212 		port_id < RTE_MAX_ETHPORTS; \
2213 		port_id = rte_eth_find_next_sibling(port_id + 1, ref_port_id))
2214 
2215 /**
2216  * Get a new unique owner identifier.
2217  * An owner identifier is used to owns Ethernet devices by only one DPDK entity
2218  * to avoid multiple management of device by different entities.
2219  *
2220  * @param	owner_id
2221  *   Owner identifier pointer.
2222  * @return
2223  *   Negative errno value on error, 0 on success.
2224  */
2225 int rte_eth_dev_owner_new(uint64_t *owner_id);
2226 
2227 /**
2228  * Set an Ethernet device owner.
2229  *
2230  * @param	port_id
2231  *  The identifier of the port to own.
2232  * @param	owner
2233  *  The owner pointer.
2234  * @return
2235  *  Negative errno value on error, 0 on success.
2236  */
2237 int rte_eth_dev_owner_set(const uint16_t port_id,
2238 		const struct rte_eth_dev_owner *owner);
2239 
2240 /**
2241  * Unset Ethernet device owner to make the device ownerless.
2242  *
2243  * @param	port_id
2244  *  The identifier of port to make ownerless.
2245  * @param	owner_id
2246  *  The owner identifier.
2247  * @return
2248  *  0 on success, negative errno value on error.
2249  */
2250 int rte_eth_dev_owner_unset(const uint16_t port_id,
2251 		const uint64_t owner_id);
2252 
2253 /**
2254  * Remove owner from all Ethernet devices owned by a specific owner.
2255  *
2256  * @param	owner_id
2257  *  The owner identifier.
2258  * @return
2259  *  0 on success, negative errno value on error.
2260  */
2261 int rte_eth_dev_owner_delete(const uint64_t owner_id);
2262 
2263 /**
2264  * Get the owner of an Ethernet device.
2265  *
2266  * @param	port_id
2267  *  The port identifier.
2268  * @param	owner
2269  *  The owner structure pointer to fill.
2270  * @return
2271  *  0 on success, negative errno value on error..
2272  */
2273 int rte_eth_dev_owner_get(const uint16_t port_id,
2274 		struct rte_eth_dev_owner *owner);
2275 
2276 /**
2277  * Get the number of ports which are usable for the application.
2278  *
2279  * These devices must be iterated by using the macro
2280  * ``RTE_ETH_FOREACH_DEV`` or ``RTE_ETH_FOREACH_DEV_OWNED_BY``
2281  * to deal with non-contiguous ranges of devices.
2282  *
2283  * @return
2284  *   The count of available Ethernet devices.
2285  */
2286 uint16_t rte_eth_dev_count_avail(void);
2287 
2288 /**
2289  * Get the total number of ports which are allocated.
2290  *
2291  * Some devices may not be available for the application.
2292  *
2293  * @return
2294  *   The total count of Ethernet devices.
2295  */
2296 uint16_t rte_eth_dev_count_total(void);
2297 
2298 /**
2299  * Convert a numerical speed in Mbps to a bitmap flag that can be used in
2300  * the bitmap link_speeds of the struct rte_eth_conf
2301  *
2302  * @param speed
2303  *   Numerical speed value in Mbps
2304  * @param duplex
2305  *   RTE_ETH_LINK_[HALF/FULL]_DUPLEX (only for 10/100M speeds)
2306  * @return
2307  *   0 if the speed cannot be mapped
2308  */
2309 uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex);
2310 
2311 /**
2312  * Get RTE_ETH_RX_OFFLOAD_* flag name.
2313  *
2314  * @param offload
2315  *   Offload flag.
2316  * @return
2317  *   Offload name or 'UNKNOWN' if the flag cannot be recognised.
2318  */
2319 const char *rte_eth_dev_rx_offload_name(uint64_t offload);
2320 
2321 /**
2322  * Get RTE_ETH_TX_OFFLOAD_* flag name.
2323  *
2324  * @param offload
2325  *   Offload flag.
2326  * @return
2327  *   Offload name or 'UNKNOWN' if the flag cannot be recognised.
2328  */
2329 const char *rte_eth_dev_tx_offload_name(uint64_t offload);
2330 
2331 /**
2332  * @warning
2333  * @b EXPERIMENTAL: this API may change without prior notice.
2334  *
2335  * Get RTE_ETH_DEV_CAPA_* flag name.
2336  *
2337  * @param capability
2338  *   Capability flag.
2339  * @return
2340  *   Capability name or 'UNKNOWN' if the flag cannot be recognized.
2341  */
2342 __rte_experimental
2343 const char *rte_eth_dev_capability_name(uint64_t capability);
2344 
2345 /**
2346  * Configure an Ethernet device.
2347  * This function must be invoked first before any other function in the
2348  * Ethernet API. This function can also be re-invoked when a device is in the
2349  * stopped state.
2350  *
2351  * @param port_id
2352  *   The port identifier of the Ethernet device to configure.
2353  * @param nb_rx_queue
2354  *   The number of receive queues to set up for the Ethernet device.
2355  * @param nb_tx_queue
2356  *   The number of transmit queues to set up for the Ethernet device.
2357  * @param eth_conf
2358  *   The pointer to the configuration data to be used for the Ethernet device.
2359  *   The *rte_eth_conf* structure includes:
2360  *     -  the hardware offload features to activate, with dedicated fields for
2361  *        each statically configurable offload hardware feature provided by
2362  *        Ethernet devices, such as IP checksum or VLAN tag stripping for
2363  *        example.
2364  *        The Rx offload bitfield API is obsolete and will be deprecated.
2365  *        Applications should set the ignore_bitfield_offloads bit on *rxmode*
2366  *        structure and use offloads field to set per-port offloads instead.
2367  *     -  Any offloading set in eth_conf->[rt]xmode.offloads must be within
2368  *        the [rt]x_offload_capa returned from rte_eth_dev_info_get().
2369  *        Any type of device supported offloading set in the input argument
2370  *        eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is enabled
2371  *        on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup()
2372  *     -  the Receive Side Scaling (RSS) configuration when using multiple Rx
2373  *        queues per port. Any RSS hash function set in eth_conf->rss_conf.rss_hf
2374  *        must be within the flow_type_rss_offloads provided by drivers via
2375  *        rte_eth_dev_info_get() API.
2376  *
2377  *   Embedding all configuration information in a single data structure
2378  *   is the more flexible method that allows the addition of new features
2379  *   without changing the syntax of the API.
2380  * @return
2381  *   - 0: Success, device configured.
2382  *   - <0: Error code returned by the driver configuration function.
2383  */
2384 int rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_queue,
2385 		uint16_t nb_tx_queue, const struct rte_eth_conf *eth_conf);
2386 
2387 /**
2388  * Check if an Ethernet device was physically removed.
2389  *
2390  * @param port_id
2391  *   The port identifier of the Ethernet device.
2392  * @return
2393  *   1 when the Ethernet device is removed, otherwise 0.
2394  */
2395 int
2396 rte_eth_dev_is_removed(uint16_t port_id);
2397 
2398 /**
2399  * Allocate and set up a receive queue for an Ethernet device.
2400  *
2401  * The function allocates a contiguous block of memory for *nb_rx_desc*
2402  * receive descriptors from a memory zone associated with *socket_id*
2403  * and initializes each receive descriptor with a network buffer allocated
2404  * from the memory pool *mb_pool*.
2405  *
2406  * @param port_id
2407  *   The port identifier of the Ethernet device.
2408  * @param rx_queue_id
2409  *   The index of the receive queue to set up.
2410  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
2411  *   to rte_eth_dev_configure().
2412  * @param nb_rx_desc
2413  *   The number of receive descriptors to allocate for the receive ring.
2414  * @param socket_id
2415  *   The *socket_id* argument is the socket identifier in case of NUMA.
2416  *   The value can be *SOCKET_ID_ANY* if there is no NUMA constraint for
2417  *   the DMA memory allocated for the receive descriptors of the ring.
2418  * @param rx_conf
2419  *   The pointer to the configuration data to be used for the receive queue.
2420  *   NULL value is allowed, in which case default Rx configuration
2421  *   will be used.
2422  *   The *rx_conf* structure contains an *rx_thresh* structure with the values
2423  *   of the Prefetch, Host, and Write-Back threshold registers of the receive
2424  *   ring.
2425  *   In addition it contains the hardware offloads features to activate using
2426  *   the RTE_ETH_RX_OFFLOAD_* flags.
2427  *   If an offloading set in rx_conf->offloads
2428  *   hasn't been set in the input argument eth_conf->rxmode.offloads
2429  *   to rte_eth_dev_configure(), it is a new added offloading, it must be
2430  *   per-queue type and it is enabled for the queue.
2431  *   No need to repeat any bit in rx_conf->offloads which has already been
2432  *   enabled in rte_eth_dev_configure() at port level. An offloading enabled
2433  *   at port level can't be disabled at queue level.
2434  *   The configuration structure also contains the pointer to the array
2435  *   of the receiving buffer segment descriptions, see rx_seg and rx_nseg
2436  *   fields, this extended configuration might be used by split offloads like
2437  *   RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT. If mb_pool is not NULL,
2438  *   the extended configuration fields must be set to NULL and zero.
2439  * @param mb_pool
2440  *   The pointer to the memory pool from which to allocate *rte_mbuf* network
2441  *   memory buffers to populate each descriptor of the receive ring. There are
2442  *   two options to provide Rx buffer configuration:
2443  *   - single pool:
2444  *     mb_pool is not NULL, rx_conf.rx_nseg is 0.
2445  *   - multiple segments description:
2446  *     mb_pool is NULL, rx_conf.rx_seg is not NULL, rx_conf.rx_nseg is not 0.
2447  *     Taken only if flag RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is set in offloads.
2448  *
2449  * @return
2450  *   - 0: Success, receive queue correctly set up.
2451  *   - -EIO: if device is removed.
2452  *   - -ENODEV: if *port_id* is invalid.
2453  *   - -EINVAL: The memory pool pointer is null or the size of network buffers
2454  *      which can be allocated from this memory pool does not fit the various
2455  *      buffer sizes allowed by the device controller.
2456  *   - -ENOMEM: Unable to allocate the receive ring descriptors or to
2457  *      allocate network memory buffers from the memory pool when
2458  *      initializing receive descriptors.
2459  */
2460 int rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
2461 		uint16_t nb_rx_desc, unsigned int socket_id,
2462 		const struct rte_eth_rxconf *rx_conf,
2463 		struct rte_mempool *mb_pool);
2464 
2465 /**
2466  * @warning
2467  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
2468  *
2469  * Allocate and set up a hairpin receive queue for an Ethernet device.
2470  *
2471  * The function set up the selected queue to be used in hairpin.
2472  *
2473  * @param port_id
2474  *   The port identifier of the Ethernet device.
2475  * @param rx_queue_id
2476  *   The index of the receive queue to set up.
2477  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
2478  *   to rte_eth_dev_configure().
2479  * @param nb_rx_desc
2480  *   The number of receive descriptors to allocate for the receive ring.
2481  *   0 means the PMD will use default value.
2482  * @param conf
2483  *   The pointer to the hairpin configuration.
2484  *
2485  * @return
2486  *   - (0) if successful.
2487  *   - (-ENODEV) if *port_id* is invalid.
2488  *   - (-ENOTSUP) if hardware doesn't support.
2489  *   - (-EINVAL) if bad parameter.
2490  *   - (-ENOMEM) if unable to allocate the resources.
2491  */
2492 __rte_experimental
2493 int rte_eth_rx_hairpin_queue_setup
2494 	(uint16_t port_id, uint16_t rx_queue_id, uint16_t nb_rx_desc,
2495 	 const struct rte_eth_hairpin_conf *conf);
2496 
2497 /**
2498  * Allocate and set up a transmit queue for an Ethernet device.
2499  *
2500  * @param port_id
2501  *   The port identifier of the Ethernet device.
2502  * @param tx_queue_id
2503  *   The index of the transmit queue to set up.
2504  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
2505  *   to rte_eth_dev_configure().
2506  * @param nb_tx_desc
2507  *   The number of transmit descriptors to allocate for the transmit ring.
2508  * @param socket_id
2509  *   The *socket_id* argument is the socket identifier in case of NUMA.
2510  *   Its value can be *SOCKET_ID_ANY* if there is no NUMA constraint for
2511  *   the DMA memory allocated for the transmit descriptors of the ring.
2512  * @param tx_conf
2513  *   The pointer to the configuration data to be used for the transmit queue.
2514  *   NULL value is allowed, in which case default Tx configuration
2515  *   will be used.
2516  *   The *tx_conf* structure contains the following data:
2517  *   - The *tx_thresh* structure with the values of the Prefetch, Host, and
2518  *     Write-Back threshold registers of the transmit ring.
2519  *     When setting Write-Back threshold to the value greater then zero,
2520  *     *tx_rs_thresh* value should be explicitly set to one.
2521  *   - The *tx_free_thresh* value indicates the [minimum] number of network
2522  *     buffers that must be pending in the transmit ring to trigger their
2523  *     [implicit] freeing by the driver transmit function.
2524  *   - The *tx_rs_thresh* value indicates the [minimum] number of transmit
2525  *     descriptors that must be pending in the transmit ring before setting the
2526  *     RS bit on a descriptor by the driver transmit function.
2527  *     The *tx_rs_thresh* value should be less or equal then
2528  *     *tx_free_thresh* value, and both of them should be less then
2529  *     *nb_tx_desc* - 3.
2530  *   - The *offloads* member contains Tx offloads to be enabled.
2531  *     If an offloading set in tx_conf->offloads
2532  *     hasn't been set in the input argument eth_conf->txmode.offloads
2533  *     to rte_eth_dev_configure(), it is a new added offloading, it must be
2534  *     per-queue type and it is enabled for the queue.
2535  *     No need to repeat any bit in tx_conf->offloads which has already been
2536  *     enabled in rte_eth_dev_configure() at port level. An offloading enabled
2537  *     at port level can't be disabled at queue level.
2538  *
2539  *     Note that setting *tx_free_thresh* or *tx_rs_thresh* value to 0 forces
2540  *     the transmit function to use default values.
2541  * @return
2542  *   - 0: Success, the transmit queue is correctly set up.
2543  *   - -ENOMEM: Unable to allocate the transmit ring descriptors.
2544  */
2545 int rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
2546 		uint16_t nb_tx_desc, unsigned int socket_id,
2547 		const struct rte_eth_txconf *tx_conf);
2548 
2549 /**
2550  * @warning
2551  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
2552  *
2553  * Allocate and set up a transmit hairpin queue for an Ethernet device.
2554  *
2555  * @param port_id
2556  *   The port identifier of the Ethernet device.
2557  * @param tx_queue_id
2558  *   The index of the transmit queue to set up.
2559  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
2560  *   to rte_eth_dev_configure().
2561  * @param nb_tx_desc
2562  *   The number of transmit descriptors to allocate for the transmit ring.
2563  *   0 to set default PMD value.
2564  * @param conf
2565  *   The hairpin configuration.
2566  *
2567  * @return
2568  *   - (0) if successful.
2569  *   - (-ENODEV) if *port_id* is invalid.
2570  *   - (-ENOTSUP) if hardware doesn't support.
2571  *   - (-EINVAL) if bad parameter.
2572  *   - (-ENOMEM) if unable to allocate the resources.
2573  */
2574 __rte_experimental
2575 int rte_eth_tx_hairpin_queue_setup
2576 	(uint16_t port_id, uint16_t tx_queue_id, uint16_t nb_tx_desc,
2577 	 const struct rte_eth_hairpin_conf *conf);
2578 
2579 /**
2580  * @warning
2581  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
2582  *
2583  * Get all the hairpin peer Rx / Tx ports of the current port.
2584  * The caller should ensure that the array is large enough to save the ports
2585  * list.
2586  *
2587  * @param port_id
2588  *   The port identifier of the Ethernet device.
2589  * @param peer_ports
2590  *   Pointer to the array to store the peer ports list.
2591  * @param len
2592  *   Length of the array to store the port identifiers.
2593  * @param direction
2594  *   Current port to peer port direction
2595  *   positive - current used as Tx to get all peer Rx ports.
2596  *   zero - current used as Rx to get all peer Tx ports.
2597  *
2598  * @return
2599  *   - (0 or positive) actual peer ports number.
2600  *   - (-EINVAL) if bad parameter.
2601  *   - (-ENODEV) if *port_id* invalid
2602  *   - (-ENOTSUP) if hardware doesn't support.
2603  *   - Others detailed errors from PMDs.
2604  */
2605 __rte_experimental
2606 int rte_eth_hairpin_get_peer_ports(uint16_t port_id, uint16_t *peer_ports,
2607 				   size_t len, uint32_t direction);
2608 
2609 /**
2610  * @warning
2611  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
2612  *
2613  * Bind all hairpin Tx queues of one port to the Rx queues of the peer port.
2614  * It is only allowed to call this function after all hairpin queues are
2615  * configured properly and the devices are in started state.
2616  *
2617  * @param tx_port
2618  *   The identifier of the Tx port.
2619  * @param rx_port
2620  *   The identifier of peer Rx port.
2621  *   RTE_MAX_ETHPORTS is allowed for the traversal of all devices.
2622  *   Rx port ID could have the same value as Tx port ID.
2623  *
2624  * @return
2625  *   - (0) if successful.
2626  *   - (-ENODEV) if Tx port ID is invalid.
2627  *   - (-EBUSY) if device is not in started state.
2628  *   - (-ENOTSUP) if hardware doesn't support.
2629  *   - Others detailed errors from PMDs.
2630  */
2631 __rte_experimental
2632 int rte_eth_hairpin_bind(uint16_t tx_port, uint16_t rx_port);
2633 
2634 /**
2635  * @warning
2636  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
2637  *
2638  * Unbind all hairpin Tx queues of one port from the Rx queues of the peer port.
2639  * This should be called before closing the Tx or Rx devices, if the bind
2640  * function is called before.
2641  * After unbinding the hairpin ports pair, it is allowed to bind them again.
2642  * Changing queues configuration should be after stopping the device(s).
2643  *
2644  * @param tx_port
2645  *   The identifier of the Tx port.
2646  * @param rx_port
2647  *   The identifier of peer Rx port.
2648  *   RTE_MAX_ETHPORTS is allowed for traversal of all devices.
2649  *   Rx port ID could have the same value as Tx port ID.
2650  *
2651  * @return
2652  *   - (0) if successful.
2653  *   - (-ENODEV) if Tx port ID is invalid.
2654  *   - (-EBUSY) if device is in stopped state.
2655  *   - (-ENOTSUP) if hardware doesn't support.
2656  *   - Others detailed errors from PMDs.
2657  */
2658 __rte_experimental
2659 int rte_eth_hairpin_unbind(uint16_t tx_port, uint16_t rx_port);
2660 
2661 /**
2662  * @warning
2663  * @b EXPERIMENTAL: this API may change without prior notice.
2664  *
2665  *  Get the number of aggregated ports of the DPDK port (specified with port_id).
2666  *  It is used when multiple ports are aggregated into a single one.
2667  *
2668  *  For the regular physical port doesn't have aggregated ports,
2669  *  the number of aggregated ports is reported as 0.
2670  *
2671  * @param port_id
2672  *   The port identifier of the Ethernet device.
2673  * @return
2674  *   - (>=0) the number of aggregated port if success.
2675  */
2676 __rte_experimental
2677 int rte_eth_dev_count_aggr_ports(uint16_t port_id);
2678 
2679 /**
2680  * @warning
2681  * @b EXPERIMENTAL: this API may change without prior notice.
2682  *
2683  *  Map a Tx queue with an aggregated port of the DPDK port (specified with port_id).
2684  *  When multiple ports are aggregated into a single one,
2685  *  it allows to choose which port to use for Tx via a queue.
2686  *
2687  *  The application should use rte_eth_dev_map_aggr_tx_affinity()
2688  *  after rte_eth_dev_configure(), rte_eth_tx_queue_setup(), and
2689  *  before rte_eth_dev_start().
2690  *
2691  * @param port_id
2692  *   The identifier of the port used in rte_eth_tx_burst().
2693  * @param tx_queue_id
2694  *   The index of the transmit queue used in rte_eth_tx_burst().
2695  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
2696  *   to rte_eth_dev_configure().
2697  * @param affinity
2698  *   The number of the aggregated port.
2699  *   Value 0 means no affinity and traffic could be routed to any aggregated port.
2700  *   The first aggregated port is number 1 and so on.
2701  *   The maximum number is given by rte_eth_dev_count_aggr_ports().
2702  *
2703  * @return
2704  *   Zero if successful. Non-zero otherwise.
2705  */
2706 __rte_experimental
2707 int rte_eth_dev_map_aggr_tx_affinity(uint16_t port_id, uint16_t tx_queue_id,
2708 				     uint8_t affinity);
2709 
2710 /**
2711  * Return the NUMA socket to which an Ethernet device is connected
2712  *
2713  * @param port_id
2714  *   The port identifier of the Ethernet device
2715  * @return
2716  *   - The NUMA socket ID which the Ethernet device is connected to.
2717  *   - -1 (which translates to SOCKET_ID_ANY) if the socket could not be
2718  *     determined. rte_errno is then set to:
2719  *     - EINVAL is the port_id is invalid,
2720  *     - 0 is the socket could not be determined,
2721  */
2722 int rte_eth_dev_socket_id(uint16_t port_id);
2723 
2724 /**
2725  * Check if port_id of device is attached
2726  *
2727  * @param port_id
2728  *   The port identifier of the Ethernet device
2729  * @return
2730  *   - 0 if port is out of range or not attached
2731  *   - 1 if device is attached
2732  */
2733 int rte_eth_dev_is_valid_port(uint16_t port_id);
2734 
2735 /**
2736  * @warning
2737  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice.
2738  *
2739  * Check if Rx queue is valid.
2740  * If the queue has been setup, it is considered valid.
2741  *
2742  * @param port_id
2743  *   The port identifier of the Ethernet device.
2744  * @param queue_id
2745  *   The index of the receive queue.
2746  * @return
2747  *   - -ENODEV: if port_id is invalid.
2748  *   - -EINVAL: if queue_id is out of range or queue has not been setup.
2749  *   - 0 if Rx queue is valid.
2750  */
2751 __rte_experimental
2752 int rte_eth_rx_queue_is_valid(uint16_t port_id, uint16_t queue_id);
2753 
2754 /**
2755  * @warning
2756  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice.
2757  *
2758  * Check if Tx queue is valid.
2759  * If the queue has been setup, it is considered valid.
2760  *
2761  * @param port_id
2762  *   The port identifier of the Ethernet device.
2763  * @param queue_id
2764  *   The index of the transmit queue.
2765  * @return
2766  *   - -ENODEV: if port_id is invalid.
2767  *   - -EINVAL: if queue_id is out of range or queue has not been setup.
2768  *   - 0 if Tx queue is valid.
2769  */
2770 __rte_experimental
2771 int rte_eth_tx_queue_is_valid(uint16_t port_id, uint16_t queue_id);
2772 
2773 /**
2774  * Start specified Rx queue of a port. It is used when rx_deferred_start
2775  * flag of the specified queue is true.
2776  *
2777  * @param port_id
2778  *   The port identifier of the Ethernet device
2779  * @param rx_queue_id
2780  *   The index of the Rx queue to update the ring.
2781  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
2782  *   to rte_eth_dev_configure().
2783  * @return
2784  *   - 0: Success, the receive queue is started.
2785  *   - -ENODEV: if *port_id* is invalid.
2786  *   - -EINVAL: The queue_id out of range or belong to hairpin.
2787  *   - -EIO: if device is removed.
2788  *   - -ENOTSUP: The function not supported in PMD.
2789  */
2790 int rte_eth_dev_rx_queue_start(uint16_t port_id, uint16_t rx_queue_id);
2791 
2792 /**
2793  * Stop specified Rx queue of a port
2794  *
2795  * @param port_id
2796  *   The port identifier of the Ethernet device
2797  * @param rx_queue_id
2798  *   The index of the Rx queue to update the ring.
2799  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
2800  *   to rte_eth_dev_configure().
2801  * @return
2802  *   - 0: Success, the receive queue is stopped.
2803  *   - -ENODEV: if *port_id* is invalid.
2804  *   - -EINVAL: The queue_id out of range or belong to hairpin.
2805  *   - -EIO: if device is removed.
2806  *   - -ENOTSUP: The function not supported in PMD.
2807  */
2808 int rte_eth_dev_rx_queue_stop(uint16_t port_id, uint16_t rx_queue_id);
2809 
2810 /**
2811  * Start Tx for specified queue of a port. It is used when tx_deferred_start
2812  * flag of the specified queue is true.
2813  *
2814  * @param port_id
2815  *   The port identifier of the Ethernet device
2816  * @param tx_queue_id
2817  *   The index of the Tx queue to update the ring.
2818  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
2819  *   to rte_eth_dev_configure().
2820  * @return
2821  *   - 0: Success, the transmit queue is started.
2822  *   - -ENODEV: if *port_id* is invalid.
2823  *   - -EINVAL: The queue_id out of range or belong to hairpin.
2824  *   - -EIO: if device is removed.
2825  *   - -ENOTSUP: The function not supported in PMD.
2826  */
2827 int rte_eth_dev_tx_queue_start(uint16_t port_id, uint16_t tx_queue_id);
2828 
2829 /**
2830  * Stop specified Tx queue of a port
2831  *
2832  * @param port_id
2833  *   The port identifier of the Ethernet device
2834  * @param tx_queue_id
2835  *   The index of the Tx queue to update the ring.
2836  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
2837  *   to rte_eth_dev_configure().
2838  * @return
2839  *   - 0: Success, the transmit queue is stopped.
2840  *   - -ENODEV: if *port_id* is invalid.
2841  *   - -EINVAL: The queue_id out of range or belong to hairpin.
2842  *   - -EIO: if device is removed.
2843  *   - -ENOTSUP: The function not supported in PMD.
2844  */
2845 int rte_eth_dev_tx_queue_stop(uint16_t port_id, uint16_t tx_queue_id);
2846 
2847 /**
2848  * Start an Ethernet device.
2849  *
2850  * The device start step is the last one and consists of setting the configured
2851  * offload features and in starting the transmit and the receive units of the
2852  * device.
2853  *
2854  * Device RTE_ETH_DEV_NOLIVE_MAC_ADDR flag causes MAC address to be set before
2855  * PMD port start callback function is invoked.
2856  *
2857  * All device queues (except form deferred start queues) status should be
2858  * `RTE_ETH_QUEUE_STATE_STARTED` after start.
2859  *
2860  * On success, all basic functions exported by the Ethernet API (link status,
2861  * receive/transmit, and so on) can be invoked.
2862  *
2863  * @param port_id
2864  *   The port identifier of the Ethernet device.
2865  * @return
2866  *   - 0: Success, Ethernet device started.
2867  *   - -EAGAIN: If start operation must be retried.
2868  *   - <0: Error code of the driver device start function.
2869  */
2870 int rte_eth_dev_start(uint16_t port_id);
2871 
2872 /**
2873  * Stop an Ethernet device. The device can be restarted with a call to
2874  * rte_eth_dev_start()
2875  *
2876  * All device queues status should be `RTE_ETH_QUEUE_STATE_STOPPED` after stop.
2877  *
2878  * @param port_id
2879  *   The port identifier of the Ethernet device.
2880  * @return
2881  *   - 0: Success, Ethernet device stopped.
2882  *   - -EBUSY: If stopping the port is not allowed in current state.
2883  *   - <0: Error code of the driver device stop function.
2884  */
2885 int rte_eth_dev_stop(uint16_t port_id);
2886 
2887 /**
2888  * Link up an Ethernet device.
2889  *
2890  * Set device link up will re-enable the device Rx/Tx
2891  * functionality after it is previously set device linked down.
2892  *
2893  * @param port_id
2894  *   The port identifier of the Ethernet device.
2895  * @return
2896  *   - 0: Success, Ethernet device linked up.
2897  *   - <0: Error code of the driver device link up function.
2898  */
2899 int rte_eth_dev_set_link_up(uint16_t port_id);
2900 
2901 /**
2902  * Link down an Ethernet device.
2903  * The device Rx/Tx functionality will be disabled if success,
2904  * and it can be re-enabled with a call to
2905  * rte_eth_dev_set_link_up()
2906  *
2907  * @param port_id
2908  *   The port identifier of the Ethernet device.
2909  */
2910 int rte_eth_dev_set_link_down(uint16_t port_id);
2911 
2912 /**
2913  * Close a stopped Ethernet device. The device cannot be restarted!
2914  * The function frees all port resources.
2915  *
2916  * @param port_id
2917  *   The port identifier of the Ethernet device.
2918  * @return
2919  *   - Zero if the port is closed successfully.
2920  *   - Negative if something went wrong.
2921  */
2922 int rte_eth_dev_close(uint16_t port_id);
2923 
2924 /**
2925  * Reset a Ethernet device and keep its port ID.
2926  *
2927  * When a port has to be reset passively, the DPDK application can invoke
2928  * this function. For example when a PF is reset, all its VFs should also
2929  * be reset. Normally a DPDK application can invoke this function when
2930  * RTE_ETH_EVENT_INTR_RESET event is detected, but can also use it to start
2931  * a port reset in other circumstances.
2932  *
2933  * When this function is called, it first stops the port and then calls the
2934  * PMD specific dev_uninit( ) and dev_init( ) to return the port to initial
2935  * state, in which no Tx and Rx queues are setup, as if the port has been
2936  * reset and not started. The port keeps the port ID it had before the
2937  * function call.
2938  *
2939  * After calling rte_eth_dev_reset( ), the application should use
2940  * rte_eth_dev_configure( ), rte_eth_rx_queue_setup( ),
2941  * rte_eth_tx_queue_setup( ), and rte_eth_dev_start( )
2942  * to reconfigure the device as appropriate.
2943  *
2944  * Note: To avoid unexpected behavior, the application should stop calling
2945  * Tx and Rx functions before calling rte_eth_dev_reset( ). For thread
2946  * safety, all these controlling functions should be called from the same
2947  * thread.
2948  *
2949  * @param port_id
2950  *   The port identifier of the Ethernet device.
2951  *
2952  * @return
2953  *   - (0) if successful.
2954  *   - (-ENODEV) if *port_id* is invalid.
2955  *   - (-ENOTSUP) if hardware doesn't support this function.
2956  *   - (-EPERM) if not ran from the primary process.
2957  *   - (-EIO) if re-initialisation failed or device is removed.
2958  *   - (-ENOMEM) if the reset failed due to OOM.
2959  *   - (-EAGAIN) if the reset temporarily failed and should be retried later.
2960  */
2961 int rte_eth_dev_reset(uint16_t port_id);
2962 
2963 /**
2964  * Enable receipt in promiscuous mode for an Ethernet device.
2965  *
2966  * @param port_id
2967  *   The port identifier of the Ethernet device.
2968  * @return
2969  *   - (0) if successful.
2970  *   - (-ENOTSUP) if support for promiscuous_enable() does not exist
2971  *     for the device.
2972  *   - (-ENODEV) if *port_id* invalid.
2973  */
2974 int rte_eth_promiscuous_enable(uint16_t port_id);
2975 
2976 /**
2977  * Disable receipt in promiscuous mode for an Ethernet device.
2978  *
2979  * @param port_id
2980  *   The port identifier of the Ethernet device.
2981  * @return
2982  *   - (0) if successful.
2983  *   - (-ENOTSUP) if support for promiscuous_disable() does not exist
2984  *     for the device.
2985  *   - (-ENODEV) if *port_id* invalid.
2986  */
2987 int rte_eth_promiscuous_disable(uint16_t port_id);
2988 
2989 /**
2990  * Return the value of promiscuous mode for an Ethernet device.
2991  *
2992  * @param port_id
2993  *   The port identifier of the Ethernet device.
2994  * @return
2995  *   - (1) if promiscuous is enabled
2996  *   - (0) if promiscuous is disabled.
2997  *   - (-1) on error
2998  */
2999 int rte_eth_promiscuous_get(uint16_t port_id);
3000 
3001 /**
3002  * Enable the receipt of any multicast frame by an Ethernet device.
3003  *
3004  * @param port_id
3005  *   The port identifier of the Ethernet device.
3006  * @return
3007  *   - (0) if successful.
3008  *   - (-ENOTSUP) if support for allmulticast_enable() does not exist
3009  *     for the device.
3010  *   - (-ENODEV) if *port_id* invalid.
3011  */
3012 int rte_eth_allmulticast_enable(uint16_t port_id);
3013 
3014 /**
3015  * Disable the receipt of all multicast frames by an Ethernet device.
3016  *
3017  * @param port_id
3018  *   The port identifier of the Ethernet device.
3019  * @return
3020  *   - (0) if successful.
3021  *   - (-ENOTSUP) if support for allmulticast_disable() does not exist
3022  *     for the device.
3023  *   - (-ENODEV) if *port_id* invalid.
3024  */
3025 int rte_eth_allmulticast_disable(uint16_t port_id);
3026 
3027 /**
3028  * Return the value of allmulticast mode for an Ethernet device.
3029  *
3030  * @param port_id
3031  *   The port identifier of the Ethernet device.
3032  * @return
3033  *   - (1) if allmulticast is enabled
3034  *   - (0) if allmulticast is disabled.
3035  *   - (-1) on error
3036  */
3037 int rte_eth_allmulticast_get(uint16_t port_id);
3038 
3039 /**
3040  * Retrieve the link status (up/down), the duplex mode (half/full),
3041  * the negotiation (auto/fixed), and if available, the speed (Mbps).
3042  *
3043  * It might need to wait up to 9 seconds.
3044  * @see rte_eth_link_get_nowait.
3045  *
3046  * @param port_id
3047  *   The port identifier of the Ethernet device.
3048  * @param link
3049  *   Link information written back.
3050  * @return
3051  *   - (0) if successful.
3052  *   - (-ENOTSUP) if the function is not supported in PMD.
3053  *   - (-ENODEV) if *port_id* invalid.
3054  *   - (-EINVAL) if bad parameter.
3055  */
3056 int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link);
3057 
3058 /**
3059  * Retrieve the link status (up/down), the duplex mode (half/full),
3060  * the negotiation (auto/fixed), and if available, the speed (Mbps).
3061  *
3062  * @param port_id
3063  *   The port identifier of the Ethernet device.
3064  * @param link
3065  *   Link information written back.
3066  * @return
3067  *   - (0) if successful.
3068  *   - (-ENOTSUP) if the function is not supported in PMD.
3069  *   - (-ENODEV) if *port_id* invalid.
3070  *   - (-EINVAL) if bad parameter.
3071  */
3072 int rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *link);
3073 
3074 /**
3075  * @warning
3076  * @b EXPERIMENTAL: this API may change without prior notice.
3077  *
3078  * The function converts a link_speed to a string. It handles all special
3079  * values like unknown or none speed.
3080  *
3081  * @param link_speed
3082  *   link_speed of rte_eth_link struct
3083  * @return
3084  *   Link speed in textual format. It's pointer to immutable memory.
3085  *   No free is required.
3086  */
3087 __rte_experimental
3088 const char *rte_eth_link_speed_to_str(uint32_t link_speed);
3089 
3090 /**
3091  * @warning
3092  * @b EXPERIMENTAL: this API may change without prior notice.
3093  *
3094  * The function converts a rte_eth_link struct representing a link status to
3095  * a string.
3096  *
3097  * @param str
3098  *   A pointer to a string to be filled with textual representation of
3099  *   device status. At least RTE_ETH_LINK_MAX_STR_LEN bytes should be allocated to
3100  *   store default link status text.
3101  * @param len
3102  *   Length of available memory at 'str' string.
3103  * @param eth_link
3104  *   Link status returned by rte_eth_link_get function
3105  * @return
3106  *   Number of bytes written to str array or -EINVAL if bad parameter.
3107  */
3108 __rte_experimental
3109 int rte_eth_link_to_str(char *str, size_t len,
3110 			const struct rte_eth_link *eth_link);
3111 
3112 /**
3113  * Retrieve the general I/O statistics of an Ethernet device.
3114  *
3115  * @param port_id
3116  *   The port identifier of the Ethernet device.
3117  * @param stats
3118  *   A pointer to a structure of type *rte_eth_stats* to be filled with
3119  *   the values of device counters for the following set of statistics:
3120  *   - *ipackets* with the total of successfully received packets.
3121  *   - *opackets* with the total of successfully transmitted packets.
3122  *   - *ibytes*   with the total of successfully received bytes.
3123  *   - *obytes*   with the total of successfully transmitted bytes.
3124  *   - *ierrors*  with the total of erroneous received packets.
3125  *   - *oerrors*  with the total of failed transmitted packets.
3126  * @return
3127  *   Zero if successful. Non-zero otherwise.
3128  */
3129 int rte_eth_stats_get(uint16_t port_id, struct rte_eth_stats *stats);
3130 
3131 /**
3132  * Reset the general I/O statistics of an Ethernet device.
3133  *
3134  * @param port_id
3135  *   The port identifier of the Ethernet device.
3136  * @return
3137  *   - (0) if device notified to reset stats.
3138  *   - (-ENOTSUP) if hardware doesn't support.
3139  *   - (-ENODEV) if *port_id* invalid.
3140  *   - (<0): Error code of the driver stats reset function.
3141  */
3142 int rte_eth_stats_reset(uint16_t port_id);
3143 
3144 /**
3145  * Retrieve names of extended statistics of an Ethernet device.
3146  *
3147  * There is an assumption that 'xstat_names' and 'xstats' arrays are matched
3148  * by array index:
3149  *  xstats_names[i].name => xstats[i].value
3150  *
3151  * And the array index is same with id field of 'struct rte_eth_xstat':
3152  *  xstats[i].id == i
3153  *
3154  * This assumption makes key-value pair matching less flexible but simpler.
3155  *
3156  * @param port_id
3157  *   The port identifier of the Ethernet device.
3158  * @param xstats_names
3159  *   An rte_eth_xstat_name array of at least *size* elements to
3160  *   be filled. If set to NULL, the function returns the required number
3161  *   of elements.
3162  * @param size
3163  *   The size of the xstats_names array (number of elements).
3164  * @return
3165  *   - A positive value lower or equal to size: success. The return value
3166  *     is the number of entries filled in the stats table.
3167  *   - A positive value higher than size: error, the given statistics table
3168  *     is too small. The return value corresponds to the size that should
3169  *     be given to succeed. The entries in the table are not valid and
3170  *     shall not be used by the caller.
3171  *   - A negative value on error (invalid port ID).
3172  */
3173 int rte_eth_xstats_get_names(uint16_t port_id,
3174 		struct rte_eth_xstat_name *xstats_names,
3175 		unsigned int size);
3176 
3177 /**
3178  * Retrieve extended statistics of an Ethernet device.
3179  *
3180  * There is an assumption that 'xstat_names' and 'xstats' arrays are matched
3181  * by array index:
3182  *  xstats_names[i].name => xstats[i].value
3183  *
3184  * And the array index is same with id field of 'struct rte_eth_xstat':
3185  *  xstats[i].id == i
3186  *
3187  * This assumption makes key-value pair matching less flexible but simpler.
3188  *
3189  * @param port_id
3190  *   The port identifier of the Ethernet device.
3191  * @param xstats
3192  *   A pointer to a table of structure of type *rte_eth_xstat*
3193  *   to be filled with device statistics ids and values.
3194  *   This parameter can be set to NULL if and only if n is 0.
3195  * @param n
3196  *   The size of the xstats array (number of elements).
3197  *   If lower than the required number of elements, the function returns
3198  *   the required number of elements.
3199  *   If equal to zero, the xstats must be NULL, the function returns the
3200  *   required number of elements.
3201  * @return
3202  *   - A positive value lower or equal to n: success. The return value
3203  *     is the number of entries filled in the stats table.
3204  *   - A positive value higher than n: error, the given statistics table
3205  *     is too small. The return value corresponds to the size that should
3206  *     be given to succeed. The entries in the table are not valid and
3207  *     shall not be used by the caller.
3208  *   - A negative value on error (invalid port ID).
3209  */
3210 int rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats,
3211 		unsigned int n);
3212 
3213 /**
3214  * Retrieve names of extended statistics of an Ethernet device.
3215  *
3216  * @param port_id
3217  *   The port identifier of the Ethernet device.
3218  * @param xstats_names
3219  *   Array to be filled in with names of requested device statistics.
3220  *   Must not be NULL if @p ids are specified (not NULL).
3221  * @param size
3222  *   Number of elements in @p xstats_names array (if not NULL) and in
3223  *   @p ids array (if not NULL). Must be 0 if both array pointers are NULL.
3224  * @param ids
3225  *   IDs array given by app to retrieve specific statistics. May be NULL to
3226  *   retrieve names of all available statistics or, if @p xstats_names is
3227  *   NULL as well, just the number of available statistics.
3228  * @return
3229  *   - A positive value lower or equal to size: success. The return value
3230  *     is the number of entries filled in the stats table.
3231  *   - A positive value higher than size: success. The given statistics table
3232  *     is too small. The return value corresponds to the size that should
3233  *     be given to succeed. The entries in the table are not valid and
3234  *     shall not be used by the caller.
3235  *   - A negative value on error.
3236  */
3237 int
3238 rte_eth_xstats_get_names_by_id(uint16_t port_id,
3239 	struct rte_eth_xstat_name *xstats_names, unsigned int size,
3240 	uint64_t *ids);
3241 
3242 /**
3243  * Retrieve extended statistics of an Ethernet device.
3244  *
3245  * @param port_id
3246  *   The port identifier of the Ethernet device.
3247  * @param ids
3248  *   IDs array given by app to retrieve specific statistics. May be NULL to
3249  *   retrieve all available statistics or, if @p values is NULL as well,
3250  *   just the number of available statistics.
3251  * @param values
3252  *   Array to be filled in with requested device statistics.
3253  *   Must not be NULL if ids are specified (not NULL).
3254  * @param size
3255  *   Number of elements in @p values array (if not NULL) and in @p ids
3256  *   array (if not NULL). Must be 0 if both array pointers are NULL.
3257  * @return
3258  *   - A positive value lower or equal to size: success. The return value
3259  *     is the number of entries filled in the stats table.
3260  *   - A positive value higher than size: success: The given statistics table
3261  *     is too small. The return value corresponds to the size that should
3262  *     be given to succeed. The entries in the table are not valid and
3263  *     shall not be used by the caller.
3264  *   - A negative value on error.
3265  */
3266 int rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,
3267 			     uint64_t *values, unsigned int size);
3268 
3269 /**
3270  * Gets the ID of a statistic from its name.
3271  *
3272  * This function searches for the statistics using string compares, and
3273  * as such should not be used on the fast-path. For fast-path retrieval of
3274  * specific statistics, store the ID as provided in *id* from this function,
3275  * and pass the ID to rte_eth_xstats_get()
3276  *
3277  * @param port_id The port to look up statistics from
3278  * @param xstat_name The name of the statistic to return
3279  * @param[out] id A pointer to an app-supplied uint64_t which should be
3280  *                set to the ID of the stat if the stat exists.
3281  * @return
3282  *    0 on success
3283  *    -ENODEV for invalid port_id,
3284  *    -EIO if device is removed,
3285  *    -EINVAL if the xstat_name doesn't exist in port_id
3286  *    -ENOMEM if bad parameter.
3287  */
3288 int rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name,
3289 		uint64_t *id);
3290 
3291 /**
3292  * Reset extended statistics of an Ethernet device.
3293  *
3294  * @param port_id
3295  *   The port identifier of the Ethernet device.
3296  * @return
3297  *   - (0) if device notified to reset extended stats.
3298  *   - (-ENOTSUP) if pmd doesn't support both
3299  *     extended stats and basic stats reset.
3300  *   - (-ENODEV) if *port_id* invalid.
3301  *   - (<0): Error code of the driver xstats reset function.
3302  */
3303 int rte_eth_xstats_reset(uint16_t port_id);
3304 
3305 /**
3306  *  Set a mapping for the specified transmit queue to the specified per-queue
3307  *  statistics counter.
3308  *
3309  * @param port_id
3310  *   The port identifier of the Ethernet device.
3311  * @param tx_queue_id
3312  *   The index of the transmit queue for which a queue stats mapping is required.
3313  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
3314  *   to rte_eth_dev_configure().
3315  * @param stat_idx
3316  *   The per-queue packet statistics functionality number that the transmit
3317  *   queue is to be assigned.
3318  *   The value must be in the range [0, RTE_ETHDEV_QUEUE_STAT_CNTRS - 1].
3319  *   Max RTE_ETHDEV_QUEUE_STAT_CNTRS being 256.
3320  * @return
3321  *   Zero if successful. Non-zero otherwise.
3322  */
3323 int rte_eth_dev_set_tx_queue_stats_mapping(uint16_t port_id,
3324 		uint16_t tx_queue_id, uint8_t stat_idx);
3325 
3326 /**
3327  *  Set a mapping for the specified receive queue to the specified per-queue
3328  *  statistics counter.
3329  *
3330  * @param port_id
3331  *   The port identifier of the Ethernet device.
3332  * @param rx_queue_id
3333  *   The index of the receive queue for which a queue stats mapping is required.
3334  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
3335  *   to rte_eth_dev_configure().
3336  * @param stat_idx
3337  *   The per-queue packet statistics functionality number that the receive
3338  *   queue is to be assigned.
3339  *   The value must be in the range [0, RTE_ETHDEV_QUEUE_STAT_CNTRS - 1].
3340  *   Max RTE_ETHDEV_QUEUE_STAT_CNTRS being 256.
3341  * @return
3342  *   Zero if successful. Non-zero otherwise.
3343  */
3344 int rte_eth_dev_set_rx_queue_stats_mapping(uint16_t port_id,
3345 					   uint16_t rx_queue_id,
3346 					   uint8_t stat_idx);
3347 
3348 /**
3349  * Retrieve the Ethernet address of an Ethernet device.
3350  *
3351  * @param port_id
3352  *   The port identifier of the Ethernet device.
3353  * @param mac_addr
3354  *   A pointer to a structure of type *ether_addr* to be filled with
3355  *   the Ethernet address of the Ethernet device.
3356  * @return
3357  *   - (0) if successful
3358  *   - (-ENODEV) if *port_id* invalid.
3359  *   - (-EINVAL) if bad parameter.
3360  */
3361 int rte_eth_macaddr_get(uint16_t port_id, struct rte_ether_addr *mac_addr);
3362 
3363 /**
3364  * @warning
3365  * @b EXPERIMENTAL: this API may change without prior notice
3366  *
3367  * Retrieve the Ethernet addresses of an Ethernet device.
3368  *
3369  * @param port_id
3370  *   The port identifier of the Ethernet device.
3371  * @param ma
3372  *   A pointer to an array of structures of type *ether_addr* to be filled with
3373  *   the Ethernet addresses of the Ethernet device.
3374  * @param num
3375  *   Number of elements in the @p ma array.
3376  *   Note that  rte_eth_dev_info::max_mac_addrs can be used to retrieve
3377  *   max number of Ethernet addresses for given port.
3378  * @return
3379  *   - number of retrieved addresses if successful
3380  *   - (-ENODEV) if *port_id* invalid.
3381  *   - (-EINVAL) if bad parameter.
3382  */
3383 __rte_experimental
3384 int rte_eth_macaddrs_get(uint16_t port_id, struct rte_ether_addr *ma,
3385 	unsigned int num);
3386 
3387 /**
3388  * Retrieve the contextual information of an Ethernet device.
3389  *
3390  * This function returns the Ethernet device information based
3391  * on the values stored internally in the device specific data.
3392  * For example: number of queues, descriptor limits, device
3393  * capabilities and offload flags.
3394  *
3395  * @param port_id
3396  *   The port identifier of the Ethernet device.
3397  * @param dev_info
3398  *   A pointer to a structure of type *rte_eth_dev_info* to be filled with
3399  *   the contextual information of the Ethernet device.
3400  * @return
3401  *   - (0) if successful.
3402  *   - (-ENOTSUP) if support for dev_infos_get() does not exist for the device.
3403  *   - (-ENODEV) if *port_id* invalid.
3404  *   - (-EINVAL) if bad parameter.
3405  */
3406 int rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info);
3407 
3408 /**
3409  * @warning
3410  * @b EXPERIMENTAL: this API may change without prior notice.
3411  *
3412  * Retrieve the configuration of an Ethernet device.
3413  *
3414  * @param port_id
3415  *   The port identifier of the Ethernet device.
3416  * @param dev_conf
3417  *   Location for Ethernet device configuration to be filled in.
3418  * @return
3419  *   - (0) if successful.
3420  *   - (-ENODEV) if *port_id* invalid.
3421  *   - (-EINVAL) if bad parameter.
3422  */
3423 __rte_experimental
3424 int rte_eth_dev_conf_get(uint16_t port_id, struct rte_eth_conf *dev_conf);
3425 
3426 /**
3427  * Retrieve the firmware version of a device.
3428  *
3429  * @param port_id
3430  *   The port identifier of the device.
3431  * @param fw_version
3432  *   A pointer to a string array storing the firmware version of a device,
3433  *   the string includes terminating null. This pointer is allocated by caller.
3434  * @param fw_size
3435  *   The size of the string array pointed by fw_version, which should be
3436  *   large enough to store firmware version of the device.
3437  * @return
3438  *   - (0) if successful.
3439  *   - (-ENOTSUP) if operation is not supported.
3440  *   - (-ENODEV) if *port_id* invalid.
3441  *   - (-EIO) if device is removed.
3442  *   - (-EINVAL) if bad parameter.
3443  *   - (>0) if *fw_size* is not enough to store firmware version, return
3444  *          the size of the non truncated string.
3445  */
3446 int rte_eth_dev_fw_version_get(uint16_t port_id,
3447 			       char *fw_version, size_t fw_size);
3448 
3449 /**
3450  * Retrieve the supported packet types of an Ethernet device.
3451  *
3452  * When a packet type is announced as supported, it *must* be recognized by
3453  * the PMD. For instance, if RTE_PTYPE_L2_ETHER, RTE_PTYPE_L2_ETHER_VLAN
3454  * and RTE_PTYPE_L3_IPV4 are announced, the PMD must return the following
3455  * packet types for these packets:
3456  * - Ether/IPv4              -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4
3457  * - Ether/VLAN/IPv4         -> RTE_PTYPE_L2_ETHER_VLAN | RTE_PTYPE_L3_IPV4
3458  * - Ether/[anything else]   -> RTE_PTYPE_L2_ETHER
3459  * - Ether/VLAN/[anything else] -> RTE_PTYPE_L2_ETHER_VLAN
3460  *
3461  * When a packet is received by a PMD, the most precise type must be
3462  * returned among the ones supported. However a PMD is allowed to set
3463  * packet type that is not in the supported list, at the condition that it
3464  * is more precise. Therefore, a PMD announcing no supported packet types
3465  * can still set a matching packet type in a received packet.
3466  *
3467  * @note
3468  *   Better to invoke this API after the device is already started or Rx burst
3469  *   function is decided, to obtain correct supported ptypes.
3470  * @note
3471  *   if a given PMD does not report what ptypes it supports, then the supported
3472  *   ptype count is reported as 0.
3473  * @param port_id
3474  *   The port identifier of the Ethernet device.
3475  * @param ptype_mask
3476  *   A hint of what kind of packet type which the caller is interested in.
3477  * @param ptypes
3478  *   An array pointer to store adequate packet types, allocated by caller.
3479  * @param num
3480  *  Size of the array pointed by param ptypes.
3481  * @return
3482  *   - (>=0) Number of supported ptypes. If the number of types exceeds num,
3483  *           only num entries will be filled into the ptypes array, but the full
3484  *           count of supported ptypes will be returned.
3485  *   - (-ENODEV) if *port_id* invalid.
3486  *   - (-EINVAL) if bad parameter.
3487  */
3488 int rte_eth_dev_get_supported_ptypes(uint16_t port_id, uint32_t ptype_mask,
3489 				     uint32_t *ptypes, int num);
3490 /**
3491  * Inform Ethernet device about reduced range of packet types to handle.
3492  *
3493  * Application can use this function to set only specific ptypes that it's
3494  * interested. This information can be used by the PMD to optimize Rx path.
3495  *
3496  * The function accepts an array `set_ptypes` allocated by the caller to
3497  * store the packet types set by the driver, the last element of the array
3498  * is set to RTE_PTYPE_UNKNOWN. The size of the `set_ptype` array should be
3499  * `rte_eth_dev_get_supported_ptypes() + 1` else it might only be filled
3500  * partially.
3501  *
3502  * @param port_id
3503  *   The port identifier of the Ethernet device.
3504  * @param ptype_mask
3505  *   The ptype family that application is interested in should be bitwise OR of
3506  *   RTE_PTYPE_*_MASK or 0.
3507  * @param set_ptypes
3508  *   An array pointer to store set packet types, allocated by caller. The
3509  *   function marks the end of array with RTE_PTYPE_UNKNOWN.
3510  * @param num
3511  *   Size of the array pointed by param ptypes.
3512  *   Should be rte_eth_dev_get_supported_ptypes() + 1 to accommodate the
3513  *   set ptypes.
3514  * @return
3515  *   - (0) if Success.
3516  *   - (-ENODEV) if *port_id* invalid.
3517  *   - (-EINVAL) if *ptype_mask* is invalid (or) set_ptypes is NULL and
3518  *     num > 0.
3519  */
3520 int rte_eth_dev_set_ptypes(uint16_t port_id, uint32_t ptype_mask,
3521 			   uint32_t *set_ptypes, unsigned int num);
3522 
3523 /**
3524  * Retrieve the MTU of an Ethernet device.
3525  *
3526  * @param port_id
3527  *   The port identifier of the Ethernet device.
3528  * @param mtu
3529  *   A pointer to a uint16_t where the retrieved MTU is to be stored.
3530  * @return
3531  *   - (0) if successful.
3532  *   - (-ENODEV) if *port_id* invalid.
3533  *   - (-EINVAL) if bad parameter.
3534  */
3535 int rte_eth_dev_get_mtu(uint16_t port_id, uint16_t *mtu);
3536 
3537 /**
3538  * Change the MTU of an Ethernet device.
3539  *
3540  * @param port_id
3541  *   The port identifier of the Ethernet device.
3542  * @param mtu
3543  *   A uint16_t for the MTU to be applied.
3544  * @return
3545  *   - (0) if successful.
3546  *   - (-ENOTSUP) if operation is not supported.
3547  *   - (-ENODEV) if *port_id* invalid.
3548  *   - (-EIO) if device is removed.
3549  *   - (-EINVAL) if *mtu* invalid, validation of mtu can occur within
3550  *     rte_eth_dev_set_mtu if dev_infos_get is supported by the device or
3551  *     when the mtu is set using dev->dev_ops->mtu_set.
3552  *   - (-EBUSY) if operation is not allowed when the port is running
3553  */
3554 int rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu);
3555 
3556 /**
3557  * Enable/Disable hardware filtering by an Ethernet device of received
3558  * VLAN packets tagged with a given VLAN Tag Identifier.
3559  *
3560  * @param port_id
3561  *   The port identifier of the Ethernet device.
3562  * @param vlan_id
3563  *   The VLAN Tag Identifier whose filtering must be enabled or disabled.
3564  * @param on
3565  *   If > 0, enable VLAN filtering of VLAN packets tagged with *vlan_id*.
3566  *   Otherwise, disable VLAN filtering of VLAN packets tagged with *vlan_id*.
3567  * @return
3568  *   - (0) if successful.
3569  *   - (-ENOTSUP) if hardware-assisted VLAN filtering not configured.
3570  *   - (-ENODEV) if *port_id* invalid.
3571  *   - (-EIO) if device is removed.
3572  *   - (-ENOSYS) if VLAN filtering on *port_id* disabled.
3573  *   - (-EINVAL) if *vlan_id* > 4095.
3574  */
3575 int rte_eth_dev_vlan_filter(uint16_t port_id, uint16_t vlan_id, int on);
3576 
3577 /**
3578  * Enable/Disable hardware VLAN Strip by a Rx queue of an Ethernet device.
3579  *
3580  * @param port_id
3581  *   The port identifier of the Ethernet device.
3582  * @param rx_queue_id
3583  *   The index of the receive queue for which a queue stats mapping is required.
3584  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
3585  *   to rte_eth_dev_configure().
3586  * @param on
3587  *   If 1, Enable VLAN Stripping of the receive queue of the Ethernet port.
3588  *   If 0, Disable VLAN Stripping of the receive queue of the Ethernet port.
3589  * @return
3590  *   - (0) if successful.
3591  *   - (-ENOTSUP) if hardware-assisted VLAN stripping not configured.
3592  *   - (-ENODEV) if *port_id* invalid.
3593  *   - (-EINVAL) if *rx_queue_id* invalid.
3594  */
3595 int rte_eth_dev_set_vlan_strip_on_queue(uint16_t port_id, uint16_t rx_queue_id,
3596 		int on);
3597 
3598 /**
3599  * Set the Outer VLAN Ether Type by an Ethernet device, it can be inserted to
3600  * the VLAN header.
3601  *
3602  * @param port_id
3603  *   The port identifier of the Ethernet device.
3604  * @param vlan_type
3605  *   The VLAN type.
3606  * @param tag_type
3607  *   The Tag Protocol ID
3608  * @return
3609  *   - (0) if successful.
3610  *   - (-ENOTSUP) if hardware-assisted VLAN TPID setup is not supported.
3611  *   - (-ENODEV) if *port_id* invalid.
3612  *   - (-EIO) if device is removed.
3613  */
3614 int rte_eth_dev_set_vlan_ether_type(uint16_t port_id,
3615 				    enum rte_vlan_type vlan_type,
3616 				    uint16_t tag_type);
3617 
3618 /**
3619  * Set VLAN offload configuration on an Ethernet device.
3620  *
3621  * @param port_id
3622  *   The port identifier of the Ethernet device.
3623  * @param offload_mask
3624  *   The VLAN Offload bit mask can be mixed use with "OR"
3625  *       RTE_ETH_VLAN_STRIP_OFFLOAD
3626  *       RTE_ETH_VLAN_FILTER_OFFLOAD
3627  *       RTE_ETH_VLAN_EXTEND_OFFLOAD
3628  *       RTE_ETH_QINQ_STRIP_OFFLOAD
3629  * @return
3630  *   - (0) if successful.
3631  *   - (-ENOTSUP) if hardware-assisted VLAN filtering not configured.
3632  *   - (-ENODEV) if *port_id* invalid.
3633  *   - (-EIO) if device is removed.
3634  */
3635 int rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask);
3636 
3637 /**
3638  * Read VLAN Offload configuration from an Ethernet device
3639  *
3640  * @param port_id
3641  *   The port identifier of the Ethernet device.
3642  * @return
3643  *   - (>0) if successful. Bit mask to indicate
3644  *       RTE_ETH_VLAN_STRIP_OFFLOAD
3645  *       RTE_ETH_VLAN_FILTER_OFFLOAD
3646  *       RTE_ETH_VLAN_EXTEND_OFFLOAD
3647  *       RTE_ETH_QINQ_STRIP_OFFLOAD
3648  *   - (-ENODEV) if *port_id* invalid.
3649  */
3650 int rte_eth_dev_get_vlan_offload(uint16_t port_id);
3651 
3652 /**
3653  * Set port based Tx VLAN insertion on or off.
3654  *
3655  * @param port_id
3656  *  The port identifier of the Ethernet device.
3657  * @param pvid
3658  *  Port based Tx VLAN identifier together with user priority.
3659  * @param on
3660  *  Turn on or off the port based Tx VLAN insertion.
3661  *
3662  * @return
3663  *   - (0) if successful.
3664  *   - negative if failed.
3665  */
3666 int rte_eth_dev_set_vlan_pvid(uint16_t port_id, uint16_t pvid, int on);
3667 
3668 /**
3669  * @warning
3670  * @b EXPERIMENTAL: this API may change without prior notice.
3671  *
3672  * Set Rx queue available descriptors threshold.
3673  *
3674  * @param port_id
3675  *  The port identifier of the Ethernet device.
3676  * @param queue_id
3677  *  The index of the receive queue.
3678  * @param avail_thresh
3679  *  The available descriptors threshold is percentage of Rx queue size
3680  *  which describes the availability of Rx queue for hardware.
3681  *  If the Rx queue availability is below it,
3682  *  the event RTE_ETH_EVENT_RX_AVAIL_THRESH is triggered.
3683  *  [1-99] to set a new available descriptors threshold.
3684  *  0 to disable threshold monitoring.
3685  *
3686  * @return
3687  *   - 0 if successful.
3688  *   - (-ENODEV) if @p port_id is invalid.
3689  *   - (-EINVAL) if bad parameter.
3690  *   - (-ENOTSUP) if available Rx descriptors threshold is not supported.
3691  *   - (-EIO) if device is removed.
3692  */
3693 __rte_experimental
3694 int rte_eth_rx_avail_thresh_set(uint16_t port_id, uint16_t queue_id,
3695 			       uint8_t avail_thresh);
3696 
3697 /**
3698  * @warning
3699  * @b EXPERIMENTAL: this API may change without prior notice.
3700  *
3701  * Find Rx queue with RTE_ETH_EVENT_RX_AVAIL_THRESH event pending.
3702  *
3703  * @param port_id
3704  *  The port identifier of the Ethernet device.
3705  * @param[inout] queue_id
3706  *  On input starting Rx queue index to search from.
3707  *  If the queue_id is bigger than maximum queue ID of the port,
3708  *  search is started from 0. So that application can keep calling
3709  *  this function to handle all pending events with a simple increment
3710  *  of queue_id on the next call.
3711  *  On output if return value is 1, Rx queue index with the event pending.
3712  * @param[out] avail_thresh
3713  *  Location for available descriptors threshold of the found Rx queue.
3714  *
3715  * @return
3716  *   - 1 if an Rx queue with pending event is found.
3717  *   - 0 if no Rx queue with pending event is found.
3718  *   - (-ENODEV) if @p port_id is invalid.
3719  *   - (-EINVAL) if bad parameter (e.g. @p queue_id is NULL).
3720  *   - (-ENOTSUP) if operation is not supported.
3721  *   - (-EIO) if device is removed.
3722  */
3723 __rte_experimental
3724 int rte_eth_rx_avail_thresh_query(uint16_t port_id, uint16_t *queue_id,
3725 				 uint8_t *avail_thresh);
3726 
3727 typedef void (*buffer_tx_error_fn)(struct rte_mbuf **unsent, uint16_t count,
3728 		void *userdata);
3729 
3730 /**
3731  * Structure used to buffer packets for future Tx
3732  * Used by APIs rte_eth_tx_buffer and rte_eth_tx_buffer_flush
3733  */
3734 struct rte_eth_dev_tx_buffer {
3735 	buffer_tx_error_fn error_callback;
3736 	void *error_userdata;
3737 	uint16_t size;           /**< Size of buffer for buffered Tx */
3738 	uint16_t length;         /**< Number of packets in the array */
3739 	/** Pending packets to be sent on explicit flush or when full */
3740 	struct rte_mbuf *pkts[];
3741 };
3742 
3743 /**
3744  * Calculate the size of the Tx buffer.
3745  *
3746  * @param sz
3747  *   Number of stored packets.
3748  */
3749 #define RTE_ETH_TX_BUFFER_SIZE(sz) \
3750 	(sizeof(struct rte_eth_dev_tx_buffer) + (sz) * sizeof(struct rte_mbuf *))
3751 
3752 /**
3753  * Initialize default values for buffered transmitting
3754  *
3755  * @param buffer
3756  *   Tx buffer to be initialized.
3757  * @param size
3758  *   Buffer size
3759  * @return
3760  *   0 if no error
3761  */
3762 int
3763 rte_eth_tx_buffer_init(struct rte_eth_dev_tx_buffer *buffer, uint16_t size);
3764 
3765 /**
3766  * Configure a callback for buffered packets which cannot be sent
3767  *
3768  * Register a specific callback to be called when an attempt is made to send
3769  * all packets buffered on an Ethernet port, but not all packets can
3770  * successfully be sent. The callback registered here will be called only
3771  * from calls to rte_eth_tx_buffer() and rte_eth_tx_buffer_flush() APIs.
3772  * The default callback configured for each queue by default just frees the
3773  * packets back to the calling mempool. If additional behaviour is required,
3774  * for example, to count dropped packets, or to retry transmission of packets
3775  * which cannot be sent, this function should be used to register a suitable
3776  * callback function to implement the desired behaviour.
3777  * The example callback "rte_eth_tx_buffer_count_callback()" is also
3778  * provided as reference.
3779  *
3780  * @param buffer
3781  *   The port identifier of the Ethernet device.
3782  * @param callback
3783  *   The function to be used as the callback.
3784  * @param userdata
3785  *   Arbitrary parameter to be passed to the callback function
3786  * @return
3787  *   0 on success, or -EINVAL if bad parameter
3788  */
3789 int
3790 rte_eth_tx_buffer_set_err_callback(struct rte_eth_dev_tx_buffer *buffer,
3791 		buffer_tx_error_fn callback, void *userdata);
3792 
3793 /**
3794  * Callback function for silently dropping unsent buffered packets.
3795  *
3796  * This function can be passed to rte_eth_tx_buffer_set_err_callback() to
3797  * adjust the default behavior when buffered packets cannot be sent. This
3798  * function drops any unsent packets silently and is used by Tx buffered
3799  * operations as default behavior.
3800  *
3801  * NOTE: this function should not be called directly, instead it should be used
3802  *       as a callback for packet buffering.
3803  *
3804  * NOTE: when configuring this function as a callback with
3805  *       rte_eth_tx_buffer_set_err_callback(), the final, userdata parameter
3806  *       should point to an uint64_t value.
3807  *
3808  * @param pkts
3809  *   The previously buffered packets which could not be sent
3810  * @param unsent
3811  *   The number of unsent packets in the pkts array
3812  * @param userdata
3813  *   Not used
3814  */
3815 void
3816 rte_eth_tx_buffer_drop_callback(struct rte_mbuf **pkts, uint16_t unsent,
3817 		void *userdata);
3818 
3819 /**
3820  * Callback function for tracking unsent buffered packets.
3821  *
3822  * This function can be passed to rte_eth_tx_buffer_set_err_callback() to
3823  * adjust the default behavior when buffered packets cannot be sent. This
3824  * function drops any unsent packets, but also updates a user-supplied counter
3825  * to track the overall number of packets dropped. The counter should be an
3826  * uint64_t variable.
3827  *
3828  * NOTE: this function should not be called directly, instead it should be used
3829  *       as a callback for packet buffering.
3830  *
3831  * NOTE: when configuring this function as a callback with
3832  *       rte_eth_tx_buffer_set_err_callback(), the final, userdata parameter
3833  *       should point to an uint64_t value.
3834  *
3835  * @param pkts
3836  *   The previously buffered packets which could not be sent
3837  * @param unsent
3838  *   The number of unsent packets in the pkts array
3839  * @param userdata
3840  *   Pointer to an uint64_t value, which will be incremented by unsent
3841  */
3842 void
3843 rte_eth_tx_buffer_count_callback(struct rte_mbuf **pkts, uint16_t unsent,
3844 		void *userdata);
3845 
3846 /**
3847  * Request the driver to free mbufs currently cached by the driver. The
3848  * driver will only free the mbuf if it is no longer in use. It is the
3849  * application's responsibility to ensure rte_eth_tx_buffer_flush(..) is
3850  * called if needed.
3851  *
3852  * @param port_id
3853  *   The port identifier of the Ethernet device.
3854  * @param queue_id
3855  *   The index of the transmit queue through which output packets must be
3856  *   sent.
3857  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
3858  *   to rte_eth_dev_configure().
3859  * @param free_cnt
3860  *   Maximum number of packets to free. Use 0 to indicate all possible packets
3861  *   should be freed. Note that a packet may be using multiple mbufs.
3862  * @return
3863  *   Failure: < 0
3864  *     -ENODEV: Invalid interface
3865  *     -EIO: device is removed
3866  *     -ENOTSUP: Driver does not support function
3867  *   Success: >= 0
3868  *     0-n: Number of packets freed. More packets may still remain in ring that
3869  *     are in use.
3870  */
3871 int
3872 rte_eth_tx_done_cleanup(uint16_t port_id, uint16_t queue_id, uint32_t free_cnt);
3873 
3874 /**
3875  * Subtypes for MACsec offload event (@ref RTE_ETH_EVENT_MACSEC)
3876  * raised by Ethernet device.
3877  */
3878 enum rte_eth_event_macsec_subtype {
3879 	/** Notifies unknown MACsec subevent. */
3880 	RTE_ETH_SUBEVENT_MACSEC_UNKNOWN,
3881 	/**
3882 	 * Subevent of RTE_ETH_EVENT_MACSEC_SECTAG_VAL_ERR sectag validation events
3883 	 *	Validation check: SecTag.TCI.V = 1
3884 	 */
3885 	RTE_ETH_SUBEVENT_MACSEC_RX_SECTAG_V_EQ1,
3886 	/**
3887 	 * Subevent of RTE_ETH_EVENT_MACSEC_SECTAG_VAL_ERR sectag validation events
3888 	 *	Validation check: SecTag.TCI.E = 0 && SecTag.TCI.C = 1
3889 	 */
3890 	RTE_ETH_SUBEVENT_MACSEC_RX_SECTAG_E_EQ0_C_EQ1,
3891 	/**
3892 	 * Subevent of RTE_ETH_EVENT_MACSEC_SECTAG_VAL_ERR sectag validation events
3893 	 *	Validation check: SecTag.SL >= 'd48
3894 	 */
3895 	RTE_ETH_SUBEVENT_MACSEC_RX_SECTAG_SL_GTE48,
3896 	/**
3897 	 * Subevent of RTE_ETH_EVENT_MACSEC_SECTAG_VAL_ERR sectag validation events
3898 	 *	Validation check: SecTag.TCI.ES = 1 && SecTag.TCI.SC = 1
3899 	 */
3900 	RTE_ETH_SUBEVENT_MACSEC_RX_SECTAG_ES_EQ1_SC_EQ1,
3901 	/**
3902 	 * Subevent of RTE_ETH_EVENT_MACSEC_SECTAG_VAL_ERR sectag validation events
3903 	 *	Validation check: SecTag.TCI.SC = 1 && SecTag.TCI.SCB = 1
3904 	 */
3905 	RTE_ETH_SUBEVENT_MACSEC_RX_SECTAG_SC_EQ1_SCB_EQ1,
3906 };
3907 
3908 /**
3909  * Event types for MACsec offload event (@ref RTE_ETH_EVENT_MACSEC)
3910  * raised by eth device.
3911  */
3912 enum rte_eth_event_macsec_type {
3913 	/** Notifies unknown MACsec event. */
3914 	RTE_ETH_EVENT_MACSEC_UNKNOWN,
3915 	/** Notifies Sectag validation failure events. */
3916 	RTE_ETH_EVENT_MACSEC_SECTAG_VAL_ERR,
3917 	/** Notifies Rx SA hard expiry events. */
3918 	RTE_ETH_EVENT_MACSEC_RX_SA_PN_HARD_EXP,
3919 	/** Notifies Rx SA soft expiry events. */
3920 	RTE_ETH_EVENT_MACSEC_RX_SA_PN_SOFT_EXP,
3921 	/** Notifies Tx SA hard expiry events. */
3922 	RTE_ETH_EVENT_MACSEC_TX_SA_PN_HARD_EXP,
3923 	/** Notifies Tx SA soft events. */
3924 	RTE_ETH_EVENT_MACSEC_TX_SA_PN_SOFT_EXP,
3925 	/** Notifies Invalid SA event. */
3926 	RTE_ETH_EVENT_MACSEC_SA_NOT_VALID,
3927 };
3928 
3929 /**
3930  * Descriptor for @ref RTE_ETH_EVENT_MACSEC event.
3931  * Used by ethdev to send extra information of the MACsec offload event.
3932  */
3933 struct rte_eth_event_macsec_desc {
3934 	/** Type of RTE_ETH_EVENT_MACSEC_* event. */
3935 	enum rte_eth_event_macsec_type type;
3936 	/** Type of RTE_ETH_SUBEVENT_MACSEC_* subevent. */
3937 	enum rte_eth_event_macsec_subtype subtype;
3938 	/**
3939 	 * Event specific metadata.
3940 	 *
3941 	 * For the following events, *userdata* registered
3942 	 * with the *rte_security_session* would be returned
3943 	 * as metadata.
3944 	 *
3945 	 * @see struct rte_security_session_conf
3946 	 */
3947 	uint64_t metadata;
3948 };
3949 
3950 /**
3951  * Subtypes for IPsec offload event(@ref RTE_ETH_EVENT_IPSEC) raised by
3952  * eth device.
3953  */
3954 enum rte_eth_event_ipsec_subtype {
3955 	/**  PMD specific error start */
3956 	RTE_ETH_EVENT_IPSEC_PMD_ERROR_START = -256,
3957 	/**  PMD specific error end */
3958 	RTE_ETH_EVENT_IPSEC_PMD_ERROR_END = -1,
3959 	/** Unknown event type */
3960 	RTE_ETH_EVENT_IPSEC_UNKNOWN = 0,
3961 	/** Sequence number overflow */
3962 	RTE_ETH_EVENT_IPSEC_ESN_OVERFLOW,
3963 	/** Soft time expiry of SA */
3964 	RTE_ETH_EVENT_IPSEC_SA_TIME_EXPIRY,
3965 	/**
3966 	 * Soft byte expiry of SA determined by
3967 	 * @ref rte_security_ipsec_lifetime::bytes_soft_limit
3968 	 */
3969 	RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY,
3970 	/**
3971 	 * Soft packet expiry of SA determined by
3972 	 * @ref rte_security_ipsec_lifetime::packets_soft_limit
3973 	 */
3974 	RTE_ETH_EVENT_IPSEC_SA_PKT_EXPIRY,
3975 	/**
3976 	 * Hard byte expiry of SA determined by
3977 	 * @ref rte_security_ipsec_lifetime::bytes_hard_limit
3978 	 */
3979 	RTE_ETH_EVENT_IPSEC_SA_BYTE_HARD_EXPIRY,
3980 	/**
3981 	 * Hard packet expiry of SA determined by
3982 	 * @ref rte_security_ipsec_lifetime::packets_hard_limit
3983 	 */
3984 	RTE_ETH_EVENT_IPSEC_SA_PKT_HARD_EXPIRY,
3985 	/** Max value of this enum */
3986 	RTE_ETH_EVENT_IPSEC_MAX
3987 };
3988 
3989 /**
3990  * Descriptor for @ref RTE_ETH_EVENT_IPSEC event. Used by eth dev to send extra
3991  * information of the IPsec offload event.
3992  */
3993 struct rte_eth_event_ipsec_desc {
3994 	/** Type of RTE_ETH_EVENT_IPSEC_* event */
3995 	enum rte_eth_event_ipsec_subtype subtype;
3996 	/**
3997 	 * Event specific metadata.
3998 	 *
3999 	 * For the following events, *userdata* registered
4000 	 * with the *rte_security_session* would be returned
4001 	 * as metadata,
4002 	 *
4003 	 * - @ref RTE_ETH_EVENT_IPSEC_ESN_OVERFLOW
4004 	 * - @ref RTE_ETH_EVENT_IPSEC_SA_TIME_EXPIRY
4005 	 * - @ref RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY
4006 	 * - @ref RTE_ETH_EVENT_IPSEC_SA_PKT_EXPIRY
4007 	 * - @ref RTE_ETH_EVENT_IPSEC_SA_BYTE_HARD_EXPIRY
4008 	 * - @ref RTE_ETH_EVENT_IPSEC_SA_PKT_HARD_EXPIRY
4009 	 *
4010 	 * @see struct rte_security_session_conf
4011 	 *
4012 	 */
4013 	uint64_t metadata;
4014 };
4015 
4016 /**
4017  * The eth device event type for interrupt, and maybe others in the future.
4018  */
4019 enum rte_eth_event_type {
4020 	RTE_ETH_EVENT_UNKNOWN,  /**< unknown event type */
4021 	RTE_ETH_EVENT_INTR_LSC, /**< lsc interrupt event */
4022 	/** queue state event (enabled/disabled) */
4023 	RTE_ETH_EVENT_QUEUE_STATE,
4024 	/** reset interrupt event, sent to VF on PF reset */
4025 	RTE_ETH_EVENT_INTR_RESET,
4026 	RTE_ETH_EVENT_VF_MBOX,  /**< message from the VF received by PF */
4027 	RTE_ETH_EVENT_MACSEC,   /**< MACsec offload related event */
4028 	RTE_ETH_EVENT_INTR_RMV, /**< device removal event */
4029 	RTE_ETH_EVENT_NEW,      /**< port is probed */
4030 	RTE_ETH_EVENT_DESTROY,  /**< port is released */
4031 	RTE_ETH_EVENT_IPSEC,    /**< IPsec offload related event */
4032 	RTE_ETH_EVENT_FLOW_AGED,/**< New aged-out flows is detected */
4033 	/**
4034 	 * Number of available Rx descriptors is smaller than the threshold.
4035 	 * @see rte_eth_rx_avail_thresh_set()
4036 	 */
4037 	RTE_ETH_EVENT_RX_AVAIL_THRESH,
4038 	/** Port recovering from a hardware or firmware error.
4039 	 * If PMD supports proactive error recovery,
4040 	 * it should trigger this event to notify application
4041 	 * that it detected an error and the recovery is being started.
4042 	 * Upon receiving the event, the application should not invoke any control path API
4043 	 * (such as rte_eth_dev_configure/rte_eth_dev_stop...) until receiving
4044 	 * RTE_ETH_EVENT_RECOVERY_SUCCESS or RTE_ETH_EVENT_RECOVERY_FAILED event.
4045 	 * The PMD will set the data path pointers to dummy functions,
4046 	 * and re-set the data path pointers to non-dummy functions
4047 	 * before reporting RTE_ETH_EVENT_RECOVERY_SUCCESS event.
4048 	 * It means that the application cannot send or receive any packets
4049 	 * during this period.
4050 	 * @note Before the PMD reports the recovery result,
4051 	 * the PMD may report the RTE_ETH_EVENT_ERR_RECOVERING event again,
4052 	 * because a larger error may occur during the recovery.
4053 	 */
4054 	RTE_ETH_EVENT_ERR_RECOVERING,
4055 	/** Port recovers successfully from the error.
4056 	 * The PMD already re-configured the port,
4057 	 * and the effect is the same as a restart operation.
4058 	 * a) The following operation will be retained: (alphabetically)
4059 	 *    - DCB configuration
4060 	 *    - FEC configuration
4061 	 *    - Flow control configuration
4062 	 *    - LRO configuration
4063 	 *    - LSC configuration
4064 	 *    - MTU
4065 	 *    - MAC address (default and those supplied by MAC address array)
4066 	 *    - Promiscuous and allmulticast mode
4067 	 *    - PTP configuration
4068 	 *    - Queue (Rx/Tx) settings
4069 	 *    - Queue statistics mappings
4070 	 *    - RSS configuration by rte_eth_dev_rss_xxx() family
4071 	 *    - Rx checksum configuration
4072 	 *    - Rx interrupt settings
4073 	 *    - Traffic management configuration
4074 	 *    - VLAN configuration (including filtering, tpid, strip, pvid)
4075 	 *    - VMDq configuration
4076 	 * b) The following configuration maybe retained
4077 	 *    or not depending on the device capabilities:
4078 	 *    - flow rules
4079 	 *      (@see RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP)
4080 	 *    - shared flow objects
4081 	 *      (@see RTE_ETH_DEV_CAPA_FLOW_SHARED_OBJECT_KEEP)
4082 	 * c) Any other configuration will not be stored
4083 	 *    and will need to be re-configured.
4084 	 */
4085 	RTE_ETH_EVENT_RECOVERY_SUCCESS,
4086 	/** Port recovery failed.
4087 	 * It means that the port should not be usable anymore.
4088 	 * The application should close the port.
4089 	 */
4090 	RTE_ETH_EVENT_RECOVERY_FAILED,
4091 	RTE_ETH_EVENT_MAX       /**< max value of this enum */
4092 };
4093 
4094 /**
4095  * User application callback to be registered for interrupts.
4096  *
4097  * Note: there is no guarantee in the DPDK drivers that a callback won't be
4098  *       called in the middle of other parts of the ethdev API. For example,
4099  *       imagine that thread A calls rte_eth_dev_start() and as part of this
4100  *       call, a RTE_ETH_EVENT_INTR_RESET event gets generated and the
4101  *       associated callback is ran on thread A. In that example, if the
4102  *       application protects its internal data using locks before calling
4103  *       rte_eth_dev_start(), and the callback takes a same lock, a deadlock
4104  *       occurs. Because of this, it is highly recommended NOT to take locks in
4105  *       those callbacks.
4106  */
4107 typedef int (*rte_eth_dev_cb_fn)(uint16_t port_id,
4108 		enum rte_eth_event_type event, void *cb_arg, void *ret_param);
4109 
4110 /**
4111  * Register a callback function for port event.
4112  *
4113  * @param port_id
4114  *  Port ID.
4115  *  RTE_ETH_ALL means register the event for all port ids.
4116  * @param event
4117  *  Event interested.
4118  * @param cb_fn
4119  *  User supplied callback function to be called.
4120  * @param cb_arg
4121  *  Pointer to the parameters for the registered callback.
4122  *
4123  * @return
4124  *  - On success, zero.
4125  *  - On failure, a negative value.
4126  */
4127 int rte_eth_dev_callback_register(uint16_t port_id,
4128 			enum rte_eth_event_type event,
4129 		rte_eth_dev_cb_fn cb_fn, void *cb_arg);
4130 
4131 /**
4132  * Unregister a callback function for port event.
4133  *
4134  * @param port_id
4135  *  Port ID.
4136  *  RTE_ETH_ALL means unregister the event for all port ids.
4137  * @param event
4138  *  Event interested.
4139  * @param cb_fn
4140  *  User supplied callback function to be called.
4141  * @param cb_arg
4142  *  Pointer to the parameters for the registered callback. -1 means to
4143  *  remove all for the same callback address and same event.
4144  *
4145  * @return
4146  *  - On success, zero.
4147  *  - On failure, a negative value.
4148  */
4149 int rte_eth_dev_callback_unregister(uint16_t port_id,
4150 			enum rte_eth_event_type event,
4151 		rte_eth_dev_cb_fn cb_fn, void *cb_arg);
4152 
4153 /**
4154  * When there is no Rx packet coming in Rx Queue for a long time, we can
4155  * sleep lcore related to Rx Queue for power saving, and enable Rx interrupt
4156  * to be triggered when Rx packet arrives.
4157  *
4158  * The rte_eth_dev_rx_intr_enable() function enables Rx queue
4159  * interrupt on specific Rx queue of a port.
4160  *
4161  * @param port_id
4162  *   The port identifier of the Ethernet device.
4163  * @param queue_id
4164  *   The index of the receive queue from which to retrieve input packets.
4165  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
4166  *   to rte_eth_dev_configure().
4167  * @return
4168  *   - (0) if successful.
4169  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
4170  *     that operation.
4171  *   - (-ENODEV) if *port_id* invalid.
4172  *   - (-EIO) if device is removed.
4173  */
4174 int rte_eth_dev_rx_intr_enable(uint16_t port_id, uint16_t queue_id);
4175 
4176 /**
4177  * When lcore wakes up from Rx interrupt indicating packet coming, disable Rx
4178  * interrupt and returns to polling mode.
4179  *
4180  * The rte_eth_dev_rx_intr_disable() function disables Rx queue
4181  * interrupt on specific Rx queue of a port.
4182  *
4183  * @param port_id
4184  *   The port identifier of the Ethernet device.
4185  * @param queue_id
4186  *   The index of the receive queue from which to retrieve input packets.
4187  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
4188  *   to rte_eth_dev_configure().
4189  * @return
4190  *   - (0) if successful.
4191  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
4192  *     that operation.
4193  *   - (-ENODEV) if *port_id* invalid.
4194  *   - (-EIO) if device is removed.
4195  */
4196 int rte_eth_dev_rx_intr_disable(uint16_t port_id, uint16_t queue_id);
4197 
4198 /**
4199  * Rx Interrupt control per port.
4200  *
4201  * @param port_id
4202  *   The port identifier of the Ethernet device.
4203  * @param epfd
4204  *   Epoll instance fd which the intr vector associated to.
4205  *   Using RTE_EPOLL_PER_THREAD allows to use per thread epoll instance.
4206  * @param op
4207  *   The operation be performed for the vector.
4208  *   Operation type of {RTE_INTR_EVENT_ADD, RTE_INTR_EVENT_DEL}.
4209  * @param data
4210  *   User raw data.
4211  * @return
4212  *   - On success, zero.
4213  *   - On failure, a negative value.
4214  */
4215 int rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data);
4216 
4217 /**
4218  * Rx Interrupt control per queue.
4219  *
4220  * @param port_id
4221  *   The port identifier of the Ethernet device.
4222  * @param queue_id
4223  *   The index of the receive queue from which to retrieve input packets.
4224  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
4225  *   to rte_eth_dev_configure().
4226  * @param epfd
4227  *   Epoll instance fd which the intr vector associated to.
4228  *   Using RTE_EPOLL_PER_THREAD allows to use per thread epoll instance.
4229  * @param op
4230  *   The operation be performed for the vector.
4231  *   Operation type of {RTE_INTR_EVENT_ADD, RTE_INTR_EVENT_DEL}.
4232  * @param data
4233  *   User raw data.
4234  * @return
4235  *   - On success, zero.
4236  *   - On failure, a negative value.
4237  */
4238 int rte_eth_dev_rx_intr_ctl_q(uint16_t port_id, uint16_t queue_id,
4239 			      int epfd, int op, void *data);
4240 
4241 /**
4242  * Get interrupt fd per Rx queue.
4243  *
4244  * @param port_id
4245  *   The port identifier of the Ethernet device.
4246  * @param queue_id
4247  *   The index of the receive queue from which to retrieve input packets.
4248  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
4249  *   to rte_eth_dev_configure().
4250  * @return
4251  *   - (>=0) the interrupt fd associated to the requested Rx queue if
4252  *           successful.
4253  *   - (-1) on error.
4254  */
4255 int
4256 rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t queue_id);
4257 
4258 /**
4259  * Turn on the LED on the Ethernet device.
4260  * This function turns on the LED on the Ethernet device.
4261  *
4262  * @param port_id
4263  *   The port identifier of the Ethernet device.
4264  * @return
4265  *   - (0) if successful.
4266  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
4267  *     that operation.
4268  *   - (-ENODEV) if *port_id* invalid.
4269  *   - (-EIO) if device is removed.
4270  */
4271 int  rte_eth_led_on(uint16_t port_id);
4272 
4273 /**
4274  * Turn off the LED on the Ethernet device.
4275  * This function turns off the LED on the Ethernet device.
4276  *
4277  * @param port_id
4278  *   The port identifier of the Ethernet device.
4279  * @return
4280  *   - (0) if successful.
4281  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
4282  *     that operation.
4283  *   - (-ENODEV) if *port_id* invalid.
4284  *   - (-EIO) if device is removed.
4285  */
4286 int  rte_eth_led_off(uint16_t port_id);
4287 
4288 /**
4289  * @warning
4290  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
4291  *
4292  * Get Forward Error Correction(FEC) capability.
4293  *
4294  * @param port_id
4295  *   The port identifier of the Ethernet device.
4296  * @param speed_fec_capa
4297  *   speed_fec_capa is out only with per-speed capabilities.
4298  *   If set to NULL, the function returns the required number
4299  *   of required array entries.
4300  * @param num
4301  *   a number of elements in an speed_fec_capa array.
4302  *
4303  * @return
4304  *   - A non-negative value lower or equal to num: success. The return value
4305  *     is the number of entries filled in the fec capa array.
4306  *   - A non-negative value higher than num: error, the given fec capa array
4307  *     is too small. The return value corresponds to the num that should
4308  *     be given to succeed. The entries in fec capa array are not valid and
4309  *     shall not be used by the caller.
4310  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
4311  *     that operation.
4312  *   - (-EIO) if device is removed.
4313  *   - (-ENODEV)  if *port_id* invalid.
4314  *   - (-EINVAL)  if *num* or *speed_fec_capa* invalid
4315  */
4316 __rte_experimental
4317 int rte_eth_fec_get_capability(uint16_t port_id,
4318 			       struct rte_eth_fec_capa *speed_fec_capa,
4319 			       unsigned int num);
4320 
4321 /**
4322  * @warning
4323  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
4324  *
4325  * Get current Forward Error Correction(FEC) mode.
4326  * If link is down and AUTO is enabled, AUTO is returned, otherwise,
4327  * configured FEC mode is returned.
4328  * If link is up, current FEC mode is returned.
4329  *
4330  * @param port_id
4331  *   The port identifier of the Ethernet device.
4332  * @param fec_capa
4333  *   A bitmask with the current FEC mode.
4334  * @return
4335  *   - (0) if successful.
4336  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
4337  *     that operation.
4338  *   - (-EIO) if device is removed.
4339  *   - (-ENODEV)  if *port_id* invalid.
4340  */
4341 __rte_experimental
4342 int rte_eth_fec_get(uint16_t port_id, uint32_t *fec_capa);
4343 
4344 /**
4345  * @warning
4346  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
4347  *
4348  * Set Forward Error Correction(FEC) mode.
4349  *
4350  * @param port_id
4351  *   The port identifier of the Ethernet device.
4352  * @param fec_capa
4353  *   A bitmask of allowed FEC modes.
4354  *   If only the AUTO bit is set, the decision on which FEC
4355  *   mode to use will be made by HW/FW or driver.
4356  *   If the AUTO bit is set with some FEC modes, only specified
4357  *   FEC modes can be set.
4358  *   If AUTO bit is clear, specify FEC mode to be used
4359  *   (only one valid mode per speed may be set).
4360  * @return
4361  *   - (0) if successful.
4362  *   - (-EINVAL) if the FEC mode is not valid.
4363  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
4364  *   - (-EIO) if device is removed.
4365  *   - (-ENODEV)  if *port_id* invalid.
4366  */
4367 __rte_experimental
4368 int rte_eth_fec_set(uint16_t port_id, uint32_t fec_capa);
4369 
4370 /**
4371  * Get current status of the Ethernet link flow control for Ethernet device
4372  *
4373  * @param port_id
4374  *   The port identifier of the Ethernet device.
4375  * @param fc_conf
4376  *   The pointer to the structure where to store the flow control parameters.
4377  * @return
4378  *   - (0) if successful.
4379  *   - (-ENOTSUP) if hardware doesn't support flow control.
4380  *   - (-ENODEV)  if *port_id* invalid.
4381  *   - (-EIO)  if device is removed.
4382  *   - (-EINVAL) if bad parameter.
4383  */
4384 int rte_eth_dev_flow_ctrl_get(uint16_t port_id,
4385 			      struct rte_eth_fc_conf *fc_conf);
4386 
4387 /**
4388  * Configure the Ethernet link flow control for Ethernet device
4389  *
4390  * @param port_id
4391  *   The port identifier of the Ethernet device.
4392  * @param fc_conf
4393  *   The pointer to the structure of the flow control parameters.
4394  * @return
4395  *   - (0) if successful.
4396  *   - (-ENOTSUP) if hardware doesn't support flow control mode.
4397  *   - (-ENODEV)  if *port_id* invalid.
4398  *   - (-EINVAL)  if bad parameter
4399  *   - (-EIO)     if flow control setup failure or device is removed.
4400  */
4401 int rte_eth_dev_flow_ctrl_set(uint16_t port_id,
4402 			      struct rte_eth_fc_conf *fc_conf);
4403 
4404 /**
4405  * Configure the Ethernet priority flow control under DCB environment
4406  * for Ethernet device.
4407  *
4408  * @param port_id
4409  * The port identifier of the Ethernet device.
4410  * @param pfc_conf
4411  * The pointer to the structure of the priority flow control parameters.
4412  * @return
4413  *   - (0) if successful.
4414  *   - (-ENOTSUP) if hardware doesn't support priority flow control mode.
4415  *   - (-ENODEV)  if *port_id* invalid.
4416  *   - (-EINVAL)  if bad parameter
4417  *   - (-EIO)     if flow control setup failure or device is removed.
4418  */
4419 int rte_eth_dev_priority_flow_ctrl_set(uint16_t port_id,
4420 				struct rte_eth_pfc_conf *pfc_conf);
4421 
4422 /**
4423  * Add a MAC address to the set used for filtering incoming packets.
4424  *
4425  * @param port_id
4426  *   The port identifier of the Ethernet device.
4427  * @param mac_addr
4428  *   The MAC address to add.
4429  * @param pool
4430  *   VMDq pool index to associate address with (if VMDq is enabled). If VMDq is
4431  *   not enabled, this should be set to 0.
4432  * @return
4433  *   - (0) if successfully added or *mac_addr* was already added.
4434  *   - (-ENOTSUP) if hardware doesn't support this feature.
4435  *   - (-ENODEV) if *port* is invalid.
4436  *   - (-EIO) if device is removed.
4437  *   - (-ENOSPC) if no more MAC addresses can be added.
4438  *   - (-EINVAL) if MAC address is invalid.
4439  */
4440 int rte_eth_dev_mac_addr_add(uint16_t port_id, struct rte_ether_addr *mac_addr,
4441 				uint32_t pool);
4442 
4443 /**
4444  * @warning
4445  * @b EXPERIMENTAL: this API may change without prior notice.
4446  *
4447  * Retrieve the information for queue based PFC.
4448  *
4449  * @param port_id
4450  *   The port identifier of the Ethernet device.
4451  * @param pfc_queue_info
4452  *   A pointer to a structure of type *rte_eth_pfc_queue_info* to be filled with
4453  *   the information about queue based PFC.
4454  * @return
4455  *   - (0) if successful.
4456  *   - (-ENOTSUP) if support for priority_flow_ctrl_queue_info_get does not exist.
4457  *   - (-ENODEV) if *port_id* invalid.
4458  *   - (-EINVAL) if bad parameter.
4459  */
4460 __rte_experimental
4461 int rte_eth_dev_priority_flow_ctrl_queue_info_get(uint16_t port_id,
4462 		struct rte_eth_pfc_queue_info *pfc_queue_info);
4463 
4464 /**
4465  * @warning
4466  * @b EXPERIMENTAL: this API may change without prior notice.
4467  *
4468  * Configure the queue based priority flow control for a given queue
4469  * for Ethernet device.
4470  *
4471  * @note When an ethdev port switches to queue based PFC mode, the
4472  * unconfigured queues shall be configured by the driver with
4473  * default values such as lower priority value for TC etc.
4474  *
4475  * @param port_id
4476  *   The port identifier of the Ethernet device.
4477  * @param pfc_queue_conf
4478  *   The pointer to the structure of the priority flow control parameters
4479  *   for the queue.
4480  * @return
4481  *   - (0) if successful.
4482  *   - (-ENOTSUP) if hardware doesn't support queue based PFC mode.
4483  *   - (-ENODEV)  if *port_id* invalid.
4484  *   - (-EINVAL)  if bad parameter
4485  *   - (-EIO)     if flow control setup queue failure
4486  */
4487 __rte_experimental
4488 int rte_eth_dev_priority_flow_ctrl_queue_configure(uint16_t port_id,
4489 		struct rte_eth_pfc_queue_conf *pfc_queue_conf);
4490 
4491 /**
4492  * Remove a MAC address from the internal array of addresses.
4493  *
4494  * @param port_id
4495  *   The port identifier of the Ethernet device.
4496  * @param mac_addr
4497  *   MAC address to remove.
4498  * @return
4499  *   - (0) if successful, or *mac_addr* didn't exist.
4500  *   - (-ENOTSUP) if hardware doesn't support.
4501  *   - (-ENODEV) if *port* invalid.
4502  *   - (-EADDRINUSE) if attempting to remove the default MAC address.
4503  *   - (-EINVAL) if MAC address is invalid.
4504  */
4505 int rte_eth_dev_mac_addr_remove(uint16_t port_id,
4506 				struct rte_ether_addr *mac_addr);
4507 
4508 /**
4509  * Set the default MAC address.
4510  * It replaces the address at index 0 of the MAC address list.
4511  * If the address was already in the MAC address list,
4512  * please remove it first.
4513  *
4514  * @param port_id
4515  *   The port identifier of the Ethernet device.
4516  * @param mac_addr
4517  *   New default MAC address.
4518  * @return
4519  *   - (0) if successful, or *mac_addr* didn't exist.
4520  *   - (-ENOTSUP) if hardware doesn't support.
4521  *   - (-ENODEV) if *port* invalid.
4522  *   - (-EINVAL) if MAC address is invalid.
4523  *   - (-EEXIST) if MAC address was already in the address list.
4524  */
4525 int rte_eth_dev_default_mac_addr_set(uint16_t port_id,
4526 		struct rte_ether_addr *mac_addr);
4527 
4528 /**
4529  * Update Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
4530  *
4531  * @param port_id
4532  *   The port identifier of the Ethernet device.
4533  * @param reta_conf
4534  *   RETA to update.
4535  * @param reta_size
4536  *   Redirection table size. The table size can be queried by
4537  *   rte_eth_dev_info_get().
4538  * @return
4539  *   - (0) if successful.
4540  *   - (-ENODEV) if *port_id* is invalid.
4541  *   - (-ENOTSUP) if hardware doesn't support.
4542  *   - (-EINVAL) if bad parameter.
4543  *   - (-EIO) if device is removed.
4544  */
4545 int rte_eth_dev_rss_reta_update(uint16_t port_id,
4546 				struct rte_eth_rss_reta_entry64 *reta_conf,
4547 				uint16_t reta_size);
4548 
4549 /**
4550  * Query Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
4551  *
4552  * @param port_id
4553  *   The port identifier of the Ethernet device.
4554  * @param reta_conf
4555  *   RETA to query. For each requested reta entry, corresponding bit
4556  *   in mask must be set.
4557  * @param reta_size
4558  *   Redirection table size. The table size can be queried by
4559  *   rte_eth_dev_info_get().
4560  * @return
4561  *   - (0) if successful.
4562  *   - (-ENODEV) if *port_id* is invalid.
4563  *   - (-ENOTSUP) if hardware doesn't support.
4564  *   - (-EINVAL) if bad parameter.
4565  *   - (-EIO) if device is removed.
4566  */
4567 int rte_eth_dev_rss_reta_query(uint16_t port_id,
4568 			       struct rte_eth_rss_reta_entry64 *reta_conf,
4569 			       uint16_t reta_size);
4570 
4571 /**
4572  * Updates unicast hash table for receiving packet with the given destination
4573  * MAC address, and the packet is routed to all VFs for which the Rx mode is
4574  * accept packets that match the unicast hash table.
4575  *
4576  * @param port_id
4577  *   The port identifier of the Ethernet device.
4578  * @param addr
4579  *   Unicast MAC address.
4580  * @param on
4581  *    1 - Set an unicast hash bit for receiving packets with the MAC address.
4582  *    0 - Clear an unicast hash bit.
4583  * @return
4584  *   - (0) if successful.
4585  *   - (-ENOTSUP) if hardware doesn't support.
4586  *   - (-ENODEV) if *port_id* invalid.
4587  *   - (-EIO) if device is removed.
4588  *   - (-EINVAL) if bad parameter.
4589  */
4590 int rte_eth_dev_uc_hash_table_set(uint16_t port_id, struct rte_ether_addr *addr,
4591 				  uint8_t on);
4592 
4593 /**
4594  * Updates all unicast hash bitmaps for receiving packet with any Unicast
4595  * Ethernet MAC addresses,the packet is routed to all VFs for which the Rx
4596  * mode is accept packets that match the unicast hash table.
4597  *
4598  * @param port_id
4599  *   The port identifier of the Ethernet device.
4600  * @param on
4601  *    1 - Set all unicast hash bitmaps for receiving all the Ethernet
4602  *         MAC addresses
4603  *    0 - Clear all unicast hash bitmaps
4604  * @return
4605  *   - (0) if successful.
4606  *   - (-ENOTSUP) if hardware doesn't support.
4607  *   - (-ENODEV) if *port_id* invalid.
4608  *   - (-EIO) if device is removed.
4609  *   - (-EINVAL) if bad parameter.
4610  */
4611 int rte_eth_dev_uc_all_hash_table_set(uint16_t port_id, uint8_t on);
4612 
4613 /**
4614  * Set the rate limitation for a queue on an Ethernet device.
4615  *
4616  * @param port_id
4617  *   The port identifier of the Ethernet device.
4618  * @param queue_idx
4619  *   The queue ID.
4620  * @param tx_rate
4621  *   The Tx rate in Mbps. Allocated from the total port link speed.
4622  * @return
4623  *   - (0) if successful.
4624  *   - (-ENOTSUP) if hardware doesn't support this feature.
4625  *   - (-ENODEV) if *port_id* invalid.
4626  *   - (-EIO) if device is removed.
4627  *   - (-EINVAL) if bad parameter.
4628  */
4629 int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx,
4630 			uint32_t tx_rate);
4631 
4632 /**
4633  * Configuration of Receive Side Scaling hash computation of Ethernet device.
4634  *
4635  * @param port_id
4636  *   The port identifier of the Ethernet device.
4637  * @param rss_conf
4638  *   The new configuration to use for RSS hash computation on the port.
4639  * @return
4640  *   - (0) if successful.
4641  *   - (-ENODEV) if port identifier is invalid.
4642  *   - (-EIO) if device is removed.
4643  *   - (-ENOTSUP) if hardware doesn't support.
4644  *   - (-EINVAL) if bad parameter.
4645  */
4646 int rte_eth_dev_rss_hash_update(uint16_t port_id,
4647 				struct rte_eth_rss_conf *rss_conf);
4648 
4649 /**
4650  * Retrieve current configuration of Receive Side Scaling hash computation
4651  * of Ethernet device.
4652  *
4653  * @param port_id
4654  *   The port identifier of the Ethernet device.
4655  * @param rss_conf
4656  *   Where to store the current RSS hash configuration of the Ethernet device.
4657  * @return
4658  *   - (0) if successful.
4659  *   - (-ENODEV) if port identifier is invalid.
4660  *   - (-EIO) if device is removed.
4661  *   - (-ENOTSUP) if hardware doesn't support RSS.
4662  *   - (-EINVAL) if bad parameter.
4663  */
4664 int
4665 rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
4666 			      struct rte_eth_rss_conf *rss_conf);
4667 
4668 /**
4669  * @warning
4670  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice.
4671  *
4672  *  Get the name of RSS hash algorithm.
4673  *
4674  * @param rss_algo
4675  *   Hash algorithm.
4676  *
4677  * @return
4678  *   Hash algorithm name or 'UNKNOWN' if the rss_algo cannot be recognized.
4679  */
4680 __rte_experimental
4681 const char *
4682 rte_eth_dev_rss_algo_name(enum rte_eth_hash_function rss_algo);
4683 
4684 /**
4685  * @warning
4686  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice.
4687  *
4688  * Get RSS hash algorithm by its name.
4689  *
4690  * @param name
4691  *   RSS hash algorithm.
4692  *
4693  * @param algo
4694  *   Return the RSS hash algorithm found, @see rte_eth_hash_function.
4695  *
4696  * @return
4697  *   - (0) if successful.
4698  *   - (-EINVAL) if not found.
4699  */
4700 __rte_experimental
4701 int
4702 rte_eth_find_rss_algo(const char *name, uint32_t *algo);
4703 
4704 /**
4705  * Add UDP tunneling port for a type of tunnel.
4706  *
4707  * Some NICs may require such configuration to properly parse a tunnel
4708  * with any standard or custom UDP port.
4709  * The packets with this UDP port will be parsed for this type of tunnel.
4710  * The device parser will also check the rest of the tunnel headers
4711  * before classifying the packet.
4712  *
4713  * With some devices, this API will affect packet classification, i.e.:
4714  *     - mbuf.packet_type reported on Rx
4715  *     - rte_flow rules with tunnel items
4716  *
4717  * @param port_id
4718  *   The port identifier of the Ethernet device.
4719  * @param tunnel_udp
4720  *   UDP tunneling configuration.
4721  *
4722  * @return
4723  *   - (0) if successful.
4724  *   - (-ENODEV) if port identifier is invalid.
4725  *   - (-EIO) if device is removed.
4726  *   - (-ENOTSUP) if hardware doesn't support tunnel type.
4727  */
4728 int
4729 rte_eth_dev_udp_tunnel_port_add(uint16_t port_id,
4730 				struct rte_eth_udp_tunnel *tunnel_udp);
4731 
4732 /**
4733  * Delete UDP tunneling port for a type of tunnel.
4734  *
4735  * The packets with this UDP port will not be classified as this type of tunnel
4736  * anymore if the device use such mapping for tunnel packet classification.
4737  *
4738  * @see rte_eth_dev_udp_tunnel_port_add
4739  *
4740  * @param port_id
4741  *   The port identifier of the Ethernet device.
4742  * @param tunnel_udp
4743  *   UDP tunneling configuration.
4744  *
4745  * @return
4746  *   - (0) if successful.
4747  *   - (-ENODEV) if port identifier is invalid.
4748  *   - (-EIO) if device is removed.
4749  *   - (-ENOTSUP) if hardware doesn't support tunnel type.
4750  */
4751 int
4752 rte_eth_dev_udp_tunnel_port_delete(uint16_t port_id,
4753 				   struct rte_eth_udp_tunnel *tunnel_udp);
4754 
4755 /**
4756  * Get DCB information on an Ethernet device.
4757  *
4758  * @param port_id
4759  *   The port identifier of the Ethernet device.
4760  * @param dcb_info
4761  *   DCB information.
4762  * @return
4763  *   - (0) if successful.
4764  *   - (-ENODEV) if port identifier is invalid.
4765  *   - (-EIO) if device is removed.
4766  *   - (-ENOTSUP) if hardware doesn't support.
4767  *   - (-EINVAL) if bad parameter.
4768  */
4769 int rte_eth_dev_get_dcb_info(uint16_t port_id,
4770 			     struct rte_eth_dcb_info *dcb_info);
4771 
4772 struct rte_eth_rxtx_callback;
4773 
4774 /**
4775  * Add a callback to be called on packet Rx on a given port and queue.
4776  *
4777  * This API configures a function to be called for each burst of
4778  * packets received on a given NIC port queue. The return value is a pointer
4779  * that can be used to later remove the callback using
4780  * rte_eth_remove_rx_callback().
4781  *
4782  * Multiple functions are called in the order that they are added.
4783  *
4784  * @param port_id
4785  *   The port identifier of the Ethernet device.
4786  * @param queue_id
4787  *   The queue on the Ethernet device on which the callback is to be added.
4788  * @param fn
4789  *   The callback function
4790  * @param user_param
4791  *   A generic pointer parameter which will be passed to each invocation of the
4792  *   callback function on this port and queue. Inter-thread synchronization
4793  *   of any user data changes is the responsibility of the user.
4794  *
4795  * @return
4796  *   NULL on error.
4797  *   On success, a pointer value which can later be used to remove the callback.
4798  */
4799 const struct rte_eth_rxtx_callback *
4800 rte_eth_add_rx_callback(uint16_t port_id, uint16_t queue_id,
4801 		rte_rx_callback_fn fn, void *user_param);
4802 
4803 /**
4804  * Add a callback that must be called first on packet Rx on a given port
4805  * and queue.
4806  *
4807  * This API configures a first function to be called for each burst of
4808  * packets received on a given NIC port queue. The return value is a pointer
4809  * that can be used to later remove the callback using
4810  * rte_eth_remove_rx_callback().
4811  *
4812  * Multiple functions are called in the order that they are added.
4813  *
4814  * @param port_id
4815  *   The port identifier of the Ethernet device.
4816  * @param queue_id
4817  *   The queue on the Ethernet device on which the callback is to be added.
4818  * @param fn
4819  *   The callback function
4820  * @param user_param
4821  *   A generic pointer parameter which will be passed to each invocation of the
4822  *   callback function on this port and queue. Inter-thread synchronization
4823  *   of any user data changes is the responsibility of the user.
4824  *
4825  * @return
4826  *   NULL on error.
4827  *   On success, a pointer value which can later be used to remove the callback.
4828  */
4829 const struct rte_eth_rxtx_callback *
4830 rte_eth_add_first_rx_callback(uint16_t port_id, uint16_t queue_id,
4831 		rte_rx_callback_fn fn, void *user_param);
4832 
4833 /**
4834  * Add a callback to be called on packet Tx on a given port and queue.
4835  *
4836  * This API configures a function to be called for each burst of
4837  * packets sent on a given NIC port queue. The return value is a pointer
4838  * that can be used to later remove the callback using
4839  * rte_eth_remove_tx_callback().
4840  *
4841  * Multiple functions are called in the order that they are added.
4842  *
4843  * @param port_id
4844  *   The port identifier of the Ethernet device.
4845  * @param queue_id
4846  *   The queue on the Ethernet device on which the callback is to be added.
4847  * @param fn
4848  *   The callback function
4849  * @param user_param
4850  *   A generic pointer parameter which will be passed to each invocation of the
4851  *   callback function on this port and queue. Inter-thread synchronization
4852  *   of any user data changes is the responsibility of the user.
4853  *
4854  * @return
4855  *   NULL on error.
4856  *   On success, a pointer value which can later be used to remove the callback.
4857  */
4858 const struct rte_eth_rxtx_callback *
4859 rte_eth_add_tx_callback(uint16_t port_id, uint16_t queue_id,
4860 		rte_tx_callback_fn fn, void *user_param);
4861 
4862 /**
4863  * Remove an Rx packet callback from a given port and queue.
4864  *
4865  * This function is used to removed callbacks that were added to a NIC port
4866  * queue using rte_eth_add_rx_callback().
4867  *
4868  * Note: the callback is removed from the callback list but it isn't freed
4869  * since the it may still be in use. The memory for the callback can be
4870  * subsequently freed back by the application by calling rte_free():
4871  *
4872  * - Immediately - if the port is stopped, or the user knows that no
4873  *   callbacks are in flight e.g. if called from the thread doing Rx/Tx
4874  *   on that queue.
4875  *
4876  * - After a short delay - where the delay is sufficient to allow any
4877  *   in-flight callbacks to complete. Alternately, the RCU mechanism can be
4878  *   used to detect when data plane threads have ceased referencing the
4879  *   callback memory.
4880  *
4881  * @param port_id
4882  *   The port identifier of the Ethernet device.
4883  * @param queue_id
4884  *   The queue on the Ethernet device from which the callback is to be removed.
4885  * @param user_cb
4886  *   User supplied callback created via rte_eth_add_rx_callback().
4887  *
4888  * @return
4889  *   - 0: Success. Callback was removed.
4890  *   - -ENODEV:  If *port_id* is invalid.
4891  *   - -ENOTSUP: Callback support is not available.
4892  *   - -EINVAL:  The queue_id is out of range, or the callback
4893  *               is NULL or not found for the port/queue.
4894  */
4895 int rte_eth_remove_rx_callback(uint16_t port_id, uint16_t queue_id,
4896 		const struct rte_eth_rxtx_callback *user_cb);
4897 
4898 /**
4899  * Remove a Tx packet callback from a given port and queue.
4900  *
4901  * This function is used to removed callbacks that were added to a NIC port
4902  * queue using rte_eth_add_tx_callback().
4903  *
4904  * Note: the callback is removed from the callback list but it isn't freed
4905  * since the it may still be in use. The memory for the callback can be
4906  * subsequently freed back by the application by calling rte_free():
4907  *
4908  * - Immediately - if the port is stopped, or the user knows that no
4909  *   callbacks are in flight e.g. if called from the thread doing Rx/Tx
4910  *   on that queue.
4911  *
4912  * - After a short delay - where the delay is sufficient to allow any
4913  *   in-flight callbacks to complete. Alternately, the RCU mechanism can be
4914  *   used to detect when data plane threads have ceased referencing the
4915  *   callback memory.
4916  *
4917  * @param port_id
4918  *   The port identifier of the Ethernet device.
4919  * @param queue_id
4920  *   The queue on the Ethernet device from which the callback is to be removed.
4921  * @param user_cb
4922  *   User supplied callback created via rte_eth_add_tx_callback().
4923  *
4924  * @return
4925  *   - 0: Success. Callback was removed.
4926  *   - -ENODEV:  If *port_id* is invalid.
4927  *   - -ENOTSUP: Callback support is not available.
4928  *   - -EINVAL:  The queue_id is out of range, or the callback
4929  *               is NULL or not found for the port/queue.
4930  */
4931 int rte_eth_remove_tx_callback(uint16_t port_id, uint16_t queue_id,
4932 		const struct rte_eth_rxtx_callback *user_cb);
4933 
4934 /**
4935  * Retrieve information about given port's Rx queue.
4936  *
4937  * @param port_id
4938  *   The port identifier of the Ethernet device.
4939  * @param queue_id
4940  *   The Rx queue on the Ethernet device for which information
4941  *   will be retrieved.
4942  * @param qinfo
4943  *   A pointer to a structure of type *rte_eth_rxq_info_info* to be filled with
4944  *   the information of the Ethernet device.
4945  *
4946  * @return
4947  *   - 0: Success
4948  *   - -ENODEV:  If *port_id* is invalid.
4949  *   - -ENOTSUP: routine is not supported by the device PMD.
4950  *   - -EINVAL:  The queue_id is out of range, or the queue
4951  *               is hairpin queue.
4952  */
4953 int rte_eth_rx_queue_info_get(uint16_t port_id, uint16_t queue_id,
4954 	struct rte_eth_rxq_info *qinfo);
4955 
4956 /**
4957  * Retrieve information about given port's Tx queue.
4958  *
4959  * @param port_id
4960  *   The port identifier of the Ethernet device.
4961  * @param queue_id
4962  *   The Tx queue on the Ethernet device for which information
4963  *   will be retrieved.
4964  * @param qinfo
4965  *   A pointer to a structure of type *rte_eth_txq_info_info* to be filled with
4966  *   the information of the Ethernet device.
4967  *
4968  * @return
4969  *   - 0: Success
4970  *   - -ENODEV:  If *port_id* is invalid.
4971  *   - -ENOTSUP: routine is not supported by the device PMD.
4972  *   - -EINVAL:  The queue_id is out of range, or the queue
4973  *               is hairpin queue.
4974  */
4975 int rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id,
4976 	struct rte_eth_txq_info *qinfo);
4977 
4978 /**
4979  * @warning
4980  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
4981  *
4982  * Retrieve information about given ports's Rx queue for recycling mbufs.
4983  *
4984  * @param port_id
4985  *   The port identifier of the Ethernet device.
4986  * @param queue_id
4987  *   The Rx queue on the Ethernet devicefor which information
4988  *   will be retrieved.
4989  * @param recycle_rxq_info
4990  *   A pointer to a structure of type *rte_eth_recycle_rxq_info* to be filled.
4991  *
4992  * @return
4993  *   - 0: Success
4994  *   - -ENODEV:  If *port_id* is invalid.
4995  *   - -ENOTSUP: routine is not supported by the device PMD.
4996  *   - -EINVAL:  The queue_id is out of range.
4997  */
4998 __rte_experimental
4999 int rte_eth_recycle_rx_queue_info_get(uint16_t port_id,
5000 		uint16_t queue_id,
5001 		struct rte_eth_recycle_rxq_info *recycle_rxq_info);
5002 
5003 /**
5004  * Retrieve information about the Rx packet burst mode.
5005  *
5006  * @param port_id
5007  *   The port identifier of the Ethernet device.
5008  * @param queue_id
5009  *   The Rx queue on the Ethernet device for which information
5010  *   will be retrieved.
5011  * @param mode
5012  *   A pointer to a structure of type *rte_eth_burst_mode* to be filled
5013  *   with the information of the packet burst mode.
5014  *
5015  * @return
5016  *   - 0: Success
5017  *   - -ENODEV:  If *port_id* is invalid.
5018  *   - -ENOTSUP: routine is not supported by the device PMD.
5019  *   - -EINVAL:  The queue_id is out of range.
5020  */
5021 int rte_eth_rx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
5022 	struct rte_eth_burst_mode *mode);
5023 
5024 /**
5025  * Retrieve information about the Tx packet burst mode.
5026  *
5027  * @param port_id
5028  *   The port identifier of the Ethernet device.
5029  * @param queue_id
5030  *   The Tx queue on the Ethernet device for which information
5031  *   will be retrieved.
5032  * @param mode
5033  *   A pointer to a structure of type *rte_eth_burst_mode* to be filled
5034  *   with the information of the packet burst mode.
5035  *
5036  * @return
5037  *   - 0: Success
5038  *   - -ENODEV:  If *port_id* is invalid.
5039  *   - -ENOTSUP: routine is not supported by the device PMD.
5040  *   - -EINVAL:  The queue_id is out of range.
5041  */
5042 int rte_eth_tx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
5043 	struct rte_eth_burst_mode *mode);
5044 
5045 /**
5046  * @warning
5047  * @b EXPERIMENTAL: this API may change without prior notice.
5048  *
5049  * Retrieve the monitor condition for a given receive queue.
5050  *
5051  * @param port_id
5052  *   The port identifier of the Ethernet device.
5053  * @param queue_id
5054  *   The Rx queue on the Ethernet device for which information
5055  *   will be retrieved.
5056  * @param pmc
5057  *   The pointer to power-optimized monitoring condition structure.
5058  *
5059  * @return
5060  *   - 0: Success.
5061  *   -ENOTSUP: Operation not supported.
5062  *   -EINVAL: Invalid parameters.
5063  *   -ENODEV: Invalid port ID.
5064  */
5065 __rte_experimental
5066 int rte_eth_get_monitor_addr(uint16_t port_id, uint16_t queue_id,
5067 		struct rte_power_monitor_cond *pmc);
5068 
5069 /**
5070  * Retrieve device registers and register attributes (number of registers and
5071  * register size)
5072  *
5073  * @param port_id
5074  *   The port identifier of the Ethernet device.
5075  * @param info
5076  *   Pointer to rte_dev_reg_info structure to fill in. If info->data is
5077  *   NULL the function fills in the width and length fields. If non-NULL
5078  *   the registers are put into the buffer pointed at by the data field.
5079  * @return
5080  *   - (0) if successful.
5081  *   - (-ENOTSUP) if hardware doesn't support.
5082  *   - (-EINVAL) if bad parameter.
5083  *   - (-ENODEV) if *port_id* invalid.
5084  *   - (-EIO) if device is removed.
5085  *   - others depends on the specific operations implementation.
5086  */
5087 int rte_eth_dev_get_reg_info(uint16_t port_id, struct rte_dev_reg_info *info);
5088 
5089 /**
5090  * Retrieve size of device EEPROM
5091  *
5092  * @param port_id
5093  *   The port identifier of the Ethernet device.
5094  * @return
5095  *   - (>=0) EEPROM size if successful.
5096  *   - (-ENOTSUP) if hardware doesn't support.
5097  *   - (-ENODEV) if *port_id* invalid.
5098  *   - (-EIO) if device is removed.
5099  *   - others depends on the specific operations implementation.
5100  */
5101 int rte_eth_dev_get_eeprom_length(uint16_t port_id);
5102 
5103 /**
5104  * Retrieve EEPROM and EEPROM attribute
5105  *
5106  * @param port_id
5107  *   The port identifier of the Ethernet device.
5108  * @param info
5109  *   The template includes buffer for return EEPROM data and
5110  *   EEPROM attributes to be filled.
5111  * @return
5112  *   - (0) if successful.
5113  *   - (-ENOTSUP) if hardware doesn't support.
5114  *   - (-EINVAL) if bad parameter.
5115  *   - (-ENODEV) if *port_id* invalid.
5116  *   - (-EIO) if device is removed.
5117  *   - others depends on the specific operations implementation.
5118  */
5119 int rte_eth_dev_get_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
5120 
5121 /**
5122  * Program EEPROM with provided data
5123  *
5124  * @param port_id
5125  *   The port identifier of the Ethernet device.
5126  * @param info
5127  *   The template includes EEPROM data for programming and
5128  *   EEPROM attributes to be filled
5129  * @return
5130  *   - (0) if successful.
5131  *   - (-ENOTSUP) if hardware doesn't support.
5132  *   - (-ENODEV) if *port_id* invalid.
5133  *   - (-EINVAL) if bad parameter.
5134  *   - (-EIO) if device is removed.
5135  *   - others depends on the specific operations implementation.
5136  */
5137 int rte_eth_dev_set_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
5138 
5139 /**
5140  * @warning
5141  * @b EXPERIMENTAL: this API may change without prior notice.
5142  *
5143  * Retrieve the type and size of plugin module EEPROM
5144  *
5145  * @param port_id
5146  *   The port identifier of the Ethernet device.
5147  * @param modinfo
5148  *   The type and size of plugin module EEPROM.
5149  * @return
5150  *   - (0) if successful.
5151  *   - (-ENOTSUP) if hardware doesn't support.
5152  *   - (-ENODEV) if *port_id* invalid.
5153  *   - (-EINVAL) if bad parameter.
5154  *   - (-EIO) if device is removed.
5155  *   - others depends on the specific operations implementation.
5156  */
5157 __rte_experimental
5158 int
5159 rte_eth_dev_get_module_info(uint16_t port_id,
5160 			    struct rte_eth_dev_module_info *modinfo);
5161 
5162 /**
5163  * @warning
5164  * @b EXPERIMENTAL: this API may change without prior notice.
5165  *
5166  * Retrieve the data of plugin module EEPROM
5167  *
5168  * @param port_id
5169  *   The port identifier of the Ethernet device.
5170  * @param info
5171  *   The template includes the plugin module EEPROM attributes, and the
5172  *   buffer for return plugin module EEPROM data.
5173  * @return
5174  *   - (0) if successful.
5175  *   - (-ENOTSUP) if hardware doesn't support.
5176  *   - (-EINVAL) if bad parameter.
5177  *   - (-ENODEV) if *port_id* invalid.
5178  *   - (-EIO) if device is removed.
5179  *   - others depends on the specific operations implementation.
5180  */
5181 __rte_experimental
5182 int
5183 rte_eth_dev_get_module_eeprom(uint16_t port_id,
5184 			      struct rte_dev_eeprom_info *info);
5185 
5186 /**
5187  * Set the list of multicast addresses to filter on an Ethernet device.
5188  *
5189  * @param port_id
5190  *   The port identifier of the Ethernet device.
5191  * @param mc_addr_set
5192  *   The array of multicast addresses to set. Equal to NULL when the function
5193  *   is invoked to flush the set of filtered addresses.
5194  * @param nb_mc_addr
5195  *   The number of multicast addresses in the *mc_addr_set* array. Equal to 0
5196  *   when the function is invoked to flush the set of filtered addresses.
5197  * @return
5198  *   - (0) if successful.
5199  *   - (-ENODEV) if *port_id* invalid.
5200  *   - (-EIO) if device is removed.
5201  *   - (-ENOTSUP) if PMD of *port_id* doesn't support multicast filtering.
5202  *   - (-ENOSPC) if *port_id* has not enough multicast filtering resources.
5203  *   - (-EINVAL) if bad parameter.
5204  */
5205 int rte_eth_dev_set_mc_addr_list(uint16_t port_id,
5206 				 struct rte_ether_addr *mc_addr_set,
5207 				 uint32_t nb_mc_addr);
5208 
5209 /**
5210  * Enable IEEE1588/802.1AS timestamping for an Ethernet device.
5211  *
5212  * @param port_id
5213  *   The port identifier of the Ethernet device.
5214  *
5215  * @return
5216  *   - 0: Success.
5217  *   - -ENODEV: The port ID is invalid.
5218  *   - -EIO: if device is removed.
5219  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
5220  */
5221 int rte_eth_timesync_enable(uint16_t port_id);
5222 
5223 /**
5224  * Disable IEEE1588/802.1AS timestamping for an Ethernet device.
5225  *
5226  * @param port_id
5227  *   The port identifier of the Ethernet device.
5228  *
5229  * @return
5230  *   - 0: Success.
5231  *   - -ENODEV: The port ID is invalid.
5232  *   - -EIO: if device is removed.
5233  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
5234  */
5235 int rte_eth_timesync_disable(uint16_t port_id);
5236 
5237 /**
5238  * Read an IEEE1588/802.1AS Rx timestamp from an Ethernet device.
5239  *
5240  * @param port_id
5241  *   The port identifier of the Ethernet device.
5242  * @param timestamp
5243  *   Pointer to the timestamp struct.
5244  * @param flags
5245  *   Device specific flags. Used to pass the Rx timesync register index to
5246  *   i40e. Unused in igb/ixgbe, pass 0 instead.
5247  *
5248  * @return
5249  *   - 0: Success.
5250  *   - -EINVAL: No timestamp is available.
5251  *   - -ENODEV: The port ID is invalid.
5252  *   - -EIO: if device is removed.
5253  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
5254  */
5255 int rte_eth_timesync_read_rx_timestamp(uint16_t port_id,
5256 		struct timespec *timestamp, uint32_t flags);
5257 
5258 /**
5259  * Read an IEEE1588/802.1AS Tx timestamp from an Ethernet device.
5260  *
5261  * @param port_id
5262  *   The port identifier of the Ethernet device.
5263  * @param timestamp
5264  *   Pointer to the timestamp struct.
5265  *
5266  * @return
5267  *   - 0: Success.
5268  *   - -EINVAL: No timestamp is available.
5269  *   - -ENODEV: The port ID is invalid.
5270  *   - -EIO: if device is removed.
5271  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
5272  */
5273 int rte_eth_timesync_read_tx_timestamp(uint16_t port_id,
5274 		struct timespec *timestamp);
5275 
5276 /**
5277  * Adjust the timesync clock on an Ethernet device.
5278  *
5279  * This is usually used in conjunction with other Ethdev timesync functions to
5280  * synchronize the device time using the IEEE1588/802.1AS protocol.
5281  *
5282  * @param port_id
5283  *   The port identifier of the Ethernet device.
5284  * @param delta
5285  *   The adjustment in nanoseconds.
5286  *
5287  * @return
5288  *   - 0: Success.
5289  *   - -ENODEV: The port ID is invalid.
5290  *   - -EIO: if device is removed.
5291  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
5292  */
5293 int rte_eth_timesync_adjust_time(uint16_t port_id, int64_t delta);
5294 
5295 /**
5296  * Read the time from the timesync clock on an Ethernet device.
5297  *
5298  * This is usually used in conjunction with other Ethdev timesync functions to
5299  * synchronize the device time using the IEEE1588/802.1AS protocol.
5300  *
5301  * @param port_id
5302  *   The port identifier of the Ethernet device.
5303  * @param time
5304  *   Pointer to the timespec struct that holds the time.
5305  *
5306  * @return
5307  *   - 0: Success.
5308  *   - -EINVAL: Bad parameter.
5309  */
5310 int rte_eth_timesync_read_time(uint16_t port_id, struct timespec *time);
5311 
5312 /**
5313  * Set the time of the timesync clock on an Ethernet device.
5314  *
5315  * This is usually used in conjunction with other Ethdev timesync functions to
5316  * synchronize the device time using the IEEE1588/802.1AS protocol.
5317  *
5318  * @param port_id
5319  *   The port identifier of the Ethernet device.
5320  * @param time
5321  *   Pointer to the timespec struct that holds the time.
5322  *
5323  * @return
5324  *   - 0: Success.
5325  *   - -EINVAL: No timestamp is available.
5326  *   - -ENODEV: The port ID is invalid.
5327  *   - -EIO: if device is removed.
5328  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
5329  */
5330 int rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *time);
5331 
5332 /**
5333  * @warning
5334  * @b EXPERIMENTAL: this API may change without prior notice.
5335  *
5336  * Read the current clock counter of an Ethernet device
5337  *
5338  * This returns the current raw clock value of an Ethernet device. It is
5339  * a raw amount of ticks, with no given time reference.
5340  * The value returned here is from the same clock than the one
5341  * filling timestamp field of Rx packets when using hardware timestamp
5342  * offload. Therefore it can be used to compute a precise conversion of
5343  * the device clock to the real time.
5344  *
5345  * E.g, a simple heuristic to derivate the frequency would be:
5346  * uint64_t start, end;
5347  * rte_eth_read_clock(port, start);
5348  * rte_delay_ms(100);
5349  * rte_eth_read_clock(port, end);
5350  * double freq = (end - start) * 10;
5351  *
5352  * Compute a common reference with:
5353  * uint64_t base_time_sec = current_time();
5354  * uint64_t base_clock;
5355  * rte_eth_read_clock(port, base_clock);
5356  *
5357  * Then, convert the raw mbuf timestamp with:
5358  * base_time_sec + (double)(*timestamp_dynfield(mbuf) - base_clock) / freq;
5359  *
5360  * This simple example will not provide a very good accuracy. One must
5361  * at least measure multiple times the frequency and do a regression.
5362  * To avoid deviation from the system time, the common reference can
5363  * be repeated from time to time. The integer division can also be
5364  * converted by a multiplication and a shift for better performance.
5365  *
5366  * @param port_id
5367  *   The port identifier of the Ethernet device.
5368  * @param clock
5369  *   Pointer to the uint64_t that holds the raw clock value.
5370  *
5371  * @return
5372  *   - 0: Success.
5373  *   - -ENODEV: The port ID is invalid.
5374  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
5375  *   - -EINVAL: if bad parameter.
5376  */
5377 __rte_experimental
5378 int
5379 rte_eth_read_clock(uint16_t port_id, uint64_t *clock);
5380 
5381 /**
5382  * Get the port ID from device name.
5383  * The device name should be specified as below:
5384  * - PCIe address (Domain:Bus:Device.Function), for example- 0000:2:00.0
5385  * - SoC device name, for example- fsl-gmac0
5386  * - vdev dpdk name, for example- net_[pcap0|null0|tap0]
5387  *
5388  * @param name
5389  *   PCI address or name of the device.
5390  * @param port_id
5391  *   Pointer to port identifier of the device.
5392  * @return
5393  *   - (0) if successful and port_id is filled.
5394  *   - (-ENODEV or -EINVAL) on failure.
5395  */
5396 int
5397 rte_eth_dev_get_port_by_name(const char *name, uint16_t *port_id);
5398 
5399 /**
5400  * Get the device name from port ID.
5401  * The device name is specified as below:
5402  * - PCIe address (Domain:Bus:Device.Function), for example- 0000:02:00.0
5403  * - SoC device name, for example- fsl-gmac0
5404  * - vdev dpdk name, for example- net_[pcap0|null0|tun0|tap0]
5405  *
5406  * @param port_id
5407  *   Port identifier of the device.
5408  * @param name
5409  *   Buffer of size RTE_ETH_NAME_MAX_LEN to store the name.
5410  * @return
5411  *   - (0) if successful.
5412  *   - (-ENODEV) if *port_id* is invalid.
5413  *   - (-EINVAL) on failure.
5414  */
5415 int
5416 rte_eth_dev_get_name_by_port(uint16_t port_id, char *name);
5417 
5418 /**
5419  * Check that numbers of Rx and Tx descriptors satisfy descriptors limits from
5420  * the Ethernet device information, otherwise adjust them to boundaries.
5421  *
5422  * @param port_id
5423  *   The port identifier of the Ethernet device.
5424  * @param nb_rx_desc
5425  *   A pointer to a uint16_t where the number of receive
5426  *   descriptors stored.
5427  * @param nb_tx_desc
5428  *   A pointer to a uint16_t where the number of transmit
5429  *   descriptors stored.
5430  * @return
5431  *   - (0) if successful.
5432  *   - (-ENOTSUP, -ENODEV or -EINVAL) on failure.
5433  */
5434 int rte_eth_dev_adjust_nb_rx_tx_desc(uint16_t port_id,
5435 				     uint16_t *nb_rx_desc,
5436 				     uint16_t *nb_tx_desc);
5437 
5438 /**
5439  * Test if a port supports specific mempool ops.
5440  *
5441  * @param port_id
5442  *   Port identifier of the Ethernet device.
5443  * @param [in] pool
5444  *   The name of the pool operations to test.
5445  * @return
5446  *   - 0: best mempool ops choice for this port.
5447  *   - 1: mempool ops are supported for this port.
5448  *   - -ENOTSUP: mempool ops not supported for this port.
5449  *   - -ENODEV: Invalid port Identifier.
5450  *   - -EINVAL: Pool param is null.
5451  */
5452 int
5453 rte_eth_dev_pool_ops_supported(uint16_t port_id, const char *pool);
5454 
5455 /**
5456  * Get the security context for the Ethernet device.
5457  *
5458  * @param port_id
5459  *   Port identifier of the Ethernet device
5460  * @return
5461  *   - NULL on error.
5462  *   - pointer to security context on success.
5463  */
5464 void *
5465 rte_eth_dev_get_sec_ctx(uint16_t port_id);
5466 
5467 /**
5468  * @warning
5469  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
5470  *
5471  * Query the device hairpin capabilities.
5472  *
5473  * @param port_id
5474  *   The port identifier of the Ethernet device.
5475  * @param cap
5476  *   Pointer to a structure that will hold the hairpin capabilities.
5477  * @return
5478  *   - (0) if successful.
5479  *   - (-ENOTSUP) if hardware doesn't support.
5480  *   - (-EINVAL) if bad parameter.
5481  */
5482 __rte_experimental
5483 int rte_eth_dev_hairpin_capability_get(uint16_t port_id,
5484 				       struct rte_eth_hairpin_cap *cap);
5485 
5486 /**
5487  * @warning
5488  * @b EXPERIMENTAL: this structure may change without prior notice.
5489  *
5490  * Ethernet device representor ID range entry
5491  */
5492 struct rte_eth_representor_range {
5493 	enum rte_eth_representor_type type; /**< Representor type */
5494 	int controller; /**< Controller index */
5495 	int pf; /**< Physical function index */
5496 	__extension__
5497 	union {
5498 		int vf; /**< VF start index */
5499 		int sf; /**< SF start index */
5500 	};
5501 	uint32_t id_base; /**< Representor ID start index */
5502 	uint32_t id_end;  /**< Representor ID end index */
5503 	char name[RTE_DEV_NAME_MAX_LEN]; /**< Representor name */
5504 };
5505 
5506 /**
5507  * @warning
5508  * @b EXPERIMENTAL: this structure may change without prior notice.
5509  *
5510  * Ethernet device representor information
5511  */
5512 struct rte_eth_representor_info {
5513 	uint16_t controller; /**< Controller ID of caller device. */
5514 	uint16_t pf; /**< Physical function ID of caller device. */
5515 	uint32_t nb_ranges_alloc; /**< Size of the ranges array. */
5516 	uint32_t nb_ranges; /**< Number of initialized ranges. */
5517 	struct rte_eth_representor_range ranges[];/**< Representor ID range. */
5518 };
5519 
5520 /**
5521  * Retrieve the representor info of the device.
5522  *
5523  * Get device representor info to be able to calculate a unique
5524  * representor ID. @see rte_eth_representor_id_get helper.
5525  *
5526  * @param port_id
5527  *   The port identifier of the device.
5528  * @param info
5529  *   A pointer to a representor info structure.
5530  *   NULL to return number of range entries and allocate memory
5531  *   for next call to store detail.
5532  *   The number of ranges that were written into this structure
5533  *   will be placed into its nb_ranges field. This number cannot be
5534  *   larger than the nb_ranges_alloc that by the user before calling
5535  *   this function. It can be smaller than the value returned by the
5536  *   function, however.
5537  * @return
5538  *   - (-ENOTSUP) if operation is not supported.
5539  *   - (-ENODEV) if *port_id* invalid.
5540  *   - (-EIO) if device is removed.
5541  *   - (>=0) number of available representor range entries.
5542  */
5543 __rte_experimental
5544 int rte_eth_representor_info_get(uint16_t port_id,
5545 				 struct rte_eth_representor_info *info);
5546 
5547 /** The NIC is able to deliver flag (if set) with packets to the PMD. */
5548 #define RTE_ETH_RX_METADATA_USER_FLAG RTE_BIT64(0)
5549 
5550 /** The NIC is able to deliver mark ID with packets to the PMD. */
5551 #define RTE_ETH_RX_METADATA_USER_MARK RTE_BIT64(1)
5552 
5553 /** The NIC is able to deliver tunnel ID with packets to the PMD. */
5554 #define RTE_ETH_RX_METADATA_TUNNEL_ID RTE_BIT64(2)
5555 
5556 /**
5557  * Negotiate the NIC's ability to deliver specific kinds of metadata to the PMD.
5558  *
5559  * Invoke this API before the first rte_eth_dev_configure() invocation
5560  * to let the PMD make preparations that are inconvenient to do later.
5561  *
5562  * The negotiation process is as follows:
5563  *
5564  * - the application requests features intending to use at least some of them;
5565  * - the PMD responds with the guaranteed subset of the requested feature set;
5566  * - the application can retry negotiation with another set of features;
5567  * - the application can pass zero to clear the negotiation result;
5568  * - the last negotiated result takes effect upon
5569  *   the ethdev configure and start.
5570  *
5571  * @note
5572  *   The PMD is supposed to first consider enabling the requested feature set
5573  *   in its entirety. Only if it fails to do so, does it have the right to
5574  *   respond with a smaller set of the originally requested features.
5575  *
5576  * @note
5577  *   Return code (-ENOTSUP) does not necessarily mean that the requested
5578  *   features are unsupported. In this case, the application should just
5579  *   assume that these features can be used without prior negotiations.
5580  *
5581  * @param port_id
5582  *   Port (ethdev) identifier
5583  *
5584  * @param[inout] features
5585  *   Feature selection buffer
5586  *
5587  * @return
5588  *   - (-EBUSY) if the port can't handle this in its current state;
5589  *   - (-ENOTSUP) if the method itself is not supported by the PMD;
5590  *   - (-ENODEV) if *port_id* is invalid;
5591  *   - (-EINVAL) if *features* is NULL;
5592  *   - (-EIO) if the device is removed;
5593  *   - (0) on success
5594  */
5595 int rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features);
5596 
5597 /** Flag to offload IP reassembly for IPv4 packets. */
5598 #define RTE_ETH_DEV_REASSEMBLY_F_IPV4 (RTE_BIT32(0))
5599 /** Flag to offload IP reassembly for IPv6 packets. */
5600 #define RTE_ETH_DEV_REASSEMBLY_F_IPV6 (RTE_BIT32(1))
5601 
5602 /**
5603  * A structure used to get/set IP reassembly configuration. It is also used
5604  * to get the maximum capability values that a PMD can support.
5605  *
5606  * If rte_eth_ip_reassembly_capability_get() returns 0, IP reassembly can be
5607  * enabled using rte_eth_ip_reassembly_conf_set() and params values lower than
5608  * capability params can be set in the PMD.
5609  */
5610 struct rte_eth_ip_reassembly_params {
5611 	/** Maximum time in ms which PMD can wait for other fragments. */
5612 	uint32_t timeout_ms;
5613 	/** Maximum number of fragments that can be reassembled. */
5614 	uint16_t max_frags;
5615 	/**
5616 	 * Flags to enable reassembly of packet types -
5617 	 * RTE_ETH_DEV_REASSEMBLY_F_xxx.
5618 	 */
5619 	uint16_t flags;
5620 };
5621 
5622 /**
5623  * @warning
5624  * @b EXPERIMENTAL: this API may change without prior notice
5625  *
5626  * Get IP reassembly capabilities supported by the PMD. This is the first API
5627  * to be called for enabling the IP reassembly offload feature. PMD will return
5628  * the maximum values of parameters that PMD can support and user can call
5629  * rte_eth_ip_reassembly_conf_set() with param values lower than capability.
5630  *
5631  * @param port_id
5632  *   The port identifier of the device.
5633  * @param capa
5634  *   A pointer to rte_eth_ip_reassembly_params structure.
5635  * @return
5636  *   - (-ENOTSUP) if offload configuration is not supported by device.
5637  *   - (-ENODEV) if *port_id* invalid.
5638  *   - (-EIO) if device is removed.
5639  *   - (-EINVAL) if device is not configured or *capa* passed is NULL.
5640  *   - (0) on success.
5641  */
5642 __rte_experimental
5643 int rte_eth_ip_reassembly_capability_get(uint16_t port_id,
5644 		struct rte_eth_ip_reassembly_params *capa);
5645 
5646 /**
5647  * @warning
5648  * @b EXPERIMENTAL: this API may change without prior notice
5649  *
5650  * Get IP reassembly configuration parameters currently set in PMD.
5651  * The API will return error if the configuration is not already
5652  * set using rte_eth_ip_reassembly_conf_set() before calling this API or if
5653  * the device is not configured.
5654  *
5655  * @param port_id
5656  *   The port identifier of the device.
5657  * @param conf
5658  *   A pointer to rte_eth_ip_reassembly_params structure.
5659  * @return
5660  *   - (-ENOTSUP) if offload configuration is not supported by device.
5661  *   - (-ENODEV) if *port_id* invalid.
5662  *   - (-EIO) if device is removed.
5663  *   - (-EINVAL) if device is not configured or if *conf* passed is NULL or if
5664  *              configuration is not set using rte_eth_ip_reassembly_conf_set().
5665  *   - (0) on success.
5666  */
5667 __rte_experimental
5668 int rte_eth_ip_reassembly_conf_get(uint16_t port_id,
5669 		struct rte_eth_ip_reassembly_params *conf);
5670 
5671 /**
5672  * @warning
5673  * @b EXPERIMENTAL: this API may change without prior notice
5674  *
5675  * Set IP reassembly configuration parameters if the PMD supports IP reassembly
5676  * offload. User should first call rte_eth_ip_reassembly_capability_get() to
5677  * check the maximum values supported by the PMD before setting the
5678  * configuration. The use of this API is mandatory to enable this feature and
5679  * should be called before rte_eth_dev_start().
5680  *
5681  * In datapath, PMD cannot guarantee that IP reassembly is always successful.
5682  * Hence, PMD shall register mbuf dynamic field and dynamic flag using
5683  * rte_eth_ip_reassembly_dynfield_register() to denote incomplete IP reassembly.
5684  * If dynfield is not successfully registered, error will be returned and
5685  * IP reassembly offload cannot be used.
5686  *
5687  * @param port_id
5688  *   The port identifier of the device.
5689  * @param conf
5690  *   A pointer to rte_eth_ip_reassembly_params structure.
5691  * @return
5692  *   - (-ENOTSUP) if offload configuration is not supported by device.
5693  *   - (-ENODEV) if *port_id* invalid.
5694  *   - (-EIO) if device is removed.
5695  *   - (-EINVAL) if device is not configured or if device is already started or
5696  *               if *conf* passed is NULL or if mbuf dynfield is not registered
5697  *               successfully by the PMD.
5698  *   - (0) on success.
5699  */
5700 __rte_experimental
5701 int rte_eth_ip_reassembly_conf_set(uint16_t port_id,
5702 		const struct rte_eth_ip_reassembly_params *conf);
5703 
5704 /**
5705  * In case of IP reassembly offload failure, packet will be updated with
5706  * dynamic flag - RTE_MBUF_DYNFLAG_IP_REASSEMBLY_INCOMPLETE_NAME and packets
5707  * will be returned without alteration.
5708  * The application can retrieve the attached fragments using mbuf dynamic field
5709  * RTE_MBUF_DYNFIELD_IP_REASSEMBLY_NAME.
5710  */
5711 typedef struct {
5712 	/**
5713 	 * Next fragment packet. Application should fetch dynamic field of
5714 	 * each fragment until a NULL is received and nb_frags is 0.
5715 	 */
5716 	struct rte_mbuf *next_frag;
5717 	/** Time spent(in ms) by HW in waiting for further fragments. */
5718 	uint16_t time_spent;
5719 	/** Number of more fragments attached in mbuf dynamic fields. */
5720 	uint16_t nb_frags;
5721 } rte_eth_ip_reassembly_dynfield_t;
5722 
5723 /**
5724  * @warning
5725  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
5726  *
5727  * Dump private info from device to a file. Provided data and the order depends
5728  * on the PMD.
5729  *
5730  * @param port_id
5731  *   The port identifier of the Ethernet device.
5732  * @param file
5733  *   A pointer to a file for output.
5734  * @return
5735  *   - (0) on success.
5736  *   - (-ENODEV) if *port_id* is invalid.
5737  *   - (-EINVAL) if null file.
5738  *   - (-ENOTSUP) if the device does not support this function.
5739  *   - (-EIO) if device is removed.
5740  */
5741 __rte_experimental
5742 int rte_eth_dev_priv_dump(uint16_t port_id, FILE *file);
5743 
5744 /**
5745  * @warning
5746  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
5747  *
5748  * Dump ethdev Rx descriptor info to a file.
5749  *
5750  * This API is used for debugging, not a dataplane API.
5751  *
5752  * @param port_id
5753  *   The port identifier of the Ethernet device.
5754  * @param queue_id
5755  *   A Rx queue identifier on this port.
5756  * @param offset
5757  *  The offset of the descriptor starting from tail. (0 is the next
5758  *  packet to be received by the driver).
5759  * @param num
5760  *   The number of the descriptors to dump.
5761  * @param file
5762  *   A pointer to a file for output.
5763  * @return
5764  *   - On success, zero.
5765  *   - On failure, a negative value.
5766  */
5767 __rte_experimental
5768 int rte_eth_rx_descriptor_dump(uint16_t port_id, uint16_t queue_id,
5769 			       uint16_t offset, uint16_t num, FILE *file);
5770 
5771 /**
5772  * @warning
5773  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
5774  *
5775  * Dump ethdev Tx descriptor info to a file.
5776  *
5777  * This API is used for debugging, not a dataplane API.
5778  *
5779  * @param port_id
5780  *   The port identifier of the Ethernet device.
5781  * @param queue_id
5782  *   A Tx queue identifier on this port.
5783  * @param offset
5784  *  The offset of the descriptor starting from tail. (0 is the place where
5785  *  the next packet will be send).
5786  * @param num
5787  *   The number of the descriptors to dump.
5788  * @param file
5789  *   A pointer to a file for output.
5790  * @return
5791  *   - On success, zero.
5792  *   - On failure, a negative value.
5793  */
5794 __rte_experimental
5795 int rte_eth_tx_descriptor_dump(uint16_t port_id, uint16_t queue_id,
5796 			       uint16_t offset, uint16_t num, FILE *file);
5797 
5798 
5799 /* Congestion management */
5800 
5801 /** Enumerate list of ethdev congestion management objects */
5802 enum rte_eth_cman_obj {
5803 	/** Congestion management based on Rx queue depth */
5804 	RTE_ETH_CMAN_OBJ_RX_QUEUE = RTE_BIT32(0),
5805 	/**
5806 	 * Congestion management based on mempool depth associated with Rx queue
5807 	 * @see rte_eth_rx_queue_setup()
5808 	 */
5809 	RTE_ETH_CMAN_OBJ_RX_QUEUE_MEMPOOL = RTE_BIT32(1),
5810 };
5811 
5812 /**
5813  * @warning
5814  * @b EXPERIMENTAL: this structure may change, or be removed, without prior notice
5815  *
5816  * A structure used to retrieve information of ethdev congestion management.
5817  */
5818 struct rte_eth_cman_info {
5819 	/**
5820 	 * Set of supported congestion management modes
5821 	 * @see enum rte_cman_mode
5822 	 */
5823 	uint64_t modes_supported;
5824 	/**
5825 	 * Set of supported congestion management objects
5826 	 * @see enum rte_eth_cman_obj
5827 	 */
5828 	uint64_t objs_supported;
5829 	/**
5830 	 * Reserved for future fields. Always returned as 0 when
5831 	 * rte_eth_cman_info_get() is invoked
5832 	 */
5833 	uint8_t rsvd[8];
5834 };
5835 
5836 /**
5837  * @warning
5838  * @b EXPERIMENTAL: this structure may change, or be removed, without prior notice
5839  *
5840  * A structure used to configure the ethdev congestion management.
5841  */
5842 struct rte_eth_cman_config {
5843 	/** Congestion management object */
5844 	enum rte_eth_cman_obj obj;
5845 	/** Congestion management mode */
5846 	enum rte_cman_mode mode;
5847 	union {
5848 		/**
5849 		 * Rx queue to configure congestion management.
5850 		 *
5851 		 * Valid when object is RTE_ETH_CMAN_OBJ_RX_QUEUE or
5852 		 * RTE_ETH_CMAN_OBJ_RX_QUEUE_MEMPOOL.
5853 		 */
5854 		uint16_t rx_queue;
5855 		/**
5856 		 * Reserved for future fields.
5857 		 * It must be set to 0 when rte_eth_cman_config_set() is invoked
5858 		 * and will be returned as 0 when rte_eth_cman_config_get() is
5859 		 * invoked.
5860 		 */
5861 		uint8_t rsvd_obj_params[4];
5862 	} obj_param;
5863 	union {
5864 		/**
5865 		 * RED configuration parameters.
5866 		 *
5867 		 * Valid when mode is RTE_CMAN_RED.
5868 		 */
5869 		struct rte_cman_red_params red;
5870 		/**
5871 		 * Reserved for future fields.
5872 		 * It must be set to 0 when rte_eth_cman_config_set() is invoked
5873 		 * and will be returned as 0 when rte_eth_cman_config_get() is
5874 		 * invoked.
5875 		 */
5876 		uint8_t rsvd_mode_params[4];
5877 	} mode_param;
5878 };
5879 
5880 /**
5881  * @warning
5882  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
5883  *
5884  * Retrieve the information for ethdev congestion management
5885  *
5886  * @param port_id
5887  *   The port identifier of the Ethernet device.
5888  * @param info
5889  *   A pointer to a structure of type *rte_eth_cman_info* to be filled with
5890  *   the information about congestion management.
5891  * @return
5892  *   - (0) if successful.
5893  *   - (-ENOTSUP) if support for cman_info_get does not exist.
5894  *   - (-ENODEV) if *port_id* invalid.
5895  *   - (-EINVAL) if bad parameter.
5896  */
5897 __rte_experimental
5898 int rte_eth_cman_info_get(uint16_t port_id, struct rte_eth_cman_info *info);
5899 
5900 /**
5901  * @warning
5902  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
5903  *
5904  * Initialize the ethdev congestion management configuration structure with default values.
5905  *
5906  * @param port_id
5907  *   The port identifier of the Ethernet device.
5908  * @param config
5909  *   A pointer to a structure of type *rte_eth_cman_config* to be initialized
5910  *   with default value.
5911  * @return
5912  *   - (0) if successful.
5913  *   - (-ENOTSUP) if support for cman_config_init does not exist.
5914  *   - (-ENODEV) if *port_id* invalid.
5915  *   - (-EINVAL) if bad parameter.
5916  */
5917 __rte_experimental
5918 int rte_eth_cman_config_init(uint16_t port_id, struct rte_eth_cman_config *config);
5919 
5920 /**
5921  * @warning
5922  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
5923  *
5924  * Configure ethdev congestion management
5925  *
5926  * @param port_id
5927  *   The port identifier of the Ethernet device.
5928  * @param config
5929  *   A pointer to a structure of type *rte_eth_cman_config* to be configured.
5930  * @return
5931  *   - (0) if successful.
5932  *   - (-ENOTSUP) if support for cman_config_set does not exist.
5933  *   - (-ENODEV) if *port_id* invalid.
5934  *   - (-EINVAL) if bad parameter.
5935  */
5936 __rte_experimental
5937 int rte_eth_cman_config_set(uint16_t port_id, const struct rte_eth_cman_config *config);
5938 
5939 /**
5940  * @warning
5941  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
5942  *
5943  * Retrieve the applied ethdev congestion management parameters for the given port.
5944  *
5945  * @param port_id
5946  *   The port identifier of the Ethernet device.
5947  * @param config
5948  *   A pointer to a structure of type *rte_eth_cman_config* to retrieve
5949  *   congestion management parameters for the given object.
5950  *   Application must fill all parameters except mode_param parameter in
5951  *   struct rte_eth_cman_config.
5952  *
5953  * @return
5954  *   - (0) if successful.
5955  *   - (-ENOTSUP) if support for cman_config_get does not exist.
5956  *   - (-ENODEV) if *port_id* invalid.
5957  *   - (-EINVAL) if bad parameter.
5958  */
5959 __rte_experimental
5960 int rte_eth_cman_config_get(uint16_t port_id, struct rte_eth_cman_config *config);
5961 
5962 #include <rte_ethdev_core.h>
5963 
5964 /**
5965  * @internal
5966  * Helper routine for rte_eth_rx_burst().
5967  * Should be called at exit from PMD's rte_eth_rx_bulk implementation.
5968  * Does necessary post-processing - invokes Rx callbacks if any, etc.
5969  *
5970  * @param port_id
5971  *  The port identifier of the Ethernet device.
5972  * @param queue_id
5973  *  The index of the receive queue from which to retrieve input packets.
5974  * @param rx_pkts
5975  *   The address of an array of pointers to *rte_mbuf* structures that
5976  *   have been retrieved from the device.
5977  * @param nb_rx
5978  *   The number of packets that were retrieved from the device.
5979  * @param nb_pkts
5980  *   The number of elements in @p rx_pkts array.
5981  * @param opaque
5982  *   Opaque pointer of Rx queue callback related data.
5983  *
5984  * @return
5985  *  The number of packets effectively supplied to the @p rx_pkts array.
5986  */
5987 uint16_t rte_eth_call_rx_callbacks(uint16_t port_id, uint16_t queue_id,
5988 		struct rte_mbuf **rx_pkts, uint16_t nb_rx, uint16_t nb_pkts,
5989 		void *opaque);
5990 
5991 /**
5992  *
5993  * Retrieve a burst of input packets from a receive queue of an Ethernet
5994  * device. The retrieved packets are stored in *rte_mbuf* structures whose
5995  * pointers are supplied in the *rx_pkts* array.
5996  *
5997  * The rte_eth_rx_burst() function loops, parsing the Rx ring of the
5998  * receive queue, up to *nb_pkts* packets, and for each completed Rx
5999  * descriptor in the ring, it performs the following operations:
6000  *
6001  * - Initialize the *rte_mbuf* data structure associated with the
6002  *   Rx descriptor according to the information provided by the NIC into
6003  *   that Rx descriptor.
6004  *
6005  * - Store the *rte_mbuf* data structure into the next entry of the
6006  *   *rx_pkts* array.
6007  *
6008  * - Replenish the Rx descriptor with a new *rte_mbuf* buffer
6009  *   allocated from the memory pool associated with the receive queue at
6010  *   initialization time.
6011  *
6012  * When retrieving an input packet that was scattered by the controller
6013  * into multiple receive descriptors, the rte_eth_rx_burst() function
6014  * appends the associated *rte_mbuf* buffers to the first buffer of the
6015  * packet.
6016  *
6017  * The rte_eth_rx_burst() function returns the number of packets
6018  * actually retrieved, which is the number of *rte_mbuf* data structures
6019  * effectively supplied into the *rx_pkts* array.
6020  * A return value equal to *nb_pkts* indicates that the Rx queue contained
6021  * at least *rx_pkts* packets, and this is likely to signify that other
6022  * received packets remain in the input queue. Applications implementing
6023  * a "retrieve as much received packets as possible" policy can check this
6024  * specific case and keep invoking the rte_eth_rx_burst() function until
6025  * a value less than *nb_pkts* is returned.
6026  *
6027  * This receive method has the following advantages:
6028  *
6029  * - It allows a run-to-completion network stack engine to retrieve and
6030  *   to immediately process received packets in a fast burst-oriented
6031  *   approach, avoiding the overhead of unnecessary intermediate packet
6032  *   queue/dequeue operations.
6033  *
6034  * - Conversely, it also allows an asynchronous-oriented processing
6035  *   method to retrieve bursts of received packets and to immediately
6036  *   queue them for further parallel processing by another logical core,
6037  *   for instance. However, instead of having received packets being
6038  *   individually queued by the driver, this approach allows the caller
6039  *   of the rte_eth_rx_burst() function to queue a burst of retrieved
6040  *   packets at a time and therefore dramatically reduce the cost of
6041  *   enqueue/dequeue operations per packet.
6042  *
6043  * - It allows the rte_eth_rx_burst() function of the driver to take
6044  *   advantage of burst-oriented hardware features (CPU cache,
6045  *   prefetch instructions, and so on) to minimize the number of CPU
6046  *   cycles per packet.
6047  *
6048  * To summarize, the proposed receive API enables many
6049  * burst-oriented optimizations in both synchronous and asynchronous
6050  * packet processing environments with no overhead in both cases.
6051  *
6052  * @note
6053  *   Some drivers using vector instructions require that *nb_pkts* is
6054  *   divisible by 4 or 8, depending on the driver implementation.
6055  *
6056  * The rte_eth_rx_burst() function does not provide any error
6057  * notification to avoid the corresponding overhead. As a hint, the
6058  * upper-level application might check the status of the device link once
6059  * being systematically returned a 0 value for a given number of tries.
6060  *
6061  * @param port_id
6062  *   The port identifier of the Ethernet device.
6063  * @param queue_id
6064  *   The index of the receive queue from which to retrieve input packets.
6065  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
6066  *   to rte_eth_dev_configure().
6067  * @param rx_pkts
6068  *   The address of an array of pointers to *rte_mbuf* structures that
6069  *   must be large enough to store *nb_pkts* pointers in it.
6070  * @param nb_pkts
6071  *   The maximum number of packets to retrieve.
6072  *   The value must be divisible by 8 in order to work with any driver.
6073  * @return
6074  *   The number of packets actually retrieved, which is the number
6075  *   of pointers to *rte_mbuf* structures effectively supplied to the
6076  *   *rx_pkts* array.
6077  */
6078 static inline uint16_t
6079 rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id,
6080 		 struct rte_mbuf **rx_pkts, const uint16_t nb_pkts)
6081 {
6082 	uint16_t nb_rx;
6083 	struct rte_eth_fp_ops *p;
6084 	void *qd;
6085 
6086 #ifdef RTE_ETHDEV_DEBUG_RX
6087 	if (port_id >= RTE_MAX_ETHPORTS ||
6088 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
6089 		RTE_ETHDEV_LOG_LINE(ERR,
6090 			"Invalid port_id=%u or queue_id=%u",
6091 			port_id, queue_id);
6092 		return 0;
6093 	}
6094 #endif
6095 
6096 	/* fetch pointer to queue data */
6097 	p = &rte_eth_fp_ops[port_id];
6098 	qd = p->rxq.data[queue_id];
6099 
6100 #ifdef RTE_ETHDEV_DEBUG_RX
6101 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
6102 
6103 	if (qd == NULL) {
6104 		RTE_ETHDEV_LOG_LINE(ERR, "Invalid Rx queue_id=%u for port_id=%u",
6105 			queue_id, port_id);
6106 		return 0;
6107 	}
6108 #endif
6109 
6110 	nb_rx = p->rx_pkt_burst(qd, rx_pkts, nb_pkts);
6111 
6112 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
6113 	{
6114 		void *cb;
6115 
6116 		/* rte_memory_order_release memory order was used when the
6117 		 * call back was inserted into the list.
6118 		 * Since there is a clear dependency between loading
6119 		 * cb and cb->fn/cb->next, rte_memory_order_acquire memory order is
6120 		 * not required.
6121 		 */
6122 		cb = rte_atomic_load_explicit(&p->rxq.clbk[queue_id],
6123 				rte_memory_order_relaxed);
6124 		if (unlikely(cb != NULL))
6125 			nb_rx = rte_eth_call_rx_callbacks(port_id, queue_id,
6126 					rx_pkts, nb_rx, nb_pkts, cb);
6127 	}
6128 #endif
6129 
6130 	rte_ethdev_trace_rx_burst(port_id, queue_id, (void **)rx_pkts, nb_rx);
6131 	return nb_rx;
6132 }
6133 
6134 /**
6135  * Get the number of used descriptors of a Rx queue
6136  *
6137  * Since it's a dataplane function, no check is performed on port_id and
6138  * queue_id. The caller must therefore ensure that the port is enabled
6139  * and the queue is configured and running.
6140  *
6141  * @param port_id
6142  *  The port identifier of the Ethernet device.
6143  * @param queue_id
6144  *  The queue ID on the specific port.
6145  * @return
6146  *  The number of used descriptors in the specific queue, or:
6147  *   - (-ENODEV) if *port_id* is invalid.
6148  *   - (-EINVAL) if *queue_id* is invalid
6149  *   - (-ENOTSUP) if the device does not support this function
6150  */
6151 static inline int
6152 rte_eth_rx_queue_count(uint16_t port_id, uint16_t queue_id)
6153 {
6154 	struct rte_eth_fp_ops *p;
6155 	void *qd;
6156 
6157 #ifdef RTE_ETHDEV_DEBUG_RX
6158 	if (port_id >= RTE_MAX_ETHPORTS ||
6159 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
6160 		RTE_ETHDEV_LOG_LINE(ERR,
6161 			"Invalid port_id=%u or queue_id=%u",
6162 			port_id, queue_id);
6163 		return -EINVAL;
6164 	}
6165 #endif
6166 
6167 	/* fetch pointer to queue data */
6168 	p = &rte_eth_fp_ops[port_id];
6169 	qd = p->rxq.data[queue_id];
6170 
6171 #ifdef RTE_ETHDEV_DEBUG_RX
6172 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
6173 	if (qd == NULL)
6174 		return -EINVAL;
6175 #endif
6176 
6177 	if (*p->rx_queue_count == NULL)
6178 		return -ENOTSUP;
6179 	return (int)(*p->rx_queue_count)(qd);
6180 }
6181 
6182 /**@{@name Rx hardware descriptor states
6183  * @see rte_eth_rx_descriptor_status
6184  */
6185 #define RTE_ETH_RX_DESC_AVAIL    0 /**< Desc available for hw. */
6186 #define RTE_ETH_RX_DESC_DONE     1 /**< Desc done, filled by hw. */
6187 #define RTE_ETH_RX_DESC_UNAVAIL  2 /**< Desc used by driver or hw. */
6188 /**@}*/
6189 
6190 /**
6191  * Check the status of a Rx descriptor in the queue
6192  *
6193  * It should be called in a similar context than the Rx function:
6194  * - on a dataplane core
6195  * - not concurrently on the same queue
6196  *
6197  * Since it's a dataplane function, no check is performed on port_id and
6198  * queue_id. The caller must therefore ensure that the port is enabled
6199  * and the queue is configured and running.
6200  *
6201  * Note: accessing to a random descriptor in the ring may trigger cache
6202  * misses and have a performance impact.
6203  *
6204  * @param port_id
6205  *  A valid port identifier of the Ethernet device which.
6206  * @param queue_id
6207  *  A valid Rx queue identifier on this port.
6208  * @param offset
6209  *  The offset of the descriptor starting from tail (0 is the next
6210  *  packet to be received by the driver).
6211  *
6212  * @return
6213  *  - (RTE_ETH_RX_DESC_AVAIL): Descriptor is available for the hardware to
6214  *    receive a packet.
6215  *  - (RTE_ETH_RX_DESC_DONE): Descriptor is done, it is filled by hw, but
6216  *    not yet processed by the driver (i.e. in the receive queue).
6217  *  - (RTE_ETH_RX_DESC_UNAVAIL): Descriptor is unavailable, either hold by
6218  *    the driver and not yet returned to hw, or reserved by the hw.
6219  *  - (-EINVAL) bad descriptor offset.
6220  *  - (-ENOTSUP) if the device does not support this function.
6221  *  - (-ENODEV) bad port or queue (only if compiled with debug).
6222  */
6223 static inline int
6224 rte_eth_rx_descriptor_status(uint16_t port_id, uint16_t queue_id,
6225 	uint16_t offset)
6226 {
6227 	struct rte_eth_fp_ops *p;
6228 	void *qd;
6229 
6230 #ifdef RTE_ETHDEV_DEBUG_RX
6231 	if (port_id >= RTE_MAX_ETHPORTS ||
6232 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
6233 		RTE_ETHDEV_LOG_LINE(ERR,
6234 			"Invalid port_id=%u or queue_id=%u",
6235 			port_id, queue_id);
6236 		return -EINVAL;
6237 	}
6238 #endif
6239 
6240 	/* fetch pointer to queue data */
6241 	p = &rte_eth_fp_ops[port_id];
6242 	qd = p->rxq.data[queue_id];
6243 
6244 #ifdef RTE_ETHDEV_DEBUG_RX
6245 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
6246 	if (qd == NULL)
6247 		return -ENODEV;
6248 #endif
6249 	if (*p->rx_descriptor_status == NULL)
6250 		return -ENOTSUP;
6251 	return (*p->rx_descriptor_status)(qd, offset);
6252 }
6253 
6254 /**@{@name Tx hardware descriptor states
6255  * @see rte_eth_tx_descriptor_status
6256  */
6257 #define RTE_ETH_TX_DESC_FULL    0 /**< Desc filled for hw, waiting xmit. */
6258 #define RTE_ETH_TX_DESC_DONE    1 /**< Desc done, packet is transmitted. */
6259 #define RTE_ETH_TX_DESC_UNAVAIL 2 /**< Desc used by driver or hw. */
6260 /**@}*/
6261 
6262 /**
6263  * Check the status of a Tx descriptor in the queue.
6264  *
6265  * It should be called in a similar context than the Tx function:
6266  * - on a dataplane core
6267  * - not concurrently on the same queue
6268  *
6269  * Since it's a dataplane function, no check is performed on port_id and
6270  * queue_id. The caller must therefore ensure that the port is enabled
6271  * and the queue is configured and running.
6272  *
6273  * Note: accessing to a random descriptor in the ring may trigger cache
6274  * misses and have a performance impact.
6275  *
6276  * @param port_id
6277  *  A valid port identifier of the Ethernet device which.
6278  * @param queue_id
6279  *  A valid Tx queue identifier on this port.
6280  * @param offset
6281  *  The offset of the descriptor starting from tail (0 is the place where
6282  *  the next packet will be send).
6283  *
6284  * @return
6285  *  - (RTE_ETH_TX_DESC_FULL) Descriptor is being processed by the hw, i.e.
6286  *    in the transmit queue.
6287  *  - (RTE_ETH_TX_DESC_DONE) Hardware is done with this descriptor, it can
6288  *    be reused by the driver.
6289  *  - (RTE_ETH_TX_DESC_UNAVAIL): Descriptor is unavailable, reserved by the
6290  *    driver or the hardware.
6291  *  - (-EINVAL) bad descriptor offset.
6292  *  - (-ENOTSUP) if the device does not support this function.
6293  *  - (-ENODEV) bad port or queue (only if compiled with debug).
6294  */
6295 static inline int rte_eth_tx_descriptor_status(uint16_t port_id,
6296 	uint16_t queue_id, uint16_t offset)
6297 {
6298 	struct rte_eth_fp_ops *p;
6299 	void *qd;
6300 
6301 #ifdef RTE_ETHDEV_DEBUG_TX
6302 	if (port_id >= RTE_MAX_ETHPORTS ||
6303 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
6304 		RTE_ETHDEV_LOG_LINE(ERR,
6305 			"Invalid port_id=%u or queue_id=%u",
6306 			port_id, queue_id);
6307 		return -EINVAL;
6308 	}
6309 #endif
6310 
6311 	/* fetch pointer to queue data */
6312 	p = &rte_eth_fp_ops[port_id];
6313 	qd = p->txq.data[queue_id];
6314 
6315 #ifdef RTE_ETHDEV_DEBUG_TX
6316 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
6317 	if (qd == NULL)
6318 		return -ENODEV;
6319 #endif
6320 	if (*p->tx_descriptor_status == NULL)
6321 		return -ENOTSUP;
6322 	return (*p->tx_descriptor_status)(qd, offset);
6323 }
6324 
6325 /**
6326  * @internal
6327  * Helper routine for rte_eth_tx_burst().
6328  * Should be called before entry PMD's rte_eth_tx_bulk implementation.
6329  * Does necessary pre-processing - invokes Tx callbacks if any, etc.
6330  *
6331  * @param port_id
6332  *   The port identifier of the Ethernet device.
6333  * @param queue_id
6334  *   The index of the transmit queue through which output packets must be
6335  *   sent.
6336  * @param tx_pkts
6337  *   The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
6338  *   which contain the output packets.
6339  * @param nb_pkts
6340  *   The maximum number of packets to transmit.
6341  * @return
6342  *   The number of output packets to transmit.
6343  */
6344 uint16_t rte_eth_call_tx_callbacks(uint16_t port_id, uint16_t queue_id,
6345 	struct rte_mbuf **tx_pkts, uint16_t nb_pkts, void *opaque);
6346 
6347 /**
6348  * Send a burst of output packets on a transmit queue of an Ethernet device.
6349  *
6350  * The rte_eth_tx_burst() function is invoked to transmit output packets
6351  * on the output queue *queue_id* of the Ethernet device designated by its
6352  * *port_id*.
6353  * The *nb_pkts* parameter is the number of packets to send which are
6354  * supplied in the *tx_pkts* array of *rte_mbuf* structures, each of them
6355  * allocated from a pool created with rte_pktmbuf_pool_create().
6356  * The rte_eth_tx_burst() function loops, sending *nb_pkts* packets,
6357  * up to the number of transmit descriptors available in the Tx ring of the
6358  * transmit queue.
6359  * For each packet to send, the rte_eth_tx_burst() function performs
6360  * the following operations:
6361  *
6362  * - Pick up the next available descriptor in the transmit ring.
6363  *
6364  * - Free the network buffer previously sent with that descriptor, if any.
6365  *
6366  * - Initialize the transmit descriptor with the information provided
6367  *   in the *rte_mbuf data structure.
6368  *
6369  * In the case of a segmented packet composed of a list of *rte_mbuf* buffers,
6370  * the rte_eth_tx_burst() function uses several transmit descriptors
6371  * of the ring.
6372  *
6373  * The rte_eth_tx_burst() function returns the number of packets it
6374  * actually sent. A return value equal to *nb_pkts* means that all packets
6375  * have been sent, and this is likely to signify that other output packets
6376  * could be immediately transmitted again. Applications that implement a
6377  * "send as many packets to transmit as possible" policy can check this
6378  * specific case and keep invoking the rte_eth_tx_burst() function until
6379  * a value less than *nb_pkts* is returned.
6380  *
6381  * It is the responsibility of the rte_eth_tx_burst() function to
6382  * transparently free the memory buffers of packets previously sent.
6383  * This feature is driven by the *tx_free_thresh* value supplied to the
6384  * rte_eth_dev_configure() function at device configuration time.
6385  * When the number of free Tx descriptors drops below this threshold, the
6386  * rte_eth_tx_burst() function must [attempt to] free the *rte_mbuf*  buffers
6387  * of those packets whose transmission was effectively completed.
6388  *
6389  * If the PMD is RTE_ETH_TX_OFFLOAD_MT_LOCKFREE capable, multiple threads can
6390  * invoke this function concurrently on the same Tx queue without SW lock.
6391  * @see rte_eth_dev_info_get, struct rte_eth_txconf::offloads
6392  *
6393  * @see rte_eth_tx_prepare to perform some prior checks or adjustments
6394  * for offloads.
6395  *
6396  * @note This function must not modify mbufs (including packets data)
6397  * unless the refcnt is 1.
6398  * An exception is the bonding PMD, which does not have "Tx prepare" support,
6399  * in this case, mbufs may be modified.
6400  *
6401  * @param port_id
6402  *   The port identifier of the Ethernet device.
6403  * @param queue_id
6404  *   The index of the transmit queue through which output packets must be
6405  *   sent.
6406  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
6407  *   to rte_eth_dev_configure().
6408  * @param tx_pkts
6409  *   The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
6410  *   which contain the output packets.
6411  * @param nb_pkts
6412  *   The maximum number of packets to transmit.
6413  * @return
6414  *   The number of output packets actually stored in transmit descriptors of
6415  *   the transmit ring. The return value can be less than the value of the
6416  *   *tx_pkts* parameter when the transmit ring is full or has been filled up.
6417  */
6418 static inline uint16_t
6419 rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
6420 		 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
6421 {
6422 	struct rte_eth_fp_ops *p;
6423 	void *qd;
6424 
6425 #ifdef RTE_ETHDEV_DEBUG_TX
6426 	if (port_id >= RTE_MAX_ETHPORTS ||
6427 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
6428 		RTE_ETHDEV_LOG_LINE(ERR,
6429 			"Invalid port_id=%u or queue_id=%u",
6430 			port_id, queue_id);
6431 		return 0;
6432 	}
6433 #endif
6434 
6435 	/* fetch pointer to queue data */
6436 	p = &rte_eth_fp_ops[port_id];
6437 	qd = p->txq.data[queue_id];
6438 
6439 #ifdef RTE_ETHDEV_DEBUG_TX
6440 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
6441 
6442 	if (qd == NULL) {
6443 		RTE_ETHDEV_LOG_LINE(ERR, "Invalid Tx queue_id=%u for port_id=%u",
6444 			queue_id, port_id);
6445 		return 0;
6446 	}
6447 #endif
6448 
6449 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
6450 	{
6451 		void *cb;
6452 
6453 		/* rte_memory_order_release memory order was used when the
6454 		 * call back was inserted into the list.
6455 		 * Since there is a clear dependency between loading
6456 		 * cb and cb->fn/cb->next, rte_memory_order_acquire memory order is
6457 		 * not required.
6458 		 */
6459 		cb = rte_atomic_load_explicit(&p->txq.clbk[queue_id],
6460 				rte_memory_order_relaxed);
6461 		if (unlikely(cb != NULL))
6462 			nb_pkts = rte_eth_call_tx_callbacks(port_id, queue_id,
6463 					tx_pkts, nb_pkts, cb);
6464 	}
6465 #endif
6466 
6467 	nb_pkts = p->tx_pkt_burst(qd, tx_pkts, nb_pkts);
6468 
6469 	rte_ethdev_trace_tx_burst(port_id, queue_id, (void **)tx_pkts, nb_pkts);
6470 	return nb_pkts;
6471 }
6472 
6473 /**
6474  * Process a burst of output packets on a transmit queue of an Ethernet device.
6475  *
6476  * The rte_eth_tx_prepare() function is invoked to prepare output packets to be
6477  * transmitted on the output queue *queue_id* of the Ethernet device designated
6478  * by its *port_id*.
6479  * The *nb_pkts* parameter is the number of packets to be prepared which are
6480  * supplied in the *tx_pkts* array of *rte_mbuf* structures, each of them
6481  * allocated from a pool created with rte_pktmbuf_pool_create().
6482  * For each packet to send, the rte_eth_tx_prepare() function performs
6483  * the following operations:
6484  *
6485  * - Check if packet meets devices requirements for Tx offloads.
6486  *
6487  * - Check limitations about number of segments.
6488  *
6489  * - Check additional requirements when debug is enabled.
6490  *
6491  * - Update and/or reset required checksums when Tx offload is set for packet.
6492  *
6493  * Since this function can modify packet data, provided mbufs must be safely
6494  * writable (e.g. modified data cannot be in shared segment).
6495  *
6496  * The rte_eth_tx_prepare() function returns the number of packets ready to be
6497  * sent. A return value equal to *nb_pkts* means that all packets are valid and
6498  * ready to be sent, otherwise stops processing on the first invalid packet and
6499  * leaves the rest packets untouched.
6500  *
6501  * When this functionality is not implemented in the driver, all packets are
6502  * are returned untouched.
6503  *
6504  * @param port_id
6505  *   The port identifier of the Ethernet device.
6506  *   The value must be a valid port ID.
6507  * @param queue_id
6508  *   The index of the transmit queue through which output packets must be
6509  *   sent.
6510  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
6511  *   to rte_eth_dev_configure().
6512  * @param tx_pkts
6513  *   The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
6514  *   which contain the output packets.
6515  * @param nb_pkts
6516  *   The maximum number of packets to process.
6517  * @return
6518  *   The number of packets correct and ready to be sent. The return value can be
6519  *   less than the value of the *tx_pkts* parameter when some packet doesn't
6520  *   meet devices requirements with rte_errno set appropriately:
6521  *   - EINVAL: offload flags are not correctly set
6522  *   - ENOTSUP: the offload feature is not supported by the hardware
6523  *   - ENODEV: if *port_id* is invalid (with debug enabled only)
6524  */
6525 
6526 #ifndef RTE_ETHDEV_TX_PREPARE_NOOP
6527 
6528 static inline uint16_t
6529 rte_eth_tx_prepare(uint16_t port_id, uint16_t queue_id,
6530 		struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
6531 {
6532 	struct rte_eth_fp_ops *p;
6533 	void *qd;
6534 
6535 #ifdef RTE_ETHDEV_DEBUG_TX
6536 	if (port_id >= RTE_MAX_ETHPORTS ||
6537 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
6538 		RTE_ETHDEV_LOG_LINE(ERR,
6539 			"Invalid port_id=%u or queue_id=%u",
6540 			port_id, queue_id);
6541 		rte_errno = ENODEV;
6542 		return 0;
6543 	}
6544 #endif
6545 
6546 	/* fetch pointer to queue data */
6547 	p = &rte_eth_fp_ops[port_id];
6548 	qd = p->txq.data[queue_id];
6549 
6550 #ifdef RTE_ETHDEV_DEBUG_TX
6551 	if (!rte_eth_dev_is_valid_port(port_id)) {
6552 		RTE_ETHDEV_LOG_LINE(ERR, "Invalid Tx port_id=%u", port_id);
6553 		rte_errno = ENODEV;
6554 		return 0;
6555 	}
6556 	if (qd == NULL) {
6557 		RTE_ETHDEV_LOG_LINE(ERR, "Invalid Tx queue_id=%u for port_id=%u",
6558 			queue_id, port_id);
6559 		rte_errno = EINVAL;
6560 		return 0;
6561 	}
6562 #endif
6563 
6564 	if (!p->tx_pkt_prepare)
6565 		return nb_pkts;
6566 
6567 	return p->tx_pkt_prepare(qd, tx_pkts, nb_pkts);
6568 }
6569 
6570 #else
6571 
6572 /*
6573  * Native NOOP operation for compilation targets which doesn't require any
6574  * preparations steps, and functional NOOP may introduce unnecessary performance
6575  * drop.
6576  *
6577  * Generally this is not a good idea to turn it on globally and didn't should
6578  * be used if behavior of tx_preparation can change.
6579  */
6580 
6581 static inline uint16_t
6582 rte_eth_tx_prepare(__rte_unused uint16_t port_id,
6583 		__rte_unused uint16_t queue_id,
6584 		__rte_unused struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
6585 {
6586 	return nb_pkts;
6587 }
6588 
6589 #endif
6590 
6591 /**
6592  * Send any packets queued up for transmission on a port and HW queue
6593  *
6594  * This causes an explicit flush of packets previously buffered via the
6595  * rte_eth_tx_buffer() function. It returns the number of packets successfully
6596  * sent to the NIC, and calls the error callback for any unsent packets. Unless
6597  * explicitly set up otherwise, the default callback simply frees the unsent
6598  * packets back to the owning mempool.
6599  *
6600  * @param port_id
6601  *   The port identifier of the Ethernet device.
6602  * @param queue_id
6603  *   The index of the transmit queue through which output packets must be
6604  *   sent.
6605  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
6606  *   to rte_eth_dev_configure().
6607  * @param buffer
6608  *   Buffer of packets to be transmit.
6609  * @return
6610  *   The number of packets successfully sent to the Ethernet device. The error
6611  *   callback is called for any packets which could not be sent.
6612  */
6613 static inline uint16_t
6614 rte_eth_tx_buffer_flush(uint16_t port_id, uint16_t queue_id,
6615 		struct rte_eth_dev_tx_buffer *buffer)
6616 {
6617 	uint16_t sent;
6618 	uint16_t to_send = buffer->length;
6619 
6620 	if (to_send == 0)
6621 		return 0;
6622 
6623 	sent = rte_eth_tx_burst(port_id, queue_id, buffer->pkts, to_send);
6624 
6625 	buffer->length = 0;
6626 
6627 	/* All packets sent, or to be dealt with by callback below */
6628 	if (unlikely(sent != to_send))
6629 		buffer->error_callback(&buffer->pkts[sent],
6630 				       (uint16_t)(to_send - sent),
6631 				       buffer->error_userdata);
6632 
6633 	return sent;
6634 }
6635 
6636 /**
6637  * Buffer a single packet for future transmission on a port and queue
6638  *
6639  * This function takes a single mbuf/packet and buffers it for later
6640  * transmission on the particular port and queue specified. Once the buffer is
6641  * full of packets, an attempt will be made to transmit all the buffered
6642  * packets. In case of error, where not all packets can be transmitted, a
6643  * callback is called with the unsent packets as a parameter. If no callback
6644  * is explicitly set up, the unsent packets are just freed back to the owning
6645  * mempool. The function returns the number of packets actually sent i.e.
6646  * 0 if no buffer flush occurred, otherwise the number of packets successfully
6647  * flushed
6648  *
6649  * @param port_id
6650  *   The port identifier of the Ethernet device.
6651  * @param queue_id
6652  *   The index of the transmit queue through which output packets must be
6653  *   sent.
6654  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
6655  *   to rte_eth_dev_configure().
6656  * @param buffer
6657  *   Buffer used to collect packets to be sent.
6658  * @param tx_pkt
6659  *   Pointer to the packet mbuf to be sent.
6660  * @return
6661  *   0 = packet has been buffered for later transmission
6662  *   N > 0 = packet has been buffered, and the buffer was subsequently flushed,
6663  *     causing N packets to be sent, and the error callback to be called for
6664  *     the rest.
6665  */
6666 static __rte_always_inline uint16_t
6667 rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id,
6668 		struct rte_eth_dev_tx_buffer *buffer, struct rte_mbuf *tx_pkt)
6669 {
6670 	buffer->pkts[buffer->length++] = tx_pkt;
6671 	if (buffer->length < buffer->size)
6672 		return 0;
6673 
6674 	return rte_eth_tx_buffer_flush(port_id, queue_id, buffer);
6675 }
6676 
6677 /**
6678  * @warning
6679  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
6680  *
6681  * Recycle used mbufs from a transmit queue of an Ethernet device, and move
6682  * these mbufs into a mbuf ring for a receive queue of an Ethernet device.
6683  * This can bypass mempool path to save CPU cycles.
6684  *
6685  * The rte_eth_recycle_mbufs() function loops, with rte_eth_rx_burst() and
6686  * rte_eth_tx_burst() functions, freeing Tx used mbufs and replenishing Rx
6687  * descriptors. The number of recycling mbufs depends on the request of Rx mbuf
6688  * ring, with the constraint of enough used mbufs from Tx mbuf ring.
6689  *
6690  * For each recycling mbufs, the rte_eth_recycle_mbufs() function performs the
6691  * following operations:
6692  *
6693  * - Copy used *rte_mbuf* buffer pointers from Tx mbuf ring into Rx mbuf ring.
6694  *
6695  * - Replenish the Rx descriptors with the recycling *rte_mbuf* mbufs freed
6696  *   from the Tx mbuf ring.
6697  *
6698  * This function spilts Rx and Tx path with different callback functions. The
6699  * callback function recycle_tx_mbufs_reuse is for Tx driver. The callback
6700  * function recycle_rx_descriptors_refill is for Rx driver. rte_eth_recycle_mbufs()
6701  * can support the case that Rx Ethernet device is different from Tx Ethernet device.
6702  *
6703  * It is the responsibility of users to select the Rx/Tx queue pair to recycle
6704  * mbufs. Before call this function, users must call rte_eth_recycle_rxq_info_get
6705  * function to retrieve selected Rx queue information.
6706  * @see rte_eth_recycle_rxq_info_get, struct rte_eth_recycle_rxq_info
6707  *
6708  * Currently, the rte_eth_recycle_mbufs() function can support to feed 1 Rx queue from
6709  * 2 Tx queues in the same thread. Do not pair the Rx queue and Tx queue in different
6710  * threads, in order to avoid memory error rewriting.
6711  *
6712  * @param rx_port_id
6713  *   Port identifying the receive side.
6714  * @param rx_queue_id
6715  *   The index of the receive queue identifying the receive side.
6716  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
6717  *   to rte_eth_dev_configure().
6718  * @param tx_port_id
6719  *   Port identifying the transmit side.
6720  * @param tx_queue_id
6721  *   The index of the transmit queue identifying the transmit side.
6722  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
6723  *   to rte_eth_dev_configure().
6724  * @param recycle_rxq_info
6725  *   A pointer to a structure of type *rte_eth_recycle_rxq_info* which contains
6726  *   the information of the Rx queue mbuf ring.
6727  * @return
6728  *   The number of recycling mbufs.
6729  */
6730 __rte_experimental
6731 static inline uint16_t
6732 rte_eth_recycle_mbufs(uint16_t rx_port_id, uint16_t rx_queue_id,
6733 		uint16_t tx_port_id, uint16_t tx_queue_id,
6734 		struct rte_eth_recycle_rxq_info *recycle_rxq_info)
6735 {
6736 	struct rte_eth_fp_ops *p1, *p2;
6737 	void *qd1, *qd2;
6738 	uint16_t nb_mbufs;
6739 
6740 #ifdef RTE_ETHDEV_DEBUG_TX
6741 	if (tx_port_id >= RTE_MAX_ETHPORTS ||
6742 			tx_queue_id >= RTE_MAX_QUEUES_PER_PORT) {
6743 		RTE_ETHDEV_LOG_LINE(ERR,
6744 				"Invalid tx_port_id=%u or tx_queue_id=%u",
6745 				tx_port_id, tx_queue_id);
6746 		return 0;
6747 	}
6748 #endif
6749 
6750 	/* fetch pointer to Tx queue data */
6751 	p1 = &rte_eth_fp_ops[tx_port_id];
6752 	qd1 = p1->txq.data[tx_queue_id];
6753 
6754 #ifdef RTE_ETHDEV_DEBUG_TX
6755 	RTE_ETH_VALID_PORTID_OR_ERR_RET(tx_port_id, 0);
6756 
6757 	if (qd1 == NULL) {
6758 		RTE_ETHDEV_LOG_LINE(ERR, "Invalid Tx queue_id=%u for port_id=%u",
6759 				tx_queue_id, tx_port_id);
6760 		return 0;
6761 	}
6762 #endif
6763 	if (p1->recycle_tx_mbufs_reuse == NULL)
6764 		return 0;
6765 
6766 #ifdef RTE_ETHDEV_DEBUG_RX
6767 	if (rx_port_id >= RTE_MAX_ETHPORTS ||
6768 			rx_queue_id >= RTE_MAX_QUEUES_PER_PORT) {
6769 		RTE_ETHDEV_LOG_LINE(ERR, "Invalid rx_port_id=%u or rx_queue_id=%u",
6770 				rx_port_id, rx_queue_id);
6771 		return 0;
6772 	}
6773 #endif
6774 
6775 	/* fetch pointer to Rx queue data */
6776 	p2 = &rte_eth_fp_ops[rx_port_id];
6777 	qd2 = p2->rxq.data[rx_queue_id];
6778 
6779 #ifdef RTE_ETHDEV_DEBUG_RX
6780 	RTE_ETH_VALID_PORTID_OR_ERR_RET(rx_port_id, 0);
6781 
6782 	if (qd2 == NULL) {
6783 		RTE_ETHDEV_LOG_LINE(ERR, "Invalid Rx queue_id=%u for port_id=%u",
6784 				rx_queue_id, rx_port_id);
6785 		return 0;
6786 	}
6787 #endif
6788 	if (p2->recycle_rx_descriptors_refill == NULL)
6789 		return 0;
6790 
6791 	/* Copy used *rte_mbuf* buffer pointers from Tx mbuf ring
6792 	 * into Rx mbuf ring.
6793 	 */
6794 	nb_mbufs = p1->recycle_tx_mbufs_reuse(qd1, recycle_rxq_info);
6795 
6796 	/* If no recycling mbufs, return 0. */
6797 	if (nb_mbufs == 0)
6798 		return 0;
6799 
6800 	/* Replenish the Rx descriptors with the recycling
6801 	 * into Rx mbuf ring.
6802 	 */
6803 	p2->recycle_rx_descriptors_refill(qd2, nb_mbufs);
6804 
6805 	return nb_mbufs;
6806 }
6807 
6808 /**
6809  * @warning
6810  * @b EXPERIMENTAL: this API may change without prior notice
6811  *
6812  * Get supported header protocols to split on Rx.
6813  *
6814  * When a packet type is announced to be split,
6815  * it *must* be supported by the PMD.
6816  * For instance, if eth-ipv4, eth-ipv4-udp is announced,
6817  * the PMD must return the following packet types for these packets:
6818  * - Ether/IPv4             -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4
6819  * - Ether/IPv4/UDP         -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP
6820  *
6821  * @param port_id
6822  *   The port identifier of the device.
6823  * @param[out] ptypes
6824  *   An array pointer to store supported protocol headers, allocated by caller.
6825  *   These ptypes are composed with RTE_PTYPE_*.
6826  * @param num
6827  *   Size of the array pointed by param ptypes.
6828  * @return
6829  *   - (>=0) Number of supported ptypes. If the number of types exceeds num,
6830  *           only num entries will be filled into the ptypes array,
6831  *           but the full count of supported ptypes will be returned.
6832  *   - (-ENOTSUP) if header protocol is not supported by device.
6833  *   - (-ENODEV) if *port_id* invalid.
6834  *   - (-EINVAL) if bad parameter.
6835  */
6836 __rte_experimental
6837 int rte_eth_buffer_split_get_supported_hdr_ptypes(uint16_t port_id, uint32_t *ptypes, int num);
6838 
6839 /**
6840  * @warning
6841  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice.
6842  *
6843  * Get the number of used descriptors of a Tx queue.
6844  *
6845  * This function retrieves the number of used descriptors of a transmit queue.
6846  * Applications can use this API in the fast path to inspect Tx queue occupancy
6847  * and take appropriate actions based on the available free descriptors.
6848  * An example action could be implementing Random Early Discard (RED).
6849  *
6850  * Since it's a fast-path function, no check is performed on port_id and queue_id.
6851  * The caller must therefore ensure that the port is enabled
6852  * and the queue is configured and running.
6853  *
6854  * @param port_id
6855  *   The port identifier of the device.
6856  * @param queue_id
6857  *   The index of the transmit queue.
6858  *   The value must be in the range [0, nb_tx_queue - 1]
6859  *   previously supplied to rte_eth_dev_configure().
6860  * @return
6861  *   The number of used descriptors in the specific queue, or:
6862  *   - (-ENODEV) if *port_id* is invalid. Enabled only when RTE_ETHDEV_DEBUG_TX is enabled.
6863  *   - (-EINVAL) if *queue_id* is invalid. Enabled only when RTE_ETHDEV_DEBUG_TX is enabled.
6864  *   - (-ENOTSUP) if the device does not support this function.
6865  *
6866  * @note This function is designed for fast-path use.
6867  * @note There is no requirement to call this function before rte_eth_tx_burst() invocation.
6868  * @note Utilize this function exclusively when the caller needs to determine
6869  * the used queue count across all descriptors of a Tx queue.
6870  * If the use case only involves checking the status of a specific descriptor slot,
6871  * opt for rte_eth_tx_descriptor_status() instead.
6872  */
6873 __rte_experimental
6874 static inline int
6875 rte_eth_tx_queue_count(uint16_t port_id, uint16_t queue_id)
6876 {
6877 	struct rte_eth_fp_ops *fops;
6878 	void *qd;
6879 	int rc;
6880 
6881 #ifdef RTE_ETHDEV_DEBUG_TX
6882 	if (port_id >= RTE_MAX_ETHPORTS || !rte_eth_dev_is_valid_port(port_id)) {
6883 		RTE_ETHDEV_LOG_LINE(ERR, "Invalid port_id=%u", port_id);
6884 		rc = -ENODEV;
6885 		goto out;
6886 	}
6887 
6888 	if (queue_id >= RTE_MAX_QUEUES_PER_PORT) {
6889 		RTE_ETHDEV_LOG_LINE(ERR, "Invalid queue_id=%u for port_id=%u",
6890 				    queue_id, port_id);
6891 		rc = -EINVAL;
6892 		goto out;
6893 	}
6894 #endif
6895 
6896 	/* Fetch pointer to Tx queue data */
6897 	fops = &rte_eth_fp_ops[port_id];
6898 	qd = fops->txq.data[queue_id];
6899 
6900 #ifdef RTE_ETHDEV_DEBUG_TX
6901 	if (qd == NULL) {
6902 		RTE_ETHDEV_LOG_LINE(ERR, "Invalid queue_id=%u for port_id=%u",
6903 				    queue_id, port_id);
6904 		rc = -EINVAL;
6905 		goto out;
6906 	}
6907 #endif
6908 	if (fops->tx_queue_count == NULL) {
6909 		rc = -ENOTSUP;
6910 		goto out;
6911 	}
6912 
6913 	rc = fops->tx_queue_count(qd);
6914 
6915 out:
6916 	rte_eth_trace_tx_queue_count(port_id, queue_id, rc);
6917 	return rc;
6918 }
6919 
6920 #ifdef __cplusplus
6921 }
6922 #endif
6923 
6924 #endif /* _RTE_ETHDEV_H_ */
6925