aboutsummaryrefslogtreecommitdiffstats
path: root/lib/librte_meter/rte_meter.h
diff options
context:
space:
mode:
authorChristian Ehrhardt <christian.ehrhardt@canonical.com>2016-12-08 14:07:29 +0100
committerChristian Ehrhardt <christian.ehrhardt@canonical.com>2016-12-12 15:41:56 +0100
commit3d9b72106bd664b1267533e7278ff817f942e3c6 (patch)
tree52a6964f40e029d55d73bc18208971eff2297891 /lib/librte_meter/rte_meter.h
parenta83862b166241910d0474f801cb2e6afa4c6875b (diff)
Imported Upstream version 16.11
Change-Id: I1944c65ddc88a9ad70f8c0eb6731552b84fbcb77 Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Diffstat (limited to 'lib/librte_meter/rte_meter.h')
-rw-r--r--lib/librte_meter/rte_meter.h24
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/librte_meter/rte_meter.h b/lib/librte_meter/rte_meter.h
index 2cd8d814..2ab71849 100644
--- a/lib/librte_meter/rte_meter.h
+++ b/lib/librte_meter/rte_meter.h
@@ -232,13 +232,15 @@ rte_meter_srtcm_color_blind_check(struct rte_meter_srtcm *m,
n_periods = time_diff / m->cir_period;
m->time += n_periods * m->cir_period;
+ /* Put the tokens overflowing from tc into te bucket */
tc = m->tc + n_periods * m->cir_bytes_per_period;
- if (tc > m->cbs)
+ te = m->te;
+ if (tc > m->cbs) {
+ te += (tc - m->cbs);
+ if (te > m->ebs)
+ te = m->ebs;
tc = m->cbs;
-
- te = m->te + n_periods * m->cir_bytes_per_period;
- if (te > m->ebs)
- te = m->ebs;
+ }
/* Color logic */
if (tc >= pkt_len) {
@@ -271,13 +273,15 @@ rte_meter_srtcm_color_aware_check(struct rte_meter_srtcm *m,
n_periods = time_diff / m->cir_period;
m->time += n_periods * m->cir_period;
+ /* Put the tokens overflowing from tc into te bucket */
tc = m->tc + n_periods * m->cir_bytes_per_period;
- if (tc > m->cbs)
+ te = m->te;
+ if (tc > m->cbs) {
+ te += (tc - m->cbs);
+ if (te > m->ebs)
+ te = m->ebs;
tc = m->cbs;
-
- te = m->te + n_periods * m->cir_bytes_per_period;
- if (te > m->ebs)
- te = m->ebs;
+ }
/* Color logic */
if ((pkt_color == e_RTE_METER_GREEN) && (tc >= pkt_len)) {