From: Ferruh Yigit <ferruh.yigit@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] net/kni: remove resources when port is closed
Date: Fri, 26 Jul 2019 17:33:04 +0100 [thread overview]
Message-ID: <20190726163304.67773-1-ferruh.yigit@intel.com> (raw)
Add .dev_close to clean resources on device close,
also set RTE_ETH_DEV_CLOSE_REMOVE device flag to cause all ethdev
resources removed on 'rte_eth_dev_close()' call.
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
drivers/net/kni/rte_eth_kni.c | 38 +++++++++++++++++++++++------------
1 file changed, 25 insertions(+), 13 deletions(-)
diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c
index 9e0c6bd2f..d12b49aaf 100644
--- a/drivers/net/kni/rte_eth_kni.c
+++ b/drivers/net/kni/rte_eth_kni.c
@@ -197,6 +197,24 @@ eth_kni_dev_stop(struct rte_eth_dev *dev)
dev->data->dev_link.link_status = 0;
}
+static void
+eth_kni_close(struct rte_eth_dev *eth_dev)
+{
+ struct pmd_internals *internals;
+ int ret;
+
+ eth_kni_dev_stop(eth_dev);
+
+ /* mac_addrs must not be freed alone because part of dev_private */
+ eth_dev->data->mac_addrs = NULL;
+
+ internals = eth_dev->data->dev_private;
+ ret = rte_kni_release(internals->kni);
+ if (ret)
+ PMD_LOG(WARNING, "Not able to release kni for %s",
+ eth_dev->data->name);
+}
+
static int
eth_kni_dev_configure(struct rte_eth_dev *dev __rte_unused)
{
@@ -327,6 +345,7 @@ eth_kni_stats_reset(struct rte_eth_dev *dev)
static const struct eth_dev_ops eth_kni_ops = {
.dev_start = eth_kni_dev_start,
.dev_stop = eth_kni_dev_stop,
+ .dev_close = eth_kni_close,
.dev_configure = eth_kni_dev_configure,
.dev_infos_get = eth_kni_dev_info,
.rx_queue_setup = eth_kni_rx_queue_setup,
@@ -362,6 +381,8 @@ eth_kni_create(struct rte_vdev_device *vdev,
data->dev_link = pmd_link;
data->mac_addrs = &internals->eth_addr;
+ data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
+
rte_eth_random_addr(internals->eth_addr.addr_bytes);
eth_dev->dev_ops = ð_kni_ops;
@@ -456,9 +477,7 @@ static int
eth_kni_remove(struct rte_vdev_device *vdev)
{
struct rte_eth_dev *eth_dev;
- struct pmd_internals *internals;
const char *name;
- int ret;
name = rte_vdev_device_name(vdev);
PMD_LOG(INFO, "Un-Initializing eth_kni for %s", name);
@@ -468,19 +487,12 @@ eth_kni_remove(struct rte_vdev_device *vdev)
if (eth_dev == NULL)
return -1;
- /* mac_addrs must not be freed alone because part of dev_private */
- eth_dev->data->mac_addrs = NULL;
-
- if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+ eth_kni_dev_stop(eth_dev);
return rte_eth_dev_release_port(eth_dev);
+ }
- eth_kni_dev_stop(eth_dev);
-
- internals = eth_dev->data->dev_private;
- ret = rte_kni_release(internals->kni);
- if (ret)
- PMD_LOG(WARNING, "Not able to release kni for %s", name);
-
+ eth_kni_close(eth_dev);
rte_eth_dev_release_port(eth_dev);
is_kni_initialized--;
--
2.21.0
next reply other threads:[~2019-07-26 16:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-26 16:33 Ferruh Yigit [this message]
2019-09-13 17:54 ` 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=20190726163304.67773-1-ferruh.yigit@intel.com \
--to=ferruh.yigit@intel.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).