public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli•us>
To: netdev@vger•kernel.org
Cc: davem@davemloft•net, jhs@mojatatu•com, xiyou.wangcong@gmail•com,
	mlxsw@mellanox•com, andrew@lunn•ch,
	vivien.didelot@savoirfairelinux•com, f.fainelli@gmail•com,
	michael.chan@broadcom•com, ganeshgr@chelsio•com,
	jeffrey.t.kirsher@intel•com, saeedm@mellanox•com,
	matanb@mellanox•com, leonro@mellanox•com, idosch@mellanox•com,
	jakub.kicinski@netronome•com, ast@kernel•org,
	daniel@iogearbox•net, simon.horman@netronome•com,
	pieter.jansenvanvuuren@netronome•com, john.hurley@netronome•com,
	alexander.h.duyck@intel•com
Subject: [patch net-next 05/20] net: sched: cls_matchall: call block callbacks for offload
Date: Tue, 17 Oct 2017 22:06:00 +0200	[thread overview]
Message-ID: <20171017200615.4530-6-jiri@resnulli.us> (raw)
In-Reply-To: <20171017200615.4530-1-jiri@resnulli.us>

From: Jiri Pirko <jiri@mellanox•com>

Use the newly introduced callbacks infrastructure and call block
callbacks alongside with the existing per-netdev ndo_setup_tc.

Signed-off-by: Jiri Pirko <jiri@mellanox•com>
---
 net/sched/cls_matchall.c | 72 ++++++++++++++++++++++++++++++------------------
 1 file changed, 45 insertions(+), 27 deletions(-)

diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c
index eeac606..5278534 100644
--- a/net/sched/cls_matchall.c
+++ b/net/sched/cls_matchall.c
@@ -50,50 +50,73 @@ static void mall_destroy_rcu(struct rcu_head *rcu)
 	kfree(head);
 }
 
-static int mall_replace_hw_filter(struct tcf_proto *tp,
-				  struct cls_mall_head *head,
-				  unsigned long cookie)
+static void mall_destroy_hw_filter(struct tcf_proto *tp,
+				   struct cls_mall_head *head,
+				   unsigned long cookie)
 {
 	struct net_device *dev = tp->q->dev_queue->dev;
 	struct tc_cls_matchall_offload cls_mall = {};
-	int err;
+	struct tcf_block *block = tp->chain->block;
 
 	tc_cls_common_offload_init(&cls_mall.common, tp);
-	cls_mall.command = TC_CLSMATCHALL_REPLACE;
-	cls_mall.exts = &head->exts;
+	cls_mall.command = TC_CLSMATCHALL_DESTROY;
 	cls_mall.cookie = cookie;
 
-	err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSMATCHALL,
-					    &cls_mall);
-	if (!err)
-		head->flags |= TCA_CLS_FLAGS_IN_HW;
-
-	return err;
+	if (tc_can_offload(dev))
+		dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSMATCHALL,
+					      &cls_mall);
+	tc_setup_cb_call(block, NULL, TC_SETUP_CLSMATCHALL, &cls_mall, false);
 }
 
