From: Vigneshwaran Saravanan/SSD TS Dev /SSIR/Engineer/Samsung Electronics Date: Fri, 20 Oct 2023 07:45:43 +0000 (+0530) Subject: plugin/ocp_fid_c6h:Added the ocp C6h feature api X-Git-Tag: v2.7~102 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=416724bab3ab72d0a7e8dd4fcfdd5479e632d4e0;p=users%2Fsagi%2Fnvme-cli.git plugin/ocp_fid_c6h:Added the ocp C6h feature api Reviewed-by: Karthik Balan karthik.b82@samsung.com, Arunpandian J arun.j@samsung.com Signed-off-by: Vigneshwaran Saravanan/SSD TS Dev /SSIR/Engineer/Samsung Electronics --- diff --git a/Documentation/nvme-ocp-get-plp-health-check-interval.txt b/Documentation/nvme-ocp-get-plp-health-check-interval.txt new file mode 100644 index 00000000..7ecd5d50 --- /dev/null +++ b/Documentation/nvme-ocp-get-plp-health-check-interval.txt @@ -0,0 +1,54 @@ +nvme-ocp-get-plp-health-check-interval(1) +================================ + +NAME +---- +nvme-ocp-get-plp-health-check-interval - Define and print plp-health-check-interval value + +SYNOPSIS +-------- +[verse] +'nvme ocp get-plp-health-check-interval' [--sel=] + +DESCRIPTION +----------- +Define plp-health-check-interval. +No argument prints current mode. + +The parameter is mandatory and may be either the NVMe character +device (ex: /dev/nvme0) or block device (ex: /dev/nvme0n1). + +This will only work on OCP compliant devices supporting this feature. +Results for any other device are undefined. + +On success it returns 0, error code otherwise. + +OPTIONS +------- + +-s :: + Select (SEL): This field specifies which value of the attributes + to return in the provided data: ++ +[] +|================== +|Select|Description +|0|Current +|1|Default +|2|Saved +|3|Supported capabilities +|4-7|Reserved +|================== + +EXAMPLES +-------- +* Has the program issue a get-plp-health-check-interval to retrieve the 0xC6 get features. ++ +------------ +# nvme ocp get-plp-health-check-interval /dev/nvme0 +------------ + +NVME +---- +Part of the nvme-user suite. diff --git a/Documentation/nvme-ocp-set-plp-health-check-interval.txt b/Documentation/nvme-ocp-set-plp-health-check-interval.txt new file mode 100644 index 00000000..df02f4fc --- /dev/null +++ b/Documentation/nvme-ocp-set-plp-health-check-interval.txt @@ -0,0 +1,53 @@ +nvme-ocp-set-plp-health-check-interval(1) +================================ + +NAME +---- +nvme-ocp-set-plp-health-check-interval - Define and set PLP health check interval + +SYNOPSIS +-------- +[verse] +'nvme ocp set-plp-health-check-interval' [--plp_health_interval= | -p ] [--save | -s] [--no-uuid | -n] + + +DESCRIPTION +----------- +Define Set PLP health check interval. +No argument prints current mode. + +The parameter is mandatory and may be either the NVMe character +device (ex: /dev/nvme0) or block device (ex: /dev/nvme0n1). + +This will only work on OCP compliant devices supporting this feature. +Results for any other device are undefined. + +On success it returns 0, error code otherwise. + +OPTIONS +------- +-p :: +--plp_health_interval=:: + Set the plp health check interval [31:16] + +-n:: +--no-uuid:: + Do not try to automatically detect UUID index for this command (required + for old OCP 1.0 support) + +-s:: +--save:: + Save the attribute so that it persists through all power states and resets. + + +EXAMPLES +-------- +* Has the program issue a set-plp-health-check-interval to retrieve the 0xC6 set features. ++ +------------ +# nvme ocp eol-plp-failure-mode /dev/nvme0 +------------ + +NVME +---- +Part of the nvme-user suite. diff --git a/plugins/ocp/ocp-nvme.c b/plugins/ocp/ocp-nvme.c index fdb6b504..c62329fc 100644 --- a/plugins/ocp/ocp-nvme.c +++ b/plugins/ocp/ocp-nvme.c @@ -1960,6 +1960,144 @@ static int set_dssd_power_state_feature(int argc, char **argv, struct command *c return err; } +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +/// plp_health_check_interval + +static int set_plp_health_check_interval(int argc, char **argv, struct command *cmd, + struct plugin *plugin) +{ + const char *desc = "Define Issue Set Feature command (FID : 0xC2) PLP Health Check Interval"; + const char *plp_health_interval = "[31:16]:PLP Health Check Interval"; + const char *save = "Specifies that the controller shall save the attribute"; + const __u32 nsid = 0; + const __u8 fid = 0xc6; + struct nvme_dev *dev; + int err; + __u32 result; + int uuid_index = 0; + + struct config { + __le16 plp_health_interval; + bool save; + }; + + struct config cfg = { + .plp_health_interval = 0, + .save = false, + }; + + OPT_ARGS(opts) = { + OPT_BYTE("plp_health_interval", 'p', &cfg.plp_health_interval, plp_health_interval), + OPT_FLAG("save", 's', &cfg.save, save), + OPT_FLAG("no-uuid", 'n', NULL, + "Skip UUID index search (UUID index not required for OCP 1.0)"), + OPT_END() + }; + + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; + + + if (!argconfig_parse_seen(opts, "no-uuid")) { + /* OCP 2.0 requires UUID index support */ + err = ocp_get_uuid_index(dev, &uuid_index); + if (err || !uuid_index) { + printf("ERROR: No OCP UUID index found"); + return err; + } + } + + + struct nvme_set_features_args args = { + .args_size = sizeof(args), + .fd = dev_fd(dev), + .fid = fid, + .nsid = nsid, + .cdw11 = cfg.plp_health_interval << 16, + .cdw12 = 0, + .save = cfg.save, + .uuidx = uuid_index, + .cdw15 = 0, + .data_len = 0, + .data = NULL, + .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, + .result = &result, + }; + + err = nvme_set_features(&args); + if (err > 0) { + nvme_show_status(err); + } else if (err < 0) { + nvme_show_perror("Define PLP Health Check Interval"); + fprintf(stderr, "Command failed while parsing.\n"); + } else { + printf("Successfully set the PLP Health Check Interval"); + printf("PLP Health Check Interval: 0x%x\n", cfg.plp_health_interval); + printf("Save bit Value: 0x%x\n", cfg.save); + } + return err; +} + +static int get_plp_health_check_interval(int argc, char **argv, struct command *cmd, + struct plugin *plugin) +{ + const char *desc = "Define Issue Get Feature command (FID : 0xC2) PLP Health Check Interval"; + const char *sel = "[0-3,8]: current/default/saved/supported/changed"; + const __u32 nsid = 0; + const __u8 fid = 0xc6; + struct nvme_dev *dev; + __u32 result; + int err; + + struct config { + __u8 sel; + }; + + struct config cfg = { + .sel = 0, + }; + + OPT_ARGS(opts) = { + OPT_BYTE("sel", 'S', &cfg.sel, sel), + OPT_END() + }; + + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; + + + struct nvme_get_features_args args = { + .args_size = sizeof(args), + .fd = dev_fd(dev), + .fid = fid, + .nsid = nsid, + .sel = cfg.sel, + .cdw11 = 0, + .uuidx = 0, + .data_len = 0, + .data = NULL, + .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, + .result = &result, + }; + + err = nvme_get_features(&args); + if (!err) { + printf("get-feature:0xC6 %s value: %#08x\n", nvme_select_to_string(cfg.sel), result); + + if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED) + nvme_show_select_result(result); + } else { + nvme_show_error("Could not get feature: 0xC6"); + } + + return err; +} + /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/ocp/ocp-nvme.h b/plugins/ocp/ocp-nvme.h index dda4ffe3..dcbe27a8 100644 --- a/plugins/ocp/ocp-nvme.h +++ b/plugins/ocp/ocp-nvme.h @@ -27,6 +27,8 @@ PLUGIN(NAME("ocp", "OCP cloud SSD extensions", NVME_VERSION), ENTRY("error-recovery-log", "Retrieve Error Recovery Log Page", ocp_error_recovery_log) ENTRY("device-capability-log", "Get Device capabilities Requirements Log Page", ocp_device_capabilities_log) ENTRY("set-dssd-power-state-feature", "Get Device capabilities Requirements Log Page", set_dssd_power_state_feature) + ENTRY("set-plp-health-check-interval", "Set PLP Health Check Interval", set_plp_health_check_interval) + ENTRY("get-plp-health-check-interval", "Get PLP Health Check Interval", get_plp_health_check_interval) ) );