Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [RFC PATCH] virtio-net: use NETIF_F_GRO_HW instead of NETIF_F_LRO
@ 2021-08-11  8:16 Jason Wang
  2021-08-11 22:17 ` Jakub Kicinski
  2021-08-12  1:20 ` ivan
  0 siblings, 2 replies; 8+ messages in thread
From: Jason Wang @ 2021-08-11  8:16 UTC (permalink / raw)
  To: mst, jasowang
  Cc: davem, kuba, virtualization, netdev, linux-kernel, ivan,
	xiangxia.m.yue, willemb, edumazet

Commit a02e8964eaf92 ("virtio-net: ethtool configurable LRO") tries to
advertise LRO on behalf of the guest offloading features and allow the
administrator to enable and disable those features via ethtool.

This may lead several issues:

- For the device that doesn't support control guest offloads, the
  "LRO" can't be disabled so we will get a warn in the
  dev_disable_lro()
- For the device that have the control guest offloads, the guest
  offloads were disabled in the case of bridge etc which may slow down
  the traffic.

Try to fix this by using NETIF_F_GRO_HW instead so we're not
guaranteed to be re-segmented as original. Or we may want a new netdev
feature like RX_GSO since the guest offloads for virtio-net is
actually to receive GSO packet.

Or we can try not advertise LRO is control guest offloads is not
enabled. This solves the warning but will still slow down the traffic.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/net/virtio_net.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 0416a7e00914..10c382b08bce 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -63,7 +63,7 @@ static const unsigned long guest_offloads[] = {
 	VIRTIO_NET_F_GUEST_CSUM
 };
 
-#define GUEST_OFFLOAD_LRO_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \
+#define GUEST_OFFLOAD_GRO_HW_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \
 				(1ULL << VIRTIO_NET_F_GUEST_TSO6) | \
 				(1ULL << VIRTIO_NET_F_GUEST_ECN)  | \
 				(1ULL << VIRTIO_NET_F_GUEST_UFO))
@@ -2481,7 +2481,7 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog,
 	        virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_ECN) ||
 		virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_UFO) ||
 		virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_CSUM))) {
-		NL_SET_ERR_MSG_MOD(extack, "Can't set XDP while host is implementing LRO/CSUM, disable LRO/CSUM first");
+		NL_SET_ERR_MSG_MOD(extack, "Can't set XDP while host is implementing GRO_HW/CSUM, disable GRO_HW/CSUM first");
 		return -EOPNOTSUPP;
 	}
 
@@ -2612,15 +2612,15 @@ static int virtnet_set_features(struct net_device *dev,
 	u64 offloads;
 	int err;
 
-	if ((dev->features ^ features) & NETIF_F_LRO) {
+	if ((dev->features ^ features) & NETIF_F_GRO_HW) {
 		if (vi->xdp_enabled)
 			return -EBUSY;
 
-		if (features & NETIF_F_LRO)
+		if (features & NETIF_F_GRO_HW)
 			offloads = vi->guest_offloads_capable;
 		else
 			offloads = vi->guest_offloads_capable &
-				   ~GUEST_OFFLOAD_LRO_MASK;
+				   ~GUEST_OFFLOAD_GRO_HW_MASK;
 
 		err = virtnet_set_guest_offloads(vi, offloads);
 		if (err)
@@ -3100,9 +3100,9 @@ static int virtnet_probe(struct virtio_device *vdev)
 		dev->features |= NETIF_F_RXCSUM;
 	if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
 	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6))
-		dev->features |= NETIF_F_LRO;
+		dev->features |= NETIF_F_GRO_HW;
 	if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS))
-		dev->hw_features |= NETIF_F_LRO;
+		dev->hw_features |= NETIF_F_GRO_HW;
 
 	dev->vlan_features = dev->features;
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH] virtio-net: use NETIF_F_GRO_HW instead of NETIF_F_LRO
  2021-08-11  8:16 [RFC PATCH] virtio-net: use NETIF_F_GRO_HW instead of NETIF_F_LRO Jason Wang
