DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Min Hu (Connor)" <humin29@huawei.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@intel.com>
Subject: [dpdk-dev] [PATCH 2/2] examples/ethtool: add closing port operation
Date: Thu, 8 Apr 2021 18:14:48 +0800
Message-ID: <1617876888-63458-3-git-send-email-humin29@huawei.com> (raw)
In-Reply-To: <1617876888-63458-1-git-send-email-humin29@huawei.com>

From: Huisong Li <lihuisong@huawei.com>

Currently, ethtool directly ends the process after 'quit' cmd. In this
case, software resources are not released and hardware resources of the
device are not uninstalled.

This patch adds closing port operation to release resources.

Fixes: bda68ab9d1e7 ("examples/ethtool: add user-space ethtool sample application")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 examples/ethtool/ethtool-app/main.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/examples/ethtool/ethtool-app/main.c b/examples/ethtool/ethtool-app/main.c
index c6023a1..adabe6e 100644
--- a/examples/ethtool/ethtool-app/main.c
+++ b/examples/ethtool/ethtool-app/main.c
@@ -256,6 +256,27 @@ static int worker_main(__rte_unused void *ptr_data)
 	return 0;
 }
 
+static void close_ports(void)
+{
+	uint16_t portid;
+	int ret;
+
+	for (portid = 0; portid < app_cfg.cnt_ports; portid++) {
+		printf("Closing port %d...", portid);
+		ret = rte_eth_dev_stop(portid);
+		if (ret != 0)
+			rte_exit(EXIT_FAILURE, "rte_eth_dev_stop: err=%s, port=%u\n",
+				 strerror(-ret), portid);
+		rte_eth_dev_close(portid);
+		printf(" Done\n");
+	}
+
+	ret = rte_eal_cleanup();
+	if (ret != 0)
+		rte_exit(EXIT_FAILURE, "EAL cleanup failed: %s\n",
+			 strerror(-ret));
+}
+
 int main(int argc, char **argv)
 {
 	int cnt_args_parsed;
@@ -299,5 +320,7 @@ int main(int argc, char **argv)
 			return -1;
 	}
 
+	close_ports();
+
 	return 0;
 }
-- 
2.7.4


  parent reply	other threads:[~2021-04-08 10:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-08 10:14 [dpdk-dev] [PATCH 0/2] fix bugs for ethtool APP Min Hu (Connor)
2021-04-08 10:14 ` [dpdk-dev] [PATCH 1/2] examples/ethtool: fix Rx/Tx queue setup with rte socket id Min Hu (Connor)
2021-04-20  0:57   ` Thomas Monjalon
2021-04-20  9:05     ` Min Hu (Connor)
2021-04-20  9:37       ` Thomas Monjalon
2021-04-08 10:14 ` Min Hu (Connor) [this message]
2021-04-20  0:59   ` [dpdk-dev] [PATCH 2/2] examples/ethtool: add closing port operation Thomas Monjalon
2021-04-20  9:10     ` Min Hu (Connor)
2021-04-20  9:38       ` Thomas Monjalon
2021-05-06  3:46 ` [dpdk-dev] [PATCH v2 0/2] fix bugs for ethtool APP Min Hu (Connor)
2021-05-06  3:46   ` [dpdk-dev] [PATCH v2 1/2] examples/ethtool: fix Rx/Tx queue setup with rte socket id Min Hu (Connor)
2021-09-28  1:34     ` Min Hu (Connor)
2021-05-06  3:46   ` [dpdk-dev] [PATCH v2 2/2] examples/ethtool: add closing port operation Min Hu (Connor)
2021-09-28  1:22     ` Min Hu (Connor)
2021-11-17 17:15     ` David Marchand
2021-06-28  3:22   ` [dpdk-dev] [PATCH v2 0/2] fix bugs for ethtool APP Min Hu (Connor)
2021-07-17  2:24     ` Min Hu (Connor)

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=1617876888-63458-3-git-send-email-humin29@huawei.com \
    --to=humin29@huawei.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    /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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git