DPDK patches and discussions
 help / color / mirror / Atom feed
From: Nikhil Jagtap <nikhil.jagtap@gmail.com>
To: cristian.dumitrescu@intel.com
Cc: dev@dpdk.org, kannan.babu.ramia@intel.com,
	Nikhil Jagtap <nikhil.jagtap@gmail.com>
Subject: [dpdk-dev] [PATCH v2] meter: fix excess token bucket update in srtcm implementation
Date: Wed, 21 Sep 2016 00:57:42 -0500	[thread overview]
Message-ID: <1474437462-6955-1-git-send-email-nikhil.jagtap@gmail.com> (raw)
In-Reply-To: <1473228910-10429-1-git-send-email-nikhil.jagtap@gmail.com>

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>
---

v2:
Removed the else part and instead added a default initialization of te.

---
 lib/librte_meter/rte_meter.h |   24 ++++++++++++++----------
 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)) {
-- 
1.7.1

  parent reply	other threads:[~2016-09-21  5:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-07  6:15 [dpdk-dev] [PATCH] " Nikhil Jagtap
2016-09-19 15:51 ` Dumitrescu, Cristian
2016-09-20  4:40   ` Nikhil Jagtap
2016-09-21  5:57 ` Nikhil Jagtap [this message]
2016-09-21  8:57   ` [dpdk-dev] [PATCH v2] " Dumitrescu, Cristian
2016-09-21 21:19     ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1474437462-6955-1-git-send-email-nikhil.jagtap@gmail.com \
    --to=nikhil.jagtap@gmail.com \
    --cc=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    --cc=kannan.babu.ramia@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).