[PATCH net-next v1 0/7] virtnet_net: prepare for af-xdp

2024-05-30 Thread Xuan Zhuo
This patch set prepares for supporting af-xdp zerocopy. There is no feature change in this patch set. I just want to reduce the patch num of the final patch set, so I split the patch set. #1-#3 add independent directory for virtio-net #4-#7 do some refactor, the sub-functions will be used by the s

[PATCH net-next v1 1/7] virtio_net: independent directory

2024-05-30 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/Kc

[PATCH net-next v1 3/7] virtio_net: add prefix virtnet to all struct inside virtio_net.h

2024-05-30 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 Acked-by: Jason Wang --- drivers/net/virtio/virtnet.h | 12 ++-- drivers/net/virtio/virtnet_main.c | 110 +++--

[PATCH net-next v1 5/7] virtio_net: separate virtnet_tx_resize()

2024-05-30 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/virtnet.h | 2 ++ drivers/net/virtio/virtnet

[PATCH net-next v1 4/7] virtio_net: separate virtnet_rx_resize()

2024-05-30 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/virtnet.h | 3 +++ drivers/net/virtio/virtnet_

[PATCH net-next v1 2/7] virtio_net: move core structures to virtio_net.h

2024-05-30 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/virtnet.h | 239 +++

[PATCH net-next v1 6/7] virtio_net: separate receive_mergeable

2024-05-30 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 Acked-by: Jason Wang --- drivers/net/virtio/virtnet.h | 4 ++ drivers/net/virtio/virtnet_main.c | 77

[PATCH net-next v1 7/7] virtio_net: separate receive_buf

2024-05-30 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 Acked-by: Jason Wang --- drivers/net/virtio/virtnet_main.c | 56 ++---

Re: [PATCH net-next v1 0/7] virtnet_net: prepare for af-xdp

2024-05-30 Thread Michael S. Tsirkin
On Thu, May 30, 2024 at 03:26:42PM +0800, Xuan Zhuo wrote: > This patch set prepares for supporting af-xdp zerocopy. > There is no feature change in this patch set. > I just want to reduce the patch num of the final patch set, > so I split the patch set. > > #1-#3 add independent directory for vir

Re: [PATCH net-next v1 0/7] virtnet_net: prepare for af-xdp

2024-05-30 Thread Xuan Zhuo
On Thu, 30 May 2024 03:55:35 -0400, "Michael S. Tsirkin" wrote: > On Thu, May 30, 2024 at 03:26:42PM +0800, Xuan Zhuo wrote: > > This patch set prepares for supporting af-xdp zerocopy. > > There is no feature change in this patch set. > > I just want to reduce the patch num of the final patch set

Re: [PATCH net v3 2/2] virtio_net: fix a spurious deadlock issue

2024-05-30 Thread Paolo Abeni
On Tue, 2024-05-28 at 21:41 +0800, Heng Qi wrote: > When the following snippet is run, lockdep will report a deadlock[1]. > > /* Acquire all queues dim_locks */ > for (i = 0; i < vi->max_queue_pairs; i++) > mutex_lock(&vi->rq[i].dim_lock); > > There's no deadlock here because the vq

Re: [PATCH net v3 2/2] virtio_net: fix a spurious deadlock issue

2024-05-30 Thread Heng Qi
On Thu, 30 May 2024 10:34:07 +0200, Paolo Abeni wrote: > On Tue, 2024-05-28 at 21:41 +0800, Heng Qi wrote: > > When the following snippet is run, lockdep will report a deadlock[1]. > > > > /* Acquire all queues dim_locks */ > > for (i = 0; i < vi->max_queue_pairs; i++) > > mutex_loc

Re: [PATCH net v3 2/2] virtio_net: fix a spurious deadlock issue

2024-05-30 Thread Michael S. Tsirkin
On Tue, May 28, 2024 at 09:41:16PM +0800, Heng Qi wrote: > When the following snippet is run, lockdep will report a deadlock[1]. > > /* Acquire all queues dim_locks */ > for (i = 0; i < vi->max_queue_pairs; i++) > mutex_lock(&vi->rq[i].dim_lock); > > There's no deadlock here because

