Line data Source code
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 : /* 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 : /* Simpler equivalent. 8< */
44 0 : rte_eal_remote_launch(lcore_hello, NULL, lcore_id);
45 : /* >8 End of simpler equivalent. */
46 : }
47 :
48 : /* call it on main lcore too */
49 0 : lcore_hello(NULL);
50 : /* >8 End of launching the function on each lcore. */
51 :
52 0 : rte_eal_mp_wait_lcore();
53 :
54 : /* clean up the EAL */
55 0 : rte_eal_cleanup();
56 :
57 0 : return 0;
58 : }
|