blob: 85976159b6498d3a5c1c4ccf9142797f60b57bab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
/*
// Copyright (c) 2019 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
*/
#include <sdbusplus/asio/object_server.hpp>
#include <utility.hpp>
#include <xyz/openbmc_project/Control/PowerSupplyRedundancy/server.hpp>
const constexpr char* psuInterface =
"/xyz/openbmc_project/inventory/system/powersupply/";
const constexpr int secondsInOneDay = 86400;
const constexpr uint8_t bmcSpecific = 0;
class ColdRedundancy
: sdbusplus::xyz::openbmc_project::Control::server::PowerSupplyRedundancy
{
public:
ColdRedundancy(
boost::asio::io_service& io,
sdbusplus::asio::object_server& objectServer,
std::shared_ptr<sdbusplus::asio::connection>& dbusConnection,
std::vector<std::unique_ptr<sdbusplus::bus::match::match>>& matches);
~ColdRedundancy() = default;
uint8_t pSUNumber() const override;
void
createPSU(boost::asio::io_service& io,
sdbusplus::asio::object_server& objectServer,
std::shared_ptr<sdbusplus::asio::connection>& dbusConnection);
private:
bool crSupported = true;
bool crEnabled = true;
bool rotationEnabled = true;
std::string rotationAlgo =
"xyz.openbmc_project.Control.PowerSupplyRedundancy.Algo.bmcSpecific";
uint8_t psOrder;
uint8_t numberOfPSU = 0;
uint32_t rotationPeriod = 7 * secondsInOneDay;
uint8_t redundancyPSURequire = 1;
void startRotateCR(void);
void startCRCheck(void);
void rotateCR(void);
void configCR(bool reConfig);
void checkCR(void);
void reRanking(void);
void putWarmRedundant(void);
void keepAliveCheck(void);
void checkRedundancyEvent();
std::shared_ptr<sdbusplus::asio::connection>& systemBus;
boost::asio::steady_timer timerRotation;
boost::asio::steady_timer timerCheck;
boost::asio::steady_timer warmRedundantTimer1;
boost::asio::steady_timer warmRedundantTimer2;
boost::asio::steady_timer keepAliveTimer;
boost::asio::steady_timer filterTimer;
boost::asio::steady_timer puRedundantTimer;
};
constexpr const uint8_t pmbusCmdCRSupport = 0xd0;
class PowerSupply
{
public:
PowerSupply(
std::string name, uint8_t bus, uint8_t address,
const std::shared_ptr<sdbusplus::asio::connection>& dbusConnection);
~PowerSupply();
std::string name;
uint8_t order = 0;
uint8_t bus;
uint8_t address;
PSUState state = PSUState::normal;
};
|