1 // SPDX-License-Identifier: GPL-2.0
3 * NVM Express device driver tracepoints
4 * Copyright (c) 2018 Johannes Thumshirn, SUSE Linux GmbH
7 #include <asm/unaligned.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
);
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
);
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
);
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
);
63 static const char *nvme_trace_admin_identify(struct trace_seq
*p
, u8
*cdw10
)
65 const char *ret
= trace_seq_buffer_ptr(p
);
67 u16 ctrlid
= get_unaligned_le16(cdw10
+ 2);
69 trace_seq_printf(p
, "cns=%u, ctrlid=%u", cns
, ctrlid
);
75 static const char *nvme_trace_admin_get_features(struct trace_seq
*p
,
78 const char *ret
= trace_seq_buffer_ptr(p
);
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
);
89 static const char *nvme_trace_get_lba_status(struct trace_seq
*p
,
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);
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);
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);
115 "slba=%llu, len=%u, ctrl=0x%x, dsmgmt=%u, reftag=%u",
116 slba
, length
, control
, dsmgmt
, reftag
);
117 trace_seq_putc(p
, 0);
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);
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);
144 const char *nvme_trace_parse_admin_cmd(struct trace_seq
*p
,
145 u8 opcode
, u8
*cdw10
)
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
);
163 return nvme_trace_common(p
, cdw10
);
167 const char *nvme_trace_parse_nvm_cmd(struct trace_seq
*p
,
168 u8 opcode
, u8
*cdw10
)
173 case nvme_cmd_write_zeroes
:
174 return nvme_trace_read_write(p
, cdw10
);
176 return nvme_trace_dsm(p
, cdw10
);
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
);
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);
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);
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);
210 static const char *nvme_trace_fabrics_property_get(struct trace_seq
*p
, u8
*spc
)
212 const char *ret
= trace_seq_buffer_ptr(p
);
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);
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);
230 const char *nvme_trace_parse_fabrics_cmd(struct trace_seq
*p
,
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
);
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
);
250 trace_seq_printf(p
, "disk=%s, ", name
);
251 trace_seq_putc(p
, 0);
256 EXPORT_TRACEPOINT_SYMBOL_GPL(nvme_sq
);