nvme-cli: Implement printing the get timestamp feature.
PATCH 1/1 nvme-cli: Implement printing the get timestamp feature.
Signed-off-by Revanth Rajashekar <revanth.rajashekar at intel.com>
--- nvme-print.c | 15 +++++++++++++++ nvme.c | 3 +++ nvme.h | 6 ++++++ 3 files changed, 24 insertions(+)
nvme-print.c +15 -0
@@ -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 *bufcase 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 ; } }
nvme.c +3 -0
@@ -2072,6 +2072,9 @@ static int get_feature(int argc, char **argv, struct command *cmd, struct plugincase NVME_FEAT_PLM_CONFIG : cfg.data_len =512 ;break ; +case NVME_FEAT_TIMESTAMP : + cfg.data_len =8 ; +break ; }if (cfg.sel ==3 )
nvme.h +6 -0
@@ -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[];
Signature · 1 line
2.17.1
PATCH 1/1 nvme-cli: Implement printing the get timestamp feature.
nvme-print.c static void show_auto_pst(struct nvme_auto_pst *apst) · line 1646
Quoted 9 lines
nvme-print.c +9
-0+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." );
Can you use if / else statements insteda of the ? : operators to make this more redable?
Otherwise this looks fine to me.