提交 46cd26f4 编写于 作者: G Gavin Li 提交者: Michael S. Tsirkin

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: NGavin Li <gavinl@nvidia.com>
Reviewed-by: NGavi Teitz <gavi@nvidia.com>
Reviewed-by: NParav Pandit <parav@nvidia.com>
Reviewed-by: NXuan Zhuo <xuanzhuo@linux.alibaba.com>
Reviewed-by: NSi-Wei Liu <si-wei.liu@oracle.com>
Message-Id: <20220914144911.56422-2-gavinl@nvidia.com>
Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
上级 cdbd952b
...@@ -3682,6 +3682,14 @@ static int virtnet_validate(struct virtio_device *vdev) ...@@ -3682,6 +3682,14 @@ static int virtnet_validate(struct virtio_device *vdev)
return 0; 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) static int virtnet_probe(struct virtio_device *vdev)
{ {
int i, err = -ENOMEM; int i, err = -ENOMEM;
...@@ -3777,10 +3785,7 @@ static int virtnet_probe(struct virtio_device *vdev) ...@@ -3777,10 +3785,7 @@ static int virtnet_probe(struct virtio_device *vdev)
spin_lock_init(&vi->refill_lock); spin_lock_init(&vi->refill_lock);
/* If we can receive ANY GSO packets, we must allocate large ones. */ /* If we can receive ANY GSO packets, we must allocate large ones. */
if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) || if (virtnet_check_guest_gso(vi))
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))
vi->big_packets = true; vi->big_packets = true;
if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF)) if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册