@ 2021-08-11 22:17 ` Jakub Kicinski
  2021-08-12  3:23   ` Jason Wang
  2021-08-12  1:20 ` ivan
  1 sibling, 1 reply; 8+ messages in thread
From: Jakub Kicinski @ 2021-08-11 22:17 UTC (permalink / raw)
  To: Jason Wang
  Cc: mst, davem, virtualization, netdev, linux-kernel, ivan,
	xiangxia.m.yue, willemb, edumazet

On Wed, 11 Aug 2021 16:16:23 +0800 Jason Wang wrote:
> Try to fix this by using NETIF_F_GRO_HW instead so we're not
> guaranteed to be re-segmented as original. 

This sentence may need rephrasing.

> Or we may want a new netdev
> feature like RX_GSO since the guest offloads for virtio-net is
> actually to receive GSO packet.
> 
> Or we can try not advertise LRO is control guest offloads is not
> enabled. This solves the warning but will still slow down the traffic.

IMO gro-hw fits pretty well, patch looks good.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH] virtio-net: use NETIF_F_GRO_HW instead of NETIF_F_LRO
  2021-08-11  8:16 [RFC PATCH] virtio-net: use NETIF_F_GRO_HW instead of NETIF_F_LRO Jason Wang
  2021-08-11 22:17 ` Jakub Kicinski
@ 2021-08-12  1:20 ` ivan
  2021-08-12  4:59   ` Michael S. Tsirkin
  1 sibling, 1 reply; 8+ messages in thread
From: ivan @ 2021-08-12  1:20 UTC (permalink / raw)
  To: Jason Wang
  Cc: Michael S. Tsirkin, David S. Miller, Jakub Kicinski,
	virtualization, netdev, linux-kernel, Tonghao Zhang,
	Willem de Bruijn, Eric Dumazet, Ivan

On Wed, Aug 11, 2021 at 3:16 AM Jason Wang <jasowang@redhat.com> wrote:
>
> Commit a02e8964eaf92 ("virtio-net: ethtool configurable LRO") tries to
> advertise LRO on behalf of the guest offloading features and allow the
> administrator to enable and disable those features via ethtool.
>
> This may lead several issues:
>
> - For the device that doesn't support control guest offloads, the
>   "LRO" can't be disabled so we will get a warn in the
>   dev_disable_lro()
> - For the device that have the control guest offloads, the guest
>   offloads were disabled in the case of bridge etc which may slow down
>   the traffic.
>
> Try to fix this by using NETIF_F_GRO_HW instead so we're not
> guaranteed to be re-segmented as original. Or we may want a new netdev
> feature like RX_GSO since the guest offloads for virtio-net is
> actually to receive GSO packet.
>
> Or we can try not advertise LRO is control guest offloads is not
> enabled. This solves the warning but will still slow down the traffic.
>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
>  drivers/net/virtio_net.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 0416a7e00914..10c382b08bce 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -63,7 +63,7 @@ static const unsigned long guest_offloads[] = {
>         VIRTIO_NET_F_GUEST_CSUM
>  };
>
> -#define GUEST_OFFLOAD_LRO_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \
> +#define GUEST_OFFLOAD_GRO_HW_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \
>                                 (1ULL << VIRTIO_NET_F_GUEST_TSO6) | \
>                                 (1ULL << VIRTIO_NET_F_GUEST_ECN)  | \
>                                 (1ULL << VIRTIO_NET_F_GUEST_UFO))
> @@ -2481,7 +2481,7 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog,
>                 virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_ECN) ||
>                 virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_UFO) ||
>                 virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_CSUM))) {
> -               NL_SET_ERR_MSG_MOD(extack, "Can't set XDP while host is implementing LRO/CSUM, disable LRO/CSUM first");
> +               NL_SET_ERR_MSG_MOD(extack, "Can't set XDP while host is implementing GRO_HW/CSUM, disable GRO_HW/CSUM first");
>                 return -EOPNOTSUPP;
>         }
>
> @@ -2612,15 +2612,15 @@ static int virtnet_set_features(struct net_device *dev,
>         u64 offloads;
>         int err;
>
> -       if ((dev->features ^ features) & NETIF_F_LRO) {
> +       if ((dev->features ^ features) & NETIF_F_GRO_HW) {
>                 if (vi->xdp_enabled)
>                         return -EBUSY;
>
> -               if (features & NETIF_F_LRO)
> +               if (features & NETIF_F_GRO_HW)
>                         offloads = vi->guest_offloads_capable;
>                 else
>                         offloads = vi->guest_offloads_capable &
> -                                  ~GUEST_OFFLOAD_LRO_MASK;
> +                                  ~GUEST_OFFLOAD_GRO_HW_MASK;
>
>                 err = virtnet_set_guest_offloads(vi, offloads);
>                 if (err)
> @@ -3100,9 +3100,9 @@ static int virtnet_probe(struct virtio_device *vdev)
>                 dev->features |= NETIF_F_RXCSUM;
>         if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
>             virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6))
> -               dev->features |= NETIF_F_LRO;
> +               dev->features |= NETIF_F_GRO_HW;
>         if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS))
> -               dev->hw_features |= NETIF_F_LRO;
> +               dev->hw_features |= NETIF_F_GRO_HW;
>
>         dev->vlan_features = dev->features;
>
> --

