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