Skip to content

Commit f61f090

Browse files
committed
nvme: add pull-model-ddc-req-log command
Since added the NVMe 2.1 log page. Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
1 parent 703daad commit f61f090

9 files changed

+128
-0
lines changed

nvme-builtin.h

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ COMMAND_LIST(
6666
ENTRY("reachability-associations-log", "Retrieve Reachability Associations Log, show it", get_reachability_associations_log)
6767
ENTRY("host-discovery-log", "Retrieve Host Discovery Log, show it", get_host_discovery_log)
6868
ENTRY("ave-discovery-log", "Retrieve AVE Discovery Log, show it", get_ave_discovery_log)
69+
ENTRY("pull-model-ddc-req-log", "Retrieve Pull Model DDC Request Log, show it", get_pull_model_ddc_req_log)
6970
ENTRY("set-feature", "Set a feature and show the resulting value", set_feature)
7071
ENTRY("set-property", "Set a property and show the resulting value", set_property)
7172
ENTRY("get-property", "Get a property and show the resulting value", get_property)

nvme-print-binary.c

+6
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,11 @@ static void binary_ave_discovery_log(struct nvme_ave_discover_log *log)
342342
d_raw((unsigned char *)log, le32_to_cpu(log->tadlpl));
343343
}
344344

345+
static void binary_pull_model_ddc_req_log(struct nvme_pull_model_ddc_req_log *log)
346+
{
347+
d_raw((unsigned char *)log, le32_to_cpu(log->tpdrpl));
348+
}
349+
345350
static struct print_ops binary_print_ops = {
346351
/* libnvme types.h print functions */
347352
.ana_log = binary_ana_log,
@@ -415,6 +420,7 @@ static struct print_ops binary_print_ops = {
415420
.reachability_associations_log = binary_reachability_associations_log,
416421
.host_discovery_log = binary_host_discovery_log,
417422
.ave_discovery_log = binary_ave_discovery_log,
423+
.pull_model_ddc_req_log = binary_pull_model_ddc_req_log,
418424

419425
/* libnvme tree print functions */
420426
.list_item = NULL,

nvme-print-json.c

+12
Original file line numberDiff line numberDiff line change
@@ -4904,6 +4904,17 @@ static void json_ave_discovery_log(struct nvme_ave_discover_log *log)
49044904
}
49054905
}
49064906

4907+
static void json_pull_model_ddc_req_log(struct nvme_pull_model_ddc_req_log *log)
4908+
{
4909+
struct json_object *r = json_create_object();
4910+
__u32 tpdrpl = le32_to_cpu(log->tpdrpl);
4911+
__u32 osp_len = tpdrpl - offsetof(struct nvme_pull_model_ddc_req_log, osp);
4912+
4913+
obj_add_uint(r, "ori", log->ori);
4914+
printf("tpdrpl: %u\n", tpdrpl);
4915+
obj_d(r, "osp", (unsigned char *)log->osp, osp_len, 16, 1);
4916+
}
4917+
49074918
static struct print_ops json_print_ops = {
49084919
/* libnvme types.h print functions */
49094920
.ana_log = json_ana_log,
@@ -4978,6 +4989,7 @@ static struct print_ops json_print_ops = {
49784989
.reachability_associations_log = json_reachability_associations_log,
49794990
.host_discovery_log = json_host_discovery_log,
49804991
.ave_discovery_log = json_ave_discovery_log,
4992+
.pull_model_ddc_req_log = json_pull_model_ddc_req_log,
49814993

49824994
/* libnvme tree print functions */
49834995
.list_item = json_list_item,

nvme-print-stdout.c

+12
Original file line numberDiff line numberDiff line change
@@ -5836,6 +5836,17 @@ static void stdout_ave_discovery_log(struct nvme_ave_discover_log *log)
58365836
}
58375837
}
58385838

