]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net/mlx5e: XDP, Improve dma address calculation of linear part for XDP_TX
authorDragos Tatulea <dtatulea@nvidia.com>
Fri, 3 Apr 2026 09:09:24 +0000 (12:09 +0300)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 7 Apr 2026 11:34:04 +0000 (13:34 +0200)
When calculating the dma address of the linear part of an XDP frame, the
formula assumes that there is a single XDP buffer per page. Extend the
formula to allow multiple XDP buffers per page by calculating the data
offset in the page.

This is a preparation for the upcoming removal of a single XDP buffer
per page limitation when the formula will no longer be correct.

Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com>
Reviewed-by: Carolina Jubran <cjubran@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20260403090927.139042-3-tariqt@nvidia.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c

index 04e1b5fa482528fb7ddbf923654f5ed1672ef760..d3bab198c99c004d2c9617b5f611bf2621347416 100644 (file)
@@ -123,7 +123,7 @@ mlx5e_xmit_xdp_buff(struct mlx5e_xdpsq *sq, struct mlx5e_rq *rq,
         * mode.
         */
 
-       dma_addr = page_pool_get_dma_addr(page) + (xdpf->data - (void *)xdpf);
+       dma_addr = page_pool_get_dma_addr(page) + offset_in_page(xdpf->data);
        dma_sync_single_for_device(sq->pdev, dma_addr, xdptxd->len, DMA_BIDIRECTIONAL);
 
        if (xdptxd->has_frags) {