xref: /dpdk/lib/ethdev/ethdev_driver.h (revision 6903de616a1296e368002687cb43ef3b9fc4699f)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Intel Corporation
3  */
4 
5 #ifndef _RTE_ETHDEV_DRIVER_H_
6 #define _RTE_ETHDEV_DRIVER_H_
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 /**
13  * @file
14  *
15  * RTE Ethernet Device PMD API
16  *
17  * These APIs for the use from Ethernet drivers, user applications shouldn't
18  * use them.
19  */
20 
21 #include <dev_driver.h>
22 #include <rte_compat.h>
23 #include <rte_ethdev.h>
24 
25 /**
26  * @internal
27  * Structure used to hold information about the callbacks to be called for a
28  * queue on Rx and Tx.
29  */
30 struct rte_eth_rxtx_callback {
31 	struct rte_eth_rxtx_callback *next;
32 	union{
33 		rte_rx_callback_fn rx;
34 		rte_tx_callback_fn tx;
35 	} fn;
36 	void *param;
37 };
38 
39 /**
40  * @internal
41  * The generic data structure associated with each Ethernet device.
42  *
43  * Pointers to burst-oriented packet receive and transmit functions are
44  * located at the beginning of the structure, along with the pointer to
45  * where all the data elements for the particular device are stored in shared
46  * memory. This split allows the function pointer and driver data to be per-
47  * process, while the actual configuration data for the device is shared.
48  */
49 struct rte_eth_dev {
50 	eth_rx_burst_t rx_pkt_burst; /**< Pointer to PMD receive function */
51 	eth_tx_burst_t tx_pkt_burst; /**< Pointer to PMD transmit function */
52 
53 	/** Pointer to PMD transmit prepare function */
54 	eth_tx_prep_t tx_pkt_prepare;
55 	/** Get the number of used Rx descriptors */
56 	eth_rx_queue_count_t rx_queue_count;
57 	/** Check the status of a Rx descriptor */
58 	eth_rx_descriptor_status_t rx_descriptor_status;
59 	/** Check the status of a Tx descriptor */
60 	eth_tx_descriptor_status_t tx_descriptor_status;
61 
62 	/**
63 	 * Device data that is shared between primary and secondary processes
64 	 */
65 	struct rte_eth_dev_data *data;
66 	void *process_private; /**< Pointer to per-process device data */
67 	const struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */
68 	struct rte_device *device; /**< Backing device */
69 	struct rte_intr_handle *intr_handle; /**< Device interrupt handle */
70 
71 	/** User application callbacks for NIC interrupts */
72 	struct rte_eth_dev_cb_list link_intr_cbs;
73 	/**
74 	 * User-supplied functions called from rx_burst to post-process
75 	 * received packets before passing them to the user
76 	 */
77 	struct rte_eth_rxtx_callback *post_rx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
78 	/**
79 	 * User-supplied functions called from tx_burst to pre-process
80 	 * received packets before passing them to the driver for transmission
81 	 */
82 	struct rte_eth_rxtx_callback *pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
83 
84 	enum rte_eth_dev_state state; /**< Flag indicating the port state */
85 	void *security_ctx; /**< Context for security ops */
86 } __rte_cache_aligned;
87 
88 struct rte_eth_dev_sriov;
89 struct rte_eth_dev_owner;
90 
91 /**
92  * @internal
93  * The data part, with no function pointers, associated with each Ethernet
94  * device. This structure is safe to place in shared memory to be common
95  * among different processes in a multi-process configuration.
96  */
97 struct rte_eth_dev_data {
98 	char name[RTE_ETH_NAME_MAX_LEN]; /**< Unique identifier name */
99 
100 	void **rx_queues; /**< Array of pointers to Rx queues */
101 	void **tx_queues; /**< Array of pointers to Tx queues */
102 	uint16_t nb_rx_queues; /**< Number of Rx queues */
103 	uint16_t nb_tx_queues; /**< Number of Tx queues */
104 
105 	struct rte_eth_dev_sriov sriov;    /**< SRIOV data */
106 
107 	/** PMD-specific private data. @see rte_eth_dev_release_port() */
108 	void *dev_private;
109 
110 	struct rte_eth_link dev_link;   /**< Link-level information & status */
111 	struct rte_eth_conf dev_conf;   /**< Configuration applied to device */
112 	uint16_t mtu;                   /**< Maximum Transmission Unit */
113 
114 	/** Common Rx buffer size handled by all queues */
115 	uint32_t min_rx_buf_size;
116 
117 	uint64_t rx_mbuf_alloc_failed; /**< Rx ring mbuf allocation failures */
118 
119 	/**
120 	 * Device Ethernet link addresses.
121 	 * All entries are unique.
122 	 * The first entry (index zero) is the default address.
123 	 */
124 	struct rte_ether_addr *mac_addrs;
125 	/** Bitmap associating MAC addresses to pools */
126 	uint64_t mac_pool_sel[RTE_ETH_NUM_RECEIVE_MAC_ADDR];
127 	/**
128 	 * Device Ethernet MAC addresses of hash filtering.
129 	 * @see rte_eth_dev_release_port()
130 	 */
131 	struct rte_ether_addr *hash_mac_addrs;
132 
133 	uint16_t port_id;           /**< Device [external] port identifier */
134 
135 	__extension__
136 	uint8_t /** Rx promiscuous mode ON(1) / OFF(0) */
137 		promiscuous   : 1,
138 		/** Rx of scattered packets is ON(1) / OFF(0) */
139 		scattered_rx : 1,
140 		/** Rx all multicast mode ON(1) / OFF(0) */
141 		all_multicast : 1,
142 		/** Device state: STARTED(1) / STOPPED(0) */
143 		dev_started : 1,
144 		/** Rx LRO is ON(1) / OFF(0) */
145 		lro         : 1,
146 		/**
147 		 * Indicates whether the device is configured:
148 		 * CONFIGURED(1) / NOT CONFIGURED(0)
149 		 */
150 		dev_configured : 1,
151 		/**
152 		 * Indicates whether the flow engine is configured:
153 		 * CONFIGURED(1) / NOT CONFIGURED(0)
154 		 */
155 		flow_configured : 1;
156 
157 	/** Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0) */
158 	uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
159 	/** Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0) */
160 	uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
161 
162 	uint32_t dev_flags;             /**< Capabilities */
163 	int numa_node;                  /**< NUMA node connection */
164 
165 	/** VLAN filter configuration */
166 	struct rte_vlan_filter_conf vlan_filter_conf;
167 
168 	struct rte_eth_dev_owner owner; /**< The port owner */
169 
170 	/**
171 	 * Switch-specific identifier.
172 	 * Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags.
173 	 */
174 	uint16_t representor_id;
175 	/**
176 	 * Port ID of the backing device.
177 	 * This device will be used to query representor info and calculate
178 	 * representor IDs. Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags.
179 	 */
180 	uint16_t backer_port_id;
181 
182 	pthread_mutex_t flow_ops_mutex; /**< rte_flow ops mutex */
183 } __rte_cache_aligned;
184 
185 /**
186  * @internal
187  * The pool of *rte_eth_dev* structures. The size of the pool
188  * is configured at compile-time in the <rte_ethdev.c> file.
189  */
190 extern struct rte_eth_dev rte_eth_devices[];
191 
192 /** @internal Declaration of the hairpin peer queue information structure. */
193 struct rte_hairpin_peer_info;
194 
195 /*
196  * Definitions of all functions exported by an Ethernet driver through the
197  * generic structure of type *eth_dev_ops* supplied in the *rte_eth_dev*
198  * structure associated with an Ethernet device.
199  */
200 
201 /** @internal Ethernet device configuration. */
202 typedef int  (*eth_dev_configure_t)(struct rte_eth_dev *dev);
203 
204 /** @internal Function used to start a configured Ethernet device. */
205 typedef int  (*eth_dev_start_t)(struct rte_eth_dev *dev);
206 
207 /** @internal Function used to stop a configured Ethernet device. */
208 typedef int (*eth_dev_stop_t)(struct rte_eth_dev *dev);
209 
210 /** @internal Function used to link up a configured Ethernet device. */
211 typedef int  (*eth_dev_set_link_up_t)(struct rte_eth_dev *dev);
212 
213 /** @internal Function used to link down a configured Ethernet device. */
214 typedef int  (*eth_dev_set_link_down_t)(struct rte_eth_dev *dev);
215 
216 /** @internal Function used to close a configured Ethernet device. */
217 typedef int (*eth_dev_close_t)(struct rte_eth_dev *dev);
218 
219 /** @internal Function used to reset a configured Ethernet device. */
220 typedef int (*eth_dev_reset_t)(struct rte_eth_dev *dev);
221 
222 /** @internal Function used to detect an Ethernet device removal. */
223 typedef int (*eth_is_removed_t)(struct rte_eth_dev *dev);
224 
225 /**
226  * @internal
227  * Function used to enable the Rx promiscuous mode of an Ethernet device.
228  *
229  * @param dev
230  *   ethdev handle of port.
231  *
232  * @return
233  *   Negative errno value on error, 0 on success.
234  *
235  * @retval 0
236  *   Success, promiscuous mode is enabled.
237  * @retval -ENOTSUP
238  *   Promiscuous mode is not supported.
239  * @retval -ENODEV
240  *   Device is gone.
241  * @retval -E_RTE_SECONDARY
242  *   Function was called from a secondary process instance and not supported.
243  * @retval -ETIMEDOUT
244  *   Attempt to enable promiscuous mode failed because of timeout.
245  * @retval -EAGAIN
246  *   Failed to enable promiscuous mode.
247  */
248 typedef int (*eth_promiscuous_enable_t)(struct rte_eth_dev *dev);
249 
250 /**
251  * @internal
252  * Function used to disable the Rx promiscuous mode of an Ethernet device.
253  *
254  * @param dev
255  *   ethdev handle of port.
256  *
257  * @return
258  *   Negative errno value on error, 0 on success.
259  *
260  * @retval 0
261  *   Success, promiscuous mode is disabled.
262  * @retval -ENOTSUP
263  *   Promiscuous mode disabling is not supported.
264  * @retval -ENODEV
265  *   Device is gone.
266  * @retval -E_RTE_SECONDARY
267  *   Function was called from a secondary process instance and not supported.
268  * @retval -ETIMEDOUT
269  *   Attempt to disable promiscuous mode failed because of timeout.
270  * @retval -EAGAIN
271  *   Failed to disable promiscuous mode.
272  */
273 typedef int (*eth_promiscuous_disable_t)(struct rte_eth_dev *dev);
274 
275 /**
276  * @internal
277  * Enable the receipt of all multicast packets by an Ethernet device.
278  *
279  * @param dev
280  *   ethdev handle of port.
281  *
282  * @return
283  *   Negative errno value on error, 0 on success.
284  *
285  * @retval 0
286  *   Success, all-multicast mode is enabled.
287  * @retval -ENOTSUP
288  *   All-multicast mode is not supported.
289  * @retval -ENODEV
290  *   Device is gone.
291  * @retval -E_RTE_SECONDARY
292  *   Function was called from a secondary process instance and not supported.
293  * @retval -ETIMEDOUT
294  *   Attempt to enable all-multicast mode failed because of timeout.
295  * @retval -EAGAIN
296  *   Failed to enable all-multicast mode.
297  */
298 typedef int (*eth_allmulticast_enable_t)(struct rte_eth_dev *dev);
299 
300 /**
301  * @internal
302  * Disable the receipt of all multicast packets by an Ethernet device.
303  *
304  * @param dev
305  *   ethdev handle of port.
306  *
307  * @return
308  *   Negative errno value on error, 0 on success.
309  *
310  * @retval 0
311  *   Success, all-multicast mode is disabled.
312  * @retval -ENOTSUP
313  *   All-multicast mode disabling is not supported.
314  * @retval -ENODEV
315  *   Device is gone.
316  * @retval -E_RTE_SECONDARY
317  *   Function was called from a secondary process instance and not supported.
318  * @retval -ETIMEDOUT
319  *   Attempt to disable all-multicast mode failed because of timeout.
320  * @retval -EAGAIN
321  *   Failed to disable all-multicast mode.
322  */
323 typedef int (*eth_allmulticast_disable_t)(struct rte_eth_dev *dev);
324 
325 /**
326  * @internal
327  * Get link speed, duplex mode and state (up/down) of an Ethernet device.
328  */
329 typedef int (*eth_link_update_t)(struct rte_eth_dev *dev,
330 				int wait_to_complete);
331 
332 /** @internal Get global I/O statistics of an Ethernet device. */
333 typedef int (*eth_stats_get_t)(struct rte_eth_dev *dev,
334 				struct rte_eth_stats *igb_stats);
335 
336 /**
337  * @internal
338  * Reset global I/O statistics of an Ethernet device to 0.
339  *
340  * @param dev
341  *   ethdev handle of port.
342  *
343  * @return
344  *   Negative errno value on error, 0 on success.
345  *
346  * @retval 0
347  *   Success, statistics has been reset.
348  * @retval -ENOTSUP
349  *   Resetting statistics is not supported.
350  * @retval -EINVAL
351  *   Resetting statistics is not valid.
352  * @retval -ENOMEM
353  *   Not enough memory to get the stats.
354  */
355 typedef int (*eth_stats_reset_t)(struct rte_eth_dev *dev);
356 
357 /** @internal Get extended stats of an Ethernet device. */
358 typedef int (*eth_xstats_get_t)(struct rte_eth_dev *dev,
359 	struct rte_eth_xstat *stats, unsigned int n);
360 
361 /**
362  * @internal
363  * Get extended stats of an Ethernet device.
364  *
365  * @param dev
366  *   ethdev handle of port.
367  * @param ids
368  *   IDs array to retrieve specific statistics. Must not be NULL.
369  * @param values
370  *   A pointer to a table to be filled with device statistics values.
371  *   Must not be NULL.
372  * @param n
373  *   Element count in @p ids and @p values.
374  *
375  * @return
376  *   - A number of filled in stats.
377  *   - A negative value on error.
378  */
379 typedef int (*eth_xstats_get_by_id_t)(struct rte_eth_dev *dev,
380 				      const uint64_t *ids,
381 				      uint64_t *values,
382 				      unsigned int n);
383 
384 /**
385  * @internal
386  * Reset extended stats of an Ethernet device.
387  *
388  * @param dev
389  *   ethdev handle of port.
390  *
391  * @return
392  *   Negative errno value on error, 0 on success.
393  *
394  * @retval 0
395  *   Success, statistics has been reset.
396  * @retval -ENOTSUP
397  *   Resetting statistics is not supported.
398  * @retval -EINVAL
399  *   Resetting statistics is not valid.
400  * @retval -ENOMEM
401  *   Not enough memory to get the stats.
402  */
403 typedef int (*eth_xstats_reset_t)(struct rte_eth_dev *dev);
404 
405 /** @internal Get names of extended stats of an Ethernet device. */
406 typedef int (*eth_xstats_get_names_t)(struct rte_eth_dev *dev,
407 	struct rte_eth_xstat_name *xstats_names, unsigned int size);
408 
409 /**
410  * @internal
411  * Get names of extended stats of an Ethernet device.
412  *
413  * @param dev
414  *   ethdev handle of port.
415  * @param ids
416  *   IDs array to retrieve specific statistics. Must not be NULL.
417  * @param xstats_names
418  *   An rte_eth_xstat_name array of at least @p size elements to be filled.
419  *   Must not be NULL.
420  * @param size
421  *   Element count in @p ids and @p xstats_names.
422  *
423  * @return
424  *   - A number of filled in stats.
425  *   - A negative value on error.
426  */
427 typedef int (*eth_xstats_get_names_by_id_t)(struct rte_eth_dev *dev,
428 	const uint64_t *ids, struct rte_eth_xstat_name *xstats_names,
429 	unsigned int size);
430 
431 /**
432  * @internal
433  * Set a queue statistics mapping for a Tx/Rx queue of an Ethernet device.
434  */
435 typedef int (*eth_queue_stats_mapping_set_t)(struct rte_eth_dev *dev,
436 					     uint16_t queue_id,
437 					     uint8_t stat_idx,
438 					     uint8_t is_rx);
439 
440 /** @internal Get specific information of an Ethernet device. */
441 typedef int (*eth_dev_infos_get_t)(struct rte_eth_dev *dev,
442 				   struct rte_eth_dev_info *dev_info);
443 
444 /** @internal Get supported ptypes of an Ethernet device. */
445 typedef const uint32_t *(*eth_dev_supported_ptypes_get_t)(struct rte_eth_dev *dev);
446 
447 /**
448  * @internal
449  * Inform Ethernet device about reduced range of packet types to handle.
450  *
451  * @param dev
452  *   The Ethernet device identifier.
453  * @param ptype_mask
454  *   The ptype family that application is interested in should be bitwise OR of
455  *   RTE_PTYPE_*_MASK or 0.
456  * @return
457  *   - (0) if Success.
458  */
459 typedef int (*eth_dev_ptypes_set_t)(struct rte_eth_dev *dev,
460 				     uint32_t ptype_mask);
461 
462 /** @internal Start Rx and Tx of a queue of an Ethernet device. */
463 typedef int (*eth_queue_start_t)(struct rte_eth_dev *dev,
464 				    uint16_t queue_id);
465 
466 /** @internal Stop Rx and Tx of a queue of an Ethernet device. */
467 typedef int (*eth_queue_stop_t)(struct rte_eth_dev *dev,
468 				    uint16_t queue_id);
469 
470 /** @internal Set up a receive queue of an Ethernet device. */
471 typedef int (*eth_rx_queue_setup_t)(struct rte_eth_dev *dev,
472 				    uint16_t rx_queue_id,
473 				    uint16_t nb_rx_desc,
474 				    unsigned int socket_id,
475 				    const struct rte_eth_rxconf *rx_conf,
476 				    struct rte_mempool *mb_pool);
477 
478 /** @internal Setup a transmit queue of an Ethernet device. */
479 typedef int (*eth_tx_queue_setup_t)(struct rte_eth_dev *dev,
480 				    uint16_t tx_queue_id,
481 				    uint16_t nb_tx_desc,
482 				    unsigned int socket_id,
483 				    const struct rte_eth_txconf *tx_conf);
484 
485 /** @internal Enable interrupt of a receive queue of an Ethernet device. */
486 typedef int (*eth_rx_enable_intr_t)(struct rte_eth_dev *dev,
487 				    uint16_t rx_queue_id);
488 
489 /** @internal Disable interrupt of a receive queue of an Ethernet device. */
490 typedef int (*eth_rx_disable_intr_t)(struct rte_eth_dev *dev,
491 				    uint16_t rx_queue_id);
492 
493 /** @internal Release memory resources allocated by given Rx/Tx queue. */
494 typedef void (*eth_queue_release_t)(struct rte_eth_dev *dev,
495 				    uint16_t queue_id);
496 
497 /** @internal Get firmware information of an Ethernet device. */
498 typedef int (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
499 				     char *fw_version, size_t fw_size);
500 
501 /** @internal Force mbufs to be from Tx ring. */
502 typedef int (*eth_tx_done_cleanup_t)(void *txq, uint32_t free_cnt);
503 
504 typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
505 	uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
506 
507 typedef void (*eth_txq_info_get_t)(struct rte_eth_dev *dev,
508 	uint16_t tx_queue_id, struct rte_eth_txq_info *qinfo);
509 
510 typedef int (*eth_burst_mode_get_t)(struct rte_eth_dev *dev,
511 	uint16_t queue_id, struct rte_eth_burst_mode *mode);
512 
513 /** @internal Set MTU. */
514 typedef int (*mtu_set_t)(struct rte_eth_dev *dev, uint16_t mtu);
515 
516 /** @internal Filtering of a VLAN Tag Identifier by an Ethernet device. */
517 typedef int (*vlan_filter_set_t)(struct rte_eth_dev *dev,
518 				  uint16_t vlan_id,
519 				  int on);
520 
521 /** @internal Set the outer/inner VLAN-TPID by an Ethernet device. */
522 typedef int (*vlan_tpid_set_t)(struct rte_eth_dev *dev,
523 			       enum rte_vlan_type type, uint16_t tpid);
524 
525 /** @internal Set VLAN offload function by an Ethernet device. */
526 typedef int (*vlan_offload_set_t)(struct rte_eth_dev *dev, int mask);
527 
528 /** @internal Set port based Tx VLAN insertion by an Ethernet device. */
529 typedef int (*vlan_pvid_set_t)(struct rte_eth_dev *dev,
530 			       uint16_t vlan_id,
531 			       int on);
532 
533 /** @internal VLAN stripping enable/disable by an queue of Ethernet device. */
534 typedef void (*vlan_strip_queue_set_t)(struct rte_eth_dev *dev,
535 				  uint16_t rx_queue_id,
536 				  int on);
537 
538 /** @internal Get current flow control parameter on an Ethernet device. */
539 typedef int (*flow_ctrl_get_t)(struct rte_eth_dev *dev,
540 			       struct rte_eth_fc_conf *fc_conf);
541 
542 /** @internal Setup flow control parameter on an Ethernet device. */
543 typedef int (*flow_ctrl_set_t)(struct rte_eth_dev *dev,
544 			       struct rte_eth_fc_conf *fc_conf);
545 
546 /** @internal Setup priority flow control parameter on an Ethernet device. */
547 typedef int (*priority_flow_ctrl_set_t)(struct rte_eth_dev *dev,
548 				struct rte_eth_pfc_conf *pfc_conf);
549 
550 /** @internal Get info for queue based PFC on an Ethernet device. */
551 typedef int (*priority_flow_ctrl_queue_info_get_t)(struct rte_eth_dev *dev,
552 			struct rte_eth_pfc_queue_info *pfc_queue_info);
553 /** @internal Configure queue based PFC parameter on an Ethernet device. */
554 typedef int (*priority_flow_ctrl_queue_config_t)(struct rte_eth_dev *dev,
555 			struct rte_eth_pfc_queue_conf *pfc_queue_conf);
556 
557 /** @internal Update RSS redirection table on an Ethernet device. */
558 typedef int (*reta_update_t)(struct rte_eth_dev *dev,
559 			     struct rte_eth_rss_reta_entry64 *reta_conf,
560 			     uint16_t reta_size);
561 
562 /** @internal Query RSS redirection table on an Ethernet device. */
563 typedef int (*reta_query_t)(struct rte_eth_dev *dev,
564 			    struct rte_eth_rss_reta_entry64 *reta_conf,
565 			    uint16_t reta_size);
566 
567 /** @internal Update RSS hash configuration of an Ethernet device. */
568 typedef int (*rss_hash_update_t)(struct rte_eth_dev *dev,
569 				 struct rte_eth_rss_conf *rss_conf);
570 
571 /** @internal Get current RSS hash configuration of an Ethernet device. */
572 typedef int (*rss_hash_conf_get_t)(struct rte_eth_dev *dev,
573 				   struct rte_eth_rss_conf *rss_conf);
574 
575 /** @internal Turn on SW controllable LED on an Ethernet device. */
576 typedef int (*eth_dev_led_on_t)(struct rte_eth_dev *dev);
577 
578 /** @internal Turn off SW controllable LED on an Ethernet device. */
579 typedef int (*eth_dev_led_off_t)(struct rte_eth_dev *dev);
580 
581 /** @internal Remove MAC address from receive address register. */
582 typedef void (*eth_mac_addr_remove_t)(struct rte_eth_dev *dev, uint32_t index);
583 
584 /** @internal Set a MAC address into Receive Address Register. */
585 typedef int (*eth_mac_addr_add_t)(struct rte_eth_dev *dev,
586 				  struct rte_ether_addr *mac_addr,
587 				  uint32_t index,
588 				  uint32_t vmdq);
589 
590 /** @internal Set a MAC address into Receive Address Register. */
591 typedef int (*eth_mac_addr_set_t)(struct rte_eth_dev *dev,
592 				  struct rte_ether_addr *mac_addr);
593 
594 /** @internal Set a Unicast Hash bitmap. */
595 typedef int (*eth_uc_hash_table_set_t)(struct rte_eth_dev *dev,
596 				  struct rte_ether_addr *mac_addr,
597 				  uint8_t on);
598 
599 /** @internal Set all Unicast Hash bitmap. */
600 typedef int (*eth_uc_all_hash_table_set_t)(struct rte_eth_dev *dev,
601 				  uint8_t on);
602 
603 /** @internal Set queue Tx rate. */
604 typedef int (*eth_set_queue_rate_limit_t)(struct rte_eth_dev *dev,
605 				uint16_t queue_idx,
606 				uint32_t tx_rate);
607 
608 /** @internal Add tunneling UDP port. */
609 typedef int (*eth_udp_tunnel_port_add_t)(struct rte_eth_dev *dev,
610 					 struct rte_eth_udp_tunnel *tunnel_udp);
611 
612 /** @internal Delete tunneling UDP port. */
613 typedef int (*eth_udp_tunnel_port_del_t)(struct rte_eth_dev *dev,
614 					 struct rte_eth_udp_tunnel *tunnel_udp);
615 
616 /** @internal set the list of multicast addresses on an Ethernet device. */
617 typedef int (*eth_set_mc_addr_list_t)(struct rte_eth_dev *dev,
618 				      struct rte_ether_addr *mc_addr_set,
619 				      uint32_t nb_mc_addr);
620 
621 /** @internal Function used to enable IEEE1588/802.1AS timestamping. */
622 typedef int (*eth_timesync_enable_t)(struct rte_eth_dev *dev);
623 
624 /** @internal Function used to disable IEEE1588/802.1AS timestamping. */
625 typedef int (*eth_timesync_disable_t)(struct rte_eth_dev *dev);
626 
627 /** @internal Function used to read an Rx IEEE1588/802.1AS timestamp. */
628 typedef int (*eth_timesync_read_rx_timestamp_t)(struct rte_eth_dev *dev,
629 						struct timespec *timestamp,
630 						uint32_t flags);
631 
632 /** @internal Function used to read a Tx IEEE1588/802.1AS timestamp. */
633 typedef int (*eth_timesync_read_tx_timestamp_t)(struct rte_eth_dev *dev,
634 						struct timespec *timestamp);
635 
636 /** @internal Function used to adjust the device clock. */
637 typedef int (*eth_timesync_adjust_time)(struct rte_eth_dev *dev, int64_t);
638 
639 /** @internal Function used to get time from the device clock. */
640 typedef int (*eth_timesync_read_time)(struct rte_eth_dev *dev,
641 				      struct timespec *timestamp);
642 
643 /** @internal Function used to get time from the device clock. */
644 typedef int (*eth_timesync_write_time)(struct rte_eth_dev *dev,
645 				       const struct timespec *timestamp);
646 
647 /** @internal Function used to get the current value of the device clock. */
648 typedef int (*eth_read_clock)(struct rte_eth_dev *dev,
649 				      uint64_t *timestamp);
650 
651 /** @internal Retrieve registers. */
652 typedef int (*eth_get_reg_t)(struct rte_eth_dev *dev,
653 				struct rte_dev_reg_info *info);
654 
655 /** @internal Retrieve EEPROM size. */
656 typedef int (*eth_get_eeprom_length_t)(struct rte_eth_dev *dev);
657 
658 /** @internal Retrieve EEPROM data. */
659 typedef int (*eth_get_eeprom_t)(struct rte_eth_dev *dev,
660 				struct rte_dev_eeprom_info *info);
661 
662 /** @internal Program EEPROM data. */
663 typedef int (*eth_set_eeprom_t)(struct rte_eth_dev *dev,
664 				struct rte_dev_eeprom_info *info);
665 
666 /** @internal Retrieve type and size of plugin module EEPROM. */
667 typedef int (*eth_get_module_info_t)(struct rte_eth_dev *dev,
668 				     struct rte_eth_dev_module_info *modinfo);
669 
670 /** @internal Retrieve plugin module EEPROM data. */
671 typedef int (*eth_get_module_eeprom_t)(struct rte_eth_dev *dev,
672 				       struct rte_dev_eeprom_info *info);
673 
674 struct rte_flow_ops;
675 /**
676  * @internal
677  * Get flow operations.
678  *
679  * If the flow API is not supported for the specified device,
680  * the driver can return NULL.
681  */
682 typedef int (*eth_flow_ops_get_t)(struct rte_eth_dev *dev,
683 				  const struct rte_flow_ops **ops);
684 
685 /** @internal Get Traffic Management (TM) operations on an Ethernet device. */
686 typedef int (*eth_tm_ops_get_t)(struct rte_eth_dev *dev, void *ops);
687 
688 /** @internal Get Traffic Metering and Policing (MTR) operations. */
689 typedef int (*eth_mtr_ops_get_t)(struct rte_eth_dev *dev, void *ops);
690 
691 /** @internal Get DCB information on an Ethernet device. */
692 typedef int (*eth_get_dcb_info)(struct rte_eth_dev *dev,
693 				 struct rte_eth_dcb_info *dcb_info);
694 
695 /** @internal Test if a port supports specific mempool ops. */
696 typedef int (*eth_pool_ops_supported_t)(struct rte_eth_dev *dev,
697 						const char *pool);
698 
699 /**
700  * @internal
701  * Get the hairpin capabilities.
702  *
703  * @param dev
704  *   ethdev handle of port.
705  * @param cap
706  *   returns the hairpin capabilities from the device.
707  *
708  * @return
709  *   Negative errno value on error, 0 on success.
710  *
711  * @retval 0
712  *   Success, hairpin is supported.
713  * @retval -ENOTSUP
714  *   Hairpin is not supported.
715  */
716 typedef int (*eth_hairpin_cap_get_t)(struct rte_eth_dev *dev,
717 				     struct rte_eth_hairpin_cap *cap);
718 
719 /**
720  * @internal
721  * Setup Rx hairpin queue.
722  *
723  * @param dev
724  *   ethdev handle of port.
725  * @param rx_queue_id
726  *   the selected Rx queue index.
727  * @param nb_rx_desc
728  *   the requested number of descriptors for this queue. 0 - use PMD default.
729  * @param conf
730  *   the Rx hairpin configuration structure.
731  *
732  * @return
733  *   Negative errno value on error, 0 on success.
734  *
735  * @retval 0
736  *   Success, hairpin is supported.
737  * @retval -ENOTSUP
738  *   Hairpin is not supported.
739  * @retval -EINVAL
740  *   One of the parameters is invalid.
741  * @retval -ENOMEM
742  *   Unable to allocate resources.
743  */
744 typedef int (*eth_rx_hairpin_queue_setup_t)
745 	(struct rte_eth_dev *dev, uint16_t rx_queue_id,
746 	 uint16_t nb_rx_desc,
747 	 const struct rte_eth_hairpin_conf *conf);
748 
749 /**
750  * @internal
751  * Setup Tx hairpin queue.
752  *
753  * @param dev
754  *   ethdev handle of port.
755  * @param tx_queue_id
756  *   the selected Tx queue index.
757  * @param nb_tx_desc
758  *   the requested number of descriptors for this queue. 0 - use PMD default.
759  * @param conf
760  *   the Tx hairpin configuration structure.
761  *
762  * @return
763  *   Negative errno value on error, 0 on success.
764  *
765  * @retval 0
766  *   Success, hairpin is supported.
767  * @retval -ENOTSUP
768  *   Hairpin is not supported.
769  * @retval -EINVAL
770  *   One of the parameters is invalid.
771  * @retval -ENOMEM
772  *   Unable to allocate resources.
773  */
774 typedef int (*eth_tx_hairpin_queue_setup_t)
775 	(struct rte_eth_dev *dev, uint16_t tx_queue_id,
776 	 uint16_t nb_tx_desc,
777 	 const struct rte_eth_hairpin_conf *hairpin_conf);
778 
779 /**
780  * @internal
781  * Get Forward Error Correction(FEC) capability.
782  *
783  * @param dev
784  *   ethdev handle of port.
785  * @param speed_fec_capa
786  *   speed_fec_capa is out only with per-speed capabilities.
787  * @param num
788  *   a number of elements in an speed_fec_capa array.
789  *
790  * @return
791  *   Negative errno value on error, positive value on success.
792  *
793  * @retval positive value
794  *   A non-negative value lower or equal to num: success. The return value
795  *   is the number of entries filled in the fec capa array.
796  *   A non-negative value higher than num: error, the given fec capa array
797  *   is too small. The return value corresponds to the num that should
798  *   be given to succeed. The entries in the fec capa array are not valid
799  *   and shall not be used by the caller.
800  * @retval -ENOTSUP
801  *   Operation is not supported.
802  * @retval -EIO
803  *   Device is removed.
804  * @retval -EINVAL
805  *   *num* or *speed_fec_capa* invalid.
806  */
807 typedef int (*eth_fec_get_capability_t)(struct rte_eth_dev *dev,
808 		struct rte_eth_fec_capa *speed_fec_capa, unsigned int num);
809 
810 /**
811  * @internal
812  * Get Forward Error Correction(FEC) mode.
813  *
814  * @param dev
815  *   ethdev handle of port.
816  * @param fec_capa
817  *   a bitmask of enabled FEC modes. If AUTO bit is set, other
818  *   bits specify FEC modes which may be negotiated. If AUTO
819  *   bit is clear, specify FEC modes to be used (only one valid
820  *   mode per speed may be set).
821  *
822  * @return
823  *   Negative errno value on error, 0 on success.
824  *
825  * @retval 0
826  *   Success, get FEC success.
827  * @retval -ENOTSUP
828  *   Operation is not supported.
829  * @retval -EIO
830  *   Device is removed.
831  */
832 typedef int (*eth_fec_get_t)(struct rte_eth_dev *dev,
833 			     uint32_t *fec_capa);
834 
835 /**
836  * @internal
837  * Set Forward Error Correction(FEC) mode.
838  *
839  * @param dev
840  *   ethdev handle of port.
841  * @param fec_capa
842  *   bitmask of allowed FEC modes. It must be only one
843  *   if AUTO is disabled. If AUTO is enabled, other
844  *   bits specify FEC modes which may be negotiated.
845  *
846  * @return
847  *   Negative errno value on error, 0 on success.
848  *
849  * @retval 0
850  *   Success, set FEC success.
851  * @retval -ENOTSUP
852  *   Operation is not supported.
853  * @retval -EINVAL
854  *   Unsupported FEC mode requested.
855  * @retval -EIO
856  *   Device is removed.
857  */
858 typedef int (*eth_fec_set_t)(struct rte_eth_dev *dev, uint32_t fec_capa);
859 
860 /**
861  * @internal
862  * Get all hairpin Tx/Rx peer ports of the current device, if any.
863  *
864  * @param dev
865  *   ethdev handle of port.
866  * @param peer_ports
867  *   array to save the ports list.
868  * @param len
869  *   array length.
870  * @param direction
871  *   value to decide the current to peer direction
872  *   positive - used as Tx to get all peer Rx ports.
873  *   zero - used as Rx to get all peer Tx ports.
874  *
875  * @return
876  *   Negative errno value on error, 0 or positive on success.
877  *
878  * @retval 0
879  *   Success, no peer ports.
880  * @retval >0
881  *   Actual number of the peer ports.
882  * @retval -ENOTSUP
883  *   Get peer ports API is not supported.
884  * @retval -EINVAL
885  *   One of the parameters is invalid.
886  */
887 typedef int (*hairpin_get_peer_ports_t)(struct rte_eth_dev *dev,
888 					uint16_t *peer_ports, size_t len,
889 					uint32_t direction);
890 
891 /**
892  * @internal
893  * Bind all hairpin Tx queues of one port to the Rx queues of the peer port.
894  *
895  * @param dev
896  *   ethdev handle of port.
897  * @param rx_port
898  *   the peer Rx port.
899  *
900  * @return
901  *   Negative errno value on error, 0 on success.
902  *
903  * @retval 0
904  *   Success, bind successfully.
905  * @retval -ENOTSUP
906  *   Bind API is not supported.
907  * @retval -EINVAL
908  *   One of the parameters is invalid.
909  * @retval -EBUSY
910  *   Device is not started.
911  */
912 typedef int (*eth_hairpin_bind_t)(struct rte_eth_dev *dev,
913 				uint16_t rx_port);
914 
915 /**
916  * @internal
917  * Unbind all hairpin Tx queues of one port from the Rx queues of the peer port.
918  *
919  * @param dev
920  *   ethdev handle of port.
921  * @param rx_port
922  *   the peer Rx port.
923  *
924  * @return
925  *   Negative errno value on error, 0 on success.
926  *
927  * @retval 0
928  *   Success, unbind successfully.
929  * @retval -ENOTSUP
930  *   Bind API is not supported.
931  * @retval -EINVAL
932  *   One of the parameters is invalid.
933  * @retval -EBUSY
934  *   Device is already stopped.
935  */
936 typedef int (*eth_hairpin_unbind_t)(struct rte_eth_dev *dev,
937 				  uint16_t rx_port);
938 
939 /** @internal Update and fetch peer queue information. */
940 typedef int (*eth_hairpin_queue_peer_update_t)
941 	(struct rte_eth_dev *dev, uint16_t peer_queue,
942 	 struct rte_hairpin_peer_info *current_info,
943 	 struct rte_hairpin_peer_info *peer_info, uint32_t direction);
944 
945 /** @internal Bind peer queue to the current queue with fetched information. */
946 typedef int (*eth_hairpin_queue_peer_bind_t)
947 	(struct rte_eth_dev *dev, uint16_t cur_queue,
948 	 struct rte_hairpin_peer_info *peer_info, uint32_t direction);
949 
950 /** @internal Unbind peer queue from the current queue. */
951 typedef int (*eth_hairpin_queue_peer_unbind_t)
952 	(struct rte_eth_dev *dev, uint16_t cur_queue, uint32_t direction);
953 
954 /**
955  * @internal
956  * Get address of memory location whose contents will change whenever there is
957  * new data to be received on an Rx queue.
958  *
959  * @param rxq
960  *   Ethdev queue pointer.
961  * @param pmc
962  *   The pointer to power-optimized monitoring condition structure.
963  * @return
964  *   Negative errno value on error, 0 on success.
965  *
966  * @retval 0
967  *   Success
968  * @retval -EINVAL
969  *   Invalid parameters
970  */
971 typedef int (*eth_get_monitor_addr_t)(void *rxq,
972 		struct rte_power_monitor_cond *pmc);
973 
974 /**
975  * @internal
976  * Get representor info to be able to calculate the unique representor ID.
977  *
978  * Caller should pass NULL as pointer of info to get number of entries,
979  * allocate info buffer according to returned entry number, then call
980  * again with buffer to get real info.
981  *
982  * To calculate the representor ID, caller should iterate each entry,
983  * match controller index, pf index, vf or sf start index and range,
984  * then calculate representor ID from offset to vf/sf start index.
985  * @see rte_eth_representor_id_get.
986  *
987  * @param dev
988  *   Ethdev handle of port.
989  * @param [out] info
990  *   Pointer to memory to save device representor info.
991  * @return
992  *   Negative errno value on error, number of info entries otherwise.
993  */
994 
995 typedef int (*eth_representor_info_get_t)(struct rte_eth_dev *dev,
996 	struct rte_eth_representor_info *info);
997 
998 /**
999  * @internal
1000  * Negotiate the NIC's ability to deliver specific kinds of metadata to the PMD.
1001  *
1002  * @param dev
1003  *   Port (ethdev) handle
1004  *
1005  * @param[inout] features
1006  *   Feature selection buffer
1007  *
1008  * @return
1009  *   Negative errno value on error, zero otherwise
1010  */
1011 typedef int (*eth_rx_metadata_negotiate_t)(struct rte_eth_dev *dev,
1012 				       uint64_t *features);
1013 
1014 /**
1015  * @internal
1016  * Get IP reassembly offload capability of a PMD.
1017  *
1018  * @param dev
1019  *   Port (ethdev) handle
1020  *
1021  * @param[out] conf
1022  *   IP reassembly capability supported by the PMD
1023  *
1024  * @return
1025  *   Negative errno value on error, zero otherwise
1026  */
1027 typedef int (*eth_ip_reassembly_capability_get_t)(struct rte_eth_dev *dev,
1028 		struct rte_eth_ip_reassembly_params *capa);
1029 
1030 /**
1031  * @internal
1032  * Get IP reassembly offload configuration parameters set in PMD.
1033  *
1034  * @param dev
1035  *   Port (ethdev) handle
1036  *
1037  * @param[out] conf
1038  *   Configuration parameters for IP reassembly.
1039  *
1040  * @return
1041  *   Negative errno value on error, zero otherwise
1042  */
1043 typedef int (*eth_ip_reassembly_conf_get_t)(struct rte_eth_dev *dev,
1044 		struct rte_eth_ip_reassembly_params *conf);
1045 
1046 /**
1047  * @internal
1048  * Set configuration parameters for enabling IP reassembly offload in hardware.
1049  *
1050  * @param dev
1051  *   Port (ethdev) handle
1052  *
1053  * @param[in] conf
1054  *   Configuration parameters for IP reassembly.
1055  *
1056  * @return
1057  *   Negative errno value on error, zero otherwise
1058  */
1059 typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev,
1060 		const struct rte_eth_ip_reassembly_params *conf);
1061 
1062 /**
1063  * @internal
1064  * Get supported header protocols of a PMD to split.
1065  *
1066  * @param dev
1067  *   Ethdev handle of port.
1068  *
1069  * @return
1070  *   An array pointer to store supported protocol headers.
1071  */
1072 typedef const uint32_t *(*eth_buffer_split_supported_hdr_ptypes_get_t)(struct rte_eth_dev *dev);
1073 
1074 /**
1075  * @internal
1076  * Dump private info from device to a file.
1077  *
1078  * @param dev
1079  *   Port (ethdev) handle.
1080  * @param file
1081  *   A pointer to a file for output.
1082  *
1083  * @return
1084  *   Negative value on error, 0 on success.
1085  *
1086  * @retval 0
1087  *   Success
1088  * @retval -EINVAL
1089  *   Invalid file
1090  */
1091 typedef int (*eth_dev_priv_dump_t)(struct rte_eth_dev *dev, FILE *file);
1092 
1093 /**
1094  * @internal Set Rx queue available descriptors threshold.
1095  * @see rte_eth_rx_avail_thresh_set()
1096  *
1097  * Driver should round down number of descriptors on conversion from
1098  * percentage.
1099  */
1100 typedef int (*eth_rx_queue_avail_thresh_set_t)(struct rte_eth_dev *dev,
1101 				      uint16_t rx_queue_id,
1102 				      uint8_t avail_thresh);
1103 
1104 /**
1105  * @internal Query Rx queue available descriptors threshold event.
1106  * @see rte_eth_rx_avail_thresh_query()
1107  */
1108 
1109 typedef int (*eth_rx_queue_avail_thresh_query_t)(struct rte_eth_dev *dev,
1110 					uint16_t *rx_queue_id,
1111 					uint8_t *avail_thresh);
1112 
1113 /** @internal Get congestion management information. */
1114 typedef int (*eth_cman_info_get_t)(struct rte_eth_dev *dev,
1115 				struct rte_eth_cman_info *info);
1116 
1117 /** @internal Init congestion management structure with default values. */
1118 typedef int (*eth_cman_config_init_t)(struct rte_eth_dev *dev,
1119 				struct rte_eth_cman_config *config);
1120 
1121 /** @internal Configure congestion management on a port. */
1122 typedef int (*eth_cman_config_set_t)(struct rte_eth_dev *dev,
1123 				const struct rte_eth_cman_config *config);
1124 
1125 /** @internal Retrieve congestion management configuration of a port. */
1126 typedef int (*eth_cman_config_get_t)(struct rte_eth_dev *dev,
1127 				struct rte_eth_cman_config *config);
1128 
1129 /**
1130  * @internal
1131  * Dump Rx descriptor info to a file.
1132  *
1133  * It is used for debugging, not a dataplane API.
1134  *
1135  * @param dev
1136  *   Port (ethdev) handle.
1137  * @param queue_id
1138  *   A Rx queue identifier on this port.
1139  * @param offset
1140  *   The offset of the descriptor starting from tail. (0 is the next
1141  *   packet to be received by the driver).
1142  * @param num
1143  *   The number of the descriptors to dump.
1144  * @param file
1145  *   A pointer to a file for output.
1146  * @return
1147  *   Negative errno value on error, zero on success.
1148  */
1149 typedef int (*eth_rx_descriptor_dump_t)(const struct rte_eth_dev *dev,
1150 					uint16_t queue_id, uint16_t offset,
1151 					uint16_t num, FILE *file);
1152 
1153 /**
1154  * @internal
1155  * Dump Tx descriptor info to a file.
1156  *
1157  * This API is used for debugging, not a dataplane API.
1158  *
1159  * @param dev
1160  *   Port (ethdev) handle.
1161  * @param queue_id
1162  *   A Tx queue identifier on this port.
1163  * @param offset
1164  *   The offset of the descriptor starting from tail. (0 is the place where
1165  *   the next packet will be send).
1166  * @param num
1167  *   The number of the descriptors to dump.
1168  * @param file
1169  *   A pointer to a file for output.
1170  * @return
1171  *   Negative errno value on error, zero on success.
1172  */
1173 typedef int (*eth_tx_descriptor_dump_t)(const struct rte_eth_dev *dev,
1174 					uint16_t queue_id, uint16_t offset,
1175 					uint16_t num, FILE *file);
1176 
1177 /**
1178  * @internal
1179  * Get the number of aggregated ports.
1180  *
1181  * @param dev
1182  *   Port (ethdev) handle.
1183  *
1184  * @return
1185  *   Negative errno value on error, 0 or positive on success.
1186  *
1187  * @retval >=0
1188  *   The number of aggregated port if success.
1189  */
1190 typedef int (*eth_count_aggr_ports_t)(struct rte_eth_dev *dev);
1191 
1192 /**
1193  * @internal
1194  * Map a Tx queue with an aggregated port of the DPDK port.
1195  *
1196  * @param dev
1197  *   Port (ethdev) handle.
1198  * @param tx_queue_id
1199  *   The index of the transmit queue used in rte_eth_tx_burst().
1200  * @param affinity
1201  *   The number of the aggregated port.
1202  *
1203  * @return
1204  *   Negative on error, 0 on success.
1205  */
1206 typedef int (*eth_map_aggr_tx_affinity_t)(struct rte_eth_dev *dev, uint16_t tx_queue_id,
1207 					  uint8_t affinity);
1208 
1209 /**
1210  * @internal A structure containing the functions exported by an Ethernet driver.
1211  */
1212 struct eth_dev_ops {
1213 	eth_dev_configure_t        dev_configure; /**< Configure device */
1214 	eth_dev_start_t            dev_start;     /**< Start device */
1215 	eth_dev_stop_t             dev_stop;      /**< Stop device */
1216 	eth_dev_set_link_up_t      dev_set_link_up;   /**< Device link up */
1217 	eth_dev_set_link_down_t    dev_set_link_down; /**< Device link down */
1218 	eth_dev_close_t            dev_close;     /**< Close device */
1219 	eth_dev_reset_t		   dev_reset;	  /**< Reset device */
1220 	eth_link_update_t          link_update;   /**< Get device link state */
1221 	/** Check if the device was physically removed */
1222 	eth_is_removed_t           is_removed;
1223 
1224 	eth_promiscuous_enable_t   promiscuous_enable; /**< Promiscuous ON */
1225 	eth_promiscuous_disable_t  promiscuous_disable;/**< Promiscuous OFF */
1226 	eth_allmulticast_enable_t  allmulticast_enable;/**< Rx multicast ON */
1227 	eth_allmulticast_disable_t allmulticast_disable;/**< Rx multicast OFF */
1228 	eth_mac_addr_remove_t      mac_addr_remove; /**< Remove MAC address */
1229 	eth_mac_addr_add_t         mac_addr_add;  /**< Add a MAC address */
1230 	eth_mac_addr_set_t         mac_addr_set;  /**< Set a MAC address */
1231 	/** Set list of multicast addresses */
1232 	eth_set_mc_addr_list_t     set_mc_addr_list;
1233 	mtu_set_t                  mtu_set;       /**< Set MTU */
1234 
1235 	/** Get generic device statistics */
1236 	eth_stats_get_t            stats_get;
1237 	/** Reset generic device statistics */
1238 	eth_stats_reset_t          stats_reset;
1239 	/** Get extended device statistics */
1240 	eth_xstats_get_t           xstats_get;
1241 	/** Reset extended device statistics */
1242 	eth_xstats_reset_t         xstats_reset;
1243 	/** Get names of extended statistics */
1244 	eth_xstats_get_names_t     xstats_get_names;
1245 	/** Configure per queue stat counter mapping */
1246 	eth_queue_stats_mapping_set_t queue_stats_mapping_set;
1247 
1248 	eth_dev_infos_get_t        dev_infos_get; /**< Get device info */
1249 	/** Retrieve Rx queue information */
1250 	eth_rxq_info_get_t         rxq_info_get;
1251 	/** Retrieve Tx queue information */
1252 	eth_txq_info_get_t         txq_info_get;
1253 	eth_burst_mode_get_t       rx_burst_mode_get; /**< Get Rx burst mode */
1254 	eth_burst_mode_get_t       tx_burst_mode_get; /**< Get Tx burst mode */
1255 	eth_fw_version_get_t       fw_version_get; /**< Get firmware version */
1256 
1257 	/** Get packet types supported and identified by device */
1258 	eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
1259 	/**
1260 	 * Inform Ethernet device about reduced range of packet types to
1261 	 * handle
1262 	 */
1263 	eth_dev_ptypes_set_t dev_ptypes_set;
1264 
1265 	/** Filter VLAN Setup */
1266 	vlan_filter_set_t          vlan_filter_set;
1267 	/** Outer/Inner VLAN TPID Setup */
1268 	vlan_tpid_set_t            vlan_tpid_set;
1269 	/** VLAN Stripping on queue */
1270 	vlan_strip_queue_set_t     vlan_strip_queue_set;
1271 	/** Set VLAN Offload */
1272 	vlan_offload_set_t         vlan_offload_set;
1273 	/** Set port based Tx VLAN insertion */
1274 	vlan_pvid_set_t            vlan_pvid_set;
1275 
1276 	eth_queue_start_t          rx_queue_start;/**< Start Rx for a queue */
1277 	eth_queue_stop_t           rx_queue_stop; /**< Stop Rx for a queue */
1278 	eth_queue_start_t          tx_queue_start;/**< Start Tx for a queue */
1279 	eth_queue_stop_t           tx_queue_stop; /**< Stop Tx for a queue */
1280 	eth_rx_queue_setup_t       rx_queue_setup;/**< Set up device Rx queue */
1281 	eth_queue_release_t        rx_queue_release; /**< Release Rx queue */
1282 
1283 	/** Enable Rx queue interrupt */
1284 	eth_rx_enable_intr_t       rx_queue_intr_enable;
1285 	/** Disable Rx queue interrupt */
1286 	eth_rx_disable_intr_t      rx_queue_intr_disable;
1287 
1288 	eth_tx_queue_setup_t       tx_queue_setup;/**< Set up device Tx queue */
1289 	eth_queue_release_t        tx_queue_release; /**< Release Tx queue */
1290 	eth_tx_done_cleanup_t      tx_done_cleanup;/**< Free Tx ring mbufs */
1291 
1292 	eth_dev_led_on_t           dev_led_on;    /**< Turn on LED */
1293 	eth_dev_led_off_t          dev_led_off;   /**< Turn off LED */
1294 
1295 	flow_ctrl_get_t            flow_ctrl_get; /**< Get flow control */
1296 	flow_ctrl_set_t            flow_ctrl_set; /**< Setup flow control */
1297 	/** Setup priority flow control */
1298 	priority_flow_ctrl_set_t   priority_flow_ctrl_set;
1299 	/** Priority flow control queue info get */
1300 	priority_flow_ctrl_queue_info_get_t priority_flow_ctrl_queue_info_get;
1301 	/** Priority flow control queue configure */
1302 	priority_flow_ctrl_queue_config_t priority_flow_ctrl_queue_config;
1303 
1304 	/** Set Unicast Table Array */
1305 	eth_uc_hash_table_set_t    uc_hash_table_set;
1306 	/** Set Unicast hash bitmap */
1307 	eth_uc_all_hash_table_set_t uc_all_hash_table_set;
1308 
1309 	/** Add UDP tunnel port */
1310 	eth_udp_tunnel_port_add_t  udp_tunnel_port_add;
1311 	/** Delete UDP tunnel port */
1312 	eth_udp_tunnel_port_del_t  udp_tunnel_port_del;
1313 
1314 	/** Set queue rate limit */
1315 	eth_set_queue_rate_limit_t set_queue_rate_limit;
1316 
1317 	/** Configure RSS hash protocols and hashing key */
1318 	rss_hash_update_t          rss_hash_update;
1319 	/** Get current RSS hash configuration */
1320 	rss_hash_conf_get_t        rss_hash_conf_get;
1321 	/** Update redirection table */
1322 	reta_update_t              reta_update;
1323 	/** Query redirection table */
1324 	reta_query_t               reta_query;
1325 
1326 	eth_get_reg_t              get_reg;           /**< Get registers */
1327 	eth_get_eeprom_length_t    get_eeprom_length; /**< Get EEPROM length */
1328 	eth_get_eeprom_t           get_eeprom;        /**< Get EEPROM data */
1329 	eth_set_eeprom_t           set_eeprom;        /**< Set EEPROM */
1330 
1331 	/** Get plugin module EEPROM attribute */
1332 	eth_get_module_info_t      get_module_info;
1333 	/** Get plugin module EEPROM data */
1334 	eth_get_module_eeprom_t    get_module_eeprom;
1335 
1336 	eth_flow_ops_get_t         flow_ops_get; /**< Get flow operations */
1337 
1338 	eth_get_dcb_info           get_dcb_info; /**< Get DCB information */
1339 
1340 	/** Turn IEEE1588/802.1AS timestamping on */
1341 	eth_timesync_enable_t      timesync_enable;
1342 	/** Turn IEEE1588/802.1AS timestamping off */
1343 	eth_timesync_disable_t     timesync_disable;
1344 	/** Read the IEEE1588/802.1AS Rx timestamp */
1345 	eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp;
1346 	/** Read the IEEE1588/802.1AS Tx timestamp */
1347 	eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp;
1348 	/** Adjust the device clock */
1349 	eth_timesync_adjust_time   timesync_adjust_time;
1350 	/** Get the device clock time */
1351 	eth_timesync_read_time     timesync_read_time;
1352 	/** Set the device clock time */
1353 	eth_timesync_write_time    timesync_write_time;
1354 
1355 	eth_read_clock             read_clock;
1356 
1357 	/** Get extended device statistic values by ID */
1358 	eth_xstats_get_by_id_t     xstats_get_by_id;
1359 	/** Get name of extended device statistics by ID */
1360 	eth_xstats_get_names_by_id_t xstats_get_names_by_id;
1361 
1362 	/** Get Traffic Management (TM) operations */
1363 	eth_tm_ops_get_t tm_ops_get;
1364 
1365 	/** Get Traffic Metering and Policing (MTR) operations */
1366 	eth_mtr_ops_get_t mtr_ops_get;
1367 
1368 	/** Test if a port supports specific mempool ops */
1369 	eth_pool_ops_supported_t pool_ops_supported;
1370 
1371 	/** Returns the hairpin capabilities */
1372 	eth_hairpin_cap_get_t hairpin_cap_get;
1373 	/** Set up device Rx hairpin queue */
1374 	eth_rx_hairpin_queue_setup_t rx_hairpin_queue_setup;
1375 	/** Set up device Tx hairpin queue */
1376 	eth_tx_hairpin_queue_setup_t tx_hairpin_queue_setup;
1377 
1378 	/** Get Forward Error Correction(FEC) capability */
1379 	eth_fec_get_capability_t fec_get_capability;
1380 	/** Get Forward Error Correction(FEC) mode */
1381 	eth_fec_get_t fec_get;
1382 	/** Set Forward Error Correction(FEC) mode */
1383 	eth_fec_set_t fec_set;
1384 
1385 	/** Get hairpin peer ports list */
1386 	hairpin_get_peer_ports_t hairpin_get_peer_ports;
1387 	/** Bind all hairpin Tx queues of device to the peer port Rx queues */
1388 	eth_hairpin_bind_t hairpin_bind;
1389 	/** Unbind all hairpin Tx queues from the peer port Rx queues */
1390 	eth_hairpin_unbind_t hairpin_unbind;
1391 	/** Pass the current queue info and get the peer queue info */
1392 	eth_hairpin_queue_peer_update_t hairpin_queue_peer_update;
1393 	/** Set up the connection between the pair of hairpin queues */
1394 	eth_hairpin_queue_peer_bind_t hairpin_queue_peer_bind;
1395 	/** Disconnect the hairpin queues of a pair from each other */
1396 	eth_hairpin_queue_peer_unbind_t hairpin_queue_peer_unbind;
1397 
1398 	/** Get power monitoring condition for Rx queue */
1399 	eth_get_monitor_addr_t get_monitor_addr;
1400 
1401 	/** Get representor info */
1402 	eth_representor_info_get_t representor_info_get;
1403 
1404 	/**
1405 	 * Negotiate the NIC's ability to deliver specific
1406 	 * kinds of metadata to the PMD
1407 	 */
1408 	eth_rx_metadata_negotiate_t rx_metadata_negotiate;
1409 
1410 	/** Get IP reassembly capability */
1411 	eth_ip_reassembly_capability_get_t ip_reassembly_capability_get;
1412 	/** Get IP reassembly configuration */
1413 	eth_ip_reassembly_conf_get_t ip_reassembly_conf_get;
1414 	/** Set IP reassembly configuration */
1415 	eth_ip_reassembly_conf_set_t ip_reassembly_conf_set;
1416 
1417 	/** Get supported header ptypes to split */
1418 	eth_buffer_split_supported_hdr_ptypes_get_t buffer_split_supported_hdr_ptypes_get;
1419 
1420 	/** Dump private info from device */
1421 	eth_dev_priv_dump_t eth_dev_priv_dump;
1422 
1423 	/** Set Rx queue available descriptors threshold */
1424 	eth_rx_queue_avail_thresh_set_t rx_queue_avail_thresh_set;
1425 	/** Query Rx queue available descriptors threshold event */
1426 	eth_rx_queue_avail_thresh_query_t rx_queue_avail_thresh_query;
1427 
1428 	/** Dump Rx descriptor info */
1429 	eth_rx_descriptor_dump_t eth_rx_descriptor_dump;
1430 	/** Dump Tx descriptor info */
1431 	eth_tx_descriptor_dump_t eth_tx_descriptor_dump;
1432 
1433 	/** Get congestion management information */
1434 	eth_cman_info_get_t cman_info_get;
1435 	/** Initialize congestion management structure with default values */
1436 	eth_cman_config_init_t cman_config_init;
1437 	/** Configure congestion management */
1438 	eth_cman_config_set_t cman_config_set;
1439 	/** Retrieve congestion management configuration */
1440 	eth_cman_config_get_t cman_config_get;
1441 
1442 	/** Get the number of aggregated ports */
1443 	eth_count_aggr_ports_t count_aggr_ports;
1444 	/** Map a Tx queue with an aggregated port of the DPDK port */
1445 	eth_map_aggr_tx_affinity_t map_aggr_tx_affinity;
1446 };
1447 
1448 /**
1449  * @internal
1450  * Check if the selected Rx queue is hairpin queue.
1451  *
1452  * @param dev
1453  *  Pointer to the selected device.
1454  * @param queue_id
1455  *  The selected queue.
1456  *
1457  * @return
1458  *   - (1) if the queue is hairpin queue, 0 otherwise.
1459  */
1460 __rte_internal
1461 int rte_eth_dev_is_rx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id);
1462 
1463 /**
1464  * @internal
1465  * Check if the selected Tx queue is hairpin queue.
1466  *
1467  * @param dev
1468  *  Pointer to the selected device.
1469  * @param queue_id
1470  *  The selected queue.
1471  *
1472  * @return
1473  *   - (1) if the queue is hairpin queue, 0 otherwise.
1474  */
1475 __rte_internal
1476 int rte_eth_dev_is_tx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id);
1477 
1478 /**
1479  * @internal
1480  * Returns a ethdev slot specified by the unique identifier name.
1481  *
1482  * @param	name
1483  *  The pointer to the Unique identifier name for each Ethernet device
1484  * @return
1485  *   - The pointer to the ethdev slot, on success. NULL on error
1486  */
1487 __rte_internal
1488 struct rte_eth_dev *rte_eth_dev_allocated(const char *name);
1489 
1490 /**
1491  * @internal
1492  * Allocates a new ethdev slot for an Ethernet device and returns the pointer
1493  * to that slot for the driver to use.
1494  *
1495  * @param	name	Unique identifier name for each Ethernet device
1496  * @return
1497  *   - Slot in the rte_dev_devices array for a new device;
1498  */
1499 __rte_internal
1500 struct rte_eth_dev *rte_eth_dev_allocate(const char *name);
1501 
1502 /**
1503  * @internal
1504  * Attach to the ethdev already initialized by the primary
1505  * process.
1506  *
1507  * @param       name    Ethernet device's name.
1508  * @return
1509  *   - Success: Slot in the rte_dev_devices array for attached
1510  *        device.
1511  *   - Error: Null pointer.
1512  */
1513 __rte_internal
1514 struct rte_eth_dev *rte_eth_dev_attach_secondary(const char *name);
1515 
1516 /**
1517  * @internal
1518  * Notify RTE_ETH_EVENT_DESTROY and release the specified ethdev port.
1519  *
1520  * The following PMD-managed data fields will be freed:
1521  *   - dev_private
1522  *   - mac_addrs
1523  *   - hash_mac_addrs
1524  * If one of these fields should not be freed,
1525  * it must be reset to NULL by the PMD, typically in dev_close method.
1526  *
1527  * @param eth_dev
1528  * Device to be detached.
1529  * @return
1530  *   - 0 on success, negative on error
1531  */
1532 __rte_internal
1533 int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev);
1534 
1535 /**
1536  * @internal
1537  * Release device queues and clear its configuration to force the user
1538  * application to reconfigure it. It is for internal use only.
1539  *
1540  * @param dev
1541  *  Pointer to struct rte_eth_dev.
1542  *
1543  * @return
1544  *  void
1545  */
1546 __rte_internal
1547 void rte_eth_dev_internal_reset(struct rte_eth_dev *dev);
1548 
1549 /**
1550  * @internal Executes all the user application registered callbacks for
1551  * the specific device. It is for DPDK internal user only. User
1552  * application should not call it directly.
1553  *
1554  * @param dev
1555  *  Pointer to struct rte_eth_dev.
1556  * @param event
1557  *  Eth device interrupt event type.
1558  * @param ret_param
1559  *  To pass data back to user application.
1560  *  This allows the user application to decide if a particular function
1561  *  is permitted or not.
1562  *
1563  * @return
1564  *  int
1565  */
1566 __rte_internal
1567 int rte_eth_dev_callback_process(struct rte_eth_dev *dev,
1568 		enum rte_eth_event_type event, void *ret_param);
1569 
1570 /**
1571  * @internal
1572  * This is the last step of device probing.
1573  * It must be called after a port is allocated and initialized successfully.
1574  *
1575  * The notification RTE_ETH_EVENT_NEW is sent to other entities
1576  * (libraries and applications).
1577  * The state is set as RTE_ETH_DEV_ATTACHED.
1578  *
1579  * @param dev
1580  *  New ethdev port.
1581  */
1582 __rte_internal
1583 void rte_eth_dev_probing_finish(struct rte_eth_dev *dev);
1584 
1585 /**
1586  * Create memzone for HW rings.
1587  * malloc can't be used as the physical address is needed.
1588  * If the memzone is already created, then this function returns a ptr
1589  * to the old one.
1590  *
1591  * @param eth_dev
1592  *   The *eth_dev* pointer is the address of the *rte_eth_dev* structure
1593  * @param name
1594  *   The name of the memory zone
1595  * @param queue_id
1596  *   The index of the queue to add to name
1597  * @param size
1598  *   The sizeof of the memory area
1599  * @param align
1600  *   Alignment for resulting memzone. Must be a power of 2.
1601  * @param socket_id
1602  *   The *socket_id* argument is the socket identifier in case of NUMA.
1603  */
1604 __rte_internal
1605 const struct rte_memzone *
1606 rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name,
1607 			 uint16_t queue_id, size_t size,
1608 			 unsigned align, int socket_id);
1609 
1610 /**
1611  * Free previously allocated memzone for HW rings.
1612  *
1613  * @param eth_dev
1614  *   The *eth_dev* pointer is the address of the *rte_eth_dev* structure
1615  * @param name
1616  *   The name of the memory zone
1617  * @param queue_id
1618  *   The index of the queue to add to name
1619  * @return
1620  *   Negative errno value on error, 0 on success.
1621  */
1622 __rte_internal
1623 int
1624 rte_eth_dma_zone_free(const struct rte_eth_dev *eth_dev, const char *name,
1625 		 uint16_t queue_id);
1626 
1627 /**
1628  * @internal
1629  * Atomically set the link status for the specific device.
1630  * It is for use by DPDK device driver use only.
1631  * User applications should not call it
1632  *
1633  * @param dev
1634  *  Pointer to struct rte_eth_dev.
1635  * @param link
1636  *  New link status value.
1637  * @return
1638  *  Same convention as eth_link_update operation.
1639  *  0   if link up status has changed
1640  *  -1  if link up status was unchanged
1641  */
1642 static inline int
1643 rte_eth_linkstatus_set(struct rte_eth_dev *dev,
1644 		       const struct rte_eth_link *new_link)
1645 {
1646 	uint64_t *dev_link = (uint64_t *)&(dev->data->dev_link);
1647 	union {
1648 		uint64_t val64;
1649 		struct rte_eth_link link;
1650 	} orig;
1651 
1652 	RTE_BUILD_BUG_ON(sizeof(*new_link) != sizeof(uint64_t));
1653 
1654 	orig.val64 = __atomic_exchange_n(dev_link, *(const uint64_t *)new_link,
1655 					__ATOMIC_SEQ_CST);
1656 
1657 	return (orig.link.link_status == new_link->link_status) ? -1 : 0;
1658 }
1659 
1660 /**
1661  * @internal
1662  * Atomically get the link speed and status.
1663  *
1664  * @param dev
1665  *  Pointer to struct rte_eth_dev.
1666  * @param link
1667  *  link status value.
1668  */
1669 static inline void
1670 rte_eth_linkstatus_get(const struct rte_eth_dev *dev,
1671 		       struct rte_eth_link *link)
1672 {
1673 	uint64_t *src = (uint64_t *)&(dev->data->dev_link);
1674 	uint64_t *dst = (uint64_t *)link;
1675 
1676 	RTE_BUILD_BUG_ON(sizeof(*link) != sizeof(uint64_t));
1677 
1678 	*dst = __atomic_load_n(src, __ATOMIC_SEQ_CST);
1679 }
1680 
1681 /**
1682  * @internal
1683  * Dummy DPDK callback for Rx/Tx packet burst.
1684  *
1685  * @param queue
1686  *  Pointer to Rx/Tx queue
1687  * @param pkts
1688  *  Packet array
1689  * @param nb_pkts
1690  *  Number of packets in packet array
1691  */
1692 __rte_internal
1693 uint16_t
1694 rte_eth_pkt_burst_dummy(void *queue __rte_unused,
1695 		struct rte_mbuf **pkts __rte_unused,
1696 		uint16_t nb_pkts __rte_unused);
1697 
1698 /**
1699  * Allocate an unique switch domain identifier.
1700  *
1701  * A pool of switch domain identifiers which can be allocated on request. This
1702  * will enabled devices which support the concept of switch domains to request
1703  * a switch domain ID which is guaranteed to be unique from other devices
1704  * running in the same process.
1705  *
1706  * @param domain_id
1707  *  switch domain identifier parameter to pass back to application
1708  *
1709  * @return
1710  *   Negative errno value on error, 0 on success.
1711  */
1712 __rte_internal
1713 int
1714 rte_eth_switch_domain_alloc(uint16_t *domain_id);
1715 
1716 /**
1717  * Free switch domain.
1718  *
1719  * Return a switch domain identifier to the pool of free identifiers after it is
1720  * no longer in use by device.
1721  *
1722  * @param domain_id
1723  *  switch domain identifier to free
1724  *
1725  * @return
1726  *   Negative errno value on error, 0 on success.
1727  */
1728 __rte_internal
1729 int
1730 rte_eth_switch_domain_free(uint16_t domain_id);
1731 
1732 /**
1733  * Generic Ethernet device arguments
1734  *
1735  * One type of representor each structure.
1736  */
1737 struct rte_eth_devargs {
1738 	uint16_t mh_controllers[RTE_MAX_MULTI_HOST_CTRLS];
1739 	/** controller/s number in case of multi-host */
1740 	uint16_t nb_mh_controllers;
1741 	/** number of controllers in multi-host controllers field */
1742 	uint16_t ports[RTE_MAX_ETHPORTS];
1743 	/** port/s number to enable on a multi-port single function */
1744 	uint16_t nb_ports;
1745 	/** number of ports in ports field */
1746 	uint16_t representor_ports[RTE_MAX_ETHPORTS];
1747 	/** representor port/s identifier to enable on device */
1748 	uint16_t nb_representor_ports;
1749 	/** number of ports in representor port field */
1750 	enum rte_eth_representor_type type; /* type of representor */
1751 };
1752 
1753 /**
1754  * PMD helper function to get representor ID from location detail.
1755  *
1756  * Get representor ID from controller, pf and (sf or vf).
1757  * The mapping is retrieved from rte_eth_representor_info_get().
1758  *
1759  * For backward compatibility, if no representor info, direct
1760  * map legacy VF (no controller and pf).
1761  *
1762  * @param port_id
1763  *  Port ID of the backing device.
1764  * @param type
1765  *  Representor type.
1766  * @param controller
1767  *  Controller ID, -1 if unspecified.
1768  * @param pf
1769  *  PF port ID, -1 if unspecified.
1770  * @param representor_port
1771  *  VF or SF representor port number, -1 if unspecified.
1772  * @param repr_id
1773  *  Pointer to output representor ID.
1774  *
1775  * @return
1776  *  Negative errno value on error, 0 on success.
1777  */
1778 __rte_internal
1779 int
1780 rte_eth_representor_id_get(uint16_t port_id,
1781 			   enum rte_eth_representor_type type,
1782 			   int controller, int pf, int representor_port,
1783 			   uint16_t *repr_id);
1784 
1785 /**
1786  * PMD helper function to parse ethdev arguments
1787  *
1788  * @param devargs
1789  *  device arguments
1790  * @param eth_devargs
1791  *  parsed ethdev specific arguments.
1792  *
1793  * @return
1794  *   Negative errno value on error, 0 on success.
1795  */
1796 __rte_internal
1797 int
1798 rte_eth_devargs_parse(const char *devargs, struct rte_eth_devargs *eth_devargs);
1799 
1800 
1801 typedef int (*ethdev_init_t)(struct rte_eth_dev *ethdev, void *init_params);
1802 typedef int (*ethdev_bus_specific_init)(struct rte_eth_dev *ethdev,
1803 	void *bus_specific_init_params);
1804 
1805 /**
1806  * PMD helper function for the creation of a new ethdev ports.
1807  *
1808  * @param device
1809  *  rte_device handle.
1810  * @param name
1811  *  port name.
1812  * @param priv_data_size
1813  *  size of private data required for port.
1814  * @param bus_specific_init
1815  *  port bus specific initialisation callback function
1816  * @param bus_init_params
1817  *  port bus specific initialisation parameters
1818  * @param ethdev_init
1819  *  device specific port initialization callback function
1820  * @param init_params
1821  *  port initialisation parameters
1822  *
1823  * @return
1824  *   Negative errno value on error, 0 on success.
1825  */
1826 __rte_internal
1827 int
1828 rte_eth_dev_create(struct rte_device *device, const char *name,
1829 	size_t priv_data_size,
1830 	ethdev_bus_specific_init bus_specific_init, void *bus_init_params,
1831 	ethdev_init_t ethdev_init, void *init_params);
1832 
1833 
1834 typedef int (*ethdev_uninit_t)(struct rte_eth_dev *ethdev);
1835 
1836 /**
1837  * PMD helper function for cleaning up the resources of a ethdev port on it's
1838  * destruction.
1839  *
1840  * @param ethdev
1841  *   ethdev handle of port.
1842  * @param ethdev_uninit
1843  *   device specific port un-initialise callback function
1844  *
1845  * @return
1846  *   Negative errno value on error, 0 on success.
1847  */
1848 __rte_internal
1849 int
1850 rte_eth_dev_destroy(struct rte_eth_dev *ethdev, ethdev_uninit_t ethdev_uninit);
1851 
1852 /**
1853  * @internal
1854  * Pass the current hairpin queue HW and/or SW information to the peer queue
1855  * and fetch back the information of the peer queue.
1856  *
1857  * @param peer_port
1858  *  Peer port identifier of the Ethernet device.
1859  * @param peer_queue
1860  *  Peer queue index of the port.
1861  * @param cur_info
1862  *  Pointer to the current information structure.
1863  * @param peer_info
1864  *  Pointer to the peer information, output.
1865  * @param direction
1866  *  Direction to pass the information.
1867  *  positive - pass Tx queue information and get peer Rx queue information
1868  *  zero - pass Rx queue information and get peer Tx queue information
1869  *
1870  * @return
1871  *  Negative errno value on error, 0 on success.
1872  */
1873 __rte_internal
1874 int
1875 rte_eth_hairpin_queue_peer_update(uint16_t peer_port, uint16_t peer_queue,
1876 				  struct rte_hairpin_peer_info *cur_info,
1877 				  struct rte_hairpin_peer_info *peer_info,
1878 				  uint32_t direction);
1879 
1880 /**
1881  * @internal
1882  * Configure current hairpin queue with the peer information fetched to create
1883  * the connection (bind) with peer queue in the specified direction.
1884  * This function might need to be called twice to fully create the connections.
1885  *
1886  * @param cur_port
1887  *  Current port identifier of the Ethernet device.
1888  * @param cur_queue
1889  *  Current queue index of the port.
1890  * @param peer_info
1891  *  Pointer to the peer information, input.
1892  * @param direction
1893  *  Direction to create the connection.
1894  *  positive - bind current Tx queue to peer Rx queue
1895  *  zero - bind current Rx queue to peer Tx queue
1896  *
1897  * @return
1898  *  Negative errno value on error, 0 on success.
1899  */
1900 __rte_internal
1901 int
1902 rte_eth_hairpin_queue_peer_bind(uint16_t cur_port, uint16_t cur_queue,
1903 				struct rte_hairpin_peer_info *peer_info,
1904 				uint32_t direction);
1905 
1906 /**
1907  * @internal
1908  * Get rte_eth_dev from device name. The device name should be specified
1909  * as below:
1910  * - PCIe address (Domain:Bus:Device.Function), for example 0000:2:00.0
1911  * - SoC device name, for example fsl-gmac0
1912  * - vdev dpdk name, for example net_[pcap0|null0|tap0]
1913  *
1914  * @param name
1915  *   PCI address or name of the device
1916  * @return
1917  *   - rte_eth_dev if successful
1918  *   - NULL on failure
1919  */
1920 __rte_internal
1921 struct rte_eth_dev*
1922 rte_eth_dev_get_by_name(const char *name);
1923 
1924 /**
1925  * @internal
1926  * Reset the current queue state and configuration to disconnect (unbind) it
1927  * from the peer queue.
1928  * This function might need to be called twice to disconnect each other.
1929  *
1930  * @param cur_port
1931  *  Current port identifier of the Ethernet device.
1932  * @param cur_queue
1933  *  Current queue index of the port.
1934  * @param direction
1935  *  Direction to destroy the connection.
1936  *  positive - unbind current Tx queue from peer Rx queue
1937  *  zero - unbind current Rx queue from peer Tx queue
1938  *
1939  * @return
1940  *  Negative errno value on error, 0 on success.
1941  */
1942 __rte_internal
1943 int
1944 rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t cur_queue,
1945 				  uint32_t direction);
1946 
1947 /**
1948  * @internal
1949  * Register mbuf dynamic field and flag for IP reassembly incomplete case.
1950  */
1951 __rte_internal
1952 int
1953 rte_eth_ip_reassembly_dynfield_register(int *field_offset, int *flag);
1954 
1955 
1956 /*
1957  * Legacy ethdev API used internally by drivers.
1958  */
1959 
1960 enum rte_filter_type {
1961 	RTE_ETH_FILTER_NONE = 0,
1962 	RTE_ETH_FILTER_ETHERTYPE,
1963 	RTE_ETH_FILTER_FLEXIBLE,
1964 	RTE_ETH_FILTER_SYN,
1965 	RTE_ETH_FILTER_NTUPLE,
1966 	RTE_ETH_FILTER_TUNNEL,
1967 	RTE_ETH_FILTER_FDIR,
1968 	RTE_ETH_FILTER_HASH,
1969 	RTE_ETH_FILTER_L2_TUNNEL,
1970 };
1971 
1972 /**
1973  * Define all structures for Ethertype Filter type.
1974  */
1975 
1976 #define RTE_ETHTYPE_FLAGS_MAC    0x0001 /**< If set, compare mac */
1977 #define RTE_ETHTYPE_FLAGS_DROP   0x0002 /**< If set, drop packet when match */
1978 
1979 /**
1980  * A structure used to define the ethertype filter entry
1981  * to support RTE_ETH_FILTER_ETHERTYPE data representation.
1982  */
1983 struct rte_eth_ethertype_filter {
1984 	struct rte_ether_addr mac_addr;   /**< Mac address to match */
1985 	uint16_t ether_type;          /**< Ether type to match */
1986 	uint16_t flags;               /**< Flags from RTE_ETHTYPE_FLAGS_* */
1987 	uint16_t queue;               /**< Queue assigned to when match */
1988 };
1989 
1990 /**
1991  * A structure used to define the TCP syn filter entry
1992  * to support RTE_ETH_FILTER_SYN data representation.
1993  */
1994 struct rte_eth_syn_filter {
1995 	/** 1 - higher priority than other filters, 0 - lower priority */
1996 	uint8_t hig_pri;
1997 	uint16_t queue;      /**< Queue assigned to when match */
1998 };
1999 
2000 /**
2001  * filter type of tunneling packet
2002  */
2003 #define RTE_ETH_TUNNEL_FILTER_OMAC  0x01 /**< filter by outer MAC addr */
2004 #define RTE_ETH_TUNNEL_FILTER_OIP   0x02 /**< filter by outer IP Addr */
2005 #define RTE_ETH_TUNNEL_FILTER_TENID 0x04 /**< filter by tenant ID */
2006 #define RTE_ETH_TUNNEL_FILTER_IMAC  0x08 /**< filter by inner MAC addr */
2007 #define RTE_ETH_TUNNEL_FILTER_IVLAN 0x10 /**< filter by inner VLAN ID */
2008 #define RTE_ETH_TUNNEL_FILTER_IIP   0x20 /**< filter by inner IP addr */
2009 
2010 #define RTE_ETH_TUNNEL_FILTER_IMAC_IVLAN (RTE_ETH_TUNNEL_FILTER_IMAC | \
2011 					  RTE_ETH_TUNNEL_FILTER_IVLAN)
2012 #define RTE_ETH_TUNNEL_FILTER_IMAC_IVLAN_TENID (RTE_ETH_TUNNEL_FILTER_IMAC | \
2013 						RTE_ETH_TUNNEL_FILTER_IVLAN | \
2014 						RTE_ETH_TUNNEL_FILTER_TENID)
2015 #define RTE_ETH_TUNNEL_FILTER_IMAC_TENID (RTE_ETH_TUNNEL_FILTER_IMAC | \
2016 					  RTE_ETH_TUNNEL_FILTER_TENID)
2017 #define RTE_ETH_TUNNEL_FILTER_OMAC_TENID_IMAC (RTE_ETH_TUNNEL_FILTER_OMAC | \
2018 					       RTE_ETH_TUNNEL_FILTER_TENID | \
2019 					       RTE_ETH_TUNNEL_FILTER_IMAC)
2020 
2021 /**
2022  *  Select IPv4 or IPv6 for tunnel filters.
2023  */
2024 enum rte_tunnel_iptype {
2025 	RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4 */
2026 	RTE_TUNNEL_IPTYPE_IPV6,     /**< IPv6 */
2027 };
2028 
2029 /**
2030  * Tunneling Packet filter configuration.
2031  */
2032 struct rte_eth_tunnel_filter_conf {
2033 	struct rte_ether_addr outer_mac;    /**< Outer MAC address to match */
2034 	struct rte_ether_addr inner_mac;    /**< Inner MAC address to match */
2035 	uint16_t inner_vlan;                /**< Inner VLAN to match */
2036 	enum rte_tunnel_iptype ip_type;     /**< IP address type */
2037 	/**
2038 	 * Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP
2039 	 * is set in filter_type, or inner destination IP address to match
2040 	 * if ETH_TUNNEL_FILTER_IIP is set in filter_type.
2041 	 */
2042 	union {
2043 		uint32_t ipv4_addr;         /**< IPv4 address in big endian */
2044 		uint32_t ipv6_addr[4];      /**< IPv6 address in big endian */
2045 	} ip_addr;
2046 	/** Flags from ETH_TUNNEL_FILTER_XX - see above */
2047 	uint16_t filter_type;
2048 	enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type */
2049 	uint32_t tenant_id;     /**< Tenant ID to match: VNI, GRE key... */
2050 	uint16_t queue_id;      /**< Queue assigned to if match */
2051 };
2052 
2053 /**
2054  *  Memory space that can be configured to store Flow Director filters
2055  *  in the board memory.
2056  */
2057 enum rte_eth_fdir_pballoc_type {
2058 	RTE_ETH_FDIR_PBALLOC_64K = 0,  /**< 64k. */
2059 	RTE_ETH_FDIR_PBALLOC_128K,     /**< 128k. */
2060 	RTE_ETH_FDIR_PBALLOC_256K,     /**< 256k. */
2061 };
2062 
2063 /**
2064  *  Select report mode of FDIR hash information in Rx descriptors.
2065  */
2066 enum rte_fdir_status_mode {
2067 	RTE_FDIR_NO_REPORT_STATUS = 0, /**< Never report FDIR hash. */
2068 	RTE_FDIR_REPORT_STATUS, /**< Only report FDIR hash for matching pkts. */
2069 	RTE_FDIR_REPORT_STATUS_ALWAYS, /**< Always report FDIR hash. */
2070 };
2071 
2072 /**
2073  * A structure used to configure the Flow Director (FDIR) feature
2074  * of an Ethernet port.
2075  *
2076  * If mode is RTE_FDIR_MODE_NONE, the pballoc value is ignored.
2077  */
2078 struct rte_eth_fdir_conf {
2079 	enum rte_fdir_mode mode; /**< Flow Director mode. */
2080 	enum rte_eth_fdir_pballoc_type pballoc; /**< Space for FDIR filters. */
2081 	enum rte_fdir_status_mode status;  /**< How to report FDIR hash. */
2082 	/** Rx queue of packets matching a "drop" filter in perfect mode. */
2083 	uint8_t drop_queue;
2084 	struct rte_eth_fdir_masks mask;
2085 	/** Flex payload configuration. */
2086 	struct rte_eth_fdir_flex_conf flex_conf;
2087 };
2088 
2089 #ifdef __cplusplus
2090 }
2091 #endif
2092 
2093 #endif /* _RTE_ETHDEV_DRIVER_H_ */
2094