xref: /OK3568_Linux_fs/kernel/include/net/tc_act/tc_mirred.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef __NET_TC_MIR_H
3*4882a593Smuzhiyun #define __NET_TC_MIR_H
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #include <net/act_api.h>
6*4882a593Smuzhiyun #include <linux/tc_act/tc_mirred.h>
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun struct tcf_mirred {
9*4882a593Smuzhiyun 	struct tc_action	common;
10*4882a593Smuzhiyun 	int			tcfm_eaction;
11*4882a593Smuzhiyun 	bool			tcfm_mac_header_xmit;
12*4882a593Smuzhiyun 	struct net_device __rcu	*tcfm_dev;
13*4882a593Smuzhiyun 	struct list_head	tcfm_list;
14*4882a593Smuzhiyun };
15*4882a593Smuzhiyun #define to_mirred(a) ((struct tcf_mirred *)a)
16*4882a593Smuzhiyun 
is_tcf_mirred_egress_redirect(const struct tc_action * a)17*4882a593Smuzhiyun static inline bool is_tcf_mirred_egress_redirect(const struct tc_action *a)
18*4882a593Smuzhiyun {
19*4882a593Smuzhiyun #ifdef CONFIG_NET_CLS_ACT
20*4882a593Smuzhiyun 	if (a->ops && a->ops->id == TCA_ID_MIRRED)
21*4882a593Smuzhiyun 		return to_mirred(a)->tcfm_eaction == TCA_EGRESS_REDIR;
22*4882a593Smuzhiyun #endif
23*4882a593Smuzhiyun 	return false;
24*4882a593Smuzhiyun }
25*4882a593Smuzhiyun 
is_tcf_mirred_egress_mirror(const struct tc_action * a)26*4882a593Smuzhiyun static inline bool is_tcf_mirred_egress_mirror(const struct tc_action *a)
27*4882a593Smuzhiyun {
28*4882a593Smuzhiyun #ifdef CONFIG_NET_CLS_ACT
29*4882a593Smuzhiyun 	if (a->ops && a->ops->id == TCA_ID_MIRRED)
30*4882a593Smuzhiyun 		return to_mirred(a)->tcfm_eaction == TCA_EGRESS_MIRROR;
31*4882a593Smuzhiyun #endif
32*4882a593Smuzhiyun 	return false;
33*4882a593Smuzhiyun }
34*4882a593Smuzhiyun 
is_tcf_mirred_ingress_redirect(const struct tc_action * a)35*4882a593Smuzhiyun static inline bool is_tcf_mirred_ingress_redirect(const struct tc_action *a)
36*4882a593Smuzhiyun {
37*4882a593Smuzhiyun #ifdef CONFIG_NET_CLS_ACT
38*4882a593Smuzhiyun 	if (a->ops && a->ops->id == TCA_ID_MIRRED)
39*4882a593Smuzhiyun 		return to_mirred(a)->tcfm_eaction == TCA_INGRESS_REDIR;
40*4882a593Smuzhiyun #endif
41*4882a593Smuzhiyun 	return false;
42*4882a593Smuzhiyun }
43*4882a593Smuzhiyun 
is_tcf_mirred_ingress_mirror(const struct tc_action * a)44*4882a593Smuzhiyun static inline bool is_tcf_mirred_ingress_mirror(const struct tc_action *a)
45*4882a593Smuzhiyun {
46*4882a593Smuzhiyun #ifdef CONFIG_NET_CLS_ACT
47*4882a593Smuzhiyun 	if (a->ops && a->ops->id == TCA_ID_MIRRED)
48*4882a593Smuzhiyun 		return to_mirred(a)->tcfm_eaction == TCA_INGRESS_MIRROR;
49*4882a593Smuzhiyun #endif
50*4882a593Smuzhiyun 	return false;
51*4882a593Smuzhiyun }
52*4882a593Smuzhiyun 
tcf_mirred_dev(const struct tc_action * a)53*4882a593Smuzhiyun static inline struct net_device *tcf_mirred_dev(const struct tc_action *a)
54*4882a593Smuzhiyun {
55*4882a593Smuzhiyun 	return rtnl_dereference(to_mirred(a)->tcfm_dev);
56*4882a593Smuzhiyun }
57*4882a593Smuzhiyun 
58*4882a593Smuzhiyun #endif /* __NET_TC_MIR_H */
59