diff --git a/Documentation/nvme-pull-model-ddr-req-log.txt b/Documentation/nvme-pull-model-ddr-req-log.txt new file mode 100644 index 0000000000..dce5e5674e --- /dev/null +++ b/Documentation/nvme-pull-model-ddr-req-log.txt @@ -0,0 +1,51 @@ +nvme-pull-model-ddr-req-log(1) +============================== + +NAME +---- +nvme-pull-model-ddr-req-log - Retrieve Pull Model DDC Request Log, show it + +SYNOPSIS +-------- +[verse] +'nvme pull-model-ddr-req-log' [--rae | -r] [--verbose | -v] + [--output-format= | -o ] [--timeout=] + +DESCRIPTION +----------- +Retrieve Pull Model DDC Request Log, show it + +The parameter is mandatory NVMe character device (ex: /dev/nvme0). + +On success it returns 0, error code otherwise. + +OPTIONS +------- +-r:: +--rae:: + Retain an Asynchronous Event. + +-v:: +--verbose:: + Increase the information detail in the output. + +-o :: +--output-format=:: + Set the reporting format to 'normal', 'json' or 'binary'. Only one + output format can be used at a time. + +-t :: +--timeout=:: + Override default timeout value. In milliseconds. + +EXAMPLES +-------- +* Has the program issue a pull-model-ddr-req-log ++ +------------ +# nvme pull-model-ddr-req-log /dev/nvme0 +------------ + +NVME +---- +Part of the nvme-user suite. diff --git a/completions/_nvme b/completions/_nvme index 0a0b5a883f..157555b461 100644 --- a/completions/_nvme +++ b/completions/_nvme @@ -117,6 +117,7 @@ _nvme () { 'reachability-associations-log:retrieve reachability associations log' 'host-discovery-log:retrieve host discovery log' 'ave-discovery-log:retrieve ave discovery log' + 'pull-model-ddr-req-log:retrieve pull model ddr req log' 'version:show the program version' 'ocp:OCP cloud SSD extensions' 'solidigm:Solidigm plug-in extensions' @@ -2774,6 +2775,22 @@ _nvme () { _arguments '*:: :->subcmds' _describe -t commands "nvme ave-discovery-log" _ad_log ;; + (pull-model-ddr-req-log) + local _pmdr_log + _pmdr_log=( + /dev/nvme':supply a device to use (required)' + --rae':Retain an Asynchronous Event' + -r':alias for --rae' + --verbose':Increase the information detail in the output.' + -v':alias for --verbose' + --output-format=':Output format: normal|json|binary' + -o ':alias for --output-format' + --timeout=':value for timeout' + -t ':alias for --timeout' + ) + _arguments '*:: :->subcmds' + _describe -t commands "nvme pull-model-ddr-req-log" _pmdr_log + ;; (version) local _version _version=( diff --git a/completions/bash-nvme-completion.sh b/completions/bash-nvme-completion.sh index 2235c50863..6b870c97ff 100644 --- a/completions/bash-nvme-completion.sh +++ b/completions/bash-nvme-completion.sh @@ -517,6 +517,10 @@ nvme_list_opts () { --output-format= -o --timeout= -t" ;; "ave-discovery-log") + opts+=" --rae -r --verbose -v --output-format= -o \ + --timeout= -t" + ;; + "pull--ddc-req-log") opts+=" --rae -r --verbose -v --output-format= -o \ --timeout= -t" ;; @@ -1751,7 +1755,7 @@ _nvme_subcmds () { rotational-media-info-log changed-alloc-ns-list-log \ io-mgmt-recv io-mgmt-send dispersed-ns-participating-nss-log \ reachability-groups-log reachability-associations-log \ - host-discovery-log ave-discovery-log" + host-discovery-log ave-discovery-log pull--ddc-req-log" # Add plugins: for plugin in "${!_plugin_subcmds[@]}"; do diff --git a/nvme-builtin.h b/nvme-builtin.h index beec920019..684f3fdfcb 100644 --- a/nvme-builtin.h +++ b/nvme-builtin.h @@ -66,6 +66,7 @@ COMMAND_LIST( 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) diff --git a/nvme-print-binary.c b/nvme-print-binary.c index bd425f31b0..17dfb8511d 100644 --- a/nvme-print-binary.c +++ b/nvme-print-binary.c @@ -342,6 +342,11 @@ static void binary_ave_discovery_log(struct nvme_ave_discover_log *log) 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, @@ -415,6 +420,7 @@ static struct print_ops binary_print_ops = { .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, diff --git a/nvme-print-json.c b/nvme-print-json.c index 13b3c6cf0e..ff34304f6b 100644 --- a/nvme-print-json.c +++ b/nvme-print-json.c @@ -4904,6 +4904,17 @@ static void json_ave_discovery_log(struct nvme_ave_discover_log *log) } } +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, @@ -4978,6 +4989,7 @@ static struct print_ops json_print_ops = { .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, diff --git a/nvme-print-stdout.c b/nvme-print-stdout.c index e10bd11fbc..f341093dc5 100644 --- a/nvme-print-stdout.c +++ b/nvme-print-stdout.c @@ -5836,6 +5836,17 @@ static void stdout_ave_discovery_log(struct nvme_ave_discover_log *log) } } +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, @@ -5910,6 +5921,7 @@ static struct print_ops stdout_print_ops = { .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, diff --git a/nvme-print.c b/nvme-print.c index a025fa2216..8492225e7f 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -1530,3 +1530,9 @@ void nvme_show_ave_discovery_log(struct nvme_ave_discover_log *log, nvme_print_f { 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); +} diff --git a/nvme-print.h b/nvme-print.h index 93c6fc8e2d..ad5d4c829b 100644 --- a/nvme-print.h +++ b/nvme-print.h @@ -96,6 +96,7 @@ struct print_ops { __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); @@ -349,4 +350,6 @@ void nvme_show_reachability_associations_log(struct nvme_reachability_associatio __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 */ diff --git a/nvme-wrap.c b/nvme-wrap.c index 64b71eaa6d..ca240280df 100644 --- a/nvme-wrap.c +++ b/nvme-wrap.c @@ -481,3 +481,9 @@ int nvme_cli_get_log_ave_discovery(struct nvme_dev *dev, bool rae, __u32 len, { 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); +} diff --git a/nvme-wrap.h b/nvme-wrap.h index d82bbd919a..43f4f8082c 100644 --- a/nvme-wrap.h +++ b/nvme-wrap.h @@ -168,4 +168,7 @@ int nvme_cli_get_log_host_discovery(struct nvme_dev *dev, bool allhoste, bool ra 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 */ diff --git a/nvme.c b/nvme.c index 5b722e6ec1..7c3070a0a4 100644 --- a/nvme.c +++ b/nvme.c @@ -10713,8 +10713,7 @@ static int get_host_discovery_log(int argc, char **argv, struct command *cmd, st return err; } -static int get_ave_discovery(struct nvme_dev *dev, bool rae, - struct nvme_ave_discover_log **logp) +static int get_ave_discovery(struct nvme_dev *dev, bool rae, struct nvme_ave_discover_log **logp) { int err; struct nvme_ave_discover_log *log; @@ -10723,7 +10722,7 @@ static int get_ave_discovery(struct nvme_dev *dev, bool rae, .args_size = sizeof(args), .fd = dev_fd(dev), .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, - .lid = NVME_LOG_LID_HOST_DISCOVER, + .lid = NVME_LOG_LID_AVE_DISCOVER, .nsid = NVME_NSID_ALL, .rae = rae, }; @@ -10791,6 +10790,85 @@ static int get_ave_discovery_log(int argc, char **argv, struct command *cmd, str 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;