get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 76938,
    "url": "http://patches.dpdk.org/api/patches/76938/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200908201830.74206-7-cristian.dumitrescu@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": "<20200908201830.74206-7-cristian.dumitrescu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200908201830.74206-7-cristian.dumitrescu@intel.com",
    "date": "2020-09-08T20:17:55",
    "name": "[v3,06/41] pipeline: add SWX pipeline action",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "063c0523136e8075534287c4ee4e239cdc6e4695",
    "submitter": {
        "id": 19,
        "url": "http://patches.dpdk.org/api/people/19/?format=api",
        "name": "Cristian Dumitrescu",
        "email": "cristian.dumitrescu@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20200908201830.74206-7-cristian.dumitrescu@intel.com/mbox/",
    "series": [
        {
            "id": 12034,
            "url": "http://patches.dpdk.org/api/series/12034/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=12034",
            "date": "2020-09-08T20:17:52",
            "name": "Pipeline alignment with the P4 language",
            "version": 3,
            "mbox": "http://patches.dpdk.org/series/12034/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/76938/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/76938/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 dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id DB51EA04B1;\n\tTue,  8 Sep 2020 22:19:39 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 7D6471C11B;\n\tTue,  8 Sep 2020 22:19:03 +0200 (CEST)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n by dpdk.org (Postfix) with ESMTP id 1D28D1C0BE\n for <dev@dpdk.org>; Tue,  8 Sep 2020 22:18:54 +0200 (CEST)",
            "from fmsmga006.fm.intel.com ([10.253.24.20])\n by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 08 Sep 2020 13:18:38 -0700",
            "from silpixa00400573.ir.intel.com (HELO\n silpixa00400573.ger.corp.intel.com) ([10.237.223.107])\n by fmsmga006.fm.intel.com with ESMTP; 08 Sep 2020 13:18:37 -0700"
        ],
        "IronPort-SDR": [
            "\n vuOvZjWWwoRlhQLSaSQzX+6pA7mpkb+5Jn1LkQ6CtS8ai/K7ciNqf1vKTFPSutlamYJd31SCgD\n aX9z3Ee7tiOg==",
            "\n CWtxWOeqw8IuCUG/Z1/2PyIiKTFfI1/aK+BN9gRwdzXsBv86SvyBLRdbtvGdguOaPa3tfnLadP\n 92RNLCe8AHdQ=="
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6000,8403,9738\"; a=\"145939377\"",
            "E=Sophos;i=\"5.76,407,1592895600\"; d=\"scan'208\";a=\"145939377\"",
            "E=Sophos;i=\"5.76,406,1592895600\"; d=\"scan'208\";a=\"504493380\""
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "From": "Cristian Dumitrescu <cristian.dumitrescu@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Tue,  8 Sep 2020 21:17:55 +0100",
        "Message-Id": "<20200908201830.74206-7-cristian.dumitrescu@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20200908201830.74206-1-cristian.dumitrescu@intel.com>",
        "References": "<20200907214032.95052-2-cristian.dumitrescu@intel.com>\n <20200908201830.74206-1-cristian.dumitrescu@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v3 06/41] pipeline: add SWX pipeline action",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "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",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Add SWX actions that are dynamically-defined through instructions as\nopposed to pre-defined. The actions are subroutines of the pipeline\nprogram that triggered by table lookup. The input arguments are the\naction data from the table entry (format defined by struct), the\nheaders and meta-data are in/out.\n\nSigned-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>\n---\n lib/librte_pipeline/rte_pipeline_version.map |   1 +\n lib/librte_pipeline/rte_swx_pipeline.c       | 147 +++++++++++++++++++\n lib/librte_pipeline/rte_swx_pipeline.h       |  32 ++++\n 3 files changed, 180 insertions(+)",
    "diff": "diff --git a/lib/librte_pipeline/rte_pipeline_version.map b/lib/librte_pipeline/rte_pipeline_version.map\nindex 4297e185d..c701f158d 100644\n--- a/lib/librte_pipeline/rte_pipeline_version.map\n+++ b/lib/librte_pipeline/rte_pipeline_version.map\n@@ -67,6 +67,7 @@ EXPERIMENTAL {\n \trte_swx_pipeline_struct_type_register;\n \trte_swx_pipeline_packet_header_register;\n \trte_swx_pipeline_packet_metadata_register;\n+\trte_swx_pipeline_action_config;\n \trte_swx_pipeline_build;\n \trte_swx_pipeline_free;\n };\ndiff --git a/lib/librte_pipeline/rte_swx_pipeline.c b/lib/librte_pipeline/rte_swx_pipeline.c\nindex 2335831bf..678700050 100644\n--- a/lib/librte_pipeline/rte_swx_pipeline.c\n+++ b/lib/librte_pipeline/rte_swx_pipeline.c\n@@ -177,6 +177,26 @@ struct header_out_runtime {\n \tuint32_t n_bytes;\n };\n \n+/*\n+ * Instruction.\n+ */\n+struct instruction {\n+};\n+\n+/*\n+ * Action.\n+ */\n+struct action {\n+\tTAILQ_ENTRY(action) node;\n+\tchar name[RTE_SWX_NAME_SIZE];\n+\tstruct struct_type *st;\n+\tstruct instruction *instructions;\n+\tuint32_t n_instructions;\n+\tuint32_t id;\n+};\n+\n+TAILQ_HEAD(action_tailq, action);\n+\n /*\n  * Pipeline.\n  */\n@@ -216,9 +236,11 @@ struct rte_swx_pipeline {\n \tstruct header_tailq headers;\n \tstruct struct_type *metadata_st;\n \tuint32_t metadata_struct_id;\n+\tstruct action_tailq actions;\n \n \tstruct port_in_runtime *in;\n \tstruct port_out_runtime *out;\n+\tstruct instruction **action_instructions;\n \tstruct thread threads[RTE_SWX_PIPELINE_THREADS_MAX];\n \n \tuint32_t n_structs;\n@@ -226,6 +248,7 @@ struct rte_swx_pipeline {\n \tuint32_t n_ports_out;\n \tuint32_t n_extern_objs;\n \tuint32_t n_extern_funcs;\n+\tuint32_t n_actions;\n \tuint32_t n_headers;\n \tint build_done;\n \tint numa_node;\n@@ -1267,6 +1290,123 @@ metadata_free(struct rte_swx_pipeline *p)\n \tmetadata_build_free(p);\n }\n \n+/*\n+ * Instruction.\n+ */\n+static int\n+instruction_config(struct rte_swx_pipeline *p __rte_unused,\n+\t\t   struct action *a __rte_unused,\n+\t\t   const char **instructions __rte_unused,\n+\t\t   uint32_t n_instructions __rte_unused)\n+{\n+\treturn 0;\n+}\n+\n+/*\n+ * Action.\n+ */\n+static struct action *\n+action_find(struct rte_swx_pipeline *p, const char *name)\n+{\n+\tstruct action *elem;\n+\n+\tif (!name)\n+\t\treturn NULL;\n+\n+\tTAILQ_FOREACH(elem, &p->actions, node)\n+\t\tif (strcmp(elem->name, name) == 0)\n+\t\t\treturn elem;\n+\n+\treturn NULL;\n+}\n+\n+int\n+rte_swx_pipeline_action_config(struct rte_swx_pipeline *p,\n+\t\t\t       const char *name,\n+\t\t\t       const char *args_struct_type_name,\n+\t\t\t       const char **instructions,\n+\t\t\t       uint32_t n_instructions)\n+{\n+\tstruct struct_type *args_struct_type;\n+\tstruct action *a;\n+\tint err;\n+\n+\tCHECK(p, EINVAL);\n+\n+\tCHECK_NAME(name, EINVAL);\n+\tCHECK(!action_find(p, name), EEXIST);\n+\n+\tif (args_struct_type_name) {\n+\t\tCHECK_NAME(args_struct_type_name, EINVAL);\n+\t\targs_struct_type = struct_type_find(p, args_struct_type_name);\n+\t\tCHECK(args_struct_type, EINVAL);\n+\t} else {\n+\t\targs_struct_type = NULL;\n+\t}\n+\n+\t/* Node allocation. */\n+\ta = calloc(1, sizeof(struct action));\n+\tCHECK(a, ENOMEM);\n+\n+\t/* Node initialization. */\n+\tstrcpy(a->name, name);\n+\ta->st = args_struct_type;\n+\ta->id = p->n_actions;\n+\n+\t/* Instruction translation. */\n+\terr = instruction_config(p, a, instructions, n_instructions);\n+\tif (err) {\n+\t\tfree(a);\n+\t\treturn err;\n+\t}\n+\n+\t/* Node add to tailq. */\n+\tTAILQ_INSERT_TAIL(&p->actions, a, node);\n+\tp->n_actions++;\n+\n+\treturn 0;\n+}\n+\n+static int\n+action_build(struct rte_swx_pipeline *p)\n+{\n+\tstruct action *action;\n+\n+\tp->action_instructions = calloc(p->n_actions,\n+\t\t\t\t\tsizeof(struct instruction *));\n+\tCHECK(p->action_instructions, ENOMEM);\n+\n+\tTAILQ_FOREACH(action, &p->actions, node)\n+\t\tp->action_instructions[action->id] = action->instructions;\n+\n+\treturn 0;\n+}\n+\n+static void\n+action_build_free(struct rte_swx_pipeline *p)\n+{\n+\tfree(p->action_instructions);\n+\tp->action_instructions = NULL;\n+}\n+\n+static void\n+action_free(struct rte_swx_pipeline *p)\n+{\n+\taction_build_free(p);\n+\n+\tfor ( ; ; ) {\n+\t\tstruct action *action;\n+\n+\t\taction = TAILQ_FIRST(&p->actions);\n+\t\tif (!action)\n+\t\t\tbreak;\n+\n+\t\tTAILQ_REMOVE(&p->actions, action, node);\n+\t\tfree(action->instructions);\n+\t\tfree(action);\n+\t}\n+}\n+\n /*\n  * Pipeline.\n  */\n@@ -1292,6 +1432,7 @@ rte_swx_pipeline_config(struct rte_swx_pipeline **p, int numa_node)\n \tTAILQ_INIT(&pipeline->extern_objs);\n \tTAILQ_INIT(&pipeline->extern_funcs);\n \tTAILQ_INIT(&pipeline->headers);\n+\tTAILQ_INIT(&pipeline->actions);\n \n \tpipeline->n_structs = 1; /* Struct 0 is reserved for action_data. */\n \tpipeline->numa_node = numa_node;\n@@ -1306,6 +1447,7 @@ rte_swx_pipeline_free(struct rte_swx_pipeline *p)\n \tif (!p)\n \t\treturn;\n \n+\taction_free(p);\n \tmetadata_free(p);\n \theader_free(p);\n \textern_func_free(p);\n@@ -1353,10 +1495,15 @@ rte_swx_pipeline_build(struct rte_swx_pipeline *p)\n \tif (status)\n \t\tgoto error;\n \n+\tstatus = action_build(p);\n+\tif (status)\n+\t\tgoto error;\n+\n \tp->build_done = 1;\n \treturn 0;\n \n error:\n+\taction_build_free(p);\n \tmetadata_build_free(p);\n \theader_build_free(p);\n \textern_func_build_free(p);\ndiff --git a/lib/librte_pipeline/rte_swx_pipeline.h b/lib/librte_pipeline/rte_swx_pipeline.h\nindex 2e8a6cdf8..1b20293cb 100644\n--- a/lib/librte_pipeline/rte_swx_pipeline.h\n+++ b/lib/librte_pipeline/rte_swx_pipeline.h\n@@ -344,6 +344,38 @@ int\n rte_swx_pipeline_packet_metadata_register(struct rte_swx_pipeline *p,\n \t\t\t\t\t  const char *struct_type_name);\n \n+/*\n+ * Pipeline action\n+ */\n+\n+/**\n+ * Pipeline action configure\n+ *\n+ * @param[in] p\n+ *   Pipeline handle.\n+ * @param[in] name\n+ *   Action name.\n+ * @param[in] args_struct_type_name\n+ *   The struct type instantiated by the action data. The action data represent\n+ *   the action arguments that are stored in the table entry together with the\n+ *   action ID. Set to NULL when the action does not have any arguments.\n+ * @param[in] instructions\n+ *   Action instructions.\n+ * @param[in] n_instructions\n+ *   Number of action instructions.\n+ * @return\n+ *   0 on success or the following error codes otherwise:\n+ *   -EINVAL: Invalid argument;\n+ *   -ENOMEM: Not enough space/cannot allocate memory;\n+ *   -EEXIST: Action with this name already exists.\n+ */\n+__rte_experimental\n+int\n+rte_swx_pipeline_action_config(struct rte_swx_pipeline *p,\n+\t\t\t       const char *name,\n+\t\t\t       const char *args_struct_type_name,\n+\t\t\t       const char **instructions,\n+\t\t\t       uint32_t n_instructions);\n \n /**\n  * Pipeline build\n",
    "prefixes": [
        "v3",
        "06/41"
    ]
}