0001
0002
0003
0004 #ifndef __NET_TC_MPLS_H
0005 #define __NET_TC_MPLS_H
0006
0007 #include <linux/tc_act/tc_mpls.h>
0008 #include <net/act_api.h>
0009
0010 struct tcf_mpls_params {
0011 int tcfm_action;
0012 u32 tcfm_label;
0013 u8 tcfm_tc;
0014 u8 tcfm_ttl;
0015 u8 tcfm_bos;
0016 __be16 tcfm_proto;
0017 struct rcu_head rcu;
0018 };
0019
0020 #define ACT_MPLS_TC_NOT_SET 0xff
0021 #define ACT_MPLS_BOS_NOT_SET 0xff
0022 #define ACT_MPLS_LABEL_NOT_SET 0xffffffff
0023
0024 struct tcf_mpls {
0025 struct tc_action common;
0026 struct tcf_mpls_params __rcu *mpls_p;
0027 };
0028 #define to_mpls(a) ((struct tcf_mpls *)a)
0029
0030 static inline bool is_tcf_mpls(const struct tc_action *a)
0031 {
0032 #ifdef CONFIG_NET_CLS_ACT
0033 if (a->ops && a->ops->id == TCA_ID_MPLS)
0034 return true;
0035 #endif
0036 return false;
0037 }
0038
0039 static inline u32 tcf_mpls_action(const struct tc_action *a)
0040 {
0041 u32 tcfm_action;
0042
0043 rcu_read_lock();
0044 tcfm_action = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_action;
0045 rcu_read_unlock();
0046
0047 return tcfm_action;
0048 }
0049
0050 static inline __be16 tcf_mpls_proto(const struct tc_action *a)
0051 {
0052 __be16 tcfm_proto;
0053
0054 rcu_read_lock();
0055 tcfm_proto = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_proto;
0056 rcu_read_unlock();
0057
0058 return tcfm_proto;
0059 }
0060
0061 static inline u32 tcf_mpls_label(const struct tc_action *a)
0062 {
0063 u32 tcfm_label;
0064
0065 rcu_read_lock();
0066 tcfm_label = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_label;
0067 rcu_read_unlock();
0068
0069 return tcfm_label;
0070 }
0071
0072 static inline u8 tcf_mpls_tc(const struct tc_action *a)
0073 {
0074 u8 tcfm_tc;
0075
0076 rcu_read_lock();
0077 tcfm_tc = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_tc;
0078 rcu_read_unlock();
0079
0080 return tcfm_tc;
0081 }
0082
0083 static inline u8 tcf_mpls_bos(const struct tc_action *a)
0084 {
0085 u8 tcfm_bos;
0086
0087 rcu_read_lock();
0088 tcfm_bos = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_bos;
0089 rcu_read_unlock();
0090
0091 return tcfm_bos;
0092 }
0093
0094 static inline u8 tcf_mpls_ttl(const struct tc_action *a)
0095 {
0096 u8 tcfm_ttl;
0097
0098 rcu_read_lock();
0099 tcfm_ttl = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_ttl;
0100 rcu_read_unlock();
0101
0102 return tcfm_ttl;
0103 }
0104
0105 #endif