xref: /dpdk/examples/helloworld/main.c (revision cb056611a8ed9ab9024f3b91bf26e97255194514)
13998e2a0SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
23998e2a0SBruce Richardson  * Copyright(c) 2010-2014 Intel Corporation
3af75078fSIntel  */
4af75078fSIntel 
5af75078fSIntel #include <stdio.h>
6af75078fSIntel #include <string.h>
7af75078fSIntel #include <stdint.h>
8af75078fSIntel #include <errno.h>
9af75078fSIntel #include <sys/queue.h>
10af75078fSIntel 
11af75078fSIntel #include <rte_memory.h>
12af75078fSIntel #include <rte_launch.h>
13af75078fSIntel #include <rte_eal.h>
14af75078fSIntel #include <rte_per_lcore.h>
15af75078fSIntel #include <rte_lcore.h>
16af75078fSIntel #include <rte_debug.h>
17af75078fSIntel 
18af75078fSIntel static int
19f2fc83b4SThomas Monjalon lcore_hello(__rte_unused void *arg)
20af75078fSIntel {
21af75078fSIntel 	unsigned lcore_id;
22af75078fSIntel 	lcore_id = rte_lcore_id();
23af75078fSIntel 	printf("hello from core %u\n", lcore_id);
24af75078fSIntel 	return 0;
25af75078fSIntel }
26af75078fSIntel 
27af75078fSIntel int
2898a16481SDavid Marchand main(int argc, char **argv)
29af75078fSIntel {
30af75078fSIntel 	int ret;
31af75078fSIntel 	unsigned lcore_id;
32af75078fSIntel 
33af75078fSIntel 	ret = rte_eal_init(argc, argv);
34af75078fSIntel 	if (ret < 0)
35af75078fSIntel 		rte_panic("Cannot init EAL\n");
36af75078fSIntel 
37*cb056611SStephen Hemminger 	/* call lcore_hello() on every worker lcore */
38*cb056611SStephen Hemminger 	RTE_LCORE_FOREACH_WORKER(lcore_id) {
39af75078fSIntel 		rte_eal_remote_launch(lcore_hello, NULL, lcore_id);
40af75078fSIntel 	}
41af75078fSIntel 
42*cb056611SStephen Hemminger 	/* call it on main lcore too */
43af75078fSIntel 	lcore_hello(NULL);
44af75078fSIntel 
45af75078fSIntel 	rte_eal_mp_wait_lcore();
46af75078fSIntel 	return 0;
47af75078fSIntel }
48