From: Huisong Li <[email protected]>

Add the RTE_LCORE_ prefix to the lcore role enum values in
rte_lcore_role_t to follow DPDK naming conventions.

- ROLE_RTE      -> RTE_LCORE_ROLE_RTE
- ROLE_OFF      -> RTE_LCORE_ROLE_OFF
- ROLE_SERVICE  -> RTE_LCORE_ROLE_SERVICE
- ROLE_NON_EAL  -> RTE_LCORE_ROLE_NON_EAL

Old names are kept as macros aliasing to the new names to preserve
backward compatibility.

Suggested-by: Thomas Monjalon <[email protected]>
Signed-off-by: Huisong Li <[email protected]>
Acked-by: Morten Brørup <[email protected]>
---
This patch has been reverted in June because our CI was not ready.
Applying it in 26.11 will be easier because there is no ABI check.
---
 app/test/test_lcores.c                       |  2 +-
 app/test/test_mempool.c                      |  2 +-
 drivers/net/softnic/rte_eth_softnic_thread.c |  4 +--
 lib/eal/common/eal_common_lcore.c            | 34 ++++++++++----------
 lib/eal/common/eal_common_options.c          | 28 ++++++++--------
 lib/eal/common/eal_private.h                 |  4 +--
 lib/eal/common/rte_service.c                 | 12 +++----
 lib/eal/include/rte_lcore.h                  | 17 +++++++---
 lib/graph/graph.c                            |  2 +-
 9 files changed, 56 insertions(+), 49 deletions(-)

diff --git a/app/test/test_lcores.c b/app/test/test_lcores.c
index 13842615d5..60354b3f7f 100644
--- a/app/test/test_lcores.c
+++ b/app/test/test_lcores.c
@@ -396,7 +396,7 @@ test_lcores(void)
        unsigned int i;
 
        for (i = 0; i < RTE_MAX_LCORE; i++) {
-               if (!rte_lcore_has_role(i, ROLE_OFF))
+               if (!rte_lcore_has_role(i, RTE_LCORE_ROLE_OFF))
                        eal_threads_count++;
        }
        if (eal_threads_count == 0) {
diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c
index f1e8adeef9..58ca51ffe8 100644
--- a/app/test/test_mempool.c
+++ b/app/test/test_mempool.c
@@ -355,7 +355,7 @@ test_mempool_sp_sc(void)
                ret = -1;
                goto err;
        }
-       if (rte_eal_lcore_role(lcore_next) != ROLE_RTE) {
+       if (rte_eal_lcore_role(lcore_next) != RTE_LCORE_ROLE_RTE) {
                ret = -1;
                goto err;
        }
diff --git a/drivers/net/softnic/rte_eth_softnic_thread.c 
b/drivers/net/softnic/rte_eth_softnic_thread.c
index f72c836199..a6d47c8b33 100644
--- a/drivers/net/softnic/rte_eth_softnic_thread.c
+++ b/drivers/net/softnic/rte_eth_softnic_thread.c
@@ -98,9 +98,9 @@ thread_is_valid(struct pmd_internals *softnic, uint32_t 
thread_id)
        if (thread_id == rte_get_main_lcore())
                return 0; /* FALSE */
 
-       if (softnic->params.sc && rte_lcore_has_role(thread_id, ROLE_SERVICE))
+       if (softnic->params.sc && rte_lcore_has_role(thread_id, 
RTE_LCORE_ROLE_SERVICE))
                return 1; /* TRUE */
-       if (!softnic->params.sc && rte_lcore_has_role(thread_id, ROLE_RTE))
+       if (!softnic->params.sc && rte_lcore_has_role(thread_id, 
RTE_LCORE_ROLE_RTE))
                return 1; /* TRUE */
 
        return 0; /* FALSE */
diff --git a/lib/eal/common/eal_common_lcore.c 
b/lib/eal/common/eal_common_lcore.c
index 1b6d77d8bc..3ddacdb8ce 100644
--- a/lib/eal/common/eal_common_lcore.c
+++ b/lib/eal/common/eal_common_lcore.c
@@ -78,7 +78,7 @@ 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 RTE_LCORE_ROLE_OFF;
        return cfg->lcore_role[lcore_id];
 }
 
@@ -101,7 +101,7 @@ int rte_lcore_is_enabled(unsigned int lcore_id)
 
        if (lcore_id >= RTE_MAX_LCORE)
                return 0;
