All of lore.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 v2 01/20] net: sched: add block bind/unbind notif. and extended block_get/put
Date: Thu, 19 Oct 2017 15:50:29 +0200	[thread overview]
Message-ID: <20171019135048.4306-2-jiri@resnulli.us> (raw)
In-Reply-To: <20171019135048.4306-1-jiri@resnulli.us>

From: Jiri Pirko <jiri@mellanox.com>

Introduce new type of ndo_setup_tc message to propage binding/unbinding
of a block to driver. Call this ndo whenever qdisc gets/puts a block.
Alongside with this, there's need to propagate binder type from qdisc
code down to the notifier. So introduce extended variants of
block_get/put in order to pass this info.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
v1->v2:
- move new enum value to the end
---
 include/linux/netdevice.h |  1 +
 include/net/pkt_cls.h     | 40 +++++++++++++++++++++++++++++++++
 net/sched/cls_api.c       | 56 ++++++++++++++++++++++++++++++++++++++++++++---
 3 files changed, 94 insertions(+), 3 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index bf014af..4de5b08 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -775,6 +775,7 @@ enum tc_setup_type {
 	TC_SETUP_CLSFLOWER,
 	TC_SETUP_CLSMATCHALL,
 	TC_SETUP_CLSBPF,
+	TC_SETUP_BLOCK,
 };
 
 /* These structures hold the attributes of xdp state that are being passed
diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h
index 49a143e..41bc7d7 100644
--- a/include/net/pkt_cls.h
+++ b/include/net/pkt_cls.h
@@ -17,13 +17,27 @@ struct tcf_walker {
 int register_tcf_proto_ops(struct tcf_proto_ops *ops);
 int unregister_tcf_proto_ops(struct tcf_proto_ops *ops);
 
+enum tcf_block_binder_type {
+	TCF_BLOCK_BINDER_TYPE_UNSPEC,
+};
+
+struct tcf_block_ext_info {
+	enum tcf_block_binder_type binder_type;
+};
+
 #ifdef CONFIG_NET_CLS
 struct tcf_chain *tcf_chain_get(struct tcf_block *block, u32 chain_index,
 				bool create);
 void tcf_chain_put(struct tcf_chain *chain);
 int tcf_block_get(struct tcf_block **p_block,
 		  struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q);
+int tcf_block_get_ext(struct tcf_block **p_block,
+		      struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q,
+		      struct tcf_block_ext_info *ei);
 void tcf_block_put(struct tcf_block *block);
+void tcf_block_put_ext(struct tcf_block *block,
+		       struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q,
+		       struct tcf_block_ext_info *ei);
 
 static inline struct Qdisc *tcf_block_q(struct tcf_block *block)
 {
@@ -46,10 +60,25 @@ int tcf_block_get(struct tcf_block **p_block,
 	return 0;
 }
 
+static inline
+int tcf_block_get_ext(struct tcf_block **p_block,
+		      struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q,
+		      struct tcf_block_ext_info *ei)
+{
+	return 0;
+}
+
 static inline void tcf_block_put(struct tcf_block *block)
 {
 }
 
+static inline
+void tcf_block_put_ext(struct tcf_block *block,
+		       struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q,
+		       struct tcf_block_ext_info *ei)
+{
+}
+
 static inline struct Qdisc *tcf_block_q(struct tcf_block *block)
 {
 	return NULL;
@@ -434,6 +463,17 @@ tcf_match_indev(struct sk_buff *skb, int ifindex)
 int tc_setup_cb_call(struct tcf_exts *exts, enum tc_setup_type type,
 		     void *type_data, bool err_stop);
 
+enum tc_block_command {
+	TC_BLOCK_BIND,
+	TC_BLOCK_UNBIND,
+};
+
+struct tc_block_offload {
+	enum tc_block_command command;
+	enum tcf_block_binder_type binder_type;
+	struct tcf_block *block;
+};
+
 struct tc_cls_common_offload {
 	u32 chain_index;
 	__be16 protocol;
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 2e8e87f..92dce26 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -240,8 +240,36 @@ tcf_chain_filter_chain_ptr_set(struct tcf_chain *chain,
 	chain->p_filter_chain = p_filter_chain;
 }
 
-int tcf_block_get(struct tcf_block **p_block,
-		  struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q)
+static void tcf_block_offload_cmd(struct tcf_block *block, struct Qdisc *q,
+				  struct tcf_block_ext_info *ei,
+				  enum tc_block_command command)
+{
+	struct net_device *dev = q->dev_queue->dev;
+	struct tc_block_offload bo = {};
+
+	if (!tc_can_offload(dev))
+		return;
+	bo.command = command;
+	bo.binder_type = ei->binder_type;
+	bo.block = block;
+	dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_BLOCK, &bo);
+}
+
+static void tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q,
+				   struct tcf_block_ext_info *ei)
+{
+	tcf_block_offload_cmd(block, q, ei, TC_BLOCK_BIND);
+}
+
+static void tcf_block_offload_unbind(struct tcf_block *block, struct Qdisc *q,
+				     struct tcf_block_ext_info *ei)
+{
+	tcf_block_offload_cmd(block, q, ei, TC_BLOCK_UNBIND);
+}
+
+int tcf_block_get_ext(struct tcf_block **p_block,
+		      struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q,
+		      struct tcf_block_ext_info *ei)
 {
 	struct tcf_block *block = kzalloc(sizeof(*block), GFP_KERNEL);
 	struct tcf_chain *chain;
@@ -259,6 +287,7 @@ int tcf_block_get(struct tcf_block **p_block,
 	tcf_chain_filter_chain_ptr_set(chain, p_filter_chain);
 	block->net = qdisc_net(q);
 	block->q = q;
+	tcf_block_offload_bind(block, q, ei);
 	*p_block = block;
 	return 0;
 
@@ -266,15 +295,28 @@ int tcf_block_get(struct tcf_block **p_block,
 	kfree(block);
 	return err;
 }
+EXPORT_SYMBOL(tcf_block_get_ext);
+
+int tcf_block_get(struct tcf_block **p_block,
+		  struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q)
+{
+	struct tcf_block_ext_info ei = {0, };
+
+	return tcf_block_get_ext(p_block, p_filter_chain, q, &ei);
+}
 EXPORT_SYMBOL(tcf_block_get);
 
-void tcf_block_put(struct tcf_block *block)
+void tcf_block_put_ext(struct tcf_block *block,
+		       struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q,
+		       struct tcf_block_ext_info *ei)
 {
 	struct tcf_chain *chain, *tmp;
 
 	if (!block)
 		return;
 
+	tcf_block_offload_unbind(block, q, ei);
+
 	/* XXX: Standalone actions are not allowed to jump to any chain, and
 	 * bound actions should be all removed after flushing. However,
 	 * filters are destroyed in RCU callbacks, we have to hold the chains
@@ -302,6 +344,14 @@ void tcf_block_put(struct tcf_block *block)
 		tcf_chain_put(chain);
 	kfree(block);
 }
+EXPORT_SYMBOL(tcf_block_put_ext);
+
+void tcf_block_put(struct tcf_block *block)
+{
+	struct tcf_block_ext_info ei = {0, };
+
+	tcf_block_put_ext(block, NULL, block->q, &ei);
+}
 EXPORT_SYMBOL(tcf_block_put);
 
 /* Main classifier routine: scans classifier chain attached
-- 
2.9.5

  reply	other threads:[~2017-10-19 13:50 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-19 13:50 [patch net-next v2 00/20] net: sched: convert cls ndo_setup_tc offload calls to per-block callbacks Jiri Pirko
2017-10-19 13:50 ` Jiri Pirko [this message]
2017-10-19 13:50 ` [patch net-next v2 02/20] net: sched: use extended variants of block_get/put in ingress and clsact qdiscs Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 03/20] net: sched: introduce per-block callbacks Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 04/20] net: sched: use tc_setup_cb_call to call " Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 05/20] net: sched: cls_matchall: call block callbacks for offload Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 06/20] net: sched: cls_u32: swap u32_remove_hw_knode and u32_remove_hw_hnode Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 07/20] net: sched: cls_u32: call block callbacks for offload Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 08/20] net: sched: cls_bpf: " Jiri Pirko
2017-11-01  0:44   ` Jakub Kicinski
2017-11-01  8:33     ` Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 09/20] mlxsw: spectrum: Convert ndo_setup_tc offloads to block callbacks Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 10/20] mlx5e: " Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 11/20] bnxt: " Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 12/20] cxgb4: " Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 13/20] ixgbe: " Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 14/20] mlx5e_rep: " Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 15/20] nfp: flower: " Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 16/20] nfp: bpf: " Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 17/20] dsa: " Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 18/20] net: sched: avoid ndo_setup_tc calls for TC_SETUP_CLS* Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 19/20] net: sched: remove unused classid field from tc_cls_common_offload Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 20/20] net: sched: remove unused is_classid_clsact_ingress/egress helpers Jiri Pirko
2017-10-21  2:04 ` [patch net-next v2 00/20] net: sched: convert cls ndo_setup_tc offload calls to per-block callbacks David Miller
2017-10-24 16:01   ` Alexander Duyck
2017-10-24 16:24     ` Alexander Duyck
     [not found]       ` <CAJ3xEMgdRBEuv0hb_G43zJXXRy=PWgY2tdHuwDN0Opc2NVF35g@mail.gmail.com>
2017-10-24 17:03         ` Or Gerlitz
2017-10-24 17:22         ` Nambiar, Amritha
2017-10-25  8:36       ` Jiri Pirko
2017-10-25 12:15     ` Jiri Pirko
     [not found]       ` <aaa66a3d-766b-f758-692a-eba7f5a8702f@mellanox.com>
2017-10-25 13:42         ` Jiri Pirko
2017-10-25 13:48           ` Or Gerlitz
2017-10-26 20:24       ` Nambiar, Amritha
2017-10-27  7:27         ` Jiri Pirko
2017-10-28  0:52           ` Jakub Kicinski
2017-10-28  7:20             ` Jiri Pirko
2017-10-28  7:53               ` Jakub Kicinski
2017-10-28  8:43                 ` Jiri Pirko
2017-10-28 17:17                   ` Jakub Kicinski
2017-10-29  7:26                     ` Jiri Pirko
2017-10-31 10:46                       ` 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=20171019135048.4306-2-jiri@resnulli.us \
    --to=jiri@resnulli.us \
    --cc=alexander.h.duyck@intel.com \
    --cc=andrew@lunn.ch \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=ganeshgr@chelsio.com \
    --cc=idosch@mellanox.com \
    --cc=jakub.kicinski@netronome.com \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=jhs@mojatatu.com \
    --cc=john.hurley@netronome.com \
    --cc=leonro@mellanox.com \
    --cc=matanb@mellanox.com \
    --cc=michael.chan@broadcom.com \
    --cc=mlxsw@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=pieter.jansenvanvuuren@netronome.com \
    --cc=saeedm@mellanox.com \
    --cc=simon.horman@netronome.com \
    --cc=vivien.didelot@savoirfairelinux.com \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.