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>
This commit is contained in:

committed by
Michael S. Tsirkin

parent
780bc7903a
commit
2a2d1382fe
@@ -59,6 +59,35 @@ static inline void virtio_store_mb(bool weak_barriers,
|
||||
struct virtio_device;
|
||||
struct virtqueue;
|
||||
|
||||
/*
|
||||
* Creates a virtqueue and allocates the descriptor ring. If
|
||||
* may_reduce_num is set, then this may allocate a smaller ring than
|
||||
* expected. The caller should query virtqueue_get_ring_size to learn
|
||||
* the actual size of the ring.
|
||||
*/
|
||||
struct virtqueue *vring_create_virtqueue(unsigned int index,
|
||||
unsigned int num,
|
||||
unsigned int vring_align,
|
||||
struct virtio_device *vdev,
|
||||
bool weak_barriers,
|
||||
bool may_reduce_num,
|
||||
bool (*notify)(struct virtqueue *vq),
|
||||
void (*callback)(struct virtqueue *vq),
|
||||
const char *name);
|
||||
|
||||
/* Creates a virtqueue with a custom layout. */
|
||||
struct virtqueue *__vring_new_virtqueue(unsigned int index,
|
||||
struct vring vring,
|
||||
struct virtio_device *vdev,
|
||||
bool weak_barriers,
|
||||
bool (*notify)(struct virtqueue *),
|
||||
void (*callback)(struct virtqueue *),
|
||||
const char *name);
|
||||
|
||||
/*
|
||||
* Creates a virtqueue with a standard layout but a caller-allocated
|
||||
* ring.
|
||||
*/
|
||||
struct virtqueue *vring_new_virtqueue(unsigned int index,
|
||||
unsigned int num,
|
||||
unsigned int vring_align,
|
||||
@@ -68,7 +97,13 @@ struct virtqueue *vring_new_virtqueue(unsigned int index,
|
||||
bool (*notify)(struct virtqueue *vq),
|
||||
void (*callback)(struct virtqueue *vq),
|
||||
const char *name);
|
||||
|
||||
/*
|
||||
* Destroys a virtqueue. If created with vring_create_virtqueue, this
|
||||
* also frees the ring.
|
||||
*/
|
||||
void vring_del_virtqueue(struct virtqueue *vq);
|
||||
|
||||
/* Filter out transport-specific feature bits. */
|
||||
void vring_transport_features(struct virtio_device *vdev);
|
||||
|
||||
|
Reference in New Issue
Block a user