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