]>
Commit | Line | Data |
---|---|---|
b4b9771b TL |
1 | /* |
2 | * net/tipc/trace.h: TIPC tracepoints | |
3 | * | |
4 | * Copyright (c) 2018, Ericsson AB | |
5 | * All rights reserved. | |
6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions are met: | |
9 | * | |
10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | |
15 | * 3. Neither the names of the copyright holders nor the names of its | |
16 | * contributors may be used to endorse or promote products derived from | |
17 | * this software without specific prior written permission. | |
18 | * | |
19 | * Alternatively, this software may be distributed under the terms of the | |
20 | * GNU General Public License ("GPL") version 2 as published by the Free | |
21 | * Software Foundation. | |
22 | * | |
23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "ASIS" | |
24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,THE | |
25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
33 | * POSSIBILITY OF SUCH DAMAGE. | |
34 | */ | |
35 | ||
36 | #undef TRACE_SYSTEM | |
37 | #define TRACE_SYSTEM tipc | |
38 | ||
39 | #if !defined(_TIPC_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) | |
40 | #define _TIPC_TRACE_H | |
41 | ||
42 | #include <linux/tracepoint.h> | |
43 | #include "core.h" | |
44 | #include "link.h" | |
45 | #include "socket.h" | |
46 | #include "node.h" | |
47 | ||
48 | #define SKB_LMIN (100) | |
49 | #define SKB_LMAX (SKB_LMIN * 2) | |
50 | #define LIST_LMIN (SKB_LMIN * 3) | |
51 | #define LIST_LMAX (SKB_LMIN * 11) | |
52 | #define SK_LMIN (SKB_LMIN * 2) | |
53 | #define SK_LMAX (SKB_LMIN * 11) | |
54 | #define LINK_LMIN (SKB_LMIN) | |
55 | #define LINK_LMAX (SKB_LMIN * 16) | |
56 | #define NODE_LMIN (SKB_LMIN) | |
57 | #define NODE_LMAX (SKB_LMIN * 11) | |
58 | ||
59 | #ifndef __TIPC_TRACE_ENUM | |
60 | #define __TIPC_TRACE_ENUM | |
61 | enum { | |
62 | TIPC_DUMP_NONE = 0, | |
63 | ||
64 | TIPC_DUMP_TRANSMQ = 1, | |
65 | TIPC_DUMP_BACKLOGQ = (1 << 1), | |
66 | TIPC_DUMP_DEFERDQ = (1 << 2), | |
67 | TIPC_DUMP_INPUTQ = (1 << 3), | |
68 | TIPC_DUMP_WAKEUP = (1 << 4), | |
69 | ||
70 | TIPC_DUMP_SK_SNDQ = (1 << 8), | |
71 | TIPC_DUMP_SK_RCVQ = (1 << 9), | |
72 | TIPC_DUMP_SK_BKLGQ = (1 << 10), | |
73 | TIPC_DUMP_ALL = 0xffffu | |
74 | }; | |
75 | #endif | |
76 | ||
26574db0 TL |
77 | /* Link & Node FSM states: */ |
78 | #define state_sym(val) \ | |
79 | __print_symbolic(val, \ | |
80 | {(0xe), "ESTABLISHED" },\ | |
81 | {(0xe << 4), "ESTABLISHING" },\ | |
82 | {(0x1 << 8), "RESET" },\ | |
83 | {(0x2 << 12), "RESETTING" },\ | |
84 | {(0xd << 16), "PEER_RESET" },\ | |
85 | {(0xf << 20), "FAILINGOVER" },\ | |
86 | {(0xc << 24), "SYNCHING" },\ | |
87 | {(0xdd), "SELF_DOWN_PEER_DOWN" },\ | |
88 | {(0xaa), "SELF_UP_PEER_UP" },\ | |
89 | {(0xd1), "SELF_DOWN_PEER_LEAVING" },\ | |
90 | {(0xac), "SELF_UP_PEER_COMING" },\ | |
91 | {(0xca), "SELF_COMING_PEER_UP" },\ | |
92 | {(0x1d), "SELF_LEAVING_PEER_DOWN" },\ | |
93 | {(0xf0), "FAILINGOVER" },\ | |
94 | {(0xcc), "SYNCHING" }) | |
95 | ||
96 | /* Link & Node FSM events: */ | |
97 | #define evt_sym(val) \ | |
98 | __print_symbolic(val, \ | |
99 | {(0xec1ab1e), "ESTABLISH_EVT" },\ | |
100 | {(0x9eed0e), "PEER_RESET_EVT" },\ | |
101 | {(0xfa110e), "FAILURE_EVT" },\ | |
102 | {(0x10ca1d0e), "RESET_EVT" },\ | |
103 | {(0xfa110bee), "FAILOVER_BEGIN_EVT" },\ | |
104 | {(0xfa110ede), "FAILOVER_END_EVT" },\ | |
105 | {(0xc1ccbee), "SYNCH_BEGIN_EVT" },\ | |
106 | {(0xc1ccede), "SYNCH_END_EVT" },\ | |
107 | {(0xece), "SELF_ESTABL_CONTACT_EVT" },\ | |
108 | {(0x1ce), "SELF_LOST_CONTACT_EVT" },\ | |
109 | {(0x9ece), "PEER_ESTABL_CONTACT_EVT" },\ | |
110 | {(0x91ce), "PEER_LOST_CONTACT_EVT" },\ | |
111 | {(0xfbe), "FAILOVER_BEGIN_EVT" },\ | |
112 | {(0xfee), "FAILOVER_END_EVT" },\ | |
113 | {(0xcbe), "SYNCH_BEGIN_EVT" },\ | |
114 | {(0xcee), "SYNCH_END_EVT" }) | |
115 | ||
01e661eb TL |
116 | extern unsigned long sysctl_tipc_sk_filter[5] __read_mostly; |
117 | ||
b4b9771b TL |
118 | int tipc_skb_dump(struct sk_buff *skb, bool more, char *buf); |
119 | int tipc_list_dump(struct sk_buff_head *list, bool more, char *buf); | |
120 | int tipc_sk_dump(struct sock *sk, u16 dqueues, char *buf); | |
121 | int tipc_link_dump(struct tipc_link *l, u16 dqueues, char *buf); | |
122 | int tipc_node_dump(struct tipc_node *n, bool more, char *buf); | |
01e661eb | 123 | bool tipc_sk_filtering(struct sock *sk); |
b4b9771b TL |
124 | |
125 | DECLARE_EVENT_CLASS(tipc_skb_class, | |
126 | ||
127 | TP_PROTO(struct sk_buff *skb, bool more, const char *header), | |
128 | ||
129 | TP_ARGS(skb, more, header), | |
130 | ||
131 | TP_STRUCT__entry( | |
132 | __string(header, header) | |
133 | __dynamic_array(char, buf, (more) ? SKB_LMAX : SKB_LMIN) | |
134 | ), | |
135 | ||
136 | TP_fast_assign( | |
137 | __assign_str(header, header); | |
138 | tipc_skb_dump(skb, more, __get_str(buf)); | |
139 | ), | |
140 | ||
141 | TP_printk("%s\n%s", __get_str(header), __get_str(buf)) | |
142 | ) | |
143 | ||
144 | #define DEFINE_SKB_EVENT(name) \ | |
145 | DEFINE_EVENT(tipc_skb_class, name, \ | |
146 | TP_PROTO(struct sk_buff *skb, bool more, const char *header), \ | |
147 | TP_ARGS(skb, more, header)) | |
148 | DEFINE_SKB_EVENT(tipc_skb_dump); | |
26574db0 TL |
149 | DEFINE_SKB_EVENT(tipc_proto_build); |
150 | DEFINE_SKB_EVENT(tipc_proto_rcv); | |
b4b9771b TL |
151 | |
152 | DECLARE_EVENT_CLASS(tipc_list_class, | |
153 | ||
154 | TP_PROTO(struct sk_buff_head *list, bool more, const char *header), | |
155 | ||
156 | TP_ARGS(list, more, header), | |
157 | ||
158 | TP_STRUCT__entry( | |
159 | __string(header, header) | |
160 | __dynamic_array(char, buf, (more) ? LIST_LMAX : LIST_LMIN) | |
161 | ), | |
162 | ||
163 | TP_fast_assign( | |
164 | __assign_str(header, header); | |
165 | tipc_list_dump(list, more, __get_str(buf)); | |
166 | ), | |
167 | ||
168 | TP_printk("%s\n%s", __get_str(header), __get_str(buf)) | |
169 | ); | |
170 | ||
171 | #define DEFINE_LIST_EVENT(name) \ | |
172 | DEFINE_EVENT(tipc_list_class, name, \ | |
173 | TP_PROTO(struct sk_buff_head *list, bool more, const char *header), \ | |
174 | TP_ARGS(list, more, header)) | |
175 | DEFINE_LIST_EVENT(tipc_list_dump); | |
176 | ||
177 | DECLARE_EVENT_CLASS(tipc_sk_class, | |
178 | ||
179 | TP_PROTO(struct sock *sk, struct sk_buff *skb, u16 dqueues, | |
180 | const char *header), | |
181 | ||
182 | TP_ARGS(sk, skb, dqueues, header), | |
183 | ||
184 | TP_STRUCT__entry( | |
185 | __string(header, header) | |
186 | __field(u32, portid) | |
187 | __dynamic_array(char, buf, (dqueues) ? SK_LMAX : SK_LMIN) | |
188 | __dynamic_array(char, skb_buf, (skb) ? SKB_LMIN : 1) | |
189 | ), | |
190 | ||
191 | TP_fast_assign( | |
192 | __assign_str(header, header); | |
193 | __entry->portid = tipc_sock_get_portid(sk); | |
194 | tipc_sk_dump(sk, dqueues, __get_str(buf)); | |
195 | if (skb) | |
196 | tipc_skb_dump(skb, false, __get_str(skb_buf)); | |
197 | else | |
198 | *(__get_str(skb_buf)) = '\0'; | |
199 | ), | |
200 | ||
201 | TP_printk("<%u> %s\n%s%s", __entry->portid, __get_str(header), | |
202 | __get_str(skb_buf), __get_str(buf)) | |
203 | ); | |
204 | ||
01e661eb TL |
205 | #define DEFINE_SK_EVENT_FILTER(name) \ |
206 | DEFINE_EVENT_CONDITION(tipc_sk_class, name, \ | |
207 | TP_PROTO(struct sock *sk, struct sk_buff *skb, u16 dqueues, \ | |
208 | const char *header), \ | |
209 | TP_ARGS(sk, skb, dqueues, header), \ | |
210 | TP_CONDITION(tipc_sk_filtering(sk))) | |
211 | DEFINE_SK_EVENT_FILTER(tipc_sk_dump); | |
212 | DEFINE_SK_EVENT_FILTER(tipc_sk_create); | |
213 | DEFINE_SK_EVENT_FILTER(tipc_sk_sendmcast); | |
214 | DEFINE_SK_EVENT_FILTER(tipc_sk_sendmsg); | |
215 | DEFINE_SK_EVENT_FILTER(tipc_sk_sendstream); | |
216 | DEFINE_SK_EVENT_FILTER(tipc_sk_poll); | |
217 | DEFINE_SK_EVENT_FILTER(tipc_sk_filter_rcv); | |
218 | DEFINE_SK_EVENT_FILTER(tipc_sk_advance_rx); | |
219 | DEFINE_SK_EVENT_FILTER(tipc_sk_rej_msg); | |
220 | DEFINE_SK_EVENT_FILTER(tipc_sk_drop_msg); | |
221 | DEFINE_SK_EVENT_FILTER(tipc_sk_release); | |
222 | DEFINE_SK_EVENT_FILTER(tipc_sk_shutdown); | |
223 | ||
224 | #define DEFINE_SK_EVENT_FILTER_COND(name, cond) \ | |
225 | DEFINE_EVENT_CONDITION(tipc_sk_class, name, \ | |
b4b9771b TL |
226 | TP_PROTO(struct sock *sk, struct sk_buff *skb, u16 dqueues, \ |
227 | const char *header), \ | |
01e661eb TL |
228 | TP_ARGS(sk, skb, dqueues, header), \ |
229 | TP_CONDITION(tipc_sk_filtering(sk) && (cond))) | |
230 | DEFINE_SK_EVENT_FILTER_COND(tipc_sk_overlimit1, tipc_sk_overlimit1(sk, skb)); | |
231 | DEFINE_SK_EVENT_FILTER_COND(tipc_sk_overlimit2, tipc_sk_overlimit2(sk, skb)); | |
b4b9771b TL |
232 | |
233 | DECLARE_EVENT_CLASS(tipc_link_class, | |
234 | ||
235 | TP_PROTO(struct tipc_link *l, u16 dqueues, const char *header), | |
236 | ||
237 | TP_ARGS(l, dqueues, header), | |
238 | ||
239 | TP_STRUCT__entry( | |
240 | __string(header, header) | |
241 | __array(char, name, TIPC_MAX_LINK_NAME) | |
242 | __dynamic_array(char, buf, (dqueues) ? LINK_LMAX : LINK_LMIN) | |
243 | ), | |
244 | ||
245 | TP_fast_assign( | |
246 | __assign_str(header, header); | |
247 | tipc_link_name_ext(l, __entry->name); | |
248 | tipc_link_dump(l, dqueues, __get_str(buf)); | |
249 | ), | |
250 | ||
251 | TP_printk("<%s> %s\n%s", __entry->name, __get_str(header), | |
252 | __get_str(buf)) | |
253 | ); | |
254 | ||
255 | #define DEFINE_LINK_EVENT(name) \ | |
256 | DEFINE_EVENT(tipc_link_class, name, \ | |
257 | TP_PROTO(struct tipc_link *l, u16 dqueues, const char *header), \ | |
258 | TP_ARGS(l, dqueues, header)) | |
259 | DEFINE_LINK_EVENT(tipc_link_dump); | |
26574db0 TL |
260 | DEFINE_LINK_EVENT(tipc_link_conges); |
261 | DEFINE_LINK_EVENT(tipc_link_timeout); | |
262 | DEFINE_LINK_EVENT(tipc_link_reset); | |
263 | ||
264 | #define DEFINE_LINK_EVENT_COND(name, cond) \ | |
265 | DEFINE_EVENT_CONDITION(tipc_link_class, name, \ | |
266 | TP_PROTO(struct tipc_link *l, u16 dqueues, const char *header), \ | |
267 | TP_ARGS(l, dqueues, header), \ | |
268 | TP_CONDITION(cond)) | |
269 | DEFINE_LINK_EVENT_COND(tipc_link_too_silent, tipc_link_too_silent(l)); | |
270 | ||
271 | DECLARE_EVENT_CLASS(tipc_link_transmq_class, | |
272 | ||
273 | TP_PROTO(struct tipc_link *r, u16 f, u16 t, struct sk_buff_head *tq), | |
274 | ||
275 | TP_ARGS(r, f, t, tq), | |
276 | ||
277 | TP_STRUCT__entry( | |
278 | __array(char, name, TIPC_MAX_LINK_NAME) | |
279 | __field(u16, from) | |
280 | __field(u16, to) | |
281 | __field(u32, len) | |
282 | __field(u16, fseqno) | |
283 | __field(u16, lseqno) | |
284 | ), | |
285 | ||
286 | TP_fast_assign( | |
287 | tipc_link_name_ext(r, __entry->name); | |
288 | __entry->from = f; | |
289 | __entry->to = t; | |
290 | __entry->len = skb_queue_len(tq); | |
291 | __entry->fseqno = msg_seqno(buf_msg(skb_peek(tq))); | |
292 | __entry->lseqno = msg_seqno(buf_msg(skb_peek_tail(tq))); | |
293 | ), | |
294 | ||
295 | TP_printk("<%s> retrans req: [%u-%u] transmq: %u [%u-%u]\n", | |
296 | __entry->name, __entry->from, __entry->to, | |
297 | __entry->len, __entry->fseqno, __entry->lseqno) | |
298 | ); | |
299 | ||
300 | DEFINE_EVENT(tipc_link_transmq_class, tipc_link_retrans, | |
301 | TP_PROTO(struct tipc_link *r, u16 f, u16 t, struct sk_buff_head *tq), | |
302 | TP_ARGS(r, f, t, tq) | |
303 | ); | |
304 | ||
305 | DEFINE_EVENT_PRINT(tipc_link_transmq_class, tipc_link_bc_ack, | |
306 | TP_PROTO(struct tipc_link *r, u16 f, u16 t, struct sk_buff_head *tq), | |
307 | TP_ARGS(r, f, t, tq), | |
308 | TP_printk("<%s> acked: [%u-%u] transmq: %u [%u-%u]\n", | |
309 | __entry->name, __entry->from, __entry->to, | |
310 | __entry->len, __entry->fseqno, __entry->lseqno) | |
311 | ); | |
b4b9771b TL |
312 | |
313 | DECLARE_EVENT_CLASS(tipc_node_class, | |
314 | ||
315 | TP_PROTO(struct tipc_node *n, bool more, const char *header), | |
316 | ||
317 | TP_ARGS(n, more, header), | |
318 | ||
319 | TP_STRUCT__entry( | |
320 | __string(header, header) | |
321 | __field(u32, addr) | |
322 | __dynamic_array(char, buf, (more) ? NODE_LMAX : NODE_LMIN) | |
323 | ), | |
324 | ||
325 | TP_fast_assign( | |
326 | __assign_str(header, header); | |
327 | __entry->addr = tipc_node_get_addr(n); | |
328 | tipc_node_dump(n, more, __get_str(buf)); | |
329 | ), | |
330 | ||
331 | TP_printk("<%x> %s\n%s", __entry->addr, __get_str(header), | |
332 | __get_str(buf)) | |
333 | ); | |
334 | ||
335 | #define DEFINE_NODE_EVENT(name) \ | |
336 | DEFINE_EVENT(tipc_node_class, name, \ | |
337 | TP_PROTO(struct tipc_node *n, bool more, const char *header), \ | |
338 | TP_ARGS(n, more, header)) | |
339 | DEFINE_NODE_EVENT(tipc_node_dump); | |
eb18a510 TL |
340 | DEFINE_NODE_EVENT(tipc_node_create); |
341 | DEFINE_NODE_EVENT(tipc_node_delete); | |
342 | DEFINE_NODE_EVENT(tipc_node_lost_contact); | |
343 | DEFINE_NODE_EVENT(tipc_node_timeout); | |
344 | DEFINE_NODE_EVENT(tipc_node_link_up); | |
345 | DEFINE_NODE_EVENT(tipc_node_link_down); | |
346 | DEFINE_NODE_EVENT(tipc_node_reset_links); | |
347 | DEFINE_NODE_EVENT(tipc_node_check_state); | |
b4b9771b | 348 | |
26574db0 TL |
349 | DECLARE_EVENT_CLASS(tipc_fsm_class, |
350 | ||
351 | TP_PROTO(const char *name, u32 os, u32 ns, int evt), | |
352 | ||
353 | TP_ARGS(name, os, ns, evt), | |
354 | ||
355 | TP_STRUCT__entry( | |
356 | __string(name, name) | |
357 | __field(u32, os) | |
358 | __field(u32, ns) | |
359 | __field(u32, evt) | |
360 | ), | |
361 | ||
362 | TP_fast_assign( | |
363 | __assign_str(name, name); | |
364 | __entry->os = os; | |
365 | __entry->ns = ns; | |
366 | __entry->evt = evt; | |
367 | ), | |
368 | ||
369 | TP_printk("<%s> %s--(%s)->%s\n", __get_str(name), | |
370 | state_sym(__entry->os), evt_sym(__entry->evt), | |
371 | state_sym(__entry->ns)) | |
372 | ); | |
373 | ||
374 | #define DEFINE_FSM_EVENT(fsm_name) \ | |
375 | DEFINE_EVENT(tipc_fsm_class, fsm_name, \ | |
376 | TP_PROTO(const char *name, u32 os, u32 ns, int evt), \ | |
377 | TP_ARGS(name, os, ns, evt)) | |
378 | DEFINE_FSM_EVENT(tipc_link_fsm); | |
eb18a510 | 379 | DEFINE_FSM_EVENT(tipc_node_fsm); |
26574db0 | 380 | |
b4b9771b TL |
381 | #endif /* _TIPC_TRACE_H */ |
382 | ||
383 | /* This part must be outside protection */ | |
384 | #undef TRACE_INCLUDE_PATH | |
385 | #define TRACE_INCLUDE_PATH . | |
386 | #undef TRACE_INCLUDE_FILE | |
387 | #define TRACE_INCLUDE_FILE trace | |
388 | #include <trace/define_trace.h> |