From patchwork Fri Jul 6 13:17:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Burakov X-Patchwork-Id: 42499 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3DF491BEC1; Fri, 6 Jul 2018 15:17:41 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 296591BE43 for ; Fri, 6 Jul 2018 15:17:36 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jul 2018 06:17:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,316,1526367600"; d="scan'208";a="238320016" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga005.jf.intel.com with ESMTP; 06 Jul 2018 06:17:33 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id w66DHXal027472; Fri, 6 Jul 2018 14:17:33 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id w66DHXFe003754; Fri, 6 Jul 2018 14:17:33 +0100 Received: (from aburakov@localhost) by sivswdev01.ir.intel.com with LOCAL id w66DHXnI003749; Fri, 6 Jul 2018 14:17:33 +0100 From: Anatoly Burakov To: dev@dpdk.org Cc: srinath.mannam@broadcom.com, scott.branden@broadcom.com, ajit.khaparde@broadcom.com Date: Fri, 6 Jul 2018 14:17:23 +0100 Message-Id: <603dcc865358cc669cba9ec042db93e32a4c8cd5.1530881548.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [RFC 02/11] eal: add function to rerieve socket index by socket ID 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" We are preparing to switch to index heap based on heap indexes rather than by NUMA nodes. First few indexes will be equal to NUMA node ID indexes. For example, currently on a machine with NUMA nodes [0, 8], heaps 0 and 8 will be active, while we want to make it so that heaps 0 and 1 are active. However, currently we don't have a function to map a specific NUMA node to a node index, so add it in this patch. Signed-off-by: Anatoly Burakov Acked-by: Alejandro Lucero --- lib/librte_eal/common/eal_common_lcore.c | 15 +++++++++++++++ lib/librte_eal/common/include/rte_lcore.h | 19 ++++++++++++++++++- lib/librte_eal/rte_eal_version.map | 1 + 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/common/eal_common_lcore.c b/lib/librte_eal/common/eal_common_lcore.c index 3167e9d79..579f5a0a1 100644 --- a/lib/librte_eal/common/eal_common_lcore.c +++ b/lib/librte_eal/common/eal_common_lcore.c @@ -132,3 +132,18 @@ rte_socket_id_by_idx(unsigned int idx) } return config->numa_nodes[idx]; } + +int __rte_experimental +rte_socket_idx_by_id(unsigned int socket) +{ + const struct rte_config *config = rte_eal_get_configuration(); + int i; + + for (i = 0; i < (int) config->numa_node_count; i++) { + unsigned int cur_socket = config->numa_nodes[i]; + if (cur_socket == socket) + return i; + } + rte_errno = EINVAL; + return -1; +} diff --git a/lib/librte_eal/common/include/rte_lcore.h b/lib/librte_eal/common/include/rte_lcore.h index 6e09d9181..f58cda09a 100644 --- a/lib/librte_eal/common/include/rte_lcore.h +++ b/lib/librte_eal/common/include/rte_lcore.h @@ -156,11 +156,28 @@ rte_socket_count(void); * * @return * - physical socket id as recognized by EAL - * - -1 on error, with errno set to EINVAL + * - -1 on error, with rte_errno set to EINVAL */ int __rte_experimental rte_socket_id_by_idx(unsigned int idx); +/** + * Return index for a particular socket id. + * + * This will return position in list of all detected physical socket id's for a + * given socket. For example, on a machine with sockets [0, 8], passing + * 8 as a parameter will return 1. + * + * @param socket + * physical socket id to return index for + * + * @return + * - index of physical socket id as recognized by EAL + * - -1 on error, with rte_errno set to EINVAL + */ +int __rte_experimental +rte_socket_idx_by_id(unsigned int socket); + /** * Get the ID of the physical socket of the specified lcore * diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index f7dd0e7bc..e7fb37b2a 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -296,6 +296,7 @@ EXPERIMENTAL { rte_mp_sendmsg; rte_socket_count; rte_socket_id_by_idx; + rte_socket_idx_by_id; rte_vfio_dma_map; rte_vfio_dma_unmap; rte_vfio_get_container_fd;