Skip to contentSkip to conversation

xsk: Fix offset calculation in unaligned mode

PATCH Applied e.kubanski 3 participants 3 messages Apr 16, 2025 – Apr 25, 2025 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20250416112956eucas1p1977ffda6af7fa81c3e46cadc93c30de3@eucas1p1.samsung.com

e.kubanski

author
#1 lore raw

PATCH v2 1/1 xsk: Fix offset calculation in unaligned mode

Bring back previous offset calculation behaviour
in AF_XDP unaligned umem mode.

In unaligned mode, upper 16 bits should contain
data offset, lower 48 bits should contain
only specific chunk location without offset.

Remove pool->headroom duplication into 48bit address.

Fixes bea14124bacb ("xsk: Get rid of xdp_buff_xsk::orig_addr")
---
 include/net/xsk_buff_pool.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/net/xsk_buff_pool.h +1 -1
index 7f0a75d6563d..b3699a848844 100644
@@ -232,8 +232,8 @@ static inline u64 xp_get_handle(struct xdp_buff_xsk *xskb,
 		return orig_addr;
 
 	offset = xskb->xdp.data - xskb->xdp.data_hard_start;
-	orig_addr -= offset;
 	offset += pool->headroom;
+	orig_addr -= offset;
 	return orig_addr + (offset << XSK_UNALIGNED_BUF_OFFSET_SHIFT);
 }
 
Signature · 1 line
2.34.1
Acked-by on v2 1/1
#2 lore raw
Quoted 9 lines · e.kubanski

Bring back previous offset calculation behaviour
in AF_XDP unaligned umem mode.

In unaligned mode, upper 16 bits should contain
data offset, lower 48 bits should contain
only specific chunk location without offset.

Remove pool->headroom duplication into 48bit address.

Thanks Eryk.

Quoted 24 lines
Fixes bea14124bacb ("xsk: Get rid of xdp_buff_xsk::orig_addr")
---
 include/net/xsk_buff_pool.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/net/xsk_buff_pool.h +1 -2
index 7f0a75d6563d..b3699a848844 100644
@@ -232,8 +232,8 @@ static inline u64 xp_get_handle(struct xdp_buff_xsk *xskb,
                return orig_addr;
 
        offset = xskb->xdp.data - xskb->xdp.data_hard_start;
-       orig_addr -= offset;
        offset += pool->headroom;
+       orig_addr -= offset;
        return orig_addr + (offset << XSK_UNALIGNED_BUF_OFFSET_SHIFT);
 }
 
--

2.34.1

#3 lore raw
In reply to e.kubanski
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Wed, 16 Apr 2025 13:29:25 +0200 you wrote:

Bring back previous offset calculation behaviour in AF_XDP unaligned umem mode.

In unaligned mode, upper 16 bits should contain data offset, lower 48 bits should contain only specific chunk location without offset.

[...]

Here is the summary with links:
- [v2,bpf] xsk: Fix offset calculation in unaligned mode

    https://git.kernel.org/netdev/net/c/bf20af079099

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html