DPDK patches and discussions
 help / color / mirror / Atom feed
From: Rastislav Cernay <cernay@netcope.com>
To: dev@dpdk.org
Cc: Rastislav Cernay <cernay@netcope.com>
Subject: [dpdk-dev] [PATCH v2] net/nfb: remove resources when port is closed
Date: Mon, 12 Aug 2019 13:19:38 +0200	[thread overview]
Message-ID: <1565608778-17185-1-git-send-email-cernay@netcope.com> (raw)
In-Reply-To: <1565362745-152027-1-git-send-email-cernay@netcope.com>

From: Rastislav Cernay <cernay@netcope.com>

The rte_eth_dev_close() function now handles freeing resources for
devices (e.g., mac_addrs).  To conform with the new close() behaviour we
are asserting the RTE_ETH_DEV_CLOSE_REMOVE flag so that
rte_eth_dev_close() releases all device level dynamic memory.

Signed-off-by: Rastislav Cernay <cernay@netcope.com>
Acked-by: Jan Remes <remes@netcope.com>
Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
---
v2: remove unnecessary cast
 drivers/net/szedata2/rte_eth_szedata2.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c
index d5dec1b..99d5ca5 100644
--- a/drivers/net/szedata2/rte_eth_szedata2.c
+++ b/drivers/net/szedata2/rte_eth_szedata2.c
@@ -1157,12 +1157,15 @@ struct szedata2_tx_queue {
 static void
 eth_dev_close(struct rte_eth_dev *dev)
 {
+	struct pmd_internals *internals = dev->data->dev_private;
 	uint16_t i;
 	uint16_t nb_rx = dev->data->nb_rx_queues;
 	uint16_t nb_tx = dev->data->nb_tx_queues;
 
 	eth_dev_stop(dev);
 
+	free(internals->sze_dev_path);
+
 	for (i = 0; i < nb_rx; i++) {
 		eth_rx_queue_release(dev->data->rx_queues[i]);
 		dev->data->rx_queues[i] = NULL;
@@ -1173,6 +1176,9 @@ struct szedata2_tx_queue {
 		dev->data->tx_queues[i] = NULL;
 	}
 	dev->data->nb_tx_queues = 0;
+
+	rte_free(dev->data->mac_addrs);
+	dev->data->mac_addrs = NULL;
 }
 
 static int
@@ -1475,6 +1481,9 @@ struct szedata2_tx_queue {
 	PMD_INIT_LOG(INFO, "Initializing eth_dev %s (driver %s)", data->name,
 			RTE_STR(RTE_SZEDATA2_DRIVER_NAME));
 
+	/* Let rte_eth_dev_close() release the port resources */
+	dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
+
 	/* Fill internal private structure. */
 	internals->dev = dev;
 	/* Get index of szedata2 device file and create path to device file */
@@ -1537,12 +1546,9 @@ struct szedata2_tx_queue {
 static int
 rte_szedata2_eth_dev_uninit(struct rte_eth_dev *dev)
 {
-	struct pmd_internals *internals = (struct pmd_internals *)
-		dev->data->dev_private;
-
 	PMD_INIT_FUNC_TRACE();
 
-	free(internals->sze_dev_path);
+	eth_dev_close(dev);
 
 	PMD_DRV_LOG(INFO, "%s device %s successfully uninitialized",
 			RTE_STR(RTE_SZEDATA2_DRIVER_NAME), dev->data->name);
-- 
1.8.3.1


  parent reply	other threads:[~2019-08-12 11:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-09 14:59 [dpdk-dev] [PATCH] net/nfb: remove resources when dev " Rastislav Cernay
2019-08-09 15:01 ` Jan Remeš
2019-08-10 12:51 ` Ye Xiaolong
2019-08-12 11:19 ` Rastislav Cernay [this message]
2019-08-27 12:08   ` [dpdk-dev] [PATCH v2] net/nfb: remove resources when port " Ferruh Yigit
2019-08-27 20:37 ` [dpdk-dev] [PATCH v3] " Rastislav Cernay
2019-08-28 17:20   ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1565608778-17185-1-git-send-email-cernay@netcope.com \
    --to=cernay@netcope.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).