@@ -2255,7 +2255,7 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index,
}
EXPORT_SYMBOL_GPL(__vring_new_virtqueue);
-struct virtqueue *vring_create_virtqueue(
+struct virtqueue *vring_setup_virtqueue(
unsigned int index,
unsigned int num,
unsigned int vring_align,
@@ -2265,7 +2265,8 @@ struct virtqueue *vring_create_virtqueue(
bool context,
bool (*notify)(struct virtqueue *),
void (*callback)(struct virtqueue *),
- const char *name)
+ const char *name,
+ struct virtqueue *vq)
{
if (virtio_has_feature(vdev, VIRTIO_F_RING_PACKED))
@@ -2277,7 +2278,7 @@ struct virtqueue *vring_create_virtqueue(
vdev, weak_barriers, may_reduce_num,
context, notify, callback, name);
}
-EXPORT_SYMBOL_GPL(vring_create_virtqueue);
+EXPORT_SYMBOL_GPL(vring_setup_virtqueue);
/* Only available for split ring */
struct virtqueue *vring_new_virtqueue(unsigned int index,
@@ -65,16 +65,33 @@ struct virtqueue;
* expected. The caller should query virtqueue_get_vring_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 ctx,
- bool (*notify)(struct virtqueue *vq),
- void (*callback)(struct virtqueue *vq),
- const char *name);
+struct virtqueue *vring_setup_virtqueue(unsigned int index,
+ unsigned int num,
+ unsigned int vring_align,
+ struct virtio_device *vdev,
+ bool weak_barriers,
+ bool may_reduce_num,
+ bool ctx,
+ bool (*notify)(struct virtqueue *vq),
+ void (*callback)(struct virtqueue *vq),
+ const char *name,
+ struct virtqueue *vq);
+
+static inline 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 ctx,
+ bool (*notify)(struct virtqueue *vq),
+ void (*callback)(struct virtqueue *vq),
+ const char *name)
+{
+ return vring_setup_virtqueue(index, num, vring_align, vdev,
+ weak_barriers, may_reduce_num, ctx,
+ notify, callback, name, NULL);
+}
/* Creates a virtqueue with a custom layout. */
struct virtqueue *__vring_new_virtqueue(unsigned int index,
Added function vring_setup_virtqueue() to allow passing existing vq without reallocating vq. The purpose of adding this function is to not break the form of vring_create_virtqueue(). Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> --- drivers/virtio/virtio_ring.c | 7 ++++--- include/linux/virtio_ring.h | 37 ++++++++++++++++++++++++++---------- 2 files changed, 31 insertions(+), 13 deletions(-)