From patchwork Fri Sep 11 13:19:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zhang X-Patchwork-Id: 77393 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 5849BA04B7; Fri, 11 Sep 2020 15:17:08 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8F0BE1C124; Fri, 11 Sep 2020 15:16:13 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id AE7161C116 for ; Fri, 11 Sep 2020 15:16:09 +0200 (CEST) IronPort-SDR: 4C42aV6/btQHuwyia9uNBKe3h55Uc8sQGcsS8xNgQIxdlwb8SpV1U70KjJut3/z+ffFpcBwLi1 FjVulIYmADgQ== X-IronPort-AV: E=McAfee;i="6000,8403,9740"; a="146482140" X-IronPort-AV: E=Sophos;i="5.76,415,1592895600"; d="scan'208";a="146482140" 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:09 -0700 IronPort-SDR: W4joRkjKY6V/Ffn+/ugsuFQF4tJ4E+WLP/bZXVA/Zw7NkFnm5pAXoRDZFjTvBxRMcNXmNSa560 Z1DQXb6TTa2w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,415,1592895600"; d="scan'208";a="342296472" Received: from dpdk51.sh.intel.com ([10.67.111.82]) by FMSMGA003.fm.intel.com with ESMTP; 11 Sep 2020 06:16:06 -0700 From: Qi Zhang To: ferruh.yigit@intel.com Cc: dev@dpdk.org, Qi Zhang , Tony Nguyen Date: Fri, 11 Sep 2020 21:19:20 +0800 Message-Id: <20200911131954.15999-7-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 06/40] net/ice/base: clean the code wrapping 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" To make the wrapping a little cleaner, move the variables only applicable to ICE_FC_AUTO into that case. Also move caching of the value to only occur on success. Signed-off-by: Tony Nguyen Signed-off-by: Qi Zhang Acked-by: Qiming Yang --- drivers/net/ice/base/ice_common.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/drivers/net/ice/base/ice_common.c b/drivers/net/ice/base/ice_common.c index 4be363047..92b2df741 100644 --- a/drivers/net/ice/base/ice_common.c +++ b/drivers/net/ice/base/ice_common.c @@ -2754,36 +2754,39 @@ static enum ice_status ice_cfg_phy_fc(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg, enum ice_fc_mode req_mode) { - struct ice_aqc_get_phy_caps_data *pcaps = NULL; struct ice_phy_cache_mode_data cache_data; - enum ice_status status = ICE_SUCCESS; u8 pause_mask = 0x0; if (!pi || !cfg) return ICE_ERR_BAD_PTR; - pcaps = (struct ice_aqc_get_phy_caps_data *) - ice_malloc(pi->hw, sizeof(*pcaps)); - if (!pcaps) - return ICE_ERR_NO_MEMORY; - - /* Cache user FC request */ - cache_data.data.curr_user_fc_req = req_mode; - ice_cache_phy_user_req(pi, cache_data, ICE_FC_MODE); - switch (req_mode) { case ICE_FC_AUTO: + { + struct ice_aqc_get_phy_caps_data *pcaps; + enum ice_status status; + + pcaps = (struct ice_aqc_get_phy_caps_data *) + ice_malloc(pi->hw, sizeof(*pcaps)); + if (!pcaps) + return ICE_ERR_NO_MEMORY; + /* Query the value of FC that both the NIC and attached media * can do. */ status = ice_aq_get_phy_caps(pi, false, ICE_AQC_REPORT_TOPO_CAP, pcaps, NULL); - if (status) - goto out; + if (status) { + ice_free(pi->hw, pcaps); + return status; + } pause_mask |= pcaps->caps & ICE_AQC_PHY_EN_TX_LINK_PAUSE; pause_mask |= pcaps->caps & ICE_AQC_PHY_EN_RX_LINK_PAUSE; + + ice_free(pi->hw, pcaps); break; + } case ICE_FC_FULL: pause_mask |= ICE_AQC_PHY_EN_TX_LINK_PAUSE; pause_mask |= ICE_AQC_PHY_EN_RX_LINK_PAUSE; @@ -2805,9 +2808,11 @@ ice_cfg_phy_fc(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg, /* set the new capabilities */ cfg->caps |= pause_mask; -out: - ice_free(pi->hw, pcaps); - return status; + /* Cache user FC request */ + cache_data.data.curr_user_fc_req = req_mode; + ice_cache_phy_user_req(pi, cache_data, ICE_FC_MODE); + + return ICE_SUCCESS; } /**