xref: /dpdk/lib/ethdev/rte_ethdev.h (revision 1d343c19330a11f05e3ea369ae5780d38772358e)
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 /* Generic Burst mode flag definition, values can be ORed. */
1824 
1825 /**
1826  * If the queues have different burst mode description, this bit will be set
1827  * by PMD, then the application can iterate to retrieve burst description for
1828  * all other queues.
1829  */
1830 #define RTE_ETH_BURST_FLAG_PER_QUEUE RTE_BIT64(0)
1831 
1832 /**
1833  * Ethernet device Rx/Tx queue packet burst mode information structure.
1834  * Used to retrieve information about packet burst mode setting.
1835  */
1836 struct rte_eth_burst_mode {
1837 	uint64_t flags; /**< The ORed values of RTE_ETH_BURST_FLAG_xxx */
1838 
1839 #define RTE_ETH_BURST_MODE_INFO_SIZE 1024 /**< Maximum size for information */
1840 	char info[RTE_ETH_BURST_MODE_INFO_SIZE]; /**< burst mode information */
1841 };
1842 
1843 /** Maximum name length for extended statistics counters */
1844 #define RTE_ETH_XSTATS_NAME_SIZE 64
1845 
1846 /**
1847  * An Ethernet device extended statistic structure
1848  *
1849  * This structure is used by rte_eth_xstats_get() to provide
1850  * statistics that are not provided in the generic *rte_eth_stats*
1851  * structure.
1852  * It maps a name ID, corresponding to an index in the array returned
1853  * by rte_eth_xstats_get_names(), to a statistic value.
1854  */
1855 struct rte_eth_xstat {
1856 	uint64_t id;        /**< The index in xstats name array. */
1857 	uint64_t value;     /**< The statistic counter value. */
1858 };
1859 
1860 /**
1861  * A name element for extended statistics.
1862  *
1863  * An array of this structure is returned by rte_eth_xstats_get_names().
1864  * It lists the names of extended statistics for a PMD. The *rte_eth_xstat*
1865  * structure references these names by their array index.
1866  *
1867  * The xstats should follow a common naming scheme.
1868  * Some names are standardized in rte_stats_strings.
1869  * Examples:
1870  *     - rx_missed_errors
1871  *     - tx_q3_bytes
1872  *     - tx_size_128_to_255_packets
1873  */
1874 struct rte_eth_xstat_name {
1875 	char name[RTE_ETH_XSTATS_NAME_SIZE]; /**< The statistic name. */
1876 };
1877 
1878 #define RTE_ETH_DCB_NUM_TCS    8
1879 #define RTE_ETH_MAX_VMDQ_POOL  64
1880 
1881 /**
1882  * A structure used to get the information of queue and
1883  * TC mapping on both Tx and Rx paths.
1884  */
1885 struct rte_eth_dcb_tc_queue_mapping {
1886 	/** Rx queues assigned to tc per Pool */
1887 	struct {
1888 		uint16_t base;
1889 		uint16_t nb_queue;
1890 	} tc_rxq[RTE_ETH_MAX_VMDQ_POOL][RTE_ETH_DCB_NUM_TCS];
1891 	/** Rx queues assigned to tc per Pool */
1892 	struct {
1893 		uint16_t base;
1894 		uint16_t nb_queue;
1895 	} tc_txq[RTE_ETH_MAX_VMDQ_POOL][RTE_ETH_DCB_NUM_TCS];
1896 };
1897 
1898 /**
1899  * A structure used to get the information of DCB.
1900  * It includes TC UP mapping and queue TC mapping.
1901  */
1902 struct rte_eth_dcb_info {
1903 	uint8_t nb_tcs;        /**< number of TCs */
1904 	uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES]; /**< Priority to tc */
1905 	uint8_t tc_bws[RTE_ETH_DCB_NUM_TCS]; /**< Tx BW percentage for each TC */
1906 	/** Rx queues assigned to tc */
1907 	struct rte_eth_dcb_tc_queue_mapping tc_queue;
1908 };
1909 
1910 /**
1911  * This enum indicates the possible Forward Error Correction (FEC) modes
1912  * of an ethdev port.
1913  */
1914 enum rte_eth_fec_mode {
1915 	RTE_ETH_FEC_NOFEC = 0,      /**< FEC is off */
1916 	RTE_ETH_FEC_AUTO,	    /**< FEC autonegotiation modes */
1917 	RTE_ETH_FEC_BASER,          /**< FEC using common algorithm */
1918 	RTE_ETH_FEC_RS,             /**< FEC using RS algorithm */
1919 	RTE_ETH_FEC_LLRS,           /**< FEC using LLRS algorithm */
1920 };
1921 
1922 /* Translate from FEC mode to FEC capa */
1923 #define RTE_ETH_FEC_MODE_TO_CAPA(x) RTE_BIT32(x)
1924 
1925 /* This macro indicates FEC capa mask */
1926 #define RTE_ETH_FEC_MODE_CAPA_MASK(x) RTE_BIT32(RTE_ETH_FEC_ ## x)
1927 
1928 /* A structure used to get capabilities per link speed */
1929 struct rte_eth_fec_capa {
1930 	uint32_t speed; /**< Link speed (see RTE_ETH_SPEED_NUM_*) */
1931 	uint32_t capa;  /**< FEC capabilities bitmask */
1932 };
1933 
1934 #define RTE_ETH_ALL RTE_MAX_ETHPORTS
1935 
1936 /* Macros to check for valid port */
1937 #define RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, retval) do { \
1938 	if (!rte_eth_dev_is_valid_port(port_id)) { \
1939 		RTE_ETHDEV_LOG(ERR, "Invalid port_id=%u\n", port_id); \
1940 		return retval; \
1941 	} \
1942 } while (0)
1943 
1944 #define RTE_ETH_VALID_PORTID_OR_RET(port_id) do { \
1945 	if (!rte_eth_dev_is_valid_port(port_id)) { \
1946 		RTE_ETHDEV_LOG(ERR, "Invalid port_id=%u\n", port_id); \
1947 		return; \
1948 	} \
1949 } while (0)
1950 
1951 /**
1952  * Function type used for Rx packet processing packet callbacks.
1953  *
1954  * The callback function is called on Rx with a burst of packets that have
1955  * been received on the given port and queue.
1956  *
1957  * @param port_id
1958  *   The Ethernet port on which Rx is being performed.
1959  * @param queue
1960  *   The queue on the Ethernet port which is being used to receive the packets.
1961  * @param pkts
1962  *   The burst of packets that have just been received.
1963  * @param nb_pkts
1964  *   The number of packets in the burst pointed to by "pkts".
1965  * @param max_pkts
1966  *   The max number of packets that can be stored in the "pkts" array.
1967  * @param user_param
1968  *   The arbitrary user parameter passed in by the application when the callback
1969  *   was originally configured.
1970  * @return
1971  *   The number of packets returned to the user.
1972  */
1973 typedef uint16_t (*rte_rx_callback_fn)(uint16_t port_id, uint16_t queue,
1974 	struct rte_mbuf *pkts[], uint16_t nb_pkts, uint16_t max_pkts,
1975 	void *user_param);
1976 
1977 /**
1978  * Function type used for Tx packet processing packet callbacks.
1979  *
1980  * The callback function is called on Tx with a burst of packets immediately
1981  * before the packets are put onto the hardware queue for transmission.
1982  *
1983  * @param port_id
1984  *   The Ethernet port on which Tx is being performed.
1985  * @param queue
1986  *   The queue on the Ethernet port which is being used to transmit the packets.
1987  * @param pkts
1988  *   The burst of packets that are about to be transmitted.
1989  * @param nb_pkts
1990  *   The number of packets in the burst pointed to by "pkts".
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 to be written to the NIC.
1996  */
1997 typedef uint16_t (*rte_tx_callback_fn)(uint16_t port_id, uint16_t queue,
1998 	struct rte_mbuf *pkts[], uint16_t nb_pkts, void *user_param);
1999 
2000 /**
2001  * Possible states of an ethdev port.
2002  */
2003 enum rte_eth_dev_state {
2004 	/** Device is unused before being probed. */
2005 	RTE_ETH_DEV_UNUSED = 0,
2006 	/** Device is attached when allocated in probing. */
2007 	RTE_ETH_DEV_ATTACHED,
2008 	/** Device is in removed state when plug-out is detected. */
2009 	RTE_ETH_DEV_REMOVED,
2010 };
2011 
2012 struct rte_eth_dev_sriov {
2013 	uint8_t active;               /**< SRIOV is active with 16, 32 or 64 pools */
2014 	uint8_t nb_q_per_pool;        /**< Rx queue number per pool */
2015 	uint16_t def_vmdq_idx;        /**< Default pool num used for PF */
2016 	uint16_t def_pool_q_idx;      /**< Default pool queue start reg index */
2017 };
2018 #define RTE_ETH_DEV_SRIOV(dev)         ((dev)->data->sriov)
2019 
2020 #define RTE_ETH_NAME_MAX_LEN RTE_DEV_NAME_MAX_LEN
2021 
2022 #define RTE_ETH_DEV_NO_OWNER 0
2023 
2024 #define RTE_ETH_MAX_OWNER_NAME_LEN 64
2025 
2026 struct rte_eth_dev_owner {
2027 	uint64_t id; /**< The owner unique identifier. */
2028 	char name[RTE_ETH_MAX_OWNER_NAME_LEN]; /**< The owner name. */
2029 };
2030 
2031 /**@{@name Device flags
2032  * Flags internally saved in rte_eth_dev_data.dev_flags
2033  * and reported in rte_eth_dev_info.dev_flags.
2034  */
2035 /** PMD supports thread-safe flow operations */
2036 #define RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE  RTE_BIT32(0)
2037 /** Device supports link state interrupt */
2038 #define RTE_ETH_DEV_INTR_LSC              RTE_BIT32(1)
2039 /** Device is a bonded slave */
2040 #define RTE_ETH_DEV_BONDED_SLAVE          RTE_BIT32(2)
2041 /** Device supports device removal interrupt */
2042 #define RTE_ETH_DEV_INTR_RMV              RTE_BIT32(3)
2043 /** Device is port representor */
2044 #define RTE_ETH_DEV_REPRESENTOR           RTE_BIT32(4)
2045 /** Device does not support MAC change after started */
2046 #define RTE_ETH_DEV_NOLIVE_MAC_ADDR       RTE_BIT32(5)
2047 /**
2048  * Queue xstats filled automatically by ethdev layer.
2049  * PMDs filling the queue xstats themselves should not set this flag
2050  */
2051 #define RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS RTE_BIT32(6)
2052 /**@}*/
2053 
2054 /**
2055  * Iterates over valid ethdev ports owned by a specific owner.
2056  *
2057  * @param port_id
2058  *   The ID of the next possible valid owned port.
2059  * @param	owner_id
2060  *  The owner identifier.
2061  *  RTE_ETH_DEV_NO_OWNER means iterate over all valid ownerless ports.
2062  * @return
2063  *   Next valid port ID owned by owner_id, RTE_MAX_ETHPORTS if there is none.
2064  */
2065 uint64_t rte_eth_find_next_owned_by(uint16_t port_id,
2066 		const uint64_t owner_id);
2067 
2068 /**
2069  * Macro to iterate over all enabled ethdev ports owned by a specific owner.
2070  */
2071 #define RTE_ETH_FOREACH_DEV_OWNED_BY(p, o) \
2072 	for (p = rte_eth_find_next_owned_by(0, o); \
2073 	     (unsigned int)p < (unsigned int)RTE_MAX_ETHPORTS; \
2074 	     p = rte_eth_find_next_owned_by(p + 1, o))
2075 
2076 /**
2077  * Iterates over valid ethdev ports.
2078  *
2079  * @param port_id
2080  *   The ID of the next possible valid port.
2081  * @return
2082  *   Next valid port ID, RTE_MAX_ETHPORTS if there is none.
2083  */
2084 uint16_t rte_eth_find_next(uint16_t port_id);
2085 
2086 /**
2087  * Macro to iterate over all enabled and ownerless ethdev ports.
2088  */
2089 #define RTE_ETH_FOREACH_DEV(p) \
2090 	RTE_ETH_FOREACH_DEV_OWNED_BY(p, RTE_ETH_DEV_NO_OWNER)
2091 
2092 /**
2093  * Iterates over ethdev ports of a specified device.
2094  *
2095  * @param port_id_start
2096  *   The ID of the next possible valid port.
2097  * @param parent
2098  *   The generic device behind the ports to iterate.
2099  * @return
2100  *   Next port ID of the device, possibly port_id_start,
2101  *   RTE_MAX_ETHPORTS if there is none.
2102  */
2103 uint16_t
2104 rte_eth_find_next_of(uint16_t port_id_start,
2105 		const struct rte_device *parent);
2106 
2107 /**
2108  * Macro to iterate over all ethdev ports of a specified device.
2109  *
2110  * @param port_id
2111  *   The ID of the matching port being iterated.
2112  * @param parent
2113  *   The rte_device pointer matching the iterated ports.
2114  */
2115 #define RTE_ETH_FOREACH_DEV_OF(port_id, parent) \
2116 	for (port_id = rte_eth_find_next_of(0, parent); \
2117 		port_id < RTE_MAX_ETHPORTS; \
2118 		port_id = rte_eth_find_next_of(port_id + 1, parent))
2119 
2120 /**
2121  * Iterates over sibling ethdev ports (i.e. sharing the same rte_device).
2122  *
2123  * @param port_id_start
2124  *   The ID of the next possible valid sibling port.
2125  * @param ref_port_id
2126  *   The ID of a reference port to compare rte_device with.
2127  * @return
2128  *   Next sibling port ID, possibly port_id_start or ref_port_id itself,
2129  *   RTE_MAX_ETHPORTS if there is none.
2130  */
2131 uint16_t
2132 rte_eth_find_next_sibling(uint16_t port_id_start, uint16_t ref_port_id);
2133 
2134 /**
2135  * Macro to iterate over all ethdev ports sharing the same rte_device
2136  * as the specified port.
2137  * Note: the specified reference port is part of the loop iterations.
2138  *
2139  * @param port_id
2140  *   The ID of the matching port being iterated.
2141  * @param ref_port_id
2142  *   The ID of the port being compared.
2143  */
2144 #define RTE_ETH_FOREACH_DEV_SIBLING(port_id, ref_port_id) \
2145 	for (port_id = rte_eth_find_next_sibling(0, ref_port_id); \
2146 		port_id < RTE_MAX_ETHPORTS; \
2147 		port_id = rte_eth_find_next_sibling(port_id + 1, ref_port_id))
2148 
2149 /**
2150  * Get a new unique owner identifier.
2151  * An owner identifier is used to owns Ethernet devices by only one DPDK entity
2152  * to avoid multiple management of device by different entities.
2153  *
2154  * @param	owner_id
2155  *   Owner identifier pointer.
2156  * @return
2157  *   Negative errno value on error, 0 on success.
2158  */
2159 int rte_eth_dev_owner_new(uint64_t *owner_id);
2160 
2161 /**
2162  * Set an Ethernet device owner.
2163  *
2164  * @param	port_id
2165  *  The identifier of the port to own.
2166  * @param	owner
2167  *  The owner pointer.
2168  * @return
2169  *  Negative errno value on error, 0 on success.
2170  */
2171 int rte_eth_dev_owner_set(const uint16_t port_id,
2172 		const struct rte_eth_dev_owner *owner);
2173 
2174 /**
2175  * Unset Ethernet device owner to make the device ownerless.
2176  *
2177  * @param	port_id
2178  *  The identifier of port to make ownerless.
2179  * @param	owner_id
2180  *  The owner identifier.
2181  * @return
2182  *  0 on success, negative errno value on error.
2183  */
2184 int rte_eth_dev_owner_unset(const uint16_t port_id,
2185 		const uint64_t owner_id);
2186 
2187 /**
2188  * Remove owner from all Ethernet devices owned by a specific owner.
2189  *
2190  * @param	owner_id
2191  *  The owner identifier.
2192  * @return
2193  *  0 on success, negative errno value on error.
2194  */
2195 int rte_eth_dev_owner_delete(const uint64_t owner_id);
2196 
2197 /**
2198  * Get the owner of an Ethernet device.
2199  *
2200  * @param	port_id
2201  *  The port identifier.
2202  * @param	owner
2203  *  The owner structure pointer to fill.
2204  * @return
2205  *  0 on success, negative errno value on error..
2206  */
2207 int rte_eth_dev_owner_get(const uint16_t port_id,
2208 		struct rte_eth_dev_owner *owner);
2209 
2210 /**
2211  * Get the number of ports which are usable for the application.
2212  *
2213  * These devices must be iterated by using the macro
2214  * ``RTE_ETH_FOREACH_DEV`` or ``RTE_ETH_FOREACH_DEV_OWNED_BY``
2215  * to deal with non-contiguous ranges of devices.
2216  *
2217  * @return
2218  *   The count of available Ethernet devices.
2219  */
2220 uint16_t rte_eth_dev_count_avail(void);
2221 
2222 /**
2223  * Get the total number of ports which are allocated.
2224  *
2225  * Some devices may not be available for the application.
2226  *
2227  * @return
2228  *   The total count of Ethernet devices.
2229  */
2230 uint16_t rte_eth_dev_count_total(void);
2231 
2232 /**
2233  * Convert a numerical speed in Mbps to a bitmap flag that can be used in
2234  * the bitmap link_speeds of the struct rte_eth_conf
2235  *
2236  * @param speed
2237  *   Numerical speed value in Mbps
2238  * @param duplex
2239  *   RTE_ETH_LINK_[HALF/FULL]_DUPLEX (only for 10/100M speeds)
2240  * @return
2241  *   0 if the speed cannot be mapped
2242  */
2243 uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex);
2244 
2245 /**
2246  * Get RTE_ETH_RX_OFFLOAD_* flag name.
2247  *
2248  * @param offload
2249  *   Offload flag.
2250  * @return
2251  *   Offload name or 'UNKNOWN' if the flag cannot be recognised.
2252  */
2253 const char *rte_eth_dev_rx_offload_name(uint64_t offload);
2254 
2255 /**
2256  * Get RTE_ETH_TX_OFFLOAD_* flag name.
2257  *
2258  * @param offload
2259  *   Offload flag.
2260  * @return
2261  *   Offload name or 'UNKNOWN' if the flag cannot be recognised.
2262  */
2263 const char *rte_eth_dev_tx_offload_name(uint64_t offload);
2264 
2265 /**
2266  * @warning
2267  * @b EXPERIMENTAL: this API may change without prior notice.
2268  *
2269  * Get RTE_ETH_DEV_CAPA_* flag name.
2270  *
2271  * @param capability
2272  *   Capability flag.
2273  * @return
2274  *   Capability name or 'UNKNOWN' if the flag cannot be recognized.
2275  */
2276 __rte_experimental
2277 const char *rte_eth_dev_capability_name(uint64_t capability);
2278 
2279 /**
2280  * Configure an Ethernet device.
2281  * This function must be invoked first before any other function in the
2282  * Ethernet API. This function can also be re-invoked when a device is in the
2283  * stopped state.
2284  *
2285  * @param port_id
2286  *   The port identifier of the Ethernet device to configure.
2287  * @param nb_rx_queue
2288  *   The number of receive queues to set up for the Ethernet device.
2289  * @param nb_tx_queue
2290  *   The number of transmit queues to set up for the Ethernet device.
2291  * @param eth_conf
2292  *   The pointer to the configuration data to be used for the Ethernet device.
2293  *   The *rte_eth_conf* structure includes:
2294  *     -  the hardware offload features to activate, with dedicated fields for
2295  *        each statically configurable offload hardware feature provided by
2296  *        Ethernet devices, such as IP checksum or VLAN tag stripping for
2297  *        example.
2298  *        The Rx offload bitfield API is obsolete and will be deprecated.
2299  *        Applications should set the ignore_bitfield_offloads bit on *rxmode*
2300  *        structure and use offloads field to set per-port offloads instead.
2301  *     -  Any offloading set in eth_conf->[rt]xmode.offloads must be within
2302  *        the [rt]x_offload_capa returned from rte_eth_dev_info_get().
2303  *        Any type of device supported offloading set in the input argument
2304  *        eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is enabled
2305  *        on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup()
2306  *     -  the Receive Side Scaling (RSS) configuration when using multiple Rx
2307  *        queues per port. Any RSS hash function set in eth_conf->rss_conf.rss_hf
2308  *        must be within the flow_type_rss_offloads provided by drivers via
2309  *        rte_eth_dev_info_get() API.
2310  *
2311  *   Embedding all configuration information in a single data structure
2312  *   is the more flexible method that allows the addition of new features
2313  *   without changing the syntax of the API.
2314  * @return
2315  *   - 0: Success, device configured.
2316  *   - <0: Error code returned by the driver configuration function.
2317  */
2318 int rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_queue,
2319 		uint16_t nb_tx_queue, const struct rte_eth_conf *eth_conf);
2320 
2321 /**
2322  * Check if an Ethernet device was physically removed.
2323  *
2324  * @param port_id
2325  *   The port identifier of the Ethernet device.
2326  * @return
2327  *   1 when the Ethernet device is removed, otherwise 0.
2328  */
2329 int
2330 rte_eth_dev_is_removed(uint16_t port_id);
2331 
2332 /**
2333  * Allocate and set up a receive queue for an Ethernet device.
2334  *
2335  * The function allocates a contiguous block of memory for *nb_rx_desc*
2336  * receive descriptors from a memory zone associated with *socket_id*
2337  * and initializes each receive descriptor with a network buffer allocated
2338  * from the memory pool *mb_pool*.
2339  *
2340  * @param port_id
2341  *   The port identifier of the Ethernet device.
2342  * @param rx_queue_id
2343  *   The index of the receive queue to set up.
2344  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
2345  *   to rte_eth_dev_configure().
2346  * @param nb_rx_desc
2347  *   The number of receive descriptors to allocate for the receive ring.
2348  * @param socket_id
2349  *   The *socket_id* argument is the socket identifier in case of NUMA.
2350  *   The value can be *SOCKET_ID_ANY* if there is no NUMA constraint for
2351  *   the DMA memory allocated for the receive descriptors of the ring.
2352  * @param rx_conf
2353  *   The pointer to the configuration data to be used for the receive queue.
2354  *   NULL value is allowed, in which case default Rx configuration
2355  *   will be used.
2356  *   The *rx_conf* structure contains an *rx_thresh* structure with the values
2357  *   of the Prefetch, Host, and Write-Back threshold registers of the receive
2358  *   ring.
2359  *   In addition it contains the hardware offloads features to activate using
2360  *   the RTE_ETH_RX_OFFLOAD_* flags.
2361  *   If an offloading set in rx_conf->offloads
2362  *   hasn't been set in the input argument eth_conf->rxmode.offloads
2363  *   to rte_eth_dev_configure(), it is a new added offloading, it must be
2364  *   per-queue type and it is enabled for the queue.
2365  *   No need to repeat any bit in rx_conf->offloads which has already been
2366  *   enabled in rte_eth_dev_configure() at port level. An offloading enabled
2367  *   at port level can't be disabled at queue level.
2368  *   The configuration structure also contains the pointer to the array
2369  *   of the receiving buffer segment descriptions, see rx_seg and rx_nseg
2370  *   fields, this extended configuration might be used by split offloads like
2371  *   RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT. If mb_pool is not NULL,
2372  *   the extended configuration fields must be set to NULL and zero.
2373  * @param mb_pool
2374  *   The pointer to the memory pool from which to allocate *rte_mbuf* network
2375  *   memory buffers to populate each descriptor of the receive ring. There are
2376  *   two options to provide Rx buffer configuration:
2377  *   - single pool:
2378  *     mb_pool is not NULL, rx_conf.rx_nseg is 0.
2379  *   - multiple segments description:
2380  *     mb_pool is NULL, rx_conf.rx_seg is not NULL, rx_conf.rx_nseg is not 0.
2381  *     Taken only if flag RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is set in offloads.
2382  *
2383  * @return
2384  *   - 0: Success, receive queue correctly set up.
2385  *   - -EIO: if device is removed.
2386  *   - -ENODEV: if *port_id* is invalid.
2387  *   - -EINVAL: The memory pool pointer is null or the size of network buffers
2388  *      which can be allocated from this memory pool does not fit the various
2389  *      buffer sizes allowed by the device controller.
2390  *   - -ENOMEM: Unable to allocate the receive ring descriptors or to
2391  *      allocate network memory buffers from the memory pool when
2392  *      initializing receive descriptors.
2393  */
2394 int rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
2395 		uint16_t nb_rx_desc, unsigned int socket_id,
2396 		const struct rte_eth_rxconf *rx_conf,
2397 		struct rte_mempool *mb_pool);
2398 
2399 /**
2400  * @warning
2401  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
2402  *
2403  * Allocate and set up a hairpin receive queue for an Ethernet device.
2404  *
2405  * The function set up the selected queue to be used in hairpin.
2406  *
2407  * @param port_id
2408  *   The port identifier of the Ethernet device.
2409  * @param rx_queue_id
2410  *   The index of the receive queue to set up.
2411  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
2412  *   to rte_eth_dev_configure().
2413  * @param nb_rx_desc
2414  *   The number of receive descriptors to allocate for the receive ring.
2415  *   0 means the PMD will use default value.
2416  * @param conf
2417  *   The pointer to the hairpin configuration.
2418  *
2419  * @return
2420  *   - (0) if successful.
2421  *   - (-ENODEV) if *port_id* is invalid.
2422  *   - (-ENOTSUP) if hardware doesn't support.
2423  *   - (-EINVAL) if bad parameter.
2424  *   - (-ENOMEM) if unable to allocate the resources.
2425  */
2426 __rte_experimental
2427 int rte_eth_rx_hairpin_queue_setup
2428 	(uint16_t port_id, uint16_t rx_queue_id, uint16_t nb_rx_desc,
2429 	 const struct rte_eth_hairpin_conf *conf);
2430 
2431 /**
2432  * Allocate and set up a transmit queue for an Ethernet device.
2433  *
2434  * @param port_id
2435  *   The port identifier of the Ethernet device.
2436  * @param tx_queue_id
2437  *   The index of the transmit queue to set up.
2438  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
2439  *   to rte_eth_dev_configure().
2440  * @param nb_tx_desc
2441  *   The number of transmit descriptors to allocate for the transmit ring.
2442  * @param socket_id
2443  *   The *socket_id* argument is the socket identifier in case of NUMA.
2444  *   Its value can be *SOCKET_ID_ANY* if there is no NUMA constraint for
2445  *   the DMA memory allocated for the transmit descriptors of the ring.
2446  * @param tx_conf
2447  *   The pointer to the configuration data to be used for the transmit queue.
2448  *   NULL value is allowed, in which case default Tx configuration
2449  *   will be used.
2450  *   The *tx_conf* structure contains the following data:
2451  *   - The *tx_thresh* structure with the values of the Prefetch, Host, and
2452  *     Write-Back threshold registers of the transmit ring.
2453  *     When setting Write-Back threshold to the value greater then zero,
2454  *     *tx_rs_thresh* value should be explicitly set to one.
2455  *   - The *tx_free_thresh* value indicates the [minimum] number of network
2456  *     buffers that must be pending in the transmit ring to trigger their
2457  *     [implicit] freeing by the driver transmit function.
2458  *   - The *tx_rs_thresh* value indicates the [minimum] number of transmit
2459  *     descriptors that must be pending in the transmit ring before setting the
2460  *     RS bit on a descriptor by the driver transmit function.
2461  *     The *tx_rs_thresh* value should be less or equal then
2462  *     *tx_free_thresh* value, and both of them should be less then
2463  *     *nb_tx_desc* - 3.
2464  *   - The *offloads* member contains Tx offloads to be enabled.
2465  *     If an offloading set in tx_conf->offloads
2466  *     hasn't been set in the input argument eth_conf->txmode.offloads
2467  *     to rte_eth_dev_configure(), it is a new added offloading, it must be
2468  *     per-queue type and it is enabled for the queue.
2469  *     No need to repeat any bit in tx_conf->offloads which has already been
2470  *     enabled in rte_eth_dev_configure() at port level. An offloading enabled
2471  *     at port level can't be disabled at queue level.
2472  *
2473  *     Note that setting *tx_free_thresh* or *tx_rs_thresh* value to 0 forces
2474  *     the transmit function to use default values.
2475  * @return
2476  *   - 0: Success, the transmit queue is correctly set up.
2477  *   - -ENOMEM: Unable to allocate the transmit ring descriptors.
2478  */
2479 int rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
2480 		uint16_t nb_tx_desc, unsigned int socket_id,
2481 		const struct rte_eth_txconf *tx_conf);
2482 
2483 /**
2484  * @warning
2485  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
2486  *
2487  * Allocate and set up a transmit hairpin queue for an Ethernet device.
2488  *
2489  * @param port_id
2490  *   The port identifier of the Ethernet device.
2491  * @param tx_queue_id
2492  *   The index of the transmit queue to set up.
2493  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
2494  *   to rte_eth_dev_configure().
2495  * @param nb_tx_desc
2496  *   The number of transmit descriptors to allocate for the transmit ring.
2497  *   0 to set default PMD value.
2498  * @param conf
2499  *   The hairpin configuration.
2500  *
2501  * @return
2502  *   - (0) if successful.
2503  *   - (-ENODEV) if *port_id* is invalid.
2504  *   - (-ENOTSUP) if hardware doesn't support.
2505  *   - (-EINVAL) if bad parameter.
2506  *   - (-ENOMEM) if unable to allocate the resources.
2507  */
2508 __rte_experimental
2509 int rte_eth_tx_hairpin_queue_setup
2510 	(uint16_t port_id, uint16_t tx_queue_id, uint16_t nb_tx_desc,
2511 	 const struct rte_eth_hairpin_conf *conf);
2512 
2513 /**
2514  * @warning
2515  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
2516  *
2517  * Get all the hairpin peer Rx / Tx ports of the current port.
2518  * The caller should ensure that the array is large enough to save the ports
2519  * list.
2520  *
2521  * @param port_id
2522  *   The port identifier of the Ethernet device.
2523  * @param peer_ports
2524  *   Pointer to the array to store the peer ports list.
2525  * @param len
2526  *   Length of the array to store the port identifiers.
2527  * @param direction
2528  *   Current port to peer port direction
2529  *   positive - current used as Tx to get all peer Rx ports.
2530  *   zero - current used as Rx to get all peer Tx ports.
2531  *
2532  * @return
2533  *   - (0 or positive) actual peer ports number.
2534  *   - (-EINVAL) if bad parameter.
2535  *   - (-ENODEV) if *port_id* invalid
2536  *   - (-ENOTSUP) if hardware doesn't support.
2537  *   - Others detailed errors from PMDs.
2538  */
2539 __rte_experimental
2540 int rte_eth_hairpin_get_peer_ports(uint16_t port_id, uint16_t *peer_ports,
2541 				   size_t len, uint32_t direction);
2542 
2543 /**
2544  * @warning
2545  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
2546  *
2547  * Bind all hairpin Tx queues of one port to the Rx queues of the peer port.
2548  * It is only allowed to call this function after all hairpin queues are
2549  * configured properly and the devices are in started state.
2550  *
2551  * @param tx_port
2552  *   The identifier of the Tx port.
2553  * @param rx_port
2554  *   The identifier of peer Rx port.
2555  *   RTE_MAX_ETHPORTS is allowed for the traversal of all devices.
2556  *   Rx port ID could have the same value as Tx port ID.
2557  *
2558  * @return
2559  *   - (0) if successful.
2560  *   - (-ENODEV) if Tx port ID is invalid.
2561  *   - (-EBUSY) if device is not in started state.
2562  *   - (-ENOTSUP) if hardware doesn't support.
2563  *   - Others detailed errors from PMDs.
2564  */
2565 __rte_experimental
2566 int rte_eth_hairpin_bind(uint16_t tx_port, uint16_t rx_port);
2567 
2568 /**
2569  * @warning
2570  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
2571  *
2572  * Unbind all hairpin Tx queues of one port from the Rx queues of the peer port.
2573  * This should be called before closing the Tx or Rx devices, if the bind
2574  * function is called before.
2575  * After unbinding the hairpin ports pair, it is allowed to bind them again.
2576  * Changing queues configuration should be after stopping the device(s).
2577  *
2578  * @param tx_port
2579  *   The identifier of the Tx port.
2580  * @param rx_port
2581  *   The identifier of peer Rx port.
2582  *   RTE_MAX_ETHPORTS is allowed for traversal of all devices.
2583  *   Rx port ID could have the same value as Tx port ID.
2584  *
2585  * @return
2586  *   - (0) if successful.
2587  *   - (-ENODEV) if Tx port ID is invalid.
2588  *   - (-EBUSY) if device is in stopped state.
2589  *   - (-ENOTSUP) if hardware doesn't support.
2590  *   - Others detailed errors from PMDs.
2591  */
2592 __rte_experimental
2593 int rte_eth_hairpin_unbind(uint16_t tx_port, uint16_t rx_port);
2594 
2595 /**
2596  * @warning
2597  * @b EXPERIMENTAL: this API may change without prior notice.
2598  *
2599  *  Get the number of aggregated ports of the DPDK port (specified with port_id).
2600  *  It is used when multiple ports are aggregated into a single one.
2601  *
2602  *  For the regular physical port doesn't have aggregated ports,
2603  *  the number of aggregated ports is reported as 0.
2604  *
2605  * @param port_id
2606  *   The port identifier of the Ethernet device.
2607  * @return
2608  *   - (>=0) the number of aggregated port if success.
2609  */
2610 __rte_experimental
2611 int rte_eth_dev_count_aggr_ports(uint16_t port_id);
2612 
2613 /**
2614  * @warning
2615  * @b EXPERIMENTAL: this API may change without prior notice.
2616  *
2617  *  Map a Tx queue with an aggregated port of the DPDK port (specified with port_id).
2618  *  When multiple ports are aggregated into a single one,
2619  *  it allows to choose which port to use for Tx via a queue.
2620  *
2621  *  The application should use rte_eth_dev_map_aggr_tx_affinity()
2622  *  after rte_eth_dev_configure(), rte_eth_tx_queue_setup(), and
2623  *  before rte_eth_dev_start().
2624  *
2625  * @param port_id
2626  *   The identifier of the port used in rte_eth_tx_burst().
2627  * @param tx_queue_id
2628  *   The index of the transmit queue used in rte_eth_tx_burst().
2629  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
2630  *   to rte_eth_dev_configure().
2631  * @param affinity
2632  *   The number of the aggregated port.
2633  *   Value 0 means no affinity and traffic could be routed to any aggregated port.
2634  *   The first aggregated port is number 1 and so on.
2635  *   The maximum number is given by rte_eth_dev_count_aggr_ports().
2636  *
2637  * @return
2638  *   Zero if successful. Non-zero otherwise.
2639  */
2640 __rte_experimental
2641 int rte_eth_dev_map_aggr_tx_affinity(uint16_t port_id, uint16_t tx_queue_id,
2642 				     uint8_t affinity);
2643 
2644 /**
2645  * Return the NUMA socket to which an Ethernet device is connected
2646  *
2647  * @param port_id
2648  *   The port identifier of the Ethernet device
2649  * @return
2650  *   - The NUMA socket ID which the Ethernet device is connected to.
2651  *   - -1 (which translates to SOCKET_ID_ANY) if the socket could not be
2652  *     determined. rte_errno is then set to:
2653  *     - EINVAL is the port_id is invalid,
2654  *     - 0 is the socket could not be determined,
2655  */
2656 int rte_eth_dev_socket_id(uint16_t port_id);
2657 
2658 /**
2659  * Check if port_id of device is attached
2660  *
2661  * @param port_id
2662  *   The port identifier of the Ethernet device
2663  * @return
2664  *   - 0 if port is out of range or not attached
2665  *   - 1 if device is attached
2666  */
2667 int rte_eth_dev_is_valid_port(uint16_t port_id);
2668 
2669 /**
2670  * @warning
2671  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice.
2672  *
2673  * Check if Rx queue is valid.
2674  * If the queue has been setup, it is considered valid.
2675  *
2676  * @param port_id
2677  *   The port identifier of the Ethernet device.
2678  * @param queue_id
2679  *   The index of the receive queue.
2680  * @return
2681  *   - -ENODEV: if port_id is invalid.
2682  *   - -EINVAL: if queue_id is out of range or queue has not been setup.
2683  *   - 0 if Rx queue is valid.
2684  */
2685 __rte_experimental
2686 int rte_eth_dev_is_valid_rxq(uint16_t port_id, uint16_t queue_id);
2687 
2688 /**
2689  * @warning
2690  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice.
2691  *
2692  * Check if Tx queue is valid.
2693  * If the queue has been setup, it is considered valid.
2694  *
2695  * @param port_id
2696  *   The port identifier of the Ethernet device.
2697  * @param queue_id
2698  *   The index of the transmit queue.
2699  * @return
2700  *   - -ENODEV: if port_id is invalid.
2701  *   - -EINVAL: if queue_id is out of range or queue has not been setup.
2702  *   - 0 if Tx queue is valid.
2703  */
2704 __rte_experimental
2705 int rte_eth_dev_is_valid_txq(uint16_t port_id, uint16_t queue_id);
2706 
2707 /**
2708  * Start specified Rx queue of a port. It is used when rx_deferred_start
2709  * flag of the specified queue is true.
2710  *
2711  * @param port_id
2712  *   The port identifier of the Ethernet device
2713  * @param rx_queue_id
2714  *   The index of the Rx queue to update the ring.
2715  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
2716  *   to rte_eth_dev_configure().
2717  * @return
2718  *   - 0: Success, the receive queue is started.
2719  *   - -ENODEV: if *port_id* is invalid.
2720  *   - -EINVAL: The queue_id out of range or belong to hairpin.
2721  *   - -EIO: if device is removed.
2722  *   - -ENOTSUP: The function not supported in PMD.
2723  */
2724 int rte_eth_dev_rx_queue_start(uint16_t port_id, uint16_t rx_queue_id);
2725 
2726 /**
2727  * Stop specified Rx queue of a port
2728  *
2729  * @param port_id
2730  *   The port identifier of the Ethernet device
2731  * @param rx_queue_id
2732  *   The index of the Rx queue to update the ring.
2733  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
2734  *   to rte_eth_dev_configure().
2735  * @return
2736  *   - 0: Success, the receive queue is stopped.
2737  *   - -ENODEV: if *port_id* is invalid.
2738  *   - -EINVAL: The queue_id out of range or belong to hairpin.
2739  *   - -EIO: if device is removed.
2740  *   - -ENOTSUP: The function not supported in PMD.
2741  */
2742 int rte_eth_dev_rx_queue_stop(uint16_t port_id, uint16_t rx_queue_id);
2743 
2744 /**
2745  * Start Tx for specified queue of a port. It is used when tx_deferred_start
2746  * flag of the specified queue is true.
2747  *
2748  * @param port_id
2749  *   The port identifier of the Ethernet device
2750  * @param tx_queue_id
2751  *   The index of the Tx queue to update the ring.
2752  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
2753  *   to rte_eth_dev_configure().
2754  * @return
2755  *   - 0: Success, the transmit queue is started.
2756  *   - -ENODEV: if *port_id* is invalid.
2757  *   - -EINVAL: The queue_id out of range or belong to hairpin.
2758  *   - -EIO: if device is removed.
2759  *   - -ENOTSUP: The function not supported in PMD.
2760  */
2761 int rte_eth_dev_tx_queue_start(uint16_t port_id, uint16_t tx_queue_id);
2762 
2763 /**
2764  * Stop specified Tx queue of a port
2765  *
2766  * @param port_id
2767  *   The port identifier of the Ethernet device
2768  * @param tx_queue_id
2769  *   The index of the Tx queue to update the ring.
2770  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
2771  *   to rte_eth_dev_configure().
2772  * @return
2773  *   - 0: Success, the transmit queue is stopped.
2774  *   - -ENODEV: if *port_id* is invalid.
2775  *   - -EINVAL: The queue_id out of range or belong to hairpin.
2776  *   - -EIO: if device is removed.
2777  *   - -ENOTSUP: The function not supported in PMD.
2778  */
2779 int rte_eth_dev_tx_queue_stop(uint16_t port_id, uint16_t tx_queue_id);
2780 
2781 /**
2782  * Start an Ethernet device.
2783  *
2784  * The device start step is the last one and consists of setting the configured
2785  * offload features and in starting the transmit and the receive units of the
2786  * device.
2787  *
2788  * Device RTE_ETH_DEV_NOLIVE_MAC_ADDR flag causes MAC address to be set before
2789  * PMD port start callback function is invoked.
2790  *
2791  * On success, all basic functions exported by the Ethernet API (link status,
2792  * receive/transmit, and so on) can be invoked.
2793  *
2794  * @param port_id
2795  *   The port identifier of the Ethernet device.
2796  * @return
2797  *   - 0: Success, Ethernet device started.
2798  *   - -EAGAIN: If start operation must be retried.
2799  *   - <0: Error code of the driver device start function.
2800  */
2801 int rte_eth_dev_start(uint16_t port_id);
2802 
2803 /**
2804  * Stop an Ethernet device. The device can be restarted with a call to
2805  * rte_eth_dev_start()
2806  *
2807  * @param port_id
2808  *   The port identifier of the Ethernet device.
2809  * @return
2810  *   - 0: Success, Ethernet device stopped.
2811  *   - -EBUSY: If stopping the port is not allowed in current state.
2812  *   - <0: Error code of the driver device stop function.
2813  */
2814 int rte_eth_dev_stop(uint16_t port_id);
2815 
2816 /**
2817  * Link up an Ethernet device.
2818  *
2819  * Set device link up will re-enable the device Rx/Tx
2820  * functionality after it is previously set device linked down.
2821  *
2822  * @param port_id
2823  *   The port identifier of the Ethernet device.
2824  * @return
2825  *   - 0: Success, Ethernet device linked up.
2826  *   - <0: Error code of the driver device link up function.
2827  */
2828 int rte_eth_dev_set_link_up(uint16_t port_id);
2829 
2830 /**
2831  * Link down an Ethernet device.
2832  * The device Rx/Tx functionality will be disabled if success,
2833  * and it can be re-enabled with a call to
2834  * rte_eth_dev_set_link_up()
2835  *
2836  * @param port_id
2837  *   The port identifier of the Ethernet device.
2838  */
2839 int rte_eth_dev_set_link_down(uint16_t port_id);
2840 
2841 /**
2842  * Close a stopped Ethernet device. The device cannot be restarted!
2843  * The function frees all port resources.
2844  *
2845  * @param port_id
2846  *   The port identifier of the Ethernet device.
2847  * @return
2848  *   - Zero if the port is closed successfully.
2849  *   - Negative if something went wrong.
2850  */
2851 int rte_eth_dev_close(uint16_t port_id);
2852 
2853 /**
2854  * Reset a Ethernet device and keep its port ID.
2855  *
2856  * When a port has to be reset passively, the DPDK application can invoke
2857  * this function. For example when a PF is reset, all its VFs should also
2858  * be reset. Normally a DPDK application can invoke this function when
2859  * RTE_ETH_EVENT_INTR_RESET event is detected, but can also use it to start
2860  * a port reset in other circumstances.
2861  *
2862  * When this function is called, it first stops the port and then calls the
2863  * PMD specific dev_uninit( ) and dev_init( ) to return the port to initial
2864  * state, in which no Tx and Rx queues are setup, as if the port has been
2865  * reset and not started. The port keeps the port ID it had before the
2866  * function call.
2867  *
2868  * After calling rte_eth_dev_reset( ), the application should use
2869  * rte_eth_dev_configure( ), rte_eth_rx_queue_setup( ),
2870  * rte_eth_tx_queue_setup( ), and rte_eth_dev_start( )
2871  * to reconfigure the device as appropriate.
2872  *
2873  * Note: To avoid unexpected behavior, the application should stop calling
2874  * Tx and Rx functions before calling rte_eth_dev_reset( ). For thread
2875  * safety, all these controlling functions should be called from the same
2876  * thread.
2877  *
2878  * @param port_id
2879  *   The port identifier of the Ethernet device.
2880  *
2881  * @return
2882  *   - (0) if successful.
2883  *   - (-ENODEV) if *port_id* is invalid.
2884  *   - (-ENOTSUP) if hardware doesn't support this function.
2885  *   - (-EPERM) if not ran from the primary process.
2886  *   - (-EIO) if re-initialisation failed or device is removed.
2887  *   - (-ENOMEM) if the reset failed due to OOM.
2888  *   - (-EAGAIN) if the reset temporarily failed and should be retried later.
2889  */
2890 int rte_eth_dev_reset(uint16_t port_id);
2891 
2892 /**
2893  * Enable receipt in promiscuous mode for an Ethernet device.
2894  *
2895  * @param port_id
2896  *   The port identifier of the Ethernet device.
2897  * @return
2898  *   - (0) if successful.
2899  *   - (-ENOTSUP) if support for promiscuous_enable() does not exist
2900  *     for the device.
2901  *   - (-ENODEV) if *port_id* invalid.
2902  */
2903 int rte_eth_promiscuous_enable(uint16_t port_id);
2904 
2905 /**
2906  * Disable receipt in promiscuous mode for an Ethernet device.
2907  *
2908  * @param port_id
2909  *   The port identifier of the Ethernet device.
2910  * @return
2911  *   - (0) if successful.
2912  *   - (-ENOTSUP) if support for promiscuous_disable() does not exist
2913  *     for the device.
2914  *   - (-ENODEV) if *port_id* invalid.
2915  */
2916 int rte_eth_promiscuous_disable(uint16_t port_id);
2917 
2918 /**
2919  * Return the value of promiscuous mode for an Ethernet device.
2920  *
2921  * @param port_id
2922  *   The port identifier of the Ethernet device.
2923  * @return
2924  *   - (1) if promiscuous is enabled
2925  *   - (0) if promiscuous is disabled.
2926  *   - (-1) on error
2927  */
2928 int rte_eth_promiscuous_get(uint16_t port_id);
2929 
2930 /**
2931  * Enable the receipt of any multicast frame by an Ethernet device.
2932  *
2933  * @param port_id
2934  *   The port identifier of the Ethernet device.
2935  * @return
2936  *   - (0) if successful.
2937  *   - (-ENOTSUP) if support for allmulticast_enable() does not exist
2938  *     for the device.
2939  *   - (-ENODEV) if *port_id* invalid.
2940  */
2941 int rte_eth_allmulticast_enable(uint16_t port_id);
2942 
2943 /**
2944  * Disable the receipt of all multicast frames by an Ethernet device.
2945  *
2946  * @param port_id
2947  *   The port identifier of the Ethernet device.
2948  * @return
2949  *   - (0) if successful.
2950  *   - (-ENOTSUP) if support for allmulticast_disable() does not exist
2951  *     for the device.
2952  *   - (-ENODEV) if *port_id* invalid.
2953  */
2954 int rte_eth_allmulticast_disable(uint16_t port_id);
2955 
2956 /**
2957  * Return the value of allmulticast mode for an Ethernet device.
2958  *
2959  * @param port_id
2960  *   The port identifier of the Ethernet device.
2961  * @return
2962  *   - (1) if allmulticast is enabled
2963  *   - (0) if allmulticast is disabled.
2964  *   - (-1) on error
2965  */
2966 int rte_eth_allmulticast_get(uint16_t port_id);
2967 
2968 /**
2969  * Retrieve the link status (up/down), the duplex mode (half/full),
2970  * the negotiation (auto/fixed), and if available, the speed (Mbps).
2971  *
2972  * It might need to wait up to 9 seconds.
2973  * @see rte_eth_link_get_nowait.
2974  *
2975  * @param port_id
2976  *   The port identifier of the Ethernet device.
2977  * @param link
2978  *   Link information written back.
2979  * @return
2980  *   - (0) if successful.
2981  *   - (-ENOTSUP) if the function is not supported in PMD.
2982  *   - (-ENODEV) if *port_id* invalid.
2983  *   - (-EINVAL) if bad parameter.
2984  */
2985 int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link);
2986 
2987 /**
2988  * Retrieve the link status (up/down), the duplex mode (half/full),
2989  * the negotiation (auto/fixed), and if available, the speed (Mbps).
2990  *
2991  * @param port_id
2992  *   The port identifier of the Ethernet device.
2993  * @param link
2994  *   Link information written back.
2995  * @return
2996  *   - (0) if successful.
2997  *   - (-ENOTSUP) if the function is not supported in PMD.
2998  *   - (-ENODEV) if *port_id* invalid.
2999  *   - (-EINVAL) if bad parameter.
3000  */
3001 int rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *link);
3002 
3003 /**
3004  * @warning
3005  * @b EXPERIMENTAL: this API may change without prior notice.
3006  *
3007  * The function converts a link_speed to a string. It handles all special
3008  * values like unknown or none speed.
3009  *
3010  * @param link_speed
3011  *   link_speed of rte_eth_link struct
3012  * @return
3013  *   Link speed in textual format. It's pointer to immutable memory.
3014  *   No free is required.
3015  */
3016 __rte_experimental
3017 const char *rte_eth_link_speed_to_str(uint32_t link_speed);
3018 
3019 /**
3020  * @warning
3021  * @b EXPERIMENTAL: this API may change without prior notice.
3022  *
3023  * The function converts a rte_eth_link struct representing a link status to
3024  * a string.
3025  *
3026  * @param str
3027  *   A pointer to a string to be filled with textual representation of
3028  *   device status. At least RTE_ETH_LINK_MAX_STR_LEN bytes should be allocated to
3029  *   store default link status text.
3030  * @param len
3031  *   Length of available memory at 'str' string.
3032  * @param eth_link
3033  *   Link status returned by rte_eth_link_get function
3034  * @return
3035  *   Number of bytes written to str array or -EINVAL if bad parameter.
3036  */
3037 __rte_experimental
3038 int rte_eth_link_to_str(char *str, size_t len,
3039 			const struct rte_eth_link *eth_link);
3040 
3041 /**
3042  * Retrieve the general I/O statistics of an Ethernet device.
3043  *
3044  * @param port_id
3045  *   The port identifier of the Ethernet device.
3046  * @param stats
3047  *   A pointer to a structure of type *rte_eth_stats* to be filled with
3048  *   the values of device counters for the following set of statistics:
3049  *   - *ipackets* with the total of successfully received packets.
3050  *   - *opackets* with the total of successfully transmitted packets.
3051  *   - *ibytes*   with the total of successfully received bytes.
3052  *   - *obytes*   with the total of successfully transmitted bytes.
3053  *   - *ierrors*  with the total of erroneous received packets.
3054  *   - *oerrors*  with the total of failed transmitted packets.
3055  * @return
3056  *   Zero if successful. Non-zero otherwise.
3057  */
3058 int rte_eth_stats_get(uint16_t port_id, struct rte_eth_stats *stats);
3059 
3060 /**
3061  * Reset the general I/O statistics of an Ethernet device.
3062  *
3063  * @param port_id
3064  *   The port identifier of the Ethernet device.
3065  * @return
3066  *   - (0) if device notified to reset stats.
3067  *   - (-ENOTSUP) if hardware doesn't support.
3068  *   - (-ENODEV) if *port_id* invalid.
3069  *   - (<0): Error code of the driver stats reset function.
3070  */
3071 int rte_eth_stats_reset(uint16_t port_id);
3072 
3073 /**
3074  * Retrieve names of extended statistics of an Ethernet device.
3075  *
3076  * There is an assumption that 'xstat_names' and 'xstats' arrays are matched
3077  * by array index:
3078  *  xstats_names[i].name => xstats[i].value
3079  *
3080  * And the array index is same with id field of 'struct rte_eth_xstat':
3081  *  xstats[i].id == i
3082  *
3083  * This assumption makes key-value pair matching less flexible but simpler.
3084  *
3085  * @param port_id
3086  *   The port identifier of the Ethernet device.
3087  * @param xstats_names
3088  *   An rte_eth_xstat_name array of at least *size* elements to
3089  *   be filled. If set to NULL, the function returns the required number
3090  *   of elements.
3091  * @param size
3092  *   The size of the xstats_names array (number of elements).
3093  * @return
3094  *   - A positive value lower or equal to size: success. The return value
3095  *     is the number of entries filled in the stats table.
3096  *   - A positive value higher than size: error, the given statistics table
3097  *     is too small. The return value corresponds to the size that should
3098  *     be given to succeed. The entries in the table are not valid and
3099  *     shall not be used by the caller.
3100  *   - A negative value on error (invalid port ID).
3101  */
3102 int rte_eth_xstats_get_names(uint16_t port_id,
3103 		struct rte_eth_xstat_name *xstats_names,
3104 		unsigned int size);
3105 
3106 /**
3107  * Retrieve extended statistics of an Ethernet device.
3108  *
3109  * There is an assumption that 'xstat_names' and 'xstats' arrays are matched
3110  * by array index:
3111  *  xstats_names[i].name => xstats[i].value
3112  *
3113  * And the array index is same with id field of 'struct rte_eth_xstat':
3114  *  xstats[i].id == i
3115  *
3116  * This assumption makes key-value pair matching less flexible but simpler.
3117  *
3118  * @param port_id
3119  *   The port identifier of the Ethernet device.
3120  * @param xstats
3121  *   A pointer to a table of structure of type *rte_eth_xstat*
3122  *   to be filled with device statistics ids and values.
3123  *   This parameter can be set to NULL if and only if n is 0.
3124  * @param n
3125  *   The size of the xstats array (number of elements).
3126  *   If lower than the required number of elements, the function returns
3127  *   the required number of elements.
3128  *   If equal to zero, the xstats must be NULL, the function returns the
3129  *   required number of elements.
3130  * @return
3131  *   - A positive value lower or equal to n: success. The return value
3132  *     is the number of entries filled in the stats table.
3133  *   - A positive value higher than n: error, the given statistics table
3134  *     is too small. The return value corresponds to the size that should
3135  *     be given to succeed. The entries in the table are not valid and
3136  *     shall not be used by the caller.
3137  *   - A negative value on error (invalid port ID).
3138  */
3139 int rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats,
3140 		unsigned int n);
3141 
3142 /**
3143  * Retrieve names of extended statistics of an Ethernet device.
3144  *
3145  * @param port_id
3146  *   The port identifier of the Ethernet device.
3147  * @param xstats_names
3148  *   Array to be filled in with names of requested device statistics.
3149  *   Must not be NULL if @p ids are specified (not NULL).
3150  * @param size
3151  *   Number of elements in @p xstats_names array (if not NULL) and in
3152  *   @p ids array (if not NULL). Must be 0 if both array pointers are NULL.
3153  * @param ids
3154  *   IDs array given by app to retrieve specific statistics. May be NULL to
3155  *   retrieve names of all available statistics or, if @p xstats_names is
3156  *   NULL as well, just the number of available statistics.
3157  * @return
3158  *   - A positive value lower or equal to size: success. The return value
3159  *     is the number of entries filled in the stats table.
3160  *   - A positive value higher than size: success. The given statistics table
3161  *     is too small. The return value corresponds to the size that should
3162  *     be given to succeed. The entries in the table are not valid and
3163  *     shall not be used by the caller.
3164  *   - A negative value on error.
3165  */
3166 int
3167 rte_eth_xstats_get_names_by_id(uint16_t port_id,
3168 	struct rte_eth_xstat_name *xstats_names, unsigned int size,
3169 	uint64_t *ids);
3170 
3171 /**
3172  * Retrieve extended statistics of an Ethernet device.
3173  *
3174  * @param port_id
3175  *   The port identifier of the Ethernet device.
3176  * @param ids
3177  *   IDs array given by app to retrieve specific statistics. May be NULL to
3178  *   retrieve all available statistics or, if @p values is NULL as well,
3179  *   just the number of available statistics.
3180  * @param values
3181  *   Array to be filled in with requested device statistics.
3182  *   Must not be NULL if ids are specified (not NULL).
3183  * @param size
3184  *   Number of elements in @p values array (if not NULL) and in @p ids
3185  *   array (if not NULL). Must be 0 if both array pointers are NULL.
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 rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,
3196 			     uint64_t *values, unsigned int size);
3197 
3198 /**
3199  * Gets the ID of a statistic from its name.
3200  *
3201  * This function searches for the statistics using string compares, and
3202  * as such should not be used on the fast-path. For fast-path retrieval of
3203  * specific statistics, store the ID as provided in *id* from this function,
3204  * and pass the ID to rte_eth_xstats_get()
3205  *
3206  * @param port_id The port to look up statistics from
3207  * @param xstat_name The name of the statistic to return
3208  * @param[out] id A pointer to an app-supplied uint64_t which should be
3209  *                set to the ID of the stat if the stat exists.
3210  * @return
3211  *    0 on success
3212  *    -ENODEV for invalid port_id,
3213  *    -EIO if device is removed,
3214  *    -EINVAL if the xstat_name doesn't exist in port_id
3215  *    -ENOMEM if bad parameter.
3216  */
3217 int rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name,
3218 		uint64_t *id);
3219 
3220 /**
3221  * Reset extended statistics of an Ethernet device.
3222  *
3223  * @param port_id
3224  *   The port identifier of the Ethernet device.
3225  * @return
3226  *   - (0) if device notified to reset extended stats.
3227  *   - (-ENOTSUP) if pmd doesn't support both
3228  *     extended stats and basic stats reset.
3229  *   - (-ENODEV) if *port_id* invalid.
3230  *   - (<0): Error code of the driver xstats reset function.
3231  */
3232 int rte_eth_xstats_reset(uint16_t port_id);
3233 
3234 /**
3235  *  Set a mapping for the specified transmit queue to the specified per-queue
3236  *  statistics counter.
3237  *
3238  * @param port_id
3239  *   The port identifier of the Ethernet device.
3240  * @param tx_queue_id
3241  *   The index of the transmit queue for which a queue stats mapping is required.
3242  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
3243  *   to rte_eth_dev_configure().
3244  * @param stat_idx
3245  *   The per-queue packet statistics functionality number that the transmit
3246  *   queue is to be assigned.
3247  *   The value must be in the range [0, RTE_ETHDEV_QUEUE_STAT_CNTRS - 1].
3248  *   Max RTE_ETHDEV_QUEUE_STAT_CNTRS being 256.
3249  * @return
3250  *   Zero if successful. Non-zero otherwise.
3251  */
3252 int rte_eth_dev_set_tx_queue_stats_mapping(uint16_t port_id,
3253 		uint16_t tx_queue_id, uint8_t stat_idx);
3254 
3255 /**
3256  *  Set a mapping for the specified receive queue to the specified per-queue
3257  *  statistics counter.
3258  *
3259  * @param port_id
3260  *   The port identifier of the Ethernet device.
3261  * @param rx_queue_id
3262  *   The index of the receive queue for which a queue stats mapping is required.
3263  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
3264  *   to rte_eth_dev_configure().
3265  * @param stat_idx
3266  *   The per-queue packet statistics functionality number that the receive
3267  *   queue is to be assigned.
3268  *   The value must be in the range [0, RTE_ETHDEV_QUEUE_STAT_CNTRS - 1].
3269  *   Max RTE_ETHDEV_QUEUE_STAT_CNTRS being 256.
3270  * @return
3271  *   Zero if successful. Non-zero otherwise.
3272  */
3273 int rte_eth_dev_set_rx_queue_stats_mapping(uint16_t port_id,
3274 					   uint16_t rx_queue_id,
3275 					   uint8_t stat_idx);
3276 
3277 /**
3278  * Retrieve the Ethernet address of an Ethernet device.
3279  *
3280  * @param port_id
3281  *   The port identifier of the Ethernet device.
3282  * @param mac_addr
3283  *   A pointer to a structure of type *ether_addr* to be filled with
3284  *   the Ethernet address of the Ethernet device.
3285  * @return
3286  *   - (0) if successful
3287  *   - (-ENODEV) if *port_id* invalid.
3288  *   - (-EINVAL) if bad parameter.
3289  */
3290 int rte_eth_macaddr_get(uint16_t port_id, struct rte_ether_addr *mac_addr);
3291 
3292 /**
3293  * @warning
3294  * @b EXPERIMENTAL: this API may change without prior notice
3295  *
3296  * Retrieve the Ethernet addresses of an Ethernet device.
3297  *
3298  * @param port_id
3299  *   The port identifier of the Ethernet device.
3300  * @param ma
3301  *   A pointer to an array of structures of type *ether_addr* to be filled with
3302  *   the Ethernet addresses of the Ethernet device.
3303  * @param num
3304  *   Number of elements in the @p ma array.
3305  *   Note that  rte_eth_dev_info::max_mac_addrs can be used to retrieve
3306  *   max number of Ethernet addresses for given port.
3307  * @return
3308  *   - number of retrieved addresses if successful
3309  *   - (-ENODEV) if *port_id* invalid.
3310  *   - (-EINVAL) if bad parameter.
3311  */
3312 __rte_experimental
3313 int rte_eth_macaddrs_get(uint16_t port_id, struct rte_ether_addr *ma,
3314 	unsigned int num);
3315 
3316 /**
3317  * Retrieve the contextual information of an Ethernet device.
3318  *
3319  * This function returns the Ethernet device information based
3320  * on the values stored internally in the device specific data.
3321  * For example: number of queues, descriptor limits, device
3322  * capabilities and offload flags.
3323  *
3324  * @param port_id
3325  *   The port identifier of the Ethernet device.
3326  * @param dev_info
3327  *   A pointer to a structure of type *rte_eth_dev_info* to be filled with
3328  *   the contextual information of the Ethernet device.
3329  * @return
3330  *   - (0) if successful.
3331  *   - (-ENOTSUP) if support for dev_infos_get() does not exist for the device.
3332  *   - (-ENODEV) if *port_id* invalid.
3333  *   - (-EINVAL) if bad parameter.
3334  */
3335 int rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info);
3336 
3337 /**
3338  * @warning
3339  * @b EXPERIMENTAL: this API may change without prior notice.
3340  *
3341  * Retrieve the configuration of an Ethernet device.
3342  *
3343  * @param port_id
3344  *   The port identifier of the Ethernet device.
3345  * @param dev_conf
3346  *   Location for Ethernet device configuration to be filled in.
3347  * @return
3348  *   - (0) if successful.
3349  *   - (-ENODEV) if *port_id* invalid.
3350  *   - (-EINVAL) if bad parameter.
3351  */
3352 __rte_experimental
3353 int rte_eth_dev_conf_get(uint16_t port_id, struct rte_eth_conf *dev_conf);
3354 
3355 /**
3356  * Retrieve the firmware version of a device.
3357  *
3358  * @param port_id
3359  *   The port identifier of the device.
3360  * @param fw_version
3361  *   A pointer to a string array storing the firmware version of a device,
3362  *   the string includes terminating null. This pointer is allocated by caller.
3363  * @param fw_size
3364  *   The size of the string array pointed by fw_version, which should be
3365  *   large enough to store firmware version of the device.
3366  * @return
3367  *   - (0) if successful.
3368  *   - (-ENOTSUP) if operation is not supported.
3369  *   - (-ENODEV) if *port_id* invalid.
3370  *   - (-EIO) if device is removed.
3371  *   - (-EINVAL) if bad parameter.
3372  *   - (>0) if *fw_size* is not enough to store firmware version, return
3373  *          the size of the non truncated string.
3374  */
3375 int rte_eth_dev_fw_version_get(uint16_t port_id,
3376 			       char *fw_version, size_t fw_size);
3377 
3378 /**
3379  * Retrieve the supported packet types of an Ethernet device.
3380  *
3381  * When a packet type is announced as supported, it *must* be recognized by
3382  * the PMD. For instance, if RTE_PTYPE_L2_ETHER, RTE_PTYPE_L2_ETHER_VLAN
3383  * and RTE_PTYPE_L3_IPV4 are announced, the PMD must return the following
3384  * packet types for these packets:
3385  * - Ether/IPv4              -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4
3386  * - Ether/VLAN/IPv4         -> RTE_PTYPE_L2_ETHER_VLAN | RTE_PTYPE_L3_IPV4
3387  * - Ether/[anything else]   -> RTE_PTYPE_L2_ETHER
3388  * - Ether/VLAN/[anything else] -> RTE_PTYPE_L2_ETHER_VLAN
3389  *
3390  * When a packet is received by a PMD, the most precise type must be
3391  * returned among the ones supported. However a PMD is allowed to set
3392  * packet type that is not in the supported list, at the condition that it
3393  * is more precise. Therefore, a PMD announcing no supported packet types
3394  * can still set a matching packet type in a received packet.
3395  *
3396  * @note
3397  *   Better to invoke this API after the device is already started or Rx burst
3398  *   function is decided, to obtain correct supported ptypes.
3399  * @note
3400  *   if a given PMD does not report what ptypes it supports, then the supported
3401  *   ptype count is reported as 0.
3402  * @param port_id
3403  *   The port identifier of the Ethernet device.
3404  * @param ptype_mask
3405  *   A hint of what kind of packet type which the caller is interested in.
3406  * @param ptypes
3407  *   An array pointer to store adequate packet types, allocated by caller.
3408  * @param num
3409  *  Size of the array pointed by param ptypes.
3410  * @return
3411  *   - (>=0) Number of supported ptypes. If the number of types exceeds num,
3412  *           only num entries will be filled into the ptypes array, but the full
3413  *           count of supported ptypes will be returned.
3414  *   - (-ENODEV) if *port_id* invalid.
3415  *   - (-EINVAL) if bad parameter.
3416  */
3417 int rte_eth_dev_get_supported_ptypes(uint16_t port_id, uint32_t ptype_mask,
3418 				     uint32_t *ptypes, int num);
3419 /**
3420  * Inform Ethernet device about reduced range of packet types to handle.
3421  *
3422  * Application can use this function to set only specific ptypes that it's
3423  * interested. This information can be used by the PMD to optimize Rx path.
3424  *
3425  * The function accepts an array `set_ptypes` allocated by the caller to
3426  * store the packet types set by the driver, the last element of the array
3427  * is set to RTE_PTYPE_UNKNOWN. The size of the `set_ptype` array should be
3428  * `rte_eth_dev_get_supported_ptypes() + 1` else it might only be filled
3429  * partially.
3430  *
3431  * @param port_id
3432  *   The port identifier of the Ethernet device.
3433  * @param ptype_mask
3434  *   The ptype family that application is interested in should be bitwise OR of
3435  *   RTE_PTYPE_*_MASK or 0.
3436  * @param set_ptypes
3437  *   An array pointer to store set packet types, allocated by caller. The
3438  *   function marks the end of array with RTE_PTYPE_UNKNOWN.
3439  * @param num
3440  *   Size of the array pointed by param ptypes.
3441  *   Should be rte_eth_dev_get_supported_ptypes() + 1 to accommodate the
3442  *   set ptypes.
3443  * @return
3444  *   - (0) if Success.
3445  *   - (-ENODEV) if *port_id* invalid.
3446  *   - (-EINVAL) if *ptype_mask* is invalid (or) set_ptypes is NULL and
3447  *     num > 0.
3448  */
3449 int rte_eth_dev_set_ptypes(uint16_t port_id, uint32_t ptype_mask,
3450 			   uint32_t *set_ptypes, unsigned int num);
3451 
3452 /**
3453  * Retrieve the MTU of an Ethernet device.
3454  *
3455  * @param port_id
3456  *   The port identifier of the Ethernet device.
3457  * @param mtu
3458  *   A pointer to a uint16_t where the retrieved MTU is to be stored.
3459  * @return
3460  *   - (0) if successful.
3461  *   - (-ENODEV) if *port_id* invalid.
3462  *   - (-EINVAL) if bad parameter.
3463  */
3464 int rte_eth_dev_get_mtu(uint16_t port_id, uint16_t *mtu);
3465 
3466 /**
3467  * Change the MTU of an Ethernet device.
3468  *
3469  * @param port_id
3470  *   The port identifier of the Ethernet device.
3471  * @param mtu
3472  *   A uint16_t for the MTU to be applied.
3473  * @return
3474  *   - (0) if successful.
3475  *   - (-ENOTSUP) if operation is not supported.
3476  *   - (-ENODEV) if *port_id* invalid.
3477  *   - (-EIO) if device is removed.
3478  *   - (-EINVAL) if *mtu* invalid, validation of mtu can occur within
3479  *     rte_eth_dev_set_mtu if dev_infos_get is supported by the device or
3480  *     when the mtu is set using dev->dev_ops->mtu_set.
3481  *   - (-EBUSY) if operation is not allowed when the port is running
3482  */
3483 int rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu);
3484 
3485 /**
3486  * Enable/Disable hardware filtering by an Ethernet device of received
3487  * VLAN packets tagged with a given VLAN Tag Identifier.
3488  *
3489  * @param port_id
3490  *   The port identifier of the Ethernet device.
3491  * @param vlan_id
3492  *   The VLAN Tag Identifier whose filtering must be enabled or disabled.
3493  * @param on
3494  *   If > 0, enable VLAN filtering of VLAN packets tagged with *vlan_id*.
3495  *   Otherwise, disable VLAN filtering of VLAN packets tagged with *vlan_id*.
3496  * @return
3497  *   - (0) if successful.
3498  *   - (-ENOTSUP) if hardware-assisted VLAN filtering not configured.
3499  *   - (-ENODEV) if *port_id* invalid.
3500  *   - (-EIO) if device is removed.
3501  *   - (-ENOSYS) if VLAN filtering on *port_id* disabled.
3502  *   - (-EINVAL) if *vlan_id* > 4095.
3503  */
3504 int rte_eth_dev_vlan_filter(uint16_t port_id, uint16_t vlan_id, int on);
3505 
3506 /**
3507  * Enable/Disable hardware VLAN Strip by a Rx queue of an Ethernet device.
3508  *
3509  * @param port_id
3510  *   The port identifier of the Ethernet device.
3511  * @param rx_queue_id
3512  *   The index of the receive queue for which a queue stats mapping is required.
3513  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
3514  *   to rte_eth_dev_configure().
3515  * @param on
3516  *   If 1, Enable VLAN Stripping of the receive queue of the Ethernet port.
3517  *   If 0, Disable VLAN Stripping of the receive queue of the Ethernet port.
3518  * @return
3519  *   - (0) if successful.
3520  *   - (-ENOTSUP) if hardware-assisted VLAN stripping not configured.
3521  *   - (-ENODEV) if *port_id* invalid.
3522  *   - (-EINVAL) if *rx_queue_id* invalid.
3523  */
3524 int rte_eth_dev_set_vlan_strip_on_queue(uint16_t port_id, uint16_t rx_queue_id,
3525 		int on);
3526 
3527 /**
3528  * Set the Outer VLAN Ether Type by an Ethernet device, it can be inserted to
3529  * the VLAN header.
3530  *
3531  * @param port_id
3532  *   The port identifier of the Ethernet device.
3533  * @param vlan_type
3534  *   The VLAN type.
3535  * @param tag_type
3536  *   The Tag Protocol ID
3537  * @return
3538  *   - (0) if successful.
3539  *   - (-ENOTSUP) if hardware-assisted VLAN TPID setup is not supported.
3540  *   - (-ENODEV) if *port_id* invalid.
3541  *   - (-EIO) if device is removed.
3542  */
3543 int rte_eth_dev_set_vlan_ether_type(uint16_t port_id,
3544 				    enum rte_vlan_type vlan_type,
3545 				    uint16_t tag_type);
3546 
3547 /**
3548  * Set VLAN offload configuration on an Ethernet device.
3549  *
3550  * @param port_id
3551  *   The port identifier of the Ethernet device.
3552  * @param offload_mask
3553  *   The VLAN Offload bit mask can be mixed use with "OR"
3554  *       RTE_ETH_VLAN_STRIP_OFFLOAD
3555  *       RTE_ETH_VLAN_FILTER_OFFLOAD
3556  *       RTE_ETH_VLAN_EXTEND_OFFLOAD
3557  *       RTE_ETH_QINQ_STRIP_OFFLOAD
3558  * @return
3559  *   - (0) if successful.
3560  *   - (-ENOTSUP) if hardware-assisted VLAN filtering not configured.
3561  *   - (-ENODEV) if *port_id* invalid.
3562  *   - (-EIO) if device is removed.
3563  */
3564 int rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask);
3565 
3566 /**
3567  * Read VLAN Offload configuration from an Ethernet device
3568  *
3569  * @param port_id
3570  *   The port identifier of the Ethernet device.
3571  * @return
3572  *   - (>0) if successful. Bit mask to indicate
3573  *       RTE_ETH_VLAN_STRIP_OFFLOAD
3574  *       RTE_ETH_VLAN_FILTER_OFFLOAD
3575  *       RTE_ETH_VLAN_EXTEND_OFFLOAD
3576  *       RTE_ETH_QINQ_STRIP_OFFLOAD
3577  *   - (-ENODEV) if *port_id* invalid.
3578  */
3579 int rte_eth_dev_get_vlan_offload(uint16_t port_id);
3580 
3581 /**
3582  * Set port based Tx VLAN insertion on or off.
3583  *
3584  * @param port_id
3585  *  The port identifier of the Ethernet device.
3586  * @param pvid
3587  *  Port based Tx VLAN identifier together with user priority.
3588  * @param on
3589  *  Turn on or off the port based Tx VLAN insertion.
3590  *
3591  * @return
3592  *   - (0) if successful.
3593  *   - negative if failed.
3594  */
3595 int rte_eth_dev_set_vlan_pvid(uint16_t port_id, uint16_t pvid, int on);
3596 
3597 /**
3598  * @warning
3599  * @b EXPERIMENTAL: this API may change without prior notice.
3600  *
3601  * Set Rx queue available descriptors threshold.
3602  *
3603  * @param port_id
3604  *  The port identifier of the Ethernet device.
3605  * @param queue_id
3606  *  The index of the receive queue.
3607  * @param avail_thresh
3608  *  The available descriptors threshold is percentage of Rx queue size
3609  *  which describes the availability of Rx queue for hardware.
3610  *  If the Rx queue availability is below it,
3611  *  the event RTE_ETH_EVENT_RX_AVAIL_THRESH is triggered.
3612  *  [1-99] to set a new available descriptors threshold.
3613  *  0 to disable threshold monitoring.
3614  *
3615  * @return
3616  *   - 0 if successful.
3617  *   - (-ENODEV) if @p port_id is invalid.
3618  *   - (-EINVAL) if bad parameter.
3619  *   - (-ENOTSUP) if available Rx descriptors threshold is not supported.
3620  *   - (-EIO) if device is removed.
3621  */
3622 __rte_experimental
3623 int rte_eth_rx_avail_thresh_set(uint16_t port_id, uint16_t queue_id,
3624 			       uint8_t avail_thresh);
3625 
3626 /**
3627  * @warning
3628  * @b EXPERIMENTAL: this API may change without prior notice.
3629  *
3630  * Find Rx queue with RTE_ETH_EVENT_RX_AVAIL_THRESH event pending.
3631  *
3632  * @param port_id
3633  *  The port identifier of the Ethernet device.
3634  * @param[inout] queue_id
3635  *  On input starting Rx queue index to search from.
3636  *  If the queue_id is bigger than maximum queue ID of the port,
3637  *  search is started from 0. So that application can keep calling
3638  *  this function to handle all pending events with a simple increment
3639  *  of queue_id on the next call.
3640  *  On output if return value is 1, Rx queue index with the event pending.
3641  * @param[out] avail_thresh
3642  *  Location for available descriptors threshold of the found Rx queue.
3643  *
3644  * @return
3645  *   - 1 if an Rx queue with pending event is found.
3646  *   - 0 if no Rx queue with pending event is found.
3647  *   - (-ENODEV) if @p port_id is invalid.
3648  *   - (-EINVAL) if bad parameter (e.g. @p queue_id is NULL).
3649  *   - (-ENOTSUP) if operation is not supported.
3650  *   - (-EIO) if device is removed.
3651  */
3652 __rte_experimental
3653 int rte_eth_rx_avail_thresh_query(uint16_t port_id, uint16_t *queue_id,
3654 				 uint8_t *avail_thresh);
3655 
3656 typedef void (*buffer_tx_error_fn)(struct rte_mbuf **unsent, uint16_t count,
3657 		void *userdata);
3658 
3659 /**
3660  * Structure used to buffer packets for future Tx
3661  * Used by APIs rte_eth_tx_buffer and rte_eth_tx_buffer_flush
3662  */
3663 struct rte_eth_dev_tx_buffer {
3664 	buffer_tx_error_fn error_callback;
3665 	void *error_userdata;
3666 	uint16_t size;           /**< Size of buffer for buffered Tx */
3667 	uint16_t length;         /**< Number of packets in the array */
3668 	/** Pending packets to be sent on explicit flush or when full */
3669 	struct rte_mbuf *pkts[];
3670 };
3671 
3672 /**
3673  * Calculate the size of the Tx buffer.
3674  *
3675  * @param sz
3676  *   Number of stored packets.
3677  */
3678 #define RTE_ETH_TX_BUFFER_SIZE(sz) \
3679 	(sizeof(struct rte_eth_dev_tx_buffer) + (sz) * sizeof(struct rte_mbuf *))
3680 
3681 /**
3682  * Initialize default values for buffered transmitting
3683  *
3684  * @param buffer
3685  *   Tx buffer to be initialized.
3686  * @param size
3687  *   Buffer size
3688  * @return
3689  *   0 if no error
3690  */
3691 int
3692 rte_eth_tx_buffer_init(struct rte_eth_dev_tx_buffer *buffer, uint16_t size);
3693 
3694 /**
3695  * Configure a callback for buffered packets which cannot be sent
3696  *
3697  * Register a specific callback to be called when an attempt is made to send
3698  * all packets buffered on an Ethernet port, but not all packets can
3699  * successfully be sent. The callback registered here will be called only
3700  * from calls to rte_eth_tx_buffer() and rte_eth_tx_buffer_flush() APIs.
3701  * The default callback configured for each queue by default just frees the
3702  * packets back to the calling mempool. If additional behaviour is required,
3703  * for example, to count dropped packets, or to retry transmission of packets
3704  * which cannot be sent, this function should be used to register a suitable
3705  * callback function to implement the desired behaviour.
3706  * The example callback "rte_eth_count_unsent_packet_callback()" is also
3707  * provided as reference.
3708  *
3709  * @param buffer
3710  *   The port identifier of the Ethernet device.
3711  * @param callback
3712  *   The function to be used as the callback.
3713  * @param userdata
3714  *   Arbitrary parameter to be passed to the callback function
3715  * @return
3716  *   0 on success, or -EINVAL if bad parameter
3717  */
3718 int
3719 rte_eth_tx_buffer_set_err_callback(struct rte_eth_dev_tx_buffer *buffer,
3720 		buffer_tx_error_fn callback, void *userdata);
3721 
3722 /**
3723  * Callback function for silently dropping unsent buffered packets.
3724  *
3725  * This function can be passed to rte_eth_tx_buffer_set_err_callback() to
3726  * adjust the default behavior when buffered packets cannot be sent. This
3727  * function drops any unsent packets silently and is used by Tx buffered
3728  * operations as default behavior.
3729  *
3730  * NOTE: this function should not be called directly, instead it should be used
3731  *       as a callback for packet buffering.
3732  *
3733  * NOTE: when configuring this function as a callback with
3734  *       rte_eth_tx_buffer_set_err_callback(), the final, userdata parameter
3735  *       should point to an uint64_t value.
3736  *
3737  * @param pkts
3738  *   The previously buffered packets which could not be sent
3739  * @param unsent
3740  *   The number of unsent packets in the pkts array
3741  * @param userdata
3742  *   Not used
3743  */
3744 void
3745 rte_eth_tx_buffer_drop_callback(struct rte_mbuf **pkts, uint16_t unsent,
3746 		void *userdata);
3747 
3748 /**
3749  * Callback function for tracking unsent buffered packets.
3750  *
3751  * This function can be passed to rte_eth_tx_buffer_set_err_callback() to
3752  * adjust the default behavior when buffered packets cannot be sent. This
3753  * function drops any unsent packets, but also updates a user-supplied counter
3754  * to track the overall number of packets dropped. The counter should be an
3755  * uint64_t variable.
3756  *
3757  * NOTE: this function should not be called directly, instead it should be used
3758  *       as a callback for packet buffering.
3759  *
3760  * NOTE: when configuring this function as a callback with
3761  *       rte_eth_tx_buffer_set_err_callback(), the final, userdata parameter
3762  *       should point to an uint64_t value.
3763  *
3764  * @param pkts
3765  *   The previously buffered packets which could not be sent
3766  * @param unsent
3767  *   The number of unsent packets in the pkts array
3768  * @param userdata
3769  *   Pointer to an uint64_t value, which will be incremented by unsent
3770  */
3771 void
3772 rte_eth_tx_buffer_count_callback(struct rte_mbuf **pkts, uint16_t unsent,
3773 		void *userdata);
3774 
3775 /**
3776  * Request the driver to free mbufs currently cached by the driver. The
3777  * driver will only free the mbuf if it is no longer in use. It is the
3778  * application's responsibility to ensure rte_eth_tx_buffer_flush(..) is
3779  * called if needed.
3780  *
3781  * @param port_id
3782  *   The port identifier of the Ethernet device.
3783  * @param queue_id
3784  *   The index of the transmit queue through which output packets must be
3785  *   sent.
3786  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
3787  *   to rte_eth_dev_configure().
3788  * @param free_cnt
3789  *   Maximum number of packets to free. Use 0 to indicate all possible packets
3790  *   should be freed. Note that a packet may be using multiple mbufs.
3791  * @return
3792  *   Failure: < 0
3793  *     -ENODEV: Invalid interface
3794  *     -EIO: device is removed
3795  *     -ENOTSUP: Driver does not support function
3796  *   Success: >= 0
3797  *     0-n: Number of packets freed. More packets may still remain in ring that
3798  *     are in use.
3799  */
3800 int
3801 rte_eth_tx_done_cleanup(uint16_t port_id, uint16_t queue_id, uint32_t free_cnt);
3802 
3803 /**
3804  * Subtypes for MACsec offload event (@ref RTE_ETH_EVENT_MACSEC)
3805  * raised by Ethernet device.
3806  */
3807 enum rte_eth_event_macsec_subtype {
3808 	/** Notifies unknown MACsec subevent. */
3809 	RTE_ETH_SUBEVENT_MACSEC_UNKNOWN,
3810 	/**
3811 	 * Subevent of RTE_ETH_EVENT_MACSEC_SECTAG_VAL_ERR sectag validation events
3812 	 *	Validation check: SecTag.TCI.V = 1
3813 	 */
3814 	RTE_ETH_SUBEVENT_MACSEC_RX_SECTAG_V_EQ1,
3815 	/**
3816 	 * Subevent of RTE_ETH_EVENT_MACSEC_SECTAG_VAL_ERR sectag validation events
3817 	 *	Validation check: SecTag.TCI.E = 0 && SecTag.TCI.C = 1
3818 	 */
3819 	RTE_ETH_SUBEVENT_MACSEC_RX_SECTAG_E_EQ0_C_EQ1,
3820 	/**
3821 	 * Subevent of RTE_ETH_EVENT_MACSEC_SECTAG_VAL_ERR sectag validation events
3822 	 *	Validation check: SecTag.SL >= 'd48
3823 	 */
3824 	RTE_ETH_SUBEVENT_MACSEC_RX_SECTAG_SL_GTE48,
3825 	/**
3826 	 * Subevent of RTE_ETH_EVENT_MACSEC_SECTAG_VAL_ERR sectag validation events
3827 	 *	Validation check: SecTag.TCI.ES = 1 && SecTag.TCI.SC = 1
3828 	 */
3829 	RTE_ETH_SUBEVENT_MACSEC_RX_SECTAG_ES_EQ1_SC_EQ1,
3830 	/**
3831 	 * Subevent of RTE_ETH_EVENT_MACSEC_SECTAG_VAL_ERR sectag validation events
3832 	 *	Validation check: SecTag.TCI.SC = 1 && SecTag.TCI.SCB = 1
3833 	 */
3834 	RTE_ETH_SUBEVENT_MACSEC_RX_SECTAG_SC_EQ1_SCB_EQ1,
3835 };
3836 
3837 /**
3838  * Event types for MACsec offload event (@ref RTE_ETH_EVENT_MACSEC)
3839  * raised by eth device.
3840  */
3841 enum rte_eth_event_macsec_type {
3842 	/** Notifies unknown MACsec event. */
3843 	RTE_ETH_EVENT_MACSEC_UNKNOWN,
3844 	/** Notifies Sectag validation failure events. */
3845 	RTE_ETH_EVENT_MACSEC_SECTAG_VAL_ERR,
3846 	/** Notifies Rx SA hard expiry events. */
3847 	RTE_ETH_EVENT_MACSEC_RX_SA_PN_HARD_EXP,
3848 	/** Notifies Rx SA soft expiry events. */
3849 	RTE_ETH_EVENT_MACSEC_RX_SA_PN_SOFT_EXP,
3850 	/** Notifies Tx SA hard expiry events. */
3851 	RTE_ETH_EVENT_MACSEC_TX_SA_PN_HARD_EXP,
3852 	/** Notifies Tx SA soft events. */
3853 	RTE_ETH_EVENT_MACSEC_TX_SA_PN_SOFT_EXP,
3854 	/** Notifies Invalid SA event. */
3855 	RTE_ETH_EVENT_MACSEC_SA_NOT_VALID,
3856 };
3857 
3858 /**
3859  * Descriptor for @ref RTE_ETH_EVENT_MACSEC event.
3860  * Used by ethdev to send extra information of the MACsec offload event.
3861  */
3862 struct rte_eth_event_macsec_desc {
3863 	/** Type of RTE_ETH_EVENT_MACSEC_* event. */
3864 	enum rte_eth_event_macsec_type type;
3865 	/** Type of RTE_ETH_SUBEVENT_MACSEC_* subevent. */
3866 	enum rte_eth_event_macsec_subtype subtype;
3867 	/**
3868 	 * Event specific metadata.
3869 	 *
3870 	 * For the following events, *userdata* registered
3871 	 * with the *rte_security_session* would be returned
3872 	 * as metadata.
3873 	 *
3874 	 * @see struct rte_security_session_conf
3875 	 */
3876 	uint64_t metadata;
3877 };
3878 
3879 /**
3880  * Subtypes for IPsec offload event(@ref RTE_ETH_EVENT_IPSEC) raised by
3881  * eth device.
3882  */
3883 enum rte_eth_event_ipsec_subtype {
3884 	/** Unknown event type */
3885 	RTE_ETH_EVENT_IPSEC_UNKNOWN = 0,
3886 	/** Sequence number overflow */
3887 	RTE_ETH_EVENT_IPSEC_ESN_OVERFLOW,
3888 	/** Soft time expiry of SA */
3889 	RTE_ETH_EVENT_IPSEC_SA_TIME_EXPIRY,
3890 	/**
3891 	 * Soft byte expiry of SA determined by
3892 	 * @ref rte_security_ipsec_lifetime::bytes_soft_limit
3893 	 */
3894 	RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY,
3895 	/**
3896 	 * Soft packet expiry of SA determined by
3897 	 * @ref rte_security_ipsec_lifetime::packets_soft_limit
3898 	 */
3899 	RTE_ETH_EVENT_IPSEC_SA_PKT_EXPIRY,
3900 	/**
3901 	 * Hard byte expiry of SA determined by
3902 	 * @ref rte_security_ipsec_lifetime::bytes_hard_limit
3903 	 */
3904 	RTE_ETH_EVENT_IPSEC_SA_BYTE_HARD_EXPIRY,
3905 	/**
3906 	 * Hard packet expiry of SA determined by
3907 	 * @ref rte_security_ipsec_lifetime::packets_hard_limit
3908 	 */
3909 	RTE_ETH_EVENT_IPSEC_SA_PKT_HARD_EXPIRY,
3910 	/** Max value of this enum */
3911 	RTE_ETH_EVENT_IPSEC_MAX
3912 };
3913 
3914 /**
3915  * Descriptor for @ref RTE_ETH_EVENT_IPSEC event. Used by eth dev to send extra
3916  * information of the IPsec offload event.
3917  */
3918 struct rte_eth_event_ipsec_desc {
3919 	/** Type of RTE_ETH_EVENT_IPSEC_* event */
3920 	enum rte_eth_event_ipsec_subtype subtype;
3921 	/**
3922 	 * Event specific metadata.
3923 	 *
3924 	 * For the following events, *userdata* registered
3925 	 * with the *rte_security_session* would be returned
3926 	 * as metadata,
3927 	 *
3928 	 * - @ref RTE_ETH_EVENT_IPSEC_ESN_OVERFLOW
3929 	 * - @ref RTE_ETH_EVENT_IPSEC_SA_TIME_EXPIRY
3930 	 * - @ref RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY
3931 	 * - @ref RTE_ETH_EVENT_IPSEC_SA_PKT_EXPIRY
3932 	 * - @ref RTE_ETH_EVENT_IPSEC_SA_BYTE_HARD_EXPIRY
3933 	 * - @ref RTE_ETH_EVENT_IPSEC_SA_PKT_HARD_EXPIRY
3934 	 *
3935 	 * @see struct rte_security_session_conf
3936 	 *
3937 	 */
3938 	uint64_t metadata;
3939 };
3940 
3941 /**
3942  * The eth device event type for interrupt, and maybe others in the future.
3943  */
3944 enum rte_eth_event_type {
3945 	RTE_ETH_EVENT_UNKNOWN,  /**< unknown event type */
3946 	RTE_ETH_EVENT_INTR_LSC, /**< lsc interrupt event */
3947 	/** queue state event (enabled/disabled) */
3948 	RTE_ETH_EVENT_QUEUE_STATE,
3949 	/** reset interrupt event, sent to VF on PF reset */
3950 	RTE_ETH_EVENT_INTR_RESET,
3951 	RTE_ETH_EVENT_VF_MBOX,  /**< message from the VF received by PF */
3952 	RTE_ETH_EVENT_MACSEC,   /**< MACsec offload related event */
3953 	RTE_ETH_EVENT_INTR_RMV, /**< device removal event */
3954 	RTE_ETH_EVENT_NEW,      /**< port is probed */
3955 	RTE_ETH_EVENT_DESTROY,  /**< port is released */
3956 	RTE_ETH_EVENT_IPSEC,    /**< IPsec offload related event */
3957 	RTE_ETH_EVENT_FLOW_AGED,/**< New aged-out flows is detected */
3958 	/**
3959 	 * Number of available Rx descriptors is smaller than the threshold.
3960 	 * @see rte_eth_rx_avail_thresh_set()
3961 	 */
3962 	RTE_ETH_EVENT_RX_AVAIL_THRESH,
3963 	/** Port recovering from a hardware or firmware error.
3964 	 * If PMD supports proactive error recovery,
3965 	 * it should trigger this event to notify application
3966 	 * that it detected an error and the recovery is being started.
3967 	 * Upon receiving the event, the application should not invoke any control path API
3968 	 * (such as rte_eth_dev_configure/rte_eth_dev_stop...) until receiving
3969 	 * RTE_ETH_EVENT_RECOVERY_SUCCESS or RTE_ETH_EVENT_RECOVERY_FAILED event.
3970 	 * The PMD will set the data path pointers to dummy functions,
3971 	 * and re-set the data path pointers to non-dummy functions
3972 	 * before reporting RTE_ETH_EVENT_RECOVERY_SUCCESS event.
3973 	 * It means that the application cannot send or receive any packets
3974 	 * during this period.
3975 	 * @note Before the PMD reports the recovery result,
3976 	 * the PMD may report the RTE_ETH_EVENT_ERR_RECOVERING event again,
3977 	 * because a larger error may occur during the recovery.
3978 	 */
3979 	RTE_ETH_EVENT_ERR_RECOVERING,
3980 	/** Port recovers successfully from the error.
3981 	 * The PMD already re-configured the port,
3982 	 * and the effect is the same as a restart operation.
3983 	 * a) The following operation will be retained: (alphabetically)
3984 	 *    - DCB configuration
3985 	 *    - FEC configuration
3986 	 *    - Flow control configuration
3987 	 *    - LRO configuration
3988 	 *    - LSC configuration
3989 	 *    - MTU
3990 	 *    - MAC address (default and those supplied by MAC address array)
3991 	 *    - Promiscuous and allmulticast mode
3992 	 *    - PTP configuration
3993 	 *    - Queue (Rx/Tx) settings
3994 	 *    - Queue statistics mappings
3995 	 *    - RSS configuration by rte_eth_dev_rss_xxx() family
3996 	 *    - Rx checksum configuration
3997 	 *    - Rx interrupt settings
3998 	 *    - Traffic management configuration
3999 	 *    - VLAN configuration (including filtering, tpid, strip, pvid)
4000 	 *    - VMDq configuration
4001 	 * b) The following configuration maybe retained
4002 	 *    or not depending on the device capabilities:
4003 	 *    - flow rules
4004 	 *      (@see RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP)
4005 	 *    - shared flow objects
4006 	 *      (@see RTE_ETH_DEV_CAPA_FLOW_SHARED_OBJECT_KEEP)
4007 	 * c) Any other configuration will not be stored
4008 	 *    and will need to be re-configured.
4009 	 */
4010 	RTE_ETH_EVENT_RECOVERY_SUCCESS,
4011 	/** Port recovery failed.
4012 	 * It means that the port should not be usable anymore.
4013 	 * The application should close the port.
4014 	 */
4015 	RTE_ETH_EVENT_RECOVERY_FAILED,
4016 	RTE_ETH_EVENT_MAX       /**< max value of this enum */
4017 };
4018 
4019 /** User application callback to be registered for interrupts. */
4020 typedef int (*rte_eth_dev_cb_fn)(uint16_t port_id,
4021 		enum rte_eth_event_type event, void *cb_arg, void *ret_param);
4022 
4023 /**
4024  * Register a callback function for port event.
4025  *
4026  * @param port_id
4027  *  Port ID.
4028  *  RTE_ETH_ALL means register the event for all port ids.
4029  * @param event
4030  *  Event interested.
4031  * @param cb_fn
4032  *  User supplied callback function to be called.
4033  * @param cb_arg
4034  *  Pointer to the parameters for the registered callback.
4035  *
4036  * @return
4037  *  - On success, zero.
4038  *  - On failure, a negative value.
4039  */
4040 int rte_eth_dev_callback_register(uint16_t port_id,
4041 			enum rte_eth_event_type event,
4042 		rte_eth_dev_cb_fn cb_fn, void *cb_arg);
4043 
4044 /**
4045  * Unregister a callback function for port event.
4046  *
4047  * @param port_id
4048  *  Port ID.
4049  *  RTE_ETH_ALL means unregister the event for all port ids.
4050  * @param event
4051  *  Event interested.
4052  * @param cb_fn
4053  *  User supplied callback function to be called.
4054  * @param cb_arg
4055  *  Pointer to the parameters for the registered callback. -1 means to
4056  *  remove all for the same callback address and same event.
4057  *
4058  * @return
4059  *  - On success, zero.
4060  *  - On failure, a negative value.
4061  */
4062 int rte_eth_dev_callback_unregister(uint16_t port_id,
4063 			enum rte_eth_event_type event,
4064 		rte_eth_dev_cb_fn cb_fn, void *cb_arg);
4065 
4066 /**
4067  * When there is no Rx packet coming in Rx Queue for a long time, we can
4068  * sleep lcore related to Rx Queue for power saving, and enable Rx interrupt
4069  * to be triggered when Rx packet arrives.
4070  *
4071  * The rte_eth_dev_rx_intr_enable() function enables Rx queue
4072  * interrupt on specific Rx queue of a port.
4073  *
4074  * @param port_id
4075  *   The port identifier of the Ethernet device.
4076  * @param queue_id
4077  *   The index of the receive queue from which to retrieve input packets.
4078  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
4079  *   to rte_eth_dev_configure().
4080  * @return
4081  *   - (0) if successful.
4082  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
4083  *     that operation.
4084  *   - (-ENODEV) if *port_id* invalid.
4085  *   - (-EIO) if device is removed.
4086  */
4087 int rte_eth_dev_rx_intr_enable(uint16_t port_id, uint16_t queue_id);
4088 
4089 /**
4090  * When lcore wakes up from Rx interrupt indicating packet coming, disable Rx
4091  * interrupt and returns to polling mode.
4092  *
4093  * The rte_eth_dev_rx_intr_disable() function disables Rx queue
4094  * interrupt on specific Rx queue of a port.
4095  *
4096  * @param port_id
4097  *   The port identifier of the Ethernet device.
4098  * @param queue_id
4099  *   The index of the receive queue from which to retrieve input packets.
4100  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
4101  *   to rte_eth_dev_configure().
4102  * @return
4103  *   - (0) if successful.
4104  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
4105  *     that operation.
4106  *   - (-ENODEV) if *port_id* invalid.
4107  *   - (-EIO) if device is removed.
4108  */
4109 int rte_eth_dev_rx_intr_disable(uint16_t port_id, uint16_t queue_id);
4110 
4111 /**
4112  * Rx Interrupt control per port.
4113  *
4114  * @param port_id
4115  *   The port identifier of the Ethernet device.
4116  * @param epfd
4117  *   Epoll instance fd which the intr vector associated to.
4118  *   Using RTE_EPOLL_PER_THREAD allows to use per thread epoll instance.
4119  * @param op
4120  *   The operation be performed for the vector.
4121  *   Operation type of {RTE_INTR_EVENT_ADD, RTE_INTR_EVENT_DEL}.
4122  * @param data
4123  *   User raw data.
4124  * @return
4125  *   - On success, zero.
4126  *   - On failure, a negative value.
4127  */
4128 int rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data);
4129 
4130 /**
4131  * Rx Interrupt control per queue.
4132  *
4133  * @param port_id
4134  *   The port identifier of the Ethernet device.
4135  * @param queue_id
4136  *   The index of the receive queue from which to retrieve input packets.
4137  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
4138  *   to rte_eth_dev_configure().
4139  * @param epfd
4140  *   Epoll instance fd which the intr vector associated to.
4141  *   Using RTE_EPOLL_PER_THREAD allows to use per thread epoll instance.
4142  * @param op
4143  *   The operation be performed for the vector.
4144  *   Operation type of {RTE_INTR_EVENT_ADD, RTE_INTR_EVENT_DEL}.
4145  * @param data
4146  *   User raw data.
4147  * @return
4148  *   - On success, zero.
4149  *   - On failure, a negative value.
4150  */
4151 int rte_eth_dev_rx_intr_ctl_q(uint16_t port_id, uint16_t queue_id,
4152 			      int epfd, int op, void *data);
4153 
4154 /**
4155  * Get interrupt fd per Rx queue.
4156  *
4157  * @param port_id
4158  *   The port identifier of the Ethernet device.
4159  * @param queue_id
4160  *   The index of the receive queue from which to retrieve input packets.
4161  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
4162  *   to rte_eth_dev_configure().
4163  * @return
4164  *   - (>=0) the interrupt fd associated to the requested Rx queue if
4165  *           successful.
4166  *   - (-1) on error.
4167  */
4168 int
4169 rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t queue_id);
4170 
4171 /**
4172  * Turn on the LED on the Ethernet device.
4173  * This function turns on the LED on the Ethernet device.
4174  *
4175  * @param port_id
4176  *   The port identifier of the Ethernet device.
4177  * @return
4178  *   - (0) if successful.
4179  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
4180  *     that operation.
4181  *   - (-ENODEV) if *port_id* invalid.
4182  *   - (-EIO) if device is removed.
4183  */
4184 int  rte_eth_led_on(uint16_t port_id);
4185 
4186 /**
4187  * Turn off the LED on the Ethernet device.
4188  * This function turns off the LED on the Ethernet device.
4189  *
4190  * @param port_id
4191  *   The port identifier of the Ethernet device.
4192  * @return
4193  *   - (0) if successful.
4194  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support
4195  *     that operation.
4196  *   - (-ENODEV) if *port_id* invalid.
4197  *   - (-EIO) if device is removed.
4198  */
4199 int  rte_eth_led_off(uint16_t port_id);
4200 
4201 /**
4202  * @warning
4203  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
4204  *
4205  * Get Forward Error Correction(FEC) capability.
4206  *
4207  * @param port_id
4208  *   The port identifier of the Ethernet device.
4209  * @param speed_fec_capa
4210  *   speed_fec_capa is out only with per-speed capabilities.
4211  *   If set to NULL, the function returns the required number
4212  *   of required array entries.
4213  * @param num
4214  *   a number of elements in an speed_fec_capa array.
4215  *
4216  * @return
4217  *   - A non-negative value lower or equal to num: success. The return value
4218  *     is the number of entries filled in the fec capa array.
4219  *   - A non-negative value higher than num: error, the given fec capa array
4220  *     is too small. The return value corresponds to the num that should
4221  *     be given to succeed. The entries in fec capa array are not valid and
4222  *     shall not be used by the caller.
4223  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
4224  *     that operation.
4225  *   - (-EIO) if device is removed.
4226  *   - (-ENODEV)  if *port_id* invalid.
4227  *   - (-EINVAL)  if *num* or *speed_fec_capa* invalid
4228  */
4229 __rte_experimental
4230 int rte_eth_fec_get_capability(uint16_t port_id,
4231 			       struct rte_eth_fec_capa *speed_fec_capa,
4232 			       unsigned int num);
4233 
4234 /**
4235  * @warning
4236  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
4237  *
4238  * Get current Forward Error Correction(FEC) mode.
4239  * If link is down and AUTO is enabled, AUTO is returned, otherwise,
4240  * configured FEC mode is returned.
4241  * If link is up, current FEC mode is returned.
4242  *
4243  * @param port_id
4244  *   The port identifier of the Ethernet device.
4245  * @param fec_capa
4246  *   A bitmask of enabled FEC modes. If AUTO bit is set, other
4247  *   bits specify FEC modes which may be negotiated. If AUTO
4248  *   bit is clear, specify FEC modes to be used (only one valid
4249  *   mode per speed may be set).
4250  * @return
4251  *   - (0) if successful.
4252  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
4253  *     that operation.
4254  *   - (-EIO) if device is removed.
4255  *   - (-ENODEV)  if *port_id* invalid.
4256  */
4257 __rte_experimental
4258 int rte_eth_fec_get(uint16_t port_id, uint32_t *fec_capa);
4259 
4260 /**
4261  * @warning
4262  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
4263  *
4264  * Set Forward Error Correction(FEC) mode.
4265  *
4266  * @param port_id
4267  *   The port identifier of the Ethernet device.
4268  * @param fec_capa
4269  *   A bitmask of allowed FEC modes. If AUTO bit is set, other
4270  *   bits specify FEC modes which may be negotiated. If AUTO
4271  *   bit is clear, specify FEC modes to be used (only one valid
4272  *   mode per speed may be set).
4273  * @return
4274  *   - (0) if successful.
4275  *   - (-EINVAL) if the FEC mode is not valid.
4276  *   - (-ENOTSUP) if underlying hardware OR driver doesn't support.
4277  *   - (-EIO) if device is removed.
4278  *   - (-ENODEV)  if *port_id* invalid.
4279  */
4280 __rte_experimental
4281 int rte_eth_fec_set(uint16_t port_id, uint32_t fec_capa);
4282 
4283 /**
4284  * Get current status of the Ethernet link flow control for Ethernet device
4285  *
4286  * @param port_id
4287  *   The port identifier of the Ethernet device.
4288  * @param fc_conf
4289  *   The pointer to the structure where to store the flow control parameters.
4290  * @return
4291  *   - (0) if successful.
4292  *   - (-ENOTSUP) if hardware doesn't support flow control.
4293  *   - (-ENODEV)  if *port_id* invalid.
4294  *   - (-EIO)  if device is removed.
4295  *   - (-EINVAL) if bad parameter.
4296  */
4297 int rte_eth_dev_flow_ctrl_get(uint16_t port_id,
4298 			      struct rte_eth_fc_conf *fc_conf);
4299 
4300 /**
4301  * Configure the Ethernet link flow control for Ethernet device
4302  *
4303  * @param port_id
4304  *   The port identifier of the Ethernet device.
4305  * @param fc_conf
4306  *   The pointer to the structure of the flow control parameters.
4307  * @return
4308  *   - (0) if successful.
4309  *   - (-ENOTSUP) if hardware doesn't support flow control mode.
4310  *   - (-ENODEV)  if *port_id* invalid.
4311  *   - (-EINVAL)  if bad parameter
4312  *   - (-EIO)     if flow control setup failure or device is removed.
4313  */
4314 int rte_eth_dev_flow_ctrl_set(uint16_t port_id,
4315 			      struct rte_eth_fc_conf *fc_conf);
4316 
4317 /**
4318  * Configure the Ethernet priority flow control under DCB environment
4319  * for Ethernet device.
4320  *
4321  * @param port_id
4322  * The port identifier of the Ethernet device.
4323  * @param pfc_conf
4324  * The pointer to the structure of the priority flow control parameters.
4325  * @return
4326  *   - (0) if successful.
4327  *   - (-ENOTSUP) if hardware doesn't support priority flow control mode.
4328  *   - (-ENODEV)  if *port_id* invalid.
4329  *   - (-EINVAL)  if bad parameter
4330  *   - (-EIO)     if flow control setup failure or device is removed.
4331  */
4332 int rte_eth_dev_priority_flow_ctrl_set(uint16_t port_id,
4333 				struct rte_eth_pfc_conf *pfc_conf);
4334 
4335 /**
4336  * Add a MAC address to the set used for filtering incoming packets.
4337  *
4338  * @param port_id
4339  *   The port identifier of the Ethernet device.
4340  * @param mac_addr
4341  *   The MAC address to add.
4342  * @param pool
4343  *   VMDq pool index to associate address with (if VMDq is enabled). If VMDq is
4344  *   not enabled, this should be set to 0.
4345  * @return
4346  *   - (0) if successfully added or *mac_addr* was already added.
4347  *   - (-ENOTSUP) if hardware doesn't support this feature.
4348  *   - (-ENODEV) if *port* is invalid.
4349  *   - (-EIO) if device is removed.
4350  *   - (-ENOSPC) if no more MAC addresses can be added.
4351  *   - (-EINVAL) if MAC address is invalid.
4352  */
4353 int rte_eth_dev_mac_addr_add(uint16_t port_id, struct rte_ether_addr *mac_addr,
4354 				uint32_t pool);
4355 
4356 /**
4357  * @warning
4358  * @b EXPERIMENTAL: this API may change without prior notice.
4359  *
4360  * Retrieve the information for queue based PFC.
4361  *
4362  * @param port_id
4363  *   The port identifier of the Ethernet device.
4364  * @param pfc_queue_info
4365  *   A pointer to a structure of type *rte_eth_pfc_queue_info* to be filled with
4366  *   the information about queue based PFC.
4367  * @return
4368  *   - (0) if successful.
4369  *   - (-ENOTSUP) if support for priority_flow_ctrl_queue_info_get does not exist.
4370  *   - (-ENODEV) if *port_id* invalid.
4371  *   - (-EINVAL) if bad parameter.
4372  */
4373 __rte_experimental
4374 int rte_eth_dev_priority_flow_ctrl_queue_info_get(uint16_t port_id,
4375 		struct rte_eth_pfc_queue_info *pfc_queue_info);
4376 
4377 /**
4378  * @warning
4379  * @b EXPERIMENTAL: this API may change without prior notice.
4380  *
4381  * Configure the queue based priority flow control for a given queue
4382  * for Ethernet device.
4383  *
4384  * @note When an ethdev port switches to queue based PFC mode, the
4385  * unconfigured queues shall be configured by the driver with
4386  * default values such as lower priority value for TC etc.
4387  *
4388  * @param port_id
4389  *   The port identifier of the Ethernet device.
4390  * @param pfc_queue_conf
4391  *   The pointer to the structure of the priority flow control parameters
4392  *   for the queue.
4393  * @return
4394  *   - (0) if successful.
4395  *   - (-ENOTSUP) if hardware doesn't support queue based PFC mode.
4396  *   - (-ENODEV)  if *port_id* invalid.
4397  *   - (-EINVAL)  if bad parameter
4398  *   - (-EIO)     if flow control setup queue failure
4399  */
4400 __rte_experimental
4401 int rte_eth_dev_priority_flow_ctrl_queue_configure(uint16_t port_id,
4402 		struct rte_eth_pfc_queue_conf *pfc_queue_conf);
4403 
4404 /**
4405  * Remove a MAC address from the internal array of addresses.
4406  *
4407  * @param port_id
4408  *   The port identifier of the Ethernet device.
4409  * @param mac_addr
4410  *   MAC address to remove.
4411  * @return
4412  *   - (0) if successful, or *mac_addr* didn't exist.
4413  *   - (-ENOTSUP) if hardware doesn't support.
4414  *   - (-ENODEV) if *port* invalid.
4415  *   - (-EADDRINUSE) if attempting to remove the default MAC address.
4416  *   - (-EINVAL) if MAC address is invalid.
4417  */
4418 int rte_eth_dev_mac_addr_remove(uint16_t port_id,
4419 				struct rte_ether_addr *mac_addr);
4420 
4421 /**
4422  * Set the default MAC address.
4423  * It replaces the address at index 0 of the MAC address list.
4424  * If the address was already in the MAC address list,
4425  * please remove it first.
4426  *
4427  * @param port_id
4428  *   The port identifier of the Ethernet device.
4429  * @param mac_addr
4430  *   New default MAC address.
4431  * @return
4432  *   - (0) if successful, or *mac_addr* didn't exist.
4433  *   - (-ENOTSUP) if hardware doesn't support.
4434  *   - (-ENODEV) if *port* invalid.
4435  *   - (-EINVAL) if MAC address is invalid.
4436  *   - (-EEXIST) if MAC address was already in the address list.
4437  */
4438 int rte_eth_dev_default_mac_addr_set(uint16_t port_id,
4439 		struct rte_ether_addr *mac_addr);
4440 
4441 /**
4442  * Update Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
4443  *
4444  * @param port_id
4445  *   The port identifier of the Ethernet device.
4446  * @param reta_conf
4447  *   RETA to update.
4448  * @param reta_size
4449  *   Redirection table size. The table size can be queried by
4450  *   rte_eth_dev_info_get().
4451  * @return
4452  *   - (0) if successful.
4453  *   - (-ENODEV) if *port_id* is invalid.
4454  *   - (-ENOTSUP) if hardware doesn't support.
4455  *   - (-EINVAL) if bad parameter.
4456  *   - (-EIO) if device is removed.
4457  */
4458 int rte_eth_dev_rss_reta_update(uint16_t port_id,
4459 				struct rte_eth_rss_reta_entry64 *reta_conf,
4460 				uint16_t reta_size);
4461 
4462 /**
4463  * Query Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
4464  *
4465  * @param port_id
4466  *   The port identifier of the Ethernet device.
4467  * @param reta_conf
4468  *   RETA to query. For each requested reta entry, corresponding bit
4469  *   in mask must be set.
4470  * @param reta_size
4471  *   Redirection table size. The table size can be queried by
4472  *   rte_eth_dev_info_get().
4473  * @return
4474  *   - (0) if successful.
4475  *   - (-ENODEV) if *port_id* is invalid.
4476  *   - (-ENOTSUP) if hardware doesn't support.
4477  *   - (-EINVAL) if bad parameter.
4478  *   - (-EIO) if device is removed.
4479  */
4480 int rte_eth_dev_rss_reta_query(uint16_t port_id,
4481 			       struct rte_eth_rss_reta_entry64 *reta_conf,
4482 			       uint16_t reta_size);
4483 
4484 /**
4485  * Updates unicast hash table for receiving packet with the given destination
4486  * MAC address, and the packet is routed to all VFs for which the Rx mode is
4487  * accept packets that match the unicast hash table.
4488  *
4489  * @param port_id
4490  *   The port identifier of the Ethernet device.
4491  * @param addr
4492  *   Unicast MAC address.
4493  * @param on
4494  *    1 - Set an unicast hash bit for receiving packets with the MAC address.
4495  *    0 - Clear an unicast hash bit.
4496  * @return
4497  *   - (0) if successful.
4498  *   - (-ENOTSUP) if hardware doesn't support.
4499   *  - (-ENODEV) if *port_id* invalid.
4500  *   - (-EIO) if device is removed.
4501  *   - (-EINVAL) if bad parameter.
4502  */
4503 int rte_eth_dev_uc_hash_table_set(uint16_t port_id, struct rte_ether_addr *addr,
4504 				  uint8_t on);
4505 
4506 /**
4507  * Updates all unicast hash bitmaps for receiving packet with any Unicast
4508  * Ethernet MAC addresses,the packet is routed to all VFs for which the Rx
4509  * mode is accept packets that match the unicast hash table.
4510  *
4511  * @param port_id
4512  *   The port identifier of the Ethernet device.
4513  * @param on
4514  *    1 - Set all unicast hash bitmaps for receiving all the Ethernet
4515  *         MAC addresses
4516  *    0 - Clear all unicast hash bitmaps
4517  * @return
4518  *   - (0) if successful.
4519  *   - (-ENOTSUP) if hardware doesn't support.
4520   *  - (-ENODEV) if *port_id* invalid.
4521  *   - (-EIO) if device is removed.
4522  *   - (-EINVAL) if bad parameter.
4523  */
4524 int rte_eth_dev_uc_all_hash_table_set(uint16_t port_id, uint8_t on);
4525 
4526 /**
4527  * Set the rate limitation for a queue on an Ethernet device.
4528  *
4529  * @param port_id
4530  *   The port identifier of the Ethernet device.
4531  * @param queue_idx
4532  *   The queue ID.
4533  * @param tx_rate
4534  *   The Tx rate in Mbps. Allocated from the total port link speed.
4535  * @return
4536  *   - (0) if successful.
4537  *   - (-ENOTSUP) if hardware doesn't support this feature.
4538  *   - (-ENODEV) if *port_id* invalid.
4539  *   - (-EIO) if device is removed.
4540  *   - (-EINVAL) if bad parameter.
4541  */
4542 int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx,
4543 			uint32_t tx_rate);
4544 
4545 /**
4546  * Configuration of Receive Side Scaling hash computation of Ethernet device.
4547  *
4548  * @param port_id
4549  *   The port identifier of the Ethernet device.
4550  * @param rss_conf
4551  *   The new configuration to use for RSS hash computation on the port.
4552  * @return
4553  *   - (0) if successful.
4554  *   - (-ENODEV) if port identifier is invalid.
4555  *   - (-EIO) if device is removed.
4556  *   - (-ENOTSUP) if hardware doesn't support.
4557  *   - (-EINVAL) if bad parameter.
4558  */
4559 int rte_eth_dev_rss_hash_update(uint16_t port_id,
4560 				struct rte_eth_rss_conf *rss_conf);
4561 
4562 /**
4563  * Retrieve current configuration of Receive Side Scaling hash computation
4564  * of Ethernet device.
4565  *
4566  * @param port_id
4567  *   The port identifier of the Ethernet device.
4568  * @param rss_conf
4569  *   Where to store the current RSS hash configuration of the Ethernet device.
4570  * @return
4571  *   - (0) if successful.
4572  *   - (-ENODEV) if port identifier is invalid.
4573  *   - (-EIO) if device is removed.
4574  *   - (-ENOTSUP) if hardware doesn't support RSS.
4575  *   - (-EINVAL) if bad parameter.
4576  */
4577 int
4578 rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
4579 			      struct rte_eth_rss_conf *rss_conf);
4580 
4581 /**
4582  * Add UDP tunneling port for a type of tunnel.
4583  *
4584  * Some NICs may require such configuration to properly parse a tunnel
4585  * with any standard or custom UDP port.
4586  * The packets with this UDP port will be parsed for this type of tunnel.
4587  * The device parser will also check the rest of the tunnel headers
4588  * before classifying the packet.
4589  *
4590  * With some devices, this API will affect packet classification, i.e.:
4591  *     - mbuf.packet_type reported on Rx
4592  *     - rte_flow rules with tunnel items
4593  *
4594  * @param port_id
4595  *   The port identifier of the Ethernet device.
4596  * @param tunnel_udp
4597  *   UDP tunneling configuration.
4598  *
4599  * @return
4600  *   - (0) if successful.
4601  *   - (-ENODEV) if port identifier is invalid.
4602  *   - (-EIO) if device is removed.
4603  *   - (-ENOTSUP) if hardware doesn't support tunnel type.
4604  */
4605 int
4606 rte_eth_dev_udp_tunnel_port_add(uint16_t port_id,
4607 				struct rte_eth_udp_tunnel *tunnel_udp);
4608 
4609 /**
4610  * Delete UDP tunneling port for a type of tunnel.
4611  *
4612  * The packets with this UDP port will not be classified as this type of tunnel
4613  * anymore if the device use such mapping for tunnel packet classification.
4614  *
4615  * @see rte_eth_dev_udp_tunnel_port_add
4616  *
4617  * @param port_id
4618  *   The port identifier of the Ethernet device.
4619  * @param tunnel_udp
4620  *   UDP tunneling configuration.
4621  *
4622  * @return
4623  *   - (0) if successful.
4624  *   - (-ENODEV) if port identifier is invalid.
4625  *   - (-EIO) if device is removed.
4626  *   - (-ENOTSUP) if hardware doesn't support tunnel type.
4627  */
4628 int
4629 rte_eth_dev_udp_tunnel_port_delete(uint16_t port_id,
4630 				   struct rte_eth_udp_tunnel *tunnel_udp);
4631 
4632 /**
4633  * Get DCB information on an Ethernet device.
4634  *
4635  * @param port_id
4636  *   The port identifier of the Ethernet device.
4637  * @param dcb_info
4638  *   DCB information.
4639  * @return
4640  *   - (0) if successful.
4641  *   - (-ENODEV) if port identifier is invalid.
4642  *   - (-EIO) if device is removed.
4643  *   - (-ENOTSUP) if hardware doesn't support.
4644  *   - (-EINVAL) if bad parameter.
4645  */
4646 int rte_eth_dev_get_dcb_info(uint16_t port_id,
4647 			     struct rte_eth_dcb_info *dcb_info);
4648 
4649 struct rte_eth_rxtx_callback;
4650 
4651 /**
4652  * Add a callback to be called on packet Rx on a given port and queue.
4653  *
4654  * This API configures a function to be called for each burst of
4655  * packets received on a given NIC port queue. The return value is a pointer
4656  * that can be used to later remove the callback using
4657  * rte_eth_remove_rx_callback().
4658  *
4659  * Multiple functions are called in the order that they are added.
4660  *
4661  * @param port_id
4662  *   The port identifier of the Ethernet device.
4663  * @param queue_id
4664  *   The queue on the Ethernet device on which the callback is to be added.
4665  * @param fn
4666  *   The callback function
4667  * @param user_param
4668  *   A generic pointer parameter which will be passed to each invocation of the
4669  *   callback function on this port and queue. Inter-thread synchronization
4670  *   of any user data changes is the responsibility of the user.
4671  *
4672  * @return
4673  *   NULL on error.
4674  *   On success, a pointer value which can later be used to remove the callback.
4675  */
4676 const struct rte_eth_rxtx_callback *
4677 rte_eth_add_rx_callback(uint16_t port_id, uint16_t queue_id,
4678 		rte_rx_callback_fn fn, void *user_param);
4679 
4680 /**
4681  * Add a callback that must be called first on packet Rx on a given port
4682  * and queue.
4683  *
4684  * This API configures a first function to be called for each burst of
4685  * packets received on a given NIC port queue. The return value is a pointer
4686  * that can be used to later remove the callback using
4687  * rte_eth_remove_rx_callback().
4688  *
4689  * Multiple functions are called in the order that they are added.
4690  *
4691  * @param port_id
4692  *   The port identifier of the Ethernet device.
4693  * @param queue_id
4694  *   The queue on the Ethernet device on which the callback is to be added.
4695  * @param fn
4696  *   The callback function
4697  * @param user_param
4698  *   A generic pointer parameter which will be passed to each invocation of the
4699  *   callback function on this port and queue. Inter-thread synchronization
4700  *   of any user data changes is the responsibility of the user.
4701  *
4702  * @return
4703  *   NULL on error.
4704  *   On success, a pointer value which can later be used to remove the callback.
4705  */
4706 const struct rte_eth_rxtx_callback *
4707 rte_eth_add_first_rx_callback(uint16_t port_id, uint16_t queue_id,
4708 		rte_rx_callback_fn fn, void *user_param);
4709 
4710 /**
4711  * Add a callback to be called on packet Tx on a given port and queue.
4712  *
4713  * This API configures a function to be called for each burst of
4714  * packets sent on a given NIC port queue. The return value is a pointer
4715  * that can be used to later remove the callback using
4716  * rte_eth_remove_tx_callback().
4717  *
4718  * Multiple functions are called in the order that they are added.
4719  *
4720  * @param port_id
4721  *   The port identifier of the Ethernet device.
4722  * @param queue_id
4723  *   The queue on the Ethernet device on which the callback is to be added.
4724  * @param fn
4725  *   The callback function
4726  * @param user_param
4727  *   A generic pointer parameter which will be passed to each invocation of the
4728  *   callback function on this port and queue. Inter-thread synchronization
4729  *   of any user data changes is the responsibility of the user.
4730  *
4731  * @return
4732  *   NULL on error.
4733  *   On success, a pointer value which can later be used to remove the callback.
4734  */
4735 const struct rte_eth_rxtx_callback *
4736 rte_eth_add_tx_callback(uint16_t port_id, uint16_t queue_id,
4737 		rte_tx_callback_fn fn, void *user_param);
4738 
4739 /**
4740  * Remove an Rx packet callback from a given port and queue.
4741  *
4742  * This function is used to removed callbacks that were added to a NIC port
4743  * queue using rte_eth_add_rx_callback().
4744  *
4745  * Note: the callback is removed from the callback list but it isn't freed
4746  * since the it may still be in use. The memory for the callback can be
4747  * subsequently freed back by the application by calling rte_free():
4748  *
4749  * - Immediately - if the port is stopped, or the user knows that no
4750  *   callbacks are in flight e.g. if called from the thread doing Rx/Tx
4751  *   on that queue.
4752  *
4753  * - After a short delay - where the delay is sufficient to allow any
4754  *   in-flight callbacks to complete. Alternately, the RCU mechanism can be
4755  *   used to detect when data plane threads have ceased referencing the
4756  *   callback memory.
4757  *
4758  * @param port_id
4759  *   The port identifier of the Ethernet device.
4760  * @param queue_id
4761  *   The queue on the Ethernet device from which the callback is to be removed.
4762  * @param user_cb
4763  *   User supplied callback created via rte_eth_add_rx_callback().
4764  *
4765  * @return
4766  *   - 0: Success. Callback was removed.
4767  *   - -ENODEV:  If *port_id* is invalid.
4768  *   - -ENOTSUP: Callback support is not available.
4769  *   - -EINVAL:  The queue_id is out of range, or the callback
4770  *               is NULL or not found for the port/queue.
4771  */
4772 int rte_eth_remove_rx_callback(uint16_t port_id, uint16_t queue_id,
4773 		const struct rte_eth_rxtx_callback *user_cb);
4774 
4775 /**
4776  * Remove a Tx packet callback from a given port and queue.
4777  *
4778  * This function is used to removed callbacks that were added to a NIC port
4779  * queue using rte_eth_add_tx_callback().
4780  *
4781  * Note: the callback is removed from the callback list but it isn't freed
4782  * since the it may still be in use. The memory for the callback can be
4783  * subsequently freed back by the application by calling rte_free():
4784  *
4785  * - Immediately - if the port is stopped, or the user knows that no
4786  *   callbacks are in flight e.g. if called from the thread doing Rx/Tx
4787  *   on that queue.
4788  *
4789  * - After a short delay - where the delay is sufficient to allow any
4790  *   in-flight callbacks to complete. Alternately, the RCU mechanism can be
4791  *   used to detect when data plane threads have ceased referencing the
4792  *   callback memory.
4793  *
4794  * @param port_id
4795  *   The port identifier of the Ethernet device.
4796  * @param queue_id
4797  *   The queue on the Ethernet device from which the callback is to be removed.
4798  * @param user_cb
4799  *   User supplied callback created via rte_eth_add_tx_callback().
4800  *
4801  * @return
4802  *   - 0: Success. Callback was removed.
4803  *   - -ENODEV:  If *port_id* is invalid.
4804  *   - -ENOTSUP: Callback support is not available.
4805  *   - -EINVAL:  The queue_id is out of range, or the callback
4806  *               is NULL or not found for the port/queue.
4807  */
4808 int rte_eth_remove_tx_callback(uint16_t port_id, uint16_t queue_id,
4809 		const struct rte_eth_rxtx_callback *user_cb);
4810 
4811 /**
4812  * Retrieve information about given port's Rx queue.
4813  *
4814  * @param port_id
4815  *   The port identifier of the Ethernet device.
4816  * @param queue_id
4817  *   The Rx queue on the Ethernet device for which information
4818  *   will be retrieved.
4819  * @param qinfo
4820  *   A pointer to a structure of type *rte_eth_rxq_info_info* to be filled with
4821  *   the information of the Ethernet device.
4822  *
4823  * @return
4824  *   - 0: Success
4825  *   - -ENODEV:  If *port_id* is invalid.
4826  *   - -ENOTSUP: routine is not supported by the device PMD.
4827  *   - -EINVAL:  The queue_id is out of range, or the queue
4828  *               is hairpin queue.
4829  */
4830 int rte_eth_rx_queue_info_get(uint16_t port_id, uint16_t queue_id,
4831 	struct rte_eth_rxq_info *qinfo);
4832 
4833 /**
4834  * Retrieve information about given port's Tx queue.
4835  *
4836  * @param port_id
4837  *   The port identifier of the Ethernet device.
4838  * @param queue_id
4839  *   The Tx queue on the Ethernet device for which information
4840  *   will be retrieved.
4841  * @param qinfo
4842  *   A pointer to a structure of type *rte_eth_txq_info_info* to be filled with
4843  *   the information of the Ethernet device.
4844  *
4845  * @return
4846  *   - 0: Success
4847  *   - -ENODEV:  If *port_id* is invalid.
4848  *   - -ENOTSUP: routine is not supported by the device PMD.
4849  *   - -EINVAL:  The queue_id is out of range, or the queue
4850  *               is hairpin queue.
4851  */
4852 int rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id,
4853 	struct rte_eth_txq_info *qinfo);
4854 
4855 /**
4856  * Retrieve information about the Rx packet burst mode.
4857  *
4858  * @param port_id
4859  *   The port identifier of the Ethernet device.
4860  * @param queue_id
4861  *   The Rx queue on the Ethernet device for which information
4862  *   will be retrieved.
4863  * @param mode
4864  *   A pointer to a structure of type *rte_eth_burst_mode* to be filled
4865  *   with the information of the packet burst mode.
4866  *
4867  * @return
4868  *   - 0: Success
4869  *   - -ENODEV:  If *port_id* is invalid.
4870  *   - -ENOTSUP: routine is not supported by the device PMD.
4871  *   - -EINVAL:  The queue_id is out of range.
4872  */
4873 int rte_eth_rx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
4874 	struct rte_eth_burst_mode *mode);
4875 
4876 /**
4877  * Retrieve information about the Tx packet burst mode.
4878  *
4879  * @param port_id
4880  *   The port identifier of the Ethernet device.
4881  * @param queue_id
4882  *   The Tx queue on the Ethernet device for which information
4883  *   will be retrieved.
4884  * @param mode
4885  *   A pointer to a structure of type *rte_eth_burst_mode* to be filled
4886  *   with the information of the packet burst mode.
4887  *
4888  * @return
4889  *   - 0: Success
4890  *   - -ENODEV:  If *port_id* is invalid.
4891  *   - -ENOTSUP: routine is not supported by the device PMD.
4892  *   - -EINVAL:  The queue_id is out of range.
4893  */
4894 int rte_eth_tx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
4895 	struct rte_eth_burst_mode *mode);
4896 
4897 /**
4898  * @warning
4899  * @b EXPERIMENTAL: this API may change without prior notice.
4900  *
4901  * Retrieve the monitor condition for a given receive queue.
4902  *
4903  * @param port_id
4904  *   The port identifier of the Ethernet device.
4905  * @param queue_id
4906  *   The Rx queue on the Ethernet device for which information
4907  *   will be retrieved.
4908  * @param pmc
4909  *   The pointer to power-optimized monitoring condition structure.
4910  *
4911  * @return
4912  *   - 0: Success.
4913  *   -ENOTSUP: Operation not supported.
4914  *   -EINVAL: Invalid parameters.
4915  *   -ENODEV: Invalid port ID.
4916  */
4917 __rte_experimental
4918 int rte_eth_get_monitor_addr(uint16_t port_id, uint16_t queue_id,
4919 		struct rte_power_monitor_cond *pmc);
4920 
4921 /**
4922  * Retrieve device registers and register attributes (number of registers and
4923  * register size)
4924  *
4925  * @param port_id
4926  *   The port identifier of the Ethernet device.
4927  * @param info
4928  *   Pointer to rte_dev_reg_info structure to fill in. If info->data is
4929  *   NULL the function fills in the width and length fields. If non-NULL
4930  *   the registers are put into the buffer pointed at by the data field.
4931  * @return
4932  *   - (0) if successful.
4933  *   - (-ENOTSUP) if hardware doesn't support.
4934  *   - (-EINVAL) if bad parameter.
4935  *   - (-ENODEV) if *port_id* invalid.
4936  *   - (-EIO) if device is removed.
4937  *   - others depends on the specific operations implementation.
4938  */
4939 int rte_eth_dev_get_reg_info(uint16_t port_id, struct rte_dev_reg_info *info);
4940 
4941 /**
4942  * Retrieve size of device EEPROM
4943  *
4944  * @param port_id
4945  *   The port identifier of the Ethernet device.
4946  * @return
4947  *   - (>=0) EEPROM size if successful.
4948  *   - (-ENOTSUP) if hardware doesn't support.
4949  *   - (-ENODEV) if *port_id* invalid.
4950  *   - (-EIO) if device is removed.
4951  *   - others depends on the specific operations implementation.
4952  */
4953 int rte_eth_dev_get_eeprom_length(uint16_t port_id);
4954 
4955 /**
4956  * Retrieve EEPROM and EEPROM attribute
4957  *
4958  * @param port_id
4959  *   The port identifier of the Ethernet device.
4960  * @param info
4961  *   The template includes buffer for return EEPROM data and
4962  *   EEPROM attributes to be filled.
4963  * @return
4964  *   - (0) if successful.
4965  *   - (-ENOTSUP) if hardware doesn't support.
4966  *   - (-EINVAL) if bad parameter.
4967  *   - (-ENODEV) if *port_id* invalid.
4968  *   - (-EIO) if device is removed.
4969  *   - others depends on the specific operations implementation.
4970  */
4971 int rte_eth_dev_get_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
4972 
4973 /**
4974  * Program EEPROM with provided data
4975  *
4976  * @param port_id
4977  *   The port identifier of the Ethernet device.
4978  * @param info
4979  *   The template includes EEPROM data for programming and
4980  *   EEPROM attributes to be filled
4981  * @return
4982  *   - (0) if successful.
4983  *   - (-ENOTSUP) if hardware doesn't support.
4984  *   - (-ENODEV) if *port_id* invalid.
4985  *   - (-EINVAL) if bad parameter.
4986  *   - (-EIO) if device is removed.
4987  *   - others depends on the specific operations implementation.
4988  */
4989 int rte_eth_dev_set_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
4990 
4991 /**
4992  * @warning
4993  * @b EXPERIMENTAL: this API may change without prior notice.
4994  *
4995  * Retrieve the type and size of plugin module EEPROM
4996  *
4997  * @param port_id
4998  *   The port identifier of the Ethernet device.
4999  * @param modinfo
5000  *   The type and size of plugin module EEPROM.
5001  * @return
5002  *   - (0) if successful.
5003  *   - (-ENOTSUP) if hardware doesn't support.
5004  *   - (-ENODEV) if *port_id* invalid.
5005  *   - (-EINVAL) if bad parameter.
5006  *   - (-EIO) if device is removed.
5007  *   - others depends on the specific operations implementation.
5008  */
5009 __rte_experimental
5010 int
5011 rte_eth_dev_get_module_info(uint16_t port_id,
5012 			    struct rte_eth_dev_module_info *modinfo);
5013 
5014 /**
5015  * @warning
5016  * @b EXPERIMENTAL: this API may change without prior notice.
5017  *
5018  * Retrieve the data of plugin module EEPROM
5019  *
5020  * @param port_id
5021  *   The port identifier of the Ethernet device.
5022  * @param info
5023  *   The template includes the plugin module EEPROM attributes, and the
5024  *   buffer for return plugin module EEPROM data.
5025  * @return
5026  *   - (0) if successful.
5027  *   - (-ENOTSUP) if hardware doesn't support.
5028  *   - (-EINVAL) if bad parameter.
5029  *   - (-ENODEV) if *port_id* invalid.
5030  *   - (-EIO) if device is removed.
5031  *   - others depends on the specific operations implementation.
5032  */
5033 __rte_experimental
5034 int
5035 rte_eth_dev_get_module_eeprom(uint16_t port_id,
5036 			      struct rte_dev_eeprom_info *info);
5037 
5038 /**
5039  * Set the list of multicast addresses to filter on an Ethernet device.
5040  *
5041  * @param port_id
5042  *   The port identifier of the Ethernet device.
5043  * @param mc_addr_set
5044  *   The array of multicast addresses to set. Equal to NULL when the function
5045  *   is invoked to flush the set of filtered addresses.
5046  * @param nb_mc_addr
5047  *   The number of multicast addresses in the *mc_addr_set* array. Equal to 0
5048  *   when the function is invoked to flush the set of filtered addresses.
5049  * @return
5050  *   - (0) if successful.
5051  *   - (-ENODEV) if *port_id* invalid.
5052  *   - (-EIO) if device is removed.
5053  *   - (-ENOTSUP) if PMD of *port_id* doesn't support multicast filtering.
5054  *   - (-ENOSPC) if *port_id* has not enough multicast filtering resources.
5055  *   - (-EINVAL) if bad parameter.
5056  */
5057 int rte_eth_dev_set_mc_addr_list(uint16_t port_id,
5058 				 struct rte_ether_addr *mc_addr_set,
5059 				 uint32_t nb_mc_addr);
5060 
5061 /**
5062  * Enable IEEE1588/802.1AS timestamping for an Ethernet device.
5063  *
5064  * @param port_id
5065  *   The port identifier of the Ethernet device.
5066  *
5067  * @return
5068  *   - 0: Success.
5069  *   - -ENODEV: The port ID is invalid.
5070  *   - -EIO: if device is removed.
5071  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
5072  */
5073 int rte_eth_timesync_enable(uint16_t port_id);
5074 
5075 /**
5076  * Disable IEEE1588/802.1AS timestamping for an Ethernet device.
5077  *
5078  * @param port_id
5079  *   The port identifier of the Ethernet device.
5080  *
5081  * @return
5082  *   - 0: Success.
5083  *   - -ENODEV: The port ID is invalid.
5084  *   - -EIO: if device is removed.
5085  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
5086  */
5087 int rte_eth_timesync_disable(uint16_t port_id);
5088 
5089 /**
5090  * Read an IEEE1588/802.1AS Rx timestamp from an Ethernet device.
5091  *
5092  * @param port_id
5093  *   The port identifier of the Ethernet device.
5094  * @param timestamp
5095  *   Pointer to the timestamp struct.
5096  * @param flags
5097  *   Device specific flags. Used to pass the Rx timesync register index to
5098  *   i40e. Unused in igb/ixgbe, pass 0 instead.
5099  *
5100  * @return
5101  *   - 0: Success.
5102  *   - -EINVAL: No timestamp is available.
5103  *   - -ENODEV: The port ID is invalid.
5104  *   - -EIO: if device is removed.
5105  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
5106  */
5107 int rte_eth_timesync_read_rx_timestamp(uint16_t port_id,
5108 		struct timespec *timestamp, uint32_t flags);
5109 
5110 /**
5111  * Read an IEEE1588/802.1AS Tx timestamp from an Ethernet device.
5112  *
5113  * @param port_id
5114  *   The port identifier of the Ethernet device.
5115  * @param timestamp
5116  *   Pointer to the timestamp struct.
5117  *
5118  * @return
5119  *   - 0: Success.
5120  *   - -EINVAL: No timestamp is available.
5121  *   - -ENODEV: The port ID is invalid.
5122  *   - -EIO: if device is removed.
5123  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
5124  */
5125 int rte_eth_timesync_read_tx_timestamp(uint16_t port_id,
5126 		struct timespec *timestamp);
5127 
5128 /**
5129  * Adjust the timesync clock on an Ethernet device.
5130  *
5131  * This is usually used in conjunction with other Ethdev timesync functions to
5132  * synchronize the device time using the IEEE1588/802.1AS protocol.
5133  *
5134  * @param port_id
5135  *   The port identifier of the Ethernet device.
5136  * @param delta
5137  *   The adjustment in nanoseconds.
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_adjust_time(uint16_t port_id, int64_t delta);
5146 
5147 /**
5148  * Read the time from the timesync clock on an Ethernet device.
5149  *
5150  * This is usually used in conjunction with other Ethdev timesync functions to
5151  * synchronize the device time using the IEEE1588/802.1AS protocol.
5152  *
5153  * @param port_id
5154  *   The port identifier of the Ethernet device.
5155  * @param time
5156  *   Pointer to the timespec struct that holds the time.
5157  *
5158  * @return
5159  *   - 0: Success.
5160  *   - -EINVAL: Bad parameter.
5161  */
5162 int rte_eth_timesync_read_time(uint16_t port_id, struct timespec *time);
5163 
5164 /**
5165  * Set the time of the timesync clock on an Ethernet device.
5166  *
5167  * This is usually used in conjunction with other Ethdev timesync functions to
5168  * synchronize the device time using the IEEE1588/802.1AS protocol.
5169  *
5170  * @param port_id
5171  *   The port identifier of the Ethernet device.
5172  * @param time
5173  *   Pointer to the timespec struct that holds the time.
5174  *
5175  * @return
5176  *   - 0: Success.
5177  *   - -EINVAL: No timestamp is available.
5178  *   - -ENODEV: The port ID is invalid.
5179  *   - -EIO: if device is removed.
5180  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
5181  */
5182 int rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *time);
5183 
5184 /**
5185  * @warning
5186  * @b EXPERIMENTAL: this API may change without prior notice.
5187  *
5188  * Read the current clock counter of an Ethernet device
5189  *
5190  * This returns the current raw clock value of an Ethernet device. It is
5191  * a raw amount of ticks, with no given time reference.
5192  * The value returned here is from the same clock than the one
5193  * filling timestamp field of Rx packets when using hardware timestamp
5194  * offload. Therefore it can be used to compute a precise conversion of
5195  * the device clock to the real time.
5196  *
5197  * E.g, a simple heuristic to derivate the frequency would be:
5198  * uint64_t start, end;
5199  * rte_eth_read_clock(port, start);
5200  * rte_delay_ms(100);
5201  * rte_eth_read_clock(port, end);
5202  * double freq = (end - start) * 10;
5203  *
5204  * Compute a common reference with:
5205  * uint64_t base_time_sec = current_time();
5206  * uint64_t base_clock;
5207  * rte_eth_read_clock(port, base_clock);
5208  *
5209  * Then, convert the raw mbuf timestamp with:
5210  * base_time_sec + (double)(*timestamp_dynfield(mbuf) - base_clock) / freq;
5211  *
5212  * This simple example will not provide a very good accuracy. One must
5213  * at least measure multiple times the frequency and do a regression.
5214  * To avoid deviation from the system time, the common reference can
5215  * be repeated from time to time. The integer division can also be
5216  * converted by a multiplication and a shift for better performance.
5217  *
5218  * @param port_id
5219  *   The port identifier of the Ethernet device.
5220  * @param clock
5221  *   Pointer to the uint64_t that holds the raw clock value.
5222  *
5223  * @return
5224  *   - 0: Success.
5225  *   - -ENODEV: The port ID is invalid.
5226  *   - -ENOTSUP: The function is not supported by the Ethernet driver.
5227  *   - -EINVAL: if bad parameter.
5228  */
5229 __rte_experimental
5230 int
5231 rte_eth_read_clock(uint16_t port_id, uint64_t *clock);
5232 
5233 /**
5234 * Get the port ID from device name. The device name should be specified
5235 * as below:
5236 * - PCIe address (Domain:Bus:Device.Function), for example- 0000:2:00.0
5237 * - SoC device name, for example- fsl-gmac0
5238 * - vdev dpdk name, for example- net_[pcap0|null0|tap0]
5239 *
5240 * @param name
5241 *  pci address or name of the device
5242 * @param port_id
5243 *   pointer to port identifier of the device
5244 * @return
5245 *   - (0) if successful and port_id is filled.
5246 *   - (-ENODEV or -EINVAL) on failure.
5247 */
5248 int
5249 rte_eth_dev_get_port_by_name(const char *name, uint16_t *port_id);
5250 
5251 /**
5252 * Get the device name from port ID. The device name is specified as below:
5253 * - PCIe address (Domain:Bus:Device.Function), for example- 0000:02:00.0
5254 * - SoC device name, for example- fsl-gmac0
5255 * - vdev dpdk name, for example- net_[pcap0|null0|tun0|tap0]
5256 *
5257 * @param port_id
5258 *   Port identifier of the device.
5259 * @param name
5260 *   Buffer of size RTE_ETH_NAME_MAX_LEN to store the name.
5261 * @return
5262 *   - (0) if successful.
5263 *   - (-ENODEV) if *port_id* is invalid.
5264 *   - (-EINVAL) on failure.
5265 */
5266 int
5267 rte_eth_dev_get_name_by_port(uint16_t port_id, char *name);
5268 
5269 /**
5270  * Check that numbers of Rx and Tx descriptors satisfy descriptors limits from
5271  * the Ethernet device information, otherwise adjust them to boundaries.
5272  *
5273  * @param port_id
5274  *   The port identifier of the Ethernet device.
5275  * @param nb_rx_desc
5276  *   A pointer to a uint16_t where the number of receive
5277  *   descriptors stored.
5278  * @param nb_tx_desc
5279  *   A pointer to a uint16_t where the number of transmit
5280  *   descriptors stored.
5281  * @return
5282  *   - (0) if successful.
5283  *   - (-ENOTSUP, -ENODEV or -EINVAL) on failure.
5284  */
5285 int rte_eth_dev_adjust_nb_rx_tx_desc(uint16_t port_id,
5286 				     uint16_t *nb_rx_desc,
5287 				     uint16_t *nb_tx_desc);
5288 
5289 /**
5290  * Test if a port supports specific mempool ops.
5291  *
5292  * @param port_id
5293  *   Port identifier of the Ethernet device.
5294  * @param [in] pool
5295  *   The name of the pool operations to test.
5296  * @return
5297  *   - 0: best mempool ops choice for this port.
5298  *   - 1: mempool ops are supported for this port.
5299  *   - -ENOTSUP: mempool ops not supported for this port.
5300  *   - -ENODEV: Invalid port Identifier.
5301  *   - -EINVAL: Pool param is null.
5302  */
5303 int
5304 rte_eth_dev_pool_ops_supported(uint16_t port_id, const char *pool);
5305 
5306 /**
5307  * Get the security context for the Ethernet device.
5308  *
5309  * @param port_id
5310  *   Port identifier of the Ethernet device
5311  * @return
5312  *   - NULL on error.
5313  *   - pointer to security context on success.
5314  */
5315 void *
5316 rte_eth_dev_get_sec_ctx(uint16_t port_id);
5317 
5318 /**
5319  * @warning
5320  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
5321  *
5322  * Query the device hairpin capabilities.
5323  *
5324  * @param port_id
5325  *   The port identifier of the Ethernet device.
5326  * @param cap
5327  *   Pointer to a structure that will hold the hairpin capabilities.
5328  * @return
5329  *   - (0) if successful.
5330  *   - (-ENOTSUP) if hardware doesn't support.
5331  *   - (-EINVAL) if bad parameter.
5332  */
5333 __rte_experimental
5334 int rte_eth_dev_hairpin_capability_get(uint16_t port_id,
5335 				       struct rte_eth_hairpin_cap *cap);
5336 
5337 /**
5338  * @warning
5339  * @b EXPERIMENTAL: this structure may change without prior notice.
5340  *
5341  * Ethernet device representor ID range entry
5342  */
5343 struct rte_eth_representor_range {
5344 	enum rte_eth_representor_type type; /**< Representor type */
5345 	int controller; /**< Controller index */
5346 	int pf; /**< Physical function index */
5347 	__extension__
5348 	union {
5349 		int vf; /**< VF start index */
5350 		int sf; /**< SF start index */
5351 	};
5352 	uint32_t id_base; /**< Representor ID start index */
5353 	uint32_t id_end;  /**< Representor ID end index */
5354 	char name[RTE_DEV_NAME_MAX_LEN]; /**< Representor name */
5355 };
5356 
5357 /**
5358  * @warning
5359  * @b EXPERIMENTAL: this structure may change without prior notice.
5360  *
5361  * Ethernet device representor information
5362  */
5363 struct rte_eth_representor_info {
5364 	uint16_t controller; /**< Controller ID of caller device. */
5365 	uint16_t pf; /**< Physical function ID of caller device. */
5366 	uint32_t nb_ranges_alloc; /**< Size of the ranges array. */
5367 	uint32_t nb_ranges; /**< Number of initialized ranges. */
5368 	struct rte_eth_representor_range ranges[];/**< Representor ID range. */
5369 };
5370 
5371 /**
5372  * Retrieve the representor info of the device.
5373  *
5374  * Get device representor info to be able to calculate a unique
5375  * representor ID. @see rte_eth_representor_id_get helper.
5376  *
5377  * @param port_id
5378  *   The port identifier of the device.
5379  * @param info
5380  *   A pointer to a representor info structure.
5381  *   NULL to return number of range entries and allocate memory
5382  *   for next call to store detail.
5383  *   The number of ranges that were written into this structure
5384  *   will be placed into its nb_ranges field. This number cannot be
5385  *   larger than the nb_ranges_alloc that by the user before calling
5386  *   this function. It can be smaller than the value returned by the
5387  *   function, however.
5388  * @return
5389  *   - (-ENOTSUP) if operation is not supported.
5390  *   - (-ENODEV) if *port_id* invalid.
5391  *   - (-EIO) if device is removed.
5392  *   - (>=0) number of available representor range entries.
5393  */
5394 __rte_experimental
5395 int rte_eth_representor_info_get(uint16_t port_id,
5396 				 struct rte_eth_representor_info *info);
5397 
5398 /** The NIC is able to deliver flag (if set) with packets to the PMD. */
5399 #define RTE_ETH_RX_METADATA_USER_FLAG RTE_BIT64(0)
5400 
5401 /** The NIC is able to deliver mark ID with packets to the PMD. */
5402 #define RTE_ETH_RX_METADATA_USER_MARK RTE_BIT64(1)
5403 
5404 /** The NIC is able to deliver tunnel ID with packets to the PMD. */
5405 #define RTE_ETH_RX_METADATA_TUNNEL_ID RTE_BIT64(2)
5406 
5407 /**
5408  * Negotiate the NIC's ability to deliver specific kinds of metadata to the PMD.
5409  *
5410  * Invoke this API before the first rte_eth_dev_configure() invocation
5411  * to let the PMD make preparations that are inconvenient to do later.
5412  *
5413  * The negotiation process is as follows:
5414  *
5415  * - the application requests features intending to use at least some of them;
5416  * - the PMD responds with the guaranteed subset of the requested feature set;
5417  * - the application can retry negotiation with another set of features;
5418  * - the application can pass zero to clear the negotiation result;
5419  * - the last negotiated result takes effect upon
5420  *   the ethdev configure and start.
5421  *
5422  * @note
5423  *   The PMD is supposed to first consider enabling the requested feature set
5424  *   in its entirety. Only if it fails to do so, does it have the right to
5425  *   respond with a smaller set of the originally requested features.
5426  *
5427  * @note
5428  *   Return code (-ENOTSUP) does not necessarily mean that the requested
5429  *   features are unsupported. In this case, the application should just
5430  *   assume that these features can be used without prior negotiations.
5431  *
5432  * @param port_id
5433  *   Port (ethdev) identifier
5434  *
5435  * @param[inout] features
5436  *   Feature selection buffer
5437  *
5438  * @return
5439  *   - (-EBUSY) if the port can't handle this in its current state;
5440  *   - (-ENOTSUP) if the method itself is not supported by the PMD;
5441  *   - (-ENODEV) if *port_id* is invalid;
5442  *   - (-EINVAL) if *features* is NULL;
5443  *   - (-EIO) if the device is removed;
5444  *   - (0) on success
5445  */
5446 int rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features);
5447 
5448 /** Flag to offload IP reassembly for IPv4 packets. */
5449 #define RTE_ETH_DEV_REASSEMBLY_F_IPV4 (RTE_BIT32(0))
5450 /** Flag to offload IP reassembly for IPv6 packets. */
5451 #define RTE_ETH_DEV_REASSEMBLY_F_IPV6 (RTE_BIT32(1))
5452 
5453 /**
5454  * A structure used to get/set IP reassembly configuration. It is also used
5455  * to get the maximum capability values that a PMD can support.
5456  *
5457  * If rte_eth_ip_reassembly_capability_get() returns 0, IP reassembly can be
5458  * enabled using rte_eth_ip_reassembly_conf_set() and params values lower than
5459  * capability params can be set in the PMD.
5460  */
5461 struct rte_eth_ip_reassembly_params {
5462 	/** Maximum time in ms which PMD can wait for other fragments. */
5463 	uint32_t timeout_ms;
5464 	/** Maximum number of fragments that can be reassembled. */
5465 	uint16_t max_frags;
5466 	/**
5467 	 * Flags to enable reassembly of packet types -
5468 	 * RTE_ETH_DEV_REASSEMBLY_F_xxx.
5469 	 */
5470 	uint16_t flags;
5471 };
5472 
5473 /**
5474  * @warning
5475  * @b EXPERIMENTAL: this API may change without prior notice
5476  *
5477  * Get IP reassembly capabilities supported by the PMD. This is the first API
5478  * to be called for enabling the IP reassembly offload feature. PMD will return
5479  * the maximum values of parameters that PMD can support and user can call
5480  * rte_eth_ip_reassembly_conf_set() with param values lower than capability.
5481  *
5482  * @param port_id
5483  *   The port identifier of the device.
5484  * @param capa
5485  *   A pointer to rte_eth_ip_reassembly_params structure.
5486  * @return
5487  *   - (-ENOTSUP) if offload configuration is not supported by device.
5488  *   - (-ENODEV) if *port_id* invalid.
5489  *   - (-EIO) if device is removed.
5490  *   - (-EINVAL) if device is not configured or *capa* passed is NULL.
5491  *   - (0) on success.
5492  */
5493 __rte_experimental
5494 int rte_eth_ip_reassembly_capability_get(uint16_t port_id,
5495 		struct rte_eth_ip_reassembly_params *capa);
5496 
5497 /**
5498  * @warning
5499  * @b EXPERIMENTAL: this API may change without prior notice
5500  *
5501  * Get IP reassembly configuration parameters currently set in PMD.
5502  * The API will return error if the configuration is not already
5503  * set using rte_eth_ip_reassembly_conf_set() before calling this API or if
5504  * the device is not configured.
5505  *
5506  * @param port_id
5507  *   The port identifier of the device.
5508  * @param conf
5509  *   A pointer to rte_eth_ip_reassembly_params structure.
5510  * @return
5511  *   - (-ENOTSUP) if offload configuration is not supported by device.
5512  *   - (-ENODEV) if *port_id* invalid.
5513  *   - (-EIO) if device is removed.
5514  *   - (-EINVAL) if device is not configured or if *conf* passed is NULL or if
5515  *              configuration is not set using rte_eth_ip_reassembly_conf_set().
5516  *   - (0) on success.
5517  */
5518 __rte_experimental
5519 int rte_eth_ip_reassembly_conf_get(uint16_t port_id,
5520 		struct rte_eth_ip_reassembly_params *conf);
5521 
5522 /**
5523  * @warning
5524  * @b EXPERIMENTAL: this API may change without prior notice
5525  *
5526  * Set IP reassembly configuration parameters if the PMD supports IP reassembly
5527  * offload. User should first call rte_eth_ip_reassembly_capability_get() to
5528  * check the maximum values supported by the PMD before setting the
5529  * configuration. The use of this API is mandatory to enable this feature and
5530  * should be called before rte_eth_dev_start().
5531  *
5532  * In datapath, PMD cannot guarantee that IP reassembly is always successful.
5533  * Hence, PMD shall register mbuf dynamic field and dynamic flag using
5534  * rte_eth_ip_reassembly_dynfield_register() to denote incomplete IP reassembly.
5535  * If dynfield is not successfully registered, error will be returned and
5536  * IP reassembly offload cannot be used.
5537  *
5538  * @param port_id
5539  *   The port identifier of the device.
5540  * @param conf
5541  *   A pointer to rte_eth_ip_reassembly_params structure.
5542  * @return
5543  *   - (-ENOTSUP) if offload configuration is not supported by device.
5544  *   - (-ENODEV) if *port_id* invalid.
5545  *   - (-EIO) if device is removed.
5546  *   - (-EINVAL) if device is not configured or if device is already started or
5547  *               if *conf* passed is NULL or if mbuf dynfield is not registered
5548  *               successfully by the PMD.
5549  *   - (0) on success.
5550  */
5551 __rte_experimental
5552 int rte_eth_ip_reassembly_conf_set(uint16_t port_id,
5553 		const struct rte_eth_ip_reassembly_params *conf);
5554 
5555 /**
5556  * In case of IP reassembly offload failure, packet will be updated with
5557  * dynamic flag - RTE_MBUF_DYNFLAG_IP_REASSEMBLY_INCOMPLETE_NAME and packets
5558  * will be returned without alteration.
5559  * The application can retrieve the attached fragments using mbuf dynamic field
5560  * RTE_MBUF_DYNFIELD_IP_REASSEMBLY_NAME.
5561  */
5562 typedef struct {
5563 	/**
5564 	 * Next fragment packet. Application should fetch dynamic field of
5565 	 * each fragment until a NULL is received and nb_frags is 0.
5566 	 */
5567 	struct rte_mbuf *next_frag;
5568 	/** Time spent(in ms) by HW in waiting for further fragments. */
5569 	uint16_t time_spent;
5570 	/** Number of more fragments attached in mbuf dynamic fields. */
5571 	uint16_t nb_frags;
5572 } rte_eth_ip_reassembly_dynfield_t;
5573 
5574 /**
5575  * @warning
5576  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
5577  *
5578  * Dump private info from device to a file. Provided data and the order depends
5579  * on the PMD.
5580  *
5581  * @param port_id
5582  *   The port identifier of the Ethernet device.
5583  * @param file
5584  *   A pointer to a file for output.
5585  * @return
5586  *   - (0) on success.
5587  *   - (-ENODEV) if *port_id* is invalid.
5588  *   - (-EINVAL) if null file.
5589  *   - (-ENOTSUP) if the device does not support this function.
5590  *   - (-EIO) if device is removed.
5591  */
5592 __rte_experimental
5593 int rte_eth_dev_priv_dump(uint16_t port_id, FILE *file);
5594 
5595 /**
5596  * @warning
5597  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
5598  *
5599  * Dump ethdev Rx descriptor info to a file.
5600  *
5601  * This API is used for debugging, not a dataplane API.
5602  *
5603  * @param port_id
5604  *   The port identifier of the Ethernet device.
5605  * @param queue_id
5606  *   A Rx queue identifier on this port.
5607  * @param offset
5608  *  The offset of the descriptor starting from tail. (0 is the next
5609  *  packet to be received by the driver).
5610  * @param num
5611  *   The number of the descriptors to dump.
5612  * @param file
5613  *   A pointer to a file for output.
5614  * @return
5615  *   - On success, zero.
5616  *   - On failure, a negative value.
5617  */
5618 __rte_experimental
5619 int rte_eth_rx_descriptor_dump(uint16_t port_id, uint16_t queue_id,
5620 			       uint16_t offset, uint16_t num, FILE *file);
5621 
5622 /**
5623  * @warning
5624  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
5625  *
5626  * Dump ethdev Tx descriptor info to a file.
5627  *
5628  * This API is used for debugging, not a dataplane API.
5629  *
5630  * @param port_id
5631  *   The port identifier of the Ethernet device.
5632  * @param queue_id
5633  *   A Tx queue identifier on this port.
5634  * @param offset
5635  *  The offset of the descriptor starting from tail. (0 is the place where
5636  *  the next packet will be send).
5637  * @param num
5638  *   The number of the descriptors to dump.
5639  * @param file
5640  *   A pointer to a file for output.
5641  * @return
5642  *   - On success, zero.
5643  *   - On failure, a negative value.
5644  */
5645 __rte_experimental
5646 int rte_eth_tx_descriptor_dump(uint16_t port_id, uint16_t queue_id,
5647 			       uint16_t offset, uint16_t num, FILE *file);
5648 
5649 
5650 /* Congestion management */
5651 
5652 /** Enumerate list of ethdev congestion management objects */
5653 enum rte_eth_cman_obj {
5654 	/** Congestion management based on Rx queue depth */
5655 	RTE_ETH_CMAN_OBJ_RX_QUEUE = RTE_BIT32(0),
5656 	/**
5657 	 * Congestion management based on mempool depth associated with Rx queue
5658 	 * @see rte_eth_rx_queue_setup()
5659 	 */
5660 	RTE_ETH_CMAN_OBJ_RX_QUEUE_MEMPOOL = RTE_BIT32(1),
5661 };
5662 
5663 /**
5664  * @warning
5665  * @b EXPERIMENTAL: this structure may change, or be removed, without prior notice
5666  *
5667  * A structure used to retrieve information of ethdev congestion management.
5668  */
5669 struct rte_eth_cman_info {
5670 	/**
5671 	 * Set of supported congestion management modes
5672 	 * @see enum rte_cman_mode
5673 	 */
5674 	uint64_t modes_supported;
5675 	/**
5676 	 * Set of supported congestion management objects
5677 	 * @see enum rte_eth_cman_obj
5678 	 */
5679 	uint64_t objs_supported;
5680 	/**
5681 	 * Reserved for future fields. Always returned as 0 when
5682 	 * rte_eth_cman_info_get() is invoked
5683 	 */
5684 	uint8_t rsvd[8];
5685 };
5686 
5687 /**
5688  * @warning
5689  * @b EXPERIMENTAL: this structure may change, or be removed, without prior notice
5690  *
5691  * A structure used to configure the ethdev congestion management.
5692  */
5693 struct rte_eth_cman_config {
5694 	/** Congestion management object */
5695 	enum rte_eth_cman_obj obj;
5696 	/** Congestion management mode */
5697 	enum rte_cman_mode mode;
5698 	union {
5699 		/**
5700 		 * Rx queue to configure congestion management.
5701 		 *
5702 		 * Valid when object is RTE_ETH_CMAN_OBJ_RX_QUEUE or
5703 		 * RTE_ETH_CMAN_OBJ_RX_QUEUE_MEMPOOL.
5704 		 */
5705 		uint16_t rx_queue;
5706 		/**
5707 		 * Reserved for future fields.
5708 		 * It must be set to 0 when rte_eth_cman_config_set() is invoked
5709 		 * and will be returned as 0 when rte_eth_cman_config_get() is
5710 		 * invoked.
5711 		 */
5712 		uint8_t rsvd_obj_params[4];
5713 	} obj_param;
5714 	union {
5715 		/**
5716 		 * RED configuration parameters.
5717 		 *
5718 		 * Valid when mode is RTE_CMAN_RED.
5719 		 */
5720 		struct rte_cman_red_params red;
5721 		/**
5722 		 * Reserved for future fields.
5723 		 * It must be set to 0 when rte_eth_cman_config_set() is invoked
5724 		 * and will be returned as 0 when rte_eth_cman_config_get() is
5725 		 * invoked.
5726 		 */
5727 		uint8_t rsvd_mode_params[4];
5728 	} mode_param;
5729 };
5730 
5731 /**
5732  * @warning
5733  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
5734  *
5735  * Retrieve the information for ethdev congestion management
5736  *
5737  * @param port_id
5738  *   The port identifier of the Ethernet device.
5739  * @param info
5740  *   A pointer to a structure of type *rte_eth_cman_info* to be filled with
5741  *   the information about congestion management.
5742  * @return
5743  *   - (0) if successful.
5744  *   - (-ENOTSUP) if support for cman_info_get does not exist.
5745  *   - (-ENODEV) if *port_id* invalid.
5746  *   - (-EINVAL) if bad parameter.
5747  */
5748 __rte_experimental
5749 int rte_eth_cman_info_get(uint16_t port_id, struct rte_eth_cman_info *info);
5750 
5751 /**
5752  * @warning
5753  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
5754  *
5755  * Initialize the ethdev congestion management configuration structure with default values.
5756  *
5757  * @param port_id
5758  *   The port identifier of the Ethernet device.
5759  * @param config
5760  *   A pointer to a structure of type *rte_eth_cman_config* to be initialized
5761  *   with default value.
5762  * @return
5763  *   - (0) if successful.
5764  *   - (-ENOTSUP) if support for cman_config_init does not exist.
5765  *   - (-ENODEV) if *port_id* invalid.
5766  *   - (-EINVAL) if bad parameter.
5767  */
5768 __rte_experimental
5769 int rte_eth_cman_config_init(uint16_t port_id, struct rte_eth_cman_config *config);
5770 
5771 /**
5772  * @warning
5773  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
5774  *
5775  * Configure ethdev congestion management
5776  *
5777  * @param port_id
5778  *   The port identifier of the Ethernet device.
5779  * @param config
5780  *   A pointer to a structure of type *rte_eth_cman_config* to be configured.
5781  * @return
5782  *   - (0) if successful.
5783  *   - (-ENOTSUP) if support for cman_config_set does not exist.
5784  *   - (-ENODEV) if *port_id* invalid.
5785  *   - (-EINVAL) if bad parameter.
5786  */
5787 __rte_experimental
5788 int rte_eth_cman_config_set(uint16_t port_id, const struct rte_eth_cman_config *config);
5789 
5790 /**
5791  * @warning
5792  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
5793  *
5794  * Retrieve the applied ethdev congestion management parameters for the given port.
5795  *
5796  * @param port_id
5797  *   The port identifier of the Ethernet device.
5798  * @param config
5799  *   A pointer to a structure of type *rte_eth_cman_config* to retrieve
5800  *   congestion management parameters for the given object.
5801  *   Application must fill all parameters except mode_param parameter in
5802  *   struct rte_eth_cman_config.
5803  *
5804  * @return
5805  *   - (0) if successful.
5806  *   - (-ENOTSUP) if support for cman_config_get does not exist.
5807  *   - (-ENODEV) if *port_id* invalid.
5808  *   - (-EINVAL) if bad parameter.
5809  */
5810 __rte_experimental
5811 int rte_eth_cman_config_get(uint16_t port_id, struct rte_eth_cman_config *config);
5812 
5813 #include <rte_ethdev_core.h>
5814 
5815 /**
5816  * @internal
5817  * Helper routine for rte_eth_rx_burst().
5818  * Should be called at exit from PMD's rte_eth_rx_bulk implementation.
5819  * Does necessary post-processing - invokes Rx callbacks if any, etc.
5820  *
5821  * @param port_id
5822  *  The port identifier of the Ethernet device.
5823  * @param queue_id
5824  *  The index of the receive queue from which to retrieve input packets.
5825  * @param rx_pkts
5826  *   The address of an array of pointers to *rte_mbuf* structures that
5827  *   have been retrieved from the device.
5828  * @param nb_rx
5829  *   The number of packets that were retrieved from the device.
5830  * @param nb_pkts
5831  *   The number of elements in @p rx_pkts array.
5832  * @param opaque
5833  *   Opaque pointer of Rx queue callback related data.
5834  *
5835  * @return
5836  *  The number of packets effectively supplied to the @p rx_pkts array.
5837  */
5838 uint16_t rte_eth_call_rx_callbacks(uint16_t port_id, uint16_t queue_id,
5839 		struct rte_mbuf **rx_pkts, uint16_t nb_rx, uint16_t nb_pkts,
5840 		void *opaque);
5841 
5842 /**
5843  *
5844  * Retrieve a burst of input packets from a receive queue of an Ethernet
5845  * device. The retrieved packets are stored in *rte_mbuf* structures whose
5846  * pointers are supplied in the *rx_pkts* array.
5847  *
5848  * The rte_eth_rx_burst() function loops, parsing the Rx ring of the
5849  * receive queue, up to *nb_pkts* packets, and for each completed Rx
5850  * descriptor in the ring, it performs the following operations:
5851  *
5852  * - Initialize the *rte_mbuf* data structure associated with the
5853  *   Rx descriptor according to the information provided by the NIC into
5854  *   that Rx descriptor.
5855  *
5856  * - Store the *rte_mbuf* data structure into the next entry of the
5857  *   *rx_pkts* array.
5858  *
5859  * - Replenish the Rx descriptor with a new *rte_mbuf* buffer
5860  *   allocated from the memory pool associated with the receive queue at
5861  *   initialization time.
5862  *
5863  * When retrieving an input packet that was scattered by the controller
5864  * into multiple receive descriptors, the rte_eth_rx_burst() function
5865  * appends the associated *rte_mbuf* buffers to the first buffer of the
5866  * packet.
5867  *
5868  * The rte_eth_rx_burst() function returns the number of packets
5869  * actually retrieved, which is the number of *rte_mbuf* data structures
5870  * effectively supplied into the *rx_pkts* array.
5871  * A return value equal to *nb_pkts* indicates that the Rx queue contained
5872  * at least *rx_pkts* packets, and this is likely to signify that other
5873  * received packets remain in the input queue. Applications implementing
5874  * a "retrieve as much received packets as possible" policy can check this
5875  * specific case and keep invoking the rte_eth_rx_burst() function until
5876  * a value less than *nb_pkts* is returned.
5877  *
5878  * This receive method has the following advantages:
5879  *
5880  * - It allows a run-to-completion network stack engine to retrieve and
5881  *   to immediately process received packets in a fast burst-oriented
5882  *   approach, avoiding the overhead of unnecessary intermediate packet
5883  *   queue/dequeue operations.
5884  *
5885  * - Conversely, it also allows an asynchronous-oriented processing
5886  *   method to retrieve bursts of received packets and to immediately
5887  *   queue them for further parallel processing by another logical core,
5888  *   for instance. However, instead of having received packets being
5889  *   individually queued by the driver, this approach allows the caller
5890  *   of the rte_eth_rx_burst() function to queue a burst of retrieved
5891  *   packets at a time and therefore dramatically reduce the cost of
5892  *   enqueue/dequeue operations per packet.
5893  *
5894  * - It allows the rte_eth_rx_burst() function of the driver to take
5895  *   advantage of burst-oriented hardware features (CPU cache,
5896  *   prefetch instructions, and so on) to minimize the number of CPU
5897  *   cycles per packet.
5898  *
5899  * To summarize, the proposed receive API enables many
5900  * burst-oriented optimizations in both synchronous and asynchronous
5901  * packet processing environments with no overhead in both cases.
5902  *
5903  * @note
5904  *   Some drivers using vector instructions require that *nb_pkts* is
5905  *   divisible by 4 or 8, depending on the driver implementation.
5906  *
5907  * The rte_eth_rx_burst() function does not provide any error
5908  * notification to avoid the corresponding overhead. As a hint, the
5909  * upper-level application might check the status of the device link once
5910  * being systematically returned a 0 value for a given number of tries.
5911  *
5912  * @param port_id
5913  *   The port identifier of the Ethernet device.
5914  * @param queue_id
5915  *   The index of the receive queue from which to retrieve input packets.
5916  *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
5917  *   to rte_eth_dev_configure().
5918  * @param rx_pkts
5919  *   The address of an array of pointers to *rte_mbuf* structures that
5920  *   must be large enough to store *nb_pkts* pointers in it.
5921  * @param nb_pkts
5922  *   The maximum number of packets to retrieve.
5923  *   The value must be divisible by 8 in order to work with any driver.
5924  * @return
5925  *   The number of packets actually retrieved, which is the number
5926  *   of pointers to *rte_mbuf* structures effectively supplied to the
5927  *   *rx_pkts* array.
5928  */
5929 static inline uint16_t
5930 rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id,
5931 		 struct rte_mbuf **rx_pkts, const uint16_t nb_pkts)
5932 {
5933 	uint16_t nb_rx;
5934 	struct rte_eth_fp_ops *p;
5935 	void *qd;
5936 
5937 #ifdef RTE_ETHDEV_DEBUG_RX
5938 	if (port_id >= RTE_MAX_ETHPORTS ||
5939 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
5940 		RTE_ETHDEV_LOG(ERR,
5941 			"Invalid port_id=%u or queue_id=%u\n",
5942 			port_id, queue_id);
5943 		return 0;
5944 	}
5945 #endif
5946 
5947 	/* fetch pointer to queue data */
5948 	p = &rte_eth_fp_ops[port_id];
5949 	qd = p->rxq.data[queue_id];
5950 
5951 #ifdef RTE_ETHDEV_DEBUG_RX
5952 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
5953 
5954 	if (qd == NULL) {
5955 		RTE_ETHDEV_LOG(ERR, "Invalid Rx queue_id=%u for port_id=%u\n",
5956 			queue_id, port_id);
5957 		return 0;
5958 	}
5959 #endif
5960 
5961 	nb_rx = p->rx_pkt_burst(qd, rx_pkts, nb_pkts);
5962 
5963 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
5964 	{
5965 		void *cb;
5966 
5967 		/* __ATOMIC_RELEASE memory order was used when the
5968 		 * call back was inserted into the list.
5969 		 * Since there is a clear dependency between loading
5970 		 * cb and cb->fn/cb->next, __ATOMIC_ACQUIRE memory order is
5971 		 * not required.
5972 		 */
5973 		cb = __atomic_load_n((void **)&p->rxq.clbk[queue_id],
5974 				__ATOMIC_RELAXED);
5975 		if (unlikely(cb != NULL))
5976 			nb_rx = rte_eth_call_rx_callbacks(port_id, queue_id,
5977 					rx_pkts, nb_rx, nb_pkts, cb);
5978 	}
5979 #endif
5980 
5981 	rte_ethdev_trace_rx_burst(port_id, queue_id, (void **)rx_pkts, nb_rx);
5982 	return nb_rx;
5983 }
5984 
5985 /**
5986  * Get the number of used descriptors of a Rx queue
5987  *
5988  * Since it's a dataplane function, no check is performed on port_id and
5989  * queue_id. The caller must therefore ensure that the port is enabled
5990  * and the queue is configured and running.
5991  *
5992  * @param port_id
5993  *  The port identifier of the Ethernet device.
5994  * @param queue_id
5995  *  The queue ID on the specific port.
5996  * @return
5997  *  The number of used descriptors in the specific queue, or:
5998  *   - (-ENODEV) if *port_id* is invalid.
5999  *   - (-EINVAL) if *queue_id* is invalid
6000  *   - (-ENOTSUP) if the device does not support this function
6001  */
6002 static inline int
6003 rte_eth_rx_queue_count(uint16_t port_id, uint16_t queue_id)
6004 {
6005 	struct rte_eth_fp_ops *p;
6006 	void *qd;
6007 
6008 #ifdef RTE_ETHDEV_DEBUG_RX
6009 	if (port_id >= RTE_MAX_ETHPORTS ||
6010 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
6011 		RTE_ETHDEV_LOG(ERR,
6012 			"Invalid port_id=%u or queue_id=%u\n",
6013 			port_id, queue_id);
6014 		return -EINVAL;
6015 	}
6016 #endif
6017 
6018 	/* fetch pointer to queue data */
6019 	p = &rte_eth_fp_ops[port_id];
6020 	qd = p->rxq.data[queue_id];
6021 
6022 #ifdef RTE_ETHDEV_DEBUG_RX
6023 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
6024 	if (qd == NULL)
6025 		return -EINVAL;
6026 #endif
6027 
6028 	if (*p->rx_queue_count == NULL)
6029 		return -ENOTSUP;
6030 	return (int)(*p->rx_queue_count)(qd);
6031 }
6032 
6033 /**@{@name Rx hardware descriptor states
6034  * @see rte_eth_rx_descriptor_status
6035  */
6036 #define RTE_ETH_RX_DESC_AVAIL    0 /**< Desc available for hw. */
6037 #define RTE_ETH_RX_DESC_DONE     1 /**< Desc done, filled by hw. */
6038 #define RTE_ETH_RX_DESC_UNAVAIL  2 /**< Desc used by driver or hw. */
6039 /**@}*/
6040 
6041 /**
6042  * Check the status of a Rx descriptor in the queue
6043  *
6044  * It should be called in a similar context than the Rx function:
6045  * - on a dataplane core
6046  * - not concurrently on the same queue
6047  *
6048  * Since it's a dataplane function, no check is performed on port_id and
6049  * queue_id. The caller must therefore ensure that the port is enabled
6050  * and the queue is configured and running.
6051  *
6052  * Note: accessing to a random descriptor in the ring may trigger cache
6053  * misses and have a performance impact.
6054  *
6055  * @param port_id
6056  *  A valid port identifier of the Ethernet device which.
6057  * @param queue_id
6058  *  A valid Rx queue identifier on this port.
6059  * @param offset
6060  *  The offset of the descriptor starting from tail (0 is the next
6061  *  packet to be received by the driver).
6062  *
6063  * @return
6064  *  - (RTE_ETH_RX_DESC_AVAIL): Descriptor is available for the hardware to
6065  *    receive a packet.
6066  *  - (RTE_ETH_RX_DESC_DONE): Descriptor is done, it is filled by hw, but
6067  *    not yet processed by the driver (i.e. in the receive queue).
6068  *  - (RTE_ETH_RX_DESC_UNAVAIL): Descriptor is unavailable, either hold by
6069  *    the driver and not yet returned to hw, or reserved by the hw.
6070  *  - (-EINVAL) bad descriptor offset.
6071  *  - (-ENOTSUP) if the device does not support this function.
6072  *  - (-ENODEV) bad port or queue (only if compiled with debug).
6073  */
6074 static inline int
6075 rte_eth_rx_descriptor_status(uint16_t port_id, uint16_t queue_id,
6076 	uint16_t offset)
6077 {
6078 	struct rte_eth_fp_ops *p;
6079 	void *qd;
6080 
6081 #ifdef RTE_ETHDEV_DEBUG_RX
6082 	if (port_id >= RTE_MAX_ETHPORTS ||
6083 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
6084 		RTE_ETHDEV_LOG(ERR,
6085 			"Invalid port_id=%u or queue_id=%u\n",
6086 			port_id, queue_id);
6087 		return -EINVAL;
6088 	}
6089 #endif
6090 
6091 	/* fetch pointer to queue data */
6092 	p = &rte_eth_fp_ops[port_id];
6093 	qd = p->rxq.data[queue_id];
6094 
6095 #ifdef RTE_ETHDEV_DEBUG_RX
6096 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
6097 	if (qd == NULL)
6098 		return -ENODEV;
6099 #endif
6100 	if (*p->rx_descriptor_status == NULL)
6101 		return -ENOTSUP;
6102 	return (*p->rx_descriptor_status)(qd, offset);
6103 }
6104 
6105 /**@{@name Tx hardware descriptor states
6106  * @see rte_eth_tx_descriptor_status
6107  */
6108 #define RTE_ETH_TX_DESC_FULL    0 /**< Desc filled for hw, waiting xmit. */
6109 #define RTE_ETH_TX_DESC_DONE    1 /**< Desc done, packet is transmitted. */
6110 #define RTE_ETH_TX_DESC_UNAVAIL 2 /**< Desc used by driver or hw. */
6111 /**@}*/
6112 
6113 /**
6114  * Check the status of a Tx descriptor in the queue.
6115  *
6116  * It should be called in a similar context than the Tx function:
6117  * - on a dataplane core
6118  * - not concurrently on the same queue
6119  *
6120  * Since it's a dataplane function, no check is performed on port_id and
6121  * queue_id. The caller must therefore ensure that the port is enabled
6122  * and the queue is configured and running.
6123  *
6124  * Note: accessing to a random descriptor in the ring may trigger cache
6125  * misses and have a performance impact.
6126  *
6127  * @param port_id
6128  *  A valid port identifier of the Ethernet device which.
6129  * @param queue_id
6130  *  A valid Tx queue identifier on this port.
6131  * @param offset
6132  *  The offset of the descriptor starting from tail (0 is the place where
6133  *  the next packet will be send).
6134  *
6135  * @return
6136  *  - (RTE_ETH_TX_DESC_FULL) Descriptor is being processed by the hw, i.e.
6137  *    in the transmit queue.
6138  *  - (RTE_ETH_TX_DESC_DONE) Hardware is done with this descriptor, it can
6139  *    be reused by the driver.
6140  *  - (RTE_ETH_TX_DESC_UNAVAIL): Descriptor is unavailable, reserved by the
6141  *    driver or the hardware.
6142  *  - (-EINVAL) bad descriptor offset.
6143  *  - (-ENOTSUP) if the device does not support this function.
6144  *  - (-ENODEV) bad port or queue (only if compiled with debug).
6145  */
6146 static inline int rte_eth_tx_descriptor_status(uint16_t port_id,
6147 	uint16_t queue_id, uint16_t offset)
6148 {
6149 	struct rte_eth_fp_ops *p;
6150 	void *qd;
6151 
6152 #ifdef RTE_ETHDEV_DEBUG_TX
6153 	if (port_id >= RTE_MAX_ETHPORTS ||
6154 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
6155 		RTE_ETHDEV_LOG(ERR,
6156 			"Invalid port_id=%u or queue_id=%u\n",
6157 			port_id, queue_id);
6158 		return -EINVAL;
6159 	}
6160 #endif
6161 
6162 	/* fetch pointer to queue data */
6163 	p = &rte_eth_fp_ops[port_id];
6164 	qd = p->txq.data[queue_id];
6165 
6166 #ifdef RTE_ETHDEV_DEBUG_TX
6167 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
6168 	if (qd == NULL)
6169 		return -ENODEV;
6170 #endif
6171 	if (*p->tx_descriptor_status == NULL)
6172 		return -ENOTSUP;
6173 	return (*p->tx_descriptor_status)(qd, offset);
6174 }
6175 
6176 /**
6177  * @internal
6178  * Helper routine for rte_eth_tx_burst().
6179  * Should be called before entry PMD's rte_eth_tx_bulk implementation.
6180  * Does necessary pre-processing - invokes Tx callbacks if any, etc.
6181  *
6182  * @param port_id
6183  *   The port identifier of the Ethernet device.
6184  * @param queue_id
6185  *   The index of the transmit queue through which output packets must be
6186  *   sent.
6187  * @param tx_pkts
6188  *   The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
6189  *   which contain the output packets.
6190  * @param nb_pkts
6191  *   The maximum number of packets to transmit.
6192  * @return
6193  *   The number of output packets to transmit.
6194  */
6195 uint16_t rte_eth_call_tx_callbacks(uint16_t port_id, uint16_t queue_id,
6196 	struct rte_mbuf **tx_pkts, uint16_t nb_pkts, void *opaque);
6197 
6198 /**
6199  * Send a burst of output packets on a transmit queue of an Ethernet device.
6200  *
6201  * The rte_eth_tx_burst() function is invoked to transmit output packets
6202  * on the output queue *queue_id* of the Ethernet device designated by its
6203  * *port_id*.
6204  * The *nb_pkts* parameter is the number of packets to send which are
6205  * supplied in the *tx_pkts* array of *rte_mbuf* structures, each of them
6206  * allocated from a pool created with rte_pktmbuf_pool_create().
6207  * The rte_eth_tx_burst() function loops, sending *nb_pkts* packets,
6208  * up to the number of transmit descriptors available in the Tx ring of the
6209  * transmit queue.
6210  * For each packet to send, the rte_eth_tx_burst() function performs
6211  * the following operations:
6212  *
6213  * - Pick up the next available descriptor in the transmit ring.
6214  *
6215  * - Free the network buffer previously sent with that descriptor, if any.
6216  *
6217  * - Initialize the transmit descriptor with the information provided
6218  *   in the *rte_mbuf data structure.
6219  *
6220  * In the case of a segmented packet composed of a list of *rte_mbuf* buffers,
6221  * the rte_eth_tx_burst() function uses several transmit descriptors
6222  * of the ring.
6223  *
6224  * The rte_eth_tx_burst() function returns the number of packets it
6225  * actually sent. A return value equal to *nb_pkts* means that all packets
6226  * have been sent, and this is likely to signify that other output packets
6227  * could be immediately transmitted again. Applications that implement a
6228  * "send as many packets to transmit as possible" policy can check this
6229  * specific case and keep invoking the rte_eth_tx_burst() function until
6230  * a value less than *nb_pkts* is returned.
6231  *
6232  * It is the responsibility of the rte_eth_tx_burst() function to
6233  * transparently free the memory buffers of packets previously sent.
6234  * This feature is driven by the *tx_free_thresh* value supplied to the
6235  * rte_eth_dev_configure() function at device configuration time.
6236  * When the number of free Tx descriptors drops below this threshold, the
6237  * rte_eth_tx_burst() function must [attempt to] free the *rte_mbuf*  buffers
6238  * of those packets whose transmission was effectively completed.
6239  *
6240  * If the PMD is RTE_ETH_TX_OFFLOAD_MT_LOCKFREE capable, multiple threads can
6241  * invoke this function concurrently on the same Tx queue without SW lock.
6242  * @see rte_eth_dev_info_get, struct rte_eth_txconf::offloads
6243  *
6244  * @see rte_eth_tx_prepare to perform some prior checks or adjustments
6245  * for offloads.
6246  *
6247  * @note This function must not modify mbufs (including packets data)
6248  * unless the refcnt is 1.
6249  * An exception is the bonding PMD, which does not have "Tx prepare" support,
6250  * in this case, mbufs may be modified.
6251  *
6252  * @param port_id
6253  *   The port identifier of the Ethernet device.
6254  * @param queue_id
6255  *   The index of the transmit queue through which output packets must be
6256  *   sent.
6257  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
6258  *   to rte_eth_dev_configure().
6259  * @param tx_pkts
6260  *   The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
6261  *   which contain the output packets.
6262  * @param nb_pkts
6263  *   The maximum number of packets to transmit.
6264  * @return
6265  *   The number of output packets actually stored in transmit descriptors of
6266  *   the transmit ring. The return value can be less than the value of the
6267  *   *tx_pkts* parameter when the transmit ring is full or has been filled up.
6268  */
6269 static inline uint16_t
6270 rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
6271 		 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
6272 {
6273 	struct rte_eth_fp_ops *p;
6274 	void *qd;
6275 
6276 #ifdef RTE_ETHDEV_DEBUG_TX
6277 	if (port_id >= RTE_MAX_ETHPORTS ||
6278 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
6279 		RTE_ETHDEV_LOG(ERR,
6280 			"Invalid port_id=%u or queue_id=%u\n",
6281 			port_id, queue_id);
6282 		return 0;
6283 	}
6284 #endif
6285 
6286 	/* fetch pointer to queue data */
6287 	p = &rte_eth_fp_ops[port_id];
6288 	qd = p->txq.data[queue_id];
6289 
6290 #ifdef RTE_ETHDEV_DEBUG_TX
6291 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
6292 
6293 	if (qd == NULL) {
6294 		RTE_ETHDEV_LOG(ERR, "Invalid Tx queue_id=%u for port_id=%u\n",
6295 			queue_id, port_id);
6296 		return 0;
6297 	}
6298 #endif
6299 
6300 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
6301 	{
6302 		void *cb;
6303 
6304 		/* __ATOMIC_RELEASE memory order was used when the
6305 		 * call back was inserted into the list.
6306 		 * Since there is a clear dependency between loading
6307 		 * cb and cb->fn/cb->next, __ATOMIC_ACQUIRE memory order is
6308 		 * not required.
6309 		 */
6310 		cb = __atomic_load_n((void **)&p->txq.clbk[queue_id],
6311 				__ATOMIC_RELAXED);
6312 		if (unlikely(cb != NULL))
6313 			nb_pkts = rte_eth_call_tx_callbacks(port_id, queue_id,
6314 					tx_pkts, nb_pkts, cb);
6315 	}
6316 #endif
6317 
6318 	nb_pkts = p->tx_pkt_burst(qd, tx_pkts, nb_pkts);
6319 
6320 	rte_ethdev_trace_tx_burst(port_id, queue_id, (void **)tx_pkts, nb_pkts);
6321 	return nb_pkts;
6322 }
6323 
6324 /**
6325  * Process a burst of output packets on a transmit queue of an Ethernet device.
6326  *
6327  * The rte_eth_tx_prepare() function is invoked to prepare output packets to be
6328  * transmitted on the output queue *queue_id* of the Ethernet device designated
6329  * by its *port_id*.
6330  * The *nb_pkts* parameter is the number of packets to be prepared which are
6331  * supplied in the *tx_pkts* array of *rte_mbuf* structures, each of them
6332  * allocated from a pool created with rte_pktmbuf_pool_create().
6333  * For each packet to send, the rte_eth_tx_prepare() function performs
6334  * the following operations:
6335  *
6336  * - Check if packet meets devices requirements for Tx offloads.
6337  *
6338  * - Check limitations about number of segments.
6339  *
6340  * - Check additional requirements when debug is enabled.
6341  *
6342  * - Update and/or reset required checksums when Tx offload is set for packet.
6343  *
6344  * Since this function can modify packet data, provided mbufs must be safely
6345  * writable (e.g. modified data cannot be in shared segment).
6346  *
6347  * The rte_eth_tx_prepare() function returns the number of packets ready to be
6348  * sent. A return value equal to *nb_pkts* means that all packets are valid and
6349  * ready to be sent, otherwise stops processing on the first invalid packet and
6350  * leaves the rest packets untouched.
6351  *
6352  * When this functionality is not implemented in the driver, all packets are
6353  * are returned untouched.
6354  *
6355  * @param port_id
6356  *   The port identifier of the Ethernet device.
6357  *   The value must be a valid port ID.
6358  * @param queue_id
6359  *   The index of the transmit queue through which output packets must be
6360  *   sent.
6361  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
6362  *   to rte_eth_dev_configure().
6363  * @param tx_pkts
6364  *   The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
6365  *   which contain the output packets.
6366  * @param nb_pkts
6367  *   The maximum number of packets to process.
6368  * @return
6369  *   The number of packets correct and ready to be sent. The return value can be
6370  *   less than the value of the *tx_pkts* parameter when some packet doesn't
6371  *   meet devices requirements with rte_errno set appropriately:
6372  *   - EINVAL: offload flags are not correctly set
6373  *   - ENOTSUP: the offload feature is not supported by the hardware
6374  *   - ENODEV: if *port_id* is invalid (with debug enabled only)
6375  *
6376  */
6377 
6378 #ifndef RTE_ETHDEV_TX_PREPARE_NOOP
6379 
6380 static inline uint16_t
6381 rte_eth_tx_prepare(uint16_t port_id, uint16_t queue_id,
6382 		struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
6383 {
6384 	struct rte_eth_fp_ops *p;
6385 	void *qd;
6386 
6387 #ifdef RTE_ETHDEV_DEBUG_TX
6388 	if (port_id >= RTE_MAX_ETHPORTS ||
6389 			queue_id >= RTE_MAX_QUEUES_PER_PORT) {
6390 		RTE_ETHDEV_LOG(ERR,
6391 			"Invalid port_id=%u or queue_id=%u\n",
6392 			port_id, queue_id);
6393 		rte_errno = ENODEV;
6394 		return 0;
6395 	}
6396 #endif
6397 
6398 	/* fetch pointer to queue data */
6399 	p = &rte_eth_fp_ops[port_id];
6400 	qd = p->txq.data[queue_id];
6401 
6402 #ifdef RTE_ETHDEV_DEBUG_TX
6403 	if (!rte_eth_dev_is_valid_port(port_id)) {
6404 		RTE_ETHDEV_LOG(ERR, "Invalid Tx port_id=%u\n", port_id);
6405 		rte_errno = ENODEV;
6406 		return 0;
6407 	}
6408 	if (qd == NULL) {
6409 		RTE_ETHDEV_LOG(ERR, "Invalid Tx queue_id=%u for port_id=%u\n",
6410 			queue_id, port_id);
6411 		rte_errno = EINVAL;
6412 		return 0;
6413 	}
6414 #endif
6415 
6416 	if (!p->tx_pkt_prepare)
6417 		return nb_pkts;
6418 
6419 	return p->tx_pkt_prepare(qd, tx_pkts, nb_pkts);
6420 }
6421 
6422 #else
6423 
6424 /*
6425  * Native NOOP operation for compilation targets which doesn't require any
6426  * preparations steps, and functional NOOP may introduce unnecessary performance
6427  * drop.
6428  *
6429  * Generally this is not a good idea to turn it on globally and didn't should
6430  * be used if behavior of tx_preparation can change.
6431  */
6432 
6433 static inline uint16_t
6434 rte_eth_tx_prepare(__rte_unused uint16_t port_id,
6435 		__rte_unused uint16_t queue_id,
6436 		__rte_unused struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
6437 {
6438 	return nb_pkts;
6439 }
6440 
6441 #endif
6442 
6443 /**
6444  * Send any packets queued up for transmission on a port and HW queue
6445  *
6446  * This causes an explicit flush of packets previously buffered via the
6447  * rte_eth_tx_buffer() function. It returns the number of packets successfully
6448  * sent to the NIC, and calls the error callback for any unsent packets. Unless
6449  * explicitly set up otherwise, the default callback simply frees the unsent
6450  * packets back to the owning mempool.
6451  *
6452  * @param port_id
6453  *   The port identifier of the Ethernet device.
6454  * @param queue_id
6455  *   The index of the transmit queue through which output packets must be
6456  *   sent.
6457  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
6458  *   to rte_eth_dev_configure().
6459  * @param buffer
6460  *   Buffer of packets to be transmit.
6461  * @return
6462  *   The number of packets successfully sent to the Ethernet device. The error
6463  *   callback is called for any packets which could not be sent.
6464  */
6465 static inline uint16_t
6466 rte_eth_tx_buffer_flush(uint16_t port_id, uint16_t queue_id,
6467 		struct rte_eth_dev_tx_buffer *buffer)
6468 {
6469 	uint16_t sent;
6470 	uint16_t to_send = buffer->length;
6471 
6472 	if (to_send == 0)
6473 		return 0;
6474 
6475 	sent = rte_eth_tx_burst(port_id, queue_id, buffer->pkts, to_send);
6476 
6477 	buffer->length = 0;
6478 
6479 	/* All packets sent, or to be dealt with by callback below */
6480 	if (unlikely(sent != to_send))
6481 		buffer->error_callback(&buffer->pkts[sent],
6482 				       (uint16_t)(to_send - sent),
6483 				       buffer->error_userdata);
6484 
6485 	return sent;
6486 }
6487 
6488 /**
6489  * Buffer a single packet for future transmission on a port and queue
6490  *
6491  * This function takes a single mbuf/packet and buffers it for later
6492  * transmission on the particular port and queue specified. Once the buffer is
6493  * full of packets, an attempt will be made to transmit all the buffered
6494  * packets. In case of error, where not all packets can be transmitted, a
6495  * callback is called with the unsent packets as a parameter. If no callback
6496  * is explicitly set up, the unsent packets are just freed back to the owning
6497  * mempool. The function returns the number of packets actually sent i.e.
6498  * 0 if no buffer flush occurred, otherwise the number of packets successfully
6499  * flushed
6500  *
6501  * @param port_id
6502  *   The port identifier of the Ethernet device.
6503  * @param queue_id
6504  *   The index of the transmit queue through which output packets must be
6505  *   sent.
6506  *   The value must be in the range [0, nb_tx_queue - 1] previously supplied
6507  *   to rte_eth_dev_configure().
6508  * @param buffer
6509  *   Buffer used to collect packets to be sent.
6510  * @param tx_pkt
6511  *   Pointer to the packet mbuf to be sent.
6512  * @return
6513  *   0 = packet has been buffered for later transmission
6514  *   N > 0 = packet has been buffered, and the buffer was subsequently flushed,
6515  *     causing N packets to be sent, and the error callback to be called for
6516  *     the rest.
6517  */
6518 static __rte_always_inline uint16_t
6519 rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id,
6520 		struct rte_eth_dev_tx_buffer *buffer, struct rte_mbuf *tx_pkt)
6521 {
6522 	buffer->pkts[buffer->length++] = tx_pkt;
6523 	if (buffer->length < buffer->size)
6524 		return 0;
6525 
6526 	return rte_eth_tx_buffer_flush(port_id, queue_id, buffer);
6527 }
6528 
6529 /**
6530  * @warning
6531  * @b EXPERIMENTAL: this API may change without prior notice
6532  *
6533  * Get supported header protocols to split on Rx.
6534  *
6535  * When a packet type is announced to be split,
6536  * it *must* be supported by the PMD.
6537  * For instance, if eth-ipv4, eth-ipv4-udp is announced,
6538  * the PMD must return the following packet types for these packets:
6539  * - Ether/IPv4             -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4
6540  * - Ether/IPv4/UDP         -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP
6541  *
6542  * @param port_id
6543  *   The port identifier of the device.
6544  * @param[out] ptypes
6545  *   An array pointer to store supported protocol headers, allocated by caller.
6546  *   These ptypes are composed with RTE_PTYPE_*.
6547  * @param num
6548  *   Size of the array pointed by param ptypes.
6549  * @return
6550  *   - (>=0) Number of supported ptypes. If the number of types exceeds num,
6551  *           only num entries will be filled into the ptypes array,
6552  *           but the full count of supported ptypes will be returned.
6553  *   - (-ENOTSUP) if header protocol is not supported by device.
6554  *   - (-ENODEV) if *port_id* invalid.
6555  *   - (-EINVAL) if bad parameter.
6556  */
6557 __rte_experimental
6558 int rte_eth_buffer_split_get_supported_hdr_ptypes(uint16_t port_id, uint32_t *ptypes, int num);
6559 
6560 #ifdef __cplusplus
6561 }
6562 #endif
6563 
6564 #endif /* _RTE_ETHDEV_H_ */
6565