From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N10sj-0006I9-Vj for qemu-devel@nongnu.org; Thu, 22 Oct 2009 12:51:23 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N10sc-00068F-LI for qemu-devel@nongnu.org; Thu, 22 Oct 2009 12:51:19 -0400 Received: from [199.232.76.173] (port=54108 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N10sa-00066p-Rb for qemu-devel@nongnu.org; Thu, 22 Oct 2009 12:51:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26490) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N10sZ-00042a-UG for qemu-devel@nongnu.org; Thu, 22 Oct 2009 12:51:12 -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 n9MGpBnU004302 for ; Thu, 22 Oct 2009 12:51:11 -0400 From: Mark McLoughlin Date: Thu, 22 Oct 2009 17:49:15 +0100 Message-Id: <1256230156-29652-15-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> Subject: [Qemu-devel] [PATCH 14/15] net: move tap_set_offload() code into tap-linux.c List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Mark McLoughlin TUNSETOFFLOAD is only available on Linux Signed-off-by: Mark McLoughlin --- net/tap-aix.c | 5 +++++ net/tap-bsd.c | 5 +++++ net/tap-linux.c | 26 ++++++++++++++++++++++++++ net/tap-solaris.c | 5 +++++ net/tap.c | 21 +-------------------- net/tap.h | 1 + 6 files changed, 43 insertions(+), 20 deletions(-) diff --git a/net/tap-aix.c b/net/tap-aix.c index 27143ff..0de3dd9 100644 --- a/net/tap-aix.c +++ b/net/tap-aix.c @@ -40,3 +40,8 @@ int tap_probe_vnet_hdr(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 1cdde90..1e85a3c 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -70,3 +70,8 @@ int tap_probe_vnet_hdr(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 0059404..b6f1fad 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -111,3 +111,29 @@ int tap_probe_vnet_hdr(int fd) return ifr.ifr_flags & IFF_VNET_HDR; } + +void tap_fd_set_offload(int fd, int csum, int tso4, + int tso6, int ecn, int ufo) +{ + unsigned int offload = 0; + + if (csum) { + offload |= TUN_F_CSUM; + if (tso4) + offload |= TUN_F_TSO4; + if (tso6) + offload |= TUN_F_TSO6; + if ((tso4 || tso6) && ecn) + offload |= TUN_F_TSO_ECN; + if (ufo) + offload |= TUN_F_UFO; + } + + if (ioctl(fd, TUNSETOFFLOAD, offload) != 0) { + offload &= ~TUN_F_UFO; + if (ioctl(fd, TUNSETOFFLOAD, offload) != 0) { + fprintf(stderr, "TUNSETOFFLOAD ioctl() failed: %s\n", + strerror(errno)); + } + } +} diff --git a/net/tap-solaris.c b/net/tap-solaris.c index 3f48e57..614df01 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -193,3 +193,8 @@ int tap_probe_vnet_hdr(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 3f6722e..9b11071 100644 --- a/net/tap.c +++ b/net/tap.c @@ -243,27 +243,8 @@ void tap_set_offload(VLANClientState *vc, int csum, int tso4, int tso6, int ecn, int ufo) { TAPState *s = vc->opaque; - unsigned int offload = 0; - - if (csum) { - offload |= TUN_F_CSUM; - if (tso4) - offload |= TUN_F_TSO4; - if (tso6) - offload |= TUN_F_TSO6; - if ((tso4 || tso6) && ecn) - offload |= TUN_F_TSO_ECN; - if (ufo) - offload |= TUN_F_UFO; - } - if (ioctl(s->fd, TUNSETOFFLOAD, offload) != 0) { - offload &= ~TUN_F_UFO; - if (ioctl(s->fd, TUNSETOFFLOAD, offload) != 0) { - fprintf(stderr, "TUNSETOFFLOAD ioctl() failed: %s\n", - strerror(errno)); - } - } + return tap_fd_set_offload(s->fd, csum, tso4, tso6, ecn, ufo); } static void tap_cleanup(VLANClientState *vc) diff --git a/net/tap.h b/net/tap.h index de729a7..16398b5 100644 --- a/net/tap.h +++ b/net/tap.h @@ -45,5 +45,6 @@ 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); +void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, int ecn, int ufo); #endif /* QEMU_NET_TAP_H */ -- 1.6.2.5