ethdev: UDP tunnels
authorJijiang Liu <jijiang.liu@intel.com>
Thu, 23 Oct 2014 13:18:53 +0000 (21:18 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 27 Oct 2014 13:37:34 +0000 (14:37 +0100)
Add two functions to support UDP tunneling port configuration.

There are "some" destination UDP port numbers that have unique meaning.
In terms of VxLAN, "IANA has assigned the value 4789 for the VXLAN UDP port,
and this value SHOULD be used by default as the destination UDP port.
Some early implementations of VXLAN have used other values for the destination
port. To enable interoperability with these implementations, the destination
port SHOULD be configurable."

Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
Acked-by: Helin Zhang <helin.zhang@intel.com>
Tested-by: Yong Liu <yong.liu@intel.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
lib/librte_ether/rte_eth_ctrl.h
lib/librte_ether/rte_ethdev.c
lib/librte_ether/rte_ethdev.h

index df21ac6..9a90d19 100644 (file)
@@ -71,6 +71,18 @@ enum rte_filter_op {
        RTE_ETH_FILTER_OP_MAX
 };
 
+/**
+ * Tunneled type.
+ */
+enum rte_eth_tunnel_type {
+       RTE_TUNNEL_TYPE_NONE = 0,
+       RTE_TUNNEL_TYPE_VXLAN,
+       RTE_TUNNEL_TYPE_GENEVE,
+       RTE_TUNNEL_TYPE_TEREDO,
+       RTE_TUNNEL_TYPE_NVGRE,
+       RTE_TUNNEL_TYPE_MAX,
+};
+
 #ifdef __cplusplus
 }
 #endif
index 50f10d9..ff1c769 100644 (file)
@@ -2037,6 +2037,58 @@ rte_eth_dev_rss_hash_conf_get(uint8_t port_id,
        return (*dev->dev_ops->rss_hash_conf_get)(dev, rss_conf);
 }
 
+int
+rte_eth_dev_udp_tunnel_add(uint8_t port_id,
+                          struct rte_eth_udp_tunnel *udp_tunnel)
+{
+       struct rte_eth_dev *dev;
+
+       if (port_id >= nb_ports) {
+               PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+               return -ENODEV;
+       }
+
+       if (udp_tunnel == NULL) {
+               PMD_DEBUG_TRACE("Invalid udp_tunnel parameter\n");
+               return -EINVAL;
+       }
+
+       if (udp_tunnel->prot_type >= RTE_TUNNEL_TYPE_MAX) {
+               PMD_DEBUG_TRACE("Invalid tunnel type\n");
+               return -EINVAL;
+       }
+
+       dev = &rte_eth_devices[port_id];
+       FUNC_PTR_OR_ERR_RET(*dev->dev_ops->udp_tunnel_add, -ENOTSUP);
+       return (*dev->dev_ops->udp_tunnel_add)(dev, udp_tunnel);
+}
+
+int
+rte_eth_dev_udp_tunnel_delete(uint8_t port_id,
+                             struct rte_eth_udp_tunnel *udp_tunnel)
+{
+       struct rte_eth_dev *dev;
+
+       if (port_id >= nb_ports) {
+               PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+               return -ENODEV;
+       }
+       dev = &rte_eth_devices[port_id];
+
+       if (udp_tunnel == NULL) {
+               PMD_DEBUG_TRACE("Invalid udp_tunnel parametr\n");
+               return -EINVAL;
+       }
+
+       if (udp_tunnel->prot_type >= RTE_TUNNEL_TYPE_MAX) {
+               PMD_DEBUG_TRACE("Invalid tunnel type\n");
+               return -EINVAL;
+       }
+
+       FUNC_PTR_OR_ERR_RET(*dev->dev_ops->udp_tunnel_del, -ENOTSUP);
+       return (*dev->dev_ops->udp_tunnel_del)(dev, udp_tunnel);
+}
+
 int
 rte_eth_led_on(uint8_t port_id)
 {
index b69a6af..8bf274d 100644 (file)
@@ -709,6 +709,14 @@ struct rte_fdir_conf {
        uint8_t drop_queue;
 };
 
+/**
+ * UDP tunneling configuration.
+ */
+struct rte_eth_udp_tunnel {
+       uint16_t udp_port;
+       uint8_t prot_type;
+};
+
 /**
  *  Possible l4type of FDIR filters.
  */
@@ -1266,6 +1274,15 @@ typedef int (*eth_mirror_rule_reset_t)(struct rte_eth_dev *dev,
                                  uint8_t rule_id);
 /**< @internal Remove a traffic mirroring rule on an Ethernet device */
 
+typedef int (*eth_udp_tunnel_add_t)(struct rte_eth_dev *dev,
+                                   struct rte_eth_udp_tunnel *tunnel_udp);
+/**< @internal Add tunneling UDP info */
+
+typedef int (*eth_udp_tunnel_del_t)(struct rte_eth_dev *dev,
+                                   struct rte_eth_udp_tunnel *tunnel_udp);
+/**< @internal Delete tunneling UDP info */
+
+
 #ifdef RTE_NIC_BYPASS
 
 enum {
@@ -1446,6 +1463,8 @@ struct eth_dev_ops {
        eth_set_vf_rx_t            set_vf_rx;  /**< enable/disable a VF receive */
        eth_set_vf_tx_t            set_vf_tx;  /**< enable/disable a VF transmit */
        eth_set_vf_vlan_filter_t   set_vf_vlan_filter;  /**< Set VF VLAN filter */
+       eth_udp_tunnel_add_t       udp_tunnel_add;
+       eth_udp_tunnel_del_t       udp_tunnel_del;
        eth_set_queue_rate_limit_t set_queue_rate_limit;   /**< Set queue rate limit */
        eth_set_vf_rate_limit_t    set_vf_rate_limit;   /**< Set VF rate limit */
 
@@ -3342,6 +3361,41 @@ int
 rte_eth_dev_rss_hash_conf_get(uint8_t port_id,
                              struct rte_eth_rss_conf *rss_conf);
 
+ /**
+ * Add UDP tunneling port of an Ethernet device for filtering a specific
+ * tunneling packet by UDP port number.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param tunnel_udp
+ *   UDP tunneling configuration.
+ *
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if port identifier is invalid.
+ *   - (-ENOTSUP) if hardware doesn't support tunnel type.
+ */
+int
+rte_eth_dev_udp_tunnel_add(uint8_t port_id,
+                          struct rte_eth_udp_tunnel *tunnel_udp);
+
+ /**
+ * Detete UDP tunneling port configuration of Ethernet device
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param tunnel_udp
+ *   UDP tunneling configuration.
+ *
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if port identifier is invalid.
+ *   - (-ENOTSUP) if hardware doesn't support tunnel type.
+ */
+int
+rte_eth_dev_udp_tunnel_delete(uint8_t port_id,
+                             struct rte_eth_udp_tunnel *tunnel_udp);
+
 /**
  * add syn filter
  *