From patchwork Wed May 4 14:03:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krishna Kumar X-Patchwork-Id: 753832 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p44E3Zjv017210 for ; Wed, 4 May 2011 14:03:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753671Ab1EDOD1 (ORCPT ); Wed, 4 May 2011 10:03:27 -0400 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:40527 "EHLO e23smtp09.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753650Ab1EDOD0 (ORCPT ); Wed, 4 May 2011 10:03:26 -0400 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [202.81.31.245]) by e23smtp09.au.ibm.com (8.14.4/8.13.1) with ESMTP id p44E3O4p031925; Thu, 5 May 2011 00:03:24 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p44E3Ow5352264; Thu, 5 May 2011 00:03:24 +1000 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p44E3MAJ011063; Thu, 5 May 2011 00:03:24 +1000 Received: from krkumar2.in.ibm.com ([9.124.221.167]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p44E3KqQ011031; Thu, 5 May 2011 00:03:20 +1000 From: Krishna Kumar To: davem@davemloft.net Cc: eric.dumazet@gmail.com, kvm@vger.kernel.org, mst@redhat.com, netdev@vger.kernel.org, rusty@rustcorp.com.au, Krishna Kumar Date: Wed, 04 May 2011 19:33:19 +0530 Message-Id: <20110504140319.14817.23145.sendpatchset@krkumar2.in.ibm.com> In-Reply-To: <20110504140258.14817.66596.sendpatchset@krkumar2.in.ibm.com> References: <20110504140258.14817.66596.sendpatchset@krkumar2.in.ibm.com> Subject: [PATCH 2/4] [RFC] virtio: Introduce new API to get free space Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Wed, 04 May 2011 14:03:35 +0000 (UTC) Introduce virtqueue_get_capacity() to help bail out of transmit path early. Also remove notification when we run out of space (I am not sure if this should be under a feature bit). Signed-off-by: Krishna Kumar --- drivers/virtio/virtio_ring.c | 13 ++++++++----- include/linux/virtio.h | 5 +++++ 2 files changed, 13 insertions(+), 5 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff -ruNp org/include/linux/virtio.h new/include/linux/virtio.h --- org/include/linux/virtio.h 2011-05-04 18:57:06.000000000 +0530 +++ new/include/linux/virtio.h 2011-05-04 18:57:09.000000000 +0530 @@ -27,6 +27,9 @@ struct virtqueue { /** * operations for virtqueue + * virtqueue_get_capacity: Get vq capacity + * vq: the struct virtqueue we're talking about. + * Returns remaining capacity of queue * virtqueue_add_buf: expose buffer to other end * vq: the struct virtqueue we're talking about. * sg: the description of the buffer(s). @@ -62,6 +65,8 @@ struct virtqueue { * All operations can be called in any context. */ +int virtqueue_get_capacity(struct virtqueue *vq); + int virtqueue_add_buf_gfp(struct virtqueue *vq, struct scatterlist sg[], unsigned int out_num, diff -ruNp org/drivers/virtio/virtio_ring.c new/drivers/virtio/virtio_ring.c --- org/drivers/virtio/virtio_ring.c 2011-05-04 18:57:06.000000000 +0530 +++ new/drivers/virtio/virtio_ring.c 2011-05-04 18:57:09.000000000 +0530 @@ -156,6 +156,14 @@ static int vring_add_indirect(struct vri return head; } +int virtqueue_get_capacity(struct virtqueue *_vq) +{ + struct vring_virtqueue *vq = to_vvq(_vq); + + return vq->num_free; +} +EXPORT_SYMBOL_GPL(virtqueue_get_capacity); + int virtqueue_add_buf_gfp(struct virtqueue *_vq, struct scatterlist sg[], unsigned int out, @@ -185,11 +193,6 @@ int virtqueue_add_buf_gfp(struct virtque if (vq->num_free < out + in) { pr_debug("Can't add buf len %i - avail = %i\n", out + in, vq->num_free); - /* FIXME: for historical reasons, we force a notify here if - * there are outgoing parts to the buffer. Presumably the - * host should service the ring ASAP. */ - if (out) - vq->notify(&vq->vq); END_USE(vq); return -ENOSPC; }