bonding: free queue memory when closing
[dpdk.git] / drivers / net / bonding / rte_eth_bond_pmd.c
index 9cafe65..5cc6372 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -1513,6 +1513,24 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
 }
 
 static void
+bond_ethdev_free_queues(struct rte_eth_dev *dev)
+{
+       uint8_t i;
+
+       for (i = 0; i < dev->data->nb_rx_queues; i++) {
+               rte_free(dev->data->rx_queues[i]);
+               dev->data->rx_queues[i] = NULL;
+       }
+       dev->data->nb_rx_queues = 0;
+
+       for (i = 0; i < dev->data->nb_tx_queues; i++) {
+               rte_free(dev->data->tx_queues[i]);
+               dev->data->tx_queues[i] = NULL;
+       }
+       dev->data->nb_tx_queues = 0;
+}
+
+void
 bond_ethdev_stop(struct rte_eth_dev *eth_dev)
 {
        struct bond_dev_private *internals = eth_dev->data->dev_private;
@@ -1552,9 +1570,10 @@ bond_ethdev_stop(struct rte_eth_dev *eth_dev)
        eth_dev->data->dev_started = 0;
 }
 
-static void
-bond_ethdev_close(struct rte_eth_dev *dev __rte_unused)
+void
+bond_ethdev_close(struct rte_eth_dev *dev)
 {
+       bond_ethdev_free_queues(dev);
 }
 
 /* forward declaration */
@@ -2042,6 +2061,24 @@ parse_error:
        return -1;
 }
 
+static int
+bond_uninit(const char *name)
+{
+       int  ret;
+
+       if (name == NULL)
+               return -EINVAL;
+
+       RTE_LOG(INFO, EAL, "Uninitializing pmd_bond for %s\n", name);
+
+       /* free link bonding eth device */
+       ret = rte_eth_bond_free(name);
+       if (ret < 0)
+               RTE_LOG(ERR, EAL, "Failed to free %s\n", name);
+
+       return ret;
+}
+
 /* this part will resolve the slave portids after all the other pdev and vdev
  * have been allocated */
 static int
@@ -2268,6 +2305,7 @@ static struct rte_driver bond_drv = {
        .name = "eth_bond",
        .type = PMD_VDEV,
        .init = bond_init,
+       .uninit = bond_uninit,
 };
 
 PMD_REGISTER_DRIVER(bond_drv);