aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNikunj A Dadhania <nikunj@linux.vnet.ibm.com>2016-06-20 17:02:40 +0530
committerAlexey Kardashevskiy <aik@ozlabs.ru>2016-06-27 12:32:58 +1000
commit070886b669840532399c9dff5f1d35d91d6fa63a (patch)
treeff90bb55f2d2f271e0c6b934aa2110b61dc3e42e /lib
parent2435442ede44f2236ccdfec0a3704ab19cafb105 (diff)
downloadSLOF-070886b669840532399c9dff5f1d35d91d6fa63a.zip
SLOF-070886b669840532399c9dff5f1d35d91d6fa63a.tar.gz
SLOF-070886b669840532399c9dff5f1d35d91d6fa63a.tar.bz2
virtio-net: fix ring handling in receive
A bug crept in while doing the virtio 1.0 enablement in commit 6e4d62c2 (virtio-net: enable virtio 1.0) + idx = virtio_modern16_to_cpu(&virtiodev, vq_rx.used->idx); [...] - vq_rx.avail->ring[vq_rx.avail->idx % vq_rx.size] = id - 1; + vq_rx.avail->ring[idx % vq_rx.size] = virtio_cpu_to_modern16(&virtiodev, id - 1); sync(); - vq_rx.avail->idx += 1; + vq_rx.avail->idx = virtio_cpu_to_modern16(&virtiodev, idx + 1); Should be using avail->idx in place of used->idx. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Diffstat (limited to 'lib')
-rw-r--r--lib/libvirtio/virtio-net.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libvirtio/virtio-net.c b/lib/libvirtio/virtio-net.c
index fc620a2..2573031 100644
--- a/lib/libvirtio/virtio-net.c
+++ b/lib/libvirtio/virtio-net.c
@@ -266,6 +266,7 @@ static int virtionet_receive(char *buf, int maxlen)
{
uint32_t len = 0;
uint32_t id, idx;
+ uint16_t avail_idx;
idx = virtio_modern16_to_cpu(&virtiodev, vq_rx.used->idx);
@@ -304,9 +305,10 @@ static int virtionet_receive(char *buf, int maxlen)
/* Move indices to next entries */
last_rx_idx = last_rx_idx + 1;
- vq_rx.avail->ring[idx % vq_rx.size] = virtio_cpu_to_modern16(&virtiodev, id - 1);
+ avail_idx = virtio_modern16_to_cpu(&virtiodev, vq_rx.avail->idx);
+ vq_rx.avail->ring[avail_idx % vq_rx.size] = virtio_cpu_to_modern16(&virtiodev, id - 1);
sync();
- vq_rx.avail->idx = virtio_cpu_to_modern16(&virtiodev, idx + 1);
+ vq_rx.avail->idx = virtio_cpu_to_modern16(&virtiodev, avail_idx + 1);
/* Tell HV that RX queue entry is ready */
virtio_queue_notify(&virtiodev, VQ_RX);