Skip to content

Commit 616159f

Browse files
committed
ocp-print-json: delete extended SMART health data v1 output format
This is to use only the v2 output format. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent 2997f55 commit 616159f

5 files changed

Lines changed: 9 additions & 194 deletions

File tree

plugins/ocp/ocp-print-json.c

Lines changed: 1 addition & 184 deletions
Original file line numberDiff line numberDiff line change
@@ -204,179 +204,7 @@ static void json_fw_activation_history(const struct fw_activation_history *fw_hi
204204
printf("\n");
205205
}
206206

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-
int i = 0;
215-
char guid[40];
216-
char ascii_arr[65];
217-
char *ascii = ascii_arr;
218-
219-
root = json_create_object();
220-
pmuw = json_create_object();
221-
pmur = json_create_object();
222-
223-
json_object_add_value_uint64(pmuw, "hi",
224-
le64_to_cpu(*(uint64_t *)&log->physical_media_units_written[8]));
225-
json_object_add_value_uint64(pmuw, "lo",
226-
le64_to_cpu(*(uint64_t *)&log->physical_media_units_written));
227-
json_object_add_value_object(root, "Physical media units written", pmuw);
228-
json_object_add_value_uint64(pmur, "hi",
229-
le64_to_cpu(*(uint64_t *)&log->physical_media_units_read[8]));
230-
json_object_add_value_uint64(pmur, "lo",
231-
le64_to_cpu(*(uint64_t *)&log->physical_media_units_read));
232-
json_object_add_value_object(root, "Physical media units read", pmur);
233-
json_object_add_value_uint64(root, "Bad user nand blocks - Raw",
234-
int48_to_long(log->bad_user_nand_blocks_raw));
235-
json_object_add_value_uint(root, "Bad user nand blocks - Normalized",
236-
le16_to_cpu(log->bad_user_nand_blocks_normalized));
237-
json_object_add_value_uint64(root, "Bad system nand blocks - Raw",
238-
int48_to_long(log->bad_system_nand_blocks_raw));
239-
json_object_add_value_uint(root, "Bad system nand blocks - Normalized",
240-
le16_to_cpu(log->bad_system_nand_blocks_normalized));
241-
json_object_add_value_uint64(root, "XOR recovery count",
242-
le64_to_cpu(log->xor_recovery_count));
243-
json_object_add_value_uint64(root, "Uncorrectable read error count",
244-
le64_to_cpu(log->uncorrectable_read_err_count));
245-
json_object_add_value_uint64(root, "Soft ecc error count",
246-
le64_to_cpu(log->soft_ecc_err_count));
247-
json_object_add_value_uint(root, "End to end detected errors",
248-
le32_to_cpu(log->end_to_end_detected_err));
249-
json_object_add_value_uint(root, "End to end corrected errors",
250-
le32_to_cpu(log->end_to_end_corrected_err));
251-
json_object_add_value_uint(root, "System data percent used",
252-
log->system_data_used_percent);
253-
json_object_add_value_uint64(root, "Refresh counts",
254-
int56_to_long(log->refresh_counts));
255-
json_object_add_value_uint(root, "Max User data erase counts",
256-
le32_to_cpu(log->user_data_erase_count_max));
257-
json_object_add_value_uint(root, "Min User data erase counts",
258-
le32_to_cpu(log->user_data_erase_count_min));
259-
json_object_add_value_uint(root, "Number of Thermal throttling events",
260-
log->thermal_throttling_event_count);
261-
json_object_add_value_uint(root, "Current throttling status",
262-
log->thermal_throttling_current_status);
263-
json_object_add_value_uint64(root, "PCIe correctable error count",
264-
le64_to_cpu(log->pcie_correctable_err_count));
265-
json_object_add_value_uint(root, "Incomplete shutdowns",
266-
le32_to_cpu(log->incomplete_shoutdowns));
267-
json_object_add_value_uint(root, "Percent free blocks",
268-
log->percent_free_blocks);
269-
json_object_add_value_uint(root, "Capacitor health",
270-
le16_to_cpu(log->capacitor_health));
271-
json_object_add_value_uint64(root, "Unaligned I/O",
272-
le64_to_cpu(log->unaligned_io));
273-
json_object_add_value_uint64(root, "Security Version Number",
274-
le64_to_cpu(log->security_version));
275-
json_object_add_value_uint64(root, "NUSE - Namespace utilization",
276-
le64_to_cpu(log->total_nuse));
277-
json_object_add_value_uint128(root, "PLP start count",
278-
le128_to_cpu(log->plp_start_count));
279-
json_object_add_value_uint128(root, "Endurance estimate",
280-
le128_to_cpu(log->endurance_estimate));
281-
smart_log_ver = le16_to_cpu(log->log_page_version);
282-
283-
json_object_add_value_uint(root, "Log page version", smart_log_ver);
284-
285-
memset((void *)guid, 0, 40);
286-
sprintf((char *)guid, "0x%"PRIx64"%"PRIx64"",
287-
le64_to_cpu(*(uint64_t *)&log->log_page_guid[8]),
288-
le64_to_cpu(*(uint64_t *)&log->log_page_guid));
289-
json_object_add_value_string(root, "Log page GUID", guid);
290-
291-
switch (smart_log_ver) {
292-
case 0 ... 1:
293-
break;
294-
default:
295-
case 6:
296-
json_object_add_value_uint(root, "Form factor",
297-
log->form_factor);
298-
json_object_add_value_uint64(root, "Die use badnandblock raw",
299-
int48_to_long(log->die_in_use_bad_nand_block_raw));
300-
json_object_add_value_uint(root, "Die use badnandblock normal",
301-
le16_to_cpu(log->die_in_use_bad_nand_block_normalized));
302-
fallthrough;
303-
case 5:
304-
json_object_add_value_uint(root, "NVMe Over Pcie Errata Version",
305-
log->nvme_over_pcie_errate_version);
306-
json_object_add_value_uint(root, "NVMe Mi Errata Version",
307-
log->nvme_mi_errata_version);
308-
json_object_add_value_uint(root, "Total media dies",
309-
le16_to_cpu(log->total_media_dies));
310-
json_object_add_value_uint(root, "Total die failure tolerance",
311-
le16_to_cpu(log->total_die_failure_tolerance));
312-
json_object_add_value_uint(root, "Media dies offline",
313-
le16_to_cpu(log->media_dies_offline));
314-
json_object_add_value_uint(root, "Max temperature recorded",
315-
log->max_temperature_recorded);
316-
json_object_add_value_uint64(root, "Nand avg erase count",
317-
le64_to_cpu(log->nand_avg_erase_count));
318-
json_object_add_value_uint(root, "Command timeouts",
319-
le32_to_cpu(log->command_timeouts));
320-
json_object_add_value_uint(root, "Sys area program fail count raw",
321-
le32_to_cpu(log->sys_area_program_fail_count_raw));
322-
json_object_add_value_uint(root, "Sys area program fail count noralized",
323-
log->sys_area_program_fail_count_normalized);
324-
json_object_add_value_uint(root, "Sys area uncorrectable read count raw",
325-
le32_to_cpu(log->sys_area_uncorr_read_count_raw));
326-
json_object_add_value_uint(root, "Sys area uncorrectable read count noralized",
327-
log->sys_area_uncorr_read_count_normalized);
328-
json_object_add_value_uint(root, "Sys area erase fail count raw",
329-
le32_to_cpu(log->sys_area_erase_fail_count_raw));
330-
json_object_add_value_uint(root, "Sys area erase fail count noralized",
331-
log->sys_area_erase_fail_count_normalized);
332-
json_object_add_value_uint(root, "Max peak power capability",
333-
le16_to_cpu(log->max_peak_power_capability));
334-
json_object_add_value_uint(root, "Current max avg power",
335-
le16_to_cpu(log->current_max_avg_power));
336-
json_object_add_value_uint64(root, "Lifetime power consumed",
337-
int48_to_long(log->lifetime_power_consumed));
338-
memset((void *)ascii, 0, 65);
339-
for (i = 0; i < 8; i++)
340-
ascii += sprintf(ascii, "%c", log->dssd_firmware_revision[i]);
341-
json_object_add_value_string(root, "Dssd firmware revision", ascii_arr);
342-
json_object_add_value_string(root, "Dssd firmware build UUID",
343-
util_uuid_to_string(log->dssd_firmware_build_uuid));
344-
ascii = ascii_arr;
345-
memset((void *)ascii, 0, 65);
346-
for (i = 0; i < 64; i++)
347-
ascii += sprintf(ascii, "%c", log->dssd_firmware_build_label[i]);
348-
json_object_add_value_string(root, "Dssd firmware build label", ascii_arr);
349-
fallthrough;
350-
case 4:
351-
json_object_add_value_uint(root, "NVMe Command Set Errata Version",
352-
log->nvme_cmdset_errata_version);
353-
json_object_add_value_uint(root, "Lowest Permitted Firmware Revision",
354-
le64_to_cpu(log->lowest_permitted_fw_rev));
355-
fallthrough;
356-
case 2 ... 3:
357-
json_object_add_value_uint(root, "Errata Version Field",
358-
log->dssd_errata_version);
359-
memcpy(&dssd_version, log->dssd_point_version, sizeof(dssd_version));
360-
json_object_add_value_uint(root, "Point Version Field",
361-
le16_to_cpu(dssd_version));
362-
memcpy(&dssd_version, log->dssd_minor_version, sizeof(dssd_version));
363-
json_object_add_value_uint(root, "Minor Version Field",
364-
le16_to_cpu(dssd_version));
365-
json_object_add_value_uint(root, "Major Version Field",
366-
log->dssd_major_version);
367-
json_object_add_value_uint(root, "NVMe Base Errata Version",
368-
log->nvme_base_errata_version);
369-
json_object_add_value_uint(root, "PCIe Link Retraining Count",
370-
le64_to_cpu(log->pcie_link_retaining_count));
371-
json_object_add_value_uint(root, "Power State Change Count",
372-
le64_to_cpu(log->power_state_change_count));
373-
}
374-
json_print_object(root, NULL);
375-
printf("\n");
376-
json_free_object(root);
377-
}
378-
379-
static void json_smart_extended_log_v2(struct ocp_smart_extended_log *log)
207+
static void json_smart_extended_log(struct ocp_smart_extended_log *log)
380208
{
381209
struct json_object *root;
382210
struct json_object *pmuw;
@@ -540,17 +368,6 @@ static void json_smart_extended_log_v2(struct ocp_smart_extended_log *log)
540368
json_free_object(root);
541369
}
542370

