pcieslot: Add slottype by length support
Add necessary support needed to display the fulllength & halflength
slottypes on dbus.
Tested By:
1. Once coreboot/u-root transfers the smbios tables, I could see that
the PCIeSlot types also show the fulllength & halflength slots on
dbus & also confirmed the same on the openbmc webUI.
Change-Id: Iaf47f3525c86a82f5b57ac8cf05b9cb12b44f5cc
Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
diff --git a/src/pcieslot.cpp b/src/pcieslot.cpp
index 4b109d0..63d7f91 100644
--- a/src/pcieslot.cpp
+++ b/src/pcieslot.cpp
@@ -45,7 +45,7 @@
auto pcieInfo = reinterpret_cast<struct SystemSlotInfo*>(dataIn);
pcieGeneration(pcieInfo->slotType);
- pcieType(pcieInfo->slotType);
+ pcieType(pcieInfo->slotType, pcieInfo->slotLength);
pcieLaneSize(pcieInfo->slotDataBusWidth);
pcieIsHotPluggable(pcieInfo->characteristics2);
pcieLocation(pcieInfo->slotDesignation, pcieInfo->length, dataIn);
@@ -75,17 +75,28 @@
}
}
-void Pcie::pcieType(const uint8_t type)
+void Pcie::pcieType(const uint8_t type, const uint8_t slotLength)
{
- std::map<uint8_t, PCIeType>::const_iterator it = pcieTypeTable.find(type);
- if (it == pcieTypeTable.end())
+ // Try to find PCIeType in the main table
+ auto it = pcieTypeTable.find(type);
+ PCIeType pcieSlotType = PCIeType::Unknown;
+
+ if (it != pcieTypeTable.end())
{
- PCIeSlot::slotType(PCIeType::Unknown);
+ pcieSlotType = it->second;
}
else
{
- PCIeSlot::slotType(it->second);
+ // If not found in `pcieTypeTable`, check `PCIeTypeByLength`
+ auto slotIt = PCIeTypeByLength.find(slotLength);
+ if (slotIt != PCIeTypeByLength.end())
+ {
+ pcieSlotType = slotIt->second;
+ }
}
+
+ // Set the slot type
+ PCIeSlot::slotType(pcieSlotType);
}
void Pcie::pcieLaneSize(const uint8_t width)