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