DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/nfb: remove resources when dev is closed
@ 2019-08-09 14:59 Rastislav Cernay
  2019-08-09 15:01 ` Jan Remeš
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Rastislav Cernay @ 2019-08-09 14:59 UTC (permalink / raw)
  To: dev; +Cc: Rastislav Cernay

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>
---
 drivers/net/nfb/nfb_ethdev.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/net/nfb/nfb_ethdev.c b/drivers/net/nfb/nfb_ethdev.c
index c3119a0..4a19979 100644
--- a/drivers/net/nfb/nfb_ethdev.c
+++ b/drivers/net/nfb/nfb_ethdev.c
@@ -210,12 +210,17 @@
 static void
 nfb_eth_dev_close(struct rte_eth_dev *dev)
 {
+	struct pmd_internals *internals = (struct pmd_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;
 
 	nfb_eth_dev_stop(dev);
 
+	nfb_nc_rxmac_deinit(internals->rxmac, internals->max_rxmac);
+	nfb_nc_txmac_deinit(internals->txmac, internals->max_txmac);
+
 	for (i = 0; i < nb_rx; i++) {
 		nfb_eth_rx_queue_release(dev->data->rx_queues[i]);
 		dev->data->rx_queues[i] = NULL;
@@ -226,6 +231,9 @@
 		dev->data->tx_queues[i] = NULL;
 	}
 	dev->data->nb_tx_queues = 0;
+
+	rte_free(dev->data->mac_addrs);
+	dev->data->mac_addrs = NULL;
 }
 
 /**
@@ -446,6 +454,9 @@
 		rte_kvargs_free(kvlist);
 	}
 
+	/* Let rte_eth_dev_close() release the port resources */
+	dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
+
 	/*
 	 * Get number of available DMA RX and TX queues, which is maximum
 	 * number of queues that can be created and store it in private device
@@ -520,15 +531,10 @@
 static int
 nfb_eth_dev_uninit(struct rte_eth_dev *dev)
 {
-	struct rte_eth_dev_data *data = dev->data;
-	struct pmd_internals *internals = (struct pmd_internals *)
-		data->dev_private;
-
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	struct rte_pci_addr *pci_addr = &pci_dev->addr;
 
-	nfb_nc_rxmac_deinit(internals->rxmac, internals->max_rxmac);
-	nfb_nc_txmac_deinit(internals->txmac, internals->max_txmac);
+	nfb_eth_dev_close(dev);
 
 	RTE_LOG(INFO, PMD, "NFB device ("
 		PCI_PRI_FMT ") successfully uninitialized\n",
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] net/nfb: remove resources when dev is closed
  2019-08-09 14:59 [dpdk-dev] [PATCH] net/nfb: remove resources when dev is closed Rastislav Cernay
@ 2019-08-09 15:01 ` Jan Remeš
  2019-08-10 12:51 ` Ye Xiaolong
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Jan Remeš @ 2019-08-09 15:01 UTC (permalink / raw)
  To: Rastislav Cernay; +Cc: dev

Acked-by: Jan Remes <remes@netcope.com>

On Fri, Aug 9, 2019 at 4:59 PM Rastislav Cernay <cernay@netcope.com> wrote:
>
> 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>
> ---
>  drivers/net/nfb/nfb_ethdev.c | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/nfb/nfb_ethdev.c b/drivers/net/nfb/nfb_ethdev.c
> index c3119a0..4a19979 100644
> --- a/drivers/net/nfb/nfb_ethdev.c
> +++ b/drivers/net/nfb/nfb_ethdev.c
> @@ -210,12 +210,17 @@
>  static void
>  nfb_eth_dev_close(struct rte_eth_dev *dev)
>  {
> +       struct pmd_internals *internals = (struct pmd_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;
>
>         nfb_eth_dev_stop(dev);
>
> +       nfb_nc_rxmac_deinit(internals->rxmac, internals->max_rxmac);
> +       nfb_nc_txmac_deinit(internals->txmac, internals->max_txmac);
> +
>         for (i = 0; i < nb_rx; i++) {
>                 nfb_eth_rx_queue_release(dev->data->rx_queues[i]);
>                 dev->data->rx_queues[i] = NULL;
> @@ -226,6 +231,9 @@
>                 dev->data->tx_queues[i] = NULL;
>         }
>         dev->data->nb_tx_queues = 0;
> +
> +       rte_free(dev->data->mac_addrs);
> +       dev->data->mac_addrs = NULL;
>  }
>
>  /**
> @@ -446,6 +454,9 @@
>                 rte_kvargs_free(kvlist);
>         }
>
> +       /* Let rte_eth_dev_close() release the port resources */
> +       dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
> +
>         /*
>          * Get number of available DMA RX and TX queues, which is maximum
>          * number of queues that can be created and store it in private device
> @@ -520,15 +531,10 @@
>  static int
>  nfb_eth_dev_uninit(struct rte_eth_dev *dev)
>  {
> -       struct rte_eth_dev_data *data = dev->data;
> -       struct pmd_internals *internals = (struct pmd_internals *)
> -               data->dev_private;
> -
>         struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
>         struct rte_pci_addr *pci_addr = &pci_dev->addr;
>
> -       nfb_nc_rxmac_deinit(internals->rxmac, internals->max_rxmac);
> -       nfb_nc_txmac_deinit(internals->txmac, internals->max_txmac);
> +       nfb_eth_dev_close(dev);
>
>         RTE_LOG(INFO, PMD, "NFB device ("
>                 PCI_PRI_FMT ") successfully uninitialized\n",
> --
> 1.8.3.1
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] net/nfb: remove resources when dev is closed
  2019-08-09 14:59 [dpdk-dev] [PATCH] net/nfb: remove resources when dev is closed Rastislav Cernay
  2019-08-09 15:01 ` Jan Remeš
