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 6D44BA2EDB for ; Mon, 30 Sep 2019 11:28:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0E5793237; Mon, 30 Sep 2019 11:28:18 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 0B0D52BF1; Mon, 30 Sep 2019 11:28:15 +0200 (CEST) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Sep 2019 02:28:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,565,1559545200"; d="scan'208";a="215649307" Received: from yexl-server.sh.intel.com (HELO localhost) ([10.67.117.17]) by fmsmga004.fm.intel.com with ESMTP; 30 Sep 2019 02:28:13 -0700 Date: Mon, 30 Sep 2019 17:25:45 +0800 From: Ye Xiaolong To: Ying Wang Cc: qi.z.zhang@intel.com, dev@dpdk.org, qiming.yang@intel.com, stable@dpdk.org Message-ID: <20190930092545.GD112560@intel.com> References: <20190927183258.44578-1-ying.a.wang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190927183258.44578-1-ying.a.wang@intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH] net/ice: cleanup RSS/FDIR profile when device init 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" On 09/28, Ying Wang wrote: >The patch cleanup RSS/FDIR profile resources when device init >to fix profile ID increase issue. Could you elaborate the profile ID increase issue in the commit log? > >Fixes: d7d150b93070 ("net/ice: enable RSS when device init") >Cc: stable@dpdk.org > >Signed-off-by: Ying Wang >--- >--- >This patch depends on the following patches in patchwork: >(1) http://patchwork.dpdk.org/project/dpdk/list/?series=6557 >(2) http://patches.dpdk.org/project/dpdk/list/?series=6579 >(3) http://patches.dpdk.org/project/dpdk/list/?series=6577 >--- > > drivers/net/ice/ice_ethdev.c | 115 +++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 115 insertions(+) > >diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c >index 3abdaffbc..04102728f 100644 >--- a/drivers/net/ice/ice_ethdev.c >+++ b/drivers/net/ice/ice_ethdev.c >@@ -13,6 +13,7 @@ > #include "base/ice_sched.h" > #include "base/ice_flow.h" > #include "base/ice_dcb.h" >+#include "base/ice_common.h" > #include "ice_ethdev.h" > #include "ice_rxtx.h" > #include "ice_generic_flow.h" >@@ -40,6 +41,7 @@ static const char * const ice_valid_args[] = { > #define ICE_OS_DEFAULT_PKG_NAME "ICE OS Default Package" > #define ICE_COMMS_PKG_NAME "ICE COMMS Package" > #define ICE_MAX_PKG_FILENAME_SIZE 256 >+#define ICE_MAX_RES_DESC_NUM 1024 > > int ice_logtype_init; > int ice_logtype_driver; >@@ -1851,6 +1853,113 @@ ice_vsi_config_sw_lldp(struct ice_vsi *vsi, bool on) > return ret; > } > >+static enum ice_status >+ice_aq_get_res_profs(struct ice_hw *hw, uint16_t num_entries, >+ struct ice_aqc_get_allocd_res_desc_resp *resp_buf, >+ uint16_t buf_size, uint16_t res_type, >+ bool res_shared, uint16_t *desc_id, >+ struct ice_sq_cd *cd, uint16_t *num_prof) May consider use struct to reduce the number of parameters. >+{ >+ struct ice_aq_desc aq_desc; >+ int ret; >+ >+ struct ice_aqc_get_allocd_res_desc *cmd = >+ &aq_desc.params.get_res_desc; >+ >+ if (!resp_buf) >+ return ICE_ERR_PARAM; >+ >+ if (buf_size != (num_entries * sizeof(*resp_buf))) >+ return ICE_ERR_PARAM; >+ >+ ice_fill_dflt_direct_cmd_desc(&aq_desc, >+ ice_aqc_opc_get_allocd_res_desc); >+ >+ cmd->ops.cmd.res = CPU_TO_LE16(((res_type << ICE_AQC_RES_TYPE_S) & >+ ICE_AQC_RES_TYPE_M) | (res_shared ? >+ ICE_AQC_RES_TYPE_FLAG_SHARED : 0)); >+ cmd->ops.cmd.first_desc = CPU_TO_LE16(*desc_id); >+ ret = ice_aq_send_cmd(hw, &aq_desc, resp_buf, buf_size, cd); >+ if (!ret) { >+ *desc_id = LE16_TO_CPU(cmd->ops.resp.next_desc); >+ *num_prof = LE16_TO_CPU(cmd->ops.resp.num_desc); >+ } >+ return ret; >+} >+ >+static enum ice_status >+ice_get_hw_res(struct ice_hw *hw, uint16_t type, uint16_t num, uint16_t *res, >+ uint16_t *prof_buf, uint16_t *num_prof) >+{ >+ struct ice_aqc_get_allocd_res_desc_resp *resp_buf; >+ int ret; >+ uint16_t buf_len; >+ >+ buf_len = sizeof(*resp_buf) + sizeof(resp_buf->elem) * (num - 1); why (num - 1) here? >+ resp_buf = (struct ice_aqc_get_allocd_res_desc_resp *) >+ ice_malloc(hw, buf_len); Cast is unnecessary for void * >+ if (!resp_buf) >+ return -ENOMEM; >+ >+ ret = ice_aq_get_res_profs(hw, num, resp_buf, buf_len, type, 1, >+ res, NULL, num_prof); >+ if (ret) >+ goto exit; >+ >+ ice_memcpy(prof_buf, resp_buf->elem, sizeof(resp_buf->elem) * >+ (*num_prof), ICE_NONDMA_TO_NONDMA); >+exit: >+ rte_free(resp_buf); >+ return ret; >+} >+ >+static int >+ice_clearup_resource(struct ice_hw *hw, uint16_t res_type) s/clearup/cleanup >+{ >+ int ret; >+ uint16_t prof_id; >+ uint16_t prof_buf[ICE_MAX_RES_DESC_NUM]; >+ uint16_t first_desc = 1; >+ uint16_t num_prof = 0; >+ >+ ret = ice_get_hw_res(hw, res_type, ICE_MAX_RES_DESC_NUM, >+ &first_desc, prof_buf, &num_prof); What is purpose of first_desc? Seems there is no reference of it afterwards. >+ if (ret) { >+ PMD_INIT_LOG(ERR, "Failed to get fxp resource"); >+ return ret; >+ } >+ >+ for (prof_id = 0; prof_id < num_prof; prof_id++) { >+ ret = ice_free_hw_res(hw, res_type, 1, &prof_buf[prof_id]); >+ if (ret) { >+ PMD_INIT_LOG(ERR, "Failed to free fxp resource"); >+ return ret; >+ } >+ } >+ >+ return 0; >+} >+ >+static int >+ice_reset_fxp_resource(struct ice_hw *hw) >+{ >+ int ret; >+ >+ ret = ice_clearup_resource(hw, ICE_AQC_RES_TYPE_FD_PROF_BLDR_PROFID); >+ if (ret) { >+ PMD_INIT_LOG(ERR, "Failed to clearup fdir resource"); >+ return ret; >+ } >+ >+ ret = ice_clearup_resource(hw, ICE_AQC_RES_TYPE_HASH_PROF_BLDR_PROFID); >+ if (ret) { >+ PMD_INIT_LOG(ERR, "Failed to clearup rss resource"); >+ return ret; >+ } >+ >+ return 0; >+} s/clearup/cleanup Thanks, Xiaolong >+ > static int > ice_dev_init(struct rte_eth_dev *dev) > { >@@ -1983,6 +2092,12 @@ ice_dev_init(struct rte_eth_dev *dev) > return ret; > } > >+ ret = ice_reset_fxp_resource(hw); >+ if (ret) { >+ PMD_INIT_LOG(ERR, "Failed to reset fxp resource"); >+ return ret; >+ } >+ > return 0; > > err_pf_setup: >-- >2.15.1 >