aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/tc_act/tc_mpls.h
blob: 721de4f5733a9366d37457d8b7307d78ae2f4903 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
/* Copyright (C) 2019 Netronome Systems, Inc. */

#ifndef __NET_TC_MPLS_H
#define __NET_TC_MPLS_H

#include <linux/tc_act/tc_mpls.h>
#include <net/act_api.h>

struct tcf_mpls_params {
	int tcfm_action;
	u32 tcfm_label;
	u8 tcfm_tc;
	u8 tcfm_ttl;
	u8 tcfm_bos;
	__be16 tcfm_proto;
	struct rcu_head	rcu;
};

#define ACT_MPLS_TC_NOT_SET	0xff
#define ACT_MPLS_BOS_NOT_SET	0xff
#define ACT_MPLS_LABEL_NOT_SET	0xffffffff

struct tcf_mpls {
	struct tc_action common;
	struct tcf_mpls_params __rcu *mpls_p;
};
#define to_mpls(a) ((struct tcf_mpls *)a)

static inline bool is_tcf_mpls(const struct tc_action *a)
{
#ifdef CONFIG_NET_CLS_ACT
	if (a->ops && a->ops->id == TCA_ID_MPLS)
		return true;
#endif
	return false;
}

static inline u32 tcf_mpls_action(const struct tc_action *a)
{
	u32 tcfm_action;

	rcu_read_lock();
	tcfm_action = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_action;
	rcu_read_unlock();

	return tcfm_action;
}

static inline __be16 tcf_mpls_proto(const struct tc_action *a)
{
	__be16 tcfm_proto;

	rcu_read_lock();
	tcfm_proto = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_proto;
	rcu_read_unlock();

	return tcfm_proto;
}

static inline u32 tcf_mpls_label(const struct tc_action *a)
{
	u32 tcfm_label;

	rcu_read_lock();
	tcfm_label = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_label;
	rcu_read_unlock();

	return tcfm_label;
}

static inline u8 tcf_mpls_tc(const struct tc_action *a)
{
	u8 tcfm_tc;

	rcu_read_lock();
	tcfm_tc = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_tc;
	rcu_read_unlock();

	return tcfm_tc;
}

static inline u8 tcf_mpls_bos(const struct tc_action *a)
{
	u8 tcfm_bos;

	rcu_read_lock();
	tcfm_bos = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_bos;
	rcu_read_unlock();

	return tcfm_bos;
}

static inline u8 tcf_mpls_ttl(const struct tc_action *a)
{
	u8 tcfm_ttl;

	rcu_read_lock();
	tcfm_ttl = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_ttl;
	rcu_read_unlock();

	return tcfm_ttl;
}

#endif /* __NET_TC_MPLS_H */