5839+
static void stdout_pull_model_ddc_req_log(struct nvme_pull_model_ddc_req_log *log)
5840+
{
5841+
__u32 tpdrpl = le32_to_cpu(log->tpdrpl);
5842+
__u32 osp_len = tpdrpl - offsetof(struct nvme_pull_model_ddc_req_log, osp);
5843+
5844+
printf("ori: %u\n", log->ori);
5845+
printf("tpdrpl: %u\n", tpdrpl);
5846+
printf("osp:\n");
5847+
d((unsigned char *)log->osp, osp_len, 16, 1);
5848+
}
5849+
58395850
static struct print_ops stdout_print_ops = {
58405851
/* libnvme types.h print functions */
58415852
.ana_log = stdout_ana_log,
@@ -5910,6 +5921,7 @@ static struct print_ops stdout_print_ops = {
59105921
.reachability_associations_log = stdout_reachability_associations_log,
59115922
.host_discovery_log = stdout_host_discovery_log,
59125923
.ave_discovery_log = stdout_ave_discovery_log,
5924+
.pull_model_ddc_req_log = stdout_pull_model_ddc_req_log,
59135925

59145926
/* libnvme tree print functions */
59155927
.list_item = stdout_list_item,

nvme-print.c

+6
Original file line numberDiff line numberDiff line change
@@ -1530,3 +1530,9 @@ void nvme_show_ave_discovery_log(struct nvme_ave_discover_log *log, nvme_print_f
15301530
{
15311531
nvme_print(ave_discovery_log, flags, log);
15321532
}
1533+
1534+
void nvme_show_pull_model_ddc_req_log(struct nvme_pull_model_ddc_req_log *log,
1535+
nvme_print_flags_t flags)
1536+
{
1537+
nvme_print(pull_model_ddc_req_log, flags, log);
1538+
}

nvme-print.h

+3
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ struct print_ops {
9696
__u64 len);
9797
void (*host_discovery_log)(struct nvme_host_discover_log *log);
9898
void (*ave_discovery_log)(struct nvme_ave_discover_log *log);
99+
void (*pull_model_ddc_req_log)(struct nvme_pull_model_ddc_req_log *log);
99100

100101
/* libnvme tree print functions */
101102
void (*list_item)(nvme_ns_t n);
@@ -349,4 +350,6 @@ void nvme_show_reachability_associations_log(struct nvme_reachability_associatio
349350
__u64 len, nvme_print_flags_t flags);
350351
void nvme_show_host_discovery_log(struct nvme_host_discover_log *log, nvme_print_flags_t flags);
351352
void nvme_show_ave_discovery_log(struct nvme_ave_discover_log *log, nvme_print_flags_t flags);
353+
void nvme_show_pull_model_ddc_req_log(struct nvme_pull_model_ddc_req_log *log,
354+
nvme_print_flags_t flags);
352355
#endif /* NVME_PRINT_H */

nvme-wrap.c

+6
Original file line numberDiff line numberDiff line change
@@ -481,3 +481,9 @@ int nvme_cli_get_log_ave_discovery(struct nvme_dev *dev, bool rae, __u32 len,
481481
{
482482
return do_admin_op(get_log_ave_discover, dev, rae, len, log);
483483
}
484+
485+
int nvme_cli_get_log_pull_model_ddc_req(struct nvme_dev *dev, bool rae, __u32 len,
486+
struct nvme_pull_model_ddc_req_log *log)
487+
{
488+
return do_admin_op(get_log_pull_model_ddc_req, dev, rae, len, log);
489+
}

nvme-wrap.h

+3
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,7 @@ int nvme_cli_get_log_host_discovery(struct nvme_dev *dev, bool allhoste, bool ra
168168

169169
int nvme_cli_get_log_ave_discovery(struct nvme_dev *dev, bool rae, __u32 len,
170170
struct nvme_ave_discover_log *log);
171+
172+
int nvme_cli_get_log_pull_model_ddc_req(struct nvme_dev *dev, bool rae, __u32 len,
173+
struct nvme_pull_model_ddc_req_log *log);
171174
#endif /* _NVME_WRAP_H */

nvme.c

+79
Original file line numberDiff line numberDiff line change
@@ -10790,6 +10790,85 @@ static int get_ave_discovery_log(int argc, char **argv, struct command *cmd, str
1079010790
return err;
1079110791
}
1079210792

10793+
static int get_pull_model_ddc_req(struct nvme_dev *dev,
10794+
bool rae, struct nvme_pull_model_ddc_req_log **logp)
10795+
{
10796+
int err;
10797+
struct nvme_pull_model_ddc_req_log *log;
10798+
__u64 log_len = sizeof(*log);
10799+
struct nvme_get_log_args args = {
10800+
.args_size = sizeof(args),
10801+
.fd = dev_fd(dev),
10802+
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
10803+
.lid = NVME_LOG_LID_PULL_MODEL_DDC_REQ,
10804+
.nsid = NVME_NSID_ALL,
10805+
.rae = rae,
10806+
};
10807+
10808+
log = nvme_alloc(log_len);
10809+
if (!log)
10810+
return -ENOMEM;
10811+
10812+
err = nvme_cli_get_log_pull_model_ddc_req(dev, rae, log_len, log);
10813+
if (err)
10814+
goto err_free;
10815+
10816+
log_len = le32_to_cpu(log->tpdrpl);
10817+
err = get_log_offset(dev, &args, &log_len, le32_to_cpu(log->tpdrpl) - log_len,
10818+
(void **)&log);
10819+
if (err)
10820+
goto err_free;
10821+
10822+
*logp = log;
10823+
return 0;
10824+
10825+
err_free:
10826+
free(log);
10827+
return err;
10828+
}
10829+
10830+
static int get_pull_model_ddc_req_log(int argc, char **argv, struct command *cmd,
10831+
struct plugin *plugin)
10832+
{
10833+
const char *desc = "Retrieve Pull Model DDC Request Log, show it";
10834+
nvme_print_flags_t flags;
10835+
int err;
10836+
10837+
_cleanup_free_ struct nvme_pull_model_ddc_req_log *log = NULL;
10838+
10839+
_cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
10840+
10841+
struct config {
10842+
bool rae;
10843+
};
10844+
10845+
struct config cfg = {
10846+
.rae = false,
10847+
};
10848+
10849+
NVME_ARGS(opts, OPT_FLAG("rae", 'r', &cfg.rae, rae));
10850+
10851+
err = parse_and_open(&dev, argc, argv, desc, opts);
10852+
if (err)
10853+
return err;
10854+
10855+
err = validate_output_format(nvme_cfg.output_format, &flags);
10856+
if (err < 0) {
10857+
nvme_show_error("Invalid output format");
10858+
return err;
10859+
}
10860+
10861+
err = get_pull_model_ddc_req(dev, cfg.rae, &log);
10862+
if (!err)
10863+
nvme_show_pull_model_ddc_req_log(log, flags);
10864+
else if (err > 0)
10865+
nvme_show_status(err);
10866+
else
10867+
nvme_show_perror("pull model ddc req log");
10868+
10869+
return err;
10870+
}
10871+
1079310872
void register_extension(struct plugin *plugin)
1079410873
{
1079510874
plugin->parent = &nvme;

0 commit comments

Comments
 (0)