1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 21da177e4SLinus Torvalds #ifndef __NET_TC_MIR_H 31da177e4SLinus Torvalds #define __NET_TC_MIR_H 41da177e4SLinus Torvalds 51da177e4SLinus Torvalds #include <net/act_api.h> 6229d2850SSridhar Samudrala #include <linux/tc_act/tc_mirred.h> 71da177e4SLinus Torvalds 8e9ce1cd3SDavid S. Miller struct tcf_mirred { 9ec0595ccSWANG Cong struct tc_action common; 10e9ce1cd3SDavid S. Miller int tcfm_eaction; 11*42f39036SVictor Nogueira u32 tcfm_blockid; 1216577923SShmulik Ladkani bool tcfm_mac_header_xmit; 132ee22a90SEric Dumazet struct net_device __rcu *tcfm_dev; 14ada066b2SEric Dumazet netdevice_tracker tcfm_dev_tracker; 153b87956eSstephen hemminger struct list_head tcfm_list; 161da177e4SLinus Torvalds }; 17a85a970aSWANG Cong #define to_mirred(a) ((struct tcf_mirred *)a) 181da177e4SLinus Torvalds is_tcf_mirred_egress_redirect(const struct tc_action * a)195724b8b5SShmulik Ladkanistatic inline bool is_tcf_mirred_egress_redirect(const struct tc_action *a) 20229d2850SSridhar Samudrala { 21229d2850SSridhar Samudrala #ifdef CONFIG_NET_CLS_ACT 22eddd2cf1SEli Cohen if (a->ops && a->ops->id == TCA_ID_MIRRED) 23229d2850SSridhar Samudrala return to_mirred(a)->tcfm_eaction == TCA_EGRESS_REDIR; 24229d2850SSridhar Samudrala #endif 25229d2850SSridhar Samudrala return false; 26229d2850SSridhar Samudrala } 27229d2850SSridhar Samudrala is_tcf_mirred_egress_mirror(const struct tc_action * a)285724b8b5SShmulik Ladkanistatic inline bool is_tcf_mirred_egress_mirror(const struct tc_action *a) 2956a20680SYotam Gigi { 3056a20680SYotam Gigi #ifdef CONFIG_NET_CLS_ACT 31eddd2cf1SEli Cohen if (a->ops && a->ops->id == TCA_ID_MIRRED) 3256a20680SYotam Gigi return to_mirred(a)->tcfm_eaction == TCA_EGRESS_MIRROR; 3356a20680SYotam Gigi #endif 3456a20680SYotam Gigi return false; 3556a20680SYotam Gigi } 3656a20680SYotam Gigi is_tcf_mirred_ingress_redirect(const struct tc_action * a)37d7609c96SJohn Hurleystatic inline bool is_tcf_mirred_ingress_redirect(const struct tc_action *a) 38d7609c96SJohn Hurley { 39d7609c96SJohn Hurley #ifdef CONFIG_NET_CLS_ACT 40d7609c96SJohn Hurley if (a->ops && a->ops->id == TCA_ID_MIRRED) 41d7609c96SJohn Hurley return to_mirred(a)->tcfm_eaction == TCA_INGRESS_REDIR; 42d7609c96SJohn Hurley #endif 43d7609c96SJohn Hurley return false; 44d7609c96SJohn Hurley } 45d7609c96SJohn Hurley is_tcf_mirred_ingress_mirror(const struct tc_action * a)46d7609c96SJohn Hurleystatic inline bool is_tcf_mirred_ingress_mirror(const struct tc_action *a) 47d7609c96SJohn Hurley { 48d7609c96SJohn Hurley #ifdef CONFIG_NET_CLS_ACT 49d7609c96SJohn Hurley if (a->ops && a->ops->id == TCA_ID_MIRRED) 50d7609c96SJohn Hurley return to_mirred(a)->tcfm_eaction == TCA_INGRESS_MIRROR; 51d7609c96SJohn Hurley #endif 52d7609c96SJohn Hurley return false; 53d7609c96SJohn Hurley } 54d7609c96SJohn Hurley tcf_mirred_dev(const struct tc_action * a)559f8a739eSCong Wangstatic inline struct net_device *tcf_mirred_dev(const struct tc_action *a) 56229d2850SSridhar Samudrala { 579f8a739eSCong Wang return rtnl_dereference(to_mirred(a)->tcfm_dev); 58229d2850SSridhar Samudrala } 59229d2850SSridhar Samudrala 60e9ce1cd3SDavid S. Miller #endif /* __NET_TC_MIR_H */ 61