[SRU][F:linux-bluefield][PATCH v1 3/3] sched: act_pedit: Implement stats_update callback

William Tu witu at nvidia.com
Mon Apr 3 22:38:41 UTC 2023


From: Petr Machata <petrm at mellanox.com>

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

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

Reported-by: Alexander Petrovskiy <alexpe at mellanox.com>
Signed-off-by: Petr Machata <petrm at mellanox.com>
Signed-off-by: David S. Miller <davem at davemloft.net>
(cherry picked from commit d4d9d9c53bef8124e93cb232ed137d91daaf6965)
Signed-off-by: Paul Blakey <paulb at nvidia.com>
Signed-off-by: William Tu <witu at nvidia.com>
---
 net/sched/act_pedit.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c
index b07a015b91ac..3224320549ad 100644
--- a/net/sched/act_pedit.c
+++ b/net/sched/act_pedit.c
@@ -429,6 +429,16 @@ static int tcf_pedit_act(struct sk_buff *skb, const struct tc_action *a,
 	return p->tcf_action;
 }
 
+static void tcf_pedit_stats_update(struct tc_action *a, u64 bytes, u32 packets,
+				   u64 lastuse, bool hw)
+{
+	struct tcf_pedit *d = to_pedit(a);
+	struct tcf_t *tm = &d->tcf_tm;
+
+	tcf_action_update_stats(a, bytes, packets, false, hw);
+	tm->lastuse = max_t(u64, tm->lastuse, lastuse);
+}
+
 static int tcf_pedit_dump(struct sk_buff *skb, struct tc_action *a,
 			  int bind, int ref)
 {
@@ -505,6 +515,7 @@ static struct tc_action_ops act_pedit_ops = {
 	.id		=	TCA_ID_PEDIT,
 	.owner		=	THIS_MODULE,
 	.act		=	tcf_pedit_act,
+	.stats_update	=	tcf_pedit_stats_update,
 	.dump		=	tcf_pedit_dump,
 	.cleanup	=	tcf_pedit_cleanup,
 	.init		=	tcf_pedit_init,
-- 
2.34.1




More information about the kernel-team mailing list