1 // SPDX-License-Identifier: GPL-2.0
3 * NVM Express target device driver tracepoints
4 * Copyright (c) 2018 Johannes Thumshirn, SUSE Linux GmbH
7 #include <asm/unaligned.h>
10 static const char *nvmet_trace_admin_identify(struct trace_seq *p, u8 *cdw10)
12 const char *ret = trace_seq_buffer_ptr(p);
14 u16 ctrlid = get_unaligned_le16(cdw10 + 2);
16 trace_seq_printf(p, "cns=%u, ctrlid=%u", cns, ctrlid);
22 static const char *nvmet_trace_admin_get_features(struct trace_seq *p,
25 const char *ret = trace_seq_buffer_ptr(p);
27 u8 sel = cdw10[1] & 0x7;
28 u32 cdw11 = get_unaligned_le32(cdw10 + 4);
30 trace_seq_printf(p, "fid=0x%x sel=0x%x cdw11=0x%x", fid, sel, cdw11);
36 static const char *nvmet_trace_read_write(struct trace_seq *p, u8 *cdw10)
38 const char *ret = trace_seq_buffer_ptr(p);
39 u64 slba = get_unaligned_le64(cdw10);
40 u16 length = get_unaligned_le16(cdw10 + 8);
41 u16 control = get_unaligned_le16(cdw10 + 10);
42 u32 dsmgmt = get_unaligned_le32(cdw10 + 12);
43 u32 reftag = get_unaligned_le32(cdw10 + 16);
46 "slba=%llu, len=%u, ctrl=0x%x, dsmgmt=%u, reftag=%u",
47 slba, length, control, dsmgmt, reftag);
53 static const char *nvmet_trace_dsm(struct trace_seq *p, u8 *cdw10)
55 const char *ret = trace_seq_buffer_ptr(p);
57 trace_seq_printf(p, "nr=%u, attributes=%u",
58 get_unaligned_le32(cdw10),
59 get_unaligned_le32(cdw10 + 4));
65 static const char *nvmet_trace_common(struct trace_seq *p, u8 *cdw10)
67 const char *ret = trace_seq_buffer_ptr(p);
69 trace_seq_printf(p, "cdw10=%*ph", 24, cdw10);
75 const char *nvmet_trace_parse_admin_cmd(struct trace_seq *p,
79 case nvme_admin_identify:
80 return nvmet_trace_admin_identify(p, cdw10);
81 case nvme_admin_get_features:
82 return nvmet_trace_admin_get_features(p, cdw10);
84 return nvmet_trace_common(p, cdw10);
88 const char *nvmet_trace_parse_nvm_cmd(struct trace_seq *p,
94 case nvme_cmd_write_zeroes:
95 return nvmet_trace_read_write(p, cdw10);
97 return nvmet_trace_dsm(p, cdw10);
99 return nvmet_trace_common(p, cdw10);
103 static const char *nvmet_trace_fabrics_property_set(struct trace_seq *p,
106 const char *ret = trace_seq_buffer_ptr(p);
108 u32 ofst = get_unaligned_le32(spc + 4);
109 u64 value = get_unaligned_le64(spc + 8);
111 trace_seq_printf(p, "attrib=%u, ofst=0x%x, value=0x%llx",
112 attrib, ofst, value);
113 trace_seq_putc(p, 0);
117 static const char *nvmet_trace_fabrics_connect(struct trace_seq *p,
120 const char *ret = trace_seq_buffer_ptr(p);
121 u16 recfmt = get_unaligned_le16(spc);
122 u16 qid = get_unaligned_le16(spc + 2);
123 u16 sqsize = get_unaligned_le16(spc + 4);
125 u32 kato = get_unaligned_le32(spc + 8);
127 trace_seq_printf(p, "recfmt=%u, qid=%u, sqsize=%u, cattr=%u, kato=%u",
128 recfmt, qid, sqsize, cattr, kato);
129 trace_seq_putc(p, 0);
133 static const char *nvmet_trace_fabrics_property_get(struct trace_seq *p,
136 const char *ret = trace_seq_buffer_ptr(p);
138 u32 ofst = get_unaligned_le32(spc + 4);
140 trace_seq_printf(p, "attrib=%u, ofst=0x%x", attrib, ofst);
141 trace_seq_putc(p, 0);
145 static const char *nvmet_trace_fabrics_common(struct trace_seq *p, u8 *spc)
147 const char *ret = trace_seq_buffer_ptr(p);
149 trace_seq_printf(p, "spcecific=%*ph", 24, spc);
150 trace_seq_putc(p, 0);
154 const char *nvmet_trace_parse_fabrics_cmd(struct trace_seq *p,
158 case nvme_fabrics_type_property_set:
159 return nvmet_trace_fabrics_property_set(p, spc);
160 case nvme_fabrics_type_connect:
161 return nvmet_trace_fabrics_connect(p, spc);
162 case nvme_fabrics_type_property_get:
163 return nvmet_trace_fabrics_property_get(p, spc);
165 return nvmet_trace_fabrics_common(p, spc);
169 const char *nvmet_trace_disk_name(struct trace_seq *p, char *name)
171 const char *ret = trace_seq_buffer_ptr(p);
174 trace_seq_printf(p, "disk=%s, ", name);
175 trace_seq_putc(p, 0);
180 const char *nvmet_trace_ctrl_name(struct trace_seq *p, struct nvmet_ctrl *ctrl)
182 const char *ret = trace_seq_buffer_ptr(p);
185 * XXX: We don't know the controller instance before executing the
186 * connect command itself because the connect command for the admin
187 * queue will not provide the cntlid which will be allocated in this
188 * command. In case of io queues, the controller instance will be
189 * mapped by the extra data of the connect command.
190 * If we can know the extra data of the connect command in this stage,
191 * we can update this print statement later.
194 trace_seq_printf(p, "%d", ctrl->cntlid);
196 trace_seq_printf(p, "_");
197 trace_seq_putc(p, 0);