get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 76945,
    "url": "http://patches.dpdk.org/api/patches/76945/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200908201830.74206-13-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-13-cristian.dumitrescu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200908201830.74206-13-cristian.dumitrescu@intel.com",
    "date": "2020-09-08T20:18:01",
    "name": "[v3,12/41] pipeline: add SWX mov instruction",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "4603fe4338e7e69d4424332f84375721de6c7fbf",
    "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-13-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/76945/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/76945/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 BBD50A04B1;\n\tTue,  8 Sep 2020 22:21:01 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 1863D1C19F;\n\tTue,  8 Sep 2020 22:19:17 +0200 (CEST)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n by dpdk.org (Postfix) with ESMTP id AE7921C0D9\n for <dev@dpdk.org>; Tue,  8 Sep 2020 22:18:59 +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:44 -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:43 -0700"
        ],
        "IronPort-SDR": [
            "\n TENRX+cjyJHVnQuStuf8qUIfffV/NH4qj3uLN2OLYVrpfG86sxONHQq9JFo7MuRt6zXm5YCaO7\n qI5NzS+ABGjA==",
            "\n Es2XaaE7JxFOlR3p9ybudrMxRqpYXqrZqThfMkGIvr8GDTiJ8/Sdu3S7vcB0VFLV0p7tr04dpW\n yJ6JUVLcOjKQ=="
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6000,8403,9738\"; a=\"145939402\"",
            "E=Sophos;i=\"5.76,407,1592895600\"; d=\"scan'208\";a=\"145939402\"",
            "E=Sophos;i=\"5.76,406,1592895600\"; d=\"scan'208\";a=\"504493413\""
        ],
        "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:01 +0100",
        "Message-Id": "<20200908201830.74206-13-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 12/41] pipeline: add SWX mov instruction",
        "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 mov (i.e. move) instruction source can be header field (H),\nmeta-data field (M), extern object (E) or function (F) mailbox field,\ntable entry action data field (T) or immediate value (I). The\ndestination is HMEF.\n\nSigned-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>\n---\n lib/librte_pipeline/rte_swx_pipeline.c | 369 +++++++++++++++++++++++++\n 1 file changed, 369 insertions(+)",
    "diff": "diff --git a/lib/librte_pipeline/rte_swx_pipeline.c b/lib/librte_pipeline/rte_swx_pipeline.c\nindex 8ddd766c2..b5b502caa 100644\n--- a/lib/librte_pipeline/rte_swx_pipeline.c\n+++ b/lib/librte_pipeline/rte_swx_pipeline.c\n@@ -6,9 +6,11 @@\n #include <stdio.h>\n #include <errno.h>\n #include <sys/queue.h>\n+#include <arpa/inet.h>\n \n #include <rte_common.h>\n #include <rte_prefetch.h>\n+#include <rte_byteorder.h>\n \n #include \"rte_swx_pipeline.h\"\n #include \"rte_swx_ctl.h\"\n@@ -32,6 +34,9 @@ do {                                                                           \\\n #define TRACE(...)\n #endif\n \n+#define ntoh64(x) rte_be_to_cpu_64(x)\n+#define hton64(x) rte_cpu_to_be_64(x)\n+\n /*\n  * Struct.\n  */\n@@ -242,6 +247,21 @@ enum instruction_type {\n \n \t/* invalidate h.header */\n \tINSTR_HDR_INVALIDATE,\n+\n+\t/* mov dst src\n+\t * dst = src\n+\t * dst = HMEF, src = HMEFTI\n+\t */\n+\tINSTR_MOV,   /* dst = MEF, src = MEFT */\n+\tINSTR_MOV_S, /* (dst, src) = (MEF, H) or (dst, src) = (H, MEFT) */\n+\tINSTR_MOV_I, /* dst = HMEF, src = I */\n+};\n+\n+struct instr_operand {\n+\tuint8_t struct_id;\n+\tuint8_t n_bits;\n+\tuint8_t offset;\n+\tuint8_t pad;\n };\n \n struct instr_io {\n@@ -262,11 +282,20 @@ struct instr_hdr_validity {\n \tuint8_t header_id;\n };\n \n+struct instr_dst_src {\n+\tstruct instr_operand dst;\n+\tunion {\n+\t\tstruct instr_operand src;\n+\t\tuint32_t src_val;\n+\t};\n+};\n+\n struct instruction {\n \tenum instruction_type type;\n \tunion {\n \t\tstruct instr_io io;\n \t\tstruct instr_hdr_validity valid;\n+\t\tstruct instr_dst_src mov;\n \t};\n };\n \n@@ -381,6 +410,57 @@ struct thread {\n #define MASK64_BIT_SET(mask, pos) ((mask) | (1LLU << (pos)))\n #define MASK64_BIT_CLR(mask, pos) ((mask) & ~(1LLU << (pos)))\n \n+#define MOV(thread, ip)  \\\n+{                                                                              \\\n+\tuint8_t *dst_struct = (thread)->structs[(ip)->mov.dst.struct_id];      \\\n+\tuint64_t *dst64_ptr = (uint64_t *)&dst_struct[(ip)->mov.dst.offset];   \\\n+\tuint64_t dst64 = *dst64_ptr;                                           \\\n+\tuint64_t dst64_mask = UINT64_MAX >> (64 - (ip)->mov.dst.n_bits);       \\\n+\t\t\t\t\t\t\t\t\t       \\\n+\tuint8_t *src_struct = (thread)->structs[(ip)->mov.src.struct_id];      \\\n+\tuint64_t *src64_ptr = (uint64_t *)&src_struct[(ip)->mov.src.offset];   \\\n+\tuint64_t src64 = *src64_ptr;                                           \\\n+\tuint64_t src64_mask = UINT64_MAX >> (64 - (ip)->mov.src.n_bits);       \\\n+\tuint64_t src = src64 & src64_mask;                                     \\\n+\t\t\t\t\t\t\t\t\t       \\\n+\t*dst64_ptr = (dst64 & ~dst64_mask) | (src & dst64_mask);               \\\n+}\n+\n+#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN\n+\n+#define MOV_S(thread, ip)  \\\n+{                                                                              \\\n+\tuint8_t *dst_struct = (thread)->structs[(ip)->mov.dst.struct_id];      \\\n+\tuint64_t *dst64_ptr = (uint64_t *)&dst_struct[(ip)->mov.dst.offset];   \\\n+\tuint64_t dst64 = *dst64_ptr;                                           \\\n+\tuint64_t dst64_mask = UINT64_MAX >> (64 - (ip)->mov.dst.n_bits);       \\\n+\t\t\t\t\t\t\t\t\t       \\\n+\tuint8_t *src_struct = (thread)->structs[(ip)->mov.src.struct_id];      \\\n+\tuint64_t *src64_ptr = (uint64_t *)&src_struct[(ip)->mov.src.offset];   \\\n+\tuint64_t src64 = *src64_ptr;                                           \\\n+\tuint64_t src = ntoh64(src64) >> (64 - (ip)->mov.src.n_bits);           \\\n+\t\t\t\t\t\t\t\t\t       \\\n+\t*dst64_ptr = (dst64 & ~dst64_mask) | (src & dst64_mask);               \\\n+}\n+\n+#else\n+\n+#define MOV_S MOV\n+\n+#endif\n+\n+#define MOV_I(thread, ip)  \\\n+{                                                                              \\\n+\tuint8_t *dst_struct = (thread)->structs[(ip)->mov.dst.struct_id];      \\\n+\tuint64_t *dst64_ptr = (uint64_t *)&dst_struct[(ip)->mov.dst.offset];   \\\n+\tuint64_t dst64 = *dst64_ptr;                                           \\\n+\tuint64_t dst64_mask = UINT64_MAX >> (64 - (ip)->mov.dst.n_bits);       \\\n+\t\t\t\t\t\t\t\t\t       \\\n+\tuint64_t src = (ip)->mov.src_val;                                      \\\n+\t\t\t\t\t\t\t\t\t       \\\n+\t*dst64_ptr = (dst64 & ~dst64_mask) | (src & dst64_mask);               \\\n+}\n+\n #define METADATA_READ(thread, offset, n_bits)                                  \\\n ({                                                                             \\\n \tuint64_t *m64_ptr = (uint64_t *)&(thread)->metadata[offset];           \\\n@@ -944,6 +1024,50 @@ extern_obj_find(struct rte_swx_pipeline *p, const char *name)\n \treturn NULL;\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+\t\t\t       struct extern_obj **object)\n+{\n+\tstruct extern_obj *obj;\n+\tstruct field *f;\n+\tchar *obj_name, *field_name;\n+\n+\tif ((name[0] != 'e') || (name[1] != '.'))\n+\t\treturn NULL;\n+\n+\tobj_name = strdup(&name[2]);\n+\tif (!obj_name)\n+\t\treturn NULL;\n+\n+\tfield_name = strchr(obj_name, '.');\n+\tif (!field_name) {\n+\t\tfree(obj_name);\n+\t\treturn NULL;\n+\t}\n+\n+\t*field_name = 0;\n+\tfield_name++;\n+\n+\tobj = extern_obj_find(p, obj_name);\n+\tif (!obj) {\n+\t\tfree(obj_name);\n+\t\treturn NULL;\n+\t}\n+\n+\tf = struct_type_field_find(obj->type->mailbox_struct_type, field_name);\n+\tif (!f) {\n+\t\tfree(obj_name);\n+\t\treturn NULL;\n+\t}\n+\n+\tif (object)\n+\t\t*object = obj;\n+\n+\tfree(obj_name);\n+\treturn f;\n+}\n+\n int\n rte_swx_pipeline_extern_type_register(struct rte_swx_pipeline *p,\n \tconst char *name,\n@@ -1182,6 +1306,50 @@ extern_func_find(struct rte_swx_pipeline *p, const char *name)\n \treturn NULL;\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+\t\t\t\tstruct extern_func **function)\n+{\n+\tstruct extern_func *func;\n+\tstruct field *f;\n+\tchar *func_name, *field_name;\n+\n+\tif ((name[0] != 'f') || (name[1] != '.'))\n+\t\treturn NULL;\n+\n+\tfunc_name = strdup(&name[2]);\n+\tif (!func_name)\n+\t\treturn NULL;\n+\n+\tfield_name = strchr(func_name, '.');\n+\tif (!field_name) {\n+\t\tfree(func_name);\n+\t\treturn NULL;\n+\t}\n+\n+\t*field_name = 0;\n+\tfield_name++;\n+\n+\tfunc = extern_func_find(p, func_name);\n+\tif (!func) {\n+\t\tfree(func_name);\n+\t\treturn NULL;\n+\t}\n+\n+\tf = struct_type_field_find(func->mailbox_struct_type, field_name);\n+\tif (!f) {\n+\t\tfree(func_name);\n+\t\treturn NULL;\n+\t}\n+\n+\tif (function)\n+\t\t*function = func;\n+\n+\tfree(func_name);\n+\treturn f;\n+}\n+\n int\n rte_swx_pipeline_extern_func_register(struct rte_swx_pipeline *p,\n \t\t\t\t      const char *name,\n@@ -1562,6 +1730,82 @@ metadata_free(struct rte_swx_pipeline *p)\n /*\n  * Instruction.\n  */\n+static struct field *\n+action_field_parse(struct action *action, const char *name);\n+\n+static struct field *\n+struct_field_parse(struct rte_swx_pipeline *p,\n+\t\t   struct action *action,\n+\t\t   const char *name,\n+\t\t   uint32_t *struct_id)\n+{\n+\tstruct field *f;\n+\n+\tswitch (name[0]) {\n+\tcase 'h':\n+\t{\n+\t\tstruct header *header;\n+\n+\t\tf = header_field_parse(p, name, &header);\n+\t\tif (!f)\n+\t\t\treturn NULL;\n+\n+\t\t*struct_id = header->struct_id;\n+\t\treturn f;\n+\t}\n+\n+\tcase 'm':\n+\t{\n+\t\tf = metadata_field_parse(p, name);\n+\t\tif (!f)\n+\t\t\treturn NULL;\n+\n+\t\t*struct_id = p->metadata_struct_id;\n+\t\treturn f;\n+\t}\n+\n+\tcase 't':\n+\t{\n+\t\tif (!action)\n+\t\t\treturn NULL;\n+\n+\t\tf = action_field_parse(action, name);\n+\t\tif (!f)\n+\t\t\treturn NULL;\n+\n+\t\t*struct_id = 0;\n+\t\treturn f;\n+\t}\n+\n+\tcase 'e':\n+\t{\n+\t\tstruct extern_obj *obj;\n+\n+\t\tf = extern_obj_mailbox_field_parse(p, name, &obj);\n+\t\tif (!f)\n+\t\t\treturn NULL;\n+\n+\t\t*struct_id = obj->struct_id;\n+\t\treturn f;\n+\t}\n+\n+\tcase 'f':\n+\t{\n+\t\tstruct extern_func *func;\n+\n+\t\tf = extern_func_mailbox_field_parse(p, name, &func);\n+\t\tif (!f)\n+\t\t\treturn NULL;\n+\n+\t\t*struct_id = func->struct_id;\n+\t\treturn f;\n+\t}\n+\n+\tdefault:\n+\t\treturn NULL;\n+\t}\n+}\n+\n static inline void\n pipeline_port_inc(struct rte_swx_pipeline *p)\n {\n@@ -2187,6 +2431,104 @@ instr_hdr_invalidate_exec(struct rte_swx_pipeline *p)\n \tthread_ip_inc(p);\n }\n \n+/*\n+ * mov.\n+ */\n+static int\n+instr_mov_translate(struct rte_swx_pipeline *p,\n+\t\t    struct action *action,\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 *dst = tokens[1], *src = tokens[2];\n+\tstruct field *fdst, *fsrc;\n+\tuint32_t dst_struct_id, src_struct_id, src_val;\n+\n+\tCHECK(n_tokens == 3, EINVAL);\n+\n+\tfdst = struct_field_parse(p, NULL, dst, &dst_struct_id);\n+\tCHECK(fdst, EINVAL);\n+\n+\t/* MOV or MOV_S. */\n+\tfsrc = struct_field_parse(p, action, src, &src_struct_id);\n+\tif (fsrc) {\n+\t\tinstr->type = INSTR_MOV;\n+\t\tif ((dst[0] == 'h' && src[0] != 'h') ||\n+\t\t    (dst[0] != 'h' && src[0] == 'h'))\n+\t\t\tinstr->type = INSTR_MOV_S;\n+\n+\t\tinstr->mov.dst.struct_id = (uint8_t)dst_struct_id;\n+\t\tinstr->mov.dst.n_bits = fdst->n_bits;\n+\t\tinstr->mov.dst.offset = fdst->offset / 8;\n+\t\tinstr->mov.src.struct_id = (uint8_t)src_struct_id;\n+\t\tinstr->mov.src.n_bits = fsrc->n_bits;\n+\t\tinstr->mov.src.offset = fsrc->offset / 8;\n+\t\treturn 0;\n+\t}\n+\n+\t/* MOV_I. */\n+\tsrc_val = strtoul(src, &src, 0);\n+\tCHECK(!src[0], EINVAL);\n+\n+\tif (dst[0] == 'h')\n+\t\tsrc_val = htonl(src_val);\n+\n+\tinstr->type = INSTR_MOV_I;\n+\tinstr->mov.dst.struct_id = (uint8_t)dst_struct_id;\n+\tinstr->mov.dst.n_bits = fdst->n_bits;\n+\tinstr->mov.dst.offset = fdst->offset / 8;\n+\tinstr->mov.src_val = (uint32_t)src_val;\n+\treturn 0;\n+}\n+\n+static inline void\n+instr_mov_exec(struct rte_swx_pipeline *p)\n+{\n+\tstruct thread *t = &p->threads[p->thread_id];\n+\tstruct instruction *ip = t->ip;\n+\n+\tTRACE(\"[Thread %2u] mov\\n\",\n+\t      p->thread_id);\n+\n+\tMOV(t, ip);\n+\n+\t/* Thread. */\n+\tthread_ip_inc(p);\n+}\n+\n+static inline void\n+instr_mov_s_exec(struct rte_swx_pipeline *p)\n+{\n+\tstruct thread *t = &p->threads[p->thread_id];\n+\tstruct instruction *ip = t->ip;\n+\n+\tTRACE(\"[Thread %2u] mov (s)\\n\",\n+\t      p->thread_id);\n+\n+\tMOV_S(t, ip);\n+\n+\t/* Thread. */\n+\tthread_ip_inc(p);\n+}\n+\n+static inline void\n+instr_mov_i_exec(struct rte_swx_pipeline *p)\n+{\n+\tstruct thread *t = &p->threads[p->thread_id];\n+\tstruct instruction *ip = t->ip;\n+\n+\tTRACE(\"[Thread %2u] mov m.f %x\\n\",\n+\t      p->thread_id,\n+\t      ip->mov.src_val);\n+\n+\tMOV_I(t, ip);\n+\n+\t/* Thread. */\n+\tthread_ip_inc(p);\n+}\n+\n #define RTE_SWX_INSTRUCTION_TOKENS_MAX 16\n \n static int\n@@ -2272,6 +2614,14 @@ instr_translate(struct rte_swx_pipeline *p,\n \t\t\t\t\t\t      instr,\n \t\t\t\t\t\t      data);\n \n+\tif (!strcmp(tokens[tpos], \"mov\"))\n+\t\treturn instr_mov_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@@ -2416,6 +2766,10 @@ static instr_exec_t instruction_table[] = {\n \n \t[INSTR_HDR_VALIDATE] = instr_hdr_validate_exec,\n \t[INSTR_HDR_INVALIDATE] = instr_hdr_invalidate_exec,\n+\n+\t[INSTR_MOV] = instr_mov_exec,\n+\t[INSTR_MOV_S] = instr_mov_s_exec,\n+\t[INSTR_MOV_I] = instr_mov_i_exec,\n };\n \n static inline void\n@@ -2446,6 +2800,21 @@ action_find(struct rte_swx_pipeline *p, const char *name)\n \treturn NULL;\n }\n \n+static struct field *\n+action_field_find(struct action *a, const char *name)\n+{\n+\treturn a->st ? struct_type_field_find(a->st, name) : NULL;\n+}\n+\n+static struct field *\n+action_field_parse(struct action *action, const char *name)\n+{\n+\tif (name[0] != 't' || name[1] != '.')\n+\t\treturn NULL;\n+\n+\treturn action_field_find(action, &name[2]);\n+}\n+\n int\n rte_swx_pipeline_action_config(struct rte_swx_pipeline *p,\n \t\t\t       const char *name,\n",
    "prefixes": [
        "v3",
        "12/41"
    ]
}