From patchwork Fri Sep 11 13:19:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zhang X-Patchwork-Id: 77417 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4CBA3A04B7; Fri, 11 Sep 2020 15:22:10 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A538D1C22A; Fri, 11 Sep 2020 15:16:58 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id B9C2B1C1EE for ; Fri, 11 Sep 2020 15:16:44 +0200 (CEST) IronPort-SDR: /2mo5CrbqFP05emsM8Zjo4pVCUwH3w7t+Paync+cRzF6wB2FI3JsI0t0aMbRkUC82B4i3bpAnf 5bbmevwu5rkg== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="146482375" X-IronPort-AV: E=Sophos;i="5.76,415,1592895600"; d="scan'208";a="146482375" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 06:16:44 -0700 IronPort-SDR: 8W8tJAiMzR8TaLNEM4vTYuywyVADfK/ld0bUS5PUk3qAL5flrGX7D9ngXFb+y6/JfE6Kuf0Lj9 IhWdc41vihaQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,415,1592895600"; d="scan'208";a="342296721" Received: from dpdk51.sh.intel.com ([10.67.111.82]) by FMSMGA003.fm.intel.com with ESMTP; 11 Sep 2020 06:16:43 -0700 From: Qi Zhang To: ferruh.yigit@intel.com Cc: dev@dpdk.org, Qi Zhang , Tony Nguyen Date: Fri, 11 Sep 2020 21:19:44 +0800 Message-Id: <20200911131954.15999-31-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20200911131954.15999-1-qi.z.zhang@intel.com> References: <20200907112826.48493-1-qi.z.zhang@intel.com> <20200911131954.15999-1-qi.z.zhang@intel.com> Subject: [dpdk-dev] [PATCH v2 30/40] net/ice/base: misc minor ACL changes 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 is a collection of minor ACL style changes including: - When there is nothing to unroll, return a value directly. - Return ICE_SUCCESS(0) in cases where an error was previously checked so ICE_SUCCESS is the only possible return. - Remove unnecessary parentheses and newlines - Move unroll of allocation to end of function and use goto on errors to free. - Fix function header comment style - Remove 'else' from an 'if else' condition where both conditions return a value to reduce indentation. Signed-off-by: Tony Nguyen Signed-off-by: Qi Zhang Acked-by: Qiming Yang --- drivers/net/ice/base/ice_acl_ctrl.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/net/ice/base/ice_acl_ctrl.c b/drivers/net/ice/base/ice_acl_ctrl.c index 02a1dd34f..bd09e9d77 100644 --- a/drivers/net/ice/base/ice_acl_ctrl.c +++ b/drivers/net/ice/base/ice_acl_ctrl.c @@ -149,10 +149,8 @@ static enum ice_status ice_acl_init_tbl(struct ice_hw *hw) u16 idx; tbl = hw->acl_tbl; - if (!tbl) { - status = ICE_ERR_CFG; - return status; - } + if (!tbl) + return ICE_ERR_CFG; ice_memset(&buf, 0, sizeof(buf), ICE_NONDMA_MEM); ice_memset(&act_buf, 0, sizeof(act_buf), ICE_NONDMA_MEM); @@ -526,7 +524,7 @@ ice_acl_alloc_partition(struct ice_hw *hw, struct ice_acl_scen *req) break; } - row = (dir > 0) ? (row + width) : (row - width); + row = dir > 0 ? row + width : row - width; if (row > hw->acl_tbl->last_tcam || row < hw->acl_tbl->first_tcam) { /* All rows have been checked. Increment 'off' that @@ -668,8 +666,7 @@ static void ice_acl_assign_act_mem_for_scen(struct ice_acl_tbl *tbl, struct ice_acl_scen *scen, struct ice_aqc_acl_scen *scen_buf, - u8 current_tcam_idx, - u8 target_tcam_idx) + u8 current_tcam_idx, u8 target_tcam_idx) { u8 i; @@ -761,10 +758,8 @@ ice_acl_create_scen(struct ice_hw *hw, u16 match_width, u16 num_entries, scen->num_entry = num_entries; status = ice_acl_alloc_partition(hw, scen); - if (status) { - ice_free(hw, scen); - return status; - } + if (status) + goto out; ice_memset(&scen_buf, 0, sizeof(scen_buf), ICE_NONDMA_MEM); @@ -829,8 +824,7 @@ ice_acl_create_scen(struct ice_hw *hw, u16 match_width, u16 num_entries, if (status) { ice_debug(hw, ICE_DBG_ACL, "AQ allocation of ACL scenario failed. status: %d\n", status); - ice_free(hw, scen); - return status; + goto out; } scen->id = *scen_id; @@ -838,6 +832,10 @@ ice_acl_create_scen(struct ice_hw *hw, u16 match_width, u16 num_entries, ice_acl_init_entry(scen); LIST_ADD(&scen->list_entry, &hw->acl_tbl->scens); +out: + if (status) + ice_free(hw, scen); + return status; }