From patchwork Wed Mar 29 12:43:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roi Dayan X-Patchwork-Id: 744760 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vtS9v0lDyz9ryv for ; Wed, 29 Mar 2017 23:43:47 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 436FBB3F; Wed, 29 Mar 2017 12:43:43 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id A65D7AB6 for ; Wed, 29 Mar 2017 12:43:41 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id 0572016F for ; Wed, 29 Mar 2017 12:43:39 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from roid@mellanox.com) with ESMTPS (AES256-SHA encrypted); 29 Mar 2017 14:43:37 +0200 Received: from dev-r-vrt-189.mtr.labs.mlnx (dev-r-vrt-189.mtr.labs.mlnx [10.212.189.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v2TChaok021164; Wed, 29 Mar 2017 15:43:37 +0300 From: Roi Dayan To: dev@openvswitch.org Date: Wed, 29 Mar 2017 15:43:13 +0300 Message-Id: <1490791414-11875-4-git-send-email-roid@mellanox.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1490791414-11875-1-git-send-email-roid@mellanox.com> References: <1490791414-11875-1-git-send-email-roid@mellanox.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Shahar Klein , Hadar Hen Zion , Rony Efraim , Jiri Pirko , Marcelo Ricardo Leitner , Simon Horman , Or Gerlitz , Andy Gospodarek Subject: [ovs-dev] [PATCH ovs V6 03/24] other-config: Add hw-offload switch to control netdev flow offloading X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Paul Blakey 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 Reviewed-by: Roi Dayan Reviewed-by: Simon Horman --- lib/netdev.c | 30 ++++++++++++++++++++++++++++++ lib/netdev.h | 2 ++ vswitchd/bridge.c | 1 + vswitchd/vswitch.xml | 11 +++++++++++ 4 files changed, 44 insertions(+) diff --git a/lib/netdev.c b/lib/netdev.c index f7b80b2..977844a 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 6d2db7d..e2d1799 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 867a26d..0f65858 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -2953,6 +2953,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 14297bf..de86049 100644 --- a/vswitchd/vswitch.xml +++ b/vswitchd/vswitch.xml @@ -170,6 +170,17 @@

The default is 10000.

+ + + +

+ Set this value to true to enable netdev flow offload. +

+

+ The default value is false. Changing this value requires + restarting the daemon +