Skip to content

Commit 9e137f0

Browse files
xyzhang-upigaw
authored andcommitted
nvme-print-stdout: fix persistent-event-log set feature event output
Refer to FDP Events Set Feature Data Structure: the number of FDP Event Types is only Dword11 bits [23:16]. the buffer only contains FDP Event Type. The value of mem_buf is incorrect: the pointer 'set_feat_event' should be converted to 'unsigned char *' first Signed-off-by: Xiaoyuan Zhang <zhxiaoy2024@gmail.com>
1 parent a11a96f commit 9e137f0

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

nvme-print-stdout.c

+20-3
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,25 @@ static void stdout_add_bitmap(int i, __u8 seb)
246246
}
247247
}
248248

249+
static void stdout_persistent_event_log_fdp_events(unsigned int cdw11,
250+
unsigned int cdw12,
251+
unsigned char *buf)
252+
{
253+
unsigned int num = (cdw11 >> 16) & 0xff;
254+
255+
for (unsigned int i = 0; i < num; i++) {
256+
printf("\t%-53s: %sEnabled\n", nvme_fdp_event_to_string(buf[0]),
257+
cdw12 & 0x1 ? "" : "Not ");
258+
}
259+
}
260+
249261
static void stdout_persistent_event_log(void *pevent_log_info,
250262
__u8 action, __u32 size,
251263
const char *devname)
252264
{
253265
__u32 offset, por_info_len, por_info_list;
254266
__u64 *fw_rev;
255-
int fid, cdw11, dword_cnt;
267+
int fid, cdw11, cdw12, dword_cnt;
256268
unsigned char *mem_buf = NULL;
257269
struct nvme_smart_log *smart_event;
258270
struct nvme_fw_commit_event *fw_commit_event;
@@ -488,8 +500,13 @@ static void stdout_persistent_event_log(void *pevent_log_info,
488500
printf("Set Feature ID :%#02x (%s), value:%#08x\n", fid,
489501
nvme_feature_to_string(fid), cdw11);
490502
if (NVME_SET_FEAT_EVENT_MB_COUNT(set_feat_event->layout)) {
491-
mem_buf = (unsigned char *)(set_feat_event + 4 + dword_cnt * 4);
492-
stdout_feature_show_fields(fid, cdw11, mem_buf);
503+
mem_buf = (unsigned char *)set_feat_event + 4 + dword_cnt * 4;
504+
if (fid == NVME_FEAT_FID_FDP_EVENTS) {
505+
cdw12 = le32_to_cpu(set_feat_event->cdw_mem[2]);
506+
stdout_persistent_event_log_fdp_events(cdw11, cdw12,
507+
mem_buf);
508+
} else
509+
stdout_feature_show_fields(fid, cdw11, mem_buf);
493510
}
494511
break;
495512
case NVME_PEL_TELEMETRY_CRT:

0 commit comments

Comments
 (0)