diff mbox series

[SRU,F:linux-bluefield,v1,2/3] sched: act_sample: Implement stats_update callback

Message ID 20230403223841.252583-3-witu@nvidia.com
State New
Headers show
Series Support hardware stats for tc actions | expand

Commit Message

William Tu April 3, 2023, 10:38 p.m. UTC
From: Ido Schimmel <idosch@nvidia.com>

BugLink: https://bugs.launchpad.net/bugs/2015136

Implement this callback in order to get the offloaded stats added to the
kernel stats.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 58c04397f74b7e949751663ac1dbfb4e964c389d)
Signed-off-by: Paul Blakey <paulb@nvidia.com>
Signed-off-by: William Tu <witu@nvidia.com>
---
 net/sched/act_sample.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/net/sched/act_sample.c b/net/sched/act_sample.c
index ee3cefa180be..f04ac8c4822d 100644
--- a/net/sched/act_sample.c
+++ b/net/sched/act_sample.c
@@ -194,6 +194,16 @@  static int tcf_sample_act(struct sk_buff *skb, const struct tc_action *a,
 	return retval;
 }
 
+static void tcf_sample_stats_update(struct tc_action *a, u64 bytes, u64 packets,
+				    u64 drops, u64 lastuse, bool hw)
+{
+	struct tcf_sample *s = to_sample(a);
+	struct tcf_t *tm = &s->tcf_tm;
+
+	tcf_action_update_stats(a, bytes, packets, drops, hw);
+	tm->lastuse = max_t(u64, tm->lastuse, lastuse);
+}
+
 static int tcf_sample_dump(struct sk_buff *skb, struct tc_action *a,
 			   int bind, int ref)
 {
@@ -280,6 +290,7 @@  static struct tc_action_ops act_sample_ops = {
 	.id	  = TCA_ID_SAMPLE,
 	.owner	  = THIS_MODULE,
 	.act	  = tcf_sample_act,
+	.stats_update = tcf_sample_stats_update,
 	.dump	  = tcf_sample_dump,
 	.init	  = tcf_sample_init,
 	.cleanup  = tcf_sample_cleanup,