The function vring_virtqueue_detach_split() is introduced to detach the vring of the current vq. num_left records how many buffers there are, which can be used to check the recovery of buffers completed. Signed-off-by: Xuan Zhuo <xuanzhuo@xxxxxxxxxxxxxxxxx> --- drivers/virtio/virtio_ring.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 0a2c58557027..f3ad9322b512 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -112,6 +112,8 @@ struct vring_virtqueue_split { */ u32 vring_align; bool may_reduce_num; + + u32 num_left; }; struct vring_virtqueue_packed { @@ -982,6 +984,21 @@ static void virtqueue_reinit_split(struct vring_virtqueue *vq) virtqueue_vring_init_split(vq); } +static void virtqueue_vring_detach_split(struct vring_virtqueue *vq, + struct vring_virtqueue_split *vring) +{ + vring->vring = vq->split.vring; + + vring->queue_dma_addr = vq->split.queue_dma_addr; + + vring->queue_size_in_bytes = vq->split.queue_size_in_bytes; + + vring->desc_extra = vq->split.desc_extra; + vring->desc_state = vq->split.desc_state; + + vring->num_left = vring->vring.num - vq->vq.num_free; +} + static void virtqueue_vring_attach_split(struct vring_virtqueue *vq, struct vring_virtqueue_split *vring) { -- 2.31.0 _______________________________________________ Virtualization mailing list Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/virtualization