]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-cli: Implement printing the get timestamp feature.
authorRevanth Rajashekar <revanth.rajashekar@intel.com>
Wed, 13 Jun 2018 19:53:52 +0000 (13:53 -0600)
committerKeith Busch <keith.busch@intel.com>
Thu, 14 Jun 2018 22:16:13 +0000 (16:16 -0600)
Signed-off-by: Revanth Rajashekar <revanth.rajashekar@intel.com>
Signed-off-by: Keith Busch <keith.busch@intel.com>
nvme-print.c
nvme.c
nvme.h

index cdaf1cbda3e08c4e9105d7a9a43ca578581334e7..242eb4e4b50044ab705df278abeaf93596502b09 100644 (file)
@@ -1450,6 +1450,7 @@ char *nvme_feature_to_string(int feature)
        case NVME_FEAT_HOST_ID:         return "Host Identifier";
        case NVME_FEAT_RESV_MASK:       return "Reservation Notification Mask";
        case NVME_FEAT_RESV_PERSIST:    return "Reservation Persistence";
+       case NVME_FEAT_TIMESTAMP:       return "Timestamp";
        default:                        return "Unknown";
        }
 }
@@ -1634,6 +1635,17 @@ static void show_auto_pst(struct nvme_auto_pst *apst)
        }
 }
 
+static void show_timestamp(struct nvme_timestamp *ts)
+{
+       printf("\tThe timestamp is : %lu\n", int48_to_long(ts->timestamp));
+       printf("\t%s\n", (ts->attr & 2) ? "The Timestamp field was initialized with a "\
+                       "Timestamp value using a Set Features command." : "The Timestamp field was initialized "\
+                       "to ‘0’ by a Controller Level Reset.");
+       printf("\t%s\n", (ts->attr & 1) ? "The controller may have stopped counting during vendor specific "\
+                       "intervals after the Timestamp value was initialized" : "The controller counted time in milliseconds "\
+                       "continuously since the Timestamp value was initialized.");
+}
+
 static void show_host_mem_buffer(struct nvme_host_mem_buffer *hmb)
 {
        printf("\tHost Memory Descriptor List Entry Count (HMDLEC): %u\n", hmb->hmdlec);
@@ -1807,6 +1819,9 @@ void nvme_feature_show_fields(__u32 fid, unsigned int result, unsigned char *buf
        case NVME_FEAT_RESV_PERSIST:
                printf("\tPersist Through Power Loss (PTPL): %s\n", (result & 0x00000001) ? "True":"False");
                break;
+       case NVME_FEAT_TIMESTAMP:
+               show_timestamp((struct nvme_timestamp *)buf);
+               break;
        }
 }
 
diff --git a/nvme.c b/nvme.c
index db0337ac70e9ea3cb0f2859231e3324970ba5b6a..2dd74d22b9719abbe41fc6fdfe08a4d465ec22a6 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -2072,6 +2072,9 @@ static int get_feature(int argc, char **argv, struct command *cmd, struct plugin
        case NVME_FEAT_PLM_CONFIG:
                cfg.data_len = 512;
                break;
+       case NVME_FEAT_TIMESTAMP:
+               cfg.data_len = 8;
+               break;
        }
 
        if (cfg.sel == 3)
diff --git a/nvme.h b/nvme.h
index 94e42f1e190291c5efea65261cf2b3e40da8ac10..5098b0ef9c7c607dcf0c48dc361a8812cdc7f988 100644 (file)
--- a/nvme.h
+++ b/nvme.h
@@ -76,6 +76,12 @@ struct nvme_auto_pst {
        __u32   rsvd32;
 };
 
+struct nvme_timestamp {
+       __u8 timestamp[6];
+       __u8 attr;
+       __u8 rsvd;
+};
+
 struct nvme_controller_list {
        __le16 num;
        __le16 identifier[];