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_eal_memconfig.h> 11 #include <rte_malloc.h> 12 #include <rte_os_shim.h> 13 14 #include "rte_ethdev.h" 15 16 struct eth_dev_shared { 17 uint64_t allocated_owners; 18 uint64_t next_owner_id; 19 uint64_t allocated_ports; 20 struct rte_eth_dev_data data[RTE_MAX_ETHPORTS]; 21 }; 22 23 /* Shared memory between primary and secondary processes. */ 24 extern struct eth_dev_shared *eth_dev_shared_data 25 __rte_guarded_by(rte_mcfg_ethdev_get_lock()); 26 27 /** 28 * The user application callback description. 29 * 30 * It contains callback address to be registered by user application, 31 * the pointer to the parameters for callback, and the event type. 32 */ 33 struct rte_eth_dev_callback { 34 TAILQ_ENTRY(rte_eth_dev_callback) next; /**< Callbacks list */ 35 rte_eth_dev_cb_fn cb_fn; /**< Callback address */ 36 void *cb_arg; /**< Parameter for callback */ 37 void *ret_param; /**< Return parameter */ 38 enum rte_eth_event_type event; /**< Interrupt event type */ 39 uint32_t active; /**< Callback is executing */ 40 }; 41 42 extern rte_spinlock_t eth_dev_cb_lock; 43 44 /* Convert all error to -EIO if device is removed. */ 45 int eth_err(uint16_t port_id, int ret); 46 47 /* 48 * Convert rte_eth_dev pointer to port ID. 49 * NULL will be translated to RTE_MAX_ETHPORTS. 50 */ 51 uint16_t eth_dev_to_id(const struct rte_eth_dev *dev); 52 53 /* Generic rte_eth_dev comparison function. */ 54 typedef int (*rte_eth_cmp_t)(const struct rte_eth_dev *, const void *); 55 56 /* Generic rte_eth_dev iterator. */ 57 struct rte_eth_dev * 58 eth_find_device(const struct rte_eth_dev *_start, rte_eth_cmp_t cmp, 59 const void *data); 60 61 /* Parse devargs value for representor parameter. */ 62 int rte_eth_devargs_parse_representor_ports(char *str, void *data); 63 64 /* reset eth fast-path API to dummy values */ 65 void eth_dev_fp_ops_reset(struct rte_eth_fp_ops *fpo); 66 67 /* setup eth fast-path API to ethdev values */ 68 void eth_dev_fp_ops_setup(struct rte_eth_fp_ops *fpo, 69 const struct rte_eth_dev *dev); 70 71 72 void *eth_dev_shared_data_prepare(void) 73 __rte_exclusive_locks_required(rte_mcfg_ethdev_get_lock()); 74 void eth_dev_shared_data_release(void) 75 __rte_exclusive_locks_required(rte_mcfg_ethdev_get_lock()); 76 77 void eth_dev_rxq_release(struct rte_eth_dev *dev, uint16_t qid); 78 void eth_dev_txq_release(struct rte_eth_dev *dev, uint16_t qid); 79 int eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues); 80 int eth_dev_tx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues); 81 82 #endif /* _ETH_PRIVATE_H_ */ 83