summaryrefslogtreecommitdiff
path: root/lib/librte_meter
diff options
context:
space:
mode:
authorNikhil Jagtap <nikhil.jagtap@gmail.com>2016-09-21 00:57:42 -0500
committerThomas Monjalon <thomas.monjalon@6wind.com>2016-09-21 22:56:03 +0200
commita15b29ebe69a59de1dc03a55e1d002056781f7d3 (patch)
tree8fefc9d9c1a6029f6d4a0117eeb82d8b04df4d03 /lib/librte_meter
parent8451269e6d7ba7501723fe2efd05745010295bac (diff)
downloaddpdk-a15b29ebe69a59de1dc03a55e1d002056781f7d3.zip
dpdk-a15b29ebe69a59de1dc03a55e1d002056781f7d3.tar.gz
dpdk-a15b29ebe69a59de1dc03a55e1d002056781f7d3.tar.xz
meter: fix excess token bucket update in srtcm
As per srTCM RFC 2697, we should be updating the E bucket only after the C bucket overflows. This patch fixes the current DPDK implementation, where we are updating both the buckets simultaneously at the same rate (CIR) which results in token accumulation rate of (2*CIR). Signed-off-by: Nikhil Jagtap <nikhil.jagtap@gmail.com> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Diffstat (limited to 'lib/librte_meter')
-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 2cd8d81..2ab7184 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)) {