Skip to contentSkip to conversation

meter: add meter configuration profile api

PATCH In review Cristian Dumitrescu 3 participants 18 messages Aug 23, 2017 – Apr 5, 2018

lore
Share & tools
lore
#0 lore raw

cover meter: add meter configuration profile api

This patch set adds support for meter configuration profiles. Benefits:
simplified configuration procedure, improved performance.

Q1: What is the configuration profile and why does it make sense?
A1: The configuration profile represents the set of configuration
parameters for a given meter object, such as the rates and sizes for the token buckets. The configuration profile concept makes sense when many meter objects share the same configuration, which is the typical usage model: thousands of traffic flows are each individually metered according to just a few service levels (i.e. profiles).

Q2: How is the configuration profile improving the performance?
A2: The performance improvement is achieved by reducing the memory
footprint of a meter object, which results in better cache utilization for the typical case when large arrays of meter objects are used. The internal data structures stored for each meter object contain:
a) Constant fields: Low level translation of the configuration parameters that does not change post-configuration. This is really duplicated for all meters that use the same configuration. This is the configuration profile data that is moved away from the meter object. Current size (implementation dependent): srTCM = 32 bytes, trTCM = 32 bytes.
b) Variable fields: Time stamps and running counters that change during the on-going traffic metering process. Current size (implementation dependant): srTCM = 24 bytes, trTCM = 32 bytes.
Therefore, by moving the constant fields to a separate profile data structure shared by all the meters with the same configuration, the size of the meter object is reduced by ~50%.

Cristian Dumitrescu (4):
meter: add meter configuration profile
test: meter autotest update
qos_meter: accommodate meter api changes
deprecation: removed the librte_meter notice

 doc/guides/rel_notes/deprecation.rst   |   3 -
 examples/qos_meter/main.c              |  36 ++++---
 examples/qos_meter/main.h              |  32 ++++---
 lib/librte_meter/rte_meter.c           |  88 ++++++++++-------
 lib/librte_meter/rte_meter.h           | 170 ++++++++++++++++++++++-----------
 lib/librte_meter/rte_meter_version.map |   8 ++
 test/test/test_meter.c                 | 138 ++++++++++++++++----------
 7 files changed, 306 insertions(+), 169 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/4 meter: add meter configuration profile

---
 lib/librte_meter/rte_meter.c           |  88 ++++++++++-------
 lib/librte_meter/rte_meter.h           | 170 ++++++++++++++++++++++-----------
 lib/librte_meter/rte_meter_version.map |   8 ++
 3 files changed, 174 insertions(+), 92 deletions(-)
lib/librte_meter/rte_meter.c +51 -37
index 5e2dadb..6f3fa59 100644
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2017 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -60,61 +60,75 @@ rte_meter_get_tb_params(uint64_t hz, uint64_t rate, uint64_t *tb_period, uint64_
 }
 
 int
-rte_meter_srtcm_config(struct rte_meter_srtcm *m, struct rte_meter_srtcm_params *params)
+rte_meter_srtcm_profile_config(struct rte_meter_srtcm_profile *p, struct rte_meter_srtcm_params *params)
 {
-	uint64_t hz;
+	uint64_t hz = rte_get_tsc_hz();
 
 	/* Check input parameters */
-	if ((m == NULL) || (params == NULL)) {
-		return -1;
-	}
+	if ((p == NULL) ||
+		(params == NULL) ||
+		(params->cir == 0) ||
+		((params->cbs == 0) && (params->ebs == 0)))
+		return -EINVAL;
 
-	if ((params->cir == 0) || ((params->cbs == 0) && (params->ebs == 0))) {
-		return -2;
-	}
+	/* Initialize srTCM run-time structure */
+	p->cbs = params->cbs;
+	p->ebs = params->ebs;
+	rte_meter_get_tb_params(hz, params->cir, &p->cir_period, &p->cir_bytes_per_period);
+
+	return 0;
+}
+
+int
+rte_meter_srtcm_config(struct rte_meter_srtcm *m, struct rte_meter_srtcm_profile *p)
+{
+	/* Check input parameters */
+	if ((m == NULL) || (p == NULL))
+		return -EINVAL;
 
 	/* Initialize srTCM run-time structure */
-	hz = rte_get_tsc_hz();
 	m->time = rte_get_tsc_cycles();
-	m->tc = m->cbs = params->cbs;
-	m->te = m->ebs = params->ebs;
-	rte_meter_get_tb_params(hz, params->cir, &m->cir_period, &m->cir_bytes_per_period);
-
-	RTE_LOG(INFO, METER, "Low level srTCM config: \n"
-		"\tCIR period = %" PRIu64 ", CIR bytes per period = %" PRIu64 "\n",
-		m->cir_period, m->cir_bytes_per_period);
+	m->tc = p->cbs;
+	m->te = p->ebs;
 
 	return 0;
 }
 
 int
-rte_meter_trtcm_config(struct rte_meter_trtcm *m, struct rte_meter_trtcm_params *params)
+rte_meter_trtcm_profile_config(struct rte_meter_trtcm_profile *p, struct rte_meter_trtcm_params *params)
 {
-	uint64_t hz;
+	uint64_t hz = rte_get_tsc_hz();
 
 	/* Check input parameters */
-	if ((m == NULL) || (params == NULL)) {
-		return -1;
-	}
+	if ((p == NULL) ||
+		(params == NULL) ||
+		(params->cir == 0) ||
+		(params->pir == 0) ||
+		(params->pir < params->cir) ||
+		(params->cbs == 0) ||
+		(params->pbs == 0))
+		return -EINVAL;
 
-	if ((params->cir == 0) || (params->pir == 0) || (params->pir < params->cir) ||
-		(params->cbs == 0) || (params->pbs == 0)) {
-		return -2;
-	}
+	/* Initialize trTCM run-time structure */
+	p->cbs = params->cbs;
+	p->pbs = params->pbs;
+	rte_meter_get_tb_params(hz, params->cir, &p->cir_period, &p->cir_bytes_per_period);
+	rte_meter_get_tb_params(hz, params->pir, &p->pir_period, &p->pir_bytes_per_period);
+
+	return 0;
+}
+
+int
+rte_meter_trtcm_config(struct rte_meter_trtcm *m, struct rte_meter_trtcm_profile *p)
+{
+	/* Check input parameters */
+	if ((m == NULL) || (p == NULL))
+		return -EINVAL;
 
 	/* Initialize trTCM run-time structure */
-	hz = rte_get_tsc_hz();
 	m->time_tc = m->time_tp = rte_get_tsc_cycles();
-	m->tc = m->cbs = params->cbs;
-	m->tp = m->pbs = params->pbs;
-	rte_meter_get_tb_params(hz, params->cir, &m->cir_period, &m->cir_bytes_per_period);
-	rte_meter_get_tb_params(hz, params->pir, &m->pir_period, &m->pir_bytes_per_period);
-
-	RTE_LOG(INFO, METER, "Low level trTCM config: \n"
-		"\tCIR period = %" PRIu64 ", CIR bytes per period = %" PRIu64 "\n"
-		"\tPIR period = %" PRIu64 ", PIR bytes per period = %" PRIu64 "\n",
-		m->cir_period, m->cir_bytes_per_period,
-		m->pir_period, m->pir_bytes_per_period);
+	m->tc = p->cbs;
+	m->tp = p->pbs;
 
 	return 0;
 }
lib/librte_meter/rte_meter.h +115 -55

327 lines not on this page · raw message

lib/librte_meter/rte_meter_version.map +8 -0
index 2fd647c..8bc8190 100644
@@ -10,3 +10,11 @@ DPDK_2.0 {
 
 	local: *;
 };
+
+DPDK_17.11 {
+	global:
+
+	rte_meter_srtcm_profile_config;
+	rte_meter_trtcm_profile_config;
+
+} DPDK_2.0;
Signature · 1 line
2.7.4
#2 lore raw

v2 cover meter: add meter configuration profile api

This patch set adds support for meter configuration profiles.
Benefits: simplified configuration procedure, improved performance.

Q1: What is the configuration profile and why does it make sense?
A1: The configuration profile represents the set of configuration
parameters for a given meter object, such as the rates and sizes for the token buckets. The configuration profile concept makes sense when many meter objects share the same configuration, which is the typical usage model: thousands of traffic flows are each individually metered according to just a few service levels (i.e. profiles).

Q2: How is the configuration profile improving the performance?
A2: The performance improvement is achieved by reducing the memory
footprint of a meter object, which results in better cache utilization for the typical case when large arrays of meter objects are used. The internal data structures stored for each meter object contain:
a) Constant fields: Low level translation of the configuration parameters that does not change post-configuration. This is really duplicated for all meters that use the same configuration. This is the configuration profile data that is moved away from the meter object. Current size (implementation dependent): srTCM = 32 bytes, trTCM = 32 bytes.
b) Variable fields: Time stamps and running counters that change during the on-going traffic metering process. Current size (implementation dependant): srTCM = 24 bytes, trTCM = 32 bytes. Therefore, by moving the constant fields to a separate profile data structure shared by all the meters with the same configuration, the size of the meter object is reduced by ~50%.

Cristian Dumitrescu (3):
lib/librte_meter: add meter configuration profile test/test_meter: update meter test examples/qos_meter: accommodate meter api changes

Jasvinder Singh (1):
examples/ip_pipeline: update flow action pipeline

 doc/guides/rel_notes/deprecation.rst               |   3 -
 doc/guides/rel_notes/release_18_02.rst             |   2 +-
 .../pipeline/pipeline_flow_actions_be.c            |  25 ++-
 examples/qos_meter/main.c                          |  39 +++-
 examples/qos_meter/main.h                          |  32 ++--
 lib/librte_meter/Makefile                          |   2 +-
 lib/librte_meter/rte_meter.c                       |  95 ++++++----
 lib/librte_meter/rte_meter.h                       | 197 ++++++++++++++-------
 lib/librte_meter/rte_meter_version.map             |   8 +
 test/test/test_meter.c                             | 194 +++++++++++---------
 10 files changed, 394 insertions(+), 203 deletions(-)
Signature · 1 line
2.9.3
#3 lore raw

PATCH v2 1/4 lib/librte_meter: add meter configuration profile

From: Cristian Dumitrescu <[email protected]>

This patch set adds api for meter configuration profiles. For a given meter object, the parameters such as the rates and sizes for the token buckets are defined as configuration profile parameters. This helps in reducing the memory footprint of a meter object which results in better cache utilization for the typical case when large arrays of meter objects are used.

---
v2:
- increment LIBABIVAR
- update release note and deprecation notice
- fix checkpatch errors

 doc/guides/rel_notes/deprecation.rst   |   3 -
 doc/guides/rel_notes/release_18_02.rst |   2 +-
 lib/librte_meter/Makefile              |   2 +-
 lib/librte_meter/rte_meter.c           |  95 +++++++++-------
 lib/librte_meter/rte_meter.h           | 197 +++++++++++++++++++++++----------
 lib/librte_meter/rte_meter_version.map |   8 ++
 6 files changed, 205 insertions(+), 102 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -3
index 13e8543..6ba5ffd 100644
@@ -50,6 +50,3 @@ Deprecation Notices
   required the previous behavior can be configured using existing flow
   director APIs. There is no ABI/API break. This change will just remove a
   global configuration setting and require explicit configuration.
-
-* librte_meter: The API will change to accommodate configuration profiles.
-  Most of the API functions will have an additional opaque parameter.
doc/guides/rel_notes/release_18_02.rst +1 -1
index 24b67bb..7343b74 100644
@@ -141,7 +141,7 @@ The libraries prepended with a plus sign were incremented in this version.
      librte_lpm.so.2
      librte_mbuf.so.3
      librte_mempool.so.3
-     librte_meter.so.1
+   + librte_meter.so.2
      librte_metrics.so.1
      librte_net.so.1
      librte_pci.so.1
lib/librte_meter/Makefile +1 -1
index bfeb5d6..d05fe39 100644
@@ -44,7 +44,7 @@ LDLIBS += -lrte_eal
 
 EXPORT_MAP := rte_meter_version.map
 
-LIBABIVER := 1
+LIBABIVER := 2
 
 #
 # all source are stored in SRCS-y
lib/librte_meter/rte_meter.c +58 -37

126 lines not on this page · raw message

lib/librte_meter/rte_meter.h +137 -60

351 lines not on this page · raw message

lib/librte_meter/rte_meter_version.map +8 -0
index 2fd647c..c4422ef 100644
@@ -10,3 +10,11 @@ DPDK_2.0 {
 
 	local: *;
 };
+
+DPDK_18.02 {
+	global:
+
+	rte_meter_srtcm_profile_config;
+	rte_meter_trtcm_profile_config;
+
+} DPDK_2.0;
Signature · 1 line
2.9.3
#4 lore raw

PATCH v3 1/1 meter: add meter configuration profile api

This patch set adds support for meter configuration profiles.
Benefits: simplified configuration procedure, improved performance.

