From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id C2B8DA0C4B;
	Mon,  8 Nov 2021 09:54:22 +0100 (CET)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 037634111E;
	Mon,  8 Nov 2021 09:54:16 +0100 (CET)
Received: from NAM11-BN8-obe.outbound.protection.outlook.com
 (mail-bn8nam11on2051.outbound.protection.outlook.com [40.107.236.51])
 by mails.dpdk.org (Postfix) with ESMTP id 24A7A40DF7
 for <dev@dpdk.org>; Mon,  8 Nov 2021 09:54:14 +0100 (CET)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=CF4P1sZjBIycQ0fGnlxxUwoIy8C+QIXcJgpLpDt1YHJ9tc76uHRdSLHFWE0FnfLW9MsGI7jNtR3skap3tYJ1/eT7AyzCZ7sJB7N9mJloMfducLt4QoGzSt+UyHD12hAANCOVLLzIPAz5nlpQDFoSDvVZ/oDynJUCAYSnCNLTACmAwV+xGUy4JfhM7mvme2ul6MAntckmtCTdjDYuP97/oM2AAwScoetHzaFu4rMHP+k8nXWT3Xy6cJob3F1VTJOweQ7Ax0b2/1C5eVVqbmFXZLa0SZ8I5u6KyJc9kgumlSTvQHjpCbefJklZ2BrkJpAvW71eutX0zHEgmSAnDbx2uQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; 
 s=arcselector9901;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
 bh=jV3Sj8KRPvFpWi011Mhqi8unVt3J/lxbA9/RYlASJJQ=;
 b=Ht6UZKNvtebmubYgY0mZT7ZlYFob7dZ20f/mwwtoYQ17es0mjs0gzan5WZLvXgyaz+BvbBO4Rf/maAPumqkkVLS5nGVNGdr2YqJfcp9pFpOyYGQWZ1j+tl02ZWOJhfN8BXbXTWM+pfnFUhnGa7RVcgDfFjQvTy1Rn4SI2V0t6uy+qCf+BPJkGwMb0PVMVrpj0bRfaW79Zr5n4ZZteTeE+W37a342WySUIzw2WoJDbdxpzWscbHWbmJD+bTlcHUmBnTws9iE/0bg2ys7iWz+RceDkcK8Hq4FtFWohH3CUdFQHta3Ws3Bp7qxKmNwwdo47z0sbOMjR1xD+OZKDR7jBTg==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is
 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com;
 dmarc=pass (p=quarantine sp=quarantine pct=100) action=none
 header.from=nvidia.com; dkim=none (message not signed); arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com;
 s=selector2;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=jV3Sj8KRPvFpWi011Mhqi8unVt3J/lxbA9/RYlASJJQ=;
 b=aZeusgFswbChFDCxb4qmEJQi+YBVFInX6VfTsx7rqyzpSPooT9s4rV4rTv7Cnxsgv3rfQEY7cmVjokl24Oz/zj8SbsKr/j78KsLOg8assaGcz5sneEnWXBlqartB0F7PDOk+++/T1xVp9uBnARavE8dIqKKLxykQ7aD0oVyxv4qxmS4sjKWqFuUdbkTHj0qlLVEu0p/6WxsK1wedoNNlq4NRmi65Pa/plgbMn8DnpmUarrzAp85Tbmd7YfMYRr9dE6kdp+Tt8Wx/E3OH0IEw87IuIHsz7kf8oXkegbz06S823CJ0Z6osGo7R68/aw/x0IvQEh+bxSe5EvCy8CqS5iA==
Received: from MW2PR16CA0020.namprd16.prod.outlook.com (2603:10b6:907::33) by
 CY4PR1201MB2535.namprd12.prod.outlook.com (2603:10b6:903:db::15) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.13; Mon, 8 Nov
 2021 08:54:10 +0000
Received: from CO1NAM11FT051.eop-nam11.prod.protection.outlook.com
 (2603:10b6:907:0:cafe::fc) by MW2PR16CA0020.outlook.office365.com
 (2603:10b6:907::33) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11 via Frontend
 Transport; Mon, 8 Nov 2021 08:54:10 +0000
X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34)
 smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed)
 header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com;
Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates
 216.228.112.34 as permitted sender) receiver=protection.outlook.com;
 client-ip=216.228.112.34; helo=mail.nvidia.com;
