From patchwork Sat May 23 10:33:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 1296676 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=PxyqmsCS; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Tfq24v5Vz9sPK for ; Sat, 23 May 2020 20:34:06 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 10E1625D72; Sat, 23 May 2020 10:34:05 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VfTJMDx8C4wa; Sat, 23 May 2020 10:33:55 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 7147A25F87; Sat, 23 May 2020 10:33:50 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 39548C0178; Sat, 23 May 2020 10:33:50 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 244EEC0178 for ; Sat, 23 May 2020 10:33:48 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 12E74886FC for ; Sat, 23 May 2020 10:33:48 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jGpm43UATn5m for ; Sat, 23 May 2020 10:33:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by hemlock.osuosl.org (Postfix) with ESMTPS id C068A886EF for ; Sat, 23 May 2020 10:33:42 +0000 (UTC) Received: by mail-pj1-f66.google.com with SMTP id a5so6091764pjh.2 for ; Sat, 23 May 2020 03:33:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OUhjytkFi88OuVRNsplXLEQwNR7Tc9ubPqcokAsZvoY=; b=PxyqmsCScVaW5wj2jK+4ElGjPeyvgy9xYodSXVhLZ0BoWCnLaY281IMHBW2Lczx17P sJrLrWacWVI/c5KSpIA+aQaLoJCiLjo80WjoddE0Kodna0IxFQCJIwc1CElFmUfrDb72 i9CNo3oG0RuHuH/+KVSE/oYY2acAEifMA1MvCzXqI9A3eV6J0JRVtPKiKlI01uDpvxWb R+P8fdrtRPpo0dcZXBmrfL/RpoloAyJLCU/wX0KwHjc11MYBXwe2zU/BZ3Kllvk+WxXU 0yecIpbD0OSUWLsz3DqJmjIIiTvNK4tnAjMPXNmVyo6bzFFjpU4yv3tRfyr3HYG+3FqG Lyog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OUhjytkFi88OuVRNsplXLEQwNR7Tc9ubPqcokAsZvoY=; b=Qsh3W0t/xi3vCKpKM81zoyuXuUDeV+yinQYakQrS4kSurtAAtfYT43mMpu7va0LyMs woSHwfLhL78GeeNvrrCIE1dM0GvURDYSMQ42ozP69m29oXHG1umNf1QIo7GUIsYlR26R k/EpebPIQbPOUXuqaeO4SpiCs1wu0dUH9pEJyUVhDBDNPe94Wm0bHDpMyUVi3Zsfh1pl DFine0ELJ7veK0pQdPruzjmffwsaIRfYyRVH2WzL2/YgRc5iYVwrmObER7p4Nnl+jJt8 zWL4LoeT3gqeRDuyo5odKP5N5W9L8xXFWG62DfFfh6m1zGsJnjlA7M0XlgznifM1T65X 4UEg== X-Gm-Message-State: AOAM531TkZIhkCWdwbat0AUggsBsPdWk71fBzzIK2hOj/gzlUkK18H52 1VkOHdnFQHTaFT+tLdcTDGc= X-Google-Smtp-Source: ABdhPJxUflap2s+aLhAdE5wyxNEVSZtiiarxvKIv7oIdabKlmBTbNxAU3z+YciTHVzoybIUGe2yUgw== X-Received: by 2002:a17:90a:c393:: with SMTP id h19mr10228503pjt.125.1590230022217; Sat, 23 May 2020 03:33:42 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id mt3sm1405205pjb.23.2020.05.23.03.33.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 May 2020 03:33:41 -0700 (PDT) From: xiangxia.m.yue@gmail.com To: i.maximets@ovn.org, u9012063@gmail.com, jarno@ovn.org, blp@ovn.org, azhou@ovn.org, pshelar@ovn.org Date: Sat, 23 May 2020 18:33:19 +0800 Message-Id: <20200523103320.47497-4-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20200523103320.47497-1-xiangxia.m.yue@gmail.com> References: <20200523103320.47497-1-xiangxia.m.yue@gmail.com> Cc: dev@openvswitch.org Subject: [ovs-dev] [PATCH ovs-dev v3 3/4] dpif-netdev: Use the u64 instead of u32 for buckets. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Tonghao Zhang When setting the meter rate to 4.3+Gbps, there is an overflow, the meters don't work as expected. Cc: Ilya Maximets Cc: William Tu Cc: Jarno Rajahalme Cc: Ben Pfaff Cc: Andy Zhou Cc: Pravin Shelar Acked-by: William Tu Signed-off-by: Tonghao Zhang --- include/openvswitch/ofp-meter.h | 2 +- lib/dpif-netdev.c | 4 ++-- lib/ofp-meter.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/openvswitch/ofp-meter.h b/include/openvswitch/ofp-meter.h index 6776eae87e26..f55f89ac1a71 100644 --- a/include/openvswitch/ofp-meter.h +++ b/include/openvswitch/ofp-meter.h @@ -37,7 +37,7 @@ struct ofputil_meter_band { uint16_t type; uint8_t prec_level; /* Non-zero if type == OFPMBT_DSCP_REMARK. */ uint32_t rate; - uint32_t burst_size; + uint64_t burst_size; }; void ofputil_format_meter_band(struct ds *, enum ofp13_meter_flags, diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index b23bb8281a89..776a16dab6e8 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -278,7 +278,7 @@ static bool dpcls_lookup(struct dpcls *cls, struct dp_meter_band { struct ofputil_meter_band up; /* type, prec_level, pad, rate, burst_size */ - uint32_t bucket; /* In 1/1000 packets (for PKTPS), or in bits (for KBPS) */ + uint64_t bucket; /* In 1/1000 packets (for PKTPS), or in bits (for KBPS) */ uint64_t packet_count; uint64_t byte_count; }; @@ -5972,7 +5972,7 @@ dp_netdev_run_meter(struct dp_netdev *dp, struct dp_packet_batch *packets_, band = &meter->bands[m]; /* Update band's bucket. */ - band->bucket += delta_t * band->up.rate; + band->bucket += (uint64_t)delta_t * band->up.rate; band->bucket += delta_in_us * band->up.rate / 1000; if (band->bucket > band->up.burst_size) { band->bucket = band->up.burst_size; diff --git a/lib/ofp-meter.c b/lib/ofp-meter.c index 9ea40a0bfb63..1ac993bb028b 100644 --- a/lib/ofp-meter.c +++ b/lib/ofp-meter.c @@ -72,7 +72,7 @@ ofputil_format_meter_band(struct ds *s, enum ofp13_meter_flags flags, ds_put_format(s, " rate=%"PRIu32, mb->rate); if (flags & OFPMF13_BURST) { - ds_put_format(s, " burst_size=%"PRIu32, mb->burst_size); + ds_put_format(s, " burst_size=%"PRIu64, mb->burst_size); } if (mb->type == OFPMBT13_DSCP_REMARK) { ds_put_format(s, " prec_level=%"PRIu8, mb->prec_level); @@ -703,7 +703,7 @@ parse_ofp_meter_mod_str__(struct ofputil_meter_mod *mm, char *string, return error; } } else if (!strcmp(name, "burst_size")) { - char *error = str_to_u32(value, &band->burst_size); + char *error = str_to_u64(value, &band->burst_size); if (error) { return error; }