Re: [PATCH] net/virtio: fix an incorrect behavior of device stop/start
From: Jens Freimann <hidden>
Date: 2017-08-30 09:13:06
Hi Tiwei, On Tue, Aug 29, 2017 at 04:26:01PM +0800, Tiwei Bie wrote:
After starting a device, the driver shouldn't deliver the
packets that already existed in the device before it is
started to the applications. This patch fixes this issue
by flushing the Rx queues when starting the device.
Fixes: a85786dc816f ("virtio: fix states handling during initialization")
Cc: stable@dpdk.org
Signed-off-by: Tiwei Bie <redacted>
---
drivers/net/virtio/virtio_ethdev.c | 6 ++++++
drivers/net/virtio/virtio_rxtx.c | 2 +-
drivers/net/virtio/virtqueue.c | 25 +++++++++++++++++++++++++
drivers/net/virtio/virtqueue.h | 5 +++++
4 files changed, 37 insertions(+), 1 deletion(-)why don't we flush Tx queues as well?
quoted hunk ↗ jump to hunk
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index e320811..6d60bc1 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c@@ -1737,6 +1737,12 @@ virtio_dev_start(struct rte_eth_dev *dev)} } + /* Flush the packets in Rx queues. */ + for (i = 0; i < dev->data->nb_rx_queues; i++) { + rxvq = dev->data->rx_queues[i]; + virtqueue_flush(rxvq->vq); + } +
A little bit further down is a for loop going over rx queues calling notify. Could we flush directly before the notify and save the additional loop? regards, Jens