[dpdk-dev,v4,2/3] ethdev: copy device configuration earlier

Message ID 1458832924-1489-3-git-send-email-pablo.de.lara.guarch@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Bruce Richardson
Headers

Commit Message

De Lara Guarch, Pablo March 24, 2016, 3:22 p.m. UTC
  In rte_eth_dev_configure(), device configuration was copied
after requesting the device information, to check the
maximum number of RX/TX queues. Since this number may change
depending on the device configuration, the memcpy of it
has to be performed before requesting the device information.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Comments

John McNamara March 24, 2016, 4:57 p.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Pablo de Lara
> Sent: Thursday, March 24, 2016 3:22 PM
> To: dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Richardson, Bruce
> <bruce.richardson@intel.com>; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>
> Subject: [dpdk-dev] [PATCH v4 2/3] ethdev: copy device configuration
> earlier
> 
> In rte_eth_dev_configure(), device configuration was copied after
> requesting the device information, to check the maximum number of RX/TX
> queues. Since this number may change depending on the device
> configuration, the memcpy of it has to be performed before requesting the
> device information.
> 
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>


Acked-by: John McNamara <john.mcnamara@intel.com>
  

Patch

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 8721a6b..b941b0d 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -901,6 +901,9 @@  rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		return -EBUSY;
 	}
 
+	/* Copy the dev_conf parameter into the dev structure */
+	memcpy(&dev->data->dev_conf, dev_conf, sizeof(dev->data->dev_conf));
+
 	/*
 	 * Check that the numbers of RX and TX queues are not greater
 	 * than the maximum number of RX and TX queues supported by the
@@ -925,9 +928,6 @@  rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		return -EINVAL;
 	}
 
-	/* Copy the dev_conf parameter into the dev structure */
-	memcpy(&dev->data->dev_conf, dev_conf, sizeof(dev->data->dev_conf));
-
 	/*
 	 * If link state interrupt is enabled, check that the
 	 * device supports it.