xref: /dpdk/lib/ethdev/ethdev_driver.h (revision 99a2dd95)
1*99a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
2*99a2dd95SBruce Richardson  * Copyright(c) 2017 Intel Corporation
3*99a2dd95SBruce Richardson  */
4*99a2dd95SBruce Richardson 
5*99a2dd95SBruce Richardson #ifndef _RTE_ETHDEV_DRIVER_H_
6*99a2dd95SBruce Richardson #define _RTE_ETHDEV_DRIVER_H_
7*99a2dd95SBruce Richardson 
8*99a2dd95SBruce Richardson /**
9*99a2dd95SBruce Richardson  * @file
10*99a2dd95SBruce Richardson  *
11*99a2dd95SBruce Richardson  * RTE Ethernet Device PMD API
12*99a2dd95SBruce Richardson  *
13*99a2dd95SBruce Richardson  * These APIs for the use from Ethernet drivers, user applications shouldn't
14*99a2dd95SBruce Richardson  * use them.
15*99a2dd95SBruce Richardson  *
16*99a2dd95SBruce Richardson  */
17*99a2dd95SBruce Richardson 
18*99a2dd95SBruce Richardson #include <rte_ethdev.h>
19*99a2dd95SBruce Richardson 
20*99a2dd95SBruce Richardson #ifdef __cplusplus
21*99a2dd95SBruce Richardson extern "C" {
22*99a2dd95SBruce Richardson #endif
23*99a2dd95SBruce Richardson 
24*99a2dd95SBruce Richardson /**< @internal Declaration of the hairpin peer queue information structure. */
25*99a2dd95SBruce Richardson struct rte_hairpin_peer_info;
26*99a2dd95SBruce Richardson 
27*99a2dd95SBruce Richardson /*
28*99a2dd95SBruce Richardson  * Definitions of all functions exported by an Ethernet driver through the
29*99a2dd95SBruce Richardson  * generic structure of type *eth_dev_ops* supplied in the *rte_eth_dev*
30*99a2dd95SBruce Richardson  * structure associated with an Ethernet device.
31*99a2dd95SBruce Richardson  */
32*99a2dd95SBruce Richardson 
33*99a2dd95SBruce Richardson typedef int  (*eth_dev_configure_t)(struct rte_eth_dev *dev);
34*99a2dd95SBruce Richardson /**< @internal Ethernet device configuration. */
35*99a2dd95SBruce Richardson 
36*99a2dd95SBruce Richardson typedef int  (*eth_dev_start_t)(struct rte_eth_dev *dev);
37*99a2dd95SBruce Richardson /**< @internal Function used to start a configured Ethernet device. */
38*99a2dd95SBruce Richardson 
39*99a2dd95SBruce Richardson typedef int (*eth_dev_stop_t)(struct rte_eth_dev *dev);
40*99a2dd95SBruce Richardson /**< @internal Function used to stop a configured Ethernet device. */
41*99a2dd95SBruce Richardson 
42*99a2dd95SBruce Richardson typedef int  (*eth_dev_set_link_up_t)(struct rte_eth_dev *dev);
43*99a2dd95SBruce Richardson /**< @internal Function used to link up a configured Ethernet device. */
44*99a2dd95SBruce Richardson 
45*99a2dd95SBruce Richardson typedef int  (*eth_dev_set_link_down_t)(struct rte_eth_dev *dev);
46*99a2dd95SBruce Richardson /**< @internal Function used to link down a configured Ethernet device. */
47*99a2dd95SBruce Richardson 
48*99a2dd95SBruce Richardson typedef int (*eth_dev_close_t)(struct rte_eth_dev *dev);
49*99a2dd95SBruce Richardson /**< @internal Function used to close a configured Ethernet device. */
50*99a2dd95SBruce Richardson 
51*99a2dd95SBruce Richardson typedef int (*eth_dev_reset_t)(struct rte_eth_dev *dev);
52*99a2dd95SBruce Richardson /** <@internal Function used to reset a configured Ethernet device. */
53*99a2dd95SBruce Richardson 
54*99a2dd95SBruce Richardson typedef int (*eth_is_removed_t)(struct rte_eth_dev *dev);
55*99a2dd95SBruce Richardson /**< @internal Function used to detect an Ethernet device removal. */
56*99a2dd95SBruce Richardson 
57*99a2dd95SBruce Richardson /**
58*99a2dd95SBruce Richardson  * @internal
59*99a2dd95SBruce Richardson  * Function used to enable the Rx promiscuous mode of an Ethernet device.
60*99a2dd95SBruce Richardson  *
61*99a2dd95SBruce Richardson  * @param dev
62*99a2dd95SBruce Richardson  *   ethdev handle of port.
63*99a2dd95SBruce Richardson  *
64*99a2dd95SBruce Richardson  * @return
65*99a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
66*99a2dd95SBruce Richardson  *
67*99a2dd95SBruce Richardson  * @retval 0
68*99a2dd95SBruce Richardson  *   Success, promiscuous mode is enabled.
69*99a2dd95SBruce Richardson  * @retval -ENOTSUP
70*99a2dd95SBruce Richardson  *   Promiscuous mode is not supported.
71*99a2dd95SBruce Richardson  * @retval -ENODEV
72*99a2dd95SBruce Richardson  *   Device is gone.
73*99a2dd95SBruce Richardson  * @retval -E_RTE_SECONDARY
74*99a2dd95SBruce Richardson  *   Function was called from a secondary process instance and not supported.
75*99a2dd95SBruce Richardson  * @retval -ETIMEDOUT
76*99a2dd95SBruce Richardson  *   Attempt to enable promiscuos mode failed because of timeout.
77*99a2dd95SBruce Richardson  * @retval -EAGAIN
78*99a2dd95SBruce Richardson  *   Failed to enable promiscuous mode.
79*99a2dd95SBruce Richardson  */
80*99a2dd95SBruce Richardson typedef int (*eth_promiscuous_enable_t)(struct rte_eth_dev *dev);
81*99a2dd95SBruce Richardson 
82*99a2dd95SBruce Richardson /**
83*99a2dd95SBruce Richardson  * @internal
84*99a2dd95SBruce Richardson  * Function used to disable the Rx promiscuous mode of an Ethernet device.
85*99a2dd95SBruce Richardson  *
86*99a2dd95SBruce Richardson  * @param dev
87*99a2dd95SBruce Richardson  *   ethdev handle of port.
88*99a2dd95SBruce Richardson  *
89*99a2dd95SBruce Richardson  * @return
90*99a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
91*99a2dd95SBruce Richardson  *
92*99a2dd95SBruce Richardson  * @retval 0
93*99a2dd95SBruce Richardson  *   Success, promiscuous mode is disabled.
94*99a2dd95SBruce Richardson  * @retval -ENOTSUP
95*99a2dd95SBruce Richardson  *   Promiscuous mode disabling is not supported.
96*99a2dd95SBruce Richardson  * @retval -ENODEV
97*99a2dd95SBruce Richardson  *   Device is gone.
98*99a2dd95SBruce Richardson  * @retval -E_RTE_SECONDARY
99*99a2dd95SBruce Richardson  *   Function was called from a secondary process instance and not supported.
100*99a2dd95SBruce Richardson  * @retval -ETIMEDOUT
101*99a2dd95SBruce Richardson  *   Attempt to disable promiscuos mode failed because of timeout.
102*99a2dd95SBruce Richardson  * @retval -EAGAIN
103*99a2dd95SBruce Richardson  *   Failed to disable promiscuous mode.
104*99a2dd95SBruce Richardson  */
105*99a2dd95SBruce Richardson typedef int (*eth_promiscuous_disable_t)(struct rte_eth_dev *dev);
106*99a2dd95SBruce Richardson 
107*99a2dd95SBruce Richardson /**
108*99a2dd95SBruce Richardson  * @internal
109*99a2dd95SBruce Richardson  * Enable the receipt of all multicast packets by an Ethernet device.
110*99a2dd95SBruce Richardson  *
111*99a2dd95SBruce Richardson  * @param dev
112*99a2dd95SBruce Richardson  *   ethdev handle of port.
113*99a2dd95SBruce Richardson  *
114*99a2dd95SBruce Richardson  * @return
115*99a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
116*99a2dd95SBruce Richardson  *
117*99a2dd95SBruce Richardson  * @retval 0
118*99a2dd95SBruce Richardson  *   Success, all-multicast mode is enabled.
119*99a2dd95SBruce Richardson  * @retval -ENOTSUP
120*99a2dd95SBruce Richardson  *   All-multicast mode is not supported.
121*99a2dd95SBruce Richardson  * @retval -ENODEV
122*99a2dd95SBruce Richardson  *   Device is gone.
123*99a2dd95SBruce Richardson  * @retval -E_RTE_SECONDARY
124*99a2dd95SBruce Richardson  *   Function was called from a secondary process instance and not supported.
125*99a2dd95SBruce Richardson  * @retval -ETIMEDOUT
126*99a2dd95SBruce Richardson  *   Attempt to enable all-multicast mode failed because of timeout.
127*99a2dd95SBruce Richardson  * @retval -EAGAIN
128*99a2dd95SBruce Richardson  *   Failed to enable all-multicast mode.
129*99a2dd95SBruce Richardson  */
130*99a2dd95SBruce Richardson typedef int (*eth_allmulticast_enable_t)(struct rte_eth_dev *dev);
131*99a2dd95SBruce Richardson 
132*99a2dd95SBruce Richardson /**
133*99a2dd95SBruce Richardson  * @internal
134*99a2dd95SBruce Richardson  * Disable the receipt of all multicast packets by an Ethernet device.
135*99a2dd95SBruce Richardson  *
136*99a2dd95SBruce Richardson  * @param dev
137*99a2dd95SBruce Richardson  *   ethdev handle of port.
138*99a2dd95SBruce Richardson  *
139*99a2dd95SBruce Richardson  * @return
140*99a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
141*99a2dd95SBruce Richardson  *
142*99a2dd95SBruce Richardson  * @retval 0
143*99a2dd95SBruce Richardson  *   Success, all-multicast mode is disabled.
144*99a2dd95SBruce Richardson  * @retval -ENOTSUP
145*99a2dd95SBruce Richardson  *   All-multicast mode disabling is not supported.
146*99a2dd95SBruce Richardson  * @retval -ENODEV
147*99a2dd95SBruce Richardson  *   Device is gone.
148*99a2dd95SBruce Richardson  * @retval -E_RTE_SECONDARY
149*99a2dd95SBruce Richardson  *   Function was called from a secondary process instance and not supported.
150*99a2dd95SBruce Richardson  * @retval -ETIMEDOUT
151*99a2dd95SBruce Richardson  *   Attempt to disable all-multicast mode failed because of timeout.
152*99a2dd95SBruce Richardson  * @retval -EAGAIN
153*99a2dd95SBruce Richardson  *   Failed to disable all-multicast mode.
154*99a2dd95SBruce Richardson  */
155*99a2dd95SBruce Richardson typedef int (*eth_allmulticast_disable_t)(struct rte_eth_dev *dev);
156*99a2dd95SBruce Richardson 
157*99a2dd95SBruce Richardson typedef int (*eth_link_update_t)(struct rte_eth_dev *dev,
158*99a2dd95SBruce Richardson 				int wait_to_complete);
159*99a2dd95SBruce Richardson /**< @internal Get link speed, duplex mode and state (up/down) of an Ethernet device. */
160*99a2dd95SBruce Richardson 
161*99a2dd95SBruce Richardson typedef int (*eth_stats_get_t)(struct rte_eth_dev *dev,
162*99a2dd95SBruce Richardson 				struct rte_eth_stats *igb_stats);
163*99a2dd95SBruce Richardson /**< @internal Get global I/O statistics of an Ethernet device. */
164*99a2dd95SBruce Richardson 
165*99a2dd95SBruce Richardson /**
166*99a2dd95SBruce Richardson  * @internal
167*99a2dd95SBruce Richardson  * Reset global I/O statistics of an Ethernet device to 0.
168*99a2dd95SBruce Richardson  *
169*99a2dd95SBruce Richardson  * @param dev
170*99a2dd95SBruce Richardson  *   ethdev handle of port.
171*99a2dd95SBruce Richardson  *
172*99a2dd95SBruce Richardson  * @return
173*99a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
174*99a2dd95SBruce Richardson  *
175*99a2dd95SBruce Richardson  * @retval 0
176*99a2dd95SBruce Richardson  *   Success, statistics has been reset.
177*99a2dd95SBruce Richardson  * @retval -ENOTSUP
178*99a2dd95SBruce Richardson  *   Resetting statistics is not supported.
179*99a2dd95SBruce Richardson  * @retval -EINVAL
180*99a2dd95SBruce Richardson  *   Resetting statistics is not valid.
181*99a2dd95SBruce Richardson  * @retval -ENOMEM
182*99a2dd95SBruce Richardson  *   Not enough memory to get the stats.
183*99a2dd95SBruce Richardson  */
184*99a2dd95SBruce Richardson typedef int (*eth_stats_reset_t)(struct rte_eth_dev *dev);
185*99a2dd95SBruce Richardson 
186*99a2dd95SBruce Richardson typedef int (*eth_xstats_get_t)(struct rte_eth_dev *dev,
187*99a2dd95SBruce Richardson 	struct rte_eth_xstat *stats, unsigned int n);
188*99a2dd95SBruce Richardson /**< @internal Get extended stats of an Ethernet device. */
189*99a2dd95SBruce Richardson 
190*99a2dd95SBruce Richardson typedef int (*eth_xstats_get_by_id_t)(struct rte_eth_dev *dev,
191*99a2dd95SBruce Richardson 				      const uint64_t *ids,
192*99a2dd95SBruce Richardson 				      uint64_t *values,
193*99a2dd95SBruce Richardson 				      unsigned int n);
194*99a2dd95SBruce Richardson /**< @internal Get extended stats of an Ethernet device. */
195*99a2dd95SBruce Richardson 
196*99a2dd95SBruce Richardson /**
197*99a2dd95SBruce Richardson  * @internal
198*99a2dd95SBruce Richardson  * Reset extended stats of an Ethernet device.
199*99a2dd95SBruce Richardson  *
200*99a2dd95SBruce Richardson  * @param dev
201*99a2dd95SBruce Richardson  *   ethdev handle of port.
202*99a2dd95SBruce Richardson  *
203*99a2dd95SBruce Richardson  * @return
204*99a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
205*99a2dd95SBruce Richardson  *
206*99a2dd95SBruce Richardson  * @retval 0
207*99a2dd95SBruce Richardson  *   Success, statistics has been reset.
208*99a2dd95SBruce Richardson  * @retval -ENOTSUP
209*99a2dd95SBruce Richardson  *   Resetting statistics is not supported.
210*99a2dd95SBruce Richardson  * @retval -EINVAL
211*99a2dd95SBruce Richardson  *   Resetting statistics is not valid.
212*99a2dd95SBruce Richardson  * @retval -ENOMEM
213*99a2dd95SBruce Richardson  *   Not enough memory to get the stats.
214*99a2dd95SBruce Richardson  */
215*99a2dd95SBruce Richardson typedef int (*eth_xstats_reset_t)(struct rte_eth_dev *dev);
216*99a2dd95SBruce Richardson 
217*99a2dd95SBruce Richardson typedef int (*eth_xstats_get_names_t)(struct rte_eth_dev *dev,
218*99a2dd95SBruce Richardson 	struct rte_eth_xstat_name *xstats_names, unsigned int size);
219*99a2dd95SBruce Richardson /**< @internal Get names of extended stats of an Ethernet device. */
220*99a2dd95SBruce Richardson 
221*99a2dd95SBruce Richardson typedef int (*eth_xstats_get_names_by_id_t)(struct rte_eth_dev *dev,
222*99a2dd95SBruce Richardson 	struct rte_eth_xstat_name *xstats_names, const uint64_t *ids,
223*99a2dd95SBruce Richardson 	unsigned int size);
224*99a2dd95SBruce Richardson /**< @internal Get names of extended stats of an Ethernet device. */
225*99a2dd95SBruce Richardson 
226*99a2dd95SBruce Richardson typedef int (*eth_queue_stats_mapping_set_t)(struct rte_eth_dev *dev,
227*99a2dd95SBruce Richardson 					     uint16_t queue_id,
228*99a2dd95SBruce Richardson 					     uint8_t stat_idx,
229*99a2dd95SBruce Richardson 					     uint8_t is_rx);
230*99a2dd95SBruce Richardson /**< @internal Set a queue statistics mapping for a tx/rx queue of an Ethernet device. */
231*99a2dd95SBruce Richardson 
232*99a2dd95SBruce Richardson typedef int (*eth_dev_infos_get_t)(struct rte_eth_dev *dev,
233*99a2dd95SBruce Richardson 				   struct rte_eth_dev_info *dev_info);
234*99a2dd95SBruce Richardson /**< @internal Get specific information of an Ethernet device. */
235*99a2dd95SBruce Richardson 
236*99a2dd95SBruce Richardson typedef const uint32_t *(*eth_dev_supported_ptypes_get_t)(struct rte_eth_dev *dev);
237*99a2dd95SBruce Richardson /**< @internal Get supported ptypes of an Ethernet device. */
238*99a2dd95SBruce Richardson 
239*99a2dd95SBruce Richardson /**
240*99a2dd95SBruce Richardson  * @internal
241*99a2dd95SBruce Richardson  * Inform Ethernet device about reduced range of packet types to handle.
242*99a2dd95SBruce Richardson  *
243*99a2dd95SBruce Richardson  * @param dev
244*99a2dd95SBruce Richardson  *   The Ethernet device identifier.
245*99a2dd95SBruce Richardson  * @param ptype_mask
246*99a2dd95SBruce Richardson  *   The ptype family that application is interested in should be bitwise OR of
247*99a2dd95SBruce Richardson  *   RTE_PTYPE_*_MASK or 0.
248*99a2dd95SBruce Richardson  * @return
249*99a2dd95SBruce Richardson  *   - (0) if Success.
250*99a2dd95SBruce Richardson  */
251*99a2dd95SBruce Richardson typedef int (*eth_dev_ptypes_set_t)(struct rte_eth_dev *dev,
252*99a2dd95SBruce Richardson 				     uint32_t ptype_mask);
253*99a2dd95SBruce Richardson 
254*99a2dd95SBruce Richardson typedef int (*eth_queue_start_t)(struct rte_eth_dev *dev,
255*99a2dd95SBruce Richardson 				    uint16_t queue_id);
256*99a2dd95SBruce Richardson /**< @internal Start rx and tx of a queue of an Ethernet device. */
257*99a2dd95SBruce Richardson 
258*99a2dd95SBruce Richardson typedef int (*eth_queue_stop_t)(struct rte_eth_dev *dev,
259*99a2dd95SBruce Richardson 				    uint16_t queue_id);
260*99a2dd95SBruce Richardson /**< @internal Stop rx and tx of a queue of an Ethernet device. */
261*99a2dd95SBruce Richardson 
262*99a2dd95SBruce Richardson typedef int (*eth_rx_queue_setup_t)(struct rte_eth_dev *dev,
263*99a2dd95SBruce Richardson 				    uint16_t rx_queue_id,
264*99a2dd95SBruce Richardson 				    uint16_t nb_rx_desc,
265*99a2dd95SBruce Richardson 				    unsigned int socket_id,
266*99a2dd95SBruce Richardson 				    const struct rte_eth_rxconf *rx_conf,
267*99a2dd95SBruce Richardson 				    struct rte_mempool *mb_pool);
268*99a2dd95SBruce Richardson /**< @internal Set up a receive queue of an Ethernet device. */
269*99a2dd95SBruce Richardson 
270*99a2dd95SBruce Richardson typedef int (*eth_tx_queue_setup_t)(struct rte_eth_dev *dev,
271*99a2dd95SBruce Richardson 				    uint16_t tx_queue_id,
272*99a2dd95SBruce Richardson 				    uint16_t nb_tx_desc,
273*99a2dd95SBruce Richardson 				    unsigned int socket_id,
274*99a2dd95SBruce Richardson 				    const struct rte_eth_txconf *tx_conf);
275*99a2dd95SBruce Richardson /**< @internal Setup a transmit queue of an Ethernet device. */
276*99a2dd95SBruce Richardson 
277*99a2dd95SBruce Richardson typedef int (*eth_rx_enable_intr_t)(struct rte_eth_dev *dev,
278*99a2dd95SBruce Richardson 				    uint16_t rx_queue_id);
279*99a2dd95SBruce Richardson /**< @internal Enable interrupt of a receive queue of an Ethernet device. */
280*99a2dd95SBruce Richardson 
281*99a2dd95SBruce Richardson typedef int (*eth_rx_disable_intr_t)(struct rte_eth_dev *dev,
282*99a2dd95SBruce Richardson 				    uint16_t rx_queue_id);
283*99a2dd95SBruce Richardson /**< @internal Disable interrupt of a receive queue of an Ethernet device. */
284*99a2dd95SBruce Richardson 
285*99a2dd95SBruce Richardson typedef void (*eth_queue_release_t)(void *queue);
286*99a2dd95SBruce Richardson /**< @internal Release memory resources allocated by given RX/TX queue. */
287*99a2dd95SBruce Richardson 
288*99a2dd95SBruce Richardson typedef int (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
289*99a2dd95SBruce Richardson 				     char *fw_version, size_t fw_size);
290*99a2dd95SBruce Richardson /**< @internal Get firmware information of an Ethernet device. */
291*99a2dd95SBruce Richardson 
292*99a2dd95SBruce Richardson typedef int (*eth_tx_done_cleanup_t)(void *txq, uint32_t free_cnt);
293*99a2dd95SBruce Richardson /**< @internal Force mbufs to be from TX ring. */
294*99a2dd95SBruce Richardson 
295*99a2dd95SBruce Richardson typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
296*99a2dd95SBruce Richardson 	uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
297*99a2dd95SBruce Richardson 
298*99a2dd95SBruce Richardson typedef void (*eth_txq_info_get_t)(struct rte_eth_dev *dev,
299*99a2dd95SBruce Richardson 	uint16_t tx_queue_id, struct rte_eth_txq_info *qinfo);
300*99a2dd95SBruce Richardson 
301*99a2dd95SBruce Richardson typedef int (*eth_burst_mode_get_t)(struct rte_eth_dev *dev,
302*99a2dd95SBruce Richardson 	uint16_t queue_id, struct rte_eth_burst_mode *mode);
303*99a2dd95SBruce Richardson 
304*99a2dd95SBruce Richardson typedef int (*mtu_set_t)(struct rte_eth_dev *dev, uint16_t mtu);
305*99a2dd95SBruce Richardson /**< @internal Set MTU. */
306*99a2dd95SBruce Richardson 
307*99a2dd95SBruce Richardson typedef int (*vlan_filter_set_t)(struct rte_eth_dev *dev,
308*99a2dd95SBruce Richardson 				  uint16_t vlan_id,
309*99a2dd95SBruce Richardson 				  int on);
310*99a2dd95SBruce Richardson /**< @internal filtering of a VLAN Tag Identifier by an Ethernet device. */
311*99a2dd95SBruce Richardson 
312*99a2dd95SBruce Richardson typedef int (*vlan_tpid_set_t)(struct rte_eth_dev *dev,
313*99a2dd95SBruce Richardson 			       enum rte_vlan_type type, uint16_t tpid);
314*99a2dd95SBruce Richardson /**< @internal set the outer/inner VLAN-TPID by an Ethernet device. */
315*99a2dd95SBruce Richardson 
316*99a2dd95SBruce Richardson typedef int (*vlan_offload_set_t)(struct rte_eth_dev *dev, int mask);
317*99a2dd95SBruce Richardson /**< @internal set VLAN offload function by an Ethernet device. */
318*99a2dd95SBruce Richardson 
319*99a2dd95SBruce Richardson typedef int (*vlan_pvid_set_t)(struct rte_eth_dev *dev,
320*99a2dd95SBruce Richardson 			       uint16_t vlan_id,
321*99a2dd95SBruce Richardson 			       int on);
322*99a2dd95SBruce Richardson /**< @internal set port based TX VLAN insertion by an Ethernet device. */
323*99a2dd95SBruce Richardson 
324*99a2dd95SBruce Richardson typedef void (*vlan_strip_queue_set_t)(struct rte_eth_dev *dev,
325*99a2dd95SBruce Richardson 				  uint16_t rx_queue_id,
326*99a2dd95SBruce Richardson 				  int on);
327*99a2dd95SBruce Richardson /**< @internal VLAN stripping enable/disable by an queue of Ethernet device. */
328*99a2dd95SBruce Richardson 
329*99a2dd95SBruce Richardson typedef int (*flow_ctrl_get_t)(struct rte_eth_dev *dev,
330*99a2dd95SBruce Richardson 			       struct rte_eth_fc_conf *fc_conf);
331*99a2dd95SBruce Richardson /**< @internal Get current flow control parameter on an Ethernet device */
332*99a2dd95SBruce Richardson 
333*99a2dd95SBruce Richardson typedef int (*flow_ctrl_set_t)(struct rte_eth_dev *dev,
334*99a2dd95SBruce Richardson 			       struct rte_eth_fc_conf *fc_conf);
335*99a2dd95SBruce Richardson /**< @internal Setup flow control parameter on an Ethernet device */
336*99a2dd95SBruce Richardson 
337*99a2dd95SBruce Richardson typedef int (*priority_flow_ctrl_set_t)(struct rte_eth_dev *dev,
338*99a2dd95SBruce Richardson 				struct rte_eth_pfc_conf *pfc_conf);
339*99a2dd95SBruce Richardson /**< @internal Setup priority flow control parameter on an Ethernet device */
340*99a2dd95SBruce Richardson 
341*99a2dd95SBruce Richardson typedef int (*reta_update_t)(struct rte_eth_dev *dev,
342*99a2dd95SBruce Richardson 			     struct rte_eth_rss_reta_entry64 *reta_conf,
343*99a2dd95SBruce Richardson 			     uint16_t reta_size);
344*99a2dd95SBruce Richardson /**< @internal Update RSS redirection table on an Ethernet device */
345*99a2dd95SBruce Richardson 
346*99a2dd95SBruce Richardson typedef int (*reta_query_t)(struct rte_eth_dev *dev,
347*99a2dd95SBruce Richardson 			    struct rte_eth_rss_reta_entry64 *reta_conf,
348*99a2dd95SBruce Richardson 			    uint16_t reta_size);
349*99a2dd95SBruce Richardson /**< @internal Query RSS redirection table on an Ethernet device */
350*99a2dd95SBruce Richardson 
351*99a2dd95SBruce Richardson typedef int (*rss_hash_update_t)(struct rte_eth_dev *dev,
352*99a2dd95SBruce Richardson 				 struct rte_eth_rss_conf *rss_conf);
353*99a2dd95SBruce Richardson /**< @internal Update RSS hash configuration of an Ethernet device */
354*99a2dd95SBruce Richardson 
355*99a2dd95SBruce Richardson typedef int (*rss_hash_conf_get_t)(struct rte_eth_dev *dev,
356*99a2dd95SBruce Richardson 				   struct rte_eth_rss_conf *rss_conf);
357*99a2dd95SBruce Richardson /**< @internal Get current RSS hash configuration of an Ethernet device */
358*99a2dd95SBruce Richardson 
359*99a2dd95SBruce Richardson typedef int (*eth_dev_led_on_t)(struct rte_eth_dev *dev);
360*99a2dd95SBruce Richardson /**< @internal Turn on SW controllable LED on an Ethernet device */
361*99a2dd95SBruce Richardson 
362*99a2dd95SBruce Richardson typedef int (*eth_dev_led_off_t)(struct rte_eth_dev *dev);
363*99a2dd95SBruce Richardson /**< @internal Turn off SW controllable LED on an Ethernet device */
364*99a2dd95SBruce Richardson 
365*99a2dd95SBruce Richardson typedef void (*eth_mac_addr_remove_t)(struct rte_eth_dev *dev, uint32_t index);
366*99a2dd95SBruce Richardson /**< @internal Remove MAC address from receive address register */
367*99a2dd95SBruce Richardson 
368*99a2dd95SBruce Richardson typedef int (*eth_mac_addr_add_t)(struct rte_eth_dev *dev,
369*99a2dd95SBruce Richardson 				  struct rte_ether_addr *mac_addr,
370*99a2dd95SBruce Richardson 				  uint32_t index,
371*99a2dd95SBruce Richardson 				  uint32_t vmdq);
372*99a2dd95SBruce Richardson /**< @internal Set a MAC address into Receive Address Register */
373*99a2dd95SBruce Richardson 
374*99a2dd95SBruce Richardson typedef int (*eth_mac_addr_set_t)(struct rte_eth_dev *dev,
375*99a2dd95SBruce Richardson 				  struct rte_ether_addr *mac_addr);
376*99a2dd95SBruce Richardson /**< @internal Set a MAC address into Receive Address Register */
377*99a2dd95SBruce Richardson 
378*99a2dd95SBruce Richardson typedef int (*eth_uc_hash_table_set_t)(struct rte_eth_dev *dev,
379*99a2dd95SBruce Richardson 				  struct rte_ether_addr *mac_addr,
380*99a2dd95SBruce Richardson 				  uint8_t on);
381*99a2dd95SBruce Richardson /**< @internal Set a Unicast Hash bitmap */
382*99a2dd95SBruce Richardson 
383*99a2dd95SBruce Richardson typedef int (*eth_uc_all_hash_table_set_t)(struct rte_eth_dev *dev,
384*99a2dd95SBruce Richardson 				  uint8_t on);
385*99a2dd95SBruce Richardson /**< @internal Set all Unicast Hash bitmap */
386*99a2dd95SBruce Richardson 
387*99a2dd95SBruce Richardson typedef int (*eth_set_queue_rate_limit_t)(struct rte_eth_dev *dev,
388*99a2dd95SBruce Richardson 				uint16_t queue_idx,
389*99a2dd95SBruce Richardson 				uint16_t tx_rate);
390*99a2dd95SBruce Richardson /**< @internal Set queue TX rate */
391*99a2dd95SBruce Richardson 
392*99a2dd95SBruce Richardson typedef int (*eth_mirror_rule_set_t)(struct rte_eth_dev *dev,
393*99a2dd95SBruce Richardson 				  struct rte_eth_mirror_conf *mirror_conf,
394*99a2dd95SBruce Richardson 				  uint8_t rule_id,
395*99a2dd95SBruce Richardson 				  uint8_t on);
396*99a2dd95SBruce Richardson /**< @internal Add a traffic mirroring rule on an Ethernet device */
397*99a2dd95SBruce Richardson 
398*99a2dd95SBruce Richardson typedef int (*eth_mirror_rule_reset_t)(struct rte_eth_dev *dev,
399*99a2dd95SBruce Richardson 				  uint8_t rule_id);
400*99a2dd95SBruce Richardson /**< @internal Remove a traffic mirroring rule on an Ethernet device */
401*99a2dd95SBruce Richardson 
402*99a2dd95SBruce Richardson typedef int (*eth_udp_tunnel_port_add_t)(struct rte_eth_dev *dev,
403*99a2dd95SBruce Richardson 					 struct rte_eth_udp_tunnel *tunnel_udp);
404*99a2dd95SBruce Richardson /**< @internal Add tunneling UDP port */
405*99a2dd95SBruce Richardson 
406*99a2dd95SBruce Richardson typedef int (*eth_udp_tunnel_port_del_t)(struct rte_eth_dev *dev,
407*99a2dd95SBruce Richardson 					 struct rte_eth_udp_tunnel *tunnel_udp);
408*99a2dd95SBruce Richardson /**< @internal Delete tunneling UDP port */
409*99a2dd95SBruce Richardson 
410*99a2dd95SBruce Richardson typedef int (*eth_set_mc_addr_list_t)(struct rte_eth_dev *dev,
411*99a2dd95SBruce Richardson 				      struct rte_ether_addr *mc_addr_set,
412*99a2dd95SBruce Richardson 				      uint32_t nb_mc_addr);
413*99a2dd95SBruce Richardson /**< @internal set the list of multicast addresses on an Ethernet device */
414*99a2dd95SBruce Richardson 
415*99a2dd95SBruce Richardson typedef int (*eth_timesync_enable_t)(struct rte_eth_dev *dev);
416*99a2dd95SBruce Richardson /**< @internal Function used to enable IEEE1588/802.1AS timestamping. */
417*99a2dd95SBruce Richardson 
418*99a2dd95SBruce Richardson typedef int (*eth_timesync_disable_t)(struct rte_eth_dev *dev);
419*99a2dd95SBruce Richardson /**< @internal Function used to disable IEEE1588/802.1AS timestamping. */
420*99a2dd95SBruce Richardson 
421*99a2dd95SBruce Richardson typedef int (*eth_timesync_read_rx_timestamp_t)(struct rte_eth_dev *dev,
422*99a2dd95SBruce Richardson 						struct timespec *timestamp,
423*99a2dd95SBruce Richardson 						uint32_t flags);
424*99a2dd95SBruce Richardson /**< @internal Function used to read an RX IEEE1588/802.1AS timestamp. */
425*99a2dd95SBruce Richardson 
426*99a2dd95SBruce Richardson typedef int (*eth_timesync_read_tx_timestamp_t)(struct rte_eth_dev *dev,
427*99a2dd95SBruce Richardson 						struct timespec *timestamp);
428*99a2dd95SBruce Richardson /**< @internal Function used to read a TX IEEE1588/802.1AS timestamp. */
429*99a2dd95SBruce Richardson 
430*99a2dd95SBruce Richardson typedef int (*eth_timesync_adjust_time)(struct rte_eth_dev *dev, int64_t);
431*99a2dd95SBruce Richardson /**< @internal Function used to adjust the device clock */
432*99a2dd95SBruce Richardson 
433*99a2dd95SBruce Richardson typedef int (*eth_timesync_read_time)(struct rte_eth_dev *dev,
434*99a2dd95SBruce Richardson 				      struct timespec *timestamp);
435*99a2dd95SBruce Richardson /**< @internal Function used to get time from the device clock. */
436*99a2dd95SBruce Richardson 
437*99a2dd95SBruce Richardson typedef int (*eth_timesync_write_time)(struct rte_eth_dev *dev,
438*99a2dd95SBruce Richardson 				       const struct timespec *timestamp);
439*99a2dd95SBruce Richardson /**< @internal Function used to get time from the device clock */
440*99a2dd95SBruce Richardson 
441*99a2dd95SBruce Richardson typedef int (*eth_read_clock)(struct rte_eth_dev *dev,
442*99a2dd95SBruce Richardson 				      uint64_t *timestamp);
443*99a2dd95SBruce Richardson /**< @internal Function used to get the current value of the device clock. */
444*99a2dd95SBruce Richardson 
445*99a2dd95SBruce Richardson typedef int (*eth_get_reg_t)(struct rte_eth_dev *dev,
446*99a2dd95SBruce Richardson 				struct rte_dev_reg_info *info);
447*99a2dd95SBruce Richardson /**< @internal Retrieve registers  */
448*99a2dd95SBruce Richardson 
449*99a2dd95SBruce Richardson typedef int (*eth_get_eeprom_length_t)(struct rte_eth_dev *dev);
450*99a2dd95SBruce Richardson /**< @internal Retrieve eeprom size  */
451*99a2dd95SBruce Richardson 
452*99a2dd95SBruce Richardson typedef int (*eth_get_eeprom_t)(struct rte_eth_dev *dev,
453*99a2dd95SBruce Richardson 				struct rte_dev_eeprom_info *info);
454*99a2dd95SBruce Richardson /**< @internal Retrieve eeprom data  */
455*99a2dd95SBruce Richardson 
456*99a2dd95SBruce Richardson typedef int (*eth_set_eeprom_t)(struct rte_eth_dev *dev,
457*99a2dd95SBruce Richardson 				struct rte_dev_eeprom_info *info);
458*99a2dd95SBruce Richardson /**< @internal Program eeprom data  */
459*99a2dd95SBruce Richardson 
460*99a2dd95SBruce Richardson typedef int (*eth_get_module_info_t)(struct rte_eth_dev *dev,
461*99a2dd95SBruce Richardson 				     struct rte_eth_dev_module_info *modinfo);
462*99a2dd95SBruce Richardson /**< @internal Retrieve type and size of plugin module eeprom */
463*99a2dd95SBruce Richardson 
464*99a2dd95SBruce Richardson typedef int (*eth_get_module_eeprom_t)(struct rte_eth_dev *dev,
465*99a2dd95SBruce Richardson 				       struct rte_dev_eeprom_info *info);
466*99a2dd95SBruce Richardson /**< @internal Retrieve plugin module eeprom data */
467*99a2dd95SBruce Richardson 
468*99a2dd95SBruce Richardson struct rte_flow_ops;
469*99a2dd95SBruce Richardson /**
470*99a2dd95SBruce Richardson  * @internal
471*99a2dd95SBruce Richardson  * Get flow operations.
472*99a2dd95SBruce Richardson  *
473*99a2dd95SBruce Richardson  * If the flow API is not supported for the specified device,
474*99a2dd95SBruce Richardson  * the driver can return NULL.
475*99a2dd95SBruce Richardson  */
476*99a2dd95SBruce Richardson typedef int (*eth_flow_ops_get_t)(struct rte_eth_dev *dev,
477*99a2dd95SBruce Richardson 				  const struct rte_flow_ops **ops);
478*99a2dd95SBruce Richardson 
479*99a2dd95SBruce Richardson typedef int (*eth_tm_ops_get_t)(struct rte_eth_dev *dev, void *ops);
480*99a2dd95SBruce Richardson /**< @internal Get Traffic Management (TM) operations on an Ethernet device */
481*99a2dd95SBruce Richardson 
482*99a2dd95SBruce Richardson typedef int (*eth_mtr_ops_get_t)(struct rte_eth_dev *dev, void *ops);
483*99a2dd95SBruce Richardson /**< @internal Get Traffic Metering and Policing (MTR) operations */
484*99a2dd95SBruce Richardson 
485*99a2dd95SBruce Richardson typedef int (*eth_get_dcb_info)(struct rte_eth_dev *dev,
486*99a2dd95SBruce Richardson 				 struct rte_eth_dcb_info *dcb_info);
487*99a2dd95SBruce Richardson /**< @internal Get dcb information on an Ethernet device */
488*99a2dd95SBruce Richardson 
489*99a2dd95SBruce Richardson typedef int (*eth_pool_ops_supported_t)(struct rte_eth_dev *dev,
490*99a2dd95SBruce Richardson 						const char *pool);
491*99a2dd95SBruce Richardson /**< @internal Test if a port supports specific mempool ops */
492*99a2dd95SBruce Richardson 
493*99a2dd95SBruce Richardson /**
494*99a2dd95SBruce Richardson  * @internal
495*99a2dd95SBruce Richardson  * Get the hairpin capabilities.
496*99a2dd95SBruce Richardson  *
497*99a2dd95SBruce Richardson  * @param dev
498*99a2dd95SBruce Richardson  *   ethdev handle of port.
499*99a2dd95SBruce Richardson  * @param cap
500*99a2dd95SBruce Richardson  *   returns the hairpin capabilities from the device.
501*99a2dd95SBruce Richardson  *
502*99a2dd95SBruce Richardson  * @return
503*99a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
504*99a2dd95SBruce Richardson  *
505*99a2dd95SBruce Richardson  * @retval 0
506*99a2dd95SBruce Richardson  *   Success, hairpin is supported.
507*99a2dd95SBruce Richardson  * @retval -ENOTSUP
508*99a2dd95SBruce Richardson  *   Hairpin is not supported.
509*99a2dd95SBruce Richardson  */
510*99a2dd95SBruce Richardson typedef int (*eth_hairpin_cap_get_t)(struct rte_eth_dev *dev,
511*99a2dd95SBruce Richardson 				     struct rte_eth_hairpin_cap *cap);
512*99a2dd95SBruce Richardson 
513*99a2dd95SBruce Richardson /**
514*99a2dd95SBruce Richardson  * @internal
515*99a2dd95SBruce Richardson  * Setup RX hairpin queue.
516*99a2dd95SBruce Richardson  *
517*99a2dd95SBruce Richardson  * @param dev
518*99a2dd95SBruce Richardson  *   ethdev handle of port.
519*99a2dd95SBruce Richardson  * @param rx_queue_id
520*99a2dd95SBruce Richardson  *   the selected RX queue index.
521*99a2dd95SBruce Richardson  * @param nb_rx_desc
522*99a2dd95SBruce Richardson  *   the requested number of descriptors for this queue. 0 - use PMD default.
523*99a2dd95SBruce Richardson  * @param conf
524*99a2dd95SBruce Richardson  *   the RX hairpin configuration structure.
525*99a2dd95SBruce Richardson  *
526*99a2dd95SBruce Richardson  * @return
527*99a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
528*99a2dd95SBruce Richardson  *
529*99a2dd95SBruce Richardson  * @retval 0
530*99a2dd95SBruce Richardson  *   Success, hairpin is supported.
531*99a2dd95SBruce Richardson  * @retval -ENOTSUP
532*99a2dd95SBruce Richardson  *   Hairpin is not supported.
533*99a2dd95SBruce Richardson  * @retval -EINVAL
534*99a2dd95SBruce Richardson  *   One of the parameters is invalid.
535*99a2dd95SBruce Richardson  * @retval -ENOMEM
536*99a2dd95SBruce Richardson  *   Unable to allocate resources.
537*99a2dd95SBruce Richardson  */
538*99a2dd95SBruce Richardson typedef int (*eth_rx_hairpin_queue_setup_t)
539*99a2dd95SBruce Richardson 	(struct rte_eth_dev *dev, uint16_t rx_queue_id,
540*99a2dd95SBruce Richardson 	 uint16_t nb_rx_desc,
541*99a2dd95SBruce Richardson 	 const struct rte_eth_hairpin_conf *conf);
542*99a2dd95SBruce Richardson 
543*99a2dd95SBruce Richardson /**
544*99a2dd95SBruce Richardson  * @internal
545*99a2dd95SBruce Richardson  * Setup TX hairpin queue.
546*99a2dd95SBruce Richardson  *
547*99a2dd95SBruce Richardson  * @param dev
548*99a2dd95SBruce Richardson  *   ethdev handle of port.
549*99a2dd95SBruce Richardson  * @param tx_queue_id
550*99a2dd95SBruce Richardson  *   the selected TX queue index.
551*99a2dd95SBruce Richardson  * @param nb_tx_desc
552*99a2dd95SBruce Richardson  *   the requested number of descriptors for this queue. 0 - use PMD default.
553*99a2dd95SBruce Richardson  * @param conf
554*99a2dd95SBruce Richardson  *   the TX hairpin configuration structure.
555*99a2dd95SBruce Richardson  *
556*99a2dd95SBruce Richardson  * @return
557*99a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
558*99a2dd95SBruce Richardson  *
559*99a2dd95SBruce Richardson  * @retval 0
560*99a2dd95SBruce Richardson  *   Success, hairpin is supported.
561*99a2dd95SBruce Richardson  * @retval -ENOTSUP
562*99a2dd95SBruce Richardson  *   Hairpin is not supported.
563*99a2dd95SBruce Richardson  * @retval -EINVAL
564*99a2dd95SBruce Richardson  *   One of the parameters is invalid.
565*99a2dd95SBruce Richardson  * @retval -ENOMEM
566*99a2dd95SBruce Richardson  *   Unable to allocate resources.
567*99a2dd95SBruce Richardson  */
568*99a2dd95SBruce Richardson typedef int (*eth_tx_hairpin_queue_setup_t)
569*99a2dd95SBruce Richardson 	(struct rte_eth_dev *dev, uint16_t tx_queue_id,
570*99a2dd95SBruce Richardson 	 uint16_t nb_tx_desc,
571*99a2dd95SBruce Richardson 	 const struct rte_eth_hairpin_conf *hairpin_conf);
572*99a2dd95SBruce Richardson 
573*99a2dd95SBruce Richardson /**
574*99a2dd95SBruce Richardson  * @internal
575*99a2dd95SBruce Richardson  * Get Forward Error Correction(FEC) capability.
576*99a2dd95SBruce Richardson  *
577*99a2dd95SBruce Richardson  * @param dev
578*99a2dd95SBruce Richardson  *   ethdev handle of port.
579*99a2dd95SBruce Richardson  * @param speed_fec_capa
580*99a2dd95SBruce Richardson  *   speed_fec_capa is out only with per-speed capabilities.
581*99a2dd95SBruce Richardson  * @param num
582*99a2dd95SBruce Richardson  *   a number of elements in an speed_fec_capa array.
583*99a2dd95SBruce Richardson  *
584*99a2dd95SBruce Richardson  * @return
585*99a2dd95SBruce Richardson  *   Negative errno value on error, positive value on success.
586*99a2dd95SBruce Richardson  *
587*99a2dd95SBruce Richardson  * @retval positive value
588*99a2dd95SBruce Richardson  *   A non-negative value lower or equal to num: success. The return value
589*99a2dd95SBruce Richardson  *   is the number of entries filled in the fec capa array.
590*99a2dd95SBruce Richardson  *   A non-negative value higher than num: error, the given fec capa array
591*99a2dd95SBruce Richardson  *   is too small. The return value corresponds to the num that should
592*99a2dd95SBruce Richardson  *   be given to succeed. The entries in the fec capa array are not valid
593*99a2dd95SBruce Richardson  *   and shall not be used by the caller.
594*99a2dd95SBruce Richardson  * @retval -ENOTSUP
595*99a2dd95SBruce Richardson  *   Operation is not supported.
596*99a2dd95SBruce Richardson  * @retval -EIO
597*99a2dd95SBruce Richardson  *   Device is removed.
598*99a2dd95SBruce Richardson  * @retval -EINVAL
599*99a2dd95SBruce Richardson  *   *num* or *speed_fec_capa* invalid.
600*99a2dd95SBruce Richardson  */
601*99a2dd95SBruce Richardson typedef int (*eth_fec_get_capability_t)(struct rte_eth_dev *dev,
602*99a2dd95SBruce Richardson 		struct rte_eth_fec_capa *speed_fec_capa, unsigned int num);
603*99a2dd95SBruce Richardson 
604*99a2dd95SBruce Richardson /**
605*99a2dd95SBruce Richardson  * @internal
606*99a2dd95SBruce Richardson  * Get Forward Error Correction(FEC) mode.
607*99a2dd95SBruce Richardson  *
608*99a2dd95SBruce Richardson  * @param dev
609*99a2dd95SBruce Richardson  *   ethdev handle of port.
610*99a2dd95SBruce Richardson  * @param fec_capa
611*99a2dd95SBruce Richardson  *   a bitmask of enabled FEC modes. If AUTO bit is set, other
612*99a2dd95SBruce Richardson  *   bits specify FEC modes which may be negotiated. If AUTO
613*99a2dd95SBruce Richardson  *   bit is clear, specify FEC modes to be used (only one valid
614*99a2dd95SBruce Richardson  *   mode per speed may be set).
615*99a2dd95SBruce Richardson  *
616*99a2dd95SBruce Richardson  * @return
617*99a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
618*99a2dd95SBruce Richardson  *
619*99a2dd95SBruce Richardson  * @retval 0
620*99a2dd95SBruce Richardson  *   Success, get FEC success.
621*99a2dd95SBruce Richardson  * @retval -ENOTSUP
622*99a2dd95SBruce Richardson  *   Operation is not supported.
623*99a2dd95SBruce Richardson  * @retval -EIO
624*99a2dd95SBruce Richardson  *   Device is removed.
625*99a2dd95SBruce Richardson  */
626*99a2dd95SBruce Richardson typedef int (*eth_fec_get_t)(struct rte_eth_dev *dev,
627*99a2dd95SBruce Richardson 			     uint32_t *fec_capa);
628*99a2dd95SBruce Richardson 
629*99a2dd95SBruce Richardson /**
630*99a2dd95SBruce Richardson  * @internal
631*99a2dd95SBruce Richardson  * Set Forward Error Correction(FEC) mode.
632*99a2dd95SBruce Richardson  *
633*99a2dd95SBruce Richardson  * @param dev
634*99a2dd95SBruce Richardson  *   ethdev handle of port.
635*99a2dd95SBruce Richardson  * @param fec_capa
636*99a2dd95SBruce Richardson  *   bitmask of allowed FEC modes. It must be only one
637*99a2dd95SBruce Richardson  *   if AUTO is disabled. If AUTO is enabled, other
638*99a2dd95SBruce Richardson  *   bits specify FEC modes which may be negotiated.
639*99a2dd95SBruce Richardson  *
640*99a2dd95SBruce Richardson  * @return
641*99a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
642*99a2dd95SBruce Richardson  *
643*99a2dd95SBruce Richardson  * @retval 0
644*99a2dd95SBruce Richardson  *   Success, set FEC success.
645*99a2dd95SBruce Richardson  * @retval -ENOTSUP
646*99a2dd95SBruce Richardson  *   Operation is not supported.
647*99a2dd95SBruce Richardson  * @retval -EINVAL
648*99a2dd95SBruce Richardson  *   Unsupported FEC mode requested.
649*99a2dd95SBruce Richardson  * @retval -EIO
650*99a2dd95SBruce Richardson  *   Device is removed.
651*99a2dd95SBruce Richardson  */
652*99a2dd95SBruce Richardson typedef int (*eth_fec_set_t)(struct rte_eth_dev *dev, uint32_t fec_capa);
653*99a2dd95SBruce Richardson 
654*99a2dd95SBruce Richardson /**
655*99a2dd95SBruce Richardson  * @internal
656*99a2dd95SBruce Richardson  * Get all hairpin Tx/Rx peer ports of the current device, if any.
657*99a2dd95SBruce Richardson  *
658*99a2dd95SBruce Richardson  * @param dev
659*99a2dd95SBruce Richardson  *   ethdev handle of port.
660*99a2dd95SBruce Richardson  * @param peer_ports
661*99a2dd95SBruce Richardson  *   array to save the ports list.
662*99a2dd95SBruce Richardson  * @param len
663*99a2dd95SBruce Richardson  *   array length.
664*99a2dd95SBruce Richardson  * @param direction
665*99a2dd95SBruce Richardson  *   value to decide the current to peer direction
666*99a2dd95SBruce Richardson  *   positive - used as Tx to get all peer Rx ports.
667*99a2dd95SBruce Richardson  *   zero - used as Rx to get all peer Tx ports.
668*99a2dd95SBruce Richardson  *
669*99a2dd95SBruce Richardson  * @return
670*99a2dd95SBruce Richardson  *   Negative errno value on error, 0 or positive on success.
671*99a2dd95SBruce Richardson  *
672*99a2dd95SBruce Richardson  * @retval 0
673*99a2dd95SBruce Richardson  *   Success, no peer ports.
674*99a2dd95SBruce Richardson  * @retval >0
675*99a2dd95SBruce Richardson  *   Actual number of the peer ports.
676*99a2dd95SBruce Richardson  * @retval -ENOTSUP
677*99a2dd95SBruce Richardson  *   Get peer ports API is not supported.
678*99a2dd95SBruce Richardson  * @retval -EINVAL
679*99a2dd95SBruce Richardson  *   One of the parameters is invalid.
680*99a2dd95SBruce Richardson  */
681*99a2dd95SBruce Richardson typedef int (*hairpin_get_peer_ports_t)(struct rte_eth_dev *dev,
682*99a2dd95SBruce Richardson 					uint16_t *peer_ports, size_t len,
683*99a2dd95SBruce Richardson 					uint32_t direction);
684*99a2dd95SBruce Richardson 
685*99a2dd95SBruce Richardson /**
686*99a2dd95SBruce Richardson  * @internal
687*99a2dd95SBruce Richardson  * Bind all hairpin Tx queues of one port to the Rx queues of the peer port.
688*99a2dd95SBruce Richardson  *
689*99a2dd95SBruce Richardson  * @param dev
690*99a2dd95SBruce Richardson  *   ethdev handle of port.
691*99a2dd95SBruce Richardson  * @param rx_port
692*99a2dd95SBruce Richardson  *   the peer Rx port.
693*99a2dd95SBruce Richardson  *
694*99a2dd95SBruce Richardson  * @return
695*99a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
696*99a2dd95SBruce Richardson  *
697*99a2dd95SBruce Richardson  * @retval 0
698*99a2dd95SBruce Richardson  *   Success, bind successfully.
699*99a2dd95SBruce Richardson  * @retval -ENOTSUP
700*99a2dd95SBruce Richardson  *   Bind API is not supported.
701*99a2dd95SBruce Richardson  * @retval -EINVAL
702*99a2dd95SBruce Richardson  *   One of the parameters is invalid.
703*99a2dd95SBruce Richardson  * @retval -EBUSY
704*99a2dd95SBruce Richardson  *   Device is not started.
705*99a2dd95SBruce Richardson  */
706*99a2dd95SBruce Richardson typedef int (*eth_hairpin_bind_t)(struct rte_eth_dev *dev,
707*99a2dd95SBruce Richardson 				uint16_t rx_port);
708*99a2dd95SBruce Richardson 
709*99a2dd95SBruce Richardson /**
710*99a2dd95SBruce Richardson  * @internal
711*99a2dd95SBruce Richardson  * Unbind all hairpin Tx queues of one port from the Rx queues of the peer port.
712*99a2dd95SBruce Richardson  *
713*99a2dd95SBruce Richardson  * @param dev
714*99a2dd95SBruce Richardson  *   ethdev handle of port.
715*99a2dd95SBruce Richardson  * @param rx_port
716*99a2dd95SBruce Richardson  *   the peer Rx port.
717*99a2dd95SBruce Richardson  *
718*99a2dd95SBruce Richardson  * @return
719*99a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
720*99a2dd95SBruce Richardson  *
721*99a2dd95SBruce Richardson  * @retval 0
722*99a2dd95SBruce Richardson  *   Success, unbind successfully.
723*99a2dd95SBruce Richardson  * @retval -ENOTSUP
724*99a2dd95SBruce Richardson  *   Bind API is not supported.
725*99a2dd95SBruce Richardson  * @retval -EINVAL
726*99a2dd95SBruce Richardson  *   One of the parameters is invalid.
727*99a2dd95SBruce Richardson  * @retval -EBUSY
728*99a2dd95SBruce Richardson  *   Device is already stopped.
729*99a2dd95SBruce Richardson  */
730*99a2dd95SBruce Richardson typedef int (*eth_hairpin_unbind_t)(struct rte_eth_dev *dev,
731*99a2dd95SBruce Richardson 				  uint16_t rx_port);
732*99a2dd95SBruce Richardson 
733*99a2dd95SBruce Richardson typedef int (*eth_hairpin_queue_peer_update_t)
734*99a2dd95SBruce Richardson 	(struct rte_eth_dev *dev, uint16_t peer_queue,
735*99a2dd95SBruce Richardson 	 struct rte_hairpin_peer_info *current_info,
736*99a2dd95SBruce Richardson 	 struct rte_hairpin_peer_info *peer_info, uint32_t direction);
737*99a2dd95SBruce Richardson /**< @internal Update and fetch peer queue information. */
738*99a2dd95SBruce Richardson 
739*99a2dd95SBruce Richardson typedef int (*eth_hairpin_queue_peer_bind_t)
740*99a2dd95SBruce Richardson 	(struct rte_eth_dev *dev, uint16_t cur_queue,
741*99a2dd95SBruce Richardson 	 struct rte_hairpin_peer_info *peer_info, uint32_t direction);
742*99a2dd95SBruce Richardson /**< @internal Bind peer queue to the current queue with fetched information. */
743*99a2dd95SBruce Richardson 
744*99a2dd95SBruce Richardson typedef int (*eth_hairpin_queue_peer_unbind_t)
745*99a2dd95SBruce Richardson 	(struct rte_eth_dev *dev, uint16_t cur_queue, uint32_t direction);
746*99a2dd95SBruce Richardson /**< @internal Unbind peer queue from the current queue. */
747*99a2dd95SBruce Richardson 
748*99a2dd95SBruce Richardson /**
749*99a2dd95SBruce Richardson  * @internal
750*99a2dd95SBruce Richardson  * Get address of memory location whose contents will change whenever there is
751*99a2dd95SBruce Richardson  * new data to be received on an Rx queue.
752*99a2dd95SBruce Richardson  *
753*99a2dd95SBruce Richardson  * @param rxq
754*99a2dd95SBruce Richardson  *   Ethdev queue pointer.
755*99a2dd95SBruce Richardson  * @param pmc
756*99a2dd95SBruce Richardson  *   The pointer to power-optimized monitoring condition structure.
757*99a2dd95SBruce Richardson  * @return
758*99a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
759*99a2dd95SBruce Richardson  *
760*99a2dd95SBruce Richardson  * @retval 0
761*99a2dd95SBruce Richardson  *   Success
762*99a2dd95SBruce Richardson  * @retval -EINVAL
763*99a2dd95SBruce Richardson  *   Invalid parameters
764*99a2dd95SBruce Richardson  */
765*99a2dd95SBruce Richardson typedef int (*eth_get_monitor_addr_t)(void *rxq,
766*99a2dd95SBruce Richardson 		struct rte_power_monitor_cond *pmc);
767*99a2dd95SBruce Richardson 
768*99a2dd95SBruce Richardson /**
769*99a2dd95SBruce Richardson  * @internal
770*99a2dd95SBruce Richardson  * Get representor info to be able to calculate the unique representor ID.
771*99a2dd95SBruce Richardson  *
772*99a2dd95SBruce Richardson  * Caller should pass NULL as pointer of info to get number of entries,
773*99a2dd95SBruce Richardson  * allocate info buffer according to returned entry number, then call
774*99a2dd95SBruce Richardson  * again with buffer to get real info.
775*99a2dd95SBruce Richardson  *
776*99a2dd95SBruce Richardson  * To calculate the representor ID, caller should iterate each entry,
777*99a2dd95SBruce Richardson  * match controller index, pf index, vf or sf start index and range,
778*99a2dd95SBruce Richardson  * then calculate representor ID from offset to vf/sf start index.
779*99a2dd95SBruce Richardson  * @see rte_eth_representor_id_get.
780*99a2dd95SBruce Richardson  *
781*99a2dd95SBruce Richardson  * @param dev
782*99a2dd95SBruce Richardson  *   Ethdev handle of port.
783*99a2dd95SBruce Richardson  * @param [out] info
784*99a2dd95SBruce Richardson  *   Pointer to memory to save device representor info.
785*99a2dd95SBruce Richardson  * @return
786*99a2dd95SBruce Richardson  *   Negative errno value on error, number of info entries otherwise.
787*99a2dd95SBruce Richardson  */
788*99a2dd95SBruce Richardson 
789*99a2dd95SBruce Richardson typedef int (*eth_representor_info_get_t)(struct rte_eth_dev *dev,
790*99a2dd95SBruce Richardson 	struct rte_eth_representor_info *info);
791*99a2dd95SBruce Richardson 
792*99a2dd95SBruce Richardson /**
793*99a2dd95SBruce Richardson  * @internal A structure containing the functions exported by an Ethernet driver.
794*99a2dd95SBruce Richardson  */
795*99a2dd95SBruce Richardson struct eth_dev_ops {
796*99a2dd95SBruce Richardson 	eth_dev_configure_t        dev_configure; /**< Configure device. */
797*99a2dd95SBruce Richardson 	eth_dev_start_t            dev_start;     /**< Start device. */
798*99a2dd95SBruce Richardson 	eth_dev_stop_t             dev_stop;      /**< Stop device. */
799*99a2dd95SBruce Richardson 	eth_dev_set_link_up_t      dev_set_link_up;   /**< Device link up. */
800*99a2dd95SBruce Richardson 	eth_dev_set_link_down_t    dev_set_link_down; /**< Device link down. */
801*99a2dd95SBruce Richardson 	eth_dev_close_t            dev_close;     /**< Close device. */
802*99a2dd95SBruce Richardson 	eth_dev_reset_t		   dev_reset;	  /**< Reset device. */
803*99a2dd95SBruce Richardson 	eth_link_update_t          link_update;   /**< Get device link state. */
804*99a2dd95SBruce Richardson 	eth_is_removed_t           is_removed;
805*99a2dd95SBruce Richardson 	/**< Check if the device was physically removed. */
806*99a2dd95SBruce Richardson 
807*99a2dd95SBruce Richardson 	eth_promiscuous_enable_t   promiscuous_enable; /**< Promiscuous ON. */
808*99a2dd95SBruce Richardson 	eth_promiscuous_disable_t  promiscuous_disable;/**< Promiscuous OFF. */
809*99a2dd95SBruce Richardson 	eth_allmulticast_enable_t  allmulticast_enable;/**< RX multicast ON. */
810*99a2dd95SBruce Richardson 	eth_allmulticast_disable_t allmulticast_disable;/**< RX multicast OFF. */
811*99a2dd95SBruce Richardson 	eth_mac_addr_remove_t      mac_addr_remove; /**< Remove MAC address. */
812*99a2dd95SBruce Richardson 	eth_mac_addr_add_t         mac_addr_add;  /**< Add a MAC address. */
813*99a2dd95SBruce Richardson 	eth_mac_addr_set_t         mac_addr_set;  /**< Set a MAC address. */
814*99a2dd95SBruce Richardson 	eth_set_mc_addr_list_t     set_mc_addr_list; /**< set list of mcast addrs. */
815*99a2dd95SBruce Richardson 	mtu_set_t                  mtu_set;       /**< Set MTU. */
816*99a2dd95SBruce Richardson 
817*99a2dd95SBruce Richardson 	eth_stats_get_t            stats_get;     /**< Get generic device statistics. */
818*99a2dd95SBruce Richardson 	eth_stats_reset_t          stats_reset;   /**< Reset generic device statistics. */
819*99a2dd95SBruce Richardson 	eth_xstats_get_t           xstats_get;    /**< Get extended device statistics. */
820*99a2dd95SBruce Richardson 	eth_xstats_reset_t         xstats_reset;  /**< Reset extended device statistics. */
821*99a2dd95SBruce Richardson 	eth_xstats_get_names_t     xstats_get_names;
822*99a2dd95SBruce Richardson 	/**< Get names of extended statistics. */
823*99a2dd95SBruce Richardson 	eth_queue_stats_mapping_set_t queue_stats_mapping_set;
824*99a2dd95SBruce Richardson 	/**< Configure per queue stat counter mapping. */
825*99a2dd95SBruce Richardson 
826*99a2dd95SBruce Richardson 	eth_dev_infos_get_t        dev_infos_get; /**< Get device info. */
827*99a2dd95SBruce Richardson 	eth_rxq_info_get_t         rxq_info_get; /**< retrieve RX queue information. */
828*99a2dd95SBruce Richardson 	eth_txq_info_get_t         txq_info_get; /**< retrieve TX queue information. */
829*99a2dd95SBruce Richardson 	eth_burst_mode_get_t       rx_burst_mode_get; /**< Get RX burst mode */
830*99a2dd95SBruce Richardson 	eth_burst_mode_get_t       tx_burst_mode_get; /**< Get TX burst mode */
831*99a2dd95SBruce Richardson 	eth_fw_version_get_t       fw_version_get; /**< Get firmware version. */
832*99a2dd95SBruce Richardson 	eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
833*99a2dd95SBruce Richardson 	/**< Get packet types supported and identified by device. */
834*99a2dd95SBruce Richardson 	eth_dev_ptypes_set_t dev_ptypes_set;
835*99a2dd95SBruce Richardson 	/**< Inform Ethernet device about reduced range of packet types to handle. */
836*99a2dd95SBruce Richardson 
837*99a2dd95SBruce Richardson 	vlan_filter_set_t          vlan_filter_set; /**< Filter VLAN Setup. */
838*99a2dd95SBruce Richardson 	vlan_tpid_set_t            vlan_tpid_set; /**< Outer/Inner VLAN TPID Setup. */
839*99a2dd95SBruce Richardson 	vlan_strip_queue_set_t     vlan_strip_queue_set; /**< VLAN Stripping on queue. */
840*99a2dd95SBruce Richardson 	vlan_offload_set_t         vlan_offload_set; /**< Set VLAN Offload. */
841*99a2dd95SBruce Richardson 	vlan_pvid_set_t            vlan_pvid_set; /**< Set port based TX VLAN insertion. */
842*99a2dd95SBruce Richardson 
843*99a2dd95SBruce Richardson 	eth_queue_start_t          rx_queue_start;/**< Start RX for a queue. */
844*99a2dd95SBruce Richardson 	eth_queue_stop_t           rx_queue_stop; /**< Stop RX for a queue. */
845*99a2dd95SBruce Richardson 	eth_queue_start_t          tx_queue_start;/**< Start TX for a queue. */
846*99a2dd95SBruce Richardson 	eth_queue_stop_t           tx_queue_stop; /**< Stop TX for a queue. */
847*99a2dd95SBruce Richardson 	eth_rx_queue_setup_t       rx_queue_setup;/**< Set up device RX queue. */
848*99a2dd95SBruce Richardson 	eth_queue_release_t        rx_queue_release; /**< Release RX queue. */
849*99a2dd95SBruce Richardson 
850*99a2dd95SBruce Richardson 	eth_rx_enable_intr_t       rx_queue_intr_enable;  /**< Enable Rx queue interrupt. */
851*99a2dd95SBruce Richardson 	eth_rx_disable_intr_t      rx_queue_intr_disable; /**< Disable Rx queue interrupt. */
852*99a2dd95SBruce Richardson 	eth_tx_queue_setup_t       tx_queue_setup;/**< Set up device TX queue. */
853*99a2dd95SBruce Richardson 	eth_queue_release_t        tx_queue_release; /**< Release TX queue. */
854*99a2dd95SBruce Richardson 	eth_tx_done_cleanup_t      tx_done_cleanup;/**< Free tx ring mbufs */
855*99a2dd95SBruce Richardson 
856*99a2dd95SBruce Richardson 	eth_dev_led_on_t           dev_led_on;    /**< Turn on LED. */
857*99a2dd95SBruce Richardson 	eth_dev_led_off_t          dev_led_off;   /**< Turn off LED. */
858*99a2dd95SBruce Richardson 
859*99a2dd95SBruce Richardson 	flow_ctrl_get_t            flow_ctrl_get; /**< Get flow control. */
860*99a2dd95SBruce Richardson 	flow_ctrl_set_t            flow_ctrl_set; /**< Setup flow control. */
861*99a2dd95SBruce Richardson 	priority_flow_ctrl_set_t   priority_flow_ctrl_set; /**< Setup priority flow control. */
862*99a2dd95SBruce Richardson 
863*99a2dd95SBruce Richardson 	eth_uc_hash_table_set_t    uc_hash_table_set; /**< Set Unicast Table Array. */
864*99a2dd95SBruce Richardson 	eth_uc_all_hash_table_set_t uc_all_hash_table_set; /**< Set Unicast hash bitmap. */
865*99a2dd95SBruce Richardson 
866*99a2dd95SBruce Richardson 	eth_mirror_rule_set_t	   mirror_rule_set; /**< Add a traffic mirror rule. */
867*99a2dd95SBruce Richardson 	eth_mirror_rule_reset_t	   mirror_rule_reset; /**< reset a traffic mirror rule. */
868*99a2dd95SBruce Richardson 
869*99a2dd95SBruce Richardson 	eth_udp_tunnel_port_add_t  udp_tunnel_port_add; /** Add UDP tunnel port. */
870*99a2dd95SBruce Richardson 	eth_udp_tunnel_port_del_t  udp_tunnel_port_del; /** Del UDP tunnel port. */
871*99a2dd95SBruce Richardson 
872*99a2dd95SBruce Richardson 	eth_set_queue_rate_limit_t set_queue_rate_limit; /**< Set queue rate limit. */
873*99a2dd95SBruce Richardson 
874*99a2dd95SBruce Richardson 	rss_hash_update_t          rss_hash_update; /** Configure RSS hash protocols. */
875*99a2dd95SBruce Richardson 	rss_hash_conf_get_t        rss_hash_conf_get; /** Get current RSS hash configuration. */
876*99a2dd95SBruce Richardson 	reta_update_t              reta_update;   /** Update redirection table. */
877*99a2dd95SBruce Richardson 	reta_query_t               reta_query;    /** Query redirection table. */
878*99a2dd95SBruce Richardson 
879*99a2dd95SBruce Richardson 	eth_get_reg_t              get_reg;           /**< Get registers. */
880*99a2dd95SBruce Richardson 	eth_get_eeprom_length_t    get_eeprom_length; /**< Get eeprom length. */
881*99a2dd95SBruce Richardson 	eth_get_eeprom_t           get_eeprom;        /**< Get eeprom data. */
882*99a2dd95SBruce Richardson 	eth_set_eeprom_t           set_eeprom;        /**< Set eeprom. */
883*99a2dd95SBruce Richardson 
884*99a2dd95SBruce Richardson 	eth_get_module_info_t      get_module_info;
885*99a2dd95SBruce Richardson 	/** Get plugin module eeprom attribute. */
886*99a2dd95SBruce Richardson 	eth_get_module_eeprom_t    get_module_eeprom;
887*99a2dd95SBruce Richardson 	/** Get plugin module eeprom data. */
888*99a2dd95SBruce Richardson 
889*99a2dd95SBruce Richardson 	eth_flow_ops_get_t         flow_ops_get; /**< Get flow operations. */
890*99a2dd95SBruce Richardson 
891*99a2dd95SBruce Richardson 	eth_get_dcb_info           get_dcb_info; /** Get DCB information. */
892*99a2dd95SBruce Richardson 
893*99a2dd95SBruce Richardson 	eth_timesync_enable_t      timesync_enable;
894*99a2dd95SBruce Richardson 	/** Turn IEEE1588/802.1AS timestamping on. */
895*99a2dd95SBruce Richardson 	eth_timesync_disable_t     timesync_disable;
896*99a2dd95SBruce Richardson 	/** Turn IEEE1588/802.1AS timestamping off. */
897*99a2dd95SBruce Richardson 	eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp;
898*99a2dd95SBruce Richardson 	/** Read the IEEE1588/802.1AS RX timestamp. */
899*99a2dd95SBruce Richardson 	eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp;
900*99a2dd95SBruce Richardson 	/** Read the IEEE1588/802.1AS TX timestamp. */
901*99a2dd95SBruce Richardson 	eth_timesync_adjust_time   timesync_adjust_time; /** Adjust the device clock. */
902*99a2dd95SBruce Richardson 	eth_timesync_read_time     timesync_read_time; /** Get the device clock time. */
903*99a2dd95SBruce Richardson 	eth_timesync_write_time    timesync_write_time; /** Set the device clock time. */
904*99a2dd95SBruce Richardson 
905*99a2dd95SBruce Richardson 	eth_read_clock             read_clock;
906*99a2dd95SBruce Richardson 
907*99a2dd95SBruce Richardson 	eth_xstats_get_by_id_t     xstats_get_by_id;
908*99a2dd95SBruce Richardson 	/**< Get extended device statistic values by ID. */
909*99a2dd95SBruce Richardson 	eth_xstats_get_names_by_id_t xstats_get_names_by_id;
910*99a2dd95SBruce Richardson 	/**< Get name of extended device statistics by ID. */
911*99a2dd95SBruce Richardson 
912*99a2dd95SBruce Richardson 	eth_tm_ops_get_t tm_ops_get;
913*99a2dd95SBruce Richardson 	/**< Get Traffic Management (TM) operations. */
914*99a2dd95SBruce Richardson 
915*99a2dd95SBruce Richardson 	eth_mtr_ops_get_t mtr_ops_get;
916*99a2dd95SBruce Richardson 	/**< Get Traffic Metering and Policing (MTR) operations. */
917*99a2dd95SBruce Richardson 
918*99a2dd95SBruce Richardson 	eth_pool_ops_supported_t pool_ops_supported;
919*99a2dd95SBruce Richardson 	/**< Test if a port supports specific mempool ops */
920*99a2dd95SBruce Richardson 
921*99a2dd95SBruce Richardson 	eth_hairpin_cap_get_t hairpin_cap_get;
922*99a2dd95SBruce Richardson 	/**< Returns the hairpin capabilities. */
923*99a2dd95SBruce Richardson 	eth_rx_hairpin_queue_setup_t rx_hairpin_queue_setup;
924*99a2dd95SBruce Richardson 	/**< Set up device RX hairpin queue. */
925*99a2dd95SBruce Richardson 	eth_tx_hairpin_queue_setup_t tx_hairpin_queue_setup;
926*99a2dd95SBruce Richardson 	/**< Set up device TX hairpin queue. */
927*99a2dd95SBruce Richardson 
928*99a2dd95SBruce Richardson 	eth_fec_get_capability_t fec_get_capability;
929*99a2dd95SBruce Richardson 	/**< Get Forward Error Correction(FEC) capability. */
930*99a2dd95SBruce Richardson 	eth_fec_get_t fec_get;
931*99a2dd95SBruce Richardson 	/**< Get Forward Error Correction(FEC) mode. */
932*99a2dd95SBruce Richardson 	eth_fec_set_t fec_set;
933*99a2dd95SBruce Richardson 	/**< Set Forward Error Correction(FEC) mode. */
934*99a2dd95SBruce Richardson 	hairpin_get_peer_ports_t hairpin_get_peer_ports;
935*99a2dd95SBruce Richardson 	/**< Get hairpin peer ports list. */
936*99a2dd95SBruce Richardson 	eth_hairpin_bind_t hairpin_bind;
937*99a2dd95SBruce Richardson 	/**< Bind all hairpin Tx queues of device to the peer port Rx queues. */
938*99a2dd95SBruce Richardson 	eth_hairpin_unbind_t hairpin_unbind;
939*99a2dd95SBruce Richardson 	/**< Unbind all hairpin Tx queues from the peer port Rx queues. */
940*99a2dd95SBruce Richardson 	eth_hairpin_queue_peer_update_t hairpin_queue_peer_update;
941*99a2dd95SBruce Richardson 	/**< Pass the current queue info and get the peer queue info. */
942*99a2dd95SBruce Richardson 	eth_hairpin_queue_peer_bind_t hairpin_queue_peer_bind;
943*99a2dd95SBruce Richardson 	/**< Set up the connection between the pair of hairpin queues. */
944*99a2dd95SBruce Richardson 	eth_hairpin_queue_peer_unbind_t hairpin_queue_peer_unbind;
945*99a2dd95SBruce Richardson 	/**< Disconnect the hairpin queues of a pair from each other. */
946*99a2dd95SBruce Richardson 
947*99a2dd95SBruce Richardson 	eth_get_monitor_addr_t get_monitor_addr;
948*99a2dd95SBruce Richardson 	/**< Get power monitoring condition for Rx queue. */
949*99a2dd95SBruce Richardson 
950*99a2dd95SBruce Richardson 	eth_representor_info_get_t representor_info_get;
951*99a2dd95SBruce Richardson 	/**< Get representor info. */
952*99a2dd95SBruce Richardson };
953*99a2dd95SBruce Richardson 
954*99a2dd95SBruce Richardson /**
955*99a2dd95SBruce Richardson  * RX/TX queue states
956*99a2dd95SBruce Richardson  */
957*99a2dd95SBruce Richardson #define RTE_ETH_QUEUE_STATE_STOPPED 0
958*99a2dd95SBruce Richardson #define RTE_ETH_QUEUE_STATE_STARTED 1
959*99a2dd95SBruce Richardson #define RTE_ETH_QUEUE_STATE_HAIRPIN 2
960*99a2dd95SBruce Richardson 
961*99a2dd95SBruce Richardson /**
962*99a2dd95SBruce Richardson  * @internal
963*99a2dd95SBruce Richardson  * Check if the selected Rx queue is hairpin queue.
964*99a2dd95SBruce Richardson  *
965*99a2dd95SBruce Richardson  * @param dev
966*99a2dd95SBruce Richardson  *  Pointer to the selected device.
967*99a2dd95SBruce Richardson  * @param queue_id
968*99a2dd95SBruce Richardson  *  The selected queue.
969*99a2dd95SBruce Richardson  *
970*99a2dd95SBruce Richardson  * @return
971*99a2dd95SBruce Richardson  *   - (1) if the queue is hairpin queue, 0 otherwise.
972*99a2dd95SBruce Richardson  */
973*99a2dd95SBruce Richardson __rte_internal
974*99a2dd95SBruce Richardson int rte_eth_dev_is_rx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id);
975*99a2dd95SBruce Richardson 
976*99a2dd95SBruce Richardson /**
977*99a2dd95SBruce Richardson  * @internal
978*99a2dd95SBruce Richardson  * Check if the selected Tx queue is hairpin queue.
979*99a2dd95SBruce Richardson  *
980*99a2dd95SBruce Richardson  * @param dev
981*99a2dd95SBruce Richardson  *  Pointer to the selected device.
982*99a2dd95SBruce Richardson  * @param queue_id
983*99a2dd95SBruce Richardson  *  The selected queue.
984*99a2dd95SBruce Richardson  *
985*99a2dd95SBruce Richardson  * @return
986*99a2dd95SBruce Richardson  *   - (1) if the queue is hairpin queue, 0 otherwise.
987*99a2dd95SBruce Richardson  */
988*99a2dd95SBruce Richardson __rte_internal
989*99a2dd95SBruce Richardson int rte_eth_dev_is_tx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id);
990*99a2dd95SBruce Richardson 
991*99a2dd95SBruce Richardson /**
992*99a2dd95SBruce Richardson  * @internal
993*99a2dd95SBruce Richardson  * Returns a ethdev slot specified by the unique identifier name.
994*99a2dd95SBruce Richardson  *
995*99a2dd95SBruce Richardson  * @param	name
996*99a2dd95SBruce Richardson  *  The pointer to the Unique identifier name for each Ethernet device
997*99a2dd95SBruce Richardson  * @return
998*99a2dd95SBruce Richardson  *   - The pointer to the ethdev slot, on success. NULL on error
999*99a2dd95SBruce Richardson  */
1000*99a2dd95SBruce Richardson __rte_internal
1001*99a2dd95SBruce Richardson struct rte_eth_dev *rte_eth_dev_allocated(const char *name);
1002*99a2dd95SBruce Richardson 
1003*99a2dd95SBruce Richardson /**
1004*99a2dd95SBruce Richardson  * @internal
1005*99a2dd95SBruce Richardson  * Allocates a new ethdev slot for an ethernet device and returns the pointer
1006*99a2dd95SBruce Richardson  * to that slot for the driver to use.
1007*99a2dd95SBruce Richardson  *
1008*99a2dd95SBruce Richardson  * @param	name	Unique identifier name for each Ethernet device
1009*99a2dd95SBruce Richardson  * @return
1010*99a2dd95SBruce Richardson  *   - Slot in the rte_dev_devices array for a new device;
1011*99a2dd95SBruce Richardson  */
1012*99a2dd95SBruce Richardson __rte_internal
1013*99a2dd95SBruce Richardson struct rte_eth_dev *rte_eth_dev_allocate(const char *name);
1014*99a2dd95SBruce Richardson 
1015*99a2dd95SBruce Richardson /**
1016*99a2dd95SBruce Richardson  * @internal
1017*99a2dd95SBruce Richardson  * Attach to the ethdev already initialized by the primary
1018*99a2dd95SBruce Richardson  * process.
1019*99a2dd95SBruce Richardson  *
1020*99a2dd95SBruce Richardson  * @param       name    Ethernet device's name.
1021*99a2dd95SBruce Richardson  * @return
1022*99a2dd95SBruce Richardson  *   - Success: Slot in the rte_dev_devices array for attached
1023*99a2dd95SBruce Richardson  *        device.
1024*99a2dd95SBruce Richardson  *   - Error: Null pointer.
1025*99a2dd95SBruce Richardson  */
1026*99a2dd95SBruce Richardson __rte_internal
1027*99a2dd95SBruce Richardson struct rte_eth_dev *rte_eth_dev_attach_secondary(const char *name);
1028*99a2dd95SBruce Richardson 
1029*99a2dd95SBruce Richardson /**
1030*99a2dd95SBruce Richardson  * @internal
1031*99a2dd95SBruce Richardson  * Notify RTE_ETH_EVENT_DESTROY and release the specified ethdev port.
1032*99a2dd95SBruce Richardson  *
1033*99a2dd95SBruce Richardson  * The following PMD-managed data fields will be freed:
1034*99a2dd95SBruce Richardson  *   - dev_private
1035*99a2dd95SBruce Richardson  *   - mac_addrs
1036*99a2dd95SBruce Richardson  *   - hash_mac_addrs
1037*99a2dd95SBruce Richardson  * If one of these fields should not be freed,
1038*99a2dd95SBruce Richardson  * it must be reset to NULL by the PMD, typically in dev_close method.
1039*99a2dd95SBruce Richardson  *
1040*99a2dd95SBruce Richardson  * @param eth_dev
1041*99a2dd95SBruce Richardson  * Device to be detached.
1042*99a2dd95SBruce Richardson  * @return
1043*99a2dd95SBruce Richardson  *   - 0 on success, negative on error
1044*99a2dd95SBruce Richardson  */
1045*99a2dd95SBruce Richardson __rte_internal
1046*99a2dd95SBruce Richardson int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev);
1047*99a2dd95SBruce Richardson 
1048*99a2dd95SBruce Richardson /**
1049*99a2dd95SBruce Richardson  * @internal
1050*99a2dd95SBruce Richardson  * Release device queues and clear its configuration to force the user
1051*99a2dd95SBruce Richardson  * application to reconfigure it. It is for internal use only.
1052*99a2dd95SBruce Richardson  *
1053*99a2dd95SBruce Richardson  * @param dev
1054*99a2dd95SBruce Richardson  *  Pointer to struct rte_eth_dev.
1055*99a2dd95SBruce Richardson  *
1056*99a2dd95SBruce Richardson  * @return
1057*99a2dd95SBruce Richardson  *  void
1058*99a2dd95SBruce Richardson  */
1059*99a2dd95SBruce Richardson __rte_internal
1060*99a2dd95SBruce Richardson void rte_eth_dev_internal_reset(struct rte_eth_dev *dev);
1061*99a2dd95SBruce Richardson 
1062*99a2dd95SBruce Richardson /**
1063*99a2dd95SBruce Richardson  * @internal Executes all the user application registered callbacks for
1064*99a2dd95SBruce Richardson  * the specific device. It is for DPDK internal user only. User
1065*99a2dd95SBruce Richardson  * application should not call it directly.
1066*99a2dd95SBruce Richardson  *
1067*99a2dd95SBruce Richardson  * @param dev
1068*99a2dd95SBruce Richardson  *  Pointer to struct rte_eth_dev.
1069*99a2dd95SBruce Richardson  * @param event
1070*99a2dd95SBruce Richardson  *  Eth device interrupt event type.
1071*99a2dd95SBruce Richardson  * @param ret_param
1072*99a2dd95SBruce Richardson  *  To pass data back to user application.
1073*99a2dd95SBruce Richardson  *  This allows the user application to decide if a particular function
1074*99a2dd95SBruce Richardson  *  is permitted or not.
1075*99a2dd95SBruce Richardson  *
1076*99a2dd95SBruce Richardson  * @return
1077*99a2dd95SBruce Richardson  *  int
1078*99a2dd95SBruce Richardson  */
1079*99a2dd95SBruce Richardson __rte_internal
1080*99a2dd95SBruce Richardson int rte_eth_dev_callback_process(struct rte_eth_dev *dev,
1081*99a2dd95SBruce Richardson 		enum rte_eth_event_type event, void *ret_param);
1082*99a2dd95SBruce Richardson 
1083*99a2dd95SBruce Richardson /**
1084*99a2dd95SBruce Richardson  * @internal
1085*99a2dd95SBruce Richardson  * This is the last step of device probing.
1086*99a2dd95SBruce Richardson  * It must be called after a port is allocated and initialized successfully.
1087*99a2dd95SBruce Richardson  *
1088*99a2dd95SBruce Richardson  * The notification RTE_ETH_EVENT_NEW is sent to other entities
1089*99a2dd95SBruce Richardson  * (libraries and applications).
1090*99a2dd95SBruce Richardson  * The state is set as RTE_ETH_DEV_ATTACHED.
1091*99a2dd95SBruce Richardson  *
1092*99a2dd95SBruce Richardson  * @param dev
1093*99a2dd95SBruce Richardson  *  New ethdev port.
1094*99a2dd95SBruce Richardson  */
1095*99a2dd95SBruce Richardson __rte_internal
1096*99a2dd95SBruce Richardson void rte_eth_dev_probing_finish(struct rte_eth_dev *dev);
1097*99a2dd95SBruce Richardson 
1098*99a2dd95SBruce Richardson /**
1099*99a2dd95SBruce Richardson  * Create memzone for HW rings.
1100*99a2dd95SBruce Richardson  * malloc can't be used as the physical address is needed.
1101*99a2dd95SBruce Richardson  * If the memzone is already created, then this function returns a ptr
1102*99a2dd95SBruce Richardson  * to the old one.
1103*99a2dd95SBruce Richardson  *
1104*99a2dd95SBruce Richardson  * @param eth_dev
1105*99a2dd95SBruce Richardson  *   The *eth_dev* pointer is the address of the *rte_eth_dev* structure
1106*99a2dd95SBruce Richardson  * @param name
1107*99a2dd95SBruce Richardson  *   The name of the memory zone
1108*99a2dd95SBruce Richardson  * @param queue_id
1109*99a2dd95SBruce Richardson  *   The index of the queue to add to name
1110*99a2dd95SBruce Richardson  * @param size
1111*99a2dd95SBruce Richardson  *   The sizeof of the memory area
1112*99a2dd95SBruce Richardson  * @param align
1113*99a2dd95SBruce Richardson  *   Alignment for resulting memzone. Must be a power of 2.
1114*99a2dd95SBruce Richardson  * @param socket_id
1115*99a2dd95SBruce Richardson  *   The *socket_id* argument is the socket identifier in case of NUMA.
1116*99a2dd95SBruce Richardson  */
1117*99a2dd95SBruce Richardson __rte_internal
1118*99a2dd95SBruce Richardson const struct rte_memzone *
1119*99a2dd95SBruce Richardson rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name,
1120*99a2dd95SBruce Richardson 			 uint16_t queue_id, size_t size,
1121*99a2dd95SBruce Richardson 			 unsigned align, int socket_id);
1122*99a2dd95SBruce Richardson 
1123*99a2dd95SBruce Richardson /**
1124*99a2dd95SBruce Richardson  * Free previously allocated memzone for HW rings.
1125*99a2dd95SBruce Richardson  *
1126*99a2dd95SBruce Richardson  * @param eth_dev
1127*99a2dd95SBruce Richardson  *   The *eth_dev* pointer is the address of the *rte_eth_dev* structure
1128*99a2dd95SBruce Richardson  * @param name
1129*99a2dd95SBruce Richardson  *   The name of the memory zone
1130*99a2dd95SBruce Richardson  * @param queue_id
1131*99a2dd95SBruce Richardson  *   The index of the queue to add to name
1132*99a2dd95SBruce Richardson  * @return
1133*99a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
1134*99a2dd95SBruce Richardson  */
1135*99a2dd95SBruce Richardson __rte_internal
1136*99a2dd95SBruce Richardson int
1137*99a2dd95SBruce Richardson rte_eth_dma_zone_free(const struct rte_eth_dev *eth_dev, const char *name,
1138*99a2dd95SBruce Richardson 		 uint16_t queue_id);
1139*99a2dd95SBruce Richardson 
1140*99a2dd95SBruce Richardson /**
1141*99a2dd95SBruce Richardson  * @internal
1142*99a2dd95SBruce Richardson  * Atomically set the link status for the specific device.
1143*99a2dd95SBruce Richardson  * It is for use by DPDK device driver use only.
1144*99a2dd95SBruce Richardson  * User applications should not call it
1145*99a2dd95SBruce Richardson  *
1146*99a2dd95SBruce Richardson  * @param dev
1147*99a2dd95SBruce Richardson  *  Pointer to struct rte_eth_dev.
1148*99a2dd95SBruce Richardson  * @param link
1149*99a2dd95SBruce Richardson  *  New link status value.
1150*99a2dd95SBruce Richardson  * @return
1151*99a2dd95SBruce Richardson  *  Same convention as eth_link_update operation.
1152*99a2dd95SBruce Richardson  *  0   if link up status has changed
1153*99a2dd95SBruce Richardson  *  -1  if link up status was unchanged
1154*99a2dd95SBruce Richardson  */
1155*99a2dd95SBruce Richardson static inline int
1156*99a2dd95SBruce Richardson rte_eth_linkstatus_set(struct rte_eth_dev *dev,
1157*99a2dd95SBruce Richardson 		       const struct rte_eth_link *new_link)
1158*99a2dd95SBruce Richardson {
1159*99a2dd95SBruce Richardson 	uint64_t *dev_link = (uint64_t *)&(dev->data->dev_link);
1160*99a2dd95SBruce Richardson 	union {
1161*99a2dd95SBruce Richardson 		uint64_t val64;
1162*99a2dd95SBruce Richardson 		struct rte_eth_link link;
1163*99a2dd95SBruce Richardson 	} orig;
1164*99a2dd95SBruce Richardson 
1165*99a2dd95SBruce Richardson 	RTE_BUILD_BUG_ON(sizeof(*new_link) != sizeof(uint64_t));
1166*99a2dd95SBruce Richardson 
1167*99a2dd95SBruce Richardson 	orig.val64 = __atomic_exchange_n(dev_link, *(const uint64_t *)new_link,
1168*99a2dd95SBruce Richardson 					__ATOMIC_SEQ_CST);
1169*99a2dd95SBruce Richardson 
1170*99a2dd95SBruce Richardson 	return (orig.link.link_status == new_link->link_status) ? -1 : 0;
1171*99a2dd95SBruce Richardson }
1172*99a2dd95SBruce Richardson 
1173*99a2dd95SBruce Richardson /**
1174*99a2dd95SBruce Richardson  * @internal
1175*99a2dd95SBruce Richardson  * Atomically get the link speed and status.
1176*99a2dd95SBruce Richardson  *
1177*99a2dd95SBruce Richardson  * @param dev
1178*99a2dd95SBruce Richardson  *  Pointer to struct rte_eth_dev.
1179*99a2dd95SBruce Richardson  * @param link
1180*99a2dd95SBruce Richardson  *  link status value.
1181*99a2dd95SBruce Richardson  */
1182*99a2dd95SBruce Richardson static inline void
1183*99a2dd95SBruce Richardson rte_eth_linkstatus_get(const struct rte_eth_dev *dev,
1184*99a2dd95SBruce Richardson 		       struct rte_eth_link *link)
1185*99a2dd95SBruce Richardson {
1186*99a2dd95SBruce Richardson 	uint64_t *src = (uint64_t *)&(dev->data->dev_link);
1187*99a2dd95SBruce Richardson 	uint64_t *dst = (uint64_t *)link;
1188*99a2dd95SBruce Richardson 
1189*99a2dd95SBruce Richardson 	RTE_BUILD_BUG_ON(sizeof(*link) != sizeof(uint64_t));
1190*99a2dd95SBruce Richardson 
1191*99a2dd95SBruce Richardson 	*dst = __atomic_load_n(src, __ATOMIC_SEQ_CST);
1192*99a2dd95SBruce Richardson }
1193*99a2dd95SBruce Richardson 
1194*99a2dd95SBruce Richardson /**
1195*99a2dd95SBruce Richardson  * Allocate an unique switch domain identifier.
1196*99a2dd95SBruce Richardson  *
1197*99a2dd95SBruce Richardson  * A pool of switch domain identifiers which can be allocated on request. This
1198*99a2dd95SBruce Richardson  * will enabled devices which support the concept of switch domains to request
1199*99a2dd95SBruce Richardson  * a switch domain id which is guaranteed to be unique from other devices
1200*99a2dd95SBruce Richardson  * running in the same process.
1201*99a2dd95SBruce Richardson  *
1202*99a2dd95SBruce Richardson  * @param domain_id
1203*99a2dd95SBruce Richardson  *  switch domain identifier parameter to pass back to application
1204*99a2dd95SBruce Richardson  *
1205*99a2dd95SBruce Richardson  * @return
1206*99a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
1207*99a2dd95SBruce Richardson  */
1208*99a2dd95SBruce Richardson __rte_internal
1209*99a2dd95SBruce Richardson int
1210*99a2dd95SBruce Richardson rte_eth_switch_domain_alloc(uint16_t *domain_id);
1211*99a2dd95SBruce Richardson 
1212*99a2dd95SBruce Richardson /**
1213*99a2dd95SBruce Richardson  * Free switch domain.
1214*99a2dd95SBruce Richardson  *
1215*99a2dd95SBruce Richardson  * Return a switch domain identifier to the pool of free identifiers after it is
1216*99a2dd95SBruce Richardson  * no longer in use by device.
1217*99a2dd95SBruce Richardson  *
1218*99a2dd95SBruce Richardson  * @param domain_id
1219*99a2dd95SBruce Richardson  *  switch domain identifier to free
1220*99a2dd95SBruce Richardson  *
1221*99a2dd95SBruce Richardson  * @return
1222*99a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
1223*99a2dd95SBruce Richardson  */
1224*99a2dd95SBruce Richardson __rte_internal
1225*99a2dd95SBruce Richardson int
1226*99a2dd95SBruce Richardson rte_eth_switch_domain_free(uint16_t domain_id);
1227*99a2dd95SBruce Richardson 
1228*99a2dd95SBruce Richardson /**
1229*99a2dd95SBruce Richardson  * Generic Ethernet device arguments
1230*99a2dd95SBruce Richardson  *
1231*99a2dd95SBruce Richardson  * One type of representor each structure.
1232*99a2dd95SBruce Richardson  */
1233*99a2dd95SBruce Richardson struct rte_eth_devargs {
1234*99a2dd95SBruce Richardson 	uint16_t mh_controllers[RTE_MAX_MULTI_HOST_CTRLS];
1235*99a2dd95SBruce Richardson 	/** controller/s number in case of multi-host */
1236*99a2dd95SBruce Richardson 	uint16_t nb_mh_controllers;
1237*99a2dd95SBruce Richardson 	/** number of controllers in multi-host controllers field */
1238*99a2dd95SBruce Richardson 	uint16_t ports[RTE_MAX_ETHPORTS];
1239*99a2dd95SBruce Richardson 	/** port/s number to enable on a multi-port single function */
1240*99a2dd95SBruce Richardson 	uint16_t nb_ports;
1241*99a2dd95SBruce Richardson 	/** number of ports in ports field */
1242*99a2dd95SBruce Richardson 	uint16_t representor_ports[RTE_MAX_ETHPORTS];
1243*99a2dd95SBruce Richardson 	/** representor port/s identifier to enable on device */
1244*99a2dd95SBruce Richardson 	uint16_t nb_representor_ports;
1245*99a2dd95SBruce Richardson 	/** number of ports in representor port field */
1246*99a2dd95SBruce Richardson 	enum rte_eth_representor_type type; /* type of representor */
1247*99a2dd95SBruce Richardson };
1248*99a2dd95SBruce Richardson 
1249*99a2dd95SBruce Richardson /**
1250*99a2dd95SBruce Richardson  * PMD helper function to get representor ID from location detail.
1251*99a2dd95SBruce Richardson  *
1252*99a2dd95SBruce Richardson  * Get representor ID from controller, pf and (sf or vf).
1253*99a2dd95SBruce Richardson  * The mapping is retrieved from rte_eth_representor_info_get().
1254*99a2dd95SBruce Richardson  *
1255*99a2dd95SBruce Richardson  * For backward compatibility, if no representor info, direct
1256*99a2dd95SBruce Richardson  * map legacy VF (no controller and pf).
1257*99a2dd95SBruce Richardson  *
1258*99a2dd95SBruce Richardson  * @param ethdev
1259*99a2dd95SBruce Richardson  *  Handle of ethdev port.
1260*99a2dd95SBruce Richardson  * @param type
1261*99a2dd95SBruce Richardson  *  Representor type.
1262*99a2dd95SBruce Richardson  * @param controller
1263*99a2dd95SBruce Richardson  *  Controller ID, -1 if unspecified.
1264*99a2dd95SBruce Richardson  * @param pf
1265*99a2dd95SBruce Richardson  *  PF port ID, -1 if unspecified.
1266*99a2dd95SBruce Richardson  * @param representor_port
1267*99a2dd95SBruce Richardson  *  VF or SF representor port number, -1 if unspecified.
1268*99a2dd95SBruce Richardson  * @param repr_id
1269*99a2dd95SBruce Richardson  *  Pointer to output representor ID.
1270*99a2dd95SBruce Richardson  *
1271*99a2dd95SBruce Richardson  * @return
1272*99a2dd95SBruce Richardson  *  Negative errno value on error, 0 on success.
1273*99a2dd95SBruce Richardson  */
1274*99a2dd95SBruce Richardson __rte_internal
1275*99a2dd95SBruce Richardson int
1276*99a2dd95SBruce Richardson rte_eth_representor_id_get(const struct rte_eth_dev *ethdev,
1277*99a2dd95SBruce Richardson 			   enum rte_eth_representor_type type,
1278*99a2dd95SBruce Richardson 			   int controller, int pf, int representor_port,
1279*99a2dd95SBruce Richardson 			   uint16_t *repr_id);
1280*99a2dd95SBruce Richardson 
1281*99a2dd95SBruce Richardson /**
1282*99a2dd95SBruce Richardson  * PMD helper function to parse ethdev arguments
1283*99a2dd95SBruce Richardson  *
1284*99a2dd95SBruce Richardson  * @param devargs
1285*99a2dd95SBruce Richardson  *  device arguments
1286*99a2dd95SBruce Richardson  * @param eth_devargs
1287*99a2dd95SBruce Richardson  *  parsed ethdev specific arguments.
1288*99a2dd95SBruce Richardson  *
1289*99a2dd95SBruce Richardson  * @return
1290*99a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
1291*99a2dd95SBruce Richardson  */
1292*99a2dd95SBruce Richardson __rte_internal
1293*99a2dd95SBruce Richardson int
1294*99a2dd95SBruce Richardson rte_eth_devargs_parse(const char *devargs, struct rte_eth_devargs *eth_devargs);
1295*99a2dd95SBruce Richardson 
1296*99a2dd95SBruce Richardson 
1297*99a2dd95SBruce Richardson typedef int (*ethdev_init_t)(struct rte_eth_dev *ethdev, void *init_params);
1298*99a2dd95SBruce Richardson typedef int (*ethdev_bus_specific_init)(struct rte_eth_dev *ethdev,
1299*99a2dd95SBruce Richardson 	void *bus_specific_init_params);
1300*99a2dd95SBruce Richardson 
1301*99a2dd95SBruce Richardson /**
1302*99a2dd95SBruce Richardson  * PMD helper function for the creation of a new ethdev ports.
1303*99a2dd95SBruce Richardson  *
1304*99a2dd95SBruce Richardson  * @param device
1305*99a2dd95SBruce Richardson  *  rte_device handle.
1306*99a2dd95SBruce Richardson  * @param name
1307*99a2dd95SBruce Richardson  *  port name.
1308*99a2dd95SBruce Richardson  * @param priv_data_size
1309*99a2dd95SBruce Richardson  *  size of private data required for port.
1310*99a2dd95SBruce Richardson  * @param bus_specific_init
1311*99a2dd95SBruce Richardson  *  port bus specific initialisation callback function
1312*99a2dd95SBruce Richardson  * @param bus_init_params
1313*99a2dd95SBruce Richardson  *  port bus specific initialisation parameters
1314*99a2dd95SBruce Richardson  * @param ethdev_init
1315*99a2dd95SBruce Richardson  *  device specific port initialization callback function
1316*99a2dd95SBruce Richardson  * @param init_params
1317*99a2dd95SBruce Richardson  *  port initialisation parameters
1318*99a2dd95SBruce Richardson  *
1319*99a2dd95SBruce Richardson  * @return
1320*99a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
1321*99a2dd95SBruce Richardson  */
1322*99a2dd95SBruce Richardson __rte_internal
1323*99a2dd95SBruce Richardson int
1324*99a2dd95SBruce Richardson rte_eth_dev_create(struct rte_device *device, const char *name,
1325*99a2dd95SBruce Richardson 	size_t priv_data_size,
1326*99a2dd95SBruce Richardson 	ethdev_bus_specific_init bus_specific_init, void *bus_init_params,
1327*99a2dd95SBruce Richardson 	ethdev_init_t ethdev_init, void *init_params);
1328*99a2dd95SBruce Richardson 
1329*99a2dd95SBruce Richardson 
1330*99a2dd95SBruce Richardson typedef int (*ethdev_uninit_t)(struct rte_eth_dev *ethdev);
1331*99a2dd95SBruce Richardson 
1332*99a2dd95SBruce Richardson /**
1333*99a2dd95SBruce Richardson  * PMD helper function for cleaning up the resources of a ethdev port on it's
1334*99a2dd95SBruce Richardson  * destruction.
1335*99a2dd95SBruce Richardson  *
1336*99a2dd95SBruce Richardson  * @param ethdev
1337*99a2dd95SBruce Richardson  *   ethdev handle of port.
1338*99a2dd95SBruce Richardson  * @param ethdev_uninit
1339*99a2dd95SBruce Richardson  *   device specific port un-initialise callback function
1340*99a2dd95SBruce Richardson  *
1341*99a2dd95SBruce Richardson  * @return
1342*99a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
1343*99a2dd95SBruce Richardson  */
1344*99a2dd95SBruce Richardson __rte_internal
1345*99a2dd95SBruce Richardson int
1346*99a2dd95SBruce Richardson rte_eth_dev_destroy(struct rte_eth_dev *ethdev, ethdev_uninit_t ethdev_uninit);
1347*99a2dd95SBruce Richardson 
1348*99a2dd95SBruce Richardson /**
1349*99a2dd95SBruce Richardson  * @internal
1350*99a2dd95SBruce Richardson  * Pass the current hairpin queue HW and/or SW information to the peer queue
1351*99a2dd95SBruce Richardson  * and fetch back the information of the peer queue.
1352*99a2dd95SBruce Richardson  *
1353*99a2dd95SBruce Richardson  * @param peer_port
1354*99a2dd95SBruce Richardson  *  Peer port identifier of the Ethernet device.
1355*99a2dd95SBruce Richardson  * @param peer_queue
1356*99a2dd95SBruce Richardson  *  Peer queue index of the port.
1357*99a2dd95SBruce Richardson  * @param cur_info
1358*99a2dd95SBruce Richardson  *  Pointer to the current information structure.
1359*99a2dd95SBruce Richardson  * @param peer_info
1360*99a2dd95SBruce Richardson  *  Pointer to the peer information, output.
1361*99a2dd95SBruce Richardson  * @param direction
1362*99a2dd95SBruce Richardson  *  Direction to pass the information.
1363*99a2dd95SBruce Richardson  *  positive - pass Tx queue information and get peer Rx queue information
1364*99a2dd95SBruce Richardson  *  zero - pass Rx queue information and get peer Tx queue information
1365*99a2dd95SBruce Richardson  *
1366*99a2dd95SBruce Richardson  * @return
1367*99a2dd95SBruce Richardson  *  Negative errno value on error, 0 on success.
1368*99a2dd95SBruce Richardson  */
1369*99a2dd95SBruce Richardson __rte_internal
1370*99a2dd95SBruce Richardson int
1371*99a2dd95SBruce Richardson rte_eth_hairpin_queue_peer_update(uint16_t peer_port, uint16_t peer_queue,
1372*99a2dd95SBruce Richardson 				  struct rte_hairpin_peer_info *cur_info,
1373*99a2dd95SBruce Richardson 				  struct rte_hairpin_peer_info *peer_info,
1374*99a2dd95SBruce Richardson 				  uint32_t direction);
1375*99a2dd95SBruce Richardson 
1376*99a2dd95SBruce Richardson /**
1377*99a2dd95SBruce Richardson  * @internal
1378*99a2dd95SBruce Richardson  * Configure current hairpin queue with the peer information fetched to create
1379*99a2dd95SBruce Richardson  * the connection (bind) with peer queue in the specified direction.
1380*99a2dd95SBruce Richardson  * This function might need to be called twice to fully create the connections.
1381*99a2dd95SBruce Richardson  *
1382*99a2dd95SBruce Richardson  * @param cur_port
1383*99a2dd95SBruce Richardson  *  Current port identifier of the Ethernet device.
1384*99a2dd95SBruce Richardson  * @param cur_queue
1385*99a2dd95SBruce Richardson  *  Current queue index of the port.
1386*99a2dd95SBruce Richardson  * @param peer_info
1387*99a2dd95SBruce Richardson  *  Pointer to the peer information, input.
1388*99a2dd95SBruce Richardson  * @param direction
1389*99a2dd95SBruce Richardson  *  Direction to create the connection.
1390*99a2dd95SBruce Richardson  *  positive - bind current Tx queue to peer Rx queue
1391*99a2dd95SBruce Richardson  *  zero - bind current Rx queue to peer Tx queue
1392*99a2dd95SBruce Richardson  *
1393*99a2dd95SBruce Richardson  * @return
1394*99a2dd95SBruce Richardson  *  Negative errno value on error, 0 on success.
1395*99a2dd95SBruce Richardson  */
1396*99a2dd95SBruce Richardson __rte_internal
1397*99a2dd95SBruce Richardson int
1398*99a2dd95SBruce Richardson rte_eth_hairpin_queue_peer_bind(uint16_t cur_port, uint16_t cur_queue,
1399*99a2dd95SBruce Richardson 				struct rte_hairpin_peer_info *peer_info,
1400*99a2dd95SBruce Richardson 				uint32_t direction);
1401*99a2dd95SBruce Richardson 
1402*99a2dd95SBruce Richardson /**
1403*99a2dd95SBruce Richardson  * @internal
1404*99a2dd95SBruce Richardson  * Reset the current queue state and configuration to disconnect (unbind) it
1405*99a2dd95SBruce Richardson  * from the peer queue.
1406*99a2dd95SBruce Richardson  * This function might need to be called twice to disconnect each other.
1407*99a2dd95SBruce Richardson  *
1408*99a2dd95SBruce Richardson  * @param cur_port
1409*99a2dd95SBruce Richardson  *  Current port identifier of the Ethernet device.
1410*99a2dd95SBruce Richardson  * @param cur_queue
1411*99a2dd95SBruce Richardson  *  Current queue index of the port.
1412*99a2dd95SBruce Richardson  * @param direction
1413*99a2dd95SBruce Richardson  *  Direction to destroy the connection.
1414*99a2dd95SBruce Richardson  *  positive - unbind current Tx queue from peer Rx queue
1415*99a2dd95SBruce Richardson  *  zero - unbind current Rx queue from peer Tx queue
1416*99a2dd95SBruce Richardson  *
1417*99a2dd95SBruce Richardson  * @return
1418*99a2dd95SBruce Richardson  *  Negative errno value on error, 0 on success.
1419*99a2dd95SBruce Richardson  */
1420*99a2dd95SBruce Richardson __rte_internal
1421*99a2dd95SBruce Richardson int
1422*99a2dd95SBruce Richardson rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t cur_queue,
1423*99a2dd95SBruce Richardson 				  uint32_t direction);
1424*99a2dd95SBruce Richardson 
1425*99a2dd95SBruce Richardson 
1426*99a2dd95SBruce Richardson /*
1427*99a2dd95SBruce Richardson  * Legacy ethdev API used internally by drivers.
1428*99a2dd95SBruce Richardson  */
1429*99a2dd95SBruce Richardson 
1430*99a2dd95SBruce Richardson enum rte_filter_type {
1431*99a2dd95SBruce Richardson 	RTE_ETH_FILTER_NONE = 0,
1432*99a2dd95SBruce Richardson 	RTE_ETH_FILTER_ETHERTYPE,
1433*99a2dd95SBruce Richardson 	RTE_ETH_FILTER_FLEXIBLE,
1434*99a2dd95SBruce Richardson 	RTE_ETH_FILTER_SYN,
1435*99a2dd95SBruce Richardson 	RTE_ETH_FILTER_NTUPLE,
1436*99a2dd95SBruce Richardson 	RTE_ETH_FILTER_TUNNEL,
1437*99a2dd95SBruce Richardson 	RTE_ETH_FILTER_FDIR,
1438*99a2dd95SBruce Richardson 	RTE_ETH_FILTER_HASH,
1439*99a2dd95SBruce Richardson 	RTE_ETH_FILTER_L2_TUNNEL,
1440*99a2dd95SBruce Richardson };
1441*99a2dd95SBruce Richardson 
1442*99a2dd95SBruce Richardson /**
1443*99a2dd95SBruce Richardson  * Define all structures for Ethertype Filter type.
1444*99a2dd95SBruce Richardson  */
1445*99a2dd95SBruce Richardson 
1446*99a2dd95SBruce Richardson #define RTE_ETHTYPE_FLAGS_MAC    0x0001 /**< If set, compare mac */
1447*99a2dd95SBruce Richardson #define RTE_ETHTYPE_FLAGS_DROP   0x0002 /**< If set, drop packet when match */
1448*99a2dd95SBruce Richardson 
1449*99a2dd95SBruce Richardson /**
1450*99a2dd95SBruce Richardson  * A structure used to define the ethertype filter entry
1451*99a2dd95SBruce Richardson  * to support RTE_ETH_FILTER_ETHERTYPE data representation.
1452*99a2dd95SBruce Richardson  */
1453*99a2dd95SBruce Richardson struct rte_eth_ethertype_filter {
1454*99a2dd95SBruce Richardson 	struct rte_ether_addr mac_addr;   /**< Mac address to match. */
1455*99a2dd95SBruce Richardson 	uint16_t ether_type;          /**< Ether type to match */
1456*99a2dd95SBruce Richardson 	uint16_t flags;               /**< Flags from RTE_ETHTYPE_FLAGS_* */
1457*99a2dd95SBruce Richardson 	uint16_t queue;               /**< Queue assigned to when match*/
1458*99a2dd95SBruce Richardson };
1459*99a2dd95SBruce Richardson 
1460*99a2dd95SBruce Richardson /**
1461*99a2dd95SBruce Richardson  * A structure used to define the TCP syn filter entry
1462*99a2dd95SBruce Richardson  * to support RTE_ETH_FILTER_SYN data representation.
1463*99a2dd95SBruce Richardson  */
1464*99a2dd95SBruce Richardson struct rte_eth_syn_filter {
1465*99a2dd95SBruce Richardson 	/** 1 - higher priority than other filters, 0 - lower priority. */
1466*99a2dd95SBruce Richardson 	uint8_t hig_pri;
1467*99a2dd95SBruce Richardson 	uint16_t queue;      /**< Queue assigned to when match */
1468*99a2dd95SBruce Richardson };
1469*99a2dd95SBruce Richardson 
1470*99a2dd95SBruce Richardson /**
1471*99a2dd95SBruce Richardson  * filter type of tunneling packet
1472*99a2dd95SBruce Richardson  */
1473*99a2dd95SBruce Richardson #define ETH_TUNNEL_FILTER_OMAC  0x01 /**< filter by outer MAC addr */
1474*99a2dd95SBruce Richardson #define ETH_TUNNEL_FILTER_OIP   0x02 /**< filter by outer IP Addr */
1475*99a2dd95SBruce Richardson #define ETH_TUNNEL_FILTER_TENID 0x04 /**< filter by tenant ID */
1476*99a2dd95SBruce Richardson #define ETH_TUNNEL_FILTER_IMAC  0x08 /**< filter by inner MAC addr */
1477*99a2dd95SBruce Richardson #define ETH_TUNNEL_FILTER_IVLAN 0x10 /**< filter by inner VLAN ID */
1478*99a2dd95SBruce Richardson #define ETH_TUNNEL_FILTER_IIP   0x20 /**< filter by inner IP addr */
1479*99a2dd95SBruce Richardson 
1480*99a2dd95SBruce Richardson #define RTE_TUNNEL_FILTER_IMAC_IVLAN (ETH_TUNNEL_FILTER_IMAC | \
1481*99a2dd95SBruce Richardson 					ETH_TUNNEL_FILTER_IVLAN)
1482*99a2dd95SBruce Richardson #define RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID (ETH_TUNNEL_FILTER_IMAC | \
1483*99a2dd95SBruce Richardson 					ETH_TUNNEL_FILTER_IVLAN | \
1484*99a2dd95SBruce Richardson 					ETH_TUNNEL_FILTER_TENID)
1485*99a2dd95SBruce Richardson #define RTE_TUNNEL_FILTER_IMAC_TENID (ETH_TUNNEL_FILTER_IMAC | \
1486*99a2dd95SBruce Richardson 					ETH_TUNNEL_FILTER_TENID)
1487*99a2dd95SBruce Richardson #define RTE_TUNNEL_FILTER_OMAC_TENID_IMAC (ETH_TUNNEL_FILTER_OMAC | \
1488*99a2dd95SBruce Richardson 					ETH_TUNNEL_FILTER_TENID | \
1489*99a2dd95SBruce Richardson 					ETH_TUNNEL_FILTER_IMAC)
1490*99a2dd95SBruce Richardson 
1491*99a2dd95SBruce Richardson /**
1492*99a2dd95SBruce Richardson  *  Select IPv4 or IPv6 for tunnel filters.
1493*99a2dd95SBruce Richardson  */
1494*99a2dd95SBruce Richardson enum rte_tunnel_iptype {
1495*99a2dd95SBruce Richardson 	RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4. */
1496*99a2dd95SBruce Richardson 	RTE_TUNNEL_IPTYPE_IPV6,     /**< IPv6. */
1497*99a2dd95SBruce Richardson };
1498*99a2dd95SBruce Richardson 
1499*99a2dd95SBruce Richardson /**
1500*99a2dd95SBruce Richardson  * Tunneling Packet filter configuration.
1501*99a2dd95SBruce Richardson  */
1502*99a2dd95SBruce Richardson struct rte_eth_tunnel_filter_conf {
1503*99a2dd95SBruce Richardson 	struct rte_ether_addr outer_mac;    /**< Outer MAC address to match. */
1504*99a2dd95SBruce Richardson 	struct rte_ether_addr inner_mac;    /**< Inner MAC address to match. */
1505*99a2dd95SBruce Richardson 	uint16_t inner_vlan;            /**< Inner VLAN to match. */
1506*99a2dd95SBruce Richardson 	enum rte_tunnel_iptype ip_type; /**< IP address type. */
1507*99a2dd95SBruce Richardson 	/**
1508*99a2dd95SBruce Richardson 	 * Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP
1509*99a2dd95SBruce Richardson 	 * is set in filter_type, or inner destination IP address to match
1510*99a2dd95SBruce Richardson 	 * if ETH_TUNNEL_FILTER_IIP is set in filter_type.
1511*99a2dd95SBruce Richardson 	 */
1512*99a2dd95SBruce Richardson 	union {
1513*99a2dd95SBruce Richardson 		uint32_t ipv4_addr;     /**< IPv4 address in big endian. */
1514*99a2dd95SBruce Richardson 		uint32_t ipv6_addr[4];  /**< IPv6 address in big endian. */
1515*99a2dd95SBruce Richardson 	} ip_addr;
1516*99a2dd95SBruce Richardson 	/** Flags from ETH_TUNNEL_FILTER_XX - see above. */
1517*99a2dd95SBruce Richardson 	uint16_t filter_type;
1518*99a2dd95SBruce Richardson 	enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
1519*99a2dd95SBruce Richardson 	uint32_t tenant_id;     /**< Tenant ID to match. VNI, GRE key... */
1520*99a2dd95SBruce Richardson 	uint16_t queue_id;      /**< Queue assigned to if match. */
1521*99a2dd95SBruce Richardson };
1522*99a2dd95SBruce Richardson 
1523*99a2dd95SBruce Richardson #ifdef __cplusplus
1524*99a2dd95SBruce Richardson }
1525*99a2dd95SBruce Richardson #endif
1526*99a2dd95SBruce Richardson 
1527*99a2dd95SBruce Richardson #endif /* _RTE_ETHDEV_DRIVER_H_ */
1528