Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71BED107B8 for ; Tue, 16 May 2023 17:45:38 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5689E7DA9 for ; Tue, 16 May 2023 10:45:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684259134; x=1715795134; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=DiTtejVz2c/Df57SiQ8xymVe0wQXJgcfOYxsT5uPkJ4=; b=h43Kip7wFXuY9yhAaepK97lSIUGRhh89ae/R2s6m6yKmaETHR4thfmww dYvGsabUpLfk2NGhNXAIWDP1fCkJLuulj0xn+2EfYZLMlSrSSaKNu+oc9 695wwCUApYRyUqUMsxGStoxcvR5eDzpWUKnfbIqNu+Kel7IDqH7d6KoaV YGx0n56u+l4Q23xmoT8KSDuG+30JmbpcK6Wp+scSm7Gwpk/x6Mu9ybncA TgVH438KmPAuScjAgHa2nKJWTK63efwB8+vw+SeHxDg5pIgfQQGHOFit5 84gILdj1zxC0qI/QfWNkTA1NlPTynQykfn3hpvGzXjSO0XIUmUe3Xwy8u A==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="417199988" X-IronPort-AV: E=Sophos;i="5.99,278,1677571200"; d="scan'208";a="417199988" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2023 10:45:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="813539801" X-IronPort-AV: E=Sophos;i="5.99,278,1677571200"; d="scan'208";a="813539801" Received: from anguy11-upstream.jf.intel.com ([10.166.9.133]) by fmsmga002.fm.intel.com with ESMTP; 16 May 2023 10:45:33 -0700 From: Tony Nguyen To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, netdev@vger.kernel.org Cc: Aleksandr Loktionov , anthony.l.nguyen@intel.com, jgarzik@redhat.com, Pucha Himasekhar Reddy Subject: [PATCH net] igb: fix bit_shift to be in [1..8] range Date: Tue, 16 May 2023 10:41:46 -0700 Message-Id: <20230516174146.2707152-1-anthony.l.nguyen@intel.com> X-Mailer: git-send-email 2.38.1 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net From: Aleksandr Loktionov In igb_hash_mc_addr() 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: 9d5c824399de ("igb: PCI-Express 82575 Gigabit Ethernet driver") Signed-off-by: Aleksandr Loktionov Tested-by: Pucha Himasekhar Reddy (A Contingent worker at Intel) Signed-off-by: Tony Nguyen --- drivers/net/ethernet/intel/igb/e1000_mac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/igb/e1000_mac.c b/drivers/net/ethernet/intel/igb/e1000_mac.c index 205d577bdbba..caf91c6f52b4 100644 --- a/drivers/net/ethernet/intel/igb/e1000_mac.c +++ b/drivers/net/ethernet/intel/igb/e1000_mac.c @@ -426,7 +426,7 @@ void igb_mta_set(struct e1000_hw *hw, u32 hash_value) static u32 igb_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr) { u32 hash_value, hash_mask; - u8 bit_shift = 0; + u8 bit_shift = 1; /* Register count multiplied by bits per register */ hash_mask = (hw->mac.mta_reg_count * 32) - 1; @@ -434,7 +434,7 @@ static u32 igb_hash_mc_addr(struct e1000_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.38.1