rxrpc: Add per-peer RTT tracker
[cascardo/linux.git] / include / trace / events / rxrpc.h
1 /* AF_RXRPC tracepoints
2  *
3  * Copyright (C) 2016 Red Hat, Inc. All Rights Reserved.
4  * Written by David Howells (dhowells@redhat.com)
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public Licence
8  * as published by the Free Software Foundation; either version
9  * 2 of the Licence, or (at your option) any later version.
10  */
11 #undef TRACE_SYSTEM
12 #define TRACE_SYSTEM rxrpc
13
14 #if !defined(_TRACE_RXRPC_H) || defined(TRACE_HEADER_MULTI_READ)
15 #define _TRACE_RXRPC_H
16
17 #include <linux/tracepoint.h>
18
19 TRACE_EVENT(rxrpc_conn,
20             TP_PROTO(struct rxrpc_connection *conn, enum rxrpc_conn_trace op,
21                      int usage, const void *where),
22
23             TP_ARGS(conn, op, usage, where),
24
25             TP_STRUCT__entry(
26                     __field(struct rxrpc_connection *,  conn            )
27                     __field(int,                        op              )
28                     __field(int,                        usage           )
29                     __field(const void *,               where           )
30                              ),
31
32             TP_fast_assign(
33                     __entry->conn = conn;
34                     __entry->op = op;
35                     __entry->usage = usage;
36                     __entry->where = where;
37                            ),
38
39             TP_printk("C=%p %s u=%d sp=%pSR",
40                       __entry->conn,
41                       rxrpc_conn_traces[__entry->op],
42                       __entry->usage,
43                       __entry->where)
44             );
45
46 TRACE_EVENT(rxrpc_client,
47             TP_PROTO(struct rxrpc_connection *conn, int channel,
48                      enum rxrpc_client_trace op),
49
50             TP_ARGS(conn, channel, op),
51
52             TP_STRUCT__entry(
53                     __field(struct rxrpc_connection *,  conn            )
54                     __field(u32,                        cid             )
55                     __field(int,                        channel         )
56                     __field(int,                        usage           )
57                     __field(enum rxrpc_client_trace,    op              )
58                     __field(enum rxrpc_conn_cache_state, cs             )
59                              ),
60
61             TP_fast_assign(
62                     __entry->conn = conn;
63                     __entry->channel = channel;
64                     __entry->usage = atomic_read(&conn->usage);
65                     __entry->op = op;
66                     __entry->cid = conn->proto.cid;
67                     __entry->cs = conn->cache_state;
68                            ),
69
70             TP_printk("C=%p h=%2d %s %s i=%08x u=%d",
71                       __entry->conn,
72                       __entry->channel,
73                       rxrpc_client_traces[__entry->op],
74                       rxrpc_conn_cache_states[__entry->cs],
75                       __entry->cid,
76                       __entry->usage)
77             );
78
79 TRACE_EVENT(rxrpc_call,
80             TP_PROTO(struct rxrpc_call *call, enum rxrpc_call_trace op,
81                      int usage, const void *where, const void *aux),
82
83             TP_ARGS(call, op, usage, where, aux),
84
85             TP_STRUCT__entry(
86                     __field(struct rxrpc_call *,        call            )
87                     __field(int,                        op              )
88                     __field(int,                        usage           )
89                     __field(const void *,               where           )
90                     __field(const void *,               aux             )
91                              ),
92
93             TP_fast_assign(
94                     __entry->call = call;
95                     __entry->op = op;
96                     __entry->usage = usage;
97                     __entry->where = where;
98                     __entry->aux = aux;
99                            ),
100
101             TP_printk("c=%p %s u=%d sp=%pSR a=%p",
102                       __entry->call,
103                       rxrpc_call_traces[__entry->op],
104                       __entry->usage,
105                       __entry->where,
106                       __entry->aux)
107             );
108
109 TRACE_EVENT(rxrpc_skb,
110             TP_PROTO(struct sk_buff *skb, enum rxrpc_skb_trace op,
111                      int usage, int mod_count, const void *where),
112
113             TP_ARGS(skb, op, usage, mod_count, where),
114
115             TP_STRUCT__entry(
116                     __field(struct sk_buff *,           skb             )
117                     __field(enum rxrpc_skb_trace,       op              )
118                     __field(int,                        usage           )
119                     __field(int,                        mod_count       )
120                     __field(const void *,               where           )
121                              ),
122
123             TP_fast_assign(
124                     __entry->skb = skb;
125                     __entry->op = op;
126                     __entry->usage = usage;
127                     __entry->mod_count = mod_count;
128                     __entry->where = where;
129                            ),
130
131             TP_printk("s=%p %s u=%d m=%d p=%pSR",
132                       __entry->skb,
133                       rxrpc_skb_traces[__entry->op],
134                       __entry->usage,
135                       __entry->mod_count,
136                       __entry->where)
137             );
138
139 TRACE_EVENT(rxrpc_rx_packet,
140             TP_PROTO(struct rxrpc_skb_priv *sp),
141
142             TP_ARGS(sp),
143
144             TP_STRUCT__entry(
145                     __field_struct(struct rxrpc_host_header,    hdr             )
146                              ),
147
148             TP_fast_assign(
149                     memcpy(&__entry->hdr, &sp->hdr, sizeof(__entry->hdr));
150                            ),
151
152             TP_printk("%08x:%08x:%08x:%04x %08x %08x %02x %02x %s",
153                       __entry->hdr.epoch, __entry->hdr.cid,
154                       __entry->hdr.callNumber, __entry->hdr.serviceId,
155                       __entry->hdr.serial, __entry->hdr.seq,
156                       __entry->hdr.type, __entry->hdr.flags,
157                       __entry->hdr.type <= 15 ? rxrpc_pkts[__entry->hdr.type] : "?UNK")
158             );
159
160 TRACE_EVENT(rxrpc_rx_done,
161             TP_PROTO(int result, int abort_code),
162
163             TP_ARGS(result, abort_code),
164
165             TP_STRUCT__entry(
166                     __field(int,                        result          )
167                     __field(int,                        abort_code      )
168                              ),
169
170             TP_fast_assign(
171                     __entry->result = result;
172                     __entry->abort_code = abort_code;
173                            ),
174
175             TP_printk("r=%d a=%d", __entry->result, __entry->abort_code)
176             );
177
178 TRACE_EVENT(rxrpc_abort,
179             TP_PROTO(const char *why, u32 cid, u32 call_id, rxrpc_seq_t seq,
180                      int abort_code, int error),
181
182             TP_ARGS(why, cid, call_id, seq, abort_code, error),
183
184             TP_STRUCT__entry(
185                     __array(char,                       why, 4          )
186                     __field(u32,                        cid             )
187                     __field(u32,                        call_id         )
188                     __field(rxrpc_seq_t,                seq             )
189                     __field(int,                        abort_code      )
190                     __field(int,                        error           )
191                              ),
192
193             TP_fast_assign(
194                     memcpy(__entry->why, why, 4);
195                     __entry->cid = cid;
196                     __entry->call_id = call_id;
197                     __entry->abort_code = abort_code;
198                     __entry->error = error;
199                     __entry->seq = seq;
200                            ),
201
202             TP_printk("%08x:%08x s=%u a=%d e=%d %s",
203                       __entry->cid, __entry->call_id, __entry->seq,
204                       __entry->abort_code, __entry->error, __entry->why)
205             );
206
207 TRACE_EVENT(rxrpc_transmit,
208             TP_PROTO(struct rxrpc_call *call, enum rxrpc_transmit_trace why),
209
210             TP_ARGS(call, why),
211
212             TP_STRUCT__entry(
213                     __field(struct rxrpc_call *,        call            )
214                     __field(enum rxrpc_transmit_trace,  why             )
215                     __field(rxrpc_seq_t,                tx_hard_ack     )
216                     __field(rxrpc_seq_t,                tx_top          )
217                              ),
218
219             TP_fast_assign(
220                     __entry->call = call;
221                     __entry->why = why;
222                     __entry->tx_hard_ack = call->tx_hard_ack;
223                     __entry->tx_top = call->tx_top;
224                            ),
225
226             TP_printk("c=%p %s f=%08x n=%u",
227                       __entry->call,
228                       rxrpc_transmit_traces[__entry->why],
229                       __entry->tx_hard_ack + 1,
230                       __entry->tx_top - __entry->tx_hard_ack)
231             );
232
233 TRACE_EVENT(rxrpc_rx_ack,
234             TP_PROTO(struct rxrpc_call *call, rxrpc_seq_t first, u8 reason, u8 n_acks),
235
236             TP_ARGS(call, first, reason, n_acks),
237
238             TP_STRUCT__entry(
239                     __field(struct rxrpc_call *,        call            )
240                     __field(rxrpc_seq_t,                first           )
241                     __field(u8,                         reason          )
242                     __field(u8,                         n_acks          )
243                              ),
244
245             TP_fast_assign(
246                     __entry->call = call;
247                     __entry->first = first;
248                     __entry->reason = reason;
249                     __entry->n_acks = n_acks;
250                            ),
251
252             TP_printk("c=%p %s f=%08x n=%u",
253                       __entry->call,
254                       rxrpc_acks(__entry->reason),
255                       __entry->first,
256                       __entry->n_acks)
257             );
258
259 TRACE_EVENT(rxrpc_tx_ack,
260             TP_PROTO(struct rxrpc_call *call, rxrpc_seq_t first,
261                      rxrpc_serial_t serial, u8 reason, u8 n_acks),
262
263             TP_ARGS(call, first, serial, reason, n_acks),
264
265             TP_STRUCT__entry(
266                     __field(struct rxrpc_call *,        call            )
267                     __field(rxrpc_seq_t,                first           )
268                     __field(rxrpc_serial_t,             serial          )
269                     __field(u8,                         reason          )
270                     __field(u8,                         n_acks          )
271                              ),
272
273             TP_fast_assign(
274                     __entry->call = call;
275                     __entry->first = first;
276                     __entry->serial = serial;
277                     __entry->reason = reason;
278                     __entry->n_acks = n_acks;
279                            ),
280
281             TP_printk("c=%p %s f=%08x r=%08x n=%u",
282                       __entry->call,
283                       rxrpc_acks(__entry->reason),
284                       __entry->first,
285                       __entry->serial,
286                       __entry->n_acks)
287             );
288
289 TRACE_EVENT(rxrpc_receive,
290             TP_PROTO(struct rxrpc_call *call, enum rxrpc_receive_trace why,
291                      rxrpc_serial_t serial, rxrpc_seq_t seq),
292
293             TP_ARGS(call, why, serial, seq),
294
295             TP_STRUCT__entry(
296                     __field(struct rxrpc_call *,        call            )
297                     __field(enum rxrpc_receive_trace,   why             )
298                     __field(rxrpc_serial_t,             serial          )
299                     __field(rxrpc_seq_t,                seq             )
300                     __field(rxrpc_seq_t,                hard_ack        )
301                     __field(rxrpc_seq_t,                top             )
302                              ),
303
304             TP_fast_assign(
305                     __entry->call = call;
306                     __entry->why = why;
307                     __entry->serial = serial;
308                     __entry->seq = seq;
309                     __entry->hard_ack = call->rx_hard_ack;
310                     __entry->top = call->rx_top;
311                            ),
312
313             TP_printk("c=%p %s r=%08x q=%08x w=%08x-%08x",
314                       __entry->call,
315                       rxrpc_receive_traces[__entry->why],
316                       __entry->serial,
317                       __entry->seq,
318                       __entry->hard_ack,
319                       __entry->top)
320             );
321
322 TRACE_EVENT(rxrpc_recvmsg,
323             TP_PROTO(struct rxrpc_call *call, enum rxrpc_recvmsg_trace why,
324                      rxrpc_seq_t seq, unsigned int offset, unsigned int len,
325                      int ret),
326
327             TP_ARGS(call, why, seq, offset, len, ret),
328
329             TP_STRUCT__entry(
330                     __field(struct rxrpc_call *,        call            )
331                     __field(enum rxrpc_recvmsg_trace,   why             )
332                     __field(rxrpc_seq_t,                seq             )
333                     __field(unsigned int,               offset          )
334                     __field(unsigned int,               len             )
335                     __field(int,                        ret             )
336                              ),
337
338             TP_fast_assign(
339                     __entry->call = call;
340                     __entry->why = why;
341                     __entry->seq = seq;
342                     __entry->offset = offset;
343                     __entry->len = len;
344                     __entry->ret = ret;
345                            ),
346
347             TP_printk("c=%p %s q=%08x o=%u l=%u ret=%d",
348                       __entry->call,
349                       rxrpc_recvmsg_traces[__entry->why],
350                       __entry->seq,
351                       __entry->offset,
352                       __entry->len,
353                       __entry->ret)
354             );
355
356 TRACE_EVENT(rxrpc_rtt_tx,
357             TP_PROTO(struct rxrpc_call *call, enum rxrpc_rtt_tx_trace why,
358                      rxrpc_serial_t send_serial),
359
360             TP_ARGS(call, why, send_serial),
361
362             TP_STRUCT__entry(
363                     __field(struct rxrpc_call *,        call            )
364                     __field(enum rxrpc_rtt_tx_trace,    why             )
365                     __field(rxrpc_serial_t,             send_serial     )
366                              ),
367
368             TP_fast_assign(
369                     __entry->call = call;
370                     __entry->why = why;
371                     __entry->send_serial = send_serial;
372                            ),
373
374             TP_printk("c=%p %s sr=%08x",
375                       __entry->call,
376                       rxrpc_rtt_tx_traces[__entry->why],
377                       __entry->send_serial)
378             );
379
380 TRACE_EVENT(rxrpc_rtt_rx,
381             TP_PROTO(struct rxrpc_call *call, enum rxrpc_rtt_rx_trace why,
382                      rxrpc_serial_t send_serial, rxrpc_serial_t resp_serial,
383                      s64 rtt, u8 nr, s64 avg),
384
385             TP_ARGS(call, why, send_serial, resp_serial, rtt, nr, avg),
386
387             TP_STRUCT__entry(
388                     __field(struct rxrpc_call *,        call            )
389                     __field(enum rxrpc_rtt_rx_trace,    why             )
390                     __field(u8,                         nr              )
391                     __field(rxrpc_serial_t,             send_serial     )
392                     __field(rxrpc_serial_t,             resp_serial     )
393                     __field(s64,                        rtt             )
394                     __field(u64,                        avg             )
395                              ),
396
397             TP_fast_assign(
398                     __entry->call = call;
399                     __entry->why = why;
400                     __entry->send_serial = send_serial;
401                     __entry->resp_serial = resp_serial;
402                     __entry->rtt = rtt;
403                     __entry->nr = nr;
404                     __entry->avg = avg;
405                            ),
406
407             TP_printk("c=%p %s sr=%08x rr=%08x rtt=%lld nr=%u avg=%lld",
408                       __entry->call,
409                       rxrpc_rtt_rx_traces[__entry->why],
410                       __entry->send_serial,
411                       __entry->resp_serial,
412                       __entry->rtt,
413                       __entry->nr,
414                       __entry->avg)
415             );
416
417 #endif /* _TRACE_RXRPC_H */
418
419 /* This part must be outside protection */
420 #include <trace/define_trace.h>