From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id CDFB4A058A; Fri, 17 Apr 2020 10:48:33 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2FCE21DECE; Fri, 17 Apr 2020 10:48:33 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 14BD01DE37 for ; Fri, 17 Apr 2020 10:48:30 +0200 (CEST) IronPort-SDR: EUaizo4NcZ8/bXJ9WHAEBFlfTjvop79nbBppqtQFMt0s/yVVqPGwr38/IHrDkayl3uR8ZkAifd n6FugAOZsJ0w== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Apr 2020 01:48:30 -0700 IronPort-SDR: JNJWEN3Xz9silpGQo/gI9Vdjag9OBSu4gXbOVMcq/0VBlIsuQXpnUs5BhPPfUprw3TW8eM7GV9 I4+IHAH0FI4g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,394,1580803200"; d="scan'208";a="289202402" Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([172.16.182.123]) by fmsmga002.fm.intel.com with ESMTP; 17 Apr 2020 01:48:28 -0700 From: Wei Zhao To: dev@dpdk.org Cc: qi.z.zhang@intel.com, qi.fu@intel.com, Wei Zhao Date: Fri, 17 Apr 2020 16:26:15 +0800 Message-Id: <20200417082617.33361-2-wei.zhao1@intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20200417082617.33361-1-wei.zhao1@intel.com> References: <20200417082617.33361-1-wei.zhao1@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 1/3] net/ice/base: add support for AH ESP and NAT-T on switch X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add dummy packet and tunnel type to support AH ESP and NAT-T on switch, now we can use spi as input set for swicth rule. Signed-off-by: Wei Zhao --- drivers/net/ice/base/ice_protocol_type.h | 12 ++ drivers/net/ice/base/ice_switch.c | 235 +++++++++++++++++++++++ drivers/net/ice/base/ice_switch.h | 1 + 3 files changed, 248 insertions(+) diff --git a/drivers/net/ice/base/ice_protocol_type.h b/drivers/net/ice/base/ice_protocol_type.h index 3fb065169..2ca7cd8ac 100644 --- a/drivers/net/ice/base/ice_protocol_type.h +++ b/drivers/net/ice/base/ice_protocol_type.h @@ -50,6 +50,7 @@ enum ice_protocol_type { ICE_L2TPV3, ICE_ESP, ICE_AH, + ICE_NAT_T, ICE_PROTOCOL_LAST }; @@ -65,6 +66,12 @@ enum ice_sw_tunnel_type { */ ICE_SW_TUN_GTP, ICE_SW_TUN_PPPOE, + ICE_SW_TUN_IPV4_ESP, + ICE_SW_TUN_IPV6_ESP, + ICE_SW_TUN_IPV4_AH, + ICE_SW_TUN_IPV6_AH, + ICE_SW_TUN_IPV4_NAT_T, + ICE_SW_TUN_IPV6_NAT_T, ICE_SW_TUN_PROFID_IPV6_ESP, ICE_SW_TUN_PROFID_IPV6_AH, ICE_SW_TUN_PROFID_MAC_IPV6_L2TPV3, @@ -287,6 +294,10 @@ struct ice_ah_hdr { __be32 seq; }; +struct ice_nat_t_hdr { + struct ice_esp_hdr esp; +}; + struct ice_nvgre { __be16 flags; __be16 protocol; @@ -309,6 +320,7 @@ union ice_prot_hdr { struct ice_l2tpv3_sess_hdr l2tpv3_sess_hdr; struct ice_esp_hdr esp_hdr; struct ice_ah_hdr ah_hdr; + struct ice_nat_t_hdr nat_t_hdr; }; /* This is mapping table entry that maps every word within a given protocol diff --git a/drivers/net/ice/base/ice_switch.c b/drivers/net/ice/base/ice_switch.c index 07f8efd65..1da438f5e 100644 --- a/drivers/net/ice/base/ice_switch.c +++ b/drivers/net/ice/base/ice_switch.c @@ -590,6 +590,176 @@ static const u8 dummy_pppoe_ipv6_packet[] = { 0x00, 0x00, /* 2 bytes for 4 bytes alignment */ }; +static const struct ice_dummy_pkt_offsets dummy_ipv4_esp_packet_offsets[] = { + { ICE_MAC_OFOS, 0 }, + { ICE_IPV4_OFOS, 14 }, + { ICE_ESP, 34 }, + { ICE_PROTOCOL_LAST, 0 }, +}; + +static const u8 dummy_ipv4_esp_pkt[] = { + 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x08, 0x00, + + 0x45, 0x00, 0x00, 0x1c, /* ICE_IPV4_IL 14 */ + 0x00, 0x00, 0x40, 0x00, + 0x40, 0x32, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, /* ICE_ESP 34 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, /* 2 bytes for 4 bytes alignment */ +}; + +static const struct ice_dummy_pkt_offsets dummy_ipv6_esp_packet_offsets[] = { + { ICE_MAC_OFOS, 0 }, + { ICE_IPV6_OFOS, 14 }, + { ICE_ESP, 54 }, + { ICE_PROTOCOL_LAST, 0 }, +}; + +static const u8 dummy_ipv6_esp_pkt[] = { + 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x86, 0xDD, + + 0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_OFOS 14 */ + 0x00, 0x08, 0x32, 0x00, /* Next header ESP */ + 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_ESP 54 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, /* 2 bytes for 4 bytes alignment */ +}; + +static const struct ice_dummy_pkt_offsets dummy_ipv4_ah_packet_offsets[] = { + { ICE_MAC_OFOS, 0 }, + { ICE_IPV4_OFOS, 14 }, + { ICE_AH, 34 }, + { ICE_PROTOCOL_LAST, 0 }, +}; + +static const u8 dummy_ipv4_ah_pkt[] = { + 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x08, 0x00, + + 0x45, 0x00, 0x00, 0x20, /* ICE_IPV4_IL 14 */ + 0x00, 0x00, 0x40, 0x00, + 0x40, 0x33, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, /* ICE_AH 34 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, /* 2 bytes for 4 bytes alignment */ +}; + +static const struct ice_dummy_pkt_offsets dummy_ipv6_ah_packet_offsets[] = { + { ICE_MAC_OFOS, 0 }, + { ICE_IPV6_OFOS, 14 }, + { ICE_AH, 54 }, + { ICE_PROTOCOL_LAST, 0 }, +}; + +static const u8 dummy_ipv6_ah_pkt[] = { + 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x86, 0xDD, + + 0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_OFOS 14 */ + 0x00, 0x0c, 0x33, 0x00, /* Next header AH */ + 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_AH 54 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, /* 2 bytes for 4 bytes alignment */ +}; + +static const struct ice_dummy_pkt_offsets dummy_ipv4_nat_packet_offsets[] = { + { ICE_MAC_OFOS, 0 }, + { ICE_IPV4_OFOS, 14 }, + { ICE_UDP_ILOS, 34 }, + { ICE_NAT_T, 42 }, + { ICE_PROTOCOL_LAST, 0 }, +}; + +static const u8 dummy_ipv4_nat_pkt[] = { + 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x08, 0x00, + + 0x45, 0x00, 0x00, 0x24, /* ICE_IPV4_IL 14 */ + 0x00, 0x00, 0x40, 0x00, + 0x40, 0x11, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x11, 0x94, /* ICE_NAT_T 34 */ + 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, /* 2 bytes for 4 bytes alignment */ +}; + +static const struct ice_dummy_pkt_offsets dummy_ipv6_nat_packet_offsets[] = { + { ICE_MAC_OFOS, 0 }, + { ICE_IPV6_OFOS, 14 }, + { ICE_UDP_ILOS, 54 }, + { ICE_NAT_T, 62 }, + { ICE_PROTOCOL_LAST, 0 }, +}; + +static const u8 dummy_ipv6_nat_pkt[] = { + 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x86, 0xDD, + + 0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_OFOS 14 */ + 0x00, 0x10, 0x11, 0x00, /* Next header NAT_T */ + 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, 0x11, 0x94, /* ICE_NAT_T 54 */ + 0x00, 0x00, 0x00, 0x00, + + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, /* 2 bytes for 4 bytes alignment */ + +}; + /* this is a recipe to profile association bitmap */ static ice_declare_bitmap(recipe_to_profile[ICE_MAX_NUM_RECIPES], ICE_MAX_NUM_PROFILES); @@ -4947,6 +5117,11 @@ static const struct ice_prot_ext_tbl_entry ice_prot_ext[ICE_PROTOCOL_LAST] = { { ICE_NVGRE, { 0, 2, 4, 6 } }, { ICE_GTP, { 8, 10, 12, 14, 16, 18, 20 } }, { ICE_PPPOE, { 0, 2, 4, 6 } }, + { ICE_PFCP, { 8, 10, 12, 14, 16, 18, 20, 22 } }, + { ICE_L2TPV3, { 0, 2, 4, 6, 8, 10 } }, + { ICE_ESP, { 0, 2, 4, 6 } }, + { ICE_AH, { 0, 2, 4, 6, 8, 10 } }, + { ICE_NAT_T, { 8, 10, 12, 14 } }, }; /* The following table describes preferred grouping of recipes. @@ -4974,6 +5149,11 @@ static const struct ice_protocol_entry ice_prot_id_tbl[ICE_PROTOCOL_LAST] = { { ICE_NVGRE, ICE_GRE_OF_HW }, { ICE_GTP, ICE_UDP_OF_HW }, { ICE_PPPOE, ICE_PPPOE_HW }, + { ICE_PFCP, ICE_UDP_ILOS_HW }, + { ICE_L2TPV3, ICE_L2TPV3_HW }, + { ICE_ESP, ICE_ESP_HW }, + { ICE_AH, ICE_AH_HW }, + { ICE_NAT_T, ICE_UDP_ILOS_HW }, }; /** @@ -5762,6 +5942,7 @@ ice_get_compat_fv_bitmap(struct ice_hw *hw, struct ice_adv_rule_info *rinfo, ice_set_bit(ICE_PROFID_MAC_IPV6_L2TPV3, bm); return; case ICE_SW_TUN_PROFID_IPV6_NAT_T: + case ICE_SW_TUN_IPV6_NAT_T: ice_set_bit(ICE_PROFID_IPV6_NAT_T, bm); return; case ICE_SW_TUN_PROFID_IPV4_PFCP_NODE: @@ -5776,6 +5957,9 @@ ice_get_compat_fv_bitmap(struct ice_hw *hw, struct ice_adv_rule_info *rinfo, case ICE_SW_TUN_PROFID_IPV6_PFCP_SESSION: ice_set_bit(ICE_PROFID_IPV6_PFCP_SESSION, bm); return; + case ICE_SW_TUN_IPV4_NAT_T: + ice_set_bit(ICE_PROFID_IPV4_NAT_T, bm); + return; case ICE_SW_TUN_AND_NON_TUN: default: prof_type = ICE_PROF_ALL; @@ -6071,6 +6255,48 @@ ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt, ipv6 = true; } + if (tun_type == ICE_SW_TUN_IPV4_ESP) { + *pkt = dummy_ipv4_esp_pkt; + *pkt_len = sizeof(dummy_ipv4_esp_pkt); + *offsets = dummy_ipv4_esp_packet_offsets; + return; + } + + if (tun_type == ICE_SW_TUN_IPV6_ESP) { + *pkt = dummy_ipv6_esp_pkt; + *pkt_len = sizeof(dummy_ipv6_esp_pkt); + *offsets = dummy_ipv6_esp_packet_offsets; + return; + } + + if (tun_type == ICE_SW_TUN_IPV4_AH) { + *pkt = dummy_ipv4_ah_pkt; + *pkt_len = sizeof(dummy_ipv4_ah_pkt); + *offsets = dummy_ipv4_ah_packet_offsets; + return; + } + + if (tun_type == ICE_SW_TUN_IPV6_AH) { + *pkt = dummy_ipv6_ah_pkt; + *pkt_len = sizeof(dummy_ipv6_ah_pkt); + *offsets = dummy_ipv6_ah_packet_offsets; + return; + } + + if (tun_type == ICE_SW_TUN_IPV4_NAT_T) { + *pkt = dummy_ipv4_nat_pkt; + *pkt_len = sizeof(dummy_ipv4_nat_pkt); + *offsets = dummy_ipv4_nat_packet_offsets; + return; + } + + if (tun_type == ICE_SW_TUN_IPV6_NAT_T) { + *pkt = dummy_ipv6_nat_pkt; + *pkt_len = sizeof(dummy_ipv6_nat_pkt); + *offsets = dummy_ipv6_nat_packet_offsets; + return; + } + if (tun_type == ICE_SW_TUN_GTP) { *pkt = dummy_udp_gtp_packet; *pkt_len = sizeof(dummy_udp_gtp_packet); @@ -6260,6 +6486,15 @@ ice_fill_adv_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt, case ICE_PPPOE: len = sizeof(struct ice_pppoe_hdr); break; + case ICE_ESP: + len = sizeof(struct ice_esp_hdr); + break; + case ICE_NAT_T: + len = sizeof(struct ice_nat_t_hdr); + break; + case ICE_AH: + len = sizeof(struct ice_ah_hdr); + break; default: return ICE_ERR_PARAM; } diff --git a/drivers/net/ice/base/ice_switch.h b/drivers/net/ice/base/ice_switch.h index f7ae5c741..765ed0945 100644 --- a/drivers/net/ice/base/ice_switch.h +++ b/drivers/net/ice/base/ice_switch.h @@ -18,6 +18,7 @@ /* Switch Profile IDs for Profile related switch rules */ #define ICE_PROFID_IPV6_ESP 72 #define ICE_PROFID_IPV6_AH 74 +#define ICE_PROFID_IPV4_NAT_T 75 #define ICE_PROFID_IPV6_NAT_T 76 #define ICE_PROFID_MAC_IPV6_L2TPV3 78 #define ICE_PROFID_IPV4_PFCP_NODE 79 -- 2.19.1