I applied this patch, recompiled the kernel, and tested it.
The warning messages are gone. Network speed is normal.
I can now enable forwarding, and nothing bad happens.
So far, so good.

Thank you.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH] virtio-net: use NETIF_F_GRO_HW instead of NETIF_F_LRO
  2021-08-11 22:17 ` Jakub Kicinski
@ 2021-08-12  3:23   ` Jason Wang
  2021-08-12  4:50     ` Michael S. Tsirkin
  0 siblings, 1 reply; 8+ messages in thread
From: Jason Wang @ 2021-08-12  3:23 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: mst, davem, virtualization, netdev, linux-kernel, ivan,
	xiangxia.m.yue, willemb, edumazet


在 2021/8/12 上午6:17, Jakub Kicinski 写道:
> On Wed, 11 Aug 2021 16:16:23 +0800 Jason Wang wrote:
>> Try to fix this by using NETIF_F_GRO_HW instead so we're not
>> guaranteed to be re-segmented as original.
> This sentence may need rephrasing.


Right, actually, I meant:


Try to fix this by using NETIF_F_GRO_HW instead. But we're not sure the 
packet could be re-segmented to the exact original packet stream. Since 
it's really depends on the bakcend implementation.


>
>> Or we may want a new netdev
>> feature like RX_GSO since the guest offloads for virtio-net is
>> actually to receive GSO packet.
>>
>> Or we can try not advertise LRO is control guest offloads is not
>> enabled. This solves the warning but will still slow down the traffic.
> IMO gro-hw fits pretty well, patch looks good.


If the re-segmentation is not a issue. I will post a formal patch.

Thanks


>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH] virtio-net: use NETIF_F_GRO_HW instead of NETIF_F_LRO
  2021-08-12  3:23   ` Jason Wang
@ 2021-08-12  4:50     ` Michael S. Tsirkin
  2021-08-12  6:18       ` Jason Wang
  0 siblings, 1 reply; 8+ messages in thread
From: Michael S. Tsirkin @ 2021-08-12  4:50 UTC (permalink / raw)
  To: Jason Wang
  Cc: Jakub Kicinski, davem, virtualization, netdev, linux-kernel,
	ivan, xiangxia.m.yue, willemb, edumazet

On Thu, Aug 12, 2021 at 11:23:04AM +0800, Jason Wang wrote:
> 
> 在 2021/8/12 上午6:17, Jakub Kicinski 写道:
> > On Wed, 11 Aug 2021 16:16:23 +0800 Jason Wang wrote:
> > > Try to fix this by using NETIF_F_GRO_HW instead so we're not
> > > guaranteed to be re-segmented as original.
> > This sentence may need rephrasing.
> 
> 
> Right, actually, I meant:
> 
> 
> Try to fix this by using NETIF_F_GRO_HW instead. But we're not sure the
> packet could be re-segmented to the exact original packet stream. Since it's
> really depends on the bakcend implementation.
> 
> 
> > 
> > > Or we may want a new netdev
> > > feature like RX_GSO since the guest offloads for virtio-net is
> > > actually to receive GSO packet.
> > > 
> > > Or we can try not advertise LRO is control guest offloads is not
> > > enabled. This solves the warning but will still slow down the traffic.
> > IMO gro-hw fits pretty well, patch looks good.
> 
> 
> If the re-segmentation is not a issue. I will post a formal patch.
> 
> Thanks


It is but the point is even though spec did not require this
we always allowed these configurations
in the past so hopefully most of them are not broken and combine
packets in the same way as GRO. Let's not break them all
in an attempt to catch bad configs, and meanwhile amend
the spec to recommend doing GW GRO.

