Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / include / net / tc_act / tc_mpls.h
blob721de4f5733a9366d37457d8b7307d78ae2f4903
1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
2 /* Copyright (C) 2019 Netronome Systems, Inc. */
4 #ifndef __NET_TC_MPLS_H
5 #define __NET_TC_MPLS_H
7 #include <linux/tc_act/tc_mpls.h>
8 #include <net/act_api.h>
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;
20 #define ACT_MPLS_TC_NOT_SET 0xff
21 #define ACT_MPLS_BOS_NOT_SET 0xff
22 #define ACT_MPLS_LABEL_NOT_SET 0xffffffff
24 struct tcf_mpls {
25 struct tc_action common;
26 struct tcf_mpls_params __rcu *mpls_p;
28 #define to_mpls(a) ((struct tcf_mpls *)a)
30 static inline bool is_tcf_mpls(const struct tc_action *a)
32 #ifdef CONFIG_NET_CLS_ACT
33 if (a->ops && a->ops->id == TCA_ID_MPLS)
34 return true;
35 #endif
36 return false;
39 static inline u32 tcf_mpls_action(const struct tc_action *a)
41 u32 tcfm_action;
43 rcu_read_lock();
44 tcfm_action = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_action;
45 rcu_read_unlock();
47 return tcfm_action;
50 static inline __be16 tcf_mpls_proto(const struct tc_action *a)
52 __be16 tcfm_proto;
54 rcu_read_lock();
55 tcfm_proto = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_proto;
56 rcu_read_unlock();
58 return tcfm_proto;
61 static inline u32 tcf_mpls_label(const struct tc_action *a)
63 u32 tcfm_label;
65 rcu_read_lock();
66 tcfm_label = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_label;
67 rcu_read_unlock();
69 return tcfm_label;
72 static inline u8 tcf_mpls_tc(const struct tc_action *a)
74 u8 tcfm_tc;
76 rcu_read_lock();
77 tcfm_tc = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_tc;
78 rcu_read_unlock();
80 return tcfm_tc;
83 static inline u8 tcf_mpls_bos(const struct tc_action *a)
85 u8 tcfm_bos;
87 rcu_read_lock();
88 tcfm_bos = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_bos;
89 rcu_read_unlock();
91 return tcfm_bos;
94 static inline u8 tcf_mpls_ttl(const struct tc_action *a)
96 u8 tcfm_ttl;
98 rcu_read_lock();
99 tcfm_ttl = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_ttl;
100 rcu_read_unlock();
102 return tcfm_ttl;
105 #endif /* __NET_TC_MPLS_H */