get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 131769,
    "url": "https://patches.dpdk.org/api/patches/131769/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20230921100832.2036256-7-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": "<20230921100832.2036256-7-skori@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230921100832.2036256-7-skori@marvell.com",
    "date": "2023-09-21T10:08:26",
    "name": "[v5,06/12] app/graph: add ipv4_lookup command line interfaces",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "4615f90afd06fc794da07a486a9f663d95af2a32",
    "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/20230921100832.2036256-7-skori@marvell.com/mbox/",
    "series": [
        {
            "id": 29586,
            "url": "https://patches.dpdk.org/api/series/29586/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=29586",
            "date": "2023-09-21T10:08:20",
            "name": "add CLI based graph application",
            "version": 5,
            "mbox": "https://patches.dpdk.org/series/29586/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/131769/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/131769/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 67350425CD;\n\tThu, 21 Sep 2023 12:09:28 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id D67DB40DDE;\n\tThu, 21 Sep 2023 12:08:55 +0200 (CEST)",
            "from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com\n [67.231.156.173])\n by mails.dpdk.org (Postfix) with ESMTP id A1B8940DC9\n for <dev@dpdk.org>; Thu, 21 Sep 2023 12:08:52 +0200 (CEST)",
            "from pps.filterd (m0045851.ppops.net [127.0.0.1])\n by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id\n 38L7PKvP008644 for <dev@dpdk.org>; Thu, 21 Sep 2023 03:08:52 -0700",
            "from dc5-exch01.marvell.com ([199.233.59.181])\n by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3t85pttqe0-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT)\n for <dev@dpdk.org>; Thu, 21 Sep 2023 03:08:51 -0700",
            "from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com\n (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48;\n Thu, 21 Sep 2023 03:08:49 -0700",
            "from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com\n (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend\n Transport; Thu, 21 Sep 2023 03:08:49 -0700",
            "from localhost.localdomain (unknown [10.28.34.25])\n by maili.marvell.com (Postfix) with ESMTP id 86E045B693B;\n Thu, 21 Sep 2023 03:08:48 -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=rCsDtPR7yi2x91gxyX6nIUQ/HzAGoZAKkinPta3pKCM=;\n b=Q5EY0ZfoY9TlBOPfTf6sMnUprYqZn9mu5p0a5/cTBkE16o383l8w+trKoTKFm1/kJw0b\n sctxd2ViEioa5ns2bR6hVS+Z9Gwo3ylIBSGU6Cc9Lie/oE3s7O96Ge70OTT9VawDsGz4\n gjGNDSMb8S3VygAaUXzTUkJQ9d8PoocN/fJ8KSa8eXmhGSJL3ewkA+CWwPtqauYBwtym\n lpOTp6MzuOGKlKu9DcJHdUFmVlh9pTvk7mKR87f6lmQzbh9XRJRzM0Ly6bSlX3IhDqPP\n jpZTjNFPA49EGNLbPNDvQvlwmnP9arlsdrRzF9rBV5I2kgy8H2vxKFtOIMiLVopFh3UM Nw==",
        "From": "<skori@marvell.com>",
        "To": "Sunil Kumar Kori <skori@marvell.com>, Rakesh Kudurumalla\n <rkudurumalla@marvell.com>",
        "CC": "<dev@dpdk.org>",
        "Subject": "[PATCH v5 06/12] app/graph: add ipv4_lookup command line interfaces",
        "Date": "Thu, 21 Sep 2023 15:38:26 +0530",
        "Message-ID": "<20230921100832.2036256-7-skori@marvell.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20230921100832.2036256-1-skori@marvell.com>",
        "References": "<20230919160455.1678716-1-skori@marvell.com>\n <20230921100832.2036256-1-skori@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Proofpoint-GUID": "z_8KexZGV_YU9yQjZBPRfeLPGp5JheMn",
        "X-Proofpoint-ORIG-GUID": "z_8KexZGV_YU9yQjZBPRfeLPGp5JheMn",
        "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-21_06,2023-09-20_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 ipv4_lookup module to configure LPM table. This LPM table\nwill be used for IPv4 lookup and forwarding.\n\nFollowing commands are exposed:\n - ipv4_lookup route add ipv4 <ip> netmask <mask> via <ip>\n - help ipv4_lookup\n\nSigned-off-by: Sunil Kumar Kori <skori@marvell.com>\nSigned-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>\n---\n app/graph/cli.c            |   2 +\n app/graph/ethdev.c         |   2 +-\n app/graph/ip4_route.c      | 205 +++++++++++++++++++++++++++++++++++++\n app/graph/meson.build      |   1 +\n app/graph/module_api.h     |   1 +\n app/graph/route.h          |  26 +++++\n app/graph/route_priv.h     |  44 ++++++++\n doc/guides/tools/graph.rst |   9 ++\n 8 files changed, 289 insertions(+), 1 deletion(-)\n create mode 100644 app/graph/ip4_route.c\n create mode 100644 app/graph/route.h\n create mode 100644 app/graph/route_priv.h",
    "diff": "diff --git a/app/graph/cli.c b/app/graph/cli.c\nindex c4b5cf3ce1..430750db6e 100644\n--- a/app/graph/cli.c\n+++ b/app/graph/cli.c\n@@ -30,6 +30,8 @@ cmdline_parse_ctx_t modules_ctx[] = {\n \t(cmdline_parse_inst_t *)&ethdev_ip6_cmd_ctx,\n \t(cmdline_parse_inst_t *)&ethdev_cmd_ctx,\n \t(cmdline_parse_inst_t *)&ethdev_help_cmd_ctx,\n+\t(cmdline_parse_inst_t *)&ipv4_lookup_cmd_ctx,\n+\t(cmdline_parse_inst_t *)&ipv4_lookup_help_cmd_ctx,\n \tNULL,\n };\n \ndiff --git a/app/graph/ethdev.c b/app/graph/ethdev.c\nindex 81ad8c4757..cb29c9054d 100644\n--- a/app/graph/ethdev.c\n+++ b/app/graph/ethdev.c\n@@ -160,7 +160,7 @@ ethdev_stop(void)\n \t}\n \n \tethdev_list_clean();\n-\trte_eal_cleanup();\n+\troute_ip4_list_clean();\n \tprintf(\"Bye...\\n\");\n }\n \ndiff --git a/app/graph/ip4_route.c b/app/graph/ip4_route.c\nnew file mode 100644\nindex 0000000000..a8fb8ba8d5\n--- /dev/null\n+++ b/app/graph/ip4_route.c\n@@ -0,0 +1,205 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2023 Marvell.\n+ */\n+\n+#include <stdio.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_node_ip4_api.h>\n+\n+#include \"module_api.h\"\n+#include \"route_priv.h\"\n+\n+static const char\n+cmd_ipv4_lookup_help[] = \"ipv4_lookup route add ipv4 <ip> netmask <mask> via <ip>\";\n+\n+struct ip4_route route4 = TAILQ_HEAD_INITIALIZER(route4);\n+\n+\n+void\n+route_ip4_list_clean(void)\n+{\n+\tstruct route_ipv4_config *route;\n+\n+\twhile (!TAILQ_EMPTY(&route4)) {\n+\t\troute = TAILQ_FIRST(&route4);\n+\t\tTAILQ_REMOVE(&route4, route, next);\n+\t}\n+}\n+\n+static struct route_ipv4_config *\n+find_route4_entry(struct route_ipv4_config *route)\n+{\n+\tstruct route_ipv4_config *ipv4route;\n+\n+\tTAILQ_FOREACH(ipv4route, &route4, next) {\n+\t\tif (!memcmp(ipv4route, route, sizeof(*route)))\n+\t\t\treturn ipv4route;\n+\t}\n+\treturn NULL;\n+\n+}\n+\n+static uint8_t\n+convert_netmask_to_depth(uint32_t netmask)\n+{\n+\tuint8_t zerobits = 0;\n+\n+\twhile ((netmask & 0x1) == 0) {\n+\t\tnetmask = netmask >> 1;\n+\t\tzerobits++;\n+\t}\n+\n+\treturn (32 - zerobits);\n+}\n+\n+static int\n+route_ip4_add(struct route_ipv4_config *route)\n+{\n+\tstruct route_ipv4_config *ipv4route;\n+\n+\tipv4route = find_route4_entry(route);\n+\n+\tif (!ipv4route) {\n+\t\tipv4route = malloc(sizeof(struct route_ipv4_config));\n+\t\tif (!ipv4route)\n+\t\t\treturn -ENOMEM;\n+\t} else {\n+\t\treturn 0;\n+\t}\n+\n+\tipv4route->ip = route->ip;\n+\tipv4route->netmask = route->netmask;\n+\tipv4route->via = route->via;\n+\tipv4route->is_used = true;\n+\n+\tTAILQ_INSERT_TAIL(&route4, ipv4route, next);\n+\treturn 0;\n+}\n+\n+int\n+route_ip4_add_to_lookup(void)\n+{\n+\tstruct route_ipv4_config *route = NULL;\n+\tint rc = -EINVAL;\n+\tuint8_t depth;\n+\tint portid;\n+\n+\tTAILQ_FOREACH(route, &route4, next) {\n+\t\tportid = ethdev_portid_by_ip4(route->via, route->netmask);\n+\t\tif (portid < 0) {\n+\t\t\tprintf(\"Invalid portid found to install the route\\n\");\n+\t\t\treturn rc;\n+\t\t}\n+\n+\t\tdepth = convert_netmask_to_depth(route->netmask);\n+\n+\t\trc = rte_node_ip4_route_add(route->ip, depth, portid,\n+\t\t\t\tRTE_NODE_IP4_LOOKUP_NEXT_REWRITE);\n+\t\tif (rc < 0)\n+\t\t\treturn rc;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static void\n+cli_ipv4_lookup_help(__rte_unused void *parsed_result, __rte_unused struct cmdline *cl,\n+\t\t     __rte_unused void *data)\n+{\n+\tsize_t len;\n+\n+\tlen = strlen(conn->msg_out);\n+\tconn->msg_out += len;\n+\tsnprintf(conn->msg_out, conn->msg_out_len_max, \"\\n%s\\n%s\\n\",\n+\t\t \"--------------------------- ipv4_lookup command help ---------------------------\",\n+\t\t cmd_ipv4_lookup_help);\n+\n+\tlen = strlen(conn->msg_out);\n+\tconn->msg_out_len_max -= len;\n+}\n+\n+static void\n+cli_ipv4_lookup(void *parsed_result, __rte_unused struct cmdline *cl, void *data __rte_unused)\n+{\n+\tstruct ip4_lookup_cmd_tokens *res = parsed_result;\n+\tstruct route_ipv4_config config;\n+\tint rc = -EINVAL;\n+\n+\tif (parser_ip4_read(&config.ip, res->ip)) {\n+\t\tprintf(MSG_ARG_INVALID, \"ipv4\");\n+\t\treturn;\n+\t}\n+\n+\tif (parser_ip4_read(&config.netmask, res->mask)) {\n+\t\tprintf(MSG_ARG_INVALID, \"netmask\");\n+\t\treturn;\n+\t}\n+\n+\tif (parser_ip4_read(&config.via, res->via_ip)) {\n+\t\tprintf(MSG_ARG_INVALID, \"via ip\");\n+\t\treturn;\n+\t}\n+\n+\trc = route_ip4_add(&config);\n+\tif (rc < 0)\n+\t\tprintf(MSG_CMD_FAIL, res->cmd);\n+}\n+\n+cmdline_parse_token_string_t ip4_lookup_cmd =\n+\tTOKEN_STRING_INITIALIZER(struct ip4_lookup_cmd_tokens, cmd, \"ipv4_lookup\");\n+cmdline_parse_token_string_t ip4_lookup_route =\n+\tTOKEN_STRING_INITIALIZER(struct ip4_lookup_cmd_tokens, route, \"route\");\n+cmdline_parse_token_string_t ip4_lookup_add =\n+\tTOKEN_STRING_INITIALIZER(struct ip4_lookup_cmd_tokens, add, \"add\");\n+cmdline_parse_token_string_t ip4_lookup_ip4 =\n+\tTOKEN_STRING_INITIALIZER(struct ip4_lookup_cmd_tokens, ip4, \"ipv4\");\n+cmdline_parse_token_string_t ip4_lookup_ip =\n+\tTOKEN_STRING_INITIALIZER(struct ip4_lookup_cmd_tokens, ip, NULL);\n+cmdline_parse_token_string_t ip4_lookup_netmask =\n+\tTOKEN_STRING_INITIALIZER(struct ip4_lookup_cmd_tokens, netmask, \"netmask\");\n+cmdline_parse_token_string_t ip4_lookup_mask =\n+\tTOKEN_STRING_INITIALIZER(struct ip4_lookup_cmd_tokens, mask, NULL);\n+cmdline_parse_token_string_t ip4_lookup_via =\n+\tTOKEN_STRING_INITIALIZER(struct ip4_lookup_cmd_tokens, via, \"via\");\n+cmdline_parse_token_string_t ip4_lookup_via_ip =\n+\tTOKEN_STRING_INITIALIZER(struct ip4_lookup_cmd_tokens, via_ip, NULL);\n+\n+cmdline_parse_inst_t ipv4_lookup_cmd_ctx = {\n+\t.f = cli_ipv4_lookup,\n+\t.data = NULL,\n+\t.help_str = cmd_ipv4_lookup_help,\n+\t.tokens = {\n+\t\t(void *)&ip4_lookup_cmd,\n+\t\t(void *)&ip4_lookup_route,\n+\t\t(void *)&ip4_lookup_add,\n+\t\t(void *)&ip4_lookup_ip4,\n+\t\t(void *)&ip4_lookup_ip,\n+\t\t(void *)&ip4_lookup_netmask,\n+\t\t(void *)&ip4_lookup_mask,\n+\t\t(void *)&ip4_lookup_via,\n+\t\t(void *)&ip4_lookup_via_ip,\n+\t\tNULL,\n+\t},\n+};\n+\n+cmdline_parse_token_string_t ipv4_lookup_help_cmd =\n+\tTOKEN_STRING_INITIALIZER(struct ipv4_lookup_help_cmd_tokens, cmd, \"help\");\n+cmdline_parse_token_string_t ipv4_lookup_help_module =\n+\tTOKEN_STRING_INITIALIZER(struct ipv4_lookup_help_cmd_tokens, module, \"ipv4_lookup\");\n+\n+cmdline_parse_inst_t ipv4_lookup_help_cmd_ctx = {\n+\t.f = cli_ipv4_lookup_help,\n+\t.data = NULL,\n+\t.help_str = \"\",\n+\t.tokens = {\n+\t\t(void *)&ipv4_lookup_help_cmd,\n+\t\t(void *)&ipv4_lookup_help_module,\n+\t\tNULL,\n+\t},\n+};\ndiff --git a/app/graph/meson.build b/app/graph/meson.build\nindex d0369f1c09..b993d6375f 100644\n--- a/app/graph/meson.build\n+++ b/app/graph/meson.build\n@@ -12,6 +12,7 @@ sources = files(\n         'cli.c',\n         'conn.c',\n         'ethdev.c',\n+        'ip4_route.c',\n         'main.c',\n         'mempool.c',\n         'utils.c',\ndiff --git a/app/graph/module_api.h b/app/graph/module_api.h\nindex d509f38837..da049a1faa 100644\n--- a/app/graph/module_api.h\n+++ b/app/graph/module_api.h\n@@ -12,6 +12,7 @@\n #include \"conn.h\"\n #include \"ethdev.h\"\n #include \"mempool.h\"\n+#include \"route.h\"\n #include \"utils.h\"\n /*\n  * Externs\ndiff --git a/app/graph/route.h b/app/graph/route.h\nnew file mode 100644\nindex 0000000000..a44d401d55\n--- /dev/null\n+++ b/app/graph/route.h\n@@ -0,0 +1,26 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2023 Marvell.\n+ */\n+\n+#ifndef APP_GRAPH_ROUTE_H\n+#define APP_GRAPH_ROUTE_H\n+\n+#define MAX_ROUTE_ENTRIES 32\n+\n+extern cmdline_parse_inst_t ipv4_lookup_cmd_ctx;\n+extern cmdline_parse_inst_t ipv4_lookup_help_cmd_ctx;\n+\n+struct route_ipv4_config {\n+\tTAILQ_ENTRY(route_ipv4_config) next;\n+\tuint32_t ip;\n+\tuint32_t netmask;\n+\tuint32_t via;\n+\tbool is_used;\n+};\n+\n+TAILQ_HEAD(ip4_route, route_ipv4_config);\n+\n+int route_ip4_add_to_lookup(void);\n+void route_ip4_list_clean(void);\n+\n+#endif\ndiff --git a/app/graph/route_priv.h b/app/graph/route_priv.h\nnew file mode 100644\nindex 0000000000..f363a551a9\n--- /dev/null\n+++ b/app/graph/route_priv.h\n@@ -0,0 +1,44 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2023 Marvell.\n+ */\n+\n+#ifndef APP_GRAPH_ROUTE_PRIV_H\n+#define APP_GRAPH_ROUTE_PRIV_H\n+\n+#define MAX_ROUTE_ENTRIES 32\n+\n+struct ip4_lookup_cmd_tokens {\n+\tcmdline_fixed_string_t cmd;\n+\tcmdline_fixed_string_t route;\n+\tcmdline_fixed_string_t add;\n+\tcmdline_fixed_string_t ip4;\n+\tcmdline_fixed_string_t ip;\n+\tcmdline_fixed_string_t netmask;\n+\tcmdline_fixed_string_t mask;\n+\tcmdline_fixed_string_t via;\n+\tcmdline_fixed_string_t via_ip;\n+};\n+\n+struct ip6_lookup_cmd_tokens {\n+\tcmdline_fixed_string_t cmd;\n+\tcmdline_fixed_string_t route;\n+\tcmdline_fixed_string_t add;\n+\tcmdline_fixed_string_t ip6;\n+\tcmdline_fixed_string_t ip;\n+\tcmdline_fixed_string_t netmask;\n+\tcmdline_fixed_string_t mask;\n+\tcmdline_fixed_string_t via;\n+\tcmdline_fixed_string_t via_ip;\n+};\n+\n+struct ipv4_lookup_help_cmd_tokens {\n+\tcmdline_fixed_string_t cmd;\n+\tcmdline_fixed_string_t module;\n+};\n+\n+struct ipv6_lookup_help_cmd_tokens {\n+\tcmdline_fixed_string_t cmd;\n+\tcmdline_fixed_string_t module;\n+};\n+\n+#endif\ndiff --git a/doc/guides/tools/graph.rst b/doc/guides/tools/graph.rst\nindex 09416a32ce..e2b4a3dfd5 100644\n--- a/doc/guides/tools/graph.rst\n+++ b/doc/guides/tools/graph.rst\n@@ -124,6 +124,15 @@ file to express the requested use case configuration.\n      - Command to dump ethdev help message\n      - Yes\n      - Yes\n+   * - ipv4_lookup route add ipv4 <ip> netmask <mask> via <ip>\n+     - Command to add a route into ``ipv4_lookup`` LPM table. It is needed if user\n+       wishes to route the packets based on LPM lookup table.\n+     - No\n+     - Yes\n+   * - help ipv4_lookup\n+     - Command to dump ipv4_lookup help message\n+     - Yes\n+     - Yes\n \n Runtime configuration\n ---------------------\n",
    "prefixes": [
        "v5",
        "06/12"
    ]
}