From fcdbe1fe1ab45d0572eec145850bd4e7991dff56 Mon Sep 17 00:00:00 2001 From: Yuanhan Liu Date: Fri, 14 Oct 2016 17:34:35 +0800 Subject: [PATCH] vhost: use last available index for ring reservation shadow_used_ring will be introduced later. Since then last avail idx will not be updated together with last used idx. So, here we use last_avail_idx for avail ring reservation. Signed-off-by: Yuanhan Liu Signed-off-by: Zhihong Wang Reviewed-by: Jianbo Liu Tested-by: Maxime Coquelin --- lib/librte_vhost/virtio_net.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index e44938842e..b41312b9e3 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -344,7 +344,7 @@ reserve_avail_buf_mergeable(struct vhost_virtqueue *vq, uint32_t size, uint32_t vec_idx = 0; uint16_t tries = 0; - cur_idx = vq->last_used_idx; + cur_idx = vq->last_avail_idx; while (1) { avail_idx = *((volatile uint16_t *)&vq->avail->idx); @@ -370,7 +370,7 @@ reserve_avail_buf_mergeable(struct vhost_virtqueue *vq, uint32_t size, return -1; } - *num_buffers = cur_idx - vq->last_used_idx; + *num_buffers = cur_idx - vq->last_avail_idx; return 0; } @@ -536,6 +536,7 @@ virtio_dev_merge_rx(struct virtio_net *dev, uint16_t queue_id, vhost_log_used_vring(dev, vq, offsetof(struct vring_used, idx), sizeof(vq->used->idx)); vq->last_used_idx += num_buffers; + vq->last_avail_idx += num_buffers; } if (likely(pkt_idx)) { -- 2.20.1