| commit | 46ece0630b0cabce894413a5f9502d02f73f3a33 | [log] [tgz] |
|---|---|---|
| author | Sampa Misra <sampmisr@in.ibm.com> | Wed Mar 18 07:17:44 2020 -0500 |
| committer | Deepak Kodihalli <dkodihal@in.ibm.com> | Thu Apr 02 05:24:32 2020 -0500 |
| tree | e17f64d2898e34259b1bd67eb797f3d6d3ec756f | |
| parent | 45fed20ff763371738f1e61d4966b8b069918820 [diff] |
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>
Need meson and ninja. Alternatively, source an OpenBMC ARM/x86 SDK.
meson build && ninja -C build
Tests can be run in the CI docker container, or with an OpenBMC x86 sdk(see below for x86 steps).
meson -Doe-sdk=enabled -Dtests=enabled build ninja -C build test
At a high-level, code in this repository belongs to one of the following three components.
This is a library which deals with the encoding and decoding of PLDM messages. It should be possible to use this library by projects other than OpenBMC, and hence certain constraints apply to it:
Source files are named according to the PLDM Type, for eg base.[h/c], fru.[h/c], etc.
Given a PLDM command "foo", the library will provide the following API: For the Requester function:
encode_foo_req() - encode a foo request decode_foo_resp() - decode a response to foo
For the Responder function:
decode_foo_req() - decode a foo request encode_foo_resp() - encode a response to foo
The library also provides API to pack and unpack PLDM headers.
This library provides handlers for incoming PLDM request messages. It provides for a registration as well as a plug-in mechanism. The library is implemented in modern C++, and handles OpenBMC's platform specifics.
The handlers are of the form
Response handler(Request payload, size_t payloadLen)
Source files are named according to the PLDM Type, for eg base.[hpp/cpp], fru.[hpp/cpp], etc.
This will support OEM or vendor-specific functions and semantic information. Following directory structure has to be used:
pldm repo
|---- oem
|----<oem_name>
|----libpldm
|----<oem based encoding and decoding files>
|----libpldmresponder
|---<oem based handler files>
<oem_name> - This folder must be created with the name of the OEM/vendor in lower case. Folders named libpldm and libpldmresponder must be created under the folder <oem_name>
Files having the oem functionality for the libpldm library should be placed under the folder oem/<oem_name>/libpldm. They must be adhering to the rules mentioned under the libpldm section above.
Files having the oem functionality for the libpldmresponder library should be placed under the folder oem/<oem_name>/libpldmresponder. They must be adhering to the rules mentioned under the libpldmresponder section above.
Once the above is done a conditional flag has to be created in the configure.ac to enable conditional compilation.
For consistency would recommend using "--enable-oem-<oem_name>".
The Makefile.am files in libpldm and libpldmresponder will need to be changed to allow conditional compilation of the code.
Consider hosting libpldm above in a repo of its own, probably even outside the OpenBMC project? A separate repo would enable something like git submodule.
This section documents important code flow paths.
a) PLDM daemon receives PLDM request message from underlying transport (MCTP).
b) PLDM daemon routes message to message handler, based on the PLDM command.
c) Message handler decodes request payload into various field(s) of the request message. It can make use of a decode_foo_req() API, and doesn't have to perform deserialization of the request payload by itself.
d) Message handler works with the request field(s) and generates response field(s).
e) Message handler prepares a response message. It can make use of an encode_foo_resp() API, and doesn't have to perform the serialization of the response field(s) by itself.
f) The PLDM daemon sends the response message prepared at step e) to the remote PLDM device.
a) A BMC PLDM requester app prepares a PLDM request message. There would be several requester apps (based on functionality/PLDM remote device). Each of them needn't bother with the serialization of request field(s), and can instead make use of an encode_foo_req() API.
b) BMC requester app requests PLDM daemon to send the request message to remote PLDM device.
c) Once the PLDM daemon receives a corresponding response message, it notifies the requester app.
d) The requester app has to work with the response field(s). It can make use of a decode_foo_resp() API to deserialize the response message.
While PLDM Platform Descriptor Records (PDRs) are mostly static information, they can vary across platforms and systems. For this reason, platform specific PDR information is encoded in platform specific JSON files. JSON files must be named based on the PDR type number. For example a state effecter PDR JSON file will be named 11.json. The JSON files may also include information to enable additional processing (apart from PDR creation) for specific PDR types, for eg mapping an effecter id to a D-Bus object.
The PLDM responder implementation finds and parses PDR JSON files to create the PDR repository. Platform specific PDR modifications would likely just result in JSON updates. New PDR type support would require JSON updates as well as PDR generation code. The PDR generator is a map of PDR Type -> C++ lambda to create PDR entries for that type based on the JSON, and to update the central PDR repo.