patches for DPDK stable branches
 help / color / Atom feed
* [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start fwd
@ 2019-09-06  1:28 Wang ShougangX
  2019-09-12 13:26 ` [dpdk-stable] [dpdk-dev] " Iremonger, Bernard
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Wang ShougangX @ 2019-09-06  1:28 UTC (permalink / raw)
  To: dev; +Cc: Wenzhuo Lu, Yang Qiming, Wang ShougangX, stable

This patch fixed the reset function to avoid crash when user don't
call port reset , port stop 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 | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index e8e2a39b6..273a7aa02 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -2344,6 +2344,9 @@ reset_port(portid_t pid)
 	if (port_id_is_invalid(pid, ENABLED_WARN))
 		return;
 
+	printf("Stopping ports...\n");
+	stop_port(pid);
+
 	printf("Resetting ports...\n");
 
 	RTE_ETH_FOREACH_DEV(pi) {
@@ -2372,6 +2375,9 @@ reset_port(portid_t pid)
 		}
 	}
 
+	printf("Starting ports...\n");
+	start_port(pid);
+
 	printf("Done\n");
 }
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [dpdk-stable] [dpdk-dev] [PATCH] app/testpmd: fix Segment fault when start fwd
  2019-09-06  1:28 [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start fwd Wang ShougangX
@ 2019-09-12 13:26 ` " Iremonger, Bernard
  2019-09-13 17:34 ` [dpdk-stable] " Ferruh Yigit
  2019-09-20  3:13 ` [dpdk-stable] [PATCH v2] " Wang ShougangX
  2 siblings, 0 replies; 15+ messages in thread
From: Iremonger, Bernard @ 2019-09-12 13:26 UTC (permalink / raw)
  To: Wang, ShougangX, dev; +Cc: Lu, Wenzhuo, Yang, Qiming, Wang, ShougangX, stable


> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wang ShougangX
> Sent: Friday, September 6, 2019 2:29 AM
> To: dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Wang, ShougangX <shougangx.wang@intel.com>;
> stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] app/testpmd: fix Segment fault when start fwd
> 
> This patch fixed the reset function to avoid crash when user don't call port reset
> , port stop 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>

Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start fwd
  2019-09-06  1:28 [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start fwd Wang ShougangX
  2019-09-12 13:26 ` [dpdk-stable] [dpdk-dev] " Iremonger, Bernard
@ 2019-09-13 17:34 ` " Ferruh Yigit
  2019-09-16  6:37   ` Wang, ShougangX
  2019-09-20  3:13 ` [dpdk-stable] [PATCH v2] " Wang ShougangX
  2 siblings, 1 reply; 15+ messages in thread
From: Ferruh Yigit @ 2019-09-13 17:34 UTC (permalink / raw)
  To: Wang ShougangX, dev; +Cc: Wenzhuo Lu, Yang Qiming, stable

On 9/6/2019 2:28 AM, Wang ShougangX wrote:
> This patch fixed the reset function to avoid crash when user don't
> call port reset , port stop 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 | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
> index e8e2a39b6..273a7aa02 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -2344,6 +2344,9 @@ reset_port(portid_t pid)
>  	if (port_id_is_invalid(pid, ENABLED_WARN))
>  		return;
>  
> +	printf("Stopping ports...\n");
> +	stop_port(pid);
> +
>  	printf("Resetting ports...\n");
>  
>  	RTE_ETH_FOREACH_DEV(pi) {
> @@ -2372,6 +2375,9 @@ reset_port(portid_t pid)
>  		}
>  	}
>  
> +	printf("Starting ports...\n");
> +	start_port(pid);
> +
>  	printf("Done\n");
>  }

Hi Shougang,

Not sure if 'reset' command should do more than it says, if there is a
requirement that port should be stopped, why not add this condition with an
error message so that user can stop the port in advance if she wants.


Btw, a few things related,
- 'reset_port()' function has a loop inside, 'RTE_ETH_FOREACH_DEV()' but it
works on single port, the loop looked unnecessary to me, can you please check
and remove the loop if required?

- I am not able to see 'reset' has been documented in
'doc/guides/testpmd_app_ug/testpmd_funcs.rst', it may be missing, can you please
check and add it if required?

