xiangxia.m.yue at gmail.com
2020-Sep-28 03:39 UTC
[PATCH 1/2] virtio-net: don't disable guest csum when disable LRO
From: Tonghao Zhang <xiangxia.m.yue at gmail.com> Open vSwitch and Linux bridge will disable LRO of the interface when this interface added to them. Now when disable the LRO, the virtio-net csum is disable too. That drops the forwarding performance. Fixes: e59ff2c49ae1 ("virtio-net: disable guest csum during XDP set") Cc: Michael S. Tsirkin <mst at redhat.com> Cc: Jason Wang <jasowang at redhat.com> Cc: Willem de Bruijn <willemb at google.com> Signed-off-by: Tonghao Zhang <xiangxia.m.yue at gmail.com> --- drivers/net/virtio_net.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 7145c83c6c8c..21b71148c532 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -63,6 +63,11 @@ static const unsigned long guest_offloads[] = { VIRTIO_NET_F_GUEST_CSUM }; +#define GUEST_OFFLOAD_LRO_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)) + struct virtnet_stat_desc { char desc[ETH_GSTRING_LEN]; size_t offset; @@ -2531,7 +2536,8 @@ static int virtnet_set_features(struct net_device *dev, if (features & NETIF_F_LRO) offloads = vi->guest_offloads_capable; else - offloads = 0; + offloads = vi->guest_offloads_capable & + ~GUEST_OFFLOAD_LRO_MASK; err = virtnet_set_guest_offloads(vi, offloads); if (err) -- 2.23.0
xiangxia.m.yue at gmail.com
2020-Sep-28 03:39 UTC
[PATCH 2/2] virtio-net: ethtool configurable RXCSUM
From: Tonghao Zhang <xiangxia.m.yue at gmail.com> Allow user configuring RXCSUM separately with ethtool -K, reusing the existing virtnet_set_guest_offloads helper that configures RXCSUM for XDP. This is conditional on VIRTIO_NET_F_CTRL_GUEST_OFFLOADS. Cc: Michael S. Tsirkin <mst at redhat.com> Cc: Jason Wang <jasowang at redhat.com> Signed-off-by: Tonghao Zhang <xiangxia.m.yue at gmail.com> --- drivers/net/virtio_net.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 21b71148c532..2e3af0b2c281 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -68,6 +68,8 @@ static const unsigned long guest_offloads[] = { (1ULL << VIRTIO_NET_F_GUEST_ECN) | \ (1ULL << VIRTIO_NET_F_GUEST_UFO)) +#define GUEST_OFFLOAD_CSUM_MASK (1ULL << VIRTIO_NET_F_GUEST_CSUM) + struct virtnet_stat_desc { char desc[ETH_GSTRING_LEN]; size_t offset; @@ -2526,25 +2528,37 @@ static int virtnet_set_features(struct net_device *dev, netdev_features_t features) { struct virtnet_info *vi = netdev_priv(dev); - u64 offloads; + u64 offloads = vi->guest_offloads & + vi->guest_offloads_capable; int err; - if ((dev->features ^ features) & NETIF_F_LRO) { - if (vi->xdp_queue_pairs) - return -EBUSY; + /* Don't allow configuration while XDP is active. */ + if (vi->xdp_queue_pairs) + return -EBUSY; + if ((dev->features ^ features) & NETIF_F_LRO) { if (features & NETIF_F_LRO) - offloads = vi->guest_offloads_capable; + offloads |= GUEST_OFFLOAD_LRO_MASK; else - offloads = vi->guest_offloads_capable & - ~GUEST_OFFLOAD_LRO_MASK; + offloads &= ~GUEST_OFFLOAD_LRO_MASK; + } - err = virtnet_set_guest_offloads(vi, offloads); - if (err) - return err; - vi->guest_offloads = offloads; + if ((dev->features ^ features) & NETIF_F_RXCSUM) { + if (features & NETIF_F_RXCSUM) + offloads |= GUEST_OFFLOAD_CSUM_MASK; + else + offloads &= ~GUEST_OFFLOAD_CSUM_MASK; } + if (offloads == (vi->guest_offloads & + vi->guest_offloads_capable)) + return 0; + + err = virtnet_set_guest_offloads(vi, offloads); + if (err) + return err; + + vi->guest_offloads = offloads; return 0; } @@ -3013,8 +3027,10 @@ static int virtnet_probe(struct virtio_device *vdev) if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) || virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6)) dev->features |= NETIF_F_LRO; - if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) + if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) { + dev->hw_features |= NETIF_F_RXCSUM; dev->hw_features |= NETIF_F_LRO; + } dev->vlan_features = dev->features; -- 2.23.0
Willem de Bruijn
2020-Sep-28 08:34 UTC
[PATCH 1/2] virtio-net: don't disable guest csum when disable LRO
On Mon, Sep 28, 2020 at 5:41 AM <xiangxia.m.yue at gmail.com> wrote:> > From: Tonghao Zhang <xiangxia.m.yue at gmail.com> > > Open vSwitch and Linux bridge will disable LRO of the interface > when this interface added to them. Now when disable the LRO, the > virtio-net csum is disable too. That drops the forwarding performance. > > Fixes: e59ff2c49ae1 ("virtio-net: disable guest csum during XDP set")Patch looks fine to me, but wrong commit here? That commit disables csum on purpose when enabling xdp with ndp_bpf. This patch refines disabling LRO with ndo_set_features. The relevant commit is a02e8964eaf9 ("virtio-net: ethtool configurable LRO"). If this is a fix, it should target [PATCH net] separately from the second patch in the patchset, which is a new feature and targets [PATCH net-next]. They can arguably target net-next together, but then it should not have a fixes tag.> Cc: Michael S. Tsirkin <mst at redhat.com> > Cc: Jason Wang <jasowang at redhat.com> > Cc: Willem de Bruijn <willemb at google.com> > Signed-off-by: Tonghao Zhang <xiangxia.m.yue at gmail.com> > --- > drivers/net/virtio_net.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index 7145c83c6c8c..21b71148c532 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -63,6 +63,11 @@ static const unsigned long guest_offloads[] = { > VIRTIO_NET_F_GUEST_CSUM > }; > > +#define GUEST_OFFLOAD_LRO_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)) > + > struct virtnet_stat_desc { > char desc[ETH_GSTRING_LEN]; > size_t offset; > @@ -2531,7 +2536,8 @@ static int virtnet_set_features(struct net_device *dev, > if (features & NETIF_F_LRO) > offloads = vi->guest_offloads_capable; > else > - offloads = 0; > + offloads = vi->guest_offloads_capable & > + ~GUEST_OFFLOAD_LRO_MASK; > > err = virtnet_set_guest_offloads(vi, offloads); > if (err) > -- > 2.23.0 >
Willem de Bruijn
2020-Sep-28 08:38 UTC
[PATCH 2/2] virtio-net: ethtool configurable RXCSUM
On Mon, Sep 28, 2020 at 5:42 AM <xiangxia.m.yue at gmail.com> wrote:> > From: Tonghao Zhang <xiangxia.m.yue at gmail.com> > > Allow user configuring RXCSUM separately with ethtool -K, > reusing the existing virtnet_set_guest_offloads helper > that configures RXCSUM for XDP. This is conditional on > VIRTIO_NET_F_CTRL_GUEST_OFFLOADS. > > Cc: Michael S. Tsirkin <mst at redhat.com> > Cc: Jason Wang <jasowang at redhat.com> > Signed-off-by: Tonghao Zhang <xiangxia.m.yue at gmail.com> > --- > drivers/net/virtio_net.c | 40 ++++++++++++++++++++++++++++------------ > 1 file changed, 28 insertions(+), 12 deletions(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index 21b71148c532..2e3af0b2c281 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -68,6 +68,8 @@ static const unsigned long guest_offloads[] = { > (1ULL << VIRTIO_NET_F_GUEST_ECN) | \ > (1ULL << VIRTIO_NET_F_GUEST_UFO)) > > +#define GUEST_OFFLOAD_CSUM_MASK (1ULL << VIRTIO_NET_F_GUEST_CSUM) > + > struct virtnet_stat_desc { > char desc[ETH_GSTRING_LEN]; > size_t offset; > @@ -2526,25 +2528,37 @@ static int virtnet_set_features(struct net_device *dev, > netdev_features_t features) > { > struct virtnet_info *vi = netdev_priv(dev); > - u64 offloads; > + u64 offloads = vi->guest_offloads & > + vi->guest_offloads_capable; > int err; > > - if ((dev->features ^ features) & NETIF_F_LRO) { > - if (vi->xdp_queue_pairs) > - return -EBUSY; > + /* Don't allow configuration while XDP is active. */ > + if (vi->xdp_queue_pairs) > + return -EBUSY; > > + if ((dev->features ^ features) & NETIF_F_LRO) { > if (features & NETIF_F_LRO) > - offloads = vi->guest_offloads_capable; > + offloads |= GUEST_OFFLOAD_LRO_MASK; > else > - offloads = vi->guest_offloads_capable & > - ~GUEST_OFFLOAD_LRO_MASK; > + offloads &= ~GUEST_OFFLOAD_LRO_MASK; > + } > > - err = virtnet_set_guest_offloads(vi, offloads); > - if (err) > - return err; > - vi->guest_offloads = offloads; > + if ((dev->features ^ features) & NETIF_F_RXCSUM) { > + if (features & NETIF_F_RXCSUM) > + offloads |= GUEST_OFFLOAD_CSUM_MASK; > + else > + offloads &= ~GUEST_OFFLOAD_CSUM_MASK; > }LRO requires receive checksum offload: packets must have their checksum verified prior to coalescing. The two features can thus not be configured fully independently.
Tonghao Zhang
2020-Sep-28 09:21 UTC
[PATCH 1/2] virtio-net: don't disable guest csum when disable LRO
On Mon, Sep 28, 2020 at 4:35 PM Willem de Bruijn <willemdebruijn.kernel at gmail.com> wrote:> > On Mon, Sep 28, 2020 at 5:41 AM <xiangxia.m.yue at gmail.com> wrote: > > > > From: Tonghao Zhang <xiangxia.m.yue at gmail.com> > > > > Open vSwitch and Linux bridge will disable LRO of the interface > > when this interface added to them. Now when disable the LRO, the > > virtio-net csum is disable too. That drops the forwarding performance. > > > > Fixes: e59ff2c49ae1 ("virtio-net: disable guest csum during XDP set") > > Patch looks fine to me, but wrong commit here?Yes, I will change the tag.> That commit disables csum on purpose when enabling xdp with ndp_bpf. > > This patch refines disabling LRO with ndo_set_features. > > The relevant commit is a02e8964eaf9 ("virtio-net: ethtool configurable LRO"). > > If this is a fix, it should target [PATCH net] separately from the > second patch in the patchset, which is a new feature and targets > [PATCH net-next]. They can arguably target net-next together, but then > it should not have a fixes tag.Thanks, I will send first patch for net, and next one to net-next.> > > Cc: Michael S. Tsirkin <mst at redhat.com> > > Cc: Jason Wang <jasowang at redhat.com> > > Cc: Willem de Bruijn <willemb at google.com> > > Signed-off-by: Tonghao Zhang <xiangxia.m.yue at gmail.com> > > --- > > drivers/net/virtio_net.c | 8 +++++++- > > 1 file changed, 7 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > > index 7145c83c6c8c..21b71148c532 100644 > > --- a/drivers/net/virtio_net.c > > +++ b/drivers/net/virtio_net.c > > @@ -63,6 +63,11 @@ static const unsigned long guest_offloads[] = { > > VIRTIO_NET_F_GUEST_CSUM > > }; > > > > +#define GUEST_OFFLOAD_LRO_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)) > > + > > struct virtnet_stat_desc { > > char desc[ETH_GSTRING_LEN]; > > size_t offset; > > @@ -2531,7 +2536,8 @@ static int virtnet_set_features(struct net_device *dev, > > if (features & NETIF_F_LRO) > > offloads = vi->guest_offloads_capable; > > else > > - offloads = 0; > > + offloads = vi->guest_offloads_capable & > > + ~GUEST_OFFLOAD_LRO_MASK; > > > > err = virtnet_set_guest_offloads(vi, offloads); > > if (err) > > -- > > 2.23.0 > >-- Best regards, Tonghao
Michael S. Tsirkin
2020-Sep-28 19:21 UTC
[PATCH 1/2] virtio-net: don't disable guest csum when disable LRO
On Mon, Sep 28, 2020 at 11:39:14AM +0800, xiangxia.m.yue at gmail.com wrote:> From: Tonghao Zhang <xiangxia.m.yue at gmail.com> > > Open vSwitch and Linux bridge will disable LRO of the interface > when this interface added to them. Now when disable the LRO, the > virtio-net csum is disable too. That drops the forwarding performance. > > Fixes: e59ff2c49ae1 ("virtio-net: disable guest csum during XDP set")I am a bit confused by this tag. Did this change bring about disabling checksum when LRO is disabled? I am not sure I follow how ...> Cc: Michael S. Tsirkin <mst at redhat.com> > Cc: Jason Wang <jasowang at redhat.com> > Cc: Willem de Bruijn <willemb at google.com> > Signed-off-by: Tonghao Zhang <xiangxia.m.yue at gmail.com> > --- > drivers/net/virtio_net.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index 7145c83c6c8c..21b71148c532 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -63,6 +63,11 @@ static const unsigned long guest_offloads[] = { > VIRTIO_NET_F_GUEST_CSUM > }; > > +#define GUEST_OFFLOAD_LRO_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)) > + > struct virtnet_stat_desc { > char desc[ETH_GSTRING_LEN]; > size_t offset; > @@ -2531,7 +2536,8 @@ static int virtnet_set_features(struct net_device *dev, > if (features & NETIF_F_LRO) > offloads = vi->guest_offloads_capable; > else > - offloads = 0; > + offloads = vi->guest_offloads_capable & > + ~GUEST_OFFLOAD_LRO_MASK; > > err = virtnet_set_guest_offloads(vi, offloads); > if (err) > -- > 2.23.0
Michael S. Tsirkin
2020-Sep-28 19:25 UTC
[PATCH 2/2] virtio-net: ethtool configurable RXCSUM
On Mon, Sep 28, 2020 at 11:39:15AM +0800, xiangxia.m.yue at gmail.com wrote:> From: Tonghao Zhang <xiangxia.m.yue at gmail.com> > > Allow user configuring RXCSUM separately with ethtool -K, > reusing the existing virtnet_set_guest_offloads helper > that configures RXCSUM for XDP. This is conditional on > VIRTIO_NET_F_CTRL_GUEST_OFFLOADS. > > Cc: Michael S. Tsirkin <mst at redhat.com> > Cc: Jason Wang <jasowang at redhat.com> > Signed-off-by: Tonghao Zhang <xiangxia.m.yue at gmail.com> > --- > drivers/net/virtio_net.c | 40 ++++++++++++++++++++++++++++------------ > 1 file changed, 28 insertions(+), 12 deletions(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index 21b71148c532..2e3af0b2c281 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -68,6 +68,8 @@ static const unsigned long guest_offloads[] = { > (1ULL << VIRTIO_NET_F_GUEST_ECN) | \ > (1ULL << VIRTIO_NET_F_GUEST_UFO)) > > +#define GUEST_OFFLOAD_CSUM_MASK (1ULL << VIRTIO_NET_F_GUEST_CSUM) > + > struct virtnet_stat_desc { > char desc[ETH_GSTRING_LEN]; > size_t offset; > @@ -2526,25 +2528,37 @@ static int virtnet_set_features(struct net_device *dev, > netdev_features_t features) > { > struct virtnet_info *vi = netdev_priv(dev); > - u64 offloads; > + u64 offloads = vi->guest_offloads & > + vi->guest_offloads_capable; > int err; > > - if ((dev->features ^ features) & NETIF_F_LRO) { > - if (vi->xdp_queue_pairs) > - return -EBUSY; > + /* Don't allow configuration while XDP is active. */ > + if (vi->xdp_queue_pairs) > + return -EBUSY; > > + if ((dev->features ^ features) & NETIF_F_LRO) { > if (features & NETIF_F_LRO) > - offloads = vi->guest_offloads_capable; > + offloads |= GUEST_OFFLOAD_LRO_MASK; > else > - offloads = vi->guest_offloads_capable & > - ~GUEST_OFFLOAD_LRO_MASK; > + offloads &= ~GUEST_OFFLOAD_LRO_MASK; > + } > > - err = virtnet_set_guest_offloads(vi, offloads); > - if (err) > - return err; > - vi->guest_offloads = offloads; > + if ((dev->features ^ features) & NETIF_F_RXCSUM) { > + if (features & NETIF_F_RXCSUM) > + offloads |= GUEST_OFFLOAD_CSUM_MASK; > + else > + offloads &= ~GUEST_OFFLOAD_CSUM_MASK; > } > > + if (offloads == (vi->guest_offloads & > + vi->guest_offloads_capable)) > + return 0;Hmm, what exactly does this do?> + > + err = virtnet_set_guest_offloads(vi, offloads); > + if (err) > + return err; > + > + vi->guest_offloads = offloads; > return 0; > } > > @@ -3013,8 +3027,10 @@ static int virtnet_probe(struct virtio_device *vdev) > if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) || > virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6)) > dev->features |= NETIF_F_LRO; > - if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) > + if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) { > + dev->hw_features |= NETIF_F_RXCSUM; > dev->hw_features |= NETIF_F_LRO; > + } > > dev->vlan_features = dev->features; > > -- > 2.23.0
Tonghao Zhang
2020-Sep-29 01:40 UTC
[PATCH 1/2] virtio-net: don't disable guest csum when disable LRO
On Tue, Sep 29, 2020 at 3:21 AM Michael S. Tsirkin <mst at redhat.com> wrote:> > On Mon, Sep 28, 2020 at 11:39:14AM +0800, xiangxia.m.yue at gmail.com wrote: > > From: Tonghao Zhang <xiangxia.m.yue at gmail.com> > > > > Open vSwitch and Linux bridge will disable LRO of the interface > > when this interface added to them. Now when disable the LRO, the > > virtio-net csum is disable too. That drops the forwarding performance. > > > > Fixes: e59ff2c49ae1 ("virtio-net: disable guest csum during XDP set") > > I am a bit confused by this tag. Did this change bring about > disabling checksum when LRO is disabled? I am not sure > I follow how ...Hi Michael It's not right fix tag. The commit a02e8964eaf9 ("virtio-net: ethtool configurable LRO"), disable the csum, when we disable the LRO> > Cc: Michael S. Tsirkin <mst at redhat.com> > > Cc: Jason Wang <jasowang at redhat.com> > > Cc: Willem de Bruijn <willemb at google.com> > > Signed-off-by: Tonghao Zhang <xiangxia.m.yue at gmail.com> > > --- > > drivers/net/virtio_net.c | 8 +++++++- > > 1 file changed, 7 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > > index 7145c83c6c8c..21b71148c532 100644 > > --- a/drivers/net/virtio_net.c > > +++ b/drivers/net/virtio_net.c > > @@ -63,6 +63,11 @@ static const unsigned long guest_offloads[] = { > > VIRTIO_NET_F_GUEST_CSUM > > }; > > > > +#define GUEST_OFFLOAD_LRO_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)) > > + > > struct virtnet_stat_desc { > > char desc[ETH_GSTRING_LEN]; > > size_t offset; > > @@ -2531,7 +2536,8 @@ static int virtnet_set_features(struct net_device *dev, > > if (features & NETIF_F_LRO) > > offloads = vi->guest_offloads_capable; > > else > > - offloads = 0; > > + offloads = vi->guest_offloads_capable & > > + ~GUEST_OFFLOAD_LRO_MASK; > > > > err = virtnet_set_guest_offloads(vi, offloads); > > if (err) > > -- > > 2.23.0 >-- Best regards, Tonghao
Maybe Matching Threads
- [PATCH 1/2] virtio-net: don't disable guest csum when disable LRO
- [PATCH 2/2] virtio-net: ethtool configurable RXCSUM
- [PATCH 2/2] virtio-net: ethtool configurable RXCSUM
- [PATCH 2/2] virtio-net: ethtool configurable RXCSUM
- [PATCH 2/2] virtio-net: ethtool configurable RXCSUM