Remove FanProfile configuration
If we add a "Profiles" vector into the PID and Stepwise
entity-manager configurations the logic becomes much more
simple. We default to all profiles, and can limit the scope
of some configurations to the selected profile.
Tested: Switched between Acoustic/Performance mode and saw
a UpperClippingCurve get added / removed.
Change-Id: Ib0448b59210f696c8a28a99da06f98b065eadf08
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/dbus/dbusconfiguration.cpp b/dbus/dbusconfiguration.cpp
index 870e5e8..1fd0d1a 100644
--- a/dbus/dbusconfiguration.cpp
+++ b/dbus/dbusconfiguration.cpp
@@ -45,8 +45,6 @@
"xyz.openbmc_project.Configuration.Pid.Zone";
constexpr const char* stepwiseConfigurationInterface =
"xyz.openbmc_project.Configuration.Stepwise";
-constexpr const char* fanProfileConfigurationIface =
- "xyz.openbmc_project.Configuration.FanProfile";
constexpr const char* thermalControlIface =
"xyz.openbmc_project.Control.ThermalMode";
constexpr const char* sensorInterface = "xyz.openbmc_project.Sensor.Value";
@@ -252,10 +250,9 @@
// this is a list because the matches can't be moved
static std::list<sdbusplus::bus::match::match> matches;
- const std::array<std::string, 5> interfaces = {
- thermalControlIface, fanProfileConfigurationIface,
- pidConfigurationInterface, pidZoneConfigurationInterface,
- stepwiseConfigurationInterface};
+ const std::array<std::string, 4> interfaces = {
+ thermalControlIface, pidConfigurationInterface,
+ pidZoneConfigurationInterface, stepwiseConfigurationInterface};
// this list only needs to be created once
if (!matches.empty())
@@ -302,11 +299,11 @@
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetSubTree");
mapper.append("/", 0,
- std::array<const char*, 7>{
- objectManagerInterface, pidConfigurationInterface,
- pidZoneConfigurationInterface,
- stepwiseConfigurationInterface, sensorInterface,
- pwmInterface, fanProfileConfigurationIface});
+ std::array<const char*, 6>{objectManagerInterface,
+ pidConfigurationInterface,
+ pidZoneConfigurationInterface,
+ stepwiseConfigurationInterface,
+ sensorInterface, pwmInterface});
std::unordered_map<
std::string, std::unordered_map<std::string, std::vector<std::string>>>
respData;
@@ -362,7 +359,6 @@
}
}
ManagedObjectType configurations;
- ManagedObjectType profiles;
for (const auto& owner : owners)
{
// skip if no pid configuration (means probably a sensor)
@@ -397,125 +393,60 @@
{
configurations.emplace(pathPair);
}
- if (pathPair.second.find(fanProfileConfigurationIface) !=
- pathPair.second.end())
- {
- profiles.emplace(pathPair);
- }
}
}
// remove controllers from config that aren't in the current profile(s)
- if (profiles.size())
+ std::vector<std::string> selectedProfiles = getSelectedProfiles(bus);
+ if (selectedProfiles.size())
{
- std::vector<std::string> selectedProfiles = getSelectedProfiles(bus);
- if (selectedProfiles.size())
+ for (auto pathIt = configurations.begin();
+ pathIt != configurations.end();)
{
- // make the names match the dbus name
- for (auto& profile : selectedProfiles)
+ for (auto confIt = pathIt->second.begin();
+ confIt != pathIt->second.end();)
{
- std::replace(profile.begin(), profile.end(), ' ', '_');
- }
-
- // remove profiles that aren't supported
- for (auto it = profiles.begin(); it != profiles.end();)
- {
- auto& path = it->first.str;
- auto inConfig = std::find_if(
- selectedProfiles.begin(), selectedProfiles.end(),
- [&path](const std::string& key) {
- return (path.find(key) != std::string::npos);
- });
- if (inConfig == selectedProfiles.end())
+ auto profilesFind = confIt->second.find("Profiles");
+ if (profilesFind == confIt->second.end())
{
- it = profiles.erase(it);
+ confIt++;
+ continue; // if no profiles selected, apply always
+ }
+ auto profiles =
+ std::get<std::vector<std::string>>(profilesFind->second);
+ if (profiles.empty())
+ {
+ confIt++;
+ continue;
+ }
+
+ bool found = false;
+ for (const std::string& profile : profiles)
+ {
+ if (std::find(selectedProfiles.begin(),
+ selectedProfiles.end(),
+ profile) != selectedProfiles.end())
+ {
+ found = true;
+ break;
+ }
+ }
+ if (found)
+ {
+ confIt++;
}
else
{
- it++;
+ confIt = pathIt->second.erase(confIt);
}
}
- std::vector<std::string> allowedControllers;
-
- // create a vector of profile match strings
- for (const auto& profile : profiles)
+ if (pathIt->second.empty())
{
- const auto& interface =
- profile.second.at(fanProfileConfigurationIface);
- auto findController = interface.find("Controllers");
- if (findController == interface.end())
- {
- throw std::runtime_error("Profile Missing Controllers");
- }
- std::vector<std::string> controllers =
- std::get<std::vector<std::string>>(findController->second);
- allowedControllers.insert(allowedControllers.end(),
- controllers.begin(),
- controllers.end());
+ pathIt = configurations.erase(pathIt);
}
- std::vector<std::regex> regexes;
- for (auto& controller : allowedControllers)
+ else
{
- std::replace(controller.begin(), controller.end(), ' ', '_');
- try
- {
- regexes.push_back(std::regex(controller));
- }
- catch (std::regex_error&)
- {
- std::cerr << "Invalid regex: " << controller << "\n";
- throw;
- }
- }
-
- // remove configurations that don't match any of the regexes
- for (auto it = configurations.begin(); it != configurations.end();)
- {
- const std::string& path = it->first;
- size_t lastSlash = path.rfind("/");
- if (lastSlash == std::string::npos)
- {
- // if this happens, the mapper has a bug
- throw std::runtime_error("Invalid path in configuration");
- }
- std::string name = path.substr(lastSlash);
- auto allowed = std::find_if(
- regexes.begin(), regexes.end(), [&name](auto& reg) {
- std::smatch match;
- return std::regex_search(name, match, reg);
- });
- if (allowed == regexes.end())
- {
- auto findZone =
- it->second.find(pidZoneConfigurationInterface);
-
- // if there is a fanzone under the given configuration, keep
- // it but remove any of the other controllers
- if (findZone != it->second.end())
- {
- for (auto subIt = it->second.begin();
- subIt != it->second.end();)
- {
- if (subIt == findZone)
- {
- subIt++;
- }
- else
- {
- subIt = it->second.erase(subIt);
- }
- }
- it++;
- }
- else
- {
- it = configurations.erase(it);
- }
- }
- else
- {
- it++;
- }
+ pathIt++;
}
}
}