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