Skip to content

Commit 41c026a

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 5a29bc9 commit 41c026a

5 files changed

Lines changed: 10 additions & 190 deletions

File tree

plugins/ocp/ocp-print-json.c

Lines changed: 1 addition & 176 deletions
Original file line numberDiff line numberDiff line change
@@ -138,171 +138,7 @@ static void json_fw_activation_history(const struct fw_activation_history *fw_hi
138138
printf("\n");
139139
}
140140

141-
static void json_smart_extended_log_v1(struct ocp_smart_extended_log *log)
142-
{
143-
struct json_object *root;
144-
struct json_object *pmuw;
145-
struct json_object *pmur;
146-
uint16_t smart_log_ver = 0;
147-
uint16_t dssd_version = 0;
148-
int i = 0;
149-
char guid[40];
150-
char ascii_arr[65];
151-
char *ascii = ascii_arr;
152-
153-
root = json_create_object();
154-
pmuw = json_create_object();
155-
pmur = json_create_object();
156-
157-
json_object_add_value_uint64(pmuw, "hi",
158-
le64_to_cpu(*(uint64_t *)&log->physical_media_units_written[8]));
159-
json_object_add_value_uint64(pmuw, "lo",
160-
le64_to_cpu(*(uint64_t *)&log->physical_media_units_written));
161-
json_object_add_value_object(root, "Physical media units written", pmuw);
162-
json_object_add_value_uint64(pmur, "hi",
163-
le64_to_cpu(*(uint64_t *)&log->physical_media_units_read[8]));
164-
json_object_add_value_uint64(pmur, "lo",
165-
le64_to_cpu(*(uint64_t *)&log->physical_media_units_read));
166-
json_object_add_value_object(root, "Physical media units read", pmur);
167-
json_object_add_value_uint64(root, "Bad user nand blocks - Raw",
168-
int48_to_long(log->bad_user_nand_blocks_raw));
169-
json_object_add_value_uint(root, "Bad user nand blocks - Normalized",
170-
le16_to_cpu(log->bad_user_nand_blocks_normalized));
171-
json_object_add_value_uint64(root, "Bad system nand blocks - Raw",
172-
int48_to_long(log->bad_system_nand_blocks_raw));
173-
json_object_add_value_uint(root, "Bad system nand blocks - Normalized",
174-
le16_to_cpu(log->bad_system_nand_blocks_normalized));
175-
json_object_add_value_uint64(root, "XOR recovery count",
176-
le64_to_cpu(log->xor_recovery_count));
177-
json_object_add_value_uint64(root, "Uncorrectable read error count",
178-
le64_to_cpu(log->uncorrectable_read_err_count));
179-
json_object_add_value_uint64(root, "Soft ecc error count",
180-
le64_to_cpu(log->soft_ecc_err_count));
181-
json_object_add_value_uint(root, "End to end detected errors",
182-
le32_to_cpu(log->end_to_end_detected_err));
183-
json_object_add_value_uint(root, "End to end corrected errors",
184-
le32_to_cpu(log->end_to_end_corrected_err));
185-
json_object_add_value_uint(root, "System data percent used",
186-
log->system_data_used_percent);
187-
json_object_add_value_uint64(root, "Refresh counts",
188-
int56_to_long(log->refresh_counts));
189-
json_object_add_value_uint(root, "Max User data erase counts",
190-
le32_to_cpu(log->user_data_erase_count_max));
191-
json_object_add_value_uint(root, "Min User data erase counts",
192-
le32_to_cpu(log->user_data_erase_count_min));
193-
json_object_add_value_uint(root, "Number of Thermal throttling events",
194-
log->thermal_throttling_event_count);
195-
json_object_add_value_uint(root, "Current throttling status",
196-
log->thermal_throttling_current_status);
197-
json_object_add_value_uint64(root, "PCIe correctable error count",
198-
le64_to_cpu(log->pcie_correctable_err_count));
199-
json_object_add_value_uint(root, "Incomplete shutdowns",
200-
le32_to_cpu(log->incomplete_shoutdowns));
201-
json_object_add_value_uint(root, "Percent free blocks",
202-
log->percent_free_blocks);
203-
json_object_add_value_uint(root, "Capacitor health",
204-
le16_to_cpu(log->capacitor_health));
205-
json_object_add_value_uint64(root, "Unaligned I/O",
206-
le64_to_cpu(log->unaligned_io));
207-
json_object_add_value_uint64(root, "Security Version Number",
208-
le64_to_cpu(log->security_version));
209-
json_object_add_value_uint64(root, "NUSE - Namespace utilization",
210-
le64_to_cpu(log->total_nuse));
211-
json_object_add_value_uint128(root, "PLP start count",
212-
le128_to_cpu(log->plp_start_count));
213-
json_object_add_value_uint128(root, "Endurance estimate",
214-
le128_to_cpu(log->endurance_estimate));
215-
smart_log_ver = le16_to_cpu(log->log_page_version);
216-
217-
json_object_add_value_uint(root, "Log page version", smart_log_ver);
218-
219-
memset((void *)guid, 0, 40);
220-
sprintf((char *)guid, "0x%"PRIx64"%"PRIx64"",
221-
le64_to_cpu(*(uint64_t *)&log->log_page_guid[8]),
222-
le64_to_cpu(*(uint64_t *)&log->log_page_guid));
223-
json_object_add_value_string(root, "Log page GUID", guid);
224-
225-
switch (smart_log_ver) {
226-
case 0 ... 1:
227-
break;
228-
default:
229-
case 5:
230-
json_object_add_value_uint(root, "NVMe Over Pcie Errata Version",
231-
log->nvme_over_pcie_errate_version);
232-
json_object_add_value_uint(root, "NVMe Mi Errata Version",
233-
log->nvme_mi_errata_version);
234-
json_object_add_value_uint(root, "Total media dies",
235-
le16_to_cpu(log->total_media_dies));
236-
json_object_add_value_uint(root, "Total die failure tolerance",
237-
le16_to_cpu(log->total_die_failure_tolerance));
238-
json_object_add_value_uint(root, "Media dies offline",
239-
le16_to_cpu(log->media_dies_offline));
240-
json_object_add_value_uint(root, "Max temperature recorded",
241-
log->max_temperature_recorded);
242-
json_object_add_value_uint64(root, "Nand avg erase count",
243-
le64_to_cpu(log->nand_avg_erase_count));
244-
json_object_add_value_uint(root, "Command timeouts",
245-
le32_to_cpu(log->command_timeouts));
246-
json_object_add_value_uint(root, "Sys area program fail count raw",
247-
le32_to_cpu(log->sys_area_program_fail_count_raw));
248-
json_object_add_value_uint(root, "Sys area program fail count noralized",
249-
log->sys_area_program_fail_count_normalized);
250-
json_object_add_value_uint(root, "Sys area uncorrectable read count raw",
251-
le32_to_cpu(log->sys_area_uncorr_read_count_raw));
252-
json_object_add_value_uint(root, "Sys area uncorrectable read count noralized",
253-
log->sys_area_uncorr_read_count_normalized);
254-
json_object_add_value_uint(root, "Sys area erase fail count raw",
255-
le32_to_cpu(log->sys_area_erase_fail_count_raw));
256-
json_object_add_value_uint(root, "Sys area erase fail count noralized",
257-
log->sys_area_erase_fail_count_normalized);
258-
json_object_add_value_uint(root, "Max peak power capability",
259-
le16_to_cpu(log->max_peak_power_capability));
260-
json_object_add_value_uint(root, "Current max avg power",
261-
le16_to_cpu(log->current_max_avg_power));
262-
json_object_add_value_uint64(root, "Lifetime power consumed",
263-
int48_to_long(log->lifetime_power_consumed));
264-
memset((void *)ascii, 0, 65);
265-
for (i = 0; i < 8; i++)
266-
ascii += sprintf(ascii, "%c", log->dssd_firmware_revision[i]);
267-
json_object_add_value_string(root, "Dssd firmware revision", ascii_arr);
268-
json_object_add_value_string(root, "Dssd firmware build UUID",
269-
util_uuid_to_string(log->dssd_firmware_build_uuid));
270-
ascii = ascii_arr;
271-
memset((void *)ascii, 0, 65);
272-
for (i = 0; i < 64; i++)
273-
ascii += sprintf(ascii, "%c", log->dssd_firmware_build_label[i]);
274-
json_object_add_value_string(root, "Dssd firmware build label", ascii_arr);
275-
fallthrough;
276-
case 4:
277-
json_object_add_value_uint(root, "NVMe Command Set Errata Version",
278-
log->nvme_cmdset_errata_version);
279-
json_object_add_value_uint(root, "Lowest Permitted Firmware Revision",
280-
le64_to_cpu(log->lowest_permitted_fw_rev));
281-
fallthrough;
282-
case 2 ... 3:
283-
json_object_add_value_uint(root, "Errata Version Field",
284-
log->dssd_errata_version);
285-
memcpy(&dssd_version, log->dssd_point_version, sizeof(dssd_version));
286-
json_object_add_value_uint(root, "Point Version Field",
287-
le16_to_cpu(dssd_version));
288-
memcpy(&dssd_version, log->dssd_minor_version, sizeof(dssd_version));
289-
json_object_add_value_uint(root, "Minor Version Field",
290-
le16_to_cpu(dssd_version));
291-
json_object_add_value_uint(root, "Major Version Field",
292-
log->dssd_major_version);
293-
json_object_add_value_uint(root, "NVMe Base Errata Version",
294-
log->nvme_base_errata_version);
295-
json_object_add_value_uint(root, "PCIe Link Retraining Count",
296-
le64_to_cpu(log->pcie_link_retaining_count));
297-
json_object_add_value_uint(root, "Power State Change Count",
298-
le64_to_cpu(log->power_state_change_count));
299-
}
300-
json_print_object(root, NULL);
301-
printf("\n");
302-
json_free_object(root);
303-
}
304-
305-
static void json_smart_extended_log_v2(struct ocp_smart_extended_log *log)
141+
static void json_smart_extended_log(struct ocp_smart_extended_log *log)
306142
{
307143
struct json_object *root;
308144
struct json_object *pmuw;
@@ -466,17 +302,6 @@ static void json_smart_extended_log_v2(struct ocp_smart_extended_log *log)
466302
json_free_object(root);
467303
}
468304

