diff options
| author | Michal Marek <mmarek@suse.cz> | 2010-10-27 18:15:57 -0400 |
|---|---|---|
| committer | Michal Marek <mmarek@suse.cz> | 2010-10-27 18:15:57 -0400 |
| commit | b74b953b998bcc2db91b694446f3a2619ec32de6 (patch) | |
| tree | 6ce24caabd730f6ae9287ed0676ec32e6ff31e9d /include/linux/virtio.h | |
| parent | abb438526201c6a79949ad45375c051b6681c253 (diff) | |
| parent | f6f94e2ab1b33f0082ac22d71f66385a60d8157f (diff) | |
Merge commit 'v2.6.36' into kbuild/misc
Update to be able to fix a recent change to scripts/basic/docproc.c
(commit eda603f).
Diffstat (limited to 'include/linux/virtio.h')
| -rw-r--r-- | include/linux/virtio.h | 56 |
1 files changed, 36 insertions, 20 deletions
diff --git a/include/linux/virtio.h b/include/linux/virtio.h index 057a2e010758..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. |
| @@ -14,7 +15,6 @@ | |||
| 14 | * @callback: the function to call when buffers are consumed (can be NULL). | 15 | * @callback: the function to call when buffers are consumed (can be NULL). |
| 15 | * @name: the name of this virtqueue (mainly for debugging) | 16 | * @name: the name of this virtqueue (mainly for debugging) |
| 16 | * @vdev: the virtio device this queue was created for. | 17 | * @vdev: the virtio device this queue was created for. |
| 17 | * @vq_ops: the operations for this virtqueue (see below). | ||
| 18 | * @priv: a pointer for the virtqueue implementation to use. | 18 | * @priv: a pointer for the virtqueue implementation to use. |
| 19 | */ | 19 | */ |
| 20 | struct virtqueue { | 20 | struct virtqueue { |
| @@ -22,56 +22,71 @@ struct virtqueue { | |||
| 22 | void (*callback)(struct virtqueue *vq); | 22 | void (*callback)(struct virtqueue *vq); |
| 23 | const char *name; | 23 | const char *name; |
| 24 | struct virtio_device *vdev; | 24 | struct virtio_device *vdev; |
| 25 | struct virtqueue_ops *vq_ops; | ||
| 26 | void *priv; | 25 | void *priv; |
| 27 | }; | 26 | }; |
| 28 | 27 | ||
| 29 | /** | 28 | /** |
| 30 | * virtqueue_ops - operations for virtqueue abstraction layer | 29 | * operations for virtqueue |
| 31 | * @add_buf: expose buffer to other end | 30 | * virtqueue_add_buf: expose buffer to other end |
| 32 | * vq: the struct virtqueue we're talking about. | 31 | * vq: the struct virtqueue we're talking about. |
| 33 | * sg: the description of the buffer(s). | 32 | * sg: the description of the buffer(s). |
| 34 | * out_num: the number of sg readable by other side | 33 | * out_num: the number of sg readable by other side |
| 35 | * 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) |
| 36 | * data: the token identifying the buffer. | 35 | * data: the token identifying the buffer. |
| 36 | * gfp: how to do memory allocations (if necessary). | ||
| 37 | * Returns remaining capacity of queue (sg segments) or a negative error. | 37 | * Returns remaining capacity of queue (sg segments) or a negative error. |
| 38 | * @kick: update after add_buf | 38 | * virtqueue_kick: update after add_buf |
| 39 | * vq: the struct virtqueue | 39 | * vq: the struct virtqueue |
| 40 | * After one or more add_buf calls, invoke this to kick the other side. | 40 | * After one or more add_buf calls, invoke this to kick the other side. |
| 41 | * @get_buf: get the next used buffer | 41 | * virtqueue_get_buf: get the next used buffer |
| 42 | * vq: the struct virtqueue we're talking about. | 42 | * vq: the struct virtqueue we're talking about. |
| 43 | * len: the length written into the buffer | 43 | * len: the length written into the buffer |
| 44 | * Returns NULL or the "data" token handed to add_buf. | 44 | * Returns NULL or the "data" token handed to add_buf. |
| 45 | * @disable_cb: disable callbacks | 45 | * virtqueue_disable_cb: disable callbacks |
| 46 | * vq: the struct virtqueue we're talking about. | 46 | * vq: the struct virtqueue we're talking about. |
| 47 | * Note that this is not necessarily synchronous, hence unreliable and only | 47 | * Note that this is not necessarily synchronous, hence unreliable and only |
| 48 | * useful as an optimization. | 48 | * useful as an optimization. |
| 49 | * @enable_cb: restart callbacks after disable_cb. | 49 | * virtqueue_enable_cb: restart callbacks after disable_cb. |
| 50 | * vq: the struct virtqueue we're talking about. | 50 | * vq: the struct virtqueue we're talking about. |
| 51 | * This re-enables callbacks; it returns "false" if there are pending | 51 | * This re-enables callbacks; it returns "false" if there are pending |
| 52 | * buffers in the queue, to detect a possible race between the driver | 52 | * buffers in the queue, to detect a possible race between the driver |
| 53 | * checking for more work, and enabling callbacks. | 53 | * checking for more work, and enabling callbacks. |
| 54 | * virtqueue_detach_unused_buf: detach first unused buffer | ||
| 55 | * vq: the struct virtqueue we're talking about. | ||
| 56 | * Returns NULL or the "data" token handed to add_buf | ||
| 54 | * | 57 | * |
| 55 | * Locking rules are straightforward: the driver is responsible for | 58 | * Locking rules are straightforward: the driver is responsible for |
| 56 | * locking. No two operations may be invoked simultaneously, with the exception | 59 | * locking. No two operations may be invoked simultaneously, with the exception |
| 57 | * of @disable_cb. | 60 | * of virtqueue_disable_cb. |
| 58 | * | 61 | * |
| 59 | * All operations can be called in any context. | 62 | * All operations can be called in any context. |
| 60 | */ | 63 | */ |
| 61 | struct virtqueue_ops { | ||
| 62 | int (*add_buf)(struct virtqueue *vq, | ||
| 63 | struct scatterlist sg[], | ||
| 64 | unsigned int out_num, | ||
| 65 | unsigned int in_num, | ||
| 66 | void *data); | ||
| 67 | 64 | ||
| 68 | void (*kick)(struct virtqueue *vq); | 65 | int virtqueue_add_buf_gfp(struct virtqueue *vq, |
| 66 | struct scatterlist sg[], | ||
| 67 | unsigned int out_num, | ||
| 68 | unsigned int in_num, | ||
| 69 | void *data, | ||
| 70 | gfp_t gfp); | ||
| 69 | 71 | ||
| 70 | void *(*get_buf)(struct virtqueue *vq, unsigned int *len); | 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 | } | ||
| 71 | 80 | ||
| 72 | void (*disable_cb)(struct virtqueue *vq); | 81 | void virtqueue_kick(struct virtqueue *vq); |
| 73 | bool (*enable_cb)(struct virtqueue *vq); | 82 | |
| 74 | }; | 83 | void *virtqueue_get_buf(struct virtqueue *vq, unsigned int *len); |
| 84 | |||
| 85 | void virtqueue_disable_cb(struct virtqueue *vq); | ||
| 86 | |||
| 87 | bool virtqueue_enable_cb(struct virtqueue *vq); | ||
| 88 | |||
| 89 | void *virtqueue_detach_unused_buf(struct virtqueue *vq); | ||
| 75 | 90 | ||
| 76 | /** | 91 | /** |
| 77 | * virtio_device - representation of a device using virtio | 92 | * virtio_device - representation of a device using virtio |
| @@ -94,6 +109,7 @@ struct virtio_device { | |||
| 94 | void *priv; | 109 | void *priv; |
| 95 | }; | 110 | }; |
| 96 | 111 | ||
| 112 | #define dev_to_virtio(dev) container_of(dev, struct virtio_device, dev) | ||
| 97 | int register_virtio_device(struct virtio_device *dev); | 113 | int register_virtio_device(struct virtio_device *dev); |
| 98 | void unregister_virtio_device(struct virtio_device *dev); | 114 | void unregister_virtio_device(struct virtio_device *dev); |
| 99 | 115 | ||
