]> git.droids-corp.org - dpdk.git/commitdiff
examples/ethtool: close port before exit
authorHuisong Li <lihuisong@huawei.com>
Thu, 6 May 2021 03:46:08 +0000 (11:46 +0800)
committerDavid Marchand <david.marchand@redhat.com>
Wed, 17 Nov 2021 17:43:21 +0000 (18:43 +0100)
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>
examples/ethtool/ethtool-app/main.c

index cdd9e9b60bd88d6cce083aa88adacee9388e3a18..1f011a932166e70adb7343b8c51ff41ec796e9ea 100644 (file)
@@ -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();