Re: [PATCH 2/2] virtio-net: ethtool configurable RXCSUM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 28, 2020 at 5:42 AM <xiangxia.m.yue@xxxxxxxxx> wrote:
>
> From: Tonghao Zhang <xiangxia.m.yue@xxxxxxxxx>
>
> 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@xxxxxxxxxx>
> Cc: Jason Wang <jasowang@xxxxxxxxxx>
> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@xxxxxxxxx>
> ---
>  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.
_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization



[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux