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 if (lcore_config[worker_id].state == WAIT)
29 while (lcore_config[worker_id].state != WAIT)
34 return lcore_config[worker_id].ret;
38 * Check that every WORKER lcores are in WAIT state, then call
39 * rte_eal_remote_launch() for all of them. If call_main is true
40 * (set to CALL_MAIN), also call the function on the main lcore.
43 rte_eal_mp_remote_launch(int (*f)(void *), void *arg,
44 enum rte_rmt_call_main_t call_main)
47 int main_lcore = rte_get_main_lcore();
49 /* check state of lcores */
50 RTE_LCORE_FOREACH_WORKER(lcore_id) {
51 if (lcore_config[lcore_id].state != WAIT)
55 /* send messages to cores */
56 RTE_LCORE_FOREACH_WORKER(lcore_id) {
57 rte_eal_remote_launch(f, arg, lcore_id);
60 if (call_main == CALL_MAIN) {
61 lcore_config[main_lcore].ret = f(arg);
62 lcore_config[main_lcore].state = WAIT;
69 * Return the state of the lcore identified by worker_id.
71 enum rte_lcore_state_t
72 rte_eal_get_lcore_state(unsigned lcore_id)
74 return lcore_config[lcore_id].state;
78 * Do a rte_eal_wait_lcore() for every lcore. The return values are
82 rte_eal_mp_wait_lcore(void)
86 RTE_LCORE_FOREACH_WORKER(lcore_id) {
87 rte_eal_wait_lcore(lcore_id);