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
62 changes: 62 additions & 0 deletions Documentation/nvme-ocp-get-telemetry-profile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
nvme-ocp-get-telemetry-profile(1)
=========================================

NAME
----
nvme-ocp-get-telemetry-profile - Define and print get-telemetry-profile value

SYNOPSIS
--------
[verse]
'nvme ocp get-telemetry-profile' <device> [--sel=<select> | -s <select>]
[--namespace-id <nsid> | -n <nsid>] [--no-uuid | -u]

DESCRIPTION
-----------
The <device> parameter is mandatory and may be either the NVMe character
device (ex: /dev/nvme0) or block device (ex: /dev/nvme0n1).

This will only work on OCP compliant devices supporting this feature.
Results for any other device are undefined.

On success it returns 0, error code otherwise.

OPTIONS
-------
-n <nsid>::
--namespace-id=<nsid>::
NSID: Assign the different kind of nsid value(like
active, inactive and invalid nsids) and check
the get feature command response:

-s <select>::
--sel=<select>::
Select (SEL): This field specifies which value of the attributes
to return in the provided data:
+
[]
|==================
|Select|Description
|0|Current
|1|Default
|2|Saved
|3|Supported capabilities
|4-7|Reserved
|==================

-u::
--no-uuid::
Do not try to automatically detect UUID index for this command (required
for old OCP 1.0 support)

EXAMPLES
--------
* Has the program issue a get-telemetry-profile to retrieve the 0xC8 get features.
+
------------
# nvme ocp get-telemetry-profile /dev/nvme0
------------

NVME
----
Part of the nvme-user suite.
15 changes: 15 additions & 0 deletions completions/_nvme
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,20 @@ _nvme () {
_arguments '*:: :->subcmds'
_describe -t commands "nvme ocp get-clear-pcie-correctable-errors options" _get_clear_pcie_correctable_error_counters
;;
(get-telemetry-profile)
local _ocp_get_telemetry_profile_feature
_ocp_get_telemetry_profile_feature=(
/dev/nvme':supply a device to use (required)'
--sel=':select from 0 - current, 1 - default, 2 - saved, 3 - supported'
-s':alias to --sel'
--namespace-id=':valid, invalid and inactive nsid'
-n':alias to --namespace-id'
--no-uuid':Skip UUID index search'
-u':alias for --no-uuid'
)
_arguments '*:: :->subcmds'
_describe -t commands "nvme ocp get-telemetry-profile options" _ocp_get_telemetry_profile_feature
;;
(*)
_files
;;
Expand Down Expand Up @@ -2873,6 +2887,7 @@ _nvme () {
hardware-component-log':retrieve hardware component log'
get-latency-monitor':Get Latency Monitor Feature'
get-clear-pcie-correctable-errors':retrieve clear pcie correctable errors'
get-telemetry-profile':retrieve Get Telemetry Profile Feature'
)
_arguments '*:: :->subcmds'
_describe -t commands "nvme ocp options" _ocp
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 @@ -1653,6 +1653,10 @@ plugin_ocp_opts () {
--namespace-id= -n --no-uuid -u"
;;
"get-clear-pcie-correctable-errors")
opts+=" --sel= -s \
--namespace-id= -n --no-uuid -u"
;;
"get-telemetry-profile")
opts+=" --sel= -s \
--namespace-id= -n --no-uuid -u"
;;
Expand Down Expand Up @@ -1738,7 +1742,7 @@ _nvme_subcmds () {
set-dssd-async-event-config get-dssd-async-event-config \
get-error-injection set-error-injection \
hardware-component-log get-latency-monitor \
get-clear-pcie-correctable-errors"
get-clear-pcie-correctable-errors get-telemetry-profile"
[mangoboost]="id-ctrl"
)

Expand Down
79 changes: 79 additions & 0 deletions plugins/ocp/ocp-nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -2022,6 +2022,85 @@ static int ocp_set_telemetry_profile_feature(int argc, char **argv, struct comma
return err;
}

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// DSSD Power State (Feature Identifier C8h) Get Feature
static int ocp_get_telemetry_profile_feature(int argc, char **argv, struct command *cmd,
struct plugin *plugin)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation error should be fixed as below. (5 tab spaces and 5 white spaces needed before struct plugin *plugin)

  static int ocp_get_telemetry_profile_feature(int argc, char **argv, struct command *cmd,
- 					      struct plugin *plugin)
+ 					     struct plugin *plugin)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ikegami-t - Incorporated the review comments

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks not changed the indentation error part.

{
const char *desc = "Define Issue Get Feature command (FID: 0xC8) Latency Monitor";
const char *sel = "[0-3]: current/default/saved/supported/";
const char *nsid = "Byte[04-07]: Namespace Identifier Valid/Invalid/Inactive";

_cleanup_nvme_dev_ struct nvme_dev *dev = NULL;

__u32 result;
int err;
bool uuid;
__u8 uuid_index = 0;

struct config {
__u8 sel;
__u32 nsid;
};

struct config cfg = {
.sel = 0,
.nsid = 0,
};

OPT_ARGS(opts) = {
OPT_BYTE("sel", 's', &cfg.sel, sel),
OPT_UINT("namespace-id", 'n', &cfg.nsid, nsid),
OPT_FLAG("no-uuid", 'u', NULL, no_uuid),
OPT_END()
};

err = parse_and_open(&dev, argc, argv, desc, opts);
if (err)
return err;

uuid = !argconfig_parse_seen(opts, "no-uuid");

if (uuid) {
/* OCP 2.0 requires UUID index support */
err = ocp_get_uuid_index(dev, &uuid_index);
if (err || !uuid_index) {
nvme_show_error("ERROR: No OCP UUID index found");
return err;
}
}

struct nvme_get_features_args args = {
.args_size = sizeof(args),
.fd = dev_fd(dev),
.fid = OCP_FID_TEL_CFG,
.nsid = cfg.nsid,
.sel = cfg.sel,
.cdw11 = 0,
.uuidx = uuid_index,
.data_len = 0,
.data = NULL,
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
.result = &result,
};

err = nvme_get_features(&args);
if (!err) {
printf("get-feature:0xC8 %s value: %#08x\n",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add support for human-readable and json print outputs? (I think it is okay to be done in future separately.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ikegami-t - Printing the libnvme api return value. I am thinking json format is not required

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About the human-readable I thought the value can be decoded but reconfirmed as the dword 0 value is always zero so understood as not required the both human-readable and json print outputs.
tel-cfg-gf

nvme_select_to_string(cfg.sel), result);

if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED)
nvme_show_select_result(0xC8, result);
} else {
nvme_show_error("Could not get feature: 0xC8");
}

return err;
}

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions plugins/ocp/ocp-nvme.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ PLUGIN(NAME("ocp", "OCP cloud SSD extensions", OCP_PLUGIN_VERSION),
ocp_get_latency_monitor_feature)
ENTRY("get-clear-pcie-correctable-errors", "Clear PCIe correctable error counters",
get_clear_pcie_correctable_error_counters)
ENTRY("get-telemetry-profile", "Get Telemetry Profile Feature",
ocp_get_telemetry_profile_feature)
)
);

Expand Down