diff mbox series

[net-next,1/3] net/sched: act_police: move police parameters into separate header file

Message ID 20190502094029.22526-2-joergen.andreasen@microchip.com
State Changes Requested
Delegated to: David Miller
Headers show
Series Add hw offload of TC police on MSCC ocelot | expand

Commit Message

Joergen Andreasen May 2, 2019, 9:40 a.m. UTC
Hardware offloading a policer requires access to it's parameters.
This is now possible by including net/tc_act/tc_police.h.

Signed-off-by: Joergen Andreasen <joergen.andreasen@microchip.com>
---
 include/net/tc_act/tc_police.h | 41 ++++++++++++++++++++++++++++++++++
 net/sched/act_police.c         | 27 +---------------------
 2 files changed, 42 insertions(+), 26 deletions(-)
 create mode 100644 include/net/tc_act/tc_police.h

Comments

Jiri Pirko May 2, 2019, 8:38 p.m. UTC | #1
Thu, May 02, 2019 at 11:40:27AM CEST, joergen.andreasen@microchip.com wrote:
>Hardware offloading a policer requires access to it's parameters.
>This is now possible by including net/tc_act/tc_police.h.
>
>Signed-off-by: Joergen Andreasen <joergen.andreasen@microchip.com>

Acked-by: Jiri Pirko <jiri@mellanox.com>
diff mbox series

Patch

diff --git a/include/net/tc_act/tc_police.h b/include/net/tc_act/tc_police.h
new file mode 100644
index 000000000000..052dc5f37aa9
--- /dev/null
+++ b/include/net/tc_act/tc_police.h
@@ -0,0 +1,41 @@ 
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __NET_TC_POLICE_H
+#define __NET_TC_POLICE_H
+
+#include <net/act_api.h>
+
+struct tcf_police_params {
+	int			tcfp_result;
+	u32			tcfp_ewma_rate;
+	s64			tcfp_burst;
+	u32			tcfp_mtu;
+	s64			tcfp_mtu_ptoks;
+	struct psched_ratecfg	rate;
+	bool			rate_present;
+	struct psched_ratecfg	peak;
+	bool			peak_present;
+	struct rcu_head rcu;
+};
+
+struct tcf_police {
+	struct tc_action	common;
+	struct tcf_police_params __rcu *params;
+
+	spinlock_t		tcfp_lock ____cacheline_aligned_in_smp;
+	s64			tcfp_toks;
+	s64			tcfp_ptoks;
+	s64			tcfp_t_c;
+};
+
+#define to_police(pc) ((struct tcf_police *)pc)
+
+static inline bool is_tcf_police(const struct tc_action *a)
+{
+#ifdef CONFIG_NET_CLS_ACT
+	if (a->ops && a->ops->id == TCA_ID_POLICE)
+		return true;
+#endif
+	return false;
+}
+
+#endif /* __NET_TC_POLICE_H */
diff --git a/net/sched/act_police.c b/net/sched/act_police.c
index 2b8581f6ab51..5cb053f2c7b1 100644
--- a/net/sched/act_police.c
+++ b/net/sched/act_police.c
@@ -19,35 +19,10 @@ 
 #include <linux/rtnetlink.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <net/act_api.h>
+#include <net/tc_act/tc_police.h>
 #include <net/netlink.h>
 #include <net/pkt_cls.h>
 
-struct tcf_police_params {
-	int			tcfp_result;
-	u32			tcfp_ewma_rate;
-	s64			tcfp_burst;
-	u32			tcfp_mtu;
-	s64			tcfp_mtu_ptoks;
-	struct psched_ratecfg	rate;
-	bool			rate_present;
-	struct psched_ratecfg	peak;
-	bool			peak_present;
-	struct rcu_head rcu;
-};
-
-struct tcf_police {
-	struct tc_action	common;
-	struct tcf_police_params __rcu *params;
-
-	spinlock_t		tcfp_lock ____cacheline_aligned_in_smp;
-	s64			tcfp_toks;
-	s64			tcfp_ptoks;
-	s64			tcfp_t_c;
-};
-
-#define to_police(pc) ((struct tcf_police *)pc)
-
 /* old policer structure from before tc actions */
 struct tc_police_compat {
 	u32			index;