diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/virtio.h | 3 | ||||
-rw-r--r-- | include/linux/vringh.h | 29 |
2 files changed, 32 insertions, 0 deletions
diff --git a/include/linux/virtio.h b/include/linux/virtio.h index ff6714e6d0f5..5d5b3abc283d 100644 --- a/include/linux/virtio.h +++ b/include/linux/virtio.h | |||
@@ -8,6 +8,7 @@ | |||
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 | #include <linux/gfp.h> |
11 | #include <linux/vringh.h> | ||
11 | 12 | ||
12 | /** | 13 | /** |
13 | * virtqueue - a queue to register buffers for sending or receiving. | 14 | * virtqueue - a queue to register buffers for sending or receiving. |
@@ -70,6 +71,7 @@ static inline unsigned int virtqueue_get_queue_index(struct virtqueue *vq) | |||
70 | * @dev: underlying device. | 71 | * @dev: underlying device. |
71 | * @id: the device type identification (used to match it with a driver). | 72 | * @id: the device type identification (used to match it with a driver). |
72 | * @config: the configuration ops for this device. | 73 | * @config: the configuration ops for this device. |
74 | * @vringh_config: configuration ops for host vrings. | ||
73 | * @vqs: the list of virtqueues for this device. | 75 | * @vqs: the list of virtqueues for this device. |
74 | * @features: the features supported by both driver and device. | 76 | * @features: the features supported by both driver and device. |
75 | * @priv: private pointer for the driver's use. | 77 | * @priv: private pointer for the driver's use. |
@@ -79,6 +81,7 @@ struct virtio_device { | |||
79 | struct device dev; | 81 | struct device dev; |
80 | struct virtio_device_id id; | 82 | struct virtio_device_id id; |
81 | const struct virtio_config_ops *config; | 83 | const struct virtio_config_ops *config; |
84 | const struct vringh_config_ops *vringh_config; | ||
82 | struct list_head vqs; | 85 | struct list_head vqs; |
83 | /* Note that this is a Linux set_bit-style bitmap. */ | 86 | /* Note that this is a Linux set_bit-style bitmap. */ |
84 | unsigned long features[1]; | 87 | unsigned long features[1]; |
diff --git a/include/linux/vringh.h b/include/linux/vringh.h index b8f086625c49..749cde28728b 100644 --- a/include/linux/vringh.h +++ b/include/linux/vringh.h | |||
@@ -47,6 +47,28 @@ struct vringh { | |||
47 | 47 | ||
48 | /* The vring (note: it may contain user pointers!) */ | 48 | /* The vring (note: it may contain user pointers!) */ |
49 | struct vring vring; | 49 | struct vring vring; |
50 | |||
51 | /* The function to call to notify the guest about added buffers */ | ||
52 | void (*notify)(struct vringh *); | ||
53 | }; | ||
54 | |||
55 | /** | ||
56 | * struct vringh_config_ops - ops for creating a host vring from a virtio driver | ||
57 | * @find_vrhs: find the host vrings and instantiate them | ||
58 | * vdev: the virtio_device | ||
59 | * nhvrs: the number of host vrings to find | ||
60 | * hvrs: on success, includes new host vrings | ||
61 | * callbacks: array of driver callbacks, for each host vring | ||
62 | * include a NULL entry for vqs that do not need a callback | ||
63 | * Returns 0 on success or error status | ||
64 | * @del_vrhs: free the host vrings found by find_vrhs(). | ||
65 | */ | ||
66 | struct virtio_device; | ||
67 | typedef void vrh_callback_t(struct virtio_device *, struct vringh *); | ||
68 | struct vringh_config_ops { | ||
69 | int (*find_vrhs)(struct virtio_device *vdev, unsigned nhvrs, | ||
70 | struct vringh *vrhs[], vrh_callback_t *callbacks[]); | ||
71 | void (*del_vrhs)(struct virtio_device *vdev); | ||
50 | }; | 72 | }; |
51 | 73 | ||
52 | /* The memory the vring can access, and what offset to apply. */ | 74 | /* The memory the vring can access, and what offset to apply. */ |
@@ -193,4 +215,11 @@ void vringh_notify_disable_kern(struct vringh *vrh); | |||
193 | 215 | ||
194 | int vringh_need_notify_kern(struct vringh *vrh); | 216 | int vringh_need_notify_kern(struct vringh *vrh); |
195 | 217 | ||
218 | /* Notify the guest about buffers added to the used ring */ | ||
219 | static inline void vringh_notify(struct vringh *vrh) | ||
220 | { | ||
221 | if (vrh->notify) | ||
222 | vrh->notify(vrh); | ||
223 | } | ||
224 | |||
196 | #endif /* _LINUX_VRINGH_H */ | 225 | #endif /* _LINUX_VRINGH_H */ |