From patchwork Thu Oct 22 16:49:16 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark McLoughlin X-Patchwork-Id: 36733 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 35D57B7BB1 for ; Fri, 23 Oct 2009 05:12:40 +1100 (EST) Received: from localhost ([127.0.0.1]:35040 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N129M-0004k8-Gz for incoming@patchwork.ozlabs.org; Thu, 22 Oct 2009 14:12:36 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N11ni-0002c3-Rj for qemu-devel@nongnu.org; Thu, 22 Oct 2009 13:50:14 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N11ne-0002ar-5t for qemu-devel@nongnu.org; Thu, 22 Oct 2009 13:50:14 -0400 Received: from [199.232.76.173] (port=35945 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N11ne-0002am-2g for qemu-devel@nongnu.org; Thu, 22 Oct 2009 13:50:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33905) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N11nd-00052I-Dm for qemu-devel@nongnu.org; Thu, 22 Oct 2009 13:50:09 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9MGpBBO009224 for ; Thu, 22 Oct 2009 12:51:11 -0400 Received: from blaa.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9MGp9wb021035; Thu, 22 Oct 2009 12:51:10 -0400 Received: by blaa.localdomain (Postfix, from userid 500) id 8A1EF45D02; Thu, 22 Oct 2009 17:49:17 +0100 (IST) From: Mark McLoughlin To: qemu-devel@nongnu.org Date: Thu, 22 Oct 2009 17:49:16 +0100 Message-Id: <1256230156-29652-16-git-send-email-markmc@redhat.com> In-Reply-To: <1256230156-29652-1-git-send-email-markmc@redhat.com> References: <1256230156-29652-1-git-send-email-markmc@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Mark McLoughlin Subject: [Qemu-devel] [PATCH 15/15] net: move UFO support detection to tap-linux.c 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 Only supported on Linux Signed-off-by: Mark McLoughlin --- net/tap-aix.c | 5 +++++ net/tap-bsd.c | 5 +++++ net/tap-linux.c | 12 ++++++++++++ net/tap-solaris.c | 5 +++++ net/tap.c | 7 +------ net/tap.h | 1 + 6 files changed, 29 insertions(+), 6 deletions(-) diff --git a/net/tap-aix.c b/net/tap-aix.c index 0de3dd9..4bc9f2f 100644 --- a/net/tap-aix.c +++ b/net/tap-aix.c @@ -41,6 +41,11 @@ int tap_probe_vnet_hdr(int fd) return 0; } +int tap_probe_has_ufo(int fd) +{ + return 0; +} + void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, int ecn, int ufo) { diff --git a/net/tap-bsd.c b/net/tap-bsd.c index 1e85a3c..3ad14bb 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -71,6 +71,11 @@ int tap_probe_vnet_hdr(int fd) return 0; } +int tap_probe_has_ufo(int fd) +{ + return 0; +} + void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, int ecn, int ufo) { diff --git a/net/tap-linux.c b/net/tap-linux.c index b6f1fad..0f621a2 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -112,6 +112,18 @@ int tap_probe_vnet_hdr(int fd) return ifr.ifr_flags & IFF_VNET_HDR; } +int tap_probe_has_ufo(int fd) +{ + unsigned offload; + + offload = TUN_F_CSUM | TUN_F_UFO; + + if (ioctl(fd, TUNSETOFFLOAD, offload) < 0) + return 0; + + return 1; +} + void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, int ecn, int ufo) { diff --git a/net/tap-solaris.c b/net/tap-solaris.c index 614df01..ef4e60c 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -194,6 +194,11 @@ int tap_probe_vnet_hdr(int fd) return 0; } +int tap_probe_has_ufo(int fd) +{ + return 0; +} + void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, int ecn, int ufo) { diff --git a/net/tap.c b/net/tap.c index 9b11071..60354e4 100644 --- a/net/tap.c +++ b/net/tap.c @@ -271,7 +271,6 @@ static TAPState *net_tap_fd_init(VLANState *vlan, int vnet_hdr) { TAPState *s; - unsigned int offload; s = qemu_mallocz(sizeof(TAPState)); s->fd = fd; @@ -281,11 +280,7 @@ static TAPState *net_tap_fd_init(VLANState *vlan, vlan, NULL, model, name, NULL, tap_receive, tap_receive_raw, tap_receive_iov, tap_cleanup, s); - s->has_ufo = 0; - /* Check if tap supports UFO */ - offload = TUN_F_CSUM | TUN_F_UFO; - if (ioctl(s->fd, TUNSETOFFLOAD, offload) == 0) - s->has_ufo = 1; + s->has_ufo = tap_probe_has_ufo(s->fd); tap_set_offload(s->vc, 0, 0, 0, 0, 0); tap_read_poll(s, 1); return s; diff --git a/net/tap.h b/net/tap.h index 16398b5..538a562 100644 --- a/net/tap.h +++ b/net/tap.h @@ -45,6 +45,7 @@ void tap_set_offload(VLANClientState *vc, int csum, int tso4, int tso6, int ecn, int tap_set_sndbuf(int fd, QemuOpts *opts); int tap_probe_vnet_hdr(int fd); +int tap_probe_has_ufo(int fd); void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, int ecn, int ufo); #endif /* QEMU_NET_TAP_H */