Received: from mail.nvidia.com (216.228.112.34) by
 CO1NAM11FT051.mail.protection.outlook.com (10.13.174.114) with Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id
 15.20.4669.10 via Frontend Transport; Mon, 8 Nov 2021 08:54:09 +0000
Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com
 (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 8 Nov
 2021 08:54:06 +0000
From: Rongwei Liu <rongweil@nvidia.com>
To: <matan@nvidia.com>, <viacheslavo@nvidia.com>, <orika@nvidia.com>,
 <thomas@monjalon.net>, Wisam Jaddo <wisamm@nvidia.com>
CC: <dev@dpdk.org>, <rasland@nvidia.com>, Haifei Luo <haifeil@nvidia.com>,
 Jiawei Wang <jiaweiw@nvidia.com>
Date: Mon, 8 Nov 2021 10:53:50 +0200
Message-ID: <20211108085352.1728466-2-rongweil@nvidia.com>
X-Mailer: git-send-email 2.27.0
In-Reply-To: <20211108085352.1728466-1-rongweil@nvidia.com>
References: <6106963.jHQkdsGB6Q@thomas>
 <20211108085352.1728466-1-rongweil@nvidia.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [172.20.187.5]
X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To
 HQMAIL107.nvidia.com (172.20.187.13)
X-EOPAttributedMessage: 0
X-MS-PublicTrafficType: Email
X-MS-Office365-Filtering-Correlation-Id: d9af4bc7-fa07-40ab-7fb0-08d9a2955464
X-MS-TrafficTypeDiagnostic: CY4PR1201MB2535:
X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr
X-Microsoft-Antispam-PRVS: <CY4PR1201MB253567AEBE019D59AD9D45FAAB919@CY4PR1201MB2535.namprd12.prod.outlook.com>
X-MS-Oob-TLC-OOBClassifiers: OLM:170;
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: bER/b9esDdjc2ebDtVdhZpai7Te3mNeKGtJuCW0Nx9xA72ezqwogtxHKMLhXSm8OVJehNiGmfP//lAOnu3crKyzEtVW6LbcqOM1qjiGpQFy+RhW/TMcZSZQogG2k4S/pKtY7wc5BPJ99KsfMCKySaIYJL9WqOincvM0D50c1yiTFdSUY08Xcf2GbFL1iqHEz2M041PUAg/UOPik8/uGQIZPnzMu4AVGLzvrCXq7mow0Kthw3VAi1ZOmcO3kdOYiMn6GSTyf00Ji/C/kC6VmrZMxwiq9BJgWOY4kdLLPfUlLyGPo0XWgypWi1nPieHHxvl4nrfYA+gFhlnp51Q2ZjEE2hWNVDAxf8IyZ+egESRT/nEe4PkeAAG61FAAynTbzEedjfrkrcAw9ObzKkAPk5WHyEVsfLziGq2JAqY3bTmLJEF7O+6PO4cX+koqHavzmOW81XLqMlI25xhiLcAkhy9Sp0+PEflcepf/yTpvmnoL5p77rG+emlb4otJU081CO2m30zFPLadtBfKlGahrlYk9ChuI92akI9PD4s7K5LzSSdbSvtZk9VgWpN8H1l4OLuDcMUEitSz0tnFU4/Ziv4jJNdgz7+SIcxZ5TlcQDa1BRg5NL6HaZzF1OfO+/dlbTJWkAKJNVEguWGsJcUrVUYorsgTJM3gtjro1O9FfckuWK9eZeMGpUbyjOvX4zsACkBwnZiFVJS7p8L7slWRn6EBw==
X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:;
 IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE;
 SFS:(4636009)(36840700001)(46966006)(6636002)(2616005)(336012)(8676002)(1076003)(16526019)(110136005)(2906002)(55016002)(426003)(508600001)(356005)(30864003)(70206006)(47076005)(5660300002)(8936002)(70586007)(36756003)(54906003)(83380400001)(7696005)(4326008)(36860700001)(7636003)(86362001)(186003)(6666004)(36906005)(316002)(107886003)(26005)(6286002)(82310400003);
 DIR:OUT; SFP:1101; 
X-OriginatorOrg: Nvidia.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Nov 2021 08:54:09.8385 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: d9af4bc7-fa07-40ab-7fb0-08d9a2955464
X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a
X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34];
 Helo=[mail.nvidia.com]
