1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2018 Gaëtan Rivet 3 */ 4 5 #ifndef _ETH_PRIVATE_H_ 6 #define _ETH_PRIVATE_H_ 7 8 #include <sys/queue.h> 9 10 #include <rte_malloc.h> 11 #include <rte_os_shim.h> 12 13 #include "rte_ethdev.h" 14 15 struct eth_dev_shared { 16 uint64_t next_owner_id; 17 rte_spinlock_t ownership_lock; 18 struct rte_eth_dev_data data[RTE_MAX_ETHPORTS]; 19 }; 20 21 extern struct eth_dev_shared *eth_dev_shared_data; 22 23 /** 24 * The user application callback description. 25 * 26 * It contains callback address to be registered by user application, 27 * the pointer to the parameters for callback, and the event type. 28 */ 29 struct rte_eth_dev_callback { 30 TAILQ_ENTRY(rte_eth_dev_callback) next; /**< Callbacks list */ 31 rte_eth_dev_cb_fn cb_fn; /**< Callback address */ 32 void *cb_arg; /**< Parameter for callback */ 33 void *ret_param; /**< Return parameter */ 34 enum rte_eth_event_type event; /**< Interrupt event type */ 35 uint32_t active; /**< Callback is executing */ 36 }; 37 38 extern rte_spinlock_t eth_dev_cb_lock; 39 40 /* Convert all error to -EIO if device is removed. */ 41 int eth_err(uint16_t port_id, int ret); 42 43 /* 44 * Convert rte_eth_dev pointer to port ID. 45 * NULL will be translated to RTE_MAX_ETHPORTS. 46 */ 47 uint16_t eth_dev_to_id(const struct rte_eth_dev *dev); 48 49 /* Generic rte_eth_dev comparison function. */ 50 typedef int (*rte_eth_cmp_t)(const struct rte_eth_dev *, const void *); 51 52 /* Generic rte_eth_dev iterator. */ 53 struct rte_eth_dev * 54 eth_find_device(const struct rte_eth_dev *_start, rte_eth_cmp_t cmp, 55 const void *data); 56 57 /* Parse devargs value for representor parameter. */ 58 int rte_eth_devargs_parse_representor_ports(char *str, void *data); 59 60 /* reset eth fast-path API to dummy values */ 61 void eth_dev_fp_ops_reset(struct rte_eth_fp_ops *fpo); 62 63 /* setup eth fast-path API to ethdev values */ 64 void eth_dev_fp_ops_setup(struct rte_eth_fp_ops *fpo, 65 const struct rte_eth_dev *dev); 66 67 68 void eth_dev_shared_data_prepare(void); 69 70 void eth_dev_rxq_release(struct rte_eth_dev *dev, uint16_t qid); 71 void eth_dev_txq_release(struct rte_eth_dev *dev, uint16_t qid); 72 int eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues); 73 int eth_dev_tx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues); 74 75 #endif /* _ETH_PRIVATE_H_ */ 76