[RFC,2/2] example/vhost: support to clear in-flight packets for async dequeue

Message ID 20220117132847.884998-3-yuanx.wang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series support to clear in-flight packets for async |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation warning apply issues

Commit Message

Wang, YuanX Jan. 17, 2022, 1:28 p.m. UTC
  This patch allows vhost_clear_queue_thread_unsafe() to clear
in-flight dequeue packets.

Signed-off-by: Yuan Wang <yuanx.wang@intel.com>
---
 examples/vhost/main.c | 8 ++++++++
 1 file changed, 8 insertions(+)
  

Patch

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 04a85262bc..050f983fd6 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -1495,6 +1495,7 @@  vhost_clear_queue_thread_unsafe(struct vhost_dev *vdev, uint16_t queue_id)
 	uint16_t n_pkt = 0;
 	uint16_t dma_id = dma_bind[vid2socketid[vdev->vid]].dmas[queue_id].dev_id;
 	struct rte_mbuf *m_enq_cpl[vdev->pkts_enq_inflight];
+	struct rte_mbuf *m_deq_cpl[vdev->pkts_deq_inflight];
 
 	if (queue_id % 2 == 0) {
 		while (vdev->pkts_enq_inflight) {
@@ -1503,6 +1504,13 @@  vhost_clear_queue_thread_unsafe(struct vhost_dev *vdev, uint16_t queue_id)
 			free_pkts(m_enq_cpl, n_pkt);
 			__atomic_sub_fetch(&vdev->pkts_enq_inflight, n_pkt, __ATOMIC_SEQ_CST);
 		}
+	} else {
+		while (vdev->pkts_deq_inflight) {
+			n_pkt = rte_vhost_clear_queue_thread_unsafe(vdev->vid,
+				queue_id, m_deq_cpl, vdev->pkts_deq_inflight, dma_id, 0);
+			free_pkts(m_deq_cpl, n_pkt);
+			__atomic_sub_fetch(&vdev->pkts_deq_inflight, n_pkt, __ATOMIC_SEQ_CST);
+		}
 	}
 }