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