Skip to content

Commit

Permalink
Merge branch '1050' of github.com:Patel-Kamalkumar/pldm into AIO
Browse files Browse the repository at this point in the history
  • Loading branch information
Patel-Kamalkumar committed Oct 6, 2023
2 parents 07cd485 + d7e0cb9 commit d576b33
Show file tree
Hide file tree
Showing 18 changed files with 142 additions and 55 deletions.
21 changes: 15 additions & 6 deletions common/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -289,7 +290,9 @@ void reportError(const char* errorMsg, const Severity& sev)
}
std::map<std::string, std::string> addlData{};
method.append(errorMsg, severity, addlData);
bus.call_noreply(method);
bus.call_noreply(
method,
std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT)).count());
}
catch (const std::exception& e)
{
Expand Down Expand Up @@ -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<microsec>(sec(DBUS_TIMEOUT))
.count());
}
else
{
Expand All @@ -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<microsec>(sec(DBUS_TIMEOUT))
.count());
}
};

Expand Down Expand Up @@ -727,7 +734,9 @@ void setBiosAttr(const BiosAttributeList& biosAttrList)
method.append(
biosConfigIntf, "PendingAttributes",
std::variant<PendingAttributesType>(pendingAttributes));
bus.call_noreply(method);
bus.call_noreply(
method, std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT))
.count());
}
catch (const sdbusplus::exception::SdBusError& e)
{
Expand Down
2 changes: 1 addition & 1 deletion host-bmc/dbus/serialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void Serialize::reSerialize(const std::vector<uint16_t> 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));
Expand Down
4 changes: 2 additions & 2 deletions host-bmc/host_pdr_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
}
Expand Down
4 changes: 3 additions & 1 deletion libpldmresponder/bios_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<microsec>(sec(DBUS_TIMEOUT)).count());
}
catch (const std::exception& e)
{
Expand Down
6 changes: 3 additions & 3 deletions libpldmresponder/fru.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<unsigned>(node_entity.entity_type), "ENTITY_NUM",
static_cast<unsigned>(node_entity.entity_instance_num), "ENTITY_ID",
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion libpldmresponder/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions libpldmresponder/test/libpldmresponder_platform_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,10 @@ TEST(getPDR, testFindPDR)
// current is not what we want

pldm_pdr_hdr* hdr = reinterpret_cast<pldm_pdr_hdr*>(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<pldm_state_effecter_pdr*>(resp->record_data);
std::cerr << "PDR entity type " << pdr->entity_type << "\n";
if (pdr->entity_type == 100)
{
found = true;
Expand Down
8 changes: 6 additions & 2 deletions oem/ibm/libpldmresponder/collect_slot_vpd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ void SlotHandler::callVPDManager(const std::string& adapterObjPath,
VPDInterface, "CollectFRUVPD");
method.append(
static_cast<sdbusplus::message::object_path>(adapterObjPath));
bus.call_noreply(method);
bus.call_noreply(
method, std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT))
.count());
}
else if (stateFiledValue == uint8_t(REMOVE) ||
stateFiledValue == uint8_t(REPLACE))
Expand All @@ -119,7 +121,9 @@ void SlotHandler::callVPDManager(const std::string& adapterObjPath,
VPDInterface, "deleteFRUVPD");
method.append(
static_cast<sdbusplus::message::object_path>(adapterObjPath));
bus.call_noreply(method);
bus.call_noreply(
method, std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT))
.count());
}
}
catch (const std::exception& e)
Expand Down
6 changes: 3 additions & 3 deletions oem/ibm/libpldmresponder/file_io_type_dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}*/
}

Expand Down
4 changes: 2 additions & 2 deletions oem/ibm/libpldmresponder/file_io_type_lid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ class LidHandler : public FileHandler
phosphor::logging::commit<IncompatibleErr>();
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);
Expand Down
6 changes: 3 additions & 3 deletions oem/ibm/libpldmresponder/file_io_type_pcie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::tuple<std::string, std::string, std::string>>
associations;
for (auto slot : ioSlotLocationCode)
Expand Down Expand Up @@ -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;
}

Expand Down
90 changes: 76 additions & 14 deletions oem/ibm/libpldmresponder/file_io_type_pel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <systemd/sd-bus.h>
#include <unistd.h>

#include <org/open_power/Logging/PEL/server.hpp>
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/server.hpp>
#include <xyz/openbmc_project/Logging/Entry/server.hpp>
Expand All @@ -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
{
Expand Down Expand Up @@ -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<microsec>(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<microsec>(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;
Expand Down Expand Up @@ -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<microsec>(sec(DBUS_TIMEOUT)).count());
}
catch (const std::exception& e)
{
Expand Down
4 changes: 3 additions & 1 deletion oem/ibm/libpldmresponder/file_io_type_progress_src.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ int ProgressCodeHandler::setRawBootProperty(
std::variant<std::tuple<uint64_t, std::vector<uint8_t>>>(
progressCodeBuffer));

bus.call_noreply(method);
bus.call_noreply(
method,
std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT)).count());
}
catch (const std::exception& e)
{
Expand Down
13 changes: 6 additions & 7 deletions oem/ibm/libpldmresponder/file_io_type_vpd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -82,18 +83,16 @@ 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
length = static_cast<uint32_t>(keywrdSize) - offset;
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;
}

Expand Down
4 changes: 3 additions & 1 deletion oem/ibm/libpldmresponder/fru_oem_ibm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ void Handler::setFirmwareUAK(std::vector<uint8_t> data)
uakInterface, "WriteKeyword");
method.append(static_cast<sdbusplus::message::object_path>(fruPath),
fruRecord, fruKeyword, data);
bus.call_noreply(method);
bus.call_noreply(
method,
std::chrono::duration_cast<microsec>(sec(DBUS_TIMEOUT)).count());
}
catch (const std::exception& e)
{
Expand Down
Loading

0 comments on commit d576b33

Please sign in to comment.