Skip to content

Commit 3d8fdb9

Browse files
committed
nvme-print-json: add json_mgmt_addr_list_log()
Since added the NVMe 2.1 log page. Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
1 parent efdb01c commit 3d8fdb9

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

nvme-print-json.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4585,6 +4585,44 @@ void json_show_finish(void)
45854585
json_r = NULL;
45864586
}
45874587

4588+
static void json_mgmt_addr_list_log(struct nvme_mgmt_addr_list_log *ma_list)
4589+
{
4590+
int i;
4591+
bool reserved = true;
4592+
struct json_object *r = json_create_object();
4593+
struct json_object *mad;
4594+
struct json_object *mat;
4595+
char json_str[STR_LEN];
4596+
4597+
for (i = 0; i < ARRAY_SIZE(ma_list->mad); i++) {
4598+
switch (ma_list->mad[i].mat) {
4599+
case 1:
4600+
case 2:
4601+
mad = json_create_object();
4602+
mat = json_create_object();
4603+
obj_add_str(mat, "definition", ma_list->mad[i].mat == 1 ?
4604+
"NVM subsystem management agent" : "fabric interface manager");
4605+
snprintf(json_str, sizeof(json_str), "type: %d", ma_list->mad[i].mat);
4606+
obj_add_obj(mad, json_str, mat);
4607+
obj_add_str(mad, "address", (const char *)ma_list->mad[i].madrs);
4608+
snprintf(json_str, sizeof(json_str), "descriptor: %d", i);
4609+
obj_add_obj(r, json_str, mad);
4610+
reserved = false;
4611+
break;
4612+
case 0xff:
4613+
goto out;
4614+
default:
4615+
break;
4616+
}
4617+
}
4618+
4619+
out:
4620+
if (reserved)
4621+
obj_add_str(r, "list", "All management address descriptors reserved");
4622+
4623+
json_print(r);
4624+
}
4625+
45884626
static struct print_ops json_print_ops = {
45894627
/* libnvme types.h print functions */
45904628
.ana_log = json_ana_log,
@@ -4652,6 +4690,7 @@ static struct print_ops json_print_ops = {
46524690
.d = json_d,
46534691
.show_init = json_show_init,
46544692
.show_finish = json_show_finish,
4693+
.mgmt_addr_list_log = json_mgmt_addr_list_log,
46554694

46564695
/* libnvme tree print functions */
46574696
.list_item = json_list_item,

0 commit comments

Comments
 (0)