| File: | .build-ci/../plugins/ocp/ocp-print-json.c |
| Warning: | line 1099, column 3 Addition of a null pointer 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 | } |