1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* 3 * Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us> 4 */ 5 6 #ifndef __NET_TC_VLAN_H 7 #define __NET_TC_VLAN_H 8 9 #include <net/act_api.h> 10 #include <linux/tc_act/tc_vlan.h> 11 12 struct tcf_vlan_params { 13 int tcfv_action; 14 unsigned char tcfv_push_dst[ETH_ALEN]; 15 unsigned char tcfv_push_src[ETH_ALEN]; 16 u16 tcfv_push_vid; 17 __be16 tcfv_push_proto; 18 u8 tcfv_push_prio; 19 struct rcu_head rcu; 20 }; 21 22 struct tcf_vlan { 23 struct tc_action common; 24 struct tcf_vlan_params __rcu *vlan_p; 25 }; 26 #define to_vlan(a) ((struct tcf_vlan *)a) 27 28 static inline bool is_tcf_vlan(const struct tc_action *a) 29 { 30 #ifdef CONFIG_NET_CLS_ACT 31 if (a->ops && a->ops->id == TCA_ID_VLAN) 32 return true; 33 #endif 34 return false; 35 } 36 37 static inline u32 tcf_vlan_action(const struct tc_action *a) 38 { 39 u32 tcfv_action; 40 41 rcu_read_lock(); 42 tcfv_action = rcu_dereference(to_vlan(a)->vlan_p)->tcfv_action; 43 rcu_read_unlock(); 44 45 return tcfv_action; 46 } 47 48 static inline u16 tcf_vlan_push_vid(const struct tc_action *a) 49 { 50 u16 tcfv_push_vid; 51 52 rcu_read_lock(); 53 tcfv_push_vid = rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_vid; 54 rcu_read_unlock(); 55 56 return tcfv_push_vid; 57 } 58 59 static inline __be16 tcf_vlan_push_proto(const struct tc_action *a) 60 { 61 __be16 tcfv_push_proto; 62 63 rcu_read_lock(); 64 tcfv_push_proto = rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_proto; 65 rcu_read_unlock(); 66 67 return tcfv_push_proto; 68 } 69 70 static inline u8 tcf_vlan_push_prio(const struct tc_action *a) 71 { 72 u8 tcfv_push_prio; 73 74 rcu_read_lock(); 75 tcfv_push_prio = rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_prio; 76 rcu_read_unlock(); 77 78 return tcfv_push_prio; 79 } 80 #endif /* __NET_TC_VLAN_H */ 81