From patchwork Wed Oct 21 11:27:48 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark McLoughlin X-Patchwork-Id: 36548 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 8BA06B7BF9 for ; Wed, 21 Oct 2009 23:58:36 +1100 (EST) Received: from localhost ([127.0.0.1]:42459 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N0alt-0001xi-8k for incoming@patchwork.ozlabs.org; Wed, 21 Oct 2009 08:58:33 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N0ZOE-0006mx-R1 for qemu-devel@nongnu.org; Wed, 21 Oct 2009 07:30:04 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N0ZO6-0006hX-OG for qemu-devel@nongnu.org; Wed, 21 Oct 2009 07:29:59 -0400 Received: from [199.232.76.173] (port=57336 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N0ZO3-0006f6-PE for qemu-devel@nongnu.org; Wed, 21 Oct 2009 07:29:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24951) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N0ZO2-0002xj-KO for qemu-devel@nongnu.org; Wed, 21 Oct 2009 07:29:51 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9LBTnsm028386 for ; Wed, 21 Oct 2009 07:29:49 -0400 Received: from blaa.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9LBTncD030679; Wed, 21 Oct 2009 07:29:49 -0400 Received: by blaa.localdomain (Postfix, from userid 500) id 17B6F462CD; Wed, 21 Oct 2009 12:27:59 +0100 (IST) From: Mark McLoughlin To: qemu-devel@nongnu.org Date: Wed, 21 Oct 2009 12:27:48 +0100 Message-Id: <1256124478-2988-10-git-send-email-markmc@redhat.com> In-Reply-To: <1256124478-2988-1-git-send-email-markmc@redhat.com> References: <1256124478-2988-1-git-send-email-markmc@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Mark McLoughlin Subject: [Qemu-devel] [PATCH 09/19] net: add flags parameter to packet queue interface 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 allows for the addition of a raw flag, and leaves the way open for other flags too. Signed-off-by: Mark McLoughlin --- net-queue.c | 26 ++++++++++++++++++-------- net-queue.h | 6 ++++++ net.c | 14 ++++++++++++-- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/net-queue.c b/net-queue.c index 75457f0..f6b01e9 100644 --- a/net-queue.c +++ b/net-queue.c @@ -41,6 +41,7 @@ struct NetPacket { QTAILQ_ENTRY(NetPacket) entry; VLANClientState *sender; + unsigned flags; int size; NetPacketSent *sent_cb; uint8_t data[0]; @@ -89,6 +90,7 @@ void qemu_del_net_queue(NetQueue *queue) static ssize_t qemu_net_queue_append(NetQueue *queue, VLANClientState *sender, + unsigned flags, const uint8_t *buf, size_t size, NetPacketSent *sent_cb) @@ -97,6 +99,7 @@ static ssize_t qemu_net_queue_append(NetQueue *queue, packet = qemu_malloc(sizeof(NetPacket) + size); packet->sender = sender; + packet->flags = flags; packet->size = size; packet->sent_cb = sent_cb; memcpy(packet->data, buf, size); @@ -108,6 +111,7 @@ static ssize_t qemu_net_queue_append(NetQueue *queue, static ssize_t qemu_net_queue_append_iov(NetQueue *queue, VLANClientState *sender, + unsigned flags, const struct iovec *iov, int iovcnt, NetPacketSent *sent_cb) @@ -123,6 +127,7 @@ static ssize_t qemu_net_queue_append_iov(NetQueue *queue, packet = qemu_malloc(sizeof(NetPacket) + max_len); packet->sender = sender; packet->sent_cb = sent_cb; + packet->flags = flags; packet->size = 0; for (i = 0; i < iovcnt; i++) { @@ -139,13 +144,14 @@ static ssize_t qemu_net_queue_append_iov(NetQueue *queue, static ssize_t qemu_net_queue_deliver(NetQueue *queue, VLANClientState *sender, + unsigned flags, const uint8_t *data, size_t size) { ssize_t ret = -1; queue->delivering = 1; - ret = queue->deliver(sender, data, size, queue->opaque); + ret = queue->deliver(sender, flags, data, size, queue->opaque); queue->delivering = 0; return ret; @@ -153,13 +159,14 @@ static ssize_t qemu_net_queue_deliver(NetQueue *queue, static ssize_t qemu_net_queue_deliver_iov(NetQueue *queue, VLANClientState *sender, + unsigned flags, const struct iovec *iov, int iovcnt) { ssize_t ret = -1; queue->delivering = 1; - ret = queue->deliver_iov(sender, iov, iovcnt, queue->opaque); + ret = queue->deliver_iov(sender, flags, iov, iovcnt, queue->opaque); queue->delivering = 0; return ret; @@ -167,6 +174,7 @@ static ssize_t qemu_net_queue_deliver_iov(NetQueue *queue, ssize_t qemu_net_queue_send(NetQueue *queue, VLANClientState *sender, + unsigned flags, const uint8_t *data, size_t size, NetPacketSent *sent_cb) @@ -174,12 +182,12 @@ ssize_t qemu_net_queue_send(NetQueue *queue, ssize_t ret; if (queue->delivering) { - return qemu_net_queue_append(queue, sender, data, size, NULL); + return qemu_net_queue_append(queue, sender, flags, data, size, NULL); } - ret = qemu_net_queue_deliver(queue, sender, data, size); + ret = qemu_net_queue_deliver(queue, sender, flags, data, size); if (ret == 0 && sent_cb != NULL) { - qemu_net_queue_append(queue, sender, data, size, sent_cb); + qemu_net_queue_append(queue, sender, flags, data, size, sent_cb); return 0; } @@ -190,6 +198,7 @@ ssize_t qemu_net_queue_send(NetQueue *queue, ssize_t qemu_net_queue_send_iov(NetQueue *queue, VLANClientState *sender, + unsigned flags, const struct iovec *iov, int iovcnt, NetPacketSent *sent_cb) @@ -197,12 +206,12 @@ ssize_t qemu_net_queue_send_iov(NetQueue *queue, ssize_t ret; if (queue->delivering) { - return qemu_net_queue_append_iov(queue, sender, iov, iovcnt, NULL); + return qemu_net_queue_append_iov(queue, sender, flags, iov, iovcnt, NULL); } - ret = qemu_net_queue_deliver_iov(queue, sender, iov, iovcnt); + ret = qemu_net_queue_deliver_iov(queue, sender, flags, iov, iovcnt); if (ret == 0 && sent_cb != NULL) { - qemu_net_queue_append_iov(queue, sender, iov, iovcnt, sent_cb); + qemu_net_queue_append_iov(queue, sender, flags, iov, iovcnt, sent_cb); return 0; } @@ -234,6 +243,7 @@ void qemu_net_queue_flush(NetQueue *queue) ret = qemu_net_queue_deliver(queue, packet->sender, + packet->flags, packet->data, packet->size); if (ret == 0 && packet->sent_cb != NULL) { diff --git a/net-queue.h b/net-queue.h index ea17df6..343760e 100644 --- a/net-queue.h +++ b/net-queue.h @@ -32,15 +32,19 @@ typedef struct NetQueue NetQueue; typedef void (NetPacketSent) (VLANClientState *sender, ssize_t ret); typedef ssize_t (NetPacketDeliver) (VLANClientState *sender, + unsigned flags, const uint8_t *buf, size_t size, void *opaque); typedef ssize_t (NetPacketDeliverIOV) (VLANClientState *sender, + unsigned flags, const struct iovec *iov, int iovcnt, void *opaque); +#define QEMU_NET_PACKET_FLAG_NONE 0 + NetQueue *qemu_new_net_queue(NetPacketDeliver *deliver, NetPacketDeliverIOV *deliver_iov, void *opaque); @@ -48,12 +52,14 @@ void qemu_del_net_queue(NetQueue *queue); ssize_t qemu_net_queue_send(NetQueue *queue, VLANClientState *sender, + unsigned flags, const uint8_t *data, size_t size, NetPacketSent *sent_cb); ssize_t qemu_net_queue_send_iov(NetQueue *queue, VLANClientState *sender, + unsigned flags, const struct iovec *iov, int iovcnt, NetPacketSent *sent_cb); diff --git a/net.c b/net.c index 56d979b..30dc402 100644 --- a/net.c +++ b/net.c @@ -302,10 +302,12 @@ static char *assign_name(VLANClientState *vc1, const char *model) } static ssize_t qemu_deliver_packet(VLANClientState *sender, + unsigned flags, const uint8_t *data, size_t size, void *opaque); static ssize_t qemu_deliver_packet_iov(VLANClientState *sender, + unsigned flags, const struct iovec *iov, int iovcnt, void *opaque); @@ -450,6 +452,7 @@ int qemu_can_send_packet(VLANClientState *sender) } static ssize_t qemu_deliver_packet(VLANClientState *sender, + unsigned flags, const uint8_t *data, size_t size, void *opaque) @@ -464,6 +467,7 @@ static ssize_t qemu_deliver_packet(VLANClientState *sender, } static ssize_t qemu_vlan_deliver_packet(VLANClientState *sender, + unsigned flags, const uint8_t *buf, size_t size, void *opaque) @@ -543,7 +547,9 @@ ssize_t qemu_send_packet_async(VLANClientState *sender, queue = sender->vlan->send_queue; } - return qemu_net_queue_send(queue, sender, buf, size, sent_cb); + return qemu_net_queue_send(queue, sender, + QEMU_NET_PACKET_FLAG_NONE, + buf, size, sent_cb); } void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size) @@ -580,6 +586,7 @@ static ssize_t calc_iov_length(const struct iovec *iov, int iovcnt) } static ssize_t qemu_deliver_packet_iov(VLANClientState *sender, + unsigned flags, const struct iovec *iov, int iovcnt, void *opaque) @@ -598,6 +605,7 @@ static ssize_t qemu_deliver_packet_iov(VLANClientState *sender, } static ssize_t qemu_vlan_deliver_packet_iov(VLANClientState *sender, + unsigned flags, const struct iovec *iov, int iovcnt, void *opaque) @@ -646,7 +654,9 @@ ssize_t qemu_sendv_packet_async(VLANClientState *sender, queue = sender->vlan->send_queue; } - return qemu_net_queue_send_iov(queue, sender, iov, iovcnt, sent_cb); + return qemu_net_queue_send_iov(queue, sender, + QEMU_NET_PACKET_FLAG_NONE, + iov, iovcnt, sent_cb); } ssize_t