Skip to content

Commit 46cd26f

Browse files
GavinLi-NVmstsirkin
authored andcommitted
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 <gavinl@nvidia.com> Reviewed-by: Gavi Teitz <gavi@nvidia.com> Reviewed-by: Parav Pandit <parav@nvidia.com> Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Reviewed-by: Si-Wei Liu <si-wei.liu@oracle.com> Message-Id: <20220914144911.56422-2-gavinl@nvidia.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent cdbd952 commit 46cd26f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

drivers/net/virtio_net.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3682,6 +3682,14 @@ static int virtnet_validate(struct virtio_device *vdev)
36823682
return 0;
36833683
}
36843684

3685+
static bool virtnet_check_guest_gso(const struct virtnet_info *vi)
3686+
{
3687+
return virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO4) ||
3688+
virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO6) ||
3689+
virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_ECN) ||
3690+
virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_UFO);
3691+
}
3692+
36853693
static int virtnet_probe(struct virtio_device *vdev)
36863694
{
36873695
int i, err = -ENOMEM;
@@ -3777,10 +3785,7 @@ static int virtnet_probe(struct virtio_device *vdev)
37773785
spin_lock_init(&vi->refill_lock);
37783786

37793787
/* If we can receive ANY GSO packets, we must allocate large ones. */
3780-
if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
3781-
virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6) ||
3782-
virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN) ||
3783-
virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_UFO))
3788+
if (virtnet_check_guest_gso(vi))
37843789
vi->big_packets = true;
37853790

37863791
if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF))

0 commit comments

Comments
 (0)