From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pablo de Lara Subject: [PATCH 5/5] test/bonding: check if socket id has memory Date: Wed, 21 Jun 2017 00:25:55 +0100 Message-ID: <20170620232555.82244-6-pablo.de.lara.guarch@intel.com> References: <20170620232555.82244-1-pablo.de.lara.guarch@intel.com> Cc: dev@dpdk.org, Pablo de Lara To: thomas@monjalon.net, declan.doherty@intel.com Return-path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id B49C258CD for ; Wed, 21 Jun 2017 09:26:19 +0200 (CEST) In-Reply-To: <20170620232555.82244-1-pablo.de.lara.guarch@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Use new function to check if socket id has reserved memory, instead of implementing a local function that checks total number of sockets, to verify if selected socket id is beyond the range of sockets. Signed-off-by: Pablo de Lara --- test/test/virtual_pmd.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/test/test/virtual_pmd.c b/test/test/virtual_pmd.c index e9dd8ac..a874cd4 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,7 +528,7 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr, * and internal (dev_private) data */ - if (socket_id >= get_number_of_sockets()) + if (!rte_eal_has_memory_socket(socket_id)) goto err; pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, socket_id); -- 2.9.4