Skip to content

Commit 9098460

Browse files
author
Gopinath P/Gopinath P
committed
plugin/ocp: Added OCP 2.7 smart extended log changes
ocp_smart_extended_log strcuture enhancement and print statement modification in stdout_smart_extended_log and json_smart_extended_log_v1 Signed-off-by: Gopinath P/Gopinath P <[email protected]> Reviewed-by: Karthik Balan [email protected] Reviewed-by: Arunpandian J [email protected]
1 parent 549a13a commit 9098460

9 files changed

Lines changed: 69 additions & 70 deletions

plugins/ocp/ocp-clear-features.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ static int ocp_clear_feature(int argc, char **argv, const char *desc, const __u8
1616
{
1717
_cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL;
1818
_cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL;
19-
__u32 result = 0;
19+
__u64 result = 0;
2020
__u32 clear = 1 << 31;
2121
__u8 uuid_index = 0;
2222
bool uuid = true;
@@ -67,7 +67,7 @@ int get_ocp_error_counters(int argc, char **argv, struct command *acmd,
6767

6868
_cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL;
6969
_cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL;
70-
__u32 result;
70+
__u64 result;
7171
int err;
7272
bool uuid;
7373
__u8 uuid_index = 0;
@@ -107,8 +107,8 @@ int get_ocp_error_counters(int argc, char **argv, struct command *acmd,
107107
err = nvme_get_features(hdl, cfg.nsid, OCP_FID_CPCIE, cfg.sel, 0,
108108
uuid_index, NULL, 0, &result);
109109
if (!err) {
110-
printf("get-feature:0xC3 %s value: %#08x\n",
111-
nvme_select_to_string(cfg.sel), result);
110+
printf("get-feature:0xC3 %s value: %#016"PRIx64"\n",
111+
nvme_select_to_string(cfg.sel), (uint64_t)result);
112112

113113
if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED)
114114
nvme_show_select_result(0xC3, result);

plugins/ocp/ocp-fw-activation-history.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ int ocp_fw_activation_history_log(int argc, char **argv, struct command *acmd,
5858
cmd.cdw14 |= NVME_FIELD_ENCODE(uuid_index,
5959
NVME_LOG_CDW14_UUID_SHIFT,
6060
NVME_LOG_CDW14_UUID_MASK);
61-
err = nvme_get_log(hdl, &cmd, false,
62-
NVME_LOG_PAGE_PDU_SIZE, NULL);
61+
err = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE);
6362
if (err)
6463
nvme_show_status(err);
6564

plugins/ocp/ocp-hardware-component-log.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ static int get_hwcomp_log_data(struct nvme_transport_handle *hdl, struct hwcomp_
188188
cmd.cdw14 |= NVME_FIELD_ENCODE(uidx,
189189
NVME_LOG_CDW14_UUID_SHIFT,
190190
NVME_LOG_CDW14_UUID_MASK);
191-
ret = nvme_get_log(hdl, &cmd, false,
192-
NVME_LOG_PAGE_PDU_SIZE, NULL);
191+
ret = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE);
193192
if (ret) {
194193
print_info_error("error: ocp: failed to get hwcomp log size (ret: %d)\n", ret);
195194
return ret;
@@ -229,8 +228,7 @@ static int get_hwcomp_log_data(struct nvme_transport_handle *hdl, struct hwcomp_
229228
(enum nvme_cmd_get_log_lid)OCP_LID_HWCOMP,
230229
NVME_CSI_NVM, log->desc, len);
231230
nvme_init_get_log_lpo(&cmd, desc_offset);
232-
ret = nvme_get_log(hdl, &cmd, false,
233-
NVME_LOG_PAGE_PDU_SIZE, NULL);
231+
ret = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE);
234232
if (ret) {
235233
print_info_error("error: ocp: failed to get log page (hwcomp: %02X, ret: %d)\n",
236234
OCP_LID_HWCOMP, ret);

plugins/ocp/ocp-nvme.c

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ int ocp_set_latency_monitor_feature(int argc, char **argv, struct command *acmd,
298298
int err = -1;
299299
_cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL;
300300
_cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL;
301-
__u32 result;
301+
__u64 result;
302302
struct feature_latency_monitor buf = { 0 };
303303
__u32 nsid = NVME_NSID_ALL;
304304
struct stat nvme_stat;
@@ -422,7 +422,7 @@ static int ocp_get_latency_monitor_feature(int argc, char **argv, struct command
422422
_cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL;
423423
_cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL;
424424

425-
__u32 result;
425+
__u64 result;
426426
int err;
427427
bool uuid;
428428
__u8 uuid_index = 0;
@@ -462,8 +462,8 @@ static int ocp_get_latency_monitor_feature(int argc, char **argv, struct command
462462
err = nvme_get_features(hdl, cfg.nsid, OCP_FID_LM, cfg.sel, 0,
463463
uuid_index, NULL, 0, &result);
464464
if (!err) {
465-
printf("get-feature:0xC5 %s value: %#08x\n",
466-
nvme_select_to_string(cfg.sel), result);
465+
printf("get-feature:0xC5 %s value: %#016"PRIx64"\n",
466+
nvme_select_to_string(cfg.sel), (uint64_t)result);
467467

468468
if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED)
469469
nvme_show_select_result(0xC5, result);
@@ -500,7 +500,7 @@ static int eol_plp_failure_mode_get(struct nvme_transport_handle *hdl, const __u
500500
__u8 sel, bool uuid)
501501
{
502502
__u8 uidx = 0;
503-
__u32 result;
503+
__u64 result;
504504
int err;
505505

506506
if (uuid) {
@@ -531,7 +531,7 @@ static int eol_plp_failure_mode_set(struct nvme_transport_handle *hdl, const __u
531531
const __u8 fid, __u8 mode, bool sv,
532532
bool uuid)
533533
{
534-
__u32 result;
534+
__u64 result;
535535
int err;
536536
__u8 uidx = 0;
537537

@@ -689,7 +689,7 @@ static int get_telemetry_data(struct nvme_transport_handle *hdl, __u32 ns, __u8
689689
cmd.cdw12 = (__u32)(0x00000000FFFFFFFF & offset);
690690
cmd.cdw13 = (__u32)((0xFFFFFFFF00000000 & offset) >> 8);
691691
cmd.cdw14 = 0;
692-
return nvme_submit_admin_passthru(hdl, &cmd, NULL);
692+
return nvme_submit_admin_passthru(hdl, &cmd);
693693
}
694694

695695
static void print_telemetry_data_area_1(struct telemetry_data_area_1 *da1,
@@ -838,7 +838,7 @@ static int extract_dump_get_log(struct nvme_transport_handle *hdl, char *feature
838838
nvme_init_get_log(&cmd, nsid, log_id, NVME_CSI_NVM,
839839
data, transfersize);
840840
nvme_init_get_log_lpo(&cmd, offset);
841-
err = nvme_get_log(hdl, &cmd, rae, NVME_LOG_PAGE_PDU_SIZE, NULL);
841+
err = nvme_get_log(hdl, &cmd, rae, NVME_LOG_PAGE_PDU_SIZE);
842842
if (err) {
843843
if (i > 0)
844844
goto close_output;
@@ -1218,7 +1218,7 @@ static int get_telemetry_log_page_data(struct nvme_transport_handle *hdl,
12181218
cmd.cdw10 |= NVME_FIELD_ENCODE(NVME_LOG_TELEM_HOST_LSP_CREATE,
12191219
NVME_LOG_CDW10_LSP_SHIFT,
12201220
NVME_LOG_CDW10_LSP_MASK);
1221-
err = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL);
1221+
err = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE);
12221222
if (err < 0)
12231223
nvme_show_error("Failed to fetch the log from drive.\n");
12241224
else if (err > 0) {
@@ -1255,7 +1255,7 @@ static int get_telemetry_log_page_data(struct nvme_transport_handle *hdl,
12551255
nvme_init_get_log(&cmd, NVME_NSID_ALL, log_id, NVME_CSI_NVM,
12561256
telemetry_log, bs);
12571257
nvme_init_get_log_lpo(&cmd, offset);
1258-
err = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE, NULL);
1258+
err = nvme_get_log(hdl, &cmd, false, NVME_LOG_PAGE_PDU_SIZE);
12591259
if (err < 0) {
12601260
nvme_show_error("Failed to fetch the log from drive.\n");
12611261
break;
@@ -1938,7 +1938,7 @@ static int ocp_device_capabilities_log(int argc, char **argv, struct command *ac
19381938

19391939
static int ocp_set_telemetry_profile(struct nvme_transport_handle *hdl, __u8 tps)
19401940
{
1941-
__u32 result;
1941+
__u64 result;
19421942
int err;
19431943
__u8 uidx = 0;
19441944

@@ -2002,18 +2002,18 @@ static int ocp_set_telemetry_profile_feature(int argc, char **argv, struct comma
20022002
///////////////////////////////////////////////////////////////////////////////
20032003
///////////////////////////////////////////////////////////////////////////////
20042004
///////////////////////////////////////////////////////////////////////////////
2005-
/// DSSD Power State (Feature Identifier C8h) Get Feature
2005+
/// Telemetry Profile (Feature Identifier C8h) Get Feature
20062006
static int ocp_get_telemetry_profile_feature(int argc, char **argv, struct command *acmd,
20072007
struct plugin *plugin)
20082008
{
2009-
const char *desc = "Define Issue Get Feature command (FID: 0xC8) Latency Monitor";
2009+
const char *desc = "Define Issue Get Feature command (FID: 0xC8) Telemetry Profile";
20102010
const char *sel = "[0-3]: current/default/saved/supported/";
20112011
const char *nsid = "Byte[04-07]: Namespace Identifier Valid/Invalid/Inactive";
20122012

20132013
_cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL;
20142014
_cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL;
20152015

2016-
__u32 result;
2016+
__u64 result;
20172017
int err;
20182018
bool uuid;
20192019
__u8 uuid_index = 0;
@@ -2053,8 +2053,8 @@ static int ocp_get_telemetry_profile_feature(int argc, char **argv, struct comma
20532053
err = nvme_get_features(hdl, cfg.nsid, OCP_FID_TEL_CFG, cfg.sel, 0,
20542054
uuid_index, NULL, 0, &result);
20552055
if (!err) {
2056-
printf("get-feature:0xC8 %s value: %#08x\n",
2057-
nvme_select_to_string(cfg.sel), result);
2056+
printf("get-feature:0xC8 %s value: %#016"PRIx64"\n",
2057+
nvme_select_to_string(cfg.sel), (uint64_t)result);
20582058

20592059
if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED)
20602060
nvme_show_select_result(0xC8, result);
@@ -2077,7 +2077,7 @@ set_dssd_power_state(struct nvme_transport_handle *hdl,
20772077
const __u8 fid, __u8 power_state, bool sv,
20782078
bool uuid)
20792079
{
2080-
__u32 result;
2080+
__u64 result;
20812081
int err;
20822082
__u8 uidx = 0;
20832083

@@ -2154,7 +2154,7 @@ static int set_dssd_power_state_feature(int argc, char **argv, struct command *a
21542154
static int get_dssd_power_state(struct nvme_transport_handle *hdl, const __u32 nsid,
21552155
const __u8 fid, __u8 sel, bool uuid)
21562156
{
2157-
__u32 result;
2157+
__u64 result;
21582158
int err;
21592159
__u8 uuid_index = 0;
21602160

@@ -2169,7 +2169,8 @@ static int get_dssd_power_state(struct nvme_transport_handle *hdl, const __u32 n
21692169

21702170
err = nvme_get_features(hdl, nsid, fid, sel, 0, uuid_index, NULL, 0, &result);
21712171
if (!err) {
2172-
printf("get-feature:0xC7 %s value: %#08x\n", nvme_select_to_string(sel), result);
2172+
printf("get-feature:0xC7 %s value: %#016"PRIx64"\n",
2173+
nvme_select_to_string(sel), (uint64_t)result);
21732174

21742175
if (sel == NVME_GET_FEATURES_SEL_SUPPORTED)
21752176
nvme_show_select_result(fid, result);
@@ -2246,7 +2247,7 @@ static int set_plp_health_check_interval(int argc, char **argv, struct command *
22462247
_cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL;
22472248
_cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL;
22482249
int err;
2249-
__u32 result;
2250+
__u64 result;
22502251
__u8 uidx = 0;
22512252

22522253
struct config {
@@ -2305,7 +2306,7 @@ static int get_plp_health_check_interval(int argc, char **argv, struct command *
23052306
const __u8 fid = 0xc6;
23062307
_cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL;
23072308
_cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL;
2308-
__u32 result;
2309+
__u64 result;
23092310
int err;
23102311

23112312
struct config {
@@ -2328,7 +2329,8 @@ static int get_plp_health_check_interval(int argc, char **argv, struct command *
23282329
err = nvme_get_features(hdl, nsid, OCP_FID_PLPI, cfg.sel, 0, 0,
23292330
NULL, 0, &result);
23302331
if (!err) {
2331-
printf("get-feature:0xC6 %s value: %#08x\n", nvme_select_to_string(cfg.sel), result);
2332+
printf("get-feature:0xC6 %s value: %#016"PRIx64"\n",
2333+
nvme_select_to_string(cfg.sel), (uint64_t)result);
23322334

23332335
if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED)
23342336
nvme_show_select_result(fid, result);
@@ -2356,7 +2358,7 @@ static int set_dssd_async_event_config(int argc, char **argv, struct command *ac
23562358
_cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL;
23572359
_cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL;
23582360
int err;
2359-
__u32 result;
2361+
__u64 result;
23602362
__u8 uidx = 0;
23612363

23622364
struct config {
@@ -2411,7 +2413,7 @@ static int get_dssd_async_event_config(int argc, char **argv, struct command *ac
24112413
const __u8 fid = OCP_FID_DAEC;
24122414
_cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL;
24132415
_cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL;
2414-
__u32 result;
2416+
__u64 result;
24152417
int err;
24162418

24172419
struct config {
@@ -2433,7 +2435,8 @@ static int get_dssd_async_event_config(int argc, char **argv, struct command *ac
24332435

24342436
err = nvme_get_features(hdl, nsid, fid, cfg.sel, 0, 0, NULL, 0, &result);
24352437
if (!err) {
2436-
printf("get-feature:0xC9 %s value: %#08x\n", nvme_select_to_string(cfg.sel), result);
2438+
printf("get-feature:0xC9 %s value: %#016"PRIx64"\n",
2439+
nvme_select_to_string(cfg.sel), (uint64_t)result);
24372440

24382441
if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED)
24392442
nvme_show_select_result(fid, result);
@@ -2672,7 +2675,7 @@ static int error_injection_get(struct nvme_transport_handle *hdl, const __u8 sel
26722675
_cleanup_free_ struct erri_entry *entry = NULL;
26732676
struct erri_get_cq_entry cq_entry;
26742677
const __u8 fid = OCP_FID_ERRI;
2675-
__u32 *result = (__u32 *)&cq_entry;
2678+
__u64 result;
26762679
__u32 data_len = 0;
26772680
__u8 uidx = 0;
26782681
int err;
@@ -2696,13 +2699,14 @@ static int error_injection_get(struct nvme_transport_handle *hdl, const __u8 sel
26962699
}
26972700

26982701
err = nvme_get_features(hdl, 0, fid, sel, 0, uidx, entry,
2699-
data_len, result);
2702+
data_len, &result);
27002703
if (!err) {
2704+
cq_entry.nume = result;
27012705
nvme_show_result("Number of Error Injections (feature: %#0*x): %#0*x (%s: %d)",
27022706
fid ? 4 : 2, fid, cq_entry.nume ? 10 : 8, cq_entry.nume,
27032707
nvme_select_to_string(sel), cq_entry.nume);
27042708
if (sel == NVME_GET_FEATURES_SEL_SUPPORTED)
2705-
nvme_show_select_result(fid, *result);
2709+
nvme_show_select_result(fid, result);
27062710
for (i = 0; i < cq_entry.nume; i++) {
27072711
printf("Entry: %d, Flags: %x (%s%s), Type: %x (%s), NRTDP: %d\n", i,
27082712
entry[i].flags, entry[i].enable ? "Enabled" : "Disabled",
@@ -2850,7 +2854,7 @@ static int enable_ieee1667_silo_get(struct nvme_transport_handle *hdl, const __u
28502854
{
28512855
struct ieee1667_get_cq_entry cq_entry = { 0 };
28522856
const __u8 fid = OCP_FID_1667;
2853-
__u32 result;
2857+
__u64 result;
28542858
__u8 uidx = 0;
28552859
int err;
28562860

@@ -2912,6 +2916,7 @@ static int enable_ieee1667_silo_set(struct nvme_transport_handle *hdl,
29122916
bool save = argconfig_parse_seen(opts, "save");
29132917
struct ieee1667_get_cq_entry cq_entry;
29142918
const __u8 fid = OCP_FID_1667;
2919+
__u64 result;
29152920
__u32 cdw11;
29162921
__u8 uidx = 0;
29172922
int err;
@@ -2927,7 +2932,8 @@ static int enable_ieee1667_silo_set(struct nvme_transport_handle *hdl,
29272932

29282933
cdw11 = OCP_SET(enable, ENABLE_IEEE1667_SILO);
29292934
err = nvme_set_features(hdl, NVME_NSID_NONE, fid, save,
2930-
cdw11, 0, 0, uidx, 0, NULL, 0, (__u32 *)&cq_entry);
2935+
cdw11, 0, 0, uidx, 0, NULL, 0, &result);
2936+
memcpy(&cq_entry, &result, sizeof(cq_entry));
29312937
if (err > 0) {
29322938
nvme_show_status(err);
29332939
} else if (err < 0) {

plugins/ocp/ocp-print-json.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,7 @@ static void json_smart_extended_log_v1(struct ocp_smart_extended_log *log)
226226
case 0 ... 1:
227227
break;
228228
default:
229-
case 4:
230-
json_object_add_value_uint(root, "NVMe Command Set Errata Version",
231-
log->nvme_cmdset_errata_version);
232-
json_object_add_value_uint(root, "Lowest Permitted Firmware Revision",
233-
le64_to_cpu(log->lowest_permitted_fw_rev));
229+
case 5:
234230
json_object_add_value_uint(root, "NVMe Over Pcie Errata Version",
235231
log->nvme_over_pcie_errate_version);
236232
json_object_add_value_uint(root, "NVMe Mi Errata Version",
@@ -243,8 +239,6 @@ static void json_smart_extended_log_v1(struct ocp_smart_extended_log *log)
243239
le16_to_cpu(log->media_dies_offline));
244240
json_object_add_value_uint(root, "Max temperature recorded",
245241
log->max_temperature_recorded);
246-
json_object_add_value_uint(root, "Form factor",
247-
log->form_factor);
248242
json_object_add_value_uint64(root, "Nand avg erase count",
249243
le64_to_cpu(log->nand_avg_erase_count));
250244
json_object_add_value_uint(root, "Command timeouts",
@@ -278,8 +272,12 @@ static void json_smart_extended_log_v1(struct ocp_smart_extended_log *log)
278272
for (i = 0; i < 64; i++)
279273
ascii += sprintf(ascii, "%c", log->dssd_firmware_build_label[i]);
280274
json_object_add_value_string(root, "Dssd firmware build label", ascii_arr);
281-
json_object_add_value_uint(root, "Die in use bad nand block",
282-
le64_to_cpu(log->die_in_use_bad_nand_block));
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));
283281
fallthrough;
284282
case 2 ... 3:
285283
json_object_add_value_uint(root, "Errata Version Field",
@@ -392,11 +390,7 @@ static void json_smart_extended_log_v2(struct ocp_smart_extended_log *log)
392390
case 0 ... 1:
393391
break;
394392
default:
395-
case 4:
396-
json_object_add_value_uint(root, "nvme_command_set_errata_version",
397-
log->nvme_cmdset_errata_version);
398-
json_object_add_value_uint(root, "lowest_permitted_firmware_revision",
399-
le64_to_cpu(log->lowest_permitted_fw_rev));
393+
case 5:
400394
json_object_add_value_uint(root, "nvme_over_pcie_errata_version",
401395
log->nvme_over_pcie_errate_version);
402396
json_object_add_value_uint(root, "nvme_mi_errata_version",
@@ -443,6 +437,12 @@ static void json_smart_extended_log_v2(struct ocp_smart_extended_log *log)
443437
ascii += sprintf(ascii, "%c", log->dssd_firmware_build_label[i]);
444438
json_object_add_value_string(root, "dssd_firmware_build_label", ascii_arr);
445439
fallthrough;
440+
case 4:
441+
json_object_add_value_uint(root, "nvme_command_set_errata_version",
442+
log->nvme_cmdset_errata_version);
443+
json_object_add_value_uint(root, "lowest_permitted_firmware_revision",
444+
le64_to_cpu(log->lowest_permitted_fw_rev));
445+
fallthrough;
446446
case 2 ... 3:
447447
json_object_add_value_uint(root, "errata_version_field",
448448
log->dssd_errata_version);

0 commit comments

Comments
 (0)