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 18#include <rte_ethdev.h> 19 20/** 21 * @internal 22 * Structure used to hold information about the callbacks to be called for a 23 * queue on Rx and Tx. 24 */ 25struct rte_eth_rxtx_callback { 26 struct rte_eth_rxtx_callback *next; 27 union{ 28 rte_rx_callback_fn rx; 29 rte_tx_callback_fn tx; 30 } fn; 31 void *param; 32}; 33 34/** 35 * @internal 36 * The generic data structure associated with each Ethernet device. 37 * 38 * Pointers to burst-oriented packet receive and transmit functions are 39 * located at the beginning of the structure, along with the pointer to 40 * where all the data elements for the particular device are stored in shared 41 * memory. This split allows the function pointer and driver data to be per- 42 * process, while the actual configuration data for the device is shared. 43 */ 44struct rte_eth_dev { 45 eth_rx_burst_t rx_pkt_burst; /**< Pointer to PMD receive function */ 46 eth_tx_burst_t tx_pkt_burst; /**< Pointer to PMD transmit function */ 47 48 /** Pointer to PMD transmit prepare function */ 49 eth_tx_prep_t tx_pkt_prepare; 50 /** Get the number of used Rx descriptors */ 51 eth_rx_queue_count_t rx_queue_count; 52 /** Check the status of a Rx descriptor */ 53 eth_rx_descriptor_status_t rx_descriptor_status; 54 /** Check the status of a Tx descriptor */ 55 eth_tx_descriptor_status_t tx_descriptor_status; 56 57 /** 58 * Device data that is shared between primary and secondary processes 59 */ 60 struct rte_eth_dev_data *data; 61 void *process_private; /**< Pointer to per-process device data */ 62 const struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */ 63 struct rte_device *device; /**< Backing device */ 64 struct rte_intr_handle *intr_handle; /**< Device interrupt handle */ 65 66 /** User application callbacks for NIC interrupts */ 67 struct rte_eth_dev_cb_list link_intr_cbs; 68 /** 69 * User-supplied functions called from rx_burst to post-process 70 * received packets before passing them to the user 71 */ 72 struct rte_eth_rxtx_callback *post_rx_burst_cbs[RTE_MAX_QUEUES_PER_PORT]; 73 /** 74 * User-supplied functions called from tx_burst to pre-process 75 * received packets before passing them to the driver for transmission 76 */ 77 struct rte_eth_rxtx_callback *pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT]; 78 79 enum rte_eth_dev_state state; /**< Flag indicating the port state */ 80 void *security_ctx; /**< Context for security ops */ 81} __rte_cache_aligned; 82 83struct rte_eth_dev_sriov; 84struct rte_eth_dev_owner; 85 86/** 87 * @internal 88 * The data part, with no function pointers, associated with each Ethernet 89 * device. This structure is safe to place in shared memory to be common 90 * among different processes in a multi-process configuration. 91 */ 92struct rte_eth_dev_data { 93 char name[RTE_ETH_NAME_MAX_LEN]; /**< Unique identifier name */ 94 95 void **rx_queues; /**< Array of pointers to Rx queues */ 96 void **tx_queues; /**< Array of pointers to Tx queues */ 97 uint16_t nb_rx_queues; /**< Number of Rx queues */ 98 uint16_t nb_tx_queues; /**< Number of Tx queues */ 99 100 struct rte_eth_dev_sriov sriov; /**< SRIOV data */ 101 102 /** PMD-specific private data. @see rte_eth_dev_release_port() */ 103 void *dev_private; 104 105 struct rte_eth_link dev_link; /**< Link-level information & status */ 106 struct rte_eth_conf dev_conf; /**< Configuration applied to device */ 107 uint16_t mtu; /**< Maximum Transmission Unit */ 108 109 /** Common Rx buffer size handled by all queues */ 110 uint32_t min_rx_buf_size; 111 112 uint64_t rx_mbuf_alloc_failed; /**< Rx ring mbuf allocation failures */ 113 114 /** Device Ethernet link address. @see rte_eth_dev_release_port() */ 115 struct rte_ether_addr *mac_addrs; 116 /** Bitmap associating MAC addresses to pools */ 117 uint64_t mac_pool_sel[RTE_ETH_NUM_RECEIVE_MAC_ADDR]; 118 /** 119 * Device Ethernet MAC addresses of hash filtering. 120 * @see rte_eth_dev_release_port() 121 */ 122 struct rte_ether_addr *hash_mac_addrs; 123 124 uint16_t port_id; /**< Device [external] port identifier */ 125 126 __extension__ 127 uint8_t /** Rx promiscuous mode ON(1) / OFF(0) */ 128 promiscuous : 1, 129 /** Rx of scattered packets is ON(1) / OFF(0) */ 130 scattered_rx : 1, 131 /** Rx all multicast mode ON(1) / OFF(0) */ 132 all_multicast : 1, 133 /** Device state: STARTED(1) / STOPPED(0) */ 134 dev_started : 1, 135 /** Rx LRO is ON(1) / OFF(0) */ 136 lro : 1, 137 /** 138 * Indicates whether the device is configured: 139 * CONFIGURED(1) / NOT CONFIGURED(0) 140 */ 141 dev_configured : 1; 142 143 /** Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0) */ 144 uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT]; 145 /** Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0) */ 146 uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT]; 147 148 uint32_t dev_flags; /**< Capabilities */ 149 int numa_node; /**< NUMA node connection */ 150 151 /** VLAN filter configuration */ 152 struct rte_vlan_filter_conf vlan_filter_conf; 153 154 struct rte_eth_dev_owner owner; /**< The port owner */ 155 156 /** 157 * Switch-specific identifier. 158 * Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags. 159 */ 160 uint16_t representor_id; 161 /** 162 * Port ID of the backing device. 163 * This device will be used to query representor info and calculate 164 * representor IDs. Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags. 165 */ 166 uint16_t backer_port_id; 167 168 pthread_mutex_t flow_ops_mutex; /**< rte_flow ops mutex */ 169} __rte_cache_aligned; 170 171/** 172 * @internal 173 * The pool of *rte_eth_dev* structures. The size of the pool 174 * is configured at compile-time in the <rte_ethdev.c> file. 175 */ 176extern struct rte_eth_dev rte_eth_devices[]; 177 178/** @internal Declaration of the hairpin peer queue information structure. */ 179struct rte_hairpin_peer_info; 180 181/* 182 * Definitions of all functions exported by an Ethernet driver through the 183 * generic structure of type *eth_dev_ops* supplied in the *rte_eth_dev* 184 * structure associated with an Ethernet device. 185 */ 186 187/** @internal Ethernet device configuration. */ 188typedef int (*eth_dev_configure_t)(struct rte_eth_dev *dev); 189 190/** @internal Function used to start a configured Ethernet device. */ 191typedef int (*eth_dev_start_t)(struct rte_eth_dev *dev); 192 193/** @internal Function used to stop a configured Ethernet device. */ 194typedef int (*eth_dev_stop_t)(struct rte_eth_dev *dev); 195 196/** @internal Function used to link up a configured Ethernet device. */ 197typedef int (*eth_dev_set_link_up_t)(struct rte_eth_dev *dev); 198 199/** @internal Function used to link down a configured Ethernet device. */ 200typedef int (*eth_dev_set_link_down_t)(struct rte_eth_dev *dev); 201 202/** @internal Function used to close a configured Ethernet device. */ 203typedef int (*eth_dev_close_t)(struct rte_eth_dev *dev); 204 205/** @internal Function used to reset a configured Ethernet device. */ 206typedef int (*eth_dev_reset_t)(struct rte_eth_dev *dev); 207 208/** @internal Function used to detect an Ethernet device removal. */ 209typedef int (*eth_is_removed_t)(struct rte_eth_dev *dev); 210 211/** 212 * @internal 213 * Function used to enable the Rx promiscuous mode of an Ethernet device. 214 * 215 * @param dev 216 * ethdev handle of port. 217 * 218 * @return 219 * Negative errno value on error, 0 on success. 220 * 221 * @retval 0 222 * Success, promiscuous mode is enabled. 223 * @retval -ENOTSUP 224 * Promiscuous mode is not supported. 225 * @retval -ENODEV 226 * Device is gone. 227 * @retval -E_RTE_SECONDARY 228 * Function was called from a secondary process instance and not supported. 229 * @retval -ETIMEDOUT 230 * Attempt to enable promiscuous mode failed because of timeout. 231 * @retval -EAGAIN 232 * Failed to enable promiscuous mode. 233 */ 234typedef int (*eth_promiscuous_enable_t)(struct rte_eth_dev *dev); 235 236/** 237 * @internal 238 * Function used to disable the Rx promiscuous mode of an Ethernet device. 239 * 240 * @param dev 241 * ethdev handle of port. 242 * 243 * @return 244 * Negative errno value on error, 0 on success. 245 * 246 * @retval 0 247 * Success, promiscuous mode is disabled. 248 * @retval -ENOTSUP 249 * Promiscuous mode disabling is not supported. 250 * @retval -ENODEV 251 * Device is gone. 252 * @retval -E_RTE_SECONDARY 253 * Function was called from a secondary process instance and not supported. 254 * @retval -ETIMEDOUT 255 * Attempt to disable promiscuous mode failed because of timeout. 256 * @retval -EAGAIN 257 * Failed to disable promiscuous mode. 258 */ 259typedef int (*eth_promiscuous_disable_t)(struct rte_eth_dev *dev); 260 261/** 262 * @internal 263 * Enable the receipt of all multicast packets by an Ethernet device. 264 * 265 * @param dev 266 * ethdev handle of port. 267 * 268 * @return 269 * Negative errno value on error, 0 on success. 270 * 271 * @retval 0 272 * Success, all-multicast mode is enabled. 273 * @retval -ENOTSUP 274 * All-multicast mode is not supported. 275 * @retval -ENODEV 276 * Device is gone. 277 * @retval -E_RTE_SECONDARY 278 * Function was called from a secondary process instance and not supported. 279 * @retval -ETIMEDOUT 280 * Attempt to enable all-multicast mode failed because of timeout. 281 * @retval -EAGAIN 282 * Failed to enable all-multicast mode. 283 */ 284typedef int (*eth_allmulticast_enable_t)(struct rte_eth_dev *dev); 285 286/** 287 * @internal 288 * Disable the receipt of all multicast packets by an Ethernet device. 289 * 290 * @param dev 291 * ethdev handle of port. 292 * 293 * @return 294 * Negative errno value on error, 0 on success. 295 * 296 * @retval 0 297 * Success, all-multicast mode is disabled. 298 * @retval -ENOTSUP 299 * All-multicast mode disabling is not supported. 300 * @retval -ENODEV 301 * Device is gone. 302 * @retval -E_RTE_SECONDARY 303 * Function was called from a secondary process instance and not supported. 304 * @retval -ETIMEDOUT 305 * Attempt to disable all-multicast mode failed because of timeout. 306 * @retval -EAGAIN 307 * Failed to disable all-multicast mode. 308 */ 309typedef int (*eth_allmulticast_disable_t)(struct rte_eth_dev *dev); 310 311/** 312 * @internal 313 * Get link speed, duplex mode and state (up/down) of an Ethernet device. 314 */ 315typedef int (*eth_link_update_t)(struct rte_eth_dev *dev, 316 int wait_to_complete); 317 318/** @internal Get global I/O statistics of an Ethernet device. */ 319typedef int (*eth_stats_get_t)(struct rte_eth_dev *dev, 320 struct rte_eth_stats *igb_stats); 321 322/** 323 * @internal 324 * Reset global I/O statistics of an Ethernet device to 0. 325 * 326 * @param dev 327 * ethdev handle of port. 328 * 329 * @return 330 * Negative errno value on error, 0 on success. 331 * 332 * @retval 0 333 * Success, statistics has been reset. 334 * @retval -ENOTSUP 335 * Resetting statistics is not supported. 336 * @retval -EINVAL 337 * Resetting statistics is not valid. 338 * @retval -ENOMEM 339 * Not enough memory to get the stats. 340 */ 341typedef int (*eth_stats_reset_t)(struct rte_eth_dev *dev); 342 343/** @internal Get extended stats of an Ethernet device. */ 344typedef int (*eth_xstats_get_t)(struct rte_eth_dev *dev, 345 struct rte_eth_xstat *stats, unsigned int n); 346 347/** 348 * @internal 349 * Get extended stats of an Ethernet device. 350 * 351 * @param dev 352 * ethdev handle of port. 353 * @param ids 354 * IDs array to retrieve specific statistics. Must not be NULL. 355 * @param values 356 * A pointer to a table to be filled with device statistics values. 357 * Must not be NULL. 358 * @param n 359 * Element count in @p ids and @p values. 360 * 361 * @return 362 * - A number of filled in stats. 363 * - A negative value on error. 364 */ 365typedef int (*eth_xstats_get_by_id_t)(struct rte_eth_dev *dev, 366 const uint64_t *ids, 367 uint64_t *values, 368 unsigned int n); 369 370/** 371 * @internal 372 * Reset extended stats of an Ethernet device. 373 * 374 * @param dev 375 * ethdev handle of port. 376 * 377 * @return 378 * Negative errno value on error, 0 on success. 379 * 380 * @retval 0 381 * Success, statistics has been reset. 382 * @retval -ENOTSUP 383 * Resetting statistics is not supported. 384 * @retval -EINVAL 385 * Resetting statistics is not valid. 386 * @retval -ENOMEM 387 * Not enough memory to get the stats. 388 */ 389typedef int (*eth_xstats_reset_t)(struct rte_eth_dev *dev); 390 391/** @internal Get names of extended stats of an Ethernet device. */ 392typedef int (*eth_xstats_get_names_t)(struct rte_eth_dev *dev, 393 struct rte_eth_xstat_name *xstats_names, unsigned int size); 394 395/** 396 * @internal 397 * Get names of extended stats of an Ethernet device. 398 * 399 * @param dev 400 * ethdev handle of port. 401 * @param ids 402 * IDs array to retrieve specific statistics. Must not be NULL. 403 * @param xstats_names 404 * An rte_eth_xstat_name array of at least @p size elements to be filled. 405 * Must not be NULL. 406 * @param size 407 * Element count in @p ids and @p xstats_names. 408 * 409 * @return 410 * - A number of filled in stats. 411 * - A negative value on error. 412 */ 413typedef int (*eth_xstats_get_names_by_id_t)(struct rte_eth_dev *dev, 414 const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, 415 unsigned int size); 416 417/** 418 * @internal 419 * Set a queue statistics mapping for a Tx/Rx queue of an Ethernet device. 420 */ 421typedef int (*eth_queue_stats_mapping_set_t)(struct rte_eth_dev *dev, 422 uint16_t queue_id, 423 uint8_t stat_idx, 424 uint8_t is_rx); 425 426/** @internal Get specific information of an Ethernet device. */ 427typedef int (*eth_dev_infos_get_t)(struct rte_eth_dev *dev, 428 struct rte_eth_dev_info *dev_info); 429 430/** @internal Get supported ptypes of an Ethernet device. */ 431typedef const uint32_t *(*eth_dev_supported_ptypes_get_t)(struct rte_eth_dev *dev); 432 433/** 434 * @internal 435 * Inform Ethernet device about reduced range of packet types to handle. 436 * 437 * @param dev 438 * The Ethernet device identifier. 439 * @param ptype_mask 440 * The ptype family that application is interested in should be bitwise OR of 441 * RTE_PTYPE_*_MASK or 0. 442 * @return 443 * - (0) if Success. 444 */ 445typedef int (*eth_dev_ptypes_set_t)(struct rte_eth_dev *dev, 446 uint32_t ptype_mask); 447 448/** @internal Start Rx and Tx of a queue of an Ethernet device. */ 449typedef int (*eth_queue_start_t)(struct rte_eth_dev *dev, 450 uint16_t queue_id); 451 452/** @internal Stop Rx and Tx of a queue of an Ethernet device. */ 453typedef int (*eth_queue_stop_t)(struct rte_eth_dev *dev, 454 uint16_t queue_id); 455 456/** @internal Set up a receive queue of an Ethernet device. */ 457typedef int (*eth_rx_queue_setup_t)(struct rte_eth_dev *dev, 458 uint16_t rx_queue_id, 459 uint16_t nb_rx_desc, 460 unsigned int socket_id, 461 const struct rte_eth_rxconf *rx_conf, 462 struct rte_mempool *mb_pool); 463 464/** @internal Setup a transmit queue of an Ethernet device. */ 465typedef int (*eth_tx_queue_setup_t)(struct rte_eth_dev *dev, 466 uint16_t tx_queue_id, 467 uint16_t nb_tx_desc, 468 unsigned int socket_id, 469 const struct rte_eth_txconf *tx_conf); 470 471/** @internal Enable interrupt of a receive queue of an Ethernet device. */ 472typedef int (*eth_rx_enable_intr_t)(struct rte_eth_dev *dev, 473 uint16_t rx_queue_id); 474 475/** @internal Disable interrupt of a receive queue of an Ethernet device. */ 476typedef int (*eth_rx_disable_intr_t)(struct rte_eth_dev *dev, 477 uint16_t rx_queue_id); 478 479/** @internal Release memory resources allocated by given Rx/Tx queue. */ 480typedef void (*eth_queue_release_t)(struct rte_eth_dev *dev, 481 uint16_t queue_id); 482 483/** @internal Get firmware information of an Ethernet device. */ 484typedef int (*eth_fw_version_get_t)(struct rte_eth_dev *dev, 485 char *fw_version, size_t fw_size); 486 487/** @internal Force mbufs to be from Tx ring. */ 488typedef int (*eth_tx_done_cleanup_t)(void *txq, uint32_t free_cnt); 489 490typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev, 491 uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo); 492 493typedef void (*eth_txq_info_get_t)(struct rte_eth_dev *dev, 494 uint16_t tx_queue_id, struct rte_eth_txq_info *qinfo); 495 496typedef int (*eth_burst_mode_get_t)(struct rte_eth_dev *dev, 497 uint16_t queue_id, struct rte_eth_burst_mode *mode); 498 499/** @internal Set MTU. */ 500typedef int (*mtu_set_t)(struct rte_eth_dev *dev, uint16_t mtu); 501 502/** @internal Filtering of a VLAN Tag Identifier by an Ethernet device. */ 503typedef int (*vlan_filter_set_t)(struct rte_eth_dev *dev, 504 uint16_t vlan_id, 505 int on); 506 507/** @internal Set the outer/inner VLAN-TPID by an Ethernet device. */ 508typedef int (*vlan_tpid_set_t)(struct rte_eth_dev *dev, 509 enum rte_vlan_type type, uint16_t tpid); 510 511/** @internal Set VLAN offload function by an Ethernet device. */ 512typedef int (*vlan_offload_set_t)(struct rte_eth_dev *dev, int mask); 513 514/** @internal Set port based Tx VLAN insertion by an Ethernet device. */ 515typedef int (*vlan_pvid_set_t)(struct rte_eth_dev *dev, 516 uint16_t vlan_id, 517 int on); 518 519/** @internal VLAN stripping enable/disable by an queue of Ethernet device. */ 520typedef void (*vlan_strip_queue_set_t)(struct rte_eth_dev *dev, 521 uint16_t rx_queue_id, 522 int on); 523 524/** @internal Get current flow control parameter on an Ethernet device. */ 525typedef int (*flow_ctrl_get_t)(struct rte_eth_dev *dev, 526 struct rte_eth_fc_conf *fc_conf); 527 528/** @internal Setup flow control parameter on an Ethernet device. */ 529typedef int (*flow_ctrl_set_t)(struct rte_eth_dev *dev, 530 struct rte_eth_fc_conf *fc_conf); 531 532/** @internal Setup priority flow control parameter on an Ethernet device. */ 533typedef int (*priority_flow_ctrl_set_t)(struct rte_eth_dev *dev, 534 struct rte_eth_pfc_conf *pfc_conf); 535 536/** @internal Update RSS redirection table on an Ethernet device. */ 537typedef int (*reta_update_t)(struct rte_eth_dev *dev, 538 struct rte_eth_rss_reta_entry64 *reta_conf, 539 uint16_t reta_size); 540 541/** @internal Query RSS redirection table on an Ethernet device. */ 542typedef int (*reta_query_t)(struct rte_eth_dev *dev, 543 struct rte_eth_rss_reta_entry64 *reta_conf, 544 uint16_t reta_size); 545 546/** @internal Update RSS hash configuration of an Ethernet device. */ 547typedef int (*rss_hash_update_t)(struct rte_eth_dev *dev, 548 struct rte_eth_rss_conf *rss_conf); 549 550/** @internal Get current RSS hash configuration of an Ethernet device. */ 551typedef int (*rss_hash_conf_get_t)(struct rte_eth_dev *dev, 552 struct rte_eth_rss_conf *rss_conf); 553 554/** @internal Turn on SW controllable LED on an Ethernet device. */ 555typedef int (*eth_dev_led_on_t)(struct rte_eth_dev *dev); 556 557/** @internal Turn off SW controllable LED on an Ethernet device. */ 558typedef int (*eth_dev_led_off_t)(struct rte_eth_dev *dev); 559 560/** @internal Remove MAC address from receive address register. */ 561typedef void (*eth_mac_addr_remove_t)(struct rte_eth_dev *dev, uint32_t index); 562 563/** @internal Set a MAC address into Receive Address Register. */ 564typedef int (*eth_mac_addr_add_t)(struct rte_eth_dev *dev, 565 struct rte_ether_addr *mac_addr, 566 uint32_t index, 567 uint32_t vmdq); 568 569/** @internal Set a MAC address into Receive Address Register. */ 570typedef int (*eth_mac_addr_set_t)(struct rte_eth_dev *dev, 571 struct rte_ether_addr *mac_addr); 572 573/** @internal Set a Unicast Hash bitmap. */ 574typedef int (*eth_uc_hash_table_set_t)(struct rte_eth_dev *dev, 575 struct rte_ether_addr *mac_addr, 576 uint8_t on); 577 578/** @internal Set all Unicast Hash bitmap. */ 579typedef int (*eth_uc_all_hash_table_set_t)(struct rte_eth_dev *dev, 580 uint8_t on); 581 582/** @internal Set queue Tx rate. */ 583typedef int (*eth_set_queue_rate_limit_t)(struct rte_eth_dev *dev, 584 uint16_t queue_idx, 585 uint16_t tx_rate); 586 587/** @internal Add tunneling UDP port. */ 588typedef int (*eth_udp_tunnel_port_add_t)(struct rte_eth_dev *dev, 589 struct rte_eth_udp_tunnel *tunnel_udp); 590 591/** @internal Delete tunneling UDP port. */ 592typedef int (*eth_udp_tunnel_port_del_t)(struct rte_eth_dev *dev, 593 struct rte_eth_udp_tunnel *tunnel_udp); 594 595/** @internal set the list of multicast addresses on an Ethernet device. */ 596typedef int (*eth_set_mc_addr_list_t)(struct rte_eth_dev *dev, 597 struct rte_ether_addr *mc_addr_set, 598 uint32_t nb_mc_addr); 599 600/** @internal Function used to enable IEEE1588/802.1AS timestamping. */ 601typedef int (*eth_timesync_enable_t)(struct rte_eth_dev *dev); 602 603/** @internal Function used to disable IEEE1588/802.1AS timestamping. */ 604typedef int (*eth_timesync_disable_t)(struct rte_eth_dev *dev); 605 606/** @internal Function used to read an Rx IEEE1588/802.1AS timestamp. */ 607typedef int (*eth_timesync_read_rx_timestamp_t)(struct rte_eth_dev *dev, 608 struct timespec *timestamp, 609 uint32_t flags); 610 611/** @internal Function used to read a Tx IEEE1588/802.1AS timestamp. */ 612typedef int (*eth_timesync_read_tx_timestamp_t)(struct rte_eth_dev *dev, 613 struct timespec *timestamp); 614 615/** @internal Function used to adjust the device clock. */ 616typedef int (*eth_timesync_adjust_time)(struct rte_eth_dev *dev, int64_t); 617 618/** @internal Function used to get time from the device clock. */ 619typedef int (*eth_timesync_read_time)(struct rte_eth_dev *dev, 620 struct timespec *timestamp); 621 622/** @internal Function used to get time from the device clock. */ 623typedef int (*eth_timesync_write_time)(struct rte_eth_dev *dev, 624 const struct timespec *timestamp); 625 626/** @internal Function used to get the current value of the device clock. */ 627typedef int (*eth_read_clock)(struct rte_eth_dev *dev, 628 uint64_t *timestamp); 629 630/** @internal Retrieve registers. */ 631typedef int (*eth_get_reg_t)(struct rte_eth_dev *dev, 632 struct rte_dev_reg_info *info); 633 634/** @internal Retrieve EEPROM size. */ 635typedef int (*eth_get_eeprom_length_t)(struct rte_eth_dev *dev); 636 637/** @internal Retrieve EEPROM data. */ 638typedef int (*eth_get_eeprom_t)(struct rte_eth_dev *dev, 639 struct rte_dev_eeprom_info *info); 640 641/** @internal Program EEPROM data. */ 642typedef int (*eth_set_eeprom_t)(struct rte_eth_dev *dev, 643 struct rte_dev_eeprom_info *info); 644 645/** @internal Retrieve type and size of plugin module EEPROM. */ 646typedef int (*eth_get_module_info_t)(struct rte_eth_dev *dev, 647 struct rte_eth_dev_module_info *modinfo); 648 649/** @internal Retrieve plugin module EEPROM data. */ 650typedef int (*eth_get_module_eeprom_t)(struct rte_eth_dev *dev, 651 struct rte_dev_eeprom_info *info); 652 653struct rte_flow_ops; 654/** 655 * @internal 656 * Get flow operations. 657 * 658 * If the flow API is not supported for the specified device, 659 * the driver can return NULL. 660 */ 661typedef int (*eth_flow_ops_get_t)(struct rte_eth_dev *dev, 662 const struct rte_flow_ops **ops); 663 664/** @internal Get Traffic Management (TM) operations on an Ethernet device. */ 665typedef int (*eth_tm_ops_get_t)(struct rte_eth_dev *dev, void *ops); 666 667/** @internal Get Traffic Metering and Policing (MTR) operations. */ 668typedef int (*eth_mtr_ops_get_t)(struct rte_eth_dev *dev, void *ops); 669 670/** @internal Get DCB information on an Ethernet device. */ 671typedef int (*eth_get_dcb_info)(struct rte_eth_dev *dev, 672 struct rte_eth_dcb_info *dcb_info); 673 674/** @internal Test if a port supports specific mempool ops. */ 675typedef int (*eth_pool_ops_supported_t)(struct rte_eth_dev *dev, 676 const char *pool); 677 678/** 679 * @internal 680 * Get the hairpin capabilities. 681 * 682 * @param dev 683 * ethdev handle of port. 684 * @param cap 685 * returns the hairpin capabilities from the device. 686 * 687 * @return 688 * Negative errno value on error, 0 on success. 689 * 690 * @retval 0 691 * Success, hairpin is supported. 692 * @retval -ENOTSUP 693 * Hairpin is not supported. 694 */ 695typedef int (*eth_hairpin_cap_get_t)(struct rte_eth_dev *dev, 696 struct rte_eth_hairpin_cap *cap); 697 698/** 699 * @internal 700 * Setup Rx hairpin queue. 701 * 702 * @param dev 703 * ethdev handle of port. 704 * @param rx_queue_id 705 * the selected Rx queue index. 706 * @param nb_rx_desc 707 * the requested number of descriptors for this queue. 0 - use PMD default. 708 * @param conf 709 * the Rx hairpin configuration structure. 710 * 711 * @return 712 * Negative errno value on error, 0 on success. 713 * 714 * @retval 0 715 * Success, hairpin is supported. 716 * @retval -ENOTSUP 717 * Hairpin is not supported. 718 * @retval -EINVAL 719 * One of the parameters is invalid. 720 * @retval -ENOMEM 721 * Unable to allocate resources. 722 */ 723typedef int (*eth_rx_hairpin_queue_setup_t) 724 (struct rte_eth_dev *dev, uint16_t rx_queue_id, 725 uint16_t nb_rx_desc, 726 const struct rte_eth_hairpin_conf *conf); 727 728/** 729 * @internal 730 * Setup Tx hairpin queue. 731 * 732 * @param dev 733 * ethdev handle of port. 734 * @param tx_queue_id 735 * the selected Tx queue index. 736 * @param nb_tx_desc 737 * the requested number of descriptors for this queue. 0 - use PMD default. 738 * @param conf 739 * the Tx hairpin configuration structure. 740 * 741 * @return 742 * Negative errno value on error, 0 on success. 743 * 744 * @retval 0 745 * Success, hairpin is supported. 746 * @retval -ENOTSUP 747 * Hairpin is not supported. 748 * @retval -EINVAL 749 * One of the parameters is invalid. 750 * @retval -ENOMEM 751 * Unable to allocate resources. 752 */ 753typedef int (*eth_tx_hairpin_queue_setup_t) 754 (struct rte_eth_dev *dev, uint16_t tx_queue_id, 755 uint16_t nb_tx_desc, 756 const struct rte_eth_hairpin_conf *hairpin_conf); 757 758/** 759 * @internal 760 * Get Forward Error Correction(FEC) capability. 761 * 762 * @param dev 763 * ethdev handle of port. 764 * @param speed_fec_capa 765 * speed_fec_capa is out only with per-speed capabilities. 766 * @param num 767 * a number of elements in an speed_fec_capa array. 768 * 769 * @return 770 * Negative errno value on error, positive value on success. 771 * 772 * @retval positive value 773 * A non-negative value lower or equal to num: success. The return value 774 * is the number of entries filled in the fec capa array. 775 * A non-negative value higher than num: error, the given fec capa array 776 * is too small. The return value corresponds to the num that should 777 * be given to succeed. The entries in the fec capa array are not valid 778 * and shall not be used by the caller. 779 * @retval -ENOTSUP 780 * Operation is not supported. 781 * @retval -EIO 782 * Device is removed. 783 * @retval -EINVAL 784 * *num* or *speed_fec_capa* invalid. 785 */ 786typedef int (*eth_fec_get_capability_t)(struct rte_eth_dev *dev, 787 struct rte_eth_fec_capa *speed_fec_capa, unsigned int num); 788 789/** 790 * @internal 791 * Get Forward Error Correction(FEC) mode. 792 * 793 * @param dev 794 * ethdev handle of port. 795 * @param fec_capa 796 * a bitmask of enabled FEC modes. If AUTO bit is set, other 797 * bits specify FEC modes which may be negotiated. If AUTO 798 * bit is clear, specify FEC modes to be used (only one valid 799 * mode per speed may be set). 800 * 801 * @return 802 * Negative errno value on error, 0 on success. 803 * 804 * @retval 0 805 * Success, get FEC success. 806 * @retval -ENOTSUP 807 * Operation is not supported. 808 * @retval -EIO 809 * Device is removed. 810 */ 811typedef int (*eth_fec_get_t)(struct rte_eth_dev *dev, 812 uint32_t *fec_capa); 813 814/** 815 * @internal 816 * Set Forward Error Correction(FEC) mode. 817 * 818 * @param dev 819 * ethdev handle of port. 820 * @param fec_capa 821 * bitmask of allowed FEC modes. It must be only one 822 * if AUTO is disabled. If AUTO is enabled, other 823 * bits specify FEC modes which may be negotiated. 824 * 825 * @return 826 * Negative errno value on error, 0 on success. 827 * 828 * @retval 0 829 * Success, set FEC success. 830 * @retval -ENOTSUP 831 * Operation is not supported. 832 * @retval -EINVAL 833 * Unsupported FEC mode requested. 834 * @retval -EIO 835 * Device is removed. 836 */ 837typedef int (*eth_fec_set_t)(struct rte_eth_dev *dev, uint32_t fec_capa); 838 839/** 840 * @internal 841 * Get all hairpin Tx/Rx peer ports of the current device, if any. 842 * 843 * @param dev 844 * ethdev handle of port. 845 * @param peer_ports 846 * array to save the ports list. 847 * @param len 848 * array length. 849 * @param direction 850 * value to decide the current to peer direction 851 * positive - used as Tx to get all peer Rx ports. 852 * zero - used as Rx to get all peer Tx ports. 853 * 854 * @return 855 * Negative errno value on error, 0 or positive on success. 856 * 857 * @retval 0 858 * Success, no peer ports. 859 * @retval >0 860 * Actual number of the peer ports. 861 * @retval -ENOTSUP 862 * Get peer ports API is not supported. 863 * @retval -EINVAL 864 * One of the parameters is invalid. 865 */ 866typedef int (*hairpin_get_peer_ports_t)(struct rte_eth_dev *dev, 867 uint16_t *peer_ports, size_t len, 868 uint32_t direction); 869 870/** 871 * @internal 872 * Bind all hairpin Tx queues of one port to the Rx queues of the peer port. 873 * 874 * @param dev 875 * ethdev handle of port. 876 * @param rx_port 877 * the peer Rx port. 878 * 879 * @return 880 * Negative errno value on error, 0 on success. 881 * 882 * @retval 0 883 * Success, bind successfully. 884 * @retval -ENOTSUP 885 * Bind API is not supported. 886 * @retval -EINVAL 887 * One of the parameters is invalid. 888 * @retval -EBUSY 889 * Device is not started. 890 */ 891typedef int (*eth_hairpin_bind_t)(struct rte_eth_dev *dev, 892 uint16_t rx_port); 893 894/** 895 * @internal 896 * Unbind all hairpin Tx queues of one port from the Rx queues of the peer port. 897 * 898 * @param dev 899 * ethdev handle of port. 900 * @param rx_port 901 * the peer Rx port. 902 * 903 * @return 904 * Negative errno value on error, 0 on success. 905 * 906 * @retval 0 907 * Success, unbind successfully. 908 * @retval -ENOTSUP 909 * Bind API is not supported. 910 * @retval -EINVAL 911 * One of the parameters is invalid. 912 * @retval -EBUSY 913 * Device is already stopped. 914 */ 915typedef int (*eth_hairpin_unbind_t)(struct rte_eth_dev *dev, 916 uint16_t rx_port); 917 918/** @internal Update and fetch peer queue information. */ 919typedef int (*eth_hairpin_queue_peer_update_t) 920 (struct rte_eth_dev *dev, uint16_t peer_queue, 921 struct rte_hairpin_peer_info *current_info, 922 struct rte_hairpin_peer_info *peer_info, uint32_t direction); 923 924/** @internal Bind peer queue to the current queue with fetched information. */ 925typedef int (*eth_hairpin_queue_peer_bind_t) 926 (struct rte_eth_dev *dev, uint16_t cur_queue, 927 struct rte_hairpin_peer_info *peer_info, uint32_t direction); 928 929/** @internal Unbind peer queue from the current queue. */ 930typedef int (*eth_hairpin_queue_peer_unbind_t) 931 (struct rte_eth_dev *dev, uint16_t cur_queue, uint32_t direction); 932 933/** 934 * @internal 935 * Get address of memory location whose contents will change whenever there is 936 * new data to be received on an Rx queue. 937 * 938 * @param rxq 939 * Ethdev queue pointer. 940 * @param pmc 941 * The pointer to power-optimized monitoring condition structure. 942 * @return 943 * Negative errno value on error, 0 on success. 944 * 945 * @retval 0 946 * Success 947 * @retval -EINVAL 948 * Invalid parameters 949 */ 950typedef int (*eth_get_monitor_addr_t)(void *rxq, 951 struct rte_power_monitor_cond *pmc); 952 953/** 954 * @internal 955 * Get representor info to be able to calculate the unique representor ID. 956 * 957 * Caller should pass NULL as pointer of info to get number of entries, 958 * allocate info buffer according to returned entry number, then call 959 * again with buffer to get real info. 960 * 961 * To calculate the representor ID, caller should iterate each entry, 962 * match controller index, pf index, vf or sf start index and range, 963 * then calculate representor ID from offset to vf/sf start index. 964 * @see rte_eth_representor_id_get. 965 * 966 * @param dev 967 * Ethdev handle of port. 968 * @param [out] info 969 * Pointer to memory to save device representor info. 970 * @return 971 * Negative errno value on error, number of info entries otherwise. 972 */ 973 974typedef int (*eth_representor_info_get_t)(struct rte_eth_dev *dev, 975 struct rte_eth_representor_info *info); 976 977/** 978 * @internal 979 * Negotiate the NIC's ability to deliver specific kinds of metadata to the PMD. 980 * 981 * @param dev 982 * Port (ethdev) handle 983 * 984 * @param[inout] features 985 * Feature selection buffer 986 * 987 * @return 988 * Negative errno value on error, zero otherwise 989 */ 990typedef int (*eth_rx_metadata_negotiate_t)(struct rte_eth_dev *dev, 991 uint64_t *features); 992 993/** 994 * @internal A structure containing the functions exported by an Ethernet driver. 995 */ 996struct eth_dev_ops { 997 eth_dev_configure_t dev_configure; /**< Configure device */ 998 eth_dev_start_t dev_start; /**< Start device */ 999 eth_dev_stop_t dev_stop; /**< Stop device */ 1000 eth_dev_set_link_up_t dev_set_link_up; /**< Device link up */
1001 eth_dev_set_link_down_t dev_set_link_down; /**< Device link down */ 1002 eth_dev_close_t dev_close; /**< Close device */ 1003 eth_dev_reset_t dev_reset; /**< Reset device */ 1004 eth_link_update_t link_update; /**< Get device link state */ 1005 /** Check if the device was physically removed */ 1006 eth_is_removed_t is_removed; 1007 1008 eth_promiscuous_enable_t promiscuous_enable; /**< Promiscuous ON */ 1009 eth_promiscuous_disable_t promiscuous_disable;/**< Promiscuous OFF */ 1010 eth_allmulticast_enable_t allmulticast_enable;/**< Rx multicast ON */ 1011 eth_allmulticast_disable_t allmulticast_disable;/**< Rx multicast OFF */ 1012 eth_mac_addr_remove_t mac_addr_remove; /**< Remove MAC address */ 1013 eth_mac_addr_add_t mac_addr_add; /**< Add a MAC address */ 1014 eth_mac_addr_set_t mac_addr_set; /**< Set a MAC address */ 1015 /** Set list of multicast addresses */ 1016 eth_set_mc_addr_list_t set_mc_addr_list; 1017 mtu_set_t mtu_set; /**< Set MTU */ 1018 1019 /** Get generic device statistics */ 1020 eth_stats_get_t stats_get; 1021 /** Reset generic device statistics */ 1022 eth_stats_reset_t stats_reset; 1023 /** Get extended device statistics */ 1024 eth_xstats_get_t xstats_get; 1025 /** Reset extended device statistics */ 1026 eth_xstats_reset_t xstats_reset; 1027 /** Get names of extended statistics */ 1028 eth_xstats_get_names_t xstats_get_names; 1029 /** Configure per queue stat counter mapping */ 1030 eth_queue_stats_mapping_set_t queue_stats_mapping_set; 1031 1032 eth_dev_infos_get_t dev_infos_get; /**< Get device info */ 1033 /** Retrieve Rx queue information */ 1034 eth_rxq_info_get_t rxq_info_get; 1035 /** Retrieve Tx queue information */ 1036 eth_txq_info_get_t txq_info_get; 1037 eth_burst_mode_get_t rx_burst_mode_get; /**< Get Rx burst mode */ 1038 eth_burst_mode_get_t tx_burst_mode_get; /**< Get Tx burst mode */ 1039 eth_fw_version_get_t fw_version_get; /**< Get firmware version */ 1040 1041 /** Get packet types supported and identified by device */ 1042 eth_dev_supported_ptypes_get_t dev_supported_ptypes_get; 1043 /** 1044 * Inform Ethernet device about reduced range of packet types to 1045 * handle 1046 */ 1047 eth_dev_ptypes_set_t dev_ptypes_set; 1048 1049 /** Filter VLAN Setup */ 1050 vlan_filter_set_t vlan_filter_set; 1051 /** Outer/Inner VLAN TPID Setup */ 1052 vlan_tpid_set_t vlan_tpid_set; 1053 /** VLAN Stripping on queue */ 1054 vlan_strip_queue_set_t vlan_strip_queue_set; 1055 /** Set VLAN Offload */ 1056 vlan_offload_set_t vlan_offload_set; 1057 /** Set port based Tx VLAN insertion */ 1058 vlan_pvid_set_t vlan_pvid_set; 1059 1060 eth_queue_start_t rx_queue_start;/**< Start Rx for a queue */ 1061 eth_queue_stop_t rx_queue_stop; /**< Stop Rx for a queue */ 1062 eth_queue_start_t tx_queue_start;/**< Start Tx for a queue */ 1063 eth_queue_stop_t tx_queue_stop; /**< Stop Tx for a queue */ 1064 eth_rx_queue_setup_t rx_queue_setup;/**< Set up device Rx queue */ 1065 eth_queue_release_t rx_queue_release; /**< Release Rx queue */ 1066 1067 /** Enable Rx queue interrupt */ 1068 eth_rx_enable_intr_t rx_queue_intr_enable; 1069 /** Disable Rx queue interrupt */ 1070 eth_rx_disable_intr_t rx_queue_intr_disable; 1071 1072 eth_tx_queue_setup_t tx_queue_setup;/**< Set up device Tx queue */ 1073 eth_queue_release_t tx_queue_release; /**< Release Tx queue */ 1074 eth_tx_done_cleanup_t tx_done_cleanup;/**< Free Tx ring mbufs */ 1075 1076 eth_dev_led_on_t dev_led_on; /**< Turn on LED */ 1077 eth_dev_led_off_t dev_led_off; /**< Turn off LED */ 1078 1079 flow_ctrl_get_t flow_ctrl_get; /**< Get flow control */ 1080 flow_ctrl_set_t flow_ctrl_set; /**< Setup flow control */ 1081 /** Setup priority flow control */ 1082 priority_flow_ctrl_set_t priority_flow_ctrl_set; 1083 1084 /** Set Unicast Table Array */ 1085 eth_uc_hash_table_set_t uc_hash_table_set; 1086 /** Set Unicast hash bitmap */ 1087 eth_uc_all_hash_table_set_t uc_all_hash_table_set; 1088 1089 /** Add UDP tunnel port */ 1090 eth_udp_tunnel_port_add_t udp_tunnel_port_add; 1091 /** Delete UDP tunnel port */ 1092 eth_udp_tunnel_port_del_t udp_tunnel_port_del; 1093 1094 /** Set queue rate limit */ 1095 eth_set_queue_rate_limit_t set_queue_rate_limit; 1096 1097 /** Configure RSS hash protocols and hashing key */ 1098 rss_hash_update_t rss_hash_update; 1099 /** Get current RSS hash configuration */ 1100 rss_hash_conf_get_t rss_hash_conf_get; 1101 /** Update redirection table */ 1102 reta_update_t reta_update; 1103 /** Query redirection table */ 1104 reta_query_t reta_query; 1105 1106 eth_get_reg_t get_reg; /**< Get registers */ 1107 eth_get_eeprom_length_t get_eeprom_length; /**< Get EEPROM length */ 1108 eth_get_eeprom_t get_eeprom; /**< Get EEPROM data */ 1109 eth_set_eeprom_t set_eeprom; /**< Set EEPROM */ 1110 1111 /** Get plugin module EEPROM attribute */ 1112 eth_get_module_info_t get_module_info; 1113 /** Get plugin module EEPROM data */ 1114 eth_get_module_eeprom_t get_module_eeprom; 1115 1116 eth_flow_ops_get_t flow_ops_get; /**< Get flow operations */ 1117 1118 eth_get_dcb_info get_dcb_info; /**< Get DCB information */ 1119 1120 /** Turn IEEE1588/802.1AS timestamping on */ 1121 eth_timesync_enable_t timesync_enable; 1122 /** Turn IEEE1588/802.1AS timestamping off */ 1123 eth_timesync_disable_t timesync_disable; 1124 /** Read the IEEE1588/802.1AS Rx timestamp */ 1125 eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp; 1126 /** Read the IEEE1588/802.1AS Tx timestamp */ 1127 eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp; 1128 /** Adjust the device clock */ 1129 eth_timesync_adjust_time timesync_adjust_time; 1130 /** Get the device clock time */ 1131 eth_timesync_read_time timesync_read_time; 1132 /** Set the device clock time */ 1133 eth_timesync_write_time timesync_write_time; 1134 1135 eth_read_clock read_clock; 1136 1137 /** Get extended device statistic values by ID */ 1138 eth_xstats_get_by_id_t xstats_get_by_id; 1139 /** Get name of extended device statistics by ID */ 1140 eth_xstats_get_names_by_id_t xstats_get_names_by_id; 1141 1142 /** Get Traffic Management (TM) operations */ 1143 eth_tm_ops_get_t tm_ops_get; 1144 1145 /** Get Traffic Metering and Policing (MTR) operations */ 1146 eth_mtr_ops_get_t mtr_ops_get; 1147 1148 /** Test if a port supports specific mempool ops */ 1149 eth_pool_ops_supported_t pool_ops_supported; 1150 1151 /** Returns the hairpin capabilities */ 1152 eth_hairpin_cap_get_t hairpin_cap_get; 1153 /** Set up device Rx hairpin queue */ 1154 eth_rx_hairpin_queue_setup_t rx_hairpin_queue_setup; 1155 /** Set up device Tx hairpin queue */ 1156 eth_tx_hairpin_queue_setup_t tx_hairpin_queue_setup; 1157 1158 /** Get Forward Error Correction(FEC) capability */ 1159 eth_fec_get_capability_t fec_get_capability; 1160 /** Get Forward Error Correction(FEC) mode */ 1161 eth_fec_get_t fec_get; 1162 /** Set Forward Error Correction(FEC) mode */ 1163 eth_fec_set_t fec_set; 1164 1165 /** Get hairpin peer ports list */ 1166 hairpin_get_peer_ports_t hairpin_get_peer_ports; 1167 /** Bind all hairpin Tx queues of device to the peer port Rx queues */ 1168 eth_hairpin_bind_t hairpin_bind; 1169 /** Unbind all hairpin Tx queues from the peer port Rx queues */ 1170 eth_hairpin_unbind_t hairpin_unbind; 1171 /** Pass the current queue info and get the peer queue info */ 1172 eth_hairpin_queue_peer_update_t hairpin_queue_peer_update; 1173 /** Set up the connection between the pair of hairpin queues */ 1174 eth_hairpin_queue_peer_bind_t hairpin_queue_peer_bind; 1175 /** Disconnect the hairpin queues of a pair from each other */ 1176 eth_hairpin_queue_peer_unbind_t hairpin_queue_peer_unbind; 1177 1178 /** Get power monitoring condition for Rx queue */ 1179 eth_get_monitor_addr_t get_monitor_addr; 1180 1181 /** Get representor info */ 1182 eth_representor_info_get_t representor_info_get; 1183 1184 /** 1185 * Negotiate the NIC's ability to deliver specific 1186 * kinds of metadata to the PMD 1187 */ 1188 eth_rx_metadata_negotiate_t rx_metadata_negotiate; 1189}; 1190 1191/** 1192 * @internal 1193 * Check if the selected Rx queue is hairpin queue. 1194 * 1195 * @param dev 1196 * Pointer to the selected device. 1197 * @param queue_id 1198 * The selected queue. 1199 * 1200 * @return 1201 * - (1) if the queue is hairpin queue, 0 otherwise. 1202 */ 1203__rte_internal 1204int rte_eth_dev_is_rx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id); 1205 1206/** 1207 * @internal 1208 * Check if the selected Tx queue is hairpin queue. 1209 * 1210 * @param dev 1211 * Pointer to the selected device. 1212 * @param queue_id 1213 * The selected queue. 1214 * 1215 * @return 1216 * - (1) if the queue is hairpin queue, 0 otherwise. 1217 */ 1218__rte_internal 1219int rte_eth_dev_is_tx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id); 1220 1221/** 1222 * @internal 1223 * Returns a ethdev slot specified by the unique identifier name. 1224 * 1225 * @param name 1226 * The pointer to the Unique identifier name for each Ethernet device 1227 * @return 1228 * - The pointer to the ethdev slot, on success. NULL on error 1229 */ 1230__rte_internal 1231struct rte_eth_dev *rte_eth_dev_allocated(const char *name); 1232 1233/** 1234 * @internal 1235 * Allocates a new ethdev slot for an Ethernet device and returns the pointer 1236 * to that slot for the driver to use. 1237 * 1238 * @param name Unique identifier name for each Ethernet device 1239 * @return 1240 * - Slot in the rte_dev_devices array for a new device; 1241 */ 1242__rte_internal 1243struct rte_eth_dev *rte_eth_dev_allocate(const char *name); 1244 1245/** 1246 * @internal 1247 * Attach to the ethdev already initialized by the primary 1248 * process. 1249 * 1250 * @param name Ethernet device's name. 1251 * @return 1252 * - Success: Slot in the rte_dev_devices array for attached 1253 * device. 1254 * - Error: Null pointer. 1255 */ 1256__rte_internal 1257struct rte_eth_dev *rte_eth_dev_attach_secondary(const char *name); 1258 1259/** 1260 * @internal 1261 * Notify RTE_ETH_EVENT_DESTROY and release the specified ethdev port. 1262 * 1263 * The following PMD-managed data fields will be freed: 1264 * - dev_private 1265 * - mac_addrs 1266 * - hash_mac_addrs 1267 * If one of these fields should not be freed, 1268 * it must be reset to NULL by the PMD, typically in dev_close method. 1269 * 1270 * @param eth_dev 1271 * Device to be detached. 1272 * @return 1273 * - 0 on success, negative on error 1274 */ 1275__rte_internal 1276int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev); 1277 1278/** 1279 * @internal 1280 * Release device queues and clear its configuration to force the user 1281 * application to reconfigure it. It is for internal use only. 1282 * 1283 * @param dev 1284 * Pointer to struct rte_eth_dev. 1285 * 1286 * @return 1287 * void 1288 */ 1289__rte_internal 1290void rte_eth_dev_internal_reset(struct rte_eth_dev *dev); 1291 1292/** 1293 * @internal Executes all the user application registered callbacks for 1294 * the specific device. It is for DPDK internal user only. User 1295 * application should not call it directly. 1296 * 1297 * @param dev 1298 * Pointer to struct rte_eth_dev. 1299 * @param event 1300 * Eth device interrupt event type. 1301 * @param ret_param 1302 * To pass data back to user application. 1303 * This allows the user application to decide if a particular function 1304 * is permitted or not. 1305 * 1306 * @return 1307 * int 1308 */ 1309__rte_internal 1310int rte_eth_dev_callback_process(struct rte_eth_dev *dev, 1311 enum rte_eth_event_type event, void *ret_param); 1312 1313/** 1314 * @internal 1315 * This is the last step of device probing. 1316 * It must be called after a port is allocated and initialized successfully. 1317 * 1318 * The notification RTE_ETH_EVENT_NEW is sent to other entities 1319 * (libraries and applications). 1320 * The state is set as RTE_ETH_DEV_ATTACHED. 1321 * 1322 * @param dev 1323 * New ethdev port. 1324 */ 1325__rte_internal 1326void rte_eth_dev_probing_finish(struct rte_eth_dev *dev); 1327 1328/** 1329 * Create memzone for HW rings. 1330 * malloc can't be used as the physical address is needed. 1331 * If the memzone is already created, then this function returns a ptr 1332 * to the old one. 1333 * 1334 * @param eth_dev 1335 * The *eth_dev* pointer is the address of the *rte_eth_dev* structure 1336 * @param name 1337 * The name of the memory zone 1338 * @param queue_id 1339 * The index of the queue to add to name 1340 * @param size 1341 * The sizeof of the memory area 1342 * @param align 1343 * Alignment for resulting memzone. Must be a power of 2. 1344 * @param socket_id 1345 * The *socket_id* argument is the socket identifier in case of NUMA. 1346 */ 1347__rte_internal 1348const struct rte_memzone * 1349rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name, 1350 uint16_t queue_id, size_t size, 1351 unsigned align, int socket_id); 1352 1353/** 1354 * Free previously allocated memzone for HW rings. 1355 * 1356 * @param eth_dev 1357 * The *eth_dev* pointer is the address of the *rte_eth_dev* structure 1358 * @param name 1359 * The name of the memory zone 1360 * @param queue_id 1361 * The index of the queue to add to name 1362 * @return 1363 * Negative errno value on error, 0 on success. 1364 */ 1365__rte_internal 1366int 1367rte_eth_dma_zone_free(const struct rte_eth_dev *eth_dev, const char *name, 1368 uint16_t queue_id); 1369 1370/** 1371 * @internal 1372 * Atomically set the link status for the specific device. 1373 * It is for use by DPDK device driver use only. 1374 * User applications should not call it 1375 * 1376 * @param dev 1377 * Pointer to struct rte_eth_dev. 1378 * @param link 1379 * New link status value. 1380 * @return 1381 * Same convention as eth_link_update operation. 1382 * 0 if link up status has changed 1383 * -1 if link up status was unchanged 1384 */ 1385static inline int 1386rte_eth_linkstatus_set(struct rte_eth_dev *dev, 1387 const struct rte_eth_link *new_link) 1388{ 1389 uint64_t *dev_link = (uint64_t *)&(dev->data->dev_link); 1390 union { 1391 uint64_t val64; 1392 struct rte_eth_link link; 1393 } orig; 1394 1395 RTE_BUILD_BUG_ON(sizeof(*new_link) != sizeof(uint64_t)); 1396 1397 orig.val64 = __atomic_exchange_n(dev_link, *(const uint64_t *)new_link, 1398 __ATOMIC_SEQ_CST); 1399 1400 return (orig.link.link_status == new_link->link_status) ? -1 : 0; 1401} 1402 1403/** 1404 * @internal 1405 * Atomically get the link speed and status. 1406 * 1407 * @param dev 1408 * Pointer to struct rte_eth_dev. 1409 * @param link 1410 * link status value. 1411 */ 1412static inline void 1413rte_eth_linkstatus_get(const struct rte_eth_dev *dev, 1414 struct rte_eth_link *link) 1415{ 1416 uint64_t *src = (uint64_t *)&(dev->data->dev_link); 1417 uint64_t *dst = (uint64_t *)link; 1418 1419 RTE_BUILD_BUG_ON(sizeof(*link) != sizeof(uint64_t)); 1420 1421 *dst = __atomic_load_n(src, __ATOMIC_SEQ_CST); 1422} 1423 1424/** 1425 * Allocate an unique switch domain identifier. 1426 * 1427 * A pool of switch domain identifiers which can be allocated on request. This 1428 * will enabled devices which support the concept of switch domains to request 1429 * a switch domain ID which is guaranteed to be unique from other devices 1430 * running in the same process. 1431 * 1432 * @param domain_id 1433 * switch domain identifier parameter to pass back to application 1434 * 1435 * @return 1436 * Negative errno value on error, 0 on success. 1437 */ 1438__rte_internal 1439int 1440rte_eth_switch_domain_alloc(uint16_t *domain_id); 1441 1442/** 1443 * Free switch domain. 1444 * 1445 * Return a switch domain identifier to the pool of free identifiers after it is 1446 * no longer in use by device. 1447 * 1448 * @param domain_id 1449 * switch domain identifier to free 1450 * 1451 * @return 1452 * Negative errno value on error, 0 on success. 1453 */ 1454__rte_internal 1455int 1456rte_eth_switch_domain_free(uint16_t domain_id); 1457 1458/** 1459 * Generic Ethernet device arguments 1460 * 1461 * One type of representor each structure. 1462 */ 1463struct rte_eth_devargs { 1464 uint16_t mh_controllers[RTE_MAX_MULTI_HOST_CTRLS]; 1465 /** controller/s number in case of multi-host */ 1466 uint16_t nb_mh_controllers; 1467 /** number of controllers in multi-host controllers field */ 1468 uint16_t ports[RTE_MAX_ETHPORTS]; 1469 /** port/s number to enable on a multi-port single function */ 1470 uint16_t nb_ports; 1471 /** number of ports in ports field */ 1472 uint16_t representor_ports[RTE_MAX_ETHPORTS]; 1473 /** representor port/s identifier to enable on device */ 1474 uint16_t nb_representor_ports; 1475 /** number of ports in representor port field */ 1476 enum rte_eth_representor_type type; /* type of representor */ 1477}; 1478 1479/** 1480 * PMD helper function to get representor ID from location detail. 1481 * 1482 * Get representor ID from controller, pf and (sf or vf). 1483 * The mapping is retrieved from rte_eth_representor_info_get(). 1484 * 1485 * For backward compatibility, if no representor info, direct 1486 * map legacy VF (no controller and pf). 1487 * 1488 * @param port_id 1489 * Port ID of the backing device. 1490 * @param type 1491 * Representor type. 1492 * @param controller 1493 * Controller ID, -1 if unspecified. 1494 * @param pf 1495 * PF port ID, -1 if unspecified. 1496 * @param representor_port 1497 * VF or SF representor port number, -1 if unspecified. 1498 * @param repr_id 1499 * Pointer to output representor ID. 1500 * 1501 * @return 1502 * Negative errno value on error, 0 on success. 1503 */ 1504__rte_internal 1505int 1506rte_eth_representor_id_get(uint16_t port_id, 1507 enum rte_eth_representor_type type, 1508 int controller, int pf, int representor_port, 1509 uint16_t *repr_id); 1510 1511/** 1512 * PMD helper function to parse ethdev arguments 1513 * 1514 * @param devargs 1515 * device arguments 1516 * @param eth_devargs 1517 * parsed ethdev specific arguments. 1518 * 1519 * @return 1520 * Negative errno value on error, 0 on success. 1521 */ 1522__rte_internal 1523int 1524rte_eth_devargs_parse(const char *devargs, struct rte_eth_devargs *eth_devargs); 1525 1526 1527typedef int (*ethdev_init_t)(struct rte_eth_dev *ethdev, void *init_params); 1528typedef int (*ethdev_bus_specific_init)(struct rte_eth_dev *ethdev, 1529 void *bus_specific_init_params); 1530 1531/** 1532 * PMD helper function for the creation of a new ethdev ports. 1533 * 1534 * @param device 1535 * rte_device handle. 1536 * @param name 1537 * port name. 1538 * @param priv_data_size 1539 * size of private data required for port. 1540 * @param bus_specific_init 1541 * port bus specific initialisation callback function 1542 * @param bus_init_params 1543 * port bus specific initialisation parameters 1544 * @param ethdev_init 1545 * device specific port initialization callback function 1546 * @param init_params 1547 * port initialisation parameters 1548 * 1549 * @return 1550 * Negative errno value on error, 0 on success. 1551 */ 1552__rte_internal 1553int 1554rte_eth_dev_create(struct rte_device *device, const char *name, 1555 size_t priv_data_size, 1556 ethdev_bus_specific_init bus_specific_init, void *bus_init_params, 1557 ethdev_init_t ethdev_init, void *init_params); 1558 1559 1560typedef int (*ethdev_uninit_t)(struct rte_eth_dev *ethdev); 1561 1562/** 1563 * PMD helper function for cleaning up the resources of a ethdev port on it's 1564 * destruction. 1565 * 1566 * @param ethdev 1567 * ethdev handle of port. 1568 * @param ethdev_uninit 1569 * device specific port un-initialise callback function 1570 * 1571 * @return 1572 * Negative errno value on error, 0 on success. 1573 */ 1574__rte_internal 1575int 1576rte_eth_dev_destroy(struct rte_eth_dev *ethdev, ethdev_uninit_t ethdev_uninit); 1577 1578/** 1579 * @internal 1580 * Pass the current hairpin queue HW and/or SW information to the peer queue 1581 * and fetch back the information of the peer queue. 1582 * 1583 * @param peer_port 1584 * Peer port identifier of the Ethernet device. 1585 * @param peer_queue 1586 * Peer queue index of the port. 1587 * @param cur_info 1588 * Pointer to the current information structure. 1589 * @param peer_info 1590 * Pointer to the peer information, output. 1591 * @param direction 1592 * Direction to pass the information. 1593 * positive - pass Tx queue information and get peer Rx queue information 1594 * zero - pass Rx queue information and get peer Tx queue information 1595 * 1596 * @return 1597 * Negative errno value on error, 0 on success. 1598 */ 1599__rte_internal 1600int 1601rte_eth_hairpin_queue_peer_update(uint16_t peer_port, uint16_t peer_queue, 1602 struct rte_hairpin_peer_info *cur_info, 1603 struct rte_hairpin_peer_info *peer_info, 1604 uint32_t direction); 1605 1606/** 1607 * @internal 1608 * Configure current hairpin queue with the peer information fetched to create 1609 * the connection (bind) with peer queue in the specified direction. 1610 * This function might need to be called twice to fully create the connections. 1611 * 1612 * @param cur_port 1613 * Current port identifier of the Ethernet device. 1614 * @param cur_queue 1615 * Current queue index of the port. 1616 * @param peer_info 1617 * Pointer to the peer information, input. 1618 * @param direction 1619 * Direction to create the connection. 1620 * positive - bind current Tx queue to peer Rx queue 1621 * zero - bind current Rx queue to peer Tx queue 1622 * 1623 * @return 1624 * Negative errno value on error, 0 on success. 1625 */ 1626__rte_internal 1627int 1628rte_eth_hairpin_queue_peer_bind(uint16_t cur_port, uint16_t cur_queue, 1629 struct rte_hairpin_peer_info *peer_info, 1630 uint32_t direction); 1631 1632/** 1633 * @internal 1634 * Reset the current queue state and configuration to disconnect (unbind) it 1635 * from the peer queue. 1636 * This function might need to be called twice to disconnect each other. 1637 * 1638 * @param cur_port 1639 * Current port identifier of the Ethernet device. 1640 * @param cur_queue 1641 * Current queue index of the port. 1642 * @param direction 1643 * Direction to destroy the connection. 1644 * positive - unbind current Tx queue from peer Rx queue 1645 * zero - unbind current Rx queue from peer Tx queue 1646 * 1647 * @return 1648 * Negative errno value on error, 0 on success. 1649 */ 1650__rte_internal 1651int 1652rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t cur_queue, 1653 uint32_t direction); 1654 1655 1656/* 1657 * Legacy ethdev API used internally by drivers. 1658 */ 1659 1660enum rte_filter_type { 1661 RTE_ETH_FILTER_NONE = 0, 1662 RTE_ETH_FILTER_ETHERTYPE, 1663 RTE_ETH_FILTER_FLEXIBLE, 1664 RTE_ETH_FILTER_SYN, 1665 RTE_ETH_FILTER_NTUPLE, 1666 RTE_ETH_FILTER_TUNNEL, 1667 RTE_ETH_FILTER_FDIR, 1668 RTE_ETH_FILTER_HASH, 1669 RTE_ETH_FILTER_L2_TUNNEL, 1670}; 1671 1672/** 1673 * Define all structures for Ethertype Filter type. 1674 */ 1675 1676#define RTE_ETHTYPE_FLAGS_MAC 0x0001 /**< If set, compare mac */ 1677#define RTE_ETHTYPE_FLAGS_DROP 0x0002 /**< If set, drop packet when match */ 1678 1679/** 1680 * A structure used to define the ethertype filter entry 1681 * to support RTE_ETH_FILTER_ETHERTYPE data representation. 1682 */ 1683struct rte_eth_ethertype_filter { 1684 struct rte_ether_addr mac_addr; /**< Mac address to match */ 1685 uint16_t ether_type; /**< Ether type to match */ 1686 uint16_t flags; /**< Flags from RTE_ETHTYPE_FLAGS_* */ 1687 uint16_t queue; /**< Queue assigned to when match */ 1688}; 1689 1690/** 1691 * A structure used to define the TCP syn filter entry 1692 * to support RTE_ETH_FILTER_SYN data representation. 1693 */ 1694struct rte_eth_syn_filter { 1695 /** 1 - higher priority than other filters, 0 - lower priority */ 1696 uint8_t hig_pri; 1697 uint16_t queue; /**< Queue assigned to when match */ 1698}; 1699 1700/** 1701 * filter type of tunneling packet 1702 */ 1703#define RTE_ETH_TUNNEL_FILTER_OMAC 0x01 /**< filter by outer MAC addr */ 1704#define RTE_ETH_TUNNEL_FILTER_OIP 0x02 /**< filter by outer IP Addr */ 1705#define RTE_ETH_TUNNEL_FILTER_TENID 0x04 /**< filter by tenant ID */ 1706#define RTE_ETH_TUNNEL_FILTER_IMAC 0x08 /**< filter by inner MAC addr */ 1707#define RTE_ETH_TUNNEL_FILTER_IVLAN 0x10 /**< filter by inner VLAN ID */ 1708#define RTE_ETH_TUNNEL_FILTER_IIP 0x20 /**< filter by inner IP addr */ 1709 1710#define RTE_ETH_TUNNEL_FILTER_IMAC_IVLAN (RTE_ETH_TUNNEL_FILTER_IMAC | \ 1711 RTE_ETH_TUNNEL_FILTER_IVLAN) 1712#define RTE_ETH_TUNNEL_FILTER_IMAC_IVLAN_TENID (RTE_ETH_TUNNEL_FILTER_IMAC | \ 1713 RTE_ETH_TUNNEL_FILTER_IVLAN | \ 1714 RTE_ETH_TUNNEL_FILTER_TENID) 1715#define RTE_ETH_TUNNEL_FILTER_IMAC_TENID (RTE_ETH_TUNNEL_FILTER_IMAC | \ 1716 RTE_ETH_TUNNEL_FILTER_TENID) 1717#define RTE_ETH_TUNNEL_FILTER_OMAC_TENID_IMAC (RTE_ETH_TUNNEL_FILTER_OMAC | \ 1718 RTE_ETH_TUNNEL_FILTER_TENID | \ 1719 RTE_ETH_TUNNEL_FILTER_IMAC) 1720 1721/** 1722 * Select IPv4 or IPv6 for tunnel filters. 1723 */ 1724enum rte_tunnel_iptype { 1725 RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4 */ 1726 RTE_TUNNEL_IPTYPE_IPV6, /**< IPv6 */ 1727}; 1728 1729/** 1730 * Tunneling Packet filter configuration. 1731 */ 1732struct rte_eth_tunnel_filter_conf { 1733 struct rte_ether_addr outer_mac; /**< Outer MAC address to match */ 1734 struct rte_ether_addr inner_mac; /**< Inner MAC address to match */ 1735 uint16_t inner_vlan; /**< Inner VLAN to match */ 1736 enum rte_tunnel_iptype ip_type; /**< IP address type */ 1737 /** 1738 * Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP 1739 * is set in filter_type, or inner destination IP address to match 1740 * if ETH_TUNNEL_FILTER_IIP is set in filter_type. 1741 */ 1742 union { 1743 uint32_t ipv4_addr; /**< IPv4 address in big endian */ 1744 uint32_t ipv6_addr[4]; /**< IPv6 address in big endian */ 1745 } ip_addr; 1746 /** Flags from ETH_TUNNEL_FILTER_XX - see above */ 1747 uint16_t filter_type; 1748 enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type */ 1749 uint32_t tenant_id; /**< Tenant ID to match: VNI, GRE key... */ 1750 uint16_t queue_id; /**< Queue assigned to if match */ 1751}; 1752 1753#endif /* _RTE_ETHDEV_DRIVER_H_ */ 1754