[PATCH net-next v3 27/27] virtio_net: xdp_features add NETDEV_XDP_ACT_XSK_ZEROCOPY

2023-12-28 Thread Xuan Zhuo
Now, we supported AF_XDP(xsk). Add NETDEV_XDP_ACT_XSK_ZEROCOPY to xdp_features. Signed-off-by: Xuan Zhuo --- drivers/net/virtio/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio/main.c b/drivers/net/virtio/main.c index cc0194c14c98..ec28f87f04a7 1006

[PATCH net-next v3 26/27] virtio_net: update tx timeout record

2023-12-28 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/xsk.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/virtio/xsk.c b/drivers/net/virtio/xsk.c index ee09e8

[PATCH net-next v3 22/27] virtio_net: xsk: rx: support fill with xsk buffer

2023-12-28 Thread Xuan Zhuo
Implement the logic of filling rq with XSK buffers. Signed-off-by: Xuan Zhuo --- drivers/net/virtio/main.c | 9 +- drivers/net/virtio/virtio_net.h | 2 ++ drivers/net/virtio/xsk.c| 51 - drivers/net/virtio/xsk.h| 2 ++ 4 files changed,

[PATCH net-next v3 21/27] virtio_net: separate receive_buf

2023-12-28 Thread Xuan Zhuo
This commit separates the function receive_buf(), then we wrap the logic of handling the skb to an independent function virtnet_receive_done(). The subsequent commit will reuse it. Signed-off-by: Xuan Zhuo --- drivers/net/virtio/main.c | 56 ++- 1 file changed

[PATCH net-next v3 25/27] virtio_net: xsk: rx: free the unused xsk buffer

2023-12-28 Thread Xuan Zhuo
Since this will be called in other circumstances(freeze), we must check whether it is xsk's buffer in this function. It cannot be judged outside this function. Signed-off-by: Xuan Zhuo --- drivers/net/virtio/main.c | 8 1 file changed, 8 insertions(+) diff --git a/drivers/net/virtio/ma

[PATCH net-next v3 20/27] virtio_net: separate receive_mergeable

