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