Skip to content

Commit 04f7b3e

Browse files
nvme-print: add human readable output for IOCS Data Structure
Add human readable output for Identify I/O Command Set Data Structure (CNS 1Ch). Signed-off-by: Francis Pravin <[email protected]>
1 parent e44f374 commit 04f7b3e

File tree

3 files changed

+54
-4
lines changed

3 files changed

+54
-4
lines changed

nvme-print-json.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,39 @@ static void obj_print(struct json_object *o)
186186
json_print(o);
187187
}
188188

189+
static void json_id_iocs_iocsc(struct json_object *obj_iocsc, __u64 iocsc)
190+
{
191+
__u8 cpncs = NVME_GET(iocsc, IOCS_IOCSC_CPNCS);
192+
__u8 slmcs = NVME_GET(iocsc, IOCS_IOCSC_SLMCS);
193+
__u8 znscs = NVME_GET(iocsc, IOCS_IOCSC_ZNSCS);
194+
__u8 kvcs = NVME_GET(iocsc, IOCS_IOCSC_KVCS);
195+
__u8 nvmcs = NVME_GET(iocsc, IOCS_IOCSC_NVMCS);
196+
197+
obj_add_str(obj_iocsc, "Computational Programs Namespace Command Set", cpncs ?
198+
"Selected" : "Not selected");
199+
obj_add_str(obj_iocsc, "Subsystem Local Memory Command Set", slmcs ?
200+
"Selected" : "Not selected");
201+
obj_add_str(obj_iocsc, "Zoned Namespace Command Set", znscs ? "Selected" : "Not selected");
202+
obj_add_str(obj_iocsc, "Key Value Command Set", kvcs ? "Selected" : "Not selected");
203+
obj_add_str(obj_iocsc, "NVM Command Set", nvmcs ? "Selected" : "Not selected");
204+
}
205+
189206
static void json_id_iocs(struct nvme_id_iocs *iocs)
190207
{
191208
struct json_object *r = json_create_object();
209+
struct json_object *obj_iocsc;
192210
char json_str[STR_LEN];
193211
__u16 i;
194212

195213
for (i = 0; i < ARRAY_SIZE(iocs->iocsc); i++) {
196214
if (iocs->iocsc[i]) {
197215
sprintf(json_str, "I/O Command Set Combination[%u]", i);
198216
obj_add_uint64(r, json_str, le64_to_cpu(iocs->iocsc[i]));
217+
218+
obj_iocsc = json_create_object();
219+
sprintf(json_str, "IOCSC%u", i);
220+
json_id_iocs_iocsc(obj_iocsc, le64_to_cpu(iocs->iocsc[i]));
221+
obj_add_obj(r, json_str, obj_iocsc);
199222
}
200223
}
201224

nvme-print-stdout.c

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3954,14 +3954,38 @@ static void stdout_endurance_group_list(struct nvme_id_endurance_group_list *end
39543954
printf("[%4u]:%#x\n", i, le16_to_cpu(endgrp_list->identifier[i]));
39553955
}
39563956

3957+
static void stdout_id_iocs_iocsc(__u64 iocsc)
3958+
{
3959+
__u8 cpncs = NVME_GET(iocsc, IOCS_IOCSC_CPNCS);
3960+
__u8 slmcs = NVME_GET(iocsc, IOCS_IOCSC_SLMCS);
3961+
__u8 znscs = NVME_GET(iocsc, IOCS_IOCSC_ZNSCS);
3962+
__u8 kvcs = NVME_GET(iocsc, IOCS_IOCSC_KVCS);
3963+
__u8 nvmcs = NVME_GET(iocsc, IOCS_IOCSC_NVMCS);
3964+
3965+
printf(" [4:4] : %#x\tComputational Programs Namespace Command Set %sSelected\n",
3966+
cpncs, cpncs ? "" : "Not ");
3967+
printf(" [3:3] : %#x\tSubsystem Local Memory Command Set %sSelected\n", slmcs,
3968+
slmcs ? "" : "Not ");
3969+
printf(" [2:2] : %#x\tZoned Namespace Command Set %sSelected\n", znscs,
3970+
znscs ? "" : "Not ");
3971+
printf(" [1:1] : %#x\tKey Value Command Set %sSelected\n", kvcs, kvcs ? "" : "Not ");
3972+
printf(" [0:0] : %#x\tNVM Command Set %sSelected\n", nvmcs, nvmcs ? "" : "Not ");
3973+
printf("\n");
3974+
}
3975+
39573976
static void stdout_id_iocs(struct nvme_id_iocs *iocs)
39583977
{
3978+
bool human = stdout_print_ops.flags & VERBOSE;
39593979
__u16 i;
39603980

3961-
for (i = 0; i < ARRAY_SIZE(iocs->iocsc); i++)
3962-
if (iocs->iocsc[i])
3981+
for (i = 0; i < ARRAY_SIZE(iocs->iocsc); i++) {
3982+
if (iocs->iocsc[i]) {
39633983
printf("I/O Command Set Combination[%u]:%"PRIx64"\n", i,
39643984
(uint64_t)le64_to_cpu(iocs->iocsc[i]));
3985+
if (human)
3986+
stdout_id_iocs_iocsc(le64_to_cpu(iocs->iocsc[i]));
3987+
}
3988+
}
39653989
}
39663990

39673991
static void stdout_error_log(struct nvme_error_log_page *err_log, int entries,

nvme.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4120,8 +4120,8 @@ static int id_iocs(int argc, char **argv, struct command *cmd, struct plugin *pl
41204120

41214121
_cleanup_free_ struct nvme_id_iocs *iocs = NULL;
41224122
_cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
4123-
int err;
41244123
nvme_print_flags_t flags;
4124+
int err;
41254125

41264126
struct config {
41274127
__u16 cntid;
@@ -4144,14 +4144,17 @@ static int id_iocs(int argc, char **argv, struct command *cmd, struct plugin *pl
41444144
return err;
41454145
}
41464146

4147+
if (argconfig_parse_seen(opts, "verbose"))
4148+
flags |= VERBOSE;
4149+
41474150
iocs = nvme_alloc(sizeof(*iocs));
41484151
if (!iocs)
41494152
return -ENOMEM;
41504153

41514154
err = nvme_identify_iocs(dev_fd(dev), cfg.cntid, iocs);
41524155
if (!err) {
41534156
printf("NVMe Identify I/O Command Set:\n");
4154-
nvme_show_id_iocs(iocs, 0);
4157+
nvme_show_id_iocs(iocs, flags);
41554158
} else if (err > 0) {
41564159
nvme_show_status(err);
41574160
} else {

0 commit comments

Comments
 (0)