| File: | .build-ci/../plugins/ocp/ocp-telemetry-decode.h |
| Warning: | line 828, column 13 Addition of a null pointer (from variable 'buf') and a probably nonzero integer value may result in undefined behavior |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | // SPDX-License-Identifier: GPL-2.0-or-later | |||
| 2 | #include <libnvme.h> | |||
| 3 | ||||
| 4 | #include <ccan/array_size/array_size.h> | |||
| 5 | #include <ccan/endian/endian.h> | |||
| 6 | #include <shared/hex-util.h> | |||
| 7 | #include <shared/int-util.h> | |||
| 8 | #include <shared/string-util.h> | |||
| 9 | #include <shared/time-util.h> | |||
| 10 | #include <shared/uint128-util.h> | |||
| 11 | #include <shared/unaligned-util.h> | |||
| 12 | #include <shared/uuid-util.h> | |||
| 13 | ||||
| 14 | #include "cleanup.h" | |||
| 15 | #include "nvme-json.h" | |||
| 16 | #include "nvme-print.h" | |||
| 17 | #include "ocp-fw-activation-history.h" | |||
| 18 | #include "ocp-hardware-component-log.h" | |||
| 19 | #include "ocp-nvme.h" | |||
| 20 | #include "ocp-print.h" | |||
| 21 | #include "ocp-smart-extended-log.h" | |||
| 22 | #include "ocp-telemetry-decode.h" | |||
| 23 | #include "ocp-utils.h" | |||
| 24 | ||||
| 25 | #define array_add_objjson_array_add_value_object json_array_add_value_object | |||
| 26 | #define array_add_strjson_array_add_value_string json_array_add_value_string | |||
| 27 | ||||
| 28 | #define obj_add_arrayjson_object_add_value_array json_object_add_value_array | |||
| 29 | #define obj_add_intjson_object_add_value_int json_object_add_value_int | |||
| 30 | #define obj_add_objjson_object_add_value_object json_object_add_value_object | |||
| 31 | #define obj_add_uintjson_object_add_value_uint json_object_add_value_uint | |||
| 32 | #define obj_add_uint128json_object_add_value_uint128 json_object_add_value_uint128 | |||
| 33 | #define obj_add_uint64json_object_add_value_uint64 json_object_add_value_uint64 | |||
| 34 | #define obj_add_strjson_object_add_value_string json_object_add_value_string | |||
| 35 | #define obj_add_uint_02xjson_object_add_uint_02x json_object_add_uint_02x | |||
| 36 | #define obj_add_uint_0xjson_object_add_uint_0x json_object_add_uint_0x | |||
| 37 | #define obj_add_byte_arrayjson_object_add_byte_array json_object_add_byte_array | |||
| 38 | #define obj_add_nprix64json_object_add_nprix64 json_object_add_nprix64 | |||
| 39 | #define obj_add_uint_0nxjson_object_add_uint_0nx json_object_add_uint_0nx | |||
| 40 | #define obj_add_0nprix64json_object_add_0nprix64 json_object_add_0nprix64 | |||
| 41 | #define obj_add_stringjson_object_add_string json_object_add_string | |||
| 42 | ||||
| 43 | static void d_json(unsigned char *buf, int len, int width, int group, struct json_object *array) | |||
| 44 | { | |||
| 45 | int i; | |||
| 46 | char ascii[32 + 1] = { 0 }; | |||
| 47 | ||||
| 48 | assert(width < sizeof(ascii))((void) sizeof (__assert_single_arg (width < sizeof(ascii) )), __extension__ ({ if (width < sizeof(ascii)) ; else __assert_fail ("width < sizeof(ascii)", "../plugins/ocp/ocp-print-json.c" , 48, __extension__ __PRETTY_FUNCTION__); })); | |||
| 49 | ||||
| 50 | for (i = 0; i < len; i++) { | |||
| 51 | ascii[i % width] = (buf[i] >= '!' && buf[i] <= '~') ? buf[i] : '.'; | |||
| 52 | if (!((i + 1) % width)) { | |||
| 53 | array_add_strjson_array_add_value_string(array, ascii); | |||
| 54 | memset(ascii, 0, sizeof(ascii)); | |||
| 55 | } | |||
| 56 | } | |||
| 57 | ||||
| 58 | if (strlen(ascii)) { | |||
| 59 | ascii[i % width + 1] = '\0'; | |||
| 60 | array_add_strjson_array_add_value_string(array, ascii); | |||
| 61 | } | |||
| 62 | } | |||
| 63 | ||||
| 64 | static void obj_d(struct json_object *o, const char *k, unsigned char *buf, int len, int width, | |||
| 65 | int group) | |||
| 66 | { | |||
| 67 | struct json_object *data = json_create_array()json_object_new_array(); | |||
| 68 | ||||
| 69 | d_json(buf, len, width, group, data); | |||
| 70 | obj_add_array(o, k, data)json_object_object_add(o, k, data); | |||
| 71 | } | |||
| 72 | ||||
| 73 | static void obj_add_result(struct json_object *o, const char *v, ...) | |||
| 74 | { | |||
| 75 | va_list ap; | |||
| 76 | ||||
| 77 | __cleanup_free__attribute__((cleanup(shr_freep))) char *value = NULL((void*)0); | |||
| 78 | ||||
| 79 | va_start(ap, v)__builtin_va_start(ap, v); | |||
| 80 | ||||
| 81 | if (vasprintf(&value, v, ap) < 0) | |||
| 82 | value = NULL((void*)0); | |||
| 83 | ||||
| 84 | obj_add_strjson_object_add_value_string(o, "Result", value ? value : alloc_error); | |||
| 85 | ||||
| 86 | va_end(ap)__builtin_va_end(ap); | |||
| 87 | } | |||
| 88 | ||||
| 89 | static void print_hwcomp_desc_json(struct hwcomp_desc_entry *e, struct json_object *r) | |||
| 90 | { | |||
| 91 | json_object_add_value_string(r, "Description", | |||
| 92 | hwcomp_id_to_string(le32_to_cpu(e->desc->id))); | |||
| 93 | json_object_add_nprix64(r, "Date/Lot Size", e->date_lot_size); | |||
| 94 | json_object_add_nprix64(r, "Additional Information Size", e->add_info_size); | |||
| 95 | json_object_add_uint_0nx(r, "Identifier", le32_to_cpu(e->desc->id), 8); | |||
| 96 | json_object_add_0nprix64(r, "Manufacture", le64_to_cpu(e->desc->mfg), 16); | |||
| 97 | json_object_add_0nprix64(r, "Revision", le64_to_cpu(e->desc->rev), 16); | |||
| 98 | json_object_add_0nprix64(r, "Manufacture Code", le64_to_cpu(e->desc->mfg_code), 16); | |||
| 99 | json_object_add_byte_array(r, "Date/Lot Code", e->date_lot_code, e->date_lot_size); | |||
| 100 | json_object_add_byte_array(r, "Additional Information", e->add_info, e->add_info_size); | |||
| 101 | } | |||
| 102 | ||||
| 103 | static void print_hwcomp_desc_list_json(struct json_object *r, struct hwcomp_desc_entry *e, | |||
| 104 | bool_Bool list, int num) | |||
| 105 | { | |||
| 106 | __cleanup_free__attribute__((cleanup(shr_freep))) char *k = NULL((void*)0); | |||
| 107 | ||||
| 108 | if (asprintf(&k, "Component %d", num) < 0) | |||
| 109 | return; | |||
| 110 | ||||
| 111 | if (list) { | |||
| 112 | json_object_add_value_string(r, k, | |||
| 113 | hwcomp_id_to_string(le32_to_cpu(e->desc->id))); | |||
| 114 | return; | |||
| 115 | } | |||
| 116 | ||||
| 117 | print_hwcomp_desc_json(e, obj_create_array_obj(r, k)); | |||
| 118 | } | |||
| 119 | ||||
| 120 | static void print_hwcomp_descs_json(struct hwcomp_log *log, __u32 id, | |||
| 121 | bool_Bool list, struct json_object *r) | |||
| 122 | { | |||
| 123 | struct hwcomp_desc_entry e; | |||
| 124 | __u64 offset; | |||
| 125 | int num = 1; | |||
| 126 | ||||
| 127 | for (offset = 0; hwcomp_desc_entry(log, offset, &e); | |||
| 128 | offset += e.desc_size) { | |||
| 129 | if (!id || id == le32_to_cpu(e.desc->id)) | |||
| 130 | print_hwcomp_desc_list_json(r, &e, list, num++); | |||
| 131 | } | |||
| 132 | } | |||
| 133 | ||||
| 134 | static void json_hwcomp_log(struct hwcomp_log *log, __u32 id, bool_Bool list) | |||
| 135 | { | |||
| 136 | struct json_object *r = json_create_object()json_object_new_object(); | |||
| 137 | ||||
| 138 | json_object_add_uint_02x(r, "Log Identifier", OCP_LID_HWCOMP); | |||
| 139 | json_object_add_uint_0x(r, "Log Page Version", le16_to_cpu(log->ver)); | |||
| 140 | json_object_add_byte_array(r, "Reserved2", log->rsvd2, ARRAY_SIZE(log->rsvd2)(sizeof(log->rsvd2) / sizeof((log->rsvd2)[0]) + 0)); | |||
| 141 | json_object_add_byte_array(r, "Log page GUID", log->guid, ARRAY_SIZE(log->guid)(sizeof(log->guid) / sizeof((log->guid)[0]) + 0)); | |||
| 142 | json_object_add_nprix64(r, "Hardware Component Log Size", | |||
| 143 | (unsigned long long)log->desc_len); | |||
| 144 | json_object_add_byte_array(r, "Reserved48", log->rsvd48, ARRAY_SIZE(log->rsvd48)(sizeof(log->rsvd48) / sizeof((log->rsvd48)[0]) + 0)); | |||
| 145 | print_hwcomp_descs_json(log, id, list, | |||
| 146 | obj_create_array_obj(r, "Component Descriptions")); | |||
| 147 | ||||
| 148 | json_print(r); | |||
| 149 | } | |||
| 150 | ||||
| 151 | static void json_fw_activation_history(const struct fw_activation_history *fw_history) | |||
| 152 | { | |||
| 153 | struct json_object *root = json_create_object()json_object_new_object(); | |||
| 154 | ||||
| 155 | json_object_add_value_uint(root, "log identifier", fw_history->log_id)json_object_object_add(root, "log identifier", json_object_new_uint64 (fw_history->log_id)); | |||
| 156 | json_object_add_value_uint(root, "valid entries", le32_to_cpu(fw_history->valid_entries))json_object_object_add(root, "valid entries", json_object_new_uint64 (le32_to_cpu(fw_history->valid_entries))); | |||
| 157 | ||||
| 158 | struct json_object *entries = json_create_array()json_object_new_array(); | |||
| 159 | ||||
| 160 | for (int index = 0; index < le32_to_cpu(fw_history->valid_entries) && | |||
| 161 | index < ARRAY_SIZE(fw_history->entries)(sizeof(fw_history->entries) / sizeof((fw_history->entries )[0]) + 0); index++) { | |||
| 162 | const struct fw_activation_history_entry *entry = &fw_history->entries[index]; | |||
| 163 | struct json_object *entry_obj = json_create_object()json_object_new_object(); | |||
| 164 | ||||
| 165 | json_object_add_value_uint(entry_obj, "version number", entry->ver_num)json_object_object_add(entry_obj, "version number", json_object_new_uint64 (entry->ver_num)); | |||
| 166 | json_object_add_value_uint(entry_obj, "entry length", entry->entry_length)json_object_object_add(entry_obj, "entry length", json_object_new_uint64 (entry->entry_length)); | |||
| 167 | json_object_add_value_uint(entry_obj, "activation count",json_object_object_add(entry_obj, "activation count", json_object_new_uint64 (le16_to_cpu(entry->activation_count))) | |||
| 168 | le16_to_cpu(entry->activation_count))json_object_object_add(entry_obj, "activation count", json_object_new_uint64 (le16_to_cpu(entry->activation_count))); | |||
| 169 | json_object_add_value_uint64(entry_obj, "timestamp",json_object_object_add(entry_obj, "timestamp", json_object_new_uint64 (int48_to_long(entry->ts.timestamp))) | |||
| 170 | int48_to_long(entry->ts.timestamp))json_object_object_add(entry_obj, "timestamp", json_object_new_uint64 (int48_to_long(entry->ts.timestamp))); | |||
| 171 | json_object_add_value_uint(entry_obj, "power cycle count",json_object_object_add(entry_obj, "power cycle count", json_object_new_uint64 (le64_to_cpu(entry->power_cycle_count))) | |||
| 172 | le64_to_cpu(entry->power_cycle_count))json_object_object_add(entry_obj, "power cycle count", json_object_new_uint64 (le64_to_cpu(entry->power_cycle_count))); | |||
| 173 | ||||
| 174 | struct json_object *fw = json_object_new_string_len(entry->previous_fw, | |||
| 175 | sizeof(entry->previous_fw)); | |||
| 176 | ||||
| 177 | json_object_add_value_object(entry_obj, "previous firmware", fw)json_object_object_add(entry_obj, "previous firmware", fw); | |||
| 178 | ||||
| 179 | fw = json_object_new_string_len(entry->new_fw, sizeof(entry->new_fw)); | |||
| 180 | ||||
| 181 | json_object_add_value_object(entry_obj, "new firmware", fw)json_object_object_add(entry_obj, "new firmware", fw); | |||
| 182 | json_object_add_value_uint(entry_obj, "slot number", entry->slot_number)json_object_object_add(entry_obj, "slot number", json_object_new_uint64 (entry->slot_number)); | |||
| 183 | json_object_add_value_uint(entry_obj, "commit action type", entry->commit_action)json_object_object_add(entry_obj, "commit action type", json_object_new_uint64 (entry->commit_action)); | |||
| 184 | json_object_add_value_uint(entry_obj, "result", le16_to_cpu(entry->result))json_object_object_add(entry_obj, "result", json_object_new_uint64 (le16_to_cpu(entry->result))); | |||
| 185 | ||||
| 186 | json_array_add_value_object(entries, entry_obj)json_object_array_add(entries, entry_obj); | |||
| 187 | } | |||
| 188 | ||||
| 189 | json_object_add_value_array(root, "entries", entries)json_object_object_add(root, "entries", entries); | |||
| 190 | ||||
| 191 | json_object_add_value_uint(root, "log page version",json_object_object_add(root, "log page version", json_object_new_uint64 (le16_to_cpu(fw_history->log_page_version))) | |||
| 192 | le16_to_cpu(fw_history->log_page_version))json_object_object_add(root, "log page version", json_object_new_uint64 (le16_to_cpu(fw_history->log_page_version))); | |||
| 193 | ||||
| 194 | char guid[2 * sizeof(fw_history->log_page_guid) + 3] = { 0 }; | |||
| 195 | ||||
| 196 | snprintf(guid, sizeof(guid), "0x%016"PRIx64"l" "x""%016"PRIx64"l" "x""", | |||
| 197 | le64_to_cpu(fw_history->log_page_guid[1]), | |||
| 198 | le64_to_cpu(fw_history->log_page_guid[0])); | |||
| 199 | json_object_add_value_string(root, "log page guid", guid); | |||
| 200 | ||||
| 201 | json_print_object(root, NULL)printf("%s", json_object_to_json_string_ext(root, (1 << 1) | (1 << 4))); | |||
| 202 | json_free_object(root)json_object_put(root); | |||
| 203 | ||||
| 204 | printf("\n"); | |||
| 205 | } | |||
| 206 | ||||
| 207 | static void json_smart_extended_log_v1(struct ocp_smart_extended_log *log) | |||
| 208 | { | |||
| 209 | struct json_object *root; | |||
| 210 | struct json_object *pmuw; | |||
| 211 | struct json_object *pmur; | |||
| 212 | uint16_t smart_log_ver = 0; | |||
| 213 | uint16_t dssd_version = 0; | |||
| 214 | char guid[40]; | |||
| 215 | char ascii_arr[65]; | |||
| 216 | ||||
| 217 | root = json_create_object()json_object_new_object(); | |||
| 218 | pmuw = json_create_object()json_object_new_object(); | |||
| 219 | pmur = json_create_object()json_object_new_object(); | |||
| 220 | ||||
| 221 | json_object_add_value_uint64(pmuw, "hi",json_object_object_add(pmuw, "hi", json_object_new_uint64(le64_to_cpu (*(uint64_t *)&log->physical_media_units_written[8]))) | |||
| 222 | le64_to_cpu(*(uint64_t *)&log->physical_media_units_written[8]))json_object_object_add(pmuw, "hi", json_object_new_uint64(le64_to_cpu (*(uint64_t *)&log->physical_media_units_written[8]))); | |||
| 223 | json_object_add_value_uint64(pmuw, "lo",json_object_object_add(pmuw, "lo", json_object_new_uint64(le64_to_cpu (*(uint64_t *)&log->physical_media_units_written))) | |||
| 224 | le64_to_cpu(*(uint64_t *)&log->physical_media_units_written))json_object_object_add(pmuw, "lo", json_object_new_uint64(le64_to_cpu (*(uint64_t *)&log->physical_media_units_written))); | |||
| 225 | json_object_add_value_object(root, "Physical media units written", pmuw)json_object_object_add(root, "Physical media units written", pmuw ); | |||
| 226 | json_object_add_value_uint64(pmur, "hi",json_object_object_add(pmur, "hi", json_object_new_uint64(le64_to_cpu (*(uint64_t *)&log->physical_media_units_read[8]))) | |||
| 227 | le64_to_cpu(*(uint64_t *)&log->physical_media_units_read[8]))json_object_object_add(pmur, "hi", json_object_new_uint64(le64_to_cpu (*(uint64_t *)&log->physical_media_units_read[8]))); | |||
| 228 | json_object_add_value_uint64(pmur, "lo",json_object_object_add(pmur, "lo", json_object_new_uint64(le64_to_cpu (*(uint64_t *)&log->physical_media_units_read))) | |||
| 229 | le64_to_cpu(*(uint64_t *)&log->physical_media_units_read))json_object_object_add(pmur, "lo", json_object_new_uint64(le64_to_cpu (*(uint64_t *)&log->physical_media_units_read))); | |||
| 230 | json_object_add_value_object(root, "Physical media units read", pmur)json_object_object_add(root, "Physical media units read", pmur ); | |||
| 231 | json_object_add_value_uint64(root, "Bad user nand blocks - Raw",json_object_object_add(root, "Bad user nand blocks - Raw", json_object_new_uint64 (int48_to_long(log->bad_user_nand_blocks_raw))) | |||
| 232 | int48_to_long(log->bad_user_nand_blocks_raw))json_object_object_add(root, "Bad user nand blocks - Raw", json_object_new_uint64 (int48_to_long(log->bad_user_nand_blocks_raw))); | |||
| 233 | json_object_add_value_uint(root, "Bad user nand blocks - Normalized",json_object_object_add(root, "Bad user nand blocks - Normalized" , json_object_new_uint64(le16_to_cpu(log->bad_user_nand_blocks_normalized ))) | |||
| 234 | le16_to_cpu(log->bad_user_nand_blocks_normalized))json_object_object_add(root, "Bad user nand blocks - Normalized" , json_object_new_uint64(le16_to_cpu(log->bad_user_nand_blocks_normalized ))); | |||
| 235 | json_object_add_value_uint64(root, "Bad system nand blocks - Raw",json_object_object_add(root, "Bad system nand blocks - Raw", json_object_new_uint64 (int48_to_long(log->bad_system_nand_blocks_raw))) | |||
| 236 | int48_to_long(log->bad_system_nand_blocks_raw))json_object_object_add(root, "Bad system nand blocks - Raw", json_object_new_uint64 (int48_to_long(log->bad_system_nand_blocks_raw))); | |||
| 237 | json_object_add_value_uint(root, "Bad system nand blocks - Normalized",json_object_object_add(root, "Bad system nand blocks - Normalized" , json_object_new_uint64(le16_to_cpu(log->bad_system_nand_blocks_normalized ))) | |||
| 238 | le16_to_cpu(log->bad_system_nand_blocks_normalized))json_object_object_add(root, "Bad system nand blocks - Normalized" , json_object_new_uint64(le16_to_cpu(log->bad_system_nand_blocks_normalized ))); | |||
| 239 | json_object_add_value_uint64(root, "XOR recovery count",json_object_object_add(root, "XOR recovery count", json_object_new_uint64 (le64_to_cpu(log->xor_recovery_count))) | |||
| 240 | le64_to_cpu(log->xor_recovery_count))json_object_object_add(root, "XOR recovery count", json_object_new_uint64 (le64_to_cpu(log->xor_recovery_count))); | |||
| 241 | json_object_add_value_uint64(root, "Uncorrectable read error count",json_object_object_add(root, "Uncorrectable read error count" , json_object_new_uint64(le64_to_cpu(log->uncorrectable_read_err_count ))) | |||
| 242 | le64_to_cpu(log->uncorrectable_read_err_count))json_object_object_add(root, "Uncorrectable read error count" , json_object_new_uint64(le64_to_cpu(log->uncorrectable_read_err_count ))); | |||
| 243 | json_object_add_value_uint64(root, "Soft ecc error count",json_object_object_add(root, "Soft ecc error count", json_object_new_uint64 (le64_to_cpu(log->soft_ecc_err_count))) | |||
| 244 | le64_to_cpu(log->soft_ecc_err_count))json_object_object_add(root, "Soft ecc error count", json_object_new_uint64 (le64_to_cpu(log->soft_ecc_err_count))); | |||
| 245 | json_object_add_value_uint(root, "End to end detected errors",json_object_object_add(root, "End to end detected errors", json_object_new_uint64 (le32_to_cpu(log->end_to_end_detected_err))) | |||
| 246 | le32_to_cpu(log->end_to_end_detected_err))json_object_object_add(root, "End to end detected errors", json_object_new_uint64 (le32_to_cpu(log->end_to_end_detected_err))); | |||
| 247 | json_object_add_value_uint(root, "End to end corrected errors",json_object_object_add(root, "End to end corrected errors", json_object_new_uint64 (le32_to_cpu(log->end_to_end_corrected_err))) | |||
| 248 | le32_to_cpu(log->end_to_end_corrected_err))json_object_object_add(root, "End to end corrected errors", json_object_new_uint64 (le32_to_cpu(log->end_to_end_corrected_err))); | |||
| 249 | json_object_add_value_uint(root, "System data percent used",json_object_object_add(root, "System data percent used", json_object_new_uint64 (log->system_data_used_percent)) | |||
| 250 | log->system_data_used_percent)json_object_object_add(root, "System data percent used", json_object_new_uint64 (log->system_data_used_percent)); | |||
| 251 | json_object_add_value_uint64(root, "Refresh counts",json_object_object_add(root, "Refresh counts", json_object_new_uint64 (int56_to_long(log->refresh_counts))) | |||
| 252 | int56_to_long(log->refresh_counts))json_object_object_add(root, "Refresh counts", json_object_new_uint64 (int56_to_long(log->refresh_counts))); | |||
| 253 | json_object_add_value_uint(root, "Max User data erase counts",json_object_object_add(root, "Max User data erase counts", json_object_new_uint64 (le32_to_cpu(log->user_data_erase_count_max))) | |||
| 254 | le32_to_cpu(log->user_data_erase_count_max))json_object_object_add(root, "Max User data erase counts", json_object_new_uint64 (le32_to_cpu(log->user_data_erase_count_max))); | |||
| 255 | json_object_add_value_uint(root, "Min User data erase counts",json_object_object_add(root, "Min User data erase counts", json_object_new_uint64 (le32_to_cpu(log->user_data_erase_count_min))) | |||
| 256 | le32_to_cpu(log->user_data_erase_count_min))json_object_object_add(root, "Min User data erase counts", json_object_new_uint64 (le32_to_cpu(log->user_data_erase_count_min))); | |||
| 257 | json_object_add_value_uint(root, "Number of Thermal throttling events",json_object_object_add(root, "Number of Thermal throttling events" , json_object_new_uint64(log->thermal_throttling_event_count )) | |||
| 258 | log->thermal_throttling_event_count)json_object_object_add(root, "Number of Thermal throttling events" , json_object_new_uint64(log->thermal_throttling_event_count )); | |||
| 259 | json_object_add_value_uint(root, "Current throttling status",json_object_object_add(root, "Current throttling status", json_object_new_uint64 (log->thermal_throttling_current_status)) | |||
| 260 | log->thermal_throttling_current_status)json_object_object_add(root, "Current throttling status", json_object_new_uint64 (log->thermal_throttling_current_status)); | |||
| 261 | json_object_add_value_uint64(root, "PCIe correctable error count",json_object_object_add(root, "PCIe correctable error count", json_object_new_uint64 (le64_to_cpu(log->pcie_correctable_err_count))) | |||
| 262 | le64_to_cpu(log->pcie_correctable_err_count))json_object_object_add(root, "PCIe correctable error count", json_object_new_uint64 (le64_to_cpu(log->pcie_correctable_err_count))); | |||
| 263 | json_object_add_value_uint(root, "Incomplete shutdowns",json_object_object_add(root, "Incomplete shutdowns", json_object_new_uint64 (le32_to_cpu(log->incomplete_shoutdowns))) | |||
| 264 | le32_to_cpu(log->incomplete_shoutdowns))json_object_object_add(root, "Incomplete shutdowns", json_object_new_uint64 (le32_to_cpu(log->incomplete_shoutdowns))); | |||
| 265 | json_object_add_value_uint(root, "Percent free blocks",json_object_object_add(root, "Percent free blocks", json_object_new_uint64 (log->percent_free_blocks)) | |||
| 266 | log->percent_free_blocks)json_object_object_add(root, "Percent free blocks", json_object_new_uint64 (log->percent_free_blocks)); | |||
| 267 | json_object_add_value_uint(root, "Capacitor health",json_object_object_add(root, "Capacitor health", json_object_new_uint64 (le16_to_cpu(log->capacitor_health))) | |||
| 268 | le16_to_cpu(log->capacitor_health))json_object_object_add(root, "Capacitor health", json_object_new_uint64 (le16_to_cpu(log->capacitor_health))); | |||
| 269 | json_object_add_value_uint64(root, "Unaligned I/O",json_object_object_add(root, "Unaligned I/O", json_object_new_uint64 (le64_to_cpu(log->unaligned_io))) | |||
| 270 | le64_to_cpu(log->unaligned_io))json_object_object_add(root, "Unaligned I/O", json_object_new_uint64 (le64_to_cpu(log->unaligned_io))); | |||
| 271 | json_object_add_value_uint64(root, "Security Version Number",json_object_object_add(root, "Security Version Number", json_object_new_uint64 (le64_to_cpu(log->security_version))) | |||
| 272 | le64_to_cpu(log->security_version))json_object_object_add(root, "Security Version Number", json_object_new_uint64 (le64_to_cpu(log->security_version))); | |||
| 273 | json_object_add_value_uint64(root, "NUSE - Namespace utilization",json_object_object_add(root, "NUSE - Namespace utilization", json_object_new_uint64 (le64_to_cpu(log->total_nuse))) | |||
| 274 | le64_to_cpu(log->total_nuse))json_object_object_add(root, "NUSE - Namespace utilization", json_object_new_uint64 (le64_to_cpu(log->total_nuse))); | |||
| 275 | json_object_add_value_uint128(root, "PLP start count",json_object_object_add(root, "PLP start count", util_json_object_new_uint128 (le128_to_cpu(log->plp_start_count))) | |||
| 276 | le128_to_cpu(log->plp_start_count))json_object_object_add(root, "PLP start count", util_json_object_new_uint128 (le128_to_cpu(log->plp_start_count))); | |||
| 277 | json_object_add_value_uint128(root, "Endurance estimate",json_object_object_add(root, "Endurance estimate", util_json_object_new_uint128 (le128_to_cpu(log->endurance_estimate))) | |||
| 278 | le128_to_cpu(log->endurance_estimate))json_object_object_add(root, "Endurance estimate", util_json_object_new_uint128 (le128_to_cpu(log->endurance_estimate))); | |||
| 279 | smart_log_ver = le16_to_cpu(log->log_page_version); | |||
| 280 | ||||
| 281 | json_object_add_value_uint(root, "Log page version", smart_log_ver)json_object_object_add(root, "Log page version", json_object_new_uint64 (smart_log_ver)); | |||
| 282 | ||||
| 283 | memset((void *)guid, 0, 40); | |||
| 284 | snprintf((char *)guid, sizeof(guid), "0x%016"PRIx64"l" "x""%016"PRIx64"l" "x""", | |||
| 285 | le64_to_cpu(*(uint64_t *)&log->log_page_guid[8]), | |||
| 286 | le64_to_cpu(*(uint64_t *)&log->log_page_guid)); | |||
| 287 | json_object_add_value_string(root, "Log page GUID", guid); | |||
| 288 | ||||
| 289 | switch (smart_log_ver) { | |||
| 290 | case 0 ... 1: | |||
| 291 | break; | |||
| 292 | default: | |||
| 293 | case 6: | |||
| 294 | json_object_add_value_uint(root, "Form factor",json_object_object_add(root, "Form factor", json_object_new_uint64 (log->form_factor)) | |||
| 295 | log->form_factor)json_object_object_add(root, "Form factor", json_object_new_uint64 (log->form_factor)); | |||
| 296 | json_object_add_value_uint64(root, "Die use badnandblock raw",json_object_object_add(root, "Die use badnandblock raw", json_object_new_uint64 (int48_to_long(log->die_in_use_bad_nand_block_raw))) | |||
| 297 | int48_to_long(log->die_in_use_bad_nand_block_raw))json_object_object_add(root, "Die use badnandblock raw", json_object_new_uint64 (int48_to_long(log->die_in_use_bad_nand_block_raw))); | |||
| 298 | json_object_add_value_uint(root, "Die use badnandblock normal",json_object_object_add(root, "Die use badnandblock normal", json_object_new_uint64 (le16_to_cpu(log->die_in_use_bad_nand_block_normalized))) | |||
| 299 | le16_to_cpu(log->die_in_use_bad_nand_block_normalized))json_object_object_add(root, "Die use badnandblock normal", json_object_new_uint64 (le16_to_cpu(log->die_in_use_bad_nand_block_normalized))); | |||
| 300 | fallthrough__attribute__((fallthrough)); | |||
| 301 | case 5: | |||
| 302 | json_object_add_value_uint(root, "NVMe Over Pcie Errata Version",json_object_object_add(root, "NVMe Over Pcie Errata Version", json_object_new_uint64(log->nvme_over_pcie_errate_version )) | |||
| 303 | log->nvme_over_pcie_errate_version)json_object_object_add(root, "NVMe Over Pcie Errata Version", json_object_new_uint64(log->nvme_over_pcie_errate_version )); | |||
| 304 | json_object_add_value_uint(root, "NVMe Mi Errata Version",json_object_object_add(root, "NVMe Mi Errata Version", json_object_new_uint64 (log->nvme_mi_errata_version)) | |||
| 305 | log->nvme_mi_errata_version)json_object_object_add(root, "NVMe Mi Errata Version", json_object_new_uint64 (log->nvme_mi_errata_version)); | |||
| 306 | json_object_add_value_uint(root, "Total media dies",json_object_object_add(root, "Total media dies", json_object_new_uint64 (le16_to_cpu(log->total_media_dies))) | |||
| 307 | le16_to_cpu(log->total_media_dies))json_object_object_add(root, "Total media dies", json_object_new_uint64 (le16_to_cpu(log->total_media_dies))); | |||
| 308 | json_object_add_value_uint(root, "Total die failure tolerance",json_object_object_add(root, "Total die failure tolerance", json_object_new_uint64 (le16_to_cpu(log->total_die_failure_tolerance))) | |||
| 309 | le16_to_cpu(log->total_die_failure_tolerance))json_object_object_add(root, "Total die failure tolerance", json_object_new_uint64 (le16_to_cpu(log->total_die_failure_tolerance))); | |||
| 310 | json_object_add_value_uint(root, "Media dies offline",json_object_object_add(root, "Media dies offline", json_object_new_uint64 (le16_to_cpu(log->media_dies_offline))) | |||
| 311 | le16_to_cpu(log->media_dies_offline))json_object_object_add(root, "Media dies offline", json_object_new_uint64 (le16_to_cpu(log->media_dies_offline))); | |||
| 312 | json_object_add_value_uint(root, "Max temperature recorded",json_object_object_add(root, "Max temperature recorded", json_object_new_uint64 (log->max_temperature_recorded)) | |||
| 313 | log->max_temperature_recorded)json_object_object_add(root, "Max temperature recorded", json_object_new_uint64 (log->max_temperature_recorded)); | |||
| 314 | json_object_add_value_uint64(root, "Nand avg erase count",json_object_object_add(root, "Nand avg erase count", json_object_new_uint64 (le64_to_cpu(log->nand_avg_erase_count))) | |||
| 315 | le64_to_cpu(log->nand_avg_erase_count))json_object_object_add(root, "Nand avg erase count", json_object_new_uint64 (le64_to_cpu(log->nand_avg_erase_count))); | |||
| 316 | json_object_add_value_uint(root, "Command timeouts",json_object_object_add(root, "Command timeouts", json_object_new_uint64 (le32_to_cpu(log->command_timeouts))) | |||
| 317 | le32_to_cpu(log->command_timeouts))json_object_object_add(root, "Command timeouts", json_object_new_uint64 (le32_to_cpu(log->command_timeouts))); | |||
| 318 | json_object_add_value_uint(root, "Sys area program fail count raw",json_object_object_add(root, "Sys area program fail count raw" , json_object_new_uint64(le32_to_cpu(log->sys_area_program_fail_count_raw ))) | |||
| 319 | le32_to_cpu(log->sys_area_program_fail_count_raw))json_object_object_add(root, "Sys area program fail count raw" , json_object_new_uint64(le32_to_cpu(log->sys_area_program_fail_count_raw ))); | |||
| 320 | json_object_add_value_uint(root, "Sys area program fail count noralized",json_object_object_add(root, "Sys area program fail count noralized" , json_object_new_uint64(log->sys_area_program_fail_count_normalized )) | |||
| 321 | log->sys_area_program_fail_count_normalized)json_object_object_add(root, "Sys area program fail count noralized" , json_object_new_uint64(log->sys_area_program_fail_count_normalized )); | |||
| 322 | json_object_add_value_uint(root, "Sys area uncorrectable read count raw",json_object_object_add(root, "Sys area uncorrectable read count raw" , json_object_new_uint64(le32_to_cpu(log->sys_area_uncorr_read_count_raw ))) | |||
| 323 | le32_to_cpu(log->sys_area_uncorr_read_count_raw))json_object_object_add(root, "Sys area uncorrectable read count raw" , json_object_new_uint64(le32_to_cpu(log->sys_area_uncorr_read_count_raw ))); | |||
| 324 | json_object_add_value_uint(root, "Sys area uncorrectable read count noralized",json_object_object_add(root, "Sys area uncorrectable read count noralized" , json_object_new_uint64(log->sys_area_uncorr_read_count_normalized )) | |||
| 325 | log->sys_area_uncorr_read_count_normalized)json_object_object_add(root, "Sys area uncorrectable read count noralized" , json_object_new_uint64(log->sys_area_uncorr_read_count_normalized )); | |||
| 326 | json_object_add_value_uint(root, "Sys area erase fail count raw",json_object_object_add(root, "Sys area erase fail count raw", json_object_new_uint64(le32_to_cpu(log->sys_area_erase_fail_count_raw ))) | |||
| 327 | le32_to_cpu(log->sys_area_erase_fail_count_raw))json_object_object_add(root, "Sys area erase fail count raw", json_object_new_uint64(le32_to_cpu(log->sys_area_erase_fail_count_raw ))); | |||
| 328 | json_object_add_value_uint(root, "Sys area erase fail count noralized",json_object_object_add(root, "Sys area erase fail count noralized" , json_object_new_uint64(log->sys_area_erase_fail_count_normalized )) | |||
| 329 | log->sys_area_erase_fail_count_normalized)json_object_object_add(root, "Sys area erase fail count noralized" , json_object_new_uint64(log->sys_area_erase_fail_count_normalized )); | |||
| 330 | json_object_add_value_uint(root, "Max peak power capability",json_object_object_add(root, "Max peak power capability", json_object_new_uint64 (le16_to_cpu(log->max_peak_power_capability))) | |||
| 331 | le16_to_cpu(log->max_peak_power_capability))json_object_object_add(root, "Max peak power capability", json_object_new_uint64 (le16_to_cpu(log->max_peak_power_capability))); | |||
| 332 | json_object_add_value_uint(root, "Current max avg power",json_object_object_add(root, "Current max avg power", json_object_new_uint64 (le16_to_cpu(log->current_max_avg_power))) | |||
| 333 | le16_to_cpu(log->current_max_avg_power))json_object_object_add(root, "Current max avg power", json_object_new_uint64 (le16_to_cpu(log->current_max_avg_power))); | |||
| 334 | json_object_add_value_uint64(root, "Lifetime power consumed",json_object_object_add(root, "Lifetime power consumed", json_object_new_uint64 (int48_to_long(log->lifetime_power_consumed))) | |||
| 335 | int48_to_long(log->lifetime_power_consumed))json_object_object_add(root, "Lifetime power consumed", json_object_new_uint64 (int48_to_long(log->lifetime_power_consumed))); | |||
| 336 | snprintf(ascii_arr, sizeof(ascii_arr), "%.*s", | |||
| 337 | (int)sizeof(log->dssd_firmware_revision), | |||
| 338 | (char *)log->dssd_firmware_revision); | |||
| 339 | json_object_add_value_string(root, "Dssd firmware revision", ascii_arr); | |||
| 340 | json_object_add_value_string(root, "Dssd firmware build UUID", | |||
| 341 | shr_uuid_to_string(log->dssd_firmware_build_uuid)); | |||
| 342 | snprintf(ascii_arr, sizeof(ascii_arr), "%.*s", | |||
| 343 | (int)sizeof(log->dssd_firmware_build_label), | |||
| 344 | (char *)log->dssd_firmware_build_label); | |||
| 345 | json_object_add_value_string(root, "Dssd firmware build label", ascii_arr); | |||
| 346 | fallthrough__attribute__((fallthrough)); | |||
| 347 | case 4: | |||
| 348 | json_object_add_value_uint(root, "NVMe Command Set Errata Version",json_object_object_add(root, "NVMe Command Set Errata Version" , json_object_new_uint64(log->nvme_cmdset_errata_version)) | |||
| 349 | log->nvme_cmdset_errata_version)json_object_object_add(root, "NVMe Command Set Errata Version" , json_object_new_uint64(log->nvme_cmdset_errata_version)); | |||
| 350 | json_object_add_value_uint(root, "Lowest Permitted Firmware Revision",json_object_object_add(root, "Lowest Permitted Firmware Revision" , json_object_new_uint64(le64_to_cpu(log->lowest_permitted_fw_rev ))) | |||
| 351 | le64_to_cpu(log->lowest_permitted_fw_rev))json_object_object_add(root, "Lowest Permitted Firmware Revision" , json_object_new_uint64(le64_to_cpu(log->lowest_permitted_fw_rev ))); | |||
| 352 | fallthrough__attribute__((fallthrough)); | |||
| 353 | case 2 ... 3: | |||
| 354 | json_object_add_value_uint(root, "Errata Version Field",json_object_object_add(root, "Errata Version Field", json_object_new_uint64 (log->dssd_errata_version)) | |||
| 355 | log->dssd_errata_version)json_object_object_add(root, "Errata Version Field", json_object_new_uint64 (log->dssd_errata_version)); | |||
| 356 | memcpy(&dssd_version, log->dssd_point_version, sizeof(dssd_version)); | |||
| 357 | json_object_add_value_uint(root, "Point Version Field",json_object_object_add(root, "Point Version Field", json_object_new_uint64 (le16_to_cpu(dssd_version))) | |||
| 358 | le16_to_cpu(dssd_version))json_object_object_add(root, "Point Version Field", json_object_new_uint64 (le16_to_cpu(dssd_version))); | |||
| 359 | memcpy(&dssd_version, log->dssd_minor_version, sizeof(dssd_version)); | |||
| 360 | json_object_add_value_uint(root, "Minor Version Field",json_object_object_add(root, "Minor Version Field", json_object_new_uint64 (le16_to_cpu(dssd_version))) | |||
| 361 | le16_to_cpu(dssd_version))json_object_object_add(root, "Minor Version Field", json_object_new_uint64 (le16_to_cpu(dssd_version))); | |||
| 362 | json_object_add_value_uint(root, "Major Version Field",json_object_object_add(root, "Major Version Field", json_object_new_uint64 (log->dssd_major_version)) | |||
| 363 | log->dssd_major_version)json_object_object_add(root, "Major Version Field", json_object_new_uint64 (log->dssd_major_version)); | |||
| 364 | json_object_add_value_uint(root, "NVMe Base Errata Version",json_object_object_add(root, "NVMe Base Errata Version", json_object_new_uint64 (log->nvme_base_errata_version)) | |||
| 365 | log->nvme_base_errata_version)json_object_object_add(root, "NVMe Base Errata Version", json_object_new_uint64 (log->nvme_base_errata_version)); | |||
| 366 | json_object_add_value_uint(root, "PCIe Link Retraining Count",json_object_object_add(root, "PCIe Link Retraining Count", json_object_new_uint64 (le64_to_cpu(log->pcie_link_retaining_count))) | |||
| 367 | le64_to_cpu(log->pcie_link_retaining_count))json_object_object_add(root, "PCIe Link Retraining Count", json_object_new_uint64 (le64_to_cpu(log->pcie_link_retaining_count))); | |||
| 368 | json_object_add_value_uint(root, "Power State Change Count",json_object_object_add(root, "Power State Change Count", json_object_new_uint64 (le64_to_cpu(log->power_state_change_count))) | |||
| 369 | le64_to_cpu(log->power_state_change_count))json_object_object_add(root, "Power State Change Count", json_object_new_uint64 (le64_to_cpu(log->power_state_change_count))); | |||
| 370 | } | |||
| 371 | json_print_object(root, NULL)printf("%s", json_object_to_json_string_ext(root, (1 << 1) | (1 << 4))); | |||
| 372 | printf("\n"); | |||
| 373 | json_free_object(root)json_object_put(root); | |||
| 374 | } | |||
| 375 | ||||
| 376 | static void json_smart_extended_log_v2(struct ocp_smart_extended_log *log) | |||
| 377 | { | |||
| 378 | struct json_object *root; | |||
| 379 | struct json_object *pmuw; | |||
| 380 | struct json_object *pmur; | |||
| 381 | uint16_t smart_log_ver = 0; | |||
| 382 | uint16_t dssd_version = 0; | |||
| 383 | char guid[40]; | |||
| 384 | char ascii_arr[65]; | |||
| 385 | ||||
| 386 | root = json_create_object()json_object_new_object(); | |||
| 387 | pmuw = json_create_object()json_object_new_object(); | |||
| 388 | pmur = json_create_object()json_object_new_object(); | |||
| 389 | ||||
| 390 | json_object_add_value_uint64(pmuw, "hi",json_object_object_add(pmuw, "hi", json_object_new_uint64(le64_to_cpu (*(uint64_t *)&log->physical_media_units_written[8]))) | |||
| 391 | le64_to_cpu(*(uint64_t *)&log->physical_media_units_written[8]))json_object_object_add(pmuw, "hi", json_object_new_uint64(le64_to_cpu (*(uint64_t *)&log->physical_media_units_written[8]))); | |||
| 392 | json_object_add_value_uint64(pmuw, "lo",json_object_object_add(pmuw, "lo", json_object_new_uint64(le64_to_cpu (*(uint64_t *)&log->physical_media_units_written))) | |||
| 393 | le64_to_cpu(*(uint64_t *)&log->physical_media_units_written))json_object_object_add(pmuw, "lo", json_object_new_uint64(le64_to_cpu (*(uint64_t *)&log->physical_media_units_written))); | |||
| 394 | json_object_add_value_object(root, "physical_media_units_written", pmuw)json_object_object_add(root, "physical_media_units_written", pmuw ); | |||
| 395 | json_object_add_value_uint64(pmur, "hi",json_object_object_add(pmur, "hi", json_object_new_uint64(le64_to_cpu (*(uint64_t *)&log->physical_media_units_read[8]))) | |||
| 396 | le64_to_cpu(*(uint64_t *)&log->physical_media_units_read[8]))json_object_object_add(pmur, "hi", json_object_new_uint64(le64_to_cpu (*(uint64_t *)&log->physical_media_units_read[8]))); | |||
| 397 | json_object_add_value_uint64(pmur, "lo",json_object_object_add(pmur, "lo", json_object_new_uint64(le64_to_cpu (*(uint64_t *)&log->physical_media_units_read))) | |||
| 398 | le64_to_cpu(*(uint64_t *)&log->physical_media_units_read))json_object_object_add(pmur, "lo", json_object_new_uint64(le64_to_cpu (*(uint64_t *)&log->physical_media_units_read))); | |||
| 399 | json_object_add_value_object(root, "physical_media_units_read", pmur)json_object_object_add(root, "physical_media_units_read", pmur ); | |||
| 400 | json_object_add_value_uint64(root, "bad_user_nand_blocks_raw",json_object_object_add(root, "bad_user_nand_blocks_raw", json_object_new_uint64 (int48_to_long(log->bad_user_nand_blocks_raw))) | |||
| 401 | int48_to_long(log->bad_user_nand_blocks_raw))json_object_object_add(root, "bad_user_nand_blocks_raw", json_object_new_uint64 (int48_to_long(log->bad_user_nand_blocks_raw))); | |||
| 402 | json_object_add_value_uint(root, "bad_user_nand_blocks_normalized",json_object_object_add(root, "bad_user_nand_blocks_normalized" , json_object_new_uint64(le16_to_cpu(log->bad_user_nand_blocks_normalized ))) | |||
| 403 | le16_to_cpu(log->bad_user_nand_blocks_normalized))json_object_object_add(root, "bad_user_nand_blocks_normalized" , json_object_new_uint64(le16_to_cpu(log->bad_user_nand_blocks_normalized ))); | |||
| 404 | json_object_add_value_uint64(root, "bad_system_nand_blocks_raw",json_object_object_add(root, "bad_system_nand_blocks_raw", json_object_new_uint64 (int48_to_long(log->bad_system_nand_blocks_raw))) | |||
| 405 | int48_to_long(log->bad_system_nand_blocks_raw))json_object_object_add(root, "bad_system_nand_blocks_raw", json_object_new_uint64 (int48_to_long(log->bad_system_nand_blocks_raw))); | |||
| 406 | json_object_add_value_uint(root, "bad_system_nand_blocks_normalized",json_object_object_add(root, "bad_system_nand_blocks_normalized" , json_object_new_uint64(le16_to_cpu(log->bad_system_nand_blocks_normalized ))) | |||
| 407 | le16_to_cpu(log->bad_system_nand_blocks_normalized))json_object_object_add(root, "bad_system_nand_blocks_normalized" , json_object_new_uint64(le16_to_cpu(log->bad_system_nand_blocks_normalized ))); | |||
| 408 | json_object_add_value_uint64(root, "xor_recovery_count",json_object_object_add(root, "xor_recovery_count", json_object_new_uint64 (le64_to_cpu(log->xor_recovery_count))) | |||
| 409 | le64_to_cpu(log->xor_recovery_count))json_object_object_add(root, "xor_recovery_count", json_object_new_uint64 (le64_to_cpu(log->xor_recovery_count))); | |||
| 410 | json_object_add_value_uint64(root, "uncorrectable_read_errors",json_object_object_add(root, "uncorrectable_read_errors", json_object_new_uint64 (le64_to_cpu(log->uncorrectable_read_err_count))) | |||
| 411 | le64_to_cpu(log->uncorrectable_read_err_count))json_object_object_add(root, "uncorrectable_read_errors", json_object_new_uint64 (le64_to_cpu(log->uncorrectable_read_err_count))); | |||
| 412 | json_object_add_value_uint64(root, "soft_ecc_error_count",json_object_object_add(root, "soft_ecc_error_count", json_object_new_uint64 (le64_to_cpu(log->soft_ecc_err_count))) | |||
| 413 | le64_to_cpu(log->soft_ecc_err_count))json_object_object_add(root, "soft_ecc_error_count", json_object_new_uint64 (le64_to_cpu(log->soft_ecc_err_count))); | |||
| 414 | json_object_add_value_uint(root, "end_to_end_detected_errors",json_object_object_add(root, "end_to_end_detected_errors", json_object_new_uint64 (le32_to_cpu(log->end_to_end_detected_err))) | |||
| 415 | le32_to_cpu(log->end_to_end_detected_err))json_object_object_add(root, "end_to_end_detected_errors", json_object_new_uint64 (le32_to_cpu(log->end_to_end_detected_err))); | |||
| 416 | json_object_add_value_uint(root, "end_to_end_corrected_errors",json_object_object_add(root, "end_to_end_corrected_errors", json_object_new_uint64 (le32_to_cpu(log->end_to_end_corrected_err))) | |||
| 417 | le32_to_cpu(log->end_to_end_corrected_err))json_object_object_add(root, "end_to_end_corrected_errors", json_object_new_uint64 (le32_to_cpu(log->end_to_end_corrected_err))); | |||
| 418 | json_object_add_value_uint(root, "system_data_percent_used",json_object_object_add(root, "system_data_percent_used", json_object_new_uint64 (log->system_data_used_percent)) | |||
| 419 | log->system_data_used_percent)json_object_object_add(root, "system_data_percent_used", json_object_new_uint64 (log->system_data_used_percent)); | |||
| 420 | json_object_add_value_uint64(root, "refresh_count",json_object_object_add(root, "refresh_count", json_object_new_uint64 (int56_to_long(log->refresh_counts))) | |||
| 421 | int56_to_long(log->refresh_counts))json_object_object_add(root, "refresh_count", json_object_new_uint64 (int56_to_long(log->refresh_counts))); | |||
| 422 | json_object_add_value_uint(root, "max_user_data_erase_count",json_object_object_add(root, "max_user_data_erase_count", json_object_new_uint64 (le32_to_cpu(log->user_data_erase_count_max))) | |||
| 423 | le32_to_cpu(log->user_data_erase_count_max))json_object_object_add(root, "max_user_data_erase_count", json_object_new_uint64 (le32_to_cpu(log->user_data_erase_count_max))); | |||
| 424 | json_object_add_value_uint(root, "min_user_data_erase_count",json_object_object_add(root, "min_user_data_erase_count", json_object_new_uint64 (le32_to_cpu(log->user_data_erase_count_min))) | |||
| 425 | le32_to_cpu(log->user_data_erase_count_min))json_object_object_add(root, "min_user_data_erase_count", json_object_new_uint64 (le32_to_cpu(log->user_data_erase_count_min))); | |||
| 426 | json_object_add_value_uint(root, "thermal_throttling_events",json_object_object_add(root, "thermal_throttling_events", json_object_new_uint64 (log->thermal_throttling_event_count)) | |||
| 427 | log->thermal_throttling_event_count)json_object_object_add(root, "thermal_throttling_events", json_object_new_uint64 (log->thermal_throttling_event_count)); | |||
| 428 | json_object_add_value_uint(root, "current_throttling_status",json_object_object_add(root, "current_throttling_status", json_object_new_uint64 (log->thermal_throttling_current_status)) | |||
| 429 | log->thermal_throttling_current_status)json_object_object_add(root, "current_throttling_status", json_object_new_uint64 (log->thermal_throttling_current_status)); | |||
| 430 | json_object_add_value_uint64(root, "pcie_correctable_errors",json_object_object_add(root, "pcie_correctable_errors", json_object_new_uint64 (le64_to_cpu(log->pcie_correctable_err_count))) | |||
| 431 | le64_to_cpu(log->pcie_correctable_err_count))json_object_object_add(root, "pcie_correctable_errors", json_object_new_uint64 (le64_to_cpu(log->pcie_correctable_err_count))); | |||
| 432 | json_object_add_value_uint(root, "incomplete_shutdowns",json_object_object_add(root, "incomplete_shutdowns", json_object_new_uint64 (le32_to_cpu(log->incomplete_shoutdowns))) | |||
| 433 | le32_to_cpu(log->incomplete_shoutdowns))json_object_object_add(root, "incomplete_shutdowns", json_object_new_uint64 (le32_to_cpu(log->incomplete_shoutdowns))); | |||
| 434 | json_object_add_value_uint(root, "percent_free_blocks",json_object_object_add(root, "percent_free_blocks", json_object_new_uint64 (log->percent_free_blocks)) | |||
| 435 | log->percent_free_blocks)json_object_object_add(root, "percent_free_blocks", json_object_new_uint64 (log->percent_free_blocks)); | |||
| 436 | json_object_add_value_uint(root, "capacitor_health",json_object_object_add(root, "capacitor_health", json_object_new_uint64 (le16_to_cpu(log->capacitor_health))) | |||
| 437 | le16_to_cpu(log->capacitor_health))json_object_object_add(root, "capacitor_health", json_object_new_uint64 (le16_to_cpu(log->capacitor_health))); | |||
| 438 | json_object_add_value_uint64(root, "unaligned_io",json_object_object_add(root, "unaligned_io", json_object_new_uint64 (le64_to_cpu(log->unaligned_io))) | |||
| 439 | le64_to_cpu(log->unaligned_io))json_object_object_add(root, "unaligned_io", json_object_new_uint64 (le64_to_cpu(log->unaligned_io))); | |||
| 440 | json_object_add_value_uint64(root, "security_version_number",json_object_object_add(root, "security_version_number", json_object_new_uint64 (le64_to_cpu(log->security_version))) | |||
| 441 | le64_to_cpu(log->security_version))json_object_object_add(root, "security_version_number", json_object_new_uint64 (le64_to_cpu(log->security_version))); | |||
| 442 | json_object_add_value_uint64(root, "nuse_namespace_utilization",json_object_object_add(root, "nuse_namespace_utilization", json_object_new_uint64 (le64_to_cpu(log->total_nuse))) | |||
| 443 | le64_to_cpu(log->total_nuse))json_object_object_add(root, "nuse_namespace_utilization", json_object_new_uint64 (le64_to_cpu(log->total_nuse))); | |||
| 444 | json_object_add_value_uint128(root, "plp_start_count",json_object_object_add(root, "plp_start_count", util_json_object_new_uint128 (le128_to_cpu(log->plp_start_count))) | |||
| 445 | le128_to_cpu(log->plp_start_count))json_object_object_add(root, "plp_start_count", util_json_object_new_uint128 (le128_to_cpu(log->plp_start_count))); | |||
| 446 | json_object_add_value_uint128(root, "endurance_estimate",json_object_object_add(root, "endurance_estimate", util_json_object_new_uint128 (le128_to_cpu(log->endurance_estimate))) | |||
| 447 | le128_to_cpu(log->endurance_estimate))json_object_object_add(root, "endurance_estimate", util_json_object_new_uint128 (le128_to_cpu(log->endurance_estimate))); | |||
| 448 | smart_log_ver = le16_to_cpu(log->log_page_version); | |||
| 449 | ||||
| 450 | json_object_add_value_uint(root, "log_page_version", smart_log_ver)json_object_object_add(root, "log_page_version", json_object_new_uint64 (smart_log_ver)); | |||
| 451 | ||||
| 452 | memset((void *)guid, 0, 40); | |||
| 453 | snprintf((char *)guid, sizeof(guid), "0x%016"PRIx64"l" "x""%016"PRIx64"l" "x""", | |||
| 454 | le64_to_cpu(*(uint64_t *)&log->log_page_guid[8]), | |||
| 455 | le64_to_cpu(*(uint64_t *)&log->log_page_guid)); | |||
| 456 | json_object_add_value_string(root, "log_page_guid", guid); | |||
| 457 | ||||
| 458 | switch (smart_log_ver) { | |||
| 459 | case 0 ... 1: | |||
| 460 | break; | |||
| 461 | default: | |||
| 462 | case 6: | |||
| 463 | json_object_add_value_uint(root, "form_factor",json_object_object_add(root, "form_factor", json_object_new_uint64 (log->form_factor)) | |||
| 464 | log->form_factor)json_object_object_add(root, "form_factor", json_object_new_uint64 (log->form_factor)); | |||
| 465 | json_object_add_value_uint64(root, "die_in_use_bad_nand_block_raw",json_object_object_add(root, "die_in_use_bad_nand_block_raw", json_object_new_uint64(int48_to_long(log->die_in_use_bad_nand_block_raw ))) | |||
| 466 | int48_to_long(log->die_in_use_bad_nand_block_raw))json_object_object_add(root, "die_in_use_bad_nand_block_raw", json_object_new_uint64(int48_to_long(log->die_in_use_bad_nand_block_raw ))); | |||
| 467 | json_object_add_value_uint(root, "die_in_use_bad_nand_block_normalized",json_object_object_add(root, "die_in_use_bad_nand_block_normalized" , json_object_new_uint64(le16_to_cpu(log->die_in_use_bad_nand_block_normalized ))) | |||
| 468 | le16_to_cpu(log->die_in_use_bad_nand_block_normalized))json_object_object_add(root, "die_in_use_bad_nand_block_normalized" , json_object_new_uint64(le16_to_cpu(log->die_in_use_bad_nand_block_normalized ))); | |||
| 469 | fallthrough__attribute__((fallthrough)); | |||
| 470 | case 5: | |||
| 471 | json_object_add_value_uint(root, "nvme_over_pcie_errata_version",json_object_object_add(root, "nvme_over_pcie_errata_version", json_object_new_uint64(log->nvme_over_pcie_errate_version )) | |||
| 472 | log->nvme_over_pcie_errate_version)json_object_object_add(root, "nvme_over_pcie_errata_version", json_object_new_uint64(log->nvme_over_pcie_errate_version )); | |||
| 473 | json_object_add_value_uint(root, "nvme_mi_errata_version",json_object_object_add(root, "nvme_mi_errata_version", json_object_new_uint64 (log->nvme_mi_errata_version)) | |||
| 474 | log->nvme_mi_errata_version)json_object_object_add(root, "nvme_mi_errata_version", json_object_new_uint64 (log->nvme_mi_errata_version)); | |||
| 475 | json_object_add_value_uint(root, "total_media_dies",json_object_object_add(root, "total_media_dies", json_object_new_uint64 (le16_to_cpu(log->total_media_dies))) | |||
| 476 | le16_to_cpu(log->total_media_dies))json_object_object_add(root, "total_media_dies", json_object_new_uint64 (le16_to_cpu(log->total_media_dies))); | |||
| 477 | json_object_add_value_uint(root, "total_die_failure_tolerance",json_object_object_add(root, "total_die_failure_tolerance", json_object_new_uint64 (le16_to_cpu(log->total_die_failure_tolerance))) | |||
| 478 | le16_to_cpu(log->total_die_failure_tolerance))json_object_object_add(root, "total_die_failure_tolerance", json_object_new_uint64 (le16_to_cpu(log->total_die_failure_tolerance))); | |||
| 479 | json_object_add_value_uint(root, "media_dies_offline",json_object_object_add(root, "media_dies_offline", json_object_new_uint64 (le16_to_cpu(log->media_dies_offline))) | |||
| 480 | le16_to_cpu(log->media_dies_offline))json_object_object_add(root, "media_dies_offline", json_object_new_uint64 (le16_to_cpu(log->media_dies_offline))); | |||
| 481 | json_object_add_value_uint(root, "max_temperature_recorded",json_object_object_add(root, "max_temperature_recorded", json_object_new_uint64 (log->max_temperature_recorded)) | |||
| 482 | log->max_temperature_recorded)json_object_object_add(root, "max_temperature_recorded", json_object_new_uint64 (log->max_temperature_recorded)); | |||
| 483 | json_object_add_value_uint64(root, "nand_avg_erase_count",json_object_object_add(root, "nand_avg_erase_count", json_object_new_uint64 (le64_to_cpu(log->nand_avg_erase_count))) | |||
| 484 | le64_to_cpu(log->nand_avg_erase_count))json_object_object_add(root, "nand_avg_erase_count", json_object_new_uint64 (le64_to_cpu(log->nand_avg_erase_count))); | |||
| 485 | json_object_add_value_uint(root, "command_timeouts",json_object_object_add(root, "command_timeouts", json_object_new_uint64 (le32_to_cpu(log->command_timeouts))) | |||
| 486 | le32_to_cpu(log->command_timeouts))json_object_object_add(root, "command_timeouts", json_object_new_uint64 (le32_to_cpu(log->command_timeouts))); | |||
| 487 | json_object_add_value_uint(root, "sys_area_program_fail_count_raw",json_object_object_add(root, "sys_area_program_fail_count_raw" , json_object_new_uint64(le32_to_cpu(log->sys_area_program_fail_count_raw ))) | |||
| 488 | le32_to_cpu(log->sys_area_program_fail_count_raw))json_object_object_add(root, "sys_area_program_fail_count_raw" , json_object_new_uint64(le32_to_cpu(log->sys_area_program_fail_count_raw ))); | |||
| 489 | json_object_add_value_uint(root, "sys_area_program_fail_count_noralized",json_object_object_add(root, "sys_area_program_fail_count_noralized" , json_object_new_uint64(log->sys_area_program_fail_count_normalized )) | |||
| 490 | log->sys_area_program_fail_count_normalized)json_object_object_add(root, "sys_area_program_fail_count_noralized" , json_object_new_uint64(log->sys_area_program_fail_count_normalized )); | |||
| 491 | json_object_add_value_uint(root, "sys_area_uncorrectable_read_count_raw",json_object_object_add(root, "sys_area_uncorrectable_read_count_raw" , json_object_new_uint64(le32_to_cpu(log->sys_area_uncorr_read_count_raw ))) | |||
| 492 | le32_to_cpu(log->sys_area_uncorr_read_count_raw))json_object_object_add(root, "sys_area_uncorrectable_read_count_raw" , json_object_new_uint64(le32_to_cpu(log->sys_area_uncorr_read_count_raw ))); | |||
| 493 | json_object_add_value_uint(root, "sys_area_uncorrectable_read_count_noralized",json_object_object_add(root, "sys_area_uncorrectable_read_count_noralized" , json_object_new_uint64(log->sys_area_uncorr_read_count_normalized )) | |||
| 494 | log->sys_area_uncorr_read_count_normalized)json_object_object_add(root, "sys_area_uncorrectable_read_count_noralized" , json_object_new_uint64(log->sys_area_uncorr_read_count_normalized )); | |||
| 495 | json_object_add_value_uint(root, "sys_area_erase_fail_count_raw",json_object_object_add(root, "sys_area_erase_fail_count_raw", json_object_new_uint64(le32_to_cpu(log->sys_area_erase_fail_count_raw ))) | |||
| 496 | le32_to_cpu(log->sys_area_erase_fail_count_raw))json_object_object_add(root, "sys_area_erase_fail_count_raw", json_object_new_uint64(le32_to_cpu(log->sys_area_erase_fail_count_raw ))); | |||
| 497 | json_object_add_value_uint(root, "sys_area_erase_fail_count_noralized",json_object_object_add(root, "sys_area_erase_fail_count_noralized" , json_object_new_uint64(log->sys_area_erase_fail_count_normalized )) | |||
| 498 | log->sys_area_erase_fail_count_normalized)json_object_object_add(root, "sys_area_erase_fail_count_noralized" , json_object_new_uint64(log->sys_area_erase_fail_count_normalized )); | |||
| 499 | json_object_add_value_uint(root, "max_peak_power_capability",json_object_object_add(root, "max_peak_power_capability", json_object_new_uint64 (le16_to_cpu(log->max_peak_power_capability))) | |||
| 500 | le16_to_cpu(log->max_peak_power_capability))json_object_object_add(root, "max_peak_power_capability", json_object_new_uint64 (le16_to_cpu(log->max_peak_power_capability))); | |||
| 501 | json_object_add_value_uint(root, "current_max_avg_power",json_object_object_add(root, "current_max_avg_power", json_object_new_uint64 (le16_to_cpu(log->current_max_avg_power))) | |||
| 502 | le16_to_cpu(log->current_max_avg_power))json_object_object_add(root, "current_max_avg_power", json_object_new_uint64 (le16_to_cpu(log->current_max_avg_power))); | |||
| 503 | json_object_add_value_uint64(root, "lifetime_power_consumed",json_object_object_add(root, "lifetime_power_consumed", json_object_new_uint64 (int48_to_long(log->lifetime_power_consumed))) | |||
| 504 | int48_to_long(log->lifetime_power_consumed))json_object_object_add(root, "lifetime_power_consumed", json_object_new_uint64 (int48_to_long(log->lifetime_power_consumed))); | |||
| 505 | snprintf(ascii_arr, sizeof(ascii_arr), "%.*s", | |||
| 506 | (int)sizeof(log->dssd_firmware_revision), | |||
| 507 | (char *)log->dssd_firmware_revision); | |||
| 508 | json_object_add_value_string(root, "dssd_firmware_revision", ascii_arr); | |||
| 509 | json_object_add_value_string(root, "dssd_firmware_build_uuid", | |||
| 510 | shr_uuid_to_string(log->dssd_firmware_build_uuid)); | |||
| 511 | snprintf(ascii_arr, sizeof(ascii_arr), "%.*s", | |||
| 512 | (int)sizeof(log->dssd_firmware_build_label), | |||
| 513 | (char *)log->dssd_firmware_build_label); | |||
| 514 | json_object_add_value_string(root, "dssd_firmware_build_label", ascii_arr); | |||
| 515 | fallthrough__attribute__((fallthrough)); | |||
| 516 | case 4: | |||
| 517 | json_object_add_value_uint(root, "nvme_command_set_errata_version",json_object_object_add(root, "nvme_command_set_errata_version" , json_object_new_uint64(log->nvme_cmdset_errata_version)) | |||
| 518 | log->nvme_cmdset_errata_version)json_object_object_add(root, "nvme_command_set_errata_version" , json_object_new_uint64(log->nvme_cmdset_errata_version)); | |||
| 519 | json_object_add_value_uint(root, "lowest_permitted_firmware_revision",json_object_object_add(root, "lowest_permitted_firmware_revision" , json_object_new_uint64(le64_to_cpu(log->lowest_permitted_fw_rev ))) | |||
| 520 | le64_to_cpu(log->lowest_permitted_fw_rev))json_object_object_add(root, "lowest_permitted_firmware_revision" , json_object_new_uint64(le64_to_cpu(log->lowest_permitted_fw_rev ))); | |||
| 521 | fallthrough__attribute__((fallthrough)); | |||
| 522 | case 2 ... 3: | |||
| 523 | json_object_add_value_uint(root, "errata_version_field",json_object_object_add(root, "errata_version_field", json_object_new_uint64 (log->dssd_errata_version)) | |||
| 524 | log->dssd_errata_version)json_object_object_add(root, "errata_version_field", json_object_new_uint64 (log->dssd_errata_version)); | |||
| 525 | memcpy(&dssd_version, log->dssd_point_version, sizeof(dssd_version)); | |||
| 526 | json_object_add_value_uint(root, "point_version_field",json_object_object_add(root, "point_version_field", json_object_new_uint64 (le16_to_cpu(dssd_version))) | |||
| 527 | le16_to_cpu(dssd_version))json_object_object_add(root, "point_version_field", json_object_new_uint64 (le16_to_cpu(dssd_version))); | |||
| 528 | memcpy(&dssd_version, log->dssd_minor_version, sizeof(dssd_version)); | |||
| 529 | json_object_add_value_uint(root, "minor_version_field",json_object_object_add(root, "minor_version_field", json_object_new_uint64 (le16_to_cpu(dssd_version))) | |||
| 530 | le16_to_cpu(dssd_version))json_object_object_add(root, "minor_version_field", json_object_new_uint64 (le16_to_cpu(dssd_version))); | |||
| 531 | json_object_add_value_uint(root, "major_version_field",json_object_object_add(root, "major_version_field", json_object_new_uint64 (log->dssd_major_version)) | |||
| 532 | log->dssd_major_version)json_object_object_add(root, "major_version_field", json_object_new_uint64 (log->dssd_major_version)); | |||
| 533 | json_object_add_value_uint(root, "nvme_base_errata_version",json_object_object_add(root, "nvme_base_errata_version", json_object_new_uint64 (log->nvme_base_errata_version)) | |||
| 534 | log->nvme_base_errata_version)json_object_object_add(root, "nvme_base_errata_version", json_object_new_uint64 (log->nvme_base_errata_version)); | |||
| 535 | json_object_add_value_uint(root, "pcie_link_retraining_count",json_object_object_add(root, "pcie_link_retraining_count", json_object_new_uint64 (le64_to_cpu(log->pcie_link_retaining_count))) | |||
| 536 | le64_to_cpu(log->pcie_link_retaining_count))json_object_object_add(root, "pcie_link_retraining_count", json_object_new_uint64 (le64_to_cpu(log->pcie_link_retaining_count))); | |||
| 537 | json_object_add_value_uint(root, "power_state_change_count",json_object_object_add(root, "power_state_change_count", json_object_new_uint64 (le64_to_cpu(log->power_state_change_count))) | |||
| 538 | le64_to_cpu(log->power_state_change_count))json_object_object_add(root, "power_state_change_count", json_object_new_uint64 (le64_to_cpu(log->power_state_change_count))); | |||
| 539 | } | |||
| 540 | json_print_object(root, NULL)printf("%s", json_object_to_json_string_ext(root, (1 << 1) | (1 << 4))); | |||
| 541 | printf("\n"); | |||
| 542 | json_free_object(root)json_object_put(root); | |||
| 543 | } | |||
| 544 | ||||
| 545 | static void json_smart_extended_log(struct ocp_smart_extended_log *log, unsigned int version) | |||
| 546 | { | |||
| 547 | switch (version) { | |||
| 548 | default: | |||
| 549 | case 1: | |||
| 550 | json_smart_extended_log_v1(log); | |||
| 551 | break; | |||
| 552 | case 2: | |||
| 553 | json_smart_extended_log_v2(log); | |||
| 554 | } | |||
| 555 | } | |||
| 556 | static void json_telemetry_log(struct ocp_telemetry_parse_options *options) | |||
| 557 | { | |||
| 558 | print_ocp_telemetry_json(options); | |||
| 559 | } | |||
| 560 | ||||
| 561 | static void json_c3_log(struct libnvme_transport_handle *hdl, struct ssd_latency_monitor_log *log_data) | |||
| 562 | { | |||
| 563 | struct json_object *root; | |||
| 564 | char ts_buf[128]; | |||
| 565 | char buf[128]; | |||
| 566 | int i, j; | |||
| 567 | char *operation[3] = {"Trim", "Write", "Read"}; | |||
| 568 | __u16 log_page_version = le16_to_cpu(log_data->log_page_version); | |||
| 569 | ||||
| 570 | root = json_create_object()json_object_new_object(); | |||
| 571 | ||||
| 572 | json_object_add_value_uint(root, "Feature Status",json_object_object_add(root, "Feature Status", json_object_new_uint64 (log_data->feature_status)) | |||
| 573 | log_data->feature_status)json_object_object_add(root, "Feature Status", json_object_new_uint64 (log_data->feature_status)); | |||
| 574 | json_object_add_value_uint(root, "Active Bucket Timer",json_object_object_add(root, "Active Bucket Timer", json_object_new_uint64 (5 * le16_to_cpu(log_data->active_bucket_timer))) | |||
| 575 | C3_ACTIVE_BUCKET_TIMER_INCREMENT *json_object_object_add(root, "Active Bucket Timer", json_object_new_uint64 (5 * le16_to_cpu(log_data->active_bucket_timer))) | |||
| 576 | le16_to_cpu(log_data->active_bucket_timer))json_object_object_add(root, "Active Bucket Timer", json_object_new_uint64 (5 * le16_to_cpu(log_data->active_bucket_timer))); | |||
| 577 | json_object_add_value_uint(root, "Active Bucket Timer Threshold",json_object_object_add(root, "Active Bucket Timer Threshold", json_object_new_uint64(5 * le16_to_cpu(log_data->active_bucket_timer_threshold ))) | |||
| 578 | C3_ACTIVE_BUCKET_TIMER_INCREMENT *json_object_object_add(root, "Active Bucket Timer Threshold", json_object_new_uint64(5 * le16_to_cpu(log_data->active_bucket_timer_threshold ))) | |||
| 579 | le16_to_cpu(log_data->active_bucket_timer_threshold))json_object_object_add(root, "Active Bucket Timer Threshold", json_object_new_uint64(5 * le16_to_cpu(log_data->active_bucket_timer_threshold ))); | |||
| 580 | json_object_add_value_uint(root, "Active Threshold A",json_object_object_add(root, "Active Threshold A", json_object_new_uint64 (5 * le16_to_cpu(log_data->active_threshold_a + 1))) | |||
| 581 | C3_ACTIVE_THRESHOLD_INCREMENT *json_object_object_add(root, "Active Threshold A", json_object_new_uint64 (5 * le16_to_cpu(log_data->active_threshold_a + 1))) | |||
| 582 | le16_to_cpu(log_data->active_threshold_a + 1))json_object_object_add(root, "Active Threshold A", json_object_new_uint64 (5 * le16_to_cpu(log_data->active_threshold_a + 1))); | |||
| 583 | json_object_add_value_uint(root, "Active Threshold B",json_object_object_add(root, "Active Threshold B", json_object_new_uint64 (5 * le16_to_cpu(log_data->active_threshold_b + 1))) | |||
| 584 | C3_ACTIVE_THRESHOLD_INCREMENT *json_object_object_add(root, "Active Threshold B", json_object_new_uint64 (5 * le16_to_cpu(log_data->active_threshold_b + 1))) | |||
| 585 | le16_to_cpu(log_data->active_threshold_b + 1))json_object_object_add(root, "Active Threshold B", json_object_new_uint64 (5 * le16_to_cpu(log_data->active_threshold_b + 1))); | |||
| 586 | json_object_add_value_uint(root, "Active Threshold C",json_object_object_add(root, "Active Threshold C", json_object_new_uint64 (5 * le16_to_cpu(log_data->active_threshold_c + 1))) | |||
| 587 | C3_ACTIVE_THRESHOLD_INCREMENT *json_object_object_add(root, "Active Threshold C", json_object_new_uint64 (5 * le16_to_cpu(log_data->active_threshold_c + 1))) | |||
| 588 | le16_to_cpu(log_data->active_threshold_c + 1))json_object_object_add(root, "Active Threshold C", json_object_new_uint64 (5 * le16_to_cpu(log_data->active_threshold_c + 1))); | |||
| 589 | json_object_add_value_uint(root, "Active Threshold D",json_object_object_add(root, "Active Threshold D", json_object_new_uint64 (5 * le16_to_cpu(log_data->active_threshold_d + 1))) | |||
| 590 | C3_ACTIVE_THRESHOLD_INCREMENT *json_object_object_add(root, "Active Threshold D", json_object_new_uint64 (5 * le16_to_cpu(log_data->active_threshold_d + 1))) | |||
| 591 | le16_to_cpu(log_data->active_threshold_d + 1))json_object_object_add(root, "Active Threshold D", json_object_new_uint64 (5 * le16_to_cpu(log_data->active_threshold_d + 1))); | |||
| 592 | json_object_add_value_uint(root, "Active Latency Configuration",json_object_object_add(root, "Active Latency Configuration", json_object_new_uint64 (le16_to_cpu(log_data->active_latency_config))) | |||
| 593 | le16_to_cpu(log_data->active_latency_config))json_object_object_add(root, "Active Latency Configuration", json_object_new_uint64 (le16_to_cpu(log_data->active_latency_config))); | |||
| 594 | json_object_add_value_uint(root, "Active Latency Minimum Window",json_object_object_add(root, "Active Latency Minimum Window", json_object_new_uint64(100 * le16_to_cpu(log_data->active_latency_min_window ))) | |||
| 595 | C3_MINIMUM_WINDOW_INCREMENT *json_object_object_add(root, "Active Latency Minimum Window", json_object_new_uint64(100 * le16_to_cpu(log_data->active_latency_min_window ))) | |||
| 596 | le16_to_cpu(log_data->active_latency_min_window))json_object_object_add(root, "Active Latency Minimum Window", json_object_new_uint64(100 * le16_to_cpu(log_data->active_latency_min_window ))); | |||
| 597 | ||||
| 598 | for (i = 0; i < C3_BUCKET_NUM4; i++) { | |||
| 599 | struct json_object *bucket; | |||
| 600 | ||||
| 601 | bucket = json_create_object()json_object_new_object(); | |||
| 602 | snprintf(buf, sizeof(buf), "Active Bucket Counter: Bucket %d", | |||
| 603 | i); | |||
| 604 | for (j = 2; j >= 0; j--) { | |||
| 605 | json_object_add_value_uint(bucket, operation[j],json_object_object_add(bucket, operation[j], json_object_new_uint64 (le32_to_cpu(log_data->active_bucket_counter[i][j+1]))) | |||
| 606 | le32_to_cpu(log_data->active_bucket_counter[i][j+1]))json_object_object_add(bucket, operation[j], json_object_new_uint64 (le32_to_cpu(log_data->active_bucket_counter[i][j+1]))); | |||
| 607 | } | |||
| 608 | json_object_add_value_object(root, buf, bucket)json_object_object_add(root, buf, bucket); | |||
| 609 | } | |||
| 610 | ||||
| 611 | for (i = 0; i < C3_BUCKET_NUM4; i++) { | |||
| 612 | struct json_object *bucket; | |||
| 613 | ||||
| 614 | bucket = json_create_object()json_object_new_object(); | |||
| 615 | snprintf(buf, sizeof(buf), | |||
| 616 | "Active Latency Time Stamp: Bucket %d", i); | |||
| 617 | for (j = 2; j >= 0; j--) { | |||
| 618 | if (le64_to_cpu(log_data->active_latency_timestamp[3-i][j]) == -1) { | |||
| 619 | json_object_add_value_string(bucket, operation[j], "NA"); | |||
| 620 | } else { | |||
| 621 | shr_format_ts(le64_to_cpu(log_data->active_latency_timestamp[3-i][j]), | |||
| 622 | ts_buf); | |||
| 623 | json_object_add_value_string(bucket, operation[j], ts_buf); | |||
| 624 | } | |||
| 625 | } | |||
| 626 | json_object_add_value_object(root, buf, bucket)json_object_object_add(root, buf, bucket); | |||
| 627 | } | |||
| 628 | ||||
| 629 | for (i = 0; i < C3_BUCKET_NUM4; i++) { | |||
| 630 | struct json_object *bucket; | |||
| 631 | ||||
| 632 | bucket = json_create_object()json_object_new_object(); | |||
| 633 | snprintf(buf, sizeof(buf), "Active Measured Latency: Bucket %d", | |||
| 634 | i); | |||
| 635 | for (j = 2; j >= 0; j--) { | |||
| 636 | json_object_add_value_uint(bucket, operation[j],json_object_object_add(bucket, operation[j], json_object_new_uint64 (le16_to_cpu(log_data->active_measured_latency[3-i][j]))) | |||
| 637 | le16_to_cpu(log_data->active_measured_latency[3-i][j]))json_object_object_add(bucket, operation[j], json_object_new_uint64 (le16_to_cpu(log_data->active_measured_latency[3-i][j]))); | |||
| 638 | } | |||
| 639 | json_object_add_value_object(root, buf, bucket)json_object_object_add(root, buf, bucket); | |||
| 640 | } | |||
| 641 | ||||
| 642 | json_object_add_value_uint(root, "Active Latency Stamp Units",json_object_object_add(root, "Active Latency Stamp Units", json_object_new_uint64 (le16_to_cpu(log_data->active_latency_stamp_units))) | |||
| 643 | le16_to_cpu(log_data->active_latency_stamp_units))json_object_object_add(root, "Active Latency Stamp Units", json_object_new_uint64 (le16_to_cpu(log_data->active_latency_stamp_units))); | |||
| 644 | ||||
| 645 | for (i = 0; i < C3_BUCKET_NUM4; i++) { | |||
| 646 | struct json_object *bucket; | |||
| 647 | ||||
| 648 | bucket = json_create_object()json_object_new_object(); | |||
| 649 | snprintf(buf, sizeof(buf), "Static Bucket Counter: Bucket %d", | |||
| 650 | i); | |||
| 651 | for (j = 2; j >= 0; j--) { | |||
| 652 | json_object_add_value_uint(bucket, operation[j],json_object_object_add(bucket, operation[j], json_object_new_uint64 (le32_to_cpu(log_data->static_bucket_counter[i][j+1]))) | |||
| 653 | le32_to_cpu(log_data->static_bucket_counter[i][j+1]))json_object_object_add(bucket, operation[j], json_object_new_uint64 (le32_to_cpu(log_data->static_bucket_counter[i][j+1]))); | |||
| 654 | } | |||
| 655 | json_object_add_value_object(root, buf, bucket)json_object_object_add(root, buf, bucket); | |||
| 656 | } | |||
| 657 | ||||
| 658 | for (i = 0; i < C3_BUCKET_NUM4; i++) { | |||
| 659 | struct json_object *bucket; | |||
| 660 | ||||
| 661 | bucket = json_create_object()json_object_new_object(); | |||
| 662 | snprintf(buf, sizeof(buf), | |||
| 663 | "Static Latency Time Stamp: Bucket %d", i); | |||
| 664 | for (j = 2; j >= 0; j--) { | |||
| 665 | if (le64_to_cpu(log_data->static_latency_timestamp[3-i][j]) == -1) { | |||
| 666 | json_object_add_value_string(bucket, operation[j], "NA"); | |||
| 667 | } else { | |||
| 668 | shr_format_ts(le64_to_cpu(log_data->static_latency_timestamp[3-i][j]), | |||
| 669 | ts_buf); | |||
| 670 | json_object_add_value_string(bucket, operation[j], ts_buf); | |||
| 671 | } | |||
| 672 | } | |||
| 673 | json_object_add_value_object(root, buf, bucket)json_object_object_add(root, buf, bucket); | |||
| 674 | } | |||
| 675 | ||||
| 676 | for (i = 0; i < C3_BUCKET_NUM4; i++) { | |||
| 677 | struct json_object *bucket; | |||
| 678 | ||||
| 679 | bucket = json_create_object()json_object_new_object(); | |||
| 680 | snprintf(buf, sizeof(buf), "Static Measured Latency: Bucket %d", | |||
| 681 | i); | |||
| 682 | for (j = 2; j >= 0; j--) { | |||
| 683 | json_object_add_value_uint(bucket, operation[j],json_object_object_add(bucket, operation[j], json_object_new_uint64 (le16_to_cpu(log_data->static_measured_latency[3-i][j]))) | |||
| 684 | le16_to_cpu(log_data->static_measured_latency[3-i][j]))json_object_object_add(bucket, operation[j], json_object_new_uint64 (le16_to_cpu(log_data->static_measured_latency[3-i][j]))); | |||
| 685 | } | |||
| 686 | json_object_add_value_object(root, buf, bucket)json_object_object_add(root, buf, bucket); | |||
| 687 | } | |||
| 688 | ||||
| 689 | json_object_add_value_uint(root, "Static Latency Stamp Units",json_object_object_add(root, "Static Latency Stamp Units", json_object_new_uint64 (le16_to_cpu(log_data->static_latency_stamp_units))) | |||
| 690 | le16_to_cpu(log_data->static_latency_stamp_units))json_object_object_add(root, "Static Latency Stamp Units", json_object_new_uint64 (le16_to_cpu(log_data->static_latency_stamp_units))); | |||
| 691 | ||||
| 692 | if (log_page_version >= 0x4) { | |||
| 693 | for (i = ARRAY_SIZE(log_data->latency_monitor_debug_log_size)(sizeof(log_data->latency_monitor_debug_log_size) / sizeof ((log_data->latency_monitor_debug_log_size)[0]) + 0) - 1; | |||
| 694 | i > 0 && (log_data->latency_monitor_debug_log_size[i] == 0); i--) | |||
| 695 | ; | |||
| 696 | shr_strscpy(buf, "0x", sizeof(buf)); | |||
| 697 | shr_bin_to_hex(buf + 2, sizeof(buf) - 2, | |||
| 698 | log_data->latency_monitor_debug_log_size, i + 1, | |||
| 699 | SHR_HEX_REVERSE(1 << 1)); | |||
| 700 | json_object_add_value_string(root, "Debug Telemetry Log Size", buf); | |||
| 701 | } | |||
| 702 | ||||
| 703 | json_object_add_value_uint(root, "Debug Log Trigger Enable",json_object_object_add(root, "Debug Log Trigger Enable", json_object_new_uint64 (le16_to_cpu(log_data->debug_log_trigger_enable))) | |||
| 704 | le16_to_cpu(log_data->debug_log_trigger_enable))json_object_object_add(root, "Debug Log Trigger Enable", json_object_new_uint64 (le16_to_cpu(log_data->debug_log_trigger_enable))); | |||
| 705 | json_object_add_value_uint(root, "Debug Log Measured Latency",json_object_object_add(root, "Debug Log Measured Latency", json_object_new_uint64 (le16_to_cpu(log_data->debug_log_measured_latency))) | |||
| 706 | le16_to_cpu(log_data->debug_log_measured_latency))json_object_object_add(root, "Debug Log Measured Latency", json_object_new_uint64 (le16_to_cpu(log_data->debug_log_measured_latency))); | |||
| 707 | if (le64_to_cpu(log_data->debug_log_latency_stamp) == -1) { | |||
| 708 | json_object_add_value_string(root, "Debug Log Latency Time Stamp", "NA"); | |||
| 709 | } else { | |||
| 710 | shr_format_ts(le64_to_cpu(log_data->debug_log_latency_stamp), ts_buf); | |||
| 711 | json_object_add_value_string(root, "Debug Log Latency Time Stamp", ts_buf); | |||
| 712 | } | |||
| 713 | json_object_add_value_uint(root, "Debug Log Pointer",json_object_object_add(root, "Debug Log Pointer", json_object_new_uint64 (le16_to_cpu(log_data->debug_log_ptr))) | |||
| 714 | le16_to_cpu(log_data->debug_log_ptr))json_object_object_add(root, "Debug Log Pointer", json_object_new_uint64 (le16_to_cpu(log_data->debug_log_ptr))); | |||
| 715 | json_object_add_value_uint(root, "Debug Counter Trigger Source",json_object_object_add(root, "Debug Counter Trigger Source", json_object_new_uint64 (le16_to_cpu(log_data->debug_log_counter_trigger))) | |||
| 716 | le16_to_cpu(log_data->debug_log_counter_trigger))json_object_object_add(root, "Debug Counter Trigger Source", json_object_new_uint64 (le16_to_cpu(log_data->debug_log_counter_trigger))); | |||
| 717 | json_object_add_value_uint(root, "Debug Log Stamp Units",json_object_object_add(root, "Debug Log Stamp Units", json_object_new_uint64 (le16_to_cpu(log_data->debug_log_stamp_units))) | |||
| 718 | le16_to_cpu(log_data->debug_log_stamp_units))json_object_object_add(root, "Debug Log Stamp Units", json_object_new_uint64 (le16_to_cpu(log_data->debug_log_stamp_units))); | |||
| 719 | json_object_add_value_uint(root, "Log Page Version", log_page_version)json_object_object_add(root, "Log Page Version", json_object_new_uint64 (log_page_version)); | |||
| 720 | ||||
| 721 | char guid[(GUID_LEN16 * 2) + 1]; | |||
| 722 | ||||
| 723 | shr_bin_to_hex(guid, sizeof(guid), log_data->log_page_guid, GUID_LEN16, | |||
| 724 | SHR_HEX_UPPER(1 << 0) | SHR_HEX_REVERSE(1 << 1)); | |||
| 725 | ||||
| 726 | json_object_add_value_string(root, "Log Page GUID", guid); | |||
| 727 | ||||
| 728 | json_print_object(root, NULL)printf("%s", json_object_to_json_string_ext(root, (1 << 1) | (1 << 4))); | |||
| 729 | printf("\n"); | |||
| 730 | ||||
| 731 | json_free_object(root)json_object_put(root); | |||
| 732 | } | |||
| 733 | ||||
| 734 | static void json_c5_log(struct libnvme_transport_handle *hdl, struct unsupported_requirement_log *log_data) | |||
| 735 | { | |||
| 736 | int j; | |||
| 737 | struct json_object *root; | |||
| 738 | char unsup_req_list_str[40]; | |||
| 739 | char guid_buf[(GUID_LEN16 * 2) + 1]; | |||
| 740 | ||||
| 741 | root = json_create_object()json_object_new_object(); | |||
| 742 | ||||
| 743 | json_object_add_value_int(root, "Number Unsupported Req IDs",json_object_object_add(root, "Number Unsupported Req IDs", json_object_new_int (le16_to_cpu(log_data->unsupported_count))) | |||
| 744 | le16_to_cpu(log_data->unsupported_count))json_object_object_add(root, "Number Unsupported Req IDs", json_object_new_int (le16_to_cpu(log_data->unsupported_count))); | |||
| 745 | ||||
| 746 | memset((void *)unsup_req_list_str, 0, 40); | |||
| 747 | for (j = 0; j < le16_to_cpu(log_data->unsupported_count) && | |||
| 748 | j < ARRAY_SIZE(log_data->unsupported_req_list)(sizeof(log_data->unsupported_req_list) / sizeof((log_data ->unsupported_req_list)[0]) + 0); j++) { | |||
| 749 | char req[sizeof(log_data->unsupported_req_list[j]) + 1] = {}; | |||
| 750 | ||||
| 751 | memcpy(req, log_data->unsupported_req_list[j], | |||
| 752 | sizeof(log_data->unsupported_req_list[j])); | |||
| 753 | snprintf(unsup_req_list_str, sizeof(unsup_req_list_str), | |||
| 754 | "Unsupported Requirement List %d", j); | |||
| 755 | json_object_add_value_string(root, unsup_req_list_str, req); | |||
| 756 | } | |||
| 757 | ||||
| 758 | json_object_add_value_int(root, "Log Page Version",json_object_object_add(root, "Log Page Version", json_object_new_int (le16_to_cpu(log_data->log_page_version))) | |||
| 759 | le16_to_cpu(log_data->log_page_version))json_object_object_add(root, "Log Page Version", json_object_new_int (le16_to_cpu(log_data->log_page_version))); | |||
| 760 | ||||
| 761 | shr_bin_to_hex(guid_buf, sizeof(guid_buf), log_data->log_page_guid, | |||
| 762 | GUID_LEN16, SHR_HEX_REVERSE(1 << 1)); | |||
| 763 | json_object_add_value_string(root, "Log page GUID", guid_buf); | |||
| 764 | ||||
| 765 | json_print_object(root, NULL)printf("%s", json_object_to_json_string_ext(root, (1 << 1) | (1 << 4))); | |||
| 766 | printf("\n"); | |||
| 767 | ||||
| 768 | json_free_object(root)json_object_put(root); | |||
| 769 | } | |||
| 770 | ||||
| 771 | static void json_c1_log(struct ocp_error_recovery_log_page *log_data) | |||
| 772 | { | |||
| 773 | struct json_object *root; | |||
| 774 | ||||
| 775 | root = json_create_object()json_object_new_object(); | |||
| 776 | char guid[64]; | |||
| 777 | ||||
| 778 | json_object_add_value_int(root, "Panic Reset Wait Time",json_object_object_add(root, "Panic Reset Wait Time", json_object_new_int (le16_to_cpu(log_data->panic_reset_wait_time))) | |||
| 779 | le16_to_cpu(log_data->panic_reset_wait_time))json_object_object_add(root, "Panic Reset Wait Time", json_object_new_int (le16_to_cpu(log_data->panic_reset_wait_time))); | |||
| 780 | json_object_add_value_int(root, "Panic Reset Action", log_data->panic_reset_action)json_object_object_add(root, "Panic Reset Action", json_object_new_int (log_data->panic_reset_action)); | |||
| 781 | json_object_add_value_int(root, "Device Recovery Action 1",json_object_object_add(root, "Device Recovery Action 1", json_object_new_int (log_data->device_recover_action_1)) | |||
| 782 | log_data->device_recover_action_1)json_object_object_add(root, "Device Recovery Action 1", json_object_new_int (log_data->device_recover_action_1)); | |||
| 783 | json_object_add_value_int(root, "Panic ID", le32_to_cpu(log_data->panic_id))json_object_object_add(root, "Panic ID", json_object_new_int( le32_to_cpu(log_data->panic_id))); | |||
| 784 | json_object_add_value_int(root, "Device Capabilities",json_object_object_add(root, "Device Capabilities", json_object_new_int (le32_to_cpu(log_data->device_capabilities))) | |||
| 785 | le32_to_cpu(log_data->device_capabilities))json_object_object_add(root, "Device Capabilities", json_object_new_int (le32_to_cpu(log_data->device_capabilities))); | |||
| 786 | json_object_add_value_int(root, "Vendor Specific Recovery Opcode",json_object_object_add(root, "Vendor Specific Recovery Opcode" , json_object_new_int(log_data->vendor_specific_recovery_opcode )) | |||
| 787 | log_data->vendor_specific_recovery_opcode)json_object_object_add(root, "Vendor Specific Recovery Opcode" , json_object_new_int(log_data->vendor_specific_recovery_opcode )); | |||
| 788 | json_object_add_value_int(root, "Vendor Specific Command CDW12",json_object_object_add(root, "Vendor Specific Command CDW12", json_object_new_int(le32_to_cpu(log_data->vendor_specific_command_cdw12 ))) | |||
| 789 | le32_to_cpu(log_data->vendor_specific_command_cdw12))json_object_object_add(root, "Vendor Specific Command CDW12", json_object_new_int(le32_to_cpu(log_data->vendor_specific_command_cdw12 ))); | |||
| 790 | json_object_add_value_int(root, "Vendor Specific Command CDW13",json_object_object_add(root, "Vendor Specific Command CDW13", json_object_new_int(le32_to_cpu(log_data->vendor_specific_command_cdw13 ))) | |||
| 791 | le32_to_cpu(log_data->vendor_specific_command_cdw13))json_object_object_add(root, "Vendor Specific Command CDW13", json_object_new_int(le32_to_cpu(log_data->vendor_specific_command_cdw13 ))); | |||
| 792 | json_object_add_value_int(root, "Vendor Specific Command Timeout",json_object_object_add(root, "Vendor Specific Command Timeout" , json_object_new_int(log_data->vendor_specific_command_timeout )) | |||
| 793 | log_data->vendor_specific_command_timeout)json_object_object_add(root, "Vendor Specific Command Timeout" , json_object_new_int(log_data->vendor_specific_command_timeout )); | |||
| 794 | json_object_add_value_int(root, "Device Recovery Action 2",json_object_object_add(root, "Device Recovery Action 2", json_object_new_int (log_data->device_recover_action_2)) | |||
| 795 | log_data->device_recover_action_2)json_object_object_add(root, "Device Recovery Action 2", json_object_new_int (log_data->device_recover_action_2)); | |||
| 796 | json_object_add_value_int(root, "Device Recovery Action 2 Timeout",json_object_object_add(root, "Device Recovery Action 2 Timeout" , json_object_new_int(log_data->device_recover_action_2_timeout )) | |||
| 797 | log_data->device_recover_action_2_timeout)json_object_object_add(root, "Device Recovery Action 2 Timeout" , json_object_new_int(log_data->device_recover_action_2_timeout )); | |||
| 798 | json_object_add_value_int(root, "Log Page Version",json_object_object_add(root, "Log Page Version", json_object_new_int (le16_to_cpu(log_data->log_page_version))) | |||
| 799 | le16_to_cpu(log_data->log_page_version))json_object_object_add(root, "Log Page Version", json_object_new_int (le16_to_cpu(log_data->log_page_version))); | |||
| 800 | ||||
| 801 | memset((void *)guid, 0, 64); | |||
| 802 | snprintf((char *)guid, sizeof(guid), "0x%016"PRIx64"l" "x""%016"PRIx64"l" "x""", | |||
| 803 | shr_get_unaligned_le64(&log_data->log_page_guid[8]), | |||
| 804 | shr_get_unaligned_le64(&log_data->log_page_guid[0])); | |||
| 805 | json_object_add_value_string(root, "Log page GUID", guid); | |||
| 806 | ||||
| 807 | json_print_object(root, NULL)printf("%s", json_object_to_json_string_ext(root, (1 << 1) | (1 << 4))); | |||
| 808 | printf("\n"); | |||
| 809 | json_free_object(root)json_object_put(root); | |||
| 810 | } | |||
| 811 | ||||
| 812 | static void json_c4_log(struct ocp_device_capabilities_log_page *log_data) | |||
| 813 | { | |||
| 814 | struct json_object *root = json_create_object()json_object_new_object(); | |||
| 815 | __u16 log_page_version = le16_to_cpu(log_data->log_page_version); | |||
| 816 | char guid[64]; | |||
| 817 | int i; | |||
| 818 | ||||
| 819 | json_object_add_value_int(root, "PCI Express Ports", le16_to_cpu(log_data->pcie_exp_port))json_object_object_add(root, "PCI Express Ports", json_object_new_int (le16_to_cpu(log_data->pcie_exp_port))); | |||
| 820 | json_object_add_value_int(root, "OOB Management Support",json_object_object_add(root, "OOB Management Support", json_object_new_int (le16_to_cpu(log_data->oob_management_support))) | |||
| 821 | le16_to_cpu(log_data->oob_management_support))json_object_object_add(root, "OOB Management Support", json_object_new_int (le16_to_cpu(log_data->oob_management_support))); | |||
| 822 | json_object_add_value_int(root, "Write Zeroes Command Support",json_object_object_add(root, "Write Zeroes Command Support", json_object_new_int (le16_to_cpu(log_data->wz_cmd_support))) | |||
| 823 | le16_to_cpu(log_data->wz_cmd_support))json_object_object_add(root, "Write Zeroes Command Support", json_object_new_int (le16_to_cpu(log_data->wz_cmd_support))); | |||
| 824 | json_object_add_value_int(root, "Sanitize Command Support",json_object_object_add(root, "Sanitize Command Support", json_object_new_int (le16_to_cpu(log_data->sanitize_cmd_support))) | |||
| 825 | le16_to_cpu(log_data->sanitize_cmd_support))json_object_object_add(root, "Sanitize Command Support", json_object_new_int (le16_to_cpu(log_data->sanitize_cmd_support))); | |||
| 826 | json_object_add_value_int(root, "Dataset Management Command Support",json_object_object_add(root, "Dataset Management Command Support" , json_object_new_int(le16_to_cpu(log_data->dsm_cmd_support ))) | |||
| 827 | le16_to_cpu(log_data->dsm_cmd_support))json_object_object_add(root, "Dataset Management Command Support" , json_object_new_int(le16_to_cpu(log_data->dsm_cmd_support ))); | |||
| 828 | json_object_add_value_int(root, "Write Uncorrectable Command Support",json_object_object_add(root, "Write Uncorrectable Command Support" , json_object_new_int(le16_to_cpu(log_data->wu_cmd_support ))) | |||
| 829 | le16_to_cpu(log_data->wu_cmd_support))json_object_object_add(root, "Write Uncorrectable Command Support" , json_object_new_int(le16_to_cpu(log_data->wu_cmd_support ))); | |||
| 830 | json_object_add_value_int(root, "Fused Operation Support",json_object_object_add(root, "Fused Operation Support", json_object_new_int (le16_to_cpu(log_data->fused_operation_support))) | |||
| 831 | le16_to_cpu(log_data->fused_operation_support))json_object_object_add(root, "Fused Operation Support", json_object_new_int (le16_to_cpu(log_data->fused_operation_support))); | |||
| 832 | json_object_add_value_int(root, "Minimum Valid DSSD Power State",json_object_object_add(root, "Minimum Valid DSSD Power State" , json_object_new_int(le16_to_cpu(log_data->min_valid_dssd_pwr_state ))) | |||
| 833 | le16_to_cpu(log_data->min_valid_dssd_pwr_state))json_object_object_add(root, "Minimum Valid DSSD Power State" , json_object_new_int(le16_to_cpu(log_data->min_valid_dssd_pwr_state ))); | |||
| 834 | for (i = 0; i <= 127; i++) | |||
| 835 | json_object_add_value_int(root, "DSSD Power State Descriptors",json_object_object_add(root, "DSSD Power State Descriptors", json_object_new_int (log_data->dssd_pwr_state_desc[i])) | |||
| 836 | log_data->dssd_pwr_state_desc[i])json_object_object_add(root, "DSSD Power State Descriptors", json_object_new_int (log_data->dssd_pwr_state_desc[i])); | |||
| 837 | if (log_page_version >= 0x2) { | |||
| 838 | __u16 fips = le16_to_cpu(log_data->fips_140_validation); | |||
| 839 | ||||
| 840 | json_object_add_value_int(root, "FIPS 140 Validation", fips)json_object_object_add(root, "FIPS 140 Validation", json_object_new_int (fips)); | |||
| 841 | json_object_add_value_string(root, "FIPS 140 Validation Status", | |||
| 842 | ocp_c4_fips_140_status(fips)); | |||
| 843 | } | |||
| 844 | json_object_add_value_int(root, "Log Page Version", log_page_version)json_object_object_add(root, "Log Page Version", json_object_new_int (log_page_version)); | |||
| 845 | ||||
| 846 | memset((void *)guid, 0, 64); | |||
| 847 | snprintf((char *)guid, sizeof(guid), "0x%016"PRIx64"l" "x""%016"PRIx64"l" "x""", | |||
| 848 | shr_get_unaligned_le64(&log_data->log_page_guid[8]), | |||
| 849 | shr_get_unaligned_le64(&log_data->log_page_guid[0])); | |||
| 850 | json_object_add_value_string(root, "Log page GUID", guid); | |||
| 851 | ||||
| 852 | json_print_object(root, NULL)printf("%s", json_object_to_json_string_ext(root, (1 << 1) | (1 << 4))); | |||
| 853 | printf("\n"); | |||
| 854 | json_free_object(root)json_object_put(root); | |||
| 855 | } | |||
| 856 | ||||
| 857 | /* | |||
| 858 | * Append the @n bytes at @data to the string in @buf, each as a hex or | |||
| 859 | * decimal number without padding, as the reserved fields were printed. | |||
| 860 | */ | |||
| 861 | static void concat_bytes(char *buf, size_t size, const __u8 *data, int n, | |||
| 862 | bool_Bool hex) | |||
| 863 | { | |||
| 864 | size_t len = strnlen(buf, size); | |||
| 865 | int i; | |||
| 866 | ||||
| 867 | for (i = 0; i < n; i++) | |||
| 868 | shr_snprintf_append(buf, size, &len, hex ? "%x" : "%d", | |||
| 869 | data[i]); | |||
| 870 | } | |||
| 871 | ||||
| 872 | /* Array lengths need to be doubled + 2 to handle | |||
| 873 | * conversion to null terminated strings | |||
| 874 | */ | |||
| 875 | #define RESERVED_ARRAY_LEN98 98 /* (2*48) + 2 */ | |||
| 876 | #define GUID_BUFFER_LEN34 34 /* (2*GUID_LEN) + 2 */ | |||
| 877 | /* Add one additional space for the null terminating char */ | |||
| 878 | #define FIFO_ARRAY_LEN17 17 | |||
| 879 | ||||
| 880 | static void json_c9_log(struct telemetry_str_log_format *log_data, __u8 *log_data_buf, | |||
| 881 | size_t total_log_page_size) | |||
| 882 | { | |||
| 883 | struct json_object *root = json_create_object()json_object_new_object(); | |||
| 884 | char res_arr[RESERVED_ARRAY_LEN98]; | |||
| 885 | char guid_buf[GUID_BUFFER_LEN34]; | |||
| 886 | char fifo_arr[FIFO_ARRAY_LEN17]; | |||
| 887 | char buf[128]; | |||
| 888 | __u64 sits = le64_to_cpu(log_data->sits); | |||
| 889 | __u64 sitsz = le64_to_cpu(log_data->sitsz); | |||
| 890 | __u64 ests = le64_to_cpu(log_data->ests); | |||
| 891 | __u64 estsz = le64_to_cpu(log_data->estsz); | |||
| 892 | __u64 vu_eve_sts = le64_to_cpu(log_data->vu_eve_sts); | |||
| 893 | __u64 vu_eve_st_sz = le64_to_cpu(log_data->vu_eve_st_sz); | |||
| 894 | __u64 ascts = le64_to_cpu(log_data->ascts); | |||
| 895 | __u64 asctsz = le64_to_cpu(log_data->asctsz); | |||
| 896 | struct statistics_id_str_table_entry stat_entry; | |||
| 897 | struct event_id_str_table_entry eve_entry; | |||
| 898 | struct vu_event_id_str_table_entry vu_eve_entry; | |||
| 899 | /* nvme_show_error() would emit a second JSON document, so errors go in this one */ | |||
| 900 | struct json_object *errors = json_create_array()json_object_new_array(); | |||
| 901 | __u64 entries = 0, i; | |||
| 902 | __u8 *table; | |||
| 903 | ||||
| 904 | json_object_add_value_int(root, "Log Page Version",json_object_object_add(root, "Log Page Version", json_object_new_int (le16_to_cpu(log_data->log_page_version))) | |||
| 905 | le16_to_cpu(log_data->log_page_version))json_object_object_add(root, "Log Page Version", json_object_new_int (le16_to_cpu(log_data->log_page_version))); | |||
| 906 | ||||
| 907 | res_arr[0] = '\0'; | |||
| 908 | concat_bytes(res_arr, sizeof(res_arr), log_data->reserved1, 15, true1); | |||
| 909 | json_object_add_value_string(root, "Reserved 1", res_arr); | |||
| 910 | ||||
| 911 | shr_bin_to_hex(guid_buf, sizeof(guid_buf), log_data->log_page_guid, | |||
| 912 | GUID_LEN16, SHR_HEX_REVERSE(1 << 1)); | |||
| 913 | json_object_add_value_string(root, "Log page GUID", guid_buf); | |||
| 914 | ||||
| 915 | json_object_add_value_int(root, "Telemetry String Log Size", le64_to_cpu(log_data->sls))json_object_object_add(root, "Telemetry String Log Size", json_object_new_int (le64_to_cpu(log_data->sls))); | |||
| 916 | ||||
| 917 | res_arr[0] = '\0'; | |||
| 918 | concat_bytes(res_arr, sizeof(res_arr), log_data->reserved2, 24, true1); | |||
| 919 | json_object_add_value_string(root, "Reserved 2", res_arr); | |||
| 920 | ||||
| 921 | json_object_add_value_int(root, "Statistics Identifier String Table Start",json_object_object_add(root, "Statistics Identifier String Table Start" , json_object_new_int(le64_to_cpu(log_data->sits))) | |||
| 922 | le64_to_cpu(log_data->sits))json_object_object_add(root, "Statistics Identifier String Table Start" , json_object_new_int(le64_to_cpu(log_data->sits))); | |||
| 923 | json_object_add_value_int(root, "Statistics Identifier String Table Size",json_object_object_add(root, "Statistics Identifier String Table Size" , json_object_new_int(le64_to_cpu(log_data->sitsz))) | |||
| 924 | le64_to_cpu(log_data->sitsz))json_object_object_add(root, "Statistics Identifier String Table Size" , json_object_new_int(le64_to_cpu(log_data->sitsz))); | |||
| 925 | json_object_add_value_int(root, "Event String Table Start", le64_to_cpu(log_data->ests))json_object_object_add(root, "Event String Table Start", json_object_new_int (le64_to_cpu(log_data->ests))); | |||
| 926 | json_object_add_value_int(root, "Event String Table Size", le64_to_cpu(log_data->estsz))json_object_object_add(root, "Event String Table Size", json_object_new_int (le64_to_cpu(log_data->estsz))); | |||
| 927 | json_object_add_value_int(root, "VU Event String Table Start",json_object_object_add(root, "VU Event String Table Start", json_object_new_int (le64_to_cpu(log_data->vu_eve_sts))) | |||
| 928 | le64_to_cpu(log_data->vu_eve_sts))json_object_object_add(root, "VU Event String Table Start", json_object_new_int (le64_to_cpu(log_data->vu_eve_sts))); | |||
| 929 | json_object_add_value_int(root, "VU Event String Table Size",json_object_object_add(root, "VU Event String Table Size", json_object_new_int (le64_to_cpu(log_data->vu_eve_st_sz))) | |||
| 930 | le64_to_cpu(log_data->vu_eve_st_sz))json_object_object_add(root, "VU Event String Table Size", json_object_new_int (le64_to_cpu(log_data->vu_eve_st_sz))); | |||
| 931 | json_object_add_value_int(root, "ASCII Table Start",json_object_object_add(root, "ASCII Table Start", json_object_new_int (le64_to_cpu(log_data->ascts))) | |||
| 932 | le64_to_cpu(log_data->ascts))json_object_object_add(root, "ASCII Table Start", json_object_new_int (le64_to_cpu(log_data->ascts))); | |||
| 933 | json_object_add_value_int(root, "ASCII Table Size",json_object_object_add(root, "ASCII Table Size", json_object_new_int (le64_to_cpu(log_data->asctsz))) | |||
| 934 | le64_to_cpu(log_data->asctsz))json_object_object_add(root, "ASCII Table Size", json_object_new_int (le64_to_cpu(log_data->asctsz))); | |||
| 935 | ||||
| 936 | memset(fifo_arr, 0, sizeof(fifo_arr)); | |||
| 937 | memcpy(fifo_arr, log_data->fifo1, sizeof(log_data->fifo1)); | |||
| 938 | json_object_add_value_string(root, "FIFO 1 ASCII String", fifo_arr); | |||
| 939 | ||||
| 940 | memset(fifo_arr, 0, sizeof(fifo_arr)); | |||
| 941 | memcpy(fifo_arr, log_data->fifo2, sizeof(log_data->fifo2)); | |||
| 942 | json_object_add_value_string(root, "FIFO 2 ASCII String", fifo_arr); | |||
| 943 | ||||
| 944 | memset(fifo_arr, 0, sizeof(fifo_arr)); | |||
| 945 | memcpy(fifo_arr, log_data->fifo3, sizeof(log_data->fifo3)); | |||
| 946 | json_object_add_value_string(root, "FIFO 3 ASCII String", fifo_arr); | |||
| 947 | ||||
| 948 | memset(fifo_arr, 0, sizeof(fifo_arr)); | |||
| 949 | memcpy(fifo_arr, log_data->fifo4, sizeof(log_data->fifo4)); | |||
| 950 | json_object_add_value_string(root, "FIFO 4 ASCII String", fifo_arr); | |||
| 951 | ||||
| 952 | memset(fifo_arr, 0, sizeof(fifo_arr)); | |||
| 953 | memcpy(fifo_arr, log_data->fifo5, sizeof(log_data->fifo5)); | |||
| 954 | json_object_add_value_string(root, "FIFO 5 ASCII String", fifo_arr); | |||
| 955 | ||||
| 956 | memset(fifo_arr, 0, sizeof(fifo_arr)); | |||
| 957 | memcpy(fifo_arr, log_data->fifo6, sizeof(log_data->fifo6)); | |||
| 958 | json_object_add_value_string(root, "FIFO 6 ASCII String", fifo_arr); | |||
| 959 | ||||
| 960 | memset(fifo_arr, 0, sizeof(fifo_arr)); | |||
| 961 | memcpy(fifo_arr, log_data->fifo7, sizeof(log_data->fifo7)); | |||
| 962 | json_object_add_value_string(root, "FIFO 7 ASCII String", fifo_arr); | |||
| 963 | ||||
| 964 | memset(fifo_arr, 0, sizeof(fifo_arr)); | |||
| 965 | memcpy(fifo_arr, log_data->fifo8, sizeof(log_data->fifo8)); | |||
| 966 | json_object_add_value_string(root, "FIFO 8 ASCII String", fifo_arr); | |||
| 967 | ||||
| 968 | memset(fifo_arr, 0, sizeof(fifo_arr)); | |||
| 969 | memcpy(fifo_arr, log_data->fifo9, sizeof(log_data->fifo9)); | |||
| 970 | json_object_add_value_string(root, "FIFO 9 ASCII String", fifo_arr); | |||
| 971 | ||||
| 972 | memset(fifo_arr, 0, sizeof(fifo_arr)); | |||
| 973 | memcpy(fifo_arr, log_data->fifo10, sizeof(log_data->fifo10)); | |||
| 974 | json_object_add_value_string(root, "FIFO 10 ASCII String", fifo_arr); | |||
| 975 | ||||
| 976 | memset(fifo_arr, 0, sizeof(fifo_arr)); | |||
| 977 | memcpy(fifo_arr, log_data->fifo11, sizeof(log_data->fifo11)); | |||
| 978 | json_object_add_value_string(root, "FIFO 11 ASCII String", fifo_arr); | |||
| 979 | ||||
| 980 | memset(fifo_arr, 0, sizeof(fifo_arr)); | |||
| 981 | memcpy(fifo_arr, log_data->fifo12, sizeof(log_data->fifo12)); | |||
| 982 | json_object_add_value_string(root, "FIFO 12 ASCII String", fifo_arr); | |||
| 983 | ||||
| 984 | memset(fifo_arr, 0, sizeof(fifo_arr)); | |||
| 985 | memcpy(fifo_arr, log_data->fifo13, sizeof(log_data->fifo13)); | |||
| 986 | json_object_add_value_string(root, "FIFO 13 ASCII String", fifo_arr); | |||
| 987 | ||||
| 988 | memset(fifo_arr, 0, sizeof(fifo_arr)); | |||
| 989 | memcpy(fifo_arr, log_data->fifo14, sizeof(log_data->fifo14)); | |||
| 990 | json_object_add_value_string(root, "FIFO 14 ASCII String", fifo_arr); | |||
| 991 | ||||
| 992 | memset(fifo_arr, 0, sizeof(fifo_arr)); | |||
| 993 | memcpy(fifo_arr, log_data->fifo15, sizeof(log_data->fifo15)); | |||
| 994 | json_object_add_value_string(root, "FIFO 15 ASCII String", fifo_arr); | |||
| 995 | ||||
| 996 | memset(fifo_arr, 0, sizeof(fifo_arr)); | |||
| 997 | memcpy(fifo_arr, log_data->fifo16, sizeof(log_data->fifo16)); | |||
| 998 | json_object_add_value_string(root, "FIFO 16 ASCII String", fifo_arr); | |||
| 999 | ||||
| 1000 | res_arr[0] = '\0'; | |||
| 1001 | concat_bytes(res_arr, sizeof(res_arr), log_data->reserved3, 48, true1); | |||
| 1002 | json_object_add_value_string(root, "Reserved 3", res_arr); | |||
| 1003 | ||||
| 1004 | table = ocp_string_table(log_data_buf, total_log_page_size, sits, sitsz, | |||
| 1005 | sizeof(stat_entry), &entries); | |||
| 1006 | if (sitsz && !table) { | |||
| ||||
| 1007 | array_add_strjson_array_add_value_string(errors, "Statistics Identifier String Table exceeds the log page"); | |||
| 1008 | } else if (sitsz) { | |||
| 1009 | struct json_object *stat_table = json_create_object()json_object_new_object(); | |||
| 1010 | ||||
| 1011 | for (i = 0; i < entries; i++) { | |||
| 1012 | struct json_object *entry = json_create_object()json_object_new_object(); | |||
| 1013 | ||||
| 1014 | memcpy(&stat_entry, table + i * sizeof(stat_entry), sizeof(stat_entry)); | |||
| 1015 | json_object_add_value_uint(entry, "Vendor Specific Statistic Identifier",json_object_object_add(entry, "Vendor Specific Statistic Identifier" , json_object_new_uint64(le16_to_cpu(stat_entry.vs_si))) | |||
| 1016 | le16_to_cpu(stat_entry.vs_si))json_object_object_add(entry, "Vendor Specific Statistic Identifier" , json_object_new_uint64(le16_to_cpu(stat_entry.vs_si))); | |||
| 1017 | json_object_add_value_uint(entry, "Reserved", stat_entry.reserved1)json_object_object_add(entry, "Reserved", json_object_new_uint64 (stat_entry.reserved1)); | |||
| 1018 | json_object_add_value_uint(entry, "ASCII ID Length",json_object_object_add(entry, "ASCII ID Length", json_object_new_uint64 (stat_entry.ascii_id_len)) | |||
| 1019 | stat_entry.ascii_id_len)json_object_object_add(entry, "ASCII ID Length", json_object_new_uint64 (stat_entry.ascii_id_len)); | |||
| 1020 | json_object_add_value_uint(entry, "ASCII ID offset",json_object_object_add(entry, "ASCII ID offset", json_object_new_uint64 (le64_to_cpu(stat_entry.ascii_id_ofst))) | |||
| 1021 | le64_to_cpu(stat_entry.ascii_id_ofst))json_object_object_add(entry, "ASCII ID offset", json_object_new_uint64 (le64_to_cpu(stat_entry.ascii_id_ofst))); | |||
| 1022 | json_object_add_value_uint(entry, "Reserved2",json_object_object_add(entry, "Reserved2", json_object_new_uint64 (le32_to_cpu(stat_entry.reserved2))) | |||
| 1023 | le32_to_cpu(stat_entry.reserved2))json_object_object_add(entry, "Reserved2", json_object_new_uint64 (le32_to_cpu(stat_entry.reserved2))); | |||
| 1024 | snprintf(buf, sizeof(buf), | |||
| 1025 | "Statistics Identifier String Table %"PRIu64"l" "u", | |||
| 1026 | (uint64_t)i); | |||
| 1027 | json_object_add_value_object(stat_table, buf, entry)json_object_object_add(stat_table, buf, entry); | |||
| 1028 | } | |||
| 1029 | ||||
| 1030 | json_object_add_value_object(root, "Statistics Identifier String Table",json_object_object_add(root, "Statistics Identifier String Table" , stat_table) | |||
| 1031 | stat_table)json_object_object_add(root, "Statistics Identifier String Table" , stat_table); | |||
| 1032 | } | |||
| 1033 | ||||
| 1034 | table = ocp_string_table(log_data_buf, total_log_page_size, ests, estsz, | |||
| 1035 | sizeof(eve_entry), &entries); | |||
| 1036 | if (estsz && !table) { | |||
| 1037 | array_add_strjson_array_add_value_string(errors, "Event String Table exceeds the log page"); | |||
| 1038 | } else if (estsz) { | |||
| 1039 | struct json_object *eve_table = json_create_object()json_object_new_object(); | |||
| 1040 | ||||
| 1041 | for (i = 0; i < entries; i++) { | |||
| 1042 | struct json_object *entry = json_create_object()json_object_new_object(); | |||
| 1043 | ||||
| 1044 | memcpy(&eve_entry, table + i * sizeof(eve_entry), sizeof(eve_entry)); | |||
| 1045 | json_object_add_value_int(entry, "Debug Event Class",json_object_object_add(entry, "Debug Event Class", json_object_new_int (eve_entry.deb_eve_class)) | |||
| 1046 | eve_entry.deb_eve_class)json_object_object_add(entry, "Debug Event Class", json_object_new_int (eve_entry.deb_eve_class)); | |||
| 1047 | json_object_add_value_int(entry, "Event Identifier",json_object_object_add(entry, "Event Identifier", json_object_new_int (le16_to_cpu(eve_entry.ei))) | |||
| 1048 | le16_to_cpu(eve_entry.ei))json_object_object_add(entry, "Event Identifier", json_object_new_int (le16_to_cpu(eve_entry.ei))); | |||
| 1049 | json_object_add_value_int(entry, "ASCII ID Length",json_object_object_add(entry, "ASCII ID Length", json_object_new_int (eve_entry.ascii_id_len)) | |||
| 1050 | eve_entry.ascii_id_len)json_object_object_add(entry, "ASCII ID Length", json_object_new_int (eve_entry.ascii_id_len)); | |||
| 1051 | json_object_add_value_int(entry, "ASCII ID offset",json_object_object_add(entry, "ASCII ID offset", json_object_new_int (le64_to_cpu(eve_entry.ascii_id_ofst))) | |||
| 1052 | le64_to_cpu(eve_entry.ascii_id_ofst))json_object_object_add(entry, "ASCII ID offset", json_object_new_int (le64_to_cpu(eve_entry.ascii_id_ofst))); | |||
| 1053 | json_object_add_value_int(entry, "Reserved",json_object_object_add(entry, "Reserved", json_object_new_int (le32_to_cpu(eve_entry.reserved2))) | |||
| 1054 | le32_to_cpu(eve_entry.reserved2))json_object_object_add(entry, "Reserved", json_object_new_int (le32_to_cpu(eve_entry.reserved2))); | |||
| 1055 | snprintf(buf, sizeof(buf), | |||
| 1056 | "Event Identifier String Table Entry %"PRIu64"l" "u", | |||
| 1057 | (uint64_t)i); | |||
| 1058 | json_object_add_value_object(eve_table, buf, entry)json_object_object_add(eve_table, buf, entry); | |||
| 1059 | } | |||
| 1060 | json_object_add_value_object(root, "Event Identifier String Table Entry",json_object_object_add(root, "Event Identifier String Table Entry" , eve_table) | |||
| 1061 | eve_table)json_object_object_add(root, "Event Identifier String Table Entry" , eve_table); | |||
| 1062 | } | |||
| 1063 | ||||
| 1064 | table = ocp_string_table(log_data_buf, total_log_page_size, vu_eve_sts, vu_eve_st_sz, | |||
| 1065 | sizeof(vu_eve_entry), &entries); | |||
| 1066 | if (vu_eve_st_sz && !table) { | |||
| 1067 | array_add_strjson_array_add_value_string(errors, "VU Event String Table exceeds the log page"); | |||
| 1068 | } else if (vu_eve_st_sz) { | |||
| 1069 | struct json_object *vu_eve_table = json_create_object()json_object_new_object(); | |||
| 1070 | ||||
| 1071 | for (i = 0; i < entries; i++) { | |||
| 1072 | struct json_object *entry = json_create_object()json_object_new_object(); | |||
| 1073 | ||||
| 1074 | memcpy(&vu_eve_entry, table + i * sizeof(vu_eve_entry), | |||
| 1075 | sizeof(vu_eve_entry)); | |||
| 1076 | json_object_add_value_int(entry, "Debug Event Class",json_object_object_add(entry, "Debug Event Class", json_object_new_int (vu_eve_entry.deb_eve_class)) | |||
| 1077 | vu_eve_entry.deb_eve_class)json_object_object_add(entry, "Debug Event Class", json_object_new_int (vu_eve_entry.deb_eve_class)); | |||
| 1078 | json_object_add_value_int(entry, "VU Event Identifier",json_object_object_add(entry, "VU Event Identifier", json_object_new_int (le16_to_cpu(vu_eve_entry.vu_ei))) | |||
| 1079 | le16_to_cpu(vu_eve_entry.vu_ei))json_object_object_add(entry, "VU Event Identifier", json_object_new_int (le16_to_cpu(vu_eve_entry.vu_ei))); | |||
| 1080 | json_object_add_value_int(entry, "ASCII ID Length",json_object_object_add(entry, "ASCII ID Length", json_object_new_int (vu_eve_entry.ascii_id_len)) | |||
| 1081 | vu_eve_entry.ascii_id_len)json_object_object_add(entry, "ASCII ID Length", json_object_new_int (vu_eve_entry.ascii_id_len)); | |||
| 1082 | json_object_add_value_int(entry, "ASCII ID offset",json_object_object_add(entry, "ASCII ID offset", json_object_new_int (le64_to_cpu(vu_eve_entry.ascii_id_ofst))) | |||
| 1083 | le64_to_cpu(vu_eve_entry.ascii_id_ofst))json_object_object_add(entry, "ASCII ID offset", json_object_new_int (le64_to_cpu(vu_eve_entry.ascii_id_ofst))); | |||
| 1084 | json_object_add_value_int(entry, "Reserved",json_object_object_add(entry, "Reserved", json_object_new_int (le32_to_cpu(vu_eve_entry.reserved))) | |||
| 1085 | le32_to_cpu(vu_eve_entry.reserved))json_object_object_add(entry, "Reserved", json_object_new_int (le32_to_cpu(vu_eve_entry.reserved))); | |||
| 1086 | snprintf(buf, sizeof(buf), | |||
| 1087 | "VU Event Identifier String Table Entry %llu", | |||
| 1088 | (unsigned long long)i); | |||
| 1089 | json_object_add_value_object(vu_eve_table, buf, entry)json_object_object_add(vu_eve_table, buf, entry); | |||
| 1090 | } | |||
| 1091 | json_object_add_value_object(root, "VU Event Identifier String Table Entry",json_object_object_add(root, "VU Event Identifier String Table Entry" , vu_eve_table) | |||
| 1092 | vu_eve_table)json_object_object_add(root, "VU Event Identifier String Table Entry" , vu_eve_table); | |||
| 1093 | } | |||
| 1094 | ||||
| 1095 | if (asctsz && !ocp_c9_table_fits(ascts, asctsz, total_log_page_size)) { | |||
| 1096 | array_add_strjson_array_add_value_string(errors, "ASCII Table exceeds the log page"); | |||
| 1097 | } else if (asctsz) { | |||
| 1098 | /* Sized, not NUL-terminated: padding between strings is part of the table. */ | |||
| 1099 | json_object_add_value_object(root, "ASCII Table",json_object_object_add(root, "ASCII Table", json_object_new_string_len ((const char *)log_data_buf + ascts * 4, (int)(asctsz * 4))) | |||
| 1100 | json_object_new_string_len((const char *)log_data_buf + ascts * 4,json_object_object_add(root, "ASCII Table", json_object_new_string_len ((const char *)log_data_buf + ascts * 4, (int)(asctsz * 4))) | |||
| 1101 | (int)(asctsz * 4)))json_object_object_add(root, "ASCII Table", json_object_new_string_len ((const char *)log_data_buf + ascts * 4, (int)(asctsz * 4))); | |||
| 1102 | } | |||
| 1103 | ||||
| 1104 | if (json_object_array_length(errors)) | |||
| 1105 | json_object_add_value_array(root, "Errors", errors)json_object_object_add(root, "Errors", errors); | |||
| 1106 | else | |||
| 1107 | json_free_object(errors)json_object_put(errors); | |||
| 1108 | ||||
| 1109 | json_print_object(root, NULL)printf("%s", json_object_to_json_string_ext(root, (1 << 1) | (1 << 4))); | |||
| 1110 | printf("\n"); | |||
| 1111 | json_free_object(root)json_object_put(root); | |||
| 1112 | } | |||
| 1113 | ||||
| 1114 | static void json_c7_log(struct libnvme_transport_handle *hdl, struct tcg_configuration_log *log_data) | |||
| 1115 | { | |||
| 1116 | struct json_object *root; | |||
| 1117 | char guid_buf[(GUID_LEN16 * 2) + 1]; | |||
| 1118 | /* | |||
| 1119 | * rsvd38 holds 456 __u8 values printed as decimal (up to 3 digits | |||
| 1120 | * each), preceded on log_page_version == 1 by two more __u8 values | |||
| 1121 | * (up to 3 digits each) from no_of_ns_prov_locking_obj_ext, plus NUL. | |||
| 1122 | */ | |||
| 1123 | char res_arr[456 * 3 + 2 * 3 + 1]; | |||
| 1124 | __u16 log_page_version = le16_to_cpu(log_data->log_page_version); | |||
| 1125 | ||||
| 1126 | root = json_create_object()json_object_new_object(); | |||
| 1127 | ||||
| 1128 | json_object_add_value_int(root, "State", log_data->state)json_object_object_add(root, "State", json_object_new_int(log_data ->state)); | |||
| 1129 | res_arr[0] = '\0'; | |||
| 1130 | concat_bytes(res_arr, sizeof(res_arr), log_data->rsvd1, 3, false0); | |||
| 1131 | json_object_add_value_string(root, "Reserved1", res_arr); | |||
| 1132 | json_object_add_value_int(root, "Locking SP Activation Count",json_object_object_add(root, "Locking SP Activation Count", json_object_new_int (log_data->locking_sp_act_count)) | |||
| 1133 | log_data->locking_sp_act_count)json_object_object_add(root, "Locking SP Activation Count", json_object_new_int (log_data->locking_sp_act_count)); | |||
| 1134 | json_object_add_value_int(root, "Tper Revert Count",json_object_object_add(root, "Tper Revert Count", json_object_new_int (log_data->locking_sp_rev_count)) | |||
| 1135 | log_data->locking_sp_rev_count)json_object_object_add(root, "Tper Revert Count", json_object_new_int (log_data->locking_sp_rev_count)); | |||
| 1136 | json_object_add_value_int(root, "Number of Locking Objects",json_object_object_add(root, "Number of Locking Objects", json_object_new_int (log_data->no_of_locking_obj)) | |||
| 1137 | log_data->no_of_locking_obj)json_object_object_add(root, "Number of Locking Objects", json_object_new_int (log_data->no_of_locking_obj)); | |||
| 1138 | json_object_add_value_int(root, "Number of Single User Mode Locking Objects",json_object_object_add(root, "Number of Single User Mode Locking Objects" , json_object_new_int(log_data->no_of_single_um_locking_obj )) | |||
| 1139 | log_data->no_of_single_um_locking_obj)json_object_object_add(root, "Number of Single User Mode Locking Objects" , json_object_new_int(log_data->no_of_single_um_locking_obj )); | |||
| 1140 | json_object_add_value_int(root, "Number of Range Provisioned Locking Objects",json_object_object_add(root, "Number of Range Provisioned Locking Objects" , json_object_new_int(log_data->no_of_range_prov_locking_obj )) | |||
| 1141 | log_data->no_of_range_prov_locking_obj)json_object_object_add(root, "Number of Range Provisioned Locking Objects" , json_object_new_int(log_data->no_of_range_prov_locking_obj )); | |||
| 1142 | json_object_add_value_int(root, "Number of Namespace Provisioned Locking Objects",json_object_object_add(root, "Number of Namespace Provisioned Locking Objects" , json_object_new_int(log_data->no_of_ns_prov_locking_obj) ) | |||
| 1143 | log_data->no_of_ns_prov_locking_obj)json_object_object_add(root, "Number of Namespace Provisioned Locking Objects" , json_object_new_int(log_data->no_of_ns_prov_locking_obj) ); | |||
| 1144 | json_object_add_value_int(root, "Number of Read Locked Locking Objects",json_object_object_add(root, "Number of Read Locked Locking Objects" , json_object_new_int(log_data->no_of_read_lock_locking_obj )) | |||
| 1145 | log_data->no_of_read_lock_locking_obj)json_object_object_add(root, "Number of Read Locked Locking Objects" , json_object_new_int(log_data->no_of_read_lock_locking_obj )); | |||
| 1146 | json_object_add_value_int(root, "Number of Write Locked Locking Objects",json_object_object_add(root, "Number of Write Locked Locking Objects" , json_object_new_int(log_data->no_of_write_lock_locking_obj )) | |||
| 1147 | log_data->no_of_write_lock_locking_obj)json_object_object_add(root, "Number of Write Locked Locking Objects" , json_object_new_int(log_data->no_of_write_lock_locking_obj )); | |||
| 1148 | json_object_add_value_int(root, "Number of Read Unlocked Locking Objects",json_object_object_add(root, "Number of Read Unlocked Locking Objects" , json_object_new_int(log_data->no_of_read_unlock_locking_obj )) | |||
| 1149 | log_data->no_of_read_unlock_locking_obj)json_object_object_add(root, "Number of Read Unlocked Locking Objects" , json_object_new_int(log_data->no_of_read_unlock_locking_obj )); | |||
| 1150 | json_object_add_value_int(root, "Number of Write Unlocked Locking Objects",json_object_object_add(root, "Number of Write Unlocked Locking Objects" , json_object_new_int(log_data->no_of_write_unlock_locking_obj )) | |||
| 1151 | log_data->no_of_write_unlock_locking_obj)json_object_object_add(root, "Number of Write Unlocked Locking Objects" , json_object_new_int(log_data->no_of_write_unlock_locking_obj )); | |||
| 1152 | json_object_add_value_int(root, "Reserved2", log_data->rsvd15)json_object_object_add(root, "Reserved2", json_object_new_int (log_data->rsvd15)); | |||
| 1153 | ||||
| 1154 | json_object_add_value_int(root, "SID Authentication Try Count",json_object_object_add(root, "SID Authentication Try Count", json_object_new_int (le32_to_cpu(log_data->sid_auth_try_count))) | |||
| 1155 | le32_to_cpu(log_data->sid_auth_try_count))json_object_object_add(root, "SID Authentication Try Count", json_object_new_int (le32_to_cpu(log_data->sid_auth_try_count))); | |||
| 1156 | json_object_add_value_int(root, "SID Authentication Try Limit",json_object_object_add(root, "SID Authentication Try Limit", json_object_new_int (le32_to_cpu(log_data->sid_auth_try_limit))) | |||
| 1157 | le32_to_cpu(log_data->sid_auth_try_limit))json_object_object_add(root, "SID Authentication Try Limit", json_object_new_int (le32_to_cpu(log_data->sid_auth_try_limit))); | |||
| 1158 | json_object_add_value_int(root, "Programmatic TCG Reset Count",json_object_object_add(root, "Programmatic TCG Reset Count", json_object_new_int (le32_to_cpu(log_data->pro_tcg_rc))) | |||
| 1159 | le32_to_cpu(log_data->pro_tcg_rc))json_object_object_add(root, "Programmatic TCG Reset Count", json_object_new_int (le32_to_cpu(log_data->pro_tcg_rc))); | |||
| 1160 | json_object_add_value_int(root, "Programmatic Reset Lock Count",json_object_object_add(root, "Programmatic Reset Lock Count", json_object_new_int(le32_to_cpu(log_data->pro_rlc))) | |||
| 1161 | le32_to_cpu(log_data->pro_rlc))json_object_object_add(root, "Programmatic Reset Lock Count", json_object_new_int(le32_to_cpu(log_data->pro_rlc))); | |||
| 1162 | json_object_add_value_int(root, "TCG Error Count", le32_to_cpu(log_data->tcg_ec))json_object_object_add(root, "TCG Error Count", json_object_new_int (le32_to_cpu(log_data->tcg_ec))); | |||
| 1163 | ||||
| 1164 | res_arr[0] = '\0'; | |||
| 1165 | if (log_page_version == 1) { | |||
| 1166 | concat_bytes(res_arr, sizeof(res_arr), | |||
| 1167 | (__u8 *)&log_data->no_of_ns_prov_locking_obj_ext, | |||
| 1168 | 2, false0); | |||
| 1169 | } else { | |||
| 1170 | json_object_add_value_int(root,json_object_object_add(root, "Number of Namespace Provisioned Locking Objects Extended" , json_object_new_int(log_data->no_of_ns_prov_locking_obj_ext )) | |||
| 1171 | "Number of Namespace Provisioned Locking Objects Extended",json_object_object_add(root, "Number of Namespace Provisioned Locking Objects Extended" , json_object_new_int(log_data->no_of_ns_prov_locking_obj_ext )) | |||
| 1172 | log_data->no_of_ns_prov_locking_obj_ext)json_object_object_add(root, "Number of Namespace Provisioned Locking Objects Extended" , json_object_new_int(log_data->no_of_ns_prov_locking_obj_ext )); | |||
| 1173 | } | |||
| 1174 | ||||
| 1175 | concat_bytes(res_arr, sizeof(res_arr), log_data->rsvd38, 456, false0); | |||
| 1176 | json_object_add_value_string(root, "Reserved3", res_arr); | |||
| 1177 | ||||
| 1178 | json_object_add_value_int(root, "Log Page Version", log_page_version)json_object_object_add(root, "Log Page Version", json_object_new_int (log_page_version)); | |||
| 1179 | ||||
| 1180 | shr_bin_to_hex(guid_buf, sizeof(guid_buf), log_data->log_page_guid, | |||
| 1181 | GUID_LEN16, SHR_HEX_REVERSE(1 << 1)); | |||
| 1182 | json_object_add_value_string(root, "Log page GUID", guid_buf); | |||
| 1183 | ||||
| 1184 | json_print_object(root, NULL)printf("%s", json_object_to_json_string_ext(root, (1 << 1) | (1 << 4))); | |||
| 1185 | printf("\n"); | |||
| 1186 | ||||
| 1187 | json_free_object(root)json_object_put(root); | |||
| 1188 | } | |||
| 1189 | ||||
| 1190 | static void pel_tcg_activity_event(void *pevent_log_info, __u32 offset, | |||
| 1191 | struct json_object *valid_attrs) | |||
| 1192 | { | |||
| 1193 | __u16 vsedl; | |||
| 1194 | struct nvme_vs_event_desc *vs_desc; | |||
| 1195 | struct tcg_activity_event_data *tcg_event_data; | |||
| 1196 | struct json_object *tcg_event_obj = json_create_object()json_object_new_object(); | |||
| 1197 | ||||
| 1198 | vs_desc = pevent_log_info + offset; | |||
| 1199 | tcg_event_data = (struct tcg_activity_event_data *)(vs_desc + 1); | |||
| 1200 | vsedl = le16_to_cpu(vs_desc->vsedl); | |||
| 1201 | ||||
| 1202 | /* Only one descriptor (0) defined for the TCG Activity Event */ | |||
| 1203 | json_object_add_value_uint(tcg_event_obj, "vendor_specific_event_descriptor",json_object_object_add(tcg_event_obj, "vendor_specific_event_descriptor" , json_object_new_uint64(0)) | |||
| 1204 | 0)json_object_object_add(tcg_event_obj, "vendor_specific_event_descriptor" , json_object_new_uint64(0)); | |||
| 1205 | json_object_add_value_uint(tcg_event_obj, "vendor_specific_event_code",json_object_object_add(tcg_event_obj, "vendor_specific_event_code" , json_object_new_uint64(le16_to_cpu(vs_desc->vsec))) | |||
| 1206 | le16_to_cpu(vs_desc->vsec))json_object_object_add(tcg_event_obj, "vendor_specific_event_code" , json_object_new_uint64(le16_to_cpu(vs_desc->vsec))); | |||
| 1207 | json_object_add_value_uint(tcg_event_obj, "vendor_specific_event_data_type",json_object_object_add(tcg_event_obj, "vendor_specific_event_data_type" , json_object_new_uint64(vs_desc->vsedt)) | |||
| 1208 | vs_desc->vsedt)json_object_object_add(tcg_event_obj, "vendor_specific_event_data_type" , json_object_new_uint64(vs_desc->vsedt)); | |||
| 1209 | json_object_add_value_uint(tcg_event_obj, "vendor_specific_event_uindex",json_object_object_add(tcg_event_obj, "vendor_specific_event_uindex" , json_object_new_uint64(vs_desc->uidx)) | |||
| 1210 | vs_desc->uidx)json_object_object_add(tcg_event_obj, "vendor_specific_event_uindex" , json_object_new_uint64(vs_desc->uidx)); | |||
| 1211 | json_object_add_value_uint(tcg_event_obj, "vendor_specific_event_data_length",json_object_object_add(tcg_event_obj, "vendor_specific_event_data_length" , json_object_new_uint64(vsedl)) | |||
| 1212 | vsedl)json_object_object_add(tcg_event_obj, "vendor_specific_event_data_length" , json_object_new_uint64(vsedl)); | |||
| 1213 | json_object_add_value_uint(tcg_event_obj, "tcg_command_count",json_object_object_add(tcg_event_obj, "tcg_command_count", json_object_new_uint64 (le32_to_cpu(tcg_event_data->tcg_command_count))) | |||
| 1214 | le32_to_cpu(tcg_event_data->tcg_command_count))json_object_object_add(tcg_event_obj, "tcg_command_count", json_object_new_uint64 (le32_to_cpu(tcg_event_data->tcg_command_count))); | |||
| 1215 | json_object_add_value_uint64(tcg_event_obj, "invoking_id",json_object_object_add(tcg_event_obj, "invoking_id", json_object_new_uint64 (le64_to_cpu(tcg_event_data->invoking_id))) | |||
| 1216 | le64_to_cpu(tcg_event_data->invoking_id))json_object_object_add(tcg_event_obj, "invoking_id", json_object_new_uint64 (le64_to_cpu(tcg_event_data->invoking_id))); | |||
| 1217 | json_object_add_value_uint64(tcg_event_obj, "method_id",json_object_object_add(tcg_event_obj, "method_id", json_object_new_uint64 (le64_to_cpu(tcg_event_data->method_id))) | |||
| 1218 | le64_to_cpu(tcg_event_data->method_id))json_object_object_add(tcg_event_obj, "method_id", json_object_new_uint64 (le64_to_cpu(tcg_event_data->method_id))); | |||
| 1219 | json_object_add_value_uint(tcg_event_obj, "com_id",json_object_object_add(tcg_event_obj, "com_id", json_object_new_uint64 (le16_to_cpu(tcg_event_data->com_id))) | |||
| 1220 | le16_to_cpu(tcg_event_data->com_id))json_object_object_add(tcg_event_obj, "com_id", json_object_new_uint64 (le16_to_cpu(tcg_event_data->com_id))); | |||
| 1221 | json_object_add_value_uint(tcg_event_obj, "protocol_id",json_object_object_add(tcg_event_obj, "protocol_id", json_object_new_uint64 (tcg_event_data->protocol_id)) | |||
| 1222 | tcg_event_data->protocol_id)json_object_object_add(tcg_event_obj, "protocol_id", json_object_new_uint64 (tcg_event_data->protocol_id)); | |||
| 1223 | json_object_add_value_uint(tcg_event_obj, "status",json_object_object_add(tcg_event_obj, "status", json_object_new_uint64 (tcg_event_data->status)) | |||
| 1224 | tcg_event_data->status)json_object_object_add(tcg_event_obj, "status", json_object_new_uint64 (tcg_event_data->status)); | |||
| 1225 | json_object_add_value_uint(tcg_event_obj, "process_time",json_object_object_add(tcg_event_obj, "process_time", json_object_new_uint64 (le16_to_cpu(tcg_event_data->process_time))) | |||
| 1226 | le16_to_cpu(tcg_event_data->process_time))json_object_object_add(tcg_event_obj, "process_time", json_object_new_uint64 (le16_to_cpu(tcg_event_data->process_time))); | |||
| 1227 | obj_d(tcg_event_obj, "tcg_activity_specific_context", | |||
| 1228 | (void *)tcg_event_data->tcg_activity_specific_context, 10, 16, 1); | |||
| 1229 | ||||
| 1230 | json_object_add_value_object(valid_attrs, "tcg_activity_event_data",json_object_object_add(valid_attrs, "tcg_activity_event_data" , tcg_event_obj) | |||
| 1231 | tcg_event_obj)json_object_object_add(valid_attrs, "tcg_activity_event_data" , tcg_event_obj); | |||
| 1232 | } | |||
| 1233 | ||||
| 1234 | static void json_pevent_entry(void *pevent_log_info, __u8 action, __u32 size, const char *devname, | |||
| 1235 | __u32 offset, struct json_object *valid) | |||
| 1236 | { | |||
| 1237 | int i; | |||
| 1238 | __u16 vsil, el; | |||
| 1239 | __u32 data_len; | |||
| 1240 | struct nvme_persistent_event_log *pevent_log_head = pevent_log_info; | |||
| 1241 | struct nvme_persistent_event_entry *pevent_entry_head; | |||
| 1242 | struct json_object *valid_attrs; | |||
| 1243 | ||||
| 1244 | for (i = 0; i < le32_to_cpu(pevent_log_head->tnev); i++) { | |||
| 1245 | pevent_entry_head = nvme_pel_event(pevent_log_info, size, | |||
| 1246 | offset); | |||
| 1247 | if (!pevent_entry_head) | |||
| 1248 | break; | |||
| 1249 | ||||
| 1250 | vsil = le16_to_cpu(pevent_entry_head->vsil); | |||
| 1251 | el = le16_to_cpu(pevent_entry_head->el); | |||
| 1252 | ||||
| 1253 | valid_attrs = json_create_object()json_object_new_object(); | |||
| 1254 | ||||
| 1255 | obj_add_uint(valid_attrs, "event_number", i)json_object_object_add(valid_attrs, "event_number", json_object_new_uint64 (i)); | |||
| 1256 | obj_add_strjson_object_add_value_string(valid_attrs, "event_type", | |||
| 1257 | nvme_pel_event_to_string(pevent_entry_head->etype)); | |||
| 1258 | obj_add_uint(valid_attrs, "event_type_rev", pevent_entry_head->etype_rev)json_object_object_add(valid_attrs, "event_type_rev", json_object_new_uint64 (pevent_entry_head->etype_rev)); | |||
| 1259 | obj_add_uint(valid_attrs, "event_header_len", pevent_entry_head->ehl)json_object_object_add(valid_attrs, "event_header_len", json_object_new_uint64 (pevent_entry_head->ehl)); | |||
| 1260 | obj_add_uint(valid_attrs, "event_header_additional_info", pevent_entry_head->ehai)json_object_object_add(valid_attrs, "event_header_additional_info" , json_object_new_uint64(pevent_entry_head->ehai)); | |||
| 1261 | obj_add_uint(valid_attrs, "ctrl_id", le16_to_cpu(pevent_entry_head->cntlid))json_object_object_add(valid_attrs, "ctrl_id", json_object_new_uint64 (le16_to_cpu(pevent_entry_head->cntlid))); | |||
| 1262 | obj_add_uint64(valid_attrs, "event_time_stamp",json_object_object_add(valid_attrs, "event_time_stamp", json_object_new_uint64 (le64_to_cpu(pevent_entry_head->ets))) | |||
| 1263 | le64_to_cpu(pevent_entry_head->ets))json_object_object_add(valid_attrs, "event_time_stamp", json_object_new_uint64 (le64_to_cpu(pevent_entry_head->ets))); | |||
| 1264 | obj_add_uint(valid_attrs, "port_id", le16_to_cpu(pevent_entry_head->pelpid))json_object_object_add(valid_attrs, "port_id", json_object_new_uint64 (le16_to_cpu(pevent_entry_head->pelpid))); | |||
| 1265 | obj_add_uint(valid_attrs, "vu_info_len", vsil)json_object_object_add(valid_attrs, "vu_info_len", json_object_new_uint64 (vsil)); | |||
| 1266 | obj_add_uint(valid_attrs, "event_len", el)json_object_object_add(valid_attrs, "event_len", json_object_new_uint64 (el)); | |||
| 1267 | ||||
| 1268 | if (vsil) | |||
| 1269 | obj_d(valid_attrs, "vs_info_bin", | |||
| 1270 | (void *)pevent_entry_head + 1, vsil, 16, 1); | |||
| 1271 | ||||
| 1272 | offset += pevent_entry_head->ehl + vsil + 3; | |||
| 1273 | ||||
| 1274 | __cleanup_free__attribute__((cleanup(shr_freep))) void *data = | |||
| 1275 | nvme_pel_event_data(pevent_log_info, offset, | |||
| 1276 | el - vsil, &data_len); | |||
| 1277 | ||||
| 1278 | if (!data) { | |||
| 1279 | array_add_obj(valid, valid_attrs)json_object_array_add(valid, valid_attrs); | |||
| 1280 | break; | |||
| 1281 | } | |||
| 1282 | ||||
| 1283 | switch (pevent_entry_head->etype) { | |||
| 1284 | case NVME_PEL_SMART_HEALTH_EVENT: | |||
| 1285 | nvme_json_pel_smart_health(data, 0, | |||
| 1286 | valid_attrs); | |||
| 1287 | break; | |||
| 1288 | case NVME_PEL_FW_COMMIT_EVENT: | |||
| 1289 | nvme_json_pel_fw_commit(data, 0, | |||
| 1290 | valid_attrs); | |||
| 1291 | break; | |||
| 1292 | case NVME_PEL_TIMESTAMP_EVENT: | |||
| 1293 | nvme_json_pel_timestamp(data, 0, | |||
| 1294 | valid_attrs); | |||
| 1295 | break; | |||
| 1296 | case NVME_PEL_POWER_ON_RESET_EVENT: | |||
| 1297 | nvme_json_pel_power_on_reset(data, 0, valid_attrs, | |||
| 1298 | pevent_entry_head->vsil, | |||
| 1299 | pevent_entry_head->el, | |||
| 1300 | data_len); | |||
| 1301 | break; | |||
| 1302 | case NVME_PEL_NSS_HW_ERROR_EVENT: | |||
| 1303 | nvme_json_pel_nss_hw_error(data, 0, | |||
| 1304 | valid_attrs); | |||
| 1305 | break; | |||
| 1306 | case NVME_PEL_CHANGE_NS_EVENT: | |||
| 1307 | nvme_json_pel_change_ns(data, 0, valid_attrs); | |||
| 1308 | break; | |||
| 1309 | case NVME_PEL_FORMAT_START_EVENT: | |||
| 1310 | nvme_json_pel_format_start(data, 0, valid_attrs); | |||
| 1311 | break; | |||
| 1312 | case NVME_PEL_FORMAT_COMPLETION_EVENT: | |||
| 1313 | nvme_json_pel_format_completion(data, 0, valid_attrs); | |||
| 1314 | break; | |||
| 1315 | case NVME_PEL_SANITIZE_START_EVENT: | |||
| 1316 | nvme_json_pel_sanitize_start(data, 0, valid_attrs); | |||
| 1317 | break; | |||
| 1318 | case NVME_PEL_SANITIZE_COMPLETION_EVENT: | |||
| 1319 | nvme_json_pel_sanitize_completion(data, 0, valid_attrs); | |||
| 1320 | break; | |||
| 1321 | case NVME_PEL_SET_FEATURE_EVENT: | |||
| 1322 | nvme_json_pel_set_feature(data, el - vsil, | |||
| 1323 | valid_attrs); | |||
| 1324 | break; | |||
| 1325 | case NVME_PEL_TELEMETRY_CRT: | |||
| 1326 | nvme_json_pel_telemetry_crt(data, 0, valid_attrs, | |||
| 1327 | pevent_entry_head->el, | |||
| 1328 | data_len); | |||
| 1329 | break; | |||
| 1330 | case NVME_PEL_THERMAL_EXCURSION_EVENT: | |||
| 1331 | nvme_json_pel_thermal_excursion(data, 0, valid_attrs); | |||
| 1332 | break; | |||
| 1333 | case NVME_PEL_VENDOR_SPECIFIC_EVENT: | |||
| 1334 | if (ocp_is_tcg_activity_event(pevent_entry_head, el, | |||
| 1335 | vsil)) | |||
| 1336 | pel_tcg_activity_event(data, 0, | |||
| 1337 | valid_attrs); | |||
| 1338 | else | |||
| 1339 | nvme_json_pel_vendor_specific_event(data, | |||
| 1340 | 0, el - vsil, | |||
| 1341 | valid_attrs); | |||
| 1342 | break; | |||
| 1343 | default: | |||
| 1344 | break; | |||
| 1345 | } | |||
| 1346 | ||||
| 1347 | array_add_obj(valid, valid_attrs)json_object_array_add(valid, valid_attrs); | |||
| 1348 | offset += el - vsil; | |||
| 1349 | } | |||
| 1350 | } | |||
| 1351 | ||||
| 1352 | static void json_persistent_event_log(void *pevent_log_info, __u8 action, | |||
| 1353 | __u32 size, const char *devname) | |||
| 1354 | { | |||
| 1355 | struct json_object *r = json_create_object()json_object_new_object(); | |||
| 1356 | struct json_object *valid; | |||
| 1357 | __u32 offset = sizeof(struct nvme_persistent_event_log); | |||
| 1358 | ||||
| 1359 | if (size >= offset) { | |||
| 1360 | valid = json_create_array()json_object_new_array(); | |||
| 1361 | nvme_json_pevent_log_head(pevent_log_info, r); | |||
| 1362 | json_pevent_entry(pevent_log_info, action, size, devname, offset, valid); | |||
| 1363 | obj_add_array(r, "list_of_event_entries", valid)json_object_object_add(r, "list_of_event_entries", valid); | |||
| 1364 | } else { | |||
| 1365 | obj_add_result(r, "No log data can be shown with this log len at least " \ | |||
| 1366 | "512 bytes is required or can be 0 to read the complete " \ | |||
| 1367 | "log page after context established"); | |||
| 1368 | } | |||
| 1369 | ||||
| 1370 | json_print(r); | |||
| 1371 | } | |||
| 1372 | ||||
| 1373 | static struct ocp_print_ops json_print_ops = { | |||
| 1374 | .hwcomp_log = json_hwcomp_log, | |||
| 1375 | .fw_act_history = json_fw_activation_history, | |||
| 1376 | .persistent_event_log = json_persistent_event_log, | |||
| 1377 | .smart_extended_log = json_smart_extended_log, | |||
| 1378 | .telemetry_log = json_telemetry_log, | |||
| 1379 | .c3_log = json_c3_log, | |||
| 1380 | .c5_log = json_c5_log, | |||
| 1381 | .c1_log = json_c1_log, | |||
| 1382 | .c4_log = json_c4_log, | |||
| 1383 | .c9_log = json_c9_log, | |||
| 1384 | .c7_log = json_c7_log, | |||
| 1385 | }; | |||
| 1386 | ||||
| 1387 | struct ocp_print_ops *ocp_get_json_print_ops(nvme_print_flags_t flags) | |||
| 1388 | { | |||
| 1389 | json_print_ops.flags = flags; | |||
| 1390 | return &json_print_ops; | |||
| 1391 | } |
| 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ | |||
| 2 | /* Copyright (c) 2024 Western Digital Corporation or its affiliates. | |||
| 3 | * | |||
| 4 | * Authors: Jeff Lien <jeff.lien@wdc.com>, | |||
| 5 | */ | |||
| 6 | #pragma once | |||
| 7 | ||||
| 8 | #include <ccan/array_size/array_size.h> | |||
| 9 | #include <shared/compiler-attributes-util.h> | |||
| 10 | ||||
| 11 | #include <libnvme.h> | |||
| 12 | ||||
| 13 | #include "nvme-print.h" | |||
| 14 | #include "field-parser.h" | |||
| 15 | ||||
| 16 | #include "ocp-nvme.h" | |||
| 17 | ||||
| 18 | extern __u8 *ptelemetry_buffer; | |||
| 19 | extern size_t ptelemetry_buffer_size; | |||
| 20 | extern __u8 *pstring_buffer; | |||
| 21 | extern size_t pstring_buffer_size; | |||
| 22 | ||||
| 23 | #define OCP_TELEMETRY_DESCRIPTION_MAX256 256 | |||
| 24 | ||||
| 25 | /***************************************************************************** | |||
| 26 | * Telemetry SMBUS/I2C/I3C (0Ch) Event ID's and Event Data Strings | |||
| 27 | *****************************************************************************/ | |||
| 28 | enum TELEMETRY_SMBUS_EVENT_ID { | |||
| 29 | SMBUS_TIMEOUT_ERRORS = 0x0000, | |||
| 30 | SMBUS_PEC_ERRORS = 0x0001, | |||
| 31 | SMBUS_ARBITRATION_LOSS = 0x0002, | |||
| 32 | SMBUS_NACK_ERROR = 0x0003, | |||
| 33 | }; | |||
| 34 | ||||
| 35 | static const char * const telemetry_smbus_nack_event_data_str[] = { | |||
| 36 | [0x0000] = "Received invalid command or data", | |||
| 37 | [0x0001] = "Device is busy", | |||
| 38 | [0x0002] = "Requested data is not available", | |||
| 39 | }; | |||
| 40 | ||||
| 41 | /***************************************************************************** | |||
| 42 | * Telemetry MCTP (0Dh) Event ID's, Event Data and Transport Protocol Strings | |||
| 43 | *****************************************************************************/ | |||
| 44 | enum TELEMETRY_MCTP_EVENT_ID { | |||
| 45 | MCTP_DROPPED_PACKET = 0x0000, | |||
| 46 | MCTP_DROPPED_MESSAGE = 0x0001, | |||
| 47 | MCTP_DISCOVERY_ADDRESSING_ERRORS = 0x0002, | |||
| 48 | MCTP_ERROR_STATUS = 0x0003, | |||
| 49 | }; | |||
| 50 | ||||
| 51 | static const char * const telemetry_mctp_dropped_packet_data_str[] = { | |||
| 52 | [0x0000] = "Unexpected middle or end packet", | |||
| 53 | [0x0001] = "Bad packet data integrity or other physical layer error: Framing errors", | |||
| 54 | [0x0002] = "Bad packet data integrity or other physical layer error: Byte alignment errors", | |||
| 55 | [0x0003] = "Bad packet data integrity or other physical layer error: Invalid packet size", | |||
| 56 | [0x0004] = "Unexpected or expired message tag", | |||
| 57 | [0x0005] = "Unknown destination EID", | |||
| 58 | [0x0006] = "Unsupported MCTP header version", | |||
| 59 | [0x0007] = "Unsupported transmission unit size", | |||
| 60 | }; | |||
| 61 | ||||
| 62 | static const char * const telemetry_mctp_dropped_message_data_str[] = { | |||
| 63 | [0x0000] = "Receipt of a new start packet", | |||
| 64 | [0x0001] = "Timeout waiting for a packet + threshold", | |||
| 65 | [0x0002] = "Out-of-sequence packet sequence number", | |||
| 66 | [0x0003] = "Incorrect transmission unit", | |||
| 67 | [0x0004] = "Bad message integrity check", | |||
| 68 | [0x0005] = "Invalid message type received", | |||
| 69 | }; | |||
| 70 | ||||
| 71 | static const char * const telemetry_mctp_discovery_data_str[] = { | |||
| 72 | [0x0000] = "Transport Binding specific bus enumeration errors", | |||
| 73 | [0x0001] = "Transport Binding specific bus address assignment errors", | |||
| 74 | }; | |||
| 75 | ||||
| 76 | static const char * const telemetry_mctp_error_status_data_str[] = { | |||
| 77 | [0x0000] = "Reserved", | |||
| 78 | [0x0001] = "ERROR", | |||
| 79 | [0x0002] = "ERROR_INVALID_DATA", | |||
| 80 | [0x0003] = "ERROR_INVALID_LENGTH", | |||
| 81 | [0x0004] = "ERROR_NOT_READY", | |||
| 82 | [0x0005] = "ERROR_UNSUPPORTED_CMD", | |||
| 83 | [0x0006] = "COMMAND_SPECIFIC", | |||
| 84 | }; | |||
| 85 | ||||
| 86 | static const char * const telemetry_mctp_transport_protocol_str[] = { | |||
| 87 | [0x00] = "PCIe VDM on device PCIe port 0", | |||
| 88 | [0x01] = "PCIe VDM on device PCIe port 1", | |||
| 89 | [0x04] = "I2C/SMBus", | |||
| 90 | [0x05] = "I3C", | |||
| 91 | }; | |||
| 92 | ||||
| 93 | ||||
| 94 | /***************************************************************************** | |||
| 95 | * Telemetry Data Structures | |||
| 96 | *****************************************************************************/ | |||
| 97 | enum TELEMETRY_TYPE { | |||
| 98 | TELEMETRY_TYPE_HOST = 7, | |||
| 99 | TELEMETRY_TYPE_CONTROLLER = 8, | |||
| 100 | }; | |||
| 101 | ||||
| 102 | #define DATA_SIZE_1212 12 | |||
| 103 | #define DATA_SIZE_88 8 | |||
| 104 | #define DATA_SIZE_44 4 | |||
| 105 | #define MAX_BUFFER_32_KB0x8000 0x8000 | |||
| 106 | #define OCP_TELEMETRY_DATA_BLOCK_SIZE512 512 | |||
| 107 | #define SIZE_OF_DWORD4 4 | |||
| 108 | #define MAX_NUM_FIFOS16 16 | |||
| 109 | #define DA1_OFFSET512 512 | |||
| 110 | #define DEFAULT_ASCII_STRING_SIZE16 16 | |||
| 111 | #define SIZE_OF_VU_EVENT_ID2 2 | |||
| 112 | ||||
| 113 | /* VU Virtual FIFO Identifier: 15:11 physical FIFO, 10:0 virtual FIFO */ | |||
| 114 | #define VU_VIRTUAL_FIFO_PHY_NUM_SHIFT11 11 | |||
| 115 | #define VU_VIRTUAL_FIFO_NUM_MASK0x07ff 0x07ff | |||
| 116 | ||||
| 117 | /* MCTP Event Flags bit 7: the MCTP Transport Header field is valid */ | |||
| 118 | #define MCTP_EVENT_FLAG_TRANSPORT_HEADER_VALID0x80 0x80 | |||
| 119 | ||||
| 120 | #define DEFAULT_TELEMETRY_LOG"telemetry-log" "telemetry-log" | |||
| 121 | #define DEFAULT_STRING_BIN"string.bin" "string.bin" | |||
| 122 | #ifdef CONFIG_JSONC | |||
| 123 | #define DEFAULT_OUTPUT_FORMAT"json" "json" | |||
| 124 | #else /* CONFIG_JSONC */ | |||
| 125 | #define DEFAULT_OUTPUT_FORMAT"json" "normal" | |||
| 126 | #endif /* CONFIG_JSONC */ | |||
| 127 | ||||
| 128 | /* C9 Telemetry String Log Format Log Page */ | |||
| 129 | #define C9_TELEMETRY_STR_LOG_LEN432 432 | |||
| 130 | #define C9_TELEMETRY_STR_LOG_SIST_OFST431 431 | |||
| 131 | ||||
| 132 | #define STR_LOG_PAGE_HEADER"Log Page Header" "Log Page Header" | |||
| 133 | #define STR_REASON_IDENTIFIER"Reason Identifier" "Reason Identifier" | |||
| 134 | #define STR_TELEMETRY_HOST_DATA_BLOCK_1"Telemetry Host-Initiated Data Block 1" "Telemetry Host-Initiated Data Block 1" | |||
| 135 | #define STR_SMART_HEALTH_INFO"SMART / Health Information Log(LID-02h)" "SMART / Health Information Log(LID-02h)" | |||
| 136 | #define STR_SMART_HEALTH_INTO_EXTENDED"SMART / Health Information Extended(LID-C0h)" "SMART / Health Information Extended(LID-C0h)" | |||
| 137 | #define STR_DA_1_STATS"Data Area 1 Statistics" "Data Area 1 Statistics" | |||
| 138 | #define STR_DA_2_STATS"Data Area 2 Statistics" "Data Area 2 Statistics" | |||
| 139 | #define STR_DA_1_EVENT_FIFO_INFO"Data Area 1 Event FIFO info" "Data Area 1 Event FIFO info" | |||
| 140 | #define STR_DA_2_EVENT_FIFO_INFO"Data Area 2 Event FIFO info" "Data Area 2 Event FIFO info" | |||
| 141 | #define STR_STATISTICS_IDENTIFIER"Statistics Identifier" "Statistics Identifier" | |||
| 142 | #define STR_STATISTICS_IDENTIFIER_STR"Statistic Identifier String" "Statistic Identifier String" | |||
| 143 | #define STR_STATISTICS_INFO_BEHAVIOUR_TYPE"Statistics Info Behavior Type" "Statistics Info Behavior Type" | |||
| 144 | #define STR_STATISTICS_INFO_CONTEXT_INDEX"Statistics Info Context Index" "Statistics Info Context Index" | |||
| 145 | #define STR_STATISTICS_INFO_HOST_HINT_TYPE"Statistics Info Host Hint Type" "Statistics Info Host Hint Type" | |||
| 146 | #define STR_STATISTICS_INFO_RESERVED"Statistics Info Reserved" "Statistics Info Reserved" | |||
| 147 | #define STR_NAMESPACE_IDENTIFIER"Namespace Identifier" "Namespace Identifier" | |||
| 148 | #define STR_NAMESPACE_INFO_VALID"Namespace Information Valid" "Namespace Information Valid" | |||
| 149 | #define STR_STATISTICS_DATA_SIZE"Statistic Data Size" "Statistic Data Size" | |||
| 150 | #define STR_NAMESPACE_IDENTIFIER_15_0"Namespace Identifier[15:0]" "Namespace Identifier[15:0]" | |||
| 151 | #define STR_STATISTICS_SPECIFIC_DATA"Statistic Specific Data" "Statistic Specific Data" | |||
| 152 | #define STR_CONTEXT_DATA_SIZE"Context Data Size" "Context Data Size" | |||
| 153 | #define STR_CONTEXT_DATA_RESERVED"Context Data Reserved" "Context Data Reserved" | |||
| 154 | #define STR_CONTEXT_SCOPE"Context Scope" "Context Scope" | |||
| 155 | #define STR_CONTEXT_SCOPE_FIELDS"Context Scope Fields" "Context Scope Fields" | |||
| 156 | #define STR_SCOPE_FIELD_STRING"Scope Field String" "Scope Field String" | |||
| 157 | #define STR_SCOPE_FIELD_OFFSET"Scope Field Offset" "Scope Field Offset" | |||
| 158 | #define STR_SCOPE_FIELD_SIZE"Scope Field Size" "Scope Field Size" | |||
| 159 | #define STR_SCOPE_FIELD_VALUE"Scope Field Value" "Scope Field Value" | |||
| 160 | #define STR_ENCAPSULATED_STATISTICS"Encapsulated Statistic Descriptors" "Encapsulated Statistic Descriptors" | |||
| 161 | #define STR_CONTEXT_NAMESPACE_ID"Namespace ID" "Namespace ID" | |||
| 162 | #define STR_CONTEXT_CONTROLLER_ID"Controller ID" "Controller ID" | |||
| 163 | #define STR_CONTEXT_QUEUE_ID"Queue ID" "Queue ID" | |||
| 164 | #define STR_STATISTICS_WORST_DIE_PERCENT"Worst die % of bad blocks" "Worst die % of bad blocks" | |||
| 165 | #define STR_STATISTICS_WORST_DIE_RAW"Worst die raw number of bad blocks" "Worst die raw number of bad blocks" | |||
| 166 | #define STR_STATISTICS_WORST_NAND_CHANNEL_PERCENT"Worst NAND channel % of bad blocks" "Worst NAND channel % of bad blocks" | |||
| 167 | #define STR_STATISTICS_WORST_NAND_CHANNEL_RAW"Worst NAND channel number of bad blocks" "Worst NAND channel number of bad blocks" | |||
| 168 | #define STR_STATISTICS_BEST_NAND_CHANNEL_PERCENT"Best NAND channel % of bad blocks" "Best NAND channel % of bad blocks" | |||
| 169 | #define STR_STATISTICS_BEST_NAND_CHANNEL_RAW"Best NAND channel number of bad blocks" "Best NAND channel number of bad blocks" | |||
| 170 | #define STR_CLASS_SPECIFIC_DATA"Class Specific Data" "Class Specific Data" | |||
| 171 | #define STR_DBG_EVENT_CLASS_TYPE"Debug Event Class type" "Debug Event Class type" | |||
| 172 | #define STR_EVENT_IDENTIFIER"Event Identifier" "Event Identifier" | |||
| 173 | #define STR_EVENT_STRING"Event String" "Event String" | |||
| 174 | #define STR_EVENT_DATA_SIZE"Event Data Size" "Event Data Size" | |||
| 175 | #define STR_VU_EVENT_STRING"VU Event String" "VU Event String" | |||
| 176 | #define STR_VU_EVENT_ID_STRING"VU Event Identifier" "VU Event Identifier" | |||
| 177 | #define STR_VU_DATA"VU Data" "VU Data" | |||
| 178 | #define STR_VU_VIRTUAL_FIFO_ID"VU Virtual FIFO Identifier" "VU Virtual FIFO Identifier" | |||
| 179 | #define STR_VU_VIRTUAL_FIFO_STRING"VU Virtual FIFO String" "VU Virtual FIFO String" | |||
| 180 | #define STR_PHYSICAL_EVENT_FIFO_NUM"Physical Event FIFO Number" "Physical Event FIFO Number" | |||
| 181 | #define STR_PHYSICAL_EVENT_FIFO_STRING"Physical Event FIFO String" "Physical Event FIFO String" | |||
| 182 | #define STR_VIRTUAL_FIFO_NUM"Virtual FIFO Number" "Virtual FIFO Number" | |||
| 183 | #define STR_SMBUS_DEBUG_EVENT_DATA"SMBUS Debug Event Data" "SMBUS Debug Event Data" | |||
| 184 | #define STR_SMBUS_DEBUG_EVENT_DATA_STRING"SMBUS Debug Event Data String" "SMBUS Debug Event Data String" | |||
| 185 | #define STR_MCTP_DEBUG_EVENT_DATA"MCTP Debug Event Data" "MCTP Debug Event Data" | |||
| 186 | #define STR_MCTP_DEBUG_EVENT_DATA_STRING"MCTP Debug Event Data String" "MCTP Debug Event Data String" | |||
| 187 | #define STR_MCTP_TRANSPORT_PROTOCOL"MCTP Transport Protocol Information" "MCTP Transport Protocol Information" | |||
| 188 | #define STR_MCTP_TRANSPORT_PROTOCOL_STRING"MCTP Transport Protocol String" "MCTP Transport Protocol String" | |||
| 189 | #define STR_MCTP_TRANSPORT_HEADER_VALID"MCTP Transport Header Valid" "MCTP Transport Header Valid" | |||
| 190 | #define STR_MCTP_TRANSPORT_HEADER"MCTP Transport Header" "MCTP Transport Header" | |||
| 191 | #define STR_LINE"==============================================================================\n" "==============================================================================\n" | |||
| 192 | #define STR_LINE2"-----------------------------------------------------------------------------\n" "-----------------------------------------------------------------------------\n" | |||
| 193 | ||||
| 194 | /** | |||
| 195 | * enum ocp_telemetry_data_area - Telemetry Data Areas | |||
| 196 | * @DATA_AREA_1: Data Area 1 | |||
| 197 | * @DATA_AREA_2: Data Area 2 | |||
| 198 | * @DATA_AREA_3: Data Area 3 | |||
| 199 | * @DATA_AREA_4: Data Area 4 | |||
| 200 | */ | |||
| 201 | enum ocp_telemetry_data_area { | |||
| 202 | DATA_AREA_1 = 0x01, | |||
| 203 | DATA_AREA_2 = 0x02, | |||
| 204 | DATA_AREA_3 = 0x03, | |||
| 205 | DATA_AREA_4 = 0x04, | |||
| 206 | }; | |||
| 207 | ||||
| 208 | /** | |||
| 209 | * enum ocp_telemetry_string_tables - OCP telemetry string tables | |||
| 210 | * @STATISTICS_IDENTIFIER_STRING: Statistic Identifier string | |||
| 211 | * @EVENT_STRING: Event String | |||
| 212 | * @VU_EVENT_STRING: VU Event String | |||
| 213 | */ | |||
| 214 | enum ocp_telemetry_string_tables { | |||
| 215 | STATISTICS_IDENTIFIER_STRING = 0, | |||
| 216 | EVENT_STRING, | |||
| 217 | VU_EVENT_STRING | |||
| 218 | }; | |||
| 219 | ||||
| 220 | /** | |||
| 221 | * enum ocp_telemetry_statistics_identifiers - OCP Statistics Identifiers | |||
| 222 | */ | |||
| 223 | enum ocp_telemetry_statistic_identifiers { | |||
| 224 | STATISTICS_RESERVED_ID = 0x00, | |||
| 225 | OUTSTANDING_ADMIN_CMDS_ID = 0x01, | |||
| 226 | HOST_WRTIE_BANDWIDTH_ID = 0x02, | |||
| 227 | GW_WRITE_BANDWITH_ID = 0x03, | |||
| 228 | ACTIVE_NAMESPACES_ID = 0x04, | |||
| 229 | INTERNAL_WRITE_WORKLOAD_ID = 0x05, | |||
| 230 | INTERNAL_READ_WORKLOAD_ID = 0x06, | |||
| 231 | INTERNAL_WRITE_QUEUE_DEPTH_ID = 0x07, | |||
| 232 | INTERNAL_READ_QUEUE_DEPTH_ID = 0x08, | |||
| 233 | PENDING_TRIM_LBA_COUNT_ID = 0x09, | |||
| 234 | HOST_TRIM_LBA_REQUEST_COUNT_ID = 0x0A, | |||
| 235 | CURRENT_NVME_POWER_STATE_ID = 0x0B, | |||
| 236 | CURRENT_DSSD_POWER_STATE_ID = 0x0C, | |||
| 237 | PROGRAM_FAIL_COUNT_ID = 0x0D, | |||
| 238 | ERASE_FAIL_COUNT_ID = 0x0E, | |||
| 239 | READ_DISTURB_WRITES_ID = 0x0F, | |||
| 240 | ||||
| 241 | RETENTION_WRITES_ID = 0x10, | |||
| 242 | WEAR_LEVELING_WRITES_ID = 0x11, | |||
| 243 | READ_RECOVERY_WRITES_ID = 0x12, | |||
| 244 | GC_WRITES_ID = 0x13, | |||
| 245 | SRAM_CORRECTABLE_COUNT_ID = 0x14, | |||
| 246 | DRAM_CORRECTABLE_COUNT_ID = 0x15, | |||
| 247 | SRAM_UNCORRECTABLE_COUNT_ID = 0x16, | |||
| 248 | DRAM_UNCORRECTABLE_COUNT_ID = 0x17, | |||
| 249 | DATA_INTEGRITY_ERROR_COUNT_ID = 0x18, | |||
| 250 | READ_RETRY_ERROR_COUNT_ID = 0x19, | |||
| 251 | PERST_EVENTS_COUNT_ID = 0x1A, | |||
| 252 | MAX_DIE_BAD_BLOCK_ID = 0x1B, | |||
| 253 | MAX_NAND_CHANNEL_BAD_BLOCK_ID = 0x1C, | |||
| 254 | MIN_NAND_CHANNEL_BAD_BLOCK_ID = 0x1D, | |||
| 255 | ||||
| 256 | NAMESPACE_ID_CONTEXT_ID = 0x6D, | |||
| 257 | CONTROLLER_ID_CONTEXT_ID = 0x6E, | |||
| 258 | QUEUE_ID_CONTEXT_ID = 0x6F, | |||
| 259 | ||||
| 260 | //RESERVED = 7FFFh-70h, | |||
| 261 | //VENDOR_UNIQUE_CLASS_TYPE = FFFFh-8000h, | |||
| 262 | }; | |||
| 263 | ||||
| 264 | ||||
| 265 | /** | |||
| 266 | * enum ocp_telemetry_debug_event_class_types - OCP Debug Event Class types | |||
| 267 | * @RESERVED_CLASS_TYPE: Reserved class | |||
| 268 | * @TIME_STAMP_CLASS_TYPE: Time stamp class | |||
| 269 | * @PCIE_CLASS_TYPE: PCIe class | |||
| 270 | * @NVME_CLASS_TYPE: NVME class | |||
| 271 | * @RESET_CLASS_TYPE: Reset class | |||
| 272 | * @BOOT_SEQUENCE_CLASS_TYPE: Boot Sequence class | |||
| 273 | * @FIRMWARE_ASSERT_CLASS_TYPE: Firmware Assert class | |||
| 274 | * @TEMPERATURE_CLASS_TYPE: Temperature class | |||
| 275 | * @MEDIA_CLASS_TYPE: Media class | |||
| 276 | * @MEDIA_WEAR_CLASS_TYPE: Media wear class | |||
| 277 | * @STATISTIC_SNAPSHOT_CLASS_TYPE: Statistic snapshot class | |||
| 278 | * @VIRTUAL_FIFO_EVENT_CLASS_TYPE: Virtual FIFO event class | |||
| 279 | * @SMBUS_I2C_I3C_EVENT_CLASS_TYPE: SMBUS/I2C/I3C event class | |||
| 280 | * @MCTP_EVENT_CLASS_TYPE: MCTP event class | |||
| 281 | * @RESERVED: Reserved class | |||
| 282 | * @VENDOR_UNIQUE_CLASS_TYPE: Vendor Unique class | |||
| 283 | */ | |||
| 284 | enum ocp_telemetry_debug_event_class_types { | |||
| 285 | RESERVED_CLASS_TYPE = 0x00, | |||
| 286 | TIME_STAMP_CLASS_TYPE = 0x01, | |||
| 287 | PCIE_CLASS_TYPE = 0x02, | |||
| 288 | NVME_CLASS_TYPE = 0x03, | |||
| 289 | RESET_CLASS_TYPE = 0x04, | |||
| 290 | BOOT_SEQUENCE_CLASS_TYPE = 0x05, | |||
| 291 | FIRMWARE_ASSERT_CLASS_TYPE = 0x06, | |||
| 292 | TEMPERATURE_CLASS_TYPE = 0x07, | |||
| 293 | MEDIA_CLASS_TYPE = 0x08, | |||
| 294 | MEDIA_WEAR_CLASS_TYPE = 0x09, | |||
| 295 | STATISTIC_SNAPSHOT_CLASS_TYPE = 0x0A, | |||
| 296 | VIRTUAL_FIFO_EVENT_CLASS_TYPE = 0x0B, | |||
| 297 | SMBUS_I2C_I3C_EVENT_CLASS_TYPE = 0x0C, | |||
| 298 | MCTP_EVENT_CLASS_TYPE = 0x0D, | |||
| 299 | //RESERVED = 7Fh-0Eh, | |||
| 300 | //VENDOR_UNIQUE_CLASS_TYPE = FFh-80h, | |||
| 301 | }; | |||
| 302 | ||||
| 303 | /** | |||
| 304 | * struct telemetry_str_log_format - Telemetry String Log Format | |||
| 305 | * @log_page_version: indicates the version of the mapping this log page uses | |||
| 306 | * Shall be set to 01h. | |||
| 307 | * @reserved1: Reserved. | |||
| 308 | * @log_page_guid: Shall be set to B13A83691A8F408B9EA495940057AA44h. | |||
| 309 | * @sls: Shall be set to the number of DWORDS in the String Log. | |||
| 310 | * @reserved2: reserved. | |||
| 311 | * @sits: shall be set to the number of DWORDS in the Statistics | |||
| 312 | * Identifier String Table | |||
| 313 | * @ests: Shall be set to the number of DWORDS from byte 0 of this | |||
| 314 | * log page to the start of the Event String Table | |||
| 315 | * @estsz: shall be set to the number of DWORDS in the Event String Table | |||
| 316 | * @vu_eve_sts: Shall be set to the number of DWORDS from byte 0 of this | |||
| 317 | * log page to the start of the VU Event String Table | |||
| 318 | * @vu_eve_st_sz: shall be set to the number of DWORDS in the VU Event String Table | |||
| 319 | * @ascts: the number of DWORDS from byte 0 of this log page until the | |||
| 320 | * ASCII Table Starts. | |||
| 321 | * @asctsz: the number of DWORDS in the ASCII Table | |||
| 322 | * @fifo1: FIFO 0 ASCII String | |||
| 323 | * @fifo2: FIFO 1 ASCII String | |||
| 324 | * @fifo3: FIFO 2 ASCII String | |||
| 325 | * @fifo4: FIFO 3 ASCII String | |||
| 326 | * @fif05: FIFO 4 ASCII String | |||
| 327 | * @fifo6: FIFO 5 ASCII String | |||
| 328 | * @fifo7: FIFO 6 ASCII String | |||
| 329 | * @fifo8: FIFO 7 ASCII String | |||
| 330 | * @fifo9: FIFO 8 ASCII String | |||
| 331 | * @fifo10: FIFO 9 ASCII String | |||
| 332 | * @fif011: FIFO 10 ASCII String | |||
| 333 | * @fif012: FIFO 11 ASCII String | |||
| 334 | * @fifo13: FIFO 12 ASCII String | |||
| 335 | * @fif014: FIFO 13 ASCII String | |||
| 336 | * @fif015: FIFO 14 ASCII String | |||
| 337 | * @fif016: FIFO 15 ASCII String | |||
| 338 | * @reserved3: reserved | |||
| 339 | */ | |||
| 340 | struct __packed__attribute__((__packed__)) telemetry_str_log_format { | |||
| 341 | __u8 log_page_version; | |||
| 342 | __u8 reserved1[15]; | |||
| 343 | __u8 log_page_guid[GUID_LEN16]; | |||
| 344 | __le64 sls; | |||
| 345 | __u8 reserved2[24]; | |||
| 346 | __le64 sits; | |||
| 347 | __le64 sitsz; | |||
| 348 | __le64 ests; | |||
| 349 | __le64 estsz; | |||
| 350 | __le64 vu_eve_sts; | |||
| 351 | __le64 vu_eve_st_sz; | |||
| 352 | __le64 ascts; | |||
| 353 | __le64 asctsz; | |||
| 354 | __u8 fifo1[16]; | |||
| 355 | __u8 fifo2[16]; | |||
| 356 | __u8 fifo3[16]; | |||
| 357 | __u8 fifo4[16]; | |||
| 358 | __u8 fifo5[16]; | |||
| 359 | __u8 fifo6[16]; | |||
| 360 | __u8 fifo7[16]; | |||
| 361 | __u8 fifo8[16]; | |||
| 362 | __u8 fifo9[16]; | |||
| 363 | __u8 fifo10[16]; | |||
| 364 | __u8 fifo11[16]; | |||
| 365 | __u8 fifo12[16]; | |||
| 366 | __u8 fifo13[16]; | |||
| 367 | __u8 fifo14[16]; | |||
| 368 | __u8 fifo15[16]; | |||
| 369 | __u8 fifo16[16]; | |||
| 370 | __u8 reserved3[48]; | |||
| 371 | }; | |||
| 372 | ||||
| 373 | /* | |||
| 374 | * struct statistics_id_str_table_entry - Statistics Identifier String Table Entry | |||
| 375 | * @vs_si: Shall be set the Vendor Unique Statistic Identifier number. | |||
| 376 | * @reserved1: Reserved | |||
| 377 | * @ascii_id_len: Shall be set the number of ASCII Characters that are valid. | |||
| 378 | * @ascii_id_ofst: Shall be set to the offset from DWORD 0/Byte 0 of the Start | |||
| 379 | * of the ASCII Table to the first character of the string for | |||
| 380 | * this Statistic Identifier string.. | |||
| 381 | * @reserved2 reserved | |||
| 382 | */ | |||
| 383 | struct __packed__attribute__((__packed__)) statistics_id_str_table_entry { | |||
| 384 | __le16 vs_si; | |||
| 385 | __u8 reserved1; | |||
| 386 | __u8 ascii_id_len; | |||
| 387 | __le64 ascii_id_ofst; | |||
| 388 | __le32 reserved2; | |||
| 389 | }; | |||
| 390 | ||||
| 391 | /* | |||
| 392 | * struct event_id_str_table_entry - Event Identifier String Table Entry | |||
| 393 | * @deb_eve_class: Shall be set the Debug Class. | |||
| 394 | * @ei: Shall be set to the Event Identifier | |||
| 395 | * @ascii_id_len: Shall be set the number of ASCII Characters that are valid. | |||
| 396 | * @ascii_id_ofst: This is the offset from DWORD 0/ Byte 0 of the start of the | |||
| 397 | * ASCII table to the ASCII data for this identifier | |||
| 398 | * @reserved2 reserved | |||
| 399 | */ | |||
| 400 | struct __packed__attribute__((__packed__)) event_id_str_table_entry { | |||
| 401 | __u8 deb_eve_class; | |||
| 402 | __le16 ei; | |||
| 403 | __u8 ascii_id_len; | |||
| 404 | __le64 ascii_id_ofst; | |||
| 405 | __le32 reserved2; | |||
| 406 | }; | |||
| 407 | ||||
| 408 | /* | |||
| 409 | * struct vu_event_id_str_table_entry - VU Event Identifier String Table Entry | |||
| 410 | * @deb_eve_class: Shall be set the Debug Class. | |||
| 411 | * @vu_ei: Shall be set to the VU Event Identifier | |||
| 412 | * @ascii_id_len: Shall be set the number of ASCII Characters that are valid. | |||
| 413 | * @ascii_id_ofst: This is the offset from DWORD 0/ Byte 0 of the start of the | |||
| 414 | * ASCII table to the ASCII data for this identifier | |||
| 415 | * @reserved reserved | |||
| 416 | */ | |||
| 417 | struct __packed__attribute__((__packed__)) vu_event_id_str_table_entry { | |||
| 418 | __u8 deb_eve_class; | |||
| 419 | __le16 vu_ei; | |||
| 420 | __u8 ascii_id_len; | |||
| 421 | __le64 ascii_id_ofst; | |||
| 422 | __le32 reserved; | |||
| 423 | }; | |||
| 424 | ||||
| 425 | ||||
| 426 | struct ocp_telemetry_parse_options { | |||
| 427 | char *telemetry_log; | |||
| 428 | char *string_log; | |||
| 429 | char *output_file; | |||
| 430 | char *output_format; | |||
| 431 | int data_area; | |||
| 432 | }; | |||
| 433 | ||||
| 434 | struct __packed__attribute__((__packed__)) nvme_ocp_telemetry_reason_id | |||
| 435 | { | |||
| 436 | __u8 error_id[64]; // Bytes 63:00 | |||
| 437 | __u8 file_id[8]; // Bytes 71:64 | |||
| 438 | __le16 line_number; // Bytes 73:72 | |||
| 439 | __u8 valid_flags; // Bytes 74 | |||
| 440 | __u8 reserved[21]; // Bytes 95:75 | |||
| 441 | __u8 vu_reason_ext[32]; // Bytes 127:96 | |||
| 442 | }; | |||
| 443 | ||||
| 444 | struct __packed__attribute__((__packed__)) nvme_ocp_telemetry_common_header | |||
| 445 | { | |||
| 446 | __u8 log_id; // Byte 00 | |||
| 447 | __le32 reserved1; // Bytes 04:01 | |||
| 448 | __u8 ieee_oui_id[3]; // Bytes 07:05 | |||
| 449 | __le16 da1_last_block; // Bytes 09:08 | |||
| 450 | __le16 da2_last_block; // Bytes 11:10 | |||
| 451 | __le16 da3_last_block; // Bytes 13:12 | |||
| 452 | __le16 reserved2; // Bytes 15:14 | |||
| 453 | __le32 da4_last_block; // Bytes 19:16 | |||
| 454 | }; | |||
| 455 | ||||
| 456 | struct __packed__attribute__((__packed__)) nvme_ocp_telemetry_host_initiated_header | |||
| 457 | { | |||
| 458 | struct nvme_ocp_telemetry_common_header commonHeader; // Bytes 19:00 | |||
| 459 | __u8 reserved3[360]; // Bytes 379:20 | |||
| 460 | __u8 host_initiated_scope; // Byte 380 | |||
| 461 | __u8 host_initiated_gen_number; // Byte 381 | |||
| 462 | __u8 host_initiated_data_available; // Byte 382 | |||
| 463 | __u8 ctrl_initiated_gen_number; // Byte 383 | |||
| 464 | struct nvme_ocp_telemetry_reason_id reason_id; // Bytes 511:384 | |||
| 465 | }; | |||
| 466 | ||||
| 467 | struct __packed__attribute__((__packed__)) nvme_ocp_telemetry_controller_initiated_header | |||
| 468 | { | |||
| 469 | struct nvme_ocp_telemetry_common_header commonHeader; // Bytes 19:00 | |||
| 470 | __u8 reserved3[361]; // Bytes 380:20 | |||
| 471 | __u8 ctrl_initiated_scope; // Byte 381 | |||
| 472 | __u8 ctrl_initiated_data_available; // Byte 382 | |||
| 473 | __u8 ctrl_initiated_gen_number; // Byte 383 | |||
| 474 | struct nvme_ocp_telemetry_reason_id reason_id; // Bytes 511:384 | |||
| 475 | }; | |||
| 476 | ||||
| 477 | struct __packed__attribute__((__packed__)) nvme_ocp_telemetry_smart | |||
| 478 | { | |||
| 479 | __u8 critical_warning; // Byte 0 | |||
| 480 | __le16 composite_temperature; // Bytes 2:1 | |||
| 481 | __u8 available_spare; // Bytes 3 | |||
| 482 | __u8 available_spare_threshold; // Bytes 4 | |||
| 483 | __u8 percentage_used; // Bytes 5 | |||
| 484 | __u8 reserved1[26]; // Bytes 31:6 | |||
| 485 | __u8 data_units_read[16]; // Bytes 47:32 | |||
| 486 | __u8 data_units_written[16]; // Bytes 63:48 | |||
| 487 | __u8 host_read_commands[16]; // Byte 79:64 | |||
| 488 | __u8 host_write_commands[16]; // Bytes 95:80 | |||
| 489 | __u8 controller_busy_time[16]; // Bytes 111:96 | |||
| 490 | __u8 power_cycles[16]; // Bytes 127:112 | |||
| 491 | __u8 power_on_hours[16]; // Bytes 143:128 | |||
| 492 | __u8 unsafe_shutdowns[16]; // Bytes 159:144 | |||
| 493 | __u8 media_and_data_integrity_errors[16]; // Bytes 175:160 | |||
| 494 | __u8 number_of_error_information_log_entries[16]; // Bytes 191:176 | |||
| 495 | __le32 warning_composite_temperature_time; // Byte 195:192 | |||
| 496 | __le32 critical_composite_temperature_time; // Bytes 199:196 | |||
| 497 | __le16 temperature_sensor1; // Bytes 201:200 | |||
| 498 | __le16 temperature_sensor2; // Byte 203:202 | |||
| 499 | __le16 temperature_sensor3; // Byte 205:204 | |||
| 500 | __le16 temperature_sensor4; // Bytes 207:206 | |||
| 501 | __le16 temperature_sensor5; // Bytes 209:208 | |||
| 502 | __le16 temperature_sensor6; // Bytes 211:210 | |||
| 503 | __le16 temperature_sensor7; // Bytes 213:212 | |||
| 504 | __le16 temperature_sensor8; // Bytes 215:214 | |||
| 505 | __le32 thermal_management_temperature1_transition_count; // Bytes 219:216 | |||
| 506 | __le32 thermal_management_temperature2_transition_count; // Bytes 223:220 | |||
| 507 | __le32 total_time_for_thermal_management_temperature1; // Bytes 227:224 | |||
| 508 | __le32 total_time_for_thermal_management_temperature2; // Bytes 231:228 | |||
| 509 | __u8 reserved2[280]; // Bytes 511:232 | |||
| 510 | }; | |||
| 511 | ||||
| 512 | struct __packed__attribute__((__packed__)) nvme_ocp_telemetry_smart_extended | |||
| 513 | { | |||
| 514 | __u8 physical_media_units_written[16]; // Bytes 15:0 | |||
| 515 | __u8 physical_media_units_read[16]; // Bytes 31:16 | |||
| 516 | __u8 bad_user_nand_blocks_raw_count[6]; // Bytes 37:32 | |||
| 517 | __le16 bad_user_nand_blocks_normalized_value; // Bytes 39:38 | |||
| 518 | __u8 bad_system_nand_blocks_raw_count[6]; // Bytes 45:40 | |||
| 519 | __le16 bad_system_nand_blocks_normalized_value; // Bytes 47:46 | |||
| 520 | __le64 xor_recovery_count; // Bytes 55:48 | |||
| 521 | __le64 uncorrectable_read_error_count; // Bytes 63:56 | |||
| 522 | __le64 soft_ecc_error_count; // Bytes 71:64 | |||
| 523 | __le32 end_to_end_correction_counts_detected_errors; // Bytes 75:72 | |||
| 524 | __le32 end_to_end_correction_counts_corrected_errors; // Bytes 79:76 | |||
| 525 | __u8 system_data_percent_used; // Byte 80 | |||
| 526 | __u8 refresh_counts[7]; // Bytes 87:81 | |||
| 527 | __le32 max_user_data_erase_count; // Bytes 91:88 | |||
| 528 | __le32 min_user_data_erase_count; // Bytes 95:92 | |||
| 529 | __u8 num_thermal_throttling_events; // Bytes 96 | |||
| 530 | __u8 current_throttling_status; // Bytes 97 | |||
| 531 | __u8 errata_version_field; // Byte 98 | |||
| 532 | __le16 point_version_field; // Byte 100:99 | |||
| 533 | __le16 minor_version_field; // Byte 102:101 | |||
| 534 | __u8 major_version_field; // Byte 103 | |||
| 535 | __le64 pcie_correctable_error_count; // Bytes 111:104 | |||
| 536 | __le32 incomplete_shutdowns; // Bytes 115:112 | |||
| 537 | __le32 reserved1; // Bytes 119:116 | |||
| 538 | __u8 percent_free_blocks; // Byte 120 | |||
| 539 | __u8 reserved2[7]; // Bytes 127:121 | |||
| 540 | __le16 capacitor_health; // Bytes 129:128 | |||
| 541 | __u8 nvme_base_errata_version; // Byte 130 | |||
| 542 | __u8 nvme_command_set_errata_version; // Byte 131 | |||
| 543 | __le32 reserved3; // Bytes 135:132 | |||
| 544 | __le64 unaligned_io; // Bytes 143:136 | |||
| 545 | __le64 security_version_number; // Bytes 151:144 | |||
| 546 | __le64 total_nuse; // Bytes 159:152 | |||
| 547 | __u8 plp_start_count[16]; // Bytes 175:160 | |||
| 548 | __u8 endurance_estimate[16]; // Bytes 191:176 | |||
| 549 | __le64 pcie_link_retraining_count; // Bytes 199:192 | |||
| 550 | __le64 power_state_change_count; // Bytes 207:200 | |||
| 551 | __le64 lowest_permitted_firmware_revision; // Bytes 215:208 | |||
| 552 | __u8 reserved4[278]; // Bytes 493:216 | |||
| 553 | __le16 log_page_version; // Bytes 495:494 | |||
| 554 | __u8 log_page_guid[GUID_LEN16]; // Bytes 511:496 | |||
| 555 | }; | |||
| 556 | ||||
| 557 | struct __packed__attribute__((__packed__)) nvme_ocp_event_fifo_data | |||
| 558 | { | |||
| 559 | __le32 event_fifo_num; | |||
| 560 | __u8 event_fifo_da; | |||
| 561 | __le64 event_fifo_start; | |||
| 562 | __le64 event_fifo_size; | |||
| 563 | }; | |||
| 564 | ||||
| 565 | struct __packed__attribute__((__packed__)) nvme_ocp_telemetry_offsets | |||
| 566 | { | |||
| 567 | __u32 data_area; | |||
| 568 | __u32 header_size; | |||
| 569 | __u64 da1_start_offset; | |||
| 570 | __u64 da1_size; | |||
| 571 | __u64 da2_start_offset; | |||
| 572 | __u64 da2_size; | |||
| 573 | __u64 da3_start_offset; | |||
| 574 | __u64 da3_size; | |||
| 575 | __u64 da4_start_offset; | |||
| 576 | __u64 da4_size; | |||
| 577 | }; | |||
| 578 | ||||
| 579 | struct __packed__attribute__((__packed__)) nvme_ocp_event_fifo_offsets | |||
| 580 | { | |||
| 581 | __le64 event_fifo_start; | |||
| 582 | __le64 event_fifo_size; | |||
| 583 | }; | |||
| 584 | ||||
| 585 | struct __packed__attribute__((__packed__)) nvme_ocp_header_in_da1 | |||
| 586 | { | |||
| 587 | __le16 major_version; // Bytes 1:0 | |||
| 588 | __le16 minor_version; // Bytes 3:2 | |||
| 589 | __le32 reserved1; // Bytes 7:4 | |||
| 590 | __le64 time_stamp; // Bytes 15:8 | |||
| 591 | __u8 log_page_guid[GUID_LEN16]; // Bytes 31:16 | |||
| 592 | __u8 num_telemetry_profiles_supported; // Byte 32 | |||
| 593 | __u8 telemetry_profile_selected; // Byte 33 | |||
| 594 | __u8 reserved2[6]; // Bytes 39:34 | |||
| 595 | __le64 string_log_size; // Bytes 47:40 | |||
| 596 | __le64 reserved3; // Bytes 55:48 | |||
| 597 | __le64 firmware_revision; // Bytes 63:56 | |||
| 598 | __u8 reserved4[32]; // Bytes 95:64 | |||
| 599 | __le64 da1_statistic_start; // Bytes 103:96 | |||
| 600 | __le64 da1_statistic_size; // Bytes 111:104 | |||
| 601 | __le64 da2_statistic_start; // Bytes 119:112 | |||
| 602 | __le64 da2_statistic_size; // Bytes 127:120 | |||
| 603 | __u8 reserved5[32]; // Bytes 159:128 | |||
| 604 | __u8 event_fifo_da[16]; // Bytes 175:160 | |||
| 605 | struct nvme_ocp_event_fifo_offsets fifo_offsets[16]; // Bytes 431:176 | |||
| 606 | __u8 reserved6[80]; // Bytes 511:432 | |||
| 607 | struct nvme_ocp_telemetry_smart smart_health_info; // Bytes 1023:512 | |||
| 608 | struct nvme_ocp_telemetry_smart_extended smart_health_info_extended; // Bytes 1535:1024 | |||
| 609 | }; | |||
| 610 | ||||
| 611 | struct __packed__attribute__((__packed__)) nvme_ocp_telemetry_statistic_descriptor | |||
| 612 | { | |||
| 613 | __le16 statistic_id; // Bytes 1:0 | |||
| 614 | __u8 statistic_info_behaviour_type : 4; // Byte 2(3:0) | |||
| 615 | __u8 statistic_info_host_hint_type : 2; // Byte 2(5:4) | |||
| 616 | __u8 statistic_info_context_index : 1; // Byte 2(6) | |||
| 617 | __u8 statistic_info_reserved : 1; // Byte 2(7) | |||
| 618 | __u8 ns_info_nsid : 7; // Bytes 3(6:0) | |||
| 619 | __u8 ns_info_ns_info_valid : 1; // Bytes 3(7) | |||
| 620 | __le16 statistic_data_size; // Bytes 5:4 | |||
| 621 | __le16 ns_identifier_15_0; // Bytes 7:6 | |||
| 622 | }; | |||
| 623 | ||||
| 624 | /* Context data at the start of a Context Statistic Descriptor's data */ | |||
| 625 | #define CONTEXT_DATA_DWORDS2 2 | |||
| 626 | ||||
| 627 | struct __packed__attribute__((__packed__)) nvme_ocp_statistic_context_data | |||
| 628 | { | |||
| 629 | __le16 context_data_size; // Bytes 1:0 | |||
| 630 | __le16 reserved; // Bytes 3:2 | |||
| 631 | __u8 scope[4]; // Bytes 7:4 | |||
| 632 | }; | |||
| 633 | ||||
| 634 | struct __packed__attribute__((__packed__)) nvme_ocp_telemetry_event_descriptor | |||
| 635 | { | |||
| 636 | __u8 debug_event_class_type; // Byte 0 | |||
| 637 | __le16 event_id; // Bytes 2:1 | |||
| 638 | __u8 event_data_size; // Byte 3 | |||
| 639 | }; | |||
| 640 | ||||
| 641 | struct __packed__attribute__((__packed__)) nvme_ocp_time_stamp_dbg_evt_class_format | |||
| 642 | { | |||
| 643 | __u8 time_stamp[DATA_SIZE_88]; // Bytes 11:4 | |||
| 644 | }; | |||
| 645 | ||||
| 646 | struct __packed__attribute__((__packed__)) nvme_ocp_pcie_dbg_evt_class_format | |||
| 647 | { | |||
| 648 | __u8 pCIeDebugEventData[DATA_SIZE_44]; // Bytes 7:4 | |||
| 649 | }; | |||
| 650 | ||||
| 651 | struct __packed__attribute__((__packed__)) nvme_ocp_nvme_dbg_evt_class_format | |||
| 652 | { | |||
| 653 | __u8 nvmeDebugEventData[DATA_SIZE_88]; // Bytes 11:4 | |||
| 654 | }; | |||
| 655 | ||||
| 656 | struct __packed__attribute__((__packed__)) nvme_ocp_media_wear_dbg_evt_class_format | |||
| 657 | { | |||
| 658 | __u8 currentMediaWear[DATA_SIZE_1212]; // Bytes 15:4 | |||
| 659 | ||||
| 660 | }; | |||
| 661 | ||||
| 662 | struct __packed__attribute__((__packed__)) nvme_ocp_virtual_fifo_dbg_evt_class_format | |||
| 663 | { | |||
| 664 | __le16 vu_virtual_fifo_identifier; // Bytes 5:4 | |||
| 665 | __le16 reserved; // Bytes 7:6 | |||
| 666 | }; | |||
| 667 | ||||
| 668 | struct __packed__attribute__((__packed__)) nvme_ocp_smbus_dbg_evt_class_format | |||
| 669 | { | |||
| 670 | __le16 smbus_debug_event_data; // Bytes 5:4 | |||
| 671 | __le16 reserved; // Bytes 7:6 | |||
| 672 | }; | |||
| 673 | ||||
| 674 | struct __packed__attribute__((__packed__)) nvme_ocp_mctp_dbg_evt_class_format | |||
| 675 | { | |||
| 676 | __le16 mctp_debug_event_data; // Bytes 5:4 | |||
| 677 | __u8 transport_protocol; // Byte 6 | |||
| 678 | __u8 event_flags; // Byte 7 | |||
| 679 | __u8 transport_header[DATA_SIZE_44]; // Bytes 11:8 | |||
| 680 | }; | |||
| 681 | ||||
| 682 | struct __packed__attribute__((__packed__)) nvme_ocp_common_dbg_evt_class_vu_data | |||
| 683 | { | |||
| 684 | __le16 vu_event_identifier; // Bytes 5:4 | |||
| 685 | __u8 data[]; // Bytes N:6 | |||
| 686 | }; | |||
| 687 | ||||
| 688 | struct __packed__attribute__((__packed__)) nvme_ocp_statistic_snapshot_evt_class_format | |||
| 689 | { | |||
| 690 | __u8 debug_event_class_type; // Byte 0 | |||
| 691 | __u8 reserved1[3]; // Bytes 3:1 | |||
| 692 | __le16 stat_id; // Bytes 5:4 | |||
| 693 | __u8 stat_info; // Byte 6 | |||
| 694 | __u8 namespace_info; // Byte 7 | |||
| 695 | __le16 stat_data_size; // Bytes 9:8 | |||
| 696 | __le16 nsid; // Bytes 11:10 | |||
| 697 | }; | |||
| 698 | ||||
| 699 | struct __packed__attribute__((__packed__)) nvme_ocp_statistics_identifier_string_table | |||
| 700 | { | |||
| 701 | __le16 vs_statistic_identifier; //1:0 | |||
| 702 | __u8 reserved1; //2 | |||
| 703 | __u8 ascii_id_length; //3 | |||
| 704 | __le64 ascii_id_offset; //11:4 | |||
| 705 | __le32 reserved2; //15:12 | |||
| 706 | }; | |||
| 707 | ||||
| 708 | struct __packed__attribute__((__packed__)) nvme_ocp_event_string_table | |||
| 709 | { | |||
| 710 | __u8 debug_event_class; //0 | |||
| 711 | __le16 event_identifier; //2:1 | |||
| 712 | __u8 ascii_id_length; //3 | |||
| 713 | __le64 ascii_id_offset; //11:4 | |||
| 714 | __le32 reserved; //15:12 | |||
| 715 | }; | |||
| 716 | ||||
| 717 | struct __packed__attribute__((__packed__)) nvme_ocp_vu_event_string_table | |||
| 718 | { | |||
| 719 | __u8 debug_event_class; //0 | |||
| 720 | __le16 vu_event_identifier; //2:1 | |||
| 721 | __u8 ascii_id_length; //3 | |||
| 722 | __le64 ascii_id_offset; //11:4 | |||
| 723 | __le32 reserved; //15:12 | |||
| 724 | }; | |||
| 725 | ||||
| 726 | struct __packed__attribute__((__packed__)) nvme_ocp_telemetry_string_header | |||
| 727 | { | |||
| 728 | __u8 version; //0:0 | |||
| 729 | __u8 reserved1[15]; //15:1 | |||
| 730 | __u8 guid[GUID_LEN16]; //32:16 | |||
| 731 | __le64 string_log_size; //39:32 | |||
| 732 | __u8 reserved2[24]; //63:40 | |||
| 733 | __le64 sits; //71:64 Statistics Identifier String Table Start(SITS) | |||
| 734 | __le64 sitsz; //79:72 Statistics Identifier String Table Size (SITSZ) | |||
| 735 | __le64 ests; //87:80 Event String Table Start(ESTS) | |||
| 736 | __le64 estsz; //95:88 Event String Table Size(ESTSZ) | |||
| 737 | __le64 vu_ests; //103:96 VU Event String Table Start | |||
| 738 | __le64 vu_estsz; //111:104 VU Event String Table Size | |||
| 739 | __le64 ascts; //119:112 ASCII Table start | |||
| 740 | __le64 asctsz; //127:120 ASCII Table Size | |||
| 741 | __u8 fifo_ascii_string[16][16]; //383:128 | |||
| 742 | __u8 reserved3[48]; //431:384 | |||
| 743 | }; | |||
| 744 | ||||
| 745 | struct __packed__attribute__((__packed__)) statistic_entry { | |||
| 746 | int identifier; | |||
| 747 | char *description; | |||
| 748 | }; | |||
| 749 | ||||
| 750 | /************************************************************ | |||
| 751 | * Telemetry ID to String Conversion Functions | |||
| 752 | ************************************************************/ | |||
| 753 | static inline const char *arg_str(const char * const *strings, | |||
| 754 | size_t array_size, size_t idx) | |||
| 755 | { | |||
| 756 | if (idx < array_size && strings[idx]) | |||
| 757 | return strings[idx]; | |||
| 758 | return "unrecognized"; | |||
| 759 | } | |||
| 760 | ||||
| 761 | #define ARGSTR(s, i)arg_str(s, (sizeof(s) / sizeof((s)[0]) + 0), i) arg_str(s, ARRAY_SIZE(s)(sizeof(s) / sizeof((s)[0]) + 0), i) | |||
| 762 | ||||
| 763 | /* Event Data is defined for the NACK error Event ID only */ | |||
| 764 | static inline const char *telemetry_smbus_event_data_to_string(int event_id, int data) | |||
| 765 | { | |||
| 766 | if (event_id != SMBUS_NACK_ERROR) | |||
| 767 | return ""; | |||
| 768 | return ARGSTR(telemetry_smbus_nack_event_data_str, data)arg_str(telemetry_smbus_nack_event_data_str, (sizeof(telemetry_smbus_nack_event_data_str ) / sizeof((telemetry_smbus_nack_event_data_str)[0]) + 0), data ); | |||
| 769 | } | |||
| 770 | ||||
| 771 | /* Each MCTP Event ID has its own Event Data values */ | |||
| 772 | static inline const char *telemetry_mctp_event_data_to_string(int event_id, int data) | |||
| 773 | { | |||
| 774 | switch (event_id) { | |||
| 775 | case MCTP_DROPPED_PACKET: | |||
| 776 | return ARGSTR(telemetry_mctp_dropped_packet_data_str, data)arg_str(telemetry_mctp_dropped_packet_data_str, (sizeof(telemetry_mctp_dropped_packet_data_str ) / sizeof((telemetry_mctp_dropped_packet_data_str)[0]) + 0), data); | |||
| 777 | case MCTP_DROPPED_MESSAGE: | |||
| 778 | return ARGSTR(telemetry_mctp_dropped_message_data_str, data)arg_str(telemetry_mctp_dropped_message_data_str, (sizeof(telemetry_mctp_dropped_message_data_str ) / sizeof((telemetry_mctp_dropped_message_data_str)[0]) + 0) , data); | |||
| 779 | case MCTP_DISCOVERY_ADDRESSING_ERRORS: | |||
| 780 | return ARGSTR(telemetry_mctp_discovery_data_str, data)arg_str(telemetry_mctp_discovery_data_str, (sizeof(telemetry_mctp_discovery_data_str ) / sizeof((telemetry_mctp_discovery_data_str)[0]) + 0), data ); | |||
| 781 | case MCTP_ERROR_STATUS: | |||
| 782 | return ARGSTR(telemetry_mctp_error_status_data_str, data)arg_str(telemetry_mctp_error_status_data_str, (sizeof(telemetry_mctp_error_status_data_str ) / sizeof((telemetry_mctp_error_status_data_str)[0]) + 0), data ); | |||
| 783 | default: | |||
| 784 | return ""; | |||
| 785 | } | |||
| 786 | } | |||
| 787 | ||||
| 788 | static inline const char *telemetry_mctp_transport_protocol_to_string(int protocol) | |||
| 789 | { | |||
| 790 | return ARGSTR(telemetry_mctp_transport_protocol_str, protocol)arg_str(telemetry_mctp_transport_protocol_str, (sizeof(telemetry_mctp_transport_protocol_str ) / sizeof((telemetry_mctp_transport_protocol_str)[0]) + 0), protocol ); | |||
| 791 | } | |||
| 792 | ||||
| 793 | /** | |||
| 794 | * @brief checks that a string log table lies within the log buffer | |||
| 795 | * | |||
| 796 | * @param ofst_dw, input table start, in DWORDs from the start of the log | |||
| 797 | * @param size_dw, input table size, in DWORDs | |||
| 798 | * @param buf_len, input log buffer length, in bytes | |||
| 799 | * | |||
| 800 | * @return true if the whole table is inside the buffer | |||
| 801 | */ | |||
| 802 | static inline bool_Bool ocp_c9_table_fits(__u64 ofst_dw, __u64 size_dw, size_t buf_len) | |||
| 803 | { | |||
| 804 | __u64 dwords = buf_len / SIZE_OF_DWORD4; | |||
| 805 | ||||
| 806 | return ofst_dw <= dwords && size_dw <= dwords - ofst_dw; | |||
| 807 | } | |||
| 808 | ||||
| 809 | /** | |||
| 810 | * @brief locates a string log table | |||
| 811 | * | |||
| 812 | * @param buf, input log buffer | |||
| 813 | * @param buf_len, input log buffer length, in bytes | |||
| 814 | * @param ofst_dw, input table start, in DWORDs from the start of the log | |||
| 815 | * @param size_dw, input table size, in DWORDs | |||
| 816 | * @param entry_size, input size of one table entry, in bytes | |||
| 817 | * @param entries, output number of whole entries in the table | |||
| 818 | * | |||
| 819 | * @return the first entry, or NULL if the table is not inside the buffer | |||
| 820 | */ | |||
| 821 | static inline __u8 *ocp_string_table(__u8 *buf, size_t buf_len, __u64 ofst_dw, | |||
| 822 | __u64 size_dw, size_t entry_size, __u64 *entries) | |||
| 823 | { | |||
| 824 | if (!ocp_c9_table_fits(ofst_dw, size_dw, buf_len)) | |||
| 825 | return NULL((void*)0); | |||
| 826 | ||||
| 827 | *entries = size_dw * SIZE_OF_DWORD4 / entry_size; | |||
| 828 | return buf + ofst_dw * SIZE_OF_DWORD4; | |||
| ||||
| 829 | } | |||
| 830 | ||||
| 831 | /** | |||
| 832 | * @brief parse the ocp telemetry host or controller log binary file | |||
| 833 | * into json or text | |||
| 834 | * | |||
| 835 | * @param options, input pointer for inputs like telemetry log bin file, | |||
| 836 | * string log bin file and output file etc. | |||
| 837 | * | |||
| 838 | * @return 0 success | |||
| 839 | */ | |||
| 840 | int parse_ocp_telemetry_log(struct ocp_telemetry_parse_options *options); | |||
| 841 | ||||
| 842 | /** | |||
| 843 | * @brief parse the ocp telemetry string log binary file to json or text | |||
| 844 | * | |||
| 845 | * @param event_fifo_num, input event FIFO number | |||
| 846 | * @param debug_event_class, input debug event class id | |||
| 847 | * @param string_table, input string table | |||
| 848 | * @param description, input description string | |||
| 849 | * | |||
| 850 | * @return 0 success | |||
| 851 | */ | |||
| 852 | int parse_ocp_telemetry_string_log(int event_fifo_num, int identifier, int debug_event_class, | |||
| 853 | enum ocp_telemetry_string_tables string_table, char *description); | |||
| 854 | ||||
| 855 | /** | |||
| 856 | * @brief gets the telemetry datas areas, offsets and sizes information | |||
| 857 | * | |||
| 858 | * @param ptelemetry_common_header, input telemetry common header pointer | |||
| 859 | * @param buf_len, input telemetry log length, in bytes | |||
| 860 | * @param ptelemetry_das_offset, input telemetry offsets pointer | |||
| 861 | * | |||
| 862 | * @return 0 success | |||
| 863 | */ | |||
| 864 | int get_telemetry_das_offset_and_size( | |||
| 865 | struct nvme_ocp_telemetry_common_header *ptelemetry_common_header, | |||
| 866 | size_t buf_len, struct nvme_ocp_telemetry_offsets *ptelemetry_das_offset); | |||
| 867 | ||||
| 868 | /** | |||
| 869 | * @brief parses statistics data to text or json formats | |||
| 870 | * | |||
| 871 | * @param root, input time json root object pointer | |||
| 872 | * @param ptelemetry_das_offset, input telemetry offsets pointer | |||
| 873 | * @param fp, input file pointer | |||
| 874 | * | |||
| 875 | * @return 0 success | |||
| 876 | */ | |||
| 877 | int parse_statistics(struct json_object *root, struct nvme_ocp_telemetry_offsets *pOffsets, | |||
| 878 | FILE *fp); | |||
| 879 | ||||
| 880 | /** | |||
| 881 | * @brief parses a single statistic data to text or json formats | |||
| 882 | * | |||
| 883 | * @param pstatistic_entry, statistic entry pointer | |||
| 884 | * @param pstat_obj, JSON object which receives the statistic, or NULL | |||
| 885 | * @param fp, input file pointer | |||
| 886 | * | |||
| 887 | * @return 0 success | |||
| 888 | */ | |||
| 889 | int parse_statistic(struct nvme_ocp_telemetry_statistic_descriptor *pstatistic_entry, | |||
| 890 | struct json_object *pstat_obj, FILE *fp); | |||
| 891 | ||||
| 892 | /** | |||
| 893 | * @brief parses event fifos data to text or json formats | |||
| 894 | * | |||
| 895 | * @param root, input time json root object pointer | |||
| 896 | * @param poffsets, input telemetry offsets pointer | |||
| 897 | * @param fp, input file pointer | |||
| 898 | * | |||
| 899 | * @return 0 success | |||
| 900 | */ | |||
| 901 | int parse_event_fifos(struct json_object *root, struct nvme_ocp_telemetry_offsets *poffsets, | |||
| 902 | FILE *fp); | |||
| 903 | ||||
| 904 | /** | |||
| 905 | * @brief parses a single event fifo data to text or json formats | |||
| 906 | * | |||
| 907 | * @param fifo_num, input event fifo number | |||
| 908 | * @param pfifo_start, event fifo start pointer | |||
| 909 | * @param pevent_fifos_object, event fifos json object pointer | |||
| 910 | * @param ptelemetry_das_offset, input telemetry offsets pointer | |||
| 911 | * @param fifo_size, input event fifo size | |||
| 912 | * @param fp, input file pointer | |||
| 913 | * | |||
| 914 | * @return 0 success | |||
| 915 | */ | |||
| 916 | int parse_event_fifo(unsigned int fifo_num, unsigned char *pfifo_start, | |||
| 917 | struct json_object *pevent_fifos_object, unsigned char *pstring_buffer, | |||
| 918 | struct nvme_ocp_telemetry_offsets *poffsets, __u64 fifo_size, FILE *fp); | |||
| 919 | ||||
| 920 | /** | |||
| 921 | * @brief parses event fifos data to text or json formats | |||
| 922 | * | |||
| 923 | * @return 0 success | |||
| 924 | */ | |||
| 925 | int print_ocp_telemetry_normal(struct ocp_telemetry_parse_options *options); | |||
| 926 | ||||
| 927 | /** | |||
| 928 | * @brief parses event fifos data to text or json formats | |||
| 929 | * | |||
| 930 | * @return 0 success | |||
| 931 | */ | |||
| 932 | int print_ocp_telemetry_json(struct ocp_telemetry_parse_options *options); | |||
| 933 | ||||
| 934 | /** | |||
| 935 | * @brief gets statistic id ascii string | |||
| 936 | * | |||
| 937 | * @param identifier, string id | |||
| 938 | * @param description, string description | |||
| 939 | * | |||
| 940 | * @return 0 success | |||
| 941 | */ | |||
| 942 | int get_statistic_id_ascii_string(int identifier, char *description); | |||
| 943 | ||||
| 944 | /** | |||
| 945 | * @brief gets event id ascii string | |||
| 946 | * | |||
| 947 | * @param identifier, string id | |||
| 948 | * @param debug_event_class, debug event class | |||
| 949 | * @param description, string description | |||
| 950 | * | |||
| 951 | * @return 0 success | |||
| 952 | */ | |||
| 953 | int get_event_id_ascii_string(int identifier, int debug_event_class, char *description); | |||
| 954 | ||||
| 955 | /** | |||
| 956 | * @brief gets vu event id ascii string | |||
| 957 | * | |||
| 958 | * @param identifier, string id | |||
| 959 | * @param debug_event_class, debug event class | |||
| 960 | * @param description, string description | |||
| 961 | * | |||
| 962 | * @return 0 success | |||
| 963 | */ | |||
| 964 | int get_vu_event_id_ascii_string(int identifier, int debug_event_class, char *description); | |||
| 965 | ||||
| 966 | /** | |||
| 967 | * @brief parses a time-stamp event fifo data to text or json formats | |||
| 968 | * | |||
| 969 | * @param pevent_descriptor, input event descriptor data | |||
| 970 | * @param pevent_descriptor_obj, event descriptor json object pointer | |||
| 971 | * @param pevent_specific_data, input event specific data | |||
| 972 | * @param pevent_fifos_object, event fifos json object pointer | |||
| 973 | * @param fp, input file pointer | |||
| 974 | * | |||
| 975 | * @return 0 success | |||
| 976 | */ | |||
| 977 | int parse_time_stamp_event( | |||
| 978 | struct nvme_ocp_telemetry_event_descriptor *pevent_descriptor, | |||
| 979 | struct json_object *pevent_descriptor_obj, | |||
| 980 | __u8 *pevent_specific_data, | |||
| 981 | struct json_object *pevent_fifos_object, | |||
| 982 | FILE *fp); | |||
| 983 | ||||
| 984 | /** | |||
| 985 | * @brief parses a pcie event fifo data to text or json formats | |||
| 986 | * | |||
| 987 | * @param pevent_descriptor, input event descriptor data | |||
| 988 | * @param pevent_descriptor_obj, event descriptor json object pointer | |||
| 989 | * @param pevent_specific_data, input event specific data | |||
| 990 | * @param pevent_fifos_object, event fifos json object pointer | |||
| 991 | * @param fp, input file pointer | |||
| 992 | * | |||
| 993 | * @return 0 success | |||
| 994 | */ | |||
| 995 | int parse_pcie_event( | |||
| 996 | struct nvme_ocp_telemetry_event_descriptor *pevent_descriptor, | |||
| 997 | struct json_object *pevent_descriptor_obj, | |||
| 998 | __u8 *pevent_specific_data, | |||
| 999 | struct json_object *pevent_fifos_object, | |||
| 1000 | FILE *fp); | |||
| 1001 | ||||
| 1002 | /** | |||
| 1003 | * @brief parses a nvme event fifo data to text or json formats | |||
| 1004 | * | |||
| 1005 | * @param pevent_descriptor, input event descriptor data | |||
| 1006 | * @param pevent_descriptor_obj, event descriptor json object pointer | |||
| 1007 | * @param pevent_specific_data, input event specific data | |||
| 1008 | * @param pevent_fifos_object, event fifos json object pointer | |||
| 1009 | * @param fp, input file pointer | |||
| 1010 | * | |||
| 1011 | * @return 0 success | |||
| 1012 | */ | |||
| 1013 | int parse_nvme_event( | |||
| 1014 | struct nvme_ocp_telemetry_event_descriptor *pevent_descriptor, | |||
| 1015 | struct json_object *pevent_descriptor_obj, | |||
| 1016 | __u8 *pevent_specific_data, | |||
| 1017 | struct json_object *pevent_fifos_object, | |||
| 1018 | FILE *fp); | |||
| 1019 | ||||
| 1020 | /** | |||
| 1021 | * @brief parses common event fifo data to text or json formats | |||
| 1022 | * | |||
| 1023 | * @param pevent_descriptor, input event descriptor data | |||
| 1024 | * @param pevent_descriptor_obj, event descriptor json object pointer | |||
| 1025 | * @param pevent_specific_data, input event specific data | |||
| 1026 | * @param pevent_fifos_object, event fifos json object pointer | |||
| 1027 | * @param fp, input file pointer | |||
| 1028 | * | |||
| 1029 | * @return | |||
| 1030 | */ | |||
| 1031 | void parse_common_event(struct nvme_ocp_telemetry_event_descriptor *pevent_descriptor, | |||
| 1032 | struct json_object *pevent_descriptor_obj, __u8 *pevent_specific_data, | |||
| 1033 | struct json_object *pevent_fifos_object, FILE *fp); | |||
| 1034 | ||||
| 1035 | /** | |||
| 1036 | * @brief parses a media-wear event fifo data to text or json formats | |||
| 1037 | * | |||
| 1038 | * @param pevent_descriptor, input event descriptor data | |||
| 1039 | * @param pevent_descriptor_obj, event descriptor json object pointer | |||
| 1040 | * @param pevent_specific_data, input event specific data | |||
| 1041 | * @param pevent_fifos_object, event fifos json object pointer | |||
| 1042 | * @param fp, input file pointer | |||
| 1043 | * | |||
| 1044 | * @return 0 success | |||
| 1045 | */ | |||
| 1046 | int parse_media_wear_event( | |||
| 1047 | struct nvme_ocp_telemetry_event_descriptor *pevent_descriptor, | |||
| 1048 | struct json_object *pevent_descriptor_obj, | |||
| 1049 | __u8 *pevent_specific_data, | |||
| 1050 | struct json_object *pevent_fifos_object, | |||
| 1051 | FILE *fp); | |||
| 1052 | ||||
| 1053 | /** | |||
| 1054 | * @brief parses a virtual FIFO event fifo data to text or json formats | |||
| 1055 | * | |||
| 1056 | * @param pevent_descriptor, input event descriptor data | |||
| 1057 | * @param pevent_descriptor_obj, event descriptor json object pointer | |||
| 1058 | * @param pevent_specific_data, input event specific data | |||
| 1059 | * @param pevent_fifos_object, event fifos json object pointer | |||
| 1060 | * @param fp, input file pointer | |||
| 1061 | * | |||
| 1062 | * @return 0 success | |||
| 1063 | */ | |||
| 1064 | int parse_virtual_fifo_event( | |||
| 1065 | struct nvme_ocp_telemetry_event_descriptor *pevent_descriptor, | |||
| 1066 | struct json_object *pevent_descriptor_obj, | |||
| 1067 | __u8 *pevent_specific_data, | |||
| 1068 | struct json_object *pevent_fifos_object, | |||
| 1069 | FILE *fp); | |||
| 1070 | ||||
| 1071 | /** | |||
| 1072 | * @brief parses a SMBUS/I2C/I3C event fifo data to text or json formats | |||
| 1073 | * | |||
| 1074 | * @param pevent_descriptor, input event descriptor data | |||
| 1075 | * @param pevent_descriptor_obj, event descriptor json object pointer | |||
| 1076 | * @param pevent_specific_data, input event specific data | |||
| 1077 | * @param pevent_fifos_object, event fifos json object pointer | |||
| 1078 | * @param fp, input file pointer | |||
| 1079 | * | |||
| 1080 | * @return 0 success | |||
| 1081 | */ | |||
| 1082 | int parse_smbus_event( | |||
| 1083 | struct nvme_ocp_telemetry_event_descriptor *pevent_descriptor, | |||
| 1084 | struct json_object *pevent_descriptor_obj, | |||
| 1085 | __u8 *pevent_specific_data, | |||
| 1086 | struct json_object *pevent_fifos_object, | |||
| 1087 | FILE *fp); | |||
| 1088 | ||||
| 1089 | /** | |||
| 1090 | * @brief parses a MCTP event fifo data to text or json formats | |||
| 1091 | * | |||
| 1092 | * @param pevent_descriptor, input event descriptor data | |||
| 1093 | * @param pevent_descriptor_obj, event descriptor json object pointer | |||
| 1094 | * @param pevent_specific_data, input event specific data | |||
| 1095 | * @param pevent_fifos_object, event fifos json object pointer | |||
| 1096 | * @param fp, input file pointer | |||
| 1097 | * | |||
| 1098 | * @return 0 success | |||
| 1099 | */ | |||
| 1100 | int parse_mctp_event( | |||
| 1101 | struct nvme_ocp_telemetry_event_descriptor *pevent_descriptor, | |||
| 1102 | struct json_object *pevent_descriptor_obj, | |||
| 1103 | __u8 *pevent_specific_data, | |||
| 1104 | struct json_object *pevent_fifos_object, | |||
| 1105 | FILE *fp); |