From 40696876ad4ccbe685ccac0c7f223855fb9c700e Mon Sep 17 00:00:00 2001 From: Gollu Appalanaidu Date: Mon, 8 Mar 2021 00:02:35 +0530 Subject: [PATCH] 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 --- nvme-print.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) 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); -- 2.50.1