* [PATCH net-next v2] pppoe: optimize hash with word access
@ 2026-04-29 2:38 Qingfang Deng
2026-05-02 2:20 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Qingfang Deng @ 2026-04-29 2:38 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Qingfang Deng, Guillaume Nault, Kees Cook,
Eric Woudstra, netdev, linux-kernel
Cc: linux-ppp
Currently, hash_item() processes the 6-byte Ethernet address and the
2-byte session ID byte-wise to compute a hash.
Optimize this by using 16-bit word operations: XOR three 16-bit words
from the Ethernet address and the 16-bit session ID, then fold the
result. This reduces the total number of loads and XORs. The Ethernet
addresses in a skb and struct pppoe_addr are both 2-byte aligned, so the
u16 pointer cast is safe.
Signed-off-by: Qingfang Deng <qingfang.deng@linux.dev>
---
v2: repost after net-next opens
v1: https://lore.kernel.org/netdev/20260413035212.56566-1-qingfang.deng@linux.dev
drivers/net/ppp/pppoe.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c
index bdd61c504a1c..ad5bb98c1579 100644
--- a/drivers/net/ppp/pppoe.c
+++ b/drivers/net/ppp/pppoe.c
@@ -136,15 +136,15 @@ static inline int cmp_addr(struct pppoe_addr *a, __be16 sid, char *addr)
#error 8 must be a multiple of PPPOE_HASH_BITS
#endif
-static int hash_item(__be16 sid, unsigned char *addr)
+static u8 hash_item(__be16 sid, const u8 addr[ETH_ALEN])
{
- unsigned char hash = 0;
+ const u16 *addr16 = (const u16 *)addr;
unsigned int i;
+ u16 hash16;
+ u8 hash;
- for (i = 0; i < ETH_ALEN; i++)
- hash ^= addr[i];
- for (i = 0; i < sizeof(sid_t) * 8; i += 8)
- hash ^= (__force __u32)sid >> i;
+ hash16 = addr16[0] ^ addr16[1] ^ addr16[2] ^ (__force u16)sid;
+ hash = (hash16 >> 8) ^ hash16;
for (i = 8; (i >>= 1) >= PPPOE_HASH_BITS;)
hash ^= hash >> i;
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net-next v2] pppoe: optimize hash with word access
2026-04-29 2:38 [PATCH net-next v2] pppoe: optimize hash with word access Qingfang Deng
@ 2026-05-02 2:20 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-05-02 2:20 UTC (permalink / raw)
To: Qingfang Deng
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, gnault, kees,
ericwouds, netdev, linux-kernel, linux-ppp
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 29 Apr 2026 10:38:46 +0800 you wrote:
> Currently, hash_item() processes the 6-byte Ethernet address and the
> 2-byte session ID byte-wise to compute a hash.
>
> Optimize this by using 16-bit word operations: XOR three 16-bit words
> from the Ethernet address and the 16-bit session ID, then fold the
> result. This reduces the total number of loads and XORs. The Ethernet
> addresses in a skb and struct pppoe_addr are both 2-byte aligned, so the
> u16 pointer cast is safe.
>
> [...]
Here is the summary with links:
- [net-next,v2] pppoe: optimize hash with word access
https://git.kernel.org/netdev/net-next/c/ff393252f99f
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-02 2:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-29 2:38 [PATCH net-next v2] pppoe: optimize hash with word access Qingfang Deng
2026-05-02 2:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox