get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 76957,
    "url": "http://patches.dpdk.org/api/patches/76957/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200908201830.74206-25-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-25-cristian.dumitrescu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200908201830.74206-25-cristian.dumitrescu@intel.com",
    "date": "2020-09-08T20:18:13",
    "name": "[v3,24/41] pipeline: introduce SWX extern instruction",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "2d146a9e3e9573804dbf568c946e26434007aa13",
    "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-25-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/76957/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/76957/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 05B54A04B1;\n\tTue,  8 Sep 2020 22:22:54 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id C18B11C1F3;\n\tTue,  8 Sep 2020 22:19:32 +0200 (CEST)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n by dpdk.org (Postfix) with ESMTP id 093321C0D9\n for <dev@dpdk.org>; Tue,  8 Sep 2020 22:19:02 +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:55 -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:54 -0700"
        ],
        "IronPort-SDR": [
            "\n ReVhodWTQhqYI9iWHnpdb6xpH1fe5bsRSPZ+Dmm8G5HP2olgGUC1/UTz+T2AUwbx/yyuNZbt9o\n zCetV1ovV0iA==",
            "\n aJRM7LqOeocraFegxZ5mSl8KWx/ddqzkSutnIeHQMkQ4JSjEG7GxWK0tp/oohcT4tltDuUw7a2\n vbLlJxqKuouw=="
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6000,8403,9738\"; a=\"145939422\"",
            "E=Sophos;i=\"5.76,407,1592895600\"; d=\"scan'208\";a=\"145939422\"",
            "E=Sophos;i=\"5.76,406,1592895600\"; d=\"scan'208\";a=\"504493483\""
        ],
        "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:18:13 +0100",
        "Message-Id": "<20200908201830.74206-25-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 24/41] pipeline: introduce SWX extern\n\tinstruction",
        "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": "The extern instruction calls one of the member functions of a given\nextern object or it calls the given extern function. The function\narguments must be written in advance in the maibox. The results are\navailable in the same place after execution.\n\nSigned-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>\n---\n lib/librte_pipeline/rte_swx_pipeline.c | 175 +++++++++++++++++++++++++\n 1 file changed, 175 insertions(+)",
    "diff": "diff --git a/lib/librte_pipeline/rte_swx_pipeline.c b/lib/librte_pipeline/rte_swx_pipeline.c\nindex 887668481..aaf2aafa5 100644\n--- a/lib/librte_pipeline/rte_swx_pipeline.c\n+++ b/lib/librte_pipeline/rte_swx_pipeline.c\n@@ -352,6 +352,12 @@ enum instruction_type {\n \n \t/* table TABLE */\n \tINSTR_TABLE,\n+\n+\t/* extern e.obj.func */\n+\tINSTR_EXTERN_OBJ,\n+\n+\t/* extern f.func */\n+\tINSTR_EXTERN_FUNC,\n };\n \n struct instr_operand {\n@@ -383,6 +389,15 @@ struct instr_table {\n \tuint8_t table_id;\n };\n \n+struct instr_extern_obj {\n+\tuint8_t ext_obj_id;\n+\tuint8_t func_id;\n+};\n+\n+struct instr_extern_func {\n+\tuint8_t ext_func_id;\n+};\n+\n struct instr_dst_src {\n \tstruct instr_operand dst;\n \tunion {\n@@ -413,6 +428,8 @@ struct instruction {\n \t\tstruct instr_dma dma;\n \t\tstruct instr_dst_src alu;\n \t\tstruct instr_table table;\n+\t\tstruct instr_extern_obj ext_obj;\n+\t\tstruct instr_extern_func ext_func;\n \t};\n };\n \n@@ -1271,6 +1288,50 @@ extern_obj_find(struct rte_swx_pipeline *p, const char *name)\n \treturn NULL;\n }\n \n+static struct extern_type_member_func *\n+extern_obj_member_func_parse(struct rte_swx_pipeline *p,\n+\t\t\t     const char *name,\n+\t\t\t     struct extern_obj **obj)\n+{\n+\tstruct extern_obj *object;\n+\tstruct extern_type_member_func *func;\n+\tchar *object_name, *func_name;\n+\n+\tif (name[0] != 'e' || name[1] != '.')\n+\t\treturn NULL;\n+\n+\tobject_name = strdup(&name[2]);\n+\tif (!object_name)\n+\t\treturn NULL;\n+\n+\tfunc_name = strchr(object_name, '.');\n+\tif (!func_name) {\n+\t\tfree(object_name);\n+\t\treturn NULL;\n+\t}\n+\n+\t*func_name = 0;\n+\tfunc_name++;\n+\n+\tobject = extern_obj_find(p, object_name);\n+\tif (!object) {\n+\t\tfree(object_name);\n+\t\treturn NULL;\n+\t}\n+\n+\tfunc = extern_type_member_func_find(object->type, func_name);\n+\tif (!func) {\n+\t\tfree(object_name);\n+\t\treturn NULL;\n+\t}\n+\n+\tif (obj)\n+\t\t*obj = object;\n+\n+\tfree(object_name);\n+\treturn func;\n+}\n+\n static struct field *\n extern_obj_mailbox_field_parse(struct rte_swx_pipeline *p,\n \t\t\t       const char *name,\n@@ -1553,6 +1614,16 @@ extern_func_find(struct rte_swx_pipeline *p, const char *name)\n \treturn NULL;\n }\n \n+static struct extern_func *\n+extern_func_parse(struct rte_swx_pipeline *p,\n+\t\t  const char *name)\n+{\n+\tif (name[0] != 'f' || name[1] != '.')\n+\t\treturn NULL;\n+\n+\treturn extern_func_find(p, &name[2]);\n+}\n+\n static struct field *\n extern_func_mailbox_field_parse(struct rte_swx_pipeline *p,\n \t\t\t\tconst char *name,\n@@ -2097,6 +2168,12 @@ thread_yield(struct rte_swx_pipeline *p)\n \tp->thread_id = (p->thread_id + 1) & (RTE_SWX_PIPELINE_THREADS_MAX - 1);\n }\n \n+static inline void\n+thread_yield_cond(struct rte_swx_pipeline *p, int cond)\n+{\n+\tp->thread_id = (p->thread_id + cond) & (RTE_SWX_PIPELINE_THREADS_MAX - 1);\n+}\n+\n /*\n  * rx.\n  */\n@@ -2760,6 +2837,94 @@ instr_table_exec(struct rte_swx_pipeline *p)\n \tthread_ip_action_call(p, t, action_id);\n }\n \n+/*\n+ * extern.\n+ */\n+static int\n+instr_extern_translate(struct rte_swx_pipeline *p,\n+\t\t       struct action *action __rte_unused,\n+\t\t       char **tokens,\n+\t\t       int n_tokens,\n+\t\t       struct instruction *instr,\n+\t\t       struct instruction_data *data __rte_unused)\n+{\n+\tchar *token = tokens[1];\n+\n+\tCHECK(n_tokens == 2, EINVAL);\n+\n+\tif (token[0] == 'e') {\n+\t\tstruct extern_obj *obj;\n+\t\tstruct extern_type_member_func *func;\n+\n+\t\tfunc = extern_obj_member_func_parse(p, token, &obj);\n+\t\tCHECK(func, EINVAL);\n+\n+\t\tinstr->type = INSTR_EXTERN_OBJ;\n+\t\tinstr->ext_obj.ext_obj_id = obj->id;\n+\t\tinstr->ext_obj.func_id = func->id;\n+\n+\t\treturn 0;\n+\t}\n+\n+\tif (token[0] == 'f') {\n+\t\tstruct extern_func *func;\n+\n+\t\tfunc = extern_func_parse(p, token);\n+\t\tCHECK(func, EINVAL);\n+\n+\t\tinstr->type = INSTR_EXTERN_FUNC;\n+\t\tinstr->ext_func.ext_func_id = func->id;\n+\n+\t\treturn 0;\n+\t}\n+\n+\tCHECK(0, EINVAL);\n+}\n+\n+static inline void\n+instr_extern_obj_exec(struct rte_swx_pipeline *p)\n+{\n+\tstruct thread *t = &p->threads[p->thread_id];\n+\tstruct instruction *ip = t->ip;\n+\tuint32_t obj_id = ip->ext_obj.ext_obj_id;\n+\tuint32_t func_id = ip->ext_obj.func_id;\n+\tstruct extern_obj_runtime *obj = &t->extern_objs[obj_id];\n+\trte_swx_extern_type_member_func_t func = obj->funcs[func_id];\n+\n+\tTRACE(\"[Thread %2u] extern obj %u member func %u\\n\",\n+\t      p->thread_id,\n+\t      obj_id,\n+\t      func_id);\n+\n+\t/* Extern object member function execute. */\n+\tuint32_t done = func(obj->obj, obj->mailbox);\n+\n+\t/* Thread. */\n+\tthread_ip_inc_cond(t, done);\n+\tthread_yield_cond(p, done ^ 1);\n+}\n+\n+static inline void\n+instr_extern_func_exec(struct rte_swx_pipeline *p)\n+{\n+\tstruct thread *t = &p->threads[p->thread_id];\n+\tstruct instruction *ip = t->ip;\n+\tuint32_t ext_func_id = ip->ext_func.ext_func_id;\n+\tstruct extern_func_runtime *ext_func = &t->extern_funcs[ext_func_id];\n+\trte_swx_extern_func_t func = ext_func->func;\n+\n+\tTRACE(\"[Thread %2u] extern func %u\\n\",\n+\t      p->thread_id,\n+\t      ext_func_id);\n+\n+\t/* Extern function execute. */\n+\tuint32_t done = func(ext_func->mailbox);\n+\n+\t/* Thread. */\n+\tthread_ip_inc_cond(t, done);\n+\tthread_yield_cond(p, done ^ 1);\n+}\n+\n /*\n  * mov.\n  */\n@@ -4367,6 +4532,14 @@ instr_translate(struct rte_swx_pipeline *p,\n \t\t\t\t\t     instr,\n \t\t\t\t\t     data);\n \n+\tif (!strcmp(tokens[tpos], \"extern\"))\n+\t\treturn instr_extern_translate(p,\n+\t\t\t\t\t      action,\n+\t\t\t\t\t      &tokens[tpos],\n+\t\t\t\t\t      n_tokens - tpos,\n+\t\t\t\t\t      instr,\n+\t\t\t\t\t      data);\n+\n \tCHECK(0, EINVAL);\n }\n \n@@ -4571,6 +4744,8 @@ static instr_exec_t instruction_table[] = {\n \t[INSTR_ALU_SHR_HI] = instr_alu_shr_hi_exec,\n \n \t[INSTR_TABLE] = instr_table_exec,\n+\t[INSTR_EXTERN_OBJ] = instr_extern_obj_exec,\n+\t[INSTR_EXTERN_FUNC] = instr_extern_func_exec,\n };\n \n static inline void\n",
    "prefixes": [
        "v3",
        "24/41"
    ]
}