IpmbSensor:Add bus index for multiple IPMB bus
IPMB bus is a physical bus which is exposed using IPMB driver. IPMB
is an I2c based serial bus that interconnects the baseboard and
chassis management.
A BMC that includes IPMB interface support and also provides the
capability for system software to send and receive messages to
and from the IPMB using the BMC as a kind of communication
controller.
In OCP multi-host platform, multiple IPMB bus support is present.
Therefore, for each config, IPMB bus value will be passed from
entity-manager json config file.
Through this IPMB bus, BMC will send and receive messages and then
store the response for each configuration.
Example :
{
"Address": "0x01",
"Bus": "$bus",
"Name": "Temp_Sensor",
"Type": "IpmbSensor"
}
In the current patchset, only IPMB bus value is read and further
implementation using this value will be done in the following
patchset.
SDR Sensor :
https://gerrit.openbmc-project.xyz/c/openbmc/dbus-sensors/+/52164
https://gerrit.openbmc-project.xyz/c/openbmc/dbus-sensors/+/38905
IPMB GPIO State :
https://gerrit.openbmc-project.xyz/c/openbmc/dbus-sensors/+/47952
TESTED: Tested on Facebook YosemiteV2 hardware and verified the
IPMB bus value.
Signed-off-by: Jayashree Dhanapal <jayashree-d@hcl.com>
Change-Id: I0a47057da98ee81471ac9f6fac69a036853db7d1
diff --git a/src/IpmbSensor.cpp b/src/IpmbSensor.cpp
index 39e385d..2af79e4 100644
--- a/src/IpmbSensor.cpp
+++ b/src/IpmbSensor.cpp
@@ -43,6 +43,7 @@
static constexpr uint8_t meAddress = 1;
static constexpr uint8_t lun = 0;
static constexpr uint8_t hostSMbusIndexDefault = 0x03;
+static constexpr uint8_t ipmbBusIndexDefault = 0;
static constexpr float pollRateDefault = 1; // in seconds
static constexpr const char* sensorPathPrefix = "/xyz/openbmc_project/sensors/";
@@ -525,6 +526,16 @@
float pollRate = getPollRate(cfg, pollRateDefault);
+ uint8_t ipmbBusIndex = ipmbBusIndexDefault;
+ auto findBusType = cfg.find("Bus");
+ if (findBusType != cfg.end())
+ {
+ ipmbBusIndex = std::visit(VariantToUnsignedIntVisitor(),
+ findBusType->second);
+ std::cerr << "Ipmb Bus Index for " << name << " is "
+ << static_cast<int>(ipmbBusIndex) << "\n";
+ }
+
/* Default sensor type is "temperature" */
std::string sensorTypeName = "temperature";
auto findType = cfg.find("SensorType");