Thanks,
ferruh

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start fwd
  2019-09-13 17:34 ` [dpdk-stable] " Ferruh Yigit
@ 2019-09-16  6:37   ` Wang, ShougangX
  2019-09-16 15:27     ` Ferruh Yigit
  0 siblings, 1 reply; 15+ messages in thread
From: Wang, ShougangX @ 2019-09-16  6:37 UTC (permalink / raw)
  To: Yigit, Ferruh, dev; +Cc: Lu, Wenzhuo, Yang, Qiming, stable

Hi Ferruh

Thanks for your reply.

> Not sure if 'reset' command should do more than it says, if there is a
> requirement that port should be stopped, why not add this condition with an
> error message so that user can stop the port in advance if she wants.

Firstly, port must be stopped before reset. Usually, port is stopped by rte_eth_dev_reset(), 
so testpmd does not prompt user to stop port. Although it can stop port, but testpmd does not 
change its own port status flag to "RTE_PORT_STOPPED" and it will cause "port start" to fail. 
So I add this patch to stop port as same as running "port stop" command.

> - 'reset_port()' function has a loop inside, 'RTE_ETH_FOREACH_DEV()' but it
> works on single port, the loop looked unnecessary to me, can you please check
> and remove the loop if required?

"port reset" supports reset all ports (testpmd > port reset all), so this loop is necessary.

> - I am not able to see 'reset' has been documented in
> 'doc/guides/testpmd_app_ug/testpmd_funcs.rst', it may be missing, can you
> please check and add it if required?

OK. I will add it in the next patch.

Thanks.
Shougang


> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Saturday, September 14, 2019 1:35 AM
> To: Wang, ShougangX <shougangx.wang@intel.com>; dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; stable@dpdk.org
> Subject: Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start
> fwd
> 
> On 9/6/2019 2:28 AM, Wang ShougangX wrote:
> > This patch fixed the reset function to avoid crash when user don't
> > call port reset , port stop 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 | 6 ++++++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
> > e8e2a39b6..273a7aa02 100644
> > --- a/app/test-pmd/testpmd.c
> > +++ b/app/test-pmd/testpmd.c
> > @@ -2344,6 +2344,9 @@ reset_port(portid_t pid)
> >  	if (port_id_is_invalid(pid, ENABLED_WARN))
> >  		return;
> >
> > +	printf("Stopping ports...\n");
> > +	stop_port(pid);
> > +
> >  	printf("Resetting ports...\n");
> >
> >  	RTE_ETH_FOREACH_DEV(pi) {
> > @@ -2372,6 +2375,9 @@ reset_port(portid_t pid)
> >  		}
> >  	}
> >
> > +	printf("Starting ports...\n");
> > +	start_port(pid);
> > +
> >  	printf("Done\n");
> >  }
> 
> Hi Shougang,
> 
> Not sure if 'reset' command should do more than it says, if there is a
> requirement that port should be stopped, why not add this condition with an
> error message so that user can stop the port in advance if she wants.
> 
> 
> Btw, a few things related,
> - 'reset_port()' function has a loop inside, 'RTE_ETH_FOREACH_DEV()' but it
> works on single port, the loop looked unnecessary to me, can you please check
> and remove the loop if required?
> 
> - I am not able to see 'reset' has been documented in
> 'doc/guides/testpmd_app_ug/testpmd_funcs.rst', it may be missing, can you
> please check and add it if required?
> 
> Thanks,
> ferruh

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start fwd
  2019-09-16  6:37   ` Wang, ShougangX
@ 2019-09-16 15:27     ` Ferruh Yigit
  2019-09-17  9:22       ` Wang, ShougangX
  0 siblings, 1 reply; 15+ messages in thread
From: Ferruh Yigit @ 2019-09-16 15:27 UTC (permalink / raw)
  To: Wang, ShougangX, dev; +Cc: Lu, Wenzhuo, Yang, Qiming, stable

On 9/16/2019 7:37 AM, Wang, ShougangX wrote:
> Hi Ferruh
> 
> Thanks for your reply.
> 
>> Not sure if 'reset' command should do more than it says, if there is a
>> requirement that port should be stopped, why not add this condition with an
>> error message so that user can stop the port in advance if she wants.
> 
> Firstly, port must be stopped before reset. Usually, port is stopped by rte_eth_dev_reset(), 
> so testpmd does not prompt user to stop port. Although it can stop port, but testpmd does not 
> change its own port status flag to "RTE_PORT_STOPPED" and it will cause "port start" to fail. 
> So I add this patch to stop port as same as running "port stop" command.

Let's assume port already stopped before calling the reset, reset will cause
port to be started.
I am for user explicitly do the stop, reset and start commands, instead of reset
automatically stop and start later.

> 
>> - 'reset_port()' function has a loop inside, 'RTE_ETH_FOREACH_DEV()' but it
>> works on single port, the loop looked unnecessary to me, can you please check
>> and remove the loop if required?
> 
> "port reset" supports reset all ports (testpmd > port reset all), so this loop is necessary.

Got it.

