2019-06-25 11:12:58 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
* Copyright(c) 2010-2014 Intel Corporation
|
2017-04-21 10:43:26 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/queue.h>
|
|
|
|
|
|
|
|
#include <rte_launch.h>
|
|
|
|
#include <rte_memory.h>
|
|
|
|
#include <rte_eal.h>
|
|
|
|
#include <rte_atomic.h>
|
2018-05-15 09:49:22 +00:00
|
|
|
#include <rte_pause.h>
|
2017-04-21 10:43:26 +00:00
|
|
|
#include <rte_per_lcore.h>
|
|
|
|
#include <rte_lcore.h>
|
|
|
|
|
2020-06-18 16:55:50 +00:00
|
|
|
#include "eal_private.h"
|
|
|
|
|
2017-04-21 10:43:26 +00:00
|
|
|
/*
|
|
|
|
* Wait until a lcore finished its job.
|
|
|
|
*/
|
|
|
|
int
|
2021-02-05 08:48:47 +00:00
|
|
|
rte_eal_wait_lcore(unsigned worker_id)
|
2017-04-21 10:43:26 +00:00
|
|
|
{
|
2021-02-05 08:48:47 +00:00
|
|
|
if (lcore_config[worker_id].state == WAIT)
|
2017-04-21 10:43:26 +00:00
|
|
|
return 0;
|
|
|
|
|
2021-02-05 08:48:47 +00:00
|
|
|
while (lcore_config[worker_id].state != WAIT &&
|
|
|
|
lcore_config[worker_id].state != FINISHED)
|
2018-05-15 09:49:22 +00:00
|
|
|
rte_pause();
|
2017-04-21 10:43:26 +00:00
|
|
|
|
|
|
|
rte_rmb();
|
|
|
|
|
|
|
|
/* we are in finished state, go to wait state */
|
2021-02-05 08:48:47 +00:00
|
|
|
lcore_config[worker_id].state = WAIT;
|
|
|
|
return lcore_config[worker_id].ret;
|
2017-04-21 10:43:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2021-02-05 08:48:47 +00:00
|
|
|
* Check that every WORKER lcores are in WAIT state, then call
|
|
|
|
* rte_eal_remote_launch() for all of them. If call_main is true
|
|
|
|
* (set to CALL_MAIN), also call the function on the main lcore.
|
2017-04-21 10:43:26 +00:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
rte_eal_mp_remote_launch(int (*f)(void *), void *arg,
|
2021-02-05 08:48:47 +00:00
|
|
|
enum rte_rmt_call_main_t call_main)
|
2017-04-21 10:43:26 +00:00
|
|
|
{
|
|
|
|
int lcore_id;
|
2021-02-05 08:48:47 +00:00
|
|
|
int main_lcore = rte_get_main_lcore();
|
2017-04-21 10:43:26 +00:00
|
|
|
|
|
|
|
/* check state of lcores */
|
2021-02-05 08:48:47 +00:00
|
|
|
RTE_LCORE_FOREACH_WORKER(lcore_id) {
|
2017-04-21 10:43:26 +00:00
|
|
|
if (lcore_config[lcore_id].state != WAIT)
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* send messages to cores */
|
2021-02-05 08:48:47 +00:00
|
|
|
RTE_LCORE_FOREACH_WORKER(lcore_id) {
|
2017-04-21 10:43:26 +00:00
|
|
|
rte_eal_remote_launch(f, arg, lcore_id);
|
|
|
|
}
|
|
|
|
|
2021-02-05 08:48:47 +00:00
|
|
|
if (call_main == CALL_MAIN) {
|
|
|
|
lcore_config[main_lcore].ret = f(arg);
|
|
|
|
lcore_config[main_lcore].state = FINISHED;
|
2017-04-21 10:43:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2021-02-05 08:48:47 +00:00
|
|
|
* Return the state of the lcore identified by worker_id.
|
2017-04-21 10:43:26 +00:00
|
|
|
*/
|
|
|
|
enum rte_lcore_state_t
|
|
|
|
rte_eal_get_lcore_state(unsigned lcore_id)
|
|
|
|
{
|
|
|
|
return lcore_config[lcore_id].state;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Do a rte_eal_wait_lcore() for every lcore. The return values are
|
|
|
|
* ignored.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
rte_eal_mp_wait_lcore(void)
|
|
|
|
{
|
|
|
|
unsigned lcore_id;
|
|
|
|
|
2021-02-05 08:48:47 +00:00
|
|
|
RTE_LCORE_FOREACH_WORKER(lcore_id) {
|
2017-04-21 10:43:26 +00:00
|
|
|
rte_eal_wait_lcore(lcore_id);
|
|
|
|
}
|
|
|
|
}
|