Skip to contentSkip to conversation

Update Persistent Event Log

PATCH New [email protected] 1 participant 4 messages May 4, 2021 NVMe

lore
Share & tools
lore
#0 lore raw

v2 cover Update Persistent Event Log

From: Wen Xiong <[email protected]>

Hi All,

We have tested persistent event log with two kinds of difference NVME devices. Per cusomter's suggestions, we would like to add or modify the fowllowing patches in current pel code.

Chaitanya, Thanks for your comments!

Thanks for your help!
Wendy

Wen Xiong (3):
nvme-cli: Add event type as filter in persistent event log
nvme-cli: Add set-feature(0xb) in persistent event log
nvme-cli: Update in persistent event pel code

 linux/nvme.h |  16 +++-
 nvme-print.c | 216 +++++++++++++++++++++++++++++++++++++--------------
 nvme-print.h |   5 +-
 nvme.c       |  12 ++-
 4 files changed, 184 insertions(+), 65 deletions(-)
Signature · 7 lines
2.27.0


_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
#1 lore raw

PATCH v2 1/3 nvme-cli: Add event type as filter in persistent event

From: Wen Xiong <[email protected]>

Add -t option in persistent event log command. The customers can use
-t to filter specific events in pel.

For example, only list hardware error(0x5).

./nvme persistent-event-log -a 0x0 -t 0x5 /dev/nvme0

---
 nvme-print.c | 21 ++++++++++++++++++---
 nvme-print.h |  4 ++--
 nvme.c       |  6 +++++-
 3 files changed, 25 insertions(+), 6 deletions(-)
nvme-print.c +18 -3
index b01a842..7b43fff 100755
@@ -1031,7 +1031,7 @@ static const char *nvme_show_nss_hw_error(__u16 error_code)
 	}
 }
 
