Linux 4.19.133
[linux/fpc-iii.git] / drivers / nvme / host / trace.c
blob25b0e310f4a813e87e3a9d4a9eadc0c17e40eb6b
1 /*
2 * NVM Express device driver tracepoints
3 * Copyright (c) 2018 Johannes Thumshirn, SUSE Linux GmbH
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
15 #include <asm/unaligned.h>
16 #include "trace.h"
18 static const char *nvme_trace_create_sq(struct trace_seq *p, u8 *cdw10)
20 const char *ret = trace_seq_buffer_ptr(p);
21 u16 sqid = get_unaligned_le16(cdw10);
22 u16 qsize = get_unaligned_le16(cdw10 + 2);
23 u16 sq_flags = get_unaligned_le16(cdw10 + 4);
24 u16 cqid = get_unaligned_le16(cdw10 + 6);
27 trace_seq_printf(p, "sqid=%u, qsize=%u, sq_flags=0x%x, cqid=%u",
28 sqid, qsize, sq_flags, cqid);
29 trace_seq_putc(p, 0);
31 return ret;
34 static const char *nvme_trace_create_cq(struct trace_seq *p, u8 *cdw10)
36 const char *ret = trace_seq_buffer_ptr(p);
37 u16 cqid = get_unaligned_le16(cdw10);
38 u16 qsize = get_unaligned_le16(cdw10 + 2);
39 u16 cq_flags = get_unaligned_le16(cdw10 + 4);
40 u16 irq_vector = get_unaligned_le16(cdw10 + 6);
42 trace_seq_printf(p, "cqid=%u, qsize=%u, cq_flags=0x%x, irq_vector=%u",
43 cqid, qsize, cq_flags, irq_vector);
44 trace_seq_putc(p, 0);
46 return ret;
49 static const char *nvme_trace_admin_identify(struct trace_seq *p, u8 *cdw10)
51 const char *ret = trace_seq_buffer_ptr(p);
52 u8 cns = cdw10[0];
53 u16 ctrlid = get_unaligned_le16(cdw10 + 2);
55 trace_seq_printf(p, "cns=%u, ctrlid=%u", cns, ctrlid);
56 trace_seq_putc(p, 0);
58 return ret;
63 static const char *nvme_trace_read_write(struct trace_seq *p, u8 *cdw10)
65 const char *ret = trace_seq_buffer_ptr(p);
66 u64 slba = get_unaligned_le64(cdw10);
67 u16 length = get_unaligned_le16(cdw10 + 8);
68 u16 control = get_unaligned_le16(cdw10 + 10);
69 u32 dsmgmt = get_unaligned_le32(cdw10 + 12);
70 u32 reftag = get_unaligned_le32(cdw10 + 16);
72 trace_seq_printf(p,
73 "slba=%llu, len=%u, ctrl=0x%x, dsmgmt=%u, reftag=%u",
74 slba, length, control, dsmgmt, reftag);
75 trace_seq_putc(p, 0);
77 return ret;
80 static const char *nvme_trace_dsm(struct trace_seq *p, u8 *cdw10)
82 const char *ret = trace_seq_buffer_ptr(p);
84 trace_seq_printf(p, "nr=%u, attributes=%u",
85 get_unaligned_le32(cdw10),
86 get_unaligned_le32(cdw10 + 4));
87 trace_seq_putc(p, 0);
89 return ret;
92 static const char *nvme_trace_common(struct trace_seq *p, u8 *cdw10)
94 const char *ret = trace_seq_buffer_ptr(p);
96 trace_seq_printf(p, "cdw10=%*ph", 24, cdw10);
97 trace_seq_putc(p, 0);
99 return ret;
102 const char *nvme_trace_parse_admin_cmd(struct trace_seq *p,
103 u8 opcode, u8 *cdw10)
105 switch (opcode) {
106 case nvme_admin_create_sq:
107 return nvme_trace_create_sq(p, cdw10);
108 case nvme_admin_create_cq:
109 return nvme_trace_create_cq(p, cdw10);
110 case nvme_admin_identify:
111 return nvme_trace_admin_identify(p, cdw10);
112 default:
113 return nvme_trace_common(p, cdw10);
117 const char *nvme_trace_parse_nvm_cmd(struct trace_seq *p,
118 u8 opcode, u8 *cdw10)
120 switch (opcode) {
121 case nvme_cmd_read:
122 case nvme_cmd_write:
123 case nvme_cmd_write_zeroes:
124 return nvme_trace_read_write(p, cdw10);
125 case nvme_cmd_dsm:
126 return nvme_trace_dsm(p, cdw10);
127 default:
128 return nvme_trace_common(p, cdw10);
132 const char *nvme_trace_disk_name(struct trace_seq *p, char *name)
134 const char *ret = trace_seq_buffer_ptr(p);
136 if (*name)
137 trace_seq_printf(p, "disk=%s, ", name);
138 trace_seq_putc(p, 0);
140 return ret;