Sync with latest ras-decode @bc6b43c (#770)
Signed-off-by: Oosman Saeed <oossaeed@amd.com>
This commit is contained in:
@@ -27,38 +27,36 @@
|
||||
#ifndef RAS_DECODE_DECODE_H
|
||||
#define RAS_DECODE_DECODE_H
|
||||
|
||||
#include "ras_decode_api.h"
|
||||
#include "aca_fields.h"
|
||||
#include "json_util.h"
|
||||
#include "ras_decode_api.h"
|
||||
|
||||
/**
|
||||
* @brief Internal decoder structure with parsed register fields
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint64_t aca_status; /**< Raw status register value */
|
||||
uint64_t aca_addr; /**< Raw address register value */
|
||||
uint64_t aca_ipid; /**< Raw IPID register value */
|
||||
uint64_t aca_synd; /**< Raw syndrome register value */
|
||||
uint32_t flags; /**< Decoder flags */
|
||||
uint16_t hw_revision; /**< Hardware hw_revision */
|
||||
typedef struct {
|
||||
uint64_t aca_status; /**< Raw status register value */
|
||||
uint64_t aca_addr; /**< Raw address register value */
|
||||
uint64_t aca_ipid; /**< Raw IPID register value */
|
||||
uint64_t aca_synd; /**< Raw syndrome register value */
|
||||
uint32_t flags; /**< Decoder flags */
|
||||
uint16_t hw_revision; /**< Hardware hw_revision */
|
||||
|
||||
aca_status_fields_t status; /**< Parsed status fields */
|
||||
aca_ipid_fields_t ipid; /**< Parsed IPID fields */
|
||||
aca_synd_fields_t synd; /**< Parsed syndrome fields */
|
||||
aca_status_fields_t status; /**< Parsed status fields */
|
||||
aca_ipid_fields_t ipid; /**< Parsed IPID fields */
|
||||
aca_synd_fields_t synd; /**< Parsed syndrome fields */
|
||||
} aca_decoder_t;
|
||||
|
||||
/**
|
||||
* @brief Structure containing raw ACA error data from hardware
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint64_t aca_status; /**< Raw status register value */
|
||||
uint64_t aca_addr; /**< Raw address register value */
|
||||
uint64_t aca_ipid; /**< Raw IPID register value */
|
||||
uint64_t aca_synd; /**< Raw syndrome register value */
|
||||
uint32_t flags; /**< Flags from descriptor */
|
||||
uint16_t hw_revision; /**< Hardware hw_revision number */
|
||||
typedef struct {
|
||||
uint64_t aca_status; /**< Raw status register value */
|
||||
uint64_t aca_addr; /**< Raw address register value */
|
||||
uint64_t aca_ipid; /**< Raw IPID register value */
|
||||
uint64_t aca_synd; /**< Raw syndrome register value */
|
||||
uint32_t flags; /**< Flags from descriptor */
|
||||
uint16_t hw_revision; /**< Hardware hw_revision number */
|
||||
} aca_raw_data_t;
|
||||
|
||||
/**
|
||||
@@ -66,6 +64,6 @@ typedef struct
|
||||
* @param[in] raw_data Pointer to structure containing raw ACA error data
|
||||
* @return JsonValue* containing the decoded error information, or NULL on failure
|
||||
*/
|
||||
JsonValue* aca_decode(const aca_raw_data_t *raw_data);
|
||||
JsonValue* aca_decode(const aca_raw_data_t* raw_data);
|
||||
|
||||
#endif /* RAS_DECODE_DECODE_H */
|
||||
|
||||
@@ -37,78 +37,73 @@
|
||||
/**
|
||||
* @brief Base structure for ACA fields containing raw register value
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint64_t raw_value; /**< Raw 64-bit register value */
|
||||
typedef struct {
|
||||
uint64_t raw_value; /**< Raw 64-bit register value */
|
||||
} aca_fields_t;
|
||||
|
||||
/**
|
||||
* @brief Structure containing decoded ACA status register fields
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
aca_fields_t base;
|
||||
uint16_t error_code;
|
||||
uint8_t error_code_ext;
|
||||
uint8_t reserv22;
|
||||
uint8_t addr_lsb;
|
||||
uint8_t reserv30;
|
||||
uint8_t err_core_id;
|
||||
uint8_t reserv38;
|
||||
uint8_t scrub;
|
||||
uint8_t reserv41;
|
||||
uint8_t poison;
|
||||
uint8_t deferred;
|
||||
uint8_t uecc;
|
||||
uint8_t cecc;
|
||||
uint8_t reserv47;
|
||||
uint8_t synd_v;
|
||||
uint8_t reserv54;
|
||||
uint8_t tcc;
|
||||
uint8_t err_core_id_val;
|
||||
uint8_t pcc;
|
||||
uint8_t addr_v;
|
||||
uint8_t misc_v;
|
||||
uint8_t en;
|
||||
uint8_t uc;
|
||||
uint8_t overflow;
|
||||
uint8_t val;
|
||||
typedef struct {
|
||||
aca_fields_t base;
|
||||
uint16_t error_code;
|
||||
uint8_t error_code_ext;
|
||||
uint8_t reserv22;
|
||||
uint8_t addr_lsb;
|
||||
uint8_t reserv30;
|
||||
uint8_t err_core_id;
|
||||
uint8_t reserv38;
|
||||
uint8_t scrub;
|
||||
uint8_t reserv41;
|
||||
uint8_t poison;
|
||||
uint8_t deferred;
|
||||
uint8_t uecc;
|
||||
uint8_t cecc;
|
||||
uint8_t reserv47;
|
||||
uint8_t synd_v;
|
||||
uint8_t reserv54;
|
||||
uint8_t tcc;
|
||||
uint8_t err_core_id_val;
|
||||
uint8_t pcc;
|
||||
uint8_t addr_v;
|
||||
uint8_t misc_v;
|
||||
uint8_t en;
|
||||
uint8_t uc;
|
||||
uint8_t overflow;
|
||||
uint8_t val;
|
||||
} aca_status_fields_t;
|
||||
|
||||
/**
|
||||
* @brief Structure containing decoded ACA IPID register fields
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
aca_fields_t base;
|
||||
uint32_t instance_id_lo;
|
||||
uint16_t hardware_id;
|
||||
uint16_t aca_type;
|
||||
uint8_t instance_id_hi;
|
||||
typedef struct {
|
||||
aca_fields_t base;
|
||||
uint32_t instance_id_lo;
|
||||
uint16_t hardware_id;
|
||||
uint16_t aca_type;
|
||||
uint8_t instance_id_hi;
|
||||
} aca_ipid_fields_t;
|
||||
|
||||
/**
|
||||
* @brief Structure containing decoded ACA syndrome register fields
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
aca_fields_t base;
|
||||
uint32_t error_information;
|
||||
uint8_t length;
|
||||
uint8_t error_priority;
|
||||
uint8_t reserved27;
|
||||
uint16_t syndrome;
|
||||
uint32_t reserved39;
|
||||
typedef struct {
|
||||
aca_fields_t base;
|
||||
uint32_t error_information;
|
||||
uint8_t length;
|
||||
uint8_t error_priority;
|
||||
uint8_t reserved27;
|
||||
uint16_t syndrome;
|
||||
uint32_t reserved39;
|
||||
} aca_synd_fields_t;
|
||||
|
||||
/**
|
||||
* @brief Structure containing decoded ACA address register fields
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
aca_fields_t base;
|
||||
uint64_t error_addr;
|
||||
uint64_t reserved;
|
||||
typedef struct {
|
||||
aca_fields_t base;
|
||||
uint64_t error_addr;
|
||||
uint64_t reserved;
|
||||
} aca_addr_fields_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,55 +30,50 @@
|
||||
#ifndef RAS_DECODE_TABLES_H
|
||||
#define RAS_DECODE_TABLES_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @brief Structure mapping hardware ID and ACA type to bank names
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t hw_id; /**< Hardware ID value */
|
||||
uint16_t aca_type; /**< ACA type identifier */
|
||||
const char *name; /**< Bank name string */
|
||||
typedef struct {
|
||||
uint16_t hw_id; /**< Hardware ID value */
|
||||
uint16_t aca_type; /**< ACA type identifier */
|
||||
const char *name; /**< Bank name string */
|
||||
} aca_bank_entry_t;
|
||||
|
||||
/**
|
||||
* @brief Structure mapping bank-specific error codes to error types
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
const char *bank; /**< Bank name string */
|
||||
uint32_t error_code; /**< Error code value */
|
||||
const char *type; /**< Error type string */
|
||||
typedef struct {
|
||||
const char *bank; /**< Bank name string */
|
||||
uint32_t error_code; /**< Error code value */
|
||||
const char *type; /**< Error type string */
|
||||
} aca_error_type_t;
|
||||
|
||||
/**
|
||||
* @brief Structure for generic error code to error type mapping
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t error_code; /**< Error code value */
|
||||
const char *type; /**< Error type string */
|
||||
typedef struct {
|
||||
uint32_t error_code; /**< Error code value */
|
||||
const char *type; /**< Error type string */
|
||||
} aca_error_entry_t;
|
||||
|
||||
/**
|
||||
* @brief Structure mapping instance_id_hi to OAM and AID values
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t oam; /**< OAM value */
|
||||
uint8_t aid; /**< AID value */
|
||||
typedef struct {
|
||||
uint8_t oam; /**< OAM value */
|
||||
uint8_t aid; /**< AID value */
|
||||
} oam_aid_map_t;
|
||||
|
||||
/**
|
||||
* @brief Structure for mapping bank and instance ID LO to instance name
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
const char *bank; /**< Bank name */
|
||||
uint32_t instance_id_lo; /**< Instance ID Lo (masked with 0xFFFFFFFC) */
|
||||
const char *name; /**< Instance name */
|
||||
typedef struct {
|
||||
const char *bank; /**< Bank name */
|
||||
uint32_t instance_id_lo; /**< Instance ID Lo (masked with 0xFFFFFFFC) */
|
||||
const char *name; /**< Instance name */
|
||||
} aca_instance_entry_t;
|
||||
|
||||
// External table declarations
|
||||
@@ -119,8 +114,8 @@ int find_error_type_by_bank(const char *bank, uint32_t error_code, const char **
|
||||
* @param[out] error_type Pointer to store result string
|
||||
* @return 0 on success, 1 if not found, -1 on parameter error
|
||||
*/
|
||||
int find_error_in_table(const aca_error_entry_t *table, size_t table_size,
|
||||
uint32_t error_code, const char **error_type);
|
||||
int find_error_in_table(const aca_error_entry_t *table, size_t table_size, uint32_t error_code,
|
||||
const char **error_type);
|
||||
|
||||
/**
|
||||
* @brief Find OAM and AID values based on instance_id_hi
|
||||
|
||||
@@ -24,8 +24,7 @@
|
||||
#define RAS_DECODE_VERSION_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -36,7 +35,7 @@ extern "C"
|
||||
*
|
||||
* - MAJOR: Incremented for incompatible API changes
|
||||
* - MINOR: Incremented for backward-compatible functionality additions
|
||||
* - PATCH: Incremented for backward-compatible bug fixes
|
||||
* - PATCH: Incremented for backward-compatible fixes
|
||||
*/
|
||||
|
||||
/* Version Components */
|
||||
@@ -49,51 +48,50 @@ extern "C"
|
||||
#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)
|
||||
#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
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int major; /**< Major version number */
|
||||
int minor; /**< Minor version number */
|
||||
int patch; /**< Patch version number */
|
||||
const char *string; /**< Version string (e.g., "1.0.0") */
|
||||
} aca_version_info_t;
|
||||
/**
|
||||
* @brief Structure containing version information
|
||||
*/
|
||||
typedef struct {
|
||||
int major; /**< Major version number */
|
||||
int minor; /**< Minor version number */
|
||||
int patch; /**< Patch version number */
|
||||
const char *string; /**< Version string (e.g., "1.0.0") */
|
||||
} aca_version_info_t;
|
||||
|
||||
/**
|
||||
* @brief Get the major version number
|
||||
* @return Major version number
|
||||
*/
|
||||
int aca_get_version_major(void);
|
||||
/**
|
||||
* @brief Get the major version number
|
||||
* @return Major version number
|
||||
*/
|
||||
int aca_get_version_major(void);
|
||||
|
||||
/**
|
||||
* @brief Get the minor version number
|
||||
* @return Minor version number
|
||||
*/
|
||||
int aca_get_version_minor(void);
|
||||
/**
|
||||
* @brief Get the minor version number
|
||||
* @return Minor version number
|
||||
*/
|
||||
int aca_get_version_minor(void);
|
||||
|
||||
/**
|
||||
* @brief Get the patch version number
|
||||
* @return Patch version number
|
||||
*/
|
||||
int aca_get_version_patch(void);
|
||||
/**
|
||||
* @brief Get the patch version number
|
||||
* @return Patch version number
|
||||
*/
|
||||
int aca_get_version_patch(void);
|
||||
|
||||
/**
|
||||
* @brief Get the version string
|
||||
* @return Pointer to version string (e.g., "1.0.0")
|
||||
*/
|
||||
const char *aca_get_version_string(void);
|
||||
/**
|
||||
* @brief Get the version string
|
||||
* @return Pointer to version string (e.g., "1.0.0")
|
||||
*/
|
||||
const char *aca_get_version_string(void);
|
||||
|
||||
/**
|
||||
* @brief Get complete version information
|
||||
* @return Structure containing all version information
|
||||
*/
|
||||
aca_version_info_t aca_get_version_info(void);
|
||||
/**
|
||||
* @brief Get complete version information
|
||||
* @return Structure containing all version information
|
||||
*/
|
||||
aca_version_info_t aca_get_version_info(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -23,9 +23,10 @@
|
||||
#ifndef BOOT_DECODE_H
|
||||
#define BOOT_DECODE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "json_util.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -36,7 +37,7 @@ extern "C" {
|
||||
* @brief Boot message structure representing OAM boot message
|
||||
*/
|
||||
typedef struct {
|
||||
uint64_t value; ///< 64-bit boot message value
|
||||
uint64_t value; ///< 64-bit boot message value
|
||||
} OamBootMsg;
|
||||
|
||||
/**
|
||||
@@ -44,44 +45,44 @@ typedef struct {
|
||||
* @param msg Boot message to decode
|
||||
* @return JsonValue containing decoded information or NULL on failure
|
||||
*/
|
||||
typedef JsonValue* (*boot_decoder_func_t)(OamBootMsg *msg);
|
||||
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
|
||||
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
|
||||
#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
|
||||
#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
|
||||
#define HBM_STACK_0 0x01
|
||||
#define HBM_STACK_1 0x02
|
||||
#define HBM_STACK_UNKNOWN -1
|
||||
|
||||
/**
|
||||
* @brief Extract specific byte from 64-bit value
|
||||
@@ -90,7 +91,7 @@ typedef struct {
|
||||
* @return Extracted byte value
|
||||
*/
|
||||
static inline uint8_t extract_byte(uint64_t value, int byte_index) {
|
||||
return (uint8_t)((value >> (byte_index * 8)) & 0xFF);
|
||||
return (uint8_t)((value >> (byte_index * 8)) & 0xFF);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,9 +99,7 @@ static inline uint8_t extract_byte(uint64_t value, int byte_index) {
|
||||
* @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;
|
||||
}
|
||||
static inline uint32_t extract_bits(int num_bits) { return (1U << num_bits) - 1; }
|
||||
|
||||
/**
|
||||
* @brief Get boot version from boot message
|
||||
@@ -159,7 +158,7 @@ int decode_hbm_stack(uint8_t stack);
|
||||
* @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);
|
||||
JsonValue *create_failed_links_array(uint8_t byte_value, int max_links);
|
||||
|
||||
/**
|
||||
* @brief Create hex string representation
|
||||
@@ -167,35 +166,35 @@ JsonValue* create_failed_links_array(uint8_t byte_value, int max_links);
|
||||
* @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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
JsonValue *decode_unhandled_error_v0(OamBootMsg *msg);
|
||||
JsonValue *decode_unhandled_error_v1(OamBootMsg *msg);
|
||||
|
||||
/**
|
||||
* @brief Get appropriate decoder function for boot message
|
||||
@@ -210,7 +209,7 @@ boot_decoder_func_t get_decoder_function(OamBootMsg *msg);
|
||||
* @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);
|
||||
JsonValue *boot_decode_orchestrator(const uint64_t *oam_boot_msgs, size_t count);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -28,13 +28,12 @@
|
||||
/**
|
||||
* @brief Structure representing an error mapping entry
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t id;
|
||||
const char *error_category;
|
||||
const char *error_type;
|
||||
const char *method;
|
||||
const char *error_severity;
|
||||
typedef struct {
|
||||
uint32_t id;
|
||||
const char *error_category;
|
||||
const char *error_type;
|
||||
const char *method;
|
||||
const char *error_severity;
|
||||
} error_map_entry_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,14 +33,7 @@ extern "C" {
|
||||
/**
|
||||
* @brief JSON value types enumeration
|
||||
*/
|
||||
typedef enum {
|
||||
JSON_NULL,
|
||||
JSON_BOOL,
|
||||
JSON_NUMBER,
|
||||
JSON_STRING,
|
||||
JSON_OBJECT,
|
||||
JSON_ARRAY
|
||||
} JsonType;
|
||||
typedef enum { JSON_NULL, JSON_BOOL, JSON_NUMBER, JSON_STRING, JSON_OBJECT, JSON_ARRAY } JsonType;
|
||||
|
||||
typedef struct JsonValue JsonValue;
|
||||
typedef struct JsonPair JsonPair;
|
||||
@@ -49,67 +42,67 @@ typedef struct JsonPair JsonPair;
|
||||
* @brief JSON key-value pair structure for objects
|
||||
*/
|
||||
struct JsonPair {
|
||||
char *key;
|
||||
JsonValue *value;
|
||||
JsonPair *next;
|
||||
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;
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
JsonValue *json_create_array(void);
|
||||
|
||||
/**
|
||||
* @brief Add a key-value pair to a JSON object
|
||||
@@ -125,7 +118,7 @@ void json_object_set(JsonValue *obj, const char *key, JsonValue *value);
|
||||
* @param key Key to search for
|
||||
* @return Pointer to JsonValue or NULL if not found
|
||||
*/
|
||||
JsonValue* json_object_get(JsonValue *obj, const char *key);
|
||||
JsonValue *json_object_get(JsonValue *obj, const char *key);
|
||||
|
||||
/**
|
||||
* @brief Check if a key exists in a JSON object
|
||||
@@ -149,7 +142,7 @@ bool json_array_push(JsonValue *arr, JsonValue *value);
|
||||
* @param index Array index
|
||||
* @return Pointer to JsonValue or NULL if index out of bounds
|
||||
*/
|
||||
JsonValue* json_array_get(JsonValue *arr, size_t index);
|
||||
JsonValue *json_array_get(JsonValue *arr, size_t index);
|
||||
|
||||
/**
|
||||
* @brief Get the size of a JSON array
|
||||
|
||||
@@ -23,31 +23,31 @@
|
||||
#ifndef RAS_DECODE_API_H
|
||||
#define RAS_DECODE_API_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "aca_version.h"
|
||||
#include "json_util.h"
|
||||
|
||||
/**
|
||||
* @brief Structure containing decoded error information
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
const char *bank_ref; /**< Reference to bank name string */
|
||||
const char *error_type_ref; /**< Reference to error type string */
|
||||
const char *severity_ref; /**< Reference to error severity string */
|
||||
const char *category_ref; /**< Reference to error category string */
|
||||
const char *instance_ref; /**< Reference to instance name string */
|
||||
int oam; /**< OAM value */
|
||||
int aid; /**< AID value */
|
||||
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 */
|
||||
typedef struct {
|
||||
const char *bank_ref; /**< Reference to bank name string */
|
||||
const char *error_type_ref; /**< Reference to error type string */
|
||||
const char *severity_ref; /**< Reference to error severity string */
|
||||
const char *category_ref; /**< Reference to error category string */
|
||||
const char *instance_ref; /**< Reference to instance name string */
|
||||
int oam; /**< OAM value */
|
||||
int aid; /**< AID value */
|
||||
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;
|
||||
|
||||
/**
|
||||
@@ -56,10 +56,12 @@ 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
|
||||
* @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, uint16_t register_context_type);
|
||||
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 as JSON
|
||||
@@ -67,10 +69,12 @@ int decode_afid(const uint64_t *register_array, size_t array_len, uint32_t flag,
|
||||
* @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
|
||||
* @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
|
||||
*/
|
||||
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);
|
||||
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);
|
||||
|
||||
/**
|
||||
* @brief Decodes the AFID from a JSON error object based on error category, type, and severity
|
||||
@@ -79,4 +83,4 @@ JsonValue* decode_error_info(const uint64_t *register_array, size_t array_len, u
|
||||
*/
|
||||
int decode_error_info_afid(JsonValue *error_json);
|
||||
|
||||
#endif // RAS_DECODE_API_H
|
||||
#endif // RAS_DECODE_API_H
|
||||
|
||||
+28
-27
@@ -45,32 +45,33 @@ set(INC_LIST
|
||||
"${PROJECT_SOURCE_DIR}/rocm_smi/include/rocm_smi/rocm_smi_utils.h")
|
||||
|
||||
set(RAS_DECODE "ras-decode")
|
||||
set(ACA_SRC_DIR "${PROJECT_SOURCE_DIR}/src/${RAS_DECODE}")
|
||||
set(SRC_LIST ${SRC_LIST}
|
||||
${ACA_SRC_DIR}/aca_decode.c
|
||||
${ACA_SRC_DIR}/aca_fields.c
|
||||
${ACA_SRC_DIR}/aca_tables.c
|
||||
${ACA_SRC_DIR}/aca_version.c
|
||||
${ACA_SRC_DIR}/boot_decode.c
|
||||
${ACA_SRC_DIR}/error_map.c
|
||||
${ACA_SRC_DIR}/json_printer.c
|
||||
${ACA_SRC_DIR}/json_util.c
|
||||
# ${ACA_SRC_DIR}/main.c
|
||||
${ACA_SRC_DIR}/ras_decode_api.c
|
||||
)
|
||||
set(ACA_INC_DIR "${PROJECT_SOURCE_DIR}/include/${RAS_DECODE}")
|
||||
set(INC_LIST ${INC_LIST}
|
||||
${ACA_INC_DIR}/aca_decode.h
|
||||
${ACA_INC_DIR}/aca_fields.h
|
||||
${ACA_INC_DIR}/aca_tables.h
|
||||
${ACA_INC_DIR}/aca_version.h
|
||||
${ACA_INC_DIR}/boot_decode.h
|
||||
${ACA_INC_DIR}/error_map.h
|
||||
${ACA_INC_DIR}/json_printer.h
|
||||
${ACA_INC_DIR}/json_util.h
|
||||
${ACA_INC_DIR}/ras_decode_api.h
|
||||
${ACA_INC_DIR}/ras_decode_constants.h
|
||||
)
|
||||
set(RAS_DECODE_REPO "git@github.amd.com:dctools/ras-decode-instinct-staging.git")
|
||||
set(RAS_DECODE_SRC_DIR "${PROJECT_SOURCE_DIR}/src/${RAS_DECODE}")
|
||||
set(RAS_DECODE_INC_DIR "${PROJECT_SOURCE_DIR}/include/${RAS_DECODE}")
|
||||
find_package(Git QUIET)
|
||||
if(GIT_FOUND)
|
||||
add_custom_target(
|
||||
${RAS_DECODE}
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_CURRENT_BINARY_DIR}/${RAS_DECODE}
|
||||
COMMAND ${GIT_EXECUTABLE} clone ${RAS_DECODE_REPO} -b main ${CMAKE_CURRENT_BINARY_DIR}/${RAS_DECODE}
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${RAS_DECODE_SRC_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/${RAS_DECODE}/src ${RAS_DECODE_SRC_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${RAS_DECODE_INC_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/${RAS_DECODE}/include ${RAS_DECODE_INC_DIR}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Cloning ${RAS_DECODE_REPO} from GitHub"
|
||||
VERBATIM
|
||||
)
|
||||
else()
|
||||
message(WARNING "Git not found, cannot clone ${RAS_DECODE_REPO}.")
|
||||
endif()
|
||||
file(GLOB RAS_DECODE_INCLUDES "${RAS_DECODE_INC_DIR}/*.h")
|
||||
file(GLOB RAS_DECODE_SOURCES "${RAS_DECODE_SRC_DIR}/*.c")
|
||||
list(REMOVE_ITEM RAS_DECODE_SOURCES "main.c")
|
||||
|
||||
set(SRC_LIST ${SRC_LIST} ${RAS_DECODE_SOURCES})
|
||||
set(INC_LIST ${INC_LIST} ${RAS_DECODE_INCLUDES})
|
||||
|
||||
if(ENABLE_ESMI_LIB)
|
||||
list(APPEND INC_LIST ${ESMI_INC_DIR}/e_smi/e_smi.h)
|
||||
list(APPEND INC_LIST ${ESMI_INC_DIR}/e_smi/e_smi_monitor.h)
|
||||
@@ -92,7 +93,7 @@ target_include_directories(${AMD_SMI} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${PROJECT_SOURCE_DIR}/rocm_smi/include
|
||||
${PROJECT_SOURCE_DIR}/common/shared_mutex
|
||||
${ACA_INC_DIR}
|
||||
${RAS_DECODE_INC_DIR}
|
||||
${DRM_INCLUDE_DIRS}
|
||||
${DRM_AMDGPU_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
+241
-287
@@ -30,13 +30,15 @@
|
||||
*/
|
||||
|
||||
#include "aca_decode.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "aca_tables.h"
|
||||
#include "error_map.h"
|
||||
#include "ras_decode_constants.h"
|
||||
#include "json_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
#include "ras_decode_constants.h"
|
||||
|
||||
/**
|
||||
* @brief Gets the bank name based on hardware ID and ACA type
|
||||
@@ -44,75 +46,63 @@
|
||||
* @param[out] bank_name Pointer to a string containing the bank name
|
||||
* @return 0 on success, -1 on failure
|
||||
*/
|
||||
static int
|
||||
aca_decoder_get_bank(const aca_decoder_t *decoder, const char **bank_name)
|
||||
{
|
||||
if (!decoder || !bank_name)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
static int aca_decoder_get_bank(const aca_decoder_t *decoder, const char **bank_name) {
|
||||
if (!decoder || !bank_name) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
const aca_ipid_fields_t *ipid = &decoder->ipid;
|
||||
return find_bank_name(ipid->hardware_id, ipid->aca_type, bank_name);
|
||||
const aca_ipid_fields_t *ipid = &decoder->ipid;
|
||||
return find_bank_name(ipid->hardware_id, ipid->aca_type, bank_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Determines the error severity based on status fields
|
||||
* @param[in] status Pointer to the ACA status fields structure
|
||||
* @return String indicating error severity: "Fatal", "Uncorrected, Non-fatal", "Corrected", or "UNKNOWN"
|
||||
* @return String indicating error severity: "Fatal", "Uncorrected, Non-fatal", "Corrected", or
|
||||
* "UNKNOWN"
|
||||
*/
|
||||
static const char *get_error_severity(const aca_status_fields_t *status)
|
||||
{
|
||||
if (status->poison)
|
||||
return RAS_DECODE_SEVERITY_UNCORRECTED_NON_FATAL;
|
||||
if (status->pcc)
|
||||
return RAS_DECODE_SEVERITY_FATAL;
|
||||
if (!status->pcc && status->uc && status->tcc)
|
||||
return RAS_DECODE_SEVERITY_FATAL;
|
||||
if (!status->pcc && status->uc && !status->tcc)
|
||||
return RAS_DECODE_SEVERITY_UNCORRECTED_NON_FATAL;
|
||||
if (!status->pcc && !status->uc && !status->tcc && status->deferred)
|
||||
return RAS_DECODE_SEVERITY_UNCORRECTED_NON_FATAL;
|
||||
if (!status->pcc && !status->uc && !status->tcc && !status->deferred)
|
||||
return RAS_DECODE_SEVERITY_CORRECTED;
|
||||
return RAS_DECODE_SEVERITY_UNKNOWN;
|
||||
static const char *get_error_severity(const aca_status_fields_t *status) {
|
||||
if (status->poison) return RAS_DECODE_SEVERITY_UNCORRECTED_NON_FATAL;
|
||||
if (status->pcc) return RAS_DECODE_SEVERITY_FATAL;
|
||||
if (!status->pcc && status->uc && status->tcc) return RAS_DECODE_SEVERITY_FATAL;
|
||||
if (!status->pcc && status->uc && !status->tcc) return RAS_DECODE_SEVERITY_UNCORRECTED_NON_FATAL;
|
||||
if (!status->pcc && !status->uc && !status->tcc && status->deferred)
|
||||
return RAS_DECODE_SEVERITY_UNCORRECTED_NON_FATAL;
|
||||
if (!status->pcc && !status->uc && !status->tcc && !status->deferred)
|
||||
return RAS_DECODE_SEVERITY_CORRECTED;
|
||||
return RAS_DECODE_SEVERITY_UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Determines the error category based on bank and error type
|
||||
* @param[in] bank Pointer to the bank name
|
||||
* @param[in] error_type Pointer to the error type
|
||||
* @return String indicating error category: "HBM Errors", "Off-Package Link Errors", or "Device Internal Errors"
|
||||
* @return String indicating error category: "HBM Errors", "Off-Package Link Errors", or "Device
|
||||
* Internal Errors"
|
||||
*/
|
||||
static const char *get_error_category(const char *bank, const char *error_type)
|
||||
{
|
||||
if (!bank || !error_type)
|
||||
{
|
||||
return RAS_DECODE_SEVERITY_UNKNOWN;
|
||||
}
|
||||
static const char *get_error_category(const char *bank, const char *error_type) {
|
||||
if (!bank || !error_type) {
|
||||
return RAS_DECODE_SEVERITY_UNKNOWN;
|
||||
}
|
||||
|
||||
if (strcmp(bank, RAS_DECODE_BANK_UMC) == 0)
|
||||
{
|
||||
if (strcmp(error_type, RAS_DECODE_ERROR_TYPE_ON_DIE_ECC) == 0 ||
|
||||
strcmp(error_type, "WriteDataPoisonErr") == 0 ||
|
||||
strcmp(error_type, "AddressCommandParityErr") == 0 ||
|
||||
strcmp(error_type, "WriteDataCrcErr") == 0 ||
|
||||
strcmp(error_type, "EcsErr") == 0 ||
|
||||
strcmp(error_type, "RdCrcErr") == 0 ||
|
||||
strcmp(error_type, RAS_DECODE_ERROR_TYPE_END_TO_END_CRC) == 0)
|
||||
{
|
||||
return RAS_DECODE_CATEGORY_HBM_ERRORS;
|
||||
}
|
||||
if (strcmp(bank, RAS_DECODE_BANK_UMC) == 0) {
|
||||
if (strcmp(error_type, RAS_DECODE_ERROR_TYPE_ON_DIE_ECC) == 0 ||
|
||||
strcmp(error_type, "WriteDataPoisonErr") == 0 ||
|
||||
strcmp(error_type, "AddressCommandParityErr") == 0 ||
|
||||
strcmp(error_type, "WriteDataCrcErr") == 0 || strcmp(error_type, "EcsErr") == 0 ||
|
||||
strcmp(error_type, "RdCrcErr") == 0 ||
|
||||
strcmp(error_type, RAS_DECODE_ERROR_TYPE_END_TO_END_CRC) == 0) {
|
||||
return RAS_DECODE_CATEGORY_HBM_ERRORS;
|
||||
}
|
||||
else if (strcmp(bank, RAS_DECODE_BANK_PCS_XGMI) == 0 ||
|
||||
} else if (strcmp(bank, RAS_DECODE_BANK_PCS_XGMI) == 0 ||
|
||||
strcmp(bank, RAS_DECODE_BANK_KPX_SERDES) == 0 ||
|
||||
strcmp(bank, RAS_DECODE_BANK_KPX_WAFL) == 0 ||
|
||||
(strcmp(bank, RAS_DECODE_BANK_PSP) == 0 && strcmp(error_type, RAS_DECODE_ERROR_TYPE_WAFL) == 0))
|
||||
{
|
||||
return RAS_DECODE_CATEGORY_OFF_PACKAGE_LINK_ERRORS;
|
||||
}
|
||||
(strcmp(bank, RAS_DECODE_BANK_PSP) == 0 &&
|
||||
strcmp(error_type, RAS_DECODE_ERROR_TYPE_WAFL) == 0)) {
|
||||
return RAS_DECODE_CATEGORY_OFF_PACKAGE_LINK_ERRORS;
|
||||
}
|
||||
|
||||
return RAS_DECODE_CATEGORY_DEVICE_INTERNAL_ERRORS;
|
||||
return RAS_DECODE_CATEGORY_DEVICE_INTERNAL_ERRORS;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,64 +114,57 @@ static const char *get_error_category(const char *bank, const char *error_type)
|
||||
* @param[out] service_error_type Pointer to store the resulting service error type string
|
||||
* @return 0 on success, non-zero on failure
|
||||
*/
|
||||
static int get_service_error_type(const char *error_category, const char *error_bank, const char *error_type,
|
||||
const char *error_severity, const char **service_error_type)
|
||||
{
|
||||
if (!error_category || !error_type || !error_severity || !service_error_type ||
|
||||
strcmp(error_category, RAS_DECODE_SEVERITY_UNKNOWN) == 0 ||
|
||||
strcmp(error_type, RAS_DECODE_SEVERITY_UNKNOWN) == 0 ||
|
||||
strcmp(error_severity, RAS_DECODE_SEVERITY_UNKNOWN) == 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (strcmp(error_type, RAS_DECODE_ERROR_TYPE_BAD_PAGE_RETIREMENT_THRESHOLD) == 0)
|
||||
{
|
||||
*service_error_type = RAS_DECODE_ERROR_TYPE_BAD_PAGE_RETIREMENT_THRESHOLD;
|
||||
return 0;
|
||||
}
|
||||
if ((strcmp(error_category, RAS_DECODE_CATEGORY_HBM_ERRORS) == 0) && (strcmp(error_severity, RAS_DECODE_SEVERITY_CORRECTED) == 0))
|
||||
{
|
||||
*service_error_type = RAS_DECODE_ERROR_TYPE_ALL;
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(error_type, "RdCrcErr") == 0)
|
||||
{
|
||||
*service_error_type = RAS_DECODE_ERROR_TYPE_END_TO_END_CRC;
|
||||
return 0;
|
||||
}
|
||||
if ((strcmp(error_category, RAS_DECODE_CATEGORY_HBM_ERRORS) == 0) && (strcmp(error_severity, RAS_DECODE_SEVERITY_FATAL) == 0) &&
|
||||
(strcmp(error_type, RAS_DECODE_ERROR_TYPE_ON_DIE_ECC) != 0) && (strcmp(error_type, RAS_DECODE_ERROR_TYPE_END_TO_END_CRC) != 0))
|
||||
{
|
||||
*service_error_type = RAS_DECODE_ERROR_TYPE_ALL_OTHERS;
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(error_category, RAS_DECODE_CATEGORY_DEVICE_INTERNAL_ERRORS) == 0)
|
||||
{
|
||||
if ((strcmp(error_severity, RAS_DECODE_SEVERITY_UNCORRECTED_NON_FATAL) == 0 ||
|
||||
strcmp(error_severity, RAS_DECODE_SEVERITY_CORRECTED) == 0 ||
|
||||
strcmp(error_severity, RAS_DECODE_SEVERITY_FATAL) == 0) &&
|
||||
strcmp(error_type, RAS_DECODE_ERROR_TYPE_HARDWARE_ASSERTION) != 0 &&
|
||||
strcmp(error_type, RAS_DECODE_ERROR_TYPE_WATCHDOG_TIMEOUT) != 0)
|
||||
{
|
||||
*service_error_type = RAS_DECODE_ERROR_TYPE_ALL_OTHERS;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (strcmp(error_category, RAS_DECODE_CATEGORY_OFF_PACKAGE_LINK_ERRORS) == 0)
|
||||
{
|
||||
if (strcmp(error_bank, RAS_DECODE_BANK_PCS_XGMI) == 0)
|
||||
{
|
||||
*service_error_type = RAS_DECODE_ERROR_TYPE_XGMI;
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(error_bank, RAS_DECODE_BANK_KPX_WAFL) == 0)
|
||||
{
|
||||
*service_error_type = RAS_DECODE_ERROR_TYPE_WAFL;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int get_service_error_type(const char *error_category, const char *error_bank,
|
||||
const char *error_type, const char *error_severity,
|
||||
const char **service_error_type) {
|
||||
if (!error_category || !error_type || !error_severity || !service_error_type ||
|
||||
strcmp(error_category, RAS_DECODE_SEVERITY_UNKNOWN) == 0 ||
|
||||
strcmp(error_type, RAS_DECODE_SEVERITY_UNKNOWN) == 0 ||
|
||||
strcmp(error_severity, RAS_DECODE_SEVERITY_UNKNOWN) == 0) {
|
||||
return -1;
|
||||
}
|
||||
if (strcmp(error_type, RAS_DECODE_ERROR_TYPE_BAD_PAGE_RETIREMENT_THRESHOLD) == 0) {
|
||||
*service_error_type = RAS_DECODE_ERROR_TYPE_BAD_PAGE_RETIREMENT_THRESHOLD;
|
||||
return 0;
|
||||
}
|
||||
if ((strcmp(error_category, RAS_DECODE_CATEGORY_HBM_ERRORS) == 0) &&
|
||||
(strcmp(error_severity, RAS_DECODE_SEVERITY_CORRECTED) == 0)) {
|
||||
*service_error_type = RAS_DECODE_ERROR_TYPE_ALL;
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(error_type, "RdCrcErr") == 0) {
|
||||
*service_error_type = RAS_DECODE_ERROR_TYPE_END_TO_END_CRC;
|
||||
return 0;
|
||||
}
|
||||
if ((strcmp(error_category, RAS_DECODE_CATEGORY_HBM_ERRORS) == 0) &&
|
||||
(strcmp(error_severity, RAS_DECODE_SEVERITY_FATAL) == 0) &&
|
||||
(strcmp(error_type, RAS_DECODE_ERROR_TYPE_ON_DIE_ECC) != 0) &&
|
||||
(strcmp(error_type, RAS_DECODE_ERROR_TYPE_END_TO_END_CRC) != 0)) {
|
||||
*service_error_type = RAS_DECODE_ERROR_TYPE_ALL_OTHERS;
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(error_category, RAS_DECODE_CATEGORY_DEVICE_INTERNAL_ERRORS) == 0) {
|
||||
if ((strcmp(error_severity, RAS_DECODE_SEVERITY_UNCORRECTED_NON_FATAL) == 0 ||
|
||||
strcmp(error_severity, RAS_DECODE_SEVERITY_CORRECTED) == 0 ||
|
||||
strcmp(error_severity, RAS_DECODE_SEVERITY_FATAL) == 0) &&
|
||||
strcmp(error_type, RAS_DECODE_ERROR_TYPE_HARDWARE_ASSERTION) != 0 &&
|
||||
strcmp(error_type, RAS_DECODE_ERROR_TYPE_WATCHDOG_TIMEOUT) != 0) {
|
||||
*service_error_type = RAS_DECODE_ERROR_TYPE_ALL_OTHERS;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (strcmp(error_category, RAS_DECODE_CATEGORY_OFF_PACKAGE_LINK_ERRORS) == 0) {
|
||||
if (strcmp(error_bank, RAS_DECODE_BANK_PCS_XGMI) == 0) {
|
||||
*service_error_type = RAS_DECODE_ERROR_TYPE_XGMI;
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(error_bank, RAS_DECODE_BANK_KPX_WAFL) == 0) {
|
||||
*service_error_type = RAS_DECODE_ERROR_TYPE_WAFL;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,117 +172,94 @@ static int get_service_error_type(const char *error_category, const char *error_
|
||||
* @param[in] decoder Pointer to the ACA decoder structure
|
||||
* @param[out] info Pointer to the error info structure to be populated
|
||||
*/
|
||||
static void aca_decoder_get_error_info(const aca_decoder_t *decoder, aca_error_info_t *info)
|
||||
{
|
||||
const char *bank;
|
||||
const char *error_type;
|
||||
const char *instance_name;
|
||||
int result;
|
||||
|
||||
info->raw_status = decoder->aca_status;
|
||||
info->raw_addr = decoder->aca_addr;
|
||||
info->raw_ipid = decoder->aca_ipid;
|
||||
info->raw_synd = decoder->aca_synd;
|
||||
|
||||
info->scrub = decoder->status.scrub;
|
||||
info->poison = decoder->status.poison;
|
||||
info->deferred = decoder->status.deferred;
|
||||
info->error_code_ext = decoder->status.error_code_ext;
|
||||
static void aca_decoder_get_error_info(const aca_decoder_t *decoder, aca_error_info_t *info) {
|
||||
const char *bank;
|
||||
const char *error_type;
|
||||
const char *instance_name;
|
||||
int result;
|
||||
|
||||
info->raw_status = decoder->aca_status;
|
||||
info->raw_addr = decoder->aca_addr;
|
||||
info->raw_ipid = decoder->aca_ipid;
|
||||
info->raw_synd = decoder->aca_synd;
|
||||
|
||||
result = aca_decoder_get_bank(decoder, &bank);
|
||||
if (result < 0)
|
||||
{
|
||||
bank = RAS_DECODE_SEVERITY_UNKNOWN;
|
||||
}
|
||||
info->bank_ref = bank;
|
||||
info->scrub = decoder->status.scrub;
|
||||
info->poison = decoder->status.poison;
|
||||
info->deferred = decoder->status.deferred;
|
||||
info->error_code_ext = decoder->status.error_code_ext;
|
||||
|
||||
if (find_instance_name(bank, decoder->ipid.instance_id_lo, &instance_name) == 0)
|
||||
{
|
||||
info->instance_ref = instance_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
info->instance_ref = RAS_DECODE_ERROR_TYPE_DECODE_INAPPLICABLE;
|
||||
}
|
||||
result = aca_decoder_get_bank(decoder, &bank);
|
||||
if (result < 0) {
|
||||
bank = RAS_DECODE_SEVERITY_UNKNOWN;
|
||||
}
|
||||
info->bank_ref = bank;
|
||||
|
||||
// 0b1000 indicate error threshold has been exceeded, and is always fatal
|
||||
if (decoder->flags & RAS_DECODE_FLAG_THRESHOLD_EXCEEDED)
|
||||
{
|
||||
info->severity_ref = RAS_DECODE_SEVERITY_FATAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
info->severity_ref = get_error_severity(&decoder->status);
|
||||
}
|
||||
if (find_instance_name(bank, decoder->ipid.instance_id_lo, &instance_name) == 0) {
|
||||
info->instance_ref = instance_name;
|
||||
} else {
|
||||
info->instance_ref = RAS_DECODE_ERROR_TYPE_DECODE_INAPPLICABLE;
|
||||
}
|
||||
|
||||
// Decode OAM and AID from instance_id_lo
|
||||
oam_aid_map_t oam_aid = {0};
|
||||
uint8_t instance_id_lo = decoder->ipid.instance_id_lo & 0xFF; // Get lower 8 bits
|
||||
if (find_oam_aid(instance_id_lo, &oam_aid) == 0)
|
||||
{
|
||||
info->oam = oam_aid.oam;
|
||||
info->aid = oam_aid.aid;
|
||||
}
|
||||
else
|
||||
{
|
||||
info->oam = -1; // Invalid value
|
||||
info->aid = -1; // Invalid value
|
||||
}
|
||||
// 0b1000 indicate error threshold has been exceeded, and is always fatal
|
||||
if (decoder->flags & RAS_DECODE_FLAG_THRESHOLD_EXCEEDED) {
|
||||
info->severity_ref = RAS_DECODE_SEVERITY_FATAL;
|
||||
} else {
|
||||
info->severity_ref = get_error_severity(&decoder->status);
|
||||
}
|
||||
|
||||
if (decoder->status.error_code_ext >= RAS_DECODE_ERROR_CODE_EXT_MIN && decoder->status.error_code_ext <= RAS_DECODE_ERROR_CODE_EXT_MAX)
|
||||
{
|
||||
uint32_t instance_id = decoder->ipid.instance_id_lo;
|
||||
uint32_t error_info = decoder->synd.error_information & 0xFF;
|
||||
// Decode OAM and AID from instance_id_lo
|
||||
oam_aid_map_t oam_aid = {0};
|
||||
uint8_t instance_id_lo = decoder->ipid.instance_id_lo & 0xFF; // Get lower 8 bits
|
||||
if (find_oam_aid(instance_id_lo, &oam_aid) == 0) {
|
||||
info->oam = oam_aid.oam;
|
||||
info->aid = oam_aid.aid;
|
||||
} else {
|
||||
info->oam = -1; // Invalid value
|
||||
info->aid = -1; // Invalid value
|
||||
}
|
||||
|
||||
if ((instance_id == RAS_DECODE_INSTANCE_ID_XCD0_400 || instance_id == RAS_DECODE_INSTANCE_ID_XCD1_400 ||
|
||||
instance_id == RAS_DECODE_INSTANCE_ID_XCD0_401 || instance_id == RAS_DECODE_INSTANCE_ID_XCD1_401) &&
|
||||
find_error_in_table(xcd_error_table, NUM_XCD_ERRORS, error_info, &error_type) == 0)
|
||||
{
|
||||
info->error_type_ref = error_type;
|
||||
}
|
||||
else if ((instance_id == RAS_DECODE_INSTANCE_ID_AID_400 || instance_id == RAS_DECODE_INSTANCE_ID_AID_401) &&
|
||||
find_error_in_table(aid_error_table, NUM_AID_ERRORS, error_info, &error_type) == 0)
|
||||
{
|
||||
info->error_type_ref = error_type;
|
||||
}
|
||||
else
|
||||
{
|
||||
info->error_type_ref = RAS_DECODE_SEVERITY_UNKNOWN;
|
||||
}
|
||||
}
|
||||
// 0b1000 indicate error threshold has been exceeded
|
||||
else if (decoder->flags & RAS_DECODE_FLAG_THRESHOLD_EXCEEDED)
|
||||
{
|
||||
info->error_type_ref = RAS_DECODE_ERROR_TYPE_BAD_PAGE_RETIREMENT_THRESHOLD;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (find_error_type_by_bank(bank, decoder->status.error_code_ext, &error_type) == 0)
|
||||
{
|
||||
info->error_type_ref = error_type;
|
||||
}
|
||||
else
|
||||
{
|
||||
info->error_type_ref = RAS_DECODE_SEVERITY_UNKNOWN;
|
||||
}
|
||||
}
|
||||
if (decoder->status.error_code_ext >= RAS_DECODE_ERROR_CODE_EXT_MIN &&
|
||||
decoder->status.error_code_ext <= RAS_DECODE_ERROR_CODE_EXT_MAX) {
|
||||
uint32_t instance_id = decoder->ipid.instance_id_lo;
|
||||
uint32_t error_info = decoder->synd.error_information & 0xFF;
|
||||
|
||||
// 0b1000 indicate error threshold has been exceeded, and is always a HBM error
|
||||
if (decoder->flags & RAS_DECODE_FLAG_THRESHOLD_EXCEEDED)
|
||||
{
|
||||
info->category_ref = RAS_DECODE_CATEGORY_HBM_ERRORS;
|
||||
if ((instance_id == RAS_DECODE_INSTANCE_ID_XCD0_400 ||
|
||||
instance_id == RAS_DECODE_INSTANCE_ID_XCD1_400 ||
|
||||
instance_id == RAS_DECODE_INSTANCE_ID_XCD0_401 ||
|
||||
instance_id == RAS_DECODE_INSTANCE_ID_XCD1_401) &&
|
||||
find_error_in_table(xcd_error_table, NUM_XCD_ERRORS, error_info, &error_type) == 0) {
|
||||
info->error_type_ref = error_type;
|
||||
} else if ((instance_id == RAS_DECODE_INSTANCE_ID_AID_400 ||
|
||||
instance_id == RAS_DECODE_INSTANCE_ID_AID_401) &&
|
||||
find_error_in_table(aid_error_table, NUM_AID_ERRORS, error_info, &error_type) == 0) {
|
||||
info->error_type_ref = error_type;
|
||||
} else {
|
||||
info->error_type_ref = RAS_DECODE_SEVERITY_UNKNOWN;
|
||||
}
|
||||
else
|
||||
{
|
||||
info->category_ref = get_error_category(bank, info->error_type_ref);
|
||||
}
|
||||
// 0b1000 indicate error threshold has been exceeded
|
||||
else if (decoder->flags & RAS_DECODE_FLAG_THRESHOLD_EXCEEDED) {
|
||||
info->error_type_ref = RAS_DECODE_ERROR_TYPE_BAD_PAGE_RETIREMENT_THRESHOLD;
|
||||
} else {
|
||||
if (find_error_type_by_bank(bank, decoder->status.error_code_ext, &error_type) == 0) {
|
||||
info->error_type_ref = error_type;
|
||||
} else {
|
||||
info->error_type_ref = RAS_DECODE_SEVERITY_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
const char *service_error;
|
||||
if (get_service_error_type(info->category_ref, info->bank_ref, info->error_type_ref, info->severity_ref, &service_error) != 0)
|
||||
{
|
||||
service_error = info->error_type_ref;
|
||||
}
|
||||
// 0b1000 indicate error threshold has been exceeded, and is always a HBM error
|
||||
if (decoder->flags & RAS_DECODE_FLAG_THRESHOLD_EXCEEDED) {
|
||||
info->category_ref = RAS_DECODE_CATEGORY_HBM_ERRORS;
|
||||
} else {
|
||||
info->category_ref = get_error_category(bank, info->error_type_ref);
|
||||
}
|
||||
|
||||
const char *service_error;
|
||||
if (get_service_error_type(info->category_ref, info->bank_ref, info->error_type_ref,
|
||||
info->severity_ref, &service_error) != 0) {
|
||||
service_error = info->error_type_ref;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -312,19 +272,18 @@ static void aca_decoder_get_error_info(const aca_decoder_t *decoder, aca_error_i
|
||||
* @param[in] synd_reg Raw syndrome register value
|
||||
*/
|
||||
static void aca_decoder_init(aca_decoder_t *decoder, uint16_t hw_revision, uint32_t flags,
|
||||
uint64_t status_reg, uint64_t ipid_reg, uint64_t synd_reg)
|
||||
{
|
||||
memset(decoder, 0, sizeof(aca_decoder_t));
|
||||
uint64_t status_reg, uint64_t ipid_reg, uint64_t synd_reg) {
|
||||
memset(decoder, 0, sizeof(aca_decoder_t));
|
||||
|
||||
decoder->hw_revision = hw_revision;
|
||||
decoder->flags = flags;
|
||||
decoder->aca_status = status_reg;
|
||||
decoder->aca_ipid = ipid_reg;
|
||||
decoder->aca_synd = synd_reg;
|
||||
decoder->hw_revision = hw_revision;
|
||||
decoder->flags = flags;
|
||||
decoder->aca_status = status_reg;
|
||||
decoder->aca_ipid = ipid_reg;
|
||||
decoder->aca_synd = synd_reg;
|
||||
|
||||
aca_status_init(&decoder->status, status_reg);
|
||||
aca_ipid_init(&decoder->ipid, ipid_reg);
|
||||
aca_synd_init(&decoder->synd, synd_reg);
|
||||
aca_status_init(&decoder->status, status_reg);
|
||||
aca_ipid_init(&decoder->ipid, ipid_reg);
|
||||
aca_synd_init(&decoder->synd, synd_reg);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -332,85 +291,80 @@ static void aca_decoder_init(aca_decoder_t *decoder, uint16_t hw_revision, uint3
|
||||
* @param[in] raw_data Pointer to structure containing raw ACA error data
|
||||
* @return JsonValue* containing the decoded error information, or NULL on failure
|
||||
*/
|
||||
JsonValue* aca_decode(const aca_raw_data_t *raw_data)
|
||||
{
|
||||
if (!raw_data) {
|
||||
return NULL;
|
||||
}
|
||||
JsonValue *aca_decode(const aca_raw_data_t *raw_data) {
|
||||
if (!raw_data) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
aca_decoder_t decoder = {0};
|
||||
aca_error_info_t info = {0};
|
||||
aca_decoder_t decoder = {0};
|
||||
aca_error_info_t info = {0};
|
||||
|
||||
aca_decoder_init(&decoder,
|
||||
raw_data->hw_revision,
|
||||
raw_data->flags,
|
||||
raw_data->aca_status,
|
||||
raw_data->aca_ipid,
|
||||
raw_data->aca_synd);
|
||||
aca_decoder_init(&decoder, raw_data->hw_revision, raw_data->flags, raw_data->aca_status,
|
||||
raw_data->aca_ipid, raw_data->aca_synd);
|
||||
|
||||
aca_decoder_get_error_info(&decoder, &info);
|
||||
aca_decoder_get_error_info(&decoder, &info);
|
||||
|
||||
// Create the main JSON object
|
||||
JsonValue *json_obj = json_create_object();
|
||||
if (!json_obj) {
|
||||
return NULL;
|
||||
}
|
||||
// Create the main JSON object
|
||||
JsonValue *json_obj = json_create_object();
|
||||
if (!json_obj) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Add bank
|
||||
json_object_set(json_obj, "bank", json_create_string(info.bank_ref));
|
||||
// Add bank
|
||||
json_object_set(json_obj, "bank", json_create_string(info.bank_ref));
|
||||
|
||||
// Create error_location object
|
||||
JsonValue *error_location = json_create_object();
|
||||
if (error_location) {
|
||||
char oam_str[16], aid_str[16];
|
||||
snprintf(oam_str, sizeof(oam_str), "%d", info.oam);
|
||||
snprintf(aid_str, sizeof(aid_str), "%d", info.aid);
|
||||
|
||||
json_object_set(error_location, "oam", json_create_string(oam_str));
|
||||
json_object_set(error_location, "aid", json_create_string(aid_str));
|
||||
json_object_set(error_location, "instance", json_create_string(info.instance_ref));
|
||||
|
||||
json_object_set(json_obj, "error_location", error_location);
|
||||
}
|
||||
// Create error_location object
|
||||
JsonValue *error_location = json_create_object();
|
||||
if (error_location) {
|
||||
char oam_str[16], aid_str[16];
|
||||
snprintf(oam_str, sizeof(oam_str), "%d", info.oam);
|
||||
snprintf(aid_str, sizeof(aid_str), "%d", info.aid);
|
||||
|
||||
// Add severity
|
||||
json_object_set(json_obj, "severity", json_create_string(info.severity_ref));
|
||||
json_object_set(error_location, "oam", json_create_string(oam_str));
|
||||
json_object_set(error_location, "aid", json_create_string(aid_str));
|
||||
json_object_set(error_location, "instance", json_create_string(info.instance_ref));
|
||||
|
||||
// Add scrub as string
|
||||
char scrub_str[16];
|
||||
snprintf(scrub_str, sizeof(scrub_str), "%u", info.scrub);
|
||||
json_object_set(json_obj, "scrub", json_create_string(scrub_str));
|
||||
json_object_set(json_obj, "error_location", error_location);
|
||||
}
|
||||
|
||||
// Add poison as string
|
||||
char poison_str[16];
|
||||
snprintf(poison_str, sizeof(poison_str), "%u", info.poison);
|
||||
json_object_set(json_obj, "poison", json_create_string(poison_str));
|
||||
// Add severity
|
||||
json_object_set(json_obj, "severity", json_create_string(info.severity_ref));
|
||||
|
||||
// Add deferred as string
|
||||
char deferred_str[16];
|
||||
snprintf(deferred_str, sizeof(deferred_str), "%u", info.deferred);
|
||||
json_object_set(json_obj, "deferred", json_create_string(deferred_str));
|
||||
// Add scrub as string
|
||||
char scrub_str[16];
|
||||
snprintf(scrub_str, sizeof(scrub_str), "%u", info.scrub);
|
||||
json_object_set(json_obj, "scrub", json_create_string(scrub_str));
|
||||
|
||||
// Add err_ext as string
|
||||
char err_ext_str[16];
|
||||
snprintf(err_ext_str, sizeof(err_ext_str), "%u", info.error_code_ext);
|
||||
json_object_set(json_obj, "err_ext", json_create_string(err_ext_str));
|
||||
// Add poison as string
|
||||
char poison_str[16];
|
||||
snprintf(poison_str, sizeof(poison_str), "%u", info.poison);
|
||||
json_object_set(json_obj, "poison", json_create_string(poison_str));
|
||||
|
||||
// Add error_category
|
||||
json_object_set(json_obj, "error_category", json_create_string(info.category_ref));
|
||||
// Add deferred as string
|
||||
char deferred_str[16];
|
||||
snprintf(deferred_str, sizeof(deferred_str), "%u", info.deferred);
|
||||
json_object_set(json_obj, "deferred", json_create_string(deferred_str));
|
||||
|
||||
// Add error_type
|
||||
json_object_set(json_obj, "error_type", json_create_string(info.error_type_ref));
|
||||
// Add err_ext as string
|
||||
char err_ext_str[16];
|
||||
snprintf(err_ext_str, sizeof(err_ext_str), "%u", info.error_code_ext);
|
||||
json_object_set(json_obj, "err_ext", json_create_string(err_ext_str));
|
||||
|
||||
// Add address as hex string
|
||||
char address_str[32];
|
||||
snprintf(address_str, sizeof(address_str), "0x%" PRIx64, info.raw_addr);
|
||||
json_object_set(json_obj, "address", json_create_string(address_str));
|
||||
// Add error_category
|
||||
json_object_set(json_obj, "error_category", json_create_string(info.category_ref));
|
||||
|
||||
// Add syndrome as hex string
|
||||
char syndrome_str[32];
|
||||
snprintf(syndrome_str, sizeof(syndrome_str), "0x%" PRIx64, info.raw_synd);
|
||||
json_object_set(json_obj, "syndrome", json_create_string(syndrome_str));
|
||||
// Add error_type
|
||||
json_object_set(json_obj, "error_type", json_create_string(info.error_type_ref));
|
||||
|
||||
return json_obj;
|
||||
// Add address as hex string
|
||||
char address_str[32];
|
||||
snprintf(address_str, sizeof(address_str), "0x%" PRIx64, info.raw_addr);
|
||||
json_object_set(json_obj, "address", json_create_string(address_str));
|
||||
|
||||
// Add syndrome as hex string
|
||||
char syndrome_str[32];
|
||||
snprintf(syndrome_str, sizeof(syndrome_str), "0x%" PRIx64, info.raw_synd);
|
||||
json_object_set(json_obj, "syndrome", json_create_string(syndrome_str));
|
||||
|
||||
return json_obj;
|
||||
}
|
||||
|
||||
@@ -40,66 +40,60 @@
|
||||
* @param[in] type The type to cast the extracted bits to
|
||||
* @return The extracted bits as a value of the specified type
|
||||
*/
|
||||
#define EXTRACT_BITS(value, start, count, type) ((type)(((value) >> (start)) & ((1ULL << (count)) - 1)))
|
||||
#define EXTRACT_BITS(value, start, count, type) \
|
||||
((type)(((value) >> (start)) & ((1ULL << (count)) - 1)))
|
||||
|
||||
uint64_t aca_fields_read(const aca_fields_t *fields)
|
||||
{
|
||||
return fields->raw_value;
|
||||
uint64_t aca_fields_read(const aca_fields_t *fields) { return fields->raw_value; }
|
||||
|
||||
void aca_status_init(aca_status_fields_t *fields, uint64_t status_reg) {
|
||||
fields->base.raw_value = status_reg;
|
||||
fields->error_code = EXTRACT_BITS(status_reg, 0, 16, uint16_t);
|
||||
fields->error_code_ext = EXTRACT_BITS(status_reg, 16, 6, uint8_t);
|
||||
fields->reserv22 = EXTRACT_BITS(status_reg, 22, 2, uint8_t);
|
||||
fields->addr_lsb = EXTRACT_BITS(status_reg, 24, 6, uint8_t);
|
||||
fields->reserv30 = EXTRACT_BITS(status_reg, 30, 2, uint8_t);
|
||||
fields->err_core_id = EXTRACT_BITS(status_reg, 32, 6, uint8_t);
|
||||
fields->reserv38 = EXTRACT_BITS(status_reg, 38, 2, uint8_t);
|
||||
fields->scrub = EXTRACT_BITS(status_reg, 40, 1, uint8_t);
|
||||
fields->reserv41 = EXTRACT_BITS(status_reg, 41, 2, uint8_t);
|
||||
fields->poison = EXTRACT_BITS(status_reg, 43, 1, uint8_t);
|
||||
fields->deferred = EXTRACT_BITS(status_reg, 44, 1, uint8_t);
|
||||
fields->uecc = EXTRACT_BITS(status_reg, 45, 1, uint8_t);
|
||||
fields->cecc = EXTRACT_BITS(status_reg, 46, 1, uint8_t);
|
||||
fields->reserv47 = EXTRACT_BITS(status_reg, 47, 5, uint8_t);
|
||||
fields->synd_v = EXTRACT_BITS(status_reg, 53, 1, uint8_t);
|
||||
fields->reserv54 = EXTRACT_BITS(status_reg, 54, 1, uint8_t);
|
||||
fields->tcc = EXTRACT_BITS(status_reg, 55, 1, uint8_t);
|
||||
fields->err_core_id_val = EXTRACT_BITS(status_reg, 56, 1, uint8_t);
|
||||
fields->pcc = EXTRACT_BITS(status_reg, 57, 1, uint8_t);
|
||||
fields->addr_v = EXTRACT_BITS(status_reg, 58, 1, uint8_t);
|
||||
fields->misc_v = EXTRACT_BITS(status_reg, 59, 1, uint8_t);
|
||||
fields->en = EXTRACT_BITS(status_reg, 60, 1, uint8_t);
|
||||
fields->uc = EXTRACT_BITS(status_reg, 61, 1, uint8_t);
|
||||
fields->overflow = EXTRACT_BITS(status_reg, 62, 1, uint8_t);
|
||||
fields->val = EXTRACT_BITS(status_reg, 63, 1, uint8_t);
|
||||
}
|
||||
|
||||
void aca_status_init(aca_status_fields_t *fields, uint64_t status_reg)
|
||||
{
|
||||
fields->base.raw_value = status_reg;
|
||||
fields->error_code = EXTRACT_BITS(status_reg, 0, 16, uint16_t);
|
||||
fields->error_code_ext = EXTRACT_BITS(status_reg, 16, 6, uint8_t);
|
||||
fields->reserv22 = EXTRACT_BITS(status_reg, 22, 2, uint8_t);
|
||||
fields->addr_lsb = EXTRACT_BITS(status_reg, 24, 6, uint8_t);
|
||||
fields->reserv30 = EXTRACT_BITS(status_reg, 30, 2, uint8_t);
|
||||
fields->err_core_id = EXTRACT_BITS(status_reg, 32, 6, uint8_t);
|
||||
fields->reserv38 = EXTRACT_BITS(status_reg, 38, 2, uint8_t);
|
||||
fields->scrub = EXTRACT_BITS(status_reg, 40, 1, uint8_t);
|
||||
fields->reserv41 = EXTRACT_BITS(status_reg, 41, 2, uint8_t);
|
||||
fields->poison = EXTRACT_BITS(status_reg, 43, 1, uint8_t);
|
||||
fields->deferred = EXTRACT_BITS(status_reg, 44, 1, uint8_t);
|
||||
fields->uecc = EXTRACT_BITS(status_reg, 45, 1, uint8_t);
|
||||
fields->cecc = EXTRACT_BITS(status_reg, 46, 1, uint8_t);
|
||||
fields->reserv47 = EXTRACT_BITS(status_reg, 47, 5, uint8_t);
|
||||
fields->synd_v = EXTRACT_BITS(status_reg, 53, 1, uint8_t);
|
||||
fields->reserv54 = EXTRACT_BITS(status_reg, 54, 1, uint8_t);
|
||||
fields->tcc = EXTRACT_BITS(status_reg, 55, 1, uint8_t);
|
||||
fields->err_core_id_val = EXTRACT_BITS(status_reg, 56, 1, uint8_t);
|
||||
fields->pcc = EXTRACT_BITS(status_reg, 57, 1, uint8_t);
|
||||
fields->addr_v = EXTRACT_BITS(status_reg, 58, 1, uint8_t);
|
||||
fields->misc_v = EXTRACT_BITS(status_reg, 59, 1, uint8_t);
|
||||
fields->en = EXTRACT_BITS(status_reg, 60, 1, uint8_t);
|
||||
fields->uc = EXTRACT_BITS(status_reg, 61, 1, uint8_t);
|
||||
fields->overflow = EXTRACT_BITS(status_reg, 62, 1, uint8_t);
|
||||
fields->val = EXTRACT_BITS(status_reg, 63, 1, uint8_t);
|
||||
void aca_ipid_init(aca_ipid_fields_t *fields, uint64_t ipid_reg) {
|
||||
fields->base.raw_value = ipid_reg;
|
||||
fields->instance_id_lo = EXTRACT_BITS(ipid_reg, 0, 32, uint32_t);
|
||||
fields->hardware_id = EXTRACT_BITS(ipid_reg, 32, 12, uint16_t);
|
||||
fields->instance_id_hi = EXTRACT_BITS(ipid_reg, 44, 4, uint8_t);
|
||||
fields->aca_type = EXTRACT_BITS(ipid_reg, 48, 16, uint16_t);
|
||||
}
|
||||
|
||||
void aca_ipid_init(aca_ipid_fields_t *fields, uint64_t ipid_reg)
|
||||
{
|
||||
fields->base.raw_value = ipid_reg;
|
||||
fields->instance_id_lo = EXTRACT_BITS(ipid_reg, 0, 32, uint32_t);
|
||||
fields->hardware_id = EXTRACT_BITS(ipid_reg, 32, 12, uint16_t);
|
||||
fields->instance_id_hi = EXTRACT_BITS(ipid_reg, 44, 4, uint8_t);
|
||||
fields->aca_type = EXTRACT_BITS(ipid_reg, 48, 16, uint16_t);
|
||||
void aca_synd_init(aca_synd_fields_t *fields, uint64_t synd_reg) {
|
||||
fields->base.raw_value = synd_reg;
|
||||
fields->error_information = EXTRACT_BITS(synd_reg, 0, 18, uint32_t);
|
||||
fields->length = EXTRACT_BITS(synd_reg, 18, 6, uint8_t);
|
||||
fields->error_priority = EXTRACT_BITS(synd_reg, 24, 3, uint8_t);
|
||||
fields->reserved27 = EXTRACT_BITS(synd_reg, 27, 5, uint8_t);
|
||||
fields->syndrome = EXTRACT_BITS(synd_reg, 32, 7, uint16_t);
|
||||
fields->reserved39 = EXTRACT_BITS(synd_reg, 39, 25, uint32_t);
|
||||
}
|
||||
|
||||
void aca_synd_init(aca_synd_fields_t *fields, uint64_t synd_reg)
|
||||
{
|
||||
fields->base.raw_value = synd_reg;
|
||||
fields->error_information = EXTRACT_BITS(synd_reg, 0, 18, uint32_t);
|
||||
fields->length = EXTRACT_BITS(synd_reg, 18, 6, uint8_t);
|
||||
fields->error_priority = EXTRACT_BITS(synd_reg, 24, 3, uint8_t);
|
||||
fields->reserved27 = EXTRACT_BITS(synd_reg, 27, 5, uint8_t);
|
||||
fields->syndrome = EXTRACT_BITS(synd_reg, 32, 7, uint16_t);
|
||||
fields->reserved39 = EXTRACT_BITS(synd_reg, 39, 25, uint32_t);
|
||||
}
|
||||
|
||||
void aca_addr_init(aca_addr_fields_t *fields, uint64_t addr_reg)
|
||||
{
|
||||
fields->base.raw_value = addr_reg;
|
||||
fields->error_addr = EXTRACT_BITS(addr_reg, 0, 56, uint64_t);
|
||||
fields->reserved = EXTRACT_BITS(addr_reg, 56, 8, uint8_t);
|
||||
void aca_addr_init(aca_addr_fields_t *fields, uint64_t addr_reg) {
|
||||
fields->base.raw_value = addr_reg;
|
||||
fields->error_addr = EXTRACT_BITS(addr_reg, 0, 56, uint64_t);
|
||||
fields->reserved = EXTRACT_BITS(addr_reg, 56, 8, uint8_t);
|
||||
}
|
||||
|
||||
+189
-265
@@ -33,30 +33,22 @@
|
||||
*/
|
||||
|
||||
#include "aca_tables.h"
|
||||
#include "ras_decode_constants.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ras_decode_constants.h"
|
||||
|
||||
/**
|
||||
* @brief Mapping table for hardware IDs and ACA types to bank names
|
||||
*/
|
||||
const aca_bank_entry_t bank_table[] = {
|
||||
{0x2E, 0x02, "cs"},
|
||||
{0x2E, 0x01, "pie"},
|
||||
{0x96, 0x00, "umc"},
|
||||
{0xFF, 0x01, "psp"},
|
||||
{0x01, 0x01, "smu"},
|
||||
{0x18, 0x00, "nbio"},
|
||||
{0x46, 0x01, "pcie"},
|
||||
{0x05, 0x00, "pb"},
|
||||
{0x259, 0x00, "kpx_serdes"},
|
||||
{0x2E, 0x04, "mall"},
|
||||
{0x267, 0x00, "kpx_wafl"},
|
||||
{0x50, 0x00, "pcs_xgmi"},
|
||||
{0x6C, 0x00, "nbif"},
|
||||
{0x80, 0x00, "shub"},
|
||||
{0x170, 0x00, "usr_dp"},
|
||||
{0x2E, 0x02, "cs"}, {0x2E, 0x01, "pie"}, {0x96, 0x00, "umc"},
|
||||
{0xFF, 0x01, "psp"}, {0x01, 0x01, "smu"}, {0x18, 0x00, "nbio"},
|
||||
{0x46, 0x01, "pcie"}, {0x05, 0x00, "pb"}, {0x259, 0x00, "kpx_serdes"},
|
||||
{0x2E, 0x04, "mall"}, {0x267, 0x00, "kpx_wafl"}, {0x50, 0x00, "pcs_xgmi"},
|
||||
{0x6C, 0x00, "nbif"}, {0x80, 0x00, "shub"}, {0x170, 0x00, "usr_dp"},
|
||||
{0x180, 0x00, "usr_cp"}};
|
||||
|
||||
/**
|
||||
@@ -253,74 +245,27 @@ const aca_error_type_t error_table[] = {
|
||||
* @brief Error GFX mapping table for XCD errors
|
||||
*/
|
||||
const aca_error_entry_t xcd_error_table[] = {
|
||||
{0x0, "GfxGcError"},
|
||||
{0x1, "GfxGcError"},
|
||||
{0x2, "GfxGcError"},
|
||||
{0x3, "GfxGcError"},
|
||||
{0x4, "GfxGcError"},
|
||||
{0x5, "GfxGcError"},
|
||||
{0x6, "GfxGcError"},
|
||||
{0x7, "GfxGcError"},
|
||||
{0x8, "GfxGcError"},
|
||||
{0x9, "GfxGcError"},
|
||||
{0xa, "GfxGcError"},
|
||||
{0xb, "GfxGcError"},
|
||||
{0xc, "GfxGcError"},
|
||||
{0xd, "GfxGcError"},
|
||||
{0xe, "GfxGcError"},
|
||||
{0xf, "GfxGcError"},
|
||||
{0x10, "GfxGcError"},
|
||||
{0x28, "Reserved"},
|
||||
{0x2a, "Reserved"}};
|
||||
{0x0, "GfxGcError"}, {0x1, "GfxGcError"}, {0x2, "GfxGcError"}, {0x3, "GfxGcError"},
|
||||
{0x4, "GfxGcError"}, {0x5, "GfxGcError"}, {0x6, "GfxGcError"}, {0x7, "GfxGcError"},
|
||||
{0x8, "GfxGcError"}, {0x9, "GfxGcError"}, {0xa, "GfxGcError"}, {0xb, "GfxGcError"},
|
||||
{0xc, "GfxGcError"}, {0xd, "GfxGcError"}, {0xe, "GfxGcError"}, {0xf, "GfxGcError"},
|
||||
{0x10, "GfxGcError"}, {0x28, "Reserved"}, {0x2a, "Reserved"}};
|
||||
|
||||
/**
|
||||
* @brief Error GFX mapping table for AID errors
|
||||
*/
|
||||
const aca_error_entry_t aid_error_table[] = {
|
||||
{0x0, "GfxGcError"},
|
||||
{0x1, "GfxGcError"},
|
||||
{0x2, "GfxGcError"},
|
||||
{0x3, "GfxGcError"},
|
||||
{0x4, "GfxGcError"},
|
||||
{0x5, "GfxMmhubError"},
|
||||
{0x6, "GfxMmhubError"},
|
||||
{0x7, "GfxMmhubError"},
|
||||
{0x8, "GfxMmhubError"},
|
||||
{0x9, "GfxMmhubError"},
|
||||
{0xa, "GfxMmhubError"},
|
||||
{0xb, "GfxMmhubError"},
|
||||
{0xc, "GfxMmhubError"},
|
||||
{0xd, "GfxGcError"},
|
||||
{0xe, "GfxVcnError"},
|
||||
{0xf, "GfxVcnError"},
|
||||
{0x10, "GfxVcnError"},
|
||||
{0x11, "GfxVcnError"},
|
||||
{0x12, "GfxVcnError"},
|
||||
{0x13, "GfxVcnError"},
|
||||
{0x14, "GfxVcnError"},
|
||||
{0x15, "GfxVcnError"},
|
||||
{0x16, "GfxVcnError"},
|
||||
{0x17, "GfxVcnError"},
|
||||
{0x18, "GfxVcnError"},
|
||||
{0x19, "GfxVcnError"},
|
||||
{0x1a, "GfxVcnError"},
|
||||
{0x1b, "GfxVcnError"},
|
||||
{0x1c, "GfxVcnError"},
|
||||
{0x1d, "GfxVcnError"},
|
||||
{0x1e, "GfxVcnError"},
|
||||
{0x1f, "GfxVcnError"},
|
||||
{0x20, "GfxVcnError"},
|
||||
{0x21, "GfxSdmaError"},
|
||||
{0x22, "GfxSdmaError"},
|
||||
{0x23, "GfxSdmaError"},
|
||||
{0x24, "GfxSdmaError"},
|
||||
{0x25, "GfxHdpError"},
|
||||
{0x26, "GfxAthubError"},
|
||||
{0x27, "GfxGcError"},
|
||||
{0x28, "Reserved"},
|
||||
{0x29, "Reserved"},
|
||||
{0x2a, "Reserved"},
|
||||
{0x2b, "Reserved"}};
|
||||
{0x0, "GfxGcError"}, {0x1, "GfxGcError"}, {0x2, "GfxGcError"}, {0x3, "GfxGcError"},
|
||||
{0x4, "GfxGcError"}, {0x5, "GfxMmhubError"}, {0x6, "GfxMmhubError"}, {0x7, "GfxMmhubError"},
|
||||
{0x8, "GfxMmhubError"}, {0x9, "GfxMmhubError"}, {0xa, "GfxMmhubError"}, {0xb, "GfxMmhubError"},
|
||||
{0xc, "GfxMmhubError"}, {0xd, "GfxGcError"}, {0xe, "GfxVcnError"}, {0xf, "GfxVcnError"},
|
||||
{0x10, "GfxVcnError"}, {0x11, "GfxVcnError"}, {0x12, "GfxVcnError"}, {0x13, "GfxVcnError"},
|
||||
{0x14, "GfxVcnError"}, {0x15, "GfxVcnError"}, {0x16, "GfxVcnError"}, {0x17, "GfxVcnError"},
|
||||
{0x18, "GfxVcnError"}, {0x19, "GfxVcnError"}, {0x1a, "GfxVcnError"}, {0x1b, "GfxVcnError"},
|
||||
{0x1c, "GfxVcnError"}, {0x1d, "GfxVcnError"}, {0x1e, "GfxVcnError"}, {0x1f, "GfxVcnError"},
|
||||
{0x20, "GfxVcnError"}, {0x21, "GfxSdmaError"}, {0x22, "GfxSdmaError"}, {0x23, "GfxSdmaError"},
|
||||
{0x24, "GfxSdmaError"}, {0x25, "GfxHdpError"}, {0x26, "GfxAthubError"}, {0x27, "GfxGcError"},
|
||||
{0x28, "Reserved"}, {0x29, "Reserved"}, {0x2a, "Reserved"}, {0x2b, "Reserved"}};
|
||||
|
||||
/**
|
||||
* @brief Table mapping instance_id_hi to OAM and AID values
|
||||
@@ -349,114 +294,113 @@ static const oam_aid_map_t oam_aid_table[] = {
|
||||
/**
|
||||
* @brief Table mapping bank and instance ID to instance names
|
||||
*/
|
||||
static const aca_instance_entry_t instance_table[] = {
|
||||
{"cs", 0x1F002000, "cmp0"},
|
||||
{"cs", 0x1F000000, "cs0"},
|
||||
{"cs", 0x1F000A00, "cs10"},
|
||||
{"cs", 0x1F000B00, "cs11"},
|
||||
{"cs", 0x1F000C00, "cs12"},
|
||||
{"cs", 0x1F000D00, "cs13"},
|
||||
{"cs", 0x1F000E00, "cs14"},
|
||||
{"cs", 0x1F000F00, "cs15"},
|
||||
{"cs", 0x1F001000, "cs16"},
|
||||
{"cs", 0x1F001100, "cs17"},
|
||||
{"cs", 0x1F001200, "cs18"},
|
||||
{"cs", 0x1F001300, "cs19"},
|
||||
{"cs", 0x1F000100, "cs1"},
|
||||
{"cs", 0x1F001400, "cs20"},
|
||||
{"cs", 0x1F001500, "cs21"},
|
||||
{"cs", 0x1F001600, "cs22"},
|
||||
{"cs", 0x1F001700, "cs23"},
|
||||
{"cs", 0x1F001800, "cs24"},
|
||||
{"cs", 0x1F001900, "cs25"},
|
||||
{"cs", 0x1F001A00, "cs26"},
|
||||
{"cs", 0x1F001B00, "cs27"},
|
||||
{"cs", 0x1F001C00, "cs28"},
|
||||
{"cs", 0x1F001D00, "cs29"},
|
||||
{"cs", 0x1F000200, "cs2"},
|
||||
{"cs", 0x1F001E00, "cs30"},
|
||||
{"cs", 0x1F001F00, "cs31"},
|
||||
{"cs", 0x1F000300, "cs3"},
|
||||
{"cs", 0x1F000400, "cs4"},
|
||||
{"cs", 0x1F000500, "cs5"},
|
||||
{"cs", 0x1F000600, "cs6"},
|
||||
{"cs", 0x1F000700, "cs7"},
|
||||
{"cs", 0x1F000800, "cs8"},
|
||||
{"cs", 0x1F000900, "cs9"},
|
||||
{"mall", 0x1F005900, "mall0"},
|
||||
{"mall", 0x1F006300, "mall10"},
|
||||
{"mall", 0x1F006400, "mall11"},
|
||||
{"mall", 0x1F006500, "mall12"},
|
||||
{"mall", 0x1F006600, "mall13"},
|
||||
{"mall", 0x1F006700, "mall14"},
|
||||
{"mall", 0x1F006800, "mall15"},
|
||||
{"mall", 0x1F006900, "mall16"},
|
||||
{"mall", 0x1F006A00, "mall17"},
|
||||
{"mall", 0x1F006B00, "mall18"},
|
||||
{"mall", 0x1F006C00, "mall19"},
|
||||
{"mall", 0x1F005A00, "mall1"},
|
||||
{"mall", 0x1F006D00, "mall20"},
|
||||
{"mall", 0x1F006E00, "mall21"},
|
||||
{"mall", 0x1F006F00, "mall22"},
|
||||
{"mall", 0x1F007000, "mall23"},
|
||||
{"mall", 0x1F007100, "mall24"},
|
||||
{"mall", 0x1F007200, "mall25"},
|
||||
{"mall", 0x1F007300, "mall26"},
|
||||
{"mall", 0x1F007400, "mall27"},
|
||||
{"mall", 0x1F007500, "mall28"},
|
||||
{"mall", 0x1F007600, "mall29"},
|
||||
{"mall", 0x1F005B00, "mall2"},
|
||||
{"mall", 0x1F007700, "mall30"},
|
||||
{"mall", 0x1F007800, "mall31"},
|
||||
{"mall", 0x1F005C00, "mall3"},
|
||||
{"mall", 0x1F005D00, "mall4"},
|
||||
{"mall", 0x1F005E00, "mall5"},
|
||||
{"mall", 0x1F005F00, "mall6"},
|
||||
{"mall", 0x1F006000, "mall7"},
|
||||
{"mall", 0x1F006100, "mall8"},
|
||||
{"mall", 0x1F006200, "mall9"},
|
||||
{"pb", 0x5EA00, "pb"},
|
||||
{"pb", 0x30082900, "ccd0 pbccd"},
|
||||
{"pb", 0x32082900, "ccd1 pbccd"},
|
||||
{"pb", 0x34082900, "ccd2 pbccd"},
|
||||
{"pb", 0x36082900, "xcd0 pbccd"},
|
||||
{"pb", 0x38082900, "xcd1 pbccd"},
|
||||
{"umc", 0x90F00, "ch0 umc0"},
|
||||
{"umc", 0x290F00, "ch0 umc1"},
|
||||
{"umc", 0x490F00, "ch0 umc2"},
|
||||
{"umc", 0x690F00, "ch0 umc3"},
|
||||
{"umc", 0x91F00, "ch1 umc0"},
|
||||
{"umc", 0x291F00, "ch1 umc1"},
|
||||
{"umc", 0x491F00, "ch1 umc2"},
|
||||
{"umc", 0x691F00, "ch1 umc3"},
|
||||
{"umc", 0x92F00, "ch2 umc0"},
|
||||
{"umc", 0x292F00, "ch2 umc1"},
|
||||
{"umc", 0x492F00, "ch2 umc2"},
|
||||
{"umc", 0x692F00, "ch2 umc3"},
|
||||
{"umc", 0x93F00, "ch3 umc0"},
|
||||
{"umc", 0x293F00, "ch3 umc1"},
|
||||
{"umc", 0x493F00, "ch3 umc2"},
|
||||
{"umc", 0x693F00, "ch3 umc3"},
|
||||
{"umc", 0x190F00, "ch4 umc0"},
|
||||
{"umc", 0x390F00, "ch4 umc1"},
|
||||
{"umc", 0x590F00, "ch4 umc2"},
|
||||
{"umc", 0x790F00, "ch4 umc3"},
|
||||
{"umc", 0x191F00, "ch5 umc0"},
|
||||
{"umc", 0x391F00, "ch5 umc1"},
|
||||
{"umc", 0x591F00, "ch5 umc2"},
|
||||
{"umc", 0x791F00, "ch5 umc3"},
|
||||
{"umc", 0x192F00, "ch6 umc0"},
|
||||
{"umc", 0x392F00, "ch6 umc1"},
|
||||
{"umc", 0x592F00, "ch6 umc2"},
|
||||
{"umc", 0x792F00, "ch6 umc3"},
|
||||
{"umc", 0x193F00, "ch7 umc0"},
|
||||
{"umc", 0x393F00, "ch7 umc1"},
|
||||
{"umc", 0x593F00, "ch7 umc2"},
|
||||
{"umc", 0x793F00, "ch7 umc3"},
|
||||
{"pcs_xgmi", 0x11A09200, "serdes a pcs0"},
|
||||
{"pcs_xgmi", 0x12109200, "serdes b pcs7"},
|
||||
{"pcs_xgmi", 0x12209200, "serdes b pcs8"},
|
||||
{"pcs_xgmi", 0x11B09200, "xgmi pcs"}};
|
||||
static const aca_instance_entry_t instance_table[] = {{"cs", 0x1F002000, "cmp0"},
|
||||
{"cs", 0x1F000000, "cs0"},
|
||||
{"cs", 0x1F000A00, "cs10"},
|
||||
{"cs", 0x1F000B00, "cs11"},
|
||||
{"cs", 0x1F000C00, "cs12"},
|
||||
{"cs", 0x1F000D00, "cs13"},
|
||||
{"cs", 0x1F000E00, "cs14"},
|
||||
{"cs", 0x1F000F00, "cs15"},
|
||||
{"cs", 0x1F001000, "cs16"},
|
||||
{"cs", 0x1F001100, "cs17"},
|
||||
{"cs", 0x1F001200, "cs18"},
|
||||
{"cs", 0x1F001300, "cs19"},
|
||||
{"cs", 0x1F000100, "cs1"},
|
||||
{"cs", 0x1F001400, "cs20"},
|
||||
{"cs", 0x1F001500, "cs21"},
|
||||
{"cs", 0x1F001600, "cs22"},
|
||||
{"cs", 0x1F001700, "cs23"},
|
||||
{"cs", 0x1F001800, "cs24"},
|
||||
{"cs", 0x1F001900, "cs25"},
|
||||
{"cs", 0x1F001A00, "cs26"},
|
||||
{"cs", 0x1F001B00, "cs27"},
|
||||
{"cs", 0x1F001C00, "cs28"},
|
||||
{"cs", 0x1F001D00, "cs29"},
|
||||
{"cs", 0x1F000200, "cs2"},
|
||||
{"cs", 0x1F001E00, "cs30"},
|
||||
{"cs", 0x1F001F00, "cs31"},
|
||||
{"cs", 0x1F000300, "cs3"},
|
||||
{"cs", 0x1F000400, "cs4"},
|
||||
{"cs", 0x1F000500, "cs5"},
|
||||
{"cs", 0x1F000600, "cs6"},
|
||||
{"cs", 0x1F000700, "cs7"},
|
||||
{"cs", 0x1F000800, "cs8"},
|
||||
{"cs", 0x1F000900, "cs9"},
|
||||
{"mall", 0x1F005900, "mall0"},
|
||||
{"mall", 0x1F006300, "mall10"},
|
||||
{"mall", 0x1F006400, "mall11"},
|
||||
{"mall", 0x1F006500, "mall12"},
|
||||
{"mall", 0x1F006600, "mall13"},
|
||||
{"mall", 0x1F006700, "mall14"},
|
||||
{"mall", 0x1F006800, "mall15"},
|
||||
{"mall", 0x1F006900, "mall16"},
|
||||
{"mall", 0x1F006A00, "mall17"},
|
||||
{"mall", 0x1F006B00, "mall18"},
|
||||
{"mall", 0x1F006C00, "mall19"},
|
||||
{"mall", 0x1F005A00, "mall1"},
|
||||
{"mall", 0x1F006D00, "mall20"},
|
||||
{"mall", 0x1F006E00, "mall21"},
|
||||
{"mall", 0x1F006F00, "mall22"},
|
||||
{"mall", 0x1F007000, "mall23"},
|
||||
{"mall", 0x1F007100, "mall24"},
|
||||
{"mall", 0x1F007200, "mall25"},
|
||||
{"mall", 0x1F007300, "mall26"},
|
||||
{"mall", 0x1F007400, "mall27"},
|
||||
{"mall", 0x1F007500, "mall28"},
|
||||
{"mall", 0x1F007600, "mall29"},
|
||||
{"mall", 0x1F005B00, "mall2"},
|
||||
{"mall", 0x1F007700, "mall30"},
|
||||
{"mall", 0x1F007800, "mall31"},
|
||||
{"mall", 0x1F005C00, "mall3"},
|
||||
{"mall", 0x1F005D00, "mall4"},
|
||||
{"mall", 0x1F005E00, "mall5"},
|
||||
{"mall", 0x1F005F00, "mall6"},
|
||||
{"mall", 0x1F006000, "mall7"},
|
||||
{"mall", 0x1F006100, "mall8"},
|
||||
{"mall", 0x1F006200, "mall9"},
|
||||
{"pb", 0x5EA00, "pb"},
|
||||
{"pb", 0x30082900, "ccd0 pbccd"},
|
||||
{"pb", 0x32082900, "ccd1 pbccd"},
|
||||
{"pb", 0x34082900, "ccd2 pbccd"},
|
||||
{"pb", 0x36082900, "xcd0 pbccd"},
|
||||
{"pb", 0x38082900, "xcd1 pbccd"},
|
||||
{"umc", 0x90F00, "ch0 umc0"},
|
||||
{"umc", 0x290F00, "ch0 umc1"},
|
||||
{"umc", 0x490F00, "ch0 umc2"},
|
||||
{"umc", 0x690F00, "ch0 umc3"},
|
||||
{"umc", 0x91F00, "ch1 umc0"},
|
||||
{"umc", 0x291F00, "ch1 umc1"},
|
||||
{"umc", 0x491F00, "ch1 umc2"},
|
||||
{"umc", 0x691F00, "ch1 umc3"},
|
||||
{"umc", 0x92F00, "ch2 umc0"},
|
||||
{"umc", 0x292F00, "ch2 umc1"},
|
||||
{"umc", 0x492F00, "ch2 umc2"},
|
||||
{"umc", 0x692F00, "ch2 umc3"},
|
||||
{"umc", 0x93F00, "ch3 umc0"},
|
||||
{"umc", 0x293F00, "ch3 umc1"},
|
||||
{"umc", 0x493F00, "ch3 umc2"},
|
||||
{"umc", 0x693F00, "ch3 umc3"},
|
||||
{"umc", 0x190F00, "ch4 umc0"},
|
||||
{"umc", 0x390F00, "ch4 umc1"},
|
||||
{"umc", 0x590F00, "ch4 umc2"},
|
||||
{"umc", 0x790F00, "ch4 umc3"},
|
||||
{"umc", 0x191F00, "ch5 umc0"},
|
||||
{"umc", 0x391F00, "ch5 umc1"},
|
||||
{"umc", 0x591F00, "ch5 umc2"},
|
||||
{"umc", 0x791F00, "ch5 umc3"},
|
||||
{"umc", 0x192F00, "ch6 umc0"},
|
||||
{"umc", 0x392F00, "ch6 umc1"},
|
||||
{"umc", 0x592F00, "ch6 umc2"},
|
||||
{"umc", 0x792F00, "ch6 umc3"},
|
||||
{"umc", 0x193F00, "ch7 umc0"},
|
||||
{"umc", 0x393F00, "ch7 umc1"},
|
||||
{"umc", 0x593F00, "ch7 umc2"},
|
||||
{"umc", 0x793F00, "ch7 umc3"},
|
||||
{"pcs_xgmi", 0x11A09200, "serdes a pcs0"},
|
||||
{"pcs_xgmi", 0x12109200, "serdes b pcs7"},
|
||||
{"pcs_xgmi", 0x12209200, "serdes b pcs8"},
|
||||
{"pcs_xgmi", 0x11B09200, "xgmi pcs"}};
|
||||
|
||||
const size_t NUM_OAM_AID_ENTRIES = sizeof(oam_aid_table) / sizeof(oam_aid_table[0]);
|
||||
const size_t NUM_BANKS = sizeof(bank_table) / sizeof(bank_table[0]);
|
||||
@@ -465,101 +409,81 @@ const size_t NUM_XCD_ERRORS = sizeof(xcd_error_table) / sizeof(xcd_error_table[0
|
||||
const size_t NUM_AID_ERRORS = sizeof(aid_error_table) / sizeof(aid_error_table[0]);
|
||||
const size_t NUM_INSTANCES = sizeof(instance_table) / sizeof(instance_table[0]);
|
||||
|
||||
int find_bank_name(uint16_t hw_id, uint16_t aca_type, const char **bank_name)
|
||||
{
|
||||
if (!bank_name)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int find_bank_name(uint16_t hw_id, uint16_t aca_type, const char **bank_name) {
|
||||
if (!bank_name) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < NUM_BANKS; i++)
|
||||
{
|
||||
if (bank_table[i].hw_id == hw_id &&
|
||||
bank_table[i].aca_type == aca_type)
|
||||
{
|
||||
*bank_name = bank_table[i].name;
|
||||
return 0;
|
||||
}
|
||||
for (size_t i = 0; i < NUM_BANKS; i++) {
|
||||
if (bank_table[i].hw_id == hw_id && bank_table[i].aca_type == aca_type) {
|
||||
*bank_name = bank_table[i].name;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
*bank_name = RAS_DECODE_SEVERITY_UNKNOWN;
|
||||
return 1;
|
||||
*bank_name = RAS_DECODE_SEVERITY_UNKNOWN;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int find_error_type_by_bank(const char *bank, uint32_t error_code, const char **error_type)
|
||||
{
|
||||
if (!bank || !error_type)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int find_error_type_by_bank(const char *bank, uint32_t error_code, const char **error_type) {
|
||||
if (!bank || !error_type) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < NUM_ERRORS; i++)
|
||||
{
|
||||
if (error_code == error_table[i].error_code &&
|
||||
strcmp(bank, error_table[i].bank) == 0)
|
||||
{
|
||||
*error_type = error_table[i].type;
|
||||
return 0;
|
||||
}
|
||||
for (size_t i = 0; i < NUM_ERRORS; i++) {
|
||||
if (error_code == error_table[i].error_code && strcmp(bank, error_table[i].bank) == 0) {
|
||||
*error_type = error_table[i].type;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
*error_type = RAS_DECODE_SEVERITY_UNKNOWN;
|
||||
return 1;
|
||||
*error_type = RAS_DECODE_SEVERITY_UNKNOWN;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int find_error_in_table(const aca_error_entry_t *table, size_t table_size,
|
||||
uint32_t error_code, const char **error_type)
|
||||
{
|
||||
if (!table || !error_type)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int find_error_in_table(const aca_error_entry_t *table, size_t table_size, uint32_t error_code,
|
||||
const char **error_type) {
|
||||
if (!table || !error_type) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < table_size; i++)
|
||||
{
|
||||
if (table[i].error_code == error_code)
|
||||
{
|
||||
*error_type = table[i].type;
|
||||
return 0;
|
||||
}
|
||||
for (size_t i = 0; i < table_size; i++) {
|
||||
if (table[i].error_code == error_code) {
|
||||
*error_type = table[i].type;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
*error_type = RAS_DECODE_SEVERITY_UNKNOWN;
|
||||
return 1;
|
||||
*error_type = RAS_DECODE_SEVERITY_UNKNOWN;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int find_oam_aid(uint8_t instance_id_hi, oam_aid_map_t *oam_aid)
|
||||
{
|
||||
if (!oam_aid || instance_id_hi >= NUM_OAM_AID_ENTRIES)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int find_oam_aid(uint8_t instance_id_hi, oam_aid_map_t *oam_aid) {
|
||||
if (!oam_aid || instance_id_hi >= NUM_OAM_AID_ENTRIES) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
oam_aid->oam = oam_aid_table[instance_id_hi].oam;
|
||||
oam_aid->aid = oam_aid_table[instance_id_hi].aid;
|
||||
return 0;
|
||||
oam_aid->oam = oam_aid_table[instance_id_hi].oam;
|
||||
oam_aid->aid = oam_aid_table[instance_id_hi].aid;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int find_instance_name(const char *bank, uint32_t instance_id_lo, const char **instance_name)
|
||||
{
|
||||
if (!bank || !instance_name)
|
||||
{
|
||||
return -1;
|
||||
int find_instance_name(const char *bank, uint32_t instance_id_lo, const char **instance_name) {
|
||||
if (!bank || !instance_name) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Mask off the lower 2 bits as specified
|
||||
uint32_t masked_id = instance_id_lo & 0xFFFFFFFC;
|
||||
|
||||
for (size_t i = 0; i < NUM_INSTANCES; i++) {
|
||||
if (instance_table[i].instance_id_lo == masked_id &&
|
||||
strcmp(bank, instance_table[i].bank) == 0) {
|
||||
*instance_name = instance_table[i].name;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Mask off the lower 2 bits as specified
|
||||
uint32_t masked_id = instance_id_lo & 0xFFFFFFFC;
|
||||
|
||||
for (size_t i = 0; i < NUM_INSTANCES; i++)
|
||||
{
|
||||
if (instance_table[i].instance_id_lo == masked_id &&
|
||||
strcmp(bank, instance_table[i].bank) == 0)
|
||||
{
|
||||
*instance_name = instance_table[i].name;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
*instance_name = RAS_DECODE_SEVERITY_UNKNOWN;
|
||||
return 1;
|
||||
*instance_name = RAS_DECODE_SEVERITY_UNKNOWN;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -24,34 +24,21 @@
|
||||
|
||||
/* Implementation of version functions */
|
||||
|
||||
int aca_get_version_major(void)
|
||||
{
|
||||
return RAS_DECODE_VERSION_MAJOR;
|
||||
}
|
||||
|
||||
int aca_get_version_minor(void)
|
||||
{
|
||||
return RAS_DECODE_VERSION_MINOR;
|
||||
}
|
||||
|
||||
int aca_get_version_patch(void)
|
||||
{
|
||||
return RAS_DECODE_VERSION_PATCH;
|
||||
}
|
||||
|
||||
const char *aca_get_version_string(void)
|
||||
{
|
||||
return RAS_DECODE_VERSION_STRING;
|
||||
}
|
||||
|
||||
aca_version_info_t aca_get_version_info(void)
|
||||
{
|
||||
aca_version_info_t info;
|
||||
|
||||
info.major = RAS_DECODE_VERSION_MAJOR;
|
||||
info.minor = RAS_DECODE_VERSION_MINOR;
|
||||
info.patch = RAS_DECODE_VERSION_PATCH;
|
||||
info.string = RAS_DECODE_VERSION_STRING;
|
||||
|
||||
return info;
|
||||
int aca_get_version_major(void) { return RAS_DECODE_VERSION_MAJOR; }
|
||||
|
||||
int aca_get_version_minor(void) { return RAS_DECODE_VERSION_MINOR; }
|
||||
|
||||
int aca_get_version_patch(void) { return RAS_DECODE_VERSION_PATCH; }
|
||||
|
||||
const char *aca_get_version_string(void) { return RAS_DECODE_VERSION_STRING; }
|
||||
|
||||
aca_version_info_t aca_get_version_info(void) {
|
||||
aca_version_info_t info;
|
||||
|
||||
info.major = RAS_DECODE_VERSION_MAJOR;
|
||||
info.minor = RAS_DECODE_VERSION_MINOR;
|
||||
info.patch = RAS_DECODE_VERSION_PATCH;
|
||||
info.string = RAS_DECODE_VERSION_STRING;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
+520
-630
تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
Diff را بارگزاری کن
@@ -21,68 +21,102 @@
|
||||
*/
|
||||
|
||||
#include "error_map.h"
|
||||
#include "ras_decode_constants.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "ras_decode_constants.h"
|
||||
|
||||
#define AFID_VERSION "0.7"
|
||||
|
||||
static const error_map_entry_t error_map[] = {
|
||||
{1, RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, RAS_DECODE_ERROR_TYPE_FW_LOAD, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FAIL_TO_INIT},
|
||||
{2, RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, RAS_DECODE_ERROR_TYPE_HBM_BIST_TEST, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FAIL_TO_INIT},
|
||||
{3, RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, RAS_DECODE_ERROR_TYPE_HBM_MEMORY_TEST, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FAIL_TO_INIT},
|
||||
{4, RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, RAS_DECODE_ERROR_TYPE_HBM_TRAINING, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FAIL_TO_INIT},
|
||||
{5, RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, RAS_DECODE_ERROR_TYPE_UNHANDLED, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FAIL_TO_INIT},
|
||||
{6, RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, RAS_DECODE_ERROR_TYPE_UNKNOWN_ERROR, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FAIL_TO_INIT},
|
||||
{7, RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, RAS_DECODE_ERROR_TYPE_USR_CP_LINK_TRAINING, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FAIL_TO_INIT},
|
||||
{8, RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, RAS_DECODE_ERROR_TYPE_USR_DP_LINK_TRAINING, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FAIL_TO_INIT},
|
||||
{9, RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, RAS_DECODE_ERROR_TYPE_WAFL_LINK_TRAINING, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FAIL_TO_INIT},
|
||||
{10, RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, RAS_DECODE_ERROR_TYPE_XGMI_LINK_TRAINING, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FAIL_TO_INIT},
|
||||
{11, RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, RAS_DECODE_ERROR_TYPE_BOOT_CONTROLLER_DATA_ABORT, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FAIL_TO_INIT},
|
||||
{12, RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, RAS_DECODE_ERROR_TYPE_BOOT_CONTROLLER_GENERIC, RAS_DECODE_PROTOCOL_CPER_WITH_SPACE, RAS_DECODE_SEVERITY_FAIL_TO_INIT},
|
||||
{13, RAS_DECODE_CATEGORY_OFF_PACKAGE_LINK_ERRORS, RAS_DECODE_ERROR_TYPE_PCIE_AER, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_CORRECTED},
|
||||
{14, RAS_DECODE_CATEGORY_OFF_PACKAGE_LINK_ERRORS, RAS_DECODE_ERROR_TYPE_PCIE_AER, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FATAL},
|
||||
{15, RAS_DECODE_CATEGORY_OFF_PACKAGE_LINK_ERRORS, RAS_DECODE_ERROR_TYPE_WAFL, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_CORRECTED},
|
||||
{16, RAS_DECODE_CATEGORY_OFF_PACKAGE_LINK_ERRORS, RAS_DECODE_ERROR_TYPE_WAFL, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FATAL},
|
||||
{17, RAS_DECODE_CATEGORY_OFF_PACKAGE_LINK_ERRORS, RAS_DECODE_ERROR_TYPE_XGMI, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_CORRECTED},
|
||||
{18, RAS_DECODE_CATEGORY_OFF_PACKAGE_LINK_ERRORS, RAS_DECODE_ERROR_TYPE_XGMI, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FATAL},
|
||||
{19, RAS_DECODE_CATEGORY_HBM_ERRORS, RAS_DECODE_ERROR_TYPE_BAD_PAGE_RETIREMENT_THRESHOLD, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FATAL},
|
||||
{20, RAS_DECODE_CATEGORY_HBM_ERRORS, RAS_DECODE_ERROR_TYPE_ON_DIE_ECC, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FATAL},
|
||||
{21, RAS_DECODE_CATEGORY_HBM_ERRORS, RAS_DECODE_ERROR_TYPE_END_TO_END_CRC, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FATAL},
|
||||
{22, RAS_DECODE_CATEGORY_HBM_ERRORS, RAS_DECODE_ERROR_TYPE_ON_DIE_ECC, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_UNCORRECTED_NON_FATAL},
|
||||
{23, RAS_DECODE_CATEGORY_HBM_ERRORS, RAS_DECODE_ERROR_TYPE_END_TO_END_CRC, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_UNCORRECTED_NON_FATAL},
|
||||
{24, RAS_DECODE_CATEGORY_HBM_ERRORS, RAS_DECODE_ERROR_TYPE_ALL, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_CORRECTED},
|
||||
{25, RAS_DECODE_CATEGORY_HBM_ERRORS, RAS_DECODE_ERROR_TYPE_ALL_OTHERS, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FATAL},
|
||||
{26, RAS_DECODE_CATEGORY_DEVICE_INTERNAL_ERRORS, RAS_DECODE_ERROR_TYPE_HARDWARE_ASSERTION, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FATAL},
|
||||
{27, RAS_DECODE_CATEGORY_DEVICE_INTERNAL_ERRORS, RAS_DECODE_ERROR_TYPE_WATCHDOG_TIMEOUT, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FATAL},
|
||||
{28, RAS_DECODE_CATEGORY_DEVICE_INTERNAL_ERRORS, RAS_DECODE_ERROR_TYPE_ALL_OTHERS, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_UNCORRECTED_NON_FATAL},
|
||||
{29, RAS_DECODE_CATEGORY_DEVICE_INTERNAL_ERRORS, RAS_DECODE_ERROR_TYPE_ALL_OTHERS, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_CORRECTED},
|
||||
{30, RAS_DECODE_CATEGORY_DEVICE_INTERNAL_ERRORS, RAS_DECODE_ERROR_TYPE_ALL_OTHERS, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FATAL},
|
||||
{31, RAS_DECODE_CATEGORY_CPER_FORMAT, RAS_DECODE_ERROR_TYPE_MALFORMED_CPER, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_ALL_CAPS},
|
||||
{32, RAS_DECODE_CATEGORY_CPER_FORMAT, RAS_DECODE_ERROR_TYPE_INCOMPLETE_RAS_DECODE_DATA, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_ALL_CAPS},
|
||||
{33, RAS_DECODE_CATEGORY_CPER_FORMAT, RAS_DECODE_ERROR_TYPE_INVALID_RAS_DECODE_DATA, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_ALL_CAPS},
|
||||
{34, RAS_DECODE_CATEGORY_UNIDENTIFIED_ERRORS, RAS_DECODE_ERROR_TYPE_UNIDENTIFIED_ERROR, RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_ALL_CAPS}};
|
||||
{1, RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, RAS_DECODE_ERROR_TYPE_FW_LOAD,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FAIL_TO_INIT},
|
||||
{2, RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, RAS_DECODE_ERROR_TYPE_HBM_BIST_TEST,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FAIL_TO_INIT},
|
||||
{3, RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, RAS_DECODE_ERROR_TYPE_HBM_MEMORY_TEST,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FAIL_TO_INIT},
|
||||
{4, RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, RAS_DECODE_ERROR_TYPE_HBM_TRAINING,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FAIL_TO_INIT},
|
||||
{5, RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, RAS_DECODE_ERROR_TYPE_UNHANDLED,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FAIL_TO_INIT},
|
||||
{6, RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, RAS_DECODE_ERROR_TYPE_UNKNOWN_ERROR,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FAIL_TO_INIT},
|
||||
{7, RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, RAS_DECODE_ERROR_TYPE_USR_CP_LINK_TRAINING,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FAIL_TO_INIT},
|
||||
{8, RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, RAS_DECODE_ERROR_TYPE_USR_DP_LINK_TRAINING,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FAIL_TO_INIT},
|
||||
{9, RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, RAS_DECODE_ERROR_TYPE_WAFL_LINK_TRAINING,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FAIL_TO_INIT},
|
||||
{10, RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, RAS_DECODE_ERROR_TYPE_XGMI_LINK_TRAINING,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FAIL_TO_INIT},
|
||||
{11, RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, RAS_DECODE_ERROR_TYPE_BOOT_CONTROLLER_DATA_ABORT,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FAIL_TO_INIT},
|
||||
{12, RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, RAS_DECODE_ERROR_TYPE_BOOT_CONTROLLER_GENERIC,
|
||||
RAS_DECODE_PROTOCOL_CPER_WITH_SPACE, RAS_DECODE_SEVERITY_FAIL_TO_INIT},
|
||||
{13, RAS_DECODE_CATEGORY_OFF_PACKAGE_LINK_ERRORS, RAS_DECODE_ERROR_TYPE_PCIE_AER,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_CORRECTED},
|
||||
{14, RAS_DECODE_CATEGORY_OFF_PACKAGE_LINK_ERRORS, RAS_DECODE_ERROR_TYPE_PCIE_AER,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FATAL},
|
||||
{15, RAS_DECODE_CATEGORY_OFF_PACKAGE_LINK_ERRORS, RAS_DECODE_ERROR_TYPE_WAFL,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_CORRECTED},
|
||||
{16, RAS_DECODE_CATEGORY_OFF_PACKAGE_LINK_ERRORS, RAS_DECODE_ERROR_TYPE_WAFL,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FATAL},
|
||||
{17, RAS_DECODE_CATEGORY_OFF_PACKAGE_LINK_ERRORS, RAS_DECODE_ERROR_TYPE_XGMI,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_CORRECTED},
|
||||
{18, RAS_DECODE_CATEGORY_OFF_PACKAGE_LINK_ERRORS, RAS_DECODE_ERROR_TYPE_XGMI,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FATAL},
|
||||
{19, RAS_DECODE_CATEGORY_HBM_ERRORS, RAS_DECODE_ERROR_TYPE_BAD_PAGE_RETIREMENT_THRESHOLD,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FATAL},
|
||||
{20, RAS_DECODE_CATEGORY_HBM_ERRORS, RAS_DECODE_ERROR_TYPE_ON_DIE_ECC, RAS_DECODE_PROTOCOL_CPER,
|
||||
RAS_DECODE_SEVERITY_FATAL},
|
||||
{21, RAS_DECODE_CATEGORY_HBM_ERRORS, RAS_DECODE_ERROR_TYPE_END_TO_END_CRC,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FATAL},
|
||||
{22, RAS_DECODE_CATEGORY_HBM_ERRORS, RAS_DECODE_ERROR_TYPE_ON_DIE_ECC, RAS_DECODE_PROTOCOL_CPER,
|
||||
RAS_DECODE_SEVERITY_UNCORRECTED_NON_FATAL},
|
||||
{23, RAS_DECODE_CATEGORY_HBM_ERRORS, RAS_DECODE_ERROR_TYPE_END_TO_END_CRC,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_UNCORRECTED_NON_FATAL},
|
||||
{24, RAS_DECODE_CATEGORY_HBM_ERRORS, RAS_DECODE_ERROR_TYPE_ALL, RAS_DECODE_PROTOCOL_CPER,
|
||||
RAS_DECODE_SEVERITY_CORRECTED},
|
||||
{25, RAS_DECODE_CATEGORY_HBM_ERRORS, RAS_DECODE_ERROR_TYPE_ALL_OTHERS, RAS_DECODE_PROTOCOL_CPER,
|
||||
RAS_DECODE_SEVERITY_FATAL},
|
||||
{26, RAS_DECODE_CATEGORY_DEVICE_INTERNAL_ERRORS, RAS_DECODE_ERROR_TYPE_HARDWARE_ASSERTION,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FATAL},
|
||||
{27, RAS_DECODE_CATEGORY_DEVICE_INTERNAL_ERRORS, RAS_DECODE_ERROR_TYPE_WATCHDOG_TIMEOUT,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FATAL},
|
||||
{28, RAS_DECODE_CATEGORY_DEVICE_INTERNAL_ERRORS, RAS_DECODE_ERROR_TYPE_ALL_OTHERS,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_UNCORRECTED_NON_FATAL},
|
||||
{29, RAS_DECODE_CATEGORY_DEVICE_INTERNAL_ERRORS, RAS_DECODE_ERROR_TYPE_ALL_OTHERS,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_CORRECTED},
|
||||
{30, RAS_DECODE_CATEGORY_DEVICE_INTERNAL_ERRORS, RAS_DECODE_ERROR_TYPE_ALL_OTHERS,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_FATAL},
|
||||
{31, RAS_DECODE_CATEGORY_CPER_FORMAT, RAS_DECODE_ERROR_TYPE_MALFORMED_CPER,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_ALL_CAPS},
|
||||
{32, RAS_DECODE_CATEGORY_CPER_FORMAT, RAS_DECODE_ERROR_TYPE_INCOMPLETE_RAS_DECODE_DATA,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_ALL_CAPS},
|
||||
{33, RAS_DECODE_CATEGORY_CPER_FORMAT, RAS_DECODE_ERROR_TYPE_INVALID_RAS_DECODE_DATA,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_ALL_CAPS},
|
||||
{34, RAS_DECODE_CATEGORY_UNIDENTIFIED_ERRORS, RAS_DECODE_ERROR_TYPE_UNIDENTIFIED_ERROR,
|
||||
RAS_DECODE_PROTOCOL_CPER, RAS_DECODE_SEVERITY_ALL_CAPS}};
|
||||
|
||||
static const size_t NUM_ERROR_ENTRIES = sizeof(error_map) / sizeof(error_map[0]);
|
||||
|
||||
int get_error_id(const char *error_category, const char *error_type, const char *error_severity)
|
||||
{
|
||||
if (!error_category || !error_type || !error_severity ||
|
||||
strcmp(error_category, RAS_DECODE_SEVERITY_UNKNOWN) == 0 ||
|
||||
strcmp(error_type, RAS_DECODE_SEVERITY_UNKNOWN) == 0 ||
|
||||
strcmp(error_severity, RAS_DECODE_SEVERITY_UNKNOWN) == 0)
|
||||
{
|
||||
return RAS_DECODE_ERROR_INVALID_RAS_DECODE_DATA_ID; // Return ID for "Invalid Error" if any input is "UNKNOWN" or NULL
|
||||
}
|
||||
int get_error_id(const char *error_category, const char *error_type, const char *error_severity) {
|
||||
if (!error_category || !error_type || !error_severity ||
|
||||
strcmp(error_category, RAS_DECODE_SEVERITY_UNKNOWN) == 0 ||
|
||||
strcmp(error_type, RAS_DECODE_SEVERITY_UNKNOWN) == 0 ||
|
||||
strcmp(error_severity, RAS_DECODE_SEVERITY_UNKNOWN) == 0) {
|
||||
return RAS_DECODE_ERROR_INVALID_RAS_DECODE_DATA_ID; // Return ID for "Invalid Error" if any
|
||||
// input is "UNKNOWN" or NULL
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < NUM_ERROR_ENTRIES; i++)
|
||||
{
|
||||
if (strcmp(error_map[i].error_category, error_category) == 0 &&
|
||||
strcmp(error_map[i].error_type, error_type) == 0 &&
|
||||
strcmp(error_map[i].error_severity, error_severity) == 0)
|
||||
{
|
||||
return (int)error_map[i].id;
|
||||
}
|
||||
for (size_t i = 0; i < NUM_ERROR_ENTRIES; i++) {
|
||||
if (strcmp(error_map[i].error_category, error_category) == 0 &&
|
||||
strcmp(error_map[i].error_type, error_type) == 0 &&
|
||||
strcmp(error_map[i].error_severity, error_severity) == 0) {
|
||||
return (int)error_map[i].id;
|
||||
}
|
||||
}
|
||||
|
||||
return RAS_DECODE_ERROR_UNIDENTIFIED_ERROR_ID; // Return ID for "Unidentified Errors" if no match found
|
||||
return RAS_DECODE_ERROR_UNIDENTIFIED_ERROR_ID; // Return ID for "Unidentified Errors" if no match
|
||||
// found
|
||||
}
|
||||
|
||||
@@ -21,54 +21,55 @@
|
||||
*/
|
||||
|
||||
#include "json_printer.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static void print_json_value_internal(JsonValue *value, int indent) {
|
||||
if (!value) return;
|
||||
|
||||
switch (value->type) {
|
||||
case JSON_NULL:
|
||||
printf("null");
|
||||
break;
|
||||
case JSON_BOOL:
|
||||
printf("%s", value->data.boolean ? "true" : "false");
|
||||
break;
|
||||
case JSON_NUMBER:
|
||||
printf("%.0f", value->data.number);
|
||||
break;
|
||||
case JSON_STRING:
|
||||
printf("\"%s\"", value->data.string ? value->data.string : "");
|
||||
break;
|
||||
case JSON_OBJECT: {
|
||||
printf("{\n");
|
||||
JsonPair *pair = value->data.object;
|
||||
bool first = true;
|
||||
while (pair) {
|
||||
if (!first) printf(",\n");
|
||||
for (int i = 0; i < indent + 3; i++) printf(" ");
|
||||
printf("\"%s\": ", pair->key);
|
||||
print_json_value_internal(pair->value, indent + 3);
|
||||
pair = pair->next;
|
||||
first = false;
|
||||
}
|
||||
printf("\n");
|
||||
for (int i = 0; i < indent; i++) printf(" ");
|
||||
printf("}");
|
||||
break;
|
||||
}
|
||||
case JSON_ARRAY: {
|
||||
printf("[");
|
||||
for (size_t i = 0; i < value->data.array.count; i++) {
|
||||
if (i > 0) printf(", ");
|
||||
print_json_value_internal(value->data.array.items[i], indent);
|
||||
}
|
||||
printf("]");
|
||||
break;
|
||||
}
|
||||
if (!value) return;
|
||||
|
||||
switch (value->type) {
|
||||
case JSON_NULL:
|
||||
printf("null");
|
||||
break;
|
||||
case JSON_BOOL:
|
||||
printf("%s", value->data.boolean ? "true" : "false");
|
||||
break;
|
||||
case JSON_NUMBER:
|
||||
printf("%.0f", value->data.number);
|
||||
break;
|
||||
case JSON_STRING:
|
||||
printf("\"%s\"", value->data.string ? value->data.string : "");
|
||||
break;
|
||||
case JSON_OBJECT: {
|
||||
printf("{\n");
|
||||
JsonPair *pair = value->data.object;
|
||||
bool first = true;
|
||||
while (pair) {
|
||||
if (!first) printf(",\n");
|
||||
for (int i = 0; i < indent + 3; i++) printf(" ");
|
||||
printf("\"%s\": ", pair->key);
|
||||
print_json_value_internal(pair->value, indent + 3);
|
||||
pair = pair->next;
|
||||
first = false;
|
||||
}
|
||||
printf("\n");
|
||||
for (int i = 0; i < indent; i++) printf(" ");
|
||||
printf("}");
|
||||
break;
|
||||
}
|
||||
case JSON_ARRAY: {
|
||||
printf("[");
|
||||
for (size_t i = 0; i < value->data.array.count; i++) {
|
||||
if (i > 0) printf(", ");
|
||||
print_json_value_internal(value->data.array.items[i], indent);
|
||||
}
|
||||
printf("]");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void print_json_value(JsonValue *value) {
|
||||
print_json_value_internal(value, 0);
|
||||
printf("\n");
|
||||
print_json_value_internal(value, 0);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
+149
-142
@@ -21,185 +21,192 @@
|
||||
*/
|
||||
|
||||
#include "json_util.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define JSON_ARRAY_INITIAL_CAPACITY 16
|
||||
|
||||
JsonValue* json_create_null(void) {
|
||||
JsonValue *val = calloc(1, sizeof(JsonValue));
|
||||
if (!val) return NULL;
|
||||
val->type = JSON_NULL;
|
||||
return val;
|
||||
JsonValue *json_create_null(void) {
|
||||
JsonValue *val = calloc(1, sizeof(JsonValue));
|
||||
if (!val) return NULL;
|
||||
val->type = JSON_NULL;
|
||||
return val;
|
||||
}
|
||||
|
||||
JsonValue* json_create_bool(bool b) {
|
||||
JsonValue *val = calloc(1, sizeof(JsonValue));
|
||||
if (!val) return NULL;
|
||||
val->type = JSON_BOOL;
|
||||
val->data.boolean = b;
|
||||
return val;
|
||||
JsonValue *json_create_bool(bool b) {
|
||||
JsonValue *val = calloc(1, sizeof(JsonValue));
|
||||
if (!val) return NULL;
|
||||
val->type = JSON_BOOL;
|
||||
val->data.boolean = b;
|
||||
return val;
|
||||
}
|
||||
|
||||
JsonValue* json_create_number(double num) {
|
||||
JsonValue *val = calloc(1, sizeof(JsonValue));
|
||||
if (!val) return NULL;
|
||||
val->type = JSON_NUMBER;
|
||||
val->data.number = num;
|
||||
return val;
|
||||
JsonValue *json_create_number(double num) {
|
||||
JsonValue *val = calloc(1, sizeof(JsonValue));
|
||||
if (!val) return NULL;
|
||||
val->type = JSON_NUMBER;
|
||||
val->data.number = num;
|
||||
return val;
|
||||
}
|
||||
|
||||
JsonValue* json_create_string(const char *str) {
|
||||
if (!str) return NULL;
|
||||
|
||||
JsonValue *val = calloc(1, sizeof(JsonValue));
|
||||
if (!val) return NULL;
|
||||
|
||||
val->type = JSON_STRING;
|
||||
val->data.string = strdup(str);
|
||||
if (!val->data.string) {
|
||||
free(val);
|
||||
return NULL;
|
||||
}
|
||||
return val;
|
||||
JsonValue *json_create_string(const char *str) {
|
||||
if (!str) return NULL;
|
||||
|
||||
JsonValue *val = calloc(1, sizeof(JsonValue));
|
||||
if (!val) return NULL;
|
||||
|
||||
val->type = JSON_STRING;
|
||||
val->data.string = strdup(str);
|
||||
if (!val->data.string) {
|
||||
free(val);
|
||||
return NULL;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
JsonValue* json_create_object(void) {
|
||||
JsonValue *val = calloc(1, sizeof(JsonValue));
|
||||
if (!val) return NULL;
|
||||
val->type = JSON_OBJECT;
|
||||
val->data.object = NULL;
|
||||
return val;
|
||||
JsonValue *json_create_object(void) {
|
||||
JsonValue *val = calloc(1, sizeof(JsonValue));
|
||||
if (!val) return NULL;
|
||||
val->type = JSON_OBJECT;
|
||||
val->data.object = NULL;
|
||||
return val;
|
||||
}
|
||||
|
||||
JsonValue* json_create_array(void) {
|
||||
JsonValue *val = calloc(1, sizeof(JsonValue));
|
||||
if (!val) return NULL;
|
||||
|
||||
val->type = JSON_ARRAY;
|
||||
val->data.array.items = malloc(sizeof(JsonValue*) * JSON_ARRAY_INITIAL_CAPACITY);
|
||||
if (!val->data.array.items) {
|
||||
free(val);
|
||||
return NULL;
|
||||
}
|
||||
val->data.array.count = 0;
|
||||
val->data.array.capacity = JSON_ARRAY_INITIAL_CAPACITY;
|
||||
return val;
|
||||
JsonValue *json_create_array(void) {
|
||||
JsonValue *val = calloc(1, sizeof(JsonValue));
|
||||
if (!val) return NULL;
|
||||
|
||||
val->type = JSON_ARRAY;
|
||||
val->data.array.items = malloc(sizeof(JsonValue *) * JSON_ARRAY_INITIAL_CAPACITY);
|
||||
if (!val->data.array.items) {
|
||||
free(val);
|
||||
return NULL;
|
||||
}
|
||||
val->data.array.count = 0;
|
||||
val->data.array.capacity = JSON_ARRAY_INITIAL_CAPACITY;
|
||||
return val;
|
||||
}
|
||||
|
||||
void json_object_set(JsonValue *obj, const char *key, JsonValue *value) {
|
||||
if (!obj || obj->type != JSON_OBJECT || !key || !value) return;
|
||||
|
||||
// Check if key already exists and update it
|
||||
JsonPair *current = obj->data.object;
|
||||
while (current) {
|
||||
if (strcmp(current->key, key) == 0) {
|
||||
json_free(current->value);
|
||||
current->value = value;
|
||||
return;
|
||||
}
|
||||
current = current->next;
|
||||
if (!obj || obj->type != JSON_OBJECT || !key || !value) {
|
||||
json_free(value);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if key already exists and update it
|
||||
JsonPair *current = obj->data.object;
|
||||
while (current) {
|
||||
if (strcmp(current->key, key) == 0) {
|
||||
json_free(current->value);
|
||||
current->value = value;
|
||||
return;
|
||||
}
|
||||
|
||||
// Key doesn't exist, create new pair
|
||||
JsonPair *pair = malloc(sizeof(JsonPair));
|
||||
if (!pair) return;
|
||||
|
||||
pair->key = strdup(key);
|
||||
if (!pair->key) {
|
||||
free(pair);
|
||||
return;
|
||||
}
|
||||
|
||||
pair->value = value;
|
||||
pair->next = NULL;
|
||||
|
||||
if (!obj->data.object) {
|
||||
obj->data.object = pair;
|
||||
} else {
|
||||
JsonPair *last = obj->data.object;
|
||||
while (last->next) {
|
||||
last = last->next;
|
||||
}
|
||||
last->next = pair;
|
||||
current = current->next;
|
||||
}
|
||||
|
||||
// Key doesn't exist, create new pair
|
||||
JsonPair *pair = malloc(sizeof(JsonPair));
|
||||
if (!pair) {
|
||||
json_free(value);
|
||||
return;
|
||||
}
|
||||
|
||||
pair->key = strdup(key);
|
||||
if (!pair->key) {
|
||||
free(pair);
|
||||
json_free(value);
|
||||
return;
|
||||
}
|
||||
|
||||
pair->value = value;
|
||||
pair->next = NULL;
|
||||
|
||||
if (!obj->data.object) {
|
||||
obj->data.object = pair;
|
||||
} else {
|
||||
JsonPair *last = obj->data.object;
|
||||
while (last->next) {
|
||||
last = last->next;
|
||||
}
|
||||
last->next = pair;
|
||||
}
|
||||
}
|
||||
|
||||
JsonValue* json_object_get(JsonValue *obj, const char *key) {
|
||||
if (!obj || obj->type != JSON_OBJECT || !key) return NULL;
|
||||
|
||||
JsonPair *current = obj->data.object;
|
||||
while (current) {
|
||||
if (strcmp(current->key, key) == 0) {
|
||||
return current->value;
|
||||
}
|
||||
current = current->next;
|
||||
JsonValue *json_object_get(JsonValue *obj, const char *key) {
|
||||
if (!obj || obj->type != JSON_OBJECT || !key) return NULL;
|
||||
|
||||
JsonPair *current = obj->data.object;
|
||||
while (current) {
|
||||
if (strcmp(current->key, key) == 0) {
|
||||
return current->value;
|
||||
}
|
||||
return NULL;
|
||||
current = current->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool json_object_has_key(JsonValue *obj, const char *key) {
|
||||
return json_object_get(obj, key) != NULL;
|
||||
return json_object_get(obj, key) != NULL;
|
||||
}
|
||||
|
||||
bool json_array_push(JsonValue *arr, JsonValue *value) {
|
||||
if (!arr || arr->type != JSON_ARRAY || !value) return false;
|
||||
|
||||
// Resize array if needed
|
||||
if (arr->data.array.count >= arr->data.array.capacity) {
|
||||
size_t new_capacity = arr->data.array.capacity * 2;
|
||||
JsonValue **new_items = realloc(arr->data.array.items,
|
||||
sizeof(JsonValue*) * new_capacity);
|
||||
if (!new_items) return false;
|
||||
|
||||
arr->data.array.items = new_items;
|
||||
arr->data.array.capacity = new_capacity;
|
||||
}
|
||||
|
||||
arr->data.array.items[arr->data.array.count] = value;
|
||||
arr->data.array.count++;
|
||||
return true;
|
||||
if (!arr || arr->type != JSON_ARRAY || !value) return false;
|
||||
|
||||
// Resize array if needed
|
||||
if (arr->data.array.count >= arr->data.array.capacity) {
|
||||
size_t new_capacity = arr->data.array.capacity * 2;
|
||||
JsonValue **new_items = realloc(arr->data.array.items, sizeof(JsonValue *) * new_capacity);
|
||||
if (!new_items) return false;
|
||||
|
||||
arr->data.array.items = new_items;
|
||||
arr->data.array.capacity = new_capacity;
|
||||
}
|
||||
|
||||
arr->data.array.items[arr->data.array.count] = value;
|
||||
arr->data.array.count++;
|
||||
return true;
|
||||
}
|
||||
|
||||
JsonValue* json_array_get(JsonValue *arr, size_t index) {
|
||||
if (!arr || arr->type != JSON_ARRAY || index >= arr->data.array.count) {
|
||||
return NULL;
|
||||
}
|
||||
return arr->data.array.items[index];
|
||||
JsonValue *json_array_get(JsonValue *arr, size_t index) {
|
||||
if (!arr || arr->type != JSON_ARRAY || index >= arr->data.array.count) {
|
||||
return NULL;
|
||||
}
|
||||
return arr->data.array.items[index];
|
||||
}
|
||||
|
||||
size_t json_array_size(JsonValue *arr) {
|
||||
if (!arr || arr->type != JSON_ARRAY) return 0;
|
||||
return arr->data.array.count;
|
||||
if (!arr || arr->type != JSON_ARRAY) return 0;
|
||||
return arr->data.array.count;
|
||||
}
|
||||
|
||||
void json_free(JsonValue *val) {
|
||||
if (!val) return;
|
||||
|
||||
switch (val->type) {
|
||||
case JSON_STRING:
|
||||
free(val->data.string);
|
||||
break;
|
||||
case JSON_OBJECT: {
|
||||
JsonPair *current = val->data.object;
|
||||
while (current) {
|
||||
JsonPair *next = current->next;
|
||||
free(current->key);
|
||||
json_free(current->value);
|
||||
free(current);
|
||||
current = next;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case JSON_ARRAY:
|
||||
for (size_t i = 0; i < val->data.array.count; i++) {
|
||||
json_free(val->data.array.items[i]);
|
||||
}
|
||||
free(val->data.array.items);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if (!val) return;
|
||||
|
||||
switch (val->type) {
|
||||
case JSON_STRING:
|
||||
free(val->data.string);
|
||||
break;
|
||||
case JSON_OBJECT: {
|
||||
JsonPair *current = val->data.object;
|
||||
while (current) {
|
||||
JsonPair *next = current->next;
|
||||
free(current->key);
|
||||
json_free(current->value);
|
||||
free(current);
|
||||
current = next;
|
||||
}
|
||||
break;
|
||||
}
|
||||
free(val);
|
||||
case JSON_ARRAY:
|
||||
for (size_t i = 0; i < val->data.array.count; i++) {
|
||||
json_free(val->data.array.items[i]);
|
||||
}
|
||||
free(val->data.array.items);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
free(val);
|
||||
}
|
||||
|
||||
+163
-160
@@ -28,180 +28,183 @@
|
||||
* with sample raw data to decode ACA error information.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ras_decode_api.h>
|
||||
#include <aca_version.h>
|
||||
#include <ras_decode_constants.h>
|
||||
#include <aca_decode.h>
|
||||
#include <json_printer.h>
|
||||
#include <stdint.h>
|
||||
#include <aca_version.h>
|
||||
#include <inttypes.h>
|
||||
#include <json_printer.h>
|
||||
#include <ras_decode_api.h>
|
||||
#include <ras_decode_constants.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// Function prototype
|
||||
void print_version_info(void);
|
||||
void demonstrate_json_decoding(void);
|
||||
|
||||
void print_version_info(void)
|
||||
{
|
||||
printf("=== ACA Decoder Library Version Information ===\n");
|
||||
printf("Version: %s\n", aca_get_version_string());
|
||||
printf("Major: %d\n", aca_get_version_major());
|
||||
printf("Minor: %d\n", aca_get_version_minor());
|
||||
printf("Patch: %d\n", aca_get_version_patch());
|
||||
void print_version_info(void) {
|
||||
printf("=== ACA Decoder Library Version Information ===\n");
|
||||
printf("Version: %s\n", aca_get_version_string());
|
||||
printf("Major: %d\n", aca_get_version_major());
|
||||
printf("Minor: %d\n", aca_get_version_minor());
|
||||
printf("Patch: %d\n", aca_get_version_patch());
|
||||
|
||||
aca_version_info_t version_info = aca_get_version_info();
|
||||
printf("Complete version info:\n");
|
||||
printf(" Major: %d\n", version_info.major);
|
||||
printf(" Minor: %d\n", version_info.minor);
|
||||
printf(" Patch: %d\n", version_info.patch);
|
||||
printf(" String: %s\n", version_info.string);
|
||||
printf("===============================================\n\n");
|
||||
aca_version_info_t version_info = aca_get_version_info();
|
||||
printf("Complete version info:\n");
|
||||
printf(" Major: %d\n", version_info.major);
|
||||
printf(" Minor: %d\n", version_info.minor);
|
||||
printf(" Patch: %d\n", version_info.patch);
|
||||
printf(" String: %s\n", version_info.string);
|
||||
printf("===============================================\n\n");
|
||||
}
|
||||
|
||||
// Function to demonstrate JSON decoding functionality
|
||||
void demonstrate_json_decoding(void)
|
||||
{
|
||||
printf("=== ACA Decoder - JSON Output Examples ===\n");
|
||||
|
||||
// Example 1: HBM FATAL ERROR (32-byte array)
|
||||
uint64_t register_array_32[RAS_DECODE_REGISTER_ARRAY_SIZE_32_BYTES] = {0xbaa000000004081b, 0x0, 0x209600090f00, 0x5d000000};
|
||||
printf("\n--- HBM FATAL ERROR (32-byte array) ---\n");
|
||||
printf("Decoded AFID: %d\n", decode_afid(register_array_32, RAS_DECODE_REGISTER_ARRAY_SIZE_32_BYTES, 0, 1, 1));
|
||||
|
||||
JsonValue *json_result_32 = decode_error_info(register_array_32, RAS_DECODE_REGISTER_ARRAY_SIZE_32_BYTES, 0, 1, 1);
|
||||
if (json_result_32) {
|
||||
print_json_value(json_result_32);
|
||||
json_free(json_result_32);
|
||||
}
|
||||
|
||||
// Example 2: GC FATAL ERROR
|
||||
uint64_t register_array_test[RAS_DECODE_REGISTER_ARRAY_SIZE_32_BYTES] = {0xbea00000003b0000, 0x100000029, 0x1200136430400, 0x20b};
|
||||
printf("\n--- GC FATAL ERROR ---\n");
|
||||
printf("Decoded AFID: %d\n", decode_afid(register_array_test, RAS_DECODE_REGISTER_ARRAY_SIZE_32_BYTES, 0, 1, 1));
|
||||
|
||||
JsonValue *json_result_test = decode_error_info(register_array_test, RAS_DECODE_REGISTER_ARRAY_SIZE_32_BYTES, 0, 1, 1);
|
||||
if (json_result_test) {
|
||||
print_json_value(json_result_test);
|
||||
json_free(json_result_test);
|
||||
}
|
||||
|
||||
// Example 3: HBM CORRECTED ERROR (128-byte array)
|
||||
uint64_t register_array_128[RAS_DECODE_REGISTER_ARRAY_SIZE_128_BYTES] = {
|
||||
0xffff,
|
||||
0xdc2040000000011b,
|
||||
0x0,
|
||||
0xd008000801000000,
|
||||
0x25000001ff,
|
||||
0x209600191f00,
|
||||
0xa000000,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0xd008000801000000,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0};
|
||||
|
||||
printf("\n--- HBM CORRECTED ERROR (128-byte array) ---\n");
|
||||
printf("Decoded AFID: %d\n", decode_afid(register_array_128, RAS_DECODE_REGISTER_ARRAY_SIZE_128_BYTES, 0, 1, 1));
|
||||
|
||||
JsonValue *json_result_128 = decode_error_info(register_array_128, RAS_DECODE_REGISTER_ARRAY_SIZE_128_BYTES, 0, 1, 1);
|
||||
if (json_result_128) {
|
||||
print_json_value(json_result_128);
|
||||
json_free(json_result_128);
|
||||
}
|
||||
|
||||
// Example 4: PCS XGMI Error
|
||||
uint64_t register_array_pcs_xgmi[RAS_DECODE_REGISTER_ARRAY_SIZE_128_BYTES] = {
|
||||
0xffffffff,
|
||||
0x9820000000060150,
|
||||
0x0,
|
||||
0xd008000200000000,
|
||||
0x27000001f9,
|
||||
0xe05012109201,
|
||||
0xaf812d4a000000,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0};
|
||||
|
||||
printf("\n--- PCS XGMI Error ---\n");
|
||||
printf("Decoded AFID: %d\n", decode_afid(register_array_pcs_xgmi, RAS_DECODE_REGISTER_ARRAY_SIZE_128_BYTES, 0, 1, 1));
|
||||
|
||||
JsonValue *json_result_pcs = decode_error_info(register_array_pcs_xgmi, RAS_DECODE_REGISTER_ARRAY_SIZE_128_BYTES, 0, 1, 1);
|
||||
if (json_result_pcs) {
|
||||
print_json_value(json_result_pcs);
|
||||
json_free(json_result_pcs);
|
||||
}
|
||||
|
||||
// Example 5: Bad page (threshold exceeded flag)
|
||||
uint64_t register_array_bad_page[RAS_DECODE_REGISTER_ARRAY_SIZE_128_BYTES] = {
|
||||
0x1,
|
||||
0xb000000000000137,
|
||||
0x0,
|
||||
0x0,
|
||||
0x1ff00000002,
|
||||
0x9600000000,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0};
|
||||
|
||||
printf("\n--- Bad Page (Threshold Exceeded) ---\n");
|
||||
printf("Decoded AFID: %d\n", decode_afid(register_array_bad_page, RAS_DECODE_REGISTER_ARRAY_SIZE_128_BYTES, RAS_DECODE_FLAG_THRESHOLD_EXCEEDED, 1, 1));
|
||||
|
||||
JsonValue *json_result_bad_page = decode_error_info(register_array_bad_page, RAS_DECODE_REGISTER_ARRAY_SIZE_128_BYTES, RAS_DECODE_FLAG_THRESHOLD_EXCEEDED, 1, 1);
|
||||
if (json_result_bad_page) {
|
||||
print_json_value(json_result_bad_page);
|
||||
json_free(json_result_bad_page);
|
||||
}
|
||||
void demonstrate_json_decoding(void) {
|
||||
printf("=== ACA Decoder - JSON Output Examples ===\n");
|
||||
|
||||
// Example 6: Boot Error Demo
|
||||
uint64_t boot_messages[8] = {
|
||||
0x3c000228a4, // Oam0bootmsg
|
||||
0x3c001228a4, // Oam1bootmsg
|
||||
0x3c002228a4, // Oam2bootmsg
|
||||
0x3c003128a4, // Oam3bootmsg
|
||||
0x3c004328a4, // Oam4bootmsg
|
||||
0x3c005228a4, // Oam5bootmsg
|
||||
0x3c006228a4, // Oam6bootmsg
|
||||
0x3c007228a4 // Oam7bootmsg
|
||||
};
|
||||
|
||||
printf("\n--- Boot Error Demo ---\n");
|
||||
printf("Decoded AFID: %d\n", decode_afid(boot_messages, sizeof(boot_messages)/sizeof(boot_messages[0]), 0, 1, 9));
|
||||
|
||||
JsonValue *json_result_boot = decode_error_info(boot_messages, sizeof(boot_messages)/sizeof(boot_messages[0]), 0, 1, 9);
|
||||
if (json_result_boot) {
|
||||
print_json_value(json_result_boot);
|
||||
json_free(json_result_boot);
|
||||
} else {
|
||||
printf("Failed to decode boot messages\n");
|
||||
}
|
||||
|
||||
printf("\n===========================================\n");
|
||||
// Example 1: HBM FATAL ERROR (32-byte array)
|
||||
uint64_t register_array_32[RAS_DECODE_REGISTER_ARRAY_SIZE_32_BYTES] = {
|
||||
0xbaa000000004081b, 0x0, 0x209600090f00, 0x5d000000};
|
||||
printf("\n--- HBM FATAL ERROR (32-byte array) ---\n");
|
||||
printf("Decoded AFID: %d\n",
|
||||
decode_afid(register_array_32, RAS_DECODE_REGISTER_ARRAY_SIZE_32_BYTES, 0, 1, 1));
|
||||
|
||||
JsonValue *json_result_32 =
|
||||
decode_error_info(register_array_32, RAS_DECODE_REGISTER_ARRAY_SIZE_32_BYTES, 0, 1, 1);
|
||||
if (json_result_32) {
|
||||
print_json_value(json_result_32);
|
||||
json_free(json_result_32);
|
||||
}
|
||||
|
||||
// Example 2: GC FATAL ERROR
|
||||
uint64_t register_array_test[RAS_DECODE_REGISTER_ARRAY_SIZE_32_BYTES] = {
|
||||
0xbea00000003b0000, 0x100000029, 0x1200136430400, 0x20b};
|
||||
printf("\n--- GC FATAL ERROR ---\n");
|
||||
printf("Decoded AFID: %d\n",
|
||||
decode_afid(register_array_test, RAS_DECODE_REGISTER_ARRAY_SIZE_32_BYTES, 0, 1, 1));
|
||||
|
||||
JsonValue *json_result_test =
|
||||
decode_error_info(register_array_test, RAS_DECODE_REGISTER_ARRAY_SIZE_32_BYTES, 0, 1, 1);
|
||||
if (json_result_test) {
|
||||
print_json_value(json_result_test);
|
||||
json_free(json_result_test);
|
||||
}
|
||||
|
||||
// Example 3: HBM CORRECTED ERROR (128-byte array)
|
||||
uint64_t register_array_128[RAS_DECODE_REGISTER_ARRAY_SIZE_128_BYTES] = {0xffff,
|
||||
0xdc2040000000011b,
|
||||
0x0,
|
||||
0xd008000801000000,
|
||||
0x25000001ff,
|
||||
0x209600191f00,
|
||||
0xa000000,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0xd008000801000000,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0};
|
||||
|
||||
printf("\n--- HBM CORRECTED ERROR (128-byte array) ---\n");
|
||||
printf("Decoded AFID: %d\n",
|
||||
decode_afid(register_array_128, RAS_DECODE_REGISTER_ARRAY_SIZE_128_BYTES, 0, 1, 1));
|
||||
|
||||
JsonValue *json_result_128 =
|
||||
decode_error_info(register_array_128, RAS_DECODE_REGISTER_ARRAY_SIZE_128_BYTES, 0, 1, 1);
|
||||
if (json_result_128) {
|
||||
print_json_value(json_result_128);
|
||||
json_free(json_result_128);
|
||||
}
|
||||
|
||||
// Example 4: PCS XGMI Error
|
||||
uint64_t register_array_pcs_xgmi[RAS_DECODE_REGISTER_ARRAY_SIZE_128_BYTES] = {0xffffffff,
|
||||
0x9820000000060150,
|
||||
0x0,
|
||||
0xd008000200000000,
|
||||
0x27000001f9,
|
||||
0xe05012109201,
|
||||
0xaf812d4a000000,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0};
|
||||
|
||||
printf("\n--- PCS XGMI Error ---\n");
|
||||
printf("Decoded AFID: %d\n",
|
||||
decode_afid(register_array_pcs_xgmi, RAS_DECODE_REGISTER_ARRAY_SIZE_128_BYTES, 0, 1, 1));
|
||||
|
||||
JsonValue *json_result_pcs =
|
||||
decode_error_info(register_array_pcs_xgmi, RAS_DECODE_REGISTER_ARRAY_SIZE_128_BYTES, 0, 1, 1);
|
||||
if (json_result_pcs) {
|
||||
print_json_value(json_result_pcs);
|
||||
json_free(json_result_pcs);
|
||||
}
|
||||
|
||||
// Example 5: Bad page (threshold exceeded flag)
|
||||
uint64_t register_array_bad_page[RAS_DECODE_REGISTER_ARRAY_SIZE_128_BYTES] = {
|
||||
0x1, 0xb000000000000137,
|
||||
0x0, 0x0,
|
||||
0x1ff00000002, 0x9600000000,
|
||||
0x0, 0x0,
|
||||
0x0, 0x0,
|
||||
0x0, 0x0,
|
||||
0x0, 0x0,
|
||||
0x0, 0x0};
|
||||
|
||||
printf("\n--- Bad Page (Threshold Exceeded) ---\n");
|
||||
printf("Decoded AFID: %d\n",
|
||||
decode_afid(register_array_bad_page, RAS_DECODE_REGISTER_ARRAY_SIZE_128_BYTES,
|
||||
RAS_DECODE_FLAG_THRESHOLD_EXCEEDED, 1, 1));
|
||||
|
||||
JsonValue *json_result_bad_page =
|
||||
decode_error_info(register_array_bad_page, RAS_DECODE_REGISTER_ARRAY_SIZE_128_BYTES,
|
||||
RAS_DECODE_FLAG_THRESHOLD_EXCEEDED, 1, 1);
|
||||
if (json_result_bad_page) {
|
||||
print_json_value(json_result_bad_page);
|
||||
json_free(json_result_bad_page);
|
||||
}
|
||||
|
||||
// Example 6: Boot Error Demo
|
||||
uint64_t boot_messages[8] = {
|
||||
0x3c000228a4, // Oam0bootmsg
|
||||
0x3c001228a4, // Oam1bootmsg
|
||||
0x3c002228a4, // Oam2bootmsg
|
||||
0x3c003128a4, // Oam3bootmsg
|
||||
0x3c004328a4, // Oam4bootmsg
|
||||
0x3c005228a4, // Oam5bootmsg
|
||||
0x3c006228a4, // Oam6bootmsg
|
||||
0x3c007228a4 // Oam7bootmsg
|
||||
};
|
||||
|
||||
printf("\n--- Boot Error Demo ---\n");
|
||||
printf("Decoded AFID: %d\n",
|
||||
decode_afid(boot_messages, sizeof(boot_messages) / sizeof(boot_messages[0]), 0, 1, 9));
|
||||
|
||||
JsonValue *json_result_boot =
|
||||
decode_error_info(boot_messages, sizeof(boot_messages) / sizeof(boot_messages[0]), 0, 1, 9);
|
||||
if (json_result_boot) {
|
||||
print_json_value(json_result_boot);
|
||||
json_free(json_result_boot);
|
||||
} else {
|
||||
printf("Failed to decode boot messages\n");
|
||||
}
|
||||
|
||||
printf("\n===========================================\n");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
// Display version information
|
||||
print_version_info();
|
||||
int main() {
|
||||
// Display version information
|
||||
print_version_info();
|
||||
|
||||
// Demonstrate the new JSON-based ACA decoding functionality
|
||||
demonstrate_json_decoding();
|
||||
// Demonstrate the new JSON-based ACA decoding functionality
|
||||
demonstrate_json_decoding();
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
+150
-161
@@ -20,185 +20,174 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "aca_decode.h"
|
||||
#include "ras_decode_constants.h"
|
||||
#include "boot_decode.h"
|
||||
#include "error_map.h"
|
||||
#include "json_util.h"
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int decode_afid(const uint64_t *register_array, size_t array_len, uint32_t flag, uint16_t hw_revision, uint16_t register_context_type)
|
||||
{
|
||||
if (!register_array)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
#include "aca_decode.h"
|
||||
#include "boot_decode.h"
|
||||
#include "error_map.h"
|
||||
#include "json_util.h"
|
||||
#include "ras_decode_constants.h"
|
||||
|
||||
// Use decode_error_info to get the JSON result
|
||||
JsonValue *json_result = decode_error_info(register_array, array_len, flag, hw_revision, register_context_type);
|
||||
if (!json_result) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Use the decode_error_info_afid function to extract AFID
|
||||
int afid = decode_error_info_afid(json_result);
|
||||
|
||||
json_free(json_result);
|
||||
return afid;
|
||||
int decode_afid(const uint64_t *register_array, size_t array_len, uint32_t flag,
|
||||
uint16_t hw_revision, uint16_t register_context_type) {
|
||||
if (!register_array) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Use decode_error_info to get the JSON result
|
||||
JsonValue *json_result =
|
||||
decode_error_info(register_array, array_len, flag, hw_revision, register_context_type);
|
||||
if (!json_result) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Use the decode_error_info_afid function to extract AFID
|
||||
int afid = decode_error_info_afid(json_result);
|
||||
|
||||
json_free(json_result);
|
||||
return afid;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (!register_array)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Check register context type parameter
|
||||
if (register_context_type == 9)
|
||||
{
|
||||
// For boot decode, use boot_decode_orchestrator with register_array and array_len
|
||||
// Flag is not used in boot decode
|
||||
return boot_decode_orchestrator((uint64_t*)register_array, array_len);
|
||||
}
|
||||
else if (register_context_type == 1)
|
||||
{
|
||||
// For ACA decode, use existing logic
|
||||
aca_raw_data_t raw_data = {0};
|
||||
|
||||
if (array_len == RAS_DECODE_REGISTER_ARRAY_SIZE_32_BYTES) // 32 bytes
|
||||
{
|
||||
raw_data.aca_status = register_array[0];
|
||||
raw_data.aca_addr = register_array[1];
|
||||
raw_data.aca_ipid = register_array[2];
|
||||
raw_data.aca_synd = register_array[3];
|
||||
}
|
||||
else if (array_len == RAS_DECODE_REGISTER_ARRAY_SIZE_128_BYTES) // 128 bytes
|
||||
{
|
||||
raw_data.aca_status = register_array[1];
|
||||
raw_data.aca_addr = register_array[2];
|
||||
raw_data.aca_ipid = register_array[5];
|
||||
raw_data.aca_synd = register_array[6];
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL; // Unsupported size
|
||||
}
|
||||
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) {
|
||||
if (!register_array) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
raw_data.flags = flag;
|
||||
raw_data.hw_revision = hw_revision;
|
||||
// Check register context type parameter
|
||||
if (register_context_type == 9) {
|
||||
// For boot decode, use boot_decode_orchestrator with register_array and array_len
|
||||
// Flag is not used in boot decode
|
||||
return boot_decode_orchestrator(register_array, array_len);
|
||||
} else if (register_context_type == 1) {
|
||||
// For ACA decode, use existing logic
|
||||
aca_raw_data_t raw_data = {0};
|
||||
|
||||
return aca_decode(&raw_data);
|
||||
}
|
||||
else
|
||||
if (array_len == RAS_DECODE_REGISTER_ARRAY_SIZE_32_BYTES) // 32 bytes
|
||||
{
|
||||
return NULL; // Invalid register context type
|
||||
raw_data.aca_status = register_array[0];
|
||||
raw_data.aca_addr = register_array[1];
|
||||
raw_data.aca_ipid = register_array[2];
|
||||
raw_data.aca_synd = register_array[3];
|
||||
} else if (array_len == RAS_DECODE_REGISTER_ARRAY_SIZE_128_BYTES) // 128 bytes
|
||||
{
|
||||
raw_data.aca_status = register_array[1];
|
||||
raw_data.aca_addr = register_array[2];
|
||||
raw_data.aca_ipid = register_array[5];
|
||||
raw_data.aca_synd = register_array[6];
|
||||
} else {
|
||||
return NULL; // Unsupported size
|
||||
}
|
||||
|
||||
raw_data.flags = flag;
|
||||
raw_data.hw_revision = hw_revision;
|
||||
|
||||
return aca_decode(&raw_data);
|
||||
} else {
|
||||
return NULL; // Invalid register context type
|
||||
}
|
||||
}
|
||||
|
||||
int decode_error_info_afid(JsonValue *error_json)
|
||||
{
|
||||
if (!error_json || error_json->type != JSON_OBJECT) {
|
||||
return -1; // Invalid AFID for null or invalid JSON
|
||||
int decode_error_info_afid(JsonValue *error_json) {
|
||||
if (!error_json || error_json->type != JSON_OBJECT) {
|
||||
return -1; // Invalid AFID for null or invalid JSON
|
||||
}
|
||||
|
||||
// Check if this is MCA error
|
||||
JsonValue *category_value = json_object_get(error_json, "error_category");
|
||||
JsonValue *type_value = json_object_get(error_json, "error_type");
|
||||
JsonValue *severity_value = json_object_get(error_json, "severity");
|
||||
|
||||
if (category_value && type_value && severity_value && category_value->type == JSON_STRING &&
|
||||
type_value->type == JSON_STRING && severity_value->type == JSON_STRING) {
|
||||
const char *error_category = category_value->data.string;
|
||||
const char *error_type = type_value->data.string;
|
||||
const char *error_severity = severity_value->data.string;
|
||||
|
||||
// Check for the specific case: HBM Errors + Bad Page Retirement Threshold + Fatal
|
||||
if (strcmp(error_category, RAS_DECODE_CATEGORY_HBM_ERRORS) == 0 &&
|
||||
strcmp(error_type, RAS_DECODE_ERROR_TYPE_BAD_PAGE_RETIREMENT_THRESHOLD) == 0 &&
|
||||
strcmp(error_severity, RAS_DECODE_SEVERITY_FATAL) == 0) {
|
||||
// Use the error_type directly as service_error for this case
|
||||
return get_error_id(error_category, error_type, error_severity);
|
||||
}
|
||||
|
||||
// Check if this is MCA error
|
||||
JsonValue *category_value = json_object_get(error_json, "error_category");
|
||||
JsonValue *type_value = json_object_get(error_json, "error_type");
|
||||
JsonValue *severity_value = json_object_get(error_json, "severity");
|
||||
// For other cases, we need to determine the service_error_type based on the logic
|
||||
// from get_service_error_type function
|
||||
const char *service_error = NULL;
|
||||
|
||||
if (category_value && type_value && severity_value &&
|
||||
category_value->type == JSON_STRING && type_value->type == JSON_STRING && severity_value->type == JSON_STRING) {
|
||||
const char *error_category = category_value->data.string;
|
||||
const char *error_type = type_value->data.string;
|
||||
const char *error_severity = severity_value->data.string;
|
||||
// Extract bank if needed for service error type determination
|
||||
JsonValue *bank_value = json_object_get(error_json, "bank");
|
||||
const char *error_bank =
|
||||
(bank_value && bank_value->type == JSON_STRING) ? bank_value->data.string : "";
|
||||
|
||||
// Check for the specific case: HBM Errors + Bad Page Retirement Threshold + Fatal
|
||||
if (strcmp(error_category, RAS_DECODE_CATEGORY_HBM_ERRORS) == 0 &&
|
||||
strcmp(error_type, RAS_DECODE_ERROR_TYPE_BAD_PAGE_RETIREMENT_THRESHOLD) == 0 &&
|
||||
strcmp(error_severity, RAS_DECODE_SEVERITY_FATAL) == 0) {
|
||||
|
||||
// Use the error_type directly as service_error for this case
|
||||
return get_error_id(error_category, error_type, error_severity);
|
||||
}
|
||||
|
||||
// For other cases, we need to determine the service_error_type based on the logic
|
||||
// from get_service_error_type function
|
||||
const char *service_error = NULL;
|
||||
|
||||
// Extract bank if needed for service error type determination
|
||||
JsonValue *bank_value = json_object_get(error_json, "bank");
|
||||
const char *error_bank = (bank_value && bank_value->type == JSON_STRING) ? bank_value->data.string : "";
|
||||
|
||||
if (strcmp(error_type, RAS_DECODE_ERROR_TYPE_BAD_PAGE_RETIREMENT_THRESHOLD) == 0) {
|
||||
service_error = RAS_DECODE_ERROR_TYPE_BAD_PAGE_RETIREMENT_THRESHOLD;
|
||||
}
|
||||
else if (strcmp(error_category, RAS_DECODE_CATEGORY_HBM_ERRORS) == 0 && strcmp(error_severity, RAS_DECODE_SEVERITY_CORRECTED) == 0) {
|
||||
service_error = RAS_DECODE_ERROR_TYPE_ALL;
|
||||
}
|
||||
else if (strcmp(error_type, "RdCrcErr") == 0) {
|
||||
service_error = RAS_DECODE_ERROR_TYPE_END_TO_END_CRC;
|
||||
}
|
||||
else if (strcmp(error_category, RAS_DECODE_CATEGORY_HBM_ERRORS) == 0 && strcmp(error_severity, RAS_DECODE_SEVERITY_FATAL) == 0 &&
|
||||
strcmp(error_type, RAS_DECODE_ERROR_TYPE_ON_DIE_ECC) != 0 && strcmp(error_type, RAS_DECODE_ERROR_TYPE_END_TO_END_CRC) != 0) {
|
||||
service_error = RAS_DECODE_ERROR_TYPE_ALL_OTHERS;
|
||||
}
|
||||
else if (strcmp(error_category, RAS_DECODE_CATEGORY_DEVICE_INTERNAL_ERRORS) == 0) {
|
||||
if ((strcmp(error_severity, RAS_DECODE_SEVERITY_UNCORRECTED_NON_FATAL) == 0 ||
|
||||
strcmp(error_severity, RAS_DECODE_SEVERITY_CORRECTED) == 0 ||
|
||||
strcmp(error_severity, RAS_DECODE_SEVERITY_FATAL) == 0) &&
|
||||
strcmp(error_type, RAS_DECODE_ERROR_TYPE_HARDWARE_ASSERTION) != 0 &&
|
||||
strcmp(error_type, RAS_DECODE_ERROR_TYPE_WATCHDOG_TIMEOUT) != 0) {
|
||||
service_error = RAS_DECODE_ERROR_TYPE_ALL_OTHERS;
|
||||
}
|
||||
}
|
||||
else if (strcmp(error_category, RAS_DECODE_CATEGORY_OFF_PACKAGE_LINK_ERRORS) == 0) {
|
||||
if (strcmp(error_bank, RAS_DECODE_BANK_PCS_XGMI) == 0) {
|
||||
service_error = RAS_DECODE_ERROR_TYPE_XGMI;
|
||||
}
|
||||
else if (strcmp(error_bank, RAS_DECODE_BANK_KPX_WAFL) == 0) {
|
||||
service_error = RAS_DECODE_ERROR_TYPE_WAFL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!service_error) {
|
||||
service_error = error_type; // Fallback to error_type
|
||||
}
|
||||
|
||||
return get_error_id(error_category, service_error, error_severity);
|
||||
if (strcmp(error_type, RAS_DECODE_ERROR_TYPE_BAD_PAGE_RETIREMENT_THRESHOLD) == 0) {
|
||||
service_error = RAS_DECODE_ERROR_TYPE_BAD_PAGE_RETIREMENT_THRESHOLD;
|
||||
} else if (strcmp(error_category, RAS_DECODE_CATEGORY_HBM_ERRORS) == 0 &&
|
||||
strcmp(error_severity, RAS_DECODE_SEVERITY_CORRECTED) == 0) {
|
||||
service_error = RAS_DECODE_ERROR_TYPE_ALL;
|
||||
} else if (strcmp(error_type, "RdCrcErr") == 0) {
|
||||
service_error = RAS_DECODE_ERROR_TYPE_END_TO_END_CRC;
|
||||
} else if (strcmp(error_category, RAS_DECODE_CATEGORY_HBM_ERRORS) == 0 &&
|
||||
strcmp(error_severity, RAS_DECODE_SEVERITY_FATAL) == 0 &&
|
||||
strcmp(error_type, RAS_DECODE_ERROR_TYPE_ON_DIE_ECC) != 0 &&
|
||||
strcmp(error_type, RAS_DECODE_ERROR_TYPE_END_TO_END_CRC) != 0) {
|
||||
service_error = RAS_DECODE_ERROR_TYPE_ALL_OTHERS;
|
||||
} else if (strcmp(error_category, RAS_DECODE_CATEGORY_DEVICE_INTERNAL_ERRORS) == 0) {
|
||||
if ((strcmp(error_severity, RAS_DECODE_SEVERITY_UNCORRECTED_NON_FATAL) == 0 ||
|
||||
strcmp(error_severity, RAS_DECODE_SEVERITY_CORRECTED) == 0 ||
|
||||
strcmp(error_severity, RAS_DECODE_SEVERITY_FATAL) == 0) &&
|
||||
strcmp(error_type, RAS_DECODE_ERROR_TYPE_HARDWARE_ASSERTION) != 0 &&
|
||||
strcmp(error_type, RAS_DECODE_ERROR_TYPE_WATCHDOG_TIMEOUT) != 0) {
|
||||
service_error = RAS_DECODE_ERROR_TYPE_ALL_OTHERS;
|
||||
}
|
||||
} else if (strcmp(error_category, RAS_DECODE_CATEGORY_OFF_PACKAGE_LINK_ERRORS) == 0) {
|
||||
if (strcmp(error_bank, RAS_DECODE_BANK_PCS_XGMI) == 0) {
|
||||
service_error = RAS_DECODE_ERROR_TYPE_XGMI;
|
||||
} else if (strcmp(error_bank, RAS_DECODE_BANK_KPX_WAFL) == 0) {
|
||||
service_error = RAS_DECODE_ERROR_TYPE_WAFL;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if this is a boot error
|
||||
// Find the first msg<i> key to get the error_type
|
||||
JsonPair *current_pair = error_json->data.object;
|
||||
JsonValue *first_msg = NULL;
|
||||
int lowest_msg_index = INT_MAX;
|
||||
|
||||
while (current_pair) {
|
||||
if (strncmp(current_pair->key, "msg", 3) == 0) {
|
||||
// Extract the message index
|
||||
int msg_index = atoi(current_pair->key + 3);
|
||||
if (msg_index < lowest_msg_index) {
|
||||
lowest_msg_index = msg_index;
|
||||
first_msg = current_pair->value;
|
||||
}
|
||||
}
|
||||
current_pair = current_pair->next;
|
||||
|
||||
if (!service_error) {
|
||||
service_error = error_type; // Fallback to error_type
|
||||
}
|
||||
|
||||
if (first_msg && first_msg->type == JSON_OBJECT) {
|
||||
// This is a boot error - extract error_type from the first message
|
||||
JsonValue *boot_error_type = json_object_get(first_msg, "error_type");
|
||||
if (boot_error_type && boot_error_type->type == JSON_STRING) {
|
||||
const char *service_error = NULL;
|
||||
service_error = boot_error_type->data.string;
|
||||
|
||||
// For boot errors, always use Boot-Time Errors category and Fail-to-init severity
|
||||
return get_error_id(RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, service_error, RAS_DECODE_SEVERITY_FAIL_TO_INIT);
|
||||
}
|
||||
|
||||
return get_error_id(error_category, service_error, error_severity);
|
||||
}
|
||||
|
||||
// Check if this is a boot error
|
||||
// Find the first msg<i> key to get the error_type
|
||||
JsonPair *current_pair = error_json->data.object;
|
||||
JsonValue *first_msg = NULL;
|
||||
int lowest_msg_index = INT_MAX;
|
||||
|
||||
while (current_pair) {
|
||||
if (strncmp(current_pair->key, "msg", 3) == 0) {
|
||||
// Extract the message index
|
||||
int msg_index = atoi(current_pair->key + 3);
|
||||
if (msg_index < lowest_msg_index) {
|
||||
lowest_msg_index = msg_index;
|
||||
first_msg = current_pair->value;
|
||||
}
|
||||
}
|
||||
|
||||
return -1; // Invalid AFID if neither MCA nor boot error format
|
||||
current_pair = current_pair->next;
|
||||
}
|
||||
|
||||
if (first_msg && first_msg->type == JSON_OBJECT) {
|
||||
// This is a boot error - extract error_type from the first message
|
||||
JsonValue *boot_error_type = json_object_get(first_msg, "error_type");
|
||||
if (boot_error_type && boot_error_type->type == JSON_STRING) {
|
||||
const char *service_error = NULL;
|
||||
service_error = boot_error_type->data.string;
|
||||
|
||||
// For boot errors, always use Boot-Time Errors category and Fail-to-init severity
|
||||
return get_error_id(RAS_DECODE_CATEGORY_BOOT_TIME_ERRORS, service_error,
|
||||
RAS_DECODE_SEVERITY_FAIL_TO_INIT);
|
||||
}
|
||||
}
|
||||
|
||||
return -1; // Invalid AFID if neither MCA nor boot error format
|
||||
}
|
||||
|
||||
مرجع در شماره جدید
Block a user