Skip to content

Commit 55bce50

Browse files
Gopinath Pigaw
authored andcommitted
plugin/ocp: Added the OCP Get Feature FID=C3h command API
Enabled Get Feature command (FID=C3h) 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: Gopinath P <[email protected]> [wagi: fixed build issues, reformated commit message] Signed-off-by: Daniel Wagner <[email protected]>
1 parent 7eb6aaf commit 55bce50

File tree

7 files changed

+169
-1
lines changed

7 files changed

+169
-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-clear-pcie-correctable-errors(1)
2+
=========================================
3+
4+
NAME
5+
----
6+
nvme-ocp-get-clear-pcie-correctable-errors - Define and print get-clear-pcie-correctable-errors value
7+
8+
SYNOPSIS
9+
--------
10+
[verse]
11+
'nvme ocp get-clear-pcie-correctable-errors' <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-clear-pcie-correctable-errors to retrieve the 0xC3 get features.
55+
+
56+
------------
57+
# nvme ocp get-clear-pcie-correctable-errors /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
@@ -411,6 +411,20 @@ _nvme () {
411411
_arguments '*:: :->subcmds'
412412
_describe -t commands "nvme ocp get-latency-monitor options" _ocp_get_latency_monitor_feature
413413
;;
414+
(get-clear-pcie-correctable-errors)
415+
local _get_clear_pcie_correctable_error_counters
416+
_get_clear_pcie_correctable_error_counters=(
417+
/dev/nvme':supply a device to use (required)'
418+
--sel=':select from 0 - current, 1 - default, 2 - saved, 3 - supported'
419+
-s':alias to --sel'
420+
--namespace-id=':valid, invalid and inactive nsid'
421+
-n':alias to --namespace-id'
422+
--no-uuid':Skip UUID index search'
423+
-u':alias for --no-uuid'
424+
)
425+
_arguments '*:: :->subcmds'
426+
_describe -t commands "nvme ocp get-clear-pcie-correctable-errors options" _get_clear_pcie_correctable_error_counters
427+
;;
414428
(*)
415429
_files
416430
;;
@@ -2858,6 +2872,7 @@ _nvme () {
28582872
set-error-injection':set error injection'
28592873
hardware-component-log':retrieve hardware component log'
28602874
get-latency-monitor':Get Latency Monitor Feature'
2875+
get-clear-pcie-correctable-errors':retrieve clear pcie correctable errors'
28612876
)
28622877
_arguments '*:: :->subcmds'
28632878
_describe -t commands "nvme ocp options" _ocp

completions/bash-nvme-completion.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1649,6 +1649,10 @@ plugin_ocp_opts () {
16491649
--output-format -o --timeout= -t"
16501650
;;
16511651
"get-latency-monitor")
1652+
opts+=" --sel= -s \
1653+
--namespace-id= -n --no-uuid -u"
1654+
;;
1655+
"get-clear-pcie-correctable-errors")
16521656
opts+=" --sel= -s \
16531657
--namespace-id= -n --no-uuid -u"
16541658
;;
@@ -1733,7 +1737,8 @@ _nvme_subcmds () {
17331737
telemetry-string-log set-telemetry-profile \
17341738
set-dssd-async-event-config get-dssd-async-event-config \
17351739
get-error-injection set-error-injection \
1736-
hardware-component-log get-latency-monitor"
1740+
hardware-component-log get-latency-monitor \
1741+
get-clear-pcie-correctable-errors"
17371742
[mangoboost]="id-ctrl"
17381743
)
17391744

plugins/ocp/ocp-clear-features.c

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,81 @@ static int ocp_clear_feature(int argc, char **argv, const char *desc, const __u8
7575
return err;
7676
}
7777

