[v2] net/vmxnet3: fix return code in initializing

Message ID 20230602164438.45939-1-corezeng@gmail.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series [v2] net/vmxnet3: fix return code in initializing |

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/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-unit-testing success Testing PASS
ci/iol-aarch-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

Kaijun Zeng June 2, 2023, 4:44 p.m. UTC
  Improve error handling

Fixes: dfaff37fc46d ("vmxnet3: import new vmxnet3 poll mode driver implementation")
Cc: stable@dpdk.org

Signed-off-by: Kaijun Zeng <corezeng@gmail.com>
---
 drivers/net/vmxnet3/vmxnet3_rxtx.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
  

Comments

Ferruh Yigit June 6, 2023, 9:08 a.m. UTC | #1
On 6/2/2023 5:44 PM, Kaijun Zeng wrote:
> Improve error handling
> 
> Fixes: dfaff37fc46d ("vmxnet3: import new vmxnet3 poll mode driver implementation")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Kaijun Zeng <corezeng@gmail.com>
> ---
>  drivers/net/vmxnet3/vmxnet3_rxtx.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/vmxnet3/vmxnet3_rxtx.c b/drivers/net/vmxnet3/vmxnet3_rxtx.c
> index 73ec1e4727..e615d40d09 100644
> --- a/drivers/net/vmxnet3/vmxnet3_rxtx.c
> +++ b/drivers/net/vmxnet3/vmxnet3_rxtx.c
> @@ -1311,7 +1311,17 @@ vmxnet3_dev_rxtx_init(struct rte_eth_dev *dev)
>  		for (j = 0; j < VMXNET3_RX_CMDRING_SIZE; j++) {
>  			/* Passing 0 as alloc_num will allocate full ring */
>  			ret = vmxnet3_post_rx_bufs(rxq, j);
> -			if (ret <= 0) {
> +
> +			/* Zero number of descriptors in the configuration of the RX queue */
> +			if (ret == 0) {
> +				PMD_INIT_LOG(ERR,
> +					"ERROR: Zero descriptor requirement in Rx queue: %d,"
> +					"buffers ring: %d\n",
> +					i, j);
> +				return -EINVAL;
> +			}
> +			/* Return the errno */
> +			if (ret < 0) {
>  				PMD_INIT_LOG(ERR,
>  					     "ERROR: Posting Rxq: %d buffers ring: %d",
>  					     i, j);


Looks good to me, @Jochen any objection?
  
Stephen Hemminger June 6, 2023, 3:36 p.m. UTC | #2
On Fri,  2 Jun 2023 12:44:38 -0400
Kaijun Zeng <corezeng@gmail.com> wrote:

> +				PMD_INIT_LOG(ERR,
> +					"ERROR: Zero descriptor requirement in Rx queue: %d,"
> +					"buffers ring: %d\n",
> +					i, j);

Please don't split messages across source lines, it makes harder for developers
to use tools to scan source for message.

Often, when message is long, it means that there is redundant information or poor wording.
For example, in your message "ERROR:" is redundant.
  
Ferruh Yigit June 7, 2023, 3:49 p.m. UTC | #3
On 6/6/2023 4:36 PM, Stephen Hemminger wrote:
> On Fri,  2 Jun 2023 12:44:38 -0400
> Kaijun Zeng <corezeng@gmail.com> wrote:
> 
>> +				PMD_INIT_LOG(ERR,
>> +					"ERROR: Zero descriptor requirement in Rx queue: %d,"
>> +					"buffers ring: %d\n",
>> +					i, j);
> 
> Please don't split messages across source lines, it makes harder for developers
> to use tools to scan source for message.
> 
> Often, when message is long, it means that there is redundant information or poor wording.
> For example, in your message "ERROR:" is redundant.
>

Agree that 'ERROR:' is redundant, and +1 to not split log message.

Kaijun,

Would you mind sending a new version with above changes?

Thanks,
ferruh
  

Patch

diff --git a/drivers/net/vmxnet3/vmxnet3_rxtx.c b/drivers/net/vmxnet3/vmxnet3_rxtx.c
index 73ec1e4727..e615d40d09 100644
--- a/drivers/net/vmxnet3/vmxnet3_rxtx.c
+++ b/drivers/net/vmxnet3/vmxnet3_rxtx.c
@@ -1311,7 +1311,17 @@  vmxnet3_dev_rxtx_init(struct rte_eth_dev *dev)
 		for (j = 0; j < VMXNET3_RX_CMDRING_SIZE; j++) {
 			/* Passing 0 as alloc_num will allocate full ring */
 			ret = vmxnet3_post_rx_bufs(rxq, j);
-			if (ret <= 0) {
+
+			/* Zero number of descriptors in the configuration of the RX queue */
+			if (ret == 0) {
+				PMD_INIT_LOG(ERR,
+					"ERROR: Zero descriptor requirement in Rx queue: %d,"
+					"buffers ring: %d\n",
+					i, j);
+				return -EINVAL;
+			}
+			/* Return the errno */
+			if (ret < 0) {
 				PMD_INIT_LOG(ERR,
 					     "ERROR: Posting Rxq: %d buffers ring: %d",
 					     i, j);