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