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);
2398 * Check if an Ethernet device was physically removed.
2401 * The port identifier of the Ethernet device.
2403 * 1 when the Ethernet device is removed, otherwise 0.
2406 rte_eth_dev_is_removed(uint16_t port_id);
2409 * Allocate and set up a receive queue for an Ethernet device.
2411 * The function allocates a contiguous block of memory for *nb_rx_desc*
2412 * receive descriptors from a memory zone associated with *socket_id*
2413 * and initializes each receive descriptor with a network buffer allocated
2414 * from the memory pool *mb_pool*.
2417 * The port identifier of the Ethernet device.
2418 * @param rx_queue_id
2419 * The index of the receive queue to set up.
2420 * The value must be in the range [0, nb_rx_queue - 1] previously supplied
2421 * to rte_eth_dev_configure().
2423 * The number of receive descriptors to allocate for the receive ring.
2425 * The *socket_id* argument is the socket identifier in case of NUMA.
2426 * The value can be *SOCKET_ID_ANY* if there is no NUMA constraint for
2427 * the DMA memory allocated for the receive descriptors of the ring.
2429 * The pointer to the configuration data to be used for the receive queue.
2430 * NULL value is allowed, in which case default Rx configuration
2432 * The *rx_conf* structure contains an *rx_thresh* structure with the values
2433 * of the Prefetch, Host, and Write-Back threshold registers of the receive
2435 * In addition it contains the hardware offloads features to activate using
2436 * the RTE_ETH_RX_OFFLOAD_* flags.
2437 * If an offloading set in rx_conf->offloads
2438 * hasn't been set in the input argument eth_conf->rxmode.offloads
2439 * to rte_eth_dev_configure(), it is a new added offloading, it must be
2440 * per-queue type and it is enabled for the queue.
2441 * No need to repeat any bit in rx_conf->offloads which has already been
2442 * enabled in rte_eth_dev_configure() at port level. An offloading enabled
2443 * at port level can't be disabled at queue level.
2444 * The configuration structure also contains the pointer to the array
2445 * of the receiving buffer segment descriptions, see rx_seg and rx_nseg
2446 * fields, this extended configuration might be used by split offloads like
2447 * RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT. If mb_pool is not NULL,
2448 * the extended configuration fields must be set to NULL and zero.
2450 * The pointer to the memory pool from which to allocate *rte_mbuf* network
2451 * memory buffers to populate each descriptor of the receive ring. There are
2452 * two options to provide Rx buffer configuration:
2454 * mb_pool is not NULL, rx_conf.rx_nseg is 0.
2455 * - multiple segments description:
2456 * mb_pool is NULL, rx_conf.rx_seg is not NULL, rx_conf.rx_nseg is not 0.
2457 * Taken only if flag RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is set in offloads.
2460 * - 0: Success, receive queue correctly set up.
2461 * - -EIO: if device is removed.
2462 * - -ENODEV: if *port_id* is invalid.
2463 * - -EINVAL: The memory pool pointer is null or the size of network buffers
2464 * which can be allocated from this memory pool does not fit the various
2465 * buffer sizes allowed by the device controller.
2466 * - -ENOMEM: Unable to allocate the receive ring descriptors or to
2467 * allocate network memory buffers from the memory pool when
2468 * initializing receive descriptors.
2470 int rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
2471 uint16_t nb_rx_desc, unsigned int socket_id,
2472 const struct rte_eth_rxconf *rx_conf,
2473 struct rte_mempool *mb_pool);
2477 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
2479 * Allocate and set up a hairpin receive queue for an Ethernet device.
2481 * The function set up the selected queue to be used in hairpin.
2484 * The port identifier of the Ethernet device.
2485 * @param rx_queue_id
2486 * The index of the receive queue to set up.
2487 * The value must be in the range [0, nb_rx_queue - 1] previously supplied
2488 * to rte_eth_dev_configure().
2490 * The number of receive descriptors to allocate for the receive ring.
2491 * 0 means the PMD will use default value.
2493 * The pointer to the hairpin configuration.
2496 * - (0) if successful.
2497 * - (-ENODEV) if *port_id* is invalid.
2498 * - (-ENOTSUP) if hardware doesn't support.
2499 * - (-EINVAL) if bad parameter.
2500 * - (-ENOMEM) if unable to allocate the resources.
2503 int rte_eth_rx_hairpin_queue_setup
2504 (uint16_t port_id, uint16_t rx_queue_id, uint16_t nb_rx_desc,
2505 const struct rte_eth_hairpin_conf *conf);
2508 * Allocate and set up a transmit queue for an Ethernet device.
2511 * The port identifier of the Ethernet device.
2512 * @param tx_queue_id
2513 * The index of the transmit queue to set up.
2514 * The value must be in the range [0, nb_tx_queue - 1] previously supplied
2515 * to rte_eth_dev_configure().
2517 * The number of transmit descriptors to allocate for the transmit ring.
2519 * The *socket_id* argument is the socket identifier in case of NUMA.
2520 * Its value can be *SOCKET_ID_ANY* if there is no NUMA constraint for
2521 * the DMA memory allocated for the transmit descriptors of the ring.
2523 * The pointer to the configuration data to be used for the transmit queue.
2524 * NULL value is allowed, in which case default Tx configuration
2526 * The *tx_conf* structure contains the following data:
2527 * - The *tx_thresh* structure with the values of the Prefetch, Host, and
2528 * Write-Back threshold registers of the transmit ring.
2529 * When setting Write-Back threshold to the value greater then zero,
2530 * *tx_rs_thresh* value should be explicitly set to one.
2531 * - The *tx_free_thresh* value indicates the [minimum] number of network
2532 * buffers that must be pending in the transmit ring to trigger their
2533 * [implicit] freeing by the driver transmit function.
2534 * - The *tx_rs_thresh* value indicates the [minimum] number of transmit
2535 * descriptors that must be pending in the transmit ring before setting the
2536 * RS bit on a descriptor by the driver transmit function.
2537 * The *tx_rs_thresh* value should be less or equal then
2538 * *tx_free_thresh* value, and both of them should be less then
2540 * - The *offloads* member contains Tx offloads to be enabled.
2541 * If an offloading set in tx_conf->offloads
2542 * hasn't been set in the input argument eth_conf->txmode.offloads
2543 * to rte_eth_dev_configure(), it is a new added offloading, it must be
2544 * per-queue type and it is enabled for the queue.
2545 * No need to repeat any bit in tx_conf->offloads which has already been
2546 * enabled in rte_eth_dev_configure() at port level. An offloading enabled
2547 * at port level can't be disabled at queue level.
2549 * Note that setting *tx_free_thresh* or *tx_rs_thresh* value to 0 forces
2550 * the transmit function to use default values.
2552 * - 0: Success, the transmit queue is correctly set up.
2553 * - -ENOMEM: Unable to allocate the transmit ring descriptors.
2555 int rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
2556 uint16_t nb_tx_desc, unsigned int socket_id,
2557 const struct rte_eth_txconf *tx_conf);
2561 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
2563 * Allocate and set up a transmit hairpin queue for an Ethernet device.
2566 * The port identifier of the Ethernet device.
2567 * @param tx_queue_id
2568 * The index of the transmit queue to set up.
2569 * The value must be in the range [0, nb_tx_queue - 1] previously supplied
2570 * to rte_eth_dev_configure().
2572 * The number of transmit descriptors to allocate for the transmit ring.
2573 * 0 to set default PMD value.
2575 * The hairpin configuration.
2578 * - (0) if successful.
2579 * - (-ENODEV) if *port_id* is invalid.
2580 * - (-ENOTSUP) if hardware doesn't support.
2581 * - (-EINVAL) if bad parameter.
2582 * - (-ENOMEM) if unable to allocate the resources.
2585 int rte_eth_tx_hairpin_queue_setup
2586 (uint16_t port_id, uint16_t tx_queue_id, uint16_t nb_tx_desc,
2587 const struct rte_eth_hairpin_conf *conf);
2591 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
2593 * Get all the hairpin peer Rx / Tx ports of the current port.
2594 * The caller should ensure that the array is large enough to save the ports
2598 * The port identifier of the Ethernet device.
2600 * Pointer to the array to store the peer ports list.
2602 * Length of the array to store the port identifiers.
2604 * Current port to peer port direction
2605 * positive - current used as Tx to get all peer Rx ports.
2606 * zero - current used as Rx to get all peer Tx ports.
2609 * - (0 or positive) actual peer ports number.
2610 * - (-EINVAL) if bad parameter.
2611 * - (-ENODEV) if *port_id* invalid
2612 * - (-ENOTSUP) if hardware doesn't support.
2613 * - Others detailed errors from PMD drivers.
2616 int rte_eth_hairpin_get_peer_ports(uint16_t port_id, uint16_t *peer_ports,
2617 size_t len, uint32_t direction);
2621 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
2623 * Bind all hairpin Tx queues of one port to the Rx queues of the peer port.
2624 * It is only allowed to call this function after all hairpin queues are
2625 * configured properly and the devices are in started state.
2628 * The identifier of the Tx port.
2630 * The identifier of peer Rx port.
2631 * RTE_MAX_ETHPORTS is allowed for the traversal of all devices.
2632 * Rx port ID could have the same value as Tx port ID.
2635 * - (0) if successful.
2636 * - (-ENODEV) if Tx port ID is invalid.
2637 * - (-EBUSY) if device is not in started state.
2638 * - (-ENOTSUP) if hardware doesn't support.
2639 * - Others detailed errors from PMD drivers.
2642 int rte_eth_hairpin_bind(uint16_t tx_port, uint16_t rx_port);
2646 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
2648 * Unbind all hairpin Tx queues of one port from the Rx queues of the peer port.
2649 * This should be called before closing the Tx or Rx devices, if the bind
2650 * function is called before.
2651 * After unbinding the hairpin ports pair, it is allowed to bind them again.
2652 * Changing queues configuration should be after stopping the device(s).
2655 * The identifier of the Tx port.
2657 * The identifier of peer Rx port.
2658 * RTE_MAX_ETHPORTS is allowed for traversal of all devices.
2659 * Rx port ID could have the same value as Tx port ID.
2662 * - (0) if successful.
2663 * - (-ENODEV) if Tx port ID is invalid.
2664 * - (-EBUSY) if device is in stopped state.
2665 * - (-ENOTSUP) if hardware doesn't support.
2666 * - Others detailed errors from PMD drivers.
2669 int rte_eth_hairpin_unbind(uint16_t tx_port, uint16_t rx_port);
2672 * Return the NUMA socket to which an Ethernet device is connected
2675 * The port identifier of the Ethernet device
2677 * The NUMA socket ID to which the Ethernet device is connected or
2678 * a default of zero if the socket could not be determined.
2679 * -1 is returned is the port_id value is out of range.
2681 int rte_eth_dev_socket_id(uint16_t port_id);
2684 * Check if port_id of device is attached
2687 * The port identifier of the Ethernet device
2689 * - 0 if port is out of range or not attached
2690 * - 1 if device is attached
2692 int rte_eth_dev_is_valid_port(uint16_t port_id);
2695 * Start specified Rx queue of a port. It is used when rx_deferred_start
2696 * flag of the specified queue is true.
2699 * The port identifier of the Ethernet device
2700 * @param rx_queue_id
2701 * The index of the Rx queue to update the ring.
2702 * The value must be in the range [0, nb_rx_queue - 1] previously supplied
2703 * to rte_eth_dev_configure().
2705 * - 0: Success, the receive queue is started.
2706 * - -ENODEV: if *port_id* is invalid.
2707 * - -EINVAL: The queue_id out of range or belong to hairpin.
2708 * - -EIO: if device is removed.
2709 * - -ENOTSUP: The function not supported in PMD driver.
2711 int rte_eth_dev_rx_queue_start(uint16_t port_id, uint16_t rx_queue_id);
2714 * Stop specified Rx queue of a port
2717 * The port identifier of the Ethernet device
2718 * @param rx_queue_id
2719 * The index of the Rx queue to update the ring.
2720 * The value must be in the range [0, nb_rx_queue - 1] previously supplied
2721 * to rte_eth_dev_configure().
2723 * - 0: Success, the receive queue is stopped.
2724 * - -ENODEV: if *port_id* is invalid.
2725 * - -EINVAL: The queue_id out of range or belong to hairpin.
2726 * - -EIO: if device is removed.
2727 * - -ENOTSUP: The function not supported in PMD driver.
2729 int rte_eth_dev_rx_queue_stop(uint16_t port_id, uint16_t rx_queue_id);
2732 * Start Tx for specified queue of a port. It is used when tx_deferred_start
2733 * flag of the specified queue is true.
2736 * The port identifier of the Ethernet device
2737 * @param tx_queue_id
2738 * The index of the Tx queue to update the ring.
2739 * The value must be in the range [0, nb_tx_queue - 1] previously supplied
2740 * to rte_eth_dev_configure().
2742 * - 0: Success, the transmit queue is started.
2743 * - -ENODEV: if *port_id* is invalid.
2744 * - -EINVAL: The queue_id out of range or belong to hairpin.
2745 * - -EIO: if device is removed.
2746 * - -ENOTSUP: The function not supported in PMD driver.
2748 int rte_eth_dev_tx_queue_start(uint16_t port_id, uint16_t tx_queue_id);
2751 * Stop specified Tx queue of a port
2754 * The port identifier of the Ethernet device
2755 * @param tx_queue_id
2756 * The index of the Tx queue to update the ring.
2757 * The value must be in the range [0, nb_tx_queue - 1] previously supplied
2758 * to rte_eth_dev_configure().
2760 * - 0: Success, the transmit queue is stopped.
2761 * - -ENODEV: if *port_id* is invalid.
2762 * - -EINVAL: The queue_id out of range or belong to hairpin.
2763 * - -EIO: if device is removed.
2764 * - -ENOTSUP: The function not supported in PMD driver.
2766 int rte_eth_dev_tx_queue_stop(uint16_t port_id, uint16_t tx_queue_id);
2769 * Start an Ethernet device.
2771 * The device start step is the last one and consists of setting the configured
2772 * offload features and in starting the transmit and the receive units of the
2775 * Device RTE_ETH_DEV_NOLIVE_MAC_ADDR flag causes MAC address to be set before
2776 * PMD port start callback function is invoked.
2778 * On success, all basic functions exported by the Ethernet API (link status,
2779 * receive/transmit, and so on) can be invoked.
2782 * The port identifier of the Ethernet device.
2784 * - 0: Success, Ethernet device started.
2785 * - <0: Error code of the driver device start function.
2787 int rte_eth_dev_start(uint16_t port_id);
2790 * Stop an Ethernet device. The device can be restarted with a call to
2791 * rte_eth_dev_start()
2794 * The port identifier of the Ethernet device.
2796 * - 0: Success, Ethernet device stopped.
2797 * - <0: Error code of the driver device stop function.
2799 int rte_eth_dev_stop(uint16_t port_id);
2802 * Link up an Ethernet device.
2804 * Set device link up will re-enable the device Rx/Tx
2805 * functionality after it is previously set device linked down.
2808 * The port identifier of the Ethernet device.
2810 * - 0: Success, Ethernet device linked up.
2811 * - <0: Error code of the driver device link up function.
2813 int rte_eth_dev_set_link_up(uint16_t port_id);
2816 * Link down an Ethernet device.
2817 * The device Rx/Tx functionality will be disabled if success,
2818 * and it can be re-enabled with a call to
2819 * rte_eth_dev_set_link_up()
2822 * The port identifier of the Ethernet device.
2824 int rte_eth_dev_set_link_down(uint16_t port_id);
2827 * Close a stopped Ethernet device. The device cannot be restarted!
2828 * The function frees all port resources.
2831 * The port identifier of the Ethernet device.
2833 * - Zero if the port is closed successfully.
2834 * - Negative if something went wrong.
2836 int rte_eth_dev_close(uint16_t port_id);
2839 * Reset a Ethernet device and keep its port ID.
2841 * When a port has to be reset passively, the DPDK application can invoke
2842 * this function. For example when a PF is reset, all its VFs should also
2843 * be reset. Normally a DPDK application can invoke this function when
2844 * RTE_ETH_EVENT_INTR_RESET event is detected, but can also use it to start
2845 * a port reset in other circumstances.
2847 * When this function is called, it first stops the port and then calls the
2848 * PMD specific dev_uninit( ) and dev_init( ) to return the port to initial
2849 * state, in which no Tx and Rx queues are setup, as if the port has been
2850 * reset and not started. The port keeps the port ID it had before the
2853 * After calling rte_eth_dev_reset( ), the application should use
2854 * rte_eth_dev_configure( ), rte_eth_rx_queue_setup( ),
2855 * rte_eth_tx_queue_setup( ), and rte_eth_dev_start( )
2856 * to reconfigure the device as appropriate.
2858 * Note: To avoid unexpected behavior, the application should stop calling
2859 * Tx and Rx functions before calling rte_eth_dev_reset( ). For thread
2860 * safety, all these controlling functions should be called from the same
2864 * The port identifier of the Ethernet device.
2867 * - (0) if successful.
2868 * - (-ENODEV) if *port_id* is invalid.
2869 * - (-ENOTSUP) if hardware doesn't support this function.
2870 * - (-EPERM) if not ran from the primary process.
2871 * - (-EIO) if re-initialisation failed or device is removed.
2872 * - (-ENOMEM) if the reset failed due to OOM.
2873 * - (-EAGAIN) if the reset temporarily failed and should be retried later.
2875 int rte_eth_dev_reset(uint16_t port_id);
2878 * Enable receipt in promiscuous mode for an Ethernet device.
2881 * The port identifier of the Ethernet device.
2883 * - (0) if successful.
2884 * - (-ENOTSUP) if support for promiscuous_enable() does not exist
2886 * - (-ENODEV) if *port_id* invalid.
2888 int rte_eth_promiscuous_enable(uint16_t port_id);
2891 * Disable receipt in promiscuous mode for an Ethernet device.
2894 * The port identifier of the Ethernet device.
2896 * - (0) if successful.
2897 * - (-ENOTSUP) if support for promiscuous_disable() does not exist
2899 * - (-ENODEV) if *port_id* invalid.
2901 int rte_eth_promiscuous_disable(uint16_t port_id);
2904 * Return the value of promiscuous mode for an Ethernet device.
2907 * The port identifier of the Ethernet device.
2909 * - (1) if promiscuous is enabled
2910 * - (0) if promiscuous is disabled.
2913 int rte_eth_promiscuous_get(uint16_t port_id);
2916 * Enable the receipt of any multicast frame by an Ethernet device.
2919 * The port identifier of the Ethernet device.
2921 * - (0) if successful.
2922 * - (-ENOTSUP) if support for allmulticast_enable() does not exist
2924 * - (-ENODEV) if *port_id* invalid.
2926 int rte_eth_allmulticast_enable(uint16_t port_id);
2929 * Disable the receipt of all multicast frames by an Ethernet device.
2932 * The port identifier of the Ethernet device.
2934 * - (0) if successful.
2935 * - (-ENOTSUP) if support for allmulticast_disable() does not exist
2937 * - (-ENODEV) if *port_id* invalid.
2939 int rte_eth_allmulticast_disable(uint16_t port_id);
2942 * Return the value of allmulticast mode for an Ethernet device.
2945 * The port identifier of the Ethernet device.
2947 * - (1) if allmulticast is enabled
2948 * - (0) if allmulticast is disabled.
2951 int rte_eth_allmulticast_get(uint16_t port_id);
2954 * Retrieve the link status (up/down), the duplex mode (half/full),
2955 * the negotiation (auto/fixed), and if available, the speed (Mbps).
2957 * It might need to wait up to 9 seconds.
2958 * @see rte_eth_link_get_nowait.
2961 * The port identifier of the Ethernet device.
2963 * Link information written back.
2965 * - (0) if successful.
2966 * - (-ENOTSUP) if the function is not supported in PMD driver.
2967 * - (-ENODEV) if *port_id* invalid.
2968 * - (-EINVAL) if bad parameter.
2970 int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link);
2973 * Retrieve the link status (up/down), the duplex mode (half/full),
2974 * the negotiation (auto/fixed), and if available, the speed (Mbps).
2977 * The port identifier of the Ethernet device.
2979 * Link information written back.
2981 * - (0) if successful.
2982 * - (-ENOTSUP) if the function is not supported in PMD driver.
2983 * - (-ENODEV) if *port_id* invalid.
2984 * - (-EINVAL) if bad parameter.
2986 int rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *link);
2990 * @b EXPERIMENTAL: this API may change without prior notice.
2992 * The function converts a link_speed to a string. It handles all special
2993 * values like unknown or none speed.
2996 * link_speed of rte_eth_link struct
2998 * Link speed in textual format. It's pointer to immutable memory.
2999 * No free is required.
3002 const char *rte_eth_link_speed_to_str(uint32_t link_speed);
3006 * @b EXPERIMENTAL: this API may change without prior notice.
3008 * The function converts a rte_eth_link struct representing a link status to
3012 * A pointer to a string to be filled with textual representation of
3013 * device status. At least RTE_ETH_LINK_MAX_STR_LEN bytes should be allocated to
3014 * store default link status text.
3016 * Length of available memory at 'str' string.
3018 * Link status returned by rte_eth_link_get function
3020 * Number of bytes written to str array or -EINVAL if bad parameter.
3023 int rte_eth_link_to_str(char *str, size_t len,
3024 const struct rte_eth_link *eth_link);
3027 * Retrieve the general I/O statistics of an Ethernet device.
3030 * The port identifier of the Ethernet device.
3032 * A pointer to a structure of type *rte_eth_stats* to be filled with
3033 * the values of device counters for the following set of statistics:
3034 * - *ipackets* with the total of successfully received packets.
3035 * - *opackets* with the total of successfully transmitted packets.
3036 * - *ibytes* with the total of successfully received bytes.
3037 * - *obytes* with the total of successfully transmitted bytes.
3038 * - *ierrors* with the total of erroneous received packets.
3039 * - *oerrors* with the total of failed transmitted packets.
3041 * Zero if successful. Non-zero otherwise.
3043 int rte_eth_stats_get(uint16_t port_id, struct rte_eth_stats *stats);
3046 * Reset the general I/O statistics of an Ethernet device.
3049 * The port identifier of the Ethernet device.
3051 * - (0) if device notified to reset stats.
3052 * - (-ENOTSUP) if hardware doesn't support.
3053 * - (-ENODEV) if *port_id* invalid.
3054 * - (<0): Error code of the driver stats reset function.
3056 int rte_eth_stats_reset(uint16_t port_id);
3059 * Retrieve names of extended statistics of an Ethernet device.
3061 * There is an assumption that 'xstat_names' and 'xstats' arrays are matched
3063 * xstats_names[i].name => xstats[i].value
3065 * And the array index is same with id field of 'struct rte_eth_xstat':
3068 * This assumption makes key-value pair matching less flexible but simpler.
3071 * The port identifier of the Ethernet device.
3072 * @param xstats_names
3073 * An rte_eth_xstat_name array of at least *size* elements to
3074 * be filled. If set to NULL, the function returns the required number
3077 * The size of the xstats_names array (number of elements).
3079 * - A positive value lower or equal to size: success. The return value
3080 * is the number of entries filled in the stats table.
3081 * - A positive value higher than size: error, the given statistics table
3082 * is too small. The return value corresponds to the size that should
3083 * be given to succeed. The entries in the table are not valid and
3084 * shall not be used by the caller.
3085 * - A negative value on error (invalid port ID).
3087 int rte_eth_xstats_get_names(uint16_t port_id,
3088 struct rte_eth_xstat_name *xstats_names,
3092 * Retrieve extended statistics of an Ethernet device.
3094 * There is an assumption that 'xstat_names' and 'xstats' arrays are matched
3096 * xstats_names[i].name => xstats[i].value
3098 * And the array index is same with id field of 'struct rte_eth_xstat':
3101 * This assumption makes key-value pair matching less flexible but simpler.
3104 * The port identifier of the Ethernet device.
3106 * A pointer to a table of structure of type *rte_eth_xstat*
3107 * to be filled with device statistics ids and values.
3108 * This parameter can be set to NULL if n is 0.
3110 * The size of the xstats array (number of elements).
3112 * - A positive value lower or equal to n: success. The return value
3113 * is the number of entries filled in the stats table.
3114 * - A positive value higher than n: error, the given statistics table
3115 * is too small. The return value corresponds to the size that should
3116 * be given to succeed. The entries in the table are not valid and
3117 * shall not be used by the caller.
3118 * - A negative value on error (invalid port ID).
3120 int rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats,
3124 * Retrieve names of extended statistics of an Ethernet device.
3127 * The port identifier of the Ethernet device.
3128 * @param xstats_names
3129 * Array to be filled in with names of requested device statistics.
3130 * Must not be NULL if @p ids are specified (not NULL).
3132 * Number of elements in @p xstats_names array (if not NULL) and in
3133 * @p ids array (if not NULL). Must be 0 if both array pointers are NULL.
3135 * IDs array given by app to retrieve specific statistics. May be NULL to
3136 * retrieve names of all available statistics or, if @p xstats_names is
3137 * NULL as well, just the number of available statistics.
3139 * - A positive value lower or equal to size: success. The return value
3140 * is the number of entries filled in the stats table.
3141 * - A positive value higher than size: success. The given statistics table
3142 * is too small. The return value corresponds to the size that should
3143 * be given to succeed. The entries in the table are not valid and
3144 * shall not be used by the caller.
3145 * - A negative value on error.
3148 rte_eth_xstats_get_names_by_id(uint16_t port_id,
3149 struct rte_eth_xstat_name *xstats_names, unsigned int size,
3153 * Retrieve extended statistics of an Ethernet device.
3156 * The port identifier of the Ethernet device.
3158 * IDs array given by app to retrieve specific statistics. May be NULL to
3159 * retrieve all available statistics or, if @p values is NULL as well,
3160 * just the number of available statistics.
3162 * Array to be filled in with requested device statistics.
3163 * Must not be NULL if ids are specified (not NULL).
3165 * Number of elements in @p values array (if not NULL) and in @p ids
3166 * array (if not NULL). Must be 0 if both array pointers are NULL.
3168 * - A positive value lower or equal to size: success. The return value
3169 * is the number of entries filled in the stats table.
3170 * - A positive value higher than size: success: The given statistics table
3171 * is too small. The return value corresponds to the size that should
3172 * be given to succeed. The entries in the table are not valid and
3173 * shall not be used by the caller.
3174 * - A negative value on error.
3176 int rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,
3177 uint64_t *values, unsigned int size);
3180 * Gets the ID of a statistic from its name.
3182 * This function searches for the statistics using string compares, and
3183 * as such should not be used on the fast-path. For fast-path retrieval of
3184 * specific statistics, store the ID as provided in *id* from this function,
3185 * and pass the ID to rte_eth_xstats_get()
3187 * @param port_id The port to look up statistics from
3188 * @param xstat_name The name of the statistic to return
3189 * @param[out] id A pointer to an app-supplied uint64_t which should be
3190 * set to the ID of the stat if the stat exists.
3193 * -ENODEV for invalid port_id,
3194 * -EIO if device is removed,
3195 * -EINVAL if the xstat_name doesn't exist in port_id
3196 * -ENOMEM if bad parameter.
3198 int rte_eth_xstats_get_id_by_name(uint16_t port_id, const char *xstat_name,
3202 * Reset extended statistics of an Ethernet device.
3205 * The port identifier of the Ethernet device.
3207 * - (0) if device notified to reset extended stats.
3208 * - (-ENOTSUP) if pmd doesn't support both
3209 * extended stats and basic stats reset.
3210 * - (-ENODEV) if *port_id* invalid.
3211 * - (<0): Error code of the driver xstats reset function.
3213 int rte_eth_xstats_reset(uint16_t port_id);
3216 * Set a mapping for the specified transmit queue to the specified per-queue
3217 * statistics counter.
3220 * The port identifier of the Ethernet device.
3221 * @param tx_queue_id
3222 * The index of the transmit queue for which a queue stats mapping is required.
3223 * The value must be in the range [0, nb_tx_queue - 1] previously supplied
3224 * to rte_eth_dev_configure().
3226 * The per-queue packet statistics functionality number that the transmit
3227 * queue is to be assigned.
3228 * The value must be in the range [0, RTE_ETHDEV_QUEUE_STAT_CNTRS - 1].
3229 * Max RTE_ETHDEV_QUEUE_STAT_CNTRS being 256.
3231 * Zero if successful. Non-zero otherwise.
3233 int rte_eth_dev_set_tx_queue_stats_mapping(uint16_t port_id,
3234 uint16_t tx_queue_id, uint8_t stat_idx);
3237 * Set a mapping for the specified receive queue to the specified per-queue
3238 * statistics counter.
3241 * The port identifier of the Ethernet device.
3242 * @param rx_queue_id
3243 * The index of the receive queue for which a queue stats mapping is required.
3244 * The value must be in the range [0, nb_rx_queue - 1] previously supplied
3245 * to rte_eth_dev_configure().
3247 * The per-queue packet statistics functionality number that the receive
3248 * queue is to be assigned.
3249 * The value must be in the range [0, RTE_ETHDEV_QUEUE_STAT_CNTRS - 1].
3250 * Max RTE_ETHDEV_QUEUE_STAT_CNTRS being 256.
3252 * Zero if successful. Non-zero otherwise.
3254 int rte_eth_dev_set_rx_queue_stats_mapping(uint16_t port_id,
3255 uint16_t rx_queue_id,
3259 * Retrieve the Ethernet address of an Ethernet device.
3262 * The port identifier of the Ethernet device.
3264 * A pointer to a structure of type *ether_addr* to be filled with
3265 * the Ethernet address of the Ethernet device.
3267 * - (0) if successful
3268 * - (-ENODEV) if *port_id* invalid.
3269 * - (-EINVAL) if bad parameter.
3271 int rte_eth_macaddr_get(uint16_t port_id, struct rte_ether_addr *mac_addr);
3275 * @b EXPERIMENTAL: this API may change without prior notice
3277 * Retrieve the Ethernet addresses of an Ethernet device.
3280 * The port identifier of the Ethernet device.
3282 * A pointer to an array of structures of type *ether_addr* to be filled with
3283 * the Ethernet addresses of the Ethernet device.
3285 * Number of elements in the @p ma array.
3286 * Note that rte_eth_dev_info::max_mac_addrs can be used to retrieve
3287 * max number of Ethernet addresses for given port.
3289 * - number of retrieved addresses if successful
3290 * - (-ENODEV) if *port_id* invalid.
3291 * - (-EINVAL) if bad parameter.
3294 int rte_eth_macaddrs_get(uint16_t port_id, struct rte_ether_addr *ma,
3298 * Retrieve the contextual information of an Ethernet device.
3300 * As part of this function, a number of of fields in dev_info will be
3301 * initialized as follows:
3306 * Where lim is defined within the rte_eth_dev_info_get as
3308 * const struct rte_eth_desc_lim lim = {
3309 * .nb_max = UINT16_MAX,
3312 * .nb_seg_max = UINT16_MAX,
3313 * .nb_mtu_seg_max = UINT16_MAX,
3316 * device = dev->device
3317 * min_mtu = RTE_ETHER_MIN_LEN - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN
3318 * max_mtu = UINT16_MAX
3320 * The following fields will be populated if support for dev_infos_get()
3321 * exists for the device and the rte_eth_dev 'dev' has been populated
3322 * successfully with a call to it:
3324 * driver_name = dev->device->driver->name
3325 * nb_rx_queues = dev->data->nb_rx_queues
3326 * nb_tx_queues = dev->data->nb_tx_queues
3327 * dev_flags = &dev->data->dev_flags
3330 * The port identifier of the Ethernet device.
3332 * A pointer to a structure of type *rte_eth_dev_info* to be filled with
3333 * the contextual information of the Ethernet device.
3335 * - (0) if successful.
3336 * - (-ENOTSUP) if support for dev_infos_get() does not exist for the device.
3337 * - (-ENODEV) if *port_id* invalid.
3338 * - (-EINVAL) if bad parameter.
3340 int rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_info);
3344 * @b EXPERIMENTAL: this API may change without prior notice.
3346 * Retrieve the configuration of an Ethernet device.
3349 * The port identifier of the Ethernet device.
3351 * Location for Ethernet device configuration to be filled in.
3353 * - (0) if successful.
3354 * - (-ENODEV) if *port_id* invalid.
3355 * - (-EINVAL) if bad parameter.
3358 int rte_eth_dev_conf_get(uint16_t port_id, struct rte_eth_conf *dev_conf);
3361 * Retrieve the firmware version of a device.
3364 * The port identifier of the device.
3366 * A pointer to a string array storing the firmware version of a device,
3367 * the string includes terminating null. This pointer is allocated by caller.
3369 * The size of the string array pointed by fw_version, which should be
3370 * large enough to store firmware version of the device.
3372 * - (0) if successful.
3373 * - (-ENOTSUP) if operation is not supported.
3374 * - (-ENODEV) if *port_id* invalid.
3375 * - (-EIO) if device is removed.
3376 * - (-EINVAL) if bad parameter.
3377 * - (>0) if *fw_size* is not enough to store firmware version, return
3378 * the size of the non truncated string.
3380 int rte_eth_dev_fw_version_get(uint16_t port_id,
3381 char *fw_version, size_t fw_size);
3384 * Retrieve the supported packet types of an Ethernet device.
3386 * When a packet type is announced as supported, it *must* be recognized by
3387 * the PMD. For instance, if RTE_PTYPE_L2_ETHER, RTE_PTYPE_L2_ETHER_VLAN
3388 * and RTE_PTYPE_L3_IPV4 are announced, the PMD must return the following
3389 * packet types for these packets:
3390 * - Ether/IPv4 -> RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4
3391 * - Ether/VLAN/IPv4 -> RTE_PTYPE_L2_ETHER_VLAN | RTE_PTYPE_L3_IPV4
3392 * - Ether/[anything else] -> RTE_PTYPE_L2_ETHER
3393 * - Ether/VLAN/[anything else] -> RTE_PTYPE_L2_ETHER_VLAN
3395 * When a packet is received by a PMD, the most precise type must be
3396 * returned among the ones supported. However a PMD is allowed to set
3397 * packet type that is not in the supported list, at the condition that it
3398 * is more precise. Therefore, a PMD announcing no supported packet types
3399 * can still set a matching packet type in a received packet.
3402 * Better to invoke this API after the device is already started or Rx burst
3403 * function is decided, to obtain correct supported ptypes.
3405 * if a given PMD does not report what ptypes it supports, then the supported
3406 * ptype count is reported as 0.
3408 * The port identifier of the Ethernet device.
3410 * A hint of what kind of packet type which the caller is interested in.
3412 * An array pointer to store adequate packet types, allocated by caller.
3414 * Size of the array pointed by param ptypes.
3416 * - (>=0) Number of supported ptypes. If the number of types exceeds num,
3417 * only num entries will be filled into the ptypes array, but the full
3418 * count of supported ptypes will be returned.
3419 * - (-ENODEV) if *port_id* invalid.
3420 * - (-EINVAL) if bad parameter.
3422 int rte_eth_dev_get_supported_ptypes(uint16_t port_id, uint32_t ptype_mask,
3423 uint32_t *ptypes, int num);
3425 * Inform Ethernet device about reduced range of packet types to handle.
3427 * Application can use this function to set only specific ptypes that it's
3428 * interested. This information can be used by the PMD to optimize Rx path.
3430 * The function accepts an array `set_ptypes` allocated by the caller to
3431 * store the packet types set by the driver, the last element of the array
3432 * is set to RTE_PTYPE_UNKNOWN. The size of the `set_ptype` array should be
3433 * `rte_eth_dev_get_supported_ptypes() + 1` else it might only be filled
3437 * The port identifier of the Ethernet device.
3439 * The ptype family that application is interested in should be bitwise OR of
3440 * RTE_PTYPE_*_MASK or 0.
3442 * An array pointer to store set packet types, allocated by caller. The
3443 * function marks the end of array with RTE_PTYPE_UNKNOWN.
3445 * Size of the array pointed by param ptypes.
3446 * Should be rte_eth_dev_get_supported_ptypes() + 1 to accommodate the
3450 * - (-ENODEV) if *port_id* invalid.
3451 * - (-EINVAL) if *ptype_mask* is invalid (or) set_ptypes is NULL and
3454 int rte_eth_dev_set_ptypes(uint16_t port_id, uint32_t ptype_mask,
3455 uint32_t *set_ptypes, unsigned int num);
3458 * Retrieve the MTU of an Ethernet device.
3461 * The port identifier of the Ethernet device.
3463 * A pointer to a uint16_t where the retrieved MTU is to be stored.
3465 * - (0) if successful.
3466 * - (-ENODEV) if *port_id* invalid.
3467 * - (-EINVAL) if bad parameter.
3469 int rte_eth_dev_get_mtu(uint16_t port_id, uint16_t *mtu);
3472 * Change the MTU of an Ethernet device.
3475 * The port identifier of the Ethernet device.
3477 * A uint16_t for the MTU to be applied.
3479 * - (0) if successful.
3480 * - (-ENOTSUP) if operation is not supported.
3481 * - (-ENODEV) if *port_id* invalid.
3482 * - (-EIO) if device is removed.
3483 * - (-EINVAL) if *mtu* invalid, validation of mtu can occur within
3484 * rte_eth_dev_set_mtu if dev_infos_get is supported by the device or
3485 * when the mtu is set using dev->dev_ops->mtu_set.
3486 * - (-EBUSY) if operation is not allowed when the port is running
3488 int rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu);
3491 * Enable/Disable hardware filtering by an Ethernet device of received
3492 * VLAN packets tagged with a given VLAN Tag Identifier.
3495 * The port identifier of the Ethernet device.
3497 * The VLAN Tag Identifier whose filtering must be enabled or disabled.
3499 * If > 0, enable VLAN filtering of VLAN packets tagged with *vlan_id*.
3500 * Otherwise, disable VLAN filtering of VLAN packets tagged with *vlan_id*.
3502 * - (0) if successful.
3503 * - (-ENOTSUP) if hardware-assisted VLAN filtering not configured.
3504 * - (-ENODEV) if *port_id* invalid.
3505 * - (-EIO) if device is removed.
3506 * - (-ENOSYS) if VLAN filtering on *port_id* disabled.
3507 * - (-EINVAL) if *vlan_id* > 4095.
3509 int rte_eth_dev_vlan_filter(uint16_t port_id, uint16_t vlan_id, int on);
3512 * Enable/Disable hardware VLAN Strip by a Rx queue of an Ethernet device.
3515 * The port identifier of the Ethernet device.
3516 * @param rx_queue_id
3517 * The index of the receive queue for which a queue stats mapping is required.
3518 * The value must be in the range [0, nb_rx_queue - 1] previously supplied
3519 * to rte_eth_dev_configure().
3521 * If 1, Enable VLAN Stripping of the receive queue of the Ethernet port.
3522 * If 0, Disable VLAN Stripping of the receive queue of the Ethernet port.
3524 * - (0) if successful.
3525 * - (-ENOTSUP) if hardware-assisted VLAN stripping not configured.
3526 * - (-ENODEV) if *port_id* invalid.
3527 * - (-EINVAL) if *rx_queue_id* invalid.
3529 int rte_eth_dev_set_vlan_strip_on_queue(uint16_t port_id, uint16_t rx_queue_id,
3533 * Set the Outer VLAN Ether Type by an Ethernet device, it can be inserted to
3537 * The port identifier of the Ethernet device.
3541 * The Tag Protocol ID
3543 * - (0) if successful.
3544 * - (-ENOTSUP) if hardware-assisted VLAN TPID setup is not supported.
3545 * - (-ENODEV) if *port_id* invalid.
3546 * - (-EIO) if device is removed.
3548 int rte_eth_dev_set_vlan_ether_type(uint16_t port_id,
3549 enum rte_vlan_type vlan_type,
3553 * Set VLAN offload configuration on an Ethernet device.
3556 * The port identifier of the Ethernet device.
3557 * @param offload_mask
3558 * The VLAN Offload bit mask can be mixed use with "OR"
3559 * RTE_ETH_VLAN_STRIP_OFFLOAD
3560 * RTE_ETH_VLAN_FILTER_OFFLOAD
3561 * RTE_ETH_VLAN_EXTEND_OFFLOAD
3562 * RTE_ETH_QINQ_STRIP_OFFLOAD
3564 * - (0) if successful.
3565 * - (-ENOTSUP) if hardware-assisted VLAN filtering not configured.
3566 * - (-ENODEV) if *port_id* invalid.
3567 * - (-EIO) if device is removed.
3569 int rte_eth_dev_set_vlan_offload(uint16_t port_id, int offload_mask);
3572 * Read VLAN Offload configuration from an Ethernet device
3575 * The port identifier of the Ethernet device.
3577 * - (>0) if successful. Bit mask to indicate
3578 * RTE_ETH_VLAN_STRIP_OFFLOAD
3579 * RTE_ETH_VLAN_FILTER_OFFLOAD
3580 * RTE_ETH_VLAN_EXTEND_OFFLOAD
3581 * RTE_ETH_QINQ_STRIP_OFFLOAD
3582 * - (-ENODEV) if *port_id* invalid.
3584 int rte_eth_dev_get_vlan_offload(uint16_t port_id);
3587 * Set port based Tx VLAN insertion on or off.
3590 * The port identifier of the Ethernet device.
3592 * Port based Tx VLAN identifier together with user priority.
3594 * Turn on or off the port based Tx VLAN insertion.
3597 * - (0) if successful.
3598 * - negative if failed.
3600 int rte_eth_dev_set_vlan_pvid(uint16_t port_id, uint16_t pvid, int on);
3602 typedef void (*buffer_tx_error_fn)(struct rte_mbuf **unsent, uint16_t count,
3606 * Structure used to buffer packets for future Tx
3607 * Used by APIs rte_eth_tx_buffer and rte_eth_tx_buffer_flush
3609 struct rte_eth_dev_tx_buffer {
3610 buffer_tx_error_fn error_callback;
3611 void *error_userdata;
3612 uint16_t size; /**< Size of buffer for buffered Tx */
3613 uint16_t length; /**< Number of packets in the array */
3614 /** Pending packets to be sent on explicit flush or when full */
3615 struct rte_mbuf *pkts[];
3619 * Calculate the size of the Tx buffer.
3622 * Number of stored packets.
3624 #define RTE_ETH_TX_BUFFER_SIZE(sz) \
3625 (sizeof(struct rte_eth_dev_tx_buffer) + (sz) * sizeof(struct rte_mbuf *))
3628 * Initialize default values for buffered transmitting
3631 * Tx buffer to be initialized.
3638 rte_eth_tx_buffer_init(struct rte_eth_dev_tx_buffer *buffer, uint16_t size);
3641 * Configure a callback for buffered packets which cannot be sent
3643 * Register a specific callback to be called when an attempt is made to send
3644 * all packets buffered on an Ethernet port, but not all packets can
3645 * successfully be sent. The callback registered here will be called only
3646 * from calls to rte_eth_tx_buffer() and rte_eth_tx_buffer_flush() APIs.
3647 * The default callback configured for each queue by default just frees the
3648 * packets back to the calling mempool. If additional behaviour is required,
3649 * for example, to count dropped packets, or to retry transmission of packets
3650 * which cannot be sent, this function should be used to register a suitable
3651 * callback function to implement the desired behaviour.
3652 * The example callback "rte_eth_count_unsent_packet_callback()" is also
3653 * provided as reference.
3656 * The port identifier of the Ethernet device.
3658 * The function to be used as the callback.
3660 * Arbitrary parameter to be passed to the callback function
3662 * 0 on success, or -EINVAL if bad parameter
3665 rte_eth_tx_buffer_set_err_callback(struct rte_eth_dev_tx_buffer *buffer,
3666 buffer_tx_error_fn callback, void *userdata);
3669 * Callback function for silently dropping unsent buffered packets.
3671 * This function can be passed to rte_eth_tx_buffer_set_err_callback() to
3672 * adjust the default behavior when buffered packets cannot be sent. This
3673 * function drops any unsent packets silently and is used by Tx buffered
3674 * operations as default behavior.
3676 * NOTE: this function should not be called directly, instead it should be used
3677 * as a callback for packet buffering.
3679 * NOTE: when configuring this function as a callback with
3680 * rte_eth_tx_buffer_set_err_callback(), the final, userdata parameter
3681 * should point to an uint64_t value.
3684 * The previously buffered packets which could not be sent
3686 * The number of unsent packets in the pkts array
3691 rte_eth_tx_buffer_drop_callback(struct rte_mbuf **pkts, uint16_t unsent,
3695 * Callback function for tracking unsent buffered packets.
3697 * This function can be passed to rte_eth_tx_buffer_set_err_callback() to
3698 * adjust the default behavior when buffered packets cannot be sent. This
3699 * function drops any unsent packets, but also updates a user-supplied counter
3700 * to track the overall number of packets dropped. The counter should be an
3701 * uint64_t variable.
3703 * NOTE: this function should not be called directly, instead it should be used
3704 * as a callback for packet buffering.
3706 * NOTE: when configuring this function as a callback with
3707 * rte_eth_tx_buffer_set_err_callback(), the final, userdata parameter
3708 * should point to an uint64_t value.
3711 * The previously buffered packets which could not be sent
3713 * The number of unsent packets in the pkts array
3715 * Pointer to an uint64_t value, which will be incremented by unsent
3718 rte_eth_tx_buffer_count_callback(struct rte_mbuf **pkts, uint16_t unsent,
3722 * Request the driver to free mbufs currently cached by the driver. The
3723 * driver will only free the mbuf if it is no longer in use. It is the
3724 * application's responsibility to ensure rte_eth_tx_buffer_flush(..) is
3728 * The port identifier of the Ethernet device.
3730 * The index of the transmit queue through which output packets must be
3732 * The value must be in the range [0, nb_tx_queue - 1] previously supplied
3733 * to rte_eth_dev_configure().
3735 * Maximum number of packets to free. Use 0 to indicate all possible packets
3736 * should be freed. Note that a packet may be using multiple mbufs.
3739 * -ENODEV: Invalid interface
3740 * -EIO: device is removed
3741 * -ENOTSUP: Driver does not support function
3743 * 0-n: Number of packets freed. More packets may still remain in ring that
3747 rte_eth_tx_done_cleanup(uint16_t port_id, uint16_t queue_id, uint32_t free_cnt);
3750 * Subtypes for IPsec offload event(@ref RTE_ETH_EVENT_IPSEC) raised by
3753 enum rte_eth_event_ipsec_subtype {
3754 /** Unknown event type */
3755 RTE_ETH_EVENT_IPSEC_UNKNOWN = 0,
3756 /** Sequence number overflow */
3757 RTE_ETH_EVENT_IPSEC_ESN_OVERFLOW,
3758 /** Soft time expiry of SA */
3759 RTE_ETH_EVENT_IPSEC_SA_TIME_EXPIRY,
3760 /** Soft byte expiry of SA */
3761 RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY,
3762 /** Max value of this enum */
3763 RTE_ETH_EVENT_IPSEC_MAX
3767 * Descriptor for @ref RTE_ETH_EVENT_IPSEC event. Used by eth dev to send extra
3768 * information of the IPsec offload event.
3770 struct rte_eth_event_ipsec_desc {
3771 /** Type of RTE_ETH_EVENT_IPSEC_* event */
3772 enum rte_eth_event_ipsec_subtype subtype;
3774 * Event specific metadata.
3776 * For the following events, *userdata* registered
3777 * with the *rte_security_session* would be returned
3780 * - @ref RTE_ETH_EVENT_IPSEC_ESN_OVERFLOW
3781 * - @ref RTE_ETH_EVENT_IPSEC_SA_TIME_EXPIRY
3782 * - @ref RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY
3784 * @see struct rte_security_session_conf
3791 * The eth device event type for interrupt, and maybe others in the future.
3793 enum rte_eth_event_type {
3794 RTE_ETH_EVENT_UNKNOWN, /**< unknown event type */
3795 RTE_ETH_EVENT_INTR_LSC, /**< lsc interrupt event */
3796 /** queue state event (enabled/disabled) */
3797 RTE_ETH_EVENT_QUEUE_STATE,
3798 /** reset interrupt event, sent to VF on PF reset */
3799 RTE_ETH_EVENT_INTR_RESET,
3800 RTE_ETH_EVENT_VF_MBOX, /**< message from the VF received by PF */
3801 RTE_ETH_EVENT_MACSEC, /**< MACsec offload related event */
3802 RTE_ETH_EVENT_INTR_RMV, /**< device removal event */
3803 RTE_ETH_EVENT_NEW, /**< port is probed */
3804 RTE_ETH_EVENT_DESTROY, /**< port is released */
3805 RTE_ETH_EVENT_IPSEC, /**< IPsec offload related event */
3806 RTE_ETH_EVENT_FLOW_AGED,/**< New aged-out flows is detected */
3807 RTE_ETH_EVENT_MAX /**< max value of this enum */
3810 /** User application callback to be registered for interrupts. */
3811 typedef int (*rte_eth_dev_cb_fn)(uint16_t port_id,
3812 enum rte_eth_event_type event, void *cb_arg, void *ret_param);
3815 * Register a callback function for port event.
3819 * RTE_ETH_ALL means register the event for all port ids.
3823 * User supplied callback function to be called.
3825 * Pointer to the parameters for the registered callback.
3828 * - On success, zero.
3829 * - On failure, a negative value.
3831 int rte_eth_dev_callback_register(uint16_t port_id,
3832 enum rte_eth_event_type event,
3833 rte_eth_dev_cb_fn cb_fn, void *cb_arg);
3836 * Unregister a callback function for port event.
3840 * RTE_ETH_ALL means unregister the event for all port ids.
3844 * User supplied callback function to be called.
3846 * Pointer to the parameters for the registered callback. -1 means to
3847 * remove all for the same callback address and same event.
3850 * - On success, zero.
3851 * - On failure, a negative value.
3853 int rte_eth_dev_callback_unregister(uint16_t port_id,
3854 enum rte_eth_event_type event,
3855 rte_eth_dev_cb_fn cb_fn, void *cb_arg);
3858 * When there is no Rx packet coming in Rx Queue for a long time, we can
3859 * sleep lcore related to Rx Queue for power saving, and enable Rx interrupt
3860 * to be triggered when Rx packet arrives.
3862 * The rte_eth_dev_rx_intr_enable() function enables Rx queue
3863 * interrupt on specific Rx queue of a port.
3866 * The port identifier of the Ethernet device.
3868 * The index of the receive queue from which to retrieve input packets.
3869 * The value must be in the range [0, nb_rx_queue - 1] previously supplied
3870 * to rte_eth_dev_configure().
3872 * - (0) if successful.
3873 * - (-ENOTSUP) if underlying hardware OR driver doesn't support
3875 * - (-ENODEV) if *port_id* invalid.
3876 * - (-EIO) if device is removed.
3878 int rte_eth_dev_rx_intr_enable(uint16_t port_id, uint16_t queue_id);
3881 * When lcore wakes up from Rx interrupt indicating packet coming, disable Rx
3882 * interrupt and returns to polling mode.
3884 * The rte_eth_dev_rx_intr_disable() function disables Rx queue
3885 * interrupt on specific Rx queue of a port.
3888 * The port identifier of the Ethernet device.
3890 * The index of the receive queue from which to retrieve input packets.
3891 * The value must be in the range [0, nb_rx_queue - 1] previously supplied
3892 * to rte_eth_dev_configure().
3894 * - (0) if successful.
3895 * - (-ENOTSUP) if underlying hardware OR driver doesn't support
3897 * - (-ENODEV) if *port_id* invalid.
3898 * - (-EIO) if device is removed.
3900 int rte_eth_dev_rx_intr_disable(uint16_t port_id, uint16_t queue_id);
3903 * Rx Interrupt control per port.
3906 * The port identifier of the Ethernet device.
3908 * Epoll instance fd which the intr vector associated to.
3909 * Using RTE_EPOLL_PER_THREAD allows to use per thread epoll instance.
3911 * The operation be performed for the vector.
3912 * Operation type of {RTE_INTR_EVENT_ADD, RTE_INTR_EVENT_DEL}.
3916 * - On success, zero.
3917 * - On failure, a negative value.
3919 int rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data);
3922 * Rx Interrupt control per queue.
3925 * The port identifier of the Ethernet device.
3927 * The index of the receive queue from which to retrieve input packets.
3928 * The value must be in the range [0, nb_rx_queue - 1] previously supplied
3929 * to rte_eth_dev_configure().
3931 * Epoll instance fd which the intr vector associated to.
3932 * Using RTE_EPOLL_PER_THREAD allows to use per thread epoll instance.
3934 * The operation be performed for the vector.
3935 * Operation type of {RTE_INTR_EVENT_ADD, RTE_INTR_EVENT_DEL}.
3939 * - On success, zero.
3940 * - On failure, a negative value.
3942 int rte_eth_dev_rx_intr_ctl_q(uint16_t port_id, uint16_t queue_id,
3943 int epfd, int op, void *data);
3946 * Get interrupt fd per Rx queue.
3949 * The port identifier of the Ethernet device.
3951 * The index of the receive queue from which to retrieve input packets.
3952 * The value must be in the range [0, nb_rx_queue - 1] previously supplied
3953 * to rte_eth_dev_configure().
3955 * - (>=0) the interrupt fd associated to the requested Rx queue if
3960 rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t queue_id);
3963 * Turn on the LED on the Ethernet device.
3964 * This function turns on the LED on the Ethernet device.
3967 * The port identifier of the Ethernet device.
3969 * - (0) if successful.
3970 * - (-ENOTSUP) if underlying hardware OR driver doesn't support
3972 * - (-ENODEV) if *port_id* invalid.
3973 * - (-EIO) if device is removed.
3975 int rte_eth_led_on(uint16_t port_id);
3978 * Turn off the LED on the Ethernet device.
3979 * This function turns off the LED on the Ethernet device.
3982 * The port identifier of the Ethernet device.
3984 * - (0) if successful.
3985 * - (-ENOTSUP) if underlying hardware OR driver doesn't support
3987 * - (-ENODEV) if *port_id* invalid.
3988 * - (-EIO) if device is removed.
3990 int rte_eth_led_off(uint16_t port_id);
3994 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
3996 * Get Forward Error Correction(FEC) capability.
3999 * The port identifier of the Ethernet device.
4000 * @param speed_fec_capa
4001 * speed_fec_capa is out only with per-speed capabilities.
4002 * If set to NULL, the function returns the required number
4003 * of required array entries.
4005 * a number of elements in an speed_fec_capa array.
4008 * - A non-negative value lower or equal to num: success. The return value
4009 * is the number of entries filled in the fec capa array.
4010 * - A non-negative value higher than num: error, the given fec capa array
4011 * is too small. The return value corresponds to the num that should
4012 * be given to succeed. The entries in fec capa array are not valid and
4013 * shall not be used by the caller.
4014 * - (-ENOTSUP) if underlying hardware OR driver doesn't support.
4016 * - (-EIO) if device is removed.
4017 * - (-ENODEV) if *port_id* invalid.
4018 * - (-EINVAL) if *num* or *speed_fec_capa* invalid
4021 int rte_eth_fec_get_capability(uint16_t port_id,
4022 struct rte_eth_fec_capa *speed_fec_capa,
4027 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
4029 * Get current Forward Error Correction(FEC) mode.
4030 * If link is down and AUTO is enabled, AUTO is returned, otherwise,
4031 * configured FEC mode is returned.
4032 * If link is up, current FEC mode is returned.
4035 * The port identifier of the Ethernet device.
4037 * A bitmask of enabled FEC modes. If AUTO bit is set, other
4038 * bits specify FEC modes which may be negotiated. If AUTO
4039 * bit is clear, specify FEC modes to be used (only one valid
4040 * mode per speed may be set).
4042 * - (0) if successful.
4043 * - (-ENOTSUP) if underlying hardware OR driver doesn't support.
4045 * - (-EIO) if device is removed.
4046 * - (-ENODEV) if *port_id* invalid.
4049 int rte_eth_fec_get(uint16_t port_id, uint32_t *fec_capa);
4053 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
4055 * Set Forward Error Correction(FEC) mode.
4058 * The port identifier of the Ethernet device.
4060 * A bitmask of allowed FEC modes. If AUTO bit is set, other
4061 * bits specify FEC modes which may be negotiated. If AUTO
4062 * bit is clear, specify FEC modes to be used (only one valid
4063 * mode per speed may be set).
4065 * - (0) if successful.
4066 * - (-EINVAL) if the FEC mode is not valid.
4067 * - (-ENOTSUP) if underlying hardware OR driver doesn't support.
4068 * - (-EIO) if device is removed.
4069 * - (-ENODEV) if *port_id* invalid.
4072 int rte_eth_fec_set(uint16_t port_id, uint32_t fec_capa);
4075 * Get current status of the Ethernet link flow control for Ethernet device
4078 * The port identifier of the Ethernet device.
4080 * The pointer to the structure where to store the flow control parameters.
4082 * - (0) if successful.
4083 * - (-ENOTSUP) if hardware doesn't support flow control.
4084 * - (-ENODEV) if *port_id* invalid.
4085 * - (-EIO) if device is removed.
4086 * - (-EINVAL) if bad parameter.
4088 int rte_eth_dev_flow_ctrl_get(uint16_t port_id,
4089 struct rte_eth_fc_conf *fc_conf);
4092 * Configure the Ethernet link flow control for Ethernet device
4095 * The port identifier of the Ethernet device.
4097 * The pointer to the structure of the flow control parameters.
4099 * - (0) if successful.
4100 * - (-ENOTSUP) if hardware doesn't support flow control mode.
4101 * - (-ENODEV) if *port_id* invalid.
4102 * - (-EINVAL) if bad parameter
4103 * - (-EIO) if flow control setup failure or device is removed.
4105 int rte_eth_dev_flow_ctrl_set(uint16_t port_id,
4106 struct rte_eth_fc_conf *fc_conf);
4109 * Configure the Ethernet priority flow control under DCB environment
4110 * for Ethernet device.
4113 * The port identifier of the Ethernet device.
4115 * The pointer to the structure of the priority flow control parameters.
4117 * - (0) if successful.
4118 * - (-ENOTSUP) if hardware doesn't support priority flow control mode.
4119 * - (-ENODEV) if *port_id* invalid.
4120 * - (-EINVAL) if bad parameter
4121 * - (-EIO) if flow control setup failure or device is removed.
4123 int rte_eth_dev_priority_flow_ctrl_set(uint16_t port_id,
4124 struct rte_eth_pfc_conf *pfc_conf);
4127 * Add a MAC address to the set used for filtering incoming packets.
4130 * The port identifier of the Ethernet device.
4132 * The MAC address to add.
4134 * VMDq pool index to associate address with (if VMDq is enabled). If VMDq is
4135 * not enabled, this should be set to 0.
4137 * - (0) if successfully added or *mac_addr* was already added.
4138 * - (-ENOTSUP) if hardware doesn't support this feature.
4139 * - (-ENODEV) if *port* is invalid.
4140 * - (-EIO) if device is removed.
4141 * - (-ENOSPC) if no more MAC addresses can be added.
4142 * - (-EINVAL) if MAC address is invalid.
4144 int rte_eth_dev_mac_addr_add(uint16_t port_id, struct rte_ether_addr *mac_addr,
4148 * Remove a MAC address from the internal array of addresses.
4151 * The port identifier of the Ethernet device.
4153 * MAC address to remove.
4155 * - (0) if successful, or *mac_addr* didn't exist.
4156 * - (-ENOTSUP) if hardware doesn't support.
4157 * - (-ENODEV) if *port* invalid.
4158 * - (-EADDRINUSE) if attempting to remove the default MAC address.
4159 * - (-EINVAL) if MAC address is invalid.
4161 int rte_eth_dev_mac_addr_remove(uint16_t port_id,
4162 struct rte_ether_addr *mac_addr);
4165 * Set the default MAC address.
4168 * The port identifier of the Ethernet device.
4170 * New default MAC address.
4172 * - (0) if successful, or *mac_addr* didn't exist.
4173 * - (-ENOTSUP) if hardware doesn't support.
4174 * - (-ENODEV) if *port* invalid.
4175 * - (-EINVAL) if MAC address is invalid.
4177 int rte_eth_dev_default_mac_addr_set(uint16_t port_id,
4178 struct rte_ether_addr *mac_addr);
4181 * Update Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
4184 * The port identifier of the Ethernet device.
4188 * Redirection table size. The table size can be queried by
4189 * rte_eth_dev_info_get().
4191 * - (0) if successful.
4192 * - (-ENODEV) if *port_id* is invalid.
4193 * - (-ENOTSUP) if hardware doesn't support.
4194 * - (-EINVAL) if bad parameter.
4195 * - (-EIO) if device is removed.
4197 int rte_eth_dev_rss_reta_update(uint16_t port_id,
4198 struct rte_eth_rss_reta_entry64 *reta_conf,
4199 uint16_t reta_size);
4202 * Query Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
4205 * The port identifier of the Ethernet device.
4207 * RETA to query. For each requested reta entry, corresponding bit
4208 * in mask must be set.
4210 * Redirection table size. The table size can be queried by
4211 * rte_eth_dev_info_get().
4213 * - (0) if successful.
4214 * - (-ENODEV) if *port_id* is invalid.
4215 * - (-ENOTSUP) if hardware doesn't support.
4216 * - (-EINVAL) if bad parameter.
4217 * - (-EIO) if device is removed.
4219 int rte_eth_dev_rss_reta_query(uint16_t port_id,
4220 struct rte_eth_rss_reta_entry64 *reta_conf,
4221 uint16_t reta_size);
4224 * Updates unicast hash table for receiving packet with the given destination
4225 * MAC address, and the packet is routed to all VFs for which the Rx mode is
4226 * accept packets that match the unicast hash table.
4229 * The port identifier of the Ethernet device.
4231 * Unicast MAC address.
4233 * 1 - Set an unicast hash bit for receiving packets with the MAC address.
4234 * 0 - Clear an unicast hash bit.
4236 * - (0) if successful.
4237 * - (-ENOTSUP) if hardware doesn't support.
4238 * - (-ENODEV) if *port_id* invalid.
4239 * - (-EIO) if device is removed.
4240 * - (-EINVAL) if bad parameter.
4242 int rte_eth_dev_uc_hash_table_set(uint16_t port_id, struct rte_ether_addr *addr,
4246 * Updates all unicast hash bitmaps for receiving packet with any Unicast
4247 * Ethernet MAC addresses,the packet is routed to all VFs for which the Rx
4248 * mode is accept packets that match the unicast hash table.
4251 * The port identifier of the Ethernet device.
4253 * 1 - Set all unicast hash bitmaps for receiving all the Ethernet
4255 * 0 - Clear all unicast hash bitmaps
4257 * - (0) if successful.
4258 * - (-ENOTSUP) if hardware doesn't support.
4259 * - (-ENODEV) if *port_id* invalid.
4260 * - (-EIO) if device is removed.
4261 * - (-EINVAL) if bad parameter.
4263 int rte_eth_dev_uc_all_hash_table_set(uint16_t port_id, uint8_t on);
4266 * Set the rate limitation for a queue on an Ethernet device.
4269 * The port identifier of the Ethernet device.
4273 * The Tx rate in Mbps. Allocated from the total port link speed.
4275 * - (0) if successful.
4276 * - (-ENOTSUP) if hardware doesn't support this feature.
4277 * - (-ENODEV) if *port_id* invalid.
4278 * - (-EIO) if device is removed.
4279 * - (-EINVAL) if bad parameter.
4281 int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx,
4285 * Configuration of Receive Side Scaling hash computation of Ethernet device.
4288 * The port identifier of the Ethernet device.
4290 * The new configuration to use for RSS hash computation on the port.
4292 * - (0) if successful.
4293 * - (-ENODEV) if port identifier is invalid.
4294 * - (-EIO) if device is removed.
4295 * - (-ENOTSUP) if hardware doesn't support.
4296 * - (-EINVAL) if bad parameter.
4298 int rte_eth_dev_rss_hash_update(uint16_t port_id,
4299 struct rte_eth_rss_conf *rss_conf);
4302 * Retrieve current configuration of Receive Side Scaling hash computation
4303 * of Ethernet device.
4306 * The port identifier of the Ethernet device.
4308 * Where to store the current RSS hash configuration of the Ethernet device.
4310 * - (0) if successful.
4311 * - (-ENODEV) if port identifier is invalid.
4312 * - (-EIO) if device is removed.
4313 * - (-ENOTSUP) if hardware doesn't support RSS.
4314 * - (-EINVAL) if bad parameter.
4317 rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
4318 struct rte_eth_rss_conf *rss_conf);
4321 * Add UDP tunneling port for a type of tunnel.
4323 * Some NICs may require such configuration to properly parse a tunnel
4324 * with any standard or custom UDP port.
4325 * The packets with this UDP port will be parsed for this type of tunnel.
4326 * The device parser will also check the rest of the tunnel headers
4327 * before classifying the packet.
4329 * With some devices, this API will affect packet classification, i.e.:
4330 * - mbuf.packet_type reported on Rx
4331 * - rte_flow rules with tunnel items
4334 * The port identifier of the Ethernet device.
4336 * UDP tunneling configuration.
4339 * - (0) if successful.
4340 * - (-ENODEV) if port identifier is invalid.
4341 * - (-EIO) if device is removed.
4342 * - (-ENOTSUP) if hardware doesn't support tunnel type.
4345 rte_eth_dev_udp_tunnel_port_add(uint16_t port_id,
4346 struct rte_eth_udp_tunnel *tunnel_udp);
4349 * Delete UDP tunneling port for a type of tunnel.
4351 * The packets with this UDP port will not be classified as this type of tunnel
4352 * anymore if the device use such mapping for tunnel packet classification.
4354 * @see rte_eth_dev_udp_tunnel_port_add
4357 * The port identifier of the Ethernet device.
4359 * UDP tunneling configuration.
4362 * - (0) if successful.
4363 * - (-ENODEV) if port identifier is invalid.
4364 * - (-EIO) if device is removed.
4365 * - (-ENOTSUP) if hardware doesn't support tunnel type.
4368 rte_eth_dev_udp_tunnel_port_delete(uint16_t port_id,
4369 struct rte_eth_udp_tunnel *tunnel_udp);
4372 * Get DCB information on an Ethernet device.
4375 * The port identifier of the Ethernet device.
4379 * - (0) if successful.
4380 * - (-ENODEV) if port identifier is invalid.
4381 * - (-EIO) if device is removed.
4382 * - (-ENOTSUP) if hardware doesn't support.
4383 * - (-EINVAL) if bad parameter.
4385 int rte_eth_dev_get_dcb_info(uint16_t port_id,
4386 struct rte_eth_dcb_info *dcb_info);
4388 struct rte_eth_rxtx_callback;
4391 * Add a callback to be called on packet Rx on a given port and queue.
4393 * This API configures a function to be called for each burst of
4394 * packets received on a given NIC port queue. The return value is a pointer
4395 * that can be used to later remove the callback using
4396 * rte_eth_remove_rx_callback().
4398 * Multiple functions are called in the order that they are added.
4401 * The port identifier of the Ethernet device.
4403 * The queue on the Ethernet device on which the callback is to be added.
4405 * The callback function
4407 * A generic pointer parameter which will be passed to each invocation of the
4408 * callback function on this port and queue. Inter-thread synchronization
4409 * of any user data changes is the responsibility of the user.
4413 * On success, a pointer value which can later be used to remove the callback.
4415 const struct rte_eth_rxtx_callback *
4416 rte_eth_add_rx_callback(uint16_t port_id, uint16_t queue_id,
4417 rte_rx_callback_fn fn, void *user_param);
4420 * Add a callback that must be called first on packet Rx on a given port
4423 * This API configures a first function to be called for each burst of
4424 * packets received on a given NIC port queue. The return value is a pointer
4425 * that can be used to later remove the callback using
4426 * rte_eth_remove_rx_callback().
4428 * Multiple functions are called in the order that they are added.
4431 * The port identifier of the Ethernet device.
4433 * The queue on the Ethernet device on which the callback is to be added.
4435 * The callback function
4437 * A generic pointer parameter which will be passed to each invocation of the
4438 * callback function on this port and queue. Inter-thread synchronization
4439 * of any user data changes is the responsibility of the user.
4443 * On success, a pointer value which can later be used to remove the callback.
4445 const struct rte_eth_rxtx_callback *
4446 rte_eth_add_first_rx_callback(uint16_t port_id, uint16_t queue_id,
4447 rte_rx_callback_fn fn, void *user_param);
4450 * Add a callback to be called on packet Tx on a given port and queue.
4452 * This API configures a function to be called for each burst of
4453 * packets sent on a given NIC port queue. The return value is a pointer
4454 * that can be used to later remove the callback using
4455 * rte_eth_remove_tx_callback().
4457 * Multiple functions are called in the order that they are added.
4460 * The port identifier of the Ethernet device.
4462 * The queue on the Ethernet device on which the callback is to be added.
4464 * The callback function
4466 * A generic pointer parameter which will be passed to each invocation of the
4467 * callback function on this port and queue. Inter-thread synchronization
4468 * of any user data changes is the responsibility of the user.
4472 * On success, a pointer value which can later be used to remove the callback.
4474 const struct rte_eth_rxtx_callback *
4475 rte_eth_add_tx_callback(uint16_t port_id, uint16_t queue_id,
4476 rte_tx_callback_fn fn, void *user_param);
4479 * Remove an Rx packet callback from a given port and queue.
4481 * This function is used to removed callbacks that were added to a NIC port
4482 * queue using rte_eth_add_rx_callback().
4484 * Note: the callback is removed from the callback list but it isn't freed
4485 * since the it may still be in use. The memory for the callback can be
4486 * subsequently freed back by the application by calling rte_free():
4488 * - Immediately - if the port is stopped, or the user knows that no
4489 * callbacks are in flight e.g. if called from the thread doing Rx/Tx
4492 * - After a short delay - where the delay is sufficient to allow any
4493 * in-flight callbacks to complete. Alternately, the RCU mechanism can be
4494 * used to detect when data plane threads have ceased referencing the
4498 * The port identifier of the Ethernet device.
4500 * The queue on the Ethernet device from which the callback is to be removed.
4502 * User supplied callback created via rte_eth_add_rx_callback().
4505 * - 0: Success. Callback was removed.
4506 * - -ENODEV: If *port_id* is invalid.
4507 * - -ENOTSUP: Callback support is not available.
4508 * - -EINVAL: The queue_id is out of range, or the callback
4509 * is NULL or not found for the port/queue.
4511 int rte_eth_remove_rx_callback(uint16_t port_id, uint16_t queue_id,
4512 const struct rte_eth_rxtx_callback *user_cb);
4515 * Remove a Tx packet callback from a given port and queue.
4517 * This function is used to removed callbacks that were added to a NIC port
4518 * queue using rte_eth_add_tx_callback().
4520 * Note: the callback is removed from the callback list but it isn't freed
4521 * since the it may still be in use. The memory for the callback can be
4522 * subsequently freed back by the application by calling rte_free():
4524 * - Immediately - if the port is stopped, or the user knows that no
4525 * callbacks are in flight e.g. if called from the thread doing Rx/Tx
4528 * - After a short delay - where the delay is sufficient to allow any
4529 * in-flight callbacks to complete. Alternately, the RCU mechanism can be
4530 * used to detect when data plane threads have ceased referencing the
4534 * The port identifier of the Ethernet device.
4536 * The queue on the Ethernet device from which the callback is to be removed.
4538 * User supplied callback created via rte_eth_add_tx_callback().
4541 * - 0: Success. Callback was removed.
4542 * - -ENODEV: If *port_id* is invalid.
4543 * - -ENOTSUP: Callback support is not available.
4544 * - -EINVAL: The queue_id is out of range, or the callback
4545 * is NULL or not found for the port/queue.
4547 int rte_eth_remove_tx_callback(uint16_t port_id, uint16_t queue_id,
4548 const struct rte_eth_rxtx_callback *user_cb);
4551 * Retrieve information about given port's Rx queue.
4554 * The port identifier of the Ethernet device.
4556 * The Rx queue on the Ethernet device for which information
4557 * will be retrieved.
4559 * A pointer to a structure of type *rte_eth_rxq_info_info* to be filled with
4560 * the information of the Ethernet device.
4564 * - -ENODEV: If *port_id* is invalid.
4565 * - -ENOTSUP: routine is not supported by the device PMD.
4566 * - -EINVAL: The queue_id is out of range, or the queue
4569 int rte_eth_rx_queue_info_get(uint16_t port_id, uint16_t queue_id,
4570 struct rte_eth_rxq_info *qinfo);
4573 * Retrieve information about given port's Tx queue.
4576 * The port identifier of the Ethernet device.
4578 * The Tx queue on the Ethernet device for which information
4579 * will be retrieved.
4581 * A pointer to a structure of type *rte_eth_txq_info_info* to be filled with
4582 * the information of the Ethernet device.
4586 * - -ENODEV: If *port_id* is invalid.
4587 * - -ENOTSUP: routine is not supported by the device PMD.
4588 * - -EINVAL: The queue_id is out of range, or the queue
4591 int rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id,
4592 struct rte_eth_txq_info *qinfo);
4595 * Retrieve information about the Rx packet burst mode.
4598 * The port identifier of the Ethernet device.
4600 * The Rx queue on the Ethernet device for which information
4601 * will be retrieved.
4603 * A pointer to a structure of type *rte_eth_burst_mode* to be filled
4604 * with the information of the packet burst mode.
4608 * - -ENODEV: If *port_id* is invalid.
4609 * - -ENOTSUP: routine is not supported by the device PMD.
4610 * - -EINVAL: The queue_id is out of range.
4612 int rte_eth_rx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
4613 struct rte_eth_burst_mode *mode);
4616 * Retrieve information about the Tx packet burst mode.
4619 * The port identifier of the Ethernet device.
4621 * The Tx queue on the Ethernet device for which information
4622 * will be retrieved.
4624 * A pointer to a structure of type *rte_eth_burst_mode* to be filled
4625 * with the information of the packet burst mode.
4629 * - -ENODEV: If *port_id* is invalid.
4630 * - -ENOTSUP: routine is not supported by the device PMD.
4631 * - -EINVAL: The queue_id is out of range.
4633 int rte_eth_tx_burst_mode_get(uint16_t port_id, uint16_t queue_id,
4634 struct rte_eth_burst_mode *mode);
4638 * @b EXPERIMENTAL: this API may change without prior notice.
4640 * Retrieve the monitor condition for a given receive queue.
4643 * The port identifier of the Ethernet device.
4645 * The Rx queue on the Ethernet device for which information
4646 * will be retrieved.
4648 * The pointer to power-optimized monitoring condition structure.
4652 * -ENOTSUP: Operation not supported.
4653 * -EINVAL: Invalid parameters.
4654 * -ENODEV: Invalid port ID.
4657 int rte_eth_get_monitor_addr(uint16_t port_id, uint16_t queue_id,
4658 struct rte_power_monitor_cond *pmc);
4661 * Retrieve device registers and register attributes (number of registers and
4665 * The port identifier of the Ethernet device.
4667 * Pointer to rte_dev_reg_info structure to fill in. If info->data is
4668 * NULL the function fills in the width and length fields. If non-NULL
4669 * the registers are put into the buffer pointed at by the data field.
4671 * - (0) if successful.
4672 * - (-ENOTSUP) if hardware doesn't support.
4673 * - (-EINVAL) if bad parameter.
4674 * - (-ENODEV) if *port_id* invalid.
4675 * - (-EIO) if device is removed.
4676 * - others depends on the specific operations implementation.
4678 int rte_eth_dev_get_reg_info(uint16_t port_id, struct rte_dev_reg_info *info);
4681 * Retrieve size of device EEPROM
4684 * The port identifier of the Ethernet device.
4686 * - (>=0) EEPROM size if successful.
4687 * - (-ENOTSUP) if hardware doesn't support.
4688 * - (-ENODEV) if *port_id* invalid.
4689 * - (-EIO) if device is removed.
4690 * - others depends on the specific operations implementation.
4692 int rte_eth_dev_get_eeprom_length(uint16_t port_id);
4695 * Retrieve EEPROM and EEPROM attribute
4698 * The port identifier of the Ethernet device.
4700 * The template includes buffer for return EEPROM data and
4701 * EEPROM attributes to be filled.
4703 * - (0) if successful.
4704 * - (-ENOTSUP) if hardware doesn't support.
4705 * - (-EINVAL) if bad parameter.
4706 * - (-ENODEV) if *port_id* invalid.
4707 * - (-EIO) if device is removed.
4708 * - others depends on the specific operations implementation.
4710 int rte_eth_dev_get_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
4713 * Program EEPROM with provided data
4716 * The port identifier of the Ethernet device.
4718 * The template includes EEPROM data for programming and
4719 * EEPROM attributes to be filled
4721 * - (0) if successful.
4722 * - (-ENOTSUP) if hardware doesn't support.
4723 * - (-ENODEV) if *port_id* invalid.
4724 * - (-EINVAL) if bad parameter.
4725 * - (-EIO) if device is removed.
4726 * - others depends on the specific operations implementation.
4728 int rte_eth_dev_set_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info);
4732 * @b EXPERIMENTAL: this API may change without prior notice.
4734 * Retrieve the type and size of plugin module EEPROM
4737 * The port identifier of the Ethernet device.
4739 * The type and size of plugin module EEPROM.
4741 * - (0) if successful.
4742 * - (-ENOTSUP) if hardware doesn't support.
4743 * - (-ENODEV) if *port_id* invalid.
4744 * - (-EINVAL) if bad parameter.
4745 * - (-EIO) if device is removed.
4746 * - others depends on the specific operations implementation.
4750 rte_eth_dev_get_module_info(uint16_t port_id,
4751 struct rte_eth_dev_module_info *modinfo);
4755 * @b EXPERIMENTAL: this API may change without prior notice.
4757 * Retrieve the data of plugin module EEPROM
4760 * The port identifier of the Ethernet device.
4762 * The template includes the plugin module EEPROM attributes, and the
4763 * buffer for return plugin module EEPROM data.
4765 * - (0) if successful.
4766 * - (-ENOTSUP) if hardware doesn't support.
4767 * - (-EINVAL) if bad parameter.
4768 * - (-ENODEV) if *port_id* invalid.
4769 * - (-EIO) if device is removed.
4770 * - others depends on the specific operations implementation.
4774 rte_eth_dev_get_module_eeprom(uint16_t port_id,
4775 struct rte_dev_eeprom_info *info);
4778 * Set the list of multicast addresses to filter on an Ethernet device.
4781 * The port identifier of the Ethernet device.
4782 * @param mc_addr_set
4783 * The array of multicast addresses to set. Equal to NULL when the function
4784 * is invoked to flush the set of filtered addresses.
4786 * The number of multicast addresses in the *mc_addr_set* array. Equal to 0
4787 * when the function is invoked to flush the set of filtered addresses.
4789 * - (0) if successful.
4790 * - (-ENODEV) if *port_id* invalid.
4791 * - (-EIO) if device is removed.
4792 * - (-ENOTSUP) if PMD of *port_id* doesn't support multicast filtering.
4793 * - (-ENOSPC) if *port_id* has not enough multicast filtering resources.
4794 * - (-EINVAL) if bad parameter.
4796 int rte_eth_dev_set_mc_addr_list(uint16_t port_id,
4797 struct rte_ether_addr *mc_addr_set,
4798 uint32_t nb_mc_addr);
4801 * Enable IEEE1588/802.1AS timestamping for an Ethernet device.
4804 * The port identifier of the Ethernet device.
4808 * - -ENODEV: The port ID is invalid.
4809 * - -EIO: if device is removed.
4810 * - -ENOTSUP: The function is not supported by the Ethernet driver.
4812 int rte_eth_timesync_enable(uint16_t port_id);
4815 * Disable IEEE1588/802.1AS timestamping for an Ethernet device.
4818 * The port identifier of the Ethernet device.
4822 * - -ENODEV: The port ID is invalid.
4823 * - -EIO: if device is removed.
4824 * - -ENOTSUP: The function is not supported by the Ethernet driver.
4826 int rte_eth_timesync_disable(uint16_t port_id);
4829 * Read an IEEE1588/802.1AS Rx timestamp from an Ethernet device.
4832 * The port identifier of the Ethernet device.
4834 * Pointer to the timestamp struct.
4836 * Device specific flags. Used to pass the Rx timesync register index to
4837 * i40e. Unused in igb/ixgbe, pass 0 instead.
4841 * - -EINVAL: No timestamp is available.
4842 * - -ENODEV: The port ID is invalid.
4843 * - -EIO: if device is removed.
4844 * - -ENOTSUP: The function is not supported by the Ethernet driver.
4846 int rte_eth_timesync_read_rx_timestamp(uint16_t port_id,
4847 struct timespec *timestamp, uint32_t flags);
4850 * Read an IEEE1588/802.1AS Tx timestamp from an Ethernet device.
4853 * The port identifier of the Ethernet device.
4855 * Pointer to the timestamp struct.
4859 * - -EINVAL: No timestamp is available.
4860 * - -ENODEV: The port ID is invalid.
4861 * - -EIO: if device is removed.
4862 * - -ENOTSUP: The function is not supported by the Ethernet driver.
4864 int rte_eth_timesync_read_tx_timestamp(uint16_t port_id,
4865 struct timespec *timestamp);
4868 * Adjust the timesync clock on an Ethernet device.
4870 * This is usually used in conjunction with other Ethdev timesync functions to
4871 * synchronize the device time using the IEEE1588/802.1AS protocol.
4874 * The port identifier of the Ethernet device.
4876 * The adjustment in nanoseconds.
4880 * - -ENODEV: The port ID is invalid.
4881 * - -EIO: if device is removed.
4882 * - -ENOTSUP: The function is not supported by the Ethernet driver.
4884 int rte_eth_timesync_adjust_time(uint16_t port_id, int64_t delta);
4887 * Read the time from the timesync clock on an Ethernet device.
4889 * This is usually used in conjunction with other Ethdev timesync functions to
4890 * synchronize the device time using the IEEE1588/802.1AS protocol.
4893 * The port identifier of the Ethernet device.
4895 * Pointer to the timespec struct that holds the time.
4899 * - -EINVAL: Bad parameter.
4901 int rte_eth_timesync_read_time(uint16_t port_id, struct timespec *time);
4904 * Set the time of the timesync clock on an Ethernet device.
4906 * This is usually used in conjunction with other Ethdev timesync functions to
4907 * synchronize the device time using the IEEE1588/802.1AS protocol.
4910 * The port identifier of the Ethernet device.
4912 * Pointer to the timespec struct that holds the time.
4916 * - -EINVAL: No timestamp is available.
4917 * - -ENODEV: The port ID is invalid.
4918 * - -EIO: if device is removed.
4919 * - -ENOTSUP: The function is not supported by the Ethernet driver.
4921 int rte_eth_timesync_write_time(uint16_t port_id, const struct timespec *time);
4925 * @b EXPERIMENTAL: this API may change without prior notice.
4927 * Read the current clock counter of an Ethernet device
4929 * This returns the current raw clock value of an Ethernet device. It is
4930 * a raw amount of ticks, with no given time reference.
4931 * The value returned here is from the same clock than the one
4932 * filling timestamp field of Rx packets when using hardware timestamp
4933 * offload. Therefore it can be used to compute a precise conversion of
4934 * the device clock to the real time.
4936 * E.g, a simple heuristic to derivate the frequency would be:
4937 * uint64_t start, end;
4938 * rte_eth_read_clock(port, start);
4939 * rte_delay_ms(100);
4940 * rte_eth_read_clock(port, end);
4941 * double freq = (end - start) * 10;
4943 * Compute a common reference with:
4944 * uint64_t base_time_sec = current_time();
4945 * uint64_t base_clock;
4946 * rte_eth_read_clock(port, base_clock);
4948 * Then, convert the raw mbuf timestamp with:
4949 * base_time_sec + (double)(*timestamp_dynfield(mbuf) - base_clock) / freq;
4951 * This simple example will not provide a very good accuracy. One must
4952 * at least measure multiple times the frequency and do a regression.
4953 * To avoid deviation from the system time, the common reference can
4954 * be repeated from time to time. The integer division can also be
4955 * converted by a multiplication and a shift for better performance.
4958 * The port identifier of the Ethernet device.
4960 * Pointer to the uint64_t that holds the raw clock value.
4964 * - -ENODEV: The port ID is invalid.
4965 * - -ENOTSUP: The function is not supported by the Ethernet driver.
4966 * - -EINVAL: if bad parameter.
4970 rte_eth_read_clock(uint16_t port_id, uint64_t *clock);
4973 * Get the port ID from device name. The device name should be specified
4975 * - PCIe address (Domain:Bus:Device.Function), for example- 0000:2:00.0
4976 * - SoC device name, for example- fsl-gmac0
4977 * - vdev dpdk name, for example- net_[pcap0|null0|tap0]
4980 * pci address or name of the device
4982 * pointer to port identifier of the device
4984 * - (0) if successful and port_id is filled.
4985 * - (-ENODEV or -EINVAL) on failure.
4988 rte_eth_dev_get_port_by_name(const char *name, uint16_t *port_id);
4991 * Get the device name from port ID. The device name is specified as below:
4992 * - PCIe address (Domain:Bus:Device.Function), for example- 0000:02:00.0
4993 * - SoC device name, for example- fsl-gmac0
4994 * - vdev dpdk name, for example- net_[pcap0|null0|tun0|tap0]
4997 * Port identifier of the device.
4999 * Buffer of size RTE_ETH_NAME_MAX_LEN to store the name.
5001 * - (0) if successful.
5002 * - (-ENODEV) if *port_id* is invalid.
5003 * - (-EINVAL) on failure.
5006 rte_eth_dev_get_name_by_port(uint16_t port_id, char *name);
5009 * Check that numbers of Rx and Tx descriptors satisfy descriptors limits from
5010 * the Ethernet device information, otherwise adjust them to boundaries.
5013 * The port identifier of the Ethernet device.
5015 * A pointer to a uint16_t where the number of receive
5016 * descriptors stored.
5018 * A pointer to a uint16_t where the number of transmit
5019 * descriptors stored.
5021 * - (0) if successful.
5022 * - (-ENOTSUP, -ENODEV or -EINVAL) on failure.
5024 int rte_eth_dev_adjust_nb_rx_tx_desc(uint16_t port_id,
5025 uint16_t *nb_rx_desc,
5026 uint16_t *nb_tx_desc);
5029 * Test if a port supports specific mempool ops.
5032 * Port identifier of the Ethernet device.
5034 * The name of the pool operations to test.
5036 * - 0: best mempool ops choice for this port.
5037 * - 1: mempool ops are supported for this port.
5038 * - -ENOTSUP: mempool ops not supported for this port.
5039 * - -ENODEV: Invalid port Identifier.
5040 * - -EINVAL: Pool param is null.
5043 rte_eth_dev_pool_ops_supported(uint16_t port_id, const char *pool);
5046 * Get the security context for the Ethernet device.
5049 * Port identifier of the Ethernet device
5052 * - pointer to security context on success.
5055 rte_eth_dev_get_sec_ctx(uint16_t port_id);
5059 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
5061 * Query the device hairpin capabilities.
5064 * The port identifier of the Ethernet device.
5066 * Pointer to a structure that will hold the hairpin capabilities.
5068 * - (0) if successful.
5069 * - (-ENOTSUP) if hardware doesn't support.
5070 * - (-EINVAL) if bad parameter.
5073 int rte_eth_dev_hairpin_capability_get(uint16_t port_id,
5074 struct rte_eth_hairpin_cap *cap);
5078 * @b EXPERIMENTAL: this structure may change without prior notice.
5080 * Ethernet device representor ID range entry
5082 struct rte_eth_representor_range {
5083 enum rte_eth_representor_type type; /**< Representor type */
5084 int controller; /**< Controller index */
5085 int pf; /**< Physical function index */
5088 int vf; /**< VF start index */
5089 int sf; /**< SF start index */
5091 uint32_t id_base; /**< Representor ID start index */
5092 uint32_t id_end; /**< Representor ID end index */
5093 char name[RTE_DEV_NAME_MAX_LEN]; /**< Representor name */
5098 * @b EXPERIMENTAL: this structure may change without prior notice.
5100 * Ethernet device representor information
5102 struct rte_eth_representor_info {
5103 uint16_t controller; /**< Controller ID of caller device. */
5104 uint16_t pf; /**< Physical function ID of caller device. */
5105 uint32_t nb_ranges_alloc; /**< Size of the ranges array. */
5106 uint32_t nb_ranges; /**< Number of initialized ranges. */
5107 struct rte_eth_representor_range ranges[];/**< Representor ID range. */
5111 * Retrieve the representor info of the device.
5113 * Get device representor info to be able to calculate a unique
5114 * representor ID. @see rte_eth_representor_id_get helper.
5117 * The port identifier of the device.
5119 * A pointer to a representor info structure.
5120 * NULL to return number of range entries and allocate memory
5121 * for next call to store detail.
5122 * The number of ranges that were written into this structure
5123 * will be placed into its nb_ranges field. This number cannot be
5124 * larger than the nb_ranges_alloc that by the user before calling
5125 * this function. It can be smaller than the value returned by the
5126 * function, however.
5128 * - (-ENOTSUP) if operation is not supported.
5129 * - (-ENODEV) if *port_id* invalid.
5130 * - (-EIO) if device is removed.
5131 * - (>=0) number of available representor range entries.
5134 int rte_eth_representor_info_get(uint16_t port_id,
5135 struct rte_eth_representor_info *info);
5137 /** The NIC is able to deliver flag (if set) with packets to the PMD. */
5138 #define RTE_ETH_RX_METADATA_USER_FLAG RTE_BIT64(0)
5140 /** The NIC is able to deliver mark ID with packets to the PMD. */
5141 #define RTE_ETH_RX_METADATA_USER_MARK RTE_BIT64(1)
5143 /** The NIC is able to deliver tunnel ID with packets to the PMD. */
5144 #define RTE_ETH_RX_METADATA_TUNNEL_ID RTE_BIT64(2)
5148 * @b EXPERIMENTAL: this API may change without prior notice
5150 * Negotiate the NIC's ability to deliver specific kinds of metadata to the PMD.
5152 * Invoke this API before the first rte_eth_dev_configure() invocation
5153 * to let the PMD make preparations that are inconvenient to do later.
5155 * The negotiation process is as follows:
5157 * - the application requests features intending to use at least some of them;
5158 * - the PMD responds with the guaranteed subset of the requested feature set;
5159 * - the application can retry negotiation with another set of features;
5160 * - the application can pass zero to clear the negotiation result;
5161 * - the last negotiated result takes effect upon
5162 * the ethdev configure and start.
5165 * The PMD is supposed to first consider enabling the requested feature set
5166 * in its entirety. Only if it fails to do so, does it have the right to
5167 * respond with a smaller set of the originally requested features.
5170 * Return code (-ENOTSUP) does not necessarily mean that the requested
5171 * features are unsupported. In this case, the application should just
5172 * assume that these features can be used without prior negotiations.
5175 * Port (ethdev) identifier
5177 * @param[inout] features
5178 * Feature selection buffer
5181 * - (-EBUSY) if the port can't handle this in its current state;
5182 * - (-ENOTSUP) if the method itself is not supported by the PMD;
5183 * - (-ENODEV) if *port_id* is invalid;
5184 * - (-EINVAL) if *features* is NULL;
5185 * - (-EIO) if the device is removed;
5189 int rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features);
5191 #include <rte_ethdev_core.h>
5195 * Helper routine for rte_eth_rx_burst().
5196 * Should be called at exit from PMD's rte_eth_rx_bulk implementation.
5197 * Does necessary post-processing - invokes Rx callbacks if any, etc.
5200 * The port identifier of the Ethernet device.
5202 * The index of the receive queue from which to retrieve input packets.
5204 * The address of an array of pointers to *rte_mbuf* structures that
5205 * have been retrieved from the device.
5207 * The number of packets that were retrieved from the device.
5209 * The number of elements in @p rx_pkts array.
5211 * Opaque pointer of Rx queue callback related data.
5214 * The number of packets effectively supplied to the @p rx_pkts array.
5216 uint16_t rte_eth_call_rx_callbacks(uint16_t port_id, uint16_t queue_id,
5217 struct rte_mbuf **rx_pkts, uint16_t nb_rx, uint16_t nb_pkts,
5222 * Retrieve a burst of input packets from a receive queue of an Ethernet
5223 * device. The retrieved packets are stored in *rte_mbuf* structures whose
5224 * pointers are supplied in the *rx_pkts* array.
5226 * The rte_eth_rx_burst() function loops, parsing the Rx ring of the
5227 * receive queue, up to *nb_pkts* packets, and for each completed Rx
5228 * descriptor in the ring, it performs the following operations:
5230 * - Initialize the *rte_mbuf* data structure associated with the
5231 * Rx descriptor according to the information provided by the NIC into
5232 * that Rx descriptor.
5234 * - Store the *rte_mbuf* data structure into the next entry of the
5237 * - Replenish the Rx descriptor with a new *rte_mbuf* buffer
5238 * allocated from the memory pool associated with the receive queue at
5239 * initialization time.
5241 * When retrieving an input packet that was scattered by the controller
5242 * into multiple receive descriptors, the rte_eth_rx_burst() function
5243 * appends the associated *rte_mbuf* buffers to the first buffer of the
5246 * The rte_eth_rx_burst() function returns the number of packets
5247 * actually retrieved, which is the number of *rte_mbuf* data structures
5248 * effectively supplied into the *rx_pkts* array.
5249 * A return value equal to *nb_pkts* indicates that the Rx queue contained
5250 * at least *rx_pkts* packets, and this is likely to signify that other
5251 * received packets remain in the input queue. Applications implementing
5252 * a "retrieve as much received packets as possible" policy can check this
5253 * specific case and keep invoking the rte_eth_rx_burst() function until
5254 * a value less than *nb_pkts* is returned.
5256 * This receive method has the following advantages:
5258 * - It allows a run-to-completion network stack engine to retrieve and
5259 * to immediately process received packets in a fast burst-oriented
5260 * approach, avoiding the overhead of unnecessary intermediate packet
5261 * queue/dequeue operations.
5263 * - Conversely, it also allows an asynchronous-oriented processing
5264 * method to retrieve bursts of received packets and to immediately
5265 * queue them for further parallel processing by another logical core,
5266 * for instance. However, instead of having received packets being
5267 * individually queued by the driver, this approach allows the caller
5268 * of the rte_eth_rx_burst() function to queue a burst of retrieved
5269 * packets at a time and therefore dramatically reduce the cost of
5270 * enqueue/dequeue operations per packet.
5272 * - It allows the rte_eth_rx_burst() function of the driver to take
5273 * advantage of burst-oriented hardware features (CPU cache,
5274 * prefetch instructions, and so on) to minimize the number of CPU
5275 * cycles per packet.
5277 * To summarize, the proposed receive API enables many
5278 * burst-oriented optimizations in both synchronous and asynchronous
5279 * packet processing environments with no overhead in both cases.
5282 * Some drivers using vector instructions require that *nb_pkts* is
5283 * divisible by 4 or 8, depending on the driver implementation.
5285 * The rte_eth_rx_burst() function does not provide any error
5286 * notification to avoid the corresponding overhead. As a hint, the
5287 * upper-level application might check the status of the device link once
5288 * being systematically returned a 0 value for a given number of tries.
5291 * The port identifier of the Ethernet device.
5293 * The index of the receive queue from which to retrieve input packets.
5294 * The value must be in the range [0, nb_rx_queue - 1] previously supplied
5295 * to rte_eth_dev_configure().
5297 * The address of an array of pointers to *rte_mbuf* structures that
5298 * must be large enough to store *nb_pkts* pointers in it.
5300 * The maximum number of packets to retrieve.
5301 * The value must be divisible by 8 in order to work with any driver.
5303 * The number of packets actually retrieved, which is the number
5304 * of pointers to *rte_mbuf* structures effectively supplied to the
5307 static inline uint16_t
5308 rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id,
5309 struct rte_mbuf **rx_pkts, const uint16_t nb_pkts)
5312 struct rte_eth_fp_ops *p;
5315 #ifdef RTE_ETHDEV_DEBUG_RX
5316 if (port_id >= RTE_MAX_ETHPORTS ||
5317 queue_id >= RTE_MAX_QUEUES_PER_PORT) {
5319 "Invalid port_id=%u or queue_id=%u\n",
5325 /* fetch pointer to queue data */
5326 p = &rte_eth_fp_ops[port_id];
5327 qd = p->rxq.data[queue_id];
5329 #ifdef RTE_ETHDEV_DEBUG_RX
5330 RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
5333 RTE_ETHDEV_LOG(ERR, "Invalid Rx queue_id=%u for port_id=%u\n",
5339 nb_rx = p->rx_pkt_burst(qd, rx_pkts, nb_pkts);
5341 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
5345 /* __ATOMIC_RELEASE memory order was used when the
5346 * call back was inserted into the list.
5347 * Since there is a clear dependency between loading
5348 * cb and cb->fn/cb->next, __ATOMIC_ACQUIRE memory order is
5351 cb = __atomic_load_n((void **)&p->rxq.clbk[queue_id],
5353 if (unlikely(cb != NULL))
5354 nb_rx = rte_eth_call_rx_callbacks(port_id, queue_id,
5355 rx_pkts, nb_rx, nb_pkts, cb);
5359 rte_ethdev_trace_rx_burst(port_id, queue_id, (void **)rx_pkts, nb_rx);
5364 * Get the number of used descriptors of a Rx queue
5367 * The port identifier of the Ethernet device.
5369 * The queue ID on the specific port.
5371 * The number of used descriptors in the specific queue, or:
5372 * - (-ENODEV) if *port_id* is invalid.
5373 * (-EINVAL) if *queue_id* is invalid
5374 * (-ENOTSUP) if the device does not support this function
5377 rte_eth_rx_queue_count(uint16_t port_id, uint16_t queue_id)
5379 struct rte_eth_fp_ops *p;
5382 if (port_id >= RTE_MAX_ETHPORTS ||
5383 queue_id >= RTE_MAX_QUEUES_PER_PORT) {
5385 "Invalid port_id=%u or queue_id=%u\n",
5390 /* fetch pointer to queue data */
5391 p = &rte_eth_fp_ops[port_id];
5392 qd = p->rxq.data[queue_id];
5394 RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
5395 RTE_FUNC_PTR_OR_ERR_RET(*p->rx_queue_count, -ENOTSUP);
5399 return (int)(*p->rx_queue_count)(qd);
5402 /**@{@name Rx hardware descriptor states
5403 * @see rte_eth_rx_descriptor_status
5405 #define RTE_ETH_RX_DESC_AVAIL 0 /**< Desc available for hw. */
5406 #define RTE_ETH_RX_DESC_DONE 1 /**< Desc done, filled by hw. */
5407 #define RTE_ETH_RX_DESC_UNAVAIL 2 /**< Desc used by driver or hw. */
5411 * Check the status of a Rx descriptor in the queue
5413 * It should be called in a similar context than the Rx function:
5414 * - on a dataplane core
5415 * - not concurrently on the same queue
5417 * Since it's a dataplane function, no check is performed on port_id and
5418 * queue_id. The caller must therefore ensure that the port is enabled
5419 * and the queue is configured and running.
5421 * Note: accessing to a random descriptor in the ring may trigger cache
5422 * misses and have a performance impact.
5425 * A valid port identifier of the Ethernet device which.
5427 * A valid Rx queue identifier on this port.
5429 * The offset of the descriptor starting from tail (0 is the next
5430 * packet to be received by the driver).
5433 * - (RTE_ETH_RX_DESC_AVAIL): Descriptor is available for the hardware to
5435 * - (RTE_ETH_RX_DESC_DONE): Descriptor is done, it is filled by hw, but
5436 * not yet processed by the driver (i.e. in the receive queue).
5437 * - (RTE_ETH_RX_DESC_UNAVAIL): Descriptor is unavailable, either hold by
5438 * the driver and not yet returned to hw, or reserved by the hw.
5439 * - (-EINVAL) bad descriptor offset.
5440 * - (-ENOTSUP) if the device does not support this function.
5441 * - (-ENODEV) bad port or queue (only if compiled with debug).
5444 rte_eth_rx_descriptor_status(uint16_t port_id, uint16_t queue_id,
5447 struct rte_eth_fp_ops *p;
5450 #ifdef RTE_ETHDEV_DEBUG_RX
5451 if (port_id >= RTE_MAX_ETHPORTS ||
5452 queue_id >= RTE_MAX_QUEUES_PER_PORT) {
5454 "Invalid port_id=%u or queue_id=%u\n",
5460 /* fetch pointer to queue data */
5461 p = &rte_eth_fp_ops[port_id];
5462 qd = p->rxq.data[queue_id];
5464 #ifdef RTE_ETHDEV_DEBUG_RX
5465 RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
5469 RTE_FUNC_PTR_OR_ERR_RET(*p->rx_descriptor_status, -ENOTSUP);
5470 return (*p->rx_descriptor_status)(qd, offset);
5473 /**@{@name Tx hardware descriptor states
5474 * @see rte_eth_tx_descriptor_status
5476 #define RTE_ETH_TX_DESC_FULL 0 /**< Desc filled for hw, waiting xmit. */
5477 #define RTE_ETH_TX_DESC_DONE 1 /**< Desc done, packet is transmitted. */
5478 #define RTE_ETH_TX_DESC_UNAVAIL 2 /**< Desc used by driver or hw. */
5482 * Check the status of a Tx descriptor in the queue.
5484 * It should be called in a similar context than the Tx function:
5485 * - on a dataplane core
5486 * - not concurrently on the same queue
5488 * Since it's a dataplane function, no check is performed on port_id and
5489 * queue_id. The caller must therefore ensure that the port is enabled
5490 * and the queue is configured and running.
5492 * Note: accessing to a random descriptor in the ring may trigger cache
5493 * misses and have a performance impact.
5496 * A valid port identifier of the Ethernet device which.
5498 * A valid Tx queue identifier on this port.
5500 * The offset of the descriptor starting from tail (0 is the place where
5501 * the next packet will be send).
5504 * - (RTE_ETH_TX_DESC_FULL) Descriptor is being processed by the hw, i.e.
5505 * in the transmit queue.
5506 * - (RTE_ETH_TX_DESC_DONE) Hardware is done with this descriptor, it can
5507 * be reused by the driver.
5508 * - (RTE_ETH_TX_DESC_UNAVAIL): Descriptor is unavailable, reserved by the
5509 * driver or the hardware.
5510 * - (-EINVAL) bad descriptor offset.
5511 * - (-ENOTSUP) if the device does not support this function.
5512 * - (-ENODEV) bad port or queue (only if compiled with debug).
5514 static inline int rte_eth_tx_descriptor_status(uint16_t port_id,
5515 uint16_t queue_id, uint16_t offset)
5517 struct rte_eth_fp_ops *p;
5520 #ifdef RTE_ETHDEV_DEBUG_TX
5521 if (port_id >= RTE_MAX_ETHPORTS ||
5522 queue_id >= RTE_MAX_QUEUES_PER_PORT) {
5524 "Invalid port_id=%u or queue_id=%u\n",
5530 /* fetch pointer to queue data */
5531 p = &rte_eth_fp_ops[port_id];
5532 qd = p->txq.data[queue_id];
5534 #ifdef RTE_ETHDEV_DEBUG_TX
5535 RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
5539 RTE_FUNC_PTR_OR_ERR_RET(*p->tx_descriptor_status, -ENOTSUP);
5540 return (*p->tx_descriptor_status)(qd, offset);
5545 * Helper routine for rte_eth_tx_burst().
5546 * Should be called before entry PMD's rte_eth_tx_bulk implementation.
5547 * Does necessary pre-processing - invokes Tx callbacks if any, etc.
5550 * The port identifier of the Ethernet device.
5552 * The index of the transmit queue through which output packets must be
5555 * The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
5556 * which contain the output packets.
5558 * The maximum number of packets to transmit.
5560 * The number of output packets to transmit.
5562 uint16_t rte_eth_call_tx_callbacks(uint16_t port_id, uint16_t queue_id,
5563 struct rte_mbuf **tx_pkts, uint16_t nb_pkts, void *opaque);
5566 * Send a burst of output packets on a transmit queue of an Ethernet device.
5568 * The rte_eth_tx_burst() function is invoked to transmit output packets
5569 * on the output queue *queue_id* of the Ethernet device designated by its
5571 * The *nb_pkts* parameter is the number of packets to send which are
5572 * supplied in the *tx_pkts* array of *rte_mbuf* structures, each of them
5573 * allocated from a pool created with rte_pktmbuf_pool_create().
5574 * The rte_eth_tx_burst() function loops, sending *nb_pkts* packets,
5575 * up to the number of transmit descriptors available in the Tx ring of the
5577 * For each packet to send, the rte_eth_tx_burst() function performs
5578 * the following operations:
5580 * - Pick up the next available descriptor in the transmit ring.
5582 * - Free the network buffer previously sent with that descriptor, if any.
5584 * - Initialize the transmit descriptor with the information provided
5585 * in the *rte_mbuf data structure.
5587 * In the case of a segmented packet composed of a list of *rte_mbuf* buffers,
5588 * the rte_eth_tx_burst() function uses several transmit descriptors
5591 * The rte_eth_tx_burst() function returns the number of packets it
5592 * actually sent. A return value equal to *nb_pkts* means that all packets
5593 * have been sent, and this is likely to signify that other output packets
5594 * could be immediately transmitted again. Applications that implement a
5595 * "send as many packets to transmit as possible" policy can check this
5596 * specific case and keep invoking the rte_eth_tx_burst() function until
5597 * a value less than *nb_pkts* is returned.
5599 * It is the responsibility of the rte_eth_tx_burst() function to
5600 * transparently free the memory buffers of packets previously sent.
5601 * This feature is driven by the *tx_free_thresh* value supplied to the
5602 * rte_eth_dev_configure() function at device configuration time.
5603 * When the number of free Tx descriptors drops below this threshold, the
5604 * rte_eth_tx_burst() function must [attempt to] free the *rte_mbuf* buffers
5605 * of those packets whose transmission was effectively completed.
5607 * If the PMD is RTE_ETH_TX_OFFLOAD_MT_LOCKFREE capable, multiple threads can
5608 * invoke this function concurrently on the same Tx queue without SW lock.
5609 * @see rte_eth_dev_info_get, struct rte_eth_txconf::offloads
5611 * @see rte_eth_tx_prepare to perform some prior checks or adjustments
5615 * The port identifier of the Ethernet device.
5617 * The index of the transmit queue through which output packets must be
5619 * The value must be in the range [0, nb_tx_queue - 1] previously supplied
5620 * to rte_eth_dev_configure().
5622 * The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
5623 * which contain the output packets.
5625 * The maximum number of packets to transmit.
5627 * The number of output packets actually stored in transmit descriptors of
5628 * the transmit ring. The return value can be less than the value of the
5629 * *tx_pkts* parameter when the transmit ring is full or has been filled up.
5631 static inline uint16_t
5632 rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id,
5633 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
5635 struct rte_eth_fp_ops *p;
5638 #ifdef RTE_ETHDEV_DEBUG_TX
5639 if (port_id >= RTE_MAX_ETHPORTS ||
5640 queue_id >= RTE_MAX_QUEUES_PER_PORT) {
5642 "Invalid port_id=%u or queue_id=%u\n",
5648 /* fetch pointer to queue data */
5649 p = &rte_eth_fp_ops[port_id];
5650 qd = p->txq.data[queue_id];
5652 #ifdef RTE_ETHDEV_DEBUG_TX
5653 RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
5656 RTE_ETHDEV_LOG(ERR, "Invalid Tx queue_id=%u for port_id=%u\n",
5662 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
5666 /* __ATOMIC_RELEASE memory order was used when the
5667 * call back was inserted into the list.
5668 * Since there is a clear dependency between loading
5669 * cb and cb->fn/cb->next, __ATOMIC_ACQUIRE memory order is
5672 cb = __atomic_load_n((void **)&p->txq.clbk[queue_id],
5674 if (unlikely(cb != NULL))
5675 nb_pkts = rte_eth_call_tx_callbacks(port_id, queue_id,
5676 tx_pkts, nb_pkts, cb);
5680 nb_pkts = p->tx_pkt_burst(qd, tx_pkts, nb_pkts);
5682 rte_ethdev_trace_tx_burst(port_id, queue_id, (void **)tx_pkts, nb_pkts);
5687 * Process a burst of output packets on a transmit queue of an Ethernet device.
5689 * The rte_eth_tx_prepare() function is invoked to prepare output packets to be
5690 * transmitted on the output queue *queue_id* of the Ethernet device designated
5692 * The *nb_pkts* parameter is the number of packets to be prepared which are
5693 * supplied in the *tx_pkts* array of *rte_mbuf* structures, each of them
5694 * allocated from a pool created with rte_pktmbuf_pool_create().
5695 * For each packet to send, the rte_eth_tx_prepare() function performs
5696 * the following operations:
5698 * - Check if packet meets devices requirements for Tx offloads.
5700 * - Check limitations about number of segments.
5702 * - Check additional requirements when debug is enabled.
5704 * - Update and/or reset required checksums when Tx offload is set for packet.
5706 * Since this function can modify packet data, provided mbufs must be safely
5707 * writable (e.g. modified data cannot be in shared segment).
5709 * The rte_eth_tx_prepare() function returns the number of packets ready to be
5710 * sent. A return value equal to *nb_pkts* means that all packets are valid and
5711 * ready to be sent, otherwise stops processing on the first invalid packet and
5712 * leaves the rest packets untouched.
5714 * When this functionality is not implemented in the driver, all packets are
5715 * are returned untouched.
5718 * The port identifier of the Ethernet device.
5719 * The value must be a valid port ID.
5721 * The index of the transmit queue through which output packets must be
5723 * The value must be in the range [0, nb_tx_queue - 1] previously supplied
5724 * to rte_eth_dev_configure().
5726 * The address of an array of *nb_pkts* pointers to *rte_mbuf* structures
5727 * which contain the output packets.
5729 * The maximum number of packets to process.
5731 * The number of packets correct and ready to be sent. The return value can be
5732 * less than the value of the *tx_pkts* parameter when some packet doesn't
5733 * meet devices requirements with rte_errno set appropriately:
5734 * - EINVAL: offload flags are not correctly set
5735 * - ENOTSUP: the offload feature is not supported by the hardware
5736 * - ENODEV: if *port_id* is invalid (with debug enabled only)
5740 #ifndef RTE_ETHDEV_TX_PREPARE_NOOP
5742 static inline uint16_t
5743 rte_eth_tx_prepare(uint16_t port_id, uint16_t queue_id,
5744 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
5746 struct rte_eth_fp_ops *p;
5749 #ifdef RTE_ETHDEV_DEBUG_TX
5750 if (port_id >= RTE_MAX_ETHPORTS ||
5751 queue_id >= RTE_MAX_QUEUES_PER_PORT) {
5753 "Invalid port_id=%u or queue_id=%u\n",
5760 /* fetch pointer to queue data */
5761 p = &rte_eth_fp_ops[port_id];
5762 qd = p->txq.data[queue_id];
5764 #ifdef RTE_ETHDEV_DEBUG_TX
5765 if (!rte_eth_dev_is_valid_port(port_id)) {
5766 RTE_ETHDEV_LOG(ERR, "Invalid Tx port_id=%u\n", port_id);
5771 RTE_ETHDEV_LOG(ERR, "Invalid Tx queue_id=%u for port_id=%u\n",
5778 if (!p->tx_pkt_prepare)
5781 return p->tx_pkt_prepare(qd, tx_pkts, nb_pkts);
5787 * Native NOOP operation for compilation targets which doesn't require any
5788 * preparations steps, and functional NOOP may introduce unnecessary performance
5791 * Generally this is not a good idea to turn it on globally and didn't should
5792 * be used if behavior of tx_preparation can change.
5795 static inline uint16_t
5796 rte_eth_tx_prepare(__rte_unused uint16_t port_id,
5797 __rte_unused uint16_t queue_id,
5798 __rte_unused struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
5806 * Send any packets queued up for transmission on a port and HW queue
5808 * This causes an explicit flush of packets previously buffered via the
5809 * rte_eth_tx_buffer() function. It returns the number of packets successfully
5810 * sent to the NIC, and calls the error callback for any unsent packets. Unless
5811 * explicitly set up otherwise, the default callback simply frees the unsent
5812 * packets back to the owning mempool.
5815 * The port identifier of the Ethernet device.
5817 * The index of the transmit queue through which output packets must be
5819 * The value must be in the range [0, nb_tx_queue - 1] previously supplied
5820 * to rte_eth_dev_configure().
5822 * Buffer of packets to be transmit.
5824 * The number of packets successfully sent to the Ethernet device. The error
5825 * callback is called for any packets which could not be sent.
5827 static inline uint16_t
5828 rte_eth_tx_buffer_flush(uint16_t port_id, uint16_t queue_id,
5829 struct rte_eth_dev_tx_buffer *buffer)
5832 uint16_t to_send = buffer->length;
5837 sent = rte_eth_tx_burst(port_id, queue_id, buffer->pkts, to_send);
5841 /* All packets sent, or to be dealt with by callback below */
5842 if (unlikely(sent != to_send))
5843 buffer->error_callback(&buffer->pkts[sent],
5844 (uint16_t)(to_send - sent),
5845 buffer->error_userdata);
5851 * Buffer a single packet for future transmission on a port and queue
5853 * This function takes a single mbuf/packet and buffers it for later
5854 * transmission on the particular port and queue specified. Once the buffer is
5855 * full of packets, an attempt will be made to transmit all the buffered
5856 * packets. In case of error, where not all packets can be transmitted, a
5857 * callback is called with the unsent packets as a parameter. If no callback
5858 * is explicitly set up, the unsent packets are just freed back to the owning
5859 * mempool. The function returns the number of packets actually sent i.e.
5860 * 0 if no buffer flush occurred, otherwise the number of packets successfully
5864 * The port identifier of the Ethernet device.
5866 * The index of the transmit queue through which output packets must be
5868 * The value must be in the range [0, nb_tx_queue - 1] previously supplied
5869 * to rte_eth_dev_configure().
5871 * Buffer used to collect packets to be sent.
5873 * Pointer to the packet mbuf to be sent.
5875 * 0 = packet has been buffered for later transmission
5876 * N > 0 = packet has been buffered, and the buffer was subsequently flushed,
5877 * causing N packets to be sent, and the error callback to be called for
5880 static __rte_always_inline uint16_t
5881 rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id,
5882 struct rte_eth_dev_tx_buffer *buffer, struct rte_mbuf *tx_pkt)
5884 buffer->pkts[buffer->length++] = tx_pkt;
5885 if (buffer->length < buffer->size)
5888 return rte_eth_tx_buffer_flush(port_id, queue_id, buffer);
5895 #endif /* _RTE_ETHDEV_H_ */