DPDK  19.02.0
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);
55 typedef void (*eth_promiscuous_enable_t)(struct rte_eth_dev *dev);
58 typedef void (*eth_promiscuous_disable_t)(struct rte_eth_dev *dev);
61 typedef void (*eth_allmulticast_enable_t)(struct rte_eth_dev *dev);
64 typedef void (*eth_allmulticast_disable_t)(struct rte_eth_dev *dev);
67 typedef int (*eth_link_update_t)(struct rte_eth_dev *dev,
68  int wait_to_complete);
71 typedef int (*eth_stats_get_t)(struct rte_eth_dev *dev,
72  struct rte_eth_stats *igb_stats);
75 typedef void (*eth_stats_reset_t)(struct rte_eth_dev *dev);
78 typedef int (*eth_xstats_get_t)(struct rte_eth_dev *dev,
79  struct rte_eth_xstat *stats, unsigned n);
82 typedef int (*eth_xstats_get_by_id_t)(struct rte_eth_dev *dev,
83  const uint64_t *ids,
84  uint64_t *values,
85  unsigned int n);
88 typedef void (*eth_xstats_reset_t)(struct rte_eth_dev *dev);
91 typedef int (*eth_xstats_get_names_t)(struct rte_eth_dev *dev,
92  struct rte_eth_xstat_name *xstats_names, unsigned size);
95 typedef int (*eth_xstats_get_names_by_id_t)(struct rte_eth_dev *dev,
96  struct rte_eth_xstat_name *xstats_names, const uint64_t *ids,
97  unsigned int size);
100 typedef int (*eth_queue_stats_mapping_set_t)(struct rte_eth_dev *dev,
101  uint16_t queue_id,
102  uint8_t stat_idx,
103  uint8_t is_rx);
106 typedef void (*eth_dev_infos_get_t)(struct rte_eth_dev *dev,
107  struct rte_eth_dev_info *dev_info);
110 typedef const uint32_t *(*eth_dev_supported_ptypes_get_t)(struct rte_eth_dev *dev);
113 typedef int (*eth_queue_start_t)(struct rte_eth_dev *dev,
114  uint16_t queue_id);
117 typedef int (*eth_queue_stop_t)(struct rte_eth_dev *dev,
118  uint16_t queue_id);
121 typedef int (*eth_rx_queue_setup_t)(struct rte_eth_dev *dev,
122  uint16_t rx_queue_id,
123  uint16_t nb_rx_desc,
124  unsigned int socket_id,
125  const struct rte_eth_rxconf *rx_conf,
126  struct rte_mempool *mb_pool);
129 typedef int (*eth_tx_queue_setup_t)(struct rte_eth_dev *dev,
130  uint16_t tx_queue_id,
131  uint16_t nb_tx_desc,
132  unsigned int socket_id,
133  const struct rte_eth_txconf *tx_conf);
136 typedef int (*eth_rx_enable_intr_t)(struct rte_eth_dev *dev,
137  uint16_t rx_queue_id);
140 typedef int (*eth_rx_disable_intr_t)(struct rte_eth_dev *dev,
141  uint16_t rx_queue_id);
144 typedef void (*eth_queue_release_t)(void *queue);
147 typedef uint32_t (*eth_rx_queue_count_t)(struct rte_eth_dev *dev,
148  uint16_t rx_queue_id);
151 typedef int (*eth_rx_descriptor_done_t)(void *rxq, uint16_t offset);
154 typedef int (*eth_rx_descriptor_status_t)(void *rxq, uint16_t offset);
157 typedef int (*eth_tx_descriptor_status_t)(void *txq, uint16_t offset);
160 typedef int (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
161  char *fw_version, size_t fw_size);
164 typedef int (*eth_tx_done_cleanup_t)(void *txq, uint32_t free_cnt);
167 typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
168  uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
169 
170 typedef void (*eth_txq_info_get_t)(struct rte_eth_dev *dev,
171  uint16_t tx_queue_id, struct rte_eth_txq_info *qinfo);
172 
173 typedef int (*mtu_set_t)(struct rte_eth_dev *dev, uint16_t mtu);
176 typedef int (*vlan_filter_set_t)(struct rte_eth_dev *dev,
177  uint16_t vlan_id,
178  int on);
181 typedef int (*vlan_tpid_set_t)(struct rte_eth_dev *dev,
182  enum rte_vlan_type type, uint16_t tpid);
185 typedef int (*vlan_offload_set_t)(struct rte_eth_dev *dev, int mask);
188 typedef int (*vlan_pvid_set_t)(struct rte_eth_dev *dev,
189  uint16_t vlan_id,
190  int on);
193 typedef void (*vlan_strip_queue_set_t)(struct rte_eth_dev *dev,
194  uint16_t rx_queue_id,
195  int on);
198 typedef uint16_t (*eth_rx_burst_t)(void *rxq,
199  struct rte_mbuf **rx_pkts,
200  uint16_t nb_pkts);
203 typedef uint16_t (*eth_tx_burst_t)(void *txq,
204  struct rte_mbuf **tx_pkts,
205  uint16_t nb_pkts);
208 typedef uint16_t (*eth_tx_prep_t)(void *txq,
209  struct rte_mbuf **tx_pkts,
210  uint16_t nb_pkts);
213 typedef int (*flow_ctrl_get_t)(struct rte_eth_dev *dev,
214  struct rte_eth_fc_conf *fc_conf);
217 typedef int (*flow_ctrl_set_t)(struct rte_eth_dev *dev,
218  struct rte_eth_fc_conf *fc_conf);
221 typedef int (*priority_flow_ctrl_set_t)(struct rte_eth_dev *dev,
222  struct rte_eth_pfc_conf *pfc_conf);
225 typedef int (*reta_update_t)(struct rte_eth_dev *dev,
226  struct rte_eth_rss_reta_entry64 *reta_conf,
227  uint16_t reta_size);
230 typedef int (*reta_query_t)(struct rte_eth_dev *dev,
231  struct rte_eth_rss_reta_entry64 *reta_conf,
232  uint16_t reta_size);
235 typedef int (*rss_hash_update_t)(struct rte_eth_dev *dev,
236  struct rte_eth_rss_conf *rss_conf);
239 typedef int (*rss_hash_conf_get_t)(struct rte_eth_dev *dev,
240  struct rte_eth_rss_conf *rss_conf);
243 typedef int (*eth_dev_led_on_t)(struct rte_eth_dev *dev);
246 typedef int (*eth_dev_led_off_t)(struct rte_eth_dev *dev);
249 typedef void (*eth_mac_addr_remove_t)(struct rte_eth_dev *dev, uint32_t index);
252 typedef int (*eth_mac_addr_add_t)(struct rte_eth_dev *dev,
253  struct ether_addr *mac_addr,
254  uint32_t index,
255  uint32_t vmdq);
258 typedef int (*eth_mac_addr_set_t)(struct rte_eth_dev *dev,
259  struct ether_addr *mac_addr);
262 typedef int (*eth_uc_hash_table_set_t)(struct rte_eth_dev *dev,
263  struct ether_addr *mac_addr,
264  uint8_t on);
267 typedef int (*eth_uc_all_hash_table_set_t)(struct rte_eth_dev *dev,
268  uint8_t on);
271 typedef int (*eth_set_queue_rate_limit_t)(struct rte_eth_dev *dev,
272  uint16_t queue_idx,
273  uint16_t tx_rate);
276 typedef int (*eth_mirror_rule_set_t)(struct rte_eth_dev *dev,
277  struct rte_eth_mirror_conf *mirror_conf,
278  uint8_t rule_id,
279  uint8_t on);
282 typedef int (*eth_mirror_rule_reset_t)(struct rte_eth_dev *dev,
283  uint8_t rule_id);
286 typedef int (*eth_udp_tunnel_port_add_t)(struct rte_eth_dev *dev,
287  struct rte_eth_udp_tunnel *tunnel_udp);
290 typedef int (*eth_udp_tunnel_port_del_t)(struct rte_eth_dev *dev,
291  struct rte_eth_udp_tunnel *tunnel_udp);
294 typedef int (*eth_set_mc_addr_list_t)(struct rte_eth_dev *dev,
295  struct ether_addr *mc_addr_set,
296  uint32_t nb_mc_addr);
299 typedef int (*eth_timesync_enable_t)(struct rte_eth_dev *dev);
302 typedef int (*eth_timesync_disable_t)(struct rte_eth_dev *dev);
305 typedef int (*eth_timesync_read_rx_timestamp_t)(struct rte_eth_dev *dev,
306  struct timespec *timestamp,
307  uint32_t flags);
310 typedef int (*eth_timesync_read_tx_timestamp_t)(struct rte_eth_dev *dev,
311  struct timespec *timestamp);
314 typedef int (*eth_timesync_adjust_time)(struct rte_eth_dev *dev, int64_t);
317 typedef int (*eth_timesync_read_time)(struct rte_eth_dev *dev,
318  struct timespec *timestamp);
321 typedef int (*eth_timesync_write_time)(struct rte_eth_dev *dev,
322  const struct timespec *timestamp);
325 typedef int (*eth_get_reg_t)(struct rte_eth_dev *dev,
326  struct rte_dev_reg_info *info);
329 typedef int (*eth_get_eeprom_length_t)(struct rte_eth_dev *dev);
332 typedef int (*eth_get_eeprom_t)(struct rte_eth_dev *dev,
333  struct rte_dev_eeprom_info *info);
336 typedef int (*eth_set_eeprom_t)(struct rte_eth_dev *dev,
337  struct rte_dev_eeprom_info *info);
340 typedef int (*eth_get_module_info_t)(struct rte_eth_dev *dev,
341  struct rte_eth_dev_module_info *modinfo);
344 typedef int (*eth_get_module_eeprom_t)(struct rte_eth_dev *dev,
345  struct rte_dev_eeprom_info *info);
348 typedef int (*eth_l2_tunnel_eth_type_conf_t)
349  (struct rte_eth_dev *dev, struct rte_eth_l2_tunnel_conf *l2_tunnel);
352 typedef int (*eth_l2_tunnel_offload_set_t)
353  (struct rte_eth_dev *dev,
354  struct rte_eth_l2_tunnel_conf *l2_tunnel,
355  uint32_t mask,
356  uint8_t en);
360 typedef int (*eth_filter_ctrl_t)(struct rte_eth_dev *dev,
361  enum rte_filter_type filter_type,
362  enum rte_filter_op filter_op,
363  void *arg);
366 typedef int (*eth_tm_ops_get_t)(struct rte_eth_dev *dev, void *ops);
369 typedef int (*eth_mtr_ops_get_t)(struct rte_eth_dev *dev, void *ops);
372 typedef int (*eth_get_dcb_info)(struct rte_eth_dev *dev,
373  struct rte_eth_dcb_info *dcb_info);
376 typedef int (*eth_pool_ops_supported_t)(struct rte_eth_dev *dev,
377  const char *pool);
383 struct eth_dev_ops {
384  eth_dev_configure_t dev_configure;
385  eth_dev_start_t dev_start;
386  eth_dev_stop_t dev_stop;
387  eth_dev_set_link_up_t dev_set_link_up;
388  eth_dev_set_link_down_t dev_set_link_down;
389  eth_dev_close_t dev_close;
390  eth_dev_reset_t dev_reset;
391  eth_link_update_t link_update;
392  eth_is_removed_t is_removed;
395  eth_promiscuous_enable_t promiscuous_enable;
396  eth_promiscuous_disable_t promiscuous_disable;
397  eth_allmulticast_enable_t allmulticast_enable;
398  eth_allmulticast_disable_t allmulticast_disable;
399  eth_mac_addr_remove_t mac_addr_remove;
400  eth_mac_addr_add_t mac_addr_add;
401  eth_mac_addr_set_t mac_addr_set;
402  eth_set_mc_addr_list_t set_mc_addr_list;
403  mtu_set_t mtu_set;
405  eth_stats_get_t stats_get;
406  eth_stats_reset_t stats_reset;
407  eth_xstats_get_t xstats_get;
408  eth_xstats_reset_t xstats_reset;
409  eth_xstats_get_names_t xstats_get_names;
411  eth_queue_stats_mapping_set_t queue_stats_mapping_set;
414  eth_dev_infos_get_t dev_infos_get;
415  eth_rxq_info_get_t rxq_info_get;
416  eth_txq_info_get_t txq_info_get;
417  eth_fw_version_get_t fw_version_get;
418  eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
421  vlan_filter_set_t vlan_filter_set;
422  vlan_tpid_set_t vlan_tpid_set;
423  vlan_strip_queue_set_t vlan_strip_queue_set;
424  vlan_offload_set_t vlan_offload_set;
425  vlan_pvid_set_t vlan_pvid_set;
427  eth_queue_start_t rx_queue_start;
428  eth_queue_stop_t rx_queue_stop;
429  eth_queue_start_t tx_queue_start;
430  eth_queue_stop_t tx_queue_stop;
431  eth_rx_queue_setup_t rx_queue_setup;
432  eth_queue_release_t rx_queue_release;
433  eth_rx_queue_count_t rx_queue_count;
435  eth_rx_descriptor_done_t rx_descriptor_done;
436  eth_rx_descriptor_status_t rx_descriptor_status;
438  eth_tx_descriptor_status_t tx_descriptor_status;
440  eth_rx_enable_intr_t rx_queue_intr_enable;
441  eth_rx_disable_intr_t rx_queue_intr_disable;
442  eth_tx_queue_setup_t tx_queue_setup;
443  eth_queue_release_t tx_queue_release;
444  eth_tx_done_cleanup_t tx_done_cleanup;
446  eth_dev_led_on_t dev_led_on;
447  eth_dev_led_off_t dev_led_off;
449  flow_ctrl_get_t flow_ctrl_get;
450  flow_ctrl_set_t flow_ctrl_set;
451  priority_flow_ctrl_set_t priority_flow_ctrl_set;
453  eth_uc_hash_table_set_t uc_hash_table_set;
454  eth_uc_all_hash_table_set_t uc_all_hash_table_set;
456  eth_mirror_rule_set_t mirror_rule_set;
457  eth_mirror_rule_reset_t mirror_rule_reset;
459  eth_udp_tunnel_port_add_t udp_tunnel_port_add;
460  eth_udp_tunnel_port_del_t udp_tunnel_port_del;
461  eth_l2_tunnel_eth_type_conf_t l2_tunnel_eth_type_conf;
463  eth_l2_tunnel_offload_set_t l2_tunnel_offload_set;
466  eth_set_queue_rate_limit_t set_queue_rate_limit;
468  rss_hash_update_t rss_hash_update;
469  rss_hash_conf_get_t rss_hash_conf_get;
470  reta_update_t reta_update;
471  reta_query_t reta_query;
473  eth_get_reg_t get_reg;
474  eth_get_eeprom_length_t get_eeprom_length;
475  eth_get_eeprom_t get_eeprom;
476  eth_set_eeprom_t set_eeprom;
478  eth_get_module_info_t get_module_info;
480  eth_get_module_eeprom_t get_module_eeprom;
483  eth_filter_ctrl_t filter_ctrl;
485  eth_get_dcb_info get_dcb_info;
487  eth_timesync_enable_t timesync_enable;
489  eth_timesync_disable_t timesync_disable;
491  eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp;
493  eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp;
495  eth_timesync_adjust_time timesync_adjust_time;
496  eth_timesync_read_time timesync_read_time;
497  eth_timesync_write_time timesync_write_time;
499  eth_xstats_get_by_id_t xstats_get_by_id;
501  eth_xstats_get_names_by_id_t xstats_get_names_by_id;
504  eth_tm_ops_get_t tm_ops_get;
507  eth_mtr_ops_get_t mtr_ops_get;
510  eth_pool_ops_supported_t pool_ops_supported;
512 };
513 
519 struct rte_eth_rxtx_callback {
520  struct rte_eth_rxtx_callback *next;
521  union{
524  } fn;
525  void *param;
526 };
527 
538 struct rte_eth_dev {
539  eth_rx_burst_t rx_pkt_burst;
540  eth_tx_burst_t tx_pkt_burst;
541  eth_tx_prep_t tx_pkt_prepare;
547  struct rte_eth_dev_data *data;
548  void *process_private;
549  const struct eth_dev_ops *dev_ops;
550  struct rte_device *device;
551  struct rte_intr_handle *intr_handle;
553  struct rte_eth_dev_cb_list link_intr_cbs;
558  struct rte_eth_rxtx_callback *post_rx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
563  struct rte_eth_rxtx_callback *pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
564  enum rte_eth_dev_state state;
565  void *security_ctx;
567 
568 struct rte_eth_dev_sriov;
569 struct rte_eth_dev_owner;
570 
578 struct rte_eth_dev_data {
579  char name[RTE_ETH_NAME_MAX_LEN];
581  void **rx_queues;
582  void **tx_queues;
583  uint16_t nb_rx_queues;
584  uint16_t nb_tx_queues;
586  struct rte_eth_dev_sriov sriov;
588  void *dev_private;
593  struct rte_eth_link dev_link;
594  struct rte_eth_conf dev_conf;
595  uint16_t mtu;
596  uint32_t min_rx_buf_size;
599  uint64_t rx_mbuf_alloc_failed;
600  struct ether_addr *mac_addrs;
604  uint64_t mac_pool_sel[ETH_NUM_RECEIVE_MAC_ADDR];
606  struct ether_addr *hash_mac_addrs;
610  uint16_t port_id;
612  __extension__
613  uint8_t promiscuous : 1,
614  scattered_rx : 1,
615  all_multicast : 1,
616  dev_started : 1,
617  lro : 1;
618  uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
620  uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
622  uint32_t dev_flags;
623  enum rte_kernel_driver kdrv;
624  int numa_node;
625  struct rte_vlan_filter_conf vlan_filter_conf;
627  struct rte_eth_dev_owner owner;
628  uint16_t representor_id;
633 
639 extern struct rte_eth_dev rte_eth_devices[];
640 
641 #endif /* _RTE_ETHDEV_CORE_H_ */