From patchwork Fri Sep 12 06:33:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jijiang Liu X-Patchwork-Id: 362 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 2FD80B398; Fri, 12 Sep 2014 08:28:54 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 35D84B396 for ; Fri, 12 Sep 2014 08:28:52 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 11 Sep 2014 23:34:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,511,1406617200"; d="scan'208";a="598478035" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga002.fm.intel.com with ESMTP; 11 Sep 2014 23:34:07 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id s8C6Y5bV005968; Fri, 12 Sep 2014 14:34:05 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id s8C6Y3jC010795; Fri, 12 Sep 2014 14:34:05 +0800 Received: (from jijiangl@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s8C6Y3gP010791; Fri, 12 Sep 2014 14:34:03 +0800 From: Jijiang Liu To: dev@dpdk.org Date: Fri, 12 Sep 2014 14:33:52 +0800 Message-Id: <1410503639-10753-2-git-send-email-jijiang.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1410503639-10753-1-git-send-email-jijiang.liu@intel.com> References: <1410503639-10753-1-git-send-email-jijiang.liu@intel.com> Subject: [dpdk-dev] [PATCH v3 1/8]i40e:support VxLAN packet identification in librte_ether X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add data structures and APIs in librte_ether for supporting tunneling UDP port configuration on i40e, Currently, only VxLAN is implemented, which include - VxLAN UDP port initialization - Add APIs to configure VxLAN UDP port Signed-off-by: Jijiang Liu Acked-by: Helin Zhang Acked-by: Jingjing Wu Acked-by: Jing Chen --- lib/librte_ether/rte_ethdev.c | 63 ++++++++++++++++++++++++++++++++++ lib/librte_ether/rte_ethdev.h | 76 +++++++++++++++++++++++++++++++++++++++++ lib/librte_ether/rte_ether.h | 8 ++++ 3 files changed, 147 insertions(+), 0 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index fd1010a..325edb1 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -1892,6 +1892,69 @@ rte_eth_dev_rss_hash_conf_get(uint8_t port_id, } int +rte_eth_dev_udp_tunnel_add(uint8_t port_id, + struct rte_eth_udp_tunnel *udp_tunnel, + uint8_t count) +{ + uint8_t i; + struct rte_eth_dev *dev; + struct rte_eth_udp_tunnel *tunnel; + + 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; + } + tunnel = udp_tunnel; + + for (i = 0; i < count; i++, tunnel++) { + if (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, count); +} + +int +rte_eth_dev_udp_tunnel_delete(uint8_t port_id, + struct rte_eth_udp_tunnel *udp_tunnel, + uint8_t count) +{ + uint8_t i; + struct rte_eth_dev *dev; + struct rte_eth_udp_tunnel *tunnel; + + 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; + } + tunnel = udp_tunnel; + for (i = 0; i < count; i++, tunnel++) { + if (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, count); +} + +int rte_eth_led_on(uint8_t port_id) { struct rte_eth_dev *dev; diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 50df654..74ac313 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -708,6 +708,26 @@ struct rte_fdir_conf { }; /** + * UDP tunneling configuration. + */ +struct rte_eth_udp_tunnel { + uint16_t udp_port; + uint8_t prot_type; +}; + +/** + * 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, +}; + +/** * Possible l4type of FDIR filters. */ enum rte_l4type { @@ -829,6 +849,7 @@ struct rte_intr_conf { * configuration settings may be needed. */ struct rte_eth_conf { + enum rte_eth_tunnel_type tunnel_type; uint16_t link_speed; /**< ETH_LINK_SPEED_10[0|00|000], or 0 for autonegotation */ uint16_t link_duplex; @@ -1240,6 +1261,17 @@ 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, + uint8_t count); +/**< @internal Add tunneling UDP info */ + +typedef int (*eth_udp_tunnel_del_t)(struct rte_eth_dev *dev, + struct rte_eth_udp_tunnel *tunnel_udp, + uint8_t count); +/**< @internal Delete tunneling UDP info */ + + #ifdef RTE_NIC_BYPASS enum { @@ -1412,6 +1444,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 */ @@ -3268,6 +3302,48 @@ int rte_eth_dev_rss_hash_conf_get(uint8_t port_id, struct rte_eth_rss_conf *rss_conf); + /** + * Add tunneling UDP port configuration of Ethernet device + * + * @param port_id + * The port identifier of the Ethernet device. + * @param tunnel_udp + * Where to store the current Tunneling UDP configuration + * of the Ethernet device. + * @param count + * How many configurations are going to added. + * + * @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, + uint8_t count); + + /** + * Detete tunneling UDP port configuration of Ethernet device + * + * @param port_id + * The port identifier of the Ethernet device. + * @param tunnel_udp + * Where to store the current Tunneling UDP configuration + * of the Ethernet device. + * @param count + * How many configurations are going to deleted. + * + * @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, + uint8_t count); + /** * add syn filter * diff --git a/lib/librte_ether/rte_ether.h b/lib/librte_ether/rte_ether.h index 2e08f23..ddbdbb3 100644 --- a/lib/librte_ether/rte_ether.h +++ b/lib/librte_ether/rte_ether.h @@ -286,6 +286,12 @@ struct vlan_hdr { uint16_t eth_proto;/**< Ethernet type of encapsulated frame. */ } __attribute__((__packed__)); +/* VXLAN protocol header */ +struct vxlan_hdr { + uint32_t vx_flags; /**< VxLAN flag. */ + uint32_t vx_vni; /**< VxLAN ID. */ +} __attribute__((__packed__)); + /* Ethernet frame types */ #define ETHER_TYPE_IPv4 0x0800 /**< IPv4 Protocol. */ #define ETHER_TYPE_IPv6 0x86DD /**< IPv6 Protocol. */ @@ -294,6 +300,8 @@ struct vlan_hdr { #define ETHER_TYPE_VLAN 0x8100 /**< IEEE 802.1Q VLAN tagging. */ #define ETHER_TYPE_1588 0x88F7 /**< IEEE 802.1AS 1588 Precise Time Protocol. */ +#define ETHER_VXLAN_HLEN (sizeof(struct udp_hdr) + sizeof(struct vxlan_hdr)) + #ifdef __cplusplus } #endif