]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
i40e: use xdp.frame_sz as XDP RxQ info frag_size
authorLarysa Zaremba <larysa.zaremba@intel.com>
Thu, 5 Mar 2026 11:12:47 +0000 (12:12 +0100)
committerJakub Kicinski <kuba@kernel.org>
Thu, 5 Mar 2026 16:02:04 +0000 (08:02 -0800)
The only user of frag_size field in XDP RxQ info is
bpf_xdp_frags_increase_tail(). It clearly expects whole buffer size instead
of DMA write size. Different assumptions in i40e driver configuration lead
to negative tailroom.

Set frag_size to the same value as frame_sz in shared pages mode, use new
helper to set frag_size when AF_XDP ZC is active.

Fixes: a045d2f2d03d ("i40e: set xdp_rxq_info::frag_size")
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
Link: https://patch.msgid.link/20260305111253.2317394-7-larysa.zaremba@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/intel/i40e/i40e_main.c

index 781ec5aa814b5d17f61589f3da3fe4553b7e65c7..926d001b215020a18a9e56a3dee1af48d1c3ff03 100644 (file)
@@ -3569,6 +3569,7 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
        u16 pf_q = vsi->base_queue + ring->queue_index;
        struct i40e_hw *hw = &vsi->back->hw;
        struct i40e_hmc_obj_rxq rx_ctx;
+       u32 xdp_frame_sz;
        int err = 0;
        bool ok;
 
@@ -3578,6 +3579,7 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
        memset(&rx_ctx, 0, sizeof(rx_ctx));
 
        ring->rx_buf_len = vsi->rx_buf_len;
+       xdp_frame_sz = i40e_rx_pg_size(ring) / 2;
 
        /* XDP RX-queue info only needed for RX rings exposed to XDP */
        if (ring->vsi->type != I40E_VSI_MAIN)
@@ -3585,11 +3587,12 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
 
        ring->xsk_pool = i40e_xsk_pool(ring);
        if (ring->xsk_pool) {
+               xdp_frame_sz = 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->queue_index,
                                         ring->q_vector->napi.napi_id,
-                                        ring->rx_buf_len);
+                                        xdp_frame_sz);
                if (err)
                        return err;
                err = xdp_rxq_info_reg_mem_model(&ring->xdp_rxq,
@@ -3605,7 +3608,7 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
                err = __xdp_rxq_info_reg(&ring->xdp_rxq, ring->netdev,
                                         ring->queue_index,
                                         ring->q_vector->napi.napi_id,
-                                        ring->rx_buf_len);
+                                        xdp_frame_sz);
                if (err)
                        return err;
                err = xdp_rxq_info_reg_mem_model(&ring->xdp_rxq,
@@ -3616,7 +3619,7 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
        }
 
 skip:
-       xdp_init_buff(&ring->xdp, i40e_rx_pg_size(ring) / 2, &ring->xdp_rxq);
+       xdp_init_buff(&ring->xdp, xdp_frame_sz, &ring->xdp_rxq);
 
        rx_ctx.dbuff = DIV_ROUND_UP(ring->rx_buf_len,
                                    BIT_ULL(I40E_RXQ_CTX_DBUFF_SHIFT));