X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT051.eop-nam11.prod.protection.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Anonymous
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1201MB2535
Subject: [dpdk-dev] [PATCH v4 1/3] app/flow-perf: support meter policy API
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>,
 <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>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

Add option "policy-mtr" to indicate if meter creation will include policy
or not. Meter creation will keep the same without it.

With "policy-mtr", the policy is introduced. API create_meter_policy
is to create a policy. API create_meter_rule will use it to create
a meter. The value of it is used to specify meter policy green color
actions.

Signed-off-by: Haifei Luo <haifeil@nvidia.com>
Signed-off-by: Jiawei Wang <jiaweiw@nvidia.com>
Signed-off-by: Rongwei Liu <rongweil@nvidia.com>
Acked-by: Wisam Monther <wisamm@nvidia.com>
---
 app/test-flow-perf/main.c      | 807 +++++++++++++++++++--------------
 doc/guides/tools/flow-perf.rst |   3 +
 2 files changed, 467 insertions(+), 343 deletions(-)

diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c
index c1ad9bb0a3..966ca9fc63 100644
--- a/app/test-flow-perf/main.c
+++ b/app/test-flow-perf/main.c
@@ -37,6 +37,7 @@
 #include <rte_mtr.h>
 
 #include "config.h"
+#include "actions_gen.h"
 #include "flow_gen.h"
 
 #define MAX_BATCHES_COUNT          100
@@ -49,10 +50,13 @@ static uint8_t flow_group;
 
 static uint64_t encap_data;
 static uint64_t decap_data;
+static uint64_t all_actions[RTE_COLORS][MAX_ACTIONS_NUM];
+static char *actions_str[RTE_COLORS];
 
 static uint64_t flow_items[MAX_ITEMS_NUM];
 static uint64_t flow_actions[MAX_ACTIONS_NUM];
 static uint64_t flow_attrs[MAX_ATTRS_NUM];
+static uint32_t policy_id[MAX_PORTS];
 static uint8_t items_idx, actions_idx, attrs_idx;
 
 static uint64_t ports_mask;
@@ -63,6 +67,7 @@ static bool delete_flag;
 static bool dump_socket_mem_flag;
 static bool enable_fwd;
 static bool unique_data;
+static bool policy_mtr;
 
 static uint8_t rx_queues_count;
 static uint8_t tx_queues_count;
@@ -124,6 +129,337 @@ static struct multi_cores_pool mc_pool = {
 	.cores_count = 1,
 };
 
