From: Shougang Wang Date: Tue, 24 Sep 2019 04:49:03 +0000 (+0000) Subject: app/testpmd: fix crash on port reset X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=1cde1b9a9b4dbf31cb5e5ccdfc5da3cb079f43a2;p=dpdk.git app/testpmd: fix crash on port reset port reset cause crash when ports are not stopped. Fixed by refusing the reset when port is not stopped. Fixes: 97f1e196799f ("app/testpmd: add port reset command") Cc: stable@dpdk.org Signed-off-by: Shougang Wang Acked-by: Bernard Iremonger --- diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index dd4e6e6021..def471d975 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -758,6 +758,9 @@ static void cmd_help_long_parsed(void *parsed_result, "port close (port_id|all)\n" " Close all ports or port_id.\n\n" + "port reset (port_id|all)\n" + " Reset all ports or port_id.\n\n" + "port attach (ident)\n" " Attach physical or virtual dev by pci address or virtual device name\n\n" diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 1e3dc44a1c..5701f3141f 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2361,6 +2361,12 @@ reset_port(portid_t pid) if (port_id_is_invalid(pid, ENABLED_WARN)) return; + if ((pid == (portid_t)RTE_PORT_ALL && !all_ports_stopped()) || + (pid != (portid_t)RTE_PORT_ALL && !port_is_stopped(pid))) { + printf("Can not reset port(s), please stop port(s) first.\n"); + return; + } + printf("Resetting ports...\n"); RTE_ETH_FOREACH_DEV(pi) { diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 67f4339ca9..cba5ba1b83 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -2041,6 +2041,15 @@ Close all ports or a specific port:: testpmd> port close (port_id|all) +port reset +~~~~~~~~~~ + +Reset all ports or a specific port:: + + testpmd> port reset (port_id|all) + +User should stop port(s) before resetting and (re-)start after reset. + port config - queue ring size ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~