diff --git a/common/utils.cpp b/common/utils.cpp index 57ad84d24..506ad1905 100644 --- a/common/utils.cpp +++ b/common/utils.cpp @@ -261,8 +261,9 @@ GetSubTreeResponse } catch (const std::exception& e) { - std::cerr << "failed GetSubTree query for interface " << ifaceList[0] - << " with ERROR=" << e.what() << "\n"; + error( + "failed GetSubTree query for interface {FACE_LIST} with ERROR = {ERR_EXCEP}", + "FACE_LIST", ifaceList[0], "ERR_EXCEP", e.what()); } return response; } @@ -289,7 +290,9 @@ void reportError(const char* errorMsg, const Severity& sev) } std::map addlData{}; method.append(errorMsg, severity, addlData); - bus.call_noreply(method); + bus.call_noreply( + method, + std::chrono::duration_cast(sec(DBUS_TIMEOUT)).count()); } catch (const std::exception& e) { @@ -324,7 +327,9 @@ void DBusHandler::setDbusProperty(const DBusMapping& dBusMap, service.c_str(), "/xyz/openbmc_project/inventory", "xyz.openbmc_project.Inventory.Manager", "Notify"); method.append(std::move(objectValueTree)); - bus.call_noreply(method); + bus.call_noreply( + method, std::chrono::duration_cast(sec(DBUS_TIMEOUT)) + .count()); } else { @@ -343,7 +348,9 @@ void DBusHandler::setDbusProperty(const DBusMapping& dBusMap, } method.append(dBusMap.interface.c_str(), dBusMap.propertyName.c_str(), variant); - bus.call_noreply(method); + bus.call_noreply( + method, std::chrono::duration_cast(sec(DBUS_TIMEOUT)) + .count()); } }; @@ -727,7 +734,9 @@ void setBiosAttr(const BiosAttributeList& biosAttrList) method.append( biosConfigIntf, "PendingAttributes", std::variant(pendingAttributes)); - bus.call_noreply(method); + bus.call_noreply( + method, std::chrono::duration_cast(sec(DBUS_TIMEOUT)) + .count()); } catch (const sdbusplus::exception::SdBusError& e) { diff --git a/host-bmc/dbus/serialize.cpp b/host-bmc/dbus/serialize.cpp index 5d6ccde1b..1a9ed777d 100644 --- a/host-bmc/dbus/serialize.cpp +++ b/host-bmc/dbus/serialize.cpp @@ -143,7 +143,7 @@ void Serialize::reSerialize(const std::vector types) { if (savedObjs.contains(type)) { - error( + info( "Removing objects of type : {OBJ_TYP} from the persistent cache", "OBJ_TYP", (unsigned)type); savedObjs.erase(savedObjs.find(type)); diff --git a/host-bmc/host_pdr_handler.cpp b/host-bmc/host_pdr_handler.cpp index 80bf46266..5ad2c8d7d 100644 --- a/host-bmc/host_pdr_handler.cpp +++ b/host-bmc/host_pdr_handler.cpp @@ -1476,7 +1476,7 @@ void HostPDRHandler::getPresentStateBySensorReadigs( ++sensorMapIndex; if (sensorMapIndex == sensorMap.end()) { - // std::cerr << "sensor map completed\n"; + // error("sensor map completed"); ++objMapIndex; sensorMapIndex = sensorMap.begin(); } @@ -1543,7 +1543,7 @@ void HostPDRHandler::getPresentStateBySensorReadigs( ++sensorMapIndex; if (sensorMapIndex == sensorMap.end()) { - // std::cerr << "sensor map completed\n"; + // error("sensor map completed"); ++objMapIndex; sensorMapIndex = sensorMap.begin(); } diff --git a/libpldmresponder/bios_config.cpp b/libpldmresponder/bios_config.cpp index deb08ce31..d01b78a57 100644 --- a/libpldmresponder/bios_config.cpp +++ b/libpldmresponder/bios_config.cpp @@ -485,7 +485,9 @@ void BIOSConfig::updateBaseBIOSTableProperty() } #endif method.append(biosConfigInterface, biosConfigPropertyName, value); - bus.call_noreply(method); + bus.call_noreply( + method, + std::chrono::duration_cast(sec(DBUS_TIMEOUT)).count()); } catch (const std::exception& e) { diff --git a/libpldmresponder/fru.cpp b/libpldmresponder/fru.cpp index c0ce2f043..7c22af4a6 100644 --- a/libpldmresponder/fru.cpp +++ b/libpldmresponder/fru.cpp @@ -212,7 +212,7 @@ void FruImpl::buildFRUTable() } catch (const std::exception& e) { - info( + error( "Config JSONs missing for the item interface type, interface = {INTF}", "INTF", interface.first); break; @@ -561,7 +561,7 @@ void FruImpl::buildIndividualFRU(const std::string& fruInterface, pldm_entity node_entity = pldm_entity_extract(node); objToEntityNode[fruObjectPath] = node_entity; error( - "Building Individual FRU [FRU_OBJ_PATH] with entityid [ {ENTITY_TYP}, {ENTITY_NUM}, {ENTITY_ID} ] Parent :[ {P_ENTITY_TYP}, {P_ENTITY_NUM}, {P_ENTITY_ID} ]", + "Building Individual FRU [{FRU_OBJ_PATH}] with entityid [ {ENTITY_TYP}, {ENTITY_NUM}, {ENTITY_ID} ] Parent :[ {P_ENTITY_TYP}, {P_ENTITY_NUM}, {P_ENTITY_ID} ]", "FRU_OBJ_PATH", fruObjectPath, "ENTITY_TYP", static_cast(node_entity.entity_type), "ENTITY_NUM", static_cast(node_entity.entity_instance_num), "ENTITY_ID", @@ -602,7 +602,7 @@ void FruImpl::buildIndividualFRU(const std::string& fruInterface, } catch (const std::exception& e) { - info( + error( "Config JSONs missing for the item in concurrent add path interface type, interface = {FRU_INTF}", "FRU_INTF", fruInterface); } diff --git a/libpldmresponder/platform.cpp b/libpldmresponder/platform.cpp index 33d98fa14..f201173e1 100644 --- a/libpldmresponder/platform.cpp +++ b/libpldmresponder/platform.cpp @@ -73,7 +73,7 @@ void Handler::generate(const pldm::utils::DBusHandler& dBusIntf, { for (const auto& directory : dir) { - error("checking if : {DIR} exists", "DIR", directory.c_str()); + info("checking if : {DIR} exists", "DIR", directory.c_str()); if (!fs::exists(directory)) { return; diff --git a/libpldmresponder/test/libpldmresponder_platform_test.cpp b/libpldmresponder/test/libpldmresponder_platform_test.cpp index 030b64b25..d49f193ec 100644 --- a/libpldmresponder/test/libpldmresponder_platform_test.cpp +++ b/libpldmresponder/test/libpldmresponder_platform_test.cpp @@ -198,13 +198,10 @@ TEST(getPDR, testFindPDR) // current is not what we want pldm_pdr_hdr* hdr = reinterpret_cast(resp->record_data); - std::cerr << "PDR next record handle " << handle << "\n"; - std::cerr << "PDR type " << hdr->type << "\n"; if (hdr->type == PLDM_STATE_EFFECTER_PDR) { pldm_state_effecter_pdr* pdr = reinterpret_cast(resp->record_data); - std::cerr << "PDR entity type " << pdr->entity_type << "\n"; if (pdr->entity_type == 100) { found = true; diff --git a/oem/ibm/libpldmresponder/collect_slot_vpd.cpp b/oem/ibm/libpldmresponder/collect_slot_vpd.cpp index ba8f6cfdd..75efba222 100644 --- a/oem/ibm/libpldmresponder/collect_slot_vpd.cpp +++ b/oem/ibm/libpldmresponder/collect_slot_vpd.cpp @@ -110,7 +110,9 @@ void SlotHandler::callVPDManager(const std::string& adapterObjPath, VPDInterface, "CollectFRUVPD"); method.append( static_cast(adapterObjPath)); - bus.call_noreply(method); + bus.call_noreply( + method, std::chrono::duration_cast(sec(DBUS_TIMEOUT)) + .count()); } else if (stateFiledValue == uint8_t(REMOVE) || stateFiledValue == uint8_t(REPLACE)) @@ -119,7 +121,9 @@ void SlotHandler::callVPDManager(const std::string& adapterObjPath, VPDInterface, "deleteFRUVPD"); method.append( static_cast(adapterObjPath)); - bus.call_noreply(method); + bus.call_noreply( + method, std::chrono::duration_cast(sec(DBUS_TIMEOUT)) + .count()); } } catch (const std::exception& e) diff --git a/oem/ibm/libpldmresponder/file_io_type_dump.cpp b/oem/ibm/libpldmresponder/file_io_type_dump.cpp index cb9d90fea..ee14606c0 100644 --- a/oem/ibm/libpldmresponder/file_io_type_dump.cpp +++ b/oem/ibm/libpldmresponder/file_io_type_dump.cpp @@ -600,9 +600,9 @@ int DumpHandler::fileAckWithMetaData(uint8_t /*fileStatus*/, } catch (const std::exception& e) { - std::cerr << "failed to set token for resource dump, ERROR=" - << e.what() << "\n"; - return PLDM_ERROR; + error("failed to set token for resource dump, + ERROR={ERR_EXCEP}", "ERR_EXCEP", e.what()); + return PLDM_ERROR; }*/ } diff --git a/oem/ibm/libpldmresponder/file_io_type_lid.hpp b/oem/ibm/libpldmresponder/file_io_type_lid.hpp index fbd564728..c388716d6 100644 --- a/oem/ibm/libpldmresponder/file_io_type_lid.hpp +++ b/oem/ibm/libpldmresponder/file_io_type_lid.hpp @@ -162,8 +162,8 @@ class LidHandler : public FileHandler phosphor::logging::commit(); validateStatus = MIN_MIF_FAIL; } - std::cerr << "Marker lid validate error, " - << "ERROR=" << e.what() << std::endl; + error("Marker lid validate error, ERROR={ERR_EXCEP}", + "ERR_EXCEP", e.what()); } oemIbmPlatformHandler->sendStateSensorEvent( sensorId, PLDM_STATE_SENSOR_STATE, 0, validateStatus, VALID); diff --git a/oem/ibm/libpldmresponder/file_io_type_pcie.cpp b/oem/ibm/libpldmresponder/file_io_type_pcie.cpp index e6b44da18..a9eb59418 100644 --- a/oem/ibm/libpldmresponder/file_io_type_pcie.cpp +++ b/oem/ibm/libpldmresponder/file_io_type_pcie.cpp @@ -619,8 +619,8 @@ void PCIeInfoHandler::parseSecondaryLink( std::filesystem::path mexConnecter(mexConnecterPath); auto mexSlotandAdapter = getMexSlotandAdapter(mexConnecter); - std::cout << "Creating associations under " - << std::get<1>(mexSlotandAdapter) << std::endl; + info("Creating associations under {MEX_SLOT_ADAPTER}", + "MEX_SLOT_ADAPTER", std::get<1>(mexSlotandAdapter)); std::vector> associations; for (auto slot : ioSlotLocationCode) @@ -972,7 +972,7 @@ void PCIeInfoHandler::parseTopologyData() (struct SlotLocCodeSuf_t*)suffix_data; if (slot_loc_suf_data == nullptr) { - std::cerr << "slot location suffix data is nullptr \n"; + error("slot location suffix data is nullptr"); break; } diff --git a/oem/ibm/libpldmresponder/file_io_type_pel.cpp b/oem/ibm/libpldmresponder/file_io_type_pel.cpp index b933148c0..c6cb2fbeb 100644 --- a/oem/ibm/libpldmresponder/file_io_type_pel.cpp +++ b/oem/ibm/libpldmresponder/file_io_type_pel.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -27,6 +28,7 @@ namespace pldm namespace responder { using namespace sdbusplus::xyz::openbmc_project::Logging::server; +using namespace sdbusplus::org::open_power::Logging::server; namespace detail { @@ -244,27 +246,85 @@ void PelHandler::postDataTransferCallBack(bool IsWriteToMemOp) } } -int PelHandler::fileAck(uint8_t /*fileStatus*/) +int PelHandler::fileAck(uint8_t fileStatus) { static constexpr auto logObjPath = "/xyz/openbmc_project/logging"; static constexpr auto logInterface = "org.open_power.Logging.PEL"; + static std::string service; auto& bus = pldm::utils::DBusHandler::getBus(); - try + if (service.empty()) { - auto service = pldm::utils::DBusHandler().getService(logObjPath, - logInterface); - auto method = bus.new_method_call(service.c_str(), logObjPath, - logInterface, "HostAck"); - method.append(fileHandle); - bus.call_noreply(method); + try + { + service = pldm::utils::DBusHandler().getService(logObjPath, + logInterface); + } + catch (const sdbusplus::exception_t& e) + { + error("Mapper call failed when trying to find logging service " + "to ack PEL ID {FILE_HANDLE} error = {ERR_EXCEP}", + "FILE_HANDLE", lg2::hex, fileHandle, "ERR_EXCEP", e); + return PLDM_ERROR; + } } - catch (const std::exception& e) + + if (fileStatus == PLDM_SUCCESS) { - error( - "HostAck D-Bus call failed on PEL ID 0x{FILE_HNDL}, error ={ERR_EXCEP}", - "FILE_HNDL", lg2::hex, fileHandle, "ERR_EXCEP", e.what()); - return PLDM_ERROR; + try + { + auto method = bus.new_method_call(service.c_str(), logObjPath, + logInterface, "HostAck"); + method.append(fileHandle); + bus.call_noreply( + method, std::chrono::duration_cast(sec(DBUS_TIMEOUT)) + .count()); + } + catch (const std::exception& e) + { + error( + "HostAck D-Bus call failed on PEL ID {FILE_HANDLE}, error = {ERR_EXCEP}", + "FILE_HANDLE", lg2::hex, fileHandle, "ERR_EXCEP", e); + return PLDM_ERROR; + } + } + else + { + PEL::RejectionReason reason{}; + if (fileStatus == PLDM_FULL_FILE_DISCARDED) + { + reason = PEL::RejectionReason::HostFull; + } + else if (fileStatus == PLDM_ERROR_FILE_DISCARDED) + { + reason = PEL::RejectionReason::BadPEL; + } + else + { + error( + "Invalid file status {STATUS} in PEL file ack response for PEL {FILE_HANDLE}", + "STATUS", lg2::hex, fileStatus, "FILE_HANDLE", lg2::hex, + fileHandle); + return PLDM_ERROR; + } + + try + { + auto method = bus.new_method_call(service.c_str(), logObjPath, + logInterface, "HostReject"); + method.append(fileHandle, reason); + bus.call_noreply( + method, std::chrono::duration_cast(sec(DBUS_TIMEOUT)) + .count()); + } + catch (const std::exception& e) + { + error("HostReject D-Bus call failed on PEL ID {FILE_HANDLE}, " + "error = {ERR_EXCEP}, status = {STATUS}", + "FILE_HANDLE", lg2::hex, fileHandle, "ERR_EXCEP", e, "STATUS", + lg2::hex, fileStatus); + return PLDM_ERROR; + } } return PLDM_SUCCESS; @@ -292,7 +352,9 @@ int PelHandler::storePel(std::string&& pelFileName) logInterface, "Create"); method.append("xyz.openbmc_project.Host.Error.Event", severity, addlData); - bus.call_noreply(method); + bus.call_noreply( + method, + std::chrono::duration_cast(sec(DBUS_TIMEOUT)).count()); } catch (const std::exception& e) { diff --git a/oem/ibm/libpldmresponder/file_io_type_progress_src.cpp b/oem/ibm/libpldmresponder/file_io_type_progress_src.cpp index bf4c9cf66..5de46031e 100644 --- a/oem/ibm/libpldmresponder/file_io_type_progress_src.cpp +++ b/oem/ibm/libpldmresponder/file_io_type_progress_src.cpp @@ -33,7 +33,9 @@ int ProgressCodeHandler::setRawBootProperty( std::variant>>( progressCodeBuffer)); - bus.call_noreply(method); + bus.call_noreply( + method, + std::chrono::duration_cast(sec(DBUS_TIMEOUT)).count()); } catch (const std::exception& e) { diff --git a/oem/ibm/libpldmresponder/file_io_type_vpd.cpp b/oem/ibm/libpldmresponder/file_io_type_vpd.cpp index b5cb1c67f..5488c0368 100644 --- a/oem/ibm/libpldmresponder/file_io_type_vpd.cpp +++ b/oem/ibm/libpldmresponder/file_io_type_vpd.cpp @@ -52,8 +52,9 @@ int keywordHandler::read(uint32_t offset, uint32_t& length, Response& response, if (length < keywrdSize) { - std::cerr << "length requested is less the keyword size, length: " - << length << " keyword size: " << keywrdSize << std::endl; + error( + "length requested is less the keyword size, length: {LEN} keyword size: {KEYWORD_SIZE}", + "LEN", length, "KEYWORD_SIZE", keywrdSize); return PLDM_ERROR_INVALID_DATA; } @@ -82,8 +83,8 @@ int keywordHandler::read(uint32_t offset, uint32_t& length, Response& response, if (offset > keywrdSize) { - std::cerr << "Offset exceeds file size, OFFSET=" << offset - << " FILE_SIZE=" << keywrdSize << std::endl; + error("Offset exceeds file size, OFFSET={OFFSET} FILE_SIZE={FILE_SIZE}", + "OFFSET", offset, "FILE_SIZE", keywrdSize); return PLDM_DATA_OUT_OF_RANGE; } // length of keyword data should be same as keyword data size in dbus object @@ -91,9 +92,7 @@ int keywordHandler::read(uint32_t offset, uint32_t& length, Response& response, auto returnCode = lseek(fd, offset, SEEK_SET); if (returnCode == -1) { - std::cerr - << "Could not find keyword data at given offset. File Seek failed" - << std::endl; + error("Could not find keyword data at given offset. File Seek failed"); return PLDM_ERROR; } diff --git a/oem/ibm/libpldmresponder/fru_oem_ibm.cpp b/oem/ibm/libpldmresponder/fru_oem_ibm.cpp index 584c0f503..cead8850e 100644 --- a/oem/ibm/libpldmresponder/fru_oem_ibm.cpp +++ b/oem/ibm/libpldmresponder/fru_oem_ibm.cpp @@ -198,7 +198,9 @@ void Handler::setFirmwareUAK(std::vector data) uakInterface, "WriteKeyword"); method.append(static_cast(fruPath), fruRecord, fruKeyword, data); - bus.call_noreply(method); + bus.call_noreply( + method, + std::chrono::duration_cast(sec(DBUS_TIMEOUT)).count()); } catch (const std::exception& e) { diff --git a/oem/ibm/libpldmresponder/inband_code_update.cpp b/oem/ibm/libpldmresponder/inband_code_update.cpp index 7458df440..ba67f51ef 100644 --- a/oem/ibm/libpldmresponder/inband_code_update.cpp +++ b/oem/ibm/libpldmresponder/inband_code_update.cpp @@ -595,7 +595,9 @@ void CodeUpdate::deleteImage() { auto method = bus.new_method_call(UPDATER_SERVICE, SW_OBJ_PATH, DELETE_INTF, "DeleteAll"); - bus.call_noreply(method); + bus.call_noreply( + method, + std::chrono::duration_cast(sec(DBUS_TIMEOUT)).count()); } catch (const std::exception& e) { @@ -797,7 +799,9 @@ int CodeUpdate::assembleCodeUpdateImage() auto method = bus.new_method_call(UPDATER_SERVICE, SOFTWARE_PATH, LID_INTERFACE, "AssembleCodeUpdateImage"); - bus.call_noreply(method); + bus.call_noreply( + method, + std::chrono::duration_cast(sec(DBUS_TIMEOUT)).count()); } catch (const std::exception& e) { diff --git a/oem/ibm/libpldmresponder/oem_ibm_handler.cpp b/oem/ibm/libpldmresponder/oem_ibm_handler.cpp index ff3968878..62675e60d 100644 --- a/oem/ibm/libpldmresponder/oem_ibm_handler.cpp +++ b/oem/ibm/libpldmresponder/oem_ibm_handler.cpp @@ -1288,7 +1288,9 @@ void pldm::responder::oem_ibm_platform::Handler::resetWatchDogTimer() bus.new_method_call(watchDogService, watchDogObjectPath, watchDogInterface, watchDogResetPropName); resetMethod.append(true); - bus.call_noreply(resetMethod); + bus.call_noreply( + resetMethod, + std::chrono::duration_cast(sec(DBUS_TIMEOUT)).count()); } catch (const std::exception& e) { @@ -1357,7 +1359,9 @@ void pldm::responder::oem_ibm_platform::Handler::setBitmapMethodCall( dbusMethod); auto val = std::get_if>(&value); method.append(*val); - bus.call_noreply(method); + bus.call_noreply( + method, + std::chrono::duration_cast(sec(DBUS_TIMEOUT)).count()); } catch (const std::exception& e) { diff --git a/softoff/main.cpp b/softoff/main.cpp index fb7b403cf..9ed8573c6 100644 --- a/softoff/main.cpp +++ b/softoff/main.cpp @@ -77,7 +77,9 @@ int main(int argc, char* argv[]) method.append( std::vector>>()); - bus.call_noreply(method); + bus.call_noreply( + method, std::chrono::duration_cast(sec(DBUS_TIMEOUT)) + .count()); } catch (const sdbusplus::exception::exception& e) {