> 
>> - I am not able to see 'reset' has been documented in
>> 'doc/guides/testpmd_app_ug/testpmd_funcs.rst', it may be missing, can you
>> please check and add it if required?
> 
> OK. I will add it in the next patch.
> 
> Thanks.
> Shougang
> 
> 
>> -----Original Message-----
>> From: Yigit, Ferruh
>> Sent: Saturday, September 14, 2019 1:35 AM
>> To: Wang, ShougangX <shougangx.wang@intel.com>; dev@dpdk.org
>> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
>> <qiming.yang@intel.com>; stable@dpdk.org
>> Subject: Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start
>> fwd
>>
>> On 9/6/2019 2:28 AM, Wang ShougangX wrote:
>>> This patch fixed the reset function to avoid crash when user don't
>>> call port reset , port stop 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 | 6 ++++++
>>>  1 file changed, 6 insertions(+)
>>>
>>> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
>>> e8e2a39b6..273a7aa02 100644
>>> --- a/app/test-pmd/testpmd.c
>>> +++ b/app/test-pmd/testpmd.c
>>> @@ -2344,6 +2344,9 @@ reset_port(portid_t pid)
>>>  	if (port_id_is_invalid(pid, ENABLED_WARN))
>>>  		return;
>>>
>>> +	printf("Stopping ports...\n");
>>> +	stop_port(pid);
>>> +
>>>  	printf("Resetting ports...\n");
>>>
>>>  	RTE_ETH_FOREACH_DEV(pi) {
>>> @@ -2372,6 +2375,9 @@ reset_port(portid_t pid)
>>>  		}
>>>  	}
>>>
>>> +	printf("Starting ports...\n");
>>> +	start_port(pid);
>>> +
>>>  	printf("Done\n");
>>>  }
>>
>> Hi Shougang,
>>
>> Not sure if 'reset' command should do more than it says, if there is a
>> requirement that port should be stopped, why not add this condition with an
>> error message so that user can stop the port in advance if she wants.
>>
>>
>> Btw, a few things related,
>> - 'reset_port()' function has a loop inside, 'RTE_ETH_FOREACH_DEV()' but it
>> works on single port, the loop looked unnecessary to me, can you please check
>> and remove the loop if required?
>>
>> - I am not able to see 'reset' has been documented in
>> 'doc/guides/testpmd_app_ug/testpmd_funcs.rst', it may be missing, can you
>> please check and add it if required?
>>
>> Thanks,
>> ferruh


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start fwd
  2019-09-16 15:27     ` Ferruh Yigit
@ 2019-09-17  9:22       ` Wang, ShougangX
  2019-09-23 11:04         ` Ferruh Yigit
  0 siblings, 1 reply; 15+ messages in thread
From: Wang, ShougangX @ 2019-09-17  9:22 UTC (permalink / raw)
  To: Yigit, Ferruh, dev; +Cc: Lu, Wenzhuo, Yang, Qiming, stable

> Let's assume port already stopped before calling the reset, reset will cause port
> to be started.

Indeed, automatically start looks strange in this case. User explicitly do the 
"port start" command should be better.

> I am for user explicitly do the stop, reset and start commands, instead of reset
> automatically stop and start later.

There are two reasons that it is necessary to stop automatically in "port reset" command:
1) Even without this patch, user does not need to manually execute "port stop" command 
before "port reset" too,  because port will be stopped in rte_eth_dev_reset() function. 
But this function does not update the port status flag of testpmd. It makes the port state 
recorded by testpmd inconsistent with the actual port state. So I add stop processing in 
reset_port() function to stop port as same as running "port stop" command.

2) If let user to stop port manually when he wants to reset port, it is not easy to use than before.

Thanks.
Shougang


> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Monday, September 16, 2019 11:28 PM
> To: Wang, ShougangX <shougangx.wang@intel.com>; dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; stable@dpdk.org
> Subject: Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start
> fwd
> 
> On 9/16/2019 7:37 AM, Wang, ShougangX wrote:
> > Hi Ferruh
> >
> > Thanks for your reply.
> >
> >> Not sure if 'reset' command should do more than it says, if there is
> >> a requirement that port should be stopped, why not add this condition
> >> with an error message so that user can stop the port in advance if she wants.
> >
> > Firstly, port must be stopped before reset. Usually, port is stopped
> > by rte_eth_dev_reset(), so testpmd does not prompt user to stop port.
> > Although it can stop port, but testpmd does not change its own port status
> flag to "RTE_PORT_STOPPED" and it will cause "port start" to fail.
> > So I add this patch to stop port as same as running "port stop" command.
> 
> Let's assume port already stopped before calling the reset, reset will cause port
> to be started.
> I am for user explicitly do the stop, reset and start commands, instead of reset
> automatically stop and start later.
> 
> >
> >> - 'reset_port()' function has a loop inside, 'RTE_ETH_FOREACH_DEV()'
> >> but it works on single port, the loop looked unnecessary to me, can
> >> you please check and remove the loop if required?
> >
> > "port reset" supports reset all ports (testpmd > port reset all), so this loop is
> necessary.
> 
> Got it.
> 
> >
> >> - I am not able to see 'reset' has been documented in
> >> 'doc/guides/testpmd_app_ug/testpmd_funcs.rst', it may be missing, can
> >> you please check and add it if required?
> >
> > OK. I will add it in the next patch.
> >
> > Thanks.
> > Shougang
> >
> >
> >> -----Original Message-----
> >> From: Yigit, Ferruh
> >> Sent: Saturday, September 14, 2019 1:35 AM
> >> To: Wang, ShougangX <shougangx.wang@intel.com>; dev@dpdk.org
> >> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
> >> <qiming.yang@intel.com>; stable@dpdk.org
> >> Subject: Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault
> >> when start fwd
> >>
> >> On 9/6/2019 2:28 AM, Wang ShougangX wrote:
> >>> This patch fixed the reset function to avoid crash when user don't
> >>> call port reset , port stop 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 | 6 ++++++
> >>>  1 file changed, 6 insertions(+)
> >>>
> >>> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
> >>> e8e2a39b6..273a7aa02 100644
> >>> --- a/app/test-pmd/testpmd.c
> >>> +++ b/app/test-pmd/testpmd.c
> >>> @@ -2344,6 +2344,9 @@ reset_port(portid_t pid)
> >>>  	if (port_id_is_invalid(pid, ENABLED_WARN))
> >>>  		return;
> >>>
> >>> +	printf("Stopping ports...\n");
> >>> +	stop_port(pid);
> >>> +
> >>>  	printf("Resetting ports...\n");
> >>>
> >>>  	RTE_ETH_FOREACH_DEV(pi) {
> >>> @@ -2372,6 +2375,9 @@ reset_port(portid_t pid)
> >>>  		}
> >>>  	}
> >>>
> >>> +	printf("Starting ports...\n");
> >>> +	start_port(pid);
> >>> +
> >>>  	printf("Done\n");
> >>>  }
> >>
> >> Hi Shougang,
> >>
> >> Not sure if 'reset' command should do more than it says, if there is
> >> a requirement that port should be stopped, why not add this condition
> >> with an error message so that user can stop the port in advance if she wants.
> >>
> >>
> >> Btw, a few things related,
> >> - 'reset_port()' function has a loop inside, 'RTE_ETH_FOREACH_DEV()'
> >> but it works on single port, the loop looked unnecessary to me, can
> >> you please check and remove the loop if required?
> >>
> >> - I am not able to see 'reset' has been documented in
> >> 'doc/guides/testpmd_app_ug/testpmd_funcs.rst', it may be missing, can
> >> you please check and add it if required?
> >>
> >> Thanks,
> >> ferruh


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [dpdk-stable] [PATCH v2] app/testpmd: fix Segment fault when start fwd
  2019-09-06  1:28 [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start fwd Wang ShougangX
  2019-09-12 13:26 ` [dpdk-stable] [dpdk-dev] " Iremonger, Bernard
  2019-09-13 17:34 ` [dpdk-stable] " Ferruh Yigit
@ 2019-09-20  3:13 ` " Wang ShougangX
  2019-09-23 10:19   ` [dpdk-stable] [dpdk-dev] " Iremonger, Bernard
  2019-09-24  4:49   ` [dpdk-stable] [PATCH v3] " Wang ShougangX
  2 siblings, 2 replies; 15+ messages in thread
