@@ -6,6 +6,7 @@ APP = simple_mp
# all source are stored in SRCS-y
SRCS-y := main.c mp_commands.c
+SRC-DEPS := build/mp_commands.h
PKGCONF ?= pkg-config
@@ -22,10 +23,13 @@ static: build/$(APP)-static
ln -sf $(APP)-static build/$(APP)
PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
-CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
+CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) -I build/
LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk)
+build/mp_commands.h: mp_commands.list Makefile
+ dpdk-cmdline-gen.py -o $@ --context-name=simple_mp_ctx $<
+
ifeq ($(MAKECMDGOALS),static)
# check for broken pkg-config
ifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),)
@@ -36,10 +40,10 @@ endif
CFLAGS += -DALLOW_EXPERIMENTAL_API
-build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(SRC-DEPS)
$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
-build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build
+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build $(SRC-DEPS)
$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
build:
@@ -47,5 +51,5 @@ build:
.PHONY: clean
clean:
- rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared
+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared build/mp_commands.h
test -d build && rmdir -p build || true
@@ -7,7 +7,16 @@
# DPDK instance, use 'make'
allow_experimental_apis = true
+
+cmd_h = custom_target('commands_hdr',
+ output: 'mp_commands.h',
+ input: files('mp_commands.list'),
+ capture: true,
+ command: [cmdline_gen_cmd, '--context-name=simple_mp_ctx', '@INPUT@']
+)
+
sources = files(
'mp_commands.c',
'main.c',
)
+sources += cmd_h
@@ -1,44 +1,18 @@
/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2014 Intel Corporation
+ * Copyright(c) 2010-2023 Intel Corporation
*/
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <inttypes.h>
-#include <stdio.h>
-#include <termios.h>
-#include <errno.h>
-#include <sys/queue.h>
-
-#include <rte_common.h>
-#include <rte_memory.h>
-#include <rte_eal.h>
-#include <rte_branch_prediction.h>
-#include <rte_launch.h>
-#include <rte_log.h>
-#include <rte_per_lcore.h>
-#include <rte_lcore.h>
#include <rte_ring.h>
-#include <rte_debug.h>
#include <rte_mempool.h>
#include <rte_string_fns.h>
-#include <cmdline_rdline.h>
-#include <cmdline_parse.h>
-#include <cmdline_parse_string.h>
-#include <cmdline_socket.h>
-#include <cmdline.h>
#include "mp_commands.h"
-/**********************************************************/
-
-struct cmd_send_result {
- cmdline_fixed_string_t action;
- cmdline_fixed_string_t message;
-};
+extern struct rte_ring *send_ring, *recv_ring;
+extern struct rte_mempool *message_pool;
+extern volatile int quit;
-static void cmd_send_parsed(void *parsed_result,
+void
+cmd_send_parsed(void *parsed_result,
__rte_unused struct cmdline *cl,
__rte_unused void *data)
{
@@ -54,29 +28,8 @@ static void cmd_send_parsed(void *parsed_result,
}
}
-cmdline_parse_token_string_t cmd_send_action =
- TOKEN_STRING_INITIALIZER(struct cmd_send_result, action, "send");
-cmdline_parse_token_string_t cmd_send_message =
- TOKEN_STRING_INITIALIZER(struct cmd_send_result, message, NULL);
-
-cmdline_parse_inst_t cmd_send = {
- .f = cmd_send_parsed, /* function to call */
- .data = NULL, /* 2nd arg of func */
- .help_str = "send a string to another process",
- .tokens = { /* token list, NULL terminated */
- (void *)&cmd_send_action,
- (void *)&cmd_send_message,
- NULL,
- },
-};
-
-/**********************************************************/
-
-struct cmd_quit_result {
- cmdline_fixed_string_t quit;
-};
-
-static void cmd_quit_parsed(__rte_unused void *parsed_result,
+void
+cmd_quit_parsed(__rte_unused void *parsed_result,
struct cmdline *cl,
__rte_unused void *data)
{
@@ -84,26 +37,8 @@ static void cmd_quit_parsed(__rte_unused void *parsed_result,
cmdline_quit(cl);
}
-cmdline_parse_token_string_t cmd_quit_quit =
- TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
-
-cmdline_parse_inst_t cmd_quit = {
- .f = cmd_quit_parsed, /* function to call */
- .data = NULL, /* 2nd arg of func */
- .help_str = "close the application",
- .tokens = { /* token list, NULL terminated */
- (void *)&cmd_quit_quit,
- NULL,
- },
-};
-
-/**********************************************************/
-
-struct cmd_help_result {
- cmdline_fixed_string_t help;
-};
-
-static void cmd_help_parsed(__rte_unused void *parsed_result,
+void
+cmd_help_parsed(__rte_unused void *parsed_result,
struct cmdline *cl,
__rte_unused void *data)
{
@@ -112,24 +47,3 @@ static void cmd_help_parsed(__rte_unused void *parsed_result,
"send commands to the simple app. Commands supported are:\n\n"
"- send [string]\n" "- help\n" "- quit\n\n");
}
-
-cmdline_parse_token_string_t cmd_help_help =
- TOKEN_STRING_INITIALIZER(struct cmd_help_result, help, "help");
-
-cmdline_parse_inst_t cmd_help = {
- .f = cmd_help_parsed, /* function to call */
- .data = NULL, /* 2nd arg of func */
- .help_str = "show help",
- .tokens = { /* token list, NULL terminated */
- (void *)&cmd_help_help,
- NULL,
- },
-};
-
-/****** CONTEXT (list of instruction) */
-cmdline_parse_ctx_t simple_mp_ctx[] = {
- (cmdline_parse_inst_t *)&cmd_send,
- (cmdline_parse_inst_t *)&cmd_quit,
- (cmdline_parse_inst_t *)&cmd_help,
- NULL,
-};
deleted file mode 100644
@@ -1,14 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2014 Intel Corporation
- */
-
-#ifndef _SIMPLE_MP_COMMANDS_H_
-#define _SIMPLE_MP_COMMANDS_H_
-
-extern struct rte_ring *send_ring;
-extern struct rte_mempool *message_pool;
-extern volatile int quit;
-
-extern cmdline_parse_ctx_t simple_mp_ctx[];
-
-#endif /* _SIMPLE_MP_COMMANDS_H_ */
new file mode 100644
@@ -0,0 +1,3 @@
+send <STRING>message # send a string to another process
+help # show help
+quit # close the application