* [dpdk-dev] [PATCH 0/3] app/flow-perf: support meter policy API
@ 2021-05-10 16:17 Jiawei Wang
2021-05-10 16:17 ` [dpdk-dev] [PATCH 1/3] " Jiawei Wang
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Jiawei Wang @ 2021-05-10 16:17 UTC (permalink / raw)
To: matan, haifeil, thomas; +Cc: dev, rasland
This patch set contains three updates for flow perf application:
1. Adds the option 'policy-mtr' to indicate if create a meter with
policy;
2. Adds the option 'meter-cir' to configure the CIR parameter;
3. Adds the option 'packet-mode' to enable the meter PPS.
Jiawei Wang (3):
app/flow-perf: support meter policy API
app/flow-perf: add new meter CIR Configuration
app/flow-perf: add the supports for meter PPS
app/test-flow-perf/main.c | 108 ++++++++++++++++++++++++++++++---
doc/guides/tools/flow-perf.rst | 9 +++
2 files changed, 110 insertions(+), 7 deletions(-)
--
2.18.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [dpdk-dev] [PATCH 1/3] app/flow-perf: support meter policy API
2021-05-10 16:17 [dpdk-dev] [PATCH 0/3] app/flow-perf: support meter policy API Jiawei Wang
@ 2021-05-10 16:17 ` Jiawei Wang
2021-05-10 16:21 ` Wisam Monther
2021-05-10 16:17 ` [dpdk-dev] [PATCH 2/3] app/flow-perf: add new meter CIR Configuration Jiawei Wang
2021-05-10 16:17 ` [dpdk-dev] [PATCH 3/3] app/flow-perf: add the supports for meter PPS Jiawei Wang
2 siblings, 1 reply; 5+ messages in thread
From: Jiawei Wang @ 2021-05-10 16:17 UTC (permalink / raw)
To: matan, haifeil, thomas, Wisam Jaddo; +Cc: dev, rasland
Add option "policy-mtr" to indicate if meter creation will include policy
or not. Meter creation will keep same without it.
With "policy-mtr", policy is introduced. API create_meter_policy
is to create a policy. API create_meter_rule will use it to create
meter.
Signed-off-by: Haifei Luo <haifeil@nvidia.com>
Signed-off-by: Jiawei Wang <jiaweiw@nvidia.com>
Acked-by: Wisam Jaddo <wisamm@nvidia.com>
---
app/test-flow-perf/main.c | 87 ++++++++++++++++++++++++++++++++--
doc/guides/tools/flow-perf.rst | 3 ++
2 files changed, 86 insertions(+), 4 deletions(-)
diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c
index 9be8edc31d..7b8b6fb9c4 100644
--- a/app/test-flow-perf/main.c
+++ b/app/test-flow-perf/main.c
@@ -53,6 +53,7 @@ static uint64_t decap_data;
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 g_policy_id[MAX_PORTS];
static uint8_t items_idx, actions_idx, attrs_idx;
static uint64_t ports_mask;
@@ -62,6 +63,7 @@ static bool delete_flag;
static bool dump_socket_mem_flag;
static bool enable_fwd;
static bool unique_data;
+static bool policy_mtr;
static struct rte_mempool *mbuf_mp;
static uint32_t nb_lcores;
@@ -115,6 +117,13 @@ static struct multi_cores_pool mc_pool = {
.cores_count = 1,
};
+/* Storage for struct rte_flow_action_rss including external data. */
+struct action_rss_data {
+ struct rte_flow_action_rss conf;
+ uint8_t key[40];
+ uint16_t queue[128];
+};
+
static void
usage(char *progname)
{
@@ -134,6 +143,7 @@ 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: To create meter with policy\n");
printf("To set flow attributes:\n");
printf(" --ingress: set ingress attribute in flows\n");
@@ -573,6 +583,7 @@ args_parse(int argc, char **argv)
{ "unique-data", 0, 0, 0 },
{ "portmask", 1, 0, 0 },
{ "cores", 1, 0, 0 },
+ { "policy-mtr", 0, 0, 0 },
/* Attributes */
{ "ingress", 0, 0, 0 },
{ "egress", 0, 0, 0 },
@@ -802,6 +813,8 @@ args_parse(int argc, char **argv)
RTE_MAX_LCORE);
}
}
+ if (strcmp(lgopts[opt_idx].name, "policy-mtr") == 0)
+ policy_mtr = true;
break;
default:
usage(argv[0]);
@@ -912,6 +925,58 @@ has_meter(void)
return 0;
}
+static void
+create_meter_policy(void)
+{
+ struct rte_mtr_error error;
+ uint32_t policy_id;
+ int ret, i, port_id;
+ struct rte_mtr_meter_policy_params policy;
+ struct action_rss_data rss_data;
+ struct rte_flow_action g_actions[2], r_actions[2];
+ uint16_t nr_ports;
+
+ memset(&rss_data, 0, sizeof(rss_data));
+ memset(&policy, 0, sizeof(policy));
+ rss_data.conf.func = RTE_ETH_HASH_FUNCTION_DEFAULT;
+ rss_data.conf.level = 0;
+ rss_data.conf.types = GET_RSS_HF();
+ rss_data.conf.key_len = 0;
+ rss_data.conf.key = NULL;
+ rss_data.conf.queue_num = RXQ_NUM;
+ uint16_t q_data[RXQ_NUM];
+ rss_data.conf.queue = q_data;
+
+ for (i = 0; i < RXQ_NUM; i++)
+ q_data[i] = i;
+ for (i = 0; i < RXQ_NUM; i++)
+ rss_data.queue[i] = i;
+
+ g_actions[0].type = RTE_FLOW_ACTION_TYPE_RSS;
+ g_actions[0].conf = &(rss_data.conf);
+ g_actions[1].type = RTE_FLOW_ACTION_TYPE_END;
+ g_actions[1].conf = NULL;
+
+ r_actions[0].type = RTE_FLOW_ACTION_TYPE_DROP;
+ r_actions[0].conf = NULL;
+ r_actions[1].type = RTE_FLOW_ACTION_TYPE_END;
+ r_actions[1].conf = NULL;
+
+ policy.actions[RTE_COLOR_GREEN] = &g_actions[0];
+ policy.actions[RTE_COLOR_YELLOW] = NULL;
+ policy.actions[RTE_COLOR_RED] = &r_actions[0];
+
+ nr_ports = rte_eth_dev_count_avail();
+ for (port_id = 0; port_id < nr_ports; port_id++) {
+ policy_id = port_id + 10;
+ ret = rte_mtr_meter_policy_add(port_id, policy_id,
+ &policy, &error);
+ if (ret)
+ printf("meter add failed port_id %d\n", port_id);
+ g_policy_id[port_id] = policy_id;
+ }
+}
+
static void
create_meter_rule(int port_id, uint32_t counter)
{
@@ -928,7 +993,14 @@ create_meter_rule(int port_id, uint32_t counter)
/*create meter*/
params.meter_profile_id = default_prof_id;
- ret = rte_mtr_create(port_id, counter, ¶ms, 1, &error);
+
+ if (!policy_mtr) {
+ ret = rte_mtr_create(port_id, counter, ¶ms, 1, &error);
+ } else {
+ params.meter_policy_id = g_policy_id[port_id];
+ ret = rte_mtr_create(port_id, counter, ¶ms, 0, &error);
+ }
+
if (ret != 0) {
printf("Port %u create meter idx(%d) error(%d) message: %s\n",
port_id, counter, error.type,
@@ -942,11 +1014,16 @@ destroy_meter_rule(int port_id, uint32_t counter)
{
struct rte_mtr_error error;
- if (rte_mtr_destroy(port_id, counter, &error)) {
- printf("Port %u destroy meter(%d) error(%d) message: %s\n",
+ if (policy_mtr) {
+ if (rte_mtr_meter_policy_delete(port_id, counter+1, &error))
+ printf("erro delete policy %d\n", counter+1);
+ } else {
+ 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");
+ rte_exit(EXIT_FAILURE, "Error in deleting meter rule");
+ }
}
}
@@ -1894,6 +1971,8 @@ main(int argc, char **argv)
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) {
diff --git a/doc/guides/tools/flow-perf.rst b/doc/guides/tools/flow-perf.rst
index 280bf7e0e0..4c6480d70a 100644
--- a/doc/guides/tools/flow-perf.rst
+++ b/doc/guides/tools/flow-perf.rst
@@ -354,3 +354,6 @@ Actions:
* ``--meter``
Add meter action to all flows actions.
Currently, 1 meter profile -> N meter rules -> N rte flows.
+
+* ``--policy-mtr``
+ Add policy-mtr to create meter with policy.
--
2.18.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [dpdk-dev] [PATCH 2/3] app/flow-perf: add new meter CIR Configuration
2021-05-10 16:17 [dpdk-dev] [PATCH 0/3] app/flow-perf: support meter policy API Jiawei Wang
2021-05-10 16:17 ` [dpdk-dev] [PATCH 1/3] " Jiawei Wang
@ 2021-05-10 16:17 ` Jiawei Wang
2021-05-10 16:17 ` [dpdk-dev] [PATCH 3/3] app/flow-perf: add the supports for meter PPS Jiawei Wang
2 siblings, 0 replies; 5+ messages in thread
From: Jiawei Wang @ 2021-05-10 16:17 UTC (permalink / raw)
To: matan, haifeil, thomas, Wisam Jaddo; +Cc: dev, rasland
Add the new meter CIR configuration parameter, user can set the
different value for committed information rate(CIR) parameter.
The usage as below:
--meter-cir=N, default count is 1250000.
Signed-off-by: Jiawei Wang <jiaweiw@nvidia.com>
Acked-by: Wisam Jaddo <wisamm@nvidia.com>
---
app/test-flow-perf/main.c | 13 +++++++++++--
doc/guides/tools/flow-perf.rst | 3 +++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c
index 7b8b6fb9c4..1836becbc8 100644
--- a/app/test-flow-perf/main.c
+++ b/app/test-flow-perf/main.c
@@ -71,6 +71,7 @@ static uint32_t rules_count;
static uint32_t rules_batch;
static uint32_t hairpin_queues_num; /* total hairpin q number - default: 0 */
static uint32_t nb_lcores;
+static uint64_t meter_cir;
#define MAX_PKT_BURST 32
#define LCORE_MODE_PKT 1
@@ -144,6 +145,8 @@ usage(char *progname)
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: To create meter with policy\n");
+ printf(" --meter-cir=N: to set committed information rate(CIR)"
+ " parameter in meter profile, default is %d\n", METER_CIR);
printf("To set flow attributes:\n");
printf(" --ingress: set ingress attribute in flows\n");
@@ -584,6 +587,7 @@ args_parse(int argc, char **argv)
{ "portmask", 1, 0, 0 },
{ "cores", 1, 0, 0 },
{ "policy-mtr", 0, 0, 0 },
+ { "meter-cir", 1, 0, 0 },
/* Attributes */
{ "ingress", 0, 0, 0 },
{ "egress", 0, 0, 0 },
@@ -815,6 +819,10 @@ args_parse(int argc, char **argv)
}
if (strcmp(lgopts[opt_idx].name, "policy-mtr") == 0)
policy_mtr = true;
+ if (strcmp(lgopts[opt_idx].name, "meter-cir") == 0) {
+ n = atoi(optarg);
+ meter_cir = (uint64_t) n;
+ }
break;
default:
usage(argv[0]);
@@ -1130,8 +1138,8 @@ create_meter_profile(void)
continue;
mp.alg = RTE_MTR_SRTCM_RFC2697;
- mp.srtcm_rfc2697.cir = METER_CIR;
- mp.srtcm_rfc2697.cbs = METER_CIR / 8;
+ mp.srtcm_rfc2697.cir = meter_cir;
+ mp.srtcm_rfc2697.cbs = meter_cir / 8;
mp.srtcm_rfc2697.ebs = 0;
ret = rte_mtr_meter_profile_add
@@ -1952,6 +1960,7 @@ main(int argc, char **argv)
dump_socket_mem_flag = false;
flow_group = DEFAULT_GROUP;
unique_data = false;
+ meter_cir = METER_CIR;
signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler);
diff --git a/doc/guides/tools/flow-perf.rst b/doc/guides/tools/flow-perf.rst
index 4c6480d70a..c3e0e8e3ad 100644
--- a/doc/guides/tools/flow-perf.rst
+++ b/doc/guides/tools/flow-perf.rst
@@ -105,6 +105,9 @@ The command line options are:
Such as header modify and encap actions. Default is using fixed
data for any action that support data for all flows.
+* ``--meter-cir=N``
+ Set the committed information rate(CIR) parameter, default count is 1250000.
+
Attributes:
* ``--ingress``
--
2.18.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [dpdk-dev] [PATCH 3/3] app/flow-perf: add the supports for meter PPS
2021-05-10 16:17 [dpdk-dev] [PATCH 0/3] app/flow-perf: support meter policy API Jiawei Wang
2021-05-10 16:17 ` [dpdk-dev] [PATCH 1/3] " Jiawei Wang
2021-05-10 16:17 ` [dpdk-dev] [PATCH 2/3] app/flow-perf: add new meter CIR Configuration Jiawei Wang
@ 2021-05-10 16:17 ` Jiawei Wang
2 siblings, 0 replies; 5+ messages in thread
From: Jiawei Wang @ 2021-05-10 16:17 UTC (permalink / raw)
To: matan, haifeil, thomas, Wisam Jaddo; +Cc: dev, rasland
The flow perf application used the srtcm_rfc2697 as meter profile
while do the meter testing.
This patch adds the support new configuration parameter
'--packet-mode' to generate the meter flows with the packet mode.
Signed-off-by: Jiawei Wang <jiaweiw@nvidia.com>
Acked-by: Wisam Jaddo <wisamm@nvidia.com>
---
app/test-flow-perf/main.c | 8 +++++++-
doc/guides/tools/flow-perf.rst | 3 +++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c
index 1836becbc8..5178f219d0 100644
--- a/app/test-flow-perf/main.c
+++ b/app/test-flow-perf/main.c
@@ -64,6 +64,7 @@ static bool dump_socket_mem_flag;
static bool enable_fwd;
static bool unique_data;
static bool policy_mtr;
+static bool packet_mode;
static struct rte_mempool *mbuf_mp;
static uint32_t nb_lcores;
@@ -147,6 +148,7 @@ usage(char *progname)
printf(" --policy-mtr: To create meter with policy\n");
printf(" --meter-cir=N: to set committed information rate(CIR)"
" parameter in meter profile, default is %d\n", METER_CIR);
+ printf(" --packet-mode: To enable packet mode for meter profile\n");
printf("To set flow attributes:\n");
printf(" --ingress: set ingress attribute in flows\n");
@@ -588,6 +590,7 @@ args_parse(int argc, char **argv)
{ "cores", 1, 0, 0 },
{ "policy-mtr", 0, 0, 0 },
{ "meter-cir", 1, 0, 0 },
+ { "packet-mode", 0, 0, 0 },
/* Attributes */
{ "ingress", 0, 0, 0 },
{ "egress", 0, 0, 0 },
@@ -823,6 +826,8 @@ args_parse(int argc, char **argv)
n = atoi(optarg);
meter_cir = (uint64_t) n;
}
+ if (strcmp(lgopts[opt_idx].name, "packet-mode") == 0)
+ packet_mode = true;
break;
default:
usage(argv[0]);
@@ -990,7 +995,7 @@ create_meter_rule(int port_id, uint32_t counter)
{
int ret;
struct rte_mtr_params params;
- uint32_t default_prof_id = 100;
+ uint32_t default_prof_id = DEFAULT_METER_PROF_ID;
struct rte_mtr_error error;
memset(¶ms, 0, sizeof(struct rte_mtr_params));
@@ -1141,6 +1146,7 @@ create_meter_profile(void)
mp.srtcm_rfc2697.cir = meter_cir;
mp.srtcm_rfc2697.cbs = meter_cir / 8;
mp.srtcm_rfc2697.ebs = 0;
+ mp.packet_mode = packet_mode;
ret = rte_mtr_meter_profile_add
(port_id, DEFAULT_METER_PROF_ID, &mp, &error);
diff --git a/doc/guides/tools/flow-perf.rst b/doc/guides/tools/flow-perf.rst
index c3e0e8e3ad..c6d7f15ace 100644
--- a/doc/guides/tools/flow-perf.rst
+++ b/doc/guides/tools/flow-perf.rst
@@ -108,6 +108,9 @@ The command line options are:
* ``--meter-cir=N``
Set the committed information rate(CIR) parameter, default count is 1250000.
+* ``--packet-mode``
+ Enable packets mode for meter profile.
+
Attributes:
* ``--ingress``
--
2.18.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH 1/3] app/flow-perf: support meter policy API
2021-05-10 16:17 ` [dpdk-dev] [PATCH 1/3] " Jiawei Wang
@ 2021-05-10 16:21 ` Wisam Monther
0 siblings, 0 replies; 5+ messages in thread
From: Wisam Monther @ 2021-05-10 16:21 UTC (permalink / raw)
To: Jiawei(Jonny) Wang, Matan Azrad, Haifei Luo, NBU-Contact-Thomas Monjalon
Cc: dev, Raslan Darawsheh
Hi guys,
I have some issues w/ this patch, please exclude my ack for now.
Can you please check my comments on the this previous patch in ML?
BRs,
Wisam Jaddo
Get Outlook for iOS<https://aka.ms/o0ukef>
________________________________
From: Jiawei(Jonny) Wang <jiaweiw@nvidia.com>
Sent: Monday, May 10, 2021 7:17:21 PM
To: Matan Azrad <matan@nvidia.com>; Haifei Luo <haifeil@nvidia.com>; NBU-Contact-Thomas Monjalon <thomas@monjalon.net>; Wisam Monther <wisamm@nvidia.com>
Cc: dev@dpdk.org <dev@dpdk.org>; Raslan Darawsheh <rasland@nvidia.com>
Subject: [PATCH 1/3] app/flow-perf: support meter policy API
Add option "policy-mtr" to indicate if meter creation will include policy
or not. Meter creation will keep same without it.
With "policy-mtr", policy is introduced. API create_meter_policy
is to create a policy. API create_meter_rule will use it to create
meter.
Signed-off-by: Haifei Luo <haifeil@nvidia.com>
Signed-off-by: Jiawei Wang <jiaweiw@nvidia.com>
Acked-by: Wisam Jaddo <wisamm@nvidia.com>
---
app/test-flow-perf/main.c | 87 ++++++++++++++++++++++++++++++++--
doc/guides/tools/flow-perf.rst | 3 ++
2 files changed, 86 insertions(+), 4 deletions(-)
diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c
index 9be8edc31d..7b8b6fb9c4 100644
--- a/app/test-flow-perf/main.c
+++ b/app/test-flow-perf/main.c
@@ -53,6 +53,7 @@ static uint64_t decap_data;
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 g_policy_id[MAX_PORTS];
static uint8_t items_idx, actions_idx, attrs_idx;
static uint64_t ports_mask;
@@ -62,6 +63,7 @@ static bool delete_flag;
static bool dump_socket_mem_flag;
static bool enable_fwd;
static bool unique_data;
+static bool policy_mtr;
static struct rte_mempool *mbuf_mp;
static uint32_t nb_lcores;
@@ -115,6 +117,13 @@ static struct multi_cores_pool mc_pool = {
.cores_count = 1,
};
+/* Storage for struct rte_flow_action_rss including external data. */
+struct action_rss_data {
+ struct rte_flow_action_rss conf;
+ uint8_t key[40];
+ uint16_t queue[128];
+};
+
static void
usage(char *progname)
{
@@ -134,6 +143,7 @@ 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: To create meter with policy\n");
printf("To set flow attributes:\n");
printf(" --ingress: set ingress attribute in flows\n");
@@ -573,6 +583,7 @@ args_parse(int argc, char **argv)
{ "unique-data", 0, 0, 0 },
{ "portmask", 1, 0, 0 },
{ "cores", 1, 0, 0 },
+ { "policy-mtr", 0, 0, 0 },
/* Attributes */
{ "ingress", 0, 0, 0 },
{ "egress", 0, 0, 0 },
@@ -802,6 +813,8 @@ args_parse(int argc, char **argv)
RTE_MAX_LCORE);
}
}
+ if (strcmp(lgopts[opt_idx].name, "policy-mtr") == 0)
+ policy_mtr = true;
break;
default:
usage(argv[0]);
@@ -912,6 +925,58 @@ has_meter(void)
return 0;
}
+static void
+create_meter_policy(void)
+{
+ struct rte_mtr_error error;
+ uint32_t policy_id;
+ int ret, i, port_id;
+ struct rte_mtr_meter_policy_params policy;
+ struct action_rss_data rss_data;
+ struct rte_flow_action g_actions[2], r_actions[2];
+ uint16_t nr_ports;
+
+ memset(&rss_data, 0, sizeof(rss_data));
+ memset(&policy, 0, sizeof(policy));
+ rss_data.conf.func = RTE_ETH_HASH_FUNCTION_DEFAULT;
+ rss_data.conf.level = 0;
+ rss_data.conf.types = GET_RSS_HF();
+ rss_data.conf.key_len = 0;
+ rss_data.conf.key = NULL;
+ rss_data.conf.queue_num = RXQ_NUM;
+ uint16_t q_data[RXQ_NUM];
+ rss_data.conf.queue = q_data;
+
+ for (i = 0; i < RXQ_NUM; i++)
+ q_data[i] = i;
+ for (i = 0; i < RXQ_NUM; i++)
+ rss_data.queue[i] = i;
+
+ g_actions[0].type = RTE_FLOW_ACTION_TYPE_RSS;
+ g_actions[0].conf = &(rss_data.conf);
+ g_actions[1].type = RTE_FLOW_ACTION_TYPE_END;
+ g_actions[1].conf = NULL;
+
+ r_actions[0].type = RTE_FLOW_ACTION_TYPE_DROP;
+ r_actions[0].conf = NULL;
+ r_actions[1].type = RTE_FLOW_ACTION_TYPE_END;
+ r_actions[1].conf = NULL;
+
+ policy.actions[RTE_COLOR_GREEN] = &g_actions[0];
+ policy.actions[RTE_COLOR_YELLOW] = NULL;
+ policy.actions[RTE_COLOR_RED] = &r_actions[0];
+
+ nr_ports = rte_eth_dev_count_avail();
+ for (port_id = 0; port_id < nr_ports; port_id++) {
+ policy_id = port_id + 10;
+ ret = rte_mtr_meter_policy_add(port_id, policy_id,
+ &policy, &error);
+ if (ret)
+ printf("meter add failed port_id %d\n", port_id);
+ g_policy_id[port_id] = policy_id;
+ }
+}
+
static void
create_meter_rule(int port_id, uint32_t counter)
{
@@ -928,7 +993,14 @@ create_meter_rule(int port_id, uint32_t counter)
/*create meter*/
params.meter_profile_id = default_prof_id;
- ret = rte_mtr_create(port_id, counter, ¶ms, 1, &error);
+
+ if (!policy_mtr) {
+ ret = rte_mtr_create(port_id, counter, ¶ms, 1, &error);
+ } else {
+ params.meter_policy_id = g_policy_id[port_id];
+ ret = rte_mtr_create(port_id, counter, ¶ms, 0, &error);
+ }
+
if (ret != 0) {
printf("Port %u create meter idx(%d) error(%d) message: %s\n",
port_id, counter, error.type,
@@ -942,11 +1014,16 @@ destroy_meter_rule(int port_id, uint32_t counter)
{
struct rte_mtr_error error;
- if (rte_mtr_destroy(port_id, counter, &error)) {
- printf("Port %u destroy meter(%d) error(%d) message: %s\n",
+ if (policy_mtr) {
+ if (rte_mtr_meter_policy_delete(port_id, counter+1, &error))
+ printf("erro delete policy %d\n", counter+1);
+ } else {
+ 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");
+ rte_exit(EXIT_FAILURE, "Error in deleting meter rule");
+ }
}
}
@@ -1894,6 +1971,8 @@ main(int argc, char **argv)
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) {
diff --git a/doc/guides/tools/flow-perf.rst b/doc/guides/tools/flow-perf.rst
index 280bf7e0e0..4c6480d70a 100644
--- a/doc/guides/tools/flow-perf.rst
+++ b/doc/guides/tools/flow-perf.rst
@@ -354,3 +354,6 @@ Actions:
* ``--meter``
Add meter action to all flows actions.
Currently, 1 meter profile -> N meter rules -> N rte flows.
+
+* ``--policy-mtr``
+ Add policy-mtr to create meter with policy.
--
2.18.1
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-05-10 16:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-10 16:17 [dpdk-dev] [PATCH 0/3] app/flow-perf: support meter policy API Jiawei Wang
2021-05-10 16:17 ` [dpdk-dev] [PATCH 1/3] " Jiawei Wang
2021-05-10 16:21 ` Wisam Monther
2021-05-10 16:17 ` [dpdk-dev] [PATCH 2/3] app/flow-perf: add new meter CIR Configuration Jiawei Wang
2021-05-10 16:17 ` [dpdk-dev] [PATCH 3/3] app/flow-perf: add the supports for meter PPS Jiawei Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).