From: Gollu Appalanaidu Date: Sun, 7 Mar 2021 18:32:35 +0000 (+0530) Subject: nvme-print: improve command support and effects log json format X-Git-Tag: v1.14~49 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=40696876ad4ccbe685ccac0c7f223855fb9c700e;p=users%2Fsagi%2Fnvme-cli.git nvme-print: improve command support and effects log json format 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 --- diff --git a/nvme-print.c b/nvme-print.c index af24a61a..b2a55af6 100755 --- a/nvme-print.c +++ b/nvme-print.c @@ -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);