[v2] app/testpmd: fix interactive mode with no ports

Message ID 20221109170918.2887-1-getelson@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series [v2] app/testpmd: fix interactive mode with no ports |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

Gregory Etelson Nov. 9, 2022, 5:09 p.m. UTC
  Testpmd terminated unconditionally if it failed to start all ports.

The patch allows testpmd to get into the command line,
if the interactive mode was requested.

Fixes: 6937d2103e22 ("app/testpmd: add option to not start device")

Cc: stephen@networkplumber.org
Cc: stable@dpdk.org

Signed-off-by: Gregory Etelson <getelson@nvidia.com>
---
v2: add Cc
---
 app/test-pmd/testpmd.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
  

Comments

Singh, Aman Deep Nov. 16, 2022, 4:23 a.m. UTC | #1
Hi Gregory,

Thanks for the patch.

On 11/9/2022 10:39 PM, Gregory Etelson wrote:
> Testpmd terminated unconditionally if it failed to start all ports.
>
> The patch allows testpmd to get into the command line,
> if the interactive mode was requested.

I tested testpmd in interactive mode with no ports.
It did get into command line-

$./dpdk-testpmd -n 4 -c 0x1f -- -i
testpmd: No probed ethernet devices
Interactive-mode selected
testpmd: create a new mbuf pool <mb_pool_0>: n=179456, size=2176, socket=0
testpmd: preferred mempool ops selected: ring_mp_mc
Done
testpmd>

>
> Fixes: 6937d2103e22 ("app/testpmd: add option to not start device")
>
> Cc: stephen@networkplumber.org
> Cc: stable@dpdk.org
>
> Signed-off-by: Gregory Etelson <getelson@nvidia.com>
> ---
> v2: add Cc
> ---
>   app/test-pmd/testpmd.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
> index 7381dfd9e5..8517f376db 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -4433,8 +4433,11 @@ main(int argc, char** argv)
>   		}
>   	}
>   
> -	if (!no_device_start && start_port(RTE_PORT_ALL) != 0)

With no ports, start_port returns 0 so it doesn't exits.

> -		rte_exit(EXIT_FAILURE, "Start ports failed\n");
> +	if (!no_device_start && start_port(RTE_PORT_ALL) != 0) {
> +		fprintf(stderr, "Start ports failed\n");
> +		if (!interactive)
> +			goto eal_out;
> +	}
>   
>   	/* set all ports to promiscuous mode by default */
>   	RTE_ETH_FOREACH_DEV(port_id) {
> @@ -4526,6 +4529,7 @@ main(int argc, char** argv)
>   			return 1;
>   	}
>   
> +eal_out:
>   	ret = rte_eal_cleanup();
>   	if (ret != 0)
>   		rte_exit(EXIT_FAILURE,
  
Ferruh Yigit Jan. 19, 2023, 3:09 p.m. UTC | #2
On 11/16/2022 4:23 AM, Singh, Aman Deep wrote:
> Hi Gregory,
> 
> Thanks for the patch.
> 
> On 11/9/2022 10:39 PM, Gregory Etelson wrote:
>> Testpmd terminated unconditionally if it failed to start all ports.
>>
>> The patch allows testpmd to get into the command line,
>> if the interactive mode was requested.
> 
> I tested testpmd in interactive mode with no ports.
> It did get into command line-
> 
> $./dpdk-testpmd -n 4 -c 0x1f -- -i
> testpmd: No probed ethernet devices
> Interactive-mode selected
> testpmd: create a new mbuf pool <mb_pool_0>: n=179456, size=2176, socket=0
> testpmd: preferred mempool ops selected: ring_mp_mc
> Done
> testpmd>
> 
>>
>> Fixes: 6937d2103e22 ("app/testpmd: add option to not start device")
>>
>> Cc: stephen@networkplumber.org
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Gregory Etelson <getelson@nvidia.com>
>> ---
>> v2: add Cc
>> ---
>>   app/test-pmd/testpmd.c | 8 ++++++--
>>   1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
>> index 7381dfd9e5..8517f376db 100644
>> --- a/app/test-pmd/testpmd.c
>> +++ b/app/test-pmd/testpmd.c
>> @@ -4433,8 +4433,11 @@ main(int argc, char** argv)
>>           }
>>       }
>>   -    if (!no_device_start && start_port(RTE_PORT_ALL) != 0)
> 
> With no ports, start_port returns 0 so it doesn't exits.
> 

Hi Aman,

I think patch is for the case port exists and 'start_port()' failed, in
that case testpmd exits.

With patch, testpmd only continues after 'start_port()' failure only if
interactive mode is selected, that also looks good to me.


Gregory,

Only for non interactive case if 'start_port()' fails, application exit
value changed to 'EXIT_SUCCESS', which is not quite right, can you
please fix it?

>> -        rte_exit(EXIT_FAILURE, "Start ports failed\n");
>> +    if (!no_device_start && start_port(RTE_PORT_ALL) != 0) {
>> +        fprintf(stderr, "Start ports failed\n");
>> +        if (!interactive)
>> +            goto eal_out;
>> +    }
>>         /* set all ports to promiscuous mode by default */
>>       RTE_ETH_FOREACH_DEV(port_id) {
>> @@ -4526,6 +4529,7 @@ main(int argc, char** argv)
>>               return 1;
>>       }
>>   +eal_out:
>>       ret = rte_eal_cleanup();
>>       if (ret != 0)
>>           rte_exit(EXIT_FAILURE,
>
  

Patch

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 7381dfd9e5..8517f376db 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -4433,8 +4433,11 @@  main(int argc, char** argv)
 		}
 	}
 
-	if (!no_device_start && start_port(RTE_PORT_ALL) != 0)
-		rte_exit(EXIT_FAILURE, "Start ports failed\n");
+	if (!no_device_start && start_port(RTE_PORT_ALL) != 0) {
+		fprintf(stderr, "Start ports failed\n");
+		if (!interactive)
+			goto eal_out;
+	}
 
 	/* set all ports to promiscuous mode by default */
 	RTE_ETH_FOREACH_DEV(port_id) {
@@ -4526,6 +4529,7 @@  main(int argc, char** argv)
 			return 1;
 	}
 
+eal_out:
 	ret = rte_eal_cleanup();
 	if (ret != 0)
 		rte_exit(EXIT_FAILURE,