Skip to content

Commit ccd1d35

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 <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 5e1fd04 commit ccd1d35

File tree

5 files changed

+140
-1
lines changed

5 files changed

+140
-1
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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>] [--nsid | -n]
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+
--nsid=<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+
EXAMPLES
50+
--------
51+
* Has the program issue a get-latency-monitor to retrieve the 0xC5 get features.
52+
+
53+
------------
54+
# nvme ocp get-latency-monitor /dev/nvme0
55+
------------
56+
57+
NVME
58+
----
59+
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: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,65 @@ 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+
436+
struct config {
437+
__u8 sel;
438+
__u32 nsid;
439+
};
440+
441+
struct config cfg = {
442+
.sel = 0,
443+
.nsid = 0,
444+
};
445+
446+
OPT_ARGS(opts) = {
447+
OPT_BYTE("sel", 's', &cfg.sel, sel),
448+
OPT_BYTE("nsid", 'n', &cfg.nsid, nsid),
449+
OPT_FLAG("no-uuid", 'u', NULL, no_uuid),
450+
OPT_END()
451+
};
452+
453+
err = parse_and_open(&dev, argc, argv, desc, opts);
454+
if (err)
455+
return err;
456+
457+
struct nvme_get_features_args args = {
458+
.args_size = sizeof(args),
459+
.fd = dev_fd(dev),
460+
.fid = OCP_FID_LM,
461+
.nsid = cfg.nsid,
462+
.sel = cfg.sel,
463+
.cdw11 = 0,
464+
.uuidx = 0,
465+
.data_len = 0,
466+
.data = NULL,
467+
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
468+
.result = &result,
469+
};
470+
471+
err = nvme_get_features(&args);
472+
if (!err) {
473+
printf("get-feature:0xC5 %s value: %#08x\n",
474+
nvme_select_to_string(cfg.sel), result);
475+
476+
if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED)
477+
nvme_show_select_result(0xC5, result);
478+
} else {
479+
nvme_show_error("Could not get feature: 0xC5");
480+
}
481+
482+
return err;
483+
}
484+
426485
///////////////////////////////////////////////////////////////////////////////
427486
///////////////////////////////////////////////////////////////////////////////
428487
///////////////////////////////////////////////////////////////////////////////

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)