-void json_persistent_event_log(void *pevent_log_info, __u32 size)
+void json_persistent_event_log(__u32 event_type, void *pevent_log_info, __u32 size)
 {
 	struct json_object *root;
 	struct json_object *valid_attrs;
@@ -1115,6 +1115,14 @@ void json_persistent_event_log(void *pevent_log_info, __u32 size)
 		if ((offset + pevent_entry_head->ehl + 3 +
 			le16_to_cpu(pevent_entry_head->el)) >= size)
 			break;
+
+		if ((event_type != 0) &
+				(pevent_entry_head->etype != event_type)) {
+			offset += pevent_entry_head->ehl + 3;
+			offset += le16_to_cpu(pevent_entry_head->el);
+			continue;
+		}
+
 		valid_attrs = json_create_object();
 
 		json_object_add_value_uint(valid_attrs, "event_type",
@@ -1343,7 +1351,7 @@ void json_persistent_event_log(void *pevent_log_info, __u32 size)
 	json_free_object(root);
 }
 
-void nvme_show_persistent_event_log(void *pevent_log_info,
+void nvme_show_persistent_event_log(__u32 event_type, void *pevent_log_info,
 	__u8 action, __u32 size, const char *devname,
 	enum nvme_print_flags flags)
 {
@@ -1366,7 +1374,7 @@ void nvme_show_persistent_event_log(void *pevent_log_info,
 	if (flags & BINARY)
 		return d_raw((unsigned char *)pevent_log_info, size);
 	if (flags & JSON)
-		return json_persistent_event_log(pevent_log_info, size);
+		return json_persistent_event_log(event_type, pevent_log_info, size);
 
 	offset = sizeof(*pevent_log_head);
 
@@ -1423,6 +1431,13 @@ void nvme_show_persistent_event_log(void *pevent_log_info,
 			le16_to_cpu(pevent_entry_head->el)) >= size)
 			break;
 
+		if ((event_type != 0) &
+				(pevent_entry_head->etype != event_type)) {
+			offset += pevent_entry_head->ehl + 3;
+			offset += le16_to_cpu(pevent_entry_head->el);
+			continue;
+		}
+
 		printf("Event Type: %u\n", pevent_entry_head->etype);
 		printf("Event Type Revision: %u\n", pevent_entry_head->etype_rev);
 		printf("Event Header Length: %u\n", pevent_entry_head->ehl);
nvme-print.h +2 -2
index 2d8ed4d..ce4f0c9 100644
@@ -49,8 +49,8 @@ void nvme_show_predictable_latency_event_agg_log(
 	struct nvme_event_agg_log_page *pea_log,
 	__u64 log_entries, __u32 size, const char *devname,
 	enum nvme_print_flags flags);
-void json_persistent_event_log(void *pevent_log_info, __u32 size);
-void nvme_show_persistent_event_log(void *pevent_log_info,
+void json_persistent_event_log(__u32 event_type, void *pevent_log_info, __u32 size);
+void nvme_show_persistent_event_log(__u32 event_type, void *pevent_log_info,
 	__u8 action, __u32 size, const char *devname,
 	enum nvme_print_flags flags);
 void json_endurance_group_event_agg_log(
nvme.c +5 -1
index a2075bf..0c8d669 100644
@@ -911,6 +911,7 @@ static int get_persistent_event_log(int argc, char **argv,
 	const char *action = "action the controller shall take during"\
 			" processing this persistent log page command.";
 	const char *log_len = "number of bytes to retrieve";
+	const char *event_type = "event type";
 	const char *raw = "use binary output";
 	void *pevent_log_info;
 	struct nvme_persistent_event_log_head *pevent_log_head;
@@ -921,6 +922,7 @@ static int get_persistent_event_log(int argc, char **argv,
 	struct config {
 		__u8 action;
 		__u32 log_len;
+		__u32 event_type;
 		int raw_binary;
 		char *output_format;
 	};
@@ -928,12 +930,14 @@ static int get_persistent_event_log(int argc, char **argv,
 	struct config cfg = {
 		.action = 0xff,
 		.log_len = 0,
+		.event_type = 0,
 		.output_format = "normal",
 	};
 
 	OPT_ARGS(opts) = {
 		OPT_UINT("action",       'a', &cfg.action,        action),
 		OPT_UINT("log_len", 	 'l', &cfg.log_len,  	  log_len),
+		OPT_UINT("event-type",   't', &cfg.event_type,   event_type),
 		OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
 		OPT_FLAG("raw-binary",   'b', &cfg.raw_binary,    raw),
 		OPT_END()
@@ -998,7 +1002,7 @@ static int get_persistent_event_log(int argc, char **argv,
 	err = nvme_persistent_event_log(fd, cfg.action,
 		cfg.log_len, pevent_log_info);
 	if (!err)
-		nvme_show_persistent_event_log(pevent_log_info, cfg.action,
+		nvme_show_persistent_event_log(cfg.event_type, pevent_log_info, cfg.action,
 			cfg.log_len, devicename, flags);
 	else if (err > 0)
 		nvme_show_status(err);
Signature · 7 lines
2.27.0


_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
#2 lore raw

PATCH v2 2/3 nvme-cli: Add set-feature(0xb) in persistent event log

In reply to [email protected]

From: Wen Xiong <[email protected]>

Add "set-feature(0xb) support in pel and tested with two NVME devices.

#./nvme persistent-event-log -a 0x0 -t 0xb /dev/nvme0 Persistent Event Entries:
EVENT Number : 302
Event Type Revision : 1
Event Header Length : 21
Controller Identifier : 65
Event Timestamp is : 846042775320587 (Fri Jan 11 13:02:00 28780 EST)
Vendor Specific Information Length: 0
Event Length : 16
EVENT Type : Set Feature Event(0xb)
Set Feature ID :0x7 (Number of Queues), value:0x4f004f
Number of IO Completion Queues Allocated (NCQA): 80 Number of IO Submission Queues Allocated (NSQA): 80

---
 linux/nvme.h |  7 +++++++
 nvme-print.c | 19 +++++++++++++++++++
 2 files changed, 26 insertions(+)
linux/nvme.h +7 -0
index 4ad09ee..91ee8be 100644
@@ -826,6 +826,12 @@ struct nvme_sanitize_compln_event {
 	__u8 	rsvd6[2];
 };
 
+/* persistent event type 0Bh */
+struct nvme_set_feature_event {
+    __le32     layout;
+    __le32     cdw_mem[0];
+};
+
 /* persistent event type 0Dh */
 struct nvme_thermal_exc_event {
     __u8 	over_temp;
@@ -877,6 +883,7 @@ enum nvme_persistent_event_types {
     NVME_FORMAT_COMPLETION_EVENT    = 0x08,
     NVME_SANITIZE_START_EVENT       = 0x09,
     NVME_SANITIZE_COMPLETION_EVENT  = 0x0a,
+    NVME_SET_FEATURE_EVENT          = 0x0b,
     NVME_THERMAL_EXCURSION_EVENT    = 0x0d
 };
 
nvme-print.c +19 -0
index 7b43fff..f22cc55 100755
@@ -1333,6 +1333,8 @@ void json_persistent_event_log(__u32 event_type, void *pevent_log_info, __u32 si
 				le16_to_cpu(sanitize_cmpln_event->cmpln_info));
 			break;
 		case NVME_THERMAL_EXCURSION_EVENT:
+			printf("No Jason format for set-feature events in PEL\n");
+		case NVME_SET_FEATURE_EVENT:
 			thermal_exc_event = pevent_log_info + offset;
 			json_object_add_value_uint(valid_attrs, "over_temp",
 				thermal_exc_event->over_temp);
@@ -1357,6 +1359,8 @@ void nvme_show_persistent_event_log(__u32 event_type, void *pevent_log_info,
 {
 	__u32 offset, por_info_len, por_info_list;
 	__u64 *fw_rev;
+	int fid, cdw11, dword_cnt;
+	unsigned char *mem_buf = NULL;
 	struct nvme_smart_log *smart_event;
 	struct nvme_fw_commit_event *fw_commit_event;
 	struct nvme_time_stamp_change_event *ts_change_event;
@@ -1367,6 +1371,7 @@ void nvme_show_persistent_event_log(__u32 event_type, void *pevent_log_info,
 	struct nvme_format_nvm_compln_event *format_cmpln_event;
 	struct nvme_sanitize_start_event *sanitize_start_event;
 	struct nvme_sanitize_compln_event *sanitize_cmpln_event;
+	struct nvme_set_feature_event *set_feat_event;
 	struct nvme_thermal_exc_event *thermal_exc_event;
 	struct nvme_persistent_event_log_head *pevent_log_head;
 	struct nvme_persistent_event_entry_head *pevent_entry_head;
@@ -1577,6 +1582,20 @@ void nvme_show_persistent_event_log(__u32 event_type, void *pevent_log_info,
 			printf("Completion Information: %u\n",
 				le16_to_cpu(sanitize_cmpln_event->cmpln_info));
 			break;
+		case NVME_SET_FEATURE_EVENT:
+			set_feat_event = pevent_log_info + offset;
+			dword_cnt =  set_feat_event->layout & 0x03;
+			fid = le32_to_cpu(set_feat_event->cdw_mem[0]) & 0x000f;
+			cdw11 = le32_to_cpu(set_feat_event->cdw_mem[1]);
+
+			if (((set_feat_event->layout & 0xff) >> 2) != 0)
+				mem_buf = (unsigned char *)(set_feat_event + 4 + dword_cnt * 4);
+
+			printf("Set Feature ID  :%#02x (%s),  value:%#08x\n", fid,
+				nvme_feature_to_string(fid), cdw11);
+
+			nvme_feature_show_fields(fid, cdw11, mem_buf);
+			break;
 		case NVME_THERMAL_EXCURSION_EVENT:
 			thermal_exc_event = pevent_log_info + offset;
 			printf("Thermal Excursion Event: \n");
Signature · 7 lines
2.27.0


_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
#3 lore raw

PATCH v2 3/3 nvme-cli: Update in persistent event pel code

In reply to [email protected]

From: Wen Xiong <[email protected]>

Update several improvement in pel:
- Add ascii format in firmware field
Old Firmware Revision: 3617604718875264338 (REV.SP42)

- Add ascii format in timestamp field
The Previous Timestamp is : 1619458220931 (Mon Apr 26 13:30:20 2021 EDT)

- ADD additional Information for hardware error

- Nicely output format
Persistent Event Entries:
EVENT Number : 0
Event Type Revision : 1
Event Header Length : 21
Controller Identifier : 65
Event Timestamp is : 564569411648175 (Fri Jun 29 00:34:08 19860 EDT)
Vendor Specific Information Length: 0
Event Length : 16
EVENT Type : Timestamp Change Event(0x3)

---
 linux/nvme.h |   9 +--
 nvme-print.c | 180 +++++++++++++++++++++++++++++++++++----------------
 nvme-print.h |   1 +
 nvme.c       |   6 ++
 4 files changed, 135 insertions(+), 61 deletions(-)
linux/nvme.h +5 -4
index 91ee8be..4212dd9 100644
@@ -755,7 +755,7 @@ struct nvme_fw_commit_event {
 
 /* persistent event type 03h */
 struct nvme_time_stamp_change_event {
-    __le64 	previous_timestamp;
+    __u8 	previous_timestamp[8];
     __le64 	ml_secs_since_reset;
 };
 
@@ -767,7 +767,7 @@ struct nvme_power_on_reset_info_list {
     __u8     rsvd4[12];
     __le32   ctrl_power_cycle;
     __le64   power_on_ml_seconds;
-    __le64   ctrl_time_stamp;
+    __u8   ctrl_time_stamp[8];
 } __attribute__((packed));
 
 /* persistent event type 05h */
@@ -845,7 +845,7 @@ struct nvme_persistent_event_entry_head {
 	__u8	ehl;
 	__u8	rsvd3;
 	__le16	ctrl_id;
-	__le64	etimestamp;
+	__u8	etimestamp[8];
 	__u8	rsvd14[6];
 	__le16	vsil;
 	__le16	el;
@@ -884,7 +884,8 @@ enum nvme_persistent_event_types {
     NVME_SANITIZE_START_EVENT       = 0x09,
     NVME_SANITIZE_COMPLETION_EVENT  = 0x0a,
     NVME_SET_FEATURE_EVENT          = 0x0b,
-    NVME_THERMAL_EXCURSION_EVENT    = 0x0d
+    NVME_TELEMETRY_CRT_EVENT        = 0x0c,
+    NVME_THERMAL_EXCURSION_EVENT    = 0x0d,
 };
 
 enum nvme_persistent_event_log_actions {
nvme-print.c +123 -57

353 lines not on this page · raw message

nvme-print.h +1 -0
index ce4f0c9..7301c04 100644
@@ -53,6 +53,7 @@ void json_persistent_event_log(__u32 event_type, void *pevent_log_info, __u32 si
 void nvme_show_persistent_event_log(__u32 event_type, void *pevent_log_info,
 	__u8 action, __u32 size, const char *devname,
 	enum nvme_print_flags flags);
+const char *nvme_pel_event_to_string(int type);
 void json_endurance_group_event_agg_log(
 	struct nvme_event_agg_log_page *endurance_log,
 	__u64 log_entries);
nvme.c +6 -0
index 0c8d669..59b4d42 100644
@@ -961,6 +961,12 @@ static int get_persistent_event_log(int argc, char **argv,
 		goto close_fd;
 	}
 
+	if (cfg.event_type !=0 && !nvme_pel_event_to_string(cfg.event_type)) {
+		printf("Not support 0x%x event in Persistent Event Log\n", cfg.event_type);
+		err = -EINVAL;
+		goto close_fd;
+	}
+
 	err = nvme_persistent_event_log(fd, cfg.action,
 			sizeof(*pevent_log_head), pevent_log_head);
 	if (err < 0) {
Signature · 7 lines
2.27.0


_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme