diff mbox series

[RFC,net-next,3/3] net/sched: act_api: update hw stats for tc action list

Message ID 20220816092338.12613-4-ozsh@nvidia.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series net: flow_offload: add support for per action hw stats | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 342 this patch: 342
netdev/cc_maintainers warning 5 maintainers not CCed: davem@davemloft.net xiyou.wangcong@gmail.com edumazet@google.com kuba@kernel.org pabeni@redhat.com
netdev/build_clang success Errors and warnings before: 5 this patch: 5
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 342 this patch: 342
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 37 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Oz Shlomo Aug. 16, 2022, 9:23 a.m. UTC
Currently action hw stats are updated during the tc filter dump sequence.
HW actions are also updated during the tc action dump sequence.
However, tc action dump does not update the hw stats for actions created
during filter instantiation.

Use the existing hw action api to update hw stats during tc action dump.

Signed-off-by: Oz Shlomo <ozsh@nvidia.com>

---
 net/sched/act_api.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 817065aa2833..5d7b6e438085 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -301,14 +301,11 @@  static int tcf_action_offload_add(struct tc_action *action,
 	return tcf_action_offload_add_ex(action, extack, NULL, NULL);
 }
 
-int tcf_action_update_hw_stats(struct tc_action *action)
+static int tcf_action_set_hw_stats(struct tc_action *action)
 {
 	struct flow_offload_action fl_act = {};
 	int err;
 
-	if (!tc_act_in_hw(action))
-		return -EOPNOTSUPP;
-
 	err = offload_action_init(&fl_act, action, FLOW_ACT_STATS, NULL);
 	if (err)
 		return err;
@@ -330,6 +327,14 @@  int tcf_action_update_hw_stats(struct tc_action *action)
 
 	return 0;
 }
+
+int tcf_action_update_hw_stats(struct tc_action *action)
+{
+	if (!tc_act_in_hw(action))
+		return -EOPNOTSUPP;
+
+	return tcf_action_set_hw_stats(action);
+}
 EXPORT_SYMBOL(tcf_action_update_hw_stats);
 
 static int tcf_action_offload_del_ex(struct tc_action *action,
@@ -543,6 +548,8 @@  static int tcf_dump_walker(struct tcf_idrinfo *idrinfo, struct sk_buff *skb,
 			index--;
 			goto nla_put_failure;
 		}
+		tcf_action_set_hw_stats(p);
+
 		err = (act_flags & TCA_ACT_FLAG_TERSE_DUMP) ?
 			tcf_action_dump_terse(skb, p, true) :
 			tcf_action_dump_1(skb, p, 0, 0);