summaryrefslogtreecommitdiffstats
path: root/extensions/openpower-pels/registry
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/openpower-pels/registry')
-rw-r--r--extensions/openpower-pels/registry/ComponentIDs.md9
-rw-r--r--extensions/openpower-pels/registry/README.md240
-rw-r--r--extensions/openpower-pels/registry/message_registry.json202
-rw-r--r--extensions/openpower-pels/registry/run-ci.sh3
-rw-r--r--extensions/openpower-pels/registry/schema/registry_example.json39
-rw-r--r--extensions/openpower-pels/registry/schema/schema.json354
-rwxr-xr-xextensions/openpower-pels/registry/tools/process_registry.py167
7 files changed, 1014 insertions, 0 deletions
diff --git a/extensions/openpower-pels/registry/ComponentIDs.md b/extensions/openpower-pels/registry/ComponentIDs.md
new file mode 100644
index 0000000..c74842d
--- /dev/null
+++ b/extensions/openpower-pels/registry/ComponentIDs.md
@@ -0,0 +1,9 @@
+# PEL Component ID List
+
+See [here](README.md#component-ids) for details on how PEL component IDs are
+used.
+
+| Component ID | Repository |
+|--------------|------------|
+| 0x1000 | Common Errors that span repositories |
+| 0x2000 | phosphor-logging |
diff --git a/extensions/openpower-pels/registry/README.md b/extensions/openpower-pels/registry/README.md
new file mode 100644
index 0000000..a0e6f49
--- /dev/null
+++ b/extensions/openpower-pels/registry/README.md
@@ -0,0 +1,240 @@
+# Platform Event Log Message Registry
+On the BMC, PELs are created from the standard event logs provided by
+phosphor-logging using a message registry that provides the PEL related fields.
+The message registry is a JSON file.
+
+## Contents
+* [Component IDs](#component-ids)
+* [Message Registry](#message-registry-fields)
+
+## Component IDs
+A component ID is a 2 byte value of the form 0xYY00 used in a PEL to:
+1. Provide the upper byte (the YY from above) of an SRC reason code in `BD`
+ SRCs.
+2. Reside in the section header of the Private Header PEL section to specify
+ the error log creator's component ID.
+3. Reside in the section header of the User Header section to specify the error
+ log committer's component ID.
+4. Reside in the section header in the User Data section to specify which
+ parser to call to parse that section.
+
+Component IDs are specified in the message registry either as the upper byte of
+the SRC reason code field for `BD` SRCs, or in the standalone `ComponentID`
+field.
+
+Component IDs will be unique on a per-repository basis for errors unique to
+that repository. When the same errors are created by multiple repositories,
+those errors will all share the same component ID. The master list of
+component IDs is [here](ComponentIDs.md).
+
+## Message Registry Fields
+The message registry schema is [here](schema/schema.json), and the message
+registry itself is [here](message_registry.json). The schema will be validated
+either during a bitbake build or during CI, or eventually possibly both.
+
+In the message registry, there are fields for specifying:
+
+### Name
+This is the key into the message registry, and is the Message property
+of the OpenBMC event log that the PEL is being created from.
+
+```
+"Name": "xyz.openbmc_project.Power.Fault"
+```
+
+### Subsystem
+This field is part of the PEL User Header section, and is used to specify
+the subsystem pertaining to the error. It is an enumeration that maps to the
+actual PEL value.
+
+```
+"Subsystem": "power_supply"
+```
+
+### Severity
+This field is part of the PEL User Header section, and is used to specify
+the PEL severity. It is an optional field, if it isn't specified, then the
+severity of the OpenBMC event log will be converted into a PEL severity value.
+
+```
+"Severity": "unrecoverable"
+```
+
+### Mfg Severity
+This is an optional field and is used to override the Severity field when a
+specific manufacturing isolation mode is enabled.
+
+```
+"MfgSeverity": "unrecoverable"
+```
+
+### Event Scope
+This field is part of the PEL User Header section, and is used to specify
+the event scope, as defined by the PEL spec. It is optional and defaults to
+"entire platform".
+
+```
+"EventScope": "entire_platform"
+```
+
+### Event Type
+This field is part of the PEL User Header section, and is used to specify
+the event type, as defined by the PEL spec. It is optional and defaults to
+"not applicable" for non-informational logs, and "misc_information_only" for
+informational ones.
+
+```
+"EventType": "na"
+```
+
+### Action Flags
+This field is part of the PEL User Header section, and is used to specify the
+PEL action flags, as defined by the PEL spec. It is an array of enumerations.
+
+The action flags can usually be deduced from other PEL fields, such as the
+severity or if there are any callouts. As such, this is an optional field and
+if not supplied the code will fill them in based on those fields.
+
+In fact, even if supplied here, the code may still modify them to ensure they
+are correct.
+
+```
+"ActionFlags": ["service_action", "report", "call_home"]
+```
+
+### Mfg Action Flags
+This is an optional field and is used to override the Action Flags field when a
+specific manufacturing isolation mode is enabled.
+
+```
+"MfgActionFlags": ["service_action", "report", "call_home"]
+```
+
+### Component ID
+This is the component ID of the PEL creator, in the form 0xYY00. For `BD`
+SRCs, this is an optional field and if not present the value will be taken from
+the upper byte of the reason code. If present for `BD` SRCs, then this byte
+must match the upper byte of the reason code.
+
+```
+"ComponentID": "0x5500"
+```
+
+### SRC Type
+This specifies the type of SRC to create. The type is the first 2 characters
+of the 8 character ASCII string field of the PEL. The allowed types are `BD`,
+for the standard OpenBMC error, and `11`, for power related errors. It is
+optional and if not specified will default to `BD`.
+
+Note: The ASCII string for BD SRCs looks like: `BDBBCCCC`, where:
+* BD = SRC type
+* BB = PEL subsystem as mentioned above
+* CCCC SRC reason code
+
+For `11` SRCs, it looks like: `1100RRRR`, where RRRR is the SRC reason code.
+
+```
+"Type": "11"
+```
+
+### SRC Reason Code
+This is the 4 character value in the latter half of the SRC ASCII string. It
+is treated as a 2 byte hex value, such as 0x5678. For `BD` SRCs, the first
+byte is the same as the first byte of the component ID field in the Private
+Header section that represents the creator's component ID.
+
+```
+"ReasonCode": "0x5544"
+```
+
+### SRC Symptom ID Fields
+The symptom ID is in the Extended User Header section and is defined in the PEL
+spec as the unique event signature string. It always starts with the ASCII
+string. This field in the message registry allows one to choose which SRC words
+to use in addition to the ASCII string field to form the symptom ID. All words
+are separated by underscores. If not specified, the code will choose a default
+format, which may depend on the SRC type.
+
+For example: ["SRCWord3", "SRCWord9"] would be:
+`<ASCII_STRING>_<SRCWord3>_<SRCWord9>`, which could look like:
+`B181320_00000050_49000000`.
+
+```
+"SymptomIDFields": ["SRCWord3", "SRCWord9"]
+```
+
+### SRC words 6 to 9
+In a PEL, these SRC words are free format and can be filled in by the user as
+desired. On the BMC, the source of these words is the AdditionalData fields in
+the event log. The message registry provides a way for the log creator to
+specify which AdditionalData property field to get the data from, and also to
+define what the SRC word means for use by parsers. If not specified, these SRC
+words will be set to zero in the PEL.
+
+```
+"Words6to9":
+{
+ "6":
+ {
+ "description": "Failing unit number",
+ "AdditionalDataPropSource": "PS_NUM"
+ }
+}
+```
+
+### SRC Power Fault flag
+The SRC has a bit in it to indicate if the error is a power fault. This is an
+optional field in the message registry and defaults to false.
+
+```
+"PowerFault: false
+```
+
+### Documentation Fields
+The documentation fields are used by PEL parsers to display a human readable
+description of a PEL. They are also the source for the Redfish event log
+messages.
+
+#### Message
+This field is used by the BMC's PEL parser as the description of the error log.
+It will also be used in Redfish event logs. It supports argument substitution
+using the %1, %2, etc placeholders allowing any of the SRC user data words 6 -
+9 to be displayed as part of the message. If the placeholders are used, then
+the `MessageArgSources` property must be present to say which SRC words to use
+for each placeholder.
+
+```
+"Message": "Processor %1 had %2 errors"
+```
+
+#### MessageArgSources
+This optional field is required when the Message field contains the %X
+placeholder arguments. It is an array that says which SRC words to get the
+placeholders from. In the example below, SRC word 6 would be used for %1, and
+SRC word 7 for %2.
+
+```
+"MessageArgSources":
+[
+ "SRCWord6", "SRCWord7"
+]
+```
+
+#### Description
+A short description of the error. This is required by the Redfish schema to generate a Redfish message entry, but is not used in Redfish or PEL output.
+
+```
+"Description": "A power fault"
+```
+
+#### Notes
+This is an optional free format text field for keeping any notes for the
+registry entry, as comments are not allowed in JSON. It is an array of strings
+for easier readability of long fields.
+
+```
+"Notes": [
+ "This entry is for every type of power fault.",
+ "There is probably a hardware failure."
+]
+```
diff --git a/extensions/openpower-pels/registry/message_registry.json b/extensions/openpower-pels/registry/message_registry.json
new file mode 100644
index 0000000..12b977b
--- /dev/null
+++ b/extensions/openpower-pels/registry/message_registry.json
@@ -0,0 +1,202 @@
+{
+ "PELs":
+ [
+ {
+ "Name": "xyz.openbmc_project.Common.Error.Timeout",
+ "Subsystem": "bmc_firmware",
+
+ "SRC":
+ {
+ "ReasonCode": "0x1001",
+ "Words6To9":
+ {
+ "6":
+ {
+ "Description": "Timeout in ms",
+ "AdditionalDataPropSource": "TIMEOUT_IN_MSEC"
+ }
+ }
+ },
+
+ "Documentation":
+ {
+ "Description": "This is a generic timeout error",
+ "Message": "An operation timed out",
+ "Notes": [
+ "The journal should contain more information"
+ ]
+ }
+ },
+
+ {
+ "Name": "xyz.openbmc_project.Common.Error.InternalFailure",
+ "Subsystem": "bmc_firmware",
+
+ "SRC":
+ {
+ "ReasonCode": "0x1002",
+ "Words6To9":
+ {
+ }
+ },
+
+ "Documentation":
+ {
+ "Description": "BMC code had a generic internal failure",
+ "Message": "An application had an internal failure",
+ "Notes": [
+ "The journal should contain more information"
+ ]
+ }
+ },
+
+ {
+ "Name": "xyz.openbmc_project.Common.Error.InvalidArgument",
+ "Subsystem": "user_error",
+
+ "SRC":
+ {
+ "ReasonCode": "0x1003",
+ "Words6To9":
+ {
+ }
+ },
+
+ "Documentation":
+ {
+ "Description": "BMC code was given an invalid argument",
+ "Message": "Code was given an invalid argument",
+ "Notes": [
+ "The journal should contain more information"
+ ]
+ }
+ },
+ {
+ "Name": "xyz.openbmc_project.Common.Error.InsufficientPermission",
+ "Subsystem": "user_error",
+
+ "SRC":
+ {
+ "ReasonCode": "0x1004",
+ "Words6To9":
+ {
+ }
+ },
+
+ "Documentation":
+ {
+ "Description": "An operation failed due to insufficient permission",
+ "Message": "An operation failed due to unsufficient permission",
+ "Notes": [
+ "The journal should contain more information"
+ ]
+ }
+ },
+
+ {
+ "Name": "xyz.openbmc_project.Common.Error.NotAllowed",
+ "Subsystem": "user_error",
+
+ "SRC":
+ {
+ "ReasonCode": "0x1005",
+ "Words6To9":
+ {
+ }
+ },
+
+ "Documentation":
+ {
+ "Description": "An operation failed because it isn't allowed",
+ "Message": "An operation failed becuase it isn't allowed",
+ "Notes": [
+ "The journal should contain more information"
+ ]
+ }
+ },
+
+ {
+ "Name": "xyz.openbmc_project.Common.Error.NoCACertificate",
+ "Subsystem": "user_error",
+
+ "SRC":
+ {
+ "ReasonCode": "0x1006",
+ "Words6To9":
+ {
+ }
+ },
+
+ "Documentation":
+ {
+ "Description": "The server's CA certificate has not been provided",
+ "Message": "The server's CA certificate has not been provided"
+ }
+ },
+
+ {
+ "Name": "org.open_power.Logging.Error.SentBadPELToHost",
+ "Subsystem": "bmc_firmware",
+ "Severity": "non_error",
+
+ "SRC":
+ {
+ "ReasonCode": "0x2001",
+ "Words6To9":
+ {
+ "6":
+ {
+ "Description": "The bad PEL ID",
+ "AdditionalDataPropSource": "BAD_ID"
+ }
+ }
+ },
+
+ "Documentation":
+ {
+ "Description": "The BMC sent the host a malformed PEL",
+ "Message": "The BMC sent the host a malformed PEL",
+ "Notes": [
+ "The host firmware rejected that PEL."
+ ]
+ }
+ },
+
+ {
+ "Name": "org.open_power.Logging.Error.BadHostPEL",
+ "Subsystem": "platform_firmware",
+ "Severity": "unrecoverable",
+
+ "SRC":
+ {
+ "ReasonCode": "0x2002",
+ "Words6To9":
+ {
+ "6":
+ {
+ "Description": "The PLID of the invalid PEL",
+ "AdditionalDataPropSource": "PLID"
+ },
+ "7":
+ {
+ "Description": "The corresponding OpenBMC event log ID",
+ "AdditionalDataPropSource": "OBMC_LOG_ID"
+ },
+ "8":
+ {
+ "Description": "The size of the invalid PEL",
+ "AdditionalDataPropSource": "PEL_SIZE"
+ }
+ }
+ },
+
+ "Documentation":
+ {
+ "Description": "The host sent the BMC an invalid PEL",
+ "Message": "The host sent the BMC an invalid PEL",
+ "Notes": [
+ ]
+ }
+ }
+ ]
+}
diff --git a/extensions/openpower-pels/registry/run-ci.sh b/extensions/openpower-pels/registry/run-ci.sh
new file mode 100644
index 0000000..4868f9b
--- /dev/null
+++ b/extensions/openpower-pels/registry/run-ci.sh
@@ -0,0 +1,3 @@
+/usr/bin/env python extensions/openpower-pels/registry/tools/process_registry.py \
+-v -s extensions/openpower-pels/registry/schema/schema.json \
+-r extensions/openpower-pels/registry/message_registry.json
diff --git a/extensions/openpower-pels/registry/schema/registry_example.json b/extensions/openpower-pels/registry/schema/registry_example.json
new file mode 100644
index 0000000..3fdf664
--- /dev/null
+++ b/extensions/openpower-pels/registry/schema/registry_example.json
@@ -0,0 +1,39 @@
+{
+ "PELs":
+ [
+ {
+ "Name": "xyz.openbmc_project.Power.Fault",
+ "Subsystem": "power_supply",
+ "Severity": "unrecoverable",
+ "ActionFlags": ["service_action", "report"],
+
+ "SRC":
+ {
+ "ReasonCode": "0x2030",
+ "SymptomIDFields": ["SRCWord3", "SRCWord6"],
+ "Words6To9":
+ {
+ "6":
+ {
+ "Description": "Failing unit number",
+ "AdditionalDataPropSource": "PS_NUM"
+ }
+ }
+ },
+
+ "Documentation":
+ {
+ "Description": "A PGOOD Fault",
+ "Message": "PS %1 had a PGOOD Fault",
+ "MessageArgSources":
+ [
+ "SRCWord6"
+ ],
+ "Notes": [
+ "In the UserData section there is a JSON",
+ "dump that provides debug information."
+ ]
+ }
+ }
+ ]
+}
diff --git a/extensions/openpower-pels/registry/schema/schema.json b/extensions/openpower-pels/registry/schema/schema.json
new file mode 100644
index 0000000..f41d425
--- /dev/null
+++ b/extensions/openpower-pels/registry/schema/schema.json
@@ -0,0 +1,354 @@
+{
+ "title": "PEL message registry schema",
+ "$id": "http://github.com/openbmc/phosphor-logging/extensions/openpower-pels/registry/schema/schema.json",
+ "description": "This schema describes JSON used for creating PELs from OpenBMC event logs.",
+ "type": "object",
+
+ "properties":
+ {
+ "PELs":
+ {
+ "title": "This is an array of entries that specify PEL fields for event logs",
+ "$ref": "#/definitions/pels"
+ }
+ },
+
+ "additionalProperties": false,
+ "minItems": 1,
+ "uniqueItems": true,
+
+ "definitions":
+ {
+ "pels":
+ {
+ "description": "Each entry in this array is for converting an event log to a PEL",
+ "type": "array",
+ "items":
+ {
+ "description": "The schema for a single event log registry entry",
+ "type": "object",
+ "properties":
+ {
+ "Name": {"$ref": "#/definitions/errorName" },
+
+ "SRC": {"$ref": "#/definitions/src" },
+
+ "Subsystem": {"$ref": "#/definitions/subsystem" },
+
+ "Severity": {"$ref": "#/definitions/severity" },
+
+ "MfgSeverity": {"$ref": "#/definitions/mfgSeverity" },
+
+ "EventScope": {"$ref": "#/definitions/eventScope" },
+
+ "EventType": {"$ref": "#/definitions/eventType" },
+
+ "ActionFlags": {"$ref": "#/definitions/actionFlags" },
+
+ "MfgActionFlags": {"$ref": "#/definitions/mfgActionFlags" },
+
+ "Documentation": {"$ref": "#/definitions/documentation" },
+
+ "ComponentID": {"$ref": "#/definitions/componentID" }
+ },
+
+ "required": ["Name", "SRC", "Subsystem", "Documentation"],
+ "additionalProperties": false
+ }
+ },
+
+ "errorName":
+ {
+ "description": "The 'Message' property of an OpenBMC event log",
+ "type": "string"
+ },
+
+ "componentID":
+ {
+ "description": "The component ID of the PEL creator, in the form 0xYY00. For BD SRCs, this is optional and if not present the component ID will be taken from the upper byte of the reason code.",
+ "type": "string",
+ "pattern": "^0x[0-9a-fA-F]{2}00$"
+ },
+
+ "src":
+ {
+ "description": "Contains fields describing the primary SRC embedded in the PEL",
+ "type": "object",
+
+ "properties":
+ {
+ "Type": {"$ref": "#/definitions/srcType" },
+
+ "ReasonCode": {"$ref": "#/definitions/reasonCode" },
+
+ "SymptomIDFields": {"$ref": "#/definitions/symptomID" },
+
+ "Words6To9": {"$ref": "#/definitions/srcWords6To9" },
+
+ "PowerFault": {"$ref": "#/definitions/powerFault" }
+ },
+
+ "required": ["ReasonCode", "Words6To9"],
+ "additionalProperties": false
+ },
+
+ "documentation":
+ {
+ "description": "This contains event documentation that will be used by tools and parsers.",
+ "type": "object",
+
+ "properties":
+ {
+ "Message": {"$ref": "#/definitions/docMessage" },
+
+ "MessageArgSources": {"$ref": "#/definitions/docMessageArgSources" },
+
+ "Description": {"$ref": "#/definitions/docDescription" },
+
+ "Notes": {"$ref": "#/definitions/docNotes" }
+
+ },
+ "additionalProperties": false,
+ "required": ["Message", "Description"]
+ },
+
+ "srcType":
+ {
+ "description": "The first byte of the SRC ASCII string. Optional and defaults to BD. The '11' SRC is only to be used for events related to power.",
+ "type": "string",
+ "enum": ["BD", "11"]
+ },
+
+ "docNotes":
+ {
+ "description": "Any notes/comments about the error. An array of strings for manual line wrapping. Optional.",
+ "type": "array",
+ "items":
+ {
+ "description": "Notes",
+ "type": "string"
+ }
+ },
+
+ "reasonCode":
+ {
+ "description": "String representation of the 2 byte reason code, like 0xABCD. The reason code is the 2nd half of the 8 character SRC ASCII String field, such as B1FFABCD.",
+ "type": "string",
+ "pattern": "^0x[0-9a-fA-F]{4}$",
+
+ "examples": [
+ "0x3355"
+ ]
+ },
+
+ "subsystem":
+ {
+ "description": "PEL subsystem enumeration. See the PEL spec for more detailed definitions.",
+ "type": "string",
+ "enum": ["processor", "processor_fru", "processor_chip",
+ "processor_unit", "processor_bus",
+
+ "memory", "memory_ctlr", "memory_bus", "memory_dimm",
+ "memory_fru", "external_cache",
+
+ "io", "io_hub", "io_bridge", "io_bus", "io_processor",
+ "io_hub_other", "phb",
+
+ "io_adapter", "io_adapter_comm", "io_device",
+ "io_device_dasd", "io_external_general",
+ "io_external_workstation", "io_storage_mezz",
+
+ "cec_hardware", "cec_sp_a", "cec_sp_b",
+ "cec_node_controller", "cec_vpd",
+ "cec_i2c", "cec_chip_iface", "cec_clocks", "cec_op_panel",
+ "cec_tod", "cec_storage_device", "cec_sp_hyp_iface",
+ "cec_service_network", "cec_sp_hostboot_iface",
+
+ "power", "power_supply", "power_control_hw", "power_fans",
+ "power_sequencer",
+
+ "others", "other_hmc", "other_test_tool", "other_media",
+ "other_multiple_subsystems", "other_na", "other_info_src",
+
+ "surv_hyp_lost_sp", "surv_sp_lost_hyp", "surv_sp_lost_hmc",
+ "surv_hmc_lost_lpar", "surv_hmc_lost_bpa",
+ "surv_hmc_lost_hmc",
+
+ "platform_firmware", "bmc_firmware", "hyp_firmware",
+ "partition_firmware", "slic_firmware", "spcn_firmware",
+ "bulk_power_firmware_side_a", "hmc_code_firmware",
+ "bulk_power_firmware_side_b", "virtual_sp", "hostboot",
+ "occ",
+
+ "software", "os_software", "xpf_software", "app_software",
+
+ "ext_env", "input_power_source", "ambient_temp",
+ "user_error", "corrosion"]
+ },
+
+ "severity":
+ {
+ "description": "PEL severity enumeration. Optional. If not provided, will use the event log severity. See the PEL spec for more detailed definitions.",
+ "type": "string",
+
+ "enum": ["non_error",
+
+ "recovered",
+
+ "predictive", "predictive_degraded_perf",
+ "predictive_reboot", "predictive_reboot_degraded",
+ "predictive_redundancy_loss",
+
+ "unrecoverable", "unrecoverable_degraded_perf",
+ "unrecoverable_redundancy_loss",
+ "unrecoverable_redundancy_loss_perf",
+ "unrecoverable_loss_of_function",
+
+ "critical", "critical_system_term",
+ "critical_imminent_failure",
+ "critical_partition_term",
+ "critical_partition_imminent_failure",
+
+ "diagnostic_error", "diagnostic_error_incorrect_results",
+
+ "symptom_recovered", "symptom_predictive",
+ "symptom_unrecoverable", "symptom_critical",
+ "symptom_diag_err"]
+ },
+
+ "mfgSeverity":
+ {
+ "description": "The PEL severity to use in manufacturing reporting mode",
+ "$ref": "#/definitions/severity"
+ },
+
+ "eventScope":
+ {
+ "description": "The event scope PEL field. Optional and defaults to entire_platform",
+ "type": "string",
+ "enum": ["entire_platform", "single_partition", "multiple_partitions",
+ "possibly_multiple_platforms"]
+ },
+
+ "eventType":
+ {
+ "description": "The event type PEL field. Optional and defaults to na",
+ "type": "string",
+ "enum": ["na", "misc_information_only", "tracing_event",
+ "dump_notification"]
+ },
+
+ "powerFault":
+ {
+ "description": "The Power Fault SRC field (bit 6 in byte 1 of header). Optional and defaults to false",
+ "type": "boolean"
+ },
+
+ "actionFlags":
+ {
+ "description": "The action flags Private Header PEL field",
+ "type": "array",
+ "items":
+ {
+ "description": "List of action flags",
+ "type": "string",
+ "enum": ["service_action", "hidden", "report", "dont_report",
+ "call_home", "isolation_incomplete", "termination"]
+ }
+ },
+
+ "mfgActionFlags":
+ {
+ "description": "The PEL action flags to use in manufacturing reporting mode",
+ "$ref": "#/definitions/actionFlags"
+ },
+
+ "docDescription":
+ {
+ "description": "This is a higher level description of the error. It is required by the Redfish schema to generate a Redfish message entry, but is not used in Redfish or PEL output.",
+ "type": "string"
+ },
+
+ "docMessage":
+ {
+ "description": "The error message. This will show up in parsed PELs, and in the Redfish event logs. It can contain placeholders for numeric values using %1, %2, etc, that come from the SRC words 6-9 as defined by the MessageArgSources property.",
+ "type": "string",
+ "examples": [
+ {"Message": "The code update from level %1 to %2 failed" }
+ ]
+ },
+
+ "docMessageArgSources":
+ {
+ "description": "The SRC word 6-9 to use as the source of the numeric arguments that will be substituted into any placeholder in the Message field. Only required if there are arguments to substitute.",
+ "type": "array",
+ "items":
+ {
+ "type": "string",
+ "enum": ["SRCWord6", "SRCWord7", "SRCWord8", "SRCWord9"]
+ },
+ "additionalItems": false
+ },
+
+ "symptomID":
+ {
+ "description": "Defines a custom Symptom ID, to be appended to the ASCII string word and separated by underscores. The maximum size of the Symptom ID field is 80 characters. The default is ASCIISTRING_SRCWord3 (e.g. B1103500_12345678).",
+ "type": "array",
+ "items":
+ {
+ "type": "string",
+ "enum": ["SRCWord3", "SRCWord4", "SRCWord5", "SRCWord6",
+ "SRCWord7", "SRCWord8", "SRCWord9"]
+ },
+ "minItems": 1,
+ "maxItems": 8,
+ "uniqueItems": true,
+
+ "examples": [
+ ["SRCWord3", "SRCWord6"]
+ ]
+ },
+
+ "srcWords6To9":
+ {
+ "description": "This details what the user defined SRC hex words (6-9) mean, and which AdditionalData properties to get them from. These will be shown in the PEL parser output. Must be present, but can be empty.",
+ "type": "object",
+ "patternProperties":
+ {
+ "^[6-9]$":
+ {
+ "type": "object",
+ "properties":
+ {
+ "Description":
+ {
+ "description": "What the value in the field represents.",
+ "type": "string"
+ },
+ "AdditionalDataPropSource":
+ {
+ "description": "Which AdditionalData property key to get the data from.",
+ "type": "string"
+ }
+ },
+
+ "additionalProperties": false
+ },
+
+ "examples":
+ {
+ "SRCWords6To9":
+ {
+ "6":
+ {
+ "Description": "Failing PSU number",
+ "AdditionalDataPropSource": "PSU_NUM"
+ }
+ }
+ }
+ },
+ "additionalProperties": false
+ }
+
+ }
+}
diff --git a/extensions/openpower-pels/registry/tools/process_registry.py b/extensions/openpower-pels/registry/tools/process_registry.py
new file mode 100755
index 0000000..09ad3e0
--- /dev/null
+++ b/extensions/openpower-pels/registry/tools/process_registry.py
@@ -0,0 +1,167 @@
+#!/usr/bin/env python
+
+import argparse
+import json
+import sys
+
+r"""
+Validates the PEL message registry JSON, which includes checking it against
+a JSON schema using the jsonschema module as well as doing some extra checks
+that can't be encoded in the schema.
+"""
+
+
+def check_duplicate_names(registry_json):
+ r"""
+ Check that there aren't any message registry entries with the same
+ 'Name' field. There may be a use case for this in the future, but there
+ isn't right now.
+
+ registry_json: The message registry JSON
+ """
+
+ names = {}
+ for entry in registry_json['PELs']:
+ if entry['Name'] in names.keys():
+ sys.exit("Found multiple uses of error {}".format(entry['Name']))
+ else:
+ names[entry['Name']] = {}
+
+
+def check_duplicate_reason_codes(registry_json):
+ r"""
+ Check that there aren't any message registry entries with the same
+ 'ReasonCode' field.
+
+ registry_json: The message registry JSON
+ """
+
+ reasonCodes = {}
+ for entry in registry_json['PELs']:
+ if entry['SRC']['ReasonCode'] in reasonCodes.keys():
+ sys.exit("Found duplicate SRC reason code {}".format(
+ entry['SRC']['ReasonCode']))
+ else:
+ reasonCodes[entry['SRC']['ReasonCode']] = {}
+
+
+def check_component_id(registry_json):
+ r"""
+ Check that the upper byte of the ComponentID field matches the upper byte
+ of the ReasonCode field, but not on "11" type SRCs where they aren't
+ supposed to match.
+
+ registry_json: The message registry JSON
+ """
+
+ for entry in registry_json['PELs']:
+
+ # Don't check on "11" SRCs as those reason codes aren't supposed to
+ # match the component ID.
+ if entry.get('Type', '') == "11":
+ continue
+
+ if 'ComponentID' in entry:
+ id = int(entry['ComponentID'], 16)
+ reason_code = int(entry['SRC']['ReasonCode'], 16)
+
+ if (id & 0xFF00) != (reason_code & 0xFF00):
+ sys.exit("Found mismatching component ID {} vs reason "
+ "code {} for error {}".format(
+ entry['ComponentID'],
+ entry['SRC']['ReasonCode'],
+ entry['Name']))
+
+
+def check_message_args(registry_json):
+ r"""
+ Check that if the Message field uses the '%' style placeholders that there
+ are that many entries in the MessageArgSources field. Also checks that
+ the MessageArgSources field is present but only if there are placeholders.
+
+ registry_json: The message registry JSON
+ """
+
+ for entry in registry_json['PELs']:
+ num_placeholders = entry['Documentation']['Message'].count('%')
+ if num_placeholders == 0:
+ continue
+
+ if 'MessageArgSources' not in entry['Documentation']:
+ sys.exit("Missing MessageArgSources property for error {}".
+ format(entry['Name']))
+
+ if num_placeholders != \
+ len(entry['Documentation']['MessageArgSources']):
+ sys.exit("Different number of placeholders found in "
+ "Message vs MessageArgSources for error {}".
+ format(entry['Name']))
+
+
+def validate_schema(registry, schema):
+ r"""
+ Validates the passed in JSON against the passed in schema JSON
+
+ registry: Path of the file containing the registry JSON
+ schema: Path of the file containing the schema JSON
+ Use None to skip the pure schema validation
+ """
+
+ with open(registry) as registry_handle:
+ registry_json = json.load(registry_handle)
+
+ if schema:
+
+ import jsonschema
+
+ with open(schema) as schema_handle:
+ schema_json = json.load(schema_handle)
+
+ try:
+ jsonschema.validate(registry_json, schema_json)
+ except jsonschema.ValidationError as e:
+ print(e)
+ sys.exit("Schema validation failed")
+
+ check_duplicate_names(registry_json)
+
+ check_duplicate_reason_codes(registry_json)
+
+ check_component_id(registry_json)
+
+ check_message_args(registry_json)
+
+
+if __name__ == '__main__':
+
+ parser = argparse.ArgumentParser(
+ description='PEL message registry processor')
+
+ parser.add_argument('-v', '--validate', action='store_true',
+ dest='validate',
+ help='Validate the JSON using the schema')
+
+ parser.add_argument('-s', '--schema-file', dest='schema_file',
+ help='The message registry JSON schema file')
+
+ parser.add_argument('-r', '--registry-file', dest='registry_file',
+ help='The message registry JSON file')
+ parser.add_argument('-k', '--skip-schema-validation', action='store_true',
+ dest='skip_schema',
+ help='Skip running schema validation. '
+ 'Only do the extra checks.')
+
+ args = parser.parse_args()
+
+ if args.validate:
+ if not args.schema_file:
+ sys.exit("Schema file required")
+
+ if not args.registry_file:
+ sys.exit("Registry file required")
+
+ schema = args.schema_file
+ if args.skip_schema:
+ schema = None
+
+ validate_schema(args.registry_file, schema)
OpenPOWER on IntegriCloud