1 // SPDX-License-Identifier: GPL-2.0
3 * NVM Express device driver tracepoints
4 * Copyright (c) 2018 Johannes Thumshirn, SUSE Linux GmbH
7 #include <linux/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_set_features(struct trace_seq
*p
,
78 const char *ret
= trace_seq_buffer_ptr(p
);
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
);
89 static const char *nvme_trace_admin_get_features(struct trace_seq
*p
,
92 const char *ret
= trace_seq_buffer_ptr(p
);
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
);
103 static const char *nvme_trace_get_lba_status(struct trace_seq
*p
,
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);
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);
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);
149 "slba=%llu, len=%u, ctrl=0x%x, dsmgmt=%u, reftag=%u",
150 slba
, length
, control
, dsmgmt
, reftag
);
151 trace_seq_putc(p
, 0);
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);
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
);
184 if (zsa
< ARRAY_SIZE(zsa_strs
) && zsa_strs
[zsa
])
185 zsa_str
= zsa_strs
[zsa
];
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);
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);
213 u8 zrasf
= cdw10
[13];
214 const char *zrasf_str
;
217 if (zrasf
< ARRAY_SIZE(zrasf_strs
) && zrasf_strs
[zrasf
])
218 zrasf_str
= zrasf_strs
[zrasf
];
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);
229 static const char *nvme_trace_resv_reg(struct trace_seq
*p
, u8
*cdw10
)
231 static const char * const rrega_strs
[] = {
233 [0x01] = "unregister",
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
];
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);
254 static const char * const rtype_strs
[] = {
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
[] = {
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;
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);
291 static const char *nvme_trace_resv_rel(struct trace_seq
*p
, u8
*cdw10
)
293 static const char * const rrela_strs
[] = {
297 const char *ret
= trace_seq_buffer_ptr(p
);
298 u8 rrela
= cdw10
[0] & 0x7;
299 u8 iekey
= (cdw10
[0] >> 3) & 0x1;
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);
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);
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);
339 const char *nvme_trace_parse_admin_cmd(struct trace_seq
*p
,
340 u8 opcode
, u8
*cdw10
)
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
);
362 return nvme_trace_common(p
, cdw10
);
366 const char *nvme_trace_parse_nvm_cmd(struct trace_seq
*p
,
367 u8 opcode
, u8
*cdw10
)
372 case nvme_cmd_write_zeroes
:
373 case nvme_cmd_zone_append
:
374 return nvme_trace_read_write(p
, cdw10
);
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
);
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
);
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);
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);
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);
422 static const char *nvme_trace_fabrics_property_get(struct trace_seq
*p
, u8
*spc
)
424 const char *ret
= trace_seq_buffer_ptr(p
);
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);
433 static const char *nvme_trace_fabrics_auth_send(struct trace_seq
*p
, u8
*spc
)
435 const char *ret
= trace_seq_buffer_ptr(p
);
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);
447 static const char *nvme_trace_fabrics_auth_receive(struct trace_seq
*p
, u8
*spc
)
449 const char *ret
= trace_seq_buffer_ptr(p
);
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);
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);
470 const char *nvme_trace_parse_fabrics_cmd(struct trace_seq
*p
,
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
);
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
);
494 trace_seq_printf(p
, "disk=%s, ", name
);
495 trace_seq_putc(p
, 0);
500 EXPORT_TRACEPOINT_SYMBOL_GPL(nvme_sq
);