+static const struct option_dict {
+	const char *str;
+	const uint64_t mask;
+	uint64_t *map;
+	uint8_t *map_idx;
+
+} flow_options[] = {
+	{
+		.str = "ether",
+		.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_ETH),
+		.map = &flow_items[0],
+		.map_idx = &items_idx
+	},
+	{
+		.str = "ipv4",
+		.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_IPV4),
+		.map = &flow_items[0],
+		.map_idx = &items_idx
+	},
+	{
+		.str = "ipv6",
+		.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_IPV6),
+		.map = &flow_items[0],
+		.map_idx = &items_idx
+	},
+	{
+		.str = "vlan",
+		.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_VLAN),
+		.map = &flow_items[0],
+		.map_idx = &items_idx
+	},
+	{
+		.str = "tcp",
+		.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_TCP),
+		.map = &flow_items[0],
+		.map_idx = &items_idx
+	},
+	{
+		.str = "udp",
+		.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_UDP),
+		.map = &flow_items[0],
+		.map_idx = &items_idx
+	},
+	{
+		.str = "vxlan",
+		.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_VXLAN),
+		.map = &flow_items[0],
+		.map_idx = &items_idx
+	},
+	{
+		.str = "vxlan-gpe",
+		.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_VXLAN_GPE),
+		.map = &flow_items[0],
+		.map_idx = &items_idx
+	},
+	{
+		.str = "gre",
+		.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_GRE),
+		.map = &flow_items[0],
+		.map_idx = &items_idx
+	},
+	{
+		.str = "geneve",
+		.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_GENEVE),
+		.map = &flow_items[0],
+		.map_idx = &items_idx
+	},
+	{
+		.str = "gtp",
+		.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_GTP),
+		.map = &flow_items[0],
+		.map_idx = &items_idx
+	},
+	{
+		.str = "meta",
+		.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_META),
+		.map = &flow_items[0],
+		.map_idx = &items_idx
+	},
+	{
+		.str = "tag",
+		.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_TAG),
+		.map = &flow_items[0],
+		.map_idx = &items_idx
+	},
+	{
+		.str = "icmpv4",
+		.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_ICMP),
+		.map = &flow_items[0],
+		.map_idx = &items_idx
+	},
+	{
+		.str = "icmpv6",
+		.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_ICMP6),
+		.map = &flow_items[0],
+		.map_idx = &items_idx
+	},
+	{
+		.str = "ingress",
+		.mask = INGRESS,
+		.map = &flow_attrs[0],
+		.map_idx = &attrs_idx
+	},
+	{
+		.str = "egress",
+		.mask = EGRESS,
+		.map = &flow_attrs[0],
+		.map_idx = &attrs_idx
+	},
+	{
+		.str = "transfer",
+		.mask = TRANSFER,
+		.map = &flow_attrs[0],
+		.map_idx = &attrs_idx
+	},
+	{
+		.str = "port-id",
+		.mask = FLOW_ACTION_MASK(RTE_FLOW_ACTION_TYPE_PORT_ID),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "rss",
+		.mask = FLOW_ACTION_MASK(RTE_FLOW_ACTION_TYPE_RSS),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "queue",
+		.mask = FLOW_ACTION_MASK(RTE_FLOW_ACTION_TYPE_QUEUE),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "jump",
+		.mask = FLOW_ACTION_MASK(RTE_FLOW_ACTION_TYPE_JUMP),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "mark",
+		.mask = FLOW_ACTION_MASK(RTE_FLOW_ACTION_TYPE_MARK),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "count",
+		.mask = FLOW_ACTION_MASK(RTE_FLOW_ACTION_TYPE_COUNT),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "set-meta",
+		.mask = FLOW_ACTION_MASK(RTE_FLOW_ACTION_TYPE_SET_META),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "set-tag",
+		.mask = FLOW_ACTION_MASK(RTE_FLOW_ACTION_TYPE_SET_TAG),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "drop",
+		.mask = FLOW_ACTION_MASK(RTE_FLOW_ACTION_TYPE_DROP),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "set-src-mac",
+		.mask = FLOW_ACTION_MASK(
+			RTE_FLOW_ACTION_TYPE_SET_MAC_SRC
+		),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "set-dst-mac",
+		.mask = FLOW_ACTION_MASK(
+			RTE_FLOW_ACTION_TYPE_SET_MAC_DST
+		),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "set-src-ipv4",
+		.mask = FLOW_ACTION_MASK(
+			RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
+		),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "set-dst-ipv4",
+		.mask = FLOW_ACTION_MASK(
+			RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
+		),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "set-src-ipv6",
+		.mask = FLOW_ACTION_MASK(
+			RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
+		),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "set-dst-ipv6",
+		.mask = FLOW_ACTION_MASK(
+			RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
+		),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "set-src-tp",
+		.mask = FLOW_ACTION_MASK(
+			RTE_FLOW_ACTION_TYPE_SET_TP_SRC
+		),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "set-dst-tp",
+		.mask = FLOW_ACTION_MASK(
+			RTE_FLOW_ACTION_TYPE_SET_TP_DST
+		),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "inc-tcp-ack",
+		.mask = FLOW_ACTION_MASK(
+			RTE_FLOW_ACTION_TYPE_INC_TCP_ACK
+		),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "dec-tcp-ack",
+		.mask = FLOW_ACTION_MASK(
+			RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK
+		),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "inc-tcp-seq",
+		.mask = FLOW_ACTION_MASK(
+			RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ
+		),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "dec-tcp-seq",
+		.mask = FLOW_ACTION_MASK(
+			RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ
+		),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "set-ttl",
+		.mask = FLOW_ACTION_MASK(
+			RTE_FLOW_ACTION_TYPE_SET_TTL
+		),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "dec-ttl",
+		.mask = FLOW_ACTION_MASK(
+			RTE_FLOW_ACTION_TYPE_DEC_TTL
+		),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "set-ipv4-dscp",
+		.mask = FLOW_ACTION_MASK(
+			RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP
+		),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "set-ipv6-dscp",
+		.mask = FLOW_ACTION_MASK(
+			RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP
+		),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "flag",
+		.mask = FLOW_ACTION_MASK(
+			RTE_FLOW_ACTION_TYPE_FLAG
+		),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "meter",
+		.mask = FLOW_ACTION_MASK(
+			RTE_FLOW_ACTION_TYPE_METER
+		),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "vxlan-encap",
+		.mask = FLOW_ACTION_MASK(
+			RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
+		),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+	{
+		.str = "vxlan-decap",
+		.mask = FLOW_ACTION_MASK(
+			RTE_FLOW_ACTION_TYPE_VXLAN_DECAP
+		),
+		.map = &flow_actions[0],
+		.map_idx = &actions_idx
+	},
+};
+
 static void
 usage(char *progname)
 {
@@ -143,7 +479,8 @@ usage(char *progname)
 	printf("  --portmask=N: hexadecimal bitmask of ports used\n");
 	printf("  --unique-data: flag to set using unique data for all"
 		" actions that support data, such as header modify and encap actions\n");
-
+	printf("  --policy-mtr=\"g1,g2:y1:r1\": To create meter with specified "
+		"color actions\n");
 	printf("To set flow attributes:\n");
 	printf("  --ingress: set ingress attribute in flows\n");
 	printf("  --egress: set egress attribute in flows\n");
@@ -236,6 +573,44 @@ usage(char *progname)
 	printf("  --vxlan-decap: add vxlan_decap action to flow actions\n");
 }
 
