1
2
3#ifndef _LINUX_BTF_IDS_H
4#define _LINUX_BTF_IDS_H
5
6struct btf_id_set {
7 u32 cnt;
8 u32 ids[];
9};
10
11#ifdef CONFIG_DEBUG_INFO_BTF
12
13#include <linux/compiler.h>
14
15
16
17
18
19
20
21
22
23
24
25#define BTF_IDS_SECTION ".BTF_ids"
26
27#define ____BTF_ID(symbol) \
28asm( \
29".pushsection " BTF_IDS_SECTION ",\"a\"; \n" \
30".local " #symbol " ; \n" \
31".type " #symbol ", STT_OBJECT; \n" \
32".size " #symbol ", 4; \n" \
33#symbol ": \n" \
34".zero 4 \n" \
35".popsection; \n");
36
37#define __BTF_ID(symbol) \
38 ____BTF_ID(symbol)
39
40#define __ID(prefix) \
41 __PASTE(prefix, __COUNTER__)
42
43
44
45
46
47#define BTF_ID(prefix, name) \
48 __BTF_ID(__ID(__BTF_ID__##prefix##__##name##__))
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65#define __BTF_ID_LIST(name, scope) \
66asm( \
67".pushsection " BTF_IDS_SECTION ",\"a\"; \n" \
68"." #scope " " #name "; \n" \
69#name ":; \n" \
70".popsection; \n");
71
72#define BTF_ID_LIST(name) \
73__BTF_ID_LIST(name, local) \
74extern u32 name[];
75
76#define BTF_ID_LIST_GLOBAL(name) \
77__BTF_ID_LIST(name, globl)
78
79
80
81
82#define BTF_ID_LIST_SINGLE(name, prefix, typename) \
83 BTF_ID_LIST(name) \
84 BTF_ID(prefix, typename)
85
86
87
88
89
90
91
92
93
94
95
96
97#define BTF_ID_UNUSED \
98asm( \
99".pushsection " BTF_IDS_SECTION ",\"a\"; \n" \
100".zero 4 \n" \
101".popsection; \n");
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121#define __BTF_SET_START(name, scope) \
122asm( \
123".pushsection " BTF_IDS_SECTION ",\"a\"; \n" \
124"." #scope " __BTF_ID__set__" #name "; \n" \
125"__BTF_ID__set__" #name ":; \n" \
126".zero 4 \n" \
127".popsection; \n");
128
129#define BTF_SET_START(name) \
130__BTF_ID_LIST(name, local) \
131__BTF_SET_START(name, local)
132
133#define BTF_SET_START_GLOBAL(name) \
134__BTF_ID_LIST(name, globl) \
135__BTF_SET_START(name, globl)
136
137#define BTF_SET_END(name) \
138asm( \
139".pushsection " BTF_IDS_SECTION ",\"a\"; \n" \
140".size __BTF_ID__set__" #name ", .-" #name " \n" \
141".popsection; \n"); \
142extern struct btf_id_set name;
143
144#else
145
146#define BTF_ID_LIST(name) static u32 name[5];
147#define BTF_ID(prefix, name)
148#define BTF_ID_UNUSED
149#define BTF_ID_LIST_GLOBAL(name) u32 name[1];
150#define BTF_ID_LIST_SINGLE(name, prefix, typename) static u32 name[1];
151#define BTF_SET_START(name) static struct btf_id_set name = { 0 };
152#define BTF_SET_START_GLOBAL(name) static struct btf_id_set name = { 0 };
153#define BTF_SET_END(name)
154
155#endif
156
157#ifdef CONFIG_NET
158
159
160
161
162#define BTF_SOCK_TYPE_xxx \
163 BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET, inet_sock) \
164 BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET_CONN, inet_connection_sock) \
165 BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET_REQ, inet_request_sock) \
166 BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET_TW, inet_timewait_sock) \
167 BTF_SOCK_TYPE(BTF_SOCK_TYPE_REQ, request_sock) \
168 BTF_SOCK_TYPE(BTF_SOCK_TYPE_SOCK, sock) \
169 BTF_SOCK_TYPE(BTF_SOCK_TYPE_SOCK_COMMON, sock_common) \
170 BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP, tcp_sock) \
171 BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP_REQ, tcp_request_sock) \
172 BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP_TW, tcp_timewait_sock) \
173 BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP6, tcp6_sock) \
174 BTF_SOCK_TYPE(BTF_SOCK_TYPE_UDP, udp_sock) \
175 BTF_SOCK_TYPE(BTF_SOCK_TYPE_UDP6, udp6_sock)
176
177enum {
178#define BTF_SOCK_TYPE(name, str) name,
179BTF_SOCK_TYPE_xxx
180#undef BTF_SOCK_TYPE
181MAX_BTF_SOCK_TYPE,
182};
183
184extern u32 btf_sock_ids[];
185#endif
186
187#endif
188