Skip to content

Commit 8d539f7

Browse files
guixinliu1995keithbusch
authored andcommitted
nvme: parse zns command's zsa and zrasf to string
Parse zone mgmt send commands's zsa and receive command's zrasf to string to make the trace log more human-readable. Signed-off-by: Guixin Liu <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent dcad6f5 commit 8d539f7

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

drivers/nvme/host/trace.c

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,28 +164,60 @@ static const char *nvme_trace_dsm(struct trace_seq *p, u8 *cdw10)
164164

165165
static const char *nvme_trace_zone_mgmt_send(struct trace_seq *p, u8 *cdw10)
166166
{
167+
static const char * const zsa_strs[] = {
168+
[0x01] = "close zone",
169+
[0x02] = "finish zone",
170+
[0x03] = "open zone",
171+
[0x04] = "reset zone",
172+
[0x05] = "offline zone",
173+
[0x10] = "set zone descriptor extension"
174+
};
167175
const char *ret = trace_seq_buffer_ptr(p);
168176
u64 slba = get_unaligned_le64(cdw10);
177+
const char *zsa_str;
169178
u8 zsa = cdw10[12];
170179
u8 all = cdw10[13];
171180

172-
trace_seq_printf(p, "slba=%llu, zsa=%u, all=%u", slba, zsa, all);
181+
if (zsa < ARRAY_SIZE(zsa_strs) && zsa_strs[zsa])
182+
zsa_str = zsa_strs[zsa];
183+
else
184+
zsa_str = "reserved";
185+
186+
trace_seq_printf(p, "slba=%llu, zsa=%u:%s, all=%u",
187+
slba, zsa, zsa_str, all);
173188
trace_seq_putc(p, 0);
174189

175190
return ret;
176191
}
177192

178193
static const char *nvme_trace_zone_mgmt_recv(struct trace_seq *p, u8 *cdw10)
179194
{
195+
static const char * const zrasf_strs[] = {
196+
[0x00] = "list all zones",
197+
[0x01] = "list the zones in the ZSE: Empty state",
198+
[0x02] = "list the zones in the ZSIO: Implicitly Opened state",
199+
[0x03] = "list the zones in the ZSEO: Explicitly Opened state",
200+
[0x04] = "list the zones in the ZSC: Closed state",
201+
[0x05] = "list the zones in the ZSF: Full state",
202+
[0x06] = "list the zones in the ZSRO: Read Only state",
203+
[0x07] = "list the zones in the ZSO: Offline state",
204+
[0x09] = "list the zones that have the zone attribute"
205+
};
180206
const char *ret = trace_seq_buffer_ptr(p);
181207
u64 slba = get_unaligned_le64(cdw10);
182208
u32 numd = get_unaligned_le32(cdw10 + 8);
183209
u8 zra = cdw10[12];
184210
u8 zrasf = cdw10[13];
211+
const char *zrasf_str;
185212
u8 pr = cdw10[14];
186213

187-
trace_seq_printf(p, "slba=%llu, numd=%u, zra=%u, zrasf=%u, pr=%u",
188-
slba, numd, zra, zrasf, pr);
214+
if (zrasf < ARRAY_SIZE(zrasf_strs) && zrasf_strs[zrasf])
215+
zrasf_str = zrasf_strs[zrasf];
216+
else
217+
zrasf_str = "reserved";
218+
219+
trace_seq_printf(p, "slba=%llu, numd=%u, zra=%u, zrasf=%u:%s, pr=%u",
220+
slba, numd, zra, zrasf, zrasf_str, pr);
189221
trace_seq_putc(p, 0);
190222

191223
return ret;

0 commit comments

Comments
 (0)