From: Gavin Li Date: Wed, 14 Sep 2022 14:49:10 +0000 (+0300) Subject: virtio-net: introduce and use helper function for guest gso support checks X-Git-Tag: v6.1-rc5~221^2~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=46cd26f4108714d2e28c93d773e1602917ac0691;p=platform%2Fkernel%2Flinux-starfive.git virtio-net: introduce and use helper function for guest gso support checks Probe routine is already several hundred lines. Use helper function for guest gso support check. Signed-off-by: Gavin Li Reviewed-by: Gavi Teitz Reviewed-by: Parav Pandit Reviewed-by: Xuan Zhuo Reviewed-by: Si-Wei Liu Message-Id: <20220914144911.56422-2-gavinl@nvidia.com> Signed-off-by: Michael S. Tsirkin --- diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 9cce7de..f831a02 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -3682,6 +3682,14 @@ static int virtnet_validate(struct virtio_device *vdev) return 0; } +static bool virtnet_check_guest_gso(const struct virtnet_info *vi) +{ + return virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO4) || + virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO6) || + virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_ECN) || + virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_UFO); +} + static int virtnet_probe(struct virtio_device *vdev) { int i, err = -ENOMEM; @@ -3777,10 +3785,7 @@ static int virtnet_probe(struct virtio_device *vdev) spin_lock_init(&vi->refill_lock); /* If we can receive ANY GSO packets, we must allocate large ones. */ - if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) || - virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6) || - virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN) || - virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_UFO)) + if (virtnet_check_guest_gso(vi)) vi->big_packets = true; if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF))