Separate the logic of attach vring, the subsequent patch will call it separately. Signed-off-by: Xuan Zhuo <xuanzhuo@xxxxxxxxxxxxxxxxx> --- drivers/virtio/virtio_ring.c | 41 +++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 980bd77d8243..e8d4de25e90b 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -1854,6 +1854,31 @@ static int vring_alloc_state_extra_packed(u32 num, struct vring_packed *vring) return -ENOMEM; } +static void vring_virtqueue_attach_packed(struct vring_virtqueue *vq, + struct vring_packed *vring) +{ + u32 num; + + num = vring->num; + + vq->vq.num_free = num; + + vq->packed.ring_dma_addr = vring->ring_dma_addr; + vq->packed.driver_event_dma_addr = vring->driver_event_dma_addr; + vq->packed.device_event_dma_addr = vring->device_event_dma_addr; + + vq->packed.ring_size_in_bytes = vring->ring_size_in_bytes; + vq->packed.event_size_in_bytes = vring->event_size_in_bytes; + + vq->packed.vring.num = num; + vq->packed.vring.desc = vring->ring; + vq->packed.vring.driver = vring->driver; + vq->packed.vring.device = vring->device; + + vq->packed.desc_state = vring->desc_state; + vq->packed.desc_extra = vring->desc_extra; +} + static struct virtqueue *vring_create_virtqueue_packed( unsigned int index, unsigned int num, @@ -1880,7 +1905,6 @@ static struct virtqueue *vring_create_virtqueue_packed( vq->vq.callback = callback; vq->vq.vdev = vdev; vq->vq.name = name; - vq->vq.num_free = num; vq->vq.index = index; vq->we_own_ring = true; vq->notify = notify; @@ -1903,18 +1927,6 @@ static struct virtqueue *vring_create_virtqueue_packed( if (virtio_has_feature(vdev, VIRTIO_F_ORDER_PLATFORM)) vq->weak_barriers = false; - vq->packed.ring_dma_addr = vring.ring_dma_addr; - vq->packed.driver_event_dma_addr = vring.driver_event_dma_addr; - vq->packed.device_event_dma_addr = vring.device_event_dma_addr; - - vq->packed.ring_size_in_bytes = vring.ring_size_in_bytes; - vq->packed.event_size_in_bytes = vring.event_size_in_bytes; - - vq->packed.vring.num = num; - vq->packed.vring.desc = vring.ring; - vq->packed.vring.driver = vring.driver; - vq->packed.vring.device = vring.device; - vq->packed.next_avail_idx = 0; vq->packed.avail_wrap_counter = 1; vq->packed.used_wrap_counter = 1; @@ -1925,8 +1937,7 @@ static struct virtqueue *vring_create_virtqueue_packed( if (err) goto err_state_extra; - vq->packed.desc_state = vring.desc_state; - vq->packed.desc_extra = vring.desc_extra; + vring_virtqueue_attach_packed(vq, &vring); /* Put everything in free lists. */ vq->free_head = 0; -- 2.31.0 _______________________________________________ Virtualization mailing list Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/virtualization