aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/virtio_config.h
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2009-06-13 00:16:36 -0400
committerRusty Russell <rusty@rustcorp.com.au>2009-06-12 08:46:36 -0400
commitd2a7ddda9ffb1c8961abff6714b0f1eb925c120f (patch)
tree1090884fd260d042255255467367e4e6b6193e5d /include/linux/virtio_config.h
parent9499f5e7ed5224c40706f0cec6542a9916bc7606 (diff)
virtio: find_vqs/del_vqs virtio operations
This replaces find_vq/del_vq with find_vqs/del_vqs virtio operations, and updates all drivers. This is needed for MSI support, because MSI needs to know the total number of vectors upfront. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (+ lguest/9p compile fixes)
Diffstat (limited to 'include/linux/virtio_config.h')
-rw-r--r--include/linux/virtio_config.h47
1 files changed, 36 insertions, 11 deletions
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index 9fae274751e0..4cd290c06a88 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -29,6 +29,7 @@
29#define VIRTIO_F_NOTIFY_ON_EMPTY 24 29#define VIRTIO_F_NOTIFY_ON_EMPTY 24
30 30
31#ifdef __KERNEL__ 31#ifdef __KERNEL__
32#include <linux/err.h>
32#include <linux/virtio.h> 33#include <linux/virtio.h>
33 34
34/** 35/**
@@ -49,16 +50,26 @@
49 * @set_status: write the status byte 50 * @set_status: write the status byte
50 * vdev: the virtio_device 51 * vdev: the virtio_device
51 * status: the new status byte 52 * status: the new status byte
53 * @request_vqs: request the specified number of virtqueues
54 * vdev: the virtio_device
55 * max_vqs: the max number of virtqueues we want
56 * If supplied, must call before any virtqueues are instantiated.
57 * To modify the max number of virtqueues after request_vqs has been
58 * called, call free_vqs and then request_vqs with a new value.
59 * @free_vqs: cleanup resources allocated by request_vqs
60 * vdev: the virtio_device
61 * If supplied, must call after all virtqueues have been deleted.
52 * @reset: reset the device 62 * @reset: reset the device
53 * vdev: the virtio device 63 * vdev: the virtio device
54 * After this, status and feature negotiation must be done again 64 * After this, status and feature negotiation must be done again
55 * @find_vq: find a virtqueue and instantiate it. 65 * @find_vqs: find virtqueues and instantiate them.
56 * vdev: the virtio_device 66 * vdev: the virtio_device
57 * index: the 0-based virtqueue number in case there's more than one. 67 * nvqs: the number of virtqueues to find
58 * callback: the virtqueue callback 68 * vqs: on success, includes new virtqueues
59 * name: the virtqueue name (mainly for debugging) 69 * callbacks: array of callbacks, for each virtqueue
60 * Returns the new virtqueue or ERR_PTR() (eg. -ENOENT). 70 * names: array of virtqueue names (mainly for debugging)
61 * @del_vq: free a virtqueue found by find_vq(). 71 * Returns 0 on success or error status
72 * @del_vqs: free virtqueues found by find_vqs().
62 * @get_features: get the array of feature bits for this device. 73 * @get_features: get the array of feature bits for this device.
63 * vdev: the virtio_device 74 * vdev: the virtio_device
64 * Returns the first 32 feature bits (all we currently need). 75 * Returns the first 32 feature bits (all we currently need).
@@ -67,6 +78,7 @@
67 * This gives the final feature bits for the device: it can change 78 * This gives the final feature bits for the device: it can change
68 * the dev->feature bits if it wants. 79 * the dev->feature bits if it wants.
69 */ 80 */
81typedef void vq_callback_t(struct virtqueue *);
70struct virtio_config_ops 82struct virtio_config_ops
71{ 83{
72 void (*get)(struct virtio_device *vdev, unsigned offset, 84 void (*get)(struct virtio_device *vdev, unsigned offset,
@@ -76,11 +88,11 @@ struct virtio_config_ops
76 u8 (*get_status)(struct virtio_device *vdev); 88 u8 (*get_status)(struct virtio_device *vdev);
77 void (*set_status)(struct virtio_device *vdev, u8 status); 89 void (*set_status)(struct virtio_device *vdev, u8 status);
78 void (*reset)(struct virtio_device *vdev); 90 void (*reset)(struct virtio_device *vdev);
79 struct virtqueue *(*find_vq)(struct virtio_device *vdev, 91 int (*find_vqs)(struct virtio_device *, unsigned nvqs,
80 unsigned index, 92 struct virtqueue *vqs[],
81 void (*callback)(struct virtqueue *), 93 vq_callback_t *callbacks[],
82 const char *name); 94 const char *names[]);
83 void (*del_vq)(struct virtqueue *vq); 95 void (*del_vqs)(struct virtio_device *);
84 u32 (*get_features)(struct virtio_device *vdev); 96 u32 (*get_features)(struct virtio_device *vdev);
85 void (*finalize_features)(struct virtio_device *vdev); 97 void (*finalize_features)(struct virtio_device *vdev);
86}; 98};
@@ -128,5 +140,18 @@ static inline int virtio_config_buf(struct virtio_device *vdev,
128 vdev->config->get(vdev, offset, buf, len); 140 vdev->config->get(vdev, offset, buf, len);
129 return 0; 141 return 0;
130} 142}
143
144static inline
145struct virtqueue *virtio_find_single_vq(struct virtio_device *vdev,
146 vq_callback_t *c, const char *n)
147{
148 vq_callback_t *callbacks[] = { c };
149 const char *names[] = { n };
150 struct virtqueue *vq;
151 int err = vdev->config->find_vqs(vdev, 1, &vq, callbacks, names);
152 if (err < 0)
153 return ERR_PTR(err);
154 return vq;
155}
131#endif /* __KERNEL__ */ 156#endif /* __KERNEL__ */
132#endif /* _LINUX_VIRTIO_CONFIG_H */ 157#endif /* _LINUX_VIRTIO_CONFIG_H */