Since added the NVMe 2.1 log page.
Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
ENTRY("reachability-associations-log", "Retrieve Reachability Associations Log, show it", get_reachability_associations_log)
ENTRY("host-discovery-log", "Retrieve Host Discovery Log, show it", get_host_discovery_log)
ENTRY("ave-discovery-log", "Retrieve AVE Discovery Log, show it", get_ave_discovery_log)
+ ENTRY("pull-model-ddc-req-log", "Retrieve Pull Model DDC Request Log, show it", get_pull_model_ddc_req_log)
ENTRY("set-feature", "Set a feature and show the resulting value", set_feature)
ENTRY("set-property", "Set a property and show the resulting value", set_property)
ENTRY("get-property", "Get a property and show the resulting value", get_property)
d_raw((unsigned char *)log, le32_to_cpu(log->tadlpl));
}
+static void binary_pull_model_ddc_req_log(struct nvme_pull_model_ddc_req_log *log)
+{
+ d_raw((unsigned char *)log, le32_to_cpu(log->tpdrpl));
+}
+
static struct print_ops binary_print_ops = {
/* libnvme types.h print functions */
.ana_log = binary_ana_log,
.reachability_associations_log = binary_reachability_associations_log,
.host_discovery_log = binary_host_discovery_log,
.ave_discovery_log = binary_ave_discovery_log,
+ .pull_model_ddc_req_log = binary_pull_model_ddc_req_log,
/* libnvme tree print functions */
.list_item = NULL,
}
}
+static void json_pull_model_ddc_req_log(struct nvme_pull_model_ddc_req_log *log)
+{
+ struct json_object *r = json_create_object();
+ __u32 tpdrpl = le32_to_cpu(log->tpdrpl);
+ __u32 osp_len = tpdrpl - offsetof(struct nvme_pull_model_ddc_req_log, osp);
+
+ obj_add_uint(r, "ori", log->ori);
+ printf("tpdrpl: %u\n", tpdrpl);
+ obj_d(r, "osp", (unsigned char *)log->osp, osp_len, 16, 1);
+}
+
static struct print_ops json_print_ops = {
/* libnvme types.h print functions */
.ana_log = json_ana_log,
.reachability_associations_log = json_reachability_associations_log,
.host_discovery_log = json_host_discovery_log,
.ave_discovery_log = json_ave_discovery_log,
+ .pull_model_ddc_req_log = json_pull_model_ddc_req_log,
/* libnvme tree print functions */
.list_item = json_list_item,
}
}
+static void stdout_pull_model_ddc_req_log(struct nvme_pull_model_ddc_req_log *log)
+{
+ __u32 tpdrpl = le32_to_cpu(log->tpdrpl);
+ __u32 osp_len = tpdrpl - offsetof(struct nvme_pull_model_ddc_req_log, osp);
+
+ printf("ori: %u\n", log->ori);
+ printf("tpdrpl: %u\n", tpdrpl);
+ printf("osp:\n");
+ d((unsigned char *)log->osp, osp_len, 16, 1);
+}
+
static struct print_ops stdout_print_ops = {
/* libnvme types.h print functions */
.ana_log = stdout_ana_log,
.reachability_associations_log = stdout_reachability_associations_log,
.host_discovery_log = stdout_host_discovery_log,
.ave_discovery_log = stdout_ave_discovery_log,
+ .pull_model_ddc_req_log = stdout_pull_model_ddc_req_log,
/* libnvme tree print functions */
.list_item = stdout_list_item,
{
nvme_print(ave_discovery_log, flags, log);
}
+
+void nvme_show_pull_model_ddc_req_log(struct nvme_pull_model_ddc_req_log *log,
+ nvme_print_flags_t flags)
+{
+ nvme_print(pull_model_ddc_req_log, flags, log);
+}
__u64 len);
void (*host_discovery_log)(struct nvme_host_discover_log *log);
void (*ave_discovery_log)(struct nvme_ave_discover_log *log);
+ void (*pull_model_ddc_req_log)(struct nvme_pull_model_ddc_req_log *log);
/* libnvme tree print functions */
void (*list_item)(nvme_ns_t n);
__u64 len, nvme_print_flags_t flags);
void nvme_show_host_discovery_log(struct nvme_host_discover_log *log, nvme_print_flags_t flags);
void nvme_show_ave_discovery_log(struct nvme_ave_discover_log *log, nvme_print_flags_t flags);
+void nvme_show_pull_model_ddc_req_log(struct nvme_pull_model_ddc_req_log *log,
+ nvme_print_flags_t flags);
#endif /* NVME_PRINT_H */
{
return do_admin_op(get_log_ave_discover, dev, rae, len, log);
}
+
+int nvme_cli_get_log_pull_model_ddc_req(struct nvme_dev *dev, bool rae, __u32 len,
+ struct nvme_pull_model_ddc_req_log *log)
+{
+ return do_admin_op(get_log_pull_model_ddc_req, dev, rae, len, log);
+}
int nvme_cli_get_log_ave_discovery(struct nvme_dev *dev, bool rae, __u32 len,
struct nvme_ave_discover_log *log);
+
+int nvme_cli_get_log_pull_model_ddc_req(struct nvme_dev *dev, bool rae, __u32 len,
+ struct nvme_pull_model_ddc_req_log *log);
#endif /* _NVME_WRAP_H */
return err;
}
+static int get_pull_model_ddc_req(struct nvme_dev *dev,
+ bool rae, struct nvme_pull_model_ddc_req_log **logp)
+{
+ int err;
+ struct nvme_pull_model_ddc_req_log *log;
+ __u64 log_len = sizeof(*log);
+ struct nvme_get_log_args args = {
+ .args_size = sizeof(args),
+ .fd = dev_fd(dev),
+ .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
+ .lid = NVME_LOG_LID_PULL_MODEL_DDC_REQ,
+ .nsid = NVME_NSID_ALL,
+ .rae = rae,
+ };
+
+ log = nvme_alloc(log_len);
+ if (!log)
+ return -ENOMEM;
+
+ err = nvme_cli_get_log_pull_model_ddc_req(dev, rae, log_len, log);
+ if (err)
+ goto err_free;
+
+ log_len = le32_to_cpu(log->tpdrpl);
+ err = get_log_offset(dev, &args, &log_len, le32_to_cpu(log->tpdrpl) - log_len,
+ (void **)&log);
+ if (err)
+ goto err_free;
+
+ *logp = log;
+ return 0;
+
+err_free:
+ free(log);
+ return err;
+}
+
+static int get_pull_model_ddc_req_log(int argc, char **argv, struct command *cmd,
+ struct plugin *plugin)
+{
+ const char *desc = "Retrieve Pull Model DDC Request Log, show it";
+ nvme_print_flags_t flags;
+ int err;
+
+ _cleanup_free_ struct nvme_pull_model_ddc_req_log *log = NULL;
+
+ _cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
+
+ struct config {
+ bool rae;
+ };
+
+ struct config cfg = {
+ .rae = false,
+ };
+
+ NVME_ARGS(opts, OPT_FLAG("rae", 'r', &cfg.rae, rae));
+
+ err = parse_and_open(&dev, argc, argv, desc, opts);
+ if (err)
+ return err;
+
+ err = validate_output_format(nvme_cfg.output_format, &flags);
+ if (err < 0) {
+ nvme_show_error("Invalid output format");
+ return err;
+ }
+
+ err = get_pull_model_ddc_req(dev, cfg.rae, &log);
+ if (!err)
+ nvme_show_pull_model_ddc_req_log(log, flags);
+ else if (err > 0)
+ nvme_show_status(err);
+ else
+ nvme_show_perror("pull model ddc req log");
+
+ return err;
+}
+
void register_extension(struct plugin *plugin)
{
plugin->parent = &nvme;