Re: [PATCH net v3 1/2] virtio_net: fix possible dim status unrecoverable

2024-05-30 Thread Michael S. Tsirkin
On Tue, May 28, 2024 at 09:41:15PM +0800, Heng Qi wrote: > When the dim worker is scheduled, if it no longer needs to issue > commands, dim may not be able to return to the working state later. > > For example, the following single queue scenario: > 1. The dim worker of rxq0 is scheduled, and th

Re: [PATCH net v3 1/2] virtio_net: fix possible dim status unrecoverable

2024-05-30 Thread Xuan Zhuo
On Tue, 28 May 2024 21:41:15 +0800, Heng Qi wrote: > When the dim worker is scheduled, if it no longer needs to issue > commands, dim may not be able to return to the working state later. > > For example, the following single queue scenario: > 1. The dim worker of rxq0 is scheduled, and the dim

Re: [PATCH net v3 2/2] virtio_net: fix a spurious deadlock issue

2024-05-30 Thread Xuan Zhuo
On Tue, 28 May 2024 21:41:16 +0800, Heng Qi wrote: > When the following snippet is run, lockdep will report a deadlock[1]. > > /* Acquire all queues dim_locks */ > for (i = 0; i < vi->max_queue_pairs; i++) > mutex_lock(&vi->rq[i].dim_lock); > > There's no deadlock here because the vq

Re: [PATCH net v3 2/2] virtio_net: fix a spurious deadlock issue

2024-05-30 Thread Jason Wang
On Thu, May 30, 2024 at 5:17 PM Michael S. Tsirkin wrote: > > On Tue, May 28, 2024 at 09:41:16PM +0800, Heng Qi wrote: > > When the following snippet is run, lockdep will report a deadlock[1]. > > > > /* Acquire all queues dim_locks */ > > for (i = 0; i < vi->max_queue_pairs; i++) > >

[PATCH net-next v2 00/12] virtnet_net: prepare for af-xdp

2024-05-30 Thread Xuan Zhuo
This patch set prepares for supporting af-xdp zerocopy. There is no feature change in this patch set. I just want to reduce the patch num of the final patch set, so I split the patch set. Thanks. v2: 1. Add five commits. That provides some helper for sq to support premapped mode. And t

[PATCH net-next v2 02/12] virtio_net: move core structures to virtio_net.h

2024-05-30 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/virtnet.h | 239 +++

[PATCH net-next v2 03/12] virtio_net: add prefix virtnet to all struct inside virtio_net.h

2024-05-30 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 Acked-by: Jason Wang --- drivers/net/virtio/virtnet.h | 12 ++-- drivers/net/virtio/virtnet_main.c | 110 +++--

[PATCH net-next v2 01/12] virtio_net: independent directory

2024-05-30 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/Kc

[PATCH net-next v2 04/12] virtio_net: separate virtnet_rx_resize()

2024-05-30 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/virtnet.h | 3 +++ drivers/net/virtio/virtnet_

[PATCH net-next v2 05/12] virtio_net: separate virtnet_tx_resize()

2024-05-30 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/virtnet.h | 2 ++ drivers/net/virtio/virtnet

[PATCH net-next v2 06/12] virtio_net: separate receive_mergeable

2024-05-30 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 Acked-by: Jason Wang --- drivers/net/virtio/virtnet.h | 4 ++ drivers/net/virtio/virtnet_main.c | 77

[PATCH net-next v2 07/12] virtio_net: separate receive_buf

2024-05-30 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 Acked-by: Jason Wang --- drivers/net/virtio/virtnet_main.c | 56 ++---

[PATCH net-next v2 08/12] virtio_ring: introduce vring_need_unmap_buffer

2024-05-30 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

[PATCH net-next v2 09/12] virtio_ring: introduce dma map api for page