-       return cfg->lcore_role[lcore_id] == ROLE_RTE;
+       return cfg->lcore_role[lcore_id] == RTE_LCORE_ROLE_RTE;
 }
 
 RTE_EXPORT_SYMBOL(rte_get_next_lcore)
@@ -188,7 +188,7 @@ rte_eal_cpu_init(void)
                lcore_to_socket_id[lcore_id] = socket_id;
 
                if (eal_cpu_detected(lcore_id) == 0) {
-                       config->lcore_role[lcore_id] = ROLE_OFF;
+                       config->lcore_role[lcore_id] = RTE_LCORE_ROLE_OFF;
                        lcore_config[lcore_id].core_index = -1;
                        continue;
                }
@@ -200,8 +200,8 @@ rte_eal_cpu_init(void)
                rte_bitset_set(config->core_indices, count);
 
                /* By default, each detected core is enabled */
-               config->lcore_role[lcore_id] = ROLE_RTE;
-               lcore_config[lcore_id].core_role = ROLE_RTE;
+               config->lcore_role[lcore_id] = RTE_LCORE_ROLE_RTE;
+               lcore_config[lcore_id].core_role = RTE_LCORE_ROLE_RTE;
                lcore_config[lcore_id].core_id = eal_cpu_core_id(lcore_id);
                lcore_config[lcore_id].numa_id = socket_id;
                EAL_LOG(DEBUG, "Detected lcore %u as "
@@ -329,7 +329,7 @@ rte_lcore_callback_register(const char *name, 
rte_lcore_init_cb init,
        if (callback->init == NULL)
                goto no_init;
        for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
-               if (cfg->lcore_role[lcore_id] == ROLE_OFF)
+               if (cfg->lcore_role[lcore_id] == RTE_LCORE_ROLE_OFF)
                        continue;
                if (callback_init(callback, lcore_id) == 0)
                        continue;
@@ -337,7 +337,7 @@ rte_lcore_callback_register(const char *name, 
rte_lcore_init_cb init,
                 * previous lcore.
                 */
                while (lcore_id-- != 0) {
-                       if (cfg->lcore_role[lcore_id] == ROLE_OFF)
+                       if (cfg->lcore_role[lcore_id] == RTE_LCORE_ROLE_OFF)
                                continue;
                        callback_uninit(callback, lcore_id);
                }
@@ -369,7 +369,7 @@ rte_lcore_callback_unregister(void *handle)
        if (callback->uninit == NULL)
                goto no_uninit;
        for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
-               if (cfg->lcore_role[lcore_id] == ROLE_OFF)
+               if (cfg->lcore_role[lcore_id] == RTE_LCORE_ROLE_OFF)
                        continue;
                callback_uninit(callback, lcore_id);
        }
@@ -398,11 +398,11 @@ eal_lcore_non_eal_allocate(void)
                goto out;
        }
        for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
-               if (cfg->lcore_role[lcore_id] != ROLE_OFF)
+               if (cfg->lcore_role[lcore_id] != RTE_LCORE_ROLE_OFF)
                        continue;
                rte_bitset_set(cfg->core_indices, core_index);
                lcore_config[lcore_id].core_index = core_index;
-               cfg->lcore_role[lcore_id] = ROLE_NON_EAL;
+               cfg->lcore_role[lcore_id] = RTE_LCORE_ROLE_NON_EAL;
                cfg->lcore_count++;
                break;
        }
@@ -425,7 +425,7 @@ eal_lcore_non_eal_allocate(void)
                        lcore_id);
                rte_bitset_clear(cfg->core_indices, 
lcore_config[lcore_id].core_index);
                lcore_config[lcore_id].core_index = -1;
-               cfg->lcore_role[lcore_id] = ROLE_OFF;
+               cfg->lcore_role[lcore_id] = RTE_LCORE_ROLE_OFF;
                cfg->lcore_count--;
                lcore_id = RTE_MAX_LCORE;
                goto out;
@@ -442,13 +442,13 @@ eal_lcore_non_eal_release(unsigned int lcore_id)
        struct lcore_callback *callback;
 
        rte_rwlock_write_lock(&lcore_lock);
-       if (cfg->lcore_role[lcore_id] != ROLE_NON_EAL)
+       if (cfg->lcore_role[lcore_id] != RTE_LCORE_ROLE_NON_EAL)
                goto out;
        TAILQ_FOREACH(callback, &lcore_callbacks, next)
                callback_uninit(callback, lcore_id);
        rte_bitset_clear(cfg->core_indices, lcore_config[lcore_id].core_index);
        lcore_config[lcore_id].core_index = -1;
