[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220424024044.94749-3-xuanzhuo@linux.alibaba.com>
Date: Sun, 24 Apr 2022 10:40:30 +0800
From: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
To: linux-kernel@...r.kernel.org
Cc: "Michael S. Tsirkin" <mst@...hat.com>,
Jason Wang <jasowang@...hat.com>,
virtualization@...ts.linux-foundation.org
Subject: [RFC PATCH 02/16] virtio_ring: split: introduce vring_virtqueue_detach_split()
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@...ux.alibaba.com>
---
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
Powered by blists - more mailing lists