Skip to content

Commit 3808b9d

Browse files
VigneshwaranSaravanaigaw
authored andcommitted
plugin/ocp: 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 <[email protected]> Reviewed-by: Arunpandian J <[email protected]> Signed-off-by: Vigneshwaran Saravanan <[email protected]>
1 parent aa3b884 commit 3808b9d

File tree

5 files changed

+158
-1
lines changed

5 files changed

+158
-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
@@ -397,6 +397,20 @@ _nvme () {
397397
_arguments '*:: :->subcmds'
398398
_describe -t commands "nvme ocp set-telemetry-profile options" _ocp_set_telemetry_profile_feature
399399
;;
400+
(get-latency-monitor)
401+
local _ocp_get_latency_monitor_feature
402+
_ocp_get_latency_monitor_feature=(
403+
/dev/nvme':supply a device to use (required)'
404+
--sel=':select from 0 - current, 1 - default, 2 - saved, 3 - supported'
405+
-s':alias to --sel'
406+
--namespace-id=':valid, invalid and inactive nsid'
407+
-n':alias to --namespace-id'
408+
--no-uuid':Skip UUID index search'
409+
-u':alias for --no-uuid'
410+
)
411+
_arguments '*:: :->subcmds'
412+
_describe -t commands "nvme ocp get-latency-monitor options" _ocp_get_latency_monitor_feature
413+
;;
400414
(*)
401415
_files
402416
;;
@@ -2843,6 +2857,7 @@ _nvme () {
28432857
get-error-injection':get error injection'
28442858
set-error-injection':set error injection'
28452859
hardware-component-log':retrieve hardware component log'
2860+
get-latency-monitor':Get Latency Monitor Feature'
28462861
)
28472862
_arguments '*:: :->subcmds'
28482863
_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
@@ -1648,6 +1648,10 @@ plugin_ocp_opts () {
16481648
opts+=" --comp-id= -i --list -l --verbose -v \
16491649
--output-format -o --timeout= -t"
16501650
;;
1651+
"get-latency-monitor")
1652+
opts+=" --sel= -s \
1653+
--namespace-id= -n --no-uuid -u"
1654+
;;
16511655
"help")
16521656
opts+=$NO_OPTS
16531657
;;
@@ -1729,7 +1733,7 @@ _nvme_subcmds () {
17291733
telemetry-string-log set-telemetry-profile \
17301734
set-dssd-async-event-config get-dssd-async-event-config \
17311735
get-error-injection set-error-injection \
1732-
hardware-component-log"
1736+
hardware-component-log get-latency-monitor"
17331737
[mangoboost]="id-ctrl"
17341738
)
17351739

plugins/ocp/ocp-nvme.c

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,80 @@ 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+
433+
_cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
434+
435+
__u32 result;
436+
int err;
437+
bool uuid;
438+
__u8 uuid_index = 0;
439+
440+
struct config {
441+
__u8 sel;
442+
__u32 nsid;
443+
};
444+
445+
struct config cfg = {
446+
.sel = 0,
447+
.nsid = 0,
448+
};
449+
450+
OPT_ARGS(opts) = {
451+
OPT_BYTE("sel", 's', &cfg.sel, sel),
452+
OPT_UINT("namespace-id", 'n', &cfg.nsid, nsid),
453+
OPT_FLAG("no-uuid", 'u', NULL, no_uuid),
454+
OPT_END()
455+
};
456+
457+
err = parse_and_open(&dev, argc, argv, desc, opts);
458+
if (err)
459+
return err;
460+
461+
uuid = !argconfig_parse_seen(opts, "no-uuid");
462+
463+
if (uuid) {
464+
/* OCP 2.0 requires UUID index support */
465+
err = ocp_get_uuid_index(dev, &uuid_index);
466+
if (err || !uuid_index) {
467+
nvme_show_error("ERROR: No OCP UUID index found");
468+
return err;
469+
}
470+
}
471+
472+
struct nvme_get_features_args args = {
473+
.args_size = sizeof(args),
474+
.fd = dev_fd(dev),
475+
.fid = OCP_FID_LM,
476+
.nsid = cfg.nsid,
477+
.sel = cfg.sel,
478+
.cdw11 = 0,
479+
.uuidx = uuid_index,
480+
.data_len = 0,
481+
.data = NULL,
482+
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
483+
.result = &result,
484+
};
485+
486+
err = nvme_get_features(&args);
487+
if (!err) {
488+
printf("get-feature:0xC5 %s value: %#08x\n",
489+
nvme_select_to_string(cfg.sel), result);
490+
491+
if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED)
492+
nvme_show_select_result(0xC5, result);
493+
} else {
494+
nvme_show_error("Could not get feature: 0xC5");
495+
}
496+
497+
return err;
498+
}
499+
426500
///////////////////////////////////////////////////////////////////////////////
427501
///////////////////////////////////////////////////////////////////////////////
428502
///////////////////////////////////////////////////////////////////////////////

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)