[v2,11/12] eal: factorize lcore role code in common code
Checks
Commit Message
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.marchand@redhat.com>
---
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(-)
@@ -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();
@@ -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
@@ -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
@@ -943,13 +943,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)
{
@@ -1348,13 +1348,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)
{