commit | a6a8ccd9486caf14b16320e20bc514bcda715721 | [log] [tgz] |
---|---|---|
author | Sagar Srinivas <sagar.srinivas@ibm.com> | Thu Apr 01 07:58:33 2021 -0500 |
committer | sagar srinivas <sagar.srinivas@ibm.com> | Wed Sep 22 08:48:59 2021 +0000 |
tree | dc179a307e6e21093b0981ecc7dd7c56f62fe6f0 | |
parent | 2746fb48d197b25942889eca4b802000a746396d [diff] |
PLDM: implement surveillance between Host and bmc This commit is to implement surveillance between host and bmc, wherein host monitors if bmc is up and running through constant pings(by sending Platform EventMessages) sent from host to BMC. And if BMC fails to respond to the pings, then BMC will be reset using the KCS interface. 1. Host->BMC - GetTID 2. BMC->Host - Respond to GetTID, SetEventReceiver 3. Host->BMC - Respond to SetEventReceiver 4. BMC->Host - Send PlatformEventMessage after the elapsed time interval(specified with SetEventReceiver command) 4. Host->BMC - If BMC fails to send respond to host within specified interval, Host resets BMC via the KCS interface Tested with PLDMTOOL: SetEventReceiver command: root@rain127bmc:/tmp# ./pldmtool base GetTID -m 8 Received Msg 08 01 81 00 02 Sending Msg 01 00 02 00 01 { "Response": 1 } platformEventMessage command(which will be received by host): root@rain118bmc:/tmp# ./pldmtool raw -d 0x80 0x02 0x0A 0x01 0x01 0x06 0x01 0x01 Request Message: 08 01 80 02 0a 01 01 06 01 01 Received Msg 08 01 80 02 0a 01 01 06 01 01 eventClass Checking Sending Msg 00 02 0a 00 00 Response Message: 08 01 00 02 0a 00 00 Received Msg 08 01 00 02 0a 00 00 Signed-off-by: Sagar Srinivas <sagar.srinivas@ibm.com> Change-Id: Iac90b2233a873a54504ffa649d324d30525b7ce3
Need meson
and ninja
. Alternatively, source an OpenBMC ARM/x86 SDK.
meson build && ninja -C build
The simplest way of running the tests is as described by the meson man page:
meson builddir && meson test -C builddir
Alternatively, tests can be run in the OpenBMC CI docker container, or with an OpenBMC x86 sdk(see below for x86 steps).
meson -Doe-sdk=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 meson option has to be created in pldm/meson_options.txt
with its mapped compiler flag to enable conditional compilation.
For consistency would recommend using "oem-<oem_name>".
The pldm/meson.build
and the corresponding source file(s) will need to incorporate the logic of adding its mapped compiler flag to allow conditional compilation of the code.
For more information on pldmtool please refer to plmdtool/README.md.
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.