[PATCH net-next v2 12/14] virtio_net: small: optimize code

2023-04-17 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 --- 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.c index 34220f5f27d1.

[PATCH net-next v2 07/14] virtio_net: separate the logic of freeing the rest mergeable buf

2023-04-17 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 v2 06/14] virtio_net: separate the logic of freeing xdp shinfo

2023-04-17 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 v2 14/14] virtio_net: small: remove skip_xdp

2023-04-17 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 5a5636178bd3..19f7a8367c

[PATCH net-next v2 13/14] virtio_net: small: optimize code

2023-04-17 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 v2 10/14] virtio_net: merge: remove skip_xdp

2023-04-17 Thread Xuan Zhuo
Now, the logic of merge xdp process is simple, we can remove the skip_xdp. Signed-off-by: Xuan Zhuo --- 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 index 42e9927e316b..a

[PATCH net-next v2 08/14] virtio_net: auto release xdp shinfo

2023-04-17 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 v2 11/14] virtio_net: introduce receive_small_xdp()

2023-04-17 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, 99 insertions(+), 66 deletions(-) diff --git a/drivers/net/v

[PATCH net-next v2 09/14] virtio_net: introduce receive_mergeable_xdp()

2023-04-17 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 --- drivers/net/virtio_net.c | 100 --- 1 file changed, 61 insertions(+), 39 deletions(-) diff --git a/drivers/net/virtio

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

2023-04-17 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 --- drivers/net/virtio_net.c | 118 +++ 1 file changed, 58 insertions(+

[PATCH net-next v2 03/14] virtio_net: optimize mergeable_xdp_prepare()

2023-04-17 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 --- drivers/net/virtio_net.c | 29 +

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

2023-04-17 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 v2 00/14] virtio_net: refactor xdp codes

2023-04-17 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 v2 05/14] virtio_net: introduce xdp res enums

2023-04-17 Thread Xuan Zhuo
virtnet_xdp_handler() is to process all the logic related to XDP. The caller only needs to care about how to deal with the buf. So this commit introduces new enums: 1. VIRTNET_XDP_RES_PASS: make skb by the buf 2. VIRTNET_XDP_RES_DROP: xdp return drop action or some error, caller should release

[PATCH net-next v2 02/14] virtio_net: introduce mergeable_xdp_prepare()

2023-04-17 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

Re: [PATCH vhost v6 08/11] virtio_ring: introduce virtqueue_dma_dev()

2023-04-17 Thread Xuan Zhuo
On Tue, 11 Apr 2023 05:16:19 -0700, Christoph Hellwig wrote: > On Tue, Apr 11, 2023 at 03:23:43PM +0800, Xuan Zhuo wrote: > > > If a direct map or not is used is a decision done by the platform code, > > > often based on firmware tables. You can't just override that. > > > > > > Can Virtio Devic

Re: [PATCH net-next] xsk: introduce xsk_dma_ops

2023-04-17 Thread Christoph Hellwig
On Mon, Apr 17, 2023 at 07:54:00PM -0700, Jakub Kicinski wrote: > AF_XDP, io_uring, and increasing number of pinned memory / zero copy > implementations need to do DMA mapping outside the drivers. You can't just do dma mapping outside the driver, because there are drivers that do not require DMA m

Re: [PATCH net-next] xsk: introduce xsk_dma_ops

2023-04-17 Thread Xuan Zhuo
On Mon, 17 Apr 2023 18:19:50 -0700, Jakub Kicinski wrote: > On Tue, 18 Apr 2023 09:07:30 +0800 Jason Wang wrote: > > > > Would you mind explaining this a bit more to folks like me who are not > > > > familiar with VirtIO? DMA API is supposed to hide the DMA mapping > > > > details from the stack,

Re: [PATCH net-next] xsk: introduce xsk_dma_ops

2023-04-17 Thread Xuan Zhuo
On Mon, 17 Apr 2023 11:57:53 -0700, Jakub Kicinski wrote: > On Mon, 17 Apr 2023 11:56:10 -0700 Jakub Kicinski wrote: > > > May misunderstand, here the "dma_ops" is not the "dma_ops" of DMA API. > > > > > > I mean the callbacks for xsk to do dma. > > > > > > Maybe, I should rename it in the next ve

