Skip to content

Commit 7d6cf87

Browse files
ikegami-tigaw
authored andcommitted
ocp: add set-enable-ieee1667-silo command
The command sets enable IEEE1667 silo. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent 22978d6 commit 7d6cf87

File tree

2 files changed

+68
-3
lines changed

2 files changed

+68
-3
lines changed

plugins/ocp/ocp-nvme.c

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "ocp-telemetry-decode.h"
3333
#include "ocp-hardware-component-log.h"
3434
#include "ocp-print.h"
35+
#include "ocp-types.h"
3536

3637
#define CREATE_CMD
3738
#include "ocp-nvme.h"
@@ -194,6 +195,8 @@ const char *data = "Error injection data structure entries";
194195
const char *number = "Number of valid error injection data entries";
195196
static const char *type = "Error injection type";
196197
static const char *nrtdp = "Number of reads to trigger device panic";
198+
static const char *save = "Specifies that the controller shall save the attribute";
199+
static const char *enable_ieee1667_silo = "enable IEEE1667 silo";
197200

198201
static int get_c3_log_page(struct nvme_dev *dev, char *format)
199202
{
@@ -544,8 +547,6 @@ static int eol_plp_failure_mode(int argc, char **argv, struct command *cmd,
544547
const char *desc = "Define EOL or PLP circuitry failure mode.\n"
545548
"No argument prints current mode.";
546549
const char *mode = "[0-3]: default/rom/wtm/normal";
547-
const char *save = "Specifies that the controller shall save the attribute";
548-
const char *sel = "[0-3]: current/default/saved/supported";
549550
const __u32 nsid = 0;
550551
const __u8 fid = 0xc2;
551552
struct nvme_dev *dev;
@@ -2242,7 +2243,6 @@ static int get_plp_health_check_interval(int argc, char **argv, struct command *
22422243
{
22432244

22442245
const char *desc = "Define Issue Get Feature command (FID : 0xC6) PLP Health Check Interval";
2245-
const char *sel = "[0-3,8]: current/default/saved/supported/changed";
22462246
const __u32 nsid = 0;
22472247
const __u8 fid = 0xc6;
22482248
struct nvme_dev *dev;
@@ -2875,6 +2875,70 @@ static int get_enable_ieee1667_silo(int argc, char **argv, struct command *cmd,
28752875
return enable_ieee1667_silo_get(dev, cfg.sel, !argconfig_parse_seen(opts, "no-uuid"));
28762876
}
28772877

2878+
static int enable_ieee1667_silo_set(struct nvme_dev *dev,
2879+
struct argconfig_commandline_options *opts)
2880+
{
2881+
struct ieee1667_get_cq_entry cq_entry;
2882+
int err;
2883+
const __u8 fid = 0xc4;
2884+
bool enable = argconfig_parse_seen(opts, "enable");
2885+
2886+
struct nvme_set_features_args args = {
2887+
.result = (__u32 *)&cq_entry,
2888+
.args_size = sizeof(args),
2889+
.fd = dev_fd(dev),
2890+
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
2891+
.cdw11 = OCP_SET(enable, ENABLE_IEEE1667_SILO),
2892+
.save = argconfig_parse_seen(opts, "save"),
2893+
.fid = fid,
2894+
};
2895+
2896+
if (!argconfig_parse_seen(opts, "no-uuid")) {
2897+
/* OCP 2.0 requires UUID index support */
2898+
err = ocp_get_uuid_index(dev, &args.uuidx);
2899+
if (err || !args.uuidx) {
2900+
nvme_show_error("ERROR: No OCP UUID index found");
2901+
return err;
2902+
}
2903+
}
2904+
2905+
err = nvme_cli_set_features(dev, &args);
2906+
if (err > 0) {
2907+
nvme_show_status(err);
2908+
} else if (err < 0) {
2909+
nvme_show_perror(enable_ieee1667_silo);
2910+
fprintf(stderr, "Command failed while parsing.\n");
2911+
} else {
2912+
enable = OCP_GET(args.cdw11, ENABLE_IEEE1667_SILO);
2913+
nvme_show_result("Successfully set enable (feature: 0x%02x): %d (%s: %s).", fid,
2914+
enable, args.save ? "Save" : "Not save",
2915+
enable ? "Enabled" : "Disabled");
2916+
}
2917+
2918+
return err;
2919+
}
2920+
2921+
static int set_enable_ieee1667_silo(int argc, char **argv, struct command *cmd,
2922+
struct plugin *plugin)
2923+
{
2924+
int err;
2925+
2926+
_cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
2927+
2928+
OPT_ARGS(opts) = {
2929+
OPT_FLAG("enable", 'e', NULL, no_uuid),
2930+
OPT_FLAG("save", 's', NULL, save),
2931+
OPT_FLAG("no-uuid", 'n', NULL, no_uuid),
2932+
OPT_END()
2933+
};
2934+
2935+
err = parse_and_open(&dev, argc, argv, enable_ieee1667_silo, opts);
2936+
if (err)
2937+
return err;
2938+
2939+
return enable_ieee1667_silo_set(dev, opts);
2940+
}
2941+
28782942
static int hwcomp_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)
28792943
{
28802944
return ocp_hwcomp_log(argc, argv, cmd, plugin);

plugins/ocp/ocp-nvme.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ PLUGIN(NAME("ocp", "OCP cloud SSD extensions", OCP_PLUGIN_VERSION),
4040
ENTRY("set-error-injection", "Inject error conditions", set_error_injection)
4141
ENTRY("get-enable-ieee1667-silo", "return set of enable IEEE1667 silo",
4242
get_enable_ieee1667_silo)
43+
ENTRY("set-enable-ieee1667-silo", "enable IEEE1667 silo", set_enable_ieee1667_silo)
4344
ENTRY("hardware-component-log", "retrieve hardware component log", hwcomp_log)
4445
)
4546
);

0 commit comments

Comments
 (0)