mirror of
https://github.com/torvalds/linux
synced 2024-10-06 19:34:19 +00:00
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: 9d5c824399
("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>
This commit is contained in:
parent
5ad3bd8444
commit
60d758659f
|
@ -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)
|
static u32 igb_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
|
||||||
{
|
{
|
||||||
u32 hash_value, hash_mask;
|
u32 hash_value, hash_mask;
|
||||||
u8 bit_shift = 0;
|
u8 bit_shift = 1;
|
||||||
|
|
||||||
/* Register count multiplied by bits per register */
|
/* Register count multiplied by bits per register */
|
||||||
hash_mask = (hw->mac.mta_reg_count * 32) - 1;
|
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
|
/* For a mc_filter_type of 0, bit_shift is the number of left-shifts
|
||||||
* where 0xFF would still fall within the hash mask.
|
* 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++;
|
bit_shift++;
|
||||||
|
|
||||||
/* The portion of the address that is used for the hash table
|
/* The portion of the address that is used for the hash table
|
||||||
|
|
Loading…
Reference in a new issue