78+
int get_ocp_error_counters(int argc, char **argv, struct command *cmd,
79+
struct plugin *plugin)
80+
{
81+
const char *desc = "Define Issue Get Feature cmd (FID: 0xC3) Clear PCIe Corr Err Counters";
82+
const char *sel = "[0-3]: current/default/saved/supported/";
83+
const char *nsid = "Byte[04-07]: Namespace Identifier Valid/Invalid/Inactive";
84+
const char *no_uuid = "Do not try to automatically detect UUID index";
85+
86+
_cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
87+
88+
__u32 result;
89+
int err;
90+
bool uuid;
91+
__u8 uuid_index = 0;
92+
93+
struct config {
94+
__u8 sel;
95+
__u32 nsid;
96+
};
97+
98+
struct config cfg = {
99+
.sel = 0,
100+
.nsid = 0,
101+
};
102+
103+
OPT_ARGS(opts) = {
104+
OPT_BYTE("sel", 's', &cfg.sel, sel),
105+
OPT_UINT("namespace-id", 'n', &cfg.nsid, nsid),
106+
OPT_FLAG("no-uuid", 'u', NULL, no_uuid),
107+
OPT_END()
108+
};
109+
110+
err = parse_and_open(&dev, argc, argv, desc, opts);
111+
if (err)
112+
return err;
113+
114+
uuid = !argconfig_parse_seen(opts, "no-uuid");
115+
116+
if (uuid) {
117+
/* OCP 2.0 requires UUID index support */
118+
err = ocp_get_uuid_index(dev, &uuid_index);
119+
if (err || !uuid_index) {
120+
nvme_show_error("ERROR: No OCP UUID index found");
121+
return err;
122+
}
123+
}
124+
125+
struct nvme_get_features_args args = {
126+
.args_size = sizeof(args),
127+
.fd = dev_fd(dev),
128+
.fid = OCP_FID_CPCIE,
129+
.nsid = cfg.nsid,
130+
.sel = cfg.sel,
131+
.cdw11 = 0,
132+
.uuidx = uuid_index,
133+
.data_len = 0,
134+
.data = NULL,
135+
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
136+
.result = &result,
137+
};
138+
139+
err = nvme_get_features(&args);
140+
if (!err) {
141+
printf("get-feature:0xC3 %s value: %#08x\n",
142+
nvme_select_to_string(cfg.sel), result);
143+
144+
if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED)
145+
nvme_show_select_result(0xC3, result);
146+
} else {
147+
nvme_show_error("Could not get feature: 0xC3");
148+
}
149+
150+
return err;
151+
}
152+
78153
int ocp_clear_fw_update_history(int argc, char **argv, struct command *cmd, struct plugin *plugin)
79154
{
80155
const char *desc = "OCP Clear Firmware Update History";

plugins/ocp/ocp-clear-features.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ int ocp_clear_fw_update_history(int argc, char **argv, struct command *cmd, stru
1010

1111
int ocp_clear_pcie_correctable_errors(int argc, char **argv, struct command *cmd,
1212
struct plugin *plugin);
13+
14+
int get_ocp_error_counters(int argc, char **argv, struct command *cmd,
15+
struct plugin *plugin);

plugins/ocp/ocp-nvme.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2686,6 +2686,12 @@ static int clear_pcie_correctable_error_counters(int argc, char **argv, struct c
26862686
return ocp_clear_pcie_correctable_errors(argc, argv, cmd, plugin);
26872687
}
26882688

2689+
static int get_clear_pcie_correctable_error_counters(int argc, char **argv, struct command *cmd,
2690+
struct plugin *plugin)
2691+
{
2692+
return get_ocp_error_counters(argc, argv, cmd, plugin);
2693+
}
2694+
26892695
static int fw_activation_history_log(int argc, char **argv, struct command *cmd,
26902696
struct plugin *plugin)
26912697
{

plugins/ocp/ocp-nvme.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ PLUGIN(NAME("ocp", "OCP cloud SSD extensions", OCP_PLUGIN_VERSION),
4444
ENTRY("hardware-component-log", "retrieve hardware component log", hwcomp_log)
4545
ENTRY("get-latency-monitor", "Get Latency Monitor Feature",
4646
ocp_get_latency_monitor_feature)
47+
ENTRY("get-clear-pcie-correctable-errors", "Clear PCIe correctable error counters",
48+
get_clear_pcie_correctable_error_counters)
4749
)
4850
);
4951

0 commit comments

Comments
 (0)