Skip to contentSkip to conversation

app/testpmd: fix Segment fault when start fwd

PATCH Superseded Wang ShougangX 3 participants 15 messages Sep 6, 2019 – Sep 25, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 app/test-pmd/testpmd.c | 6 ++++++
 1 file changed, 6 insertions(+)
app/test-pmd/testpmd.c +6 -0
index e8e2a39b6..273a7aa02 100644
@@ -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");
 }
 
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Wang ShougangX
Sent: Friday, September 6, 2019 2:29 AM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>; Wang, ShougangX <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH] app/testpmd: fix Segment fault when start fwd

Quoted 7 lines

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")
#2 lore raw
In reply to Wang ShougangX
Quoted 26 lines · Wang ShougangX

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")
---
 app/test-pmd/testpmd.c | 6 ++++++
 1 file changed, 6 insertions(+)
app/test-pmd/testpmd.c +3 -0
index e8e2a39b6..273a7aa02 100644
@@ -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) {

app/test-pmd/testpmd.c reset_port(portid_t pid) · line 2382

Quoted 8 lines
app/test-pmd/testpmd.c +3 -0
@@ -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

#3 lore raw

Hi Ferruh

Thanks for your reply.

Quoted 3 lines

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.

Quoted 3 lines

- '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.

Quoted 3 lines

- 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

Quoted 63 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Saturday, September 14, 2019 1:35 AM
To: Wang, ShougangX <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>; [email protected]
Subject: Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start fwd

Quoted 26 lines · Wang ShougangX

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")
---
 app/test-pmd/testpmd.c | 6 ++++++
 1 file changed, 6 insertions(+)
app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0 -0

e8e2a39b6..273a7aa02 100644

app/test-pmd/testpmd.c +3 -0
@@ -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) {

app/test-pmd/testpmd.c reset_port(portid_t pid) · line 2382

Quoted 8 lines
app/test-pmd/testpmd.c +3 -0
@@ -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

#4 lore raw
Quoted 4 lines · ShougangX

Hi Ferruh

Thanks for your reply.

Quoted 8 lines
Quoted 3 lines

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.

Quoted 6 lines
Quoted 4 lines

- '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.

Quoted 74 lines
Quoted 4 lines

- 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

Quoted 63 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Saturday, September 14, 2019 1:35 AM
To: Wang, ShougangX <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>; [email protected]
Subject: Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start fwd

Quoted 26 lines · Wang ShougangX

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")
---
 app/test-pmd/testpmd.c | 6 ++++++
 1 file changed, 6 insertions(+)
app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0 -0

e8e2a39b6..273a7aa02 100644

app/test-pmd/testpmd.c +3 -0
@@ -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) {

app/test-pmd/testpmd.c reset_port(portid_t pid) · line 2382

Quoted 8 lines
app/test-pmd/testpmd.c +3 -0
@@ -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

#5 lore raw
Quoted 2 lines

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.

Quoted 2 lines

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

Quoted 113 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Monday, September 16, 2019 11:28 PM
To: Wang, ShougangX <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>; [email protected]
Subject: Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start fwd

Quoted 11 lines · ShougangX

Hi Ferruh

Thanks for your reply.

Quoted 3 lines

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.

Quoted 1 line

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.

Quoted 6 lines
Quoted 4 lines

- '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.

Quoted 74 lines
Quoted 4 lines

- 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

Quoted 63 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Saturday, September 14, 2019 1:35 AM
To: Wang, ShougangX <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>; [email protected]
Subject: Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start fwd

Quoted 26 lines · Wang ShougangX

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")
---
 app/test-pmd/testpmd.c | 6 ++++++
 1 file changed, 6 insertions(+)
app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0 -0

e8e2a39b6..273a7aa02 100644

app/test-pmd/testpmd.c +3 -0
@@ -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) {

app/test-pmd/testpmd.c reset_port(portid_t pid) · line 2382

Quoted 8 lines
app/test-pmd/testpmd.c +3 -0
@@ -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

#6 lore raw
Quoted 9 lines · ShougangX
Quoted 2 lines

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.

Quoted 2 lines

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

Quoted 6 lines

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.

Quoted 2 lines

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

Quoted 119 lines

Thanks.
Shougang

Quoted 113 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Monday, September 16, 2019 11:28 PM
To: Wang, ShougangX <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>; [email protected]
Subject: Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start fwd

Quoted 11 lines · ShougangX

Hi Ferruh

Thanks for your reply.

Quoted 3 lines

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.

Quoted 1 line

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.

Quoted 6 lines
Quoted 4 lines

- '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.

Quoted 74 lines
Quoted 4 lines

- 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

Quoted 63 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Saturday, September 14, 2019 1:35 AM
To: Wang, ShougangX <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>; [email protected]
Subject: Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start fwd

Quoted 26 lines · Wang ShougangX

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")
---
 app/test-pmd/testpmd.c | 6 ++++++
 1 file changed, 6 insertions(+)
app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0 -0

e8e2a39b6..273a7aa02 100644

app/test-pmd/testpmd.c +3 -0
@@ -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) {

app/test-pmd/testpmd.c reset_port(portid_t pid) · line 2382

Quoted 8 lines
app/test-pmd/testpmd.c +3 -0
@@ -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

#7 lore raw

Hi ShougangX, Ferruh,

Quoted 36 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ferruh Yigit
Sent: Monday, September 23, 2019 12:04 PM
To: Wang, ShougangX <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start fwd

Quoted 10 lines · ShougangX
Quoted 2 lines

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.

Quoted 2 lines

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:

Quoted 2 lines

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.

Quoted 4 lines

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.

Quoted 1 line
Quoted 8 lines
Quoted 1 line

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.

Quoted 107 lines

[1] see: The Zen of Python :)

