^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * NVM Express target device driver tracepoints
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (c) 2018 Johannes Thumshirn, SUSE Linux GmbH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <asm/unaligned.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include "trace.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) static const char *nvmet_trace_admin_identify(struct trace_seq *p, u8 *cdw10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) u8 cns = cdw10[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) u16 ctrlid = get_unaligned_le16(cdw10 + 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) trace_seq_printf(p, "cns=%u, ctrlid=%u", cns, ctrlid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) static const char *nvmet_trace_admin_get_features(struct trace_seq *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) u8 *cdw10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) u8 fid = cdw10[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) u8 sel = cdw10[1] & 0x7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) u32 cdw11 = get_unaligned_le32(cdw10 + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) trace_seq_printf(p, "fid=0x%x sel=0x%x cdw11=0x%x", fid, sel, cdw11);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) static const char *nvmet_trace_get_lba_status(struct trace_seq *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) u8 *cdw10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) u64 slba = get_unaligned_le64(cdw10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) u32 mndw = get_unaligned_le32(cdw10 + 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) u16 rl = get_unaligned_le16(cdw10 + 12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) u8 atype = cdw10[15];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) trace_seq_printf(p, "slba=0x%llx, mndw=0x%x, rl=0x%x, atype=%u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) slba, mndw, rl, atype);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) static const char *nvmet_trace_read_write(struct trace_seq *p, u8 *cdw10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) u64 slba = get_unaligned_le64(cdw10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) u16 length = get_unaligned_le16(cdw10 + 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) u16 control = get_unaligned_le16(cdw10 + 10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) u32 dsmgmt = get_unaligned_le32(cdw10 + 12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) u32 reftag = get_unaligned_le32(cdw10 + 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) trace_seq_printf(p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) "slba=%llu, len=%u, ctrl=0x%x, dsmgmt=%u, reftag=%u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) slba, length, control, dsmgmt, reftag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) static const char *nvmet_trace_dsm(struct trace_seq *p, u8 *cdw10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) trace_seq_printf(p, "nr=%u, attributes=%u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) get_unaligned_le32(cdw10),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) get_unaligned_le32(cdw10 + 4));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) static const char *nvmet_trace_common(struct trace_seq *p, u8 *cdw10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) trace_seq_printf(p, "cdw10=%*ph", 24, cdw10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) const char *nvmet_trace_parse_admin_cmd(struct trace_seq *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) u8 opcode, u8 *cdw10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) switch (opcode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) case nvme_admin_identify:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) return nvmet_trace_admin_identify(p, cdw10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) case nvme_admin_get_features:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) return nvmet_trace_admin_get_features(p, cdw10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) case nvme_admin_get_lba_status:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) return nvmet_trace_get_lba_status(p, cdw10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) return nvmet_trace_common(p, cdw10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) const char *nvmet_trace_parse_nvm_cmd(struct trace_seq *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) u8 opcode, u8 *cdw10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) switch (opcode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) case nvme_cmd_read:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) case nvme_cmd_write:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) case nvme_cmd_write_zeroes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) return nvmet_trace_read_write(p, cdw10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) case nvme_cmd_dsm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) return nvmet_trace_dsm(p, cdw10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) return nvmet_trace_common(p, cdw10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) static const char *nvmet_trace_fabrics_property_set(struct trace_seq *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) u8 *spc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) u8 attrib = spc[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) u32 ofst = get_unaligned_le32(spc + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) u64 value = get_unaligned_le64(spc + 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) trace_seq_printf(p, "attrib=%u, ofst=0x%x, value=0x%llx",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) attrib, ofst, value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) static const char *nvmet_trace_fabrics_connect(struct trace_seq *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) u8 *spc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) u16 recfmt = get_unaligned_le16(spc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) u16 qid = get_unaligned_le16(spc + 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) u16 sqsize = get_unaligned_le16(spc + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) u8 cattr = spc[6];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) u32 kato = get_unaligned_le32(spc + 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) trace_seq_printf(p, "recfmt=%u, qid=%u, sqsize=%u, cattr=%u, kato=%u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) recfmt, qid, sqsize, cattr, kato);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) static const char *nvmet_trace_fabrics_property_get(struct trace_seq *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) u8 *spc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) u8 attrib = spc[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) u32 ofst = get_unaligned_le32(spc + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) trace_seq_printf(p, "attrib=%u, ofst=0x%x", attrib, ofst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) static const char *nvmet_trace_fabrics_common(struct trace_seq *p, u8 *spc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) trace_seq_printf(p, "specific=%*ph", 24, spc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) const char *nvmet_trace_parse_fabrics_cmd(struct trace_seq *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) u8 fctype, u8 *spc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) switch (fctype) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) case nvme_fabrics_type_property_set:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) return nvmet_trace_fabrics_property_set(p, spc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) case nvme_fabrics_type_connect:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) return nvmet_trace_fabrics_connect(p, spc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) case nvme_fabrics_type_property_get:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) return nvmet_trace_fabrics_property_get(p, spc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) return nvmet_trace_fabrics_common(p, spc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) const char *nvmet_trace_disk_name(struct trace_seq *p, char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) if (*name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) trace_seq_printf(p, "disk=%s, ", name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) const char *nvmet_trace_ctrl_name(struct trace_seq *p, struct nvmet_ctrl *ctrl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) * XXX: We don't know the controller instance before executing the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) * connect command itself because the connect command for the admin
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) * queue will not provide the cntlid which will be allocated in this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) * command. In case of io queues, the controller instance will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) * mapped by the extra data of the connect command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) * If we can know the extra data of the connect command in this stage,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) * we can update this print statement later.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) if (ctrl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) trace_seq_printf(p, "%d", ctrl->cntlid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) trace_seq_printf(p, "_");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) trace_seq_putc(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)