This code belongs to the lcore API, move the prototype to the right
header, then factorize the code into the common code.

Signed-off-by: David Marchand <david.march...@redhat.com>
Acked-by: Thomas Monjalon <tho...@monjalon.net>
---
 lib/librte_eal/common/eal_common_lcore.c  | 10 ++++++++++
 lib/librte_eal/common/include/rte_eal.h   | 11 -----------
 lib/librte_eal/common/include/rte_lcore.h | 10 ++++++++++
 lib/librte_eal/freebsd/eal/eal.c          |  7 -------
 lib/librte_eal/linux/eal/eal.c            |  7 -------
 5 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_lcore.c 
b/lib/librte_eal/common/eal_common_lcore.c
index b01a210..39efade 100644
--- a/lib/librte_eal/common/eal_common_lcore.c
+++ b/lib/librte_eal/common/eal_common_lcore.c
@@ -53,6 +53,16 @@ rte_cpuset_t rte_lcore_cpuset(unsigned int lcore_id)
        return lcore_config[lcore_id].cpuset;
 }
 
+enum rte_lcore_role_t
+rte_eal_lcore_role(unsigned int lcore_id)
+{
+       struct rte_config *cfg = rte_eal_get_configuration();
+
+       if (lcore_id >= RTE_MAX_LCORE)
+               return ROLE_OFF;
+       return cfg->lcore_role[lcore_id];
+}
+
 int rte_lcore_is_enabled(unsigned int lcore_id)
 {
        struct rte_config *cfg = rte_eal_get_configuration();
diff --git a/lib/librte_eal/common/include/rte_eal.h 
b/lib/librte_eal/common/include/rte_eal.h
index b7cf912..ea3c9df 100644
--- a/lib/librte_eal/common/include/rte_eal.h
+++ b/lib/librte_eal/common/include/rte_eal.h
@@ -84,17 +84,6 @@ struct rte_config {
 struct rte_config *rte_eal_get_configuration(void);
 
 /**
- * Get a lcore's role.
- *
- * @param lcore_id
- *   The identifier of the lcore.
- * @return
- *   The role of the lcore.
- */
-enum rte_lcore_role_t rte_eal_lcore_role(unsigned lcore_id);
-
-
-/**
  * Get the process type in a multi-process setup
  *
  * @return
diff --git a/lib/librte_eal/common/include/rte_lcore.h 
b/lib/librte_eal/common/include/rte_lcore.h
index ea40c25..555b692 100644
--- a/lib/librte_eal/common/include/rte_lcore.h
+++ b/lib/librte_eal/common/include/rte_lcore.h
@@ -70,6 +70,16 @@ RTE_DECLARE_PER_LCORE(unsigned, _lcore_id);  /**< Per thread 
"lcore id". */
 RTE_DECLARE_PER_LCORE(rte_cpuset_t, _cpuset); /**< Per thread "cpuset". */
 
 /**
+ * Get a lcore's role.
+ *
+ * @param lcore_id
+ *   The identifier of the lcore, which MUST be between 0 and RTE_MAX_LCORE-1.
+ * @return
+ *   The role of the lcore.
+ */
+enum rte_lcore_role_t rte_eal_lcore_role(unsigned int lcore_id);
+
+/**
  * Return the Application thread ID of the execution unit.
  *
  * Note: in most cases the lcore id returned here will also correspond
diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c
index 14e1713..f70d88c 100644
--- a/lib/librte_eal/freebsd/eal/eal.c
+++ b/lib/librte_eal/freebsd/eal/eal.c
@@ -955,13 +955,6 @@ rte_eal_cleanup(void)
        return 0;
 }
 
-/* get core role */
-enum rte_lcore_role_t
-rte_eal_lcore_role(unsigned lcore_id)
-{
-       return rte_config.lcore_role[lcore_id];
-}
-
 enum rte_proc_type_t
 rte_eal_process_type(void)
 {
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index aae67b2..e242a8b 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -1308,13 +1308,6 @@ rte_eal_cleanup(void)
        return 0;
 }
 
-/* get core role */
-enum rte_lcore_role_t
-rte_eal_lcore_role(unsigned lcore_id)
-{
-       return rte_config.lcore_role[lcore_id];
-}
-
 enum rte_proc_type_t
 rte_eal_process_type(void)
 {
-- 
1.8.3.1

Reply via email to