summaryrefslogtreecommitdiffstats
path: root/plugins/ocp/ocp-telemetry-decode.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/ocp/ocp-telemetry-decode.c')
-rw-r--r--plugins/ocp/ocp-telemetry-decode.c471
1 files changed, 303 insertions, 168 deletions
diff --git a/plugins/ocp/ocp-telemetry-decode.c b/plugins/ocp/ocp-telemetry-decode.c
index 11963be..1a6ebe3 100644
--- a/plugins/ocp/ocp-telemetry-decode.c
+++ b/plugins/ocp/ocp-telemetry-decode.c
@@ -64,6 +64,7 @@ void print_telemetry_fifo_event(__u8 class_type,
if (class_type) {
class_str = telemetry_event_class_to_string(class_type);
printf("Event Class : %s\n", class_str);
+ printf(" Size : 0x%02x\n", size);
}
switch (class_type) {
@@ -75,9 +76,8 @@ void print_telemetry_fifo_event(__u8 class_type,
(int)((le64_to_cpu(timestamp%3600)/60)),
(int)(le64_to_cpu(timestamp%60)));
- printf(" Event ID : 0x%02x %s\n", id, telemetry_ts_event_to_string(id));
+ printf(" Event ID : 0x%04x %s\n", id, telemetry_ts_event_to_string(id));
printf(" Timestamp : %s\n", time_str);
- printf(" Size : %d\n", size);
if (size > 8) {
printf(" VU Data : 0x");
for (j = 8; j < size; j++)
@@ -87,7 +87,7 @@ void print_telemetry_fifo_event(__u8 class_type,
break;
case TELEMETRY_PCIE_CLASS:
- printf(" Event ID : 0x%02x %s\n",
+ printf(" Event ID : 0x%04x %s\n",
id, telemetry_pcie_event_id_to_string(id));
printf(" State : 0x%02x %s\n",
data[0], telemetry_pcie_state_data_to_string(data[0]));
@@ -104,7 +104,7 @@ void print_telemetry_fifo_event(__u8 class_type,
break;
case TELEMETRY_NVME_CLASS:
- printf(" Event ID : 0x%02x %s\n",
+ printf(" Event ID : 0x%04x %s\n",
id, telemetry_nvme_event_id_to_string(id));
if ((id == ADMIN_QUEUE_NONZERO_STATUS) ||
(id == IO_QUEUE_NONZERO_STATUS)) {
@@ -128,46 +128,46 @@ void print_telemetry_fifo_event(__u8 class_type,
le32_to_cpu(csts_reg_data));
}
if (size > 8)
- print_vu_event_data(size, (__u8 *)&data[8]);
+ print_vu_event_data((size-8), (__u8 *)&data[8]);
break;
case TELEMETRY_RESET_CLASS:
- printf(" Event ID : 0x%02x %s\n",
+ printf(" Event ID : 0x%04x %s\n",
id, telemetry_reset_event_id_to_string(id));
if (size)
print_vu_event_data(size, data);
break;
case TELEMETRY_BOOT_SEQ_CLASS:
- printf(" Event ID : 0x%02x %s\n",
+ printf(" Event ID : 0x%04x %s\n",
id, telemetry_boot_seq_event_id_to_string(id));
if (size)
print_vu_event_data(size, data);
break;
case TELEMETRY_FW_ASSERT_CLASS:
- printf(" Event ID : 0x%02x %s\n",
+ printf(" Event ID : 0x%04x %s\n",
id, telemetry_fw_assert_event_id_to_string(id));
if (size)
print_vu_event_data(size, data);
break;
case TELEMETRY_TEMPERATURE_CLASS:
- printf(" Event ID : 0x%02x %s\n",
+ printf(" Event ID : 0x%04x %s\n",
id, telemetry_temperature_event_id_to_string(id));
if (size)
print_vu_event_data(size, data);
break;
case TELEMETRY_MEDIA_DBG_CLASS:
- printf(" Event ID : 0x%02x %s\n",
+ printf(" Event ID : 0x%04x %s\n",
id, telemetry_media_debug_event_id_to_string(id));
if (size)
print_vu_event_data(size, data);
break;
case TELEMETRY_MEDIA_WEAR_CLASS:
- printf(" Event ID : 0x%02x %s\n",
+ printf(" Event ID : 0x%04x %s\n",
id, telemetry_media_debug_event_id_to_string(id));
__u32 host_tb_written = *(__u32 *)&data[0];
__u32 media_tb_written = *(__u32 *)&data[4];
@@ -181,7 +181,7 @@ void print_telemetry_fifo_event(__u8 class_type,
le16_to_cpu(media_tb_erased));
if (size > 12)
- print_vu_event_data(size, (__u8 *)&data[12]);
+ print_vu_event_data((size-12), (__u8 *)&data[12]);
break;
case TELEMETRY_STAT_SNAPSHOT_CLASS:
@@ -280,7 +280,7 @@ struct request_data ocp_header_in_da1[] = {
{ "Minor Version", 2 },
{ "Reserved1", 4 },
{ "Timestamp", 8 },
- { "Log page GUID", 16 },
+ { "Log page GUID", GUID_LEN },
{ "Number Telemetry Profiles Supported", 1 },
{ "Telemetry Profile Selected", 1 },
{ "Reserved2", 6 },
@@ -419,9 +419,10 @@ struct request_data smart_extended[] = {
{ "Lowest Permitted Firmware Revision", 8 },
{ "Reserved4", 278 },
{ "Log Page Version", 2 },
- { "Log page GUID", 16 }
+ { "Log page GUID", GUID_LEN }
};
+#ifdef CONFIG_JSONC
void json_add_formatted_u32_str(struct json_object *pobject, const char *msg, unsigned int pdata)
{
char data_str[70] = { 0 };
@@ -443,6 +444,7 @@ void json_add_formatted_var_size_str(struct json_object *pobject, const char *ms
json_object_add_value_string(pobject, msg, description_str);
}
+#endif /* CONFIG_JSONC */
int get_telemetry_das_offset_and_size(
struct nvme_ocp_telemetry_common_header *ptelemetry_common_header,
@@ -636,49 +638,67 @@ int parse_ocp_telemetry_string_log(int event_fifo_num, int identifier, int debug
return 0;
}
+#ifdef CONFIG_JSONC
void parse_time_stamp_event(struct nvme_ocp_telemetry_event_descriptor *pevent_descriptor,
struct json_object *pevent_descriptor_obj, __u8 *pevent_specific_data,
struct json_object *pevent_fifos_object, FILE *fp)
{
struct nvme_ocp_time_stamp_dbg_evt_class_format *ptime_stamp_event =
(struct nvme_ocp_time_stamp_dbg_evt_class_format *) pevent_specific_data;
-
- int vu_event_id = (int)ptime_stamp_event->vu_event_identifier;
-
- unsigned int data_size = ((pevent_descriptor->event_data_size * SIZE_OF_DWORD)-
- sizeof(struct nvme_ocp_time_stamp_dbg_evt_class_format));
-
- __u8 *pdata = (__u8 *)ptime_stamp_event +
- sizeof(struct nvme_ocp_time_stamp_dbg_evt_class_format);
-
+ struct nvme_ocp_common_dbg_evt_class_vu_data *ptime_stamp_event_vu_data = NULL;
+ __u16 vu_event_id = 0;
+ __u8 *pdata = NULL;
char description_str[256] = "";
-
- parse_ocp_telemetry_string_log(0, ptime_stamp_event->vu_event_identifier,
- pevent_descriptor->debug_event_class_type,
- VU_EVENT_STRING, description_str);
+ unsigned int vu_data_size = 0;
+ bool vu_data_present = false;
+
+ if ((pevent_descriptor->event_data_size * SIZE_OF_DWORD) >
+ sizeof(struct nvme_ocp_time_stamp_dbg_evt_class_format)) {
+ vu_data_present = true;
+ vu_data_size =
+ ((pevent_descriptor->event_data_size * SIZE_OF_DWORD) -
+ (sizeof(struct nvme_ocp_time_stamp_dbg_evt_class_format) +
+ SIZE_OF_VU_EVENT_ID));
+
+ ptime_stamp_event_vu_data =
+ (struct nvme_ocp_common_dbg_evt_class_vu_data *)((__u64)ptime_stamp_event +
+ sizeof(struct nvme_ocp_time_stamp_dbg_evt_class_format));
+ vu_event_id = le16_to_cpu(ptime_stamp_event_vu_data->vu_event_identifier);
+ pdata = (__u8 *)&(ptime_stamp_event_vu_data->data);
+
+ parse_ocp_telemetry_string_log(0, vu_event_id,
+ pevent_descriptor->debug_event_class_type,
+ VU_EVENT_STRING, description_str);
+ }
if (pevent_fifos_object != NULL) {
json_add_formatted_var_size_str(pevent_descriptor_obj, STR_CLASS_SPECIFIC_DATA,
ptime_stamp_event->time_stamp, DATA_SIZE_8);
- json_add_formatted_u32_str(pevent_descriptor_obj, STR_VU_EVENT_ID_STRING,
- vu_event_id);
- json_object_add_value_string(pevent_descriptor_obj, STR_VU_EVENT_STRING,
- description_str);
- json_add_formatted_var_size_str(pevent_descriptor_obj, STR_VU_DATA, pdata,
- data_size);
+ if (vu_data_present) {
+ json_add_formatted_u32_str(pevent_descriptor_obj, STR_VU_EVENT_ID_STRING,
+ vu_event_id);
+ json_object_add_value_string(pevent_descriptor_obj, STR_VU_EVENT_STRING,
+ description_str);
+ json_add_formatted_var_size_str(pevent_descriptor_obj, STR_VU_DATA, pdata,
+ vu_data_size);
+ }
} else {
if (fp) {
print_formatted_var_size_str(STR_CLASS_SPECIFIC_DATA,
ptime_stamp_event->time_stamp, DATA_SIZE_8, fp);
- fprintf(fp, "%s: 0x%x\n", STR_VU_EVENT_ID_STRING, vu_event_id);
- fprintf(fp, "%s: %s\n", STR_VU_EVENT_STRING, description_str);
- print_formatted_var_size_str(STR_VU_DATA, pdata, data_size, fp);
+ if (vu_data_present) {
+ fprintf(fp, "%s: 0x%x\n", STR_VU_EVENT_ID_STRING, vu_event_id);
+ fprintf(fp, "%s: %s\n", STR_VU_EVENT_STRING, description_str);
+ print_formatted_var_size_str(STR_VU_DATA, pdata, vu_data_size, fp);
+ }
} else {
print_formatted_var_size_str(STR_CLASS_SPECIFIC_DATA,
ptime_stamp_event->time_stamp, DATA_SIZE_8, fp);
- printf("%s: 0x%x\n", STR_VU_EVENT_ID_STRING, vu_event_id);
- printf("%s: %s\n", STR_VU_EVENT_STRING, description_str);
- print_formatted_var_size_str(STR_VU_DATA, pdata, data_size, fp);
+ if (vu_data_present) {
+ printf("%s: 0x%x\n", STR_VU_EVENT_ID_STRING, vu_event_id);
+ printf("%s: %s\n", STR_VU_EVENT_STRING, description_str);
+ print_formatted_var_size_str(STR_VU_DATA, pdata, vu_data_size, fp);
+ }
}
}
}
@@ -689,37 +709,60 @@ void parse_pcie_event(struct nvme_ocp_telemetry_event_descriptor *pevent_descrip
{
struct nvme_ocp_pcie_dbg_evt_class_format *ppcie_event =
(struct nvme_ocp_pcie_dbg_evt_class_format *) pevent_specific_data;
- int vu_event_id = (int) ppcie_event->vu_event_identifier;
- unsigned int data_size = ((pevent_descriptor->event_data_size * SIZE_OF_DWORD) -
- sizeof(struct nvme_ocp_pcie_dbg_evt_class_format));
- __u8 *pdata = (__u8 *) ppcie_event + sizeof(struct nvme_ocp_pcie_dbg_evt_class_format);
+ struct nvme_ocp_common_dbg_evt_class_vu_data *ppcie_event_vu_data = NULL;
+ __u16 vu_event_id = 0;
+ __u8 *pdata = NULL;
char description_str[256] = "";
-
- parse_ocp_telemetry_string_log(0, ppcie_event->vu_event_identifier,
- pevent_descriptor->debug_event_class_type, VU_EVENT_STRING, description_str);
+ unsigned int vu_data_size = 0;
+ bool vu_data_present = false;
+
+ if ((pevent_descriptor->event_data_size * SIZE_OF_DWORD) >
+ sizeof(struct nvme_ocp_pcie_dbg_evt_class_format)) {
+ vu_data_present = true;
+ vu_data_size =
+ ((pevent_descriptor->event_data_size * SIZE_OF_DWORD) -
+ (sizeof(struct nvme_ocp_pcie_dbg_evt_class_format) +
+ SIZE_OF_VU_EVENT_ID));
+
+ ppcie_event_vu_data =
+ (struct nvme_ocp_common_dbg_evt_class_vu_data *)((__u64)ppcie_event +
+ sizeof(struct nvme_ocp_pcie_dbg_evt_class_format));
+ vu_event_id = le16_to_cpu(ppcie_event_vu_data->vu_event_identifier);
+ pdata = (__u8 *)&(ppcie_event_vu_data->data);
+
+ parse_ocp_telemetry_string_log(0, vu_event_id,
+ pevent_descriptor->debug_event_class_type,
+ VU_EVENT_STRING, description_str);
+ }
if (pevent_fifos_object != NULL) {
json_add_formatted_var_size_str(pevent_descriptor_obj, STR_CLASS_SPECIFIC_DATA,
ppcie_event->pCIeDebugEventData, DATA_SIZE_4);
- json_add_formatted_u32_str(pevent_descriptor_obj, STR_VU_EVENT_ID_STRING,
- vu_event_id);
- json_object_add_value_string(pevent_descriptor_obj, STR_VU_EVENT_STRING,
- description_str);
- json_add_formatted_var_size_str(pevent_descriptor_obj, STR_VU_DATA, pdata,
- data_size);
+ if (vu_data_present) {
+ json_add_formatted_u32_str(pevent_descriptor_obj, STR_VU_EVENT_ID_STRING,
+ vu_event_id);
+ json_object_add_value_string(pevent_descriptor_obj, STR_VU_EVENT_STRING,
+ description_str);
+ json_add_formatted_var_size_str(pevent_descriptor_obj, STR_VU_DATA, pdata,
+ vu_data_size);
+ }
} else {
if (fp) {
print_formatted_var_size_str(STR_CLASS_SPECIFIC_DATA,
ppcie_event->pCIeDebugEventData, DATA_SIZE_4, fp);
- fprintf(fp, "%s: 0x%x\n", STR_VU_EVENT_ID_STRING, vu_event_id);
- fprintf(fp, "%s: %s\n", STR_VU_EVENT_STRING, description_str);
- print_formatted_var_size_str(STR_VU_DATA, pdata, data_size, fp);
+ if (vu_data_present) {
+ fprintf(fp, "%s: 0x%x\n", STR_VU_EVENT_ID_STRING, vu_event_id);
+ fprintf(fp, "%s: %s\n", STR_VU_EVENT_STRING, description_str);
+ print_formatted_var_size_str(STR_VU_DATA, pdata, vu_data_size, fp);
+ }
} else {
print_formatted_var_size_str(STR_CLASS_SPECIFIC_DATA,
ppcie_event->pCIeDebugEventData, DATA_SIZE_4, fp);
- printf("%s: 0x%x\n", STR_VU_EVENT_ID_STRING, vu_event_id);
- printf("%s: %s\n", STR_VU_EVENT_STRING, description_str);
- print_formatted_var_size_str(STR_VU_DATA, pdata, data_size, fp);
+ if (vu_data_present) {
+ printf("%s: 0x%x\n", STR_VU_EVENT_ID_STRING, vu_event_id);
+ printf("%s: %s\n", STR_VU_EVENT_STRING, description_str);
+ print_formatted_var_size_str(STR_VU_DATA, pdata, vu_data_size, fp);
+ }
}
}
}
@@ -730,38 +773,61 @@ void parse_nvme_event(struct nvme_ocp_telemetry_event_descriptor *pevent_descrip
{
struct nvme_ocp_nvme_dbg_evt_class_format *pnvme_event =
(struct nvme_ocp_nvme_dbg_evt_class_format *) pevent_specific_data;
- int vu_event_id = (int) pnvme_event->vu_event_identifier;
- unsigned int data_size = ((pevent_descriptor->event_data_size *
- SIZE_OF_DWORD) - sizeof(struct nvme_ocp_nvme_dbg_evt_class_format));
- __u8 *pdata = (__u8 *) pnvme_event + sizeof(struct nvme_ocp_nvme_dbg_evt_class_format);
+ struct nvme_ocp_common_dbg_evt_class_vu_data *pnvme_event_vu_data = NULL;
+ __u16 vu_event_id = 0;
+ __u8 *pdata = NULL;
char description_str[256] = "";
-
- parse_ocp_telemetry_string_log(0, pnvme_event->vu_event_identifier,
- pevent_descriptor->debug_event_class_type, VU_EVENT_STRING,
- description_str);
+ unsigned int vu_data_size = 0;
+ bool vu_data_present = false;
+
+ if ((pevent_descriptor->event_data_size * SIZE_OF_DWORD) >
+ sizeof(struct nvme_ocp_nvme_dbg_evt_class_format)) {
+ vu_data_present = true;
+ vu_data_size =
+ ((pevent_descriptor->event_data_size * SIZE_OF_DWORD) -
+ (sizeof(struct nvme_ocp_nvme_dbg_evt_class_format) +
+ SIZE_OF_VU_EVENT_ID));
+ pnvme_event_vu_data =
+ (struct nvme_ocp_common_dbg_evt_class_vu_data *)((__u64)pnvme_event +
+ sizeof(struct nvme_ocp_nvme_dbg_evt_class_format));
+
+ vu_event_id = le16_to_cpu(pnvme_event_vu_data->vu_event_identifier);
+ pdata = (__u8 *)&(pnvme_event_vu_data->data);
+
+ parse_ocp_telemetry_string_log(0, vu_event_id,
+ pevent_descriptor->debug_event_class_type,
+ VU_EVENT_STRING,
+ description_str);
+ }
if (pevent_fifos_object != NULL) {
json_add_formatted_var_size_str(pevent_descriptor_obj, STR_CLASS_SPECIFIC_DATA,
- pnvme_event->nvmeDebugEventData, DATA_SIZE_8);
- json_add_formatted_u32_str(pevent_descriptor_obj, STR_VU_EVENT_ID_STRING,
- vu_event_id);
- json_object_add_value_string(pevent_descriptor_obj, STR_VU_EVENT_STRING,
- description_str);
- json_add_formatted_var_size_str(pevent_descriptor_obj, STR_VU_DATA, pdata,
- data_size);
+ pnvme_event->nvmeDebugEventData, DATA_SIZE_8);
+ if (vu_data_present) {
+ json_add_formatted_u32_str(pevent_descriptor_obj, STR_VU_EVENT_ID_STRING,
+ vu_event_id);
+ json_object_add_value_string(pevent_descriptor_obj, STR_VU_EVENT_STRING,
+ description_str);
+ json_add_formatted_var_size_str(pevent_descriptor_obj, STR_VU_DATA, pdata,
+ vu_data_size);
+ }
} else {
if (fp) {
print_formatted_var_size_str(STR_CLASS_SPECIFIC_DATA,
pnvme_event->nvmeDebugEventData, DATA_SIZE_8, fp);
- fprintf(fp, "%s: 0x%x\n", STR_VU_EVENT_ID_STRING, vu_event_id);
- fprintf(fp, "%s: %s\n", STR_VU_EVENT_STRING, description_str);
- print_formatted_var_size_str(STR_VU_DATA, pdata, data_size, fp);
+ if (vu_data_present) {
+ fprintf(fp, "%s: 0x%x\n", STR_VU_EVENT_ID_STRING, vu_event_id);
+ fprintf(fp, "%s: %s\n", STR_VU_EVENT_STRING, description_str);
+ print_formatted_var_size_str(STR_VU_DATA, pdata, vu_data_size, fp);
+ }
} else {
print_formatted_var_size_str(STR_CLASS_SPECIFIC_DATA,
pnvme_event->nvmeDebugEventData, DATA_SIZE_8, fp);
- printf("%s: 0x%x\n", STR_VU_EVENT_ID_STRING, vu_event_id);
- printf("%s: %s\n", STR_VU_EVENT_STRING, description_str);
- print_formatted_var_size_str(STR_VU_DATA, pdata, data_size, fp);
+ if (vu_data_present) {
+ printf("%s: 0x%x\n", STR_VU_EVENT_ID_STRING, vu_event_id);
+ printf("%s: %s\n", STR_VU_EVENT_STRING, description_str);
+ print_formatted_var_size_str(STR_VU_DATA, pdata, vu_data_size, fp);
+ }
}
}
}
@@ -770,34 +836,38 @@ void parse_common_event(struct nvme_ocp_telemetry_event_descriptor *pevent_descr
struct json_object *pevent_descriptor_obj, __u8 *pevent_specific_data,
struct json_object *pevent_fifos_object, FILE *fp)
{
- struct nvme_ocp_common_dbg_evt_class_format *pcommon_debug_event =
- (struct nvme_ocp_common_dbg_evt_class_format *) pevent_specific_data;
- int vu_event_id = (int) pcommon_debug_event->vu_event_identifier;
- unsigned int data_size = ((pevent_descriptor->event_data_size *
- SIZE_OF_DWORD) - sizeof(struct nvme_ocp_common_dbg_evt_class_format));
- __u8 *pdata = (__u8 *) pcommon_debug_event +
- sizeof(struct nvme_ocp_common_dbg_evt_class_format);
- char description_str[256] = "";
-
- parse_ocp_telemetry_string_log(0, pcommon_debug_event->vu_event_identifier,
- pevent_descriptor->debug_event_class_type, VU_EVENT_STRING, description_str);
-
- if (pevent_fifos_object != NULL) {
- json_add_formatted_u32_str(pevent_descriptor_obj, STR_VU_EVENT_ID_STRING,
- vu_event_id);
- json_object_add_value_string(pevent_descriptor_obj, STR_VU_EVENT_STRING,
- description_str);
- json_add_formatted_var_size_str(pevent_descriptor_obj, STR_VU_DATA, pdata,
- data_size);
- } else {
- if (fp) {
- fprintf(fp, "%s: 0x%x\n", STR_VU_EVENT_ID_STRING, vu_event_id);
- fprintf(fp, "%s: %s\n", STR_VU_EVENT_STRING, description_str);
- print_formatted_var_size_str(STR_VU_DATA, pdata, data_size, fp);
+ if (pevent_specific_data) {
+ struct nvme_ocp_common_dbg_evt_class_vu_data *pcommon_debug_event_vu_data =
+ (struct nvme_ocp_common_dbg_evt_class_vu_data *) pevent_specific_data;
+
+ __u16 vu_event_id = le16_to_cpu(pcommon_debug_event_vu_data->vu_event_identifier);
+ char description_str[256] = "";
+ __u8 *pdata = (__u8 *)&(pcommon_debug_event_vu_data->data);
+
+ unsigned int vu_data_size = ((pevent_descriptor->event_data_size *
+ SIZE_OF_DWORD) - SIZE_OF_VU_EVENT_ID);
+
+ parse_ocp_telemetry_string_log(0, vu_event_id,
+ pevent_descriptor->debug_event_class_type,
+ VU_EVENT_STRING, description_str);
+
+ if (pevent_fifos_object != NULL) {
+ json_add_formatted_u32_str(pevent_descriptor_obj, STR_VU_EVENT_ID_STRING,
+ vu_event_id);
+ json_object_add_value_string(pevent_descriptor_obj, STR_VU_EVENT_STRING,
+ description_str);
+ json_add_formatted_var_size_str(pevent_descriptor_obj, STR_VU_DATA, pdata,
+ vu_data_size);
} else {
- printf("%s: 0x%x\n", STR_VU_EVENT_ID_STRING, vu_event_id);
- printf("%s: %s\n", STR_VU_EVENT_STRING, description_str);
- print_formatted_var_size_str(STR_VU_DATA, pdata, data_size, fp);
+ if (fp) {
+ fprintf(fp, "%s: 0x%x\n", STR_VU_EVENT_ID_STRING, vu_event_id);
+ fprintf(fp, "%s: %s\n", STR_VU_EVENT_STRING, description_str);
+ print_formatted_var_size_str(STR_VU_DATA, pdata, vu_data_size, fp);
+ } else {
+ printf("%s: 0x%x\n", STR_VU_EVENT_ID_STRING, vu_event_id);
+ printf("%s: %s\n", STR_VU_EVENT_STRING, description_str);
+ print_formatted_var_size_str(STR_VU_DATA, pdata, vu_data_size, fp);
+ }
}
}
}
@@ -808,39 +878,62 @@ void parse_media_wear_event(struct nvme_ocp_telemetry_event_descriptor *pevent_d
{
struct nvme_ocp_media_wear_dbg_evt_class_format *pmedia_wear_event =
(struct nvme_ocp_media_wear_dbg_evt_class_format *) pevent_specific_data;
- int vu_event_id = (int) pmedia_wear_event->vu_event_identifier;
- unsigned int data_size = ((pevent_descriptor->event_data_size * SIZE_OF_DWORD) -
- sizeof(struct nvme_ocp_media_wear_dbg_evt_class_format));
- __u8 *pdata = (__u8 *) pmedia_wear_event +
- sizeof(struct nvme_ocp_media_wear_dbg_evt_class_format);
- char description_str[256] = "";
+ struct nvme_ocp_common_dbg_evt_class_vu_data *pmedia_wear_event_vu_data = NULL;
- parse_ocp_telemetry_string_log(0, pmedia_wear_event->vu_event_identifier,
- pevent_descriptor->debug_event_class_type, VU_EVENT_STRING,
- description_str);
+ __u16 vu_event_id = 0;
+ __u8 *pdata = NULL;
+ char description_str[256] = "";
+ unsigned int vu_data_size = 0;
+ bool vu_data_present = false;
+
+ if ((pevent_descriptor->event_data_size * SIZE_OF_DWORD) >
+ sizeof(struct nvme_ocp_media_wear_dbg_evt_class_format)) {
+ vu_data_present = true;
+ vu_data_size =
+ ((pevent_descriptor->event_data_size * SIZE_OF_DWORD) -
+ (sizeof(struct nvme_ocp_media_wear_dbg_evt_class_format) +
+ SIZE_OF_VU_EVENT_ID));
+
+ pmedia_wear_event_vu_data =
+ (struct nvme_ocp_common_dbg_evt_class_vu_data *)((__u64)pmedia_wear_event +
+ sizeof(struct nvme_ocp_media_wear_dbg_evt_class_format));
+ vu_event_id = le16_to_cpu(pmedia_wear_event_vu_data->vu_event_identifier);
+ pdata = (__u8 *)&(pmedia_wear_event_vu_data->data);
+
+ parse_ocp_telemetry_string_log(0, vu_event_id,
+ pevent_descriptor->debug_event_class_type,
+ VU_EVENT_STRING,
+ description_str);
+ }
if (pevent_fifos_object != NULL) {
json_add_formatted_var_size_str(pevent_descriptor_obj, STR_CLASS_SPECIFIC_DATA,
pmedia_wear_event->currentMediaWear, DATA_SIZE_12);
- json_add_formatted_u32_str(pevent_descriptor_obj, STR_VU_EVENT_ID_STRING,
- vu_event_id);
- json_object_add_value_string(pevent_descriptor_obj, STR_VU_EVENT_STRING,
- description_str);
- json_add_formatted_var_size_str(pevent_descriptor_obj, STR_VU_DATA, pdata,
- data_size);
+ if (vu_data_present) {
+ json_add_formatted_u32_str(pevent_descriptor_obj, STR_VU_EVENT_ID_STRING,
+ vu_event_id);
+ json_object_add_value_string(pevent_descriptor_obj, STR_VU_EVENT_STRING,
+ description_str);
+ json_add_formatted_var_size_str(pevent_descriptor_obj, STR_VU_DATA, pdata,
+ vu_data_size);
+ }
} else {
if (fp) {
print_formatted_var_size_str(STR_CLASS_SPECIFIC_DATA,
pmedia_wear_event->currentMediaWear, DATA_SIZE_12, fp);
- fprintf(fp, "%s: 0x%x\n", STR_VU_EVENT_ID_STRING, vu_event_id);
- fprintf(fp, "%s: %s\n", STR_VU_EVENT_STRING, description_str);
- print_formatted_var_size_str(STR_VU_DATA, pdata, data_size, fp);
+ if (vu_data_present) {
+ fprintf(fp, "%s: 0x%x\n", STR_VU_EVENT_ID_STRING, vu_event_id);
+ fprintf(fp, "%s: %s\n", STR_VU_EVENT_STRING, description_str);
+ print_formatted_var_size_str(STR_VU_DATA, pdata, vu_data_size, fp);
+ }
} else {
print_formatted_var_size_str(STR_CLASS_SPECIFIC_DATA,
pmedia_wear_event->currentMediaWear, DATA_SIZE_12, NULL);
- printf("%s: 0x%x\n", STR_VU_EVENT_ID_STRING, vu_event_id);
- printf("%s: %s\n", STR_VU_EVENT_STRING, description_str);
- print_formatted_var_size_str(STR_VU_DATA, pdata, data_size, fp);
+ if (vu_data_present) {
+ printf("%s: 0x%x\n", STR_VU_EVENT_ID_STRING, vu_event_id);
+ printf("%s: %s\n", STR_VU_EVENT_STRING, description_str);
+ print_formatted_var_size_str(STR_VU_DATA, pdata, vu_data_size, fp);
+ }
}
}
}
@@ -895,16 +988,27 @@ int parse_event_fifo(unsigned int fifo_num, unsigned char *pfifo_start,
(struct nvme_ocp_telemetry_event_descriptor *)
(pfifo_start + offset_to_move);
+ /* check if at the end of the list */
+ if (pevent_descriptor->debug_event_class_type == RESERVED_CLASS_TYPE)
+ break;
+
if (pevent_descriptor != NULL && pevent_descriptor->event_data_size >= 0) {
- //Data is present in the form of DWORDS, So multiplying with sizeof(DWORD)
+ /* Data is present in the form of DWORDS,
+ * So multiplying with sizeof(DWORD)
+ */
unsigned int data_size = pevent_descriptor->event_data_size *
SIZE_OF_DWORD;
- __u8 *pevent_specific_data = (__u8 *)pevent_descriptor + event_des_size;
-
+ __u8 *pevent_specific_data = NULL;
+ __u16 event_id = 0;
char description_str[256] = "";
- parse_ocp_telemetry_string_log(0, pevent_descriptor->event_id,
+ if (pevent_descriptor != NULL && pevent_descriptor->event_data_size > 0)
+ pevent_specific_data = (__u8 *)pevent_descriptor + event_des_size;
+
+ event_id = le16_to_cpu(pevent_descriptor->event_id);
+
+ parse_ocp_telemetry_string_log(0, event_id,
pevent_descriptor->debug_event_class_type, EVENT_STRING,
description_str);
@@ -916,7 +1020,7 @@ int parse_event_fifo(unsigned int fifo_num, unsigned char *pfifo_start,
STR_DBG_EVENT_CLASS_TYPE,
pevent_descriptor->debug_event_class_type);
json_add_formatted_u32_str(pevent_descriptor_obj,
- STR_EVENT_IDENTIFIER, pevent_descriptor->event_id);
+ STR_EVENT_IDENTIFIER, event_id);
json_object_add_value_string(pevent_descriptor_obj,
STR_EVENT_STRING, description_str);
json_add_formatted_u32_str(pevent_descriptor_obj,
@@ -930,18 +1034,18 @@ int parse_event_fifo(unsigned int fifo_num, unsigned char *pfifo_start,
fprintf(fp, "%s: 0x%x\n", STR_DBG_EVENT_CLASS_TYPE,
pevent_descriptor->debug_event_class_type);
fprintf(fp, "%s: 0x%x\n", STR_EVENT_IDENTIFIER,
- pevent_descriptor->event_id);
+ event_id);
fprintf(fp, "%s: %s\n", STR_EVENT_STRING, description_str);
fprintf(fp, "%s: 0x%x\n", STR_EVENT_DATA_SIZE,
pevent_descriptor->event_data_size);
} else {
printf("%s: 0x%x\n", STR_DBG_EVENT_CLASS_TYPE,
- pevent_descriptor->debug_event_class_type);
+ pevent_descriptor->debug_event_class_type);
printf("%s: 0x%x\n", STR_EVENT_IDENTIFIER,
- pevent_descriptor->event_id);
+ event_id);
printf("%s: %s\n", STR_EVENT_STRING, description_str);
printf("%s: 0x%x\n", STR_EVENT_DATA_SIZE,
- pevent_descriptor->event_data_size);
+ pevent_descriptor->event_data_size);
}
if (pevent_descriptor->debug_event_class_type >= 0x80)
@@ -951,28 +1055,43 @@ int parse_event_fifo(unsigned int fifo_num, unsigned char *pfifo_start,
switch (pevent_descriptor->debug_event_class_type) {
case TIME_STAMP_CLASS_TYPE:
- parse_time_stamp_event(pevent_descriptor, pevent_descriptor_obj,
- pevent_specific_data, pevent_fifos_object, fp);
+ parse_time_stamp_event(pevent_descriptor,
+ pevent_descriptor_obj,
+ pevent_specific_data,
+ pevent_fifos_object,
+ fp);
break;
case PCIE_CLASS_TYPE:
- parse_pcie_event(pevent_descriptor, pevent_descriptor_obj,
- pevent_specific_data, pevent_fifos_object, fp);
+ parse_pcie_event(pevent_descriptor,
+ pevent_descriptor_obj,
+ pevent_specific_data,
+ pevent_fifos_object,
+ fp);
break;
case NVME_CLASS_TYPE:
- parse_nvme_event(pevent_descriptor, pevent_descriptor_obj,
- pevent_specific_data, pevent_fifos_object, fp);
+ parse_nvme_event(pevent_descriptor,
+ pevent_descriptor_obj,
+ pevent_specific_data,
+ pevent_fifos_object,
+ fp);
break;
case RESET_CLASS_TYPE:
case BOOT_SEQUENCE_CLASS_TYPE:
case FIRMWARE_ASSERT_CLASS_TYPE:
case TEMPERATURE_CLASS_TYPE:
case MEDIA_CLASS_TYPE:
- parse_common_event(pevent_descriptor, pevent_descriptor_obj,
- pevent_specific_data, pevent_fifos_object, fp);
+ parse_common_event(pevent_descriptor,
+ pevent_descriptor_obj,
+ pevent_specific_data,
+ pevent_fifos_object,
+ fp);
break;
case MEDIA_WEAR_CLASS_TYPE:
- parse_media_wear_event(pevent_descriptor, pevent_descriptor_obj,
- pevent_specific_data, pevent_fifos_object, fp);
+ parse_media_wear_event(pevent_descriptor,
+ pevent_descriptor_obj,
+ pevent_specific_data,
+ pevent_fifos_object,
+ fp);
break;
case STATISTIC_SNAPSHOT_CLASS_TYPE: {
struct nvme_ocp_statistic_snapshot_evt_class_format
@@ -989,20 +1108,22 @@ int parse_event_fifo(unsigned int fifo_num, unsigned char *pfifo_start,
case RESERVED_CLASS_TYPE:
default:
break;
- }
+ }
- if (pevent_descriptor_obj != NULL && pevent_fifo_array != NULL)
- json_array_add_value_object(pevent_fifo_array, pevent_descriptor_obj);
- else {
- if (fp)
- fprintf(fp, STR_LINE2);
- else
- printf(STR_LINE2);
- }
- } else
- break;
+ if (pevent_descriptor_obj != NULL && pevent_fifo_array != NULL)
+ json_array_add_value_object(pevent_fifo_array,
+ pevent_descriptor_obj);
+ else {
+ if (fp)
+ fprintf(fp, STR_LINE2);
+ else
+ printf(STR_LINE2);
+ }
+ } else
+ break;
- offset_to_move += (pevent_descriptor->event_data_size * SIZE_OF_DWORD + event_des_size);
+ offset_to_move += (pevent_descriptor->event_data_size * SIZE_OF_DWORD +
+ event_des_size);
}
if (pevent_fifos_object != NULL && pevent_fifo_array != NULL)
@@ -1241,9 +1362,16 @@ int print_ocp_telemetry_normal(struct ocp_telemetry_parse_options *options)
fprintf(fp, STR_LINE);
fprintf(fp, "%s\n", STR_LOG_PAGE_HEADER);
fprintf(fp, STR_LINE);
- if (!strcmp(options->telemetry_type, "host"))
- generic_structure_parser(ptelemetry_buffer, host_log_page_header,
- ARRAY_SIZE(host_log_page_header), NULL, 0, fp);
+ if (!strcmp(options->telemetry_type, "host")) {
+ if ((ptelemetry_buffer == NULL) ||
+ (ARRAY_SIZE(host_log_page_header) == 0))
+ printf("skip generic_structure_parser\n");
+ else
+ generic_structure_parser(ptelemetry_buffer,
+ host_log_page_header,
+ ARRAY_SIZE(host_log_page_header),
+ NULL, 0, fp);
+ }
else if (!strcmp(options->telemetry_type, "controller"))
generic_structure_parser(ptelemetry_buffer,
controller_log_page_header,
@@ -1350,9 +1478,15 @@ int print_ocp_telemetry_normal(struct ocp_telemetry_parse_options *options)
printf(STR_LINE);
printf("%s\n", STR_LOG_PAGE_HEADER);
printf(STR_LINE);
- if (!strcmp(options->telemetry_type, "host"))
- generic_structure_parser(ptelemetry_buffer, host_log_page_header,
- ARRAY_SIZE(host_log_page_header), NULL, 0, NULL);
+ if (!strcmp(options->telemetry_type, "host")) {
+ if ((ptelemetry_buffer == NULL) ||
+ (ARRAY_SIZE(host_log_page_header) == 0))
+ printf("skip generic_structure_parser\n");
+ else {
+ generic_structure_parser(ptelemetry_buffer, host_log_page_header,
+ ARRAY_SIZE(host_log_page_header), NULL, 0, NULL);
+ }
+ }
else if (!strcmp(options->telemetry_type, "controller"))
generic_structure_parser(ptelemetry_buffer, controller_log_page_header,
ARRAY_SIZE(controller_log_page_header), NULL, 0, NULL);
@@ -1363,7 +1497,7 @@ int print_ocp_telemetry_normal(struct ocp_telemetry_parse_options *options)
__u8 *preason_identifier_offset = ptelemetry_buffer +
offsetof(struct nvme_ocp_telemetry_host_initiated_header, reason_id);
generic_structure_parser(preason_identifier_offset, reason_identifier,
- ARRAY_SIZE(reason_identifier), NULL, 0, NULL);
+ ARRAY_SIZE(reason_identifier), NULL, 0, NULL);
printf(STR_LINE);
printf("%s\n", STR_TELEMETRY_HOST_DATA_BLOCK_1);
@@ -1382,7 +1516,7 @@ int print_ocp_telemetry_normal(struct ocp_telemetry_parse_options *options)
__u8 *pda1_header_offset = ptelemetry_buffer + offsets.da1_start_offset;//512
generic_structure_parser(pda1_header_offset, ocp_header_in_da1,
- ARRAY_SIZE(ocp_header_in_da1), NULL, 0, NULL);
+ ARRAY_SIZE(ocp_header_in_da1), NULL, 0, NULL);
printf(STR_LINE);
printf("%s\n", STR_SMART_HEALTH_INFO);
@@ -1391,7 +1525,7 @@ int print_ocp_telemetry_normal(struct ocp_telemetry_parse_options *options)
offsetof(struct nvme_ocp_header_in_da1, smart_health_info);
generic_structure_parser(pda1_smart_offset, smart, ARRAY_SIZE(smart), NULL, 0,
- NULL);
+ NULL);
printf(STR_LINE);
printf("%s\n", STR_SMART_HEALTH_INTO_EXTENDED);
@@ -1400,7 +1534,7 @@ int print_ocp_telemetry_normal(struct ocp_telemetry_parse_options *options)
offsetof(struct nvme_ocp_header_in_da1, smart_health_info_extended);
generic_structure_parser(pda1_smart_ext_offset, smart_extended,
- ARRAY_SIZE(smart_extended), NULL, 0, NULL);
+ ARRAY_SIZE(smart_extended), NULL, 0, NULL);
printf(STR_LINE);
printf("%s\n", STR_DA_1_STATS);
@@ -1564,3 +1698,4 @@ int print_ocp_telemetry_json(struct ocp_telemetry_parse_options *options)
return status;
}
+#endif /* CONFIG_JSONC */