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