Skip to content

Commit 9e4eaeb

Browse files
plugin/ocp_get_feature_fid_c5h:Added the OCP Get Feature FID=C5h command api
Enabled the Get Feature Command FID=C5h command api with nsid field Values Reviewed-by: Karthik Balan <[email protected]> Reviewed-by: Arunpandian J <[email protected]> Signed-off-by: Vigneshwaran Saravanan/Vigneshwaran Saravanan <[email protected]>
1 parent 31aa468 commit 9e4eaeb

File tree

5 files changed

+158
-1
lines changed

5 files changed

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

completions/_nvme

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,20 @@ _nvme () {
396396
_arguments '*:: :->subcmds'
397397
_describe -t commands "nvme ocp set-telemetry-profile options" _ocp_set_telemetry_profile_feature
398398
;;
399+
(get-latency-monitor)
400+
local _ocp_get_latency_monitor_feature
401+
_ocp_get_latency_monitor_feature=(
402+
/dev/nvme':supply a device to use (required)'
403+
--sel=':select from 0 - current, 1 - default, 2 - saved, 3 - supported'
404+
-S':alias to --sel'
405+
--nsid=':valid, invalid and inactive nsid'
406+
-n':alias to --nsid'
407+
--no-uuid':Skip UUID index search'
408+
-u':alias for --no-uuid'
409+
)
410+
_arguments '*:: :->subcmds'
411+
_describe -t commands "nvme ocp get-latency-monitor options" _ocp_get_latency_monitor_feature
412+
;;
399413
(*)
400414
_files
401415
;;
@@ -2816,6 +2830,7 @@ _nvme () {
28162830
get-error-injection':get error injection'
28172831
set-error-injection':set error injection'
28182832
hardware-component-log':retrieve hardware component log'
2833+
get-latency-monitor':Get Latency Monitor Feature'
28192834
)
28202835
_arguments '*:: :->subcmds'
28212836
_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
@@ -1616,6 +1616,10 @@ plugin_ocp_opts () {
16161616
opts+=" --comp-id= -i --list -l --verbose -v \
16171617
--output-format -o --timeout= -t"
16181618
;;
1619+
"get-latency-monitor")
1620+
opts+=" --sel= -S \
1621+
--nsid= -n"
1622+
;;
16191623
"help")
16201624
opts+=$NO_OPTS
16211625
;;
@@ -1697,7 +1701,7 @@ _nvme_subcmds () {
16971701
telemetry-string-log set-telemetry-profile \
16981702
set-dssd-async-event-config get-dssd-async-event-config \
16991703
get-error-injection set-error-injection \
1700-
hardware-component-log"
1704+
hardware-component-log get-latency-monitor"
17011705
)
17021706

17031707
# Associative array mapping plugins to corresponding option completions

plugins/ocp/ocp-nvme.c

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,78 @@ int ocp_set_latency_monitor_feature(int argc, char **argv, struct command *cmd,
423423
return err;
424424
}
425425

426+
static int ocp_get_latency_monitor_feature(int argc, char **argv, struct command *cmd,
427+
struct plugin *plugin)
428+
{
429+
const char *desc = "Define Issue Get Feature command (FID: 0xC5) Latency Monitor";
430+
const char *sel = "[0-3]: current/default/saved/supported/";
431+
const char *nsid = "Byte[04-07]: Namespace Identifier Valid/Invalid/Inactive";
432+
struct nvme_dev *dev;
433+
__u32 result;
434+
int err;
435+
bool uuid;
436+
__u8 uuid_index = 0;
437+
438+
struct config {
439+
__u8 sel;
440+
__u32 nsid;
441+
};
442+
443+
struct config cfg = {
444+
.sel = 0,
445+
.nsid = 0,
446+
};
447+
448+
OPT_ARGS(opts) = {
449+
OPT_BYTE("sel", 's', &cfg.sel, sel),
450+
OPT_BYTE("namespace-id", 'n', &cfg.nsid, nsid),
451+
OPT_FLAG("no-uuid", 'u', NULL, no_uuid),
452+
OPT_END()
453+
};
454+
455+
err = parse_and_open(&dev, argc, argv, desc, opts);
456+
if (err)
457+
return err;
458+
459+
uuid = !argconfig_parse_seen(opts, "no-uuid");
460+
461+
if (uuid) {
462+
/* OCP 2.0 requires UUID index support */
463+
err = ocp_get_uuid_index(dev, &uuid_index);
464+
if (err || !uuid_index) {
465+
nvme_show_error("ERROR: No OCP UUID index found");
466+
return err;
467+
}
468+
}
469+
470+
struct nvme_get_features_args args = {
471+
.args_size = sizeof(args),
472+
.fd = dev_fd(dev),
473+
.fid = OCP_FID_LM,
474+
.nsid = cfg.nsid,
475+
.sel = cfg.sel,
476+
.cdw11 = 0,
477+
.uuidx = uuid_index,
478+
.data_len = 0,
479+
.data = NULL,
480+
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
481+
.result = &result,
482+
};
483+
484+
err = nvme_get_features(&args);
485+
if (!err) {
486+
printf("get-feature:0xC5 %s value: %#08x\n",
487+
nvme_select_to_string(cfg.sel), result);
488+
489+
if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED)
490+
nvme_show_select_result(OCP_FID_LM, result);
491+
} else {
492+
nvme_show_error("Could not get feature: 0xC5");
493+
}
494+
495+
return err;
496+
}
497+
426498
///////////////////////////////////////////////////////////////////////////////
427499
///////////////////////////////////////////////////////////////////////////////
428500
///////////////////////////////////////////////////////////////////////////////

plugins/ocp/ocp-nvme.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ PLUGIN(NAME("ocp", "OCP cloud SSD extensions", OCP_PLUGIN_VERSION),
4242
get_enable_ieee1667_silo)
4343
ENTRY("set-enable-ieee1667-silo", "enable IEEE1667 silo", set_enable_ieee1667_silo)
4444
ENTRY("hardware-component-log", "retrieve hardware component log", hwcomp_log)
45+
ENTRY("get-latency-monitor", "Get Latency Monitor Feature",
46+
ocp_get_latency_monitor_feature)
4547
)
4648
);
4749

0 commit comments

Comments
 (0)