trace.h (3403B)
1/* SPDX-License-Identifier: GPL-2.0 */ 2 3#undef TRACE_SYSTEM 4#define TRACE_SYSTEM ucsi 5 6#if !defined(__UCSI_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) 7#define __UCSI_TRACE_H 8 9#include <linux/tracepoint.h> 10#include <linux/usb/typec_altmode.h> 11 12const char *ucsi_cmd_str(u64 raw_cmd); 13const char *ucsi_cci_str(u32 cci); 14const char *ucsi_recipient_str(u8 recipient); 15 16DECLARE_EVENT_CLASS(ucsi_log_command, 17 TP_PROTO(u64 command, int ret), 18 TP_ARGS(command, ret), 19 TP_STRUCT__entry( 20 __field(u64, ctrl) 21 __field(int, ret) 22 ), 23 TP_fast_assign( 24 __entry->ctrl = command; 25 __entry->ret = ret; 26 ), 27 TP_printk("%s -> %s (err=%d)", ucsi_cmd_str(__entry->ctrl), 28 __entry->ret < 0 ? "FAIL" : "OK", 29 __entry->ret < 0 ? __entry->ret : 0) 30); 31 32DEFINE_EVENT(ucsi_log_command, ucsi_run_command, 33 TP_PROTO(u64 command, int ret), 34 TP_ARGS(command, ret) 35); 36 37DEFINE_EVENT(ucsi_log_command, ucsi_reset_ppm, 38 TP_PROTO(u64 command, int ret), 39 TP_ARGS(command, ret) 40); 41 42DECLARE_EVENT_CLASS(ucsi_log_connector_status, 43 TP_PROTO(int port, struct ucsi_connector_status *status), 44 TP_ARGS(port, status), 45 TP_STRUCT__entry( 46 __field(int, port) 47 __field(u16, change) 48 __field(u8, opmode) 49 __field(u8, connected) 50 __field(u8, pwr_dir) 51 __field(u8, partner_flags) 52 __field(u8, partner_type) 53 __field(u32, request_data_obj) 54 __field(u8, bc_status) 55 ), 56 TP_fast_assign( 57 __entry->port = port - 1; 58 __entry->change = status->change; 59 __entry->opmode = UCSI_CONSTAT_PWR_OPMODE(status->flags); 60 __entry->connected = !!(status->flags & UCSI_CONSTAT_CONNECTED); 61 __entry->pwr_dir = !!(status->flags & UCSI_CONSTAT_PWR_DIR); 62 __entry->partner_flags = UCSI_CONSTAT_PARTNER_FLAGS(status->flags); 63 __entry->partner_type = UCSI_CONSTAT_PARTNER_TYPE(status->flags); 64 __entry->request_data_obj = status->request_data_obj; 65 __entry->bc_status = UCSI_CONSTAT_BC_STATUS(status->pwr_status); 66 ), 67 TP_printk("port%d status: change=%04x, opmode=%x, connected=%d, " 68 "sourcing=%d, partner_flags=%x, partner_type=%x, " 69 "request_data_obj=%08x, BC status=%x", __entry->port, 70 __entry->change, __entry->opmode, __entry->connected, 71 __entry->pwr_dir, __entry->partner_flags, __entry->partner_type, 72 __entry->request_data_obj, __entry->bc_status) 73); 74 75DEFINE_EVENT(ucsi_log_connector_status, ucsi_connector_change, 76 TP_PROTO(int port, struct ucsi_connector_status *status), 77 TP_ARGS(port, status) 78); 79 80DEFINE_EVENT(ucsi_log_connector_status, ucsi_register_port, 81 TP_PROTO(int port, struct ucsi_connector_status *status), 82 TP_ARGS(port, status) 83); 84 85DECLARE_EVENT_CLASS(ucsi_log_register_altmode, 86 TP_PROTO(u8 recipient, struct typec_altmode *alt), 87 TP_ARGS(recipient, alt), 88 TP_STRUCT__entry( 89 __field(u8, recipient) 90 __field(u16, svid) 91 __field(u8, mode) 92 __field(u32, vdo) 93 ), 94 TP_fast_assign( 95 __entry->recipient = recipient; 96 __entry->svid = alt->svid; 97 __entry->mode = alt->mode; 98 __entry->vdo = alt->vdo; 99 ), 100 TP_printk("%s alt mode: svid %04x, mode %d vdo %x", 101 ucsi_recipient_str(__entry->recipient), __entry->svid, 102 __entry->mode, __entry->vdo) 103); 104 105DEFINE_EVENT(ucsi_log_register_altmode, ucsi_register_altmode, 106 TP_PROTO(u8 recipient, struct typec_altmode *alt), 107 TP_ARGS(recipient, alt) 108); 109 110#endif /* __UCSI_TRACE_H */ 111 112/* This part must be outside protection */ 113 114#undef TRACE_INCLUDE_PATH 115#define TRACE_INCLUDE_PATH . 116 117#undef TRACE_INCLUDE_FILE 118#define TRACE_INCLUDE_FILE trace 119 120#include <trace/define_trace.h>