Skip to content

Commit 2bc9174

Browse files
guixinliu1995keithbusch
authored andcommitted
nvmet: add tracing of zns commands
Add nvme_cmd_zone_append, nvme_cmd_zone_mgmt_send and nvme_cmd_zone_mgmt_recv parse to nvme target tracing. Signed-off-by: Guixin Liu <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 8fc3b0f commit 2bc9174

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

drivers/nvme/target/trace.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,82 @@ const char *nvmet_trace_parse_admin_cmd(struct trace_seq *p,
119119
}
120120
}
121121

122+
static const char *nvmet_trace_zone_mgmt_send(struct trace_seq *p, u8 *cdw10)
123+
{
124+
static const char * const zsa_strs[] = {
125+
[0x01] = "close zone",
126+
[0x02] = "finish zone",
127+
[0x03] = "open zone",
128+
[0x04] = "reset zone",
129+
[0x05] = "offline zone",
130+
[0x10] = "set zone descriptor extension"
131+
};
132+
const char *ret = trace_seq_buffer_ptr(p);
133+
u64 slba = get_unaligned_le64(cdw10);
134+
const char *zsa_str;
135+
u8 zsa = cdw10[12];
136+
u8 all = cdw10[13];
137+
138+
if (zsa < ARRAY_SIZE(zsa_strs) && zsa_strs[zsa])
139+
zsa_str = zsa_strs[zsa];
140+
else
141+
zsa_str = "reserved";
142+
143+
trace_seq_printf(p, "slba=%llu, zsa=%u:%s, all=%u",
144+
slba, zsa, zsa_str, all);
145+
trace_seq_putc(p, 0);
146+
147+
return ret;
148+
}
149+
150+
static const char *nvmet_trace_zone_mgmt_recv(struct trace_seq *p, u8 *cdw10)
151+
{
152+
static const char * const zrasf_strs[] = {
153+
[0x00] = "list all zones",
154+
[0x01] = "list the zones in the ZSE: Empty state",
155+
[0x02] = "list the zones in the ZSIO: Implicitly Opened state",
156+
[0x03] = "list the zones in the ZSEO: Explicitly Opened state",
157+
[0x04] = "list the zones in the ZSC: Closed state",
158+
[0x05] = "list the zones in the ZSF: Full state",
159+
[0x06] = "list the zones in the ZSRO: Read Only state",
160+
[0x07] = "list the zones in the ZSO: Offline state",
161+
[0x09] = "list the zones that have the zone attribute"
162+
};
163+
const char *ret = trace_seq_buffer_ptr(p);
164+
u64 slba = get_unaligned_le64(cdw10);
165+
u32 numd = get_unaligned_le32(&cdw10[8]);
166+
u8 zra = cdw10[12];
167+
u8 zrasf = cdw10[13];
168+
const char *zrasf_str;
169+
u8 pr = cdw10[14];
170+
171+
if (zrasf < ARRAY_SIZE(zrasf_strs) && zrasf_strs[zrasf])
172+
zrasf_str = zrasf_strs[zrasf];
173+
else
174+
zrasf_str = "reserved";
175+
176+
trace_seq_printf(p, "slba=%llu, numd=%u, zra=%u, zrasf=%u:%s, pr=%u",
177+
slba, numd, zra, zrasf, zrasf_str, pr);
178+
trace_seq_putc(p, 0);
179+
180+
return ret;
181+
}
182+
122183
const char *nvmet_trace_parse_nvm_cmd(struct trace_seq *p,
123184
u8 opcode, u8 *cdw10)
124185
{
125186
switch (opcode) {
126187
case nvme_cmd_read:
127188
case nvme_cmd_write:
128189
case nvme_cmd_write_zeroes:
190+
case nvme_cmd_zone_append:
129191
return nvmet_trace_read_write(p, cdw10);
130192
case nvme_cmd_dsm:
131193
return nvmet_trace_dsm(p, cdw10);
194+
case nvme_cmd_zone_mgmt_send:
195+
return nvmet_trace_zone_mgmt_send(p, cdw10);
196+
case nvme_cmd_zone_mgmt_recv:
197+
return nvmet_trace_zone_mgmt_recv(p, cdw10);
132198
default:
133199
return nvmet_trace_common(p, cdw10);
134200
}

0 commit comments

Comments
 (0)