From patchwork Wed May 13 13:31:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 1289294 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=CXCa4q3a; 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 49MbFP3dfwz9sSW for ; Wed, 13 May 2020 23:32:25 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 1D83D264BE; Wed, 13 May 2020 13:32:23 +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 b94z0uRpF2Qs; Wed, 13 May 2020 13:32:18 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 1D52125E31; Wed, 13 May 2020 13:32:14 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0F9B8C088F; Wed, 13 May 2020 13:32:14 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3FC79C016F for ; Wed, 13 May 2020 13:32:10 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 2FB02881D2 for ; Wed, 13 May 2020 13:32:10 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id R+BSQ2ZmqZnB for ; Wed, 13 May 2020 13:32:09 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by whitealder.osuosl.org (Postfix) with ESMTPS id A5CA0881BB for ; Wed, 13 May 2020 13:32:09 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id t7so6833948plr.0 for ; Wed, 13 May 2020 06:32:09 -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=S/Gx9qV5N3G6zU4fxDZNw3l8c0wctHBWjMgWzvejGu4=; b=CXCa4q3aMKB2VIIDUvW5YjKDKvVNi1Kwlx3PwaBiO0xnET/fdtrqRdVXNsoZl/3Dah 6gONRrRu5s8QqWpAnSJRhLT0wBvUZMiIxAoB6voJ1DjDjIdgPZihftcpI/gmR8ODWYLS Jap6HJLouhb/S4TR5p9hFqdN7fDWNqH8H6LzRHlgvhNgWbgj7lPJMsQxU9GuXqzjAFrA TnQ/UJ0rJoNsvpN0j83Cg6US/+Mi9MBcLAr1jFur1FjlP68ih6rVlr9D1x5Pgy9mXEF/ 9717zYZH1OmrTklyyU69jV3kgGl3ItHwqfIngbGY6P/nYkQESuaRvb8bE7J7+/x5xzl1 4xWw== 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=S/Gx9qV5N3G6zU4fxDZNw3l8c0wctHBWjMgWzvejGu4=; b=NMKlMrb+d16a2mRkVrk677ESQA0N1h+J1jT355e/pQVHewP0YNRqCu/GbP/RMxQD8/ r0JujVSbtmA2xL8Bp0Z0NcONOWVwyIvOeXU1us5hQBqNL4Qdxs4ZN+J0lkmvdByWDnww 4+P3ZRyQvc2e3HIZlacb1JBzKCiM7IGdYU3+kWxCqg9kG3pn5Tlys0D4XrLOaxUZ1+9P idt0uaobXoLw5xW6q0rcZN0eRrr2EoyizbqyEje0Falnej7stFsVPwprX8GvQZdIMPoN rPoJv+gcypjbfvKbZI5ctiNB/sJ9VxxNcl8dYSI1dXASDqYR4IEZEnWBudba0IW9ZGHU cq0A== X-Gm-Message-State: AGi0Pua3kb2CTGfLgBTVSV39mJUbrPav+oN6HQms0uqWQwwNgh/DZltL yHiN1GQ99jRqiKEUqAVF/AcmpT+i4aM= X-Google-Smtp-Source: APiQypKOO+i6qDtXTfMtePEncPrntQyij9XYkcGiqB8EHQGGl1K9tFzYCIhei9RnIw/PcpRsR2O2yQ== X-Received: by 2002:a17:90a:8d12:: with SMTP id c18mr34001180pjo.144.1589376728966; Wed, 13 May 2020 06:32:08 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id h11sm14488745pfo.120.2020.05.13.06.32.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 May 2020 06:32:08 -0700 (PDT) From: xiangxia.m.yue@gmail.com To: dev@openvswitch.org, i.maximets@ovn.org, u9012063@gmail.com, jarno@ovn.org, blp@ovn.org, azhou@ovn.org, pshelar@ovn.org Date: Wed, 13 May 2020 21:31:34 +0800 Message-Id: <20200513133135.48474-4-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20200513133135.48474-1-xiangxia.m.yue@gmail.com> References: <1584180230-89020-1-git-send-email-xiangxia.m.yue@gmail.com> <20200513133135.48474-1-xiangxia.m.yue@gmail.com> Subject: [ovs-dev] [PATCH ovs v2 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 36ecbfc728a9..9dac33ee3fca 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -277,7 +277,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; }; @@ -5971,7 +5971,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; }