Skip to content

Commit beb3e4b

Browse files
kevin-laatz-intelborkmann
authored andcommitted
mlx5e: modify driver for handling offsets
With the addition of the unaligned chunks option, we need to make sure we handle the offsets accordingly based on the mode we are currently running in. This patch modifies the driver to appropriately mask the address for each case. Signed-off-by: Kevin Laatz <[email protected]> Acked-by: Jonathan Lemon <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
1 parent d8c3061 commit beb3e4b

File tree

2 files changed

+8
-3
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/en

2 files changed

+8
-3
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ bool mlx5e_xdp_handle(struct mlx5e_rq *rq, struct mlx5e_dma_info *di,
122122
void *va, u16 *rx_headroom, u32 *len, bool xsk)
123123
{
124124
struct bpf_prog *prog = READ_ONCE(rq->xdp_prog);
125+
struct xdp_umem *umem = rq->umem;
125126
struct xdp_buff xdp;
126127
u32 act;
127128
int err;
@@ -138,8 +139,11 @@ bool mlx5e_xdp_handle(struct mlx5e_rq *rq, struct mlx5e_dma_info *di,
138139
xdp.rxq = &rq->xdp_rxq;
139140

140141
act = bpf_prog_run_xdp(prog, &xdp);
141-
if (xsk)
142-
xdp.handle += xdp.data - xdp.data_hard_start;
142+
if (xsk) {
143+
u64 off = xdp.data - xdp.data_hard_start;
144+
145+
xdp.handle = xsk_umem_adjust_offset(umem, xdp.handle, off);
146+
}
143147
switch (act) {
144148
case XDP_PASS:
145149
*rx_headroom = xdp.data - xdp.data_hard_start;

drivers/net/ethernet/mellanox/mlx5/core/en/xsk/rx.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ int mlx5e_xsk_page_alloc_umem(struct mlx5e_rq *rq,
2424
if (!xsk_umem_peek_addr_rq(umem, &handle))
2525
return -ENOMEM;
2626

27-
dma_info->xsk.handle = handle + rq->buff.umem_headroom;
27+
dma_info->xsk.handle = xsk_umem_adjust_offset(umem, handle,
28+
rq->buff.umem_headroom);
2829
dma_info->xsk.data = xdp_umem_get_data(umem, dma_info->xsk.handle);
2930

3031
/* No need to add headroom to the DMA address. In striding RQ case, we

0 commit comments

Comments
 (0)