Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions Documentation/nvme-pull-model-ddr-req-log.txt
Original file line number Diff line number Diff line change
@@ -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' <device> [--rae | -r] [--verbose | -v]
[--output-format=<fmt> | -o <fmt>] [--timeout=<timeout>]

DESCRIPTION
-----------
Retrieve Pull Model DDC Request Log, show it

The <device> 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 <fmt>::
--output-format=<fmt>::
Set the reporting format to 'normal', 'json' or 'binary'. Only one
output format can be used at a time.

-t <timeout>::
--timeout=<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.
17 changes: 17 additions & 0 deletions completions/_nvme
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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=(
Expand Down
6 changes: 5 additions & 1 deletion completions/bash-nvme-completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
;;
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions nvme-builtin.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
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)

Check failure on line 69 in nvme-builtin.h

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: line length of 115 exceeds 100 columns
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)
Expand Down
6 changes: 6 additions & 0 deletions nvme-print-binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions nvme-print-json.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions nvme-print-stdout.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions nvme-print.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
3 changes: 3 additions & 0 deletions nvme-print.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 */
6 changes: 6 additions & 0 deletions nvme-wrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
3 changes: 3 additions & 0 deletions nvme-wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
84 changes: 81 additions & 3 deletions nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
};
Expand Down Expand Up @@ -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;
Expand Down