[RFC,08/13] add vhost fast dequeue flush function

Message ID 20190708171320.38802-9-yong.liu@intel.com
State Superseded
Delegated to: Maxime Coquelin
Headers show
Series
  • [RFC,01/13] add vhost normal enqueue function
Related show

Checks

Context Check Description
ci/Intel-compilation fail Compilation issues
ci/checkpatch success coding style OK

Commit Message

Marvin Liu July 8, 2019, 5:13 p.m.
Vhost fast dequeue function will flush used ring immediately.
Descriptor's flag is pre-calculated by macro.

Signed-off-by: Marvin Liu <yong.liu@intel.com>

Patch

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index 83ed2d599..cd51ed47a 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -265,6 +265,21 @@  flush_used_fast_packed(struct virtio_net *dev, struct vhost_virtqueue *vq,
 	}
 }
 
+static __rte_always_inline void
+flush_dequeue_fast_used_packed(struct virtio_net *dev,
+			struct vhost_virtqueue *vq, uint16_t id,
+			uint16_t id1, uint16_t id2, uint16_t id3)
+{
+	uint16_t flags = 0;
+
+	if (vq->used_wrap_counter)
+		flags = VIRTIO_TX_FLAG_PACKED;
+	else
+		flags = VIRTIO_TX_WRAP_FLAG_PACKED;
+
+	flush_used_fast_packed(dev, vq, 0, 0, 0, 0, id, id1, id2, id3, flags);
+}
+
 static __rte_always_inline void
 flush_enqueue_fast_used_packed(struct virtio_net *dev,
 			struct vhost_virtqueue *vq, uint64_t len,
@@ -1946,6 +1961,8 @@  virtio_dev_tx_fast_packed(struct virtio_net *dev, struct vhost_virtqueue *vq,
 		(void *)(uintptr_t)(desc_addr[3] + buf_offset),
 		pkts[3]->pkt_len);
 
+	flush_dequeue_fast_used_packed(dev, vq, ids[0], ids[1], ids[2],
+				ids[3]);
 	if (virtio_net_with_host_offload(dev)) {
 		hdr = (struct virtio_net_hdr *)((uintptr_t)desc_addr[0]);
 		hdr1 = (struct virtio_net_hdr *)((uintptr_t)desc_addr[1]);