PCIe CPER Section Enhancement
This commit improves PCIe error reporting capabilities by:
- Adding support for PCIe capability version detection and parsing
- Expanding Advanced Error Reporting information extraction
The changes include:
- New capability_registers structure to decode PCIe capability registers
- Updated PCIe JSON Schema to match
- Support for PCIe 2.0+ extended registers when detected
- Improved error source identification and root error status reporting
- Fix typo for Advanced Error Reporting capabilit[i]es_control
- Updated generate/gen-section-pcie.c and pcie.json example
In the future we could:
- Implement TLP header log parsing with detailed descriptions
- Add support for Flit mode in PCIe 2.0+ devices
Tested:
- test/cper-tests passes
- cper-convert to-json|to-cper on pcie.cper|json in example path
- Tested "cper-convert to-json-section" using an extracted OS GHES PCIE
CPER from error injection and compare against expected values
Note, schema validation is intentionally less restrictive than it could
be for pcie advanced error reporting as it evolves.
Change-Id: Ifebb9d97d28a3a487a0aab53bf9e757afeedd64a
Signed-off-by: Erwin Tsaur <etsaur@nvidia.com>
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/cper-utils.c b/cper-utils.c
index f6adbdb..01c1f7e 100644
--- a/cper-utils.c
+++ b/cper-utils.c
@@ -491,3 +491,47 @@
json_object_new_string_len(platform_string,
sizeof(platform_string) - 1));
}
+
+void add_int(json_object *register_ir, const char *field_name, int value)
+{
+ json_object_object_add(register_ir, field_name,
+ json_object_new_uint64(value));
+}
+
+void add_bool(json_object *register_ir, const char *field_name, UINT64 value)
+{
+ json_object_object_add(register_ir, field_name,
+ json_object_new_boolean(value));
+}
+
+void add_bool_enum(json_object *register_ir, const char *field_name,
+ const char *value_dict[2], UINT64 value_int)
+{
+ const char *value = value_dict[0];
+ if (value_int > 0) {
+ value = value_dict[1];
+ }
+ json_object_object_add(register_ir, field_name,
+ json_object_new_string(value));
+}
+
+void add_dict(json_object *register_ir, const char *field_name, UINT64 value,
+ const char *dict[], size_t dict_size)
+{
+ json_object *field_ir = json_object_new_object();
+ json_object_object_add(register_ir, field_name, field_ir);
+ json_object_object_add(field_ir, "raw", json_object_new_uint64(value));
+
+ if (dict != NULL) {
+ if (value < dict_size) {
+ const char *name = dict[value];
+ if (name != NULL) {
+ const char *value_name = name;
+
+ json_object_object_add(
+ field_ir, "value",
+ json_object_new_string(value_name));
+ }
+ }
+ }
+}