From 3791fac5833063982382c074865a481c66b22530 Mon Sep 17 00:00:00 2001
From: Rafal Kozik <rk@semihalf.com>
Date: Wed, 14 Nov 2018 10:59:45 +0100
Subject: [PATCH 039/166] net/ena: fix cleaning HW IO rings configuration

When queues are stopped release Tx buffers.
During start initialize array of empty Tx/Rx reqs with default values.

Fixes: df238f84c0a2 ("net/ena: recreate HW IO rings on start and stop")
Cc: stable@dpdk.org

Signed-off-by: Rafal Kozik <rk@semihalf.com>
Acked-by: Michal Krawczyk <mk@semihalf.com>
---
 drivers/net/ena/ena_ethdev.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index 8e7451a61a..ac80ee054a 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -1098,6 +1098,7 @@ static int ena_create_io_queue(struct ena_ring *ring)
 		{ ENA_ADMIN_PLACEMENT_POLICY_HOST,
 		  0, 0, 0, 0, 0 };
 	uint16_t ena_qid;
+	unsigned int i;
 	int rc;
 
 	adapter = ring->adapter;
@@ -1108,10 +1109,14 @@ static int ena_create_io_queue(struct ena_ring *ring)
 		ctx.direction = ENA_COM_IO_QUEUE_DIRECTION_TX;
 		ctx.mem_queue_type = ena_dev->tx_mem_queue_type;
 		ctx.queue_size = adapter->tx_ring_size;
+		for (i = 0; i < ring->ring_size; i++)
+			ring->empty_tx_reqs[i] = i;
 	} else {
 		ena_qid = ENA_IO_RXQ_IDX(ring->id);
 		ctx.direction = ENA_COM_IO_QUEUE_DIRECTION_RX;
 		ctx.queue_size = adapter->rx_ring_size;
+		for (i = 0; i < ring->ring_size; i++)
+			ring->empty_rx_reqs[i] = i;
 	}
 	ctx.qid = ena_qid;
 	ctx.msix_vector = -1; /* interrupts not used */
@@ -1154,6 +1159,8 @@ static void ena_free_io_queues_all(struct ena_adapter *adapter)
 	for (i = 0; i < nb_txq; ++i) {
 		ena_qid = ENA_IO_TXQ_IDX(i);
 		ena_com_destroy_io_queue(ena_dev, ena_qid);
+
+		ena_tx_queue_release_bufs(&adapter->tx_ring[i]);
 	}
 
 	for (i = 0; i < nb_rxq; ++i) {
-- 
2.25.1

