]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-print: add human readable output for IOCS Data Structure
authorFrancis Pravin <francis.p@samsung.com>
Thu, 27 Feb 2025 12:19:32 +0000 (17:49 +0530)
committerDaniel Wagner <wagi@monom.org>
Thu, 27 Feb 2025 14:48:14 +0000 (15:48 +0100)
Add human readable output for Identify I/O Command Set Data
Structure (CNS 1Ch).

Signed-off-by: Francis Pravin <francis.p@samsung.com>
nvme-print-json.c
nvme-print-stdout.c
nvme.c

index 5b3c36296055a7bdfcc0c01ba0b48fbace65abfd..13b3c6cf0ed2f2b33d90c51f0aa4970571a884fa 100644 (file)
@@ -186,9 +186,27 @@ static void obj_print(struct json_object *o)
                json_print(o);
 }
 
+static void json_id_iocs_iocsc(struct json_object *obj_iocsc, __u64 iocsc)
+{
+       __u8 cpncs = NVME_GET(iocsc, IOCS_IOCSC_CPNCS);
+       __u8 slmcs = NVME_GET(iocsc, IOCS_IOCSC_SLMCS);
+       __u8 znscs = NVME_GET(iocsc, IOCS_IOCSC_ZNSCS);
+       __u8 kvcs = NVME_GET(iocsc, IOCS_IOCSC_KVCS);
+       __u8 nvmcs = NVME_GET(iocsc, IOCS_IOCSC_NVMCS);
+
+       obj_add_str(obj_iocsc, "Computational Programs Namespace Command Set", cpncs ?
+                   "Selected" : "Not selected");
+       obj_add_str(obj_iocsc, "Subsystem Local Memory Command Set", slmcs ?
+                   "Selected" : "Not selected");
+       obj_add_str(obj_iocsc, "Zoned Namespace Command Set", znscs ? "Selected" : "Not selected");
+       obj_add_str(obj_iocsc, "Key Value Command Set", kvcs ? "Selected" : "Not selected");
+       obj_add_str(obj_iocsc, "NVM Command Set", nvmcs ? "Selected" : "Not selected");
+}
+
 static void json_id_iocs(struct nvme_id_iocs *iocs)
 {
        struct json_object *r = json_create_object();
+       struct json_object *obj_iocsc;
        char json_str[STR_LEN];
        __u16 i;
 
@@ -196,6 +214,11 @@ static void json_id_iocs(struct nvme_id_iocs *iocs)
                if (iocs->iocsc[i]) {
                        sprintf(json_str, "I/O Command Set Combination[%u]", i);
                        obj_add_uint64(r, json_str, le64_to_cpu(iocs->iocsc[i]));
+
+                       obj_iocsc = json_create_object();
+                       sprintf(json_str, "IOCSC%u", i);
+                       json_id_iocs_iocsc(obj_iocsc, le64_to_cpu(iocs->iocsc[i]));
+                       obj_add_obj(r, json_str, obj_iocsc);
                }
        }
 
index 2e4acf252da8526fc576300354fda3d665afe936..e10bd11fbc2c1864a131566104c6d92274d07145 100644 (file)
@@ -3954,14 +3954,38 @@ static void stdout_endurance_group_list(struct nvme_id_endurance_group_list *end
                printf("[%4u]:%#x\n", i, le16_to_cpu(endgrp_list->identifier[i]));
 }
 
+static void stdout_id_iocs_iocsc(__u64 iocsc)
+{
+       __u8 cpncs = NVME_GET(iocsc, IOCS_IOCSC_CPNCS);
+       __u8 slmcs = NVME_GET(iocsc, IOCS_IOCSC_SLMCS);
+       __u8 znscs = NVME_GET(iocsc, IOCS_IOCSC_ZNSCS);
+       __u8 kvcs = NVME_GET(iocsc, IOCS_IOCSC_KVCS);
+       __u8 nvmcs = NVME_GET(iocsc, IOCS_IOCSC_NVMCS);
+
+       printf("  [4:4] : %#x\tComputational Programs Namespace Command Set %sSelected\n",
+               cpncs, cpncs ? "" : "Not ");
+       printf("  [3:3] : %#x\tSubsystem Local Memory Command Set %sSelected\n", slmcs,
+               slmcs ? "" : "Not ");
+       printf("  [2:2] : %#x\tZoned Namespace Command Set %sSelected\n", znscs,
+               znscs ? "" : "Not ");
+       printf("  [1:1] : %#x\tKey Value Command Set %sSelected\n", kvcs, kvcs ? "" : "Not ");
+       printf("  [0:0] : %#x\tNVM Command Set %sSelected\n", nvmcs, nvmcs ? "" : "Not ");
+       printf("\n");
+}
+
 static void stdout_id_iocs(struct nvme_id_iocs *iocs)
 {
+       bool human = stdout_print_ops.flags & VERBOSE;
        __u16 i;
 
-       for (i = 0; i < ARRAY_SIZE(iocs->iocsc); i++)
-               if (iocs->iocsc[i])
+       for (i = 0; i < ARRAY_SIZE(iocs->iocsc); i++) {
+               if (iocs->iocsc[i]) {
                        printf("I/O Command Set Combination[%u]:%"PRIx64"\n", i,
                                (uint64_t)le64_to_cpu(iocs->iocsc[i]));
+                       if (human)
+                               stdout_id_iocs_iocsc(le64_to_cpu(iocs->iocsc[i]));
+               }
+       }
 }
 
 static void stdout_error_log(struct nvme_error_log_page *err_log, int entries,
diff --git a/nvme.c b/nvme.c
index 6d6e76fdf3130a0b32142632a001bf0ea9cbbc6a..5b722e6ec1f647a6856e1666cba172a8022b8276 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -4120,8 +4120,8 @@ static int id_iocs(int argc, char **argv, struct command *cmd, struct plugin *pl
 
        _cleanup_free_ struct nvme_id_iocs *iocs = NULL;
        _cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
-       int err;
        nvme_print_flags_t flags;
+       int err;
 
        struct config {
                __u16   cntid;
@@ -4144,6 +4144,9 @@ static int id_iocs(int argc, char **argv, struct command *cmd, struct plugin *pl
                return err;
        }
 
+       if (argconfig_parse_seen(opts, "verbose"))
+               flags |= VERBOSE;
+
        iocs = nvme_alloc(sizeof(*iocs));
        if (!iocs)
                return -ENOMEM;
@@ -4151,7 +4154,7 @@ static int id_iocs(int argc, char **argv, struct command *cmd, struct plugin *pl
        err = nvme_identify_iocs(dev_fd(dev), cfg.cntid, iocs);
        if (!err) {
                printf("NVMe Identify I/O Command Set:\n");
-               nvme_show_id_iocs(iocs, 0);
+               nvme_show_id_iocs(iocs, flags);
        } else if (err > 0) {
                nvme_show_status(err);
        } else {