diff mbox series

[ovs-dev,ovs-dev,6/7] ofp-meter: Add get max-rate function

Message ID 1577517076-105041-7-git-send-email-xiangxia.m.yue@gmail.com
State Changes Requested
Headers show
Series Support meter action offload | expand

Commit Message

Tonghao Zhang Dec. 28, 2019, 7:11 a.m. UTC
From: Tonghao Zhang <xiangxia.m.yue@gmail.com>

This patch will be used later.

Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
---
 include/openvswitch/ofp-meter.h |  1 +
 lib/ofp-meter.c                 | 13 +++++++++++++
 2 files changed, 14 insertions(+)
diff mbox series

Patch

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;
+}