get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 29727,
    "url": "https://patches.dpdk.org/api/patches/29727/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1507208974-180500-6-git-send-email-cristian.dumitrescu@intel.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": "<1507208974-180500-6-git-send-email-cristian.dumitrescu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1507208974-180500-6-git-send-email-cristian.dumitrescu@intel.com",
    "date": "2017-10-05T13:09:34",
    "name": "[dpdk-dev,V2,5/5] app/testpmd: cli for traffic metering and policing",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "cdcdfa2232a5e6558b68b72e5675a86cb7ff5a92",
    "submitter": {
        "id": 19,
        "url": "https://patches.dpdk.org/api/people/19/?format=api",
        "name": "Cristian Dumitrescu",
        "email": "cristian.dumitrescu@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1507208974-180500-6-git-send-email-cristian.dumitrescu@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/29727/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/29727/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 90A641B219;\n\tThu,  5 Oct 2017 15:09:51 +0200 (CEST)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby dpdk.org (Postfix) with ESMTP id 66A5A1B217\n\tfor <dev@dpdk.org>; Thu,  5 Oct 2017 15:09:48 +0200 (CEST)",
            "from fmsmga004.fm.intel.com ([10.253.24.48])\n\tby orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t05 Oct 2017 06:09:47 -0700",
            "from silpixa00382658.ir.intel.com ([10.237.223.29])\n\tby fmsmga004.fm.intel.com with ESMTP; 05 Oct 2017 06:09:45 -0700"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.42,481,1500966000\"; d=\"scan'208\";a=\"319901103\"",
        "From": "Cristian Dumitrescu <cristian.dumitrescu@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "thomas@monjalon.net, adrien.mazarguil@6wind.com, jingjing.wu@intel.com, \n\themant.agrawal@nxp.com, jerin.jacob@caviumnetworks.com,\n\tjasvinder.singh@intel.com",
        "Date": "Thu,  5 Oct 2017 14:09:34 +0100",
        "Message-Id": "<1507208974-180500-6-git-send-email-cristian.dumitrescu@intel.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1507208974-180500-1-git-send-email-cristian.dumitrescu@intel.com>",
        "References": "<1503705973-80742-2-git-send-email-cristian.dumitrescu@intel.com>\n\t<1507208974-180500-1-git-send-email-cristian.dumitrescu@intel.com>",
        "Subject": "[dpdk-dev] [PATCH V2 5/5] app/testpmd: cli for traffic metering and\n\tpolicing",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Add CLI commands to exercise the ethdev Traffic Metering and Policing\n(MTR) API.\n\nSigned-off-by: Jasvinder Singh <jasvinder.singh@intel.com>\nAcked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>\n---\n app/test-pmd/Makefile       |    1 +\n app/test-pmd/cmdline.c      |   10 +\n app/test-pmd/cmdline_flow.c |   24 +\n app/test-pmd/cmdline_mtr.c  | 1013 +++++++++++++++++++++++++++++++++++++++++++\n app/test-pmd/cmdline_mtr.h  |   49 +++\n 5 files changed, 1097 insertions(+)\n create mode 100644 app/test-pmd/cmdline_mtr.c\n create mode 100644 app/test-pmd/cmdline_mtr.h",
    "diff": "diff --git a/app/test-pmd/Makefile b/app/test-pmd/Makefile\nindex c36be19..8fb6491 100644\n--- a/app/test-pmd/Makefile\n+++ b/app/test-pmd/Makefile\n@@ -48,6 +48,7 @@ SRCS-y := testpmd.c\n SRCS-y += parameters.c\n SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += cmdline.c\n SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += cmdline_flow.c\n+SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += cmdline_mtr.c\n SRCS-y += config.c\n SRCS-y += iofwd.c\n SRCS-y += macfwd.c\ndiff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c\nindex ccdf239..8338b5c 100644\n--- a/app/test-pmd/cmdline.c\n+++ b/app/test-pmd/cmdline.c\n@@ -99,6 +99,7 @@\n #include <rte_pmd_bnxt.h>\n #endif\n #include \"testpmd.h\"\n+#include \"cmdline_mtr.h\"\n \n static struct cmdline *testpmd_cl;\n \n@@ -14334,6 +14335,15 @@ cmdline_parse_ctx_t main_ctx[] = {\n \t(cmdline_parse_inst_t *)&cmd_set_hash_input_set,\n \t(cmdline_parse_inst_t *)&cmd_set_fdir_input_set,\n \t(cmdline_parse_inst_t *)&cmd_flow,\n+\t(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,\n+\t(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,\n+\t(cmdline_parse_inst_t *)&cmd_del_port_meter_profile,\n+\t(cmdline_parse_inst_t *)&cmd_set_port_meter,\n+\t(cmdline_parse_inst_t *)&cmd_del_port_meter,\n+\t(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,\n+\t(cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,\n+\t(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,\n+\t(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,\n \t(cmdline_parse_inst_t *)&cmd_mcast_addr,\n \t(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,\n \t(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,\ndiff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c\nindex a17a004..f210ce5 100644\n--- a/app/test-pmd/cmdline_flow.c\n+++ b/app/test-pmd/cmdline_flow.c\n@@ -194,6 +194,8 @@ enum index {\n \tACTION_VF,\n \tACTION_VF_ORIGINAL,\n \tACTION_VF_ID,\n+\tACTION_METER,\n+\tACTION_METER_ID,\n };\n \n /** Size of pattern[] field in struct rte_flow_item_raw. */\n@@ -601,6 +603,7 @@ static const enum index next_action[] = {\n \tACTION_RSS,\n \tACTION_PF,\n \tACTION_VF,\n+\tACTION_METER,\n \tZERO,\n };\n \n@@ -635,6 +638,12 @@ static const enum index action_vf[] = {\n \tZERO,\n };\n \n+static const enum index action_meter[] = {\n+\tACTION_METER_ID,\n+\tACTION_NEXT,\n+\tZERO,\n+};\n+\n static int parse_init(struct context *, const struct token *,\n \t\t      const char *, unsigned int,\n \t\t      void *, unsigned int);\n@@ -1566,6 +1575,21 @@ static const struct token token_list[] = {\n \t\t.args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),\n \t\t.call = parse_vc_conf,\n \t},\n+\t[ACTION_METER] = {\n+\t\t.name = \"meter\",\n+\t\t.help = \"meter the directed packets at given id\",\n+\t\t.priv = PRIV_ACTION(METER,\n+\t\t\t\t    sizeof(struct rte_flow_action_meter)),\n+\t\t.next = NEXT(action_meter),\n+\t\t.call = parse_vc,\n+\t},\n+\t[ACTION_METER_ID] = {\n+\t\t.name = \"mtr_id\",\n+\t\t.help = \"meter id to use\",\n+\t\t.next = NEXT(action_meter, NEXT_ENTRY(UNSIGNED)),\n+\t\t.args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),\n+\t\t.call = parse_vc_conf,\n+\t},\n };\n \n /** Remove and return last entry from argument stack. */\ndiff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c\nnew file mode 100644\nindex 0000000..58feee5\n--- /dev/null\n+++ b/app/test-pmd/cmdline_mtr.c\n@@ -0,0 +1,1013 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2017 Intel Corporation. All rights reserved.\n+ *   All rights reserved.\n+ *\n+ *   Redistribution and use in source and binary forms, with or without\n+ *   modification, are permitted provided that the following conditions\n+ *   are met:\n+ *\n+ *     * Redistributions of source code must retain the above copyright\n+ *       notice, this list of conditions and the following disclaimer.\n+ *     * Redistributions in binary form must reproduce the above copyright\n+ *       notice, this list of conditions and the following disclaimer in\n+ *       the documentation and/or other materials provided with the\n+ *       distribution.\n+ *     * Neither the name of Intel Corporation nor the names of its\n+ *       contributors may be used to endorse or promote products derived\n+ *       from this software without specific prior written permission.\n+ *\n+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#include <cmdline_parse.h>\n+#include <cmdline_parse_num.h>\n+#include <cmdline_parse_string.h>\n+\n+#include <rte_ethdev.h>\n+#include <rte_flow.h>\n+#include <rte_mtr.h>\n+\n+#include \"testpmd.h\"\n+#include \"cmdline_mtr.h\"\n+\n+/** Display Meter Error Message */\n+static void\n+print_err_msg(struct rte_mtr_error *error)\n+{\n+\tstatic const char *const errstrlist[] = {\n+\t\t[RTE_MTR_ERROR_TYPE_NONE] = \"no error\",\n+\t\t[RTE_MTR_ERROR_TYPE_UNSPECIFIED] = \"cause unspecified\",\n+\t\t[RTE_MTR_ERROR_TYPE_METER_PROFILE_ID] = \"meter profile id\",\n+\t\t[RTE_MTR_ERROR_TYPE_METER_PROFILE] = \"meter profile null\",\n+\t\t[RTE_MTR_ERROR_TYPE_MTR_ID]\t= \"meter id\",\n+\t\t[RTE_MTR_ERROR_TYPE_MTR_PARAMS] = \"meter params null\",\n+\t\t[RTE_MTR_ERROR_TYPE_POLICER_ACTION_GREEN]\n+\t\t\t= \"policer action(green)\",\n+\t\t[RTE_MTR_ERROR_TYPE_POLICER_ACTION_YELLOW]\n+\t\t\t= \"policer action(yellow)\",\n+\t\t[RTE_MTR_ERROR_TYPE_POLICER_ACTION_RED]\n+\t\t\t= \"policer action(red)\",\n+\t\t[RTE_MTR_ERROR_TYPE_STATS_MASK] = \"stats mask\",\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};\n+\n+\tconst char *errstr;\n+\tchar buf[64];\n+\n+\tif ((unsigned int)error->type >= RTE_DIM(errstrlist) ||\n+\t\t!errstrlist[error->type])\n+\t\terrstr = \"unknown type\";\n+\telse\n+\t\terrstr = errstrlist[error->type];\n+\n+\tif (error->cause)\n+\t\tsnprintf(buf, sizeof(buf), \"cause: %p, \", error->cause);\n+\n+\tprintf(\"%s: %s%s (error %d)\\n\", errstr, error->cause ? buf : \"\",\n+\t\terror->message ? error->message : \"(no stated reason)\",\n+\t\terror->type);\n+}\n+\n+static int\n+string_to_policer_action(char *s)\n+{\n+\tif (strcmp(s, \"G\") == 0)\n+\t\treturn MTR_POLICER_ACTION_COLOR_GREEN;\n+\n+\tif (strcmp(s, \"Y\") == 0)\n+\t\treturn MTR_POLICER_ACTION_COLOR_YELLOW;\n+\n+\tif (strcmp(s, \"R\") == 0)\n+\t\treturn MTR_POLICER_ACTION_COLOR_RED;\n+\n+\tif (strcmp(s, \"D\") == 0)\n+\t\treturn MTR_POLICER_ACTION_DROP;\n+\n+\treturn -1;\n+}\n+\n+/* *** Add Port Meter Profile srtcm_rfc2697 *** */\n+struct cmd_add_port_meter_profile_srtcm_result {\n+\tcmdline_fixed_string_t add;\n+\tcmdline_fixed_string_t port;\n+\tcmdline_fixed_string_t meter;\n+\tcmdline_fixed_string_t profile;\n+\tcmdline_fixed_string_t srtcm_rfc2697;\n+\tuint8_t port_id;\n+\tuint32_t profile_id;\n+\tuint64_t cir;\n+\tuint64_t cbs;\n+\tuint64_t ebs;\n+\tuint8_t color_aware;\n+};\n+\n+cmdline_parse_token_string_t cmd_add_port_meter_profile_srtcm_add =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_srtcm_result, add, \"add\");\n+cmdline_parse_token_string_t cmd_add_port_meter_profile_srtcm_port =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_srtcm_result,\n+\t\t\tport, \"port\");\n+cmdline_parse_token_string_t cmd_add_port_meter_profile_srtcm_meter =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_srtcm_result,\n+\t\t\tmeter, \"meter\");\n+cmdline_parse_token_string_t cmd_add_port_meter_profile_srtcm_profile =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_srtcm_result,\n+\t\t\tprofile, \"profile\");\n+cmdline_parse_token_string_t cmd_add_port_meter_profile_srtcm_srtcm_rfc2697 =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_srtcm_result,\n+\t\t\tsrtcm_rfc2697, \"srtcm_rfc2697\");\n+cmdline_parse_token_num_t cmd_add_port_meter_profile_srtcm_port_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_srtcm_result,\n+\t\t\tport_id, UINT8);\n+cmdline_parse_token_num_t cmd_add_port_meter_profile_srtcm_profile_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_srtcm_result,\n+\t\t\tprofile_id, UINT32);\n+cmdline_parse_token_num_t cmd_add_port_meter_profile_srtcm_cir =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_srtcm_result,\n+\t\t\tcir, UINT64);\n+cmdline_parse_token_num_t cmd_add_port_meter_profile_srtcm_cbs =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_srtcm_result,\n+\t\t\tcbs, UINT64);\n+cmdline_parse_token_num_t cmd_add_port_meter_profile_srtcm_ebs =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_srtcm_result,\n+\t\t\tebs, UINT64);\n+\n+static void cmd_add_port_meter_profile_srtcm_parsed(void *parsed_result,\n+\t__attribute__((unused)) struct cmdline *cl,\n+\t__attribute__((unused)) void *data)\n+{\n+\tstruct cmd_add_port_meter_profile_srtcm_result *res = parsed_result;\n+\tstruct rte_mtr_meter_profile mp;\n+\tstruct rte_mtr_error error;\n+\tuint32_t profile_id = res->profile_id;\n+\tuint8_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/* Private shaper profile params */\n+\tmemset(&mp, 0, sizeof(struct rte_mtr_meter_profile));\n+\tmp.alg = 0;\n+\tmp.srtcm_rfc2697.cir = res->cir;\n+\tmp.srtcm_rfc2697.cbs = res->cbs;\n+\tmp.srtcm_rfc2697.ebs = res->ebs;\n+\n+\tret = rte_mtr_meter_profile_add(port_id, profile_id, &mp, &error);\n+\tif (ret != 0) {\n+\t\tprint_err_msg(&error);\n+\t\treturn;\n+\t}\n+}\n+\n+cmdline_parse_inst_t cmd_add_port_meter_profile_srtcm = {\n+\t.f = cmd_add_port_meter_profile_srtcm_parsed,\n+\t.data = NULL,\n+\t.help_str = \"Add port meter profile srtcm (rfc2697)\",\n+\t.tokens = {\n+\t\t(void *)&cmd_add_port_meter_profile_srtcm_add,\n+\t\t(void *)&cmd_add_port_meter_profile_srtcm_port,\n+\t\t(void *)&cmd_add_port_meter_profile_srtcm_meter,\n+\t\t(void *)&cmd_add_port_meter_profile_srtcm_profile,\n+\t\t(void *)&cmd_add_port_meter_profile_srtcm_port_id,\n+\t\t(void *)&cmd_add_port_meter_profile_srtcm_profile_id,\n+\t\t(void *)&cmd_add_port_meter_profile_srtcm_srtcm_rfc2697,\n+\t\t(void *)&cmd_add_port_meter_profile_srtcm_cir,\n+\t\t(void *)&cmd_add_port_meter_profile_srtcm_cbs,\n+\t\t(void *)&cmd_add_port_meter_profile_srtcm_ebs,\n+\t\tNULL,\n+\t},\n+};\n+\n+/* *** Add Port Meter Profile trtcm_rfc2698 *** */\n+struct cmd_add_port_meter_profile_trtcm_result {\n+\tcmdline_fixed_string_t add;\n+\tcmdline_fixed_string_t port;\n+\tcmdline_fixed_string_t meter;\n+\tcmdline_fixed_string_t profile;\n+\tcmdline_fixed_string_t trtcm_rfc2698;\n+\tuint8_t port_id;\n+\tuint32_t profile_id;\n+\tuint64_t cir;\n+\tuint64_t pir;\n+\tuint64_t cbs;\n+\tuint64_t pbs;\n+};\n+\n+cmdline_parse_token_string_t cmd_add_port_meter_profile_trtcm_add =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_trtcm_result, add, \"add\");\n+cmdline_parse_token_string_t cmd_add_port_meter_profile_trtcm_port =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_trtcm_result,\n+\t\t\tport, \"port\");\n+cmdline_parse_token_string_t cmd_add_port_meter_profile_trtcm_meter =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_trtcm_result,\n+\t\t\tmeter, \"meter\");\n+cmdline_parse_token_string_t cmd_add_port_meter_profile_trtcm_profile =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_trtcm_result,\n+\t\t\tprofile, \"profile\");\n+cmdline_parse_token_string_t cmd_add_port_meter_profile_trtcm_trtcm_rfc2698 =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_trtcm_result,\n+\t\t\ttrtcm_rfc2698, \"trtcm_rfc2698\");\n+cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_port_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_trtcm_result,\n+\t\t\tport_id, UINT8);\n+cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_profile_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_trtcm_result,\n+\t\t\tprofile_id, UINT32);\n+cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_cir =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_trtcm_result,\n+\t\t\tcir, UINT64);\n+cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_pir =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_trtcm_result,\n+\t\t\tpir, UINT64);\n+cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_cbs =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_trtcm_result,\n+\t\t\tcbs, UINT64);\n+cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_pbs =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_trtcm_result,\n+\t\t\tpbs, UINT64);\n+\n+static void cmd_add_port_meter_profile_trtcm_parsed(void *parsed_result,\n+\t__attribute__((unused)) struct cmdline *cl,\n+\t__attribute__((unused)) void *data)\n+{\n+\tstruct cmd_add_port_meter_profile_trtcm_result *res = parsed_result;\n+\tstruct rte_mtr_meter_profile mp;\n+\tstruct rte_mtr_error error;\n+\tuint32_t profile_id = res->profile_id;\n+\tuint8_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/* Private shaper profile params */\n+\tmemset(&mp, 0, sizeof(struct rte_mtr_meter_profile));\n+\tmp.alg = 0;\n+\tmp.trtcm_rfc2698.cir = res->cir;\n+\tmp.trtcm_rfc2698.pir = res->pir;\n+\tmp.trtcm_rfc2698.cbs = res->cbs;\n+\tmp.trtcm_rfc2698.pbs = res->pbs;\n+\n+\tret = rte_mtr_meter_profile_add(port_id, profile_id, &mp, &error);\n+\tif (ret != 0) {\n+\t\tprint_err_msg(&error);\n+\t\treturn;\n+\t}\n+}\n+\n+cmdline_parse_inst_t cmd_add_port_meter_profile_trtcm = {\n+\t.f = cmd_add_port_meter_profile_trtcm_parsed,\n+\t.data = NULL,\n+\t.help_str = \"Add port meter profile trtcm (rfc2698)\",\n+\t.tokens = {\n+\t\t(void *)&cmd_add_port_meter_profile_trtcm_add,\n+\t\t(void *)&cmd_add_port_meter_profile_trtcm_port,\n+\t\t(void *)&cmd_add_port_meter_profile_trtcm_meter,\n+\t\t(void *)&cmd_add_port_meter_profile_trtcm_profile,\n+\t\t(void *)&cmd_add_port_meter_profile_trtcm_port_id,\n+\t\t(void *)&cmd_add_port_meter_profile_trtcm_profile_id,\n+\t\t(void *)&cmd_add_port_meter_profile_trtcm_trtcm_rfc2698,\n+\t\t(void *)&cmd_add_port_meter_profile_trtcm_cir,\n+\t\t(void *)&cmd_add_port_meter_profile_trtcm_pir,\n+\t\t(void *)&cmd_add_port_meter_profile_trtcm_cbs,\n+\t\t(void *)&cmd_add_port_meter_profile_trtcm_pbs,\n+\t\tNULL,\n+\t},\n+};\n+\n+/* *** Add Port Meter Profile trtcm_rfc4115 *** */\n+struct cmd_add_port_meter_profile_trtcm_rfc4115_result {\n+\tcmdline_fixed_string_t add;\n+\tcmdline_fixed_string_t port;\n+\tcmdline_fixed_string_t meter;\n+\tcmdline_fixed_string_t profile;\n+\tcmdline_fixed_string_t trtcm_rfc4115;\n+\tuint8_t port_id;\n+\tuint32_t profile_id;\n+\tuint64_t cir;\n+\tuint64_t eir;\n+\tuint64_t cbs;\n+\tuint64_t ebs;\n+};\n+\n+cmdline_parse_token_string_t cmd_add_port_meter_profile_trtcm_rfc4115_add =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_trtcm_rfc4115_result, add,\n+\t\t\"add\");\n+cmdline_parse_token_string_t cmd_add_port_meter_profile_trtcm_rfc4115_port =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_trtcm_rfc4115_result,\n+\t\t\tport, \"port\");\n+cmdline_parse_token_string_t cmd_add_port_meter_profile_trtcm_rfc4115_meter =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_trtcm_rfc4115_result,\n+\t\t\tmeter, \"meter\");\n+cmdline_parse_token_string_t cmd_add_port_meter_profile_trtcm_rfc4115_profile =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_trtcm_rfc4115_result,\n+\t\t\tprofile, \"profile\");\n+cmdline_parse_token_string_t\n+\tcmd_add_port_meter_profile_trtcm_rfc4115_trtcm_rfc4115 =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_trtcm_rfc4115_result,\n+\t\t\ttrtcm_rfc4115, \"trtcm_rfc4115\");\n+cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_rfc4115_port_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_trtcm_rfc4115_result,\n+\t\t\tport_id, UINT8);\n+cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_rfc4115_profile_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_trtcm_rfc4115_result,\n+\t\t\tprofile_id, UINT32);\n+cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_rfc4115_cir =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_trtcm_rfc4115_result,\n+\t\t\tcir, UINT64);\n+cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_rfc4115_eir =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_trtcm_rfc4115_result,\n+\t\t\teir, UINT64);\n+cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_rfc4115_cbs =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_trtcm_rfc4115_result,\n+\t\t\tcbs, UINT64);\n+cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_rfc4115_ebs =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_add_port_meter_profile_trtcm_rfc4115_result,\n+\t\t\tebs, UINT64);\n+\n+static void cmd_add_port_meter_profile_trtcm_rfc4115_parsed(\n+\tvoid *parsed_result,\n+\t__attribute__((unused)) struct cmdline *cl,\n+\t__attribute__((unused)) void *data)\n+{\n+\tstruct cmd_add_port_meter_profile_trtcm_rfc4115_result *res =\n+\t\tparsed_result;\n+\tstruct rte_mtr_meter_profile mp;\n+\tstruct rte_mtr_error error;\n+\tuint32_t profile_id = res->profile_id;\n+\tuint8_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/* Private shaper profile params */\n+\tmemset(&mp, 0, sizeof(struct rte_mtr_meter_profile));\n+\tmp.alg = 0;\n+\tmp.trtcm_rfc4115.cir = res->cir;\n+\tmp.trtcm_rfc4115.eir = res->eir;\n+\tmp.trtcm_rfc4115.cbs = res->cbs;\n+\tmp.trtcm_rfc4115.ebs = res->ebs;\n+\n+\tret = rte_mtr_meter_profile_add(port_id, profile_id, &mp, &error);\n+\tif (ret != 0) {\n+\t\tprint_err_msg(&error);\n+\t\treturn;\n+\t}\n+}\n+\n+cmdline_parse_inst_t cmd_add_port_meter_profile_trtcm_rfc4115 = {\n+\t.f = cmd_add_port_meter_profile_trtcm_rfc4115_parsed,\n+\t.data = NULL,\n+\t.help_str = \"Add port meter profile trtcm (rfc4115)\",\n+\t.tokens = {\n+\t\t(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_add,\n+\t\t(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_port,\n+\t\t(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_meter,\n+\t\t(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_profile,\n+\t\t(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_port_id,\n+\t\t(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_profile_id,\n+\t\t(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_trtcm_rfc4115,\n+\t\t(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_cir,\n+\t\t(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_eir,\n+\t\t(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_cbs,\n+\t\t(void *)&cmd_add_port_meter_profile_trtcm_rfc4115_ebs,\n+\t\tNULL,\n+\t},\n+};\n+\n+/* *** Delete Port Meter Profile *** */\n+struct cmd_del_port_meter_profile_result {\n+\tcmdline_fixed_string_t del;\n+\tcmdline_fixed_string_t port;\n+\tcmdline_fixed_string_t meter;\n+\tcmdline_fixed_string_t profile;\n+\tuint8_t port_id;\n+\tuint32_t profile_id;\n+};\n+\n+cmdline_parse_token_string_t cmd_del_port_meter_profile_del =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_del_port_meter_profile_result, del, \"del\");\n+cmdline_parse_token_string_t cmd_del_port_meter_profile_port =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_del_port_meter_profile_result,\n+\t\t\tport, \"port\");\n+cmdline_parse_token_string_t cmd_del_port_meter_profile_meter =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_del_port_meter_profile_result,\n+\t\t\tmeter, \"meter\");\n+cmdline_parse_token_string_t cmd_del_port_meter_profile_profile =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_del_port_meter_profile_result,\n+\t\t\tprofile, \"profile\");\n+cmdline_parse_token_num_t cmd_del_port_meter_profile_port_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_del_port_meter_profile_result,\n+\t\t\tport_id, UINT8);\n+cmdline_parse_token_num_t cmd_del_port_meter_profile_profile_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_del_port_meter_profile_result,\n+\t\t\tprofile_id, UINT32);\n+\n+static void cmd_del_port_meter_profile_parsed(void *parsed_result,\n+\t__attribute__((unused)) struct cmdline *cl,\n+\t__attribute__((unused)) void *data)\n+{\n+\tstruct cmd_del_port_meter_profile_result *res = parsed_result;\n+\tstruct rte_mtr_error error;\n+\tuint32_t profile_id = res->profile_id;\n+\tuint8_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 profile */\n+\tret = rte_mtr_meter_profile_delete(port_id, profile_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_profile = {\n+\t.f = cmd_del_port_meter_profile_parsed,\n+\t.data = NULL,\n+\t.help_str = \"Delete port meter profile\",\n+\t.tokens = {\n+\t\t(void *)&cmd_del_port_meter_profile_del,\n+\t\t(void *)&cmd_del_port_meter_profile_port,\n+\t\t(void *)&cmd_del_port_meter_profile_meter,\n+\t\t(void *)&cmd_del_port_meter_profile_profile,\n+\t\t(void *)&cmd_del_port_meter_profile_port_id,\n+\t\t(void *)&cmd_del_port_meter_profile_profile_id,\n+\t\tNULL,\n+\t},\n+};\n+\n+/* *** Create Port Meter Object *** */\n+struct cmd_set_port_meter_result {\n+\tcmdline_fixed_string_t set;\n+\tcmdline_fixed_string_t port;\n+\tcmdline_fixed_string_t meter;\n+\tuint8_t port_id;\n+\tuint32_t mtr_id;\n+\tuint32_t profile_id;\n+\tcmdline_fixed_string_t g_action;\n+\tcmdline_fixed_string_t y_action;\n+\tcmdline_fixed_string_t r_action;\n+\tuint64_t statistics_mask;\n+\tuint32_t shared;\n+};\n+\n+cmdline_parse_token_string_t cmd_set_port_meter_set =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_result, set, \"set\");\n+cmdline_parse_token_string_t cmd_set_port_meter_port =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_result, port, \"port\");\n+cmdline_parse_token_string_t cmd_set_port_meter_meter =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_result, meter, \"meter\");\n+cmdline_parse_token_num_t cmd_set_port_meter_port_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_result, port_id, UINT8);\n+cmdline_parse_token_num_t cmd_set_port_meter_mtr_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_result, mtr_id, UINT32);\n+cmdline_parse_token_num_t cmd_set_port_meter_profile_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_result, profile_id, UINT32);\n+cmdline_parse_token_string_t cmd_set_port_meter_g_action =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_set_port_meter_result,\n+\t\tg_action, \"R#Y#G#D\");\n+cmdline_parse_token_string_t cmd_set_port_meter_y_action =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_set_port_meter_result,\n+\t\ty_action, \"R#Y#G#D\");\n+cmdline_parse_token_string_t cmd_set_port_meter_r_action =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_set_port_meter_result,\n+\t\tr_action, \"R#Y#G#D\");\n+cmdline_parse_token_num_t cmd_set_port_meter_statistics_mask =\n+\tTOKEN_NUM_INITIALIZER(struct cmd_set_port_meter_result,\n+\t\tstatistics_mask, UINT64);\n+cmdline_parse_token_num_t cmd_set_port_meter_shared =\n+\tTOKEN_NUM_INITIALIZER(struct cmd_set_port_meter_result,\n+\t\tshared, UINT32);\n+\n+static void cmd_set_port_meter_parsed(void *parsed_result,\n+\t__attribute__((unused)) struct cmdline *cl,\n+\t__attribute__((unused)) void *data)\n+{\n+\tstruct cmd_set_port_meter_result *res = parsed_result;\n+\tstruct rte_mtr_error error;\n+\tstruct rte_mtr_params params;\n+\tuint32_t mtr_id = res->mtr_id;\n+\tuint32_t shared = res->shared;\n+\tuint8_t port_id = res->port_id;\n+\t\n+\tint ret;\n+\n+\tif (port_id_is_invalid(port_id, ENABLED_WARN))\n+\t\treturn;\n+\n+\t/* Meter params */\n+\tmemset(&params, 0, sizeof(struct rte_mtr_params));\n+\tparams.meter_profile_id = res->profile_id;\n+\tparams.use_prev_mtr_color = 1;\n+\tparams.dscp_table = NULL;\n+\tparams.meter_enable = 1;\n+\tparams.action[RTE_MTR_GREEN] =\n+\t\tstring_to_policer_action(res->g_action);\n+\tparams.action[RTE_MTR_YELLOW] =\n+\t\tstring_to_policer_action(res->y_action);\n+\tparams.action[RTE_MTR_RED] =\n+\t\tstring_to_policer_action(res->r_action);\n+\tparams.stats_mask = res->statistics_mask;\n+\t\n+\tret = rte_mtr_create(port_id, mtr_id, &params, shared, &error);\n+\tif (ret != 0) {\n+\t\tprint_err_msg(&error);\n+\t\treturn;\n+\t}\n+}\n+\n+cmdline_parse_inst_t cmd_set_port_meter = {\n+\t.f = cmd_set_port_meter_parsed,\n+\t.data = NULL,\n+\t.help_str = \"Set port meter\",\n+\t.tokens = {\n+\t\t(void *)&cmd_set_port_meter_set,\n+\t\t(void *)&cmd_set_port_meter_port,\n+\t\t(void *)&cmd_set_port_meter_meter,\n+\t\t(void *)&cmd_set_port_meter_port_id,\n+\t\t(void *)&cmd_set_port_meter_mtr_id,\n+\t\t(void *)&cmd_set_port_meter_profile_id,\n+\t\t(void *)&cmd_set_port_meter_g_action,\n+\t\t(void *)&cmd_set_port_meter_y_action,\n+\t\t(void *)&cmd_set_port_meter_r_action,\n+\t\t(void *)&cmd_set_port_meter_statistics_mask,\n+\t\t(void *)&cmd_set_port_meter_shared,\t\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;\n+\tcmdline_fixed_string_t port;\n+\tcmdline_fixed_string_t meter;\n+\tuint8_t port_id;\n+\tuint32_t mtr_id;\n+};\n+\n+cmdline_parse_token_string_t cmd_del_port_meter_del =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_del_port_meter_result, del, \"del\");\n+cmdline_parse_token_string_t cmd_del_port_meter_port =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_del_port_meter_result, port, \"port\");\n+cmdline_parse_token_string_t cmd_del_port_meter_meter =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_del_port_meter_result, meter, \"meter\");\n+cmdline_parse_token_num_t cmd_del_port_meter_port_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_del_port_meter_result, port_id, UINT8);\n+cmdline_parse_token_num_t cmd_del_port_meter_mtr_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_del_port_meter_result, mtr_id, UINT32);\n+\n+static void cmd_del_port_meter_parsed(void *parsed_result,\n+\t__attribute__((unused)) struct cmdline *cl,\n+\t__attribute__((unused)) void *data)\n+{\n+\tstruct cmd_del_port_meter_result *res = parsed_result;\n+\tstruct rte_mtr_error error;\n+\tuint32_t mtr_id = res->mtr_id;\n+\tuint8_t port_id = res->port_id;\n+\t\n+\tint ret;\n+\n+\tif (port_id_is_invalid(port_id, ENABLED_WARN))\n+\t\treturn;\n+\n+\t/* Destroy Meter */\n+\tret = rte_mtr_destroy(port_id, mtr_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 = {\n+\t.f = cmd_del_port_meter_parsed,\n+\t.data = NULL,\n+\t.help_str = \"Delete port meter\",\n+\t.tokens = {\n+\t\t(void *)&cmd_del_port_meter_del,\n+\t\t(void *)&cmd_del_port_meter_port,\n+\t\t(void *)&cmd_del_port_meter_meter,\n+\t\t(void *)&cmd_del_port_meter_port_id,\n+\t\t(void *)&cmd_del_port_meter_mtr_id,\n+\t\tNULL,\n+\t},\n+};\n+\n+/* *** Set Port Meter Profile *** */\n+struct cmd_set_port_meter_profile_result {\n+\tcmdline_fixed_string_t set;\n+\tcmdline_fixed_string_t port;\n+\tcmdline_fixed_string_t meter;\n+\tcmdline_fixed_string_t profile;\n+\tuint8_t port_id;\n+\tuint32_t mtr_id;\n+\tuint32_t profile_id;\n+};\n+\n+cmdline_parse_token_string_t cmd_set_port_meter_profile_set =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_profile_result, set, \"set\");\n+cmdline_parse_token_string_t cmd_set_port_meter_profile_port =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_profile_result, port, \"port\");\n+cmdline_parse_token_string_t cmd_set_port_meter_profile_meter =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_profile_result, meter, \"meter\");\n+cmdline_parse_token_string_t cmd_set_port_meter_profile_profile =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_profile_result, profile, \"profile\");\n+cmdline_parse_token_num_t cmd_set_port_meter_profile_port_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_profile_result, port_id, UINT8);\n+cmdline_parse_token_num_t cmd_set_port_meter_profile_mtr_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_profile_result, mtr_id, UINT32);\n+cmdline_parse_token_num_t cmd_set_port_meter_profile_profile_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_profile_result, profile_id, UINT32);\n+\n+static void cmd_set_port_meter_profile_parsed(void *parsed_result,\n+\t__attribute__((unused)) struct cmdline *cl,\n+\t__attribute__((unused)) void *data)\n+{\n+\tstruct cmd_set_port_meter_profile_result *res = parsed_result;\n+\tstruct rte_mtr_error error;\n+\tuint32_t mtr_id = res->mtr_id;\n+\tuint32_t profile_id = res->profile_id;\n+\tuint8_t port_id = res->port_id;\n+\t\n+\tint ret;\n+\n+\tif (port_id_is_invalid(port_id, ENABLED_WARN))\n+\t\treturn;\n+\n+\t/* Set meter profile */\n+\tret = rte_mtr_meter_profile_update(port_id, mtr_id,\n+\t\tprofile_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_set_port_meter_profile = {\n+\t.f = cmd_set_port_meter_profile_parsed,\n+\t.data = NULL,\n+\t.help_str = \"Set port meter profile\",\n+\t.tokens = {\n+\t\t(void *)&cmd_set_port_meter_profile_set,\n+\t\t(void *)&cmd_set_port_meter_profile_port,\n+\t\t(void *)&cmd_set_port_meter_profile_meter,\n+\t\t(void *)&cmd_set_port_meter_profile_profile,\n+\t\t(void *)&cmd_set_port_meter_profile_port_id,\n+\t\t(void *)&cmd_set_port_meter_profile_mtr_id,\n+\t\t(void *)&cmd_set_port_meter_profile_profile_id,\n+\t\tNULL,\n+\t},\n+};\n+\n+/* *** Set Port Meter Policer Action *** */\n+struct cmd_set_port_meter_policer_action_result {\n+\tcmdline_fixed_string_t set;\n+\tcmdline_fixed_string_t port;\n+\tcmdline_fixed_string_t meter;\n+\tcmdline_fixed_string_t policer;\n+\tcmdline_fixed_string_t action;\n+\tuint8_t port_id;\n+\tuint32_t mtr_id;\n+\tcmdline_fixed_string_t color;\n+\tcmdline_fixed_string_t policer_action;\n+};\n+\n+cmdline_parse_token_string_t cmd_set_port_meter_policer_action_set =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_policer_action_result, set, \"set\");\n+cmdline_parse_token_string_t cmd_set_port_meter_policer_action_port =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_policer_action_result, port, \"port\");\n+cmdline_parse_token_string_t cmd_set_port_meter_policer_action_meter =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_policer_action_result, meter, \"meter\");\n+cmdline_parse_token_string_t cmd_set_port_meter_policer_action_policer =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_policer_action_result, policer, \"policer\");\n+cmdline_parse_token_string_t cmd_set_port_meter_policer_action_action =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_policer_action_result, action, \"action\");\n+cmdline_parse_token_num_t cmd_set_port_meter_policer_action_port_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_policer_action_result, port_id, UINT8);\n+cmdline_parse_token_num_t cmd_set_port_meter_policer_action_mtr_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_policer_action_result, mtr_id, UINT32);\n+cmdline_parse_token_string_t cmd_set_port_meter_policer_action_color =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_policer_action_result, color, \"G#Y#R\");\n+cmdline_parse_token_string_t cmd_set_port_meter_policer_action_policer_action =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_policer_action_result,\n+\t\tpolicer_action, \"G#Y#R#D\");\n+\n+static void cmd_set_port_meter_policer_action_parsed(void *parsed_result,\n+\t__attribute__((unused)) struct cmdline *cl,\n+\t__attribute__((unused)) void *data)\n+{\n+\tstruct cmd_set_port_meter_policer_action_result *res = parsed_result;\n+\tenum rte_mtr_color color;\n+\tenum rte_mtr_policer_action action[RTE_MTR_COLORS];\n+\tstruct rte_mtr_error error;\n+\tuint32_t mtr_id = res->mtr_id;\n+\tuint8_t port_id = res->port_id;\n+\tchar *c = res->color;\n+\tchar *a = res->policer_action;\n+\tint ret;\n+\n+\tif (port_id_is_invalid(port_id, ENABLED_WARN))\n+\t\treturn;\n+\n+\t/* Color */\n+\tif (strcmp(c, \"G\") == 0)\n+\t\tcolor = RTE_MTR_GREEN;\n+\telse if (strcmp(c, \"Y\") == 0)\n+\t\tcolor = RTE_MTR_YELLOW;\n+\telse if (strcmp(c, \"Y\") == 0)\n+\t\tcolor = RTE_MTR_RED;\n+\telse\n+\t\tcolor = RTE_MTR_COLORS;\n+\n+\t/* Action */\n+\tif (strcmp(a, \"G\") == 0)\n+\t\taction[color] = MTR_POLICER_ACTION_COLOR_GREEN;\n+\telse if (strcmp(a, \"Y\") == 0)\n+\t\taction[color] = MTR_POLICER_ACTION_COLOR_YELLOW;\n+\telse if (strcmp(a, \"Y\") == 0)\n+\t\taction[color] = MTR_POLICER_ACTION_COLOR_RED;\n+\telse\n+\t\taction[color] = MTR_POLICER_ACTION_DROP;\n+\n+\tret = rte_mtr_policer_actions_update(port_id, mtr_id,\n+\t\t1 << color, action, &error);\n+\tif (ret != 0) {\n+\t\tprint_err_msg(&error);\n+\t\treturn;\n+\t}\n+}\n+\n+cmdline_parse_inst_t cmd_set_port_meter_policer_action = {\n+\t.f = cmd_set_port_meter_policer_action_parsed,\n+\t.data = NULL,\n+\t.help_str = \"Set port meter policer action\",\n+\t.tokens = {\n+\t\t(void *)&cmd_set_port_meter_policer_action_set,\n+\t\t(void *)&cmd_set_port_meter_policer_action_port,\n+\t\t(void *)&cmd_set_port_meter_policer_action_meter,\n+\t\t(void *)&cmd_set_port_meter_policer_action_policer,\n+\t\t(void *)&cmd_set_port_meter_policer_action_action,\n+\t\t(void *)&cmd_set_port_meter_policer_action_port_id,\n+\t\t(void *)&cmd_set_port_meter_policer_action_mtr_id,\n+\t\t(void *)&cmd_set_port_meter_policer_action_color,\n+\t\t(void *)&cmd_set_port_meter_policer_action_policer_action,\n+\t\tNULL,\n+\t},\n+};\n+\n+/* *** Set Port Meter Stats Mask *** */\n+struct cmd_set_port_meter_stats_mask_result {\n+\tcmdline_fixed_string_t set;\n+\tcmdline_fixed_string_t port;\n+\tcmdline_fixed_string_t meter;\n+\tcmdline_fixed_string_t stats;\n+\tcmdline_fixed_string_t mask;\n+\tuint8_t port_id;\n+\tuint32_t mtr_id;\n+\tuint64_t stats_mask;\n+};\n+\n+cmdline_parse_token_string_t cmd_set_port_meter_stats_mask_set =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_stats_mask_result, set, \"set\");\n+cmdline_parse_token_string_t cmd_set_port_meter_stats_mask_port =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_stats_mask_result, port, \"port\");\n+cmdline_parse_token_string_t cmd_set_port_meter_stats_mask_meter =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_stats_mask_result, meter, \"meter\");\n+cmdline_parse_token_string_t cmd_set_port_meter_stats_mask_stats =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_stats_mask_result, stats, \"stats\");\n+cmdline_parse_token_string_t cmd_set_port_meter_stats_mask_mask =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_stats_mask_result, mask, \"mask\");\n+cmdline_parse_token_num_t cmd_set_port_meter_stats_mask_port_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_stats_mask_result, port_id, UINT8);\n+cmdline_parse_token_num_t cmd_set_port_meter_stats_mask_mtr_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_stats_mask_result, mtr_id, UINT32);\n+cmdline_parse_token_num_t cmd_set_port_meter_stats_mask_stats_mask =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_set_port_meter_stats_mask_result, stats_mask, UINT64);\n+\n+static void cmd_set_port_meter_stats_mask_parsed(void *parsed_result,\n+\t__attribute__((unused)) struct cmdline *cl,\n+\t__attribute__((unused)) void *data)\n+{\n+\tstruct cmd_set_port_meter_stats_mask_result *res = parsed_result;\n+\tstruct rte_mtr_error error;\n+\tuint64_t stats_mask = res->stats_mask;\n+\tuint32_t mtr_id = res->mtr_id;\n+\tuint8_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+\tret = rte_mtr_stats_update(port_id, mtr_id, stats_mask, &error);\n+\tif (ret != 0) {\n+\t\tprint_err_msg(&error);\n+\t\treturn;\n+\t}\n+}\n+\n+cmdline_parse_inst_t cmd_set_port_meter_stats_mask = {\n+\t.f = cmd_set_port_meter_stats_mask_parsed,\n+\t.data = NULL,\n+\t.help_str = \"Set port meter stats mask\",\n+\t.tokens = {\n+\t\t(void *)&cmd_set_port_meter_stats_mask_set,\n+\t\t(void *)&cmd_set_port_meter_stats_mask_port,\n+\t\t(void *)&cmd_set_port_meter_stats_mask_meter,\n+\t\t(void *)&cmd_set_port_meter_stats_mask_stats,\n+\t\t(void *)&cmd_set_port_meter_stats_mask_mask,\n+\t\t(void *)&cmd_set_port_meter_stats_mask_port_id,\n+\t\t(void *)&cmd_set_port_meter_stats_mask_mtr_id,\n+\t\t(void *)&cmd_set_port_meter_stats_mask_stats_mask,\n+\t\tNULL,\n+\t},\n+};\n+\n+/* *** Show Port Meter Stats *** */\n+struct cmd_show_port_meter_stats_result {\n+\tcmdline_fixed_string_t show;\n+\tcmdline_fixed_string_t port;\n+\tcmdline_fixed_string_t meter;\n+\tcmdline_fixed_string_t stats;\n+\tuint8_t port_id;\n+\tuint32_t mtr_id;\n+\tuint32_t clear;\n+};\n+\n+cmdline_parse_token_string_t cmd_show_port_meter_stats_show =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_show_port_meter_stats_result, show, \"show\");\n+cmdline_parse_token_string_t cmd_show_port_meter_stats_port =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_show_port_meter_stats_result, port, \"port\");\n+cmdline_parse_token_string_t cmd_show_port_meter_stats_meter =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_show_port_meter_stats_result, meter, \"meter\");\n+cmdline_parse_token_string_t cmd_show_port_meter_stats_stats =\n+\tTOKEN_STRING_INITIALIZER(\n+\t\tstruct cmd_show_port_meter_stats_result, stats, \"stats\");\n+cmdline_parse_token_num_t cmd_show_port_meter_stats_port_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_show_port_meter_stats_result, port_id, UINT8);\n+cmdline_parse_token_num_t cmd_show_port_meter_stats_mtr_id =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_show_port_meter_stats_result, mtr_id, UINT32);\n+cmdline_parse_token_num_t cmd_show_port_meter_stats_clear =\n+\tTOKEN_NUM_INITIALIZER(\n+\t\tstruct cmd_show_port_meter_stats_result, clear, UINT32);\n+\n+static void cmd_show_port_meter_stats_parsed(void *parsed_result,\n+\t__attribute__((unused)) struct cmdline *cl,\n+\t__attribute__((unused)) void *data)\n+{\n+\tstruct cmd_show_port_meter_stats_result *res = parsed_result;\n+\tstruct rte_mtr_stats stats;\n+\tuint64_t stats_mask = 0;\n+\tstruct rte_mtr_error error;\n+\tuint32_t mtr_id = res->mtr_id;\n+\tuint32_t clear = res->clear;\n+\tuint8_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+\tmemset(&stats, 0, sizeof(struct rte_mtr_stats));\n+\tret = rte_mtr_stats_read(port_id, mtr_id, &stats,\n+\t\t&stats_mask, clear, &error);\n+\tif (ret != 0) {\n+\t\tprint_err_msg(&error);\n+\t\treturn;\n+\t}\n+\n+\t/* Display stats */\n+\tif (stats_mask & RTE_MTR_STATS_N_PKTS_GREEN)\n+\t\tprintf(\"\\tPkts G: %\" PRIu64 \"\\n\",\n+\t\t\tstats.n_pkts[RTE_MTR_GREEN]);\n+\tif (stats_mask & RTE_MTR_STATS_N_BYTES_GREEN)\n+\t\tprintf(\"\\tBytes G: %\" PRIu64 \"\\n\",\n+\t\t\tstats.n_bytes[RTE_MTR_GREEN]);\n+\tif (stats_mask & RTE_MTR_STATS_N_PKTS_YELLOW)\n+\t\tprintf(\"\\tPkts Y: %\" PRIu64 \"\\n\",\n+\t\t\tstats.n_pkts[RTE_MTR_YELLOW]);\n+\tif (stats_mask & RTE_MTR_STATS_N_BYTES_YELLOW)\n+\t\tprintf(\"\\tBytes Y: %\" PRIu64 \"\\n\",\n+\t\t\tstats.n_bytes[RTE_MTR_YELLOW]);\n+\tif (stats_mask & RTE_MTR_STATS_N_PKTS_RED)\n+\t\tprintf(\"\\tPkts R: %\" PRIu64 \"\\n\",\n+\t\t\tstats.n_pkts[RTE_MTR_RED]);\n+\tif (stats_mask & RTE_MTR_STATS_N_BYTES_RED)\n+\t\tprintf(\"\\tBytes Y: %\" PRIu64 \"\\n\",\n+\t\t\tstats.n_bytes[RTE_MTR_RED]);\n+\tif (stats_mask & RTE_MTR_STATS_N_PKTS_DROPPED)\n+\t\tprintf(\"\\tPkts DROPPED: %\" PRIu64 \"\\n\",\n+\t\t\tstats.n_pkts_dropped);\n+\tif (stats_mask & RTE_MTR_STATS_N_BYTES_DROPPED)\n+\t\tprintf(\"\\tBytes DROPPED: %\" PRIu64 \"\\n\",\n+\t\t\tstats.n_bytes_dropped);\n+}\n+\n+cmdline_parse_inst_t cmd_show_port_meter_stats = {\n+\t.f = cmd_show_port_meter_stats_parsed,\n+\t.data = NULL,\n+\t.help_str = \"Show port meter stats\",\n+\t.tokens = {\n+\t\t(void *)&cmd_show_port_meter_stats_show,\n+\t\t(void *)&cmd_show_port_meter_stats_port,\n+\t\t(void *)&cmd_show_port_meter_stats_meter,\n+\t\t(void *)&cmd_show_port_meter_stats_stats,\n+\t\t(void *)&cmd_show_port_meter_stats_port_id,\n+\t\t(void *)&cmd_show_port_meter_stats_mtr_id,\n+\t\t(void *)&cmd_show_port_meter_stats_clear,\n+\t\tNULL,\n+\t},\n+};\ndiff --git a/app/test-pmd/cmdline_mtr.h b/app/test-pmd/cmdline_mtr.h\nnew file mode 100644\nindex 0000000..5e9af77\n--- /dev/null\n+++ b/app/test-pmd/cmdline_mtr.h\n@@ -0,0 +1,49 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2017 Intel Corporation. All rights reserved.\n+ *   All rights reserved.\n+ *\n+ *   Redistribution and use in source and binary forms, with or without\n+ *   modification, are permitted provided that the following conditions\n+ *   are met:\n+ *\n+ *     * Redistributions of source code must retain the above copyright\n+ *       notice, this list of conditions and the following disclaimer.\n+ *     * Redistributions in binary form must reproduce the above copyright\n+ *       notice, this list of conditions and the following disclaimer in\n+ *       the documentation and/or other materials provided with the\n+ *       distribution.\n+ *     * Neither the name of Intel Corporation nor the names of its\n+ *       contributors may be used to endorse or promote products derived\n+ *       from this software without specific prior written permission.\n+ *\n+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#ifndef _CMDLINE_MTR_H_\n+#define _CMDLINE_MTR_H_\n+\n+/* Traffic Metering and Policing */\n+extern cmdline_parse_inst_t cmd_add_port_meter_profile_srtcm;\n+extern cmdline_parse_inst_t cmd_add_port_meter_profile_trtcm;\n+extern cmdline_parse_inst_t cmd_add_port_meter_profile_trtcm_rfc4115;\n+extern cmdline_parse_inst_t cmd_del_port_meter_profile;\n+extern cmdline_parse_inst_t cmd_set_port_meter;\n+extern cmdline_parse_inst_t cmd_del_port_meter;\n+extern cmdline_parse_inst_t cmd_set_port_meter_profile;\n+extern cmdline_parse_inst_t cmd_set_port_meter_policer_action;\n+extern cmdline_parse_inst_t cmd_set_port_meter_stats_mask;\n+extern cmdline_parse_inst_t cmd_show_port_meter_stats;\n+\n+#endif /* _CMDLINE_MTR_H_ */\n\\ No newline at end of file\n",
    "prefixes": [
        "dpdk-dev",
        "V2",
        "5/5"
    ]
}