summaryrefslogtreecommitdiffstats
path: root/hw/virtio-net.c
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2009-10-22 17:43:47 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2009-10-27 12:29:03 -0500
commitf5436dd96aea2ec937964230831f241ebd3b658b (patch)
tree3ded9f3042f591e7b31df21616c49fa18fa98296 /hw/virtio-net.c
parentb1c28b464d5f21805d322b67f008e114a484146d (diff)
downloadhqemu-f5436dd96aea2ec937964230831f241ebd3b658b.zip
hqemu-f5436dd96aea2ec937964230831f241ebd3b658b.tar.gz
virtio-net: enable tap offload if guest supports it
We query the guest's feature set to see if it supports offload and, if so, we enable those features on the tap interface. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/virtio-net.c')
-rw-r--r--hw/virtio-net.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index d10d183..5e9520d 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -152,6 +152,11 @@ static uint32_t virtio_net_get_features(VirtIODevice *vdev)
features |= (1 << VIRTIO_NET_F_HOST_TSO4);
features |= (1 << VIRTIO_NET_F_HOST_TSO6);
features |= (1 << VIRTIO_NET_F_HOST_ECN);
+
+ features |= (1 << VIRTIO_NET_F_GUEST_CSUM);
+ features |= (1 << VIRTIO_NET_F_GUEST_TSO4);
+ features |= (1 << VIRTIO_NET_F_GUEST_TSO6);
+ features |= (1 << VIRTIO_NET_F_GUEST_ECN);
}
return features;
@@ -177,6 +182,14 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint32_t features)
VirtIONet *n = to_virtio_net(vdev);
n->mergeable_rx_bufs = !!(features & (1 << VIRTIO_NET_F_MRG_RXBUF));
+
+ if (n->has_vnet_hdr) {
+ tap_set_offload(n->vc->peer,
+ (features >> VIRTIO_NET_F_GUEST_CSUM) & 1,
+ (features >> VIRTIO_NET_F_GUEST_TSO4) & 1,
+ (features >> VIRTIO_NET_F_GUEST_TSO6) & 1,
+ (features >> VIRTIO_NET_F_GUEST_ECN) & 1);
+ }
}
static int virtio_net_handle_rx_mode(VirtIONet *n, uint8_t cmd,
@@ -702,6 +715,11 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
if (n->has_vnet_hdr) {
tap_using_vnet_hdr(n->vc->peer, 1);
+ tap_set_offload(n->vc->peer,
+ (n->vdev.features >> VIRTIO_NET_F_GUEST_CSUM) & 1,
+ (n->vdev.features >> VIRTIO_NET_F_GUEST_TSO4) & 1,
+ (n->vdev.features >> VIRTIO_NET_F_GUEST_TSO6) & 1,
+ (n->vdev.features >> VIRTIO_NET_F_GUEST_ECN) & 1);
}
}
OpenPOWER on IntegriCloud