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 2C9A2A04B5; Mon, 7 Sep 2020 13:29:48 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 807A11C236; Mon, 7 Sep 2020 13:25:16 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id AE0EB1C225 for ; Mon, 7 Sep 2020 13:25:14 +0200 (CEST) IronPort-SDR: bDZoh6JpZi2AN8QV9LhuZ6fKTvGiKfqnWKaiXfDKZUYawdRltyowMZgwnOcAqVGx7ERnLb8W3F W+Tiz/7ml2ag== X-IronPort-AV: E=McAfee;i="6000,8403,9736"; a="157252703" X-IronPort-AV: E=Sophos;i="5.76,401,1592895600"; d="scan'208";a="157252703" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2020 04:25:14 -0700 IronPort-SDR: zWgTkRuKSo0qzPjt/wCTjyJnmtSjetqgG/xn7a6lh9GXrMBJzPx7ufieU8kRJlIStB7LOoyDGc Z1L48wrINwxA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,401,1592895600"; d="scan'208";a="328058914" Received: from dpdk51.sh.intel.com ([10.67.111.82]) by fmsmga004.fm.intel.com with ESMTP; 07 Sep 2020 04:25:13 -0700 From: Qi Zhang To: qiming.yang@intel.com Cc: dev@dpdk.org, Qi Zhang , Tony Nguyen Date: Mon, 7 Sep 2020 19:28:16 +0800 Message-Id: <20200907112826.48493-31-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20200907112826.48493-1-qi.z.zhang@intel.com> References: <20200907112826.48493-1-qi.z.zhang@intel.com> Subject: [dpdk-dev] [PATCH 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 --- 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; } -- 2.13.6