> 
> > 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH] virtio-net: use NETIF_F_GRO_HW instead of NETIF_F_LRO
  2021-08-12  1:20 ` ivan
@ 2021-08-12  4:59   ` Michael S. Tsirkin
  2021-08-12  6:28     ` ivan
  0 siblings, 1 reply; 8+ messages in thread
From: Michael S. Tsirkin @ 2021-08-12  4:59 UTC (permalink / raw)
  To: ivan
  Cc: Jason Wang, David S. Miller, Jakub Kicinski, virtualization,
	netdev, linux-kernel, Tonghao Zhang, Willem de Bruijn,
	Eric Dumazet

On Wed, Aug 11, 2021 at 08:20:03PM -0500, ivan wrote:
> On Wed, Aug 11, 2021 at 3:16 AM Jason Wang <jasowang@redhat.com> wrote:
> >
> > Commit a02e8964eaf92 ("virtio-net: ethtool configurable LRO") tries to
> > advertise LRO on behalf of the guest offloading features and allow the
> > administrator to enable and disable those features via ethtool.
> >
> > This may lead several issues:
> >
> > - For the device that doesn't support control guest offloads, the
> >   "LRO" can't be disabled so we will get a warn in the
> >   dev_disable_lro()
> > - For the device that have the control guest offloads, the guest
> >   offloads were disabled in the case of bridge etc which may slow down
> >   the traffic.
> >
> > Try to fix this by using NETIF_F_GRO_HW instead so we're not
> > guaranteed to be re-segmented as original. Or we may want a new netdev
> > feature like RX_GSO since the guest offloads for virtio-net is
> > actually to receive GSO packet.
> >
> > Or we can try not advertise LRO is control guest offloads is not
> > enabled. This solves the warning but will still slow down the traffic.
> >
> > Signed-off-by: Jason Wang <jasowang@redhat.com>
> > ---
> >  drivers/net/virtio_net.c | 14 +++++++-------
> >  1 file changed, 7 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > index 0416a7e00914..10c382b08bce 100644
> > --- a/drivers/net/virtio_net.c
> > +++ b/drivers/net/virtio_net.c
> > @@ -63,7 +63,7 @@ static const unsigned long guest_offloads[] = {
> >         VIRTIO_NET_F_GUEST_CSUM
> >  };
> >
> > -#define GUEST_OFFLOAD_LRO_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \
> > +#define GUEST_OFFLOAD_GRO_HW_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \
> >                                 (1ULL << VIRTIO_NET_F_GUEST_TSO6) | \
> >                                 (1ULL << VIRTIO_NET_F_GUEST_ECN)  | \
> >                                 (1ULL << VIRTIO_NET_F_GUEST_UFO))
> > @@ -2481,7 +2481,7 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog,
> >                 virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_ECN) ||
> >                 virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_UFO) ||
> >                 virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_CSUM))) {
> > -               NL_SET_ERR_MSG_MOD(extack, "Can't set XDP while host is implementing LRO/CSUM, disable LRO/CSUM first");
> > +               NL_SET_ERR_MSG_MOD(extack, "Can't set XDP while host is implementing GRO_HW/CSUM, disable GRO_HW/CSUM first");
> >                 return -EOPNOTSUPP;
> >         }
> >
> > @@ -2612,15 +2612,15 @@ static int virtnet_set_features(struct net_device *dev,
> >         u64 offloads;
> >         int err;
> >
> > -       if ((dev->features ^ features) & NETIF_F_LRO) {
> > +       if ((dev->features ^ features) & NETIF_F_GRO_HW) {
> >                 if (vi->xdp_enabled)
> >                         return -EBUSY;
> >
> > -               if (features & NETIF_F_LRO)
> > +               if (features & NETIF_F_GRO_HW)
> >                         offloads = vi->guest_offloads_capable;
> >                 else
> >                         offloads = vi->guest_offloads_capable &
> > -                                  ~GUEST_OFFLOAD_LRO_MASK;
> > +                                  ~GUEST_OFFLOAD_GRO_HW_MASK;
> >
> >                 err = virtnet_set_guest_offloads(vi, offloads);
> >                 if (err)
> > @@ -3100,9 +3100,9 @@ static int virtnet_probe(struct virtio_device *vdev)
> >                 dev->features |= NETIF_F_RXCSUM;
> >         if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
> >             virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6))
> > -               dev->features |= NETIF_F_LRO;
> > +               dev->features |= NETIF_F_GRO_HW;
> >         if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS))
> > -               dev->hw_features |= NETIF_F_LRO;
> > +               dev->hw_features |= NETIF_F_GRO_HW;
> >
> >         dev->vlan_features = dev->features;
> >
> > --
> 
> I applied this patch, recompiled the kernel, and tested it.
> The warning messages are gone. Network speed is normal.
> I can now enable forwarding, and nothing bad happens.
> So far, so good.
> 
> Thank you.

OK so that's

Tested-by: ivan <ivan@prestigetransportation.com>

It is still weird that without the patch networking dies.

What happens if you apply the patch then try to disable GRO
using ethtool?

-- 
MST


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH] virtio-net: use NETIF_F_GRO_HW instead of NETIF_F_LRO
  2021-08-12  4:50     ` Michael S. Tsirkin
