Skip to content

Commit 6b412b7

Browse files
lgdacunhigaw
authored andcommitted
plugins/ocp: Add --all-ns option to command get-error-injection.
Fixed data buffer retrieval. Fixed data buffer parsing. Typo fix. Different spec versions ask for different valid nsid values. Signed-off-by: Leonardo da Cunha <[email protected]>
1 parent c24f46d commit 6b412b7

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ SYNOPSIS
99
--------
1010
[verse]
1111
'nvme ocp get-error-injection' <device> [--no-uuid | -n]
12-
[--sel=<select> | -s <select>]
12+
[--sel=<select> | -s <select>] [--all-ns | -a]
1313

1414
DESCRIPTION
1515
-----------
@@ -44,6 +44,11 @@ OPTIONS
4444
|4-7|Reserved
4545
|==================
4646

47+
-a::
48+
--all-ns::
49+
Send the command to all namespaces. This option is used to specify
50+
whether to target all namespaces or no specific namespace.
51+
4752
EXAMPLES
4853
--------
4954
* Has the program issue a get-error-injection to retrieve the 0xC0 get features.

plugins/ocp/ocp-nvme.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2857,7 +2857,7 @@ static int fw_activation_history_log(int argc, char **argv, struct command *cmd,
28572857
return ocp_fw_activation_history_log(argc, argv, cmd, plugin);
28582858
}
28592859

2860-
static int error_injection_get(struct nvme_dev *dev, const __u8 sel, bool uuid)
2860+
static int error_injection_get(struct nvme_dev *dev, const __u8 sel, bool uuid, __u32 nsid)
28612861
{
28622862
struct erri_get_cq_entry cq_entry;
28632863
int err;
@@ -2868,7 +2868,7 @@ static int error_injection_get(struct nvme_dev *dev, const __u8 sel, bool uuid)
28682868

28692869
struct nvme_get_features_args args = {
28702870
.result = (__u32 *)&cq_entry,
2871-
.data = entry,
2871+
.nsid = nsid,
28722872
.args_size = sizeof(args),
28732873
.fd = dev_fd(dev),
28742874
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
@@ -2891,22 +2891,23 @@ static int error_injection_get(struct nvme_dev *dev, const __u8 sel, bool uuid)
28912891
nvme_show_error("malloc: %s", strerror(errno));
28922892
return -errno;
28932893
}
2894+
args.data = entry;
28942895

28952896
err = nvme_cli_get_features(dev, &args);
28962897
if (!err) {
2897-
nvme_show_result("Number of Error Injecttions (feature: %#0*x): %#0*x (%s: %d)",
2898+
nvme_show_result("Number of Error Injections (feature: %#0*x): %#0*x (%s: %d)",
28982899
fid ? 4 : 2, fid, cq_entry.nume ? 10 : 8, cq_entry.nume,
28992900
nvme_select_to_string(sel), cq_entry.nume);
29002901
if (sel == NVME_GET_FEATURES_SEL_SUPPORTED)
29012902
nvme_show_select_result(fid, *args.result);
29022903
for (i = 0; i < cq_entry.nume; i++) {
29032904
printf("Entry: %d, Flags: %x (%s%s), Type: %x (%s), NRTDP: %d\n", i,
2904-
entry->flags, entry->enable ? "Enabled" : "Disabled",
2905-
entry->single ? ", Single instance" : "", entry->type,
2906-
erri_type_to_string(entry->type), entry->nrtdp);
2905+
entry[i].flags, entry[i].enable ? "Enabled" : "Disabled",
2906+
entry[i].single ? ", Single instance" : "", entry[i].type,
2907+
erri_type_to_string(entry[i].type), entry[i].nrtdp);
29072908
}
29082909
} else {
2909-
nvme_show_error("Could not get feature: %#0*x.", fid ? 4 : 2, fid);
2910+
nvme_show_error("Could not get feature: %#0*x. %d", fid ? 4 : 2, fid);
29102911
}
29112912

29122913
return err;
@@ -2919,21 +2920,31 @@ static int get_error_injection(int argc, char **argv, struct command *cmd, struc
29192920
struct config {
29202921
__u8 sel;
29212922
};
2923+
__u32 nsid;
29222924
struct config cfg = { 0 };
29232925

29242926
_cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
29252927

29262928
OPT_ARGS(opts) = {
29272929
OPT_BYTE("sel", 's', &cfg.sel, sel),
29282930
OPT_FLAG("no-uuid", 'n', NULL, no_uuid),
2931+
OPT_FLAG("all-ns", 'a', NULL, all_ns),
29292932
OPT_END()
29302933
};
29312934

29322935
err = parse_and_open(&dev, argc, argv, desc, opts);
29332936
if (err)
29342937
return err;
29352938

2936-
return error_injection_get(dev, cfg.sel, !argconfig_parse_seen(opts, "no-uuid"));
2939+
/*
2940+
* Different spec versions ask for different nsid values
2941+
* OCP v1.0 - NSID: Shall be set to zero
2942+
* OCP v2.0r21 - NSID: Shall be set to FFFFFFFFh.
2943+
* OCP v2.5 - NSID: The host should either clear this to zero or set this to FFFFFFFFh
2944+
*/
2945+
nsid = argconfig_parse_seen(opts, "all-ns") ? NVME_NSID_ALL : 0;
2946+
2947+
return error_injection_get(dev, cfg.sel, !argconfig_parse_seen(opts, "no-uuid"), nsid);
29372948
}
29382949

29392950
static int error_injection_set(struct nvme_dev *dev, struct erri_config *cfg, bool uuid, __u32 nsid)

0 commit comments

Comments
 (0)