nvme-cli: Decode "Supported Events Bitmap" in PEL header
PATCH 1/5 nvme-cli: Decode "Supported Events Bitmap" in PEL header
From: Wen Xiong <[email protected]>
"Supported Events Bitmap" in PEL header shows what events are supported in current nvme devices.
Persistent Event Log for device: nvme0n1
Action for Persistent Event Log: 0
..
..
..
Supported Events Bitmap:
Support SMART/Health Log Snapshot Event(0x1)
Support Firmware Commit Event(0x2)
Support Timestamp Change Event(0x3)
Support Power-on or Reset Event(0x4)
Support NVM Subsystem Hardware Error Event(0x5)
Support Change Namespace Event(0x6)
Support Format NVM Start Event(0x7)
Support Format NVM Completion Event(0x8)
Support Sanitize Start Event(0x9)
Support Sanitize Completion Event(0xa)
Support Set Feature Event(0xb)
Support Set Telemetry CRT Event(0xc)
Support Thermal Excursion Event(0xd)--- nvme-print.c | 44 ++++++++++++++++++++++++++++++++++++++------ nvme.c | 4 ++-- 2 files changed, 40 insertions(+), 8 deletions(-)
nvme-print.c +38 -6
@@ -1053,6 +1053,26 @@ void nvme_show_predictable_latency_event_agg_log( } } +const char *nvme_pel_event_to_string (int type) +{ +switch (type) { +case NVME_PEL_SMART_HEALTH_EVENT :return "SMART/Health Log Snapshot Event(0x1)" ; +case NVME_PEL_FW_COMMIT_EVENT :return "Firmware Commit Event(0x2)" ; +case NVME_PEL_TIMESTAMP_EVENT :return "Timestamp Change Event(0x3)" ; +case NVME_PEL_POWER_ON_RESET_EVENT :return "Power-on or Reset Event(0x4)" ; +case NVME_PEL_NSS_HW_ERROR_EVENT :return "NVM Subsystem Hardware Error Event(0x5)" ; +case NVME_PEL_CHANGE_NS_EVENT :return "Change Namespace Event(0x6)" ; +case NVME_PEL_FORMAT_START_EVENT :return "Format NVM Start Event(0x7)" ; +case NVME_PEL_FORMAT_COMPLETION_EVENT :return "Format NVM Completion Event(0x8)" ; +case NVME_PEL_SANITIZE_START_EVENT :return "Sanitize Start Event(0x9)" ; +case NVME_PEL_SANITIZE_COMPLETION_EVENT :return "Sanitize Completion Event(0xa)" ; +case NVME_PEL_SET_FEATURE_EVENT :return "Set Feature Event(0xb)" ; +case NVME_PEL_TELEMETRY_CRT :return "Set Telemetry CRT Event(0xc)" ; +case NVME_PEL_THERMAL_EXCURSION_EVENT :return "Thermal Excursion Event(0xd)" ; +default :return NULL ; + } +} +static const char *nvme_show_nss_hw_error (__u16 error_code) {switch (error_code) {
@@ -1089,6 +1109,7 @@ void json_persistent_event_log(void *pevent_log_info, __u32 size)__u32 offset, por_info_len, por_info_list;__u64 *fw_rev;char key[128 ]; +char evt_str[50 ];struct nvme_smart_log *smart_event;struct nvme_fw_commit_event *fw_commit_event;
@@ -1151,9 +1172,16 @@ void json_persistent_event_log(void *pevent_log_info, __u32 size)for (int i =0 ; i <32 ; i++) {if (pevent_log_head->seb[i] ==0 )continue ; -sprintf (key,"bitmap_%d" , i); -json_object_add_value_uint (root, key, - pevent_log_head->seb[i]); +for (int bit =0 ; bit <8 ; bit++) { +if (nvme_pel_event_to_string (bit + i *8 )) { +sprintf (key,"bitmap_%x" , (bit + i *8 )); +if ((pevent_log_head->seb[i] >> bit) &0x1 ) +snprintf (evt_str,sizeof (evt_str),"Support %s" , +nvme_pel_event_to_string (bit + i *8 )); +json_object_add_value_string (root, key, evt_str); + } + } + } }else { printf("No log data can be shown with this log len at least " \
@@ -1479,12 +1507,16 @@ void nvme_show_persistent_event_log(void *pevent_log_info, le32_to_cpu(pevent_log_head->rci));if (human)nvme_show_persistent_event_log_rci (pevent_log_head->rci); -printf ("Supported Events Bitmap: " ); +printf ("Supported Events Bitmap: \n" );for (int i =0 ; i <32 ; i++) {if (pevent_log_head->seb[i] ==0 )continue ; -printf (" BitMap[%d] is 0x%x\n" , i, - pevent_log_head->seb[i]); +for (int bit =0 ; bit <8 ; bit++) { +if (nvme_pel_event_to_string (bit + i *8 )) +if ((pevent_log_head->seb[i] >> bit) &0x1 ) +printf (" Support %s\n" , +nvme_pel_event_to_string (bit + i *8 )); + } } }else { printf("No log data can be shown with this log len at least " \
nvme.c +2 -2
@@ -4900,7 +4900,7 @@ static int dsm(int argc, char **argv, struct command *cmd, struct plugin *plugin nc =argconfig_parse_comma_sep_array (cfg.ctx_attrs, (int *)ctx_attrs,ARRAY_SIZE (ctx_attrs)); nb =argconfig_parse_comma_sep_array (cfg.blocks, (int *)nlbs,ARRAY_SIZE (nlbs)); - ns =argconfig_parse_comma_sep_array_long (cfg.slbas, slbas,ARRAY_SIZE (slbas)); + ns =argconfig_parse_comma_sep_array_long (cfg.slbas, (long long unsigned int *)slbas,ARRAY_SIZE (slbas)); nr =max (nc,max (nb, ns));if (!nr || nr >256 ) {fprintf (stderr,"No range definition provided\n" );
@@ -5044,7 +5044,7 @@ static int copy(int argc, char **argv, struct command *cmd, struct plugin *plugi } } -nvme_init_copy_range (copy, nlbs, slbas, eilbrts, elbatms, elbats, nr); +nvme_init_copy_range (copy, nlbs, (__u64 *)slbas, eilbrts, elbatms, elbats, nr); err = nvme_copy(fd, cfg.namespace_id, copy, cfg.sdlba, nr, cfg.prinfor, cfg.prinfow, cfg.dtype, cfg.dspec, cfg.format, cfg.lr,
Signature · 1 line
2.27.0
PATCH 2/5 nvme-cli: Adds event number in persistent event entries
From: Wen Xiong <[email protected]>
Persistent Event Entries:
Event Number: 0
Event Type: SMART/Health Log Snapshot Event(0x1)
Event Type Revision: 1
Event Header Length: 21
Controller Identifier: 66
Event Timestamp: 44392
--- nvme-print.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-)
nvme-print.c +17 -16
@@ -1199,9 +1199,10 @@ void json_persistent_event_log(void *pevent_log_info, __u32 size) le16_to_cpu(pevent_entry_head->el)) >= size)break ; valid_attrs =json_create_object (); - -json_object_add_value_uint (valid_attrs,"event_type" , - pevent_entry_head->etype); + +json_object_add_value_uint (valid_attrs,"event_number" , i); +json_object_add_value_string (valid_attrs,"event_type" , +nvme_pel_event_to_string (pevent_entry_head->etype));json_object_add_value_uint (valid_attrs,"event_type_rev" , pevent_entry_head->etype_rev); json_object_add_value_uint(valid_attrs, "event_header_len",
@@ -1535,8 +1536,8 @@ void nvme_show_persistent_event_log(void *pevent_log_info,if ((offset + pevent_entry_head->ehl +3 +le16_to_cpu (pevent_entry_head->el)) >= size)break ; - -printf ("Event Type: %u\n" , pevent_entry_head->etype); +printf ("Event Number: %u\n" , i); +printf ("Event Type: %s\n" ,nvme_pel_event_to_string (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); printf("Controller Identifier: %u\n",
@@ -1552,12 +1553,12 @@ void nvme_show_persistent_event_log(void *pevent_log_info,switch (pevent_entry_head->etype) {case NVME_PEL_SMART_HEALTH_EVENT : smart_event = pevent_log_info + offset; -printf ("Smart Health Event: \n" ); +printf ("Smart Health Event Entry: \n" );nvme_show_smart_log (smart_event,NVME_NSID_ALL , devname, flags);break ;case NVME_PEL_FW_COMMIT_EVENT : fw_commit_event = pevent_log_info + offset; -printf ("FW Commit Event: \n" ); +printf ("FW Commit Event Entry: \n" );printf ("Old Firmware Revision: %" PRIu64"\n" ,le64_to_cpu (fw_commit_event->old_fw_rev)); printf("New Firmware Revision: %"PRIu64"\n",
@@ -1574,7 +1575,7 @@ void nvme_show_persistent_event_log(void *pevent_log_info,break ;case NVME_PEL_TIMESTAMP_EVENT : ts_change_event = pevent_log_info + offset; -printf ("Time Stamp Change Event: \n" ); +printf ("Time Stamp Change Event Entry: \n" );printf ("Previous Timestamp: %" PRIu64"\n" ,le64_to_cpu (ts_change_event->previous_timestamp)); printf("Milliseconds Since Reset: %"PRIu64"\n",
@@ -1586,7 +1587,7 @@ void nvme_show_persistent_event_log(void *pevent_log_info, por_info_list = por_info_len /sizeof (*por_event); -printf ("Power On Reset Event: \n" ); +printf ("Power On Reset Event Entry: \n" ); fw_rev = pevent_log_info + offset;printf ("Firmware Revision: %" PRIu64"\n" ,le64_to_cpu (*fw_rev));printf ("Reset Information List: \n" );
@@ -1609,13 +1610,13 @@ void nvme_show_persistent_event_log(void *pevent_log_info,break ;case NVME_PEL_NSS_HW_ERROR_EVENT : nss_hw_err_event = pevent_log_info + offset; -printf ("NVM Subsystem Hardware Error Event Code: %u, %s\n" , +printf ("NVM Subsystem Hardware Error Event Code Entry: %u, %s\n" ,le16_to_cpu (nss_hw_err_event->nss_hw_err_event_code),nvme_show_nss_hw_error (nss_hw_err_event->nss_hw_err_event_code));break ;case NVME_PEL_CHANGE_NS_EVENT : ns_event = pevent_log_info + offset; -printf ("Change Namespace Event: \n" ); +printf ("Change Namespace Event Entry: \n" );printf ("Namespace Management CDW10: %u\n" ,le32_to_cpu (ns_event->nsmgt_cdw10)); printf("Namespace Size: %"PRIu64"\n",
@@ -1634,7 +1635,7 @@ void nvme_show_persistent_event_log(void *pevent_log_info,break ;case NVME_PEL_FORMAT_START_EVENT : format_start_event = pevent_log_info + offset; -printf ("Format NVM Start Event: \n" ); +printf ("Format NVM Start Event Entry: \n" );printf ("Namespace Identifier: %u\n" ,le32_to_cpu (format_start_event->nsid)); printf("Format NVM Attributes: %u\n",
@@ -1644,7 +1645,7 @@ void nvme_show_persistent_event_log(void *pevent_log_info,break ;case NVME_PEL_FORMAT_COMPLETION_EVENT : format_cmpln_event = pevent_log_info + offset; -printf ("Format NVM Completion Event: \n" ); +printf ("Format NVM Completion Event Entry: \n" );printf ("Namespace Identifier: %u\n" ,le32_to_cpu (format_cmpln_event->nsid)); printf("Smallest Format Progress Indicator: %u\n",
@@ -1658,7 +1659,7 @@ void nvme_show_persistent_event_log(void *pevent_log_info,break ;case NVME_PEL_SANITIZE_START_EVENT : sanitize_start_event = pevent_log_info + offset; -printf ("Sanitize Start Event: \n" ); +printf ("Sanitize Start Event Entry: \n" );printf ("SANICAP: %u\n" , sanitize_start_event->sani_cap);printf ("Sanitize CDW10: %u\n" ,le32_to_cpu (sanitize_start_event->sani_cdw10));
@@ -1667,7 +1668,7 @@ void nvme_show_persistent_event_log(void *pevent_log_info,break ;case NVME_PEL_SANITIZE_COMPLETION_EVENT : sanitize_cmpln_event = pevent_log_info + offset; -printf ("Sanitize Completion Event: \n" ); +printf ("Sanitize Completion Event Entry: \n" );printf ("Sanitize Progress: %u\n" ,le16_to_cpu (sanitize_cmpln_event->sani_prog)); printf("Sanitize Status: %u\n",
@@ -1677,7 +1678,7 @@ void nvme_show_persistent_event_log(void *pevent_log_info,break ;case NVME_PEL_THERMAL_EXCURSION_EVENT : thermal_exc_event = pevent_log_info + offset; -printf ("Thermal Excursion Event: \n" ); +printf ("Thermal Excursion Event Entry: \n" );printf ("Over Temperature: %u\n" , thermal_exc_event->over_temp);printf ("Threshold: %u\n" , thermal_exc_event->threshold);break ;
Signature · 1 line
2.27.0
Re: [PATCH 2/5] nvme-cli: Adds event number in persistent event entries
nvme-print.c void nvme_show_persistent_event_log(void *pevent_log_info, · line 1556
Quoted 7 lines
nvme-print.c +1
-1@@ -1552,12 +1553,12 @@ void nvme_show_persistent_event_log(void *pevent_log_info,switch (pevent_entry_head->etype) {case NVME_PEL_SMART_HEALTH_EVENT : smart_event = pevent_log_info + offset; -printf ("Smart Health Event: \n" ); +printf ("Smart Health Event Entry: \n" );
original string is fine, why do we need to change it ?
Quoted 10 lines
nvme-print.c +1
-1nvme_show_smart_log (smart_event,NVME_NSID_ALL , devname, flags);break ;case NVME_PEL_FW_COMMIT_EVENT : fw_commit_event = pevent_log_info + offset; -printf ("FW Commit Event: \n" ); +printf ("FW Commit Event Entry: \n" );printf ("Old Firmware Revision: %" PRIu64"\n" ,le64_to_cpu (fw_commit_event->old_fw_rev)); printf("New Firmware Revision: %"PRIu64"\n",
nvme-print.c void nvme_show_persistent_event_log(void *pevent_log_info, · line 1578
Quoted 5 lines
nvme-print.c +1
-1@@ -1574,7 +1575,7 @@ void nvme_show_persistent_event_log(void *pevent_log_info,break ;case NVME_PEL_TIMESTAMP_EVENT : ts_change_event = pevent_log_info + offset; -printf ("Time Stamp Change Event: \n" ); +printf ("Time Stamp Change Event Entry: \n" );
same comment as above
nvme-print.c void nvme_show_persistent_event_log(void *pevent_log_info, · line 1590
Quoted 9 lines
nvme-print.c +1
-1printf ("Previous Timestamp: %" PRIu64"\n" ,le64_to_cpu (ts_change_event->previous_timestamp)); printf("Milliseconds Since Reset: %"PRIu64"\n",@@ -1586,7 +1587,7 @@ void nvme_show_persistent_event_log(void *pevent_log_info, por_info_list = por_info_len /sizeof (*por_event); -printf ("Power On Reset Event: \n" ); +printf ("Power On Reset Event Entry: \n" );
same comment as above
nvme-print.c void nvme_show_persistent_event_log(void *pevent_log_info, · line 1613
Quoted 9 lines
nvme-print.c +1
-1fw_rev = pevent_log_info + offset;printf ("Firmware Revision: %" PRIu64"\n" ,le64_to_cpu (*fw_rev));printf ("Reset Information List: \n" );@@ -1609,13 +1610,13 @@ void nvme_show_persistent_event_log(void *pevent_log_info,break ;case NVME_PEL_NSS_HW_ERROR_EVENT : nss_hw_err_event = pevent_log_info + offset; - printf("NVM Subsystem Hardware Error Event Code: %u, %s\n", + printf("NVM Subsystem Hardware Error Event Code Entry: %u, %s\n",
same comment as above
nvme-print.c void nvme_show_persistent_event_log(void *pevent_log_info, · line 1619
Quoted 7 lines
nvme-print.c +1
-1le16_to_cpu (nss_hw_err_event->nss_hw_err_event_code), nvme_show_nss_hw_error(nss_hw_err_event->nss_hw_err_event_code));break ;case NVME_PEL_CHANGE_NS_EVENT : ns_event = pevent_log_info + offset; -printf ("Change Namespace Event: \n" ); +printf ("Change Namespace Event Entry: \n" );
same comment as above
nvme-print.c void nvme_show_persistent_event_log(void *pevent_log_info, · line 1638
Quoted 9 lines
nvme-print.c +1
-1printf ("Namespace Management CDW10: %u\n" ,le32_to_cpu (ns_event->nsmgt_cdw10)); printf("Namespace Size: %"PRIu64"\n",@@ -1634,7 +1635,7 @@ void nvme_show_persistent_event_log(void *pevent_log_info,break ;case NVME_PEL_FORMAT_START_EVENT : format_start_event = pevent_log_info + offset; -printf ("Format NVM Start Event: \n" ); +printf ("Format NVM Start Event Entry: \n" );
same comment as above
Quoted 40 lines
nvme-print.c +4
-4printf ("Namespace Identifier: %u\n" ,le32_to_cpu (format_start_event->nsid)); printf("Format NVM Attributes: %u\n",@@ -1644,7 +1645,7 @@ void nvme_show_persistent_event_log(void *pevent_log_info,break ;case NVME_PEL_FORMAT_COMPLETION_EVENT : format_cmpln_event = pevent_log_info + offset; -printf ("Format NVM Completion Event: \n" ); +printf ("Format NVM Completion Event Entry: \n" );printf ("Namespace Identifier: %u\n" ,le32_to_cpu (format_cmpln_event->nsid)); printf("Smallest Format Progress Indicator: %u\n",@@ -1658,7 +1659,7 @@ void nvme_show_persistent_event_log(void *pevent_log_info,break ;case NVME_PEL_SANITIZE_START_EVENT : sanitize_start_event = pevent_log_info + offset; -printf ("Sanitize Start Event: \n" ); +printf ("Sanitize Start Event Entry: \n" );printf ("SANICAP: %u\n" , sanitize_start_event->sani_cap);printf ("Sanitize CDW10: %u\n" ,le32_to_cpu (sanitize_start_event->sani_cdw10));@@ -1667,7 +1668,7 @@ void nvme_show_persistent_event_log(void *pevent_log_info,break ;case NVME_PEL_SANITIZE_COMPLETION_EVENT : sanitize_cmpln_event = pevent_log_info + offset; -printf ("Sanitize Completion Event: \n" ); +printf ("Sanitize Completion Event Entry: \n" );printf ("Sanitize Progress: %u\n" ,le16_to_cpu (sanitize_cmpln_event->sani_prog)); printf("Sanitize Status: %u\n",@@ -1677,7 +1678,7 @@ void nvme_show_persistent_event_log(void *pevent_log_info,break ;case NVME_PEL_THERMAL_EXCURSION_EVENT : thermal_exc_event = pevent_log_info + offset; -printf ("Thermal Excursion Event: \n" ); +printf ("Thermal Excursion Event Entry: \n" );printf ("Over Temperature: %u\n" , thermal_exc_event->over_temp);printf ("Threshold: %u\n" , thermal_exc_event->threshold);break ;
PATCH 3/5 nvme-cli: Adds readable firmware level in persistent
In reply to [email protected]From: Wen Xiong <[email protected]>
For example, In Firmware Commit Event:
Old Firmware Revision: 3617604718875264338
New Firmware Revision: 3833777500989048146
changes to
Old Firmware Revision: 3617604718875264338 (REV.SP42) New Firmware Revision: 3833777500989048146 (REV.SP45)
--- nvme-print.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-)
nvme-print.c +21 -11
@@ -1110,6 +1110,7 @@ void json_persistent_event_log(void *pevent_log_info, __u32 size)__u64 *fw_rev;char key[128 ];char evt_str[50 ]; +char fw_str[50 ];struct nvme_smart_log *smart_event;struct nvme_fw_commit_event *fw_commit_event;
@@ -1292,10 +1293,14 @@ void json_persistent_event_log(void *pevent_log_info, __u32 size)break ;case NVME_PEL_FW_COMMIT_EVENT : fw_commit_event = pevent_log_info + offset; -json_object_add_value_uint64 (valid_attrs,"old_fw_rev" , -le64_to_cpu (fw_commit_event->old_fw_rev)); -json_object_add_value_uint64 (valid_attrs,"new_fw_rev" , -le64_to_cpu (fw_commit_event->new_fw_rev)); +snprintf (fw_str,sizeof (fw_str),"%" PRIu64" (%s)" , +le64_to_cpu (fw_commit_event->old_fw_rev), +fw_to_string ((char *)&fw_commit_event->old_fw_rev)); +json_object_add_value_string (valid_attrs,"old_fw_rev" , fw_str); +snprintf (fw_str,sizeof (fw_str),"%" PRIu64" (%s)" , +le64_to_cpu (fw_commit_event->new_fw_rev), +fw_to_string ((char *)&fw_commit_event->new_fw_rev)); +json_object_add_value_string (valid_attrs,"new_fw_rev" , fw_str);json_object_add_value_uint (valid_attrs,"fw_commit_action" , fw_commit_event->fw_commit_action); json_object_add_value_uint(valid_attrs, "fw_slot",
@@ -1323,8 +1328,10 @@ void json_persistent_event_log(void *pevent_log_info, __u32 size) por_info_list = por_info_len /sizeof (*por_event); fw_rev = pevent_log_info + offset; -json_object_add_value_uint64 (valid_attrs,"fw_rev" , -le64_to_cpu (*fw_rev)); +snprintf (fw_str,sizeof (fw_str),"%" PRIu64" (%s)" , +le64_to_cpu (*fw_rev), +fw_to_string ((char *)fw_rev)); +json_object_add_value_string (valid_attrs,"fw_rev" , fw_str);for (int i =0 ; i < por_info_list; i++) { por_event = pevent_log_info + offset +sizeof (*fw_rev) + i *sizeof (*por_event);
@@ -1559,10 +1566,12 @@ void nvme_show_persistent_event_log(void *pevent_log_info,case NVME_PEL_FW_COMMIT_EVENT : fw_commit_event = pevent_log_info + offset;printf ("FW Commit Event Entry: \n" ); -printf ("Old Firmware Revision: %" PRIu64"\n" , -le64_to_cpu (fw_commit_event->old_fw_rev)); -printf ("New Firmware Revision: %" PRIu64"\n" , -le64_to_cpu (fw_commit_event->new_fw_rev)); +printf ("Old Firmware Revision: %" PRIu64" (%s)\n" , +le64_to_cpu (fw_commit_event->old_fw_rev), +fw_to_string ((char *)&fw_commit_event->old_fw_rev)); +printf ("New Firmware Revision: %" PRIu64" (%s)\n" , +le64_to_cpu (fw_commit_event->new_fw_rev), +fw_to_string ((char *)&fw_commit_event->new_fw_rev));printf ("FW Commit Action: %u\n" , fw_commit_event->fw_commit_action);printf ("FW Slot: %u\n" , fw_commit_event->fw_slot);
@@ -1589,7 +1598,8 @@ void nvme_show_persistent_event_log(void *pevent_log_info,printf ("Power On Reset Event Entry: \n" ); fw_rev = pevent_log_info + offset; -printf ("Firmware Revision: %" PRIu64"\n" ,le64_to_cpu (*fw_rev)); +printf ("Firmware Revision: %" PRIu64" (%s)\n" ,le64_to_cpu (*fw_rev), +fw_to_string ((char *)fw_rev));printf ("Reset Information List: \n" );for (int i =0 ; i < por_info_list; i++) {
Signature · 1 line
2.27.0
PATCH 4/5 nvme-cli: Add support set feature event in PEL
In reply to [email protected]From: Wen Xiong <[email protected]>
Add "Set Feature" event in PEL.
--- nvme-print.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
nvme-print.c +18 -0
@@ -1459,6 +1459,8 @@ void nvme_show_persistent_event_log(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;
@@ -1469,6 +1471,7 @@ void nvme_show_persistent_event_log(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 *pevent_log_head;struct nvme_persistent_event_entry *pevent_entry_head;
@@ -1686,6 +1689,21 @@ void nvme_show_persistent_event_log(void *pevent_log_info,printf ("Completion Information: %u\n" ,le16_to_cpu (sanitize_cmpln_event->cmpln_info));break ; +case NVME_PEL_SET_FEATURE_EVENT : + set_feat_event = pevent_log_info + offset; +printf ("Set Feature Event: \n" ); + 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_PEL_THERMAL_EXCURSION_EVENT : thermal_exc_event = pevent_log_info + offset;printf ("Thermal Excursion Event Entry: \n" );
Signature · 1 line
2.27.0
Re: [PATCH 4/5] nvme-cli: Add support set feature event in PEL
Quoted 6 lines · On 11/17/21 08:04, [email protected] wrote:
From: Wen Xiong <[email protected]>
Add "Set Feature" event in PEL.
Signed-off-by Wen Xiong <[email protected]>---
do you have a controller to set this feature ?
also, please provide the output of the set-feature command for PEL ..
PATCH 5/5 nvme-cli: Add support Telemetry CRT in PEL
In reply to [email protected]From: Wen Xiong <[email protected]>
Add "Telemetry CRT" event in PEL.
--- nvme-print.c | 3 +++ 1 file changed, 3 insertions(+)
nvme-print.c +3 -0
@@ -1704,6 +1704,9 @@ void nvme_show_persistent_event_log(void *pevent_log_info,nvme_feature_show_fields (fid, cdw11, mem_buf);break ; +case NVME_PEL_TELEMETRY_CRT : +d (pevent_log_info + offset,512 ,16 ,1 ); +break ;case NVME_PEL_THERMAL_EXCURSION_EVENT : thermal_exc_event = pevent_log_info + offset;printf ("Thermal Excursion Event Entry: \n" );
Signature · 1 line
2.27.0
Quoted 25 lines · On 11/17/21 08:04, [email protected] wrote:
From: Wen Xiong <[email protected]>
"Supported Events Bitmap" in PEL header shows what events are supported in current nvme devices.
Persistent Event Log for device: nvme0n1
Action for Persistent Event Log: 0
..
..
..
Supported Events Bitmap:Support SMART/Health Log Snapshot Event(0x1) Support Firmware Commit Event(0x2) Support Timestamp Change Event(0x3) Support Power-on or Reset Event(0x4) Support NVM Subsystem Hardware Error Event(0x5) Support Change Namespace Event(0x6) Support Format NVM Start Event(0x7) Support Format NVM Completion Event(0x8) Support Sanitize Start Event(0x9) Support Sanitize Completion Event(0xa) Support Set Feature Event(0xb) Support Set Telemetry CRT Event(0xc) Support Thermal Excursion Event(0xd)
Quoted 1 line
Signed-off-by Wen Xiong <[email protected]>
You need to provide a cover-letter for series like this...
Quoted 51 lines
--- nvme-print.c | 44 ++++++++++++++++++++++++++++++++++++++------ nvme.c | 4 ++-- 2 files changed, 40 insertions(+), 8 deletions(-)nvme-print.c +21
-3@@ -1053,6 +1053,26 @@ void nvme_show_predictable_latency_event_agg_log( } } +const char *nvme_pel_event_to_string (int type) +{ +switch (type) { +case NVME_PEL_SMART_HEALTH_EVENT :return "SMART/Health Log Snapshot Event(0x1)" ; +case NVME_PEL_FW_COMMIT_EVENT :return "Firmware Commit Event(0x2)" ; +case NVME_PEL_TIMESTAMP_EVENT :return "Timestamp Change Event(0x3)" ; +case NVME_PEL_POWER_ON_RESET_EVENT :return "Power-on or Reset Event(0x4)" ; +case NVME_PEL_NSS_HW_ERROR_EVENT :return "NVM Subsystem Hardware Error Event(0x5)" ; +case NVME_PEL_CHANGE_NS_EVENT :return "Change Namespace Event(0x6)" ; +case NVME_PEL_FORMAT_START_EVENT :return "Format NVM Start Event(0x7)" ; +case NVME_PEL_FORMAT_COMPLETION_EVENT :return "Format NVM Completion Event(0x8)" ; +case NVME_PEL_SANITIZE_START_EVENT :return "Sanitize Start Event(0x9)" ; +case NVME_PEL_SANITIZE_COMPLETION_EVENT :return "Sanitize Completion Event(0xa)" ; +case NVME_PEL_SET_FEATURE_EVENT :return "Set Feature Event(0xb)" ; +case NVME_PEL_TELEMETRY_CRT :return "Set Telemetry CRT Event(0xc)" ; +case NVME_PEL_THERMAL_EXCURSION_EVENT :return "Thermal Excursion Event(0xd)" ; +default :return NULL ; + } +} +static const char *nvme_show_nss_hw_error (__u16 error_code) {switch (error_code) {@@ -1089,6 +1109,7 @@ void json_persistent_event_log(void *pevent_log_info, __u32 size)__u32 offset, por_info_len, por_info_list;__u64 *fw_rev;char key[128 ]; +char evt_str[50 ];struct nvme_smart_log *smart_event;struct nvme_fw_commit_event *fw_commit_event;@@ -1151,9 +1172,16 @@ void json_persistent_event_log(void *pevent_log_info, __u32 size)for (int i =0 ; i <32 ; i++) {if (pevent_log_head->seb[i] ==0 )continue ; -sprintf (key,"bitmap_%d" , i); -json_object_add_value_uint (root, key, - pevent_log_head->seb[i]);
nvme-print.c void json_persistent_event_log(void *pevent_log_info, __u32 size) · line 1184
Quoted 10 lines
nvme-print.c +10
-0+for (int bit =0 ; bit <8 ; bit++) { +if (nvme_pel_event_to_string (bit + i *8 )) { +sprintf (key,"bitmap_%x" , (bit + i *8 )); +if ((pevent_log_head->seb[i] >> bit) &0x1 ) +snprintf (evt_str,sizeof (evt_str),"Support %s" , +nvme_pel_event_to_string (bit + i *8 )); +json_object_add_value_string (root, key, evt_str); + } + } +
please create a helper for above hunk, too much nesting ..
Quoted 10 lines
nvme-print.c +1
-1} }else { printf("No log data can be shown with this log len at least " \@@ -1479,12 +1507,16 @@ void nvme_show_persistent_event_log(void *pevent_log_info, le32_to_cpu(pevent_log_head->rci));if (human)nvme_show_persistent_event_log_rci (pevent_log_head->rci); -printf ("Supported Events Bitmap: " ); +printf ("Supported Events Bitmap: \n" );for (int i =0 ; i <32 ; i++) {
nvme-print.c void nvme_show_persistent_event_log(void *pevent_log_info, · line 1519
Quoted 10 lines
nvme-print.c +6
-2if (pevent_log_head->seb[i] ==0 )continue ; -printf (" BitMap[%d] is 0x%x\n" , i, - pevent_log_head->seb[i]); +for (int bit =0 ; bit <8 ; bit++) { +if (nvme_pel_event_to_string (bit + i *8 )) +if ((pevent_log_head->seb[i] >> bit) &0x1 ) +printf (" Support %s\n" , +nvme_pel_event_to_string (bit + i *8 )); + }
same here as above
Quoted 26 lines
nvme-print.c +0
-0} }else { printf("No log data can be shown with this log len at least " \nvme.c +2
-2@@ -4900,7 +4900,7 @@ static int dsm(int argc, char **argv, struct command *cmd, struct plugin *plugin nc =argconfig_parse_comma_sep_array (cfg.ctx_attrs, (int *)ctx_attrs,ARRAY_SIZE (ctx_attrs)); nb =argconfig_parse_comma_sep_array (cfg.blocks, (int *)nlbs,ARRAY_SIZE (nlbs)); - ns =argconfig_parse_comma_sep_array_long (cfg.slbas, slbas,ARRAY_SIZE (slbas)); + ns =argconfig_parse_comma_sep_array_long (cfg.slbas, (long long unsigned int *)slbas,ARRAY_SIZE (slbas)); nr =max (nc,max (nb, ns));if (!nr || nr >256 ) {fprintf (stderr,"No range definition provided\n" );@@ -5044,7 +5044,7 @@ static int copy(int argc, char **argv, struct command *cmd, struct plugin *plugi } } -nvme_init_copy_range (copy, nlbs, slbas, eilbrts, elbatms, elbats, nr); +nvme_init_copy_range (copy, nlbs, (__u64 *)slbas, eilbrts, elbatms, elbats, nr); err = nvme_copy(fd, cfg.namespace_id, copy, cfg.sdlba, nr, cfg.prinfor, cfg.prinfow, cfg.dtype, cfg.dspec, cfg.format, cfg.lr,