aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/vringh.h
diff options
context:
space:
mode:
authorSjur Brændeland <sjur.brandeland@stericsson.com>2013-03-19 23:21:24 -0400
committerRusty Russell <rusty@rustcorp.com.au>2013-03-19 23:36:05 -0400
commit3beee86a4b9374e38dba36b44e81f1423a0d6b54 (patch)
tree5993020791a65623200b45393ccd63b342d5a933 /include/linux/vringh.h
parent1515c5ce26ae45a8ecea4e68a484562ca4356442 (diff)
virtio: Introduce vringh wrappers in virtio_config
Add wrappers for the host vrings to support loose coupling between the virtio device and driver. A new struct vringh_config_ops with the functions find_vrhs() and del_vrhs() is added to the virtio_device struct. This enables virtio drivers to manage virtio host rings without detailed knowledge of how the vrings are created and deleted. The function vringh_notify() is added so vringh clients can notify the other side that buffers are added to the used-ring. Cc: Ohad Ben-Cohen <ohad@wizery.com> Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (constified vringh_config)
Diffstat (limited to 'include/linux/vringh.h')
-rw-r--r--include/linux/vringh.h29
1 files changed, 29 insertions, 0 deletions
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 */
66struct virtio_device;
67typedef void vrh_callback_t(struct virtio_device *, struct vringh *);
68struct 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
194int vringh_need_notify_kern(struct vringh *vrh); 216int vringh_need_notify_kern(struct vringh *vrh);
195 217
218/* Notify the guest about buffers added to the used ring */
219static 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 */