@ 2021-08-12  6:18       ` Jason Wang
  0 siblings, 0 replies; 8+ messages in thread
From: Jason Wang @ 2021-08-12  6:18 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Jakub Kicinski, davem, virtualization, netdev, linux-kernel,
	ivan, xiangxia.m.yue, willemb, edumazet


在 2021/8/12 下午12:50, Michael S. Tsirkin 写道:
> On Thu, Aug 12, 2021 at 11:23:04AM +0800, Jason Wang wrote:
>> 在 2021/8/12 上午6:17, Jakub Kicinski 写道:
>>> On Wed, 11 Aug 2021 16:16:23 +0800 Jason Wang wrote:
>>>> Try to fix this by using NETIF_F_GRO_HW instead so we're not
>>>> guaranteed to be re-segmented as original.
>>> This sentence may need rephrasing.
>>
>> Right, actually, I meant:
>>
>>
>> Try to fix this by using NETIF_F_GRO_HW instead. But we're not sure the
>> packet could be re-segmented to the exact original packet stream. Since it's
>> really depends on the bakcend implementation.
>>
>>
>>>> Or we may want a new netdev
>>>> feature like RX_GSO since the guest offloads for virtio-net is
>>>> actually to receive GSO packet.
>>>>
>>>> Or we can try not advertise LRO is control guest offloads is not
>>>> enabled. This solves the warning but will still slow down the traffic.
>>> IMO gro-hw fits pretty well, patch looks good.
>>
>> If the re-segmentation is not a issue. I will post a formal patch.
>>
>> Thanks
>
> It is but the point is even though spec did not require this
> we always allowed these configurations
> in the past so hopefully most of them are not broken and combine
> packets in the same way as GRO. Let's not break them all
> in an attempt to catch bad configs, and meanwhile amend
> the spec to recommend doing GW GRO.


Ok, let me add this in the commit log and send a formal patch.

Thanks


>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH] virtio-net: use NETIF_F_GRO_HW instead of NETIF_F_LRO
  2021-08-12  4:59   ` Michael S. Tsirkin
