aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksandr Loktionov <aleksandr.loktionov@intel.com>2025-02-06 16:08:40 +0000
committerKevin Bowling <kbowling@FreeBSD.org>2026-08-11 20:59:31 +0000
commite7ffea395ee8add21b2cce0806285131e12cc454 (patch)
treed71822e04c6620cd668a247e62e9bb419005522d
parent53e4711616041a668ab61f2ce86c9fa139ab67a9 (diff)
e1000: fix MAC address hash bit shift
DPDK commit message net/e1000/base: fix MAC address hash bit shift 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: af75078fece3 ("first public release") Cc: stable@dpdk.org Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com> Obtained from: DPDK (1749e662f6) MFC after: 2 weeks
-rw-r--r--sys/dev/e1000/e1000_mac.c4
-rw-r--r--sys/dev/e1000/e1000_vf.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/sys/dev/e1000/e1000_mac.c b/sys/dev/e1000/e1000_mac.c
index 23cc89f92c6e..a34e2c873a0e 100644
--- a/sys/dev/e1000/e1000_mac.c
+++ b/sys/dev/e1000/e1000_mac.c
@@ -523,7 +523,7 @@ int e1000_rar_set_generic(struct e1000_hw *hw, u8 *addr, u32 index)
u32 e1000_hash_mc_addr_generic(struct e1000_hw *hw, u8 *mc_addr)
{
u32 hash_value, hash_mask;
- u8 bit_shift = 0;
+ u8 bit_shift = 1;
DEBUGFUNC("e1000_hash_mc_addr_generic");
@@ -533,7 +533,7 @@ u32 e1000_hash_mc_addr_generic(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 (bit_shift < 4 && hash_mask >> bit_shift != 0xFF)
bit_shift++;
/* The portion of the address that is used for the hash table
diff --git a/sys/dev/e1000/e1000_vf.c b/sys/dev/e1000/e1000_vf.c
index 2394c240d18d..a2c19c980f34 100644
--- a/sys/dev/e1000/e1000_vf.c
+++ b/sys/dev/e1000/e1000_vf.c
@@ -359,7 +359,7 @@ static int e1000_rar_set_vf(struct e1000_hw *hw, u8 *addr,
static u32 e1000_hash_mc_addr_vf(struct e1000_hw *hw, u8 *mc_addr)
{
u32 hash_value, hash_mask;
- u8 bit_shift = 0;
+ u8 bit_shift = 1;
DEBUGFUNC("e1000_hash_mc_addr_generic");
@@ -370,7 +370,7 @@ static u32 e1000_hash_mc_addr_vf(struct e1000_hw *hw, u8 *mc_addr)
* The bit_shift is the number of left-shifts
* where 0xFF would still fall within the hash mask.
*/
- while (hash_mask >> bit_shift != 0xFF)
+ while (bit_shift < 4 && hash_mask >> bit_shift != 0xFF)
bit_shift++;
hash_value = hash_mask & (((mc_addr[4] >> (8 - bit_shift)) |