1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ 2 /* Copyright (C) 2019 Netronome Systems, Inc. */ 3 4 #ifndef __NET_TC_MPLS_H 5 #define __NET_TC_MPLS_H 6 7 #include <linux/tc_act/tc_mpls.h> 8 #include <net/act_api.h> 9 10 struct tcf_mpls_params { 11 int tcfm_action; 12 u32 tcfm_label; 13 u8 tcfm_tc; 14 u8 tcfm_ttl; 15 u8 tcfm_bos; 16 __be16 tcfm_proto; 17 struct rcu_head rcu; 18 }; 19 20 #define ACT_MPLS_TC_NOT_SET 0xff 21 #define ACT_MPLS_BOS_NOT_SET 0xff 22 #define ACT_MPLS_LABEL_NOT_SET 0xffffffff 23 24 struct tcf_mpls { 25 struct tc_action common; 26 struct tcf_mpls_params __rcu *mpls_p; 27 }; 28 #define to_mpls(a) ((struct tcf_mpls *)a) 29 30 static inline u32 tcf_mpls_action(const struct tc_action *a) 31 { 32 u32 tcfm_action; 33 34 rcu_read_lock(); 35 tcfm_action = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_action; 36 rcu_read_unlock(); 37 38 return tcfm_action; 39 } 40 41 static inline __be16 tcf_mpls_proto(const struct tc_action *a) 42 { 43 __be16 tcfm_proto; 44 45 rcu_read_lock(); 46 tcfm_proto = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_proto; 47 rcu_read_unlock(); 48 49 return tcfm_proto; 50 } 51 52 static inline u32 tcf_mpls_label(const struct tc_action *a) 53 { 54 u32 tcfm_label; 55 56 rcu_read_lock(); 57 tcfm_label = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_label; 58 rcu_read_unlock(); 59 60 return tcfm_label; 61 } 62 63 static inline u8 tcf_mpls_tc(const struct tc_action *a) 64 { 65 u8 tcfm_tc; 66 67 rcu_read_lock(); 68 tcfm_tc = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_tc; 69 rcu_read_unlock(); 70 71 return tcfm_tc; 72 } 73 74 static inline u8 tcf_mpls_bos(const struct tc_action *a) 75 { 76 u8 tcfm_bos; 77 78 rcu_read_lock(); 79 tcfm_bos = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_bos; 80 rcu_read_unlock(); 81 82 return tcfm_bos; 83 } 84 85 static inline u8 tcf_mpls_ttl(const struct tc_action *a) 86 { 87 u8 tcfm_ttl; 88 89 rcu_read_lock(); 90 tcfm_ttl = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_ttl; 91 rcu_read_unlock(); 92 93 return tcfm_ttl; 94 } 95 96 #endif /* __NET_TC_MPLS_H */ 97