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