Quoted 22 lines

Thanks.
Shougang

Quoted 17 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Monday, September 16, 2019 11:28 PM
To: Wang, ShougangX <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>; [email protected]
Subject: Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start fwd

Quoted 7 lines · ShougangX

Hi Ferruh

Thanks for your reply.

Quoted 3 lines

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.

Quoted 82 lines
Quoted 82 lines
Quoted 5 lines

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.

Quoted 1 line

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.

Quoted 7 lines
Quoted 4 lines

- '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.

Quoted 58 lines
Quoted 4 lines

- 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

Quoted 47 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Saturday, September 14, 2019 1:35 AM
To: Wang, ShougangX <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>; [email protected]
Subject: Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start fwd

Quoted 26 lines · Wang ShougangX

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")
---
 app/test-pmd/testpmd.c | 6 ++++++
 1 file changed, 6 insertions(+)
app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0 -0

e8e2a39b6..273a7aa02 100644

app/test-pmd/testpmd.c +3 -0
@@ -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) {

app/test-pmd/testpmd.c reset_port(portid_t pid) · line 2382

Quoted 8 lines
app/test-pmd/testpmd.c +3 -0
@@ -2372,6 +2375,9 @@ reset_port(portid_t pid)
 		}
 	}
 
+	printf("Starting ports...\n");
+	start_port(pid);
+
 	printf("Done\n");
 }

Hi Shougang,

Quoted 17 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

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.

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

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.

#8 lore raw

Hi Regards, Ferruh

Quoted 55 lines

-----Original Message-----
From: Iremonger, Bernard
Sent: Monday, September 23, 2019 10:18 PM
To: Yigit, Ferruh <[email protected]>; Wang, ShougangX <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start fwd

Hi ShougangX, Ferruh,

Quoted 37 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ferruh Yigit
Sent: Monday, September 23, 2019 12:04 PM
To: Wang, ShougangX <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start fwd

Quoted 11 lines · ShougangX
Quoted 2 lines

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.

Quoted 2 lines

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:

Quoted 2 lines

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.

Quoted 4 lines

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.

Quoted 1 line
Quoted 6 lines
Quoted 2 lines

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

Quoted 9 lines

problem.

Quoted 3 lines

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.

Quoted 125 lines
Quoted 18 lines

[1] see: The Zen of Python :)

Quoted 15 lines

Thanks.
Shougang

Quoted 10 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Monday, September 16, 2019 11:28 PM
To: Wang, ShougangX <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>; [email protected]
Subject: Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start fwd

On 9/16/2019 7:37 AM, Wang, ShougangX wrote:

Quoted 11 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Hi Ferruh

Thanks for your reply.

Quoted 3 lines

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.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

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.

Quoted 95 lines
Quoted 80 lines
Quoted 80 lines
Quoted 2 lines

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.

Quoted 1 line

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.

Quoted 7 lines
Quoted 4 lines

- '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.

Quoted 59 lines
Quoted 4 lines

- 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

Quoted 48 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Saturday, September 14, 2019 1:35 AM
To: Wang, ShougangX <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>; [email protected]
Subject: Re: [dpdk-stable] [PATCH] app/testpmd: fix Segment fault when start fwd

Quoted 27 lines · Wang ShougangX

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")
---
 app/test-pmd/testpmd.c | 6 ++++++
 1 file changed, 6 insertions(+)
app/test-pmd/testpmd.c +0 -0

index
e8e2a39b6..273a7aa02 100644

