diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2013-03-20 01:14:26 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2013-03-20 01:14:52 -0400 |
commit | 282edb36499042a92b71f052f51754ae7ed936e4 (patch) | |
tree | 5031caab94e52b30e48515e881ea87a32daaeaeb /drivers/virtio | |
parent | 13816c768d46586e925b22736992258d6105ad2c (diff) |
virtio_ring: virtqueue_add_outbuf / virtqueue_add_inbuf.
These are specialized versions of virtqueue_add_buf(), which cover
over 80% of cases and are far clearer.
In particular, the scatterlists passed to these functions don't have
to be clean (ie. we ignore end markers).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/virtio')
-rw-r--r-- | drivers/virtio/virtio_ring.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index a78ad459cc85..5217baf5528c 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c | |||
@@ -366,6 +366,50 @@ int virtqueue_add_sgs(struct virtqueue *_vq, | |||
366 | EXPORT_SYMBOL_GPL(virtqueue_add_sgs); | 366 | EXPORT_SYMBOL_GPL(virtqueue_add_sgs); |
367 | 367 | ||
368 | /** | 368 | /** |
369 | * virtqueue_add_outbuf - expose output buffers to other end | ||
370 | * @vq: the struct virtqueue we're talking about. | ||
371 | * @sgs: array of scatterlists (need not be terminated!) | ||
372 | * @num: the number of scatterlists readable by other side | ||
373 | * @data: the token identifying the buffer. | ||
374 | * @gfp: how to do memory allocations (if necessary). | ||
375 | * | ||
376 | * Caller must ensure we don't call this with other virtqueue operations | ||
377 | * at the same time (except where noted). | ||
378 | * | ||
379 | * Returns zero or a negative error (ie. ENOSPC, ENOMEM). | ||
380 | */ | ||
381 | int virtqueue_add_outbuf(struct virtqueue *vq, | ||
382 | struct scatterlist sg[], unsigned int num, | ||
383 | void *data, | ||
384 | gfp_t gfp) | ||
385 | { | ||
386 | return virtqueue_add(vq, &sg, sg_next_arr, num, 0, 1, 0, data, gfp); | ||
387 | } | ||
388 | EXPORT_SYMBOL_GPL(virtqueue_add_outbuf); | ||
389 | |||
390 | /** | ||
391 | * virtqueue_add_inbuf - expose input buffers to other end | ||
392 | * @vq: the struct virtqueue we're talking about. | ||
393 | * @sgs: array of scatterlists (need not be terminated!) | ||
394 | * @num: the number of scatterlists writable by other side | ||
395 | * @data: the token identifying the buffer. | ||
396 | * @gfp: how to do memory allocations (if necessary). | ||
397 | * | ||
398 | * Caller must ensure we don't call this with other virtqueue operations | ||
399 | * at the same time (except where noted). | ||
400 | * | ||
401 | * Returns zero or a negative error (ie. ENOSPC, ENOMEM). | ||
402 | */ | ||
403 | int virtqueue_add_inbuf(struct virtqueue *vq, | ||
404 | struct scatterlist sg[], unsigned int num, | ||
405 | void *data, | ||
406 | gfp_t gfp) | ||
407 | { | ||
408 | return virtqueue_add(vq, &sg, sg_next_arr, 0, num, 0, 1, data, gfp); | ||
409 | } | ||
410 | EXPORT_SYMBOL_GPL(virtqueue_add_inbuf); | ||
411 | |||
412 | /** | ||
369 | * virtqueue_kick_prepare - first half of split virtqueue_kick call. | 413 | * virtqueue_kick_prepare - first half of split virtqueue_kick call. |
370 | * @vq: the struct virtqueue | 414 | * @vq: the struct virtqueue |
371 | * | 415 | * |