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