1# Platform Event Log Message Registry
2
3On the BMC, PELs are created from the standard event logs provided by
4phosphor-logging using a message registry that provides the PEL related fields.
5The message registry is a JSON file.
6
7## Contents
8
9- [Component IDs](#component-ids)
10- [Message Registry](#message-registry-fields)
11- [Modifying and Testing](#modifying-and-testing)
12
13## Component IDs
14
15A component ID is a 2 byte value of the form 0xYY00 used in a PEL to:
16
171. Provide the upper byte (the YY from above) of an SRC reason code in `BD`
18   SRCs.
192. Reside in the section header of the Private Header PEL section to specify the
20   error log creator's component ID.
213. Reside in the section header of the User Header section to specify the error
22   log committer's component ID.
234. Reside in the section header in the User Data section to specify which parser
24   to call to parse that section.
25
26Component IDs are specified in the message registry either as the upper byte of
27the SRC reason code field for `BD` SRCs, or in the standalone `ComponentID`
28field.
29
30Component IDs will be unique on a per-repository basis for errors unique to that
31repository. When the same errors are created by multiple repositories, those
32errors will all share the same component ID. The master list of component IDs is
33[here](O_component_ids.json). That file can used by PEL parsers to display a
34name for the component ID. The 'O' in the name is the creator ID value for BMC
35created PELs.
36
37## Message Registry Fields
38
39The message registry schema is [here](schema/schema.json), and the message
40registry itself is [here](message_registry.json). The schema will be validated
41either during a bitbake build or during CI, or eventually possibly both.
42
43In the message registry, there are fields for specifying:
44
45### Name
46
47This is the key into the message registry, and is the Message property of the
48OpenBMC event log that the PEL is being created from.
49
50```json
51"Name": "xyz.openbmc_project.Power.Fault"
52```
53
54### Subsystem
55
56This field is part of the PEL User Header section, and is used to specify the
57subsystem pertaining to the error. It is an enumeration that maps to the actual
58PEL value. If the subsystem isn't known ahead of time, it can be passed in at
59the time of PEL creation using the 'PEL_SUBSYSTEM' AdditionalData field. In this
60case, 'Subsystem' isn't required, though 'PossibleSubsystems' is.
61
62```json
63"Subsystem": "power_supply"
64```
65
66### PossibleSubsystems
67
68This field is used by scripts that build documentation from the message registry
69to know which subsystems are possible for an error when it can't be hardcoded
70using the 'Subsystem' field. It is mutually exclusive with the 'Subsystem'
71field.
72
73```json
74"PossibleSubsystems": ["memory", "processor"]
75```
76
77### Severity
78
79This field is part of the PEL User Header section, and is used to specify the
80PEL severity. It is an optional field, if it isn't specified, then the severity
81of the OpenBMC event log will be converted into a PEL severity value.
82
83It can either be the plain severity value, or an array of severity values that
84are based on system type, where an entry without a system type will match
85anything unless another entry has a matching system type.
86
87```json
88"Severity": "unrecoverable"
89```
90
91```json
92Severity":
93[
94    {
95        "System": "system1",
96        "SevValue": "recovered"
97    },
98    {
99        "Severity": "unrecoverable"
100    }
101]
102```
103
104The above example shows that on system 'system1' the severity will be recovered,
105and on every other system it will be unrecoverable.
106
107### Mfg Severity
108
109This is an optional field and is used to override the Severity field when a
110specific manufacturing isolation mode is enabled. It has the same format as
111Severity.
112
113```json
114"MfgSeverity": "unrecoverable"
115```
116
117### Event Scope
118
119This field is part of the PEL User Header section, and is used to specify the
120event scope, as defined by the PEL spec. It is optional and defaults to "entire
121platform".
122
123```json
124"EventScope": "entire_platform"
125```
126
127### Event Type
128
129This field is part of the PEL User Header section, and is used to specify the
130event type, as defined by the PEL spec. It is optional and defaults to "not
131applicable" for non-informational logs, and "misc_information_only" for
132informational ones.
133
134```json
135"EventType": "na"
136```
137
138### Action Flags
139
140This field is part of the PEL User Header section, and is used to specify the
141PEL action flags, as defined by the PEL spec. It is an array of enumerations.
142
143The action flags can usually be deduced from other PEL fields, such as the
144severity or if there are any callouts. As such, this is an optional field and if
145not supplied the code will fill them in based on those fields.
146
147In fact, even if supplied here, the code may still modify them to ensure they
148are correct. The rules used for this are
149[here](../README.md#action-flags-and-event-type-rules).
150
151```json
152"ActionFlags": ["service_action", "report", "call_home"]
153```
154
155### Mfg Action Flags
156
157This is an optional field and is used to override the Action Flags field when a
158specific manufacturing isolation mode is enabled.
159
160```json
161"MfgActionFlags": ["service_action", "report", "call_home"]
162```
163
164### Component ID
165
166This is the component ID of the PEL creator, in the form 0xYY00. For `BD` SRCs,
167this is an optional field and if not present the value will be taken from the
168upper byte of the reason code. If present for `BD` SRCs, then this byte must
169match the upper byte of the reason code.
170
171```json
172"ComponentID": "0x5500"
173```
174
175### SRC Type
176
177This specifies the type of SRC to create. The type is the first 2 characters of
178the 8 character ASCII string field of the PEL. The allowed types are `BD`, for
179the standard OpenBMC error, and `11`, for power related errors. It is optional
180and if not specified will default to `BD`.
181
182Note: The ASCII string for BD SRCs looks like: `BDBBCCCC`, where:
183
184- BD = SRC type
185- BB = PEL subsystem as mentioned above
186- CCCC SRC reason code
187
188For `11` SRCs, it looks like: `1100RRRR`, where RRRR is the SRC reason code.
189
190```json
191"Type": "11"
192```
193
194### SRC Reason Code
195
196This is the 4 character value in the latter half of the SRC ASCII string. It is
197treated as a 2 byte hex value, such as 0x5678. For `BD` SRCs, the first byte is
198the same as the first byte of the component ID field in the Private Header
199section that represents the creator's component ID.
200
201```json
202"ReasonCode": "0x5544"
203```
204
205### SRC Symptom ID Fields
206
207The symptom ID is in the Extended User Header section and is defined in the PEL
208spec as the unique event signature string. It always starts with the ASCII
209string. This field in the message registry allows one to choose which SRC words
210to use in addition to the ASCII string field to form the symptom ID. All words
211are separated by underscores. If not specified, the code will choose a default
212format, which may depend on the SRC type.
213
214For example: ["SRCWord3", "SRCWord9"] would be:
215`<ASCII_STRING>_<SRCWord3>_<SRCWord9>`, which could look like:
216`B181320_00000050_49000000`.
217
218```json
219"SymptomIDFields": ["SRCWord3", "SRCWord9"]
220```
221
222### SRC words 6 to 9
223
224In a PEL, these SRC words are free format and can be filled in by the user as
225desired. On the BMC, the source of these words is the AdditionalData fields in
226the event log. The message registry provides a way for the log creator to
227specify which AdditionalData property field to get the data from, and also to
228define what the SRC word means for use by parsers. If not specified, these SRC
229words will be set to zero in the PEL.
230
231```json
232"Words6to9":
233{
234    "6":
235    {
236        "description": "Failing unit number",
237        "AdditionalDataPropSource": "PS_NUM"
238    }
239}
240```
241
242### Documentation Fields
243
244The documentation fields are used by PEL parsers to display a human readable
245description of a PEL. They are also the source for the Redfish event log
246messages.
247
248#### Message
249
250This field is used by the BMC's PEL parser as the description of the error log.
251It will also be used in Redfish event logs. It supports argument substitution
252using the %1, %2, etc placeholders allowing any of the SRC user data words 6 - 9
253to be displayed as part of the message. If the placeholders are used, then the
254`MessageArgSources` property must be present to say which SRC words to use for
255each placeholder.
256
257```json
258"Message": "Processor %1 had %2 errors"
259```
260
261#### MessageArgSources
262
263This optional field is required when the Message field contains the %X
264placeholder arguments. It is an array that says which SRC words to get the
265placeholders from. In the example below, SRC word 6 would be used for %1, and
266SRC word 7 for %2.
267
268```json
269"MessageArgSources":
270[
271    "SRCWord6", "SRCWord7"
272]
273```
274
275#### Description
276
277A short description of the error. This is required by the Redfish schema to
278generate a Redfish message entry, but is not used in Redfish or PEL output.
279
280```json
281"Description": "A power fault"
282```
283
284#### Notes
285
286This is an optional free format text field for keeping any notes for the
287registry entry, as comments are not allowed in JSON. It is an array of strings
288for easier readability of long fields.
289
290```json
291"Notes": [
292    "This entry is for every type of power fault.",
293    "There is probably a hardware failure."
294]
295```
296
297### Callout Fields
298
299The callout fields allow one to specify the PEL callouts (either a hardware FRU,
300a symbolic FRU, or a maintenance procedure) in the entry for a particular error.
301These callouts can vary based on system type, as well as a user specified
302AdditionalData property field. Callouts will be added to the PEL in the order
303they are listed in the JSON. If a callout is passed into the error, say with
304CALLOUT_INVENTORY_PATH, then that callout will be added to the PEL before the
305callouts in the registry.
306
307There is room for up to 10 callouts in a PEL.
308
309#### Callouts example based on the system type
310
311```json
312"Callouts":
313[
314    {
315        "System": "system1",
316        "CalloutList":
317        [
318            {
319                "Priority": "high",
320                "LocCode": "P1-C1"
321            },
322            {
323                "Priority": "low",
324                "LocCode": "P1"
325            }
326        ]
327    },
328    {
329        "CalloutList":
330        [
331            {
332                "Priority": "high",
333                "Procedure": "SVCDOCS"
334            }
335        ]
336
337    }
338]
339
340```
341
342The above example shows that on system 'system1', the FRU at location P1-C1 will
343be called out with a priority of high, and the FRU at P1 with a priority of low.
344On every other system, the maintenance procedure SVCDOCS is called out.
345
346#### Callouts example based on an AdditionalData field
347
348```json
349"CalloutsUsingAD":
350{
351    "ADName": "PROC_NUM",
352    "CalloutsWithTheirADValues":
353    [
354        {
355            "ADValue": "0",
356            "Callouts":
357            [
358                {
359                    "CalloutList":
360                    [
361                        {
362                            "Priority": "high",
363                            "LocCode": "P1-C5"
364                        }
365                    ]
366                }
367            ]
368        },
369        {
370            "ADValue": "1",
371            "Callouts":
372            [
373                {
374                    "CalloutList":
375                    [
376                        {
377                            "Priority": "high",
378                            "LocCode": "P1-C6"
379                        }
380                    ]
381                }
382            ]
383        }
384    ]
385}
386
387```
388
389This example shows that the callouts were selected based on the 'PROC_NUM'
390AdditionalData field. When PROC_NUM was 0, the FRU at P1-C5 was called out. When
391it was 1, P1-C6 was called out. Note that the same 'Callouts' array is used as
392in the previous example, so these callouts can also depend on the system type.
393
394If it's desired to use a different set of callouts when there isn't a match on
395the AdditionalData field, one can use CalloutsWhenNoADMatch. In the following
396example, the 'air_mover' callout will be added if 'PROC_NUM' isn't 0.
397'CalloutsWhenNoADMatch' has the same schema as the 'Callouts' section.
398
399```json
400"CalloutsUsingAD":
401{
402    "ADName": "PROC_NUM",
403    "CalloutsWithTheirADValues":
404    [
405        {
406            "ADValue": "0",
407            "Callouts":
408            [
409                {
410                    "CalloutList":
411                    [
412                        {
413                            "Priority": "high",
414                            "LocCode": "P1-C5"
415                        }
416                    ]
417                }
418            ]
419        },
420    ],
421    "CalloutsWhenNoADMatch": [
422        {
423            "CalloutList": [
424                {
425                    "Priority": "high",
426                    "SymbolicFRU": "air_mover"
427                }
428            ]
429        }
430    ]
431}
432
433```
434
435#### CalloutType
436
437This field can be used to modify the failing component type field in the callout
438when the default doesn\'t fit:
439
440```json
441{
442
443    "Priority": "high",
444    "Procedure": "FIXIT22"
445    "CalloutType": "config_procedure"
446}
447```
448
449The defaults are:
450
451- Normal hardware FRU: hardware_fru
452- Symbolic FRU: symbolic_fru
453- Procedure: maint_procedure
454
455#### Symbolic FRU callouts with dynamic trusted location codes
456
457A special case is when one wants to use a symbolic FRU callout with a trusted
458location code, but the location code to use isn\'t known until runtime. This
459means it can\'t be specified using the 'LocCode' key in the registry.
460
461In this case, one should use the 'SymbolicFRUTrusted' key along with the
462'UseInventoryLocCode' key, and then pass in the inventory item that has the
463desired location code using the 'CALLOUT_INVENTORY_PATH' entry inside of the
464AdditionalData property. The code will then look up the location code for that
465passed in inventory FRU and place it in the symbolic FRU callout. The normal FRU
466callout with that inventory item will not be created. The symbolic FRU must be
467the first callout in the registry for this to work.
468
469```json
470{
471  "Priority": "high",
472  "SymbolicFRUTrusted": "AIR_MOVR",
473  "UseInventoryLocCode": true
474}
475```
476
477### Capturing the Journal
478
479The PEL daemon can be told to capture pieces of the journal in PEL UserData
480sections. This could be useful for debugging problems where a BMC dump which
481would also contain the journal isn't available.
482
483The 'JournalCapture' field has two formats, one that will create one UserData
484section with the previous N lines of the journal, and another that can capture
485any number of journal snippets based on the journal's SYSLOG_IDENTIFIER field.
486
487```json
488"JournalCapture": {
489    "NumLines": 30
490}
491```
492
493```json
494"JournalCapture":
495{
496    "Sections": [
497        {
498            "SyslogID": "phosphor-bmc-state-manager",
499            "NumLines": 20
500        },
501        {
502            "SyslogID": "phosphor-log-manager",
503            "NumLines": 15
504        }
505    ]
506}
507```
508
509The first example will capture the previous 30 lines from the journal into a
510single UserData section.
511
512The second example will create two UserData sections, the first with the most
513recent 20 lines from phosphor-bmc-state-manager, and the second with 15 lines
514from phosphor-log-manager.
515
516If a UserData section would make the PEL exceed its maximum size of 16KB, it
517will be dropped.
518
519## Modifying and Testing
520
521The general process for adding new entries to the message registry is:
522
5231. Update message_registry.json to add the new errors.
5242. If a new component ID is used (usually the first byte of the SRC reason
525   code), document it in O_component_ids.json.
5263. Validate the file. It must be valid JSON and obey the schema. The
527   `process_registry.py` script in `extensions/openpower-pels/registry/tools`
528   will validate both, though it requires the python-jsonschema package to do
529   the schema validation. This script is also run to validate the message
530   registry as part of CI testing.
531
532   ```sh
533   ./tools/process_registry.py -v -s schema/schema.json -r message_registry.json
534   ```
535
5364. One can test what PELs are generated from these new entries without writing
537   any code to create the corresponding event logs:
538
539   1. Copy the modified message_registry.json into `/etc/phosphor-logging/` on
540      the BMC. That directory may need to be created.
541   2. Use busctl to call the Create method to create an event log corresponding
542      to the message registry entry under test.
543
544      ```sh
545      busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging \
546      xyz.openbmc_project.Logging.Create Create ssa{ss} \
547      xyz.openbmc_project.Common.Error.Timeout \
548      xyz.openbmc_project.Logging.Entry.Level.Error 1 "TIMEOUT_IN_MSEC" "5"
549      ```
550
551   3. Check the PEL that was created using peltool.
552   4. When finished, delete the file from `/etc/phosphor-logging/`.
553