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