CNDP  22.08.0
pktdev_core.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2019-2022 Intel Corporation
3  */
4 
5 #ifndef __PKTDEV_CORE_H_
6 #define __PKTDEV_CORE_H_
7 
8 #include <stdbool.h>
20 /*
21  * Definitions of all functions exported by an Ethernet driver through the
22  * the generic structure of type *pktdev_ops* supplied in the *cne_pktdev*
23  * structure associated with an Ethernet device.
24  */
25 struct cne_pktdev;
26 
27 typedef int (*pkt_dev_start_t)(struct cne_pktdev *dev);
30 typedef void (*pkt_dev_stop_t)(struct cne_pktdev *dev);
33 typedef int (*pkt_dev_admin_st_up_t)(struct cne_pktdev *dev);
36 typedef int (*pkt_dev_admin_st_down_t)(struct cne_pktdev *dev);
39 typedef void (*pkt_dev_close_t)(struct cne_pktdev *dev);
42 typedef int (*pkt_dev_infos_get_t)(struct cne_pktdev *dev, struct pktdev_info *dev_info);
45 typedef int (*eth_link_update_t)(struct cne_pktdev *dev, int wait_to_complete);
48 typedef int (*eth_stats_get_t)(struct cne_pktdev *dev, lport_stats_t *igb_stats);
70 typedef int (*eth_stats_reset_t)(struct cne_pktdev *dev);
71 
82 typedef int (*eth_tx_done_cleanup_t)(void *txq, uint32_t free_cnt);
83 
96 typedef uint16_t (*eth_rx_burst_t)(void *rxq, pktmbuf_t **rx_pkts, uint16_t nb_pkts);
97 
110 typedef uint16_t (*eth_tx_burst_t)(void *txq, pktmbuf_t **tx_pkts, uint16_t nb_pkts);
111 
124 typedef uint16_t (*eth_tx_prep_t)(void *txq, pktmbuf_t **tx_pkts, uint16_t nb_pkts);
125 
136 typedef int (*eth_mac_addr_set_t)(struct cne_pktdev *dev, struct ether_addr *mac_addr);
137 
150 typedef int (*eth_pkt_alloc)(struct cne_pktdev *dev, pktmbuf_t **bufs, uint16_t nb_pkts);
151 
156  PKTDEV_UNUSED = 0,
158 };
159 
163 struct pktdev_ops {
164  pkt_dev_admin_st_up_t admin_state_up;
165  pkt_dev_admin_st_down_t admin_state_down;
166  pkt_dev_close_t dev_close;
167  pkt_dev_infos_get_t dev_infos_get;
168  eth_mac_addr_set_t mac_addr_set;
169  eth_link_update_t link_update;
170  eth_stats_get_t stats_get;
171  eth_stats_reset_t stats_reset;
172  eth_tx_done_cleanup_t tx_done_cleanup;
173  eth_pkt_alloc pkt_alloc;
174 };
175 
186 struct cne_pktdev {
187  eth_rx_burst_t rx_pkt_burst;
188  eth_tx_burst_t tx_pkt_burst;
189  eth_tx_prep_t tx_pkt_prepare;
190  struct pktdev_data *data;
191  struct pktdev_driver *drv;
192  void *process_private;
193  const struct pktdev_ops *dev_ops;
194  enum pktdev_state state;
195 } __cne_cache_aligned;
196 
197 extern struct cne_pktdev pktdev_devices[CNE_MAX_ETHPORTS];
198 
199 #define PKTDEV_NAME_MAX_LEN 16
207 struct pktdev_data {
208  char name[PKTDEV_NAME_MAX_LEN];
209  char ifname[PKTDEV_NAME_MAX_LEN];
210  void *rx_queue;
211  void *tx_queue;
212  bool admin_state;
213  void *dev_private;
214  uint32_t min_rx_buf_size;
215  struct ether_addr *mac_addr;
216  uint16_t lport_id;
217  uint16_t numa_node;
218  struct offloads *offloads;
219 } __cne_cache_aligned;
220 
226 extern struct cne_pktdev cne_pktdevices[];
227 
228 #endif /* __PKTDEV_CORE_H_ */
pktdev_state
Definition: pktdev_core.h:155
@ PKTDEV_ACTIVE
Definition: pktdev_core.h:157