From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7BE58A0508; Thu, 7 Apr 2022 04:59:20 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CADCA42886; Thu, 7 Apr 2022 04:58:51 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 5126342886 for ; Thu, 7 Apr 2022 04:58:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649300329; x=1680836329; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GypuUfHl5KQvgLq0XITj/gqSyLC9O1aub31sne0FyNQ=; b=WiKCxrDP+BfypISXz3Hev1owU1ygSoTdMFCltpouPrqimxTPvDMR2Q7h h4lc48zplZWweDm6w8yFHRd7vHQeILLW/EOzAlbhu9Z+9/TXeaTyVUHJy vp6gtJA9yArsKZS9FN6VncRVF7f1A0DTjTgySryBrCy4iPMMvbAmUYsn4 Yxlzn/EgKkQxTCvk6b9GLyisAfAttBaqXnj/R6Fsp+doyu0n3+XFedtAd s+VgWD1bCnCI2YEdkoWG/d3iH0qvleHLnF8fyd0gTl21oqWUf8JheTZ8s OpNXkuRZyUDeFmQjH3KE446V5kg7GOl/YQdJDM1ie8sj8nhWSViH7KJFu A==; X-IronPort-AV: E=McAfee;i="6200,9189,10309"; a="248738358" X-IronPort-AV: E=Sophos;i="5.90,241,1643702400"; d="scan'208";a="248738358" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2022 19:58:48 -0700 X-IronPort-AV: E=Sophos;i="5.90,241,1643702400"; d="scan'208";a="570850572" Received: from intel-cd-odc-kevin.cd.intel.com ([10.240.178.195]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2022 19:58:46 -0700 From: Kevin Liu To: dev@dpdk.org Cc: qiming.yang@intel.com, qi.z.zhang@intel.com, stevex.yang@intel.com, Junfeng Guo , Kevin Liu Subject: [PATCH 12/39] net/ice: add VXLAN support for switch filter Date: Thu, 7 Apr 2022 10:56:39 +0000 Message-Id: <20220407105706.18889-13-kevinx.liu@intel.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220407105706.18889-1-kevinx.liu@intel.com> References: <20220407105706.18889-1-kevinx.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Junfeng Guo 1. Add profile rule for VXLAN on Switch Filter, including pattern_eth_ipv4_udp_vxlan_any pattern_eth_ipv6_udp_vxlan_any pattern_eth_ipv4_udp_vxlan_eth_ipv4 pattern_eth_ipv4_udp_vxlan_eth_ipv6 pattern_eth_ipv6_udp_vxlan_eth_ipv4 pattern_eth_ipv6_udp_vxlan_eth_ipv6 2. Add common rule for VXLAN on Switch Filter, including +-----------------+-----------------------------------------------------+ | Pattern | Input Set | +-----------------+-----------------------------------------------------+ | ipv4_vxlan_ipv4 | vni, inner dmac, inner dst/src ip, outer dst/src ip | | ipv4_vxlan_ipv6 | vni, inner dmac, inner dst/src ip | | ipv6_vxlan_ipv4 | vni, inner dmac, inner dst/src ip | | ipv6_vxlan_ipv6 | vni, inner dmac, inner dst/src ip | +-----------------+-----------------------------------------------------+ Signed-off-by: Junfeng Guo Signed-off-by: Kevin Liu --- drivers/net/ice/ice_generic_flow.c | 20 ++++++++++ drivers/net/ice/ice_generic_flow.h | 4 ++ drivers/net/ice/ice_switch_filter.c | 59 +++++++++++++++++++++++++++-- 3 files changed, 80 insertions(+), 3 deletions(-) diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c index 53b1c0b69a..1433094ed4 100644 --- a/drivers/net/ice/ice_generic_flow.c +++ b/drivers/net/ice/ice_generic_flow.c @@ -375,6 +375,26 @@ enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv4_icmp[] = { RTE_FLOW_ITEM_TYPE_END, }; +/* IPv4 VXLAN ANY */ +enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_any[] = { + RTE_FLOW_ITEM_TYPE_ETH, + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_VXLAN, + RTE_FLOW_ITEM_TYPE_ANY, + RTE_FLOW_ITEM_TYPE_END, +}; + +/* IPv6 VXLAN ANY */ +enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_any[] = { + RTE_FLOW_ITEM_TYPE_ETH, + RTE_FLOW_ITEM_TYPE_IPV6, + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_VXLAN, + RTE_FLOW_ITEM_TYPE_ANY, + RTE_FLOW_ITEM_TYPE_END, +}; + /* IPv4 VXLAN MAC IPv4 */ enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_eth_ipv4[] = { RTE_FLOW_ITEM_TYPE_ETH, diff --git a/drivers/net/ice/ice_generic_flow.h b/drivers/net/ice/ice_generic_flow.h index 11f51a5c15..def7e2d6d6 100644 --- a/drivers/net/ice/ice_generic_flow.h +++ b/drivers/net/ice/ice_generic_flow.h @@ -175,6 +175,10 @@ extern enum rte_flow_item_type pattern_eth_ipv6_icmp6[]; extern enum rte_flow_item_type pattern_eth_vlan_ipv6_icmp6[]; extern enum rte_flow_item_type pattern_eth_qinq_ipv6_icmp6[]; +/* IPv4/IPv6 VXLAN ANY */ +extern enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_any[]; +extern enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_any[]; + /* IPv4 VXLAN IPv4 */ extern enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv4[]; extern enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv4_udp[]; diff --git a/drivers/net/ice/ice_switch_filter.c b/drivers/net/ice/ice_switch_filter.c index 36c9bffb73..e90e109eca 100644 --- a/drivers/net/ice/ice_switch_filter.c +++ b/drivers/net/ice/ice_switch_filter.c @@ -85,6 +85,19 @@ #define ICE_SW_INSET_DIST_VXLAN_IPV4 ( \ ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_DMAC | \ ICE_INSET_VXLAN_VNI) +#define ICE_SW_INSET_DIST_IPV4_VXLAN_IPV4 ( \ + ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | \ + ICE_INSET_DMAC | ICE_INSET_VXLAN_VNI | \ + ICE_INSET_TUN_IPV4_SRC | ICE_INSET_TUN_IPV4_DST) +#define ICE_SW_INSET_DIST_IPV4_VXLAN_IPV6 ( \ + ICE_INSET_DMAC | ICE_INSET_VXLAN_VNI | \ + ICE_INSET_IPV6_SRC | ICE_INSET_IPV6_DST) +#define ICE_SW_INSET_DIST_IPV6_VXLAN_IPV4 ( \ + ICE_INSET_DMAC | ICE_INSET_VXLAN_VNI | \ + ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST) +#define ICE_SW_INSET_DIST_IPV6_VXLAN_IPV6 ( \ + ICE_INSET_DMAC | ICE_INSET_VXLAN_VNI | \ + ICE_INSET_IPV6_SRC | ICE_INSET_IPV6_DST) #define ICE_SW_INSET_DIST_NVGRE_IPV4_TCP ( \ ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | \ ICE_INSET_TCP_SRC_PORT | ICE_INSET_TCP_DST_PORT | \ @@ -112,6 +125,9 @@ ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | \ ICE_INSET_UDP_SRC_PORT | ICE_INSET_UDP_DST_PORT | \ ICE_INSET_IPV4_TOS) +#define ICE_SW_INSET_PERM_TUNNEL_IPV6 ( \ + ICE_INSET_IPV6_SRC | ICE_INSET_IPV6_DST | \ + ICE_INSET_IPV6_NEXT_HDR | ICE_INSET_IPV6_TC) #define ICE_SW_INSET_MAC_PPPOE ( \ ICE_INSET_VLAN_OUTER | ICE_INSET_VLAN_INNER | \ ICE_INSET_DMAC | ICE_INSET_ETHERTYPE | ICE_INSET_PPPOE_SESSION) @@ -217,9 +233,14 @@ ice_pattern_match_item ice_switch_pattern_dist_list[] = { {pattern_eth_ipv6, ICE_SW_INSET_MAC_IPV6, ICE_INSET_NONE, ICE_INSET_NONE}, {pattern_eth_ipv6_udp, ICE_SW_INSET_MAC_IPV6_UDP, ICE_INSET_NONE, ICE_INSET_NONE}, {pattern_eth_ipv6_tcp, ICE_SW_INSET_MAC_IPV6_TCP, ICE_INSET_NONE, ICE_INSET_NONE}, + {pattern_eth_ipv4_udp_vxlan_any, ICE_INSET_NONE, ICE_INSET_NONE, ICE_INSET_NONE}, + {pattern_eth_ipv6_udp_vxlan_any, ICE_INSET_NONE, ICE_INSET_NONE, ICE_INSET_NONE}, {pattern_eth_ipv4_udp_vxlan_eth_ipv4, ICE_INSET_IPV4_DST, ICE_SW_INSET_DIST_VXLAN_IPV4, ICE_INSET_NONE}, {pattern_eth_ipv4_udp_vxlan_eth_ipv4_udp, ICE_INSET_IPV4_DST, ICE_SW_INSET_DIST_VXLAN_IPV4_UDP, ICE_INSET_NONE}, {pattern_eth_ipv4_udp_vxlan_eth_ipv4_tcp, ICE_INSET_IPV4_DST, ICE_SW_INSET_DIST_VXLAN_IPV4_TCP, ICE_INSET_NONE}, + {pattern_eth_ipv4_udp_vxlan_eth_ipv6, ICE_SW_INSET_DIST_IPV4_VXLAN_IPV6, ICE_INSET_NONE, ICE_INSET_NONE}, + {pattern_eth_ipv6_udp_vxlan_eth_ipv4, ICE_SW_INSET_DIST_IPV6_VXLAN_IPV4, ICE_INSET_NONE, ICE_INSET_NONE}, + {pattern_eth_ipv6_udp_vxlan_eth_ipv6, ICE_SW_INSET_DIST_IPV6_VXLAN_IPV6, ICE_INSET_NONE, ICE_INSET_NONE}, {pattern_eth_ipv4_nvgre_eth_ipv4, ICE_INSET_IPV4_DST, ICE_SW_INSET_DIST_NVGRE_IPV4, ICE_INSET_NONE}, {pattern_eth_ipv4_nvgre_eth_ipv4_udp, ICE_INSET_IPV4_DST, ICE_SW_INSET_DIST_NVGRE_IPV4_UDP, ICE_INSET_NONE}, {pattern_eth_ipv4_nvgre_eth_ipv4_tcp, ICE_INSET_IPV4_DST, ICE_SW_INSET_DIST_NVGRE_IPV4_TCP, ICE_INSET_NONE}, @@ -301,9 +322,14 @@ ice_pattern_match_item ice_switch_pattern_perm_list[] = { {pattern_eth_ipv6, ICE_SW_INSET_MAC_IPV6, ICE_INSET_NONE, ICE_INSET_NONE}, {pattern_eth_ipv6_udp, ICE_SW_INSET_MAC_IPV6_UDP, ICE_INSET_NONE, ICE_INSET_NONE}, {pattern_eth_ipv6_tcp, ICE_SW_INSET_MAC_IPV6_TCP, ICE_INSET_NONE, ICE_INSET_NONE}, + {pattern_eth_ipv4_udp_vxlan_any, ICE_INSET_NONE, ICE_INSET_NONE, ICE_INSET_NONE}, + {pattern_eth_ipv6_udp_vxlan_any, ICE_INSET_NONE, ICE_INSET_NONE, ICE_INSET_NONE}, {pattern_eth_ipv4_udp_vxlan_eth_ipv4, ICE_INSET_NONE, ICE_SW_INSET_PERM_TUNNEL_IPV4, ICE_INSET_NONE}, {pattern_eth_ipv4_udp_vxlan_eth_ipv4_udp, ICE_INSET_NONE, ICE_SW_INSET_PERM_TUNNEL_IPV4_UDP, ICE_INSET_NONE}, {pattern_eth_ipv4_udp_vxlan_eth_ipv4_tcp, ICE_INSET_NONE, ICE_SW_INSET_PERM_TUNNEL_IPV4_TCP, ICE_INSET_NONE}, + {pattern_eth_ipv4_udp_vxlan_eth_ipv6, ICE_SW_INSET_DIST_IPV4_VXLAN_IPV6, ICE_INSET_NONE, ICE_INSET_NONE}, + {pattern_eth_ipv6_udp_vxlan_eth_ipv4, ICE_SW_INSET_DIST_IPV6_VXLAN_IPV4, ICE_INSET_NONE, ICE_INSET_NONE}, + {pattern_eth_ipv6_udp_vxlan_eth_ipv6, ICE_SW_INSET_DIST_IPV6_VXLAN_IPV6, ICE_INSET_NONE, ICE_INSET_NONE}, {pattern_eth_ipv4_nvgre_eth_ipv4, ICE_INSET_NONE, ICE_SW_INSET_PERM_TUNNEL_IPV4, ICE_INSET_NONE}, {pattern_eth_ipv4_nvgre_eth_ipv4_udp, ICE_INSET_NONE, ICE_SW_INSET_PERM_TUNNEL_IPV4_UDP, ICE_INSET_NONE}, {pattern_eth_ipv4_nvgre_eth_ipv4_tcp, ICE_INSET_NONE, ICE_SW_INSET_PERM_TUNNEL_IPV4_TCP, ICE_INSET_NONE}, @@ -566,6 +592,11 @@ ice_switch_parse_pattern(const struct rte_flow_item pattern[], bool inner_ipv6_valid = 0; bool inner_tcp_valid = 0; bool inner_udp_valid = 0; + bool ipv4_ipv4_valid = 0; + bool ipv4_ipv6_valid = 0; + bool ipv6_ipv4_valid = 0; + bool ipv6_ipv6_valid = 0; + bool any_valid = 0; uint16_t j, k, t = 0; if (*tun_type == ICE_SW_TUN_AND_NON_TUN_QINQ || @@ -586,6 +617,7 @@ ice_switch_parse_pattern(const struct rte_flow_item pattern[], switch (item_type) { case RTE_FLOW_ITEM_TYPE_ANY: *tun_type = ICE_SW_TUN_AND_NON_TUN; + any_valid = 1; break; case RTE_FLOW_ITEM_TYPE_ETH: @@ -654,6 +686,10 @@ ice_switch_parse_pattern(const struct rte_flow_item pattern[], case RTE_FLOW_ITEM_TYPE_IPV4: ipv4_spec = item->spec; ipv4_mask = item->mask; + if (ipv4_valid) + ipv4_ipv4_valid = 1; + if (ipv6_valid) + ipv6_ipv4_valid = 1; if (tunnel_valid) { inner_ipv4_valid = 1; input = &inner_input_set; @@ -734,6 +770,10 @@ ice_switch_parse_pattern(const struct rte_flow_item pattern[], case RTE_FLOW_ITEM_TYPE_IPV6: ipv6_spec = item->spec; ipv6_mask = item->mask; + if (ipv4_valid) + ipv4_ipv6_valid = 1; + if (ipv6_valid) + ipv6_ipv6_valid = 1; if (tunnel_valid) { inner_ipv6_valid = 1; input = &inner_input_set; @@ -1577,9 +1617,7 @@ ice_switch_parse_pattern(const struct rte_flow_item pattern[], } if (*tun_type == ICE_NON_TUN) { - if (vxlan_valid) - *tun_type = ICE_SW_TUN_VXLAN; - else if (nvgre_valid) + if (nvgre_valid) *tun_type = ICE_SW_TUN_NVGRE; else if (ipv4_valid && tcp_valid) *tun_type = ICE_SW_IPV4_TCP; @@ -1591,6 +1629,21 @@ ice_switch_parse_pattern(const struct rte_flow_item pattern[], *tun_type = ICE_SW_IPV6_UDP; } + if (vxlan_valid) { + if (ipv4_ipv4_valid) + *tun_type = ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV4; + else if (ipv4_ipv6_valid) + *tun_type = ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV6; + else if (ipv6_ipv4_valid) + *tun_type = ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV4; + else if (ipv6_ipv6_valid) + *tun_type = ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV6; + else if (ipv6_valid && any_valid) + *tun_type = ICE_SW_TUN_PROFID_IPV6_VXLAN; + else if (ipv4_valid && any_valid) + *tun_type = ICE_SW_TUN_PROFID_IPV4_VXLAN; + } + if (input_set_byte > MAX_INPUT_SET_BYTE) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, -- 2.33.1