get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 131640,
    "url": "https://patches.dpdk.org/api/patches/131640/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20230919160455.1678716-1-skori@marvell.com/",
    "project": {
        "id": 1,
        "url": "https://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": "<20230919160455.1678716-1-skori@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230919160455.1678716-1-skori@marvell.com",
    "date": "2023-09-19T16:04:42",
    "name": "[v4,01/14] app/graph: add application framework to read CLI",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "095d7dc723b074fcd52fc763fabb96a2b9288203",
    "submitter": {
        "id": 1318,
        "url": "https://patches.dpdk.org/api/people/1318/?format=api",
        "name": "Sunil Kumar Kori",
        "email": "skori@marvell.com"
    },
    "delegate": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20230919160455.1678716-1-skori@marvell.com/mbox/",
    "series": [
        {
            "id": 29557,
            "url": "https://patches.dpdk.org/api/series/29557/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=29557",
            "date": "2023-09-19T16:04:42",
            "name": "[v4,01/14] app/graph: add application framework to read CLI",
            "version": 4,
            "mbox": "https://patches.dpdk.org/series/29557/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/131640/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/131640/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 6DB484260C;\n\tTue, 19 Sep 2023 18:05:22 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 4EBD640633;\n\tTue, 19 Sep 2023 18:05:22 +0200 (CEST)",
            "from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com\n [67.231.148.174])\n by mails.dpdk.org (Postfix) with ESMTP id B946940277\n for <dev@dpdk.org>; Tue, 19 Sep 2023 18:05:20 +0200 (CEST)",
            "from pps.filterd (m0045849.ppops.net [127.0.0.1])\n by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id\n 38JDa02F012050 for <dev@dpdk.org>; Tue, 19 Sep 2023 09:05:19 -0700",
            "from dc5-exch02.marvell.com ([199.233.59.182])\n by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3t7cnq0p6d-2\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT)\n for <dev@dpdk.org>; Tue, 19 Sep 2023 09:05:19 -0700",
            "from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com\n (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48;\n Tue, 19 Sep 2023 09:05:03 -0700",
            "from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com\n (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend\n Transport; Tue, 19 Sep 2023 09:05:03 -0700",
            "from localhost.localdomain (unknown [10.28.34.25])\n by maili.marvell.com (Postfix) with ESMTP id 8A90D3F709C;\n Tue, 19 Sep 2023 09:05:02 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;\n h=from : to : cc :\n subject : date : message-id : in-reply-to : references : mime-version :\n content-transfer-encoding : content-type; s=pfpt0220;\n bh=OSLmPwg4OV3ct4eK898u7lgWwEQyUgSlJ1Ohoveuxqw=;\n b=fmNeYyXcBQEaC3K/9+75n2xpeApuwgLe1YBdJ+MTNN5IEwxRgAZ+iDCay3S06AbMMjDv\n yi7Uf7fVcfkWMDlmupqfIXwehQjAfclJ/9ttL6zyhC8nvQKgiWizeRaNVQ5a/hpqxX3O\n zJlspGBq6EJXa8bKQjG0HPFR7CbTeFJBifUoM8pT7IeWClHAuE5E5lAVTgM3p/LAEqfA\n PSRJ0+I40k27duYkkDDWQS56NiLspnnLaL1Nwq3Qa3JE4l44x7eV8nRW2fSiDQCHhflw\n /7ymqreDc8LyqDFjjN9In42ATo4aap2u9FP+eReiLxJc08xGIThqwgcvj8iqc9cv14oD aA==",
        "From": "<skori@marvell.com>",
        "To": "Sunil Kumar Kori <skori@marvell.com>, Rakesh Kudurumalla\n <rkudurumalla@marvell.com>",
        "CC": "<dev@dpdk.org>",
        "Subject": "[PATCH v4 01/14] app/graph: add application framework to read CLI",
        "Date": "Tue, 19 Sep 2023 21:34:42 +0530",
        "Message-ID": "<20230919160455.1678716-1-skori@marvell.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20230908104907.4060511-1-skori@marvell.com>",
        "References": "<20230908104907.4060511-1-skori@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Proofpoint-ORIG-GUID": "eVV4-b7gdD0Tl5CFnuO8pVz3JEZDJPPc",
        "X-Proofpoint-GUID": "eVV4-b7gdD0Tl5CFnuO8pVz3JEZDJPPc",
        "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26\n definitions=2023-09-19_07,2023-09-19_01,2023-05-22_02",
        "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": "From: Sunil Kumar Kori <skori@marvell.com>\n\nIt adds base framework to read a given .cli file as a command line\nparameter \"-s\".\n\nExample:\n # ./dpdk-graph -c 0xff -- -s ./app/graph/examples/dummy.cli\n\nEach .cli file will contain commands to configure different module like\nmempool, ethdev, lookup tables, graph etc. Command parsing is backed by\ncommandline library.\n\nEach module needs to expose its supported commands & corresponding\ncallback functions to commandline library to get them parsed.\n\nSigned-off-by: Sunil Kumar Kori <skori@marvell.com>\nSigned-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>\n---\nv3..v4:\n - Addressed Nithin's review comments\n\n app/graph/cli.c        | 113 ++++++++++++++++++++++++++++++++++++\n app/graph/cli.h        |  32 +++++++++++\n app/graph/main.c       | 127 +++++++++++++++++++++++++++++++++++++++++\n app/graph/meson.build  |  14 +++++\n app/graph/module_api.h |  16 ++++++\n app/meson.build        |   1 +\n 6 files changed, 303 insertions(+)\n create mode 100644 app/graph/cli.c\n create mode 100644 app/graph/cli.h\n create mode 100644 app/graph/main.c\n create mode 100644 app/graph/meson.build\n create mode 100644 app/graph/module_api.h",
    "diff": "diff --git a/app/graph/cli.c b/app/graph/cli.c\nnew file mode 100644\nindex 0000000000..473fa1635a\n--- /dev/null\n+++ b/app/graph/cli.c\n@@ -0,0 +1,113 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2023 Marvell.\n+ */\n+\n+#include <errno.h>\n+#include <stdio.h>\n+#include <stdint.h>\n+#include <stdlib.h>\n+#include <string.h>\n+\n+#include <cmdline_parse.h>\n+#include <cmdline_parse_num.h>\n+#include <cmdline_parse_string.h>\n+#include <cmdline_socket.h>\n+#include <rte_common.h>\n+\n+#include \"module_api.h\"\n+\n+#define CMD_MAX_TOKENS 256\n+#define MAX_LINE_SIZE 2048\n+\n+cmdline_parse_ctx_t modules_ctx[] = {\n+\tNULL,\n+};\n+\n+static struct cmdline *cl;\n+\n+static int\n+is_comment(char *in)\n+{\n+\tif ((strlen(in) && index(\"!#%;\", in[0])) ||\n+\t\t(strncmp(in, \"//\", 2) == 0) ||\n+\t\t(strncmp(in, \"--\", 2) == 0))\n+\t\treturn 1;\n+\n+\treturn 0;\n+}\n+\n+void\n+cli_init(void)\n+{\n+\tcl = cmdline_stdin_new(modules_ctx, \"\");\n+}\n+\n+void\n+cli_exit(void)\n+{\n+\tcmdline_stdin_exit(cl);\n+}\n+\n+void\n+cli_process(char *in, char *out, size_t out_size, __rte_unused void *obj)\n+{\n+\tint rc;\n+\n+\tif (is_comment(in))\n+\t\treturn;\n+\n+\trc = cmdline_parse(cl, in);\n+\tif (rc == CMDLINE_PARSE_AMBIGUOUS)\n+\t\tsnprintf(out, out_size, MSG_CMD_FAIL, \"Ambiguous command\");\n+\telse if (rc == CMDLINE_PARSE_NOMATCH)\n+\t\tsnprintf(out, out_size, MSG_CMD_FAIL, \"Command mismatch\");\n+\telse if (rc == CMDLINE_PARSE_BAD_ARGS)\n+\t\tsnprintf(out, out_size, MSG_CMD_FAIL, \"Bad arguments\");\n+\n+\treturn;\n+\n+}\n+\n+int\n+cli_script_process(const char *file_name, size_t msg_in_len_max, size_t msg_out_len_max, void *obj)\n+{\n+\tchar *msg_in = NULL, *msg_out = NULL;\n+\tFILE *f = NULL;\n+\n+\t/* Check input arguments */\n+\tif ((file_name == NULL) || (strlen(file_name) == 0) || (msg_in_len_max == 0) ||\n+\t    (msg_out_len_max == 0))\n+\t\treturn -EINVAL;\n+\n+\tmsg_in = malloc(msg_in_len_max + 1);\n+\tmsg_out = malloc(msg_out_len_max + 1);\n+\tif ((msg_in == NULL) || (msg_out == NULL)) {\n+\t\tfree(msg_out);\n+\t\tfree(msg_in);\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\t/* Open input file */\n+\tf = fopen(file_name, \"r\");\n+\tif (f == NULL) {\n+\t\tfree(msg_out);\n+\t\tfree(msg_in);\n+\t\treturn -EIO;\n+\t}\n+\n+\t/* Read file */\n+\twhile (fgets(msg_in, msg_in_len_max, f) != NULL) {\n+\t\tmsg_out[0] = 0;\n+\n+\t\tcli_process(msg_in, msg_out, msg_out_len_max, obj);\n+\n+\t\tif (strlen(msg_out))\n+\t\t\tprintf(\"%s\", msg_out);\n+\t}\n+\n+\t/* Close file */\n+\tfclose(f);\n+\tfree(msg_out);\n+\tfree(msg_in);\n+\treturn 0;\n+}\ndiff --git a/app/graph/cli.h b/app/graph/cli.h\nnew file mode 100644\nindex 0000000000..652f948352\n--- /dev/null\n+++ b/app/graph/cli.h\n@@ -0,0 +1,32 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2023 Marvell.\n+ */\n+\n+#ifndef APP_GRAPH_CLI_H\n+#define APP_GRAPH_CLI_H\n+\n+/* Macros */\n+#define MSG_OUT_OF_MEMORY   \"Not enough memory.\\n\"\n+#define MSG_CMD_UNKNOWN     \"Unknown command \\\"%s\\\".\\n\"\n+#define MSG_CMD_UNIMPLEM    \"Command \\\"%s\\\" not implemented.\\n\"\n+#define MSG_ARG_NOT_ENOUGH  \"Not enough arguments for command \\\"%s\\\".\\n\"\n+#define MSG_ARG_TOO_MANY    \"Too many arguments for command \\\"%s\\\".\\n\"\n+#define MSG_ARG_MISMATCH    \"Wrong number of arguments for command \\\"%s\\\".\\n\"\n+#define MSG_ARG_NOT_FOUND   \"Argument \\\"%s\\\" not found.\\n\"\n+#define MSG_ARG_INVALID     \"Invalid value for argument \\\"%s\\\".\\n\"\n+#define MSG_FILE_ERR        \"Error in file \\\"%s\\\" at line %u.\\n\"\n+#define MSG_FILE_NOT_ENOUGH \"Not enough rules in file \\\"%s\\\".\\n\"\n+#define MSG_CMD_FAIL        \"Command \\\"%s\\\" failed.\\n\"\n+\n+#define APP_CLI_CMD_NAME_SIZE\t64\n+\n+void cli_init(void);\n+\n+void cli_exit(void);\n+\n+void cli_process(char *in, char *out, size_t out_size, void *arg);\n+\n+int cli_script_process(const char *file_name, size_t msg_in_len_max, size_t msg_out_len_max,\n+\t\t       void *arg);\n+\n+#endif\ndiff --git a/app/graph/main.c b/app/graph/main.c\nnew file mode 100644\nindex 0000000000..a4af1ec7e1\n--- /dev/null\n+++ b/app/graph/main.c\n@@ -0,0 +1,127 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2023 Marvell.\n+ */\n+\n+#include <fcntl.h>\n+#include <getopt.h>\n+#include <signal.h>\n+#include <stdio.h>\n+#include <stdlib.h>\n+#include <string.h>\n+#include <unistd.h>\n+\n+#include <rte_eal.h>\n+#include <rte_launch.h>\n+\n+#include \"module_api.h\"\n+\n+volatile bool force_quit;\n+\n+static const char usage[] = \"%s EAL_ARGS -- -s SCRIPT \"\n+\t\t\t    \"[--help]\\n\";\n+\n+static struct app_params {\n+\tchar *script_name;\n+} app = {\n+\t.script_name = NULL,\n+};\n+\n+static void\n+signal_handler(int signum)\n+{\n+\tif (signum == SIGINT || signum == SIGTERM) {\n+\t\tprintf(\"\\n\\nSignal %d received, preparing to exit...\\n\", signum);\n+\t\tforce_quit = true;\n+\t}\n+}\n+\n+static int\n+app_args_parse(int argc, char **argv)\n+{\n+\tstruct option lgopts[] = {\n+\t\t{\"help\", 0, 0, 'H'},\n+\t};\n+\tint s_present, n_args, i;\n+\tchar *app_name = argv[0];\n+\tint opt, option_index;\n+\n+\t/* Skip EAL input args */\n+\tn_args = argc;\n+\tfor (i = 0; i < n_args; i++)\n+\t\tif (strcmp(argv[i], \"--\") == 0) {\n+\t\t\targc -= i;\n+\t\t\targv += i;\n+\t\t\tbreak;\n+\t\t}\n+\n+\tif (i == n_args)\n+\t\treturn 0;\n+\n+\t/* Parse args */\n+\ts_present = 0;\n+\n+\twhile ((opt = getopt_long(argc, argv, \"s:\", lgopts, &option_index)) != EOF) {\n+\t\tswitch (opt) {\n+\t\tcase 's':\n+\t\t\tif (s_present) {\n+\t\t\t\tprintf(\"Error: Multiple -s arguments\\n\");\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\ts_present = 1;\n+\n+\t\t\tif (!strlen(optarg)) {\n+\t\t\t\tprintf(\"Error: Argument for -s not provided\\n\");\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\n+\t\t\tapp.script_name = strdup(optarg);\n+\t\t\tif (app.script_name == NULL) {\n+\t\t\t\tprintf(\"Error: Not enough memory\\n\");\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tbreak;\n+\n+\t\tcase 'H':\n+\t\tdefault:\n+\t\t\tprintf(usage, app_name);\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\toptind = 1; /* reset getopt lib */\n+\n+\treturn 0;\n+}\n+\n+int\n+main(int argc, char **argv)\n+{\n+\tint rc;\n+\n+\t/* Parse application arguments */\n+\trc = app_args_parse(argc, argv);\n+\tif (rc < 0)\n+\t\treturn rc;\n+\n+\t/* EAL */\n+\trc = rte_eal_init(argc, argv);\n+\tif (rc < 0) {\n+\t\tprintf(\"Error: EAL initialization failed (%d)\\n\", rc);\n+\t\treturn rc;\n+\t};\n+\n+\tforce_quit = false;\n+\tsignal(SIGINT, signal_handler);\n+\tsignal(SIGTERM, signal_handler);\n+\n+\tcli_init();\n+\n+\t/* Script */\n+\tif (app.script_name) {\n+\t\tcli_script_process(app.script_name, 0,\n+\t\t\t0, NULL);\n+\t}\n+\n+\tcli_exit();\n+\trte_eal_cleanup();\n+\treturn 0;\n+}\n\\ No newline at end of file\ndiff --git a/app/graph/meson.build b/app/graph/meson.build\nnew file mode 100644\nindex 0000000000..87c4ce30a8\n--- /dev/null\n+++ b/app/graph/meson.build\n@@ -0,0 +1,14 @@\n+# SPDX-License-Identifier: BSD-3-Clause\n+# Copyright(c) 2023 Marvell.\n+\n+# override default name to drop the hyphen\n+name = 'graph'\n+if not build\n+    subdir_done()\n+endif\n+\n+deps += ['bus_pci', 'graph', 'eal', 'lpm', 'ethdev', 'node', 'cmdline']\n+sources = files(\n+        'cli.c',\n+        'main.c',\n+)\ndiff --git a/app/graph/module_api.h b/app/graph/module_api.h\nnew file mode 100644\nindex 0000000000..372aeae7e3\n--- /dev/null\n+++ b/app/graph/module_api.h\n@@ -0,0 +1,16 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2023 Marvell.\n+ */\n+\n+#ifndef APP_GRAPH_MODULE_API_H\n+#define APP_GRAPH_MODULE_API_H\n+\n+#include <stdint.h>\n+#include <stdbool.h>\n+#include \"cli.h\"\n+/*\n+ * Externs\n+ */\n+extern volatile bool force_quit;\n+\n+#endif\ndiff --git a/app/meson.build b/app/meson.build\nindex e4bf5c531c..728c936383 100644\n--- a/app/meson.build\n+++ b/app/meson.build\n@@ -17,6 +17,7 @@ endif\n apps = [\n         'dumpcap',\n         'pdump',\n+        'graph',\n         'proc-info',\n         'test-acl',\n         'test-bbdev',\n",
    "prefixes": [
        "v4",
        "01/14"
    ]
}