drm/rockchip: Don't change hdmi reference clock rate
[drm/drm-misc.git] / drivers / nvme / host / trace.c
blobad25ad1e40412cef5525de3f52cc1c1d3793f8f1
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 <linux/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_set_features(struct trace_seq *p,
76 u8 *cdw10)
78 const char *ret = trace_seq_buffer_ptr(p);
79 u8 fid = cdw10[0];
80 u8 sv = cdw10[3] & 0x8;
81 u32 cdw11 = get_unaligned_le32(cdw10 + 4);
83 trace_seq_printf(p, "fid=0x%x, sv=0x%x, cdw11=0x%x", fid, sv, cdw11);
84 trace_seq_putc(p, 0);
86 return ret;
89 static const char *nvme_trace_admin_get_features(struct trace_seq *p,
90 u8 *cdw10)
92 const char *ret = trace_seq_buffer_ptr(p);
93 u8 fid = cdw10[0];
94 u8 sel = cdw10[1] & 0x7;
95 u32 cdw11 = get_unaligned_le32(cdw10 + 4);
97 trace_seq_printf(p, "fid=0x%x, sel=0x%x, cdw11=0x%x", fid, sel, cdw11);
98 trace_seq_putc(p, 0);
100 return ret;
103 static const char *nvme_trace_get_lba_status(struct trace_seq *p,
104 u8 *cdw10)
106 const char *ret = trace_seq_buffer_ptr(p);
107 u64 slba = get_unaligned_le64(cdw10);
108 u32 mndw = get_unaligned_le32(cdw10 + 8);
109 u16 rl = get_unaligned_le16(cdw10 + 12);
110 u8 atype = cdw10[15];
112 trace_seq_printf(p, "slba=0x%llx, mndw=0x%x, rl=0x%x, atype=%u",
113 slba, mndw, rl, atype);
114 trace_seq_putc(p, 0);
116 return ret;
119 static const char *nvme_trace_admin_format_nvm(struct trace_seq *p, u8 *cdw10)
121 const char *ret = trace_seq_buffer_ptr(p);
123 * lbafu(bit 13:12) is already in the upper 4 bits, lbafl: bit 03:00.
125 u8 lbaf = (cdw10[1] & 0x30) | (cdw10[0] & 0xF);
126 u8 mset = (cdw10[0] >> 4) & 0x1;
127 u8 pi = (cdw10[0] >> 5) & 0x7;
128 u8 pil = cdw10[1] & 0x1;
129 u8 ses = (cdw10[1] >> 1) & 0x7;
131 trace_seq_printf(p, "lbaf=%u, mset=%u, pi=%u, pil=%u, ses=%u",
132 lbaf, mset, pi, pil, ses);
134 trace_seq_putc(p, 0);
136 return ret;
139 static const char *nvme_trace_read_write(struct trace_seq *p, u8 *cdw10)
141 const char *ret = trace_seq_buffer_ptr(p);
142 u64 slba = get_unaligned_le64(cdw10);
143 u16 length = get_unaligned_le16(cdw10 + 8);
144 u16 control = get_unaligned_le16(cdw10 + 10);
145 u32 dsmgmt = get_unaligned_le32(cdw10 + 12);
146 u32 reftag = get_unaligned_le32(cdw10 + 16);
148 trace_seq_printf(p,
149 "slba=%llu, len=%u, ctrl=0x%x, dsmgmt=%u, reftag=%u",
150 slba, length, control, dsmgmt, reftag);
151 trace_seq_putc(p, 0);
153 return ret;
156 static const char *nvme_trace_dsm(struct trace_seq *p, u8 *cdw10)
158 const char *ret = trace_seq_buffer_ptr(p);
160 trace_seq_printf(p, "nr=%u, attributes=%u",
161 get_unaligned_le32(cdw10),
162 get_unaligned_le32(cdw10 + 4));
163 trace_seq_putc(p, 0);
165 return ret;
168 static const char *nvme_trace_zone_mgmt_send(struct trace_seq *p, u8 *cdw10)
170 static const char * const zsa_strs[] = {
171 [0x01] = "close zone",
172 [0x02] = "finish zone",
173 [0x03] = "open zone",
174 [0x04] = "reset zone",
175 [0x05] = "offline zone",
176 [0x10] = "set zone descriptor extension"
178 const char *ret = trace_seq_buffer_ptr(p);
179 u64 slba = get_unaligned_le64(cdw10);
180 const char *zsa_str;
181 u8 zsa = cdw10[12];
182 u8 all = cdw10[13];
184 if (zsa < ARRAY_SIZE(zsa_strs) && zsa_strs[zsa])
185 zsa_str = zsa_strs[zsa];
186 else
187 zsa_str = "reserved";
189 trace_seq_printf(p, "slba=%llu, zsa=%u:%s, all=%u",
190 slba, zsa, zsa_str, all);
191 trace_seq_putc(p, 0);
193 return ret;
196 static const char *nvme_trace_zone_mgmt_recv(struct trace_seq *p, u8 *cdw10)
198 static const char * const zrasf_strs[] = {
199 [0x00] = "list all zones",
200 [0x01] = "list the zones in the ZSE: Empty state",
201 [0x02] = "list the zones in the ZSIO: Implicitly Opened state",
202 [0x03] = "list the zones in the ZSEO: Explicitly Opened state",
203 [0x04] = "list the zones in the ZSC: Closed state",
204 [0x05] = "list the zones in the ZSF: Full state",
205 [0x06] = "list the zones in the ZSRO: Read Only state",
206 [0x07] = "list the zones in the ZSO: Offline state",
207 [0x09] = "list the zones that have the zone attribute"
209 const char *ret = trace_seq_buffer_ptr(p);
210 u64 slba = get_unaligned_le64(cdw10);
211 u32 numd = get_unaligned_le32(cdw10 + 8);
212 u8 zra = cdw10[12];
213 u8 zrasf = cdw10[13];
214 const char *zrasf_str;
215 u8 pr = cdw10[14];
217 if (zrasf < ARRAY_SIZE(zrasf_strs) && zrasf_strs[zrasf])
218 zrasf_str = zrasf_strs[zrasf];
219 else
220 zrasf_str = "reserved";
222 trace_seq_printf(p, "slba=%llu, numd=%u, zra=%u, zrasf=%u:%s, pr=%u",
223 slba, numd, zra, zrasf, zrasf_str, pr);
224 trace_seq_putc(p, 0);
226 return ret;
229 static const char *nvme_trace_resv_reg(struct trace_seq *p, u8 *cdw10)
231 static const char * const rrega_strs[] = {
232 [0x00] = "register",
233 [0x01] = "unregister",
234 [0x02] = "replace",
236 const char *ret = trace_seq_buffer_ptr(p);
237 u8 rrega = cdw10[0] & 0x7;
238 u8 iekey = (cdw10[0] >> 3) & 0x1;
239 u8 ptpl = (cdw10[3] >> 6) & 0x3;
240 const char *rrega_str;
242 if (rrega < ARRAY_SIZE(rrega_strs) && rrega_strs[rrega])
243 rrega_str = rrega_strs[rrega];
244 else
245 rrega_str = "reserved";
247 trace_seq_printf(p, "rrega=%u:%s, iekey=%u, ptpl=%u",
248 rrega, rrega_str, iekey, ptpl);
249 trace_seq_putc(p, 0);
251 return ret;
254 static const char * const rtype_strs[] = {
255 [0x00] = "reserved",
256 [0x01] = "write exclusive",
257 [0x02] = "exclusive access",
258 [0x03] = "write exclusive registrants only",
259 [0x04] = "exclusive access registrants only",
260 [0x05] = "write exclusive all registrants",
261 [0x06] = "exclusive access all registrants",
264 static const char *nvme_trace_resv_acq(struct trace_seq *p, u8 *cdw10)
266 static const char * const racqa_strs[] = {
267 [0x00] = "acquire",
268 [0x01] = "preempt",
269 [0x02] = "preempt and abort",
271 const char *ret = trace_seq_buffer_ptr(p);
272 u8 racqa = cdw10[0] & 0x7;
273 u8 iekey = (cdw10[0] >> 3) & 0x1;
274 u8 rtype = cdw10[1];
275 const char *racqa_str = "reserved";
276 const char *rtype_str = "reserved";
278 if (racqa < ARRAY_SIZE(racqa_strs) && racqa_strs[racqa])
279 racqa_str = racqa_strs[racqa];
281 if (rtype < ARRAY_SIZE(rtype_strs) && rtype_strs[rtype])
282 rtype_str = rtype_strs[rtype];
284 trace_seq_printf(p, "racqa=%u:%s, iekey=%u, rtype=%u:%s",
285 racqa, racqa_str, iekey, rtype, rtype_str);
286 trace_seq_putc(p, 0);
288 return ret;
291 static const char *nvme_trace_resv_rel(struct trace_seq *p, u8 *cdw10)
293 static const char * const rrela_strs[] = {
294 [0x00] = "release",
295 [0x01] = "clear",
297 const char *ret = trace_seq_buffer_ptr(p);
298 u8 rrela = cdw10[0] & 0x7;
299 u8 iekey = (cdw10[0] >> 3) & 0x1;
300 u8 rtype = cdw10[1];
301 const char *rrela_str = "reserved";
302 const char *rtype_str = "reserved";
304 if (rrela < ARRAY_SIZE(rrela_strs) && rrela_strs[rrela])
305 rrela_str = rrela_strs[rrela];
307 if (rtype < ARRAY_SIZE(rtype_strs) && rtype_strs[rtype])
308 rtype_str = rtype_strs[rtype];
310 trace_seq_printf(p, "rrela=%u:%s, iekey=%u, rtype=%u:%s",
311 rrela, rrela_str, iekey, rtype, rtype_str);
312 trace_seq_putc(p, 0);
314 return ret;
317 static const char *nvme_trace_resv_report(struct trace_seq *p, u8 *cdw10)
319 const char *ret = trace_seq_buffer_ptr(p);
320 u32 numd = get_unaligned_le32(cdw10);
321 u8 eds = cdw10[4] & 0x1;
323 trace_seq_printf(p, "numd=%u, eds=%u", numd, eds);
324 trace_seq_putc(p, 0);
326 return ret;
329 static const char *nvme_trace_common(struct trace_seq *p, u8 *cdw10)
331 const char *ret = trace_seq_buffer_ptr(p);
333 trace_seq_printf(p, "cdw10=%*ph", 24, cdw10);
334 trace_seq_putc(p, 0);
336 return ret;
339 const char *nvme_trace_parse_admin_cmd(struct trace_seq *p,
340 u8 opcode, u8 *cdw10)
342 switch (opcode) {
343 case nvme_admin_delete_sq:
344 return nvme_trace_delete_sq(p, cdw10);
345 case nvme_admin_create_sq:
346 return nvme_trace_create_sq(p, cdw10);
347 case nvme_admin_delete_cq:
348 return nvme_trace_delete_cq(p, cdw10);
349 case nvme_admin_create_cq:
350 return nvme_trace_create_cq(p, cdw10);
351 case nvme_admin_identify:
352 return nvme_trace_admin_identify(p, cdw10);
353 case nvme_admin_set_features:
354 return nvme_trace_admin_set_features(p, cdw10);
355 case nvme_admin_get_features:
356 return nvme_trace_admin_get_features(p, cdw10);
357 case nvme_admin_get_lba_status:
358 return nvme_trace_get_lba_status(p, cdw10);
359 case nvme_admin_format_nvm:
360 return nvme_trace_admin_format_nvm(p, cdw10);
361 default:
362 return nvme_trace_common(p, cdw10);
366 const char *nvme_trace_parse_nvm_cmd(struct trace_seq *p,
367 u8 opcode, u8 *cdw10)
369 switch (opcode) {
370 case nvme_cmd_read:
371 case nvme_cmd_write:
372 case nvme_cmd_write_zeroes:
373 case nvme_cmd_zone_append:
374 return nvme_trace_read_write(p, cdw10);
375 case nvme_cmd_dsm:
376 return nvme_trace_dsm(p, cdw10);
377 case nvme_cmd_zone_mgmt_send:
378 return nvme_trace_zone_mgmt_send(p, cdw10);
379 case nvme_cmd_zone_mgmt_recv:
380 return nvme_trace_zone_mgmt_recv(p, cdw10);
381 case nvme_cmd_resv_register:
382 return nvme_trace_resv_reg(p, cdw10);
383 case nvme_cmd_resv_acquire:
384 return nvme_trace_resv_acq(p, cdw10);
385 case nvme_cmd_resv_release:
386 return nvme_trace_resv_rel(p, cdw10);
387 case nvme_cmd_resv_report:
388 return nvme_trace_resv_report(p, cdw10);
389 default:
390 return nvme_trace_common(p, cdw10);
394 static const char *nvme_trace_fabrics_property_set(struct trace_seq *p, u8 *spc)
396 const char *ret = trace_seq_buffer_ptr(p);
397 u8 attrib = spc[0];
398 u32 ofst = get_unaligned_le32(spc + 4);
399 u64 value = get_unaligned_le64(spc + 8);
401 trace_seq_printf(p, "attrib=%u, ofst=0x%x, value=0x%llx",
402 attrib, ofst, value);
403 trace_seq_putc(p, 0);
404 return ret;
407 static const char *nvme_trace_fabrics_connect(struct trace_seq *p, u8 *spc)
409 const char *ret = trace_seq_buffer_ptr(p);
410 u16 recfmt = get_unaligned_le16(spc);
411 u16 qid = get_unaligned_le16(spc + 2);
412 u16 sqsize = get_unaligned_le16(spc + 4);
413 u8 cattr = spc[6];
414 u32 kato = get_unaligned_le32(spc + 8);
416 trace_seq_printf(p, "recfmt=%u, qid=%u, sqsize=%u, cattr=%u, kato=%u",
417 recfmt, qid, sqsize, cattr, kato);
418 trace_seq_putc(p, 0);
419 return ret;
422 static const char *nvme_trace_fabrics_property_get(struct trace_seq *p, u8 *spc)
424 const char *ret = trace_seq_buffer_ptr(p);
425 u8 attrib = spc[0];
426 u32 ofst = get_unaligned_le32(spc + 4);
428 trace_seq_printf(p, "attrib=%u, ofst=0x%x", attrib, ofst);
429 trace_seq_putc(p, 0);
430 return ret;
433 static const char *nvme_trace_fabrics_auth_send(struct trace_seq *p, u8 *spc)
435 const char *ret = trace_seq_buffer_ptr(p);
436 u8 spsp0 = spc[1];
437 u8 spsp1 = spc[2];
438 u8 secp = spc[3];
439 u32 tl = get_unaligned_le32(spc + 4);
441 trace_seq_printf(p, "spsp0=%02x, spsp1=%02x, secp=%02x, tl=%u",
442 spsp0, spsp1, secp, tl);
443 trace_seq_putc(p, 0);
444 return ret;
447 static const char *nvme_trace_fabrics_auth_receive(struct trace_seq *p, u8 *spc)
449 const char *ret = trace_seq_buffer_ptr(p);
450 u8 spsp0 = spc[1];
451 u8 spsp1 = spc[2];
452 u8 secp = spc[3];
453 u32 al = get_unaligned_le32(spc + 4);
455 trace_seq_printf(p, "spsp0=%02x, spsp1=%02x, secp=%02x, al=%u",
456 spsp0, spsp1, secp, al);
457 trace_seq_putc(p, 0);
458 return ret;
461 static const char *nvme_trace_fabrics_common(struct trace_seq *p, u8 *spc)
463 const char *ret = trace_seq_buffer_ptr(p);
465 trace_seq_printf(p, "specific=%*ph", 24, spc);
466 trace_seq_putc(p, 0);
467 return ret;
470 const char *nvme_trace_parse_fabrics_cmd(struct trace_seq *p,
471 u8 fctype, u8 *spc)
473 switch (fctype) {
474 case nvme_fabrics_type_property_set:
475 return nvme_trace_fabrics_property_set(p, spc);
476 case nvme_fabrics_type_connect:
477 return nvme_trace_fabrics_connect(p, spc);
478 case nvme_fabrics_type_property_get:
479 return nvme_trace_fabrics_property_get(p, spc);
480 case nvme_fabrics_type_auth_send:
481 return nvme_trace_fabrics_auth_send(p, spc);
482 case nvme_fabrics_type_auth_receive:
483 return nvme_trace_fabrics_auth_receive(p, spc);
484 default:
485 return nvme_trace_fabrics_common(p, spc);
489 const char *nvme_trace_disk_name(struct trace_seq *p, char *name)
491 const char *ret = trace_seq_buffer_ptr(p);
493 if (*name)
494 trace_seq_printf(p, "disk=%s, ", name);
495 trace_seq_putc(p, 0);
497 return ret;
500 EXPORT_TRACEPOINT_SYMBOL_GPL(nvme_sq);