From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by dpdk.org (Postfix) with ESMTP id D34587F70 for ; Wed, 7 Sep 2016 08:15:51 +0200 (CEST) Received: by mail-pf0-f196.google.com with SMTP id x24so398410pfa.3 for ; Tue, 06 Sep 2016 23:15:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=6P12/vHFTc1c1xqoAiR/wtnvFLcRtDjWdGbEoCPyzyg=; b=iIsnhsybQxpxSCqswi+rY1GRU+yfOaSKkHruZPfptCslJOh3OeGnHGfVc7jen1CxvB DmDd26COCumfdIxCVv6URmGk6mxYsFbqkbK8PFCnb+X5dN2hBfbjlIctdnLZ+wzNKzc3 oIgmI7SbO9uC6sBIn6U3e+uVmDky65lZjrSAEA5LYZAmCESe4ZWrVqg2XM77DjGHFWN6 lO2PrYA9w6fet9EkEobYy/7V4eWlTlBIE8N8i4OEC8oJ4tCbhFmIjmATgIVSfkuzqccB kEVw8kwWDHtSSkOHwy1gIxLeganN7ztAp3lhTkoI18KuB2He6P4wpBKSiuSgMPvPaeQ4 DtzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=6P12/vHFTc1c1xqoAiR/wtnvFLcRtDjWdGbEoCPyzyg=; b=TOrplaNC8xu7Dq4+jlTupvV9qlHfEI0T7QLzuug39XJoqVSwAtHg/B7cLav4bsA0Ha j0xn0eChTtBQ0VDRG8/6j8Mj4P5zZtyNBNS7rXn1+ysgumlFGYK56iPfmwijpz7df/O/ d/T/542qhF379mP424fYcppHVAfWSRXGiMzYFmIjOi7J4VmBQ1tfswbdaQc1GQf3RNlV /i6KxHpvtQHXyj0nzJDiLsMPc9hNm8kID1gSwBNAJ6mKxljz45OeMKdYywBbUUwRvgou wka3OOv0ndsj3usrBp5hKD5aEXdF33dqygnQWXO9VR35Cdp08jY0533OBTCY51elhCO0 +bmQ== X-Gm-Message-State: AE9vXwPCT1k2FU048sq/8hsDbMZU050rdj02YJvUe9U3atqJDRV6z3/K79FjaYA7oTWe/w== X-Received: by 10.98.57.151 with SMTP id u23mr79463486pfj.4.1473228951215; Tue, 06 Sep 2016 23:15:51 -0700 (PDT) Received: from localhost.localdomain ([14.141.235.254]) by smtp.gmail.com with ESMTPSA id az10sm40833861pab.5.2016.09.06.23.15.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Sep 2016 23:15:50 -0700 (PDT) From: Nikhil Jagtap To: cristian.dumitrescu@intel.com Cc: dev@dpdk.org, kannan.babu.ramia@intel.com, Nikhil Jagtap Date: Wed, 7 Sep 2016 01:15:10 -0500 Message-Id: <1473228910-10429-1-git-send-email-nikhil.jagtap@gmail.com> X-Mailer: git-send-email 1.7.1 Subject: [dpdk-dev] [PATCH] meter: fix excess token bucket update in srtcm implementation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Sep 2016 06:15:52 -0000 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 --- lib/librte_meter/rte_meter.h | 26 ++++++++++++++++---------- 1 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/librte_meter/rte_meter.h b/lib/librte_meter/rte_meter.h index 2cd8d81..0ffcb60 100644 --- a/lib/librte_meter/rte_meter.h +++ b/lib/librte_meter/rte_meter.h @@ -232,13 +232,16 @@ 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) + if (tc > m->cbs) { + te = m->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; + } else { + te = m->te; + } /* Color logic */ if (tc >= pkt_len) { @@ -271,13 +274,16 @@ 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) + if (tc > m->cbs) { + te = m->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; + } else { + te = m->te; + } /* Color logic */ if ((pkt_color == e_RTE_METER_GREEN) && (tc >= pkt_len)) { -- 1.7.1