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 May 25, 2023
2 parents 7dde80c + 1430595 commit c85d7d1
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 37 deletions.
45 changes: 27 additions & 18 deletions oem/ibm/libpldmresponder/file_io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,9 @@ namespace fs = std::filesystem;
*/
class DMA
{
DMA(){}
public:
DMA()
{
responseReceived = false;
}

DMA(uint32_t length)
{
responseReceived = false;
Expand All @@ -88,6 +86,15 @@ class DMA
{
pageAlignedLength += pageSize;
}
responseReceived = false;
memAddr = nullptr;
xdmaFd = -1;
SourceFd = -1;
rc= 0;
pageAlignedLength=0;
iotPtr = nullptr;
iotPtrbc = nullptr;
timer = nullptr;
}
~DMA()
{
Expand Down Expand Up @@ -213,6 +220,10 @@ class DMA
iotPtrbc = iotPtr.release();
}
}
void setResponseReceived(bool bresponse){responseReceived = bresponse;}

bool getResponseReceived(){return responseReceived ;}

/** @brief API to transfer data between BMC and host using DMA
*
* @param[in] path - pathname of the file to transfer data from or
Expand All @@ -239,19 +250,17 @@ class DMA
*/
int transferHostDataToSocket(int fd, uint32_t length, uint64_t address);

public:
bool responseReceived = false;

private:
int xdmaFd = -1;
void* memAddr = nullptr;
std::unique_ptr<IO> iotPtr;
IO* iotPtrbc;
std::unique_ptr<Timer> timer;
int rc = 0;
uint32_t pageAlignedLength = 0;
uint32_t m_length;
int32_t SourceFd = -1;
bool responseReceived = false;
void* memAddr = nullptr;
int xdmaFd = -1;
int32_t SourceFd = -1;
uint32_t pageAlignedLength;
int rc;
std::unique_ptr<IO> iotPtr;
IO* iotPtrbc;
std::unique_ptr<Timer> timer;
uint32_t m_length;
};

