Remove Configuration interface prefix from utils APIs
This eliminates some repetitive verbosity from daemons that handle a lot
of different sensor types (such as hwmontempsensor and psusensor). It
also positions us to more cleanly use a single data structure for both
existing APIs like GetSensorConfiguration() and
setupPropertiesChangedMatches(), as well as upcoming I2C
device-management support.
Tested: hwmontempsensor and adcsensor on romed8hm3 continue to behave as
they did previously.
Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Change-Id: I9d80475ca4160c8d2ff0afab942709496d51238d
diff --git a/src/ADCSensor.cpp b/src/ADCSensor.cpp
index 4d47762..eacce22 100644
--- a/src/ADCSensor.cpp
+++ b/src/ADCSensor.cpp
@@ -49,9 +49,8 @@
const std::string& sensorConfiguration,
std::optional<BridgeGpio>&& bridgeGpio) :
Sensor(escapeName(sensorName), std::move(thresholdsIn), sensorConfiguration,
- "xyz.openbmc_project.Configuration.ADC", false, false,
- maxVoltageReading / scaleFactor, minVoltageReading / scaleFactor,
- conn, readState),
+ "ADC", false, false, maxVoltageReading / scaleFactor,
+ minVoltageReading / scaleFactor, conn, readState),
objServer(objectServer), inputDev(io), waitTimer(io), path(path),
scaleFactor(scaleFactor),
sensorPollMs(static_cast<unsigned int>(pollRate * 1000)),
diff --git a/src/ADCSensorMain.cpp b/src/ADCSensorMain.cpp
index 3669330..a2f6514 100644
--- a/src/ADCSensorMain.cpp
+++ b/src/ADCSensorMain.cpp
@@ -39,8 +39,7 @@
namespace fs = std::filesystem;
-static constexpr auto sensorTypes{
- std::to_array<const char*>({"xyz.openbmc_project.Configuration.ADC"})};
+static constexpr auto sensorTypes{std::to_array<const char*>({"ADC"})};
static std::regex inputRegex(R"(in(\d+)_input)");
static boost::container::flat_map<size_t, bool> cpuPresence;
@@ -120,7 +119,7 @@
// find base configuration
for (const char* type : sensorTypes)
{
- auto sensorBase = cfgData.find(type);
+ auto sensorBase = cfgData.find(configInterfaceName(type));
if (sensorBase != cfgData.end())
{
baseConfiguration = &(*sensorBase);
diff --git a/src/ExitAirTempSensor.cpp b/src/ExitAirTempSensor.cpp
index ea5a432..33fd079 100644
--- a/src/ExitAirTempSensor.cpp
+++ b/src/ExitAirTempSensor.cpp
@@ -37,9 +37,8 @@
#include <vector>
constexpr const double altitudeFactor = 1.14;
-constexpr const char* exitAirIface =
- "xyz.openbmc_project.Configuration.ExitAirTempSensor";
-constexpr const char* cfmIface = "xyz.openbmc_project.Configuration.CFMSensor";
+constexpr const char* exitAirType = "ExitAirTempSensor";
+constexpr const char* cfmType = "CFMSensor";
// todo: this *might* need to be configurable
constexpr const char* inletTemperatureSensor = "temperature/Front_Panel_Temp";
@@ -56,8 +55,8 @@
static constexpr size_t minSystemCfm = 50;
-constexpr const auto monitorIfaces{
- std::to_array<const char*>({exitAirIface, cfmIface})};
+constexpr const auto monitorTypes{
+ std::to_array<const char*>({exitAirType, cfmType})};
static std::vector<std::shared_ptr<CFMSensor>> cfmSensors;
@@ -160,8 +159,8 @@
std::vector<thresholds::Threshold>&& thresholdData,
std::shared_ptr<ExitAirTempSensor>& parent) :
Sensor(escapeName(sensorName), std::move(thresholdData),
- sensorConfiguration, "xyz.openbmc_project.Configuration.CFMSensor",
- false, false, cfmMaxReading, cfmMinReading, conn, PowerState::on),
+ sensorConfiguration, "CFMSensor", false, false, cfmMaxReading,
+ cfmMinReading, conn, PowerState::on),
parent(parent), objServer(objectServer)
{
sensorInterface = objectServer.add_interface(
@@ -497,9 +496,8 @@
sdbusplus::asio::object_server& objectServer,
std::vector<thresholds::Threshold>&& thresholdData) :
Sensor(escapeName(sensorName), std::move(thresholdData),
- sensorConfiguration, "xyz.openbmc_project.Configuration.ExitAirTemp",
- false, false, exitAirMaxReading, exitAirMinReading, conn,
- PowerState::on),
+ sensorConfiguration, "ExitAirTemp", false, false, exitAirMaxReading,
+ exitAirMinReading, conn, PowerState::on),
objServer(objectServer)
{
sensorInterface = objectServer.add_interface(
@@ -873,7 +871,7 @@
{
for (const auto& [intf, cfg] : interfaces)
{
- if (intf == exitAirIface)
+ if (intf == configInterfaceName(exitAirType))
{
// thresholds should be under the same path
std::vector<thresholds::Threshold> sensorThresholds;
@@ -892,7 +890,7 @@
exitAirSensor->alphaS = loadVariant<double>(cfg, "AlphaS");
exitAirSensor->alphaF = loadVariant<double>(cfg, "AlphaF");
}
- else if (intf == cfmIface)
+ else if (intf == configInterfaceName(cfmType))
{
// thresholds should be under the same path
std::vector<thresholds::Threshold> sensorThresholds;
@@ -925,7 +923,7 @@
}
});
getter->getConfiguration(
- std::vector<std::string>(monitorIfaces.begin(), monitorIfaces.end()));
+ std::vector<std::string>(monitorTypes.begin(), monitorTypes.end()));
}
int main()
@@ -959,7 +957,7 @@
});
};
std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches =
- setupPropertiesChangedMatches(*systemBus, monitorIfaces, eventHandler);
+ setupPropertiesChangedMatches(*systemBus, monitorTypes, eventHandler);
setupManufacturingModeMatch(*systemBus);
io.run();
diff --git a/src/ExternalSensorMain.cpp b/src/ExternalSensorMain.cpp
index e04fc78..e79098f 100644
--- a/src/ExternalSensorMain.cpp
+++ b/src/ExternalSensorMain.cpp
@@ -51,8 +51,7 @@
static constexpr bool debug = false;
-static const char* sensorType =
- "xyz.openbmc_project.Configuration.ExternalSensor";
+static const char* sensorType = "ExternalSensor";
void updateReaper(boost::container::flat_map<
std::string, std::shared_ptr<ExternalSensor>>& sensors,
@@ -172,7 +171,7 @@
const std::string& interfacePath = sensor.first.str;
const SensorData& sensorData = sensor.second;
- auto sensorBase = sensorData.find(sensorType);
+ auto sensorBase = sensorData.find(configInterfaceName(sensorType));
if (sensorBase == sensorData.end())
{
std::cerr << "Base configuration not found for "
diff --git a/src/FanMain.cpp b/src/FanMain.cpp
index 6732575..4e7542b 100644
--- a/src/FanMain.cpp
+++ b/src/FanMain.cpp
@@ -40,10 +40,8 @@
namespace fs = std::filesystem;
// The following two structures need to be consistent
-static auto sensorTypes{std::to_array<const char*>(
- {"xyz.openbmc_project.Configuration.AspeedFan",
- "xyz.openbmc_project.Configuration.I2CFan",
- "xyz.openbmc_project.Configuration.NuvotonFan"})};
+static auto sensorTypes{
+ std::to_array<const char*>({"AspeedFan", "I2CFan", "NuvotonFan"})};
enum FanTypes
{
@@ -237,6 +235,7 @@
fs::path directory = path.parent_path();
FanTypes fanType = getFanType(directory);
+ std::string cfgIntf = configInterfaceName(sensorTypes[fanType]);
// convert to 0 based
size_t index = std::stoul(indexStr) - 1;
@@ -249,7 +248,7 @@
{
// find the base of the configuration to see if indexes
// match
- auto sensorBaseFind = cfgData.find(sensorTypes[fanType]);
+ auto sensorBaseFind = cfgData.find(cfgIntf);
if (sensorBaseFind == cfgData.end())
{
continue;
@@ -364,7 +363,7 @@
}
auto presenceConfig =
- sensorData->find(baseType + std::string(".Presence"));
+ sensorData->find(cfgIntf + std::string(".Presence"));
std::unique_ptr<PresenceSensor> presenceSensor(nullptr);
@@ -410,7 +409,7 @@
std::make_pair(defaultMinReading, defaultMaxReading);
auto connector =
- sensorData->find(baseType + std::string(".Connector"));
+ sensorData->find(cfgIntf + std::string(".Connector"));
std::optional<std::string> led;
std::string pwmName;
diff --git a/src/HwmonTempMain.cpp b/src/HwmonTempMain.cpp
index 1431508..5a773b2 100644
--- a/src/HwmonTempMain.cpp
+++ b/src/HwmonTempMain.cpp
@@ -48,29 +48,11 @@
static constexpr double minValueTemperature = -128; // DegreesC
namespace fs = std::filesystem;
-static auto sensorTypes{
- std::to_array<const char*>({"xyz.openbmc_project.Configuration.DPS310",
- "xyz.openbmc_project.Configuration.EMC1412",
- "xyz.openbmc_project.Configuration.EMC1413",
- "xyz.openbmc_project.Configuration.EMC1414",
- "xyz.openbmc_project.Configuration.HDC1080",
- "xyz.openbmc_project.Configuration.JC42",
- "xyz.openbmc_project.Configuration.LM75A",
- "xyz.openbmc_project.Configuration.LM95234",
- "xyz.openbmc_project.Configuration.MAX31725",
- "xyz.openbmc_project.Configuration.MAX31730",
- "xyz.openbmc_project.Configuration.MAX6581",
- "xyz.openbmc_project.Configuration.MAX6654",
- "xyz.openbmc_project.Configuration.NCT7802",
- "xyz.openbmc_project.Configuration.NCT6779",
- "xyz.openbmc_project.Configuration.SBTSI",
- "xyz.openbmc_project.Configuration.SI7020",
- "xyz.openbmc_project.Configuration.TMP112",
- "xyz.openbmc_project.Configuration.TMP175",
- "xyz.openbmc_project.Configuration.TMP421",
- "xyz.openbmc_project.Configuration.TMP441",
- "xyz.openbmc_project.Configuration.TMP75",
- "xyz.openbmc_project.Configuration.W83773G"})};
+static auto sensorTypes{std::to_array<const char*>(
+ {"DPS310", "EMC1412", "EMC1413", "EMC1414", "HDC1080", "JC42",
+ "LM75A", "LM95234", "MAX31725", "MAX31730", "MAX6581", "MAX6654",
+ "NCT7802", "NCT6779", "SBTSI", "SI7020", "TMP112", "TMP175",
+ "TMP421", "TMP441", "TMP75", "W83773G"})};
static struct SensorParams
getSensorParameters(const std::filesystem::path& path)
diff --git a/src/IntelCPUSensorMain.cpp b/src/IntelCPUSensorMain.cpp
index 2780c1f..485729b 100644
--- a/src/IntelCPUSensorMain.cpp
+++ b/src/IntelCPUSensorMain.cpp
@@ -89,8 +89,7 @@
namespace fs = std::filesystem;
-static constexpr auto sensorTypes{
- std::to_array<const char*>({"xyz.openbmc_project.Configuration.XeonCPU"})};
+static constexpr auto sensorTypes{std::to_array<const char*>({"XeonCPU"})};
static constexpr auto hiddenProps{std::to_array<const char*>(
{IntelCPUSensor::labelTcontrol, "Tthrottle", "Tjmax"})};
@@ -244,7 +243,8 @@
for (const char* type : sensorTypes)
{
sensorType = type;
- auto sensorBase = sensorData->find(sensorType);
+ auto sensorBase =
+ sensorData->find(configInterfaceName(sensorType));
if (sensorBase != sensorData->end())
{
baseConfiguration = &(*sensorBase);
@@ -623,7 +623,7 @@
{
for (const auto& [intf, cfg] : cfgData)
{
- if (intf != type)
+ if (intf != configInterfaceName(type))
{
continue;
}
diff --git a/src/IntrusionSensorMain.cpp b/src/IntrusionSensorMain.cpp
index f85b1a6..f46254f 100644
--- a/src/IntrusionSensorMain.cpp
+++ b/src/IntrusionSensorMain.cpp
@@ -43,9 +43,8 @@
static constexpr bool debug = false;
-static constexpr const char* sensorType =
- "xyz.openbmc_project.Configuration.ChassisIntrusionSensor";
-static constexpr const char* nicType = "xyz.openbmc_project.Configuration.NIC";
+static constexpr const char* sensorType = "ChassisIntrusionSensor";
+static constexpr const char* nicType = "NIC";
static constexpr auto nicTypes{std::to_array<const char*>({nicType})};
namespace fs = std::filesystem;
@@ -77,7 +76,7 @@
sensorData = &cfgData;
// match sensor type
- auto sensorBase = sensorData->find(sensorType);
+ auto sensorBase = sensorData->find(configInterfaceName(sensorType));
if (sensorBase == sensorData->end())
{
std::cerr << "error finding base configuration \n";
@@ -188,7 +187,7 @@
baseConfiguration = nullptr;
// find base configuration
- auto sensorBase = cfgData.find(nicType);
+ auto sensorBase = cfgData.find(configInterfaceName(nicType));
if (sensorBase == cfgData.end())
{
continue;
@@ -473,8 +472,8 @@
sdbusplus::bus::match_t lanConfigMatch(
static_cast<sdbusplus::bus_t&>(*systemBus),
"type='signal', member='PropertiesChanged',path_namespace='" +
- std::string(inventoryPath) + "',arg0namespace='" + nicType +
- "'",
+ std::string(inventoryPath) + "',arg0namespace='" +
+ configInterfaceName(nicType) + "'",
[&systemBus](sdbusplus::message_t& msg) {
if (msg.is_method_error())
{
diff --git a/src/IpmbSensor.cpp b/src/IpmbSensor.cpp
index 9d087a7..7c5f965 100644
--- a/src/IpmbSensor.cpp
+++ b/src/IpmbSensor.cpp
@@ -36,8 +36,7 @@
constexpr const bool debug = false;
-constexpr const char* configInterface =
- "xyz.openbmc_project.Configuration.IpmbSensor";
+constexpr const char* sensorType = "IpmbSensor";
static constexpr double ipmbMaxReading = 0xFF;
static constexpr double ipmbMinReading = 0;
@@ -64,8 +63,8 @@
uint8_t deviceAddress, uint8_t hostSMbusIndex,
const float pollRate, std::string& sensorTypeName) :
Sensor(escapeName(sensorName), std::move(thresholdData),
- sensorConfiguration, "xyz.openbmc_project.Configuration.IpmbSensor",
- false, false, ipmbMaxReading, ipmbMinReading, conn, PowerState::on),
+ sensorConfiguration, "IpmbSensor", false, false, ipmbMaxReading,
+ ipmbMinReading, conn, PowerState::on),
deviceAddress(deviceAddress), hostSMbusIndex(hostSMbusIndex),
sensorPollMs(static_cast<int>(pollRate * 1000)), objectServer(objectServer),
waitTimer(io)
@@ -499,7 +498,7 @@
{
for (const auto& [intf, cfg] : interfaces)
{
- if (intf != configInterface)
+ if (intf != configInterfaceName(sensorType))
{
continue;
}
@@ -640,8 +639,7 @@
std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches =
setupPropertiesChangedMatches(
- *systemBus, std::to_array<const char*>({configInterface}),
- eventHandler);
+ *systemBus, std::to_array<const char*>({sensorType}), eventHandler);
sdbusplus::bus::match_t powerChangeMatch(
static_cast<sdbusplus::bus_t&>(*systemBus),
diff --git a/src/MCUTempSensor.cpp b/src/MCUTempSensor.cpp
index 8c96154..47893d2 100644
--- a/src/MCUTempSensor.cpp
+++ b/src/MCUTempSensor.cpp
@@ -39,8 +39,7 @@
constexpr const bool debug = false;
-constexpr const char* configInterface =
- "xyz.openbmc_project.Configuration.MCUTempSensor";
+constexpr const char* sensorType = "MCUTempSensor";
static constexpr double mcuTempMaxReading = 0xFF;
static constexpr double mcuTempMinReading = 0;
@@ -55,8 +54,7 @@
uint8_t busId, uint8_t mcuAddress,
uint8_t tempReg) :
Sensor(escapeName(sensorName), std::move(thresholdData),
- sensorConfiguration,
- "xyz.openbmc_project.Configuration.MCUTempSensor", false, false,
+ sensorConfiguration, "MCUTempSensor", false, false,
mcuTempMaxReading, mcuTempMinReading, conn),
busId(busId), mcuAddress(mcuAddress), tempReg(tempReg),
objectServer(objectServer), waitTimer(io)
@@ -210,7 +208,7 @@
{
for (const auto& [intf, cfg] : interfaces)
{
- if (intf != configInterface)
+ if (intf != configInterfaceName(sensorType))
{
continue;
}
@@ -292,8 +290,7 @@
std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches =
setupPropertiesChangedMatches(
- *systemBus, std::to_array<const char*>({configInterface}),
- eventHandler);
+ *systemBus, std::to_array<const char*>({sensorType}), eventHandler);
setupManufacturingModeMatch(*systemBus);
io.run();
return 0;
diff --git a/src/NVMeSensor.cpp b/src/NVMeSensor.cpp
index a5257f5..d32d166 100644
--- a/src/NVMeSensor.cpp
+++ b/src/NVMeSensor.cpp
@@ -29,7 +29,7 @@
const std::string& sensorConfiguration,
const int busNumber) :
Sensor(escapeName(sensorName), std::move(thresholdsIn), sensorConfiguration,
- NVMeSensor::configType, false, false, maxReading, minReading, conn,
+ NVMeSensor::sensorType, false, false, maxReading, minReading, conn,
PowerState::on),
bus(busNumber), objServer(objectServer)
{
diff --git a/src/NVMeSensorMain.cpp b/src/NVMeSensorMain.cpp
index 71993d2..1398d3c 100644
--- a/src/NVMeSensorMain.cpp
+++ b/src/NVMeSensorMain.cpp
@@ -125,7 +125,8 @@
for (const auto& [interfacePath, sensorData] : sensorConfigurations)
{
// find base configuration
- auto sensorBase = sensorData.find(NVMeSensor::configType);
+ auto sensorBase =
+ sensorData.find(configInterfaceName(NVMeSensor::sensorType));
if (sensorBase == sensorData.end())
{
continue;
@@ -189,7 +190,7 @@
handleSensorConfigurations(io, objectServer, dbusConnection,
sensorConfigurations);
});
- getter->getConfiguration(std::vector<std::string>{NVMeSensor::configType});
+ getter->getConfiguration(std::vector<std::string>{NVMeSensor::sensorType});
}
static void interfaceRemoved(sdbusplus::message_t& message, NVMEMap& contexts)
@@ -258,7 +259,7 @@
std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches =
setupPropertiesChangedMatches(
- *systemBus, std::to_array<const char*>({NVMeSensor::configType}),
+ *systemBus, std::to_array<const char*>({NVMeSensor::sensorType}),
eventHandler);
// Watch for entity-manager to remove configuration interfaces
diff --git a/src/PSUSensorMain.cpp b/src/PSUSensorMain.cpp
index e485598..0a197b8 100644
--- a/src/PSUSensorMain.cpp
+++ b/src/PSUSensorMain.cpp
@@ -40,43 +40,14 @@
static constexpr bool debug = false;
static constexpr auto sensorTypes{std::to_array<const char*>(
- {"xyz.openbmc_project.Configuration.ADM1266",
- "xyz.openbmc_project.Configuration.ADM1272",
- "xyz.openbmc_project.Configuration.ADM1275",
- "xyz.openbmc_project.Configuration.ADM1278",
- "xyz.openbmc_project.Configuration.ADM1293",
- "xyz.openbmc_project.Configuration.ADS7830",
- "xyz.openbmc_project.Configuration.BMR490",
- "xyz.openbmc_project.Configuration.DPS800",
- "xyz.openbmc_project.Configuration.INA219",
- "xyz.openbmc_project.Configuration.INA230",
- "xyz.openbmc_project.Configuration.IPSPS",
- "xyz.openbmc_project.Configuration.ISL68137",
- "xyz.openbmc_project.Configuration.ISL68220",
- "xyz.openbmc_project.Configuration.ISL68223",
- "xyz.openbmc_project.Configuration.ISL69225",
- "xyz.openbmc_project.Configuration.ISL69243",
- "xyz.openbmc_project.Configuration.ISL69260",
- "xyz.openbmc_project.Configuration.LM25066",
- "xyz.openbmc_project.Configuration.MAX16601",
- "xyz.openbmc_project.Configuration.MAX20710",
- "xyz.openbmc_project.Configuration.MAX20730",
- "xyz.openbmc_project.Configuration.MAX20734",
- "xyz.openbmc_project.Configuration.MAX20796",
- "xyz.openbmc_project.Configuration.MAX34451",
- "xyz.openbmc_project.Configuration.MP2971",
- "xyz.openbmc_project.Configuration.MP2973",
- "xyz.openbmc_project.Configuration.MP5023",
- "xyz.openbmc_project.Configuration.pmbus",
- "xyz.openbmc_project.Configuration.PXE1610",
- "xyz.openbmc_project.Configuration.RAA228000",
- "xyz.openbmc_project.Configuration.RAA228228",
- "xyz.openbmc_project.Configuration.RAA228620",
- "xyz.openbmc_project.Configuration.RAA229001",
- "xyz.openbmc_project.Configuration.RAA229004",
- "xyz.openbmc_project.Configuration.RAA229126",
- "xyz.openbmc_project.Configuration.TPS546D24",
- "xyz.openbmc_project.Configuration.XDPE12284"})};
+ {"ADM1266", "ADM1272", "ADM1275", "ADM1278", "ADM1293",
+ "ADS7830", "BMR490", "DPS800", "INA219", "INA230",
+ "IPSPS", "ISL68137", "ISL68220", "ISL68223", "ISL69225",
+ "ISL69243", "ISL69260", "LM25066", "MAX16601", "MAX20710",
+ "MAX20730", "MAX20734", "MAX20796", "MAX34451", "MP2971",
+ "MP2973", "MP5023", "pmbus", "PXE1610", "RAA228000",
+ "RAA228228", "RAA228620", "RAA229001", "RAA229004", "RAA229126",
+ "TPS546D24", "XDPE12284"})};
// clang-format off
static constexpr auto pmbusNames{std::to_array<const char*>({
@@ -395,7 +366,7 @@
sensorData = &cfgData;
for (const char* type : sensorTypes)
{
- auto sensorBase = sensorData->find(type);
+ auto sensorBase = sensorData->find(configInterfaceName(type));
if (sensorBase != sensorData->end())
{
baseConfig = &sensorBase->second;
diff --git a/src/Utils.cpp b/src/Utils.cpp
index cf9ff75..7b33cb7 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -142,6 +142,7 @@
ManagedObjectType& resp, bool useCache)
{
static ManagedObjectType managedObj;
+ std::string typeIntf = configInterfaceName(type);
if (!useCache)
{
@@ -169,7 +170,7 @@
{
for (const auto& [intf, cfg] : pathPair.second)
{
- if (intf.starts_with(type))
+ if (intf.starts_with(typeIntf))
{
resp.emplace(pathPair);
break;
@@ -705,7 +706,8 @@
auto match = std::make_unique<sdbusplus::bus::match_t>(
static_cast<sdbusplus::bus_t&>(bus),
"type='signal',member='PropertiesChanged',path_namespace='" +
- std::string(inventoryPath) + "',arg0namespace='" + type + "'",
+ std::string(inventoryPath) + "',arg0namespace='" +
+ configInterfaceName(type) + "'",
handler);
matches.emplace_back(std::move(match));
}