Re: [PATCH 0/5] vDPA/ifcvf: implement immediate initialization mechanism

2023-04-23 Thread Jason Wang
On Mon, Apr 24, 2023 at 12:53 PM Michael S. Tsirkin wrote: > > On Mon, Apr 24, 2023 at 11:50:20AM +0800, Jason Wang wrote: > > On Thu, Apr 20, 2023 at 5:17 PM Zhu, Lingshan > > wrote: > > > > > > > > > > > > On 4/3/2023 6:10 PM, Zhu, Lingshan wrote: > > > > > > > > > > > > On 4/3/2023 1:28 PM, J

Re: [PATCH 0/5] vDPA/ifcvf: implement immediate initialization mechanism

2023-04-23 Thread Michael S. Tsirkin
On Mon, Apr 24, 2023 at 11:50:20AM +0800, Jason Wang wrote: > On Thu, Apr 20, 2023 at 5:17 PM Zhu, Lingshan wrote: > > > > > > > > On 4/3/2023 6:10 PM, Zhu, Lingshan wrote: > > > > > > > > > On 4/3/2023 1:28 PM, Jason Wang wrote: > > >> On Fri, Mar 31, 2023 at 8:49 PM Zhu Lingshan > > >> wrote: >

Re: [PATCH 0/5] vDPA/ifcvf: implement immediate initialization mechanism

2023-04-23 Thread Michael S. Tsirkin
On Sat, Apr 01, 2023 at 04:48:49AM +0800, Zhu Lingshan wrote: > Formerly, ifcvf driver has implemented a lazy-initialization mechanism > for the virtqueues and other config space contents, > it would store all configurations that passed down from the userspace, > then load them to the device config

Re: [PATCH 2/5] get_driver_features from virito registers

2023-04-23 Thread Michael S. Tsirkin
subj typo: virtio On Sat, Apr 01, 2023 at 04:48:51AM +0800, Zhu Lingshan wrote: > This commit implements a new function ifcvf_get_driver_feature() > which read driver_features from virtio registers. > > To be less ambiguous, ifcvf_set_features() is renamed to > ifcvf_set_driver_features(), and if

Re: [PATCH 0/5] vDPA/ifcvf: implement immediate initialization mechanism

2023-04-23 Thread Jason Wang
On Thu, Apr 20, 2023 at 5:17 PM Zhu, Lingshan wrote: > > > > On 4/3/2023 6:10 PM, Zhu, Lingshan wrote: > > > > > > On 4/3/2023 1:28 PM, Jason Wang wrote: > >> On Fri, Mar 31, 2023 at 8:49 PM Zhu Lingshan > >> wrote: > >>> Formerly, ifcvf driver has implemented a lazy-initialization mechanism > >>

Re: [PATCH v3] vhost_vdpa: fix unmap process in no-batch mode

2023-04-23 Thread Jason Wang
On Thu, Apr 20, 2023 at 11:17 PM Cindy Lu wrote: > > While using the vdpa device with vIOMMU enabled > in the guest VM, when the vdpa device bind to vfio-pci and run testpmd > then system will fail to unmap. > The test process is > Load guest VM --> attach to virtio driver--> bind to vfio-pci driv

Re: [RFC 0/2] vduse: add support for networking devices

2023-04-23 Thread Jason Wang
On Sun, Apr 23, 2023 at 4:22 PM Yongji Xie wrote: > > On Sun, Apr 23, 2023 at 2:31 PM Jason Wang wrote: > > > > On Fri, Apr 21, 2023 at 10:28 PM Maxime Coquelin > > wrote: > > > > > > > > > > > > On 4/21/23 07:51, Jason Wang wrote: > > > > On Thu, Apr 20, 2023 at 10:16 PM Maxime Coquelin > > > >

Re: [PATCH net-next v1] xsk: introduce xsk_dma_cbs

2023-04-23 Thread Michael S. Tsirkin
On Sun, Apr 23, 2023 at 08:45:20AM +0200, Greg KH wrote: > On Sun, Apr 23, 2023 at 02:25:45PM +0800, Xuan Zhuo wrote: > > The purpose of this patch is to allow driver pass the own dma callbacks > > to xsk. > > > > This is to cope with the scene of virtio-net. If virtio does not have > > VIRTIO_F_A

Re: [PATCH net] virtio-net: reject small vring sizes

2023-04-23 Thread Michael S. Tsirkin
On Sun, Apr 23, 2023 at 12:28:49PM +, Alvaro Karsz wrote: > > > > > The rest of stuff can probably just be moved to after find_vqs without > > > > much pain. > > > > > > > Actually, I think that with a little bit of pain :) > > > If we use small vrings and a GRO feature bit is set, Linux will

Re: [PATCH net] virtio-net: reject small vring sizes

