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 8C572A00C5; Thu, 11 Jun 2020 10:40:39 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 619D91BEAF; Thu, 11 Jun 2020 10:39:49 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 506CE1BEA9 for ; Thu, 11 Jun 2020 10:39:47 +0200 (CEST) IronPort-SDR: muYlKPdnNGZxlj8vVkLCPHqaUU9LizWMhio52o1a/sdev+MTq4yMj0tPzp2mxgO0oNRsFux66B bCmENEfD6APA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2020 01:39:47 -0700 IronPort-SDR: /a++pe8GxeINbsP5puJhS38xf00NOTP5HUXKE4+wMMdaMv031JBI5/oWoksd0cRWUMci/5dy9z d3lt8LAE4cSA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,499,1583222400"; d="scan'208";a="419039190" Received: from dpdk51.sh.intel.com ([10.67.111.82]) by orsmga004.jf.intel.com with ESMTP; 11 Jun 2020 01:39:45 -0700 From: Qi Zhang To: qiming.yang@intel.com Cc: dev@dpdk.org, xiaolong.ye@intel.com, Qi Zhang , Wei Zhao , Paul M Stillwell Jr Date: Thu, 11 Jun 2020 16:43:27 +0800 Message-Id: <20200611084330.18301-8-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20200611084330.18301-1-qi.z.zhang@intel.com> References: <20200611084330.18301-1-qi.z.zhang@intel.com> Subject: [dpdk-dev] [PATCH 07/10] net/ice/base: get tunnel type for recipe 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" This patch add support to get tunnel type of recipe after get recipe from fw. This will fix the issue in function ice_find_recp() for tunnel type comparing. Signed-off-by: Wei Zhao Signed-off-by: Paul M Stillwell Jr Signed-off-by: Qi Zhang --- drivers/net/ice/base/ice_switch.c | 177 +++++++++++++++++++++++++++++++++++++- drivers/net/ice/base/ice_switch.h | 2 + 2 files changed, 177 insertions(+), 2 deletions(-) diff --git a/drivers/net/ice/base/ice_switch.c b/drivers/net/ice/base/ice_switch.c index 1b1693dbb..06d8f9c55 100644 --- a/drivers/net/ice/base/ice_switch.c +++ b/drivers/net/ice/base/ice_switch.c @@ -1024,6 +1024,179 @@ static void ice_collect_result_idx(struct ice_aqc_recipe_data_elem *buf, } /** + * ice_get_tun_type_for_recipe - get tunnel type for the recipe + * @rid: recipe ID that we are populating + */ +static enum ice_sw_tunnel_type ice_get_tun_type_for_recipe(u8 rid) +{ + u8 vxlan_profile[12] = {10, 11, 12, 16, 17, 18, 22, 23, 24, 25, 26, 27}; + 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}; + enum ice_sw_tunnel_type tun_type; + u16 i, j, profile_num = 0; + bool non_tun_valid = false; + bool pppoe_valid = false; + bool vxlan_valid = false; + bool gre_valid = false; + bool gtp_valid = false; + bool flag_valid = false; + + for (j = 0; j < ICE_MAX_NUM_PROFILES; j++) { + if (!ice_is_bit_set(recipe_to_profile[rid], j)) + continue; + else + profile_num++; + + for (i = 0; i < 12; i++) { + if (gre_profile[i] == j) + gre_valid = true; + } + + for (i = 0; i < 12; i++) { + if (vxlan_profile[i] == j) + vxlan_valid = true; + } + + for (i = 0; i < 7; i++) { + if (pppoe_profile[i] == j) + pppoe_valid = true; + } + + for (i = 0; i < 6; i++) { + if (non_tun_profile[i] == j) + non_tun_valid = true; + } + + if (j >= ICE_PROFID_IPV4_GTPC_TEID && + j <= ICE_PROFID_IPV6_GTPU_IPV6_OTHER) + gtp_valid = true; + + if (j >= ICE_PROFID_IPV4_ESP && + j <= ICE_PROFID_IPV6_PFCP_SESSION) + flag_valid = true; + } + + if (!non_tun_valid && vxlan_valid) + tun_type = ICE_SW_TUN_VXLAN; + else if (!non_tun_valid && gre_valid) + tun_type = ICE_SW_TUN_NVGRE; + else if (!non_tun_valid && pppoe_valid) + tun_type = ICE_SW_TUN_PPPOE; + else if (!non_tun_valid && gtp_valid) + tun_type = ICE_SW_TUN_GTP; + else if ((non_tun_valid && vxlan_valid) || + (non_tun_valid && gre_valid) || + (non_tun_valid && gtp_valid) || + (non_tun_valid && pppoe_valid)) + tun_type = ICE_SW_TUN_AND_NON_TUN; + else if ((non_tun_valid && !vxlan_valid) || + (non_tun_valid && !gre_valid) || + (non_tun_valid && !gtp_valid) || + (non_tun_valid && !pppoe_valid)) + tun_type = ICE_NON_TUN; + + if (profile_num > 1 && tun_type == ICE_SW_TUN_PPPOE) { + i = ice_is_bit_set(recipe_to_profile[rid], + ICE_PROFID_PPPOE_IPV4_OTHER); + j = ice_is_bit_set(recipe_to_profile[rid], + ICE_PROFID_PPPOE_IPV6_OTHER); + if (i && !j) + tun_type = ICE_SW_TUN_PPPOE_IPV4; + else if (!i && j) + tun_type = ICE_SW_TUN_PPPOE_IPV6; + } + + if (profile_num == 1 && (flag_valid || non_tun_valid)) { + for (j = 0; j < ICE_MAX_NUM_PROFILES; j++) { + if (ice_is_bit_set(recipe_to_profile[rid], j)) { + switch (j) { + case ICE_PROFID_IPV4_TCP: + tun_type = ICE_SW_IPV4_TCP; + break; + case ICE_PROFID_IPV4_UDP: + tun_type = ICE_SW_IPV4_UDP; + break; + case ICE_PROFID_IPV6_TCP: + tun_type = ICE_SW_IPV6_TCP; + break; + case ICE_PROFID_IPV6_UDP: + tun_type = ICE_SW_IPV6_UDP; + break; + case ICE_PROFID_PPPOE_PAY: + tun_type = ICE_SW_TUN_PPPOE_PAY; + break; + case ICE_PROFID_PPPOE_IPV4_TCP: + tun_type = ICE_SW_TUN_PPPOE_IPV4_TCP; + break; + case ICE_PROFID_PPPOE_IPV4_UDP: + tun_type = ICE_SW_TUN_PPPOE_IPV4_UDP; + break; + case ICE_PROFID_PPPOE_IPV4_OTHER: + tun_type = ICE_SW_TUN_PPPOE_IPV4; + break; + case ICE_PROFID_PPPOE_IPV6_TCP: + tun_type = ICE_SW_TUN_PPPOE_IPV6_TCP; + break; + case ICE_PROFID_PPPOE_IPV6_UDP: + tun_type = ICE_SW_TUN_PPPOE_IPV4_UDP; + break; + case ICE_PROFID_PPPOE_IPV6_OTHER: + tun_type = ICE_SW_TUN_PPPOE_IPV6; + break; + case ICE_PROFID_IPV4_ESP: + tun_type = ICE_SW_TUN_IPV4_ESP; + break; + case ICE_PROFID_IPV6_ESP: + tun_type = ICE_SW_TUN_IPV6_ESP; + break; + case ICE_PROFID_IPV4_AH: + tun_type = ICE_SW_TUN_IPV4_AH; + break; + case ICE_PROFID_IPV6_AH: + tun_type = ICE_SW_TUN_IPV6_AH; + break; + case ICE_PROFID_IPV4_NAT_T: + tun_type = ICE_SW_TUN_IPV4_NAT_T; + break; + case ICE_PROFID_IPV6_NAT_T: + tun_type = ICE_SW_TUN_IPV6_NAT_T; + break; + case ICE_PROFID_IPV4_PFCP_NODE: + tun_type = + ICE_SW_TUN_PROFID_IPV4_PFCP_NODE; + break; + case ICE_PROFID_IPV6_PFCP_NODE: + tun_type = + ICE_SW_TUN_PROFID_IPV6_PFCP_NODE; + break; + case ICE_PROFID_IPV4_PFCP_SESSION: + tun_type = + ICE_SW_TUN_PROFID_IPV4_PFCP_SESSION; + break; + case ICE_PROFID_IPV6_PFCP_SESSION: + tun_type = + ICE_SW_TUN_PROFID_IPV6_PFCP_SESSION; + break; + case ICE_PROFID_MAC_IPV4_L2TPV3: + tun_type = ICE_SW_TUN_IPV4_L2TPV3; + break; + case ICE_PROFID_MAC_IPV6_L2TPV3: + tun_type = ICE_SW_TUN_IPV6_L2TPV3; + break; + default: + break; + } + + return tun_type; + } + } + } + + return tun_type; +} + +/** * ice_get_recp_frm_fw - update SW bookkeeping from FW recipe entries * @hw: pointer to hardware structure * @recps: struct that we need to populate @@ -1166,6 +1339,7 @@ ice_get_recp_frm_fw(struct ice_hw *hw, struct ice_sw_recipe *recps, u8 rid, lkup_exts->n_val_words = fv_word_idx; recps[rid].big_recp = (num_recps > 1); recps[rid].n_grp_count = (u8)num_recps; + recps[rid].tun_type = ice_get_tun_type_for_recipe(rid); recps[rid].root_buf = (struct ice_aqc_recipe_data_elem *) ice_memdup(hw, tmp, recps[rid].n_grp_count * sizeof(*recps[rid].root_buf), ICE_NONDMA_TO_NONDMA); @@ -5548,8 +5722,7 @@ static u16 ice_find_recp(struct ice_hw *hw, struct ice_prot_lkup_ext *lkup_exts, /* If for "i"th recipe the found was never set to false * then it means we found our match */ - if ((tun_type == recp[i].tun_type || - tun_type == ICE_SW_TUN_AND_NON_TUN) && found) + if (tun_type == recp[i].tun_type && found) return i; /* Return the recipe ID */ } } diff --git a/drivers/net/ice/base/ice_switch.h b/drivers/net/ice/base/ice_switch.h index 1ba85b16b..cc3d2702e 100644 --- a/drivers/net/ice/base/ice_switch.h +++ b/drivers/net/ice/base/ice_switch.h @@ -27,6 +27,8 @@ #define ICE_PROFID_PPPOE_IPV6_TCP 38 #define ICE_PROFID_PPPOE_IPV6_UDP 39 #define ICE_PROFID_PPPOE_IPV6_OTHER 40 +#define ICE_PROFID_IPV4_GTPC_TEID 41 +#define ICE_PROFID_IPV6_GTPU_IPV6_OTHER 70 #define ICE_PROFID_IPV4_ESP 71 #define ICE_PROFID_IPV6_ESP 72 #define ICE_PROFID_IPV4_AH 73 -- 2.13.6