[dpdk-dev,v2,4/4] test/bonding: remove socket id check

Message ID 20170621050733.88850-5-pablo.de.lara.guarch@intel.com (mailing list archive)
State Accepted, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

De Lara Guarch, Pablo June 21, 2017, 5:07 a.m. UTC
  When creating a virtual pmd to test link bonding,
the socket id was checked, if it was in the range
of available sockets.
This check is unnecessary, as the socket specified
might not have memory anyway, so it will fail
at memory allocation.

Therefore, the best solution is to remove this check.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 test/test/virtual_pmd.c | 17 -----------------
 1 file changed, 17 deletions(-)
  

Comments

Doherty, Declan June 22, 2017, 11:48 a.m. UTC | #1
On 21/06/2017 6:07 AM, Pablo de Lara wrote:
> When creating a virtual pmd to test link bonding,
> the socket id was checked, if it was in the range
> of available sockets.
> This check is unnecessary, as the socket specified
> might not have memory anyway, so it will fail
> at memory allocation.
>
> Therefore, the best solution is to remove this check.
>
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> ---
...
>

Acked-by: Declan Doherty <declan.doherty@intel.com>
  

Patch

diff --git a/test/test/virtual_pmd.c b/test/test/virtual_pmd.c
index e9dd8ac..f1ea3e1 100644
--- a/test/test/virtual_pmd.c
+++ b/test/test/virtual_pmd.c
@@ -511,20 +511,6 @@  virtual_ethdev_get_mbufs_from_tx_queue(uint8_t port_id,
 		burst_length, NULL);
 }
 
-static uint8_t
-get_number_of_sockets(void)
-{
-	int sockets = 0;
-	int i;
-	const struct rte_memseg *ms = rte_eal_get_physmem_layout();
-
-	for (i = 0; i < RTE_MAX_MEMSEG && ms[i].addr != NULL; i++) {
-		if (sockets < ms[i].socket_id)
-			sockets = ms[i].socket_id;
-	}
-	/* Number of sockets = maximum socket_id + 1 */
-	return ++sockets;
-}
 
 int
 virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
@@ -542,9 +528,6 @@  virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
 	 * and internal (dev_private) data
 	 */
 
-	if (socket_id >= get_number_of_sockets())
-		goto err;
-
 	pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, socket_id);
 	if (pci_dev == NULL)
 		goto err;