diff mbox

[ovs-dev,ovs,V8,03/26] other-config: Add hw-offload switch to control netdev flow offloading

Message ID 1493824097-47495-4-git-send-email-roid@mellanox.com
State Changes Requested
Headers show

Commit Message

Roi Dayan May 3, 2017, 3:07 p.m. UTC
From: Paul Blakey <paulb@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@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
---
 lib/netdev.c         | 30 ++++++++++++++++++++++++++++++
 lib/netdev.h         |  2 ++
 vswitchd/bridge.c    |  1 +
 vswitchd/vswitch.xml | 11 +++++++++++
 4 files changed, 44 insertions(+)

Comments

Simon Horman May 8, 2017, 12:38 p.m. UTC | #1
On Wed, May 03, 2017 at 06:07:54PM +0300, Roi Dayan wrote:
> From: Paul Blakey <paulb@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@mellanox.com>
> Reviewed-by: Roi Dayan <roid@mellanox.com>
> Reviewed-by: Simon Horman <simon.horman@netronome.com>

...

This does not appear to address Flavio Leitner's review of v7 of this patch.
Roi Dayan May 16, 2017, 9:12 a.m. UTC | #2
On 08/05/2017 15:38, Simon Horman wrote:
> On Wed, May 03, 2017 at 06:07:54PM +0300, Roi Dayan wrote:
>> From: Paul Blakey <paulb@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@mellanox.com>
>> Reviewed-by: Roi Dayan <roid@mellanox.com>
>> Reviewed-by: Simon Horman <simon.horman@netronome.com>
>
> ...
>
> This does not appear to address Flavio Leitner's review of v7 of this patch.
>

as mentioned, email problems, I looked in the online archive and 
addressed for V9.

as suggested, I removed the extern from netdev_flow_api_enabled and 
added function netdev_is_flow_api_enabled().

I didn't add netdev_flow_api_supported as it seems redundant..?
we compile tc.c in Linux only so we can't have 
netdev_set_flow_api_enabled() implementation so will keep it empty.
diff mbox

Patch

diff --git a/lib/netdev.c b/lib/netdev.c
index 1677027..90c95cb 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -2092,7 +2092,37 @@  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;
+
+#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)
+{
+    netdev_flow_api_enabled = false;
+}
+#endif
diff --git a/lib/netdev.h b/lib/netdev.h
index 17890e6..7435fdf 100644
--- a/lib/netdev.h
+++ b/lib/netdev.h
@@ -178,6 +178,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 *);
+extern bool netdev_flow_api_enabled;
+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 ebb6249..d1e130f 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -2954,6 +2954,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 bb66cb5..8eeedd0 100644
--- a/vswitchd/vswitch.xml
+++ b/vswitchd/vswitch.xml
@@ -178,6 +178,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"