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