diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2010-04-29 10:26:37 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2010-05-19 08:45:46 -0400 |
commit | bbd603efb4238cf78083c00f0a81adfa8994aa33 (patch) | |
tree | 3980961f9dbf08e748b3c2de56caf43dec21aa76 /include | |
parent | dc3f5e68f846eec38fb31d78f0b6e83633ad375e (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')
-rw-r--r-- | include/linux/virtio.h | 22 |
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 @@ | |||
7 | #include <linux/spinlock.h> | 7 | #include <linux/spinlock.h> |
8 | #include <linux/device.h> | 8 | #include <linux/device.h> |
9 | #include <linux/mod_devicetable.h> | 9 | #include <linux/mod_devicetable.h> |
10 | #include <linux/gfp.h> | ||
10 | 11 | ||
11 | /** | 12 | /** |
12 | * virtqueue - a queue to register buffers for sending or receiving. | 13 | * virtqueue - a queue to register buffers for sending or receiving. |
@@ -32,6 +33,7 @@ struct virtqueue { | |||
32 | * out_num: the number of sg readable by other side | 33 | * out_num: the number of sg readable by other side |
33 | * in_num: the number of sg which are writable (after readable ones) | 34 | * in_num: the number of sg which are writable (after readable ones) |
34 | * data: the token identifying the buffer. | 35 | * data: the token identifying the buffer. |
36 | * gfp: how to do memory allocations (if necessary). | ||
35 | * Returns remaining capacity of queue (sg segments) or a negative error. | 37 | * Returns remaining capacity of queue (sg segments) or a negative error. |
36 | * virtqueue_kick: update after add_buf | 38 | * virtqueue_kick: update after add_buf |
37 | * vq: the struct virtqueue | 39 | * vq: the struct virtqueue |
@@ -60,11 +62,21 @@ struct virtqueue { | |||
60 | * All operations can be called in any context. | 62 | * All operations can be called in any context. |
61 | */ | 63 | */ |
62 | 64 | ||
63 | int virtqueue_add_buf(struct virtqueue *vq, | 65 | int virtqueue_add_buf_gfp(struct virtqueue *vq, |
64 | struct scatterlist sg[], | 66 | struct scatterlist sg[], |
65 | unsigned int out_num, | 67 | unsigned int out_num, |
66 | unsigned int in_num, | 68 | unsigned int in_num, |
67 | void *data); | 69 | void *data, |
70 | gfp_t gfp); | ||
71 | |||
72 | static inline int virtqueue_add_buf(struct virtqueue *vq, | ||
73 | struct scatterlist sg[], | ||
74 | unsigned int out_num, | ||
75 | unsigned int in_num, | ||
76 | void *data) | ||
77 | { | ||
78 | return virtqueue_add_buf_gfp(vq, sg, out_num, in_num, data, GFP_ATOMIC); | ||
79 | } | ||
68 | 80 | ||
69 | void virtqueue_kick(struct virtqueue *vq); | 81 | void virtqueue_kick(struct virtqueue *vq); |
70 | 82 | ||