543-
static void json_smart_extended_log(struct ocp_smart_extended_log *log, unsigned int version)
544-
{
545-
switch (version) {
546-
default:
547-
case 1:
548-
json_smart_extended_log_v1(log);
549-
break;
550-
case 2:
551-
json_smart_extended_log_v2(log);
552-
}
553-
}
554371
static void json_telemetry_log(struct ocp_telemetry_parse_options *options)
555372
{
556373
print_ocp_telemetry_json(options);

plugins/ocp/ocp-print-stdout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static void stdout_fw_activation_history(const struct fw_activation_history *fw_
100100
printf("\n");
101101
}
102102

103-
static void stdout_smart_extended_log(struct ocp_smart_extended_log *log, unsigned int version)
103+
static void stdout_smart_extended_log(struct ocp_smart_extended_log *log)
104104
{
105105
uint16_t smart_log_ver = 0;
106106
uint16_t dssd_version = 0;

plugins/ocp/ocp-print.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ void ocp_show_persistent_event_log(void *pevent_log_info,
4444
pevent_log_info, action, size, devname);
4545
}
4646

47-
void ocp_smart_extended_log(struct ocp_smart_extended_log *log, unsigned int version,
47+
void ocp_smart_extended_log(struct ocp_smart_extended_log *log,
4848
nvme_print_flags_t flags)
4949
{
50-
ocp_print(smart_extended_log, flags, log, version);
50+
ocp_print(smart_extended_log, flags, log);
5151
}
5252

5353
void ocp_show_telemetry_log(struct ocp_telemetry_parse_options *options, nvme_print_flags_t flags)

plugins/ocp/ocp-print.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct ocp_print_ops {
1212
void (*hwcomp_log)(struct hwcomp_log *log, __u32 id, bool list);
1313
void (*fw_act_history)(const struct fw_activation_history *fw_history);
1414
void (*persistent_event_log)(void *pevent_log_info, __u8 action, __u32 size, const char *devname);
15-
void (*smart_extended_log)(struct ocp_smart_extended_log *log, unsigned int version);
15+
void (*smart_extended_log)(struct ocp_smart_extended_log *log);
1616
void (*telemetry_log)(struct ocp_telemetry_parse_options *options);
1717
void (*c3_log)(struct nvme_transport_handle *hdl, struct ssd_latency_monitor_log *log_data);
1818
void (*c5_log)(struct nvme_transport_handle *hdl, struct unsupported_requirement_log *log_data);
@@ -41,7 +41,7 @@ void ocp_fw_act_history(const struct fw_activation_history *fw_history, nvme_pri
4141
void ocp_show_persistent_event_log(void *pevent_log_info,
4242
__u8 action, __u32 size, const char *devname,
4343
nvme_print_flags_t flags);
44-
void ocp_smart_extended_log(struct ocp_smart_extended_log *log, unsigned int version,
44+
void ocp_smart_extended_log(struct ocp_smart_extended_log *log,
4545
nvme_print_flags_t flags);
4646
void ocp_show_telemetry_log(struct ocp_telemetry_parse_options *options, nvme_print_flags_t flags);
4747
void ocp_c3_log(struct nvme_transport_handle *hdl, struct ssd_latency_monitor_log *log_data,

plugins/ocp/ocp-smart-extended-log.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ static __u8 scao_guid[GUID_LEN] = {
2626
0xC9, 0x14, 0xD5, 0xAF
2727
};
2828

29-
static int get_c0_log_page(struct nvme_transport_handle *hdl, char *format,
30-
unsigned int format_version)
29+
static int get_c0_log_page(struct nvme_transport_handle *hdl, char *format)
3130
{
3231
struct ocp_smart_extended_log *data;
3332
struct nvme_passthru_cmd cmd;
@@ -85,7 +84,7 @@ static int get_c0_log_page(struct nvme_transport_handle *hdl, char *format,
8584
}
8685

8786
/* print the data */
88-
ocp_smart_extended_log(data, format_version, fmt);
87+
ocp_smart_extended_log(data, fmt);
8988
} else {
9089
fprintf(stderr, "ERROR : OCP : Unable to read C0 data from buffer\n");
9190
}
@@ -109,8 +108,7 @@ int ocp_smart_add_log(int argc, char **argv, struct command *acmd,
109108
if (ret)
110109
return ret;
111110

112-
ret = get_c0_log_page(hdl, nvme_args.output_format,
113-
nvme_args.output_format_ver);
111+
ret = get_c0_log_page(hdl, nvme_args.output_format);
114112
if (ret)
115113
fprintf(stderr, "ERROR : OCP : Failure reading the C0 Log Page, ret = %d\n",
116114
ret);

0 commit comments

Comments
 (0)