+#include "virtio_user/vhost.h"
+
+#define virtio_user_get_dev(hwp) container_of(hwp, struct virtio_user_dev, hw)
+
+static void
+virtio_user_reset_queues_packed(struct rte_eth_dev *eth_dev)
+{
+ struct virtio_user_dev *dev = eth_dev->data->dev_private;
+ struct virtio_hw *hw = &dev->hw;
+ struct virtnet_rx *rxvq;
+ struct virtnet_tx *txvq;
+ uint16_t i;
+
+ /* Add lock to avoid queue contention. */
+ rte_spinlock_lock(&hw->state_lock);
+ hw->started = 0;
+
+ /*
+ * Waitting for datapath to complete before resetting queues.
+ * 1 ms should be enough for the ongoing Tx/Rx function to finish.
+ */
+ rte_delay_ms(1);
+
+ /* Vring reset for each Tx queue and Rx queue. */
+ for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
+ rxvq = eth_dev->data->rx_queues[i];
+ virtqueue_rxvq_reset_packed(rxvq->vq);
+ virtio_dev_rx_queue_setup_finish(eth_dev, i);
+ }
+
+ for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
+ txvq = eth_dev->data->tx_queues[i];
+ virtqueue_txvq_reset_packed(txvq->vq);
+ }
+
+ hw->started = 1;
+ rte_spinlock_unlock(&hw->state_lock);
+}