@ 2019-08-10 12:51 ` Ye Xiaolong
  2019-08-12 11:19 ` [dpdk-dev] [PATCH v2] net/nfb: remove resources when port " Rastislav Cernay
  2019-08-27 20:37 ` [dpdk-dev] [PATCH v3] " Rastislav Cernay
  3 siblings, 0 replies; 7+ messages in thread
From: Ye Xiaolong @ 2019-08-10 12:51 UTC (permalink / raw)
  To: Rastislav Cernay; +Cc: dev

On 08/09, Rastislav Cernay wrote:
>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>
>---
> drivers/net/nfb/nfb_ethdev.c | 18 ++++++++++++------
> 1 file changed, 12 insertions(+), 6 deletions(-)
>
>diff --git a/drivers/net/nfb/nfb_ethdev.c b/drivers/net/nfb/nfb_ethdev.c
>index c3119a0..4a19979 100644
>--- a/drivers/net/nfb/nfb_ethdev.c
>+++ b/drivers/net/nfb/nfb_ethdev.c
>@@ -210,12 +210,17 @@
> static void
> nfb_eth_dev_close(struct rte_eth_dev *dev)
> {
>+	struct pmd_internals *internals = (struct pmd_internals *)
>+		dev->data->dev_private;

The device private pointer (dev_private) is of type void *, therefore this
cast is unnecessary.

> 	uint16_t i;
> 	uint16_t nb_rx = dev->data->nb_rx_queues;
> 	uint16_t nb_tx = dev->data->nb_tx_queues;
> 
> 	nfb_eth_dev_stop(dev);
> 
>+	nfb_nc_rxmac_deinit(internals->rxmac, internals->max_rxmac);
>+	nfb_nc_txmac_deinit(internals->txmac, internals->max_txmac);
>+
> 	for (i = 0; i < nb_rx; i++) {
> 		nfb_eth_rx_queue_release(dev->data->rx_queues[i]);
> 		dev->data->rx_queues[i] = NULL;
>@@ -226,6 +231,9 @@
> 		dev->data->tx_queues[i] = NULL;
> 	}
> 	dev->data->nb_tx_queues = 0;
>+
>+	rte_free(dev->data->mac_addrs);
>+	dev->data->mac_addrs = NULL;
> }
> 
> /**
>@@ -446,6 +454,9 @@
> 		rte_kvargs_free(kvlist);
> 	}
> 
>+	/* Let rte_eth_dev_close() release the port resources */
>+	dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
>+
> 	/*
> 	 * Get number of available DMA RX and TX queues, which is maximum
> 	 * number of queues that can be created and store it in private device
>@@ -520,15 +531,10 @@
> static int
> nfb_eth_dev_uninit(struct rte_eth_dev *dev)
> {
>-	struct rte_eth_dev_data *data = dev->data;
>-	struct pmd_internals *internals = (struct pmd_internals *)
>-		data->dev_private;
>-
> 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
> 	struct rte_pci_addr *pci_addr = &pci_dev->addr;
> 
>-	nfb_nc_rxmac_deinit(internals->rxmac, internals->max_rxmac);
>-	nfb_nc_txmac_deinit(internals->txmac, internals->max_txmac);
>+	nfb_eth_dev_close(dev);
> 
> 	RTE_LOG(INFO, PMD, "NFB device ("
> 		PCI_PRI_FMT ") successfully uninitialized\n",
>-- 
>1.8.3.1
>

For the rest,

Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-dev] [PATCH v2] net/nfb: remove resources when port is closed
  2019-08-09 14:59 [dpdk-dev] [PATCH] net/nfb: remove resources when dev is closed Rastislav Cernay
  2019-08-09 15:01 ` Jan Remeš
  2019-08-10 12:51 ` Ye Xiaolong
@ 2019-08-12 11:19 ` Rastislav Cernay
  2019-08-27 12:08   ` Ferruh Yigit
  2019-08-27 20:37 ` [dpdk-dev] [PATCH v3] " Rastislav Cernay
  3 siblings, 1 reply; 7+ messages in thread
