1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Trace points for SSAM/SSH.
5 * Copyright (C) 2020-2022 Maximilian Luz <luzmaximilian@gmail.com>
9 #define TRACE_SYSTEM surface_aggregator
11 #if !defined(_SURFACE_AGGREGATOR_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
12 #define _SURFACE_AGGREGATOR_TRACE_H
14 #include <linux/surface_aggregator/serial_hub.h>
16 #include <linux/unaligned.h>
17 #include <linux/tracepoint.h>
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
);
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
);
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
);
37 TRACE_DEFINE_ENUM(SSH_PACKET_FLAGS_SF_MASK
);
38 TRACE_DEFINE_ENUM(SSH_PACKET_FLAGS_TY_MASK
);
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
);
49 TRACE_DEFINE_ENUM(SSH_REQUEST_TY_FLUSH_BIT
);
50 TRACE_DEFINE_ENUM(SSH_REQUEST_TY_HAS_RESPONSE_BIT
);
52 TRACE_DEFINE_ENUM(SSH_REQUEST_FLAGS_SF_MASK
);
53 TRACE_DEFINE_ENUM(SSH_REQUEST_FLAGS_TY_MASK
);
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
);
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)
101 #ifndef _SURFACE_AGGREGATOR_TRACE_HELPERS
102 #define _SURFACE_AGGREGATOR_TRACE_HELPERS
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.
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.
112 static inline void ssam_trace_ptr_uid(const void *ptr
, char *uid_str
)
114 char buf
[2 * sizeof(void *) + 1];
116 BUILD_BUG_ON(ARRAY_SIZE(buf
) < SSAM_PTR_UID_LEN
);
118 snprintf(buf
, ARRAY_SIZE(buf
), "%p", ptr
);
119 memcpy(uid_str
, &buf
[ARRAY_SIZE(buf
) - SSAM_PTR_UID_LEN
],
124 * ssam_trace_get_packet_seq() - Read the packet's sequence ID.
127 * Return: Returns the packet's sequence ID (SEQ) field if present, or
128 * %SSAM_SEQ_NOT_APPLICABLE if not (e.g. flush packet).
130 static inline u16
ssam_trace_get_packet_seq(const struct ssh_packet
*p
)
132 if (!p
->data
.ptr
|| p
->data
.len
< SSH_MESSAGE_LENGTH(0))
133 return SSAM_SEQ_NOT_APPLICABLE
;
135 return p
->data
.ptr
[SSH_MSGOFFSET_FRAME(seq
)];
139 * ssam_trace_get_request_id() - Read the packet's request ID.
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).
146 static inline u32
ssam_trace_get_request_id(const struct ssh_packet
*p
)
148 if (!p
->data
.ptr
|| p
->data
.len
< SSH_COMMAND_MESSAGE_LENGTH(0))
149 return SSAM_RQID_NOT_APPLICABLE
;
151 return get_unaligned_le16(&p
->data
.ptr
[SSH_MSGOFFSET_COMMAND(rqid
)]);
155 * ssam_trace_get_request_tid() - Read the packet's request target ID.
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).
162 static inline u32
ssam_trace_get_request_tid(const struct ssh_packet
*p
)
164 if (!p
->data
.ptr
|| p
->data
.len
< SSH_COMMAND_MESSAGE_LENGTH(0))
165 return SSAM_SSH_TID_NOT_APPLICABLE
;
167 return get_unaligned_le16(&p
->data
.ptr
[SSH_MSGOFFSET_COMMAND(tid
)]);
171 * ssam_trace_get_request_sid() - Read the packet's request source ID.
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).
178 static inline u32
ssam_trace_get_request_sid(const struct ssh_packet
*p
)
180 if (!p
->data
.ptr
|| p
->data
.len
< SSH_COMMAND_MESSAGE_LENGTH(0))
181 return SSAM_SSH_TID_NOT_APPLICABLE
;
183 return get_unaligned_le16(&p
->data
.ptr
[SSH_MSGOFFSET_COMMAND(sid
)]);
187 * ssam_trace_get_request_tc() - Read the packet's request target category.
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).
194 static inline u32
ssam_trace_get_request_tc(const struct ssh_packet
*p
)
196 if (!p
->data
.ptr
|| p
->data
.len
< SSH_COMMAND_MESSAGE_LENGTH(0))
197 return SSAM_SSH_TC_NOT_APPLICABLE
;
199 return get_unaligned_le16(&p
->data
.ptr
[SSH_MSGOFFSET_COMMAND(tc
)]);
202 #endif /* _SURFACE_AGGREGATOR_TRACE_HELPERS */
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)])
208 #define ssam_show_generic_u8_field(value) \
209 __print_symbolic(value, \
210 { SSAM_U8_FIELD_NOT_APPLICABLE, "N/A" } \
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" } \
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" } \
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" } \
240 #define ssam_show_packet_seq(seq) \
241 __print_symbolic(seq, \
242 { SSAM_SEQ_NOT_APPLICABLE, "N/A" } \
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" } \
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" } \
263 #define ssam_show_request_id(rqid) \
264 __print_symbolic(rqid, \
265 { SSAM_RQID_NOT_APPLICABLE, "N/A" } \
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" } \
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" } \
321 DECLARE_EVENT_CLASS(ssam_frame_class
,
322 TP_PROTO(const struct ssh_frame
*frame
),
333 __entry
->type
= frame
->type
;
334 __entry
->seq
= frame
->seq
;
335 __entry
->len
= get_unaligned_le16(&frame
->len
);
338 TP_printk("ty=%s, seq=%#04x, len=%u",
339 ssam_show_frame_type(__entry
->type
),
345 #define DEFINE_SSAM_FRAME_EVENT(name) \
346 DEFINE_EVENT(ssam_frame_class, ssam_##name, \
347 TP_PROTO(const struct ssh_frame *frame), \
351 DECLARE_EVENT_CLASS(ssam_command_class
,
352 TP_PROTO(const struct ssh_command
*cmd
, u16 len
),
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
;
376 TP_printk("rqid=%#06x, tid=%s, sid=%s, tc=%s, cid=%#04x, iid=%#04x, len=%u",
378 ssam_show_ssh_tid(__entry
->tid
),
379 ssam_show_ssh_tid(__entry
->sid
),
380 ssam_show_ssh_tc(__entry
->tc
),
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), \
393 DECLARE_EVENT_CLASS(ssam_packet_class
,
394 TP_PROTO(const struct ssh_packet
*packet
),
399 __field(unsigned long, state
)
400 __array(char, uid
, SSAM_PTR_UID_LEN
)
401 __field(u8
, priority
)
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
);
414 TP_printk("uid=%s, seq=%s, ty=%s, pri=%#04x, len=%u, sta=%s",
416 ssam_show_packet_seq(__entry
->seq
),
417 ssam_show_packet_type(__entry
->state
),
420 ssam_show_packet_state(__entry
->state
)
424 #define DEFINE_SSAM_PACKET_EVENT(name) \
425 DEFINE_EVENT(ssam_packet_class, ssam_##name, \
426 TP_PROTO(const struct ssh_packet *packet), \
430 DECLARE_EVENT_CLASS(ssam_packet_status_class
,
431 TP_PROTO(const struct ssh_packet
*packet
, int status
),
433 TP_ARGS(packet
, status
),
436 __field(unsigned long, state
)
438 __array(char, uid
, SSAM_PTR_UID_LEN
)
439 __field(u8
, priority
)
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
);
453 TP_printk("uid=%s, seq=%s, ty=%s, pri=%#04x, len=%u, sta=%s, status=%d",
455 ssam_show_packet_seq(__entry
->seq
),
456 ssam_show_packet_type(__entry
->state
),
459 ssam_show_packet_state(__entry
->state
),
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) \
470 DECLARE_EVENT_CLASS(ssam_request_class
,
471 TP_PROTO(const struct ssh_request
*request
),
476 __field(unsigned long, state
)
478 __array(char, uid
, SSAM_PTR_UID_LEN
)
487 const struct ssh_packet
*p
= &request
->packet
;
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
);
500 TP_printk("uid=%s, rqid=%s, ty=%s, sta=%s, tid=%s, sid=%s, tc=%s, cid=%s, iid=%s",
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
)
513 #define DEFINE_SSAM_REQUEST_EVENT(name) \
514 DEFINE_EVENT(ssam_request_class, ssam_##name, \
515 TP_PROTO(const struct ssh_request *request), \
519 DECLARE_EVENT_CLASS(ssam_request_status_class
,
520 TP_PROTO(const struct ssh_request
*request
, int status
),
522 TP_ARGS(request
, status
),
525 __field(unsigned long, state
)
528 __array(char, uid
, SSAM_PTR_UID_LEN
)
537 const struct ssh_packet
*p
= &request
->packet
;
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
);
551 TP_printk("uid=%s, rqid=%s, ty=%s, sta=%s, tid=%s, sid=%s, tc=%s, cid=%s, iid=%s, status=%d",
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
),
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) \
571 DECLARE_EVENT_CLASS(ssam_alloc_class
,
572 TP_PROTO(void *ptr
, size_t len
),
578 __array(char, uid
, SSAM_PTR_UID_LEN
)
583 ssam_trace_ptr_uid(ptr
, __entry
->uid
);
586 TP_printk("uid=%s, len=%zu", __entry
->uid
, __entry
->len
)
589 #define DEFINE_SSAM_ALLOC_EVENT(name) \
590 DEFINE_EVENT(ssam_alloc_class, ssam_##name, \
591 TP_PROTO(void *ptr, size_t len), \
595 DECLARE_EVENT_CLASS(ssam_free_class
,
601 __array(char, uid
, SSAM_PTR_UID_LEN
)
605 ssam_trace_ptr_uid(ptr
, __entry
->uid
);
608 TP_printk("uid=%s", __entry
->uid
)
611 #define DEFINE_SSAM_FREE_EVENT(name) \
612 DEFINE_EVENT(ssam_free_class, ssam_##name, \
613 TP_PROTO(void *ptr), \
617 DECLARE_EVENT_CLASS(ssam_pending_class
,
618 TP_PROTO(unsigned int pending
),
623 __field(unsigned int, pending
)
627 __entry
->pending
= pending
;
630 TP_printk("pending=%u", __entry
->pending
)
633 #define DEFINE_SSAM_PENDING_EVENT(name) \
634 DEFINE_EVENT(ssam_pending_class, ssam_##name, \
635 TP_PROTO(unsigned int pending), \
639 DECLARE_EVENT_CLASS(ssam_data_class
,
640 TP_PROTO(size_t length
),
645 __field(size_t, length
)
649 __entry
->length
= length
;
652 TP_printk("length=%zu", __entry
->length
)
655 #define DEFINE_SSAM_DATA_EVENT(name) \
656 DEFINE_EVENT(ssam_data_class, ssam_##name, \
657 TP_PROTO(size_t length), \
661 DEFINE_SSAM_FRAME_EVENT(rx_frame_received
);
662 DEFINE_SSAM_COMMAND_EVENT(rx_response_received
);
663 DEFINE_SSAM_COMMAND_EVENT(rx_event_received
);
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
);
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
);
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
);
688 DEFINE_SSAM_ALLOC_EVENT(ctrl_packet_alloc
);
689 DEFINE_SSAM_FREE_EVENT(ctrl_packet_free
);
691 DEFINE_SSAM_ALLOC_EVENT(event_item_alloc
);
692 DEFINE_SSAM_FREE_EVENT(event_item_free
);
694 #endif /* _SURFACE_AGGREGATOR_TRACE_H */
696 /* This part must be outside protection */
697 #undef TRACE_INCLUDE_PATH
698 #undef TRACE_INCLUDE_FILE
700 #define TRACE_INCLUDE_PATH .
701 #define TRACE_INCLUDE_FILE trace
703 #include <trace/define_trace.h>