phosphor-post-code-manager: Add post code support for multi host
Added implementation to handle post codes from multiple host to BMC with
multi process approach. Each process handles post codes for corresponding host.
TESTED : Built the openbmc image targetting Facebook YosemiteV2 hardware.
Verified all the host's postcodes stored in corresponding host directories.
Signed-off-by: Kumar Thangavel <thangavel.k@hcl.com>
Change-Id: I29d55558ed165d9e4494f017e13808dff6252b04
diff --git a/inc/post_code.hpp b/inc/post_code.hpp
index 5541de4..5e2a7b9 100644
--- a/inc/post_code.hpp
+++ b/inc/post_code.hpp
@@ -34,16 +34,39 @@
#define MaxPostCodeCycles 100
-const static constexpr char *PostCodePath =
- "/xyz/openbmc_project/state/boot/raw";
-const static constexpr char *PropertiesIntf = "org.freedesktop.DBus.Properties";
-const static constexpr char *PostCodeListPath =
- "/var/lib/phosphor-post-code-manager/";
const static constexpr char *CurrentBootCycleCountName =
"CurrentBootCycleCount";
const static constexpr char *CurrentBootCycleIndexName =
"CurrentBootCycleIndex";
-const static constexpr char *HostStatePath = "/xyz/openbmc_project/state/host0";
+
+// Singleton holder to store host/node and other path information
+class PostCodeDataHolder
+{
+ static PostCodeDataHolder *instance;
+
+ PostCodeDataHolder()
+ {
+ }
+
+ public:
+ static PostCodeDataHolder *getInstance()
+ {
+ if (!instance)
+ instance = new PostCodeDataHolder;
+ return instance;
+ }
+
+ int node;
+
+ const static constexpr char *PostCodePath =
+ "/xyz/openbmc_project/state/boot/raw";
+ const static constexpr char *PropertiesIntf =
+ "org.freedesktop.DBus.Properties";
+ const static constexpr char *PostCodeListPathPrefix =
+ "/var/lib/phosphor-post-code-manager/host";
+ const static constexpr char *HostStatePathPrefix =
+ "/xyz/openbmc_project/state/host";
+};
struct EventDeleter
{
@@ -63,14 +86,20 @@
struct PostCode : sdbusplus::server::object_t<post_code, delete_all>
{
+ PostCodeDataHolder *postcodeDataHolderObj =
+ postcodeDataHolderObj->getInstance();
+
PostCode(sdbusplus::bus::bus &bus, const char *path, EventPtr &event) :
sdbusplus::server::object_t<post_code, delete_all>(bus, path), bus(bus),
propertiesChangedSignalRaw(
bus,
sdbusplus::bus::match::rules::type::signal() +
sdbusplus::bus::match::rules::member("PropertiesChanged") +
- sdbusplus::bus::match::rules::path(PostCodePath) +
- sdbusplus::bus::match::rules::interface(PropertiesIntf),
+ sdbusplus::bus::match::rules::path(
+ postcodeDataHolderObj->PostCodePath +
+ std::to_string(postcodeDataHolderObj->node)) +
+ sdbusplus::bus::match::rules::interface(
+ postcodeDataHolderObj->PropertiesIntf),
[this](sdbusplus::message::message &msg) {
std::string objectName;
std::map<std::string, std::variant<uint64_t>> msgData;
@@ -89,8 +118,11 @@
bus,
sdbusplus::bus::match::rules::type::signal() +
sdbusplus::bus::match::rules::member("PropertiesChanged") +
- sdbusplus::bus::match::rules::path(HostStatePath) +
- sdbusplus::bus::match::rules::interface(PropertiesIntf),
+ sdbusplus::bus::match::rules::path(
+ postcodeDataHolderObj->HostStatePathPrefix +
+ std::to_string(postcodeDataHolderObj->node)) +
+ sdbusplus::bus::match::rules::interface(
+ postcodeDataHolderObj->PropertiesIntf),
[this](sdbusplus::message::message &msg) {
std::string objectName;
std::map<std::string, std::variant<std::string>> msgData;
@@ -124,9 +156,11 @@
{
phosphor::logging::log<phosphor::logging::level::INFO>(
"PostCode is created");
- auto dir = fs::path(PostCodeListPath);
+ auto dir = fs::path(postcodeDataHolderObj->PostCodeListPathPrefix +
+ std::to_string(postcodeDataHolderObj->node));
fs::create_directories(dir);
- strPostCodeListPath = PostCodeListPath;
+ strPostCodeListPath = postcodeDataHolderObj->PostCodeListPathPrefix +
+ std::to_string(postcodeDataHolderObj->node) + "/";
strCurrentBootCycleIndexName = CurrentBootCycleIndexName;
uint16_t index = 0;
deserialize(