From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 85C88A0679 for ; Wed, 3 Apr 2019 19:16:27 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7624E1B512; Wed, 3 Apr 2019 19:16:23 +0200 (CEST) Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by dpdk.org (Postfix) with ESMTP id E68201B4ED for ; Wed, 3 Apr 2019 19:16:17 +0200 (CEST) Received: by mail-pg1-f171.google.com with SMTP id i2so8635427pgj.11 for ; Wed, 03 Apr 2019 10:16:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4ATaw2+J2yf9RUkQAsCJwSsb3985TdCTdsjttjhqaDw=; b=Jw+taltUSgn+axPS+Ic1NcMlhuatEz9qf+g7L7+08TEMlmooUgPXJVLQiYew9pd314 wELoE/eFaJNHIxtB22oRwzabcNr60HL6A6iDIHhKAL5IpOb9Y6GlOWxYw6E0NGU6XOYH 7kEWELdjua36u/c15uJm98kV9iF83b2CQlxoB6DYMlTMUNBNHYy4uZTFivtpRfZ+fPN8 1Noe3Rrl71pL+LrvrE9EmA8+REYc1jl/zdPQzycJGK+6YFUtGTA3uuH3g8aM94datXIe eIzrq+DFMkP6PrUn2BE3UyaywsQ2XXx1GCJZ7/hcRMw6D++tnluRj/jcHi7zAhVGOcrz l0rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4ATaw2+J2yf9RUkQAsCJwSsb3985TdCTdsjttjhqaDw=; b=o0GI2ZJ20YHC5Z1GnX0370/gM5YK5fU81tgqTr0t+DH554gbxehTugkBmaf0s+6QuM z5vI9ufQlzKAHEqmtsnGECL+ljc8yon2ZhwR50xfUcojYihcSn8NpfMOWAgr8BEWOs+r h92iWrruatcjUMz1iMvFVnt8mcUVt8+puMC/Ou+X7OFkydd/+BBzGwXRR+WU6vYW/hCJ /7eaTF+o12jIS1Vdz4WdRC+apqfB/v/BFLlTNBomjCY4Q/uTgPVlq34k6/2r23IQNMox 17tj2g2Kj/XkUauWAXik6ZxNzhJ/12GTbkijCmIQ4CnOGTChDkAEITA/n/rGxsCnp3Kw 5tdQ== X-Gm-Message-State: APjAAAX7UpDOJhM01sMx3zhmoU2kyY80bCCWFeVNJW/uiPVi7eV7Iw// m3PuGXHFOcxJlp2uAC8a3flx+HGoKnFCcw== X-Google-Smtp-Source: APXvYqyRvhiMqzrpfjbnJnmbP6QGpNXfpyWP1fS0T1jDpoLqJebKckpUjvRqLuSCtUWLhWqNTx0/vw== X-Received: by 2002:a63:ff26:: with SMTP id k38mr802205pgi.123.1554311776453; Wed, 03 Apr 2019 10:16:16 -0700 (PDT) Received: from shemminger-XPS-13-9360.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id k14sm23041693pfb.125.2019.04.03.10.16.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 10:16:15 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Wed, 3 Apr 2019 10:16:06 -0700 Message-Id: <20190403171610.23970-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190403171610.23970-1-stephen@networkplumber.org> References: <20190403171610.23970-1-stephen@networkplumber.org> Subject: [dpdk-dev] [RFC 1/5] eal: add accessor functions for lcore_config 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" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190403171606.bb5ZO72zs99Ro0QZw0YoSUiijnY9oL8EhtQQkdZRqwA@z> 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. Mark the state and return code functions as experimental since these values might change in the future and probably shouldn't have been used by non EAL code anyway. Signed-off-by: Stephen Hemminger --- doc/guides/rel_notes/release_19_05.rst | 7 +++ lib/librte_eal/common/eal_common_lcore.c | 46 ++++++++++++++++++ lib/librte_eal/common/include/rte_lcore.h | 57 +++++++++++++++++------ 3 files changed, 96 insertions(+), 14 deletions(-) diff --git a/doc/guides/rel_notes/release_19_05.rst b/doc/guides/rel_notes/release_19_05.rst index bdad1ddbeedf..995fbf177b93 100644 --- a/doc/guides/rel_notes/release_19_05.rst +++ b/doc/guides/rel_notes/release_19_05.rst @@ -188,6 +188,13 @@ ABI Changes alignment for ``rte_crypto_asym_op`` to restore expected ``rte_crypto_op`` layout and alignment. +* eal: the lcore config structure ``struct lcore_config`` will be made + internal to the EAL in a future release. This will allow the structure to + change without impacting API or ABI. All accesses to fields of this + structure should be done by the corresponding accessor functions. + For example, instead of using ``lcore_config[lcore_id].socket_id`` + the function ``rte_lcore_socket_id(lcore_id)`` should be used instead. + Shared Library Versions ----------------------- diff --git a/lib/librte_eal/common/eal_common_lcore.c b/lib/librte_eal/common/eal_common_lcore.c index 1cbac42286ba..806204d9f73d 100644 --- a/lib/librte_eal/common/eal_common_lcore.c +++ b/lib/librte_eal/common/eal_common_lcore.c @@ -16,6 +16,52 @@ #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 lcore_id) +{ + return lcore_config[lcore_id].cpuset; +} + +unsigned +rte_lcore_to_socket_id(unsigned int lcore_id) +{ + return lcore_config[lcore_id].socket_id; +} + +enum rte_lcore_state_t +rte_lcore_state(unsigned lcore_id) +{ + return lcore_config[lcore_id].state; +} + +int +rte_lcore_return_code(unsigned lcore_id) +{ + return lcore_config[lcore_id].ret; +} + + 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 dea17f500065..7477ed2d9550 100644 --- a/lib/librte_eal/common/include/rte_lcore.h +++ b/lib/librte_eal/common/include/rte_lcore.h @@ -121,15 +121,7 @@ rte_lcore_count(void) * @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,37 @@ rte_socket_id_by_idx(unsigned int idx); * @return * the ID of lcoreid's physical socket */ -static inline unsigned -rte_lcore_to_socket_id(unsigned lcore_id) -{ - return lcore_config[lcore_id].socket_id; -} +unsigned rte_lcore_to_socket_id(unsigned 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 lcore_id); + +/** + * Get the return code from a lcore thread. + * @param lcore_id + * the targeted lcore, which MUST be between 0 and RTE_MAX_LCORE-1 + * and finished + * @return + * the return code from the lcore thread + */ +int __rte_experimental +rte_lcore_return_code(unsigned lcore_id); /** * Test if an lcore is enabled. @@ -201,6 +219,17 @@ rte_lcore_is_enabled(unsigned lcore_id) return cfg->lcore_role[lcore_id] == ROLE_RTE; } +/** + * Get the state of an lcore ID. + * + * @param lcore_id + * the targeted lcore, which MUST be between 0 and RTE_MAX_LCORE-1. + * @return + * the current state of that lcore + */ +enum rte_lcore_state_t __rte_experimental +rte_lcore_state(unsigned lcore_id); + /** * Get the next enabled lcore ID. * -- 2.17.1