When programming dbuff on rx queue context, avoid division round up as it causes to actually corrupt the tailroom for AF_XDP ZC. Below is an example based on 4k chunk size when xsk pool pointer is valid on given rx ring: chunk_size = 4096 headroom = 256 tailroom = 320 ring->rx_buf_len = 4096 - 256 - 320 = 3520 rx_ctx.dbuff = DIV_ROUND_UP(3520, 128) -> 3520 / 128 = 27.5 -> round up results in 28 dbuff programming unit is 128. If we give 128 * 28 = 3584. So HW will corrupt 64 bytes from tailroom. Doing plain division will floor the result and would not exceed reserved space at the end. Also, restore ::rx_buf_len setting via xsk_pool_get_rx_frame_size() as of now it respects the tailroom. Fixes: 1bbc04de607b ("ice: xsk: add RX multi-buffer support") Signed-off-by: Maciej Fijalkowski --- drivers/net/ethernet/intel/ice/ice_base.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_base.c b/drivers/net/ethernet/intel/ice/ice_base.c index 1667f686ff75..930688bd3476 100644 --- a/drivers/net/ethernet/intel/ice/ice_base.c +++ b/drivers/net/ethernet/intel/ice/ice_base.c @@ -498,8 +498,11 @@ static int ice_setup_rx_ctx(struct ice_rx_ring *ring) /* Receive Packet Data Buffer Size. * The Packet Data Buffer Size is defined in 128 byte units. */ - rlan_ctx.dbuf = DIV_ROUND_UP(ring->rx_buf_len, - BIT_ULL(ICE_RLAN_CTX_DBUF_S)); + if (ring->xsk_pool) + rlan_ctx.dbuf = ring->rx_buf_len / BIT_ULL(ICE_RLAN_CTX_DBUF_S); + else + rlan_ctx.dbuf = DIV_ROUND_UP(ring->rx_buf_len, + BIT_ULL(ICE_RLAN_CTX_DBUF_S)); /* use 32 byte descriptors */ rlan_ctx.dsize = 1; @@ -673,6 +676,9 @@ static int ice_vsi_cfg_rxq(struct ice_rx_ring *ring) if (ring->xsk_pool) { u32 frag_size = xsk_pool_get_rx_frag_step(ring->xsk_pool); + + ring->rx_buf_len = + xsk_pool_get_rx_frame_size(ring->xsk_pool); err = __xdp_rxq_info_reg(&ring->xdp_rxq, ring->netdev, ring->q_index, ring->q_vector->napi.napi_id, -- 2.43.0