summaryrefslogtreecommitdiff
path: root/psu-manager
diff options
context:
space:
mode:
authorCheng C Yang <cheng.c.yang@intel.com>2019-08-08 04:54:20 +0300
committerCheng C Yang <cheng.c.yang@intel.com>2019-08-07 22:00:13 +0300
commita19580d978a58d1715b998c2b1db54462ca41d1e (patch)
treebbef2b27e665ad2d374fed449477bd45ef00717d /psu-manager
parent35478dce1b79e65d3a0862baf0b99166809da700 (diff)
downloadprovingground-a19580d978a58d1715b998c2b1db54462ca41d1e.tar.xz
Support Cold Redundancy ipmi command
Support ipmi command or redfish to change Cold Redundancy related config parameters. Tested: With Cold Redundancy ipmi command code change, run ipmi command to change config paramters - RotationEnable, RotationAlgorithm, RotationRankOrder, periodOfRotation and PowerSupplyRedundancyEnabled, the parameters in Cold Redundancy service will also be changed. Change-Id: I254553c7c9f1a2e33ef07a17433bd1ecd8a992f1 Signed-off-by: Cheng C Yang <cheng.c.yang@intel.com>
Diffstat (limited to 'psu-manager')
-rw-r--r--psu-manager/include/cold_redundancy.hpp4
-rw-r--r--psu-manager/include/utility.hpp2
-rw-r--r--psu-manager/src/cold_redundancy.cpp111
3 files changed, 107 insertions, 10 deletions
diff --git a/psu-manager/include/cold_redundancy.hpp b/psu-manager/include/cold_redundancy.hpp
index 53bf679..6d5397c 100644
--- a/psu-manager/include/cold_redundancy.hpp
+++ b/psu-manager/include/cold_redundancy.hpp
@@ -33,6 +33,7 @@ class ColdRedundancy
std::shared_ptr<sdbusplus::asio::connection>& dbusConnection);
~ColdRedundancy() = default;
+ uint8_t pSUNumber() const override;
void
createPSU(boost::asio::io_service& io,
sdbusplus::asio::object_server& objectServer,
@@ -42,7 +43,8 @@ class ColdRedundancy
bool crSupported = true;
bool crEnabled = true;
bool rotationEnabled = true;
- uint8_t rotationAlgo = 0;
+ std::string rotationAlgo =
+ "xyz.openbmc_project.Control.PowerSupplyRedundancy.Algo.bmcSpecific";
uint8_t psOrder;
uint8_t numberOfPSU = 0;
uint32_t rotationPeriod = 7 * secondsInOneDay;
diff --git a/psu-manager/include/utility.hpp b/psu-manager/include/utility.hpp
index 342d36f..e3c312a 100644
--- a/psu-manager/include/utility.hpp
+++ b/psu-manager/include/utility.hpp
@@ -22,6 +22,8 @@
#include <sdbusplus/asio/connection.hpp>
const constexpr char* entityManagerName = "xyz.openbmc_project.EntityManager";
+static const constexpr char* redundancyInterface =
+ "xyz.openbmc_project.Control.PowerSupplyRedundancy";
static const constexpr std::array<const char*, 1> psuEventInterface = {
"xyz.openbmc_project.State.Decorator.OperationalStatus"};
diff --git a/psu-manager/src/cold_redundancy.cpp b/psu-manager/src/cold_redundancy.cpp
index 81169a8..e88897e 100644
--- a/psu-manager/src/cold_redundancy.cpp
+++ b/psu-manager/src/cold_redundancy.cpp
@@ -75,6 +75,87 @@ ColdRedundancy::ColdRedundancy(
});
};
+ std::function<void(sdbusplus::message::message&)> paramConfig =
+ [this](sdbusplus::message::message& message) {
+ std::string objectName;
+ boost::container::flat_map<
+ std::string, std::variant<bool, uint8_t, uint32_t, std::string,
+ std::vector<uint8_t>>>
+ values;
+ message.read(objectName, values);
+
+ for (auto& value : values)
+ {
+ if (value.first == "ColdRedundancyEnabled")
+ {
+ bool* pCREnabled = std::get_if<bool>(&(value.second));
+ if (pCREnabled != nullptr)
+ {
+ crEnabled = *pCREnabled;
+ ColdRedundancy::configCR(false);
+ }
+ continue;
+ }
+ if (value.first == "RotationEnabled")
+ {
+ bool* pRotationEnabled = std::get_if<bool>(&(value.second));
+ if (pRotationEnabled != nullptr)
+ {
+ rotationEnabled = *pRotationEnabled;
+ ColdRedundancy::configCR(false);
+ }
+ continue;
+ }
+ if (value.first == "RotationAlgorithm")
+ {
+ std::string* pAlgo =
+ std::get_if<std::string>(&(value.second));
+ if (pAlgo != nullptr)
+ {
+ rotationAlgo = *pAlgo;
+ }
+ continue;
+ }
+ if (value.first == "RotationRankOrder")
+ {
+ auto pRank =
+ std::get_if<std::vector<uint8_t>>(&(value.second));
+ if (pRank == nullptr)
+ {
+ continue;
+ }
+ uint8_t rankSize = pRank->size();
+ uint8_t index = 0;
+ for (auto& psu : powerSupplies)
+ {
+ if (index < rankSize)
+ {
+ psu->order = (*pRank)[index];
+ }
+ else
+ {
+ psu->order = 0;
+ }
+ index++;
+ }
+ ColdRedundancy::configCR(false);
+ continue;
+ }
+ if (value.first == "PeriodOfRotation")
+ {
+ uint32_t* pPeriod = std::get_if<uint32_t>(&(value.second));
+ if (pPeriod != nullptr)
+ {
+ rotationPeriod = *pPeriod;
+ timerRotation.cancel();
+ startRotateCR();
+ }
+ continue;
+ }
+ std::cerr << "Unused property changed\n";
+ }
+ };
+
std::function<void(sdbusplus::message::message&)> eventCollect =
[&](sdbusplus::message::message& message) {
std::string objectName;
@@ -152,6 +233,14 @@ ColdRedundancy::ColdRedundancy(
matches.emplace_back(std::move(eventMatch));
}
+ auto configParamMatch = std::make_unique<sdbusplus::bus::match::match>(
+ static_cast<sdbusplus::bus::bus&>(*systemBus),
+ "type='signal',member='PropertiesChanged',path_namespace='" +
+ std::string(coldRedundancyPath) + "',arg0namespace='" +
+ redundancyInterface + "'",
+ paramConfig);
+ matches.emplace_back(std::move(configParamMatch));
+
io.run();
}
@@ -164,12 +253,11 @@ void ColdRedundancy::createPSU(
std::vector<PropertyMapType> sensorConfigs;
numberOfPSU = 0;
powerSupplies.clear();
- sensorConfigs.clear();
// call mapper to get matched obj paths
conn->async_method_call(
- [this, &conn, &sensorConfigs](const boost::system::error_code ec,
- GetSubTreeType subtree) {
+ [this, &conn](const boost::system::error_code ec,
+ GetSubTreeType subtree) {
if (ec)
{
std::cerr << "Exception happened when communicating to "
@@ -202,9 +290,8 @@ void ColdRedundancy::createPSU(
continue;
conn->async_method_call(
- [this, &conn,
- &sensorConfigs](const boost::system::error_code ec,
- PropertyMapType propMap) {
+ [this, &conn](const boost::system::error_code ec,
+ PropertyMapType propMap) {
if (ec)
{
std::cerr
@@ -216,7 +303,6 @@ void ColdRedundancy::createPSU(
{
std::cerr << "get valid propMap\n";
}
- // sensorConfigs.emplace_back(propMap);
auto configBus =
std::get_if<uint64_t>(&propMap["Bus"]);
auto configAddress =
@@ -257,6 +343,11 @@ void ColdRedundancy::createPSU(
startCRCheck();
}
+uint8_t ColdRedundancy::pSUNumber() const
+{
+ return numberOfPSU;
+}
+
PowerSupply::PowerSupply(
std::string name, uint8_t bus, uint8_t address,
const std::shared_ptr<sdbusplus::asio::connection>& dbusConnection) :
@@ -277,7 +368,8 @@ PowerSupply::PowerSupply(
void ColdRedundancy::reRanking(void)
{
uint8_t index = 1;
- if (rotationAlgo == bmcSpecific)
+ if (rotationAlgo ==
+ "xyz.openbmc_project.Control.PowerSupplyRedundancy.Algo.bmcSpecific")
{
for (auto& psu : powerSupplies)
{
@@ -297,7 +389,8 @@ void ColdRedundancy::reRanking(void)
{
if (psu->state == PSUState::acLost)
{
- rotationAlgo = bmcSpecific;
+ rotationAlgo = "xyz.openbmc_project.Control."
+ "PowerSupplyRedundancy.Algo.bmcSpecific";
reRanking();
return;
}