* [dpdk-dev] [PATCH 0/4] meter: add meter configuration profile api
@ 2017-08-23 11:36 Cristian Dumitrescu
2017-08-23 11:36 ` [dpdk-dev] [PATCH 1/4] meter: add meter configuration profile Cristian Dumitrescu
` (4 more replies)
0 siblings, 5 replies; 18+ messages in thread
From: Cristian Dumitrescu @ 2017-08-23 11:36 UTC (permalink / raw)
To: dev; +Cc: thomas
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(-)
--
2.7.4
^ permalink raw reply [flat|nested] 18+ messages in thread
* [dpdk-dev] [PATCH 1/4] meter: add meter configuration profile
2017-08-23 11:36 [dpdk-dev] [PATCH 0/4] meter: add meter configuration profile api Cristian Dumitrescu
@ 2017-08-23 11:36 ` Cristian Dumitrescu
2017-12-12 9:53 ` [dpdk-dev] [PATCH v2 0/4] meter: add meter configuration profile api Jasvinder Singh
2017-08-23 11:36 ` [dpdk-dev] [PATCH 2/4] test: meter autotest update Cristian Dumitrescu
` (3 subsequent siblings)
4 siblings, 1 reply; 18+ messages in thread
From: Cristian Dumitrescu @ 2017-08-23 11:36 UTC (permalink / raw)
To: dev; +Cc: thomas
Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
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(-)
diff --git a/lib/librte_meter/rte_meter.c b/lib/librte_meter/rte_meter.c
index 5e2dadb..6f3fa59 100644
--- a/lib/librte_meter/rte_meter.c
+++ b/lib/librte_meter/rte_meter.c
@@ -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;
}
diff --git a/lib/librte_meter/rte_meter.h b/lib/librte_meter/rte_meter.h
index 2ab7184..c4bf9fd 100644
--- a/lib/librte_meter/rte_meter.h
+++ b/lib/librte_meter/rte_meter.h
@@ -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
@@ -82,6 +82,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;
@@ -89,38 +101,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
@@ -130,6 +170,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);
@@ -138,6 +179,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
@@ -149,6 +192,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);
@@ -158,6 +202,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
@@ -167,6 +213,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);
@@ -175,6 +222,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
@@ -186,6 +235,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);
@@ -195,23 +245,21 @@ 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 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 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 {
- 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 */
+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 */
@@ -220,8 +268,17 @@ struct rte_meter_trtcm {
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 */
+};
+
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)
{
@@ -229,17 +286,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 */
@@ -262,6 +319,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)
@@ -270,17 +328,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 */
@@ -303,6 +361,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)
{
@@ -311,18 +370,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) {
@@ -344,6 +403,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)
@@ -353,18 +413,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..8bc8190 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_17.11 {
+ global:
+
+ rte_meter_srtcm_profile_config;
+ rte_meter_trtcm_profile_config;
+
+} DPDK_2.0;
--
2.7.4
^ permalink raw reply [flat|nested] 18+ messages in thread
* [dpdk-dev] [PATCH 2/4] test: meter autotest update
2017-08-23 11:36 [dpdk-dev] [PATCH 0/4] meter: add meter configuration profile api Cristian Dumitrescu
2017-08-23 11:36 ` [dpdk-dev] [PATCH 1/4] meter: add meter configuration profile Cristian Dumitrescu
@ 2017-08-23 11:36 ` Cristian Dumitrescu
2017-08-23 11:36 ` [dpdk-dev] [PATCH 3/4] qos_meter: accommodate meter api changes Cristian Dumitrescu
` (2 subsequent siblings)
4 siblings, 0 replies; 18+ messages in thread
From: Cristian Dumitrescu @ 2017-08-23 11:36 UTC (permalink / raw)
To: dev; +Cc: thomas
Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
test/test/test_meter.c | 138 +++++++++++++++++++++++++++++++------------------
1 file changed, 87 insertions(+), 51 deletions(-)
diff --git a/test/test/test_meter.c b/test/test/test_meter.c
index 26b0565..b3232f6 100644
--- a/test/test/test_meter.c
+++ b/test/test/test_meter.c
@@ -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;
--
2.7.4
^ permalink raw reply [flat|nested] 18+ messages in thread
* [dpdk-dev] [PATCH 3/4] qos_meter: accommodate meter api changes
2017-08-23 11:36 [dpdk-dev] [PATCH 0/4] meter: add meter configuration profile api Cristian Dumitrescu
2017-08-23 11:36 ` [dpdk-dev] [PATCH 1/4] meter: add meter configuration profile Cristian Dumitrescu
2017-08-23 11:36 ` [dpdk-dev] [PATCH 2/4] test: meter autotest update Cristian Dumitrescu
@ 2017-08-23 11:36 ` Cristian Dumitrescu
2017-08-23 11:36 ` [dpdk-dev] [PATCH 4/4] deprecation: removed the librte_meter notice Cristian Dumitrescu
2017-10-12 20:51 ` [dpdk-dev] [PATCH 0/4] meter: add meter configuration profile api Thomas Monjalon
4 siblings, 0 replies; 18+ messages in thread
From: Cristian Dumitrescu @ 2017-08-23 11:36 UTC (permalink / raw)
To: dev; +Cc: thomas
Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
examples/qos_meter/main.c | 36 +++++++++++++++++++++++++-----------
examples/qos_meter/main.h | 32 ++++++++++++++++++++------------
2 files changed, 45 insertions(+), 23 deletions(-)
diff --git a/examples/qos_meter/main.c b/examples/qos_meter/main.c
index b0909f6..420ec5a 100644
--- a/examples/qos_meter/main.c
+++ b/examples/qos_meter/main.c
@@ -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 */
diff --git a/examples/qos_meter/main.h b/examples/qos_meter/main.h
index 54867dc..bff97a4 100644
--- a/examples/qos_meter/main.h
+++ b/examples/qos_meter/main.h
@@ -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_ */
--
2.7.4
^ permalink raw reply [flat|nested] 18+ messages in thread
* [dpdk-dev] [PATCH 4/4] deprecation: removed the librte_meter notice
2017-08-23 11:36 [dpdk-dev] [PATCH 0/4] meter: add meter configuration profile api Cristian Dumitrescu
` (2 preceding siblings ...)
2017-08-23 11:36 ` [dpdk-dev] [PATCH 3/4] qos_meter: accommodate meter api changes Cristian Dumitrescu
@ 2017-08-23 11:36 ` Cristian Dumitrescu
2017-10-12 20:51 ` [dpdk-dev] [PATCH 0/4] meter: add meter configuration profile api Thomas Monjalon
4 siblings, 0 replies; 18+ messages in thread
From: Cristian Dumitrescu @ 2017-08-23 11:36 UTC (permalink / raw)
To: dev; +Cc: thomas
Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
doc/guides/rel_notes/deprecation.rst | 3 ---
1 file changed, 3 deletions(-)
diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index 3362f33..11a9d09 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -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
--
2.7.4
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [dpdk-dev] [PATCH 0/4] meter: add meter configuration profile api
2017-08-23 11:36 [dpdk-dev] [PATCH 0/4] meter: add meter configuration profile api Cristian Dumitrescu
` (3 preceding siblings ...)
2017-08-23 11:36 ` [dpdk-dev] [PATCH 4/4] deprecation: removed the librte_meter notice Cristian Dumitrescu
@ 2017-10-12 20:51 ` Thomas Monjalon
4 siblings, 0 replies; 18+ messages in thread
From: Thomas Monjalon @ 2017-10-12 20:51 UTC (permalink / raw)
To: Cristian Dumitrescu; +Cc: dev
> 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(-)
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.
^ permalink raw reply [flat|nested] 18+ messages in thread
* [dpdk-dev] [PATCH v2 0/4] meter: add meter configuration profile api
2017-08-23 11:36 ` [dpdk-dev] [PATCH 1/4] meter: add meter configuration profile Cristian Dumitrescu
@ 2017-12-12 9:53 ` Jasvinder Singh
2017-12-12 9:53 ` [dpdk-dev] [PATCH v2 1/4] lib/librte_meter: add meter configuration profile Jasvinder Singh
` (3 more replies)
0 siblings, 4 replies; 18+ messages in thread
From: Jasvinder Singh @ 2017-12-12 9:53 UTC (permalink / raw)
To: dev; +Cc: cristian.dumitrescu
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(-)
--
2.9.3
^ permalink raw reply [flat|nested] 18+ messages in thread
* [dpdk-dev] [PATCH v2 1/4] lib/librte_meter: add meter configuration profile
2017-12-12 9:53 ` [dpdk-dev] [PATCH v2 0/4] meter: add meter configuration profile api Jasvinder Singh
@ 2017-12-12 9:53 ` Jasvinder Singh
2018-01-08 10:00 ` [dpdk-dev] [PATCH v3] meter: add meter configuration profile api Jasvinder Singh
2017-12-12 9:53 ` [dpdk-dev] [PATCH v2 2/4] test/test_meter: update meter test Jasvinder Singh
` (2 subsequent siblings)
3 siblings, 1 reply; 18+ messages in thread
From: Jasvinder Singh @ 2017-12-12 9:53 UTC (permalink / raw)
To: dev; +Cc: cristian.dumitrescu
From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
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.
Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
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(-)
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/lib/librte_meter/Makefile b/lib/librte_meter/Makefile
index bfeb5d6..d05fe39 100644
--- a/lib/librte_meter/Makefile
+++ b/lib/librte_meter/Makefile
@@ -44,7 +44,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 5e2dadb..9db7a4a 100644
--- a/lib/librte_meter/rte_meter.c
+++ b/lib/librte_meter/rte_meter.c
@@ -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,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 2ab7184..38994c3 100644
--- a/lib/librte_meter/rte_meter.h
+++ b/lib/librte_meter/rte_meter.h
@@ -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
@@ -82,6 +82,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;
@@ -89,38 +101,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
@@ -130,6 +170,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);
@@ -138,6 +179,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
@@ -149,6 +192,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);
@@ -158,6 +202,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
@@ -167,6 +213,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);
@@ -175,6 +222,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
@@ -186,6 +235,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);
@@ -195,33 +245,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)
{
@@ -229,17 +303,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 */
@@ -262,6 +336,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)
@@ -270,17 +345,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 */
@@ -303,6 +378,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)
{
@@ -311,18 +387,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) {
@@ -344,6 +420,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)
@@ -353,18 +430,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;
--
2.9.3
^ permalink raw reply [flat|nested] 18+ messages in thread
* [dpdk-dev] [PATCH v2 2/4] test/test_meter: update meter test
2017-12-12 9:53 ` [dpdk-dev] [PATCH v2 0/4] meter: add meter configuration profile api Jasvinder Singh
2017-12-12 9:53 ` [dpdk-dev] [PATCH v2 1/4] lib/librte_meter: add meter configuration profile Jasvinder Singh
@ 2017-12-12 9:53 ` Jasvinder Singh
2017-12-12 9:53 ` [dpdk-dev] [PATCH v2 3/4] examples/qos_meter: accommodate meter api changes Jasvinder Singh
2017-12-12 9:53 ` [dpdk-dev] [PATCH v2 4/4] examples/ip_pipeline: update flow action pipeline Jasvinder Singh
3 siblings, 0 replies; 18+ messages in thread
From: Jasvinder Singh @ 2017-12-12 9:53 UTC (permalink / raw)
To: dev; +Cc: cristian.dumitrescu
From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Modify the unit test to accomodate the changes in the apis.
Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
test/test/test_meter.c | 194 +++++++++++++++++++++++++++++--------------------
1 file changed, 115 insertions(+), 79 deletions(-)
diff --git a/test/test/test_meter.c b/test/test/test_meter.c
index 26b0565..b6d133a 100644
--- a/test/test/test_meter.c
+++ b/test/test/test_meter.c
@@ -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;
--
2.9.3
^ permalink raw reply [flat|nested] 18+ messages in thread
* [dpdk-dev] [PATCH v2 3/4] examples/qos_meter: accommodate meter api changes
2017-12-12 9:53 ` [dpdk-dev] [PATCH v2 0/4] meter: add meter configuration profile api Jasvinder Singh
2017-12-12 9:53 ` [dpdk-dev] [PATCH v2 1/4] lib/librte_meter: add meter configuration profile Jasvinder Singh
2017-12-12 9:53 ` [dpdk-dev] [PATCH v2 2/4] test/test_meter: update meter test Jasvinder Singh
@ 2017-12-12 9:53 ` Jasvinder Singh
2017-12-12 9:53 ` [dpdk-dev] [PATCH v2 4/4] examples/ip_pipeline: update flow action pipeline Jasvinder Singh
3 siblings, 0 replies; 18+ messages in thread
From: Jasvinder Singh @ 2017-12-12 9:53 UTC (permalink / raw)
To: dev; +Cc: cristian.dumitrescu
From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Modify the sample application to adapt the api changes.
Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
examples/qos_meter/main.c | 39 ++++++++++++++++++++++++++++++---------
examples/qos_meter/main.h | 32 ++++++++++++++++++++------------
2 files changed, 50 insertions(+), 21 deletions(-)
diff --git a/examples/qos_meter/main.c b/examples/qos_meter/main.c
index 67b4a75..23908f0 100644
--- a/examples/qos_meter/main.c
+++ b/examples/qos_meter/main.c
@@ -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 */
diff --git a/examples/qos_meter/main.h b/examples/qos_meter/main.h
index 54867dc..bff97a4 100644
--- a/examples/qos_meter/main.h
+++ b/examples/qos_meter/main.h
@@ -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_ */
--
2.9.3
^ permalink raw reply [flat|nested] 18+ messages in thread
* [dpdk-dev] [PATCH v2 4/4] examples/ip_pipeline: update flow action pipeline
2017-12-12 9:53 ` [dpdk-dev] [PATCH v2 0/4] meter: add meter configuration profile api Jasvinder Singh
` (2 preceding siblings ...)
2017-12-12 9:53 ` [dpdk-dev] [PATCH v2 3/4] examples/qos_meter: accommodate meter api changes Jasvinder Singh
@ 2017-12-12 9:53 ` Jasvinder Singh
3 siblings, 0 replies; 18+ messages in thread
From: Jasvinder Singh @ 2017-12-12 9:53 UTC (permalink / raw)
To: dev; +Cc: cristian.dumitrescu
Update flow action pipeline to conform the meter api changes.
Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
---
.../pipeline/pipeline_flow_actions_be.c | 25 +++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_actions_be.c b/examples/ip_pipeline/pipeline/pipeline_flow_actions_be.c
index 11fcbb7..8874f04 100644
--- a/examples/ip_pipeline/pipeline/pipeline_flow_actions_be.c
+++ b/examples/ip_pipeline/pipeline/pipeline_flow_actions_be.c
@@ -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 = ¶ms->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);
--
2.9.3
^ permalink raw reply [flat|nested] 18+ messages in thread
* [dpdk-dev] [PATCH v3] meter: add meter configuration profile api
2017-12-12 9:53 ` [dpdk-dev] [PATCH v2 1/4] lib/librte_meter: add meter configuration profile Jasvinder Singh
@ 2018-01-08 10:00 ` Jasvinder Singh
2018-01-08 10:00 ` [dpdk-dev] [PATCH v3] lib/librte_meter: add meter configuration profile Jasvinder Singh
0 siblings, 1 reply; 18+ messages in thread
From: Jasvinder Singh @ 2018-01-08 10:00 UTC (permalink / raw)
To: dev; +Cc: cristian.dumitrescu
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(-)
--
2.9.3
^ permalink raw reply [flat|nested] 18+ messages in thread
* [dpdk-dev] [PATCH v3] lib/librte_meter: add meter configuration profile
2018-01-08 10:00 ` [dpdk-dev] [PATCH v3] meter: add meter configuration profile api Jasvinder Singh
@ 2018-01-08 10:00 ` Jasvinder Singh
2018-01-08 15:43 ` [dpdk-dev] [PATCH v4] " Jasvinder Singh
0 siblings, 1 reply; 18+ messages in thread
From: Jasvinder Singh @ 2018-01-08 10:00 UTC (permalink / raw)
To: dev; +Cc: cristian.dumitrescu
From: Cristian Dumitrescu <cristian.dumitrescu@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@intel.com>
Signed-off-by: Jasvinder Singh <jasvinder.singh@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 = ¶ms->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
^ permalink raw reply [flat|nested] 18+ messages in thread
* [dpdk-dev] [PATCH v4] lib/librte_meter: add meter configuration profile
2018-01-08 10:00 ` [dpdk-dev] [PATCH v3] lib/librte_meter: add meter configuration profile Jasvinder Singh
@ 2018-01-08 15:43 ` Jasvinder Singh
2018-01-11 13:54 ` Dumitrescu, Cristian
2018-02-19 21:12 ` Thomas Monjalon
0 siblings, 2 replies; 18+ messages in thread
From: Jasvinder Singh @ 2018-01-08 15:43 UTC (permalink / raw)
To: dev; +Cc: cristian.dumitrescu
From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
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%.
Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
---
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(-)
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 = ¶ms->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
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [dpdk-dev] [PATCH v4] lib/librte_meter: add meter configuration profile
2018-01-08 15:43 ` [dpdk-dev] [PATCH v4] " Jasvinder Singh
@ 2018-01-11 13:54 ` Dumitrescu, Cristian
2018-02-19 21:12 ` Thomas Monjalon
1 sibling, 0 replies; 18+ messages in thread
From: Dumitrescu, Cristian @ 2018-01-11 13:54 UTC (permalink / raw)
To: Singh, Jasvinder, dev
> -----Original Message-----
> From: Singh, Jasvinder
> Sent: Monday, January 8, 2018 3:44 PM
> To: dev@dpdk.org
> Cc: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>
> Subject: [PATCH v4] lib/librte_meter: add meter configuration profile
>
> From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
>
> This patch adds support for meter configuration profiles.
> Benefits: simplified configuration procedure, improved performance.
>
...<snip>
>
> Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
> ---
> V4:
> - change commit message
>
Applied to next-qos tree.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [dpdk-dev] [PATCH v4] lib/librte_meter: add meter configuration profile
2018-01-08 15:43 ` [dpdk-dev] [PATCH v4] " Jasvinder Singh
2018-01-11 13:54 ` Dumitrescu, Cristian
@ 2018-02-19 21:12 ` Thomas Monjalon
2018-04-05 10:12 ` Thomas Monjalon
1 sibling, 1 reply; 18+ messages in thread
From: Thomas Monjalon @ 2018-02-19 21:12 UTC (permalink / raw)
To: Jasvinder Singh, cristian.dumitrescu; +Cc: dev
08/01/2018 16:43, Jasvinder Singh:
> From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
>
> 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%.
>
> Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
Applied for 18.05 (was postponed to preserve 18.02 ABI), thanks.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [dpdk-dev] [PATCH v4] lib/librte_meter: add meter configuration profile
2018-02-19 21:12 ` Thomas Monjalon
@ 2018-04-05 10:12 ` Thomas Monjalon
2018-04-05 11:00 ` Dumitrescu, Cristian
0 siblings, 1 reply; 18+ messages in thread
From: Thomas Monjalon @ 2018-04-05 10:12 UTC (permalink / raw)
To: Jasvinder Singh, cristian.dumitrescu; +Cc: dev
19/02/2018 22:12, Thomas Monjalon:
> 08/01/2018 16:43, Jasvinder Singh:
> > Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> > Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
>
> 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
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [dpdk-dev] [PATCH v4] lib/librte_meter: add meter configuration profile
2018-04-05 10:12 ` Thomas Monjalon
@ 2018-04-05 11:00 ` Dumitrescu, Cristian
0 siblings, 0 replies; 18+ messages in thread
From: Dumitrescu, Cristian @ 2018-04-05 11:00 UTC (permalink / raw)
To: Thomas Monjalon, Singh, Jasvinder; +Cc: dev
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas@monjalon.net]
> Sent: Thursday, April 5, 2018 11:12 AM
> To: Singh, Jasvinder <jasvinder.singh@intel.com>; Dumitrescu, Cristian
> <cristian.dumitrescu@intel.com>
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v4] lib/librte_meter: add meter
> configuration profile
>
> 19/02/2018 22:12, Thomas Monjalon:
> > 08/01/2018 16:43, Jasvinder Singh:
> > > Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> > > Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
> >
> > 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!
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2018-04-05 11:00 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-23 11:36 [dpdk-dev] [PATCH 0/4] meter: add meter configuration profile api Cristian Dumitrescu
2017-08-23 11:36 ` [dpdk-dev] [PATCH 1/4] meter: add meter configuration profile Cristian Dumitrescu
2017-12-12 9:53 ` [dpdk-dev] [PATCH v2 0/4] meter: add meter configuration profile api Jasvinder Singh
2017-12-12 9:53 ` [dpdk-dev] [PATCH v2 1/4] lib/librte_meter: add meter configuration profile Jasvinder Singh
2018-01-08 10:00 ` [dpdk-dev] [PATCH v3] meter: add meter configuration profile api Jasvinder Singh
2018-01-08 10:00 ` [dpdk-dev] [PATCH v3] lib/librte_meter: add meter configuration profile Jasvinder Singh
2018-01-08 15:43 ` [dpdk-dev] [PATCH v4] " Jasvinder Singh
2018-01-11 13:54 ` Dumitrescu, Cristian
2018-02-19 21:12 ` Thomas Monjalon
2018-04-05 10:12 ` Thomas Monjalon
2018-04-05 11:00 ` Dumitrescu, Cristian
2017-12-12 9:53 ` [dpdk-dev] [PATCH v2 2/4] test/test_meter: update meter test Jasvinder Singh
2017-12-12 9:53 ` [dpdk-dev] [PATCH v2 3/4] examples/qos_meter: accommodate meter api changes Jasvinder Singh
2017-12-12 9:53 ` [dpdk-dev] [PATCH v2 4/4] examples/ip_pipeline: update flow action pipeline Jasvinder Singh
2017-08-23 11:36 ` [dpdk-dev] [PATCH 2/4] test: meter autotest update Cristian Dumitrescu
2017-08-23 11:36 ` [dpdk-dev] [PATCH 3/4] qos_meter: accommodate meter api changes Cristian Dumitrescu
2017-08-23 11:36 ` [dpdk-dev] [PATCH 4/4] deprecation: removed the librte_meter notice Cristian Dumitrescu
2017-10-12 20:51 ` [dpdk-dev] [PATCH 0/4] meter: add meter configuration profile api Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).