nvme: add tracepoint for nvme_setup_cmd
Add tracepoints for nvme_setup_cmd() for tracing admin and/or nvm commands.
Examples of the two tracepoints are as follows for trace_nvme_setup_admin_cmd():
kworker/u8:0-5 [003] .... 2.998792: nvme_setup_admin_cmd: cmdid=14, flags=0x0, meta=0x0, cmd=(nvme_admin_create_cq cqid=1, qsize=1023, cq_flags=0x3, irq_vector=0)
and trace_nvme_setup_nvm_cmd():
dd-205 [001] .... 3.503929: nvme_setup_nvm_cmd: qid=1, nsid=1, cmdid=989, flags=0x0, meta=0x0, cmd=(nvme_cmd_read slba=4096, len=2047, ctrl=0x0, dsmgmt=0, reftag=0)
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2018-01-26 18:21:37 +08:00
|
|
|
/*
|
|
|
|
* NVM Express device driver tracepoints
|
|
|
|
* Copyright (c) 2018 Johannes Thumshirn, SUSE Linux GmbH
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <asm/unaligned.h>
|
|
|
|
#include "trace.h"
|
|
|
|
|
|
|
|
static const char *nvme_trace_create_sq(struct trace_seq *p, u8 *cdw10)
|
|
|
|
{
|
|
|
|
const char *ret = trace_seq_buffer_ptr(p);
|
|
|
|
u16 sqid = get_unaligned_le16(cdw10);
|
|
|
|
u16 qsize = get_unaligned_le16(cdw10 + 2);
|
|
|
|
u16 sq_flags = get_unaligned_le16(cdw10 + 4);
|
|
|
|
u16 cqid = get_unaligned_le16(cdw10 + 6);
|
|
|
|
|
|
|
|
|
|
|
|
trace_seq_printf(p, "sqid=%u, qsize=%u, sq_flags=0x%x, cqid=%u",
|
|
|
|
sqid, qsize, sq_flags, cqid);
|
|
|
|
trace_seq_putc(p, 0);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *nvme_trace_create_cq(struct trace_seq *p, u8 *cdw10)
|
|
|
|
{
|
|
|
|
const char *ret = trace_seq_buffer_ptr(p);
|
|
|
|
u16 cqid = get_unaligned_le16(cdw10);
|
|
|
|
u16 qsize = get_unaligned_le16(cdw10 + 2);
|
|
|
|
u16 cq_flags = get_unaligned_le16(cdw10 + 4);
|
|
|
|
u16 irq_vector = get_unaligned_le16(cdw10 + 6);
|
|
|
|
|
|
|
|
trace_seq_printf(p, "cqid=%u, qsize=%u, cq_flags=0x%x, irq_vector=%u",
|
|
|
|
cqid, qsize, cq_flags, irq_vector);
|
|
|
|
trace_seq_putc(p, 0);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *nvme_trace_admin_identify(struct trace_seq *p, u8 *cdw10)
|
|
|
|
{
|
|
|
|
const char *ret = trace_seq_buffer_ptr(p);
|
|
|
|
u8 cns = cdw10[0];
|
|
|
|
u16 ctrlid = get_unaligned_le16(cdw10 + 2);
|
|
|
|
|
|
|
|
trace_seq_printf(p, "cns=%u, ctrlid=%u", cns, ctrlid);
|
|
|
|
trace_seq_putc(p, 0);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const char *nvme_trace_read_write(struct trace_seq *p, u8 *cdw10)
|
|
|
|
{
|
|
|
|
const char *ret = trace_seq_buffer_ptr(p);
|
|
|
|
u64 slba = get_unaligned_le64(cdw10);
|
|
|
|
u16 length = get_unaligned_le16(cdw10 + 8);
|
|
|
|
u16 control = get_unaligned_le16(cdw10 + 10);
|
|
|
|
u32 dsmgmt = get_unaligned_le32(cdw10 + 12);
|
|
|
|
u32 reftag = get_unaligned_le32(cdw10 + 16);
|
|
|
|
|
|
|
|
trace_seq_printf(p,
|
|
|
|
"slba=%llu, len=%u, ctrl=0x%x, dsmgmt=%u, reftag=%u",
|
|
|
|
slba, length, control, dsmgmt, reftag);
|
|
|
|
trace_seq_putc(p, 0);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *nvme_trace_dsm(struct trace_seq *p, u8 *cdw10)
|
|
|
|
{
|
|
|
|
const char *ret = trace_seq_buffer_ptr(p);
|
|
|
|
|
|
|
|
trace_seq_printf(p, "nr=%u, attributes=%u",
|
|
|
|
get_unaligned_le32(cdw10),
|
|
|
|
get_unaligned_le32(cdw10 + 4));
|
|
|
|
trace_seq_putc(p, 0);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *nvme_trace_common(struct trace_seq *p, u8 *cdw10)
|
|
|
|
{
|
|
|
|
const char *ret = trace_seq_buffer_ptr(p);
|
|
|
|
|
|
|
|
trace_seq_printf(p, "cdw10=%*ph", 24, cdw10);
|
|
|
|
trace_seq_putc(p, 0);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *nvme_trace_parse_admin_cmd(struct trace_seq *p,
|
|
|
|
u8 opcode, u8 *cdw10)
|
|
|
|
{
|
|
|
|
switch (opcode) {
|
|
|
|
case nvme_admin_create_sq:
|
|
|
|
return nvme_trace_create_sq(p, cdw10);
|
|
|
|
case nvme_admin_create_cq:
|
|
|
|
return nvme_trace_create_cq(p, cdw10);
|
|
|
|
case nvme_admin_identify:
|
|
|
|
return nvme_trace_admin_identify(p, cdw10);
|
|
|
|
default:
|
|
|
|
return nvme_trace_common(p, cdw10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *nvme_trace_parse_nvm_cmd(struct trace_seq *p,
|
|
|
|
u8 opcode, u8 *cdw10)
|
|
|
|
{
|
|
|
|
switch (opcode) {
|
|
|
|
case nvme_cmd_read:
|
|
|
|
case nvme_cmd_write:
|
|
|
|
case nvme_cmd_write_zeroes:
|
|
|
|
return nvme_trace_read_write(p, cdw10);
|
|
|
|
case nvme_cmd_dsm:
|
|
|
|
return nvme_trace_dsm(p, cdw10);
|
|
|
|
default:
|
|
|
|
return nvme_trace_common(p, cdw10);
|
|
|
|
}
|
|
|
|
}
|
2018-06-30 06:50:03 +08:00
|
|
|
|
|
|
|
const char *nvme_trace_disk_name(struct trace_seq *p, char *name)
|
|
|
|
{
|
|
|
|
const char *ret = trace_seq_buffer_ptr(p);
|
|
|
|
|
|
|
|
if (*name)
|
|
|
|
trace_seq_printf(p, "disk=%s, ", name);
|
|
|
|
trace_seq_putc(p, 0);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2018-12-19 00:59:53 +08:00
|
|
|
EXPORT_SYMBOL_GPL(nvme_trace_disk_name);
|
|
|
|
|
|
|
|
EXPORT_TRACEPOINT_SYMBOL_GPL(nvme_sq);
|