1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Intel Corporation
5 #ifndef _RTE_ETHDEV_CORE_H_
6 #define _RTE_ETHDEV_CORE_H_
13 * RTE Ethernet Device internal header.
15 * This header contains internal data types. But they are still part of the
16 * public API because they are used by inline functions in the published API.
18 * Applications should not use these directly.
22 struct rte_eth_dev_callback;
23 /** @internal Structure to keep track of registered callbacks */
24 RTE_TAILQ_HEAD(rte_eth_dev_cb_list, rte_eth_dev_callback);
28 typedef uint16_t (*eth_rx_burst_t)(void *rxq,
29 struct rte_mbuf **rx_pkts,
31 /**< @internal Retrieve input packets from a receive queue of an Ethernet device. */
33 typedef uint16_t (*eth_tx_burst_t)(void *txq,
34 struct rte_mbuf **tx_pkts,
36 /**< @internal Send output packets on a transmit queue of an Ethernet device. */
38 typedef uint16_t (*eth_tx_prep_t)(void *txq,
39 struct rte_mbuf **tx_pkts,
41 /**< @internal Prepare output packets on a transmit queue of an Ethernet device. */
44 typedef uint32_t (*eth_rx_queue_count_t)(void *rxq);
45 /**< @internal Get number of used descriptors on a receive queue. */
47 typedef int (*eth_rx_descriptor_status_t)(void *rxq, uint16_t offset);
48 /**< @internal Check the status of a Rx descriptor */
50 typedef int (*eth_tx_descriptor_status_t)(void *txq, uint16_t offset);
51 /**< @internal Check the status of a Tx descriptor */
55 * Structure used to hold opaque pointers to internal ethdev Rx/Tx
57 * The main purpose to expose these pointers at all - allow compiler
58 * to fetch this data for fast-path ethdev inline functions in advance.
60 struct rte_ethdev_qdata {
61 /** points to array of internal queue data pointers */
63 /** points to array of queue callback data pointers */
69 * fast-path ethdev functions and related data are hold in a flat array.
70 * One entry per ethdev.
71 * On 64-bit systems contents of this structure occupy exactly two 64B lines.
72 * On 32-bit systems contents of this structure fits into one 64B line.
74 struct rte_eth_fp_ops {
78 * Rx fast-path functions and related data.
79 * 64-bit systems: occupies first 64B line
81 /** PMD receive function. */
82 eth_rx_burst_t rx_pkt_burst;
83 /** Get the number of used RX descriptors. */
84 eth_rx_queue_count_t rx_queue_count;
85 /** Check the status of a Rx descriptor. */
86 eth_rx_descriptor_status_t rx_descriptor_status;
87 /** Rx queues data. */
88 struct rte_ethdev_qdata rxq;
89 uintptr_t reserved1[3];
94 * Tx fast-path functions and related data.
95 * 64-bit systems: occupies second 64B line
97 /** PMD transmit function. */
98 eth_tx_burst_t tx_pkt_burst;
99 /** PMD transmit prepare function. */
100 eth_tx_prep_t tx_pkt_prepare;
101 /** Check the status of a Tx descriptor. */
102 eth_tx_descriptor_status_t tx_descriptor_status;
103 /** Tx queues data. */
104 struct rte_ethdev_qdata txq;
105 uintptr_t reserved2[3];
108 } __rte_cache_aligned;
110 extern struct rte_eth_fp_ops rte_eth_fp_ops[RTE_MAX_ETHPORTS];
115 * Structure used to hold information about the callbacks to be called for a
116 * queue on RX and TX.
118 struct rte_eth_rxtx_callback {
119 struct rte_eth_rxtx_callback *next;
121 rte_rx_callback_fn rx;
122 rte_tx_callback_fn tx;
129 * The generic data structure associated with each ethernet device.
131 * Pointers to burst-oriented packet receive and transmit functions are
132 * located at the beginning of the structure, along with the pointer to
133 * where all the data elements for the particular device are stored in shared
134 * memory. This split allows the function pointer and driver data to be per-
135 * process, while the actual configuration data for the device is shared.
138 eth_rx_burst_t rx_pkt_burst; /**< Pointer to PMD receive function. */
139 eth_tx_burst_t tx_pkt_burst; /**< Pointer to PMD transmit function. */
140 eth_tx_prep_t tx_pkt_prepare; /**< Pointer to PMD transmit prepare function. */
142 eth_rx_queue_count_t rx_queue_count; /**< Get the number of used RX descriptors. */
143 eth_rx_descriptor_status_t rx_descriptor_status; /**< Check the status of a Rx descriptor. */
144 eth_tx_descriptor_status_t tx_descriptor_status; /**< Check the status of a Tx descriptor. */
147 * Next two fields are per-device data but *data is shared between
148 * primary and secondary processes and *process_private is per-process
149 * private. The second one is managed by PMDs if necessary.
151 struct rte_eth_dev_data *data; /**< Pointer to device data. */
152 void *process_private; /**< Pointer to per-process device data. */
153 const struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */
154 struct rte_device *device; /**< Backing device */
155 struct rte_intr_handle *intr_handle; /**< Device interrupt handle */
156 /** User application callbacks for NIC interrupts */
157 struct rte_eth_dev_cb_list link_intr_cbs;
159 * User-supplied functions called from rx_burst to post-process
160 * received packets before passing them to the user
162 struct rte_eth_rxtx_callback *post_rx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
164 * User-supplied functions called from tx_burst to pre-process
165 * received packets before passing them to the driver for transmission.
167 struct rte_eth_rxtx_callback *pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
168 enum rte_eth_dev_state state; /**< Flag indicating the port state */
169 void *security_ctx; /**< Context for security ops */
171 uint64_t reserved_64s[4]; /**< Reserved for future fields */
172 void *reserved_ptrs[4]; /**< Reserved for future fields */
173 } __rte_cache_aligned;
175 struct rte_eth_dev_sriov;
176 struct rte_eth_dev_owner;
180 * The data part, with no function pointers, associated with each ethernet device.
182 * This structure is safe to place in shared memory to be common among different
183 * processes in a multi-process configuration.
185 struct rte_eth_dev_data {
186 char name[RTE_ETH_NAME_MAX_LEN]; /**< Unique identifier name */
188 void **rx_queues; /**< Array of pointers to RX queues. */
189 void **tx_queues; /**< Array of pointers to TX queues. */
190 uint16_t nb_rx_queues; /**< Number of RX queues. */
191 uint16_t nb_tx_queues; /**< Number of TX queues. */
193 struct rte_eth_dev_sriov sriov; /**< SRIOV data */
196 /**< PMD-specific private data.
197 * @see rte_eth_dev_release_port()
200 struct rte_eth_link dev_link; /**< Link-level information & status. */
201 struct rte_eth_conf dev_conf; /**< Configuration applied to device. */
202 uint16_t mtu; /**< Maximum Transmission Unit. */
203 uint32_t min_rx_buf_size;
204 /**< Common RX buffer size handled by all queues. */
206 uint64_t rx_mbuf_alloc_failed; /**< RX ring mbuf allocation failures. */
207 struct rte_ether_addr *mac_addrs;
208 /**< Device Ethernet link address.
209 * @see rte_eth_dev_release_port()
211 uint64_t mac_pool_sel[ETH_NUM_RECEIVE_MAC_ADDR];
212 /**< Bitmap associating MAC addresses to pools. */
213 struct rte_ether_addr *hash_mac_addrs;
214 /**< Device Ethernet MAC addresses of hash filtering.
215 * @see rte_eth_dev_release_port()
217 uint16_t port_id; /**< Device [external] port identifier. */
220 uint8_t promiscuous : 1, /**< RX promiscuous mode ON(1) / OFF(0). */
221 scattered_rx : 1, /**< RX of scattered packets is ON(1) / OFF(0) */
222 all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
223 dev_started : 1, /**< Device state: STARTED(1) / STOPPED(0). */
224 lro : 1, /**< RX LRO is ON(1) / OFF(0) */
226 /**< Indicates whether the device is configured.
227 * CONFIGURED(1) / NOT CONFIGURED(0).
229 uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
230 /**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
231 uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
232 /**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
233 uint32_t dev_flags; /**< Capabilities. */
234 int numa_node; /**< NUMA node connection. */
235 struct rte_vlan_filter_conf vlan_filter_conf;
236 /**< VLAN filter configuration. */
237 struct rte_eth_dev_owner owner; /**< The port owner. */
238 uint16_t representor_id;
239 /**< Switch-specific identifier.
240 * Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags.
242 uint16_t backer_port_id;
243 /**< Port ID of the backing device.
244 * This device will be used to query representor
245 * info and calculate representor IDs.
246 * Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags.
249 pthread_mutex_t flow_ops_mutex; /**< rte_flow ops mutex. */
250 uint64_t reserved_64s[4]; /**< Reserved for future fields */
251 void *reserved_ptrs[4]; /**< Reserved for future fields */
252 } __rte_cache_aligned;
256 * The pool of *rte_eth_dev* structures. The size of the pool
257 * is configured at compile-time in the <rte_ethdev.c> file.
259 extern struct rte_eth_dev rte_eth_devices[];
261 #endif /* _RTE_ETHDEV_CORE_H_ */