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>
19 * Wait until a lcore finished its job.
22 rte_eal_wait_lcore(unsigned slave_id)
24 if (lcore_config[slave_id].state == WAIT)
27 while (lcore_config[slave_id].state != WAIT &&
28 lcore_config[slave_id].state != FINISHED)
33 /* we are in finished state, go to wait state */
34 lcore_config[slave_id].state = WAIT;
35 return lcore_config[slave_id].ret;
39 * Check that every SLAVE lcores are in WAIT state, then call
40 * rte_eal_remote_launch() for all of them. If call_master is true
41 * (set to CALL_MASTER), also call the function on the master lcore.
44 rte_eal_mp_remote_launch(int (*f)(void *), void *arg,
45 enum rte_rmt_call_master_t call_master)
48 int master = rte_get_master_lcore();
50 /* check state of lcores */
51 RTE_LCORE_FOREACH_SLAVE(lcore_id) {
52 if (lcore_config[lcore_id].state != WAIT)
56 /* send messages to cores */
57 RTE_LCORE_FOREACH_SLAVE(lcore_id) {
58 rte_eal_remote_launch(f, arg, lcore_id);
61 if (call_master == CALL_MASTER) {
62 lcore_config[master].ret = f(arg);
63 lcore_config[master].state = FINISHED;
70 * Return the state of the lcore identified by slave_id.
72 enum rte_lcore_state_t
73 rte_eal_get_lcore_state(unsigned lcore_id)
75 return lcore_config[lcore_id].state;
79 * Do a rte_eal_wait_lcore() for every lcore. The return values are
83 rte_eal_mp_wait_lcore(void)
87 RTE_LCORE_FOREACH_SLAVE(lcore_id) {
88 rte_eal_wait_lcore(lcore_id);