'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',
--- /dev/null
+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
'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')
--- /dev/null
+sources += [
+ 'plugins/ocp/ocp-utils.c',
+ 'plugins/ocp/ocp-nvme.c',
+ 'plugins/ocp/ocp-clear-fw-update-history.c',
+]
+
--- /dev/null
+// 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;
+}
--- /dev/null
+/* 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);
#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"
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);
+}
#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
--- /dev/null
+// 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;
+}
--- /dev/null
+/* 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);
#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)
{
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);
+}
#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(
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)
)
);