Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (c) 2015 Tom Herbert <tom@herbertland.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #ifndef __ILA_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #define __ILA_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/ip.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/socket.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/skbuff.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <net/checksum.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <net/genetlink.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <net/ip.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <net/protocol.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <uapi/linux/ila.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) struct ila_locator {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 		__u8            v8[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 		__be16          v16[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 		__be32          v32[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 		__be64		v64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) struct ila_identifier {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #if defined(__LITTLE_ENDIAN_BITFIELD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 			u8 __space:4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 			u8 csum_neutral:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 			u8 type:3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #elif defined(__BIG_ENDIAN_BITFIELD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 			u8 type:3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 			u8 csum_neutral:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 			u8 __space:4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #error  "Adjust your <asm/byteorder.h> defines"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 			u8 __space2[7];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		__u8            v8[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		__be16          v16[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		__be32          v32[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		__be64		v64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #define CSUM_NEUTRAL_FLAG	htonl(0x10000000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) struct ila_addr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		struct in6_addr addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 			struct ila_locator loc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 			struct ila_identifier ident;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		};
^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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) static inline struct ila_addr *ila_a2i(struct in6_addr *addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	return (struct ila_addr *)addr;
^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) struct ila_params {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	struct ila_locator locator;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	struct ila_locator locator_match;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	__wsum csum_diff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	u8 csum_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	u8 ident_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) static inline __wsum compute_csum_diff8(const __be32 *from, const __be32 *to)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	__be32 diff[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		~from[0], ~from[1], to[0], to[1],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	return csum_partial(diff, sizeof(diff), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) static inline bool ila_csum_neutral_set(struct ila_identifier ident)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	return !!(ident.csum_neutral);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) void ila_update_ipv6_locator(struct sk_buff *skb, struct ila_params *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 			     bool set_csum_neutral);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) void ila_init_saved_csum(struct ila_params *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) struct ila_net {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		struct rhashtable rhash_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		spinlock_t *locks; /* Bucket locks for entry manipulation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		unsigned int locks_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		bool hooks_registered;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	} xlat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) int ila_lwt_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) void ila_lwt_fini(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) int ila_xlat_init_net(struct net *net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) void ila_xlat_exit_net(struct net *net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) int ila_xlat_nl_cmd_add_mapping(struct sk_buff *skb, struct genl_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) int ila_xlat_nl_cmd_del_mapping(struct sk_buff *skb, struct genl_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) int ila_xlat_nl_cmd_get_mapping(struct sk_buff *skb, struct genl_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) int ila_xlat_nl_cmd_flush(struct sk_buff *skb, struct genl_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) int ila_xlat_nl_dump_start(struct netlink_callback *cb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) int ila_xlat_nl_dump_done(struct netlink_callback *cb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) int ila_xlat_nl_dump(struct sk_buff *skb, struct netlink_callback *cb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) extern unsigned int ila_net_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) extern struct genl_family ila_nl_family;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) #endif /* __ILA_H */