]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-print: improve command support and effects log json format
authorGollu Appalanaidu <anaidu.gollu@samsung.com>
Sun, 7 Mar 2021 18:32:35 +0000 (00:02 +0530)
committerKeith Busch <kbusch@kernel.org>
Tue, 9 Mar 2021 18:47:36 +0000 (11:47 -0700)
Currently command support and effects log page on json format
printing all the opcodes irrespective of the command supported.
Most part of the log page is "Unkown" opcodes, fixed that. Also
added two json objects "acs" and "iocs" to print them seperately.

Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
nvme-print.c

index af24a61a2465b7cd9f218f44df859c4d7443188b..b2a55af699ffb06f730cee5db76b345246b26c8a 100755 (executable)
@@ -788,26 +788,36 @@ add:
 static void json_effects_log(struct nvme_effects_log_page *effects_log)
 {
        struct json_object *root;
+       struct json_object *acs;
+       struct json_object *iocs;
        unsigned int opcode;
        char key[128];
        __u32 effect;
 
        root = json_create_object();
-
+       acs = json_create_object();
        for (opcode = 0; opcode < 256; opcode++) {
-               sprintf(key, "ACS%d (%s)", opcode,
-                       nvme_cmd_to_string(1, opcode));
                effect = le32_to_cpu(effects_log->acs[opcode]);
-               json_object_add_value_uint(root, key, effect);
+               if (effect & NVME_CMD_EFFECTS_CSUPP) {
+                       sprintf(key, "ACS_%u (%s)", opcode,
+                               nvme_cmd_to_string(1, opcode));
+                       json_object_add_value_uint(acs, key, effect);
+               }
        }
 
+       json_object_add_value_object(root, "admin_cmd_set", acs);
+
+       iocs = json_create_object();
        for (opcode = 0; opcode < 256; opcode++) {
-               sprintf(key, "IOCS%d (%s)", opcode,
-                       nvme_cmd_to_string(0, opcode));
                effect = le32_to_cpu(effects_log->iocs[opcode]);
-               json_object_add_value_uint(root, key, effect);
+               if (effect & NVME_CMD_EFFECTS_CSUPP) {
+                       sprintf(key, "IOCS_%u (%s)", opcode,
+                               nvme_cmd_to_string(0, opcode));
+                       json_object_add_value_uint(iocs, key, effect);
+               }
        }
 
+       json_object_add_value_object(root, "io_cmd_set", iocs);
        json_print_object(root, NULL);
        printf("\n");
        json_free_object(root);