DPDK  19.11.14
rte_ethdev_core.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Intel Corporation
3  */
4 
5 #ifndef _RTE_ETHDEV_CORE_H_
6 #define _RTE_ETHDEV_CORE_H_
7 
20 struct rte_eth_dev_callback;
22 TAILQ_HEAD(rte_eth_dev_cb_list, rte_eth_dev_callback);
23 
24 /*
25  * Definitions of all functions exported by an Ethernet driver through the
26  * the generic structure of type *eth_dev_ops* supplied in the *rte_eth_dev*
27  * structure associated with an Ethernet device.
28  */
29 struct rte_eth_dev;
30 
31 typedef int (*eth_dev_configure_t)(struct rte_eth_dev *dev);
34 typedef int (*eth_dev_start_t)(struct rte_eth_dev *dev);
37 typedef void (*eth_dev_stop_t)(struct rte_eth_dev *dev);
40 typedef int (*eth_dev_set_link_up_t)(struct rte_eth_dev *dev);
43 typedef int (*eth_dev_set_link_down_t)(struct rte_eth_dev *dev);
46 typedef void (*eth_dev_close_t)(struct rte_eth_dev *dev);
49 typedef int (*eth_dev_reset_t)(struct rte_eth_dev *dev);
52 typedef int (*eth_is_removed_t)(struct rte_eth_dev *dev);
78 typedef int (*eth_promiscuous_enable_t)(struct rte_eth_dev *dev);
79 
103 typedef int (*eth_promiscuous_disable_t)(struct rte_eth_dev *dev);
104 
128 typedef int (*eth_allmulticast_enable_t)(struct rte_eth_dev *dev);
129 
153 typedef int (*eth_allmulticast_disable_t)(struct rte_eth_dev *dev);
154 
155 typedef int (*eth_link_update_t)(struct rte_eth_dev *dev,
156  int wait_to_complete);
159 typedef int (*eth_stats_get_t)(struct rte_eth_dev *dev,
160  struct rte_eth_stats *igb_stats);
182 typedef int (*eth_stats_reset_t)(struct rte_eth_dev *dev);
183 
184 typedef int (*eth_xstats_get_t)(struct rte_eth_dev *dev,
185  struct rte_eth_xstat *stats, unsigned n);
188 typedef int (*eth_xstats_get_by_id_t)(struct rte_eth_dev *dev,
189  const uint64_t *ids,
190  uint64_t *values,
191  unsigned int n);
213 typedef int (*eth_xstats_reset_t)(struct rte_eth_dev *dev);
214 
215 typedef int (*eth_xstats_get_names_t)(struct rte_eth_dev *dev,
216  struct rte_eth_xstat_name *xstats_names, unsigned size);
219 typedef int (*eth_xstats_get_names_by_id_t)(struct rte_eth_dev *dev,
220  struct rte_eth_xstat_name *xstats_names, const uint64_t *ids,
221  unsigned int size);
224 typedef int (*eth_queue_stats_mapping_set_t)(struct rte_eth_dev *dev,
225  uint16_t queue_id,
226  uint8_t stat_idx,
227  uint8_t is_rx);
230 typedef int (*eth_dev_infos_get_t)(struct rte_eth_dev *dev,
231  struct rte_eth_dev_info *dev_info);
234 typedef const uint32_t *(*eth_dev_supported_ptypes_get_t)(struct rte_eth_dev *dev);
249 typedef int (*eth_dev_ptypes_set_t)(struct rte_eth_dev *dev,
250  uint32_t ptype_mask);
251 
252 typedef int (*eth_queue_start_t)(struct rte_eth_dev *dev,
253  uint16_t queue_id);
256 typedef int (*eth_queue_stop_t)(struct rte_eth_dev *dev,
257  uint16_t queue_id);
260 typedef int (*eth_rx_queue_setup_t)(struct rte_eth_dev *dev,
261  uint16_t rx_queue_id,
262  uint16_t nb_rx_desc,
263  unsigned int socket_id,
264  const struct rte_eth_rxconf *rx_conf,
265  struct rte_mempool *mb_pool);
268 typedef int (*eth_tx_queue_setup_t)(struct rte_eth_dev *dev,
269  uint16_t tx_queue_id,
270  uint16_t nb_tx_desc,
271  unsigned int socket_id,
272  const struct rte_eth_txconf *tx_conf);
275 typedef int (*eth_rx_enable_intr_t)(struct rte_eth_dev *dev,
276  uint16_t rx_queue_id);
279 typedef int (*eth_rx_disable_intr_t)(struct rte_eth_dev *dev,
280  uint16_t rx_queue_id);
283 typedef void (*eth_queue_release_t)(void *queue);
286 typedef uint32_t (*eth_rx_queue_count_t)(struct rte_eth_dev *dev,
287  uint16_t rx_queue_id);
290 typedef int (*eth_rx_descriptor_done_t)(void *rxq, uint16_t offset);
293 typedef int (*eth_rx_descriptor_status_t)(void *rxq, uint16_t offset);
296 typedef int (*eth_tx_descriptor_status_t)(void *txq, uint16_t offset);
299 typedef int (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
300  char *fw_version, size_t fw_size);
303 typedef int (*eth_tx_done_cleanup_t)(void *txq, uint32_t free_cnt);
306 typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
307  uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
308 
309 typedef void (*eth_txq_info_get_t)(struct rte_eth_dev *dev,
310  uint16_t tx_queue_id, struct rte_eth_txq_info *qinfo);
311 
312 typedef int (*eth_burst_mode_get_t)(struct rte_eth_dev *dev,
313  uint16_t queue_id, struct rte_eth_burst_mode *mode);
314 
315 typedef int (*mtu_set_t)(struct rte_eth_dev *dev, uint16_t mtu);
318 typedef int (*vlan_filter_set_t)(struct rte_eth_dev *dev,
319  uint16_t vlan_id,
320  int on);
323 typedef int (*vlan_tpid_set_t)(struct rte_eth_dev *dev,
324  enum rte_vlan_type type, uint16_t tpid);
327 typedef int (*vlan_offload_set_t)(struct rte_eth_dev *dev, int mask);
330 typedef int (*vlan_pvid_set_t)(struct rte_eth_dev *dev,
331  uint16_t vlan_id,
332  int on);
335 typedef void (*vlan_strip_queue_set_t)(struct rte_eth_dev *dev,
336  uint16_t rx_queue_id,
337  int on);
340 typedef uint16_t (*eth_rx_burst_t)(void *rxq,
341  struct rte_mbuf **rx_pkts,
342  uint16_t nb_pkts);
345 typedef uint16_t (*eth_tx_burst_t)(void *txq,
346  struct rte_mbuf **tx_pkts,
347  uint16_t nb_pkts);
350 typedef uint16_t (*eth_tx_prep_t)(void *txq,
351  struct rte_mbuf **tx_pkts,
352  uint16_t nb_pkts);
355 typedef int (*flow_ctrl_get_t)(struct rte_eth_dev *dev,
356  struct rte_eth_fc_conf *fc_conf);
359 typedef int (*flow_ctrl_set_t)(struct rte_eth_dev *dev,
360  struct rte_eth_fc_conf *fc_conf);
363 typedef int (*priority_flow_ctrl_set_t)(struct rte_eth_dev *dev,
364  struct rte_eth_pfc_conf *pfc_conf);
367 typedef int (*reta_update_t)(struct rte_eth_dev *dev,
368  struct rte_eth_rss_reta_entry64 *reta_conf,
369  uint16_t reta_size);
372 typedef int (*reta_query_t)(struct rte_eth_dev *dev,
373  struct rte_eth_rss_reta_entry64 *reta_conf,
374  uint16_t reta_size);
377 typedef int (*rss_hash_update_t)(struct rte_eth_dev *dev,
378  struct rte_eth_rss_conf *rss_conf);
381 typedef int (*rss_hash_conf_get_t)(struct rte_eth_dev *dev,
382  struct rte_eth_rss_conf *rss_conf);
385 typedef int (*eth_dev_led_on_t)(struct rte_eth_dev *dev);
388 typedef int (*eth_dev_led_off_t)(struct rte_eth_dev *dev);
391 typedef void (*eth_mac_addr_remove_t)(struct rte_eth_dev *dev, uint32_t index);
394 typedef int (*eth_mac_addr_add_t)(struct rte_eth_dev *dev,
395  struct rte_ether_addr *mac_addr,
396  uint32_t index,
397  uint32_t vmdq);
400 typedef int (*eth_mac_addr_set_t)(struct rte_eth_dev *dev,
401  struct rte_ether_addr *mac_addr);
404 typedef int (*eth_uc_hash_table_set_t)(struct rte_eth_dev *dev,
405  struct rte_ether_addr *mac_addr,
406  uint8_t on);
409 typedef int (*eth_uc_all_hash_table_set_t)(struct rte_eth_dev *dev,
410  uint8_t on);
413 typedef int (*eth_set_queue_rate_limit_t)(struct rte_eth_dev *dev,
414  uint16_t queue_idx,
415  uint16_t tx_rate);
418 typedef int (*eth_mirror_rule_set_t)(struct rte_eth_dev *dev,
419  struct rte_eth_mirror_conf *mirror_conf,
420  uint8_t rule_id,
421  uint8_t on);
424 typedef int (*eth_mirror_rule_reset_t)(struct rte_eth_dev *dev,
425  uint8_t rule_id);
428 typedef int (*eth_udp_tunnel_port_add_t)(struct rte_eth_dev *dev,
429  struct rte_eth_udp_tunnel *tunnel_udp);
432 typedef int (*eth_udp_tunnel_port_del_t)(struct rte_eth_dev *dev,
433  struct rte_eth_udp_tunnel *tunnel_udp);
436 typedef int (*eth_set_mc_addr_list_t)(struct rte_eth_dev *dev,
437  struct rte_ether_addr *mc_addr_set,
438  uint32_t nb_mc_addr);
441 typedef int (*eth_timesync_enable_t)(struct rte_eth_dev *dev);
444 typedef int (*eth_timesync_disable_t)(struct rte_eth_dev *dev);
447 typedef int (*eth_timesync_read_rx_timestamp_t)(struct rte_eth_dev *dev,
448  struct timespec *timestamp,
449  uint32_t flags);
452 typedef int (*eth_timesync_read_tx_timestamp_t)(struct rte_eth_dev *dev,
453  struct timespec *timestamp);
456 typedef int (*eth_timesync_adjust_time)(struct rte_eth_dev *dev, int64_t);
459 typedef int (*eth_timesync_read_time)(struct rte_eth_dev *dev,
460  struct timespec *timestamp);
463 typedef int (*eth_timesync_write_time)(struct rte_eth_dev *dev,
464  const struct timespec *timestamp);
467 typedef int (*eth_read_clock)(struct rte_eth_dev *dev,
468  uint64_t *timestamp);
471 typedef int (*eth_get_reg_t)(struct rte_eth_dev *dev,
472  struct rte_dev_reg_info *info);
475 typedef int (*eth_get_eeprom_length_t)(struct rte_eth_dev *dev);
478 typedef int (*eth_get_eeprom_t)(struct rte_eth_dev *dev,
479  struct rte_dev_eeprom_info *info);
482 typedef int (*eth_set_eeprom_t)(struct rte_eth_dev *dev,
483  struct rte_dev_eeprom_info *info);
486 typedef int (*eth_get_module_info_t)(struct rte_eth_dev *dev,
487  struct rte_eth_dev_module_info *modinfo);
490 typedef int (*eth_get_module_eeprom_t)(struct rte_eth_dev *dev,
491  struct rte_dev_eeprom_info *info);
494 typedef int (*eth_l2_tunnel_eth_type_conf_t)
495  (struct rte_eth_dev *dev, struct rte_eth_l2_tunnel_conf *l2_tunnel);
498 typedef int (*eth_l2_tunnel_offload_set_t)
499  (struct rte_eth_dev *dev,
500  struct rte_eth_l2_tunnel_conf *l2_tunnel,
501  uint32_t mask,
502  uint8_t en);
506 typedef int (*eth_filter_ctrl_t)(struct rte_eth_dev *dev,
507  enum rte_filter_type filter_type,
508  enum rte_filter_op filter_op,
509  void *arg);
512 typedef int (*eth_tm_ops_get_t)(struct rte_eth_dev *dev, void *ops);
515 typedef int (*eth_mtr_ops_get_t)(struct rte_eth_dev *dev, void *ops);
518 typedef int (*eth_get_dcb_info)(struct rte_eth_dev *dev,
519  struct rte_eth_dcb_info *dcb_info);
522 typedef int (*eth_pool_ops_supported_t)(struct rte_eth_dev *dev,
523  const char *pool);
543 typedef int (*eth_hairpin_cap_get_t)(struct rte_eth_dev *dev,
544  struct rte_eth_hairpin_cap *cap);
545 
571 typedef int (*eth_rx_hairpin_queue_setup_t)
572  (struct rte_eth_dev *dev, uint16_t rx_queue_id,
573  uint16_t nb_rx_desc,
574  const struct rte_eth_hairpin_conf *conf);
575 
601 typedef int (*eth_tx_hairpin_queue_setup_t)
602  (struct rte_eth_dev *dev, uint16_t tx_queue_id,
603  uint16_t nb_tx_desc,
604  const struct rte_eth_hairpin_conf *hairpin_conf);
605 
609 struct eth_dev_ops {
610  eth_dev_configure_t dev_configure;
611  eth_dev_start_t dev_start;
612  eth_dev_stop_t dev_stop;
613  eth_dev_set_link_up_t dev_set_link_up;
614  eth_dev_set_link_down_t dev_set_link_down;
615  eth_dev_close_t dev_close;
616  eth_dev_reset_t dev_reset;
617  eth_link_update_t link_update;
618  eth_is_removed_t is_removed;
621  eth_promiscuous_enable_t promiscuous_enable;
622  eth_promiscuous_disable_t promiscuous_disable;
623  eth_allmulticast_enable_t allmulticast_enable;
624  eth_allmulticast_disable_t allmulticast_disable;
625  eth_mac_addr_remove_t mac_addr_remove;
626  eth_mac_addr_add_t mac_addr_add;
627  eth_mac_addr_set_t mac_addr_set;
628  eth_set_mc_addr_list_t set_mc_addr_list;
629  mtu_set_t mtu_set;
631  eth_stats_get_t stats_get;
632  eth_stats_reset_t stats_reset;
633  eth_xstats_get_t xstats_get;
634  eth_xstats_reset_t xstats_reset;
635  eth_xstats_get_names_t xstats_get_names;
637  eth_queue_stats_mapping_set_t queue_stats_mapping_set;
640  eth_dev_infos_get_t dev_infos_get;
641  eth_rxq_info_get_t rxq_info_get;
642  eth_txq_info_get_t txq_info_get;
643  eth_burst_mode_get_t rx_burst_mode_get;
644  eth_burst_mode_get_t tx_burst_mode_get;
645  eth_fw_version_get_t fw_version_get;
646  eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
648  eth_dev_ptypes_set_t dev_ptypes_set;
651  vlan_filter_set_t vlan_filter_set;
652  vlan_tpid_set_t vlan_tpid_set;
653  vlan_strip_queue_set_t vlan_strip_queue_set;
654  vlan_offload_set_t vlan_offload_set;
655  vlan_pvid_set_t vlan_pvid_set;
657  eth_queue_start_t rx_queue_start;
658  eth_queue_stop_t rx_queue_stop;
659  eth_queue_start_t tx_queue_start;
660  eth_queue_stop_t tx_queue_stop;
661  eth_rx_queue_setup_t rx_queue_setup;
662  eth_queue_release_t rx_queue_release;
663  eth_rx_queue_count_t rx_queue_count;
665  eth_rx_descriptor_done_t rx_descriptor_done;
666  eth_rx_descriptor_status_t rx_descriptor_status;
668  eth_tx_descriptor_status_t tx_descriptor_status;
670  eth_rx_enable_intr_t rx_queue_intr_enable;
671  eth_rx_disable_intr_t rx_queue_intr_disable;
672  eth_tx_queue_setup_t tx_queue_setup;
673  eth_queue_release_t tx_queue_release;
674  eth_tx_done_cleanup_t tx_done_cleanup;
676  eth_dev_led_on_t dev_led_on;
677  eth_dev_led_off_t dev_led_off;
679  flow_ctrl_get_t flow_ctrl_get;
680  flow_ctrl_set_t flow_ctrl_set;
681  priority_flow_ctrl_set_t priority_flow_ctrl_set;
683  eth_uc_hash_table_set_t uc_hash_table_set;
684  eth_uc_all_hash_table_set_t uc_all_hash_table_set;
686  eth_mirror_rule_set_t mirror_rule_set;
687  eth_mirror_rule_reset_t mirror_rule_reset;
689  eth_udp_tunnel_port_add_t udp_tunnel_port_add;
690  eth_udp_tunnel_port_del_t udp_tunnel_port_del;
691  eth_l2_tunnel_eth_type_conf_t l2_tunnel_eth_type_conf;
693  eth_l2_tunnel_offload_set_t l2_tunnel_offload_set;
696  eth_set_queue_rate_limit_t set_queue_rate_limit;
698  rss_hash_update_t rss_hash_update;
699  rss_hash_conf_get_t rss_hash_conf_get;
700  reta_update_t reta_update;
701  reta_query_t reta_query;
703  eth_get_reg_t get_reg;
704  eth_get_eeprom_length_t get_eeprom_length;
705  eth_get_eeprom_t get_eeprom;
706  eth_set_eeprom_t set_eeprom;
708  eth_get_module_info_t get_module_info;
710  eth_get_module_eeprom_t get_module_eeprom;
713  eth_filter_ctrl_t filter_ctrl;
715  eth_get_dcb_info get_dcb_info;
717  eth_timesync_enable_t timesync_enable;
719  eth_timesync_disable_t timesync_disable;
721  eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp;
723  eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp;
725  eth_timesync_adjust_time timesync_adjust_time;
726  eth_timesync_read_time timesync_read_time;
727  eth_timesync_write_time timesync_write_time;
729  eth_read_clock read_clock;
730 
731  eth_xstats_get_by_id_t xstats_get_by_id;
733  eth_xstats_get_names_by_id_t xstats_get_names_by_id;
736  eth_tm_ops_get_t tm_ops_get;
739  eth_mtr_ops_get_t mtr_ops_get;
742  eth_pool_ops_supported_t pool_ops_supported;
745  eth_hairpin_cap_get_t hairpin_cap_get;
747  eth_rx_hairpin_queue_setup_t rx_hairpin_queue_setup;
749  eth_tx_hairpin_queue_setup_t tx_hairpin_queue_setup;
751 };
752 
758 struct rte_eth_rxtx_callback {
759  struct rte_eth_rxtx_callback *next;
760  union{
763  } fn;
764  void *param;
765 };
766 
777 struct rte_eth_dev {
778  eth_rx_burst_t rx_pkt_burst;
779  eth_tx_burst_t tx_pkt_burst;
780  eth_tx_prep_t tx_pkt_prepare;
786  struct rte_eth_dev_data *data;
787  void *process_private;
788  const struct eth_dev_ops *dev_ops;
789  struct rte_device *device;
790  struct rte_intr_handle *intr_handle;
792  struct rte_eth_dev_cb_list link_intr_cbs;
797  struct rte_eth_rxtx_callback *post_rx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
802  struct rte_eth_rxtx_callback *pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
803  enum rte_eth_dev_state state;
804  void *security_ctx;
806  uint64_t reserved_64s[4];
807  void *reserved_ptrs[4];
809 
810 struct rte_eth_dev_sriov;
811 struct rte_eth_dev_owner;
812 
820 struct rte_eth_dev_data {
821  char name[RTE_ETH_NAME_MAX_LEN];
823  void **rx_queues;
824  void **tx_queues;
825  uint16_t nb_rx_queues;
826  uint16_t nb_tx_queues;
828  struct rte_eth_dev_sriov sriov;
830  void *dev_private;
835  struct rte_eth_link dev_link;
836  struct rte_eth_conf dev_conf;
837  uint16_t mtu;
838  uint32_t min_rx_buf_size;
841  uint64_t rx_mbuf_alloc_failed;
842  struct rte_ether_addr *mac_addrs;
846  uint64_t mac_pool_sel[ETH_NUM_RECEIVE_MAC_ADDR];
848  struct rte_ether_addr *hash_mac_addrs;
852  uint16_t port_id;
854  __extension__
855  uint8_t promiscuous : 1,
856  scattered_rx : 1,
857  all_multicast : 1,
858  dev_started : 1,
859  lro : 1;
860  uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
862  uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
864  uint32_t dev_flags;
865  enum rte_kernel_driver kdrv;
866  int numa_node;
867  struct rte_vlan_filter_conf vlan_filter_conf;
869  struct rte_eth_dev_owner owner;
870  uint16_t representor_id;
875  uint64_t reserved_64s[4];
876  void *reserved_ptrs[4];
878 
884 extern struct rte_eth_dev rte_eth_devices[];
885 
886 #endif /* _RTE_ETHDEV_CORE_H_ */
uint16_t txq
rte_filter_op
Definition: rte_eth_ctrl.h:47
#define ETH_NUM_RECEIVE_MAC_ADDR
Definition: rte_ethdev.h:637
int(* eth_is_removed_t)(struct rte_eth_dev *dev)
uint16_t(* rte_tx_callback_fn)(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], uint16_t nb_pkts, void *user_param)
Definition: rte_ethdev.h:1464
rte_kernel_driver
Definition: rte_dev.h:60
rte_eth_dev_state
Definition: rte_ethdev.h:1470
rte_vlan_type
Definition: rte_ethdev.h:416
rte_filter_type
Definition: rte_eth_ctrl.h:29
#define __rte_cache_aligned
Definition: rte_common.h:322
TAILQ_HEAD(vdev_driver_list, rte_vdev_driver)
uint16_t(* rte_rx_callback_fn)(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], uint16_t nb_pkts, uint16_t max_pkts, void *user_param)
Definition: rte_ethdev.h:1440