1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3 * Trace points for SSAM/SSH.
4 *
5 * Copyright (C) 2020-2022 Maximilian Luz <luzmaximilian@gmail.com>
6 */
7
8 #undef TRACE_SYSTEM
9 #define TRACE_SYSTEM surface_aggregator
10
11 #if !defined(_SURFACE_AGGREGATOR_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
12 #define _SURFACE_AGGREGATOR_TRACE_H
13
14 #include <linux/surface_aggregator/serial_hub.h>
15
16 #include <asm/unaligned.h>
17 #include <linux/tracepoint.h>
18
19 TRACE_DEFINE_ENUM(SSH_FRAME_TYPE_DATA_SEQ);
20 TRACE_DEFINE_ENUM(SSH_FRAME_TYPE_DATA_NSQ);
21 TRACE_DEFINE_ENUM(SSH_FRAME_TYPE_ACK);
22 TRACE_DEFINE_ENUM(SSH_FRAME_TYPE_NAK);
23
24 TRACE_DEFINE_ENUM(SSH_PACKET_SF_LOCKED_BIT);
25 TRACE_DEFINE_ENUM(SSH_PACKET_SF_QUEUED_BIT);
26 TRACE_DEFINE_ENUM(SSH_PACKET_SF_PENDING_BIT);
27 TRACE_DEFINE_ENUM(SSH_PACKET_SF_TRANSMITTING_BIT);
28 TRACE_DEFINE_ENUM(SSH_PACKET_SF_TRANSMITTED_BIT);
29 TRACE_DEFINE_ENUM(SSH_PACKET_SF_ACKED_BIT);
30 TRACE_DEFINE_ENUM(SSH_PACKET_SF_CANCELED_BIT);
31 TRACE_DEFINE_ENUM(SSH_PACKET_SF_COMPLETED_BIT);
32
33 TRACE_DEFINE_ENUM(SSH_PACKET_TY_FLUSH_BIT);
34 TRACE_DEFINE_ENUM(SSH_PACKET_TY_SEQUENCED_BIT);
35 TRACE_DEFINE_ENUM(SSH_PACKET_TY_BLOCKING_BIT);
36
37 TRACE_DEFINE_ENUM(SSH_PACKET_FLAGS_SF_MASK);
38 TRACE_DEFINE_ENUM(SSH_PACKET_FLAGS_TY_MASK);
39
40 TRACE_DEFINE_ENUM(SSH_REQUEST_SF_LOCKED_BIT);
41 TRACE_DEFINE_ENUM(SSH_REQUEST_SF_QUEUED_BIT);
42 TRACE_DEFINE_ENUM(SSH_REQUEST_SF_PENDING_BIT);
43 TRACE_DEFINE_ENUM(SSH_REQUEST_SF_TRANSMITTING_BIT);
44 TRACE_DEFINE_ENUM(SSH_REQUEST_SF_TRANSMITTED_BIT);
45 TRACE_DEFINE_ENUM(SSH_REQUEST_SF_RSPRCVD_BIT);
46 TRACE_DEFINE_ENUM(SSH_REQUEST_SF_CANCELED_BIT);
47 TRACE_DEFINE_ENUM(SSH_REQUEST_SF_COMPLETED_BIT);
48
49 TRACE_DEFINE_ENUM(SSH_REQUEST_TY_FLUSH_BIT);
50 TRACE_DEFINE_ENUM(SSH_REQUEST_TY_HAS_RESPONSE_BIT);
51
52 TRACE_DEFINE_ENUM(SSH_REQUEST_FLAGS_SF_MASK);
53 TRACE_DEFINE_ENUM(SSH_REQUEST_FLAGS_TY_MASK);
54
55 TRACE_DEFINE_ENUM(SSAM_SSH_TC_SAM);
56 TRACE_DEFINE_ENUM(SSAM_SSH_TC_BAT);
57 TRACE_DEFINE_ENUM(SSAM_SSH_TC_TMP);
58 TRACE_DEFINE_ENUM(SSAM_SSH_TC_PMC);
59 TRACE_DEFINE_ENUM(SSAM_SSH_TC_FAN);
60 TRACE_DEFINE_ENUM(SSAM_SSH_TC_PoM);
61 TRACE_DEFINE_ENUM(SSAM_SSH_TC_DBG);
62 TRACE_DEFINE_ENUM(SSAM_SSH_TC_KBD);
63 TRACE_DEFINE_ENUM(SSAM_SSH_TC_FWU);
64 TRACE_DEFINE_ENUM(SSAM_SSH_TC_UNI);
65 TRACE_DEFINE_ENUM(SSAM_SSH_TC_LPC);
66 TRACE_DEFINE_ENUM(SSAM_SSH_TC_TCL);
67 TRACE_DEFINE_ENUM(SSAM_SSH_TC_SFL);
68 TRACE_DEFINE_ENUM(SSAM_SSH_TC_KIP);
69 TRACE_DEFINE_ENUM(SSAM_SSH_TC_EXT);
70 TRACE_DEFINE_ENUM(SSAM_SSH_TC_BLD);
71 TRACE_DEFINE_ENUM(SSAM_SSH_TC_BAS);
72 TRACE_DEFINE_ENUM(SSAM_SSH_TC_SEN);
73 TRACE_DEFINE_ENUM(SSAM_SSH_TC_SRQ);
74 TRACE_DEFINE_ENUM(SSAM_SSH_TC_MCU);
75 TRACE_DEFINE_ENUM(SSAM_SSH_TC_HID);
76 TRACE_DEFINE_ENUM(SSAM_SSH_TC_TCH);
77 TRACE_DEFINE_ENUM(SSAM_SSH_TC_BKL);
78 TRACE_DEFINE_ENUM(SSAM_SSH_TC_TAM);
79 TRACE_DEFINE_ENUM(SSAM_SSH_TC_ACC0);
80 TRACE_DEFINE_ENUM(SSAM_SSH_TC_UFI);
81 TRACE_DEFINE_ENUM(SSAM_SSH_TC_USC);
82 TRACE_DEFINE_ENUM(SSAM_SSH_TC_PEN);
83 TRACE_DEFINE_ENUM(SSAM_SSH_TC_VID);
84 TRACE_DEFINE_ENUM(SSAM_SSH_TC_AUD);
85 TRACE_DEFINE_ENUM(SSAM_SSH_TC_SMC);
86 TRACE_DEFINE_ENUM(SSAM_SSH_TC_KPD);
87 TRACE_DEFINE_ENUM(SSAM_SSH_TC_REG);
88 TRACE_DEFINE_ENUM(SSAM_SSH_TC_SPT);
89 TRACE_DEFINE_ENUM(SSAM_SSH_TC_SYS);
90 TRACE_DEFINE_ENUM(SSAM_SSH_TC_ACC1);
91 TRACE_DEFINE_ENUM(SSAM_SSH_TC_SHB);
92 TRACE_DEFINE_ENUM(SSAM_SSH_TC_POS);
93
94 #define SSAM_PTR_UID_LEN 9
95 #define SSAM_U8_FIELD_NOT_APPLICABLE ((u16)-1)
96 #define SSAM_SEQ_NOT_APPLICABLE ((u16)-1)
97 #define SSAM_RQID_NOT_APPLICABLE ((u32)-1)
98 #define SSAM_SSH_TC_NOT_APPLICABLE 0
99 #define SSAM_SSH_TID_NOT_APPLICABLE ((u8)-1)
100
101 #ifndef _SURFACE_AGGREGATOR_TRACE_HELPERS
102 #define _SURFACE_AGGREGATOR_TRACE_HELPERS
103
104 /**
105 * ssam_trace_ptr_uid() - Convert the pointer to a non-pointer UID string.
106 * @ptr: The pointer to convert.
107 * @uid_str: A buffer of length SSAM_PTR_UID_LEN where the UID will be stored.
108 *
109 * Converts the given pointer into a UID string that is safe to be shared
110 * with userspace and logs, i.e. doesn't give away the real memory location.
111 */
ssam_trace_ptr_uid(const void * ptr,char * uid_str)112 static inline void ssam_trace_ptr_uid(const void *ptr, char *uid_str)
113 {
114 char buf[2 * sizeof(void *) + 1];
115
116 BUILD_BUG_ON(ARRAY_SIZE(buf) < SSAM_PTR_UID_LEN);
117
118 snprintf(buf, ARRAY_SIZE(buf), "%p", ptr);
119 memcpy(uid_str, &buf[ARRAY_SIZE(buf) - SSAM_PTR_UID_LEN],
120 SSAM_PTR_UID_LEN);
121 }
122
123 /**
124 * ssam_trace_get_packet_seq() - Read the packet's sequence ID.
125 * @p: The packet.
126 *
127 * Return: Returns the packet's sequence ID (SEQ) field if present, or
128 * %SSAM_SEQ_NOT_APPLICABLE if not (e.g. flush packet).
129 */
ssam_trace_get_packet_seq(const struct ssh_packet * p)130 static inline u16 ssam_trace_get_packet_seq(const struct ssh_packet *p)
131 {
132 if (!p->data.ptr || p->data.len < SSH_MESSAGE_LENGTH(0))
133 return SSAM_SEQ_NOT_APPLICABLE;
134
135 return p->data.ptr[SSH_MSGOFFSET_FRAME(seq)];
136 }
137
138 /**
139 * ssam_trace_get_request_id() - Read the packet's request ID.
140 * @p: The packet.
141 *
142 * Return: Returns the packet's request ID (RQID) field if the packet
143 * represents a request with command data, or %SSAM_RQID_NOT_APPLICABLE if not
144 * (e.g. flush request, control packet).
145 */
ssam_trace_get_request_id(const struct ssh_packet * p)146 static inline u32 ssam_trace_get_request_id(const struct ssh_packet *p)
147 {
148 if (!p->data.ptr || p->data.len < SSH_COMMAND_MESSAGE_LENGTH(0))
149 return SSAM_RQID_NOT_APPLICABLE;
150
151 return get_unaligned_le16(&p->data.ptr[SSH_MSGOFFSET_COMMAND(rqid)]);
152 }
153
154 /**
155 * ssam_trace_get_request_tid() - Read the packet's request target ID.
156 * @p: The packet.
157 *
158 * Return: Returns the packet's request target ID (TID) field if the packet
159 * represents a request with command data, or %SSAM_SSH_TID_NOT_APPLICABLE
160 * if not (e.g. flush request, control packet).
161 */
ssam_trace_get_request_tid(const struct ssh_packet * p)162 static inline u32 ssam_trace_get_request_tid(const struct ssh_packet *p)
163 {
164 if (!p->data.ptr || p->data.len < SSH_COMMAND_MESSAGE_LENGTH(0))
165 return SSAM_SSH_TID_NOT_APPLICABLE;
166
167 return get_unaligned_le16(&p->data.ptr[SSH_MSGOFFSET_COMMAND(tid)]);
168 }
169
170 /**
171 * ssam_trace_get_request_sid() - Read the packet's request source ID.
172 * @p: The packet.
173 *
174 * Return: Returns the packet's request source ID (SID) field if the packet
175 * represents a request with command data, or %SSAM_SSH_TID_NOT_APPLICABLE
176 * if not (e.g. flush request, control packet).
177 */
ssam_trace_get_request_sid(const struct ssh_packet * p)178 static inline u32 ssam_trace_get_request_sid(const struct ssh_packet *p)
179 {
180 if (!p->data.ptr || p->data.len < SSH_COMMAND_MESSAGE_LENGTH(0))
181 return SSAM_SSH_TID_NOT_APPLICABLE;
182
183 return get_unaligned_le16(&p->data.ptr[SSH_MSGOFFSET_COMMAND(sid)]);
184 }
185
186 /**
187 * ssam_trace_get_request_tc() - Read the packet's request target category.
188 * @p: The packet.
189 *
190 * Return: Returns the packet's request target category (TC) field if the
191 * packet represents a request with command data, or %SSAM_SSH_TC_NOT_APPLICABLE
192 * if not (e.g. flush request, control packet).
193 */
ssam_trace_get_request_tc(const struct ssh_packet * p)194 static inline u32 ssam_trace_get_request_tc(const struct ssh_packet *p)
195 {
196 if (!p->data.ptr || p->data.len < SSH_COMMAND_MESSAGE_LENGTH(0))
197 return SSAM_SSH_TC_NOT_APPLICABLE;
198
199 return get_unaligned_le16(&p->data.ptr[SSH_MSGOFFSET_COMMAND(tc)]);
200 }
201
202 #endif /* _SURFACE_AGGREGATOR_TRACE_HELPERS */
203
204 #define ssam_trace_get_command_field_u8(packet, field) \
205 ((!(packet) || (packet)->data.len < SSH_COMMAND_MESSAGE_LENGTH(0)) \
206 ? 0 : (packet)->data.ptr[SSH_MSGOFFSET_COMMAND(field)])
207
208 #define ssam_show_generic_u8_field(value) \
209 __print_symbolic(value, \
210 { SSAM_U8_FIELD_NOT_APPLICABLE, "N/A" } \
211 )
212
213 #define ssam_show_frame_type(ty) \
214 __print_symbolic(ty, \
215 { SSH_FRAME_TYPE_DATA_SEQ, "DSEQ" }, \
216 { SSH_FRAME_TYPE_DATA_NSQ, "DNSQ" }, \
217 { SSH_FRAME_TYPE_ACK, "ACK" }, \
218 { SSH_FRAME_TYPE_NAK, "NAK" } \
219 )
220
221 #define ssam_show_packet_type(type) \
222 __print_flags(flags & SSH_PACKET_FLAGS_TY_MASK, "", \
223 { BIT(SSH_PACKET_TY_FLUSH_BIT), "F" }, \
224 { BIT(SSH_PACKET_TY_SEQUENCED_BIT), "S" }, \
225 { BIT(SSH_PACKET_TY_BLOCKING_BIT), "B" } \
226 )
227
228 #define ssam_show_packet_state(state) \
229 __print_flags(flags & SSH_PACKET_FLAGS_SF_MASK, "", \
230 { BIT(SSH_PACKET_SF_LOCKED_BIT), "L" }, \
231 { BIT(SSH_PACKET_SF_QUEUED_BIT), "Q" }, \
232 { BIT(SSH_PACKET_SF_PENDING_BIT), "P" }, \
233 { BIT(SSH_PACKET_SF_TRANSMITTING_BIT), "S" }, \
234 { BIT(SSH_PACKET_SF_TRANSMITTED_BIT), "T" }, \
235 { BIT(SSH_PACKET_SF_ACKED_BIT), "A" }, \
236 { BIT(SSH_PACKET_SF_CANCELED_BIT), "C" }, \
237 { BIT(SSH_PACKET_SF_COMPLETED_BIT), "F" } \
238 )
239
240 #define ssam_show_packet_seq(seq) \
241 __print_symbolic(seq, \
242 { SSAM_SEQ_NOT_APPLICABLE, "N/A" } \
243 )
244
245 #define ssam_show_request_type(flags) \
246 __print_flags((flags) & SSH_REQUEST_FLAGS_TY_MASK, "", \
247 { BIT(SSH_REQUEST_TY_FLUSH_BIT), "F" }, \
248 { BIT(SSH_REQUEST_TY_HAS_RESPONSE_BIT), "R" } \
249 )
250
251 #define ssam_show_request_state(flags) \
252 __print_flags((flags) & SSH_REQUEST_FLAGS_SF_MASK, "", \
253 { BIT(SSH_REQUEST_SF_LOCKED_BIT), "L" }, \
254 { BIT(SSH_REQUEST_SF_QUEUED_BIT), "Q" }, \
255 { BIT(SSH_REQUEST_SF_PENDING_BIT), "P" }, \
256 { BIT(SSH_REQUEST_SF_TRANSMITTING_BIT), "S" }, \
257 { BIT(SSH_REQUEST_SF_TRANSMITTED_BIT), "T" }, \
258 { BIT(SSH_REQUEST_SF_RSPRCVD_BIT), "A" }, \
259 { BIT(SSH_REQUEST_SF_CANCELED_BIT), "C" }, \
260 { BIT(SSH_REQUEST_SF_COMPLETED_BIT), "F" } \
261 )
262
263 #define ssam_show_request_id(rqid) \
264 __print_symbolic(rqid, \
265 { SSAM_RQID_NOT_APPLICABLE, "N/A" } \
266 )
267
268 #define ssam_show_ssh_tid(tid) \
269 __print_symbolic(tid, \
270 { SSAM_SSH_TID_NOT_APPLICABLE, "N/A" }, \
271 { SSAM_SSH_TID_HOST, "Host" }, \
272 { SSAM_SSH_TID_SAM, "SAM" }, \
273 { SSAM_SSH_TID_KIP, "KIP" }, \
274 { SSAM_SSH_TID_DEBUG, "Debug" }, \
275 { SSAM_SSH_TID_SURFLINK, "SurfLink" } \
276 )
277
278 #define ssam_show_ssh_tc(tc) \
279 __print_symbolic(tc, \
280 { SSAM_SSH_TC_NOT_APPLICABLE, "N/A" }, \
281 { SSAM_SSH_TC_SAM, "SAM" }, \
282 { SSAM_SSH_TC_BAT, "BAT" }, \
283 { SSAM_SSH_TC_TMP, "TMP" }, \
284 { SSAM_SSH_TC_PMC, "PMC" }, \
285 { SSAM_SSH_TC_FAN, "FAN" }, \
286 { SSAM_SSH_TC_PoM, "PoM" }, \
287 { SSAM_SSH_TC_DBG, "DBG" }, \
288 { SSAM_SSH_TC_KBD, "KBD" }, \
289 { SSAM_SSH_TC_FWU, "FWU" }, \
290 { SSAM_SSH_TC_UNI, "UNI" }, \
291 { SSAM_SSH_TC_LPC, "LPC" }, \
292 { SSAM_SSH_TC_TCL, "TCL" }, \
293 { SSAM_SSH_TC_SFL, "SFL" }, \
294 { SSAM_SSH_TC_KIP, "KIP" }, \
295 { SSAM_SSH_TC_EXT, "EXT" }, \
296 { SSAM_SSH_TC_BLD, "BLD" }, \
297 { SSAM_SSH_TC_BAS, "BAS" }, \
298 { SSAM_SSH_TC_SEN, "SEN" }, \
299 { SSAM_SSH_TC_SRQ, "SRQ" }, \
300 { SSAM_SSH_TC_MCU, "MCU" }, \
301 { SSAM_SSH_TC_HID, "HID" }, \
302 { SSAM_SSH_TC_TCH, "TCH" }, \
303 { SSAM_SSH_TC_BKL, "BKL" }, \
304 { SSAM_SSH_TC_TAM, "TAM" }, \
305 { SSAM_SSH_TC_ACC0, "ACC0" }, \
306 { SSAM_SSH_TC_UFI, "UFI" }, \
307 { SSAM_SSH_TC_USC, "USC" }, \
308 { SSAM_SSH_TC_PEN, "PEN" }, \
309 { SSAM_SSH_TC_VID, "VID" }, \
310 { SSAM_SSH_TC_AUD, "AUD" }, \
311 { SSAM_SSH_TC_SMC, "SMC" }, \
312 { SSAM_SSH_TC_KPD, "KPD" }, \
313 { SSAM_SSH_TC_REG, "REG" }, \
314 { SSAM_SSH_TC_SPT, "SPT" }, \
315 { SSAM_SSH_TC_SYS, "SYS" }, \
316 { SSAM_SSH_TC_ACC1, "ACC1" }, \
317 { SSAM_SSH_TC_SHB, "SMB" }, \
318 { SSAM_SSH_TC_POS, "POS" } \
319 )
320
321 DECLARE_EVENT_CLASS(ssam_frame_class,
322 TP_PROTO(const struct ssh_frame *frame),
323
324 TP_ARGS(frame),
325
326 TP_STRUCT__entry(
327 __field(u8, type)
328 __field(u8, seq)
329 __field(u16, len)
330 ),
331
332 TP_fast_assign(
333 __entry->type = frame->type;
334 __entry->seq = frame->seq;
335 __entry->len = get_unaligned_le16(&frame->len);
336 ),
337
338 TP_printk("ty=%s, seq=%#04x, len=%u",
339 ssam_show_frame_type(__entry->type),
340 __entry->seq,
341 __entry->len
342 )
343 );
344
345 #define DEFINE_SSAM_FRAME_EVENT(name) \
346 DEFINE_EVENT(ssam_frame_class, ssam_##name, \
347 TP_PROTO(const struct ssh_frame *frame), \
348 TP_ARGS(frame) \
349 )
350
351 DECLARE_EVENT_CLASS(ssam_command_class,
352 TP_PROTO(const struct ssh_command *cmd, u16 len),
353
354 TP_ARGS(cmd, len),
355
356 TP_STRUCT__entry(
357 __field(u16, rqid)
358 __field(u16, len)
359 __field(u8, tid)
360 __field(u8, sid)
361 __field(u8, tc)
362 __field(u8, cid)
363 __field(u8, iid)
364 ),
365
366 TP_fast_assign(
367 __entry->rqid = get_unaligned_le16(&cmd->rqid);
368 __entry->tid = cmd->tid;
369 __entry->sid = cmd->sid;
370 __entry->tc = cmd->tc;
371 __entry->cid = cmd->cid;
372 __entry->iid = cmd->iid;
373 __entry->len = len;
374 ),
375
376 TP_printk("rqid=%#06x, tid=%s, sid=%s, tc=%s, cid=%#04x, iid=%#04x, len=%u",
377 __entry->rqid,
378 ssam_show_ssh_tid(__entry->tid),
379 ssam_show_ssh_tid(__entry->sid),
380 ssam_show_ssh_tc(__entry->tc),
381 __entry->cid,
382 __entry->iid,
383 __entry->len
384 )
385 );
386
387 #define DEFINE_SSAM_COMMAND_EVENT(name) \
388 DEFINE_EVENT(ssam_command_class, ssam_##name, \
389 TP_PROTO(const struct ssh_command *cmd, u16 len), \
390 TP_ARGS(cmd, len) \
391 )
392
393 DECLARE_EVENT_CLASS(ssam_packet_class,
394 TP_PROTO(const struct ssh_packet *packet),
395
396 TP_ARGS(packet),
397
398 TP_STRUCT__entry(
399 __field(unsigned long, state)
400 __array(char, uid, SSAM_PTR_UID_LEN)
401 __field(u8, priority)
402 __field(u16, length)
403 __field(u16, seq)
404 ),
405
406 TP_fast_assign(
407 __entry->state = READ_ONCE(packet->state);
408 ssam_trace_ptr_uid(packet, __entry->uid);
409 __entry->priority = READ_ONCE(packet->priority);
410 __entry->length = packet->data.len;
411 __entry->seq = ssam_trace_get_packet_seq(packet);
412 ),
413
414 TP_printk("uid=%s, seq=%s, ty=%s, pri=%#04x, len=%u, sta=%s",
415 __entry->uid,
416 ssam_show_packet_seq(__entry->seq),
417 ssam_show_packet_type(__entry->state),
418 __entry->priority,
419 __entry->length,
420 ssam_show_packet_state(__entry->state)
421 )
422 );
423
424 #define DEFINE_SSAM_PACKET_EVENT(name) \
425 DEFINE_EVENT(ssam_packet_class, ssam_##name, \
426 TP_PROTO(const struct ssh_packet *packet), \
427 TP_ARGS(packet) \
428 )
429
430 DECLARE_EVENT_CLASS(ssam_packet_status_class,
431 TP_PROTO(const struct ssh_packet *packet, int status),
432
433 TP_ARGS(packet, status),
434
435 TP_STRUCT__entry(
436 __field(unsigned long, state)
437 __field(int, status)
438 __array(char, uid, SSAM_PTR_UID_LEN)
439 __field(u8, priority)
440 __field(u16, length)
441 __field(u16, seq)
442 ),
443
444 TP_fast_assign(
445 __entry->state = READ_ONCE(packet->state);
446 __entry->status = status;
447 ssam_trace_ptr_uid(packet, __entry->uid);
448 __entry->priority = READ_ONCE(packet->priority);
449 __entry->length = packet->data.len;
450 __entry->seq = ssam_trace_get_packet_seq(packet);
451 ),
452
453 TP_printk("uid=%s, seq=%s, ty=%s, pri=%#04x, len=%u, sta=%s, status=%d",
454 __entry->uid,
455 ssam_show_packet_seq(__entry->seq),
456 ssam_show_packet_type(__entry->state),
457 __entry->priority,
458 __entry->length,
459 ssam_show_packet_state(__entry->state),
460 __entry->status
461 )
462 );
463
464 #define DEFINE_SSAM_PACKET_STATUS_EVENT(name) \
465 DEFINE_EVENT(ssam_packet_status_class, ssam_##name, \
466 TP_PROTO(const struct ssh_packet *packet, int status), \
467 TP_ARGS(packet, status) \
468 )
469
470 DECLARE_EVENT_CLASS(ssam_request_class,
471 TP_PROTO(const struct ssh_request *request),
472
473 TP_ARGS(request),
474
475 TP_STRUCT__entry(
476 __field(unsigned long, state)
477 __field(u32, rqid)
478 __array(char, uid, SSAM_PTR_UID_LEN)
479 __field(u8, tc)
480 __field(u16, cid)
481 __field(u16, iid)
482 __field(u8, tid)
483 __field(u8, sid)
484 ),
485
486 TP_fast_assign(
487 const struct ssh_packet *p = &request->packet;
488
489 /* Use packet for UID so we can match requests to packets. */
490 __entry->state = READ_ONCE(request->state);
491 __entry->rqid = ssam_trace_get_request_id(p);
492 ssam_trace_ptr_uid(p, __entry->uid);
493 __entry->tid = ssam_trace_get_request_tid(p);
494 __entry->sid = ssam_trace_get_request_sid(p);
495 __entry->tc = ssam_trace_get_request_tc(p);
496 __entry->cid = ssam_trace_get_command_field_u8(p, cid);
497 __entry->iid = ssam_trace_get_command_field_u8(p, iid);
498 ),
499
500 TP_printk("uid=%s, rqid=%s, ty=%s, sta=%s, tid=%s, sid=%s, tc=%s, cid=%s, iid=%s",
501 __entry->uid,
502 ssam_show_request_id(__entry->rqid),
503 ssam_show_request_type(__entry->state),
504 ssam_show_request_state(__entry->state),
505 ssam_show_ssh_tid(__entry->tid),
506 ssam_show_ssh_tid(__entry->sid),
507 ssam_show_ssh_tc(__entry->tc),
508 ssam_show_generic_u8_field(__entry->cid),
509 ssam_show_generic_u8_field(__entry->iid)
510 )
511 );
512
513 #define DEFINE_SSAM_REQUEST_EVENT(name) \
514 DEFINE_EVENT(ssam_request_class, ssam_##name, \
515 TP_PROTO(const struct ssh_request *request), \
516 TP_ARGS(request) \
517 )
518
519 DECLARE_EVENT_CLASS(ssam_request_status_class,
520 TP_PROTO(const struct ssh_request *request, int status),
521
522 TP_ARGS(request, status),
523
524 TP_STRUCT__entry(
525 __field(unsigned long, state)
526 __field(u32, rqid)
527 __field(int, status)
528 __array(char, uid, SSAM_PTR_UID_LEN)
529 __field(u8, tc)
530 __field(u16, cid)
531 __field(u16, iid)
532 __field(u8, tid)
533 __field(u8, sid)
534 ),
535
536 TP_fast_assign(
537 const struct ssh_packet *p = &request->packet;
538
539 /* Use packet for UID so we can match requests to packets. */
540 __entry->state = READ_ONCE(request->state);
541 __entry->rqid = ssam_trace_get_request_id(p);
542 __entry->status = status;
543 ssam_trace_ptr_uid(p, __entry->uid);
544 __entry->tid = ssam_trace_get_request_tid(p);
545 __entry->sid = ssam_trace_get_request_sid(p);
546 __entry->tc = ssam_trace_get_request_tc(p);
547 __entry->cid = ssam_trace_get_command_field_u8(p, cid);
548 __entry->iid = ssam_trace_get_command_field_u8(p, iid);
549 ),
550
551 TP_printk("uid=%s, rqid=%s, ty=%s, sta=%s, tid=%s, sid=%s, tc=%s, cid=%s, iid=%s, status=%d",
552 __entry->uid,
553 ssam_show_request_id(__entry->rqid),
554 ssam_show_request_type(__entry->state),
555 ssam_show_request_state(__entry->state),
556 ssam_show_ssh_tid(__entry->tid),
557 ssam_show_ssh_tid(__entry->sid),
558 ssam_show_ssh_tc(__entry->tc),
559 ssam_show_generic_u8_field(__entry->cid),
560 ssam_show_generic_u8_field(__entry->iid),
561 __entry->status
562 )
563 );
564
565 #define DEFINE_SSAM_REQUEST_STATUS_EVENT(name) \
566 DEFINE_EVENT(ssam_request_status_class, ssam_##name, \
567 TP_PROTO(const struct ssh_request *request, int status),\
568 TP_ARGS(request, status) \
569 )
570
571 DECLARE_EVENT_CLASS(ssam_alloc_class,
572 TP_PROTO(void *ptr, size_t len),
573
574 TP_ARGS(ptr, len),
575
576 TP_STRUCT__entry(
577 __field(size_t, len)
578 __array(char, uid, SSAM_PTR_UID_LEN)
579 ),
580
581 TP_fast_assign(
582 __entry->len = len;
583 ssam_trace_ptr_uid(ptr, __entry->uid);
584 ),
585
586 TP_printk("uid=%s, len=%zu", __entry->uid, __entry->len)
587 );
588
589 #define DEFINE_SSAM_ALLOC_EVENT(name) \
590 DEFINE_EVENT(ssam_alloc_class, ssam_##name, \
591 TP_PROTO(void *ptr, size_t len), \
592 TP_ARGS(ptr, len) \
593 )
594
595 DECLARE_EVENT_CLASS(ssam_free_class,
596 TP_PROTO(void *ptr),
597
598 TP_ARGS(ptr),
599
600 TP_STRUCT__entry(
601 __array(char, uid, SSAM_PTR_UID_LEN)
602 ),
603
604 TP_fast_assign(
605 ssam_trace_ptr_uid(ptr, __entry->uid);
606 ),
607
608 TP_printk("uid=%s", __entry->uid)
609 );
610
611 #define DEFINE_SSAM_FREE_EVENT(name) \
612 DEFINE_EVENT(ssam_free_class, ssam_##name, \
613 TP_PROTO(void *ptr), \
614 TP_ARGS(ptr) \
615 )
616
617 DECLARE_EVENT_CLASS(ssam_pending_class,
618 TP_PROTO(unsigned int pending),
619
620 TP_ARGS(pending),
621
622 TP_STRUCT__entry(
623 __field(unsigned int, pending)
624 ),
625
626 TP_fast_assign(
627 __entry->pending = pending;
628 ),
629
630 TP_printk("pending=%u", __entry->pending)
631 );
632
633 #define DEFINE_SSAM_PENDING_EVENT(name) \
634 DEFINE_EVENT(ssam_pending_class, ssam_##name, \
635 TP_PROTO(unsigned int pending), \
636 TP_ARGS(pending) \
637 )
638
639 DECLARE_EVENT_CLASS(ssam_data_class,
640 TP_PROTO(size_t length),
641
642 TP_ARGS(length),
643
644 TP_STRUCT__entry(
645 __field(size_t, length)
646 ),
647
648 TP_fast_assign(
649 __entry->length = length;
650 ),
651
652 TP_printk("length=%zu", __entry->length)
653 );
654
655 #define DEFINE_SSAM_DATA_EVENT(name) \
656 DEFINE_EVENT(ssam_data_class, ssam_##name, \
657 TP_PROTO(size_t length), \
658 TP_ARGS(length) \
659 )
660
661 DEFINE_SSAM_FRAME_EVENT(rx_frame_received);
662 DEFINE_SSAM_COMMAND_EVENT(rx_response_received);
663 DEFINE_SSAM_COMMAND_EVENT(rx_event_received);
664
665 DEFINE_SSAM_PACKET_EVENT(packet_release);
666 DEFINE_SSAM_PACKET_EVENT(packet_submit);
667 DEFINE_SSAM_PACKET_EVENT(packet_resubmit);
668 DEFINE_SSAM_PACKET_EVENT(packet_timeout);
669 DEFINE_SSAM_PACKET_EVENT(packet_cancel);
670 DEFINE_SSAM_PACKET_STATUS_EVENT(packet_complete);
671 DEFINE_SSAM_PENDING_EVENT(ptl_timeout_reap);
672
673 DEFINE_SSAM_REQUEST_EVENT(request_submit);
674 DEFINE_SSAM_REQUEST_EVENT(request_timeout);
675 DEFINE_SSAM_REQUEST_EVENT(request_cancel);
676 DEFINE_SSAM_REQUEST_STATUS_EVENT(request_complete);
677 DEFINE_SSAM_PENDING_EVENT(rtl_timeout_reap);
678
679 DEFINE_SSAM_PACKET_EVENT(ei_tx_drop_ack_packet);
680 DEFINE_SSAM_PACKET_EVENT(ei_tx_drop_nak_packet);
681 DEFINE_SSAM_PACKET_EVENT(ei_tx_drop_dsq_packet);
682 DEFINE_SSAM_PACKET_STATUS_EVENT(ei_tx_fail_write);
683 DEFINE_SSAM_PACKET_EVENT(ei_tx_corrupt_data);
684 DEFINE_SSAM_DATA_EVENT(ei_rx_corrupt_syn);
685 DEFINE_SSAM_FRAME_EVENT(ei_rx_corrupt_data);
686 DEFINE_SSAM_REQUEST_EVENT(ei_rx_drop_response);
687
688 DEFINE_SSAM_ALLOC_EVENT(ctrl_packet_alloc);
689 DEFINE_SSAM_FREE_EVENT(ctrl_packet_free);
690
691 DEFINE_SSAM_ALLOC_EVENT(event_item_alloc);
692 DEFINE_SSAM_FREE_EVENT(event_item_free);
693
694 #endif /* _SURFACE_AGGREGATOR_TRACE_H */
695
696 /* This part must be outside protection */
697 #undef TRACE_INCLUDE_PATH
698 #undef TRACE_INCLUDE_FILE
699
700 #define TRACE_INCLUDE_PATH .
701 #define TRACE_INCLUDE_FILE trace
702
703 #include <trace/define_trace.h>
704