f-stack/dpdk/examples/helloworld/main.c

52 lines
919 B
C
Raw Normal View History

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 <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>
static int
2021-02-05 08:48:47 +00:00
lcore_hello(__rte_unused void *arg)
2017-04-21 10:43:26 +00:00
{
unsigned lcore_id;
lcore_id = rte_lcore_id();
printf("hello from core %u\n", lcore_id);
return 0;
}
int
main(int argc, char **argv)
{
int ret;
unsigned lcore_id;
ret = rte_eal_init(argc, argv);
if (ret < 0)
rte_panic("Cannot init EAL\n");
2021-02-05 08:48:47 +00:00
/* call lcore_hello() on every worker lcore */
RTE_LCORE_FOREACH_WORKER(lcore_id) {
2017-04-21 10:43:26 +00:00
rte_eal_remote_launch(lcore_hello, NULL, lcore_id);
}
2021-02-05 08:48:47 +00:00
/* call it on main lcore too */
2017-04-21 10:43:26 +00:00
lcore_hello(NULL);
rte_eal_mp_wait_lcore();
2022-09-02 04:40:05 +00:00
/* clean up the EAL */
rte_eal_cleanup();
2017-04-21 10:43:26 +00:00
return 0;
}