[SRU][F:linux-bluefield][PATCH 5/7] flow_offload: add support for packet-per-second policing

Bodong Wang bodong at nvidia.com
Tue Aug 3 19:16:07 UTC 2021


From: Xingfeng Hu <xingfeng.hu at corigine.com>

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

Allow flow_offload API to configure packet-per-second policing using rate
and burst parameters.

Dummy implementations of tcf_police_rate_pkt_ps() and
tcf_police_burst_pkt() are supplied which return 0, the unconfigured state.
This is to facilitate splitting the offload, driver, and TC code portion of
this feature into separate patches with the aim of providing a logical flow
for review. And the implementation of these helpers will be filled out by a
follow-up patch.

Signed-off-by: Xingfeng Hu <xingfeng.hu at corigine.com>
Signed-off-by: Simon Horman <simon.horman at netronome.com>
Signed-off-by: Louis Peens <louis.peens at netronome.com>
Signed-off-by: David S. Miller <davem at davemloft.net>
(cherry picked from commit 25660156f4cc4cf0cb55deda69f999dab554b750)
Signed-off-by: Bodong Wang <bodong at nvidia.com>
---
 include/net/flow_offload.h     |  2 ++
 include/net/tc_act/tc_police.h | 12 ++++++++++++
 net/sched/cls_api.c            |  3 +++
 3 files changed, 17 insertions(+)

diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
index 5a29d204..e9686f7 100644
--- a/include/net/flow_offload.h
+++ b/include/net/flow_offload.h
@@ -202,6 +202,8 @@ struct flow_action_entry {
 			u32			index;
 			u32			burst;
 			u64			rate_bytes_ps;
+			u64			burst_pkt;
+			u64			rate_pkt_ps;
 			u32			mtu;
 		} police;
 		struct {				/* FLOW_ACTION_CT */
diff --git a/include/net/tc_act/tc_police.h b/include/net/tc_act/tc_police.h
index 6d1e26b..ae117f7 100644
--- a/include/net/tc_act/tc_police.h
+++ b/include/net/tc_act/tc_police.h
@@ -97,6 +97,18 @@ static inline u32 tcf_police_burst(const struct tc_action *act)
 	return burst;
 }
 
+static inline u64 tcf_police_rate_pkt_ps(const struct tc_action *act)
+{
+	/* Not implemented */
+	return 0;
+}
+
+static inline u32 tcf_police_burst_pkt(const struct tc_action *act)
+{
+	/* Not implemented */
+	return 0;
+}
+
 static inline u32 tcf_police_tcfp_mtu(const struct tc_action *act)
 {
 	struct tcf_police *police = to_police(act);
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 960bd36..0f1c58f 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -3604,6 +3604,9 @@ int tc_setup_flow_action(struct flow_action *flow_action,
 			entry->police.burst = tcf_police_burst(act);
 			entry->police.rate_bytes_ps =
 				tcf_police_rate_bytes_ps(act);
+			entry->police.burst_pkt = tcf_police_burst_pkt(act);
+			entry->police.rate_pkt_ps =
+				tcf_police_rate_pkt_ps(act);
 			entry->police.mtu = tcf_police_tcfp_mtu(act);
 			entry->police.index = act->tcfa_index;
 		} else if (is_tcf_ct(act)) {
-- 
1.8.3.1




More information about the kernel-team mailing list