DPDK patches and discussions
 help / color / mirror / Atom feed
From: Patrick Lu <Patrick.Lu@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] Add an API to query enabled core index
Date: Wed, 11 Jun 2014 13:45:09 -0700	[thread overview]
Message-ID: <1402519509-26653-1-git-send-email-Patrick.Lu@intel.com> (raw)

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

             reply	other threads:[~2014-06-11 20:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-11 20:45 Patrick Lu [this message]
2014-06-11 21:51 ` Thomas Monjalon
2014-06-11 21:57   ` Richardson, Bruce
2014-06-11 22:50     ` Thomas Monjalon
2014-06-11 23:27       ` Richardson, Bruce
2014-06-12  0:18         ` Dumitrescu, Cristian
2014-06-12  8:20     ` Olivier MATZ
2014-06-12 15:54       ` Richardson, Bruce
2014-06-13 16:58         ` Patrick Lu
2014-06-13 17:25           ` Richardson, Bruce
2014-06-11 21:58   ` Lu, Patrick
2014-06-11 22:46     ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1402519509-26653-1-git-send-email-Patrick.Lu@intel.com \
    --to=patrick.lu@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).