Add helper for virtio queue reset. * virtio_reset_vq: reset a queue individually * virtio_del_resetq: del a reset queue * virtio_enable_resetq: enable a reset queue Signed-off-by: Xuan Zhuo <xuanzhuo@xxxxxxxxxxxxxxxxx> --- include/linux/virtio_config.h | 57 +++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h index 6e94f7d0e153..ddc26a5e74fd 100644 --- a/include/linux/virtio_config.h +++ b/include/linux/virtio_config.h @@ -240,6 +240,63 @@ int virtio_find_vqs_ctx(struct virtio_device *vdev, unsigned nvqs, desc); } +/** + * virtio_reset_vq - reset a queue individually + * @vdev: the device + * @queue_index: the queue index + * + * returns 0 on success or error status + * + */ +static inline +int virtio_reset_vq(struct virtio_device *vdev, u16 queue_index) +{ + if (!vdev->config->reset_vq) + return -ENOENT; + + return vdev->config->reset_vq(vdev, queue_index); +} + +/** + * virtio_del_resetq - del a reset queue + * @vdev: the device + * @queue_index: the queue index + * + * returns 0 on success or error status. + * + */ +static inline +int virtio_del_resetq(struct virtio_device *vdev, u16 queue_index) +{ + if (!vdev->config->del_reset_vq) + return -ENOENT; + + return vdev->config->del_reset_vq(vdev, queue_index); +} + +/** + * virtio_enable_resetq - enable a reset queue + * @vdev: the device + * @queue_index: the queue index + * @callback: callback for the virtqueue, NULL for vq that do not need a callback + * @name: virtqueue names (mainly for debugging), NULL for vq unused by driver + * @ctx: ctx + * + * returns vq on success or error status + * + */ +static inline +struct virtqueue *virtio_enable_resetq(struct virtio_device *vdev, + u16 queue_index, vq_callback_t *callback, + const char *name, const bool *ctx) +{ + if (!vdev->config->enable_reset_vq) + return ERR_PTR(-ENOENT); + + return vdev->config->enable_reset_vq(vdev, queue_index, callback, + name, ctx); +} + /** * virtio_device_ready - enable vq use in probe function * @vdev: the device -- 2.31.0 _______________________________________________ Virtualization mailing list Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/virtualization