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### SRC Deconfig Flag
243
244Bit 6 in hex word 5 of the SRC means that one or more called out resources have
245been deconfigured, and this flag can be used to set that bit. The only other way
246to set it is by indicating it when
247[passing in the callouts via JSON](../README.md#callouts).
248
249This is looked at by the software that creates the periodic PELs that indicate a
250system is running with deconfigured hardware.
251
252```json
253"DeconfigFlag": true
254```
255
256### Documentation Fields
257
258The documentation fields are used by PEL parsers to display a human readable
259description of a PEL. They are also the source for the Redfish event log
260messages.
261
262#### Message
263
264This field is used by the BMC's PEL parser as the description of the error log.
265It will also be used in Redfish event logs. It supports argument substitution
266using the %1, %2, etc placeholders allowing any of the SRC user data words 6 - 9
267to be displayed as part of the message. If the placeholders are used, then the
268`MessageArgSources` property must be present to say which SRC words to use for
269each placeholder.
270
271```json
272"Message": "Processor %1 had %2 errors"
273```
274
275#### MessageArgSources
276
277This optional field is required when the Message field contains the %X
278placeholder arguments. It is an array that says which SRC words to get the
279placeholders from. In the example below, SRC word 6 would be used for %1, and
280SRC word 7 for %2.
281
282```json
283"MessageArgSources":
284[
285    "SRCWord6", "SRCWord7"
286]
287```
288
289#### Description
290
291A short description of the error. This is required by the Redfish schema to
292generate a Redfish message entry, but is not used in Redfish or PEL output.
293
294```json
295"Description": "A power fault"
296```
297
298#### Notes
299
300This is an optional free format text field for keeping any notes for the
301registry entry, as comments are not allowed in JSON. It is an array of strings
302for easier readability of long fields.
303
304```json
305"Notes": [
306    "This entry is for every type of power fault.",
307    "There is probably a hardware failure."
308]
309```
310
311### Callout Fields
312
313The callout fields allow one to specify the PEL callouts (either a hardware FRU,
314a symbolic FRU, or a maintenance procedure) in the entry for a particular error.
315These callouts can vary based on system type, as well as a user specified
316AdditionalData property field. Callouts will be added to the PEL in the order
317they are listed in the JSON. If a callout is passed into the error, say with
318CALLOUT_INVENTORY_PATH, then that callout will be added to the PEL before the
319callouts in the registry.
320
321There is room for up to 10 callouts in a PEL.
322
323#### Callouts example based on the system type
324
325```json
326"Callouts":
327[
328    {
329        "System": "system1",
330        "CalloutList":
331        [
332            {
333                "Priority": "high",
334                "LocCode": "P1-C1"
335            },
336            {
337                "Priority": "low",
338                "LocCode": "P1"
339            }
340        ]
341    },
342    {
343        "CalloutList":
344        [
345            {
346                "Priority": "high",
347                "Procedure": "SVCDOCS"
348            }
349        ]
350
351    }
352]
353
354```
355
356The above example shows that on system 'system1', the FRU at location P1-C1 will
357be called out with a priority of high, and the FRU at P1 with a priority of low.
358On every other system, the maintenance procedure SVCDOCS is called out.
359
360#### Callouts example based on an AdditionalData field
361
362```json
363"CalloutsUsingAD":
364{
365    "ADName": "PROC_NUM",
366    "CalloutsWithTheirADValues":
367    [
368        {
369            "ADValue": "0",
370            "Callouts":
371            [
372                {
373                    "CalloutList":
374                    [
375                        {
376                            "Priority": "high",
377                            "LocCode": "P1-C5"
378                        }
379                    ]
380                }
381            ]
382        },
383        {
384            "ADValue": "1",
385            "Callouts":
386            [
387                {
388                    "CalloutList":
389                    [
390                        {
391                            "Priority": "high",
392                            "LocCode": "P1-C6"
393                        }
394                    ]
395                }
396            ]
397        }
398    ]
399}
400
401```
402
403This example shows that the callouts were selected based on the 'PROC_NUM'
404AdditionalData field. When PROC_NUM was 0, the FRU at P1-C5 was called out. When
405it was 1, P1-C6 was called out. Note that the same 'Callouts' array is used as
406in the previous example, so these callouts can also depend on the system type.
407
408If it's desired to use a different set of callouts when there isn't a match on
409the AdditionalData field, one can use CalloutsWhenNoADMatch. In the following
410example, the 'air_mover' callout will be added if 'PROC_NUM' isn't 0.
411'CalloutsWhenNoADMatch' has the same schema as the 'Callouts' section.
412
413```json
414"CalloutsUsingAD":
415{
416    "ADName": "PROC_NUM",
417    "CalloutsWithTheirADValues":
418    [
419        {
420            "ADValue": "0",
421            "Callouts":
422            [
423                {
424                    "CalloutList":
425                    [
426                        {
427                            "Priority": "high",
428                            "LocCode": "P1-C5"
429                        }
430                    ]
431                }
432            ]
433        },
434    ],
435    "CalloutsWhenNoADMatch": [
436        {
437            "CalloutList": [
438                {
439                    "Priority": "high",
440                    "SymbolicFRU": "air_mover"
441                }
442            ]
443        }
444    ]
445}
446
447```
448
449#### CalloutType
450
451This field can be used to modify the failing component type field in the callout
452when the default doesn\'t fit:
453
454```json
455{
456
457    "Priority": "high",
458    "Procedure": "FIXIT22"
459    "CalloutType": "config_procedure"
460}
461```
462
463The defaults are:
464
465- Normal hardware FRU: hardware_fru
466- Symbolic FRU: symbolic_fru
467- Procedure: maint_procedure
468
469#### Symbolic FRU callouts with dynamic trusted location codes
470
471A special case is when one wants to use a symbolic FRU callout with a trusted
472location code, but the location code to use isn\'t known until runtime. This
473means it can\'t be specified using the 'LocCode' key in the registry.
474
475In this case, one should use the 'SymbolicFRUTrusted' key along with the
476'UseInventoryLocCode' key, and then pass in the inventory item that has the
477desired location code using the 'CALLOUT_INVENTORY_PATH' entry inside of the
478AdditionalData property. The code will then look up the location code for that
479passed in inventory FRU and place it in the symbolic FRU callout. The normal FRU
480callout with that inventory item will not be created. The symbolic FRU must be
481the first callout in the registry for this to work.
482
483```json
484{
485  "Priority": "high",
486  "SymbolicFRUTrusted": "AIR_MOVR",
487  "UseInventoryLocCode": true
488}
489```
490
491### Capturing the Journal
492
493The PEL daemon can be told to capture pieces of the journal in PEL UserData
494sections. This could be useful for debugging problems where a BMC dump which
495would also contain the journal isn't available.
496
497The 'JournalCapture' field has two formats, one that will create one UserData
498section with the previous N lines of the journal, and another that can capture
499any number of journal snippets based on the journal's SYSLOG_IDENTIFIER field.
500
501```json
502"JournalCapture": {
503    "NumLines": 30
504}
505```
506
507```json
508"JournalCapture":
509{
510    "Sections": [
511        {
512            "SyslogID": "phosphor-bmc-state-manager",
513            "NumLines": 20
514        },
515        {
516            "SyslogID": "phosphor-log-manager",
517            "NumLines": 15
518        }
519    ]
520}
521```
522
523The first example will capture the previous 30 lines from the journal into a
524single UserData section.
525
526The second example will create two UserData sections, the first with the most
527recent 20 lines from phosphor-bmc-state-manager, and the second with 15 lines
528from phosphor-log-manager.
529
530If a UserData section would make the PEL exceed its maximum size of 16KB, it
531will be dropped.
532
533## Modifying and Testing
534
535The general process for adding new entries to the message registry is:
536
5371. Update message_registry.json to add the new errors.
5382. If a new component ID is used (usually the first byte of the SRC reason
539   code), document it in O_component_ids.json.
5403. Validate the file. It must be valid JSON and obey the schema. The
541   `validate_registry.py` script in `extensions/openpower-pels/registry/tools`
542   will validate both, though it requires the python-jsonschema package to do
543   the schema validation. This script is also run to validate the message
544   registry as part of CI testing.
545
546   ```sh
547   ./tools/validate_registry.py -s schema/schema.json -r message_registry.json
548   ```
549
5504. One can test what PELs are generated from these new entries without writing
551   any code to create the corresponding event logs:
552
553   1. Copy the modified message_registry.json into `/etc/phosphor-logging/` on
554      the BMC. That directory may need to be created.
555   2. Use busctl to call the Create method to create an event log corresponding
556      to the message registry entry under test.
557
558      ```sh
559      busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging \
560      xyz.openbmc_project.Logging.Create Create ssa{ss} \
561      xyz.openbmc_project.Common.Error.Timeout \
562      xyz.openbmc_project.Logging.Entry.Level.Error 1 "TIMEOUT_IN_MSEC" "5"
563      ```
564
565   3. Check the PEL that was created using peltool.
566   4. When finished, delete the file from `/etc/phosphor-logging/`.
567