-       cfg->lcore_role[lcore_id] = ROLE_OFF;
+       cfg->lcore_role[lcore_id] = RTE_LCORE_ROLE_OFF;
        cfg->lcore_count--;
 out:
        rte_rwlock_write_unlock(&lcore_lock);
@@ -464,7 +464,7 @@ rte_lcore_iterate(rte_lcore_iterate_cb cb, void *arg)
 
        rte_rwlock_read_lock(&lcore_lock);
        for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
-               if (cfg->lcore_role[lcore_id] == ROLE_OFF)
+               if (cfg->lcore_role[lcore_id] == RTE_LCORE_ROLE_OFF)
                        continue;
                ret = cb(lcore_id, arg);
                if (ret != 0)
@@ -478,11 +478,11 @@ static const char *
 lcore_role_str(enum rte_lcore_role_t role)
 {
        switch (role) {
-       case ROLE_RTE:
+       case RTE_LCORE_ROLE_RTE:
                return "RTE";
-       case ROLE_SERVICE:
+       case RTE_LCORE_ROLE_SERVICE:
                return "SERVICE";
-       case ROLE_NON_EAL:
+       case RTE_LCORE_ROLE_NON_EAL:
                return "NON_EAL";
        default:
                return "UNKNOWN";
diff --git a/lib/eal/common/eal_common_options.c 
b/lib/eal/common/eal_common_options.c
index aa91d76355..b2c0744447 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -898,10 +898,10 @@ eal_parse_service_coremask(const char *coremask)
                                        return -1;
                                }
 
-                               if (cfg->lcore_role[idx] == ROLE_RTE)
+                               if (cfg->lcore_role[idx] == RTE_LCORE_ROLE_RTE)
                                        taken_lcore_count++;
 
-                               lcore_config[idx].core_role = ROLE_SERVICE;
+                               lcore_config[idx].core_role = 
RTE_LCORE_ROLE_SERVICE;
                                count++;
                        }
                }
@@ -940,7 +940,7 @@ update_lcore_config(const rte_cpuset_t *cpuset, bool remap, 
uint16_t remap_base)
        /* set everything to disabled first, then set up values */
        rte_bitset_clear_all(cfg->core_indices, RTE_MAX_LCORE);
        for (i = 0; i < RTE_MAX_LCORE; i++) {
-               cfg->lcore_role[i] = ROLE_OFF;
+               cfg->lcore_role[i] = RTE_LCORE_ROLE_OFF;
                lcore_config[i].core_index = -1;
        }
 
@@ -969,7 +969,7 @@ update_lcore_config(const rte_cpuset_t *cpuset, bool remap, 
uint16_t remap_base)
                        }
 
                        rte_bitset_set(cfg->core_indices, count);
-                       cfg->lcore_role[lcore_id] = ROLE_RTE;
+                       cfg->lcore_role[lcore_id] = RTE_LCORE_ROLE_RTE;
                        lcore_config[lcore_id].core_index = count;
                        CPU_ZERO(&lcore_config[lcore_id].cpuset);
                        CPU_SET(i, &lcore_config[lcore_id].cpuset);
