diff options
Diffstat (limited to 'src/usr/util/runtime/rt_cmds.C')
-rw-r--r-- | src/usr/util/runtime/rt_cmds.C | 164 |
1 files changed, 136 insertions, 28 deletions
diff --git a/src/usr/util/runtime/rt_cmds.C b/src/usr/util/runtime/rt_cmds.C index c015215b5..aa23ae7c0 100644 --- a/src/usr/util/runtime/rt_cmds.C +++ b/src/usr/util/runtime/rt_cmds.C @@ -48,6 +48,7 @@ // switchToFspScomAccess #ifdef CONFIG_NVDIMM #include <isteps/nvdimm/nvdimm.H> // notify NVDIMM protection change +#include <util/runtime/rt_fwnotify.H> #endif extern char hbi_ImageId; @@ -1162,42 +1163,101 @@ void cmd_nvdimm_protection_msg( char* &o_output, uint32_t i_huid, { errlHndl_t l_err = nullptr; o_output = new char[500]; - uint8_t l_notifyType = NVDIMM::NOT_PROTECTED; TARGETING::Target* l_targ{}; l_targ = getTargetFromHUID(i_huid); - if (l_targ != NULL) - { - if (protection == 1) - { - l_notifyType = NVDIMM::PROTECTED; - l_err = notifyNvdimmProtectionChange(l_targ, NVDIMM::PROTECTED); - } - else if (protection == 2) - { - l_notifyType = NVDIMM::UNPROTECTED_BECAUSE_ERROR; - l_err = notifyNvdimmProtectionChange(l_targ, NVDIMM::UNPROTECTED_BECAUSE_ERROR); - } - else - { - l_err = notifyNvdimmProtectionChange(l_targ, NVDIMM::NOT_PROTECTED); - } - if (l_err) - { - sprintf( o_output, "Error on call to notifyNvdimmProtectionChange" - "(0x%.8X, %d), rc=0x%.8X, plid=0x%.8X", - i_huid, l_notifyType, ERRL_GETRC_SAFE(l_err), l_err->plid() ); - errlCommit(l_err, UTIL_COMP_ID); - return; - } + + // protection should match enum from nvdimm_protection_t + // No match will just return, no error generated + l_err = notifyNvdimmProtectionChange( l_targ, + (NVDIMM::nvdimm_protection_t)protection); + if (l_err) + { + sprintf( o_output, "Error on call to notifyNvdimmProtectionChange" + "(0x%.8X, %d), rc=0x%.8X, plid=0x%.8X", + i_huid, protection, ERRL_GETRC_SAFE(l_err), l_err->plid() ); + errlCommit(l_err, UTIL_COMP_ID); + } +} + +/** + * @brief Check the ES (energy source) health status of all NVDIMMs in the + * system. If check fails, see HBRT traces for further details. + * @param[out] o_output Output display buffer, memory allocated here. + * Will inform caller if ES health check passes or fails. + */ +void cmd_nvDimmEsCheckHealthStatus( char* &o_output) +{ + o_output = new char[500]; + if (NVDIMM::nvDimmEsCheckHealthStatusOnSystem()) + { + sprintf( o_output, "cmd_nvDimmEsCheckHealthStatus: " + "ES (energy source) health status check passed."); + } else { - sprintf( o_output, "cmd_nvdimm_protection_msg: HUID 0x%.8X not found", - i_huid ); - return; + sprintf( o_output, "cmd_nvDimmEsCheckHealthStatus: " + "ES (energy source) health status check failed. " + "Inspect HBRT traces for further details."); + + } + + return; +} // end cmd_nvDimmEsCheckHealthStatus + +/** + * @brief Check the NVM (non-volatile memory) health status of all NVDIMMs in + * the system. If check fails, see HBRT traces for further details. + * @param[out] o_output Output display buffer, memory allocated here. + * Will inform caller if NVM health check passes or fails. + */ + +void cmd_nvdDmmNvmCheckHealthStatus( char* &o_output) +{ + o_output = new char[500]; + if (NVDIMM::nvDimmNvmCheckHealthStatusOnSystem()) + { + sprintf( o_output, "cmd_nvdDmmNvmCheckHealthStatus: " + "NVM (non-volatile memory) health status check passed."); + + } + else + { + sprintf( o_output, "cmd_nvdDmmNvmCheckHealthStatus: " + "NVM (non-volatile memory) health status check failed. " + "Inspect HBRT traces for further details."); + + } + + return; +} // end cmd_nvdDmmNvmCheckHealthStatus + + +/** + * @brief Execute nvdimm operation, see interface.h for operation format + * @param[out] o_output Output display buffer, memory allocated here. + * Will inform caller if nvdimm op passes or fails. + * @param[in] i_op nvdimm operation to perform, see interface.h + */ +void cmd_nvdimm_op( char* &o_output, uint16_t i_op ) +{ + o_output = new char[500]; + + hostInterfaces::nvdimm_operation_t l_operation; + l_operation.procId = HBRT_NVDIMM_OPERATION_APPLY_TO_ALL_NVDIMMS; + l_operation.rsvd1 = 0x0; + l_operation.rsvd2 = 0x0; + l_operation.opType = (hostInterfaces::NVDIMM_Op_t)i_op; + + int rc = doNvDimmOperation(l_operation); + if (rc == -1) + { + sprintf( o_output, "Error on call doNvDimmOperation() op 0x%X",i_op); } } + + #endif /** @@ -1534,6 +1594,44 @@ int hbrtCommand( int argc, sprintf(*l_output, "ERROR: nvdimm_protection <huid> <0 or 1>"); } } + else if( !strcmp( argv[0], "nvdimm_es_check_status" ) ) + { + if (argc == 1) + { + cmd_nvDimmEsCheckHealthStatus( *l_output ); + } + else + { + *l_output = new char[100]; + sprintf(*l_output, "Usage: nvdimm_es_check_status"); + } + } + else if( !strcmp( argv[0], "nvdimm_nvm_check_status" ) ) + { + if (argc == 1) + { + cmd_nvdDmmNvmCheckHealthStatus( *l_output ); + } + else + { + *l_output = new char[100]; + sprintf(*l_output, "Usage: nvdimm_nvm_check_status"); + } + } + else if( !strcmp( argv[0], "nvdimm_op" ) ) + { + if (argc == 2) + { + uint16_t op = strtou64(argv[1], NULL, 16); + cmd_nvdimm_op( *l_output, op ); + } + else + { + *l_output = new char[100]; + sprintf(*l_output, "ERROR: nvdimm_op <op>"); + } + } + #endif else { @@ -1574,6 +1672,16 @@ int hbrtCommand( int argc, #ifdef CONFIG_NVDIMM sprintf( l_tmpstr, "nvdimm_protection <huid> <0 or 1>\n"); strcat( *l_output, l_tmpstr ); + sprintf( l_tmpstr, "nvdimm_es_check_status\n"); + strcat( *l_output, l_tmpstr ); + sprintf( l_tmpstr, "nvdimm_nvm_check_status\n"); + strcat( *l_output, l_tmpstr ); + sprintf( l_tmpstr, "nvdimm_op <op>\n" + " 0x1=disarm 0x2=disable_encryption 0x4=remove_keys\n" + " 0x8=enable_encryption 0x10=arm 0x20=es_healthcheck\n" + " 0x40=nvm_healthcheck\n"); + strcat( *l_output, l_tmpstr ); + #endif } |