Skip to content

Commit 10912fc

Browse files
kevin-laatz-intelborkmann
authored andcommitted
i40e: simplify Rx buffer recycle
Currently, the dma, addr and handle are modified when we reuse Rx buffers in zero-copy mode. However, this is not required as the inputs to the function are copies, not the original values themselves. As we use the copies within the function, we can use the original 'old_bi' values directly without having to mask and add the headroom. Signed-off-by: Kevin Laatz <[email protected]> Acked-by: Jonathan Lemon <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
1 parent 1c6d6e0 commit 10912fc

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -420,23 +420,16 @@ static void i40e_reuse_rx_buffer_zc(struct i40e_ring *rx_ring,
420420
struct i40e_rx_buffer *old_bi)
421421
{
422422
struct i40e_rx_buffer *new_bi = &rx_ring->rx_bi[rx_ring->next_to_alloc];
423-
unsigned long mask = (unsigned long)rx_ring->xsk_umem->chunk_mask;
424-
u64 hr = rx_ring->xsk_umem->headroom + XDP_PACKET_HEADROOM;
425423
u16 nta = rx_ring->next_to_alloc;
426424

427425
/* update, and store next to alloc */
428426
nta++;
429427
rx_ring->next_to_alloc = (nta < rx_ring->count) ? nta : 0;
430428

431429
/* transfer page from old buffer to new buffer */
432-
new_bi->dma = old_bi->dma & mask;
433-
new_bi->dma += hr;
434-
435-
new_bi->addr = (void *)((unsigned long)old_bi->addr & mask);
436-
new_bi->addr += hr;
437-
438-
new_bi->handle = old_bi->handle & mask;
439-
new_bi->handle += rx_ring->xsk_umem->headroom;
430+
new_bi->dma = old_bi->dma;
431+
new_bi->addr = old_bi->addr;
432+
new_bi->handle = old_bi->handle;
440433

441434
old_bi->addr = NULL;
442435
}

0 commit comments

Comments
 (0)