From patchwork Thu Feb 9 14:18:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Or Gerlitz X-Patchwork-Id: 726140 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3vK0YF4d99z9s3v for ; Fri, 10 Feb 2017 01:18:25 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752788AbdBIOSX (ORCPT ); Thu, 9 Feb 2017 09:18:23 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:52572 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752505AbdBIOSW (ORCPT ); Thu, 9 Feb 2017 09:18:22 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from ogerlitz@mellanox.com) with ESMTPS (AES256-SHA encrypted); 9 Feb 2017 16:18:15 +0200 Received: from r-vnc04.mtr.labs.mlnx (r-vnc04.mtr.labs.mlnx [10.208.0.116]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v19EIEgS001037; Thu, 9 Feb 2017 16:18:15 +0200 From: Or Gerlitz To: "David S. Miller" Cc: Daniel Borkmann , Jakub Kicinski , John Fastabend , Amir Vadai , netdev@vger.kernel.org, Or Gerlitz Subject: [PATCH net-next 3/4] net/sched: cls_u32: Use skip flags to reflect HW offload status Date: Thu, 9 Feb 2017 16:18:07 +0200 Message-Id: <1486649888-2786-4-git-send-email-ogerlitz@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1486649888-2786-1-git-send-email-ogerlitz@mellanox.com> References: <1486649888-2786-1-git-send-email-ogerlitz@mellanox.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Currently there is no way of querying whether a filter is offloaded to HW or not when using both policy (no flag). Reuse the skip flags to show the insertion status by setting the skip_hw flag in case the filter wasn't offloaded. Signed-off-by: Or Gerlitz --- net/sched/cls_u32.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index a6ec3e4b..97411d5 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -493,7 +493,7 @@ static void u32_clear_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h) } static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n, - u32 flags) + u32 *flags) { struct net_device *dev = tp->q->dev_queue->dev; struct tc_cls_u32_offload u32_offload = {0}; @@ -503,8 +503,12 @@ static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n, offload.type = TC_SETUP_CLSU32; offload.cls_u32 = &u32_offload; - if (!tc_should_offload(dev, tp, flags)) - return tc_skip_sw(flags) ? -EINVAL : 0; + if (!tc_should_offload(dev, tp, *flags)) { + if (tc_skip_sw(*flags)) + return -EINVAL; + *flags = TCA_CLS_FLAGS_SKIP_HW; + return 0; + } offload.cls_u32->command = TC_CLSU32_REPLACE_KNODE; offload.cls_u32->knode.handle = n->handle; @@ -523,9 +527,11 @@ static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n, err = dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, tp->protocol, &offload); - if (tc_skip_sw(flags)) + if (tc_skip_sw(*flags)) return err; + if (err) + *flags = TCA_CLS_FLAGS_SKIP_HW; return 0; } @@ -889,12 +895,13 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, return err; } - err = u32_replace_hw_knode(tp, new, flags); + err = u32_replace_hw_knode(tp, new, &flags); if (err) { u32_destroy_key(tp, new, false); return err; } + n->flags |= flags; u32_replace_knode(tp, tp_c, new); tcf_unbind_filter(tp, &n->res); call_rcu(&n->rcu, u32_delete_key_rcu); @@ -1010,10 +1017,11 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, struct tc_u_knode __rcu **ins; struct tc_u_knode *pins; - err = u32_replace_hw_knode(tp, n, flags); + err = u32_replace_hw_knode(tp, n, &flags); if (err) goto errhw; + n->flags |= flags; ins = &ht->ht[TC_U32_HASH(handle)]; for (pins = rtnl_dereference(*ins); pins; ins = &pins->next, pins = rtnl_dereference(*ins))