From patchwork Thu May 23 13:58:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 53667 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 43D971B959; Thu, 23 May 2019 15:59:57 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 95A5C1B94E for ; Thu, 23 May 2019 15:59:52 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9ED463092667; Thu, 23 May 2019 13:59:48 +0000 (UTC) Received: from dmarchan.remote.csb (ovpn-204-124.brq.redhat.com [10.40.204.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D4AC5D707; Thu, 23 May 2019 13:59:45 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, stephen@networkplumber.org Date: Thu, 23 May 2019 15:58:58 +0200 Message-Id: <1558619942-9723-3-git-send-email-david.marchand@redhat.com> In-Reply-To: <1558619942-9723-1-git-send-email-david.marchand@redhat.com> References: <20190408182510.16078-1-stephen@networkplumber.org> <1558619942-9723-1-git-send-email-david.marchand@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 23 May 2019 13:59:51 +0000 (UTC) Subject: [dpdk-dev] [PATCH v4 2/5] eal: add lcore accessors 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" From: Stephen Hemminger The fields of the internal EAL core configuration are currently laid bare as part of the API. This is not good practice and limits fixing issues with layout and sizes. Make new accessor functions for the fields used by current drivers and examples. Signed-off-by: Stephen Hemminger Signed-off-by: David Marchand --- lib/librte_eal/common/eal_common_lcore.c | 33 +++++++++++++++++++++++++++ lib/librte_eal/common/include/rte_lcore.h | 38 +++++++++++++++++++------------ lib/librte_eal/rte_eal_version.map | 10 ++++++++ 3 files changed, 67 insertions(+), 14 deletions(-) --- Changelog since v3: - updated title - rebased on master - removed doc update - removed unneeded rte_lcore_return_code diff --git a/lib/librte_eal/common/eal_common_lcore.c b/lib/librte_eal/common/eal_common_lcore.c index 8c2744f..38af260 100644 --- a/lib/librte_eal/common/eal_common_lcore.c +++ b/lib/librte_eal/common/eal_common_lcore.c @@ -16,6 +16,39 @@ #include "eal_private.h" #include "eal_thread.h" +int rte_lcore_index(int lcore_id) +{ + if (unlikely(lcore_id >= RTE_MAX_LCORE)) + return -1; + + if (lcore_id < 0) + lcore_id = (int)rte_lcore_id(); + + return lcore_config[lcore_id].core_index; +} + +int rte_lcore_to_cpu_id(int lcore_id) +{ + if (unlikely(lcore_id >= RTE_MAX_LCORE)) + return -1; + + if (lcore_id < 0) + lcore_id = (int)rte_lcore_id(); + + return lcore_config[lcore_id].core_id; +} + +rte_cpuset_t rte_lcore_cpuset(unsigned int lcore_id) +{ + return lcore_config[lcore_id].cpuset; +} + +unsigned int +rte_lcore_to_socket_id(unsigned int lcore_id) +{ + return lcore_config[lcore_id].socket_id; +} + static int socket_id_cmp(const void *a, const void *b) { diff --git a/lib/librte_eal/common/include/rte_lcore.h b/lib/librte_eal/common/include/rte_lcore.h index 705594a..e688450 100644 --- a/lib/librte_eal/common/include/rte_lcore.h +++ b/lib/librte_eal/common/include/rte_lcore.h @@ -121,15 +121,7 @@ struct lcore_config { * @return * The relative index, or -1 if not enabled. */ -static inline int -rte_lcore_index(int lcore_id) -{ - if (lcore_id >= RTE_MAX_LCORE) - return -1; - if (lcore_id < 0) - lcore_id = (int)rte_lcore_id(); - return lcore_config[lcore_id].core_index; -} +int rte_lcore_index(int lcore_id); /** * Return the ID of the physical socket of the logical core we are @@ -177,11 +169,29 @@ struct lcore_config { * @return * the ID of lcoreid's physical socket */ -static inline unsigned int -rte_lcore_to_socket_id(unsigned int lcore_id) -{ - return lcore_config[lcore_id].socket_id; -} +unsigned int +rte_lcore_to_socket_id(unsigned int lcore_id); + +/** + * Return the id of the lcore on a socket starting from zero. + * + * @param lcore_id + * The targeted lcore, or -1 for the current one. + * @return + * The relative index, or -1 if not enabled. + */ +int +rte_lcore_to_cpu_id(int lcore_id); + +/** + * Return the cpuset for a given lcore. + * @param lcore_id + * the targeted lcore, which MUST be between 0 and RTE_MAX_LCORE-1. + * @return + * The cpuset of that lcore + */ +rte_cpuset_t +rte_lcore_cpuset(unsigned int lcore_id); /** * Test if an lcore is enabled. diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index 2454934..cb0eb69 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -287,6 +287,16 @@ DPDK_19.05 { } DPDK_18.11; +DPDK_19.08 { + global: + + rte_lcore_cpuset; + rte_lcore_index; + rte_lcore_to_cpu_id; + rte_lcore_to_socket_id; + +} DPDK_19.05; + EXPERIMENTAL { global: