Skip to content

Commit c1241bb

Browse files
lgdacunhigaw
authored andcommitted
plugins/ocp: Add --all-ns option to command set-error-injection.
Different spec versions ask for different valid nsid values. Signed-off-by: Leonardo da Cunha <[email protected]>
1 parent baec0f0 commit c1241bb

File tree

2 files changed

+52
-15
lines changed

2 files changed

+52
-15
lines changed

Documentation/nvme-ocp-set-error-injection.txt

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ SYNOPSIS
1010
[verse]
1111
'nvme ocp set-error-injection' <device> [--data=<file> | -d <file>]
1212
[--number=<num> | -n <num>] [--no-uuid | -N]
13-
[--type=<type> | -t <type>] [--nrtdp=<num> | -r <num>]
14-
[--verbose | -v] [--output-format=<fmt> | -o <fmt>]
15-
[--timeout=<timeout>]
13+
[--all-ns | -a] [--type=<type> | -t <type>]
14+
[--nrtdp=<num> | -r <num>] [--timeout=<timeout>]
1615

1716
DESCRIPTION
1817
-----------
@@ -40,23 +39,18 @@ OPTIONS
4039
Do not try to automatically detect UUID index for this command (required
4140
for old OCP 1.0 support)
4241

42+
-a::
43+
--all-ns::
44+
Apply to all namespaces
45+
4346
-t <type>::
4447
--type=<type>::
45-
Error injection type
48+
Error injection type (1-22: see NOTES section for valid types)
4649

4750
-r <num>::
4851
--nrtdp=<num>::
4952
Number of reads to trigger device panic
5053

51-
-v::
52-
--verbose::
53-
Increase the information detail in the output.
54-
55-
-o <fmt>::
56-
--output-format=<fmt>::
57-
Set the reporting format to 'normal', 'json' or 'binary'. Only one
58-
output format can be used at a time.
59-
6054
--timeout=<timeout>::
6155
Override default timeout value. In milliseconds.
6256

@@ -74,6 +68,38 @@ EXAMPLES
7468
# nvme ocp set-error-injection /dev/nvme0 -t 2 -r 5
7569
------------
7670

71+
* Has the program issue a set-error-injection for all namespaces with type 1.
72+
+
73+
------------
74+
# nvme ocp set-error-injection /dev/nvme0 -a -t 1
75+
------------
76+
77+
NOTES
78+
-----
79+
Valid error injection types:
80+
1 - CPU/controller hang
81+
2 - NAND hang
82+
3 - PLP defect
83+
4 - Logical firmware error
84+
5 - DRAM corruption critical path
85+
6 - DRAM corruption non-critical path
86+
7 - NAND corruption
87+
8 - SRAM corruption
88+
9 - HW malfunction
89+
10 - No more NAND spares available
90+
11 - Incomplete shutdown
91+
12 - Metadata corruption
92+
13 - Critical garbage collection
93+
14 - Latency spike
94+
15 - I/O command failure
95+
16 - I/O command timeout
96+
17 - Admin command failure
97+
18 - Admin command timeout
98+
19 - Thermal throttle engaged
99+
20 - Thermal throttle disengaged
100+
21 - Critical temperature event
101+
22 - Die offline
102+
77103
NVME
78104
----
79105
Part of the nvme-user suite.

plugins/ocp/ocp-nvme.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ struct ieee1667_get_cq_entry {
189189

190190
static const char *sel = "[0-3]: current/default/saved/supported";
191191
static const char *no_uuid = "Skip UUID index search (UUID index not required for OCP 1.0)";
192+
static const char *all_ns = "Apply to all namespaces";
192193
const char *data = "Error injection data structure entries";
193194
const char *number = "Number of valid error injection data entries";
194195
static const char *type = "Error injection type";
@@ -2935,12 +2936,13 @@ static int get_error_injection(int argc, char **argv, struct command *cmd, struc
29352936
return error_injection_get(dev, cfg.sel, !argconfig_parse_seen(opts, "no-uuid"));
29362937
}
29372938

2938-
static int error_injection_set(struct nvme_dev *dev, struct erri_config *cfg, bool uuid)
2939+
static int error_injection_set(struct nvme_dev *dev, struct erri_config *cfg, bool uuid, __u32 nsid)
29392940
{
29402941
int err;
29412942
__u32 result;
29422943
struct nvme_set_features_args args = {
29432944
.args_size = sizeof(args),
2945+
.nsid = nsid,
29442946
.fd = dev_fd(dev),
29452947
.fid = OCP_FID_ERRI,
29462948
.cdw11 = cfg->number,
@@ -3010,6 +3012,7 @@ static int set_error_injection(int argc, char **argv, struct command *cmd, struc
30103012
{
30113013
const char *desc = "Inject error conditions";
30123014
int err;
3015+
__u32 nsid;
30133016
struct erri_config cfg = {
30143017
.number = 1,
30153018
};
@@ -3020,14 +3023,22 @@ static int set_error_injection(int argc, char **argv, struct command *cmd, struc
30203023
OPT_FILE("data", 'd', &cfg.file, data),
30213024
OPT_BYTE("number", 'n', &cfg.number, number),
30223025
OPT_FLAG("no-uuid", 'N', NULL, no_uuid),
3026+
OPT_FLAG("all-ns", 'a', NULL, all_ns),
30233027
OPT_SHRT("type", 't', &cfg.type, type),
30243028
OPT_SHRT("nrtdp", 'r', &cfg.nrtdp, nrtdp));
30253029

30263030
err = parse_and_open(&dev, argc, argv, desc, opts);
30273031
if (err)
30283032
return err;
30293033

3030-
return error_injection_set(dev, &cfg, !argconfig_parse_seen(opts, "no-uuid"));
3034+
/*
3035+
* Different spec versions ask for different nsid values
3036+
* OCP v1.0 - NSID: Shall be set to zero
3037+
* OCP v2.0r21 - NSID: Shall be set to FFFFFFFFh.
3038+
* OCP v2.5 - NSID: The host should either clear this to zero or set this to FFFFFFFFh
3039+
*/
3040+
nsid = argconfig_parse_seen(opts, "all-ns") ? NVME_NSID_ALL : 0;
3041+
return error_injection_set(dev, &cfg, !argconfig_parse_seen(opts, "no-uuid"), nsid);
30313042
}
30323043

30333044
static int enable_ieee1667_silo_get(struct nvme_dev *dev, const __u8 sel, bool uuid)

0 commit comments

Comments
 (0)