xref: /dpdk/lib/ethdev/ethdev_private.h (revision 4b4f810e)
199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
299a2dd95SBruce Richardson  * Copyright(c) 2018 Gaëtan Rivet
399a2dd95SBruce Richardson  */
499a2dd95SBruce Richardson 
599a2dd95SBruce Richardson #ifndef _ETH_PRIVATE_H_
699a2dd95SBruce Richardson #define _ETH_PRIVATE_H_
799a2dd95SBruce Richardson 
8*4b4f810eSFerruh Yigit #include <sys/queue.h>
9*4b4f810eSFerruh Yigit 
10*4b4f810eSFerruh Yigit #include <rte_malloc.h>
1199a2dd95SBruce Richardson #include <rte_os_shim.h>
1299a2dd95SBruce Richardson 
1399a2dd95SBruce Richardson #include "rte_ethdev.h"
1499a2dd95SBruce Richardson 
15*4b4f810eSFerruh Yigit struct eth_dev_shared {
16*4b4f810eSFerruh Yigit 	uint64_t next_owner_id;
17*4b4f810eSFerruh Yigit 	rte_spinlock_t ownership_lock;
18*4b4f810eSFerruh Yigit 	struct rte_eth_dev_data data[RTE_MAX_ETHPORTS];
19*4b4f810eSFerruh Yigit };
20*4b4f810eSFerruh Yigit 
21*4b4f810eSFerruh Yigit extern struct eth_dev_shared *eth_dev_shared_data;
22*4b4f810eSFerruh Yigit 
23*4b4f810eSFerruh Yigit /**
24*4b4f810eSFerruh Yigit  * The user application callback description.
25*4b4f810eSFerruh Yigit  *
26*4b4f810eSFerruh Yigit  * It contains callback address to be registered by user application,
27*4b4f810eSFerruh Yigit  * the pointer to the parameters for callback, and the event type.
28*4b4f810eSFerruh Yigit  */
29*4b4f810eSFerruh Yigit struct rte_eth_dev_callback {
30*4b4f810eSFerruh Yigit 	TAILQ_ENTRY(rte_eth_dev_callback) next; /**< Callbacks list */
31*4b4f810eSFerruh Yigit 	rte_eth_dev_cb_fn cb_fn;                /**< Callback address */
32*4b4f810eSFerruh Yigit 	void *cb_arg;                           /**< Parameter for callback */
33*4b4f810eSFerruh Yigit 	void *ret_param;                        /**< Return parameter */
34*4b4f810eSFerruh Yigit 	enum rte_eth_event_type event;          /**< Interrupt event type */
35*4b4f810eSFerruh Yigit 	uint32_t active;                        /**< Callback is executing */
36*4b4f810eSFerruh Yigit };
37*4b4f810eSFerruh Yigit 
38*4b4f810eSFerruh Yigit extern rte_spinlock_t eth_dev_cb_lock;
39*4b4f810eSFerruh Yigit 
4099a2dd95SBruce Richardson /*
415906be5aSAndrew Rybchenko  * Convert rte_eth_dev pointer to port ID.
4299a2dd95SBruce Richardson  * NULL will be translated to RTE_MAX_ETHPORTS.
4399a2dd95SBruce Richardson  */
4499a2dd95SBruce Richardson uint16_t eth_dev_to_id(const struct rte_eth_dev *dev);
4599a2dd95SBruce Richardson 
4699a2dd95SBruce Richardson /* Generic rte_eth_dev comparison function. */
4799a2dd95SBruce Richardson typedef int (*rte_eth_cmp_t)(const struct rte_eth_dev *, const void *);
4899a2dd95SBruce Richardson 
4999a2dd95SBruce Richardson /* Generic rte_eth_dev iterator. */
5099a2dd95SBruce Richardson struct rte_eth_dev *
5199a2dd95SBruce Richardson eth_find_device(const struct rte_eth_dev *_start, rte_eth_cmp_t cmp,
5299a2dd95SBruce Richardson 		const void *data);
5399a2dd95SBruce Richardson 
5499a2dd95SBruce Richardson /* Parse devargs value for representor parameter. */
5599a2dd95SBruce Richardson int rte_eth_devargs_parse_representor_ports(char *str, void *data);
5699a2dd95SBruce Richardson 
57c87d435aSKonstantin Ananyev /* reset eth fast-path API to dummy values */
58c87d435aSKonstantin Ananyev void eth_dev_fp_ops_reset(struct rte_eth_fp_ops *fpo);
59c87d435aSKonstantin Ananyev 
60c87d435aSKonstantin Ananyev /* setup eth fast-path API to ethdev values */
61c87d435aSKonstantin Ananyev void eth_dev_fp_ops_setup(struct rte_eth_fp_ops *fpo,
62c87d435aSKonstantin Ananyev 		const struct rte_eth_dev *dev);
63c87d435aSKonstantin Ananyev 
64*4b4f810eSFerruh Yigit 
65*4b4f810eSFerruh Yigit void eth_dev_shared_data_prepare(void);
66*4b4f810eSFerruh Yigit 
67*4b4f810eSFerruh Yigit void eth_dev_rxq_release(struct rte_eth_dev *dev, uint16_t qid);
68*4b4f810eSFerruh Yigit void eth_dev_txq_release(struct rte_eth_dev *dev, uint16_t qid);
69*4b4f810eSFerruh Yigit int eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues);
70*4b4f810eSFerruh Yigit int eth_dev_tx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues);
71*4b4f810eSFerruh Yigit 
7299a2dd95SBruce Richardson #endif /* _ETH_PRIVATE_H_ */
73