diff options
author | Andy Lutomirski <luto@kernel.org> | 2016-02-03 00:46:37 -0500 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2016-03-02 10:01:57 -0500 |
commit | 2a2d1382fe9dccfce6f9c60a9c9fd2f0fe5bcf2b (patch) | |
tree | ab3783be11369f689e3e7aebe0c438ab6746375f /include/linux/virtio_ring.h | |
parent | 780bc7903a32edb63be138487fd981694d993610 (diff) |
virtio: Add improved queue allocation API
This leaves vring_new_virtqueue alone for compatbility, but it
adds two new improved APIs:
vring_create_virtqueue: Creates a virtqueue backed by automatically
allocated coherent memory. (Some day it this could be extended to
support non-coherent memory, too, if there ends up being a platform
on which it's worthwhile.)
__vring_new_virtqueue: Creates a virtqueue with a manually-specified
layout. This should allow mic_virtio to work much more cleanly.
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'include/linux/virtio_ring.h')
-rw-r--r-- | include/linux/virtio_ring.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h index a156e2b6ccfe..e8d36938f09a 100644 --- a/include/linux/virtio_ring.h +++ b/include/linux/virtio_ring.h | |||
@@ -59,6 +59,35 @@ static inline void virtio_store_mb(bool weak_barriers, | |||
59 | struct virtio_device; | 59 | struct virtio_device; |
60 | struct virtqueue; | 60 | struct virtqueue; |
61 | 61 | ||
62 | /* | ||
63 | * Creates a virtqueue and allocates the descriptor ring. If | ||
64 | * may_reduce_num is set, then this may allocate a smaller ring than | ||
65 | * expected. The caller should query virtqueue_get_ring_size to learn | ||
66 | * the actual size of the ring. | ||
67 | */ | ||
68 | struct virtqueue *vring_create_virtqueue(unsigned int index, | ||
69 | unsigned int num, | ||
70 | unsigned int vring_align, | ||
71 | struct virtio_device *vdev, | ||
72 | bool weak_barriers, | ||
73 | bool may_reduce_num, | ||
74 | bool (*notify)(struct virtqueue *vq), | ||
75 | void (*callback)(struct virtqueue *vq), | ||
76 | const char *name); | ||
77 | |||
78 | /* Creates a virtqueue with a custom layout. */ | ||
79 | struct virtqueue *__vring_new_virtqueue(unsigned int index, | ||
80 | struct vring vring, | ||
81 | struct virtio_device *vdev, | ||
82 | bool weak_barriers, | ||
83 | bool (*notify)(struct virtqueue *), | ||
84 | void (*callback)(struct virtqueue *), | ||
85 | const char *name); | ||
86 | |||
87 | /* | ||
88 | * Creates a virtqueue with a standard layout but a caller-allocated | ||
89 | * ring. | ||
90 | */ | ||
62 | struct virtqueue *vring_new_virtqueue(unsigned int index, | 91 | struct virtqueue *vring_new_virtqueue(unsigned int index, |
63 | unsigned int num, | 92 | unsigned int num, |
64 | unsigned int vring_align, | 93 | unsigned int vring_align, |
@@ -68,7 +97,13 @@ struct virtqueue *vring_new_virtqueue(unsigned int index, | |||
68 | bool (*notify)(struct virtqueue *vq), | 97 | bool (*notify)(struct virtqueue *vq), |
69 | void (*callback)(struct virtqueue *vq), | 98 | void (*callback)(struct virtqueue *vq), |
70 | const char *name); | 99 | const char *name); |
100 | |||
101 | /* | ||
102 | * Destroys a virtqueue. If created with vring_create_virtqueue, this | ||
103 | * also frees the ring. | ||
104 | */ | ||
71 | void vring_del_virtqueue(struct virtqueue *vq); | 105 | void vring_del_virtqueue(struct virtqueue *vq); |
106 | |||
72 | /* Filter out transport-specific feature bits. */ | 107 | /* Filter out transport-specific feature bits. */ |
73 | void vring_transport_features(struct virtio_device *vdev); | 108 | void vring_transport_features(struct virtio_device *vdev); |
74 | 109 | ||