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