Re: [PATCH net-next v3 3/6] virtio_net: support device stats

2024-03-11 Thread Xuan Zhuo
On Thu, 7 Mar 2024 08:50:21 -0800, Jakub Kicinski wrote: > CC: Willem and some driver folks for more input, context: extending > https://lore.kernel.org/all/20240306195509.1502746-1-k...@kernel.org/ > to cover virtio stats. > > On Tue, 27 Feb 2024 16:03:00 +0800 Xuan Zhuo wrote: > > +static const

Re: [PATCH net-next v3 3/6] virtio_net: support device stats

2024-03-11 Thread Jakub Kicinski
On Mon, 11 Mar 2024 18:48:45 +0800 Xuan Zhuo wrote: > On Thu, 7 Mar 2024 08:50:21 -0800, Jakub Kicinski wrote: > > CC: Willem and some driver folks for more input, context: extending > > https://lore.kernel.org/all/20240306195509.1502746-1-k...@kernel.org/ > > to cover virtio stats. > > > > On Tue

[PATCH vhost v4 00/10] virtio: drivers maintain dma info for premapped vq

2024-03-11 Thread Xuan Zhuo
As discussed: http://lore.kernel.org/all/cacgkmevq0no8qgc46u4mgsmtud44fd_cflcpavmj3rhyqrz...@mail.gmail.com If the virtio is premapped mode, the driver should manage the dma info by self. So the virtio core should not store the dma info. We can release the memory used to store the dma info. For

[PATCH vhost v4 01/10] virtio_ring: introduce vring_need_unmap_buffer

2024-03-11 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 vhost v4 04/10] virtio_ring: split: remove double check of the unmap ops

2024-03-11 Thread Xuan Zhuo
In the functions vring_unmap_one_split and vring_unmap_one_split_indirect, multiple checks are made whether unmap is performed and whether it is INDIRECT. These two functions are usually called in a loop, and we should put the check outside the loop. And we unmap the descs with VRING_DESC_F_INDIR

[PATCH vhost v4 03/10] virtio_ring: packed: structure the indirect desc table

2024-03-11 Thread Xuan Zhuo
This commit structure the indirect desc table. Then we can get the desc num directly when doing unmap. And save the dma info to the struct, then the indirect will not use the dma fields of the desc_extra. The subsequent commits will make the dma fields are optional. But for the indirect case, we m

[PATCH vhost v4 02/10] virtio_ring: packed: remove double check of the unmap ops

2024-03-11 Thread Xuan Zhuo
In the functions vring_unmap_extra_packed and vring_unmap_desc_packed, multiple checks are made whether unmap is performed and whether it is INDIRECT. These two functions are usually called in a loop, and we should put the check outside the loop. And we unmap the descs with VRING_DESC_F_INDIRECT

[PATCH vhost v4 06/10] virtio_ring: no store dma info when unmap is not needed

2024-03-11 Thread Xuan Zhuo
As discussed: http://lore.kernel.org/all/CACGkMEug-=C+VQhkMYSgUKMC==04m7-uem_yc21bggkkzh8...@mail.gmail.com When the vq is premapped mode, the driver manages the dma info is a good way. So this commit make the virtio core not to store the dma info and release the memory which is used to store the

[PATCH vhost v4 07/10] virtio: find_vqs: add new parameter premapped

2024-03-11 Thread Xuan Zhuo
If the premapped mode is enabled, the dma array(struct vring_desc_dma) of virtio core will not be allocated. That is judged when find_vqs() is called. To avoid allocating dma array in find_vqs() and releasing it immediately by virtqueue_set_dma_premapped(). This patch introduces a new parameter to

[PATCH vhost v4 10/10] virtio_ring: virtqueue_set_dma_premapped support disable

2024-03-11 Thread Xuan Zhuo
Now, the API virtqueue_set_dma_premapped just support to enable premapped mode. If we allow enabling the premapped dynamically, we should make this API to support disable the premapped mode. Signed-off-by: Xuan Zhuo --- drivers/virtio/virtio_ring.c | 34 ++ inclu

[PATCH vhost v4 09/10] virtio_net: set premapped mode by find_vqs()

2024-03-11 Thread Xuan Zhuo
Now, the virtio core can set the premapped mode by find_vqs(). If the premapped can be enabled, the dma array will not be allocated. So virtio-net use the api of find_vqs to enable the premapped. Judge the premapped mode by the vq->premapped instead of saving local variable. Signed-off-by: Xuan Z

[PATCH vhost v4 05/10] virtio_ring: split: structure the indirect desc table

2024-03-11 Thread Xuan Zhuo
This commit structure the indirect desc table. Then we can get the desc num directly when doing unmap. And save the dma info to the struct, then the indirect will not use the dma fields of the desc_extra. The subsequent commits will make the dma fields are optional. But for the indirect case, we m

[PATCH vhost v4 08/10] virtio_ring: export premapped to driver by struct virtqueue

2024-03-11 Thread Xuan Zhuo
Export the premapped to drivers, then drivers can check the vq premapped mode after the find_vqs(). Because the find_vqs() just try to enable the vq premapped mode, the driver must check that after find_vqs(). Signed-off-by: Xuan Zhuo --- drivers/virtio/virtio_ring.c | 13 + include/