diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2009-09-24 00:26:31 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2009-09-23 08:56:31 -0400 |
commit | 3c1b27d5043086a485f8526353ae9fe37bfa1065 (patch) | |
tree | e3b6eda3c66bcd1fc3af6e7fa6e4e3af77459474 /drivers/virtio | |
parent | f68d24082e22ccee3077d11aeb6dc5354f0ca7f1 (diff) |
virtio: make add_buf return capacity remaining
This API change means that virtio_net can tell how much capacity
remains for buffers. It's necessarily fuzzy, since
VIRTIO_RING_F_INDIRECT_DESC means we can fit any number of descriptors
in one, *if* we can kmalloc.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Dinesh Subhraveti <dineshs@us.ibm.com>
Diffstat (limited to 'drivers/virtio')
-rw-r--r-- | drivers/virtio/virtio_balloon.c | 2 | ||||
-rw-r--r-- | drivers/virtio/virtio_ring.c | 6 |
2 files changed, 6 insertions, 2 deletions
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 26b278264796..39789232646d 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c | |||
@@ -84,7 +84,7 @@ static void tell_host(struct virtio_balloon *vb, struct virtqueue *vq) | |||
84 | init_completion(&vb->acked); | 84 | init_completion(&vb->acked); |
85 | 85 | ||
86 | /* We should always be able to add one buffer to an empty queue. */ | 86 | /* We should always be able to add one buffer to an empty queue. */ |
87 | if (vq->vq_ops->add_buf(vq, &sg, 1, 0, vb) != 0) | 87 | if (vq->vq_ops->add_buf(vq, &sg, 1, 0, vb) < 0) |
88 | BUG(); | 88 | BUG(); |
89 | vq->vq_ops->kick(vq); | 89 | vq->vq_ops->kick(vq); |
90 | 90 | ||
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index a882f2606515..f53600580726 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c | |||
@@ -208,7 +208,11 @@ add_head: | |||
208 | 208 | ||
209 | pr_debug("Added buffer head %i to %p\n", head, vq); | 209 | pr_debug("Added buffer head %i to %p\n", head, vq); |
210 | END_USE(vq); | 210 | END_USE(vq); |
211 | return 0; | 211 | |
212 | /* If we're indirect, we can fit many (assuming not OOM). */ | ||
213 | if (vq->indirect) | ||
214 | return vq->num_free ? vq->vring.num : 0; | ||
215 | return vq->num_free; | ||
212 | } | 216 | } |
213 | 217 | ||
214 | static void vring_kick(struct virtqueue *_vq) | 218 | static void vring_kick(struct virtqueue *_vq) |