get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 91556,
    "url": "https://patches.dpdk.org/api/patches/91556/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20210415092023.2089541-3-lizh@nvidia.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": "<20210415092023.2089541-3-lizh@nvidia.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210415092023.2089541-3-lizh@nvidia.com",
    "date": "2021-04-15T09:20:23",
    "name": "[v8,2/2] app/testpmd: support policy actions per color",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "8ba33728ae3b932ee3939cce466758d71041ada7",
    "submitter": {
        "id": 1967,
        "url": "https://patches.dpdk.org/api/people/1967/?format=api",
        "name": "Li Zhang",
        "email": "lizh@nvidia.com"
    },
    "delegate": {
        "id": 319,
        "url": "https://patches.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20210415092023.2089541-3-lizh@nvidia.com/mbox/",
    "series": [
        {
            "id": 16404,
            "url": "https://patches.dpdk.org/api/series/16404/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=16404",
            "date": "2021-04-15T09:20:21",
            "name": "Support meter policy API",
            "version": 8,
            "mbox": "https://patches.dpdk.org/series/16404/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/91556/comments/",
    "check": "fail",
    "checks": "https://patches.dpdk.org/api/patches/91556/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 3EC35A0A0E;\n\tThu, 15 Apr 2021 11:20:38 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id DCB41162160;\n\tThu, 15 Apr 2021 11:20:34 +0200 (CEST)",
            "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n by mails.dpdk.org (Postfix) with ESMTP id A619A16213F\n for <dev@dpdk.org>; Thu, 15 Apr 2021 11:20:31 +0200 (CEST)",
            "from Internal Mail-Server by MTLPINE1 (envelope-from\n lizh@nvidia.com)\n with SMTP; 15 Apr 2021 12:20:27 +0300",
            "from nvidia.com (c-235-17-1-009.mtl.labs.mlnx [10.235.17.9])\n by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 13F9KRhu026624;\n Thu, 15 Apr 2021 12:20:27 +0300"
        ],
        "From": "Li Zhang <lizh@nvidia.com>",
        "To": "dekelp@nvidia.com, orika@nvidia.com, viacheslavo@nvidia.com,\n matan@nvidia.com, shahafs@nvidia.com, cristian.dumitrescu@intel.com,\n lironh@marvell.com, jerinj@marvell.com, ferruh.yigit@intel.com,\n ajit.khaparde@broadcom.com, Xiaoyun Li <xiaoyun.li@intel.com>",
        "Cc": "dev@dpdk.org, thomas@monjalon.net, rasland@nvidia.com, roniba@nvidia.com,\n Haifei Luo <haifeil@nvidia.com>",
        "Date": "Thu, 15 Apr 2021 12:20:23 +0300",
        "Message-Id": "<20210415092023.2089541-3-lizh@nvidia.com>",
        "X-Mailer": "git-send-email 2.21.0",
        "In-Reply-To": "<20210415092023.2089541-1-lizh@nvidia.com>",
        "References": "<20210318085815.804896-1-lizh@nvidia.com>\n <20210415092023.2089541-1-lizh@nvidia.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v8 2/2] app/testpmd: support policy actions per\n color",
        "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",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "From: Haifei Luo <haifeil@nvidia.com>\n\nAdd the create/del policy CLIs to support actions per color.\nThe CLIs are:\nCreate:  add port meter policy (port_id) (policy_id) g_actions (actions)\ny_actions (actions) r_actions (actions)\nDelete:  del port meter policy (port_id) (policy_id)\n\nExamples:\ntestpmd> add port meter policy 0 1 g_actions rss / end y_actions end\nr_actions drop / end\ntestpmd> del port meter policy 0 1\n\nSigned-off-by: Haifei Luo <haifeil@nvidia.com>\nAcked-by: Matan Azrad <matan@nvidia.com>\n---\n app/test-pmd/cmdline.c                      |  13 ++-\n app/test-pmd/cmdline_flow.c                 | 118 +++++++++++++++++++-\n app/test-pmd/cmdline_mtr.c                  |  85 +++++++++++++-\n app/test-pmd/cmdline_mtr.h                  |   3 +\n app/test-pmd/config.c                       |  32 ++++++\n app/test-pmd/testpmd.h                      |   2 +\n doc/guides/testpmd_app_ug/testpmd_funcs.rst |  30 ++++-\n 7 files changed, 269 insertions(+), 14 deletions(-)",
    "diff": "diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c\nindex e244df27dc..35452dba86 100644\n--- a/app/test-pmd/cmdline.c\n+++ b/app/test-pmd/cmdline.c\n@@ -705,9 +705,8 @@ static void cmd_help_long_parsed(void *parsed_result,\n \t\t\t\"del port meter profile (port_id) (profile_id)\\n\"\n \t\t\t\"    meter profile delete\\n\\n\"\n \n-\t\t\t\"create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\\n\"\n-\t\t\t\"(g_action) (y_action) (r_action) (stats_mask) (shared)\\n\"\n-\t\t\t\"(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\\n\"\n+\t\t\t\"create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\\n\"\n+\t\t\t\"(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\\n\"\n \t\t\t\"(dscp_tbl_entry63)]\\n\"\n \t\t\t\"    meter create\\n\\n\"\n \n@@ -720,6 +719,13 @@ static void cmd_help_long_parsed(void *parsed_result,\n \t\t\t\"del port meter (port_id) (mtr_id)\\n\"\n \t\t\t\"    meter delete\\n\\n\"\n \n+\t\t\t\"add port meter policy (port_id) (policy_id) g_actions (actions)\\n\"\n+\t\t\t\"y_actions (actions) r_actions (actions)\\n\"\n+\t\t\t\"    meter policy add\\n\\n\"\n+\n+\t\t\t\"del port meter policy (port_id) (policy_id)\\n\"\n+\t\t\t\"    meter policy delete\\n\\n\"\n+\n \t\t\t\"set port meter profile (port_id) (mtr_id) (profile_id)\\n\"\n \t\t\t\"    meter update meter profile\\n\\n\"\n \n@@ -17072,6 +17078,7 @@ cmdline_parse_ctx_t main_ctx[] = {\n \t(cmdline_parse_inst_t *)&cmd_enable_port_meter,\n \t(cmdline_parse_inst_t *)&cmd_disable_port_meter,\n \t(cmdline_parse_inst_t *)&cmd_del_port_meter,\n+\t(cmdline_parse_inst_t *)&cmd_del_port_meter_policy,\n \t(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,\n \t(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,\n \t(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,\ndiff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c\nindex 0127d9e7d6..1d69eb9c9d 100644\n--- a/app/test-pmd/cmdline_flow.c\n+++ b/app/test-pmd/cmdline_flow.c\n@@ -55,6 +55,10 @@ enum index {\n \tGROUP_ID,\n \tPRIORITY_LEVEL,\n \tSHARED_ACTION_ID,\n+\tPOLICY_ID,\n+\n+\t/* TOP-level command. */\n+\tADD,\n \n \t/* Top-level command. */\n \tSET,\n@@ -293,6 +297,9 @@ enum index {\n \tITEM_GENEVE_OPT_TYPE,\n \tITEM_GENEVE_OPT_LENGTH,\n \tITEM_GENEVE_OPT_DATA,\n+\tITEM_POL_PORT,\n+\tITEM_POL_METER,\n+\tITEM_POL_POLICY,\n \n \t/* Validate/create actions. */\n \tACTIONS,\n@@ -431,6 +438,9 @@ enum index {\n \tACTION_MODIFY_FIELD_SRC_OFFSET,\n \tACTION_MODIFY_FIELD_SRC_VALUE,\n \tACTION_MODIFY_FIELD_WIDTH,\n+\tACTION_POL_G,\n+\tACTION_POL_Y,\n+\tACTION_POL_R,\n };\n \n /** Maximum size for pattern in struct rte_flow_item_raw. */\n@@ -814,6 +824,9 @@ struct buffer {\n \t\tstruct {\n \t\t\tint destroy;\n \t\t} aged; /**< Aged arguments. */\n+\t\tstruct {\n+\t\t\tuint32_t policy_id;\n+\t\t} policy;/**< Policy arguments. */\n \t} args; /**< Command arguments. */\n };\n \n@@ -1797,6 +1810,9 @@ static int parse_ipv6_addr(struct context *, const struct token *,\n static int parse_port(struct context *, const struct token *,\n \t\t      const char *, unsigned int,\n \t\t      void *, unsigned int);\n+static int parse_mp(struct context *, const struct token *,\n+\t\t\tconst char *, unsigned int,\n+\t\t\tvoid *, unsigned int);\n static int parse_sa(struct context *, const struct token *,\n \t\t    const char *, unsigned int,\n \t\t    void *, unsigned int);\n@@ -1835,7 +1851,7 @@ static const struct token token_list[] = {\n \t[ZERO] = {\n \t\t.name = \"ZERO\",\n \t\t.help = \"null entry, abused as the entry point\",\n-\t\t.next = NEXT(NEXT_ENTRY(FLOW)),\n+\t\t.next = NEXT(NEXT_ENTRY(FLOW, ADD)),\n \t},\n \t[END] = {\n \t\t.name = \"\",\n@@ -1957,6 +1973,13 @@ static const struct token token_list[] = {\n \t\t.call = parse_int,\n \t\t.comp = comp_none,\n \t},\n+\t[POLICY_ID] = {\n+\t\t.name = \"{policy_id}\",\n+\t\t.type = \"POLCIY_ID\",\n+\t\t.help = \"policy id\",\n+\t\t.call = parse_int,\n+\t\t.comp = comp_none,\n+\t},\n \t/* Top-level command. */\n \t[FLOW] = {\n \t\t.name = \"flow\",\n@@ -4555,6 +4578,54 @@ static const struct token token_list[] = {\n \t\t.help = \"specify action to share\",\n \t\t.next = NEXT(next_action),\n \t},\n+\t[ACTION_POL_G] = {\n+\t\t.name = \"g_actions\",\n+\t\t.help = \"submit a list of associated actions for green\",\n+\t\t.next = NEXT(next_action),\n+\t\t.call = parse_mp,\n+\t},\n+\t[ACTION_POL_Y] = {\n+\t\t.name = \"y_actions\",\n+\t\t.help = \"submit a list of associated actions for yellow\",\n+\t\t.next = NEXT(next_action),\n+\t},\n+\t[ACTION_POL_R] = {\n+\t\t.name = \"r_actions\",\n+\t\t.help = \"submit a list of associated actions for red\",\n+\t\t.next = NEXT(next_action),\n+\t},\n+\n+\t/* Top-level command. */\n+\t[ADD] = {\n+\t\t.name = \"add\",\n+\t\t.type = \"port meter policy {port_id} {arg}\",\n+\t\t.help = \"add port meter policy\",\n+\t\t.next = NEXT(NEXT_ENTRY(ITEM_POL_PORT)),\n+\t\t.call = parse_init,\n+\t},\n+\t/* Sub-level commands. */\n+\t[ITEM_POL_PORT] = {\n+\t\t.name = \"port\",\n+\t\t.help = \"add port meter policy\",\n+\t\t.next = NEXT(NEXT_ENTRY(ITEM_POL_METER)),\n+\t},\n+\t[ITEM_POL_METER] = {\n+\t\t.name = \"meter\",\n+\t\t.help = \"add port meter policy\",\n+\t\t.next = NEXT(NEXT_ENTRY(ITEM_POL_POLICY)),\n+\t},\n+\t[ITEM_POL_POLICY] = {\n+\t\t.name = \"policy\",\n+\t\t.help = \"add port meter policy\",\n+\t\t.next = NEXT(NEXT_ENTRY(ACTION_POL_R),\n+\t\t\t\tNEXT_ENTRY(ACTION_POL_Y),\n+\t\t\t\tNEXT_ENTRY(ACTION_POL_G),\n+\t\t\t\tNEXT_ENTRY(POLICY_ID),\n+\t\t\t\tNEXT_ENTRY(PORT_ID)),\n+\t\t.args = ARGS(ARGS_ENTRY(struct buffer, args.policy.policy_id),\n+\t\t\t\tARGS_ENTRY(struct buffer, port)),\n+\t\t.call = parse_mp,\n+\t},\n };\n \n /** Remove and return last entry from argument stack. */\n@@ -4739,6 +4810,47 @@ parse_init(struct context *ctx, const struct token *token,\n \treturn len;\n }\n \n+/** Parse tokens for meter policy action commands. */\n+static int\n+parse_mp(struct context *ctx, const struct token *token,\n+\tconst char *str, unsigned int len,\n+\tvoid *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+\tif (!out->command) {\n+\t\tif (ctx->curr != ITEM_POL_POLICY)\n+\t\t\treturn -1;\n+\t\tif (sizeof(*out) > size)\n+\t\t\treturn -1;\n+\t\tout->command = ctx->curr;\n+\t\tctx->objdata = 0;\n+\t\tctx->object = out;\n+\t\tctx->objmask = NULL;\n+\t\tout->args.vc.data = (uint8_t *)out + size;\n+\t\treturn len;\n+\t}\n+\tswitch (ctx->curr) {\n+\tcase ACTION_POL_G:\n+\t\tout->args.vc.actions =\n+\t\t\t(void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),\n+\t\t\t\t\tsizeof(double));\n+\t\tout->command = ctx->curr;\n+\t\tctx->objdata = 0;\n+\t\tctx->object = out;\n+\t\tctx->objmask = NULL;\n+\t\treturn len;\n+\tdefault:\n+\t\treturn -1;\n+\t}\n+}\n+\n /** Parse tokens for shared action commands. */\n static int\n parse_sa(struct context *ctx, const struct token *token,\n@@ -7726,6 +7838,10 @@ cmd_flow_parsed(const struct buffer *in)\n \tcase TUNNEL_LIST:\n \t\tport_flow_tunnel_list(in->port);\n \t\tbreak;\n+\tcase ACTION_POL_G:\n+\t\tport_meter_policy_add(in->port, in->args.policy.policy_id,\n+\t\t\t\t\tin->args.vc.actions);\n+\t\tbreak;\n \tdefault:\n \t\tbreak;\n \t}\ndiff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c\nindex aa454af536..eff2473e7b 100644\n--- a/app/test-pmd/cmdline_mtr.c\n+++ b/app/test-pmd/cmdline_mtr.c\n@@ -37,6 +37,8 @@ print_err_msg(struct rte_mtr_error *error)\n \t\t[RTE_MTR_ERROR_TYPE_STATS] = \"stats\",\n \t\t[RTE_MTR_ERROR_TYPE_SHARED]\n \t\t\t= \"shared meter\",\n+\t\t[RTE_MTR_ERROR_TYPE_METER_POLICY_ID] = \"meter policy id\",\n+\t\t[RTE_MTR_ERROR_TYPE_METER_POLICY] = \"meter policy null\",\n \t};\n \n \tconst char *errstr;\n@@ -56,6 +58,12 @@ print_err_msg(struct rte_mtr_error *error)\n \t\terror->type);\n }\n \n+void\n+print_mtr_err_msg(struct rte_mtr_error *error)\n+{\n+\tprint_err_msg(error);\n+}\n+\n static int\n parse_uint(uint64_t *value, const char *str)\n {\n@@ -705,6 +713,7 @@ struct cmd_create_port_meter_result {\n \tuint16_t port_id;\n \tuint32_t mtr_id;\n \tuint32_t profile_id;\n+\tuint32_t policy_id;\n \tcmdline_fixed_string_t meter_enable;\n \tcmdline_fixed_string_t g_action;\n \tcmdline_fixed_string_t y_action;\n@@ -732,6 +741,9 @@ cmdline_parse_token_num_t cmd_create_port_meter_mtr_id =\n cmdline_parse_token_num_t cmd_create_port_meter_profile_id =\n \tTOKEN_NUM_INITIALIZER(\n \t\tstruct cmd_create_port_meter_result, profile_id, RTE_UINT32);\n+cmdline_parse_token_num_t cmd_create_port_meter_policy_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_create_port_meter_result, policy_id, RTE_UINT32);\n cmdline_parse_token_string_t cmd_create_port_meter_meter_enable =\n \tTOKEN_STRING_INITIALIZER(struct cmd_create_port_meter_result,\n \t\tmeter_enable, \"yes#no\");\n@@ -775,7 +787,7 @@ static void cmd_create_port_meter_parsed(void *parsed_result,\n \t/* Meter params */\n \tmemset(&params, 0, sizeof(struct rte_mtr_params));\n \tparams.meter_profile_id = res->profile_id;\n-\n+\tparams.meter_policy_id = res->policy_id;\n \t/* Parse meter input color string params */\n \tret = parse_meter_color_str(c_str, &use_prev_meter_color, &dscp_table);\n \tif (ret) {\n@@ -790,7 +802,6 @@ static void cmd_create_port_meter_parsed(void *parsed_result,\n \t\tparams.meter_enable = 1;\n \telse\n \t\tparams.meter_enable = 0;\n-\n \tparams.stats_mask = res->statistics_mask;\n \n \tret = rte_mtr_create(port_id, mtr_id, &params, shared, &error);\n@@ -805,7 +816,6 @@ cmdline_parse_inst_t cmd_create_port_meter = {\n \t.f = cmd_create_port_meter_parsed,\n \t.data = NULL,\n \t.help_str = \"create port meter <port_id> <mtr_id> <profile_id> <meter_enable>(yes|no) \"\n-\t\t\"<g_action>(R|Y|G|D) <y_action>(R|Y|G|D) <r_action>(R|Y|G|D) \"\n \t\t\"<stats_mask> <shared> <use_pre_meter_color> \"\n \t\t\"[<dscp_tbl_entry0> <dscp_tbl_entry1> ...<dscp_tbl_entry63>]\",\n \t.tokens = {\n@@ -815,10 +825,8 @@ cmdline_parse_inst_t cmd_create_port_meter = {\n \t\t(void *)&cmd_create_port_meter_port_id,\n \t\t(void *)&cmd_create_port_meter_mtr_id,\n \t\t(void *)&cmd_create_port_meter_profile_id,\n+\t\t(void *)&cmd_create_port_meter_policy_id,\n \t\t(void *)&cmd_create_port_meter_meter_enable,\n-\t\t(void *)&cmd_create_port_meter_g_action,\n-\t\t(void *)&cmd_create_port_meter_y_action,\n-\t\t(void *)&cmd_create_port_meter_r_action,\n \t\t(void *)&cmd_create_port_meter_statistics_mask,\n \t\t(void *)&cmd_create_port_meter_shared,\n \t\t(void *)&cmd_create_port_meter_input_color,\n@@ -948,6 +956,71 @@ cmdline_parse_inst_t cmd_disable_port_meter = {\n \t},\n };\n \n+/* *** Delete Port Meter Policy Object *** */\n+struct cmd_del_port_meter_policy_result {\n+\tcmdline_fixed_string_t del;\n+\tcmdline_fixed_string_t port;\n+\tcmdline_fixed_string_t meter;\n+\tcmdline_fixed_string_t policy;\n+\tuint16_t port_id;\n+\tuint32_t policy_id;\n+};\n+\n+cmdline_parse_token_string_t cmd_del_port_meter_policy_del =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_del_port_meter_policy_result, del, \"del\");\n+cmdline_parse_token_string_t cmd_del_port_meter_policy_port =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_del_port_meter_policy_result, port, \"port\");\n+cmdline_parse_token_string_t cmd_del_port_meter_policy_meter =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_del_port_meter_policy_result, meter, \"meter\");\n+cmdline_parse_token_string_t cmd_del_port_meter_policy_policy =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_del_port_meter_policy_result, policy, \"policy\");\n+cmdline_parse_token_num_t cmd_del_port_meter_policy_port_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_del_port_meter_policy_result, port_id, RTE_UINT16);\n+cmdline_parse_token_num_t cmd_del_port_meter_policy_policy_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_del_port_meter_policy_result, policy_id, RTE_UINT32);\n+\n+static void cmd_del_port_meter_policy_parsed(void *parsed_result,\n+\t__rte_unused struct cmdline *cl,\n+\t__rte_unused void *data)\n+{\n+\tstruct cmd_del_port_meter_policy_result *res = parsed_result;\n+\tstruct rte_mtr_error error;\n+\tuint32_t policy_id = res->policy_id;\n+\tuint16_t port_id = res->port_id;\n+\tint ret;\n+\n+\tif (port_id_is_invalid(port_id, ENABLED_WARN))\n+\t\treturn;\n+\n+\t/* Delete Meter Policy*/\n+\tret = rte_mtr_meter_policy_delete(port_id, policy_id, &error);\n+\tif (ret != 0) {\n+\t\tprint_err_msg(&error);\n+\t\treturn;\n+\t}\n+}\n+\n+cmdline_parse_inst_t cmd_del_port_meter_policy = {\n+\t.f = cmd_del_port_meter_policy_parsed,\n+\t.data = NULL,\n+\t.help_str = \"Delete port meter policy\",\n+\t.tokens = {\n+\t\t(void *)&cmd_del_port_meter_policy_del,\n+\t\t(void *)&cmd_del_port_meter_policy_port,\n+\t\t(void *)&cmd_del_port_meter_policy_meter,\n+\t\t(void *)&cmd_del_port_meter_policy_policy,\n+\t\t(void *)&cmd_del_port_meter_policy_port_id,\n+\t\t(void *)&cmd_del_port_meter_policy_policy_id,\n+\t\tNULL,\n+\t},\n+};\n+\n /* *** Delete Port Meter Object *** */\n struct cmd_del_port_meter_result {\n \tcmdline_fixed_string_t del;\ndiff --git a/app/test-pmd/cmdline_mtr.h b/app/test-pmd/cmdline_mtr.h\nindex 7e2713cea3..2415fc16c3 100644\n--- a/app/test-pmd/cmdline_mtr.h\n+++ b/app/test-pmd/cmdline_mtr.h\n@@ -4,6 +4,7 @@\n \n #ifndef _CMDLINE_MTR_H_\n #define _CMDLINE_MTR_H_\n+#include <rte_mtr.h>\n \n /* Traffic Metering and Policing */\n extern cmdline_parse_inst_t cmd_show_port_meter_cap;\n@@ -15,9 +16,11 @@ extern cmdline_parse_inst_t cmd_create_port_meter;\n extern cmdline_parse_inst_t cmd_enable_port_meter;\n extern cmdline_parse_inst_t cmd_disable_port_meter;\n extern cmdline_parse_inst_t cmd_del_port_meter;\n+extern cmdline_parse_inst_t cmd_del_port_meter_policy;\n extern cmdline_parse_inst_t cmd_set_port_meter_profile;\n extern cmdline_parse_inst_t cmd_set_port_meter_dscp_table;\n extern cmdline_parse_inst_t cmd_set_port_meter_stats_mask;\n extern cmdline_parse_inst_t cmd_show_port_meter_stats;\n+void print_mtr_err_msg(struct rte_mtr_error *error);\n \n #endif /* _CMDLINE_MTR_H_ */\ndiff --git a/app/test-pmd/config.c b/app/test-pmd/config.c\nindex 40b2b29725..c4fe0d59e1 100644\n--- a/app/test-pmd/config.c\n+++ b/app/test-pmd/config.c\n@@ -38,6 +38,7 @@\n #include <rte_string_fns.h>\n #include <rte_cycles.h>\n #include <rte_flow.h>\n+#include <rte_mtr.h>\n #include <rte_errno.h>\n #ifdef RTE_NET_IXGBE\n #include <rte_pmd_ixgbe.h>\n@@ -52,6 +53,7 @@\n #include <rte_hexdump.h>\n \n #include \"testpmd.h\"\n+#include \"cmdline_mtr.h\"\n \n #define ETHDEV_FWVERS_LEN 32\n \n@@ -1465,6 +1467,36 @@ action_alloc(portid_t port_id, uint32_t id,\n \treturn 0;\n }\n \n+/** Add port meter policy */\n+int\n+port_meter_policy_add(portid_t port_id, uint32_t policy_id,\n+\t\t\tconst struct rte_flow_action *actions)\n+{\n+\tstruct rte_mtr_error error;\n+\tconst struct rte_flow_action *act = actions;\n+\tconst struct rte_flow_action *start;\n+\tstruct rte_mtr_meter_policy_params policy;\n+\tuint32_t i = 0, act_n;\n+\tint ret;\n+\n+\tfor (i = 0; i < RTE_COLORS; i++) {\n+\t\tfor (act_n = 0, start = act;\n+\t\t\tact->type != RTE_FLOW_ACTION_TYPE_END; act++)\n+\t\t\tact_n++;\n+\t\tif (act_n && act->type == RTE_FLOW_ACTION_TYPE_END)\n+\t\t\tpolicy.actions[i] = start;\n+\t\telse\n+\t\t\tpolicy.actions[i] = NULL;\n+\t\tact++;\n+\t}\n+\tret = rte_mtr_meter_policy_add(port_id,\n+\t\t\tpolicy_id,\n+\t\t\t&policy, &error);\n+\tif (ret)\n+\t\tprint_mtr_err_msg(&error);\n+\treturn ret;\n+}\n+\n /** Create shared action */\n int\n port_shared_action_create(portid_t port_id, uint32_t id,\ndiff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h\nindex 36d8535d0c..2a9c24be26 100644\n--- a/app/test-pmd/testpmd.h\n+++ b/app/test-pmd/testpmd.h\n@@ -838,6 +838,8 @@ void port_flow_tunnel_list(portid_t port_id);\n void port_flow_tunnel_destroy(portid_t port_id, uint32_t tunnel_id);\n void port_flow_tunnel_create(portid_t port_id, const struct tunnel_ops *ops);\n int port_flow_isolate(portid_t port_id, int set);\n+int port_meter_policy_add(portid_t port_id, uint32_t policy_id,\n+\t\tconst struct rte_flow_action *actions);\n \n void rx_ring_desc_display(portid_t port_id, queueid_t rxq_id, uint16_t rxd_id);\n void tx_ring_desc_display(portid_t port_id, queueid_t txq_id, uint16_t txd_id);\ndiff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst\nindex 824d8bdf27..91db2d6b60 100644\n--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst\n+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst\n@@ -2767,13 +2767,37 @@ Delete meter profile from the ethernet device::\n \n    testpmd> del port meter profile (port_id) (profile_id)\n \n+create port policy\n+~~~~~~~~~~~~~~~~~~\n+\n+Create new policy object for the ethernet device::\n+\n+   testpmd> add port meter policy (port_id) (policy_id) g_actions \\\n+   {action} y_actions {action} r_actions {action}\n+\n+where:\n+\n+* ``policy_id``: policy ID.\n+* ``action``: action lists for green/yellow/red colors.\n+\n+delete port policy\n+~~~~~~~~~~~~~~~~~~\n+\n+Delete policy object for the ethernet device::\n+\n+   testpmd> del port meter policy (port_id) (policy_id)\n+\n+where:\n+\n+* ``policy_id``: policy ID.\n+\n create port meter\n ~~~~~~~~~~~~~~~~~\n \n Create new meter object for the ethernet device::\n \n    testpmd> create port meter (port_id) (mtr_id) (profile_id) \\\n-   (meter_enable) (g_action) (y_action) (r_action) (stats_mask) (shared) \\\n+   (policy_id) (meter_enable) (stats_mask) (shared) \\\n    (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\\\n    (dscp_tbl_entry63)]\n \n@@ -2781,11 +2805,9 @@ where:\n \n * ``mtr_id``: meter object ID.\n * ``profile_id``: ID for the meter profile.\n+* ``policy_id``: ID for the policy.\n * ``meter_enable``: When this parameter has a non-zero value, the meter object\n   gets enabled at the time of creation, otherwise remains disabled.\n-* ``g_action``: Policer action for the packet with green color.\n-* ``y_action``: Policer action for the packet with yellow color.\n-* ``r_action``: Policer action for the packet with red color.\n * ``stats_mask``: Mask of statistics counter types to be enabled for the\n   meter object.\n * ``shared``:  When this parameter has a non-zero value, the meter object is\n",
    "prefixes": [
        "v8",
        "2/2"
    ]
}