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 int action; /* tcf_action */ 14 u8 tcfm_tc; 15 u8 tcfm_ttl; 16 u8 tcfm_bos; 17 __be16 tcfm_proto; 18 struct rcu_head rcu; 19 }; 20 21 #define ACT_MPLS_TC_NOT_SET 0xff 22 #define ACT_MPLS_BOS_NOT_SET 0xff 23 #define ACT_MPLS_LABEL_NOT_SET 0xffffffff 24 25 struct tcf_mpls { 26 struct tc_action common; 27 struct tcf_mpls_params __rcu *mpls_p; 28 }; 29 #define to_mpls(a) ((struct tcf_mpls *)a) 30 tcf_mpls_action(const struct tc_action * a)31static inline u32 tcf_mpls_action(const struct tc_action *a) 32 { 33 u32 tcfm_action; 34 35 rcu_read_lock(); 36 tcfm_action = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_action; 37 rcu_read_unlock(); 38 39 return tcfm_action; 40 } 41 tcf_mpls_proto(const struct tc_action * a)42static inline __be16 tcf_mpls_proto(const struct tc_action *a) 43 { 44 __be16 tcfm_proto; 45 46 rcu_read_lock(); 47 tcfm_proto = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_proto; 48 rcu_read_unlock(); 49 50 return tcfm_proto; 51 } 52 tcf_mpls_label(const struct tc_action * a)53static inline u32 tcf_mpls_label(const struct tc_action *a) 54 { 55 u32 tcfm_label; 56 57 rcu_read_lock(); 58 tcfm_label = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_label; 59 rcu_read_unlock(); 60 61 return tcfm_label; 62 } 63 tcf_mpls_tc(const struct tc_action * a)64static inline u8 tcf_mpls_tc(const struct tc_action *a) 65 { 66 u8 tcfm_tc; 67 68 rcu_read_lock(); 69 tcfm_tc = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_tc; 70 rcu_read_unlock(); 71 72 return tcfm_tc; 73 } 74 tcf_mpls_bos(const struct tc_action * a)75static inline u8 tcf_mpls_bos(const struct tc_action *a) 76 { 77 u8 tcfm_bos; 78 79 rcu_read_lock(); 80 tcfm_bos = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_bos; 81 rcu_read_unlock(); 82 83 return tcfm_bos; 84 } 85 tcf_mpls_ttl(const struct tc_action * a)86static inline u8 tcf_mpls_ttl(const struct tc_action *a) 87 { 88 u8 tcfm_ttl; 89 90 rcu_read_lock(); 91 tcfm_ttl = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_ttl; 92 rcu_read_unlock(); 93 94 return tcfm_ttl; 95 } 96 97 #endif /* __NET_TC_MPLS_H */ 98