drivers: fix vmxnet3 return wrong error code in initializing
Checks
Commit Message
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
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
@@ -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