[dpdk-dev,v6,4/6] virtio: free queue memory in virtio_dev_close()
diff mbox

Message ID 1436968265-14362-5-git-send-email-bernard.iremonger@intel.com
State Accepted, archived
Headers show

Commit Message

Iremonger, Bernard July 15, 2015, 1:51 p.m. UTC
Add function virtio_free_queues() and call from virtio_dev_close()
Use virtio_dev_rx_queue_release() and virtio_dev_tx_queue_release()

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/virtio/virtio_ethdev.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Patch
diff mbox

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 964fcc0..b992898 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -439,6 +439,22 @@  virtio_dev_cq_queue_setup(struct rte_eth_dev *dev, uint16_t vtpci_queue_idx,
 }
 
 static void
+virtio_free_queues(struct rte_eth_dev *dev)
+{
+	unsigned int i;
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++)
+		virtio_dev_rx_queue_release(dev->data->rx_queues[i]);
+
+	dev->data->nb_rx_queues = 0;
+
+	for (i = 0; i < dev->data->nb_tx_queues; i++)
+		virtio_dev_tx_queue_release(dev->data->tx_queues[i]);
+
+	dev->data->nb_tx_queues = 0;
+}
+
+static void
 virtio_dev_close(struct rte_eth_dev *dev)
 {
 	struct virtio_hw *hw = dev->data->dev_private;
@@ -452,6 +468,7 @@  virtio_dev_close(struct rte_eth_dev *dev)
 	vtpci_reset(hw);
 	hw->started = 0;
 	virtio_dev_free_mbufs(dev);
+	virtio_free_queues(dev);
 }
 
 static void