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