Linux-libre 5.4.47-gnu
[librecmc/linux-libre.git] / include / net / geneve.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __NET_GENEVE_H
3 #define __NET_GENEVE_H  1
4
5 #include <net/udp_tunnel.h>
6
7 #define GENEVE_UDP_PORT         6081
8
9 /* Geneve Header:
10  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
11  *  |Ver|  Opt Len  |O|C|    Rsvd.  |          Protocol Type        |
12  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
13  *  |        Virtual Network Identifier (VNI)       |    Reserved   |
14  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
15  *  |                    Variable Length Options                    |
16  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
17  *
18  * Option Header:
19  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
20  *  |          Option Class         |      Type     |R|R|R| Length  |
21  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
22  *  |                      Variable Option Data                     |
23  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
24  */
25
26 struct geneve_opt {
27         __be16  opt_class;
28         u8      type;
29 #ifdef __LITTLE_ENDIAN_BITFIELD
30         u8      length:5;
31         u8      r3:1;
32         u8      r2:1;
33         u8      r1:1;
34 #else
35         u8      r1:1;
36         u8      r2:1;
37         u8      r3:1;
38         u8      length:5;
39 #endif
40         u8      opt_data[];
41 };
42
43 #define GENEVE_CRIT_OPT_TYPE (1 << 7)
44
45 struct genevehdr {
46 #ifdef __LITTLE_ENDIAN_BITFIELD
47         u8 opt_len:6;
48         u8 ver:2;
49         u8 rsvd1:6;
50         u8 critical:1;
51         u8 oam:1;
52 #else
53         u8 ver:2;
54         u8 opt_len:6;
55         u8 oam:1;
56         u8 critical:1;
57         u8 rsvd1:6;
58 #endif
59         __be16 proto_type;
60         u8 vni[3];
61         u8 rsvd2;
62         struct geneve_opt options[];
63 };
64
65 static inline bool netif_is_geneve(const struct net_device *dev)
66 {
67         return dev->rtnl_link_ops &&
68                !strcmp(dev->rtnl_link_ops->kind, "geneve");
69 }
70
71 #ifdef CONFIG_INET
72 struct net_device *geneve_dev_create_fb(struct net *net, const char *name,
73                                         u8 name_assign_type, u16 dst_port);
74 #endif /*ifdef CONFIG_INET */
75
76 #endif /*ifdef__NET_GENEVE_H */