diff options
author | Paul Blakey <paulb@mellanox.com> | 2017-06-13 18:03:29 +0300 |
---|---|---|
committer | Simon Horman <simon.horman@netronome.com> | 2017-06-14 10:13:25 +0200 |
commit | 53611f7b05460ee60cc94d67e14ac8945de4b4f9 (patch) | |
tree | ef8a8670a99557da746b76418bb9dc5ce74c49c8 /lib | |
parent | 18ebd48cfb01ea0e239c6820520a1c57063cc58f (diff) | |
download | openvswitch-53611f7b05460ee60cc94d67e14ac8945de4b4f9.tar.gz |
other-config: Add hw-offload switch to control netdev flow offloading
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>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/netdev.c | 35 | ||||
-rw-r--r-- | lib/netdev.h | 2 |
2 files changed, 37 insertions, 0 deletions
diff --git a/lib/netdev.c b/lib/netdev.c index 21d2b68ac..5008a4378 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 87fa32a4a..557236646 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. */ |