From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M6NwR-0007tP-M1 for qemu-devel@nongnu.org; Tue, 19 May 2009 07:57:08 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M6NwN-0007q7-SA for qemu-devel@nongnu.org; Tue, 19 May 2009 07:57:07 -0400 Received: from [199.232.76.173] (port=43622 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M6NwN-0007pz-OD for qemu-devel@nongnu.org; Tue, 19 May 2009 07:57:03 -0400 Received: from mx2.redhat.com ([66.187.237.31]:46315) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M6NwN-0001VH-1b for qemu-devel@nongnu.org; Tue, 19 May 2009 07:57:03 -0400 Message-ID: <4A129E89.7030603@redhat.com> Date: Tue, 19 May 2009 14:56:57 +0300 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 0/13] Add generic packet buffering API References: <1242726931-5726-1-git-send-email-markmc@redhat.com> <4A128785.9040903@redhat.com> <1242729209.16653.19.camel@blaa> In-Reply-To: <1242729209.16653.19.camel@blaa> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mark McLoughlin Cc: Anthony Liguori , qemu-devel@nongnu.org Mark McLoughlin wrote: >> It will need adjustments to the device models; for example we'll need >> virtqueue_pop_commit() after we're certain the tap had enough room for >> our packet and virtqueue_pop_cancel() (to unmap the buffers) if we don't. >> > > Yep, it's possible with virtio. However, you can't unpop the buffer from > a tap file descriptor or socket. > > The alternative in those cases is to implement buffering for each, or to > always check the receiving side has buffers available before popping. I > choose this option because checking in advance for each packet seems > expensive - i.e. a syscall for tap/socket or a trawl through the ring > for virtio. > For virtio (or the other emulated devices) the check is pretty cheap; furthermore you only need to do it when something changes (notification or a pop). So, with the disadvantage of an asymmetrical API, we have: transmit(): conditional pop tap->receive() commit pop / cancel pop receive(): tap->send() if (no more room) tap->stop() receive_notify(): if (more room) tap->start() -- error compiling committee.c: too many arguments to function