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