WIP FPC-III support
[linux/fpc-iii.git] / drivers / nvme / host / trace.c
blob5c3cb6928f3cecefc0c3c9380b695ea75611da8e
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * NVM Express device driver tracepoints
4 * Copyright (c) 2018 Johannes Thumshirn, SUSE Linux GmbH
5 */
7 #include <asm/unaligned.h>
8 #include "trace.h"
10 static const char *nvme_trace_delete_sq(struct trace_seq *p, u8 *cdw10)
12 const char *ret = trace_seq_buffer_ptr(p);
13 u16 sqid = get_unaligned_le16(cdw10);
15 trace_seq_printf(p, "sqid=%u", sqid);
16 trace_seq_putc(p, 0);
18 return ret;
21 static const char *nvme_trace_create_sq(struct trace_seq *p, u8 *cdw10)
23 const char *ret = trace_seq_buffer_ptr(p);
24 u16 sqid = get_unaligned_le16(cdw10);
25 u16 qsize = get_unaligned_le16(cdw10 + 2);
26 u16 sq_flags = get_unaligned_le16(cdw10 + 4);
27 u16 cqid = get_unaligned_le16(cdw10 + 6);
30 trace_seq_printf(p, "sqid=%u, qsize=%u, sq_flags=0x%x, cqid=%u",
31 sqid, qsize, sq_flags, cqid);
32 trace_seq_putc(p, 0);
34 return ret;
37 static const char *nvme_trace_delete_cq(struct trace_seq *p, u8 *cdw10)
39 const char *ret = trace_seq_buffer_ptr(p);
40 u16 cqid = get_unaligned_le16(cdw10);
42 trace_seq_printf(p, "cqid=%u", cqid);
43 trace_seq_putc(p, 0);
45 return ret;
48 static const char *nvme_trace_create_cq(struct trace_seq *p, u8 *cdw10)
50 const char *ret = trace_seq_buffer_ptr(p);
51 u16 cqid = get_unaligned_le16(cdw10);
52 u16 qsize = get_unaligned_le16(cdw10 + 2);
53 u16 cq_flags = get_unaligned_le16(cdw10 + 4);
54 u16 irq_vector = get_unaligned_le16(cdw10 + 6);
56 trace_seq_printf(p, "cqid=%u, qsize=%u, cq_flags=0x%x, irq_vector=%u",
57 cqid, qsize, cq_flags, irq_vector);
58 trace_seq_putc(p, 0);
60 return ret;
63 static const char *nvme_trace_admin_identify(struct trace_seq *p, u8 *cdw10)
65 const char *ret = trace_seq_buffer_ptr(p);
66 u8 cns = cdw10[0];
67 u16 ctrlid = get_unaligned_le16(cdw10 + 2);
69 trace_seq_printf(p, "cns=%u, ctrlid=%u", cns, ctrlid);
70 trace_seq_putc(p, 0);
72 return ret;
75 static const char *nvme_trace_admin_get_features(struct trace_seq *p,
76 u8 *cdw10)
78 const char *ret = trace_seq_buffer_ptr(p);
79 u8 fid = cdw10[0];
80 u8 sel = cdw10[1] & 0x7;
81 u32 cdw11 = get_unaligned_le32(cdw10 + 4);
83 trace_seq_printf(p, "fid=0x%x sel=0x%x cdw11=0x%x", fid, sel, cdw11);
84 trace_seq_putc(p, 0);
86 return ret;
89 static const char *nvme_trace_get_lba_status(struct trace_seq *p,
90 u8 *cdw10)
92 const char *ret = trace_seq_buffer_ptr(p);
93 u64 slba = get_unaligned_le64(cdw10);
94 u32 mndw = get_unaligned_le32(cdw10 + 8);
95 u16 rl = get_unaligned_le16(cdw10 + 12);
96 u8 atype = cdw10[15];
98 trace_seq_printf(p, "slba=0x%llx, mndw=0x%x, rl=0x%x, atype=%u",
99 slba, mndw, rl, atype);
100 trace_seq_putc(p, 0);
102 return ret;
105 static const char *nvme_trace_read_write(struct trace_seq *p, u8 *cdw10)
107 const char *ret = trace_seq_buffer_ptr(p);
108 u64 slba = get_unaligned_le64(cdw10);
109 u16 length = get_unaligned_le16(cdw10 + 8);
110 u16 control = get_unaligned_le16(cdw10 + 10);
111 u32 dsmgmt = get_unaligned_le32(cdw10 + 12);
112 u32 reftag = get_unaligned_le32(cdw10 + 16);
114 trace_seq_printf(p,
115 "slba=%llu, len=%u, ctrl=0x%x, dsmgmt=%u, reftag=%u",
116 slba, length, control, dsmgmt, reftag);
117 trace_seq_putc(p, 0);
119 return ret;
122 static const char *nvme_trace_dsm(struct trace_seq *p, u8 *cdw10)
124 const char *ret = trace_seq_buffer_ptr(p);
126 trace_seq_printf(p, "nr=%u, attributes=%u",
127 get_unaligned_le32(cdw10),
128 get_unaligned_le32(cdw10 + 4));
129 trace_seq_putc(p, 0);
131 return ret;
134 static const char *nvme_trace_common(struct trace_seq *p, u8 *cdw10)
136 const char *ret = trace_seq_buffer_ptr(p);
138 trace_seq_printf(p, "cdw10=%*ph", 24, cdw10);
139 trace_seq_putc(p, 0);
141 return ret;
144 const char *nvme_trace_parse_admin_cmd(struct trace_seq *p,
145 u8 opcode, u8 *cdw10)
147 switch (opcode) {
148 case nvme_admin_delete_sq:
149 return nvme_trace_delete_sq(p, cdw10);
150 case nvme_admin_create_sq:
151 return nvme_trace_create_sq(p, cdw10);
152 case nvme_admin_delete_cq:
153 return nvme_trace_delete_cq(p, cdw10);
154 case nvme_admin_create_cq:
155 return nvme_trace_create_cq(p, cdw10);
156 case nvme_admin_identify:
157 return nvme_trace_admin_identify(p, cdw10);
158 case nvme_admin_get_features:
159 return nvme_trace_admin_get_features(p, cdw10);
160 case nvme_admin_get_lba_status:
161 return nvme_trace_get_lba_status(p, cdw10);
162 default:
163 return nvme_trace_common(p, cdw10);
167 const char *nvme_trace_parse_nvm_cmd(struct trace_seq *p,
168 u8 opcode, u8 *cdw10)
170 switch (opcode) {
171 case nvme_cmd_read:
172 case nvme_cmd_write:
173 case nvme_cmd_write_zeroes:
174 return nvme_trace_read_write(p, cdw10);
175 case nvme_cmd_dsm:
176 return nvme_trace_dsm(p, cdw10);
177 default:
178 return nvme_trace_common(p, cdw10);
182 static const char *nvme_trace_fabrics_property_set(struct trace_seq *p, u8 *spc)
184 const char *ret = trace_seq_buffer_ptr(p);
185 u8 attrib = spc[0];
186 u32 ofst = get_unaligned_le32(spc + 4);
187 u64 value = get_unaligned_le64(spc + 8);
189 trace_seq_printf(p, "attrib=%u, ofst=0x%x, value=0x%llx",
190 attrib, ofst, value);
191 trace_seq_putc(p, 0);
192 return ret;
195 static const char *nvme_trace_fabrics_connect(struct trace_seq *p, u8 *spc)
197 const char *ret = trace_seq_buffer_ptr(p);
198 u16 recfmt = get_unaligned_le16(spc);
199 u16 qid = get_unaligned_le16(spc + 2);
200 u16 sqsize = get_unaligned_le16(spc + 4);
201 u8 cattr = spc[6];
202 u32 kato = get_unaligned_le32(spc + 8);
204 trace_seq_printf(p, "recfmt=%u, qid=%u, sqsize=%u, cattr=%u, kato=%u",
205 recfmt, qid, sqsize, cattr, kato);
206 trace_seq_putc(p, 0);
207 return ret;
210 static const char *nvme_trace_fabrics_property_get(struct trace_seq *p, u8 *spc)
212 const char *ret = trace_seq_buffer_ptr(p);
213 u8 attrib = spc[0];
214 u32 ofst = get_unaligned_le32(spc + 4);
216 trace_seq_printf(p, "attrib=%u, ofst=0x%x", attrib, ofst);
217 trace_seq_putc(p, 0);
218 return ret;
221 static const char *nvme_trace_fabrics_common(struct trace_seq *p, u8 *spc)
223 const char *ret = trace_seq_buffer_ptr(p);
225 trace_seq_printf(p, "specific=%*ph", 24, spc);
226 trace_seq_putc(p, 0);
227 return ret;
230 const char *nvme_trace_parse_fabrics_cmd(struct trace_seq *p,
231 u8 fctype, u8 *spc)
233 switch (fctype) {
234 case nvme_fabrics_type_property_set:
235 return nvme_trace_fabrics_property_set(p, spc);
236 case nvme_fabrics_type_connect:
237 return nvme_trace_fabrics_connect(p, spc);
238 case nvme_fabrics_type_property_get:
239 return nvme_trace_fabrics_property_get(p, spc);
240 default:
241 return nvme_trace_fabrics_common(p, spc);
245 const char *nvme_trace_disk_name(struct trace_seq *p, char *name)
247 const char *ret = trace_seq_buffer_ptr(p);
249 if (*name)
250 trace_seq_printf(p, "disk=%s, ", name);
251 trace_seq_putc(p, 0);
253 return ret;
256 EXPORT_TRACEPOINT_SYMBOL_GPL(nvme_sq);