From patchwork Sat Dec 28 07:11:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 1215823 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.137; helo=fraxinus.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.b="Vmq3HOHh"; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47lFHd48lMz9sPW for ; Sat, 28 Dec 2019 18:11:57 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 11E5785B0D; Sat, 28 Dec 2019 07:11:56 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QCB8vvbj-cuT; Sat, 28 Dec 2019 07:11:55 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 830E78598A; Sat, 28 Dec 2019 07:11:55 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 63EF3C1D90; Sat, 28 Dec 2019 07:11:55 +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 9F888C1D8A for ; Sat, 28 Dec 2019 07:11:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 949F186523 for ; Sat, 28 Dec 2019 07:11:54 +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 3bL+-ZkcyHO4 for ; Sat, 28 Dec 2019 07:11:52 +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 AA37B86354 for ; Sat, 28 Dec 2019 07:11:43 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id s21so9844722plr.7 for ; Fri, 27 Dec 2019 23:11:43 -0800 (PST) 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=n4D1JyuvOtBCRvY1rZ+JjKCqV/caJINfFBNdPhYVhKI=; b=Vmq3HOHhU8J/nq28uM09StW7u+/1an7bkHMr36vDX/bCDBtMBrSjZZU4AuPE+B2+hf xQXBRcHwkUGujiq87AF8QRgRNPkxPojG/pcCL1inv5BAjv8wOFv42HucEv9t8Ulc9G5V 1Ua2vUxn3Knol/kJpCzxLrO2LIEq+Xkr6TcHRYX5P60xAGQcmIdVMrVvRUxQvTVAbCuJ C/hEE2eDf4pKq0g2jLylY9UxgtQqwnG58hV7SVdDQIq9bB5aS7KyHhlEHFr1MsTIMT2M eeA974lux3YcrUi8KAyTHmwNcCcqvHmaY8TGLDa9mvMWAeBfdbU0xpWWJIUQM/lsbeSR kLRw== 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=n4D1JyuvOtBCRvY1rZ+JjKCqV/caJINfFBNdPhYVhKI=; b=WvsrvxszEjnyIDFlHT9EPeQI2OBRD+wsynyaIeynOE3UOY5jb8h+AkxYWkyUg3MAmd xBcRtqYqITGgkcK+EhrZzPMEaAA/pIMj1AkZ79KxcPttxuAyTpZvCoYhoNkWQKfRKVPR cq4nyAW2QP0rag81mQCCW/S3bdAPCKOfTl56nZT474GUySM6MtEMPwxX0Ww0ZwNC2fZ+ F5X+Mp6AM2WTb5wOoTkCL4e15dpABLRVL5mVyOk4a6mPjFhJGezdS5ZWzFqVu2YpqYeb WnmqOQfRCzf4I9Mi+Y9GTe5jUPQ9gOsgk4F//AeUsIwy4aOCXTHN7dsq/zwsrc5Br/q2 fSzw== X-Gm-Message-State: APjAAAWZ/Ta7KJ/0EO5CkBsiPlB5LsMb6ydVqju2M1PO8TshltZ1A6qT ABiZn9vBgy6WwDYbdU7qfws= X-Google-Smtp-Source: APXvYqxa/vKhKNo9opAimsnAgvi/3uCh/D3vJcMHRvGxxg9YEPxt7Qm5usYsdM1VPRZLEQzNKSSLiw== X-Received: by 2002:a17:902:bc4b:: with SMTP id t11mr19706678plz.190.1577517103355; Fri, 27 Dec 2019 23:11:43 -0800 (PST) Received: from local.opencloud.tech.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id o2sm17380429pjo.26.2019.12.27.23.11.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Dec 2019 23:11:42 -0800 (PST) From: xiangxia.m.yue@gmail.com To: blp@ovn.org, i.maximets@ovn.org, elibr@mellanox.com Date: Sat, 28 Dec 2019 15:11:15 +0800 Message-Id: <1577517076-105041-7-git-send-email-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1577517076-105041-1-git-send-email-xiangxia.m.yue@gmail.com> References: <1577517076-105041-1-git-send-email-xiangxia.m.yue@gmail.com> Cc: dev@openvswitch.org, martinbj2008@gmail.com Subject: [ovs-dev] [ovs-dev 6/7] ofp-meter: Add get max-rate function 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 This patch will be used later. Signed-off-by: Tonghao Zhang --- include/openvswitch/ofp-meter.h | 1 + lib/ofp-meter.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/openvswitch/ofp-meter.h b/include/openvswitch/ofp-meter.h index 6776eae..c6678f5 100644 --- a/include/openvswitch/ofp-meter.h +++ b/include/openvswitch/ofp-meter.h @@ -62,6 +62,7 @@ int ofputil_decode_meter_config(struct ofpbuf *, struct ofpbuf *bands); void ofputil_format_meter_config(struct ds *, const struct ofputil_meter_config *); +uint32_t ofputil_meter_config_max_rate(struct ofputil_meter_config *conf); struct ofputil_meter_mod { uint16_t command; diff --git a/lib/ofp-meter.c b/lib/ofp-meter.c index 9ea40a0..c1a7087 100644 --- a/lib/ofp-meter.c +++ b/lib/ofp-meter.c @@ -807,3 +807,16 @@ ofputil_format_meter_mod(struct ds *s, const struct ofputil_meter_mod *mm) ofputil_format_meter_config(s, &mm->meter); } + +uint32_t +ofputil_meter_config_max_rate(struct ofputil_meter_config *conf) +{ + uint32_t i, max_rate = 0; + for (i = 0; i < conf->n_bands; i++) { + if (max_rate < conf->bands[i].rate) { + max_rate = conf->bands[i].rate; + } + } + + return max_rate; +}