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 bool tcfv_push_prio_exists; 20 struct rcu_head rcu; 21 }; 22 23 struct tcf_vlan { 24 struct tc_action common; 25 struct tcf_vlan_params __rcu *vlan_p; 26 }; 27 #define to_vlan(a) ((struct tcf_vlan *)a) 28 tcf_vlan_action(const struct tc_action * a)29static inline u32 tcf_vlan_action(const struct tc_action *a) 30 { 31 u32 tcfv_action; 32 33 rcu_read_lock(); 34 tcfv_action = rcu_dereference(to_vlan(a)->vlan_p)->tcfv_action; 35 rcu_read_unlock(); 36 37 return tcfv_action; 38 } 39 tcf_vlan_push_vid(const struct tc_action * a)40static inline u16 tcf_vlan_push_vid(const struct tc_action *a) 41 { 42 u16 tcfv_push_vid; 43 44 rcu_read_lock(); 45 tcfv_push_vid = rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_vid; 46 rcu_read_unlock(); 47 48 return tcfv_push_vid; 49 } 50 tcf_vlan_push_proto(const struct tc_action * a)51static inline __be16 tcf_vlan_push_proto(const struct tc_action *a) 52 { 53 __be16 tcfv_push_proto; 54 55 rcu_read_lock(); 56 tcfv_push_proto = rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_proto; 57 rcu_read_unlock(); 58 59 return tcfv_push_proto; 60 } 61 tcf_vlan_push_prio(const struct tc_action * a)62static inline u8 tcf_vlan_push_prio(const struct tc_action *a) 63 { 64 u8 tcfv_push_prio; 65 66 rcu_read_lock(); 67 tcfv_push_prio = rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_prio; 68 rcu_read_unlock(); 69 70 return tcfv_push_prio; 71 } 72 tcf_vlan_push_eth(unsigned char * src,unsigned char * dest,const struct tc_action * a)73static inline void tcf_vlan_push_eth(unsigned char *src, unsigned char *dest, 74 const struct tc_action *a) 75 { 76 rcu_read_lock(); 77 memcpy(dest, rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_dst, ETH_ALEN); 78 memcpy(src, rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_src, ETH_ALEN); 79 rcu_read_unlock(); 80 } 81 82 #endif /* __NET_TC_VLAN_H */ 83