[dpdk-dev,v6,3/3] bonding: free queue memory in stop function

Message ID 1437491784-26676-4-git-send-email-bernard.iremonger@intel.com (mailing list archive)
State Changes Requested, archived
Headers

Commit Message

Iremonger, Bernard July 21, 2015, 3:16 p.m. UTC
  add function bond_ethdev_free_queues() and call from the bond_ethdev_stop() function.

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

Comments

Thomas Monjalon July 27, 2015, 2:48 a.m. UTC | #1
2015-07-21 16:16, Bernard Iremonger:
> add function bond_ethdev_free_queues() and call from the bond_ethdev_stop() function.

Other drivers free their queues when closing.
Why is it done in stop() for bonding?
  
Iremonger, Bernard July 27, 2015, 8:31 a.m. UTC | #2
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Monday, July 27, 2015 3:48 AM
> To: Iremonger, Bernard
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v6 3/3] bonding: free queue memory in stop
> function
> 
> 2015-07-21 16:16, Bernard Iremonger:
> > add function bond_ethdev_free_queues() and call from the
> bond_ethdev_stop() function.
> 
> Other drivers free their queues when closing.
> Why is it done in stop() for bonding?

Hi Thomas,

The close() function  is empty in bonding so I decided to free the queues in the stop() function which is implemented.
The stop() function is called before the close() function, so the effect is the same. 
It would be better to free the queues in the close() function, I will move it there.

Regards,

Bernard.
  
Thomas Monjalon July 27, 2015, 9:55 a.m. UTC | #3
2015-07-27 08:31, Iremonger, Bernard:
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > 2015-07-21 16:16, Bernard Iremonger:
> > > add function bond_ethdev_free_queues() and call from the
> > bond_ethdev_stop() function.
> > 
> > Other drivers free their queues when closing.
> > Why is it done in stop() for bonding?
> 
> Hi Thomas,
> 
> The close() function  is empty in bonding so I decided to free the queues in the stop() function which is implemented.
> The stop() function is called before the close() function, so the effect is the same.

No, the effect is not the same. We can call stop() without close()
and then re-start the port.

> It would be better to free the queues in the close() function, I will move it there.

Yes please.
  

Patch

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index cad8f3c..2221197 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -1512,6 +1512,24 @@  bond_ethdev_start(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+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)
 {
@@ -1550,6 +1568,8 @@  bond_ethdev_stop(struct rte_eth_dev *eth_dev)
 
 	eth_dev->data->dev_link.link_status = 0;
 	eth_dev->data->dev_started = 0;
+
+	bond_ethdev_free_queues(eth_dev);
 }
 
 static void