ethdev: add function to get hairpin peer ports list
[dpdk.git] / lib / librte_ethdev / rte_ethdev_driver.h
index 35cc4fb..03e00d5 100644 (file)
@@ -655,6 +655,85 @@ typedef int (*eth_fec_get_t)(struct rte_eth_dev *dev,
  */
 typedef int (*eth_fec_set_t)(struct rte_eth_dev *dev, uint32_t fec_capa);
 
+/**
+ * @internal
+ * Get all hairpin Tx/Rx peer ports of the current device, if any.
+ *
+ * @param dev
+ *   ethdev handle of port.
+ * @param peer_ports
+ *   array to save the ports list.
+ * @param len
+ *   array length.
+ * @param direction
+ *   value to decide the current to peer direction
+ *   positive - used as Tx to get all peer Rx ports.
+ *   zero - used as Rx to get all peer Tx ports.
+ *
+ * @return
+ *   Negative errno value on error, 0 or positive on success.
+ *
+ * @retval 0
+ *   Success, no peer ports.
+ * @retval >0
+ *   Actual number of the peer ports.
+ * @retval -ENOTSUP
+ *   Get peer ports API is not supported.
+ * @retval -EINVAL
+ *   One of the parameters is invalid.
+ */
+typedef int (*hairpin_get_peer_ports_t)(struct rte_eth_dev *dev,
+                                       uint16_t *peer_ports, size_t len,
+                                       uint32_t direction);
+
+/**
+ * @internal
+ * Bind all hairpin Tx queues of one port to the Rx queues of the peer port.
+ *
+ * @param dev
+ *   ethdev handle of port.
+ * @param rx_port
+ *   the peer Rx port.
+ *
+ * @return
+ *   Negative errno value on error, 0 on success.
+ *
+ * @retval 0
+ *   Success, bind successfully.
+ * @retval -ENOTSUP
+ *   Bind API is not supported.
+ * @retval -EINVAL
+ *   One of the parameters is invalid.
+ * @retval -EBUSY
+ *   Device is not started.
+ */
+typedef int (*eth_hairpin_bind_t)(struct rte_eth_dev *dev,
+                               uint16_t rx_port);
+
+/**
+ * @internal
+ * Unbind all hairpin Tx queues of one port from the Rx queues of the peer port.
+ *
+ * @param dev
+ *   ethdev handle of port.
+ * @param rx_port
+ *   the peer Rx port.
+ *
+ * @return
+ *   Negative errno value on error, 0 on success.
+ *
+ * @retval 0
+ *   Success, unbind successfully.
+ * @retval -ENOTSUP
+ *   Bind API is not supported.
+ * @retval -EINVAL
+ *   One of the parameters is invalid.
+ * @retval -EBUSY
+ *   Device is already stopped.
+ */
+typedef int (*eth_hairpin_unbind_t)(struct rte_eth_dev *dev,
+                                 uint16_t rx_port);
+
 /**
  * @internal A structure containing the functions exported by an Ethernet driver.
  */
@@ -801,6 +880,12 @@ struct eth_dev_ops {
        /**< Get Forward Error Correction(FEC) mode. */
        eth_fec_set_t fec_set;
        /**< Set Forward Error Correction(FEC) mode. */
+       hairpin_get_peer_ports_t hairpin_get_peer_ports;
+       /**< Get hairpin peer ports list. */
+       eth_hairpin_bind_t hairpin_bind;
+       /**< Bind all hairpin Tx queues of device to the peer port Rx queues. */
+       eth_hairpin_unbind_t hairpin_unbind;
+       /**< Unbind all hairpin Tx queues from the peer port Rx queues. */
 };
 
 /**