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