From: Wang ShougangX @ 2019-09-20  3:13 UTC (permalink / raw)
  To: dev; +Cc: wenzhuo.lu, qiming.yang, ferruh.yigit, Wang ShougangX, stable

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) {
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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [dpdk-stable] [dpdk-dev] [PATCH v2] app/testpmd: fix Segment fault when start fwd
  2019-09-20  3:13 ` [dpdk-stable] [PATCH v2] " Wang ShougangX
@ 2019-09-23 10:19   ` " Iremonger, Bernard
  2019-09-24  1:43     ` Wang, ShougangX
  2019-09-24  4:49   ` [dpdk-stable] [PATCH v3] " Wang ShougangX
  1 sibling, 1 reply; 15+ messages in thread
From: Iremonger, Bernard @ 2019-09-23 10:19 UTC (permalink / raw)
  To: Wang, ShougangX, dev
  Cc: Lu, Wenzhuo, Yang, Qiming, Yigit, Ferruh, Wang, ShougangX, stable

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.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start fwd
  2019-09-17  9:22       ` Wang, ShougangX
@ 2019-09-23 11:04         ` Ferruh Yigit
  2019-09-23 14:18           ` [dpdk-stable] [dpdk-dev] " Iremonger, Bernard
  0 siblings, 1 reply; 15+ messages in thread
From: Ferruh Yigit @ 2019-09-23 11:04 UTC (permalink / raw)
  To: Wang, ShougangX, dev; +Cc: Lu, Wenzhuo, Yang, Qiming, stable

On 9/17/2019 10:22 AM, Wang, ShougangX wrote:
>> Let's assume port already stopped before calling the reset, reset will cause port
>> to be started.
> 
> Indeed, automatically start looks strange in this case. User explicitly do the 
> "port start" command should be better.
> 
>> I am for user explicitly do the stop, reset and start commands, instead of reset
>> automatically stop and start later.
> 
> There are two reasons that it is necessary to stop automatically in "port reset" command:
> 1) Even without this patch, user does not need to manually execute "port stop" command 
> before "port reset" too,  because port will be stopped in rte_eth_dev_reset() function. 
> But this function does not update the port status flag of testpmd. It makes the port state 
> recorded by testpmd inconsistent with the actual port state. So I add stop processing in 
> reset_port() function to stop port as same as running "port stop" command.

I see 'rte_eth_dev_reset()' API calls the 'rte_eth_dev_stop()' but it isn't
enough as you said and a testpmd stop is required, instead of doing in the
function it is easy to detect port is not stopped and return an error in the
'reset', it is up to user to stop and do the reset.

> 
> 2) If let user to stop port manually when he wants to reset port, it is not easy to use than before.

I still prefer 'Explicit is better than implicit.' [1], yes it is two commands
now to reset the port if it is already started but I don't see this is a problem.

Anyway this is not a big deal, if testpmd maintainers are OK for it we can
continue with this...


[1] see: The Zen of Python :)

> 
> Thanks.
> Shougang
> 
> 
>> -----Original Message-----
>> From: Yigit, Ferruh
>> Sent: Monday, September 16, 2019 11:28 PM
>> To: Wang, ShougangX <shougangx.wang@intel.com>; dev@dpdk.org
>> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
>> <qiming.yang@intel.com>; stable@dpdk.org
>> Subject: Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start
>> fwd
>>
>> On 9/16/2019 7:37 AM, Wang, ShougangX wrote:
>>> Hi Ferruh
>>>
>>> Thanks for your reply.
>>>
>>>> Not sure if 'reset' command should do more than it says, if there is
>>>> a requirement that port should be stopped, why not add this condition
>>>> with an error message so that user can stop the port in advance if she wants.
>>>
>>> Firstly, port must be stopped before reset. Usually, port is stopped
>>> by rte_eth_dev_reset(), so testpmd does not prompt user to stop port.
>>> Although it can stop port, but testpmd does not change its own port status
>> flag to "RTE_PORT_STOPPED" and it will cause "port start" to fail.
>>> So I add this patch to stop port as same as running "port stop" command.
>>
>> Let's assume port already stopped before calling the reset, reset will cause port
>> to be started.
>> I am for user explicitly do the stop, reset and start commands, instead of reset
>> automatically stop and start later.
>>
>>>
>>>> - 'reset_port()' function has a loop inside, 'RTE_ETH_FOREACH_DEV()'
>>>> but it works on single port, the loop looked unnecessary to me, can
>>>> you please check and remove the loop if required?
>>>
>>> "port reset" supports reset all ports (testpmd > port reset all), so this loop is
>> necessary.
>>
>> Got it.
>>
>>>
>>>> - I am not able to see 'reset' has been documented in
>>>> 'doc/guides/testpmd_app_ug/testpmd_funcs.rst', it may be missing, can
>>>> you please check and add it if required?
>>>
>>> OK. I will add it in the next patch.
>>>
>>> Thanks.
>>> Shougang
>>>
>>>
>>>> -----Original Message-----
>>>> From: Yigit, Ferruh
>>>> Sent: Saturday, September 14, 2019 1:35 AM
>>>> To: Wang, ShougangX <shougangx.wang@intel.com>; dev@dpdk.org
>>>> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
>>>> <qiming.yang@intel.com>; stable@dpdk.org
>>>> Subject: Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault
>>>> when start fwd
>>>>
>>>> On 9/6/2019 2:28 AM, Wang ShougangX wrote:
>>>>> This patch fixed the reset function to avoid crash when user don't
>>>>> call port reset , port stop 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 | 6 ++++++
>>>>>  1 file changed, 6 insertions(+)
>>>>>
>>>>> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
>>>>> e8e2a39b6..273a7aa02 100644
>>>>> --- a/app/test-pmd/testpmd.c
>>>>> +++ b/app/test-pmd/testpmd.c
>>>>> @@ -2344,6 +2344,9 @@ reset_port(portid_t pid)
>>>>>  	if (port_id_is_invalid(pid, ENABLED_WARN))
>>>>>  		return;
>>>>>
>>>>> +	printf("Stopping ports...\n");
>>>>> +	stop_port(pid);
>>>>> +
>>>>>  	printf("Resetting ports...\n");
>>>>>
>>>>>  	RTE_ETH_FOREACH_DEV(pi) {
>>>>> @@ -2372,6 +2375,9 @@ reset_port(portid_t pid)
>>>>>  		}
>>>>>  	}
>>>>>
>>>>> +	printf("Starting ports...\n");
>>>>> +	start_port(pid);
>>>>> +
>>>>>  	printf("Done\n");
>>>>>  }
>>>>
>>>> Hi Shougang,
>>>>
>>>> Not sure if 'reset' command should do more than it says, if there is
>>>> a requirement that port should be stopped, why not add this condition
>>>> with an error message so that user can stop the port in advance if she wants.
>>>>
>>>>
>>>> Btw, a few things related,
>>>> - 'reset_port()' function has a loop inside, 'RTE_ETH_FOREACH_DEV()'
>>>> but it works on single port, the loop looked unnecessary to me, can
>>>> you please check and remove the loop if required?
>>>>
>>>> - I am not able to see 'reset' has been documented in
>>>> 'doc/guides/testpmd_app_ug/testpmd_funcs.rst', it may be missing, can
>>>> you please check and add it if required?
>>>>
>>>> Thanks,
>>>> ferruh
> 


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [dpdk-stable] [dpdk-dev] [PATCH] app/testpmd: fix Segment fault when start fwd
  2019-09-23 11:04         ` Ferruh Yigit
@ 2019-09-23 14:18           ` " Iremonger, Bernard
  2019-09-24  2:31             ` Wang, ShougangX
  0 siblings, 1 reply; 15+ messages in thread
From: Iremonger, Bernard @ 2019-09-23 14:18 UTC (permalink / raw)
  To: Yigit, Ferruh, Wang, ShougangX, dev; +Cc: Lu, Wenzhuo, Yang, Qiming, stable

Hi ShougangX, Ferruh,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ferruh Yigit
> Sent: Monday, September 23, 2019 12:04 PM
> To: Wang, ShougangX <shougangx.wang@intel.com>; dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; stable@dpdk.org
> Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH] app/testpmd: fix Segment
> fault when start fwd
> 
> On 9/17/2019 10:22 AM, Wang, ShougangX wrote:
> >> Let's assume port already stopped before calling the reset, reset
> >> will cause port to be started.
> >
> > Indeed, automatically start looks strange in this case. User
> > explicitly do the "port start" command should be better.
> >
> >> I am for user explicitly do the stop, reset and start commands,
> >> instead of reset automatically stop and start later.
> >
> > There are two reasons that it is necessary to stop automatically in "port
> reset" command:
> > 1) Even without this patch, user does not need to manually execute
> > "port stop" command before "port reset" too,  because port will be
> stopped in rte_eth_dev_reset() function.
> > But this function does not update the port status flag of testpmd. It
> > makes the port state recorded by testpmd inconsistent with the actual
> > port state. So I add stop processing in
> > reset_port() function to stop port as same as running "port stop"
> command.
> 
> I see 'rte_eth_dev_reset()' API calls the 'rte_eth_dev_stop()' but it isn't
> enough as you said and a testpmd stop is required, instead of doing in the
> function it is easy to detect port is not stopped and return an error in the
> 'reset', it is up to user to stop and do the reset.
> 
> >
> > 2) If let user to stop port manually when he wants to reset port, it is not
> easy to use than before.
> 
> I still prefer 'Explicit is better than implicit.' [1], yes it is two commands now to
> reset the port if it is already started but I don't see this is a problem.
> 
> Anyway this is not a big deal, if testpmd maintainers are OK for it we can
> continue with this...

