get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/133501/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 133501,
    "url": "http://patches.dpdk.org/api/patches/133501/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20231027110117.70995-10-bruce.richardson@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patches.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": "<20231027110117.70995-10-bruce.richardson@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20231027110117.70995-10-bruce.richardson@intel.com",
    "date": "2023-10-27T11:01:17",
    "name": "[v7,9/9] examples/ntb: auto-generate cmdline boilerplate",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "c9e064aba5fc9059125e0ae89ea994c2b7bb8b6b",
    "submitter": {
        "id": 20,
        "url": "http://patches.dpdk.org/api/people/20/?format=api",
        "name": "Bruce Richardson",
        "email": "bruce.richardson@intel.com"
    },
    "delegate": {
        "id": 24651,
        "url": "http://patches.dpdk.org/api/users/24651/?format=api",
        "username": "dmarchand",
        "first_name": "David",
        "last_name": "Marchand",
        "email": "david.marchand@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20231027110117.70995-10-bruce.richardson@intel.com/mbox/",
    "series": [
        {
            "id": 30025,
            "url": "http://patches.dpdk.org/api/series/30025/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=30025",
            "date": "2023-10-27T11:01:08",
            "name": "document and simplify use of cmdline",
            "version": 7,
            "mbox": "http://patches.dpdk.org/series/30025/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/133501/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/133501/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 844DD43215;\n\tFri, 27 Oct 2023 13:02:50 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 6D07042E27;\n\tFri, 27 Oct 2023 13:01:47 +0200 (CEST)",
            "from mgamail.intel.com (mgamail.intel.com [192.198.163.8])\n by mails.dpdk.org (Postfix) with ESMTP id 964CB42E10\n for <dev@dpdk.org>; Fri, 27 Oct 2023 13:01:44 +0200 (CEST)",
            "from orsmga004.jf.intel.com ([10.7.209.38])\n by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 27 Oct 2023 04:01:44 -0700",
            "from silpixa00401385.ir.intel.com ([10.237.214.154])\n by orsmga004.jf.intel.com with ESMTP; 27 Oct 2023 04:01:42 -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=1698404505; x=1729940505;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=XcIW41mdP/aND+hYsOeIRwGJJMHt9INJPO52QPeCgiA=;\n b=fZg+WrE9DIqeJnjxY0QRHnwL9un8QKcbGX4qKAjGMJ2eLyxumDU/51X8\n gbTCV7KwqMOVQG26zMNrM0lnJaPuhiz+qh9NMMImJl+NndQ2Tzvhb8w3t\n Zc0L6AYU4E97Z6TyLTiqMGDRkJ6Cs4tuK4aGXHztG4ufkxEftvAr+WqNX\n xtO+lI821xop3OiQYR0jsMcBc8Q3nVQ+6HJXxTMMOBIWm7WtU8dv2CA2n\n evZ+saE62u3nXx8wT1r7YRbcCxfHmSPCIJN1+6rW8CjbWQVtrEWDkr12Y\n ZvGKp+XIcSGAdZmIcZh780qYvtwqS/5oqeS0kAE4CkWfANBMYkpINAQF4 A==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6600,9927,10875\"; a=\"546720\"",
            "E=Sophos;i=\"6.03,256,1694761200\";\n   d=\"scan'208\";a=\"546720\"",
            "E=McAfee;i=\"6600,9927,10875\"; a=\"883157879\"",
            "E=Sophos;i=\"6.03,256,1694761200\"; d=\"scan'208\";a=\"883157879\""
        ],
        "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>",
        "Subject": "[PATCH v7 9/9] examples/ntb: auto-generate cmdline boilerplate",
        "Date": "Fri, 27 Oct 2023 12:01:17 +0100",
        "Message-Id": "<20231027110117.70995-10-bruce.richardson@intel.com>",
        "X-Mailer": "git-send-email 2.39.2",
        "In-Reply-To": "<20231027110117.70995-1-bruce.richardson@intel.com>",
        "References": "<20230802170052.955323-1-bruce.richardson@intel.com>\n <20231027110117.70995-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/ntb/Makefile      |  12 ++-\n examples/ntb/commands.list |  11 ++\n examples/ntb/meson.build   |   7 ++\n examples/ntb/ntb_fwd.c     | 200 ++++---------------------------------\n 4 files changed, 47 insertions(+), 183 deletions(-)\n create mode 100644 examples/ntb/commands.list",
    "diff": "diff --git a/examples/ntb/Makefile b/examples/ntb/Makefile\nindex d9b6e53090..f5b3405c47 100644\n--- a/examples/ntb/Makefile\n+++ b/examples/ntb/Makefile\n@@ -6,6 +6,7 @@ APP = ntb_fwd\n \n # all source are stored in SRCS-y\n SRCS-y := ntb_fwd.c\n+SRC-DEPS := build/commands.h\n \n PKGCONF ?= pkg-config\n \n@@ -25,10 +26,13 @@ CFLAGS += -D_FILE_OFFSET_BITS=64\n LDFLAGS += -pthread\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@@ -39,10 +43,10 @@ endif\n \n CFLAGS += -DALLOW_EXPERIMENTAL_API\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@@ -50,5 +54,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/ntb/commands.list b/examples/ntb/commands.list\nnew file mode 100644\nindex 0000000000..a26b8acfa3\n--- /dev/null\n+++ b/examples/ntb/commands.list\n@@ -0,0 +1,11 @@\n+# SPDX-License-Identifier: BSD-3-Clause\n+# Copyright(c) 2023 Intel Corporation\n+#\n+help                   # show help\n+quit                   # exit application\n+send <STRING>filepath  # send <file_path>\n+start                  # start pkt fwd between ntb and ethdev\n+stop                   # stop packet forwarding\n+show port stats        # show statistics for all ports\n+clear port stats       # clear all port statistics\n+set fwd <(file-trans,iofwd,txonly,rxonly)>mode  # set forwarding mode as file-trans|rxonly|txonly|iofwd\ndiff --git a/examples/ntb/meson.build b/examples/ntb/meson.build\nindex 18eaffdf21..6c23081c41 100644\n--- a/examples/ntb/meson.build\n+++ b/examples/ntb/meson.build\n@@ -17,3 +17,10 @@ cflags += ['-D_FILE_OFFSET_BITS=64']\n sources = files(\n         'ntb_fwd.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\ndiff --git a/examples/ntb/ntb_fwd.c b/examples/ntb/ntb_fwd.c\nindex 585aad9d70..95a6148c82 100644\n--- a/examples/ntb/ntb_fwd.c\n+++ b/examples/ntb/ntb_fwd.c\n@@ -21,6 +21,7 @@\n #include <rte_cycles.h>\n #include <rte_pmd_ntb.h>\n #include <rte_mbuf_pool_ops.h>\n+#include \"commands.h\"\n \n /* Per-port statistics struct */\n struct ntb_port_statistics {\n@@ -103,12 +104,7 @@ static struct rte_eth_conf eth_port_conf = {\n \t},\n };\n \n-/* *** Help command with introduction. *** */\n-struct cmd_help_result {\n-\tcmdline_fixed_string_t help;\n-};\n-\n-static void\n+void\n cmd_help_parsed(__rte_unused void *parsed_result,\n \t\tstruct cmdline *cl,\n \t\t__rte_unused void *data)\n@@ -134,26 +130,7 @@ cmd_help_parsed(__rte_unused void *parsed_result,\n \t);\n \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-/* *** QUIT *** */\n-struct cmd_quit_result {\n-\tcmdline_fixed_string_t quit;\n-};\n-\n-static void\n+void\n cmd_quit_parsed(__rte_unused void *parsed_result,\n \t\tstruct cmdline *cl,\n \t\t__rte_unused void *data)\n@@ -188,31 +165,12 @@ cmd_quit_parsed(__rte_unused void *parsed_result,\n \tcmdline_quit(cl);\n }\n \n-cmdline_parse_token_string_t cmd_quit_quit =\n-\t\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 = \"exit application\",\n-\t.tokens = {\n-\t\t(void *)&cmd_quit_quit,\n-\t\tNULL,\n-\t},\n-};\n-\n-/* *** SEND FILE PARAMETERS *** */\n-struct cmd_sendfile_result {\n-\tcmdline_fixed_string_t send_string;\n-\tchar filepath[];\n-};\n-\n-static void\n-cmd_sendfile_parsed(void *parsed_result,\n+void\n+cmd_send_parsed(void *parsed_result,\n \t\t    __rte_unused struct cmdline *cl,\n \t\t    __rte_unused void *data)\n {\n-\tstruct cmd_sendfile_result *res = parsed_result;\n+\tstruct cmd_send_result *res = parsed_result;\n \tstruct rte_rawdev_buf *pkts_send[NTB_MAX_PKT_BURST];\n \tstruct rte_mbuf *mbuf_send[NTB_MAX_PKT_BURST];\n \tuint64_t size, count, i, j, nb_burst;\n@@ -327,24 +285,6 @@ cmd_sendfile_parsed(void *parsed_result,\n \tfclose(file);\n }\n \n-cmdline_parse_token_string_t cmd_send_file_send =\n-\tTOKEN_STRING_INITIALIZER(struct cmd_sendfile_result, send_string,\n-\t\t\t\t \"send\");\n-cmdline_parse_token_string_t cmd_send_file_filepath =\n-\tTOKEN_STRING_INITIALIZER(struct cmd_sendfile_result, filepath, NULL);\n-\n-\n-cmdline_parse_inst_t cmd_send_file = {\n-\t.f = cmd_sendfile_parsed,\n-\t.data = NULL,\n-\t.help_str = \"send <file_path>\",\n-\t.tokens = {\n-\t\t(void *)&cmd_send_file_send,\n-\t\t(void *)&cmd_send_file_filepath,\n-\t\tNULL,\n-\t},\n-};\n-\n #define RECV_FILE_LEN 30\n static int\n start_polling_recv_file(void *param)\n@@ -788,12 +728,7 @@ start_pkt_fwd(void)\n \t}\n }\n \n-/* *** START FWD PARAMETERS *** */\n-struct cmd_start_result {\n-\tcmdline_fixed_string_t start;\n-};\n-\n-static void\n+void\n cmd_start_parsed(__rte_unused void *parsed_result,\n \t\t\t    __rte_unused struct cmdline *cl,\n \t\t\t    __rte_unused void *data)\n@@ -801,25 +736,7 @@ cmd_start_parsed(__rte_unused void *parsed_result,\n \tstart_pkt_fwd();\n }\n \n-cmdline_parse_token_string_t cmd_start_start =\n-\t\tTOKEN_STRING_INITIALIZER(struct cmd_start_result, start, \"start\");\n-\n-cmdline_parse_inst_t cmd_start = {\n-\t.f = cmd_start_parsed,\n-\t.data = NULL,\n-\t.help_str = \"start pkt fwd between ntb and ethdev\",\n-\t.tokens = {\n-\t\t(void *)&cmd_start_start,\n-\t\tNULL,\n-\t},\n-};\n-\n-/* *** STOP *** */\n-struct cmd_stop_result {\n-\tcmdline_fixed_string_t stop;\n-};\n-\n-static void\n+void\n cmd_stop_parsed(__rte_unused void *parsed_result,\n \t\t__rte_unused struct cmdline *cl,\n \t\t__rte_unused void *data)\n@@ -844,19 +761,6 @@ cmd_stop_parsed(__rte_unused void *parsed_result,\n \tprintf(\"\\nDone.\\n\");\n }\n \n-cmdline_parse_token_string_t cmd_stop_stop =\n-\t\tTOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, \"stop\");\n-\n-cmdline_parse_inst_t cmd_stop = {\n-\t.f = cmd_stop_parsed,\n-\t.data = NULL,\n-\t.help_str = \"stop: Stop packet forwarding\",\n-\t.tokens = {\n-\t\t(void *)&cmd_stop_stop,\n-\t\tNULL,\n-\t},\n-};\n-\n static void\n ntb_stats_clear(void)\n {\n@@ -975,58 +879,28 @@ ntb_stats_display(void)\n \tfree(ids);\n }\n \n-/* *** SHOW/CLEAR PORT STATS *** */\n-struct cmd_stats_result {\n-\tcmdline_fixed_string_t show;\n-\tcmdline_fixed_string_t port;\n-\tcmdline_fixed_string_t stats;\n-};\n-\n-static void\n-cmd_stats_parsed(void *parsed_result,\n+void\n+cmd_show_port_stats_parsed(__rte_unused void *parsed_result,\n \t\t __rte_unused struct cmdline *cl,\n \t\t __rte_unused void *data)\n {\n-\tstruct cmd_stats_result *res = parsed_result;\n-\tif (!strcmp(res->show, \"clear\"))\n-\t\tntb_stats_clear();\n-\telse\n-\t\tntb_stats_display();\n+\tntb_stats_display();\n }\n \n-cmdline_parse_token_string_t cmd_stats_show =\n-\tTOKEN_STRING_INITIALIZER(struct cmd_stats_result, show, \"show#clear\");\n-cmdline_parse_token_string_t cmd_stats_port =\n-\tTOKEN_STRING_INITIALIZER(struct cmd_stats_result, port, \"port\");\n-cmdline_parse_token_string_t cmd_stats_stats =\n-\tTOKEN_STRING_INITIALIZER(struct cmd_stats_result, stats, \"stats\");\n-\n-\n-cmdline_parse_inst_t cmd_stats = {\n-\t.f = cmd_stats_parsed,\n-\t.data = NULL,\n-\t.help_str = \"show|clear port stats\",\n-\t.tokens = {\n-\t\t(void *)&cmd_stats_show,\n-\t\t(void *)&cmd_stats_port,\n-\t\t(void *)&cmd_stats_stats,\n-\t\tNULL,\n-\t},\n-};\n-\n-/* *** SET FORWARDING MODE *** */\n-struct cmd_set_fwd_mode_result {\n-\tcmdline_fixed_string_t set;\n-\tcmdline_fixed_string_t fwd;\n-\tcmdline_fixed_string_t mode;\n-};\n+void\n+cmd_clear_port_stats_parsed(__rte_unused void *parsed_result,\n+\t\t __rte_unused struct cmdline *cl,\n+\t\t __rte_unused void *data)\n+{\n+\tntb_stats_clear();\n+}\n \n-static void\n-cmd_set_fwd_mode_parsed(__rte_unused void *parsed_result,\n+void\n+cmd_set_fwd_parsed(void *parsed_result,\n \t\t\t__rte_unused struct cmdline *cl,\n \t\t\t__rte_unused void *data)\n {\n-\tstruct cmd_set_fwd_mode_result *res = parsed_result;\n+\tstruct cmd_set_fwd_result *res = parsed_result;\n \tint i;\n \n \tif (in_test) {\n@@ -1043,38 +917,6 @@ cmd_set_fwd_mode_parsed(__rte_unused void *parsed_result,\n \tprintf(\"Invalid %s packet forwarding mode.\\n\", res->mode);\n }\n \n-cmdline_parse_token_string_t cmd_setfwd_set =\n-\tTOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, \"set\");\n-cmdline_parse_token_string_t cmd_setfwd_fwd =\n-\tTOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, \"fwd\");\n-cmdline_parse_token_string_t cmd_setfwd_mode =\n-\tTOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,\n-\t\t\t\t\"file-trans#iofwd#txonly#rxonly\");\n-\n-cmdline_parse_inst_t cmd_set_fwd_mode = {\n-\t.f = cmd_set_fwd_mode_parsed,\n-\t.data = NULL,\n-\t.help_str = \"set forwarding mode as file-trans|rxonly|txonly|iofwd\",\n-\t.tokens = {\n-\t\t(void *)&cmd_setfwd_set,\n-\t\t(void *)&cmd_setfwd_fwd,\n-\t\t(void *)&cmd_setfwd_mode,\n-\t\tNULL,\n-\t},\n-};\n-\n-/* list of instructions */\n-cmdline_parse_ctx_t main_ctx[] = {\n-\t(cmdline_parse_inst_t *)&cmd_help,\n-\t(cmdline_parse_inst_t *)&cmd_send_file,\n-\t(cmdline_parse_inst_t *)&cmd_start,\n-\t(cmdline_parse_inst_t *)&cmd_stop,\n-\t(cmdline_parse_inst_t *)&cmd_stats,\n-\t(cmdline_parse_inst_t *)&cmd_set_fwd_mode,\n-\t(cmdline_parse_inst_t *)&cmd_quit,\n-\tNULL,\n-};\n-\n /* prompt function, called from main on MAIN lcore */\n static void\n prompt(void)\n",
    "prefixes": [
        "v7",
        "9/9"
    ]
}