]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
virtio-net: xsk: rx: move the xdp->data adjustment to buf_to_xdp()
authorBui Quang Minh <minhquangbui99@gmail.com>
Sat, 5 Jul 2025 07:55:14 +0000 (14:55 +0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 10 Jul 2025 01:41:35 +0000 (18:41 -0700)
This commit does not do any functional changes. It moves xdp->data
adjustment for buffer other than first buffer to buf_to_xdp() helper so
that the xdp_buff adjustment does not scatter over different functions.

Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
Link: https://patch.msgid.link/20250705075515.34260-1-minhquangbui99@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/virtio_net.c

index 9f6e0153ed2db4400939ab30d4f28ea1df78c8d2..4d995a47a11639ed23153f7eb9a1ee05469b8b2c 100644 (file)
@@ -1179,7 +1179,14 @@ static struct xdp_buff *buf_to_xdp(struct virtnet_info *vi,
                return NULL;
        }
 
-       xsk_buff_set_size(xdp, len);
+       if (first_buf) {
+               xsk_buff_set_size(xdp, len);
+       } else {
+               xdp_prepare_buff(xdp, xdp->data_hard_start,
+                                XDP_PACKET_HEADROOM - vi->hdr_len, len, 1);
+               xdp->flags = 0;
+       }
+
        xsk_buff_dma_sync_for_cpu(xdp);
 
        return xdp;
@@ -1304,7 +1311,7 @@ static int xsk_append_merge_buffer(struct virtnet_info *vi,
                        goto err;
                }
 
-               memcpy(buf, xdp->data - vi->hdr_len, len);
+               memcpy(buf, xdp->data, len);
 
                xsk_buff_free(xdp);