Skip to content

Commit 5c6d7e7

Browse files
VigneshwaranSaravanaigaw
authored andcommitted
plugin/ocp: Added the OCP Get Feature FID=C8h command api
Enabled Get Feature command (FID=C8h) api with sel, namespace-id, no-uuid command line arguments. namespace-id added to the test the command with active, inactive and invalid nsid values. Reviewed-by: Karthik Balan <[email protected]> Reviewed-by: Arunpandian J <[email protected]> Signed-off-by: Vigneshwaran Saravanan <[email protected]>
1 parent 9c576e7 commit 5c6d7e7

File tree

5 files changed

+163
-1
lines changed

5 files changed

+163
-1
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
nvme-ocp-get-telemetry-profile(1)
2+
=========================================
3+
4+
NAME
5+
----
6+
nvme-ocp-get-telemetry-profile - Define and print get-telemetry-profile value
7+
8+
SYNOPSIS
9+
--------
10+
[verse]
11+
'nvme ocp get-telemetry-profile' <device> [--sel=<select> | -s <select>]
12+
[--namespace-id <nsid> | -n <nsid>] [--no-uuid | -u]
13+
14+
DESCRIPTION
15+
-----------
16+
The <device> parameter is mandatory and may be either the NVMe character
17+
device (ex: /dev/nvme0) or block device (ex: /dev/nvme0n1).
18+
19+
This will only work on OCP compliant devices supporting this feature.
20+
Results for any other device are undefined.
21+
22+
On success it returns 0, error code otherwise.
23+
24+
OPTIONS
25+
-------
26+
-n <nsid>::
27+
--namespace-id=<nsid>::
28+
NSID: Assign the different kind of nsid value(like
29+
active, inactive and invalid nsids) and check
30+
the get feature command response:
31+
32+
-s <select>::
33+
--sel=<select>::
34+
Select (SEL): This field specifies which value of the attributes
35+
to return in the provided data:
36+
+
37+
[]
38+
|==================
39+
|Select|Description
40+
|0|Current
41+
|1|Default
42+
|2|Saved
43+
|3|Supported capabilities
44+
|4-7|Reserved
45+
|==================
46+
47+
-u::
48+
--no-uuid::
49+
Do not try to automatically detect UUID index for this command (required
50+
for old OCP 1.0 support)
51+
52+
EXAMPLES
53+
--------
54+
* Has the program issue a get-telemetry-profile to retrieve the 0xC8 get features.
55+
+
56+
------------
57+
# nvme ocp get-telemetry-profile /dev/nvme0
58+
------------
59+
60+
NVME
61+
----
62+
Part of the nvme-user suite.

completions/_nvme

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,20 @@ _nvme () {
425425
_arguments '*:: :->subcmds'
426426
_describe -t commands "nvme ocp get-clear-pcie-correctable-errors options" _get_clear_pcie_correctable_error_counters
427427
;;
428+
(get-telemetry-profile)
429+
local _ocp_get_telemetry_profile_feature
430+
_ocp_get_telemetry_profile_feature=(
431+
/dev/nvme':supply a device to use (required)'
432+
--sel=':select from 0 - current, 1 - default, 2 - saved, 3 - supported'
433+
-s':alias to --sel'
434+
--namespace-id=':valid, invalid and inactive nsid'
435+
-n':alias to --namespace-id'
436+
--no-uuid':Skip UUID index search'
437+
-u':alias for --no-uuid'
438+
)
439+
_arguments '*:: :->subcmds'
440+
_describe -t commands "nvme ocp get-telemetry-profile options" _ocp_get_telemetry_profile_feature
441+
;;
428442
(*)
429443
_files
430444
;;
@@ -2873,6 +2887,7 @@ _nvme () {
28732887
hardware-component-log':retrieve hardware component log'
28742888
get-latency-monitor':Get Latency Monitor Feature'
28752889
get-clear-pcie-correctable-errors':retrieve clear pcie correctable errors'
2890+
get-telemetry-profile':retrieve Get Telemetry Profile Feature'
28762891
)
28772892
_arguments '*:: :->subcmds'
28782893
_describe -t commands "nvme ocp options" _ocp

completions/bash-nvme-completion.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1653,6 +1653,10 @@ plugin_ocp_opts () {
16531653
--namespace-id= -n --no-uuid -u"
16541654
;;
16551655
"get-clear-pcie-correctable-errors")
1656+
opts+=" --sel= -s \
1657+
--namespace-id= -n --no-uuid -u"
1658+
;;
1659+
"get-telemetry-profile")
16561660
opts+=" --sel= -s \
16571661
--namespace-id= -n --no-uuid -u"
16581662
;;
@@ -1738,7 +1742,7 @@ _nvme_subcmds () {
17381742
set-dssd-async-event-config get-dssd-async-event-config \
17391743
get-error-injection set-error-injection \
17401744
hardware-component-log get-latency-monitor \
1741-
get-clear-pcie-correctable-errors"
1745+
get-clear-pcie-correctable-errors get-telemetry-profile"
17421746
[mangoboost]="id-ctrl"
17431747
)
17441748

