From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 22A5BA0547; Fri, 10 Sep 2021 10:27:20 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4BD5141125; Fri, 10 Sep 2021 10:27:05 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id B730A410E8 for ; Fri, 10 Sep 2021 10:27:01 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10102"; a="221060986" X-IronPort-AV: E=Sophos;i="5.85,282,1624345200"; d="scan'208";a="221060986" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Sep 2021 01:26:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,282,1624345200"; d="scan'208";a="540346388" Received: from wuwenjun.sh.intel.com ([10.67.110.178]) by FMSMGA003.fm.intel.com with ESMTP; 10 Sep 2021 01:26:57 -0700 From: Wenjun Wu To: dev@dpdk.org, qi.z.zhang@intel.com Cc: Wenjun Wu Date: Fri, 10 Sep 2021 16:08:18 +0800 Message-Id: <20210910080821.18718-5-wenjun1.wu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210910080821.18718-1-wenjun1.wu@intel.com> References: <20210910080821.18718-1-wenjun1.wu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 20.11 4/7] net/ice: fix error set of queue number X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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 is not for LTS upstream, just for users to cherry-pick. The queue number actually applied should be the maximum integer power of 2 less than or equal to min(vsi->nb_qps, ICE_MAX_Q_PER_TC), so we need to get the most significant 1 bit. However the return value of function rte_bsf32 is the least significant 1 bit. This patch replaces the function rte_bsf32 with the function rte_fls_u32 and adds necessary boundary check. Signed-off-by: Wenjun Wu --- drivers/net/ice/ice_ethdev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index 5a1e775718..ce98477427 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -750,7 +750,7 @@ ice_vsi_config_tc_queue_mapping(struct ice_vsi *vsi, struct ice_aqc_vsi_props *info, uint8_t enabled_tcmap) { - uint16_t bsf, qp_idx; + uint16_t fls, qp_idx; /* default tc 0 now. Multi-TC supporting need to be done later. * Configure TC and queue mapping parameters, for enabled TC, @@ -762,15 +762,15 @@ ice_vsi_config_tc_queue_mapping(struct ice_vsi *vsi, } vsi->nb_qps = RTE_MIN(vsi->nb_qps, ICE_MAX_Q_PER_TC); - bsf = rte_bsf32(vsi->nb_qps); + fls = (vsi->nb_qps == 0) ? 0 : rte_fls_u32(vsi->nb_qps) - 1; /* Adjust the queue number to actual queues that can be applied */ - vsi->nb_qps = 0x1 << bsf; + vsi->nb_qps = (vsi->nb_qps == 0) ? 0 : 0x1 << fls; qp_idx = 0; /* Set tc and queue mapping with VSI */ info->tc_mapping[0] = rte_cpu_to_le_16((qp_idx << ICE_AQ_VSI_TC_Q_OFFSET_S) | - (bsf << ICE_AQ_VSI_TC_Q_NUM_S)); + (fls << ICE_AQ_VSI_TC_Q_NUM_S)); /* Associate queue number with VSI */ info->mapping_flags |= rte_cpu_to_le_16(ICE_AQ_VSI_Q_MAP_CONTIG); -- 2.25.1