1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2017 Intel Corporation
11 * RTE Ethernet Device API
13 * The Ethernet Device API is composed of two parts:
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.
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.
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.
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.
37 * In all functions of the Ethernet API, the Ethernet device is
38 * designated by an integer >= 0 named the device port identifier.
40 * At the Ethernet driver level, Ethernet devices are represented by a generic
41 * data structure of type *rte_eth_dev*.
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.
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
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
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()
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.
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
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
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
93 * The following configuration may be retained or not
94 * depending on the device capabilities:
97 * - flow-related shared objects, e.g. indirect actions
99 * Any other configuration will not be stored and will need to be re-entered
100 * before a call to rte_eth_dev_start().
102 * Finally, a network application can close an Ethernet device by invoking the
103 * rte_eth_dev_close() function.
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
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
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.
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.
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
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:
132 * - Sharing among multiple packets the incompressible cost of the
133 * invocation of receive/transmit functions.
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.
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.
154 /* Use this macro to check if LRO API is supported */
155 #define RTE_ETHDEV_HAS_LRO_SUPPORT
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
163 #include <rte_compat.h>
165 #include <rte_interrupts.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>
175 #include "rte_ethdev_trace_fp.h"
176 #include "rte_dev_info.h"
178 extern int rte_eth_dev_logtype;
180 #define RTE_ETHDEV_LOG(level, ...) \
181 rte_log(RTE_LOG_ ## level, rte_eth_dev_logtype, "" __VA_ARGS__)
186 * Initializes a device iterator.
188 * This iterator allows accessing a list of devices matching some devargs.
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().
196 * Device description string.
199 * 0 on successful initialization, negative otherwise.
201 int rte_eth_iterator_init(struct rte_dev_iterator *iter, const char *devargs);
204 * Iterates on devices with devargs filter.
205 * The ownership is not checked.
207 * The next port ID is returned, and the iterator is updated.
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().
215 * A port ID if found, RTE_MAX_ETHPORTS otherwise.
217 uint16_t rte_eth_iterator_next(struct rte_dev_iterator *iter);
220 * Free some allocated fields of the iterator.
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).
225 * It is safe to call this function twice; it will do nothing more.
228 * Device iterator handle initialized by rte_eth_iterator_init().
229 * The fields bus_str and cls_str are freed if needed.
231 void rte_eth_iterator_cleanup(struct rte_dev_iterator *iter);
234 * Macro to iterate over all ethdev ports matching some devargs.
236 * If a break is done before the end of the loop,
237 * the function rte_eth_iterator_cleanup() must be called.
240 * Iterated port ID of type uint16_t.
242 * Device parameters input as string of type char*.
244 * Iterator handle of type struct rte_dev_iterator, used internally.
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))
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).
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. */
267 * Total of Rx packets dropped by the HW,
268 * because there are no available buffer (i.e. Rx queues are full).
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];
287 /**@{@name Link speed capabilities
288 * Device supported speeds bitmap flags
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
326 /**@{@name Link speed
327 * Ethernet numeric link speeds in Mbps
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
362 * A structure used to retrieve link-level information of an Ethernet port.
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 */
372 /**@{@name Link negotiation
373 * Constants used in link management.
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. */
391 * A structure used to configure the ring threshold registers of an Rx/Tx
392 * queue for an Ethernet port.
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. */
400 /**@{@name Multi-queue mode
401 * @see rte_eth_conf.rxmode.mq_mode.
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
412 * A set of values to identify what method is to be used to route
413 * packets to multiple queues.
415 enum rte_eth_rx_mq_mode {
416 /** None of DCB, RSS or VMDq mode */
417 RTE_ETH_MQ_RX_NONE = 0,
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,
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,
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
447 * A set of values to identify what method is to be used to transmit
448 * packets using multi-TCs.
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 */
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
462 * A structure used to configure the Rx features of an Ethernet port.
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).*/
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.
478 uint64_t reserved_64s[2]; /**< Reserved for future fields */
479 void *reserved_ptrs[2]; /**< Reserved for future fields */
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.
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,
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
499 * A structure used to describe a VLAN filter.
500 * If the bit corresponding to a VID is set, such VID is on.
502 struct rte_vlan_filter_conf {
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
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.
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.
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. */
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.
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
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.
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
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.
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.
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.
645 #define RTE_ETH_RSS_L4_CHKSUM RTE_BIT64(35)
646 #define ETH_RSS_L4_CHKSUM RTE_ETH_RSS_L4_CHKSUM
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
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
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.
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)
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.
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.
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
700 * level 1, requests RSS to be performed on the outermost packet
701 * encapsulation level.
703 #define RTE_ETH_RSS_LEVEL_OUTERMOST (UINT64_C(1) << 50)
704 #define ETH_RSS_LEVEL_OUTERMOST RTE_ETH_RSS_LEVEL_OUTERMOST
707 * level 2, requests RSS to be performed on the specified inner packet
708 * encapsulation level, from outermost to innermost (lower to higher values).
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
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)
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.
724 * RSS types with SRC/DST_ONLY.
728 static inline uint64_t
729 rte_eth_rss_hf_refine(uint64_t rss_hf)
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);
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);
740 #define RTE_ETH_RSS_IPV6_PRE32 ( \
742 RTE_ETH_RSS_L3_PRE32)
743 #define ETH_RSS_IPV6_PRE32 RTE_ETH_RSS_IPV6_PRE32
745 #define RTE_ETH_RSS_IPV6_PRE40 ( \
747 RTE_ETH_RSS_L3_PRE40)
748 #define ETH_RSS_IPV6_PRE40 RTE_ETH_RSS_IPV6_PRE40
750 #define RTE_ETH_RSS_IPV6_PRE48 ( \
752 RTE_ETH_RSS_L3_PRE48)
753 #define ETH_RSS_IPV6_PRE48 RTE_ETH_RSS_IPV6_PRE48
755 #define RTE_ETH_RSS_IPV6_PRE56 ( \
757 RTE_ETH_RSS_L3_PRE56)
758 #define ETH_RSS_IPV6_PRE56 RTE_ETH_RSS_IPV6_PRE56
760 #define RTE_ETH_RSS_IPV6_PRE64 ( \
762 RTE_ETH_RSS_L3_PRE64)
763 #define ETH_RSS_IPV6_PRE64 RTE_ETH_RSS_IPV6_PRE64
765 #define RTE_ETH_RSS_IPV6_PRE96 ( \
767 RTE_ETH_RSS_L3_PRE96)
768 #define ETH_RSS_IPV6_PRE96 RTE_ETH_RSS_IPV6_PRE96
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
860 #define RTE_ETH_RSS_IP ( \
862 RTE_ETH_RSS_FRAG_IPV4 | \
863 RTE_ETH_RSS_NONFRAG_IPV4_OTHER | \
865 RTE_ETH_RSS_FRAG_IPV6 | \
866 RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \
868 #define ETH_RSS_IP RTE_ETH_RSS_IP
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
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
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
887 #define RTE_ETH_RSS_TUNNEL ( \
888 RTE_ETH_RSS_VXLAN | \
889 RTE_ETH_RSS_GENEVE | \
891 #define ETH_RSS_TUNNEL RTE_ETH_RSS_TUNNEL
893 #define RTE_ETH_RSS_VLAN ( \
894 RTE_ETH_RSS_S_VLAN | \
896 #define ETH_RSS_VLAN RTE_ETH_RSS_VLAN
898 /** Mask of valid RSS hash protocols */
899 #define RTE_ETH_RSS_PROTO_MASK ( \
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 | \
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 | \
917 RTE_ETH_RSS_VXLAN | \
918 RTE_ETH_RSS_GENEVE | \
919 RTE_ETH_RSS_NVGRE | \
921 #define ETH_RSS_PROTO_MASK RTE_ETH_RSS_PROTO_MASK
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.
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
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
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
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
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
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
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
987 /**@{@name VMDq Rx mode
988 * @see rte_eth_vmdq_rx_conf.rx_mode
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
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
1013 struct rte_eth_rss_reta_entry64 {
1014 /** Mask bits indicate which entries need to be updated/queried. */
1016 /** Group of 64 redirection table entries. */
1017 uint16_t reta[RTE_ETH_RETA_GROUP_SIZE];
1021 * This enum indicates the possible number of traffic classes
1022 * in DCB configurations
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. */
1028 #define ETH_4_TCS RTE_ETH_4_TCS
1029 #define ETH_8_TCS RTE_ETH_8_TCS
1032 * This enum indicates the possible number of queue pools
1033 * in VMDq configurations.
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. */
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
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];
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];
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];
1065 struct rte_eth_vmdq_tx_conf {
1066 enum rte_eth_nb_pools nb_queue_pools; /**< VMDq mode, 64 pools. */
1070 * A structure used to configure the VMDq+DCB feature
1071 * of an Ethernet port.
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.
1077 * A default pool may be used, if desired, to route all traffic which
1078 * does not match the VLAN filter rules.
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 */
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];
1094 * A structure used to configure the VMDq feature of an Ethernet port when
1095 * not combined with the DCB feature.
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.
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.
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.
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_* */
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. */
1125 * A structure used to configure the Tx features of an Ethernet port.
1127 struct rte_eth_txmode {
1128 enum rte_eth_tx_mq_mode mq_mode; /**< Tx multi-queues mode. */
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.
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;
1145 uint64_t reserved_64s[2]; /**< Reserved for future fields */
1146 void *reserved_ptrs[2]; /**< Reserved for future fields */
1151 * @b EXPERIMENTAL: this structure may change without prior notice.
1153 * A structure used to configure an Rx packet segment to split.
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:
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.
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.
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.
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.
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
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. */
1194 * @b EXPERIMENTAL: this structure may change without prior notice.
1196 * A common structure used to describe Rx packet segment properties.
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. */
1205 * A structure used to configure an Rx ring of an Ethernet port.
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. */
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.
1219 uint16_t share_group;
1220 uint16_t share_qid; /**< Shared Rx queue ID in group */
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.
1228 * Points to the array of segment descriptions for an entire packet.
1229 * Array elements are properties for consecutive Rx segments.
1231 * The supported capabilities of receiving segmentation is reported
1232 * in rte_eth_dev_info.rx_seg_capa field.
1234 union rte_eth_rxseg *rx_seg;
1236 uint64_t reserved_64s[2]; /**< Reserved for future fields */
1237 void *reserved_ptrs[2]; /**< Reserved for future fields */
1241 * A structure used to configure a Tx ring of an Ethernet port.
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. */
1249 uint8_t tx_deferred_start; /**< Do not start queue with rte_eth_dev_start(). */
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.
1257 uint64_t reserved_64s[2]; /**< Reserved for future fields */
1258 void *reserved_ptrs[2]; /**< Reserved for future fields */
1263 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
1265 * A structure used to return the hairpin capabilities that are supported.
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. */
1277 #define RTE_ETH_MAX_HAIRPIN_PEERS 32
1281 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
1283 * A structure used to hold hairpin peer data.
1285 struct rte_eth_hairpin_peer {
1286 uint16_t port; /**< Peer port. */
1287 uint16_t queue; /**< Peer queue. */
1292 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
1294 * A structure used to configure hairpin binding.
1296 struct rte_eth_hairpin_conf {
1297 uint32_t peer_count:16; /**< The number of peers. */
1300 * Explicit Tx flow rule mode.
1301 * One hairpin pair of queues should have the same attribute.
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.
1308 uint32_t tx_explicit:1;
1311 * Manually bind hairpin queues.
1312 * One hairpin pair of queues should have the same attribute.
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.
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];
1327 * A structure contains information about HW descriptor ring limitations.
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. */
1335 * Max allowed number of segments per whole packet.
1337 * - For TSO packet this is the total number of data descriptors allowed
1340 * @see nb_mtu_seg_max
1342 uint16_t nb_seg_max;
1345 * Max number of segments per one MTU.
1347 * - For non-TSO packet, this is the maximum allowed number of segments
1348 * in a single transmit packet.
1350 * - For TSO packet each segment within the TSO may span up to this
1355 uint16_t nb_mtu_seg_max;
1359 * This enum indicates the flow control mode
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. */
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
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.
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 */
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.
1393 struct rte_eth_pfc_conf {
1394 struct rte_eth_fc_conf fc; /**< General flow control parameter. */
1395 uint8_t priority; /**< VLAN User Priority. */
1399 * Tunnel type for device-specific classifier configuration.
1400 * @see rte_eth_udp_tunnel
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,
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
1426 /* Deprecated API file for rte_eth_dev_filter_* functions */
1427 #include "rte_eth_ctrl.h"
1430 * Memory space that can be configured to store Flow Director filters
1431 * in the board memory.
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. */
1438 #define rte_fdir_pballoc_type rte_eth_fdir_pballoc_type
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
1445 * Select report mode of FDIR hash information in Rx descriptors.
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. */
1454 * A structure used to configure the Flow Director (FDIR) feature
1455 * of an Ethernet port.
1457 * If mode is RTE_FDIR_MODE_NONE, the pballoc value is ignored.
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. */
1465 struct rte_eth_fdir_masks mask;
1466 /** Flex payload configuration. */
1467 struct rte_eth_fdir_flex_conf flex_conf;
1470 #define rte_fdir_conf rte_eth_fdir_conf
1473 * UDP tunneling configuration.
1475 * Used to configure the classifier of a device,
1476 * associating an UDP port with a type of tunnel.
1478 * Some NICs may need such configuration to properly parse a tunnel
1479 * with any standard or custom UDP port.
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 */
1487 * A structure used to enable/disable specific device interrupts.
1489 struct rte_eth_intr_conf {
1490 /** enable/disable lsc interrupt. 0 (default) - disable, 1 enable */
1492 /** enable/disable rxq interrupt. 0 (default) - disable, 1 enable */
1494 /** enable/disable rmv interrupt. 0 (default) - disable, 1 enable */
1498 #define rte_intr_conf rte_eth_intr_conf
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.
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. */
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. */
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. */
1545 * Rx offload capabilities of a device.
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
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.
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)
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
1601 * If new Rx offload capabilities are defined, they also must be
1602 * mentioned in rte_rx_offload_names in rte_ethdev.c file.
1606 * Tx offload capabilities of a device.
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
1637 * Multiple threads can invoke rte_eth_tx_burst() concurrently on the same
1638 * Tx queue without SW lock.
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
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.
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
1655 * Device supports generic UDP tunneled packet TSO.
1656 * Application must set RTE_MBUF_F_TX_TUNNEL_UDP and other mbuf fields required
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
1662 * Device supports generic IP tunneled packet TSO.
1663 * Application must set RTE_MBUF_F_TX_TUNNEL_IP and other mbuf fields required
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
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.
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
1679 * If new Tx offload capabilities are defined, they also must be
1680 * mentioned in rte_tx_offload_names in rte_ethdev.c file.
1683 /**@{@name Device capabilities
1684 * Non-offload capabilities reported in rte_eth_dev_info.dev_capa.
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)
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
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)
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.
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
1717 * Preferred Rx/Tx port parameters.
1718 * There are separate instances of this structure for transmission
1719 * and reception respectively.
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 */
1728 * Default values for switch domain ID when ethdev does not support switch
1729 * domain definitions.
1731 #define RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID (UINT16_MAX)
1734 * Ethernet device associated switch information
1736 struct rte_eth_switch_info {
1737 const char *name; /**< switch name */
1738 uint16_t domain_id; /**< switch domain ID */
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
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.
1757 * @b EXPERIMENTAL: this structure may change without prior notice.
1759 * Ethernet device Rx buffer segmentation capabilities.
1761 struct rte_eth_rxseg_capa {
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. */
1771 * Ethernet device information
1775 * Ethernet device representor port type.
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. */
1785 * A structure used to retrieve the contextual information of
1786 * an Ethernet device, such as the controlling driver of the
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. */
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_). */
1840 * Switching information for ports on a device with a
1841 * embedded managed interconnect/switch.
1843 struct rte_eth_switch_info switch_info;
1845 uint64_t reserved_64s[2]; /**< Reserved for future fields */
1846 void *reserved_ptrs[2]; /**< Reserved for future fields */
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. */
1856 * Ethernet device Rx queue information structure.
1857 * Used to retrieve information about configured queue.
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;
1869 * Ethernet device Tx queue information structure.
1870 * Used to retrieve information about configured queue.
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;
1878 /* Generic Burst mode flag definition, values can be ORed. */
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
1885 #define RTE_ETH_BURST_FLAG_PER_QUEUE RTE_BIT64(0)
1888 * Ethernet device Rx/Tx queue packet burst mode information structure.
1889 * Used to retrieve information about packet burst mode setting.
1891 struct rte_eth_burst_mode {
1892 uint64_t flags; /**< The ORed values of RTE_ETH_BURST_FLAG_xxx */
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 */
1898 /** Maximum name length for extended statistics counters */
1899 #define RTE_ETH_XSTATS_NAME_SIZE 64
1902 * An Ethernet device extended statistic structure
1904 * This structure is used by rte_eth_xstats_get() to provide
1905 * statistics that are not provided in the generic *rte_eth_stats*
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.
1910 struct rte_eth_xstat {
1911 uint64_t id; /**< The index in xstats name array. */
1912 uint64_t value; /**< The statistic counter value. */
1916 * A name element for extended statistics.
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.
1922 * The xstats should follow a common naming scheme.
1923 * Some names are standardized in rte_stats_strings.
1925 * - rx_missed_errors
1927 * - tx_size_128_to_255_packets
1929 struct rte_eth_xstat_name {
1930 char name[RTE_ETH_XSTATS_NAME_SIZE]; /**< The statistic name. */
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
1939 * A structure used to get the information of queue and
1940 * TC mapping on both Tx and Rx paths.
1942 struct rte_eth_dcb_tc_queue_mapping {
1943 /** Rx queues assigned to tc per Pool */
1947 } tc_rxq[RTE_ETH_MAX_VMDQ_POOL][RTE_ETH_DCB_NUM_TCS];
1948 /** Rx queues assigned to tc per Pool */
1952 } tc_txq[RTE_ETH_MAX_VMDQ_POOL][RTE_ETH_DCB_NUM_TCS];
1956 * A structure used to get the information of DCB.
1957 * It includes TC UP mapping and queue TC mapping.
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;
1968 * This enum indicates the possible Forward Error Correction (FEC) modes
1969 * of an ethdev port.
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 */
1978 /* Translate from FEC mode to FEC capa */
1979 #define RTE_ETH_FEC_MODE_TO_CAPA(x) RTE_BIT32(x)
1981 /* This macro indicates FEC capa mask */
1982 #define RTE_ETH_FEC_MODE_CAPA_MASK(x) RTE_BIT32(RTE_ETH_FEC_ ## x)
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 */
1990 #define RTE_ETH_ALL RTE_MAX_ETHPORTS
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); \
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); \
2008 * Function type used for Rx packet processing packet callbacks.
2010 * The callback function is called on Rx with a burst of packets that have
2011 * been received on the given port and queue.
2014 * The Ethernet port on which Rx is being performed.
2016 * The queue on the Ethernet port which is being used to receive the packets.
2018 * The burst of packets that have just been received.
2020 * The number of packets in the burst pointed to by "pkts".
2022 * The max number of packets that can be stored in the "pkts" array.
2024 * The arbitrary user parameter passed in by the application when the callback
2025 * was originally configured.
2027 * The number of packets returned to the user.
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,
2034 * Function type used for Tx packet processing packet callbacks.
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.
2040 * The Ethernet port on which Tx is being performed.
2042 * The queue on the Ethernet port which is being used to transmit the packets.
2044 * The burst of packets that are about to be transmitted.
2046 * The number of packets in the burst pointed to by "pkts".
2048 * The arbitrary user parameter passed in by the application when the callback
2049 * was originally configured.
2051 * The number of packets to be written to the NIC.
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);
2057 * Possible states of an ethdev port.
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,
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 */
2074 #define RTE_ETH_DEV_SRIOV(dev) ((dev)->data->sriov)
2076 #define RTE_ETH_NAME_MAX_LEN RTE_DEV_NAME_MAX_LEN
2078 #define RTE_ETH_DEV_NO_OWNER 0
2080 #define RTE_ETH_MAX_OWNER_NAME_LEN 64
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. */
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.
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)
2104 * Queue xstats filled automatically by ethdev layer.
2105 * PMDs filling the queue xstats themselves should not set this flag
2107 #define RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS RTE_BIT32(6)
2111 * Iterates over valid ethdev ports owned by a specific owner.
2114 * The ID of the next possible valid owned port.
2116 * The owner identifier.
2117 * RTE_ETH_DEV_NO_OWNER means iterate over all valid ownerless ports.
2119 * Next valid port ID owned by owner_id, RTE_MAX_ETHPORTS if there is none.
2121 uint64_t rte_eth_find_next_owned_by(uint16_t port_id,
2122 const uint64_t owner_id);
2125 * Macro to iterate over all enabled ethdev ports owned by a specific owner.
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))
2133 * Iterates over valid ethdev ports.
2136 * The ID of the next possible valid port.
2138 * Next valid port ID, RTE_MAX_ETHPORTS if there is none.
2140 uint16_t rte_eth_find_next(uint16_t port_id);
2143 * Macro to iterate over all enabled and ownerless ethdev ports.
2145 #define RTE_ETH_FOREACH_DEV(p) \
2146 RTE_ETH_FOREACH_DEV_OWNED_BY(p, RTE_ETH_DEV_NO_OWNER)
2149 * Iterates over ethdev ports of a specified device.
2151 * @param port_id_start
2152 * The ID of the next possible valid port.
2154 * The generic device behind the ports to iterate.
2156 * Next port ID of the device, possibly port_id_start,
2157 * RTE_MAX_ETHPORTS if there is none.
2160 rte_eth_find_next_of(uint16_t port_id_start,
2161 const struct rte_device *parent);
2164 * Macro to iterate over all ethdev ports of a specified device.
2167 * The ID of the matching port being iterated.
2169 * The rte_device pointer matching the iterated ports.
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))
2177 * Iterates over sibling ethdev ports (i.e. sharing the same rte_device).
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.
2184 * Next sibling port ID, possibly port_id_start or ref_port_id itself,
2185 * RTE_MAX_ETHPORTS if there is none.
2188 rte_eth_find_next_sibling(uint16_t port_id_start, uint16_t ref_port_id);
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.
2196 * The ID of the matching port being iterated.
2197 * @param ref_port_id
2198 * The ID of the port being compared.
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))
2207 * @b EXPERIMENTAL: this API may change without prior notice.
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.
2214 * Owner identifier pointer.
2216 * Negative errno value on error, 0 on success.
2219 int rte_eth_dev_owner_new(uint64_t *owner_id);
2223 * @b EXPERIMENTAL: this API may change without prior notice.
2225 * Set an Ethernet device owner.
2228 * The identifier of the port to own.
2230 * The owner pointer.
2232 * Negative errno value on error, 0 on success.
2235 int rte_eth_dev_owner_set(const uint16_t port_id,
2236 const struct rte_eth_dev_owner *owner);
2240 * @b EXPERIMENTAL: this API may change without prior notice.
2242 * Unset Ethernet device owner to make the device ownerless.
2245 * The identifier of port to make ownerless.
2247 * The owner identifier.
2249 * 0 on success, negative errno value on error.
2252 int rte_eth_dev_owner_unset(const uint16_t port_id,
2253 const uint64_t owner_id);
2257 * @b EXPERIMENTAL: this API may change without prior notice.
2259 * Remove owner from all Ethernet devices owned by a specific owner.
2262 * The owner identifier.
2264 * 0 on success, negative errno value on error.
2267 int rte_eth_dev_owner_delete(const uint64_t owner_id);
2271 * @b EXPERIMENTAL: this API may change without prior notice.
2273 * Get the owner of an Ethernet device.
2276 * The port identifier.
2278 * The owner structure pointer to fill.
2280 * 0 on success, negative errno value on error..
2283 int rte_eth_dev_owner_get(const uint16_t port_id,
2284 struct rte_eth_dev_owner *owner);
2287 * Get the number of ports which are usable for the application.
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.
2294 * The count of available Ethernet devices.
2296 uint16_t rte_eth_dev_count_avail(void);
2299 * Get the total number of ports which are allocated.
2301 * Some devices may not be available for the application.
2304 * The total count of Ethernet devices.
2306 uint16_t rte_eth_dev_count_total(void);
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
2313 * Numerical speed value in Mbps
2315 * RTE_ETH_LINK_[HALF/FULL]_DUPLEX (only for 10/100M speeds)
2317 * 0 if the speed cannot be mapped
2319 uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex);
2322 * Get RTE_ETH_RX_OFFLOAD_* flag name.
2327 * Offload name or 'UNKNOWN' if the flag cannot be recognised.
2329 const char *rte_eth_dev_rx_offload_name(uint64_t offload);
2332 * Get RTE_ETH_TX_OFFLOAD_* flag name.
2337 * Offload name or 'UNKNOWN' if the flag cannot be recognised.
2339 const char *rte_eth_dev_tx_offload_name(uint64_t offload);
2343 * @b EXPERIMENTAL: this API may change without prior notice.
2345 * Get RTE_ETH_DEV_CAPA_* flag name.
2350 * Capability name or 'UNKNOWN' if the flag cannot be recognized.
2353 const char *rte_eth_dev_capability_name(uint64_t capability);
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
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.
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
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.
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.
2391 * - 0: Success, device configured.
2392 * - <0: Error code returned by the driver configuration function.
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);
2399 * @b EXPERIMENTAL: this API may change without prior notice.
2401 * Check if an Ethernet device was physically removed.
2404 * The port identifier of the Ethernet device.
2406 * 1 when the Ethernet device is removed, otherwise 0.
2410 rte_eth_dev_is_removed(uint16_t port_id);
2413 * Allocate and set up a receive queue for an Ethernet device.
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*.
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().
2427 * The number of receive descriptors to allocate for the receive ring.
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.
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
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
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.
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:
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.
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.
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);
2481 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
2483 * Allocate and set up a hairpin receive queue for an Ethernet device.
2485 * The function set up the selected queue to be used in hairpin.
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().
2494 * The number of receive descriptors to allocate for the receive ring.
2495 * 0 means the PMD will use default value.
2497 * The pointer to the hairpin configuration.
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.
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);
2512 * Allocate and set up a transmit queue for an Ethernet device.
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().
2521 * The number of transmit descriptors to allocate for the transmit ring.
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.
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
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
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.
2553 * Note that setting *tx_free_thresh* or *tx_rs_thresh* value to 0 forces
2554 * the transmit function to use default values.
2556 * - 0: Success, the transmit queue is correctly set up.
2557 * - -ENOMEM: Unable to allocate the transmit ring descriptors.
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);
2565 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
2567 * Allocate and set up a transmit hairpin queue for an Ethernet device.
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().
2576 * The number of transmit descriptors to allocate for the transmit ring.
2577 * 0 to set default PMD value.
2579 * The hairpin configuration.
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.
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);
2595 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
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
2602 * The port identifier of the Ethernet device.
2604 * Pointer to the array to store the peer ports list.
2606 * Length of the array to store the port identifiers.
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.
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.
2620 int rte_eth_hairpin_get_peer_ports(uint16_t port_id, uint16_t *peer_ports,
2621 size_t len, uint32_t direction);
2625 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
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.
2632 * The identifier of the Tx 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.
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.
2646 int rte_eth_hairpin_bind(uint16_t tx_port, uint16_t rx_port);
2650 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
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).
2659 * The identifier of the Tx 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.
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.
2673 int rte_eth_hairpin_unbind(uint16_t tx_port, uint16_t rx_port);
2676 * Return the NUMA socket to which an Ethernet device is connected
2679 * The port identifier of the Ethernet device
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.
2685 int rte_eth_dev_socket_id(uint16_t port_id);
2688 * Check if port_id of device is attached
2691 * The port identifier of the Ethernet device
2693 * - 0 if port is out of range or not attached
2694 * - 1 if device is attached
2696 int rte_eth_dev_is_valid_port(uint16_t port_id);
2699 * Start specified Rx queue of a port. It is used when rx_deferred_start
2700 * flag of the specified queue is true.
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().
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.
2715 int rte_eth_dev_rx_queue_start(uint16_t port_id, uint16_t rx_queue_id);
2718 * Stop specified Rx queue of a port
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().
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.
2733 int rte_eth_dev_rx_queue_stop(uint16_t port_id, uint16_t rx_queue_id);
2736 * Start Tx for specified queue of a port. It is used when tx_deferred_start
2737 * flag of the specified queue is true.
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().
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.
2752 int rte_eth_dev_tx_queue_start(uint16_t port_id, uint16_t tx_queue_id);
2755 * Stop specified Tx queue of a port
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().
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.
2770 int rte_eth_dev_tx_queue_stop(uint16_t port_id, uint16_t tx_queue_id);
2773 * Start an Ethernet device.
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
2779 * Device RTE_ETH_DEV_NOLIVE_MAC_ADDR flag causes MAC address to be set before
2780 * PMD port start callback function is invoked.
2782 * On success, all basic functions exported by the Ethernet API (link status,
2783 * receive/transmit, and so on) can be invoked.
2786 * The port identifier of the Ethernet device.
2788 * - 0: Success, Ethernet device started.
2789 * - <0: Error code of the driver device start function.
2791 int rte_eth_dev_start(uint16_t port_id);
2794 * Stop an Ethernet device. The device can be restarted with a call to
2795 * rte_eth_dev_start()
2798 * The port identifier of the Ethernet device.
2800 * - 0: Success, Ethernet device stopped.
2801 * - <0: Error code of the driver device stop function.
2803 int rte_eth_dev_stop(uint16_t port_id);
2806 * Link up an Ethernet device.
2808 * Set device link up will re-enable the device Rx/Tx
2809 * functionality after it is previously set device linked down.
2812 * The port identifier of the Ethernet device.
2814 * - 0: Success, Ethernet device linked up.
2815 * - <0: Error code of the driver device link up function.
2817 int rte_eth_dev_set_link_up(uint16_t port_id);
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()
2826 * The port identifier of the Ethernet device.
2828 int rte_eth_dev_set_link_down(uint16_t port_id);
2831 * Close a stopped Ethernet device. The device cannot be restarted!
2832 * The function frees all port resources.
2835 * The port identifier of the Ethernet device.
2837 * - Zero if the port is closed successfully.
2838 * - Negative if something went wrong.
2840 int rte_eth_dev_close(uint16_t port_id);
2843 * Reset a Ethernet device and keep its port ID.
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.
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
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.
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
2868 * The port identifier of the Ethernet device.
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.
2879 int rte_eth_dev_reset(uint16_t port_id);
2882 * Enable receipt in promiscuous mode for an Ethernet device.
2885 * The port identifier of the Ethernet device.
2887 * - (0) if successful.
2888 * - (-ENOTSUP) if support for promiscuous_enable() does not exist
2890 * - (-ENODEV) if *port_id* invalid.
2892 int rte_eth_promiscuous_enable(uint16_t port_id);
2895 * Disable receipt in promiscuous mode for an Ethernet device.
2898 * The port identifier of the Ethernet device.
2900 * - (0) if successful.
2901 * - (-ENOTSUP) if support for promiscuous_disable() does not exist
2903 * - (-ENODEV) if *port_id* invalid.
2905 int rte_eth_promiscuous_disable(uint16_t port_id);
2908 * Return the value of promiscuous mode for an Ethernet device.
2911 * The port identifier of the Ethernet device.
2913 * - (1) if promiscuous is enabled
2914 * - (0) if promiscuous is disabled.
2917 int rte_eth_promiscuous_get(uint16_t port_id);
2920 * Enable the receipt of any multicast frame by an Ethernet device.
2923 * The port identifier of the Ethernet device.
2925 * - (0) if successful.
2926 * - (-ENOTSUP) if support for allmulticast_enable() does not exist
2928 * - (-ENODEV) if *port_id* invalid.
2930 int rte_eth_allmulticast_enable(uint16_t port_id);
2933 * Disable the receipt of all multicast frames by an Ethernet device.
2936 * The port identifier of the Ethernet device.
2938 * - (0) if successful.
2939 * - (-ENOTSUP) if support for allmulticast_disable() does not exist
2941 * - (-ENODEV) if *port_id* invalid.
2943 int rte_eth_allmulticast_disable(uint16_t port_id);
2946 * Return the value of allmulticast mode for an Ethernet device.
2949 * The port identifier of the Ethernet device.
2951 * - (1) if allmulticast is enabled
2952 * - (0) if allmulticast is disabled.
2955 int rte_eth_allmulticast_get(uint16_t port_id);
2958 * Retrieve the link status (up/down), the duplex mode (half/full),
2959 * the negotiation (auto/fixed), and if available, the speed (Mbps).
2961 * It might need to wait up to 9 seconds.
2962 * @see rte_eth_link_get_nowait.
2965 * The port identifier of the Ethernet device.
2967 * Link information written back.
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.
2974 int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link);
2977 * Retrieve the link status (up/down), the duplex mode (half/full),
2978 * the negotiation (auto/fixed), and if available, the speed (Mbps).
2981 * The port identifier of the Ethernet device.
2983 * Link information written back.
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.
2990 int rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *link);
2994 * @b EXPERIMENTAL: this API may change without prior notice.
2996 * The function converts a link_speed to a string. It handles all special
2997 * values like unknown or none speed.
3000 * link_speed of rte_eth_link struct
3002 * Link speed in textual format. It's pointer to immutable memory.
3003 * No free is required.
3006 const char *rte_eth_link_speed_to_str(uint32_t link_speed);
3010 * @b EXPERIMENTAL: this API may change without prior notice.
3012 * The function converts a rte_eth_link struct representing a link status to
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.
3020 * Length of available memory at 'str' string.
3022 * Link status returned by rte_eth_link_get function
3024 * Number of bytes written to str array or -EINVAL if bad parameter.
3027 int rte_eth_link_to_str(char *str, size_t len,
3028 const struct rte_eth_link *eth_link);
3031 * Retrieve the general I/O statistics of an Ethernet device.
3034 * The port identifier of the Ethernet device.
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.
3045 * Zero if successful. Non-zero otherwise.
3047 int rte_eth_stats_get(uint16_t port_id, struct rte_eth_stats *stats);
3050 * Reset the general I/O statistics of an Ethernet device.
3053 * The port identifier of the Ethernet device.
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.
3060 int rte_eth_stats_reset(uint16_t port_id);
3063 * Retrieve names of extended statistics of an Ethernet device.
3065 * There is an assumption that 'xstat_names' and 'xstats' arrays are matched
3067 * xstats_names[i].name => xstats[i].value
3069 * And the array index is same with id field of 'struct rte_eth_xstat':
3072 * This assumption makes key-value pair matching less flexible but simpler.
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
3081 * The size of the xstats_names array (number of elements).
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).
3091 int rte_eth_xstats_get_names(uint16_t port_id,
3092 struct rte_eth_xstat_name *xstats_names,
3096 * Retrieve extended statistics of an Ethernet device.
3098 * There is an assumption that 'xstat_names' and 'xstats' arrays are matched
3100 * xstats_names[i].name => xstats[i].value
3102 * And the array index is same with id field of 'struct rte_eth_xstat':
3105 * This assumption makes key-value pair matching less flexible but simpler.
3108 * The port identifier of the Ethernet device.
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.
3114 * The size of the xstats array (number of elements).
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).
3124 int rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats,
3128 * Retrieve names of extended statistics of an Ethernet device.
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).
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.
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.
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.
3152 rte_eth_xstats_get_names_by_id(uint16_t port_id,
3153 struct rte_eth_xstat_name *xstats_names, unsigned int size,
3157 * Retrieve extended statistics of an Ethernet device.
3160 * The port identifier of the Ethernet device.
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.
3166 * Array to be filled in with requested device statistics.
3167 * Must not be NULL if ids are specified (not NULL).
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.
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.
3180 int rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,
3181 uint64_t *values, unsigned int size);
3184 * Gets the ID of a statistic from its name.
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()
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.
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.
3202 int rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name,
3206 * Reset extended statistics of an Ethernet device.
3209 * The port identifier of the Ethernet device.
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.
3217 int rte_eth_xstats_reset(uint16_t port_id);
3220 * Set a mapping for the specified transmit queue to the specified per-queue
3221 * statistics counter.
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().
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.
3235 * Zero if successful. Non-zero otherwise.
3237 int rte_eth_dev_set_tx_queue_stats_mapping(uint16_t port_id,
3238 uint16_t tx_queue_id, uint8_t stat_idx);
3241 * Set a mapping for the specified receive queue to the specified per-queue
3242 * statistics counter.
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().
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.
3256 * Zero if successful. Non-zero otherwise.
3258 int rte_eth_dev_set_rx_queue_stats_mapping(uint16_t port_id,
3259 uint16_t rx_queue_id,
3263 * Retrieve the Ethernet address of an Ethernet device.
3266 * The port identifier of the Ethernet device.
3268 * A pointer to a structure of type *ether_addr* to be filled with
3269 * the Ethernet address of the Ethernet device.
3271 * - (0) if successful
3272 * - (-ENODEV) if *port_id* invalid.
3273 * - (-EINVAL) if bad parameter.
3275 int rte_eth_macaddr_get(uint16_t port_id, struct rte_ether_addr *mac_addr);
3279 * @b EXPERIMENTAL: this API may change without prior notice
3281 * Retrieve the Ethernet addresses of an Ethernet device.
3284 * The port identifier of the Ethernet device.
3286 * A pointer to an array of structures of type *ether_addr* to be filled with
3287 * the Ethernet addresses of the Ethernet device.
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.
3293 * - number of retrieved addresses if successful
3294 * - (-ENODEV) if *port_id* invalid.
3295 * - (-EINVAL) if bad parameter.
3298 int rte_eth_macaddrs_get(uint16_t port_id, struct rte_ether_addr *ma,
3302 * Retrieve the contextual information of an Ethernet device.
3304 * As part of this function, a number of of fields in dev_info will be
3305 * initialized as follows:
3310 * Where lim is defined within the rte_eth_dev_info_get as
3312 * const struct rte_eth_desc_lim lim = {
3313 * .nb_max = UINT16_MAX,
3316 * .nb_seg_max = UINT16_MAX,
3317 * .nb_mtu_seg_max = UINT16_MAX,
3320 * device = dev->device
3321 * min_mtu = RTE_ETHER_MIN_LEN - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN
3322 * max_mtu = UINT16_MAX
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:
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
3334 * The port identifier of the Ethernet device.
3336 * A pointer to a structure of type *rte_eth_dev_info* to be filled with
3337 * the contextual information of the Ethernet device.
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.
3344 int rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info);
3348 * @b EXPERIMENTAL: this API may change without prior notice.
3350 * Retrieve the configuration of an Ethernet device.
3353 * The port identifier of the Ethernet device.
3355 * Location for Ethernet device configuration to be filled in.
3357 * - (0) if successful.
3358 * - (-ENODEV) if *port_id* invalid.
3359 * - (-EINVAL) if bad parameter.
3362 int rte_eth_dev_conf_get(uint16_t port_id, struct rte_eth_conf *dev_conf);
3365 * Retrieve the firmware version of a device.
3368 * The port identifier of the device.
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.
3373 * The size of the string array pointed by fw_version, which should be
3374 * large enough to store firmware version of the device.
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.
3384 int rte_eth_dev_fw_version_get(uint16_t port_id,
3385 char *fw_version, size_t fw_size);
3388 * Retrieve the supported packet types of an Ethernet device.
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
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.
3406 * Better to invoke this API after the device is already started or Rx burst
3407 * function is decided, to obtain correct supported ptypes.
3409 * if a given PMD does not report what ptypes it supports, then the supported
3410 * ptype count is reported as 0.
3412 * The port identifier of the Ethernet device.
3414 * A hint of what kind of packet type which the caller is interested in.
3416 * An array pointer to store adequate packet types, allocated by caller.
3418 * Size of the array pointed by param ptypes.
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.
3426 int rte_eth_dev_get_supported_ptypes(uint16_t port_id, uint32_t ptype_mask,
3427 uint32_t *ptypes, int num);
3429 * Inform Ethernet device about reduced range of packet types to handle.
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.
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
3441 * The port identifier of the Ethernet device.
3443 * The ptype family that application is interested in should be bitwise OR of
3444 * RTE_PTYPE_*_MASK or 0.
3446 * An array pointer to store set packet types, allocated by caller. The
3447 * function marks the end of array with RTE_PTYPE_UNKNOWN.
3449 * Size of the array pointed by param ptypes.
3450 * Should be rte_eth_dev_get_supported_ptypes() + 1 to accommodate the
3454 * - (-ENODEV) if *port_id* invalid.
3455 * - (-EINVAL) if *ptype_mask* is invalid (or) set_ptypes is NULL and
3458 int rte_eth_dev_set_ptypes(uint16_t port_id, uint32_t ptype_mask,
3459 uint32_t *set_ptypes, unsigned int num);
3462 * Retrieve the MTU of an Ethernet device.
3465 * The port identifier of the Ethernet device.
3467 * A pointer to a uint16_t where the retrieved MTU is to be stored.
3469 * - (0) if successful.
3470 * - (-ENODEV) if *port_id* invalid.
3471 * - (-EINVAL) if bad parameter.
3473 int rte_eth_dev_get_mtu(uint16_t port_id, uint16_t *mtu);
3476 * Change the MTU of an Ethernet device.
3479 * The port identifier of the Ethernet device.
3481 * A uint16_t for the MTU to be applied.
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
3492 int rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu);
3495 * Enable/Disable hardware filtering by an Ethernet device of received
3496 * VLAN packets tagged with a given VLAN Tag Identifier.
3499 * The port identifier of the Ethernet device.
3501 * The VLAN Tag Identifier whose filtering must be enabled or disabled.
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*.
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.
3513 int rte_eth_dev_vlan_filter(uint16_t port_id, uint16_t vlan_id, int on);
3516 * Enable/Disable hardware VLAN Strip by a Rx queue of an Ethernet device.
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().
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.
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.
3533 int rte_eth_dev_set_vlan_strip_on_queue(uint16_t port_id, uint16_t rx_queue_id,
3537 * Set the Outer VLAN Ether Type by an Ethernet device, it can be inserted to
3541 * The port identifier of the Ethernet device.
3545 * The Tag Protocol ID
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.
3552 int rte_eth_dev_set_vlan_ether_type(uint16_t port_id,
3553 enum rte_vlan_type vlan_type,
3557 * Set VLAN offload configuration on an Ethernet device.
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
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.
3573 int rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask);
3576 * Read VLAN Offload configuration from an Ethernet device
3579 * The port identifier of the Ethernet device.
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.
3588 int rte_eth_dev_get_vlan_offload(uint16_t port_id);
3591 * Set port based Tx VLAN insertion on or off.
3594 * The port identifier of the Ethernet device.
3596 * Port based Tx VLAN identifier together with user priority.
3598 * Turn on or off the port based Tx VLAN insertion.
3601 * - (0) if successful.
3602 * - negative if failed.
3604 int rte_eth_dev_set_vlan_pvid(uint16_t port_id, uint16_t pvid, int on);
3606 typedef void (*buffer_tx_error_fn)(struct rte_mbuf **unsent, uint16_t count,
3610 * Structure used to buffer packets for future Tx
3611 * Used by APIs rte_eth_tx_buffer and rte_eth_tx_buffer_flush
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[];
3623 * Calculate the size of the Tx buffer.
3626 * Number of stored packets.
3628 #define RTE_ETH_TX_BUFFER_SIZE(sz) \
3629 (sizeof(struct rte_eth_dev_tx_buffer) + (sz) * sizeof(struct rte_mbuf *))
3632 * Initialize default values for buffered transmitting
3635 * Tx buffer to be initialized.
3642 rte_eth_tx_buffer_init(struct rte_eth_dev_tx_buffer *buffer, uint16_t size);
3645 * Configure a callback for buffered packets which cannot be sent
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.
3660 * The port identifier of the Ethernet device.
3662 * The function to be used as the callback.
3664 * Arbitrary parameter to be passed to the callback function
3666 * 0 on success, or -EINVAL if bad parameter
3669 rte_eth_tx_buffer_set_err_callback(struct rte_eth_dev_tx_buffer *buffer,
3670 buffer_tx_error_fn callback, void *userdata);
3673 * Callback function for silently dropping unsent buffered packets.
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.
3680 * NOTE: this function should not be called directly, instead it should be used
3681 * as a callback for packet buffering.
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.
3688 * The previously buffered packets which could not be sent
3690 * The number of unsent packets in the pkts array
3695 rte_eth_tx_buffer_drop_callback(struct rte_mbuf **pkts, uint16_t unsent,
3699 * Callback function for tracking unsent buffered packets.
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.
3707 * NOTE: this function should not be called directly, instead it should be used
3708 * as a callback for packet buffering.
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.
3715 * The previously buffered packets which could not be sent
3717 * The number of unsent packets in the pkts array
3719 * Pointer to an uint64_t value, which will be incremented by unsent
3722 rte_eth_tx_buffer_count_callback(struct rte_mbuf **pkts, uint16_t unsent,
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
3732 * The port identifier of the Ethernet device.
3734 * The index of the transmit queue through which output packets must be
3736 * The value must be in the range [0, nb_tx_queue - 1] previously supplied
3737 * to rte_eth_dev_configure().
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.
3743 * -ENODEV: Invalid interface
3744 * -EIO: device is removed
3745 * -ENOTSUP: Driver does not support function
3747 * 0-n: Number of packets freed. More packets may still remain in ring that
3751 rte_eth_tx_done_cleanup(uint16_t port_id, uint16_t queue_id, uint32_t free_cnt);
3754 * Subtypes for IPsec offload event(@ref RTE_ETH_EVENT_IPSEC) raised by
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
3771 * Descriptor for @ref RTE_ETH_EVENT_IPSEC event. Used by eth dev to send extra
3772 * information of the IPsec offload event.
3774 struct rte_eth_event_ipsec_desc {
3775 /** Type of RTE_ETH_EVENT_IPSEC_* event */
3776 enum rte_eth_event_ipsec_subtype subtype;
3778 * Event specific metadata.
3780 * For the following events, *userdata* registered
3781 * with the *rte_security_session* would be returned
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
3788 * @see struct rte_security_session_conf
3795 * The eth device event type for interrupt, and maybe others in the future.
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 */
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);
3819 * Register a callback function for port event.
3823 * RTE_ETH_ALL means register the event for all port ids.
3827 * User supplied callback function to be called.
3829 * Pointer to the parameters for the registered callback.
3832 * - On success, zero.
3833 * - On failure, a negative value.
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);
3840 * Unregister a callback function for port event.
3844 * RTE_ETH_ALL means unregister the event for all port ids.
3848 * User supplied callback function to be called.
3850 * Pointer to the parameters for the registered callback. -1 means to
3851 * remove all for the same callback address and same event.
3854 * - On success, zero.
3855 * - On failure, a negative value.
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);
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.
3866 * The rte_eth_dev_rx_intr_enable() function enables Rx queue
3867 * interrupt on specific Rx queue of a port.
3870 * The port identifier of the Ethernet device.
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().
3876 * - (0) if successful.
3877 * - (-ENOTSUP) if underlying hardware OR driver doesn't support
3879 * - (-ENODEV) if *port_id* invalid.
3880 * - (-EIO) if device is removed.
3882 int rte_eth_dev_rx_intr_enable(uint16_t port_id, uint16_t queue_id);
3885 * When lcore wakes up from Rx interrupt indicating packet coming, disable Rx
3886 * interrupt and returns to polling mode.
3888 * The rte_eth_dev_rx_intr_disable() function disables Rx queue
3889 * interrupt on specific Rx queue of a port.
3892 * The port identifier of the Ethernet device.
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().
3898 * - (0) if successful.
3899 * - (-ENOTSUP) if underlying hardware OR driver doesn't support
3901 * - (-ENODEV) if *port_id* invalid.
3902 * - (-EIO) if device is removed.
3904 int rte_eth_dev_rx_intr_disable(uint16_t port_id, uint16_t queue_id);
3907 * Rx Interrupt control per port.
3910 * The port identifier of the Ethernet device.
3912 * Epoll instance fd which the intr vector associated to.
3913 * Using RTE_EPOLL_PER_THREAD allows to use per thread epoll instance.
3915 * The operation be performed for the vector.
3916 * Operation type of {RTE_INTR_EVENT_ADD, RTE_INTR_EVENT_DEL}.
3920 * - On success, zero.
3921 * - On failure, a negative value.
3923 int rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data);
3926 * Rx Interrupt control per queue.
3929 * The port identifier of the Ethernet device.
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().
3935 * Epoll instance fd which the intr vector associated to.
3936 * Using RTE_EPOLL_PER_THREAD allows to use per thread epoll instance.
3938 * The operation be performed for the vector.
3939 * Operation type of {RTE_INTR_EVENT_ADD, RTE_INTR_EVENT_DEL}.
3943 * - On success, zero.
3944 * - On failure, a negative value.
3946 int rte_eth_dev_rx_intr_ctl_q(uint16_t port_id, uint16_t queue_id,
3947 int epfd, int op, void *data);
3950 * Get interrupt fd per Rx queue.
3953 * The port identifier of the Ethernet device.
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().
3959 * - (>=0) the interrupt fd associated to the requested Rx queue if
3964 rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t queue_id);
3967 * Turn on the LED on the Ethernet device.
3968 * This function turns on the LED on the Ethernet device.
3971 * The port identifier of the Ethernet device.
3973 * - (0) if successful.
3974 * - (-ENOTSUP) if underlying hardware OR driver doesn't support
3976 * - (-ENODEV) if *port_id* invalid.
3977 * - (-EIO) if device is removed.
3979 int rte_eth_led_on(uint16_t port_id);
3982 * Turn off the LED on the Ethernet device.
3983 * This function turns off the LED on the Ethernet device.
3986 * The port identifier of the Ethernet device.
3988 * - (0) if successful.
3989 * - (-ENOTSUP) if underlying hardware OR driver doesn't support
3991 * - (-ENODEV) if *port_id* invalid.
3992 * - (-EIO) if device is removed.
3994 int rte_eth_led_off(uint16_t port_id);
3998 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
4000 * Get Forward Error Correction(FEC) capability.
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.
4009 * a number of elements in an speed_fec_capa array.
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.
4020 * - (-EIO) if device is removed.
4021 * - (-ENODEV) if *port_id* invalid.
4022 * - (-EINVAL) if *num* or *speed_fec_capa* invalid
4025 int rte_eth_fec_get_capability(uint16_t port_id,
4026 struct rte_eth_fec_capa *speed_fec_capa,
4031 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
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.
4039 * The port identifier of the Ethernet device.
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).
4046 * - (0) if successful.
4047 * - (-ENOTSUP) if underlying hardware OR driver doesn't support.
4049 * - (-EIO) if device is removed.
4050 * - (-ENODEV) if *port_id* invalid.
4053 int rte_eth_fec_get(uint16_t port_id, uint32_t *fec_capa);
4057 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
4059 * Set Forward Error Correction(FEC) mode.
4062 * The port identifier of the Ethernet device.
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).
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.
4076 int rte_eth_fec_set(uint16_t port_id, uint32_t fec_capa);
4079 * Get current status of the Ethernet link flow control for Ethernet device
4082 * The port identifier of the Ethernet device.
4084 * The pointer to the structure where to store the flow control parameters.
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.
4092 int rte_eth_dev_flow_ctrl_get(uint16_t port_id,
4093 struct rte_eth_fc_conf *fc_conf);
4096 * Configure the Ethernet link flow control for Ethernet device
4099 * The port identifier of the Ethernet device.
4101 * The pointer to the structure of the flow control parameters.
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.
4109 int rte_eth_dev_flow_ctrl_set(uint16_t port_id,
4110 struct rte_eth_fc_conf *fc_conf);
4113 * Configure the Ethernet priority flow control under DCB environment
4114 * for Ethernet device.
4117 * The port identifier of the Ethernet device.
4119 * The pointer to the structure of the priority flow control parameters.
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.
4127 int rte_eth_dev_priority_flow_ctrl_set(uint16_t port_id,
4128 struct rte_eth_pfc_conf *pfc_conf);
4131 * Add a MAC address to the set used for filtering incoming packets.
4134 * The port identifier of the Ethernet device.
4136 * The MAC address to add.
4138 * VMDq pool index to associate address with (if VMDq is enabled). If VMDq is
4139 * not enabled, this should be set to 0.
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.
4148 int rte_eth_dev_mac_addr_add(uint16_t port_id, struct rte_ether_addr *mac_addr,
4152 * Remove a MAC address from the internal array of addresses.
4155 * The port identifier of the Ethernet device.
4157 * MAC address to remove.
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.
4165 int rte_eth_dev_mac_addr_remove(uint16_t port_id,
4166 struct rte_ether_addr *mac_addr);
4169 * Set the default MAC address.
4172 * The port identifier of the Ethernet device.
4174 * New default MAC address.
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.
4181 int rte_eth_dev_default_mac_addr_set(uint16_t port_id,
4182 struct rte_ether_addr *mac_addr);
4185 * Update Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
4188 * The port identifier of the Ethernet device.
4192 * Redirection table size. The table size can be queried by
4193 * rte_eth_dev_info_get().
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.
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);
4206 * Query Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
4209 * The port identifier of the Ethernet device.
4211 * RETA to query. For each requested reta entry, corresponding bit
4212 * in mask must be set.
4214 * Redirection table size. The table size can be queried by
4215 * rte_eth_dev_info_get().
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.
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);
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.
4233 * The port identifier of the Ethernet device.
4235 * Unicast MAC address.
4237 * 1 - Set an unicast hash bit for receiving packets with the MAC address.
4238 * 0 - Clear an unicast hash bit.
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.
4246 int rte_eth_dev_uc_hash_table_set(uint16_t port_id, struct rte_ether_addr *addr,
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.
4255 * The port identifier of the Ethernet device.
4257 * 1 - Set all unicast hash bitmaps for receiving all the Ethernet
4259 * 0 - Clear all unicast hash bitmaps
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.
4267 int rte_eth_dev_uc_all_hash_table_set(uint16_t port_id, uint8_t on);
4270 * Set the rate limitation for a queue on an Ethernet device.
4273 * The port identifier of the Ethernet device.
4277 * The Tx rate in Mbps. Allocated from the total port link speed.
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.
4285 int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx,
4289 * Configuration of Receive Side Scaling hash computation of Ethernet device.
4292 * The port identifier of the Ethernet device.
4294 * The new configuration to use for RSS hash computation on the port.
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.
4302 int rte_eth_dev_rss_hash_update(uint16_t port_id,
4303 struct rte_eth_rss_conf *rss_conf);
4306 * Retrieve current configuration of Receive Side Scaling hash computation
4307 * of Ethernet device.
4310 * The port identifier of the Ethernet device.
4312 * Where to store the current RSS hash configuration of the Ethernet device.
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.
4321 rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
4322 struct rte_eth_rss_conf *rss_conf);
4325 * Add UDP tunneling port for a type of tunnel.
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.
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
4338 * The port identifier of the Ethernet device.
4340 * UDP tunneling configuration.
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.
4349 rte_eth_dev_udp_tunnel_port_add(uint16_t port_id,
4350 struct rte_eth_udp_tunnel *tunnel_udp);
4353 * Delete UDP tunneling port for a type of tunnel.
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.
4358 * @see rte_eth_dev_udp_tunnel_port_add
4361 * The port identifier of the Ethernet device.
4363 * UDP tunneling configuration.
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.
4372 rte_eth_dev_udp_tunnel_port_delete(uint16_t port_id,
4373 struct rte_eth_udp_tunnel *tunnel_udp);
4376 * Get DCB information on an Ethernet device.
4379 * The port identifier of the Ethernet device.
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.
4389 int rte_eth_dev_get_dcb_info(uint16_t port_id,
4390 struct rte_eth_dcb_info *dcb_info);
4392 struct rte_eth_rxtx_callback;
4395 * Add a callback to be called on packet Rx on a given port and queue.
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().
4402 * Multiple functions are called in the order that they are added.
4405 * The port identifier of the Ethernet device.
4407 * The queue on the Ethernet device on which the callback is to be added.
4409 * The callback function
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.
4417 * On success, a pointer value which can later be used to remove the callback.
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);
4424 * Add a callback that must be called first on packet Rx on a given port
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().
4432 * Multiple functions are called in the order that they are added.
4435 * The port identifier of the Ethernet device.
4437 * The queue on the Ethernet device on which the callback is to be added.
4439 * The callback function
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.
4447 * On success, a pointer value which can later be used to remove the callback.
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);
4454 * Add a callback to be called on packet Tx on a given port and queue.
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().
4461 * Multiple functions are called in the order that they are added.
4464 * The port identifier of the Ethernet device.
4466 * The queue on the Ethernet device on which the callback is to be added.
4468 * The callback function
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.
4476 * On success, a pointer value which can later be used to remove the callback.
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);
4483 * Remove an Rx packet callback from a given port and queue.
4485 * This function is used to removed callbacks that were added to a NIC port
4486 * queue using rte_eth_add_rx_callback().
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():
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
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
4502 * The port identifier of the Ethernet device.
4504 * The queue on the Ethernet device from which the callback is to be removed.
4506 * User supplied callback created via rte_eth_add_rx_callback().
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.
4515 int rte_eth_remove_rx_callback(uint16_t port_id, uint16_t queue_id,
4516 const struct rte_eth_rxtx_callback *user_cb);
4519 * Remove a Tx packet callback from a given port and queue.
4521 * This function is used to removed callbacks that were added to a NIC port
4522 * queue using rte_eth_add_tx_callback().
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():
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
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
4538 * The port identifier of the Ethernet device.
4540 * The queue on the Ethernet device from which the callback is to be removed.
4542 * User supplied callback created via rte_eth_add_tx_callback().
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.
4551 int rte_eth_remove_tx_callback(uint16_t port_id, uint16_t queue_id,
4552 const struct rte_eth_rxtx_callback *user_cb);
4555 * Retrieve information about given port's Rx queue.
4558 * The port identifier of the Ethernet device.
4560 * The Rx queue on the Ethernet device for which information
4561 * will be retrieved.
4563 * A pointer to a structure of type *rte_eth_rxq_info_info* to be filled with
4564 * the information of the Ethernet device.
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
4573 int rte_eth_rx_queue_info_get(uint16_t port_id, uint16_t queue_id,
4574 struct rte_eth_rxq_info *qinfo);
4577 * Retrieve information about given port's Tx queue.
4580 * The port identifier of the Ethernet device.
4582 * The Tx queue on the Ethernet device for which information
4583 * will be retrieved.
4585 * A pointer to a structure of type *rte_eth_txq_info_info* to be filled with
4586 * the information of the Ethernet device.
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
4595 int rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id,
4596 struct rte_eth_txq_info *qinfo);
4599 * Retrieve information about the Rx packet burst mode.
4602 * The port identifier of the Ethernet device.
4604 * The Rx queue on the Ethernet device for which information
4605 * will be retrieved.
4607 * A pointer to a structure of type *rte_eth_burst_mode* to be filled
4608 * with the information of the packet burst mode.
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.
4616 int rte_eth_rx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
4617 struct rte_eth_burst_mode *mode);
4620 * Retrieve information about the Tx packet burst mode.
4623 * The port identifier of the Ethernet device.
4625 * The Tx queue on the Ethernet device for which information
4626 * will be retrieved.
4628 * A pointer to a structure of type *rte_eth_burst_mode* to be filled
4629 * with the information of the packet burst mode.
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.
4637 int rte_eth_tx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
4638 struct rte_eth_burst_mode *mode);
4642 * @b EXPERIMENTAL: this API may change without prior notice.
4644 * Retrieve the monitor condition for a given receive queue.
4647 * The port identifier of the Ethernet device.
4649 * The Rx queue on the Ethernet device for which information
4650 * will be retrieved.
4652 * The pointer to power-optimized monitoring condition structure.
4656 * -ENOTSUP: Operation not supported.
4657 * -EINVAL: Invalid parameters.
4658 * -ENODEV: Invalid port ID.
4661 int rte_eth_get_monitor_addr(uint16_t port_id, uint16_t queue_id,
4662 struct rte_power_monitor_cond *pmc);
4665 * Retrieve device registers and register attributes (number of registers and
4669 * The port identifier of the Ethernet device.
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.
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.
4682 int rte_eth_dev_get_reg_info(uint16_t port_id, struct rte_dev_reg_info *info);
4685 * Retrieve size of device EEPROM
4688 * The port identifier of the Ethernet device.
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.
4696 int rte_eth_dev_get_eeprom_length(uint16_t port_id);
4699 * Retrieve EEPROM and EEPROM attribute
4702 * The port identifier of the Ethernet device.
4704 * The template includes buffer for return EEPROM data and
4705 * EEPROM attributes to be filled.
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.
4714 int rte_eth_dev_get_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
4717 * Program EEPROM with provided data
4720 * The port identifier of the Ethernet device.
4722 * The template includes EEPROM data for programming and
4723 * EEPROM attributes to be filled
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.
4732 int rte_eth_dev_set_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
4736 * @b EXPERIMENTAL: this API may change without prior notice.
4738 * Retrieve the type and size of plugin module EEPROM
4741 * The port identifier of the Ethernet device.
4743 * The type and size of plugin module EEPROM.
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.
4754 rte_eth_dev_get_module_info(uint16_t port_id,
4755 struct rte_eth_dev_module_info *modinfo);
4759 * @b EXPERIMENTAL: this API may change without prior notice.
4761 * Retrieve the data of plugin module EEPROM
4764 * The port identifier of the Ethernet device.
4766 * The template includes the plugin module EEPROM attributes, and the
4767 * buffer for return plugin module EEPROM data.
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.
4778 rte_eth_dev_get_module_eeprom(uint16_t port_id,
4779 struct rte_dev_eeprom_info *info);
4782 * Set the list of multicast addresses to filter on an Ethernet device.
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.
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.
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.
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);
4805 * Enable IEEE1588/802.1AS timestamping for an Ethernet device.
4808 * The port identifier of the Ethernet device.
4812 * - -ENODEV: The port ID is invalid.
4813 * - -EIO: if device is removed.
4814 * - -ENOTSUP: The function is not supported by the Ethernet driver.
4816 int rte_eth_timesync_enable(uint16_t port_id);
4819 * Disable IEEE1588/802.1AS timestamping for an Ethernet device.
4822 * The port identifier of the Ethernet device.
4826 * - -ENODEV: The port ID is invalid.
4827 * - -EIO: if device is removed.
4828 * - -ENOTSUP: The function is not supported by the Ethernet driver.
4830 int rte_eth_timesync_disable(uint16_t port_id);
4833 * Read an IEEE1588/802.1AS Rx timestamp from an Ethernet device.
4836 * The port identifier of the Ethernet device.
4838 * Pointer to the timestamp struct.
4840 * Device specific flags. Used to pass the Rx timesync register index to
4841 * i40e. Unused in igb/ixgbe, pass 0 instead.
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.
4850 int rte_eth_timesync_read_rx_timestamp(uint16_t port_id,
4851 struct timespec *timestamp, uint32_t flags);
4854 * Read an IEEE1588/802.1AS Tx timestamp from an Ethernet device.
4857 * The port identifier of the Ethernet device.
4859 * Pointer to the timestamp struct.
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.
4868 int rte_eth_timesync_read_tx_timestamp(uint16_t port_id,
4869 struct timespec *timestamp);
4872 * Adjust the timesync clock on an Ethernet device.
4874 * This is usually used in conjunction with other Ethdev timesync functions to
4875 * synchronize the device time using the IEEE1588/802.1AS protocol.
4878 * The port identifier of the Ethernet device.
4880 * The adjustment in nanoseconds.
4884 * - -ENODEV: The port ID is invalid.
4885 * - -EIO: if device is removed.
4886 * - -ENOTSUP: The function is not supported by the Ethernet driver.
4888 int rte_eth_timesync_adjust_time(uint16_t port_id, int64_t delta);
4891 * Read the time from the timesync clock on an Ethernet device.
4893 * This is usually used in conjunction with other Ethdev timesync functions to
4894 * synchronize the device time using the IEEE1588/802.1AS protocol.
4897 * The port identifier of the Ethernet device.
4899 * Pointer to the timespec struct that holds the time.
4903 * - -EINVAL: Bad parameter.
4905 int rte_eth_timesync_read_time(uint16_t port_id, struct timespec *time);
4908 * Set the time of the timesync clock on an Ethernet device.
4910 * This is usually used in conjunction with other Ethdev timesync functions to
4911 * synchronize the device time using the IEEE1588/802.1AS protocol.
4914 * The port identifier of the Ethernet device.
4916 * Pointer to the timespec struct that holds the time.
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.
4925 int rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *time);
4929 * @b EXPERIMENTAL: this API may change without prior notice.
4931 * Read the current clock counter of an Ethernet device
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.
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;
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);
4952 * Then, convert the raw mbuf timestamp with:
4953 * base_time_sec + (double)(*timestamp_dynfield(mbuf) - base_clock) / freq;
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.
4962 * The port identifier of the Ethernet device.
4964 * Pointer to the uint64_t that holds the raw clock value.
4968 * - -ENODEV: The port ID is invalid.
4969 * - -ENOTSUP: The function is not supported by the Ethernet driver.
4970 * - -EINVAL: if bad parameter.
4974 rte_eth_read_clock(uint16_t port_id, uint64_t *clock);
4977 * Get the port ID from device name. The device name should be specified
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]
4984 * pci address or name of the device
4986 * pointer to port identifier of the device
4988 * - (0) if successful and port_id is filled.
4989 * - (-ENODEV or -EINVAL) on failure.
4992 rte_eth_dev_get_port_by_name(const char *name, uint16_t *port_id);
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]
5001 * Port identifier of the device.
5003 * Buffer of size RTE_ETH_NAME_MAX_LEN to store the name.
5005 * - (0) if successful.
5006 * - (-ENODEV) if *port_id* is invalid.
5007 * - (-EINVAL) on failure.
5010 rte_eth_dev_get_name_by_port(uint16_t port_id, char *name);
5013 * Check that numbers of Rx and Tx descriptors satisfy descriptors limits from
5014 * the Ethernet device information, otherwise adjust them to boundaries.
5017 * The port identifier of the Ethernet device.
5019 * A pointer to a uint16_t where the number of receive
5020 * descriptors stored.
5022 * A pointer to a uint16_t where the number of transmit
5023 * descriptors stored.
5025 * - (0) if successful.
5026 * - (-ENOTSUP, -ENODEV or -EINVAL) on failure.
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);
5033 * Test if a port supports specific mempool ops.
5036 * Port identifier of the Ethernet device.
5038 * The name of the pool operations to test.
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.
5047 rte_eth_dev_pool_ops_supported(uint16_t port_id, const char *pool);
5050 * Get the security context for the Ethernet device.
5053 * Port identifier of the Ethernet device
5056 * - pointer to security context on success.
5059 rte_eth_dev_get_sec_ctx(uint16_t port_id);
5063 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
5065 * Query the device hairpin capabilities.
5068 * The port identifier of the Ethernet device.
5070 * Pointer to a structure that will hold the hairpin capabilities.
5072 * - (0) if successful.
5073 * - (-ENOTSUP) if hardware doesn't support.
5074 * - (-EINVAL) if bad parameter.
5077 int rte_eth_dev_hairpin_capability_get(uint16_t port_id,
5078 struct rte_eth_hairpin_cap *cap);
5082 * @b EXPERIMENTAL: this structure may change without prior notice.
5084 * Ethernet device representor ID range entry
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 */
5092 int vf; /**< VF start index */
5093 int sf; /**< SF start index */
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 */
5102 * @b EXPERIMENTAL: this structure may change without prior notice.
5104 * Ethernet device representor information
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. */
5115 * Retrieve the representor info of the device.
5117 * Get device representor info to be able to calculate a unique
5118 * representor ID. @see rte_eth_representor_id_get helper.
5121 * The port identifier of the device.
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.
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.
5138 int rte_eth_representor_info_get(uint16_t port_id,
5139 struct rte_eth_representor_info *info);
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)
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)
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)
5152 * @b EXPERIMENTAL: this API may change without prior notice
5154 * Negotiate the NIC's ability to deliver specific kinds of metadata to the PMD.
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.
5159 * The negotiation process is as follows:
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.
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.
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.
5179 * Port (ethdev) identifier
5181 * @param[inout] features
5182 * Feature selection buffer
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;
5193 int rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features);
5195 #include <rte_ethdev_core.h>
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.
5204 * The port identifier of the Ethernet device.
5206 * The index of the receive queue from which to retrieve input packets.
5208 * The address of an array of pointers to *rte_mbuf* structures that
5209 * have been retrieved from the device.
5211 * The number of packets that were retrieved from the device.
5213 * The number of elements in @p rx_pkts array.
5215 * Opaque pointer of Rx queue callback related data.
5218 * The number of packets effectively supplied to the @p rx_pkts array.
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,
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.
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:
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.
5238 * - Store the *rte_mbuf* data structure into the next entry of the
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.
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
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.
5260 * This receive method has the following advantages:
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.
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.
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.
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.
5286 * Some drivers using vector instructions require that *nb_pkts* is
5287 * divisible by 4 or 8, depending on the driver implementation.
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.
5295 * The port identifier of the Ethernet device.
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().
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.
5304 * The maximum number of packets to retrieve.
5305 * The value must be divisible by 8 in order to work with any driver.
5307 * The number of packets actually retrieved, which is the number
5308 * of pointers to *rte_mbuf* structures effectively supplied to the
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)
5316 struct rte_eth_fp_ops *p;
5319 #ifdef RTE_ETHDEV_DEBUG_RX
5320 if (port_id >= RTE_MAX_ETHPORTS ||
5321 queue_id >= RTE_MAX_QUEUES_PER_PORT) {
5323 "Invalid port_id=%u or queue_id=%u\n",
5329 /* fetch pointer to queue data */
5330 p = &rte_eth_fp_ops[port_id];
5331 qd = p->rxq.data[queue_id];
5333 #ifdef RTE_ETHDEV_DEBUG_RX
5334 RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
5337 RTE_ETHDEV_LOG(ERR, "Invalid Rx queue_id=%u for port_id=%u\n",
5343 nb_rx = p->rx_pkt_burst(qd, rx_pkts, nb_pkts);
5345 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
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
5355 cb = __atomic_load_n((void **)&p->rxq.clbk[queue_id],
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);
5363 rte_ethdev_trace_rx_burst(port_id, queue_id, (void **)rx_pkts, nb_rx);
5368 * Get the number of used descriptors of a Rx queue
5371 * The port identifier of the Ethernet device.
5373 * The queue ID on the specific port.
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
5381 rte_eth_rx_queue_count(uint16_t port_id, uint16_t queue_id)
5383 struct rte_eth_fp_ops *p;
5386 if (port_id >= RTE_MAX_ETHPORTS ||
5387 queue_id >= RTE_MAX_QUEUES_PER_PORT) {
5389 "Invalid port_id=%u or queue_id=%u\n",
5394 /* fetch pointer to queue data */
5395 p = &rte_eth_fp_ops[port_id];
5396 qd = p->rxq.data[queue_id];
5398 RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
5399 RTE_FUNC_PTR_OR_ERR_RET(*p->rx_queue_count, -ENOTSUP);
5403 return (int)(*p->rx_queue_count)(qd);
5406 /**@{@name Rx hardware descriptor states
5407 * @see rte_eth_rx_descriptor_status
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. */
5415 * Check the status of a Rx descriptor in the queue
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
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.
5425 * Note: accessing to a random descriptor in the ring may trigger cache
5426 * misses and have a performance impact.
5429 * A valid port identifier of the Ethernet device which.
5431 * A valid Rx queue identifier on this port.
5433 * The offset of the descriptor starting from tail (0 is the next
5434 * packet to be received by the driver).
5437 * - (RTE_ETH_RX_DESC_AVAIL): Descriptor is available for the hardware to
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).
5448 rte_eth_rx_descriptor_status(uint16_t port_id, uint16_t queue_id,
5451 struct rte_eth_fp_ops *p;
5454 #ifdef RTE_ETHDEV_DEBUG_RX
5455 if (port_id >= RTE_MAX_ETHPORTS ||
5456 queue_id >= RTE_MAX_QUEUES_PER_PORT) {
5458 "Invalid port_id=%u or queue_id=%u\n",
5464 /* fetch pointer to queue data */
5465 p = &rte_eth_fp_ops[port_id];
5466 qd = p->rxq.data[queue_id];
5468 #ifdef RTE_ETHDEV_DEBUG_RX
5469 RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
5473 RTE_FUNC_PTR_OR_ERR_RET(*p->rx_descriptor_status, -ENOTSUP);
5474 return (*p->rx_descriptor_status)(qd, offset);
5477 /**@{@name Tx hardware descriptor states
5478 * @see rte_eth_tx_descriptor_status
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. */
5486 * Check the status of a Tx descriptor in the queue.
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
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.
5496 * Note: accessing to a random descriptor in the ring may trigger cache
5497 * misses and have a performance impact.
5500 * A valid port identifier of the Ethernet device which.
5502 * A valid Tx queue identifier on this port.
5504 * The offset of the descriptor starting from tail (0 is the place where
5505 * the next packet will be send).
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).
5518 static inline int rte_eth_tx_descriptor_status(uint16_t port_id,
5519 uint16_t queue_id, uint16_t offset)
5521 struct rte_eth_fp_ops *p;
5524 #ifdef RTE_ETHDEV_DEBUG_TX
5525 if (port_id >= RTE_MAX_ETHPORTS ||
5526 queue_id >= RTE_MAX_QUEUES_PER_PORT) {
5528 "Invalid port_id=%u or queue_id=%u\n",
5534 /* fetch pointer to queue data */
5535 p = &rte_eth_fp_ops[port_id];
5536 qd = p->txq.data[queue_id];
5538 #ifdef RTE_ETHDEV_DEBUG_TX
5539 RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
5543 RTE_FUNC_PTR_OR_ERR_RET(*p->tx_descriptor_status, -ENOTSUP);
5544 return (*p->tx_descriptor_status)(qd, offset);
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.
5554 * The port identifier of the Ethernet device.
5556 * The index of the transmit queue through which output packets must be
5559 * The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
5560 * which contain the output packets.
5562 * The maximum number of packets to transmit.
5564 * The number of output packets to transmit.
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);
5570 * Send a burst of output packets on a transmit queue of an Ethernet device.
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
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
5581 * For each packet to send, the rte_eth_tx_burst() function performs
5582 * the following operations:
5584 * - Pick up the next available descriptor in the transmit ring.
5586 * - Free the network buffer previously sent with that descriptor, if any.
5588 * - Initialize the transmit descriptor with the information provided
5589 * in the *rte_mbuf data structure.
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
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.
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.
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
5615 * @see rte_eth_tx_prepare to perform some prior checks or adjustments
5619 * The port identifier of the Ethernet device.
5621 * The index of the transmit queue through which output packets must be
5623 * The value must be in the range [0, nb_tx_queue - 1] previously supplied
5624 * to rte_eth_dev_configure().
5626 * The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
5627 * which contain the output packets.
5629 * The maximum number of packets to transmit.
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.
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)
5639 struct rte_eth_fp_ops *p;
5642 #ifdef RTE_ETHDEV_DEBUG_TX
5643 if (port_id >= RTE_MAX_ETHPORTS ||
5644 queue_id >= RTE_MAX_QUEUES_PER_PORT) {
5646 "Invalid port_id=%u or queue_id=%u\n",
5652 /* fetch pointer to queue data */
5653 p = &rte_eth_fp_ops[port_id];
5654 qd = p->txq.data[queue_id];
5656 #ifdef RTE_ETHDEV_DEBUG_TX
5657 RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
5660 RTE_ETHDEV_LOG(ERR, "Invalid Tx queue_id=%u for port_id=%u\n",
5666 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
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
5676 cb = __atomic_load_n((void **)&p->txq.clbk[queue_id],
5678 if (unlikely(cb != NULL))
5679 nb_pkts = rte_eth_call_tx_callbacks(port_id, queue_id,
5680 tx_pkts, nb_pkts, cb);
5684 nb_pkts = p->tx_pkt_burst(qd, tx_pkts, nb_pkts);
5686 rte_ethdev_trace_tx_burst(port_id, queue_id, (void **)tx_pkts, nb_pkts);
5691 * Process a burst of output packets on a transmit queue of an Ethernet device.
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
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:
5702 * - Check if packet meets devices requirements for Tx offloads.
5704 * - Check limitations about number of segments.
5706 * - Check additional requirements when debug is enabled.
5708 * - Update and/or reset required checksums when Tx offload is set for packet.
5710 * Since this function can modify packet data, provided mbufs must be safely
5711 * writable (e.g. modified data cannot be in shared segment).
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.
5718 * When this functionality is not implemented in the driver, all packets are
5719 * are returned untouched.
5722 * The port identifier of the Ethernet device.
5723 * The value must be a valid port ID.
5725 * The index of the transmit queue through which output packets must be
5727 * The value must be in the range [0, nb_tx_queue - 1] previously supplied
5728 * to rte_eth_dev_configure().
5730 * The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
5731 * which contain the output packets.
5733 * The maximum number of packets to process.
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)
5744 #ifndef RTE_ETHDEV_TX_PREPARE_NOOP
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)
5750 struct rte_eth_fp_ops *p;
5753 #ifdef RTE_ETHDEV_DEBUG_TX
5754 if (port_id >= RTE_MAX_ETHPORTS ||
5755 queue_id >= RTE_MAX_QUEUES_PER_PORT) {
5757 "Invalid port_id=%u or queue_id=%u\n",
5764 /* fetch pointer to queue data */
5765 p = &rte_eth_fp_ops[port_id];
5766 qd = p->txq.data[queue_id];
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);
5775 RTE_ETHDEV_LOG(ERR, "Invalid Tx queue_id=%u for port_id=%u\n",
5782 if (!p->tx_pkt_prepare)
5785 return p->tx_pkt_prepare(qd, tx_pkts, nb_pkts);
5791 * Native NOOP operation for compilation targets which doesn't require any
5792 * preparations steps, and functional NOOP may introduce unnecessary performance
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.
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)
5810 * Send any packets queued up for transmission on a port and HW queue
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.
5819 * The port identifier of the Ethernet device.
5821 * The index of the transmit queue through which output packets must be
5823 * The value must be in the range [0, nb_tx_queue - 1] previously supplied
5824 * to rte_eth_dev_configure().
5826 * Buffer of packets to be transmit.
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.
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)
5836 uint16_t to_send = buffer->length;
5841 sent = rte_eth_tx_burst(port_id, queue_id, buffer->pkts, to_send);
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);
5855 * Buffer a single packet for future transmission on a port and queue
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
5868 * The port identifier of the Ethernet device.
5870 * The index of the transmit queue through which output packets must be
5872 * The value must be in the range [0, nb_tx_queue - 1] previously supplied
5873 * to rte_eth_dev_configure().
5875 * Buffer used to collect packets to be sent.
5877 * Pointer to the packet mbuf to be sent.
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
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)
5888 buffer->pkts[buffer->length++] = tx_pkt;
5889 if (buffer->length < buffer->size)
5892 return rte_eth_tx_buffer_flush(port_id, queue_id, buffer);
5899 #endif /* _RTE_ETHDEV_H_ */