The branch main has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=e7ffea395ee8add21b2cce0806285131e12cc454
commit e7ffea395ee8add21b2cce0806285131e12cc454 Author: Aleksandr Loktionov <[email protected]> AuthorDate: 2025-02-06 16:08:40 +0000 Commit: Kevin Bowling <[email protected]> CommitDate: 2026-08-11 20:59:31 +0000 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: [email protected] Signed-off-by: Aleksandr Loktionov <[email protected]> Signed-off-by: Anatoly Burakov <[email protected]> Acked-by: Bruce Richardson <[email protected]> Obtained from: DPDK (1749e662f6) MFC after: 2 weeks --- sys/dev/e1000/e1000_mac.c | 4 ++-- sys/dev/e1000/e1000_vf.c | 4 ++-- 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)) |
