[ovs-dev] [PATCH V11 07/33] other-config: Add hw-offload switch to control netdev flow offloading

Roi Dayan roid at mellanox.com
Tue Jun 13 15:03:29 UTC 2017


From: Paul Blakey <paulb at mellanox.com>

Add a new configuration option - hw-offload that enables netdev
flow api. Enabling this option will allow offloading flows
using netdev implementation instead of the kernel datapath.
This configuration option defaults to false - disabled.

Signed-off-by: Paul Blakey <paulb at mellanox.com>
Reviewed-by: Roi Dayan <roid at mellanox.com>
Reviewed-by: Simon Horman <simon.horman at netronome.com>
Acked-by: Flavio Leitner <fbl at sysclose.org>
---
 lib/netdev.c         | 35 +++++++++++++++++++++++++++++++++++
 lib/netdev.h         |  2 ++
 vswitchd/bridge.c    |  1 +
 vswitchd/vswitch.xml | 15 +++++++++++++++
 4 files changed, 53 insertions(+)

diff --git a/lib/netdev.c b/lib/netdev.c
index 21d2b68..5008a43 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -92,6 +92,8 @@ struct netdev_registered_class {
     struct ovs_refcount refcnt;
 };
 
+static bool netdev_flow_api_enabled = false;
+
 /* This is set pretty low because we probably won't learn anything from the
  * additional log messages. */
 static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20);
@@ -2107,7 +2109,40 @@ netdev_init_flow_api(struct netdev *netdev)
 {
     const struct netdev_class *class = netdev->netdev_class;
 
+    if (!netdev_is_flow_api_enabled()) {
+        return EOPNOTSUPP;
+    }
+
     return (class->init_flow_api
             ? class->init_flow_api(netdev)
             : EOPNOTSUPP);
 }
+
+bool
+netdev_is_flow_api_enabled(void)
+{
+    return netdev_flow_api_enabled;
+}
+
+#ifdef __linux__
+void
+netdev_set_flow_api_enabled(const struct smap *ovs_other_config)
+{
+    if (smap_get_bool(ovs_other_config, "hw-offload", false)) {
+        static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
+
+        if (ovsthread_once_start(&once)) {
+            netdev_flow_api_enabled = true;
+
+            VLOG_INFO("netdev: Flow API Enabled");
+
+            ovsthread_once_done(&once);
+        }
+    }
+}
+#else
+void
+netdev_set_flow_api_enabled(const struct smap *ovs_other_config OVS_UNUSED)
+{
+}
+#endif
diff --git a/lib/netdev.h b/lib/netdev.h
index 87fa32a..5572366 100644
--- a/lib/netdev.h
+++ b/lib/netdev.h
@@ -179,6 +179,8 @@ int netdev_flow_get(struct netdev *, struct match *, struct nlattr **actions,
 int netdev_flow_del(struct netdev *, const ovs_u128 *,
                     struct dpif_flow_stats *);
 int netdev_init_flow_api(struct netdev *);
+bool netdev_is_flow_api_enabled(void);
+void netdev_set_flow_api_enabled(const struct smap *ovs_other_config);
 
 /* native tunnel APIs */
 /* Structure to pass parameters required to build a tunnel header. */
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index cc7a43b..8336d70 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -2955,6 +2955,7 @@ bridge_run(void)
     cfg = ovsrec_open_vswitch_first(idl);
 
     if (cfg) {
+        netdev_set_flow_api_enabled(&cfg->other_config);
         dpdk_init(&cfg->other_config);
     }
 
diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml
index 892f839..7e5062f 100644
--- a/vswitchd/vswitch.xml
+++ b/vswitchd/vswitch.xml
@@ -178,6 +178,21 @@
         <p>
           The default is 10000.
         </p>
+    </column>
+
+      <column name="other_config" key="hw-offload"
+              type='{"type": "boolean"}'>
+        <p>
+          Set this value to <code>true</code> to enable netdev flow offload.
+        </p>
+        <p>
+          The default value is <code>false</code>. Changing this value requires
+          restarting the daemon
+        </p>
+        <p>
+          Currently Open vSwitch supports hardware offloading on
+          Linux systems.  On other systems, this value is ignored.
+        </p>
       </column>
 
       <column name="other_config" key="dpdk-init"
-- 
2.7.4



More information about the dev mailing list