diff mbox series

[ovs-dev,ovs-dev,3/7] dpif-provider: Add dpif provider meter api

Message ID 1577517076-105041-4-git-send-email-xiangxia.m.yue@gmail.com
State New
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>

Add the callback which will be called when we operate
the meter offload.

Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
---
 lib/dpif-netdev.c   |  3 +++
 lib/dpif-netlink.c  |  3 +++
 lib/dpif-provider.h |  5 ++++
 lib/dpif.c          | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/dpif.h          |  6 +++++
 5 files changed, 83 insertions(+)

Comments

0-day Robot Dec. 28, 2019, 8:05 a.m. UTC | #1
Bleep bloop.  Greetings Tonghao Zhang, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
WARNING: Line is 84 characters long (recommended limit is 79)
#95 FILE: lib/dpif.c:1997:
        VLOG_WARN_RL(&error_rl, "%s: failed to get DPIF meter config %"PRIu32": %s",

WARNING: Line is 85 characters long (recommended limit is 79)
#116 FILE: lib/dpif.c:2018:
        VLOG_WARN_RL(&error_rl, "%s: failed to offload set DPIF meter %"PRIu32": %s",

WARNING: Line is 85 characters long (recommended limit is 79)
#137 FILE: lib/dpif.c:2039:
        VLOG_WARN_RL(&error_rl, "%s: failed to offload get DPIF meter %"PRIu32": %s",

Lines checked: 163, Warnings: 3, Errors: 0


Please check this out.  If you feel there has been an error, please email aconole@redhat.com

Thanks,
0-day Robot
diff mbox series

Patch

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index c92d9aa..051d090 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -7681,6 +7681,9 @@  const struct dpif_class dpif_netdev_class = {
     dpif_netdev_meter_set,
     dpif_netdev_meter_get,
     dpif_netdev_meter_del,
+    NULL,
+    NULL,
+    NULL,
 };
 
 static void
diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
index a31da55..09489ec 100644
--- a/lib/dpif-netlink.c
+++ b/lib/dpif-netlink.c
@@ -3945,6 +3945,9 @@  const struct dpif_class dpif_netlink_class = {
     dpif_netlink_meter_set,
     dpif_netlink_meter_get,
     dpif_netlink_meter_del,
+    NULL,
+    NULL,
+    NULL,
 };
 
 static int
diff --git a/lib/dpif-provider.h b/lib/dpif-provider.h
index f8ca310..e7b09f5 100644
--- a/lib/dpif-provider.h
+++ b/lib/dpif-provider.h
@@ -614,6 +614,11 @@  struct dpif_class {
      * zero. */
     int (*meter_del)(struct dpif *, ofproto_meter_id meter_id,
                      struct ofputil_meter_stats *, uint16_t n_bands);
+    int (*meter_get_config)(struct dpif *, ofproto_meter_id meter_id,
+                            struct ofputil_meter_config *);
+    int (*meter_set_offload)(struct dpif *, ofproto_meter_id meter_id, void *);
+    int (*meter_get_offload)(struct dpif *, ofproto_meter_id meter_id, void **,
+                             uint16_t size);
 };
 
 extern const struct dpif_class dpif_netlink_class;
diff --git a/lib/dpif.c b/lib/dpif.c
index c88b210..8ef4534 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -66,6 +66,9 @@  COVERAGE_DEFINE(dpif_execute_with_help);
 COVERAGE_DEFINE(dpif_meter_set);
 COVERAGE_DEFINE(dpif_meter_get);
 COVERAGE_DEFINE(dpif_meter_del);
+COVERAGE_DEFINE(dpif_meter_get_config);
+COVERAGE_DEFINE(dpif_meter_set_offload);
+COVERAGE_DEFINE(dpif_meter_get_offload);
 
 static const struct dpif_class *base_dpif_classes[] = {
 #if defined(__linux__) || defined(_WIN32)
@@ -1976,3 +1979,66 @@  dpif_meter_del(struct dpif *dpif, ofproto_meter_id meter_id,
     }
     return error;
 }
+
+int
+dpif_meter_get_config(struct dpif *dpif, ofproto_meter_id meter_id,
+                      struct ofputil_meter_config *config)
+{
+    COVERAGE_INC(dpif_meter_get_config);
+
+    int error = (dpif->dpif_class->meter_get_config
+                 ? dpif->dpif_class->meter_get_config(dpif, meter_id,
+                                                      config)
+                 : EOPNOTSUPP);
+    if (!error) {
+        VLOG_DBG_RL(&dpmsg_rl, "%s: DPIF meter %"PRIu32" get config",
+                    dpif_name(dpif), meter_id.uint32);
+    } else {
+        VLOG_WARN_RL(&error_rl, "%s: failed to get DPIF meter config %"PRIu32": %s",
+                     dpif_name(dpif), meter_id.uint32, ovs_strerror(error));
+    }
+
+    return error;
+}
+
+int
+dpif_meter_set_offload(struct dpif *dpif, ofproto_meter_id meter_id,
+                       void *data)
+{
+    COVERAGE_INC(dpif_meter_set_offload);
+
+    int error = (dpif->dpif_class->meter_set_offload
+                 ? dpif->dpif_class->meter_set_offload(dpif, meter_id,
+                                                       data)
+                 : EOPNOTSUPP);
+    if (!error) {
+        VLOG_DBG_RL(&dpmsg_rl, "%s: DPIF meter %"PRIu32" offload set",
+                    dpif_name(dpif), meter_id.uint32);
+    } else {
+        VLOG_WARN_RL(&error_rl, "%s: failed to offload set DPIF meter %"PRIu32": %s",
+                     dpif_name(dpif), meter_id.uint32, ovs_strerror(error));
+    }
+
+    return error;
+}
+
+int
+dpif_meter_get_offload(struct dpif *dpif, ofproto_meter_id meter_id,
+                       void **data, uint16_t size)
+{
+    COVERAGE_INC(dpif_meter_get_offload);
+
+    int error = (dpif->dpif_class->meter_get_offload
+                 ? dpif->dpif_class->meter_get_offload(dpif, meter_id,
+                                                       data, size)
+                 : EOPNOTSUPP);
+    if (!error) {
+        VLOG_DBG_RL(&dpmsg_rl, "%s: DPIF meter %"PRIu32" offload get",
+                    dpif_name(dpif), meter_id.uint32);
+    } else {
+        VLOG_WARN_RL(&error_rl, "%s: failed to offload get DPIF meter %"PRIu32": %s",
+                     dpif_name(dpif), meter_id.uint32, ovs_strerror(error));
+    }
+
+    return error;
+}
diff --git a/lib/dpif.h b/lib/dpif.h
index d96f854..cab7f39 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -890,6 +890,12 @@  int dpif_meter_get(const struct dpif *, ofproto_meter_id meter_id,
                    struct ofputil_meter_stats *, uint16_t n_bands);
 int dpif_meter_del(struct dpif *, ofproto_meter_id meter_id,
                    struct ofputil_meter_stats *, uint16_t n_bands);
+int dpif_meter_get_config(struct dpif *dpif, ofproto_meter_id meter_id,
+                          struct ofputil_meter_config *config);
+int dpif_meter_set_offload(struct dpif *dpif, ofproto_meter_id meter_id,
+                           void *data);
+int dpif_meter_get_offload(struct dpif *dpif, ofproto_meter_id meter_id,
+                           void **data, uint16_t size);
 
 /* Miscellaneous. */