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

2023-06-05 Thread Kaijun Zeng
Improve error handling

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

Signed-off-by: Kaijun Zeng 
---
 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);
-- 
2.30.2



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

2023-06-07 Thread Kaijun Zeng
Improve error handling and code style

Bugzilla ID: 1239

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

Signed-off-by: Kaijun Zeng 

---
 drivers/net/vmxnet3/vmxnet3_rxtx.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_rxtx.c 
b/drivers/net/vmxnet3/vmxnet3_rxtx.c
index a875ffec07..e6e36dca93 100644
--- a/drivers/net/vmxnet3/vmxnet3_rxtx.c
+++ b/drivers/net/vmxnet3/vmxnet3_rxtx.c
@@ -1311,11 +1311,18 @@ 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: Posting Rxq: %d buffers 
ring: %d",
-i, j);
-   return -ret;
+   "Invalid configuration in Rx queue: %d, 
buffers ring: %d\n",
+   i, j);
+   return -EINVAL;
+   }
+   /* Return the error number */
+   if (ret < 0) {
+   PMD_INIT_LOG(ERR, "Posting Rxq: %d buffers 
ring: %d", i, j);
+   return ret;
}
/*
 * Updating device with the index:next2fill to fill the
-- 
2.30.2



[PATCH v3] net/vmxnet3: fix return code in initializing

2023-06-07 Thread Kaijun Zeng
Improve error handling

Bugzilla ID: 1239
Fixes: dfaff37fc46d ("vmxnet3: import new vmxnet3 poll mode driver 
implementation")
Cc: sta...@dpdk.org

Signed-off-by: Kaijun Zeng 
---
v3:
* Improve coding style

v2:
* Improve error handling
---
 drivers/net/vmxnet3/vmxnet3_rxtx.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_rxtx.c 
b/drivers/net/vmxnet3/vmxnet3_rxtx.c
index a875ffec07..e6e36dca93 100644
--- a/drivers/net/vmxnet3/vmxnet3_rxtx.c
+++ b/drivers/net/vmxnet3/vmxnet3_rxtx.c
@@ -1311,11 +1311,18 @@ 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: Posting Rxq: %d buffers 
ring: %d",
-i, j);
-   return -ret;
+   "Invalid configuration in Rx queue: %d, 
buffers ring: %d\n",
+   i, j);
+   return -EINVAL;
+   }
+   /* Return the error number */
+   if (ret < 0) {
+   PMD_INIT_LOG(ERR, "Posting Rxq: %d buffers 
ring: %d", i, j);
+   return ret;
}
/*
 * Updating device with the index:next2fill to fill the
-- 
2.30.2