xref: /dpdk/lib/ethdev/ethdev_driver.h (revision 4ff58b73)
199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
299a2dd95SBruce Richardson  * Copyright(c) 2017 Intel Corporation
399a2dd95SBruce Richardson  */
499a2dd95SBruce Richardson 
599a2dd95SBruce Richardson #ifndef _RTE_ETHDEV_DRIVER_H_
699a2dd95SBruce Richardson #define _RTE_ETHDEV_DRIVER_H_
799a2dd95SBruce Richardson 
8dbf9fc1dSBrian Dooley #ifdef __cplusplus
9dbf9fc1dSBrian Dooley extern "C" {
10dbf9fc1dSBrian Dooley #endif
11dbf9fc1dSBrian Dooley 
1299a2dd95SBruce Richardson /**
1399a2dd95SBruce Richardson  * @file
1499a2dd95SBruce Richardson  *
1599a2dd95SBruce Richardson  * RTE Ethernet Device PMD API
1699a2dd95SBruce Richardson  *
1799a2dd95SBruce Richardson  * These APIs for the use from Ethernet drivers, user applications shouldn't
1899a2dd95SBruce Richardson  * use them.
1999a2dd95SBruce Richardson  *
2099a2dd95SBruce Richardson  */
2199a2dd95SBruce Richardson 
2299a2dd95SBruce Richardson #include <rte_ethdev.h>
2399a2dd95SBruce Richardson 
24f9bdee26SKonstantin Ananyev /**
25f9bdee26SKonstantin Ananyev  * @internal
26f9bdee26SKonstantin Ananyev  * Structure used to hold information about the callbacks to be called for a
2709fd4227SAndrew Rybchenko  * queue on Rx and Tx.
28f9bdee26SKonstantin Ananyev  */
29f9bdee26SKonstantin Ananyev struct rte_eth_rxtx_callback {
30f9bdee26SKonstantin Ananyev 	struct rte_eth_rxtx_callback *next;
31f9bdee26SKonstantin Ananyev 	union{
32f9bdee26SKonstantin Ananyev 		rte_rx_callback_fn rx;
33f9bdee26SKonstantin Ananyev 		rte_tx_callback_fn tx;
34f9bdee26SKonstantin Ananyev 	} fn;
35f9bdee26SKonstantin Ananyev 	void *param;
36f9bdee26SKonstantin Ananyev };
37f9bdee26SKonstantin Ananyev 
38f9bdee26SKonstantin Ananyev /**
39f9bdee26SKonstantin Ananyev  * @internal
400d9f56a8SAndrew Rybchenko  * The generic data structure associated with each Ethernet device.
41f9bdee26SKonstantin Ananyev  *
42f9bdee26SKonstantin Ananyev  * Pointers to burst-oriented packet receive and transmit functions are
43f9bdee26SKonstantin Ananyev  * located at the beginning of the structure, along with the pointer to
44f9bdee26SKonstantin Ananyev  * where all the data elements for the particular device are stored in shared
45f9bdee26SKonstantin Ananyev  * memory. This split allows the function pointer and driver data to be per-
46f9bdee26SKonstantin Ananyev  * process, while the actual configuration data for the device is shared.
47f9bdee26SKonstantin Ananyev  */
48f9bdee26SKonstantin Ananyev struct rte_eth_dev {
4955645ee6SAndrew Rybchenko 	eth_rx_burst_t rx_pkt_burst; /**< Pointer to PMD receive function */
5055645ee6SAndrew Rybchenko 	eth_tx_burst_t tx_pkt_burst; /**< Pointer to PMD transmit function */
51cc0a6444SAndrew Rybchenko 
523c2ca0a9SAndrew Rybchenko 	/** Pointer to PMD transmit prepare function */
53f9bdee26SKonstantin Ananyev 	eth_tx_prep_t tx_pkt_prepare;
543c2ca0a9SAndrew Rybchenko 	/** Get the number of used Rx descriptors */
55f9bdee26SKonstantin Ananyev 	eth_rx_queue_count_t rx_queue_count;
563c2ca0a9SAndrew Rybchenko 	/** Check the status of a Rx descriptor */
57f9bdee26SKonstantin Ananyev 	eth_rx_descriptor_status_t rx_descriptor_status;
583c2ca0a9SAndrew Rybchenko 	/** Check the status of a Tx descriptor */
59f9bdee26SKonstantin Ananyev 	eth_tx_descriptor_status_t tx_descriptor_status;
60f9bdee26SKonstantin Ananyev 
61f9bdee26SKonstantin Ananyev 	/**
623c2ca0a9SAndrew Rybchenko 	 * Device data that is shared between primary and secondary processes
63f9bdee26SKonstantin Ananyev 	 */
64f9bdee26SKonstantin Ananyev 	struct rte_eth_dev_data *data;
6555645ee6SAndrew Rybchenko 	void *process_private; /**< Pointer to per-process device data */
66f9bdee26SKonstantin Ananyev 	const struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */
67f9bdee26SKonstantin Ananyev 	struct rte_device *device; /**< Backing device */
68f9bdee26SKonstantin Ananyev 	struct rte_intr_handle *intr_handle; /**< Device interrupt handle */
69cc0a6444SAndrew Rybchenko 
70f9bdee26SKonstantin Ananyev 	/** User application callbacks for NIC interrupts */
71f9bdee26SKonstantin Ananyev 	struct rte_eth_dev_cb_list link_intr_cbs;
72f9bdee26SKonstantin Ananyev 	/**
73f9bdee26SKonstantin Ananyev 	 * User-supplied functions called from rx_burst to post-process
74f9bdee26SKonstantin Ananyev 	 * received packets before passing them to the user
75f9bdee26SKonstantin Ananyev 	 */
76f9bdee26SKonstantin Ananyev 	struct rte_eth_rxtx_callback *post_rx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
77f9bdee26SKonstantin Ananyev 	/**
78f9bdee26SKonstantin Ananyev 	 * User-supplied functions called from tx_burst to pre-process
7955645ee6SAndrew Rybchenko 	 * received packets before passing them to the driver for transmission
80f9bdee26SKonstantin Ananyev 	 */
81f9bdee26SKonstantin Ananyev 	struct rte_eth_rxtx_callback *pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
82cc0a6444SAndrew Rybchenko 
83f9bdee26SKonstantin Ananyev 	enum rte_eth_dev_state state; /**< Flag indicating the port state */
84f9bdee26SKonstantin Ananyev 	void *security_ctx; /**< Context for security ops */
85f9bdee26SKonstantin Ananyev } __rte_cache_aligned;
86f9bdee26SKonstantin Ananyev 
87f9bdee26SKonstantin Ananyev struct rte_eth_dev_sriov;
88f9bdee26SKonstantin Ananyev struct rte_eth_dev_owner;
89f9bdee26SKonstantin Ananyev 
90f9bdee26SKonstantin Ananyev /**
91f9bdee26SKonstantin Ananyev  * @internal
920d9f56a8SAndrew Rybchenko  * The data part, with no function pointers, associated with each Ethernet
93f9bdee26SKonstantin Ananyev  * device. This structure is safe to place in shared memory to be common
94f9bdee26SKonstantin Ananyev  * among different processes in a multi-process configuration.
95f9bdee26SKonstantin Ananyev  */
96f9bdee26SKonstantin Ananyev struct rte_eth_dev_data {
97f9bdee26SKonstantin Ananyev 	char name[RTE_ETH_NAME_MAX_LEN]; /**< Unique identifier name */
98f9bdee26SKonstantin Ananyev 
9955645ee6SAndrew Rybchenko 	void **rx_queues; /**< Array of pointers to Rx queues */
10055645ee6SAndrew Rybchenko 	void **tx_queues; /**< Array of pointers to Tx queues */
10155645ee6SAndrew Rybchenko 	uint16_t nb_rx_queues; /**< Number of Rx queues */
10255645ee6SAndrew Rybchenko 	uint16_t nb_tx_queues; /**< Number of Tx queues */
103f9bdee26SKonstantin Ananyev 
104f9bdee26SKonstantin Ananyev 	struct rte_eth_dev_sriov sriov;    /**< SRIOV data */
105f9bdee26SKonstantin Ananyev 
1063c2ca0a9SAndrew Rybchenko 	/** PMD-specific private data. @see rte_eth_dev_release_port() */
107f9bdee26SKonstantin Ananyev 	void *dev_private;
108f9bdee26SKonstantin Ananyev 
10955645ee6SAndrew Rybchenko 	struct rte_eth_link dev_link;   /**< Link-level information & status */
11055645ee6SAndrew Rybchenko 	struct rte_eth_conf dev_conf;   /**< Configuration applied to device */
11155645ee6SAndrew Rybchenko 	uint16_t mtu;                   /**< Maximum Transmission Unit */
112cc0a6444SAndrew Rybchenko 
1133c2ca0a9SAndrew Rybchenko 	/** Common Rx buffer size handled by all queues */
114f9bdee26SKonstantin Ananyev 	uint32_t min_rx_buf_size;
115f9bdee26SKonstantin Ananyev 
11609fd4227SAndrew Rybchenko 	uint64_t rx_mbuf_alloc_failed; /**< Rx ring mbuf allocation failures */
117cc0a6444SAndrew Rybchenko 
1183c2ca0a9SAndrew Rybchenko 	/** Device Ethernet link address. @see rte_eth_dev_release_port() */
119f9bdee26SKonstantin Ananyev 	struct rte_ether_addr *mac_addrs;
1203c2ca0a9SAndrew Rybchenko 	/** Bitmap associating MAC addresses to pools */
121295968d1SFerruh Yigit 	uint64_t mac_pool_sel[RTE_ETH_NUM_RECEIVE_MAC_ADDR];
1223c2ca0a9SAndrew Rybchenko 	/**
1233c2ca0a9SAndrew Rybchenko 	 * Device Ethernet MAC addresses of hash filtering.
124f9bdee26SKonstantin Ananyev 	 * @see rte_eth_dev_release_port()
125f9bdee26SKonstantin Ananyev 	 */
1263c2ca0a9SAndrew Rybchenko 	struct rte_ether_addr *hash_mac_addrs;
127cc0a6444SAndrew Rybchenko 
12855645ee6SAndrew Rybchenko 	uint16_t port_id;           /**< Device [external] port identifier */
129f9bdee26SKonstantin Ananyev 
130f9bdee26SKonstantin Ananyev 	__extension__
1313c2ca0a9SAndrew Rybchenko 	uint8_t /** Rx promiscuous mode ON(1) / OFF(0) */
1323c2ca0a9SAndrew Rybchenko 		promiscuous   : 1,
1333c2ca0a9SAndrew Rybchenko 		/** Rx of scattered packets is ON(1) / OFF(0) */
134f9bdee26SKonstantin Ananyev 		scattered_rx : 1,
1353c2ca0a9SAndrew Rybchenko 		/** Rx all multicast mode ON(1) / OFF(0) */
136f9bdee26SKonstantin Ananyev 		all_multicast : 1,
1373c2ca0a9SAndrew Rybchenko 		/** Device state: STARTED(1) / STOPPED(0) */
138f9bdee26SKonstantin Ananyev 		dev_started : 1,
1393c2ca0a9SAndrew Rybchenko 		/** Rx LRO is ON(1) / OFF(0) */
140f9bdee26SKonstantin Ananyev 		lro         : 1,
1413c2ca0a9SAndrew Rybchenko 		/**
1423c2ca0a9SAndrew Rybchenko 		 * Indicates whether the device is configured:
1433c2ca0a9SAndrew Rybchenko 		 * CONFIGURED(1) / NOT CONFIGURED(0)
144f9bdee26SKonstantin Ananyev 		 */
145*4ff58b73SAlexander Kozyrev 		dev_configured : 1,
146*4ff58b73SAlexander Kozyrev 		/**
147*4ff58b73SAlexander Kozyrev 		 * Indicates whether the flow engine is configured:
148*4ff58b73SAlexander Kozyrev 		 * CONFIGURED(1) / NOT CONFIGURED(0)
149*4ff58b73SAlexander Kozyrev 		 */
150*4ff58b73SAlexander Kozyrev 		flow_configured : 1;
151cc0a6444SAndrew Rybchenko 
1523c2ca0a9SAndrew Rybchenko 	/** Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0) */
153f9bdee26SKonstantin Ananyev 	uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
1543c2ca0a9SAndrew Rybchenko 	/** Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0) */
155f9bdee26SKonstantin Ananyev 	uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
156cc0a6444SAndrew Rybchenko 
15755645ee6SAndrew Rybchenko 	uint32_t dev_flags;             /**< Capabilities */
15855645ee6SAndrew Rybchenko 	int numa_node;                  /**< NUMA node connection */
159cc0a6444SAndrew Rybchenko 
1603c2ca0a9SAndrew Rybchenko 	/** VLAN filter configuration */
161f9bdee26SKonstantin Ananyev 	struct rte_vlan_filter_conf vlan_filter_conf;
162cc0a6444SAndrew Rybchenko 
16355645ee6SAndrew Rybchenko 	struct rte_eth_dev_owner owner; /**< The port owner */
164cc0a6444SAndrew Rybchenko 
1653c2ca0a9SAndrew Rybchenko 	/**
1663c2ca0a9SAndrew Rybchenko 	 * Switch-specific identifier.
167f9bdee26SKonstantin Ananyev 	 * Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags.
168f9bdee26SKonstantin Ananyev 	 */
1693c2ca0a9SAndrew Rybchenko 	uint16_t representor_id;
1703c2ca0a9SAndrew Rybchenko 	/**
1713c2ca0a9SAndrew Rybchenko 	 * Port ID of the backing device.
1723c2ca0a9SAndrew Rybchenko 	 * This device will be used to query representor info and calculate
1733c2ca0a9SAndrew Rybchenko 	 * representor IDs. Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags.
1743c2ca0a9SAndrew Rybchenko 	 */
175f9bdee26SKonstantin Ananyev 	uint16_t backer_port_id;
176f9bdee26SKonstantin Ananyev 
17755645ee6SAndrew Rybchenko 	pthread_mutex_t flow_ops_mutex; /**< rte_flow ops mutex */
178f9bdee26SKonstantin Ananyev } __rte_cache_aligned;
179f9bdee26SKonstantin Ananyev 
180f9bdee26SKonstantin Ananyev /**
181f9bdee26SKonstantin Ananyev  * @internal
182f9bdee26SKonstantin Ananyev  * The pool of *rte_eth_dev* structures. The size of the pool
183f9bdee26SKonstantin Ananyev  * is configured at compile-time in the <rte_ethdev.c> file.
184f9bdee26SKonstantin Ananyev  */
185f9bdee26SKonstantin Ananyev extern struct rte_eth_dev rte_eth_devices[];
186f9bdee26SKonstantin Ananyev 
1873c2ca0a9SAndrew Rybchenko /** @internal Declaration of the hairpin peer queue information structure. */
18899a2dd95SBruce Richardson struct rte_hairpin_peer_info;
18999a2dd95SBruce Richardson 
19099a2dd95SBruce Richardson /*
19199a2dd95SBruce Richardson  * Definitions of all functions exported by an Ethernet driver through the
19299a2dd95SBruce Richardson  * generic structure of type *eth_dev_ops* supplied in the *rte_eth_dev*
19399a2dd95SBruce Richardson  * structure associated with an Ethernet device.
19499a2dd95SBruce Richardson  */
19599a2dd95SBruce Richardson 
1963c2ca0a9SAndrew Rybchenko /** @internal Ethernet device configuration. */
19799a2dd95SBruce Richardson typedef int  (*eth_dev_configure_t)(struct rte_eth_dev *dev);
19899a2dd95SBruce Richardson 
1993c2ca0a9SAndrew Rybchenko /** @internal Function used to start a configured Ethernet device. */
20099a2dd95SBruce Richardson typedef int  (*eth_dev_start_t)(struct rte_eth_dev *dev);
20199a2dd95SBruce Richardson 
2023c2ca0a9SAndrew Rybchenko /** @internal Function used to stop a configured Ethernet device. */
20399a2dd95SBruce Richardson typedef int (*eth_dev_stop_t)(struct rte_eth_dev *dev);
20499a2dd95SBruce Richardson 
2053c2ca0a9SAndrew Rybchenko /** @internal Function used to link up a configured Ethernet device. */
20699a2dd95SBruce Richardson typedef int  (*eth_dev_set_link_up_t)(struct rte_eth_dev *dev);
20799a2dd95SBruce Richardson 
2083c2ca0a9SAndrew Rybchenko /** @internal Function used to link down a configured Ethernet device. */
20999a2dd95SBruce Richardson typedef int  (*eth_dev_set_link_down_t)(struct rte_eth_dev *dev);
21099a2dd95SBruce Richardson 
2113c2ca0a9SAndrew Rybchenko /** @internal Function used to close a configured Ethernet device. */
21299a2dd95SBruce Richardson typedef int (*eth_dev_close_t)(struct rte_eth_dev *dev);
21399a2dd95SBruce Richardson 
2143c2ca0a9SAndrew Rybchenko /** @internal Function used to reset a configured Ethernet device. */
21599a2dd95SBruce Richardson typedef int (*eth_dev_reset_t)(struct rte_eth_dev *dev);
21699a2dd95SBruce Richardson 
2173c2ca0a9SAndrew Rybchenko /** @internal Function used to detect an Ethernet device removal. */
21899a2dd95SBruce Richardson typedef int (*eth_is_removed_t)(struct rte_eth_dev *dev);
21999a2dd95SBruce Richardson 
22099a2dd95SBruce Richardson /**
22199a2dd95SBruce Richardson  * @internal
22299a2dd95SBruce Richardson  * Function used to enable the Rx promiscuous mode of an Ethernet device.
22399a2dd95SBruce Richardson  *
22499a2dd95SBruce Richardson  * @param dev
22599a2dd95SBruce Richardson  *   ethdev handle of port.
22699a2dd95SBruce Richardson  *
22799a2dd95SBruce Richardson  * @return
22899a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
22999a2dd95SBruce Richardson  *
23099a2dd95SBruce Richardson  * @retval 0
23199a2dd95SBruce Richardson  *   Success, promiscuous mode is enabled.
23299a2dd95SBruce Richardson  * @retval -ENOTSUP
23399a2dd95SBruce Richardson  *   Promiscuous mode is not supported.
23499a2dd95SBruce Richardson  * @retval -ENODEV
23599a2dd95SBruce Richardson  *   Device is gone.
23699a2dd95SBruce Richardson  * @retval -E_RTE_SECONDARY
23799a2dd95SBruce Richardson  *   Function was called from a secondary process instance and not supported.
23899a2dd95SBruce Richardson  * @retval -ETIMEDOUT
23951395027SFerruh Yigit  *   Attempt to enable promiscuous mode failed because of timeout.
24099a2dd95SBruce Richardson  * @retval -EAGAIN
24199a2dd95SBruce Richardson  *   Failed to enable promiscuous mode.
24299a2dd95SBruce Richardson  */
24399a2dd95SBruce Richardson typedef int (*eth_promiscuous_enable_t)(struct rte_eth_dev *dev);
24499a2dd95SBruce Richardson 
24599a2dd95SBruce Richardson /**
24699a2dd95SBruce Richardson  * @internal
24799a2dd95SBruce Richardson  * Function used to disable the Rx promiscuous mode of an Ethernet device.
24899a2dd95SBruce Richardson  *
24999a2dd95SBruce Richardson  * @param dev
25099a2dd95SBruce Richardson  *   ethdev handle of port.
25199a2dd95SBruce Richardson  *
25299a2dd95SBruce Richardson  * @return
25399a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
25499a2dd95SBruce Richardson  *
25599a2dd95SBruce Richardson  * @retval 0
25699a2dd95SBruce Richardson  *   Success, promiscuous mode is disabled.
25799a2dd95SBruce Richardson  * @retval -ENOTSUP
25899a2dd95SBruce Richardson  *   Promiscuous mode disabling is not supported.
25999a2dd95SBruce Richardson  * @retval -ENODEV
26099a2dd95SBruce Richardson  *   Device is gone.
26199a2dd95SBruce Richardson  * @retval -E_RTE_SECONDARY
26299a2dd95SBruce Richardson  *   Function was called from a secondary process instance and not supported.
26399a2dd95SBruce Richardson  * @retval -ETIMEDOUT
26451395027SFerruh Yigit  *   Attempt to disable promiscuous mode failed because of timeout.
26599a2dd95SBruce Richardson  * @retval -EAGAIN
26699a2dd95SBruce Richardson  *   Failed to disable promiscuous mode.
26799a2dd95SBruce Richardson  */
26899a2dd95SBruce Richardson typedef int (*eth_promiscuous_disable_t)(struct rte_eth_dev *dev);
26999a2dd95SBruce Richardson 
27099a2dd95SBruce Richardson /**
27199a2dd95SBruce Richardson  * @internal
27299a2dd95SBruce Richardson  * Enable the receipt of all multicast packets by an Ethernet device.
27399a2dd95SBruce Richardson  *
27499a2dd95SBruce Richardson  * @param dev
27599a2dd95SBruce Richardson  *   ethdev handle of port.
27699a2dd95SBruce Richardson  *
27799a2dd95SBruce Richardson  * @return
27899a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
27999a2dd95SBruce Richardson  *
28099a2dd95SBruce Richardson  * @retval 0
28199a2dd95SBruce Richardson  *   Success, all-multicast mode is enabled.
28299a2dd95SBruce Richardson  * @retval -ENOTSUP
28399a2dd95SBruce Richardson  *   All-multicast mode is not supported.
28499a2dd95SBruce Richardson  * @retval -ENODEV
28599a2dd95SBruce Richardson  *   Device is gone.
28699a2dd95SBruce Richardson  * @retval -E_RTE_SECONDARY
28799a2dd95SBruce Richardson  *   Function was called from a secondary process instance and not supported.
28899a2dd95SBruce Richardson  * @retval -ETIMEDOUT
28999a2dd95SBruce Richardson  *   Attempt to enable all-multicast mode failed because of timeout.
29099a2dd95SBruce Richardson  * @retval -EAGAIN
29199a2dd95SBruce Richardson  *   Failed to enable all-multicast mode.
29299a2dd95SBruce Richardson  */
29399a2dd95SBruce Richardson typedef int (*eth_allmulticast_enable_t)(struct rte_eth_dev *dev);
29499a2dd95SBruce Richardson 
29599a2dd95SBruce Richardson /**
29699a2dd95SBruce Richardson  * @internal
29799a2dd95SBruce Richardson  * Disable the receipt of all multicast packets by an Ethernet device.
29899a2dd95SBruce Richardson  *
29999a2dd95SBruce Richardson  * @param dev
30099a2dd95SBruce Richardson  *   ethdev handle of port.
30199a2dd95SBruce Richardson  *
30299a2dd95SBruce Richardson  * @return
30399a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
30499a2dd95SBruce Richardson  *
30599a2dd95SBruce Richardson  * @retval 0
30699a2dd95SBruce Richardson  *   Success, all-multicast mode is disabled.
30799a2dd95SBruce Richardson  * @retval -ENOTSUP
30899a2dd95SBruce Richardson  *   All-multicast mode disabling is not supported.
30999a2dd95SBruce Richardson  * @retval -ENODEV
31099a2dd95SBruce Richardson  *   Device is gone.
31199a2dd95SBruce Richardson  * @retval -E_RTE_SECONDARY
31299a2dd95SBruce Richardson  *   Function was called from a secondary process instance and not supported.
31399a2dd95SBruce Richardson  * @retval -ETIMEDOUT
31499a2dd95SBruce Richardson  *   Attempt to disable all-multicast mode failed because of timeout.
31599a2dd95SBruce Richardson  * @retval -EAGAIN
31699a2dd95SBruce Richardson  *   Failed to disable all-multicast mode.
31799a2dd95SBruce Richardson  */
31899a2dd95SBruce Richardson typedef int (*eth_allmulticast_disable_t)(struct rte_eth_dev *dev);
31999a2dd95SBruce Richardson 
3203c2ca0a9SAndrew Rybchenko /**
3213c2ca0a9SAndrew Rybchenko  * @internal
3223c2ca0a9SAndrew Rybchenko  * Get link speed, duplex mode and state (up/down) of an Ethernet device.
3233c2ca0a9SAndrew Rybchenko  */
32499a2dd95SBruce Richardson typedef int (*eth_link_update_t)(struct rte_eth_dev *dev,
32599a2dd95SBruce Richardson 				int wait_to_complete);
32699a2dd95SBruce Richardson 
3273c2ca0a9SAndrew Rybchenko /** @internal Get global I/O statistics of an Ethernet device. */
32899a2dd95SBruce Richardson typedef int (*eth_stats_get_t)(struct rte_eth_dev *dev,
32999a2dd95SBruce Richardson 				struct rte_eth_stats *igb_stats);
33099a2dd95SBruce Richardson 
33199a2dd95SBruce Richardson /**
33299a2dd95SBruce Richardson  * @internal
33399a2dd95SBruce Richardson  * Reset global I/O statistics of an Ethernet device to 0.
33499a2dd95SBruce Richardson  *
33599a2dd95SBruce Richardson  * @param dev
33699a2dd95SBruce Richardson  *   ethdev handle of port.
33799a2dd95SBruce Richardson  *
33899a2dd95SBruce Richardson  * @return
33999a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
34099a2dd95SBruce Richardson  *
34199a2dd95SBruce Richardson  * @retval 0
34299a2dd95SBruce Richardson  *   Success, statistics has been reset.
34399a2dd95SBruce Richardson  * @retval -ENOTSUP
34499a2dd95SBruce Richardson  *   Resetting statistics is not supported.
34599a2dd95SBruce Richardson  * @retval -EINVAL
34699a2dd95SBruce Richardson  *   Resetting statistics is not valid.
34799a2dd95SBruce Richardson  * @retval -ENOMEM
34899a2dd95SBruce Richardson  *   Not enough memory to get the stats.
34999a2dd95SBruce Richardson  */
35099a2dd95SBruce Richardson typedef int (*eth_stats_reset_t)(struct rte_eth_dev *dev);
35199a2dd95SBruce Richardson 
3523c2ca0a9SAndrew Rybchenko /** @internal Get extended stats of an Ethernet device. */
35399a2dd95SBruce Richardson typedef int (*eth_xstats_get_t)(struct rte_eth_dev *dev,
35499a2dd95SBruce Richardson 	struct rte_eth_xstat *stats, unsigned int n);
35599a2dd95SBruce Richardson 
35671b5e430SIvan Ilchenko /**
35771b5e430SIvan Ilchenko  * @internal
35871b5e430SIvan Ilchenko  * Get extended stats of an Ethernet device.
35971b5e430SIvan Ilchenko  *
36071b5e430SIvan Ilchenko  * @param dev
36171b5e430SIvan Ilchenko  *   ethdev handle of port.
36271b5e430SIvan Ilchenko  * @param ids
36371b5e430SIvan Ilchenko  *   IDs array to retrieve specific statistics. Must not be NULL.
36471b5e430SIvan Ilchenko  * @param values
36571b5e430SIvan Ilchenko  *   A pointer to a table to be filled with device statistics values.
36671b5e430SIvan Ilchenko  *   Must not be NULL.
36771b5e430SIvan Ilchenko  * @param n
36871b5e430SIvan Ilchenko  *   Element count in @p ids and @p values.
36971b5e430SIvan Ilchenko  *
37071b5e430SIvan Ilchenko  * @return
37171b5e430SIvan Ilchenko  *   - A number of filled in stats.
37271b5e430SIvan Ilchenko  *   - A negative value on error.
37371b5e430SIvan Ilchenko  */
37499a2dd95SBruce Richardson typedef int (*eth_xstats_get_by_id_t)(struct rte_eth_dev *dev,
37599a2dd95SBruce Richardson 				      const uint64_t *ids,
37699a2dd95SBruce Richardson 				      uint64_t *values,
37799a2dd95SBruce Richardson 				      unsigned int n);
37899a2dd95SBruce Richardson 
37999a2dd95SBruce Richardson /**
38099a2dd95SBruce Richardson  * @internal
38199a2dd95SBruce Richardson  * Reset extended stats of an Ethernet device.
38299a2dd95SBruce Richardson  *
38399a2dd95SBruce Richardson  * @param dev
38499a2dd95SBruce Richardson  *   ethdev handle of port.
38599a2dd95SBruce Richardson  *
38699a2dd95SBruce Richardson  * @return
38799a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
38899a2dd95SBruce Richardson  *
38999a2dd95SBruce Richardson  * @retval 0
39099a2dd95SBruce Richardson  *   Success, statistics has been reset.
39199a2dd95SBruce Richardson  * @retval -ENOTSUP
39299a2dd95SBruce Richardson  *   Resetting statistics is not supported.
39399a2dd95SBruce Richardson  * @retval -EINVAL
39499a2dd95SBruce Richardson  *   Resetting statistics is not valid.
39599a2dd95SBruce Richardson  * @retval -ENOMEM
39699a2dd95SBruce Richardson  *   Not enough memory to get the stats.
39799a2dd95SBruce Richardson  */
39899a2dd95SBruce Richardson typedef int (*eth_xstats_reset_t)(struct rte_eth_dev *dev);
39999a2dd95SBruce Richardson 
4003c2ca0a9SAndrew Rybchenko /** @internal Get names of extended stats of an Ethernet device. */
40199a2dd95SBruce Richardson typedef int (*eth_xstats_get_names_t)(struct rte_eth_dev *dev,
40299a2dd95SBruce Richardson 	struct rte_eth_xstat_name *xstats_names, unsigned int size);
40399a2dd95SBruce Richardson 
40471b5e430SIvan Ilchenko /**
40571b5e430SIvan Ilchenko  * @internal
40671b5e430SIvan Ilchenko  * Get names of extended stats of an Ethernet device.
40771b5e430SIvan Ilchenko  *
40871b5e430SIvan Ilchenko  * @param dev
40971b5e430SIvan Ilchenko  *   ethdev handle of port.
4108c9f976fSAndrew Rybchenko  * @param ids
4118c9f976fSAndrew Rybchenko  *   IDs array to retrieve specific statistics. Must not be NULL.
41271b5e430SIvan Ilchenko  * @param xstats_names
41371b5e430SIvan Ilchenko  *   An rte_eth_xstat_name array of at least @p size elements to be filled.
41471b5e430SIvan Ilchenko  *   Must not be NULL.
41571b5e430SIvan Ilchenko  * @param size
41671b5e430SIvan Ilchenko  *   Element count in @p ids and @p xstats_names.
41771b5e430SIvan Ilchenko  *
41871b5e430SIvan Ilchenko  * @return
41971b5e430SIvan Ilchenko  *   - A number of filled in stats.
42071b5e430SIvan Ilchenko  *   - A negative value on error.
42171b5e430SIvan Ilchenko  */
42299a2dd95SBruce Richardson typedef int (*eth_xstats_get_names_by_id_t)(struct rte_eth_dev *dev,
4238c9f976fSAndrew Rybchenko 	const uint64_t *ids, struct rte_eth_xstat_name *xstats_names,
42499a2dd95SBruce Richardson 	unsigned int size);
42599a2dd95SBruce Richardson 
4263c2ca0a9SAndrew Rybchenko /**
4273c2ca0a9SAndrew Rybchenko  * @internal
4283c2ca0a9SAndrew Rybchenko  * Set a queue statistics mapping for a Tx/Rx queue of an Ethernet device.
4293c2ca0a9SAndrew Rybchenko  */
43099a2dd95SBruce Richardson typedef int (*eth_queue_stats_mapping_set_t)(struct rte_eth_dev *dev,
43199a2dd95SBruce Richardson 					     uint16_t queue_id,
43299a2dd95SBruce Richardson 					     uint8_t stat_idx,
43399a2dd95SBruce Richardson 					     uint8_t is_rx);
43499a2dd95SBruce Richardson 
4353c2ca0a9SAndrew Rybchenko /** @internal Get specific information of an Ethernet device. */
43699a2dd95SBruce Richardson typedef int (*eth_dev_infos_get_t)(struct rte_eth_dev *dev,
43799a2dd95SBruce Richardson 				   struct rte_eth_dev_info *dev_info);
43899a2dd95SBruce Richardson 
4393c2ca0a9SAndrew Rybchenko /** @internal Get supported ptypes of an Ethernet device. */
44099a2dd95SBruce Richardson typedef const uint32_t *(*eth_dev_supported_ptypes_get_t)(struct rte_eth_dev *dev);
44199a2dd95SBruce Richardson 
44299a2dd95SBruce Richardson /**
44399a2dd95SBruce Richardson  * @internal
44499a2dd95SBruce Richardson  * Inform Ethernet device about reduced range of packet types to handle.
44599a2dd95SBruce Richardson  *
44699a2dd95SBruce Richardson  * @param dev
44799a2dd95SBruce Richardson  *   The Ethernet device identifier.
44899a2dd95SBruce Richardson  * @param ptype_mask
44999a2dd95SBruce Richardson  *   The ptype family that application is interested in should be bitwise OR of
45099a2dd95SBruce Richardson  *   RTE_PTYPE_*_MASK or 0.
45199a2dd95SBruce Richardson  * @return
45299a2dd95SBruce Richardson  *   - (0) if Success.
45399a2dd95SBruce Richardson  */
45499a2dd95SBruce Richardson typedef int (*eth_dev_ptypes_set_t)(struct rte_eth_dev *dev,
45599a2dd95SBruce Richardson 				     uint32_t ptype_mask);
45699a2dd95SBruce Richardson 
4573c2ca0a9SAndrew Rybchenko /** @internal Start Rx and Tx of a queue of an Ethernet device. */
45899a2dd95SBruce Richardson typedef int (*eth_queue_start_t)(struct rte_eth_dev *dev,
45999a2dd95SBruce Richardson 				    uint16_t queue_id);
46099a2dd95SBruce Richardson 
4613c2ca0a9SAndrew Rybchenko /** @internal Stop Rx and Tx of a queue of an Ethernet device. */
46299a2dd95SBruce Richardson typedef int (*eth_queue_stop_t)(struct rte_eth_dev *dev,
46399a2dd95SBruce Richardson 				    uint16_t queue_id);
46499a2dd95SBruce Richardson 
4653c2ca0a9SAndrew Rybchenko /** @internal Set up a receive queue of an Ethernet device. */
46699a2dd95SBruce Richardson typedef int (*eth_rx_queue_setup_t)(struct rte_eth_dev *dev,
46799a2dd95SBruce Richardson 				    uint16_t rx_queue_id,
46899a2dd95SBruce Richardson 				    uint16_t nb_rx_desc,
46999a2dd95SBruce Richardson 				    unsigned int socket_id,
47099a2dd95SBruce Richardson 				    const struct rte_eth_rxconf *rx_conf,
47199a2dd95SBruce Richardson 				    struct rte_mempool *mb_pool);
47299a2dd95SBruce Richardson 
4733c2ca0a9SAndrew Rybchenko /** @internal Setup a transmit queue of an Ethernet device. */
47499a2dd95SBruce Richardson typedef int (*eth_tx_queue_setup_t)(struct rte_eth_dev *dev,
47599a2dd95SBruce Richardson 				    uint16_t tx_queue_id,
47699a2dd95SBruce Richardson 				    uint16_t nb_tx_desc,
47799a2dd95SBruce Richardson 				    unsigned int socket_id,
47899a2dd95SBruce Richardson 				    const struct rte_eth_txconf *tx_conf);
47999a2dd95SBruce Richardson 
4803c2ca0a9SAndrew Rybchenko /** @internal Enable interrupt of a receive queue of an Ethernet device. */
48199a2dd95SBruce Richardson typedef int (*eth_rx_enable_intr_t)(struct rte_eth_dev *dev,
48299a2dd95SBruce Richardson 				    uint16_t rx_queue_id);
48399a2dd95SBruce Richardson 
4843c2ca0a9SAndrew Rybchenko /** @internal Disable interrupt of a receive queue of an Ethernet device. */
48599a2dd95SBruce Richardson typedef int (*eth_rx_disable_intr_t)(struct rte_eth_dev *dev,
48699a2dd95SBruce Richardson 				    uint16_t rx_queue_id);
48799a2dd95SBruce Richardson 
4883c2ca0a9SAndrew Rybchenko /** @internal Release memory resources allocated by given Rx/Tx queue. */
4897483341aSXueming Li typedef void (*eth_queue_release_t)(struct rte_eth_dev *dev,
4907483341aSXueming Li 				    uint16_t queue_id);
49199a2dd95SBruce Richardson 
4923c2ca0a9SAndrew Rybchenko /** @internal Get firmware information of an Ethernet device. */
49399a2dd95SBruce Richardson typedef int (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
49499a2dd95SBruce Richardson 				     char *fw_version, size_t fw_size);
49599a2dd95SBruce Richardson 
4963c2ca0a9SAndrew Rybchenko /** @internal Force mbufs to be from Tx ring. */
49799a2dd95SBruce Richardson typedef int (*eth_tx_done_cleanup_t)(void *txq, uint32_t free_cnt);
49899a2dd95SBruce Richardson 
49999a2dd95SBruce Richardson typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
50099a2dd95SBruce Richardson 	uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
50199a2dd95SBruce Richardson 
50299a2dd95SBruce Richardson typedef void (*eth_txq_info_get_t)(struct rte_eth_dev *dev,
50399a2dd95SBruce Richardson 	uint16_t tx_queue_id, struct rte_eth_txq_info *qinfo);
50499a2dd95SBruce Richardson 
50599a2dd95SBruce Richardson typedef int (*eth_burst_mode_get_t)(struct rte_eth_dev *dev,
50699a2dd95SBruce Richardson 	uint16_t queue_id, struct rte_eth_burst_mode *mode);
50799a2dd95SBruce Richardson 
5083c2ca0a9SAndrew Rybchenko /** @internal Set MTU. */
50999a2dd95SBruce Richardson typedef int (*mtu_set_t)(struct rte_eth_dev *dev, uint16_t mtu);
51099a2dd95SBruce Richardson 
5113c2ca0a9SAndrew Rybchenko /** @internal Filtering of a VLAN Tag Identifier by an Ethernet device. */
51299a2dd95SBruce Richardson typedef int (*vlan_filter_set_t)(struct rte_eth_dev *dev,
51399a2dd95SBruce Richardson 				  uint16_t vlan_id,
51499a2dd95SBruce Richardson 				  int on);
51599a2dd95SBruce Richardson 
5163c2ca0a9SAndrew Rybchenko /** @internal Set the outer/inner VLAN-TPID by an Ethernet device. */
51799a2dd95SBruce Richardson typedef int (*vlan_tpid_set_t)(struct rte_eth_dev *dev,
51899a2dd95SBruce Richardson 			       enum rte_vlan_type type, uint16_t tpid);
51999a2dd95SBruce Richardson 
5203c2ca0a9SAndrew Rybchenko /** @internal Set VLAN offload function by an Ethernet device. */
52199a2dd95SBruce Richardson typedef int (*vlan_offload_set_t)(struct rte_eth_dev *dev, int mask);
52299a2dd95SBruce Richardson 
5233c2ca0a9SAndrew Rybchenko /** @internal Set port based Tx VLAN insertion by an Ethernet device. */
52499a2dd95SBruce Richardson typedef int (*vlan_pvid_set_t)(struct rte_eth_dev *dev,
52599a2dd95SBruce Richardson 			       uint16_t vlan_id,
52699a2dd95SBruce Richardson 			       int on);
52799a2dd95SBruce Richardson 
5283c2ca0a9SAndrew Rybchenko /** @internal VLAN stripping enable/disable by an queue of Ethernet device. */
52999a2dd95SBruce Richardson typedef void (*vlan_strip_queue_set_t)(struct rte_eth_dev *dev,
53099a2dd95SBruce Richardson 				  uint16_t rx_queue_id,
53199a2dd95SBruce Richardson 				  int on);
53299a2dd95SBruce Richardson 
5333c2ca0a9SAndrew Rybchenko /** @internal Get current flow control parameter on an Ethernet device. */
53499a2dd95SBruce Richardson typedef int (*flow_ctrl_get_t)(struct rte_eth_dev *dev,
53599a2dd95SBruce Richardson 			       struct rte_eth_fc_conf *fc_conf);
53699a2dd95SBruce Richardson 
5373c2ca0a9SAndrew Rybchenko /** @internal Setup flow control parameter on an Ethernet device. */
53899a2dd95SBruce Richardson typedef int (*flow_ctrl_set_t)(struct rte_eth_dev *dev,
53999a2dd95SBruce Richardson 			       struct rte_eth_fc_conf *fc_conf);
54099a2dd95SBruce Richardson 
5413c2ca0a9SAndrew Rybchenko /** @internal Setup priority flow control parameter on an Ethernet device. */
54299a2dd95SBruce Richardson typedef int (*priority_flow_ctrl_set_t)(struct rte_eth_dev *dev,
54399a2dd95SBruce Richardson 				struct rte_eth_pfc_conf *pfc_conf);
54499a2dd95SBruce Richardson 
5450de345e9SJerin Jacob /** @internal Get info for queue based PFC on an Ethernet device. */
5460de345e9SJerin Jacob typedef int (*priority_flow_ctrl_queue_info_get_t)(struct rte_eth_dev *dev,
5470de345e9SJerin Jacob 			struct rte_eth_pfc_queue_info *pfc_queue_info);
5480de345e9SJerin Jacob /** @internal Configure queue based PFC parameter on an Ethernet device. */
5490de345e9SJerin Jacob typedef int (*priority_flow_ctrl_queue_config_t)(struct rte_eth_dev *dev,
5500de345e9SJerin Jacob 			struct rte_eth_pfc_queue_conf *pfc_queue_conf);
5510de345e9SJerin Jacob 
5523c2ca0a9SAndrew Rybchenko /** @internal Update RSS redirection table on an Ethernet device. */
55399a2dd95SBruce Richardson typedef int (*reta_update_t)(struct rte_eth_dev *dev,
55499a2dd95SBruce Richardson 			     struct rte_eth_rss_reta_entry64 *reta_conf,
55599a2dd95SBruce Richardson 			     uint16_t reta_size);
55699a2dd95SBruce Richardson 
5573c2ca0a9SAndrew Rybchenko /** @internal Query RSS redirection table on an Ethernet device. */
55899a2dd95SBruce Richardson typedef int (*reta_query_t)(struct rte_eth_dev *dev,
55999a2dd95SBruce Richardson 			    struct rte_eth_rss_reta_entry64 *reta_conf,
56099a2dd95SBruce Richardson 			    uint16_t reta_size);
56199a2dd95SBruce Richardson 
5623c2ca0a9SAndrew Rybchenko /** @internal Update RSS hash configuration of an Ethernet device. */
56399a2dd95SBruce Richardson typedef int (*rss_hash_update_t)(struct rte_eth_dev *dev,
56499a2dd95SBruce Richardson 				 struct rte_eth_rss_conf *rss_conf);
56599a2dd95SBruce Richardson 
5663c2ca0a9SAndrew Rybchenko /** @internal Get current RSS hash configuration of an Ethernet device. */
56799a2dd95SBruce Richardson typedef int (*rss_hash_conf_get_t)(struct rte_eth_dev *dev,
56899a2dd95SBruce Richardson 				   struct rte_eth_rss_conf *rss_conf);
56999a2dd95SBruce Richardson 
5703c2ca0a9SAndrew Rybchenko /** @internal Turn on SW controllable LED on an Ethernet device. */
57199a2dd95SBruce Richardson typedef int (*eth_dev_led_on_t)(struct rte_eth_dev *dev);
57299a2dd95SBruce Richardson 
5733c2ca0a9SAndrew Rybchenko /** @internal Turn off SW controllable LED on an Ethernet device. */
57499a2dd95SBruce Richardson typedef int (*eth_dev_led_off_t)(struct rte_eth_dev *dev);
57599a2dd95SBruce Richardson 
5763c2ca0a9SAndrew Rybchenko /** @internal Remove MAC address from receive address register. */
57799a2dd95SBruce Richardson typedef void (*eth_mac_addr_remove_t)(struct rte_eth_dev *dev, uint32_t index);
57899a2dd95SBruce Richardson 
5793c2ca0a9SAndrew Rybchenko /** @internal Set a MAC address into Receive Address Register. */
58099a2dd95SBruce Richardson typedef int (*eth_mac_addr_add_t)(struct rte_eth_dev *dev,
58199a2dd95SBruce Richardson 				  struct rte_ether_addr *mac_addr,
58299a2dd95SBruce Richardson 				  uint32_t index,
58399a2dd95SBruce Richardson 				  uint32_t vmdq);
58499a2dd95SBruce Richardson 
5853c2ca0a9SAndrew Rybchenko /** @internal Set a MAC address into Receive Address Register. */
58699a2dd95SBruce Richardson typedef int (*eth_mac_addr_set_t)(struct rte_eth_dev *dev,
58799a2dd95SBruce Richardson 				  struct rte_ether_addr *mac_addr);
58899a2dd95SBruce Richardson 
5893c2ca0a9SAndrew Rybchenko /** @internal Set a Unicast Hash bitmap. */
59099a2dd95SBruce Richardson typedef int (*eth_uc_hash_table_set_t)(struct rte_eth_dev *dev,
59199a2dd95SBruce Richardson 				  struct rte_ether_addr *mac_addr,
59299a2dd95SBruce Richardson 				  uint8_t on);
59399a2dd95SBruce Richardson 
5943c2ca0a9SAndrew Rybchenko /** @internal Set all Unicast Hash bitmap. */
59599a2dd95SBruce Richardson typedef int (*eth_uc_all_hash_table_set_t)(struct rte_eth_dev *dev,
59699a2dd95SBruce Richardson 				  uint8_t on);
59799a2dd95SBruce Richardson 
5983c2ca0a9SAndrew Rybchenko /** @internal Set queue Tx rate. */
59999a2dd95SBruce Richardson typedef int (*eth_set_queue_rate_limit_t)(struct rte_eth_dev *dev,
60099a2dd95SBruce Richardson 				uint16_t queue_idx,
60199a2dd95SBruce Richardson 				uint16_t tx_rate);
60299a2dd95SBruce Richardson 
6033c2ca0a9SAndrew Rybchenko /** @internal Add tunneling UDP port. */
60499a2dd95SBruce Richardson typedef int (*eth_udp_tunnel_port_add_t)(struct rte_eth_dev *dev,
60599a2dd95SBruce Richardson 					 struct rte_eth_udp_tunnel *tunnel_udp);
60699a2dd95SBruce Richardson 
6073c2ca0a9SAndrew Rybchenko /** @internal Delete tunneling UDP port. */
60899a2dd95SBruce Richardson typedef int (*eth_udp_tunnel_port_del_t)(struct rte_eth_dev *dev,
60999a2dd95SBruce Richardson 					 struct rte_eth_udp_tunnel *tunnel_udp);
61099a2dd95SBruce Richardson 
6113c2ca0a9SAndrew Rybchenko /** @internal set the list of multicast addresses on an Ethernet device. */
61299a2dd95SBruce Richardson typedef int (*eth_set_mc_addr_list_t)(struct rte_eth_dev *dev,
61399a2dd95SBruce Richardson 				      struct rte_ether_addr *mc_addr_set,
61499a2dd95SBruce Richardson 				      uint32_t nb_mc_addr);
61599a2dd95SBruce Richardson 
6163c2ca0a9SAndrew Rybchenko /** @internal Function used to enable IEEE1588/802.1AS timestamping. */
61799a2dd95SBruce Richardson typedef int (*eth_timesync_enable_t)(struct rte_eth_dev *dev);
61899a2dd95SBruce Richardson 
6193c2ca0a9SAndrew Rybchenko /** @internal Function used to disable IEEE1588/802.1AS timestamping. */
62099a2dd95SBruce Richardson typedef int (*eth_timesync_disable_t)(struct rte_eth_dev *dev);
62199a2dd95SBruce Richardson 
6223c2ca0a9SAndrew Rybchenko /** @internal Function used to read an Rx IEEE1588/802.1AS timestamp. */
62399a2dd95SBruce Richardson typedef int (*eth_timesync_read_rx_timestamp_t)(struct rte_eth_dev *dev,
62499a2dd95SBruce Richardson 						struct timespec *timestamp,
62599a2dd95SBruce Richardson 						uint32_t flags);
62699a2dd95SBruce Richardson 
6273c2ca0a9SAndrew Rybchenko /** @internal Function used to read a Tx IEEE1588/802.1AS timestamp. */
62899a2dd95SBruce Richardson typedef int (*eth_timesync_read_tx_timestamp_t)(struct rte_eth_dev *dev,
62999a2dd95SBruce Richardson 						struct timespec *timestamp);
63099a2dd95SBruce Richardson 
6313c2ca0a9SAndrew Rybchenko /** @internal Function used to adjust the device clock. */
63299a2dd95SBruce Richardson typedef int (*eth_timesync_adjust_time)(struct rte_eth_dev *dev, int64_t);
63399a2dd95SBruce Richardson 
6343c2ca0a9SAndrew Rybchenko /** @internal Function used to get time from the device clock. */
63599a2dd95SBruce Richardson typedef int (*eth_timesync_read_time)(struct rte_eth_dev *dev,
63699a2dd95SBruce Richardson 				      struct timespec *timestamp);
63799a2dd95SBruce Richardson 
6383c2ca0a9SAndrew Rybchenko /** @internal Function used to get time from the device clock. */
63999a2dd95SBruce Richardson typedef int (*eth_timesync_write_time)(struct rte_eth_dev *dev,
64099a2dd95SBruce Richardson 				       const struct timespec *timestamp);
64199a2dd95SBruce Richardson 
6423c2ca0a9SAndrew Rybchenko /** @internal Function used to get the current value of the device clock. */
64399a2dd95SBruce Richardson typedef int (*eth_read_clock)(struct rte_eth_dev *dev,
64499a2dd95SBruce Richardson 				      uint64_t *timestamp);
64599a2dd95SBruce Richardson 
6463c2ca0a9SAndrew Rybchenko /** @internal Retrieve registers. */
64799a2dd95SBruce Richardson typedef int (*eth_get_reg_t)(struct rte_eth_dev *dev,
64899a2dd95SBruce Richardson 				struct rte_dev_reg_info *info);
64999a2dd95SBruce Richardson 
650bf73419dSAndrew Rybchenko /** @internal Retrieve EEPROM size. */
65199a2dd95SBruce Richardson typedef int (*eth_get_eeprom_length_t)(struct rte_eth_dev *dev);
65299a2dd95SBruce Richardson 
653bf73419dSAndrew Rybchenko /** @internal Retrieve EEPROM data. */
65499a2dd95SBruce Richardson typedef int (*eth_get_eeprom_t)(struct rte_eth_dev *dev,
65599a2dd95SBruce Richardson 				struct rte_dev_eeprom_info *info);
65699a2dd95SBruce Richardson 
657bf73419dSAndrew Rybchenko /** @internal Program EEPROM data. */
65899a2dd95SBruce Richardson typedef int (*eth_set_eeprom_t)(struct rte_eth_dev *dev,
65999a2dd95SBruce Richardson 				struct rte_dev_eeprom_info *info);
66099a2dd95SBruce Richardson 
661bf73419dSAndrew Rybchenko /** @internal Retrieve type and size of plugin module EEPROM. */
66299a2dd95SBruce Richardson typedef int (*eth_get_module_info_t)(struct rte_eth_dev *dev,
66399a2dd95SBruce Richardson 				     struct rte_eth_dev_module_info *modinfo);
66499a2dd95SBruce Richardson 
665bf73419dSAndrew Rybchenko /** @internal Retrieve plugin module EEPROM data. */
66699a2dd95SBruce Richardson typedef int (*eth_get_module_eeprom_t)(struct rte_eth_dev *dev,
66799a2dd95SBruce Richardson 				       struct rte_dev_eeprom_info *info);
66899a2dd95SBruce Richardson 
66999a2dd95SBruce Richardson struct rte_flow_ops;
67099a2dd95SBruce Richardson /**
67199a2dd95SBruce Richardson  * @internal
67299a2dd95SBruce Richardson  * Get flow operations.
67399a2dd95SBruce Richardson  *
67499a2dd95SBruce Richardson  * If the flow API is not supported for the specified device,
67599a2dd95SBruce Richardson  * the driver can return NULL.
67699a2dd95SBruce Richardson  */
67799a2dd95SBruce Richardson typedef int (*eth_flow_ops_get_t)(struct rte_eth_dev *dev,
67899a2dd95SBruce Richardson 				  const struct rte_flow_ops **ops);
67999a2dd95SBruce Richardson 
6803c2ca0a9SAndrew Rybchenko /** @internal Get Traffic Management (TM) operations on an Ethernet device. */
68199a2dd95SBruce Richardson typedef int (*eth_tm_ops_get_t)(struct rte_eth_dev *dev, void *ops);
68299a2dd95SBruce Richardson 
6833c2ca0a9SAndrew Rybchenko /** @internal Get Traffic Metering and Policing (MTR) operations. */
68499a2dd95SBruce Richardson typedef int (*eth_mtr_ops_get_t)(struct rte_eth_dev *dev, void *ops);
68599a2dd95SBruce Richardson 
686064e90c4SAndrew Rybchenko /** @internal Get DCB information on an Ethernet device. */
68799a2dd95SBruce Richardson typedef int (*eth_get_dcb_info)(struct rte_eth_dev *dev,
68899a2dd95SBruce Richardson 				 struct rte_eth_dcb_info *dcb_info);
68999a2dd95SBruce Richardson 
6903c2ca0a9SAndrew Rybchenko /** @internal Test if a port supports specific mempool ops. */
69199a2dd95SBruce Richardson typedef int (*eth_pool_ops_supported_t)(struct rte_eth_dev *dev,
69299a2dd95SBruce Richardson 						const char *pool);
69399a2dd95SBruce Richardson 
69499a2dd95SBruce Richardson /**
69599a2dd95SBruce Richardson  * @internal
69699a2dd95SBruce Richardson  * Get the hairpin capabilities.
69799a2dd95SBruce Richardson  *
69899a2dd95SBruce Richardson  * @param dev
69999a2dd95SBruce Richardson  *   ethdev handle of port.
70099a2dd95SBruce Richardson  * @param cap
70199a2dd95SBruce Richardson  *   returns the hairpin capabilities from the device.
70299a2dd95SBruce Richardson  *
70399a2dd95SBruce Richardson  * @return
70499a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
70599a2dd95SBruce Richardson  *
70699a2dd95SBruce Richardson  * @retval 0
70799a2dd95SBruce Richardson  *   Success, hairpin is supported.
70899a2dd95SBruce Richardson  * @retval -ENOTSUP
70999a2dd95SBruce Richardson  *   Hairpin is not supported.
71099a2dd95SBruce Richardson  */
71199a2dd95SBruce Richardson typedef int (*eth_hairpin_cap_get_t)(struct rte_eth_dev *dev,
71299a2dd95SBruce Richardson 				     struct rte_eth_hairpin_cap *cap);
71399a2dd95SBruce Richardson 
71499a2dd95SBruce Richardson /**
71599a2dd95SBruce Richardson  * @internal
71609fd4227SAndrew Rybchenko  * Setup Rx hairpin queue.
71799a2dd95SBruce Richardson  *
71899a2dd95SBruce Richardson  * @param dev
71999a2dd95SBruce Richardson  *   ethdev handle of port.
72099a2dd95SBruce Richardson  * @param rx_queue_id
72109fd4227SAndrew Rybchenko  *   the selected Rx queue index.
72299a2dd95SBruce Richardson  * @param nb_rx_desc
72399a2dd95SBruce Richardson  *   the requested number of descriptors for this queue. 0 - use PMD default.
72499a2dd95SBruce Richardson  * @param conf
72509fd4227SAndrew Rybchenko  *   the Rx hairpin configuration structure.
72699a2dd95SBruce Richardson  *
72799a2dd95SBruce Richardson  * @return
72899a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
72999a2dd95SBruce Richardson  *
73099a2dd95SBruce Richardson  * @retval 0
73199a2dd95SBruce Richardson  *   Success, hairpin is supported.
73299a2dd95SBruce Richardson  * @retval -ENOTSUP
73399a2dd95SBruce Richardson  *   Hairpin is not supported.
73499a2dd95SBruce Richardson  * @retval -EINVAL
73599a2dd95SBruce Richardson  *   One of the parameters is invalid.
73699a2dd95SBruce Richardson  * @retval -ENOMEM
73799a2dd95SBruce Richardson  *   Unable to allocate resources.
73899a2dd95SBruce Richardson  */
73999a2dd95SBruce Richardson typedef int (*eth_rx_hairpin_queue_setup_t)
74099a2dd95SBruce Richardson 	(struct rte_eth_dev *dev, uint16_t rx_queue_id,
74199a2dd95SBruce Richardson 	 uint16_t nb_rx_desc,
74299a2dd95SBruce Richardson 	 const struct rte_eth_hairpin_conf *conf);
74399a2dd95SBruce Richardson 
74499a2dd95SBruce Richardson /**
74599a2dd95SBruce Richardson  * @internal
74609fd4227SAndrew Rybchenko  * Setup Tx hairpin queue.
74799a2dd95SBruce Richardson  *
74899a2dd95SBruce Richardson  * @param dev
74999a2dd95SBruce Richardson  *   ethdev handle of port.
75099a2dd95SBruce Richardson  * @param tx_queue_id
75109fd4227SAndrew Rybchenko  *   the selected Tx queue index.
75299a2dd95SBruce Richardson  * @param nb_tx_desc
75399a2dd95SBruce Richardson  *   the requested number of descriptors for this queue. 0 - use PMD default.
75499a2dd95SBruce Richardson  * @param conf
75509fd4227SAndrew Rybchenko  *   the Tx hairpin configuration structure.
75699a2dd95SBruce Richardson  *
75799a2dd95SBruce Richardson  * @return
75899a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
75999a2dd95SBruce Richardson  *
76099a2dd95SBruce Richardson  * @retval 0
76199a2dd95SBruce Richardson  *   Success, hairpin is supported.
76299a2dd95SBruce Richardson  * @retval -ENOTSUP
76399a2dd95SBruce Richardson  *   Hairpin is not supported.
76499a2dd95SBruce Richardson  * @retval -EINVAL
76599a2dd95SBruce Richardson  *   One of the parameters is invalid.
76699a2dd95SBruce Richardson  * @retval -ENOMEM
76799a2dd95SBruce Richardson  *   Unable to allocate resources.
76899a2dd95SBruce Richardson  */
76999a2dd95SBruce Richardson typedef int (*eth_tx_hairpin_queue_setup_t)
77099a2dd95SBruce Richardson 	(struct rte_eth_dev *dev, uint16_t tx_queue_id,
77199a2dd95SBruce Richardson 	 uint16_t nb_tx_desc,
77299a2dd95SBruce Richardson 	 const struct rte_eth_hairpin_conf *hairpin_conf);
77399a2dd95SBruce Richardson 
77499a2dd95SBruce Richardson /**
77599a2dd95SBruce Richardson  * @internal
77699a2dd95SBruce Richardson  * Get Forward Error Correction(FEC) capability.
77799a2dd95SBruce Richardson  *
77899a2dd95SBruce Richardson  * @param dev
77999a2dd95SBruce Richardson  *   ethdev handle of port.
78099a2dd95SBruce Richardson  * @param speed_fec_capa
78199a2dd95SBruce Richardson  *   speed_fec_capa is out only with per-speed capabilities.
78299a2dd95SBruce Richardson  * @param num
78399a2dd95SBruce Richardson  *   a number of elements in an speed_fec_capa array.
78499a2dd95SBruce Richardson  *
78599a2dd95SBruce Richardson  * @return
78699a2dd95SBruce Richardson  *   Negative errno value on error, positive value on success.
78799a2dd95SBruce Richardson  *
78899a2dd95SBruce Richardson  * @retval positive value
78999a2dd95SBruce Richardson  *   A non-negative value lower or equal to num: success. The return value
79099a2dd95SBruce Richardson  *   is the number of entries filled in the fec capa array.
79199a2dd95SBruce Richardson  *   A non-negative value higher than num: error, the given fec capa array
79299a2dd95SBruce Richardson  *   is too small. The return value corresponds to the num that should
79399a2dd95SBruce Richardson  *   be given to succeed. The entries in the fec capa array are not valid
79499a2dd95SBruce Richardson  *   and shall not be used by the caller.
79599a2dd95SBruce Richardson  * @retval -ENOTSUP
79699a2dd95SBruce Richardson  *   Operation is not supported.
79799a2dd95SBruce Richardson  * @retval -EIO
79899a2dd95SBruce Richardson  *   Device is removed.
79999a2dd95SBruce Richardson  * @retval -EINVAL
80099a2dd95SBruce Richardson  *   *num* or *speed_fec_capa* invalid.
80199a2dd95SBruce Richardson  */
80299a2dd95SBruce Richardson typedef int (*eth_fec_get_capability_t)(struct rte_eth_dev *dev,
80399a2dd95SBruce Richardson 		struct rte_eth_fec_capa *speed_fec_capa, unsigned int num);
80499a2dd95SBruce Richardson 
80599a2dd95SBruce Richardson /**
80699a2dd95SBruce Richardson  * @internal
80799a2dd95SBruce Richardson  * Get Forward Error Correction(FEC) mode.
80899a2dd95SBruce Richardson  *
80999a2dd95SBruce Richardson  * @param dev
81099a2dd95SBruce Richardson  *   ethdev handle of port.
81199a2dd95SBruce Richardson  * @param fec_capa
81299a2dd95SBruce Richardson  *   a bitmask of enabled FEC modes. If AUTO bit is set, other
81399a2dd95SBruce Richardson  *   bits specify FEC modes which may be negotiated. If AUTO
81499a2dd95SBruce Richardson  *   bit is clear, specify FEC modes to be used (only one valid
81599a2dd95SBruce Richardson  *   mode per speed may be set).
81699a2dd95SBruce Richardson  *
81799a2dd95SBruce Richardson  * @return
81899a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
81999a2dd95SBruce Richardson  *
82099a2dd95SBruce Richardson  * @retval 0
82199a2dd95SBruce Richardson  *   Success, get FEC success.
82299a2dd95SBruce Richardson  * @retval -ENOTSUP
82399a2dd95SBruce Richardson  *   Operation is not supported.
82499a2dd95SBruce Richardson  * @retval -EIO
82599a2dd95SBruce Richardson  *   Device is removed.
82699a2dd95SBruce Richardson  */
82799a2dd95SBruce Richardson typedef int (*eth_fec_get_t)(struct rte_eth_dev *dev,
82899a2dd95SBruce Richardson 			     uint32_t *fec_capa);
82999a2dd95SBruce Richardson 
83099a2dd95SBruce Richardson /**
83199a2dd95SBruce Richardson  * @internal
83299a2dd95SBruce Richardson  * Set Forward Error Correction(FEC) mode.
83399a2dd95SBruce Richardson  *
83499a2dd95SBruce Richardson  * @param dev
83599a2dd95SBruce Richardson  *   ethdev handle of port.
83699a2dd95SBruce Richardson  * @param fec_capa
83799a2dd95SBruce Richardson  *   bitmask of allowed FEC modes. It must be only one
83899a2dd95SBruce Richardson  *   if AUTO is disabled. If AUTO is enabled, other
83999a2dd95SBruce Richardson  *   bits specify FEC modes which may be negotiated.
84099a2dd95SBruce Richardson  *
84199a2dd95SBruce Richardson  * @return
84299a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
84399a2dd95SBruce Richardson  *
84499a2dd95SBruce Richardson  * @retval 0
84599a2dd95SBruce Richardson  *   Success, set FEC success.
84699a2dd95SBruce Richardson  * @retval -ENOTSUP
84799a2dd95SBruce Richardson  *   Operation is not supported.
84899a2dd95SBruce Richardson  * @retval -EINVAL
84999a2dd95SBruce Richardson  *   Unsupported FEC mode requested.
85099a2dd95SBruce Richardson  * @retval -EIO
85199a2dd95SBruce Richardson  *   Device is removed.
85299a2dd95SBruce Richardson  */
85399a2dd95SBruce Richardson typedef int (*eth_fec_set_t)(struct rte_eth_dev *dev, uint32_t fec_capa);
85499a2dd95SBruce Richardson 
85599a2dd95SBruce Richardson /**
85699a2dd95SBruce Richardson  * @internal
85799a2dd95SBruce Richardson  * Get all hairpin Tx/Rx peer ports of the current device, if any.
85899a2dd95SBruce Richardson  *
85999a2dd95SBruce Richardson  * @param dev
86099a2dd95SBruce Richardson  *   ethdev handle of port.
86199a2dd95SBruce Richardson  * @param peer_ports
86299a2dd95SBruce Richardson  *   array to save the ports list.
86399a2dd95SBruce Richardson  * @param len
86499a2dd95SBruce Richardson  *   array length.
86599a2dd95SBruce Richardson  * @param direction
86699a2dd95SBruce Richardson  *   value to decide the current to peer direction
86799a2dd95SBruce Richardson  *   positive - used as Tx to get all peer Rx ports.
86899a2dd95SBruce Richardson  *   zero - used as Rx to get all peer Tx ports.
86999a2dd95SBruce Richardson  *
87099a2dd95SBruce Richardson  * @return
87199a2dd95SBruce Richardson  *   Negative errno value on error, 0 or positive on success.
87299a2dd95SBruce Richardson  *
87399a2dd95SBruce Richardson  * @retval 0
87499a2dd95SBruce Richardson  *   Success, no peer ports.
87599a2dd95SBruce Richardson  * @retval >0
87699a2dd95SBruce Richardson  *   Actual number of the peer ports.
87799a2dd95SBruce Richardson  * @retval -ENOTSUP
87899a2dd95SBruce Richardson  *   Get peer ports API is not supported.
87999a2dd95SBruce Richardson  * @retval -EINVAL
88099a2dd95SBruce Richardson  *   One of the parameters is invalid.
88199a2dd95SBruce Richardson  */
88299a2dd95SBruce Richardson typedef int (*hairpin_get_peer_ports_t)(struct rte_eth_dev *dev,
88399a2dd95SBruce Richardson 					uint16_t *peer_ports, size_t len,
88499a2dd95SBruce Richardson 					uint32_t direction);
88599a2dd95SBruce Richardson 
88699a2dd95SBruce Richardson /**
88799a2dd95SBruce Richardson  * @internal
88899a2dd95SBruce Richardson  * Bind all hairpin Tx queues of one port to the Rx queues of the peer port.
88999a2dd95SBruce Richardson  *
89099a2dd95SBruce Richardson  * @param dev
89199a2dd95SBruce Richardson  *   ethdev handle of port.
89299a2dd95SBruce Richardson  * @param rx_port
89399a2dd95SBruce Richardson  *   the peer Rx port.
89499a2dd95SBruce Richardson  *
89599a2dd95SBruce Richardson  * @return
89699a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
89799a2dd95SBruce Richardson  *
89899a2dd95SBruce Richardson  * @retval 0
89999a2dd95SBruce Richardson  *   Success, bind successfully.
90099a2dd95SBruce Richardson  * @retval -ENOTSUP
90199a2dd95SBruce Richardson  *   Bind API is not supported.
90299a2dd95SBruce Richardson  * @retval -EINVAL
90399a2dd95SBruce Richardson  *   One of the parameters is invalid.
90499a2dd95SBruce Richardson  * @retval -EBUSY
90599a2dd95SBruce Richardson  *   Device is not started.
90699a2dd95SBruce Richardson  */
90799a2dd95SBruce Richardson typedef int (*eth_hairpin_bind_t)(struct rte_eth_dev *dev,
90899a2dd95SBruce Richardson 				uint16_t rx_port);
90999a2dd95SBruce Richardson 
91099a2dd95SBruce Richardson /**
91199a2dd95SBruce Richardson  * @internal
91299a2dd95SBruce Richardson  * Unbind all hairpin Tx queues of one port from the Rx queues of the peer port.
91399a2dd95SBruce Richardson  *
91499a2dd95SBruce Richardson  * @param dev
91599a2dd95SBruce Richardson  *   ethdev handle of port.
91699a2dd95SBruce Richardson  * @param rx_port
91799a2dd95SBruce Richardson  *   the peer Rx port.
91899a2dd95SBruce Richardson  *
91999a2dd95SBruce Richardson  * @return
92099a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
92199a2dd95SBruce Richardson  *
92299a2dd95SBruce Richardson  * @retval 0
92399a2dd95SBruce Richardson  *   Success, unbind successfully.
92499a2dd95SBruce Richardson  * @retval -ENOTSUP
92599a2dd95SBruce Richardson  *   Bind API is not supported.
92699a2dd95SBruce Richardson  * @retval -EINVAL
92799a2dd95SBruce Richardson  *   One of the parameters is invalid.
92899a2dd95SBruce Richardson  * @retval -EBUSY
92999a2dd95SBruce Richardson  *   Device is already stopped.
93099a2dd95SBruce Richardson  */
93199a2dd95SBruce Richardson typedef int (*eth_hairpin_unbind_t)(struct rte_eth_dev *dev,
93299a2dd95SBruce Richardson 				  uint16_t rx_port);
93399a2dd95SBruce Richardson 
9343c2ca0a9SAndrew Rybchenko /** @internal Update and fetch peer queue information. */
93599a2dd95SBruce Richardson typedef int (*eth_hairpin_queue_peer_update_t)
93699a2dd95SBruce Richardson 	(struct rte_eth_dev *dev, uint16_t peer_queue,
93799a2dd95SBruce Richardson 	 struct rte_hairpin_peer_info *current_info,
93899a2dd95SBruce Richardson 	 struct rte_hairpin_peer_info *peer_info, uint32_t direction);
93999a2dd95SBruce Richardson 
9403c2ca0a9SAndrew Rybchenko /** @internal Bind peer queue to the current queue with fetched information. */
94199a2dd95SBruce Richardson typedef int (*eth_hairpin_queue_peer_bind_t)
94299a2dd95SBruce Richardson 	(struct rte_eth_dev *dev, uint16_t cur_queue,
94399a2dd95SBruce Richardson 	 struct rte_hairpin_peer_info *peer_info, uint32_t direction);
94499a2dd95SBruce Richardson 
9453c2ca0a9SAndrew Rybchenko /** @internal Unbind peer queue from the current queue. */
94699a2dd95SBruce Richardson typedef int (*eth_hairpin_queue_peer_unbind_t)
94799a2dd95SBruce Richardson 	(struct rte_eth_dev *dev, uint16_t cur_queue, uint32_t direction);
94899a2dd95SBruce Richardson 
94999a2dd95SBruce Richardson /**
95099a2dd95SBruce Richardson  * @internal
95199a2dd95SBruce Richardson  * Get address of memory location whose contents will change whenever there is
95299a2dd95SBruce Richardson  * new data to be received on an Rx queue.
95399a2dd95SBruce Richardson  *
95499a2dd95SBruce Richardson  * @param rxq
95599a2dd95SBruce Richardson  *   Ethdev queue pointer.
95699a2dd95SBruce Richardson  * @param pmc
95799a2dd95SBruce Richardson  *   The pointer to power-optimized monitoring condition structure.
95899a2dd95SBruce Richardson  * @return
95999a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
96099a2dd95SBruce Richardson  *
96199a2dd95SBruce Richardson  * @retval 0
96299a2dd95SBruce Richardson  *   Success
96399a2dd95SBruce Richardson  * @retval -EINVAL
96499a2dd95SBruce Richardson  *   Invalid parameters
96599a2dd95SBruce Richardson  */
96699a2dd95SBruce Richardson typedef int (*eth_get_monitor_addr_t)(void *rxq,
96799a2dd95SBruce Richardson 		struct rte_power_monitor_cond *pmc);
96899a2dd95SBruce Richardson 
96999a2dd95SBruce Richardson /**
97099a2dd95SBruce Richardson  * @internal
97199a2dd95SBruce Richardson  * Get representor info to be able to calculate the unique representor ID.
97299a2dd95SBruce Richardson  *
97399a2dd95SBruce Richardson  * Caller should pass NULL as pointer of info to get number of entries,
97499a2dd95SBruce Richardson  * allocate info buffer according to returned entry number, then call
97599a2dd95SBruce Richardson  * again with buffer to get real info.
97699a2dd95SBruce Richardson  *
97799a2dd95SBruce Richardson  * To calculate the representor ID, caller should iterate each entry,
97899a2dd95SBruce Richardson  * match controller index, pf index, vf or sf start index and range,
97999a2dd95SBruce Richardson  * then calculate representor ID from offset to vf/sf start index.
98099a2dd95SBruce Richardson  * @see rte_eth_representor_id_get.
98199a2dd95SBruce Richardson  *
98299a2dd95SBruce Richardson  * @param dev
98399a2dd95SBruce Richardson  *   Ethdev handle of port.
98499a2dd95SBruce Richardson  * @param [out] info
98599a2dd95SBruce Richardson  *   Pointer to memory to save device representor info.
98699a2dd95SBruce Richardson  * @return
98799a2dd95SBruce Richardson  *   Negative errno value on error, number of info entries otherwise.
98899a2dd95SBruce Richardson  */
98999a2dd95SBruce Richardson 
99099a2dd95SBruce Richardson typedef int (*eth_representor_info_get_t)(struct rte_eth_dev *dev,
99199a2dd95SBruce Richardson 	struct rte_eth_representor_info *info);
99299a2dd95SBruce Richardson 
99399a2dd95SBruce Richardson /**
994f6d8a6d3SIvan Malov  * @internal
995f6d8a6d3SIvan Malov  * Negotiate the NIC's ability to deliver specific kinds of metadata to the PMD.
996f6d8a6d3SIvan Malov  *
997f6d8a6d3SIvan Malov  * @param dev
998f6d8a6d3SIvan Malov  *   Port (ethdev) handle
999f6d8a6d3SIvan Malov  *
1000f6d8a6d3SIvan Malov  * @param[inout] features
1001f6d8a6d3SIvan Malov  *   Feature selection buffer
1002f6d8a6d3SIvan Malov  *
1003f6d8a6d3SIvan Malov  * @return
1004f6d8a6d3SIvan Malov  *   Negative errno value on error, zero otherwise
1005f6d8a6d3SIvan Malov  */
1006f6d8a6d3SIvan Malov typedef int (*eth_rx_metadata_negotiate_t)(struct rte_eth_dev *dev,
1007f6d8a6d3SIvan Malov 				       uint64_t *features);
1008f6d8a6d3SIvan Malov 
1009f6d8a6d3SIvan Malov /**
1010a75ab6e5SAkhil Goyal  * @internal
1011a75ab6e5SAkhil Goyal  * Get IP reassembly offload capability of a PMD.
1012a75ab6e5SAkhil Goyal  *
1013a75ab6e5SAkhil Goyal  * @param dev
1014a75ab6e5SAkhil Goyal  *   Port (ethdev) handle
1015a75ab6e5SAkhil Goyal  *
1016a75ab6e5SAkhil Goyal  * @param[out] conf
1017a75ab6e5SAkhil Goyal  *   IP reassembly capability supported by the PMD
1018a75ab6e5SAkhil Goyal  *
1019a75ab6e5SAkhil Goyal  * @return
1020a75ab6e5SAkhil Goyal  *   Negative errno value on error, zero otherwise
1021a75ab6e5SAkhil Goyal  */
1022a75ab6e5SAkhil Goyal typedef int (*eth_ip_reassembly_capability_get_t)(struct rte_eth_dev *dev,
1023a75ab6e5SAkhil Goyal 		struct rte_eth_ip_reassembly_params *capa);
1024a75ab6e5SAkhil Goyal 
1025a75ab6e5SAkhil Goyal /**
1026a75ab6e5SAkhil Goyal  * @internal
1027a75ab6e5SAkhil Goyal  * Get IP reassembly offload configuration parameters set in PMD.
1028a75ab6e5SAkhil Goyal  *
1029a75ab6e5SAkhil Goyal  * @param dev
1030a75ab6e5SAkhil Goyal  *   Port (ethdev) handle
1031a75ab6e5SAkhil Goyal  *
1032a75ab6e5SAkhil Goyal  * @param[out] conf
1033a75ab6e5SAkhil Goyal  *   Configuration parameters for IP reassembly.
1034a75ab6e5SAkhil Goyal  *
1035a75ab6e5SAkhil Goyal  * @return
1036a75ab6e5SAkhil Goyal  *   Negative errno value on error, zero otherwise
1037a75ab6e5SAkhil Goyal  */
1038a75ab6e5SAkhil Goyal typedef int (*eth_ip_reassembly_conf_get_t)(struct rte_eth_dev *dev,
1039a75ab6e5SAkhil Goyal 		struct rte_eth_ip_reassembly_params *conf);
1040a75ab6e5SAkhil Goyal 
1041a75ab6e5SAkhil Goyal /**
1042a75ab6e5SAkhil Goyal  * @internal
1043a75ab6e5SAkhil Goyal  * Set configuration parameters for enabling IP reassembly offload in hardware.
1044a75ab6e5SAkhil Goyal  *
1045a75ab6e5SAkhil Goyal  * @param dev
1046a75ab6e5SAkhil Goyal  *   Port (ethdev) handle
1047a75ab6e5SAkhil Goyal  *
1048a75ab6e5SAkhil Goyal  * @param[in] conf
1049a75ab6e5SAkhil Goyal  *   Configuration parameters for IP reassembly.
1050a75ab6e5SAkhil Goyal  *
1051a75ab6e5SAkhil Goyal  * @return
1052a75ab6e5SAkhil Goyal  *   Negative errno value on error, zero otherwise
1053a75ab6e5SAkhil Goyal  */
1054a75ab6e5SAkhil Goyal typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev,
1055a75ab6e5SAkhil Goyal 		const struct rte_eth_ip_reassembly_params *conf);
1056a75ab6e5SAkhil Goyal 
1057a75ab6e5SAkhil Goyal /**
1058edcf22c6SMin Hu (Connor)  * @internal
1059edcf22c6SMin Hu (Connor)  * Dump private info from device to a file.
1060edcf22c6SMin Hu (Connor)  *
1061edcf22c6SMin Hu (Connor)  * @param dev
1062edcf22c6SMin Hu (Connor)  *   Port (ethdev) handle.
1063edcf22c6SMin Hu (Connor)  * @param file
1064edcf22c6SMin Hu (Connor)  *   A pointer to a file for output.
1065edcf22c6SMin Hu (Connor)  *
1066edcf22c6SMin Hu (Connor)  * @return
1067edcf22c6SMin Hu (Connor)  *   Negative value on error, 0 on success.
1068edcf22c6SMin Hu (Connor)  *
1069edcf22c6SMin Hu (Connor)  * @retval 0
1070edcf22c6SMin Hu (Connor)  *   Success
1071edcf22c6SMin Hu (Connor)  * @retval -EINVAL
1072edcf22c6SMin Hu (Connor)  *   Invalid file
1073edcf22c6SMin Hu (Connor)  */
1074edcf22c6SMin Hu (Connor) typedef int (*eth_dev_priv_dump_t)(struct rte_eth_dev *dev, FILE *file);
1075edcf22c6SMin Hu (Connor) 
1076edcf22c6SMin Hu (Connor) /**
107799a2dd95SBruce Richardson  * @internal A structure containing the functions exported by an Ethernet driver.
107899a2dd95SBruce Richardson  */
107999a2dd95SBruce Richardson struct eth_dev_ops {
108055645ee6SAndrew Rybchenko 	eth_dev_configure_t        dev_configure; /**< Configure device */
108155645ee6SAndrew Rybchenko 	eth_dev_start_t            dev_start;     /**< Start device */
108255645ee6SAndrew Rybchenko 	eth_dev_stop_t             dev_stop;      /**< Stop device */
108355645ee6SAndrew Rybchenko 	eth_dev_set_link_up_t      dev_set_link_up;   /**< Device link up */
108455645ee6SAndrew Rybchenko 	eth_dev_set_link_down_t    dev_set_link_down; /**< Device link down */
108555645ee6SAndrew Rybchenko 	eth_dev_close_t            dev_close;     /**< Close device */
108655645ee6SAndrew Rybchenko 	eth_dev_reset_t		   dev_reset;	  /**< Reset device */
108755645ee6SAndrew Rybchenko 	eth_link_update_t          link_update;   /**< Get device link state */
10883c2ca0a9SAndrew Rybchenko 	/** Check if the device was physically removed */
108999a2dd95SBruce Richardson 	eth_is_removed_t           is_removed;
109099a2dd95SBruce Richardson 
109155645ee6SAndrew Rybchenko 	eth_promiscuous_enable_t   promiscuous_enable; /**< Promiscuous ON */
109255645ee6SAndrew Rybchenko 	eth_promiscuous_disable_t  promiscuous_disable;/**< Promiscuous OFF */
109355645ee6SAndrew Rybchenko 	eth_allmulticast_enable_t  allmulticast_enable;/**< Rx multicast ON */
109455645ee6SAndrew Rybchenko 	eth_allmulticast_disable_t allmulticast_disable;/**< Rx multicast OFF */
109555645ee6SAndrew Rybchenko 	eth_mac_addr_remove_t      mac_addr_remove; /**< Remove MAC address */
109655645ee6SAndrew Rybchenko 	eth_mac_addr_add_t         mac_addr_add;  /**< Add a MAC address */
109755645ee6SAndrew Rybchenko 	eth_mac_addr_set_t         mac_addr_set;  /**< Set a MAC address */
10983c2ca0a9SAndrew Rybchenko 	/** Set list of multicast addresses */
10993c2ca0a9SAndrew Rybchenko 	eth_set_mc_addr_list_t     set_mc_addr_list;
110055645ee6SAndrew Rybchenko 	mtu_set_t                  mtu_set;       /**< Set MTU */
110199a2dd95SBruce Richardson 
11023c2ca0a9SAndrew Rybchenko 	/** Get generic device statistics */
11033c2ca0a9SAndrew Rybchenko 	eth_stats_get_t            stats_get;
11043c2ca0a9SAndrew Rybchenko 	/** Reset generic device statistics */
11053c2ca0a9SAndrew Rybchenko 	eth_stats_reset_t          stats_reset;
11063c2ca0a9SAndrew Rybchenko 	/** Get extended device statistics */
11073c2ca0a9SAndrew Rybchenko 	eth_xstats_get_t           xstats_get;
11083c2ca0a9SAndrew Rybchenko 	/** Reset extended device statistics */
11093c2ca0a9SAndrew Rybchenko 	eth_xstats_reset_t         xstats_reset;
11103c2ca0a9SAndrew Rybchenko 	/** Get names of extended statistics */
111199a2dd95SBruce Richardson 	eth_xstats_get_names_t     xstats_get_names;
11123c2ca0a9SAndrew Rybchenko 	/** Configure per queue stat counter mapping */
111399a2dd95SBruce Richardson 	eth_queue_stats_mapping_set_t queue_stats_mapping_set;
111499a2dd95SBruce Richardson 
111555645ee6SAndrew Rybchenko 	eth_dev_infos_get_t        dev_infos_get; /**< Get device info */
11163c2ca0a9SAndrew Rybchenko 	/** Retrieve Rx queue information */
11173c2ca0a9SAndrew Rybchenko 	eth_rxq_info_get_t         rxq_info_get;
11183c2ca0a9SAndrew Rybchenko 	/** Retrieve Tx queue information */
11193c2ca0a9SAndrew Rybchenko 	eth_txq_info_get_t         txq_info_get;
112009fd4227SAndrew Rybchenko 	eth_burst_mode_get_t       rx_burst_mode_get; /**< Get Rx burst mode */
112109fd4227SAndrew Rybchenko 	eth_burst_mode_get_t       tx_burst_mode_get; /**< Get Tx burst mode */
112255645ee6SAndrew Rybchenko 	eth_fw_version_get_t       fw_version_get; /**< Get firmware version */
112399a2dd95SBruce Richardson 
11243c2ca0a9SAndrew Rybchenko 	/** Get packet types supported and identified by device */
11253c2ca0a9SAndrew Rybchenko 	eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
11263c2ca0a9SAndrew Rybchenko 	/**
11273c2ca0a9SAndrew Rybchenko 	 * Inform Ethernet device about reduced range of packet types to
11283c2ca0a9SAndrew Rybchenko 	 * handle
11293c2ca0a9SAndrew Rybchenko 	 */
11303c2ca0a9SAndrew Rybchenko 	eth_dev_ptypes_set_t dev_ptypes_set;
11313c2ca0a9SAndrew Rybchenko 
11323c2ca0a9SAndrew Rybchenko 	/** Filter VLAN Setup */
11333c2ca0a9SAndrew Rybchenko 	vlan_filter_set_t          vlan_filter_set;
11343c2ca0a9SAndrew Rybchenko 	/** Outer/Inner VLAN TPID Setup */
11353c2ca0a9SAndrew Rybchenko 	vlan_tpid_set_t            vlan_tpid_set;
11363c2ca0a9SAndrew Rybchenko 	/** VLAN Stripping on queue */
11373c2ca0a9SAndrew Rybchenko 	vlan_strip_queue_set_t     vlan_strip_queue_set;
11383c2ca0a9SAndrew Rybchenko 	/** Set VLAN Offload */
11393c2ca0a9SAndrew Rybchenko 	vlan_offload_set_t         vlan_offload_set;
11403c2ca0a9SAndrew Rybchenko 	/** Set port based Tx VLAN insertion */
11413c2ca0a9SAndrew Rybchenko 	vlan_pvid_set_t            vlan_pvid_set;
114299a2dd95SBruce Richardson 
114355645ee6SAndrew Rybchenko 	eth_queue_start_t          rx_queue_start;/**< Start Rx for a queue */
114455645ee6SAndrew Rybchenko 	eth_queue_stop_t           rx_queue_stop; /**< Stop Rx for a queue */
114555645ee6SAndrew Rybchenko 	eth_queue_start_t          tx_queue_start;/**< Start Tx for a queue */
114655645ee6SAndrew Rybchenko 	eth_queue_stop_t           tx_queue_stop; /**< Stop Tx for a queue */
114755645ee6SAndrew Rybchenko 	eth_rx_queue_setup_t       rx_queue_setup;/**< Set up device Rx queue */
114855645ee6SAndrew Rybchenko 	eth_queue_release_t        rx_queue_release; /**< Release Rx queue */
114999a2dd95SBruce Richardson 
11503c2ca0a9SAndrew Rybchenko 	/** Enable Rx queue interrupt */
11513c2ca0a9SAndrew Rybchenko 	eth_rx_enable_intr_t       rx_queue_intr_enable;
11523c2ca0a9SAndrew Rybchenko 	/** Disable Rx queue interrupt */
11533c2ca0a9SAndrew Rybchenko 	eth_rx_disable_intr_t      rx_queue_intr_disable;
11543c2ca0a9SAndrew Rybchenko 
115509fd4227SAndrew Rybchenko 	eth_tx_queue_setup_t       tx_queue_setup;/**< Set up device Tx queue */
115609fd4227SAndrew Rybchenko 	eth_queue_release_t        tx_queue_release; /**< Release Tx queue */
115709fd4227SAndrew Rybchenko 	eth_tx_done_cleanup_t      tx_done_cleanup;/**< Free Tx ring mbufs */
115899a2dd95SBruce Richardson 
115955645ee6SAndrew Rybchenko 	eth_dev_led_on_t           dev_led_on;    /**< Turn on LED */
116055645ee6SAndrew Rybchenko 	eth_dev_led_off_t          dev_led_off;   /**< Turn off LED */
116199a2dd95SBruce Richardson 
116255645ee6SAndrew Rybchenko 	flow_ctrl_get_t            flow_ctrl_get; /**< Get flow control */
116355645ee6SAndrew Rybchenko 	flow_ctrl_set_t            flow_ctrl_set; /**< Setup flow control */
11643c2ca0a9SAndrew Rybchenko 	/** Setup priority flow control */
11653c2ca0a9SAndrew Rybchenko 	priority_flow_ctrl_set_t   priority_flow_ctrl_set;
11660de345e9SJerin Jacob 	/** Priority flow control queue info get */
11670de345e9SJerin Jacob 	priority_flow_ctrl_queue_info_get_t priority_flow_ctrl_queue_info_get;
11680de345e9SJerin Jacob 	/** Priority flow control queue configure */
11690de345e9SJerin Jacob 	priority_flow_ctrl_queue_config_t priority_flow_ctrl_queue_config;
117099a2dd95SBruce Richardson 
11713c2ca0a9SAndrew Rybchenko 	/** Set Unicast Table Array */
11723c2ca0a9SAndrew Rybchenko 	eth_uc_hash_table_set_t    uc_hash_table_set;
11733c2ca0a9SAndrew Rybchenko 	/** Set Unicast hash bitmap */
11743c2ca0a9SAndrew Rybchenko 	eth_uc_all_hash_table_set_t uc_all_hash_table_set;
117599a2dd95SBruce Richardson 
11763c2ca0a9SAndrew Rybchenko 	/** Add UDP tunnel port */
11773c2ca0a9SAndrew Rybchenko 	eth_udp_tunnel_port_add_t  udp_tunnel_port_add;
11783c2ca0a9SAndrew Rybchenko 	/** Delete UDP tunnel port */
11793c2ca0a9SAndrew Rybchenko 	eth_udp_tunnel_port_del_t  udp_tunnel_port_del;
118099a2dd95SBruce Richardson 
11813c2ca0a9SAndrew Rybchenko 	/** Set queue rate limit */
11823c2ca0a9SAndrew Rybchenko 	eth_set_queue_rate_limit_t set_queue_rate_limit;
118399a2dd95SBruce Richardson 
11843c2ca0a9SAndrew Rybchenko 	/** Configure RSS hash protocols and hashing key */
11853c2ca0a9SAndrew Rybchenko 	rss_hash_update_t          rss_hash_update;
11863c2ca0a9SAndrew Rybchenko 	/** Get current RSS hash configuration */
11873c2ca0a9SAndrew Rybchenko 	rss_hash_conf_get_t        rss_hash_conf_get;
11883c2ca0a9SAndrew Rybchenko 	/** Update redirection table */
11893c2ca0a9SAndrew Rybchenko 	reta_update_t              reta_update;
11903c2ca0a9SAndrew Rybchenko 	/** Query redirection table */
11913c2ca0a9SAndrew Rybchenko 	reta_query_t               reta_query;
119299a2dd95SBruce Richardson 
119355645ee6SAndrew Rybchenko 	eth_get_reg_t              get_reg;           /**< Get registers */
119455645ee6SAndrew Rybchenko 	eth_get_eeprom_length_t    get_eeprom_length; /**< Get EEPROM length */
119555645ee6SAndrew Rybchenko 	eth_get_eeprom_t           get_eeprom;        /**< Get EEPROM data */
119655645ee6SAndrew Rybchenko 	eth_set_eeprom_t           set_eeprom;        /**< Set EEPROM */
119799a2dd95SBruce Richardson 
1198bf73419dSAndrew Rybchenko 	/** Get plugin module EEPROM attribute */
119999a2dd95SBruce Richardson 	eth_get_module_info_t      get_module_info;
1200bf73419dSAndrew Rybchenko 	/** Get plugin module EEPROM data */
120199a2dd95SBruce Richardson 	eth_get_module_eeprom_t    get_module_eeprom;
120299a2dd95SBruce Richardson 
120355645ee6SAndrew Rybchenko 	eth_flow_ops_get_t         flow_ops_get; /**< Get flow operations */
120499a2dd95SBruce Richardson 
12053c2ca0a9SAndrew Rybchenko 	eth_get_dcb_info           get_dcb_info; /**< Get DCB information */
120699a2dd95SBruce Richardson 
12073c2ca0a9SAndrew Rybchenko 	/** Turn IEEE1588/802.1AS timestamping on */
120899a2dd95SBruce Richardson 	eth_timesync_enable_t      timesync_enable;
12093c2ca0a9SAndrew Rybchenko 	/** Turn IEEE1588/802.1AS timestamping off */
121099a2dd95SBruce Richardson 	eth_timesync_disable_t     timesync_disable;
12113c2ca0a9SAndrew Rybchenko 	/** Read the IEEE1588/802.1AS Rx timestamp */
121299a2dd95SBruce Richardson 	eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp;
12133c2ca0a9SAndrew Rybchenko 	/** Read the IEEE1588/802.1AS Tx timestamp */
121499a2dd95SBruce Richardson 	eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp;
12153c2ca0a9SAndrew Rybchenko 	/** Adjust the device clock */
12163c2ca0a9SAndrew Rybchenko 	eth_timesync_adjust_time   timesync_adjust_time;
12173c2ca0a9SAndrew Rybchenko 	/** Get the device clock time */
12183c2ca0a9SAndrew Rybchenko 	eth_timesync_read_time     timesync_read_time;
12193c2ca0a9SAndrew Rybchenko 	/** Set the device clock time */
12203c2ca0a9SAndrew Rybchenko 	eth_timesync_write_time    timesync_write_time;
122199a2dd95SBruce Richardson 
122299a2dd95SBruce Richardson 	eth_read_clock             read_clock;
122399a2dd95SBruce Richardson 
12243c2ca0a9SAndrew Rybchenko 	/** Get extended device statistic values by ID */
122599a2dd95SBruce Richardson 	eth_xstats_get_by_id_t     xstats_get_by_id;
12263c2ca0a9SAndrew Rybchenko 	/** Get name of extended device statistics by ID */
122799a2dd95SBruce Richardson 	eth_xstats_get_names_by_id_t xstats_get_names_by_id;
122899a2dd95SBruce Richardson 
12293c2ca0a9SAndrew Rybchenko 	/** Get Traffic Management (TM) operations */
123099a2dd95SBruce Richardson 	eth_tm_ops_get_t tm_ops_get;
123199a2dd95SBruce Richardson 
12323c2ca0a9SAndrew Rybchenko 	/** Get Traffic Metering and Policing (MTR) operations */
123399a2dd95SBruce Richardson 	eth_mtr_ops_get_t mtr_ops_get;
123499a2dd95SBruce Richardson 
12353c2ca0a9SAndrew Rybchenko 	/** Test if a port supports specific mempool ops */
123699a2dd95SBruce Richardson 	eth_pool_ops_supported_t pool_ops_supported;
123799a2dd95SBruce Richardson 
12383c2ca0a9SAndrew Rybchenko 	/** Returns the hairpin capabilities */
123999a2dd95SBruce Richardson 	eth_hairpin_cap_get_t hairpin_cap_get;
12403c2ca0a9SAndrew Rybchenko 	/** Set up device Rx hairpin queue */
124199a2dd95SBruce Richardson 	eth_rx_hairpin_queue_setup_t rx_hairpin_queue_setup;
12423c2ca0a9SAndrew Rybchenko 	/** Set up device Tx hairpin queue */
124399a2dd95SBruce Richardson 	eth_tx_hairpin_queue_setup_t tx_hairpin_queue_setup;
124499a2dd95SBruce Richardson 
12453c2ca0a9SAndrew Rybchenko 	/** Get Forward Error Correction(FEC) capability */
124699a2dd95SBruce Richardson 	eth_fec_get_capability_t fec_get_capability;
12473c2ca0a9SAndrew Rybchenko 	/** Get Forward Error Correction(FEC) mode */
124899a2dd95SBruce Richardson 	eth_fec_get_t fec_get;
12493c2ca0a9SAndrew Rybchenko 	/** Set Forward Error Correction(FEC) mode */
125099a2dd95SBruce Richardson 	eth_fec_set_t fec_set;
12513c2ca0a9SAndrew Rybchenko 
12523c2ca0a9SAndrew Rybchenko 	/** Get hairpin peer ports list */
125399a2dd95SBruce Richardson 	hairpin_get_peer_ports_t hairpin_get_peer_ports;
12543c2ca0a9SAndrew Rybchenko 	/** Bind all hairpin Tx queues of device to the peer port Rx queues */
125599a2dd95SBruce Richardson 	eth_hairpin_bind_t hairpin_bind;
12563c2ca0a9SAndrew Rybchenko 	/** Unbind all hairpin Tx queues from the peer port Rx queues */
125799a2dd95SBruce Richardson 	eth_hairpin_unbind_t hairpin_unbind;
12583c2ca0a9SAndrew Rybchenko 	/** Pass the current queue info and get the peer queue info */
125999a2dd95SBruce Richardson 	eth_hairpin_queue_peer_update_t hairpin_queue_peer_update;
12603c2ca0a9SAndrew Rybchenko 	/** Set up the connection between the pair of hairpin queues */
126199a2dd95SBruce Richardson 	eth_hairpin_queue_peer_bind_t hairpin_queue_peer_bind;
12623c2ca0a9SAndrew Rybchenko 	/** Disconnect the hairpin queues of a pair from each other */
126399a2dd95SBruce Richardson 	eth_hairpin_queue_peer_unbind_t hairpin_queue_peer_unbind;
126499a2dd95SBruce Richardson 
12653c2ca0a9SAndrew Rybchenko 	/** Get power monitoring condition for Rx queue */
126699a2dd95SBruce Richardson 	eth_get_monitor_addr_t get_monitor_addr;
126799a2dd95SBruce Richardson 
12683c2ca0a9SAndrew Rybchenko 	/** Get representor info */
126999a2dd95SBruce Richardson 	eth_representor_info_get_t representor_info_get;
1270f6d8a6d3SIvan Malov 
1271f6d8a6d3SIvan Malov 	/**
1272f6d8a6d3SIvan Malov 	 * Negotiate the NIC's ability to deliver specific
127355645ee6SAndrew Rybchenko 	 * kinds of metadata to the PMD
1274f6d8a6d3SIvan Malov 	 */
1275f6d8a6d3SIvan Malov 	eth_rx_metadata_negotiate_t rx_metadata_negotiate;
1276a75ab6e5SAkhil Goyal 
1277a75ab6e5SAkhil Goyal 	/** Get IP reassembly capability */
1278a75ab6e5SAkhil Goyal 	eth_ip_reassembly_capability_get_t ip_reassembly_capability_get;
1279a75ab6e5SAkhil Goyal 	/** Get IP reassembly configuration */
1280a75ab6e5SAkhil Goyal 	eth_ip_reassembly_conf_get_t ip_reassembly_conf_get;
1281a75ab6e5SAkhil Goyal 	/** Set IP reassembly configuration */
1282a75ab6e5SAkhil Goyal 	eth_ip_reassembly_conf_set_t ip_reassembly_conf_set;
1283edcf22c6SMin Hu (Connor) 
1284edcf22c6SMin Hu (Connor) 	/** Dump private info from device */
1285edcf22c6SMin Hu (Connor) 	eth_dev_priv_dump_t eth_dev_priv_dump;
128699a2dd95SBruce Richardson };
128799a2dd95SBruce Richardson 
128899a2dd95SBruce Richardson /**
128999a2dd95SBruce Richardson  * @internal
129099a2dd95SBruce Richardson  * Check if the selected Rx queue is hairpin queue.
129199a2dd95SBruce Richardson  *
129299a2dd95SBruce Richardson  * @param dev
129399a2dd95SBruce Richardson  *  Pointer to the selected device.
129499a2dd95SBruce Richardson  * @param queue_id
129599a2dd95SBruce Richardson  *  The selected queue.
129699a2dd95SBruce Richardson  *
129799a2dd95SBruce Richardson  * @return
129899a2dd95SBruce Richardson  *   - (1) if the queue is hairpin queue, 0 otherwise.
129999a2dd95SBruce Richardson  */
130099a2dd95SBruce Richardson __rte_internal
130199a2dd95SBruce Richardson int rte_eth_dev_is_rx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id);
130299a2dd95SBruce Richardson 
130399a2dd95SBruce Richardson /**
130499a2dd95SBruce Richardson  * @internal
130599a2dd95SBruce Richardson  * Check if the selected Tx queue is hairpin queue.
130699a2dd95SBruce Richardson  *
130799a2dd95SBruce Richardson  * @param dev
130899a2dd95SBruce Richardson  *  Pointer to the selected device.
130999a2dd95SBruce Richardson  * @param queue_id
131099a2dd95SBruce Richardson  *  The selected queue.
131199a2dd95SBruce Richardson  *
131299a2dd95SBruce Richardson  * @return
131399a2dd95SBruce Richardson  *   - (1) if the queue is hairpin queue, 0 otherwise.
131499a2dd95SBruce Richardson  */
131599a2dd95SBruce Richardson __rte_internal
131699a2dd95SBruce Richardson int rte_eth_dev_is_tx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id);
131799a2dd95SBruce Richardson 
131899a2dd95SBruce Richardson /**
131999a2dd95SBruce Richardson  * @internal
132099a2dd95SBruce Richardson  * Returns a ethdev slot specified by the unique identifier name.
132199a2dd95SBruce Richardson  *
132299a2dd95SBruce Richardson  * @param	name
132399a2dd95SBruce Richardson  *  The pointer to the Unique identifier name for each Ethernet device
132499a2dd95SBruce Richardson  * @return
132599a2dd95SBruce Richardson  *   - The pointer to the ethdev slot, on success. NULL on error
132699a2dd95SBruce Richardson  */
132799a2dd95SBruce Richardson __rte_internal
132899a2dd95SBruce Richardson struct rte_eth_dev *rte_eth_dev_allocated(const char *name);
132999a2dd95SBruce Richardson 
133099a2dd95SBruce Richardson /**
133199a2dd95SBruce Richardson  * @internal
13320d9f56a8SAndrew Rybchenko  * Allocates a new ethdev slot for an Ethernet device and returns the pointer
133399a2dd95SBruce Richardson  * to that slot for the driver to use.
133499a2dd95SBruce Richardson  *
133599a2dd95SBruce Richardson  * @param	name	Unique identifier name for each Ethernet device
133699a2dd95SBruce Richardson  * @return
133799a2dd95SBruce Richardson  *   - Slot in the rte_dev_devices array for a new device;
133899a2dd95SBruce Richardson  */
133999a2dd95SBruce Richardson __rte_internal
134099a2dd95SBruce Richardson struct rte_eth_dev *rte_eth_dev_allocate(const char *name);
134199a2dd95SBruce Richardson 
134299a2dd95SBruce Richardson /**
134399a2dd95SBruce Richardson  * @internal
134499a2dd95SBruce Richardson  * Attach to the ethdev already initialized by the primary
134599a2dd95SBruce Richardson  * process.
134699a2dd95SBruce Richardson  *
134799a2dd95SBruce Richardson  * @param       name    Ethernet device's name.
134899a2dd95SBruce Richardson  * @return
134999a2dd95SBruce Richardson  *   - Success: Slot in the rte_dev_devices array for attached
135099a2dd95SBruce Richardson  *        device.
135199a2dd95SBruce Richardson  *   - Error: Null pointer.
135299a2dd95SBruce Richardson  */
135399a2dd95SBruce Richardson __rte_internal
135499a2dd95SBruce Richardson struct rte_eth_dev *rte_eth_dev_attach_secondary(const char *name);
135599a2dd95SBruce Richardson 
135699a2dd95SBruce Richardson /**
135799a2dd95SBruce Richardson  * @internal
135899a2dd95SBruce Richardson  * Notify RTE_ETH_EVENT_DESTROY and release the specified ethdev port.
135999a2dd95SBruce Richardson  *
136099a2dd95SBruce Richardson  * The following PMD-managed data fields will be freed:
136199a2dd95SBruce Richardson  *   - dev_private
136299a2dd95SBruce Richardson  *   - mac_addrs
136399a2dd95SBruce Richardson  *   - hash_mac_addrs
136499a2dd95SBruce Richardson  * If one of these fields should not be freed,
136599a2dd95SBruce Richardson  * it must be reset to NULL by the PMD, typically in dev_close method.
136699a2dd95SBruce Richardson  *
136799a2dd95SBruce Richardson  * @param eth_dev
136899a2dd95SBruce Richardson  * Device to be detached.
136999a2dd95SBruce Richardson  * @return
137099a2dd95SBruce Richardson  *   - 0 on success, negative on error
137199a2dd95SBruce Richardson  */
137299a2dd95SBruce Richardson __rte_internal
137399a2dd95SBruce Richardson int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev);
137499a2dd95SBruce Richardson 
137599a2dd95SBruce Richardson /**
137699a2dd95SBruce Richardson  * @internal
137799a2dd95SBruce Richardson  * Release device queues and clear its configuration to force the user
137899a2dd95SBruce Richardson  * application to reconfigure it. It is for internal use only.
137999a2dd95SBruce Richardson  *
138099a2dd95SBruce Richardson  * @param dev
138199a2dd95SBruce Richardson  *  Pointer to struct rte_eth_dev.
138299a2dd95SBruce Richardson  *
138399a2dd95SBruce Richardson  * @return
138499a2dd95SBruce Richardson  *  void
138599a2dd95SBruce Richardson  */
138699a2dd95SBruce Richardson __rte_internal
138799a2dd95SBruce Richardson void rte_eth_dev_internal_reset(struct rte_eth_dev *dev);
138899a2dd95SBruce Richardson 
138999a2dd95SBruce Richardson /**
139099a2dd95SBruce Richardson  * @internal Executes all the user application registered callbacks for
139199a2dd95SBruce Richardson  * the specific device. It is for DPDK internal user only. User
139299a2dd95SBruce Richardson  * application should not call it directly.
139399a2dd95SBruce Richardson  *
139499a2dd95SBruce Richardson  * @param dev
139599a2dd95SBruce Richardson  *  Pointer to struct rte_eth_dev.
139699a2dd95SBruce Richardson  * @param event
139799a2dd95SBruce Richardson  *  Eth device interrupt event type.
139899a2dd95SBruce Richardson  * @param ret_param
139999a2dd95SBruce Richardson  *  To pass data back to user application.
140099a2dd95SBruce Richardson  *  This allows the user application to decide if a particular function
140199a2dd95SBruce Richardson  *  is permitted or not.
140299a2dd95SBruce Richardson  *
140399a2dd95SBruce Richardson  * @return
140499a2dd95SBruce Richardson  *  int
140599a2dd95SBruce Richardson  */
140699a2dd95SBruce Richardson __rte_internal
140799a2dd95SBruce Richardson int rte_eth_dev_callback_process(struct rte_eth_dev *dev,
140899a2dd95SBruce Richardson 		enum rte_eth_event_type event, void *ret_param);
140999a2dd95SBruce Richardson 
141099a2dd95SBruce Richardson /**
141199a2dd95SBruce Richardson  * @internal
141299a2dd95SBruce Richardson  * This is the last step of device probing.
141399a2dd95SBruce Richardson  * It must be called after a port is allocated and initialized successfully.
141499a2dd95SBruce Richardson  *
141599a2dd95SBruce Richardson  * The notification RTE_ETH_EVENT_NEW is sent to other entities
141699a2dd95SBruce Richardson  * (libraries and applications).
141799a2dd95SBruce Richardson  * The state is set as RTE_ETH_DEV_ATTACHED.
141899a2dd95SBruce Richardson  *
141999a2dd95SBruce Richardson  * @param dev
142099a2dd95SBruce Richardson  *  New ethdev port.
142199a2dd95SBruce Richardson  */
142299a2dd95SBruce Richardson __rte_internal
142399a2dd95SBruce Richardson void rte_eth_dev_probing_finish(struct rte_eth_dev *dev);
142499a2dd95SBruce Richardson 
142599a2dd95SBruce Richardson /**
142699a2dd95SBruce Richardson  * Create memzone for HW rings.
142799a2dd95SBruce Richardson  * malloc can't be used as the physical address is needed.
142899a2dd95SBruce Richardson  * If the memzone is already created, then this function returns a ptr
142999a2dd95SBruce Richardson  * to the old one.
143099a2dd95SBruce Richardson  *
143199a2dd95SBruce Richardson  * @param eth_dev
143299a2dd95SBruce Richardson  *   The *eth_dev* pointer is the address of the *rte_eth_dev* structure
143399a2dd95SBruce Richardson  * @param name
143499a2dd95SBruce Richardson  *   The name of the memory zone
143599a2dd95SBruce Richardson  * @param queue_id
143699a2dd95SBruce Richardson  *   The index of the queue to add to name
143799a2dd95SBruce Richardson  * @param size
143899a2dd95SBruce Richardson  *   The sizeof of the memory area
143999a2dd95SBruce Richardson  * @param align
144099a2dd95SBruce Richardson  *   Alignment for resulting memzone. Must be a power of 2.
144199a2dd95SBruce Richardson  * @param socket_id
144299a2dd95SBruce Richardson  *   The *socket_id* argument is the socket identifier in case of NUMA.
144399a2dd95SBruce Richardson  */
144499a2dd95SBruce Richardson __rte_internal
144599a2dd95SBruce Richardson const struct rte_memzone *
144699a2dd95SBruce Richardson rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name,
144799a2dd95SBruce Richardson 			 uint16_t queue_id, size_t size,
144899a2dd95SBruce Richardson 			 unsigned align, int socket_id);
144999a2dd95SBruce Richardson 
145099a2dd95SBruce Richardson /**
145199a2dd95SBruce Richardson  * Free previously allocated memzone for HW rings.
145299a2dd95SBruce Richardson  *
145399a2dd95SBruce Richardson  * @param eth_dev
145499a2dd95SBruce Richardson  *   The *eth_dev* pointer is the address of the *rte_eth_dev* structure
145599a2dd95SBruce Richardson  * @param name
145699a2dd95SBruce Richardson  *   The name of the memory zone
145799a2dd95SBruce Richardson  * @param queue_id
145899a2dd95SBruce Richardson  *   The index of the queue to add to name
145999a2dd95SBruce Richardson  * @return
146099a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
146199a2dd95SBruce Richardson  */
146299a2dd95SBruce Richardson __rte_internal
146399a2dd95SBruce Richardson int
146499a2dd95SBruce Richardson rte_eth_dma_zone_free(const struct rte_eth_dev *eth_dev, const char *name,
146599a2dd95SBruce Richardson 		 uint16_t queue_id);
146699a2dd95SBruce Richardson 
146799a2dd95SBruce Richardson /**
146899a2dd95SBruce Richardson  * @internal
146999a2dd95SBruce Richardson  * Atomically set the link status for the specific device.
147099a2dd95SBruce Richardson  * It is for use by DPDK device driver use only.
147199a2dd95SBruce Richardson  * User applications should not call it
147299a2dd95SBruce Richardson  *
147399a2dd95SBruce Richardson  * @param dev
147499a2dd95SBruce Richardson  *  Pointer to struct rte_eth_dev.
147599a2dd95SBruce Richardson  * @param link
147699a2dd95SBruce Richardson  *  New link status value.
147799a2dd95SBruce Richardson  * @return
147899a2dd95SBruce Richardson  *  Same convention as eth_link_update operation.
147999a2dd95SBruce Richardson  *  0   if link up status has changed
148099a2dd95SBruce Richardson  *  -1  if link up status was unchanged
148199a2dd95SBruce Richardson  */
148299a2dd95SBruce Richardson static inline int
rte_eth_linkstatus_set(struct rte_eth_dev * dev,const struct rte_eth_link * new_link)148399a2dd95SBruce Richardson rte_eth_linkstatus_set(struct rte_eth_dev *dev,
148499a2dd95SBruce Richardson 		       const struct rte_eth_link *new_link)
148599a2dd95SBruce Richardson {
148699a2dd95SBruce Richardson 	uint64_t *dev_link = (uint64_t *)&(dev->data->dev_link);
148799a2dd95SBruce Richardson 	union {
148899a2dd95SBruce Richardson 		uint64_t val64;
148999a2dd95SBruce Richardson 		struct rte_eth_link link;
149099a2dd95SBruce Richardson 	} orig;
149199a2dd95SBruce Richardson 
149299a2dd95SBruce Richardson 	RTE_BUILD_BUG_ON(sizeof(*new_link) != sizeof(uint64_t));
149399a2dd95SBruce Richardson 
149499a2dd95SBruce Richardson 	orig.val64 = __atomic_exchange_n(dev_link, *(const uint64_t *)new_link,
149599a2dd95SBruce Richardson 					__ATOMIC_SEQ_CST);
149699a2dd95SBruce Richardson 
149799a2dd95SBruce Richardson 	return (orig.link.link_status == new_link->link_status) ? -1 : 0;
149899a2dd95SBruce Richardson }
149999a2dd95SBruce Richardson 
150099a2dd95SBruce Richardson /**
150199a2dd95SBruce Richardson  * @internal
150299a2dd95SBruce Richardson  * Atomically get the link speed and status.
150399a2dd95SBruce Richardson  *
150499a2dd95SBruce Richardson  * @param dev
150599a2dd95SBruce Richardson  *  Pointer to struct rte_eth_dev.
150699a2dd95SBruce Richardson  * @param link
150799a2dd95SBruce Richardson  *  link status value.
150899a2dd95SBruce Richardson  */
150999a2dd95SBruce Richardson static inline void
rte_eth_linkstatus_get(const struct rte_eth_dev * dev,struct rte_eth_link * link)151099a2dd95SBruce Richardson rte_eth_linkstatus_get(const struct rte_eth_dev *dev,
151199a2dd95SBruce Richardson 		       struct rte_eth_link *link)
151299a2dd95SBruce Richardson {
151399a2dd95SBruce Richardson 	uint64_t *src = (uint64_t *)&(dev->data->dev_link);
151499a2dd95SBruce Richardson 	uint64_t *dst = (uint64_t *)link;
151599a2dd95SBruce Richardson 
151699a2dd95SBruce Richardson 	RTE_BUILD_BUG_ON(sizeof(*link) != sizeof(uint64_t));
151799a2dd95SBruce Richardson 
151899a2dd95SBruce Richardson 	*dst = __atomic_load_n(src, __ATOMIC_SEQ_CST);
151999a2dd95SBruce Richardson }
152099a2dd95SBruce Richardson 
152199a2dd95SBruce Richardson /**
1522a41f593fSFerruh Yigit  * @internal
1523a41f593fSFerruh Yigit  * Dummy DPDK callback for Rx/Tx packet burst.
1524a41f593fSFerruh Yigit  *
1525a41f593fSFerruh Yigit  * @param queue
1526a41f593fSFerruh Yigit  *  Pointer to Rx/Tx queue
1527a41f593fSFerruh Yigit  * @param pkts
1528a41f593fSFerruh Yigit  *  Packet array
1529a41f593fSFerruh Yigit  * @param nb_pkts
1530a41f593fSFerruh Yigit  *  Number of packets in packet array
1531a41f593fSFerruh Yigit  */
1532a41f593fSFerruh Yigit __rte_internal
1533a41f593fSFerruh Yigit uint16_t
1534a41f593fSFerruh Yigit rte_eth_pkt_burst_dummy(void *queue __rte_unused,
1535a41f593fSFerruh Yigit 		struct rte_mbuf **pkts __rte_unused,
1536a41f593fSFerruh Yigit 		uint16_t nb_pkts __rte_unused);
1537a41f593fSFerruh Yigit 
1538a41f593fSFerruh Yigit /**
153999a2dd95SBruce Richardson  * Allocate an unique switch domain identifier.
154099a2dd95SBruce Richardson  *
154199a2dd95SBruce Richardson  * A pool of switch domain identifiers which can be allocated on request. This
154299a2dd95SBruce Richardson  * will enabled devices which support the concept of switch domains to request
15435906be5aSAndrew Rybchenko  * a switch domain ID which is guaranteed to be unique from other devices
154499a2dd95SBruce Richardson  * running in the same process.
154599a2dd95SBruce Richardson  *
154699a2dd95SBruce Richardson  * @param domain_id
154799a2dd95SBruce Richardson  *  switch domain identifier parameter to pass back to application
154899a2dd95SBruce Richardson  *
154999a2dd95SBruce Richardson  * @return
155099a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
155199a2dd95SBruce Richardson  */
155299a2dd95SBruce Richardson __rte_internal
155399a2dd95SBruce Richardson int
155499a2dd95SBruce Richardson rte_eth_switch_domain_alloc(uint16_t *domain_id);
155599a2dd95SBruce Richardson 
155699a2dd95SBruce Richardson /**
155799a2dd95SBruce Richardson  * Free switch domain.
155899a2dd95SBruce Richardson  *
155999a2dd95SBruce Richardson  * Return a switch domain identifier to the pool of free identifiers after it is
156099a2dd95SBruce Richardson  * no longer in use by device.
156199a2dd95SBruce Richardson  *
156299a2dd95SBruce Richardson  * @param domain_id
156399a2dd95SBruce Richardson  *  switch domain identifier to free
156499a2dd95SBruce Richardson  *
156599a2dd95SBruce Richardson  * @return
156699a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
156799a2dd95SBruce Richardson  */
156899a2dd95SBruce Richardson __rte_internal
156999a2dd95SBruce Richardson int
157099a2dd95SBruce Richardson rte_eth_switch_domain_free(uint16_t domain_id);
157199a2dd95SBruce Richardson 
157299a2dd95SBruce Richardson /**
157399a2dd95SBruce Richardson  * Generic Ethernet device arguments
157499a2dd95SBruce Richardson  *
157599a2dd95SBruce Richardson  * One type of representor each structure.
157699a2dd95SBruce Richardson  */
157799a2dd95SBruce Richardson struct rte_eth_devargs {
157899a2dd95SBruce Richardson 	uint16_t mh_controllers[RTE_MAX_MULTI_HOST_CTRLS];
157999a2dd95SBruce Richardson 	/** controller/s number in case of multi-host */
158099a2dd95SBruce Richardson 	uint16_t nb_mh_controllers;
158199a2dd95SBruce Richardson 	/** number of controllers in multi-host controllers field */
158299a2dd95SBruce Richardson 	uint16_t ports[RTE_MAX_ETHPORTS];
158399a2dd95SBruce Richardson 	/** port/s number to enable on a multi-port single function */
158499a2dd95SBruce Richardson 	uint16_t nb_ports;
158599a2dd95SBruce Richardson 	/** number of ports in ports field */
158699a2dd95SBruce Richardson 	uint16_t representor_ports[RTE_MAX_ETHPORTS];
158799a2dd95SBruce Richardson 	/** representor port/s identifier to enable on device */
158899a2dd95SBruce Richardson 	uint16_t nb_representor_ports;
158999a2dd95SBruce Richardson 	/** number of ports in representor port field */
159099a2dd95SBruce Richardson 	enum rte_eth_representor_type type; /* type of representor */
159199a2dd95SBruce Richardson };
159299a2dd95SBruce Richardson 
159399a2dd95SBruce Richardson /**
159499a2dd95SBruce Richardson  * PMD helper function to get representor ID from location detail.
159599a2dd95SBruce Richardson  *
159699a2dd95SBruce Richardson  * Get representor ID from controller, pf and (sf or vf).
159799a2dd95SBruce Richardson  * The mapping is retrieved from rte_eth_representor_info_get().
159899a2dd95SBruce Richardson  *
159999a2dd95SBruce Richardson  * For backward compatibility, if no representor info, direct
160099a2dd95SBruce Richardson  * map legacy VF (no controller and pf).
160199a2dd95SBruce Richardson  *
1602ff4e52efSViacheslav Galaktionov  * @param port_id
1603ff4e52efSViacheslav Galaktionov  *  Port ID of the backing device.
160499a2dd95SBruce Richardson  * @param type
160599a2dd95SBruce Richardson  *  Representor type.
160699a2dd95SBruce Richardson  * @param controller
160799a2dd95SBruce Richardson  *  Controller ID, -1 if unspecified.
160899a2dd95SBruce Richardson  * @param pf
160999a2dd95SBruce Richardson  *  PF port ID, -1 if unspecified.
161099a2dd95SBruce Richardson  * @param representor_port
161199a2dd95SBruce Richardson  *  VF or SF representor port number, -1 if unspecified.
161299a2dd95SBruce Richardson  * @param repr_id
161399a2dd95SBruce Richardson  *  Pointer to output representor ID.
161499a2dd95SBruce Richardson  *
161599a2dd95SBruce Richardson  * @return
161699a2dd95SBruce Richardson  *  Negative errno value on error, 0 on success.
161799a2dd95SBruce Richardson  */
161899a2dd95SBruce Richardson __rte_internal
161999a2dd95SBruce Richardson int
1620ff4e52efSViacheslav Galaktionov rte_eth_representor_id_get(uint16_t port_id,
162199a2dd95SBruce Richardson 			   enum rte_eth_representor_type type,
162299a2dd95SBruce Richardson 			   int controller, int pf, int representor_port,
162399a2dd95SBruce Richardson 			   uint16_t *repr_id);
162499a2dd95SBruce Richardson 
162599a2dd95SBruce Richardson /**
162699a2dd95SBruce Richardson  * PMD helper function to parse ethdev arguments
162799a2dd95SBruce Richardson  *
162899a2dd95SBruce Richardson  * @param devargs
162999a2dd95SBruce Richardson  *  device arguments
163099a2dd95SBruce Richardson  * @param eth_devargs
163199a2dd95SBruce Richardson  *  parsed ethdev specific arguments.
163299a2dd95SBruce Richardson  *
163399a2dd95SBruce Richardson  * @return
163499a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
163599a2dd95SBruce Richardson  */
163699a2dd95SBruce Richardson __rte_internal
163799a2dd95SBruce Richardson int
163899a2dd95SBruce Richardson rte_eth_devargs_parse(const char *devargs, struct rte_eth_devargs *eth_devargs);
163999a2dd95SBruce Richardson 
164099a2dd95SBruce Richardson 
164199a2dd95SBruce Richardson typedef int (*ethdev_init_t)(struct rte_eth_dev *ethdev, void *init_params);
164299a2dd95SBruce Richardson typedef int (*ethdev_bus_specific_init)(struct rte_eth_dev *ethdev,
164399a2dd95SBruce Richardson 	void *bus_specific_init_params);
164499a2dd95SBruce Richardson 
164599a2dd95SBruce Richardson /**
164699a2dd95SBruce Richardson  * PMD helper function for the creation of a new ethdev ports.
164799a2dd95SBruce Richardson  *
164899a2dd95SBruce Richardson  * @param device
164999a2dd95SBruce Richardson  *  rte_device handle.
165099a2dd95SBruce Richardson  * @param name
165199a2dd95SBruce Richardson  *  port name.
165299a2dd95SBruce Richardson  * @param priv_data_size
165399a2dd95SBruce Richardson  *  size of private data required for port.
165499a2dd95SBruce Richardson  * @param bus_specific_init
165599a2dd95SBruce Richardson  *  port bus specific initialisation callback function
165699a2dd95SBruce Richardson  * @param bus_init_params
165799a2dd95SBruce Richardson  *  port bus specific initialisation parameters
165899a2dd95SBruce Richardson  * @param ethdev_init
165999a2dd95SBruce Richardson  *  device specific port initialization callback function
166099a2dd95SBruce Richardson  * @param init_params
166199a2dd95SBruce Richardson  *  port initialisation parameters
166299a2dd95SBruce Richardson  *
166399a2dd95SBruce Richardson  * @return
166499a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
166599a2dd95SBruce Richardson  */
166699a2dd95SBruce Richardson __rte_internal
166799a2dd95SBruce Richardson int
166899a2dd95SBruce Richardson rte_eth_dev_create(struct rte_device *device, const char *name,
166999a2dd95SBruce Richardson 	size_t priv_data_size,
167099a2dd95SBruce Richardson 	ethdev_bus_specific_init bus_specific_init, void *bus_init_params,
167199a2dd95SBruce Richardson 	ethdev_init_t ethdev_init, void *init_params);
167299a2dd95SBruce Richardson 
167399a2dd95SBruce Richardson 
167499a2dd95SBruce Richardson typedef int (*ethdev_uninit_t)(struct rte_eth_dev *ethdev);
167599a2dd95SBruce Richardson 
167699a2dd95SBruce Richardson /**
167799a2dd95SBruce Richardson  * PMD helper function for cleaning up the resources of a ethdev port on it's
167899a2dd95SBruce Richardson  * destruction.
167999a2dd95SBruce Richardson  *
168099a2dd95SBruce Richardson  * @param ethdev
168199a2dd95SBruce Richardson  *   ethdev handle of port.
168299a2dd95SBruce Richardson  * @param ethdev_uninit
168399a2dd95SBruce Richardson  *   device specific port un-initialise callback function
168499a2dd95SBruce Richardson  *
168599a2dd95SBruce Richardson  * @return
168699a2dd95SBruce Richardson  *   Negative errno value on error, 0 on success.
168799a2dd95SBruce Richardson  */
168899a2dd95SBruce Richardson __rte_internal
168999a2dd95SBruce Richardson int
169099a2dd95SBruce Richardson rte_eth_dev_destroy(struct rte_eth_dev *ethdev, ethdev_uninit_t ethdev_uninit);
169199a2dd95SBruce Richardson 
169299a2dd95SBruce Richardson /**
169399a2dd95SBruce Richardson  * @internal
169499a2dd95SBruce Richardson  * Pass the current hairpin queue HW and/or SW information to the peer queue
169599a2dd95SBruce Richardson  * and fetch back the information of the peer queue.
169699a2dd95SBruce Richardson  *
169799a2dd95SBruce Richardson  * @param peer_port
169899a2dd95SBruce Richardson  *  Peer port identifier of the Ethernet device.
169999a2dd95SBruce Richardson  * @param peer_queue
170099a2dd95SBruce Richardson  *  Peer queue index of the port.
170199a2dd95SBruce Richardson  * @param cur_info
170299a2dd95SBruce Richardson  *  Pointer to the current information structure.
170399a2dd95SBruce Richardson  * @param peer_info
170499a2dd95SBruce Richardson  *  Pointer to the peer information, output.
170599a2dd95SBruce Richardson  * @param direction
170699a2dd95SBruce Richardson  *  Direction to pass the information.
170799a2dd95SBruce Richardson  *  positive - pass Tx queue information and get peer Rx queue information
170899a2dd95SBruce Richardson  *  zero - pass Rx queue information and get peer Tx queue information
170999a2dd95SBruce Richardson  *
171099a2dd95SBruce Richardson  * @return
171199a2dd95SBruce Richardson  *  Negative errno value on error, 0 on success.
171299a2dd95SBruce Richardson  */
171399a2dd95SBruce Richardson __rte_internal
171499a2dd95SBruce Richardson int
171599a2dd95SBruce Richardson rte_eth_hairpin_queue_peer_update(uint16_t peer_port, uint16_t peer_queue,
171699a2dd95SBruce Richardson 				  struct rte_hairpin_peer_info *cur_info,
171799a2dd95SBruce Richardson 				  struct rte_hairpin_peer_info *peer_info,
171899a2dd95SBruce Richardson 				  uint32_t direction);
171999a2dd95SBruce Richardson 
172099a2dd95SBruce Richardson /**
172199a2dd95SBruce Richardson  * @internal
172299a2dd95SBruce Richardson  * Configure current hairpin queue with the peer information fetched to create
172399a2dd95SBruce Richardson  * the connection (bind) with peer queue in the specified direction.
172499a2dd95SBruce Richardson  * This function might need to be called twice to fully create the connections.
172599a2dd95SBruce Richardson  *
172699a2dd95SBruce Richardson  * @param cur_port
172799a2dd95SBruce Richardson  *  Current port identifier of the Ethernet device.
172899a2dd95SBruce Richardson  * @param cur_queue
172999a2dd95SBruce Richardson  *  Current queue index of the port.
173099a2dd95SBruce Richardson  * @param peer_info
173199a2dd95SBruce Richardson  *  Pointer to the peer information, input.
173299a2dd95SBruce Richardson  * @param direction
173399a2dd95SBruce Richardson  *  Direction to create the connection.
173499a2dd95SBruce Richardson  *  positive - bind current Tx queue to peer Rx queue
173599a2dd95SBruce Richardson  *  zero - bind current Rx queue to peer Tx queue
173699a2dd95SBruce Richardson  *
173799a2dd95SBruce Richardson  * @return
173899a2dd95SBruce Richardson  *  Negative errno value on error, 0 on success.
173999a2dd95SBruce Richardson  */
174099a2dd95SBruce Richardson __rte_internal
174199a2dd95SBruce Richardson int
174299a2dd95SBruce Richardson rte_eth_hairpin_queue_peer_bind(uint16_t cur_port, uint16_t cur_queue,
174399a2dd95SBruce Richardson 				struct rte_hairpin_peer_info *peer_info,
174499a2dd95SBruce Richardson 				uint32_t direction);
174599a2dd95SBruce Richardson 
174699a2dd95SBruce Richardson /**
174799a2dd95SBruce Richardson  * @internal
1748961fb402SKumara Parameshwaran  * Get rte_eth_dev from device name. The device name should be specified
1749961fb402SKumara Parameshwaran  * as below:
1750961fb402SKumara Parameshwaran  * - PCIe address (Domain:Bus:Device.Function), for example 0000:2:00.0
1751961fb402SKumara Parameshwaran  * - SoC device name, for example fsl-gmac0
1752961fb402SKumara Parameshwaran  * - vdev dpdk name, for example net_[pcap0|null0|tap0]
1753961fb402SKumara Parameshwaran  *
1754961fb402SKumara Parameshwaran  * @param name
1755961fb402SKumara Parameshwaran  *   PCI address or name of the device
1756961fb402SKumara Parameshwaran  * @return
1757961fb402SKumara Parameshwaran  *   - rte_eth_dev if successful
1758961fb402SKumara Parameshwaran  *   - NULL on failure
1759961fb402SKumara Parameshwaran  */
1760961fb402SKumara Parameshwaran __rte_internal
1761961fb402SKumara Parameshwaran struct rte_eth_dev*
1762961fb402SKumara Parameshwaran rte_eth_dev_get_by_name(const char *name);
1763961fb402SKumara Parameshwaran 
1764961fb402SKumara Parameshwaran /**
1765961fb402SKumara Parameshwaran  * @internal
176699a2dd95SBruce Richardson  * Reset the current queue state and configuration to disconnect (unbind) it
176799a2dd95SBruce Richardson  * from the peer queue.
176899a2dd95SBruce Richardson  * This function might need to be called twice to disconnect each other.
176999a2dd95SBruce Richardson  *
177099a2dd95SBruce Richardson  * @param cur_port
177199a2dd95SBruce Richardson  *  Current port identifier of the Ethernet device.
177299a2dd95SBruce Richardson  * @param cur_queue
177399a2dd95SBruce Richardson  *  Current queue index of the port.
177499a2dd95SBruce Richardson  * @param direction
177599a2dd95SBruce Richardson  *  Direction to destroy the connection.
177699a2dd95SBruce Richardson  *  positive - unbind current Tx queue from peer Rx queue
177799a2dd95SBruce Richardson  *  zero - unbind current Rx queue from peer Tx queue
177899a2dd95SBruce Richardson  *
177999a2dd95SBruce Richardson  * @return
178099a2dd95SBruce Richardson  *  Negative errno value on error, 0 on success.
178199a2dd95SBruce Richardson  */
178299a2dd95SBruce Richardson __rte_internal
178399a2dd95SBruce Richardson int
178499a2dd95SBruce Richardson rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t cur_queue,
178599a2dd95SBruce Richardson 				  uint32_t direction);
178699a2dd95SBruce Richardson 
17873c059b2cSAkhil Goyal /**
17883c059b2cSAkhil Goyal  * @internal
17893c059b2cSAkhil Goyal  * Register mbuf dynamic field and flag for IP reassembly incomplete case.
17903c059b2cSAkhil Goyal  */
17913c059b2cSAkhil Goyal __rte_internal
17923c059b2cSAkhil Goyal int
17933c059b2cSAkhil Goyal rte_eth_ip_reassembly_dynfield_register(int *field_offset, int *flag);
17943c059b2cSAkhil Goyal 
179599a2dd95SBruce Richardson 
179699a2dd95SBruce Richardson /*
179799a2dd95SBruce Richardson  * Legacy ethdev API used internally by drivers.
179899a2dd95SBruce Richardson  */
179999a2dd95SBruce Richardson 
180099a2dd95SBruce Richardson enum rte_filter_type {
180199a2dd95SBruce Richardson 	RTE_ETH_FILTER_NONE = 0,
180299a2dd95SBruce Richardson 	RTE_ETH_FILTER_ETHERTYPE,
180399a2dd95SBruce Richardson 	RTE_ETH_FILTER_FLEXIBLE,
180499a2dd95SBruce Richardson 	RTE_ETH_FILTER_SYN,
180599a2dd95SBruce Richardson 	RTE_ETH_FILTER_NTUPLE,
180699a2dd95SBruce Richardson 	RTE_ETH_FILTER_TUNNEL,
180799a2dd95SBruce Richardson 	RTE_ETH_FILTER_FDIR,
180899a2dd95SBruce Richardson 	RTE_ETH_FILTER_HASH,
180999a2dd95SBruce Richardson 	RTE_ETH_FILTER_L2_TUNNEL,
181099a2dd95SBruce Richardson };
181199a2dd95SBruce Richardson 
181299a2dd95SBruce Richardson /**
181399a2dd95SBruce Richardson  * Define all structures for Ethertype Filter type.
181499a2dd95SBruce Richardson  */
181599a2dd95SBruce Richardson 
181699a2dd95SBruce Richardson #define RTE_ETHTYPE_FLAGS_MAC    0x0001 /**< If set, compare mac */
181799a2dd95SBruce Richardson #define RTE_ETHTYPE_FLAGS_DROP   0x0002 /**< If set, drop packet when match */
181899a2dd95SBruce Richardson 
181999a2dd95SBruce Richardson /**
182099a2dd95SBruce Richardson  * A structure used to define the ethertype filter entry
182199a2dd95SBruce Richardson  * to support RTE_ETH_FILTER_ETHERTYPE data representation.
182299a2dd95SBruce Richardson  */
182399a2dd95SBruce Richardson struct rte_eth_ethertype_filter {
182455645ee6SAndrew Rybchenko 	struct rte_ether_addr mac_addr;   /**< Mac address to match */
182599a2dd95SBruce Richardson 	uint16_t ether_type;          /**< Ether type to match */
182699a2dd95SBruce Richardson 	uint16_t flags;               /**< Flags from RTE_ETHTYPE_FLAGS_* */
182799a2dd95SBruce Richardson 	uint16_t queue;               /**< Queue assigned to when match */
182899a2dd95SBruce Richardson };
182999a2dd95SBruce Richardson 
183099a2dd95SBruce Richardson /**
183199a2dd95SBruce Richardson  * A structure used to define the TCP syn filter entry
183299a2dd95SBruce Richardson  * to support RTE_ETH_FILTER_SYN data representation.
183399a2dd95SBruce Richardson  */
183499a2dd95SBruce Richardson struct rte_eth_syn_filter {
183555645ee6SAndrew Rybchenko 	/** 1 - higher priority than other filters, 0 - lower priority */
183699a2dd95SBruce Richardson 	uint8_t hig_pri;
183799a2dd95SBruce Richardson 	uint16_t queue;      /**< Queue assigned to when match */
183899a2dd95SBruce Richardson };
183999a2dd95SBruce Richardson 
184099a2dd95SBruce Richardson /**
184199a2dd95SBruce Richardson  * filter type of tunneling packet
184299a2dd95SBruce Richardson  */
1843295968d1SFerruh Yigit #define RTE_ETH_TUNNEL_FILTER_OMAC  0x01 /**< filter by outer MAC addr */
1844295968d1SFerruh Yigit #define RTE_ETH_TUNNEL_FILTER_OIP   0x02 /**< filter by outer IP Addr */
1845295968d1SFerruh Yigit #define RTE_ETH_TUNNEL_FILTER_TENID 0x04 /**< filter by tenant ID */
1846295968d1SFerruh Yigit #define RTE_ETH_TUNNEL_FILTER_IMAC  0x08 /**< filter by inner MAC addr */
1847295968d1SFerruh Yigit #define RTE_ETH_TUNNEL_FILTER_IVLAN 0x10 /**< filter by inner VLAN ID */
1848295968d1SFerruh Yigit #define RTE_ETH_TUNNEL_FILTER_IIP   0x20 /**< filter by inner IP addr */
184999a2dd95SBruce Richardson 
1850295968d1SFerruh Yigit #define RTE_ETH_TUNNEL_FILTER_IMAC_IVLAN (RTE_ETH_TUNNEL_FILTER_IMAC | \
1851295968d1SFerruh Yigit 					  RTE_ETH_TUNNEL_FILTER_IVLAN)
1852295968d1SFerruh Yigit #define RTE_ETH_TUNNEL_FILTER_IMAC_IVLAN_TENID (RTE_ETH_TUNNEL_FILTER_IMAC | \
1853295968d1SFerruh Yigit 						RTE_ETH_TUNNEL_FILTER_IVLAN | \
1854295968d1SFerruh Yigit 						RTE_ETH_TUNNEL_FILTER_TENID)
1855295968d1SFerruh Yigit #define RTE_ETH_TUNNEL_FILTER_IMAC_TENID (RTE_ETH_TUNNEL_FILTER_IMAC | \
1856295968d1SFerruh Yigit 					  RTE_ETH_TUNNEL_FILTER_TENID)
1857295968d1SFerruh Yigit #define RTE_ETH_TUNNEL_FILTER_OMAC_TENID_IMAC (RTE_ETH_TUNNEL_FILTER_OMAC | \
1858295968d1SFerruh Yigit 					       RTE_ETH_TUNNEL_FILTER_TENID | \
1859295968d1SFerruh Yigit 					       RTE_ETH_TUNNEL_FILTER_IMAC)
186099a2dd95SBruce Richardson 
186199a2dd95SBruce Richardson /**
186299a2dd95SBruce Richardson  *  Select IPv4 or IPv6 for tunnel filters.
186399a2dd95SBruce Richardson  */
186499a2dd95SBruce Richardson enum rte_tunnel_iptype {
186555645ee6SAndrew Rybchenko 	RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4 */
186655645ee6SAndrew Rybchenko 	RTE_TUNNEL_IPTYPE_IPV6,     /**< IPv6 */
186799a2dd95SBruce Richardson };
186899a2dd95SBruce Richardson 
186999a2dd95SBruce Richardson /**
187099a2dd95SBruce Richardson  * Tunneling Packet filter configuration.
187199a2dd95SBruce Richardson  */
187299a2dd95SBruce Richardson struct rte_eth_tunnel_filter_conf {
187355645ee6SAndrew Rybchenko 	struct rte_ether_addr outer_mac;    /**< Outer MAC address to match */
187455645ee6SAndrew Rybchenko 	struct rte_ether_addr inner_mac;    /**< Inner MAC address to match */
187555645ee6SAndrew Rybchenko 	uint16_t inner_vlan;                /**< Inner VLAN to match */
187655645ee6SAndrew Rybchenko 	enum rte_tunnel_iptype ip_type;     /**< IP address type */
187799a2dd95SBruce Richardson 	/**
187899a2dd95SBruce Richardson 	 * Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP
187999a2dd95SBruce Richardson 	 * is set in filter_type, or inner destination IP address to match
188099a2dd95SBruce Richardson 	 * if ETH_TUNNEL_FILTER_IIP is set in filter_type.
188199a2dd95SBruce Richardson 	 */
188299a2dd95SBruce Richardson 	union {
188355645ee6SAndrew Rybchenko 		uint32_t ipv4_addr;         /**< IPv4 address in big endian */
188455645ee6SAndrew Rybchenko 		uint32_t ipv6_addr[4];      /**< IPv6 address in big endian */
188599a2dd95SBruce Richardson 	} ip_addr;
188655645ee6SAndrew Rybchenko 	/** Flags from ETH_TUNNEL_FILTER_XX - see above */
188799a2dd95SBruce Richardson 	uint16_t filter_type;
188855645ee6SAndrew Rybchenko 	enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type */
188955645ee6SAndrew Rybchenko 	uint32_t tenant_id;     /**< Tenant ID to match: VNI, GRE key... */
189055645ee6SAndrew Rybchenko 	uint16_t queue_id;      /**< Queue assigned to if match */
189199a2dd95SBruce Richardson };
189299a2dd95SBruce Richardson 
1893dbf9fc1dSBrian Dooley #ifdef __cplusplus
1894dbf9fc1dSBrian Dooley }
1895dbf9fc1dSBrian Dooley #endif
1896dbf9fc1dSBrian Dooley 
189799a2dd95SBruce Richardson #endif /* _RTE_ETHDEV_DRIVER_H_ */
1898