[v2] app/testpmd: fix Segment fault when start fwd

Message ID 20190920031333.16859-1-shougangx.wang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series [v2] app/testpmd: fix Segment fault when start fwd |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-dpdk_compile_ovs success Compile Testing PASS
ci/iol-dpdk_compile success Compile Testing PASS
ci/iol-dpdk_compile_spdk success Compile Testing PASS
ci/intel-Performance success Performance Testing PASS
ci/mellanox-Performance success Performance Testing PASS

Commit Message

Shougang Wang Sept. 20, 2019, 3:13 a.m. UTC
  This patch fixed the reset function to avoid crash when user don't
call port stop, port reset and port start functions as sequence.

Fixes: 97f1e19679 ("app/testpmd: add port reset command")
Cc: stable@dpdk.org

Signed-off-by: Wang ShougangX <shougangx.wang@intel.com>
---
 app/test-pmd/testpmd.c                      | 2 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 9 +++++++++
 2 files changed, 11 insertions(+)
  

Comments

Iremonger, Bernard Sept. 23, 2019, 10:19 a.m. UTC | #1
Hi Shougangx

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wang ShougangX
> Sent: Friday, September 20, 2019 4:14 AM
> To: dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>; Wang,
> ShougangX <shougangx.wang@intel.com>; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH v2] app/testpmd: fix Segment fault when start
> fwd
> 
> This patch fixed the reset function to avoid crash when user don't call port
> stop, port reset and port start functions as sequence.
> 
> Fixes: 97f1e19679 ("app/testpmd: add port reset command")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Wang ShougangX <shougangx.wang@intel.com>
> ---
>  app/test-pmd/testpmd.c                      | 2 ++
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst | 9 +++++++++
>  2 files changed, 11 insertions(+)
> 
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
> e8e2a39b6..9224aa1f7 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -2344,6 +2344,8 @@ reset_port(portid_t pid)
>  	if (port_id_is_invalid(pid, ENABLED_WARN))
>  		return;
> 
> +	stop_port(pid);
> +
>  	printf("Resetting ports...\n");
> 
>  	RTE_ETH_FOREACH_DEV(pi) {

The app/test-pmd/cmdline.c  file should be updated at line 760 to add help text for the "port reset (port_id|all)\n" command. 

> diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> index 313e0707e..2c459810c 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 (re-)start the port after reset.
> +
>  port config - queue ring size
>  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> --
> 2.17.1

Regards,

Bernard.
  
Shougang Wang Sept. 24, 2019, 1:43 a.m. UTC | #2
Hi Bernard

> The app/test-pmd/cmdline.c  file should be updated at line 760 to add help text
> for the "port reset (port_id|all)\n" command.

Thank you very much, I will add in next patch.

Thanks.
Shougang

> -----Original Message-----
> From: Iremonger, Bernard
> Sent: Monday, September 23, 2019 6:20 PM
> To: Wang, ShougangX <shougangx.wang@intel.com>; dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>; Wang,
> ShougangX <shougangx.wang@intel.com>; stable@dpdk.org
> Subject: RE: [dpdk-dev] [PATCH v2] app/testpmd: fix Segment fault when start
> fwd
> 
> Hi Shougangx
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wang ShougangX
> > Sent: Friday, September 20, 2019 4:14 AM
> > To: dev@dpdk.org
> > Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
> > <qiming.yang@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>; Wang,
> > ShougangX <shougangx.wang@intel.com>; stable@dpdk.org
> > Subject: [dpdk-dev] [PATCH v2] app/testpmd: fix Segment fault when
> > start fwd
> >
> > This patch fixed the reset function to avoid crash when user don't
> > call port stop, port reset and port start functions as sequence.
> >
> > Fixes: 97f1e19679 ("app/testpmd: add port reset command")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Wang ShougangX <shougangx.wang@intel.com>
> > ---
> >  app/test-pmd/testpmd.c                      | 2 ++
> >  doc/guides/testpmd_app_ug/testpmd_funcs.rst | 9 +++++++++
> >  2 files changed, 11 insertions(+)
> >
> > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
> > e8e2a39b6..9224aa1f7 100644
> > --- a/app/test-pmd/testpmd.c
> > +++ b/app/test-pmd/testpmd.c
> > @@ -2344,6 +2344,8 @@ reset_port(portid_t pid)
> >  	if (port_id_is_invalid(pid, ENABLED_WARN))
> >  		return;
> >
> > +	stop_port(pid);
> > +
> >  	printf("Resetting ports...\n");
> >
> >  	RTE_ETH_FOREACH_DEV(pi) {
> 
> The app/test-pmd/cmdline.c  file should be updated at line 760 to add help text
> for the "port reset (port_id|all)\n" command.
> 
> > diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> > b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> > index 313e0707e..2c459810c 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 (re-)start the port after reset.
> > +
> >  port config - queue ring size
> >  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > --
> > 2.17.1
> 
> Regards,
> 
> Bernard.
  

Patch

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index e8e2a39b6..9224aa1f7 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -2344,6 +2344,8 @@  reset_port(portid_t pid)
 	if (port_id_is_invalid(pid, ENABLED_WARN))
 		return;
 
+	stop_port(pid);
+
 	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 313e0707e..2c459810c 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 (re-)start the port after reset.
+
 port config - queue ring size
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~