Skip to content

Commit 8a502b5

Browse files
guixinliu1995keithbusch
authored andcommitted
nvme: parse reservation commands's action and rtype to string
Parse reservation commands's action(including rrega, racqa and rrela) and rtype to string to make the trace log more human-readable. Signed-off-by: Guixin Liu <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 609e60a commit 8a502b5

File tree

1 file changed

+52
-6
lines changed

1 file changed

+52
-6
lines changed

drivers/nvme/host/trace.c

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,41 +228,87 @@ static const char *nvme_trace_zone_mgmt_recv(struct trace_seq *p, u8 *cdw10)
228228

229229
static const char *nvme_trace_resv_reg(struct trace_seq *p, u8 *cdw10)
230230
{
231+
static const char * const rrega_strs[] = {
232+
[0x00] = "register",
233+
[0x01] = "unregister",
234+
[0x02] = "replace",
235+
};
231236
const char *ret = trace_seq_buffer_ptr(p);
232237
u8 rrega = cdw10[0] & 0x7;
233238
u8 iekey = (cdw10[0] >> 3) & 0x1;
234239
u8 ptpl = (cdw10[3] >> 6) & 0x3;
240+
const char *rrega_str;
241+
242+
if (rrega < ARRAY_SIZE(rrega_strs) && rrega_strs[rrega])
243+
rrega_str = rrega_strs[rrega];
244+
else
245+
rrega_str = "reserved";
235246

236-
trace_seq_printf(p, "rrega=%u, iekey=%u, ptpl=%u",
237-
rrega, iekey, ptpl);
247+
trace_seq_printf(p, "rrega=%u:%s, iekey=%u, ptpl=%u",
248+
rrega, rrega_str, iekey, ptpl);
238249
trace_seq_putc(p, 0);
239250

240251
return ret;
241252
}
242253

254+
static const char * const rtype_strs[] = {
255+
[0x00] = "reserved",
256+
[0x01] = "write exclusive",
257+
[0x02] = "exclusive access",
258+
[0x03] = "write exclusive registrants only",
259+
[0x04] = "exclusive access registrants only",
260+
[0x05] = "write exclusive all registrants",
261+
[0x06] = "exclusive access all registrants",
262+
};
263+
243264
static const char *nvme_trace_resv_acq(struct trace_seq *p, u8 *cdw10)
244265
{
266+
static const char * const racqa_strs[] = {
267+
[0x00] = "acquire",
268+
[0x01] = "preempt",
269+
[0x02] = "preempt and abort",
270+
};
245271
const char *ret = trace_seq_buffer_ptr(p);
246272
u8 racqa = cdw10[0] & 0x7;
247273
u8 iekey = (cdw10[0] >> 3) & 0x1;
248274
u8 rtype = cdw10[1];
275+
const char *racqa_str = "reserved";
276+
const char *rtype_str = "reserved";
249277

250-
trace_seq_printf(p, "racqa=%u, iekey=%u, rtype=%u",
251-
racqa, iekey, rtype);
278+
if (racqa < ARRAY_SIZE(racqa_strs) && racqa_strs[racqa])
279+
racqa_str = racqa_strs[racqa];
280+
281+
if (rtype < ARRAY_SIZE(rtype_strs) && rtype_strs[rtype])
282+
rtype_str = rtype_strs[rtype];
283+
284+
trace_seq_printf(p, "racqa=%u:%s, iekey=%u, rtype=%u:%s",
285+
racqa, racqa_str, iekey, rtype, rtype_str);
252286
trace_seq_putc(p, 0);
253287

254288
return ret;
255289
}
256290

257291
static const char *nvme_trace_resv_rel(struct trace_seq *p, u8 *cdw10)
258292
{
293+
static const char * const rrela_strs[] = {
294+
[0x00] = "release",
295+
[0x01] = "clear",
296+
};
259297
const char *ret = trace_seq_buffer_ptr(p);
260298
u8 rrela = cdw10[0] & 0x7;
261299
u8 iekey = (cdw10[0] >> 3) & 0x1;
262300
u8 rtype = cdw10[1];
301+
const char *rrela_str = "reserved";
302+
const char *rtype_str = "reserved";
303+
304+
if (rrela < ARRAY_SIZE(rrela_strs) && rrela_strs[rrela])
305+
rrela_str = rrela_strs[rrela];
306+
307+
if (rtype < ARRAY_SIZE(rtype_strs) && rtype_strs[rtype])
308+
rtype_str = rtype_strs[rtype];
263309

264-
trace_seq_printf(p, "rrela=%u, iekey=%u, rtype=%u",
265-
rrela, iekey, rtype);
310+
trace_seq_printf(p, "rrela=%u:%s, iekey=%u, rtype=%u:%s",
311+
rrela, rrela_str, iekey, rtype, rtype_str);
266312
trace_seq_putc(p, 0);
267313

268314
return ret;

0 commit comments

Comments
 (0)