[v2,2/2] examples/ethtool: add closing port operation

Message ID 1620272768-42421-3-git-send-email-humin29@huawei.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series fix bugs for ethtool APP |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/github-robot success github build: passed
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

humin (Q) May 6, 2021, 3:46 a.m. UTC
  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 | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
  

Comments

humin (Q) Sept. 28, 2021, 1:22 a.m. UTC | #1
Hi, Ferruh,
	any comments?

在 2021/5/6 11:46, Min Hu (Connor) 写道:
> 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 | 18 ++++++++++++++++++
>   1 file changed, 18 insertions(+)
> 
> diff --git a/examples/ethtool/ethtool-app/main.c b/examples/ethtool/ethtool-app/main.c
> index 21ed85c..9ac0a44 100644
> --- a/examples/ethtool/ethtool-app/main.c
> +++ b/examples/ethtool/ethtool-app/main.c
> @@ -256,6 +256,22 @@ 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");
> +	}
> +}
> +
>   int main(int argc, char **argv)
>   {
>   	int cnt_args_parsed;
> @@ -299,6 +315,8 @@ int main(int argc, char **argv)
>   			return -1;
>   	}
>   
> +	close_ports();
> +
>   	/* clean up the EAL */
>   	rte_eal_cleanup();
>   
>
  
David Marchand Nov. 17, 2021, 5:15 p.m. UTC | #2
On Thu, May 6, 2021 at 5:46 AM Min Hu (Connor) <humin29@huawei.com> wrote:
>
> 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.
>
> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>

I see nothing wrong with series and there was no objection.
Series applied, thanks.
  

Patch

diff --git a/examples/ethtool/ethtool-app/main.c b/examples/ethtool/ethtool-app/main.c
index 21ed85c..9ac0a44 100644
--- a/examples/ethtool/ethtool-app/main.c
+++ b/examples/ethtool/ethtool-app/main.c
@@ -256,6 +256,22 @@  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");
+	}
+}
+
 int main(int argc, char **argv)
 {
 	int cnt_args_parsed;
@@ -299,6 +315,8 @@  int main(int argc, char **argv)
 			return -1;
 	}
 
+	close_ports();
+
 	/* clean up the EAL */
 	rte_eal_cleanup();