new file mode 100644
@@ -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 */
@@ -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;
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