From: Andrew Rybchenko <arybchenko@solarflare.com>
To: <dev@dpdk.org>
Subject: [dpdk-dev] [PATCH 3/3] net/sfc: release port upon close
Date: Fri, 21 Jun 2019 10:40:41 +0100 [thread overview]
Message-ID: <1561110041-1795-3-git-send-email-arybchenko@solarflare.com> (raw)
In-Reply-To: <1561110041-1795-1-git-send-email-arybchenko@solarflare.com>
Set RTE_ETH_DEV_CLOSE_REMOVE upon probe so all the resources
for the port can be freed by rte_eth_dev_close() and the ethdev
port freed.
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Ivan Malov <ivan.malov@oktetlabs.ru>
---
drivers/net/sfc/sfc_ethdev.c | 51 ++++++++++++++++++------------------
1 file changed, 26 insertions(+), 25 deletions(-)
diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 583f31b8c..279b58641 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -34,6 +34,10 @@ uint32_t sfc_logtype_driver;
static struct sfc_dp_list sfc_dp_head =
TAILQ_HEAD_INITIALIZER(sfc_dp_head);
+
+static void sfc_eth_dev_clear_ops(struct rte_eth_dev *dev);
+
+
static int
sfc_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
{
@@ -335,9 +339,29 @@ sfc_dev_close(struct rte_eth_dev *dev)
sfc_err(sa, "unexpected adapter state %u on close", sa->state);
break;
}
+
+ /*
+ * Cleanup all resources in accordance with RTE_ETH_DEV_CLOSE_REMOVE.
+ * Rollback primary process sfc_eth_dev_init() below.
+ */
+
+ sfc_eth_dev_clear_ops(dev);
+
+ sfc_detach(sa);
+ sfc_unprobe(sa);
+
+ sfc_kvargs_cleanup(sa);
+
sfc_adapter_unlock(sa);
+ sfc_adapter_lock_fini(sa);
sfc_log_init(sa, "done");
+
+ /* Required for logging, so cleanup last */
+ sa->eth_dev = NULL;
+
+ dev->process_private = NULL;
+ free(sa);
}
static void
@@ -2123,6 +2147,8 @@ sfc_eth_dev_init(struct rte_eth_dev *dev)
sfc_log_init(sa, "entry");
+ dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
+
dev->data->mac_addrs = rte_zmalloc("sfc", RTE_ETHER_ADDR_LEN, 0);
if (dev->data->mac_addrs == NULL) {
rc = ENOMEM;
@@ -2189,8 +2215,6 @@ sfc_eth_dev_init(struct rte_eth_dev *dev)
static int
sfc_eth_dev_uninit(struct rte_eth_dev *dev)
{
- struct sfc_adapter *sa;
-
if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
sfc_eth_dev_secondary_clear_ops(dev);
return 0;
@@ -2198,29 +2222,6 @@ sfc_eth_dev_uninit(struct rte_eth_dev *dev)
sfc_dev_close(dev);
- sa = sfc_adapter_by_eth_dev(dev);
- sfc_log_init(sa, "entry");
-
- sfc_adapter_lock(sa);
-
- sfc_eth_dev_clear_ops(dev);
-
- sfc_detach(sa);
- sfc_unprobe(sa);
-
- sfc_kvargs_cleanup(sa);
-
- sfc_adapter_unlock(sa);
- sfc_adapter_lock_fini(sa);
-
- sfc_log_init(sa, "done");
-
- /* Required for logging, so cleanup last */
- sa->eth_dev = NULL;
-
- dev->process_private = NULL;
- free(sa);
-
return 0;
}
--
2.17.1
next prev parent reply other threads:[~2019-06-21 9:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-21 9:40 [dpdk-dev] [PATCH 1/3] ethdev: avoid error on PCI unplug of already closed ethdev Andrew Rybchenko
2019-06-21 9:40 ` [dpdk-dev] [PATCH 2/3] net/sfc: ensure that device is closed on removal Andrew Rybchenko
2019-06-21 9:40 ` Andrew Rybchenko [this message]
2019-06-21 9:52 ` [dpdk-dev] [dpdk-stable] [PATCH 1/3] ethdev: avoid error on PCI unplug of already closed ethdev David Marchand
2019-06-21 10:15 ` Andrew Rybchenko
2019-07-02 17:38 ` Ferruh Yigit
2019-07-03 13:55 ` 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=1561110041-1795-3-git-send-email-arybchenko@solarflare.com \
--to=arybchenko@solarflare.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).