2019-06-12 20:45:33 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
/*
|
|
|
|
* NVM Express target device driver tracepoints
|
|
|
|
* Copyright (c) 2018 Johannes Thumshirn, SUSE Linux GmbH
|
|
|
|
*
|
|
|
|
* This is entirely based on drivers/nvme/host/trace.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
#undef TRACE_SYSTEM
|
|
|
|
#define TRACE_SYSTEM nvmet
|
|
|
|
|
|
|
|
#if !defined(_TRACE_NVMET_H) || defined(TRACE_HEADER_MULTI_READ)
|
|
|
|
#define _TRACE_NVMET_H
|
|
|
|
|
|
|
|
#include <linux/nvme.h>
|
|
|
|
#include <linux/tracepoint.h>
|
|
|
|
#include <linux/trace_seq.h>
|
|
|
|
|
|
|
|
#include "nvmet.h"
|
|
|
|
|
|
|
|
const char *nvmet_trace_parse_admin_cmd(struct trace_seq *p, u8 opcode,
|
|
|
|
u8 *cdw10);
|
|
|
|
const char *nvmet_trace_parse_nvm_cmd(struct trace_seq *p, u8 opcode,
|
|
|
|
u8 *cdw10);
|
|
|
|
const char *nvmet_trace_parse_fabrics_cmd(struct trace_seq *p, u8 fctype,
|
|
|
|
u8 *spc);
|
|
|
|
|
|
|
|
#define parse_nvme_cmd(qid, opcode, fctype, cdw10) \
|
|
|
|
((opcode) == nvme_fabrics_command ? \
|
|
|
|
nvmet_trace_parse_fabrics_cmd(p, fctype, cdw10) : \
|
|
|
|
(qid ? \
|
|
|
|
nvmet_trace_parse_nvm_cmd(p, opcode, cdw10) : \
|
|
|
|
nvmet_trace_parse_admin_cmd(p, opcode, cdw10)))
|
|
|
|
|
|
|
|
const char *nvmet_trace_ctrl_name(struct trace_seq *p, struct nvmet_ctrl *ctrl);
|
|
|
|
#define __print_ctrl_name(ctrl) \
|
|
|
|
nvmet_trace_ctrl_name(p, ctrl)
|
|
|
|
|
|
|
|
const char *nvmet_trace_disk_name(struct trace_seq *p, char *name);
|
|
|
|
#define __print_disk_name(name) \
|
|
|
|
nvmet_trace_disk_name(p, name)
|
|
|
|
|
|
|
|
#ifndef TRACE_HEADER_MULTI_READ
|
|
|
|
static inline struct nvmet_ctrl *nvmet_req_to_ctrl(struct nvmet_req *req)
|
|
|
|
{
|
|
|
|
return req->sq->ctrl;
|
|
|
|
}
|
|
|
|
|
2024-06-11 20:26:44 +08:00
|
|
|
static inline void __assign_req_name(char *name, struct nvmet_req *req)
|
2019-06-12 20:45:33 +08:00
|
|
|
{
|
2024-06-11 20:26:44 +08:00
|
|
|
if (req->ns)
|
|
|
|
strncpy(name, req->ns->device_path, DISK_NAME_LEN);
|
|
|
|
else
|
|
|
|
memset(name, 0, DISK_NAME_LEN);
|
2019-06-12 20:45:33 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
TRACE_EVENT(nvmet_req_init,
|
|
|
|
TP_PROTO(struct nvmet_req *req, struct nvme_command *cmd),
|
|
|
|
TP_ARGS(req, cmd),
|
|
|
|
TP_STRUCT__entry(
|
|
|
|
__field(struct nvme_command *, cmd)
|
|
|
|
__field(struct nvmet_ctrl *, ctrl)
|
|
|
|
__array(char, disk, DISK_NAME_LEN)
|
|
|
|
__field(int, qid)
|
|
|
|
__field(u16, cid)
|
|
|
|
__field(u8, opcode)
|
|
|
|
__field(u8, fctype)
|
|
|
|
__field(u8, flags)
|
|
|
|
__field(u32, nsid)
|
|
|
|
__field(u64, metadata)
|
|
|
|
__array(u8, cdw10, 24)
|
|
|
|
),
|
|
|
|
TP_fast_assign(
|
|
|
|
__entry->cmd = cmd;
|
|
|
|
__entry->ctrl = nvmet_req_to_ctrl(req);
|
2024-06-11 20:26:44 +08:00
|
|
|
__assign_req_name(__entry->disk, req);
|
2019-06-12 20:45:33 +08:00
|
|
|
__entry->qid = req->sq->qid;
|
|
|
|
__entry->cid = cmd->common.command_id;
|
|
|
|
__entry->opcode = cmd->common.opcode;
|
|
|
|
__entry->fctype = cmd->fabrics.fctype;
|
|
|
|
__entry->flags = cmd->common.flags;
|
|
|
|
__entry->nsid = le32_to_cpu(cmd->common.nsid);
|
|
|
|
__entry->metadata = le64_to_cpu(cmd->common.metadata);
|
|
|
|
memcpy(__entry->cdw10, &cmd->common.cdw10,
|
|
|
|
sizeof(__entry->cdw10));
|
|
|
|
),
|
|
|
|
TP_printk("nvmet%s: %sqid=%d, cmdid=%u, nsid=%u, flags=%#x, "
|
|
|
|
"meta=%#llx, cmd=(%s, %s)",
|
|
|
|
__print_ctrl_name(__entry->ctrl),
|
|
|
|
__print_disk_name(__entry->disk),
|
|
|
|
__entry->qid, __entry->cid, __entry->nsid,
|
|
|
|
__entry->flags, __entry->metadata,
|
|
|
|
show_opcode_name(__entry->qid, __entry->opcode,
|
|
|
|
__entry->fctype),
|
|
|
|
parse_nvme_cmd(__entry->qid, __entry->opcode,
|
|
|
|
__entry->fctype, __entry->cdw10))
|
|
|
|
);
|
|
|
|
|
|
|
|
TRACE_EVENT(nvmet_req_complete,
|
|
|
|
TP_PROTO(struct nvmet_req *req),
|
|
|
|
TP_ARGS(req),
|
|
|
|
TP_STRUCT__entry(
|
|
|
|
__field(struct nvmet_ctrl *, ctrl)
|
|
|
|
__array(char, disk, DISK_NAME_LEN)
|
|
|
|
__field(int, qid)
|
|
|
|
__field(int, cid)
|
|
|
|
__field(u64, result)
|
|
|
|
__field(u16, status)
|
|
|
|
),
|
|
|
|
TP_fast_assign(
|
|
|
|
__entry->ctrl = nvmet_req_to_ctrl(req);
|
|
|
|
__entry->qid = req->cq->qid;
|
|
|
|
__entry->cid = req->cqe->command_id;
|
|
|
|
__entry->result = le64_to_cpu(req->cqe->result.u64);
|
|
|
|
__entry->status = le16_to_cpu(req->cqe->status) >> 1;
|
2024-06-11 20:26:44 +08:00
|
|
|
__assign_req_name(__entry->disk, req);
|
2019-06-12 20:45:33 +08:00
|
|
|
),
|
|
|
|
TP_printk("nvmet%s: %sqid=%d, cmdid=%u, res=%#llx, status=%#x",
|
|
|
|
__print_ctrl_name(__entry->ctrl),
|
|
|
|
__print_disk_name(__entry->disk),
|
|
|
|
__entry->qid, __entry->cid, __entry->result, __entry->status)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
#endif /* _TRACE_NVMET_H */
|
|
|
|
|
|
|
|
#undef TRACE_INCLUDE_PATH
|
|
|
|
#define TRACE_INCLUDE_PATH .
|
|
|
|
#undef TRACE_INCLUDE_FILE
|
|
|
|
#define TRACE_INCLUDE_FILE trace
|
|
|
|
|
|
|
|
/* This part must be outside protection */
|
|
|
|
#include <trace/define_trace.h>
|