GNU Linux-libre 4.14.290-gnu1
[releases.git] / include / trace / events / libata.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM libata
4
5 #if !defined(_TRACE_LIBATA_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_LIBATA_H
7
8 #include <linux/ata.h>
9 #include <linux/libata.h>
10 #include <linux/tracepoint.h>
11 #include <linux/trace_seq.h>
12
13 #define ata_opcode_name(opcode) { opcode, #opcode }
14 #define show_opcode_name(val)                                   \
15         __print_symbolic(val,                                   \
16                  ata_opcode_name(ATA_CMD_DEV_RESET),            \
17                  ata_opcode_name(ATA_CMD_CHK_POWER),            \
18                  ata_opcode_name(ATA_CMD_STANDBY),              \
19                  ata_opcode_name(ATA_CMD_IDLE),                 \
20                  ata_opcode_name(ATA_CMD_EDD),                  \
21                  ata_opcode_name(ATA_CMD_DOWNLOAD_MICRO),       \
22                  ata_opcode_name(ATA_CMD_DOWNLOAD_MICRO_DMA),   \
23                  ata_opcode_name(ATA_CMD_NOP),                  \
24                  ata_opcode_name(ATA_CMD_FLUSH),                \
25                  ata_opcode_name(ATA_CMD_FLUSH_EXT),            \
26                  ata_opcode_name(ATA_CMD_ID_ATA),               \
27                  ata_opcode_name(ATA_CMD_ID_ATAPI),             \
28                  ata_opcode_name(ATA_CMD_SERVICE),              \
29                  ata_opcode_name(ATA_CMD_READ),                 \
30                  ata_opcode_name(ATA_CMD_READ_EXT),             \
31                  ata_opcode_name(ATA_CMD_READ_QUEUED),          \
32                  ata_opcode_name(ATA_CMD_READ_STREAM_EXT),      \
33                  ata_opcode_name(ATA_CMD_READ_STREAM_DMA_EXT),  \
34                  ata_opcode_name(ATA_CMD_WRITE),                \
35                  ata_opcode_name(ATA_CMD_WRITE_EXT),            \
36                  ata_opcode_name(ATA_CMD_WRITE_QUEUED),         \
37                  ata_opcode_name(ATA_CMD_WRITE_STREAM_EXT),     \
38                  ata_opcode_name(ATA_CMD_WRITE_STREAM_DMA_EXT), \
39                  ata_opcode_name(ATA_CMD_WRITE_FUA_EXT),        \
40                  ata_opcode_name(ATA_CMD_WRITE_QUEUED_FUA_EXT), \
41                  ata_opcode_name(ATA_CMD_FPDMA_READ),           \
42                  ata_opcode_name(ATA_CMD_FPDMA_WRITE),          \
43                  ata_opcode_name(ATA_CMD_NCQ_NON_DATA),         \
44                  ata_opcode_name(ATA_CMD_FPDMA_SEND),           \
45                  ata_opcode_name(ATA_CMD_FPDMA_RECV),           \
46                  ata_opcode_name(ATA_CMD_PIO_READ),             \
47                  ata_opcode_name(ATA_CMD_PIO_READ_EXT),         \
48                  ata_opcode_name(ATA_CMD_PIO_WRITE),            \
49                  ata_opcode_name(ATA_CMD_PIO_WRITE_EXT),        \
50                  ata_opcode_name(ATA_CMD_READ_MULTI),           \
51                  ata_opcode_name(ATA_CMD_READ_MULTI_EXT),       \
52                  ata_opcode_name(ATA_CMD_WRITE_MULTI),          \
53                  ata_opcode_name(ATA_CMD_WRITE_MULTI_EXT),      \
54                  ata_opcode_name(ATA_CMD_WRITE_MULTI_FUA_EXT),  \
55                  ata_opcode_name(ATA_CMD_SET_FEATURES),         \
56                  ata_opcode_name(ATA_CMD_SET_MULTI),            \
57                  ata_opcode_name(ATA_CMD_PACKET),               \
58                  ata_opcode_name(ATA_CMD_VERIFY),               \
59                  ata_opcode_name(ATA_CMD_VERIFY_EXT),           \
60                  ata_opcode_name(ATA_CMD_WRITE_UNCORR_EXT),     \
61                  ata_opcode_name(ATA_CMD_STANDBYNOW1),          \
62                  ata_opcode_name(ATA_CMD_IDLEIMMEDIATE),        \
63                  ata_opcode_name(ATA_CMD_SLEEP),                \
64                  ata_opcode_name(ATA_CMD_INIT_DEV_PARAMS),      \
65                  ata_opcode_name(ATA_CMD_READ_NATIVE_MAX),      \
66                  ata_opcode_name(ATA_CMD_READ_NATIVE_MAX_EXT),  \
67                  ata_opcode_name(ATA_CMD_SET_MAX),              \
68                  ata_opcode_name(ATA_CMD_SET_MAX_EXT),          \
69                  ata_opcode_name(ATA_CMD_READ_LOG_EXT),         \
70                  ata_opcode_name(ATA_CMD_WRITE_LOG_EXT),        \
71                  ata_opcode_name(ATA_CMD_READ_LOG_DMA_EXT),     \
72                  ata_opcode_name(ATA_CMD_WRITE_LOG_DMA_EXT),    \
73                  ata_opcode_name(ATA_CMD_TRUSTED_NONDATA),      \
74                  ata_opcode_name(ATA_CMD_TRUSTED_RCV),          \
75                  ata_opcode_name(ATA_CMD_TRUSTED_RCV_DMA),      \
76                  ata_opcode_name(ATA_CMD_TRUSTED_SND),          \
77                  ata_opcode_name(ATA_CMD_TRUSTED_SND_DMA),      \
78                  ata_opcode_name(ATA_CMD_PMP_READ),             \
79                  ata_opcode_name(ATA_CMD_PMP_READ_DMA),         \
80                  ata_opcode_name(ATA_CMD_PMP_WRITE),            \
81                  ata_opcode_name(ATA_CMD_PMP_WRITE_DMA),        \
82                  ata_opcode_name(ATA_CMD_CONF_OVERLAY),         \
83                  ata_opcode_name(ATA_CMD_SEC_SET_PASS),         \
84                  ata_opcode_name(ATA_CMD_SEC_UNLOCK),           \
85                  ata_opcode_name(ATA_CMD_SEC_ERASE_PREP),       \
86                  ata_opcode_name(ATA_CMD_SEC_ERASE_UNIT),       \
87                  ata_opcode_name(ATA_CMD_SEC_FREEZE_LOCK),      \
88                  ata_opcode_name(ATA_CMD_SEC_DISABLE_PASS),     \
89                  ata_opcode_name(ATA_CMD_CONFIG_STREAM),        \
90                  ata_opcode_name(ATA_CMD_SMART),                \
91                  ata_opcode_name(ATA_CMD_MEDIA_LOCK),           \
92                  ata_opcode_name(ATA_CMD_MEDIA_UNLOCK),         \
93                  ata_opcode_name(ATA_CMD_DSM),                  \
94                  ata_opcode_name(ATA_CMD_CHK_MED_CRD_TYP),      \
95                  ata_opcode_name(ATA_CMD_CFA_REQ_EXT_ERR),      \
96                  ata_opcode_name(ATA_CMD_CFA_WRITE_NE),         \
97                  ata_opcode_name(ATA_CMD_CFA_TRANS_SECT),       \
98                  ata_opcode_name(ATA_CMD_CFA_ERASE),            \
99                  ata_opcode_name(ATA_CMD_CFA_WRITE_MULT_NE),    \
100                  ata_opcode_name(ATA_CMD_REQ_SENSE_DATA),       \
101                  ata_opcode_name(ATA_CMD_SANITIZE_DEVICE),      \
102                  ata_opcode_name(ATA_CMD_ZAC_MGMT_IN),          \
103                  ata_opcode_name(ATA_CMD_ZAC_MGMT_OUT),         \
104                  ata_opcode_name(ATA_CMD_RESTORE),              \
105                  ata_opcode_name(ATA_CMD_READ_LONG),            \
106                  ata_opcode_name(ATA_CMD_READ_LONG_ONCE),       \
107                  ata_opcode_name(ATA_CMD_WRITE_LONG),           \
108                  ata_opcode_name(ATA_CMD_WRITE_LONG_ONCE))
109
110 #define ata_error_name(result)  { result, #result }
111 #define show_error_name(val)                            \
112         __print_symbolic(val,                           \
113                 ata_error_name(ATA_ICRC),               \
114                 ata_error_name(ATA_UNC),                \
115                 ata_error_name(ATA_MC),                 \
116                 ata_error_name(ATA_IDNF),               \
117                 ata_error_name(ATA_MCR),                \
118                 ata_error_name(ATA_ABORTED),            \
119                 ata_error_name(ATA_TRK0NF),             \
120                 ata_error_name(ATA_AMNF))
121
122 #define ata_protocol_name(proto)        { proto, #proto }
123 #define show_protocol_name(val)                         \
124         __print_symbolic(val,                           \
125                 ata_protocol_name(ATA_PROT_UNKNOWN),    \
126                 ata_protocol_name(ATA_PROT_NODATA),     \
127                 ata_protocol_name(ATA_PROT_PIO),        \
128                 ata_protocol_name(ATA_PROT_DMA),        \
129                 ata_protocol_name(ATA_PROT_NCQ),        \
130                 ata_protocol_name(ATA_PROT_NCQ_NODATA), \
131                 ata_protocol_name(ATAPI_PROT_NODATA),   \
132                 ata_protocol_name(ATAPI_PROT_PIO),      \
133                 ata_protocol_name(ATAPI_PROT_DMA))
134
135 const char *libata_trace_parse_status(struct trace_seq*, unsigned char);
136 #define __parse_status(s) libata_trace_parse_status(p, s)
137
138 const char *libata_trace_parse_eh_action(struct trace_seq *, unsigned int);
139 #define __parse_eh_action(a) libata_trace_parse_eh_action(p, a)
140
141 const char *libata_trace_parse_eh_err_mask(struct trace_seq *, unsigned int);
142 #define __parse_eh_err_mask(m) libata_trace_parse_eh_err_mask(p, m)
143
144 const char *libata_trace_parse_qc_flags(struct trace_seq *, unsigned int);
145 #define __parse_qc_flags(f) libata_trace_parse_qc_flags(p, f)
146
147 const char *libata_trace_parse_subcmd(struct trace_seq *, unsigned char,
148                                       unsigned char, unsigned char);
149 #define __parse_subcmd(c,f,h) libata_trace_parse_subcmd(p, c, f, h)
150
151 TRACE_EVENT(ata_qc_issue,
152
153         TP_PROTO(struct ata_queued_cmd *qc),
154
155         TP_ARGS(qc),
156
157         TP_STRUCT__entry(
158                 __field( unsigned int,  ata_port )
159                 __field( unsigned int,  ata_dev )
160                 __field( unsigned int,  tag     )
161                 __field( unsigned char, cmd     )
162                 __field( unsigned char, dev     )
163                 __field( unsigned char, lbal    )
164                 __field( unsigned char, lbam    )
165                 __field( unsigned char, lbah    )
166                 __field( unsigned char, nsect   )
167                 __field( unsigned char, feature )
168                 __field( unsigned char, hob_lbal )
169                 __field( unsigned char, hob_lbam )
170                 __field( unsigned char, hob_lbah )
171                 __field( unsigned char, hob_nsect )
172                 __field( unsigned char, hob_feature )
173                 __field( unsigned char, ctl )
174                 __field( unsigned char, proto )
175                 __field( unsigned long, flags )
176         ),
177
178         TP_fast_assign(
179                 __entry->ata_port       = qc->ap->print_id;
180                 __entry->ata_dev        = qc->dev->link->pmp + qc->dev->devno;
181                 __entry->tag            = qc->tag;
182                 __entry->proto          = qc->tf.protocol;
183                 __entry->cmd            = qc->tf.command;
184                 __entry->dev            = qc->tf.device;
185                 __entry->lbal           = qc->tf.lbal;
186                 __entry->lbam           = qc->tf.lbam;
187                 __entry->lbah           = qc->tf.lbah;
188                 __entry->hob_lbal       = qc->tf.hob_lbal;
189                 __entry->hob_lbam       = qc->tf.hob_lbam;
190                 __entry->hob_lbah       = qc->tf.hob_lbah;
191                 __entry->feature        = qc->tf.feature;
192                 __entry->hob_feature    = qc->tf.hob_feature;
193                 __entry->nsect          = qc->tf.nsect;
194                 __entry->hob_nsect      = qc->tf.hob_nsect;
195         ),
196
197         TP_printk("ata_port=%u ata_dev=%u tag=%d proto=%s cmd=%s%s " \
198                   " tf=(%02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x)",
199                   __entry->ata_port, __entry->ata_dev, __entry->tag,
200                   show_protocol_name(__entry->proto),
201                   show_opcode_name(__entry->cmd),
202                   __parse_subcmd(__entry->cmd, __entry->feature, __entry->hob_nsect),
203                   __entry->cmd, __entry->feature, __entry->nsect,
204                   __entry->lbal, __entry->lbam, __entry->lbah,
205                   __entry->hob_feature, __entry->hob_nsect,
206                   __entry->hob_lbal, __entry->hob_lbam, __entry->hob_lbah,
207                   __entry->dev)
208 );
209
210 DECLARE_EVENT_CLASS(ata_qc_complete_template,
211
212         TP_PROTO(struct ata_queued_cmd *qc),
213
214         TP_ARGS(qc),
215
216         TP_STRUCT__entry(
217                 __field( unsigned int,  ata_port )
218                 __field( unsigned int,  ata_dev )
219                 __field( unsigned int,  tag     )
220                 __field( unsigned char, status  )
221                 __field( unsigned char, dev     )
222                 __field( unsigned char, lbal    )
223                 __field( unsigned char, lbam    )
224                 __field( unsigned char, lbah    )
225                 __field( unsigned char, nsect   )
226                 __field( unsigned char, error   )
227                 __field( unsigned char, hob_lbal )
228                 __field( unsigned char, hob_lbam )
229                 __field( unsigned char, hob_lbah )
230                 __field( unsigned char, hob_nsect )
231                 __field( unsigned char, hob_feature )
232                 __field( unsigned char, ctl )
233                 __field( unsigned long, flags )
234         ),
235
236         TP_fast_assign(
237                 __entry->ata_port       = qc->ap->print_id;
238                 __entry->ata_dev        = qc->dev->link->pmp + qc->dev->devno;
239                 __entry->tag            = qc->tag;
240                 __entry->status         = qc->result_tf.command;
241                 __entry->dev            = qc->result_tf.device;
242                 __entry->lbal           = qc->result_tf.lbal;
243                 __entry->lbam           = qc->result_tf.lbam;
244                 __entry->lbah           = qc->result_tf.lbah;
245                 __entry->hob_lbal       = qc->result_tf.hob_lbal;
246                 __entry->hob_lbam       = qc->result_tf.hob_lbam;
247                 __entry->hob_lbah       = qc->result_tf.hob_lbah;
248                 __entry->error          = qc->result_tf.feature;
249                 __entry->hob_feature    = qc->result_tf.hob_feature;
250                 __entry->nsect          = qc->result_tf.nsect;
251                 __entry->hob_nsect      = qc->result_tf.hob_nsect;
252                 __entry->flags          = qc->flags;
253         ),
254
255         TP_printk("ata_port=%u ata_dev=%u tag=%d flags=%s status=%s " \
256                   " res=(%02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x)",
257                   __entry->ata_port, __entry->ata_dev, __entry->tag,
258                   __parse_qc_flags(__entry->flags),
259                   __parse_status(__entry->status),
260                   __entry->status, __entry->error, __entry->nsect,
261                   __entry->lbal, __entry->lbam, __entry->lbah,
262                   __entry->hob_feature, __entry->hob_nsect,
263                   __entry->hob_lbal, __entry->hob_lbam, __entry->hob_lbah,
264                   __entry->dev)
265 );
266
267 DEFINE_EVENT(ata_qc_complete_template, ata_qc_complete_internal,
268              TP_PROTO(struct ata_queued_cmd *qc),
269              TP_ARGS(qc));
270
271 DEFINE_EVENT(ata_qc_complete_template, ata_qc_complete_failed,
272              TP_PROTO(struct ata_queued_cmd *qc),
273              TP_ARGS(qc));
274
275 DEFINE_EVENT(ata_qc_complete_template, ata_qc_complete_done,
276              TP_PROTO(struct ata_queued_cmd *qc),
277              TP_ARGS(qc));
278
279 TRACE_EVENT(ata_eh_link_autopsy,
280
281         TP_PROTO(struct ata_device *dev, unsigned int eh_action, unsigned int eh_err_mask),
282
283         TP_ARGS(dev, eh_action, eh_err_mask),
284
285         TP_STRUCT__entry(
286                 __field( unsigned int,  ata_port )
287                 __field( unsigned int,  ata_dev )
288                 __field( unsigned int,  eh_action )
289                 __field( unsigned int,  eh_err_mask)
290         ),
291
292         TP_fast_assign(
293                 __entry->ata_port       = dev->link->ap->print_id;
294                 __entry->ata_dev        = dev->link->pmp + dev->devno;
295                 __entry->eh_action      = eh_action;
296                 __entry->eh_err_mask    = eh_err_mask;
297         ),
298
299         TP_printk("ata_port=%u ata_dev=%u eh_action=%s err_mask=%s",
300                   __entry->ata_port, __entry->ata_dev,
301                   __parse_eh_action(__entry->eh_action),
302                   __parse_eh_err_mask(__entry->eh_err_mask))
303 );
304
305 TRACE_EVENT(ata_eh_link_autopsy_qc,
306
307         TP_PROTO(struct ata_queued_cmd *qc),
308
309         TP_ARGS(qc),
310
311         TP_STRUCT__entry(
312                 __field( unsigned int,  ata_port )
313                 __field( unsigned int,  ata_dev )
314                 __field( unsigned int,  tag     )
315                 __field( unsigned int,  qc_flags )
316                 __field( unsigned int,  eh_err_mask)
317         ),
318
319         TP_fast_assign(
320                 __entry->ata_port       = qc->ap->print_id;
321                 __entry->ata_dev        = qc->dev->link->pmp + qc->dev->devno;
322                 __entry->tag            = qc->tag;
323                 __entry->qc_flags       = qc->flags;
324                 __entry->eh_err_mask    = qc->err_mask;
325         ),
326
327         TP_printk("ata_port=%u ata_dev=%u tag=%d flags=%s err_mask=%s",
328                   __entry->ata_port, __entry->ata_dev, __entry->tag,
329                   __parse_qc_flags(__entry->qc_flags),
330                   __parse_eh_err_mask(__entry->eh_err_mask))
331 );
332
333 #endif /*  _TRACE_LIBATA_H */
334
335 /* This part must be outside protection */
336 #include <trace/define_trace.h>