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