@@ -1141,12 +1141,12 @@ eal_parse_service_corelist(const char *corelist)
                        if (min == RTE_MAX_LCORE)
                                min = idx;
                        for (idx = min; idx <= max; idx++) {
-                               if (cfg->lcore_role[idx] != ROLE_SERVICE) {
-                                       if (cfg->lcore_role[idx] == ROLE_RTE)
+                               if (cfg->lcore_role[idx] != 
RTE_LCORE_ROLE_SERVICE) {
+                                       if (cfg->lcore_role[idx] == 
RTE_LCORE_ROLE_RTE)
                                                taken_lcore_count++;
 
                                        lcore_config[idx].core_role =
-                                                       ROLE_SERVICE;
+                                                       RTE_LCORE_ROLE_SERVICE;
                                        count++;
                                }
                        }
@@ -1169,7 +1169,7 @@ eal_parse_service_corelist(const char *corelist)
        rte_cpuset_t service_cpuset;
        CPU_ZERO(&service_cpuset);
        for (i = 0; i < RTE_MAX_LCORE; i++) {
-               if (lcore_config[i].core_role == ROLE_SERVICE)
+               if (lcore_config[i].core_role == RTE_LCORE_ROLE_SERVICE)
                        CPU_SET(i, &service_cpuset);
        }
        if (CPU_COUNT(&service_cpuset) > 0) {
@@ -1198,12 +1198,12 @@ eal_parse_main_lcore(const char *arg)
                return -1;
 
        /* ensure main core is not used as service core */
-       if (lcore_config[cfg->main_lcore].core_role == ROLE_SERVICE) {
+       if (lcore_config[cfg->main_lcore].core_role == RTE_LCORE_ROLE_SERVICE) {
                EAL_LOG(ERR, "Error: Main lcore is used as a service core");
                return -1;
        }
        /* check that we have the core recorded in the core list */
-       if (cfg->lcore_role[cfg->main_lcore] != ROLE_RTE) {
+       if (cfg->lcore_role[cfg->main_lcore] != RTE_LCORE_ROLE_RTE) {
                EAL_LOG(ERR, "Error: Main lcore is not enabled for DPDK");
                return -1;
        }
@@ -1393,7 +1393,7 @@ eal_parse_lcores(const char *lcores)
        /* Reset lcore config */
        rte_bitset_clear_all(cfg->core_indices, RTE_MAX_LCORE);
        for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
-               cfg->lcore_role[idx] = ROLE_OFF;
+               cfg->lcore_role[idx] = RTE_LCORE_ROLE_OFF;
                lcore_config[idx].core_index = -1;
                CPU_ZERO(&lcore_config[idx].cpuset);
        }
@@ -1455,10 +1455,10 @@ eal_parse_lcores(const char *lcores)
                                continue;
                        set_count--;
 
-                       if (cfg->lcore_role[idx] != ROLE_RTE) {
+                       if (cfg->lcore_role[idx] != RTE_LCORE_ROLE_RTE) {
                                rte_bitset_set(cfg->core_indices, count);
                                lcore_config[idx].core_index = count;
-                               cfg->lcore_role[idx] = ROLE_RTE;
+                               cfg->lcore_role[idx] = RTE_LCORE_ROLE_RTE;
                                count++;
                        }
 
@@ -2436,7 +2436,7 @@ compute_ctrl_threads_cpuset(struct internal_config 
*internal_cfg)
        unsigned int lcore_id;
 
        for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
-               if (rte_lcore_has_role(lcore_id, ROLE_OFF))
+               if (rte_lcore_has_role(lcore_id, RTE_LCORE_ROLE_OFF))
                        continue;
                RTE_CPU_OR(cpuset, cpuset, &lcore_config[lcore_id].cpuset);
        }
diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h
index 8507791ec2..03563eb04d 100644
--- a/lib/eal/common/eal_private.h
+++ b/lib/eal/common/eal_private.h
@@ -419,7 +419,7 @@ uint64_t get_tsc_freq_arch(void);
  * Allocate a free lcore to associate to a non-EAL thread.
  *
  * @return
- *   - the id of a lcore with role ROLE_NON_EAL on success.
+ *   - the id of a lcore with role RTE_LCORE_ROLE_NON_EAL on success.
  *   - RTE_MAX_LCORE if none was available or initializing was refused (see
  *     rte_lcore_callback_register).
  */
@@ -430,7 +430,7 @@ unsigned int eal_lcore_non_eal_allocate(void);
  * Counterpart of eal_lcore_non_eal_allocate().
  *
  * @param lcore_id
- *   The lcore with role ROLE_NON_EAL to release.
+ *   The lcore with role RTE_LCORE_ROLE_NON_EAL to release.
  */
 void eal_lcore_non_eal_release(unsigned int lcore_id);
 
diff --git a/lib/eal/common/rte_service.c b/lib/eal/common/rte_service.c
index d2ac9d3f14..5c3a350ae8 100644
--- a/lib/eal/common/rte_service.c
+++ b/lib/eal/common/rte_service.c
@@ -107,7 +107,7 @@ rte_service_init(void)
        int i;
        struct rte_config *cfg = rte_eal_get_configuration();
        for (i = 0; i < RTE_MAX_LCORE; i++) {
-               if (lcore_config[i].core_role == ROLE_SERVICE) {
+               if (lcore_config[i].core_role == RTE_LCORE_ROLE_SERVICE) {
                        if ((unsigned int)i == cfg->main_lcore)
                                continue;
                        rte_service_lcore_add(i);
@@ -718,7 +718,7 @@ set_lcore_state(uint32_t lcore, int32_t state)
        lcore_config[lcore].core_role = state;
 
        /* update per-lcore optimized state tracking */
-       cs->is_service_core = (state == ROLE_SERVICE);
+       cs->is_service_core = (state == RTE_LCORE_ROLE_SERVICE);
 
        rte_eal_trace_service_lcore_state_change(lcore, state);
 }
@@ -734,7 +734,7 @@ rte_service_lcore_reset_all(void)
 
                if (cs->is_service_core) {
                        rte_bitset_clear_all(cs->mapped_services, 
RTE_SERVICE_NUM_MAX);
-                       set_lcore_state(i, ROLE_RTE);
+                       set_lcore_state(i, RTE_LCORE_ROLE_RTE);
                        /* runstate act as guard variable Use
                         * store-release memory order here to synchronize
                         * with load-acquire in runstate read functions.
@@ -761,7 +761,7 @@ rte_service_lcore_add(uint32_t lcore)
        if (cs->is_service_core)
                return -EALREADY;
 
-       set_lcore_state(lcore, ROLE_SERVICE);
+       set_lcore_state(lcore, RTE_LCORE_ROLE_SERVICE);
 
        /* ensure that after adding a core the mask and state are defaults */
        rte_bitset_clear_all(cs->mapped_services, RTE_SERVICE_NUM_MAX);
@@ -793,7 +793,7 @@ rte_service_lcore_del(uint32_t lcore)
                        RUNSTATE_STOPPED)
                return -EBUSY;
 
-       set_lcore_state(lcore, ROLE_RTE);
+       set_lcore_state(lcore, RTE_LCORE_ROLE_RTE);
 
        rte_smp_wmb();
        return 0;
@@ -1126,7 +1126,7 @@ rte_service_dump(FILE *f, uint32_t id)
 
        fprintf(f, "Service Cores Summary\n");
        for (i = 0; i < RTE_MAX_LCORE; i++) {
-               if (lcore_config[i].core_role != ROLE_SERVICE)
+               if (lcore_config[i].core_role != RTE_LCORE_ROLE_SERVICE)
                        continue;
 
                service_dump_calls_per_lcore(f, i);
diff --git a/lib/eal/include/rte_lcore.h b/lib/eal/include/rte_lcore.h
index 696ae9ec95..1b192a6727 100644
--- a/lib/eal/include/rte_lcore.h
+++ b/lib/eal/include/rte_lcore.h
@@ -31,12 +31,18 @@ RTE_DECLARE_PER_LCORE(unsigned, _lcore_id);  /**< Per 
thread "lcore id". */
  * The lcore role (used in RTE or not).
  */
 enum rte_lcore_role_t {
-       ROLE_RTE,
-       ROLE_OFF,
-       ROLE_SERVICE,
-       ROLE_NON_EAL,
+       RTE_LCORE_ROLE_RTE,
+       RTE_LCORE_ROLE_OFF,
+       RTE_LCORE_ROLE_SERVICE,
+       RTE_LCORE_ROLE_NON_EAL,
 };
 
+/* Old lcore role aliases for backward compatibility. */
+#define ROLE_RTE       RTE_LCORE_ROLE_RTE
+#define ROLE_OFF       RTE_LCORE_ROLE_OFF
+#define ROLE_SERVICE   RTE_LCORE_ROLE_SERVICE
+#define ROLE_NON_EAL   RTE_LCORE_ROLE_NON_EAL
+
 /**
  * Get a lcore's role.
  *
@@ -327,7 +333,8 @@ rte_lcore_callback_unregister(void *handle);
 typedef int (*rte_lcore_iterate_cb)(unsigned int lcore_id, void *arg);
 
 /**
- * Iterate on all active lcores (ROLE_RTE, ROLE_SERVICE and ROLE_NON_EAL).
+ * Iterate on all active lcores (RTE_LCORE_ROLE_RTE, RTE_LCORE_ROLE_SERVICE
+ * and RTE_LCORE_ROLE_NON_EAL).
  * No modification on the lcore states is allowed in the callback.
  *
  * Note: as opposed to init/uninit callbacks, iteration callbacks can be
diff --git a/lib/graph/graph.c b/lib/graph/graph.c
index 5f8ada2185..8165a0a932 100644
--- a/lib/graph/graph.c
+++ b/lib/graph/graph.c
@@ -359,7 +359,7 @@ rte_graph_model_mcore_dispatch_core_bind(rte_graph_t id, 
int lcore)
                goto fail;
        }
 
-       if (rte_lcore_has_role(lcore, ROLE_OFF))
+       if (rte_lcore_has_role(lcore, RTE_LCORE_ROLE_OFF))
                SET_ERR_JMP(ENOLINK, fail, "lcore %d is invalid", lcore);
 
        STAILQ_FOREACH(graph, &graph_list, next)
-- 
2.55.0

Reply via email to