From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4F03441E2F; Thu, 9 Mar 2023 05:58:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C9ED942BC9; Thu, 9 Mar 2023 05:58:01 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 09EB840A7E for ; Thu, 9 Mar 2023 05:57:58 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0025B1042; Wed, 8 Mar 2023 20:58:41 -0800 (PST) Received: from 2p2660v4-1.austin.arm.com (2p2660v4-1.austin.arm.com [10.118.14.10]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 61D493F67D; Wed, 8 Mar 2023 20:57:57 -0800 (PST) From: Honnappa Nagarahalli To: mb@smartsharesystems.com, olivier.matz@6wind.com, konstantin.v.ananyev@yandex.ru Cc: dev@dpdk.org, honnappa.nagarahalli@arm.com, ruifeng.wang@arm.com, kamalakshitha.aligeri@arm.com, wathsala.vithanage@arm.com, nd@arm.com Subject: [PATCH 3/4] eal: add API to check if lcore id is valid Date: Wed, 8 Mar 2023 22:57:37 -0600 Message-Id: <20230309045738.1261000-4-honnappa.nagarahalli@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230309045738.1261000-1-honnappa.nagarahalli@arm.com> References: <20230309045738.1261000-1-honnappa.nagarahalli@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Simple API to check if the lcore ID does not exceed the maximum number of lcores configured. Signed-off-by: Honnappa Nagarahalli Reviewed-by: Ruifeng Wang --- lib/eal/include/rte_lcore.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/eal/include/rte_lcore.h b/lib/eal/include/rte_lcore.h index 6a355e9986..cf99919a02 100644 --- a/lib/eal/include/rte_lcore.h +++ b/lib/eal/include/rte_lcore.h @@ -38,6 +38,20 @@ enum rte_lcore_role_t { ROLE_NON_EAL, }; +/** + * Check if the lcore ID is valid + * + * @param lcore_id + * The identifier of the lcore. + * + * @return + * True if the given lcore ID is between 0 and RTE_MAX_LCORE-1. + */ +static inline int rte_lcore_id_is_valid(unsigned int lcore_id) +{ + return (lcore_id < RTE_MAX_LCORE); +} + /** * Get a lcore's role. * -- 2.25.1