2017-12-19 15:49:02 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
* Copyright(c) 2010-2014 Intel Corporation
|
2012-09-04 12:54:00 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <sys/queue.h>
|
|
|
|
|
|
|
|
#include <rte_memory.h>
|
|
|
|
#include <rte_launch.h>
|
|
|
|
#include <rte_eal.h>
|
|
|
|
#include <rte_per_lcore.h>
|
|
|
|
#include <rte_lcore.h>
|
|
|
|
#include <rte_debug.h>
|
|
|
|
|
2021-07-16 13:57:52 +00:00
|
|
|
/* Launch a function on lcore. 8< */
|
2012-09-04 12:54:00 +00:00
|
|
|
static int
|
2020-02-09 15:54:54 +00:00
|
|
|
lcore_hello(__rte_unused void *arg)
|
2012-09-04 12:54:00 +00:00
|
|
|
{
|
|
|
|
unsigned lcore_id;
|
|
|
|
lcore_id = rte_lcore_id();
|
|
|
|
printf("hello from core %u\n", lcore_id);
|
|
|
|
return 0;
|
|
|
|
}
|
2021-07-16 13:57:52 +00:00
|
|
|
/* >8 End of launching function on lcore. */
|
2012-09-04 12:54:00 +00:00
|
|
|
|
2021-07-16 13:57:52 +00:00
|
|
|
/* Initialization of Environment Abstraction Layer (EAL). 8< */
|
2012-09-04 12:54:00 +00:00
|
|
|
int
|
2014-09-26 14:04:02 +00:00
|
|
|
main(int argc, char **argv)
|
2012-09-04 12:54:00 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
unsigned lcore_id;
|
|
|
|
|
|
|
|
ret = rte_eal_init(argc, argv);
|
|
|
|
if (ret < 0)
|
|
|
|
rte_panic("Cannot init EAL\n");
|
2021-07-16 13:57:52 +00:00
|
|
|
/* >8 End of initialization of Environment Abstraction Layer */
|
2012-09-04 12:54:00 +00:00
|
|
|
|
2021-07-16 13:57:52 +00:00
|
|
|
/* Launches the function on each lcore. 8< */
|
2020-10-15 22:57:19 +00:00
|
|
|
RTE_LCORE_FOREACH_WORKER(lcore_id) {
|
2021-07-16 13:57:52 +00:00
|
|
|
/* Simpler equivalent. 8< */
|
2012-09-04 12:54:00 +00:00
|
|
|
rte_eal_remote_launch(lcore_hello, NULL, lcore_id);
|
2021-07-16 13:57:52 +00:00
|
|
|
/* >8 End of simpler equivalent. */
|
2012-09-04 12:54:00 +00:00
|
|
|
}
|
|
|
|
|
2020-10-15 22:57:19 +00:00
|
|
|
/* call it on main lcore too */
|
2012-09-04 12:54:00 +00:00
|
|
|
lcore_hello(NULL);
|
2021-07-16 13:57:52 +00:00
|
|
|
/* >8 End of launching the function on each lcore. */
|
2012-09-04 12:54:00 +00:00
|
|
|
|
|
|
|
rte_eal_mp_wait_lcore();
|
2021-04-15 02:26:03 +00:00
|
|
|
|
|
|
|
/* clean up the EAL */
|
|
|
|
rte_eal_cleanup();
|
|
|
|
|
2012-09-04 12:54:00 +00:00
|
|
|
return 0;
|
|
|
|
}
|