Re: [PATCH net-next] xsk: introduce xsk_dma_ops

2023-04-17 Thread Jason Wang
On Tue, Apr 18, 2023 at 2:58 AM Jakub Kicinski wrote: > > On Mon, 17 Apr 2023 11:56:10 -0700 Jakub Kicinski wrote: > > > May misunderstand, here the "dma_ops" is not the "dma_ops" of DMA API. > > > > > > I mean the callbacks for xsk to do dma. > > > > > > Maybe, I should rename it in the next vers

Re: [PATCH v4 1/2] vdpa/snet: support getting and setting VQ state

2023-04-17 Thread Alvaro Karsz
> > Signed-off-by: Alvaro Karsz > > Acked-by: Jason Wang > Thanks Jason. BTW, Michael, I see that you merged the first version into the mst tree. ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation

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

2023-04-17 Thread Michael S. Tsirkin
On Mon, Apr 17, 2023 at 11:51:22AM +, Alvaro Karsz wrote: > > > I see your point. > > > Regardless, we'll need to fail probe in some cases. > > > ring size of 1 for example (if I'm not mistaken) > > > > Hmm. We can make it work if we increase hard header size, then > > there will always be roo

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

2023-04-17 Thread Alvaro Karsz
> > I see your point. > > Regardless, we'll need to fail probe in some cases. > > ring size of 1 for example (if I'm not mistaken) > > Hmm. We can make it work if we increase hard header size, then > there will always be room for vnet header. > > > control vq even needs a bigger ring. > > Why do

Re: [PATCH v5] vdpa/mlx5: Avoid losing link state updates

2023-04-17 Thread Michael S. Tsirkin
And in fact this is v6, isn't it? Similar to v6 but rebased? On Mon, Apr 17, 2023 at 02:03:43PM +0300, Eli Cohen wrote: > Current code ignores link state updates if VIRTIO_NET_F_STATUS was not > negotiated. However, link state updates could be received before feature > negotiation was completed ,

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

2023-04-17 Thread Michael S. Tsirkin
On Mon, Apr 17, 2023 at 10:04:56AM +, Alvaro Karsz wrote: > > > So, what do you think, we should fix virtio-net to work with smaller > > > rings? we should fail probe? > > > > > > I think that since this never came up until now, there is no big demand > > > to such small rings. > > > > The w

Re: [PATCH v5] vdpa/mlx5: Avoid losing link state updates

2023-04-17 Thread Michael S. Tsirkin
On Mon, Apr 17, 2023 at 02:03:43PM +0300, Eli Cohen wrote: > Current code ignores link state updates if VIRTIO_NET_F_STATUS was not > negotiated. However, link state updates could be received before feature > negotiation was completed , therefore causing link state events to be > lost, possibly lea

Re: [PATCH v5] vdpa/mlx5: Avoid losing link state updates

2023-04-17 Thread Michael S. Tsirkin
On Mon, Apr 17, 2023 at 02:03:43PM +0300, Eli Cohen wrote: > Current code ignores link state updates if VIRTIO_NET_F_STATUS was not > negotiated. However, link state updates could be received before feature > negotiation was completed , therefore causing link state events to be > lost, possibly lea

Re: [PATCH v3 6/7] mm/gup: remove vmas parameter from pin_user_pages()

2023-04-17 Thread David Hildenbrand
On 15.04.23 14:09, Lorenzo Stoakes wrote: After the introduction of FOLL_SAME_FILE we no longer require vmas for any invocation of pin_user_pages(), so eliminate this parameter from the function and all callers. This clears the way to removing the vmas parameter from GUP altogether. Signed-off-

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

2023-04-17 Thread Alvaro Karsz
> > So, what do you think, we should fix virtio-net to work with smaller rings? > > we should fail probe? > > > > I think that since this never came up until now, there is no big demand to > > such small rings. > > The worry is that once we start failing probe there's just a tiny chance > hosts

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