I am inclined to agree with Ferruh, that it would be better to return an error if the port is not stopped when "port reset" is called rather that silently stopping the port.


> [1] see: The Zen of Python :)
> 
> >
> > Thanks.
> > Shougang
> >
> >
> >> -----Original Message-----
> >> From: Yigit, Ferruh
> >> Sent: Monday, September 16, 2019 11:28 PM
> >> To: Wang, ShougangX <shougangx.wang@intel.com>; dev@dpdk.org
> >> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
> >> <qiming.yang@intel.com>; stable@dpdk.org
> >> Subject: Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault
> >> when start fwd
> >>
> >> On 9/16/2019 7:37 AM, Wang, ShougangX wrote:
> >>> Hi Ferruh
> >>>
> >>> Thanks for your reply.
> >>>
> >>>> Not sure if 'reset' command should do more than it says, if there
> >>>> is a requirement that port should be stopped, why not add this
> >>>> condition with an error message so that user can stop the port in
> advance if she wants.
> >>>
> >>> Firstly, port must be stopped before reset. Usually, port is stopped
> >>> by rte_eth_dev_reset(), so testpmd does not prompt user to stop port.
> >>> Although it can stop port, but testpmd does not change its own port
> >>> status
> >> flag to "RTE_PORT_STOPPED" and it will cause "port start" to fail.
> >>> So I add this patch to stop port as same as running "port stop" command.
> >>
> >> Let's assume port already stopped before calling the reset, reset
> >> will cause port to be started.
> >> I am for user explicitly do the stop, reset and start commands,
> >> instead of reset automatically stop and start later.
> >>
> >>>
> >>>> - 'reset_port()' function has a loop inside, 'RTE_ETH_FOREACH_DEV()'
> >>>> but it works on single port, the loop looked unnecessary to me, can
> >>>> you please check and remove the loop if required?
> >>>
> >>> "port reset" supports reset all ports (testpmd > port reset all), so
> >>> this loop is
> >> necessary.
> >>
> >> Got it.
> >>
> >>>
> >>>> - I am not able to see 'reset' has been documented in
> >>>> 'doc/guides/testpmd_app_ug/testpmd_funcs.rst', it may be missing,
> >>>> can you please check and add it if required?
> >>>
> >>> OK. I will add it in the next patch.
> >>>
> >>> Thanks.
> >>> Shougang
> >>>
> >>>
> >>>> -----Original Message-----
> >>>> From: Yigit, Ferruh
> >>>> Sent: Saturday, September 14, 2019 1:35 AM
> >>>> To: Wang, ShougangX <shougangx.wang@intel.com>; dev@dpdk.org
> >>>> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
> >>>> <qiming.yang@intel.com>; stable@dpdk.org
> >>>> Subject: Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault
> >>>> when start fwd
> >>>>
> >>>> On 9/6/2019 2:28 AM, Wang ShougangX wrote:
> >>>>> This patch fixed the reset function to avoid crash when user don't
> >>>>> call port reset , port stop 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 | 6 ++++++
> >>>>>  1 file changed, 6 insertions(+)
> >>>>>
> >>>>> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
> >>>>> e8e2a39b6..273a7aa02 100644
> >>>>> --- a/app/test-pmd/testpmd.c
> >>>>> +++ b/app/test-pmd/testpmd.c
> >>>>> @@ -2344,6 +2344,9 @@ reset_port(portid_t pid)
> >>>>>  	if (port_id_is_invalid(pid, ENABLED_WARN))
> >>>>>  		return;
> >>>>>
> >>>>> +	printf("Stopping ports...\n");
> >>>>> +	stop_port(pid);
> >>>>> +
> >>>>>  	printf("Resetting ports...\n");
> >>>>>
> >>>>>  	RTE_ETH_FOREACH_DEV(pi) {
> >>>>> @@ -2372,6 +2375,9 @@ reset_port(portid_t pid)
> >>>>>  		}
> >>>>>  	}
> >>>>>
> >>>>> +	printf("Starting ports...\n");
> >>>>> +	start_port(pid);
> >>>>> +
> >>>>>  	printf("Done\n");
> >>>>>  }
> >>>>
> >>>> Hi Shougang,
> >>>>
> >>>> Not sure if 'reset' command should do more than it says, if there
> >>>> is a requirement that port should be stopped, why not add this
> >>>> condition with an error message so that user can stop the port in
> advance if she wants.
> >>>>
> >>>>
> >>>> Btw, a few things related,
> >>>> - 'reset_port()' function has a loop inside, 'RTE_ETH_FOREACH_DEV()'
> >>>> but it works on single port, the loop looked unnecessary to me, can
> >>>> you please check and remove the loop if required?
> >>>>
> >>>> - I am not able to see 'reset' has been documented in
> >>>> 'doc/guides/testpmd_app_ug/testpmd_funcs.rst', it may be missing,
> >>>> can you please check and add it if required?
> >>>>
> >>>> Thanks,
> >>>> ferruh

