Skip to content

Commit

Permalink
platform-mc: Get inventory path from MctpDiscovery
Browse files Browse the repository at this point in the history
The inventory name was set as PLDM_DEVICE_TID, but we might need
more specific name to identify inventory item. This change made
it get inventory path found by MctpDiscovery. It keeps the original
path name by default if it didn't get the path from MctpDiscovery.

Tested with:
CodeConstruct/mctp#17
https://gerrit.openbmc.org/c/openbmc/entity-manager/+/66750
which gets static EID from entity-manager and creates association
definition D-Bus interface.

Change-Id: I17b6c56722df180defa1f769a54fd4b10df22d71
Signed-off-by: Delphine CC Chiu <[email protected]>
  • Loading branch information
DelphineCCChiu committed Feb 2, 2024
1 parent 00653f0 commit 6d1a93b
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 30 deletions.
31 changes: 20 additions & 11 deletions platform-mc/terminus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,24 @@ namespace platform_mc
/* default the max message buffer size BMC supported to 4K bytes */
#define MAX_MESSAGE_BUFFER_SIZE 4096

Terminus::Terminus(tid_t tid, uint64_t supportedTypes) :
initalized(false), maxBufferSize(MAX_MESSAGE_BUFFER_SIZE),
synchronyConfigurationSupported(0), pollEvent(false), tid(tid),
supportedTypes(supportedTypes)
Terminus::Terminus(tid_t tid, uint64_t supportedTypes,
InventoryPath inventoryPath) :
initalized(false),
maxBufferSize(MAX_MESSAGE_BUFFER_SIZE), synchronyConfigurationSupported(0),
pollEvent(false), tid(tid), supportedTypes(supportedTypes)
{
inventoryPath = "/xyz/openbmc_project/inventory/Item/Board/PLDM_Device_" +
std::to_string(tid);
if (inventoryPath.empty())
{
invPath = "/xyz/openbmc_project/inventory/Item/Board/PLDM_Device_" +
std::to_string(tid);
}
else
{
invPath = inventoryPath;
}

inventoryItemBoardInft = std::make_unique<InventoryItemBoardIntf>(
utils::DBusHandler::getBus(), inventoryPath.c_str());
utils::DBusHandler::getBus(), invPath.c_str());
}

