From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: netdev@vger.kernel.org
Cc: jiri@resnulli.us, gerlitz.or@gmail.com,
sridhar.samudrala@intel.com, oss-drivers@netronome.com,
john.hurley@netronome.com
Subject: [RFC net-next 3/4] net: sched: cls_flower: implement offload tcf_proto_op
Date: Thu, 24 May 2018 19:25:38 -0700 [thread overview]
Message-ID: <20180525022539.6799-4-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <20180525022539.6799-1-jakub.kicinski@netronome.com>
From: John Hurley <john.hurley@netronome.com>
Add the offload tcf_proto_op in flower to generate an offload message for
each filter in the given tcf_proto. Call the specified callback with this
new offload message. The function only returns an error if the callback
rejects adding a 'hardware only' rule.
A filter contains a flag to indicate if it is in hardware or not. To
ensure the offload function properly maintains this flag, keep a reference
counter for the number of instances of the filter that are in hardware.
Only update the flag when this counter changes from or to 0.
Signed-off-by: John Hurley <john.hurley@netronome.com>
---
net/sched/cls_flower.c | 51 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index eacaaf803914..c23d338df6a1 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -90,6 +90,7 @@ struct cls_fl_filter {
struct list_head list;
u32 handle;
u32 flags;
+ u32 in_hw_count;
union {
struct work_struct work;
struct rcu_head rcu;
@@ -289,6 +290,7 @@ static int fl_hw_replace_filter(struct tcf_proto *tp,
fl_hw_destroy_filter(tp, f, NULL);
return err;
} else if (err > 0) {
+ f->in_hw_count = err;
tcf_block_offload_inc(block, &f->flags);
}
@@ -1092,6 +1094,54 @@ static void fl_walk(struct tcf_proto *tp, struct tcf_walker *arg)
}
}
+static int fl_offload(struct tcf_proto *tp, bool add, tc_setup_cb_t *cb,
+ void *cb_priv, struct netlink_ext_ack *extack)
+{
+ struct cls_fl_head *head = rtnl_dereference(tp->root);
+ struct tc_cls_flower_offload cls_flower = {};
+ struct tcf_block *block = tp->chain->block;
+ struct fl_flow_mask *mask;
+ struct cls_fl_filter *f;
+ int err;
+
+ list_for_each_entry(mask, &head->masks, list) {
+ list_for_each_entry(f, &mask->filters, list) {
+ if (tc_skip_hw(f->flags))
+ continue;
+
+ tc_cls_common_offload_init(&cls_flower.common, tp,
+ f->flags, extack);
+ cls_flower.command = add ?
+ TC_CLSFLOWER_REPLACE : TC_CLSFLOWER_DESTROY;
+ cls_flower.cookie = (unsigned long)f;
+ cls_flower.dissector = &mask->dissector;
+ cls_flower.mask = &f->mkey;
+ cls_flower.key = &f->key;
+ cls_flower.exts = &f->exts;
+ cls_flower.classid = f->res.classid;
+
+ err = cb(TC_SETUP_CLSFLOWER, &cls_flower, cb_priv);
+ if (err) {
+ if (add && tc_skip_sw(f->flags))
+ return err;
+ continue;
+ }
+
+ if (add) {
+ if (!f->in_hw_count)
+ tcf_block_offload_inc(block, &f->flags);
+ f->in_hw_count++;
+ } else {
+ f->in_hw_count--;
+ if (!f->in_hw_count)
+ tcf_block_offload_dec(block, &f->flags);
+ }
+ }
+ }
+
+ return 0;
+}
+
static int fl_dump_key_val(struct sk_buff *skb,
void *val, int val_type,
void *mask, int mask_type, int len)
@@ -1443,6 +1493,7 @@ static struct tcf_proto_ops cls_fl_ops __read_mostly = {
.change = fl_change,
.delete = fl_delete,
.walk = fl_walk,
+ .offload = fl_offload,
.dump = fl_dump,
.bind_class = fl_bind_class,
.owner = THIS_MODULE,
--
2.17.0
next prev parent reply other threads:[~2018-05-25 2:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-25 2:25 [RFC net-next 0/4] net: sched: support replay of filter offload when binding to block Jakub Kicinski
2018-05-25 2:25 ` [RFC net-next 1/4] net: sched: pass extack pointer to block binds and cb registration Jakub Kicinski
2018-05-25 2:25 ` [RFC net-next 2/4] net: sched: add tcf_proto_op to offload a rule Jakub Kicinski
2018-05-25 2:25 ` Jakub Kicinski [this message]
2018-05-25 2:25 ` [RFC net-next 4/4] net: sched: cls_matchall: implement offload tcf_proto_op Jakub Kicinski
2018-05-28 10:48 ` [RFC net-next 0/4] net: sched: support replay of filter offload when binding to block Or Gerlitz
2018-05-28 20:02 ` Jakub Kicinski
2018-05-30 15:59 ` Or Gerlitz
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=20180525022539.6799-4-jakub.kicinski@netronome.com \
--to=jakub.kicinski@netronome.com \
--cc=gerlitz.or@gmail.com \
--cc=jiri@resnulli.us \
--cc=john.hurley@netronome.com \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@netronome.com \
--cc=sridhar.samudrala@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).