diff mbox series

[SRU,F:linux-bluefield,1/7] net: qos: add tc police offloading action with max frame size limit

Message ID 1628018169-6826-2-git-send-email-bodong@nvidia.com
State New
Headers show
Series Add support for packet-per-second policing | expand

Commit Message

Bodong Wang Aug. 3, 2021, 7:16 p.m. UTC
From: Po Liu <Po.Liu@nxp.com>

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

Current police offloading support the 'burst'' and 'rate_bytes_ps'. Some
hardware own the capability to limit the frame size. If the frame size
larger than the setting, the frame would be dropped. For the police
action itself already accept the 'mtu' parameter in tc command. But not
extend to tc flower offloading. So extend 'mtu' to tc flower offloading.

Signed-off-by: Po Liu <Po.Liu@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 19e528dc9af29169fa7cdfa61071805fdef504c6)
Signed-off-by: Bodong Wang <bodong@nvidia.com>
---
 include/net/flow_offload.h     |  1 +
 include/net/tc_act/tc_police.h | 10 ++++++++++
 net/sched/cls_api.c            |  1 +
 3 files changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
index 4f442ab..faa9418 100644
--- a/include/net/flow_offload.h
+++ b/include/net/flow_offload.h
@@ -201,6 +201,7 @@  struct flow_action_entry {
 		struct {				/* FLOW_ACTION_POLICE */
 			s64			burst;
 			u64			rate_bytes_ps;
+			u32			mtu;
 		} police;
 		struct {				/* FLOW_ACTION_CT */
 			int action;
diff --git a/include/net/tc_act/tc_police.h b/include/net/tc_act/tc_police.h
index cfdc7cb..9bb9b05 100644
--- a/include/net/tc_act/tc_police.h
+++ b/include/net/tc_act/tc_police.h
@@ -67,4 +67,14 @@  static inline s64 tcf_police_tcfp_burst(const struct tc_action *act)
 	return params->tcfp_burst;
 }
 
+static inline u32 tcf_police_tcfp_mtu(const struct tc_action *act)
+{
+	struct tcf_police *police = to_police(act);
+	struct tcf_police_params *params;
+
+	params = rcu_dereference_protected(police->params,
+					   lockdep_is_held(&police->tcf_lock));
+	return params->tcfp_mtu;
+}
+
 #endif /* __NET_TC_POLICE_H */
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 9c9afc0..cdb51b5 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -3604,6 +3604,7 @@  int tc_setup_flow_action(struct flow_action *flow_action,
 			entry->police.burst = tcf_police_tcfp_burst(act);
 			entry->police.rate_bytes_ps =
 				tcf_police_rate_bytes_ps(act);
+			entry->police.mtu = tcf_police_tcfp_mtu(act);
 		} else if (is_tcf_ct(act)) {
 			entry->id = FLOW_ACTION_CT;
 			entry->ct.action = tcf_ct_action(act);