From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by dpdk.org (Postfix) with ESMTP id E37B4B0CC for ; Wed, 11 Jun 2014 22:56:53 +0200 (CEST) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 11 Jun 2014 13:57:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,460,1400050800"; d="scan'208";a="444447851" Received: from debian-x64.ch.intel.com ([10.2.63.57]) by azsmga001.ch.intel.com with ESMTP; 11 Jun 2014 13:57:07 -0700 From: Patrick Lu To: dev@dpdk.org Date: Wed, 11 Jun 2014 13:45:09 -0700 Message-Id: <1402519509-26653-1-git-send-email-Patrick.Lu@intel.com> X-Mailer: git-send-email 2.0.0 Subject: [dpdk-dev] [PATCH] Add an API to query enabled core index X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jun 2014 20:56:54 -0000 EAL -c option allows the user to enable any lcore in the system. Oftentimes, the user app wants to know 1st enabled core, 2nd enabled core, etc, rather than phyical core ID (rte_lcore_id().) The new API rte_lcore_id2() will return an index from enabled lcores starting from zero. --- lib/librte_eal/common/include/rte_lcore.h | 12 ++++++++++++ lib/librte_eal/linuxapp/eal/eal.c | 1 + lib/librte_eal/linuxapp/eal/include/exec-env/rte_lcore.h | 1 + 3 files changed, 14 insertions(+) diff --git a/lib/librte_eal/common/include/rte_lcore.h b/lib/librte_eal/common/include/rte_lcore.h index 3802a28..f0682ce 100644 --- a/lib/librte_eal/common/include/rte_lcore.h +++ b/lib/librte_eal/common/include/rte_lcore.h @@ -92,6 +92,18 @@ rte_lcore_count(void) #include /** + * Return the index of the enabled lcore starting from zero. + * + * @return + * the ID of current lcoreid's index + */ +static inline unsigned +rte_lcore_id2(void) +{ + return lcore_config[rte_lcore_id()].core_id2; +} + +/** * Return the ID of the physical socket of the logical core we are * running on. * @return diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c index 070bdc9..a9c9e6c 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -444,6 +444,7 @@ eal_parse_coremask(const char *coremask) return -1; } cfg->lcore_role[idx] = ROLE_RTE; + lcore_config[idx].core_id2 = count; if(count == 0) cfg->master_lcore = idx; count++; diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_lcore.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_lcore.h index e19ab54..9316b05 100644 --- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_lcore.h +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_lcore.h @@ -57,6 +57,7 @@ struct lcore_config { volatile enum rte_lcore_state_t state; /**< lcore state */ unsigned socket_id; /**< physical socket id for this lcore */ unsigned core_id; /**< core number on socket for this lcore */ + unsigned core_id2; /**< DPDK core index, starting from 0 */ }; /** -- 2.0.0