1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2017 Intel Corporation 3 */ 4 5 #ifndef _RTE_ETHDEV_DRIVER_H_ 6 #define _RTE_ETHDEV_DRIVER_H_ 7 8 /** 9 * @file 10 * 11 * RTE Ethernet Device PMD API 12 * 13 * These APIs for the use from Ethernet drivers, user applications shouldn't 14 * use them. 15 */ 16 17 #include <pthread.h> 18 19 #include <dev_driver.h> 20 #include <rte_compat.h> 21 #include <rte_ethdev.h> 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /** 28 * @internal 29 * Structure used to hold information about the callbacks to be called for a 30 * queue on Rx and Tx. 31 */ 32 struct rte_eth_rxtx_callback { 33 RTE_ATOMIC(struct rte_eth_rxtx_callback *) next; 34 union{ 35 rte_rx_callback_fn rx; 36 rte_tx_callback_fn tx; 37 } fn; 38 void *param; 39 }; 40 41 /** 42 * @internal 43 * The generic data structure associated with each Ethernet device. 44 * 45 * Pointers to burst-oriented packet receive and transmit functions are 46 * located at the beginning of the structure, along with the pointer to 47 * where all the data elements for the particular device are stored in shared 48 * memory. This split allows the function pointer and driver data to be per- 49 * process, while the actual configuration data for the device is shared. 50 */ 51 struct __rte_cache_aligned rte_eth_dev { 52 eth_rx_burst_t rx_pkt_burst; /**< Pointer to PMD receive function */ 53 eth_tx_burst_t tx_pkt_burst; /**< Pointer to PMD transmit function */ 54 55 /** Pointer to PMD transmit prepare function */ 56 eth_tx_prep_t tx_pkt_prepare; 57 /** Get the number of used Rx descriptors */ 58 eth_rx_queue_count_t rx_queue_count; 59 /** Check the status of a Rx descriptor */ 60 eth_rx_descriptor_status_t rx_descriptor_status; 61 /** Get the number of used Tx descriptors */ 62 eth_tx_queue_count_t tx_queue_count; 63 /** Check the status of a Tx descriptor */ 64 eth_tx_descriptor_status_t tx_descriptor_status; 65 /** Pointer to PMD transmit mbufs reuse function */ 66 eth_recycle_tx_mbufs_reuse_t recycle_tx_mbufs_reuse; 67 /** Pointer to PMD receive descriptors refill function */ 68 eth_recycle_rx_descriptors_refill_t recycle_rx_descriptors_refill; 69 70 /** 71 * Device data that is shared between primary and secondary processes 72 */ 73 struct rte_eth_dev_data *data; 74 void *process_private; /**< Pointer to per-process device data */ 75 const struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */ 76 /** Fast path flow API functions exported by PMD */ 77 const struct rte_flow_fp_ops *flow_fp_ops; 78 struct rte_device *device; /**< Backing device */ 79 struct rte_intr_handle *intr_handle; /**< Device interrupt handle */ 80 81 /** User application callbacks for NIC interrupts */ 82 struct rte_eth_dev_cb_list link_intr_cbs; 83 /** 84 * User-supplied functions called from rx_burst to post-process 85 * received packets before passing them to the user 86 */ 87 RTE_ATOMIC(struct rte_eth_rxtx_callback *) post_rx_burst_cbs[RTE_MAX_QUEUES_PER_PORT]; 88 /** 89 * User-supplied functions called from tx_burst to pre-process 90 * received packets before passing them to the driver for transmission 91 */ 92 RTE_ATOMIC(struct rte_eth_rxtx_callback *) pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT]; 93 94 enum rte_eth_dev_state state; /**< Flag indicating the port state */ 95 void *security_ctx; /**< Context for security ops */ 96 }; 97 98 struct rte_eth_dev_sriov; 99 struct rte_eth_dev_owner; 100 101 /** 102 * @internal 103 * The data part, with no function pointers, associated with each Ethernet 104 * device. This structure is safe to place in shared memory to be common 105 * among different processes in a multi-process configuration. 106 */ 107 struct __rte_cache_aligned rte_eth_dev_data { 108 char name[RTE_ETH_NAME_MAX_LEN]; /**< Unique identifier name */ 109 110 void **rx_queues; /**< Array of pointers to Rx queues */ 111 void **tx_queues; /**< Array of pointers to Tx queues */ 112 uint16_t nb_rx_queues; /**< Number of Rx queues */ 113 uint16_t nb_tx_queues; /**< Number of Tx queues */ 114 115 struct rte_eth_dev_sriov sriov; /**< SRIOV data */ 116 117 /** PMD-specific private data. @see rte_eth_dev_release_port() */ 118 void *dev_private; 119 120 struct rte_eth_link dev_link; /**< Link-level information & status */ 121 struct rte_eth_conf dev_conf; /**< Configuration applied to device */ 122 uint16_t mtu; /**< Maximum Transmission Unit */ 123 124 /** Common Rx buffer size handled by all queues */ 125 uint32_t min_rx_buf_size; 126 127 uint64_t rx_mbuf_alloc_failed; /**< Rx ring mbuf allocation failures */ 128 129 /** 130 * Device Ethernet link addresses. 131 * All entries are unique. 132 * The first entry (index zero) is the default address. 133 */ 134 struct rte_ether_addr *mac_addrs; 135 /** Bitmap associating MAC addresses to pools */ 136 uint64_t mac_pool_sel[RTE_ETH_NUM_RECEIVE_MAC_ADDR]; 137 /** 138 * Device Ethernet MAC addresses of hash filtering. 139 * @see rte_eth_dev_release_port() 140 */ 141 struct rte_ether_addr *hash_mac_addrs; 142 143 uint16_t port_id; /**< Device [external] port identifier */ 144 145 __extension__ 146 uint8_t /** Rx promiscuous mode ON(1) / OFF(0) */ 147 promiscuous : 1, 148 /** Rx of scattered packets is ON(1) / OFF(0) */ 149 scattered_rx : 1, 150 /** Rx all multicast mode ON(1) / OFF(0) */ 151 all_multicast : 1, 152 /** Device state: STARTED(1) / STOPPED(0) */ 153 dev_started : 1, 154 /** Rx LRO is ON(1) / OFF(0) */ 155 lro : 1, 156 /** 157 * Indicates whether the device is configured: 158 * CONFIGURED(1) / NOT CONFIGURED(0) 159 */ 160 dev_configured : 1, 161 /** 162 * Indicates whether the flow engine is configured: 163 * CONFIGURED(1) / NOT CONFIGURED(0) 164 */ 165 flow_configured : 1; 166 167 /** Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0) */ 168 uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT]; 169 /** Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0) */ 170 uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT]; 171 172 uint32_t dev_flags; /**< Capabilities */ 173 int numa_node; /**< NUMA node connection */ 174 175 /** VLAN filter configuration */ 176 struct rte_vlan_filter_conf vlan_filter_conf; 177 178 struct rte_eth_dev_owner owner; /**< The port owner */ 179 180 /** 181 * Switch-specific identifier. 182 * Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags. 183 */ 184 uint16_t representor_id; 185 /** 186 * Port ID of the backing device. 187 * This device will be used to query representor info and calculate 188 * representor IDs. Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags. 189 */ 190 uint16_t backer_port_id; 191 192 pthread_mutex_t flow_ops_mutex; /**< rte_flow ops mutex */ 193 }; 194 195 /** 196 * @internal 197 * The pool of *rte_eth_dev* structures. The size of the pool 198 * is configured at compile-time in the <rte_ethdev.c> file. 199 */ 200 extern struct rte_eth_dev rte_eth_devices[]; 201 202 /** @internal Declaration of the hairpin peer queue information structure. */ 203 struct rte_hairpin_peer_info; 204 205 /* 206 * Definitions of all functions exported by an Ethernet driver through the 207 * generic structure of type *eth_dev_ops* supplied in the *rte_eth_dev* 208 * structure associated with an Ethernet device. 209 */ 210 211 /** @internal Ethernet device configuration. */ 212 typedef int (*eth_dev_configure_t)(struct rte_eth_dev *dev); 213 214 /** @internal Function used to start a configured Ethernet device. */ 215 typedef int (*eth_dev_start_t)(struct rte_eth_dev *dev); 216 217 /** @internal Function used to stop a configured Ethernet device. */ 218 typedef int (*eth_dev_stop_t)(struct rte_eth_dev *dev); 219 220 /** @internal Function used to link up a configured Ethernet device. */ 221 typedef int (*eth_dev_set_link_up_t)(struct rte_eth_dev *dev); 222 223 /** @internal Function used to link down a configured Ethernet device. */ 224 typedef int (*eth_dev_set_link_down_t)(struct rte_eth_dev *dev); 225 226 /** @internal Function used to close a configured Ethernet device. */ 227 typedef int (*eth_dev_close_t)(struct rte_eth_dev *dev); 228 229 /** @internal Function used to reset a configured Ethernet device. */ 230 typedef int (*eth_dev_reset_t)(struct rte_eth_dev *dev); 231 232 /** @internal Function used to detect an Ethernet device removal. */ 233 typedef int (*eth_is_removed_t)(struct rte_eth_dev *dev); 234 235 /** 236 * @internal 237 * Function used to enable the Rx promiscuous mode of an Ethernet device. 238 * 239 * @param dev 240 * ethdev handle of port. 241 * 242 * @return 243 * Negative errno value on error, 0 on success. 244 * 245 * @retval 0 246 * Success, promiscuous mode is enabled. 247 * @retval -ENOTSUP 248 * Promiscuous mode is not supported. 249 * @retval -ENODEV 250 * Device is gone. 251 * @retval -E_RTE_SECONDARY 252 * Function was called from a secondary process instance and not supported. 253 * @retval -ETIMEDOUT 254 * Attempt to enable promiscuous mode failed because of timeout. 255 * @retval -EAGAIN 256 * Failed to enable promiscuous mode. 257 */ 258 typedef int (*eth_promiscuous_enable_t)(struct rte_eth_dev *dev); 259 260 /** 261 * @internal 262 * Function used to disable the Rx promiscuous mode of an Ethernet device. 263 * 264 * @param dev 265 * ethdev handle of port. 266 * 267 * @return 268 * Negative errno value on error, 0 on success. 269 * 270 * @retval 0 271 * Success, promiscuous mode is disabled. 272 * @retval -ENOTSUP 273 * Promiscuous mode disabling is not supported. 274 * @retval -ENODEV 275 * Device is gone. 276 * @retval -E_RTE_SECONDARY 277 * Function was called from a secondary process instance and not supported. 278 * @retval -ETIMEDOUT 279 * Attempt to disable promiscuous mode failed because of timeout. 280 * @retval -EAGAIN 281 * Failed to disable promiscuous mode. 282 */ 283 typedef int (*eth_promiscuous_disable_t)(struct rte_eth_dev *dev); 284 285 /** 286 * @internal 287 * Enable the receipt of all multicast packets by an Ethernet device. 288 * 289 * @param dev 290 * ethdev handle of port. 291 * 292 * @return 293 * Negative errno value on error, 0 on success. 294 * 295 * @retval 0 296 * Success, all-multicast mode is enabled. 297 * @retval -ENOTSUP 298 * All-multicast mode is not supported. 299 * @retval -ENODEV 300 * Device is gone. 301 * @retval -E_RTE_SECONDARY 302 * Function was called from a secondary process instance and not supported. 303 * @retval -ETIMEDOUT 304 * Attempt to enable all-multicast mode failed because of timeout. 305 * @retval -EAGAIN 306 * Failed to enable all-multicast mode. 307 */ 308 typedef int (*eth_allmulticast_enable_t)(struct rte_eth_dev *dev); 309 310 /** 311 * @internal 312 * Disable the receipt of all multicast packets by an Ethernet device. 313 * 314 * @param dev 315 * ethdev handle of port. 316 * 317 * @return 318 * Negative errno value on error, 0 on success. 319 * 320 * @retval 0 321 * Success, all-multicast mode is disabled. 322 * @retval -ENOTSUP 323 * All-multicast mode disabling is not supported. 324 * @retval -ENODEV 325 * Device is gone. 326 * @retval -E_RTE_SECONDARY 327 * Function was called from a secondary process instance and not supported. 328 * @retval -ETIMEDOUT 329 * Attempt to disable all-multicast mode failed because of timeout. 330 * @retval -EAGAIN 331 * Failed to disable all-multicast mode. 332 */ 333 typedef int (*eth_allmulticast_disable_t)(struct rte_eth_dev *dev); 334 335 /** 336 * @internal 337 * Get link speed, duplex mode and state (up/down) of an Ethernet device. 338 */ 339 typedef int (*eth_link_update_t)(struct rte_eth_dev *dev, 340 int wait_to_complete); 341 342 /** 343 * @internal 344 * Get number of current active lanes 345 * 346 * @param dev 347 * ethdev handle of port. 348 * @param speed_lanes 349 * Number of active lanes that the link has trained up. This information 350 * is displayed for Autonegotiated or Fixed speed trained link. 351 * @return 352 * Negative errno value on error, 0 on success. 353 * 354 * @retval 0 355 * Success, get speed_lanes data success. 356 * @retval -ENOTSUP 357 * Operation is not supported. 358 * @retval -EIO 359 * Device is removed. 360 */ 361 typedef int (*eth_speed_lanes_get_t)(struct rte_eth_dev *dev, uint32_t *speed_lanes); 362 363 /** 364 * @internal 365 * Set speed lanes supported by the NIC. This configuration is applicable only when 366 * fix speed is already configured and or will be configured. This api requires the 367 * port be stopped, since driver has to re-configure PHY with fixed speed and lanes. 368 * If no lanes are configured prior or after "port config X speed Y duplex Z", the 369 * driver will choose the default lane for that speed to bring up the link. 370 * 371 * @param dev 372 * ethdev handle of port. 373 * @param speed_lanes 374 * Non-negative number of lanes 375 * 376 * @return 377 * Negative errno value on error, 0 on success. 378 * 379 * @retval 0 380 * Success, set lanes success. 381 * @retval -ENOTSUP 382 * Operation is not supported. 383 * @retval -EINVAL 384 * Unsupported number of lanes for fixed speed requested. 385 * @retval -EIO 386 * Device is removed. 387 */ 388 typedef int (*eth_speed_lanes_set_t)(struct rte_eth_dev *dev, uint32_t speed_lanes); 389 390 /** 391 * @internal 392 * Get supported link speed lanes capability. The driver returns number of lanes 393 * supported per speed in the form of lanes capability bitmap per speed. 394 * 395 * @param speed_lanes_capa 396 * A pointer to num of rte_eth_speed_lanes_capa struct array which carries the 397 * bit map of lanes supported per speed. The number of supported speeds is the 398 * size of this speed_lanes_capa table. In link up condition, only active supported 399 * speeds lanes bitmap information will be displayed. In link down condition, all 400 * the supported speeds and its supported lanes bitmap would be fetched and displayed. 401 * 402 * This api is overloaded to fetch the size of the speed_lanes_capa array if 403 * testpmd calls the driver with speed_lanes_capa = NULL and num = 0 404 * 405 * @param num 406 * Number of elements in a speed_speed_lanes_capa array. This num is equal to the 407 * number of supported speeds by the controller. This value will vary in link up 408 * and link down condition. num is updated by the driver if speed_lanes_capa is NULL. 409 * 410 * @return 411 * Negative errno value on error, positive value on success. 412 * 413 * @retval positive value 414 * A non-negative value lower or equal to num: success. The return value 415 * is the number of entries filled in the speed lanes array. 416 * A non-negative value higher than num: error, the given speed lanes capa array 417 * is too small. The return value corresponds to the num that should 418 * be given to succeed. The entries in the speed lanes capa array are not valid 419 * and shall not be used by the caller. 420 * @retval -ENOTSUP 421 * Operation is not supported. 422 * @retval -EINVAL 423 * *num* or *speed_lanes_capa* invalid. 424 */ 425 typedef int (*eth_speed_lanes_get_capability_t)(struct rte_eth_dev *dev, 426 struct rte_eth_speed_lanes_capa *speed_lanes_capa, 427 unsigned int num); 428 429 /** @internal Get global I/O statistics of an Ethernet device. */ 430 typedef int (*eth_stats_get_t)(struct rte_eth_dev *dev, 431 struct rte_eth_stats *igb_stats); 432 433 /** 434 * @internal 435 * Reset global I/O statistics of an Ethernet device to 0. 436 * 437 * @param dev 438 * ethdev handle of port. 439 * 440 * @return 441 * Negative errno value on error, 0 on success. 442 * 443 * @retval 0 444 * Success, statistics has been reset. 445 * @retval -ENOTSUP 446 * Resetting statistics is not supported. 447 * @retval -EINVAL 448 * Resetting statistics is not valid. 449 * @retval -ENOMEM 450 * Not enough memory to get the stats. 451 */ 452 typedef int (*eth_stats_reset_t)(struct rte_eth_dev *dev); 453 454 /** @internal Get extended stats of an Ethernet device. */ 455 typedef int (*eth_xstats_get_t)(struct rte_eth_dev *dev, 456 struct rte_eth_xstat *stats, unsigned int n); 457 458 /** 459 * @internal 460 * Get extended stats of an Ethernet device. 461 * 462 * @param dev 463 * ethdev handle of port. 464 * @param ids 465 * IDs array to retrieve specific statistics. Must not be NULL. 466 * @param values 467 * A pointer to a table to be filled with device statistics values. 468 * Must not be NULL. 469 * @param n 470 * Element count in @p ids and @p values. 471 * 472 * @return 473 * - A number of filled in stats. 474 * - A negative value on error. 475 */ 476 typedef int (*eth_xstats_get_by_id_t)(struct rte_eth_dev *dev, 477 const uint64_t *ids, 478 uint64_t *values, 479 unsigned int n); 480 481 /** 482 * @internal 483 * Reset extended stats of an Ethernet device. 484 * 485 * @param dev 486 * ethdev handle of port. 487 * 488 * @return 489 * Negative errno value on error, 0 on success. 490 * 491 * @retval 0 492 * Success, statistics has been reset. 493 * @retval -ENOTSUP 494 * Resetting statistics is not supported. 495 * @retval -EINVAL 496 * Resetting statistics is not valid. 497 * @retval -ENOMEM 498 * Not enough memory to get the stats. 499 */ 500 typedef int (*eth_xstats_reset_t)(struct rte_eth_dev *dev); 501 502 /** @internal Get names of extended stats of an Ethernet device. */ 503 typedef int (*eth_xstats_get_names_t)(struct rte_eth_dev *dev, 504 struct rte_eth_xstat_name *xstats_names, unsigned int size); 505 506 /** 507 * @internal 508 * Get names of extended stats of an Ethernet device. 509 * 510 * @param dev 511 * ethdev handle of port. 512 * @param ids 513 * IDs array to retrieve specific statistics. Must not be NULL. 514 * @param xstats_names 515 * An rte_eth_xstat_name array of at least @p size elements to be filled. 516 * Must not be NULL. 517 * @param size 518 * Element count in @p ids and @p xstats_names. 519 * 520 * @return 521 * - A number of filled in stats. 522 * - A negative value on error. 523 */ 524 typedef int (*eth_xstats_get_names_by_id_t)(struct rte_eth_dev *dev, 525 const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, 526 unsigned int size); 527 528 /** 529 * @internal 530 * Set a queue statistics mapping for a Tx/Rx queue of an Ethernet device. 531 */ 532 typedef int (*eth_queue_stats_mapping_set_t)(struct rte_eth_dev *dev, 533 uint16_t queue_id, 534 uint8_t stat_idx, 535 uint8_t is_rx); 536 537 /** @internal Get specific information of an Ethernet device. */ 538 typedef int (*eth_dev_infos_get_t)(struct rte_eth_dev *dev, 539 struct rte_eth_dev_info *dev_info); 540 541 /** 542 * @internal 543 * Function used to get supported ptypes of an Ethernet device. 544 * 545 * @param dev 546 * ethdev handle of port. 547 * 548 * @param no_of_elements 549 * number of ptypes elements. Must be initialized to 0. 550 * 551 * @retval 552 * Success, array of ptypes elements and valid no_of_elements > 0. 553 * Failures, NULL. 554 */ 555 typedef const uint32_t *(*eth_dev_supported_ptypes_get_t)(struct rte_eth_dev *dev, 556 size_t *no_of_elements); 557 558 /** 559 * @internal 560 * Inform Ethernet device about reduced range of packet types to handle. 561 * 562 * @param dev 563 * The Ethernet device identifier. 564 * @param ptype_mask 565 * The ptype family that application is interested in should be bitwise OR of 566 * RTE_PTYPE_*_MASK or 0. 567 * @return 568 * - (0) if Success. 569 */ 570 typedef int (*eth_dev_ptypes_set_t)(struct rte_eth_dev *dev, 571 uint32_t ptype_mask); 572 573 /** @internal Start Rx and Tx of a queue of an Ethernet device. */ 574 typedef int (*eth_queue_start_t)(struct rte_eth_dev *dev, 575 uint16_t queue_id); 576 577 /** @internal Stop Rx and Tx of a queue of an Ethernet device. */ 578 typedef int (*eth_queue_stop_t)(struct rte_eth_dev *dev, 579 uint16_t queue_id); 580 581 /** @internal Set up a receive queue of an Ethernet device. */ 582 typedef int (*eth_rx_queue_setup_t)(struct rte_eth_dev *dev, 583 uint16_t rx_queue_id, 584 uint16_t nb_rx_desc, 585 unsigned int socket_id, 586 const struct rte_eth_rxconf *rx_conf, 587 struct rte_mempool *mb_pool); 588 589 /** @internal Setup a transmit queue of an Ethernet device. */ 590 typedef int (*eth_tx_queue_setup_t)(struct rte_eth_dev *dev, 591 uint16_t tx_queue_id, 592 uint16_t nb_tx_desc, 593 unsigned int socket_id, 594 const struct rte_eth_txconf *tx_conf); 595 596 /** @internal Enable interrupt of a receive queue of an Ethernet device. */ 597 typedef int (*eth_rx_enable_intr_t)(struct rte_eth_dev *dev, 598 uint16_t rx_queue_id); 599 600 /** @internal Disable interrupt of a receive queue of an Ethernet device. */ 601 typedef int (*eth_rx_disable_intr_t)(struct rte_eth_dev *dev, 602 uint16_t rx_queue_id); 603 604 /** @internal Release memory resources allocated by given Rx/Tx queue. */ 605 typedef void (*eth_queue_release_t)(struct rte_eth_dev *dev, 606 uint16_t queue_id); 607 608 /** @internal Get firmware information of an Ethernet device. */ 609 typedef int (*eth_fw_version_get_t)(struct rte_eth_dev *dev, 610 char *fw_version, size_t fw_size); 611 612 /** @internal Force mbufs to be from Tx ring. */ 613 typedef int (*eth_tx_done_cleanup_t)(void *txq, uint32_t free_cnt); 614 615 typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev, 616 uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo); 617 618 typedef void (*eth_txq_info_get_t)(struct rte_eth_dev *dev, 619 uint16_t tx_queue_id, struct rte_eth_txq_info *qinfo); 620 621 typedef void (*eth_recycle_rxq_info_get_t)(struct rte_eth_dev *dev, 622 uint16_t rx_queue_id, 623 struct rte_eth_recycle_rxq_info *recycle_rxq_info); 624 625 typedef int (*eth_burst_mode_get_t)(struct rte_eth_dev *dev, 626 uint16_t queue_id, struct rte_eth_burst_mode *mode); 627 628 /** @internal Set MTU. */ 629 typedef int (*mtu_set_t)(struct rte_eth_dev *dev, uint16_t mtu); 630 631 /** @internal Filtering of a VLAN Tag Identifier by an Ethernet device. */ 632 typedef int (*vlan_filter_set_t)(struct rte_eth_dev *dev, 633 uint16_t vlan_id, 634 int on); 635 636 /** @internal Set the outer/inner VLAN-TPID by an Ethernet device. */ 637 typedef int (*vlan_tpid_set_t)(struct rte_eth_dev *dev, 638 enum rte_vlan_type type, uint16_t tpid); 639 640 /** @internal Set VLAN offload function by an Ethernet device. */ 641 typedef int (*vlan_offload_set_t)(struct rte_eth_dev *dev, int mask); 642 643 /** @internal Set port based Tx VLAN insertion by an Ethernet device. */ 644 typedef int (*vlan_pvid_set_t)(struct rte_eth_dev *dev, 645 uint16_t vlan_id, 646 int on); 647 648 /** @internal VLAN stripping enable/disable by an queue of Ethernet device. */ 649 typedef void (*vlan_strip_queue_set_t)(struct rte_eth_dev *dev, 650 uint16_t rx_queue_id, 651 int on); 652 653 /** @internal Get current flow control parameter on an Ethernet device. */ 654 typedef int (*flow_ctrl_get_t)(struct rte_eth_dev *dev, 655 struct rte_eth_fc_conf *fc_conf); 656 657 /** @internal Setup flow control parameter on an Ethernet device. */ 658 typedef int (*flow_ctrl_set_t)(struct rte_eth_dev *dev, 659 struct rte_eth_fc_conf *fc_conf); 660 661 /** @internal Setup priority flow control parameter on an Ethernet device. */ 662 typedef int (*priority_flow_ctrl_set_t)(struct rte_eth_dev *dev, 663 struct rte_eth_pfc_conf *pfc_conf); 664 665 /** @internal Get info for queue based PFC on an Ethernet device. */ 666 typedef int (*priority_flow_ctrl_queue_info_get_t)(struct rte_eth_dev *dev, 667 struct rte_eth_pfc_queue_info *pfc_queue_info); 668 /** @internal Configure queue based PFC parameter on an Ethernet device. */ 669 typedef int (*priority_flow_ctrl_queue_config_t)(struct rte_eth_dev *dev, 670 struct rte_eth_pfc_queue_conf *pfc_queue_conf); 671 672 /** @internal Update RSS redirection table on an Ethernet device. */ 673 typedef int (*reta_update_t)(struct rte_eth_dev *dev, 674 struct rte_eth_rss_reta_entry64 *reta_conf, 675 uint16_t reta_size); 676 677 /** @internal Query RSS redirection table on an Ethernet device. */ 678 typedef int (*reta_query_t)(struct rte_eth_dev *dev, 679 struct rte_eth_rss_reta_entry64 *reta_conf, 680 uint16_t reta_size); 681 682 /** @internal Update RSS hash configuration of an Ethernet device. */ 683 typedef int (*rss_hash_update_t)(struct rte_eth_dev *dev, 684 struct rte_eth_rss_conf *rss_conf); 685 686 /** @internal Get current RSS hash configuration of an Ethernet device. */ 687 typedef int (*rss_hash_conf_get_t)(struct rte_eth_dev *dev, 688 struct rte_eth_rss_conf *rss_conf); 689 690 /** @internal Turn on SW controllable LED on an Ethernet device. */ 691 typedef int (*eth_dev_led_on_t)(struct rte_eth_dev *dev); 692 693 /** @internal Turn off SW controllable LED on an Ethernet device. */ 694 typedef int (*eth_dev_led_off_t)(struct rte_eth_dev *dev); 695 696 /** @internal Remove MAC address from receive address register. */ 697 typedef void (*eth_mac_addr_remove_t)(struct rte_eth_dev *dev, uint32_t index); 698 699 /** @internal Set a MAC address into Receive Address Register. */ 700 typedef int (*eth_mac_addr_add_t)(struct rte_eth_dev *dev, 701 struct rte_ether_addr *mac_addr, 702 uint32_t index, 703 uint32_t vmdq); 704 705 /** @internal Set a MAC address into Receive Address Register. */ 706 typedef int (*eth_mac_addr_set_t)(struct rte_eth_dev *dev, 707 struct rte_ether_addr *mac_addr); 708 709 /** @internal Set a Unicast Hash bitmap. */ 710 typedef int (*eth_uc_hash_table_set_t)(struct rte_eth_dev *dev, 711 struct rte_ether_addr *mac_addr, 712 uint8_t on); 713 714 /** @internal Set all Unicast Hash bitmap. */ 715 typedef int (*eth_uc_all_hash_table_set_t)(struct rte_eth_dev *dev, 716 uint8_t on); 717 718 /** @internal Set queue Tx rate. */ 719 typedef int (*eth_set_queue_rate_limit_t)(struct rte_eth_dev *dev, 720 uint16_t queue_idx, 721 uint32_t tx_rate); 722 723 /** @internal Add tunneling UDP port. */ 724 typedef int (*eth_udp_tunnel_port_add_t)(struct rte_eth_dev *dev, 725 struct rte_eth_udp_tunnel *tunnel_udp); 726 727 /** @internal Delete tunneling UDP port. */ 728 typedef int (*eth_udp_tunnel_port_del_t)(struct rte_eth_dev *dev, 729 struct rte_eth_udp_tunnel *tunnel_udp); 730 731 /** @internal set the list of multicast addresses on an Ethernet device. */ 732 typedef int (*eth_set_mc_addr_list_t)(struct rte_eth_dev *dev, 733 struct rte_ether_addr *mc_addr_set, 734 uint32_t nb_mc_addr); 735 736 /** @internal Function used to enable IEEE1588/802.1AS timestamping. */ 737 typedef int (*eth_timesync_enable_t)(struct rte_eth_dev *dev); 738 739 /** @internal Function used to disable IEEE1588/802.1AS timestamping. */ 740 typedef int (*eth_timesync_disable_t)(struct rte_eth_dev *dev); 741 742 /** @internal Function used to read an Rx IEEE1588/802.1AS timestamp. */ 743 typedef int (*eth_timesync_read_rx_timestamp_t)(struct rte_eth_dev *dev, 744 struct timespec *timestamp, 745 uint32_t flags); 746 747 /** @internal Function used to read a Tx IEEE1588/802.1AS timestamp. */ 748 typedef int (*eth_timesync_read_tx_timestamp_t)(struct rte_eth_dev *dev, 749 struct timespec *timestamp); 750 751 /** @internal Function used to adjust the device clock. */ 752 typedef int (*eth_timesync_adjust_time)(struct rte_eth_dev *dev, int64_t); 753 754 /** @internal Function used to get time from the device clock. */ 755 typedef int (*eth_timesync_read_time)(struct rte_eth_dev *dev, 756 struct timespec *timestamp); 757 758 /** @internal Function used to get time from the device clock. */ 759 typedef int (*eth_timesync_write_time)(struct rte_eth_dev *dev, 760 const struct timespec *timestamp); 761 762 /** @internal Function used to get the current value of the device clock. */ 763 typedef int (*eth_read_clock)(struct rte_eth_dev *dev, 764 uint64_t *timestamp); 765 766 /** @internal Retrieve registers. */ 767 typedef int (*eth_get_reg_t)(struct rte_eth_dev *dev, 768 struct rte_dev_reg_info *info); 769 770 /** @internal Retrieve EEPROM size. */ 771 typedef int (*eth_get_eeprom_length_t)(struct rte_eth_dev *dev); 772 773 /** @internal Retrieve EEPROM data. */ 774 typedef int (*eth_get_eeprom_t)(struct rte_eth_dev *dev, 775 struct rte_dev_eeprom_info *info); 776 777 /** @internal Program EEPROM data. */ 778 typedef int (*eth_set_eeprom_t)(struct rte_eth_dev *dev, 779 struct rte_dev_eeprom_info *info); 780 781 /** @internal Retrieve type and size of plugin module EEPROM. */ 782 typedef int (*eth_get_module_info_t)(struct rte_eth_dev *dev, 783 struct rte_eth_dev_module_info *modinfo); 784 785 /** @internal Retrieve plugin module EEPROM data. */ 786 typedef int (*eth_get_module_eeprom_t)(struct rte_eth_dev *dev, 787 struct rte_dev_eeprom_info *info); 788 789 struct rte_flow_ops; 790 /** 791 * @internal 792 * Get flow operations. 793 * 794 * If the flow API is not supported for the specified device, 795 * the driver can return NULL. 796 */ 797 typedef int (*eth_flow_ops_get_t)(struct rte_eth_dev *dev, 798 const struct rte_flow_ops **ops); 799 800 /** @internal Get Traffic Management (TM) operations on an Ethernet device. */ 801 typedef int (*eth_tm_ops_get_t)(struct rte_eth_dev *dev, void *ops); 802 803 /** @internal Get Traffic Metering and Policing (MTR) operations. */ 804 typedef int (*eth_mtr_ops_get_t)(struct rte_eth_dev *dev, void *ops); 805 806 /** @internal Get DCB information on an Ethernet device. */ 807 typedef int (*eth_get_dcb_info)(struct rte_eth_dev *dev, 808 struct rte_eth_dcb_info *dcb_info); 809 810 /** @internal Test if a port supports specific mempool ops. */ 811 typedef int (*eth_pool_ops_supported_t)(struct rte_eth_dev *dev, 812 const char *pool); 813 814 /** 815 * @internal 816 * Get the hairpin capabilities. 817 * 818 * @param dev 819 * ethdev handle of port. 820 * @param cap 821 * returns the hairpin capabilities from the device. 822 * 823 * @return 824 * Negative errno value on error, 0 on success. 825 * 826 * @retval 0 827 * Success, hairpin is supported. 828 * @retval -ENOTSUP 829 * Hairpin is not supported. 830 */ 831 typedef int (*eth_hairpin_cap_get_t)(struct rte_eth_dev *dev, 832 struct rte_eth_hairpin_cap *cap); 833 834 /** 835 * @internal 836 * Setup Rx hairpin queue. 837 * 838 * @param dev 839 * ethdev handle of port. 840 * @param rx_queue_id 841 * the selected Rx queue index. 842 * @param nb_rx_desc 843 * the requested number of descriptors for this queue. 0 - use PMD default. 844 * @param conf 845 * the Rx hairpin configuration structure. 846 * 847 * @return 848 * Negative errno value on error, 0 on success. 849 * 850 * @retval 0 851 * Success, hairpin is supported. 852 * @retval -ENOTSUP 853 * Hairpin is not supported. 854 * @retval -EINVAL 855 * One of the parameters is invalid. 856 * @retval -ENOMEM 857 * Unable to allocate resources. 858 */ 859 typedef int (*eth_rx_hairpin_queue_setup_t) 860 (struct rte_eth_dev *dev, uint16_t rx_queue_id, 861 uint16_t nb_rx_desc, 862 const struct rte_eth_hairpin_conf *conf); 863 864 /** 865 * @internal 866 * Setup Tx hairpin queue. 867 * 868 * @param dev 869 * ethdev handle of port. 870 * @param tx_queue_id 871 * the selected Tx queue index. 872 * @param nb_tx_desc 873 * the requested number of descriptors for this queue. 0 - use PMD default. 874 * @param conf 875 * the Tx hairpin configuration structure. 876 * 877 * @return 878 * Negative errno value on error, 0 on success. 879 * 880 * @retval 0 881 * Success, hairpin is supported. 882 * @retval -ENOTSUP 883 * Hairpin is not supported. 884 * @retval -EINVAL 885 * One of the parameters is invalid. 886 * @retval -ENOMEM 887 * Unable to allocate resources. 888 */ 889 typedef int (*eth_tx_hairpin_queue_setup_t) 890 (struct rte_eth_dev *dev, uint16_t tx_queue_id, 891 uint16_t nb_tx_desc, 892 const struct rte_eth_hairpin_conf *hairpin_conf); 893 894 /** 895 * @internal 896 * Get Forward Error Correction(FEC) capability. 897 * 898 * @param dev 899 * ethdev handle of port. 900 * @param speed_fec_capa 901 * speed_fec_capa is out only with per-speed capabilities. 902 * @param num 903 * a number of elements in an speed_fec_capa array. 904 * 905 * @return 906 * Negative errno value on error, positive value on success. 907 * 908 * @retval positive value 909 * A non-negative value lower or equal to num: success. The return value 910 * is the number of entries filled in the fec capa array. 911 * A non-negative value higher than num: error, the given fec capa array 912 * is too small. The return value corresponds to the num that should 913 * be given to succeed. The entries in the fec capa array are not valid 914 * and shall not be used by the caller. 915 * @retval -ENOTSUP 916 * Operation is not supported. 917 * @retval -EIO 918 * Device is removed. 919 * @retval -EINVAL 920 * *num* or *speed_fec_capa* invalid. 921 */ 922 typedef int (*eth_fec_get_capability_t)(struct rte_eth_dev *dev, 923 struct rte_eth_fec_capa *speed_fec_capa, unsigned int num); 924 925 /** 926 * @internal 927 * Get Forward Error Correction(FEC) mode. 928 * 929 * @param dev 930 * ethdev handle of port. 931 * @param fec_capa 932 * a bitmask of enabled FEC modes. If AUTO bit is set, other 933 * bits specify FEC modes which may be negotiated. If AUTO 934 * bit is clear, specify FEC modes to be used (only one valid 935 * mode per speed may be set). 936 * 937 * @return 938 * Negative errno value on error, 0 on success. 939 * 940 * @retval 0 941 * Success, get FEC success. 942 * @retval -ENOTSUP 943 * Operation is not supported. 944 * @retval -EIO 945 * Device is removed. 946 */ 947 typedef int (*eth_fec_get_t)(struct rte_eth_dev *dev, 948 uint32_t *fec_capa); 949 950 /** 951 * @internal 952 * Set Forward Error Correction(FEC) mode. 953 * 954 * @param dev 955 * ethdev handle of port. 956 * @param fec_capa 957 * bitmask of allowed FEC modes. It must be only one 958 * if AUTO is disabled. If AUTO is enabled, other 959 * bits specify FEC modes which may be negotiated. 960 * 961 * @return 962 * Negative errno value on error, 0 on success. 963 * 964 * @retval 0 965 * Success, set FEC success. 966 * @retval -ENOTSUP 967 * Operation is not supported. 968 * @retval -EINVAL 969 * Unsupported FEC mode requested. 970 * @retval -EIO 971 * Device is removed. 972 */ 973 typedef int (*eth_fec_set_t)(struct rte_eth_dev *dev, uint32_t fec_capa); 974 975 /** 976 * @internal 977 * Get all hairpin Tx/Rx peer ports of the current device, if any. 978 * 979 * @param dev 980 * ethdev handle of port. 981 * @param peer_ports 982 * array to save the ports list. 983 * @param len 984 * array length. 985 * @param direction 986 * value to decide the current to peer direction 987 * positive - used as Tx to get all peer Rx ports. 988 * zero - used as Rx to get all peer Tx ports. 989 * 990 * @return 991 * Negative errno value on error, 0 or positive on success. 992 * 993 * @retval 0 994 * Success, no peer ports. 995 * @retval >0 996 * Actual number of the peer ports. 997 * @retval -ENOTSUP 998 * Get peer ports API is not supported. 999 * @retval -EINVAL 1000 * One of the parameters is invalid. 1001 */ 1002 typedef int (*hairpin_get_peer_ports_t)(struct rte_eth_dev *dev, 1003 uint16_t *peer_ports, size_t len, 1004 uint32_t direction); 1005 1006 /** 1007 * @internal 1008 * Bind all hairpin Tx queues of one port to the Rx queues of the peer port. 1009 * 1010 * @param dev 1011 * ethdev handle of port. 1012 * @param rx_port 1013 * the peer Rx port. 1014 * 1015 * @return 1016 * Negative errno value on error, 0 on success. 1017 * 1018 * @retval 0 1019 * Success, bind successfully. 1020 * @retval -ENOTSUP 1021 * Bind API is not supported. 1022 * @retval -EINVAL 1023 * One of the parameters is invalid. 1024 * @retval -EBUSY 1025 * Device is not started. 1026 */ 1027 typedef int (*eth_hairpin_bind_t)(struct rte_eth_dev *dev, 1028 uint16_t rx_port); 1029 1030 /** 1031 * @internal 1032 * Unbind all hairpin Tx queues of one port from the Rx queues of the peer port. 1033 * 1034 * @param dev 1035 * ethdev handle of port. 1036 * @param rx_port 1037 * the peer Rx port. 1038 * 1039 * @return 1040 * Negative errno value on error, 0 on success. 1041 * 1042 * @retval 0 1043 * Success, unbind successfully. 1044 * @retval -ENOTSUP 1045 * Bind API is not supported. 1046 * @retval -EINVAL 1047 * One of the parameters is invalid. 1048 * @retval -EBUSY 1049 * Device is already stopped. 1050 */ 1051 typedef int (*eth_hairpin_unbind_t)(struct rte_eth_dev *dev, 1052 uint16_t rx_port); 1053 1054 /** @internal Update and fetch peer queue information. */ 1055 typedef int (*eth_hairpin_queue_peer_update_t) 1056 (struct rte_eth_dev *dev, uint16_t peer_queue, 1057 struct rte_hairpin_peer_info *current_info, 1058 struct rte_hairpin_peer_info *peer_info, uint32_t direction); 1059 1060 /** @internal Bind peer queue to the current queue with fetched information. */ 1061 typedef int (*eth_hairpin_queue_peer_bind_t) 1062 (struct rte_eth_dev *dev, uint16_t cur_queue, 1063 struct rte_hairpin_peer_info *peer_info, uint32_t direction); 1064 1065 /** @internal Unbind peer queue from the current queue. */ 1066 typedef int (*eth_hairpin_queue_peer_unbind_t) 1067 (struct rte_eth_dev *dev, uint16_t cur_queue, uint32_t direction); 1068 1069 /** 1070 * @internal 1071 * Get address of memory location whose contents will change whenever there is 1072 * new data to be received on an Rx queue. 1073 * 1074 * @param rxq 1075 * Ethdev queue pointer. 1076 * @param pmc 1077 * The pointer to power-optimized monitoring condition structure. 1078 * @return 1079 * Negative errno value on error, 0 on success. 1080 * 1081 * @retval 0 1082 * Success 1083 * @retval -EINVAL 1084 * Invalid parameters 1085 */ 1086 typedef int (*eth_get_monitor_addr_t)(void *rxq, 1087 struct rte_power_monitor_cond *pmc); 1088 1089 /** 1090 * @internal 1091 * Get representor info to be able to calculate the unique representor ID. 1092 * 1093 * Caller should pass NULL as pointer of info to get number of entries, 1094 * allocate info buffer according to returned entry number, then call 1095 * again with buffer to get real info. 1096 * 1097 * To calculate the representor ID, caller should iterate each entry, 1098 * match controller index, pf index, vf or sf start index and range, 1099 * then calculate representor ID from offset to vf/sf start index. 1100 * @see rte_eth_representor_id_get. 1101 * 1102 * @param dev 1103 * Ethdev handle of port. 1104 * @param [out] info 1105 * Pointer to memory to save device representor info. 1106 * @return 1107 * Negative errno value on error, number of info entries otherwise. 1108 */ 1109 1110 typedef int (*eth_representor_info_get_t)(struct rte_eth_dev *dev, 1111 struct rte_eth_representor_info *info); 1112 1113 /** 1114 * @internal 1115 * Negotiate the NIC's ability to deliver specific kinds of metadata to the PMD. 1116 * 1117 * @param dev 1118 * Port (ethdev) handle 1119 * 1120 * @param[inout] features 1121 * Feature selection buffer 1122 * 1123 * @return 1124 * Negative errno value on error, zero otherwise 1125 */ 1126 typedef int (*eth_rx_metadata_negotiate_t)(struct rte_eth_dev *dev, 1127 uint64_t *features); 1128 1129 /** 1130 * @internal 1131 * Get IP reassembly offload capability of a PMD. 1132 * 1133 * @param dev 1134 * Port (ethdev) handle 1135 * 1136 * @param[out] conf 1137 * IP reassembly capability supported by the PMD 1138 * 1139 * @return 1140 * Negative errno value on error, zero otherwise 1141 */ 1142 typedef int (*eth_ip_reassembly_capability_get_t)(struct rte_eth_dev *dev, 1143 struct rte_eth_ip_reassembly_params *capa); 1144 1145 /** 1146 * @internal 1147 * Get IP reassembly offload configuration parameters set in PMD. 1148 * 1149 * @param dev 1150 * Port (ethdev) handle 1151 * 1152 * @param[out] conf 1153 * Configuration parameters for IP reassembly. 1154 * 1155 * @return 1156 * Negative errno value on error, zero otherwise 1157 */ 1158 typedef int (*eth_ip_reassembly_conf_get_t)(struct rte_eth_dev *dev, 1159 struct rte_eth_ip_reassembly_params *conf); 1160 1161 /** 1162 * @internal 1163 * Set configuration parameters for enabling IP reassembly offload in hardware. 1164 * 1165 * @param dev 1166 * Port (ethdev) handle 1167 * 1168 * @param[in] conf 1169 * Configuration parameters for IP reassembly. 1170 * 1171 * @return 1172 * Negative errno value on error, zero otherwise 1173 */ 1174 typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev, 1175 const struct rte_eth_ip_reassembly_params *conf); 1176 1177 /** 1178 * @internal 1179 * Get supported header protocols of a PMD to split. 1180 * 1181 * @param dev 1182 * Ethdev handle of port. 1183 * 1184 * @return 1185 * An array pointer to store supported protocol headers. 1186 */ 1187 typedef const uint32_t *(*eth_buffer_split_supported_hdr_ptypes_get_t)(struct rte_eth_dev *dev, 1188 size_t *no_of_elements); 1189 1190 /** 1191 * @internal 1192 * Dump private info from device to a file. 1193 * 1194 * @param dev 1195 * Port (ethdev) handle. 1196 * @param file 1197 * A pointer to a file for output. 1198 * 1199 * @return 1200 * Negative value on error, 0 on success. 1201 * 1202 * @retval 0 1203 * Success 1204 * @retval -EINVAL 1205 * Invalid file 1206 */ 1207 typedef int (*eth_dev_priv_dump_t)(struct rte_eth_dev *dev, FILE *file); 1208 1209 /** 1210 * @internal Set Rx queue available descriptors threshold. 1211 * @see rte_eth_rx_avail_thresh_set() 1212 * 1213 * Driver should round down number of descriptors on conversion from 1214 * percentage. 1215 */ 1216 typedef int (*eth_rx_queue_avail_thresh_set_t)(struct rte_eth_dev *dev, 1217 uint16_t rx_queue_id, 1218 uint8_t avail_thresh); 1219 1220 /** 1221 * @internal Query Rx queue available descriptors threshold event. 1222 * @see rte_eth_rx_avail_thresh_query() 1223 */ 1224 1225 typedef int (*eth_rx_queue_avail_thresh_query_t)(struct rte_eth_dev *dev, 1226 uint16_t *rx_queue_id, 1227 uint8_t *avail_thresh); 1228 1229 /** @internal Get congestion management information. */ 1230 typedef int (*eth_cman_info_get_t)(struct rte_eth_dev *dev, 1231 struct rte_eth_cman_info *info); 1232 1233 /** @internal Init congestion management structure with default values. */ 1234 typedef int (*eth_cman_config_init_t)(struct rte_eth_dev *dev, 1235 struct rte_eth_cman_config *config); 1236 1237 /** @internal Configure congestion management on a port. */ 1238 typedef int (*eth_cman_config_set_t)(struct rte_eth_dev *dev, 1239 const struct rte_eth_cman_config *config); 1240 1241 /** @internal Retrieve congestion management configuration of a port. */ 1242 typedef int (*eth_cman_config_get_t)(struct rte_eth_dev *dev, 1243 struct rte_eth_cman_config *config); 1244 1245 /** 1246 * @internal 1247 * Dump Rx descriptor info to a file. 1248 * 1249 * It is used for debugging, not a dataplane API. 1250 * 1251 * @param dev 1252 * Port (ethdev) handle. 1253 * @param queue_id 1254 * A Rx queue identifier on this port. 1255 * @param offset 1256 * The offset of the descriptor starting from tail. (0 is the next 1257 * packet to be received by the driver). 1258 * @param num 1259 * The number of the descriptors to dump. 1260 * @param file 1261 * A pointer to a file for output. 1262 * @return 1263 * Negative errno value on error, zero on success. 1264 */ 1265 typedef int (*eth_rx_descriptor_dump_t)(const struct rte_eth_dev *dev, 1266 uint16_t queue_id, uint16_t offset, 1267 uint16_t num, FILE *file); 1268 1269 /** 1270 * @internal 1271 * Dump Tx descriptor info to a file. 1272 * 1273 * This API is used for debugging, not a dataplane API. 1274 * 1275 * @param dev 1276 * Port (ethdev) handle. 1277 * @param queue_id 1278 * A Tx queue identifier on this port. 1279 * @param offset 1280 * The offset of the descriptor starting from tail. (0 is the place where 1281 * the next packet will be send). 1282 * @param num 1283 * The number of the descriptors to dump. 1284 * @param file 1285 * A pointer to a file for output. 1286 * @return 1287 * Negative errno value on error, zero on success. 1288 */ 1289 typedef int (*eth_tx_descriptor_dump_t)(const struct rte_eth_dev *dev, 1290 uint16_t queue_id, uint16_t offset, 1291 uint16_t num, FILE *file); 1292 1293 /** 1294 * @internal 1295 * Get the number of aggregated ports. 1296 * 1297 * @param dev 1298 * Port (ethdev) handle. 1299 * 1300 * @return 1301 * Negative errno value on error, 0 or positive on success. 1302 * 1303 * @retval >=0 1304 * The number of aggregated port if success. 1305 */ 1306 typedef int (*eth_count_aggr_ports_t)(struct rte_eth_dev *dev); 1307 1308 /** 1309 * @internal 1310 * Map a Tx queue with an aggregated port of the DPDK port. 1311 * 1312 * @param dev 1313 * Port (ethdev) handle. 1314 * @param tx_queue_id 1315 * The index of the transmit queue used in rte_eth_tx_burst(). 1316 * @param affinity 1317 * The number of the aggregated port. 1318 * 1319 * @return 1320 * Negative on error, 0 on success. 1321 */ 1322 typedef int (*eth_map_aggr_tx_affinity_t)(struct rte_eth_dev *dev, uint16_t tx_queue_id, 1323 uint8_t affinity); 1324 1325 /** 1326 * @internal 1327 * Defines types of operations which can be executed by the application. 1328 */ 1329 enum rte_eth_dev_operation { 1330 RTE_ETH_START, 1331 }; 1332 1333 /**@{@name Restore flags 1334 * Flags returned by get_restore_flags() callback. 1335 * They indicate to ethdev layer which configuration is required to be restored. 1336 */ 1337 /** If set, ethdev layer will forcefully restore default and any other added MAC addresses. */ 1338 #define RTE_ETH_RESTORE_MAC_ADDR RTE_BIT64(0) 1339 /** If set, ethdev layer will forcefully restore current promiscuous mode setting. */ 1340 #define RTE_ETH_RESTORE_PROMISC RTE_BIT64(1) 1341 /** If set, ethdev layer will forcefully restore current all multicast mode setting. */ 1342 #define RTE_ETH_RESTORE_ALLMULTI RTE_BIT64(2) 1343 /**@}*/ 1344 1345 /** All configuration which can be restored by ethdev layer. */ 1346 #define RTE_ETH_RESTORE_ALL (RTE_ETH_RESTORE_MAC_ADDR | \ 1347 RTE_ETH_RESTORE_PROMISC | \ 1348 RTE_ETH_RESTORE_ALLMULTI) 1349 1350 /** 1351 * @internal 1352 * Fetch from the driver what kind of configuration must be restored by ethdev layer, 1353 * after certain operations are performed by the application (such as rte_eth_dev_start()). 1354 * 1355 * @param dev 1356 * Port (ethdev) handle. 1357 * @param op 1358 * Type of operation executed by the application. 1359 * 1360 * @return 1361 * ORed restore flags indicating which configuration should be restored by ethdev. 1362 * 0 if no restore is required by the driver. 1363 */ 1364 typedef uint64_t (*eth_get_restore_flags_t)(struct rte_eth_dev *dev, 1365 enum rte_eth_dev_operation op); 1366 1367 /** 1368 * @internal A structure containing the functions exported by an Ethernet driver. 1369 */ 1370 struct eth_dev_ops { 1371 eth_dev_configure_t dev_configure; /**< Configure device */ 1372 eth_dev_start_t dev_start; /**< Start device */ 1373 eth_dev_stop_t dev_stop; /**< Stop device */ 1374 eth_dev_set_link_up_t dev_set_link_up; /**< Device link up */ 1375 eth_dev_set_link_down_t dev_set_link_down; /**< Device link down */ 1376 eth_dev_close_t dev_close; /**< Close device */ 1377 eth_dev_reset_t dev_reset; /**< Reset device */ 1378 eth_link_update_t link_update; /**< Get device link state */ 1379 eth_speed_lanes_get_t speed_lanes_get; /**< Get link speed active lanes */ 1380 eth_speed_lanes_set_t speed_lanes_set; /**< Set link speeds supported lanes */ 1381 /** Get link speed lanes capability */ 1382 eth_speed_lanes_get_capability_t speed_lanes_get_capa; 1383 /** Check if the device was physically removed */ 1384 eth_is_removed_t is_removed; 1385 1386 eth_promiscuous_enable_t promiscuous_enable; /**< Promiscuous ON */ 1387 eth_promiscuous_disable_t promiscuous_disable;/**< Promiscuous OFF */ 1388 eth_allmulticast_enable_t allmulticast_enable;/**< Rx multicast ON */ 1389 eth_allmulticast_disable_t allmulticast_disable;/**< Rx multicast OFF */ 1390 eth_mac_addr_remove_t mac_addr_remove; /**< Remove MAC address */ 1391 eth_mac_addr_add_t mac_addr_add; /**< Add a MAC address */ 1392 eth_mac_addr_set_t mac_addr_set; /**< Set a MAC address */ 1393 /** Set list of multicast addresses */ 1394 eth_set_mc_addr_list_t set_mc_addr_list; 1395 mtu_set_t mtu_set; /**< Set MTU */ 1396 1397 /** Get generic device statistics */ 1398 eth_stats_get_t stats_get; 1399 /** Reset generic device statistics */ 1400 eth_stats_reset_t stats_reset; 1401 /** Get extended device statistics */ 1402 eth_xstats_get_t xstats_get; 1403 /** Reset extended device statistics */ 1404 eth_xstats_reset_t xstats_reset; 1405 /** Get names of extended statistics */ 1406 eth_xstats_get_names_t xstats_get_names; 1407 /** Configure per queue stat counter mapping */ 1408 eth_queue_stats_mapping_set_t queue_stats_mapping_set; 1409 1410 eth_dev_infos_get_t dev_infos_get; /**< Get device info */ 1411 /** Retrieve Rx queue information */ 1412 eth_rxq_info_get_t rxq_info_get; 1413 /** Retrieve Tx queue information */ 1414 eth_txq_info_get_t txq_info_get; 1415 /** Retrieve mbufs recycle Rx queue information */ 1416 eth_recycle_rxq_info_get_t recycle_rxq_info_get; 1417 eth_burst_mode_get_t rx_burst_mode_get; /**< Get Rx burst mode */ 1418 eth_burst_mode_get_t tx_burst_mode_get; /**< Get Tx burst mode */ 1419 eth_fw_version_get_t fw_version_get; /**< Get firmware version */ 1420 1421 /** Get packet types supported and identified by device */ 1422 eth_dev_supported_ptypes_get_t dev_supported_ptypes_get; 1423 /** 1424 * Inform Ethernet device about reduced range of packet types to 1425 * handle 1426 */ 1427 eth_dev_ptypes_set_t dev_ptypes_set; 1428 1429 /** Filter VLAN Setup */ 1430 vlan_filter_set_t vlan_filter_set; 1431 /** Outer/Inner VLAN TPID Setup */ 1432 vlan_tpid_set_t vlan_tpid_set; 1433 /** VLAN Stripping on queue */ 1434 vlan_strip_queue_set_t vlan_strip_queue_set; 1435 /** Set VLAN Offload */ 1436 vlan_offload_set_t vlan_offload_set; 1437 /** Set port based Tx VLAN insertion */ 1438 vlan_pvid_set_t vlan_pvid_set; 1439 1440 eth_queue_start_t rx_queue_start;/**< Start Rx for a queue */ 1441 eth_queue_stop_t rx_queue_stop; /**< Stop Rx for a queue */ 1442 eth_queue_start_t tx_queue_start;/**< Start Tx for a queue */ 1443 eth_queue_stop_t tx_queue_stop; /**< Stop Tx for a queue */ 1444 eth_rx_queue_setup_t rx_queue_setup;/**< Set up device Rx queue */ 1445 eth_queue_release_t rx_queue_release; /**< Release Rx queue */ 1446 1447 /** Enable Rx queue interrupt */ 1448 eth_rx_enable_intr_t rx_queue_intr_enable; 1449 /** Disable Rx queue interrupt */ 1450 eth_rx_disable_intr_t rx_queue_intr_disable; 1451 1452 eth_tx_queue_setup_t tx_queue_setup;/**< Set up device Tx queue */ 1453 eth_queue_release_t tx_queue_release; /**< Release Tx queue */ 1454 eth_tx_done_cleanup_t tx_done_cleanup;/**< Free Tx ring mbufs */ 1455 1456 eth_dev_led_on_t dev_led_on; /**< Turn on LED */ 1457 eth_dev_led_off_t dev_led_off; /**< Turn off LED */ 1458 1459 flow_ctrl_get_t flow_ctrl_get; /**< Get flow control */ 1460 flow_ctrl_set_t flow_ctrl_set; /**< Setup flow control */ 1461 /** Setup priority flow control */ 1462 priority_flow_ctrl_set_t priority_flow_ctrl_set; 1463 /** Priority flow control queue info get */ 1464 priority_flow_ctrl_queue_info_get_t priority_flow_ctrl_queue_info_get; 1465 /** Priority flow control queue configure */ 1466 priority_flow_ctrl_queue_config_t priority_flow_ctrl_queue_config; 1467 1468 /** Set Unicast Table Array */ 1469 eth_uc_hash_table_set_t uc_hash_table_set; 1470 /** Set Unicast hash bitmap */ 1471 eth_uc_all_hash_table_set_t uc_all_hash_table_set; 1472 1473 /** Add UDP tunnel port */ 1474 eth_udp_tunnel_port_add_t udp_tunnel_port_add; 1475 /** Delete UDP tunnel port */ 1476 eth_udp_tunnel_port_del_t udp_tunnel_port_del; 1477 1478 /** Set queue rate limit */ 1479 eth_set_queue_rate_limit_t set_queue_rate_limit; 1480 1481 /** Configure RSS hash protocols and hashing key */ 1482 rss_hash_update_t rss_hash_update; 1483 /** Get current RSS hash configuration */ 1484 rss_hash_conf_get_t rss_hash_conf_get; 1485 /** Update redirection table */ 1486 reta_update_t reta_update; 1487 /** Query redirection table */ 1488 reta_query_t reta_query; 1489 1490 eth_get_reg_t get_reg; /**< Get registers */ 1491 eth_get_eeprom_length_t get_eeprom_length; /**< Get EEPROM length */ 1492 eth_get_eeprom_t get_eeprom; /**< Get EEPROM data */ 1493 eth_set_eeprom_t set_eeprom; /**< Set EEPROM */ 1494 1495 /** Get plugin module EEPROM attribute */ 1496 eth_get_module_info_t get_module_info; 1497 /** Get plugin module EEPROM data */ 1498 eth_get_module_eeprom_t get_module_eeprom; 1499 1500 eth_flow_ops_get_t flow_ops_get; /**< Get flow operations */ 1501 1502 eth_get_dcb_info get_dcb_info; /**< Get DCB information */ 1503 1504 /** Turn IEEE1588/802.1AS timestamping on */ 1505 eth_timesync_enable_t timesync_enable; 1506 /** Turn IEEE1588/802.1AS timestamping off */ 1507 eth_timesync_disable_t timesync_disable; 1508 /** Read the IEEE1588/802.1AS Rx timestamp */ 1509 eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp; 1510 /** Read the IEEE1588/802.1AS Tx timestamp */ 1511 eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp; 1512 /** Adjust the device clock */ 1513 eth_timesync_adjust_time timesync_adjust_time; 1514 /** Get the device clock time */ 1515 eth_timesync_read_time timesync_read_time; 1516 /** Set the device clock time */ 1517 eth_timesync_write_time timesync_write_time; 1518 1519 eth_read_clock read_clock; 1520 1521 /** Get extended device statistic values by ID */ 1522 eth_xstats_get_by_id_t xstats_get_by_id; 1523 /** Get name of extended device statistics by ID */ 1524 eth_xstats_get_names_by_id_t xstats_get_names_by_id; 1525 1526 /** Get Traffic Management (TM) operations */ 1527 eth_tm_ops_get_t tm_ops_get; 1528 1529 /** Get Traffic Metering and Policing (MTR) operations */ 1530 eth_mtr_ops_get_t mtr_ops_get; 1531 1532 /** Test if a port supports specific mempool ops */ 1533 eth_pool_ops_supported_t pool_ops_supported; 1534 1535 /** Returns the hairpin capabilities */ 1536 eth_hairpin_cap_get_t hairpin_cap_get; 1537 /** Set up device Rx hairpin queue */ 1538 eth_rx_hairpin_queue_setup_t rx_hairpin_queue_setup; 1539 /** Set up device Tx hairpin queue */ 1540 eth_tx_hairpin_queue_setup_t tx_hairpin_queue_setup; 1541 1542 /** Get Forward Error Correction(FEC) capability */ 1543 eth_fec_get_capability_t fec_get_capability; 1544 /** Get Forward Error Correction(FEC) mode */ 1545 eth_fec_get_t fec_get; 1546 /** Set Forward Error Correction(FEC) mode */ 1547 eth_fec_set_t fec_set; 1548 1549 /** Get hairpin peer ports list */ 1550 hairpin_get_peer_ports_t hairpin_get_peer_ports; 1551 /** Bind all hairpin Tx queues of device to the peer port Rx queues */ 1552 eth_hairpin_bind_t hairpin_bind; 1553 /** Unbind all hairpin Tx queues from the peer port Rx queues */ 1554 eth_hairpin_unbind_t hairpin_unbind; 1555 /** Pass the current queue info and get the peer queue info */ 1556 eth_hairpin_queue_peer_update_t hairpin_queue_peer_update; 1557 /** Set up the connection between the pair of hairpin queues */ 1558 eth_hairpin_queue_peer_bind_t hairpin_queue_peer_bind; 1559 /** Disconnect the hairpin queues of a pair from each other */ 1560 eth_hairpin_queue_peer_unbind_t hairpin_queue_peer_unbind; 1561 1562 /** Get power monitoring condition for Rx queue */ 1563 eth_get_monitor_addr_t get_monitor_addr; 1564 1565 /** Get representor info */ 1566 eth_representor_info_get_t representor_info_get; 1567 1568 /** 1569 * Negotiate the NIC's ability to deliver specific 1570 * kinds of metadata to the PMD 1571 */ 1572 eth_rx_metadata_negotiate_t rx_metadata_negotiate; 1573 1574 /** Get IP reassembly capability */ 1575 eth_ip_reassembly_capability_get_t ip_reassembly_capability_get; 1576 /** Get IP reassembly configuration */ 1577 eth_ip_reassembly_conf_get_t ip_reassembly_conf_get; 1578 /** Set IP reassembly configuration */ 1579 eth_ip_reassembly_conf_set_t ip_reassembly_conf_set; 1580 1581 /** Get supported header ptypes to split */ 1582 eth_buffer_split_supported_hdr_ptypes_get_t buffer_split_supported_hdr_ptypes_get; 1583 1584 /** Dump private info from device */ 1585 eth_dev_priv_dump_t eth_dev_priv_dump; 1586 1587 /** Set Rx queue available descriptors threshold */ 1588 eth_rx_queue_avail_thresh_set_t rx_queue_avail_thresh_set; 1589 /** Query Rx queue available descriptors threshold event */ 1590 eth_rx_queue_avail_thresh_query_t rx_queue_avail_thresh_query; 1591 1592 /** Dump Rx descriptor info */ 1593 eth_rx_descriptor_dump_t eth_rx_descriptor_dump; 1594 /** Dump Tx descriptor info */ 1595 eth_tx_descriptor_dump_t eth_tx_descriptor_dump; 1596 1597 /** Get congestion management information */ 1598 eth_cman_info_get_t cman_info_get; 1599 /** Initialize congestion management structure with default values */ 1600 eth_cman_config_init_t cman_config_init; 1601 /** Configure congestion management */ 1602 eth_cman_config_set_t cman_config_set; 1603 /** Retrieve congestion management configuration */ 1604 eth_cman_config_get_t cman_config_get; 1605 1606 /** Get the number of aggregated ports */ 1607 eth_count_aggr_ports_t count_aggr_ports; 1608 /** Map a Tx queue with an aggregated port of the DPDK port */ 1609 eth_map_aggr_tx_affinity_t map_aggr_tx_affinity; 1610 1611 /** Get configuration which ethdev should restore */ 1612 eth_get_restore_flags_t get_restore_flags; 1613 }; 1614 1615 /** 1616 * @internal 1617 * Check if the selected Rx queue is hairpin queue. 1618 * 1619 * @param dev 1620 * Pointer to the selected device. 1621 * @param queue_id 1622 * The selected queue. 1623 * 1624 * @return 1625 * - (1) if the queue is hairpin queue, 0 otherwise. 1626 */ 1627 __rte_internal 1628 int rte_eth_dev_is_rx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id); 1629 1630 /** 1631 * @internal 1632 * Check if the selected Tx queue is hairpin queue. 1633 * 1634 * @param dev 1635 * Pointer to the selected device. 1636 * @param queue_id 1637 * The selected queue. 1638 * 1639 * @return 1640 * - (1) if the queue is hairpin queue, 0 otherwise. 1641 */ 1642 __rte_internal 1643 int rte_eth_dev_is_tx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id); 1644 1645 /** 1646 * @internal 1647 * Returns a ethdev slot specified by the unique identifier name. 1648 * 1649 * @param name 1650 * The pointer to the Unique identifier name for each Ethernet device 1651 * @return 1652 * - The pointer to the ethdev slot, on success. NULL on error 1653 */ 1654 __rte_internal 1655 struct rte_eth_dev *rte_eth_dev_allocated(const char *name); 1656 1657 /** 1658 * @internal 1659 * Allocates a new ethdev slot for an Ethernet device and returns the pointer 1660 * to that slot for the driver to use. 1661 * 1662 * @param name Unique identifier name for each Ethernet device 1663 * @return 1664 * - Slot in the rte_dev_devices array for a new device; 1665 */ 1666 __rte_internal 1667 struct rte_eth_dev *rte_eth_dev_allocate(const char *name); 1668 1669 /** 1670 * @internal 1671 * Attach to the ethdev already initialized by the primary 1672 * process. 1673 * 1674 * @param name Ethernet device's name. 1675 * @return 1676 * - Success: Slot in the rte_dev_devices array for attached 1677 * device. 1678 * - Error: Null pointer. 1679 */ 1680 __rte_internal 1681 struct rte_eth_dev *rte_eth_dev_attach_secondary(const char *name); 1682 1683 /** 1684 * @internal 1685 * Notify RTE_ETH_EVENT_DESTROY and release the specified ethdev port. 1686 * 1687 * The following PMD-managed data fields will be freed: 1688 * - dev_private 1689 * - mac_addrs 1690 * - hash_mac_addrs 1691 * If one of these fields should not be freed, 1692 * it must be reset to NULL by the PMD, typically in dev_close method. 1693 * 1694 * @param eth_dev 1695 * Device to be detached. 1696 * @return 1697 * - 0 on success, negative on error 1698 */ 1699 __rte_internal 1700 int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev); 1701 1702 /** 1703 * @internal 1704 * Release device queues and clear its configuration to force the user 1705 * application to reconfigure it. It is for internal use only. 1706 * 1707 * @param dev 1708 * Pointer to struct rte_eth_dev. 1709 * 1710 * @return 1711 * void 1712 */ 1713 __rte_internal 1714 void rte_eth_dev_internal_reset(struct rte_eth_dev *dev); 1715 1716 /** 1717 * @internal Executes all the user application registered callbacks for 1718 * the specific device. It is for DPDK internal user only. User 1719 * application should not call it directly. 1720 * 1721 * @param dev 1722 * Pointer to struct rte_eth_dev. 1723 * @param event 1724 * Eth device interrupt event type. 1725 * @param ret_param 1726 * To pass data back to user application. 1727 * This allows the user application to decide if a particular function 1728 * is permitted or not. 1729 * 1730 * @return 1731 * int 1732 */ 1733 __rte_internal 1734 int rte_eth_dev_callback_process(struct rte_eth_dev *dev, 1735 enum rte_eth_event_type event, void *ret_param); 1736 1737 /** 1738 * @internal 1739 * This is the last step of device probing. 1740 * It must be called after a port is allocated and initialized successfully. 1741 * 1742 * The notification RTE_ETH_EVENT_NEW is sent to other entities 1743 * (libraries and applications). 1744 * The state is set as RTE_ETH_DEV_ATTACHED. 1745 * 1746 * @param dev 1747 * New ethdev port. 1748 */ 1749 __rte_internal 1750 void rte_eth_dev_probing_finish(struct rte_eth_dev *dev); 1751 1752 /** 1753 * Create memzone for HW rings. 1754 * malloc can't be used as the physical address is needed. 1755 * If the memzone is already created, then this function returns a ptr 1756 * to the old one. 1757 * 1758 * @param eth_dev 1759 * The *eth_dev* pointer is the address of the *rte_eth_dev* structure 1760 * @param name 1761 * The name of the memory zone 1762 * @param queue_id 1763 * The index of the queue to add to name 1764 * @param size 1765 * The sizeof of the memory area 1766 * @param align 1767 * Alignment for resulting memzone. Must be a power of 2. 1768 * @param socket_id 1769 * The *socket_id* argument is the socket identifier in case of NUMA. 1770 */ 1771 __rte_internal 1772 const struct rte_memzone * 1773 rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name, 1774 uint16_t queue_id, size_t size, 1775 unsigned align, int socket_id); 1776 1777 /** 1778 * Free previously allocated memzone for HW rings. 1779 * 1780 * @param eth_dev 1781 * The *eth_dev* pointer is the address of the *rte_eth_dev* structure 1782 * @param name 1783 * The name of the memory zone 1784 * @param queue_id 1785 * The index of the queue to add to name 1786 * @return 1787 * Negative errno value on error, 0 on success. 1788 */ 1789 __rte_internal 1790 int 1791 rte_eth_dma_zone_free(const struct rte_eth_dev *eth_dev, const char *name, 1792 uint16_t queue_id); 1793 1794 /** 1795 * @internal 1796 * Atomically set the link status for the specific device. 1797 * It is for use by DPDK device driver use only. 1798 * User applications should not call it 1799 * 1800 * @param dev 1801 * Pointer to struct rte_eth_dev. 1802 * @param link 1803 * New link status value. 1804 * @return 1805 * Same convention as eth_link_update operation. 1806 * 0 if link up status has changed 1807 * -1 if link up status was unchanged 1808 */ 1809 static inline int 1810 rte_eth_linkstatus_set(struct rte_eth_dev *dev, 1811 const struct rte_eth_link *new_link) 1812 { 1813 struct rte_eth_link old_link; 1814 1815 old_link.val64 = rte_atomic_exchange_explicit(&dev->data->dev_link.val64, 1816 new_link->val64, 1817 rte_memory_order_seq_cst); 1818 1819 return (old_link.link_status == new_link->link_status) ? -1 : 0; 1820 } 1821 1822 /** 1823 * @internal 1824 * Atomically get the link speed and status. 1825 * 1826 * @param dev 1827 * Pointer to struct rte_eth_dev. 1828 * @param link 1829 * link status value. 1830 */ 1831 static inline void 1832 rte_eth_linkstatus_get(const struct rte_eth_dev *dev, 1833 struct rte_eth_link *link) 1834 { 1835 struct rte_eth_link curr_link; 1836 1837 curr_link.val64 = rte_atomic_load_explicit(&dev->data->dev_link.val64, 1838 rte_memory_order_seq_cst); 1839 rte_atomic_store_explicit(&link->val64, curr_link.val64, rte_memory_order_seq_cst); 1840 } 1841 1842 /** 1843 * @internal 1844 * Dummy DPDK callback for Rx/Tx packet burst. 1845 * 1846 * @param queue 1847 * Pointer to Rx/Tx queue 1848 * @param pkts 1849 * Packet array 1850 * @param nb_pkts 1851 * Number of packets in packet array 1852 */ 1853 __rte_internal 1854 uint16_t 1855 rte_eth_pkt_burst_dummy(void *queue __rte_unused, 1856 struct rte_mbuf **pkts __rte_unused, 1857 uint16_t nb_pkts __rte_unused); 1858 1859 /** 1860 * Allocate an unique switch domain identifier. 1861 * 1862 * A pool of switch domain identifiers which can be allocated on request. This 1863 * will enabled devices which support the concept of switch domains to request 1864 * a switch domain ID which is guaranteed to be unique from other devices 1865 * running in the same process. 1866 * 1867 * @param domain_id 1868 * switch domain identifier parameter to pass back to application 1869 * 1870 * @return 1871 * Negative errno value on error, 0 on success. 1872 */ 1873 __rte_internal 1874 int 1875 rte_eth_switch_domain_alloc(uint16_t *domain_id); 1876 1877 /** 1878 * Free switch domain. 1879 * 1880 * Return a switch domain identifier to the pool of free identifiers after it is 1881 * no longer in use by device. 1882 * 1883 * @param domain_id 1884 * switch domain identifier to free 1885 * 1886 * @return 1887 * Negative errno value on error, 0 on success. 1888 */ 1889 __rte_internal 1890 int 1891 rte_eth_switch_domain_free(uint16_t domain_id); 1892 1893 /** 1894 * Generic Ethernet device arguments 1895 * 1896 * One type of representor each structure. 1897 */ 1898 struct rte_eth_devargs { 1899 uint16_t mh_controllers[RTE_MAX_MULTI_HOST_CTRLS]; 1900 /** controller/s number in case of multi-host */ 1901 uint16_t nb_mh_controllers; 1902 /** number of controllers in multi-host controllers field */ 1903 uint16_t ports[RTE_MAX_ETHPORTS]; 1904 /** port/s number to enable on a multi-port single function */ 1905 uint16_t nb_ports; 1906 /** number of ports in ports field */ 1907 uint16_t representor_ports[RTE_MAX_ETHPORTS]; 1908 /** representor port/s identifier to enable on device */ 1909 uint16_t nb_representor_ports; 1910 /** number of ports in representor port field */ 1911 enum rte_eth_representor_type type; /* type of representor */ 1912 }; 1913 1914 /** 1915 * PMD helper function to get representor ID from location detail. 1916 * 1917 * Get representor ID from controller, pf and (sf or vf). 1918 * The mapping is retrieved from rte_eth_representor_info_get(). 1919 * 1920 * For backward compatibility, if no representor info, direct 1921 * map legacy VF (no controller and pf). 1922 * 1923 * @param port_id 1924 * Port ID of the backing device. 1925 * @param type 1926 * Representor type. 1927 * @param controller 1928 * Controller ID, -1 if unspecified. 1929 * @param pf 1930 * PF port ID, -1 if unspecified. 1931 * @param representor_port 1932 * VF or SF representor port number, -1 if unspecified. 1933 * @param repr_id 1934 * Pointer to output representor ID. 1935 * 1936 * @return 1937 * Negative errno value on error, 0 on success. 1938 */ 1939 __rte_internal 1940 int 1941 rte_eth_representor_id_get(uint16_t port_id, 1942 enum rte_eth_representor_type type, 1943 int controller, int pf, int representor_port, 1944 uint16_t *repr_id); 1945 1946 /** 1947 * @internal 1948 * Check if the ethdev is a representor port. 1949 * 1950 * @param dev 1951 * Pointer to struct rte_eth_dev. 1952 * 1953 * @return 1954 * false the ethdev is not a representor port. 1955 * true the ethdev is a representor port. 1956 */ 1957 static inline bool 1958 rte_eth_dev_is_repr(const struct rte_eth_dev *dev) 1959 { 1960 return ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0); 1961 } 1962 1963 /** 1964 * PMD helper function to parse ethdev arguments 1965 * 1966 * @param devargs 1967 * device arguments 1968 * @param eth_devargs 1969 * contiguous memory populated with parsed ethdev specific arguments. 1970 * @param nb_da 1971 * size of eth_devargs array passed 1972 * 1973 * @return 1974 * Negative errno value on error, no of devargs parsed on success. 1975 */ 1976 __rte_internal 1977 int 1978 rte_eth_devargs_parse(const char *devargs, struct rte_eth_devargs *eth_devargs, 1979 unsigned int nb_da); 1980 1981 1982 typedef int (*ethdev_init_t)(struct rte_eth_dev *ethdev, void *init_params); 1983 typedef int (*ethdev_bus_specific_init)(struct rte_eth_dev *ethdev, 1984 void *bus_specific_init_params); 1985 1986 /** 1987 * PMD helper function for the creation of a new ethdev ports. 1988 * 1989 * @param device 1990 * rte_device handle. 1991 * @param name 1992 * port name. 1993 * @param priv_data_size 1994 * size of private data required for port. 1995 * @param bus_specific_init 1996 * port bus specific initialisation callback function 1997 * @param bus_init_params 1998 * port bus specific initialisation parameters 1999 * @param ethdev_init 2000 * device specific port initialization callback function 2001 * @param init_params 2002 * port initialisation parameters 2003 * 2004 * @return 2005 * Negative errno value on error, 0 on success. 2006 */ 2007 __rte_internal 2008 int 2009 rte_eth_dev_create(struct rte_device *device, const char *name, 2010 size_t priv_data_size, 2011 ethdev_bus_specific_init bus_specific_init, void *bus_init_params, 2012 ethdev_init_t ethdev_init, void *init_params); 2013 2014 2015 typedef int (*ethdev_uninit_t)(struct rte_eth_dev *ethdev); 2016 2017 /** 2018 * PMD helper function for cleaning up the resources of a ethdev port on it's 2019 * destruction. 2020 * 2021 * @param ethdev 2022 * ethdev handle of port. 2023 * @param ethdev_uninit 2024 * device specific port un-initialise callback function 2025 * 2026 * @return 2027 * Negative errno value on error, 0 on success. 2028 */ 2029 __rte_internal 2030 int 2031 rte_eth_dev_destroy(struct rte_eth_dev *ethdev, ethdev_uninit_t ethdev_uninit); 2032 2033 /** 2034 * @internal 2035 * Pass the current hairpin queue HW and/or SW information to the peer queue 2036 * and fetch back the information of the peer queue. 2037 * 2038 * @param peer_port 2039 * Peer port identifier of the Ethernet device. 2040 * @param peer_queue 2041 * Peer queue index of the port. 2042 * @param cur_info 2043 * Pointer to the current information structure. 2044 * @param peer_info 2045 * Pointer to the peer information, output. 2046 * @param direction 2047 * Direction to pass the information. 2048 * positive - pass Tx queue information and get peer Rx queue information 2049 * zero - pass Rx queue information and get peer Tx queue information 2050 * 2051 * @return 2052 * Negative errno value on error, 0 on success. 2053 */ 2054 __rte_internal 2055 int 2056 rte_eth_hairpin_queue_peer_update(uint16_t peer_port, uint16_t peer_queue, 2057 struct rte_hairpin_peer_info *cur_info, 2058 struct rte_hairpin_peer_info *peer_info, 2059 uint32_t direction); 2060 2061 /** 2062 * @internal 2063 * Configure current hairpin queue with the peer information fetched to create 2064 * the connection (bind) with peer queue in the specified direction. 2065 * This function might need to be called twice to fully create the connections. 2066 * 2067 * @param cur_port 2068 * Current port identifier of the Ethernet device. 2069 * @param cur_queue 2070 * Current queue index of the port. 2071 * @param peer_info 2072 * Pointer to the peer information, input. 2073 * @param direction 2074 * Direction to create the connection. 2075 * positive - bind current Tx queue to peer Rx queue 2076 * zero - bind current Rx queue to peer Tx queue 2077 * 2078 * @return 2079 * Negative errno value on error, 0 on success. 2080 */ 2081 __rte_internal 2082 int 2083 rte_eth_hairpin_queue_peer_bind(uint16_t cur_port, uint16_t cur_queue, 2084 struct rte_hairpin_peer_info *peer_info, 2085 uint32_t direction); 2086 2087 /** 2088 * @internal 2089 * Get rte_eth_dev from device name. The device name should be specified 2090 * as below: 2091 * - PCIe address (Domain:Bus:Device.Function), for example 0000:2:00.0 2092 * - SoC device name, for example fsl-gmac0 2093 * - vdev dpdk name, for example net_[pcap0|null0|tap0] 2094 * 2095 * @param name 2096 * PCI address or name of the device 2097 * @return 2098 * - rte_eth_dev if successful 2099 * - NULL on failure 2100 */ 2101 __rte_internal 2102 struct rte_eth_dev* 2103 rte_eth_dev_get_by_name(const char *name); 2104 2105 /** 2106 * @internal 2107 * Reset the current queue state and configuration to disconnect (unbind) it 2108 * from the peer queue. 2109 * This function might need to be called twice to disconnect each other. 2110 * 2111 * @param cur_port 2112 * Current port identifier of the Ethernet device. 2113 * @param cur_queue 2114 * Current queue index of the port. 2115 * @param direction 2116 * Direction to destroy the connection. 2117 * positive - unbind current Tx queue from peer Rx queue 2118 * zero - unbind current Rx queue from peer Tx queue 2119 * 2120 * @return 2121 * Negative errno value on error, 0 on success. 2122 */ 2123 __rte_internal 2124 int 2125 rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t cur_queue, 2126 uint32_t direction); 2127 2128 /** 2129 * @internal 2130 * Register mbuf dynamic field and flag for IP reassembly incomplete case. 2131 */ 2132 __rte_internal 2133 int 2134 rte_eth_ip_reassembly_dynfield_register(int *field_offset, int *flag); 2135 2136 2137 /* 2138 * Legacy ethdev API used internally by drivers. 2139 */ 2140 2141 enum rte_filter_type { 2142 RTE_ETH_FILTER_NONE = 0, 2143 RTE_ETH_FILTER_ETHERTYPE, 2144 RTE_ETH_FILTER_FLEXIBLE, 2145 RTE_ETH_FILTER_SYN, 2146 RTE_ETH_FILTER_NTUPLE, 2147 RTE_ETH_FILTER_TUNNEL, 2148 RTE_ETH_FILTER_FDIR, 2149 RTE_ETH_FILTER_HASH, 2150 RTE_ETH_FILTER_L2_TUNNEL, 2151 }; 2152 2153 /** 2154 * Define all structures for Ethertype Filter type. 2155 */ 2156 2157 #define RTE_ETHTYPE_FLAGS_MAC 0x0001 /**< If set, compare mac */ 2158 #define RTE_ETHTYPE_FLAGS_DROP 0x0002 /**< If set, drop packet when match */ 2159 2160 /** 2161 * A structure used to define the ethertype filter entry 2162 * to support RTE_ETH_FILTER_ETHERTYPE data representation. 2163 */ 2164 struct rte_eth_ethertype_filter { 2165 struct rte_ether_addr mac_addr; /**< Mac address to match */ 2166 uint16_t ether_type; /**< Ether type to match */ 2167 uint16_t flags; /**< Flags from RTE_ETHTYPE_FLAGS_* */ 2168 uint16_t queue; /**< Queue assigned to when match */ 2169 }; 2170 2171 /** 2172 * A structure used to define the TCP syn filter entry 2173 * to support RTE_ETH_FILTER_SYN data representation. 2174 */ 2175 struct rte_eth_syn_filter { 2176 /** 1 - higher priority than other filters, 0 - lower priority */ 2177 uint8_t hig_pri; 2178 uint16_t queue; /**< Queue assigned to when match */ 2179 }; 2180 2181 /** 2182 * filter type of tunneling packet 2183 */ 2184 #define RTE_ETH_TUNNEL_FILTER_OMAC 0x01 /**< filter by outer MAC addr */ 2185 #define RTE_ETH_TUNNEL_FILTER_OIP 0x02 /**< filter by outer IP Addr */ 2186 #define RTE_ETH_TUNNEL_FILTER_TENID 0x04 /**< filter by tenant ID */ 2187 #define RTE_ETH_TUNNEL_FILTER_IMAC 0x08 /**< filter by inner MAC addr */ 2188 #define RTE_ETH_TUNNEL_FILTER_IVLAN 0x10 /**< filter by inner VLAN ID */ 2189 #define RTE_ETH_TUNNEL_FILTER_IIP 0x20 /**< filter by inner IP addr */ 2190 2191 #define RTE_ETH_TUNNEL_FILTER_IMAC_IVLAN (RTE_ETH_TUNNEL_FILTER_IMAC | \ 2192 RTE_ETH_TUNNEL_FILTER_IVLAN) 2193 #define RTE_ETH_TUNNEL_FILTER_IMAC_IVLAN_TENID (RTE_ETH_TUNNEL_FILTER_IMAC | \ 2194 RTE_ETH_TUNNEL_FILTER_IVLAN | \ 2195 RTE_ETH_TUNNEL_FILTER_TENID) 2196 #define RTE_ETH_TUNNEL_FILTER_IMAC_TENID (RTE_ETH_TUNNEL_FILTER_IMAC | \ 2197 RTE_ETH_TUNNEL_FILTER_TENID) 2198 #define RTE_ETH_TUNNEL_FILTER_OMAC_TENID_IMAC (RTE_ETH_TUNNEL_FILTER_OMAC | \ 2199 RTE_ETH_TUNNEL_FILTER_TENID | \ 2200 RTE_ETH_TUNNEL_FILTER_IMAC) 2201 2202 /** 2203 * Select IPv4 or IPv6 for tunnel filters. 2204 */ 2205 enum rte_tunnel_iptype { 2206 RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4 */ 2207 RTE_TUNNEL_IPTYPE_IPV6, /**< IPv6 */ 2208 }; 2209 2210 /** 2211 * Tunneling Packet filter configuration. 2212 */ 2213 struct rte_eth_tunnel_filter_conf { 2214 struct rte_ether_addr outer_mac; /**< Outer MAC address to match */ 2215 struct rte_ether_addr inner_mac; /**< Inner MAC address to match */ 2216 uint16_t inner_vlan; /**< Inner VLAN to match */ 2217 enum rte_tunnel_iptype ip_type; /**< IP address type */ 2218 /** 2219 * Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP 2220 * is set in filter_type, or inner destination IP address to match 2221 * if ETH_TUNNEL_FILTER_IIP is set in filter_type. 2222 */ 2223 union { 2224 uint32_t ipv4_addr; /**< IPv4 address in big endian */ 2225 uint32_t ipv6_addr[4]; /**< IPv6 address in big endian */ 2226 } ip_addr; 2227 /** Flags from ETH_TUNNEL_FILTER_XX - see above */ 2228 uint16_t filter_type; 2229 enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type */ 2230 uint32_t tenant_id; /**< Tenant ID to match: VNI, GRE key... */ 2231 uint16_t queue_id; /**< Queue assigned to if match */ 2232 }; 2233 2234 /** 2235 * Memory space that can be configured to store Flow Director filters 2236 * in the board memory. 2237 */ 2238 enum rte_eth_fdir_pballoc_type { 2239 RTE_ETH_FDIR_PBALLOC_64K = 0, /**< 64k. */ 2240 RTE_ETH_FDIR_PBALLOC_128K, /**< 128k. */ 2241 RTE_ETH_FDIR_PBALLOC_256K, /**< 256k. */ 2242 }; 2243 2244 /** 2245 * Select report mode of FDIR hash information in Rx descriptors. 2246 */ 2247 enum rte_fdir_status_mode { 2248 RTE_FDIR_NO_REPORT_STATUS = 0, /**< Never report FDIR hash. */ 2249 RTE_FDIR_REPORT_STATUS, /**< Only report FDIR hash for matching pkts. */ 2250 RTE_FDIR_REPORT_STATUS_ALWAYS, /**< Always report FDIR hash. */ 2251 }; 2252 2253 /** 2254 * A structure used to configure the Flow Director (FDIR) feature 2255 * of an Ethernet port. 2256 * 2257 * If mode is RTE_FDIR_MODE_NONE, the pballoc value is ignored. 2258 */ 2259 struct rte_eth_fdir_conf { 2260 enum rte_fdir_mode mode; /**< Flow Director mode. */ 2261 enum rte_eth_fdir_pballoc_type pballoc; /**< Space for FDIR filters. */ 2262 enum rte_fdir_status_mode status; /**< How to report FDIR hash. */ 2263 /** Rx queue of packets matching a "drop" filter in perfect mode. */ 2264 uint8_t drop_queue; 2265 struct rte_eth_fdir_masks mask; 2266 /** Flex payload configuration. */ 2267 struct rte_eth_fdir_flex_conf flex_conf; 2268 }; 2269 2270 /** 2271 * @internal 2272 * Fetch from the driver what kind of configuration must be restored by ethdev layer, 2273 * using get_restore_flags() callback. 2274 * 2275 * If callback is not defined, it is assumed that all supported configuration must be restored. 2276 * 2277 * @param dev 2278 * Port (ethdev) handle. 2279 * @param op 2280 * Type of operation executed by the application. 2281 * 2282 * @return 2283 * ORed restore flags indicating which configuration should be restored by ethdev. 2284 * 0 if no restore is required by the driver. 2285 */ 2286 __rte_internal 2287 uint64_t 2288 rte_eth_get_restore_flags(struct rte_eth_dev *dev, 2289 enum rte_eth_dev_operation op); 2290 2291 #ifdef __cplusplus 2292 } 2293 #endif 2294 2295 #endif /* _RTE_ETHDEV_DRIVER_H_ */ 2296