linux/include/trace/events/ufs.h
<<
>>
Prefs
   1/*
   2 * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
   3 *
   4 * This program is free software; you can redistribute it and/or modify
   5 * it under the terms of the GNU General Public License version 2 and
   6 * only version 2 as published by the Free Software Foundation.
   7 *
   8 * This program is distributed in the hope that it will be useful,
   9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11 * GNU General Public License for more details.
  12 */
  13
  14#undef TRACE_SYSTEM
  15#define TRACE_SYSTEM ufs
  16
  17#if !defined(_TRACE_UFS_H) || defined(TRACE_HEADER_MULTI_READ)
  18#define _TRACE_UFS_H
  19
  20#include <linux/tracepoint.h>
  21
  22#define UFS_LINK_STATES                 \
  23        EM(UIC_LINK_OFF_STATE)          \
  24        EM(UIC_LINK_ACTIVE_STATE)       \
  25        EMe(UIC_LINK_HIBERN8_STATE)
  26
  27#define UFS_PWR_MODES                   \
  28        EM(UFS_ACTIVE_PWR_MODE)         \
  29        EM(UFS_SLEEP_PWR_MODE)          \
  30        EMe(UFS_POWERDOWN_PWR_MODE)
  31
  32#define UFSCHD_CLK_GATING_STATES        \
  33        EM(CLKS_OFF)                    \
  34        EM(CLKS_ON)                     \
  35        EM(REQ_CLKS_OFF)                \
  36        EMe(REQ_CLKS_ON)
  37
  38/* Enums require being exported to userspace, for user tool parsing */
  39#undef EM
  40#undef EMe
  41#define EM(a)   TRACE_DEFINE_ENUM(a);
  42#define EMe(a)  TRACE_DEFINE_ENUM(a);
  43
  44UFS_LINK_STATES;
  45UFS_PWR_MODES;
  46UFSCHD_CLK_GATING_STATES;
  47
  48/*
  49 * Now redefine the EM() and EMe() macros to map the enums to the strings
  50 * that will be printed in the output.
  51 */
  52#undef EM
  53#undef EMe
  54#define EM(a)   { a, #a },
  55#define EMe(a)  { a, #a }
  56
  57TRACE_EVENT(ufshcd_clk_gating,
  58
  59        TP_PROTO(const char *dev_name, int state),
  60
  61        TP_ARGS(dev_name, state),
  62
  63        TP_STRUCT__entry(
  64                __string(dev_name, dev_name)
  65                __field(int, state)
  66        ),
  67
  68        TP_fast_assign(
  69                __assign_str(dev_name, dev_name);
  70                __entry->state = state;
  71        ),
  72
  73        TP_printk("%s: gating state changed to %s",
  74                __get_str(dev_name),
  75                __print_symbolic(__entry->state, UFSCHD_CLK_GATING_STATES))
  76);
  77
  78TRACE_EVENT(ufshcd_clk_scaling,
  79
  80        TP_PROTO(const char *dev_name, const char *state, const char *clk,
  81                u32 prev_state, u32 curr_state),
  82
  83        TP_ARGS(dev_name, state, clk, prev_state, curr_state),
  84
  85        TP_STRUCT__entry(
  86                __string(dev_name, dev_name)
  87                __string(state, state)
  88                __string(clk, clk)
  89                __field(u32, prev_state)
  90                __field(u32, curr_state)
  91        ),
  92
  93        TP_fast_assign(
  94                __assign_str(dev_name, dev_name);
  95                __assign_str(state, state);
  96                __assign_str(clk, clk);
  97                __entry->prev_state = prev_state;
  98                __entry->curr_state = curr_state;
  99        ),
 100
 101        TP_printk("%s: %s %s from %u to %u Hz",
 102                __get_str(dev_name), __get_str(state), __get_str(clk),
 103                __entry->prev_state, __entry->curr_state)
 104);
 105
 106TRACE_EVENT(ufshcd_auto_bkops_state,
 107
 108        TP_PROTO(const char *dev_name, const char *state),
 109
 110        TP_ARGS(dev_name, state),
 111
 112        TP_STRUCT__entry(
 113                __string(dev_name, dev_name)
 114                __string(state, state)
 115        ),
 116
 117        TP_fast_assign(
 118                __assign_str(dev_name, dev_name);
 119                __assign_str(state, state);
 120        ),
 121
 122        TP_printk("%s: auto bkops - %s",
 123                __get_str(dev_name), __get_str(state))
 124);
 125
 126DECLARE_EVENT_CLASS(ufshcd_profiling_template,
 127        TP_PROTO(const char *dev_name, const char *profile_info, s64 time_us,
 128                 int err),
 129
 130        TP_ARGS(dev_name, profile_info, time_us, err),
 131
 132        TP_STRUCT__entry(
 133                __string(dev_name, dev_name)
 134                __string(profile_info, profile_info)
 135                __field(s64, time_us)
 136                __field(int, err)
 137        ),
 138
 139        TP_fast_assign(
 140                __assign_str(dev_name, dev_name);
 141                __assign_str(profile_info, profile_info);
 142                __entry->time_us = time_us;
 143                __entry->err = err;
 144        ),
 145
 146        TP_printk("%s: %s: took %lld usecs, err %d",
 147                __get_str(dev_name), __get_str(profile_info),
 148                __entry->time_us, __entry->err)
 149);
 150
 151DEFINE_EVENT(ufshcd_profiling_template, ufshcd_profile_hibern8,
 152        TP_PROTO(const char *dev_name, const char *profile_info, s64 time_us,
 153                 int err),
 154        TP_ARGS(dev_name, profile_info, time_us, err));
 155
 156DEFINE_EVENT(ufshcd_profiling_template, ufshcd_profile_clk_gating,
 157        TP_PROTO(const char *dev_name, const char *profile_info, s64 time_us,
 158                 int err),
 159        TP_ARGS(dev_name, profile_info, time_us, err));
 160
 161DEFINE_EVENT(ufshcd_profiling_template, ufshcd_profile_clk_scaling,
 162        TP_PROTO(const char *dev_name, const char *profile_info, s64 time_us,
 163                 int err),
 164        TP_ARGS(dev_name, profile_info, time_us, err));
 165
 166DECLARE_EVENT_CLASS(ufshcd_template,
 167        TP_PROTO(const char *dev_name, int err, s64 usecs,
 168                 int dev_state, int link_state),
 169
 170        TP_ARGS(dev_name, err, usecs, dev_state, link_state),
 171
 172        TP_STRUCT__entry(
 173                __field(s64, usecs)
 174                __field(int, err)
 175                __string(dev_name, dev_name)
 176                __field(int, dev_state)
 177                __field(int, link_state)
 178        ),
 179
 180        TP_fast_assign(
 181                __entry->usecs = usecs;
 182                __entry->err = err;
 183                __assign_str(dev_name, dev_name);
 184                __entry->dev_state = dev_state;
 185                __entry->link_state = link_state;
 186        ),
 187
 188        TP_printk(
 189                "%s: took %lld usecs, dev_state: %s, link_state: %s, err %d",
 190                __get_str(dev_name),
 191                __entry->usecs,
 192                __print_symbolic(__entry->dev_state, UFS_PWR_MODES),
 193                __print_symbolic(__entry->link_state, UFS_LINK_STATES),
 194                __entry->err
 195        )
 196);
 197
 198DEFINE_EVENT(ufshcd_template, ufshcd_system_suspend,
 199             TP_PROTO(const char *dev_name, int err, s64 usecs,
 200                      int dev_state, int link_state),
 201             TP_ARGS(dev_name, err, usecs, dev_state, link_state));
 202
 203DEFINE_EVENT(ufshcd_template, ufshcd_system_resume,
 204             TP_PROTO(const char *dev_name, int err, s64 usecs,
 205                      int dev_state, int link_state),
 206             TP_ARGS(dev_name, err, usecs, dev_state, link_state));
 207
 208DEFINE_EVENT(ufshcd_template, ufshcd_runtime_suspend,
 209             TP_PROTO(const char *dev_name, int err, s64 usecs,
 210                      int dev_state, int link_state),
 211             TP_ARGS(dev_name, err, usecs, dev_state, link_state));
 212
 213DEFINE_EVENT(ufshcd_template, ufshcd_runtime_resume,
 214             TP_PROTO(const char *dev_name, int err, s64 usecs,
 215                      int dev_state, int link_state),
 216             TP_ARGS(dev_name, err, usecs, dev_state, link_state));
 217
 218DEFINE_EVENT(ufshcd_template, ufshcd_init,
 219             TP_PROTO(const char *dev_name, int err, s64 usecs,
 220                      int dev_state, int link_state),
 221             TP_ARGS(dev_name, err, usecs, dev_state, link_state));
 222
 223TRACE_EVENT(ufshcd_command,
 224        TP_PROTO(const char *dev_name, const char *str, unsigned int tag,
 225                        u32 doorbell, int transfer_len, u32 intr, u64 lba,
 226                        u8 opcode),
 227
 228        TP_ARGS(dev_name, str, tag, doorbell, transfer_len, intr, lba, opcode),
 229
 230        TP_STRUCT__entry(
 231                __string(dev_name, dev_name)
 232                __string(str, str)
 233                __field(unsigned int, tag)
 234                __field(u32, doorbell)
 235                __field(int, transfer_len)
 236                __field(u32, intr)
 237                __field(u64, lba)
 238                __field(u8, opcode)
 239        ),
 240
 241        TP_fast_assign(
 242                __assign_str(dev_name, dev_name);
 243                __assign_str(str, str);
 244                __entry->tag = tag;
 245                __entry->doorbell = doorbell;
 246                __entry->transfer_len = transfer_len;
 247                __entry->intr = intr;
 248                __entry->lba = lba;
 249                __entry->opcode = opcode;
 250        ),
 251
 252        TP_printk(
 253                "%s: %s: tag: %u, DB: 0x%x, size: %d, IS: %u, LBA: %llu, opcode: 0x%x",
 254                __get_str(str), __get_str(dev_name), __entry->tag,
 255                __entry->doorbell, __entry->transfer_len,
 256                __entry->intr, __entry->lba, (u32)__entry->opcode
 257        )
 258);
 259
 260TRACE_EVENT(ufshcd_upiu,
 261        TP_PROTO(const char *dev_name, const char *str, void *hdr, void *tsf),
 262
 263        TP_ARGS(dev_name, str, hdr, tsf),
 264
 265        TP_STRUCT__entry(
 266                __string(dev_name, dev_name)
 267                __string(str, str)
 268                __array(unsigned char, hdr, 12)
 269                __array(unsigned char, tsf, 16)
 270        ),
 271
 272        TP_fast_assign(
 273                __assign_str(dev_name, dev_name);
 274                __assign_str(str, str);
 275                memcpy(__entry->hdr, hdr, sizeof(__entry->hdr));
 276                memcpy(__entry->tsf, tsf, sizeof(__entry->tsf));
 277        ),
 278
 279        TP_printk(
 280                "%s: %s: HDR:%s, CDB:%s",
 281                __get_str(str), __get_str(dev_name),
 282                __print_hex(__entry->hdr, sizeof(__entry->hdr)),
 283                __print_hex(__entry->tsf, sizeof(__entry->tsf))
 284        )
 285);
 286
 287#endif /* if !defined(_TRACE_UFS_H) || defined(TRACE_HEADER_MULTI_READ) */
 288
 289/* This part must be outside protection */
 290#include <trace/define_trace.h>
 291