From patchwork Wed Oct 21 11:27:55 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark McLoughlin X-Patchwork-Id: 36550 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 05BEDB7C0C for ; Thu, 22 Oct 2009 00:09:54 +1100 (EST) Received: from localhost ([127.0.0.1]:58823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N0awo-0006Pj-Ul for incoming@patchwork.ozlabs.org; Wed, 21 Oct 2009 09:09:51 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N0ZZh-00050M-CD for qemu-devel@nongnu.org; Wed, 21 Oct 2009 07:41:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N0ZZb-0004vX-1Z for qemu-devel@nongnu.org; Wed, 21 Oct 2009 07:41:51 -0400 Received: from [199.232.76.173] (port=48909 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N0ZZZ-0004ur-Oc for qemu-devel@nongnu.org; Wed, 21 Oct 2009 07:41:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12489) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N0ZZZ-0005Mt-72 for qemu-devel@nongnu.org; Wed, 21 Oct 2009 07:41:45 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9LBToMO023972 for ; Wed, 21 Oct 2009 07:29:50 -0400 Received: from blaa.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9LBTnwq030682; Wed, 21 Oct 2009 07:29:50 -0400 Received: by blaa.localdomain (Postfix, from userid 500) id 57FEF463CE; Wed, 21 Oct 2009 12:27:59 +0100 (IST) From: Mark McLoughlin To: qemu-devel@nongnu.org Date: Wed, 21 Oct 2009 12:27:55 +0100 Message-Id: <1256124478-2988-17-git-send-email-markmc@redhat.com> In-Reply-To: <1256124478-2988-1-git-send-email-markmc@redhat.com> References: <1256124478-2988-1-git-send-email-markmc@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Mark McLoughlin Subject: [Qemu-devel] [PATCH 16/19] virtio-net: enable tap offload if guest supports it X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- hw/virtio-net.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/hw/virtio-net.c b/hw/virtio-net.c index 5ce4b42..19d00a6 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -149,6 +149,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; @@ -174,6 +179,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 (peer_has_vnet_hdr(n)) { + 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, @@ -700,6 +713,11 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id) if (peer_has_vnet_hdr(n)) { 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); } }