2024-05-30 Thread Xuan Zhuo
The virtio-net sq will use these APIs to map the scatterlist. dma_addr_t virtqueue_dma_map_page_attrs(struct virtqueue *_vq, struct page *page, size_t offset, size_t size, enum dma_data_direction dir,

[PATCH net-next v2 10/12] virtio_ring: introduce virtqueue_dma_map_sg_attrs

2024-05-30 Thread Xuan Zhuo
Introduce a helper to do dma map for scatterlist. That can be used by other drivers. Signed-off-by: Xuan Zhuo --- drivers/virtio/virtio_ring.c | 32 include/linux/virtio.h | 3 +++ 2 files changed, 35 insertions(+) diff --git a/drivers/virtio/virtio_ring.

[PATCH net-next v2 11/12] virtio_ring: virtqueue_set_dma_premapped() support to disable

2024-05-30 Thread Xuan Zhuo
virtio-net sq will only enable premapped mode when the sq is bound to the af-xdp. So we need the helper (virtqueue_set_dma_premapped) to enable the premapped mode when af-xdp binds to the sq. And to disable the premapped mode when af-xdp unbinds to the sq. Signed-off-by: Xuan Zhuo --- drivers/n

[PATCH net-next v2 12/12] virtio_net: refactor the xmit type

2024-05-30 Thread Xuan Zhuo
Because the af-xdp and the sq premapped mode will introduce two new xmit types, so I refactor the xmit type mechanism first. Then we can add two new xmit types simply by add two new enum. We can use the last two bits of the pointer to distinguish the xmit type, so we can distinguish four xmit type

Re: [PATCH net-next v2 00/12] virtnet_net: prepare for af-xdp

2024-05-30 Thread Michael S. Tsirkin
On Thu, May 30, 2024 at 07:23:54PM +0800, Xuan Zhuo wrote: > This patch set prepares for supporting af-xdp zerocopy. > There is no feature change in this patch set. > I just want to reduce the patch num of the final patch set, > so I split the patch set. > > Thanks. > > v2: > 1. Add five comm

Re: [PATCH net-next v2 00/12] virtnet_net: prepare for af-xdp

2024-05-30 Thread Xuan Zhuo
On Thu, 30 May 2024 07:53:17 -0400, "Michael S. Tsirkin" wrote: > On Thu, May 30, 2024 at 07:23:54PM +0800, Xuan Zhuo wrote: > > This patch set prepares for supporting af-xdp zerocopy. > > There is no feature change in this patch set. > > I just want to reduce the patch num of the final patch set

Re: [PATCH net-next v2 00/12] virtnet_net: prepare for af-xdp

2024-05-30 Thread Xuan Zhuo
On Thu, 30 May 2024 19:54:44 +0800, Xuan Zhuo wrote: > On Thu, 30 May 2024 07:53:17 -0400, "Michael S. Tsirkin" > wrote: > > On Thu, May 30, 2024 at 07:23:54PM +0800, Xuan Zhuo wrote: > > > This patch set prepares for supporting af-xdp zerocopy. > > > There is no feature change in this patch se

Re: [PATCH net-next v2 00/12] virtnet_net: prepare for af-xdp

2024-05-30 Thread Jakub Kicinski
On Fri, 31 May 2024 09:40:14 +0800 Xuan Zhuo wrote: > On Thu, 30 May 2024 19:54:44 +0800, Xuan Zhuo > wrote: > > On Thu, 30 May 2024 07:53:17 -0400, "Michael S. Tsirkin" > > wrote: > > > It's great that you are working on this but > > > I'd like to see the actual use of this first. > > > >

Re: [PATCH net-next v2 00/12] virtnet_net: prepare for af-xdp

2024-05-30 Thread Xuan Zhuo
On Thu, 30 May 2024 18:55:17 -0700, Jakub Kicinski wrote: > On Fri, 31 May 2024 09:40:14 +0800 Xuan Zhuo wrote: > > On Thu, 30 May 2024 19:54:44 +0800, Xuan Zhuo > > wrote: > > > On Thu, 30 May 2024 07:53:17 -0400, "Michael S. Tsirkin" > > > wrote: > > > > It's great that you are working on th