From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 369BA37B7 for ; Wed, 21 Jun 2017 09:26:15 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP; 21 Jun 2017 00:26:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,368,1493708400"; d="scan'208";a="101899241" Received: from silpixa00399464.ir.intel.com (HELO silpixa00399464.ger.corp.intel.com) ([10.237.222.157]) by orsmga002.jf.intel.com with ESMTP; 21 Jun 2017 00:26:11 -0700 From: Pablo de Lara To: thomas@monjalon.net, declan.doherty@intel.com Cc: dev@dpdk.org, Pablo de Lara Date: Wed, 21 Jun 2017 00:25:51 +0100 Message-Id: <20170620232555.82244-2-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170620232555.82244-1-pablo.de.lara.guarch@intel.com> References: <20170620232555.82244-1-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH 1/5] eal: check if socket has memory reserved X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jun 2017 07:26:15 -0000 Several drivers and apps check if a socket has reserved memory, by implementing their own function, which returns the total number of sockets that have memory. This function is not really useful, as the main goal is to check if memory on a specific socket is available, rather than checking if a socket id is beyond the total number of sockets (there could be a socket in the middle with no memory). Therefore, it looks more useful to have a function in EAL that can be used in these files. Signed-off-by: Pablo de Lara --- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 7 +++++++ lib/librte_eal/common/eal_common_memory.c | 17 +++++++++++++++++ lib/librte_eal/common/include/rte_memory.h | 9 +++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 7 +++++++ 4 files changed, 40 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index 2e48a73..85813e3 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -193,3 +193,10 @@ DPDK_17.05 { vfio_get_group_no; } DPDK_17.02; + +DPDK_17.08 { + global: + + rte_eal_has_memory_socket; + +} DPDK_17.05; diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c index 6155752..9811d06 100644 --- a/lib/librte_eal/common/eal_common_memory.c +++ b/lib/librte_eal/common/eal_common_memory.c @@ -120,6 +120,23 @@ unsigned rte_memory_get_nrank(void) return rte_eal_get_configuration()->mem_config->nrank; } +/** + * Return if socket has memory reserved. + */ +unsigned int +rte_eal_has_memory_socket(uint8_t socket_id) +{ + unsigned 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 (ms[i].socket_id == (int) socket_id) + return 1; + } + + return 0; +} + static int rte_eal_memdevice_init(void) { diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h index 4aa5d1f..e5fa902 100644 --- a/lib/librte_eal/common/include/rte_memory.h +++ b/lib/librte_eal/common/include/rte_memory.h @@ -195,6 +195,15 @@ unsigned rte_memory_get_nchannel(void); */ unsigned rte_memory_get_nrank(void); +/** + * Return if socket has memory reserved. + * + * @return + * - 0 if socket has no memory reserved. + * - 1 if socket has memory reserved.. + */ +unsigned int rte_eal_has_memory_socket(uint8_t socket_id); + #ifdef RTE_LIBRTE_XEN_DOM0 /**< Internal use only - should DOM0 memory mapping be used */ diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index 670bab3..0b3ba7f 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -198,3 +198,10 @@ DPDK_17.05 { vfio_get_group_no; } DPDK_17.02; + +DPDK_17.08 { + global: + + rte_eal_has_memory_socket; + +} DPDK_17.05; -- 2.9.4