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 <[email protected]>
Reviewed-by: Roi Dayan <[email protected]>
---
 lib/netdev.c         | 18 ++++++++++++++++++
 lib/netdev.h         |  2 ++
 vswitchd/bridge.c    |  2 ++
 vswitchd/vswitch.xml | 11 +++++++++++
 4 files changed, 33 insertions(+)

diff --git a/lib/netdev.c b/lib/netdev.c
index 3ac3c48..b289166 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -2071,7 +2071,25 @@ netdev_init_flow_api(struct netdev *netdev)
 {
     const struct netdev_class *class = netdev->netdev_class;
 
+    if (!netdev_flow_api_enabled) {
+        return EOPNOTSUPP;
+    }
+
     return (class->init_flow_api
             ? class->init_flow_api(netdev)
             : EOPNOTSUPP);
 }
+
+bool netdev_flow_api_enabled = false;
+
+void
+netdev_set_flow_api_enabled(bool enabled)
+{
+    static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
+
+    if (ovsthread_once_start(&once)) {
+        netdev_flow_api_enabled = enabled;
+        VLOG_INFO("netdev: Flow API %s", enabled ? "Enabled" : "Disabled");
+        ovsthread_once_done(&once);
+    }
+}
diff --git a/lib/netdev.h b/lib/netdev.h
index c04632d..5be67ea 100644
--- a/lib/netdev.h
+++ b/lib/netdev.h
@@ -168,6 +168,8 @@ int netdev_flow_get(struct netdev *, struct match *, struct 
nlattr **actions,
                     struct dpif_flow_stats *, ovs_u128 *, struct ofpbuf *);
 int netdev_flow_del(struct netdev *, struct dpif_flow_stats *, ovs_u128 *);
 int netdev_init_flow_api(struct netdev *);
+extern bool netdev_flow_api_enabled;
+void netdev_set_flow_api_enabled(bool flow_api_enabled);
 
 /* native tunnel APIs */
 /* Structure to pass parameters required to build a tunnel header. */
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 7f33070..e90a31a 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -2919,6 +2919,8 @@ bridge_run(void)
     cfg = ovsrec_open_vswitch_first(idl);
 
     if (cfg) {
+        netdev_set_flow_api_enabled(smap_get_bool(&cfg->other_config,
+                                                  "hw-offload", false));
         dpdk_init(&cfg->other_config);
     }
 
diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml
index 66c349b..9bc9f5f 100644
--- a/vswitchd/vswitch.xml
+++ b/vswitchd/vswitch.xml
@@ -169,6 +169,17 @@
         <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>
       </column>
 
       <column name="other_config" key="dpdk-init"
-- 
1.8.3.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to