Christoph Hellwig | bc50ad7 | 2019-02-18 09:36:29 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Johannes Thumshirn | 3d030e4 | 2018-01-26 11:21:37 +0100 | [diff] [blame] | 2 | /* |
| 3 | * NVM Express device driver tracepoints |
| 4 | * Copyright (c) 2018 Johannes Thumshirn, SUSE Linux GmbH |
Johannes Thumshirn | 3d030e4 | 2018-01-26 11:21:37 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #undef TRACE_SYSTEM |
| 8 | #define TRACE_SYSTEM nvme |
| 9 | |
| 10 | #if !defined(_TRACE_NVME_H) || defined(TRACE_HEADER_MULTI_READ) |
| 11 | #define _TRACE_NVME_H |
| 12 | |
| 13 | #include <linux/nvme.h> |
| 14 | #include <linux/tracepoint.h> |
| 15 | #include <linux/trace_seq.h> |
| 16 | |
| 17 | #include "nvme.h" |
| 18 | |
Keith Busch | 5d87eb9 | 2018-06-29 16:50:01 -0600 | [diff] [blame] | 19 | const char *nvme_trace_parse_admin_cmd(struct trace_seq *p, u8 opcode, |
| 20 | u8 *cdw10); |
Johannes Thumshirn | 3d030e4 | 2018-01-26 11:21:37 +0100 | [diff] [blame] | 21 | const char *nvme_trace_parse_nvm_cmd(struct trace_seq *p, u8 opcode, |
Keith Busch | 5d87eb9 | 2018-06-29 16:50:01 -0600 | [diff] [blame] | 22 | u8 *cdw10); |
Minwoo Im | ad795e4 | 2019-06-12 21:45:31 +0900 | [diff] [blame] | 23 | const char *nvme_trace_parse_fabrics_cmd(struct trace_seq *p, u8 fctype, |
| 24 | u8 *spc); |
Johannes Thumshirn | 3d030e4 | 2018-01-26 11:21:37 +0100 | [diff] [blame] | 25 | |
Minwoo Im | ad795e4 | 2019-06-12 21:45:31 +0900 | [diff] [blame] | 26 | #define parse_nvme_cmd(qid, opcode, fctype, cdw10) \ |
| 27 | ((opcode) == nvme_fabrics_command ? \ |
| 28 | nvme_trace_parse_fabrics_cmd(p, fctype, cdw10) : \ |
| 29 | ((qid) ? \ |
| 30 | nvme_trace_parse_nvm_cmd(p, opcode, cdw10) : \ |
| 31 | nvme_trace_parse_admin_cmd(p, opcode, cdw10))) |
Keith Busch | 5d87eb9 | 2018-06-29 16:50:01 -0600 | [diff] [blame] | 32 | |
Keith Busch | 6268953 | 2018-06-29 16:50:03 -0600 | [diff] [blame] | 33 | const char *nvme_trace_disk_name(struct trace_seq *p, char *name); |
| 34 | #define __print_disk_name(name) \ |
| 35 | nvme_trace_disk_name(p, name) |
| 36 | |
| 37 | #ifndef TRACE_HEADER_MULTI_READ |
| 38 | static inline void __assign_disk_name(char *name, struct gendisk *disk) |
| 39 | { |
| 40 | if (disk) |
| 41 | memcpy(name, disk->disk_name, DISK_NAME_LEN); |
| 42 | else |
| 43 | memset(name, 0, DISK_NAME_LEN); |
| 44 | } |
| 45 | #endif |
| 46 | |
Keith Busch | 5d87eb9 | 2018-06-29 16:50:01 -0600 | [diff] [blame] | 47 | TRACE_EVENT(nvme_setup_cmd, |
| 48 | TP_PROTO(struct request *req, struct nvme_command *cmd), |
| 49 | TP_ARGS(req, cmd), |
Johannes Thumshirn | 3d030e4 | 2018-01-26 11:21:37 +0100 | [diff] [blame] | 50 | TP_STRUCT__entry( |
Keith Busch | 6268953 | 2018-06-29 16:50:03 -0600 | [diff] [blame] | 51 | __array(char, disk, DISK_NAME_LEN) |
Keith Busch | b80a55e | 2018-07-02 09:15:03 -0600 | [diff] [blame] | 52 | __field(int, ctrl_id) |
Keith Busch | 5d87eb9 | 2018-06-29 16:50:01 -0600 | [diff] [blame] | 53 | __field(int, qid) |
| 54 | __field(u8, opcode) |
| 55 | __field(u8, flags) |
Minwoo Im | ad795e4 | 2019-06-12 21:45:31 +0900 | [diff] [blame] | 56 | __field(u8, fctype) |
Keith Busch | 5d87eb9 | 2018-06-29 16:50:01 -0600 | [diff] [blame] | 57 | __field(u16, cid) |
| 58 | __field(u32, nsid) |
Keith Busch | 234211b | 2021-07-19 09:44:39 -0700 | [diff] [blame] | 59 | __field(bool, metadata) |
Keith Busch | 5d87eb9 | 2018-06-29 16:50:01 -0600 | [diff] [blame] | 60 | __array(u8, cdw10, 24) |
Johannes Thumshirn | 3d030e4 | 2018-01-26 11:21:37 +0100 | [diff] [blame] | 61 | ), |
| 62 | TP_fast_assign( |
Keith Busch | b80a55e | 2018-07-02 09:15:03 -0600 | [diff] [blame] | 63 | __entry->ctrl_id = nvme_req(req)->ctrl->instance; |
Keith Busch | 5d87eb9 | 2018-06-29 16:50:01 -0600 | [diff] [blame] | 64 | __entry->qid = nvme_req_qid(req); |
| 65 | __entry->opcode = cmd->common.opcode; |
| 66 | __entry->flags = cmd->common.flags; |
| 67 | __entry->cid = cmd->common.command_id; |
| 68 | __entry->nsid = le32_to_cpu(cmd->common.nsid); |
Keith Busch | 234211b | 2021-07-19 09:44:39 -0700 | [diff] [blame] | 69 | __entry->metadata = !!blk_integrity_rq(req); |
Minwoo Im | ad795e4 | 2019-06-12 21:45:31 +0900 | [diff] [blame] | 70 | __entry->fctype = cmd->fabrics.fctype; |
Christoph Hellwig | f3fa33a | 2021-11-26 13:18:00 +0100 | [diff] [blame] | 71 | __assign_disk_name(__entry->disk, req->q->disk); |
Chaitanya Kulkarni | b7c8f36 | 2018-12-12 15:11:37 -0800 | [diff] [blame] | 72 | memcpy(__entry->cdw10, &cmd->common.cdw10, |
Keith Busch | 81fe928 | 2019-03-13 18:54:56 +0100 | [diff] [blame] | 73 | sizeof(__entry->cdw10)); |
Johannes Thumshirn | 3d030e4 | 2018-01-26 11:21:37 +0100 | [diff] [blame] | 74 | ), |
Keith Busch | 234211b | 2021-07-19 09:44:39 -0700 | [diff] [blame] | 75 | TP_printk("nvme%d: %sqid=%d, cmdid=%u, nsid=%u, flags=0x%x, meta=0x%x, cmd=(%s %s)", |
Keith Busch | 6268953 | 2018-06-29 16:50:03 -0600 | [diff] [blame] | 76 | __entry->ctrl_id, __print_disk_name(__entry->disk), |
| 77 | __entry->qid, __entry->cid, __entry->nsid, |
| 78 | __entry->flags, __entry->metadata, |
Minwoo Im | ad795e4 | 2019-06-12 21:45:31 +0900 | [diff] [blame] | 79 | show_opcode_name(__entry->qid, __entry->opcode, |
| 80 | __entry->fctype), |
| 81 | parse_nvme_cmd(__entry->qid, __entry->opcode, |
| 82 | __entry->fctype, __entry->cdw10)) |
Johannes Thumshirn | 3d030e4 | 2018-01-26 11:21:37 +0100 | [diff] [blame] | 83 | ); |
| 84 | |
Johannes Thumshirn | ca5554a | 2018-01-26 11:21:38 +0100 | [diff] [blame] | 85 | TRACE_EVENT(nvme_complete_rq, |
| 86 | TP_PROTO(struct request *req), |
| 87 | TP_ARGS(req), |
| 88 | TP_STRUCT__entry( |
Keith Busch | 6268953 | 2018-06-29 16:50:03 -0600 | [diff] [blame] | 89 | __array(char, disk, DISK_NAME_LEN) |
Keith Busch | b80a55e | 2018-07-02 09:15:03 -0600 | [diff] [blame] | 90 | __field(int, ctrl_id) |
Keith Busch | 5d87eb9 | 2018-06-29 16:50:01 -0600 | [diff] [blame] | 91 | __field(int, qid) |
| 92 | __field(int, cid) |
| 93 | __field(u64, result) |
| 94 | __field(u8, retries) |
| 95 | __field(u8, flags) |
| 96 | __field(u16, status) |
Johannes Thumshirn | ca5554a | 2018-01-26 11:21:38 +0100 | [diff] [blame] | 97 | ), |
| 98 | TP_fast_assign( |
Keith Busch | b80a55e | 2018-07-02 09:15:03 -0600 | [diff] [blame] | 99 | __entry->ctrl_id = nvme_req(req)->ctrl->instance; |
Keith Busch | 5d87eb9 | 2018-06-29 16:50:01 -0600 | [diff] [blame] | 100 | __entry->qid = nvme_req_qid(req); |
| 101 | __entry->cid = req->tag; |
| 102 | __entry->result = le64_to_cpu(nvme_req(req)->result.u64); |
| 103 | __entry->retries = nvme_req(req)->retries; |
| 104 | __entry->flags = nvme_req(req)->flags; |
| 105 | __entry->status = nvme_req(req)->status; |
Christoph Hellwig | f3fa33a | 2021-11-26 13:18:00 +0100 | [diff] [blame] | 106 | __assign_disk_name(__entry->disk, req->q->disk); |
Johannes Thumshirn | ca5554a | 2018-01-26 11:21:38 +0100 | [diff] [blame] | 107 | ), |
Minwoo Im | 5f965f4 | 2019-06-12 21:45:32 +0900 | [diff] [blame] | 108 | TP_printk("nvme%d: %sqid=%d, cmdid=%u, res=%#llx, retries=%u, flags=0x%x, status=%#x", |
Keith Busch | 6268953 | 2018-06-29 16:50:03 -0600 | [diff] [blame] | 109 | __entry->ctrl_id, __print_disk_name(__entry->disk), |
| 110 | __entry->qid, __entry->cid, __entry->result, |
| 111 | __entry->retries, __entry->flags, __entry->status) |
Johannes Thumshirn | ca5554a | 2018-01-26 11:21:38 +0100 | [diff] [blame] | 112 | |
| 113 | ); |
| 114 | |
Chaitanya Kulkarni | 09bd1ff | 2018-09-17 10:47:06 -0700 | [diff] [blame] | 115 | #define aer_name(aer) { aer, #aer } |
| 116 | |
| 117 | TRACE_EVENT(nvme_async_event, |
| 118 | TP_PROTO(struct nvme_ctrl *ctrl, u32 result), |
| 119 | TP_ARGS(ctrl, result), |
| 120 | TP_STRUCT__entry( |
| 121 | __field(int, ctrl_id) |
| 122 | __field(u32, result) |
| 123 | ), |
| 124 | TP_fast_assign( |
| 125 | __entry->ctrl_id = ctrl->instance; |
| 126 | __entry->result = result; |
| 127 | ), |
| 128 | TP_printk("nvme%d: NVME_AEN=%#08x [%s]", |
| 129 | __entry->ctrl_id, __entry->result, |
| 130 | __print_symbolic(__entry->result, |
| 131 | aer_name(NVME_AER_NOTICE_NS_CHANGED), |
| 132 | aer_name(NVME_AER_NOTICE_ANA), |
| 133 | aer_name(NVME_AER_NOTICE_FW_ACT_STARTING), |
Chaitanya Kulkarni | 521cfb8 | 2019-05-13 10:46:05 -0700 | [diff] [blame] | 134 | aer_name(NVME_AER_NOTICE_DISC_CHANGED), |
Chaitanya Kulkarni | 09bd1ff | 2018-09-17 10:47:06 -0700 | [diff] [blame] | 135 | aer_name(NVME_AER_ERROR), |
| 136 | aer_name(NVME_AER_SMART), |
| 137 | aer_name(NVME_AER_CSS), |
| 138 | aer_name(NVME_AER_VS)) |
| 139 | ) |
| 140 | ); |
| 141 | |
| 142 | #undef aer_name |
| 143 | |
yupeng | 604c01d | 2018-12-18 17:59:53 +0100 | [diff] [blame] | 144 | TRACE_EVENT(nvme_sq, |
| 145 | TP_PROTO(struct request *req, __le16 sq_head, int sq_tail), |
| 146 | TP_ARGS(req, sq_head, sq_tail), |
| 147 | TP_STRUCT__entry( |
| 148 | __field(int, ctrl_id) |
| 149 | __array(char, disk, DISK_NAME_LEN) |
| 150 | __field(int, qid) |
| 151 | __field(u16, sq_head) |
| 152 | __field(u16, sq_tail) |
| 153 | ), |
| 154 | TP_fast_assign( |
| 155 | __entry->ctrl_id = nvme_req(req)->ctrl->instance; |
Christoph Hellwig | f3fa33a | 2021-11-26 13:18:00 +0100 | [diff] [blame] | 156 | __assign_disk_name(__entry->disk, req->q->disk); |
yupeng | 604c01d | 2018-12-18 17:59:53 +0100 | [diff] [blame] | 157 | __entry->qid = nvme_req_qid(req); |
| 158 | __entry->sq_head = le16_to_cpu(sq_head); |
| 159 | __entry->sq_tail = sq_tail; |
| 160 | ), |
| 161 | TP_printk("nvme%d: %sqid=%d, head=%u, tail=%u", |
| 162 | __entry->ctrl_id, __print_disk_name(__entry->disk), |
| 163 | __entry->qid, __entry->sq_head, __entry->sq_tail |
| 164 | ) |
| 165 | ); |
| 166 | |
Johannes Thumshirn | 3d030e4 | 2018-01-26 11:21:37 +0100 | [diff] [blame] | 167 | #endif /* _TRACE_NVME_H */ |
| 168 | |
| 169 | #undef TRACE_INCLUDE_PATH |
| 170 | #define TRACE_INCLUDE_PATH . |
| 171 | #undef TRACE_INCLUDE_FILE |
| 172 | #define TRACE_INCLUDE_FILE trace |
| 173 | |
| 174 | /* This part must be outside protection */ |
| 175 | #include <trace/define_trace.h> |