From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by dpdk.org (Postfix) with ESMTP id 2DD101B1A0 for ; Tue, 2 Apr 2019 22:53:45 +0200 (CEST) Received: by mail-pl1-f194.google.com with SMTP id y6so6850007pll.13 for ; Tue, 02 Apr 2019 13:53:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZO/Q1fFbU+TXI18edyBkwKfpBZhxzYETYfyPsGMY5h8=; b=wGxkx531N4DX6dcK2UhExr7x00oCQincbR9yVXv+QD1UdaD74Ltl1+lT4cacBoqxF2 3EUhaVn8TN5756j2AX8/qGz9zCkP7wJFUGnisPDyK1qi7EGRdOC/2ci42aioTSFhnlcZ 6IgtR0B2YfWlhwyANH3hvHroXmWI3lkUL6h0vhGINIsfNM2ia8fxVNQpdf5+3GtLtkit lZZC/YWvRzb0ELOASS8rpRdAOA+0Dr7C8685RENgxOzSkzC9zi90SWEAKgdQjit5IXEM XY7X9BpJGgd5KgebXnNgLnG9VKwkn971OxT3iK35AN2l2MuvNfHDTr1mcHx2TjF7spfj tfNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZO/Q1fFbU+TXI18edyBkwKfpBZhxzYETYfyPsGMY5h8=; b=JovWv1/PvWTG7ga4sVuzNZIrOtbtjRQHu2BPirR67JWz4NDsrks940yuAeFPNCEbij LOEinrSUJOjemgLlPSbMpLoS/8VS2Ghl9IHufKGTuXs/wcvtQjah+BcHg+P1Lv2O9Tqz EId8SapKhwdIUz48o2dYRWdPbBd4cV3Ia13OkAtBNGeCIwZOtzF42P0ATKNpAWOgmNMO alP6fiY14QjsvCkBWFfmrxbJWgqUjI+5liBBzE75lH3j0GeR7sSgsfcuLUABWB/vDCJF NJhnbgr0v5J036IDHLtPbJvSfi/4SdManYDsq5O9zfzvYAfLznFgg3y7infOFPJk2Iyw lhjg== X-Gm-Message-State: APjAAAVBDsZfmcHHYK1eihrVKBhG1pnDqcgJDtY3nyjoKYJ8Oirsy5nD w4AJ2XbT9hL/O6AdNTvT+k5xO55MsLbW+A== X-Google-Smtp-Source: APXvYqwv/y9N4BtoyRQA3zwOU6GyhsqHL69LiX3gSarDZlorClEMriHHJv+8+JVcqnOwDTjFNEdByA== X-Received: by 2002:a17:902:32b:: with SMTP id 40mr70385975pld.122.1554238423966; Tue, 02 Apr 2019 13:53:43 -0700 (PDT) Received: from shemminger-XPS-13-9360.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id h19sm21392903pfd.130.2019.04.02.13.53.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Apr 2019 13:53:42 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 2 Apr 2019 13:53:35 -0700 Message-Id: <20190402205335.13745-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190402155722.21400-1-stephen@networkplumber.org> References: <20190402155722.21400-1-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH v3] eal: rename state values in rte_lcore_state X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 20:53:45 -0000 C language does not really treat enum's as first class symbols. The values in an enum live in a global namespace. That means if DPDK defines "RUNNING" it can't be used by another enum in an application using DPDK. To solve this add a prefix "RTE_LCORE_" to the enum values, and make them grammatically consistent. Also, simplify the inline thread_is_running() which is copied in softnic and ip_pipeline. Signed-off-by: Stephen Hemminger --- v3 - fix BSD and bond driver usage of state drivers/event/octeontx/ssovf_evdev_selftest.c | 2 +- drivers/event/sw/sw_evdev_selftest.c | 4 ++-- drivers/net/softnic/rte_eth_softnic_thread.c | 5 +---- examples/bond/main.c | 4 ++-- examples/ip_pipeline/thread.c | 5 +---- examples/l2fwd-keepalive/main.c | 2 +- lib/librte_eal/common/eal_common_launch.c | 12 ++++++------ lib/librte_eal/common/include/rte_launch.h | 6 +++--- lib/librte_eal/common/rte_service.c | 2 +- lib/librte_eal/freebsd/eal/eal.c | 2 +- lib/librte_eal/freebsd/eal/eal_thread.c | 6 +++--- lib/librte_eal/linux/eal/eal.c | 2 +- lib/librte_eal/linux/eal/eal_thread.c | 8 ++++---- 13 files changed, 27 insertions(+), 33 deletions(-) diff --git a/drivers/event/octeontx/ssovf_evdev_selftest.c b/drivers/event/octeontx/ssovf_evdev_selftest.c index 239362fcf549..06370840ba36 100644 --- a/drivers/event/octeontx/ssovf_evdev_selftest.c +++ b/drivers/event/octeontx/ssovf_evdev_selftest.c @@ -577,7 +577,7 @@ wait_workers_to_join(int lcore, const rte_atomic32_t *count) RTE_SET_USED(count); print_cycles = cycles = rte_get_timer_cycles(); - while (rte_eal_get_lcore_state(lcore) != FINISHED) { + while (rte_eal_get_lcore_state(lcore) != RTE_LCORE_FINISHED) { uint64_t new_cycles = rte_get_timer_cycles(); if (new_cycles - print_cycles > rte_get_timer_hz()) { diff --git a/drivers/event/sw/sw_evdev_selftest.c b/drivers/event/sw/sw_evdev_selftest.c index d00d5de613d7..9e16f7d3520f 100644 --- a/drivers/event/sw/sw_evdev_selftest.c +++ b/drivers/event/sw/sw_evdev_selftest.c @@ -3116,8 +3116,8 @@ worker_loopback(struct test *t, uint8_t disable_implicit_release) rte_eal_remote_launch(worker_loopback_worker_fn, t, w_lcore); print_cycles = cycles = rte_get_timer_cycles(); - while (rte_eal_get_lcore_state(p_lcore) != FINISHED || - rte_eal_get_lcore_state(w_lcore) != FINISHED) { + while (rte_eal_get_lcore_state(p_lcore) != RTE_LCORE_FINISHED || + rte_eal_get_lcore_state(w_lcore) != RTE_LCORE_FINISHED) { rte_service_run_iter_on_app_lcore(t->service_id, 1); diff --git a/drivers/net/softnic/rte_eth_softnic_thread.c b/drivers/net/softnic/rte_eth_softnic_thread.c index 57989a5aac54..dee3923101bc 100644 --- a/drivers/net/softnic/rte_eth_softnic_thread.c +++ b/drivers/net/softnic/rte_eth_softnic_thread.c @@ -118,10 +118,7 @@ thread_is_valid(struct pmd_internals *softnic, uint32_t thread_id) static inline int thread_is_running(uint32_t thread_id) { - enum rte_lcore_state_t thread_state; - - thread_state = rte_eal_get_lcore_state(thread_id); - return (thread_state == RUNNING)? 1 : 0; + return rte_eal_get_lcore_state(thread_id) == RTE_LCORE_RUNNING; } static int32_t diff --git a/examples/bond/main.c b/examples/bond/main.c index ef86194fff4a..12123a4b16d8 100644 --- a/examples/bond/main.c +++ b/examples/bond/main.c @@ -527,7 +527,7 @@ static void cmd_start_parsed(__attribute__((unused)) void *parsed_result, rte_spinlock_trylock(&global_flag_stru_p->lock); if (global_flag_stru_p->LcoreMainIsRunning == 0) { - if (lcore_config[global_flag_stru_p->LcoreMainCore].state != WAIT) { + if (lcore_config[global_flag_stru_p->LcoreMainCore].state != RTE_LCORE_WAIT) { rte_spinlock_unlock(&global_flag_stru_p->lock); return; } @@ -796,7 +796,7 @@ main(int argc, char *argv[]) /* check state of lcores */ RTE_LCORE_FOREACH_SLAVE(slave_core_id) { - if (lcore_config[slave_core_id].state != WAIT) + if (lcore_config[slave_core_id].state != RTE_LCORE_WAIT) return -EBUSY; } /* start lcore main on core != master_core - ARP response thread */ diff --git a/examples/ip_pipeline/thread.c b/examples/ip_pipeline/thread.c index 272fbbeed1bc..3a62a0aee8bc 100644 --- a/examples/ip_pipeline/thread.c +++ b/examples/ip_pipeline/thread.c @@ -158,10 +158,7 @@ thread_init(void) static inline int thread_is_running(uint32_t thread_id) { - enum rte_lcore_state_t thread_state; - - thread_state = rte_eal_get_lcore_state(thread_id); - return (thread_state == RUNNING) ? 1 : 0; + return rte_eal_get_lcore_state(thread_id) == RTE_LCORE_RUNNING; } /** diff --git a/examples/l2fwd-keepalive/main.c b/examples/l2fwd-keepalive/main.c index 0bf2b533648a..2e1edfa05937 100644 --- a/examples/l2fwd-keepalive/main.c +++ b/examples/l2fwd-keepalive/main.c @@ -502,7 +502,7 @@ dead_core(__rte_unused void *ptr_data, const int id_core) if (terminate_signal_received) return; printf("Dead core %i - restarting..\n", id_core); - if (rte_eal_get_lcore_state(id_core) == FINISHED) { + if (rte_eal_get_lcore_state(id_core) == RTE_LCORE_FINISHED) { rte_eal_wait_lcore(id_core); rte_eal_remote_launch(l2fwd_launch_one_lcore, NULL, id_core); } else { diff --git a/lib/librte_eal/common/eal_common_launch.c b/lib/librte_eal/common/eal_common_launch.c index fe0ba3f0d617..74a3f1a28432 100644 --- a/lib/librte_eal/common/eal_common_launch.c +++ b/lib/librte_eal/common/eal_common_launch.c @@ -21,17 +21,17 @@ int rte_eal_wait_lcore(unsigned slave_id) { - if (lcore_config[slave_id].state == WAIT) + if (lcore_config[slave_id].state == RTE_LCORE_WAITING) return 0; - while (lcore_config[slave_id].state != WAIT && - lcore_config[slave_id].state != FINISHED) + while (lcore_config[slave_id].state != RTE_LCORE_WAITING && + lcore_config[slave_id].state != RTE_LCORE_FINISHED) rte_pause(); rte_rmb(); /* we are in finished state, go to wait state */ - lcore_config[slave_id].state = WAIT; + lcore_config[slave_id].state = RTE_LCORE_WAITING; return lcore_config[slave_id].ret; } @@ -49,7 +49,7 @@ rte_eal_mp_remote_launch(int (*f)(void *), void *arg, /* check state of lcores */ RTE_LCORE_FOREACH_SLAVE(lcore_id) { - if (lcore_config[lcore_id].state != WAIT) + if (lcore_config[lcore_id].state != RTE_LCORE_WAITING) return -EBUSY; } @@ -60,7 +60,7 @@ rte_eal_mp_remote_launch(int (*f)(void *), void *arg, if (call_master == CALL_MASTER) { lcore_config[master].ret = f(arg); - lcore_config[master].state = FINISHED; + lcore_config[master].state = RTE_LCORE_FINISHED; } return 0; diff --git a/lib/librte_eal/common/include/rte_launch.h b/lib/librte_eal/common/include/rte_launch.h index 06a671752ace..286ca31c98ab 100644 --- a/lib/librte_eal/common/include/rte_launch.h +++ b/lib/librte_eal/common/include/rte_launch.h @@ -19,9 +19,9 @@ extern "C" { * State of an lcore. */ enum rte_lcore_state_t { - WAIT, /**< waiting a new command */ - RUNNING, /**< executing command */ - FINISHED, /**< command executed */ + RTE_LCORE_WAITING, /**< waiting a new command */ + RTE_LCORE_RUNNING, /**< executing command */ + RTE_LCORE_FINISHED, /**< command executed */ }; /** diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c index 5f75e5a53fbf..8dd7586027ff 100644 --- a/lib/librte_eal/common/rte_service.c +++ b/lib/librte_eal/common/rte_service.c @@ -450,7 +450,7 @@ rte_service_runner_func(void *arg) rte_smp_rmb(); } - lcore_config[lcore].state = WAIT; + lcore_config[lcore].state = RTE_LCORE_WAITING; return 0; } diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c index 790c6afa7050..aae4243486bd 100644 --- a/lib/librte_eal/freebsd/eal/eal.c +++ b/lib/librte_eal/freebsd/eal/eal.c @@ -784,7 +784,7 @@ rte_eal_init(int argc, char **argv) if (pipe(lcore_config[i].pipe_slave2master) < 0) rte_panic("Cannot create pipe\n"); - lcore_config[i].state = WAIT; + lcore_config[i].state = RTE_LCORE_WAIT; /* create a thread for each lcore */ ret = pthread_create(&lcore_config[i].thread_id, NULL, diff --git a/lib/librte_eal/freebsd/eal/eal_thread.c b/lib/librte_eal/freebsd/eal/eal_thread.c index 309b5872666b..f25e84fa312b 100644 --- a/lib/librte_eal/freebsd/eal/eal_thread.c +++ b/lib/librte_eal/freebsd/eal/eal_thread.c @@ -41,7 +41,7 @@ rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id) int m2s = lcore_config[slave_id].pipe_master2slave[1]; int s2m = lcore_config[slave_id].pipe_slave2master[0]; - if (lcore_config[slave_id].state != WAIT) + if (lcore_config[slave_id].state != RTE_LCORE_WAITING) return -EBUSY; lcore_config[slave_id].f = f; @@ -136,7 +136,7 @@ eal_thread_loop(__attribute__((unused)) void *arg) if (n <= 0) rte_panic("cannot read on configuration pipe\n"); - lcore_config[lcore_id].state = RUNNING; + lcore_config[lcore_id].state = RTE_LCORE_RUNNING; /* send ack */ n = 0; @@ -153,7 +153,7 @@ eal_thread_loop(__attribute__((unused)) void *arg) ret = lcore_config[lcore_id].f(fct_arg); lcore_config[lcore_id].ret = ret; rte_wmb(); - lcore_config[lcore_id].state = FINISHED; + lcore_config[lcore_id].state = RTE_LCORE_FINISHED; } /* never reached */ diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c index 75ed0cf1029f..3fe25a1feb2f 100644 --- a/lib/librte_eal/linux/eal/eal.c +++ b/lib/librte_eal/linux/eal/eal.c @@ -1158,7 +1158,7 @@ rte_eal_init(int argc, char **argv) if (pipe(lcore_config[i].pipe_slave2master) < 0) rte_panic("Cannot create pipe\n"); - lcore_config[i].state = WAIT; + lcore_config[i].state = RTE_LCORE_WAITING; /* create a thread for each lcore */ ret = pthread_create(&lcore_config[i].thread_id, NULL, diff --git a/lib/librte_eal/linux/eal/eal_thread.c b/lib/librte_eal/linux/eal/eal_thread.c index 379773b683e8..058692a45412 100644 --- a/lib/librte_eal/linux/eal/eal_thread.c +++ b/lib/librte_eal/linux/eal/eal_thread.c @@ -41,7 +41,7 @@ rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id) int m2s = lcore_config[slave_id].pipe_master2slave[1]; int s2m = lcore_config[slave_id].pipe_slave2master[0]; - if (lcore_config[slave_id].state != WAIT) + if (lcore_config[slave_id].state != RTE_LCORE_WAITING) return -EBUSY; lcore_config[slave_id].f = f; @@ -136,7 +136,7 @@ eal_thread_loop(__attribute__((unused)) void *arg) if (n <= 0) rte_panic("cannot read on configuration pipe\n"); - lcore_config[lcore_id].state = RUNNING; + lcore_config[lcore_id].state = RTE_LCORE_RUNNING; /* send ack */ n = 0; @@ -158,9 +158,9 @@ eal_thread_loop(__attribute__((unused)) void *arg) * state, because the application will not lcore_wait() for it. */ if (lcore_config[lcore_id].core_role == ROLE_SERVICE) - lcore_config[lcore_id].state = WAIT; + lcore_config[lcore_id].state = RTE_LCORE_WAITING; else - lcore_config[lcore_id].state = FINISHED; + lcore_config[lcore_id].state = RTE_LCORE_FINISHED; } /* never reached */ -- 2.17.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 5DC25A0679 for ; Tue, 2 Apr 2019 22:53:48 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0D36D1B1D6; Tue, 2 Apr 2019 22:53:47 +0200 (CEST) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by dpdk.org (Postfix) with ESMTP id 2DD101B1A0 for ; Tue, 2 Apr 2019 22:53:45 +0200 (CEST) Received: by mail-pl1-f194.google.com with SMTP id y6so6850007pll.13 for ; Tue, 02 Apr 2019 13:53:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZO/Q1fFbU+TXI18edyBkwKfpBZhxzYETYfyPsGMY5h8=; b=wGxkx531N4DX6dcK2UhExr7x00oCQincbR9yVXv+QD1UdaD74Ltl1+lT4cacBoqxF2 3EUhaVn8TN5756j2AX8/qGz9zCkP7wJFUGnisPDyK1qi7EGRdOC/2ci42aioTSFhnlcZ 6IgtR0B2YfWlhwyANH3hvHroXmWI3lkUL6h0vhGINIsfNM2ia8fxVNQpdf5+3GtLtkit lZZC/YWvRzb0ELOASS8rpRdAOA+0Dr7C8685RENgxOzSkzC9zi90SWEAKgdQjit5IXEM XY7X9BpJGgd5KgebXnNgLnG9VKwkn971OxT3iK35AN2l2MuvNfHDTr1mcHx2TjF7spfj tfNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZO/Q1fFbU+TXI18edyBkwKfpBZhxzYETYfyPsGMY5h8=; b=JovWv1/PvWTG7ga4sVuzNZIrOtbtjRQHu2BPirR67JWz4NDsrks940yuAeFPNCEbij LOEinrSUJOjemgLlPSbMpLoS/8VS2Ghl9IHufKGTuXs/wcvtQjah+BcHg+P1Lv2O9Tqz EId8SapKhwdIUz48o2dYRWdPbBd4cV3Ia13OkAtBNGeCIwZOtzF42P0ATKNpAWOgmNMO alP6fiY14QjsvCkBWFfmrxbJWgqUjI+5liBBzE75lH3j0GeR7sSgsfcuLUABWB/vDCJF NJhnbgr0v5J036IDHLtPbJvSfi/4SdManYDsq5O9zfzvYAfLznFgg3y7infOFPJk2Iyw lhjg== X-Gm-Message-State: APjAAAVBDsZfmcHHYK1eihrVKBhG1pnDqcgJDtY3nyjoKYJ8Oirsy5nD w4AJ2XbT9hL/O6AdNTvT+k5xO55MsLbW+A== X-Google-Smtp-Source: APXvYqwv/y9N4BtoyRQA3zwOU6GyhsqHL69LiX3gSarDZlorClEMriHHJv+8+JVcqnOwDTjFNEdByA== X-Received: by 2002:a17:902:32b:: with SMTP id 40mr70385975pld.122.1554238423966; Tue, 02 Apr 2019 13:53:43 -0700 (PDT) Received: from shemminger-XPS-13-9360.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id h19sm21392903pfd.130.2019.04.02.13.53.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Apr 2019 13:53:42 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 2 Apr 2019 13:53:35 -0700 Message-Id: <20190402205335.13745-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190402155722.21400-1-stephen@networkplumber.org> References: <20190402155722.21400-1-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH v3] eal: rename state values in rte_lcore_state X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190402205335.XYe8lZCzoHz-7Nekc6eZyevGByeFLozX6p8iIEWiqY8@z> C language does not really treat enum's as first class symbols. The values in an enum live in a global namespace. That means if DPDK defines "RUNNING" it can't be used by another enum in an application using DPDK. To solve this add a prefix "RTE_LCORE_" to the enum values, and make them grammatically consistent. Also, simplify the inline thread_is_running() which is copied in softnic and ip_pipeline. Signed-off-by: Stephen Hemminger --- v3 - fix BSD and bond driver usage of state drivers/event/octeontx/ssovf_evdev_selftest.c | 2 +- drivers/event/sw/sw_evdev_selftest.c | 4 ++-- drivers/net/softnic/rte_eth_softnic_thread.c | 5 +---- examples/bond/main.c | 4 ++-- examples/ip_pipeline/thread.c | 5 +---- examples/l2fwd-keepalive/main.c | 2 +- lib/librte_eal/common/eal_common_launch.c | 12 ++++++------ lib/librte_eal/common/include/rte_launch.h | 6 +++--- lib/librte_eal/common/rte_service.c | 2 +- lib/librte_eal/freebsd/eal/eal.c | 2 +- lib/librte_eal/freebsd/eal/eal_thread.c | 6 +++--- lib/librte_eal/linux/eal/eal.c | 2 +- lib/librte_eal/linux/eal/eal_thread.c | 8 ++++---- 13 files changed, 27 insertions(+), 33 deletions(-) diff --git a/drivers/event/octeontx/ssovf_evdev_selftest.c b/drivers/event/octeontx/ssovf_evdev_selftest.c index 239362fcf549..06370840ba36 100644 --- a/drivers/event/octeontx/ssovf_evdev_selftest.c +++ b/drivers/event/octeontx/ssovf_evdev_selftest.c @@ -577,7 +577,7 @@ wait_workers_to_join(int lcore, const rte_atomic32_t *count) RTE_SET_USED(count); print_cycles = cycles = rte_get_timer_cycles(); - while (rte_eal_get_lcore_state(lcore) != FINISHED) { + while (rte_eal_get_lcore_state(lcore) != RTE_LCORE_FINISHED) { uint64_t new_cycles = rte_get_timer_cycles(); if (new_cycles - print_cycles > rte_get_timer_hz()) { diff --git a/drivers/event/sw/sw_evdev_selftest.c b/drivers/event/sw/sw_evdev_selftest.c index d00d5de613d7..9e16f7d3520f 100644 --- a/drivers/event/sw/sw_evdev_selftest.c +++ b/drivers/event/sw/sw_evdev_selftest.c @@ -3116,8 +3116,8 @@ worker_loopback(struct test *t, uint8_t disable_implicit_release) rte_eal_remote_launch(worker_loopback_worker_fn, t, w_lcore); print_cycles = cycles = rte_get_timer_cycles(); - while (rte_eal_get_lcore_state(p_lcore) != FINISHED || - rte_eal_get_lcore_state(w_lcore) != FINISHED) { + while (rte_eal_get_lcore_state(p_lcore) != RTE_LCORE_FINISHED || + rte_eal_get_lcore_state(w_lcore) != RTE_LCORE_FINISHED) { rte_service_run_iter_on_app_lcore(t->service_id, 1); diff --git a/drivers/net/softnic/rte_eth_softnic_thread.c b/drivers/net/softnic/rte_eth_softnic_thread.c index 57989a5aac54..dee3923101bc 100644 --- a/drivers/net/softnic/rte_eth_softnic_thread.c +++ b/drivers/net/softnic/rte_eth_softnic_thread.c @@ -118,10 +118,7 @@ thread_is_valid(struct pmd_internals *softnic, uint32_t thread_id) static inline int thread_is_running(uint32_t thread_id) { - enum rte_lcore_state_t thread_state; - - thread_state = rte_eal_get_lcore_state(thread_id); - return (thread_state == RUNNING)? 1 : 0; + return rte_eal_get_lcore_state(thread_id) == RTE_LCORE_RUNNING; } static int32_t diff --git a/examples/bond/main.c b/examples/bond/main.c index ef86194fff4a..12123a4b16d8 100644 --- a/examples/bond/main.c +++ b/examples/bond/main.c @@ -527,7 +527,7 @@ static void cmd_start_parsed(__attribute__((unused)) void *parsed_result, rte_spinlock_trylock(&global_flag_stru_p->lock); if (global_flag_stru_p->LcoreMainIsRunning == 0) { - if (lcore_config[global_flag_stru_p->LcoreMainCore].state != WAIT) { + if (lcore_config[global_flag_stru_p->LcoreMainCore].state != RTE_LCORE_WAIT) { rte_spinlock_unlock(&global_flag_stru_p->lock); return; } @@ -796,7 +796,7 @@ main(int argc, char *argv[]) /* check state of lcores */ RTE_LCORE_FOREACH_SLAVE(slave_core_id) { - if (lcore_config[slave_core_id].state != WAIT) + if (lcore_config[slave_core_id].state != RTE_LCORE_WAIT) return -EBUSY; } /* start lcore main on core != master_core - ARP response thread */ diff --git a/examples/ip_pipeline/thread.c b/examples/ip_pipeline/thread.c index 272fbbeed1bc..3a62a0aee8bc 100644 --- a/examples/ip_pipeline/thread.c +++ b/examples/ip_pipeline/thread.c @@ -158,10 +158,7 @@ thread_init(void) static inline int thread_is_running(uint32_t thread_id) { - enum rte_lcore_state_t thread_state; - - thread_state = rte_eal_get_lcore_state(thread_id); - return (thread_state == RUNNING) ? 1 : 0; + return rte_eal_get_lcore_state(thread_id) == RTE_LCORE_RUNNING; } /** diff --git a/examples/l2fwd-keepalive/main.c b/examples/l2fwd-keepalive/main.c index 0bf2b533648a..2e1edfa05937 100644 --- a/examples/l2fwd-keepalive/main.c +++ b/examples/l2fwd-keepalive/main.c @@ -502,7 +502,7 @@ dead_core(__rte_unused void *ptr_data, const int id_core) if (terminate_signal_received) return; printf("Dead core %i - restarting..\n", id_core); - if (rte_eal_get_lcore_state(id_core) == FINISHED) { + if (rte_eal_get_lcore_state(id_core) == RTE_LCORE_FINISHED) { rte_eal_wait_lcore(id_core); rte_eal_remote_launch(l2fwd_launch_one_lcore, NULL, id_core); } else { diff --git a/lib/librte_eal/common/eal_common_launch.c b/lib/librte_eal/common/eal_common_launch.c index fe0ba3f0d617..74a3f1a28432 100644 --- a/lib/librte_eal/common/eal_common_launch.c +++ b/lib/librte_eal/common/eal_common_launch.c @@ -21,17 +21,17 @@ int rte_eal_wait_lcore(unsigned slave_id) { - if (lcore_config[slave_id].state == WAIT) + if (lcore_config[slave_id].state == RTE_LCORE_WAITING) return 0; - while (lcore_config[slave_id].state != WAIT && - lcore_config[slave_id].state != FINISHED) + while (lcore_config[slave_id].state != RTE_LCORE_WAITING && + lcore_config[slave_id].state != RTE_LCORE_FINISHED) rte_pause(); rte_rmb(); /* we are in finished state, go to wait state */ - lcore_config[slave_id].state = WAIT; + lcore_config[slave_id].state = RTE_LCORE_WAITING; return lcore_config[slave_id].ret; } @@ -49,7 +49,7 @@ rte_eal_mp_remote_launch(int (*f)(void *), void *arg, /* check state of lcores */ RTE_LCORE_FOREACH_SLAVE(lcore_id) { - if (lcore_config[lcore_id].state != WAIT) + if (lcore_config[lcore_id].state != RTE_LCORE_WAITING) return -EBUSY; } @@ -60,7 +60,7 @@ rte_eal_mp_remote_launch(int (*f)(void *), void *arg, if (call_master == CALL_MASTER) { lcore_config[master].ret = f(arg); - lcore_config[master].state = FINISHED; + lcore_config[master].state = RTE_LCORE_FINISHED; } return 0; diff --git a/lib/librte_eal/common/include/rte_launch.h b/lib/librte_eal/common/include/rte_launch.h index 06a671752ace..286ca31c98ab 100644 --- a/lib/librte_eal/common/include/rte_launch.h +++ b/lib/librte_eal/common/include/rte_launch.h @@ -19,9 +19,9 @@ extern "C" { * State of an lcore. */ enum rte_lcore_state_t { - WAIT, /**< waiting a new command */ - RUNNING, /**< executing command */ - FINISHED, /**< command executed */ + RTE_LCORE_WAITING, /**< waiting a new command */ + RTE_LCORE_RUNNING, /**< executing command */ + RTE_LCORE_FINISHED, /**< command executed */ }; /** diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c index 5f75e5a53fbf..8dd7586027ff 100644 --- a/lib/librte_eal/common/rte_service.c +++ b/lib/librte_eal/common/rte_service.c @@ -450,7 +450,7 @@ rte_service_runner_func(void *arg) rte_smp_rmb(); } - lcore_config[lcore].state = WAIT; + lcore_config[lcore].state = RTE_LCORE_WAITING; return 0; } diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c index 790c6afa7050..aae4243486bd 100644 --- a/lib/librte_eal/freebsd/eal/eal.c +++ b/lib/librte_eal/freebsd/eal/eal.c @@ -784,7 +784,7 @@ rte_eal_init(int argc, char **argv) if (pipe(lcore_config[i].pipe_slave2master) < 0) rte_panic("Cannot create pipe\n"); - lcore_config[i].state = WAIT; + lcore_config[i].state = RTE_LCORE_WAIT; /* create a thread for each lcore */ ret = pthread_create(&lcore_config[i].thread_id, NULL, diff --git a/lib/librte_eal/freebsd/eal/eal_thread.c b/lib/librte_eal/freebsd/eal/eal_thread.c index 309b5872666b..f25e84fa312b 100644 --- a/lib/librte_eal/freebsd/eal/eal_thread.c +++ b/lib/librte_eal/freebsd/eal/eal_thread.c @@ -41,7 +41,7 @@ rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id) int m2s = lcore_config[slave_id].pipe_master2slave[1]; int s2m = lcore_config[slave_id].pipe_slave2master[0]; - if (lcore_config[slave_id].state != WAIT) + if (lcore_config[slave_id].state != RTE_LCORE_WAITING) return -EBUSY; lcore_config[slave_id].f = f; @@ -136,7 +136,7 @@ eal_thread_loop(__attribute__((unused)) void *arg) if (n <= 0) rte_panic("cannot read on configuration pipe\n"); - lcore_config[lcore_id].state = RUNNING; + lcore_config[lcore_id].state = RTE_LCORE_RUNNING; /* send ack */ n = 0; @@ -153,7 +153,7 @@ eal_thread_loop(__attribute__((unused)) void *arg) ret = lcore_config[lcore_id].f(fct_arg); lcore_config[lcore_id].ret = ret; rte_wmb(); - lcore_config[lcore_id].state = FINISHED; + lcore_config[lcore_id].state = RTE_LCORE_FINISHED; } /* never reached */ diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c index 75ed0cf1029f..3fe25a1feb2f 100644 --- a/lib/librte_eal/linux/eal/eal.c +++ b/lib/librte_eal/linux/eal/eal.c @@ -1158,7 +1158,7 @@ rte_eal_init(int argc, char **argv) if (pipe(lcore_config[i].pipe_slave2master) < 0) rte_panic("Cannot create pipe\n"); - lcore_config[i].state = WAIT; + lcore_config[i].state = RTE_LCORE_WAITING; /* create a thread for each lcore */ ret = pthread_create(&lcore_config[i].thread_id, NULL, diff --git a/lib/librte_eal/linux/eal/eal_thread.c b/lib/librte_eal/linux/eal/eal_thread.c index 379773b683e8..058692a45412 100644 --- a/lib/librte_eal/linux/eal/eal_thread.c +++ b/lib/librte_eal/linux/eal/eal_thread.c @@ -41,7 +41,7 @@ rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id) int m2s = lcore_config[slave_id].pipe_master2slave[1]; int s2m = lcore_config[slave_id].pipe_slave2master[0]; - if (lcore_config[slave_id].state != WAIT) + if (lcore_config[slave_id].state != RTE_LCORE_WAITING) return -EBUSY; lcore_config[slave_id].f = f; @@ -136,7 +136,7 @@ eal_thread_loop(__attribute__((unused)) void *arg) if (n <= 0) rte_panic("cannot read on configuration pipe\n"); - lcore_config[lcore_id].state = RUNNING; + lcore_config[lcore_id].state = RTE_LCORE_RUNNING; /* send ack */ n = 0; @@ -158,9 +158,9 @@ eal_thread_loop(__attribute__((unused)) void *arg) * state, because the application will not lcore_wait() for it. */ if (lcore_config[lcore_id].core_role == ROLE_SERVICE) - lcore_config[lcore_id].state = WAIT; + lcore_config[lcore_id].state = RTE_LCORE_WAITING; else - lcore_config[lcore_id].state = FINISHED; + lcore_config[lcore_id].state = RTE_LCORE_FINISHED; } /* never reached */ -- 2.17.1