get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 115663,
    "url": "https://patches.dpdk.org/api/patches/115663/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20220830185811.1843109-7-cristian.dumitrescu@intel.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": "<20220830185811.1843109-7-cristian.dumitrescu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20220830185811.1843109-7-cristian.dumitrescu@intel.com",
    "date": "2022-08-30T18:58:10",
    "name": "[V3,6/7] examples/pipeline: add CLI commands for direct registers",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "6b996b1521a27436d2c9be06a38d3707fcaf8f52",
    "submitter": {
        "id": 19,
        "url": "https://patches.dpdk.org/api/people/19/?format=api",
        "name": "Cristian Dumitrescu",
        "email": "cristian.dumitrescu@intel.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/20220830185811.1843109-7-cristian.dumitrescu@intel.com/mbox/",
    "series": [
        {
            "id": 24469,
            "url": "https://patches.dpdk.org/api/series/24469/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=24469",
            "date": "2022-08-30T18:58:04",
            "name": "pipeline: support direct registers and meters",
            "version": 3,
            "mbox": "https://patches.dpdk.org/series/24469/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/115663/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/115663/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 1DB1BA00C5;\n\tTue, 30 Aug 2022 20:59:04 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 38B7242B71;\n\tTue, 30 Aug 2022 20:58:33 +0200 (CEST)",
            "from mga03.intel.com (mga03.intel.com [134.134.136.65])\n by mails.dpdk.org (Postfix) with ESMTP id DE58A40F18\n for <dev@dpdk.org>; Tue, 30 Aug 2022 20:58:26 +0200 (CEST)",
            "from orsmga003.jf.intel.com ([10.7.209.27])\n by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 30 Aug 2022 11:58:17 -0700",
            "from silpixa00400573.ir.intel.com (HELO\n silpixa00400573.ger.corp.intel.com.) ([10.237.223.157])\n by orsmga003.jf.intel.com with ESMTP; 30 Aug 2022 11:58:17 -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=1661885907; x=1693421907;\n h=from:to:subject:date:message-id:in-reply-to:references:\n mime-version:content-transfer-encoding;\n bh=sx/iaGyaadlMWvywXnlJlbEUv5hTvQSceNb+Jn4oEVo=;\n b=j3jSEQJZR6qagPJQ+MOPQ8SODjLMiam7xP8dq3ZtXU/m1GMAw6B2QWSS\n XX8P1uxMQSjzAv47MMcL4nR+uovESeVzLFdGtkdKLmgMLXOS8yt+r0F3e\n KZWuaH3BOBAaFxHRGbF96RqFtAvriEUp9LkIe63DiJFQou7hsJOw/JIWH\n tzF4RxlGmH3AOe4eHhcqYHETM4SlqlE63R2DgCeMwGh1LlG4fSSrFl6zK\n Cdusdhh3s6ynl1P0FKlE5cnoyZpmALP71YgjVYLduQUnm/Se+KeZnr5HA\n MwXYlXPeAKiXtpnlHWjZYauGrivB5wGZ9svPch25HIVO6FqRzzjfrC/xL Q==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6500,9779,10455\"; a=\"296554029\"",
            "E=Sophos;i=\"5.93,275,1654585200\"; d=\"scan'208\";a=\"296554029\"",
            "E=Sophos;i=\"5.93,275,1654585200\"; d=\"scan'208\";a=\"562770854\""
        ],
        "X-ExtLoop1": "1",
        "From": "Cristian Dumitrescu <cristian.dumitrescu@intel.com>",
        "To": "dev@dpdk.org",
        "Subject": "[PATCH V3 6/7] examples/pipeline: add CLI commands for direct\n registers",
        "Date": "Tue, 30 Aug 2022 18:58:10 +0000",
        "Message-Id": "<20220830185811.1843109-7-cristian.dumitrescu@intel.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20220830185811.1843109-1-cristian.dumitrescu@intel.com>",
        "References": "<20220826103605.1579589-1-cristian.dumitrescu@intel.com>\n <20220830185811.1843109-1-cristian.dumitrescu@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": "Add the CLI command support for reading/writing direct registers.\n\nSigned-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>\n---\n examples/pipeline/cli.c | 228 +++++++++++++++++++++++++++++++++-------\n 1 file changed, 192 insertions(+), 36 deletions(-)",
    "diff": "diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c\nindex 2e69698031..115147adfc 100644\n--- a/examples/pipeline/cli.c\n+++ b/examples/pipeline/cli.c\n@@ -142,6 +142,54 @@ is_comment(char *in)\n \treturn 0;\n }\n \n+static void\n+table_entry_free(struct rte_swx_table_entry *entry)\n+{\n+\tif (!entry)\n+\t\treturn;\n+\n+\tfree(entry->key);\n+\tfree(entry->key_mask);\n+\tfree(entry->action_data);\n+\tfree(entry);\n+}\n+\n+static struct rte_swx_table_entry *\n+parse_table_entry(struct rte_swx_ctl_pipeline *p,\n+\t\t  char *table_name,\n+\t\t  char **tokens,\n+\t\t  uint32_t n_tokens)\n+{\n+\tstruct rte_swx_table_entry *entry;\n+\tchar *line;\n+\tuint32_t i;\n+\n+\t/* Buffer allocation. */\n+\tline = malloc(MAX_LINE_SIZE);\n+\tif (!line)\n+\t\treturn NULL;\n+\n+\t/* Copy tokens to buffer. Since the tokens were initially part of a buffer of size\n+\t * MAX_LINE_LENGTH, it is guaranteed that putting back some of them into a buffer of the\n+\t * same size separated by a single space will not result in buffer overrun.\n+\t */\n+\tline[0] = 0;\n+\tfor (i = 0; i < n_tokens; i++) {\n+\t\tif (i)\n+\t\t\tstrcat(line, \" \");\n+\n+\t\tstrcat(line, tokens[i]);\n+\t}\n+\n+\t/* Read the table entry from the input buffer. */\n+\tentry = rte_swx_ctl_pipeline_table_entry_read(p, table_name, line, NULL);\n+\n+\t/* Buffer free. */\n+\tfree(line);\n+\n+\treturn entry;\n+}\n+\n static const char cmd_mempool_help[] =\n \"mempool <mempool_name>\\n\"\n \"   buffer <buffer_size>\\n\"\n@@ -732,18 +780,6 @@ cmd_pipeline_build(char **tokens,\n \t\tfclose(iospec_file);\n }\n \n-static void\n-table_entry_free(struct rte_swx_table_entry *entry)\n-{\n-\tif (!entry)\n-\t\treturn;\n-\n-\tfree(entry->key);\n-\tfree(entry->key_mask);\n-\tfree(entry->action_data);\n-\tfree(entry);\n-}\n-\n static int\n pipeline_table_entries_add(struct rte_swx_ctl_pipeline *p,\n \t\t\t   const char *table_name,\n@@ -1710,7 +1746,9 @@ cmd_pipeline_abort(char **tokens,\n }\n \n static const char cmd_pipeline_regrd_help[] =\n-\"pipeline <pipeline_name> regrd <register_array_name> <index>\\n\";\n+\"pipeline <pipeline_name> regrd <register_array_name>\\n\"\n+\t\"index <index>\\n\"\n+\t\" | table <table_name> match <field0> ...\\n\";\n \n static void\n cmd_pipeline_regrd(char **tokens,\n@@ -1720,18 +1758,20 @@ cmd_pipeline_regrd(char **tokens,\n \tvoid *obj __rte_unused)\n {\n \tstruct rte_swx_pipeline *p;\n-\tconst char *name;\n+\tstruct rte_swx_ctl_pipeline *ctl;\n+\tconst char *pipeline_name, *name;\n \tuint64_t value;\n-\tuint32_t idx;\n \tint status;\n \n-\tif (n_tokens != 5) {\n+\tif (n_tokens < 5) {\n \t\tsnprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);\n \t\treturn;\n \t}\n \n-\tp = rte_swx_pipeline_find(tokens[1]);\n-\tif (!p) {\n+\tpipeline_name = tokens[1];\n+\tp = rte_swx_pipeline_find(pipeline_name);\n+\tctl = rte_swx_ctl_pipeline_find(pipeline_name);\n+\tif (!p || !ctl) {\n \t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"pipeline_name\");\n \t\treturn;\n \t}\n@@ -1743,22 +1783,77 @@ cmd_pipeline_regrd(char **tokens,\n \n \tname = tokens[3];\n \n-\tif (parser_read_uint32(&idx, tokens[4])) {\n-\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"index\");\n+\t/* index. */\n+\tif (!strcmp(tokens[4], \"index\")) {\n+\t\tuint32_t idx;\n+\n+\t\tif (n_tokens != 6) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif (parser_read_uint32(&idx, tokens[5])) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"index\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tstatus = rte_swx_ctl_pipeline_regarray_read(p, name, idx, &value);\n+\t\tif (status) {\n+\t\t\tsnprintf(out, out_size, \"Command failed.\\n\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tsnprintf(out, out_size, \"0x%\" PRIx64 \"\\n\", value);\n \t\treturn;\n \t}\n \n-\tstatus = rte_swx_ctl_pipeline_regarray_read(p, name, idx, &value);\n-\tif (status) {\n-\t\tsnprintf(out, out_size, \"Command failed.\\n\");\n+\t/* table. */\n+\tif (!strcmp(tokens[4], \"table\")) {\n+\t\tstruct rte_swx_table_entry *entry;\n+\t\tchar *table_name;\n+\n+\t\tif (n_tokens < 8) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\ttable_name = tokens[5];\n+\n+\t\tif (strcmp(tokens[6], \"match\")) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"match\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tentry = parse_table_entry(ctl, table_name, &tokens[6], n_tokens - 6);\n+\t\tif (!entry) {\n+\t\t\tsnprintf(out, out_size, \"Invalid match tokens.\\n\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tstatus = rte_swx_ctl_pipeline_regarray_read_with_key(p,\n+\t\t\t\t\t\t\t\t     name,\n+\t\t\t\t\t\t\t\t     table_name,\n+\t\t\t\t\t\t\t\t     entry->key,\n+\t\t\t\t\t\t\t\t     &value);\n+\t\ttable_entry_free(entry);\n+\t\tif (status) {\n+\t\t\tsnprintf(out, out_size, \"Command failed.\\n\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tsnprintf(out, out_size, \"0x%\" PRIx64 \"\\n\", value);\n \t\treturn;\n \t}\n \n-\tsnprintf(out, out_size, \"0x%\" PRIx64 \"\\n\", value);\n+\t/* anything else. */\n+\tsnprintf(out, out_size, \"Invalid token %s\\n.\", tokens[4]);\n+\treturn;\n }\n \n static const char cmd_pipeline_regwr_help[] =\n-\"pipeline <pipeline_name> regwr <register_array_name> <index> <value>\\n\";\n+\"pipeline <pipeline_name> regwr <register_array_name> value <value>\\n\"\n+\t\"index <index>\\n\"\n+\t\" | table <table_name> match <field0> ...\\n\";\n \n static void\n cmd_pipeline_regwr(char **tokens,\n@@ -1768,18 +1863,20 @@ cmd_pipeline_regwr(char **tokens,\n \tvoid *obj __rte_unused)\n {\n \tstruct rte_swx_pipeline *p;\n-\tconst char *name;\n-\tuint64_t value;\n-\tuint32_t idx;\n+\tstruct rte_swx_ctl_pipeline *ctl;\n+\tconst char *pipeline_name, *name;\n+\tuint64_t value = 0;\n \tint status;\n \n-\tif (n_tokens != 6) {\n+\tif (n_tokens < 7) {\n \t\tsnprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);\n \t\treturn;\n \t}\n \n-\tp = rte_swx_pipeline_find(tokens[1]);\n-\tif (!p) {\n+\tpipeline_name = tokens[1];\n+\tp = rte_swx_pipeline_find(pipeline_name);\n+\tctl = rte_swx_ctl_pipeline_find(pipeline_name);\n+\tif (!p || !ctl) {\n \t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"pipeline_name\");\n \t\treturn;\n \t}\n@@ -1791,8 +1888,8 @@ cmd_pipeline_regwr(char **tokens,\n \n \tname = tokens[3];\n \n-\tif (parser_read_uint32(&idx, tokens[4])) {\n-\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"index\");\n+\tif (strcmp(tokens[4], \"value\")) {\n+\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"value\");\n \t\treturn;\n \t}\n \n@@ -1801,11 +1898,70 @@ cmd_pipeline_regwr(char **tokens,\n \t\treturn;\n \t}\n \n-\tstatus = rte_swx_ctl_pipeline_regarray_write(p, name, idx, value);\n-\tif (status) {\n-\t\tsnprintf(out, out_size, \"Command failed.\\n\");\n+\t/* index. */\n+\tif (!strcmp(tokens[6], \"index\")) {\n+\t\tuint32_t idx;\n+\n+\t\tif (n_tokens != 8) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif (parser_read_uint32(&idx, tokens[7])) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_INVALID, \"index\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tstatus = rte_swx_ctl_pipeline_regarray_write(p, name, idx, value);\n+\t\tif (status) {\n+\t\t\tsnprintf(out, out_size, \"Command failed.\\n\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tsnprintf(out, out_size, \"0x%\" PRIx64 \"\\n\", value);\n \t\treturn;\n \t}\n+\n+\t/* table. */\n+\tif (!strcmp(tokens[6], \"table\")) {\n+\t\tstruct rte_swx_table_entry *entry;\n+\t\tchar *table_name;\n+\n+\t\tif (n_tokens < 10) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\ttable_name = tokens[7];\n+\n+\t\tif (strcmp(tokens[8], \"match\")) {\n+\t\t\tsnprintf(out, out_size, MSG_ARG_NOT_FOUND, \"match\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tentry = parse_table_entry(ctl, table_name, &tokens[8], n_tokens - 8);\n+\t\tif (!entry) {\n+\t\t\tsnprintf(out, out_size, \"Invalid match tokens.\\n\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tstatus = rte_swx_ctl_pipeline_regarray_write_with_key(p,\n+\t\t\t\t\t\t\t\t      name,\n+\t\t\t\t\t\t\t\t      table_name,\n+\t\t\t\t\t\t\t\t      entry->key,\n+\t\t\t\t\t\t\t\t      value);\n+\t\ttable_entry_free(entry);\n+\t\tif (status) {\n+\t\t\tsnprintf(out, out_size, \"Command failed.\\n\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\treturn;\n+\t}\n+\n+\t/* anything else. */\n+\tsnprintf(out, out_size, \"Invalid token %s\\n.\", tokens[6]);\n+\treturn;\n }\n \n static const char cmd_pipeline_meter_profile_add_help[] =\n",
    "prefixes": [
        "V3",
        "6/7"
    ]
}