summaryrefslogtreecommitdiff
path: root/include/linux/virtio.h
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2010-04-29 17:26:37 +0300
committerRusty Russell <rusty@rustcorp.com.au>2010-05-19 22:15:46 +0930
commitbbd603efb4238cf78083c00f0a81adfa8994aa33 (patch)
tree3980961f9dbf08e748b3c2de56caf43dec21aa76 /include/linux/virtio.h
parentdc3f5e68f846eec38fb31d78f0b6e83633ad375e (diff)
virtio: add_buf_gfp
Add an add_buf variant that gets gfp parameter. Use that to allocate indirect buffers. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'include/linux/virtio.h')
-rw-r--r--include/linux/virtio.h22
1 files changed, 17 insertions, 5 deletions
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index 5b0fce0d2aa2..aff5b4f74041 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -7,6 +7,7 @@
#include <linux/spinlock.h>
#include <linux/device.h>
#include <linux/mod_devicetable.h>
+#include <linux/gfp.h>
/**
* virtqueue - a queue to register buffers for sending or receiving.
@@ -32,6 +33,7 @@ struct virtqueue {
* out_num: the number of sg readable by other side
* in_num: the number of sg which are writable (after readable ones)
* data: the token identifying the buffer.
+ * gfp: how to do memory allocations (if necessary).
* Returns remaining capacity of queue (sg segments) or a negative error.
* virtqueue_kick: update after add_buf
* vq: the struct virtqueue
@@ -60,11 +62,21 @@ struct virtqueue {
* All operations can be called in any context.
*/
-int virtqueue_add_buf(struct virtqueue *vq,
- struct scatterlist sg[],
- unsigned int out_num,
- unsigned int in_num,
- void *data);
+int virtqueue_add_buf_gfp(struct virtqueue *vq,
+ struct scatterlist sg[],
+ unsigned int out_num,
+ unsigned int in_num,
+ void *data,
+ gfp_t gfp);
+
+static inline int virtqueue_add_buf(struct virtqueue *vq,
+ struct scatterlist sg[],
+ unsigned int out_num,
+ unsigned int in_num,
+ void *data)
+{
+ return virtqueue_add_buf_gfp(vq, sg, out_num, in_num, data, GFP_ATOMIC);
+}
void virtqueue_kick(struct virtqueue *vq);