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