]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-print: Add Controller Metadata and Namespace Metadata
authorDaniel Wagner <dwagner@suse.de>
Fri, 17 Dec 2021 15:45:10 +0000 (16:45 +0100)
committerDaniel Wagner <dwagner@suse.de>
Fri, 17 Dec 2021 16:46:02 +0000 (17:46 +0100)
Port and extent the libnvme part from the commit b8a403b ("Add NVMe MI
Features: Controller Metadata (0x7E) and Namespace Metadata (0x7F).")
from the nvme-cli monolithic branch.

While at it add the missing definitions.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
libnvme
nvme-print.c
subprojects/libnvme.wrap

diff --git a/libnvme b/libnvme
index e4ab11b3fac33b397932a562b634533d9985073e..cfc9f9be07f365e07a8c5a27d2ddb9e7bbae5eae 160000 (submodule)
--- a/libnvme
+++ b/libnvme
@@ -1 +1 @@
-Subproject commit e4ab11b3fac33b397932a562b634533d9985073e
+Subproject commit cfc9f9be07f365e07a8c5a27d2ddb9e7bbae5eae
index 27bee7e03ea87c8f718a43a5670c5e6069b4b491..894d25711ede52c55f72df7630eb46248d317b92 100644 (file)
@@ -5982,6 +5982,8 @@ const char *nvme_feature_to_string(enum nvme_features_id feature)
        case NVME_FEAT_FID_ENDURANCE_EVT_CFG:   return "Enduarance Event Group Configuration";
        case NVME_FEAT_FID_IOCS_PROFILE:        return "I/O Command Set Profile";
        case NVME_FEAT_FID_SPINUP_CONTROL:      return "Spinup Control";
+       case NVME_FEAT_FID_CTRL_METADATA:       return "Controller Metadata";
+       case NVME_FEAT_FID_NS_METADATA: return "Namespace Metadata";
        case NVME_FEAT_FID_SW_PROGRESS: return "Software Progress";
        case NVME_FEAT_FID_HOST_ID:     return "Host Identifier";
        case NVME_FEAT_FID_RESV_MASK:   return "Reservation Notification Mask";
@@ -6296,6 +6298,90 @@ static void nvme_show_plm_config(struct nvme_plm_config *plmcfg)
        printf("\tDTWIN Time Threshold  :%"PRIu64"\n", le64_to_cpu(plmcfg->dtwintt));
 }
 
+static char *nvme_show_host_metadata_type_to_string(enum nvme_features_id fid,
+                                                   __u8 type)
+{
+       switch (fid) {
+       case NVME_FEAT_FID_CTRL_METADATA:
+              switch (type) {
+              case NVME_CTRL_METADATA_OS_CTRL_NAME:
+                      return "Operating System Controller Name";
+              case NVME_CTRL_METADATA_OS_DRIVER_NAME:
+                      return "Operating System Driver Name";
+              case NVME_CTRL_METADATA_OS_DRIVER_VER:
+                      return "Operating System Driver Version";
+              case NVME_CTRL_METADATA_PRE_BOOT_CTRL_NAME:
+                      return "Pre-boot Controller Name";
+              case NVME_CTRL_METADATA_PRE_BOOT_DRIVER_NAME:
+                      return "Pre-boot Driver Name";
+              case NVME_CTRL_METADATA_PRE_BOOT_DRIVER_VER:
+                      return "Pre-boot Driver Version";
+              case NVME_CTRL_METADATA_SYS_PROC_MODEL:
+                      return "System Processor Model";
+              case NVME_CTRL_METADATA_CHIPSET_DRV_NAME:
+                      return "Chipset Driver Name";
+              case NVME_CTRL_METADATA_CHIPSET_DRV_VERSION:
+                      return "Chipset Driver Version";
+              case NVME_CTRL_METADATA_OS_NAME_AND_BUILD:
+                      return "Operating System Name and Build";
+              case NVME_CTRL_METADATA_SYS_PROD_NAME:
+                      return "System Product Name";
+              case NVME_CTRL_METADATA_FIRMWARE_VERSION:
+                      return "Firmware Version";
+              case NVME_CTRL_METADATA_OS_DRIVER_FILENAME:
+                      return "Operating System Driver Filename";
+              case NVME_CTRL_METADATA_DISPLAY_DRV_NAME:
+                      return "Display Driver Name";
+              case NVME_CTRL_METADATA_DISPLAY_DRV_VERSION:
+                      return "Display Driver Version";
+              case NVME_CTRL_METADATA_HOST_DET_FAIL_REC:
+                      return "Host-Determined Failure Record";
+              default:
+                      return "Unknown Controller Type";
+              }
+       case NVME_FEAT_FID_NS_METADATA:
+              switch (type) {
+              case NVME_NS_METADATA_OS_NS_NAME:
+                      return "Operating System Namespace Name";
+              case NVME_NS_METADATA_PRE_BOOT_NS_NAME:
+                      return "Pre-boot Namespace Name";
+              case NVME_NS_METADATA_OS_NS_QUAL_1:
+                      return "Operating System Namespace Name Qualifier 1";
+              case NVME_NS_METADATA_OS_NS_QUAL_2:
+                      return "Operating System Namespace Name Qualifier 2";
+              default:
+                      return "Unknown Namespace Type";
+              }
+       default:
+              return "Unknown Feature";
+       }
+}
+
+static void nvme_show_host_metadata(enum nvme_features_id fid,
+                                   struct nvme_host_metadata *data)
+{
+       struct nvme_metadata_element_desc *desc = &data->descs[0];
+       int i;
+       char val[4096];
+       __u16 len;
+
+       printf("\tNum Metadata Element Descriptors: %d\n", data->ndesc);
+       for (i = 0; i < data->ndesc; i++) {
+              len = le16_to_cpu(desc->len);
+              strncpy(val, (char *)desc->val, min(sizeof(val) - 1, len));
+
+              printf("\tElement[%-3d]:\n", i);
+              printf("\t\tType     : 0x%02x (%s)\n", desc->type,
+                      nvme_show_host_metadata_type_to_string(fid, desc->type));
+              printf("\t\tRevision : %d\n", desc->rev);
+              printf("\t\tLength   : %d\n", len);
+              printf("\t\tValue    : %s\n", val);
+
+              desc = (struct nvme_metadata_element_desc *)
+                      &desc->val[desc->len];
+       }
+}
+
 void nvme_feature_show_fields(enum nvme_features_id fid, unsigned int result, unsigned char *buf)
 {
        __u8 field;
@@ -6428,6 +6514,10 @@ void nvme_feature_show_fields(enum nvme_features_id fid, unsigned int result, un
        case NVME_FEAT_FID_SPINUP_CONTROL:
                printf("\tSpinup control feature Enabled: %s\n", (result & 1) ? "True" : "False");
                break;
+       case NVME_FEAT_FID_CTRL_METADATA:
+       case NVME_FEAT_FID_NS_METADATA:
+               nvme_show_host_metadata(fid, (struct nvme_host_metadata *)buf);
+               break;
        case NVME_FEAT_FID_SW_PROGRESS:
                printf("\tPre-boot Software Load Count (PBSLC): %u\n", result & 0x000000ff);
                break;
index 0dc91f6d100f9029daf3137dad25416a561ecc40..ae0da728a96e7bf1b7b08c2fc67f7ee507cec854 100644 (file)
@@ -1,3 +1,3 @@
 [wrap-git]
 url = https://github.com/linux-nvme/libnvme.git
-revision = e4ab11b3fac33b397932a562b634533d9985073e
+revision = cfc9f9be07f365e07a8c5a27d2ddb9e7bbae5eae