+static void
+handle_meter_policy(char *prog, char *arg)
+{
+	char *token;
+	size_t i, j, k;
+	j = 0;
+	k = 0;
+	policy_mtr = true;
+	token = strsep(&arg, ":\0");
+	while (token != NULL && j < RTE_COLORS) {
+		actions_str[j++] = token;
+		token = strsep(&arg, ":\0");
+	}
+	j = 0;
+	token = strtok(actions_str[0], ",\0");
+	while (token == NULL && j < RTE_COLORS - 1)
+		token = strtok(actions_str[++j], ",\0");
+	while (j < RTE_COLORS && token != NULL) {
+		for (i = 0; i < RTE_DIM(flow_options); i++) {
+			if (!strcmp(token, flow_options[i].str)) {
+				all_actions[j][k++] = flow_options[i].mask;
+				break;
+			}
+		}
+		/* Reached last item with no match */
+		if (i >= RTE_DIM(flow_options)) {
+			fprintf(stderr, "Invalid actions item: %s\n", token);
+			usage(prog);
+			rte_exit(EXIT_SUCCESS, "Invalid actions item\n");
+		}
+		token = strtok(NULL, ",\0");
+		while (!token && j < RTE_COLORS - 1) {
+			token = strtok(actions_str[++j], ",\0");
+			k = 0;
+		}
+	}
+}
+
 static void
 args_parse(int argc, char **argv)
 {
@@ -243,341 +618,11 @@ args_parse(int argc, char **argv)
 	char **argvopt;
 	char *token;
 	char *end;
+	char *arg;
 	int n, opt;
 	int opt_idx;
 	size_t i;
 
-	static const struct option_dict {
-		const char *str;
-		const uint64_t mask;
-		uint64_t *map;
-		uint8_t *map_idx;
-
-	} flow_options[] = {
-		{
-			.str = "ether",
-			.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_ETH),
-			.map = &flow_items[0],
-			.map_idx = &items_idx
-		},
-		{
-			.str = "ipv4",
-			.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_IPV4),
-			.map = &flow_items[0],
-			.map_idx = &items_idx
-		},
-		{
-			.str = "ipv6",
-			.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_IPV6),
-			.map = &flow_items[0],
-			.map_idx = &items_idx
-		},
-		{
-			.str = "vlan",
-			.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_VLAN),
-			.map = &flow_items[0],
-			.map_idx = &items_idx
-		},
-		{
-			.str = "tcp",
-			.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_TCP),
-			.map = &flow_items[0],
-			.map_idx = &items_idx
-		},
-		{
-			.str = "udp",
-			.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_UDP),
-			.map = &flow_items[0],
-			.map_idx = &items_idx
-		},
-		{
-			.str = "vxlan",
-			.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_VXLAN),
-			.map = &flow_items[0],
-			.map_idx = &items_idx
-		},
-		{
-			.str = "vxlan-gpe",
-			.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_VXLAN_GPE),
-			.map = &flow_items[0],
-			.map_idx = &items_idx
-		},
-		{
-			.str = "gre",
-			.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_GRE),
-			.map = &flow_items[0],
-			.map_idx = &items_idx
-		},
-		{
-			.str = "geneve",
-			.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_GENEVE),
-			.map = &flow_items[0],
-			.map_idx = &items_idx
-		},
-		{
-			.str = "gtp",
-			.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_GTP),
-			.map = &flow_items[0],
-			.map_idx = &items_idx
-		},
-		{
-			.str = "meta",
-			.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_META),
-			.map = &flow_items[0],
-			.map_idx = &items_idx
-		},
-		{
-			.str = "tag",
-			.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_TAG),
-			.map = &flow_items[0],
-			.map_idx = &items_idx
-		},
-		{
-			.str = "icmpv4",
-			.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_ICMP),
-			.map = &flow_items[0],
-			.map_idx = &items_idx
-		},
-		{
-			.str = "icmpv6",
-			.mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_ICMP6),
-			.map = &flow_items[0],
-			.map_idx = &items_idx
-		},
-		{
-			.str = "ingress",
-			.mask = INGRESS,
-			.map = &flow_attrs[0],
-			.map_idx = &attrs_idx
-		},
-		{
-			.str = "egress",
-			.mask = EGRESS,
-			.map = &flow_attrs[0],
-			.map_idx = &attrs_idx
-		},
-		{
-			.str = "transfer",
-			.mask = TRANSFER,
-			.map = &flow_attrs[0],
-			.map_idx = &attrs_idx
-		},
-		{
-			.str = "port-id",
-			.mask = FLOW_ACTION_MASK(RTE_FLOW_ACTION_TYPE_PORT_ID),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "rss",
-			.mask = FLOW_ACTION_MASK(RTE_FLOW_ACTION_TYPE_RSS),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "queue",
-			.mask = FLOW_ACTION_MASK(RTE_FLOW_ACTION_TYPE_QUEUE),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "jump",
-			.mask = FLOW_ACTION_MASK(RTE_FLOW_ACTION_TYPE_JUMP),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "mark",
-			.mask = FLOW_ACTION_MASK(RTE_FLOW_ACTION_TYPE_MARK),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "count",
-			.mask = FLOW_ACTION_MASK(RTE_FLOW_ACTION_TYPE_COUNT),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "set-meta",
-			.mask = FLOW_ACTION_MASK(RTE_FLOW_ACTION_TYPE_SET_META),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "set-tag",
-			.mask = FLOW_ACTION_MASK(RTE_FLOW_ACTION_TYPE_SET_TAG),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "drop",
-			.mask = FLOW_ACTION_MASK(RTE_FLOW_ACTION_TYPE_DROP),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "set-src-mac",
-			.mask = FLOW_ACTION_MASK(
-				RTE_FLOW_ACTION_TYPE_SET_MAC_SRC
-			),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "set-dst-mac",
-			.mask = FLOW_ACTION_MASK(
-				RTE_FLOW_ACTION_TYPE_SET_MAC_DST
-			),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "set-src-ipv4",
-			.mask = FLOW_ACTION_MASK(
-				RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
-			),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "set-dst-ipv4",
-			.mask = FLOW_ACTION_MASK(
-				RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
-			),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "set-src-ipv6",
-			.mask = FLOW_ACTION_MASK(
-				RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
-			),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "set-dst-ipv6",
-			.mask = FLOW_ACTION_MASK(
-				RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
-			),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "set-src-tp",
-			.mask = FLOW_ACTION_MASK(
-				RTE_FLOW_ACTION_TYPE_SET_TP_SRC
-			),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "set-dst-tp",
-			.mask = FLOW_ACTION_MASK(
-				RTE_FLOW_ACTION_TYPE_SET_TP_DST
-			),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "inc-tcp-ack",
-			.mask = FLOW_ACTION_MASK(
-				RTE_FLOW_ACTION_TYPE_INC_TCP_ACK
-			),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "dec-tcp-ack",
-			.mask = FLOW_ACTION_MASK(
-				RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK
-			),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "inc-tcp-seq",
-			.mask = FLOW_ACTION_MASK(
-				RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ
-			),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "dec-tcp-seq",
-			.mask = FLOW_ACTION_MASK(
-				RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ
-			),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "set-ttl",
-			.mask = FLOW_ACTION_MASK(
-				RTE_FLOW_ACTION_TYPE_SET_TTL
-			),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "dec-ttl",
-			.mask = FLOW_ACTION_MASK(
-				RTE_FLOW_ACTION_TYPE_DEC_TTL
-			),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "set-ipv4-dscp",
-			.mask = FLOW_ACTION_MASK(
-				RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP
-			),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "set-ipv6-dscp",
-			.mask = FLOW_ACTION_MASK(
-				RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP
-			),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "flag",
-			.mask = FLOW_ACTION_MASK(
-				RTE_FLOW_ACTION_TYPE_FLAG
-			),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "meter",
-			.mask = FLOW_ACTION_MASK(
-				RTE_FLOW_ACTION_TYPE_METER
-			),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "vxlan-encap",
-			.mask = FLOW_ACTION_MASK(
-				RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
-			),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-		{
-			.str = "vxlan-decap",
-			.mask = FLOW_ACTION_MASK(
-				RTE_FLOW_ACTION_TYPE_VXLAN_DECAP
-			),
-			.map = &flow_actions[0],
-			.map_idx = &actions_idx
-		},
-	};
-
 	static const struct option lgopts[] = {
 		/* Control */
 		{ "help",                       0, 0, 0 },
@@ -653,6 +698,7 @@ args_parse(int argc, char **argv)
 		{ "raw-decap",                  1, 0, 0 },
 		{ "vxlan-encap",                0, 0, 0 },
 		{ "vxlan-decap",                0, 0, 0 },
+		{ "policy-mtr",                 1, 0, 0 },
 	};
 
 	RTE_ETH_FOREACH_DEV(i)
