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 */
56 * Structure used to hold information about the callbacks to be called for a
59 struct rte_eth_rxtx_callback {
60 struct rte_eth_rxtx_callback *next;
62 rte_rx_callback_fn rx;
63 rte_tx_callback_fn tx;
70 * The generic data structure associated with each ethernet device.
72 * Pointers to burst-oriented packet receive and transmit functions are
73 * located at the beginning of the structure, along with the pointer to
74 * where all the data elements for the particular device are stored in shared
75 * memory. This split allows the function pointer and driver data to be per-
76 * process, while the actual configuration data for the device is shared.
79 eth_rx_burst_t rx_pkt_burst; /**< Pointer to PMD receive function. */
80 eth_tx_burst_t tx_pkt_burst; /**< Pointer to PMD transmit function. */
81 eth_tx_prep_t tx_pkt_prepare; /**< Pointer to PMD transmit prepare function. */
83 eth_rx_queue_count_t rx_queue_count; /**< Get the number of used RX descriptors. */
84 eth_rx_descriptor_status_t rx_descriptor_status; /**< Check the status of a Rx descriptor. */
85 eth_tx_descriptor_status_t tx_descriptor_status; /**< Check the status of a Tx descriptor. */
88 * Next two fields are per-device data but *data is shared between
89 * primary and secondary processes and *process_private is per-process
90 * private. The second one is managed by PMDs if necessary.
92 struct rte_eth_dev_data *data; /**< Pointer to device data. */
93 void *process_private; /**< Pointer to per-process device data. */
94 const struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */
95 struct rte_device *device; /**< Backing device */
96 struct rte_intr_handle *intr_handle; /**< Device interrupt handle */
97 /** User application callbacks for NIC interrupts */
98 struct rte_eth_dev_cb_list link_intr_cbs;
100 * User-supplied functions called from rx_burst to post-process
101 * received packets before passing them to the user
103 struct rte_eth_rxtx_callback *post_rx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
105 * User-supplied functions called from tx_burst to pre-process
106 * received packets before passing them to the driver for transmission.
108 struct rte_eth_rxtx_callback *pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
109 enum rte_eth_dev_state state; /**< Flag indicating the port state */
110 void *security_ctx; /**< Context for security ops */
112 uint64_t reserved_64s[4]; /**< Reserved for future fields */
113 void *reserved_ptrs[4]; /**< Reserved for future fields */
114 } __rte_cache_aligned;
116 struct rte_eth_dev_sriov;
117 struct rte_eth_dev_owner;
121 * The data part, with no function pointers, associated with each ethernet device.
123 * This structure is safe to place in shared memory to be common among different
124 * processes in a multi-process configuration.
126 struct rte_eth_dev_data {
127 char name[RTE_ETH_NAME_MAX_LEN]; /**< Unique identifier name */
129 void **rx_queues; /**< Array of pointers to RX queues. */
130 void **tx_queues; /**< Array of pointers to TX queues. */
131 uint16_t nb_rx_queues; /**< Number of RX queues. */
132 uint16_t nb_tx_queues; /**< Number of TX queues. */
134 struct rte_eth_dev_sriov sriov; /**< SRIOV data */
137 /**< PMD-specific private data.
138 * @see rte_eth_dev_release_port()
141 struct rte_eth_link dev_link; /**< Link-level information & status. */
142 struct rte_eth_conf dev_conf; /**< Configuration applied to device. */
143 uint16_t mtu; /**< Maximum Transmission Unit. */
144 uint32_t min_rx_buf_size;
145 /**< Common RX buffer size handled by all queues. */
147 uint64_t rx_mbuf_alloc_failed; /**< RX ring mbuf allocation failures. */
148 struct rte_ether_addr *mac_addrs;
149 /**< Device Ethernet link address.
150 * @see rte_eth_dev_release_port()
152 uint64_t mac_pool_sel[ETH_NUM_RECEIVE_MAC_ADDR];
153 /**< Bitmap associating MAC addresses to pools. */
154 struct rte_ether_addr *hash_mac_addrs;
155 /**< Device Ethernet MAC addresses of hash filtering.
156 * @see rte_eth_dev_release_port()
158 uint16_t port_id; /**< Device [external] port identifier. */
161 uint8_t promiscuous : 1, /**< RX promiscuous mode ON(1) / OFF(0). */
162 scattered_rx : 1, /**< RX of scattered packets is ON(1) / OFF(0) */
163 all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
164 dev_started : 1, /**< Device state: STARTED(1) / STOPPED(0). */
165 lro : 1, /**< RX LRO is ON(1) / OFF(0) */
167 /**< Indicates whether the device is configured.
168 * CONFIGURED(1) / NOT CONFIGURED(0).
170 uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
171 /**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
172 uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
173 /**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
174 uint32_t dev_flags; /**< Capabilities. */
175 int numa_node; /**< NUMA node connection. */
176 struct rte_vlan_filter_conf vlan_filter_conf;
177 /**< VLAN filter configuration. */
178 struct rte_eth_dev_owner owner; /**< The port owner. */
179 uint16_t representor_id;
180 /**< Switch-specific identifier.
181 * Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags.
183 uint16_t backer_port_id;
184 /**< Port ID of the backing device.
185 * This device will be used to query representor
186 * info and calculate representor IDs.
187 * Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags.
190 pthread_mutex_t flow_ops_mutex; /**< rte_flow ops mutex. */
191 uint64_t reserved_64s[4]; /**< Reserved for future fields */
192 void *reserved_ptrs[4]; /**< Reserved for future fields */
193 } __rte_cache_aligned;
197 * The pool of *rte_eth_dev* structures. The size of the pool
198 * is configured at compile-time in the <rte_ethdev.c> file.
200 extern struct rte_eth_dev rte_eth_devices[];
202 #endif /* _RTE_ETHDEV_CORE_H_ */