Skip to content

Commit

Permalink
Expose PmUnitInfo in PlatformExplorer
Browse files Browse the repository at this point in the history
Summary:
getPmUnitName -> getPmUnitInfo.

Simple getter for PmUnitInfo in PlatformExplorer.

Reviewed By: alandau

Differential Revision: D61671534

fbshipit-source-id: 27476a041caa24a9197fc8bd7766fad03640a22b
  • Loading branch information
Justin Kim authored and facebook-github-bot committed Aug 27, 2024
1 parent 14d894a commit 6940440
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
4 changes: 2 additions & 2 deletions fboss/platform/platform_manager/DataStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ void DataStore::updateI2cBusNum(
i2cBusNums_[std::make_pair(slotPath, pmUnitScopeBusName)] = busNum;
}

std::string DataStore::getPmUnitName(const std::string& slotPath) const {
PmUnitInfo DataStore::getPmUnitInfo(const std::string& slotPath) const {
if (slotPathToPmUnitInfo.find(slotPath) != slotPathToPmUnitInfo.end()) {
return *slotPathToPmUnitInfo.at(slotPath).name();
return slotPathToPmUnitInfo.at(slotPath);
}
throw std::runtime_error(
fmt::format("Could not find PmUnit at {}", slotPath));
Expand Down
6 changes: 3 additions & 3 deletions fboss/platform/platform_manager/DataStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class DataStore {
const std::string& pmUnitScopeBusName,
uint16_t busNum);

// Get PmUnitName at the given SlotPath
std::string getPmUnitName(const std::string& slotPath) const;
// Get PmUnitInfo at the given SlotPath
PmUnitInfo getPmUnitInfo(const std::string& slotPath) const;

// Checks if a PmUnit exists at the given SlotPath
bool hasPmUnit(const std::string& slotPath) const;
Expand Down Expand Up @@ -86,7 +86,7 @@ class DataStore {
// Map from PciSubDevicePath to CharDevPath
std::map<std::string, std::string> pciSubDevicePathToCharDevPath_{};

// Map from PmUnitName to its PmUnitInfo
// Map from SlotPath to its PmUnitInfo
std::map<std::string, PmUnitInfo> slotPathToPmUnitInfo{};

const PlatformConfig& platformConfig_;
Expand Down
9 changes: 7 additions & 2 deletions fboss/platform/platform_manager/PlatformExplorer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,9 @@ void PlatformExplorer::reportExplorationSummary() {
for (const auto& [slotPath, errMsgs] : errorMessagesBySlotPath) {
XLOG(INFO) << fmt::format(
"Failures in PmUnit {} at {}",
dataStore_.hasPmUnit(slotPath) ? dataStore_.getPmUnitName(slotPath)
: "<ABSENT>",
dataStore_.hasPmUnit(slotPath)
? *dataStore_.getPmUnitInfo(slotPath).name()
: "<ABSENT>",
slotPath);
int i = 1;
for (const auto& errMsg : errMsgs) {
Expand Down Expand Up @@ -641,6 +642,10 @@ PlatformManagerStatus PlatformExplorer::getPMStatus() const {
return platformManagerStatus_.copy();
}

PmUnitInfo PlatformExplorer::getPmUnitInfo(const std::string& slotPath) const {
return dataStore_.getPmUnitInfo(slotPath);
}

void PlatformExplorer::setupI2cDevice(
const std::string& devicePath,
uint16_t busNum,
Expand Down
4 changes: 4 additions & 0 deletions fboss/platform/platform_manager/PlatformExplorer.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ class PlatformExplorer {
// Get the last PlatformManagerStatus.
PlatformManagerStatus getPMStatus() const;

// Get the PmUnitInfo of the given SlotPath and PmUnitName.
// throws if no PmUnit found at the SlotPath.
PmUnitInfo getPmUnitInfo(const std::string& slotPath) const;

private:
void createDeviceSymLink(
const std::string& linkPath,
Expand Down
5 changes: 3 additions & 2 deletions fboss/platform/platform_manager/tests/DataStoreTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ TEST(DataStoreTest, PmUnitAtSlotPath) {
dataStore.updatePmUnitInfo("/", "MCB_FAN_CPLD", 1);
EXPECT_TRUE(dataStore.hasPmUnit("/"));
EXPECT_FALSE(dataStore.hasPmUnit("/SMB_SLOT@1"));
EXPECT_EQ(dataStore.getPmUnitName("/"), "MCB_FAN_CPLD");
EXPECT_THROW(dataStore.getPmUnitName("/SMB_SLOT@1"), std::runtime_error);
EXPECT_EQ(*dataStore.getPmUnitInfo("/").name(), "MCB_FAN_CPLD");
EXPECT_EQ(*dataStore.getPmUnitInfo("/").version()->productSubVersion(), 1);
EXPECT_THROW(dataStore.getPmUnitInfo("/SMB_SLOT@1"), std::runtime_error);
}

TEST(DataStoreTest, FpgaIpBlockPciDevicePath) {
Expand Down

0 comments on commit 6940440

Please sign in to comment.