Skip to content

Commit 00e37a2

Browse files
committed
nvme-print-stdout: split PEL set feature event function
This is to reduce the PEL long function implementation. Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
1 parent f4448cd commit 00e37a2

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

nvme-print-stdout.c

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,38 @@ static void stdout_persistent_event_log_fdp_events(unsigned int cdw11, unsigned
257257
}
258258
}
259259

260+
static void pel_set_feature_event(void *pevent_log_info, __u32 offset)
261+
{
262+
int fid, cdw11, cdw12, dword_cnt;
263+
unsigned char *mem_buf;
264+
struct nvme_set_feature_event *set_feat_event = pevent_log_info + offset;
265+
266+
printf("Set Feature Event Entry:\n");
267+
dword_cnt = NVME_SET_FEAT_EVENT_DW_COUNT(set_feat_event->layout);
268+
fid = NVME_GET(le32_to_cpu(set_feat_event->cdw_mem[0]), FEATURES_CDW10_FID);
269+
cdw11 = le32_to_cpu(set_feat_event->cdw_mem[1]);
270+
271+
printf("Set Feature ID: 0x%02x (%s), value: 0x%08x\n", fid, nvme_feature_to_string(fid),
272+
cdw11);
273+
274+
if (!NVME_SET_FEAT_EVENT_MB_COUNT(set_feat_event->layout))
275+
return;
276+
277+
mem_buf = (unsigned char *)set_feat_event + 4 + dword_cnt * 4;
278+
if (fid == NVME_FEAT_FID_FDP_EVENTS) {
279+
cdw12 = le32_to_cpu(set_feat_event->cdw_mem[2]);
280+
stdout_persistent_event_log_fdp_events(cdw11, cdw12, mem_buf);
281+
} else {
282+
stdout_feature_show_fields(fid, cdw11, mem_buf);
283+
}
284+
}
285+
260286
static void stdout_persistent_event_log(void *pevent_log_info,
261287
__u8 action, __u32 size,
262288
const char *devname)
263289
{
264290
__u32 offset, por_info_len, por_info_list;
265291
__u64 *fw_rev;
266-
int fid, cdw11, cdw12, dword_cnt;
267-
unsigned char *mem_buf = NULL;
268292
struct nvme_smart_log *smart_event;
269293
struct nvme_fw_commit_event *fw_commit_event;
270294
struct nvme_time_stamp_change_event *ts_change_event;
@@ -275,7 +299,6 @@ static void stdout_persistent_event_log(void *pevent_log_info,
275299
struct nvme_format_nvm_compln_event *format_cmpln_event;
276300
struct nvme_sanitize_start_event *sanitize_start_event;
277301
struct nvme_sanitize_compln_event *sanitize_cmpln_event;
278-
struct nvme_set_feature_event *set_feat_event;
279302
struct nvme_thermal_exc_event *thermal_exc_event;
280303
struct nvme_persistent_event_log *pevent_log_head;
281304
struct nvme_persistent_event_entry *pevent_entry_head;
@@ -490,24 +513,7 @@ static void stdout_persistent_event_log(void *pevent_log_info,
490513
le16_to_cpu(sanitize_cmpln_event->cmpln_info));
491514
break;
492515
case NVME_PEL_SET_FEATURE_EVENT:
493-
set_feat_event = pevent_log_info + offset;
494-
printf("Set Feature Event Entry:\n");
495-
dword_cnt = NVME_SET_FEAT_EVENT_DW_COUNT(set_feat_event->layout);
496-
fid = NVME_GET(le32_to_cpu(set_feat_event->cdw_mem[0]), FEATURES_CDW10_FID);
497-
cdw11 = le32_to_cpu(set_feat_event->cdw_mem[1]);
498-
499-
printf("Set Feature ID: 0x%02x (%s), value: 0x%08x\n", fid,
500-
nvme_feature_to_string(fid), cdw11);
501-
if (NVME_SET_FEAT_EVENT_MB_COUNT(set_feat_event->layout)) {
502-
mem_buf = (unsigned char *)set_feat_event + 4 + dword_cnt * 4;
503-
if (fid == NVME_FEAT_FID_FDP_EVENTS) {
504-
cdw12 = le32_to_cpu(set_feat_event->cdw_mem[2]);
505-
stdout_persistent_event_log_fdp_events(cdw11, cdw12,
506-
mem_buf);
507-
} else {
508-
stdout_feature_show_fields(fid, cdw11, mem_buf);
509-
}
510-
}
516+
pel_set_feature_event(pevent_log_info, offset);
511517
break;
512518
case NVME_PEL_TELEMETRY_CRT:
513519
d(pevent_log_info + offset, 512, 16, 1);

0 commit comments

Comments
 (0)