469-
static void json_smart_extended_log(struct ocp_smart_extended_log *log, unsigned int version)
470-
{
471-
switch (version) {
472-
default:
473-
case 1:
474-
json_smart_extended_log_v1(log);
475-
break;
476-
case 2:
477-
json_smart_extended_log_v2(log);
478-
}
479-
}
480305
static void json_telemetry_log(struct ocp_telemetry_parse_options *options)
481306
{
482307
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
@@ -97,7 +97,7 @@ static void stdout_fw_activation_history(const struct fw_activation_history *fw_
9797
printf("\n");
9898
}
9999

100-
static void stdout_smart_extended_log(struct ocp_smart_extended_log *log, unsigned int version)
100+
static void stdout_smart_extended_log(struct ocp_smart_extended_log *log)
101101
{
102102
uint16_t smart_log_ver = 0;
103103
uint16_t dssd_version = 0;

plugins/ocp/ocp-print.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ void ocp_fw_act_history(const struct fw_activation_history *fw_history, nvme_pri
3636
ocp_print(fw_act_history, flags, fw_history);
3737
}
3838

39-
void ocp_smart_extended_log(struct ocp_smart_extended_log *log, unsigned int version,
39+
void ocp_smart_extended_log(struct ocp_smart_extended_log *log,
4040
nvme_print_flags_t flags)
4141
{
42-
ocp_print(smart_extended_log, flags, log, version);
42+
ocp_print(smart_extended_log, flags, log);
4343
}
4444

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

plugins/ocp/ocp-print.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
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);
14-
void (*smart_extended_log)(struct ocp_smart_extended_log *log, unsigned int version);
14+
void (*smart_extended_log)(struct ocp_smart_extended_log *log);
1515
void (*telemetry_log)(struct ocp_telemetry_parse_options *options);
1616
void (*c3_log)(struct nvme_transport_handle *hdl, struct ssd_latency_monitor_log *log_data);
1717
void (*c5_log)(struct nvme_transport_handle *hdl, struct unsupported_requirement_log *log_data);
@@ -37,8 +37,8 @@ static inline struct ocp_print_ops *ocp_get_json_print_ops(nvme_print_flags_t fl
3737

3838
void ocp_show_hwcomp_log(struct hwcomp_log *log, __u32 id, bool list, nvme_print_flags_t flags);
3939
void ocp_fw_act_history(const struct fw_activation_history *fw_history, nvme_print_flags_t flags);
40-
void ocp_smart_extended_log(struct ocp_smart_extended_log *log, unsigned int version,
41-
nvme_print_flags_t flags);
40+
void ocp_smart_extended_log(struct ocp_smart_extended_log *log,
41+
nvme_print_flags_t flags);
4242
void ocp_show_telemetry_log(struct ocp_telemetry_parse_options *options, nvme_print_flags_t flags);
4343
void ocp_c3_log(struct nvme_transport_handle *hdl, struct ssd_latency_monitor_log *log_data,
4444
nvme_print_flags_t flags);

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

Lines changed: 3 additions & 8 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;
@@ -86,7 +85,7 @@ static int get_c0_log_page(struct nvme_transport_handle *hdl, char *format,
8685
}
8786

8887
/* print the data */
89-
ocp_smart_extended_log(data, format_version, fmt);
88+
ocp_smart_extended_log(data, fmt);
9089
} else {
9190
fprintf(stderr, "ERROR : OCP : Unable to read C0 data from buffer\n");
9291
}
@@ -106,26 +105,22 @@ int ocp_smart_add_log(int argc, char **argv, struct command *acmd,
106105

107106
struct config {
108107
char *output_format;
109-
unsigned int output_format_version;
110108
};
111109

112110
struct config cfg = {
113111
.output_format = "normal",
114-
.output_format_version = 1,
115112
};
116113

117114
OPT_ARGS(opts) = {
118115
OPT_FMT("output-format", 'o', &cfg.output_format, "output Format: normal|json"),
119-
OPT_UINT("output-format-version", 0, &cfg.output_format_version, "output Format version: 1|2"),
120116
OPT_END()
121117
};
122118

123119
ret = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
124120
if (ret)
125121
return ret;
126122

127-
ret = get_c0_log_page(hdl, cfg.output_format,
128-
cfg.output_format_version);
123+
ret = get_c0_log_page(hdl, cfg.output_format);
129124
if (ret)
130125
fprintf(stderr, "ERROR : OCP : Failure reading the C0 Log Page, ret = %d\n",
131126
ret);

0 commit comments

Comments
 (0)