From: David Marchand Date: Fri, 25 Oct 2019 13:56:09 +0000 (+0200) Subject: eal: factorize lcore role code X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=6614072791154410116007cbe6ab237c06b5a577;p=dpdk.git eal: factorize lcore role code 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 Acked-by: Thomas Monjalon --- diff --git a/lib/librte_eal/common/eal_common_lcore.c b/lib/librte_eal/common/eal_common_lcore.c index b01a21011a..39efadef1a 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 b7cf912145..ea3c9df719 100644 --- a/lib/librte_eal/common/include/rte_eal.h +++ b/lib/librte_eal/common/include/rte_eal.h @@ -83,17 +83,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 * diff --git a/lib/librte_eal/common/include/rte_lcore.h b/lib/librte_eal/common/include/rte_lcore.h index 3e415ed237..476b8ef3a7 100644 --- a/lib/librte_eal/common/include/rte_lcore.h +++ b/lib/librte_eal/common/include/rte_lcore.h @@ -25,6 +25,16 @@ extern "C" { 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. * diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c index 7c23d471c0..511d8d7ba5 100644 --- a/lib/librte_eal/freebsd/eal/eal.c +++ b/lib/librte_eal/freebsd/eal/eal.c @@ -970,13 +970,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 d0adf7cd12..9e2d50cfba 100644 --- a/lib/librte_eal/linux/eal/eal.c +++ b/lib/librte_eal/linux/eal/eal.c @@ -1323,13 +1323,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) {