blob: f8c550df061564a72e54ad610ca5d1a02078efbc [file] [log] [blame]
Hannes Reinecke255c03d2015-03-27 16:46:38 +01001/*
2 * libata-trace.c - trace functions for libata
3 *
4 * Copyright 2015 Hannes Reinecke
5 * Copyright 2015 SUSE Linux GmbH
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; see the file COPYING. If not, write to
19 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#include <linux/kernel.h>
23#include <linux/trace_seq.h>
24#include <trace/events/libata.h>
25
26const char *
27libata_trace_parse_status(struct trace_seq *p, unsigned char status)
28{
29 const char *ret = trace_seq_buffer_ptr(p);
30
31 trace_seq_printf(p, "{ ");
32 if (status & ATA_BUSY)
33 trace_seq_printf(p, "BUSY ");
34 if (status & ATA_DRDY)
35 trace_seq_printf(p, "DRDY ");
36 if (status & ATA_DF)
37 trace_seq_printf(p, "DF ");
38 if (status & ATA_DSC)
39 trace_seq_printf(p, "DSC ");
40 if (status & ATA_DRQ)
41 trace_seq_printf(p, "DRQ ");
42 if (status & ATA_CORR)
43 trace_seq_printf(p, "CORR ");
44 if (status & ATA_SENSE)
45 trace_seq_printf(p, "SENSE ");
46 if (status & ATA_ERR)
47 trace_seq_printf(p, "ERR ");
48 trace_seq_putc(p, '}');
49 trace_seq_putc(p, 0);
50
51 return ret;
52}
53
54const char *
55libata_trace_parse_eh_action(struct trace_seq *p, unsigned int eh_action)
56{
57 const char *ret = trace_seq_buffer_ptr(p);
58
59 trace_seq_printf(p, "%x", eh_action);
60 if (eh_action) {
61 trace_seq_printf(p, "{ ");
62 if (eh_action & ATA_EH_REVALIDATE)
63 trace_seq_printf(p, "REVALIDATE ");
64 if (eh_action & (ATA_EH_SOFTRESET | ATA_EH_HARDRESET))
65 trace_seq_printf(p, "RESET ");
66 else if (eh_action & ATA_EH_SOFTRESET)
67 trace_seq_printf(p, "SOFTRESET ");
68 else if (eh_action & ATA_EH_HARDRESET)
69 trace_seq_printf(p, "HARDRESET ");
70 if (eh_action & ATA_EH_ENABLE_LINK)
71 trace_seq_printf(p, "ENABLE_LINK ");
72 if (eh_action & ATA_EH_PARK)
73 trace_seq_printf(p, "PARK ");
74 trace_seq_putc(p, '}');
75 }
76 trace_seq_putc(p, 0);
77
78 return ret;
79}
80
81const char *
82libata_trace_parse_eh_err_mask(struct trace_seq *p, unsigned int eh_err_mask)
83{
84 const char *ret = trace_seq_buffer_ptr(p);
85
86 trace_seq_printf(p, "%x", eh_err_mask);
87 if (eh_err_mask) {
88 trace_seq_printf(p, "{ ");
89 if (eh_err_mask & AC_ERR_DEV)
90 trace_seq_printf(p, "DEV ");
91 if (eh_err_mask & AC_ERR_HSM)
92 trace_seq_printf(p, "HSM ");
93 if (eh_err_mask & AC_ERR_TIMEOUT)
94 trace_seq_printf(p, "TIMEOUT ");
95 if (eh_err_mask & AC_ERR_MEDIA)
96 trace_seq_printf(p, "MEDIA ");
97 if (eh_err_mask & AC_ERR_ATA_BUS)
98 trace_seq_printf(p, "ATA_BUS ");
99 if (eh_err_mask & AC_ERR_HOST_BUS)
100 trace_seq_printf(p, "HOST_BUS ");
101 if (eh_err_mask & AC_ERR_SYSTEM)
102 trace_seq_printf(p, "SYSTEM ");
103 if (eh_err_mask & AC_ERR_INVALID)
104 trace_seq_printf(p, "INVALID ");
105 if (eh_err_mask & AC_ERR_OTHER)
106 trace_seq_printf(p, "OTHER ");
107 if (eh_err_mask & AC_ERR_NODEV_HINT)
108 trace_seq_printf(p, "NODEV_HINT ");
109 if (eh_err_mask & AC_ERR_NCQ)
110 trace_seq_printf(p, "NCQ ");
111 trace_seq_putc(p, '}');
112 }
113 trace_seq_putc(p, 0);
114
115 return ret;
116}
117
118const char *
119libata_trace_parse_qc_flags(struct trace_seq *p, unsigned int qc_flags)
120{
121 const char *ret = trace_seq_buffer_ptr(p);
122
123 trace_seq_printf(p, "%x", qc_flags);
124 if (qc_flags) {
125 trace_seq_printf(p, "{ ");
126 if (qc_flags & ATA_QCFLAG_ACTIVE)
127 trace_seq_printf(p, "ACTIVE ");
128 if (qc_flags & ATA_QCFLAG_DMAMAP)
129 trace_seq_printf(p, "DMAMAP ");
130 if (qc_flags & ATA_QCFLAG_IO)
131 trace_seq_printf(p, "IO ");
132 if (qc_flags & ATA_QCFLAG_RESULT_TF)
133 trace_seq_printf(p, "RESULT_TF ");
134 if (qc_flags & ATA_QCFLAG_CLEAR_EXCL)
135 trace_seq_printf(p, "CLEAR_EXCL ");
136 if (qc_flags & ATA_QCFLAG_QUIET)
137 trace_seq_printf(p, "QUIET ");
138 if (qc_flags & ATA_QCFLAG_RETRY)
139 trace_seq_printf(p, "RETRY ");
140 if (qc_flags & ATA_QCFLAG_FAILED)
141 trace_seq_printf(p, "FAILED ");
142 if (qc_flags & ATA_QCFLAG_SENSE_VALID)
143 trace_seq_printf(p, "SENSE_VALID ");
144 if (qc_flags & ATA_QCFLAG_EH_SCHEDULED)
145 trace_seq_printf(p, "EH_SCHEDULED ");
146 trace_seq_putc(p, '}');
147 }
148 trace_seq_putc(p, 0);
149
150 return ret;
151}
Hannes Reineckea5703842016-04-25 12:45:49 +0200152
153const char *
154libata_trace_parse_subcmd(struct trace_seq *p, unsigned char cmd,
155 unsigned char feature, unsigned char hob_nsect)
156{
157 const char *ret = trace_seq_buffer_ptr(p);
158
159 switch (cmd) {
160 case ATA_CMD_FPDMA_RECV:
161 switch (hob_nsect & 0x5f) {
162 case ATA_SUBCMD_FPDMA_RECV_RD_LOG_DMA_EXT:
163 trace_seq_printf(p, " READ_LOG_DMA_EXT");
164 break;
Hannes Reinecke28a3fc22016-04-25 12:45:52 +0200165 case ATA_SUBCMD_FPDMA_RECV_ZAC_MGMT_IN:
166 trace_seq_printf(p, " ZAC_MGMT_IN");
167 break;
Hannes Reineckea5703842016-04-25 12:45:49 +0200168 }
169 break;
170 case ATA_CMD_FPDMA_SEND:
171 switch (hob_nsect & 0x5f) {
172 case ATA_SUBCMD_FPDMA_SEND_WR_LOG_DMA_EXT:
173 trace_seq_printf(p, " WRITE_LOG_DMA_EXT");
174 break;
175 case ATA_SUBCMD_FPDMA_SEND_DSM:
176 trace_seq_printf(p, " DATASET_MANAGEMENT");
177 break;
178 }
179 break;
180 case ATA_CMD_NCQ_NON_DATA:
181 switch (feature) {
182 case ATA_SUBCMD_NCQ_NON_DATA_ABORT_QUEUE:
183 trace_seq_printf(p, " ABORT_QUEUE");
184 break;
185 case ATA_SUBCMD_NCQ_NON_DATA_SET_FEATURES:
186 trace_seq_printf(p, " SET_FEATURES");
187 break;
188 case ATA_SUBCMD_NCQ_NON_DATA_ZERO_EXT:
189 trace_seq_printf(p, " ZERO_EXT");
190 break;
Hannes Reinecke284b3b72016-04-25 12:45:54 +0200191 case ATA_SUBCMD_NCQ_NON_DATA_ZAC_MGMT_OUT:
192 trace_seq_printf(p, " ZAC_MGMT_OUT");
193 break;
Hannes Reineckea5703842016-04-25 12:45:49 +0200194 }
195 break;
Hannes Reinecke28a3fc22016-04-25 12:45:52 +0200196 case ATA_CMD_ZAC_MGMT_IN:
197 switch (feature) {
198 case ATA_SUBCMD_ZAC_MGMT_IN_REPORT_ZONES:
199 trace_seq_printf(p, " REPORT_ZONES");
200 break;
201 }
202 break;
Hannes Reinecke27708a92016-04-25 12:45:53 +0200203 case ATA_CMD_ZAC_MGMT_OUT:
204 switch (feature) {
205 case ATA_SUBCMD_ZAC_MGMT_OUT_CLOSE_ZONE:
206 trace_seq_printf(p, " CLOSE_ZONE");
207 break;
208 case ATA_SUBCMD_ZAC_MGMT_OUT_FINISH_ZONE:
209 trace_seq_printf(p, " FINISH_ZONE");
210 break;
211 case ATA_SUBCMD_ZAC_MGMT_OUT_OPEN_ZONE:
212 trace_seq_printf(p, " OPEN_ZONE");
213 break;
214 case ATA_SUBCMD_ZAC_MGMT_OUT_RESET_WRITE_POINTER:
215 trace_seq_printf(p, " RESET_WRITE_POINTER");
216 break;
217 }
218 break;
Hannes Reineckea5703842016-04-25 12:45:49 +0200219 }
220 trace_seq_putc(p, 0);
221
222 return ret;
223}