From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N2qdI-0004Yh-Co for qemu-devel@nongnu.org; Tue, 27 Oct 2009 14:19:00 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N2qdD-0004WE-GK for qemu-devel@nongnu.org; Tue, 27 Oct 2009 14:18:59 -0400 Received: from [199.232.76.173] (port=37361 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N2qdD-0004W3-Da for qemu-devel@nongnu.org; Tue, 27 Oct 2009 14:18:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38988) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N2qdC-0000f9-0e for qemu-devel@nongnu.org; Tue, 27 Oct 2009 14:18:55 -0400 From: Mark McLoughlin Date: Tue, 27 Oct 2009 18:16:39 +0000 Message-Id: <1256667399-3149-6-git-send-email-markmc@redhat.com> In-Reply-To: <1256667399-3149-1-git-send-email-markmc@redhat.com> References: <1256667399-3149-1-git-send-email-markmc@redhat.com> Subject: [Qemu-devel] [PATCH 5/5] tap: drain queue in tap_send() List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Sven Rudolph , Scott Tsai , Mark McLoughlin Okay, let's try re-enabling the drain-entire-queue behaviour, with a difference - before each subsequent packet, use qemu_can_send_packet() to check that we can send it. This is similar to how we check before polling the tap fd and avoids having to drop a packet if the receiver cannot handle it. This patch should be a performance improvement since we no longer have to go through the mainloop for each packet. Signed-off-by: Mark McLoughlin --- net/tap.c | 33 ++++++++++++++++++--------------- 1 files changed, 18 insertions(+), 15 deletions(-) diff --git a/net/tap.c b/net/tap.c index f32226b..5272d7d 100644 --- a/net/tap.c +++ b/net/tap.c @@ -187,23 +187,26 @@ static void tap_send_completed(VLANClientState *vc, ssize_t len) static void tap_send(void *opaque) { TAPState *s = opaque; - uint8_t *buf = s->buf; int size; - size = tap_read_packet(s->fd, s->buf, sizeof(s->buf)); - if (size <= 0) { - return; - } + do { + uint8_t *buf = s->buf; - if (s->has_vnet_hdr && !s->using_vnet_hdr) { - buf += sizeof(struct virtio_net_hdr); - size -= sizeof(struct virtio_net_hdr); - } + size = tap_read_packet(s->fd, s->buf, sizeof(s->buf)); + if (size <= 0) { + break; + } - size = qemu_send_packet_async(s->vc, buf, size, tap_send_completed); - if (size == 0) { - tap_read_poll(s, 0); - } + if (s->has_vnet_hdr && !s->using_vnet_hdr) { + buf += sizeof(struct virtio_net_hdr); + size -= sizeof(struct virtio_net_hdr); + } + + size = qemu_send_packet_async(s->vc, buf, size, tap_send_completed); + if (size == 0) { + tap_read_poll(s, 0); + } + } while (size > 0 && qemu_can_send_packet(s->vc)); } int tap_has_ufo(VLANClientState *vc) -- 1.6.2.5