diff --git a/Documentation/nvme-ocp-get-error-injection.txt b/Documentation/nvme-ocp-get-error-injection.txt index 8061e497bf..188c6b3f6a 100644 --- a/Documentation/nvme-ocp-get-error-injection.txt +++ b/Documentation/nvme-ocp-get-error-injection.txt @@ -9,7 +9,7 @@ SYNOPSIS -------- [verse] 'nvme ocp get-error-injection' [--no-uuid | -n] - [--sel=] + [--sel=] [--all-ns | -a] DESCRIPTION ----------- @@ -44,6 +44,11 @@ OPTIONS |4-7|Reserved |================== +-a:: +--all-ns:: + Send the command to all namespaces. This option is used to specify + whether to target all namespaces or no specific namespace. + EXAMPLES -------- * Has the program issue a get-error-injection to retrieve the 0xC0 get features. diff --git a/completions/_nvme b/completions/_nvme index 4717f9f920..88617a622d 100644 --- a/completions/_nvme +++ b/completions/_nvme @@ -345,6 +345,8 @@ _nvme () { -s':alias for --sel' --no-uuid':Skip UUID index search' -n':alias for --no-uuid' + --all-ns':Send the command to all namespaces' + -a':alias for --all-ns' ) _arguments '*:: :->subcmds' _describe -t commands "nvme ocp get-error-injection options" _get_error_injection @@ -368,6 +370,8 @@ _nvme () { --output-format=':Output format: normal|json|binary' -o ':alias for --output-format' --timeout=':value for timeout' + --all-ns':Send the command to all namespaces' + -a':alias for --all-ns' ) _arguments '*:: :->subcmds' _describe -t commands "nvme ocp set-error-injection options" _set_error_injection diff --git a/completions/bash-nvme-completion.sh b/completions/bash-nvme-completion.sh index 8f917a1d5e..e15617e3ad 100644 --- a/completions/bash-nvme-completion.sh +++ b/completions/bash-nvme-completion.sh @@ -1638,11 +1638,11 @@ plugin_ocp_opts () { opts+=" --output-file= -o" ;; "get-error-injection") - opts+=" --sel= -s --no-uuid -n" + opts+=" --sel= -s --no-uuid -n --all-ns -a" ;; "set-error-injection") opts+=" --data= -d --number= -n --no-uuid -N --type= -t \ - --nrtdp= -r --verbose -v --output-format -o --timeout=" + --nrtdp= -r --verbose -v --output-format -o --timeout= --all-ns -a" ;; "hardware-component-log") opts+=" --comp-id= -i --list -l --verbose -v \ diff --git a/plugins/ocp/ocp-nvme.c b/plugins/ocp/ocp-nvme.c index ac08a6d346..c3f4149d4b 100644 --- a/plugins/ocp/ocp-nvme.c +++ b/plugins/ocp/ocp-nvme.c @@ -2857,7 +2857,7 @@ static int fw_activation_history_log(int argc, char **argv, struct command *cmd, return ocp_fw_activation_history_log(argc, argv, cmd, plugin); } -static int error_injection_get(struct nvme_dev *dev, const __u8 sel, bool uuid) +static int error_injection_get(struct nvme_dev *dev, const __u8 sel, bool uuid, __u32 nsid) { struct erri_get_cq_entry cq_entry; int err; @@ -2868,7 +2868,7 @@ static int error_injection_get(struct nvme_dev *dev, const __u8 sel, bool uuid) struct nvme_get_features_args args = { .result = (__u32 *)&cq_entry, - .data = entry, + .nsid = nsid, .args_size = sizeof(args), .fd = dev_fd(dev), .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, @@ -2891,22 +2891,23 @@ static int error_injection_get(struct nvme_dev *dev, const __u8 sel, bool uuid) nvme_show_error("malloc: %s", strerror(errno)); return -errno; } + args.data = entry; err = nvme_cli_get_features(dev, &args); if (!err) { - nvme_show_result("Number of Error Injecttions (feature: %#0*x): %#0*x (%s: %d)", + nvme_show_result("Number of Error Injections (feature: %#0*x): %#0*x (%s: %d)", fid ? 4 : 2, fid, cq_entry.nume ? 10 : 8, cq_entry.nume, nvme_select_to_string(sel), cq_entry.nume); if (sel == NVME_GET_FEATURES_SEL_SUPPORTED) nvme_show_select_result(fid, *args.result); for (i = 0; i < cq_entry.nume; i++) { printf("Entry: %d, Flags: %x (%s%s), Type: %x (%s), NRTDP: %d\n", i, - entry->flags, entry->enable ? "Enabled" : "Disabled", - entry->single ? ", Single instance" : "", entry->type, - erri_type_to_string(entry->type), entry->nrtdp); + entry[i].flags, entry[i].enable ? "Enabled" : "Disabled", + entry[i].single ? ", Single instance" : "", entry[i].type, + erri_type_to_string(entry[i].type), entry[i].nrtdp); } } else { - nvme_show_error("Could not get feature: %#0*x.", fid ? 4 : 2, fid); + nvme_show_error("Could not get feature: %#0*x. %d", fid ? 4 : 2, fid); } return err; @@ -2919,6 +2920,7 @@ static int get_error_injection(int argc, char **argv, struct command *cmd, struc struct config { __u8 sel; }; + __u32 nsid; struct config cfg = { 0 }; _cleanup_nvme_dev_ struct nvme_dev *dev = NULL; @@ -2926,6 +2928,7 @@ static int get_error_injection(int argc, char **argv, struct command *cmd, struc OPT_ARGS(opts) = { OPT_BYTE("sel", 's', &cfg.sel, sel), OPT_FLAG("no-uuid", 'n', NULL, no_uuid), + OPT_FLAG("all-ns", 'a', NULL, all_ns), OPT_END() }; @@ -2933,7 +2936,15 @@ static int get_error_injection(int argc, char **argv, struct command *cmd, struc if (err) return err; - return error_injection_get(dev, cfg.sel, !argconfig_parse_seen(opts, "no-uuid")); + /* + * Different spec versions ask for different nsid values + * OCP v1.0 - NSID: Shall be set to zero + * OCP v2.0r21 - NSID: Shall be set to FFFFFFFFh. + * OCP v2.5 - NSID: The host should either clear this to zero or set this to FFFFFFFFh + */ + nsid = argconfig_parse_seen(opts, "all-ns") ? NVME_NSID_ALL : 0; + + return error_injection_get(dev, cfg.sel, !argconfig_parse_seen(opts, "no-uuid"), nsid); } static int error_injection_set(struct nvme_dev *dev, struct erri_config *cfg, bool uuid, __u32 nsid)