From patchwork Mon Mar 13 13:36:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roi Dayan X-Patchwork-Id: 738137 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 3vhfBn545kz9s0Z for ; Tue, 14 Mar 2017 00:40:33 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 1188FC04; Mon, 13 Mar 2017 13:37:33 +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 AF9D9BCC for ; Mon, 13 Mar 2017 13:37:26 +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 5846A243 for ; Mon, 13 Mar 2017 13:37:23 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from roid@mellanox.com) with ESMTPS (AES256-SHA encrypted); 13 Mar 2017 15:37:20 +0200 Received: from r-vnc05.mtr.labs.mlnx (r-vnc05.mtr.labs.mlnx [10.208.0.115]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v2DDbJZ9028197; Mon, 13 Mar 2017 15:37:20 +0200 From: Roi Dayan To: dev@openvswitch.org Date: Mon, 13 Mar 2017 15:36:54 +0200 Message-Id: <1489412234-30916-5-git-send-email-roid@mellanox.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1489412234-30916-1-git-send-email-roid@mellanox.com> References: <1489412234-30916-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 V4 04/24] other-config: Add tc-policy switch to control tc flower flag 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 tc-policy option that controls tc flower flag. Possible options are none, skip_sw, skip_hw. The default is none which is to insert the rule both to sw and hw. This option is only relevant if hw-offload is enabled. Signed-off-by: Paul Blakey Reviewed-by: Roi Dayan --- lib/netdev.c | 6 ++++++ lib/tc.c | 43 ++++++++++++++++++++++++++++++++++++++++++- lib/tc.h | 1 + vswitchd/vswitch.xml | 17 +++++++++++++++++ 4 files changed, 66 insertions(+), 1 deletions(-) diff --git a/lib/netdev.c b/lib/netdev.c index 977844a..6bde14b 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -54,6 +54,9 @@ #include "openvswitch/vlog.h" #include "flow.h" #include "util.h" +#ifdef __linux__ +#include "tc.h" +#endif VLOG_DEFINE_THIS_MODULE(netdev); @@ -2115,6 +2118,9 @@ netdev_set_flow_api_enabled(const struct smap *ovs_other_config) VLOG_INFO("netdev: Flow API Enabled"); + tc_set_policy(smap_get_def(ovs_other_config, "tc-policy", + TC_POLICY_DEFAULT)); + ovsthread_once_done(&once); } } diff --git a/lib/tc.c b/lib/tc.c index 0c9c15e..219f702 100644 --- a/lib/tc.c +++ b/lib/tc.c @@ -38,6 +38,14 @@ VLOG_DEFINE_THIS_MODULE(tc); static struct vlog_rate_limit parse_err = VLOG_RATE_LIMIT_INIT(5, 5); +enum tc_offload_policy { + TC_POLICY_NONE, + TC_POLICY_SKIP_SW, + TC_POLICY_SKIP_HW +}; + +static enum tc_offload_policy tc_policy = TC_POLICY_NONE; + /* Returns tc handle 'major':'minor'. */ unsigned int tc_make_handle(unsigned int major, unsigned int minor) @@ -725,6 +733,18 @@ tc_get_flower(int ifindex, int prio, int handle, struct tc_flower *flower) return error; } +static int +tc_get_tc_cls_policy(enum tc_offload_policy policy) +{ + if (policy == TC_POLICY_SKIP_HW) { + return TCA_CLS_FLAGS_SKIP_HW; + } else if (policy == TC_POLICY_SKIP_SW) { + return TCA_CLS_FLAGS_SKIP_SW; + } + + return 0; +} + static void nl_msg_put_act_push_vlan(struct ofpbuf *request, uint16_t vid, uint8_t prio) { @@ -995,7 +1015,7 @@ nl_msg_put_flower_options(struct ofpbuf *request, struct tc_flower *flower) } } - nl_msg_put_u32(request, TCA_FLOWER_FLAGS, 0); + nl_msg_put_u32(request, TCA_FLOWER_FLAGS, tc_get_tc_cls_policy(tc_policy)); if (flower->tunnel.tunnel) { nl_msg_put_flower_tunnel(request, flower); @@ -1040,3 +1060,24 @@ tc_replace_flower(int ifindex, uint16_t prio, uint32_t handle, return error; } + +void +tc_set_policy(const char *policy) +{ + if (!policy) { + return; + } + + if (!strcmp(policy, "skip_sw")) { + tc_policy = TC_POLICY_SKIP_SW; + } else if (!strcmp(policy, "skip_hw")) { + tc_policy = TC_POLICY_SKIP_HW; + } else if (!strcmp(policy, "none")) { + tc_policy = TC_POLICY_NONE; + } else { + VLOG_WARN("tc: Invalid policy '%s'", policy); + return; + } + + VLOG_INFO("tc: Using policy '%s'", policy); +} diff --git a/lib/tc.h b/lib/tc.h index 5ca6c55..6f6cc09 100644 --- a/lib/tc.h +++ b/lib/tc.h @@ -115,5 +115,6 @@ int tc_flush(int ifindex); int tc_dump_flower_start(int ifindex, struct nl_dump *dump); int parse_netlink_to_tc_flower(struct ofpbuf *reply, struct tc_flower *flower); +void tc_set_policy(const char *policy); #endif /* tc.h */ diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml index 942e68f..a37d2ed 100644 --- a/vswitchd/vswitch.xml +++ b/vswitchd/vswitch.xml @@ -183,6 +183,23 @@

+ +

+ Specified the policy used with HW offloading. + Options: + none - Add software rule and offload rule to HW. + skip_sw - Offload rule to HW only. + skip_hw - Add software rule without offloading rule to HW. +

+

+ This is only relevant if HW offloading is enabled (hw-offload). +

+

+ The default value is none. +

+
+