162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef __NET_TC_MIR_H 362306a36Sopenharmony_ci#define __NET_TC_MIR_H 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#include <net/act_api.h> 662306a36Sopenharmony_ci#include <linux/tc_act/tc_mirred.h> 762306a36Sopenharmony_ci 862306a36Sopenharmony_cistruct tcf_mirred { 962306a36Sopenharmony_ci struct tc_action common; 1062306a36Sopenharmony_ci int tcfm_eaction; 1162306a36Sopenharmony_ci bool tcfm_mac_header_xmit; 1262306a36Sopenharmony_ci struct net_device __rcu *tcfm_dev; 1362306a36Sopenharmony_ci netdevice_tracker tcfm_dev_tracker; 1462306a36Sopenharmony_ci struct list_head tcfm_list; 1562306a36Sopenharmony_ci}; 1662306a36Sopenharmony_ci#define to_mirred(a) ((struct tcf_mirred *)a) 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_cistatic inline bool is_tcf_mirred_egress_redirect(const struct tc_action *a) 1962306a36Sopenharmony_ci{ 2062306a36Sopenharmony_ci#ifdef CONFIG_NET_CLS_ACT 2162306a36Sopenharmony_ci if (a->ops && a->ops->id == TCA_ID_MIRRED) 2262306a36Sopenharmony_ci return to_mirred(a)->tcfm_eaction == TCA_EGRESS_REDIR; 2362306a36Sopenharmony_ci#endif 2462306a36Sopenharmony_ci return false; 2562306a36Sopenharmony_ci} 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_cistatic inline bool is_tcf_mirred_egress_mirror(const struct tc_action *a) 2862306a36Sopenharmony_ci{ 2962306a36Sopenharmony_ci#ifdef CONFIG_NET_CLS_ACT 3062306a36Sopenharmony_ci if (a->ops && a->ops->id == TCA_ID_MIRRED) 3162306a36Sopenharmony_ci return to_mirred(a)->tcfm_eaction == TCA_EGRESS_MIRROR; 3262306a36Sopenharmony_ci#endif 3362306a36Sopenharmony_ci return false; 3462306a36Sopenharmony_ci} 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_cistatic inline bool is_tcf_mirred_ingress_redirect(const struct tc_action *a) 3762306a36Sopenharmony_ci{ 3862306a36Sopenharmony_ci#ifdef CONFIG_NET_CLS_ACT 3962306a36Sopenharmony_ci if (a->ops && a->ops->id == TCA_ID_MIRRED) 4062306a36Sopenharmony_ci return to_mirred(a)->tcfm_eaction == TCA_INGRESS_REDIR; 4162306a36Sopenharmony_ci#endif 4262306a36Sopenharmony_ci return false; 4362306a36Sopenharmony_ci} 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_cistatic inline bool is_tcf_mirred_ingress_mirror(const struct tc_action *a) 4662306a36Sopenharmony_ci{ 4762306a36Sopenharmony_ci#ifdef CONFIG_NET_CLS_ACT 4862306a36Sopenharmony_ci if (a->ops && a->ops->id == TCA_ID_MIRRED) 4962306a36Sopenharmony_ci return to_mirred(a)->tcfm_eaction == TCA_INGRESS_MIRROR; 5062306a36Sopenharmony_ci#endif 5162306a36Sopenharmony_ci return false; 5262306a36Sopenharmony_ci} 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_cistatic inline struct net_device *tcf_mirred_dev(const struct tc_action *a) 5562306a36Sopenharmony_ci{ 5662306a36Sopenharmony_ci return rtnl_dereference(to_mirred(a)->tcfm_dev); 5762306a36Sopenharmony_ci} 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci#endif /* __NET_TC_MIR_H */ 60