xref: /dpdk/lib/ethdev/rte_ethdev_core.h (revision c56185fc183fc0532d2f03aaf04bbf0989ea91a5)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Intel Corporation
3  */
4 
5 #ifndef _RTE_ETHDEV_CORE_H_
6 #define _RTE_ETHDEV_CORE_H_
7 
8 /**
9  * @file
10  *
11  * RTE Ethernet Device internal header.
12  *
13  * This header contains internal data types. But they are still part of the
14  * public API because they are used by inline functions in the published API.
15  *
16  * Applications should not use these directly.
17  */
18 
19 struct rte_eth_dev_callback;
20 /** @internal Structure to keep track of registered callbacks */
21 RTE_TAILQ_HEAD(rte_eth_dev_cb_list, rte_eth_dev_callback);
22 
23 struct rte_eth_dev;
24 
25 /**
26  * @internal Retrieve input packets from a receive queue of an Ethernet device.
27  */
28 typedef uint16_t (*eth_rx_burst_t)(void *rxq,
29 				   struct rte_mbuf **rx_pkts,
30 				   uint16_t nb_pkts);
31 
32 /**
33  * @internal Send output packets on a transmit queue of an Ethernet device.
34  */
35 typedef uint16_t (*eth_tx_burst_t)(void *txq,
36 				   struct rte_mbuf **tx_pkts,
37 				   uint16_t nb_pkts);
38 
39 /**
40  * @internal Prepare output packets on a transmit queue of an Ethernet device.
41  */
42 typedef uint16_t (*eth_tx_prep_t)(void *txq,
43 				   struct rte_mbuf **tx_pkts,
44 				   uint16_t nb_pkts);
45 
46 
47 /** @internal Get number of used descriptors on a receive queue. */
48 typedef uint32_t (*eth_rx_queue_count_t)(void *rxq);
49 
50 /** @internal Check the status of a Rx descriptor */
51 typedef int (*eth_rx_descriptor_status_t)(void *rxq, uint16_t offset);
52 
53 /** @internal Check the status of a Tx descriptor */
54 typedef int (*eth_tx_descriptor_status_t)(void *txq, uint16_t offset);
55 
56 /**
57  * @internal
58  * Structure used to hold opaque pointers to internal ethdev Rx/Tx
59  * queues data.
60  * The main purpose to expose these pointers at all - allow compiler
61  * to fetch this data for fast-path ethdev inline functions in advance.
62  */
63 struct rte_ethdev_qdata {
64 	/** points to array of internal queue data pointers */
65 	void **data;
66 	/** points to array of queue callback data pointers */
67 	void **clbk;
68 };
69 
70 /**
71  * @internal
72  * fast-path ethdev functions and related data are hold in a flat array.
73  * One entry per ethdev.
74  * On 64-bit systems contents of this structure occupy exactly two 64B lines.
75  * On 32-bit systems contents of this structure fits into one 64B line.
76  */
77 struct rte_eth_fp_ops {
78 
79 	/**@{*/
80 	/**
81 	 * Rx fast-path functions and related data.
82 	 * 64-bit systems: occupies first 64B line
83 	 */
84 	/** PMD receive function. */
85 	eth_rx_burst_t rx_pkt_burst;
86 	/** Get the number of used Rx descriptors. */
87 	eth_rx_queue_count_t rx_queue_count;
88 	/** Check the status of a Rx descriptor. */
89 	eth_rx_descriptor_status_t rx_descriptor_status;
90 	/** Rx queues data. */
91 	struct rte_ethdev_qdata rxq;
92 	uintptr_t reserved1[3];
93 	/**@}*/
94 
95 	/**@{*/
96 	/**
97 	 * Tx fast-path functions and related data.
98 	 * 64-bit systems: occupies second 64B line
99 	 */
100 	/** PMD transmit function. */
101 	eth_tx_burst_t tx_pkt_burst;
102 	/** PMD transmit prepare function. */
103 	eth_tx_prep_t tx_pkt_prepare;
104 	/** Check the status of a Tx descriptor. */
105 	eth_tx_descriptor_status_t tx_descriptor_status;
106 	/** Tx queues data. */
107 	struct rte_ethdev_qdata txq;
108 	uintptr_t reserved2[3];
109 	/**@}*/
110 
111 } __rte_cache_aligned;
112 
113 extern struct rte_eth_fp_ops rte_eth_fp_ops[RTE_MAX_ETHPORTS];
114 
115 #endif /* _RTE_ETHDEV_CORE_H_ */
116