1# PLDM - Platform Level Data Model 2 3[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE) 4 5## Overview 6 7PLDM (Platform Level Data Model) is a key component of the OpenBMC project, 8providing a standardized data model and message formats for various platform 9management functionalities. It defines a method to manage, monitor, and control 10the firmware and hardware of a system. 11 12The OpenBMC PLDM project aims to implement the specifications defined by the 13Distributed Management Task Force (DMTF), allowing for interoperable management 14interfaces across different hardware and firmware components. 15 16## Features 17 18- **Standardized Messaging:** Adheres to the DMTF's PLDM specifications, 19 enabling consistent and interoperable communication between different 20 components. 21- **Modularity:** Supports multiple PLDM types, including base, FRU,Firmware 22 update, Platform Monitoring and Control, and BIOS Control and Configuration. 23- **Extensibility:** Easily extendable to support new PLDM types and custom OEM 24 commands. 25- **Integration:** Seamlessly integrates with other OpenBMC components for 26 comprehensive system management. 27 28## Getting Started 29 30### Prerequisites 31 32To build and run PLDM, you need the following dependencies: 33 34- `Meson` 35- `Ninja` 36 37Alternatively, source an OpenBMC ARM/x86 SDK. 38 39### Building 40 41To build the PLDM project, follow these steps: 42 43```bash 44meson setup build && ninja -C build 45``` 46 47### To run unit tests 48 49The simplest way of running the tests is as described by the meson man page: 50 51```bash 52meson setup builddir && meson setup test -C builddir 53``` 54 55Alternatively, tests can be run in the OpenBMC CI docker container using 56[these](https://github.com/openbmc/docs/blob/master/testing/local-ci-build.md) 57steps. 58 59### To enable pldm verbosity 60 61pldm daemon accepts a command line argument `--verbose` or `--v` or `-v` to 62enable the daemon to run in verbose mode. It can be done via adding this option 63to the environment file that pldm service consumes. 64 65```bash 66echo 'PLDMD_ARGS="--verbose"' > /etc/default/pldmd 67systemctl restart pldmd 68``` 69 70### To disable pldm verbosity 71 72```bash 73rm /etc/default/pldmd 74systemctl restart pldmd 75``` 76 77### Code Organization 78 79At a high-level, code in this repository belongs to one of the following three 80components. 81 82#### libpldmresponder 83 84This library provides handlers for incoming PLDM request messages. It provides 85for a registration as well as a plug-in mechanism. The library is implemented in 86modern C++, and handles OpenBMC's platform specifics. 87 88The handlers are of the form 89 90```c 91Response handler(Request payload, size_t payloadLen) 92``` 93 94Source files are named according to the PLDM Type, for eg base.[hpp/cpp], 95fru.[hpp/cpp], etc. 96 97#### OEM/vendor-specific functions 98 99This will support OEM or vendor-specific functions and semantic information. 100Following directory structure has to be used: 101 102```txt 103 pldm repo 104 |---- oem 105 |----<oem_name> 106 |----libpldmresponder 107 |---<oem based handler files> 108 109``` 110 111<oem_name> - This folder must be created with the name of the OEM/vendor in 112lower case. Folders named libpldm and libpldmresponder must be created under the 113folder <oem_name> 114 115Files having the oem functionality for the libpldmresponder library should be 116placed under the folder oem/<oem_name>/libpldmresponder. They must be adhering 117to the rules mentioned under the libpldmresponder section above. 118 119Once the above is done a meson option has to be created in 120`pldm/meson_options.txt` with its mapped compiler flag to enable conditional 121compilation. 122 123For consistency would recommend using "oem-<oem_name>". 124 125The `pldm/meson.build` and the corresponding source file(s) will need to 126incorporate the logic of adding its mapped compiler flag to allow conditional 127compilation of the code. 128 129##### libpldm 130 131pldm daemon links against the libpldm library during compilation, For more 132information on libpldm please refer to 133[libpldm](https://github.com/openbmc/libpldm) 134 135##### pldmtool 136 137For more information on pldmtool please refer to plmdtool/README.md. 138 139##### Flows 140 141This section documents important code flow paths. 142 143###### BMC as PLDM responder 144 145a) PLDM daemon receives PLDM request message from underlying transport (MCTP). 146 147b) PLDM daemon routes message to message handler, based on the PLDM command. 148 149c) Message handler decodes request payload into various field(s) of the request 150message. It can make use of a decode_foo_req() API, and doesn't have to perform 151deserialization of the request payload by itself. 152 153d) Message handler works with the request field(s) and generates response 154field(s). 155 156e) Message handler prepares a response message. It can make use of an 157encode_foo_resp() API, and doesn't have to perform the serialization of the 158response field(s) by itself. 159 160f) The PLDM daemon sends the response message prepared at step e) to the remote 161PLDM device. 162 163##### BMC as PLDM requester 164 165a) A BMC PLDM requester app prepares a PLDM request message. There would be 166several requester apps (based on functionality/PLDM remote device). Each of them 167needn't bother with the serialization of request field(s), and can instead make 168use of an encode_foo_req() API. 169 170b) BMC requester app requests PLDM daemon to send the request message to remote 171PLDM device. 172 173c) Once the PLDM daemon receives a corresponding response message, it notifies 174the requester app. 175 176d) The requester app has to work with the response field(s). It can make use of 177a decode_foo_resp() API to deserialize the response message. 178 179###### PDR Implementation 180 181While PLDM Platform Descriptor Records (PDRs) are mostly static information, 182they can vary across platforms and systems. For this reason, platform specific 183PDR information is encoded in platform specific JSON files. JSON files must be 184named based on the PDR type number. For example a state effecter PDR JSON file 185will be named 11.json. The JSON files may also include information to enable 186additional processing (apart from PDR creation) for specific PDR types, for eg 187mapping an effecter id to a D-Bus object. 188 189The PLDM responder implementation finds and parses PDR JSON files to create the 190PDR repository. Platform specific PDR modifications would likely just result in 191JSON updates. New PDR type support would require JSON updates as well as PDR 192generation code. The PDR generator is a map of PDR Type -> C++ lambda to create 193PDR entries for that type based on the JSON, and to update the central PDR repo. 194 195###### BIOS Support 196 197Redfish supports the BIOS Attribute Registry, which provides users with a list 198of BIOS attributes supported in the BIOS configuration. To incorporate BIOS 199attribute registry support in openBMC, BmcWeb is designed to read data from the 200Base BIOS Table. PLDM populates the Base BIOS Table for the BIOS Config Manager 201based on BIOS JSON files. BIOS functionality is integrated into PLDM according 202to the guidelines in the 203[PLDM BIOS Specification](https://www.dmtf.org/sites/default/files/standards/documents/DSP0247_1.0.0.pdf). 204BIOS attributes, also referred to as BIOS parameters or configuration settings, 205are structured within JSON files. Each attribute is defined by its name, type, 206and type-specific metadata. PLDM parses 207[BIOS JSON file](https://github.com/openbmc/pldm/tree/master/oem/ibm/configurations/bios/com.ibm.Hardware.Chassis.Model.Rainier2U) 208and creates the 209[Base BIOS Table](https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/BIOSConfig/Manager.interface.yaml#L62) 210hosted by [BIOS Config Manager](https://github.com/openbmc/bios-settings-mgr). 211The design is documented in 212[DesignDoc](https://github.com/openbmc/docs/blob/master/designs/remote-bios-configuration.md). 213Redfish supports 214[BIOS Attribute registry](https://redfish.dmtf.org/schemas/v1/AttributeRegistry.v1_3_8.json), 215which provides users with the list of BIOS attributes supported in the BIOS 216configuration. The BIOS Attribute registry data is supposed to be derived from 217[Base BIOS Table](https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/BIOSConfig/Manager.interface.yaml#L62). 218PLDM populates the Base BIOS Table for BIOS Config Manager based on BIOS Json 219files. 220 221After the JSON files are parsed, pldm would also create the string table, 222attribute table, and attribute value table as per Section7 in 223[PLDM BIOS Specification](https://www.dmtf.org/sites/default/files/standards/documents/DSP0247_1.0.0.pdf). 224Those BIOS tables are exchanged with remote PLDM terminus using the 225`GetBiosTable` command as defined in DSP0247_1.0.0.pdf Section 8.1. All the 226`bios attribute json files are kept under OEM` 227[Path](https://github.com/openbmc/pldm/tree/master/oem). BIOS json configuration 228is provided in bios_attr.json file which contains attributes of type enum, 229integer and string. 230 231Integer Attribute details as documented at Table9 of 232[PLDM BIOS Specification](https://www.dmtf.org/sites/default/files/standards/documents/DSP0247_1.0.0.pdf): 233 234```json 235{ 236 "entries": [ 237 { 238 "attribute_type": "integer", 239 "attribute_name": "Attribute Name", 240 "lower_bound": "The lower bound on the integer value", 241 "upper_bound": "The upper bound on the integer value", 242 "scalar_increment": "The scalar value that is used for the increments to this integer ", 243 "default_value": "The default value of the integer", 244 "help_text": "Help text about attribute usage", 245 "display_name": "Attribute Display Name", 246 "read_only": "Read only Attribute" 247 } 248 ] 249} 250``` 251 252Enum Attribute details as documented at Table6 of 253[PLDM BIOS Specification](https://www.dmtf.org/sites/default/files/standards/documents/DSP0247_1.0.0.pdf): 254 255```json 256{ 257 "entries": [ 258 { 259 "attribute_type": "enum", 260 "attribute_name": "Attribute Name", 261 "possible_values": [ 262 "An array of character strings of variable to indicate the possible values of the BIOS attribute" 263 ], 264 "default_values": "Default value", 265 "help_text": "Help text about attribute usage", 266 "display_name": "Display Name", 267 "read_only": "Read only Attribute" 268 } 269 ] 270} 271``` 272 273String Attribute details as documented at Table7 of 274[PLDM BIOS Specification](https://www.dmtf.org/sites/default/files/standards/documents/DSP0247_1.0.0.pdf): 275 276```json 277{ 278 "entries": [ 279 { 280 "attribute_type": "string", 281 "attribute_name": "Attribute Name", 282 "string_type": "It specifies the character encoding format, which can be ASCII, Hex, UTF-8, UTF-16LE, or UTF-16BE. Currently, only ASCII is supported", 283 "minimum_string_length": "The minimum length of the string in bytes", 284 "maximum_string_length": "The maximum length of the string in bytes", 285 "default_string": "The default string itself", 286 "help_text": "Help text about attribute usage", 287 "display_name": "Attribute Display Name", 288 "read_only": "Read only Attribute" 289 } 290 ] 291} 292``` 293 294As PLDM BIOS Attributes may differ across platforms and systems, supporting 295system-specific BIOS attributes is crucial. To achieve this, BIOS JSON files are 296organized under folders named after the system type. System type information is 297retrieved from the Entity Manager service, which hosts the 298[Compatible Interface](https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/Inventory/Decorator/Compatible.interface.yaml). 299 300This interface dynamically populates the Names property with system type 301information. However, determining the system type in the application space may 302take some time since the compatible interface and the Names property are 303dynamically created by the Entity Manager. Consequently, BIOS tables are lazily 304constructed upon receiving the system type. 305 306To enable system-specific BIOS attribute support within PLDM, the meson option 307`system-specific-bios-json` can be utilized. With `system-specific-bios-json` 308option `enabled` BIOS JSON files specific to the system type are fetched during 309runtime. 310