From patchwork Thu Oct 22 16:49:13 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark McLoughlin X-Patchwork-Id: 36725 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 A6C73B7BB0 for ; Fri, 23 Oct 2009 04:49:24 +1100 (EST) Received: from localhost ([127.0.0.1]:34826 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N11ms-00020n-3P for incoming@patchwork.ozlabs.org; Thu, 22 Oct 2009 13:49:22 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N10sq-0006Jq-D7 for qemu-devel@nongnu.org; Thu, 22 Oct 2009 12:51:28 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N10sd-000694-FB for qemu-devel@nongnu.org; Thu, 22 Oct 2009 12:51:20 -0400 Received: from [199.232.76.173] (port=54109 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N10sa-00066u-PT for qemu-devel@nongnu.org; Thu, 22 Oct 2009 12:51:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48975) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N10sZ-00042Y-S0 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 n9MGpAKG009220 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 n9MGp9ns021038; Thu, 22 Oct 2009 12:51:10 -0400 Received: by blaa.localdomain (Postfix, from userid 500) id 65AEA45C9A; Thu, 22 Oct 2009 17:49:17 +0100 (IST) From: Mark McLoughlin To: qemu-devel@nongnu.org Date: Thu, 22 Oct 2009 17:49:13 +0100 Message-Id: <1256230156-29652-13-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 12/15] net: move tap_set_sndbuf() 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 TUNSETSNDBUF is only available on linux Signed-off-by: Mark McLoughlin --- net/tap-aix.c | 6 ++++++ net/tap-bsd.c | 5 +++++ net/tap-linux.c | 23 +++++++++++++++++++++++ net/tap-solaris.c | 5 +++++ net/tap.c | 25 +------------------------ net/tap.h | 2 ++ 6 files changed, 42 insertions(+), 24 deletions(-) diff --git a/net/tap-aix.c b/net/tap-aix.c index 5ec3b2c..3f9ccdd 100644 --- a/net/tap-aix.c +++ b/net/tap-aix.c @@ -30,3 +30,9 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required fprintf(stderr, "no tap on AIX\n"); return -1; } + +int tap_set_sndbuf(int fd, QemuOpts *opts) +{ + return 0; +} + diff --git a/net/tap-bsd.c b/net/tap-bsd.c index 6940434..e28615f 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -60,3 +60,8 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required fcntl(fd, F_SETFL, O_NONBLOCK); return fd; } + +int tap_set_sndbuf(int fd, QemuOpts *opts) +{ + return 0; +} diff --git a/net/tap-linux.c b/net/tap-linux.c index c6f751e..6c3b6e3 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -76,3 +76,26 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required fcntl(fd, F_SETFL, O_NONBLOCK); return fd; } + +/* sndbuf should be set to a value lower than the tx queue + * capacity of any destination network interface. + * Ethernet NICs generally have txqueuelen=1000, so 1Mb is + * a good default, given a 1500 byte MTU. + */ +#define TAP_DEFAULT_SNDBUF 1024*1024 + +int tap_set_sndbuf(int fd, QemuOpts *opts) +{ + int sndbuf; + + sndbuf = qemu_opt_get_size(opts, "sndbuf", TAP_DEFAULT_SNDBUF); + if (!sndbuf) { + sndbuf = INT_MAX; + } + + if (ioctl(fd, TUNSETSNDBUF, &sndbuf) == -1 && qemu_opt_get(opts, "sndbuf")) { + qemu_error("TUNSETSNDBUF ioctl failed: %s\n", strerror(errno)); + return -1; + } + return 0; +} diff --git a/net/tap-solaris.c b/net/tap-solaris.c index 0dd5b68..de5855a 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -183,3 +183,8 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required fcntl(fd, F_SETFL, O_NONBLOCK); return fd; } + +int tap_set_sndbuf(int fd, QemuOpts *opts) +{ + return 0; +} diff --git a/net/tap.c b/net/tap.c index 5392937..df2cfbe 100644 --- a/net/tap.c +++ b/net/tap.c @@ -209,29 +209,6 @@ static void tap_send(void *opaque) } while (size > 0); } -/* sndbuf should be set to a value lower than the tx queue - * capacity of any destination network interface. - * Ethernet NICs generally have txqueuelen=1000, so 1Mb is - * a good default, given a 1500 byte MTU. - */ -#define TAP_DEFAULT_SNDBUF 1024*1024 - -static int tap_set_sndbuf(TAPState *s, QemuOpts *opts) -{ - int sndbuf; - - sndbuf = qemu_opt_get_size(opts, "sndbuf", TAP_DEFAULT_SNDBUF); - if (!sndbuf) { - sndbuf = INT_MAX; - } - - if (ioctl(s->fd, TUNSETSNDBUF, &sndbuf) == -1 && qemu_opt_get(opts, "sndbuf")) { - qemu_error("TUNSETSNDBUF ioctl failed: %s\n", strerror(errno)); - return -1; - } - return 0; -} - int tap_has_ufo(VLANClientState *vc) { TAPState *s = vc->opaque; @@ -465,7 +442,7 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan return -1; } - if (tap_set_sndbuf(s, opts) < 0) { + if (tap_set_sndbuf(s->fd, opts) < 0) { return -1; } diff --git a/net/tap.h b/net/tap.h index 5648ddd..0d67c24 100644 --- a/net/tap.h +++ b/net/tap.h @@ -43,4 +43,6 @@ int tap_has_vnet_hdr(VLANClientState *vc); void tap_using_vnet_hdr(VLANClientState *vc, int using_vnet_hdr); void tap_set_offload(VLANClientState *vc, int csum, int tso4, int tso6, int ecn, int ufo); +int tap_set_sndbuf(int fd, QemuOpts *opts); + #endif /* QEMU_NET_TAP_H */