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 4FF13461AD; Thu, 6 Feb 2025 17:10:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 89A7E410E6; Thu, 6 Feb 2025 17:09:19 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by mails.dpdk.org (Postfix) with ESMTP id E1C1140E41 for ; Thu, 6 Feb 2025 17:09:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1738858157; x=1770394157; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=NrkprsQHEdVfbV0axmDkPA4fiUYReRoVnCmO3vdLZh0=; b=DqK7GWJ2sxeAwx+Ud1vi6CoU5saXbONJN7iqGG39h0VVekV9qtMw5bff FWGjPlABfKlQuUxu6AI+NYfTLvXjE3Vzq9O/UQ3TBiqtm886wMnZozSGy FEBR+u9kcD4A9rPZy4r/tu8TmUhDAVhJ/ZLNkEGtjrJX1ZCbtPdols2oZ anSk5sylCwXeqT1uEyhSH/yOx+mwE/E0gyNhpAoKilAAYXTru2M6z1EcP Im/k+iMjv3gpoPWn8iztQmObE/AkUsR0KI2nmM5S+0GFxgegXrDYadxbJ y41WxWu2QdJETN+BDxNasq0ogMJqoWeA4tW58bauEMlZEOY6vvBLgRVYL A==; X-CSE-ConnectionGUID: fZLbokRGSTGsI98us7/JLA== X-CSE-MsgGUID: MBz6BufNRSqoG7LffeB8nA== X-IronPort-AV: E=McAfee;i="6700,10204,11336"; a="50860733" X-IronPort-AV: E=Sophos;i="6.13,264,1732608000"; d="scan'208";a="50860733" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2025 08:09:16 -0800 X-CSE-ConnectionGUID: W0ondnBSQlWvZS2s8qqHow== X-CSE-MsgGUID: NTvdEjtuTUSl+XkOSBDIbw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,264,1732608000"; d="scan'208";a="111166751" Received: from silpixa00401119.ir.intel.com ([10.55.129.167]) by fmviesa007.fm.intel.com with ESMTP; 06 Feb 2025 08:09:15 -0800 From: Anatoly Burakov To: dev@dpdk.org, Alvin Zhang , Ferruh Yigit Subject: [PATCH v1 11/24] net/igc/base: fix MAC addr hash bit shift Date: Thu, 6 Feb 2025 16:08:34 +0000 Message-ID: X-Mailer: git-send-email 2.43.5 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From: Aleksandr Loktionov In e1000_hash_mc_addr_generic() the expression: "mc_addr[4] >> 8 - bit_shift", right shifting "mc_addr[4]" shift by more than 7 bits always yields zero, so hash becomes not so different. Add initialization with bit_shift = 1, and add a loop condition to ensure bit_shift will be always in [1..8] range. Fixes: 8cb7c57d9b3c ("net/igc: support device initialization") Cc: stable@dpdk.org Signed-off-by: Aleksandr Loktionov Signed-off-by: Anatoly Burakov --- drivers/net/intel/igc/base/igc_mac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/intel/igc/base/igc_mac.c b/drivers/net/intel/igc/base/igc_mac.c index 3cd6506e5e..c69f8ac73b 100644 --- a/drivers/net/intel/igc/base/igc_mac.c +++ b/drivers/net/intel/igc/base/igc_mac.c @@ -486,7 +486,7 @@ static int igc_rar_set_generic(struct igc_hw *hw, u8 *addr, u32 index) u32 igc_hash_mc_addr_generic(struct igc_hw *hw, u8 *mc_addr) { u32 hash_value, hash_mask; - u8 bit_shift = 0; + u8 bit_shift = 1; DEBUGFUNC("igc_hash_mc_addr_generic"); @@ -496,7 +496,7 @@ u32 igc_hash_mc_addr_generic(struct igc_hw *hw, u8 *mc_addr) /* For a mc_filter_type of 0, bit_shift is the number of left-shifts * where 0xFF would still fall within the hash mask. */ - while (hash_mask >> bit_shift != 0xFF) + while (hash_mask >> bit_shift != 0xFF && bit_shift < 4) bit_shift++; /* The portion of the address that is used for the hash table -- 2.43.5