Merge https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next
[linux-2.6-microblaze.git] / include / linux / btf_ids.h
index 335a190..2aea877 100644 (file)
@@ -8,6 +8,15 @@ struct btf_id_set {
        u32 ids[];
 };
 
+struct btf_id_set8 {
+       u32 cnt;
+       u32 flags;
+       struct {
+               u32 id;
+               u32 flags;
+       } pairs[];
+};
+
 #ifdef CONFIG_DEBUG_INFO_BTF
 
 #include <linux/compiler.h> /* for __PASTE */
@@ -25,7 +34,7 @@ struct btf_id_set {
 
 #define BTF_IDS_SECTION ".BTF_ids"
 
-#define ____BTF_ID(symbol)                             \
+#define ____BTF_ID(symbol, word)                       \
 asm(                                                   \
 ".pushsection " BTF_IDS_SECTION ",\"a\";       \n"     \
 ".local " #symbol " ;                          \n"     \
@@ -33,10 +42,11 @@ asm(                                                        \
 ".size  " #symbol ", 4;                        \n"     \
 #symbol ":                                     \n"     \
 ".zero 4                                       \n"     \
+word                                                   \
 ".popsection;                                  \n");
 
-#define __BTF_ID(symbol) \
-       ____BTF_ID(symbol)
+#define __BTF_ID(symbol, word) \
+       ____BTF_ID(symbol, word)
 
 #define __ID(prefix) \
        __PASTE(prefix, __COUNTER__)
@@ -46,7 +56,14 @@ asm(                                                 \
  * to 4 zero bytes.
  */
 #define BTF_ID(prefix, name) \
-       __BTF_ID(__ID(__BTF_ID__##prefix##__##name##__))
+       __BTF_ID(__ID(__BTF_ID__##prefix##__##name##__), "")
+
+#define ____BTF_ID_FLAGS(prefix, name, flags) \
+       __BTF_ID(__ID(__BTF_ID__##prefix##__##name##__), ".long " #flags "\n")
+#define __BTF_ID_FLAGS(prefix, name, flags, ...) \
+       ____BTF_ID_FLAGS(prefix, name, flags)
+#define BTF_ID_FLAGS(prefix, name, ...) \
+       __BTF_ID_FLAGS(prefix, name, ##__VA_ARGS__, 0)
 
 /*
  * The BTF_ID_LIST macro defines pure (unsorted) list
@@ -145,10 +162,51 @@ asm(                                                      \
 ".popsection;                                 \n");    \
 extern struct btf_id_set name;
 
+/*
+ * The BTF_SET8_START/END macros pair defines sorted list of
+ * BTF IDs and their flags plus its members count, with the
+ * following layout:
+ *
+ * BTF_SET8_START(list)
+ * BTF_ID_FLAGS(type1, name1, flags)
+ * BTF_ID_FLAGS(type2, name2, flags)
+ * BTF_SET8_END(list)
+ *
+ * __BTF_ID__set8__list:
+ * .zero 8
+ * list:
+ * __BTF_ID__type1__name1__3:
+ * .zero 4
+ * .word (1 << 0) | (1 << 2)
+ * __BTF_ID__type2__name2__5:
+ * .zero 4
+ * .word (1 << 3) | (1 << 1) | (1 << 2)
+ *
+ */
+#define __BTF_SET8_START(name, scope)                  \
+asm(                                                   \
+".pushsection " BTF_IDS_SECTION ",\"a\";       \n"     \
+"." #scope " __BTF_ID__set8__" #name ";        \n"     \
+"__BTF_ID__set8__" #name ":;                   \n"     \
+".zero 8                                       \n"     \
+".popsection;                                  \n");
+
+#define BTF_SET8_START(name)                           \
+__BTF_ID_LIST(name, local)                             \
+__BTF_SET8_START(name, local)
+
+#define BTF_SET8_END(name)                             \
+asm(                                                   \
+".pushsection " BTF_IDS_SECTION ",\"a\";      \n"      \
+".size __BTF_ID__set8__" #name ", .-" #name "  \n"     \
+".popsection;                                 \n");    \
+extern struct btf_id_set8 name;
+
 #else
 
 #define BTF_ID_LIST(name) static u32 __maybe_unused name[5];
 #define BTF_ID(prefix, name)
+#define BTF_ID_FLAGS(prefix, name, ...)
 #define BTF_ID_UNUSED
 #define BTF_ID_LIST_GLOBAL(name, n) u32 __maybe_unused name[n];
 #define BTF_ID_LIST_SINGLE(name, prefix, typename) static u32 __maybe_unused name[1];
@@ -156,6 +214,8 @@ extern struct btf_id_set name;
 #define BTF_SET_START(name) static struct btf_id_set __maybe_unused name = { 0 };
 #define BTF_SET_START_GLOBAL(name) static struct btf_id_set __maybe_unused name = { 0 };
 #define BTF_SET_END(name)
+#define BTF_SET8_START(name) static struct btf_id_set8 __maybe_unused name = { 0 };
+#define BTF_SET8_END(name)
 
 #endif /* CONFIG_DEBUG_INFO_BTF */
 
@@ -179,7 +239,8 @@ extern struct btf_id_set name;
        BTF_SOCK_TYPE(BTF_SOCK_TYPE_UDP, udp_sock)                      \
        BTF_SOCK_TYPE(BTF_SOCK_TYPE_UDP6, udp6_sock)                    \
        BTF_SOCK_TYPE(BTF_SOCK_TYPE_UNIX, unix_sock)                    \
-       BTF_SOCK_TYPE(BTF_SOCK_TYPE_MPTCP, mptcp_sock)
+       BTF_SOCK_TYPE(BTF_SOCK_TYPE_MPTCP, mptcp_sock)                  \
+       BTF_SOCK_TYPE(BTF_SOCK_TYPE_SOCKET, socket)
 
 enum {
 #define BTF_SOCK_TYPE(name, str) name,