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