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
16 #define TRACE_SYSTEM nvme
18 #if !defined(_TRACE_NVME_H) || defined(TRACE_HEADER_MULTI_READ)
21 #include <linux/nvme.h>
22 #include <linux/tracepoint.h>
23 #include <linux/trace_seq.h>
27 #define nvme_admin_opcode_name(opcode) { opcode, #opcode }
28 #define show_admin_opcode_name(val) \
29 __print_symbolic(val, \
30 nvme_admin_opcode_name(nvme_admin_delete_sq), \
31 nvme_admin_opcode_name(nvme_admin_create_sq), \
32 nvme_admin_opcode_name(nvme_admin_get_log_page), \
33 nvme_admin_opcode_name(nvme_admin_delete_cq), \
34 nvme_admin_opcode_name(nvme_admin_create_cq), \
35 nvme_admin_opcode_name(nvme_admin_identify), \
36 nvme_admin_opcode_name(nvme_admin_abort_cmd), \
37 nvme_admin_opcode_name(nvme_admin_set_features), \
38 nvme_admin_opcode_name(nvme_admin_get_features), \
39 nvme_admin_opcode_name(nvme_admin_async_event), \
40 nvme_admin_opcode_name(nvme_admin_ns_mgmt), \
41 nvme_admin_opcode_name(nvme_admin_activate_fw), \
42 nvme_admin_opcode_name(nvme_admin_download_fw), \
43 nvme_admin_opcode_name(nvme_admin_ns_attach), \
44 nvme_admin_opcode_name(nvme_admin_keep_alive), \
45 nvme_admin_opcode_name(nvme_admin_directive_send), \
46 nvme_admin_opcode_name(nvme_admin_directive_recv), \
47 nvme_admin_opcode_name(nvme_admin_dbbuf), \
48 nvme_admin_opcode_name(nvme_admin_format_nvm), \
49 nvme_admin_opcode_name(nvme_admin_security_send), \
50 nvme_admin_opcode_name(nvme_admin_security_recv), \
51 nvme_admin_opcode_name(nvme_admin_sanitize_nvm))
53 const char *nvme_trace_parse_admin_cmd(struct trace_seq
*p
, u8 opcode
,
55 #define __parse_nvme_admin_cmd(opcode, cdw10) \
56 nvme_trace_parse_admin_cmd(p, opcode, cdw10)
58 #define nvme_opcode_name(opcode) { opcode, #opcode }
59 #define show_opcode_name(val) \
60 __print_symbolic(val, \
61 nvme_opcode_name(nvme_cmd_flush), \
62 nvme_opcode_name(nvme_cmd_write), \
63 nvme_opcode_name(nvme_cmd_read), \
64 nvme_opcode_name(nvme_cmd_write_uncor), \
65 nvme_opcode_name(nvme_cmd_compare), \
66 nvme_opcode_name(nvme_cmd_write_zeroes), \
67 nvme_opcode_name(nvme_cmd_dsm), \
68 nvme_opcode_name(nvme_cmd_resv_register), \
69 nvme_opcode_name(nvme_cmd_resv_report), \
70 nvme_opcode_name(nvme_cmd_resv_acquire), \
71 nvme_opcode_name(nvme_cmd_resv_release))
73 const char *nvme_trace_parse_nvm_cmd(struct trace_seq
*p
, u8 opcode
,
75 #define __parse_nvme_cmd(opcode, cdw10) \
76 nvme_trace_parse_nvm_cmd(p, opcode, cdw10)
78 TRACE_EVENT(nvme_setup_admin_cmd
,
79 TP_PROTO(struct nvme_command
*cmd
),
85 __field(u64
, metadata
)
86 __array(u8
, cdw10
, 24)
89 __entry
->opcode
= cmd
->common
.opcode
;
90 __entry
->flags
= cmd
->common
.flags
;
91 __entry
->cid
= cmd
->common
.command_id
;
92 __entry
->metadata
= le64_to_cpu(cmd
->common
.metadata
);
93 memcpy(__entry
->cdw10
, cmd
->common
.cdw10
,
94 sizeof(__entry
->cdw10
));
96 TP_printk(" cmdid=%u, flags=0x%x, meta=0x%llx, cmd=(%s %s)",
97 __entry
->cid
, __entry
->flags
, __entry
->metadata
,
98 show_admin_opcode_name(__entry
->opcode
),
99 __parse_nvme_admin_cmd(__entry
->opcode
, __entry
->cdw10
))
103 TRACE_EVENT(nvme_setup_nvm_cmd
,
104 TP_PROTO(int qid
, struct nvme_command
*cmd
),
112 __field(u64
, metadata
)
113 __array(u8
, cdw10
, 24)
117 __entry
->opcode
= cmd
->common
.opcode
;
118 __entry
->flags
= cmd
->common
.flags
;
119 __entry
->cid
= cmd
->common
.command_id
;
120 __entry
->nsid
= le32_to_cpu(cmd
->common
.nsid
);
121 __entry
->metadata
= le64_to_cpu(cmd
->common
.metadata
);
122 memcpy(__entry
->cdw10
, cmd
->common
.cdw10
,
123 sizeof(__entry
->cdw10
));
125 TP_printk("qid=%d, nsid=%u, cmdid=%u, flags=0x%x, meta=0x%llx, cmd=(%s %s)",
126 __entry
->qid
, __entry
->nsid
, __entry
->cid
,
127 __entry
->flags
, __entry
->metadata
,
128 show_opcode_name(__entry
->opcode
),
129 __parse_nvme_cmd(__entry
->opcode
, __entry
->cdw10
))
132 TRACE_EVENT(nvme_complete_rq
,
133 TP_PROTO(struct request
*req
),
144 __entry
->qid
= req
->q
->id
;
145 __entry
->cid
= req
->tag
;
146 __entry
->result
= le64_to_cpu(nvme_req(req
)->result
.u64
);
147 __entry
->retries
= nvme_req(req
)->retries
;
148 __entry
->flags
= nvme_req(req
)->flags
;
149 __entry
->status
= nvme_req(req
)->status
;
151 TP_printk("cmdid=%u, qid=%d, res=%llu, retries=%u, flags=0x%x, status=%u",
152 __entry
->cid
, __entry
->qid
, __entry
->result
,
153 __entry
->retries
, __entry
->flags
, __entry
->status
)
157 #endif /* _TRACE_NVME_H */
159 #undef TRACE_INCLUDE_PATH
160 #define TRACE_INCLUDE_PATH .
161 #undef TRACE_INCLUDE_FILE
162 #define TRACE_INCLUDE_FILE trace
164 /* This part must be outside protection */
165 #include <trace/define_trace.h>