Skip to content

Commit

Permalink
ocp: support OCP 2.5 Set Telemetry Profile feature
Browse files Browse the repository at this point in the history
Adds a new OCP plugin function to set the device telemetry profile,
configuring what debug data shall be collected by the device.

Signed-off-by: Brandon Paupore <[email protected]>
  • Loading branch information
brandon-paupore-sndk authored and igaw committed Mar 20, 2024
1 parent fbb3311 commit 5348a86
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 1 deletion.
43 changes: 43 additions & 0 deletions Documentation/nvme-ocp-set-telemetry-profile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
nvme-ocp-set-telemetry-profile(1)
=================================

NAME
----
nvme-ocp-set-telemetry-profile - Set Telemetry Profile

SYNOPSIS
--------
[verse]
'nvme ocp set-telemetry-profile' <device>
[--telemetry-profile-select=<tps> | -t <tps>]

DESCRIPTION
-----------
For the NVMe device given, sets the OCP Set Telemetry Profile Feature

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
-------
-t <tps>::
--tps=<tps>::
Telemetry Profile Select. The device shall collect debug data per the
specified profile number.

EXAMPLES
--------
* Has the program issue a set-telemetry-profile command to use profile five.
+
------------
# nvme ocp set-telemetry-profile /dev/nvme0 -t 5
------------

NVME
----
Part of the nvme-user suite.
11 changes: 11 additions & 0 deletions completions/_nvme
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,16 @@ _nvme () {
_arguments '*:: :->subcmds'
_describe -t commands "nvme solidigm vs-drive-info" _vs_drive_info
;;
(set-telemetry-profile)
local _ocp_set_telemetry_profile_feature
_ocp_set_telemetry_profile_feature=(
/dev/nvme':supply a device to use (required)'
--telemetry-profile-select=':Telemetry Profile Select'
-t':alias for --telemetry-profile-select'
)
_arguments '*:: :->subcmds'
_describe -t commands "nvme ocp set-telemetry-profile options" _ocp_set_telemetry_profile_feature
;;
(*)
_files
;;
Expand Down Expand Up @@ -2255,6 +2265,7 @@ _nvme () {
device-capability-log':Get Device capability log'
set-dssd-power-state-feature':Set DSSD Power State'
telemetry-string-log':Retrieve Telemetry string Log Page'
set-telemetry-profile':Set Telemetry Profile'
)
_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 @@ -1444,6 +1444,9 @@ plugin_ocp_opts () {
"telemetry-string-log")
opts+=" --output-file= -o"
;;
"set-telemetry-profile")
opts+=" --telemetry-profile-select= -t"
;;
"help")
opts+=$NO_OPTS
;;
Expand Down Expand Up @@ -1519,7 +1522,8 @@ _nvme_subcmds () {
clear-fw-activate-history eol-plp-failure-mode \
clear-pcie-correctable-error-counters \
vs-fw-activate-history device-capability-log \
set-dssd-power-state-feature telemetry-string-log"
set-dssd-power-state-feature telemetry-string-log \
set-telemetry-profile"
)

# Associative array mapping plugins to corresponding option completions
Expand Down
84 changes: 84 additions & 0 deletions plugins/ocp/ocp-nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -2056,6 +2056,90 @@ static int ocp_device_capabilities_log(int argc, char **argv, struct command *cm
return ret;
}

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Set Telemetry Profile (Feature Identifier C8h) Set Feature

static int ocp_set_telemetry_profile(struct nvme_dev *dev, __u8 tps)
{
__u32 result;
int err;
int uuid_index = 0;

/* 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_set_features_args args = {
.args_size = sizeof(args),
.fd = dev_fd(dev),
.fid = 0xC8,
.nsid = 0xFFFFFFFF,
.cdw11 = tps,
.cdw12 = 0,
.save = true,
.uuidx = uuid_index,
.cdw15 = 0,
.data_len = 0,
.data = NULL,
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
.result = &result,
};

err = nvme_set_features(&args);
if (err > 0) {
nvme_show_status(err);
} else if (err < 0) {
nvme_show_perror("Set Telemetry Profile");
fprintf(stderr, "Command failed while parsing.\n");
} else {
printf("Successfully Set Telemetry Profile (feature: 0xC8) to below values\n");
printf("Telemetry Profile Select: 0x%x\n", tps);
}

return err;
}

static int ocp_set_telemetry_profile_feature(int argc, char **argv, struct command *cmd,
struct plugin *plugin)
{
const char *desc = "Set Telemetry Profile (Feature Identifier C8h) Set Feature.";
const char *tps = "Telemetry Profile Select for device debug data collection";
struct nvme_dev *dev;
int err;

struct config {
__u8 tps;
};

struct config cfg = {
.tps = 0,
};

OPT_ARGS(opts) = {
OPT_BYTE("telemetry-profile-select", 't', &cfg.tps, tps),
OPT_END()
};

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

if (argconfig_parse_seen(opts, "telemetry-profile-select"))
err = ocp_set_telemetry_profile(dev, cfg.tps);
else
nvme_show_error("Telemetry Profile Select is a required argument");

dev_close(dev);

return err;
}

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions plugins/ocp/ocp-nvme.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ PLUGIN(NAME("ocp", "OCP cloud SSD extensions", NVME_VERSION),
ENTRY("set-plp-health-check-interval", "Set PLP Health Check Interval", set_plp_health_check_interval)
ENTRY("get-plp-health-check-interval", "Get PLP Health Check Interval", get_plp_health_check_interval)
ENTRY("telemetry-string-log", "Retrieve Telemetry string Log Page", ocp_telemetry_str_log_format)
ENTRY("set-telemetry-profile", "Set Telemetry Profile Feature", ocp_set_telemetry_profile_feature)
)
);

Expand Down

0 comments on commit 5348a86

Please sign in to comment.