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