Skip to content

Commit 2f86c80

Browse files
kevin-laatz-intelborkmann
authored andcommitted
i40e: 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: Bruce Richardson <[email protected]> Signed-off-by: Kevin Laatz <[email protected]> Acked-by: Jonathan Lemon <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
1 parent c05cd36 commit 2f86c80

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

drivers/net/ethernet/intel/i40e/i40e_xsk.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ int i40e_xsk_umem_setup(struct i40e_vsi *vsi, struct xdp_umem *umem,
190190
**/
191191
static int i40e_run_xdp_zc(struct i40e_ring *rx_ring, struct xdp_buff *xdp)
192192
{
193+
struct xdp_umem *umem = rx_ring->xsk_umem;
193194
int err, result = I40E_XDP_PASS;
195+
u64 offset = umem->headroom;
194196
struct i40e_ring *xdp_ring;
195197
struct bpf_prog *xdp_prog;
196198
u32 act;
@@ -201,7 +203,10 @@ static int i40e_run_xdp_zc(struct i40e_ring *rx_ring, struct xdp_buff *xdp)
201203
*/
202204
xdp_prog = READ_ONCE(rx_ring->xdp_prog);
203205
act = bpf_prog_run_xdp(xdp_prog, xdp);
204-
xdp->handle += xdp->data - xdp->data_hard_start;
206+
offset += xdp->data - xdp->data_hard_start;
207+
208+
xdp->handle = xsk_umem_adjust_offset(umem, xdp->handle, offset);
209+
205210
switch (act) {
206211
case XDP_PASS:
207212
break;
@@ -262,7 +267,7 @@ static bool i40e_alloc_buffer_zc(struct i40e_ring *rx_ring,
262267
bi->addr = xdp_umem_get_data(umem, handle);
263268
bi->addr += hr;
264269

265-
bi->handle = handle + umem->headroom;
270+
bi->handle = handle;
266271

267272
xsk_umem_discard_addr(umem);
268273
return true;
@@ -299,7 +304,7 @@ static bool i40e_alloc_buffer_slow_zc(struct i40e_ring *rx_ring,
299304
bi->addr = xdp_umem_get_data(umem, handle);
300305
bi->addr += hr;
301306

302-
bi->handle = handle + umem->headroom;
307+
bi->handle = handle;
303308

304309
xsk_umem_discard_addr_rq(umem);
305310
return true;
@@ -464,7 +469,7 @@ void i40e_zca_free(struct zero_copy_allocator *alloc, unsigned long handle)
464469
bi->addr = xdp_umem_get_data(rx_ring->xsk_umem, handle);
465470
bi->addr += hr;
466471

467-
bi->handle = (u64)handle + rx_ring->xsk_umem->headroom;
472+
bi->handle = (u64)handle;
468473
}
469474

470475
/**

0 commit comments

Comments
 (0)