Q1: What is the configuration profile and why does it make sense?
A1: The configuration profile represents the set of configuration
parameters for a given meter object, such as the rates and sizes for the token buckets. The configuration profile concept makes sense when many meter objects share the same configuration, which is the typical usage model: thousands of traffic flows are each individually metered according to just a few service levels (i.e. profiles).

Q2: How is the configuration profile improving the performance?
A2: The performance improvement is achieved by reducing the memory
footprint of a meter object, which results in better cache utilization for the typical case when large arrays of meter objects are used. The internal data structures stored for each meter object contain:
a) Constant fields: Low level translation of the configuration parameters that does not change post-configuration. This is really duplicated for all meters that use the same configuration. This is the configuration profile data that is moved away from the meter object. Current size (implementation dependent): srTCM = 32 bytes, trTCM = 32 bytes.
b) Variable fields: Time stamps and running counters that change during the on-going traffic metering process. Current size (implementation dependant): srTCM = 24 bytes, trTCM = 32 bytes. Therefore, by moving the constant fields to a separate profile data structure shared by all the meters with the same configuration, the size of the meter object is reduced by ~50%.

Cristian Dumitrescu (1):
lib/librte_meter: add meter configuration profile

 doc/guides/rel_notes/deprecation.rst               |   3 -
 doc/guides/rel_notes/release_18_02.rst             |   2 +-
 .../pipeline/pipeline_flow_actions_be.c            |  25 ++-
 examples/qos_meter/main.c                          |  39 ++++-
 examples/qos_meter/main.h                          |  32 ++--
 lib/librte_meter/Makefile                          |   2 +-
 lib/librte_meter/rte_meter.c                       |  93 ++++++----
 lib/librte_meter/rte_meter.h                       | 195 ++++++++++++++-------
 lib/librte_meter/rte_meter_version.map             |   8 +
 test/test/test_meter.c                             | 194 +++++++++++---------
 10 files changed, 392 insertions(+), 201 deletions(-)
Signature · 1 line
2.9.3
#5 lore raw

PATCH v3 1/1 lib/librte_meter: add meter configuration profile

From: Cristian Dumitrescu <[email protected]>

This patch adds api for meter configuration profiles. For a given meter object, the parameters such as the rates and sizes for the token buckets are defined as configuration profile parameters. This helps in reducing the memory footprint of a meter object which results in better cache utilization for the typical case when large arrays of meter objects are used.

---
v3:
- fix doxygen comments

v2:
- fix checkpatch warnings
- fix build error in ip_pipeline sample app

 doc/guides/rel_notes/deprecation.rst               |   3 -
 doc/guides/rel_notes/release_18_02.rst             |   2 +-
 .../pipeline/pipeline_flow_actions_be.c            |  25 ++-
 examples/qos_meter/main.c                          |  39 ++++-
 examples/qos_meter/main.h                          |  32 ++--
 lib/librte_meter/Makefile                          |   2 +-
 lib/librte_meter/rte_meter.c                       |  93 ++++++----
 lib/librte_meter/rte_meter.h                       | 195 ++++++++++++++-------
 lib/librte_meter/rte_meter_version.map             |   8 +
 test/test/test_meter.c                             | 194 +++++++++++---------
 10 files changed, 392 insertions(+), 201 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -3
index 13e8543..6ba5ffd 100644
@@ -50,6 +50,3 @@ Deprecation Notices
   required the previous behavior can be configured using existing flow
   director APIs. There is no ABI/API break. This change will just remove a
   global configuration setting and require explicit configuration.
-
-* librte_meter: The API will change to accommodate configuration profiles.
-  Most of the API functions will have an additional opaque parameter.
doc/guides/rel_notes/release_18_02.rst +1 -1
index 24b67bb..7343b74 100644
@@ -141,7 +141,7 @@ The libraries prepended with a plus sign were incremented in this version.
      librte_lpm.so.2
      librte_mbuf.so.3
      librte_mempool.so.3
-     librte_meter.so.1
+   + librte_meter.so.2
      librte_metrics.so.1
      librte_net.so.1
      librte_pci.so.1
