Linux Audio

Check our new training course

Loading...
Note: File does not exist in v3.1.
 1/* SPDX-License-Identifier: GPL-2.0 */
 2#ifndef __NET_TC_POLICE_H
 3#define __NET_TC_POLICE_H
 4
 5#include <net/act_api.h>
 6
 7struct tcf_police_params {
 8	int			tcfp_result;
 9	u32			tcfp_ewma_rate;
10	s64			tcfp_burst;
11	u32			tcfp_mtu;
12	s64			tcfp_mtu_ptoks;
13	struct psched_ratecfg	rate;
14	bool			rate_present;
15	struct psched_ratecfg	peak;
16	bool			peak_present;
17	struct rcu_head rcu;
18};
19
20struct tcf_police {
21	struct tc_action	common;
22	struct tcf_police_params __rcu *params;
23
24	spinlock_t		tcfp_lock ____cacheline_aligned_in_smp;
25	s64			tcfp_toks;
26	s64			tcfp_ptoks;
27	s64			tcfp_t_c;
28};
29
30#define to_police(pc) ((struct tcf_police *)pc)
31
32/* old policer structure from before tc actions */
33struct tc_police_compat {
34	u32			index;
35	int			action;
36	u32			limit;
37	u32			burst;
38	u32			mtu;
39	struct tc_ratespec	rate;
40	struct tc_ratespec	peakrate;
41};
42
43static inline bool is_tcf_police(const struct tc_action *act)
44{
45#ifdef CONFIG_NET_CLS_ACT
46	if (act->ops && act->ops->id == TCA_ID_POLICE)
47		return true;
48#endif
49	return false;
50}
51
52static inline u64 tcf_police_rate_bytes_ps(const struct tc_action *act)
53{
54	struct tcf_police *police = to_police(act);
55	struct tcf_police_params *params;
56
57	params = rcu_dereference_bh_rtnl(police->params);
58	return params->rate.rate_bytes_ps;
59}
60
61static inline s64 tcf_police_tcfp_burst(const struct tc_action *act)
62{
63	struct tcf_police *police = to_police(act);
64	struct tcf_police_params *params;
65
66	params = rcu_dereference_bh_rtnl(police->params);
67	return params->tcfp_burst;
68}
69
70#endif /* __NET_TC_POLICE_H */