xref: /openbmc/linux/include/net/ioam6.h (revision 887069f4)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  *  IPv6 IOAM implementation
4  *
5  *  Author:
6  *  Justin Iurman <justin.iurman@uliege.be>
7  */
8 
9 #ifndef _NET_IOAM6_H
10 #define _NET_IOAM6_H
11 
12 #include <linux/net.h>
13 #include <linux/ipv6.h>
14 #include <linux/ioam6.h>
15 #include <linux/rhashtable-types.h>
16 
17 struct ioam6_namespace {
18 	struct rhash_head head;
19 	struct rcu_head rcu;
20 
21 	struct ioam6_schema __rcu *schema;
22 
23 	__be16 id;
24 	__be32 data;
25 	__be64 data_wide;
26 };
27 
28 struct ioam6_schema {
29 	struct rhash_head head;
30 	struct rcu_head rcu;
31 
32 	struct ioam6_namespace __rcu *ns;
33 
34 	u32 id;
35 	int len;
36 	__be32 hdr;
37 
38 	u8 data[0];
39 };
40 
41 struct ioam6_pernet_data {
42 	struct mutex lock;
43 	struct rhashtable namespaces;
44 	struct rhashtable schemas;
45 };
46 
47 static inline struct ioam6_pernet_data *ioam6_pernet(struct net *net)
48 {
49 #if IS_ENABLED(CONFIG_IPV6)
50 	return net->ipv6.ioam6_data;
51 #else
52 	return NULL;
53 #endif
54 }
55 
56 struct ioam6_namespace *ioam6_namespace(struct net *net, __be16 id);
57 void ioam6_fill_trace_data(struct sk_buff *skb,
58 			   struct ioam6_namespace *ns,
59 			   struct ioam6_trace_hdr *trace);
60 
61 int ioam6_init(void);
62 void ioam6_exit(void);
63 
64 int ioam6_iptunnel_init(void);
65 void ioam6_iptunnel_exit(void);
66 
67 #endif /* _NET_IOAM6_H */
68