examples/dma: fix max-frame-size cannot be zero

Message ID 20240220023153.29793-1-fengchengwen@huawei.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series examples/dma: fix max-frame-size cannot be zero |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

fengchengwen Feb. 20, 2024, 2:31 a.m. UTC
  In the original implementation, the max_frame_size could be zero, but
commit ("examples/dma: replace getopt with argparse") treat zero as an
error. This commit fixes it.

Also, since unsigned doesn't < 0, adjust "<= 0" judgement to "== 0".

Fixes: 8d85afb19af7 ("examples/dma: replace getopt with argparse")

Reported-by: Jiang, YuX <yux.jiang@intel.com>
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 examples/dma/dmafwd.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
  

Comments

Yu Jiang Feb. 21, 2024, 6:51 a.m. UTC | #1
> -----Original Message-----
> From: Chengwen Feng <fengchengwen@huawei.com>
> Sent: Tuesday, February 20, 2024 10:32 AM
> To: thomas@monjalon.net; dev@dpdk.org; Jiang, YuX <yux.jiang@intel.com>;
> Richardson, Bruce <bruce.richardson@intel.com>; Laatz, Kevin
> <kevin.laatz@intel.com>
> Subject: [PATCH] examples/dma: fix max-frame-size cannot be zero
> 
> In the original implementation, the max_frame_size could be zero, but commit
> ("examples/dma: replace getopt with argparse") treat zero as an error. This
> commit fixes it.
> 
> Also, since unsigned doesn't < 0, adjust "<= 0" judgement to "== 0".
> 
> Fixes: 8d85afb19af7 ("examples/dma: replace getopt with argparse")
> 
> Reported-by: Jiang, YuX <yux.jiang@intel.com>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
>  examples/dma/dmafwd.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/examples/dma/dmafwd.c b/examples/dma/dmafwd.c index
> f4a0bff06e..acceae6b7b 100644
> --- a/examples/dma/dmafwd.c
> +++ b/examples/dma/dmafwd.c
> @@ -695,23 +695,23 @@ dma_parse_args(int argc, char **argv, unsigned int
> nb_ports)
>  		return ret;
> 
>  	/* check argument's value which parsing by autosave. */
> -	if (dma_batch_sz <= 0 || dma_batch_sz > MAX_PKT_BURST) {
> +	if (dma_batch_sz == 0 || dma_batch_sz > MAX_PKT_BURST) {
>  		printf("Invalid dma batch size, %d.\n", dma_batch_sz);
>  		return -1;
>  	}
> 
> -	if (max_frame_size <= 0 || max_frame_size >
> RTE_ETHER_MAX_JUMBO_FRAME_LEN) {
> +	if (max_frame_size > RTE_ETHER_MAX_JUMBO_FRAME_LEN) {
>  		printf("Invalid max frame size, %d.\n", max_frame_size);
>  		return -1;
>  	}
> 
> -	if (nb_queues <= 0 || nb_queues > MAX_RX_QUEUES_COUNT) {
> +	if (nb_queues == 0 || nb_queues > MAX_RX_QUEUES_COUNT) {
>  		printf("Invalid RX queues number %d. Max %u\n",
>  			nb_queues, MAX_RX_QUEUES_COUNT);
>  		return -1;
>  	}
> 
> -	if (ring_size <= 0) {
> +	if (ring_size == 0) {
>  		printf("Invalid ring size, %d.\n", ring_size);
>  		return -1;
>  	}
> @@ -721,7 +721,7 @@ dma_parse_args(int argc, char **argv, unsigned int
> nb_ports)
>  		ring_size = MBUF_RING_SIZE;
>  	}
> 
> -	if (stats_interval <= 0) {
> +	if (stats_interval == 0) {
>  		printf("Invalid stats interval, setting to 1\n");
>  		stats_interval = 1;	/* set to default */
>  	}
> --
> 2.17.1

Tested-by:  Yu Jiang <yux.jiang@intel.com>

Best regards,
Yu Jiang
  
fengchengwen March 5, 2024, 11:42 a.m. UTC | #2
Hi Thomas,

This commit fix bug "Bug 1387 - [dpdk24.03] cbdma: Failed to launch dpdk-dma app" [1]

Should I send v2 to add the following line in commit log?
Bugzilla ID: 1387

[1] https://bugs.dpdk.org/show_bug.cgi?id=1387

Thanks

On 2024/2/21 14:51, Jiang, YuX wrote:
>> -----Original Message-----
>> From: Chengwen Feng <fengchengwen@huawei.com>
>> Sent: Tuesday, February 20, 2024 10:32 AM
>> To: thomas@monjalon.net; dev@dpdk.org; Jiang, YuX <yux.jiang@intel.com>;
>> Richardson, Bruce <bruce.richardson@intel.com>; Laatz, Kevin
>> <kevin.laatz@intel.com>
>> Subject: [PATCH] examples/dma: fix max-frame-size cannot be zero
>>
>> In the original implementation, the max_frame_size could be zero, but commit
>> ("examples/dma: replace getopt with argparse") treat zero as an error. This
>> commit fixes it.
>>
>> Also, since unsigned doesn't < 0, adjust "<= 0" judgement to "== 0".
>>
>> Fixes: 8d85afb19af7 ("examples/dma: replace getopt with argparse")
>>
>> Reported-by: Jiang, YuX <yux.jiang@intel.com>
>> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
>> ---
>>  examples/dma/dmafwd.c | 10 +++++-----
>>  1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/examples/dma/dmafwd.c b/examples/dma/dmafwd.c index
>> f4a0bff06e..acceae6b7b 100644
>> --- a/examples/dma/dmafwd.c
>> +++ b/examples/dma/dmafwd.c
>> @@ -695,23 +695,23 @@ dma_parse_args(int argc, char **argv, unsigned int
>> nb_ports)
>>  		return ret;
>>
>>  	/* check argument's value which parsing by autosave. */
>> -	if (dma_batch_sz <= 0 || dma_batch_sz > MAX_PKT_BURST) {
>> +	if (dma_batch_sz == 0 || dma_batch_sz > MAX_PKT_BURST) {
>>  		printf("Invalid dma batch size, %d.\n", dma_batch_sz);
>>  		return -1;
>>  	}
>>
>> -	if (max_frame_size <= 0 || max_frame_size >
>> RTE_ETHER_MAX_JUMBO_FRAME_LEN) {
>> +	if (max_frame_size > RTE_ETHER_MAX_JUMBO_FRAME_LEN) {
>>  		printf("Invalid max frame size, %d.\n", max_frame_size);
>>  		return -1;
>>  	}
>>
>> -	if (nb_queues <= 0 || nb_queues > MAX_RX_QUEUES_COUNT) {
>> +	if (nb_queues == 0 || nb_queues > MAX_RX_QUEUES_COUNT) {
>>  		printf("Invalid RX queues number %d. Max %u\n",
>>  			nb_queues, MAX_RX_QUEUES_COUNT);
>>  		return -1;
>>  	}
>>
>> -	if (ring_size <= 0) {
>> +	if (ring_size == 0) {
>>  		printf("Invalid ring size, %d.\n", ring_size);
>>  		return -1;
>>  	}
>> @@ -721,7 +721,7 @@ dma_parse_args(int argc, char **argv, unsigned int
>> nb_ports)
>>  		ring_size = MBUF_RING_SIZE;
>>  	}
>>
>> -	if (stats_interval <= 0) {
>> +	if (stats_interval == 0) {
>>  		printf("Invalid stats interval, setting to 1\n");
>>  		stats_interval = 1;	/* set to default */
>>  	}
>> --
>> 2.17.1
> 
> Tested-by:  Yu Jiang <yux.jiang@intel.com>
> 
> Best regards,
> Yu Jiang
> .
>
  
Thomas Monjalon March 5, 2024, 12:52 p.m. UTC | #3
05/03/2024 12:42, fengchengwen:
> Hi Thomas,
> 
> This commit fix bug "Bug 1387 - [dpdk24.03] cbdma: Failed to launch dpdk-dma app" [1]
> 
> Should I send v2 to add the following line in commit log?
> Bugzilla ID: 1387

I can add it while merging.
  
Thomas Monjalon March 7, 2024, 9:07 a.m. UTC | #4
05/03/2024 13:52, Thomas Monjalon:
> 05/03/2024 12:42, fengchengwen:
> > Hi Thomas,
> > 
> > This commit fix bug "Bug 1387 - [dpdk24.03] cbdma: Failed to launch dpdk-dma app" [1]
> > 
> > Should I send v2 to add the following line in commit log?
> > Bugzilla ID: 1387
> 
> I can add it while merging.

Applied, thanks.
  

Patch

diff --git a/examples/dma/dmafwd.c b/examples/dma/dmafwd.c
index f4a0bff06e..acceae6b7b 100644
--- a/examples/dma/dmafwd.c
+++ b/examples/dma/dmafwd.c
@@ -695,23 +695,23 @@  dma_parse_args(int argc, char **argv, unsigned int nb_ports)
 		return ret;
 
 	/* check argument's value which parsing by autosave. */
-	if (dma_batch_sz <= 0 || dma_batch_sz > MAX_PKT_BURST) {
+	if (dma_batch_sz == 0 || dma_batch_sz > MAX_PKT_BURST) {
 		printf("Invalid dma batch size, %d.\n", dma_batch_sz);
 		return -1;
 	}
 
-	if (max_frame_size <= 0 || max_frame_size > RTE_ETHER_MAX_JUMBO_FRAME_LEN) {
+	if (max_frame_size > RTE_ETHER_MAX_JUMBO_FRAME_LEN) {
 		printf("Invalid max frame size, %d.\n", max_frame_size);
 		return -1;
 	}
 
-	if (nb_queues <= 0 || nb_queues > MAX_RX_QUEUES_COUNT) {
+	if (nb_queues == 0 || nb_queues > MAX_RX_QUEUES_COUNT) {
 		printf("Invalid RX queues number %d. Max %u\n",
 			nb_queues, MAX_RX_QUEUES_COUNT);
 		return -1;
 	}
 
-	if (ring_size <= 0) {
+	if (ring_size == 0) {
 		printf("Invalid ring size, %d.\n", ring_size);
 		return -1;
 	}
@@ -721,7 +721,7 @@  dma_parse_args(int argc, char **argv, unsigned int nb_ports)
 		ring_size = MBUF_RING_SIZE;
 	}
 
-	if (stats_interval <= 0) {
+	if (stats_interval == 0) {
 		printf("Invalid stats interval, setting to 1\n");
 		stats_interval = 1;	/* set to default */
 	}