From patchwork Wed Mar 10 10:03:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 47221 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 0F38FB7CCD for ; Wed, 10 Mar 2010 21:23:59 +1100 (EST) Received: from localhost ([127.0.0.1]:43447 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NpJ45-0001d3-GY for incoming@patchwork.ozlabs.org; Wed, 10 Mar 2010 05:22:57 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NpIlW-0003sh-7r for qemu-devel@nongnu.org; Wed, 10 Mar 2010 05:03:46 -0500 Received: from [199.232.76.173] (port=49334 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NpIlV-0003sK-Fg for qemu-devel@nongnu.org; Wed, 10 Mar 2010 05:03:45 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NpIlQ-0001sK-1m for qemu-devel@nongnu.org; Wed, 10 Mar 2010 05:03:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:61997) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NpIlP-0001s0-GQ for qemu-devel@nongnu.org; Wed, 10 Mar 2010 05:03:39 -0500 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 o2AA3c0v018923 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 10 Mar 2010 05:03:38 -0500 Received: from localhost.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 o2AA3SbH017099; Wed, 10 Mar 2010 05:03:37 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 10 Mar 2010 11:03:20 +0100 Message-Id: <05a971c6373db001152b1d064a3618d90cf2772d.1268214633.git.quintela@redhat.com> In-Reply-To: References: In-Reply-To: References: 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. Subject: [Qemu-devel] [PATCH 06/14] tap: insert tap_can_send() into tap_send() 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 This way we can remove the poll test Signed-off-by: Juan Quintela --- net/tap.c | 27 +++++++++------------------ 1 files changed, 9 insertions(+), 18 deletions(-) diff --git a/net/tap.c b/net/tap.c index 7a7320c..3ab65a3 100644 --- a/net/tap.c +++ b/net/tap.c @@ -61,17 +61,15 @@ typedef struct TAPState { static int launch_script(const char *setup_script, const char *ifname, int fd); -static int tap_can_send(void *opaque); static void tap_send(void *opaque); static void tap_writable(void *opaque); static void tap_update_fd_handler(TAPState *s) { - qemu_set_fd_handler2(s->fd, - s->read_poll ? tap_can_send : NULL, - s->read_poll ? tap_send : NULL, - s->write_poll ? tap_writable : NULL, - s); + qemu_set_fd_handler(s->fd, + s->read_poll ? tap_send : NULL, + s->write_poll ? tap_writable : NULL, + s); } static void tap_read_poll(TAPState *s, int enable) @@ -165,13 +163,6 @@ static ssize_t tap_receive(VLANClientState *nc, const uint8_t *buf, size_t size) return tap_write_packet(s, iov, 1); } -static int tap_can_send(void *opaque) -{ - TAPState *s = opaque; - - return qemu_can_send_packet(&s->nc); -} - #ifndef __sun__ ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxlen) { @@ -188,12 +179,10 @@ static void tap_send_completed(VLANClientState *nc, ssize_t len) static void tap_send(void *opaque) { TAPState *s = opaque; - int size; - do { + while (qemu_can_send_packet(&s->nc) > 0) { uint8_t *buf = s->buf; - - size = tap_read_packet(s->fd, s->buf, sizeof(s->buf)); + int size = tap_read_packet(s->fd, s->buf, sizeof(s->buf)); if (size <= 0) { break; } @@ -206,8 +195,10 @@ static void tap_send(void *opaque) size = qemu_send_packet_async(&s->nc, buf, size, tap_send_completed); if (size == 0) { tap_read_poll(s, 0); + } else if (size < 0) { + return; } - } while (size > 0 && qemu_can_send_packet(&s->nc)); + } } int tap_has_ufo(VLANClientState *nc)