]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
plugin/ocp_fid_c6h:Added the ocp C6h feature api
authorVigneshwaran Saravanan/SSD TS Dev /SSIR/Engineer/Samsung Electronics <s.vignesh@samsung.com>
Fri, 20 Oct 2023 07:45:43 +0000 (13:15 +0530)
committerDaniel Wagner <wagi@monom.org>
Tue, 7 Nov 2023 08:05:12 +0000 (09:05 +0100)
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 <s.vignesh@samsung.com>
Documentation/nvme-ocp-get-plp-health-check-interval.txt [new file with mode: 0644]
Documentation/nvme-ocp-set-plp-health-check-interval.txt [new file with mode: 0644]
plugins/ocp/ocp-nvme.c
plugins/ocp/ocp-nvme.h

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 (file)
index 0000000..7ecd5d5
--- /dev/null
@@ -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' <device> [--sel=<select> | -s <select>]
+
+DESCRIPTION
+-----------
+Define plp-health-check-interval.
+No argument prints current mode.
+
+The <device> 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=<select>::
+       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 (file)
index 0000000..df02f4f
--- /dev/null
@@ -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' <device> [--plp_health_interval=<plp_health_interval> | -p <plp_health_interval>] [--save | -s] [--no-uuid | -n] 
+
+
+DESCRIPTION
+-----------
+Define Set PLP health check interval.
+No argument prints current mode.
+
+The <device> 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>::
+--plp_health_interval=<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.
index fdb6b5047f2b088bb4ae0ca15ac16f0c5e9c2815..c62329fcbcddcc841f9eb5a65cac7d0fb6b2c73b 100644 (file)
@@ -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;
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////
index dda4ffe32cfb2e0cdd3a04ec7a6ff0981bfd4d72..dcbe27a82f4e59754487cf03e0ea79e048833b97 100644 (file)
@@ -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)
        )
 );