All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Add an API to query enabled core index
@ 2014-06-11 20:45 Patrick Lu
       [not found] ` <1402519509-26653-1-git-send-email-Patrick.Lu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 12+ messages in thread
From: Patrick Lu @ 2014-06-11 20:45 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

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 <exec-env/rte_lcore.h>
 
 /**
+ * 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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-06-13 17:25 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-11 20:45 [PATCH] Add an API to query enabled core index Patrick Lu
     [not found] ` <1402519509-26653-1-git-send-email-Patrick.Lu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-06-11 21:51   ` Thomas Monjalon
2014-06-11 21:57     ` Richardson, Bruce
     [not found]       ` <59AF69C657FD0841A61C55336867B5B01AA35210-kPTMFJFq+rELt2AQoY/u9bfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-06-11 22:50         ` Thomas Monjalon
2014-06-11 23:27           ` Richardson, Bruce
     [not found]             ` <59AF69C657FD0841A61C55336867B5B01AA352EF-kPTMFJFq+rELt2AQoY/u9bfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-06-12  0:18               ` Dumitrescu, Cristian
2014-06-12  8:20         ` Olivier MATZ
     [not found]           ` <539962C0.10701-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2014-06-12 15:54             ` Richardson, Bruce
     [not found]               ` <59AF69C657FD0841A61C55336867B5B01AA357CE-kPTMFJFq+rELt2AQoY/u9bfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-06-13 16:58                 ` Patrick Lu
     [not found]                   ` <20140613165828.GA31321-GQGeBJRQ6etbn3E1eTv7vNh3ngVCH38I@public.gmane.org>
2014-06-13 17:25                     ` Richardson, Bruce
2014-06-11 21:58     ` Lu, Patrick
     [not found]       ` <EFC7DD9FAC418F4683FA895DBD8B35A30E1B9C53-AtyAts71sc+krb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-06-11 22:46         ` Thomas Monjalon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.