]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
plugins/solidigm: Added Identify controller VU extensions parsing.
authorleonardo.da.cunha <leonardo.da.cunha@solidigm.com>
Tue, 6 Jun 2023 23:37:06 +0000 (16:37 -0700)
committerDaniel Wagner <wagi@monom.org>
Sat, 17 Jun 2023 08:29:05 +0000 (10:29 +0200)
Signed-off-by: leonardo.da.cunha <leonardo.da.cunha@solidigm.com>
plugins/solidigm/meson.build
plugins/solidigm/solidigm-id-ctrl.c [new file with mode: 0644]
plugins/solidigm/solidigm-id-ctrl.h [new file with mode: 0644]
plugins/solidigm/solidigm-nvme.c
plugins/solidigm/solidigm-nvme.h

index cb28d4e6f68e4a111d8ccb687d4f5bc8fd6852a0..688e77b17c2f1e611d44891ae86483552733f6e1 100644 (file)
@@ -1,4 +1,5 @@
 sources += [
+  'plugins/solidigm/solidigm-id-ctrl.c',
   'plugins/solidigm/solidigm-util.c',
   'plugins/solidigm/solidigm-smart.c',
   'plugins/solidigm/solidigm-garbage-collection.c',
diff --git a/plugins/solidigm/solidigm-id-ctrl.c b/plugins/solidigm/solidigm-id-ctrl.c
new file mode 100644 (file)
index 0000000..f45e758
--- /dev/null
@@ -0,0 +1,73 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2023 Solidigm.
+ *
+ * Author: leonardo.da.cunha@solidigm.com
+ */
+
+#include <inttypes.h>
+#include "common.h"
+#include "solidigm-id-ctrl.h"
+
+struct __packed nvme_vu_id_ctrl_field { /* CDR MR5 */
+       __u8    rsvd1[3];
+       __u8 ss;
+       char health[20];
+       __u8 cls;
+       __u8 nlw;
+       __u8 scap;
+       __u8 sstat;
+       char bl[8];
+       __u8 rsvd2[38];
+       __le64 ww;
+       char mic_bl[4];
+       char mic_fw[4];
+};
+
+void sldgm_id_ctrl(uint8_t *vs, struct json_object *root)
+{
+       // text output aligns nicely with property name up to 10 chars
+       const char *str_ss = "stripeSize";
+       const char *str_health = "health";
+       const char *str_cls = "linkSpeed";
+       const char *str_nlw = "negLnkWdth";
+       const char *str_scap = "secCapab";
+       const char *str_sstat = "secStatus";
+       const char *str_bl = "bootLoader";
+       const char *str_ww = "wwid";
+       const char *str_mic_bl = "bwLimGran";
+       const char *str_mic_fw = "ioLimGran";
+
+       struct nvme_vu_id_ctrl_field *id = (struct nvme_vu_id_ctrl_field *)vs;
+
+       const char str_heathy[sizeof(id->health)] = "healthy";
+       const char *health = id->health[0] ? id->health : str_heathy;
+
+       if (root == NULL) {
+               printf("%-10s: %u\n", str_ss, id->ss);
+               printf("%-10s: %.*s\n", str_health, (int)sizeof(id->health), health);
+               printf("%-10s: %u\n", str_cls, id->cls);
+               printf("%-10s: %u\n", str_nlw, id->nlw);
+               printf("%-10s: %u\n", str_scap, id->scap);
+               printf("%-10s: %u\n", str_sstat, id->sstat);
+               printf("%-10s: %.*s\n", str_bl, (int)sizeof(id->bl), id->bl);
+               printf("%-10s: 0x%016"PRIx64"\n", str_ww, le64_to_cpu(id->ww));
+               printf("%-10s: %.*s\n", str_mic_bl, (int)sizeof(id->mic_bl), id->mic_bl);
+               printf("%-10s: %.*s\n", str_mic_fw, (int)sizeof(id->mic_fw), id->mic_fw);
+               return;
+       }
+
+       json_object_add_value_uint(root, str_ss, id->ss);
+       json_object_object_add(root, str_health,
+                              json_object_new_string_len(health, sizeof(id->health)));
+       json_object_add_value_uint(root, str_cls, id->cls);
+       json_object_add_value_uint(root, str_nlw, id->nlw);
+       json_object_add_value_uint(root, str_scap, id->scap);
+       json_object_add_value_uint(root, str_sstat, id->sstat);
+       json_object_object_add(root, str_bl, json_object_new_string_len(id->bl, sizeof(id->bl)));
+       json_object_add_value_uint64(root, str_ww, le64_to_cpu(id->ww));
+       json_object_object_add(root, str_mic_bl,
+                              json_object_new_string_len(id->mic_bl, sizeof(id->mic_bl)));
+       json_object_object_add(root, str_mic_fw,
+                              json_object_new_string_len(id->mic_fw, sizeof(id->mic_fw)));
+}
diff --git a/plugins/solidigm/solidigm-id-ctrl.h b/plugins/solidigm/solidigm-id-ctrl.h
new file mode 100644 (file)
index 0000000..ed6e438
--- /dev/null
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (c) 2023 Solidigm.
+ *
+ * Author: leonardo.da.cunha@solidigm.com
+ */
+
+#include <inttypes.h>
+#include "util/json.h"
+void sldgm_id_ctrl(uint8_t *vs, struct json_object *root);
index d8c82b1287dd7925e090f24823528de32f9a2019..bcc23146c34f3b9b2bfd8810739b96b160d1821e 100644 (file)
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 /*
- * Copyright (c) 2022 Solidigm.
+ * Copyright (c) 2022-2023 Solidigm.
  *
  * Author: leonardo.da.cunha@solidigm.com
  */
@@ -10,6 +10,7 @@
 #define CREATE_CMD
 #include "solidigm-nvme.h"
 
+#include "solidigm-id-ctrl.h"
 #include "solidigm-smart.h"
 #include "solidigm-internal-logs.h"
 #include "solidigm-garbage-collection.h"
 #include "plugins/ocp/ocp-smart-extended-log.h"
 #include "plugins/ocp/ocp-fw-activation-history.h"
 
+static int id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *plugin)
+{
+       return __id_ctrl(argc, argv, cmd, plugin, sldgm_id_ctrl);
+}
+
 static int get_additional_smart_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)
 {
        return solidigm_get_additional_smart_log(argc, argv, cmd, plugin);
index bb56aeb1cfc1e5657e6552f5daf9f18ffac0eb52..937ceafc2c97efe071ebf8e9b6b9022f9444bbf8 100644 (file)
 
 #include "cmd.h"
 
-#define SOLIDIGM_PLUGIN_VERSION "0.12"
+#define SOLIDIGM_PLUGIN_VERSION "0.13"
 
 PLUGIN(NAME("solidigm", "Solidigm vendor specific extensions", SOLIDIGM_PLUGIN_VERSION),
        COMMAND_LIST(
+               ENTRY("id-ctrl", "Send NVMe Identify Controller", id_ctrl)
                ENTRY("smart-log-add", "Retrieve Solidigm SMART Log", get_additional_smart_log)
                ENTRY("vs-smart-add-log", "Get SMART / health extended log (redirects to ocp plug-in)", smart_cloud)
                ENTRY("vs-internal-log", "Retrieve Debug log binaries", get_internal_log)