[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220816092338.12613-3-ozsh@nvidia.com>
Date: Tue, 16 Aug 2022 12:23:37 +0300
From: Oz Shlomo <ozsh@...dia.com>
To: <netdev@...r.kernel.org>
CC: Jiri Pirko <jiri@...dia.com>, Jamal Hadi Salim <jhs@...atatu.com>,
"Simon Horman" <simon.horman@...igine.com>,
Baowen Zheng <baowen.zheng@...igine.com>,
Vlad Buslov <vladbu@...dia.com>,
Ido Schimmel <idosch@...dia.com>, Roi Dayan <roid@...dia.com>,
Oz Shlomo <ozsh@...dia.com>
Subject: [ RFC net-next 2/3] net: flow_offload: add action stats api
The current offload api provides visibility to flow hw stats.
This works as long as the flow stats values apply to all the flow's
actions. However, this assumption breaks when an action, such as police,
decides to drop or jump over other actions.
Extend the flow_offload api to return stat record per action instance.
Use the per action stats value, if available, when updating the action
instance counters.
Signed-off-by: Oz Shlomo <ozsh@...dia.com>
---
include/net/flow_offload.h | 6 ++++++
include/net/pkt_cls.h | 26 ++++++++++++++++----------
net/sched/cls_flower.c | 4 +++-
net/sched/cls_matchall.c | 2 +-
4 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
index 2a9a9e42e7fd..5e1a34a76772 100644
--- a/include/net/flow_offload.h
+++ b/include/net/flow_offload.h
@@ -436,6 +436,11 @@ struct flow_stats {
bool used_hw_stats_valid;
};
+struct flow_act_stats {
+ unsigned int num_actions;
+ struct flow_stats stats[];
+};
+
static inline void flow_stats_update(struct flow_stats *flow_stats,
u64 bytes, u64 pkts,
u64 drops, u64 lastused,
@@ -583,6 +588,7 @@ struct flow_cls_offload {
struct flow_rule *rule;
struct flow_stats stats;
u32 classid;
+ struct flow_act_stats *act_stats;
};
enum offload_act_command {
diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h
index 27eac9e73c61..f5e5582aef17 100644
--- a/include/net/pkt_cls.h
+++ b/include/net/pkt_cls.h
@@ -269,24 +269,30 @@ static inline void tcf_exts_put_net(struct tcf_exts *exts)
static inline void
tcf_exts_hw_stats_update(const struct tcf_exts *exts,
- struct flow_stats *stats)
+ struct flow_stats *flow_stats,
+ struct flow_act_stats *act_stats)
{
#ifdef CONFIG_NET_CLS_ACT
int i;
for (i = 0; i < exts->nr_actions; i++) {
struct tc_action *a = exts->actions[i];
+ struct flow_stats *stats = flow_stats;
/* if stats from hw, just skip */
- if (tcf_action_update_hw_stats(a)) {
- preempt_disable();
- tcf_action_stats_update(a, stats->bytes, stats->pkts, stats->drops,
- stats->lastused, true);
- preempt_enable();
-
- a->used_hw_stats = stats->used_hw_stats;
- a->used_hw_stats_valid = stats->used_hw_stats_valid;
- }
+ if (!tcf_action_update_hw_stats(a))
+ continue;
+
+ if (act_stats)
+ stats = &act_stats->stats[i];
+
+ preempt_disable();
+ tcf_action_stats_update(a, stats->bytes, stats->pkts, stats->drops,
+ stats->lastused, true);
+ preempt_enable();
+
+ a->used_hw_stats = stats->used_hw_stats;
+ a->used_hw_stats_valid = stats->used_hw_stats_valid;
}
#endif
}
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index 7da3337c4356..7dc8a62796b5 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -499,7 +499,9 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f,
tc_setup_cb_call(block, TC_SETUP_CLSFLOWER, &cls_flower, false,
rtnl_held);
- tcf_exts_hw_stats_update(&f->exts, &cls_flower.stats);
+ tcf_exts_hw_stats_update(&f->exts, &cls_flower.stats, cls_flower.act_stats);
+
+ kfree(cls_flower.act_stats);
}
static void __fl_put(struct cls_fl_filter *f)
diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c
index b5520a9c35e6..0ba4392b93de 100644
--- a/net/sched/cls_matchall.c
+++ b/net/sched/cls_matchall.c
@@ -332,7 +332,7 @@ static void mall_stats_hw_filter(struct tcf_proto *tp,
tc_setup_cb_call(block, TC_SETUP_CLSMATCHALL, &cls_mall, false, true);
- tcf_exts_hw_stats_update(&head->exts, &cls_mall.stats);
+ tcf_exts_hw_stats_update(&head->exts, &cls_mall.stats, NULL);
}
static int mall_dump(struct net *net, struct tcf_proto *tp, void *fh,
--
1.8.3.1
Powered by blists - more mailing lists