From: Rastislav Cernay @ 2019-08-12 11:19 UTC (permalink / raw)
  To: dev; +Cc: Rastislav Cernay

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/nfb: remove resources when port is closed
  2019-08-12 11:19 ` [dpdk-dev] [PATCH v2] net/nfb: remove resources when port " Rastislav Cernay
@ 2019-08-27 12:08   ` Ferruh Yigit
  0 siblings, 0 replies; 7+ messages in thread
From: Ferruh Yigit @ 2019-08-27 12:08 UTC (permalink / raw)
  To: Rastislav Cernay, dev

On 8/12/2019 12:19 PM, Rastislav Cernay wrote:
> 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(-)

Hi Rastislav,

The first version of this patch is for 'nfb' driver [1], ack/review is based on
that path. But this patch, v2, is for 'szedata2' driver. It looks like something
went wrong.

But both driver needs this update, can you please send a proper new version for
'nfb' (v3) and a new 'szedata2' patch?

Thanks,
ferruh


[1]
https://mails.dpdk.org/archives/dev/2019-August/140864.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-dev] [PATCH v3] net/nfb: remove resources when port is closed
  2019-08-09 14:59 [dpdk-dev] [PATCH] net/nfb: remove resources when dev is closed Rastislav Cernay
                   ` (2 preceding siblings ...)
  2019-08-12 11:19 ` [dpdk-dev] [PATCH v2] net/nfb: remove resources when port " Rastislav Cernay
@ 2019-08-27 20:37 ` Rastislav Cernay
  2019-08-28 17:20   ` Ferruh Yigit
  3 siblings, 1 reply; 7+ messages in thread
From: Rastislav Cernay @ 2019-08-27 20:37 UTC (permalink / raw)
  To: dev; +Cc: Rastislav Cernay

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>
Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
Acked-by: Jan Remes <remes@netcope.com>
---
v2: remove unnecessary cast
v3: send correct patch
drivers/net/nfb/nfb_ethdev.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/net/nfb/nfb_ethdev.c b/drivers/net/nfb/nfb_ethdev.c
index c3119a0..f4093d4 100644
--- a/drivers/net/nfb/nfb_ethdev.c
+++ b/drivers/net/nfb/nfb_ethdev.c
@@ -210,12 +210,16 @@
 static void
 nfb_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;
 
 	nfb_eth_dev_stop(dev);
 
+	nfb_nc_rxmac_deinit(internals->rxmac, internals->max_rxmac);
+	nfb_nc_txmac_deinit(internals->txmac, internals->max_txmac);
+
 	for (i = 0; i < nb_rx; i++) {
 		nfb_eth_rx_queue_release(dev->data->rx_queues[i]);
 		dev->data->rx_queues[i] = NULL;
@@ -226,6 +230,9 @@
 		dev->data->tx_queues[i] = NULL;
 	}
 	dev->data->nb_tx_queues = 0;
+
+	rte_free(dev->data->mac_addrs);
+	dev->data->mac_addrs = NULL;
 }
 
 /**
@@ -446,6 +453,9 @@
 		rte_kvargs_free(kvlist);
 	}
 
+	/* Let rte_eth_dev_close() release the port resources */
+	dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
+
 	/*
 	 * Get number of available DMA RX and TX queues, which is maximum
 	 * number of queues that can be created and store it in private device
@@ -520,15 +530,10 @@
 static int
 nfb_eth_dev_uninit(struct rte_eth_dev *dev)
 {
-	struct rte_eth_dev_data *data = dev->data;
-	struct pmd_internals *internals = (struct pmd_internals *)
-		data->dev_private;
-
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	struct rte_pci_addr *pci_addr = &pci_dev->addr;
 
-	nfb_nc_rxmac_deinit(internals->rxmac, internals->max_rxmac);
-	nfb_nc_txmac_deinit(internals->txmac, internals->max_txmac);
+	nfb_eth_dev_close(dev);
 
 	RTE_LOG(INFO, PMD, "NFB device ("
 		PCI_PRI_FMT ") successfully uninitialized\n",
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH v3] net/nfb: remove resources when port is closed
  2019-08-27 20:37 ` [dpdk-dev] [PATCH v3] " Rastislav Cernay
@ 2019-08-28 17:20   ` Ferruh Yigit
  0 siblings, 0 replies; 7+ messages in thread
From: Ferruh Yigit @ 2019-08-28 17:20 UTC (permalink / raw)
  To: Rastislav Cernay, dev

On 8/27/2019 9:37 PM, Rastislav Cernay wrote:
> 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>
> Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
> Acked-by: Jan Remes <remes@netcope.com>

Applied to dpdk-next-net/master, thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-08-28 17:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-09 14:59 [dpdk-dev] [PATCH] net/nfb: remove resources when dev is closed Rastislav Cernay
2019-08-09 15:01 ` Jan Remeš
2019-08-10 12:51 ` Ye Xiaolong
2019-08-12 11:19 ` [dpdk-dev] [PATCH v2] net/nfb: remove resources when port " Rastislav Cernay
2019-08-27 12:08   ` Ferruh Yigit
2019-08-27 20:37 ` [dpdk-dev] [PATCH v3] " Rastislav Cernay
2019-08-28 17:20   ` Ferruh Yigit

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).