2023-04-17 Thread Michael S. Tsirkin
On Mon, Apr 17, 2023 at 07:33:58AM +, Alvaro Karsz wrote: > > > > > > Actually, I think that all you need to do is disable NETIF_F_SG, > > > > > > and things will work, no? > > > > > > > > > > I think that this is not so simple, if I understand correctly, by > > > > > disabling NETIF_F_SG we w

[PATCH] vdpa/snet: implement kick_vq_with_data callback

2023-04-17 Thread Alvaro Karsz
Implement the kick_vq_with_data vDPA callback. On kick, we pass the next available data to the DPU by writing it in the kick offset. Signed-off-by: Alvaro Karsz --- Should be applied on top of: https://lore.kernel.org/virtualization/20230413081855.36643-1-alvaro.ka...@solid-run.com/ drivers/vdp

Re: [PATCH v4 2/2] vdpa/snet: support the suspend vDPA callback

2023-04-17 Thread Jason Wang
On Thu, Apr 13, 2023 at 3:33 PM Alvaro Karsz wrote: > > When suspend is called, the driver sends a suspend command to the DPU > through the control mechanism. > > Signed-off-by: Alvaro Karsz Acked-by: Jason Wang Thanks > --- > drivers/vdpa/solidrun/snet_ctrl.c | 6 ++ > drivers/vdpa/sol

Re: [PATCH v4 1/2] vdpa/snet: support getting and setting VQ state

2023-04-17 Thread Jason Wang
On Thu, Apr 13, 2023 at 3:33 PM Alvaro Karsz wrote: > > This patch adds the get_vq_state and set_vq_state vDPA callbacks. > > In order to get the VQ state, the state needs to be read from the DPU. > In order to allow that, the old messaging mechanism is replaced with a new, > flexible control mech

Re: [PATCH 2/2] virtio-vdpa: add VIRTIO_F_NOTIFICATION_DATA feature support

2023-04-17 Thread Jason Wang
On Thu, Apr 13, 2023 at 4:19 PM Alvaro Karsz wrote: > > Add VIRTIO_F_NOTIFICATION_DATA support for vDPA transport. > If this feature is negotiated, the driver passes extra data when kicking > a virtqueue. > > A device that offers this feature needs to implement the > kick_vq_with_data callback. >

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

2023-04-17 Thread Alvaro Karsz
> > > > > Actually, I think that all you need to do is disable NETIF_F_SG, > > > > > and things will work, no? > > > > > > > > I think that this is not so simple, if I understand correctly, by > > > > disabling NETIF_F_SG we will never receive a chained skbs to transmit, > > > > but we still have

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

2023-04-17 Thread Michael S. Tsirkin
On Mon, Apr 17, 2023 at 07:07:59AM +, Alvaro Karsz wrote: > > Why tx timeout without frags? > > Please see my response to Michael. > > > > * Guest GSO/big MTU (without VIRTIO_NET_F_MRG_RXBUF?), we can't chain > > > page size buffers anymore. > > > > > > Or, we disable the GUEST_GSO, HOST_G

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

2023-04-17 Thread Michael S. Tsirkin
On Mon, Apr 17, 2023 at 07:03:52AM +, Alvaro Karsz wrote: > > > > Actually, I think that all you need to do is disable NETIF_F_SG, > > > > and things will work, no? > > > > > > I think that this is not so simple, if I understand correctly, by > > > disabling NETIF_F_SG we will never receive a

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

2023-04-17 Thread Alvaro Karsz
> Why tx timeout without frags? Please see my response to Michael. > > * Guest GSO/big MTU (without VIRTIO_NET_F_MRG_RXBUF?), we can't chain page > > size buffers anymore. > > > Or, we disable the GUEST_GSO, HOST_GSO.. > And disable VIRTIO_NET_F_MTU, quoting the spec: "A driver SHOULD neg

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

2023-04-17 Thread Alvaro Karsz
> > > Actually, I think that all you need to do is disable NETIF_F_SG, > > > and things will work, no? > > > > I think that this is not so simple, if I understand correctly, by disabling > > NETIF_F_SG we will never receive a chained skbs to transmit, but we still > > have more functionality to a