[dpdk-dev] [PATCH] vhost: fix assuming packed ring size is a power of 2
Maxime Coquelin
maxime.coquelin at redhat.com
Wed Jul 7 11:55:57 CEST 2021
Unlike split ring, packed ring does not mandate the ring size
to be a power of 2. So we have to use a modulo operation when
wrapping ring index.
Fixes: 873e8dad6f49 ("vhost: support packed ring in async datapath")
Cc: stable at dpdk.org
Signed-off-by: Maxime Coquelin <maxime.coquelin at redhat.com>
---
lib/vhost/virtio_net.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
index b93482587c..43011b5a2a 100644
--- a/lib/vhost/virtio_net.c
+++ b/lib/vhost/virtio_net.c
@@ -2131,7 +2131,7 @@ uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,
if (vq_is_packed(dev)) {
for (i = 0; i < n_pkts_put; i++) {
- from = (start_idx + i) & (vq_size - 1);
+ from = (start_idx + i) % vq_size;
n_buffers += pkts_info[from].nr_buffers;
pkts[i] = pkts_info[from].mbuf;
}
--
2.31.1
More information about the dev
mailing list