From patchwork Thu Oct 22 16:43:47 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark McLoughlin X-Patchwork-Id: 36729 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 30910B7BAD for ; Fri, 23 Oct 2009 05:04:57 +1100 (EST) Received: from localhost ([127.0.0.1]:46356 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N121u-0000ui-O7 for incoming@patchwork.ozlabs.org; Thu, 22 Oct 2009 14:04:54 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N11hh-0000MA-5p for qemu-devel@nongnu.org; Thu, 22 Oct 2009 13:44:01 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N11hc-0000LI-Hu for qemu-devel@nongnu.org; Thu, 22 Oct 2009 13:44:00 -0400 Received: from [199.232.76.173] (port=53849 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N11hc-0000LF-Dy for qemu-devel@nongnu.org; Thu, 22 Oct 2009 13:43:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10330) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N11hb-00041e-SK for qemu-devel@nongnu.org; Thu, 22 Oct 2009 13:43:56 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9MGjilw011671 for ; Thu, 22 Oct 2009 12:45:45 -0400 Received: from blaa.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9MGjinV004574; Thu, 22 Oct 2009 12:45:44 -0400 Received: by blaa.localdomain (Postfix, from userid 500) id C68CD45B91; Thu, 22 Oct 2009 17:43:50 +0100 (IST) From: Mark McLoughlin To: qemu-devel@nongnu.org Date: Thu, 22 Oct 2009 17:43:47 +0100 Message-Id: <1256229830-28066-17-git-send-email-markmc@redhat.com> In-Reply-To: <1256229830-28066-1-git-send-email-markmc@redhat.com> References: <1256229830-28066-1-git-send-email-markmc@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 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 bb085ae..3fb10a2 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); } }