1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
10 #include <rte_launch.h>
11 #include <rte_memory.h>
13 #include <rte_atomic.h>
14 #include <rte_pause.h>
15 #include <rte_per_lcore.h>
16 #include <rte_lcore.h>
18 #include "eal_private.h"
21 * Wait until a lcore finished its job.
24 rte_eal_wait_lcore(unsigned worker_id)
26 while (__atomic_load_n(&lcore_config[worker_id].state,
27 __ATOMIC_ACQUIRE) != WAIT)
30 return lcore_config[worker_id].ret;
34 * Check that every WORKER lcores are in WAIT state, then call
35 * rte_eal_remote_launch() for all of them. If call_main is true
36 * (set to CALL_MAIN), also call the function on the main lcore.
39 rte_eal_mp_remote_launch(int (*f)(void *), void *arg,
40 enum rte_rmt_call_main_t call_main)
43 int main_lcore = rte_get_main_lcore();
45 /* check state of lcores */
46 RTE_LCORE_FOREACH_WORKER(lcore_id) {
47 if (lcore_config[lcore_id].state != WAIT)
51 /* send messages to cores */
52 RTE_LCORE_FOREACH_WORKER(lcore_id) {
53 rte_eal_remote_launch(f, arg, lcore_id);
56 if (call_main == CALL_MAIN) {
57 lcore_config[main_lcore].ret = f(arg);
58 lcore_config[main_lcore].state = WAIT;
65 * Return the state of the lcore identified by worker_id.
67 enum rte_lcore_state_t
68 rte_eal_get_lcore_state(unsigned lcore_id)
70 return lcore_config[lcore_id].state;
74 * Do a rte_eal_wait_lcore() for every lcore. The return values are
78 rte_eal_mp_wait_lcore(void)
82 RTE_LCORE_FOREACH_WORKER(lcore_id) {
83 rte_eal_wait_lcore(lcore_id);