[dpdk-dev] [RFC 07/29] vhost: mark desc being used
Tiwei Bie
tiwei.bie at intel.com
Wed Jun 21 04:57:43 CEST 2017
From: Yuanhan Liu <yuanhan.liu at linux.intel.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu at linux.intel.com>
---
lib/librte_vhost/virtio_net.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index fd6f200..df88e31 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -1009,6 +1009,7 @@ dequeue_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,
*/
if (likely((desc->len == dev->vhost_hlen) &&
(desc->flags & VRING_DESC_F_NEXT) != 0)) {
+ rte_smp_wmb();
desc->flags = 0;
desc = &descs[(head_idx++) & (vq->size - 1)];
@@ -1068,11 +1069,11 @@ dequeue_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,
/* This desc reaches to its end, get the next one */
if (desc_avail == 0) {
+ if ((desc->flags & VRING_DESC_F_NEXT) == 0)
+ break;
+
+ rte_smp_wmb();
desc->flags = 0;
-
- if ((desc->flags & VRING_DESC_F_NEXT) == 0)
- break;
-
desc = &descs[(head_idx++) & (vq->size - 1)];
if (unlikely(desc->flags & VRING_DESC_F_INDIRECT))
return -1;
@@ -1111,6 +1112,7 @@ dequeue_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,
mbuf_avail = cur->buf_len - RTE_PKTMBUF_HEADROOM;
}
}
+ rte_smp_wmb();
desc->flags = 0;
prev->data_len = mbuf_offset;
--
2.7.4
More information about the dev
mailing list