]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
ocp: add get-enable-ieee1667-silo command
authorTokunori Ikegami <ikegami.t@gmail.com>
Sun, 8 Sep 2024 10:00:52 +0000 (19:00 +0900)
committerDaniel Wagner <wagi@monom.org>
Mon, 16 Sep 2024 10:52:14 +0000 (12:52 +0200)
The commands returns set of enable IEEE1667 silo.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
plugins/ocp/ocp-nvme.c
plugins/ocp/ocp-nvme.h

index ef4e784e1092de4d977e68681869335ddda30156..1aa5ed0a5993382f386338aceeb0bcca781d0f6f 100644 (file)
@@ -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"));
+}
index 16d929d522dc269413c6217d543d5addd8fd981f..de23de01e085190e3025719d648f594101b7b932 100644 (file)
@@ -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)
        )
 );