Line data Source code
1 : /* SPDX-License-Identifier: BSD-3-Clause
2 : * Copyright(c) 2010-2014 Intel Corporation
3 : */
4 :
5 : #include <errno.h>
6 : #include <stdint.h>
7 : #include <stdio.h>
8 : #include <string.h>
9 : #include <sys/queue.h>
10 :
11 : #include <rte_debug.h>
12 : #include <rte_eal.h>
13 : #include <rte_launch.h>
14 : #include <rte_lcore.h>
15 : #include <rte_memory.h>
16 : #include <rte_per_lcore.h>
17 :
18 : /* Launch a function on lcore. 8< */
19 : static int
20 0 : lcore_hello(__rte_unused void* arg)
21 : {
22 0 : unsigned lcore_id;
23 0 : lcore_id = rte_lcore_id();
24 0 : printf("hello from core %u\n", lcore_id);
25 0 : return 0;
26 : }
27 : /* >8 End of launching function on lcore. */
28 :
29 : /* Initialization of Environment Abstraction Layer (EAL). 8< */
30 : int
31 0 : main(int argc, char** argv)
32 : {
33 0 : int ret;
34 0 : unsigned lcore_id;
35 :
36 0 : ret = rte_eal_init(argc, argv);
37 0 : if (ret < 0)
38 0 : rte_panic("Cannot init EAL\n");
39 : /* >8 End of initialization of Environment Abstraction Layer */
40 :
41 : /* Launches the function on each lcore. 8< */
42 0 : RTE_LCORE_FOREACH_WORKER(lcore_id)
43 : {
44 : /* Simpler equivalent. 8< */
45 0 : rte_eal_remote_launch(lcore_hello, NULL, lcore_id);
46 : /* >8 End of simpler equivalent. */
47 : }
48 :
49 : /* call it on main lcore too */
50 0 : lcore_hello(NULL);
51 : /* >8 End of launching the function on each lcore. */
52 :
53 0 : rte_eal_mp_wait_lcore();
54 :
55 : /* clean up the EAL */
56 0 : rte_eal_cleanup();
57 :
58 0 : return 0;
59 : }
|