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