DPDK  19.08.0-rc0
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 rte_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 rte_ether_addr *mac_addr);
262 typedef int (*eth_uc_hash_table_set_t)(struct rte_eth_dev *dev,
263  struct rte_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 rte_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_read_clock)(struct rte_eth_dev *dev,
326  uint64_t *timestamp);
329 typedef int (*eth_get_reg_t)(struct rte_eth_dev *dev,
330  struct rte_dev_reg_info *info);
333 typedef int (*eth_get_eeprom_length_t)(struct rte_eth_dev *dev);
336 typedef int (*eth_get_eeprom_t)(struct rte_eth_dev *dev,
337  struct rte_dev_eeprom_info *info);
340 typedef int (*eth_set_eeprom_t)(struct rte_eth_dev *dev,
341  struct rte_dev_eeprom_info *info);
344 typedef int (*eth_get_module_info_t)(struct rte_eth_dev *dev,
345  struct rte_eth_dev_module_info *modinfo);
348 typedef int (*eth_get_module_eeprom_t)(struct rte_eth_dev *dev,
349  struct rte_dev_eeprom_info *info);
352 typedef int (*eth_l2_tunnel_eth_type_conf_t)
353  (struct rte_eth_dev *dev, struct rte_eth_l2_tunnel_conf *l2_tunnel);
356 typedef int (*eth_l2_tunnel_offload_set_t)
357  (struct rte_eth_dev *dev,
358  struct rte_eth_l2_tunnel_conf *l2_tunnel,
359  uint32_t mask,
360  uint8_t en);
364 typedef int (*eth_filter_ctrl_t)(struct rte_eth_dev *dev,
365  enum rte_filter_type filter_type,
366  enum rte_filter_op filter_op,
367  void *arg);
370 typedef int (*eth_tm_ops_get_t)(struct rte_eth_dev *dev, void *ops);
373 typedef int (*eth_mtr_ops_get_t)(struct rte_eth_dev *dev, void *ops);
376 typedef int (*eth_get_dcb_info)(struct rte_eth_dev *dev,
377  struct rte_eth_dcb_info *dcb_info);
380 typedef int (*eth_pool_ops_supported_t)(struct rte_eth_dev *dev,
381  const char *pool);
387 struct eth_dev_ops {
388  eth_dev_configure_t dev_configure;
389  eth_dev_start_t dev_start;
390  eth_dev_stop_t dev_stop;
391  eth_dev_set_link_up_t dev_set_link_up;
392  eth_dev_set_link_down_t dev_set_link_down;
393  eth_dev_close_t dev_close;
394  eth_dev_reset_t dev_reset;
395  eth_link_update_t link_update;
396  eth_is_removed_t is_removed;
399  eth_promiscuous_enable_t promiscuous_enable;
400  eth_promiscuous_disable_t promiscuous_disable;
401  eth_allmulticast_enable_t allmulticast_enable;
402  eth_allmulticast_disable_t allmulticast_disable;
403  eth_mac_addr_remove_t mac_addr_remove;
404  eth_mac_addr_add_t mac_addr_add;
405  eth_mac_addr_set_t mac_addr_set;
406  eth_set_mc_addr_list_t set_mc_addr_list;
407  mtu_set_t mtu_set;
409  eth_stats_get_t stats_get;
410  eth_stats_reset_t stats_reset;
411  eth_xstats_get_t xstats_get;
412  eth_xstats_reset_t xstats_reset;
413  eth_xstats_get_names_t xstats_get_names;
415  eth_queue_stats_mapping_set_t queue_stats_mapping_set;
418  eth_dev_infos_get_t dev_infos_get;
419  eth_rxq_info_get_t rxq_info_get;
420  eth_txq_info_get_t txq_info_get;
421  eth_fw_version_get_t fw_version_get;
422  eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
425  vlan_filter_set_t vlan_filter_set;
426  vlan_tpid_set_t vlan_tpid_set;
427  vlan_strip_queue_set_t vlan_strip_queue_set;
428  vlan_offload_set_t vlan_offload_set;
429  vlan_pvid_set_t vlan_pvid_set;
431  eth_queue_start_t rx_queue_start;
432  eth_queue_stop_t rx_queue_stop;
433  eth_queue_start_t tx_queue_start;
434  eth_queue_stop_t tx_queue_stop;
435  eth_rx_queue_setup_t rx_queue_setup;
436  eth_queue_release_t rx_queue_release;
437  eth_rx_queue_count_t rx_queue_count;
439  eth_rx_descriptor_done_t rx_descriptor_done;
440  eth_rx_descriptor_status_t rx_descriptor_status;
442  eth_tx_descriptor_status_t tx_descriptor_status;
444  eth_rx_enable_intr_t rx_queue_intr_enable;
445  eth_rx_disable_intr_t rx_queue_intr_disable;
446  eth_tx_queue_setup_t tx_queue_setup;
447  eth_queue_release_t tx_queue_release;
448  eth_tx_done_cleanup_t tx_done_cleanup;
450  eth_dev_led_on_t dev_led_on;
451  eth_dev_led_off_t dev_led_off;
453  flow_ctrl_get_t flow_ctrl_get;
454  flow_ctrl_set_t flow_ctrl_set;
455  priority_flow_ctrl_set_t priority_flow_ctrl_set;
457  eth_uc_hash_table_set_t uc_hash_table_set;
458  eth_uc_all_hash_table_set_t uc_all_hash_table_set;
460  eth_mirror_rule_set_t mirror_rule_set;
461  eth_mirror_rule_reset_t mirror_rule_reset;
463  eth_udp_tunnel_port_add_t udp_tunnel_port_add;
464  eth_udp_tunnel_port_del_t udp_tunnel_port_del;
465  eth_l2_tunnel_eth_type_conf_t l2_tunnel_eth_type_conf;
467  eth_l2_tunnel_offload_set_t l2_tunnel_offload_set;
470  eth_set_queue_rate_limit_t set_queue_rate_limit;
472  rss_hash_update_t rss_hash_update;
473  rss_hash_conf_get_t rss_hash_conf_get;
474  reta_update_t reta_update;
475  reta_query_t reta_query;
477  eth_get_reg_t get_reg;
478  eth_get_eeprom_length_t get_eeprom_length;
479  eth_get_eeprom_t get_eeprom;
480  eth_set_eeprom_t set_eeprom;
482  eth_get_module_info_t get_module_info;
484  eth_get_module_eeprom_t get_module_eeprom;
487  eth_filter_ctrl_t filter_ctrl;
489  eth_get_dcb_info get_dcb_info;
491  eth_timesync_enable_t timesync_enable;
493  eth_timesync_disable_t timesync_disable;
495  eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp;
497  eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp;
499  eth_timesync_adjust_time timesync_adjust_time;
500  eth_timesync_read_time timesync_read_time;
501  eth_timesync_write_time timesync_write_time;
503  eth_read_clock read_clock;
504 
505  eth_xstats_get_by_id_t xstats_get_by_id;
507  eth_xstats_get_names_by_id_t xstats_get_names_by_id;
510  eth_tm_ops_get_t tm_ops_get;
513  eth_mtr_ops_get_t mtr_ops_get;
516  eth_pool_ops_supported_t pool_ops_supported;
518 };
519 
525 struct rte_eth_rxtx_callback {
526  struct rte_eth_rxtx_callback *next;
527  union{
530  } fn;
531  void *param;
532 };
533 
544 struct rte_eth_dev {
545  eth_rx_burst_t rx_pkt_burst;
546  eth_tx_burst_t tx_pkt_burst;
547  eth_tx_prep_t tx_pkt_prepare;
553  struct rte_eth_dev_data *data;
554  void *process_private;
555  const struct eth_dev_ops *dev_ops;
556  struct rte_device *device;
557  struct rte_intr_handle *intr_handle;
559  struct rte_eth_dev_cb_list link_intr_cbs;
564  struct rte_eth_rxtx_callback *post_rx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
569  struct rte_eth_rxtx_callback *pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
570  enum rte_eth_dev_state state;
571  void *security_ctx;
573 
574 struct rte_eth_dev_sriov;
575 struct rte_eth_dev_owner;
576 
584 struct rte_eth_dev_data {
585  char name[RTE_ETH_NAME_MAX_LEN];
587  void **rx_queues;
588  void **tx_queues;
589  uint16_t nb_rx_queues;
590  uint16_t nb_tx_queues;
592  struct rte_eth_dev_sriov sriov;
594  void *dev_private;
599  struct rte_eth_link dev_link;
600  struct rte_eth_conf dev_conf;
601  uint16_t mtu;
602  uint32_t min_rx_buf_size;
605  uint64_t rx_mbuf_alloc_failed;
606  struct rte_ether_addr *mac_addrs;
610  uint64_t mac_pool_sel[ETH_NUM_RECEIVE_MAC_ADDR];
612  struct rte_ether_addr *hash_mac_addrs;
616  uint16_t port_id;
618  __extension__
619  uint8_t promiscuous : 1,
620  scattered_rx : 1,
621  all_multicast : 1,
622  dev_started : 1,
623  lro : 1;
624  uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
626  uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
628  uint32_t dev_flags;
629  enum rte_kernel_driver kdrv;
630  int numa_node;
631  struct rte_vlan_filter_conf vlan_filter_conf;
633  struct rte_eth_dev_owner owner;
634  uint16_t representor_id;
639 
645 extern struct rte_eth_dev rte_eth_devices[];
646 
647 #endif /* _RTE_ETHDEV_CORE_H_ */
uint16_t txq
Definition: rte_mbuf.h:642
rte_filter_op
Definition: rte_eth_ctrl.h:46
#define ETH_NUM_RECEIVE_MAC_ADDR
Definition: rte_ethdev.h:595
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:1354
rte_kernel_driver
Definition: rte_dev.h:60
rte_eth_dev_state
Definition: rte_ethdev.h:1360
rte_vlan_type
Definition: rte_ethdev.h:411
#define __rte_cache_aligned
Definition: rte_memory.h:66
rte_filter_type
Definition: rte_eth_ctrl.h:28
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:1330