examples/ip_pipeline/pipeline/pipeline_flow_actions_be.c +24 -1
index 9599b7d..33f1c41 100644
@@ -111,6 +111,7 @@ static pipeline_msg_req_handler custom_handlers[] = {
  */
 struct meter_policer {
 	struct rte_meter_trtcm meter;
+	struct rte_meter_trtcm_profile meter_profile;
 	struct pipeline_fa_policer_params policer;
 	struct pipeline_fa_policer_stats stats;
 };
@@ -127,8 +128,15 @@ flow_table_entry_set_meter(struct flow_table_entry *entry,
 {
 	struct rte_meter_trtcm *meter = &entry->mp[meter_id].meter;
 	struct rte_meter_trtcm_params *meter_params = &params->m[meter_id];
+	struct rte_meter_trtcm_profile *meter_profile =
+					&entry->mp[meter_id].meter_profile;
+	int status;
 
-	return rte_meter_trtcm_config(meter, meter_params);
+	status = rte_meter_trtcm_profile_config(meter_profile, meter_params);
+	if (status)
+		return status;
+
+	return rte_meter_trtcm_config(meter, meter_profile);
 }
 
 static void
@@ -202,11 +210,14 @@ pkt_work(
 	enum rte_meter_color color = p->dscp[dscp].color;
 
 	struct rte_meter_trtcm *meter = &entry->mp[tc].meter;
+	struct rte_meter_trtcm_profile *meter_profile =
+					&entry->mp[tc].meter_profile;
 	struct pipeline_fa_policer_params *policer = &entry->mp[tc].policer;
 	struct pipeline_fa_policer_stats *stats = &entry->mp[tc].stats;
 
 	/* Read (entry), compute */
 	enum rte_meter_color color2 = rte_meter_trtcm_color_aware_check(meter,
+		meter_profile,
 		time,
 		total_length,
 		color);
@@ -284,42 +295,54 @@ pkt4_work(
 	enum rte_meter_color color3 = p->dscp[dscp3].color;
 
 	struct rte_meter_trtcm *meter0 = &entry0->mp[tc0].meter;
+	struct rte_meter_trtcm_profile *meter0_profile =
+				&entry0->mp[tc0].meter_profile;
 	struct pipeline_fa_policer_params *policer0 = &entry0->mp[tc0].policer;
 	struct pipeline_fa_policer_stats *stats0 = &entry0->mp[tc0].stats;
 
 	struct rte_meter_trtcm *meter1 = &entry1->mp[tc1].meter;
+	struct rte_meter_trtcm_profile *meter1_profile =
+				&entry1->mp[tc1].meter_profile;
 	struct pipeline_fa_policer_params *policer1 = &entry1->mp[tc1].policer;
 	struct pipeline_fa_policer_stats *stats1 = &entry1->mp[tc1].stats;
 
 	struct rte_meter_trtcm *meter2 = &entry2->mp[tc2].meter;
+	struct rte_meter_trtcm_profile *meter2_profile =
+				&entry2->mp[tc2].meter_profile;
 	struct pipeline_fa_policer_params *policer2 = &entry2->mp[tc2].policer;
 	struct pipeline_fa_policer_stats *stats2 = &entry2->mp[tc2].stats;
 
 	struct rte_meter_trtcm *meter3 = &entry3->mp[tc3].meter;
+	struct rte_meter_trtcm_profile *meter3_profile =
+				&entry3->mp[tc3].meter_profile;
 	struct pipeline_fa_policer_params *policer3 = &entry3->mp[tc3].policer;
 	struct pipeline_fa_policer_stats *stats3 = &entry3->mp[tc3].stats;
 
 	/* Read (entry), compute, write (entry) */
 	enum rte_meter_color color2_0 = rte_meter_trtcm_color_aware_check(
 		meter0,
+		meter0_profile,
 		time,
 		total_length0,
 		color0);
 
 	enum rte_meter_color color2_1 = rte_meter_trtcm_color_aware_check(
 		meter1,
+		meter1_profile,
 		time,
 		total_length1,
 		color1);
 
 	enum rte_meter_color color2_2 = rte_meter_trtcm_color_aware_check(
 		meter2,
+		meter2_profile,
 		time,
 		total_length2,
 		color2);
 
 	enum rte_meter_color color2_3 = rte_meter_trtcm_color_aware_check(
 		meter3,
+		meter3_profile,
 		time,
 		total_length3,
 		color3);
examples/qos_meter/main.c +30 -9
index 7a0df50..1e1370f 100644
@@ -92,14 +92,23 @@ static uint16_t port_tx;
 static struct rte_mbuf *pkts_rx[PKT_RX_BURST_MAX];
 struct rte_eth_dev_tx_buffer *tx_buffer;
 
-struct rte_meter_srtcm_params app_srtcm_params[] = {
-	{.cir = 1000000 * 46,  .cbs = 2048, .ebs = 2048},
+struct rte_meter_srtcm_params app_srtcm_params = {
+	.cir = 1000000 * 46,
+	.cbs = 2048,
+	.ebs = 2048
 };
 
-struct rte_meter_trtcm_params app_trtcm_params[] = {
-	{.cir = 1000000 * 46,  .pir = 1500000 * 46,  .cbs = 2048, .pbs = 2048},
+struct rte_meter_srtcm_profile app_srtcm_profile;
+
+struct rte_meter_trtcm_params app_trtcm_params = {
+	.cir = 1000000 * 46,
+	.pir = 1500000 * 46,
+	.cbs = 2048,
+	.pbs = 2048
 };
 
+struct rte_meter_trtcm_profile app_trtcm_profile;
+
 #define APP_FLOWS_MAX  256
 
 FLOW_METER app_flows[APP_FLOWS_MAX];
@@ -107,12 +116,21 @@ FLOW_METER app_flows[APP_FLOWS_MAX];
 static int
 app_configure_flow_table(void)
 {
-	uint32_t i, j;
+	uint32_t i;
 	int ret;
 
-	for (i = 0, j = 0; i < APP_FLOWS_MAX;
-			i ++, j = (j + 1) % RTE_DIM(PARAMS)) {
-		ret = FUNC_CONFIG(&app_flows[i], &PARAMS[j]);
+	ret = rte_meter_srtcm_profile_config(&app_srtcm_profile,
+		&app_srtcm_params);
+	if (ret)
+		return ret;
+
+	ret = rte_meter_trtcm_profile_config(&app_trtcm_profile,
+		&app_trtcm_params);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < APP_FLOWS_MAX; i++) {
+		ret = FUNC_CONFIG(&app_flows[i], &PROFILE);
 		if (ret)
 			return ret;
 	}
@@ -137,7 +155,10 @@ app_pkt_handle(struct rte_mbuf *pkt, uint64_t time)
 	enum policer_action action;
 
 	/* color input is not used for blind modes */
-	output_color = (uint8_t) FUNC_METER(&app_flows[flow_id], time, pkt_len,
+	output_color = (uint8_t) FUNC_METER(&app_flows[flow_id],
+		&PROFILE,
+		time,
+		pkt_len,
 		(enum rte_meter_color) input_color);
 
 	/* Apply policing and set the output color */
examples/qos_meter/main.h +20 -12
index b27e8eb..f51eb66 100644
@@ -21,44 +21,52 @@ enum policer_action policer_table[e_RTE_METER_COLORS][e_RTE_METER_COLORS] =
 
 #if APP_MODE == APP_MODE_FWD
 
-#define FUNC_METER(a,b,c,d) color, flow_id=flow_id, pkt_len=pkt_len, time=time
+#define FUNC_METER(m, p, time, pkt_len, pkt_color)	\
+({							\
+	void *mp = m;					\
+	void *pp = p;					\
+	mp = mp;					\
+	pp = pp;					\
+	time = time;					\
+	pkt_len = pkt_len;				\
+	pkt_color;					\
+})
 #define FUNC_CONFIG(a, b) 0
-#define PARAMS	app_srtcm_params
 #define FLOW_METER int
+#define PROFILE	app_srtcm_profile
 
 #elif APP_MODE == APP_MODE_SRTCM_COLOR_BLIND
 
-#define FUNC_METER(a,b,c,d) rte_meter_srtcm_color_blind_check(a,b,c)
+#define FUNC_METER(m, p, time, pkt_len, pkt_color)	\
+	rte_meter_srtcm_color_blind_check(m, p, time, pkt_len)
 #define FUNC_CONFIG   rte_meter_srtcm_config
-#define PARAMS        app_srtcm_params
 #define FLOW_METER    struct rte_meter_srtcm
+#define PROFILE       app_srtcm_profile
 
 #elif (APP_MODE == APP_MODE_SRTCM_COLOR_AWARE)
 
 #define FUNC_METER    rte_meter_srtcm_color_aware_check
 #define FUNC_CONFIG   rte_meter_srtcm_config
-#define PARAMS        app_srtcm_params
 #define FLOW_METER    struct rte_meter_srtcm
+#define PROFILE       app_srtcm_profile
 
 #elif (APP_MODE == APP_MODE_TRTCM_COLOR_BLIND)
 
-#define FUNC_METER(a,b,c,d) rte_meter_trtcm_color_blind_check(a,b,c)
+#define FUNC_METER(m, p, time, pkt_len, pkt_color)	\
+	rte_meter_trtcm_color_blind_check(m, p, time, pkt_len)
 #define FUNC_CONFIG  rte_meter_trtcm_config
-#define PARAMS       app_trtcm_params
 #define FLOW_METER   struct rte_meter_trtcm
+#define PROFILE      app_trtcm_profile
 
 #elif (APP_MODE == APP_MODE_TRTCM_COLOR_AWARE)
 
-#define FUNC_METER   rte_meter_trtcm_color_aware_check
+#define FUNC_METER rte_meter_trtcm_color_aware_check
 #define FUNC_CONFIG  rte_meter_trtcm_config
-#define PARAMS       app_trtcm_params
 #define FLOW_METER   struct rte_meter_trtcm
+#define PROFILE      app_trtcm_profile
 
 #else
 #error Invalid value for APP_MODE
 #endif
 
-
-
-
 #endif /* _MAIN_H_ */
lib/librte_meter/Makefile +1 -1
index 3b80c6a..2dc071e 100644
@@ -16,7 +16,7 @@ LDLIBS += -lrte_eal
 
 EXPORT_MAP := rte_meter_version.map
 
-LIBABIVER := 1
+LIBABIVER := 2
 
 #
 # all source are stored in SRCS-y
lib/librte_meter/rte_meter.c +57 -36

118 lines not on this page · raw message

lib/librte_meter/rte_meter.h +136 -59

343 lines not on this page · raw message

lib/librte_meter/rte_meter_version.map +8 -0
index 2fd647c..c4422ef 100644
@@ -10,3 +10,11 @@ DPDK_2.0 {
 
 	local: *;
 };
+
+DPDK_18.02 {
+	global:
+
+	rte_meter_srtcm_profile_config;
+	rte_meter_trtcm_profile_config;
+
+} DPDK_2.0;
test/test/test_meter.c +115 -79

423 lines not on this page · raw message

Signature · 1 line
2.9.3
#6 lore raw

PATCH v4 1/1 lib/librte_meter: add meter configuration profile

From: Cristian Dumitrescu <[email protected]>

This patch adds support for meter configuration profiles.
Benefits: simplified configuration procedure, improved performance.

Q1: What is the configuration profile and why does it make sense?
A1: The configuration profile represents the set of configuration
parameters for a given meter object, such as the rates and sizes for the token buckets. The configuration profile concept makes sense when many meter objects share the same configuration, which is the typical usage model: thousands of traffic flows are each individually metered according to just a few service levels (i.e. profiles).

Q2: How is the configuration profile improving the performance?
A2: The performance improvement is achieved by reducing the memory
footprint of a meter object, which results in better cache utilization for the typical case when large arrays of meter objects are used. The internal data structures stored for each meter object contain:
a) Constant fields: Low level translation of the configuration parameters that does not change post-configuration. This is really duplicated for all meters that use the same configuration. This is the configuration profile data that is moved away from the meter object. Current size (implementation dependent): srTCM = 32 bytes, trTCM = 32 bytes.
b) Variable fields: Time stamps and running counters that change during the on-going traffic metering process. Current size (implementation dependant): srTCM = 24 bytes, trTCM = 32 bytes. Therefore, by moving the constant fields to a separate profile data structure shared by all the meters with the same configuration, the size of the meter object is reduced by ~50%.

---
V4:
- change commit message

v3:
- fix doxygen comments

v2:
- fix checkpatch warnings
- fix build error in ip_pipeline sample app

 doc/guides/rel_notes/deprecation.rst               |   3 -
 doc/guides/rel_notes/release_18_02.rst             |   2 +-
 .../pipeline/pipeline_flow_actions_be.c            |  25 ++-
 examples/qos_meter/main.c                          |  39 ++++-
 examples/qos_meter/main.h                          |  32 ++--
 lib/librte_meter/Makefile                          |   2 +-
 lib/librte_meter/rte_meter.c                       |  93 ++++++----
 lib/librte_meter/rte_meter.h                       | 195 ++++++++++++++-------
 lib/librte_meter/rte_meter_version.map             |   8 +
 test/test/test_meter.c                             | 194 +++++++++++---------
 10 files changed, 392 insertions(+), 201 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -3
index 13e8543..6ba5ffd 100644
@@ -50,6 +50,3 @@ Deprecation Notices
   required the previous behavior can be configured using existing flow
   director APIs. There is no ABI/API break. This change will just remove a
   global configuration setting and require explicit configuration.
-
-* librte_meter: The API will change to accommodate configuration profiles.
-  Most of the API functions will have an additional opaque parameter.
doc/guides/rel_notes/release_18_02.rst +1 -1
index 24b67bb..7343b74 100644
@@ -141,7 +141,7 @@ The libraries prepended with a plus sign were incremented in this version.
      librte_lpm.so.2
      librte_mbuf.so.3
      librte_mempool.so.3
-     librte_meter.so.1
+   + librte_meter.so.2
      librte_metrics.so.1
      librte_net.so.1
      librte_pci.so.1
examples/ip_pipeline/pipeline/pipeline_flow_actions_be.c +24 -1
index 9599b7d..33f1c41 100644
@@ -111,6 +111,7 @@ static pipeline_msg_req_handler custom_handlers[] = {
  */
 struct meter_policer {
 	struct rte_meter_trtcm meter;
+	struct rte_meter_trtcm_profile meter_profile;
 	struct pipeline_fa_policer_params policer;
 	struct pipeline_fa_policer_stats stats;
 };
@@ -127,8 +128,15 @@ flow_table_entry_set_meter(struct flow_table_entry *entry,
 {
 	struct rte_meter_trtcm *meter = &entry->mp[meter_id].meter;
 	struct rte_meter_trtcm_params *meter_params = &params->m[meter_id];
+	struct rte_meter_trtcm_profile *meter_profile =
+					&entry->mp[meter_id].meter_profile;
+	int status;
 
-	return rte_meter_trtcm_config(meter, meter_params);
+	status = rte_meter_trtcm_profile_config(meter_profile, meter_params);
+	if (status)
+		return status;
+
+	return rte_meter_trtcm_config(meter, meter_profile);
 }
 
 static void
@@ -202,11 +210,14 @@ pkt_work(
 	enum rte_meter_color color = p->dscp[dscp].color;
 
 	struct rte_meter_trtcm *meter = &entry->mp[tc].meter;
+	struct rte_meter_trtcm_profile *meter_profile =
+					&entry->mp[tc].meter_profile;
 	struct pipeline_fa_policer_params *policer = &entry->mp[tc].policer;
 	struct pipeline_fa_policer_stats *stats = &entry->mp[tc].stats;
 
 	/* Read (entry), compute */
 	enum rte_meter_color color2 = rte_meter_trtcm_color_aware_check(meter,
+		meter_profile,
 		time,
 		total_length,
 		color);
@@ -284,42 +295,54 @@ pkt4_work(
 	enum rte_meter_color color3 = p->dscp[dscp3].color;
 
 	struct rte_meter_trtcm *meter0 = &entry0->mp[tc0].meter;
+	struct rte_meter_trtcm_profile *meter0_profile =
+				&entry0->mp[tc0].meter_profile;
 	struct pipeline_fa_policer_params *policer0 = &entry0->mp[tc0].policer;
 	struct pipeline_fa_policer_stats *stats0 = &entry0->mp[tc0].stats;
 
 	struct rte_meter_trtcm *meter1 = &entry1->mp[tc1].meter;
+	struct rte_meter_trtcm_profile *meter1_profile =
+				&entry1->mp[tc1].meter_profile;
 	struct pipeline_fa_policer_params *policer1 = &entry1->mp[tc1].policer;
 	struct pipeline_fa_policer_stats *stats1 = &entry1->mp[tc1].stats;
 
 	struct rte_meter_trtcm *meter2 = &entry2->mp[tc2].meter;
+	struct rte_meter_trtcm_profile *meter2_profile =
+				&entry2->mp[tc2].meter_profile;
 	struct pipeline_fa_policer_params *policer2 = &entry2->mp[tc2].policer;
 	struct pipeline_fa_policer_stats *stats2 = &entry2->mp[tc2].stats;
 
 	struct rte_meter_trtcm *meter3 = &entry3->mp[tc3].meter;
+	struct rte_meter_trtcm_profile *meter3_profile =
+				&entry3->mp[tc3].meter_profile;
 	struct pipeline_fa_policer_params *policer3 = &entry3->mp[tc3].policer;
 	struct pipeline_fa_policer_stats *stats3 = &entry3->mp[tc3].stats;
 
 	/* Read (entry), compute, write (entry) */
 	enum rte_meter_color color2_0 = rte_meter_trtcm_color_aware_check(
 		meter0,
+		meter0_profile,
 		time,
 		total_length0,
 		color0);
 
 	enum rte_meter_color color2_1 = rte_meter_trtcm_color_aware_check(
 		meter1,
+		meter1_profile,
 		time,
 		total_length1,
 		color1);
 
 	enum rte_meter_color color2_2 = rte_meter_trtcm_color_aware_check(
 		meter2,
+		meter2_profile,
 		time,
 		total_length2,
 		color2);
 
 	enum rte_meter_color color2_3 = rte_meter_trtcm_color_aware_check(
 		meter3,
+		meter3_profile,
 		time,
 		total_length3,
 		color3);
examples/qos_meter/main.c +30 -9
index 7a0df50..1e1370f 100644
@@ -92,14 +92,23 @@ static uint16_t port_tx;
 static struct rte_mbuf *pkts_rx[PKT_RX_BURST_MAX];
 struct rte_eth_dev_tx_buffer *tx_buffer;
 
-struct rte_meter_srtcm_params app_srtcm_params[] = {
-	{.cir = 1000000 * 46,  .cbs = 2048, .ebs = 2048},
+struct rte_meter_srtcm_params app_srtcm_params = {
+	.cir = 1000000 * 46,
+	.cbs = 2048,
+	.ebs = 2048
 };
 
-struct rte_meter_trtcm_params app_trtcm_params[] = {
-	{.cir = 1000000 * 46,  .pir = 1500000 * 46,  .cbs = 2048, .pbs = 2048},
+struct rte_meter_srtcm_profile app_srtcm_profile;
+
+struct rte_meter_trtcm_params app_trtcm_params = {
+	.cir = 1000000 * 46,
+	.pir = 1500000 * 46,
+	.cbs = 2048,
+	.pbs = 2048
 };
 
+struct rte_meter_trtcm_profile app_trtcm_profile;
+
 #define APP_FLOWS_MAX  256
 
 FLOW_METER app_flows[APP_FLOWS_MAX];
@@ -107,12 +116,21 @@ FLOW_METER app_flows[APP_FLOWS_MAX];
 static int
 app_configure_flow_table(void)
 {
-	uint32_t i, j;
+	uint32_t i;
 	int ret;
 
-	for (i = 0, j = 0; i < APP_FLOWS_MAX;
-			i ++, j = (j + 1) % RTE_DIM(PARAMS)) {
-		ret = FUNC_CONFIG(&app_flows[i], &PARAMS[j]);
+	ret = rte_meter_srtcm_profile_config(&app_srtcm_profile,
+		&app_srtcm_params);
+	if (ret)
+		return ret;
+
+	ret = rte_meter_trtcm_profile_config(&app_trtcm_profile,
+		&app_trtcm_params);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < APP_FLOWS_MAX; i++) {
+		ret = FUNC_CONFIG(&app_flows[i], &PROFILE);
 		if (ret)
 			return ret;
 	}
@@ -137,7 +155,10 @@ app_pkt_handle(struct rte_mbuf *pkt, uint64_t time)
 	enum policer_action action;
 
 	/* color input is not used for blind modes */
-	output_color = (uint8_t) FUNC_METER(&app_flows[flow_id], time, pkt_len,
+	output_color = (uint8_t) FUNC_METER(&app_flows[flow_id],
+		&PROFILE,
+		time,
+		pkt_len,
 		(enum rte_meter_color) input_color);
 
 	/* Apply policing and set the output color */
examples/qos_meter/main.h +20 -12
index b27e8eb..f51eb66 100644
@@ -21,44 +21,52 @@ enum policer_action policer_table[e_RTE_METER_COLORS][e_RTE_METER_COLORS] =
 
 #if APP_MODE == APP_MODE_FWD
 
-#define FUNC_METER(a,b,c,d) color, flow_id=flow_id, pkt_len=pkt_len, time=time
+#define FUNC_METER(m, p, time, pkt_len, pkt_color)	\
+({							\
+	void *mp = m;					\
+	void *pp = p;					\
+	mp = mp;					\
+	pp = pp;					\
+	time = time;					\
+	pkt_len = pkt_len;				\
+	pkt_color;					\
+})
 #define FUNC_CONFIG(a, b) 0
-#define PARAMS	app_srtcm_params
 #define FLOW_METER int
+#define PROFILE	app_srtcm_profile
 
 #elif APP_MODE == APP_MODE_SRTCM_COLOR_BLIND
 
-#define FUNC_METER(a,b,c,d) rte_meter_srtcm_color_blind_check(a,b,c)
+#define FUNC_METER(m, p, time, pkt_len, pkt_color)	\
+	rte_meter_srtcm_color_blind_check(m, p, time, pkt_len)
 #define FUNC_CONFIG   rte_meter_srtcm_config
-#define PARAMS        app_srtcm_params
 #define FLOW_METER    struct rte_meter_srtcm
+#define PROFILE       app_srtcm_profile
 
 #elif (APP_MODE == APP_MODE_SRTCM_COLOR_AWARE)
 
 #define FUNC_METER    rte_meter_srtcm_color_aware_check
 #define FUNC_CONFIG   rte_meter_srtcm_config
-#define PARAMS        app_srtcm_params
 #define FLOW_METER    struct rte_meter_srtcm
+#define PROFILE       app_srtcm_profile
 
 #elif (APP_MODE == APP_MODE_TRTCM_COLOR_BLIND)
 
-#define FUNC_METER(a,b,c,d) rte_meter_trtcm_color_blind_check(a,b,c)
+#define FUNC_METER(m, p, time, pkt_len, pkt_color)	\
+	rte_meter_trtcm_color_blind_check(m, p, time, pkt_len)
 #define FUNC_CONFIG  rte_meter_trtcm_config
-#define PARAMS       app_trtcm_params
 #define FLOW_METER   struct rte_meter_trtcm
+#define PROFILE      app_trtcm_profile
 
 #elif (APP_MODE == APP_MODE_TRTCM_COLOR_AWARE)
 
-#define FUNC_METER   rte_meter_trtcm_color_aware_check
+#define FUNC_METER rte_meter_trtcm_color_aware_check
 #define FUNC_CONFIG  rte_meter_trtcm_config
-#define PARAMS       app_trtcm_params
 #define FLOW_METER   struct rte_meter_trtcm
+#define PROFILE      app_trtcm_profile
 
 #else
 #error Invalid value for APP_MODE
 #endif
 
-
-
-
 #endif /* _MAIN_H_ */
lib/librte_meter/Makefile +1 -1
index 3b80c6a..2dc071e 100644
@@ -16,7 +16,7 @@ LDLIBS += -lrte_eal
 
 EXPORT_MAP := rte_meter_version.map
 
-LIBABIVER := 1
+LIBABIVER := 2
 
 #
 # all source are stored in SRCS-y
lib/librte_meter/rte_meter.c +57 -36

118 lines not on this page · raw message

lib/librte_meter/rte_meter.h +136 -59

343 lines not on this page · raw message

lib/librte_meter/rte_meter_version.map +8 -0
index 2fd647c..c4422ef 100644
@@ -10,3 +10,11 @@ DPDK_2.0 {
 
 	local: *;
 };
+
+DPDK_18.02 {
+	global:
+
+	rte_meter_srtcm_profile_config;
+	rte_meter_trtcm_profile_config;
+
+} DPDK_2.0;
test/test/test_meter.c +115 -79

423 lines not on this page · raw message

Signature · 1 line
2.9.3
author Applied
#7 lore raw

Re: [PATCH v4] lib/librte_meter: add meter configuration profile

Quoted 9 lines

-----Original Message-----
From: Singh, Jasvinder
Sent: Monday, January 8, 2018 3:44 PM
To: [email protected]
Cc: Dumitrescu, Cristian <[email protected]>
Subject: [PATCH v4] lib/librte_meter: add meter configuration profile

Quoted 5 lines

From: Cristian Dumitrescu <[email protected]>

This patch adds support for meter configuration profiles.
Benefits: simplified configuration procedure, improved performance.

...<snip>

Quoted 7 lines

---
V4:
- change commit message

Applied to next-qos tree.

#8 lore raw

Re: [PATCH v4] lib/librte_meter: add meter configuration profile

In reply to Jasvinder Singh

08/01/2018 16:43, Jasvinder Singh:

Quoted 31 lines

From: Cristian Dumitrescu <[email protected]>

This patch adds support for meter configuration profiles.
Benefits: simplified configuration procedure, improved performance.

Q1: What is the configuration profile and why does it make sense?
A1: The configuration profile represents the set of configuration
parameters for a given meter object, such as the rates and sizes for the token buckets. The configuration profile concept makes sense when many meter objects share the same configuration, which is the typical usage model: thousands of traffic flows are each individually metered according to just a few service levels (i.e. profiles).

Q2: How is the configuration profile improving the performance?
A2: The performance improvement is achieved by reducing the memory
footprint of a meter object, which results in better cache utilization for the typical case when large arrays of meter objects are used. The internal data structures stored for each meter object contain:
a) Constant fields: Low level translation of the configuration parameters that does not change post-configuration. This is really duplicated for all meters that use the same configuration. This is the configuration profile data that is moved away from the meter object. Current size (implementation dependent): srTCM = 32 bytes, trTCM = 32 bytes.
b) Variable fields: Time stamps and running counters that change during the on-going traffic metering process. Current size (implementation dependant): srTCM = 24 bytes, trTCM = 32 bytes. Therefore, by moving the constant fields to a separate profile data structure shared by all the meters with the same configuration, the size of the meter object is reduced by ~50%.

Quoted 2 lines

Applied for 18.05 (was postponed to preserve 18.02 ABI), thanks.

#9 lore raw

Re: [PATCH v4] lib/librte_meter: add meter configuration profile

19/02/2018 22:12, Thomas Monjalon:

Quoted 5 lines

08/01/2018 16:43, Jasvinder Singh:

Quoted 2 lines

Applied for 18.05 (was postponed to preserve 18.02 ABI), thanks.

We forgot to update the release notes about the API change. Please, could you send a patch to add it in the appropriate section? Thanks

#10 lore raw

Re: [PATCH v4] lib/librte_meter: add meter configuration profile

Quoted 13 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Thursday, April 5, 2018 11:12 AM
To: Singh, Jasvinder <[email protected]>; Dumitrescu, Cristian <[email protected]>
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v4] lib/librte_meter: add meter configuration profile

19/02/2018 22:12, Thomas Monjalon:

Quoted 1 line

08/01/2018 16:43, Jasvinder Singh:

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

Applied for 18.05 (was postponed to preserve 18.02 ABI), thanks.

We forgot to update the release notes about the API change. Please, could you send a patch to add it in the appropriate section? Thanks

Will send a quick patch later today, thanks!

#11 lore raw

PATCH v2 2/4 test/test_meter: update meter test

In reply to Jasvinder Singh

From: Cristian Dumitrescu <[email protected]>

Modify the unit test to accomodate the changes in the apis.

---
 test/test/test_meter.c | 194 +++++++++++++++++++++++++++++--------------------
 1 file changed, 115 insertions(+), 79 deletions(-)
test/test/test_meter.c +115 -79
index 26b0565..b6d133a 100644
@@ -82,43 +82,43 @@ static inline int
 tm_test_srtcm_config(void)
 {
 #define SRTCM_CFG_MSG "srtcm_config"
-	struct rte_meter_srtcm sm;
+	struct rte_meter_srtcm_profile sp;
 	struct  rte_meter_srtcm_params sparams1;
 
 	/* invalid parameter test */
-	if(rte_meter_srtcm_config(NULL, NULL) == 0)
+	if (rte_meter_srtcm_profile_config(NULL, NULL) == 0)
 		melog(SRTCM_CFG_MSG);
-	if(rte_meter_srtcm_config(&sm, NULL) == 0)
+	if (rte_meter_srtcm_profile_config(&sp, NULL) == 0)
 		melog(SRTCM_CFG_MSG);
-	if(rte_meter_srtcm_config(NULL, &sparams) == 0)
+	if (rte_meter_srtcm_profile_config(NULL, &sparams) == 0)
 		melog(SRTCM_CFG_MSG);
 
 	/* cbs and ebs can't both be zero */
 	sparams1 = sparams;
 	sparams1.cbs = 0;
 	sparams1.ebs = 0;
-	if(rte_meter_srtcm_config(&sm, &sparams1) == 0)
+	if (rte_meter_srtcm_profile_config(&sp, &sparams1) == 0)
 		melog(SRTCM_CFG_MSG);
 
 	/* cir should never be 0 */
 	sparams1 = sparams;
 	sparams1.cir = 0;
-	if(rte_meter_srtcm_config(&sm, &sparams1) == 0)
+	if (rte_meter_srtcm_profile_config(&sp, &sparams1) == 0)
 		melog(SRTCM_CFG_MSG);
 
 	/* one of ebs and cbs can be zero, should be successful */
 	sparams1 = sparams;
 	sparams1.ebs = 0;
-	if(rte_meter_srtcm_config(&sm, &sparams1) != 0)
+	if (rte_meter_srtcm_profile_config(&sp, &sparams1) != 0)
 		melog(SRTCM_CFG_MSG);
 
 	sparams1 = sparams;
 	sparams1.cbs = 0;
-	if(rte_meter_srtcm_config(&sm, &sparams1) != 0)
+	if (rte_meter_srtcm_profile_config(&sp, &sparams1) != 0)
 		melog(SRTCM_CFG_MSG);
 
 	/* usual parameter, should be successful */
-	if(rte_meter_srtcm_config(&sm, &sparams) != 0)
+	if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
 		melog(SRTCM_CFG_MSG);
 
 	return 0;
@@ -131,47 +131,47 @@ tm_test_srtcm_config(void)
 static inline int
 tm_test_trtcm_config(void)
 {
-	struct rte_meter_trtcm tm;
+	struct rte_meter_trtcm_profile tp;
 	struct  rte_meter_trtcm_params tparams1;
 #define TRTCM_CFG_MSG "trtcm_config"
 
 	/* invalid parameter test */
-	if(rte_meter_trtcm_config(NULL, NULL) == 0)
+	if (rte_meter_trtcm_profile_config(NULL, NULL) == 0)
 		melog(TRTCM_CFG_MSG);
-	if(rte_meter_trtcm_config(&tm, NULL) == 0)
+	if (rte_meter_trtcm_profile_config(&tp, NULL) == 0)
 		melog(TRTCM_CFG_MSG);
-	if(rte_meter_trtcm_config(NULL, &tparams) == 0)
+	if (rte_meter_trtcm_profile_config(NULL, &tparams) == 0)
 		melog(TRTCM_CFG_MSG);
 
 	/* cir, cbs, pir and pbs never be zero */
 	tparams1 = tparams;
 	tparams1.cir = 0;
-	if(rte_meter_trtcm_config(&tm, &tparams1) == 0)
+	if (rte_meter_trtcm_profile_config(&tp, &tparams1) == 0)
 		melog(TRTCM_CFG_MSG);
 
 	tparams1 = tparams;
 	tparams1.cbs = 0;
-	if(rte_meter_trtcm_config(&tm, &tparams1) == 0)
+	if (rte_meter_trtcm_profile_config(&tp, &tparams1) == 0)
 		melog(TRTCM_CFG_MSG);
 
 	tparams1 = tparams;
 	tparams1.pbs = 0;
-	if(rte_meter_trtcm_config(&tm, &tparams1) == 0)
+	if (rte_meter_trtcm_profile_config(&tp, &tparams1) == 0)
 		melog(TRTCM_CFG_MSG);
 
 	tparams1 = tparams;
 	tparams1.pir = 0;
-	if(rte_meter_trtcm_config(&tm, &tparams1) == 0)
+	if (rte_meter_trtcm_profile_config(&tp, &tparams1) == 0)
 		melog(TRTCM_CFG_MSG);
 
 	/* pir should be greater or equal to cir */
 	tparams1 = tparams;
 	tparams1.pir = tparams1.cir - 1;
-	if(rte_meter_trtcm_config(&tm, &tparams1) == 0)
+	if (rte_meter_trtcm_profile_config(&tp, &tparams1) == 0)
 		melog(TRTCM_CFG_MSG" pir < cir test");
 
 	/* usual parameter, should be successful */
-	if(rte_meter_trtcm_config(&tm, &tparams) != 0)
+	if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
 		melog(TRTCM_CFG_MSG);
 
 	return 0;
@@ -184,41 +184,50 @@ static inline int
 tm_test_srtcm_color_blind_check(void)
 {
 #define SRTCM_BLIND_CHECK_MSG "srtcm_blind_check"
+	struct rte_meter_srtcm_profile sp;
 	struct rte_meter_srtcm sm;
 	uint64_t time;
 	uint64_t hz = rte_get_tsc_hz();
 
 	/* Test green */
-	if(rte_meter_srtcm_config(&sm, &sparams) != 0)
+	if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
+		melog(SRTCM_BLIND_CHECK_MSG);
+	if (rte_meter_srtcm_config(&sm, &sp) != 0)
 		melog(SRTCM_BLIND_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
-	if(rte_meter_srtcm_color_blind_check(
-		&sm, time, TM_TEST_SRTCM_CBS_DF - 1)
+	if (rte_meter_srtcm_color_blind_check(
+		&sm, &sp, time, TM_TEST_SRTCM_CBS_DF - 1)
 		!= e_RTE_METER_GREEN)
 		melog(SRTCM_BLIND_CHECK_MSG" GREEN");
 
 	/* Test yellow */
-	if(rte_meter_srtcm_config(&sm, &sparams) != 0)
+	if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
+		melog(SRTCM_BLIND_CHECK_MSG);
+	if (rte_meter_srtcm_config(&sm, &sp) != 0)
 		melog(SRTCM_BLIND_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
-	if(rte_meter_srtcm_color_blind_check(
-		&sm, time, TM_TEST_SRTCM_CBS_DF + 1)
+	if (rte_meter_srtcm_color_blind_check(
+		&sm, &sp, time, TM_TEST_SRTCM_CBS_DF + 1)
 		!= e_RTE_METER_YELLOW)
 		melog(SRTCM_BLIND_CHECK_MSG" YELLOW");
 
-	if(rte_meter_srtcm_config(&sm, &sparams) != 0)
+	if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
+		melog(SRTCM_BLIND_CHECK_MSG);
+	if (rte_meter_srtcm_config(&sm, &sp) != 0)
 		melog(SRTCM_BLIND_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
-	if(rte_meter_srtcm_color_blind_check(
-		&sm, time, (uint32_t)sm.ebs - 1) != e_RTE_METER_YELLOW)
+	if (rte_meter_srtcm_color_blind_check(
+		&sm, &sp, time, (uint32_t)sp.ebs - 1) != e_RTE_METER_YELLOW)
 		melog(SRTCM_BLIND_CHECK_MSG" YELLOW");
 
 	/* Test red */
-	if(rte_meter_srtcm_config(&sm, &sparams) != 0)
+	if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
+		melog(SRTCM_BLIND_CHECK_MSG);
+	if (rte_meter_srtcm_config(&sm, &sp) != 0)
 		melog(SRTCM_BLIND_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
-	if(rte_meter_srtcm_color_blind_check(
-		&sm, time, TM_TEST_SRTCM_EBS_DF + 1)
+	if (rte_meter_srtcm_color_blind_check(
+		&sm, &sp, time, TM_TEST_SRTCM_EBS_DF + 1)
 		!= e_RTE_METER_RED)
 		melog(SRTCM_BLIND_CHECK_MSG" RED");
 
@@ -235,41 +244,50 @@ tm_test_trtcm_color_blind_check(void)
 #define TRTCM_BLIND_CHECK_MSG "trtcm_blind_check"
 
 	uint64_t time;
+	struct rte_meter_trtcm_profile tp;
 	struct rte_meter_trtcm tm;
 	uint64_t hz = rte_get_tsc_hz();
 
 	/* Test green */
-	if(rte_meter_trtcm_config(&tm, &tparams) != 0)
+	if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
+		melog(TRTCM_BLIND_CHECK_MSG);
+	if (rte_meter_trtcm_config(&tm, &tp) != 0)
 		melog(TRTCM_BLIND_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
-	if(rte_meter_trtcm_color_blind_check(
-		&tm, time, TM_TEST_TRTCM_CBS_DF - 1)
+	if (rte_meter_trtcm_color_blind_check(
+		&tm, &tp, time, TM_TEST_TRTCM_CBS_DF - 1)
 		!= e_RTE_METER_GREEN)
 		melog(TRTCM_BLIND_CHECK_MSG" GREEN");
 
 	/* Test yellow */
-	if(rte_meter_trtcm_config(&tm, &tparams) != 0)
+	if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
+		melog(TRTCM_BLIND_CHECK_MSG);
+	if (rte_meter_trtcm_config(&tm, &tp) != 0)
 		melog(TRTCM_BLIND_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
-	if(rte_meter_trtcm_color_blind_check(
-		&tm, time, TM_TEST_TRTCM_CBS_DF + 1)
+	if (rte_meter_trtcm_color_blind_check(
+		&tm, &tp, time, TM_TEST_TRTCM_CBS_DF + 1)
 		!= e_RTE_METER_YELLOW)
 		melog(TRTCM_BLIND_CHECK_MSG" YELLOW");
 
-	if(rte_meter_trtcm_config(&tm, &tparams) != 0)
+	if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
+		melog(TRTCM_BLIND_CHECK_MSG);
+	if (rte_meter_trtcm_config(&tm, &tp) != 0)
 		melog(TRTCM_BLIND_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
-	if(rte_meter_trtcm_color_blind_check(
-		&tm, time, TM_TEST_TRTCM_PBS_DF - 1)
+	if (rte_meter_trtcm_color_blind_check(
+		&tm, &tp, time, TM_TEST_TRTCM_PBS_DF - 1)
 		!= e_RTE_METER_YELLOW)
 		melog(TRTCM_BLIND_CHECK_MSG" YELLOW");
 
 	/* Test red */
-	if(rte_meter_trtcm_config(&tm, &tparams) != 0)
+	if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
+		melog(TRTCM_BLIND_CHECK_MSG);
+	if (rte_meter_trtcm_config(&tm, &tp) != 0)
 		melog(TRTCM_BLIND_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
-	if(rte_meter_trtcm_color_blind_check(
-		&tm, time, TM_TEST_TRTCM_PBS_DF + 1)
+	if (rte_meter_trtcm_color_blind_check(
+		&tm, &tp, time, TM_TEST_TRTCM_PBS_DF + 1)
 		!= e_RTE_METER_RED)
 		melog(TRTCM_BLIND_CHECK_MSG" RED");
 
@@ -291,36 +309,45 @@ tm_test_srtcm_aware_check
 (enum rte_meter_color in[4], enum rte_meter_color out[4])
 {
 #define SRTCM_AWARE_CHECK_MSG "srtcm_aware_check"
+	struct rte_meter_srtcm_profile sp;
 	struct rte_meter_srtcm sm;
 	uint64_t time;
 	uint64_t hz = rte_get_tsc_hz();
 
-	if(rte_meter_srtcm_config(&sm, &sparams) != 0)
+	if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
+		melog(SRTCM_AWARE_CHECK_MSG);
+	if (rte_meter_srtcm_config(&sm, &sp) != 0)
 		melog(SRTCM_AWARE_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
-	if(rte_meter_srtcm_color_aware_check(
-		&sm, time, TM_TEST_SRTCM_CBS_DF - 1, in[0]) != out[0])
+	if (rte_meter_srtcm_color_aware_check(
+		&sm, &sp, time, TM_TEST_SRTCM_CBS_DF - 1, in[0]) != out[0])
 		melog(SRTCM_AWARE_CHECK_MSG" %u:%u", in[0], out[0]);
 
-	if(rte_meter_srtcm_config(&sm, &sparams) != 0)
+	if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
+		melog(SRTCM_AWARE_CHECK_MSG);
+	if (rte_meter_srtcm_config(&sm, &sp) != 0)
 		melog(SRTCM_AWARE_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
-	if(rte_meter_srtcm_color_aware_check(
-		&sm, time, TM_TEST_SRTCM_CBS_DF + 1, in[1]) != out[1])
+	if (rte_meter_srtcm_color_aware_check(
+		&sm, &sp, time, TM_TEST_SRTCM_CBS_DF + 1, in[1]) != out[1])
 		melog(SRTCM_AWARE_CHECK_MSG" %u:%u", in[1], out[1]);
 
-	if(rte_meter_srtcm_config(&sm, &sparams) != 0)
+	if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
+		melog(SRTCM_AWARE_CHECK_MSG);
+	if (rte_meter_srtcm_config(&sm, &sp) != 0)
 		melog(SRTCM_AWARE_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
-	if(rte_meter_srtcm_color_aware_check(
-		&sm, time, TM_TEST_SRTCM_EBS_DF - 1, in[2]) != out[2])
+	if (rte_meter_srtcm_color_aware_check(
+		&sm, &sp, time, TM_TEST_SRTCM_EBS_DF - 1, in[2]) != out[2])
 		melog(SRTCM_AWARE_CHECK_MSG" %u:%u", in[2], out[2]);
 
-	if(rte_meter_srtcm_config(&sm, &sparams) != 0)
+	if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
+		melog(SRTCM_AWARE_CHECK_MSG);
+	if (rte_meter_srtcm_config(&sm, &sp) != 0)
 		melog(SRTCM_AWARE_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
-	if(rte_meter_srtcm_color_aware_check(
-		&sm, time, TM_TEST_SRTCM_EBS_DF + 1, in[3]) != out[3])
+	if (rte_meter_srtcm_color_aware_check(
+		&sm, &sp, time, TM_TEST_SRTCM_EBS_DF + 1, in[3]) != out[3])
 		melog(SRTCM_AWARE_CHECK_MSG" %u:%u", in[3], out[3]);
 
 	return 0;
@@ -346,7 +373,7 @@ tm_test_srtcm_color_aware_check(void)
 	out[1] = e_RTE_METER_YELLOW;
 	out[2] = e_RTE_METER_YELLOW;
 	out[3] = e_RTE_METER_RED;
-	if(tm_test_srtcm_aware_check(in, out) != 0)
+	if (tm_test_srtcm_aware_check(in, out) != 0)
 		return -1;
 
 	/**
@@ -358,7 +385,7 @@ tm_test_srtcm_color_aware_check(void)
 	out[1] = e_RTE_METER_YELLOW;
 	out[2] = e_RTE_METER_YELLOW;
 	out[3] = e_RTE_METER_RED;
-	if(tm_test_srtcm_aware_check(in, out) != 0)
+	if (tm_test_srtcm_aware_check(in, out) != 0)
 		return -1;
 
 	/**
@@ -370,7 +397,7 @@ tm_test_srtcm_color_aware_check(void)
 	out[1] = e_RTE_METER_RED;
 	out[2] = e_RTE_METER_RED;
 	out[3] = e_RTE_METER_RED;
-	if(tm_test_srtcm_aware_check(in, out) != 0)
+	if (tm_test_srtcm_aware_check(in, out) != 0)
 		return -1;
 
 	return 0;
@@ -389,36 +416,45 @@ tm_test_trtcm_aware_check
 (enum rte_meter_color in[4], enum rte_meter_color out[4])
 {
 #define TRTCM_AWARE_CHECK_MSG "trtcm_aware_check"
+	struct rte_meter_trtcm_profile tp;
 	struct rte_meter_trtcm tm;
 	uint64_t time;
 	uint64_t hz = rte_get_tsc_hz();
 
-	if(rte_meter_trtcm_config(&tm, &tparams) != 0)
+	if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
+		melog(TRTCM_AWARE_CHECK_MSG);
+	if (rte_meter_trtcm_config(&tm, &tp) != 0)
 		melog(TRTCM_AWARE_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
-	if(rte_meter_trtcm_color_aware_check(
-		&tm, time, TM_TEST_TRTCM_CBS_DF - 1, in[0]) != out[0])
+	if (rte_meter_trtcm_color_aware_check(
+		&tm, &tp, time, TM_TEST_TRTCM_CBS_DF - 1, in[0]) != out[0])
 		melog(TRTCM_AWARE_CHECK_MSG" %u:%u", in[0], out[0]);
 
-	if(rte_meter_trtcm_config(&tm, &tparams) != 0)
+	if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
+		melog(TRTCM_AWARE_CHECK_MSG);
+	if (rte_meter_trtcm_config(&tm, &tp) != 0)
 		melog(TRTCM_AWARE_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
-	if(rte_meter_trtcm_color_aware_check(
-		&tm, time, TM_TEST_TRTCM_CBS_DF + 1, in[1]) != out[1])
+	if (rte_meter_trtcm_color_aware_check(
+		&tm, &tp, time, TM_TEST_TRTCM_CBS_DF + 1, in[1]) != out[1])
 		melog(TRTCM_AWARE_CHECK_MSG" %u:%u", in[1], out[1]);
 
-	if(rte_meter_trtcm_config(&tm, &tparams) != 0)
+	if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
+		melog(TRTCM_AWARE_CHECK_MSG);
+	if (rte_meter_trtcm_config(&tm, &tp) != 0)
 		melog(TRTCM_AWARE_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
-	if(rte_meter_trtcm_color_aware_check(
-		&tm, time, TM_TEST_TRTCM_PBS_DF - 1, in[2]) != out[2])
+	if (rte_meter_trtcm_color_aware_check(
+		&tm, &tp, time, TM_TEST_TRTCM_PBS_DF - 1, in[2]) != out[2])
 		melog(TRTCM_AWARE_CHECK_MSG" %u:%u", in[2], out[2]);
 
-	if(rte_meter_trtcm_config(&tm, &tparams) != 0)
+	if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
+		melog(TRTCM_AWARE_CHECK_MSG);
+	if (rte_meter_trtcm_config(&tm, &tp) != 0)
 		melog(TRTCM_AWARE_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
-	if(rte_meter_trtcm_color_aware_check(
-		&tm, time, TM_TEST_TRTCM_PBS_DF + 1, in[3]) != out[3])
+	if (rte_meter_trtcm_color_aware_check(
+		&tm, &tp, time, TM_TEST_TRTCM_PBS_DF + 1, in[3]) != out[3])
 		melog(TRTCM_AWARE_CHECK_MSG" %u:%u", in[3], out[3]);
 
 	return 0;
@@ -444,7 +480,7 @@ tm_test_trtcm_color_aware_check(void)
 	out[1] = e_RTE_METER_YELLOW;
 	out[2] = e_RTE_METER_YELLOW;
 	out[3] = e_RTE_METER_RED;
-	if(tm_test_trtcm_aware_check(in, out) != 0)
+	if (tm_test_trtcm_aware_check(in, out) != 0)
 		return -1;
 
 	in[0] = in[1] = in[2] = in[3] = e_RTE_METER_YELLOW;
@@ -452,7 +488,7 @@ tm_test_trtcm_color_aware_check(void)
 	out[1] = e_RTE_METER_YELLOW;
 	out[2] = e_RTE_METER_YELLOW;
 	out[3] = e_RTE_METER_RED;
-	if(tm_test_trtcm_aware_check(in, out) != 0)
+	if (tm_test_trtcm_aware_check(in, out) != 0)
 		return -1;
 
 	in[0] = in[1] = in[2] = in[3] = e_RTE_METER_RED;
@@ -460,7 +496,7 @@ tm_test_trtcm_color_aware_check(void)
 	out[1] = e_RTE_METER_RED;
 	out[2] = e_RTE_METER_RED;
 	out[3] = e_RTE_METER_RED;
-	if(tm_test_trtcm_aware_check(in, out) != 0)
+	if (tm_test_trtcm_aware_check(in, out) != 0)
 		return -1;
 
 	return 0;
@@ -472,22 +508,22 @@ tm_test_trtcm_color_aware_check(void)
 static int
 test_meter(void)
 {
-	if(tm_test_srtcm_config() != 0 )
+	if (tm_test_srtcm_config() != 0)
 		return -1;
 
-	if(tm_test_trtcm_config() != 0 )
+	if (tm_test_trtcm_config() != 0)
 		return -1;
 
-	if(tm_test_srtcm_color_blind_check() != 0)
+	if (tm_test_srtcm_color_blind_check() != 0)
 		return -1;
 
-	if(tm_test_trtcm_color_blind_check()!= 0)
+	if (tm_test_trtcm_color_blind_check() != 0)
 		return -1;
 
-	if(tm_test_srtcm_color_aware_check()!= 0)
+	if (tm_test_srtcm_color_aware_check() != 0)
 		return -1;
 
-	if(tm_test_trtcm_color_aware_check()!= 0)
+	if (tm_test_trtcm_color_aware_check() != 0)
 		return -1;
 
 	return 0;
Signature · 1 line
2.9.3
#12 lore raw

PATCH v2 3/4 examples/qos_meter: accommodate meter api changes

In reply to Jasvinder Singh

From: Cristian Dumitrescu <[email protected]>

Modify the sample application to adapt the api changes.

---
 examples/qos_meter/main.c | 39 ++++++++++++++++++++++++++++++---------
 examples/qos_meter/main.h | 32 ++++++++++++++++++++------------
 2 files changed, 50 insertions(+), 21 deletions(-)
examples/qos_meter/main.c +30 -9
index 67b4a75..23908f0 100644
@@ -121,14 +121,23 @@ static uint16_t port_tx;
 static struct rte_mbuf *pkts_rx[PKT_RX_BURST_MAX];
 struct rte_eth_dev_tx_buffer *tx_buffer;
 
-struct rte_meter_srtcm_params app_srtcm_params[] = {
-	{.cir = 1000000 * 46,  .cbs = 2048, .ebs = 2048},
+struct rte_meter_srtcm_params app_srtcm_params = {
+	.cir = 1000000 * 46,
+	.cbs = 2048,
+	.ebs = 2048
 };
 
-struct rte_meter_trtcm_params app_trtcm_params[] = {
-	{.cir = 1000000 * 46,  .pir = 1500000 * 46,  .cbs = 2048, .pbs = 2048},
+struct rte_meter_srtcm_profile app_srtcm_profile;
+
+struct rte_meter_trtcm_params app_trtcm_params = {
+	.cir = 1000000 * 46,
+	.pir = 1500000 * 46,
+	.cbs = 2048,
+	.pbs = 2048
 };
 
+struct rte_meter_trtcm_profile app_trtcm_profile;
+
 #define APP_FLOWS_MAX  256
 
 FLOW_METER app_flows[APP_FLOWS_MAX];
@@ -136,12 +145,21 @@ FLOW_METER app_flows[APP_FLOWS_MAX];
 static int
 app_configure_flow_table(void)
 {
-	uint32_t i, j;
+	uint32_t i;
 	int ret;
 
-	for (i = 0, j = 0; i < APP_FLOWS_MAX;
-			i ++, j = (j + 1) % RTE_DIM(PARAMS)) {
-		ret = FUNC_CONFIG(&app_flows[i], &PARAMS[j]);
+	ret = rte_meter_srtcm_profile_config(&app_srtcm_profile,
+		&app_srtcm_params);
+	if (ret)
+		return ret;
+
+	ret = rte_meter_trtcm_profile_config(&app_trtcm_profile,
+		&app_trtcm_params);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < APP_FLOWS_MAX; i++) {
+		ret = FUNC_CONFIG(&app_flows[i], &PROFILE);
 		if (ret)
 			return ret;
 	}
@@ -166,7 +184,10 @@ app_pkt_handle(struct rte_mbuf *pkt, uint64_t time)
 	enum policer_action action;
 
 	/* color input is not used for blind modes */
-	output_color = (uint8_t) FUNC_METER(&app_flows[flow_id], time, pkt_len,
+	output_color = (uint8_t) FUNC_METER(&app_flows[flow_id],
+		&PROFILE,
+		time,
+		pkt_len,
 		(enum rte_meter_color) input_color);
 
 	/* Apply policing and set the output color */
examples/qos_meter/main.h +20 -12
index 54867dc..bff97a4 100644
@@ -50,44 +50,52 @@ enum policer_action policer_table[e_RTE_METER_COLORS][e_RTE_METER_COLORS] =
 
 #if APP_MODE == APP_MODE_FWD
 
-#define FUNC_METER(a,b,c,d) color, flow_id=flow_id, pkt_len=pkt_len, time=time
+#define FUNC_METER(m, p, time, pkt_len, pkt_color)	\
+({							\
+	void *mp = m;					\
+	void *pp = p;					\
+	mp = mp;					\
+	pp = pp;					\
+	time = time;					\
+	pkt_len = pkt_len;				\
+	pkt_color;					\
+})
 #define FUNC_CONFIG(a, b) 0
-#define PARAMS	app_srtcm_params
 #define FLOW_METER int
+#define PROFILE	app_srtcm_profile
 
 #elif APP_MODE == APP_MODE_SRTCM_COLOR_BLIND
 
-#define FUNC_METER(a,b,c,d) rte_meter_srtcm_color_blind_check(a,b,c)
+#define FUNC_METER(m, p, time, pkt_len, pkt_color)	\
+	rte_meter_srtcm_color_blind_check(m, p, time, pkt_len)
 #define FUNC_CONFIG   rte_meter_srtcm_config
-#define PARAMS        app_srtcm_params
 #define FLOW_METER    struct rte_meter_srtcm
+#define PROFILE       app_srtcm_profile
 
 #elif (APP_MODE == APP_MODE_SRTCM_COLOR_AWARE)
 
 #define FUNC_METER    rte_meter_srtcm_color_aware_check
 #define FUNC_CONFIG   rte_meter_srtcm_config
-#define PARAMS        app_srtcm_params
 #define FLOW_METER    struct rte_meter_srtcm
+#define PROFILE       app_srtcm_profile
 
 #elif (APP_MODE == APP_MODE_TRTCM_COLOR_BLIND)
 
-#define FUNC_METER(a,b,c,d) rte_meter_trtcm_color_blind_check(a,b,c)
+#define FUNC_METER(m, p, time, pkt_len, pkt_color)	\
+	rte_meter_trtcm_color_blind_check(m, p, time, pkt_len)
 #define FUNC_CONFIG  rte_meter_trtcm_config
-#define PARAMS       app_trtcm_params
 #define FLOW_METER   struct rte_meter_trtcm
+#define PROFILE      app_trtcm_profile
 
 #elif (APP_MODE == APP_MODE_TRTCM_COLOR_AWARE)
 
-#define FUNC_METER   rte_meter_trtcm_color_aware_check
+#define FUNC_METER rte_meter_trtcm_color_aware_check
 #define FUNC_CONFIG  rte_meter_trtcm_config
-#define PARAMS       app_trtcm_params
 #define FLOW_METER   struct rte_meter_trtcm
+#define PROFILE      app_trtcm_profile
 
 #else
 #error Invalid value for APP_MODE
 #endif
 
-
-
-
 #endif /* _MAIN_H_ */
Signature · 1 line
2.9.3
#13 lore raw

PATCH v2 4/4 examples/ip_pipeline: update flow action pipeline

In reply to Jasvinder Singh

Update flow action pipeline to conform the meter api changes.

---
 .../pipeline/pipeline_flow_actions_be.c            | 25 +++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)
examples/ip_pipeline/pipeline/pipeline_flow_actions_be.c +24 -1
index 11fcbb7..8874f04 100644
@@ -140,6 +140,7 @@ static pipeline_msg_req_handler custom_handlers[] = {
  */
 struct meter_policer {
 	struct rte_meter_trtcm meter;
+	struct rte_meter_trtcm_profile meter_profile;
 	struct pipeline_fa_policer_params policer;
 	struct pipeline_fa_policer_stats stats;
 };
@@ -156,8 +157,15 @@ flow_table_entry_set_meter(struct flow_table_entry *entry,
 {
 	struct rte_meter_trtcm *meter = &entry->mp[meter_id].meter;
 	struct rte_meter_trtcm_params *meter_params = &params->m[meter_id];
+	struct rte_meter_trtcm_profile *meter_profile =
+					&entry->mp[meter_id].meter_profile;
+	int status;
 
-	return rte_meter_trtcm_config(meter, meter_params);
+	status = rte_meter_trtcm_profile_config(meter_profile, meter_params);
+	if (status)
+		return status;
+
+	return rte_meter_trtcm_config(meter, meter_profile);
 }
 
 static void
@@ -231,11 +239,14 @@ pkt_work(
 	enum rte_meter_color color = p->dscp[dscp].color;
 
 	struct rte_meter_trtcm *meter = &entry->mp[tc].meter;
+	struct rte_meter_trtcm_profile *meter_profile =
+					&entry->mp[tc].meter_profile;
 	struct pipeline_fa_policer_params *policer = &entry->mp[tc].policer;
 	struct pipeline_fa_policer_stats *stats = &entry->mp[tc].stats;
 
 	/* Read (entry), compute */
 	enum rte_meter_color color2 = rte_meter_trtcm_color_aware_check(meter,
+		meter_profile,
 		time,
 		total_length,
 		color);
@@ -313,42 +324,54 @@ pkt4_work(
 	enum rte_meter_color color3 = p->dscp[dscp3].color;
 
 	struct rte_meter_trtcm *meter0 = &entry0->mp[tc0].meter;
+	struct rte_meter_trtcm_profile *meter0_profile =
+				&entry0->mp[tc0].meter_profile;
 	struct pipeline_fa_policer_params *policer0 = &entry0->mp[tc0].policer;
 	struct pipeline_fa_policer_stats *stats0 = &entry0->mp[tc0].stats;
 
 	struct rte_meter_trtcm *meter1 = &entry1->mp[tc1].meter;
+	struct rte_meter_trtcm_profile *meter1_profile =
+				&entry1->mp[tc1].meter_profile;
 	struct pipeline_fa_policer_params *policer1 = &entry1->mp[tc1].policer;
 	struct pipeline_fa_policer_stats *stats1 = &entry1->mp[tc1].stats;
 
 	struct rte_meter_trtcm *meter2 = &entry2->mp[tc2].meter;
+	struct rte_meter_trtcm_profile *meter2_profile =
+				&entry2->mp[tc2].meter_profile;
 	struct pipeline_fa_policer_params *policer2 = &entry2->mp[tc2].policer;
 	struct pipeline_fa_policer_stats *stats2 = &entry2->mp[tc2].stats;
 
 	struct rte_meter_trtcm *meter3 = &entry3->mp[tc3].meter;
+	struct rte_meter_trtcm_profile *meter3_profile =
+				&entry3->mp[tc3].meter_profile;
 	struct pipeline_fa_policer_params *policer3 = &entry3->mp[tc3].policer;
 	struct pipeline_fa_policer_stats *stats3 = &entry3->mp[tc3].stats;
 
 	/* Read (entry), compute, write (entry) */
 	enum rte_meter_color color2_0 = rte_meter_trtcm_color_aware_check(
 		meter0,
+		meter0_profile,
 		time,
 		total_length0,
 		color0);
 
 	enum rte_meter_color color2_1 = rte_meter_trtcm_color_aware_check(
 		meter1,
+		meter1_profile,
 		time,
 		total_length1,
 		color1);
 
 	enum rte_meter_color color2_2 = rte_meter_trtcm_color_aware_check(
 		meter2,
+		meter2_profile,
 		time,
 		total_length2,
 		color2);
 
 	enum rte_meter_color color2_3 = rte_meter_trtcm_color_aware_check(
 		meter3,
+		meter3_profile,
 		time,
 		total_length3,
 		color3);
Signature · 1 line
2.9.3
#14 lore raw

PATCH 2/4 test: meter autotest update

In reply to Cristian Dumitrescu
---
 test/test/test_meter.c | 138 +++++++++++++++++++++++++++++++------------------
 1 file changed, 87 insertions(+), 51 deletions(-)
test/test/test_meter.c +87 -51
index 26b0565..b3232f6 100644
@@ -82,43 +82,43 @@ static inline int
 tm_test_srtcm_config(void)
 {
 #define SRTCM_CFG_MSG "srtcm_config"
-	struct rte_meter_srtcm sm;
+	struct rte_meter_srtcm_profile sp;
 	struct  rte_meter_srtcm_params sparams1;
 
 	/* invalid parameter test */
-	if(rte_meter_srtcm_config(NULL, NULL) == 0)
+	if(rte_meter_srtcm_profile_config(NULL, NULL) == 0)
 		melog(SRTCM_CFG_MSG);
-	if(rte_meter_srtcm_config(&sm, NULL) == 0)
+	if(rte_meter_srtcm_profile_config(&sp, NULL) == 0)
 		melog(SRTCM_CFG_MSG);
-	if(rte_meter_srtcm_config(NULL, &sparams) == 0)
+	if(rte_meter_srtcm_profile_config(NULL, &sparams) == 0)
 		melog(SRTCM_CFG_MSG);
 
 	/* cbs and ebs can't both be zero */
 	sparams1 = sparams;
 	sparams1.cbs = 0;
 	sparams1.ebs = 0;
-	if(rte_meter_srtcm_config(&sm, &sparams1) == 0)
+	if(rte_meter_srtcm_profile_config(&sp, &sparams1) == 0)
 		melog(SRTCM_CFG_MSG);
 
 	/* cir should never be 0 */
 	sparams1 = sparams;
 	sparams1.cir = 0;
-	if(rte_meter_srtcm_config(&sm, &sparams1) == 0)
+	if(rte_meter_srtcm_profile_config(&sp, &sparams1) == 0)
 		melog(SRTCM_CFG_MSG);
 
 	/* one of ebs and cbs can be zero, should be successful */
 	sparams1 = sparams;
 	sparams1.ebs = 0;
-	if(rte_meter_srtcm_config(&sm, &sparams1) != 0)
+	if(rte_meter_srtcm_profile_config(&sp, &sparams1) != 0)
 		melog(SRTCM_CFG_MSG);
 
 	sparams1 = sparams;
 	sparams1.cbs = 0;
-	if(rte_meter_srtcm_config(&sm, &sparams1) != 0)
+	if(rte_meter_srtcm_profile_config(&sp, &sparams1) != 0)
 		melog(SRTCM_CFG_MSG);
 
 	/* usual parameter, should be successful */
-	if(rte_meter_srtcm_config(&sm, &sparams) != 0)
+	if(rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
 		melog(SRTCM_CFG_MSG);
 
 	return 0;
@@ -131,47 +131,47 @@ tm_test_srtcm_config(void)
 static inline int
 tm_test_trtcm_config(void)
 {
-	struct rte_meter_trtcm tm;
+	struct rte_meter_trtcm_profile tp;
 	struct  rte_meter_trtcm_params tparams1;
 #define TRTCM_CFG_MSG "trtcm_config"
 
 	/* invalid parameter test */
-	if(rte_meter_trtcm_config(NULL, NULL) == 0)
+	if(rte_meter_trtcm_profile_config(NULL, NULL) == 0)
 		melog(TRTCM_CFG_MSG);
-	if(rte_meter_trtcm_config(&tm, NULL) == 0)
+	if(rte_meter_trtcm_profile_config(&tp, NULL) == 0)
 		melog(TRTCM_CFG_MSG);
-	if(rte_meter_trtcm_config(NULL, &tparams) == 0)
+	if(rte_meter_trtcm_profile_config(NULL, &tparams) == 0)
 		melog(TRTCM_CFG_MSG);
 
 	/* cir, cbs, pir and pbs never be zero */
 	tparams1 = tparams;
 	tparams1.cir = 0;
-	if(rte_meter_trtcm_config(&tm, &tparams1) == 0)
+	if(rte_meter_trtcm_profile_config(&tp, &tparams1) == 0)
 		melog(TRTCM_CFG_MSG);
 
 	tparams1 = tparams;
 	tparams1.cbs = 0;
-	if(rte_meter_trtcm_config(&tm, &tparams1) == 0)
+	if(rte_meter_trtcm_profile_config(&tp, &tparams1) == 0)
 		melog(TRTCM_CFG_MSG);
 
 	tparams1 = tparams;
 	tparams1.pbs = 0;
-	if(rte_meter_trtcm_config(&tm, &tparams1) == 0)
+	if(rte_meter_trtcm_profile_config(&tp, &tparams1) == 0)
 		melog(TRTCM_CFG_MSG);
 
 	tparams1 = tparams;
 	tparams1.pir = 0;
-	if(rte_meter_trtcm_config(&tm, &tparams1) == 0)
+	if(rte_meter_trtcm_profile_config(&tp, &tparams1) == 0)
 		melog(TRTCM_CFG_MSG);
 
 	/* pir should be greater or equal to cir */
 	tparams1 = tparams;
 	tparams1.pir = tparams1.cir - 1;
-	if(rte_meter_trtcm_config(&tm, &tparams1) == 0)
+	if(rte_meter_trtcm_profile_config(&tp, &tparams1) == 0)
 		melog(TRTCM_CFG_MSG" pir < cir test");
 
 	/* usual parameter, should be successful */
-	if(rte_meter_trtcm_config(&tm, &tparams) != 0)
+	if(rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
 		melog(TRTCM_CFG_MSG);
 
 	return 0;
@@ -184,41 +184,50 @@ static inline int
 tm_test_srtcm_color_blind_check(void)
 {
 #define SRTCM_BLIND_CHECK_MSG "srtcm_blind_check"
+	struct rte_meter_srtcm_profile sp;
 	struct rte_meter_srtcm sm;
 	uint64_t time;
 	uint64_t hz = rte_get_tsc_hz();
 
 	/* Test green */
-	if(rte_meter_srtcm_config(&sm, &sparams) != 0)
+	if(rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
+		melog(SRTCM_BLIND_CHECK_MSG);
+	if(rte_meter_srtcm_config(&sm, &sp) != 0)
 		melog(SRTCM_BLIND_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
 	if(rte_meter_srtcm_color_blind_check(
-		&sm, time, TM_TEST_SRTCM_CBS_DF - 1)
+		&sm, &sp, time, TM_TEST_SRTCM_CBS_DF - 1)
 		!= e_RTE_METER_GREEN)
 		melog(SRTCM_BLIND_CHECK_MSG" GREEN");
 
 	/* Test yellow */
-	if(rte_meter_srtcm_config(&sm, &sparams) != 0)
+	if(rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
+		melog(SRTCM_BLIND_CHECK_MSG);
+	if(rte_meter_srtcm_config(&sm, &sp) != 0)
 		melog(SRTCM_BLIND_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
 	if(rte_meter_srtcm_color_blind_check(
-		&sm, time, TM_TEST_SRTCM_CBS_DF + 1)
+		&sm, &sp, time, TM_TEST_SRTCM_CBS_DF + 1)
 		!= e_RTE_METER_YELLOW)
 		melog(SRTCM_BLIND_CHECK_MSG" YELLOW");
 
-	if(rte_meter_srtcm_config(&sm, &sparams) != 0)
+	if(rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
+		melog(SRTCM_BLIND_CHECK_MSG);
+	if(rte_meter_srtcm_config(&sm, &sp) != 0)
 		melog(SRTCM_BLIND_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
 	if(rte_meter_srtcm_color_blind_check(
-		&sm, time, (uint32_t)sm.ebs - 1) != e_RTE_METER_YELLOW)
+		&sm, &sp, time, (uint32_t)sp.ebs - 1) != e_RTE_METER_YELLOW)
 		melog(SRTCM_BLIND_CHECK_MSG" YELLOW");
 
 	/* Test red */
-	if(rte_meter_srtcm_config(&sm, &sparams) != 0)
+	if(rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
+		melog(SRTCM_BLIND_CHECK_MSG);
+	if(rte_meter_srtcm_config(&sm, &sp) != 0)
 		melog(SRTCM_BLIND_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
 	if(rte_meter_srtcm_color_blind_check(
-		&sm, time, TM_TEST_SRTCM_EBS_DF + 1)
+		&sm, &sp, time, TM_TEST_SRTCM_EBS_DF + 1)
 		!= e_RTE_METER_RED)
 		melog(SRTCM_BLIND_CHECK_MSG" RED");
 
@@ -235,41 +244,50 @@ tm_test_trtcm_color_blind_check(void)
 #define TRTCM_BLIND_CHECK_MSG "trtcm_blind_check"
 
 	uint64_t time;
+	struct rte_meter_trtcm_profile tp;
 	struct rte_meter_trtcm tm;
 	uint64_t hz = rte_get_tsc_hz();
 
 	/* Test green */
-	if(rte_meter_trtcm_config(&tm, &tparams) != 0)
+	if(rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
+		melog(TRTCM_BLIND_CHECK_MSG);
+	if(rte_meter_trtcm_config(&tm, &tp) != 0)
 		melog(TRTCM_BLIND_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
 	if(rte_meter_trtcm_color_blind_check(
-		&tm, time, TM_TEST_TRTCM_CBS_DF - 1)
+		&tm, &tp, time, TM_TEST_TRTCM_CBS_DF - 1)
 		!= e_RTE_METER_GREEN)
 		melog(TRTCM_BLIND_CHECK_MSG" GREEN");
 
 	/* Test yellow */
-	if(rte_meter_trtcm_config(&tm, &tparams) != 0)
+	if(rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
+		melog(TRTCM_BLIND_CHECK_MSG);
+	if(rte_meter_trtcm_config(&tm, &tp) != 0)
 		melog(TRTCM_BLIND_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
 	if(rte_meter_trtcm_color_blind_check(
-		&tm, time, TM_TEST_TRTCM_CBS_DF + 1)
+		&tm, &tp, time, TM_TEST_TRTCM_CBS_DF + 1)
 		!= e_RTE_METER_YELLOW)
 		melog(TRTCM_BLIND_CHECK_MSG" YELLOW");
 
-	if(rte_meter_trtcm_config(&tm, &tparams) != 0)
+	if(rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
+		melog(TRTCM_BLIND_CHECK_MSG);
+	if(rte_meter_trtcm_config(&tm, &tp) != 0)
 		melog(TRTCM_BLIND_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
 	if(rte_meter_trtcm_color_blind_check(
-		&tm, time, TM_TEST_TRTCM_PBS_DF - 1)
+		&tm, &tp, time, TM_TEST_TRTCM_PBS_DF - 1)
 		!= e_RTE_METER_YELLOW)
 		melog(TRTCM_BLIND_CHECK_MSG" YELLOW");
 
 	/* Test red */
-	if(rte_meter_trtcm_config(&tm, &tparams) != 0)
+	if(rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
+		melog(TRTCM_BLIND_CHECK_MSG);
+	if(rte_meter_trtcm_config(&tm, &tp) != 0)
 		melog(TRTCM_BLIND_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
 	if(rte_meter_trtcm_color_blind_check(
-		&tm, time, TM_TEST_TRTCM_PBS_DF + 1)
+		&tm, &tp, time, TM_TEST_TRTCM_PBS_DF + 1)
 		!= e_RTE_METER_RED)
 		melog(TRTCM_BLIND_CHECK_MSG" RED");
 
@@ -291,36 +309,45 @@ tm_test_srtcm_aware_check
 (enum rte_meter_color in[4], enum rte_meter_color out[4])
 {
 #define SRTCM_AWARE_CHECK_MSG "srtcm_aware_check"
+	struct rte_meter_srtcm_profile sp;
 	struct rte_meter_srtcm sm;
 	uint64_t time;
 	uint64_t hz = rte_get_tsc_hz();
 
-	if(rte_meter_srtcm_config(&sm, &sparams) != 0)
+	if(rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
+		melog(SRTCM_AWARE_CHECK_MSG);
+	if(rte_meter_srtcm_config(&sm, &sp) != 0)
 		melog(SRTCM_AWARE_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
 	if(rte_meter_srtcm_color_aware_check(
-		&sm, time, TM_TEST_SRTCM_CBS_DF - 1, in[0]) != out[0])
+		&sm, &sp, time, TM_TEST_SRTCM_CBS_DF - 1, in[0]) != out[0])
 		melog(SRTCM_AWARE_CHECK_MSG" %u:%u", in[0], out[0]);
 
-	if(rte_meter_srtcm_config(&sm, &sparams) != 0)
+	if(rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
+		melog(SRTCM_AWARE_CHECK_MSG);
+	if(rte_meter_srtcm_config(&sm, &sp) != 0)
 		melog(SRTCM_AWARE_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
 	if(rte_meter_srtcm_color_aware_check(
-		&sm, time, TM_TEST_SRTCM_CBS_DF + 1, in[1]) != out[1])
+		&sm, &sp, time, TM_TEST_SRTCM_CBS_DF + 1, in[1]) != out[1])
 		melog(SRTCM_AWARE_CHECK_MSG" %u:%u", in[1], out[1]);
 
-	if(rte_meter_srtcm_config(&sm, &sparams) != 0)
+	if(rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
+		melog(SRTCM_AWARE_CHECK_MSG);
+	if(rte_meter_srtcm_config(&sm, &sp) != 0)
 		melog(SRTCM_AWARE_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
 	if(rte_meter_srtcm_color_aware_check(
-		&sm, time, TM_TEST_SRTCM_EBS_DF - 1, in[2]) != out[2])
+		&sm, &sp, time, TM_TEST_SRTCM_EBS_DF - 1, in[2]) != out[2])
 		melog(SRTCM_AWARE_CHECK_MSG" %u:%u", in[2], out[2]);
 
-	if(rte_meter_srtcm_config(&sm, &sparams) != 0)
+	if(rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
+		melog(SRTCM_AWARE_CHECK_MSG);
+	if(rte_meter_srtcm_config(&sm, &sp) != 0)
 		melog(SRTCM_AWARE_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
 	if(rte_meter_srtcm_color_aware_check(
-		&sm, time, TM_TEST_SRTCM_EBS_DF + 1, in[3]) != out[3])
+		&sm, &sp, time, TM_TEST_SRTCM_EBS_DF + 1, in[3]) != out[3])
 		melog(SRTCM_AWARE_CHECK_MSG" %u:%u", in[3], out[3]);
 
 	return 0;
@@ -389,36 +416,45 @@ tm_test_trtcm_aware_check
 (enum rte_meter_color in[4], enum rte_meter_color out[4])
 {
 #define TRTCM_AWARE_CHECK_MSG "trtcm_aware_check"
+	struct rte_meter_trtcm_profile tp;
 	struct rte_meter_trtcm tm;
 	uint64_t time;
 	uint64_t hz = rte_get_tsc_hz();
 
-	if(rte_meter_trtcm_config(&tm, &tparams) != 0)
+	if(rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
+		melog(TRTCM_AWARE_CHECK_MSG);
+	if(rte_meter_trtcm_config(&tm, &tp) != 0)
 		melog(TRTCM_AWARE_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
 	if(rte_meter_trtcm_color_aware_check(
-		&tm, time, TM_TEST_TRTCM_CBS_DF - 1, in[0]) != out[0])
+		&tm, &tp, time, TM_TEST_TRTCM_CBS_DF - 1, in[0]) != out[0])
 		melog(TRTCM_AWARE_CHECK_MSG" %u:%u", in[0], out[0]);
 
-	if(rte_meter_trtcm_config(&tm, &tparams) != 0)
+	if(rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
+		melog(TRTCM_AWARE_CHECK_MSG);
+	if(rte_meter_trtcm_config(&tm, &tp) != 0)
 		melog(TRTCM_AWARE_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
 	if(rte_meter_trtcm_color_aware_check(
-		&tm, time, TM_TEST_TRTCM_CBS_DF + 1, in[1]) != out[1])
+		&tm, &tp, time, TM_TEST_TRTCM_CBS_DF + 1, in[1]) != out[1])
 		melog(TRTCM_AWARE_CHECK_MSG" %u:%u", in[1], out[1]);
 
-	if(rte_meter_trtcm_config(&tm, &tparams) != 0)
+	if(rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
+		melog(TRTCM_AWARE_CHECK_MSG);
+	if(rte_meter_trtcm_config(&tm, &tp) != 0)
 		melog(TRTCM_AWARE_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
 	if(rte_meter_trtcm_color_aware_check(
-		&tm, time, TM_TEST_TRTCM_PBS_DF - 1, in[2]) != out[2])
+		&tm, &tp, time, TM_TEST_TRTCM_PBS_DF - 1, in[2]) != out[2])
 		melog(TRTCM_AWARE_CHECK_MSG" %u:%u", in[2], out[2]);
 
-	if(rte_meter_trtcm_config(&tm, &tparams) != 0)
+	if(rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
+		melog(TRTCM_AWARE_CHECK_MSG);
+	if(rte_meter_trtcm_config(&tm, &tp) != 0)
 		melog(TRTCM_AWARE_CHECK_MSG);
 	time = rte_get_tsc_cycles() + hz;
 	if(rte_meter_trtcm_color_aware_check(
-		&tm, time, TM_TEST_TRTCM_PBS_DF + 1, in[3]) != out[3])
+		&tm, &tp, time, TM_TEST_TRTCM_PBS_DF + 1, in[3]) != out[3])
 		melog(TRTCM_AWARE_CHECK_MSG" %u:%u", in[3], out[3]);
 
 	return 0;
Signature · 1 line
2.7.4
#15 lore raw

PATCH 3/4 qos_meter: accommodate meter api changes

In reply to Cristian Dumitrescu
---
 examples/qos_meter/main.c | 36 +++++++++++++++++++++++++-----------
 examples/qos_meter/main.h | 32 ++++++++++++++++++++------------
 2 files changed, 45 insertions(+), 23 deletions(-)
examples/qos_meter/main.c +25 -11
index b0909f6..420ec5a 100644
@@ -121,13 +121,15 @@ static uint8_t port_tx;
 static struct rte_mbuf *pkts_rx[PKT_RX_BURST_MAX];
 struct rte_eth_dev_tx_buffer *tx_buffer;
 
-struct rte_meter_srtcm_params app_srtcm_params[] = {
-	{.cir = 1000000 * 46,  .cbs = 2048, .ebs = 2048},
-};
+struct rte_meter_srtcm_params app_srtcm_params =
+	{.cir = 1000000 * 46,  .cbs = 2048, .ebs = 2048};
 
-struct rte_meter_trtcm_params app_trtcm_params[] = {
-	{.cir = 1000000 * 46,  .pir = 1500000 * 46,  .cbs = 2048, .pbs = 2048},
-};
+struct rte_meter_srtcm_profile app_srtcm_profile;
+
+struct rte_meter_trtcm_params app_trtcm_params =
+	{.cir = 1000000 * 46,  .pir = 1500000 * 46,  .cbs = 2048, .pbs = 2048};
+
+struct rte_meter_trtcm_profile app_trtcm_profile;
 
 #define APP_FLOWS_MAX  256
 
@@ -136,12 +138,21 @@ FLOW_METER app_flows[APP_FLOWS_MAX];
 static int
 app_configure_flow_table(void)
 {
-	uint32_t i, j;
+	uint32_t i;
 	int ret;
 
-	for (i = 0, j = 0; i < APP_FLOWS_MAX;
-			i ++, j = (j + 1) % RTE_DIM(PARAMS)) {
-		ret = FUNC_CONFIG(&app_flows[i], &PARAMS[j]);
+	ret = rte_meter_srtcm_profile_config(&app_srtcm_profile,
+		&app_srtcm_params);
+	if (ret)
+		return ret;
+
+	ret = rte_meter_trtcm_profile_config(&app_trtcm_profile,
+		&app_trtcm_params);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < APP_FLOWS_MAX; i++) {
+		ret = FUNC_CONFIG(&app_flows[i], &PROFILE);
 		if (ret)
 			return ret;
 	}
@@ -166,7 +177,10 @@ app_pkt_handle(struct rte_mbuf *pkt, uint64_t time)
 	enum policer_action action;
 
 	/* color input is not used for blind modes */
-	output_color = (uint8_t) FUNC_METER(&app_flows[flow_id], time, pkt_len,
+	output_color = (uint8_t) FUNC_METER(&app_flows[flow_id],
+		&PROFILE,
+		time,
+		pkt_len,
 		(enum rte_meter_color) input_color);
 
 	/* Apply policing and set the output color */
examples/qos_meter/main.h +20 -12
index 54867dc..bff97a4 100644
@@ -50,44 +50,52 @@ enum policer_action policer_table[e_RTE_METER_COLORS][e_RTE_METER_COLORS] =
 
 #if APP_MODE == APP_MODE_FWD
 
-#define FUNC_METER(a,b,c,d) color, flow_id=flow_id, pkt_len=pkt_len, time=time
+#define FUNC_METER(m, p, time, pkt_len, pkt_color)	\
+({							\
+	void *mp = m;					\
+	void *pp = p;					\
+	mp = mp;					\
+	pp = pp;					\
+	time = time;					\
+	pkt_len = pkt_len;				\
+	pkt_color;					\
+})
 #define FUNC_CONFIG(a, b) 0
-#define PARAMS	app_srtcm_params
 #define FLOW_METER int
+#define PROFILE	app_srtcm_profile
 
 #elif APP_MODE == APP_MODE_SRTCM_COLOR_BLIND
 
-#define FUNC_METER(a,b,c,d) rte_meter_srtcm_color_blind_check(a,b,c)
+#define FUNC_METER(m, p, time, pkt_len, pkt_color)	\
+	rte_meter_srtcm_color_blind_check(m, p, time, pkt_len)
 #define FUNC_CONFIG   rte_meter_srtcm_config
-#define PARAMS        app_srtcm_params
 #define FLOW_METER    struct rte_meter_srtcm
+#define PROFILE       app_srtcm_profile
 
 #elif (APP_MODE == APP_MODE_SRTCM_COLOR_AWARE)
 
 #define FUNC_METER    rte_meter_srtcm_color_aware_check
 #define FUNC_CONFIG   rte_meter_srtcm_config
-#define PARAMS        app_srtcm_params
 #define FLOW_METER    struct rte_meter_srtcm
+#define PROFILE       app_srtcm_profile
 
 #elif (APP_MODE == APP_MODE_TRTCM_COLOR_BLIND)
 
-#define FUNC_METER(a,b,c,d) rte_meter_trtcm_color_blind_check(a,b,c)
+#define FUNC_METER(m, p, time, pkt_len, pkt_color)	\
+	rte_meter_trtcm_color_blind_check(m, p, time, pkt_len)
 #define FUNC_CONFIG  rte_meter_trtcm_config
-#define PARAMS       app_trtcm_params
 #define FLOW_METER   struct rte_meter_trtcm
+#define PROFILE      app_trtcm_profile
 
 #elif (APP_MODE == APP_MODE_TRTCM_COLOR_AWARE)
 
-#define FUNC_METER   rte_meter_trtcm_color_aware_check
+#define FUNC_METER rte_meter_trtcm_color_aware_check
 #define FUNC_CONFIG  rte_meter_trtcm_config
-#define PARAMS       app_trtcm_params
 #define FLOW_METER   struct rte_meter_trtcm
+#define PROFILE      app_trtcm_profile
 
 #else
 #error Invalid value for APP_MODE
 #endif
 
-
-
-
 #endif /* _MAIN_H_ */
Signature · 1 line
2.7.4
#16 lore raw

PATCH 4/4 deprecation: removed the librte_meter notice

In reply to Cristian Dumitrescu
---
 doc/guides/rel_notes/deprecation.rst | 3 ---
 1 file changed, 3 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -3
index 3362f33..11a9d09 100644
@@ -112,9 +112,6 @@ Deprecation Notices
 
   - ``rte_cryptodev_allocate_driver``
 
-* librte_meter: The API will change to accommodate configuration profiles.
-  Most of the API functions will have an additional opaque parameter.
-
 * librte_table: The ``key_mask`` parameter will be added to all the hash tables
   that currently do not have it, as well as to the hash compute function prototype.
   The non-"do-sig" versions of the hash tables will be removed
Signature · 1 line
2.7.4
#17 lore raw
In reply to Cristian Dumitrescu
Quoted 6 lines

Cristian Dumitrescu (4):
meter: add meter configuration profile
test: meter autotest update
qos_meter: accommodate meter api changes
deprecation: removed the librte_meter notice

Quoted 8 lines
 doc/guides/rel_notes/deprecation.rst   |   3 -
 examples/qos_meter/main.c              |  36 ++++---
 examples/qos_meter/main.h              |  32 ++++---
 lib/librte_meter/rte_meter.c           |  88 ++++++++++-------
 lib/librte_meter/rte_meter.h           | 170 ++++++++++++++++++++++-----------
 lib/librte_meter/rte_meter_version.map |   8 ++
 test/test/test_meter.c                 | 138 ++++++++++++++++----------
 7 files changed, 306 insertions(+), 169 deletions(-)

There are too many checkpatches warnings.

And there is at least one compilation error with the first patch:

test/test/test_meter.c:93:34: fatal error: incompatible pointer types
passing 'struct rte_meter_srtcm_params *' to parameter of type 'struct rte_meter_srtcm_profile *' [-Wincompatible-pointer-types]

Please try to improve for RC2.