-static void mall_destroy_hw_filter(struct tcf_proto *tp,
-				   struct cls_mall_head *head,
-				   unsigned long cookie)
+static int mall_replace_hw_filter(struct tcf_proto *tp,
+				  struct cls_mall_head *head,
+				  unsigned long cookie)
 {
 	struct net_device *dev = tp->q->dev_queue->dev;
 	struct tc_cls_matchall_offload cls_mall = {};
+	struct tcf_block *block = tp->chain->block;
+	bool skip_sw = tc_skip_sw(head->flags);
+	int err;
 
 	tc_cls_common_offload_init(&cls_mall.common, tp);
-	cls_mall.command = TC_CLSMATCHALL_DESTROY;
+	cls_mall.command = TC_CLSMATCHALL_REPLACE;
+	cls_mall.exts = &head->exts;
 	cls_mall.cookie = cookie;
 
-	dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSMATCHALL, &cls_mall);
+	if (tc_can_offload(dev)) {
+		err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSMATCHALL,
+						    &cls_mall);
+		if (err) {
+			if (skip_sw)
+				return err;
+		} else {
+			head->flags |= TCA_CLS_FLAGS_IN_HW;
+		}
+	}
+
+	err = tc_setup_cb_call(block, NULL, TC_SETUP_CLSMATCHALL,
+			       &cls_mall, skip_sw);
+	if (err < 0) {
+		mall_destroy_hw_filter(tp, head, cookie);
+		return err;
+	} else if (err > 0) {
+		head->flags |= TCA_CLS_FLAGS_IN_HW;
+	}
+
+	if (skip_sw && !(head->flags & TCA_CLS_FLAGS_IN_HW))
+		return -EINVAL;
+
+	return 0;
 }
 
 static void mall_destroy(struct tcf_proto *tp)
 {
 	struct cls_mall_head *head = rtnl_dereference(tp->root);
-	struct net_device *dev = tp->q->dev_queue->dev;
 
 	if (!head)
 		return;
 
-	if (tc_should_offload(dev, head->flags))
+	if (!tc_skip_hw(head->flags))
 		mall_destroy_hw_filter(tp, head, (unsigned long) head);
 
 	call_rcu(&head->rcu, mall_destroy_rcu);
@@ -133,7 +156,6 @@ static int mall_change(struct net *net, struct sk_buff *in_skb,
 		       void **arg, bool ovr)
 {
 	struct cls_mall_head *head = rtnl_dereference(tp->root);
-	struct net_device *dev = tp->q->dev_queue->dev;
 	struct nlattr *tb[TCA_MATCHALL_MAX + 1];
 	struct cls_mall_head *new;
 	u32 flags = 0;
@@ -173,14 +195,10 @@ static int mall_change(struct net *net, struct sk_buff *in_skb,
 	if (err)
 		goto err_set_parms;
 
-	if (tc_should_offload(dev, flags)) {
+	if (!tc_skip_hw(new->flags)) {
 		err = mall_replace_hw_filter(tp, new, (unsigned long) new);
-		if (err) {
-			if (tc_skip_sw(flags))
-				goto err_replace_hw_filter;
-			else
-				err = 0;
-		}
+		if (err)
+			goto err_replace_hw_filter;
 	}
 
 	if (!tc_in_hw(new->flags))
-- 
2.9.5

  parent reply	other threads:[~2017-10-17 20:06 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-17 20:05 [patch net-next 00/20] net: sched: convert cls ndo_setup_tc offload calls to per-block callbacks Jiri Pirko
2017-10-17 20:05 ` [patch net-next 01/20] net: sched: add block bind/unbind notif. and extended block_get/put Jiri Pirko
2017-10-17 20:22   ` Duyck, Alexander H
2017-10-18  6:59     ` Jiri Pirko
2017-10-19 12:23   ` David Miller
2017-10-19 13:13     ` Jiri Pirko
2017-10-17 20:05 ` [patch net-next 02/20] net: sched: use extended variants of block_get/put in ingress and clsact qdiscs Jiri Pirko
2017-10-17 20:05 ` [patch net-next 03/20] net: sched: introduce per-block callbacks Jiri Pirko
2017-10-17 20:05 ` [patch net-next 04/20] net: sched: use tc_setup_cb_call to call " Jiri Pirko
2017-10-17 20:06 ` Jiri Pirko [this message]
2017-10-17 20:06 ` [patch net-next 06/20] net: sched: cls_u32: swap u32_remove_hw_knode and u32_remove_hw_hnode Jiri Pirko
2017-10-17 20:06 ` [patch net-next 07/20] net: sched: cls_u32: call block callbacks for offload Jiri Pirko
2017-10-17 20:06 ` [patch net-next 08/20] net: sched: cls_bpf: " Jiri Pirko
2017-10-17 20:06 ` [patch net-next 09/20] mlxsw: spectrum: Convert ndo_setup_tc offloads to block callbacks Jiri Pirko
2017-10-17 20:06 ` [patch net-next 10/20] mlx5e: " Jiri Pirko
2017-10-17 20:06 ` [patch net-next 11/20] bnxt: " Jiri Pirko
2017-10-17 20:06 ` [patch net-next 12/20] cxgb4: " Jiri Pirko
2017-10-17 20:06 ` [patch net-next 13/20] ixgbe: " Jiri Pirko
2017-10-17 20:06 ` [patch net-next 14/20] mlx5e_rep: " Jiri Pirko
2017-10-17 20:06 ` [patch net-next 15/20] nfp: flower: " Jiri Pirko
2017-10-17 20:06 ` [patch net-next 16/20] nfp: bpf: " Jiri Pirko
2017-10-17 20:06 ` [patch net-next 17/20] dsa: " Jiri Pirko
2017-10-17 20:06 ` [patch net-next 18/20] net: sched: avoid ndo_setup_tc calls for TC_SETUP_CLS* Jiri Pirko
2017-10-17 20:06 ` [patch net-next 19/20] net: sched: remove unused classid field from tc_cls_common_offload Jiri Pirko
2017-10-17 20:06 ` [patch net-next 20/20] net: sched: remove unused is_classid_clsact_ingress/egress helpers Jiri Pirko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171017200615.4530-6-jiri@resnulli.us \
    --to=jiri@resnulli$(echo .)us \
    --cc=alexander.h.duyck@intel$(echo .)com \
    --cc=andrew@lunn$(echo .)ch \
    --cc=ast@kernel$(echo .)org \
    --cc=daniel@iogearbox$(echo .)net \
    --cc=davem@davemloft$(echo .)net \
    --cc=f.fainelli@gmail$(echo .)com \
    --cc=ganeshgr@chelsio$(echo .)com \
    --cc=idosch@mellanox$(echo .)com \
    --cc=jakub.kicinski@netronome$(echo .)com \
    --cc=jeffrey.t.kirsher@intel$(echo .)com \
    --cc=jhs@mojatatu$(echo .)com \
    --cc=john.hurley@netronome$(echo .)com \
    --cc=leonro@mellanox$(echo .)com \
    --cc=matanb@mellanox$(echo .)com \
    --cc=michael.chan@broadcom$(echo .)com \
    --cc=mlxsw@mellanox$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=pieter.jansenvanvuuren@netronome$(echo .)com \
    --cc=saeedm@mellanox$(echo .)com \
    --cc=simon.horman@netronome$(echo .)com \
    --cc=vivien.didelot@savoirfairelinux$(echo .)com \
    --cc=xiyou.wangcong@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox