xref: /openbmc/docs/designs/vpd-collection.md (revision 5873e0b9)
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
8
9On OpenBMC, Vital Product Data (VPD) collection is limited to only one or two
10Field Replaceable Units (FRUs) today - one example is the BMC FRU. On OpenPower
11systems, the BMC also supports just one VPD format, the [OpenPower VPD] [1] format.
12As a part of its enterprise class servers, IBM will use the IPZ format VPD, which
13the BMC currently does not support. Certain 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 different
23  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 synthesized out
30of certain parameters of the FRU (atypical - for FRUs that do not have an
31EEPROM).
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
37
38Essentially, the IPZ VPD structure consists of key-value pairs called keywords.
39Each keyword can be used to contain specific data about the FRU. For example,
40the SN keyword will contain a serial number that can uniquely identify an
41instance of a part. Keywords themselves can be combined or grouped into records.
42For example, a single record can be used to group keywords that have similar
43function, such as serial number, part number.
44
45The keyword format VPD does not contain records, but instead has just keywords
46laid out one after another.
47
48The IPZ format is quite similar in its structure to the OpenPower format except
49for the following details:
50
51- IPZ VPD has different records and keywords.
52
53- IPZ VPD is required to implement and validate ECC as defined in the OpenPower
54  specification. The BMC code currently does not validate/use ECC although the
55  specification does define it, but will need to use the ECC for IBM's
56  enterprise class of servers.
57
58- The keyword format VPD is also something that consists of key-value pairs, but
59  has no concept of a record to group keywords together. The ECC for the keyword
60  format VPD is simply a CRC.
61
62## Requirements
63
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 the
76  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
109
110This document covers the architectural, interface, and design details. It
111provides recommendations for implementations, but implementation details are
112outside the scope of this document.
113
114The proposal here is to build upon the existing VPD collection design used by
115open power. The current implementation consists of the following entities:
116
117- [op-vpd-parser] [2] service, which parses the contents of an EEPROM containing
118  VPD in the OpenPower VPD format.
119
120- A udev [rule] [3] that is used by systemd to launch the above service as
121  EEPROM devices are connected.
122
123- A set of config [files] [4] that describe the inventory objects and D-Bus
124  properties to update for a given FRU.
125
126In order to meet the requirements noted in the previous section, the following
127updates will be made:
128
129- Two new services will be created to handle the new VPD formats. ipz-vpd-parser
130  and a keyword-vpd-parser. These services shall be templated to allow for
131  multiple instances to be run.
132
133- Another service will be created to update the inventory with location code
134  information. Since the location code expansion comes from the system VPD, this
135  service can only be launched after the system VPD (stored on the backplane) is
136  collected.
137
138- There will be one udev rule per EEPROM on the system from which the BMC has to
139  collect VPD. We could also have just a single rule, but that would mean we
140  would have to filter out non-VPD EEPROMs somehow.
141
142- Each udev rule will be setup to launch an instance of one of the VPD parser
143  services (The format of the VPD in any given EEPROM are known at build time as
144  they are system specific)
145
146- The service (one instance of ipz-vpd-parser or keyword-vpd-parser), when
147  launched, will read the EEPROM, parse its contents and use config files to
148  determine what VPD contents to store in the inventory.
149
150- The service will update the inventory D-Bus object with the contents of the
151  VPD in the following format: There will be one interface per record (ex, VINI
152  record) which will have each keyword as a property (ex, FN, PN). This will
153  allow us to support multiple records that can have the same keyword and will
154  also serve as means to logically group keywords in the inventory, quite
155  similar to how they are grouped in the actual VPD. For example (some names
156  here are made up, but they help illustrate the point), for the VINI record
157  containing keywords SN, FN and CCIN, the representation in D-Bus would look
158  like:
159
160```
161Interface: com.ibm.ipzvpd.VINI
162Properties:
163    SN
164    FN
165    CCIN
166```
167
168- In case of keyword format VPD, all keywords shall be placed as properties
169  under a single interface.
170
171- The parser services will not format or transform the data in VPD in any way
172  before updating the properties noted above, the properties shall be stored as
173  byte arrays. Note, however, that the services will continue updating the
174  commonly used FRU properties such as SerialNumber, PartNumber as strings, just
175  as the openpower-vpd-parser does.
176
177- To handle VPD writes, another systemd service will be launched once all the
178  VPD read services have completed. This service shall be a daemon that will
179  manage parallel writes to EEPROMs. The VPD writer service will expose D-bus
180  interfaces to update VPD for a FRU given its inventory path.
181
182- Generation of the udev rules and configs shall be layered such that they can
183  be tweaked on a per-system basis.
184
185### Open topics
186
187Some open questions:
188
189- Some more thought is needed on how concurrent maintenance (replacing a FRU
190  when the host is up and running) will be handled. That will be presented in
191  its own design document.
192
193## Alternatives Considered
194
195The following alternative designs were considered:
196
197### Write a standalone VPD server app
198
199One option considered was to develop a standalone, do-it-all VPD application on
200the BMC that collects all of the VPD by BMC standby. The application has to be a
201daemon that will expose a set of D-bus interfaces to:
202
203- Collect/recollect all VPD.
204- Query a given FRU for its VPD. Example read the serial number of the VRM.
205- Update the VPD keyword(s) for a given FRU.
206- Concurrently maintain a FRU, which will in turn perform a remove/add/replace
207  operation.
208
209The application would be driven off of a configuration file that lists the FRUs
210available for a given system, their I2C bus address, slave address etc.
211
212This option was rejected for the following reasons:
213
214- Design would make the application very specific to a given system or a set of
215  VPD formats. Although the application could be written in a way that allows
216  plugging in support for different VPD formats, it was deemed that the current
217  approach of small applications that target a very specific requirement is
218  better.
219- The design does not leverage upon the layered design approach that the chosen
220  option allows us to do.
221
222### Build upon the entity manager
223
224Using the entity manager: https://github.com/openbmc/entity-manager. The Entity
225manager has an application called the FruDevice, which probes /dev/i2c/ for
226EEPROMs, reads (IPMI format) VPD and stores it on DBUS.
227
228The application could be enhanced to:
229
230- Add support for other VPD formats such as the IPZ and keyword format.
231- Perhaps update a different set of data into a different DBUS object, like the
232  Inventory manager.
233- Change the external DBUS interfaces that read/write FRU data to take an
234  inventory path (instead of the I2C path, address it takes in today).
235
236This option was rejected for the following reasons:
237
238- We do not need the full spectrum of functions offered by the entity manager,
239  that is we do not want to replace the existing inventory manager. Moving away
240  from the inventory manager for Power systems is outside of the scope of this
241  document.
242- The code did not appear very pluggable to add support for new VPD formats, we
243  might have to end up just utilizing #ifdef's to separate functions.
244- Does not have a way to determine system blueprint for FRU devices, scans the
245  entire /dev/ tree to pick out EEPROMs.
246
247## Impacts
248
249The following impacts have been identified:
250
251- The services to parse VPD and store it in the inventory will add some time to
252  the BMC boot flow. The impact should be kept to a minimum by achieving maximum
253  possible parallelism in the launching of these services.
254- Applications that need to read VPD keywords will be impacted in the sense that
255  they would have to use the inventory interfaces to fetch the data they are
256  interested in.
257
258## Testing
259
260VPD parsing function can be tested by faking out the VPD EEPROMs as files on the
261filesystem. Such testing can also ensure that the right set of VPD data makes
262its way into the OpenBMC Inventory. There is also a proposal to build in a file
263mode into the application. The file mode will not need real hardware to test the
264code functions, but can use files on the BMC to mimic the EEPROMs.
265
266VPD writes can be tested by writing a small command line utility that can invoke
267the VPD write application's APIs to write VPD.
268
269[1]:
270  https://www-355.ibm.com/systems/power/openpower/posting.xhtml?postingId=1D060729AC96891885257E1B0053BC95
271[2]:
272  https://github.com/openbmc/meta-openpower/blob/master/recipes-phosphor/vpd/openpower-fru-vpd/op-vpd-parser.service
273[3]:
274  https://github.com/openbmc/meta-openpower/blob/master/recipes-phosphor/vpd/openpower-fru-vpd/70-op-vpd.rules
275[4]:
276  https://github.com/openbmc/meta-openpower/blob/master/recipes-phosphor/vpd/openpower-fru-vpd-layout/layout.yaml
277