[dpdk-dev] [PATCH v3] lib/librte_meter: add meter configuration profile

Jasvinder Singh jasvinder.singh at intel.com
Mon Jan 8 11:00:44 CET 2018


From: Cristian Dumitrescu <cristian.dumitrescu at intel.com>

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.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu at intel.com>
Signed-off-by: Jasvinder Singh <jasvinder.singh at intel.com>
---
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(-)

diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index 13e8543..6ba5ffd 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -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.
diff --git a/doc/guides/rel_notes/release_18_02.rst b/doc/guides/rel_notes/release_18_02.rst
index 24b67bb..7343b74 100644
--- a/doc/guides/rel_notes/release_18_02.rst
+++ b/doc/guides/rel_notes/release_18_02.rst
@@ -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
diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_actions_be.c b/examples/ip_pipeline/pipeline/pipeline_flow_actions_be.c
index 9599b7d..33f1c41 100644
--- a/examples/ip_pipeline/pipeline/pipeline_flow_actions_be.c
+++ b/examples/ip_pipeline/pipeline/pipeline_flow_actions_be.c
@@ -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);
diff --git a/examples/qos_meter/main.c b/examples/qos_meter/main.c
index 7a0df50..1e1370f 100644
--- a/examples/qos_meter/main.c
+++ b/examples/qos_meter/main.c
@@ -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 */
diff --git a/examples/qos_meter/main.h b/examples/qos_meter/main.h
index b27e8eb..f51eb66 100644
--- a/examples/qos_meter/main.h
+++ b/examples/qos_meter/main.h
@@ -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_ */
diff --git a/lib/librte_meter/Makefile b/lib/librte_meter/Makefile
index 3b80c6a..2dc071e 100644
--- a/lib/librte_meter/Makefile
+++ b/lib/librte_meter/Makefile
@@ -16,7 +16,7 @@ LDLIBS += -lrte_eal
 
 EXPORT_MAP := rte_meter_version.map
 
-LIBABIVER := 1
+LIBABIVER := 2
 
 #
 # all source are stored in SRCS-y
diff --git a/lib/librte_meter/rte_meter.c b/lib/librte_meter/rte_meter.c
index 332c519..473f69a 100644
--- a/lib/librte_meter/rte_meter.c
+++ b/lib/librte_meter/rte_meter.c
@@ -31,61 +31,82 @@ 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;
 }
diff --git a/lib/librte_meter/rte_meter.h b/lib/librte_meter/rte_meter.h
index ebdc453..29b46bb 100644
--- a/lib/librte_meter/rte_meter.h
+++ b/lib/librte_meter/rte_meter.h
@@ -53,6 +53,18 @@ struct rte_meter_trtcm_params {
 	uint64_t pbs; /**< Peak Burst Size (PBS). Measured in bytes. */
 };
 
+/**
+ * Internal data structure storing the srTCM configuration profile. Typically
+ * shared by multiple srTCM objects.
+ */
+struct rte_meter_srtcm_profile;
+
+/**
+ * Internal data structure storing the trTCM configuration profile. Typically
+ * shared by multiple trTCM objects.
+ */
+struct rte_meter_trtcm_profile;
+
 /** Internal data structure storing the srTCM run-time context per metered traffic flow. */
 struct rte_meter_srtcm;
 
@@ -60,38 +72,66 @@ struct rte_meter_srtcm;
 struct rte_meter_trtcm;
 
 /**
+ * srTCM profile configuration
+ *
+ * @param p
+ *    Pointer to pre-allocated srTCM profile data structure
+ * @param params
+ *    srTCM profile parameters
+ * @return
+ *    0 upon success, error code otherwise
+ */
+int rte_meter_srtcm_profile_config(struct rte_meter_srtcm_profile *p,
+	struct rte_meter_srtcm_params *params);
+
+/**
+ * trTCM profile configuration
+ *
+ * @param p
+ *    Pointer to pre-allocated trTCM profile data structure
+ * @param params
+ *    trTCM profile parameters
+ * @return
+ *    0 upon success, error code otherwise
+ */
+int rte_meter_trtcm_profile_config(struct rte_meter_trtcm_profile *p,
+	struct rte_meter_trtcm_params *params);
+
+/**
  * srTCM configuration per metered traffic flow
  *
  * @param m
  *    Pointer to pre-allocated srTCM data structure
- * @param params
- *    User parameters per srTCM metered traffic flow
+ * @param p
+ *    srTCM profile. Needs to be valid.
  * @return
  *    0 upon success, error code otherwise
  */
 int
 rte_meter_srtcm_config(struct rte_meter_srtcm *m,
-	struct rte_meter_srtcm_params *params);
+	struct rte_meter_srtcm_profile *p);
 
 /**
  * trTCM configuration per metered traffic flow
  *
  * @param m
  *    Pointer to pre-allocated trTCM data structure
- * @param params
- *    User parameters per trTCM metered traffic flow
+ * @param p
+ *    trTCM profile. Needs to be valid.
  * @return
  *    0 upon success, error code otherwise
  */
 int
 rte_meter_trtcm_config(struct rte_meter_trtcm *m,
-	struct rte_meter_trtcm_params *params);
+	struct rte_meter_trtcm_profile *p);
 
 /**
  * srTCM color blind traffic metering
  *
  * @param m
  *    Handle to srTCM instance
+ * @param p
+ *    srTCM profile specified at srTCM object creation time
  * @param time
  *    Current CPU time stamp (measured in CPU cycles)
  * @param pkt_len
@@ -101,6 +141,7 @@ rte_meter_trtcm_config(struct rte_meter_trtcm *m,
  */
 static inline enum rte_meter_color
 rte_meter_srtcm_color_blind_check(struct rte_meter_srtcm *m,
+	struct rte_meter_srtcm_profile *p,
 	uint64_t time,
 	uint32_t pkt_len);
 
