]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-print-json: add json_mgmt_addr_list_log()
authorTokunori Ikegami <ikegami.t@gmail.com>
Mon, 13 Jan 2025 07:01:42 +0000 (16:01 +0900)
committerDaniel Wagner <wagi@monom.org>
Mon, 13 Jan 2025 16:43:29 +0000 (17:43 +0100)
Since added the NVMe 2.1 log page.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
nvme-print-json.c

index b7cbf3afe4e80dfed5bdf573cb61eede0da687f2..a46105f0e8685b4c3366cd25867cdfe3061acf24 100644 (file)
@@ -4591,6 +4591,44 @@ void json_show_finish(void)
        json_r = NULL;
 }
 
+static void json_mgmt_addr_list_log(struct nvme_mgmt_addr_list_log *ma_list)
+{
+       int i;
+       bool reserved = true;
+       struct json_object *r = json_create_object();
+       struct json_object *mad;
+       struct json_object *mat;
+       char json_str[STR_LEN];
+
+       for (i = 0; i < ARRAY_SIZE(ma_list->mad); i++) {
+               switch (ma_list->mad[i].mat) {
+               case 1:
+               case 2:
+                       mad = json_create_object();
+                       mat = json_create_object();
+                       obj_add_str(mat, "definition", ma_list->mad[i].mat == 1 ?
+                                   "NVM subsystem management agent" : "fabric interface manager");
+                       snprintf(json_str, sizeof(json_str), "type: %d", ma_list->mad[i].mat);
+                       obj_add_obj(mad, json_str, mat);
+                       obj_add_str(mad, "address", (const char *)ma_list->mad[i].madrs);
+                       snprintf(json_str, sizeof(json_str), "descriptor: %d", i);
+                       obj_add_obj(r, json_str, mad);
+                       reserved = false;
+                       break;
+               case 0xff:
+                       goto out;
+               default:
+                       break;
+               }
+       }
+
+out:
+       if (reserved)
+               obj_add_str(r, "list", "All management address descriptors reserved");
+
+       json_print(r);
+}
+
 static struct print_ops json_print_ops = {
        /* libnvme types.h print functions */
        .ana_log                        = json_ana_log,
@@ -4658,6 +4696,7 @@ static struct print_ops json_print_ops = {
        .d                              = json_d,
        .show_init                      = json_show_init,
        .show_finish                    = json_show_finish,
+       .mgmt_addr_list_log             = json_mgmt_addr_list_log,
 
        /* libnvme tree print functions */
        .list_item                      = json_list_item,