[SWDEV-522623] Add afid functionality to API and CLI (#330)

Change-Id: I015bde926491d54e09da8f39b05650515711e09f

[SWDEV-522623] Add afid functionality to API and CLI


Change-Id: I015bde926491d54e09da8f39b05650515711e09f

Signed-off-by: Oosman Saeed <oossaeed@amd.com>
Co-authored-by: Oosman Saeed <oossaeed@amd.com>
Esse commit está contido em:
Saeed, Oosman
2025-05-15 21:49:56 -05:00
commit de GitHub
commit 1bb1f8acc2
21 arquivos alterados com 2228 adições e 209 exclusões
+64
Ver Arquivo
@@ -0,0 +1,64 @@
/**
* @file aca_decode.h
* @brief Internal decoder interface and data structures
*/
#ifndef ACA_DECODE_H
#define ACA_DECODE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "aca_fields.h"
/**
* @brief Internal decoder structure with parsed register fields
*/
typedef struct
{
uint64_t aca_status; /**< Raw status 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_decoder_t;
/**
* @brief Structure containing raw ACA error data from hardware
*/
typedef struct
{
uint64_t aca_status; /**< Raw status 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;
/**
* @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 */
int afid; /**< AFID value (AMD Field ID) */
} aca_error_info_t;
/**
* @brief Main decode function that processes raw ACA error data
* @param[in] raw_data Pointer to structure containing raw ACA error data
* @return Decoded error information structure
*/
aca_error_info_t aca_decode(const aca_raw_data_t *raw_data);
#ifdef __cplusplus
}
#endif
#endif /* ACA_DECODE_H */
+110
Ver Arquivo
@@ -0,0 +1,110 @@
/**
* @file aca_fields.h
* @brief ACA register field definitions and manipulation functions
*
* Contains structures and functions for decoding and handling
* ACA register fields. It provides field
* definitions for status, IPID, and syndrome registers, along with
* functions to initialize and access these fields.
*/
#ifndef ACA_FIELDS_H
#define ACA_FIELDS_H
#include <stdint.h>
/**
* @brief Base structure for ACA fields containing raw 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;
} 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;
} 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;
} aca_synd_fields_t;
/**
* @brief Reads the raw value from an ACA field structure
* @param[in] fields Pointer to the ACA fields structure
* @return The raw 64-bit value stored in the structure
*/
uint64_t aca_fields_read(const aca_fields_t *fields);
/**
* @brief Initializes ACA status fields from a raw status register value
* @param[out] fields Pointer to the status fields structure to initialize
* @param[in] status_reg Raw 64-bit status register value
*/
void aca_status_init(aca_status_fields_t *fields, uint64_t status_reg);
/**
* @brief Initializes ACA IPID fields from a raw IPID register value
* @param[out] fields Pointer to the IPID fields structure to initialize
* @param[in] ipid_reg Raw 64-bit IPID register value
*/
void aca_ipid_init(aca_ipid_fields_t *fields, uint64_t ipid_reg);
/**
* @brief Initializes ACA syndrome fields from a raw syndrome register value
* @param[out] fields Pointer to the syndrome fields structure to initialize
* @param[in] synd_reg Raw 64-bit syndrome register value
*/
void aca_synd_init(aca_synd_fields_t *fields, uint64_t synd_reg);
#endif
+84
Ver Arquivo
@@ -0,0 +1,84 @@
/**
* @file aca_tables.h
* @brief ACA lookup table definitions and helper functions
* @details Contains data structures and functions definitions for mapping ACA Registers
* into their corresponding names and types.
*/
#ifndef ACA_TABLES_H
#define ACA_TABLES_H
#include <stdint.h>
#include <stddef.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 */
} 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 */
} 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 */
} aca_error_entry_t;
// External table declarations
extern const aca_bank_entry_t bank_table[];
extern const aca_error_type_t error_table[];
extern const aca_error_entry_t xcd_error_table[];
extern const aca_error_entry_t aid_error_table[];
// Table size constants
extern const size_t NUM_BANKS;
extern const size_t NUM_ERRORS;
extern const size_t NUM_XCD_ERRORS;
extern const size_t NUM_AID_ERRORS;
/**
* @brief Find bank name based on hardware ID and ACA type
* @param[in] hw_id Hardware ID value
* @param[in] aca_type ACA type value
* @param[out] bank_name Pointer to store result string
* @return 0 on success, 1 if not found, -1 on parameter error
*/
int find_bank_name(uint16_t hw_id, uint16_t aca_type, const char **bank_name);
/**
* @brief Find error type for a specific bank and error code
* @param[in] bank Bank name string
* @param[in] error_code Error code value
* @param[out] error_type Pointer to store result string
* @return 0 on success, 1 if not found, -1 on parameter error
*/
int find_error_type_by_bank(const char *bank, uint32_t error_code, const char **error_type);
/**
* @brief Generic lookup for error codes in an error table
* @param[in] table Pointer to error table
* @param[in] table_size Number of table entries
* @param[in] error_code Error code to look up
* @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);
#endif
+27
Ver Arquivo
@@ -0,0 +1,27 @@
#ifndef ERROR_MAP_H
#define ERROR_MAP_H
#include <stdint.h>
/**
* @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;
} error_map_entry_t;
/**
* @brief Get error ID based on category, type and severity
* @param[in] error_category Error category string
* @param[in] error_type Error type string
* @param[in] error_severity Error severity string
* @return Error ID if found, -1 if not found
*/
int get_error_id(const char *error_category, const char *error_type, const char *error_severity);
#endif /* ERROR_MAP_H */