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 /** 9 * @file 10 * 11 * RTE Ethernet Device PMD API 12 * 13 * These APIs for the use from Ethernet drivers, user applications shouldn't 14 * use them. 15 * 16 */ 17 18 #include <rte_ethdev.h> 19 20 /**< @internal Declaration of the hairpin peer queue information structure. */ 21 struct rte_hairpin_peer_info; 22 23 /* 24 * Definitions of all functions exported by an Ethernet driver through the 25 * generic structure of type *eth_dev_ops* supplied in the *rte_eth_dev* 26 * structure associated with an Ethernet device. 27 */ 28 29 typedef int (*eth_dev_configure_t)(struct rte_eth_dev *dev); 30 /**< @internal Ethernet device configuration. */ 31 32 typedef int (*eth_dev_start_t)(struct rte_eth_dev *dev); 33 /**< @internal Function used to start a configured Ethernet device. */ 34 35 typedef int (*eth_dev_stop_t)(struct rte_eth_dev *dev); 36 /**< @internal Function used to stop a configured Ethernet device. */ 37 38 typedef int (*eth_dev_set_link_up_t)(struct rte_eth_dev *dev); 39 /**< @internal Function used to link up a configured Ethernet device. */ 40 41 typedef int (*eth_dev_set_link_down_t)(struct rte_eth_dev *dev); 42 /**< @internal Function used to link down a configured Ethernet device. */ 43 44 typedef int (*eth_dev_close_t)(struct rte_eth_dev *dev); 45 /**< @internal Function used to close a configured Ethernet device. */ 46 47 typedef int (*eth_dev_reset_t)(struct rte_eth_dev *dev); 48 /** <@internal Function used to reset a configured Ethernet device. */ 49 50 typedef int (*eth_is_removed_t)(struct rte_eth_dev *dev); 51 /**< @internal Function used to detect an Ethernet device removal. */ 52 53 /** 54 * @internal 55 * Function used to enable the Rx promiscuous mode of an Ethernet device. 56 * 57 * @param dev 58 * ethdev handle of port. 59 * 60 * @return 61 * Negative errno value on error, 0 on success. 62 * 63 * @retval 0 64 * Success, promiscuous mode is enabled. 65 * @retval -ENOTSUP 66 * Promiscuous mode is not supported. 67 * @retval -ENODEV 68 * Device is gone. 69 * @retval -E_RTE_SECONDARY 70 * Function was called from a secondary process instance and not supported. 71 * @retval -ETIMEDOUT 72 * Attempt to enable promiscuos mode failed because of timeout. 73 * @retval -EAGAIN 74 * Failed to enable promiscuous mode. 75 */ 76 typedef int (*eth_promiscuous_enable_t)(struct rte_eth_dev *dev); 77 78 /** 79 * @internal 80 * Function used to disable the Rx promiscuous mode of an Ethernet device. 81 * 82 * @param dev 83 * ethdev handle of port. 84 * 85 * @return 86 * Negative errno value on error, 0 on success. 87 * 88 * @retval 0 89 * Success, promiscuous mode is disabled. 90 * @retval -ENOTSUP 91 * Promiscuous mode disabling is not supported. 92 * @retval -ENODEV 93 * Device is gone. 94 * @retval -E_RTE_SECONDARY 95 * Function was called from a secondary process instance and not supported. 96 * @retval -ETIMEDOUT 97 * Attempt to disable promiscuos mode failed because of timeout. 98 * @retval -EAGAIN 99 * Failed to disable promiscuous mode. 100 */ 101 typedef int (*eth_promiscuous_disable_t)(struct rte_eth_dev *dev); 102 103 /** 104 * @internal 105 * Enable the receipt of all multicast packets by an Ethernet device. 106 * 107 * @param dev 108 * ethdev handle of port. 109 * 110 * @return 111 * Negative errno value on error, 0 on success. 112 * 113 * @retval 0 114 * Success, all-multicast mode is enabled. 115 * @retval -ENOTSUP 116 * All-multicast mode is not supported. 117 * @retval -ENODEV 118 * Device is gone. 119 * @retval -E_RTE_SECONDARY 120 * Function was called from a secondary process instance and not supported. 121 * @retval -ETIMEDOUT 122 * Attempt to enable all-multicast mode failed because of timeout. 123 * @retval -EAGAIN 124 * Failed to enable all-multicast mode. 125 */ 126 typedef int (*eth_allmulticast_enable_t)(struct rte_eth_dev *dev); 127 128 /** 129 * @internal 130 * Disable the receipt of all multicast packets by an Ethernet device. 131 * 132 * @param dev 133 * ethdev handle of port. 134 * 135 * @return 136 * Negative errno value on error, 0 on success. 137 * 138 * @retval 0 139 * Success, all-multicast mode is disabled. 140 * @retval -ENOTSUP 141 * All-multicast mode disabling is not supported. 142 * @retval -ENODEV 143 * Device is gone. 144 * @retval -E_RTE_SECONDARY 145 * Function was called from a secondary process instance and not supported. 146 * @retval -ETIMEDOUT 147 * Attempt to disable all-multicast mode failed because of timeout. 148 * @retval -EAGAIN 149 * Failed to disable all-multicast mode. 150 */ 151 typedef int (*eth_allmulticast_disable_t)(struct rte_eth_dev *dev); 152 153 typedef int (*eth_link_update_t)(struct rte_eth_dev *dev, 154 int wait_to_complete); 155 /**< @internal Get link speed, duplex mode and state (up/down) of an Ethernet device. */ 156 157 typedef int (*eth_stats_get_t)(struct rte_eth_dev *dev, 158 struct rte_eth_stats *igb_stats); 159 /**< @internal Get global I/O statistics of an Ethernet device. */ 160 161 /** 162 * @internal 163 * Reset global I/O statistics of an Ethernet device to 0. 164 * 165 * @param dev 166 * ethdev handle of port. 167 * 168 * @return 169 * Negative errno value on error, 0 on success. 170 * 171 * @retval 0 172 * Success, statistics has been reset. 173 * @retval -ENOTSUP 174 * Resetting statistics is not supported. 175 * @retval -EINVAL 176 * Resetting statistics is not valid. 177 * @retval -ENOMEM 178 * Not enough memory to get the stats. 179 */ 180 typedef int (*eth_stats_reset_t)(struct rte_eth_dev *dev); 181 182 typedef int (*eth_xstats_get_t)(struct rte_eth_dev *dev, 183 struct rte_eth_xstat *stats, unsigned int n); 184 /**< @internal Get extended stats of an Ethernet device. */ 185 186 /** 187 * @internal 188 * Get extended stats of an Ethernet device. 189 * 190 * @param dev 191 * ethdev handle of port. 192 * @param ids 193 * IDs array to retrieve specific statistics. Must not be NULL. 194 * @param values 195 * A pointer to a table to be filled with device statistics values. 196 * Must not be NULL. 197 * @param n 198 * Element count in @p ids and @p values. 199 * 200 * @return 201 * - A number of filled in stats. 202 * - A negative value on error. 203 */ 204 typedef int (*eth_xstats_get_by_id_t)(struct rte_eth_dev *dev, 205 const uint64_t *ids, 206 uint64_t *values, 207 unsigned int n); 208 209 /** 210 * @internal 211 * Reset extended stats of an Ethernet device. 212 * 213 * @param dev 214 * ethdev handle of port. 215 * 216 * @return 217 * Negative errno value on error, 0 on success. 218 * 219 * @retval 0 220 * Success, statistics has been reset. 221 * @retval -ENOTSUP 222 * Resetting statistics is not supported. 223 * @retval -EINVAL 224 * Resetting statistics is not valid. 225 * @retval -ENOMEM 226 * Not enough memory to get the stats. 227 */ 228 typedef int (*eth_xstats_reset_t)(struct rte_eth_dev *dev); 229 230 typedef int (*eth_xstats_get_names_t)(struct rte_eth_dev *dev, 231 struct rte_eth_xstat_name *xstats_names, unsigned int size); 232 /**< @internal Get names of extended stats of an Ethernet device. */ 233 234 /** 235 * @internal 236 * Get names of extended stats of an Ethernet device. 237 * 238 * @param dev 239 * ethdev handle of port. 240 * @param ids 241 * IDs array to retrieve specific statistics. Must not be NULL. 242 * @param xstats_names 243 * An rte_eth_xstat_name array of at least @p size elements to be filled. 244 * Must not be NULL. 245 * @param size 246 * Element count in @p ids and @p xstats_names. 247 * 248 * @return 249 * - A number of filled in stats. 250 * - A negative value on error. 251 */ 252 typedef int (*eth_xstats_get_names_by_id_t)(struct rte_eth_dev *dev, 253 const uint64_t *ids, struct rte_eth_xstat_name *xstats_names, 254 unsigned int size); 255 256 typedef int (*eth_queue_stats_mapping_set_t)(struct rte_eth_dev *dev, 257 uint16_t queue_id, 258 uint8_t stat_idx, 259 uint8_t is_rx); 260 /**< @internal Set a queue statistics mapping for a tx/rx queue of an Ethernet device. */ 261 262 typedef int (*eth_dev_infos_get_t)(struct rte_eth_dev *dev, 263 struct rte_eth_dev_info *dev_info); 264 /**< @internal Get specific information of an Ethernet device. */ 265 266 typedef const uint32_t *(*eth_dev_supported_ptypes_get_t)(struct rte_eth_dev *dev); 267 /**< @internal Get supported ptypes of an Ethernet device. */ 268 269 /** 270 * @internal 271 * Inform Ethernet device about reduced range of packet types to handle. 272 * 273 * @param dev 274 * The Ethernet device identifier. 275 * @param ptype_mask 276 * The ptype family that application is interested in should be bitwise OR of 277 * RTE_PTYPE_*_MASK or 0. 278 * @return 279 * - (0) if Success. 280 */ 281 typedef int (*eth_dev_ptypes_set_t)(struct rte_eth_dev *dev, 282 uint32_t ptype_mask); 283 284 typedef int (*eth_queue_start_t)(struct rte_eth_dev *dev, 285 uint16_t queue_id); 286 /**< @internal Start rx and tx of a queue of an Ethernet device. */ 287 288 typedef int (*eth_queue_stop_t)(struct rte_eth_dev *dev, 289 uint16_t queue_id); 290 /**< @internal Stop rx and tx of a queue of an Ethernet device. */ 291 292 typedef int (*eth_rx_queue_setup_t)(struct rte_eth_dev *dev, 293 uint16_t rx_queue_id, 294 uint16_t nb_rx_desc, 295 unsigned int socket_id, 296 const struct rte_eth_rxconf *rx_conf, 297 struct rte_mempool *mb_pool); 298 /**< @internal Set up a receive queue of an Ethernet device. */ 299 300 typedef int (*eth_tx_queue_setup_t)(struct rte_eth_dev *dev, 301 uint16_t tx_queue_id, 302 uint16_t nb_tx_desc, 303 unsigned int socket_id, 304 const struct rte_eth_txconf *tx_conf); 305 /**< @internal Setup a transmit queue of an Ethernet device. */ 306 307 typedef int (*eth_rx_enable_intr_t)(struct rte_eth_dev *dev, 308 uint16_t rx_queue_id); 309 /**< @internal Enable interrupt of a receive queue of an Ethernet device. */ 310 311 typedef int (*eth_rx_disable_intr_t)(struct rte_eth_dev *dev, 312 uint16_t rx_queue_id); 313 /**< @internal Disable interrupt of a receive queue of an Ethernet device. */ 314 315 typedef void (*eth_queue_release_t)(struct rte_eth_dev *dev, 316 uint16_t queue_id); 317 /**< @internal Release memory resources allocated by given RX/TX queue. */ 318 319 typedef int (*eth_fw_version_get_t)(struct rte_eth_dev *dev, 320 char *fw_version, size_t fw_size); 321 /**< @internal Get firmware information of an Ethernet device. */ 322 323 typedef int (*eth_tx_done_cleanup_t)(void *txq, uint32_t free_cnt); 324 /**< @internal Force mbufs to be from TX ring. */ 325 326 typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev, 327 uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo); 328 329 typedef void (*eth_txq_info_get_t)(struct rte_eth_dev *dev, 330 uint16_t tx_queue_id, struct rte_eth_txq_info *qinfo); 331 332 typedef int (*eth_burst_mode_get_t)(struct rte_eth_dev *dev, 333 uint16_t queue_id, struct rte_eth_burst_mode *mode); 334 335 typedef int (*mtu_set_t)(struct rte_eth_dev *dev, uint16_t mtu); 336 /**< @internal Set MTU. */ 337 338 typedef int (*vlan_filter_set_t)(struct rte_eth_dev *dev, 339 uint16_t vlan_id, 340 int on); 341 /**< @internal filtering of a VLAN Tag Identifier by an Ethernet device. */ 342 343 typedef int (*vlan_tpid_set_t)(struct rte_eth_dev *dev, 344 enum rte_vlan_type type, uint16_t tpid); 345 /**< @internal set the outer/inner VLAN-TPID by an Ethernet device. */ 346 347 typedef int (*vlan_offload_set_t)(struct rte_eth_dev *dev, int mask); 348 /**< @internal set VLAN offload function by an Ethernet device. */ 349 350 typedef int (*vlan_pvid_set_t)(struct rte_eth_dev *dev, 351 uint16_t vlan_id, 352 int on); 353 /**< @internal set port based TX VLAN insertion by an Ethernet device. */ 354 355 typedef void (*vlan_strip_queue_set_t)(struct rte_eth_dev *dev, 356 uint16_t rx_queue_id, 357 int on); 358 /**< @internal VLAN stripping enable/disable by an queue of Ethernet device. */ 359 360 typedef int (*flow_ctrl_get_t)(struct rte_eth_dev *dev, 361 struct rte_eth_fc_conf *fc_conf); 362 /**< @internal Get current flow control parameter on an Ethernet device */ 363 364 typedef int (*flow_ctrl_set_t)(struct rte_eth_dev *dev, 365 struct rte_eth_fc_conf *fc_conf); 366 /**< @internal Setup flow control parameter on an Ethernet device */ 367 368 typedef int (*priority_flow_ctrl_set_t)(struct rte_eth_dev *dev, 369 struct rte_eth_pfc_conf *pfc_conf); 370 /**< @internal Setup priority flow control parameter on an Ethernet device */ 371 372 typedef int (*reta_update_t)(struct rte_eth_dev *dev, 373 struct rte_eth_rss_reta_entry64 *reta_conf, 374 uint16_t reta_size); 375 /**< @internal Update RSS redirection table on an Ethernet device */ 376 377 typedef int (*reta_query_t)(struct rte_eth_dev *dev, 378 struct rte_eth_rss_reta_entry64 *reta_conf, 379 uint16_t reta_size); 380 /**< @internal Query RSS redirection table on an Ethernet device */ 381 382 typedef int (*rss_hash_update_t)(struct rte_eth_dev *dev, 383 struct rte_eth_rss_conf *rss_conf); 384 /**< @internal Update RSS hash configuration of an Ethernet device */ 385 386 typedef int (*rss_hash_conf_get_t)(struct rte_eth_dev *dev, 387 struct rte_eth_rss_conf *rss_conf); 388 /**< @internal Get current RSS hash configuration of an Ethernet device */ 389 390 typedef int (*eth_dev_led_on_t)(struct rte_eth_dev *dev); 391 /**< @internal Turn on SW controllable LED on an Ethernet device */ 392 393 typedef int (*eth_dev_led_off_t)(struct rte_eth_dev *dev); 394 /**< @internal Turn off SW controllable LED on an Ethernet device */ 395 396 typedef void (*eth_mac_addr_remove_t)(struct rte_eth_dev *dev, uint32_t index); 397 /**< @internal Remove MAC address from receive address register */ 398 399 typedef int (*eth_mac_addr_add_t)(struct rte_eth_dev *dev, 400 struct rte_ether_addr *mac_addr, 401 uint32_t index, 402 uint32_t vmdq); 403 /**< @internal Set a MAC address into Receive Address Register */ 404 405 typedef int (*eth_mac_addr_set_t)(struct rte_eth_dev *dev, 406 struct rte_ether_addr *mac_addr); 407 /**< @internal Set a MAC address into Receive Address Register */ 408 409 typedef int (*eth_uc_hash_table_set_t)(struct rte_eth_dev *dev, 410 struct rte_ether_addr *mac_addr, 411 uint8_t on); 412 /**< @internal Set a Unicast Hash bitmap */ 413 414 typedef int (*eth_uc_all_hash_table_set_t)(struct rte_eth_dev *dev, 415 uint8_t on); 416 /**< @internal Set all Unicast Hash bitmap */ 417 418 typedef int (*eth_set_queue_rate_limit_t)(struct rte_eth_dev *dev, 419 uint16_t queue_idx, 420 uint16_t tx_rate); 421 /**< @internal Set queue TX rate */ 422 423 typedef int (*eth_udp_tunnel_port_add_t)(struct rte_eth_dev *dev, 424 struct rte_eth_udp_tunnel *tunnel_udp); 425 /**< @internal Add tunneling UDP port */ 426 427 typedef int (*eth_udp_tunnel_port_del_t)(struct rte_eth_dev *dev, 428 struct rte_eth_udp_tunnel *tunnel_udp); 429 /**< @internal Delete tunneling UDP port */ 430 431 typedef int (*eth_set_mc_addr_list_t)(struct rte_eth_dev *dev, 432 struct rte_ether_addr *mc_addr_set, 433 uint32_t nb_mc_addr); 434 /**< @internal set the list of multicast addresses on an Ethernet device */ 435 436 typedef int (*eth_timesync_enable_t)(struct rte_eth_dev *dev); 437 /**< @internal Function used to enable IEEE1588/802.1AS timestamping. */ 438 439 typedef int (*eth_timesync_disable_t)(struct rte_eth_dev *dev); 440 /**< @internal Function used to disable IEEE1588/802.1AS timestamping. */ 441 442 typedef int (*eth_timesync_read_rx_timestamp_t)(struct rte_eth_dev *dev, 443 struct timespec *timestamp, 444 uint32_t flags); 445 /**< @internal Function used to read an RX IEEE1588/802.1AS timestamp. */ 446 447 typedef int (*eth_timesync_read_tx_timestamp_t)(struct rte_eth_dev *dev, 448 struct timespec *timestamp); 449 /**< @internal Function used to read a TX IEEE1588/802.1AS timestamp. */ 450 451 typedef int (*eth_timesync_adjust_time)(struct rte_eth_dev *dev, int64_t); 452 /**< @internal Function used to adjust the device clock */ 453 454 typedef int (*eth_timesync_read_time)(struct rte_eth_dev *dev, 455 struct timespec *timestamp); 456 /**< @internal Function used to get time from the device clock. */ 457 458 typedef int (*eth_timesync_write_time)(struct rte_eth_dev *dev, 459 const struct timespec *timestamp); 460 /**< @internal Function used to get time from the device clock */ 461 462 typedef int (*eth_read_clock)(struct rte_eth_dev *dev, 463 uint64_t *timestamp); 464 /**< @internal Function used to get the current value of the device clock. */ 465 466 typedef int (*eth_get_reg_t)(struct rte_eth_dev *dev, 467 struct rte_dev_reg_info *info); 468 /**< @internal Retrieve registers */ 469 470 typedef int (*eth_get_eeprom_length_t)(struct rte_eth_dev *dev); 471 /**< @internal Retrieve eeprom size */ 472 473 typedef int (*eth_get_eeprom_t)(struct rte_eth_dev *dev, 474 struct rte_dev_eeprom_info *info); 475 /**< @internal Retrieve eeprom data */ 476 477 typedef int (*eth_set_eeprom_t)(struct rte_eth_dev *dev, 478 struct rte_dev_eeprom_info *info); 479 /**< @internal Program eeprom data */ 480 481 typedef int (*eth_get_module_info_t)(struct rte_eth_dev *dev, 482 struct rte_eth_dev_module_info *modinfo); 483 /**< @internal Retrieve type and size of plugin module eeprom */ 484 485 typedef int (*eth_get_module_eeprom_t)(struct rte_eth_dev *dev, 486 struct rte_dev_eeprom_info *info); 487 /**< @internal Retrieve plugin module eeprom data */ 488 489 struct rte_flow_ops; 490 /** 491 * @internal 492 * Get flow operations. 493 * 494 * If the flow API is not supported for the specified device, 495 * the driver can return NULL. 496 */ 497 typedef int (*eth_flow_ops_get_t)(struct rte_eth_dev *dev, 498 const struct rte_flow_ops **ops); 499 500 typedef int (*eth_tm_ops_get_t)(struct rte_eth_dev *dev, void *ops); 501 /**< @internal Get Traffic Management (TM) operations on an Ethernet device */ 502 503 typedef int (*eth_mtr_ops_get_t)(struct rte_eth_dev *dev, void *ops); 504 /**< @internal Get Traffic Metering and Policing (MTR) operations */ 505 506 typedef int (*eth_get_dcb_info)(struct rte_eth_dev *dev, 507 struct rte_eth_dcb_info *dcb_info); 508 /**< @internal Get dcb information on an Ethernet device */ 509 510 typedef int (*eth_pool_ops_supported_t)(struct rte_eth_dev *dev, 511 const char *pool); 512 /**< @internal Test if a port supports specific mempool ops */ 513 514 /** 515 * @internal 516 * Get the hairpin capabilities. 517 * 518 * @param dev 519 * ethdev handle of port. 520 * @param cap 521 * returns the hairpin capabilities from the device. 522 * 523 * @return 524 * Negative errno value on error, 0 on success. 525 * 526 * @retval 0 527 * Success, hairpin is supported. 528 * @retval -ENOTSUP 529 * Hairpin is not supported. 530 */ 531 typedef int (*eth_hairpin_cap_get_t)(struct rte_eth_dev *dev, 532 struct rte_eth_hairpin_cap *cap); 533 534 /** 535 * @internal 536 * Setup RX hairpin queue. 537 * 538 * @param dev 539 * ethdev handle of port. 540 * @param rx_queue_id 541 * the selected RX queue index. 542 * @param nb_rx_desc 543 * the requested number of descriptors for this queue. 0 - use PMD default. 544 * @param conf 545 * the RX hairpin configuration structure. 546 * 547 * @return 548 * Negative errno value on error, 0 on success. 549 * 550 * @retval 0 551 * Success, hairpin is supported. 552 * @retval -ENOTSUP 553 * Hairpin is not supported. 554 * @retval -EINVAL 555 * One of the parameters is invalid. 556 * @retval -ENOMEM 557 * Unable to allocate resources. 558 */ 559 typedef int (*eth_rx_hairpin_queue_setup_t) 560 (struct rte_eth_dev *dev, uint16_t rx_queue_id, 561 uint16_t nb_rx_desc, 562 const struct rte_eth_hairpin_conf *conf); 563 564 /** 565 * @internal 566 * Setup TX hairpin queue. 567 * 568 * @param dev 569 * ethdev handle of port. 570 * @param tx_queue_id 571 * the selected TX queue index. 572 * @param nb_tx_desc 573 * the requested number of descriptors for this queue. 0 - use PMD default. 574 * @param conf 575 * the TX hairpin configuration structure. 576 * 577 * @return 578 * Negative errno value on error, 0 on success. 579 * 580 * @retval 0 581 * Success, hairpin is supported. 582 * @retval -ENOTSUP 583 * Hairpin is not supported. 584 * @retval -EINVAL 585 * One of the parameters is invalid. 586 * @retval -ENOMEM 587 * Unable to allocate resources. 588 */ 589 typedef int (*eth_tx_hairpin_queue_setup_t) 590 (struct rte_eth_dev *dev, uint16_t tx_queue_id, 591 uint16_t nb_tx_desc, 592 const struct rte_eth_hairpin_conf *hairpin_conf); 593 594 /** 595 * @internal 596 * Get Forward Error Correction(FEC) capability. 597 * 598 * @param dev 599 * ethdev handle of port. 600 * @param speed_fec_capa 601 * speed_fec_capa is out only with per-speed capabilities. 602 * @param num 603 * a number of elements in an speed_fec_capa array. 604 * 605 * @return 606 * Negative errno value on error, positive value on success. 607 * 608 * @retval positive value 609 * A non-negative value lower or equal to num: success. The return value 610 * is the number of entries filled in the fec capa array. 611 * A non-negative value higher than num: error, the given fec capa array 612 * is too small. The return value corresponds to the num that should 613 * be given to succeed. The entries in the fec capa array are not valid 614 * and shall not be used by the caller. 615 * @retval -ENOTSUP 616 * Operation is not supported. 617 * @retval -EIO 618 * Device is removed. 619 * @retval -EINVAL 620 * *num* or *speed_fec_capa* invalid. 621 */ 622 typedef int (*eth_fec_get_capability_t)(struct rte_eth_dev *dev, 623 struct rte_eth_fec_capa *speed_fec_capa, unsigned int num); 624 625 /** 626 * @internal 627 * Get Forward Error Correction(FEC) mode. 628 * 629 * @param dev 630 * ethdev handle of port. 631 * @param fec_capa 632 * a bitmask of enabled FEC modes. If AUTO bit is set, other 633 * bits specify FEC modes which may be negotiated. If AUTO 634 * bit is clear, specify FEC modes to be used (only one valid 635 * mode per speed may be set). 636 * 637 * @return 638 * Negative errno value on error, 0 on success. 639 * 640 * @retval 0 641 * Success, get FEC success. 642 * @retval -ENOTSUP 643 * Operation is not supported. 644 * @retval -EIO 645 * Device is removed. 646 */ 647 typedef int (*eth_fec_get_t)(struct rte_eth_dev *dev, 648 uint32_t *fec_capa); 649 650 /** 651 * @internal 652 * Set Forward Error Correction(FEC) mode. 653 * 654 * @param dev 655 * ethdev handle of port. 656 * @param fec_capa 657 * bitmask of allowed FEC modes. It must be only one 658 * if AUTO is disabled. If AUTO is enabled, other 659 * bits specify FEC modes which may be negotiated. 660 * 661 * @return 662 * Negative errno value on error, 0 on success. 663 * 664 * @retval 0 665 * Success, set FEC success. 666 * @retval -ENOTSUP 667 * Operation is not supported. 668 * @retval -EINVAL 669 * Unsupported FEC mode requested. 670 * @retval -EIO 671 * Device is removed. 672 */ 673 typedef int (*eth_fec_set_t)(struct rte_eth_dev *dev, uint32_t fec_capa); 674 675 /** 676 * @internal 677 * Get all hairpin Tx/Rx peer ports of the current device, if any. 678 * 679 * @param dev 680 * ethdev handle of port. 681 * @param peer_ports 682 * array to save the ports list. 683 * @param len 684 * array length. 685 * @param direction 686 * value to decide the current to peer direction 687 * positive - used as Tx to get all peer Rx ports. 688 * zero - used as Rx to get all peer Tx ports. 689 * 690 * @return 691 * Negative errno value on error, 0 or positive on success. 692 * 693 * @retval 0 694 * Success, no peer ports. 695 * @retval >0 696 * Actual number of the peer ports. 697 * @retval -ENOTSUP 698 * Get peer ports API is not supported. 699 * @retval -EINVAL 700 * One of the parameters is invalid. 701 */ 702 typedef int (*hairpin_get_peer_ports_t)(struct rte_eth_dev *dev, 703 uint16_t *peer_ports, size_t len, 704 uint32_t direction); 705 706 /** 707 * @internal 708 * Bind all hairpin Tx queues of one port to the Rx queues of the peer port. 709 * 710 * @param dev 711 * ethdev handle of port. 712 * @param rx_port 713 * the peer Rx port. 714 * 715 * @return 716 * Negative errno value on error, 0 on success. 717 * 718 * @retval 0 719 * Success, bind successfully. 720 * @retval -ENOTSUP 721 * Bind API is not supported. 722 * @retval -EINVAL 723 * One of the parameters is invalid. 724 * @retval -EBUSY 725 * Device is not started. 726 */ 727 typedef int (*eth_hairpin_bind_t)(struct rte_eth_dev *dev, 728 uint16_t rx_port); 729 730 /** 731 * @internal 732 * Unbind all hairpin Tx queues of one port from the Rx queues of the peer port. 733 * 734 * @param dev 735 * ethdev handle of port. 736 * @param rx_port 737 * the peer Rx port. 738 * 739 * @return 740 * Negative errno value on error, 0 on success. 741 * 742 * @retval 0 743 * Success, unbind successfully. 744 * @retval -ENOTSUP 745 * Bind API is not supported. 746 * @retval -EINVAL 747 * One of the parameters is invalid. 748 * @retval -EBUSY 749 * Device is already stopped. 750 */ 751 typedef int (*eth_hairpin_unbind_t)(struct rte_eth_dev *dev, 752 uint16_t rx_port); 753 754 typedef int (*eth_hairpin_queue_peer_update_t) 755 (struct rte_eth_dev *dev, uint16_t peer_queue, 756 struct rte_hairpin_peer_info *current_info, 757 struct rte_hairpin_peer_info *peer_info, uint32_t direction); 758 /**< @internal Update and fetch peer queue information. */ 759 760 typedef int (*eth_hairpin_queue_peer_bind_t) 761 (struct rte_eth_dev *dev, uint16_t cur_queue, 762 struct rte_hairpin_peer_info *peer_info, uint32_t direction); 763 /**< @internal Bind peer queue to the current queue with fetched information. */ 764 765 typedef int (*eth_hairpin_queue_peer_unbind_t) 766 (struct rte_eth_dev *dev, uint16_t cur_queue, uint32_t direction); 767 /**< @internal Unbind peer queue from the current queue. */ 768 769 /** 770 * @internal 771 * Get address of memory location whose contents will change whenever there is 772 * new data to be received on an Rx queue. 773 * 774 * @param rxq 775 * Ethdev queue pointer. 776 * @param pmc 777 * The pointer to power-optimized monitoring condition structure. 778 * @return 779 * Negative errno value on error, 0 on success. 780 * 781 * @retval 0 782 * Success 783 * @retval -EINVAL 784 * Invalid parameters 785 */ 786 typedef int (*eth_get_monitor_addr_t)(void *rxq, 787 struct rte_power_monitor_cond *pmc); 788 789 /** 790 * @internal 791 * Get representor info to be able to calculate the unique representor ID. 792 * 793 * Caller should pass NULL as pointer of info to get number of entries, 794 * allocate info buffer according to returned entry number, then call 795 * again with buffer to get real info. 796 * 797 * To calculate the representor ID, caller should iterate each entry, 798 * match controller index, pf index, vf or sf start index and range, 799 * then calculate representor ID from offset to vf/sf start index. 800 * @see rte_eth_representor_id_get. 801 * 802 * @param dev 803 * Ethdev handle of port. 804 * @param [out] info 805 * Pointer to memory to save device representor info. 806 * @return 807 * Negative errno value on error, number of info entries otherwise. 808 */ 809 810 typedef int (*eth_representor_info_get_t)(struct rte_eth_dev *dev, 811 struct rte_eth_representor_info *info); 812 813 /** 814 * @internal 815 * Negotiate the NIC's ability to deliver specific kinds of metadata to the PMD. 816 * 817 * @param dev 818 * Port (ethdev) handle 819 * 820 * @param[inout] features 821 * Feature selection buffer 822 * 823 * @return 824 * Negative errno value on error, zero otherwise 825 */ 826 typedef int (*eth_rx_metadata_negotiate_t)(struct rte_eth_dev *dev, 827 uint64_t *features); 828 829 /** 830 * @internal A structure containing the functions exported by an Ethernet driver. 831 */ 832 struct eth_dev_ops { 833 eth_dev_configure_t dev_configure; /**< Configure device. */ 834 eth_dev_start_t dev_start; /**< Start device. */ 835 eth_dev_stop_t dev_stop; /**< Stop device. */ 836 eth_dev_set_link_up_t dev_set_link_up; /**< Device link up. */ 837 eth_dev_set_link_down_t dev_set_link_down; /**< Device link down. */ 838 eth_dev_close_t dev_close; /**< Close device. */ 839 eth_dev_reset_t dev_reset; /**< Reset device. */ 840 eth_link_update_t link_update; /**< Get device link state. */ 841 eth_is_removed_t is_removed; 842 /**< Check if the device was physically removed. */ 843 844 eth_promiscuous_enable_t promiscuous_enable; /**< Promiscuous ON. */ 845 eth_promiscuous_disable_t promiscuous_disable;/**< Promiscuous OFF. */ 846 eth_allmulticast_enable_t allmulticast_enable;/**< RX multicast ON. */ 847 eth_allmulticast_disable_t allmulticast_disable;/**< RX multicast OFF. */ 848 eth_mac_addr_remove_t mac_addr_remove; /**< Remove MAC address. */ 849 eth_mac_addr_add_t mac_addr_add; /**< Add a MAC address. */ 850 eth_mac_addr_set_t mac_addr_set; /**< Set a MAC address. */ 851 eth_set_mc_addr_list_t set_mc_addr_list; /**< set list of mcast addrs. */ 852 mtu_set_t mtu_set; /**< Set MTU. */ 853 854 eth_stats_get_t stats_get; /**< Get generic device statistics. */ 855 eth_stats_reset_t stats_reset; /**< Reset generic device statistics. */ 856 eth_xstats_get_t xstats_get; /**< Get extended device statistics. */ 857 eth_xstats_reset_t xstats_reset; /**< Reset extended device statistics. */ 858 eth_xstats_get_names_t xstats_get_names; 859 /**< Get names of extended statistics. */ 860 eth_queue_stats_mapping_set_t queue_stats_mapping_set; 861 /**< Configure per queue stat counter mapping. */ 862 863 eth_dev_infos_get_t dev_infos_get; /**< Get device info. */ 864 eth_rxq_info_get_t rxq_info_get; /**< retrieve RX queue information. */ 865 eth_txq_info_get_t txq_info_get; /**< retrieve TX queue information. */ 866 eth_burst_mode_get_t rx_burst_mode_get; /**< Get RX burst mode */ 867 eth_burst_mode_get_t tx_burst_mode_get; /**< Get TX burst mode */ 868 eth_fw_version_get_t fw_version_get; /**< Get firmware version. */ 869 eth_dev_supported_ptypes_get_t dev_supported_ptypes_get; 870 /**< Get packet types supported and identified by device. */ 871 eth_dev_ptypes_set_t dev_ptypes_set; 872 /**< Inform Ethernet device about reduced range of packet types to handle. */ 873 874 vlan_filter_set_t vlan_filter_set; /**< Filter VLAN Setup. */ 875 vlan_tpid_set_t vlan_tpid_set; /**< Outer/Inner VLAN TPID Setup. */ 876 vlan_strip_queue_set_t vlan_strip_queue_set; /**< VLAN Stripping on queue. */ 877 vlan_offload_set_t vlan_offload_set; /**< Set VLAN Offload. */ 878 vlan_pvid_set_t vlan_pvid_set; /**< Set port based TX VLAN insertion. */ 879 880 eth_queue_start_t rx_queue_start;/**< Start RX for a queue. */ 881 eth_queue_stop_t rx_queue_stop; /**< Stop RX for a queue. */ 882 eth_queue_start_t tx_queue_start;/**< Start TX for a queue. */ 883 eth_queue_stop_t tx_queue_stop; /**< Stop TX for a queue. */ 884 eth_rx_queue_setup_t rx_queue_setup;/**< Set up device RX queue. */ 885 eth_queue_release_t rx_queue_release; /**< Release RX queue. */ 886 887 eth_rx_enable_intr_t rx_queue_intr_enable; /**< Enable Rx queue interrupt. */ 888 eth_rx_disable_intr_t rx_queue_intr_disable; /**< Disable Rx queue interrupt. */ 889 eth_tx_queue_setup_t tx_queue_setup;/**< Set up device TX queue. */ 890 eth_queue_release_t tx_queue_release; /**< Release TX queue. */ 891 eth_tx_done_cleanup_t tx_done_cleanup;/**< Free tx ring mbufs */ 892 893 eth_dev_led_on_t dev_led_on; /**< Turn on LED. */ 894 eth_dev_led_off_t dev_led_off; /**< Turn off LED. */ 895 896 flow_ctrl_get_t flow_ctrl_get; /**< Get flow control. */ 897 flow_ctrl_set_t flow_ctrl_set; /**< Setup flow control. */ 898 priority_flow_ctrl_set_t priority_flow_ctrl_set; /**< Setup priority flow control. */ 899 900 eth_uc_hash_table_set_t uc_hash_table_set; /**< Set Unicast Table Array. */ 901 eth_uc_all_hash_table_set_t uc_all_hash_table_set; /**< Set Unicast hash bitmap. */ 902 903 eth_udp_tunnel_port_add_t udp_tunnel_port_add; /** Add UDP tunnel port. */ 904 eth_udp_tunnel_port_del_t udp_tunnel_port_del; /** Del UDP tunnel port. */ 905 906 eth_set_queue_rate_limit_t set_queue_rate_limit; /**< Set queue rate limit. */ 907 908 rss_hash_update_t rss_hash_update; /** Configure RSS hash protocols. */ 909 rss_hash_conf_get_t rss_hash_conf_get; /** Get current RSS hash configuration. */ 910 reta_update_t reta_update; /** Update redirection table. */ 911 reta_query_t reta_query; /** Query redirection table. */ 912 913 eth_get_reg_t get_reg; /**< Get registers. */ 914 eth_get_eeprom_length_t get_eeprom_length; /**< Get eeprom length. */ 915 eth_get_eeprom_t get_eeprom; /**< Get eeprom data. */ 916 eth_set_eeprom_t set_eeprom; /**< Set eeprom. */ 917 918 eth_get_module_info_t get_module_info; 919 /** Get plugin module eeprom attribute. */ 920 eth_get_module_eeprom_t get_module_eeprom; 921 /** Get plugin module eeprom data. */ 922 923 eth_flow_ops_get_t flow_ops_get; /**< Get flow operations. */ 924 925 eth_get_dcb_info get_dcb_info; /** Get DCB information. */ 926 927 eth_timesync_enable_t timesync_enable; 928 /** Turn IEEE1588/802.1AS timestamping on. */ 929 eth_timesync_disable_t timesync_disable; 930 /** Turn IEEE1588/802.1AS timestamping off. */ 931 eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp; 932 /** Read the IEEE1588/802.1AS RX timestamp. */ 933 eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp; 934 /** Read the IEEE1588/802.1AS TX timestamp. */ 935 eth_timesync_adjust_time timesync_adjust_time; /** Adjust the device clock. */ 936 eth_timesync_read_time timesync_read_time; /** Get the device clock time. */ 937 eth_timesync_write_time timesync_write_time; /** Set the device clock time. */ 938 939 eth_read_clock read_clock; 940 941 eth_xstats_get_by_id_t xstats_get_by_id; 942 /**< Get extended device statistic values by ID. */ 943 eth_xstats_get_names_by_id_t xstats_get_names_by_id; 944 /**< Get name of extended device statistics by ID. */ 945 946 eth_tm_ops_get_t tm_ops_get; 947 /**< Get Traffic Management (TM) operations. */ 948 949 eth_mtr_ops_get_t mtr_ops_get; 950 /**< Get Traffic Metering and Policing (MTR) operations. */ 951 952 eth_pool_ops_supported_t pool_ops_supported; 953 /**< Test if a port supports specific mempool ops */ 954 955 eth_hairpin_cap_get_t hairpin_cap_get; 956 /**< Returns the hairpin capabilities. */ 957 eth_rx_hairpin_queue_setup_t rx_hairpin_queue_setup; 958 /**< Set up device RX hairpin queue. */ 959 eth_tx_hairpin_queue_setup_t tx_hairpin_queue_setup; 960 /**< Set up device TX hairpin queue. */ 961 962 eth_fec_get_capability_t fec_get_capability; 963 /**< Get Forward Error Correction(FEC) capability. */ 964 eth_fec_get_t fec_get; 965 /**< Get Forward Error Correction(FEC) mode. */ 966 eth_fec_set_t fec_set; 967 /**< Set Forward Error Correction(FEC) mode. */ 968 hairpin_get_peer_ports_t hairpin_get_peer_ports; 969 /**< Get hairpin peer ports list. */ 970 eth_hairpin_bind_t hairpin_bind; 971 /**< Bind all hairpin Tx queues of device to the peer port Rx queues. */ 972 eth_hairpin_unbind_t hairpin_unbind; 973 /**< Unbind all hairpin Tx queues from the peer port Rx queues. */ 974 eth_hairpin_queue_peer_update_t hairpin_queue_peer_update; 975 /**< Pass the current queue info and get the peer queue info. */ 976 eth_hairpin_queue_peer_bind_t hairpin_queue_peer_bind; 977 /**< Set up the connection between the pair of hairpin queues. */ 978 eth_hairpin_queue_peer_unbind_t hairpin_queue_peer_unbind; 979 /**< Disconnect the hairpin queues of a pair from each other. */ 980 981 eth_get_monitor_addr_t get_monitor_addr; 982 /**< Get power monitoring condition for Rx queue. */ 983 984 eth_representor_info_get_t representor_info_get; 985 /**< Get representor info. */ 986 987 /** 988 * Negotiate the NIC's ability to deliver specific 989 * kinds of metadata to the PMD. 990 */ 991 eth_rx_metadata_negotiate_t rx_metadata_negotiate; 992 }; 993 994 /** 995 * @internal 996 * Check if the selected Rx queue is hairpin queue. 997 * 998 * @param dev 999 * Pointer to the selected device. 1000 * @param queue_id 1001 * The selected queue. 1002 * 1003 * @return 1004 * - (1) if the queue is hairpin queue, 0 otherwise. 1005 */ 1006 __rte_internal 1007 int rte_eth_dev_is_rx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id); 1008 1009 /** 1010 * @internal 1011 * Check if the selected Tx queue is hairpin queue. 1012 * 1013 * @param dev 1014 * Pointer to the selected device. 1015 * @param queue_id 1016 * The selected queue. 1017 * 1018 * @return 1019 * - (1) if the queue is hairpin queue, 0 otherwise. 1020 */ 1021 __rte_internal 1022 int rte_eth_dev_is_tx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id); 1023 1024 /** 1025 * @internal 1026 * Returns a ethdev slot specified by the unique identifier name. 1027 * 1028 * @param name 1029 * The pointer to the Unique identifier name for each Ethernet device 1030 * @return 1031 * - The pointer to the ethdev slot, on success. NULL on error 1032 */ 1033 __rte_internal 1034 struct rte_eth_dev *rte_eth_dev_allocated(const char *name); 1035 1036 /** 1037 * @internal 1038 * Allocates a new ethdev slot for an ethernet device and returns the pointer 1039 * to that slot for the driver to use. 1040 * 1041 * @param name Unique identifier name for each Ethernet device 1042 * @return 1043 * - Slot in the rte_dev_devices array for a new device; 1044 */ 1045 __rte_internal 1046 struct rte_eth_dev *rte_eth_dev_allocate(const char *name); 1047 1048 /** 1049 * @internal 1050 * Attach to the ethdev already initialized by the primary 1051 * process. 1052 * 1053 * @param name Ethernet device's name. 1054 * @return 1055 * - Success: Slot in the rte_dev_devices array for attached 1056 * device. 1057 * - Error: Null pointer. 1058 */ 1059 __rte_internal 1060 struct rte_eth_dev *rte_eth_dev_attach_secondary(const char *name); 1061 1062 /** 1063 * @internal 1064 * Notify RTE_ETH_EVENT_DESTROY and release the specified ethdev port. 1065 * 1066 * The following PMD-managed data fields will be freed: 1067 * - dev_private 1068 * - mac_addrs 1069 * - hash_mac_addrs 1070 * If one of these fields should not be freed, 1071 * it must be reset to NULL by the PMD, typically in dev_close method. 1072 * 1073 * @param eth_dev 1074 * Device to be detached. 1075 * @return 1076 * - 0 on success, negative on error 1077 */ 1078 __rte_internal 1079 int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev); 1080 1081 /** 1082 * @internal 1083 * Release device queues and clear its configuration to force the user 1084 * application to reconfigure it. It is for internal use only. 1085 * 1086 * @param dev 1087 * Pointer to struct rte_eth_dev. 1088 * 1089 * @return 1090 * void 1091 */ 1092 __rte_internal 1093 void rte_eth_dev_internal_reset(struct rte_eth_dev *dev); 1094 1095 /** 1096 * @internal Executes all the user application registered callbacks for 1097 * the specific device. It is for DPDK internal user only. User 1098 * application should not call it directly. 1099 * 1100 * @param dev 1101 * Pointer to struct rte_eth_dev. 1102 * @param event 1103 * Eth device interrupt event type. 1104 * @param ret_param 1105 * To pass data back to user application. 1106 * This allows the user application to decide if a particular function 1107 * is permitted or not. 1108 * 1109 * @return 1110 * int 1111 */ 1112 __rte_internal 1113 int rte_eth_dev_callback_process(struct rte_eth_dev *dev, 1114 enum rte_eth_event_type event, void *ret_param); 1115 1116 /** 1117 * @internal 1118 * This is the last step of device probing. 1119 * It must be called after a port is allocated and initialized successfully. 1120 * 1121 * The notification RTE_ETH_EVENT_NEW is sent to other entities 1122 * (libraries and applications). 1123 * The state is set as RTE_ETH_DEV_ATTACHED. 1124 * 1125 * @param dev 1126 * New ethdev port. 1127 */ 1128 __rte_internal 1129 void rte_eth_dev_probing_finish(struct rte_eth_dev *dev); 1130 1131 /** 1132 * Create memzone for HW rings. 1133 * malloc can't be used as the physical address is needed. 1134 * If the memzone is already created, then this function returns a ptr 1135 * to the old one. 1136 * 1137 * @param eth_dev 1138 * The *eth_dev* pointer is the address of the *rte_eth_dev* structure 1139 * @param name 1140 * The name of the memory zone 1141 * @param queue_id 1142 * The index of the queue to add to name 1143 * @param size 1144 * The sizeof of the memory area 1145 * @param align 1146 * Alignment for resulting memzone. Must be a power of 2. 1147 * @param socket_id 1148 * The *socket_id* argument is the socket identifier in case of NUMA. 1149 */ 1150 __rte_internal 1151 const struct rte_memzone * 1152 rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name, 1153 uint16_t queue_id, size_t size, 1154 unsigned align, int socket_id); 1155 1156 /** 1157 * Free previously allocated memzone for HW rings. 1158 * 1159 * @param eth_dev 1160 * The *eth_dev* pointer is the address of the *rte_eth_dev* structure 1161 * @param name 1162 * The name of the memory zone 1163 * @param queue_id 1164 * The index of the queue to add to name 1165 * @return 1166 * Negative errno value on error, 0 on success. 1167 */ 1168 __rte_internal 1169 int 1170 rte_eth_dma_zone_free(const struct rte_eth_dev *eth_dev, const char *name, 1171 uint16_t queue_id); 1172 1173 /** 1174 * @internal 1175 * Atomically set the link status for the specific device. 1176 * It is for use by DPDK device driver use only. 1177 * User applications should not call it 1178 * 1179 * @param dev 1180 * Pointer to struct rte_eth_dev. 1181 * @param link 1182 * New link status value. 1183 * @return 1184 * Same convention as eth_link_update operation. 1185 * 0 if link up status has changed 1186 * -1 if link up status was unchanged 1187 */ 1188 static inline int 1189 rte_eth_linkstatus_set(struct rte_eth_dev *dev, 1190 const struct rte_eth_link *new_link) 1191 { 1192 uint64_t *dev_link = (uint64_t *)&(dev->data->dev_link); 1193 union { 1194 uint64_t val64; 1195 struct rte_eth_link link; 1196 } orig; 1197 1198 RTE_BUILD_BUG_ON(sizeof(*new_link) != sizeof(uint64_t)); 1199 1200 orig.val64 = __atomic_exchange_n(dev_link, *(const uint64_t *)new_link, 1201 __ATOMIC_SEQ_CST); 1202 1203 return (orig.link.link_status == new_link->link_status) ? -1 : 0; 1204 } 1205 1206 /** 1207 * @internal 1208 * Atomically get the link speed and status. 1209 * 1210 * @param dev 1211 * Pointer to struct rte_eth_dev. 1212 * @param link 1213 * link status value. 1214 */ 1215 static inline void 1216 rte_eth_linkstatus_get(const struct rte_eth_dev *dev, 1217 struct rte_eth_link *link) 1218 { 1219 uint64_t *src = (uint64_t *)&(dev->data->dev_link); 1220 uint64_t *dst = (uint64_t *)link; 1221 1222 RTE_BUILD_BUG_ON(sizeof(*link) != sizeof(uint64_t)); 1223 1224 *dst = __atomic_load_n(src, __ATOMIC_SEQ_CST); 1225 } 1226 1227 /** 1228 * Allocate an unique switch domain identifier. 1229 * 1230 * A pool of switch domain identifiers which can be allocated on request. This 1231 * will enabled devices which support the concept of switch domains to request 1232 * a switch domain id which is guaranteed to be unique from other devices 1233 * running in the same process. 1234 * 1235 * @param domain_id 1236 * switch domain identifier parameter to pass back to application 1237 * 1238 * @return 1239 * Negative errno value on error, 0 on success. 1240 */ 1241 __rte_internal 1242 int 1243 rte_eth_switch_domain_alloc(uint16_t *domain_id); 1244 1245 /** 1246 * Free switch domain. 1247 * 1248 * Return a switch domain identifier to the pool of free identifiers after it is 1249 * no longer in use by device. 1250 * 1251 * @param domain_id 1252 * switch domain identifier to free 1253 * 1254 * @return 1255 * Negative errno value on error, 0 on success. 1256 */ 1257 __rte_internal 1258 int 1259 rte_eth_switch_domain_free(uint16_t domain_id); 1260 1261 /** 1262 * Generic Ethernet device arguments 1263 * 1264 * One type of representor each structure. 1265 */ 1266 struct rte_eth_devargs { 1267 uint16_t mh_controllers[RTE_MAX_MULTI_HOST_CTRLS]; 1268 /** controller/s number in case of multi-host */ 1269 uint16_t nb_mh_controllers; 1270 /** number of controllers in multi-host controllers field */ 1271 uint16_t ports[RTE_MAX_ETHPORTS]; 1272 /** port/s number to enable on a multi-port single function */ 1273 uint16_t nb_ports; 1274 /** number of ports in ports field */ 1275 uint16_t representor_ports[RTE_MAX_ETHPORTS]; 1276 /** representor port/s identifier to enable on device */ 1277 uint16_t nb_representor_ports; 1278 /** number of ports in representor port field */ 1279 enum rte_eth_representor_type type; /* type of representor */ 1280 }; 1281 1282 /** 1283 * PMD helper function to get representor ID from location detail. 1284 * 1285 * Get representor ID from controller, pf and (sf or vf). 1286 * The mapping is retrieved from rte_eth_representor_info_get(). 1287 * 1288 * For backward compatibility, if no representor info, direct 1289 * map legacy VF (no controller and pf). 1290 * 1291 * @param port_id 1292 * Port ID of the backing device. 1293 * @param type 1294 * Representor type. 1295 * @param controller 1296 * Controller ID, -1 if unspecified. 1297 * @param pf 1298 * PF port ID, -1 if unspecified. 1299 * @param representor_port 1300 * VF or SF representor port number, -1 if unspecified. 1301 * @param repr_id 1302 * Pointer to output representor ID. 1303 * 1304 * @return 1305 * Negative errno value on error, 0 on success. 1306 */ 1307 __rte_internal 1308 int 1309 rte_eth_representor_id_get(uint16_t port_id, 1310 enum rte_eth_representor_type type, 1311 int controller, int pf, int representor_port, 1312 uint16_t *repr_id); 1313 1314 /** 1315 * PMD helper function to parse ethdev arguments 1316 * 1317 * @param devargs 1318 * device arguments 1319 * @param eth_devargs 1320 * parsed ethdev specific arguments. 1321 * 1322 * @return 1323 * Negative errno value on error, 0 on success. 1324 */ 1325 __rte_internal 1326 int 1327 rte_eth_devargs_parse(const char *devargs, struct rte_eth_devargs *eth_devargs); 1328 1329 1330 typedef int (*ethdev_init_t)(struct rte_eth_dev *ethdev, void *init_params); 1331 typedef int (*ethdev_bus_specific_init)(struct rte_eth_dev *ethdev, 1332 void *bus_specific_init_params); 1333 1334 /** 1335 * PMD helper function for the creation of a new ethdev ports. 1336 * 1337 * @param device 1338 * rte_device handle. 1339 * @param name 1340 * port name. 1341 * @param priv_data_size 1342 * size of private data required for port. 1343 * @param bus_specific_init 1344 * port bus specific initialisation callback function 1345 * @param bus_init_params 1346 * port bus specific initialisation parameters 1347 * @param ethdev_init 1348 * device specific port initialization callback function 1349 * @param init_params 1350 * port initialisation parameters 1351 * 1352 * @return 1353 * Negative errno value on error, 0 on success. 1354 */ 1355 __rte_internal 1356 int 1357 rte_eth_dev_create(struct rte_device *device, const char *name, 1358 size_t priv_data_size, 1359 ethdev_bus_specific_init bus_specific_init, void *bus_init_params, 1360 ethdev_init_t ethdev_init, void *init_params); 1361 1362 1363 typedef int (*ethdev_uninit_t)(struct rte_eth_dev *ethdev); 1364 1365 /** 1366 * PMD helper function for cleaning up the resources of a ethdev port on it's 1367 * destruction. 1368 * 1369 * @param ethdev 1370 * ethdev handle of port. 1371 * @param ethdev_uninit 1372 * device specific port un-initialise callback function 1373 * 1374 * @return 1375 * Negative errno value on error, 0 on success. 1376 */ 1377 __rte_internal 1378 int 1379 rte_eth_dev_destroy(struct rte_eth_dev *ethdev, ethdev_uninit_t ethdev_uninit); 1380 1381 /** 1382 * @internal 1383 * Pass the current hairpin queue HW and/or SW information to the peer queue 1384 * and fetch back the information of the peer queue. 1385 * 1386 * @param peer_port 1387 * Peer port identifier of the Ethernet device. 1388 * @param peer_queue 1389 * Peer queue index of the port. 1390 * @param cur_info 1391 * Pointer to the current information structure. 1392 * @param peer_info 1393 * Pointer to the peer information, output. 1394 * @param direction 1395 * Direction to pass the information. 1396 * positive - pass Tx queue information and get peer Rx queue information 1397 * zero - pass Rx queue information and get peer Tx queue information 1398 * 1399 * @return 1400 * Negative errno value on error, 0 on success. 1401 */ 1402 __rte_internal 1403 int 1404 rte_eth_hairpin_queue_peer_update(uint16_t peer_port, uint16_t peer_queue, 1405 struct rte_hairpin_peer_info *cur_info, 1406 struct rte_hairpin_peer_info *peer_info, 1407 uint32_t direction); 1408 1409 /** 1410 * @internal 1411 * Configure current hairpin queue with the peer information fetched to create 1412 * the connection (bind) with peer queue in the specified direction. 1413 * This function might need to be called twice to fully create the connections. 1414 * 1415 * @param cur_port 1416 * Current port identifier of the Ethernet device. 1417 * @param cur_queue 1418 * Current queue index of the port. 1419 * @param peer_info 1420 * Pointer to the peer information, input. 1421 * @param direction 1422 * Direction to create the connection. 1423 * positive - bind current Tx queue to peer Rx queue 1424 * zero - bind current Rx queue to peer Tx queue 1425 * 1426 * @return 1427 * Negative errno value on error, 0 on success. 1428 */ 1429 __rte_internal 1430 int 1431 rte_eth_hairpin_queue_peer_bind(uint16_t cur_port, uint16_t cur_queue, 1432 struct rte_hairpin_peer_info *peer_info, 1433 uint32_t direction); 1434 1435 /** 1436 * @internal 1437 * Reset the current queue state and configuration to disconnect (unbind) it 1438 * from the peer queue. 1439 * This function might need to be called twice to disconnect each other. 1440 * 1441 * @param cur_port 1442 * Current port identifier of the Ethernet device. 1443 * @param cur_queue 1444 * Current queue index of the port. 1445 * @param direction 1446 * Direction to destroy the connection. 1447 * positive - unbind current Tx queue from peer Rx queue 1448 * zero - unbind current Rx queue from peer Tx queue 1449 * 1450 * @return 1451 * Negative errno value on error, 0 on success. 1452 */ 1453 __rte_internal 1454 int 1455 rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t cur_queue, 1456 uint32_t direction); 1457 1458 1459 /* 1460 * Legacy ethdev API used internally by drivers. 1461 */ 1462 1463 enum rte_filter_type { 1464 RTE_ETH_FILTER_NONE = 0, 1465 RTE_ETH_FILTER_ETHERTYPE, 1466 RTE_ETH_FILTER_FLEXIBLE, 1467 RTE_ETH_FILTER_SYN, 1468 RTE_ETH_FILTER_NTUPLE, 1469 RTE_ETH_FILTER_TUNNEL, 1470 RTE_ETH_FILTER_FDIR, 1471 RTE_ETH_FILTER_HASH, 1472 RTE_ETH_FILTER_L2_TUNNEL, 1473 }; 1474 1475 /** 1476 * Define all structures for Ethertype Filter type. 1477 */ 1478 1479 #define RTE_ETHTYPE_FLAGS_MAC 0x0001 /**< If set, compare mac */ 1480 #define RTE_ETHTYPE_FLAGS_DROP 0x0002 /**< If set, drop packet when match */ 1481 1482 /** 1483 * A structure used to define the ethertype filter entry 1484 * to support RTE_ETH_FILTER_ETHERTYPE data representation. 1485 */ 1486 struct rte_eth_ethertype_filter { 1487 struct rte_ether_addr mac_addr; /**< Mac address to match. */ 1488 uint16_t ether_type; /**< Ether type to match */ 1489 uint16_t flags; /**< Flags from RTE_ETHTYPE_FLAGS_* */ 1490 uint16_t queue; /**< Queue assigned to when match*/ 1491 }; 1492 1493 /** 1494 * A structure used to define the TCP syn filter entry 1495 * to support RTE_ETH_FILTER_SYN data representation. 1496 */ 1497 struct rte_eth_syn_filter { 1498 /** 1 - higher priority than other filters, 0 - lower priority. */ 1499 uint8_t hig_pri; 1500 uint16_t queue; /**< Queue assigned to when match */ 1501 }; 1502 1503 /** 1504 * filter type of tunneling packet 1505 */ 1506 #define ETH_TUNNEL_FILTER_OMAC 0x01 /**< filter by outer MAC addr */ 1507 #define ETH_TUNNEL_FILTER_OIP 0x02 /**< filter by outer IP Addr */ 1508 #define ETH_TUNNEL_FILTER_TENID 0x04 /**< filter by tenant ID */ 1509 #define ETH_TUNNEL_FILTER_IMAC 0x08 /**< filter by inner MAC addr */ 1510 #define ETH_TUNNEL_FILTER_IVLAN 0x10 /**< filter by inner VLAN ID */ 1511 #define ETH_TUNNEL_FILTER_IIP 0x20 /**< filter by inner IP addr */ 1512 1513 #define RTE_TUNNEL_FILTER_IMAC_IVLAN (ETH_TUNNEL_FILTER_IMAC | \ 1514 ETH_TUNNEL_FILTER_IVLAN) 1515 #define RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID (ETH_TUNNEL_FILTER_IMAC | \ 1516 ETH_TUNNEL_FILTER_IVLAN | \ 1517 ETH_TUNNEL_FILTER_TENID) 1518 #define RTE_TUNNEL_FILTER_IMAC_TENID (ETH_TUNNEL_FILTER_IMAC | \ 1519 ETH_TUNNEL_FILTER_TENID) 1520 #define RTE_TUNNEL_FILTER_OMAC_TENID_IMAC (ETH_TUNNEL_FILTER_OMAC | \ 1521 ETH_TUNNEL_FILTER_TENID | \ 1522 ETH_TUNNEL_FILTER_IMAC) 1523 1524 /** 1525 * Select IPv4 or IPv6 for tunnel filters. 1526 */ 1527 enum rte_tunnel_iptype { 1528 RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4. */ 1529 RTE_TUNNEL_IPTYPE_IPV6, /**< IPv6. */ 1530 }; 1531 1532 /** 1533 * Tunneling Packet filter configuration. 1534 */ 1535 struct rte_eth_tunnel_filter_conf { 1536 struct rte_ether_addr outer_mac; /**< Outer MAC address to match. */ 1537 struct rte_ether_addr inner_mac; /**< Inner MAC address to match. */ 1538 uint16_t inner_vlan; /**< Inner VLAN to match. */ 1539 enum rte_tunnel_iptype ip_type; /**< IP address type. */ 1540 /** 1541 * Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP 1542 * is set in filter_type, or inner destination IP address to match 1543 * if ETH_TUNNEL_FILTER_IIP is set in filter_type. 1544 */ 1545 union { 1546 uint32_t ipv4_addr; /**< IPv4 address in big endian. */ 1547 uint32_t ipv6_addr[4]; /**< IPv6 address in big endian. */ 1548 } ip_addr; 1549 /** Flags from ETH_TUNNEL_FILTER_XX - see above. */ 1550 uint16_t filter_type; 1551 enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */ 1552 uint32_t tenant_id; /**< Tenant ID to match. VNI, GRE key... */ 1553 uint16_t queue_id; /**< Queue assigned to if match. */ 1554 }; 1555 1556 #endif /* _RTE_ETHDEV_DRIVER_H_ */ 1557