From mboxrd@z Thu Jan 1 00:00:00 1970 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=woa5KfrHPhV84mfN9WQcS5myrb5WELgVViIu6VCuOH4=; b=EWFbICBcoHhyFZfk9P1uD377PeoP0awgb16tUBduogaH/GhggypSvZtPx4bSOzzNjJ tnh6xYQKuGbioFxT8kXzkBfMHq01r4QJHJZij8AxOTI9/6UMUCj66l1XhMHPyVGbXzXP jG+4uVptaFuG5p4hfNQHiXX6JkdmZm1RPTZXC/p1nIjGUYydZZ6Ac80qtkJCkw30Bol9 pL45JlW0QEqM0BYJ5X65vIEtTszXQNL9YK5xZ5fjJttRN/bAVSrbfduoFIYg7QQym0eg ElcuTn2zfz/gSrRozfU0Exz+GI0gl1Cyc8G5nLO+DuTCydkF3sw0HDTy1vCcZ/fgkxT/ 448Q== 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:in-reply-to :references; bh=woa5KfrHPhV84mfN9WQcS5myrb5WELgVViIu6VCuOH4=; b=h+2Ou06ey7vZFOm5lnib6i9nhudj8jscWzf3/i670h9JKlvqdOHHFVIMgiQzDb4XAY vQSxWWR8BP8awmOk9AWp+UTVQr44GVF6EE2QBYsQuImw/wsaPnoWZ/Uz+FekNIg8jjnc mxgN500gKFvQTDrQ5GSIlLTiVomIhmfEgNPGpElG4BxmBDbRE824B5DzI0yU9DBHFr7C g+ykLCz/FcnVr9g9J+BSD2mwprYeRg6UHYzQ7sZ/nyXv1Z79W4lIJX9hI77UBuWXkKaq Tznzhnjr6TytM48Bt4WHI8NhLz1tz9rhXwQBs44ZN9uu7HPMT5YrR4KO0cMMz2+q9OXv fgOA== X-Gm-Message-State: AE9vXwNm7ybwZ/ny1ajb2w2Xdo12JM67Aun5nMu99uPwa8VKTjR4BvrK1uklh461OtQ0CQ== X-Received: by 10.98.153.202 with SMTP id t71mr61536272pfk.114.1474437530352; Tue, 20 Sep 2016 22:58:50 -0700 (PDT) Received: from localhost.localdomain ([14.141.235.254]) by smtp.gmail.com with ESMTPSA id x66sm83114321pfb.86.2016.09.20.22.58.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Sep 2016 22:58:49 -0700 (PDT) From: Nikhil Jagtap To: cristian.dumitrescu@intel.com Cc: dev@dpdk.org, kannan.babu.ramia@intel.com, Nikhil Jagtap Date: Wed, 21 Sep 2016 00:57:42 -0500 Message-Id: <1474437462-6955-1-git-send-email-nikhil.jagtap@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1473228910-10429-1-git-send-email-nikhil.jagtap@gmail.com> References: <1473228910-10429-1-git-send-email-nikhil.jagtap@gmail.com> Subject: [dpdk-dev] [PATCH v2] 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, 21 Sep 2016 05:58:51 -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 --- 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