libpldmresponder: enable DBus change notification
This commit enables libpldmresponder to subscribe to DBus
property change signal for the BIOS properties which are fetched from
DBus. The new DBus value is received and the relevant entry in the
attributeValueTable is updated.
test result:
root@rainier:/tmp# pldmtool bios GetBIOSTable -t 0
Parsed Response Msg:
PLDM StringTable:
BIOSStringHandle : BIOSString
0 : Allowed
1 : Disabled
2 : Enabled
3 : IPv4DHCP
4 : IPv4Static
5 : Not Allowed
6 : Perm
7 : Temp
8 : pvm-fw-boot-side
9 : pvm-inband-code-update
10 : pvm-os-boot-side
11 : pvm-pcie-error-inject
12 : pvm-surveillance
13 : pvm-system-name
14 : vmi-hostname
15 : vmi-if-count
16 : vmi-if0-ipv4-ipaddr
17 : vmi-if0-ipv4-method
18 : vmi-if0-ipv4-prefix-length
19 : vmi-if1-ipv4-ipaddr
20 : vmi-if1-ipv4-method
21 : vmi-if1-ipv4-prefix-length
22 : vmi-ipv4-gateway
root@rainier:/tmp#
root@rainier:/tmp# pldmtool bios GetBIOSTable -t 1
Parsed Response Msg:
PLDM AttributeTable:
AttributeHandle: 0, AttributeNameHandle: 13(pvm-system-name)
AttributeType: BIOSStringReadOnly
StringType: 0x01
MinimumStringLength: 1
MaximumStringLength: 100
DefaultStringLength: 15
DefaultString: witherspoon-128
AttributeHandle: 1, AttributeNameHandle: 14(vmi-hostname)
AttributeType: BIOSString
StringType: 0x01
MinimumStringLength: 0
MaximumStringLength: 255
DefaultStringLength: 0
DefaultString:
AttributeHandle: 2, AttributeNameHandle: 22(vmi-ipv4-gateway)
AttributeType: BIOSString
StringType: 0x01
MinimumStringLength: 7
MaximumStringLength: 15
DefaultStringLength: 7
DefaultString: 0.0.0.0
AttributeHandle: 3, AttributeNameHandle: 16(vmi-if0-ipv4-ipaddr)
AttributeType: BIOSString
StringType: 0x01
MinimumStringLength: 7
MaximumStringLength: 15
DefaultStringLength: 7
DefaultString: 0.0.0.0
AttributeHandle: 4, AttributeNameHandle: 19(vmi-if1-ipv4-ipaddr)
AttributeType: BIOSString
StringType: 0x01
MinimumStringLength: 7
MaximumStringLength: 15
DefaultStringLength: 7
DefaultString: 0.0.0.0
AttributeHandle: 5, AttributeNameHandle: 15(vmi-if-count)
AttributeType: BIOSIntegerReadOnly
LowerBound: 0
UpperBound: 2
ScalarIncrement: 1
DefaultValue: 1
AttributeHandle: 6, AttributeNameHandle: 18(vmi-if0-ipv4-prefix-length)
AttributeType: BIOSInteger
LowerBound: 0
UpperBound: 32
ScalarIncrement: 1
DefaultValue: 0
AttributeHandle: 7, AttributeNameHandle: 21(vmi-if1-ipv4-prefix-length)
AttributeType: BIOSInteger
LowerBound: 0
UpperBound: 32
ScalarIncrement: 1
DefaultValue: 0
AttributeHandle: 8, AttributeNameHandle: 8(pvm-fw-boot-side)
AttributeType: BIOSEnumerationReadOnly
NumberOfPossibleValues: 2
PossibleValueStringHandle[0] = 6(Perm)
PossibleValueStringHandle[1] = 7(Temp)
NumberOfDefaultValues: 1
DefaultValueStringHandleIndex[0] = 0, StringHandle = 6(Perm)
AttributeHandle: 9, AttributeNameHandle: 10(pvm-os-boot-side)
AttributeType: BIOSEnumerationReadOnly
NumberOfPossibleValues: 2
PossibleValueStringHandle[0] = 6(Perm)
PossibleValueStringHandle[1] = 7(Temp)
NumberOfDefaultValues: 1
DefaultValueStringHandleIndex[0] = 0, StringHandle = 6(Perm)
AttributeHandle: 10, AttributeNameHandle: 9(pvm-inband-code-update)
AttributeType: BIOSEnumerationReadOnly
NumberOfPossibleValues: 2
PossibleValueStringHandle[0] = 0(Allowed)
PossibleValueStringHandle[1] = 5(Not Allowed)
NumberOfDefaultValues: 1
DefaultValueStringHandleIndex[0] = 0, StringHandle = 0(Allowed)
AttributeHandle: 11, AttributeNameHandle: 12(pvm-surveillance)
AttributeType: BIOSEnumerationReadOnly
NumberOfPossibleValues: 2
PossibleValueStringHandle[0] = 1(Disabled)
PossibleValueStringHandle[1] = 2(Enabled)
NumberOfDefaultValues: 1
DefaultValueStringHandleIndex[0] = 1, StringHandle = 2(Enabled)
AttributeHandle: 12, AttributeNameHandle: 11(pvm-pcie-error-inject)
AttributeType: BIOSEnumerationReadOnly
NumberOfPossibleValues: 2
PossibleValueStringHandle[0] = 1(Disabled)
PossibleValueStringHandle[1] = 2(Enabled)
NumberOfDefaultValues: 1
DefaultValueStringHandleIndex[0] = 1, StringHandle = 2(Enabled)
AttributeHandle: 13, AttributeNameHandle: 17(vmi-if0-ipv4-method)
AttributeType: BIOSEnumeration
NumberOfPossibleValues: 2
PossibleValueStringHandle[0] = 4(IPv4Static)
PossibleValueStringHandle[1] = 3(IPv4DHCP)
NumberOfDefaultValues: 1
DefaultValueStringHandleIndex[0] = 0, StringHandle = 4(IPv4Static)
AttributeHandle: 14, AttributeNameHandle: 20(vmi-if1-ipv4-method)
AttributeType: BIOSEnumeration
NumberOfPossibleValues: 2
PossibleValueStringHandle[0] = 4(IPv4Static)
PossibleValueStringHandle[1] = 3(IPv4DHCP)
NumberOfDefaultValues: 1
DefaultValueStringHandleIndex[0] = 0, StringHandle = 4(IPv4Static)
root@rainier:/tmp#
root@rainier:/tmp# pldmtool bios GetBIOSTable -t 2
Parsed Response Msg:
PLDM AttributeValueTable:
AttributeHandle: 0
AttributeType: BIOSStringReadOnly
CurrentStringLength: 15
CurrentString: witherspoon-128
AttributeHandle: 1
AttributeType: BIOSString
CurrentStringLength: 0
CurrentString:
AttributeHandle: 2
AttributeType: BIOSString
CurrentStringLength: 7
CurrentString: 0.0.0.0
AttributeHandle: 3
AttributeType: BIOSString
CurrentStringLength: 7
CurrentString: 0.0.0.0
AttributeHandle: 4
AttributeType: BIOSString
CurrentStringLength: 7
CurrentString: 0.0.0.0
AttributeHandle: 5
AttributeType: BIOSIntegerReadOnly
CurrentValue: 1
AttributeHandle: 6
AttributeType: BIOSInteger
CurrentValue: 0
AttributeHandle: 7
AttributeType: BIOSInteger
CurrentValue: 0
AttributeHandle: 8
AttributeType: BIOSEnumerationReadOnly
NumberOfCurrentValues: 1
CurrentValueStringHandleIndex[0] = 0, StringHandle = 6(Perm)
AttributeHandle: 9
AttributeType: BIOSEnumerationReadOnly
NumberOfCurrentValues: 1
CurrentValueStringHandleIndex[0] = 0, StringHandle = 6(Perm)
AttributeHandle: 10
AttributeType: BIOSEnumerationReadOnly
NumberOfCurrentValues: 1
CurrentValueStringHandleIndex[0] = 0, StringHandle = 0(Allowed)
AttributeHandle: 11
AttributeType: BIOSEnumerationReadOnly
NumberOfCurrentValues: 1
CurrentValueStringHandleIndex[0] = 1, StringHandle = 2(Enabled)
AttributeHandle: 12
AttributeType: BIOSEnumerationReadOnly
NumberOfCurrentValues: 1
CurrentValueStringHandleIndex[0] = 1, StringHandle = 2(Enabled)
AttributeHandle: 13
AttributeType: BIOSEnumeration
NumberOfCurrentValues: 1
CurrentValueStringHandleIndex[0] = 0, StringHandle = 4(IPv4Static)
AttributeHandle: 14
AttributeType: BIOSEnumeration
NumberOfCurrentValues: 1
CurrentValueStringHandleIndex[0] = 0, StringHandle = 4(IPv4Static)
root@rainier:/tmp#
root@rainier:/tmp# busctl get-property xyz.openbmc_project.Settings
/xyz/openbmc_project/network/vmi/intf1/ipv4/addr0 xyz.openbmc_project.Network.IP
PrefixLength
y 0
root@rainier:/tmp# busctl set-property xyz.openbmc_project.Settings
/xyz/openbmc_project/network/vmi/intf1/ipv4/addr0 xyz.openbmc_project.Network.IP
PrefixLength y 6
root@rainier:/tmp# busctl get-property xyz.openbmc_project.Settings
/xyz/openbmc_project/network/vmi/intf1/ipv4/addr0 xyz.openbmc_project.Network.IP
Origin
s "xyz.openbmc_project.Network.IP.AddressOrigin.Static"
root@rainier:/tmp# busctl set-property xyz.openbmc_project.Settings
/xyz/openbmc_project/network/vmi/intf1/ipv4/addr0 xyz.openbmc_project.Network.IP
Origin s "xyz.openbmc_project.Network.IP.AddressOrigin.DHCP"
root@rainier:/tmp# busctl get-property xyz.openbmc_project.Settings
/xyz/openbmc_project/network/vmi/intf1/ipv4/addr0 xyz.openbmc_project.Network.IP
Address
s "0.0.0.0"
root@rainier:/tmp# busctl set-property xyz.openbmc_project.Settings
/xyz/openbmc_project/network/vmi/intf1/ipv4/addr0 xyz.openbmc_project.Network.IP
Address s "1.2.3.4"
root@rainier:/tmp# pldmtool bios GetBIOSTable -t 2
Parsed Response Msg:
PLDM AttributeValueTable:
AttributeHandle: 0
AttributeType: BIOSStringReadOnly
CurrentStringLength: 15
CurrentString: witherspoon-128
AttributeHandle: 1
AttributeType: BIOSString
CurrentStringLength: 0
CurrentString:
AttributeHandle: 2
AttributeType: BIOSString
CurrentStringLength: 7
CurrentString: 0.0.0.0
AttributeHandle: 3
AttributeType: BIOSString
CurrentStringLength: 7
CurrentString: 0.0.0.0
AttributeHandle: 4
AttributeType: BIOSString
CurrentStringLength: 7
CurrentString: 1.2.3.4
AttributeHandle: 5
AttributeType: BIOSIntegerReadOnly
CurrentValue: 1
AttributeHandle: 6
AttributeType: BIOSInteger
CurrentValue: 0
AttributeHandle: 7
AttributeType: BIOSInteger
CurrentValue: 6
AttributeHandle: 8
AttributeType: BIOSEnumerationReadOnly
NumberOfCurrentValues: 1
CurrentValueStringHandleIndex[0] = 0, StringHandle = 6(Perm)
AttributeHandle: 9
AttributeType: BIOSEnumerationReadOnly
NumberOfCurrentValues: 1
CurrentValueStringHandleIndex[0] = 0, StringHandle = 6(Perm)
AttributeHandle: 10
AttributeType: BIOSEnumerationReadOnly
NumberOfCurrentValues: 1
CurrentValueStringHandleIndex[0] = 0, StringHandle = 0(Allowed)
AttributeHandle: 11
AttributeType: BIOSEnumerationReadOnly
NumberOfCurrentValues: 1
CurrentValueStringHandleIndex[0] = 1, StringHandle = 2(Enabled)
AttributeHandle: 12
AttributeType: BIOSEnumerationReadOnly
NumberOfCurrentValues: 1
CurrentValueStringHandleIndex[0] = 1, StringHandle = 2(Enabled)
AttributeHandle: 13
AttributeType: BIOSEnumeration
NumberOfCurrentValues: 1
CurrentValueStringHandleIndex[0] = 0, StringHandle = 4(IPv4Static)
AttributeHandle: 14
AttributeType: BIOSEnumeration
NumberOfCurrentValues: 1
CurrentValueStringHandleIndex[0] = 1, StringHandle = 3(IPv4DHCP)
Change-Id: I60e8f916a82bda0ef27c8c482fafb755b65210b4
Signed-off-by: Sampa Misra <sampmisr@in.ibm.com>
diff --git a/libpldmresponder/bios_config.cpp b/libpldmresponder/bios_config.cpp
index e742ee6..ade09b2 100644
--- a/libpldmresponder/bios_config.cpp
+++ b/libpldmresponder/bios_config.cpp
@@ -3,6 +3,7 @@
#include "bios_enum_attribute.hpp"
#include "bios_integer_attribute.hpp"
#include "bios_string_attribute.hpp"
+#include "bios_table.hpp"
#include <fstream>
#include <iostream>
@@ -263,6 +264,83 @@
}
}
+void BIOSConfig::processBiosAttrChangeNotification(
+ const DbusChObjProperties& chProperties, uint32_t biosAttrIndex)
+{
+ const auto& dBusMap = biosAttributes[biosAttrIndex]->getDBusMap();
+ const auto& propertyName = dBusMap->propertyName;
+ const auto& attrName = biosAttributes[biosAttrIndex]->name;
+
+ const auto it = chProperties.find(propertyName);
+ if (it == chProperties.end())
+ {
+ return;
+ }
+
+ PropertyValue newPropVal = it->second;
+ auto stringTable = getBIOSTable(PLDM_BIOS_STRING_TABLE);
+ if (!stringTable.has_value())
+ {
+ std::cerr << "BIOS string table unavailable\n";
+ return;
+ }
+ BIOSStringTable biosStringTable(*stringTable);
+ uint16_t attrNameHdl{};
+ try
+ {
+ attrNameHdl = biosStringTable.findHandle(attrName);
+ }
+ catch (std::invalid_argument& e)
+ {
+ std::cerr << "Could not find handle for BIOS string, ATTRIBUTE="
+ << attrName.c_str() << "\n";
+ return;
+ }
+
+ auto attrTable = getBIOSTable(PLDM_BIOS_ATTR_TABLE);
+ if (!attrTable.has_value())
+ {
+ std::cerr << "Attribute table not present\n";
+ return;
+ }
+ const struct pldm_bios_attr_table_entry* tableEntry =
+ table::attribute::findByStringHandle(*attrTable, attrNameHdl);
+ if (tableEntry == nullptr)
+ {
+ std::cerr << "Attribute not found in attribute table, name= "
+ << attrName.c_str() << "name handle=" << attrNameHdl << "\n";
+ return;
+ }
+
+ auto [attrHdl, attrType, stringHdl] =
+ table::attribute::decodeHeader(tableEntry);
+
+ auto attrValueSrcTable = getBIOSTable(PLDM_BIOS_ATTR_VAL_TABLE);
+
+ if (!attrValueSrcTable.has_value())
+ {
+ std::cerr << "Attribute value table not present\n";
+ return;
+ }
+
+ Table newValue;
+ auto rc = biosAttributes[biosAttrIndex]->updateAttrVal(
+ newValue, attrHdl, attrType, newPropVal);
+ if (rc != PLDM_SUCCESS)
+ {
+ std::cerr << "Could not update the attribute value table for attribute "
+ "handle="
+ << attrHdl << " and type=" << (uint32_t)attrType << "\n";
+ return;
+ }
+ auto destTable = table::attribute_value::updateTable(
+ *attrValueSrcTable, newValue.data(), newValue.size());
+ if (destTable.has_value())
+ {
+ storeTable(tableDir / attrValueTableFile, *destTable);
+ }
+}
+
} // namespace bios
} // namespace responder
} // namespace pldm