Message ID | 8014f898ca6b768d7be626b83c617a1e84adfeb9.1306921434.git.mst@redhat.com |
---|---|
State | Not Applicable, archived |
Delegated to: | David Miller |
Headers | show |
On Wed, 1 Jun 2011 12:49:46 +0300, "Michael S. Tsirkin" <mst@redhat.com> wrote: > Add API to check ring capacity. Because of the option > to use indirect buffers, this returns the worst > case, not the normal case capacity. Can we drop the silly "add_buf() returns capacity" hack then? Thanks, Rusty. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, Jun 02, 2011 at 11:41:50AM +0930, Rusty Russell wrote: > On Wed, 1 Jun 2011 12:49:46 +0300, "Michael S. Tsirkin" <mst@redhat.com> wrote: > > Add API to check ring capacity. Because of the option > > to use indirect buffers, this returns the worst > > case, not the normal case capacity. > > Can we drop the silly "add_buf() returns capacity" hack then? > > Thanks, > Rusty. Sure. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 68b9136..23422f1 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -344,6 +344,14 @@ void *virtqueue_get_buf(struct virtqueue *_vq, unsigned int *len) } EXPORT_SYMBOL_GPL(virtqueue_get_buf); +int virtqueue_min_capacity(struct virtqueue *_vq) +{ + struct vring_virtqueue *vq = to_vvq(_vq); + + return vq->num_free; +} +EXPORT_SYMBOL_GPL(virtqueue_min_capacity); + void virtqueue_disable_cb(struct virtqueue *_vq) { struct vring_virtqueue *vq = to_vvq(_vq); diff --git a/include/linux/virtio.h b/include/linux/virtio.h index 7108857..209220d 100644 --- a/include/linux/virtio.h +++ b/include/linux/virtio.h @@ -42,6 +42,9 @@ struct virtqueue { * vq: the struct virtqueue we're talking about. * len: the length written into the buffer * Returns NULL or the "data" token handed to add_buf. + * virtqueue_min_capacity: get the current capacity of the queue + * vq: the struct virtqueue we're talking about. + * Returns the current worst case capacity of the queue. * virtqueue_disable_cb: disable callbacks * vq: the struct virtqueue we're talking about. * Note that this is not necessarily synchronous, hence unreliable and only @@ -89,6 +92,8 @@ void virtqueue_kick(struct virtqueue *vq); void *virtqueue_get_buf(struct virtqueue *vq, unsigned int *len); +int virtqueue_min_capacity(struct virtqueue *vq); + void virtqueue_disable_cb(struct virtqueue *vq); bool virtqueue_enable_cb(struct virtqueue *vq);
Add API to check ring capacity. Because of the option to use indirect buffers, this returns the worst case, not the normal case capacity. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> --- drivers/virtio/virtio_ring.c | 8 ++++++++ include/linux/virtio.h | 5 +++++ 2 files changed, 13 insertions(+), 0 deletions(-)