Skip to content

Commit c9e0743

Browse files
plugin/ocp_get_feature_fid_c5h:Added the OCP Get Feature FID=C5h command api
Enabled the Get Feature command (FID=C5h) 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 <karthik.b82@samsung.com> Reviewed-by: Arunpandian J <arun.j@samsung.com> Signed-off-by: Vigneshwaran Saravanan/Vigneshwaran Saravanan <s.vignesh@samsung.com>
1 parent 31aa468 commit c9e0743

File tree

5 files changed

+156
-1
lines changed

5 files changed

+156
-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-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>]
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-latency-monitor to retrieve the 0xC5 get features.
55+
+
56+
------------
57+
# nvme ocp get-latency-monitor /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
@@ -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+
--namespace-id=':valid, invalid and inactive nsid'
406+
-n':alias to --namespace-id'
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+
--namespace-id= -n --no-uuid= -u"
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(0xC5, 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)