[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190502094029.22526-2-joergen.andreasen@microchip.com>
Date: Thu, 2 May 2019 11:40:27 +0200
From: Joergen Andreasen <joergen.andreasen@...rochip.com>
To: <netdev@...r.kernel.org>
CC: Joergen Andreasen <joergen.andreasen@...rochip.com>,
Jamal Hadi Salim <jhs@...atatu.com>,
Cong Wang <xiyou.wangcong@...il.com>,
Jiri Pirko <jiri@...nulli.us>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
Microchip Linux Driver Support <UNGLinuxDriver@...rochip.com>,
"David S. Miller" <davem@...emloft.net>,
Ralf Baechle <ralf@...ux-mips.org>,
"Paul Burton" <paul.burton@...s.com>,
James Hogan <jhogan@...nel.org>, <linux-mips@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
Subject: [PATCH net-next 1/3] net/sched: act_police: move police parameters into separate header file
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@...rochip.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
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;
--
2.17.1
Powered by blists - more mailing lists