1 /* SPDX-License-Identifier: GPL-2.0 */
3 * NVM Express device driver tracepoints
4 * Copyright (c) 2018 Johannes Thumshirn, SUSE Linux GmbH
8 #define TRACE_SYSTEM nvme
10 #if !defined(_TRACE_NVME_H) || defined(TRACE_HEADER_MULTI_READ)
13 #include <linux/nvme.h>
14 #include <linux/tracepoint.h>
15 #include <linux/trace_seq.h>
19 const char *nvme_trace_parse_admin_cmd(struct trace_seq *p, u8 opcode,
21 const char *nvme_trace_parse_nvm_cmd(struct trace_seq *p, u8 opcode,
24 #define parse_nvme_cmd(qid, opcode, cdw10) \
26 nvme_trace_parse_nvm_cmd(p, opcode, cdw10) : \
27 nvme_trace_parse_admin_cmd(p, opcode, cdw10))
29 const char *nvme_trace_disk_name(struct trace_seq *p, char *name);
30 #define __print_disk_name(name) \
31 nvme_trace_disk_name(p, name)
33 #ifndef TRACE_HEADER_MULTI_READ
34 static inline void __assign_disk_name(char *name, struct gendisk *disk)
37 memcpy(name, disk->disk_name, DISK_NAME_LEN);
39 memset(name, 0, DISK_NAME_LEN);
43 TRACE_EVENT(nvme_setup_cmd,
44 TP_PROTO(struct request *req, struct nvme_command *cmd),
47 __array(char, disk, DISK_NAME_LEN)
54 __field(u64, metadata)
55 __array(u8, cdw10, 24)
58 __entry->ctrl_id = nvme_req(req)->ctrl->instance;
59 __entry->qid = nvme_req_qid(req);
60 __entry->opcode = cmd->common.opcode;
61 __entry->flags = cmd->common.flags;
62 __entry->cid = cmd->common.command_id;
63 __entry->nsid = le32_to_cpu(cmd->common.nsid);
64 __entry->metadata = le64_to_cpu(cmd->common.metadata);
65 __assign_disk_name(__entry->disk, req->rq_disk);
66 memcpy(__entry->cdw10, &cmd->common.cdw10,
67 sizeof(__entry->cdw10));
69 TP_printk("nvme%d: %sqid=%d, cmdid=%u, nsid=%u, flags=0x%x, meta=0x%llx, cmd=(%s %s)",
70 __entry->ctrl_id, __print_disk_name(__entry->disk),
71 __entry->qid, __entry->cid, __entry->nsid,
72 __entry->flags, __entry->metadata,
73 show_opcode_name(__entry->qid, __entry->opcode),
74 parse_nvme_cmd(__entry->qid, __entry->opcode, __entry->cdw10))
77 TRACE_EVENT(nvme_complete_rq,
78 TP_PROTO(struct request *req),
81 __array(char, disk, DISK_NAME_LEN)
91 __entry->ctrl_id = nvme_req(req)->ctrl->instance;
92 __entry->qid = nvme_req_qid(req);
93 __entry->cid = req->tag;
94 __entry->result = le64_to_cpu(nvme_req(req)->result.u64);
95 __entry->retries = nvme_req(req)->retries;
96 __entry->flags = nvme_req(req)->flags;
97 __entry->status = nvme_req(req)->status;
98 __assign_disk_name(__entry->disk, req->rq_disk);
100 TP_printk("nvme%d: %sqid=%d, cmdid=%u, res=%llu, retries=%u, flags=0x%x, status=%u",
101 __entry->ctrl_id, __print_disk_name(__entry->disk),
102 __entry->qid, __entry->cid, __entry->result,
103 __entry->retries, __entry->flags, __entry->status)
107 #define aer_name(aer) { aer, #aer }
109 TRACE_EVENT(nvme_async_event,
110 TP_PROTO(struct nvme_ctrl *ctrl, u32 result),
111 TP_ARGS(ctrl, result),
113 __field(int, ctrl_id)
117 __entry->ctrl_id = ctrl->instance;
118 __entry->result = result;
120 TP_printk("nvme%d: NVME_AEN=%#08x [%s]",
121 __entry->ctrl_id, __entry->result,
122 __print_symbolic(__entry->result,
123 aer_name(NVME_AER_NOTICE_NS_CHANGED),
124 aer_name(NVME_AER_NOTICE_ANA),
125 aer_name(NVME_AER_NOTICE_FW_ACT_STARTING),
126 aer_name(NVME_AER_NOTICE_DISC_CHANGED),
127 aer_name(NVME_AER_ERROR),
128 aer_name(NVME_AER_SMART),
129 aer_name(NVME_AER_CSS),
130 aer_name(NVME_AER_VS))
137 TP_PROTO(struct request *req, __le16 sq_head, int sq_tail),
138 TP_ARGS(req, sq_head, sq_tail),
140 __field(int, ctrl_id)
141 __array(char, disk, DISK_NAME_LEN)
143 __field(u16, sq_head)
144 __field(u16, sq_tail)
147 __entry->ctrl_id = nvme_req(req)->ctrl->instance;
148 __assign_disk_name(__entry->disk, req->rq_disk);
149 __entry->qid = nvme_req_qid(req);
150 __entry->sq_head = le16_to_cpu(sq_head);
151 __entry->sq_tail = sq_tail;
153 TP_printk("nvme%d: %sqid=%d, head=%u, tail=%u",
154 __entry->ctrl_id, __print_disk_name(__entry->disk),
155 __entry->qid, __entry->sq_head, __entry->sq_tail
159 #endif /* _TRACE_NVME_H */
161 #undef TRACE_INCLUDE_PATH
162 #define TRACE_INCLUDE_PATH .
163 #undef TRACE_INCLUDE_FILE
164 #define TRACE_INCLUDE_FILE trace
166 /* This part must be outside protection */
167 #include <trace/define_trace.h>