From: Peng Zhang <peng.zh...@corigine.com>

OVS-DPDK meters are created in advance and OpenFlow rules refer to them by
their unique ID. A new API is used to offload them. By calling the API,
meters are created and try to be offload by port in the bridge with the
proxy port id.

Signed-off-by: Peng Zhang <peng.zh...@corigine.com>
Signed-off-by: Jin Liu <jin....@corigine.com>
Co-authored-by: Jin Liu <jin....@corigine.com>
Signed-off-by: Simon Horman <simon.hor...@corigine.com>
---
 lib/dpif-netdev.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 2c08a71c8db2..e8d0ca6606de 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -7277,6 +7277,11 @@ dpif_netdev_meter_set(struct dpif *dpif, 
ofproto_meter_id meter_id,
 
     ovs_mutex_unlock(&dp->meters_lock);
 
+    if (netdev_is_flow_api_enabled()) {
+        dpdk_meter_offload_set(dpif_normalize_type(dpif_type(dpif)),
+                               meter_id, config);
+    }
+
     return 0;
 }
 
@@ -7313,8 +7318,18 @@ dpif_netdev_meter_get(const struct dpif *dpif,
 
         ovs_mutex_unlock(&meter->lock);
         stats->n_bands = i;
-    }
 
+        if (netdev_is_flow_api_enabled()) {
+            dpdk_meter_offload_get(dpif_normalize_type(dpif_type(dpif)),
+                                   meter_id_, stats);
+
+            /* nit: Meter offload currently only supports one band */
+            if (meter->n_bands) {
+                stats->bands[0].packet_count = stats->packet_in_count;
+                stats->bands[0].byte_count = stats->byte_in_count;
+            }
+        }
+    }
     return 0;
 }
 
@@ -7330,6 +7345,11 @@ dpif_netdev_meter_del(struct dpif *dpif,
     if (!error) {
         uint32_t meter_id = meter_id_.uint32;
 
+        if (netdev_is_flow_api_enabled()) {
+            dpdk_meter_offload_del(dpif_normalize_type(dpif_type(dpif)),
+                                   meter_id_, stats);
+        }
+
         ovs_mutex_lock(&dp->meters_lock);
         dp_meter_detach_free(&dp->meters, meter_id);
         ovs_mutex_unlock(&dp->meters_lock);
-- 
2.30.2

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to