app/test-pmd/testpmd.c +3 -0
@@ -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) {

app/test-pmd/testpmd.c reset_port(portid_t pid) · line 2382

Quoted 8 lines
app/test-pmd/testpmd.c +3 -0
@@ -2372,6 +2375,9 @@ reset_port(portid_t pid)
 		}
 	}
 
+	printf("Starting ports...\n");
+	start_port(pid);
+
 	printf("Done\n");
 }

Hi Shougang,

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

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.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

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?

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Thanks,
ferruh

Regards,

Bernard.

Thanks.
Shougang

#9 lore raw

PATCH v2 1/1 app/testpmd: fix Segment fault when start fwd

In reply to Wang ShougangX

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")
---
 app/test-pmd/testpmd.c                      | 2 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 9 +++++++++
 2 files changed, 11 insertions(+)
app/test-pmd/testpmd.c +2 -0
index e8e2a39b6..9224aa1f7 100644
@@ -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) {
doc/guides/testpmd_app_ug/testpmd_funcs.rst +9 -0
index 313e0707e..2c459810c 100644
@@ -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
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Signature · 1 line
2.17.1
#10 lore raw

Hi Shougangx

Quoted 27 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Wang ShougangX
Sent: Friday, September 20, 2019 4:14 AM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>; Yigit, Ferruh <[email protected]>; Wang, ShougangX <[email protected]>; [email protected]
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")
---
 app/test-pmd/testpmd.c                      | 2 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 9 +++++++++
 2 files changed, 11 insertions(+)
app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0 -0

e8e2a39b6..9224aa1f7 100644

app/test-pmd/testpmd.c reset_port(portid_t pid) · line 2351

Quoted 8 lines
app/test-pmd/testpmd.c +2 -0
@@ -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.

Quoted 22 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +9 -1
index 313e0707e..2c459810c 100644
@@ -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
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
--
Quoted 1 line

2.17.1

Regards,

Bernard.

#11 lore raw

Hi Bernard

Quoted 2 lines

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

Quoted 78 lines

-----Original Message-----
From: Iremonger, Bernard
Sent: Monday, September 23, 2019 6:20 PM
To: Wang, ShougangX <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>; Yigit, Ferruh <[email protected]>; Wang, ShougangX <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v2] app/testpmd: fix Segment fault when start fwd

Hi Shougangx

Quoted 27 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Wang ShougangX
Sent: Friday, September 20, 2019 4:14 AM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>; Yigit, Ferruh <[email protected]>; Wang, ShougangX <[email protected]>; [email protected]
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")
---
 app/test-pmd/testpmd.c                      | 2 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 9 +++++++++
 2 files changed, 11 insertions(+)
app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0 -0

e8e2a39b6..9224aa1f7 100644

app/test-pmd/testpmd.c reset_port(portid_t pid) · line 2351

Quoted 8 lines
app/test-pmd/testpmd.c +2 -0
@@ -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.

Quoted 22 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +9 -1
index 313e0707e..2c459810c 100644
@@ -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
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
--
Quoted 1 line

2.17.1

Regards,

Bernard.

#12 lore raw

PATCH v3 1/1 app/testpmd: fix Segment fault when start fwd

In reply to Wang ShougangX

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")
---
 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(+)
app/test-pmd/cmdline.c +3 -0
index 56783aa13..9d0c3db5e 100644
@@ -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"
 
app/test-pmd/testpmd.c +6 -0
index e8e2a39b6..9b7a1521a 100644
@@ -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) {
doc/guides/testpmd_app_ug/testpmd_funcs.rst +9 -0
index 313e0707e..b1a14cc4e 100644
@@ -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
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Signature · 1 line
2.17.1
Acked-by on v3 1/1
#13 lore raw
Quoted 9 lines

-----Original Message-----
From: Wang, ShougangX
Sent: Tuesday, September 24, 2019 5:49 AM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Iremonger, Bernard <[email protected]>; Yigit, Ferruh <[email protected]>; Wang, ShougangX <[email protected]>; [email protected]
Subject: [PATCH v3] app/testpmd: fix Segment fault when start fwd

Quoted 7 lines

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")
Applied
#14 lore raw
Quoted 12 lines · Bernard
Quoted 12 lines

-----Original Message-----
From: Wang, ShougangX
Sent: Tuesday, September 24, 2019 5:49 AM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Iremonger, Bernard <[email protected]>; Yigit, Ferruh <[email protected]>; Wang, ShougangX <[email protected]>; [email protected]
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.

Quoted 7 lines
Quoted 4 lines
Fixes 97f1e19679 ("app/testpmd: add port reset command")

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