Skip to content

Commit cca315f

Browse files
qzedjwrdegoede
authored andcommitted
platform/surface: aggregator: Add target and source IDs to command trace events
Add command source and target IDs to trace events. Tracing support for the Surface Aggregator driver was originally implemented at a time when only two peers were known: Host and SAM. We now know that there are at least five, with three actively being used (Host, SAM, KIP; four with Debug if you want to count manually enabling that interface). So it makes sense to also explicitly name the peers involved when tracing. Signed-off-by: Maximilian Luz <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]>
1 parent 1bbca5c commit cca315f

File tree

1 file changed

+67
-6
lines changed
  • drivers/platform/surface/aggregator

1 file changed

+67
-6
lines changed

drivers/platform/surface/aggregator/trace.h

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ TRACE_DEFINE_ENUM(SSAM_SSH_TC_POS);
9696
#define SSAM_SEQ_NOT_APPLICABLE ((u16)-1)
9797
#define SSAM_RQID_NOT_APPLICABLE ((u32)-1)
9898
#define SSAM_SSH_TC_NOT_APPLICABLE 0
99+
#define SSAM_SSH_TID_NOT_APPLICABLE ((u8)-1)
99100

100101
#ifndef _SURFACE_AGGREGATOR_TRACE_HELPERS
101102
#define _SURFACE_AGGREGATOR_TRACE_HELPERS
@@ -150,12 +151,44 @@ static inline u32 ssam_trace_get_request_id(const struct ssh_packet *p)
150151
return get_unaligned_le16(&p->data.ptr[SSH_MSGOFFSET_COMMAND(rqid)]);
151152
}
152153

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+
*/
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+
*/
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+
153186
/**
154187
* ssam_trace_get_request_tc() - Read the packet's request target category.
155188
* @p: The packet.
156189
*
157190
* Return: Returns the packet's request target category (TC) field if the
158-
* packet represents a request with command data, or %SSAM_TC_NOT_APPLICABLE
191+
* packet represents a request with command data, or %SSAM_SSH_TC_NOT_APPLICABLE
159192
* if not (e.g. flush request, control packet).
160193
*/
161194
static inline u32 ssam_trace_get_request_tc(const struct ssh_packet *p)
@@ -232,8 +265,18 @@ static inline u32 ssam_trace_get_request_tc(const struct ssh_packet *p)
232265
{ SSAM_RQID_NOT_APPLICABLE, "N/A" } \
233266
)
234267

235-
#define ssam_show_ssh_tc(rqid) \
236-
__print_symbolic(rqid, \
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, \
237280
{ SSAM_SSH_TC_NOT_APPLICABLE, "N/A" }, \
238281
{ SSAM_SSH_TC_SAM, "SAM" }, \
239282
{ SSAM_SSH_TC_BAT, "BAT" }, \
@@ -313,21 +356,27 @@ DECLARE_EVENT_CLASS(ssam_command_class,
313356
TP_STRUCT__entry(
314357
__field(u16, rqid)
315358
__field(u16, len)
359+
__field(u8, tid)
360+
__field(u8, sid)
316361
__field(u8, tc)
317362
__field(u8, cid)
318363
__field(u8, iid)
319364
),
320365

321366
TP_fast_assign(
322367
__entry->rqid = get_unaligned_le16(&cmd->rqid);
368+
__entry->tid = cmd->tid;
369+
__entry->sid = cmd->sid;
323370
__entry->tc = cmd->tc;
324371
__entry->cid = cmd->cid;
325372
__entry->iid = cmd->iid;
326373
__entry->len = len;
327374
),
328375

329-
TP_printk("rqid=%#06x, tc=%s, cid=%#04x, iid=%#04x, len=%u",
376+
TP_printk("rqid=%#06x, tid=%s, sid=%s, tc=%s, cid=%#04x, iid=%#04x, len=%u",
330377
__entry->rqid,
378+
ssam_show_ssh_tid(__entry->tid),
379+
ssam_show_ssh_tid(__entry->sid),
331380
ssam_show_ssh_tc(__entry->tc),
332381
__entry->cid,
333382
__entry->iid,
@@ -430,6 +479,8 @@ DECLARE_EVENT_CLASS(ssam_request_class,
430479
__field(u8, tc)
431480
__field(u16, cid)
432481
__field(u16, iid)
482+
__field(u8, tid)
483+
__field(u8, sid)
433484
),
434485

435486
TP_fast_assign(
@@ -439,16 +490,20 @@ DECLARE_EVENT_CLASS(ssam_request_class,
439490
__entry->state = READ_ONCE(request->state);
440491
__entry->rqid = ssam_trace_get_request_id(p);
441492
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);
442495
__entry->tc = ssam_trace_get_request_tc(p);
443496
__entry->cid = ssam_trace_get_command_field_u8(p, cid);
444497
__entry->iid = ssam_trace_get_command_field_u8(p, iid);
445498
),
446499

447-
TP_printk("uid=%s, rqid=%s, ty=%s, sta=%s, tc=%s, cid=%s, iid=%s",
500+
TP_printk("uid=%s, rqid=%s, ty=%s, sta=%s, tid=%s, sid=%s, tc=%s, cid=%s, iid=%s",
448501
__entry->uid,
449502
ssam_show_request_id(__entry->rqid),
450503
ssam_show_request_type(__entry->state),
451504
ssam_show_request_state(__entry->state),
505+
ssam_show_ssh_tid(__entry->tid),
506+
ssam_show_ssh_tid(__entry->sid),
452507
ssam_show_ssh_tc(__entry->tc),
453508
ssam_show_generic_u8_field(__entry->cid),
454509
ssam_show_generic_u8_field(__entry->iid)
@@ -474,6 +529,8 @@ DECLARE_EVENT_CLASS(ssam_request_status_class,
474529
__field(u8, tc)
475530
__field(u16, cid)
476531
__field(u16, iid)
532+
__field(u8, tid)
533+
__field(u8, sid)
477534
),
478535

479536
TP_fast_assign(
@@ -484,16 +541,20 @@ DECLARE_EVENT_CLASS(ssam_request_status_class,
484541
__entry->rqid = ssam_trace_get_request_id(p);
485542
__entry->status = status;
486543
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);
487546
__entry->tc = ssam_trace_get_request_tc(p);
488547
__entry->cid = ssam_trace_get_command_field_u8(p, cid);
489548
__entry->iid = ssam_trace_get_command_field_u8(p, iid);
490549
),
491550

492-
TP_printk("uid=%s, rqid=%s, ty=%s, sta=%s, tc=%s, cid=%s, iid=%s, status=%d",
551+
TP_printk("uid=%s, rqid=%s, ty=%s, sta=%s, tid=%s, sid=%s, tc=%s, cid=%s, iid=%s, status=%d",
493552
__entry->uid,
494553
ssam_show_request_id(__entry->rqid),
495554
ssam_show_request_type(__entry->state),
496555
ssam_show_request_state(__entry->state),
556+
ssam_show_ssh_tid(__entry->tid),
557+
ssam_show_ssh_tid(__entry->sid),
497558
ssam_show_ssh_tc(__entry->tc),
498559
ssam_show_generic_u8_field(__entry->cid),
499560
ssam_show_generic_u8_field(__entry->iid),

0 commit comments

Comments
 (0)