Skip to content

Commit 14a7755

Browse files
committed
nvme: add mgmt-addr-list-log command
Since added the NVMe 2.1 log page. Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
1 parent 37c8e05 commit 14a7755

File tree

7 files changed

+82
-0
lines changed

7 files changed

+82
-0
lines changed

nvme-builtin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ COMMAND_LIST(
5858
ENTRY("mi-cmd-support-effects-log", "Retrieve MI Command Support and Effects log and show it", get_mi_cmd_support_effects_log)
5959
ENTRY("media-unit-stat-log", "Retrieve the configuration and wear of media units, show it", get_media_unit_stat_log)
6060
ENTRY("supported-cap-config-log", "Retrieve the list of Supported Capacity Configuration Descriptors", get_supp_cap_config_log)
61+
ENTRY("mgmt-addr-list-log", "Retrieve Management Address List Log, show it", get_mgmt_addr_list_log)
6162
ENTRY("set-feature", "Set a feature and show the resulting value", set_feature)
6263
ENTRY("set-property", "Set a property and show the resulting value", set_property)
6364
ENTRY("get-property", "Get a property and show the resulting value", get_property)

nvme-print-stdout.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5509,6 +5509,33 @@ static void stdout_connect_msg(nvme_ctrl_t c)
55095509
printf("connecting to device: %s\n", nvme_ctrl_get_name(c));
55105510
}
55115511

5512+
static void stdout_mgmt_addr_list_log(struct nvme_mgmt_addr_list_log *ma_list)
5513+
{
5514+
int i;
5515+
bool reserved = true;
5516+
5517+
printf("Management Address List:\n");
5518+
for (i = 0; i < ARRAY_SIZE(ma_list->mad); i++) {
5519+
switch (ma_list->mad[i].mat) {
5520+
case 1:
5521+
case 2:
5522+
printf("Descriptor: %d, Type: %d (%s), Address: %s\n", i,
5523+
ma_list->mad[i].mat,
5524+
ma_list->mad[i].mat == 1 ? "NVM subsystem management agent" :
5525+
"fabric interface manager", ma_list->mad[i].madrs);
5526+
reserved = false;
5527+
break;
5528+
case 0xff:
5529+
goto out;
5530+
default:
5531+
break;
5532+
}
5533+
}
5534+
out:
5535+
if (reserved)
5536+
printf("All management address descriptors reserved\n");
5537+
}
5538+
55125539
static struct print_ops stdout_print_ops = {
55135540
/* libnvme types.h print functions */
55145541
.ana_log = stdout_ana_log,
@@ -5576,6 +5603,7 @@ static struct print_ops stdout_print_ops = {
55765603
.d = stdout_d,
55775604
.show_init = NULL,
55785605
.show_finish = NULL,
5606+
.mgmt_addr_list_log = stdout_mgmt_addr_list_log,
55795607

55805608
/* libnvme tree print functions */
55815609
.list_item = stdout_list_item,

nvme-print.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,3 +1440,8 @@ void nvme_show_finish(void)
14401440
{
14411441
nvme_print_output_format(show_finish);
14421442
}
1443+
1444+
void nvme_show_mgmt_addr_list_log(struct nvme_mgmt_addr_list_log *ma_list, nvme_print_flags_t flags)
1445+
{
1446+
nvme_print(mgmt_addr_list_log, flags, ma_list);
1447+
}

nvme-print.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ struct print_ops {
8888
void (*d)(unsigned char *buf, int len, int width, int group);
8989
void (*show_init)(void);
9090
void (*show_finish)(void);
91+
void (*mgmt_addr_list_log)(struct nvme_mgmt_addr_list_log *ma_log);
9192

9293
/* libnvme tree print functions */
9394
void (*list_item)(nvme_ns_t n);
@@ -327,4 +328,6 @@ const char *nvme_degrees_string(long t);
327328
void print_array(char *name, __u8 *data, int size);
328329
void json_print(struct json_object *r);
329330
struct json_object *obj_create_array_obj(struct json_object *o, const char *k);
331+
void nvme_show_mgmt_addr_list_log(struct nvme_mgmt_addr_list_log *ma_list,
332+
nvme_print_flags_t flags);
330333
#endif /* NVME_PRINT_H */

nvme-wrap.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,3 +430,9 @@ int nvme_cli_security_receive(struct nvme_dev *dev,
430430

431431
return -ENODEV;
432432
}
433+
434+
int nvme_cli_get_log_mgmt_addr_list(struct nvme_dev *dev, __u32 len,
435+
struct nvme_mgmt_addr_list_log *ma_list)
436+
{
437+
return do_admin_op(get_log_mgmt_addr_list, dev, len, ma_list);
438+
}

nvme-wrap.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,7 @@ int nvme_cli_security_send(struct nvme_dev *dev,
146146
int nvme_cli_security_receive(struct nvme_dev *dev,
147147
struct nvme_security_receive_args* args);
148148

149+
int nvme_cli_get_log_mgmt_addr_list(struct nvme_dev *dev, __u32 len,
150+
struct nvme_mgmt_addr_list_log *ma_list);
151+
149152
#endif /* _NVME_WRAP_H */

nvme.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9962,6 +9962,42 @@ static int nmi_send(int argc, char **argv, struct command *cmd, struct plugin *p
99629962
return nvme_mi(argc, argv, nvme_admin_nvme_mi_send, desc);
99639963
}
99649964

9965+
static int get_mgmt_addr_list_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)
9966+
{
9967+
const char *desc = "Retrieve Management Address List Log, show it";
9968+
9969+
_cleanup_free_ struct nvme_mgmt_addr_list_log *ma_log = NULL;
9970+
_cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
9971+
nvme_print_flags_t flags;
9972+
int err = -1;
9973+
9974+
NVME_ARGS(opts);
9975+
9976+
err = parse_and_open(&dev, argc, argv, desc, opts);
9977+
if (err)
9978+
return err;
9979+
9980+
err = validate_output_format(nvme_cfg.output_format, &flags);
9981+
if (err < 0) {
9982+
nvme_show_error("Invalid output format");
9983+
return err;
9984+
}
9985+
9986+
ma_log = nvme_alloc(sizeof(*ma_log));
9987+
if (!ma_log)
9988+
return -ENOMEM;
9989+
9990+
err = nvme_cli_get_log_mgmt_addr_list(dev, sizeof(struct nvme_mgmt_addr_list_log), ma_log);
9991+
if (!err)
9992+
nvme_show_mgmt_addr_list_log(ma_log, flags);
9993+
else if (err > 0)
9994+
nvme_show_status(err);
9995+
else
9996+
nvme_show_perror("management address list log");
9997+
9998+
return err;
9999+
}
10000+
996510001
void register_extension(struct plugin *plugin)
996610002
{
996710003
plugin->parent = &nvme;

0 commit comments

Comments
 (0)