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 A structure containing the functions exported by an Ethernet driver. 1176 */ 1177 struct eth_dev_ops { 1178 eth_dev_configure_t dev_configure; /**< Configure device */ 1179 eth_dev_start_t dev_start; /**< Start device */ 1180 eth_dev_stop_t dev_stop; /**< Stop device */ 1181 eth_dev_set_link_up_t dev_set_link_up; /**< Device link up */ 1182 eth_dev_set_link_down_t dev_set_link_down; /**< Device link down */ 1183 eth_dev_close_t dev_close; /**< Close device */ 1184 eth_dev_reset_t dev_reset; /**< Reset device */ 1185 eth_link_update_t link_update; /**< Get device link state */ 1186 /** Check if the device was physically removed */ 1187 eth_is_removed_t is_removed; 1188 1189 eth_promiscuous_enable_t promiscuous_enable; /**< Promiscuous ON */ 1190 eth_promiscuous_disable_t promiscuous_disable;/**< Promiscuous OFF */ 1191 eth_allmulticast_enable_t allmulticast_enable;/**< Rx multicast ON */ 1192 eth_allmulticast_disable_t allmulticast_disable;/**< Rx multicast OFF */ 1193 eth_mac_addr_remove_t mac_addr_remove; /**< Remove MAC address */ 1194 eth_mac_addr_add_t mac_addr_add; /**< Add a MAC address */ 1195 eth_mac_addr_set_t mac_addr_set; /**< Set a MAC address */ 1196 /** Set list of multicast addresses */ 1197 eth_set_mc_addr_list_t set_mc_addr_list; 1198 mtu_set_t mtu_set; /**< Set MTU */ 1199 1200 /** Get generic device statistics */ 1201 eth_stats_get_t stats_get; 1202 /** Reset generic device statistics */ 1203 eth_stats_reset_t stats_reset; 1204 /** Get extended device statistics */ 1205 eth_xstats_get_t xstats_get; 1206 /** Reset extended device statistics */ 1207 eth_xstats_reset_t xstats_reset; 1208 /** Get names of extended statistics */ 1209 eth_xstats_get_names_t xstats_get_names; 1210 /** Configure per queue stat counter mapping */ 1211 eth_queue_stats_mapping_set_t queue_stats_mapping_set; 1212 1213 eth_dev_infos_get_t dev_infos_get; /**< Get device info */ 1214 /** Retrieve Rx queue information */ 1215 eth_rxq_info_get_t rxq_info_get; 1216 /** Retrieve Tx queue information */ 1217 eth_txq_info_get_t txq_info_get; 1218 eth_burst_mode_get_t rx_burst_mode_get; /**< Get Rx burst mode */ 1219 eth_burst_mode_get_t tx_burst_mode_get; /**< Get Tx burst mode */ 1220 eth_fw_version_get_t fw_version_get; /**< Get firmware version */ 1221 1222 /** Get packet types supported and identified by device */ 1223 eth_dev_supported_ptypes_get_t dev_supported_ptypes_get; 1224 /** 1225 * Inform Ethernet device about reduced range of packet types to 1226 * handle 1227 */ 1228 eth_dev_ptypes_set_t dev_ptypes_set; 1229 1230 /** Filter VLAN Setup */ 1231 vlan_filter_set_t vlan_filter_set; 1232 /** Outer/Inner VLAN TPID Setup */ 1233 vlan_tpid_set_t vlan_tpid_set; 1234 /** VLAN Stripping on queue */ 1235 vlan_strip_queue_set_t vlan_strip_queue_set; 1236 /** Set VLAN Offload */ 1237 vlan_offload_set_t vlan_offload_set; 1238 /** Set port based Tx VLAN insertion */ 1239 vlan_pvid_set_t vlan_pvid_set; 1240 1241 eth_queue_start_t rx_queue_start;/**< Start Rx for a queue */ 1242 eth_queue_stop_t rx_queue_stop; /**< Stop Rx for a queue */ 1243 eth_queue_start_t tx_queue_start;/**< Start Tx for a queue */ 1244 eth_queue_stop_t tx_queue_stop; /**< Stop Tx for a queue */ 1245 eth_rx_queue_setup_t rx_queue_setup;/**< Set up device Rx queue */ 1246 eth_queue_release_t rx_queue_release; /**< Release Rx queue */ 1247 1248 /** Enable Rx queue interrupt */ 1249 eth_rx_enable_intr_t rx_queue_intr_enable; 1250 /** Disable Rx queue interrupt */ 1251 eth_rx_disable_intr_t rx_queue_intr_disable; 1252 1253 eth_tx_queue_setup_t tx_queue_setup;/**< Set up device Tx queue */ 1254 eth_queue_release_t tx_queue_release; /**< Release Tx queue */ 1255 eth_tx_done_cleanup_t tx_done_cleanup;/**< Free Tx ring mbufs */ 1256 1257 eth_dev_led_on_t dev_led_on; /**< Turn on LED */ 1258 eth_dev_led_off_t dev_led_off; /**< Turn off LED */ 1259 1260 flow_ctrl_get_t flow_ctrl_get; /**< Get flow control */ 1261 flow_ctrl_set_t flow_ctrl_set; /**< Setup flow control */ 1262 /** Setup priority flow control */ 1263 priority_flow_ctrl_set_t priority_flow_ctrl_set; 1264 /** Priority flow control queue info get */ 1265 priority_flow_ctrl_queue_info_get_t priority_flow_ctrl_queue_info_get; 1266 /** Priority flow control queue configure */ 1267 priority_flow_ctrl_queue_config_t priority_flow_ctrl_queue_config; 1268 1269 /** Set Unicast Table Array */ 1270 eth_uc_hash_table_set_t uc_hash_table_set; 1271 /** Set Unicast hash bitmap */ 1272 eth_uc_all_hash_table_set_t uc_all_hash_table_set; 1273 1274 /** Add UDP tunnel port */ 1275 eth_udp_tunnel_port_add_t udp_tunnel_port_add; 1276 /** Delete UDP tunnel port */ 1277 eth_udp_tunnel_port_del_t udp_tunnel_port_del; 1278 1279 /** Set queue rate limit */ 1280 eth_set_queue_rate_limit_t set_queue_rate_limit; 1281 1282 /** Configure RSS hash protocols and hashing key */ 1283 rss_hash_update_t rss_hash_update; 1284 /** Get current RSS hash configuration */ 1285 rss_hash_conf_get_t rss_hash_conf_get; 1286 /** Update redirection table */ 1287 reta_update_t reta_update; 1288 /** Query redirection table */ 1289 reta_query_t reta_query; 1290 1291 eth_get_reg_t get_reg; /**< Get registers */ 1292 eth_get_eeprom_length_t get_eeprom_length; /**< Get EEPROM length */ 1293 eth_get_eeprom_t get_eeprom; /**< Get EEPROM data */ 1294 eth_set_eeprom_t set_eeprom; /**< Set EEPROM */ 1295 1296 /** Get plugin module EEPROM attribute */ 1297 eth_get_module_info_t get_module_info; 1298 /** Get plugin module EEPROM data */ 1299 eth_get_module_eeprom_t get_module_eeprom; 1300 1301 eth_flow_ops_get_t flow_ops_get; /**< Get flow operations */ 1302 1303 eth_get_dcb_info get_dcb_info; /**< Get DCB information */ 1304 1305 /** Turn IEEE1588/802.1AS timestamping on */ 1306 eth_timesync_enable_t timesync_enable; 1307 /** Turn IEEE1588/802.1AS timestamping off */ 1308 eth_timesync_disable_t timesync_disable; 1309 /** Read the IEEE1588/802.1AS Rx timestamp */ 1310 eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp; 1311 /** Read the IEEE1588/802.1AS Tx timestamp */ 1312 eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp; 1313 /** Adjust the device clock */ 1314 eth_timesync_adjust_time timesync_adjust_time; 1315 /** Get the device clock time */ 1316 eth_timesync_read_time timesync_read_time; 1317 /** Set the device clock time */ 1318 eth_timesync_write_time timesync_write_time; 1319 1320 eth_read_clock read_clock; 1321 1322 /** Get extended device statistic values by ID */ 1323 eth_xstats_get_by_id_t xstats_get_by_id; 1324 /** Get name of extended device statistics by ID */ 1325 eth_xstats_get_names_by_id_t xstats_get_names_by_id; 1326 1327 /** Get Traffic Management (TM) operations */ 1328 eth_tm_ops_get_t tm_ops_get; 1329 1330 /** Get Traffic Metering and Policing (MTR) operations */ 1331 eth_mtr_ops_get_t mtr_ops_get; 1332 1333 /** Test if a port supports specific mempool ops */ 1334 eth_pool_ops_supported_t pool_ops_supported; 1335 1336 /** Returns the hairpin capabilities */ 1337 eth_hairpin_cap_get_t hairpin_cap_get; 1338 /** Set up device Rx hairpin queue */ 1339 eth_rx_hairpin_queue_setup_t rx_hairpin_queue_setup; 1340 /** Set up device Tx hairpin queue */ 1341 eth_tx_hairpin_queue_setup_t tx_hairpin_queue_setup; 1342 1343 /** Get Forward Error Correction(FEC) capability */ 1344 eth_fec_get_capability_t fec_get_capability; 1345 /** Get Forward Error Correction(FEC) mode */ 1346 eth_fec_get_t fec_get; 1347 /** Set Forward Error Correction(FEC) mode */ 1348 eth_fec_set_t fec_set; 1349 1350 /** Get hairpin peer ports list */ 1351 hairpin_get_peer_ports_t hairpin_get_peer_ports; 1352 /** Bind all hairpin Tx queues of device to the peer port Rx queues */ 1353 eth_hairpin_bind_t hairpin_bind; 1354 /** Unbind all hairpin Tx queues from the peer port Rx queues */ 1355 eth_hairpin_unbind_t hairpin_unbind; 1356 /** Pass the current queue info and get the peer queue info */ 1357 eth_hairpin_queue_peer_update_t hairpin_queue_peer_update; 1358 /** Set up the connection between the pair of hairpin queues */ 1359 eth_hairpin_queue_peer_bind_t hairpin_queue_peer_bind; 1360 /** Disconnect the hairpin queues of a pair from each other */ 1361 eth_hairpin_queue_peer_unbind_t hairpin_queue_peer_unbind; 1362 1363 /** Get power monitoring condition for Rx queue */ 1364 eth_get_monitor_addr_t get_monitor_addr; 1365 1366 /** Get representor info */ 1367 eth_representor_info_get_t representor_info_get; 1368 1369 /** 1370 * Negotiate the NIC's ability to deliver specific 1371 * kinds of metadata to the PMD 1372 */ 1373 eth_rx_metadata_negotiate_t rx_metadata_negotiate; 1374 1375 /** Get IP reassembly capability */ 1376 eth_ip_reassembly_capability_get_t ip_reassembly_capability_get; 1377 /** Get IP reassembly configuration */ 1378 eth_ip_reassembly_conf_get_t ip_reassembly_conf_get; 1379 /** Set IP reassembly configuration */ 1380 eth_ip_reassembly_conf_set_t ip_reassembly_conf_set; 1381 1382 /** Get supported header ptypes to split */ 1383 eth_buffer_split_supported_hdr_ptypes_get_t buffer_split_supported_hdr_ptypes_get; 1384 1385 /** Dump private info from device */ 1386 eth_dev_priv_dump_t eth_dev_priv_dump; 1387 1388 /** Set Rx queue available descriptors threshold */ 1389 eth_rx_queue_avail_thresh_set_t rx_queue_avail_thresh_set; 1390 /** Query Rx queue available descriptors threshold event */ 1391 eth_rx_queue_avail_thresh_query_t rx_queue_avail_thresh_query; 1392 1393 /** Dump Rx descriptor info */ 1394 eth_rx_descriptor_dump_t eth_rx_descriptor_dump; 1395 /** Dump Tx descriptor info */ 1396 eth_tx_descriptor_dump_t eth_tx_descriptor_dump; 1397 1398 /** Get congestion management information */ 1399 eth_cman_info_get_t cman_info_get; 1400 /** Initialize congestion management structure with default values */ 1401 eth_cman_config_init_t cman_config_init; 1402 /** Configure congestion management */ 1403 eth_cman_config_set_t cman_config_set; 1404 /** Retrieve congestion management configuration */ 1405 eth_cman_config_get_t cman_config_get; 1406 }; 1407 1408 /** 1409 * @internal 1410 * Check if the selected Rx queue is hairpin queue. 1411 * 1412 * @param dev 1413 * Pointer to the selected device. 1414 * @param queue_id 1415 * The selected queue. 1416 * 1417 * @return 1418 * - (1) if the queue is hairpin queue, 0 otherwise. 1419 */ 1420 __rte_internal 1421 int rte_eth_dev_is_rx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id); 1422 1423 /** 1424 * @internal 1425 * Check if the selected Tx queue is hairpin queue. 1426 * 1427 * @param dev 1428 * Pointer to the selected device. 1429 * @param queue_id 1430 * The selected queue. 1431 * 1432 * @return 1433 * - (1) if the queue is hairpin queue, 0 otherwise. 1434 */ 1435 __rte_internal 1436 int rte_eth_dev_is_tx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id); 1437 1438 /** 1439 * @internal 1440 * Returns a ethdev slot specified by the unique identifier name. 1441 * 1442 * @param name 1443 * The pointer to the Unique identifier name for each Ethernet device 1444 * @return 1445 * - The pointer to the ethdev slot, on success. NULL on error 1446 */ 1447 __rte_internal 1448 struct rte_eth_dev *rte_eth_dev_allocated(const char *name); 1449 1450 /** 1451 * @internal 1452 * Allocates a new ethdev slot for an Ethernet device and returns the pointer 1453 * to that slot for the driver to use. 1454 * 1455 * @param name Unique identifier name for each Ethernet device 1456 * @return 1457 * - Slot in the rte_dev_devices array for a new device; 1458 */ 1459 __rte_internal 1460 struct rte_eth_dev *rte_eth_dev_allocate(const char *name); 1461 1462 /** 1463 * @internal 1464 * Attach to the ethdev already initialized by the primary 1465 * process. 1466 * 1467 * @param name Ethernet device's name. 1468 * @return 1469 * - Success: Slot in the rte_dev_devices array for attached 1470 * device. 1471 * - Error: Null pointer. 1472 */ 1473 __rte_internal 1474 struct rte_eth_dev *rte_eth_dev_attach_secondary(const char *name); 1475 1476 /** 1477 * @internal 1478 * Notify RTE_ETH_EVENT_DESTROY and release the specified ethdev port. 1479 * 1480 * The following PMD-managed data fields will be freed: 1481 * - dev_private 1482 * - mac_addrs 1483 * - hash_mac_addrs 1484 * If one of these fields should not be freed, 1485 * it must be reset to NULL by the PMD, typically in dev_close method. 1486 * 1487 * @param eth_dev 1488 * Device to be detached. 1489 * @return 1490 * - 0 on success, negative on error 1491 */ 1492 __rte_internal 1493 int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev); 1494 1495 /** 1496 * @internal 1497 * Release device queues and clear its configuration to force the user 1498 * application to reconfigure it. It is for internal use only. 1499 * 1500 * @param dev 1501 * Pointer to struct rte_eth_dev. 1502 * 1503 * @return 1504 * void 1505 */ 1506 __rte_internal 1507 void rte_eth_dev_internal_reset(struct rte_eth_dev *dev); 1508 1509 /** 1510 * @internal Executes all the user application registered callbacks for 1511 * the specific device. It is for DPDK internal user only. User 1512 * application should not call it directly. 1513 * 1514 * @param dev 1515 * Pointer to struct rte_eth_dev. 1516 * @param event 1517 * Eth device interrupt event type. 1518 * @param ret_param 1519 * To pass data back to user application. 1520 * This allows the user application to decide if a particular function 1521 * is permitted or not. 1522 * 1523 * @return 1524 * int 1525 */ 1526 __rte_internal 1527 int rte_eth_dev_callback_process(struct rte_eth_dev *dev, 1528 enum rte_eth_event_type event, void *ret_param); 1529 1530 /** 1531 * @internal 1532 * This is the last step of device probing. 1533 * It must be called after a port is allocated and initialized successfully. 1534 * 1535 * The notification RTE_ETH_EVENT_NEW is sent to other entities 1536 * (libraries and applications). 1537 * The state is set as RTE_ETH_DEV_ATTACHED. 1538 * 1539 * @param dev 1540 * New ethdev port. 1541 */ 1542 __rte_internal 1543 void rte_eth_dev_probing_finish(struct rte_eth_dev *dev); 1544 1545 /** 1546 * Create memzone for HW rings. 1547 * malloc can't be used as the physical address is needed. 1548 * If the memzone is already created, then this function returns a ptr 1549 * to the old one. 1550 * 1551 * @param eth_dev 1552 * The *eth_dev* pointer is the address of the *rte_eth_dev* structure 1553 * @param name 1554 * The name of the memory zone 1555 * @param queue_id 1556 * The index of the queue to add to name 1557 * @param size 1558 * The sizeof of the memory area 1559 * @param align 1560 * Alignment for resulting memzone. Must be a power of 2. 1561 * @param socket_id 1562 * The *socket_id* argument is the socket identifier in case of NUMA. 1563 */ 1564 __rte_internal 1565 const struct rte_memzone * 1566 rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name, 1567 uint16_t queue_id, size_t size, 1568 unsigned align, int socket_id); 1569 1570 /** 1571 * Free previously allocated memzone for HW rings. 1572 * 1573 * @param eth_dev 1574 * The *eth_dev* pointer is the address of the *rte_eth_dev* structure 1575 * @param name 1576 * The name of the memory zone 1577 * @param queue_id 1578 * The index of the queue to add to name 1579 * @return 1580 * Negative errno value on error, 0 on success. 1581 */ 1582 __rte_internal 1583 int 1584 rte_eth_dma_zone_free(const struct rte_eth_dev *eth_dev, const char *name, 1585 uint16_t queue_id); 1586 1587 /** 1588 * @internal 1589 * Atomically set the link status for the specific device. 1590 * It is for use by DPDK device driver use only. 1591 * User applications should not call it 1592 * 1593 * @param dev 1594 * Pointer to struct rte_eth_dev. 1595 * @param link 1596 * New link status value. 1597 * @return 1598 * Same convention as eth_link_update operation. 1599 * 0 if link up status has changed 1600 * -1 if link up status was unchanged 1601 */ 1602 static inline int 1603 rte_eth_linkstatus_set(struct rte_eth_dev *dev, 1604 const struct rte_eth_link *new_link) 1605 { 1606 uint64_t *dev_link = (uint64_t *)&(dev->data->dev_link); 1607 union { 1608 uint64_t val64; 1609 struct rte_eth_link link; 1610 } orig; 1611 1612 RTE_BUILD_BUG_ON(sizeof(*new_link) != sizeof(uint64_t)); 1613 1614 orig.val64 = __atomic_exchange_n(dev_link, *(const uint64_t *)new_link, 1615 __ATOMIC_SEQ_CST); 1616 1617 return (orig.link.link_status == new_link->link_status) ? -1 : 0; 1618 } 1619 1620 /** 1621 * @internal 1622 * Atomically get the link speed and status. 1623 * 1624 * @param dev 1625 * Pointer to struct rte_eth_dev. 1626 * @param link 1627 * link status value. 1628 */ 1629 static inline void 1630 rte_eth_linkstatus_get(const struct rte_eth_dev *dev, 1631 struct rte_eth_link *link) 1632 { 1633 uint64_t *src = (uint64_t *)&(dev->data->dev_link); 1634 uint64_t *dst = (uint64_t *)link; 1635 1636 RTE_BUILD_BUG_ON(sizeof(*link) != sizeof(uint64_t)); 1637 1638 *dst = __atomic_load_n(src, __ATOMIC_SEQ_CST); 1639 } 1640 1641 /** 1642 * @internal 1643 * Dummy DPDK callback for Rx/Tx packet burst. 1644 * 1645 * @param queue 1646 * Pointer to Rx/Tx queue 1647 * @param pkts 1648 * Packet array 1649 * @param nb_pkts 1650 * Number of packets in packet array 1651 */ 1652 __rte_internal 1653 uint16_t 1654 rte_eth_pkt_burst_dummy(void *queue __rte_unused, 1655 struct rte_mbuf **pkts __rte_unused, 1656 uint16_t nb_pkts __rte_unused); 1657 1658 /** 1659 * Allocate an unique switch domain identifier. 1660 * 1661 * A pool of switch domain identifiers which can be allocated on request. This 1662 * will enabled devices which support the concept of switch domains to request 1663 * a switch domain ID which is guaranteed to be unique from other devices 1664 * running in the same process. 1665 * 1666 * @param domain_id 1667 * switch domain identifier parameter to pass back to application 1668 * 1669 * @return 1670 * Negative errno value on error, 0 on success. 1671 */ 1672 __rte_internal 1673 int 1674 rte_eth_switch_domain_alloc(uint16_t *domain_id); 1675 1676 /** 1677 * Free switch domain. 1678 * 1679 * Return a switch domain identifier to the pool of free identifiers after it is 1680 * no longer in use by device. 1681 * 1682 * @param domain_id 1683 * switch domain identifier to free 1684 * 1685 * @return 1686 * Negative errno value on error, 0 on success. 1687 */ 1688 __rte_internal 1689 int 1690 rte_eth_switch_domain_free(uint16_t domain_id); 1691 1692 /** 1693 * Generic Ethernet device arguments 1694 * 1695 * One type of representor each structure. 1696 */ 1697 struct rte_eth_devargs { 1698 uint16_t mh_controllers[RTE_MAX_MULTI_HOST_CTRLS]; 1699 /** controller/s number in case of multi-host */ 1700 uint16_t nb_mh_controllers; 1701 /** number of controllers in multi-host controllers field */ 1702 uint16_t ports[RTE_MAX_ETHPORTS]; 1703 /** port/s number to enable on a multi-port single function */ 1704 uint16_t nb_ports; 1705 /** number of ports in ports field */ 1706 uint16_t representor_ports[RTE_MAX_ETHPORTS]; 1707 /** representor port/s identifier to enable on device */ 1708 uint16_t nb_representor_ports; 1709 /** number of ports in representor port field */ 1710 enum rte_eth_representor_type type; /* type of representor */ 1711 }; 1712 1713 /** 1714 * PMD helper function to get representor ID from location detail. 1715 * 1716 * Get representor ID from controller, pf and (sf or vf). 1717 * The mapping is retrieved from rte_eth_representor_info_get(). 1718 * 1719 * For backward compatibility, if no representor info, direct 1720 * map legacy VF (no controller and pf). 1721 * 1722 * @param port_id 1723 * Port ID of the backing device. 1724 * @param type 1725 * Representor type. 1726 * @param controller 1727 * Controller ID, -1 if unspecified. 1728 * @param pf 1729 * PF port ID, -1 if unspecified. 1730 * @param representor_port 1731 * VF or SF representor port number, -1 if unspecified. 1732 * @param repr_id 1733 * Pointer to output representor ID. 1734 * 1735 * @return 1736 * Negative errno value on error, 0 on success. 1737 */ 1738 __rte_internal 1739 int 1740 rte_eth_representor_id_get(uint16_t port_id, 1741 enum rte_eth_representor_type type, 1742 int controller, int pf, int representor_port, 1743 uint16_t *repr_id); 1744 1745 /** 1746 * PMD helper function to parse ethdev arguments 1747 * 1748 * @param devargs 1749 * device arguments 1750 * @param eth_devargs 1751 * parsed ethdev specific arguments. 1752 * 1753 * @return 1754 * Negative errno value on error, 0 on success. 1755 */ 1756 __rte_internal 1757 int 1758 rte_eth_devargs_parse(const char *devargs, struct rte_eth_devargs *eth_devargs); 1759 1760 1761 typedef int (*ethdev_init_t)(struct rte_eth_dev *ethdev, void *init_params); 1762 typedef int (*ethdev_bus_specific_init)(struct rte_eth_dev *ethdev, 1763 void *bus_specific_init_params); 1764 1765 /** 1766 * PMD helper function for the creation of a new ethdev ports. 1767 * 1768 * @param device 1769 * rte_device handle. 1770 * @param name 1771 * port name. 1772 * @param priv_data_size 1773 * size of private data required for port. 1774 * @param bus_specific_init 1775 * port bus specific initialisation callback function 1776 * @param bus_init_params 1777 * port bus specific initialisation parameters 1778 * @param ethdev_init 1779 * device specific port initialization callback function 1780 * @param init_params 1781 * port initialisation parameters 1782 * 1783 * @return 1784 * Negative errno value on error, 0 on success. 1785 */ 1786 __rte_internal 1787 int 1788 rte_eth_dev_create(struct rte_device *device, const char *name, 1789 size_t priv_data_size, 1790 ethdev_bus_specific_init bus_specific_init, void *bus_init_params, 1791 ethdev_init_t ethdev_init, void *init_params); 1792 1793 1794 typedef int (*ethdev_uninit_t)(struct rte_eth_dev *ethdev); 1795 1796 /** 1797 * PMD helper function for cleaning up the resources of a ethdev port on it's 1798 * destruction. 1799 * 1800 * @param ethdev 1801 * ethdev handle of port. 1802 * @param ethdev_uninit 1803 * device specific port un-initialise callback function 1804 * 1805 * @return 1806 * Negative errno value on error, 0 on success. 1807 */ 1808 __rte_internal 1809 int 1810 rte_eth_dev_destroy(struct rte_eth_dev *ethdev, ethdev_uninit_t ethdev_uninit); 1811 1812 /** 1813 * @internal 1814 * Pass the current hairpin queue HW and/or SW information to the peer queue 1815 * and fetch back the information of the peer queue. 1816 * 1817 * @param peer_port 1818 * Peer port identifier of the Ethernet device. 1819 * @param peer_queue 1820 * Peer queue index of the port. 1821 * @param cur_info 1822 * Pointer to the current information structure. 1823 * @param peer_info 1824 * Pointer to the peer information, output. 1825 * @param direction 1826 * Direction to pass the information. 1827 * positive - pass Tx queue information and get peer Rx queue information 1828 * zero - pass Rx queue information and get peer Tx queue information 1829 * 1830 * @return 1831 * Negative errno value on error, 0 on success. 1832 */ 1833 __rte_internal 1834 int 1835 rte_eth_hairpin_queue_peer_update(uint16_t peer_port, uint16_t peer_queue, 1836 struct rte_hairpin_peer_info *cur_info, 1837 struct rte_hairpin_peer_info *peer_info, 1838 uint32_t direction); 1839 1840 /** 1841 * @internal 1842 * Configure current hairpin queue with the peer information fetched to create 1843 * the connection (bind) with peer queue in the specified direction. 1844 * This function might need to be called twice to fully create the connections. 1845 * 1846 * @param cur_port 1847 * Current port identifier of the Ethernet device. 1848 * @param cur_queue 1849 * Current queue index of the port. 1850 * @param peer_info 1851 * Pointer to the peer information, input. 1852 * @param direction 1853 * Direction to create the connection. 1854 * positive - bind current Tx queue to peer Rx queue 1855 * zero - bind current Rx queue to peer Tx queue 1856 * 1857 * @return 1858 * Negative errno value on error, 0 on success. 1859 */ 1860 __rte_internal 1861 int 1862 rte_eth_hairpin_queue_peer_bind(uint16_t cur_port, uint16_t cur_queue, 1863 struct rte_hairpin_peer_info *peer_info, 1864 uint32_t direction); 1865 1866 /** 1867 * @internal 1868 * Get rte_eth_dev from device name. The device name should be specified 1869 * as below: 1870 * - PCIe address (Domain:Bus:Device.Function), for example 0000:2:00.0 1871 * - SoC device name, for example fsl-gmac0 1872 * - vdev dpdk name, for example net_[pcap0|null0|tap0] 1873 * 1874 * @param name 1875 * PCI address or name of the device 1876 * @return 1877 * - rte_eth_dev if successful 1878 * - NULL on failure 1879 */ 1880 __rte_internal 1881 struct rte_eth_dev* 1882 rte_eth_dev_get_by_name(const char *name); 1883 1884 /** 1885 * @internal 1886 * Reset the current queue state and configuration to disconnect (unbind) it 1887 * from the peer queue. 1888 * This function might need to be called twice to disconnect each other. 1889 * 1890 * @param cur_port 1891 * Current port identifier of the Ethernet device. 1892 * @param cur_queue 1893 * Current queue index of the port. 1894 * @param direction 1895 * Direction to destroy the connection. 1896 * positive - unbind current Tx queue from peer Rx queue 1897 * zero - unbind current Rx queue from peer Tx queue 1898 * 1899 * @return 1900 * Negative errno value on error, 0 on success. 1901 */ 1902 __rte_internal 1903 int 1904 rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t cur_queue, 1905 uint32_t direction); 1906 1907 /** 1908 * @internal 1909 * Register mbuf dynamic field and flag for IP reassembly incomplete case. 1910 */ 1911 __rte_internal 1912 int 1913 rte_eth_ip_reassembly_dynfield_register(int *field_offset, int *flag); 1914 1915 1916 /* 1917 * Legacy ethdev API used internally by drivers. 1918 */ 1919 1920 enum rte_filter_type { 1921 RTE_ETH_FILTER_NONE = 0, 1922 RTE_ETH_FILTER_ETHERTYPE, 1923 RTE_ETH_FILTER_FLEXIBLE, 1924 RTE_ETH_FILTER_SYN, 1925 RTE_ETH_FILTER_NTUPLE, 1926 RTE_ETH_FILTER_TUNNEL, 1927 RTE_ETH_FILTER_FDIR, 1928 RTE_ETH_FILTER_HASH, 1929 RTE_ETH_FILTER_L2_TUNNEL, 1930 }; 1931 1932 /** 1933 * Define all structures for Ethertype Filter type. 1934 */ 1935 1936 #define RTE_ETHTYPE_FLAGS_MAC 0x0001 /**< If set, compare mac */ 1937 #define RTE_ETHTYPE_FLAGS_DROP 0x0002 /**< If set, drop packet when match */ 1938 1939 /** 1940 * A structure used to define the ethertype filter entry 1941 * to support RTE_ETH_FILTER_ETHERTYPE data representation. 1942 */ 1943 struct rte_eth_ethertype_filter { 1944 struct rte_ether_addr mac_addr; /**< Mac address to match */ 1945 uint16_t ether_type; /**< Ether type to match */ 1946 uint16_t flags; /**< Flags from RTE_ETHTYPE_FLAGS_* */ 1947 uint16_t queue; /**< Queue assigned to when match */ 1948 }; 1949 1950 /** 1951 * A structure used to define the TCP syn filter entry 1952 * to support RTE_ETH_FILTER_SYN data representation. 1953 */ 1954 struct rte_eth_syn_filter { 1955 /** 1 - higher priority than other filters, 0 - lower priority */ 1956 uint8_t hig_pri; 1957 uint16_t queue; /**< Queue assigned to when match */ 1958 }; 1959 1960 /** 1961 * filter type of tunneling packet 1962 */ 1963 #define RTE_ETH_TUNNEL_FILTER_OMAC 0x01 /**< filter by outer MAC addr */ 1964 #define RTE_ETH_TUNNEL_FILTER_OIP 0x02 /**< filter by outer IP Addr */ 1965 #define RTE_ETH_TUNNEL_FILTER_TENID 0x04 /**< filter by tenant ID */ 1966 #define RTE_ETH_TUNNEL_FILTER_IMAC 0x08 /**< filter by inner MAC addr */ 1967 #define RTE_ETH_TUNNEL_FILTER_IVLAN 0x10 /**< filter by inner VLAN ID */ 1968 #define RTE_ETH_TUNNEL_FILTER_IIP 0x20 /**< filter by inner IP addr */ 1969 1970 #define RTE_ETH_TUNNEL_FILTER_IMAC_IVLAN (RTE_ETH_TUNNEL_FILTER_IMAC | \ 1971 RTE_ETH_TUNNEL_FILTER_IVLAN) 1972 #define RTE_ETH_TUNNEL_FILTER_IMAC_IVLAN_TENID (RTE_ETH_TUNNEL_FILTER_IMAC | \ 1973 RTE_ETH_TUNNEL_FILTER_IVLAN | \ 1974 RTE_ETH_TUNNEL_FILTER_TENID) 1975 #define RTE_ETH_TUNNEL_FILTER_IMAC_TENID (RTE_ETH_TUNNEL_FILTER_IMAC | \ 1976 RTE_ETH_TUNNEL_FILTER_TENID) 1977 #define RTE_ETH_TUNNEL_FILTER_OMAC_TENID_IMAC (RTE_ETH_TUNNEL_FILTER_OMAC | \ 1978 RTE_ETH_TUNNEL_FILTER_TENID | \ 1979 RTE_ETH_TUNNEL_FILTER_IMAC) 1980 1981 /** 1982 * Select IPv4 or IPv6 for tunnel filters. 1983 */ 1984 enum rte_tunnel_iptype { 1985 RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4 */ 1986 RTE_TUNNEL_IPTYPE_IPV6, /**< IPv6 */ 1987 }; 1988 1989 /** 1990 * Tunneling Packet filter configuration. 1991 */ 1992 struct rte_eth_tunnel_filter_conf { 1993 struct rte_ether_addr outer_mac; /**< Outer MAC address to match */ 1994 struct rte_ether_addr inner_mac; /**< Inner MAC address to match */ 1995 uint16_t inner_vlan; /**< Inner VLAN to match */ 1996 enum rte_tunnel_iptype ip_type; /**< IP address type */ 1997 /** 1998 * Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP 1999 * is set in filter_type, or inner destination IP address to match 2000 * if ETH_TUNNEL_FILTER_IIP is set in filter_type. 2001 */ 2002 union { 2003 uint32_t ipv4_addr; /**< IPv4 address in big endian */ 2004 uint32_t ipv6_addr[4]; /**< IPv6 address in big endian */ 2005 } ip_addr; 2006 /** Flags from ETH_TUNNEL_FILTER_XX - see above */ 2007 uint16_t filter_type; 2008 enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type */ 2009 uint32_t tenant_id; /**< Tenant ID to match: VNI, GRE key... */ 2010 uint16_t queue_id; /**< Queue assigned to if match */ 2011 }; 2012 2013 /** 2014 * Memory space that can be configured to store Flow Director filters 2015 * in the board memory. 2016 */ 2017 enum rte_eth_fdir_pballoc_type { 2018 RTE_ETH_FDIR_PBALLOC_64K = 0, /**< 64k. */ 2019 RTE_ETH_FDIR_PBALLOC_128K, /**< 128k. */ 2020 RTE_ETH_FDIR_PBALLOC_256K, /**< 256k. */ 2021 }; 2022 2023 /** 2024 * Select report mode of FDIR hash information in Rx descriptors. 2025 */ 2026 enum rte_fdir_status_mode { 2027 RTE_FDIR_NO_REPORT_STATUS = 0, /**< Never report FDIR hash. */ 2028 RTE_FDIR_REPORT_STATUS, /**< Only report FDIR hash for matching pkts. */ 2029 RTE_FDIR_REPORT_STATUS_ALWAYS, /**< Always report FDIR hash. */ 2030 }; 2031 2032 /** 2033 * A structure used to configure the Flow Director (FDIR) feature 2034 * of an Ethernet port. 2035 * 2036 * If mode is RTE_FDIR_MODE_NONE, the pballoc value is ignored. 2037 */ 2038 struct rte_eth_fdir_conf { 2039 enum rte_fdir_mode mode; /**< Flow Director mode. */ 2040 enum rte_eth_fdir_pballoc_type pballoc; /**< Space for FDIR filters. */ 2041 enum rte_fdir_status_mode status; /**< How to report FDIR hash. */ 2042 /** Rx queue of packets matching a "drop" filter in perfect mode. */ 2043 uint8_t drop_queue; 2044 struct rte_eth_fdir_masks mask; 2045 /** Flex payload configuration. */ 2046 struct rte_eth_fdir_flex_conf flex_conf; 2047 }; 2048 2049 #ifdef __cplusplus 2050 } 2051 #endif 2052 2053 #endif /* _RTE_ETHDEV_DRIVER_H_ */ 2054