netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Edward Cree <ecree@solarflare.com>
To: Jamal Hadi Salim <jhs@mojatatu.com>,
	Jiri Pirko <jiri@resnulli.us>,
	"Pablo Neira Ayuso" <pablo@netfilter.org>,
	David Miller <davem@davemloft.net>
Cc: netdev <netdev@vger.kernel.org>,
	Cong Wang <xiyou.wangcong@gmail.com>,
	Andy Gospodarek <andy@greyhouse.net>,
	Anjali Singhai Jain <anjali.singhai@intel.com>,
	Jakub Kicinski <jakub.kicinski@netronome.com>,
	"Or Gerlitz" <gerlitz.or@gmail.com>
Subject: [RFC PATCH net-next 2/3] flow_offload: restore ability to collect separate stats per action
Date: Fri, 3 May 2019 16:06:55 +0100	[thread overview]
Message-ID: <alpine.LFD.2.21.1905031603340.11823@ehc-opti7040.uk.solarflarecom.com> (raw)

Introduce a new offload command TC_CLSFLOWER_STATS_BYINDEX, similar to
 the existing TC_CLSFLOWER_STATS but specifying an action_index (the
 tcfa_index of the action), which is called for each stats-having action
 on the rule.  Drivers should implement either, but not both, of these
 commands.

Signed-off-by: Edward Cree <ecree@solarflare.com>
---
 include/net/pkt_cls.h  |  2 ++
 net/sched/cls_flower.c | 30 ++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h
index d5e7a1af346f..0e33c52c23a8 100644
--- a/include/net/pkt_cls.h
+++ b/include/net/pkt_cls.h
@@ -762,6 +762,7 @@ enum tc_fl_command {
 	TC_CLSFLOWER_REPLACE,
 	TC_CLSFLOWER_DESTROY,
 	TC_CLSFLOWER_STATS,
+	TC_CLSFLOWER_STATS_BYINDEX,
 	TC_CLSFLOWER_TMPLT_CREATE,
 	TC_CLSFLOWER_TMPLT_DESTROY,
 };
@@ -773,6 +774,7 @@ struct tc_cls_flower_offload {
 	struct flow_rule *rule;
 	struct flow_stats stats;
 	u32 classid;
+	u32 action_index; /* for TC_CLSFLOWER_STATS_BYINDEX */
 };
 
 static inline struct flow_rule *
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index f6685fc53119..be339cd6a86e 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -474,6 +474,10 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f,
 {
 	struct tc_cls_flower_offload cls_flower = {};
 	struct tcf_block *block = tp->chain->block;
+#ifdef CONFIG_NET_CLS_ACT
+	struct tc_action *a;
+	int i;
+#endif
 
 	if (!rtnl_held)
 		rtnl_lock();
@@ -489,6 +493,32 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f,
 			      cls_flower.stats.pkts,
 			      cls_flower.stats.lastused);
 
+#ifdef CONFIG_NET_CLS_ACT
+	for (i = 0; i < f->exts.nr_actions; i++) {
+		a = f->exts.actions[i];
+
+		if (!a->ops->stats_update)
+			continue;
+		memset(&cls_flower, 0, sizeof(cls_flower));
+		tc_cls_common_offload_init(&cls_flower.common, tp, f->flags, NULL);
+		cls_flower.command = TC_CLSFLOWER_STATS_BYINDEX;
+		cls_flower.cookie = (unsigned long) f;
+		cls_flower.classid = f->res.classid;
+		cls_flower.action_index = a->tcfa_index;
+
+		tc_setup_cb_call(block, TC_SETUP_CLSFLOWER, &cls_flower, false);
+
+		/* Some ->stats_update() use percpu variables and must thus be
+		 * called with preemption disabled.
+		 */
+		preempt_disable();
+		a->ops->stats_update(a, cls_flower.stats.bytes,
+				     cls_flower.stats.pkts,
+				     cls_flower.stats.lastused, true);
+		preempt_enable();
+	}
+#endif
+
 	if (!rtnl_held)
 		rtnl_unlock();
 }

             reply	other threads:[~2019-05-03 15:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-03 15:06 Edward Cree [this message]
2019-05-04  6:27 ` [RFC PATCH net-next 2/3] flow_offload: restore ability to collect separate stats per action Jakub Kicinski
2019-05-06 12:41   ` Jamal Hadi Salim
2019-05-07 12:27     ` Edward Cree
2019-05-07 17:22       ` Jakub Kicinski
2019-05-08 14:02       ` Jamal Hadi Salim
2019-05-08 17:07         ` Edward Cree
2019-05-09 15:23           ` Jamal Hadi Salim

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=alpine.LFD.2.21.1905031603340.11823@ehc-opti7040.uk.solarflarecom.com \
    --to=ecree@solarflare.com \
    --cc=andy@greyhouse.net \
    --cc=anjali.singhai@intel.com \
    --cc=davem@davemloft.net \
    --cc=gerlitz.or@gmail.com \
    --cc=jakub.kicinski@netronome.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --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 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).