@ 2021-08-12  6:28     ` ivan
  0 siblings, 0 replies; 8+ messages in thread
From: ivan @ 2021-08-12  6:28 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Jason Wang, David S. Miller, Jakub Kicinski, virtualization,
	netdev, linux-kernel, Tonghao Zhang, Willem de Bruijn,
	Eric Dumazet, Ivan

On Thu, Aug 12, 2021 at 12:00 AM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Wed, Aug 11, 2021 at 08:20:03PM -0500, ivan wrote:
> > On Wed, Aug 11, 2021 at 3:16 AM Jason Wang <jasowang@redhat.com> wrote:
> > >
> > > Commit a02e8964eaf92 ("virtio-net: ethtool configurable LRO") tries to
> > > advertise LRO on behalf of the guest offloading features and allow the
> > > administrator to enable and disable those features via ethtool.
> > >
> > > This may lead several issues:
> > >
> > > - For the device that doesn't support control guest offloads, the
> > >   "LRO" can't be disabled so we will get a warn in the
> > >   dev_disable_lro()
> > > - For the device that have the control guest offloads, the guest
> > >   offloads were disabled in the case of bridge etc which may slow down
> > >   the traffic.
> > >
> > > Try to fix this by using NETIF_F_GRO_HW instead so we're not
> > > guaranteed to be re-segmented as original. Or we may want a new netdev
> > > feature like RX_GSO since the guest offloads for virtio-net is
> > > actually to receive GSO packet.
> > >
> > > Or we can try not advertise LRO is control guest offloads is not
> > > enabled. This solves the warning but will still slow down the traffic.
> > >
> > > Signed-off-by: Jason Wang <jasowang@redhat.com>
> > > ---
> > >  drivers/net/virtio_net.c | 14 +++++++-------
> > >  1 file changed, 7 insertions(+), 7 deletions(-)
> > >
> > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > > index 0416a7e00914..10c382b08bce 100644
> > > --- a/drivers/net/virtio_net.c
> > > +++ b/drivers/net/virtio_net.c
> > > @@ -63,7 +63,7 @@ static const unsigned long guest_offloads[] = {
> > >         VIRTIO_NET_F_GUEST_CSUM
> > >  };
> > >
> > > -#define GUEST_OFFLOAD_LRO_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \
> > > +#define GUEST_OFFLOAD_GRO_HW_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \
> > >                                 (1ULL << VIRTIO_NET_F_GUEST_TSO6) | \
> > >                                 (1ULL << VIRTIO_NET_F_GUEST_ECN)  | \
> > >                                 (1ULL << VIRTIO_NET_F_GUEST_UFO))
> > > @@ -2481,7 +2481,7 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog,
> > >                 virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_ECN) ||
> > >                 virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_UFO) ||
> > >                 virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_CSUM))) {
> > > -               NL_SET_ERR_MSG_MOD(extack, "Can't set XDP while host is implementing LRO/CSUM, disable LRO/CSUM first");
> > > +               NL_SET_ERR_MSG_MOD(extack, "Can't set XDP while host is implementing GRO_HW/CSUM, disable GRO_HW/CSUM first");
> > >                 return -EOPNOTSUPP;
> > >         }
> > >
> > > @@ -2612,15 +2612,15 @@ static int virtnet_set_features(struct net_device *dev,
> > >         u64 offloads;
> > >         int err;
> > >
> > > -       if ((dev->features ^ features) & NETIF_F_LRO) {
> > > +       if ((dev->features ^ features) & NETIF_F_GRO_HW) {
> > >                 if (vi->xdp_enabled)
> > >                         return -EBUSY;
> > >
> > > -               if (features & NETIF_F_LRO)
> > > +               if (features & NETIF_F_GRO_HW)
> > >                         offloads = vi->guest_offloads_capable;
> > >                 else
> > >                         offloads = vi->guest_offloads_capable &
> > > -                                  ~GUEST_OFFLOAD_LRO_MASK;
> > > +                                  ~GUEST_OFFLOAD_GRO_HW_MASK;
> > >
> > >                 err = virtnet_set_guest_offloads(vi, offloads);
> > >                 if (err)
> > > @@ -3100,9 +3100,9 @@ static int virtnet_probe(struct virtio_device *vdev)
> > >                 dev->features |= NETIF_F_RXCSUM;
> > >         if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
> > >             virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6))
> > > -               dev->features |= NETIF_F_LRO;
> > > +               dev->features |= NETIF_F_GRO_HW;
> > >         if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS))
> > > -               dev->hw_features |= NETIF_F_LRO;
> > > +               dev->hw_features |= NETIF_F_GRO_HW;
> > >
> > >         dev->vlan_features = dev->features;
> > >
> > > --
> >
> > I applied this patch, recompiled the kernel, and tested it.
> > The warning messages are gone. Network speed is normal.
> > I can now enable forwarding, and nothing bad happens.
> > So far, so good.
> >
> > Thank you.
>
> OK so that's
>
> Tested-by: ivan <ivan@prestigetransportation.com>
>
> It is still weird that without the patch networking dies.
>
> What happens if you apply the patch then try to disable GRO
> using ethtool?
Nothing bad.  Ethtool shows successful change to off.
Makes no differrece on the iperf tests.  Still good.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-08-12  6:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-11  8:16 [RFC PATCH] virtio-net: use NETIF_F_GRO_HW instead of NETIF_F_LRO Jason Wang
2021-08-11 22:17 ` Jakub Kicinski
2021-08-12  3:23   ` Jason Wang
2021-08-12  4:50     ` Michael S. Tsirkin
2021-08-12  6:18       ` Jason Wang
2021-08-12  1:20 ` ivan
2021-08-12  4:59   ` Michael S. Tsirkin
2021-08-12  6:28     ` ivan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).