[RFC net-next v1 04/12] virtio_ring: perform premapped operations based on per-buffer

2024-09-23 Thread Xuan Zhuo
The current configuration sets the virtqueue (vq) to premapped mode, implying that all buffers submitted to this queue must be mapped ahead of time. This presents a challenge for the virtnet send queue (sq): the virtnet driver would be required to keep track of dma information for vq size * 17, whi

[RFC net-next v1 10/12] virtio_net: xsk: tx: support xmit xsk buffer

2024-09-23 Thread Xuan Zhuo
The driver's tx napi is very important for XSK. It is responsible for obtaining data from the XSK queue and sending it out. At the beginning, we need to trigger tx napi. virtnet_free_old_xmit distinguishes three type ptr(skb, xdp frame, xsk buffer) by the last bits of the pointer. Signed-off-by:

[RFC net-next v1 06/12] virtio_ring: remove API virtqueue_set_dma_premapped

2024-09-23 Thread Xuan Zhuo
Now, this API is useless. remove it. Signed-off-by: Xuan Zhuo --- drivers/virtio/virtio_ring.c | 48 include/linux/virtio.h | 2 -- 2 files changed, 50 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index b570acb

[RFC net-next v1 05/12] virtio-net: rq submits premapped per-buffer

2024-09-23 Thread Xuan Zhuo
virtio-net rq submits premapped per-buffer by setting sg page to NULL; Signed-off-by: Xuan Zhuo --- drivers/net/virtio_net.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 6f4781ec2b36..630e5b21ad69 1

[RFC net-next v1 12/12] virtio_net: xdp_features add NETDEV_XDP_ACT_XSK_ZEROCOPY

2024-09-23 Thread Xuan Zhuo
Now, we support AF_XDP(xsk). Add NETDEV_XDP_ACT_XSK_ZEROCOPY to xdp_features. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/net/virtio_net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index a1ef0277c550..

[RFC net-next v1 11/12] virtio_net: update tx timeout record

2024-09-23 Thread Xuan Zhuo
If send queue sent some packets, we update the tx timeout record to prevent the tx timeout. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/net/virtio_net.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 1a870f1df91

[RFC net-next v1 03/12] virtio_ring: packed: record extras for indirect buffers

2024-09-23 Thread Xuan Zhuo
The subsequent commit needs to know whether every indirect buffer is premapped or not. So we need to introduce an extra struct for every indirect buffer to record this info. Signed-off-by: Xuan Zhuo --- drivers/virtio/virtio_ring.c | 67 1 file changed, 37 in

[RFC net-next v1 09/12] virtio_net: xsk: prevent disable tx napi

2024-09-23 Thread Xuan Zhuo
Since xsk's TX queue is consumed by TX NAPI, if sq is bound to xsk, then we must stop tx napi from being disabled. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/net/virtio_net.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/

[RFC net-next v1 02/12] virtio_ring: split: record extras for indirect buffers

2024-09-23 Thread Xuan Zhuo
The subsequent commit needs to know whether every indirect buffer is premapped or not. So we need to introduce an extra struct for every indirect buffer to record this info. Signed-off-by: Xuan Zhuo --- drivers/virtio/virtio_ring.c | 126 +-- 1 file changed, 61 in

[RFC net-next v1 00/12] virtio-net: support AF_XDP zero copy (tx)

2024-09-23 Thread Xuan Zhuo
Because the merge window is closed, so this is RFC. v1: 1. some small fixes for http://lore.kernel.org/all/20240820073330.9161-1-xuanz...@linux.alibaba.com 1. fix the title of the commit #2, #3 2. fix the gcc error for commit #3 3. use virtqueue_dma_ for tx hdr

[RFC net-next v1 01/12] virtio_ring: introduce vring_need_unmap_buffer

2024-09-23 Thread Xuan Zhuo
To make the code readable, introduce vring_need_unmap_buffer() to replace do_unmap. use_dma_api premapped -> vring_need_unmap_buffer() 1. false falsefalse 2. truefalsetrue 3. truetrue false Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drive

[RFC net-next v1 08/12] virtio_net: xsk: bind/unbind xsk for tx

2024-09-23 Thread Xuan Zhuo
This patch implement the logic of bind/unbind xsk pool to sq and rq. Signed-off-by: Xuan Zhuo --- drivers/net/virtio_net.c | 53 1 file changed, 53 insertions(+) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 41a5ea9b788d..7c37961

[RFC net-next v1 07/12] virtio_net: refactor the xmit type

2024-09-23 Thread Xuan Zhuo
Because the af-xdp will introduce a new xmit type, so I refactor the xmit type mechanism first. In general, pointers are aligned to 4 or 8 bytes. If it is aligned to 4 bytes, then only two bits are free for a pointer. But there are 4 types here, so we can't use bits to distinguish them. And 2 bits