Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/132748/?format=api
http://patchwork.dpdk.org/api/patches/132748/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20231017121318.146007-8-bruce.richardson@intel.com/", "project": { "id": 1, "url": "http://patchwork.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20231017121318.146007-8-bruce.richardson@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20231017121318.146007-8-bruce.richardson@intel.com", "date": "2023-10-17T12:13:16", "name": "[v5,7/9] examples/vdpa: auto-generate cmdline boilerplate", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "2f821d3ccd2511ffae655351ef7e9d4f8d3984d8", "submitter": { "id": 20, "url": "http://patchwork.dpdk.org/api/people/20/?format=api", "name": "Bruce Richardson", "email": "bruce.richardson@intel.com" }, "delegate": { "id": 1, "url": "http://patchwork.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20231017121318.146007-8-bruce.richardson@intel.com/mbox/", "series": [ { "id": 29878, "url": "http://patchwork.dpdk.org/api/series/29878/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=29878", "date": "2023-10-17T12:13:09", "name": "document and simplify use of cmdline", "version": 5, "mbox": "http://patchwork.dpdk.org/series/29878/mbox/" } ], "comments": "http://patchwork.dpdk.org/api/patches/132748/comments/", "check": "success", "checks": "http://patchwork.dpdk.org/api/patches/132748/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 5C0EA4318A;\n\tTue, 17 Oct 2023 14:14:18 +0200 (CEST)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 3656642DCD;\n\tTue, 17 Oct 2023 14:13:41 +0200 (CEST)", "from mgamail.intel.com (mgamail.intel.com [134.134.136.31])\n by mails.dpdk.org (Postfix) with ESMTP id BCEF542DB2\n for <dev@dpdk.org>; Tue, 17 Oct 2023 14:13:39 +0200 (CEST)", "from fmviesa001.fm.intel.com ([10.60.135.141])\n by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 17 Oct 2023 05:13:39 -0700", "from unknown (HELO silpixa00401385.ir.intel.com) ([10.237.214.41])\n by fmviesa001.fm.intel.com with ESMTP; 17 Oct 2023 05:13:43 -0700" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1697544819; x=1729080819;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=eHJRZHmN4kFqKeivEFmViSHUGQL6TI2gSbwpJ0KbhFQ=;\n b=nD38y3g7GpNV7FU1Nkz9UrBrN1NOlB3v1baI9sF5FP55BVL19TCoRN4e\n T+G03qBBrQWy7JAhI/rFrJYHIOQ9CXjp6mntApU2zg4653s8vUs5K4vyq\n IkByan34VjJ7KAXD0bgI9OfnEr263rBuOvhv458oR8Xu89ClUxd1Zlr1V\n HYv50LSxS8hc58/OEobsf9OdWOwmQJmT0h9gKhKa3lvqUFFC0Kpi0CJQ0\n v+3RX16/GkeVIaAIEKuteW4YL7UXpObx8NEzRCfiggXMXWEhpbAAUkiiY\n /0cggHSXsELrVr9ZTA6HnyvKci96KMwm28Pv8tnz5w42daKo+Airuo8pL g==;", "X-IronPort-AV": [ "E=McAfee;i=\"6600,9927,10865\"; a=\"449984828\"", "E=Sophos;i=\"6.03,232,1694761200\"; d=\"scan'208\";a=\"449984828\"", "E=Sophos;i=\"6.03,232,1694761200\";\n d=\"scan'208\";a=\"4068964\"" ], "X-ExtLoop1": "1", "From": "Bruce Richardson <bruce.richardson@intel.com>", "To": "dev@dpdk.org", "Cc": "david.marchand@redhat.com, rjarry@redhat.com,\n Bruce Richardson <bruce.richardson@intel.com>,\n Maxime Coquelin <maxime.coquelin@redhat.com>,\n Chenbo Xia <chenbo.xia@intel.com>", "Subject": "[PATCH v5 7/9] examples/vdpa: auto-generate cmdline boilerplate", "Date": "Tue, 17 Oct 2023 13:13:16 +0100", "Message-Id": "<20231017121318.146007-8-bruce.richardson@intel.com>", "X-Mailer": "git-send-email 2.39.2", "In-Reply-To": "<20231017121318.146007-1-bruce.richardson@intel.com>", "References": "<20230802170052.955323-1-bruce.richardson@intel.com>\n <20231017121318.146007-1-bruce.richardson@intel.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org" }, "content": "Use the dpdk-cmdline-gen script to autogenerate all the boilerplate\nstructs and defines for the commandline part of the app.\n\nSigned-off-by: Bruce Richardson <bruce.richardson@intel.com>\n---\n examples/vdpa/Makefile | 12 ++--\n examples/vdpa/commands.list | 8 +++\n examples/vdpa/main.c | 131 ++----------------------------------\n examples/vdpa/meson.build | 7 ++\n 4 files changed, 30 insertions(+), 128 deletions(-)\n create mode 100644 examples/vdpa/commands.list", "diff": "diff --git a/examples/vdpa/Makefile b/examples/vdpa/Makefile\nindex d974db4f40..aa60a000cf 100644\n--- a/examples/vdpa/Makefile\n+++ b/examples/vdpa/Makefile\n@@ -6,6 +6,7 @@ APP = vdpa\n \n # all source are stored in SRCS-y\n SRCS-y := main.c\n+SRC-DEPS := build/commands.h\n CFLAGS += -DALLOW_EXPERIMENTAL_API\n \n PKGCONF ?= pkg-config\n@@ -23,10 +24,13 @@ static: build/$(APP)-static\n \tln -sf $(APP)-static build/$(APP)\n \n PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)\n-CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)\n+CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) -I build/\n LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)\n LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk)\n \n+build/commands.h: commands.list Makefile\n+\tdpdk-cmdline-gen.py -o $@ --context-name=main_ctx $<\n+\n ifeq ($(MAKECMDGOALS),static)\n # check for broken pkg-config\n ifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),)\n@@ -35,10 +39,10 @@ $(error \"Cannot generate statically-linked binaries with this version of pkg-con\n endif\n endif\n \n-build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build\n+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(SRC-DEPS)\n \t$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)\n \n-build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build\n+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build $(SRC-DEPS)\n \t$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)\n \n build:\n@@ -46,5 +50,5 @@ build:\n \n .PHONY: clean\n clean:\n-\trm -f build/$(APP) build/$(APP)-static build/$(APP)-shared\n+\trm -f build/$(APP) build/$(APP)-static build/$(APP)-shared build/*.h\n \ttest -d build && rmdir -p build || true\ndiff --git a/examples/vdpa/commands.list b/examples/vdpa/commands.list\nnew file mode 100644\nindex 0000000000..1eb8486c45\n--- /dev/null\n+++ b/examples/vdpa/commands.list\n@@ -0,0 +1,8 @@\n+# SPDX-License-Identifier: BSD-3-Clause\n+# Copyright(c) 2023 Intel Corporation\n+#\n+help # show help\n+list # list all available vdpa devices\n+create <STRING>socket_path <STRING>bdf # create a new vdpa port\n+stats <STRING>bdf <UINT32>qid # show device statistics\n+quit # exit application\ndiff --git a/examples/vdpa/main.c b/examples/vdpa/main.c\nindex 4d3203f3a7..289db26498 100644\n--- a/examples/vdpa/main.c\n+++ b/examples/vdpa/main.c\n@@ -16,11 +16,8 @@\n #include <rte_pci.h>\n #include <rte_string_fns.h>\n \n-#include <cmdline_parse.h>\n #include <cmdline_socket.h>\n-#include <cmdline_parse_string.h>\n-#include <cmdline_parse_num.h>\n-#include <cmdline.h>\n+#include \"commands.h\" /* auto-generated file from commands.list */\n #include \"vdpa_blk_compact.h\"\n \n #define MAX_PATH_LEN 128\n@@ -301,14 +298,9 @@ signal_handler(int signum)\n \t}\n }\n \n-/* interactive cmds */\n+/* interactive cmd functions */\n \n-/* *** Help command with introduction. *** */\n-struct cmd_help_result {\n-\tcmdline_fixed_string_t help;\n-};\n-\n-static void cmd_help_parsed(__rte_unused void *parsed_result,\n+void cmd_help_parsed(__rte_unused void *parsed_result,\n \t\tstruct cmdline *cl,\n \t\t__rte_unused void *data)\n {\n@@ -325,25 +317,7 @@ static void cmd_help_parsed(__rte_unused void *parsed_result,\n \t);\n }\n \n-cmdline_parse_token_string_t cmd_help_help =\n-\tTOKEN_STRING_INITIALIZER(struct cmd_help_result, help, \"help\");\n-\n-cmdline_parse_inst_t cmd_help = {\n-\t.f = cmd_help_parsed,\n-\t.data = NULL,\n-\t.help_str = \"show help\",\n-\t.tokens = {\n-\t\t(void *)&cmd_help_help,\n-\t\tNULL,\n-\t},\n-};\n-\n-/* *** List all available vdpa devices *** */\n-struct cmd_list_result {\n-\tcmdline_fixed_string_t action;\n-};\n-\n-static void cmd_list_vdpa_devices_parsed(\n+void cmd_list_parsed(\n \t\t__rte_unused void *parsed_result,\n \t\tstruct cmdline *cl,\n \t\t__rte_unused void *data)\n@@ -376,27 +350,7 @@ static void cmd_list_vdpa_devices_parsed(\n \t}\n }\n \n-cmdline_parse_token_string_t cmd_action_list =\n-\tTOKEN_STRING_INITIALIZER(struct cmd_list_result, action, \"list\");\n-\n-cmdline_parse_inst_t cmd_list_vdpa_devices = {\n-\t.f = cmd_list_vdpa_devices_parsed,\n-\t.data = NULL,\n-\t.help_str = \"list all available vdpa devices\",\n-\t.tokens = {\n-\t\t(void *)&cmd_action_list,\n-\t\tNULL,\n-\t},\n-};\n-\n-/* *** Create new vdpa port *** */\n-struct cmd_create_result {\n-\tcmdline_fixed_string_t action;\n-\tcmdline_fixed_string_t socket_path;\n-\tcmdline_fixed_string_t bdf;\n-};\n-\n-static void cmd_create_vdpa_port_parsed(void *parsed_result,\n+void cmd_create_parsed(void *parsed_result,\n \t\tstruct cmdline *cl,\n \t\t__rte_unused void *data)\n {\n@@ -417,33 +371,7 @@ static void cmd_create_vdpa_port_parsed(void *parsed_result,\n \t\tdevcnt++;\n }\n \n-cmdline_parse_token_string_t cmd_action_create =\n-\tTOKEN_STRING_INITIALIZER(struct cmd_create_result, action, \"create\");\n-cmdline_parse_token_string_t cmd_socket_path =\n-\tTOKEN_STRING_INITIALIZER(struct cmd_create_result, socket_path, NULL);\n-cmdline_parse_token_string_t cmd_bdf =\n-\tTOKEN_STRING_INITIALIZER(struct cmd_create_result, bdf, NULL);\n-\n-cmdline_parse_inst_t cmd_create_vdpa_port = {\n-\t.f = cmd_create_vdpa_port_parsed,\n-\t.data = NULL,\n-\t.help_str = \"create a new vdpa port\",\n-\t.tokens = {\n-\t\t(void *)&cmd_action_create,\n-\t\t(void *)&cmd_socket_path,\n-\t\t(void *)&cmd_bdf,\n-\t\tNULL,\n-\t},\n-};\n-\n-/* *** STATS *** */\n-struct cmd_stats_result {\n-\tcmdline_fixed_string_t stats;\n-\tcmdline_fixed_string_t bdf;\n-\tuint16_t qid;\n-};\n-\n-static void cmd_device_stats_parsed(void *parsed_result, struct cmdline *cl,\n+void cmd_stats_parsed(void *parsed_result, struct cmdline *cl,\n \t\t\t\t __rte_unused void *data)\n {\n \tstruct cmd_stats_result *res = parsed_result;\n@@ -525,31 +453,7 @@ static void cmd_device_stats_parsed(void *parsed_result, struct cmdline *cl,\n \t}\n }\n \n-cmdline_parse_token_string_t cmd_device_stats_ =\n-\tTOKEN_STRING_INITIALIZER(struct cmd_stats_result, stats, \"stats\");\n-cmdline_parse_token_string_t cmd_device_bdf =\n-\tTOKEN_STRING_INITIALIZER(struct cmd_stats_result, bdf, NULL);\n-cmdline_parse_token_num_t cmd_queue_id =\n-\tTOKEN_NUM_INITIALIZER(struct cmd_stats_result, qid, RTE_UINT32);\n-\n-cmdline_parse_inst_t cmd_device_stats = {\n-\t.f = cmd_device_stats_parsed,\n-\t.data = NULL,\n-\t.help_str = \"stats: show device statistics\",\n-\t.tokens = {\n-\t\t(void *)&cmd_device_stats_,\n-\t\t(void *)&cmd_device_bdf,\n-\t\t(void *)&cmd_queue_id,\n-\t\tNULL,\n-\t},\n-};\n-\n-/* *** QUIT *** */\n-struct cmd_quit_result {\n-\tcmdline_fixed_string_t quit;\n-};\n-\n-static void cmd_quit_parsed(__rte_unused void *parsed_result,\n+void cmd_quit_parsed(__rte_unused void *parsed_result,\n \t\tstruct cmdline *cl,\n \t\t__rte_unused void *data)\n {\n@@ -557,27 +461,6 @@ static void cmd_quit_parsed(__rte_unused void *parsed_result,\n \tcmdline_quit(cl);\n }\n \n-cmdline_parse_token_string_t cmd_quit_quit =\n-\tTOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, \"quit\");\n-\n-cmdline_parse_inst_t cmd_quit = {\n-\t.f = cmd_quit_parsed,\n-\t.data = NULL,\n-\t.help_str = \"quit: exit application\",\n-\t.tokens = {\n-\t\t(void *)&cmd_quit_quit,\n-\t\tNULL,\n-\t},\n-};\n-cmdline_parse_ctx_t main_ctx[] = {\n-\t(cmdline_parse_inst_t *)&cmd_help,\n-\t(cmdline_parse_inst_t *)&cmd_list_vdpa_devices,\n-\t(cmdline_parse_inst_t *)&cmd_create_vdpa_port,\n-\t(cmdline_parse_inst_t *)&cmd_device_stats,\n-\t(cmdline_parse_inst_t *)&cmd_quit,\n-\tNULL,\n-};\n-\n int\n main(int argc, char *argv[])\n {\ndiff --git a/examples/vdpa/meson.build b/examples/vdpa/meson.build\nindex bd086050dc..a48028da4d 100644\n--- a/examples/vdpa/meson.build\n+++ b/examples/vdpa/meson.build\n@@ -16,3 +16,10 @@ allow_experimental_apis = true\n sources = files(\n 'main.c',\n )\n+cmd_h = custom_target('commands_hdr',\n+\toutput: 'commands.h',\n+\tinput: files('commands.list'),\n+\tcapture: true,\n+\tcommand: [cmdline_gen_cmd, '--context-name=main_ctx', '@INPUT@']\n+)\n+sources += cmd_h\n", "prefixes": [ "v5", "7/9" ] }{ "id": 132748, "url": "