2023-12-28 Thread Xuan Zhuo
This commit separates the function receive_mergeable(), put the logic of appending frag to the skb as an independent function. The subsequent commit will reuse it. Signed-off-by: Xuan Zhuo --- drivers/net/virtio/main.c | 77 --- 1 file changed, 47 insertions(+

[PATCH net-next v3 24/27] virtio_net: xsk: rx: support recv small mode

2023-12-28 Thread Xuan Zhuo
receive the xsk buffer for small mode. Signed-off-by: Xuan Zhuo --- drivers/net/virtio/xsk.c | 33 + 1 file changed, 33 insertions(+) diff --git a/drivers/net/virtio/xsk.c b/drivers/net/virtio/xsk.c index 005bb5f66271..ee09e898a291 100644 --- a/drivers/net/virtio

[PATCH net-next v3 23/27] virtio_net: xsk: rx: support recv merge mode

2023-12-28 Thread Xuan Zhuo
The virtnet_xdp_handler() is re-used. But 1. We need to copy data to create skb for XDP_PASS. 2. We need to call xsk_buff_free() to release the buffer. 3. The handle for xdp_buff is difference. If we pushed this logic into existing receive handle(merge and small), we would have to maintain code s

[PATCH net-next v3 19/27] virtio_net: xsk: tx: free the unused xsk buffer

2023-12-28 Thread Xuan Zhuo
virtnet_sq_free_unused_buf() check xsk buffer. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/net/virtio/main.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/virtio/main.c b/drivers/net/virtio/main.c index 2c82418b0344..ab1970158d85 100644 ---

[PATCH net-next v3 18/27] virtio_net: xsk: tx: handle the transmitted xsk buffer

2023-12-28 Thread Xuan Zhuo
virtnet_free_old_xmit distinguishes three type ptr(skb, xdp frame, xsk buffer) by the last bits of the pointer. Signed-off-by: Xuan Zhuo --- drivers/net/virtio/virtio_net.h | 30 ++ drivers/net/virtio/xsk.c| 33 ++--- drivers/net/vi

[PATCH net-next v3 17/27] virtio_net: xsk: tx: support wakeup

2023-12-28 Thread Xuan Zhuo
xsk wakeup is used to trigger the logic for xsk xmit by xsk framework or user. Virtio-net does not support to actively generate an interruption, so it tries to trigger tx NAPI on the local cpu. Signed-off-by: Xuan Zhuo --- drivers/net/virtio/main.c | 20 ++-- drivers/net/v

[PATCH net-next v3 16/27] virtio_net: xsk: tx: support xmit xsk buffer

2023-12-28 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. Signed-off-by: Xuan Zhuo --- drivers/net/virtio/main.c | 22 ++--- drivers/net/virtio/virtio_net.h | 4 ++ drivers

[PATCH net-next v3 10/27] virtio_net: sq support premapped mode

2023-12-28 Thread Xuan Zhuo
If the xsk is enabling, the xsk tx will share the send queue. But the xsk requires that the send queue use the premapped mode. So the send queue must support premapped mode. command: pktgen_sample01_simple.sh -i eth0 -s 16/1400 -d 10.0.0.123 -m 00:16:3e:12:e1:3e -n 0 -p 100 machine: ecs.ebmg6e.2

[PATCH net-next v3 13/27] virtio_net: xsk: bind/unbind xsk

2023-12-28 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/Makefile | 2 +- drivers/net/virtio/main.c | 11 +- drivers/net/virtio/virtio_net.h | 17 +++ drivers/net/virtio/xsk.c| 187

[PATCH net-next v3 15/27] virtio_net: move some api to header

2023-12-28 Thread Xuan Zhuo
__free_old_xmit is_xdp_raw_buffer_queue These two APIs are needed by the xsk part. So this commit move theses to the header. And add prefix "virtnet_". Signed-off-by: Xuan Zhuo --- drivers/net/virtio/main.c | 86 +++-- drivers/net/virtio/virtio_net.h | 72 +

[PATCH net-next v3 07/27] virtio_ring: virtqueue_disable_and_recycle let the callback detach bufs

2023-12-28 Thread Xuan Zhuo
Now, inside virtqueue_disable_and_recycle, the recycle() just has two parameters(vq, buf) after detach operate. But if we are in premapped mode, we may need to get some dma info when detach buf like virtqueue_get_buf_ctx_dma(). So we call recycle directly, this callback detaches bufs self. It sho

[PATCH net-next v3 14/27] virtio_net: xsk: prevent disable tx napi

2023-12-28 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/main.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio/main.c

[PATCH net-next v3 12/27] virtio_net: separate virtnet_tx_resize()

2023-12-28 Thread Xuan Zhuo
This patch separates two sub-functions from virtnet_tx_resize(): * virtnet_tx_pause * virtnet_tx_resume Then the subsequent virtnet_tx_reset() can share these two functions. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/net/virtio/main.c | 35 +++-

[PATCH net-next v3 06/27] virtio_ring: introduce virtqueue_get_buf_ctx_dma()

2023-12-28 Thread Xuan Zhuo
introduce virtqueue_get_buf_ctx_dma() to collect the dma info when get buf from virtio core for premapped mode. If the virtio queue is premapped mode, the virtio-net send buf may have many desc. Every desc dma address need to be unmap. So here we introduce a new helper to collect the dma address o

[PATCH net-next v3 08/27] virtio_ring: introduce virtqueue_detach_unused_buf_dma()

2023-12-28 Thread Xuan Zhuo
introduce virtqueue_detach_unused_buf_dma() to collect the dma info when get buf from virtio core for premapped mode. If the virtio queue is premapped mode, the virtio-net send buf may have many desc. Every desc dma address need to be unmap. So here we introduce a new helper to collect the dma add

[PATCH net-next v3 04/27] virtio_net: move core structures to virtio_net.h

2023-12-28 Thread Xuan Zhuo
Move some core structures (send_queue, receive_queue, virtnet_info) definitions and the relative structures definitions into the virtio_net.h file. That will be used by the other c code files. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/net/virtio/main.c | 189 +

[PATCH net-next v3 11/27] virtio_net: separate virtnet_rx_resize()

2023-12-28 Thread Xuan Zhuo
This patch separates two sub-functions from virtnet_rx_resize(): * virtnet_rx_pause * virtnet_rx_resume Then the subsequent reset rx for xsk can share these two functions. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/net/virtio/main.c | 29 + dri

[PATCH net-next v3 02/27] virtio_net: unify the code for recycling the xmit ptr

2023-12-28 Thread Xuan Zhuo
There are two completely similar and independent implementations. This is inconvenient for the subsequent addition of new types. So extract a function from this piece of code and call this function uniformly to recover old xmit ptr. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/net/

[PATCH net-next v3 03/27] virtio_net: independent directory

2023-12-28 Thread Xuan Zhuo
Create a separate directory for virtio-net. AF_XDP support will be added later, then a separate xsk.c file will be added, so we should create a directory for virtio-net. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- MAINTAINERS | 2 +- drivers/net/Kconfig

[PATCH net-next v3 09/27] virtio_ring: introduce virtqueue_get_dma_premapped()

2023-12-28 Thread Xuan Zhuo
Introduce helper virtqueue_get_dma_premapped(), then the driver can know whether dma unmap is needed. Signed-off-by: Xuan Zhuo --- drivers/net/virtio/main.c | 22 +- drivers/net/virtio/virtio_net.h | 3 --- drivers/virtio/virtio_ring.c| 22 ++ i

[PATCH net-next v3 00/27] virtio-net: support AF_XDP zero copy

2023-12-28 Thread Xuan Zhuo
## AF_XDP XDP socket(AF_XDP) is an excellent bypass kernel network framework. The zero copy feature of xsk (XDP socket) needs to be supported by the driver. The performance of zero copy is very good. mlx5 and intel ixgbe already support this feature, This patch set allows virtio-net to support xsk

[PATCH net-next v3 05/27] virtio_net: add prefix virtnet to all struct inside virtio_net.h

2023-12-28 Thread Xuan Zhuo
We move some structures to the header file, but these structures do not prefixed with virtnet. This patch adds virtnet for these. Signed-off-by: Xuan Zhuo --- drivers/net/virtio/main.c | 100 drivers/net/virtio/virtio_net.h | 12 ++-- 2 files changed, 56 i

[PATCH net-next v3 01/27] virtio_net: rename free_old_xmit_skbs to free_old_xmit

2023-12-28 Thread Xuan Zhuo
Since free_old_xmit_skbs not only deals with skb, but also xdp frame and subsequent added xsk, so change the name of this function to free_old_xmit. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/net/virtio_net.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff