1# VPD collection app on OpenBMC 2 3Author: Santosh Puranik <santosh.puranik@in.ibm.com> <santosh.puranik> 4 5Created: 2019-06-11 6 7## Problem Description 8On OpenBMC, Vital Product Data (VPD) collection is limited to only one or two 9Field Replaceable Units (FRUs) today - one example is the BMC FRU. 10On OpenPower systems, the BMC also supports just one VPD format, the 11[OpenPower VPD] [1] format. As a part of its enterprise class servers, IBM will 12use the IPZ format VPD, which the BMC currently does not support. 13Certain FRUs also have keyword format VPD. 14 15The BMC requires to read VPD for all FRUs for several reasons: 16 17- Some of the VPD information such as FRU part number, serial number need to be 18 included in the Platform Error Logs (PELs) for calling out FRUs for service. 19 20- Several use cases on the BMC require that the applications decide on a certain 21 code path based on what level of FRU is plugged in. For example, the 22 application that controls voltage regulators might need to set 23 different registers based on the version of the voltage regulator FRU. 24 25- There are use cases for the BMC to send VPD data to the host 26 hypervisor/operating system (over PLDM). This is mainly so that the host can 27 get VPD that is not directly accessible to it. 28 29The VPD data itself may reside on an EEPROM (typical) or may be 30synthesized out of certain parameters of the FRU (atypical - for FRUs that do 31not have an EEPROM). 32 33This design document aims to define a high level design for VPD collection and 34VPD access on OpenBMC. It does *not* cover low level API details. 35 36## Background and References 37Essentially, the IPZ VPD structure consists of key-value pairs called keywords. 38Each keyword can be used to contain specific data about the FRU. For example, 39the SN keyword will contain a serial number that can uniquely identify an 40instance of a part. Keywords themselves can be combined or grouped into records. 41For example, a single record can be used to group keywords that have similar 42function, such as serial number, part number. 43 44The keyword format VPD does not contain records, but instead has just keywords 45laid out one after another. 46 47The IPZ format is quite similar in its structure to the OpenPower format except 48for the following details: 49 50- IPZ VPD has different records and keywords. 51 52- IPZ VPD is required to implement and validate ECC as defined in the OpenPower 53 specification. The BMC code currently does not validate/use ECC although the 54 specification does define it, but will need to use the ECC for IBM's 55 enterprise class of servers. 56 57- The keyword format VPD is also something that consists of key-value pairs, but 58 has no concept of a record to group keywords together. The ECC for the keyword 59 format VPD is simply a CRC. 60 61## Requirements 62The following are requirements for the VPD function on OpenBMC: 63 64- The BMC must collect VPD for all FRUs that it has direct access to by the time 65 the BMC reaches Standby (aka the Ready state, a state from where the BMC can 66 begin CEC poweron). This is needed for several reasons: 67 68 BMC applications need to be able to read VPD for FRUs to determine, for ex., 69 the hardware level of the FRU. 70 71 Some of the VPD will need to be exchanged with the host. 72 73 Manufacturing and Service engineers need the ability to view and program 74 the FRU VPD without powering the system ON. 75 76 Certain system level VPD is also used by applications on the BMC to determine 77 the system type, model on which it is running. 78 79- If a FRU does not have a VPD store such as an EEPROM, the BMC should be able 80 to synthesize VPD for such FRUs. Details on VPD synthesis will be in its own 81 design document and are not covered here. 82 83- The BMC should be able to recollect VPD for FRUs that can be hotplugged or 84 serviced when the BMC is running. 85 86- The BMC must log errors if any of the VPD cannot be properly parsed or fails 87 ECC checks. 88 89- The BMC must create/update FRU inventory objects for all FRUs that it collects 90 VPD for. The inventory D-Bus object must contain (among other details), the 91 serial number, part number and CCIN (an IBM way of differentiating different 92 versions of a FRU) of the FRU. 93 94- Applications on the BMC need to have the ability to query any given VPD 95 keyword for a given FRU. 96 97- Applications also need to have the ability to update the VPD contents in a 98 FRU. For example, the BMC needs to have the ability to update the system VPD 99 in scenarios where the FRU containing the system VPD is repaired in the field. 100 101- There needs to be a tool/API that allows viewing and updating VPD for any 102 given FRU. This includes FRUs that the BMC does not directly collect VPD for 103 (such as FRUs that can be accessed both by the BMC and the host, but the host 104 collects VPD for) 105 106## Proposed Design 107This document covers the architectural, interface, and design details. It 108provides recommendations for implementations, but implementation details are 109outside the scope of this document. 110 111The proposal here is to build upon the existing VPD collection design used by 112open power. The current implementation consists of the following entities: 113 114- [op-vpd-parser] [2] service, which parses the contents of an EEPROM 115 containing VPD in the OpenPower VPD format. 116 117- A udev [rule] [3] that is used by systemd to launch the above service as 118 EEPROM devices are connected. 119 120- A set of config [files] [4] that describe the inventory objects and D-Bus 121 properties to update for a given FRU. 122 123In order to meet the requirements noted in the previous section, the following 124updates will be made: 125 126- Two new services will be created to handle the new VPD formats. ipz-vpd-parser 127 and a keyword-vpd-parser. These services shall be templated to allow for 128 multiple instances to be run. 129 130- Another service will be created to update the inventory with location code 131 information. Since the location code expansion comes from the system VPD, this 132 service can only be launched after the system VPD (stored on the backplane) is 133 collected. 134 135- There will be one udev rule per EEPROM on the system from which the BMC has to 136 collect VPD. We could also have just a single rule, but that would mean we 137 would have to filter out non-VPD EEPROMs somehow. 138 139- Each udev rule will be setup to launch an instance of one of the VPD parser 140 services (The format of the VPD in any given EEPROM are known at build time 141 as they are system specific) 142 143- The service (one instance of ipz-vpd-parser or keyword-vpd-parser), when 144 launched, will read the EEPROM, parse its contents and use config files 145 to determine what VPD contents to store in the inventory. 146 147- The service will update the inventory D-Bus object with the contents of the 148 VPD in the following format: There will be one interface per 149 record (ex, VINI record) which will have each keyword as a property 150 (ex, FN, PN). This will allow us to support multiple records that can have the 151 same keyword and will also serve as means to logically group keywords in the 152 inventory, quite similar to how they are grouped in the actual VPD. 153 For example (some names here are made up, but they help illustrate the point), 154 for the VINI record containing keywords SN, FN and CCIN, the representation in 155 D-Bus would look like: 156 157``` 158Interface: com.ibm.ipzvpd.VINI 159Properties: 160 SN 161 FN 162 CCIN 163``` 164 165- In case of keyword format VPD, all keywords shall be placed as properties 166 under a single interface. 167 168- The parser services will not format or transform the data in VPD in any way 169 before updating the properties noted above, the properties shall be stored as 170 byte arrays. Note, however, that the services will continue updating the 171 commonly used FRU properties such as SerialNumber, PartNumber as strings, just 172 as the openpower-vpd-parser does. 173 174- To handle VPD writes, another systemd service will be launched once all the 175 VPD read services have completed. This service shall be a daemon that will 176 manage parallel writes to EEPROMs. The VPD writer service will expose D-bus 177 interfaces to update VPD for a FRU given its inventory path. 178 179- Generation of the udev rules and configs shall be layered such that 180 they can be tweaked on a per-system basis. 181 182### Open topics 183Some open questions: 184 185- Some more thought is needed on how concurrent maintenance (replacing a FRU 186 when the host is up and running) will be handled. That will be presented in 187 its own design document. 188 189## Alternatives Considered 190The following alternative designs were considered: 191### Write a standalone VPD server app 192One option considered was to develop a standalone, do-it-all VPD application on 193the BMC that collects all of the VPD by BMC standby. The application has to be a 194daemon that will expose a set of D-bus interfaces to: 195 196- Collect/recollect all VPD. 197- Query a given FRU for its VPD. Example read the serial number of the VRM. 198- Update the VPD keyword(s) for a given FRU. 199- Concurrently maintain a FRU, which will in turn perform a remove/add/replace 200 operation. 201 202The application would be driven off of a configuration file that lists the FRUs 203available for a given system, their I2C bus address, slave address etc. 204 205This option was rejected for the following reasons: 206 207- Design would make the application very specific to a given system or a set of 208 VPD formats. Although the application could be written in a way that allows 209 plugging in support for different VPD formats, it was deemed that the current 210 approach of small applications that target a very specific requirement is 211 better. 212- The design does not leverage upon the layered design approach that the chosen 213 option allows us to do. 214 215### Build upon the entity manager 216Using the entity manager: https://github.com/openbmc/entity-manager. 217The Entity manager has an application called the FruDevice, which probes 218/dev/i2c/ for EEPROMs, reads (IPMI format) VPD and stores it on DBUS. 219 220The application could be enhanced to: 221- Add support for other VPD formats such as the IPZ and keyword format. 222- Perhaps update a different set of data into a different DBUS object, like the 223 Inventory manager. 224- Change the external DBUS interfaces that read/write FRU data to take an 225 inventory path (instead of the I2C path, address it takes in today). 226 227This option was rejected for the following reasons: 228 229- We do not need the full spectrum of functions offered by the entity manager, 230 that is we do not want to replace the existing inventory manager. Moving away 231 from the inventory manager for Power systems is outside of the scope of this 232 document. 233- The code did not appear very pluggable to add support for new VPD formats, we 234 might have to end up just utilizing #ifdef's to separate functions. 235- Does not have a way to determine system blueprint for FRU devices, scans the 236 entire /dev/ tree to pick out EEPROMs. 237 238## Impacts 239The following impacts have been identified: 240- The services to parse VPD and store it in the inventory will add some time to 241 the BMC boot flow. The impact should be kept to a minimum by achieving maximum 242 possible parallelism in the launching of these services. 243- Applications that need to read VPD keywords will be impacted in the sense that 244 they would have to use the inventory interfaces to fetch the data they are 245 interested in. 246 247## Testing 248VPD parsing function can be tested by faking out the VPD EEPROMs as files on the 249filesystem. Such testing can also ensure that the right set of VPD data makes 250its way into the OpenBMC Inventory. There is also a proposal to build in a file 251mode into the application. The file mode will not need real hardware to test the 252code functions, but can use files on the BMC to mimic the EEPROMs. 253 254VPD writes can be tested by writing a small command line utility 255that can invoke the VPD write application's APIs to write VPD. 256 257[1]:https://www-355.ibm.com/systems/power/openpower/posting.xhtml?postingId=1D060729AC96891885257E1B0053BC95 258[2]:https://github.com/openbmc/meta-openpower/blob/master/recipes-phosphor/vpd/openpower-fru-vpd/op-vpd-parser.service 259[3]:https://github.com/openbmc/meta-openpower/blob/master/recipes-phosphor/vpd/openpower-fru-vpd/70-op-vpd.rules 260[4]:https://github.com/openbmc/meta-openpower/blob/master/recipes-phosphor/vpd/openpower-fru-vpd-layout/layout.yaml 261 262