Regards,

Bernard.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [dpdk-stable] [dpdk-dev] [PATCH v2] app/testpmd: fix Segment fault when start fwd
  2019-09-23 10:19   ` [dpdk-stable] [dpdk-dev] " Iremonger, Bernard
@ 2019-09-24  1:43     ` Wang, ShougangX
  0 siblings, 0 replies; 15+ messages in thread
From: Wang, ShougangX @ 2019-09-24  1:43 UTC (permalink / raw)
  To: Iremonger, Bernard, dev; +Cc: Lu, Wenzhuo, Yang, Qiming, Yigit, Ferruh, stable

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.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [dpdk-stable] [dpdk-dev] [PATCH] app/testpmd: fix Segment fault when start fwd
  2019-09-23 14:18           ` [dpdk-stable] [dpdk-dev] " Iremonger, Bernard
@ 2019-09-24  2:31             ` Wang, ShougangX
  0 siblings, 0 replies; 15+ messages in thread
From: Wang, ShougangX @ 2019-09-24  2:31 UTC (permalink / raw)
  To: Iremonger, Bernard, Yigit, Ferruh, dev; +Cc: Lu, Wenzhuo, Yang, Qiming, stable

Hi Regards, Ferruh

> -----Original Message-----
> From: Iremonger, Bernard
> Sent: Monday, September 23, 2019 10:18 PM
> To: Yigit, Ferruh <ferruh.yigit@intel.com>; Wang, ShougangX
> <shougangx.wang@intel.com>; dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; stable@dpdk.org
> Subject: RE: [dpdk-dev] [dpdk-stable] [PATCH] app/testpmd: fix Segment fault
> when start fwd
> 
> Hi ShougangX, Ferruh,
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ferruh Yigit
> > Sent: Monday, September 23, 2019 12:04 PM
> > To: Wang, ShougangX <shougangx.wang@intel.com>; dev@dpdk.org
> > Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
> > <qiming.yang@intel.com>; stable@dpdk.org
> > Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH] app/testpmd: fix Segment
> > fault when start fwd
> >
> > On 9/17/2019 10:22 AM, Wang, ShougangX wrote:
> > >> Let's assume port already stopped before calling the reset, reset
> > >> will cause port to be started.
> > >
> > > Indeed, automatically start looks strange in this case. User
> > > explicitly do the "port start" command should be better.
> > >
> > >> I am for user explicitly do the stop, reset and start commands,
> > >> instead of reset automatically stop and start later.
> > >
> > > There are two reasons that it is necessary to stop automatically in
> > > "port
> > reset" command:
> > > 1) Even without this patch, user does not need to manually execute
> > > "port stop" command before "port reset" too,  because port will be
> > stopped in rte_eth_dev_reset() function.
> > > But this function does not update the port status flag of testpmd.
> > > It makes the port state recorded by testpmd inconsistent with the
> > > actual port state. So I add stop processing in
> > > reset_port() function to stop port as same as running "port stop"
> > command.
> >
> > I see 'rte_eth_dev_reset()' API calls the 'rte_eth_dev_stop()' but it
> > isn't enough as you said and a testpmd stop is required, instead of
> > doing in the function it is easy to detect port is not stopped and
> > return an error in the 'reset', it is up to user to stop and do the reset.
> >
> > >
> > > 2) If let user to stop port manually when he wants to reset port, it
> > > is not
> > easy to use than before.
> >
> > I still prefer 'Explicit is better than implicit.' [1], yes it is two
> > commands now to reset the port if it is already started but I don't see this is a
> problem.
> >
> > Anyway this is not a big deal, if testpmd maintainers are OK for it we
> > can continue with this...
> 
> I am inclined to agree with Ferruh, that it would be better to return an error if
> the port is not stopped when "port reset" is called rather that silently stopping
> the port.
> 

