Skip to content

Commit 60d7586

Browse files
aloktiondavem330
authored andcommitted
igb: fix bit_shift to be in [1..8] range
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: 9d5c824 ("igb: PCI-Express 82575 Gigabit Ethernet driver") Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com> Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 5ad3bd8 commit 60d7586

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/net/ethernet/intel/igb/e1000_mac.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,15 +426,15 @@ void igb_mta_set(struct e1000_hw *hw, u32 hash_value)
426426
static u32 igb_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
427427
{
428428
u32 hash_value, hash_mask;
429-
u8 bit_shift = 0;
429+
u8 bit_shift = 1;
430430

431431
/* Register count multiplied by bits per register */
432432
hash_mask = (hw->mac.mta_reg_count * 32) - 1;
433433

434434
/* For a mc_filter_type of 0, bit_shift is the number of left-shifts
435435
* where 0xFF would still fall within the hash mask.
436436
*/
437-
while (hash_mask >> bit_shift != 0xFF)
437+
while (hash_mask >> bit_shift != 0xFF && bit_shift < 4)
438438
bit_shift++;
439439

440440
/* The portion of the address that is used for the hash table

0 commit comments

Comments
 (0)