/** @brief Transfer the data between BMC and host using DMA.
Expand Down Expand Up @@ -295,7 +304,7 @@ Response transferAll(std::shared_ptr<DMAInterface> intf, int32_t file,
part.address = address;

auto timerCb = [=](Timer& /*source*/, Timer::TimePoint /*time*/) {
if (!intf->responseReceived)
if (!intf->getResponseReceived())
{
std::cout
<< " EventLoop Timeout..!! Terminating data tranfer operation.\n";
Expand Down Expand Up @@ -352,7 +361,7 @@ Response transferAll(std::shared_ptr<DMAInterface> intf, int32_t file,
}
if (static_cast<int>(part.length) == rc)
{
weakPtr->responseReceived = true;
weakPtr->setResponseReceived(true);
encode_rw_file_memory_resp(instance_id, command, PLDM_SUCCESS,
origLength, responsePtr);

Expand Down
8 changes: 4 additions & 4 deletions oem/ibm/libpldmresponder/file_io_by_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ int FileHandler::transferFileData(int32_t fd, bool upstream, uint32_t offset,
std::weak_ptr<dma::DMA> wxInterface = xdmaInterface;
std::weak_ptr<FileHandler> wxfunctionPtr = functionPtr;
auto timerCb = [=, this](Timer& /*source*/, Timer::TimePoint /*time*/) {
if (!xdmaInterface->responseReceived)
if (!xdmaInterface->getResponseReceived())
{
std::cout
<< " EventLoop Timeout..!! Terminating FileHandler data tranfer operation.\n";
Expand Down Expand Up @@ -132,7 +132,7 @@ int FileHandler::transferFileData(int32_t fd, bool upstream, uint32_t offset,
}
if (static_cast<int>(part.length) == rc)
{
wInterface->responseReceived = true;
wInterface->setResponseReceived(true);
encode_rw_file_by_type_memory_resp(
instance_id, command, PLDM_SUCCESS, origLength, responsePtr);
responseHdr.respInterface->sendPLDMRespMsg(response, key);
Expand Down Expand Up @@ -193,7 +193,7 @@ int FileHandler::transferFileDataToSocket(int32_t fd, uint32_t& length,
std::weak_ptr<dma::DMA> wxInterface = xdmaInterface;
std::weak_ptr<FileHandler> wxfunctionPtr = functionPtr;
auto timerCb = [=, this](Timer& /*source*/, Timer::TimePoint /*time*/) {
if (!xdmaInterface->responseReceived)
if (!xdmaInterface->getResponseReceived())
{
Response response(sizeof(pldm_msg_hdr) + command, 0);
auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
Expand Down Expand Up @@ -250,7 +250,7 @@ int FileHandler::transferFileDataToSocket(int32_t fd, uint32_t& length,
}
if (static_cast<int>(part.length) == rc)
{
wInterface->responseReceived = true;
wInterface->setResponseReceived(true);
encode_rw_file_by_type_memory_resp(
instance_id, command, PLDM_SUCCESS, origLength, responsePtr);
responseHdr.respInterface->sendPLDMRespMsg(response, key);
Expand Down
75 changes: 63 additions & 12 deletions oem/ibm/libpldmresponder/file_io_type_lid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// #include "file_io_by_type.hpp"
#include "file_io.hpp"

#include <xyz/openbmc_project/Software/Version/error.hpp>

#include <filesystem>
#include <sstream>
#include <string>
Expand All @@ -13,11 +15,16 @@ namespace pldm
{
namespace responder
{

namespace fs = std::filesystem;

using MarkerLIDremainingSize = uint64_t;

constexpr auto markerLidName = "80a00001.lid";
constexpr auto accessKeyExpired =
"sdbusplus::xyz::openbmc_project::Software::Version::Error::ExpiredAccessKey";
constexpr auto incompatibleErr =
"sdbusplus::xyz::openbmc_project::Software::Version::Error::Incompatible";

/** @class LidHandler
*
* @brief Inherits and implements FileHandler. This class is used
Expand Down Expand Up @@ -114,6 +121,60 @@ class LidHandler : public FileHandler
return true;
}

int validateMarkerLid(oem_platform::Handler* oemPlatformHandler,
const std::string& lidPath)
{
int rc = PLDM_SUCCESS;
if (oemPlatformHandler != nullptr)
{
pldm::responder::oem_ibm_platform::Handler* oemIbmPlatformHandler =
dynamic_cast<pldm::responder::oem_ibm_platform::Handler*>(
oemPlatformHandler);
auto sensorId =
oemIbmPlatformHandler->codeUpdate->getMarkerLidSensor();
using namespace pldm::responder::oem_ibm_platform;
auto markerLidDirPath = fs::path(LID_STAGING_DIR) / "lid" /
markerLidName;
try
{
auto& bus = pldm::utils::DBusHandler::getBus();
rc = processCodeUpdateLid(lidPath);
if (rc != PLDM_SUCCESS)
{
return rc;
}
auto method = bus.new_method_call(
"xyz.openbmc_project.Software.BMC.Updater",
"/xyz/openbmc_project/software",
"xyz.openbmc_project.Software.LID", "Validate");
method.append(markerLidDirPath.c_str());
bus.call(method);
}
catch (const sdbusplus::exception::exception& e)
{
uint8_t validateStatus = 0;
if (strcmp(e.name(), accessKeyExpired) != 0)
{
validateStatus = ENTITLEMENT_FAIL;
}
else if (strcmp(e.name(), incompatibleErr) != 0)
{
validateStatus = MIN_MIF_FAIL;
}
std::cerr << "Marker lid validate error, "
<< "ERROR=" << e.what() << std::endl;
oemIbmPlatformHandler->sendStateSensorEvent(
sensorId, PLDM_STATE_SENSOR_STATE, 0, validateStatus,
VALID);
return PLDM_ERROR;
}
oemIbmPlatformHandler->sendStateSensorEvent(
sensorId, PLDM_STATE_SENSOR_STATE, 0, VALID, VALID);
rc = PLDM_SUCCESS;
}
return rc;
}

virtual int writeFromMemory(uint32_t offset, uint32_t length,
uint64_t address,
oem_platform::Handler* oemPlatformHandler,
Expand Down Expand Up @@ -293,17 +354,7 @@ class LidHandler : public FileHandler
markerLIDremainingSize -= length;
if (markerLIDremainingSize == 0)
{
pldm::responder::oem_ibm_platform::Handler*
oemIbmPlatformHandler = dynamic_cast<
pldm::responder::oem_ibm_platform::Handler*>(
oemPlatformHandler);
auto sensorId =
oemIbmPlatformHandler->codeUpdate->getMarkerLidSensor();
using namespace pldm::responder::oem_ibm_platform;
oemIbmPlatformHandler->sendStateSensorEvent(
sensorId, PLDM_STATE_SENSOR_STATE, 0, VALID, VALID);
// validate api
rc = PLDM_SUCCESS;
rc = validateMarkerLid(oemPlatformHandler, lidPath);
}
}
else if (codeUpdateInProgress)
Expand Down
6 changes: 3 additions & 3 deletions oem/ibm/service_files/pldm-clear-dma.service
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ [email protected]
[Service]
RemainAfterExit=yes
Type=oneshot
ExecStart=/usr/bin/killall -SIGSTOP pldmd
ExecStart=/usr/bin/killall -SIGCONT pldmd
ExecStart=/usr/bin/killall -SIGSTOP pldmd
ExecStart=/usr/bin/killall -SIGCONT pldmd

[Install]
WantedBy[email protected]
#[email protected]

0 comments on commit c85d7d1

Please sign in to comment.