plugins/ocp/ocp-nvme.c

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,6 +2022,85 @@ static int ocp_set_telemetry_profile_feature(int argc, char **argv, struct comma
20222022
return err;
20232023
}
20242024

2025+
///////////////////////////////////////////////////////////////////////////////
2026+
///////////////////////////////////////////////////////////////////////////////
2027+
///////////////////////////////////////////////////////////////////////////////
2028+
///////////////////////////////////////////////////////////////////////////////
2029+
/// DSSD Power State (Feature Identifier C8h) Get Feature
2030+
static int ocp_get_telemetry_profile_feature(int argc, char **argv, struct command *cmd,
2031+
struct plugin *plugin)
2032+
{
2033+
const char *desc = "Define Issue Get Feature command (FID: 0xC8) Latency Monitor";
2034+
const char *sel = "[0-3]: current/default/saved/supported/";
2035+
const char *nsid = "Byte[04-07]: Namespace Identifier Valid/Invalid/Inactive";
2036+
2037+
_cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
2038+
2039+
__u32 result;
2040+
int err;
2041+
bool uuid;
2042+
__u8 uuid_index = 0;
2043+
2044+
struct config {
2045+
__u8 sel;
2046+
__u32 nsid;
2047+
};
2048+
2049+
struct config cfg = {
2050+
.sel = 0,
2051+
.nsid = 0,
2052+
};
2053+
2054+
OPT_ARGS(opts) = {
2055+
OPT_BYTE("sel", 's', &cfg.sel, sel),
2056+
OPT_UINT("namespace-id", 'n', &cfg.nsid, nsid),
2057+
OPT_FLAG("no-uuid", 'u', NULL, no_uuid),
2058+
OPT_END()
2059+
};
2060+
2061+
err = parse_and_open(&dev, argc, argv, desc, opts);
2062+
if (err)
2063+
return err;
2064+
2065+
uuid = !argconfig_parse_seen(opts, "no-uuid");
2066+
2067+
if (uuid) {
2068+
/* OCP 2.0 requires UUID index support */
2069+
err = ocp_get_uuid_index(dev, &uuid_index);
2070+
if (err || !uuid_index) {
2071+
nvme_show_error("ERROR: No OCP UUID index found");
2072+
return err;
2073+
}
2074+
}
2075+
2076+
struct nvme_get_features_args args = {
2077+
.args_size = sizeof(args),
2078+
.fd = dev_fd(dev),
2079+
.fid = OCP_FID_TEL_CFG,
2080+
.nsid = cfg.nsid,
2081+
.sel = cfg.sel,
2082+
.cdw11 = 0,
2083+
.uuidx = uuid_index,
2084+
.data_len = 0,
2085+
.data = NULL,
2086+
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
2087+
.result = &result,
2088+
};
2089+
2090+
err = nvme_get_features(&args);
2091+
if (!err) {
2092+
printf("get-feature:0xC8 %s value: %#08x\n",
2093+
nvme_select_to_string(cfg.sel), result);
2094+
2095+
if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED)
2096+
nvme_show_select_result(0xC8, result);
2097+
} else {
2098+
nvme_show_error("Could not get feature: 0xC8");
2099+
}
2100+
2101+
return err;
2102+
}
2103+
20252104
///////////////////////////////////////////////////////////////////////////////
20262105
///////////////////////////////////////////////////////////////////////////////
20272106
///////////////////////////////////////////////////////////////////////////////

plugins/ocp/ocp-nvme.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ PLUGIN(NAME("ocp", "OCP cloud SSD extensions", OCP_PLUGIN_VERSION),
4646
ocp_get_latency_monitor_feature)
4747
ENTRY("get-clear-pcie-correctable-errors", "Clear PCIe correctable error counters",
4848
get_clear_pcie_correctable_error_counters)
49+
ENTRY("get-telemetry-profile", "Get Telemetry Profile Feature",
50+
ocp_get_telemetry_profile_feature)
4951
)
5052
);
5153

0 commit comments

Comments
 (0)