From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nikhil Jagtap Subject: [PATCH v2] meter: fix excess token bucket update in srtcm implementation Date: Wed, 21 Sep 2016 00:57:42 -0500 Message-ID: <1474437462-6955-1-git-send-email-nikhil.jagtap@gmail.com> References: <1473228910-10429-1-git-send-email-nikhil.jagtap@gmail.com> Cc: dev@dpdk.org, kannan.babu.ramia@intel.com, Nikhil Jagtap To: cristian.dumitrescu@intel.com Return-path: Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by dpdk.org (Postfix) with ESMTP id 0CE6637B2 for ; Wed, 21 Sep 2016 07:58:51 +0200 (CEST) Received: by mail-pf0-f193.google.com with SMTP id n24so1900528pfb.3 for ; Tue, 20 Sep 2016 22:58:50 -0700 (PDT) In-Reply-To: <1473228910-10429-1-git-send-email-nikhil.jagtap@gmail.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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