meter: add configuration profile
authorCristian Dumitrescu <cristian.dumitrescu@intel.com>
Mon, 8 Jan 2018 15:43:56 +0000 (15:43 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 19 Feb 2018 21:28:05 +0000 (22:28 +0100)
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 dependent): 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%.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
12 files changed:
doc/guides/rel_notes/deprecation.rst
doc/guides/rel_notes/release_18_05.rst
examples/ip_pipeline/Makefile
examples/ip_pipeline/pipeline/pipeline_flow_actions_be.c
examples/qos_meter/Makefile
examples/qos_meter/main.c
examples/qos_meter/main.h
lib/librte_meter/Makefile
lib/librte_meter/rte_meter.c
lib/librte_meter/rte_meter.h
lib/librte_meter/rte_meter_version.map
test/test/test_meter.c

index 9b55761..74c18ed 100644 (file)
@@ -165,9 +165,6 @@ Deprecation Notices
   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.
-
 * ring: The alignment constraints on the ring structure will be relaxed
   to one cache line instead of two, and an empty cache line padding will
   be added between the producer and consumer structures. The size of the
index 85f4dc5..3923dc2 100644 (file)
@@ -142,7 +142,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
index 27f7cc6..85fbbaf 100644 (file)
@@ -48,6 +48,7 @@ LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
 VPATH += pipeline
 CFLAGS += -I. -I./pipeline/
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 OBJS := $(patsubst %.c,build/%.o,$(SRCS-y))
 
@@ -88,6 +89,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) := $(SRCS-y)
 CFLAGS += -I$(SRCDIR) -I$(SRCDIR)/pipeline
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS) -Wno-error=unused-function -Wno-error=unused-variable
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 include $(RTE_SDK)/mk/rte.extapp.mk
 
index 9599b7d..33f1c41 100644 (file)
@@ -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);
index 69ac661..6da2407 100644 (file)
@@ -23,6 +23,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
        $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -48,6 +50,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 
index f0f9bca..42cf4b2 100644 (file)
@@ -90,14 +90,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];
@@ -105,12 +114,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;
        }
@@ -135,7 +153,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 */
index b27e8eb..f51eb66 100644 (file)
@@ -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_ */
index 3b80c6a..2dc071e 100644 (file)
@@ -16,7 +16,7 @@ LDLIBS += -lrte_eal
 
 EXPORT_MAP := rte_meter_version.map
 
-LIBABIVER := 1
+LIBABIVER := 2
 
 #
 # all source are stored in SRCS-y
index 332c519..59af5ef 100644 (file)
@@ -30,62 +30,83 @@ 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)
+int __rte_experimental
+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)
+int __rte_experimental
+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;
 }
index ebdc453..03d8056 100644 (file)
@@ -20,6 +20,7 @@ extern "C" {
  ***/
 
 #include <stdint.h>
+#include <rte_compat.h>
 
 /*
  * Application Programmer's Interface (API)
@@ -53,45 +54,87 @@ 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;
 
 /** Internal data structure storing the trTCM run-time context per metered traffic flow. */
 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_experimental
+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_experimental
+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 +144,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 +153,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 +166,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 +176,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 +187,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 +196,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 +209,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 +219,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 +277,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 +310,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 +319,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 +352,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 +361,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 +394,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 +404,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)) {
index 2fd647c..391b80c 100644 (file)
@@ -10,3 +10,11 @@ DPDK_2.0 {
 
        local: *;
 };
+
+EXPERIMENTAL {
+       global:
+
+       rte_meter_srtcm_profile_config;
+       rte_meter_trtcm_profile_config;
+
+} DPDK_2.0;
index 9f6abf9..8bb47e7 100644 (file)
@@ -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;