From: Tokunori Ikegami Date: Sun, 8 Sep 2024 10:00:52 +0000 (+0900) Subject: ocp: add get-enable-ieee1667-silo command X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=caa1544693abbd17c3588afae718d265d0ef6933;p=users%2Fsagi%2Fnvme-cli.git ocp: add get-enable-ieee1667-silo command The commands returns set of enable IEEE1667 silo. Signed-off-by: Tokunori Ikegami --- diff --git a/plugins/ocp/ocp-nvme.c b/plugins/ocp/ocp-nvme.c index ef4e784e..1aa5ed0a 100644 --- a/plugins/ocp/ocp-nvme.c +++ b/plugins/ocp/ocp-nvme.c @@ -194,6 +194,11 @@ struct erri_config { __u16 nrtdp; }; +struct ieee1667_get_cq_entry { + __u32 enabled:3; + __u32 rsvd3:29; +}; + static const char *sel = "[0-3]: current/default/saved/supported"; static const char *no_uuid = "Skip UUID index search (UUID index not required for OCP 1.0)"; const char *data = "Error injection data structure entries"; @@ -4141,3 +4146,67 @@ static int set_error_injection(int argc, char **argv, struct command *cmd, struc return error_injection_set(dev, &cfg, !argconfig_parse_seen(opts, "no-uuid")); } + +static int enable_ieee1667_silo_get(struct nvme_dev *dev, const __u8 sel, bool uuid) +{ + struct ieee1667_get_cq_entry cq_entry; + int err; + const __u8 fid = 0xc4; + + struct nvme_get_features_args args = { + .result = (__u32 *)&cq_entry, + .args_size = sizeof(args), + .fd = dev_fd(dev), + .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, + .sel = sel, + .fid = fid, + }; + + if (uuid) { + /* OCP 2.0 requires UUID index support */ + err = ocp_get_uuid_index(dev, &args.uuidx); + if (err || !args.uuidx) { + nvme_show_error("ERROR: No OCP UUID index found"); + return err; + } + } + + err = nvme_cli_get_features(dev, &args); + if (!err) { + if (sel == NVME_GET_FEATURES_SEL_SUPPORTED) + nvme_show_select_result(fid, *args.result); + else + nvme_show_result("IEEE1667 Sifo Enabled (feature: 0x%02x): 0x%0x (%s: %s)", + fid, cq_entry.enabled, nvme_select_to_string(sel), + cq_entry.enabled ? "enabled" : "disabled"); + } else { + nvme_show_error("Could not get feature: 0x%02x.", fid); + } + + return err; +} + +static int get_enable_ieee1667_silo(int argc, char **argv, struct command *cmd, + struct plugin *plugin) +{ + const char *desc = "return set of enable IEEE1667 silo"; + int err; + struct config { + __u8 sel; + }; + struct config cfg = { 0 }; + + _cleanup_nvme_dev_ struct nvme_dev *dev = NULL; + + OPT_ARGS(opts) = { + OPT_BYTE("sel", 's', &cfg.sel, sel), + OPT_FLAG("no-uuid", 'n', NULL, no_uuid), + OPT_END() + }; + + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; + + return enable_ieee1667_silo_get(dev, cfg.sel, !argconfig_parse_seen(opts, "no-uuid")); +} diff --git a/plugins/ocp/ocp-nvme.h b/plugins/ocp/ocp-nvme.h index 16d929d5..de23de01 100644 --- a/plugins/ocp/ocp-nvme.h +++ b/plugins/ocp/ocp-nvme.h @@ -38,6 +38,8 @@ PLUGIN(NAME("ocp", "OCP cloud SSD extensions", OCP_PLUGIN_VERSION), ENTRY("tcg-configuration-log", "Retrieve TCG Configuration Log Page", ocp_tcg_configuration_log) ENTRY("get-error-injection", "Return set of error injection", get_error_injection) ENTRY("set-error-injection", "Inject error conditions", set_error_injection) + ENTRY("get-enable-ieee1667-silo", "return set of enable IEEE1667 silo", + get_enable_ieee1667_silo) ) );