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