test/telemetry: fix typo at beginning of line
[dpdk.git] / lib / librte_ethdev / rte_ethdev_driver.h
index 9a65bd5..0eacfd8 100644 (file)
@@ -21,6 +21,9 @@
 extern "C" {
 #endif
 
+/**< @internal Declaration of the hairpin peer queue information structure. */
+struct rte_hairpin_peer_info;
+
 /*
  * Definitions of all functions exported by an Ethernet driver through the
  * generic structure of type *eth_dev_ops* supplied in the *rte_eth_dev*
@@ -33,7 +36,7 @@ typedef int  (*eth_dev_configure_t)(struct rte_eth_dev *dev);
 typedef int  (*eth_dev_start_t)(struct rte_eth_dev *dev);
 /**< @internal Function used to start a configured Ethernet device. */
 
-typedef void (*eth_dev_stop_t)(struct rte_eth_dev *dev);
+typedef int (*eth_dev_stop_t)(struct rte_eth_dev *dev);
 /**< @internal Function used to stop a configured Ethernet device. */
 
 typedef int  (*eth_dev_set_link_up_t)(struct rte_eth_dev *dev);
@@ -462,17 +465,28 @@ typedef int (*eth_get_module_eeprom_t)(struct rte_eth_dev *dev,
                                       struct rte_dev_eeprom_info *info);
 /**< @internal Retrieve plugin module eeprom data */
 
-typedef int (*eth_l2_tunnel_eth_type_conf_t)
-       (struct rte_eth_dev *dev, struct rte_eth_l2_tunnel_conf *l2_tunnel);
-/**< @internal config l2 tunnel ether type */
-
-typedef int (*eth_l2_tunnel_offload_set_t)
-       (struct rte_eth_dev *dev,
-        struct rte_eth_l2_tunnel_conf *l2_tunnel,
-        uint32_t mask,
-        uint8_t en);
-/**< @internal enable/disable the l2 tunnel offload functions */
+/**
+ * Feature filter types
+ */
+enum rte_filter_type {
+       RTE_ETH_FILTER_NONE = 0,
+       RTE_ETH_FILTER_ETHERTYPE,
+       RTE_ETH_FILTER_FLEXIBLE,
+       RTE_ETH_FILTER_SYN,
+       RTE_ETH_FILTER_NTUPLE,
+       RTE_ETH_FILTER_TUNNEL,
+       RTE_ETH_FILTER_FDIR,
+       RTE_ETH_FILTER_HASH,
+       RTE_ETH_FILTER_L2_TUNNEL,
+       RTE_ETH_FILTER_GENERIC,
+};
 
+/**
+ * Generic operations on filters
+ */
+enum rte_filter_op {
+       RTE_ETH_FILTER_GET,      /**< get flow API ops */
+};
 
 typedef int (*eth_filter_ctrl_t)(struct rte_eth_dev *dev,
                                 enum rte_filter_type filter_type,
@@ -655,6 +669,37 @@ 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.
@@ -703,6 +748,21 @@ typedef int (*eth_hairpin_bind_t)(struct rte_eth_dev *dev,
 typedef int (*eth_hairpin_unbind_t)(struct rte_eth_dev *dev,
                                  uint16_t rx_port);
 
+typedef int (*eth_hairpin_queue_peer_update_t)
+       (struct rte_eth_dev *dev, uint16_t peer_queue,
+        struct rte_hairpin_peer_info *current_info,
+        struct rte_hairpin_peer_info *peer_info, uint32_t direction);
+/**< @internal Update and fetch peer queue information. */
+
+typedef int (*eth_hairpin_queue_peer_bind_t)
+       (struct rte_eth_dev *dev, uint16_t cur_queue,
+        struct rte_hairpin_peer_info *peer_info, uint32_t direction);
+/**< @internal Bind peer queue to the current queue with fetched information. */
+
+typedef int (*eth_hairpin_queue_peer_unbind_t)
+       (struct rte_eth_dev *dev, uint16_t cur_queue, uint32_t direction);
+/**< @internal Unbind peer queue from the current queue. */
+
 /**
  * @internal A structure containing the functions exported by an Ethernet driver.
  */
@@ -782,10 +842,6 @@ struct eth_dev_ops {
 
        eth_udp_tunnel_port_add_t  udp_tunnel_port_add; /** Add UDP tunnel port. */
        eth_udp_tunnel_port_del_t  udp_tunnel_port_del; /** Del UDP tunnel port. */
-       eth_l2_tunnel_eth_type_conf_t l2_tunnel_eth_type_conf;
-       /** Config ether type of l2 tunnel. */
-       eth_l2_tunnel_offload_set_t   l2_tunnel_offload_set;
-       /** Enable/disable l2 tunnel offload functions. */
 
        eth_set_queue_rate_limit_t set_queue_rate_limit; /**< Set queue rate limit. */
 
@@ -849,10 +905,18 @@ 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. */
+       eth_hairpin_queue_peer_update_t hairpin_queue_peer_update;
+       /**< Pass the current queue info and get the peer queue info. */
+       eth_hairpin_queue_peer_bind_t hairpin_queue_peer_bind;
+       /**< Set up the connection between the pair of hairpin queues. */
+       eth_hairpin_queue_peer_unbind_t hairpin_queue_peer_unbind;
+       /**< Disconnect the hairpin queues of a pair from each other. */
 };
 
 /**
@@ -1208,6 +1272,169 @@ __rte_internal
 int
 rte_eth_dev_destroy(struct rte_eth_dev *ethdev, ethdev_uninit_t ethdev_uninit);
 
+/**
+ * @internal
+ * Pass the current hairpin queue HW and/or SW information to the peer queue
+ * and fetch back the information of the peer queue.
+ *
+ * @param peer_port
+ *  Peer port identifier of the Ethernet device.
+ * @param peer_queue
+ *  Peer queue index of the port.
+ * @param cur_info
+ *  Pointer to the current information structure.
+ * @param peer_info
+ *  Pointer to the peer information, output.
+ * @param direction
+ *  Direction to pass the information.
+ *  positive - pass Tx queue information and get peer Rx queue information
+ *  zero - pass Rx queue information and get peer Tx queue information
+ *
+ * @return
+ *  Negative errno value on error, 0 on success.
+ */
+__rte_internal
+int
+rte_eth_hairpin_queue_peer_update(uint16_t peer_port, uint16_t peer_queue,
+                                 struct rte_hairpin_peer_info *cur_info,
+                                 struct rte_hairpin_peer_info *peer_info,
+                                 uint32_t direction);
+
+/**
+ * @internal
+ * Configure current hairpin queue with the peer information fetched to create
+ * the connection (bind) with peer queue in the specified direction.
+ * This function might need to be called twice to fully create the connections.
+ *
+ * @param cur_port
+ *  Current port identifier of the Ethernet device.
+ * @param cur_queue
+ *  Current queue index of the port.
+ * @param peer_info
+ *  Pointer to the peer information, input.
+ * @param direction
+ *  Direction to create the connection.
+ *  positive - bind current Tx queue to peer Rx queue
+ *  zero - bind current Rx queue to peer Tx queue
+ *
+ * @return
+ *  Negative errno value on error, 0 on success.
+ */
+__rte_internal
+int
+rte_eth_hairpin_queue_peer_bind(uint16_t cur_port, uint16_t cur_queue,
+                               struct rte_hairpin_peer_info *peer_info,
+                               uint32_t direction);
+
+/**
+ * @internal
+ * Reset the current queue state and configuration to disconnect (unbind) it
+ * from the peer queue.
+ * This function might need to be called twice to disconnect each other.
+ *
+ * @param cur_port
+ *  Current port identifier of the Ethernet device.
+ * @param cur_queue
+ *  Current queue index of the port.
+ * @param direction
+ *  Direction to destroy the connection.
+ *  positive - unbind current Tx queue from peer Rx queue
+ *  zero - unbind current Rx queue from peer Tx queue
+ *
+ * @return
+ *  Negative errno value on error, 0 on success.
+ */
+__rte_internal
+int
+rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t cur_queue,
+                                 uint32_t direction);
+
+
+/*
+ * Legacy ethdev API used internally by drivers.
+ */
+
+/**
+ * Define all structures for Ethertype Filter type.
+ */
+
+#define RTE_ETHTYPE_FLAGS_MAC    0x0001 /**< If set, compare mac */
+#define RTE_ETHTYPE_FLAGS_DROP   0x0002 /**< If set, drop packet when match */
+
+/**
+ * A structure used to define the ethertype filter entry
+ * to support RTE_ETH_FILTER_ETHERTYPE data representation.
+ */
+struct rte_eth_ethertype_filter {
+       struct rte_ether_addr mac_addr;   /**< Mac address to match. */
+       uint16_t ether_type;          /**< Ether type to match */
+       uint16_t flags;               /**< Flags from RTE_ETHTYPE_FLAGS_* */
+       uint16_t queue;               /**< Queue assigned to when match*/
+};
+
+/**
+ * A structure used to define the TCP syn filter entry
+ * to support RTE_ETH_FILTER_SYN data representation.
+ */
+struct rte_eth_syn_filter {
+       /** 1 - higher priority than other filters, 0 - lower priority. */
+       uint8_t hig_pri;
+       uint16_t queue;      /**< Queue assigned to when match */
+};
+
+/**
+ * filter type of tunneling packet
+ */
+#define ETH_TUNNEL_FILTER_OMAC  0x01 /**< filter by outer MAC addr */
+#define ETH_TUNNEL_FILTER_OIP   0x02 /**< filter by outer IP Addr */
+#define ETH_TUNNEL_FILTER_TENID 0x04 /**< filter by tenant ID */
+#define ETH_TUNNEL_FILTER_IMAC  0x08 /**< filter by inner MAC addr */
+#define ETH_TUNNEL_FILTER_IVLAN 0x10 /**< filter by inner VLAN ID */
+#define ETH_TUNNEL_FILTER_IIP   0x20 /**< filter by inner IP addr */
+
+#define RTE_TUNNEL_FILTER_IMAC_IVLAN (ETH_TUNNEL_FILTER_IMAC | \
+                                       ETH_TUNNEL_FILTER_IVLAN)
+#define RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID (ETH_TUNNEL_FILTER_IMAC | \
+                                       ETH_TUNNEL_FILTER_IVLAN | \
+                                       ETH_TUNNEL_FILTER_TENID)
+#define RTE_TUNNEL_FILTER_IMAC_TENID (ETH_TUNNEL_FILTER_IMAC | \
+                                       ETH_TUNNEL_FILTER_TENID)
+#define RTE_TUNNEL_FILTER_OMAC_TENID_IMAC (ETH_TUNNEL_FILTER_OMAC | \
+                                       ETH_TUNNEL_FILTER_TENID | \
+                                       ETH_TUNNEL_FILTER_IMAC)
+
+/**
+ *  Select IPv4 or IPv6 for tunnel filters.
+ */
+enum rte_tunnel_iptype {
+       RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4. */
+       RTE_TUNNEL_IPTYPE_IPV6,     /**< IPv6. */
+};
+
+/**
+ * Tunneling Packet filter configuration.
+ */
+struct rte_eth_tunnel_filter_conf {
+       struct rte_ether_addr outer_mac;    /**< Outer MAC address to match. */
+       struct rte_ether_addr inner_mac;    /**< Inner MAC address to match. */
+       uint16_t inner_vlan;            /**< Inner VLAN to match. */
+       enum rte_tunnel_iptype ip_type; /**< IP address type. */
+       /**
+        * Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP
+        * is set in filter_type, or inner destination IP address to match
+        * if ETH_TUNNEL_FILTER_IIP is set in filter_type.
+        */
+       union {
+               uint32_t ipv4_addr;     /**< IPv4 address in big endian. */
+               uint32_t ipv6_addr[4];  /**< IPv6 address in big endian. */
+       } ip_addr;
+       /** Flags from ETH_TUNNEL_FILTER_XX - see above. */
+       uint16_t filter_type;
+       enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
+       uint32_t tenant_id;     /**< Tenant ID to match. VNI, GRE key... */
+       uint16_t queue_id;      /**< Queue assigned to if match. */
+};
+
 #ifdef __cplusplus
 }
 #endif