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 #define ata_class_name(class)	{ class, #class }
136 #define show_class_name(val)				\
137 	__print_symbolic(val,				\
138 		ata_class_name(ATA_DEV_UNKNOWN),	\
139 		ata_class_name(ATA_DEV_ATA),		\
140 		ata_class_name(ATA_DEV_ATA_UNSUP),	\
141 		ata_class_name(ATA_DEV_ATAPI),		\
142 		ata_class_name(ATA_DEV_ATAPI_UNSUP),	\
143 		ata_class_name(ATA_DEV_PMP),		\
144 		ata_class_name(ATA_DEV_PMP_UNSUP),	\
145 		ata_class_name(ATA_DEV_SEMB),		\
146 		ata_class_name(ATA_DEV_SEMB_UNSUP),	\
147 		ata_class_name(ATA_DEV_ZAC),		\
148 		ata_class_name(ATA_DEV_ZAC_UNSUP),	\
149 		ata_class_name(ATA_DEV_NONE))
150 
151 #define ata_sff_hsm_state_name(state)	{ state, #state }
152 #define show_sff_hsm_state_name(val)				\
153     __print_symbolic(val,				\
154 		ata_sff_hsm_state_name(HSM_ST_IDLE),	\
155 		ata_sff_hsm_state_name(HSM_ST_FIRST),	\
156 		ata_sff_hsm_state_name(HSM_ST),		\
157 		ata_sff_hsm_state_name(HSM_ST_LAST),	\
158 		ata_sff_hsm_state_name(HSM_ST_ERR))
159 
160 const char *libata_trace_parse_status(struct trace_seq*, unsigned char);
161 #define __parse_status(s) libata_trace_parse_status(p, s)
162 
163 const char *libata_trace_parse_host_stat(struct trace_seq *, unsigned char);
164 #define __parse_host_stat(s) libata_trace_parse_host_stat(p, s)
165 
166 const char *libata_trace_parse_eh_action(struct trace_seq *, unsigned int);
167 #define __parse_eh_action(a) libata_trace_parse_eh_action(p, a)
168 
169 const char *libata_trace_parse_eh_err_mask(struct trace_seq *, unsigned int);
170 #define __parse_eh_err_mask(m) libata_trace_parse_eh_err_mask(p, m)
171 
172 const char *libata_trace_parse_qc_flags(struct trace_seq *, unsigned int);
173 #define __parse_qc_flags(f) libata_trace_parse_qc_flags(p, f)
174 
175 const char *libata_trace_parse_tf_flags(struct trace_seq *, unsigned int);
176 #define __parse_tf_flags(f) libata_trace_parse_tf_flags(p, f)
177 
178 const char *libata_trace_parse_subcmd(struct trace_seq *, unsigned char,
179 				      unsigned char, unsigned char);
180 #define __parse_subcmd(c,f,h) libata_trace_parse_subcmd(p, c, f, h)
181 
182 DECLARE_EVENT_CLASS(ata_qc_issue_template,
183 
184 	TP_PROTO(struct ata_queued_cmd *qc),
185 
186 	TP_ARGS(qc),
187 
188 	TP_STRUCT__entry(
189 		__field( unsigned int,	ata_port )
190 		__field( unsigned int,	ata_dev	)
191 		__field( unsigned int,	tag	)
192 		__field( unsigned char,	cmd	)
193 		__field( unsigned char,	dev	)
194 		__field( unsigned char,	lbal	)
195 		__field( unsigned char,	lbam	)
196 		__field( unsigned char,	lbah	)
197 		__field( unsigned char,	nsect	)
198 		__field( unsigned char,	feature	)
199 		__field( unsigned char,	hob_lbal )
200 		__field( unsigned char,	hob_lbam )
201 		__field( unsigned char,	hob_lbah )
202 		__field( unsigned char,	hob_nsect )
203 		__field( unsigned char,	hob_feature )
204 		__field( unsigned char,	ctl )
205 		__field( unsigned char,	proto )
206 		__field( unsigned long,	flags )
207 	),
208 
209 	TP_fast_assign(
210 		__entry->ata_port	= qc->ap->print_id;
211 		__entry->ata_dev	= qc->dev->link->pmp + qc->dev->devno;
212 		__entry->tag		= qc->tag;
213 		__entry->proto		= qc->tf.protocol;
214 		__entry->cmd		= qc->tf.command;
215 		__entry->dev		= qc->tf.device;
216 		__entry->lbal		= qc->tf.lbal;
217 		__entry->lbam		= qc->tf.lbam;
218 		__entry->lbah		= qc->tf.lbah;
219 		__entry->hob_lbal	= qc->tf.hob_lbal;
220 		__entry->hob_lbam	= qc->tf.hob_lbam;
221 		__entry->hob_lbah	= qc->tf.hob_lbah;
222 		__entry->feature	= qc->tf.feature;
223 		__entry->hob_feature	= qc->tf.hob_feature;
224 		__entry->nsect		= qc->tf.nsect;
225 		__entry->hob_nsect	= qc->tf.hob_nsect;
226 	),
227 
228 	TP_printk("ata_port=%u ata_dev=%u tag=%d proto=%s cmd=%s%s " \
229 		  " tf=(%02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x)",
230 		  __entry->ata_port, __entry->ata_dev, __entry->tag,
231 		  show_protocol_name(__entry->proto),
232 		  show_opcode_name(__entry->cmd),
233 		  __parse_subcmd(__entry->cmd, __entry->feature, __entry->hob_nsect),
234 		  __entry->cmd, __entry->feature, __entry->nsect,
235 		  __entry->lbal, __entry->lbam, __entry->lbah,
236 		  __entry->hob_feature, __entry->hob_nsect,
237 		  __entry->hob_lbal, __entry->hob_lbam, __entry->hob_lbah,
238 		  __entry->dev)
239 );
240 
241 DEFINE_EVENT(ata_qc_issue_template, ata_qc_prep,
242 	     TP_PROTO(struct ata_queued_cmd *qc),
243 	     TP_ARGS(qc));
244 
245 DEFINE_EVENT(ata_qc_issue_template, ata_qc_issue,
246 	     TP_PROTO(struct ata_queued_cmd *qc),
247 	     TP_ARGS(qc));
248 
249 DECLARE_EVENT_CLASS(ata_qc_complete_template,
250 
251 	TP_PROTO(struct ata_queued_cmd *qc),
252 
253 	TP_ARGS(qc),
254 
255 	TP_STRUCT__entry(
256 		__field( unsigned int,	ata_port )
257 		__field( unsigned int,	ata_dev	)
258 		__field( unsigned int,	tag	)
259 		__field( unsigned char,	status	)
260 		__field( unsigned char,	dev	)
261 		__field( unsigned char,	lbal	)
262 		__field( unsigned char,	lbam	)
263 		__field( unsigned char,	lbah	)
264 		__field( unsigned char,	nsect	)
265 		__field( unsigned char,	error	)
266 		__field( unsigned char,	hob_lbal )
267 		__field( unsigned char,	hob_lbam )
268 		__field( unsigned char,	hob_lbah )
269 		__field( unsigned char,	hob_nsect )
270 		__field( unsigned char,	hob_feature )
271 		__field( unsigned char,	ctl )
272 		__field( unsigned long,	flags )
273 	),
274 
275 	TP_fast_assign(
276 		__entry->ata_port	= qc->ap->print_id;
277 		__entry->ata_dev	= qc->dev->link->pmp + qc->dev->devno;
278 		__entry->tag		= qc->tag;
279 		__entry->status		= qc->result_tf.command;
280 		__entry->dev		= qc->result_tf.device;
281 		__entry->lbal		= qc->result_tf.lbal;
282 		__entry->lbam		= qc->result_tf.lbam;
283 		__entry->lbah		= qc->result_tf.lbah;
284 		__entry->hob_lbal	= qc->result_tf.hob_lbal;
285 		__entry->hob_lbam	= qc->result_tf.hob_lbam;
286 		__entry->hob_lbah	= qc->result_tf.hob_lbah;
287 		__entry->error		= qc->result_tf.feature;
288 		__entry->hob_feature	= qc->result_tf.hob_feature;
289 		__entry->nsect		= qc->result_tf.nsect;
290 		__entry->hob_nsect	= qc->result_tf.hob_nsect;
291 		__entry->flags		= qc->flags;
292 	),
293 
294 	TP_printk("ata_port=%u ata_dev=%u tag=%d flags=%s status=%s " \
295 		  " res=(%02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x)",
296 		  __entry->ata_port, __entry->ata_dev, __entry->tag,
297 		  __parse_qc_flags(__entry->flags),
298 		  __parse_status(__entry->status),
299 		  __entry->status, __entry->error, __entry->nsect,
300 		  __entry->lbal, __entry->lbam, __entry->lbah,
301 		  __entry->hob_feature, __entry->hob_nsect,
302 		  __entry->hob_lbal, __entry->hob_lbam, __entry->hob_lbah,
303 		  __entry->dev)
304 );
305 
306 DEFINE_EVENT(ata_qc_complete_template, ata_qc_complete_internal,
307 	     TP_PROTO(struct ata_queued_cmd *qc),
308 	     TP_ARGS(qc));
309 
310 DEFINE_EVENT(ata_qc_complete_template, ata_qc_complete_failed,
311 	     TP_PROTO(struct ata_queued_cmd *qc),
312 	     TP_ARGS(qc));
313 
314 DEFINE_EVENT(ata_qc_complete_template, ata_qc_complete_done,
315 	     TP_PROTO(struct ata_queued_cmd *qc),
316 	     TP_ARGS(qc));
317 
318 TRACE_EVENT(ata_tf_load,
319 
320 	TP_PROTO(struct ata_port *ap, const struct ata_taskfile *tf),
321 
322 	TP_ARGS(ap, tf),
323 
324 	TP_STRUCT__entry(
325 		__field( unsigned int,	ata_port )
326 		__field( unsigned char,	cmd	)
327 		__field( unsigned char,	dev	)
328 		__field( unsigned char,	lbal	)
329 		__field( unsigned char,	lbam	)
330 		__field( unsigned char,	lbah	)
331 		__field( unsigned char,	nsect	)
332 		__field( unsigned char,	feature	)
333 		__field( unsigned char,	hob_lbal )
334 		__field( unsigned char,	hob_lbam )
335 		__field( unsigned char,	hob_lbah )
336 		__field( unsigned char,	hob_nsect )
337 		__field( unsigned char,	hob_feature )
338 		__field( unsigned char,	proto	)
339 	),
340 
341 	TP_fast_assign(
342 		__entry->ata_port	= ap->print_id;
343 		__entry->proto		= tf->protocol;
344 		__entry->cmd		= tf->command;
345 		__entry->dev		= tf->device;
346 		__entry->lbal		= tf->lbal;
347 		__entry->lbam		= tf->lbam;
348 		__entry->lbah		= tf->lbah;
349 		__entry->hob_lbal	= tf->hob_lbal;
350 		__entry->hob_lbam	= tf->hob_lbam;
351 		__entry->hob_lbah	= tf->hob_lbah;
352 		__entry->feature	= tf->feature;
353 		__entry->hob_feature	= tf->hob_feature;
354 		__entry->nsect		= tf->nsect;
355 		__entry->hob_nsect	= tf->hob_nsect;
356 	),
357 
358 	TP_printk("ata_port=%u proto=%s cmd=%s%s " \
359 		  " tf=(%02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x)",
360 		  __entry->ata_port,
361 		  show_protocol_name(__entry->proto),
362 		  show_opcode_name(__entry->cmd),
363 		  __parse_subcmd(__entry->cmd, __entry->feature, __entry->hob_nsect),
364 		  __entry->cmd, __entry->feature, __entry->nsect,
365 		  __entry->lbal, __entry->lbam, __entry->lbah,
366 		  __entry->hob_feature, __entry->hob_nsect,
367 		  __entry->hob_lbal, __entry->hob_lbam, __entry->hob_lbah,
368 		  __entry->dev)
369 );
370 
371 DECLARE_EVENT_CLASS(ata_exec_command_template,
372 
373 	TP_PROTO(struct ata_port *ap, const struct ata_taskfile *tf, unsigned int tag),
374 
375 	TP_ARGS(ap, tf, tag),
376 
377 	TP_STRUCT__entry(
378 		__field( unsigned int,	ata_port )
379 		__field( unsigned int,	tag	)
380 		__field( unsigned char,	cmd	)
381 		__field( unsigned char,	feature	)
382 		__field( unsigned char,	hob_nsect )
383 		__field( unsigned char,	proto	)
384 	),
385 
386 	TP_fast_assign(
387 		__entry->ata_port	= ap->print_id;
388 		__entry->tag		= tag;
389 		__entry->proto		= tf->protocol;
390 		__entry->cmd		= tf->command;
391 		__entry->feature	= tf->feature;
392 		__entry->hob_nsect	= tf->hob_nsect;
393 	),
394 
395 	TP_printk("ata_port=%u tag=%d proto=%s cmd=%s%s",
396 		  __entry->ata_port, __entry->tag,
397 		  show_protocol_name(__entry->proto),
398 		  show_opcode_name(__entry->cmd),
399 		  __parse_subcmd(__entry->cmd, __entry->feature, __entry->hob_nsect))
400 );
401 
402 DEFINE_EVENT(ata_exec_command_template, ata_exec_command,
403 	     TP_PROTO(struct ata_port *ap, const struct ata_taskfile *tf, unsigned int tag),
404 	     TP_ARGS(ap, tf, tag));
405 
406 DEFINE_EVENT(ata_exec_command_template, ata_bmdma_setup,
407 	     TP_PROTO(struct ata_port *ap, const struct ata_taskfile *tf, unsigned int tag),
408 	     TP_ARGS(ap, tf, tag));
409 
410 DEFINE_EVENT(ata_exec_command_template, ata_bmdma_start,
411 	     TP_PROTO(struct ata_port *ap, const struct ata_taskfile *tf, unsigned int tag),
412 	     TP_ARGS(ap, tf, tag));
413 
414 DEFINE_EVENT(ata_exec_command_template, ata_bmdma_stop,
415 	     TP_PROTO(struct ata_port *ap, const struct ata_taskfile *tf, unsigned int tag),
416 	     TP_ARGS(ap, tf, tag));
417 
418 TRACE_EVENT(ata_bmdma_status,
419 
420 	TP_PROTO(struct ata_port *ap, unsigned int host_stat),
421 
422 	TP_ARGS(ap, host_stat),
423 
424 	TP_STRUCT__entry(
425 		__field( unsigned int,	ata_port )
426 		__field( unsigned int,	tag	)
427 		__field( unsigned char,	host_stat )
428 	),
429 
430 	TP_fast_assign(
431 		__entry->ata_port	= ap->print_id;
432 		__entry->host_stat	= host_stat;
433 	),
434 
435 	TP_printk("ata_port=%u host_stat=%s",
436 		  __entry->ata_port,
437 		  __parse_host_stat(__entry->host_stat))
438 );
439 
440 TRACE_EVENT(ata_eh_link_autopsy,
441 
442 	TP_PROTO(struct ata_device *dev, unsigned int eh_action, unsigned int eh_err_mask),
443 
444 	TP_ARGS(dev, eh_action, eh_err_mask),
445 
446 	TP_STRUCT__entry(
447 		__field( unsigned int,	ata_port )
448 		__field( unsigned int,	ata_dev	)
449 		__field( unsigned int,	eh_action )
450 		__field( unsigned int,	eh_err_mask)
451 	),
452 
453 	TP_fast_assign(
454 		__entry->ata_port	= dev->link->ap->print_id;
455 		__entry->ata_dev	= dev->link->pmp + dev->devno;
456 		__entry->eh_action	= eh_action;
457 		__entry->eh_err_mask	= eh_err_mask;
458 	),
459 
460 	TP_printk("ata_port=%u ata_dev=%u eh_action=%s err_mask=%s",
461 		  __entry->ata_port, __entry->ata_dev,
462 		  __parse_eh_action(__entry->eh_action),
463 		  __parse_eh_err_mask(__entry->eh_err_mask))
464 );
465 
466 TRACE_EVENT(ata_eh_link_autopsy_qc,
467 
468 	TP_PROTO(struct ata_queued_cmd *qc),
469 
470 	TP_ARGS(qc),
471 
472 	TP_STRUCT__entry(
473 		__field( unsigned int,	ata_port )
474 		__field( unsigned int,	ata_dev	)
475 		__field( unsigned int,	tag	)
476 		__field( unsigned int,	qc_flags )
477 		__field( unsigned int,	eh_err_mask)
478 	),
479 
480 	TP_fast_assign(
481 		__entry->ata_port	= qc->ap->print_id;
482 		__entry->ata_dev	= qc->dev->link->pmp + qc->dev->devno;
483 		__entry->tag		= qc->tag;
484 		__entry->qc_flags	= qc->flags;
485 		__entry->eh_err_mask	= qc->err_mask;
486 	),
487 
488 	TP_printk("ata_port=%u ata_dev=%u tag=%d flags=%s err_mask=%s",
489 		  __entry->ata_port, __entry->ata_dev, __entry->tag,
490 		  __parse_qc_flags(__entry->qc_flags),
491 		  __parse_eh_err_mask(__entry->eh_err_mask))
492 );
493 
494 DECLARE_EVENT_CLASS(ata_eh_action_template,
495 
496 	TP_PROTO(struct ata_link *link, unsigned int devno, unsigned int eh_action),
497 
498 	TP_ARGS(link, devno, eh_action),
499 
500 	TP_STRUCT__entry(
501 		__field( unsigned int,	ata_port )
502 		__field( unsigned int,	ata_dev	)
503 		__field( unsigned int,	eh_action )
504 	),
505 
506 	TP_fast_assign(
507 		__entry->ata_port	= link->ap->print_id;
508 		__entry->ata_dev	= link->pmp + devno;
509 		__entry->eh_action	= eh_action;
510 	),
511 
512 	TP_printk("ata_port=%u ata_dev=%u eh_action=%s",
513 		  __entry->ata_port, __entry->ata_dev,
514 		  __parse_eh_action(__entry->eh_action))
515 );
516 
517 DEFINE_EVENT(ata_eh_action_template, ata_eh_about_to_do,
518 	     TP_PROTO(struct ata_link *link, unsigned int devno, unsigned int eh_action),
519 	     TP_ARGS(link, devno, eh_action));
520 
521 DEFINE_EVENT(ata_eh_action_template, ata_eh_done,
522 	     TP_PROTO(struct ata_link *link, unsigned int devno, unsigned int eh_action),
523 	     TP_ARGS(link, devno, eh_action));
524 
525 DECLARE_EVENT_CLASS(ata_link_reset_begin_template,
526 
527 	TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline),
528 
529 	TP_ARGS(link, class, deadline),
530 
531 	TP_STRUCT__entry(
532 		__field( unsigned int,	ata_port )
533 		__array( unsigned int,	class, 2 )
534 		__field( unsigned long,	deadline )
535 	),
536 
537 	TP_fast_assign(
538 		__entry->ata_port	= link->ap->print_id;
539 		memcpy(__entry->class, class, 2);
540 		__entry->deadline	= deadline;
541 	),
542 
543 	TP_printk("ata_port=%u deadline=%lu classes=[%s,%s]",
544 		  __entry->ata_port, __entry->deadline,
545 		  show_class_name(__entry->class[0]),
546 		  show_class_name(__entry->class[1]))
547 );
548 
549 DEFINE_EVENT(ata_link_reset_begin_template, ata_link_hardreset_begin,
550 	     TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline),
551 	     TP_ARGS(link, class, deadline));
552 
553 DEFINE_EVENT(ata_link_reset_begin_template, ata_slave_hardreset_begin,
554 	     TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline),
555 	     TP_ARGS(link, class, deadline));
556 
557 DEFINE_EVENT(ata_link_reset_begin_template, ata_link_softreset_begin,
558 	     TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline),
559 	     TP_ARGS(link, class, deadline));
560 
561 DECLARE_EVENT_CLASS(ata_link_reset_end_template,
562 
563 	TP_PROTO(struct ata_link *link, unsigned int *class, int rc),
564 
565 	TP_ARGS(link, class, rc),
566 
567 	TP_STRUCT__entry(
568 		__field( unsigned int,	ata_port )
569 		__array( unsigned int,	class, 2 )
570 		__field( int,		rc	)
571 	),
572 
573 	TP_fast_assign(
574 		__entry->ata_port	= link->ap->print_id;
575 		memcpy(__entry->class, class, 2);
576 		__entry->rc		= rc;
577 	),
578 
579 	TP_printk("ata_port=%u rc=%d class=[%s,%s]",
580 		  __entry->ata_port, __entry->rc,
581 		  show_class_name(__entry->class[0]),
582 		  show_class_name(__entry->class[1]))
583 );
584 
585 DEFINE_EVENT(ata_link_reset_end_template, ata_link_hardreset_end,
586 	     TP_PROTO(struct ata_link *link, unsigned int *class, int rc),
587 	     TP_ARGS(link, class, rc));
588 
589 DEFINE_EVENT(ata_link_reset_end_template, ata_slave_hardreset_end,
590 	     TP_PROTO(struct ata_link *link, unsigned int *class, int rc),
591 	     TP_ARGS(link, class, rc));
592 
593 DEFINE_EVENT(ata_link_reset_end_template, ata_link_softreset_end,
594 	     TP_PROTO(struct ata_link *link, unsigned int *class, int rc),
595 	     TP_ARGS(link, class, rc));
596 
597 DEFINE_EVENT(ata_link_reset_end_template, ata_link_postreset,
598 	     TP_PROTO(struct ata_link *link, unsigned int *class, int rc),
599 	     TP_ARGS(link, class, rc));
600 
601 DEFINE_EVENT(ata_link_reset_end_template, ata_slave_postreset,
602 	     TP_PROTO(struct ata_link *link, unsigned int *class, int rc),
603 	     TP_ARGS(link, class, rc));
604 
605 DECLARE_EVENT_CLASS(ata_port_eh_begin_template,
606 
607 	TP_PROTO(struct ata_port *ap),
608 
609 	TP_ARGS(ap),
610 
611 	TP_STRUCT__entry(
612 		__field( unsigned int,	ata_port )
613 	),
614 
615 	TP_fast_assign(
616 		__entry->ata_port	= ap->print_id;
617 	),
618 
619 	TP_printk("ata_port=%u", __entry->ata_port)
620 );
621 
622 DEFINE_EVENT(ata_port_eh_begin_template, ata_std_sched_eh,
623 	     TP_PROTO(struct ata_port *ap),
624 	     TP_ARGS(ap));
625 
626 DEFINE_EVENT(ata_port_eh_begin_template, ata_port_freeze,
627 	     TP_PROTO(struct ata_port *ap),
628 	     TP_ARGS(ap));
629 
630 DEFINE_EVENT(ata_port_eh_begin_template, ata_port_thaw,
631 	     TP_PROTO(struct ata_port *ap),
632 	     TP_ARGS(ap));
633 
634 DECLARE_EVENT_CLASS(ata_sff_hsm_template,
635 
636 	TP_PROTO(struct ata_queued_cmd *qc, unsigned char status),
637 
638 	TP_ARGS(qc, status),
639 
640 	TP_STRUCT__entry(
641 		__field( unsigned int,	ata_port )
642 		__field( unsigned int,	ata_dev	)
643 		__field( unsigned int,	tag	)
644 		__field( unsigned int,	qc_flags )
645 		__field( unsigned int,	protocol )
646 		__field( unsigned int,	hsm_state )
647 		__field( unsigned char,	dev_state )
648 	),
649 
650 	TP_fast_assign(
651 		__entry->ata_port	= qc->ap->print_id;
652 		__entry->ata_dev	= qc->dev->link->pmp + qc->dev->devno;
653 		__entry->tag		= qc->tag;
654 		__entry->qc_flags	= qc->flags;
655 		__entry->protocol	= qc->tf.protocol;
656 		__entry->hsm_state	= qc->ap->hsm_task_state;
657 		__entry->dev_state	= status;
658 	),
659 
660 	TP_printk("ata_port=%u ata_dev=%u tag=%d proto=%s flags=%s task_state=%s dev_stat=0x%X",
661 		  __entry->ata_port, __entry->ata_dev, __entry->tag,
662 		  show_protocol_name(__entry->protocol),
663 		  __parse_qc_flags(__entry->qc_flags),
664 		  show_sff_hsm_state_name(__entry->hsm_state),
665 		  __entry->dev_state)
666 );
667 
668 DEFINE_EVENT(ata_sff_hsm_template, ata_sff_hsm_state,
669 	TP_PROTO(struct ata_queued_cmd *qc, unsigned char state),
670 	TP_ARGS(qc, state));
671 
672 DEFINE_EVENT(ata_sff_hsm_template, ata_sff_hsm_command_complete,
673 	TP_PROTO(struct ata_queued_cmd *qc, unsigned char state),
674 	TP_ARGS(qc, state));
675 
676 DEFINE_EVENT(ata_sff_hsm_template, ata_sff_port_intr,
677 	TP_PROTO(struct ata_queued_cmd *qc, unsigned char state),
678 	TP_ARGS(qc, state));
679 
680 DECLARE_EVENT_CLASS(ata_transfer_data_template,
681 
682 	TP_PROTO(struct ata_queued_cmd *qc, unsigned int offset, unsigned int count),
683 
684 	TP_ARGS(qc, offset, count),
685 
686 	TP_STRUCT__entry(
687 		__field( unsigned int,	ata_port )
688 		__field( unsigned int,	ata_dev	)
689 		__field( unsigned int,	tag	)
690 		__field( unsigned int,	flags	)
691 		__field( unsigned int,	offset	)
692 		__field( unsigned int,	bytes	)
693 	),
694 
695 	TP_fast_assign(
696 		__entry->ata_port	= qc->ap->print_id;
697 		__entry->ata_dev	= qc->dev->link->pmp + qc->dev->devno;
698 		__entry->tag		= qc->tag;
699 		__entry->flags		= qc->tf.flags;
700 		__entry->offset		= offset;
701 		__entry->bytes		= count;
702 	),
703 
704 	TP_printk("ata_port=%u ata_dev=%u tag=%d flags=%s offset=%u bytes=%u",
705 		  __entry->ata_port, __entry->ata_dev, __entry->tag,
706 		  __parse_tf_flags(__entry->flags),
707 		  __entry->offset, __entry->bytes)
708 );
709 
710 DEFINE_EVENT(ata_transfer_data_template, ata_sff_pio_transfer_data,
711 	     TP_PROTO(struct ata_queued_cmd *qc, unsigned int offset, unsigned int count),
712 	     TP_ARGS(qc, offset, count));
713 
714 DEFINE_EVENT(ata_transfer_data_template, atapi_pio_transfer_data,
715 	     TP_PROTO(struct ata_queued_cmd *qc, unsigned int offset, unsigned int count),
716 	     TP_ARGS(qc, offset, count));
717 
718 DEFINE_EVENT(ata_transfer_data_template, atapi_send_cdb,
719 	     TP_PROTO(struct ata_queued_cmd *qc, unsigned int offset, unsigned int count),
720 	     TP_ARGS(qc, offset, count));
721 
722 DECLARE_EVENT_CLASS(ata_sff_template,
723 
724 	TP_PROTO(struct ata_port *ap),
725 
726 	TP_ARGS(ap),
727 
728 	TP_STRUCT__entry(
729 		__field( unsigned int,	ata_port )
730 		__field( unsigned char,	hsm_state )
731 	),
732 
733 	TP_fast_assign(
734 		__entry->ata_port	= ap->print_id;
735 		__entry->hsm_state	= ap->hsm_task_state;
736 	),
737 
738 	TP_printk("ata_port=%u task_state=%s",
739 		  __entry->ata_port,
740 		  show_sff_hsm_state_name(__entry->hsm_state))
741 );
742 
743 DEFINE_EVENT(ata_sff_template, ata_sff_flush_pio_task,
744 	     TP_PROTO(struct ata_port *ap),
745 	     TP_ARGS(ap));
746 
747 #endif /*  _TRACE_LIBATA_H */
748 
749 /* This part must be outside protection */
750 #include <trace/define_trace.h>
751