Blame SOURCES/dpdk-dev-v2-1-4-net-virtio-fix-vector-Rx-break-caused-by-rxq-flushing.patch

e49aad
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
e49aad
index e0328f61d..64a0cc608 100644
e49aad
--- a/drivers/net/virtio/virtio_ethdev.c
e49aad
+++ b/drivers/net/virtio/virtio_ethdev.c
e49aad
@@ -1860,7 +1860,7 @@ virtio_dev_start(struct rte_eth_dev *dev)
e49aad
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
e49aad
 		rxvq = dev->data->rx_queues[i];
e49aad
 		/* Flush the old packets */
e49aad
-		virtqueue_flush(rxvq->vq);
e49aad
+		virtqueue_rxvq_flush(rxvq->vq);
e49aad
 		virtqueue_notify(rxvq->vq);
e49aad
 	}
e49aad
 
e49aad
diff --git a/drivers/net/virtio/virtqueue.c b/drivers/net/virtio/virtqueue.c
e49aad
index c3a536f8a..696d0e4a4 100644
e49aad
--- a/drivers/net/virtio/virtqueue.c
e49aad
+++ b/drivers/net/virtio/virtqueue.c
e49aad
@@ -37,6 +37,7 @@
e49aad
 #include "virtqueue.h"
e49aad
 #include "virtio_logs.h"
e49aad
 #include "virtio_pci.h"
e49aad
+#include "virtio_rxtx_simple.h"
e49aad
 
e49aad
 /*
e49aad
  * Two types of mbuf to be cleaned:
e49aad
@@ -62,8 +63,10 @@ virtqueue_detatch_unused(struct virtqueue *vq)
e49aad
 
e49aad
 /* Flush the elements in the used ring. */
e49aad
 void
e49aad
-virtqueue_flush(struct virtqueue *vq)
e49aad
+virtqueue_rxvq_flush(struct virtqueue *vq)
e49aad
 {
e49aad
+	struct virtnet_rx *rxq = &vq->rxq;
e49aad
+	struct virtio_hw *hw = vq->hw;
e49aad
 	struct vring_used_elem *uep;
e49aad
 	struct vq_desc_extra *dxp;
e49aad
 	uint16_t used_idx, desc_idx;
e49aad
@@ -74,13 +77,27 @@ virtqueue_flush(struct virtqueue *vq)
e49aad
 	for (i = 0; i < nb_used; i++) {
e49aad
 		used_idx = vq->vq_used_cons_idx & (vq->vq_nentries - 1);
e49aad
 		uep = &vq->vq_ring.used->ring[used_idx];
e49aad
-		desc_idx = (uint16_t)uep->id;
e49aad
-		dxp = &vq->vq_descx[desc_idx];
e49aad
-		if (dxp->cookie != NULL) {
e49aad
-			rte_pktmbuf_free(dxp->cookie);
e49aad
-			dxp->cookie = NULL;
e49aad
+		if (hw->use_simple_rx) {
e49aad
+			desc_idx = used_idx;
e49aad
+			rte_pktmbuf_free(vq->sw_ring[desc_idx]);
e49aad
+			vq->vq_free_cnt++;
e49aad
+		} else {
e49aad
+			desc_idx = (uint16_t)uep->id;
e49aad
+			dxp = &vq->vq_descx[desc_idx];
e49aad
+			if (dxp->cookie != NULL) {
e49aad
+				rte_pktmbuf_free(dxp->cookie);
e49aad
+				dxp->cookie = NULL;
e49aad
+			}
e49aad
+			vq_ring_free_chain(vq, desc_idx);
e49aad
 		}
e49aad
 		vq->vq_used_cons_idx++;
e49aad
-		vq_ring_free_chain(vq, desc_idx);
e49aad
+	}
e49aad
+
e49aad
+	if (hw->use_simple_rx) {
e49aad
+		while (vq->vq_free_cnt >= RTE_VIRTIO_VPMD_RX_REARM_THRESH) {
e49aad
+			virtio_rxq_rearm_vec(rxq);
e49aad
+			if (virtqueue_kick_prepare(vq))
e49aad
+				virtqueue_notify(vq);
e49aad
+		}
e49aad
 	}
e49aad
 }
e49aad
diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h
e49aad
index 2305d91a4..ab466c2db 100644
e49aad
--- a/drivers/net/virtio/virtqueue.h
e49aad
+++ b/drivers/net/virtio/virtqueue.h
e49aad
@@ -304,7 +304,7 @@ void virtqueue_dump(struct virtqueue *vq);
e49aad
 struct rte_mbuf *virtqueue_detatch_unused(struct virtqueue *vq);
e49aad
 
e49aad
 /* Flush the elements in the used ring. */
e49aad
-void virtqueue_flush(struct virtqueue *vq);
e49aad
+void virtqueue_rxvq_flush(struct virtqueue *vq);
e49aad
 
e49aad
 static inline int
e49aad
 virtqueue_full(const struct virtqueue *vq)