bool Terminus::doesSupport(uint8_t type)
Expand Down Expand Up @@ -193,8 +202,8 @@ void Terminus::addNumericSensor(

try
{
auto sensor = std::make_shared<NumericSensor>(
tid, true, pdr, sensorName, inventoryPath);
auto sensor = std::make_shared<NumericSensor>(tid, true, pdr,
sensorName, invPath);
numericSensors.emplace_back(sensor);
}
catch (const std::exception& e)
Expand Down Expand Up @@ -305,8 +314,8 @@ void Terminus::addCompactNumericSensor(

try
{
auto sensor = std::make_shared<NumericSensor>(
tid, true, pdr, sensorName, inventoryPath);
auto sensor = std::make_shared<NumericSensor>(tid, true, pdr,
sensorName, invPath);
numericSensors.emplace_back(sensor);
}
catch (const std::exception& e)
Expand Down
5 changes: 3 additions & 2 deletions platform-mc/terminus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ using InventoryItemBoardIntf = sdbusplus::server::object_t<
class Terminus
{
public:
Terminus(tid_t tid, uint64_t supportedPLDMTypes);
Terminus(tid_t tid, uint64_t supportedPLDMTypes,
InventoryPath inventoryPath);

/** @brief Check if the terminus supports the PLDM type message
*
Expand Down Expand Up @@ -111,7 +112,7 @@ class Terminus
sensorAuxiliaryNamesTbl{};

std::unique_ptr<InventoryItemBoardIntf> inventoryItemBoardInft = nullptr;
std::string inventoryPath;
std::string invPath;
};
} // namespace platform_mc
} // namespace pldm
4 changes: 3 additions & 1 deletion platform-mc/terminus_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ requester::Coroutine TerminusManager::initMctpTerminus(const MctpInfo& mctpInfo)
{
mctp_eid_t eid = std::get<0>(mctpInfo);
tid_t tid = 0;
InventoryPath inventoryPath = std::get<4>(mctpInfo);
bool isMapped = false;
auto rc = co_await getTidOverMctp(eid, &tid);
if (rc || tid == PLDM_TID_RESERVED)
Expand Down Expand Up @@ -289,7 +290,8 @@ requester::Coroutine TerminusManager::initMctpTerminus(const MctpInfo& mctpInfo)
co_return PLDM_ERROR;
}

termini[tid] = std::make_shared<Terminus>(tid, supportedTypes);
termini[tid] = std::make_shared<Terminus>(tid, supportedTypes,
inventoryPath);
co_return PLDM_SUCCESS;
}

Expand Down
12 changes: 6 additions & 6 deletions platform-mc/test/event_manager_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ TEST_F(EventManagerTest, processNumericSensorEventTest)
#define SENSOR_READING 50
#define WARNING_HIGH 45
pldm::tid_t tid = 1;
termini[tid] =
std::make_shared<Terminus>(tid, 1 << PLDM_BASE | 1 << PLDM_PLATFORM);
termini[tid] = std::make_shared<Terminus>(
tid, 1 << PLDM_BASE | 1 << PLDM_PLATFORM, "");
std::vector<uint8_t> pdr1{
0x1,
0x0,
Expand Down Expand Up @@ -207,8 +207,8 @@ TEST_F(EventManagerTest, SetEventReceiverTest)
// Add terminus
auto mappedTid = terminusManager.mapTid(pldm::MctpInfo(1, "", "", 1, ""));
auto tid = mappedTid.value();
termini[tid] =
std::make_shared<Terminus>(tid, 1 << PLDM_BASE | 1 << PLDM_PLATFORM);
termini[tid] = std::make_shared<Terminus>(
tid, 1 << PLDM_BASE | 1 << PLDM_PLATFORM, "");
auto terminus = termini[tid];

// queue eventMessageBufferSize response(bufferSize=32)
Expand Down Expand Up @@ -351,8 +351,8 @@ TEST_F(EventManagerTest, pollForPlatformEventTaskMultipartTransferTest)
// Add terminus
auto mappedTid = terminusManager.mapTid(pldm::MctpInfo(1, "", "", 1, ""));
auto tid = mappedTid.value();
termini[tid] =
std::make_shared<Terminus>(tid, 1 << PLDM_BASE | 1 << PLDM_PLATFORM);
termini[tid] = std::make_shared<Terminus>(
tid, 1 << PLDM_BASE | 1 << PLDM_PLATFORM, "");
auto terminus = termini[tid];

// queue pollForPlatformEventMessage first part response
Expand Down
10 changes: 5 additions & 5 deletions platform-mc/test/platform_manager_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ TEST_F(PlatformManagerTest, initTerminusTest)
auto mappedTid =
mockTerminusManager.mapTid(pldm::MctpInfo(1, "", "", 1, ""));
auto tid = mappedTid.value();
termini[tid] =
std::make_shared<Terminus>(tid, 1 << PLDM_BASE | 1 << PLDM_PLATFORM);
termini[tid] = std::make_shared<Terminus>(
tid, 1 << PLDM_BASE | 1 << PLDM_PLATFORM, "");
auto terminus = termini[tid];

// queue dummy eventMessageBufferSize response
Expand Down Expand Up @@ -168,7 +168,7 @@ TEST_F(PlatformManagerTest, negativeInitTerminusTest1)
auto mappedTid =
mockTerminusManager.mapTid(pldm::MctpInfo(1, "", "", 1, ""));
auto tid = mappedTid.value();
termini[tid] = std::make_shared<Terminus>(tid, 1 << PLDM_BASE);
termini[tid] = std::make_shared<Terminus>(tid, 1 << PLDM_BASE, "");
auto terminus = termini[tid];

platformManager.initTerminus();
Expand All @@ -183,8 +183,8 @@ TEST_F(PlatformManagerTest, negativeInitTerminusTest2)
auto mappedTid =
mockTerminusManager.mapTid(pldm::MctpInfo(1, "", "", 1, ""));
auto tid = mappedTid.value();
termini[tid] =
std::make_shared<Terminus>(tid, 1 << PLDM_BASE | 1 << PLDM_PLATFORM);
termini[tid] = std::make_shared<Terminus>(
tid, 1 << PLDM_BASE | 1 << PLDM_PLATFORM, "");
auto terminus = termini[tid];

// queue getPDRRepositoryInfo response cc=PLDM_ERROR
Expand Down
2 changes: 1 addition & 1 deletion platform-mc/test/sensor_manager_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ TEST_F(SensorManagerTest, sensorPollingTest)
uint64_t expectedTimes = (seconds * 1000) / SENSOR_POLLING_TIME;

pldm::tid_t tid = 1;
termini[tid] = std::make_shared<pldm::platform_mc::Terminus>(tid, 0);
termini[tid] = std::make_shared<pldm::platform_mc::Terminus>(tid, 0, "");

EXPECT_CALL(sensorManager, doSensorPolling(tid))
.Times(Between(expectedTimes - 3, expectedTimes + 3))
Expand Down
8 changes: 4 additions & 4 deletions platform-mc/test/terminus_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ using namespace pldm::platform_mc;

TEST(TerminusTest, supportedTypeTest)
{
auto t1 = Terminus(1, 1 << PLDM_BASE);
auto t2 = Terminus(2, 1 << PLDM_BASE | 1 << PLDM_PLATFORM);
auto t1 = Terminus(1, 1 << PLDM_BASE, "");
auto t2 = Terminus(2, 1 << PLDM_BASE | 1 << PLDM_PLATFORM, "");

EXPECT_EQ(true, t1.doesSupport(PLDM_BASE));
EXPECT_EQ(false, t1.doesSupport(PLDM_PLATFORM));
Expand All @@ -20,14 +20,14 @@ TEST(TerminusTest, supportedTypeTest)
TEST(TerminusTest, getTidTest)
{
const pldm::tid_t tid = 1;
auto t1 = Terminus(tid, 1 << PLDM_BASE);
auto t1 = Terminus(tid, 1 << PLDM_BASE, "");

EXPECT_EQ(tid, t1.getTid());
}

TEST(TerminusTest, parseSensorAuxiliaryNamesPDRTest)
{
auto t1 = Terminus(1, 1 << PLDM_BASE | 1 << PLDM_PLATFORM);
auto t1 = Terminus(1, 1 << PLDM_BASE | 1 << PLDM_PLATFORM, "");
std::vector<uint8_t> pdr1{
0x0,
0x0,
Expand Down

0 comments on commit 6d1a93b

Please sign in to comment.