Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: wenxiong@linux.vnet.ibm.com
To: linux-nvme@lists.infradead.org
Cc: keith.busch@intel.com, wenxiong@us.ibm.com,
	Wen Xiong <wenxiong@linux.vnet.ibm.com>
Subject: [PATCH V2 2/3] nvme-cli: Add set-feature(0xb) in persistent event log
Date: Tue,  4 May 2021 08:33:46 -0500	[thread overview]
Message-ID: <1620135227-21783-3-git-send-email-wenxiong@linux.vnet.ibm.com> (raw)
In-Reply-To: <1620135227-21783-1-git-send-email-wenxiong@linux.vnet.ibm.com>

From: Wen Xiong <wenxiong@linux.vnet.ibm.com>

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

Signed-off-by: Wen Xiong <wenxiong@linux.vnet.ibm.com>
---
 linux/nvme.h |  7 +++++++
 nvme-print.c | 19 +++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/linux/nvme.h b/linux/nvme.h
index 4ad09ee..91ee8be 100644
--- a/linux/nvme.h
+++ b/linux/nvme.h
@@ -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
 };
 
diff --git a/nvme-print.c b/nvme-print.c
index 7b43fff..f22cc55 100755
--- a/nvme-print.c
+++ b/nvme-print.c
@@ -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");
-- 
2.27.0


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  parent reply	other threads:[~2021-05-04 14:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-04 13:33 [PATCH V2 0/3] Update Persistent Event Log wenxiong
2021-05-04 13:33 ` [PATCH V2 1/3] nvme-cli: Add event type as filter in persistent event wenxiong
2021-05-04 13:33 ` wenxiong [this message]
2021-05-04 13:33 ` [PATCH V2 3/3] nvme-cli: Update in persistent event pel code wenxiong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1620135227-21783-3-git-send-email-wenxiong@linux.vnet.ibm.com \
    --to=wenxiong@linux.vnet.ibm.com \
    --cc=keith.busch@intel.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=wenxiong@us.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox