get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 55246,
    "url": "http://patches.dpdk.org/api/patches/55246/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20190624153736.127968-2-jackmin@mellanox.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": "<20190624153736.127968-2-jackmin@mellanox.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20190624153736.127968-2-jackmin@mellanox.com",
    "date": "2019-06-24T15:37:35",
    "name": "[1/2] app/testpmd: support raw encap/decap actions",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "aeeaa43fd33d228942e35fd282b222ca6d8c4f4e",
    "submitter": {
        "id": 1065,
        "url": "http://patches.dpdk.org/api/people/1065/?format=api",
        "name": "Xiaoyu Min",
        "email": "jackmin@mellanox.com"
    },
    "delegate": {
        "id": 319,
        "url": "http://patches.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20190624153736.127968-2-jackmin@mellanox.com/mbox/",
    "series": [
        {
            "id": 5133,
            "url": "http://patches.dpdk.org/api/series/5133/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=5133",
            "date": "2019-06-24T15:37:34",
            "name": "app/testpmd: support raw encap/decap actions",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/5133/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/55246/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/55246/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id CB7731BA8E;\n\tMon, 24 Jun 2019 17:37:45 +0200 (CEST)",
            "from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130])\n\tby dpdk.org (Postfix) with ESMTP id CE9421B9FC\n\tfor <dev@dpdk.org>; Mon, 24 Jun 2019 17:37:43 +0200 (CEST)"
        ],
        "From": "Xiaoyu Min <jackmin@mellanox.com>",
        "To": "Wenzhuo Lu <wenzhuo.lu@intel.com>, Jingjing Wu <jingjing.wu@intel.com>, \n\tBernard Iremonger <bernard.iremonger@intel.com>,\n\tAdrien Mazarguil <adrien.mazarguil@6wind.com>,\n\tJohn McNamara <john.mcnamara@intel.com>,\n\tMarko Kovacevic <marko.kovacevic@intel.com>",
        "Cc": "dev@dpdk.org",
        "Date": "Mon, 24 Jun 2019 23:37:35 +0800",
        "Message-Id": "<20190624153736.127968-2-jackmin@mellanox.com>",
        "X-Mailer": "git-send-email 2.21.0",
        "In-Reply-To": "<20190624153736.127968-1-jackmin@mellanox.com>",
        "References": "<20190624153736.127968-1-jackmin@mellanox.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH 1/2] app/testpmd: support raw encap/decap actions",
        "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\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "This patch intend to support\naction_raw_encap/decap [1] in a generic and convenient way.\n\nTwo new commands - set raw_encap, set raw_decap are introduced just\nlike the other commands for encap/decap, i.e. set vxlan.\n\nThese two commands have corresponding global buffers\nwhich can be used by PMD as the input buffer for raw encap/decap.\n\nThe commands use the rte_flow pattern syntax to help user build the\nraw buffer in a convenient way.\n\nA common way to use it:\n\n- encap matched egress packet with VxLAN tunnel:\ntestpmd> set raw_encap eth src is 10:11:22:33:44:55 / vlan tci is 1\n\t inner_type is 0x0800 / ipv4 / udp dst is 4789 / vxlan vni\n\t is 2 / end_set\ntestpmd> flow create 0 egress pattern eth / ipv4 / end actions\n\t raw_encap / end\n\n- decap l2 header and encap GRE tunnel on matched egress packet:\ntestpmd> set raw_decap eth / end_set\ntestpmd> set raw_encap eth dst is 10:22:33:44:55:66 / ipv4 / gre\n\t protocol is 0x0800 / end_set\ntestpmd> flow create 0 egress pattern eth / ipv4 / end actions\n\t raw_decap / raw_encap / end\n\n- decap VxLAN tunnel and encap l2 header on matched ingress packet:\ntestpmd> set raw_encap eth src is 10:11:22:33:44:55 type is 0x0800 /\n\t end_set\ntestpmd> set raw_decap eth / ipv4 / udp / vxlan / end_set\ntestpmd> flow create 0 ingress pattern eth / ipv4 / udp dst is 250 /\n         vxlan vni is 0x1234 / ipv4 / end actions raw_decap /\n         raw_encap / queue index 1 / mark id 0x1234 / end\n\n[1] http://mails.dpdk.org/archives/dev/2018-October/116092.html\n\nSigned-off-by: Xiaoyu Min <jackmin@mellanox.com>\n---\n app/test-pmd/cmdline.c                      |  13 +\n app/test-pmd/cmdline_flow.c                 | 536 +++++++++++++++++++-\n app/test-pmd/testpmd.h                      |   2 +\n doc/guides/testpmd_app_ug/testpmd_funcs.rst |  48 ++\n 4 files changed, 598 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c\nindex d1e0d4402c..3cbfdcd2c1 100644\n--- a/app/test-pmd/cmdline.c\n+++ b/app/test-pmd/cmdline.c\n@@ -760,6 +760,12 @@ static void cmd_help_long_parsed(void *parsed_result,\n \t\t\t\" eth-src (eth-src) eth-dst (eth-dst)\\n\"\n \t\t\t\"       Configure the NVGRE encapsulation for flows.\\n\\n\"\n \n+\t\t\t\"raw_encap {flow items}\"\n+\t\t\t\"\tConfigure the encapsulation with raw data.\\n\\n\"\n+\n+\t\t\t\"raw_decap {flow items}\"\n+\t\t\t\"\tConfigure the decapsulation with raw data.\\n\\n\"\n+\n \t\t\t, list_pkt_forwarding_modes()\n \t\t);\n \t}\n@@ -1137,6 +1143,12 @@ static void cmd_help_long_parsed(void *parsed_result,\n \t\t\t\"flow isolate {port_id} {boolean}\\n\"\n \t\t\t\"    Restrict ingress traffic to the defined\"\n \t\t\t\" flow rules\\n\\n\"\n+\n+\t\t\t\"set raw_encap {flow items}\\n\"\n+\t\t\t\"\tConfig encap with raw data.\\n\\n\"\n+\n+\t\t\t\"set raw_decap {flow items}\\n\"\n+\t\t\t\"\tConfig decap with raw data.\\n\\n\"\n \t\t);\n \t}\n \n@@ -18979,6 +18991,7 @@ cmdline_parse_ctx_t main_ctx[] = {\n #endif\n \t(cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,\n \t(cmdline_parse_inst_t *)&cmd_show_tx_metadata,\n+\t(cmdline_parse_inst_t *)&cmd_set_raw,\n \tNULL,\n };\n \ndiff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c\nindex 201bd9de56..e7da0fad2a 100644\n--- a/app/test-pmd/cmdline_flow.c\n+++ b/app/test-pmd/cmdline_flow.c\n@@ -28,6 +28,8 @@ enum index {\n \t/* Special tokens. */\n \tZERO = 0,\n \tEND,\n+\tSTART_SET,\n+\tEND_SET,\n \n \t/* Common tokens. */\n \tINTEGER,\n@@ -45,8 +47,13 @@ enum index {\n \tPRIORITY_LEVEL,\n \n \t/* Top-level command. */\n-\tFLOW,\n+\tSET,\n+\t/* Sub-leve commands. */\n+\tSET_RAW_ENCAP,\n+\tSET_RAW_DECAP,\n \n+\t/* Top-level command. */\n+\tFLOW,\n \t/* Sub-level commands. */\n \tVALIDATE,\n \tCREATE,\n@@ -272,6 +279,8 @@ enum index {\n \tACTION_SET_MAC_SRC_MAC_SRC,\n \tACTION_SET_MAC_DST,\n \tACTION_SET_MAC_DST_MAC_DST,\n+\tACTION_RAW_ENCAP,\n+\tACTION_RAW_DECAP,\n };\n \n /** Maximum size for pattern in struct rte_flow_item_raw. */\n@@ -294,6 +303,25 @@ struct action_rss_data {\n /** Maximum number of items in struct rte_flow_action_vxlan_encap. */\n #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6\n \n+#define ACTION_RAW_ENCAP_MAX_DATA 128\n+\n+/** Storage for struct rte_flow_action_raw_encap. */\n+struct raw_encap_data {\n+\tuint8_t data[ACTION_RAW_ENCAP_MAX_DATA];\n+\tuint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];\n+\tsize_t size;\n+};\n+\n+struct raw_encap_data raw_encap_data = {.size = 0};\n+\n+/** Storage for struct rte_flow_action_raw_decap. */\n+struct raw_decap_data {\n+\tuint8_t data[ACTION_RAW_ENCAP_MAX_DATA];\n+\tsize_t size;\n+};\n+\n+struct raw_decap_data raw_decap_data = {.size = 0};\n+\n /** Storage for struct rte_flow_action_vxlan_encap including external data. */\n struct action_vxlan_encap_data {\n \tstruct rte_flow_action_vxlan_encap conf;\n@@ -610,6 +638,7 @@ static const enum index next_item[] = {\n \tITEM_ICMP6_ND_OPT_SLA_ETH,\n \tITEM_ICMP6_ND_OPT_TLA_ETH,\n \tITEM_META,\n+\tEND_SET,\n \tZERO,\n };\n \n@@ -885,6 +914,8 @@ static const enum index next_action[] = {\n \tACTION_SET_TTL,\n \tACTION_SET_MAC_SRC,\n \tACTION_SET_MAC_DST,\n+\tACTION_RAW_ENCAP,\n+\tACTION_RAW_DECAP,\n \tZERO,\n };\n \n@@ -1047,6 +1078,12 @@ static const enum index action_set_mac_dst[] = {\n \tZERO,\n };\n \n+static int parse_set_raw_encap_decap(struct context *, const struct token *,\n+\t\t\t\t     const char *, unsigned int,\n+\t\t\t\t     void *, unsigned int);\n+static int parse_set_init(struct context *, const struct token *,\n+\t\t\t  const char *, unsigned int,\n+\t\t\t  void *, unsigned int);\n static int parse_init(struct context *, const struct token *,\n \t\t      const char *, unsigned int,\n \t\t      void *, unsigned int);\n@@ -1093,6 +1130,12 @@ static int parse_vc_action_mplsoudp_encap(struct context *,\n static int parse_vc_action_mplsoudp_decap(struct context *,\n \t\t\t\t\t  const struct token *, const char *,\n \t\t\t\t\t  unsigned int, void *, unsigned int);\n+static int parse_vc_action_raw_encap(struct context *,\n+\t\t\t\t     const struct token *, const char *,\n+\t\t\t\t     unsigned int, void *, unsigned int);\n+static int parse_vc_action_raw_decap(struct context *,\n+\t\t\t\t     const struct token *, const char *,\n+\t\t\t\t     unsigned int, void *, unsigned int);\n static int parse_destroy(struct context *, const struct token *,\n \t\t\t const char *, unsigned int,\n \t\t\t void *, unsigned int);\n@@ -1166,6 +1209,16 @@ static const struct token token_list[] = {\n \t\t.type = \"RETURN\",\n \t\t.help = \"command may end here\",\n \t},\n+\t[START_SET] = {\n+\t\t.name = \"START_SET\",\n+\t\t.help = \"null entry, abused as the entry point for set\",\n+\t\t.next = NEXT(NEXT_ENTRY(SET)),\n+\t},\n+\t[END_SET] = {\n+\t\t.name = \"end_set\",\n+\t\t.type = \"RETURN\",\n+\t\t.help = \"set command may end here\",\n+\t},\n \t/* Common tokens. */\n \t[INTEGER] = {\n \t\t.name = \"{int}\",\n@@ -2854,6 +2907,46 @@ static const struct token token_list[] = {\n \t\t\t     (struct rte_flow_action_set_mac, mac_addr)),\n \t\t.call = parse_vc_conf,\n \t},\n+\t[ACTION_RAW_ENCAP] = {\n+\t\t.name = \"raw_encap\",\n+\t\t.help = \"encapsulation data, defined by set raw_encap\",\n+\t\t.priv = PRIV_ACTION(RAW_ENCAP,\n+\t\t\tsizeof(struct rte_flow_action_raw_encap)),\n+\t\t.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),\n+\t\t.call = parse_vc_action_raw_encap,\n+\t},\n+\t[ACTION_RAW_DECAP] = {\n+\t\t.name = \"raw_decap\",\n+\t\t.help = \"decapsulation data, defined by set raw_encap\",\n+\t\t.priv = PRIV_ACTION(RAW_DECAP,\n+\t\t\tsizeof(struct rte_flow_action_raw_decap)),\n+\t\t.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),\n+\t\t.call = parse_vc_action_raw_decap,\n+\t},\n+\t/* Top level command. */\n+\t[SET] = {\n+\t\t.name = \"set\",\n+\t\t.help = \"set raw encap/decap data\",\n+\t\t.type = \"set raw_encap|raw_decap <pattern>\",\n+\t\t.next = NEXT(NEXT_ENTRY\n+\t\t\t     (SET_RAW_ENCAP,\n+\t\t\t      SET_RAW_DECAP)),\n+\t\t.call = parse_set_init,\n+\t},\n+\t/* Sub-level commands. */\n+\t[SET_RAW_ENCAP] = {\n+\t\t.name = \"raw_encap\",\n+\t\t.help = \"set raw encap data\",\n+\t\t.next = NEXT(next_item),\n+\t\t.call = parse_set_raw_encap_decap,\n+\t},\n+\t[SET_RAW_DECAP] = {\n+\t\t.name = \"raw_decap\",\n+\t\t.help = \"set raw decap data\",\n+\t\t.next = NEXT(next_item),\n+\t\t.call = parse_set_raw_encap_decap,\n+\t}\n+\n };\n \n /** Remove and return last entry from argument stack. */\n@@ -4140,6 +4233,75 @@ parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,\n \treturn ret;\n }\n \n+static int\n+parse_vc_action_raw_encap(struct context *ctx, const struct token *token,\n+\t\t\t  const char *str, unsigned int len, void *buf,\n+\t\t\t  unsigned int size)\n+{\n+\tstruct buffer *out = buf;\n+\tstruct rte_flow_action *action;\n+\tstruct rte_flow_action_raw_encap *raw_encap_conf = NULL;\n+\tuint8_t *data = NULL;\n+\tint ret;\n+\n+\tret = parse_vc(ctx, token, str, len, buf, size);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\t/* Nothing else to do if there is no buffer. */\n+\tif (!out)\n+\t\treturn ret;\n+\tif (!out->args.vc.actions_n)\n+\t\treturn -1;\n+\taction = &out->args.vc.actions[out->args.vc.actions_n - 1];\n+\t/* Point to selected object. */\n+\tctx->object = out->args.vc.data;\n+\tctx->objmask = NULL;\n+\t/* Copy the headers to the buffer. */\n+\traw_encap_conf = ctx->object;\n+\t/* data stored from tail of data buffer */\n+\tdata = (uint8_t *)&(raw_encap_data.data) +\n+\t\tACTION_RAW_ENCAP_MAX_DATA - raw_encap_data.size;\n+\traw_encap_conf->data = data;\n+\traw_encap_conf->preserve = NULL;\n+\traw_encap_conf->size = raw_encap_data.size;\n+\taction->conf = raw_encap_conf;\n+\treturn ret;\n+}\n+\n+static int\n+parse_vc_action_raw_decap(struct context *ctx, const struct token *token,\n+\t\t\t  const char *str, unsigned int len, void *buf,\n+\t\t\t  unsigned int size)\n+{\n+\tstruct buffer *out = buf;\n+\tstruct rte_flow_action *action;\n+\tstruct rte_flow_action_raw_decap *raw_decap_conf = NULL;\n+\tuint8_t *data = NULL;\n+\tint ret;\n+\n+\tret = parse_vc(ctx, token, str, len, buf, size);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\t/* Nothing else to do if there is no buffer. */\n+\tif (!out)\n+\t\treturn ret;\n+\tif (!out->args.vc.actions_n)\n+\t\treturn -1;\n+\taction = &out->args.vc.actions[out->args.vc.actions_n - 1];\n+\t/* Point to selected object. */\n+\tctx->object = out->args.vc.data;\n+\tctx->objmask = NULL;\n+\t/* Copy the headers to the buffer. */\n+\traw_decap_conf = ctx->object;\n+\t/* data stored from tail of data buffer */\n+\tdata = (uint8_t *)&(raw_decap_data.data) +\n+\t\tACTION_RAW_ENCAP_MAX_DATA - raw_decap_data.size;\n+\traw_decap_conf->data = data;\n+\traw_decap_conf->size = raw_decap_data.size;\n+\taction->conf = raw_decap_conf;\n+\treturn ret;\n+}\n+\n /** Parse tokens for destroy command. */\n static int\n parse_destroy(struct context *ctx, const struct token *token,\n@@ -4796,6 +4958,73 @@ parse_port(struct context *ctx, const struct token *token,\n \treturn ret;\n }\n \n+/** Parse set command, initialize output buffer for subsequent tokens. */\n+static int\n+parse_set_raw_encap_decap(struct context *ctx, const struct token *token,\n+\t\t\t  const char *str, unsigned int len,\n+\t\t\t  void *buf, unsigned int size)\n+{\n+\tstruct buffer *out = buf;\n+\n+\t/* Token name must match. */\n+\tif (parse_default(ctx, token, str, len, NULL, 0) < 0)\n+\t\treturn -1;\n+\t/* Nothing else to do if there is no buffer. */\n+\tif (!out)\n+\t\treturn len;\n+\t/* Make sure buffer is large enough. */\n+\tif (size < sizeof(*out))\n+\t\treturn -1;\n+\tctx->objdata = 0;\n+\tctx->objmask = NULL;\n+\tif (!out->command)\n+\t\treturn -1;\n+\tout->command = ctx->curr;\n+\treturn len;\n+}\n+\n+/**\n+ * Parse set raw_encap/raw_decap command,\n+ * initialize output buffer for subsequent tokens.\n+ */\n+static int\n+parse_set_init(struct context *ctx, const struct token *token,\n+\t       const char *str, unsigned int len,\n+\t       void *buf, unsigned int size)\n+{\n+\tstruct buffer *out = buf;\n+\n+\t/* Token name must match. */\n+\tif (parse_default(ctx, token, str, len, NULL, 0) < 0)\n+\t\treturn -1;\n+\t/* Nothing else to do if there is no buffer. */\n+\tif (!out)\n+\t\treturn len;\n+\t/* Make sure buffer is large enough. */\n+\tif (size < sizeof(*out))\n+\t\treturn -1;\n+\t/* Initialize buffer. */\n+\tmemset(out, 0x00, sizeof(*out));\n+\tmemset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));\n+\tctx->objdata = 0;\n+\tctx->object = out;\n+\tctx->objmask = NULL;\n+\tif (!out->command) {\n+\t\tif (ctx->curr != SET)\n+\t\t\treturn -1;\n+\t\tif (sizeof(*out) > size)\n+\t\t\treturn -1;\n+\t\tout->command = ctx->curr;\n+\t\tout->args.vc.data = (uint8_t *)out + size;\n+\t\t/* All we need is pattern */\n+\t\tout->args.vc.pattern =\n+\t\t\t(void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),\n+\t\t\t\t\t       sizeof(double));\n+\t\tctx->object = out->args.vc.pattern;\n+\t}\n+\treturn len;\n+}\n+\n /** No completion. */\n static int\n comp_none(struct context *ctx, const struct token *token,\n@@ -4929,6 +5158,7 @@ static struct context cmd_flow_context;\n \n /** Global parser instance (cmdline API). */\n cmdline_parse_inst_t cmd_flow;\n+cmdline_parse_inst_t cmd_set_raw;\n \n /** Initialize context. */\n static void\n@@ -5208,3 +5438,307 @@ cmdline_parse_inst_t cmd_flow = {\n \t\tNULL,\n \t}, /**< Tokens are returned by cmd_flow_tok(). */\n };\n+\n+/** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */\n+\n+static void\n+update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)\n+{\n+\tstruct rte_flow_item_ipv4 *ipv4;\n+\tstruct rte_flow_item_eth *eth;\n+\tstruct rte_flow_item_ipv6 *ipv6;\n+\tstruct rte_flow_item_vxlan *vxlan;\n+\tstruct rte_flow_item_vxlan_gpe *gpe;\n+\tstruct rte_flow_item_nvgre *nvgre;\n+\tuint32_t ipv6_vtc_flow;\n+\n+\tswitch (item->type) {\n+\tcase RTE_FLOW_ITEM_TYPE_ETH:\n+\t\teth = (struct rte_flow_item_eth *)buf;\n+\t\tif (next_proto)\n+\t\t\teth->type = rte_cpu_to_be_16(next_proto);\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_IPV4:\n+\t\tipv4 = (struct rte_flow_item_ipv4 *)buf;\n+\t\tipv4->hdr.version_ihl = 0x45;\n+\t\tipv4->hdr.next_proto_id = (uint8_t)next_proto;\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_IPV6:\n+\t\tipv6 = (struct rte_flow_item_ipv6 *)buf;\n+\t\tipv6->hdr.proto = (uint8_t)next_proto;\n+\t\tipv6_vtc_flow = rte_be_to_cpu_32(ipv6->hdr.vtc_flow);\n+\t\tipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */\n+\t\tipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */\n+\t\tipv6->hdr.vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_VXLAN:\n+\t\tvxlan = (struct rte_flow_item_vxlan *)buf;\n+\t\tvxlan->flags = 0x08;\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_VXLAN_GPE:\n+\t\tgpe = (struct rte_flow_item_vxlan_gpe *)buf;\n+\t\tgpe->flags = 0x0C;\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_NVGRE:\n+\t\tnvgre = (struct rte_flow_item_nvgre *)buf;\n+\t\tnvgre->protocol = rte_cpu_to_be_16(0x6558);\n+\t\tnvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);\n+\t\tbreak;\n+\tdefault:\n+\t\tbreak;\n+\t}\n+}\n+\n+/** Helper of get item's default mask. */\n+static const void *\n+flow_item_default_mask(const struct rte_flow_item *item)\n+{\n+\tconst void *mask = NULL;\n+\n+\tswitch (item->type) {\n+\tcase RTE_FLOW_ITEM_TYPE_ANY:\n+\t\tmask = &rte_flow_item_any_mask;\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_VF:\n+\t\tmask = &rte_flow_item_vf_mask;\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_PORT_ID:\n+\t\tmask = &rte_flow_item_port_id_mask;\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_RAW:\n+\t\tmask = &rte_flow_item_raw_mask;\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_ETH:\n+\t\tmask = &rte_flow_item_eth_mask;\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_VLAN:\n+\t\tmask = &rte_flow_item_vlan_mask;\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_IPV4:\n+\t\tmask = &rte_flow_item_ipv4_mask;\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_IPV6:\n+\t\tmask = &rte_flow_item_ipv6_mask;\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_ICMP:\n+\t\tmask = &rte_flow_item_icmp_mask;\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_UDP:\n+\t\tmask = &rte_flow_item_udp_mask;\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_TCP:\n+\t\tmask = &rte_flow_item_tcp_mask;\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_SCTP:\n+\t\tmask = &rte_flow_item_sctp_mask;\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_VXLAN:\n+\t\tmask = &rte_flow_item_vxlan_mask;\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_VXLAN_GPE:\n+\t\tmask = &rte_flow_item_vxlan_gpe_mask;\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_E_TAG:\n+\t\tmask = &rte_flow_item_e_tag_mask;\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_NVGRE:\n+\t\tmask = &rte_flow_item_nvgre_mask;\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_MPLS:\n+\t\tmask = &rte_flow_item_mpls_mask;\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_GRE:\n+\t\tmask = &rte_flow_item_gre_mask;\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_META:\n+\t\tmask = &rte_flow_item_meta_mask;\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_FUZZY:\n+\t\tmask = &rte_flow_item_fuzzy_mask;\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_GTP:\n+\t\tmask = &rte_flow_item_gtp_mask;\n+\t\tbreak;\n+\tcase RTE_FLOW_ITEM_TYPE_ESP:\n+\t\tmask = &rte_flow_item_esp_mask;\n+\t\tbreak;\n+\tdefault:\n+\t\tbreak;\n+\t}\n+\treturn mask;\n+}\n+\n+\n+\n+/** Dispatch parsed buffer to function calls. */\n+static void\n+cmd_set_raw_parsed(const struct buffer *in)\n+{\n+\tuint32_t n = in->args.vc.pattern_n;\n+\tint i = 0;\n+\tstruct rte_flow_item *item = NULL;\n+\tsize_t size = 0;\n+\tuint8_t *data = NULL;\n+\tuint8_t *data_tail = NULL;\n+\tsize_t *total_size = NULL;\n+\tuint16_t upper_layer = 0;\n+\tuint16_t proto = 0;\n+\n+\tRTE_ASSERT(in->command == SET_RAW_ENCAP ||\n+\t\t   in->command == SET_RAW_DECAP);\n+\tif (in->command == SET_RAW_ENCAP) {\n+\t\ttotal_size = &raw_encap_data.size;\n+\t\tdata = (uint8_t *)&raw_encap_data.data;\n+\t} else {\n+\t\ttotal_size = &raw_decap_data.size;\n+\t\tdata = (uint8_t *)&raw_decap_data.data;\n+\t}\n+\t*total_size = 0;\n+\tmemset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);\n+\t/* process hdr from upper layer to low layer (L3/L4 -> L2). */\n+\tdata_tail = data + ACTION_RAW_ENCAP_MAX_DATA;\n+\tfor (i = n - 1 ; i >= 0; --i) {\n+\t\titem = in->args.vc.pattern + i;\n+\t\tif (item->spec == NULL)\n+\t\t\titem->spec = flow_item_default_mask(item);\n+\t\tswitch (item->type) {\n+\t\tcase RTE_FLOW_ITEM_TYPE_ETH:\n+\t\t\tsize = sizeof(struct rte_flow_item_eth);\n+\t\t\tbreak;\n+\t\tcase RTE_FLOW_ITEM_TYPE_VLAN:\n+\t\t\tsize = sizeof(struct rte_flow_item_vlan);\n+\t\t\tproto = RTE_ETHER_TYPE_VLAN;\n+\t\t\tbreak;\n+\t\tcase RTE_FLOW_ITEM_TYPE_IPV4:\n+\t\t\tsize = sizeof(struct rte_flow_item_ipv4);\n+\t\t\tproto = RTE_ETHER_TYPE_IPV4;\n+\t\t\tbreak;\n+\t\tcase RTE_FLOW_ITEM_TYPE_IPV6:\n+\t\t\tsize = sizeof(struct rte_flow_item_ipv6);\n+\t\t\tproto = RTE_ETHER_TYPE_IPV6;\n+\t\t\tbreak;\n+\t\tcase RTE_FLOW_ITEM_TYPE_UDP:\n+\t\t\tsize = sizeof(struct rte_flow_item_udp);\n+\t\t\tproto = 0x11;\n+\t\t\tbreak;\n+\t\tcase RTE_FLOW_ITEM_TYPE_TCP:\n+\t\t\tsize = sizeof(struct rte_flow_item_tcp);\n+\t\t\tproto = 0x06;\n+\t\t\tbreak;\n+\t\tcase RTE_FLOW_ITEM_TYPE_VXLAN:\n+\t\t\tsize = sizeof(struct rte_flow_item_vxlan);\n+\t\t\tbreak;\n+\t\tcase RTE_FLOW_ITEM_TYPE_VXLAN_GPE:\n+\t\t\tsize = sizeof(struct rte_flow_item_vxlan_gpe);\n+\t\t\tbreak;\n+\t\tcase RTE_FLOW_ITEM_TYPE_GRE:\n+\t\t\tsize = sizeof(struct rte_flow_item_gre);\n+\t\t\tproto = 0x2F;\n+\t\t\tbreak;\n+\t\tcase RTE_FLOW_ITEM_TYPE_MPLS:\n+\t\t\tsize = sizeof(struct rte_flow_item_mpls);\n+\t\t\tbreak;\n+\t\tcase RTE_FLOW_ITEM_TYPE_NVGRE:\n+\t\t\tsize = sizeof(struct rte_flow_item_nvgre);\n+\t\t\tproto = 0x2F;\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tprintf(\"Error - Not supported item\\n\");\n+\t\t\t*total_size = 0;\n+\t\t\tmemset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);\n+\t\t\treturn;\n+\t\t}\n+\t\t*total_size += size;\n+\t\trte_memcpy(data_tail - (*total_size), item->spec, size);\n+\t\t/* update some fields which cannot be set by cmdline */\n+\t\tupdate_fields((data_tail - (*total_size)), item,\n+\t\t\t      upper_layer);\n+\t\tupper_layer = proto;\n+\t}\n+\tif (verbose_level & 0x1)\n+\t\tprintf(\"total data size is %zu\\n\", (*total_size));\n+\tRTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);\n+}\n+\n+/** Populate help strings for current token (cmdline API). */\n+static int\n+cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,\n+\t\t     unsigned int size)\n+{\n+\tstruct context *ctx = &cmd_flow_context;\n+\tconst struct token *token = &token_list[ctx->prev];\n+\n+\t(void)hdr;\n+\tif (!size)\n+\t\treturn -1;\n+\t/* Set token type and update global help with details. */\n+\tsnprintf(dst, size, \"%s\", (token->type ? token->type : \"TOKEN\"));\n+\tif (token->help)\n+\t\tcmd_set_raw.help_str = token->help;\n+\telse\n+\t\tcmd_set_raw.help_str = token->name;\n+\treturn 0;\n+}\n+\n+/** Token definition template (cmdline API). */\n+static struct cmdline_token_hdr cmd_set_raw_token_hdr = {\n+\t.ops = &(struct cmdline_token_ops){\n+\t\t.parse = cmd_flow_parse,\n+\t\t.complete_get_nb = cmd_flow_complete_get_nb,\n+\t\t.complete_get_elt = cmd_flow_complete_get_elt,\n+\t\t.get_help = cmd_set_raw_get_help,\n+\t},\n+\t.offset = 0,\n+};\n+\n+/** Populate the next dynamic token. */\n+static void\n+cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,\n+\t     cmdline_parse_token_hdr_t **hdr_inst)\n+{\n+\tstruct context *ctx = &cmd_flow_context;\n+\n+\t/* Always reinitialize context before requesting the first token. */\n+\tif (!(hdr_inst - cmd_set_raw.tokens)) {\n+\t\tcmd_flow_context_init(ctx);\n+\t\tctx->curr = START_SET;\n+\t}\n+\t/* Return NULL when no more tokens are expected. */\n+\tif (!ctx->next_num && (ctx->curr != START_SET)) {\n+\t\t*hdr = NULL;\n+\t\treturn;\n+\t}\n+\t/* Determine if command should end here. */\n+\tif (ctx->eol && ctx->last && ctx->next_num) {\n+\t\tconst enum index *list = ctx->next[ctx->next_num - 1];\n+\t\tint i;\n+\n+\t\tfor (i = 0; list[i]; ++i) {\n+\t\t\tif (list[i] != END)\n+\t\t\t\tcontinue;\n+\t\t\t*hdr = NULL;\n+\t\t\treturn;\n+\t\t}\n+\t}\n+\t*hdr = &cmd_set_raw_token_hdr;\n+}\n+\n+/** Token generator and output processing callback (cmdline API). */\n+static void\n+cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)\n+{\n+\tif (cl == NULL)\n+\t\tcmd_set_raw_tok(arg0, arg2);\n+\telse\n+\t\tcmd_set_raw_parsed(arg0);\n+}\n+\n+/** Global parser instance (cmdline API). */\n+cmdline_parse_inst_t cmd_set_raw = {\n+\t.f = cmd_set_raw_cb,\n+\t.data = NULL, /**< Unused. */\n+\t.help_str = NULL, /**< Updated by cmd_flow_get_help(). */\n+\t.tokens = {\n+\t\tNULL,\n+\t}, /**< Tokens are returned by cmd_flow_tok(). */\n+};\ndiff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h\nindex e3a6f7c717..ba04c3ba53 100644\n--- a/app/test-pmd/testpmd.h\n+++ b/app/test-pmd/testpmd.h\n@@ -11,6 +11,7 @@\n #include <rte_bus_pci.h>\n #include <rte_gro.h>\n #include <rte_gso.h>\n+#include <cmdline.h>\n \n #define RTE_PORT_ALL            (~(portid_t)0x0)\n \n@@ -263,6 +264,7 @@ extern struct fwd_engine ieee1588_fwd_engine;\n #endif\n \n extern struct fwd_engine * fwd_engines[]; /**< NULL terminated array. */\n+extern cmdline_parse_inst_t cmd_set_raw;\n \n extern uint16_t mempool_flags;\n \ndiff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst\nindex cb83a3ce8a..a0c10367ab 100644\n--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst\n+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst\n@@ -1815,6 +1815,30 @@ flow rule using the action mplsoudp_decap will use the last configuration set.\n To have a different decapsulation header, one of those commands must be called\n before the flow rule creation.\n \n+Config Raw Encapsulation\n+~~~~~~~~~~~~~~~~~~~~~~~~~\n+\n+Configure the raw data to be used when encapsulating a packet by\n+rte_flow_action_raw_encap::\n+\n+ set raw_encap {item} [/ {item} [...]] / end_set\n+\n+This command will set an internal buffer inside testpmd, any following flow rule\n+using the action raw_encap will use the last configuration set.\n+To have a different encapsulation header, this command must be called before the\n+flow rule creation.\n+\n+Config Raw Decapsulation\n+~~~~~~~~~~~~~~~~~~~~~~~~\n+\n+Configure the raw data to be used when decapsulating a packet by\n+rte_flow_action_raw_decap::\n+\n+ set raw_decap {item} [/ {item} [...]] / end_set\n+\n+This command will set an internal buffer inside testpmd, any following flow rule\n+using the action raw_decap will use the last configuration set.\n+\n Port Functions\n --------------\n \n@@ -4620,6 +4644,30 @@ IPv6 MPLSoUDP with VLAN outer header::\n  testpmd> flow create 0 ingress pattern eth / vlan / ipv6 / udp / mpls / end\n         actions mplsoudp_decap / l2_encap / end\n \n+Sample Raw encapsulation rule\n+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n+\n+Raw encapsulation configuration can be set by the following commands\n+\n+Eecapsulating VxLAN::\n+\n+ testpmd> set raw_encap eth src is 10:11:22:33:44:55 / vlan tci is 1\n+        inner_type is 0x0800 / ipv4 / udp dst is 4789 / vxlan vni\n+        is 2 / end_set\n+ testpmd> flow create 0 egress pattern eth / ipv4 / end actions\n+        raw_encap / end\n+\n+Sample Raw decapsulation rule\n+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n+\n+Raw decapsulation configuration can be set by the following commands\n+\n+Decapsulating VxLAN::\n+\n+ testpmd> set raw_decap eth / ipv4 / udp / vxlan / end_set\n+ testpmd> flow create 0 ingress pattern eth / ipv4 / udp / vxlan / eth / ipv4 /\n+        end actions raw_decap / queue index 0 / end\n+\n BPF Functions\n --------------\n \n",
    "prefixes": [
        "1/2"
    ]
}