oem-ibm: Send the event to host when BIOS attribute changes
IBM has the requirement to send a hot update to host when the
BIOS attribute changes. This patch enables sending an OEM platform
event message to host with the details of the BIOS attributes that
changed on the BMC. Once the host acknowledges the event, then BMC
updates the BaseBiosTable in the bios-config-manager. The host comes
down and reads the changed BIOS attributes by calling the command
GetBIOSAttribute value.
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
Change-Id: Id1579bfed1967e653da743313c825b765d227681
diff --git a/libpldmresponder/bios.cpp b/libpldmresponder/bios.cpp
index a62d978..fbe6144 100644
--- a/libpldmresponder/bios.cpp
+++ b/libpldmresponder/bios.cpp
@@ -67,7 +67,9 @@
DBusHandler dbusHandler;
-Handler::Handler() : biosConfig(BIOS_JSONS_DIR, BIOS_TABLES_DIR, &dbusHandler)
+Handler::Handler(int fd, uint8_t eid, dbus_api::Requester* requester) :
+ biosConfig(BIOS_JSONS_DIR, BIOS_TABLES_DIR, &dbusHandler, fd, eid,
+ requester)
{
biosConfig.removeTables();
biosConfig.buildTables();
diff --git a/libpldmresponder/bios.hpp b/libpldmresponder/bios.hpp
index 9cfb22b..2fbf8ab 100644
--- a/libpldmresponder/bios.hpp
+++ b/libpldmresponder/bios.hpp
@@ -7,6 +7,7 @@
#include "bios_config.hpp"
#include "bios_table.hpp"
+#include "pldmd/dbus_impl_requester.hpp"
#include "pldmd/handler.hpp"
#include <stdint.h>
@@ -28,7 +29,13 @@
class Handler : public CmdHandler
{
public:
- Handler();
+ /** @brief Constructor
+ *
+ * @param[in] fd - socket descriptor to communicate to host
+ * @param[in] eid - MCTP EID of host firmware
+ * @param[in] requester - pointer to Requester object
+ */
+ Handler(int fd, uint8_t eid, dbus_api::Requester* requester);
/** @brief Handler for GetDateTime
*
diff --git a/libpldmresponder/bios_config.cpp b/libpldmresponder/bios_config.cpp
index e3d89a6..f79984a 100644
--- a/libpldmresponder/bios_config.cpp
+++ b/libpldmresponder/bios_config.cpp
@@ -11,6 +11,10 @@
#include <fstream>
#include <iostream>
+#ifdef OEM_IBM
+#include "oem/ibm/libpldmresponder/platform_oem_ibm.hpp"
+#endif
+
namespace pldm
{
namespace responder
@@ -34,9 +38,12 @@
} // namespace
BIOSConfig::BIOSConfig(const char* jsonDir, const char* tableDir,
- DBusHandler* const dbusHandler) :
+ DBusHandler* const dbusHandler, int fd, uint8_t eid,
+ dbus_api::Requester* requester) :
jsonDir(jsonDir),
- tableDir(tableDir), dbusHandler(dbusHandler), isUpdateProperty(false)
+ tableDir(tableDir), dbusHandler(dbusHandler), fd(fd), eid(eid),
+ requester(requester)
+
{
fs::create_directories(tableDir);
constructAttributes();
@@ -70,7 +77,8 @@
return loadTable(tablePath);
}
-int BIOSConfig::setBIOSTable(uint8_t tableType, const Table& table)
+int BIOSConfig::setBIOSTable(uint8_t tableType, const Table& table,
+ bool updateBaseBIOSTable)
{
fs::path stringTablePath(tableDir / stringTableFile);
fs::path attrTablePath(tableDir / attrTableFile);
@@ -117,16 +125,16 @@
}
storeTable(attrValueTablePath, table);
- isUpdateProperty = true;
}
else
{
return PLDM_INVALID_BIOS_TABLE_TYPE;
}
- if (isUpdateProperty)
+ if ((tableType == PLDM_BIOS_ATTR_VAL_TABLE) && updateBaseBIOSTable)
{
- isUpdateProperty = false;
+ std::cout << "setBIOSTable:: updateBaseBIOSTableProperty() "
+ << "\n";
updateBaseBIOSTableProperty();
}
@@ -633,7 +641,8 @@
};
}
-int BIOSConfig::setAttrValue(const void* entry, size_t size)
+int BIOSConfig::setAttrValue(const void* entry, size_t size,
+ bool updateBaseBIOSTable)
{
auto attrValueTable = getBIOSTable(PLDM_BIOS_ATTR_VAL_TABLE);
auto attrTable = getBIOSTable(PLDM_BIOS_ATTR_TABLE);
@@ -692,7 +701,7 @@
return PLDM_ERROR;
}
- setBIOSTable(PLDM_BIOS_ATTR_VAL_TABLE, *destTable);
+ setBIOSTable(PLDM_BIOS_ATTR_VAL_TABLE, *destTable, updateBaseBIOSTable);
return PLDM_SUCCESS;
}
@@ -814,6 +823,8 @@
void BIOSConfig::constructPendingAttribute(
const PendingAttributes& pendingAttributes)
{
+ std::vector<uint16_t> listOfHandles{};
+
for (auto& attribute : pendingAttributes)
{
std::string attributeName = attribute.first;
@@ -849,9 +860,24 @@
}
entry->attr_handle = htole16(handler);
+ listOfHandles.emplace_back(htole16(handler));
+
(*iter)->generateAttributeEntry(attributevalue, attrValueEntry);
- setAttrValue(attrValueEntry.data(), attrValueEntry.size());
+ setAttrValue(attrValueEntry.data(), attrValueEntry.size(), false);
+ }
+
+ if (listOfHandles.size())
+ {
+#ifdef OEM_IBM
+ auto rc = pldm::responder::platform::sendBiosAttributeUpdateEvent(
+ fd, eid, requester, listOfHandles);
+ if (rc != PLDM_SUCCESS)
+ {
+ return;
+ }
+#endif
+ updateBaseBIOSTableProperty();
}
}
diff --git a/libpldmresponder/bios_config.hpp b/libpldmresponder/bios_config.hpp
index b10ca78..4cfa582 100644
--- a/libpldmresponder/bios_config.hpp
+++ b/libpldmresponder/bios_config.hpp
@@ -4,6 +4,7 @@
#include "bios_attribute.hpp"
#include "bios_table.hpp"
+#include "pldmd/dbus_impl_requester.hpp"
#include <nlohmann/json.hpp>
@@ -68,16 +69,23 @@
* @param[in] jsonDir - The directory where json file exists
* @param[in] tableDir - The directory where the persistent table is placed
* @param[in] dbusHandler - Dbus Handler
+ * @param[in] fd - socket descriptor to communicate to host
+ * @param[in] eid - MCTP EID of host firmware
+ * @param[in] requester - pointer to Requester object
*/
explicit BIOSConfig(const char* jsonDir, const char* tableDir,
- DBusHandler* const dbusHandler);
+ DBusHandler* const dbusHandler, int fd, uint8_t eid,
+ dbus_api::Requester* requester);
/** @brief Set attribute value on dbus and attribute value table
* @param[in] entry - attribute value entry
* @param[in] size - size of the attribute value entry
+ * @param[in] updateBaseBIOSTable - update BaseBIOSTable D-Bus property
+ * if this is set to true
* @return pldm_completion_codes
*/
- int setAttrValue(const void* entry, size_t size);
+ int setAttrValue(const void* entry, size_t size,
+ bool updateBaseBIOSTable = true);
/** @brief Remove the persistent tables */
void removeTables();
@@ -96,17 +104,30 @@
* {BIOSStringTable=0x0, BIOSAttributeTable=0x1,
* BIOSAttributeValueTable=0x2}
* @param[in] table - table data
+ * @param[in] updateBaseBIOSTable - update BaseBIOSTable D-Bus property
+ * if this is set to true
* @return pldm_completion_codes
*/
- int setBIOSTable(uint8_t tableType, const Table& table);
+ int setBIOSTable(uint8_t tableType, const Table& table,
+ bool updateBaseBIOSTable = true);
private:
const fs::path jsonDir;
const fs::path tableDir;
DBusHandler* const dbusHandler;
- bool isUpdateProperty;
BaseBIOSTable baseBIOSTableMaps;
+ /** @brief socket descriptor to communicate to host */
+ int fd;
+
+ /** @brief MCTP EID of host firmware */
+ uint8_t eid;
+
+ /** @brief pointer to Requester object, primarily used to access API to
+ * obtain PLDM instance id.
+ */
+ dbus_api::Requester* requester;
+
// vector persists all attributes
using BIOSAttributes = std::vector<std::unique_ptr<BIOSAttribute>>;
BIOSAttributes biosAttributes;
diff --git a/libpldmresponder/meson.build b/libpldmresponder/meson.build
index 481c82b..eb86a04 100644
--- a/libpldmresponder/meson.build
+++ b/libpldmresponder/meson.build
@@ -32,7 +32,8 @@
'../oem/ibm/libpldmresponder/file_io_by_type.cpp',
'../oem/ibm/libpldmresponder/file_io_type_pel.cpp',
'../oem/ibm/libpldmresponder/file_io_type_dump.cpp',
- '../oem/ibm/libpldmresponder/file_io_type_cert.cpp'
+ '../oem/ibm/libpldmresponder/file_io_type_cert.cpp',
+ '../oem/ibm/libpldmresponder/platform_oem_ibm.cpp'
]
endif