[SWDEV-553168] Add support for decoding out of band boot time CPER files.

Change-Id: Ic4278698f9c5b5ae56bd56fd43150c0653c1ef05
Ta zmiana jest zawarta w:
Oosman Saeed authored and Arif, Maisam committed 2025-10-07 22:23:33 -05:00
1 rodzic c4cad504be
złożenie c6698c9100
28 plików zmienionych
+2438 -649

Żadne pliki nie pasują do Twojego wyszukiwania

-119
Wyświetl plik
@@ -1,119 +0,0 @@
/*
* Copyright (c) Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @file aca_constants.h
* @brief Shared constants for ACA error decoding
*
* This file contains string constants and numerical constants that are used
* across multiple source files to improve maintainability and prevent typos.
*/
#ifndef ACA_CONSTANTS_H
#define ACA_CONSTANTS_H
/* Error severity constants */
#define ACA_SEVERITY_UNKNOWN "UNKNOWN"
#define ACA_SEVERITY_FATAL "Fatal"
#define ACA_SEVERITY_CORRECTED "Corrected"
#define ACA_SEVERITY_UNCORRECTED_NON_FATAL "Uncorrected, Non-fatal"
#define ACA_SEVERITY_FAIL_TO_INIT "Fail-to-init"
#define ACA_SEVERITY_ALL_CAPS "ALL"
/* Error category constants */
#define ACA_CATEGORY_HBM_ERRORS "HBM Errors"
#define ACA_CATEGORY_DEVICE_INTERNAL_ERRORS "Device Internal Errors"
#define ACA_CATEGORY_OFF_PACKAGE_LINK_ERRORS "Off-Package Link Errors"
#define ACA_CATEGORY_BOOT_TIME_ERRORS "Boot-Time Errors"
#define ACA_CATEGORY_CPER_FORMAT "CPER Format"
#define ACA_CATEGORY_UNIDENTIFIED_ERRORS "Unidentified Errors"
/* Common error type constants */
#define ACA_ERROR_TYPE_ALL_OTHERS "All Others"
#define ACA_ERROR_TYPE_ALL "All"
#define ACA_ERROR_TYPE_DECODE_INAPPLICABLE "Decode Inapplicable"
#define ACA_ERROR_TYPE_BAD_PAGE_RETIREMENT_THRESHOLD "Bad Page Retirement Threshold"
#define ACA_ERROR_TYPE_HARDWARE_ASSERTION "Hardware Assertion (HWA)"
#define ACA_ERROR_TYPE_WATCHDOG_TIMEOUT "Watchdog Timeout (WDT)"
#define ACA_ERROR_TYPE_ON_DIE_ECC "On-die ECC"
#define ACA_ERROR_TYPE_END_TO_END_CRC "End-to-end CRC"
#define ACA_ERROR_TYPE_WAFL "WAFL"
#define ACA_ERROR_TYPE_XGMI "XGMI"
/* Boot-time error type constants */
#define ACA_ERROR_TYPE_FW_LOAD "FW Load"
#define ACA_ERROR_TYPE_HBM_BIST_TEST "HBM BIST Test"
#define ACA_ERROR_TYPE_HBM_MEMORY_TEST "HBM Memory Test"
#define ACA_ERROR_TYPE_HBM_TRAINING "HBM Training"
#define ACA_ERROR_TYPE_UNHANDLED "Unhandled"
#define ACA_ERROR_TYPE_UNKNOWN_ERROR "Unknown"
#define ACA_ERROR_TYPE_USR_CP_LINK_TRAINING "USR CP Link Training"
#define ACA_ERROR_TYPE_USR_DP_LINK_TRAINING "USR DP Link Training"
#define ACA_ERROR_TYPE_WAFL_LINK_TRAINING "WAFL Link Training"
#define ACA_ERROR_TYPE_XGMI_LINK_TRAINING "XGMI Link Training"
#define ACA_ERROR_TYPE_BOOT_CONTROLLER_DATA_ABORT "Boot Controller Data Abort"
#define ACA_ERROR_TYPE_BOOT_CONTROLLER_GENERIC "Boot Controller Generic"
/* Link error type constants */
#define ACA_ERROR_TYPE_PCIE_AER "PCIe AER"
/* CPER format error type constants */
#define ACA_ERROR_TYPE_MALFORMED_CPER "Malformed CPER"
#define ACA_ERROR_TYPE_INCOMPLETE_ACA_DATA "Incomplete ACA Data"
#define ACA_ERROR_TYPE_INVALID_ACA_DATA "Invalid ACA Data"
#define ACA_ERROR_TYPE_UNIDENTIFIED_ERROR "Unidentified Error"
/* Protocol constants */
#define ACA_PROTOCOL_CPER "CPER"
#define ACA_PROTOCOL_CPER_WITH_SPACE "CPER "
/* Bank name strings */
#define ACA_BANK_UMC "umc"
#define ACA_BANK_PSP "psp"
#define ACA_BANK_CS "cs"
#define ACA_BANK_PIE "pie"
#define ACA_BANK_PCS_XGMI "pcs_xgmi"
#define ACA_BANK_KPX_SERDES "kpx_serdes"
#define ACA_BANK_KPX_WAFL "kpx_wafl"
/* Numerical constants */
#define ACA_FLAG_THRESHOLD_EXCEEDED 0x8
#define ACA_REGISTER_ARRAY_SIZE_32_BYTES 4
#define ACA_REGISTER_ARRAY_SIZE_128_BYTES 16
/* Error code ranges */
#define ACA_ERROR_CODE_EXT_MIN 0x3A
#define ACA_ERROR_CODE_EXT_MAX 0x3E
/* Instance ID values for XCD and AID error decoding */
#define ACA_INSTANCE_ID_XCD0_400 0x36430400
#define ACA_INSTANCE_ID_XCD1_400 0x38430400
#define ACA_INSTANCE_ID_XCD0_401 0x36430401
#define ACA_INSTANCE_ID_XCD1_401 0x38430401
#define ACA_INSTANCE_ID_AID_400 0x3B30400
#define ACA_INSTANCE_ID_AID_401 0x3B30401
/* Error return codes */
#define ACA_ERROR_INVALID_ACA_DATA_ID 33
#define ACA_ERROR_UNIDENTIFIED_ERROR_ID 34
#endif /* ACA_CONSTANTS_H */
-60
Wyświetl plik
@@ -1,60 +0,0 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @file utils.h
* @brief Common utility functions
*/
#ifndef UTILS_H
#define UTILS_H
#include <stdint.h>
/**
* @brief Convert a 64-bit value from little endian to big endian
* @param[in] value Value to convert
* @return Converted value in big endian
*/
static inline uint64_t le64_to_be64(uint64_t value) {
return ((value & 0xFF00000000000000ULL) >> 56) |
((value & 0x00FF000000000000ULL) >> 40) |
((value & 0x0000FF0000000000ULL) >> 24) |
((value & 0x000000FF00000000ULL) >> 8) |
((value & 0x00000000FF000000ULL) << 8) |
((value & 0x0000000000FF0000ULL) << 24) |
((value & 0x000000000000FF00ULL) << 40) |
((value & 0x00000000000000FFULL) << 56);
}
/**
* @brief Convert an array of 64-bit values from little endian to big endian
* @param[in,out] array Array to convert
* @param[in] len Length of the array
*/
static inline void convert_array_le_to_be(uint64_t *array, size_t len) {
for (size_t i = 0; i < len; i++) {
array[i] = le64_to_be64(array[i]);
}
}
#endif /* UTILS_H */
+9 -17
Wyświetl plik
@@ -1,4 +1,3 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) Advanced Micro Devices, Inc. All rights reserved.
*
@@ -21,20 +20,16 @@
* THE SOFTWARE.
*/
/**
/**
* @file aca_decode.h
* @brief Internal decoder interface and data structures
*/
#ifndef RAS_DECODE_DECODE_H
#define RAS_DECODE_DECODE_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef ACA_DECODE_H
#define ACA_DECODE_H
#include "aca_api.h"
#include "ras_decode_api.h"
#include "aca_fields.h"
#include "json_util.h"
/**
* @brief Internal decoder structure with parsed register fields
@@ -67,13 +62,10 @@ typedef struct
} aca_raw_data_t;
/**
* @brief Main decode function that processes raw ACA error data
* @brief Main decode function that processes raw ACA error data and returns JSON
* @param[in] raw_data Pointer to structure containing raw ACA error data
* @return Decoded error information structure
* @return JsonValue* containing the decoded error information, or NULL on failure
*/
aca_error_info_t aca_decode(const aca_raw_data_t *raw_data);
JsonValue* aca_decode(const aca_raw_data_t *raw_data);
#ifdef __cplusplus
}
#endif
#endif /* ACA_DECODE_H */
#endif /* RAS_DECODE_DECODE_H */
@@ -1,4 +1,3 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) Advanced Micro Devices, Inc. All rights reserved.
*
@@ -21,7 +20,7 @@
* THE SOFTWARE.
*/
/**
/**
* @file aca_fields.h
* @brief ACA register field definitions and manipulation functions
*
@@ -30,8 +29,8 @@
* definitions for status, IPID, and syndrome registers, along with
* functions to initialize and access these fields.
*/
#ifndef ACA_FIELDS_H
#define ACA_FIELDS_H
#ifndef RAS_DECODE_FIELDS_H
#define RAS_DECODE_FIELDS_H
#include <stdint.h>
@@ -1,4 +1,3 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) Advanced Micro Devices, Inc. All rights reserved.
*
@@ -28,8 +27,8 @@
* into their corresponding names and types.
*/
#ifndef ACA_TABLES_H
#define ACA_TABLES_H
#ifndef RAS_DECODE_TABLES_H
#define RAS_DECODE_TABLES_H
#include <stdint.h>
#include <stddef.h>
@@ -20,8 +20,8 @@
* THE SOFTWARE.
*/
#ifndef ACA_VERSION_H
#define ACA_VERSION_H
#ifndef RAS_DECODE_VERSION_H
#define RAS_DECODE_VERSION_H
#ifdef __cplusplus
extern "C"
@@ -40,12 +40,19 @@ extern "C"
*/
/* Version Components */
#define ACA_VERSION_MAJOR 1 /**< Major version number */
#define ACA_VERSION_MINOR 0 /**< Minor version number */
#define ACA_VERSION_PATCH 0 /**< Patch version number */
#define RAS_DECODE_VERSION_MAJOR 2 /**< Major version number */
#define RAS_DECODE_VERSION_MINOR 0 /**< Minor version number */
#define RAS_DECODE_VERSION_PATCH 0 /**< Patch version number */
/* Version String */
#define ACA_VERSION_STRING "1.0.0"
/* Helper macros for string concatenation */
#define RAS_DECODE_STRINGIFY(x) #x
#define RAS_DECODE_TOSTRING(x) RAS_DECODE_STRINGIFY(x)
/* Version String - dynamically constructed from components */
#define RAS_DECODE_VERSION_STRING \
RAS_DECODE_TOSTRING(RAS_DECODE_VERSION_MAJOR) "." \
RAS_DECODE_TOSTRING(RAS_DECODE_VERSION_MINOR) "." \
RAS_DECODE_TOSTRING(RAS_DECODE_VERSION_PATCH)
/**
* @brief Structure containing version information
@@ -92,4 +99,4 @@ extern "C"
}
#endif
#endif /* ACA_VERSION_H */
#endif /* RAS_DECODE_VERSION_H */
+219
Wyświetl plik
@@ -0,0 +1,219 @@
/*
* Copyright (c) Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef BOOT_DECODE_H
#define BOOT_DECODE_H
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "json_util.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Boot message structure representing OAM boot message
*/
typedef struct {
uint64_t value; ///< 64-bit boot message value
} OamBootMsg;
/**
* @brief Decoder function pointer type
* @param msg Boot message to decode
* @return JsonValue containing decoded information or NULL on failure
*/
typedef JsonValue* (*boot_decoder_func_t)(OamBootMsg *msg);
/**
* @brief Decoder mapping entry
*/
typedef struct {
uint8_t encoding; ///< Error encoding value
boot_decoder_func_t decoder; ///< Decoder function
} boot_decoder_entry_t;
/**
* @brief Boot message constants
*/
#define BOOT_ERROR_PRESENT_MARKER 0xA4
#define BOOT_IN_BOOT_MARKER 0xBA
#define BOOT_SUCCESS_ENCODING 0xBA
/**
* @brief Error encoding constants
*/
#define BOOT_ENCODING_HBM_TRAINING 0x01
#define BOOT_ENCODING_FW_LOAD 0x04
#define BOOT_ENCODING_WAFL_LINK 0x05
#define BOOT_ENCODING_XGMI_LINK 0x06
#define BOOT_ENCODING_USR_CP_LINK 0x07
#define BOOT_ENCODING_USR_DP_LINK 0x08
#define BOOT_ENCODING_HBM_MEM_TEST 0x09
#define BOOT_ENCODING_HBM_BIST_TEST 0x0A
#define BOOT_ENCODING_BOOT_CTRL_GEN_V0 0x0B
#define BOOT_ENCODING_BOOT_CTRL_GEN_V1 0x0C
#define BOOT_ENCODING_DATA_ABORT 0x0D
/**
* @brief HBM stack decoder constants
*/
#define HBM_STACK_0 0x01
#define HBM_STACK_1 0x02
#define HBM_STACK_UNKNOWN -1
/**
* @brief Extract specific byte from 64-bit value
* @param value 64-bit value
* @param byte_index Byte index (0-7)
* @return Extracted byte value
*/
static inline uint8_t extract_byte(uint64_t value, int byte_index) {
return (uint8_t)((value >> (byte_index * 8)) & 0xFF);
}
/**
* @brief Extract specific bits mask
* @param num_bits Number of bits to extract
* @return Bit mask
*/
static inline uint32_t extract_bits(int num_bits) {
return (1U << num_bits) - 1;
}
/**
* @brief Get boot version from boot message
* @param msg Boot message
* @return Boot version (0 or 1)
*/
int get_boot_version(OamBootMsg *msg);
/**
* @brief Get error encoding from boot message
* @param msg Boot message
* @return Error encoding value
*/
int get_error_encoding(OamBootMsg *msg);
/**
* @brief Check if error is present in boot message
* @param msg Boot message
* @return true if error present, false otherwise
*/
bool error_present(OamBootMsg *msg);
/**
* @brief Check if in boot mode
* @param msg Boot message
* @return true if in boot mode, false otherwise
*/
bool in_boot(OamBootMsg *msg);
/**
* @brief Get socket number from boot message
* @param msg Boot message
* @param version Boot version
* @return Socket number
*/
int get_socket(OamBootMsg *msg, int version);
/**
* @brief Get AID number from boot message
* @param msg Boot message
* @param version Boot version
* @return AID number
*/
int get_aid(OamBootMsg *msg, int version);
/**
* @brief Decode HBM stack value
* @param stack Stack value
* @return Decoded stack number or HBM_STACK_UNKNOWN
*/
int decode_hbm_stack(uint8_t stack);
/**
* @brief Create JSON array of failed links
* @param byte_value Byte containing link status bits
* @param max_links Maximum number of links to check
* @return JsonValue array or NULL on failure
*/
JsonValue* create_failed_links_array(uint8_t byte_value, int max_links);
/**
* @brief Create hex string representation
* @param value Value to convert
* @param width Width of hex string (with padding)
* @return Dynamically allocated hex string or NULL on failure
*/
char* create_hex_string(uint64_t value, int width);
// Decoder functions for Version 0
JsonValue* decode_hbm_training_v0(OamBootMsg *msg);
JsonValue* decode_fw_load_v0(OamBootMsg *msg);
JsonValue* decode_wafl_link_training_v0(OamBootMsg *msg);
JsonValue* decode_xgmi_link_training_v0(OamBootMsg *msg);
JsonValue* decode_usr_cp_link_training_v0(OamBootMsg *msg);
JsonValue* decode_usr_dp_link_training_v0(OamBootMsg *msg);
JsonValue* decode_hbm_mem_test_v0(OamBootMsg *msg);
JsonValue* decode_hbm_bist_test_v0(OamBootMsg *msg);
JsonValue* decode_boot_controller_generic_v0(OamBootMsg *msg);
// Decoder functions for Version 1
JsonValue* decode_hbm_training_v1(OamBootMsg *msg);
JsonValue* decode_fw_load_v1(OamBootMsg *msg);
JsonValue* decode_wafl_link_training_v1(OamBootMsg *msg);
JsonValue* decode_xgmi_link_training_v1(OamBootMsg *msg);
JsonValue* decode_usr_cp_link_training_v1(OamBootMsg *msg);
JsonValue* decode_usr_dp_link_training_v1(OamBootMsg *msg);
JsonValue* decode_hbm_mem_test_v1(OamBootMsg *msg);
JsonValue* decode_hbm_bist_test_v1(OamBootMsg *msg);
JsonValue* decode_boot_controller_generic_v1(OamBootMsg *msg);
JsonValue* decode_data_abort_v1(OamBootMsg *msg);
JsonValue* decode_boot_success_v1(OamBootMsg *msg);
// Unhandled error decoders
JsonValue* decode_unhandled_error_v0(OamBootMsg *msg);
JsonValue* decode_unhandled_error_v1(OamBootMsg *msg);
/**
* @brief Get appropriate decoder function for boot message
* @param msg Boot message
* @return Decoder function pointer or NULL if no decoder found
*/
boot_decoder_func_t get_decoder_function(OamBootMsg *msg);
/**
* @brief Orchestrate decoding of multiple boot messages
* @param oam_boot_msgs Array of boot message values
* @param count Number of boot messages
* @return JsonValue object containing decoded results or NULL on failure
*/
JsonValue* boot_decode_orchestrator(uint64_t *oam_boot_msgs, size_t count);
#ifdef __cplusplus
}
#endif
#endif /* BOOT_DECODE_H */
@@ -1,4 +1,3 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) Advanced Micro Devices, Inc. All rights reserved.
*
+42
Wyświetl plik
@@ -0,0 +1,42 @@
/*
* Copyright (c) Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef JSON_PRINTER_H
#define JSON_PRINTER_H
#include "json_util.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Print a JSON value to stdout in formatted form
* @param value JSON value to print
*/
void print_json_value(JsonValue *value);
#ifdef __cplusplus
}
#endif
#endif /* JSON_PRINTER_H */
+171
Wyświetl plik
@@ -0,0 +1,171 @@
/*
* Copyright (c) Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef JSON_UTIL_H
#define JSON_UTIL_H
#include <stdbool.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief JSON value types enumeration
*/
typedef enum {
JSON_NULL,
JSON_BOOL,
JSON_NUMBER,
JSON_STRING,
JSON_OBJECT,
JSON_ARRAY
} JsonType;
typedef struct JsonValue JsonValue;
typedef struct JsonPair JsonPair;
/**
* @brief JSON key-value pair structure for objects
*/
struct JsonPair {
char *key;
JsonValue *value;
JsonPair *next;
};
/**
* @brief JSON value structure
*/
struct JsonValue {
JsonType type;
union {
bool boolean;
double number;
char *string;
JsonPair *object; // Linked list of key-value pairs
struct {
JsonValue **items;
size_t count;
size_t capacity;
} array;
} data;
};
/**
* @brief Create a null JSON value
* @return Pointer to new JsonValue or NULL on failure
*/
JsonValue* json_create_null(void);
/**
* @brief Create a boolean JSON value
* @param b Boolean value
* @return Pointer to new JsonValue or NULL on failure
*/
JsonValue* json_create_bool(bool b);
/**
* @brief Create a number JSON value
* @param num Numeric value
* @return Pointer to new JsonValue or NULL on failure
*/
JsonValue* json_create_number(double num);
/**
* @brief Create a string JSON value
* @param str String value (will be copied)
* @return Pointer to new JsonValue or NULL on failure
*/
JsonValue* json_create_string(const char *str);
/**
* @brief Create an empty JSON object
* @return Pointer to new JsonValue or NULL on failure
*/
JsonValue* json_create_object(void);
/**
* @brief Create an empty JSON array
* @return Pointer to new JsonValue or NULL on failure
*/
JsonValue* json_create_array(void);
/**
* @brief Add a key-value pair to a JSON object
* @param obj JSON object to modify
* @param key Key string (will be copied)
* @param value Value to add
*/
void json_object_set(JsonValue *obj, const char *key, JsonValue *value);
/**
* @brief Get a value by key from a JSON object
* @param obj JSON object to search
* @param key Key to search for
* @return Pointer to JsonValue or NULL if not found
*/
JsonValue* json_object_get(JsonValue *obj, const char *key);
/**
* @brief Check if a key exists in a JSON object
* @param obj JSON object to check
* @param key Key to check for
* @return true if key exists, false otherwise
*/
bool json_object_has_key(JsonValue *obj, const char *key);
/**
* @brief Add a value to a JSON array
* @param arr JSON array to modify
* @param value Value to add
* @return true on success, false on failure
*/
bool json_array_push(JsonValue *arr, JsonValue *value);
/**
* @brief Get a value by index from a JSON array
* @param arr JSON array to access
* @param index Array index
* @return Pointer to JsonValue or NULL if index out of bounds
*/
JsonValue* json_array_get(JsonValue *arr, size_t index);
/**
* @brief Get the size of a JSON array
* @param arr JSON array
* @return Number of elements in array, or 0 if not an array
*/
size_t json_array_size(JsonValue *arr);
/**
* @brief Free a JSON value and all its contents
* @param val JSON value to free
*/
void json_free(JsonValue *val);
#ifdef __cplusplus
}
#endif
#endif /* JSON_UTIL_H */
@@ -1,4 +1,3 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) Advanced Micro Devices, Inc. All rights reserved.
*
@@ -21,11 +20,13 @@
* THE SOFTWARE.
*/
#ifndef ACA_API_H
#define ACA_API_H
#ifndef RAS_DECODE_API_H
#define RAS_DECODE_API_H
#include <stdint.h>
#include <stddef.h>
#include "aca_version.h"
#include "json_util.h"
/**
* @brief Structure containing decoded error information
@@ -39,12 +40,13 @@ typedef struct
const char *instance_ref; /**< Reference to instance name string */
int oam; /**< OAM value */
int aid; /**< AID value */
int afid; /**< AFID value (AMD Field ID) */
uint64_t raw_status; /**< Raw status register value */
uint64_t raw_addr; /**< Raw address register value */
uint64_t raw_ipid; /**< Raw IPID register value */
uint64_t raw_synd; /**< Raw syndrome register value */
uint8_t scrub; /**< Scrub bit from status */
uint8_t poison; /**< Poison bit from status */
uint8_t deferred; /**< Deferred bit from status */
uint8_t error_code_ext; /**< Extended error code from status */
} aca_error_info_t;
@@ -54,18 +56,27 @@ typedef struct
* @param[in] array_len Size of register array in elements
* @param[in] flag Decoder flags
* @param[in] hw_revision Hardware revision number
* @param[in] register_context_type Register context type (16-bit): 1 for ACA decode, 9 for boot decode
* @return AFID value or -1 if decoding fails
*/
int decode_afid(const uint64_t *register_array, size_t array_len, uint32_t flag, uint16_t hw_revision);
int decode_afid(const uint64_t *register_array, size_t array_len, uint32_t flag, uint16_t hw_revision, uint16_t register_context_type);
/**
* @brief Decodes and returns complete error information from a register array
* @brief Decodes and returns complete error information from a register array as JSON
* @param[in] register_array Pointer to an array of 64-bit register values
* @param[in] array_len Size of register array in elements
* @param[in] flag Decoder flags
* @param[in] hw_revision Hardware revision number
* @return Complete error information structure
* @param[in] register_context_type Register context type (16-bit): 1 for ACA decode, 9 for boot decode
* @return JsonValue* containing complete error information, or NULL on failure
*/
aca_error_info_t decode_error_info(const uint64_t *register_array, size_t array_len, uint32_t flag, uint16_t hw_revision);
JsonValue* decode_error_info(const uint64_t *register_array, size_t array_len, uint32_t flag, uint16_t hw_revision, uint16_t register_context_type);
#endif // ACA_API_H
/**
* @brief Decodes the AFID from a JSON error object based on error category, type, and severity
* @param[in] error_json Pointer to JSON object containing error information
* @return AFID value or -1 if decoding fails or JSON is NULL
*/
int decode_error_info_afid(JsonValue *error_json);
#endif // RAS_DECODE_API_H
+121
Wyświetl plik
@@ -0,0 +1,121 @@
/*
* Copyright (c) Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @file ras_decode_constants.h
* @brief Shared constants for ACA error decoding
*
* This file contains string constants and numerical constants that are used
* across multiple source files to improve maintainability and prevent typos.
*/
#ifndef RAS_DECODE_CONSTANTS_H
#define RAS_DECODE_CONSTANTS_H
/* Error severity constants */
#define RAS_DECODE_SEVERITY_UNKNOWN "UNKNOWN"
#define RAS_DECODE_SEVERITY_FATAL "Fatal"
#define RAS_DECODE_SEVERITY_CORRECTED "Corrected"
#define RAS_DECODE_SEVERITY_UNCORRECTED_NON_FATAL "Uncorrected, Non-fatal"
#define RAS_DECODE_SEVERITY_FAIL_TO_INIT "Fail-to-init"
#define RAS_DECODE_SEVERITY_ALL_CAPS "ALL"
/* Error category constants */
#define RAS_DECODE_CATEGORY_HBM_ERRORS "HBM Errors"
#define RAS_DECODE_CATEGORY_DEVICE_INTERNAL_ERRORS "Device Internal Errors"
#define RAS_DECODE_CATEGORY_OFF_PACKAGE_LINK_ERRORS "Off-Package Link Errors"
#define RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS "Boot-Time Errors"
#define RAS_DECODE_CATEGORY_CPER_FORMAT "CPER Format"
#define RAS_DECODE_CATEGORY_UNIDENTIFIED_ERRORS "Unidentified Errors"
/* Common error type constants */
#define RAS_DECODE_ERROR_TYPE_ALL_OTHERS "All Others"
#define RAS_DECODE_ERROR_TYPE_ALL "All"
#define RAS_DECODE_ERROR_TYPE_DECODE_INAPPLICABLE "Decode Inapplicable"
#define RAS_DECODE_ERROR_TYPE_BAD_PAGE_RETIREMENT_THRESHOLD "Bad Page Retirement Threshold"
#define RAS_DECODE_ERROR_TYPE_HARDWARE_ASSERTION "Hardware Assertion (HWA)"
#define RAS_DECODE_ERROR_TYPE_WATCHDOG_TIMEOUT "Watchdog Timeout (WDT)"
#define RAS_DECODE_ERROR_TYPE_ON_DIE_ECC "On-die ECC"
#define RAS_DECODE_ERROR_TYPE_END_TO_END_CRC "End-to-end CRC"
#define RAS_DECODE_ERROR_TYPE_WAFL "WAFL"
#define RAS_DECODE_ERROR_TYPE_XGMI "XGMI"
/* Boot-time error type constants */
#define RAS_DECODE_ERROR_TYPE_FW_LOAD "FW Load"
#define RAS_DECODE_ERROR_TYPE_HBM_BIST_TEST "HBM BIST Test"
#define RAS_DECODE_ERROR_TYPE_HBM_MEMORY_TEST "HBM Memory Test"
#define RAS_DECODE_ERROR_TYPE_HBM_TRAINING "HBM Training"
#define RAS_DECODE_ERROR_TYPE_UNHANDLED "Unhandled"
#define RAS_DECODE_ERROR_TYPE_UNKNOWN_ERROR "Unknown"
#define RAS_DECODE_ERROR_TYPE_USR_CP_LINK_TRAINING "USR CP Link Training"
#define RAS_DECODE_ERROR_TYPE_USR_DP_LINK_TRAINING "USR DP Link Training"
#define RAS_DECODE_ERROR_TYPE_WAFL_LINK_TRAINING "WAFL Link Training"
#define RAS_DECODE_ERROR_TYPE_XGMI_LINK_TRAINING "XGMI Link Training"
#define RAS_DECODE_ERROR_TYPE_BOOT_CONTROLLER_DATA_ABORT "Boot Controller Data Abort"
#define RAS_DECODE_ERROR_TYPE_BOOT_CONTROLLER_GENERIC "Boot Controller Generic"
#define RAS_DECODE_ERROR_TYPE_BOOT_SUCCESS "Boot Success"
/* Link error type constants */
#define RAS_DECODE_ERROR_TYPE_PCIE_AER "PCIe AER"
/* CPER format error type constants */
#define RAS_DECODE_ERROR_TYPE_MALFORMED_CPER "Malformed CPER"
#define RAS_DECODE_ERROR_TYPE_INCOMPLETE_RAS_DECODE_DATA "Incomplete ACA Data"
#define RAS_DECODE_ERROR_TYPE_INVALID_RAS_DECODE_DATA "Invalid ACA Data"
#define RAS_DECODE_ERROR_TYPE_UNIDENTIFIED_ERROR "Unidentified Error"
/* Protocol constants */
#define RAS_DECODE_PROTOCOL_CPER "CPER"
#define RAS_DECODE_PROTOCOL_CPER_WITH_SPACE "CPER "
/* Bank name strings */
#define RAS_DECODE_BANK_UMC "umc"
#define RAS_DECODE_BANK_PSP "psp"
#define RAS_DECODE_BANK_CS "cs"
#define RAS_DECODE_BANK_PIE "pie"
#define RAS_DECODE_BANK_PCS_XGMI "pcs_xgmi"
#define RAS_DECODE_BANK_KPX_SERDES "kpx_serdes"
#define RAS_DECODE_BANK_KPX_WAFL "kpx_wafl"
/* Numerical constants */
#define RAS_DECODE_FLAG_THRESHOLD_EXCEEDED 0x8
#define RAS_DECODE_REGISTER_ARRAY_SIZE_32_BYTES 4
#define RAS_DECODE_REGISTER_ARRAY_SIZE_128_BYTES 16
#define BOOT_REGISTER_ARRAY_SIZE_64_BYTES 8
/* Error code ranges */
#define RAS_DECODE_ERROR_CODE_EXT_MIN 0x3A
#define RAS_DECODE_ERROR_CODE_EXT_MAX 0x3E
/* Instance ID values for XCD and AID error decoding */
#define RAS_DECODE_INSTANCE_ID_XCD0_400 0x36430400
#define RAS_DECODE_INSTANCE_ID_XCD1_400 0x38430400
#define RAS_DECODE_INSTANCE_ID_XCD0_401 0x36430401
#define RAS_DECODE_INSTANCE_ID_XCD1_401 0x38430401
#define RAS_DECODE_INSTANCE_ID_AID_400 0x3B30400
#define RAS_DECODE_INSTANCE_ID_AID_401 0x3B30401
/* Error return codes */
#define RAS_DECODE_ERROR_INVALID_RAS_DECODE_DATA_ID 33
#define RAS_DECODE_ERROR_UNIDENTIFIED_ERROR_ID 34
#endif /* RAS_DECODE_CONSTANTS_H */