@@ -109,6 +150,8 @@ rte_meter_srtcm_color_blind_check(struct rte_meter_srtcm *m,
  *
  * @param m
  *    Handle to srTCM instance
+ * @param p
+ *    srTCM profile specified at srTCM object creation time
  * @param time
  *    Current CPU time stamp (measured in CPU cycles)
  * @param pkt_len
@@ -120,6 +163,7 @@ rte_meter_srtcm_color_blind_check(struct rte_meter_srtcm *m,
  */
 static inline enum rte_meter_color
 rte_meter_srtcm_color_aware_check(struct rte_meter_srtcm *m,
+	struct rte_meter_srtcm_profile *p,
 	uint64_t time,
 	uint32_t pkt_len,
 	enum rte_meter_color pkt_color);
@@ -129,6 +173,8 @@ rte_meter_srtcm_color_aware_check(struct rte_meter_srtcm *m,
  *
  * @param m
  *    Handle to trTCM instance
+ * @param p
+ *    trTCM profile specified at trTCM object creation time
  * @param time
  *    Current CPU time stamp (measured in CPU cycles)
  * @param pkt_len
@@ -138,6 +184,7 @@ rte_meter_srtcm_color_aware_check(struct rte_meter_srtcm *m,
  */
 static inline enum rte_meter_color
 rte_meter_trtcm_color_blind_check(struct rte_meter_trtcm *m,
+	struct rte_meter_trtcm_profile *p,
 	uint64_t time,
 	uint32_t pkt_len);
 
@@ -146,6 +193,8 @@ rte_meter_trtcm_color_blind_check(struct rte_meter_trtcm *m,
  *
  * @param m
  *    Handle to trTCM instance
+ * @param p
+ *    trTCM profile specified at trTCM object creation time
  * @param time
  *    Current CPU time stamp (measured in CPU cycles)
  * @param pkt_len
@@ -157,6 +206,7 @@ rte_meter_trtcm_color_blind_check(struct rte_meter_trtcm *m,
  */
 static inline enum rte_meter_color
 rte_meter_trtcm_color_aware_check(struct rte_meter_trtcm *m,
+	struct rte_meter_trtcm_profile *p,
 	uint64_t time,
 	uint32_t pkt_len,
 	enum rte_meter_color pkt_color);
@@ -166,33 +216,57 @@ rte_meter_trtcm_color_aware_check(struct rte_meter_trtcm *m,
  *
  ***/
 
+struct rte_meter_srtcm_profile {
+	uint64_t cbs;
+	/**< Upper limit for C token bucket */
+	uint64_t ebs;
+	/**< Upper limit for E token bucket */
+	uint64_t cir_period;
+	/**< Number of CPU cycles for each update of C and E token buckets */
+	uint64_t cir_bytes_per_period;
+	/**< Number of bytes to add to C and E token buckets on each update */
+};
+
 /* Internal data structure storing the srTCM run-time context per metered traffic flow. */
 struct rte_meter_srtcm {
 	uint64_t time; /* Time of latest update of C and E token buckets */
 	uint64_t tc;   /* Number of bytes currently available in the committed (C) token bucket */
 	uint64_t te;   /* Number of bytes currently available in the excess (E) token bucket */
-	uint64_t cbs;  /* Upper limit for C token bucket */
-	uint64_t ebs;  /* Upper limit for E token bucket */
-	uint64_t cir_period; /* Number of CPU cycles for one update of C and E token buckets */
-	uint64_t cir_bytes_per_period; /* Number of bytes to add to C and E token buckets on each update */
 };
 
-/* Internal data structure storing the trTCM run-time context per metered traffic flow. */
+struct rte_meter_trtcm_profile {
+	uint64_t cbs;
+	/**< Upper limit for C token bucket */
+	uint64_t pbs;
+	/**< Upper limit for P token bucket */
+	uint64_t cir_period;
+	/**< Number of CPU cycles for one update of C token bucket */
+	uint64_t cir_bytes_per_period;
+	/**< Number of bytes to add to C token bucket on each update */
+	uint64_t pir_period;
+	/**< Number of CPU cycles for one update of P token bucket */
+	uint64_t pir_bytes_per_period;
+	/**< Number of bytes to add to P token bucket on each update */
+};
+
+/**
+ * Internal data structure storing the trTCM run-time context per metered
+ * traffic flow.
+ */
 struct rte_meter_trtcm {
-	uint64_t time_tc; /* Time of latest update of C token bucket */
-	uint64_t time_tp; /* Time of latest update of E token bucket */
-	uint64_t tc;      /* Number of bytes currently available in the committed (C) token bucket */
-	uint64_t tp;      /* Number of bytes currently available in the peak (P) token bucket */
-	uint64_t cbs;     /* Upper limit for C token bucket */
-	uint64_t pbs;     /* Upper limit for P token bucket */
-	uint64_t cir_period; /* Number of CPU cycles for one update of C token bucket */
-	uint64_t cir_bytes_per_period; /* Number of bytes to add to C token bucket on each update */
-	uint64_t pir_period; /* Number of CPU cycles for one update of P token bucket */
-	uint64_t pir_bytes_per_period; /* Number of bytes to add to P token bucket on each update */
+	uint64_t time_tc;
+	/**< Time of latest update of C token bucket */
+	uint64_t time_tp;
+	/**< Time of latest update of E token bucket */
+	uint64_t tc;
+	/**< Number of bytes currently available in committed(C) token bucket */
+	uint64_t tp;
+	/**< Number of bytes currently available in the peak(P) token bucket */
 };
 
 static inline enum rte_meter_color
 rte_meter_srtcm_color_blind_check(struct rte_meter_srtcm *m,
+	struct rte_meter_srtcm_profile *p,
 	uint64_t time,
 	uint32_t pkt_len)
 {
@@ -200,17 +274,17 @@ rte_meter_srtcm_color_blind_check(struct rte_meter_srtcm *m,
 
 	/* Bucket update */
 	time_diff = time - m->time;
-	n_periods = time_diff / m->cir_period;
-	m->time += n_periods * m->cir_period;
+	n_periods = time_diff / p->cir_period;
+	m->time += n_periods * p->cir_period;
 
 	/* Put the tokens overflowing from tc into te bucket */
-	tc = m->tc + n_periods * m->cir_bytes_per_period;
+	tc = m->tc + n_periods * p->cir_bytes_per_period;
 	te = m->te;
-	if (tc > m->cbs) {
-		te += (tc - m->cbs);
-		if (te > m->ebs)
-			te = m->ebs;
-		tc = m->cbs;
+	if (tc > p->cbs) {
+		te += (tc - p->cbs);
+		if (te > p->ebs)
+			te = p->ebs;
+		tc = p->cbs;
 	}
 
 	/* Color logic */
@@ -233,6 +307,7 @@ rte_meter_srtcm_color_blind_check(struct rte_meter_srtcm *m,
 
 static inline enum rte_meter_color
 rte_meter_srtcm_color_aware_check(struct rte_meter_srtcm *m,
+	struct rte_meter_srtcm_profile *p,
 	uint64_t time,
 	uint32_t pkt_len,
 	enum rte_meter_color pkt_color)
@@ -241,17 +316,17 @@ rte_meter_srtcm_color_aware_check(struct rte_meter_srtcm *m,
 
 	/* Bucket update */
 	time_diff = time - m->time;
-	n_periods = time_diff / m->cir_period;
-	m->time += n_periods * m->cir_period;
+	n_periods = time_diff / p->cir_period;
+	m->time += n_periods * p->cir_period;
 
 	/* Put the tokens overflowing from tc into te bucket */
-	tc = m->tc + n_periods * m->cir_bytes_per_period;
+	tc = m->tc + n_periods * p->cir_bytes_per_period;
 	te = m->te;
-	if (tc > m->cbs) {
-		te += (tc - m->cbs);
-		if (te > m->ebs)
-			te = m->ebs;
-		tc = m->cbs;
+	if (tc > p->cbs) {
+		te += (tc - p->cbs);
+		if (te > p->ebs)
+			te = p->ebs;
+		tc = p->cbs;
 	}
 
 	/* Color logic */
@@ -274,6 +349,7 @@ rte_meter_srtcm_color_aware_check(struct rte_meter_srtcm *m,
 
 static inline enum rte_meter_color
 rte_meter_trtcm_color_blind_check(struct rte_meter_trtcm *m,
+	struct rte_meter_trtcm_profile *p,
 	uint64_t time,
 	uint32_t pkt_len)
 {
@@ -282,18 +358,18 @@ rte_meter_trtcm_color_blind_check(struct rte_meter_trtcm *m,
 	/* Bucket update */
 	time_diff_tc = time - m->time_tc;
 	time_diff_tp = time - m->time_tp;
-	n_periods_tc = time_diff_tc / m->cir_period;
-	n_periods_tp = time_diff_tp / m->pir_period;
-	m->time_tc += n_periods_tc * m->cir_period;
-	m->time_tp += n_periods_tp * m->pir_period;
+	n_periods_tc = time_diff_tc / p->cir_period;
+	n_periods_tp = time_diff_tp / p->pir_period;
+	m->time_tc += n_periods_tc * p->cir_period;
+	m->time_tp += n_periods_tp * p->pir_period;
 
-	tc = m->tc + n_periods_tc * m->cir_bytes_per_period;
-	if (tc > m->cbs)
-		tc = m->cbs;
+	tc = m->tc + n_periods_tc * p->cir_bytes_per_period;
+	if (tc > p->cbs)
+		tc = p->cbs;
 
-	tp = m->tp + n_periods_tp * m->pir_bytes_per_period;
-	if (tp > m->pbs)
-		tp = m->pbs;
+	tp = m->tp + n_periods_tp * p->pir_bytes_per_period;
+	if (tp > p->pbs)
+		tp = p->pbs;
 
 	/* Color logic */
 	if (tp < pkt_len) {
@@ -315,6 +391,7 @@ rte_meter_trtcm_color_blind_check(struct rte_meter_trtcm *m,
 
 static inline enum rte_meter_color
 rte_meter_trtcm_color_aware_check(struct rte_meter_trtcm *m,
+	struct rte_meter_trtcm_profile *p,
 	uint64_t time,
 	uint32_t pkt_len,
 	enum rte_meter_color pkt_color)
@@ -324,18 +401,18 @@ rte_meter_trtcm_color_aware_check(struct rte_meter_trtcm *m,
 	/* Bucket update */
 	time_diff_tc = time - m->time_tc;
 	time_diff_tp = time - m->time_tp;
-	n_periods_tc = time_diff_tc / m->cir_period;
-	n_periods_tp = time_diff_tp / m->pir_period;
-	m->time_tc += n_periods_tc * m->cir_period;
-	m->time_tp += n_periods_tp * m->pir_period;
-
-	tc = m->tc + n_periods_tc * m->cir_bytes_per_period;
-	if (tc > m->cbs)
-		tc = m->cbs;
-
-	tp = m->tp + n_periods_tp * m->pir_bytes_per_period;
-	if (tp > m->pbs)
-		tp = m->pbs;
+	n_periods_tc = time_diff_tc / p->cir_period;
+	n_periods_tp = time_diff_tp / p->pir_period;
+	m->time_tc += n_periods_tc * p->cir_period;
+	m->time_tp += n_periods_tp * p->pir_period;
+
+	tc = m->tc + n_periods_tc * p->cir_bytes_per_period;
+	if (tc > p->cbs)
+		tc = p->cbs;
+
+	tp = m->tp + n_periods_tp * p->pir_bytes_per_period;
+	if (tp > p->pbs)
+		tp = p->pbs;
 
 	/* Color logic */
 	if ((pkt_color == e_RTE_METER_RED) || (tp < pkt_len)) {
diff --git a/lib/librte_meter/rte_meter_version.map b/lib/librte_meter/rte_meter_version.map
index 2fd647c..c4422ef 100644
--- a/lib/librte_meter/rte_meter_version.map
+++ b/lib/librte_meter/rte_meter_version.map
@@ -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;
diff --git a/test/test/test_meter.c b/test/test/test_meter.c
index 9f6abf9..8bb47e7 100644
--- a/test/test/test_meter.c
+++ b/test/test/test_meter.c
@@ -53,43 +53,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;
@@ -102,47 +102,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;
@@ -155,41 +155,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");
 
@@ -206,41 +215,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");
 
@@ -262,36 +280,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;
@@ -317,7 +344,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;
 
 	/**
@@ -329,7 +356,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;
 
 	/**
@@ -341,7 +368,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;
@@ -360,36 +387,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;
@@ -415,7 +451,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;
@@ -423,7 +459,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;
@@ -431,7 +467,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;
@@ -443,22 +479,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;
-- 
2.9.3



More information about the dev mailing list