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