Skip to content

Commit 0e3de75

Browse files
author
Gopinath P/Gopinath P
committed
plugin/ocp_get_feature_fid_c3h: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]>
1 parent 5ced5c0 commit 0e3de75

7 files changed

Lines changed: 168 additions & 1 deletion

File tree

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
@@ -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-clear-pcie-correctable-errors)
400+
local _get_clear_pcie_correctable_error_counters
401+
_get_clear_pcie_correctable_error_counters=(
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-clear-pcie-correctable-errors options" _get_clear_pcie_correctable_error_counters
412+
;;
399413
(*)
400414
_files
401415
;;
@@ -2818,6 +2832,7 @@ _nvme () {
28182832
get-error-injection':get error injection'
28192833
set-error-injection':set error injection'
28202834
hardware-component-log':retrieve hardware component log'
2835+
get-clear-pcie-correctable-errors':retrieve clear pcie correctable errors'
28212836
)
28222837
_arguments '*:: :->subcmds'
28232838
_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-clear-pcie-correctable-errors")
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-clear-pcie-correctable-errors"
17011705
)
17021706

17031707
# Associative array mapping plugins to corresponding option completions

plugins/ocp/ocp-clear-features.c

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

78+
static 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+
85+
_cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
86+
87+
__u32 result;
88+
int err;
89+
bool uuid;
90+
__u8 uuid_index = 0;
91+
92+
struct config {
93+
__u8 sel;
94+
__u32 nsid;
95+
};
96+
97+
struct config cfg = {
98+
.sel = 0,
99+
.nsid = 0,
100+
};
101+
102+
OPT_ARGS(opts) = {
103+
OPT_BYTE("sel", 's', &cfg.sel, sel),
104+
OPT_UINT("namespace-id", 'n', &cfg.nsid, nsid),
105+
OPT_FLAG("no-uuid", 'u', NULL, no_uuid),
106+
OPT_END()
107+
};
108+
109+
err = parse_and_open(&dev, argc, argv, desc, opts);
110+
if (err)
111+
return err;
112+
113+
uuid = !argconfig_parse_seen(opts, "no-uuid");
114+
115+
if (uuid) {
116+
/* OCP 2.0 requires UUID index support */
117+
err = ocp_get_uuid_index(dev, &uuid_index);
118+
if (err || !uuid_index) {
119+
nvme_show_error("ERROR: No OCP UUID index found");
120+
return err;
121+
}
122+
}
123+
124+
struct nvme_get_features_args args = {
125+
.args_size = sizeof(args),
126+
.fd = dev_fd(dev),
127+
.fid = OCP_FID_CPCIE,
128+
.nsid = cfg.nsid,
129+
.sel = cfg.sel,
130+
.cdw11 = 0,
131+
.uuidx = uuid_index,
132+
.data_len = 0,
133+
.data = NULL,
134+
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
135+
.result = &result,
136+
};
137+
138+
err = nvme_get_features(&args);
139+
if (!err) {
140+
printf("get-feature:0xC3 %s value: %#08x\n",
141+
nvme_select_to_string(cfg.sel), result);
142+
143+
if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED)
144+
nvme_show_select_result(0xC3, result);
145+
} else {
146+
nvme_show_error("Could not get feature: 0xC3");
147+
}
148+
149+
return err;
150+
}
151+
78152
int ocp_clear_fw_update_history(int argc, char **argv, struct command *cmd, struct plugin *plugin)
79153
{
80154
const char *desc = "OCP Clear Firmware Update History";

plugins/ocp/ocp-clear-features.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ 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);
16+

plugins/ocp/ocp-nvme.c

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

2615+
static int get_clear_pcie_correctable_error_counters(int argc, char **argv, struct command *cmd,
2616+
struct plugin *plugin)
2617+
{
2618+
return get_ocp_error_counters(argc, argv, cmd, plugin);
2619+
}
2620+
26152621
static int fw_activation_history_log(int argc, char **argv, struct command *cmd,
26162622
struct plugin *plugin)
26172623
{

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-clear-pcie-correctable-errors", "Clear PCIe correctable error counters",
46+
get_clear_pcie_correctable_error_counters)
4547
)
4648
);
4749

0 commit comments

Comments
 (0)