From: Hemant Agrawal <hemant.agrawal@nxp.com>
To: dev@dpdk.org, stephen@networkplumber.org,
david.marchand@redhat.com, maxime@leroys.fr
Subject: [PATCH v2 4/5] net/dpaa2: bifurcate close into close and deinit
Date: Thu, 13 Nov 2025 10:59:30 +0530 [thread overview]
Message-ID: <20251113052931.1784953-4-hemant.agrawal@nxp.com> (raw)
In-Reply-To: <20251113052931.1784953-1-hemant.agrawal@nxp.com>
The close function was overloaded to be also used as deinit function.
This can cause issues when using functions like hotplug.
This patch cleans up the code and implement separate close and deinit
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
drivers/net/dpaa2/dpaa2_ethdev.c | 92 ++++++++++++++++++--------------
1 file changed, 51 insertions(+), 41 deletions(-)
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index f82c50341d..0cd875d715 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -1524,53 +1524,14 @@ dpaa2_dev_stop(struct rte_eth_dev *dev)
static int
dpaa2_dev_close(struct rte_eth_dev *dev)
{
- struct dpaa2_dev_priv *priv = dev->data->dev_private;
- struct fsl_mc_io *dpni = dev->process_private;
- int i, ret;
- struct rte_eth_link link;
-
PMD_INIT_FUNC_TRACE();
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;
- if (!dpni) {
- DPAA2_PMD_WARN("Already closed or not started");
- return -EINVAL;
- }
-
dpaa2_tm_deinit(dev);
dpaa2_flow_clean(dev);
- /* Clean the device first */
- ret = dpni_reset(dpni, CMD_PRI_LOW, priv->token);
- if (ret) {
- DPAA2_PMD_ERR("Failure cleaning dpni device: err=%d", ret);
- return ret;
- }
-
- memset(&link, 0, sizeof(link));
- rte_eth_linkstatus_set(dev, &link);
-
- /* Free private queues memory */
- dpaa2_free_rx_tx_queues(dev);
- /* Close the device at underlying layer*/
- ret = dpni_close(dpni, CMD_PRI_LOW, priv->token);
- if (ret) {
- DPAA2_PMD_ERR("Failure closing dpni device with err code %d",
- ret);
- }
-
- /* Free the allocated memory for ethernet private data and dpni*/
- priv->hw = NULL;
- dev->process_private = NULL;
- rte_free(dpni);
- for (i = 0; i < MAX_TCS; i++)
- rte_free(priv->extract.tc_extract_param[i]);
-
- rte_free(priv->extract.qos_extract_param);
-
- DPAA2_PMD_INFO("%s: netdev deleted", dev->data->name);
return 0;
}
@@ -2891,6 +2852,55 @@ dpaa2_get_devargs(struct rte_devargs *devargs, const char *key)
return 1;
}
+static int
+dpaa2_dev_deinit(struct rte_eth_dev *dev)
+{
+ struct dpaa2_dev_priv *priv = dev->data->dev_private;
+ struct fsl_mc_io *dpni = dev->process_private;
+ int i, ret;
+ struct rte_eth_link link;
+
+ PMD_INIT_FUNC_TRACE();
+
+ if (!dpni) {
+ DPAA2_PMD_WARN("Already closed or not started");
+ return -EINVAL;
+ }
+
+ /* Clean the device first */
+ ret = dpni_reset(dpni, CMD_PRI_LOW, priv->token);
+ if (ret) {
+ DPAA2_PMD_ERR("Failure cleaning dpni device: err=%d", ret);
+ return ret;
+ }
+
+ memset(&link, 0, sizeof(link));
+ rte_eth_linkstatus_set(dev, &link);
+
+ /* Free private queues memory */
+ dpaa2_free_rx_tx_queues(dev);
+ /* Close the device at underlying layer*/
+ ret = dpni_close(dpni, CMD_PRI_LOW, priv->token);
+ if (ret) {
+ DPAA2_PMD_ERR("Failure closing dpni device with err code %d",
+ ret);
+ }
+
+ /* Free the allocated memory for ethernet private data and dpni*/
+ priv->hw = NULL;
+ dev->process_private = NULL;
+ rte_free(dpni);
+
+ for (i = 0; i < MAX_TCS; i++)
+ rte_free(priv->extract.tc_extract_param[i]);
+
+ rte_free(priv->extract.qos_extract_param);
+
+ DPAA2_PMD_INFO("%s: netdev deleted", dev->data->name);
+ return 0;
+}
+
+
static int
dpaa2_dev_init(struct rte_eth_dev *eth_dev)
{
@@ -3177,7 +3187,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
return 0;
init_err:
- dpaa2_dev_close(eth_dev);
+ dpaa2_dev_deinit(eth_dev);
return ret;
}
@@ -3381,7 +3391,7 @@ rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev)
eth_dev = rte_eth_dev_allocated(dpaa2_dev->device.name);
if (eth_dev) {
- dpaa2_dev_close(eth_dev);
+ dpaa2_dev_deinit(eth_dev);
ret = rte_eth_dev_release_port(eth_dev);
}
--
2.25.1
next prev parent reply other threads:[~2025-11-13 5:30 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-06 16:38 [PATCH 1/3] net/dpaa2: fix duplicate calling of dpaa2 dev close Hemant Agrawal
2025-11-06 16:38 ` [PATCH 2/3] net/dpaa2: clear active VDQ state when freeing Rx queues Hemant Agrawal
2025-11-06 19:29 ` Stephen Hemminger
2025-11-07 9:51 ` Maxime Leroy
2025-11-07 10:38 ` Hemant Agrawal
2025-11-07 8:34 ` David Marchand
2025-11-06 16:38 ` [PATCH 3/3] bus/fslmc: add support for hotplug of dpni Hemant Agrawal
2025-11-07 8:32 ` [PATCH 1/3] net/dpaa2: fix duplicate calling of dpaa2 dev close David Marchand
2025-11-08 15:35 ` David Marchand
2025-11-12 23:06 ` Stephen Hemminger
2025-11-13 5:29 ` [PATCH v2 1/5] " Hemant Agrawal
2025-11-13 5:29 ` [PATCH v2 2/5] net/dpaa2: clear active VDQ state when freeing Rx queues Hemant Agrawal
2025-11-13 5:29 ` [PATCH v2 3/5] net/dpaa2: fix queue free cleanup Hemant Agrawal
2025-11-13 5:29 ` Hemant Agrawal [this message]
2025-11-13 5:29 ` [PATCH v2 5/5] bus/fslmc: add support for hotplug of dpni Hemant Agrawal
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=20251113052931.1784953-4-hemant.agrawal@nxp.com \
--to=hemant.agrawal@nxp.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=maxime@leroys.fr \
--cc=stephen@networkplumber.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).