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 | ||
b4b9771b TL |
116 | int tipc_skb_dump(struct sk_buff *skb, bool more, char *buf); |
117 | int tipc_list_dump(struct sk_buff_head *list, bool more, char *buf); | |
118 | int tipc_sk_dump(struct sock *sk, u16 dqueues, char *buf); | |
119 | int tipc_link_dump(struct tipc_link *l, u16 dqueues, char *buf); | |
120 | int tipc_node_dump(struct tipc_node *n, bool more, char *buf); | |
121 | ||
122 | DECLARE_EVENT_CLASS(tipc_skb_class, | |
123 | ||
124 | TP_PROTO(struct sk_buff *skb, bool more, const char *header), | |
125 | ||
126 | TP_ARGS(skb, more, header), | |
127 | ||
128 | TP_STRUCT__entry( | |
129 | __string(header, header) | |
130 | __dynamic_array(char, buf, (more) ? SKB_LMAX : SKB_LMIN) | |
131 | ), | |
132 | ||
133 | TP_fast_assign( | |
134 | __assign_str(header, header); | |
135 | tipc_skb_dump(skb, more, __get_str(buf)); | |
136 | ), | |
137 | ||
138 | TP_printk("%s\n%s", __get_str(header), __get_str(buf)) | |
139 | ) | |
140 | ||
141 | #define DEFINE_SKB_EVENT(name) \ | |
142 | DEFINE_EVENT(tipc_skb_class, name, \ | |
143 | TP_PROTO(struct sk_buff *skb, bool more, const char *header), \ | |
144 | TP_ARGS(skb, more, header)) | |
145 | DEFINE_SKB_EVENT(tipc_skb_dump); | |
26574db0 TL |
146 | DEFINE_SKB_EVENT(tipc_proto_build); |
147 | DEFINE_SKB_EVENT(tipc_proto_rcv); | |
b4b9771b TL |
148 | |
149 | DECLARE_EVENT_CLASS(tipc_list_class, | |
150 | ||
151 | TP_PROTO(struct sk_buff_head *list, bool more, const char *header), | |
152 | ||
153 | TP_ARGS(list, more, header), | |
154 | ||
155 | TP_STRUCT__entry( | |
156 | __string(header, header) | |
157 | __dynamic_array(char, buf, (more) ? LIST_LMAX : LIST_LMIN) | |
158 | ), | |
159 | ||
160 | TP_fast_assign( | |
161 | __assign_str(header, header); | |
162 | tipc_list_dump(list, more, __get_str(buf)); | |
163 | ), | |
164 | ||
165 | TP_printk("%s\n%s", __get_str(header), __get_str(buf)) | |
166 | ); | |
167 | ||
168 | #define DEFINE_LIST_EVENT(name) \ | |
169 | DEFINE_EVENT(tipc_list_class, name, \ | |
170 | TP_PROTO(struct sk_buff_head *list, bool more, const char *header), \ | |
171 | TP_ARGS(list, more, header)) | |
172 | DEFINE_LIST_EVENT(tipc_list_dump); | |
173 | ||
174 | DECLARE_EVENT_CLASS(tipc_sk_class, | |
175 | ||
176 | TP_PROTO(struct sock *sk, struct sk_buff *skb, u16 dqueues, | |
177 | const char *header), | |
178 | ||
179 | TP_ARGS(sk, skb, dqueues, header), | |
180 | ||
181 | TP_STRUCT__entry( | |
182 | __string(header, header) | |
183 | __field(u32, portid) | |
184 | __dynamic_array(char, buf, (dqueues) ? SK_LMAX : SK_LMIN) | |
185 | __dynamic_array(char, skb_buf, (skb) ? SKB_LMIN : 1) | |
186 | ), | |
187 | ||
188 | TP_fast_assign( | |
189 | __assign_str(header, header); | |
190 | __entry->portid = tipc_sock_get_portid(sk); | |
191 | tipc_sk_dump(sk, dqueues, __get_str(buf)); | |
192 | if (skb) | |
193 | tipc_skb_dump(skb, false, __get_str(skb_buf)); | |
194 | else | |
195 | *(__get_str(skb_buf)) = '\0'; | |
196 | ), | |
197 | ||
198 | TP_printk("<%u> %s\n%s%s", __entry->portid, __get_str(header), | |
199 | __get_str(skb_buf), __get_str(buf)) | |
200 | ); | |
201 | ||
202 | #define DEFINE_SK_EVENT(name) \ | |
203 | DEFINE_EVENT(tipc_sk_class, name, \ | |
204 | TP_PROTO(struct sock *sk, struct sk_buff *skb, u16 dqueues, \ | |
205 | const char *header), \ | |
206 | TP_ARGS(sk, skb, dqueues, header)) | |
207 | DEFINE_SK_EVENT(tipc_sk_dump); | |
208 | ||
209 | DECLARE_EVENT_CLASS(tipc_link_class, | |
210 | ||
211 | TP_PROTO(struct tipc_link *l, u16 dqueues, const char *header), | |
212 | ||
213 | TP_ARGS(l, dqueues, header), | |
214 | ||
215 | TP_STRUCT__entry( | |
216 | __string(header, header) | |
217 | __array(char, name, TIPC_MAX_LINK_NAME) | |
218 | __dynamic_array(char, buf, (dqueues) ? LINK_LMAX : LINK_LMIN) | |
219 | ), | |
220 | ||
221 | TP_fast_assign( | |
222 | __assign_str(header, header); | |
223 | tipc_link_name_ext(l, __entry->name); | |
224 | tipc_link_dump(l, dqueues, __get_str(buf)); | |
225 | ), | |
226 | ||
227 | TP_printk("<%s> %s\n%s", __entry->name, __get_str(header), | |
228 | __get_str(buf)) | |
229 | ); | |
230 | ||
231 | #define DEFINE_LINK_EVENT(name) \ | |
232 | DEFINE_EVENT(tipc_link_class, name, \ | |
233 | TP_PROTO(struct tipc_link *l, u16 dqueues, const char *header), \ | |
234 | TP_ARGS(l, dqueues, header)) | |
235 | DEFINE_LINK_EVENT(tipc_link_dump); | |
26574db0 TL |
236 | DEFINE_LINK_EVENT(tipc_link_conges); |
237 | DEFINE_LINK_EVENT(tipc_link_timeout); | |
238 | DEFINE_LINK_EVENT(tipc_link_reset); | |
239 | ||
240 | #define DEFINE_LINK_EVENT_COND(name, cond) \ | |
241 | DEFINE_EVENT_CONDITION(tipc_link_class, name, \ | |
242 | TP_PROTO(struct tipc_link *l, u16 dqueues, const char *header), \ | |
243 | TP_ARGS(l, dqueues, header), \ | |
244 | TP_CONDITION(cond)) | |
245 | DEFINE_LINK_EVENT_COND(tipc_link_too_silent, tipc_link_too_silent(l)); | |
246 | ||
247 | DECLARE_EVENT_CLASS(tipc_link_transmq_class, | |
248 | ||
249 | TP_PROTO(struct tipc_link *r, u16 f, u16 t, struct sk_buff_head *tq), | |
250 | ||
251 | TP_ARGS(r, f, t, tq), | |
252 | ||
253 | TP_STRUCT__entry( | |
254 | __array(char, name, TIPC_MAX_LINK_NAME) | |
255 | __field(u16, from) | |
256 | __field(u16, to) | |
257 | __field(u32, len) | |
258 | __field(u16, fseqno) | |
259 | __field(u16, lseqno) | |
260 | ), | |
261 | ||
262 | TP_fast_assign( | |
263 | tipc_link_name_ext(r, __entry->name); | |
264 | __entry->from = f; | |
265 | __entry->to = t; | |
266 | __entry->len = skb_queue_len(tq); | |
267 | __entry->fseqno = msg_seqno(buf_msg(skb_peek(tq))); | |
268 | __entry->lseqno = msg_seqno(buf_msg(skb_peek_tail(tq))); | |
269 | ), | |
270 | ||
271 | TP_printk("<%s> retrans req: [%u-%u] transmq: %u [%u-%u]\n", | |
272 | __entry->name, __entry->from, __entry->to, | |
273 | __entry->len, __entry->fseqno, __entry->lseqno) | |
274 | ); | |
275 | ||
276 | DEFINE_EVENT(tipc_link_transmq_class, tipc_link_retrans, | |
277 | TP_PROTO(struct tipc_link *r, u16 f, u16 t, struct sk_buff_head *tq), | |
278 | TP_ARGS(r, f, t, tq) | |
279 | ); | |
280 | ||
281 | DEFINE_EVENT_PRINT(tipc_link_transmq_class, tipc_link_bc_ack, | |
282 | TP_PROTO(struct tipc_link *r, u16 f, u16 t, struct sk_buff_head *tq), | |
283 | TP_ARGS(r, f, t, tq), | |
284 | TP_printk("<%s> acked: [%u-%u] transmq: %u [%u-%u]\n", | |
285 | __entry->name, __entry->from, __entry->to, | |
286 | __entry->len, __entry->fseqno, __entry->lseqno) | |
287 | ); | |
b4b9771b TL |
288 | |
289 | DECLARE_EVENT_CLASS(tipc_node_class, | |
290 | ||
291 | TP_PROTO(struct tipc_node *n, bool more, const char *header), | |
292 | ||
293 | TP_ARGS(n, more, header), | |
294 | ||
295 | TP_STRUCT__entry( | |
296 | __string(header, header) | |
297 | __field(u32, addr) | |
298 | __dynamic_array(char, buf, (more) ? NODE_LMAX : NODE_LMIN) | |
299 | ), | |
300 | ||
301 | TP_fast_assign( | |
302 | __assign_str(header, header); | |
303 | __entry->addr = tipc_node_get_addr(n); | |
304 | tipc_node_dump(n, more, __get_str(buf)); | |
305 | ), | |
306 | ||
307 | TP_printk("<%x> %s\n%s", __entry->addr, __get_str(header), | |
308 | __get_str(buf)) | |
309 | ); | |
310 | ||
311 | #define DEFINE_NODE_EVENT(name) \ | |
312 | DEFINE_EVENT(tipc_node_class, name, \ | |
313 | TP_PROTO(struct tipc_node *n, bool more, const char *header), \ | |
314 | TP_ARGS(n, more, header)) | |
315 | DEFINE_NODE_EVENT(tipc_node_dump); | |
316 | ||
26574db0 TL |
317 | DECLARE_EVENT_CLASS(tipc_fsm_class, |
318 | ||
319 | TP_PROTO(const char *name, u32 os, u32 ns, int evt), | |
320 | ||
321 | TP_ARGS(name, os, ns, evt), | |
322 | ||
323 | TP_STRUCT__entry( | |
324 | __string(name, name) | |
325 | __field(u32, os) | |
326 | __field(u32, ns) | |
327 | __field(u32, evt) | |
328 | ), | |
329 | ||
330 | TP_fast_assign( | |
331 | __assign_str(name, name); | |
332 | __entry->os = os; | |
333 | __entry->ns = ns; | |
334 | __entry->evt = evt; | |
335 | ), | |
336 | ||
337 | TP_printk("<%s> %s--(%s)->%s\n", __get_str(name), | |
338 | state_sym(__entry->os), evt_sym(__entry->evt), | |
339 | state_sym(__entry->ns)) | |
340 | ); | |
341 | ||
342 | #define DEFINE_FSM_EVENT(fsm_name) \ | |
343 | DEFINE_EVENT(tipc_fsm_class, fsm_name, \ | |
344 | TP_PROTO(const char *name, u32 os, u32 ns, int evt), \ | |
345 | TP_ARGS(name, os, ns, evt)) | |
346 | DEFINE_FSM_EVENT(tipc_link_fsm); | |
347 | ||
b4b9771b TL |
348 | #endif /* _TIPC_TRACE_H */ |
349 | ||
350 | /* This part must be outside protection */ | |
351 | #undef TRACE_INCLUDE_PATH | |
352 | #define TRACE_INCLUDE_PATH . | |
353 | #undef TRACE_INCLUDE_FILE | |
354 | #define TRACE_INCLUDE_FILE trace | |
355 | #include <trace/define_trace.h> |