[v7,2/3] app/flow-perf: add meter-profile to support cir cbs and ebs

Message ID 20211108111051.1841401-3-rongweil@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series add meter policy support in flow-perf |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Rongwei Liu Nov. 8, 2021, 11:10 a.m. UTC
  Change meter-cir option to meter-profile to cover CIR/CBS/EBS all.

The usage is as below:
--meter-profile=N1,N2,N3 default value is 1250000 156250 0.

Signed-off-by: Rongwei Liu <rongweil@nvidia.com>
Acked-by: Wisam Monther <wisamm@nvidia.com>
---
 app/test-flow-perf/main.c      | 27 +++++++++++++++++++++++----
 doc/guides/tools/flow-perf.rst |  3 +++
 2 files changed, 26 insertions(+), 4 deletions(-)
  

Patch

diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c
index 4d5d2d7a8f..63675bfcb4 100644
--- a/app/test-flow-perf/main.c
+++ b/app/test-flow-perf/main.c
@@ -85,6 +85,7 @@  static uint32_t hairpin_queues_num; /* total hairpin q number - default: 0 */
 static uint32_t nb_lcores;
 static uint8_t max_priority;
 static uint32_t rand_seed;
+static uint64_t meter_profile_values[3]; /* CIR CBS EBS values. */
 
 #define MAX_PKT_BURST    32
 #define LCORE_MODE_PKT    1
@@ -493,6 +494,8 @@  usage(char *progname)
 	printf("  --mbuf-size=N: to set the size of mbuf\n");
 	printf("  --mbuf-cache-size=N: to set the size of mbuf cache\n");
 	printf("  --total-mbuf-count=N: to set the count of total mbuf count\n");
+	printf("  --meter-profile=cir,cbs,ebs: set CIR CBS EBS parameters in meter"
+		" profile, default is %d,%d,%d\n", METER_CIR, METER_CIR / 8, 0);
 
 	printf("To set flow attributes:\n");
 	printf("  --ingress: set ingress attribute in flows\n");
@@ -624,9 +627,10 @@  args_parse(int argc, char **argv)
 	uint32_t prio;
 	char *token;
 	char *end;
+	char *arg;
 	int n, opt;
 	int opt_idx;
-	size_t i;
+	size_t i, j;
 
 	static const struct option lgopts[] = {
 		/* Control */
@@ -705,6 +709,7 @@  args_parse(int argc, char **argv)
 		{ "vxlan-encap",                0, 0, 0 },
 		{ "vxlan-decap",                0, 0, 0 },
 		{ "policy-mtr",                 1, 0, 0 },
+		{ "meter-profile",              1, 0, 0 },
 	};
 
 	RTE_ETH_FOREACH_DEV(i)
@@ -922,6 +927,18 @@  args_parse(int argc, char **argv)
 						RTE_MAX_LCORE);
 				}
 			}
+			if (strcmp(lgopts[opt_idx].name,
+						"meter-profile") == 0) {
+				arg = optarg;
+				j = 0;
+				token = strsep(&arg, ",\0");
+				while (token != NULL && j < sizeof(
+						meter_profile_values) /
+						sizeof(uint64_t)) {
+					meter_profile_values[j++] = atol(token);
+					token = strsep(&arg, ",\0");
+				}
+			}
 			if (strcmp(lgopts[opt_idx].name, "policy-mtr") == 0)
 				handle_meter_policy(argv[0], optarg);
 			break;
@@ -1251,9 +1268,11 @@  create_meter_profile(void)
 		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;
+		mp.srtcm_rfc2697.cir = meter_profile_values[0] ?
+			meter_profile_values[0] : METER_CIR;
+		mp.srtcm_rfc2697.cbs = meter_profile_values[1] ?
+			meter_profile_values[1] : METER_CIR / 8;
+		mp.srtcm_rfc2697.ebs = meter_profile_values[2];
 		ret = rte_mtr_meter_profile_add
 			(port_id, DEFAULT_METER_PROF_ID, &mp, &error);
 		if (ret != 0) {
diff --git a/doc/guides/tools/flow-perf.rst b/doc/guides/tools/flow-perf.rst
index 9b131bad8c..4074b0a94d 100644
--- a/doc/guides/tools/flow-perf.rst
+++ b/doc/guides/tools/flow-perf.rst
@@ -134,6 +134,9 @@  The command line options are:
 *	``--total-mbuf-count=N``
 	Set the count of total mbuf number, default count is 32000.
 
+*	``--meter-profile=N1,N2,N3``
+	Set the CIR, CBS and EBS parameter, default value is 1250000, 156250 and 0.
+
 Attributes:
 
 *	``--ingress``