I will adopt your suggestion.

> 
> > [1] see: The Zen of Python :)
> >
> > >
> > > Thanks.
> > > Shougang
> > >
> > >
> > >> -----Original Message-----
> > >> From: Yigit, Ferruh
> > >> Sent: Monday, September 16, 2019 11:28 PM
> > >> To: Wang, ShougangX <shougangx.wang@intel.com>; dev@dpdk.org
> > >> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
> > >> <qiming.yang@intel.com>; stable@dpdk.org
> > >> Subject: Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault
> > >> when start fwd
> > >>
> > >> On 9/16/2019 7:37 AM, Wang, ShougangX wrote:
> > >>> Hi Ferruh
> > >>>
> > >>> Thanks for your reply.
> > >>>
> > >>>> Not sure if 'reset' command should do more than it says, if there
> > >>>> is a requirement that port should be stopped, why not add this
> > >>>> condition with an error message so that user can stop the port in
> > advance if she wants.
> > >>>
> > >>> Firstly, port must be stopped before reset. Usually, port is
> > >>> stopped by rte_eth_dev_reset(), so testpmd does not prompt user to stop
> port.
> > >>> Although it can stop port, but testpmd does not change its own
> > >>> port status
> > >> flag to "RTE_PORT_STOPPED" and it will cause "port start" to fail.
> > >>> So I add this patch to stop port as same as running "port stop" command.
> > >>
> > >> Let's assume port already stopped before calling the reset, reset
> > >> will cause port to be started.
> > >> I am for user explicitly do the stop, reset and start commands,
> > >> instead of reset automatically stop and start later.
> > >>
> > >>>
> > >>>> - 'reset_port()' function has a loop inside, 'RTE_ETH_FOREACH_DEV()'
> > >>>> but it works on single port, the loop looked unnecessary to me,
> > >>>> can you please check and remove the loop if required?
> > >>>
> > >>> "port reset" supports reset all ports (testpmd > port reset all),
> > >>> so this loop is
> > >> necessary.
> > >>
> > >> Got it.
> > >>
> > >>>
> > >>>> - I am not able to see 'reset' has been documented in
> > >>>> 'doc/guides/testpmd_app_ug/testpmd_funcs.rst', it may be missing,
> > >>>> can you please check and add it if required?
> > >>>
> > >>> OK. I will add it in the next patch.
> > >>>
> > >>> Thanks.
> > >>> Shougang
> > >>>
> > >>>
> > >>>> -----Original Message-----
> > >>>> From: Yigit, Ferruh
> > >>>> Sent: Saturday, September 14, 2019 1:35 AM
> > >>>> To: Wang, ShougangX <shougangx.wang@intel.com>; dev@dpdk.org
> > >>>> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
> > >>>> <qiming.yang@intel.com>; stable@dpdk.org
> > >>>> Subject: Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault
> > >>>> when start fwd
> > >>>>
> > >>>> On 9/6/2019 2:28 AM, Wang ShougangX wrote:
> > >>>>> This patch fixed the reset function to avoid crash when user
> > >>>>> don't call port reset , port stop 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 | 6 ++++++
> > >>>>>  1 file changed, 6 insertions(+)
> > >>>>>
> > >>>>> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
> > >>>>> index
> > >>>>> e8e2a39b6..273a7aa02 100644
> > >>>>> --- a/app/test-pmd/testpmd.c
> > >>>>> +++ b/app/test-pmd/testpmd.c
> > >>>>> @@ -2344,6 +2344,9 @@ reset_port(portid_t pid)
> > >>>>>  	if (port_id_is_invalid(pid, ENABLED_WARN))
> > >>>>>  		return;
> > >>>>>
> > >>>>> +	printf("Stopping ports...\n");
> > >>>>> +	stop_port(pid);
> > >>>>> +
> > >>>>>  	printf("Resetting ports...\n");
> > >>>>>
> > >>>>>  	RTE_ETH_FOREACH_DEV(pi) {
> > >>>>> @@ -2372,6 +2375,9 @@ reset_port(portid_t pid)
> > >>>>>  		}
> > >>>>>  	}
> > >>>>>
> > >>>>> +	printf("Starting ports...\n");
> > >>>>> +	start_port(pid);
> > >>>>> +
> > >>>>>  	printf("Done\n");
> > >>>>>  }
> > >>>>
> > >>>> Hi Shougang,
> > >>>>
> > >>>> Not sure if 'reset' command should do more than it says, if there
> > >>>> is a requirement that port should be stopped, why not add this
> > >>>> condition with an error message so that user can stop the port in
> > advance if she wants.
> > >>>>
> > >>>>
> > >>>> Btw, a few things related,
> > >>>> - 'reset_port()' function has a loop inside, 'RTE_ETH_FOREACH_DEV()'
> > >>>> but it works on single port, the loop looked unnecessary to me,
> > >>>> can you please check and remove the loop if required?
> > >>>>
> > >>>> - I am not able to see 'reset' has been documented in
> > >>>> 'doc/guides/testpmd_app_ug/testpmd_funcs.rst', it may be missing,
> > >>>> can you please check and add it if required?
> > >>>>
> > >>>> Thanks,
> > >>>> ferruh
> 
> Regards,
> 
> Bernard.
> 