2023-04-23 Thread Alvaro Karsz
> > > The rest of stuff can probably just be moved to after find_vqs without > > > much pain. > > > > > Actually, I think that with a little bit of pain :) > > If we use small vrings and a GRO feature bit is set, Linux will need to > > allocate 64KB of continuous memory for every receive descrip

Re: [PATCH net] virtio-net: reject small vring sizes

2023-04-23 Thread Michael S. Tsirkin
On Mon, Apr 17, 2023 at 06:43:39AM +, Alvaro Karsz wrote: > > > +static int virtnet_validate_vqs(struct virtnet_info *vi) > > > +{ > > > + u32 i, min_size = roundup_pow_of_two(MAX_SKB_FRAGS + 2); > > > > why power of two? > > The ring size is always a power of 2, Not really, packed rings

Re: [PATCH net] virtio-net: reject small vring sizes

2023-04-23 Thread Michael S. Tsirkin
On Sun, Apr 23, 2023 at 08:01:35AM +, Alvaro Karsz wrote: > We could add a new virtio_config_ops: peek_vqs. > We can call it during virtnet_validate, and then fixup the features in case > of small vrings. > > If peek_vqs is not implemented by the transport, we can just fail probe later > in

Re: [PATCH net] virtio-net: reject small vring sizes

2023-04-23 Thread Michael S. Tsirkin
On Sun, Apr 23, 2023 at 07:52:10AM +, Alvaro Karsz wrote: > > Hmm. I was wrong. There is no way to disable CVQ feature bit. > > > > 1. Reset the device. > > 2. Set the ACKNOWLEDGE status bit: the guest OS has notice the device. > > 3. Set the DRIVER status bit: the guest OS knows how to drive

[PATCH net-next v3 15/15] virtio_net: introduce virtnet_build_skb()

2023-04-23 Thread Xuan Zhuo
This logic is used in multiple places, now we separate it into a helper. Signed-off-by: Xuan Zhuo --- drivers/net/virtio_net.c | 34 +- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 811cf1

[PATCH net-next v3 13/15] virtio_net: small: remove skip_xdp

2023-04-23 Thread Xuan Zhuo
now, the process of xdp is simple, we can remove the skip_xdp. Signed-off-by: Xuan Zhuo --- drivers/net/virtio_net.c | 26 -- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 601c0e7fc32b..d2973c8fa4

[PATCH net-next v3 11/15] virtio_net: small: optimize code

2023-04-23 Thread Xuan Zhuo
In the case of XDP-PASS, skb_reserve uses the delta to compatible non-XDP, now remove this logic. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/net/virtio_net.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net

[PATCH net-next v3 14/15] virtio_net: introduce receive_small_build_xdp

2023-04-23 Thread Xuan Zhuo
Simplifying receive_small() function. Bringing the logic relating to build_skb together. Signed-off-by: Xuan Zhuo --- drivers/net/virtio_net.c | 48 ++-- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/vir

[PATCH net-next v3 07/15] virtio_net: auto release xdp shinfo

2023-04-23 Thread Xuan Zhuo
virtnet_build_xdp_buff_mrg() and virtnet_xdp_handler() auto release xdp shinfo then the caller no need to careful the xdp shinfo. Signed-off-by: Xuan Zhuo --- drivers/net/virtio_net.c | 29 + 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/net/

[PATCH net-next v3 09/15] virtio_net: merge: remove skip_xdp

2023-04-23 Thread Xuan Zhuo
Now, the logic of merge xdp process is simple, we can remove the skip_xdp. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/net/virtio_net.c | 23 ++- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c

[PATCH net-next v3 08/15] virtio_net: introduce receive_mergeable_xdp()

2023-04-23 Thread Xuan Zhuo
The purpose of this patch is to simplify the receive_mergeable(). Separate all the logic of XDP into a function. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/net/virtio_net.c | 100 --- 1 file changed, 62 insertions(+), 38 deletions(-) diff --gi

[PATCH net-next v3 06/15] virtio_net: separate the logic of freeing the rest mergeable buf

2023-04-23 Thread Xuan Zhuo
This patch introduce a new function that frees the rest mergeable buf. The subsequent patch will reuse this function. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/net/virtio_net.c | 36 1 file changed, 24 insertions(+), 12 deletions(-) diff --g

[PATCH net-next v3 12/15] virtio_net: small: optimize code

2023-04-23 Thread Xuan Zhuo
Avoid the problem that some variables(headroom and so on) will repeat the calculation when process xdp. Signed-off-by: Xuan Zhuo --- drivers/net/virtio_net.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index

[PATCH net-next v3 04/15] virtio_net: introduce virtnet_xdp_handler() to seprate the logic of run xdp

2023-04-23 Thread Xuan Zhuo
At present, we have two similar logic to perform the XDP prog. Therefore, this patch separates the code of executing XDP, which is conducive to later maintenance. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/net/virtio_net.c | 118 +++ 1 file ch

[PATCH net-next v3 10/15] virtio_net: introduce receive_small_xdp()

2023-04-23 Thread Xuan Zhuo
The purpose of this patch is to simplify the receive_small(). Separate all the logic of XDP of small into a function. Signed-off-by: Xuan Zhuo --- drivers/net/virtio_net.c | 165 --- 1 file changed, 100 insertions(+), 65 deletions(-) diff --git a/drivers/net/

[PATCH net-next v3 02/15] virtio_net: introduce mergeable_xdp_get_buf()

2023-04-23 Thread Xuan Zhuo
Separating the logic of preparation for xdp from receive_mergeable. The purpose of this is to simplify the logic of execution of XDP. The main logic here is that when headroom is insufficient, we need to allocate a new page and calculate offset. It should be noted that if there is new page, the v

[PATCH net-next v3 05/15] virtio_net: separate the logic of freeing xdp shinfo

2023-04-23 Thread Xuan Zhuo
This patch introduce a new function that releases the xdp shinfo. The subsequent patch will reuse this function. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/net/virtio_net.c | 27 --- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/n

[PATCH net-next v3 01/15] virtio_net: mergeable xdp: put old page immediately

2023-04-23 Thread Xuan Zhuo
In the xdp implementation of virtio-net mergeable, it always checks whether two page is used and a page is selected to release. This is complicated for the processing of action, and be careful. In the entire process, we have such principles: * If xdp_page is used (PASS, TX, Redirect), then we rele

[PATCH net-next v3 00/15] virtio_net: refactor xdp codes

2023-04-23 Thread Xuan Zhuo
Due to historical reasons, the implementation of XDP in virtio-net is relatively chaotic. For example, the processing of XDP actions has two copies of similar code. Such as page, xdp_page processing, etc. The purpose of this patch set is to refactor these code. Reduce the difficulty of subsequent

[PATCH net-next v3 03/15] virtio_net: optimize mergeable_xdp_get_buf()

2023-04-23 Thread Xuan Zhuo
The previous patch, in order to facilitate review, I do not do any modification. This patch has made some optimization on the top. * remove some repeated logics in this function. * add fast check for passing without any alloc. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/net/virti

Re: [PATCH net-next v1] xsk: introduce xsk_dma_cbs

2023-04-23 Thread Xuan Zhuo
On Sun, 23 Apr 2023 10:39:15 +0200, Greg KH wrote: > On Sun, Apr 23, 2023 at 02:58:36PM +0800, Xuan Zhuo wrote: > > On Sun, 23 Apr 2023 08:45:20 +0200, Greg KH > > wrote: > > > On Sun, Apr 23, 2023 at 02:25:45PM +0800, Xuan Zhuo wrote: > > > > The purpose of this patch is to allow driver pass th

Re: [PATCH net-next v1] xsk: introduce xsk_dma_cbs

2023-04-23 Thread Greg KH
On Sun, Apr 23, 2023 at 02:58:36PM +0800, Xuan Zhuo wrote: > On Sun, 23 Apr 2023 08:45:20 +0200, Greg KH > wrote: > > On Sun, Apr 23, 2023 at 02:25:45PM +0800, Xuan Zhuo wrote: > > > The purpose of this patch is to allow driver pass the own dma callbacks > > > to xsk. > > > > > > This is to cope

Re: [PATCH net] virtio-net: reject small vring sizes

2023-04-23 Thread Alvaro Karsz
We could add a new virtio_config_ops: peek_vqs. We can call it during virtnet_validate, and then fixup the features in case of small vrings. If peek_vqs is not implemented by the transport, we can just fail probe later in case of small vrings. ___ Vir

Re: [PATCH net] virtio-net: reject small vring sizes

2023-04-23 Thread Alvaro Karsz
> Hmm. I was wrong. There is no way to disable CVQ feature bit. > > 1. Reset the device. > 2. Set the ACKNOWLEDGE status bit: the guest OS has notice the device. > 3. Set the DRIVER status bit: the guest OS knows how to drive the device. > 4. Read device feature bits, and write the subset of featu

Re: [PATCH net-next v1] xsk: introduce xsk_dma_cbs

2023-04-23 Thread Xuan Zhuo
On Sun, 23 Apr 2023 08:45:20 +0200, Greg KH wrote: > On Sun, Apr 23, 2023 at 02:25:45PM +0800, Xuan Zhuo wrote: > > The purpose of this patch is to allow driver pass the own dma callbacks > > to xsk. > > > > This is to cope with the scene of virtio-net. If virtio does not have > > VIRTIO_F_ACCESS_

Re: [PATCH net] virtio-net: reject small vring sizes

2023-04-23 Thread Michael S. Tsirkin
On Sun, Apr 23, 2023 at 06:51:46AM +, Alvaro Karsz wrote: > > Yes that makes sense, it's architetural. We can disable ctrl vq though. > > The problem here is that we know the vring size after calling > virtnet_find_vqs, so the number of VQs already includes the control VQ. > > Actually, many