1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Intel Corporation
5 #ifndef _RTE_ETHDEV_DRIVER_H_
6 #define _RTE_ETHDEV_DRIVER_H_
11 * RTE Ethernet Device PMD API
13 * These APIs for the use from Ethernet drivers, user applications shouldn't
18 #include <rte_ethdev.h>
25 * Definitions of all functions exported by an Ethernet driver through the
26 * generic structure of type *eth_dev_ops* supplied in the *rte_eth_dev*
27 * structure associated with an Ethernet device.
30 typedef int (*eth_dev_configure_t)(struct rte_eth_dev *dev);
31 /**< @internal Ethernet device configuration. */
33 typedef int (*eth_dev_start_t)(struct rte_eth_dev *dev);
34 /**< @internal Function used to start a configured Ethernet device. */
36 typedef void (*eth_dev_stop_t)(struct rte_eth_dev *dev);
37 /**< @internal Function used to stop a configured Ethernet device. */
39 typedef int (*eth_dev_set_link_up_t)(struct rte_eth_dev *dev);
40 /**< @internal Function used to link up a configured Ethernet device. */
42 typedef int (*eth_dev_set_link_down_t)(struct rte_eth_dev *dev);
43 /**< @internal Function used to link down a configured Ethernet device. */
45 typedef int (*eth_dev_close_t)(struct rte_eth_dev *dev);
46 /**< @internal Function used to close a configured Ethernet device. */
48 typedef int (*eth_dev_reset_t)(struct rte_eth_dev *dev);
49 /** <@internal Function used to reset a configured Ethernet device. */
51 typedef int (*eth_is_removed_t)(struct rte_eth_dev *dev);
52 /**< @internal Function used to detect an Ethernet device removal. */
56 * Function used to enable the Rx promiscuous mode of an Ethernet device.
59 * ethdev handle of port.
62 * Negative errno value on error, 0 on success.
65 * Success, promiscuous mode is enabled.
67 * Promiscuous mode is not supported.
70 * @retval -E_RTE_SECONDARY
71 * Function was called from a secondary process instance and not supported.
73 * Attempt to enable promiscuos mode failed because of timeout.
75 * Failed to enable promiscuous mode.
77 typedef int (*eth_promiscuous_enable_t)(struct rte_eth_dev *dev);
81 * Function used to disable the Rx promiscuous mode of an Ethernet device.
84 * ethdev handle of port.
87 * Negative errno value on error, 0 on success.
90 * Success, promiscuous mode is disabled.
92 * Promiscuous mode disabling is not supported.
95 * @retval -E_RTE_SECONDARY
96 * Function was called from a secondary process instance and not supported.
98 * Attempt to disable promiscuos mode failed because of timeout.
100 * Failed to disable promiscuous mode.
102 typedef int (*eth_promiscuous_disable_t)(struct rte_eth_dev *dev);
106 * Enable the receipt of all multicast packets by an Ethernet device.
109 * ethdev handle of port.
112 * Negative errno value on error, 0 on success.
115 * Success, all-multicast mode is enabled.
117 * All-multicast mode is not supported.
120 * @retval -E_RTE_SECONDARY
121 * Function was called from a secondary process instance and not supported.
123 * Attempt to enable all-multicast mode failed because of timeout.
125 * Failed to enable all-multicast mode.
127 typedef int (*eth_allmulticast_enable_t)(struct rte_eth_dev *dev);
131 * Disable the receipt of all multicast packets by an Ethernet device.
134 * ethdev handle of port.
137 * Negative errno value on error, 0 on success.
140 * Success, all-multicast mode is disabled.
142 * All-multicast mode disabling is not supported.
145 * @retval -E_RTE_SECONDARY
146 * Function was called from a secondary process instance and not supported.
148 * Attempt to disable all-multicast mode failed because of timeout.
150 * Failed to disable all-multicast mode.
152 typedef int (*eth_allmulticast_disable_t)(struct rte_eth_dev *dev);
154 typedef int (*eth_link_update_t)(struct rte_eth_dev *dev,
155 int wait_to_complete);
156 /**< @internal Get link speed, duplex mode and state (up/down) of an Ethernet device. */
158 typedef int (*eth_stats_get_t)(struct rte_eth_dev *dev,
159 struct rte_eth_stats *igb_stats);
160 /**< @internal Get global I/O statistics of an Ethernet device. */
164 * Reset global I/O statistics of an Ethernet device to 0.
167 * ethdev handle of port.
170 * Negative errno value on error, 0 on success.
173 * Success, statistics has been reset.
175 * Resetting statistics is not supported.
177 * Resetting statistics is not valid.
179 * Not enough memory to get the stats.
181 typedef int (*eth_stats_reset_t)(struct rte_eth_dev *dev);
183 typedef int (*eth_xstats_get_t)(struct rte_eth_dev *dev,
184 struct rte_eth_xstat *stats, unsigned int n);
185 /**< @internal Get extended stats of an Ethernet device. */
187 typedef int (*eth_xstats_get_by_id_t)(struct rte_eth_dev *dev,
191 /**< @internal Get extended stats of an Ethernet device. */
195 * Reset extended stats of an Ethernet device.
198 * ethdev handle of port.
201 * Negative errno value on error, 0 on success.
204 * Success, statistics has been reset.
206 * Resetting statistics is not supported.
208 * Resetting statistics is not valid.
210 * Not enough memory to get the stats.
212 typedef int (*eth_xstats_reset_t)(struct rte_eth_dev *dev);
214 typedef int (*eth_xstats_get_names_t)(struct rte_eth_dev *dev,
215 struct rte_eth_xstat_name *xstats_names, unsigned int size);
216 /**< @internal Get names of extended stats of an Ethernet device. */
218 typedef int (*eth_xstats_get_names_by_id_t)(struct rte_eth_dev *dev,
219 struct rte_eth_xstat_name *xstats_names, const uint64_t *ids,
221 /**< @internal Get names of extended stats of an Ethernet device. */
223 typedef int (*eth_queue_stats_mapping_set_t)(struct rte_eth_dev *dev,
227 /**< @internal Set a queue statistics mapping for a tx/rx queue of an Ethernet device. */
229 typedef int (*eth_dev_infos_get_t)(struct rte_eth_dev *dev,
230 struct rte_eth_dev_info *dev_info);
231 /**< @internal Get specific information of an Ethernet device. */
233 typedef const uint32_t *(*eth_dev_supported_ptypes_get_t)(struct rte_eth_dev *dev);
234 /**< @internal Get supported ptypes of an Ethernet device. */
238 * Inform Ethernet device about reduced range of packet types to handle.
241 * The Ethernet device identifier.
243 * The ptype family that application is interested in should be bitwise OR of
244 * RTE_PTYPE_*_MASK or 0.
248 typedef int (*eth_dev_ptypes_set_t)(struct rte_eth_dev *dev,
249 uint32_t ptype_mask);
251 typedef int (*eth_queue_start_t)(struct rte_eth_dev *dev,
253 /**< @internal Start rx and tx of a queue of an Ethernet device. */
255 typedef int (*eth_queue_stop_t)(struct rte_eth_dev *dev,
257 /**< @internal Stop rx and tx of a queue of an Ethernet device. */
259 typedef int (*eth_rx_queue_setup_t)(struct rte_eth_dev *dev,
260 uint16_t rx_queue_id,
262 unsigned int socket_id,
263 const struct rte_eth_rxconf *rx_conf,
264 struct rte_mempool *mb_pool);
265 /**< @internal Set up a receive queue of an Ethernet device. */
267 typedef int (*eth_tx_queue_setup_t)(struct rte_eth_dev *dev,
268 uint16_t tx_queue_id,
270 unsigned int socket_id,
271 const struct rte_eth_txconf *tx_conf);
272 /**< @internal Setup a transmit queue of an Ethernet device. */
274 typedef int (*eth_rx_enable_intr_t)(struct rte_eth_dev *dev,
275 uint16_t rx_queue_id);
276 /**< @internal Enable interrupt of a receive queue of an Ethernet device. */
278 typedef int (*eth_rx_disable_intr_t)(struct rte_eth_dev *dev,
279 uint16_t rx_queue_id);
280 /**< @internal Disable interrupt of a receive queue of an Ethernet device. */
282 typedef void (*eth_queue_release_t)(void *queue);
283 /**< @internal Release memory resources allocated by given RX/TX queue. */
285 typedef int (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
286 char *fw_version, size_t fw_size);
287 /**< @internal Get firmware information of an Ethernet device. */
289 typedef int (*eth_tx_done_cleanup_t)(void *txq, uint32_t free_cnt);
290 /**< @internal Force mbufs to be from TX ring. */
292 typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
293 uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
295 typedef void (*eth_txq_info_get_t)(struct rte_eth_dev *dev,
296 uint16_t tx_queue_id, struct rte_eth_txq_info *qinfo);
298 typedef int (*eth_burst_mode_get_t)(struct rte_eth_dev *dev,
299 uint16_t queue_id, struct rte_eth_burst_mode *mode);
301 typedef int (*mtu_set_t)(struct rte_eth_dev *dev, uint16_t mtu);
302 /**< @internal Set MTU. */
304 typedef int (*vlan_filter_set_t)(struct rte_eth_dev *dev,
307 /**< @internal filtering of a VLAN Tag Identifier by an Ethernet device. */
309 typedef int (*vlan_tpid_set_t)(struct rte_eth_dev *dev,
310 enum rte_vlan_type type, uint16_t tpid);
311 /**< @internal set the outer/inner VLAN-TPID by an Ethernet device. */
313 typedef int (*vlan_offload_set_t)(struct rte_eth_dev *dev, int mask);
314 /**< @internal set VLAN offload function by an Ethernet device. */
316 typedef int (*vlan_pvid_set_t)(struct rte_eth_dev *dev,
319 /**< @internal set port based TX VLAN insertion by an Ethernet device. */
321 typedef void (*vlan_strip_queue_set_t)(struct rte_eth_dev *dev,
322 uint16_t rx_queue_id,
324 /**< @internal VLAN stripping enable/disable by an queue of Ethernet device. */
326 typedef int (*flow_ctrl_get_t)(struct rte_eth_dev *dev,
327 struct rte_eth_fc_conf *fc_conf);
328 /**< @internal Get current flow control parameter on an Ethernet device */
330 typedef int (*flow_ctrl_set_t)(struct rte_eth_dev *dev,
331 struct rte_eth_fc_conf *fc_conf);
332 /**< @internal Setup flow control parameter on an Ethernet device */
334 typedef int (*priority_flow_ctrl_set_t)(struct rte_eth_dev *dev,
335 struct rte_eth_pfc_conf *pfc_conf);
336 /**< @internal Setup priority flow control parameter on an Ethernet device */
338 typedef int (*reta_update_t)(struct rte_eth_dev *dev,
339 struct rte_eth_rss_reta_entry64 *reta_conf,
341 /**< @internal Update RSS redirection table on an Ethernet device */
343 typedef int (*reta_query_t)(struct rte_eth_dev *dev,
344 struct rte_eth_rss_reta_entry64 *reta_conf,
346 /**< @internal Query RSS redirection table on an Ethernet device */
348 typedef int (*rss_hash_update_t)(struct rte_eth_dev *dev,
349 struct rte_eth_rss_conf *rss_conf);
350 /**< @internal Update RSS hash configuration of an Ethernet device */
352 typedef int (*rss_hash_conf_get_t)(struct rte_eth_dev *dev,
353 struct rte_eth_rss_conf *rss_conf);
354 /**< @internal Get current RSS hash configuration of an Ethernet device */
356 typedef int (*eth_dev_led_on_t)(struct rte_eth_dev *dev);
357 /**< @internal Turn on SW controllable LED on an Ethernet device */
359 typedef int (*eth_dev_led_off_t)(struct rte_eth_dev *dev);
360 /**< @internal Turn off SW controllable LED on an Ethernet device */
362 typedef void (*eth_mac_addr_remove_t)(struct rte_eth_dev *dev, uint32_t index);
363 /**< @internal Remove MAC address from receive address register */
365 typedef int (*eth_mac_addr_add_t)(struct rte_eth_dev *dev,
366 struct rte_ether_addr *mac_addr,
369 /**< @internal Set a MAC address into Receive Address Register */
371 typedef int (*eth_mac_addr_set_t)(struct rte_eth_dev *dev,
372 struct rte_ether_addr *mac_addr);
373 /**< @internal Set a MAC address into Receive Address Register */
375 typedef int (*eth_uc_hash_table_set_t)(struct rte_eth_dev *dev,
376 struct rte_ether_addr *mac_addr,
378 /**< @internal Set a Unicast Hash bitmap */
380 typedef int (*eth_uc_all_hash_table_set_t)(struct rte_eth_dev *dev,
382 /**< @internal Set all Unicast Hash bitmap */
384 typedef int (*eth_set_queue_rate_limit_t)(struct rte_eth_dev *dev,
387 /**< @internal Set queue TX rate */
389 typedef int (*eth_mirror_rule_set_t)(struct rte_eth_dev *dev,
390 struct rte_eth_mirror_conf *mirror_conf,
393 /**< @internal Add a traffic mirroring rule on an Ethernet device */
395 typedef int (*eth_mirror_rule_reset_t)(struct rte_eth_dev *dev,
397 /**< @internal Remove a traffic mirroring rule on an Ethernet device */
399 typedef int (*eth_udp_tunnel_port_add_t)(struct rte_eth_dev *dev,
400 struct rte_eth_udp_tunnel *tunnel_udp);
401 /**< @internal Add tunneling UDP port */
403 typedef int (*eth_udp_tunnel_port_del_t)(struct rte_eth_dev *dev,
404 struct rte_eth_udp_tunnel *tunnel_udp);
405 /**< @internal Delete tunneling UDP port */
407 typedef int (*eth_set_mc_addr_list_t)(struct rte_eth_dev *dev,
408 struct rte_ether_addr *mc_addr_set,
409 uint32_t nb_mc_addr);
410 /**< @internal set the list of multicast addresses on an Ethernet device */
412 typedef int (*eth_timesync_enable_t)(struct rte_eth_dev *dev);
413 /**< @internal Function used to enable IEEE1588/802.1AS timestamping. */
415 typedef int (*eth_timesync_disable_t)(struct rte_eth_dev *dev);
416 /**< @internal Function used to disable IEEE1588/802.1AS timestamping. */
418 typedef int (*eth_timesync_read_rx_timestamp_t)(struct rte_eth_dev *dev,
419 struct timespec *timestamp,
421 /**< @internal Function used to read an RX IEEE1588/802.1AS timestamp. */
423 typedef int (*eth_timesync_read_tx_timestamp_t)(struct rte_eth_dev *dev,
424 struct timespec *timestamp);
425 /**< @internal Function used to read a TX IEEE1588/802.1AS timestamp. */
427 typedef int (*eth_timesync_adjust_time)(struct rte_eth_dev *dev, int64_t);
428 /**< @internal Function used to adjust the device clock */
430 typedef int (*eth_timesync_read_time)(struct rte_eth_dev *dev,
431 struct timespec *timestamp);
432 /**< @internal Function used to get time from the device clock. */
434 typedef int (*eth_timesync_write_time)(struct rte_eth_dev *dev,
435 const struct timespec *timestamp);
436 /**< @internal Function used to get time from the device clock */
438 typedef int (*eth_read_clock)(struct rte_eth_dev *dev,
439 uint64_t *timestamp);
440 /**< @internal Function used to get the current value of the device clock. */
442 typedef int (*eth_get_reg_t)(struct rte_eth_dev *dev,
443 struct rte_dev_reg_info *info);
444 /**< @internal Retrieve registers */
446 typedef int (*eth_get_eeprom_length_t)(struct rte_eth_dev *dev);
447 /**< @internal Retrieve eeprom size */
449 typedef int (*eth_get_eeprom_t)(struct rte_eth_dev *dev,
450 struct rte_dev_eeprom_info *info);
451 /**< @internal Retrieve eeprom data */
453 typedef int (*eth_set_eeprom_t)(struct rte_eth_dev *dev,
454 struct rte_dev_eeprom_info *info);
455 /**< @internal Program eeprom data */
457 typedef int (*eth_get_module_info_t)(struct rte_eth_dev *dev,
458 struct rte_eth_dev_module_info *modinfo);
459 /**< @internal Retrieve type and size of plugin module eeprom */
461 typedef int (*eth_get_module_eeprom_t)(struct rte_eth_dev *dev,
462 struct rte_dev_eeprom_info *info);
463 /**< @internal Retrieve plugin module eeprom data */
465 typedef int (*eth_l2_tunnel_eth_type_conf_t)
466 (struct rte_eth_dev *dev, struct rte_eth_l2_tunnel_conf *l2_tunnel);
467 /**< @internal config l2 tunnel ether type */
469 typedef int (*eth_l2_tunnel_offload_set_t)
470 (struct rte_eth_dev *dev,
471 struct rte_eth_l2_tunnel_conf *l2_tunnel,
474 /**< @internal enable/disable the l2 tunnel offload functions */
477 typedef int (*eth_filter_ctrl_t)(struct rte_eth_dev *dev,
478 enum rte_filter_type filter_type,
479 enum rte_filter_op filter_op,
481 /**< @internal Take operations to assigned filter type on an Ethernet device */
483 typedef int (*eth_tm_ops_get_t)(struct rte_eth_dev *dev, void *ops);
484 /**< @internal Get Traffic Management (TM) operations on an Ethernet device */
486 typedef int (*eth_mtr_ops_get_t)(struct rte_eth_dev *dev, void *ops);
487 /**< @internal Get Traffic Metering and Policing (MTR) operations */
489 typedef int (*eth_get_dcb_info)(struct rte_eth_dev *dev,
490 struct rte_eth_dcb_info *dcb_info);
491 /**< @internal Get dcb information on an Ethernet device */
493 typedef int (*eth_pool_ops_supported_t)(struct rte_eth_dev *dev,
495 /**< @internal Test if a port supports specific mempool ops */
499 * Get the hairpin capabilities.
502 * ethdev handle of port.
504 * returns the hairpin capabilities from the device.
507 * Negative errno value on error, 0 on success.
510 * Success, hairpin is supported.
512 * Hairpin is not supported.
514 typedef int (*eth_hairpin_cap_get_t)(struct rte_eth_dev *dev,
515 struct rte_eth_hairpin_cap *cap);
519 * Setup RX hairpin queue.
522 * ethdev handle of port.
524 * the selected RX queue index.
526 * the requested number of descriptors for this queue. 0 - use PMD default.
528 * the RX hairpin configuration structure.
531 * Negative errno value on error, 0 on success.
534 * Success, hairpin is supported.
536 * Hairpin is not supported.
538 * One of the parameters is invalid.
540 * Unable to allocate resources.
542 typedef int (*eth_rx_hairpin_queue_setup_t)
543 (struct rte_eth_dev *dev, uint16_t rx_queue_id,
545 const struct rte_eth_hairpin_conf *conf);
549 * Setup TX hairpin queue.
552 * ethdev handle of port.
554 * the selected TX queue index.
556 * the requested number of descriptors for this queue. 0 - use PMD default.
558 * the TX hairpin configuration structure.
561 * Negative errno value on error, 0 on success.
564 * Success, hairpin is supported.
566 * Hairpin is not supported.
568 * One of the parameters is invalid.
570 * Unable to allocate resources.
572 typedef int (*eth_tx_hairpin_queue_setup_t)
573 (struct rte_eth_dev *dev, uint16_t tx_queue_id,
575 const struct rte_eth_hairpin_conf *hairpin_conf);
579 * Get Forward Error Correction(FEC) capability.
582 * ethdev handle of port.
583 * @param speed_fec_capa
584 * speed_fec_capa is out only with per-speed capabilities.
586 * a number of elements in an speed_fec_capa array.
589 * Negative errno value on error, positive value on success.
591 * @retval positive value
592 * A non-negative value lower or equal to num: success. The return value
593 * is the number of entries filled in the fec capa array.
594 * A non-negative value higher than num: error, the given fec capa array
595 * is too small. The return value corresponds to the num that should
596 * be given to succeed. The entries in the fec capa array are not valid
597 * and shall not be used by the caller.
599 * Operation is not supported.
603 * *num* or *speed_fec_capa* invalid.
605 typedef int (*eth_fec_get_capability_t)(struct rte_eth_dev *dev,
606 struct rte_eth_fec_capa *speed_fec_capa, unsigned int num);
610 * Get Forward Error Correction(FEC) mode.
613 * ethdev handle of port.
615 * a bitmask of enabled FEC modes. If AUTO bit is set, other
616 * bits specify FEC modes which may be negotiated. If AUTO
617 * bit is clear, specify FEC modes to be used (only one valid
618 * mode per speed may be set).
621 * Negative errno value on error, 0 on success.
624 * Success, get FEC success.
626 * Operation is not supported.
630 typedef int (*eth_fec_get_t)(struct rte_eth_dev *dev,
635 * Set Forward Error Correction(FEC) mode.
638 * ethdev handle of port.
640 * bitmask of allowed FEC modes. It must be only one
641 * if AUTO is disabled. If AUTO is enabled, other
642 * bits specify FEC modes which may be negotiated.
645 * Negative errno value on error, 0 on success.
648 * Success, set FEC success.
650 * Operation is not supported.
652 * Unsupported FEC mode requested.
656 typedef int (*eth_fec_set_t)(struct rte_eth_dev *dev, uint32_t fec_capa);
660 * Get all hairpin Tx/Rx peer ports of the current device, if any.
663 * ethdev handle of port.
665 * array to save the ports list.
669 * value to decide the current to peer direction
670 * positive - used as Tx to get all peer Rx ports.
671 * zero - used as Rx to get all peer Tx ports.
674 * Negative errno value on error, 0 or positive on success.
677 * Success, no peer ports.
679 * Actual number of the peer ports.
681 * Get peer ports API is not supported.
683 * One of the parameters is invalid.
685 typedef int (*hairpin_get_peer_ports_t)(struct rte_eth_dev *dev,
686 uint16_t *peer_ports, size_t len,
691 * Bind all hairpin Tx queues of one port to the Rx queues of the peer port.
694 * ethdev handle of port.
699 * Negative errno value on error, 0 on success.
702 * Success, bind successfully.
704 * Bind API is not supported.
706 * One of the parameters is invalid.
708 * Device is not started.
710 typedef int (*eth_hairpin_bind_t)(struct rte_eth_dev *dev,
715 * Unbind all hairpin Tx queues of one port from the Rx queues of the peer port.
718 * ethdev handle of port.
723 * Negative errno value on error, 0 on success.
726 * Success, unbind successfully.
728 * Bind API is not supported.
730 * One of the parameters is invalid.
732 * Device is already stopped.
734 typedef int (*eth_hairpin_unbind_t)(struct rte_eth_dev *dev,
738 * @internal A structure containing the functions exported by an Ethernet driver.
741 eth_dev_configure_t dev_configure; /**< Configure device. */
742 eth_dev_start_t dev_start; /**< Start device. */
743 eth_dev_stop_t dev_stop; /**< Stop device. */
744 eth_dev_set_link_up_t dev_set_link_up; /**< Device link up. */
745 eth_dev_set_link_down_t dev_set_link_down; /**< Device link down. */
746 eth_dev_close_t dev_close; /**< Close device. */
747 eth_dev_reset_t dev_reset; /**< Reset device. */
748 eth_link_update_t link_update; /**< Get device link state. */
749 eth_is_removed_t is_removed;
750 /**< Check if the device was physically removed. */
752 eth_promiscuous_enable_t promiscuous_enable; /**< Promiscuous ON. */
753 eth_promiscuous_disable_t promiscuous_disable;/**< Promiscuous OFF. */
754 eth_allmulticast_enable_t allmulticast_enable;/**< RX multicast ON. */
755 eth_allmulticast_disable_t allmulticast_disable;/**< RX multicast OFF. */
756 eth_mac_addr_remove_t mac_addr_remove; /**< Remove MAC address. */
757 eth_mac_addr_add_t mac_addr_add; /**< Add a MAC address. */
758 eth_mac_addr_set_t mac_addr_set; /**< Set a MAC address. */
759 eth_set_mc_addr_list_t set_mc_addr_list; /**< set list of mcast addrs. */
760 mtu_set_t mtu_set; /**< Set MTU. */
762 eth_stats_get_t stats_get; /**< Get generic device statistics. */
763 eth_stats_reset_t stats_reset; /**< Reset generic device statistics. */
764 eth_xstats_get_t xstats_get; /**< Get extended device statistics. */
765 eth_xstats_reset_t xstats_reset; /**< Reset extended device statistics. */
766 eth_xstats_get_names_t xstats_get_names;
767 /**< Get names of extended statistics. */
768 eth_queue_stats_mapping_set_t queue_stats_mapping_set;
769 /**< Configure per queue stat counter mapping. */
771 eth_dev_infos_get_t dev_infos_get; /**< Get device info. */
772 eth_rxq_info_get_t rxq_info_get; /**< retrieve RX queue information. */
773 eth_txq_info_get_t txq_info_get; /**< retrieve TX queue information. */
774 eth_burst_mode_get_t rx_burst_mode_get; /**< Get RX burst mode */
775 eth_burst_mode_get_t tx_burst_mode_get; /**< Get TX burst mode */
776 eth_fw_version_get_t fw_version_get; /**< Get firmware version. */
777 eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
778 /**< Get packet types supported and identified by device. */
779 eth_dev_ptypes_set_t dev_ptypes_set;
780 /**< Inform Ethernet device about reduced range of packet types to handle. */
782 vlan_filter_set_t vlan_filter_set; /**< Filter VLAN Setup. */
783 vlan_tpid_set_t vlan_tpid_set; /**< Outer/Inner VLAN TPID Setup. */
784 vlan_strip_queue_set_t vlan_strip_queue_set; /**< VLAN Stripping on queue. */
785 vlan_offload_set_t vlan_offload_set; /**< Set VLAN Offload. */
786 vlan_pvid_set_t vlan_pvid_set; /**< Set port based TX VLAN insertion. */
788 eth_queue_start_t rx_queue_start;/**< Start RX for a queue. */
789 eth_queue_stop_t rx_queue_stop; /**< Stop RX for a queue. */
790 eth_queue_start_t tx_queue_start;/**< Start TX for a queue. */
791 eth_queue_stop_t tx_queue_stop; /**< Stop TX for a queue. */
792 eth_rx_queue_setup_t rx_queue_setup;/**< Set up device RX queue. */
793 eth_queue_release_t rx_queue_release; /**< Release RX queue. */
795 eth_rx_enable_intr_t rx_queue_intr_enable; /**< Enable Rx queue interrupt. */
796 eth_rx_disable_intr_t rx_queue_intr_disable; /**< Disable Rx queue interrupt. */
797 eth_tx_queue_setup_t tx_queue_setup;/**< Set up device TX queue. */
798 eth_queue_release_t tx_queue_release; /**< Release TX queue. */
799 eth_tx_done_cleanup_t tx_done_cleanup;/**< Free tx ring mbufs */
801 eth_dev_led_on_t dev_led_on; /**< Turn on LED. */
802 eth_dev_led_off_t dev_led_off; /**< Turn off LED. */
804 flow_ctrl_get_t flow_ctrl_get; /**< Get flow control. */
805 flow_ctrl_set_t flow_ctrl_set; /**< Setup flow control. */
806 priority_flow_ctrl_set_t priority_flow_ctrl_set; /**< Setup priority flow control. */
808 eth_uc_hash_table_set_t uc_hash_table_set; /**< Set Unicast Table Array. */
809 eth_uc_all_hash_table_set_t uc_all_hash_table_set; /**< Set Unicast hash bitmap. */
811 eth_mirror_rule_set_t mirror_rule_set; /**< Add a traffic mirror rule. */
812 eth_mirror_rule_reset_t mirror_rule_reset; /**< reset a traffic mirror rule. */
814 eth_udp_tunnel_port_add_t udp_tunnel_port_add; /** Add UDP tunnel port. */
815 eth_udp_tunnel_port_del_t udp_tunnel_port_del; /** Del UDP tunnel port. */
816 eth_l2_tunnel_eth_type_conf_t l2_tunnel_eth_type_conf;
817 /** Config ether type of l2 tunnel. */
818 eth_l2_tunnel_offload_set_t l2_tunnel_offload_set;
819 /** Enable/disable l2 tunnel offload functions. */
821 eth_set_queue_rate_limit_t set_queue_rate_limit; /**< Set queue rate limit. */
823 rss_hash_update_t rss_hash_update; /** Configure RSS hash protocols. */
824 rss_hash_conf_get_t rss_hash_conf_get; /** Get current RSS hash configuration. */
825 reta_update_t reta_update; /** Update redirection table. */
826 reta_query_t reta_query; /** Query redirection table. */
828 eth_get_reg_t get_reg; /**< Get registers. */
829 eth_get_eeprom_length_t get_eeprom_length; /**< Get eeprom length. */
830 eth_get_eeprom_t get_eeprom; /**< Get eeprom data. */
831 eth_set_eeprom_t set_eeprom; /**< Set eeprom. */
833 eth_get_module_info_t get_module_info;
834 /** Get plugin module eeprom attribute. */
835 eth_get_module_eeprom_t get_module_eeprom;
836 /** Get plugin module eeprom data. */
838 eth_filter_ctrl_t filter_ctrl; /**< common filter control. */
840 eth_get_dcb_info get_dcb_info; /** Get DCB information. */
842 eth_timesync_enable_t timesync_enable;
843 /** Turn IEEE1588/802.1AS timestamping on. */
844 eth_timesync_disable_t timesync_disable;
845 /** Turn IEEE1588/802.1AS timestamping off. */
846 eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp;
847 /** Read the IEEE1588/802.1AS RX timestamp. */
848 eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp;
849 /** Read the IEEE1588/802.1AS TX timestamp. */
850 eth_timesync_adjust_time timesync_adjust_time; /** Adjust the device clock. */
851 eth_timesync_read_time timesync_read_time; /** Get the device clock time. */
852 eth_timesync_write_time timesync_write_time; /** Set the device clock time. */
854 eth_read_clock read_clock;
856 eth_xstats_get_by_id_t xstats_get_by_id;
857 /**< Get extended device statistic values by ID. */
858 eth_xstats_get_names_by_id_t xstats_get_names_by_id;
859 /**< Get name of extended device statistics by ID. */
861 eth_tm_ops_get_t tm_ops_get;
862 /**< Get Traffic Management (TM) operations. */
864 eth_mtr_ops_get_t mtr_ops_get;
865 /**< Get Traffic Metering and Policing (MTR) operations. */
867 eth_pool_ops_supported_t pool_ops_supported;
868 /**< Test if a port supports specific mempool ops */
870 eth_hairpin_cap_get_t hairpin_cap_get;
871 /**< Returns the hairpin capabilities. */
872 eth_rx_hairpin_queue_setup_t rx_hairpin_queue_setup;
873 /**< Set up device RX hairpin queue. */
874 eth_tx_hairpin_queue_setup_t tx_hairpin_queue_setup;
875 /**< Set up device TX hairpin queue. */
877 eth_fec_get_capability_t fec_get_capability;
878 /**< Get Forward Error Correction(FEC) capability. */
879 eth_fec_get_t fec_get;
880 /**< Get Forward Error Correction(FEC) mode. */
881 eth_fec_set_t fec_set;
882 /**< Set Forward Error Correction(FEC) mode. */
883 hairpin_get_peer_ports_t hairpin_get_peer_ports;
884 /**< Get hairpin peer ports list. */
885 eth_hairpin_bind_t hairpin_bind;
886 /**< Bind all hairpin Tx queues of device to the peer port Rx queues. */
887 eth_hairpin_unbind_t hairpin_unbind;
888 /**< Unbind all hairpin Tx queues from the peer port Rx queues. */
894 #define RTE_ETH_QUEUE_STATE_STOPPED 0
895 #define RTE_ETH_QUEUE_STATE_STARTED 1
896 #define RTE_ETH_QUEUE_STATE_HAIRPIN 2
900 * Check if the selected Rx queue is hairpin queue.
903 * Pointer to the selected device.
905 * The selected queue.
908 * - (1) if the queue is hairpin queue, 0 otherwise.
911 int rte_eth_dev_is_rx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id);
915 * Check if the selected Tx queue is hairpin queue.
918 * Pointer to the selected device.
920 * The selected queue.
923 * - (1) if the queue is hairpin queue, 0 otherwise.
926 int rte_eth_dev_is_tx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id);
930 * Returns a ethdev slot specified by the unique identifier name.
933 * The pointer to the Unique identifier name for each Ethernet device
935 * - The pointer to the ethdev slot, on success. NULL on error
938 struct rte_eth_dev *rte_eth_dev_allocated(const char *name);
942 * Allocates a new ethdev slot for an ethernet device and returns the pointer
943 * to that slot for the driver to use.
945 * @param name Unique identifier name for each Ethernet device
947 * - Slot in the rte_dev_devices array for a new device;
950 struct rte_eth_dev *rte_eth_dev_allocate(const char *name);
954 * Attach to the ethdev already initialized by the primary
957 * @param name Ethernet device's name.
959 * - Success: Slot in the rte_dev_devices array for attached
961 * - Error: Null pointer.
964 struct rte_eth_dev *rte_eth_dev_attach_secondary(const char *name);
968 * Notify RTE_ETH_EVENT_DESTROY and release the specified ethdev port.
970 * The following PMD-managed data fields will be freed:
974 * If one of these fields should not be freed,
975 * it must be reset to NULL by the PMD, typically in dev_close method.
978 * Device to be detached.
980 * - 0 on success, negative on error
983 int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev);
987 * Release device queues and clear its configuration to force the user
988 * application to reconfigure it. It is for internal use only.
991 * Pointer to struct rte_eth_dev.
997 void rte_eth_dev_internal_reset(struct rte_eth_dev *dev);
1000 * @internal Executes all the user application registered callbacks for
1001 * the specific device. It is for DPDK internal user only. User
1002 * application should not call it directly.
1005 * Pointer to struct rte_eth_dev.
1007 * Eth device interrupt event type.
1009 * To pass data back to user application.
1010 * This allows the user application to decide if a particular function
1011 * is permitted or not.
1017 int rte_eth_dev_callback_process(struct rte_eth_dev *dev,
1018 enum rte_eth_event_type event, void *ret_param);
1022 * This is the last step of device probing.
1023 * It must be called after a port is allocated and initialized successfully.
1025 * The notification RTE_ETH_EVENT_NEW is sent to other entities
1026 * (libraries and applications).
1027 * The state is set as RTE_ETH_DEV_ATTACHED.
1033 void rte_eth_dev_probing_finish(struct rte_eth_dev *dev);
1036 * Create memzone for HW rings.
1037 * malloc can't be used as the physical address is needed.
1038 * If the memzone is already created, then this function returns a ptr
1042 * The *eth_dev* pointer is the address of the *rte_eth_dev* structure
1044 * The name of the memory zone
1046 * The index of the queue to add to name
1048 * The sizeof of the memory area
1050 * Alignment for resulting memzone. Must be a power of 2.
1052 * The *socket_id* argument is the socket identifier in case of NUMA.
1055 const struct rte_memzone *
1056 rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name,
1057 uint16_t queue_id, size_t size,
1058 unsigned align, int socket_id);
1061 * Free previously allocated memzone for HW rings.
1064 * The *eth_dev* pointer is the address of the *rte_eth_dev* structure
1066 * The name of the memory zone
1068 * The index of the queue to add to name
1070 * Negative errno value on error, 0 on success.
1074 rte_eth_dma_zone_free(const struct rte_eth_dev *eth_dev, const char *name,
1079 * Atomically set the link status for the specific device.
1080 * It is for use by DPDK device driver use only.
1081 * User applications should not call it
1084 * Pointer to struct rte_eth_dev.
1086 * New link status value.
1088 * Same convention as eth_link_update operation.
1089 * 0 if link up status has changed
1090 * -1 if link up status was unchanged
1093 rte_eth_linkstatus_set(struct rte_eth_dev *dev,
1094 const struct rte_eth_link *new_link)
1096 uint64_t *dev_link = (uint64_t *)&(dev->data->dev_link);
1099 struct rte_eth_link link;
1102 RTE_BUILD_BUG_ON(sizeof(*new_link) != sizeof(uint64_t));
1104 orig.val64 = __atomic_exchange_n(dev_link, *(const uint64_t *)new_link,
1107 return (orig.link.link_status == new_link->link_status) ? -1 : 0;
1112 * Atomically get the link speed and status.
1115 * Pointer to struct rte_eth_dev.
1117 * link status value.
1120 rte_eth_linkstatus_get(const struct rte_eth_dev *dev,
1121 struct rte_eth_link *link)
1123 uint64_t *src = (uint64_t *)&(dev->data->dev_link);
1124 uint64_t *dst = (uint64_t *)link;
1126 RTE_BUILD_BUG_ON(sizeof(*link) != sizeof(uint64_t));
1128 *dst = __atomic_load_n(src, __ATOMIC_SEQ_CST);
1132 * Allocate an unique switch domain identifier.
1134 * A pool of switch domain identifiers which can be allocated on request. This
1135 * will enabled devices which support the concept of switch domains to request
1136 * a switch domain id which is guaranteed to be unique from other devices
1137 * running in the same process.
1140 * switch domain identifier parameter to pass back to application
1143 * Negative errno value on error, 0 on success.
1147 rte_eth_switch_domain_alloc(uint16_t *domain_id);
1150 * Free switch domain.
1152 * Return a switch domain identifier to the pool of free identifiers after it is
1153 * no longer in use by device.
1156 * switch domain identifier to free
1159 * Negative errno value on error, 0 on success.
1163 rte_eth_switch_domain_free(uint16_t domain_id);
1165 /** Generic Ethernet device arguments */
1166 struct rte_eth_devargs {
1167 uint16_t ports[RTE_MAX_ETHPORTS];
1168 /** port/s number to enable on a multi-port single function */
1170 /** number of ports in ports field */
1171 uint16_t representor_ports[RTE_MAX_ETHPORTS];
1172 /** representor port/s identifier to enable on device */
1173 uint16_t nb_representor_ports;
1174 /** number of ports in representor port field */
1178 * PMD helper function to parse ethdev arguments
1182 * @param eth_devargs
1183 * parsed ethdev specific arguments.
1186 * Negative errno value on error, 0 on success.
1190 rte_eth_devargs_parse(const char *devargs, struct rte_eth_devargs *eth_devargs);
1193 typedef int (*ethdev_init_t)(struct rte_eth_dev *ethdev, void *init_params);
1194 typedef int (*ethdev_bus_specific_init)(struct rte_eth_dev *ethdev,
1195 void *bus_specific_init_params);
1198 * PMD helper function for the creation of a new ethdev ports.
1201 * rte_device handle.
1204 * @param priv_data_size
1205 * size of private data required for port.
1206 * @param bus_specific_init
1207 * port bus specific initialisation callback function
1208 * @param bus_init_params
1209 * port bus specific initialisation parameters
1210 * @param ethdev_init
1211 * device specific port initialization callback function
1212 * @param init_params
1213 * port initialisation parameters
1216 * Negative errno value on error, 0 on success.
1220 rte_eth_dev_create(struct rte_device *device, const char *name,
1221 size_t priv_data_size,
1222 ethdev_bus_specific_init bus_specific_init, void *bus_init_params,
1223 ethdev_init_t ethdev_init, void *init_params);
1226 typedef int (*ethdev_uninit_t)(struct rte_eth_dev *ethdev);
1229 * PMD helper function for cleaning up the resources of a ethdev port on it's
1233 * ethdev handle of port.
1234 * @param ethdev_uninit
1235 * device specific port un-initialise callback function
1238 * Negative errno value on error, 0 on success.
1242 rte_eth_dev_destroy(struct rte_eth_dev *ethdev, ethdev_uninit_t ethdev_uninit);
1248 #endif /* _RTE_ETHDEV_DRIVER_H_ */