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