]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
solidigm, ocp: Added OCP-Clear-FW-Update-History support, and exposed feature on...
authorhpanosy <haro.panosyan@intel.com>
Thu, 11 Aug 2022 23:34:13 +0000 (16:34 -0700)
committerleonardo.da.cunha <leo.da.cunha@solidigm.com>
Wed, 14 Dec 2022 20:19:02 +0000 (12:19 -0800)
12 files changed:
Documentation/meson.build
Documentation/nvme-ocp-clear-fw-activate-history.txt [new file with mode: 0644]
plugins/meson.build
plugins/ocp/meson.build [new file with mode: 0644]
plugins/ocp/ocp-clear-fw-update-history.c [new file with mode: 0644]
plugins/ocp/ocp-clear-fw-update-history.h [new file with mode: 0644]
plugins/ocp/ocp-nvme.c
plugins/ocp/ocp-nvme.h
plugins/ocp/ocp-utils.c [new file with mode: 0644]
plugins/ocp/ocp-utils.h [new file with mode: 0644]
plugins/solidigm/solidigm-nvme.c
plugins/solidigm/solidigm-nvme.h

index a15d1e4b87f589fcea413ec0afba08bc8d3edf32..68be45fa0c5df77e94726eb991e384e73e18934c 100644 (file)
@@ -78,6 +78,7 @@ adoc_sources = [
   'nvme-nvm-id-ctrl',
   'nvme-ocp-latency-monitor-log',
   'nvme-ocp-smart-add-log',
+  'nvme-ocp-clear-fw-activate-history',
   'nvme-persistent-event-log',
   'nvme-pred-lat-event-agg-log',
   'nvme-predictable-lat-log',
diff --git a/Documentation/nvme-ocp-clear-fw-activate-history.txt b/Documentation/nvme-ocp-clear-fw-activate-history.txt
new file mode 100644 (file)
index 0000000..2108480
--- /dev/null
@@ -0,0 +1,49 @@
+nvme-ocp-clear-fw-activate-history(1)
+=====================================
+
+NAME
+----
+nvme-ocp-clear-fw-activate-history - Clear the OCP Firmware Update History Log
+
+SYNOPSIS
+--------
+[verse]
+'nvme ocp clear-fw-activate-history' <device> [--no-uuid | -n>]
+
+DESCRIPTION
+-----------
+For the NVMe device given, Clear OCP Firmware Update History Log.
+
+The <device> parameter is mandatory and may be either the NVMe character
+device (ex: /dev/nvme0) or block device (ex: /dev/nvme0n1).
+
+This command with no option added, will try to automatically detect the
+parameters of the command. This will work successfully or fail gracefully for
+devices supporting UUID for Vendor Specific Information (NVMe 1.4 or later,
+OCP 2.0 requires NVMe 1.4b). For devices that do not support OCP 2.0 the
+command will fail gracefully, unless the --no-uuid option is provided.
+
+For OCP 1.0 devices (before NVMe 1.4) the --no-uuid option is required.
+When --no-uuid option is provided, results for devices before NVMe 1.4 without
+OCP support are undefined.
+
+On success it returns 0, error code otherwise.
+
+OPTIONS
+-------
+-n::
+--no-uuid::
+       Do not try to automatically detect UUID index for this command (required
+        for old OCP 1.0 support)
+
+EXAMPLES
+--------
+* Clears OCP Firmware Activation History Log for the device:
++
+------------
+# nvme ocp clear-fw-activate-history /dev/nvme0
+------------
+
+NVME
+----
+Part of the nvme-user suite.
\ No newline at end of file
index e6d9aaab6e77f867852d4b5a9f8bc0f976f8b15c..52b7f4aea7b39b69fa6badc2843a09f00c722522 100644 (file)
@@ -22,7 +22,7 @@ sources += [
   'plugins/wdc/wdc-nvme.c',
   'plugins/ymtc/ymtc-nvme.c',
   'plugins/zns/zns.c',
-  'plugins/ocp/ocp-nvme.c',
   'plugins/inspur/inspur-nvme.c',
 ]
 subdir('solidigm')
+subdir('ocp')
diff --git a/plugins/ocp/meson.build b/plugins/ocp/meson.build
new file mode 100644 (file)
index 0000000..a4e5d20
--- /dev/null
@@ -0,0 +1,6 @@
+sources += [
+  'plugins/ocp/ocp-utils.c',
+  'plugins/ocp/ocp-nvme.c',
+  'plugins/ocp/ocp-clear-fw-update-history.c',
+]
+
diff --git a/plugins/ocp/ocp-clear-fw-update-history.c b/plugins/ocp/ocp-clear-fw-update-history.c
new file mode 100644 (file)
index 0000000..fef09cf
--- /dev/null
@@ -0,0 +1,73 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2022 Solidigm.
+ *
+ * Authors: haro.panosyan@solidigm.com
+ *          leonardo.da.cunha@solidigm.com
+ */
+
+#include <unistd.h>
+#include "ocp-utils.h"
+#include "nvme-print.h"
+
+static const __u8 OCP_FID_CLEAR_FW_ACTIVATION_HISTORY = 0xC1;
+
+int ocp_clear_fw_update_history(int argc, char **argv, struct command *cmd, struct plugin *plugin)
+{
+       const char *desc = "OCP Clear Firmware Update History";
+       __u32 result = 0;
+       __u32 clear_fw_history = 1 << 31;
+       struct nvme_dev *dev;
+       int uuid_index = 0;
+       bool no_uuid = false;
+       int err;
+
+       OPT_ARGS(opts) = {
+               OPT_FLAG("no-uuid", 'n', &no_uuid,
+                        "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 (no_uuid == false) {
+               // OCP 2.0 requires UUID index support
+               err = ocp_get_uuid_index(dev, &uuid_index);
+               if (err || uuid_index == 0) {
+                       fprintf(stderr, "ERROR: No OCP UUID index found\n");
+                       goto close_dev;
+               }
+       }
+
+       struct nvme_set_features_args args = {
+               .result = &result,
+               .data = NULL,
+               .args_size = sizeof(args),
+               .fd = dev_fd(dev),
+               .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
+               .nsid = 0,
+               .cdw11 = clear_fw_history,
+               .cdw12 = 0,
+               .cdw13 = 0,
+               .cdw15 = 0,
+               .data_len = 0,
+               .save = 0,
+               .uuidx = uuid_index,
+               .fid = OCP_FID_CLEAR_FW_ACTIVATION_HISTORY,
+       };
+
+       err = nvme_set_features(&args);
+
+       if (err == 0)
+               printf("Success : %s\n", desc);
+       else if (err > 0)
+               nvme_show_status(err);
+       else
+               printf("Fail : %s\n", desc);
+close_dev:
+       /* Redundant close() to make static code analysis happy */
+       close(dev->direct.fd);
+       dev_close(dev);
+       return err;
+}
diff --git a/plugins/ocp/ocp-clear-fw-update-history.h b/plugins/ocp/ocp-clear-fw-update-history.h
new file mode 100644 (file)
index 0000000..25fb6b1
--- /dev/null
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (c) 2022 Solidigm.
+ *
+ * Authors: haro.panosyan@solidigm.com
+ *          leonardo.da.cunha@solidigm.com
+ */
+
+int ocp_clear_fw_update_history(int argc, char **argv, struct command *cmd, struct plugin *plugin);
index 5cbf6cb2ad7d11195e45721e061c9246b63c4742..14a5f306d159a66ef429c7a818642b8f9c5f2140 100644 (file)
@@ -22,6 +22,7 @@
 #include "linux/types.h"
 #include "util/types.h"
 #include "nvme-print.h"
+#include "ocp-clear-fw-update-history.h"
 
 #define CREATE_CMD
 #include "ocp-nvme.h"
@@ -765,3 +766,9 @@ static int ocp_latency_monitor_log(int argc, char **argv, struct command *comman
         dev_close(dev);
         return ret;
 }
+
+static int clear_fw_update_history(int argc, char **argv, struct command *cmd,
+                                  struct plugin *plugin)
+{
+       return ocp_clear_fw_update_history(argc, argv, cmd, plugin);
+}
index 3e3f437aeaaf51db855388209824268193229deb..c20646a2445664f4ccd2630660e6eeac652bb3e5 100644 (file)
 #include "cmd.h"
 
 PLUGIN(NAME("ocp", "OCP cloud SSD extensions", NVME_VERSION),
-    COMMAND_LIST(
-        ENTRY("smart-add-log", "Retrieve extended SMART Information", ocp_smart_add_log)
-        ENTRY("latency-monitor-log", "Get Latency Monitor Log Page", ocp_latency_monitor_log)
-    )
+       COMMAND_LIST(
+               ENTRY("smart-add-log", "Retrieve extended SMART Information", ocp_smart_add_log)
+               ENTRY("latency-monitor-log", "Get Latency Monitor Log Page",
+                     ocp_latency_monitor_log)
+               ENTRY("clear-fw-activate-history", "Clear firmware update history log",
+                     clear_fw_update_history)
+       )
 );
 
 #endif
diff --git a/plugins/ocp/ocp-utils.c b/plugins/ocp/ocp-utils.c
new file mode 100644 (file)
index 0000000..9294c05
--- /dev/null
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2022 Solidigm.
+ *
+ * Author: leonardo.da.cunha@solidigm.com
+ */
+
+#include "ocp-utils.h"
+
+const unsigned char ocp_uuid[NVME_UUID_LEN] = {
+       0x6f, 0xbe, 0x56, 0x8f, 0x99, 0x29, 0x1d, 0xa2, 0x94, 0x47,
+       0x94, 0xe0, 0x5b, 0xd5, 0x94, 0xc1 };
+
+int ocp_get_uuid_index(struct nvme_dev *dev, int *index)
+{
+       struct nvme_id_uuid_list uuid_list;
+       int err = nvme_identify_uuid(dev_fd(dev), &uuid_list);
+
+       *index = 0;
+       if (err)
+               return err;
+
+       for (int i = 0; i < NVME_ID_UUID_LIST_MAX; i++) {
+               if (memcmp(ocp_uuid, &uuid_list.entry[i].uuid, NVME_UUID_LEN) == 0) {
+                       *index = i + 1;
+                       break;
+               }
+       }
+       return err;
+}
diff --git a/plugins/ocp/ocp-utils.h b/plugins/ocp/ocp-utils.h
new file mode 100644 (file)
index 0000000..44d0af4
--- /dev/null
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (c) 2022 Solidigm.
+ *
+ * Author: leonardo.da.cunha@solidigm.com
+ */
+
+#include "nvme.h"
+
+/**
+ * ocp_get_uuid_index() - Get OCP UUID index
+ * @dev:       nvme device
+ * @index:     integer ponter to here to save the index
+ * @result:    The command completion result from CQE dword0
+ *
+ * Return: Zero if nvme device has UUID list log page, or result of get uuid list otherwise.
+ */
+int ocp_get_uuid_index(struct nvme_dev *dev, int *index);
index 684648ad06a1651da9a4f5e24fabe8af142e495f..b547035cfa9d37a40f47ec9027b4a8b227c6c023 100644 (file)
@@ -14,6 +14,7 @@
 #include "solidigm-garbage-collection.h"
 #include "solidigm-latency-tracking.h"
 #include "solidigm-telemetry.h"
+#include "plugins/ocp/ocp-clear-fw-update-history.h"
 
 static int get_additional_smart_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)
 {
@@ -33,4 +34,10 @@ static int get_latency_tracking_log(int argc, char **argv, struct command *cmd,
 static int get_telemetry_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)
 {
        return solidigm_get_telemetry_log(argc, argv, cmd, plugin);
-}
\ No newline at end of file
+}
+
+static int clear_fw_update_history(int argc, char **argv, struct command *cmd,
+                                                                  struct plugin *plugin)
+{
+       return ocp_clear_fw_update_history(argc, argv, cmd, plugin);
+}
index ed48400093b2dfe1a8e4cf16be7ed7447249afd9..778dbf99f63aeb601c72f9802dc3e8603797f4a3 100644 (file)
@@ -13,7 +13,7 @@
 
 #include "cmd.h"
 
-#define SOLIDIGM_PLUGIN_VERSION "0.6"
+#define SOLIDIGM_PLUGIN_VERSION "0.7"
 
 PLUGIN(NAME("solidigm", "Solidigm vendor specific extensions", SOLIDIGM_PLUGIN_VERSION),
        COMMAND_LIST(
@@ -21,6 +21,9 @@ PLUGIN(NAME("solidigm", "Solidigm vendor specific extensions", SOLIDIGM_PLUGIN_V
                ENTRY("garbage-collect-log", "Retrieve Garbage Collection Log", get_garbage_collection_log)
                ENTRY("latency-tracking-log", "Enable/Retrieve Latency tracking Log", get_latency_tracking_log)
                ENTRY("parse-telemetry-log", "Parse Telemetry Log binary", get_telemetry_log)
+               ENTRY("clear-fw-activate-history",
+                     "Clear firmware update history log (redirects to ocp plug-in)",
+                     clear_fw_update_history)
        )
 );