Skip to content

Commit caa1544

Browse files
ikegami-tigaw
authored andcommitted
ocp: add get-enable-ieee1667-silo command
The commands returns set of enable IEEE1667 silo. Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
1 parent 53f2b1a commit caa1544

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

plugins/ocp/ocp-nvme.c

+69
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ struct erri_config {
194194
__u16 nrtdp;
195195
};
196196

197+
struct ieee1667_get_cq_entry {
198+
__u32 enabled:3;
199+
__u32 rsvd3:29;
200+
};
201+
197202
static const char *sel = "[0-3]: current/default/saved/supported";
198203
static const char *no_uuid = "Skip UUID index search (UUID index not required for OCP 1.0)";
199204
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
41414146

41424147
return error_injection_set(dev, &cfg, !argconfig_parse_seen(opts, "no-uuid"));
41434148
}
4149+
4150+
static int enable_ieee1667_silo_get(struct nvme_dev *dev, const __u8 sel, bool uuid)
4151+
{
4152+
struct ieee1667_get_cq_entry cq_entry;
4153+
int err;
4154+
const __u8 fid = 0xc4;
4155+
4156+
struct nvme_get_features_args args = {
4157+
.result = (__u32 *)&cq_entry,
4158+
.args_size = sizeof(args),
4159+
.fd = dev_fd(dev),
4160+
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
4161+
.sel = sel,
4162+
.fid = fid,
4163+
};
4164+
4165+
if (uuid) {
4166+
/* OCP 2.0 requires UUID index support */
4167+
err = ocp_get_uuid_index(dev, &args.uuidx);
4168+
if (err || !args.uuidx) {
4169+
nvme_show_error("ERROR: No OCP UUID index found");
4170+
return err;
4171+
}
4172+
}
4173+
4174+
err = nvme_cli_get_features(dev, &args);
4175+
if (!err) {
4176+
if (sel == NVME_GET_FEATURES_SEL_SUPPORTED)
4177+
nvme_show_select_result(fid, *args.result);
4178+
else
4179+
nvme_show_result("IEEE1667 Sifo Enabled (feature: 0x%02x): 0x%0x (%s: %s)",
4180+
fid, cq_entry.enabled, nvme_select_to_string(sel),
4181+
cq_entry.enabled ? "enabled" : "disabled");
4182+
} else {
4183+
nvme_show_error("Could not get feature: 0x%02x.", fid);
4184+
}
4185+
4186+
return err;
4187+
}
4188+
4189+
static int get_enable_ieee1667_silo(int argc, char **argv, struct command *cmd,
4190+
struct plugin *plugin)
4191+
{
4192+
const char *desc = "return set of enable IEEE1667 silo";
4193+
int err;
4194+
struct config {
4195+
__u8 sel;
4196+
};
4197+
struct config cfg = { 0 };
4198+
4199+
_cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
4200+
4201+
OPT_ARGS(opts) = {
4202+
OPT_BYTE("sel", 's', &cfg.sel, sel),
4203+
OPT_FLAG("no-uuid", 'n', NULL, no_uuid),
4204+
OPT_END()
4205+
};
4206+
4207+
err = parse_and_open(&dev, argc, argv, desc, opts);
4208+
if (err)
4209+
return err;
4210+
4211+
return enable_ieee1667_silo_get(dev, cfg.sel, !argconfig_parse_seen(opts, "no-uuid"));
4212+
}

plugins/ocp/ocp-nvme.h

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ PLUGIN(NAME("ocp", "OCP cloud SSD extensions", OCP_PLUGIN_VERSION),
3838
ENTRY("tcg-configuration-log", "Retrieve TCG Configuration Log Page", ocp_tcg_configuration_log)
3939
ENTRY("get-error-injection", "Return set of error injection", get_error_injection)
4040
ENTRY("set-error-injection", "Inject error conditions", set_error_injection)
41+
ENTRY("get-enable-ieee1667-silo", "return set of enable IEEE1667 silo",
42+
get_enable_ieee1667_silo)
4143
)
4244
);
4345

0 commit comments

Comments
 (0)