Thanks.
Shougang

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [dpdk-stable] [PATCH v3] app/testpmd: fix Segment fault when start fwd
  2019-09-20  3:13 ` [dpdk-stable] [PATCH v2] " Wang ShougangX
  2019-09-23 10:19   ` [dpdk-stable] [dpdk-dev] " Iremonger, Bernard
@ 2019-09-24  4:49   ` " Wang ShougangX
  2019-09-24  9:09     ` Iremonger, Bernard
  1 sibling, 1 reply; 15+ messages in thread
From: Wang ShougangX @ 2019-09-24  4:49 UTC (permalink / raw)
  To: dev; +Cc: qiming.yang, bernard.iremonger, ferruh.yigit, Wang ShougangX, stable

This patch fixed the reset function to avoid crash when user don't
call port stop, port reset 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/cmdline.c                      | 3 +++
 app/test-pmd/testpmd.c                      | 6 ++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 9 +++++++++
 3 files changed, 18 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 56783aa13..9d0c3db5e 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 e8e2a39b6..9b7a1521a 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -2344,6 +2344,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 313e0707e..b1a14cc4e 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
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [dpdk-stable] [PATCH v3] app/testpmd: fix Segment fault when start fwd
  2019-09-24  4:49   ` [dpdk-stable] [PATCH v3] " Wang ShougangX
@ 2019-09-24  9:09     ` Iremonger, Bernard
  2019-09-25 17:37       ` Ferruh Yigit
  0 siblings, 1 reply; 15+ messages in thread
From: Iremonger, Bernard @ 2019-09-24  9:09 UTC (permalink / raw)
  To: Wang, ShougangX, dev; +Cc: Yang, Qiming, Yigit, Ferruh, stable

> -----Original Message-----
> From: Wang, ShougangX
> Sent: Tuesday, September 24, 2019 5:49 AM
> To: dev@dpdk.org
> Cc: Yang, Qiming <qiming.yang@intel.com>; Iremonger, Bernard
> <bernard.iremonger@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>;
> Wang, ShougangX <shougangx.wang@intel.com>; stable@dpdk.org
> Subject: [PATCH v3] 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 functions as sequence.
> 
> Fixes: 97f1e19679 ("app/testpmd: add port reset command")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Wang ShougangX <shougangx.wang@intel.com>

Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [dpdk-stable] [PATCH v3] app/testpmd: fix Segment fault when start fwd
  2019-09-24  9:09     ` Iremonger, Bernard
@ 2019-09-25 17:37       ` Ferruh Yigit
  0 siblings, 0 replies; 15+ messages in thread
From: Ferruh Yigit @ 2019-09-25 17:37 UTC (permalink / raw)
  To: Iremonger, Bernard, Wang, ShougangX, dev; +Cc: Yang, Qiming, stable

On 9/24/2019 10:09 AM, Iremonger, Bernard wrote:
>> -----Original Message-----
>> From: Wang, ShougangX
>> Sent: Tuesday, September 24, 2019 5:49 AM
>> To: dev@dpdk.org
>> Cc: Yang, Qiming <qiming.yang@intel.com>; Iremonger, Bernard
>> <bernard.iremonger@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>;
>> Wang, ShougangX <shougangx.wang@intel.com>; stable@dpdk.org
>> Subject: [PATCH v3] 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 functions as sequence.
>>
>> Fixes: 97f1e19679 ("app/testpmd: add port reset command")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Wang ShougangX <shougangx.wang@intel.com>
> 
> Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
> 

Applied to dpdk-next-net/master, thanks.

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, back to index

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-06  1:28 [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start fwd Wang ShougangX
2019-09-12 13:26 ` [dpdk-stable] [dpdk-dev] " Iremonger, Bernard
2019-09-13 17:34 ` [dpdk-stable] " Ferruh Yigit
2019-09-16  6:37   ` Wang, ShougangX
2019-09-16 15:27     ` Ferruh Yigit
2019-09-17  9:22       ` Wang, ShougangX
2019-09-23 11:04         ` Ferruh Yigit
2019-09-23 14:18           ` [dpdk-stable] [dpdk-dev] " Iremonger, Bernard
2019-09-24  2:31             ` Wang, ShougangX
2019-09-20  3:13 ` [dpdk-stable] [PATCH v2] " Wang ShougangX
2019-09-23 10:19   ` [dpdk-stable] [dpdk-dev] " Iremonger, Bernard
2019-09-24  1:43     ` Wang, ShougangX
2019-09-24  4:49   ` [dpdk-stable] [PATCH v3] " Wang ShougangX
2019-09-24  9:09     ` Iremonger, Bernard
2019-09-25 17:37       ` Ferruh Yigit

patches for DPDK stable branches

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/stable/0 stable/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 stable stable/ http://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


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