summaryrefslogtreecommitdiffstats
path: root/src/spdk/dpdk/examples/helloworld/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/spdk/dpdk/examples/helloworld/main.c')
-rw-r--r--src/spdk/dpdk/examples/helloworld/main.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/spdk/dpdk/examples/helloworld/main.c b/src/spdk/dpdk/examples/helloworld/main.c
new file mode 100644
index 000000000..968045f1b
--- /dev/null
+++ b/src/spdk/dpdk/examples/helloworld/main.c
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
+ */
+
+#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
+lcore_hello(__rte_unused void *arg)
+{
+ 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");
+
+ /* call lcore_hello() on every slave lcore */
+ RTE_LCORE_FOREACH_SLAVE(lcore_id) {
+ rte_eal_remote_launch(lcore_hello, NULL, lcore_id);
+ }
+
+ /* call it on master lcore too */
+ lcore_hello(NULL);
+
+ rte_eal_mp_wait_lcore();
+ return 0;
+}