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 62550A0508; Thu, 7 Apr 2022 04:59:13 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 533214285E; Thu, 7 Apr 2022 04:58:48 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id A887E410DD for ; Thu, 7 Apr 2022 04:58:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649300326; x=1680836326; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ej+hNt6aRetaFtO6hTS6hPkvkACq5l0iXPnR186tnes=; b=ZiZ4kQYPLPBVsugu6DbLuzRwda57PF981crE3tU3xN1G9ss6snXjZNp0 wBQhLvxjji18KmzZNfhhn452hm0Ypnxlz65dBotJ7B0/idhn7aPna3WCS 6GjVpwWyXktFzRsTfSmcqdu2kHe0IdIc8wexawBAkgrNCmPLFixKRi2Ui 8ekbKFDUQJJ2tjhPv9C8huqoxgMclJDo7WD0+xS3s4zRhchkPKbiVfO8h WcbiJX6Y4RD/b6hbEwhnC4FmrNtaELgUpNAwUslmEgzdrXGM24cOyQNqD LVpiI5kb6VB/e4QFL37TKCL/zV/N7LW70E6oTlU7sxGR2jBYMPPJ9xyzp Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10309"; a="248738353" X-IronPort-AV: E=Sophos;i="5.90,241,1643702400"; d="scan'208";a="248738353" 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:46 -0700 X-IronPort-AV: E=Sophos;i="5.90,241,1643702400"; d="scan'208";a="570850559" 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:43 -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 11/39] net/ice/base: add VXLAN support for switch filter Date: Thu, 7 Apr 2022 10:56:38 +0000 Message-Id: <20220407105706.18889-12-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/base/ice_protocol_type.h | 6 + drivers/net/ice/base/ice_switch.c | 213 ++++++++++++++++++++++- drivers/net/ice/base/ice_switch.h | 12 ++ 3 files changed, 230 insertions(+), 1 deletion(-) diff --git a/drivers/net/ice/base/ice_protocol_type.h b/drivers/net/ice/base/ice_protocol_type.h index 0e6e5990be..d6332c5690 100644 --- a/drivers/net/ice/base/ice_protocol_type.h +++ b/drivers/net/ice/base/ice_protocol_type.h @@ -112,6 +112,12 @@ enum ice_sw_tunnel_type { ICE_SW_TUN_IPV6_NAT_T, ICE_SW_TUN_IPV4_L2TPV3, ICE_SW_TUN_IPV6_L2TPV3, + ICE_SW_TUN_PROFID_IPV4_VXLAN, + ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV4, + ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV6, + ICE_SW_TUN_PROFID_IPV6_VXLAN, + ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV4, + ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV6, ICE_SW_TUN_PROFID_IPV6_ESP, ICE_SW_TUN_PROFID_IPV6_AH, ICE_SW_TUN_PROFID_MAC_IPV6_L2TPV3, diff --git a/drivers/net/ice/base/ice_switch.c b/drivers/net/ice/base/ice_switch.c index d4cc664ad7..b0c50c8f40 100644 --- a/drivers/net/ice/base/ice_switch.c +++ b/drivers/net/ice/base/ice_switch.c @@ -228,6 +228,117 @@ static const u8 dummy_udp_tun_udp_packet[] = { 0x00, 0x08, 0x00, 0x00, }; +static const +struct ice_dummy_pkt_offsets dummy_udp_tun_ipv6_tcp_packet_offsets[] = { + { ICE_MAC_OFOS, 0 }, + { ICE_ETYPE_OL, 12 }, + { ICE_IPV4_OFOS, 14 }, + { ICE_UDP_OF, 34 }, + { ICE_VXLAN, 42 }, + { ICE_GENEVE, 42 }, + { ICE_VXLAN_GPE, 42 }, + { ICE_MAC_IL, 50 }, + { ICE_IPV6_IL, 64 }, + { ICE_TCP_IL, 104 }, + { ICE_PROTOCOL_LAST, 0 }, +}; + +static const u8 dummy_udp_tun_ipv6_tcp_packet[] = { + 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x08, 0x00, /* ICE_ETYPE_OL 12 */ + + 0x45, 0x00, 0x00, 0x5a, /* ICE_IPV4_OFOS 14 */ + 0x00, 0x01, 0x00, 0x00, + 0x40, 0x11, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x12, 0xb5, /* ICE_UDP_OF 34 */ + 0x00, 0x46, 0x00, 0x00, + + 0x00, 0x00, 0x65, 0x58, /* ICE_VXLAN 42 */ + 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_IL 50 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x86, 0xdd, + + 0x60, 0x00, 0x00, 0x00, /* ICE_IPV4_IL 64 */ + 0x00, 0x00, 0x06, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, /* ICE_TCP_IL 104 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x50, 0x02, 0x20, 0x00, + 0x00, 0x00, 0x00, 0x00 +}; + +static const +struct ice_dummy_pkt_offsets dummy_udp_tun_ipv6_udp_packet_offsets[] = { + { ICE_MAC_OFOS, 0 }, + { ICE_ETYPE_OL, 12 }, + { ICE_IPV4_OFOS, 14 }, + { ICE_UDP_OF, 34 }, + { ICE_VXLAN, 42 }, + { ICE_GENEVE, 42 }, + { ICE_VXLAN_GPE, 42 }, + { ICE_MAC_IL, 50 }, + { ICE_IPV6_IL, 64 }, + { ICE_UDP_ILOS, 104 }, + { ICE_PROTOCOL_LAST, 0 }, +}; + +static const u8 dummy_udp_tun_ipv6_udp_packet[] = { + 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x08, 0x00, /* ICE_ETYPE_OL 12 */ + + 0x45, 0x00, 0x00, 0x4e, /* ICE_IPV4_OFOS 14 */ + 0x00, 0x01, 0x00, 0x00, + 0x00, 0x11, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x12, 0xb5, /* ICE_UDP_OF 34 */ + 0x00, 0x3a, 0x00, 0x00, + + 0x00, 0x00, 0x65, 0x58, /* ICE_VXLAN 42 */ + 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_IL 50 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x86, 0xdd, + + 0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_IL 64 */ + 0x00, 0x58, 0x11, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, /* ICE_UDP_ILOS 104 */ + 0x00, 0x08, 0x00, 0x00, +}; + /* offset info for MAC + IPv4 + UDP dummy packet */ static const struct ice_dummy_pkt_offsets dummy_udp_packet_offsets[] = { { ICE_MAC_OFOS, 0 }, @@ -2001,6 +2112,10 @@ static enum ice_sw_tunnel_type ice_get_tun_type_for_recipe(u8 rid, bool vlan) u8 gre_profile[12] = {13, 14, 15, 19, 20, 21, 28, 29, 30, 31, 32, 33}; u8 pppoe_profile[7] = {34, 35, 36, 37, 38, 39, 40}; u8 non_tun_profile[6] = {4, 5, 6, 7, 8, 9}; + bool ipv4_vxlan_ipv4_valid = false; + bool ipv4_vxlan_ipv6_valid = false; + bool ipv6_vxlan_ipv4_valid = false; + bool ipv6_vxlan_ipv6_valid = false; enum ice_sw_tunnel_type tun_type; u16 i, j, k, profile_num = 0; bool non_tun_valid = false; @@ -2022,8 +2137,17 @@ static enum ice_sw_tunnel_type ice_get_tun_type_for_recipe(u8 rid, bool vlan) } for (i = 0; i < 12; i++) { - if (vxlan_profile[i] == j) + if (vxlan_profile[i] == j) { vxlan_valid = true; + if (i < 3) + ipv4_vxlan_ipv4_valid = true; + else if (i < 6) + ipv6_vxlan_ipv4_valid = true; + else if (i < 9) + ipv4_vxlan_ipv6_valid = true; + else if (i < 12) + ipv6_vxlan_ipv6_valid = true; + } } for (i = 0; i < 7; i++) { @@ -2083,6 +2207,20 @@ static enum ice_sw_tunnel_type ice_get_tun_type_for_recipe(u8 rid, bool vlan) break; } } + if (tun_type == ICE_SW_TUN_VXLAN) { + if (ipv4_vxlan_ipv4_valid && ipv4_vxlan_ipv6_valid) + tun_type = ICE_SW_TUN_PROFID_IPV4_VXLAN; + else if (ipv6_vxlan_ipv4_valid && ipv6_vxlan_ipv6_valid) + tun_type = ICE_SW_TUN_PROFID_IPV6_VXLAN; + else if (ipv4_vxlan_ipv4_valid) + tun_type = ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV4; + else if (ipv4_vxlan_ipv6_valid) + tun_type = ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV6; + else if (ipv6_vxlan_ipv4_valid) + tun_type = ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV4; + else if (ipv6_vxlan_ipv6_valid) + tun_type = ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV6; + } if (profile_num == 1 && (flag_valid || non_tun_valid || pppoe_valid)) { for (j = 0; j < ICE_MAX_NUM_PROFILES; j++) { @@ -7496,6 +7634,12 @@ static bool ice_tun_type_match_word(enum ice_sw_tunnel_type tun_type, u16 *mask) case ICE_SW_TUN_VXLAN_GPE: case ICE_SW_TUN_GENEVE: case ICE_SW_TUN_VXLAN: + case ICE_SW_TUN_PROFID_IPV4_VXLAN: + case ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV4: + case ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV6: + case ICE_SW_TUN_PROFID_IPV6_VXLAN: + case ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV4: + case ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV6: case ICE_SW_TUN_NVGRE: case ICE_SW_TUN_UDP: case ICE_ALL_TUNNELS: @@ -7613,6 +7757,42 @@ ice_get_compat_fv_bitmap(struct ice_hw *hw, struct ice_adv_rule_info *rinfo, case ICE_SW_TUN_PPPOE_IPV6_UDP: ice_set_bit(ICE_PROFID_PPPOE_IPV6_UDP, bm); return; + case ICE_SW_TUN_PROFID_IPV4_VXLAN: + ice_set_bit(ICE_PROFID_IPV4_TUN_M_IPV4_TCP, bm); + ice_set_bit(ICE_PROFID_IPV4_TUN_M_IPV4_UDP, bm); + ice_set_bit(ICE_PROFID_IPV4_TUN_M_IPV4_OTHER, bm); + ice_set_bit(ICE_PROFID_IPV4_TUN_M_IPV6_TCP, bm); + ice_set_bit(ICE_PROFID_IPV4_TUN_M_IPV6_UDP, bm); + ice_set_bit(ICE_PROFID_IPV4_TUN_M_IPV6_OTHER, bm); + return; + case ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV4: + ice_set_bit(ICE_PROFID_IPV4_TUN_M_IPV4_TCP, bm); + ice_set_bit(ICE_PROFID_IPV4_TUN_M_IPV4_UDP, bm); + ice_set_bit(ICE_PROFID_IPV4_TUN_M_IPV4_OTHER, bm); + return; + case ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV6: + ice_set_bit(ICE_PROFID_IPV4_TUN_M_IPV6_TCP, bm); + ice_set_bit(ICE_PROFID_IPV4_TUN_M_IPV6_UDP, bm); + ice_set_bit(ICE_PROFID_IPV4_TUN_M_IPV6_OTHER, bm); + return; + case ICE_SW_TUN_PROFID_IPV6_VXLAN: + ice_set_bit(ICE_PROFID_IPV6_TUN_M_IPV4_TCP, bm); + ice_set_bit(ICE_PROFID_IPV6_TUN_M_IPV4_UDP, bm); + ice_set_bit(ICE_PROFID_IPV6_TUN_M_IPV4_OTHER, bm); + ice_set_bit(ICE_PROFID_IPV6_TUN_M_IPV6_TCP, bm); + ice_set_bit(ICE_PROFID_IPV6_TUN_M_IPV6_UDP, bm); + ice_set_bit(ICE_PROFID_IPV6_TUN_M_IPV6_OTHER, bm); + return; + case ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV4: + ice_set_bit(ICE_PROFID_IPV6_TUN_M_IPV4_TCP, bm); + ice_set_bit(ICE_PROFID_IPV6_TUN_M_IPV4_UDP, bm); + ice_set_bit(ICE_PROFID_IPV6_TUN_M_IPV4_OTHER, bm); + return; + case ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV6: + ice_set_bit(ICE_PROFID_IPV6_TUN_M_IPV6_TCP, bm); + ice_set_bit(ICE_PROFID_IPV6_TUN_M_IPV6_UDP, bm); + ice_set_bit(ICE_PROFID_IPV6_TUN_M_IPV6_OTHER, bm); + return; case ICE_SW_TUN_PROFID_IPV6_ESP: case ICE_SW_TUN_IPV6_ESP: ice_set_bit(ICE_PROFID_IPV6_ESP, bm); @@ -7780,6 +7960,12 @@ bool ice_is_prof_rule(enum ice_sw_tunnel_type type) { switch (type) { case ICE_SW_TUN_AND_NON_TUN: + case ICE_SW_TUN_PROFID_IPV4_VXLAN: + case ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV4: + case ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV6: + case ICE_SW_TUN_PROFID_IPV6_VXLAN: + case ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV4: + case ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV6: case ICE_SW_TUN_PROFID_IPV6_ESP: case ICE_SW_TUN_PROFID_IPV6_AH: case ICE_SW_TUN_PROFID_MAC_IPV6_L2TPV3: @@ -8396,8 +8582,27 @@ ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt, return; } + if (tun_type == ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV6 || + tun_type == ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV6) { + if (tcp) { + *pkt = dummy_udp_tun_ipv6_tcp_packet; + *pkt_len = sizeof(dummy_udp_tun_ipv6_tcp_packet); + *offsets = dummy_udp_tun_ipv6_tcp_packet_offsets; + return; + } + + *pkt = dummy_udp_tun_ipv6_udp_packet; + *pkt_len = sizeof(dummy_udp_tun_ipv6_udp_packet); + *offsets = dummy_udp_tun_ipv6_udp_packet_offsets; + return; + } + if (tun_type == ICE_SW_TUN_VXLAN || tun_type == ICE_SW_TUN_GENEVE || tun_type == ICE_SW_TUN_VXLAN_GPE || tun_type == ICE_SW_TUN_UDP || + tun_type == ICE_SW_TUN_PROFID_IPV4_VXLAN || + tun_type == ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV4 || + tun_type == ICE_SW_TUN_PROFID_IPV6_VXLAN || + tun_type == ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV4 || tun_type == ICE_SW_TUN_GENEVE_VLAN || tun_type == ICE_SW_TUN_VXLAN_VLAN) { if (tcp) { @@ -8613,6 +8818,12 @@ ice_fill_adv_packet_tun(struct ice_hw *hw, enum ice_sw_tunnel_type tun_type, case ICE_SW_TUN_AND_NON_TUN: case ICE_SW_TUN_VXLAN_GPE: case ICE_SW_TUN_VXLAN: + case ICE_SW_TUN_PROFID_IPV4_VXLAN: + case ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV4: + case ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV6: + case ICE_SW_TUN_PROFID_IPV6_VXLAN: + case ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV4: + case ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV6: case ICE_SW_TUN_VXLAN_VLAN: case ICE_SW_TUN_UDP: if (!ice_get_open_tunnel_port(hw, TNL_VXLAN, &open_port)) diff --git a/drivers/net/ice/base/ice_switch.h b/drivers/net/ice/base/ice_switch.h index a2b3c80107..efb9399b77 100644 --- a/drivers/net/ice/base/ice_switch.h +++ b/drivers/net/ice/base/ice_switch.h @@ -20,6 +20,18 @@ #define ICE_PROFID_IPV4_UDP 5 #define ICE_PROFID_IPV6_TCP 7 #define ICE_PROFID_IPV6_UDP 8 +#define ICE_PROFID_IPV4_TUN_M_IPV4_TCP 10 +#define ICE_PROFID_IPV4_TUN_M_IPV4_UDP 11 +#define ICE_PROFID_IPV4_TUN_M_IPV4_OTHER 12 +#define ICE_PROFID_IPV6_TUN_M_IPV4_TCP 16 +#define ICE_PROFID_IPV6_TUN_M_IPV4_UDP 17 +#define ICE_PROFID_IPV6_TUN_M_IPV4_OTHER 18 +#define ICE_PROFID_IPV4_TUN_M_IPV6_TCP 22 +#define ICE_PROFID_IPV4_TUN_M_IPV6_UDP 23 +#define ICE_PROFID_IPV4_TUN_M_IPV6_OTHER 24 +#define ICE_PROFID_IPV6_TUN_M_IPV6_TCP 25 +#define ICE_PROFID_IPV6_TUN_M_IPV6_UDP 26 +#define ICE_PROFID_IPV6_TUN_M_IPV6_OTHER 27 #define ICE_PROFID_PPPOE_PAY 34 #define ICE_PROFID_PPPOE_IPV4_TCP 35 #define ICE_PROFID_PPPOE_IPV4_UDP 36 -- 2.33.1