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