1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Intel Corporation
5 #ifndef _RTE_ETHDEV_DRIVER_H_
6 #define _RTE_ETHDEV_DRIVER_H_
11 * RTE Ethernet Device PMD API
13 * These APIs for the use from Ethernet drivers, user applications shouldn't
18 #include <rte_ethdev.h>
22 * Structure used to hold information about the callbacks to be called for a
25 struct rte_eth_rxtx_callback {
26 struct rte_eth_rxtx_callback *next;
28 rte_rx_callback_fn rx;
29 rte_tx_callback_fn tx;
36 * The generic data structure associated with each Ethernet device.
38 * Pointers to burst-oriented packet receive and transmit functions are
39 * located at the beginning of the structure, along with the pointer to
40 * where all the data elements for the particular device are stored in shared
41 * memory. This split allows the function pointer and driver data to be per-
42 * process, while the actual configuration data for the device is shared.
45 eth_rx_burst_t rx_pkt_burst; /**< Pointer to PMD receive function */
46 eth_tx_burst_t tx_pkt_burst; /**< Pointer to PMD transmit function */
48 /** Pointer to PMD transmit prepare function */
49 eth_tx_prep_t tx_pkt_prepare;
50 /** Get the number of used Rx descriptors */
51 eth_rx_queue_count_t rx_queue_count;
52 /** Check the status of a Rx descriptor */
53 eth_rx_descriptor_status_t rx_descriptor_status;
54 /** Check the status of a Tx descriptor */
55 eth_tx_descriptor_status_t tx_descriptor_status;
58 * Device data that is shared between primary and secondary processes
60 struct rte_eth_dev_data *data;
61 void *process_private; /**< Pointer to per-process device data */
62 const struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */
63 struct rte_device *device; /**< Backing device */
64 struct rte_intr_handle *intr_handle; /**< Device interrupt handle */
66 /** User application callbacks for NIC interrupts */
67 struct rte_eth_dev_cb_list link_intr_cbs;
69 * User-supplied functions called from rx_burst to post-process
70 * received packets before passing them to the user
72 struct rte_eth_rxtx_callback *post_rx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
74 * User-supplied functions called from tx_burst to pre-process
75 * received packets before passing them to the driver for transmission
77 struct rte_eth_rxtx_callback *pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
79 enum rte_eth_dev_state state; /**< Flag indicating the port state */
80 void *security_ctx; /**< Context for security ops */
81 } __rte_cache_aligned;
83 struct rte_eth_dev_sriov;
84 struct rte_eth_dev_owner;
88 * The data part, with no function pointers, associated with each Ethernet
89 * device. This structure is safe to place in shared memory to be common
90 * among different processes in a multi-process configuration.
92 struct rte_eth_dev_data {
93 char name[RTE_ETH_NAME_MAX_LEN]; /**< Unique identifier name */
95 void **rx_queues; /**< Array of pointers to Rx queues */
96 void **tx_queues; /**< Array of pointers to Tx queues */
97 uint16_t nb_rx_queues; /**< Number of Rx queues */
98 uint16_t nb_tx_queues; /**< Number of Tx queues */
100 struct rte_eth_dev_sriov sriov; /**< SRIOV data */
102 /** PMD-specific private data. @see rte_eth_dev_release_port() */
105 struct rte_eth_link dev_link; /**< Link-level information & status */
106 struct rte_eth_conf dev_conf; /**< Configuration applied to device */
107 uint16_t mtu; /**< Maximum Transmission Unit */
109 /** Common Rx buffer size handled by all queues */
110 uint32_t min_rx_buf_size;
112 uint64_t rx_mbuf_alloc_failed; /**< Rx ring mbuf allocation failures */
114 /** Device Ethernet link address. @see rte_eth_dev_release_port() */
115 struct rte_ether_addr *mac_addrs;
116 /** Bitmap associating MAC addresses to pools */
117 uint64_t mac_pool_sel[RTE_ETH_NUM_RECEIVE_MAC_ADDR];
119 * Device Ethernet MAC addresses of hash filtering.
120 * @see rte_eth_dev_release_port()
122 struct rte_ether_addr *hash_mac_addrs;
124 uint16_t port_id; /**< Device [external] port identifier */
127 uint8_t /** Rx promiscuous mode ON(1) / OFF(0) */
129 /** Rx of scattered packets is ON(1) / OFF(0) */
131 /** Rx all multicast mode ON(1) / OFF(0) */
133 /** Device state: STARTED(1) / STOPPED(0) */
135 /** Rx LRO is ON(1) / OFF(0) */
138 * Indicates whether the device is configured:
139 * CONFIGURED(1) / NOT CONFIGURED(0)
143 /** Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0) */
144 uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
145 /** Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0) */
146 uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
148 uint32_t dev_flags; /**< Capabilities */
149 int numa_node; /**< NUMA node connection */
151 /** VLAN filter configuration */
152 struct rte_vlan_filter_conf vlan_filter_conf;
154 struct rte_eth_dev_owner owner; /**< The port owner */
157 * Switch-specific identifier.
158 * Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags.
160 uint16_t representor_id;
162 * Port ID of the backing device.
163 * This device will be used to query representor info and calculate
164 * representor IDs. Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags.
166 uint16_t backer_port_id;
168 pthread_mutex_t flow_ops_mutex; /**< rte_flow ops mutex */
169 } __rte_cache_aligned;
173 * The pool of *rte_eth_dev* structures. The size of the pool
174 * is configured at compile-time in the <rte_ethdev.c> file.
176 extern struct rte_eth_dev rte_eth_devices[];
178 /** @internal Declaration of the hairpin peer queue information structure. */
179 struct rte_hairpin_peer_info;
182 * Definitions of all functions exported by an Ethernet driver through the
183 * generic structure of type *eth_dev_ops* supplied in the *rte_eth_dev*
184 * structure associated with an Ethernet device.
187 /** @internal Ethernet device configuration. */
188 typedef int (*eth_dev_configure_t)(struct rte_eth_dev *dev);
190 /** @internal Function used to start a configured Ethernet device. */
191 typedef int (*eth_dev_start_t)(struct rte_eth_dev *dev);
193 /** @internal Function used to stop a configured Ethernet device. */
194 typedef int (*eth_dev_stop_t)(struct rte_eth_dev *dev);
196 /** @internal Function used to link up a configured Ethernet device. */
197 typedef int (*eth_dev_set_link_up_t)(struct rte_eth_dev *dev);
199 /** @internal Function used to link down a configured Ethernet device. */
200 typedef int (*eth_dev_set_link_down_t)(struct rte_eth_dev *dev);
202 /** @internal Function used to close a configured Ethernet device. */
203 typedef int (*eth_dev_close_t)(struct rte_eth_dev *dev);
205 /** @internal Function used to reset a configured Ethernet device. */
206 typedef int (*eth_dev_reset_t)(struct rte_eth_dev *dev);
208 /** @internal Function used to detect an Ethernet device removal. */
209 typedef int (*eth_is_removed_t)(struct rte_eth_dev *dev);
213 * Function used to enable the Rx promiscuous mode of an Ethernet device.
216 * ethdev handle of port.
219 * Negative errno value on error, 0 on success.
222 * Success, promiscuous mode is enabled.
224 * Promiscuous mode is not supported.
227 * @retval -E_RTE_SECONDARY
228 * Function was called from a secondary process instance and not supported.
230 * Attempt to enable promiscuous mode failed because of timeout.
232 * Failed to enable promiscuous mode.
234 typedef int (*eth_promiscuous_enable_t)(struct rte_eth_dev *dev);
238 * Function used to disable the Rx promiscuous mode of an Ethernet device.
241 * ethdev handle of port.
244 * Negative errno value on error, 0 on success.
247 * Success, promiscuous mode is disabled.
249 * Promiscuous mode disabling is not supported.
252 * @retval -E_RTE_SECONDARY
253 * Function was called from a secondary process instance and not supported.
255 * Attempt to disable promiscuous mode failed because of timeout.
257 * Failed to disable promiscuous mode.
259 typedef int (*eth_promiscuous_disable_t)(struct rte_eth_dev *dev);
263 * Enable the receipt of all multicast packets by an Ethernet device.
266 * ethdev handle of port.
269 * Negative errno value on error, 0 on success.
272 * Success, all-multicast mode is enabled.
274 * All-multicast mode is not supported.
277 * @retval -E_RTE_SECONDARY
278 * Function was called from a secondary process instance and not supported.
280 * Attempt to enable all-multicast mode failed because of timeout.
282 * Failed to enable all-multicast mode.
284 typedef int (*eth_allmulticast_enable_t)(struct rte_eth_dev *dev);
288 * Disable the receipt of all multicast packets by an Ethernet device.
291 * ethdev handle of port.
294 * Negative errno value on error, 0 on success.
297 * Success, all-multicast mode is disabled.
299 * All-multicast mode disabling is not supported.
302 * @retval -E_RTE_SECONDARY
303 * Function was called from a secondary process instance and not supported.
305 * Attempt to disable all-multicast mode failed because of timeout.
307 * Failed to disable all-multicast mode.
309 typedef int (*eth_allmulticast_disable_t)(struct rte_eth_dev *dev);
313 * Get link speed, duplex mode and state (up/down) of an Ethernet device.
315 typedef int (*eth_link_update_t)(struct rte_eth_dev *dev,
316 int wait_to_complete);
318 /** @internal Get global I/O statistics of an Ethernet device. */
319 typedef int (*eth_stats_get_t)(struct rte_eth_dev *dev,
320 struct rte_eth_stats *igb_stats);
324 * Reset global I/O statistics of an Ethernet device to 0.
327 * ethdev handle of port.
330 * Negative errno value on error, 0 on success.
333 * Success, statistics has been reset.
335 * Resetting statistics is not supported.
337 * Resetting statistics is not valid.
339 * Not enough memory to get the stats.
341 typedef int (*eth_stats_reset_t)(struct rte_eth_dev *dev);
343 /** @internal Get extended stats of an Ethernet device. */
344 typedef int (*eth_xstats_get_t)(struct rte_eth_dev *dev,
345 struct rte_eth_xstat *stats, unsigned int n);
349 * Get extended stats of an Ethernet device.
352 * ethdev handle of port.
354 * IDs array to retrieve specific statistics. Must not be NULL.
356 * A pointer to a table to be filled with device statistics values.
359 * Element count in @p ids and @p values.
362 * - A number of filled in stats.
363 * - A negative value on error.
365 typedef int (*eth_xstats_get_by_id_t)(struct rte_eth_dev *dev,
372 * Reset extended stats of an Ethernet device.
375 * ethdev handle of port.
378 * Negative errno value on error, 0 on success.
381 * Success, statistics has been reset.
383 * Resetting statistics is not supported.
385 * Resetting statistics is not valid.
387 * Not enough memory to get the stats.
389 typedef int (*eth_xstats_reset_t)(struct rte_eth_dev *dev);
391 /** @internal Get names of extended stats of an Ethernet device. */
392 typedef int (*eth_xstats_get_names_t)(struct rte_eth_dev *dev,
393 struct rte_eth_xstat_name *xstats_names, unsigned int size);
397 * Get names of extended stats of an Ethernet device.
400 * ethdev handle of port.
402 * IDs array to retrieve specific statistics. Must not be NULL.
403 * @param xstats_names
404 * An rte_eth_xstat_name array of at least @p size elements to be filled.
407 * Element count in @p ids and @p xstats_names.
410 * - A number of filled in stats.
411 * - A negative value on error.
413 typedef int (*eth_xstats_get_names_by_id_t)(struct rte_eth_dev *dev,
414 const uint64_t *ids, struct rte_eth_xstat_name *xstats_names,
419 * Set a queue statistics mapping for a Tx/Rx queue of an Ethernet device.
421 typedef int (*eth_queue_stats_mapping_set_t)(struct rte_eth_dev *dev,
426 /** @internal Get specific information of an Ethernet device. */
427 typedef int (*eth_dev_infos_get_t)(struct rte_eth_dev *dev,
428 struct rte_eth_dev_info *dev_info);
430 /** @internal Get supported ptypes of an Ethernet device. */
431 typedef const uint32_t *(*eth_dev_supported_ptypes_get_t)(struct rte_eth_dev *dev);
435 * Inform Ethernet device about reduced range of packet types to handle.
438 * The Ethernet device identifier.
440 * The ptype family that application is interested in should be bitwise OR of
441 * RTE_PTYPE_*_MASK or 0.
445 typedef int (*eth_dev_ptypes_set_t)(struct rte_eth_dev *dev,
446 uint32_t ptype_mask);
448 /** @internal Start Rx and Tx of a queue of an Ethernet device. */
449 typedef int (*eth_queue_start_t)(struct rte_eth_dev *dev,
452 /** @internal Stop Rx and Tx of a queue of an Ethernet device. */
453 typedef int (*eth_queue_stop_t)(struct rte_eth_dev *dev,
456 /** @internal Set up a receive queue of an Ethernet device. */
457 typedef int (*eth_rx_queue_setup_t)(struct rte_eth_dev *dev,
458 uint16_t rx_queue_id,
460 unsigned int socket_id,
461 const struct rte_eth_rxconf *rx_conf,
462 struct rte_mempool *mb_pool);
464 /** @internal Setup a transmit queue of an Ethernet device. */
465 typedef int (*eth_tx_queue_setup_t)(struct rte_eth_dev *dev,
466 uint16_t tx_queue_id,
468 unsigned int socket_id,
469 const struct rte_eth_txconf *tx_conf);
471 /** @internal Enable interrupt of a receive queue of an Ethernet device. */
472 typedef int (*eth_rx_enable_intr_t)(struct rte_eth_dev *dev,
473 uint16_t rx_queue_id);
475 /** @internal Disable interrupt of a receive queue of an Ethernet device. */
476 typedef int (*eth_rx_disable_intr_t)(struct rte_eth_dev *dev,
477 uint16_t rx_queue_id);
479 /** @internal Release memory resources allocated by given Rx/Tx queue. */
480 typedef void (*eth_queue_release_t)(struct rte_eth_dev *dev,
483 /** @internal Get firmware information of an Ethernet device. */
484 typedef int (*eth_fw_version_get_t)(struct rte_eth_dev *dev,
485 char *fw_version, size_t fw_size);
487 /** @internal Force mbufs to be from Tx ring. */
488 typedef int (*eth_tx_done_cleanup_t)(void *txq, uint32_t free_cnt);
490 typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev,
491 uint16_t rx_queue_id, struct rte_eth_rxq_info *qinfo);
493 typedef void (*eth_txq_info_get_t)(struct rte_eth_dev *dev,
494 uint16_t tx_queue_id, struct rte_eth_txq_info *qinfo);
496 typedef int (*eth_burst_mode_get_t)(struct rte_eth_dev *dev,
497 uint16_t queue_id, struct rte_eth_burst_mode *mode);
499 /** @internal Set MTU. */
500 typedef int (*mtu_set_t)(struct rte_eth_dev *dev, uint16_t mtu);
502 /** @internal Filtering of a VLAN Tag Identifier by an Ethernet device. */
503 typedef int (*vlan_filter_set_t)(struct rte_eth_dev *dev,
507 /** @internal Set the outer/inner VLAN-TPID by an Ethernet device. */
508 typedef int (*vlan_tpid_set_t)(struct rte_eth_dev *dev,
509 enum rte_vlan_type type, uint16_t tpid);
511 /** @internal Set VLAN offload function by an Ethernet device. */
512 typedef int (*vlan_offload_set_t)(struct rte_eth_dev *dev, int mask);
514 /** @internal Set port based Tx VLAN insertion by an Ethernet device. */
515 typedef int (*vlan_pvid_set_t)(struct rte_eth_dev *dev,
519 /** @internal VLAN stripping enable/disable by an queue of Ethernet device. */
520 typedef void (*vlan_strip_queue_set_t)(struct rte_eth_dev *dev,
521 uint16_t rx_queue_id,
524 /** @internal Get current flow control parameter on an Ethernet device. */
525 typedef int (*flow_ctrl_get_t)(struct rte_eth_dev *dev,
526 struct rte_eth_fc_conf *fc_conf);
528 /** @internal Setup flow control parameter on an Ethernet device. */
529 typedef int (*flow_ctrl_set_t)(struct rte_eth_dev *dev,
530 struct rte_eth_fc_conf *fc_conf);
532 /** @internal Setup priority flow control parameter on an Ethernet device. */
533 typedef int (*priority_flow_ctrl_set_t)(struct rte_eth_dev *dev,
534 struct rte_eth_pfc_conf *pfc_conf);
536 /** @internal Get info for queue based PFC on an Ethernet device. */
537 typedef int (*priority_flow_ctrl_queue_info_get_t)(struct rte_eth_dev *dev,
538 struct rte_eth_pfc_queue_info *pfc_queue_info);
539 /** @internal Configure queue based PFC parameter on an Ethernet device. */
540 typedef int (*priority_flow_ctrl_queue_config_t)(struct rte_eth_dev *dev,
541 struct rte_eth_pfc_queue_conf *pfc_queue_conf);
543 /** @internal Update RSS redirection table on an Ethernet device. */
544 typedef int (*reta_update_t)(struct rte_eth_dev *dev,
545 struct rte_eth_rss_reta_entry64 *reta_conf,
548 /** @internal Query RSS redirection table on an Ethernet device. */
549 typedef int (*reta_query_t)(struct rte_eth_dev *dev,
550 struct rte_eth_rss_reta_entry64 *reta_conf,
553 /** @internal Update RSS hash configuration of an Ethernet device. */
554 typedef int (*rss_hash_update_t)(struct rte_eth_dev *dev,
555 struct rte_eth_rss_conf *rss_conf);
557 /** @internal Get current RSS hash configuration of an Ethernet device. */
558 typedef int (*rss_hash_conf_get_t)(struct rte_eth_dev *dev,
559 struct rte_eth_rss_conf *rss_conf);
561 /** @internal Turn on SW controllable LED on an Ethernet device. */
562 typedef int (*eth_dev_led_on_t)(struct rte_eth_dev *dev);
564 /** @internal Turn off SW controllable LED on an Ethernet device. */
565 typedef int (*eth_dev_led_off_t)(struct rte_eth_dev *dev);
567 /** @internal Remove MAC address from receive address register. */
568 typedef void (*eth_mac_addr_remove_t)(struct rte_eth_dev *dev, uint32_t index);
570 /** @internal Set a MAC address into Receive Address Register. */
571 typedef int (*eth_mac_addr_add_t)(struct rte_eth_dev *dev,
572 struct rte_ether_addr *mac_addr,
576 /** @internal Set a MAC address into Receive Address Register. */
577 typedef int (*eth_mac_addr_set_t)(struct rte_eth_dev *dev,
578 struct rte_ether_addr *mac_addr);
580 /** @internal Set a Unicast Hash bitmap. */
581 typedef int (*eth_uc_hash_table_set_t)(struct rte_eth_dev *dev,
582 struct rte_ether_addr *mac_addr,
585 /** @internal Set all Unicast Hash bitmap. */
586 typedef int (*eth_uc_all_hash_table_set_t)(struct rte_eth_dev *dev,
589 /** @internal Set queue Tx rate. */
590 typedef int (*eth_set_queue_rate_limit_t)(struct rte_eth_dev *dev,
594 /** @internal Add tunneling UDP port. */
595 typedef int (*eth_udp_tunnel_port_add_t)(struct rte_eth_dev *dev,
596 struct rte_eth_udp_tunnel *tunnel_udp);
598 /** @internal Delete tunneling UDP port. */
599 typedef int (*eth_udp_tunnel_port_del_t)(struct rte_eth_dev *dev,
600 struct rte_eth_udp_tunnel *tunnel_udp);
602 /** @internal set the list of multicast addresses on an Ethernet device. */
603 typedef int (*eth_set_mc_addr_list_t)(struct rte_eth_dev *dev,
604 struct rte_ether_addr *mc_addr_set,
605 uint32_t nb_mc_addr);
607 /** @internal Function used to enable IEEE1588/802.1AS timestamping. */
608 typedef int (*eth_timesync_enable_t)(struct rte_eth_dev *dev);
610 /** @internal Function used to disable IEEE1588/802.1AS timestamping. */
611 typedef int (*eth_timesync_disable_t)(struct rte_eth_dev *dev);
613 /** @internal Function used to read an Rx IEEE1588/802.1AS timestamp. */
614 typedef int (*eth_timesync_read_rx_timestamp_t)(struct rte_eth_dev *dev,
615 struct timespec *timestamp,
618 /** @internal Function used to read a Tx IEEE1588/802.1AS timestamp. */
619 typedef int (*eth_timesync_read_tx_timestamp_t)(struct rte_eth_dev *dev,
620 struct timespec *timestamp);
622 /** @internal Function used to adjust the device clock. */
623 typedef int (*eth_timesync_adjust_time)(struct rte_eth_dev *dev, int64_t);
625 /** @internal Function used to get time from the device clock. */
626 typedef int (*eth_timesync_read_time)(struct rte_eth_dev *dev,
627 struct timespec *timestamp);
629 /** @internal Function used to get time from the device clock. */
630 typedef int (*eth_timesync_write_time)(struct rte_eth_dev *dev,
631 const struct timespec *timestamp);
633 /** @internal Function used to get the current value of the device clock. */
634 typedef int (*eth_read_clock)(struct rte_eth_dev *dev,
635 uint64_t *timestamp);
637 /** @internal Retrieve registers. */
638 typedef int (*eth_get_reg_t)(struct rte_eth_dev *dev,
639 struct rte_dev_reg_info *info);
641 /** @internal Retrieve EEPROM size. */
642 typedef int (*eth_get_eeprom_length_t)(struct rte_eth_dev *dev);
644 /** @internal Retrieve EEPROM data. */
645 typedef int (*eth_get_eeprom_t)(struct rte_eth_dev *dev,
646 struct rte_dev_eeprom_info *info);
648 /** @internal Program EEPROM data. */
649 typedef int (*eth_set_eeprom_t)(struct rte_eth_dev *dev,
650 struct rte_dev_eeprom_info *info);
652 /** @internal Retrieve type and size of plugin module EEPROM. */
653 typedef int (*eth_get_module_info_t)(struct rte_eth_dev *dev,
654 struct rte_eth_dev_module_info *modinfo);
656 /** @internal Retrieve plugin module EEPROM data. */
657 typedef int (*eth_get_module_eeprom_t)(struct rte_eth_dev *dev,
658 struct rte_dev_eeprom_info *info);
663 * Get flow operations.
665 * If the flow API is not supported for the specified device,
666 * the driver can return NULL.
668 typedef int (*eth_flow_ops_get_t)(struct rte_eth_dev *dev,
669 const struct rte_flow_ops **ops);
671 /** @internal Get Traffic Management (TM) operations on an Ethernet device. */
672 typedef int (*eth_tm_ops_get_t)(struct rte_eth_dev *dev, void *ops);
674 /** @internal Get Traffic Metering and Policing (MTR) operations. */
675 typedef int (*eth_mtr_ops_get_t)(struct rte_eth_dev *dev, void *ops);
677 /** @internal Get DCB information on an Ethernet device. */
678 typedef int (*eth_get_dcb_info)(struct rte_eth_dev *dev,
679 struct rte_eth_dcb_info *dcb_info);
681 /** @internal Test if a port supports specific mempool ops. */
682 typedef int (*eth_pool_ops_supported_t)(struct rte_eth_dev *dev,
687 * Get the hairpin capabilities.
690 * ethdev handle of port.
692 * returns the hairpin capabilities from the device.
695 * Negative errno value on error, 0 on success.
698 * Success, hairpin is supported.
700 * Hairpin is not supported.
702 typedef int (*eth_hairpin_cap_get_t)(struct rte_eth_dev *dev,
703 struct rte_eth_hairpin_cap *cap);
707 * Setup Rx hairpin queue.
710 * ethdev handle of port.
712 * the selected Rx queue index.
714 * the requested number of descriptors for this queue. 0 - use PMD default.
716 * the Rx hairpin configuration structure.
719 * Negative errno value on error, 0 on success.
722 * Success, hairpin is supported.
724 * Hairpin is not supported.
726 * One of the parameters is invalid.
728 * Unable to allocate resources.
730 typedef int (*eth_rx_hairpin_queue_setup_t)
731 (struct rte_eth_dev *dev, uint16_t rx_queue_id,
733 const struct rte_eth_hairpin_conf *conf);
737 * Setup Tx hairpin queue.
740 * ethdev handle of port.
742 * the selected Tx queue index.
744 * the requested number of descriptors for this queue. 0 - use PMD default.
746 * the Tx hairpin configuration structure.
749 * Negative errno value on error, 0 on success.
752 * Success, hairpin is supported.
754 * Hairpin is not supported.
756 * One of the parameters is invalid.
758 * Unable to allocate resources.
760 typedef int (*eth_tx_hairpin_queue_setup_t)
761 (struct rte_eth_dev *dev, uint16_t tx_queue_id,
763 const struct rte_eth_hairpin_conf *hairpin_conf);
767 * Get Forward Error Correction(FEC) capability.
770 * ethdev handle of port.
771 * @param speed_fec_capa
772 * speed_fec_capa is out only with per-speed capabilities.
774 * a number of elements in an speed_fec_capa array.
777 * Negative errno value on error, positive value on success.
779 * @retval positive value
780 * A non-negative value lower or equal to num: success. The return value
781 * is the number of entries filled in the fec capa array.
782 * A non-negative value higher than num: error, the given fec capa array
783 * is too small. The return value corresponds to the num that should
784 * be given to succeed. The entries in the fec capa array are not valid
785 * and shall not be used by the caller.
787 * Operation is not supported.
791 * *num* or *speed_fec_capa* invalid.
793 typedef int (*eth_fec_get_capability_t)(struct rte_eth_dev *dev,
794 struct rte_eth_fec_capa *speed_fec_capa, unsigned int num);
798 * Get Forward Error Correction(FEC) mode.
801 * ethdev handle of port.
803 * a bitmask of enabled FEC modes. If AUTO bit is set, other
804 * bits specify FEC modes which may be negotiated. If AUTO
805 * bit is clear, specify FEC modes to be used (only one valid
806 * mode per speed may be set).
809 * Negative errno value on error, 0 on success.
812 * Success, get FEC success.
814 * Operation is not supported.
818 typedef int (*eth_fec_get_t)(struct rte_eth_dev *dev,
823 * Set Forward Error Correction(FEC) mode.
826 * ethdev handle of port.
828 * bitmask of allowed FEC modes. It must be only one
829 * if AUTO is disabled. If AUTO is enabled, other
830 * bits specify FEC modes which may be negotiated.
833 * Negative errno value on error, 0 on success.
836 * Success, set FEC success.
838 * Operation is not supported.
840 * Unsupported FEC mode requested.
844 typedef int (*eth_fec_set_t)(struct rte_eth_dev *dev, uint32_t fec_capa);
848 * Get all hairpin Tx/Rx peer ports of the current device, if any.
851 * ethdev handle of port.
853 * array to save the ports list.
857 * value to decide the current to peer direction
858 * positive - used as Tx to get all peer Rx ports.
859 * zero - used as Rx to get all peer Tx ports.
862 * Negative errno value on error, 0 or positive on success.
865 * Success, no peer ports.
867 * Actual number of the peer ports.
869 * Get peer ports API is not supported.
871 * One of the parameters is invalid.
873 typedef int (*hairpin_get_peer_ports_t)(struct rte_eth_dev *dev,
874 uint16_t *peer_ports, size_t len,
879 * Bind all hairpin Tx queues of one port to the Rx queues of the peer port.
882 * ethdev handle of port.
887 * Negative errno value on error, 0 on success.
890 * Success, bind successfully.
892 * Bind API is not supported.
894 * One of the parameters is invalid.
896 * Device is not started.
898 typedef int (*eth_hairpin_bind_t)(struct rte_eth_dev *dev,
903 * Unbind all hairpin Tx queues of one port from the Rx queues of the peer port.
906 * ethdev handle of port.
911 * Negative errno value on error, 0 on success.
914 * Success, unbind successfully.
916 * Bind API is not supported.
918 * One of the parameters is invalid.
920 * Device is already stopped.
922 typedef int (*eth_hairpin_unbind_t)(struct rte_eth_dev *dev,
925 /** @internal Update and fetch peer queue information. */
926 typedef int (*eth_hairpin_queue_peer_update_t)
927 (struct rte_eth_dev *dev, uint16_t peer_queue,
928 struct rte_hairpin_peer_info *current_info,
929 struct rte_hairpin_peer_info *peer_info, uint32_t direction);
931 /** @internal Bind peer queue to the current queue with fetched information. */
932 typedef int (*eth_hairpin_queue_peer_bind_t)
933 (struct rte_eth_dev *dev, uint16_t cur_queue,
934 struct rte_hairpin_peer_info *peer_info, uint32_t direction);
936 /** @internal Unbind peer queue from the current queue. */
937 typedef int (*eth_hairpin_queue_peer_unbind_t)
938 (struct rte_eth_dev *dev, uint16_t cur_queue, uint32_t direction);
942 * Get address of memory location whose contents will change whenever there is
943 * new data to be received on an Rx queue.
946 * Ethdev queue pointer.
948 * The pointer to power-optimized monitoring condition structure.
950 * Negative errno value on error, 0 on success.
957 typedef int (*eth_get_monitor_addr_t)(void *rxq,
958 struct rte_power_monitor_cond *pmc);
962 * Get representor info to be able to calculate the unique representor ID.
964 * Caller should pass NULL as pointer of info to get number of entries,
965 * allocate info buffer according to returned entry number, then call
966 * again with buffer to get real info.
968 * To calculate the representor ID, caller should iterate each entry,
969 * match controller index, pf index, vf or sf start index and range,
970 * then calculate representor ID from offset to vf/sf start index.
971 * @see rte_eth_representor_id_get.
974 * Ethdev handle of port.
976 * Pointer to memory to save device representor info.
978 * Negative errno value on error, number of info entries otherwise.
981 typedef int (*eth_representor_info_get_t)(struct rte_eth_dev *dev,
982 struct rte_eth_representor_info *info);
986 * Negotiate the NIC's ability to deliver specific kinds of metadata to the PMD.
989 * Port (ethdev) handle
991 * @param[inout] features
992 * Feature selection buffer
995 * Negative errno value on error, zero otherwise
997 typedef int (*eth_rx_metadata_negotiate_t)(struct rte_eth_dev *dev,
1001 * @internal A structure containing the functions exported by an Ethernet driver.
1003 struct eth_dev_ops {
1004 eth_dev_configure_t dev_configure; /**< Configure device */
1005 eth_dev_start_t dev_start; /**< Start device */
1006 eth_dev_stop_t dev_stop; /**< Stop device */
1007 eth_dev_set_link_up_t dev_set_link_up; /**< Device link up */
1008 eth_dev_set_link_down_t dev_set_link_down; /**< Device link down */
1009 eth_dev_close_t dev_close; /**< Close device */
1010 eth_dev_reset_t dev_reset; /**< Reset device */
1011 eth_link_update_t link_update; /**< Get device link state */
1012 /** Check if the device was physically removed */
1013 eth_is_removed_t is_removed;
1015 eth_promiscuous_enable_t promiscuous_enable; /**< Promiscuous ON */
1016 eth_promiscuous_disable_t promiscuous_disable;/**< Promiscuous OFF */
1017 eth_allmulticast_enable_t allmulticast_enable;/**< Rx multicast ON */
1018 eth_allmulticast_disable_t allmulticast_disable;/**< Rx multicast OFF */
1019 eth_mac_addr_remove_t mac_addr_remove; /**< Remove MAC address */
1020 eth_mac_addr_add_t mac_addr_add; /**< Add a MAC address */
1021 eth_mac_addr_set_t mac_addr_set; /**< Set a MAC address */
1022 /** Set list of multicast addresses */
1023 eth_set_mc_addr_list_t set_mc_addr_list;
1024 mtu_set_t mtu_set; /**< Set MTU */
1026 /** Get generic device statistics */
1027 eth_stats_get_t stats_get;
1028 /** Reset generic device statistics */
1029 eth_stats_reset_t stats_reset;
1030 /** Get extended device statistics */
1031 eth_xstats_get_t xstats_get;
1032 /** Reset extended device statistics */
1033 eth_xstats_reset_t xstats_reset;
1034 /** Get names of extended statistics */
1035 eth_xstats_get_names_t xstats_get_names;
1036 /** Configure per queue stat counter mapping */
1037 eth_queue_stats_mapping_set_t queue_stats_mapping_set;
1039 eth_dev_infos_get_t dev_infos_get; /**< Get device info */
1040 /** Retrieve Rx queue information */
1041 eth_rxq_info_get_t rxq_info_get;
1042 /** Retrieve Tx queue information */
1043 eth_txq_info_get_t txq_info_get;
1044 eth_burst_mode_get_t rx_burst_mode_get; /**< Get Rx burst mode */
1045 eth_burst_mode_get_t tx_burst_mode_get; /**< Get Tx burst mode */
1046 eth_fw_version_get_t fw_version_get; /**< Get firmware version */
1048 /** Get packet types supported and identified by device */
1049 eth_dev_supported_ptypes_get_t dev_supported_ptypes_get;
1051 * Inform Ethernet device about reduced range of packet types to
1054 eth_dev_ptypes_set_t dev_ptypes_set;
1056 /** Filter VLAN Setup */
1057 vlan_filter_set_t vlan_filter_set;
1058 /** Outer/Inner VLAN TPID Setup */
1059 vlan_tpid_set_t vlan_tpid_set;
1060 /** VLAN Stripping on queue */
1061 vlan_strip_queue_set_t vlan_strip_queue_set;
1062 /** Set VLAN Offload */
1063 vlan_offload_set_t vlan_offload_set;
1064 /** Set port based Tx VLAN insertion */
1065 vlan_pvid_set_t vlan_pvid_set;
1067 eth_queue_start_t rx_queue_start;/**< Start Rx for a queue */
1068 eth_queue_stop_t rx_queue_stop; /**< Stop Rx for a queue */
1069 eth_queue_start_t tx_queue_start;/**< Start Tx for a queue */
1070 eth_queue_stop_t tx_queue_stop; /**< Stop Tx for a queue */
1071 eth_rx_queue_setup_t rx_queue_setup;/**< Set up device Rx queue */
1072 eth_queue_release_t rx_queue_release; /**< Release Rx queue */
1074 /** Enable Rx queue interrupt */
1075 eth_rx_enable_intr_t rx_queue_intr_enable;
1076 /** Disable Rx queue interrupt */
1077 eth_rx_disable_intr_t rx_queue_intr_disable;
1079 eth_tx_queue_setup_t tx_queue_setup;/**< Set up device Tx queue */
1080 eth_queue_release_t tx_queue_release; /**< Release Tx queue */
1081 eth_tx_done_cleanup_t tx_done_cleanup;/**< Free Tx ring mbufs */
1083 eth_dev_led_on_t dev_led_on; /**< Turn on LED */
1084 eth_dev_led_off_t dev_led_off; /**< Turn off LED */
1086 flow_ctrl_get_t flow_ctrl_get; /**< Get flow control */
1087 flow_ctrl_set_t flow_ctrl_set; /**< Setup flow control */
1088 /** Setup priority flow control */
1089 priority_flow_ctrl_set_t priority_flow_ctrl_set;
1090 /** Priority flow control queue info get */
1091 priority_flow_ctrl_queue_info_get_t priority_flow_ctrl_queue_info_get;
1092 /** Priority flow control queue configure */
1093 priority_flow_ctrl_queue_config_t priority_flow_ctrl_queue_config;
1095 /** Set Unicast Table Array */
1096 eth_uc_hash_table_set_t uc_hash_table_set;
1097 /** Set Unicast hash bitmap */
1098 eth_uc_all_hash_table_set_t uc_all_hash_table_set;
1100 /** Add UDP tunnel port */
1101 eth_udp_tunnel_port_add_t udp_tunnel_port_add;
1102 /** Delete UDP tunnel port */
1103 eth_udp_tunnel_port_del_t udp_tunnel_port_del;
1105 /** Set queue rate limit */
1106 eth_set_queue_rate_limit_t set_queue_rate_limit;
1108 /** Configure RSS hash protocols and hashing key */
1109 rss_hash_update_t rss_hash_update;
1110 /** Get current RSS hash configuration */
1111 rss_hash_conf_get_t rss_hash_conf_get;
1112 /** Update redirection table */
1113 reta_update_t reta_update;
1114 /** Query redirection table */
1115 reta_query_t reta_query;
1117 eth_get_reg_t get_reg; /**< Get registers */
1118 eth_get_eeprom_length_t get_eeprom_length; /**< Get EEPROM length */
1119 eth_get_eeprom_t get_eeprom; /**< Get EEPROM data */
1120 eth_set_eeprom_t set_eeprom; /**< Set EEPROM */
1122 /** Get plugin module EEPROM attribute */
1123 eth_get_module_info_t get_module_info;
1124 /** Get plugin module EEPROM data */
1125 eth_get_module_eeprom_t get_module_eeprom;
1127 eth_flow_ops_get_t flow_ops_get; /**< Get flow operations */
1129 eth_get_dcb_info get_dcb_info; /**< Get DCB information */
1131 /** Turn IEEE1588/802.1AS timestamping on */
1132 eth_timesync_enable_t timesync_enable;
1133 /** Turn IEEE1588/802.1AS timestamping off */
1134 eth_timesync_disable_t timesync_disable;
1135 /** Read the IEEE1588/802.1AS Rx timestamp */
1136 eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp;
1137 /** Read the IEEE1588/802.1AS Tx timestamp */
1138 eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp;
1139 /** Adjust the device clock */
1140 eth_timesync_adjust_time timesync_adjust_time;
1141 /** Get the device clock time */
1142 eth_timesync_read_time timesync_read_time;
1143 /** Set the device clock time */
1144 eth_timesync_write_time timesync_write_time;
1146 eth_read_clock read_clock;
1148 /** Get extended device statistic values by ID */
1149 eth_xstats_get_by_id_t xstats_get_by_id;
1150 /** Get name of extended device statistics by ID */
1151 eth_xstats_get_names_by_id_t xstats_get_names_by_id;
1153 /** Get Traffic Management (TM) operations */
1154 eth_tm_ops_get_t tm_ops_get;
1156 /** Get Traffic Metering and Policing (MTR) operations */
1157 eth_mtr_ops_get_t mtr_ops_get;
1159 /** Test if a port supports specific mempool ops */
1160 eth_pool_ops_supported_t pool_ops_supported;
1162 /** Returns the hairpin capabilities */
1163 eth_hairpin_cap_get_t hairpin_cap_get;
1164 /** Set up device Rx hairpin queue */
1165 eth_rx_hairpin_queue_setup_t rx_hairpin_queue_setup;
1166 /** Set up device Tx hairpin queue */
1167 eth_tx_hairpin_queue_setup_t tx_hairpin_queue_setup;
1169 /** Get Forward Error Correction(FEC) capability */
1170 eth_fec_get_capability_t fec_get_capability;
1171 /** Get Forward Error Correction(FEC) mode */
1172 eth_fec_get_t fec_get;
1173 /** Set Forward Error Correction(FEC) mode */
1174 eth_fec_set_t fec_set;
1176 /** Get hairpin peer ports list */
1177 hairpin_get_peer_ports_t hairpin_get_peer_ports;
1178 /** Bind all hairpin Tx queues of device to the peer port Rx queues */
1179 eth_hairpin_bind_t hairpin_bind;
1180 /** Unbind all hairpin Tx queues from the peer port Rx queues */
1181 eth_hairpin_unbind_t hairpin_unbind;
1182 /** Pass the current queue info and get the peer queue info */
1183 eth_hairpin_queue_peer_update_t hairpin_queue_peer_update;
1184 /** Set up the connection between the pair of hairpin queues */
1185 eth_hairpin_queue_peer_bind_t hairpin_queue_peer_bind;
1186 /** Disconnect the hairpin queues of a pair from each other */
1187 eth_hairpin_queue_peer_unbind_t hairpin_queue_peer_unbind;
1189 /** Get power monitoring condition for Rx queue */
1190 eth_get_monitor_addr_t get_monitor_addr;
1192 /** Get representor info */
1193 eth_representor_info_get_t representor_info_get;
1196 * Negotiate the NIC's ability to deliver specific
1197 * kinds of metadata to the PMD
1199 eth_rx_metadata_negotiate_t rx_metadata_negotiate;
1204 * Check if the selected Rx queue is hairpin queue.
1207 * Pointer to the selected device.
1209 * The selected queue.
1212 * - (1) if the queue is hairpin queue, 0 otherwise.
1215 int rte_eth_dev_is_rx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id);
1219 * Check if the selected Tx queue is hairpin queue.
1222 * Pointer to the selected device.
1224 * The selected queue.
1227 * - (1) if the queue is hairpin queue, 0 otherwise.
1230 int rte_eth_dev_is_tx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id);
1234 * Returns a ethdev slot specified by the unique identifier name.
1237 * The pointer to the Unique identifier name for each Ethernet device
1239 * - The pointer to the ethdev slot, on success. NULL on error
1242 struct rte_eth_dev *rte_eth_dev_allocated(const char *name);
1246 * Allocates a new ethdev slot for an Ethernet device and returns the pointer
1247 * to that slot for the driver to use.
1249 * @param name Unique identifier name for each Ethernet device
1251 * - Slot in the rte_dev_devices array for a new device;
1254 struct rte_eth_dev *rte_eth_dev_allocate(const char *name);
1258 * Attach to the ethdev already initialized by the primary
1261 * @param name Ethernet device's name.
1263 * - Success: Slot in the rte_dev_devices array for attached
1265 * - Error: Null pointer.
1268 struct rte_eth_dev *rte_eth_dev_attach_secondary(const char *name);
1272 * Notify RTE_ETH_EVENT_DESTROY and release the specified ethdev port.
1274 * The following PMD-managed data fields will be freed:
1278 * If one of these fields should not be freed,
1279 * it must be reset to NULL by the PMD, typically in dev_close method.
1282 * Device to be detached.
1284 * - 0 on success, negative on error
1287 int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev);
1291 * Release device queues and clear its configuration to force the user
1292 * application to reconfigure it. It is for internal use only.
1295 * Pointer to struct rte_eth_dev.
1301 void rte_eth_dev_internal_reset(struct rte_eth_dev *dev);
1304 * @internal Executes all the user application registered callbacks for
1305 * the specific device. It is for DPDK internal user only. User
1306 * application should not call it directly.
1309 * Pointer to struct rte_eth_dev.
1311 * Eth device interrupt event type.
1313 * To pass data back to user application.
1314 * This allows the user application to decide if a particular function
1315 * is permitted or not.
1321 int rte_eth_dev_callback_process(struct rte_eth_dev *dev,
1322 enum rte_eth_event_type event, void *ret_param);
1326 * This is the last step of device probing.
1327 * It must be called after a port is allocated and initialized successfully.
1329 * The notification RTE_ETH_EVENT_NEW is sent to other entities
1330 * (libraries and applications).
1331 * The state is set as RTE_ETH_DEV_ATTACHED.
1337 void rte_eth_dev_probing_finish(struct rte_eth_dev *dev);
1340 * Create memzone for HW rings.
1341 * malloc can't be used as the physical address is needed.
1342 * If the memzone is already created, then this function returns a ptr
1346 * The *eth_dev* pointer is the address of the *rte_eth_dev* structure
1348 * The name of the memory zone
1350 * The index of the queue to add to name
1352 * The sizeof of the memory area
1354 * Alignment for resulting memzone. Must be a power of 2.
1356 * The *socket_id* argument is the socket identifier in case of NUMA.
1359 const struct rte_memzone *
1360 rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name,
1361 uint16_t queue_id, size_t size,
1362 unsigned align, int socket_id);
1365 * Free previously allocated memzone for HW rings.
1368 * The *eth_dev* pointer is the address of the *rte_eth_dev* structure
1370 * The name of the memory zone
1372 * The index of the queue to add to name
1374 * Negative errno value on error, 0 on success.
1378 rte_eth_dma_zone_free(const struct rte_eth_dev *eth_dev, const char *name,
1383 * Atomically set the link status for the specific device.
1384 * It is for use by DPDK device driver use only.
1385 * User applications should not call it
1388 * Pointer to struct rte_eth_dev.
1390 * New link status value.
1392 * Same convention as eth_link_update operation.
1393 * 0 if link up status has changed
1394 * -1 if link up status was unchanged
1397 rte_eth_linkstatus_set(struct rte_eth_dev *dev,
1398 const struct rte_eth_link *new_link)
1400 uint64_t *dev_link = (uint64_t *)&(dev->data->dev_link);
1403 struct rte_eth_link link;
1406 RTE_BUILD_BUG_ON(sizeof(*new_link) != sizeof(uint64_t));
1408 orig.val64 = __atomic_exchange_n(dev_link, *(const uint64_t *)new_link,
1411 return (orig.link.link_status == new_link->link_status) ? -1 : 0;
1416 * Atomically get the link speed and status.
1419 * Pointer to struct rte_eth_dev.
1421 * link status value.
1424 rte_eth_linkstatus_get(const struct rte_eth_dev *dev,
1425 struct rte_eth_link *link)
1427 uint64_t *src = (uint64_t *)&(dev->data->dev_link);
1428 uint64_t *dst = (uint64_t *)link;
1430 RTE_BUILD_BUG_ON(sizeof(*link) != sizeof(uint64_t));
1432 *dst = __atomic_load_n(src, __ATOMIC_SEQ_CST);
1436 * Allocate an unique switch domain identifier.
1438 * A pool of switch domain identifiers which can be allocated on request. This
1439 * will enabled devices which support the concept of switch domains to request
1440 * a switch domain ID which is guaranteed to be unique from other devices
1441 * running in the same process.
1444 * switch domain identifier parameter to pass back to application
1447 * Negative errno value on error, 0 on success.
1451 rte_eth_switch_domain_alloc(uint16_t *domain_id);
1454 * Free switch domain.
1456 * Return a switch domain identifier to the pool of free identifiers after it is
1457 * no longer in use by device.
1460 * switch domain identifier to free
1463 * Negative errno value on error, 0 on success.
1467 rte_eth_switch_domain_free(uint16_t domain_id);
1470 * Generic Ethernet device arguments
1472 * One type of representor each structure.
1474 struct rte_eth_devargs {
1475 uint16_t mh_controllers[RTE_MAX_MULTI_HOST_CTRLS];
1476 /** controller/s number in case of multi-host */
1477 uint16_t nb_mh_controllers;
1478 /** number of controllers in multi-host controllers field */
1479 uint16_t ports[RTE_MAX_ETHPORTS];
1480 /** port/s number to enable on a multi-port single function */
1482 /** number of ports in ports field */
1483 uint16_t representor_ports[RTE_MAX_ETHPORTS];
1484 /** representor port/s identifier to enable on device */
1485 uint16_t nb_representor_ports;
1486 /** number of ports in representor port field */
1487 enum rte_eth_representor_type type; /* type of representor */
1491 * PMD helper function to get representor ID from location detail.
1493 * Get representor ID from controller, pf and (sf or vf).
1494 * The mapping is retrieved from rte_eth_representor_info_get().
1496 * For backward compatibility, if no representor info, direct
1497 * map legacy VF (no controller and pf).
1500 * Port ID of the backing device.
1504 * Controller ID, -1 if unspecified.
1506 * PF port ID, -1 if unspecified.
1507 * @param representor_port
1508 * VF or SF representor port number, -1 if unspecified.
1510 * Pointer to output representor ID.
1513 * Negative errno value on error, 0 on success.
1517 rte_eth_representor_id_get(uint16_t port_id,
1518 enum rte_eth_representor_type type,
1519 int controller, int pf, int representor_port,
1523 * PMD helper function to parse ethdev arguments
1527 * @param eth_devargs
1528 * parsed ethdev specific arguments.
1531 * Negative errno value on error, 0 on success.
1535 rte_eth_devargs_parse(const char *devargs, struct rte_eth_devargs *eth_devargs);
1538 typedef int (*ethdev_init_t)(struct rte_eth_dev *ethdev, void *init_params);
1539 typedef int (*ethdev_bus_specific_init)(struct rte_eth_dev *ethdev,
1540 void *bus_specific_init_params);
1543 * PMD helper function for the creation of a new ethdev ports.
1546 * rte_device handle.
1549 * @param priv_data_size
1550 * size of private data required for port.
1551 * @param bus_specific_init
1552 * port bus specific initialisation callback function
1553 * @param bus_init_params
1554 * port bus specific initialisation parameters
1555 * @param ethdev_init
1556 * device specific port initialization callback function
1557 * @param init_params
1558 * port initialisation parameters
1561 * Negative errno value on error, 0 on success.
1565 rte_eth_dev_create(struct rte_device *device, const char *name,
1566 size_t priv_data_size,
1567 ethdev_bus_specific_init bus_specific_init, void *bus_init_params,
1568 ethdev_init_t ethdev_init, void *init_params);
1571 typedef int (*ethdev_uninit_t)(struct rte_eth_dev *ethdev);
1574 * PMD helper function for cleaning up the resources of a ethdev port on it's
1578 * ethdev handle of port.
1579 * @param ethdev_uninit
1580 * device specific port un-initialise callback function
1583 * Negative errno value on error, 0 on success.
1587 rte_eth_dev_destroy(struct rte_eth_dev *ethdev, ethdev_uninit_t ethdev_uninit);
1591 * Pass the current hairpin queue HW and/or SW information to the peer queue
1592 * and fetch back the information of the peer queue.
1595 * Peer port identifier of the Ethernet device.
1597 * Peer queue index of the port.
1599 * Pointer to the current information structure.
1601 * Pointer to the peer information, output.
1603 * Direction to pass the information.
1604 * positive - pass Tx queue information and get peer Rx queue information
1605 * zero - pass Rx queue information and get peer Tx queue information
1608 * Negative errno value on error, 0 on success.
1612 rte_eth_hairpin_queue_peer_update(uint16_t peer_port, uint16_t peer_queue,
1613 struct rte_hairpin_peer_info *cur_info,
1614 struct rte_hairpin_peer_info *peer_info,
1615 uint32_t direction);
1619 * Configure current hairpin queue with the peer information fetched to create
1620 * the connection (bind) with peer queue in the specified direction.
1621 * This function might need to be called twice to fully create the connections.
1624 * Current port identifier of the Ethernet device.
1626 * Current queue index of the port.
1628 * Pointer to the peer information, input.
1630 * Direction to create the connection.
1631 * positive - bind current Tx queue to peer Rx queue
1632 * zero - bind current Rx queue to peer Tx queue
1635 * Negative errno value on error, 0 on success.
1639 rte_eth_hairpin_queue_peer_bind(uint16_t cur_port, uint16_t cur_queue,
1640 struct rte_hairpin_peer_info *peer_info,
1641 uint32_t direction);
1645 * Get rte_eth_dev from device name. The device name should be specified
1647 * - PCIe address (Domain:Bus:Device.Function), for example 0000:2:00.0
1648 * - SoC device name, for example fsl-gmac0
1649 * - vdev dpdk name, for example net_[pcap0|null0|tap0]
1652 * PCI address or name of the device
1654 * - rte_eth_dev if successful
1659 rte_eth_dev_get_by_name(const char *name);
1663 * Reset the current queue state and configuration to disconnect (unbind) it
1664 * from the peer queue.
1665 * This function might need to be called twice to disconnect each other.
1668 * Current port identifier of the Ethernet device.
1670 * Current queue index of the port.
1672 * Direction to destroy the connection.
1673 * positive - unbind current Tx queue from peer Rx queue
1674 * zero - unbind current Rx queue from peer Tx queue
1677 * Negative errno value on error, 0 on success.
1681 rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t cur_queue,
1682 uint32_t direction);
1686 * Legacy ethdev API used internally by drivers.
1689 enum rte_filter_type {
1690 RTE_ETH_FILTER_NONE = 0,
1691 RTE_ETH_FILTER_ETHERTYPE,
1692 RTE_ETH_FILTER_FLEXIBLE,
1694 RTE_ETH_FILTER_NTUPLE,
1695 RTE_ETH_FILTER_TUNNEL,
1696 RTE_ETH_FILTER_FDIR,
1697 RTE_ETH_FILTER_HASH,
1698 RTE_ETH_FILTER_L2_TUNNEL,
1702 * Define all structures for Ethertype Filter type.
1705 #define RTE_ETHTYPE_FLAGS_MAC 0x0001 /**< If set, compare mac */
1706 #define RTE_ETHTYPE_FLAGS_DROP 0x0002 /**< If set, drop packet when match */
1709 * A structure used to define the ethertype filter entry
1710 * to support RTE_ETH_FILTER_ETHERTYPE data representation.
1712 struct rte_eth_ethertype_filter {
1713 struct rte_ether_addr mac_addr; /**< Mac address to match */
1714 uint16_t ether_type; /**< Ether type to match */
1715 uint16_t flags; /**< Flags from RTE_ETHTYPE_FLAGS_* */
1716 uint16_t queue; /**< Queue assigned to when match */
1720 * A structure used to define the TCP syn filter entry
1721 * to support RTE_ETH_FILTER_SYN data representation.
1723 struct rte_eth_syn_filter {
1724 /** 1 - higher priority than other filters, 0 - lower priority */
1726 uint16_t queue; /**< Queue assigned to when match */
1730 * filter type of tunneling packet
1732 #define RTE_ETH_TUNNEL_FILTER_OMAC 0x01 /**< filter by outer MAC addr */
1733 #define RTE_ETH_TUNNEL_FILTER_OIP 0x02 /**< filter by outer IP Addr */
1734 #define RTE_ETH_TUNNEL_FILTER_TENID 0x04 /**< filter by tenant ID */
1735 #define RTE_ETH_TUNNEL_FILTER_IMAC 0x08 /**< filter by inner MAC addr */
1736 #define RTE_ETH_TUNNEL_FILTER_IVLAN 0x10 /**< filter by inner VLAN ID */
1737 #define RTE_ETH_TUNNEL_FILTER_IIP 0x20 /**< filter by inner IP addr */
1739 #define RTE_ETH_TUNNEL_FILTER_IMAC_IVLAN (RTE_ETH_TUNNEL_FILTER_IMAC | \
1740 RTE_ETH_TUNNEL_FILTER_IVLAN)
1741 #define RTE_ETH_TUNNEL_FILTER_IMAC_IVLAN_TENID (RTE_ETH_TUNNEL_FILTER_IMAC | \
1742 RTE_ETH_TUNNEL_FILTER_IVLAN | \
1743 RTE_ETH_TUNNEL_FILTER_TENID)
1744 #define RTE_ETH_TUNNEL_FILTER_IMAC_TENID (RTE_ETH_TUNNEL_FILTER_IMAC | \
1745 RTE_ETH_TUNNEL_FILTER_TENID)
1746 #define RTE_ETH_TUNNEL_FILTER_OMAC_TENID_IMAC (RTE_ETH_TUNNEL_FILTER_OMAC | \
1747 RTE_ETH_TUNNEL_FILTER_TENID | \
1748 RTE_ETH_TUNNEL_FILTER_IMAC)
1751 * Select IPv4 or IPv6 for tunnel filters.
1753 enum rte_tunnel_iptype {
1754 RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4 */
1755 RTE_TUNNEL_IPTYPE_IPV6, /**< IPv6 */
1759 * Tunneling Packet filter configuration.
1761 struct rte_eth_tunnel_filter_conf {
1762 struct rte_ether_addr outer_mac; /**< Outer MAC address to match */
1763 struct rte_ether_addr inner_mac; /**< Inner MAC address to match */
1764 uint16_t inner_vlan; /**< Inner VLAN to match */
1765 enum rte_tunnel_iptype ip_type; /**< IP address type */
1767 * Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP
1768 * is set in filter_type, or inner destination IP address to match
1769 * if ETH_TUNNEL_FILTER_IIP is set in filter_type.
1772 uint32_t ipv4_addr; /**< IPv4 address in big endian */
1773 uint32_t ipv6_addr[4]; /**< IPv6 address in big endian */
1775 /** Flags from ETH_TUNNEL_FILTER_XX - see above */
1776 uint16_t filter_type;
1777 enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type */
1778 uint32_t tenant_id; /**< Tenant ID to match: VNI, GRE key... */
1779 uint16_t queue_id; /**< Queue assigned to if match */
1782 #endif /* _RTE_ETHDEV_DRIVER_H_ */