@@ -233,6 +233,44 @@ int virtio_find_vqs_ctx(struct virtio_device *vdev, unsigned nvqs,
desc);
}
+/**
+ * virtio_reset_vq - reset a queue individually
+ * @vq: the virtqueue
+ *
+ * returns 0 on success or error status
+ *
+ * After successfully calling this, be sure to call
+ * virtqueue_detach_unused_buf() to recycle the buffer in the ring, and
+ * then call vring_release_virtqueue() to release the vq ring.
+ *
+ * Caller should guarantee that the vring is not accessed by any functions
+ * of virtqueue.
+ */
+static inline
+int virtio_reset_vq(struct virtqueue *vq)
+{
+ if (!vq->vdev->config->reset_vq)
+ return -ENOENT;
+
+ return vq->vdev->config->reset_vq(vq);
+}
+
+/**
+ * virtio_enable_resetq - enable a reset queue
+ * @vq: the virtqueue
+ *
+ * returns 0 on success or error status
+ *
+ */
+static inline
+int virtio_enable_resetq(struct virtqueue *vq)
+{
+ if (!vq->vdev->config->enable_reset_vq)
+ return -ENOENT;
+
+ return vq->vdev->config->enable_reset_vq(vq);
+}
+
/**
* virtio_device_ready - enable vq use in probe function
* @vdev: the device
Add helper for virtio queue reset. * virtio_reset_vq: reset a queue individually * virtio_enable_resetq: enable a reset queue Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> --- include/linux/virtio_config.h | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)