[dpdk-dev,v2,1/6] net/vmxnet3: improve error checks and return values

Message ID 1471997140-46527-2-git-send-email-yongwang@vmware.com (mailing list archive)
State Superseded, archived
Delegated to: Bruce Richardson
Headers

Commit Message

Yong Wang Aug. 24, 2016, 12:05 a.m. UTC
  Signed-off-by: Yong Wang <yongwang@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_ethdev.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
  

Comments

Yong Wang Aug. 29, 2016, 7:18 p.m. UTC | #1
v3:
* fixed transposed # of tx/rx queue comparison

v2:
* updated vmxnet3 feature doc.
* updated vmxnet3 guide to remove stale information.

v1: This patchset includes a few bug fixes and some enhancement.

* Fixed a bug with dev_configure memzone size;
* Enhanced error checks during device start.
  * the driver will now report error if the rx queue number is
    not a power of two, instead of waiting for the activation
    to fail.
  * Instead of returning -1 (which is interpreted as -EPERM) on
    device activation failure, -EINVAL is returned now.
* Enabled LRO if requested.

Yong Wang (6):
  net/vmxnet3: improve error checks and return values
  net/vmxnet3: coding style changes
  net/vmxnet3: reallocate shared memzone on re-config
  net/vmxnet3: update feature doc
  net/vmxnet3: update nic doc
  net/vmxnet3: enable lro

 doc/guides/nics/features/vmxnet3.ini |  22 ++++++
 doc/guides/nics/vmxnet3.rst          |  12 +---
 drivers/net/vmxnet3/vmxnet3_ethdev.c | 125 +++++++++++++++++++++--------------
 drivers/net/vmxnet3/vmxnet3_ethdev.h |  32 +++++----
 drivers/net/vmxnet3/vmxnet3_ring.h   |  22 +++---
 drivers/net/vmxnet3/vmxnet3_rxtx.c   |  59 +++++++++--------
 6 files changed, 158 insertions(+), 114 deletions(-)
  
Bruce Richardson Sept. 19, 2016, 2:44 p.m. UTC | #2
On Mon, Aug 29, 2016 at 12:18:44PM -0700, Yong Wang wrote:
> v3:
> * fixed transposed # of tx/rx queue comparison
> 
> v2:
> * updated vmxnet3 feature doc.
> * updated vmxnet3 guide to remove stale information.
> 
> v1: This patchset includes a few bug fixes and some enhancement.
> 
> * Fixed a bug with dev_configure memzone size;
> * Enhanced error checks during device start.
>   * the driver will now report error if the rx queue number is
>     not a power of two, instead of waiting for the activation
>     to fail.
>   * Instead of returning -1 (which is interpreted as -EPERM) on
>     device activation failure, -EINVAL is returned now.
> * Enabled LRO if requested.
> 
> Yong Wang (6):
>   net/vmxnet3: improve error checks and return values
>   net/vmxnet3: coding style changes
>   net/vmxnet3: reallocate shared memzone on re-config
>   net/vmxnet3: update feature doc
>   net/vmxnet3: update nic doc
>   net/vmxnet3: enable lro
> 
Applied to dpdk-next-net/rel_16_11

/Bruce
  

Patch

diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c
index 5874215..f5035bb 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c
@@ -360,9 +360,16 @@  vmxnet3_dev_configure(struct rte_eth_dev *dev)
 
 	PMD_INIT_FUNC_TRACE();
 
-	if (dev->data->nb_rx_queues > UINT8_MAX ||
-	    dev->data->nb_tx_queues > UINT8_MAX)
+	if (dev->data->nb_rx_queues > VMXNET3_MAX_TX_QUEUES ||
+	    dev->data->nb_tx_queues > VMXNET3_MAX_RX_QUEUES) {
+		PMD_INIT_LOG(ERR, "ERROR: Number of queues not supported");
 		return -EINVAL;
+	}
+
+	if (!rte_is_power_of_2(dev->data->nb_rx_queues)) {
+		PMD_INIT_LOG(ERR, "ERROR: Number of rx queues not power of 2");
+		return -EINVAL;
+	}
 
 	size = dev->data->nb_rx_queues * sizeof(struct Vmxnet3_TxQueueDesc) +
 		dev->data->nb_tx_queues * sizeof(struct Vmxnet3_RxQueueDesc);
@@ -550,7 +557,7 @@  vmxnet3_setup_driver_shared(struct rte_eth_dev *dev)
 static int
 vmxnet3_dev_start(struct rte_eth_dev *dev)
 {
-	int status, ret;
+	int ret;
 	struct vmxnet3_hw *hw = dev->data->dev_private;
 
 	PMD_INIT_FUNC_TRACE();
@@ -567,11 +574,11 @@  vmxnet3_dev_start(struct rte_eth_dev *dev)
 
 	/* Activate device by register write */
 	VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD, VMXNET3_CMD_ACTIVATE_DEV);
-	status = VMXNET3_READ_BAR1_REG(hw, VMXNET3_REG_CMD);
+	ret = VMXNET3_READ_BAR1_REG(hw, VMXNET3_REG_CMD);
 
-	if (status != 0) {
+	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Device activation: UNSUCCESSFUL");
-		return -1;
+		return -EINVAL;
 	}
 
 	/* Disable interrupts */
@@ -583,7 +590,7 @@  vmxnet3_dev_start(struct rte_eth_dev *dev)
 	 */
 	ret = vmxnet3_dev_rxtx_init(dev);
 	if (ret != VMXNET3_SUCCESS) {
-		PMD_INIT_LOG(ERR, "Device receive init: UNSUCCESSFUL");
+		PMD_INIT_LOG(ERR, "Device queue init: UNSUCCESSFUL");
 		return ret;
 	}
 
@@ -598,7 +605,7 @@  vmxnet3_dev_start(struct rte_eth_dev *dev)
 	PMD_INIT_LOG(DEBUG, "Reading events: 0x%X", events);
 	vmxnet3_process_events(hw);
 #endif
-	return status;
+	return VMXNET3_SUCCESS;
 }
 
 /*