@@ -869,6 +915,8 @@ args_parse(int argc, char **argv)
 						RTE_MAX_LCORE);
 				}
 			}
+			if (strcmp(lgopts[opt_idx].name, "policy-mtr") == 0)
+				handle_meter_policy(argv[0], optarg);
 			break;
 		default:
 			usage(argv[0]);
@@ -979,12 +1027,68 @@ has_meter(void)
 	return 0;
 }
 
+static void
+create_meter_policy(void)
+{
+	struct rte_mtr_error error;
+	int ret, port_id;
+	struct rte_mtr_meter_policy_params policy;
+	uint16_t nr_ports;
+	struct rte_flow_action actions[RTE_COLORS][MAX_ACTIONS_NUM];
+	int i;
+
+	memset(actions, 0, sizeof(actions));
+	memset(&policy, 0, sizeof(policy));
+	nr_ports = rte_eth_dev_count_avail();
+	for (port_id = 0; port_id < nr_ports; port_id++) {
+		for (i = 0; i < RTE_COLORS; i++)
+			fill_actions(actions[i], all_actions[i], 0, 0, 0,
+				     0, 0, 0, unique_data, rx_queues_count,
+				     dst_ports[port_id]);
+		policy.actions[RTE_COLOR_GREEN] = actions[RTE_COLOR_GREEN];
+		policy.actions[RTE_COLOR_YELLOW] = actions[RTE_COLOR_YELLOW];
+		policy.actions[RTE_COLOR_RED] = actions[RTE_COLOR_RED];
+		policy_id[port_id] = port_id + 10;
+		ret = rte_mtr_meter_policy_add(port_id, policy_id[port_id],
+					       &policy, &error);
+		if (ret) {
+			fprintf(stderr, "meter policy add failed port_id %d\n",
+				port_id);
+			policy_id[port_id] = UINT32_MAX;
+		}
+		memset(actions, 0, sizeof(actions));
+	}
+}
+
+
+static void
+destroy_meter_policy(void)
+{
+	struct rte_mtr_error error;
+	uint16_t nr_ports;
+	int port_id;
+
+	nr_ports = rte_eth_dev_count_avail();
+	for (port_id = 0; port_id < nr_ports; port_id++) {
+		/* If port outside portmask */
+		if (!((ports_mask >> port_id) & 0x1))
+			continue;
+
+		if (rte_mtr_meter_policy_delete
+			(port_id, policy_id[port_id], &error)) {
+			fprintf(stderr, "Port %u del policy error(%d) message: %s\n",
+				port_id, error.type,
+				error.message ? error.message : "(no stated reason)");
+			rte_exit(EXIT_FAILURE, "Error: Destroy meter policy Failed!\n");
+		}
+	}
+}
+
 static void
 create_meter_rule(int port_id, uint32_t counter)
 {
 	int ret;
 	struct rte_mtr_params params;
-	uint32_t default_prof_id = 100;
 	struct rte_mtr_error error;
 
 	memset(&params, 0, sizeof(struct rte_mtr_params));
@@ -994,8 +1098,15 @@ create_meter_rule(int port_id, uint32_t counter)
 	params.dscp_table = NULL;
 
 	/*create meter*/
-	params.meter_profile_id = default_prof_id;
-	ret = rte_mtr_create(port_id, counter, &params, 1, &error);
+	params.meter_profile_id = DEFAULT_METER_PROF_ID;
+
+	if (!policy_mtr) {
+		ret = rte_mtr_create(port_id, counter, &params, 1, &error);
+	} else {
+		params.meter_policy_id = policy_id[port_id];
+		ret = rte_mtr_create(port_id, counter, &params, 0, &error);
+	}
+
 	if (ret != 0) {
 		printf("Port %u create meter idx(%d) error(%d) message: %s\n",
 			port_id, counter, error.type,
@@ -1009,11 +1120,17 @@ destroy_meter_rule(int port_id, uint32_t counter)
 {
 	struct rte_mtr_error error;
 
+	if (policy_mtr && policy_id[port_id] != UINT32_MAX) {
+		if (rte_mtr_meter_policy_delete(port_id, policy_id[port_id],
+					&error))
+			fprintf(stderr, "error delete policy %d\n", counter+1);
+		policy_id[port_id] = UINT32_MAX;
+	}
 	if (rte_mtr_destroy(port_id, counter, &error)) {
-		printf("Port %u destroy meter(%d) error(%d) message: %s\n",
-			port_id, counter, error.type,
-			error.message ? error.message : "(no stated reason)");
-		rte_exit(EXIT_FAILURE, "Error in deleting meter rule\n");
+		fprintf(stderr, "Port %u destroy meter(%d) error(%d) message: %s\n",
+		port_id, counter, error.type,
+		error.message ? error.message : "(no stated reason)");
+		rte_exit(EXIT_FAILURE, "Error in deleting meter rule");
 	}
 }
 
@@ -1118,12 +1235,10 @@ create_meter_profile(void)
 		/* If port outside portmask */
 		if (!((ports_mask >> port_id) & 0x1))
 			continue;
-
 		mp.alg = RTE_MTR_SRTCM_RFC2697;
 		mp.srtcm_rfc2697.cir = METER_CIR;
 		mp.srtcm_rfc2697.cbs = METER_CIR / 8;
 		mp.srtcm_rfc2697.ebs = 0;
-
 		ret = rte_mtr_meter_profile_add
 			(port_id, DEFAULT_METER_PROF_ID, &mp, &error);
 		if (ret != 0) {
@@ -1992,16 +2107,22 @@ main(int argc, char **argv)
 
 	printf(":: Flows Count per port: %d\n\n", rules_count);
 
-	if (has_meter())
+	if (has_meter()) {
 		create_meter_profile();
+		if (policy_mtr)
+			create_meter_policy();
+	}
 	rte_eal_mp_remote_launch(run_rte_flow_handler_cores, NULL, CALL_MAIN);
 
 	if (enable_fwd) {
 		init_lcore_info();
 		rte_eal_mp_remote_launch(start_forwarding, NULL, CALL_MAIN);
 	}
-	if (has_meter() && delete_flag)
+	if (has_meter() && delete_flag) {
 		destroy_meter_profile();
+		if (policy_mtr)
+			destroy_meter_policy();
+	}
 
 	RTE_ETH_FOREACH_DEV(port) {
 		rte_flow_flush(port, &error);
diff --git a/doc/guides/tools/flow-perf.rst b/doc/guides/tools/flow-perf.rst
index e608a44c24..a23b94bb55 100644
--- a/doc/guides/tools/flow-perf.rst
+++ b/doc/guides/tools/flow-perf.rst
@@ -383,3 +383,6 @@ Actions:
 *       ``--meter``
         Add meter action to all flows actions.
         Currently, 1 meter profile -> N meter rules -> N rte flows.
+
+*       ``--policy-mtr=<str>``
+        Add policy-mtr to create meter with policy and specify policy actions.
-- 
2.27.0