xref: /dpdk/lib/ethdev/ethdev_private.h (revision 36c46e738120c381cf663c96692454c5aa75e203)
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 
84b4f810eSFerruh Yigit #include <sys/queue.h>
94b4f810eSFerruh Yigit 
105fa33785SDavid Marchand #include <rte_eal_memconfig.h>
114b4f810eSFerruh Yigit #include <rte_malloc.h>
1299a2dd95SBruce Richardson #include <rte_os_shim.h>
1399a2dd95SBruce Richardson 
1499a2dd95SBruce Richardson #include "rte_ethdev.h"
1599a2dd95SBruce Richardson 
164b4f810eSFerruh Yigit struct eth_dev_shared {
17*36c46e73SDavid Marchand 	uint64_t allocated_owners;
184b4f810eSFerruh Yigit 	uint64_t next_owner_id;
19*36c46e73SDavid Marchand 	uint64_t allocated_ports;
204b4f810eSFerruh Yigit 	struct rte_eth_dev_data data[RTE_MAX_ETHPORTS];
214b4f810eSFerruh Yigit };
224b4f810eSFerruh Yigit 
235fa33785SDavid Marchand /* Shared memory between primary and secondary processes. */
245fa33785SDavid Marchand extern struct eth_dev_shared *eth_dev_shared_data
255fa33785SDavid Marchand 	__rte_guarded_by(rte_mcfg_ethdev_get_lock());
264b4f810eSFerruh Yigit 
274b4f810eSFerruh Yigit /**
284b4f810eSFerruh Yigit  * The user application callback description.
294b4f810eSFerruh Yigit  *
304b4f810eSFerruh Yigit  * It contains callback address to be registered by user application,
314b4f810eSFerruh Yigit  * the pointer to the parameters for callback, and the event type.
324b4f810eSFerruh Yigit  */
334b4f810eSFerruh Yigit struct rte_eth_dev_callback {
344b4f810eSFerruh Yigit 	TAILQ_ENTRY(rte_eth_dev_callback) next; /**< Callbacks list */
354b4f810eSFerruh Yigit 	rte_eth_dev_cb_fn cb_fn;                /**< Callback address */
364b4f810eSFerruh Yigit 	void *cb_arg;                           /**< Parameter for callback */
374b4f810eSFerruh Yigit 	void *ret_param;                        /**< Return parameter */
384b4f810eSFerruh Yigit 	enum rte_eth_event_type event;          /**< Interrupt event type */
394b4f810eSFerruh Yigit 	uint32_t active;                        /**< Callback is executing */
404b4f810eSFerruh Yigit };
414b4f810eSFerruh Yigit 
424b4f810eSFerruh Yigit extern rte_spinlock_t eth_dev_cb_lock;
434b4f810eSFerruh Yigit 
446b81dddbSJerin Jacob /* Convert all error to -EIO if device is removed. */
456b81dddbSJerin Jacob int eth_err(uint16_t port_id, int ret);
466b81dddbSJerin Jacob 
4799a2dd95SBruce Richardson /*
485906be5aSAndrew Rybchenko  * Convert rte_eth_dev pointer to port ID.
4999a2dd95SBruce Richardson  * NULL will be translated to RTE_MAX_ETHPORTS.
5099a2dd95SBruce Richardson  */
5199a2dd95SBruce Richardson uint16_t eth_dev_to_id(const struct rte_eth_dev *dev);
5299a2dd95SBruce Richardson 
5399a2dd95SBruce Richardson /* Generic rte_eth_dev comparison function. */
5499a2dd95SBruce Richardson typedef int (*rte_eth_cmp_t)(const struct rte_eth_dev *, const void *);
5599a2dd95SBruce Richardson 
5699a2dd95SBruce Richardson /* Generic rte_eth_dev iterator. */
5799a2dd95SBruce Richardson struct rte_eth_dev *
5899a2dd95SBruce Richardson eth_find_device(const struct rte_eth_dev *_start, rte_eth_cmp_t cmp,
5999a2dd95SBruce Richardson 		const void *data);
6099a2dd95SBruce Richardson 
6199a2dd95SBruce Richardson /* Parse devargs value for representor parameter. */
6299a2dd95SBruce Richardson int rte_eth_devargs_parse_representor_ports(char *str, void *data);
6399a2dd95SBruce Richardson 
64c87d435aSKonstantin Ananyev /* reset eth fast-path API to dummy values */
65c87d435aSKonstantin Ananyev void eth_dev_fp_ops_reset(struct rte_eth_fp_ops *fpo);
66c87d435aSKonstantin Ananyev 
67c87d435aSKonstantin Ananyev /* setup eth fast-path API to ethdev values */
68c87d435aSKonstantin Ananyev void eth_dev_fp_ops_setup(struct rte_eth_fp_ops *fpo,
69c87d435aSKonstantin Ananyev 		const struct rte_eth_dev *dev);
70c87d435aSKonstantin Ananyev 
714b4f810eSFerruh Yigit 
727fe371ebSDavid Marchand void *eth_dev_shared_data_prepare(void)
735fa33785SDavid Marchand 	__rte_exclusive_locks_required(rte_mcfg_ethdev_get_lock());
74*36c46e73SDavid Marchand void eth_dev_shared_data_release(void)
75*36c46e73SDavid Marchand 	__rte_exclusive_locks_required(rte_mcfg_ethdev_get_lock());
764b4f810eSFerruh Yigit 
774b4f810eSFerruh Yigit void eth_dev_rxq_release(struct rte_eth_dev *dev, uint16_t qid);
784b4f810eSFerruh Yigit void eth_dev_txq_release(struct rte_eth_dev *dev, uint16_t qid);
794b4f810eSFerruh Yigit int eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues);
804b4f810eSFerruh Yigit int eth_dev_tx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues);
814b4f810eSFerruh Yigit 
8299a2dd95SBruce Richardson #endif /* _ETH_PRIVATE_H_ */
83