drivers: fix vmxnet3 return wrong error code in initializing

Message ID 20230528143734.145326-1-user@sklga (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series drivers: fix vmxnet3 return wrong error code in initializing |

Checks

Context Check Description
ci/checkpatch warning coding style issues
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/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-unit-testing success Testing PASS

Commit Message

Kaijun Zeng May 28, 2023, 2:37 p.m. UTC
  From: Kaijun Zeng <corezeng@gmail.com>

In vmxnet3_dev_rxtx_init(), a wrong error code may be thrown after it invokes
vmxnet3_post_rx_bufs() because it negates the error code before returning it.
It causes rte_eth_dev_start() to give a positive number to the invoker, but it
should be a negative number, as described in the comments.

Bugzilla ID: 1239

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

Comments

Ferruh Yigit June 1, 2023, 3:12 p.m. UTC | #1
On 5/28/2023 3:37 PM, root wrote:
> From: Kaijun Zeng <corezeng@gmail.com>
> 
> In vmxnet3_dev_rxtx_init(), a wrong error code may be thrown after it invokes
> vmxnet3_post_rx_bufs() because it negates the error code before returning it.
> It causes rte_eth_dev_start() to give a positive number to the invoker, but it
> should be a negative number, as described in the comments.
> 
> Bugzilla ID: 1239
> 
> Signed-off-by: Kaijun Zeng <corezeng@gmail.com>
> ---
>  drivers/net/vmxnet3/vmxnet3_rxtx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/vmxnet3/vmxnet3_rxtx.c b/drivers/net/vmxnet3/vmxnet3_rxtx.c
> index a875ffec07..73ec1e4727 100644
> --- a/drivers/net/vmxnet3/vmxnet3_rxtx.c
> +++ b/drivers/net/vmxnet3/vmxnet3_rxtx.c
> @@ -1315,7 +1315,7 @@ vmxnet3_dev_rxtx_init(struct rte_eth_dev *dev)
>  				PMD_INIT_LOG(ERR,
>  					     "ERROR: Posting Rxq: %d buffers ring: %d",
>  					     i, j);
> -				return -ret;
> +				return ret;


Hi Kaijun,

Thanks for the fix, it looks valid.

But 'ret' being 0 also seems problematic, mentioned code is as following:
```
ret = vmxnet3_post_rx_bufs(rxq, j);
if (ret <= 0) {
	PMD_INIT_LOG(ERR,
		"ERROR: Posting Rxq: %d buffers ring: %d", i, j);
	return ret;
}
```

'vmxnet3_dev_rxtx_init()' can return 0 and failure, but caller will take
it as success.

Perhaps better to send an explicit error:

```
if (ret <= 0) {
	...
	return -EXXX
}
```




btw, for the next version of the patch, please use 'net/vmxnet3: '
prefix for patch title, like:
"net/vmxnet3: fix return code in initializing"

Also please include following Fixes tag in the commit log:
```
Fixes: dfaff37fc46d ("vmxnet3: import new vmxnet3 poll mode driver
implementation")
Cc: stable@dpdk.org
```

For more details you can check contribution guide:
https://doc.dpdk.org/guides/contributing/patches.html#commit-messages-subject-line
  

Patch

diff --git a/drivers/net/vmxnet3/vmxnet3_rxtx.c b/drivers/net/vmxnet3/vmxnet3_rxtx.c
index a875ffec07..73ec1e4727 100644
--- a/drivers/net/vmxnet3/vmxnet3_rxtx.c
+++ b/drivers/net/vmxnet3/vmxnet3_rxtx.c
@@ -1315,7 +1315,7 @@  vmxnet3_dev_rxtx_init(struct rte_eth_dev *dev)
 				PMD_INIT_LOG(ERR,
 					     "ERROR: Posting Rxq: %d buffers ring: %d",
 					     i, j);
-				return -ret;
+				return ret;
 			}
 			/*
 			 * Updating device with the index:next2fill to fill the