The rasdaemon conding style follows Linux Kernel where it makes sense.
Yet, changes made overtime ended with some coding style non-compliances.
Adjust rasdaemon coding style by using:
scripts/checkpatch.pl --fix-inplace --strict *.c --ignore PREFER_KERNEL_TYPES
And doing some manual fixups where the script didn't work.
As a bonus, some typos were also fixed on some rasdaemon messages.
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
#include "ras-mce-handler.h"
#include "bitfield.h"
-unsigned bitfield_msg(char *buf, size_t len, const char **bitarray,
- unsigned array_len,
- unsigned bit_offset, unsigned ignore_bits,
- uint64_t status)
+unsigned int bitfield_msg(char *buf, size_t len, const char **bitarray,
+ unsigned int array_len,
+ unsigned int bit_offset, unsigned int ignore_bits,
+ uint64_t status)
{
int i, n;
char *p = buf;
static uint64_t bitmask(uint64_t i)
{
uint64_t mask = 1;
+
while (mask < i)
mask = (mask << 1) | 1;
return mask;
for (f = fields; f->str; f++) {
uint64_t v = (status >> f->start_bit) & bitmask(f->stringlen - 1);
char *s = NULL;
+
if (v < f->stringlen)
s = f->str[v];
if (!s) {
struct numfield *fields)
{
struct numfield *f;
+
for (f = fields; f->name; f++) {
uint64_t mask = (1ULL << (f->end - f->start + 1)) - 1;
uint64_t v = (status >> f->start) & mask;
+
if (v > 0 || f->force) {
char fmt[32] = {0};
+
snprintf(fmt, 32, "%%s: %s\n", f->fmt ? f->fmt : "%Lu");
mce_snprintf(e->error_msg, fmt, f->name, v);
}
};
static const char *k8threshold[] = {
- [0 ... K8_MCELOG_THRESHOLD_DRAM_ECC - 1] = "Unknow threshold counter",
+ [0 ... K8_MCELOG_THRESHOLD_DRAM_ECC - 1] = "Unknown threshold counter",
[K8_MCELOG_THRESHOLD_DRAM_ECC] = "MC4_MISC0 DRAM threshold",
[K8_MCELOG_THRESHOLD_LINK] = "MC4_MISC1 Link threshold",
[K8_MCELOG_THRESHOLD_L3_CACHE] = "MC4_MISC2 L3 Cache threshold",
static const char *transaction[] = {
"instruction", "data", "generic", "reserved"
};
+
static const char *cachelevel[] = {
"0", "1", "2", "generic"
};
+
static const char *memtrans[] = {
"generic error", "generic read", "generic write", "data read",
"data write", "instruction fetch", "prefetch", "evict", "snoop",
"?", "?", "?", "?", "?", "?", "?"
};
+
static const char *partproc[] = {
"local node origin", "local node response",
"local node observed", "generic participation"
};
+
static const char *timeout[] = {
"request didn't time out",
"request timed out"
};
+
static const char *memoryio[] = {
"memory", "res.", "i/o", "generic"
};
+
static const char *nbextendederr[] = {
"RAM ECC error",
"CRC error",
"L3 Cache Tag Error",
"L3 Cache LRU Error"
};
+
static const char *highbits[32] = {
[31] = "valid",
[30] = "error overflow (multiple errors)",
if (e->status & (3ULL << 45)) {
mce_snprintf(e->error_msg,
"Data cache ECC error (syndrome %x)",
- (uint32_t) (e->status >> 47) & 0xff);
+ (uint32_t)(e->status >> 47) & 0xff);
if (e->status & (1ULL << 40))
mce_snprintf(e->error_msg, "found by scrubber");
}
if ((errcode & 0xfff0) == 0x0010)
mce_snprintf(e->error_msg, "TLB parity error in %s array",
- (exterrcode == 0) ? "physical" : "virtual");
+ (exterrcode == 0) ? "physical" : "virtual");
}
static void decode_k8_bu_mc(struct mce_event *e)
mce_snprintf(e->error_msg, "L2 cache ECC error");
mce_snprintf(e->error_msg, "%s array error",
- !exterrcode ? "Bus or cache" : "Cache tag");
+ !exterrcode ? "Bus or cache" : "Cache tag");
}
-static void decode_k8_nb_mc(struct mce_event *e, unsigned *memerr)
+static void decode_k8_nb_mc(struct mce_event *e, unsigned int *memerr)
{
unsigned short exterrcode = (e->status >> 16) & 0x0f;
case 0:
*memerr = 1;
mce_snprintf(e->error_msg, "ECC syndrome = %x",
- (uint32_t) (e->status >> 47) & 0xff);
+ (uint32_t)(e->status >> 47) & 0xff);
break;
case 8:
*memerr = 1;
mce_snprintf(e->error_msg, "Chipkill ECC syndrome = %x",
- (uint32_t) ((((e->status >> 24) & 0xff) << 8)
- | ((e->status >> 47) & 0xff)));
+ (uint32_t)((((e->status >> 24) & 0xff) << 8)
+ | ((e->status >> 47) & 0xff)));
break;
case 1:
case 2:
case 4:
case 6:
mce_snprintf(e->error_msg, "link number = %x",
- (uint32_t) (e->status >> 36) & 0xf);
+ (uint32_t)(e->status >> 36) & 0xf);
break;
}
}
int parse_amd_k8_event(struct ras_events *ras, struct mce_event *e)
{
- unsigned ismemerr = 0;
+ unsigned int ismemerr = 0;
/* Don't handle GART errors */
if (e->bank == 4) {
unsigned short exterrcode = (e->status >> 16) & 0x0f;
+
if (exterrcode == 5 && (e->status & (1ULL << 61))) {
return -1;
}
SMCA_PCIE, /* PCI Express Unit */
SMCA_PCIE_V2,
SMCA_XGMI_PCS, /* xGMI PCS Unit */
- SMCA_NBIF, /*NBIF Unit */
- SMCA_SHUB, /* System Hub Unit */
- SMCA_SATA, /* SATA Unit */
- SMCA_USB, /* USB Unit */
+ SMCA_NBIF, /* NBIF Unit */
+ SMCA_SHUB, /* System Hub Unit */
+ SMCA_SATA, /* SATA Unit */
+ SMCA_USB, /* USB Unit */
SMCA_USR_DP, /* Ultra Short Reach Data Plane Controller */
SMCA_USR_CP, /* Ultra Short Reach Control Plane Controller */
SMCA_GMI_PCS, /* GMI PCS Unit */
[SMCA_PSP ... SMCA_PSP_V2] = { "Platform Security Processor" },
[SMCA_SMU ... SMCA_SMU_V2] = { "System Management Unit" },
[SMCA_MP5] = { "Microprocessor 5 Unit" },
- [SMCA_MPDMA] = { "MPDMA Unit" },
+ [SMCA_MPDMA] = { "MPDMA Unit" },
[SMCA_NBIO] = { "Northbridge IO Unit" },
[SMCA_PCIE ... SMCA_PCIE_V2] = { "PCI Express Unit" },
[SMCA_XGMI_PCS] = { "Ext Global Memory Interconnect PCS Unit" },
void amd_decode_errcode(struct mce_event *e)
{
-
decode_amd_errcode(e);
if (e->status & MCI_STATUS_POISON)
if (e->status & MCI_STATUS_TCC)
mce_snprintf(e->mcistatus_msg, "Task_context_corrupt");
-
}
+
/*
* To find the UMC channel represented by this bank we need to match on its
* instance_id. The instance_id of a bank is held in the lower 32 bits of its
return (umc % 2) ? tmp + 4 : tmp;
}
-static inline void fixup_hwid(struct mce_priv* m, uint32_t *hwid_mcatype)
+static inline void fixup_hwid(struct mce_priv *m, uint32_t *hwid_mcatype)
{
if (m->family == 0x19) {
switch (m->model) {
channel, csrow);
}
-
if (e->vdata_len) {
uint64_t smca_config = e->vdata[2];
if (smca_config & BIT(9))
memcpy(e->frutext, e->vdata, 16);
}
-
}
int parse_amd_smca_event(struct ras_events *ras, struct mce_event *e)
uint64_t mcgstatus = e->mcgstatus;
mce_snprintf(e->mcgstatus_msg, "mcgstatus=%lld",
- (long long)e->mcgstatus);
+ (long long)e->mcgstatus);
if (mcgstatus & MCG_STATUS_RIPV)
mce_snprintf(e->mcgstatus_msg, "RIPV");
static char *transaction[] = {
"instruction", "data", "generic", "reserved"
};
+
/* Error codes: cache level (LL) */
static char *cachelevel[] = {
"reserved", "L1", "L2", "L3/generic"
};
+
/* Error codes: memory transaction type (RRRR) */
static char *memtrans[] = {
"generic", "generic read", "generic write", "data read",
"data write", "instruction fetch", "prefetch", "evict", "snoop",
"?", "?", "?", "?", "?", "?", "?"
};
+
/* Participation Processor */
static char *partproc[] = {
"local node origin", "local node response",
"local node observed", "generic participation"
};
+
/* Timeout */
static char *timeout[] = {
"request didn't time out",
"request timed out"
};
+
/* internal unclassified error code */
static char *internal[] = { "reserved",
"reserved",
PP_MSG(ec), TO_MSG(ec),
R4_MSG(ec), LL_MSG(ec));
return;
-
}
{
uint64_t status = e->status;
uint32_t mca = status & 0xffff;
- unsigned rank0 = -1, rank1 = -1, chan;
+ unsigned int rank0 = -1, rank1 = -1, chan;
switch (e->bank) {
case 4:
/* Ignore unless this is an corrected extended error from an iMC bank */
if (e->bank < 9 || e->bank > 16 || (status & MCI_STATUS_UC) ||
- !test_prefix(7, status & 0xefff))
+ !test_prefix(7, status & 0xefff))
return;
/*
*/
if (rank0 != -1 && rank1 != -1)
mce_snprintf(e->mc_location, "ranks=%d and %d",
- rank0, rank1);
+ rank0, rank1);
else if (rank0 != -1)
mce_snprintf(e->mc_location, "rank=%d", rank0);
}
[0x22] = "Phy detected in-band reset (no width change)",
[0x23] = "Link failover clock failover",
[0x30] = "Rx detected CRC error - successful LLR after Phy re-init",
- [0x31] = "Rx detected CRC error - successful LLR wihout Phy re-init",
+ [0x31] = "Rx detected CRC error - successful LLR without Phy re-init",
};
static struct field qpi_mc[] = {
{
uint64_t status = e->status;
uint32_t mca = status & 0xffff;
- unsigned rank0 = -1, rank1 = -1, chan;
+ unsigned int rank0 = -1, rank1 = -1, chan;
switch (e->bank) {
case 4:
/* Ignore unless this is an corrected extended error from an iMC bank */
if (e->bank < 9 || e->bank > 16 || (status & MCI_STATUS_UC) ||
- !test_prefix(7, status & 0xefff))
+ !test_prefix(7, status & 0xefff))
return;
/*
*/
if (rank0 != -1 && rank1 != -1)
mce_snprintf(e->mc_location, "ranks=%d and %d",
- rank0, rank1);
+ rank0, rank1);
else if (rank0 != -1)
mce_snprintf(e->mc_location, "rank=%d", rank0);
}
static void dunnington_decode_internal(struct mce_event *e, uint64_t status)
{
uint32_t mca = (status >> 16) & 0xffff;
+
if ((mca & 0xfff0) == 0)
decode_bitfield(e, mca, dnt_front_status);
else if ((mca & 0xf0ff) == 0)
void dunnington_decode_model(struct mce_event *e)
{
uint64_t status = e->status;
+
if ((status & 0xffff) == 0xe0f)
dunnington_decode_bus(e, status);
else if ((status & 0xffff) == (1 << 10))
#include "ras-mce-handler.h"
#include "bitfield.h"
-
/* See IA32 SDM Vol3B Table 16-20 */
static char *pcu_1[] = {
[0x22] = "Phy detected in-band reset (no width change)",
[0x23] = "Link failover clock failover",
[0x30] = "Rx detected CRC error - successful LLR after Phy re-init",
- [0x31] = "Rx detected CRC error - successful LLR wihout Phy re-init",
+ [0x31] = "Rx detected CRC error - successful LLR without Phy re-init",
};
static struct field qpi_mc[] = {
{
uint64_t status = e->status;
uint32_t mca = status & 0xffff;
- unsigned rank0 = -1, rank1 = -1, chan;
+ unsigned int rank0 = -1, rank1 = -1, chan;
switch (e->bank) {
case 4:
/* Ignore unless this is an corrected extended error from an iMC bank */
if (e->bank < 9 || e->bank > 16 || (status & MCI_STATUS_UC) ||
- !test_prefix(7, status & 0xefff))
+ !test_prefix(7, status & 0xefff))
return;
/*
*/
if (rank0 != -1 && rank1 != -1)
mce_snprintf(e->mc_location, "ranks=%d and %d",
- rank0, rank1);
+ rank0, rank1);
else if (rank0 != -1)
mce_snprintf(e->mc_location, "rank=%d", rank0);
}
struct mce_priv *mce = ras->mce_priv;
uint64_t status = e->status;
uint32_t mca = status & 0xffff;
- unsigned rank0 = -1, rank1 = -1, chan;
+ unsigned int rank0 = -1, rank1 = -1, chan;
switch (e->bank) {
case 4:
/* Ignore unless this is an corrected extended error from an iMC bank */
if (e->bank < 9 || e->bank > 16 || (status & MCI_STATUS_UC) ||
- !test_prefix(7, status & 0xefff))
+ !test_prefix(7, status & 0xefff))
return;
/*
*/
if (rank0 >= 0 && rank1 >= 0)
mce_snprintf(e->mc_location, "ranks=%d and %d",
- rank0, rank1);
+ rank0, rank1);
else if (rank0 >= 0)
mce_snprintf(e->mc_location, "rank=%d", rank0);
else
* faling rank to a DIMM slot.
*/
#if 0
-static int failrank2dimm(unsigned failrank, int socket, int channel)
+static int failrank2dimm(unsigned int failrank, int socket, int channel)
{
switch (failrank) {
case 0: case 1: case 2: case 3:
{
uint64_t status = e->status;
uint32_t mca = status & 0xffff;
- unsigned rank0 = -1, rank1 = -1, chan = 0;
+ unsigned int rank0 = -1, rank1 = -1, chan = 0;
switch (e->bank) {
case 5:
uint64_t status = e->status;
uint32_t mca = status & 0xffff;
uint64_t misc = e->misc;
- unsigned channel, dimm;
+ unsigned int channel, dimm;
- if ((mca >> 11) == 1) { /* bus and interconnect QPI */
+ if ((mca >> 11) == 1) { /* bus and interconnect QPI */
decode_bitfield(e, status, qpi_status);
if (status & MCI_STATUS_MISCV) {
decode_numfield(e, misc, qpi_numbers);
{
uint64_t status = e->status;
uint32_t mca = status & 0xffff;
+
if (mca == 0x0001) { /* internal unspecified */
decode_bitfield(e, status, internal_error_status);
decode_numfield(e, status, internal_error_numbers);
FIELD(25, bus_queue_error_type),
SBITFIELD(30, "internal BINIT"),
SBITFIELD(36, "received parity error on response transaction"),
- SBITFIELD(38, "timeout BINIT (ROB timeout)."
- " No micro-instruction retired for some time"),
+ SBITFIELD(38,
+ "timeout BINIT (ROB timeout). No micro-instruction retired for some time"),
FIELD_NULL(39),
SBITFIELD(42, "bus transaction received hard error response"),
SBITFIELD(43, "failure that caused IERR"),
FIELD_NULL(31),
FIELD_NULL(32),
SBITFIELD(35, "BINIT received from external bus"),
- SBITFIELD(37, "Received hard error reponse on split transaction (Bus BINIT)"),
+ SBITFIELD(37, "Received hard error response on split transaction (Bus BINIT)"),
{}
};
static struct {
int value;
char *str;
-} p4_model []= {
+} p4_model[] = {
{16, "FSB address parity"},
{17, "Response hard fail"},
{18, "Response parity"},
void p4_decode_model(struct mce_event *e)
{
uint32_t model = e->status & 0xffff0000L;
- unsigned i;
+ unsigned int i;
for (i = 0; i < ARRAY_SIZE(p4_model); i++) {
if (model & (1 << p4_model[i].value))
{
struct mce_priv *mce = ras->mce_priv;
uint32_t mca = e->status & 0xffff;
- unsigned rank0 = -1, rank1 = -1, chan;
+ unsigned int rank0 = -1, rank1 = -1, chan;
switch (e->bank) {
case 4:
/* Ignore unless this is an corrected extended error from an iMC bank */
if (e->bank < 8 || e->bank > 11 || (e->status & MCI_STATUS_UC) ||
- !test_prefix(7, e->status & 0xefff))
+ !test_prefix(7, e->status & 0xefff))
return;
/*
*/
if (rank0 >= 0 && rank1 >= 0)
mce_snprintf(e->mc_location, "ranks=%d and %d",
- rank0, rank1);
+ rank0, rank1);
else if (rank0 >= 0)
mce_snprintf(e->mc_location, "rank=%d", rank0);
else
* can be converted to a DIMM number within a channel for systems with either
* two or three DIMMs per channel.
*/
-static int failrank2dimm(unsigned failrank, int socket, int channel)
+static int failrank2dimm(unsigned int failrank, int socket, int channel)
{
switch (failrank) {
case 0: case 1: case 2: case 3:
{
uint64_t status = e->status;
uint32_t mca = status & 0xffff;
- unsigned rank0 = -1, rank1 = -1, chan;
+ unsigned int rank0 = -1, rank1 = -1, chan;
switch (e->bank) {
case 4:
/* Ignore unless this is an corrected extended error from an iMC bank */
if (e->bank < 13 || e->bank > 18 || (status & MCI_STATUS_UC) ||
- !test_prefix(7, status & 0xefff))
+ !test_prefix(7, status & 0xefff))
return;
/*
*/
if (rank0 != -1 && rank1 != -1)
mce_snprintf(e->mc_location, "ranks=%d and %d",
- rank0, rank1);
+ rank0, rank1);
else if (rank0 != -1)
mce_snprintf(e->mc_location, "rank=%d", rank0);
}
static void tulsa_decode_internal(struct mce_event *e, uint64_t status)
{
uint32_t mca = (status >> 16) & 0xffff;
+
if ((mca & 0xfff0) == 0)
decode_bitfield(e, mca, tls_front_status);
else if ((mca & 0xf0ff) == 0)
#define BUS_PP_MASK 0x600 /*bit 9, bit 10*/
#define BUS_PP_SHIFT 0x9
-#define MCG_TES_P (1ULL<<11) /* Yellow bit cache threshold supported */
-
+#define MCG_TES_P BIT_ULL(11) /* Yellow bit cache threshold supported */
static char *TT[] = {
"Instruction",
static struct {
uint8_t value;
- char* str;
-} RRRR [] = {
+ char *str;
+} RRRR[] = {
{0, "Generic"},
{1, "Read"},
{2, "Write" },
static char *tracking_msg[] = {
[1] = "green",
[2] = "yellow",
- [3] ="res3"
+ [3] = "res3"
};
static const char *arstate[4] = {
sprintf(channel, "%u", status & 0xf);
mce_snprintf(e->error_msg, "MEMORY CONTROLLER %s_CHANNEL%s_ERR",
- mmm_mnemonic[(status >> 4) & 7], channel);
+ mmm_mnemonic[(status >> 4) & 7], channel);
mce_snprintf(e->error_msg, "Transaction: %s",
- mmm_desc[(status >> 4) & 7]);
+ mmm_desc[(status >> 4) & 7]);
}
static void decode_termal_bank(struct mce_event *e)
static char *get_RRRR_str(uint8_t rrrr)
{
- unsigned i;
+ unsigned int i;
for (i = 0; i < ARRAY_SIZE(RRRR); i++) {
if (RRRR[i].value == rrrr) {
#define decode_attr(arr, val) ({ \
char *__str; \
- if ((unsigned)(val) >= ARRAY_SIZE(arr)) \
+ if ((unsigned int)(val) >= ARRAY_SIZE(arr)) \
__str = "UNKNOWN"; \
else \
__str = (arr)[val]; \
decode_attr(LL, mca & 3));
} else if (test_prefix(4, mca)) {
mce_snprintf(e->mcastatus_msg, "%s TLB %s Error",
- decode_attr(TT, (mca & TLB_TT_MASK) >> TLB_TT_SHIFT),
- decode_attr(LL, (mca & TLB_LL_MASK) >> TLB_LL_SHIFT));
+ decode_attr(TT, (mca & TLB_TT_MASK) >> TLB_TT_SHIFT),
+ decode_attr(LL, (mca & TLB_LL_MASK) >> TLB_LL_SHIFT));
} else if (test_prefix(8, mca)) {
- unsigned typenum = (mca & CACHE_TT_MASK) >> CACHE_TT_SHIFT;
- unsigned levelnum = (mca & CACHE_LL_MASK) >> CACHE_LL_SHIFT;
+ unsigned int typenum = (mca & CACHE_TT_MASK) >> CACHE_TT_SHIFT;
+ unsigned int levelnum = (mca & CACHE_LL_MASK) >> CACHE_LL_SHIFT;
char *type = decode_attr(TT, typenum);
char *level = decode_attr(LL, levelnum);
+
mce_snprintf(e->mcastatus_msg,
"%s CACHE %s %s Error", type, level,
- get_RRRR_str((mca & CACHE_RRRR_MASK) >>
- CACHE_RRRR_SHIFT));
+ get_RRRR_str((mca & CACHE_RRRR_MASK) >> CACHE_RRRR_SHIFT));
#if 0
/* FIXME: We shouldn't mix parsing with actions */
if (track == 2)
else
mce_snprintf(e->mcistatus_msg, "Corrected_error");
-
if (e->status & MCI_STATUS_EN)
mce_snprintf(e->mcistatus_msg, "Error_enabled");
-
if (e->status & MCI_STATUS_PCC)
mce_snprintf(e->mcistatus_msg, "Processor_context_corrupt");
- if (e->status & (MCI_STATUS_S|MCI_STATUS_AR))
+ if (e->status & (MCI_STATUS_S | MCI_STATUS_AR))
mce_snprintf(e->mcistatus_msg, "%s",
arstate[(e->status >> 55) & 3]);
/* Check if the error is at the memory controller */
if (((e->status & 0xffff) >> 7) == 1) {
- unsigned corr_err_cnt;
+ unsigned int corr_err_cnt;
corr_err_cnt = EXTRACT(e->status, 38, 52);
mce_snprintf(e->mc_location, "n_errors=%d", corr_err_cnt);
}
if (test_prefix(11, (e->status & 0xffffL))) {
- switch(mce->cputype) {
+ switch (mce->cputype) {
case CPU_P6OLD:
p6old_decode_model(e);
break;
break;
}
}
- switch(mce->cputype) {
+ switch (mce->cputype) {
case CPU_NEHALEM:
nehalem_decode_model(e);
break;
return -EINVAL;
}
}
- if (pread(fd, &data, sizeof data, msr) != sizeof data) {
+ if (pread(fd, &data, sizeof(data), msr) != sizeof(data)) {
log(ALL, LOG_ERR,
"Cannot read MSR_ERROR_CONTROL from %s\n", fpath);
return -EINVAL;
}
data |= bit;
- if (pwrite(fd, &data, sizeof data, msr) != sizeof data) {
+ if (pwrite(fd, &data, sizeof(data), msr) != sizeof(data)) {
log(ALL, LOG_ERR,
"Cannot write MSR_ERROR_CONTROL to %s\n", fpath);
return -EINVAL;
}
- if (pread(fd, &data, sizeof data, msr) != sizeof data) {
+ if (pread(fd, &data, sizeof(data), msr) != sizeof(data)) {
log(ALL, LOG_ERR,
"Cannot re-read MSR_ERROR_CONTROL from %s\n", fpath);
return -EINVAL;
return 0;
}
-int set_intel_imc_log(enum cputype cputype, unsigned ncpus)
+int set_intel_imc_log(enum cputype cputype, unsigned int ncpus)
{
int cpu, msr, bit, rc;
"MISC2:",
"MISC3:",
};
+
/*PCIe AER Error Payload Type 1*/
static const char * const disp_payload1_err_reg_name[] = {
"Error Type:",
"ARMv8 Core 1",
};
-
static const char * const err_mcu_sub_type[] = {
"ERR0",
"ERR1",
return "unknown error";
}
-
-
static const char * const err_pcie_aer_sub_type[] = {
"Root Port",
"Device",
return "unknown error";
}
-
static const char * const err_ocm_sub_type[] = {
"ERR0",
"ERR1",
/*get the error type name*/
static const char *oem_type_name(const struct amp_ras_type_info *info,
- uint8_t type_id)
+ uint8_t type_id)
{
const struct amp_ras_type_info *type = &info[0];
if (type->id != type_id)
continue;
- if (type->sub == NULL)
+ if (!type->sub)
return type->name;
if (sub_type_id >= type->sub_num)
return "unknown";
}
static int store_amp_err_data(struct ras_ns_ev_decoder *ev_decoder,
- const char *name)
+ const char *name)
{
int rc;
/*save all Ampere Specific Error Payload type 0 to sqlite3 database*/
static void record_amp_payload0_err(struct ras_ns_ev_decoder *ev_decoder,
- const char *type_str, const char *subtype_str,
+ const char *type_str, const char *subtype_str,
const struct amp_payload0_type_sec *err)
{
- if (ev_decoder != NULL) {
+ if (ev_decoder) {
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
- AMP_PAYLOAD0_FIELD_TYPE, 0, type_str);
+ AMP_PAYLOAD0_FIELD_TYPE, 0, type_str);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
- AMP_PAYLOAD0_FIELD_SUB_TYPE, 0, subtype_str);
+ AMP_PAYLOAD0_FIELD_SUB_TYPE, 0, subtype_str);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD0_FIELD_INS, INSTANCE(err->instance), NULL);
+ AMP_PAYLOAD0_FIELD_INS, INSTANCE(err->instance), NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD0_FIELD_SOCKET_NUM,
+ AMP_PAYLOAD0_FIELD_SOCKET_NUM,
SOCKET_NUM(err->instance), NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD0_FIELD_STATUS_REG, err->err_status, NULL);
+ AMP_PAYLOAD0_FIELD_STATUS_REG, err->err_status, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
- AMP_PAYLOAD0_FIELD_ADDR_REG,
+ AMP_PAYLOAD0_FIELD_ADDR_REG,
err->err_addr, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
- AMP_PAYLOAD0_FIELD_MISC0,
+ AMP_PAYLOAD0_FIELD_MISC0,
err->err_misc_0, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
- AMP_PAYLOAD0_FIELD_MISC1,
+ AMP_PAYLOAD0_FIELD_MISC1,
err->err_misc_1, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
- AMP_PAYLOAD0_FIELD_MISC2,
+ AMP_PAYLOAD0_FIELD_MISC2,
err->err_misc_2, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
- AMP_PAYLOAD0_FIELD_MISC3,
+ AMP_PAYLOAD0_FIELD_MISC3,
err->err_misc_3, NULL);
store_amp_err_data(ev_decoder, "amp_payload0_event_tab");
}
/*save all Ampere Specific Error Payload type 1 to sqlite3 database*/
static void record_amp_payload1_err(struct ras_ns_ev_decoder *ev_decoder,
- const char *type_str, const char *subtype_str,
+ const char *type_str, const char *subtype_str,
const struct amp_payload1_type_sec *err)
{
- if (ev_decoder != NULL) {
+ if (ev_decoder) {
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
AMP_PAYLOAD1_FIELD_TYPE, 0, type_str);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
/*save all Ampere Specific Error Payload type 2 to sqlite3 database*/
static void record_amp_payload2_err(struct ras_ns_ev_decoder *ev_decoder,
- const char *type_str, const char *subtype_str,
- const struct amp_payload2_type_sec *err)
+ const char *type_str, const char *subtype_str,
+ const struct amp_payload2_type_sec *err)
{
- if (ev_decoder != NULL) {
+ if (ev_decoder) {
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
- AMP_PAYLOAD2_FIELD_TYPE, 0, type_str);
+ AMP_PAYLOAD2_FIELD_TYPE, 0, type_str);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
- AMP_PAYLOAD2_FIELD_SUB_TYPE, 0, subtype_str);
+ AMP_PAYLOAD2_FIELD_SUB_TYPE, 0, subtype_str);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD2_FIELD_INS, INSTANCE(err->instance), NULL);
+ AMP_PAYLOAD2_FIELD_INS, INSTANCE(err->instance), NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD2_FIELD_SOCKET_NUM,
+ AMP_PAYLOAD2_FIELD_SOCKET_NUM,
SOCKET_NUM(err->instance), NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD2_FIELD_CE_REPORT_REG,
+ AMP_PAYLOAD2_FIELD_CE_REPORT_REG,
err->ce_register, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD2_FIELD_CE_LOACATION,
+ AMP_PAYLOAD2_FIELD_CE_LOACATION,
err->ce_location, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD2_FIELD_CE_ADDR,
+ AMP_PAYLOAD2_FIELD_CE_ADDR,
err->ce_addr, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD2_FIELD_UE_REPORT_REG,
+ AMP_PAYLOAD2_FIELD_UE_REPORT_REG,
err->ue_register, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD2_FIELD_UE_LOCATION,
+ AMP_PAYLOAD2_FIELD_UE_LOCATION,
err->ue_location, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD2_FIELD_UE_ADDR,
+ AMP_PAYLOAD2_FIELD_UE_ADDR,
err->ue_addr, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD2_FIELD_RESERVED1,
+ AMP_PAYLOAD2_FIELD_RESERVED1,
err->reserved1, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
- AMP_PAYLOAD2_FIELD_RESERVED2,
+ AMP_PAYLOAD2_FIELD_RESERVED2,
err->reserved2, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
- AMP_PAYLOAD2_FIELD_RESERVED3,
+ AMP_PAYLOAD2_FIELD_RESERVED3,
err->reserved3, NULL);
store_amp_err_data(ev_decoder, "amp_payload2_event_tab");
}
/*save all Ampere Specific Error Payload type 3 to sqlite3 database*/
static void record_amp_payload3_err(struct ras_ns_ev_decoder *ev_decoder,
- const char *type_str, const char *subtype_str,
+ const char *type_str, const char *subtype_str,
const struct amp_payload3_type_sec *err)
{
- if (ev_decoder != NULL) {
+ if (ev_decoder) {
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
- AMP_PAYLOAD3_FIELD_TYPE, 0, type_str);
+ AMP_PAYLOAD3_FIELD_TYPE, 0, type_str);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
- AMP_PAYLOAD3_FIELD_SUB_TYPE, 0, subtype_str);
+ AMP_PAYLOAD3_FIELD_SUB_TYPE, 0, subtype_str);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD3_FIELD_INS, INSTANCE(err->instance), NULL);
+ AMP_PAYLOAD3_FIELD_INS, INSTANCE(err->instance), NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD3_FIELD_SOCKET_NUM,
+ AMP_PAYLOAD3_FIELD_SOCKET_NUM,
SOCKET_NUM(err->instance), NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
- AMP_PAYLOAD3_FIELD_FW_SPEC_DATA0,
+ AMP_PAYLOAD3_FIELD_FW_SPEC_DATA0,
err->fw_speci_data0, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
- AMP_PAYLOAD3_FIELD_FW_SPEC_DATA1,
+ AMP_PAYLOAD3_FIELD_FW_SPEC_DATA1,
err->fw_speci_data1, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
- AMP_PAYLOAD3_FIELD_FW_SPEC_DATA2,
+ AMP_PAYLOAD3_FIELD_FW_SPEC_DATA2,
err->fw_speci_data2, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
- AMP_PAYLOAD3_FIELD_FW_SPEC_DATA3,
+ AMP_PAYLOAD3_FIELD_FW_SPEC_DATA3,
err->fw_speci_data3, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
- AMP_PAYLOAD3_FIELD_FW_SPEC_DATA4,
+ AMP_PAYLOAD3_FIELD_FW_SPEC_DATA4,
err->fw_speci_data4, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
- AMP_PAYLOAD3_FIELD_FW_SPEC_DATA5,
+ AMP_PAYLOAD3_FIELD_FW_SPEC_DATA5,
err->fw_speci_data5, NULL);
store_amp_err_data(ev_decoder, "amp_payload3_event_tab");
}
}
static void record_amp_payload0_err(struct ras_ns_ev_decoder *ev_decoder,
- const char *type_str, const char *subtype_str,
- const struct amp_payload0_type_sec *err)
+ const char *type_str, const char *subtype_str,
+ const struct amp_payload0_type_sec *err)
{
}
static void record_amp_payload1_err(struct ras_ns_ev_decoder *ev_decoder,
- const char *type_str, const char *subtype_str,
- const struct amp_payload1_type_sec *err)
+ const char *type_str, const char *subtype_str,
+ const struct amp_payload1_type_sec *err)
{
}
static void record_amp_payload2_err(struct ras_ns_ev_decoder *ev_decoder,
- const char *type_str, const char *subtype_str,
- const struct amp_payload2_type_sec *err)
+ const char *type_str, const char *subtype_str,
+ const struct amp_payload2_type_sec *err)
{
}
static void record_amp_payload3_err(struct ras_ns_ev_decoder *ev_decoder,
- const char *type_str, const char *subtype_str,
- const struct amp_payload3_type_sec *err)
+ const char *type_str, const char *subtype_str,
+ const struct amp_payload3_type_sec *err)
{
}
/*decode ampere specific error payload type 0, the CPU's data is save*/
/*to sqlite by ras-arm-handler, others are saved by this function.*/
void decode_amp_payload0_err_regs(struct ras_ns_ev_decoder *ev_decoder,
- struct trace_seq *s,
+ struct trace_seq *s,
const struct amp_payload0_type_sec *err)
{
char buf[AMP_PAYLOAD0_BUF_LEN];
/*decode ampere specific error payload type 1 and save to sqlite db*/
static void decode_amp_payload1_err_regs(struct ras_ns_ev_decoder *ev_decoder,
- struct trace_seq *s,
- const struct amp_payload1_type_sec *err)
+ struct trace_seq *s,
+ const struct amp_payload1_type_sec *err)
{
char buf[AMP_PAYLOAD0_BUF_LEN];
char *p = buf;
/*decode ampere specific error payload type 2 and save to sqlite db*/
static void decode_amp_payload2_err_regs(struct ras_ns_ev_decoder *ev_decoder,
- struct trace_seq *s,
- const struct amp_payload2_type_sec *err)
+ struct trace_seq *s,
+ const struct amp_payload2_type_sec *err)
{
char buf[AMP_PAYLOAD0_BUF_LEN];
char *p = buf;
subtype_str = err_peci_rasdp_sub_type(err->subtype);
else
subtype_str = oem_subtype_name(amp_payload_error_type,
- TYPE(err->type), err->subtype);
+ TYPE(err->type), err->subtype);
//display error type
p += snprintf(p, end - p, " %s", disp_payload2_err_reg_name[i++]);
p += snprintf(p, end - p, " %s\n", type_str);
/*decode ampere specific error payload type 3 and save to sqlite db*/
static void decode_amp_payload3_err_regs(struct ras_ns_ev_decoder *ev_decoder,
- struct trace_seq *s,
- const struct amp_payload3_type_sec *err)
+ struct trace_seq *s,
+ const struct amp_payload3_type_sec *err)
{
char buf[AMP_PAYLOAD0_BUF_LEN];
char *p = buf;
p += snprintf(p, end - p, " %s", disp_payload3_err_reg_name[i++]);
p += snprintf(p, end - p, " %s\n", type_str);
-
//display error subtype
p += snprintf(p, end - p, " %s", disp_payload3_err_reg_name[i++]);
p += snprintf(p, end - p, " %s\n", subtype_str);
if (ras_mc_add_vendor_table(ras, &ev_decoder->stmt_dec_record,
&db_tab) != SQLITE_OK) {
trace_seq_printf(s,
- "create sql %s fail\n",
- sqlite3_table_list[payload_type]);
+ "create sql %s fail\n",
+ sqlite3_table_list[payload_type]);
return -1;
}
}
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
- id, 0, event->timestamp);
+ id, 0, event->timestamp);
#endif
if (payload_type == PAYLOAD_TYPE_0) {
if (module->id != module_id)
continue;
- if (module->sub == NULL)
+ if (!module->sub)
return module->name;
if (sub_module_id >= module->sub_num)
struct ras_non_standard_event *event)
{
const struct hisi_oem_type1_err_sec *err =
- (struct hisi_oem_type1_err_sec*)event->error;
+ (struct hisi_oem_type1_err_sec *)event->error;
if (err->val_bits == 0) {
trace_seq_printf(s, "%s: no valid error information\n",
#ifdef HAVE_SQLITE3
void record_vendor_data(struct ras_ns_ev_decoder *ev_decoder,
- enum hisi_oem_data_type data_type,
+ enum hisi_oem_data_type data_type,
int id, int64_t data, const char *text)
{
- if (ev_decoder->stmt_dec_record == NULL)
+ if (!ev_decoder->stmt_dec_record)
return;
switch (data_type) {
{
int rc;
- if (ev_decoder->stmt_dec_record == NULL)
+ if (!ev_decoder->stmt_dec_record)
return 0;
rc = sqlite3_step(ev_decoder->stmt_dec_record);
};
#endif
-static const char* soc_desc[] = {
+static const char *soc_desc[] = {
"Kunpeng916",
"Kunpeng920",
"Kunpeng930",
};
-static const char* module_name[] = {
+static const char *module_name[] = {
"MN",
"PLL",
"SLLC",
"HBMC",
};
-static const char* get_soc_desc(uint8_t soc_id)
+static const char *get_soc_desc(uint8_t soc_id)
{
- if (soc_id >= sizeof(soc_desc)/sizeof(char *))
+ if (soc_id >= sizeof(soc_desc) / sizeof(char *))
return "unknown";
return soc_desc[soc_id];
static void decode_module(struct ras_ns_ev_decoder *ev_decoder,
struct hisi_event *event, uint8_t module_id)
{
- if (module_id >= sizeof(module_name)/sizeof(char *)) {
+ if (module_id >= sizeof(module_name) / sizeof(char *)) {
HISI_SNPRINTF(event->error_msg, "module=unknown(id=%hhu) ", module_id);
record_vendor_data(ev_decoder, HISI_OEM_DATA_TYPE_TEXT,
HISI_COMMON_FIELD_MODULE_ID,
}
static void decode_hisi_common_section_hdr(struct ras_ns_ev_decoder *ev_decoder,
- const struct hisi_common_error_section *err,
+ const struct hisi_common_error_section *err,
struct hisi_event *event)
{
HISI_SNPRINTF(event->error_msg, "[ table_version=%hhu", err->version);
#define JM_SNPRINTF mce_snprintf
static void record_jm_data(struct ras_ns_ev_decoder *ev_decoder,
- enum jm_oem_data_type data_type,
+ enum jm_oem_data_type data_type,
int id, int64_t data, const char *text);
struct jm_event {
"OTHER",
};
-
static const char * const scp_module_desc[] = {
"SRAM",
"WDT",
"SRAM",
"WDT",
};
+
/* JaguarMicro DPE sub system module definitions */
#define JM_SUBSYS_DPE_MOD_EPG 0
#define JM_SUBSYS_DPE_MOD_PIPE 1
static const char *get_jm_soc_desc(uint8_t soc_id)
{
- if (soc_id >= sizeof(soc_desc)/sizeof(char *))
+ if (soc_id >= sizeof(soc_desc) / sizeof(char *))
return "unknown";
return soc_desc[soc_id];
static const char *get_jm_subsystem_desc(uint8_t subsys_id)
{
- if (subsys_id >= sizeof(subsystem_desc)/sizeof(char *))
+ if (subsys_id >= sizeof(subsystem_desc) / sizeof(char *))
return "unknown";
return subsystem_desc[subsys_id];
switch (subsys_id) {
case JM_SUB_SYS_CMN:
module = cmn_module_desc;
- tbl_size = sizeof(cmn_module_desc)/sizeof(char *);
+ tbl_size = sizeof(cmn_module_desc) / sizeof(char *);
break;
case JM_SUB_SYS_DDRH:
case JM_SUB_SYS_DDRV:
module = ddr_module_desc;
- tbl_size = sizeof(ddr_module_desc)/sizeof(char *);
+ tbl_size = sizeof(ddr_module_desc) / sizeof(char *);
break;
case JM_SUB_SYS_GIC:
module = gic_module_desc;
- tbl_size = sizeof(gic_module_desc)/sizeof(char *);
+ tbl_size = sizeof(gic_module_desc) / sizeof(char *);
break;
case JM_SUB_SYS_IOSUB:
module = iosub_module_desc;
- tbl_size = sizeof(iosub_module_desc)/sizeof(char *);
+ tbl_size = sizeof(iosub_module_desc) / sizeof(char *);
break;
case JM_SUB_SYS_SCP:
module = scp_module_desc;
- tbl_size = sizeof(scp_module_desc)/sizeof(char *);
+ tbl_size = sizeof(scp_module_desc) / sizeof(char *);
break;
case JM_SUB_SYS_MCP:
module = mcp_module_desc;
- tbl_size = sizeof(mcp_module_desc)/sizeof(char *);
+ tbl_size = sizeof(mcp_module_desc) / sizeof(char *);
break;
case JM_SUB_SYS_IMU0:
case JM_SUB_SYS_IMU1:
module = imu_module_desc;
- tbl_size = sizeof(imu_module_desc)/sizeof(char *);
+ tbl_size = sizeof(imu_module_desc) / sizeof(char *);
break;
case JM_SUB_SYS_DPE:
module = dpe_module_desc;
- tbl_size = sizeof(dpe_module_desc)/sizeof(char *);
+ tbl_size = sizeof(dpe_module_desc) / sizeof(char *);
break;
case JM_SUB_SYS_RPE:
module = rpe_module_desc;
- tbl_size = sizeof(rpe_module_desc)/sizeof(char *);
+ tbl_size = sizeof(rpe_module_desc) / sizeof(char *);
break;
case JM_SUB_SYS_PSUB:
module = psub_module_desc;
- tbl_size = sizeof(psub_module_desc)/sizeof(char *);
+ tbl_size = sizeof(psub_module_desc) / sizeof(char *);
break;
case JM_SUB_SYS_HAC:
module = hac_module_desc;
- tbl_size = sizeof(hac_module_desc)/sizeof(char *);
+ tbl_size = sizeof(hac_module_desc) / sizeof(char *);
break;
case JM_SUB_SYS_TCM:
module = tcm_module_desc;
- tbl_size = sizeof(tcm_module_desc)/sizeof(char *);
+ tbl_size = sizeof(tcm_module_desc) / sizeof(char *);
break;
default:
break;
}
- if ((module == NULL) || (mod_id >= tbl_size))
+ if ((!module) || (mod_id >= tbl_size))
return "unknown";
return module[mod_id];
if (subsys_id == JM_SUB_SYS_IOSUB && mod_id == JM_SUBSYS_IOSUB_MOD_SMMU) {
sub_module = iosub_smmu_sub_desc;
- tbl_size = sizeof(iosub_smmu_sub_desc)/sizeof(char *);
+ tbl_size = sizeof(iosub_smmu_sub_desc) / sizeof(char *);
} else if (subsys_id == JM_SUB_SYS_IOSUB && mod_id == JM_SUBSYS_IOSUB_MOD_OTHER) {
sub_module = iosub_other_sub_desc;
- tbl_size = sizeof(iosub_other_sub_desc)/sizeof(char *);
+ tbl_size = sizeof(iosub_other_sub_desc) / sizeof(char *);
} else if (subsys_id == JM_SUB_SYS_DPE && mod_id == JM_SUBSYS_DPE_MOD_SMMU) {
sub_module = smmu_sub_desc;
- tbl_size = sizeof(smmu_sub_desc)/sizeof(char *);
+ tbl_size = sizeof(smmu_sub_desc) / sizeof(char *);
} else if (subsys_id == JM_SUB_SYS_RPE && mod_id == JM_SUBSYS_RPE_MOD_SMMU) {
sub_module = smmu_sub_desc;
- tbl_size = sizeof(smmu_sub_desc)/sizeof(char *);
+ tbl_size = sizeof(smmu_sub_desc) / sizeof(char *);
} else if (subsys_id == JM_SUB_SYS_PSUB && mod_id == JM_SUBSYS_PSUB_MOD_PCIE0) {
sub_module = psub_pcie0_sub_desc;
- tbl_size = sizeof(psub_pcie0_sub_desc)/sizeof(char *);
+ tbl_size = sizeof(psub_pcie0_sub_desc) / sizeof(char *);
} else if (subsys_id == JM_SUB_SYS_PSUB && mod_id == JM_SUBSYS_PSUB_MOD_X2RC_SMMU) {
sub_module = smmu_sub_desc;
- tbl_size = sizeof(smmu_sub_desc)/sizeof(char *);
+ tbl_size = sizeof(smmu_sub_desc) / sizeof(char *);
} else if (subsys_id == JM_SUB_SYS_PSUB && mod_id == JM_SUBSYS_PSUB_MOD_X16RC_SMMU) {
sub_module = smmu_sub_desc;
- tbl_size = sizeof(smmu_sub_desc)/sizeof(char *);
+ tbl_size = sizeof(smmu_sub_desc) / sizeof(char *);
} else if (subsys_id == JM_SUB_SYS_PSUB && mod_id == JM_SUBSYS_PSUB_MOD_SDMA_SMMU) {
sub_module = smmu_sub_desc;
- tbl_size = sizeof(smmu_sub_desc)/sizeof(char *);
+ tbl_size = sizeof(smmu_sub_desc) / sizeof(char *);
} else if (subsys_id == JM_SUB_SYS_TCM && mod_id == JM_SUBSYS_TCM_MOD_SMMU) {
sub_module = smmu_sub_desc;
- tbl_size = sizeof(smmu_sub_desc)/sizeof(char *);
+ tbl_size = sizeof(smmu_sub_desc) / sizeof(char *);
} else {
sub_module = NULL;
tbl_size = 0;
}
- if ((sub_module == NULL) || (sub_id >= tbl_size))
+ if ((!sub_module) || (sub_id >= tbl_size))
return "unknown";
return sub_module[sub_id];
}
-
static const char *get_jm_dev_desc(uint8_t subsys_id, uint8_t mod_id, uint8_t sub_id)
{
if (subsys_id == JM_SUB_SYS_CSUB)
return default_dev_desc[0];
}
-
#define JM_ERR_SEVERITY_NFE 0
#define JM_ERR_SEVERITY_FE 1
#define JM_ERR_SEVERITY_CE 2
}
static void decode_jm_common_sec_head(struct ras_ns_ev_decoder *ev_decoder,
- const struct jm_common_sec_head *err,
+ const struct jm_common_sec_head *err,
struct jm_event *event)
{
if (err->val_bits & BIT(JM_COMMON_VALID_SOC_ID)) {
JM_SNPRINTF(event->error_msg, "[ table_version=%hhu decode_version:%hhu",
- err->version, PAYLOAD_VERSION);
+ err->version, PAYLOAD_VERSION);
record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_INT,
- JM_PAYLOAD_FIELD_VERSION,
+ JM_PAYLOAD_FIELD_VERSION,
err->version, NULL);
}
if (err->val_bits & BIT(JM_COMMON_VALID_SOC_ID)) {
JM_SNPRINTF(event->error_msg, " soc=%s", get_jm_soc_desc(err->soc_id));
record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_INT,
- JM_PAYLOAD_FIELD_SOC_ID,
+ JM_PAYLOAD_FIELD_SOC_ID,
err->soc_id, NULL);
}
if (err->val_bits & BIT(JM_COMMON_VALID_SUBSYSTEM_ID)) {
JM_SNPRINTF(event->error_msg, " sub system=%s",
- get_jm_subsystem_desc(err->subsystem_id));
+ get_jm_subsystem_desc(err->subsystem_id));
record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_TEXT,
- JM_PAYLOAD_FIELD_SUB_SYS,
+ JM_PAYLOAD_FIELD_SUB_SYS,
0, get_jm_subsystem_desc(err->subsystem_id));
}
if (err->val_bits & BIT(JM_COMMON_VALID_MODULE_ID)) {
JM_SNPRINTF(event->error_msg, " module=%s",
- get_jm_module_desc(err->subsystem_id, err->module_id));
+ get_jm_module_desc(err->subsystem_id, err->module_id));
record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_TEXT,
- JM_PAYLOAD_FIELD_MODULE,
+ JM_PAYLOAD_FIELD_MODULE,
0, get_jm_module_desc(err->subsystem_id, err->module_id));
record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_INT,
- JM_PAYLOAD_FIELD_MODULE_ID,
+ JM_PAYLOAD_FIELD_MODULE_ID,
err->module_id, NULL);
}
if (err->val_bits & BIT(JM_COMMON_VALID_SUBMODULE_ID)) {
JM_SNPRINTF(event->error_msg, " sub module=%s",
- get_jm_submod_desc(err->subsystem_id, err->module_id, err->submodule_id));
+ get_jm_submod_desc(err->subsystem_id, err->module_id, err->submodule_id));
record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_TEXT,
- JM_PAYLOAD_FIELD_SUB_MODULE,
+ JM_PAYLOAD_FIELD_SUB_MODULE,
0,
get_jm_submod_desc(err->subsystem_id, err->module_id, err->submodule_id));
record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_INT,
- JM_PAYLOAD_FIELD_MODULE_ID,
+ JM_PAYLOAD_FIELD_MODULE_ID,
err->submodule_id, NULL);
}
-
if (err->val_bits & BIT(JM_COMMON_VALID_DEV_ID)) {
JM_SNPRINTF(event->error_msg, " dev=%s",
- get_jm_dev_desc(err->subsystem_id, err->module_id, err->submodule_id));
+ get_jm_dev_desc(err->subsystem_id, err->module_id, err->submodule_id));
record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_TEXT,
- JM_PAYLOAD_FIELD_DEV,
+ JM_PAYLOAD_FIELD_DEV,
0, get_jm_dev_desc(err->subsystem_id, err->module_id, err->submodule_id));
record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_INT,
- JM_PAYLOAD_FIELD_DEV_ID,
+ JM_PAYLOAD_FIELD_DEV_ID,
err->dev_id, NULL);
-
}
-
if (err->val_bits & BIT(JM_COMMON_VALID_ERR_TYPE)) {
JM_SNPRINTF(event->error_msg, " err_type=%hu", err->err_type);
record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_INT,
- JM_PAYLOAD_FIELD_ERR_TYPE,
+ JM_PAYLOAD_FIELD_ERR_TYPE,
err->err_type, NULL);
}
-
if (err->val_bits & BIT(JM_COMMON_VALID_ERR_SEVERITY)) {
JM_SNPRINTF(event->error_msg, " err_severity=%s",
- jm_err_severity(err->err_severity));
+ jm_err_severity(err->err_severity));
record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_TEXT,
- JM_PAYLOAD_FIELD_ERR_SEVERITY,
+ JM_PAYLOAD_FIELD_ERR_SEVERITY,
0, jm_err_severity(err->err_severity));
}
}
static void decode_jm_common_sec_tail(struct ras_ns_ev_decoder *ev_decoder,
- const struct jm_common_sec_tail *err,
+ const struct jm_common_sec_tail *err,
struct jm_event *event, uint32_t val_bits)
{
if (val_bits & BIT(JM_COMMON_VALID_REG_ARRAY_SIZE) && err->reg_array_size > 0) {
JM_SNPRINTF(event->reg_msg, "Extended Register Dump:");
for (i = 0; i < err->reg_array_size; i++) {
JM_SNPRINTF(event->reg_msg, "reg%02d=0x%08x",
- i, err->reg_array[i]);
+ i, err->reg_array[i]);
}
}
}
/*Save data with different type into sqlite3 db*/
static void record_jm_data(struct ras_ns_ev_decoder *ev_decoder,
- enum jm_oem_data_type data_type, int id,
+ enum jm_oem_data_type data_type, int id,
int64_t data, const char *text)
{
switch (data_type) {
break;
case JM_OEM_DATA_TYPE_TEXT:
sqlite3_bind_text(ev_decoder->stmt_dec_record, id, text,
- -1, NULL);
+ -1, NULL);
break;
default:
break;
}
static int store_jm_err_data(struct ras_ns_ev_decoder *ev_decoder,
- const char *tab_name)
+ const char *tab_name)
{
int rc;
rc = sqlite3_step(ev_decoder->stmt_dec_record);
if (rc != SQLITE_OK && rc != SQLITE_DONE)
log(TERM, LOG_ERR,
- "Failed to do step on sqlite. Table = %s error = %d\n",
+ "Failed to do step on sqlite. Table = %s error = %d\n",
tab_name, rc);
rc = sqlite3_reset(ev_decoder->stmt_dec_record);
if (rc != SQLITE_OK && rc != SQLITE_DONE)
log(TERM, LOG_ERR,
- "Failed to reset on sqlite. Table = %s error = %d\n",
+ "Failed to reset on sqlite. Table = %s error = %d\n",
tab_name, rc);
rc = sqlite3_clear_bindings(ev_decoder->stmt_dec_record);
if (rc != SQLITE_OK && rc != SQLITE_DONE)
log(TERM, LOG_ERR,
- "Failed to clear bindings on sqlite. Table = %s error = %d\n",
+ "Failed to clear bindings on sqlite. Table = %s error = %d\n",
tab_name, rc);
return rc;
}
-
/*save all JaguarMicro Specific Error Payload type 0 to sqlite3 database*/
static void record_jm_payload_err(struct ras_ns_ev_decoder *ev_decoder,
- const char *reg_str)
+ const char *reg_str)
{
- if (ev_decoder != NULL) {
+ if (ev_decoder) {
record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_TEXT,
- JM_PAYLOAD_FIELD_REGS_DUMP, 0, reg_str);
+ JM_PAYLOAD_FIELD_REGS_DUMP, 0, reg_str);
store_jm_err_data(ev_decoder, "jm_payload0_event_tab");
}
}
#else
static void record_jm_data(struct ras_ns_ev_decoder *ev_decoder,
- enum jm_oem_data_type data_type,
+ enum jm_oem_data_type data_type,
int id, int64_t data, const char *text)
{
}
static void record_jm_payload_err(struct ras_ns_ev_decoder *ev_decoder,
- const char *reg_str)
+ const char *reg_str)
{
}
#endif
-
/*decode JaguarMicro specific error payload type 0, the CPU's data is save*/
/*to sqlite by ras-arm-handler, others are saved by this function.*/
static void decode_jm_payload0_err_regs(struct ras_ns_ev_decoder *ev_decoder,
- struct trace_seq *s,
+ struct trace_seq *s,
const struct jm_payload0_type_sec *err)
{
int i = 0;
JM_SNPRINTF(jmevent.reg_msg, " %s", disp_payload1_err_reg_name[i++]);
JM_SNPRINTF(jmevent.reg_msg, " 0x%x\n", err->errgen);
-
trace_seq_printf(s, "Register Dump:\n");
decode_jm_common_sec_tail(ev_decoder, common_tail, &jmevent, common_head->val_bits);
-
record_jm_payload_err(ev_decoder, jmevent.reg_msg);
trace_seq_printf(s, "%s\n", jmevent.reg_msg);
decode_jm_common_sec_head(ev_decoder, common_head, &jmevent);
trace_seq_printf(s, "%s\n", jmevent.error_msg);
-
//display ecc_1bit_error_interrupt_low
JM_SNPRINTF(jmevent.reg_msg, " %s", disp_payload2_err_reg_name[i++]);
JM_SNPRINTF(jmevent.reg_msg, " 0x%x; ", err->ecc_1bit_int_low);
JM_SNPRINTF(jmevent.reg_msg, " %s", disp_payload2_err_reg_name[i++]);
JM_SNPRINTF(jmevent.reg_msg, " 0x%x\n", err->ecc_2bit_int_high);
-
trace_seq_printf(s, "Register Dump:\n");
decode_jm_common_sec_tail(ev_decoder, common_tail, &jmevent, common_head->val_bits);
trace_seq_printf(s, "%s\n", jmevent.reg_msg);
}
-
/*decode JaguarMicro specific error payload type 6 and save to sqlite db*/
static void decode_jm_payload6_err_regs(struct ras_ns_ev_decoder *ev_decoder,
struct trace_seq *s,
/* error data decoding functions */
static int decode_jm_oem_type_error(struct ras_events *ras,
- struct ras_ns_ev_decoder *ev_decoder,
+ struct ras_ns_ev_decoder *ev_decoder,
struct trace_seq *s,
struct ras_non_standard_event *event,
int payload_type)
int id = JM_PAYLOAD_FIELD_TIMESTAMP;
record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_TEXT,
- id, 0, event->timestamp);
+ id, 0, event->timestamp);
if (payload_type == PAYLOAD_TYPE_0) {
const struct jm_payload0_type_sec *err =
/* error type0 data decoding functions */
static int decode_jm_oem_type0_error(struct ras_events *ras,
- struct ras_ns_ev_decoder *ev_decoder,
+ struct ras_ns_ev_decoder *ev_decoder,
struct trace_seq *s,
struct ras_non_standard_event *event)
{
/* error type1 data decoding functions */
static int decode_jm_oem_type1_error(struct ras_events *ras,
- struct ras_ns_ev_decoder *ev_decoder,
+ struct ras_ns_ev_decoder *ev_decoder,
struct trace_seq *s,
struct ras_non_standard_event *event)
{
return decode_jm_oem_type_error(ras, ev_decoder, s, event, PAYLOAD_TYPE_1);
}
+
/* error type2 data decoding functions */
static int decode_jm_oem_type2_error(struct ras_events *ras,
- struct ras_ns_ev_decoder *ev_decoder,
+ struct ras_ns_ev_decoder *ev_decoder,
struct trace_seq *s,
struct ras_non_standard_event *event)
{
/* error type5 data decoding functions */
static int decode_jm_oem_type5_error(struct ras_events *ras,
- struct ras_ns_ev_decoder *ev_decoder,
+ struct ras_ns_ev_decoder *ev_decoder,
struct trace_seq *s,
struct ras_non_standard_event *event)
{
/* error type6 data decoding functions */
static int decode_jm_oem_type6_error(struct ras_events *ras,
- struct ras_ns_ev_decoder *ev_decoder,
+ struct ras_ns_ev_decoder *ev_decoder,
struct trace_seq *s,
struct ras_non_standard_event *event)
{
#ifdef HAVE_SQLITE3
if (ras->record_events && !ev_decoder->stmt_dec_record) {
if (ras_mc_add_vendor_table(ras, &ev_decoder->stmt_dec_record,
- &jm_payload0_event_tab) != SQLITE_OK) {
+ &jm_payload0_event_tab) != SQLITE_OK) {
log(TERM, LOG_WARNING, "Failed to create sql jm_payload0_event_tab\n");
return -1;
}
return 0;
}
-
struct ras_ns_ev_decoder jm_ns_oem_type_decoder[] = {
{
.sec_type = "82d78ba3-fa14-407a-ba0e-f3ba8170013c",
register_ns_ev_decoder(&jm_ns_oem_type_decoder[i]);
}
-
};
int record_yitian_ddr_reg_dump_event(struct ras_ns_ev_decoder *ev_decoder,
- struct ras_yitian_ddr_payload_event *ev)
+ struct ras_yitian_ddr_payload_event *ev)
{
int rc;
struct sqlite3_stmt *stmt = ev_decoder->stmt_dec_record;
log(TERM, LOG_INFO, "yitian_ddr_reg_dump_event store: %p\n", stmt);
- sqlite3_bind_text (stmt, 1, ev->timestamp, -1, NULL);
- sqlite3_bind_int64 (stmt, 2, ev->address);
- sqlite3_bind_text (stmt, 3, ev->reg_msg, -1, NULL);
+ sqlite3_bind_text(stmt, 1, ev->timestamp, -1, NULL);
+ sqlite3_bind_int64(stmt, 2, ev->address);
+ sqlite3_bind_text(stmt, 3, ev->reg_msg, -1, NULL);
rc = sqlite3_step(stmt);
if (rc != SQLITE_OK && rc != SQLITE_DONE)
log(TERM, LOG_ERR,
- "Failed to do yitian_ddr_reg_dump_event step on sqlite: error = %d\n", rc);
+ "Failed to do yitian_ddr_reg_dump_event step on sqlite: error = %d\n", rc);
rc = sqlite3_reset(stmt);
if (rc != SQLITE_OK && rc != SQLITE_DONE)
log(TERM, LOG_ERR,
- "Failed reset yitian_ddr_reg_dump_event on sqlite: error = %d\n", rc);
+ "Failed reset yitian_ddr_reg_dump_event on sqlite: error = %d\n", rc);
log(TERM, LOG_INFO, "register inserted at db\n");
return rc;
#endif
static const char *oem_type_name(const struct yitian_ras_type_info *info,
- uint8_t type_id)
+ uint8_t type_id)
{
const struct yitian_ras_type_info *type = &info[0];
if (type->id != type_id)
continue;
- if (type->sub == NULL)
+ if (!type->sub)
return type->name;
if (sub_type_id >= type->sub_num)
return "unknown";
}
void decode_yitian_ddr_payload_err_regs(struct ras_ns_ev_decoder *ev_decoder,
- struct trace_seq *s,
+ struct trace_seq *s,
const struct yitian_ddr_payload_type_sec *err,
struct ras_events *ras)
{
tm = localtime(&now);
if (tm)
strftime(ev.timestamp, sizeof(ev.timestamp),
- "%Y-%m-%d %H:%M:%S %z", tm);
+ "%Y-%m-%d %H:%M:%S %z", tm);
//display error type
p += snprintf(p, end - p, " %s", yitian_ddr_payload_err_reg_name[i++]);
p += snprintf(p, end - p, " %s,", type_str);
#ifdef HAVE_SQLITE3
record_yitian_ddr_reg_dump_event(ev_decoder, &ev);
#endif
-
}
static int add_yitian_common_table(struct ras_events *ras,
- struct ras_ns_ev_decoder *ev_decoder)
+ struct ras_ns_ev_decoder *ev_decoder)
{
#ifdef HAVE_SQLITE3
if (ras->record_events && !ev_decoder->stmt_dec_record) {
if (ras_mc_add_vendor_table(ras, &ev_decoder->stmt_dec_record,
- &yitian_ddr_payload_section_tab) != SQLITE_OK) {
+ &yitian_ddr_payload_section_tab) != SQLITE_OK) {
log(TERM, LOG_WARNING,
- "Failed to create sql yitian_ddr_payload_section_tab\n");
+ "Failed to create sql yitian_ddr_payload_section_tab\n");
return -1;
}
}
static void __attribute__((constructor)) yitian_ns_init(void)
{
int i;
+
for (i = 0; i < ARRAY_SIZE(yitian_ns_oem_decoder); i++)
register_ns_ev_decoder(&yitian_ns_oem_decoder[i]);
}
struct link_queue *queue = NULL;
queue = (struct link_queue *)malloc(sizeof(struct link_queue));
- if (queue == NULL) {
+ if (!queue) {
log(TERM, LOG_ERR, "Failed to allocate memory for queue.\n");
return NULL;
}
void clear_queue(struct link_queue *queue)
{
- if (queue == NULL)
+ if (!queue)
return;
struct queue_node *node = queue->head;
struct queue_node *tmp = NULL;
- while (node != NULL) {
+ while (node) {
tmp = node;
node = node->next;
free(tmp);
void push(struct link_queue *queue, struct queue_node *node)
{
/* there is no element in the queue */
- if (queue->head == NULL)
+ if (!queue->head)
queue->head = node;
else
queue->tail->next = node;
{
struct queue_node *tmp = NULL;
- if (queue == NULL || is_empty(queue))
+ if (!queue || is_empty(queue))
return -1;
tmp = queue->head;
struct queue_node *front(struct link_queue *queue)
{
- if (queue == NULL)
+ if (!queue)
return NULL;
return queue->head;
struct queue_node *node = NULL;
node = (struct queue_node *)malloc(sizeof(struct queue_node));
- if (node != NULL) {
+ if (node) {
node->time = time;
node->value = value;
node->next = NULL;
*/
if (ras->use_uptime)
- now = record->ts/user_hz + ras->uptime_diff;
+ now = record->ts / user_hz + ras->uptime_diff;
else
now = time(NULL);
sel_data[4] = (((dev & 0x1f) << 3) | (fn & 0x7));
sprintf(ipmi_add_sel,
- "ipmitool raw 0x0a 0x44 0x00 0x00 0xc0 0x00 0x00 0x00 0x00 0x3a 0xcd 0x00 0xc0 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x",
+ "ipmitool raw 0x0a 0x44 0x00 0x00 0xc0 0x00 0x00 0x00 0x00 0x3a 0xcd 0x00 0xc0 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x",
sel_data[0], sel_data[1], sel_data[2], sel_data[3], sel_data[4]);
system(ipmi_add_sel);
#define BIT2 2
void display_raw_data(struct trace_seq *s,
- const uint8_t *buf,
+ const uint8_t *buf,
uint32_t datalen)
{
int i = 0, line_count = 0;
if (ev->pei_len % err_info_size != 0) {
log(TERM, LOG_ERR,
- "The event data does not match to the ARM Processor Error Information Structure\n");
+ "The event data does not match to the ARM Processor Error Information Structure\n");
return num;
}
num_pei = ev->pei_len / err_info_size;
*/
if (ras->use_uptime)
- now = record->ts/user_hz + ras->uptime_diff;
+ now = record->ts / user_hz + ras->uptime_diff;
else
now = time(NULL);
#ifdef HAVE_AMP_NS_DECODE
//decode ampere specific error
decode_amp_payload0_err_regs(NULL, s,
- (struct amp_payload0_type_sec *)ev.vsei_error);
+ (struct amp_payload0_type_sec *)ev.vsei_error);
#else
display_raw_data(s, ev.vsei_error, ev.oem_len);
#endif
cpu_infos = (struct cpu_info *)malloc(sizeof(*cpu_infos) * cpus);
if (!cpu_infos) {
log(TERM, LOG_ERR,
- "Failed to allocate memory for cpu infos in %s.\n", __func__);
+ "Failed to allocate memory for cpu infos in %s.\n", __func__);
return -1;
}
cpu_infos[i].state = get_cpu_status(i);
cpu_infos[i].ce_queue = init_queue();
- if (cpu_infos[i].ce_queue == NULL) {
+ if (!cpu_infos[i].ce_queue) {
log(TERM, LOG_ERR,
- "Failed to allocate memory for cpu ce queue in %s.\n", __func__);
+ "Failed to allocate memory for cpu ce queue in %s.\n", __func__);
return -1;
}
}
{
if (config->value > config->limit) {
log(TERM, LOG_WARNING, "Value: %lu exceed limit: %lu, set to limit\n",
- config->value, config->limit);
+ config->value, config->limit);
config->value = config->limit;
}
}
for (int i = 0; i < env_size; ++i) {
if (isdigit(env[i])) {
if (*value > ULONG_MAX / DEC_CHECK ||
- (*value == ULONG_MAX / DEC_CHECK && env[i] - '0' > LAST_BIT_OF_UL)) {
+ (*value == ULONG_MAX / DEC_CHECK && env[i] - '0' > LAST_BIT_OF_UL)) {
log(TERM, LOG_ERR, "%s is out of range: %lu\n", env, ULONG_MAX);
return -1;
}
if (parse_ul_config(config, env, &value) < 0) {
log(TERM, LOG_ERR, "Invalid %s: %s! Use default value %lu.\n",
- config->name, env, config->value);
+ config->name, env, config->value);
return;
}
{
char *env = getenv("CPU_ISOLATION_ENABLE");
- if (env == NULL || strcasecmp(env, "yes"))
+ if (!env || strcasecmp(env, "yes"))
return -1;
return 0;
cpu_infos[cpu].ce_nums -= tmp;
}
log(TERM, LOG_INFO,
- "Current number of Corrected Errors in cpu%d in the cycle is %lu\n",
+ "Current number of Corrected Errors in cpu%d in the cycle is %lu\n",
cpu, cpu_infos[cpu].ce_nums);
if (cpu_infos[cpu].ce_nums >= threshold.value) {
log(TERM, LOG_INFO,
- "Corrected Errors exceeded threshold %lu, try to offline cpu%u\n",
+ "Corrected Errors exceeded threshold %lu, try to offline cpu%u\n",
threshold.value, cpu);
return do_cpu_offline(cpu);
}
{
struct queue_node *node = node_create(err_info->time, err_info->nums);
- if (node == NULL) {
+ if (!node) {
log(TERM, LOG_ERR, "Fail to allocate memory for queue node\n");
return;
}
if (cpu >= ncores || cpu < 0) {
log(TERM, LOG_ERR,
- "The current cpu %d has exceed the total number of cpu:%u\n", cpu, ncores);
+ "The current cpu %d has exceed the total number of cpu:%u\n", cpu, ncores);
return;
}
*/
if (ncores - sysconf(_SC_NPROCESSORS_ONLN) >= cpu_limit.value) {
log(TERM, LOG_WARNING,
- "Offlined cpus have exceeded limit: %lu, choose to do nothing\n",
+ "Offlined cpus have exceeded limit: %lu, choose to do nothing\n",
cpu_limit.value);
return;
}
log(TERM, LOG_WARNING, "Doing nothing in the cpu%d\n", cpu);
else if (ret == HANDLE_SUCCEED) {
log(TERM, LOG_INFO, "Offline cpu%d succeed, the state is %s\n",
- cpu, cpu_state[cpu_infos[cpu].state]);
+ cpu, cpu_state[cpu_infos[cpu].state]);
clear_queue(cpu_infos[cpu].ce_queue);
cpu_infos[cpu].ce_nums = 0;
cpu_infos[cpu].uce_nums = 0;
} else
log(TERM, LOG_WARNING, "Offline cpu%d fail, the state is %s\n",
- cpu, cpu_state[cpu_infos[cpu].state]);
+ cpu, cpu_state[cpu_infos[cpu].state]);
}
static const unsigned char be[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
for (i = 0; i < 16; i++) {
- p += sprintf(p, "%.2x", (unsigned char) uu[be[i]]);
+ p += sprintf(p, "%.2x", (unsigned char)uu[be[i]]);
switch (i) {
case 3:
case 5:
return uuid;
}
-static const char* get_cxl_type_str(const char** type_array, uint8_t num_elems, uint8_t type)
+static const char *get_cxl_type_str(const char **type_array, uint8_t num_elems, uint8_t type)
{
if (type >= num_elems)
return "Unknown";
if (ev.flags & CXL_POISON_FLAG_OVERFLOW) {
if (tep_get_field_val(s, event, "overflow_ts", record, &val, 1) < 0)
return -1;
- convert_timestamp(val, ev.overflow_ts, sizeof(ev.overflow_ts));
+ convert_timestamp(val, ev.overflow_ts, sizeof(ev.overflow_ts));
} else
strncpy(ev.overflow_ts, "1970-01-01 00:00:00 +0000", sizeof(ev.overflow_ts));
if (trace_seq_printf(s, "overflow timestamp:%s\n", ev.overflow_ts) <= 0)
static char *cxl_event_log_type_str(uint32_t log_type)
{
-
switch (log_type) {
case CXL_EVENT_TYPE_INFO:
return "Informational";
if (trace_seq_printf(s, "\n %08x: ", i) <= 0)
break;
if (trace_seq_printf(s, "%02x%02x%02x%02x ",
- buf[i], buf[i+1], buf[i+2], buf[i+3]) <= 0)
+ buf[i], buf[i + 1], buf[i + 2], buf[i + 3]) <= 0)
break;
}
#define CXL_GMER_VALID_DEVICE BIT(2)
#define CXL_GMER_VALID_COMPONENT BIT(3)
-static const char* cxl_gmer_mem_event_type[] = {
+static const char *cxl_gmer_mem_event_type[] = {
"ECC Error",
"Invalid Address",
"Data Path Error",
};
-static const char* cxl_gmer_trans_type[] = {
+static const char *cxl_gmer_trans_type[] = {
"Unknown",
"Host Read",
"Host Write",
return -1;
ev.type = val;
if (trace_seq_printf(s, "type:%s ", get_cxl_type_str(cxl_gmer_mem_event_type,
- ARRAY_SIZE(cxl_gmer_mem_event_type), ev.type)) <= 0)
+ ARRAY_SIZE(cxl_gmer_mem_event_type), ev.type)) <= 0)
return -1;
if (tep_get_field_val(s, event, "transaction_type", record, &val, 1) < 0)
return -1;
ev.type = val;
if (trace_seq_printf(s, "type:%s ", get_cxl_type_str(cxl_gmer_mem_event_type,
- ARRAY_SIZE(cxl_gmer_mem_event_type), ev.type)) <= 0)
+ ARRAY_SIZE(cxl_gmer_mem_event_type), ev.type)) <= 0)
return -1;
if (tep_get_field_val(s, event, "transaction_type", record, &val, 1) < 0)
*
* CXL res 3.0 section 8.2.9.2.1.3; Table 8-45
*/
-static const char* cxl_dev_evt_type[] = {
+static const char *cxl_dev_evt_type[] = {
"Health Status Change",
"Media Status Change",
"Life Used Change",
{ .bit = CXL_DHI_HS_HW_REPLACEMENT_NEEDED, .flag = "REPLACEMENT_NEEDED" },
};
-static const char* cxl_media_status[] = {
+static const char *cxl_media_status[] = {
"Normal",
"Not Ready",
"Write Persistency Lost",
"All Data Loss Imminent",
};
-static const char* cxl_two_bit_status[] = {
+static const char *cxl_two_bit_status[] = {
"Normal",
"Warning",
"Critical",
};
-static const char* cxl_one_bit_status[] = {
+static const char *cxl_one_bit_status[] = {
"Normal",
"Warning",
};
return -1;
ev.event_type = val;
if (trace_seq_printf(s, "event_type:%s ", get_cxl_type_str(cxl_dev_evt_type,
- ARRAY_SIZE(cxl_dev_evt_type), ev.event_type)) <= 0)
+ ARRAY_SIZE(cxl_dev_evt_type), ev.event_type)) <= 0)
return -1;
if (tep_get_field_val(s, event, "health_status", record, &val, 1) < 0)
return -1;
ev.media_status = val;
if (trace_seq_printf(s, "media_status:%s ", get_cxl_type_str(cxl_media_status,
- ARRAY_SIZE(cxl_media_status), ev.media_status)) <= 0)
+ ARRAY_SIZE(cxl_media_status), ev.media_status)) <= 0)
return -1;
if (tep_get_field_val(s, event, "add_status", record, &val, 1) < 0)
return -1;
ev.add_status = val;
if (trace_seq_printf(s, "as_life_used:%s ", get_cxl_type_str(cxl_two_bit_status,
- ARRAY_SIZE(cxl_two_bit_status),
+ ARRAY_SIZE(cxl_two_bit_status),
CXL_DHI_AS_LIFE_USED(ev.add_status))) <= 0)
return -1;
if (trace_seq_printf(s, "as_dev_temp:%s ", get_cxl_type_str(cxl_two_bit_status,
- ARRAY_SIZE(cxl_two_bit_status),
+ ARRAY_SIZE(cxl_two_bit_status),
CXL_DHI_AS_DEV_TEMP(ev.add_status))) <= 0)
return -1;
if (trace_seq_printf(s, "as_cor_vol_err_cnt:%s ", get_cxl_type_str(cxl_one_bit_status,
- ARRAY_SIZE(cxl_one_bit_status),
+ ARRAY_SIZE(cxl_one_bit_status),
CXL_DHI_AS_COR_VOL_ERR_CNT(ev.add_status))) <= 0)
return -1;
if (trace_seq_printf(s, "as_cor_per_err_cnt:%s ", get_cxl_type_str(cxl_one_bit_status,
- ARRAY_SIZE(cxl_one_bit_status),
+ ARRAY_SIZE(cxl_one_bit_status),
CXL_DHI_AS_COR_PER_ERR_CNT(ev.add_status))) <= 0)
return -1;
struct devlink_event ev;
if (ras->use_uptime)
- now = record->ts/user_hz + ras->uptime_diff;
+ now = record->ts / user_hz + ras->uptime_diff;
else
now = time(NULL);
free(ev.msg);
return 0;
-
}
int ras_devlink_event_handler(struct trace_seq *s,
*/
if (ras->use_uptime)
- now = record->ts/user_hz + ras->uptime_diff;
+ now = record->ts / user_hz + ras->uptime_diff;
else
now = time(NULL);
return -1;
ev.driver_name = tep_get_field_raw(s, event, "driver_name",
- record, &len, 1);
+ record, &len, 1);
if (!ev.driver_name)
return -1;
#include "ras-logger.h"
#include "ras-report.h"
-
static const struct {
int error;
const char *name;
*/
if (ras->use_uptime)
- now = record->ts/user_hz + ras->uptime_diff;
+ now = record->ts / user_hz + ras->uptime_diff;
else
now = time(NULL);
#define ENDIAN KBUFFER_ENDIAN_BIG
#endif
-extern char* choices_disable;
+extern char *choices_disable;
static int get_debugfs_dir(char *tracing_dir, size_t len)
{
char line[MAX_PATH + 1 + 256];
char *p, *type, *dir;
- fp = fopen("/proc/mounts","r");
+ fp = fopen("/proc/mounts", "r");
if (!fp) {
log(ALL, LOG_INFO, "Can't open /proc/mounts");
return errno;
tracing_dir[len - 1] = '\0';
return 0;
}
- } while(1);
+ } while (1);
fclose(fp);
log(ALL, LOG_INFO, "Can't find debugfs\n");
strcat(ras->tracing, "/tracing");
if (has_instances) {
strcat(ras->tracing, "/instances/" TOOL_NAME);
- rc = mkdir(ras->tracing, S_IRWXU);
+ rc = mkdir(ras->tracing, 0700);
if (rc < 0 && errno != EEXIST) {
log(ALL, LOG_INFO,
"Unable to create " TOOL_NAME " instance at %s\n",
return 0;
}
-static int is_disabled_event(char *group, char *event) {
+static int is_disabled_event(char *group, char *event)
+{
char ras_event_name[MAX_PATH + 1];
snprintf(ras_event_name, sizeof(ras_event_name), "%s:%s",
- group, event);
+ group, event);
- if (choices_disable != NULL && strlen(choices_disable) != 0 && strstr(choices_disable, ras_event_name)) {
+ if (choices_disable && strlen(choices_disable) != 0 && strstr(choices_disable, ras_event_name)) {
return 1;
}
return 0;
{
int fd, rc;
char fname[MAX_PATH + 1];
+
enable = is_disabled_event(group, event) ? 0 : 1;
snprintf(fname, sizeof(fname), "%s%s:%s\n",
return errno;
}
- rc = write(fd, fname,strlen(fname));
+ rc = write(fd, fname, strlen(fname));
if (rc < 0) {
log(ALL, LOG_WARNING, "Can't write to set_event\n");
close(fd);
#endif
#ifdef HAVE_DISKERROR
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,18,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
rc |= __toggle_ras_mc_event(ras, "block", "block_rq_error", enable);
#else
rc |= __toggle_ras_mc_event(ras, "block", "block_rq_complete", enable);
return rc;
}
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)
/*
* Set kernel filter. libtrace doesn't provide an API for setting filters
* in kernel, we have to implement it here.
return errno;
}
- rc = write(fd, filter_str ,strlen(filter_str));
+ rc = write(fd, filter_str, strlen(filter_str));
if (rc < 0) {
log(ALL, LOG_WARNING, "Can't write to filter file\n");
close(fd);
error:
close(fd);
return page_size;
-
}
static void parse_ras_data(struct pthread_data *pdata, struct kbuffer *kbuf,
trace_seq_init(&s);
tep_print_event(pdata->ras->pevent, &s, &record,
"%16s-%-5d [%03d] %s %6.1000d %s %s",
- TEP_PRINT_COMM, TEP_PRINT_PID, TEP_PRINT_CPU,
- TEP_PRINT_LATENCY, TEP_PRINT_TIME, TEP_PRINT_NAME,
- TEP_PRINT_INFO);
+ TEP_PRINT_COMM, TEP_PRINT_PID, TEP_PRINT_CPU,
+ TEP_PRINT_LATENCY, TEP_PRINT_TIME, TEP_PRINT_NAME,
+ TEP_PRINT_INFO);
trace_seq_do_printf(&s);
printf("\n");
fflush(stdout);
}
static int read_ras_event_all_cpus(struct pthread_data *pdata,
- unsigned n_cpus)
+ unsigned int n_cpus)
{
ssize_t size;
unsigned long long time_stamp;
/* FIXME: use select to open for all CPUs */
snprintf(pipe_raw, sizeof(pipe_raw),
- "per_cpu/cpu%d/trace_pipe_raw", i);
+ "per_cpu/cpu%d/trace_pipe_raw", i);
fds[i].fd = open_trace(pdata[0].ras, pipe_raw, O_RDONLY);
if (fds[i].fd < 0) {
fdsiginfo.ssi_signo == SIGTERM ||
fdsiginfo.ssi_signo == SIGHUP ||
fdsiginfo.ssi_signo == SIGQUIT) {
- log(TERM, LOG_INFO, "Recevied signal=%d\n",
+ log(TERM, LOG_INFO, "Received signal=%d\n",
fdsiginfo.ssi_signo);
goto cleanup;
} else {
int fd, rc;
time_t uptime, now;
size_t size;
- unsigned j1;
+ unsigned int j1;
char buf[4096];
/* Check if uptime is supported (kernel 3.10-rc1 or upper) */
}
static int add_event_handler(struct ras_events *ras, struct tep_handle *pevent,
- unsigned page_size, char *group, char *event,
+ unsigned int page_size, char *group, char *event,
tep_event_handler_func func, char *filter_str, int id)
{
int fd, size, rc;
char *page, fname[MAX_PATH + 1];
- struct tep_event_filter * filter = NULL;
+ struct tep_event_filter *filter = NULL;
snprintf(fname, sizeof(fname), "events/%s/%s/format", group, event);
if (is_disabled_event(group, event)) {
log(ALL, LOG_INFO, "Disabled %s:%s tracing from config\n",
- group, event);
+ group, event);
return -EINVAL;
}
{
int rc, page_size, i;
int num_events = 0;
- unsigned cpus;
+ unsigned int cpus;
struct tep_handle *pevent = NULL;
struct pthread_data *data = NULL;
struct ras_events *ras = NULL;
#endif
#ifdef HAVE_DISKERROR
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,18,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
rc = add_event_handler(ras, pevent, page_size, "block",
"block_rq_error", ras_diskerror_event_handler,
NULL, DISKERROR_EVENT);
if (!data)
goto err;
-
for (i = 0; i < cpus; i++) {
data[i].ras = ras;
data[i].cpu = i;
}
log(SYSLOG, LOG_INFO,
- "Opening one thread per cpu (%d threads)\n", cpus);
+ "Opening one thread per cpu (%d threads)\n", cpus);
for (i = 0; i < cpus; i++) {
rc = pthread_create(&data[i].thread, NULL,
- handle_ras_events_cpu,
+ handle_ras_events_cpu,
(void *)&data[i]);
if (rc) {
log(SYSLOG, LOG_INFO,
- "Failed to create thread for cpu %d. Aborting.\n",
+ "Failed to create thread for cpu %d. Aborting.\n",
i);
while (--i)
pthread_cancel(data[i].thread);
p += sprintf(p, "card_handle: %d ", cpd->mem_array_handle);
if (cpd->validation_bits & CPER_MEM_VALID_MODULE_HANDLE)
p += sprintf(p, "module_handle: %d ", cpd->mem_dev_handle);
- p += sprintf(p-1, ")");
+ p += sprintf(p - 1, ")");
return buf;
}
static char uuid[sizeof("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")];
char *p = uuid;
int i;
- static const unsigned char le[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15};
+ static const unsigned char le[16] = {3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15};
for (i = 0; i < 16; i++) {
- p += sprintf(p, "%.2x", (unsigned char) uu[le[i]]);
+ p += sprintf(p, "%.2x", (unsigned char)uu[le[i]]);
switch (i) {
case 3:
case 5:
return uuid;
}
-
static void report_extlog_mem_event(struct ras_events *ras,
struct tep_record *record,
struct trace_seq *s,
struct ras_extlog_event *ev)
{
trace_seq_printf(s, "%d %s error: %s physical addr: 0x%llx mask: 0x%llx%s %s %s",
- ev->error_seq, err_severity(ev->severity),
+ ev->error_seq, err_severity(ev->severity),
err_type(ev->etype), ev->address,
err_mask(ev->pa_mask_lsb),
err_cper_data(ev->cper_data),
*/
if (ras->use_uptime)
- now = record->ts/user_hz + ras->uptime_diff;
+ now = record->ts / user_hz + ras->uptime_diff;
else
now = time(NULL);
*/
if (ras->use_uptime)
- now = record->ts/user_hz + ras->uptime_diff;
+ now = record->ts / user_hz + ras->uptime_diff;
else
now = time(NULL);
if (tep_get_field_val(s, event, "top_layer", record, &val, 1) < 0)
goto parse_error;
parsed_fields++;
- ev.top_layer = (signed char) val;
+ ev.top_layer = (signed char)val;
if (tep_get_field_val(s, event, "middle_layer", record, &val, 1) < 0)
goto parse_error;
parsed_fields++;
- ev.middle_layer = (signed char) val;
+ ev.middle_layer = (signed char)val;
if (tep_get_field_val(s, event, "lower_layer", record, &val, 1) < 0)
goto parse_error;
parsed_fields++;
- ev.lower_layer = (signed char) val;
+ ev.lower_layer = (signed char)val;
if (ev.top_layer >= 0 || ev.middle_layer >= 0 || ev.lower_layer >= 0) {
if (ev.lower_layer >= 0)
trace_seq_printf(s, " location: %d:%d:%d",
- ev.top_layer, ev.middle_layer, ev.lower_layer);
+ ev.top_layer, ev.middle_layer, ev.lower_layer);
else if (ev.middle_layer >= 0)
trace_seq_printf(s, " location: %d:%d",
ev.top_layer, ev.middle_layer);
ev.grain = val;
trace_seq_printf(s, " grain: %lld", ev.grain);
-
if (tep_get_field_val(s, event, "syndrome", record, &val, 1) < 0)
goto parse_error;
parsed_fields++;
else if (mce->model == 0x6a)
return CPU_ICELAKE_XEON;
else if (mce->model == 0x6c)
- return CPU_ICELAKE_DE;
+ return CPU_ICELAKE_DE;
else if (mce->model == 0x86)
- return CPU_TREMONT_D;
+ return CPU_TREMONT_D;
else if (mce->model == 0x8f)
- return CPU_SAPPHIRERAPIDS;
+ return CPU_SAPPHIRERAPIDS;
else if (mce->model == 0xcf)
return CPU_EMERALDRAPIDS;
mce->mhz = 0;
mce->vendor[0] = '\0';
- f = fopen("/proc/cpuinfo","r");
+ f = fopen("/proc/cpuinfo", "r");
if (!f) {
log(ALL, LOG_INFO, "Can't open /proc/cpuinfo\n");
return errno;
while (seen != CPU_ALL && getdelim(&line, &linelen, '\n', f) > 0) {
if (sscanf(line, "vendor_id : %63[^\n]",
- (char *)&mce->vendor) == 1)
+ (char *)&mce->vendor) == 1)
seen |= CPU_VENDOR;
else if (sscanf(line, "cpu family : %d", &mce->family) == 1)
seen |= CPU_FAMILY;
if (seen != CPU_ALL) {
log(ALL, LOG_INFO, "Can't parse /proc/cpuinfo: missing%s%s%s%s%s\n",
- (seen & CPU_VENDOR) ? "" : " [vendor_id]",
+ (seen & CPU_VENDOR) ? "" : " [vendor_id]",
(seen & CPU_FAMILY) ? "" : " [cpu family]",
(seen & CPU_MODEL) ? "" : " [model]",
(seen & CPU_MHZ) ? "" : " [cpu MHz]",
ret = EINVAL;
}
goto ret;
- } else if (!strcmp(mce->vendor,"HygonGenuine")) {
+ } else if (!strcmp(mce->vendor, "HygonGenuine")) {
if (mce->family == 24) {
mce->cputype = CPU_DHYANA;
}
goto ret;
- } else if (!strcmp(mce->vendor,"GenuineIntel")) {
+ } else if (!strcmp(mce->vendor, "GenuineIntel")) {
mce->cputype = select_intel_cputype(mce);
} else {
ret = EINVAL;
return ret;
}
-int register_mce_handler(struct ras_events *ras, unsigned ncpus)
+int register_mce_handler(struct ras_events *ras, unsigned int ncpus)
{
int rc;
struct mce_priv *mce;
rc = detect_cpu(mce);
if (rc) {
if (mce->processor_flags)
- free (mce->processor_flags);
- free (ras->mce_priv);
+ free(mce->processor_flags);
+ free(ras->mce_priv);
ras->mce_priv = NULL;
return (rc);
}
*/
if (ras->use_uptime)
- now = record->ts/user_hz + ras->uptime_diff;
+ now = record->ts / user_hz + ras->uptime_diff;
else
now = time(NULL);
if (strlen(e->frutext)) {
trace_seq_printf(s, ", FRU Text= %s", e->frutext);
trace_seq_printf(s, ", Vendor Data= ");
- for (int i = 2; i < e->vdata_len/8; i++) {
+ for (int i = 2; i < e->vdata_len / 8; i++) {
trace_seq_printf(s, "0x%lx", e->vdata[i]);
trace_seq_printf(s, " ");
}
} else {
trace_seq_printf(s, ", Vendor Data= ");
- for (int i = 0; i < e->vdata_len/8; i ++) {
+ for (int i = 0; i < e->vdata_len / 8; i++) {
trace_seq_printf(s, "0x%lx", e->vdata[i]);
trace_seq_printf(s, " ");
}
mce->ipid = event->ipid;
if (!mce->ipid || !mce->status) {
log(TERM, LOG_ERR, "%s MSR required.\n",
- mce->ipid ? "Status" : "Ipid");
+ mce->ipid ? "Status" : "Ipid");
rc = -EINVAL;
goto free_mce;
}
return "unknown";
}
-
int ras_memory_failure_event_handler(struct trace_seq *s,
struct tep_record *record,
struct tep_event *event, void *context)
*/
if (ras->use_uptime)
- now = record->ts/user_hz + ras->uptime_diff;
+ now = record->ts / user_hz + ras->uptime_diff;
else
now = time(NULL);
static struct ras_ns_ev_decoder *ras_ns_ev_dec_list;
-void print_le_hex(struct trace_seq *s, const uint8_t *buf, int index) {
- trace_seq_printf(s, "%02x%02x%02x%02x", buf[index+3], buf[index+2], buf[index+1], buf[index]);
+void print_le_hex(struct trace_seq *s, const uint8_t *buf, int index)
+{
+ trace_seq_printf(s, "%02x%02x%02x%02x", buf[index + 3], buf[index + 2], buf[index + 1], buf[index]);
}
static char *uuid_le(const char *uu)
static char uuid[sizeof("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")];
char *p = uuid;
int i;
- static const unsigned char le[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15};
+ static const unsigned char le[16] = {3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15};
for (i = 0; i < 16; i++) {
- p += sprintf(p, "%.2x", (unsigned char) uu[le[i]]);
+ p += sprintf(p, "%.2x", (unsigned char)uu[le[i]]);
switch (i) {
case 3:
case 5:
*/
if (ras->use_uptime)
- now = record->ts/user_hz + ras->uptime_diff;
+ now = record->ts / user_hz + ras->uptime_diff;
else
now = time(NULL);
ev.sec_type = tep_get_field_raw(s, event, "sec_type",
record, &len, 1);
- if(!ev.sec_type)
+ if (!ev.sec_type)
return -1;
if (strcmp(uuid_le(ev.sec_type),
"e8ed898d-df16-43cc-8ecc-54f060ef157f") == 0)
trace_seq_printf(s, "\n section type: %s",
- "Ampere Specific Error\n");
+ "Ampere Specific Error\n");
else
trace_seq_printf(s, " section type: %s",
uuid_le(ev.sec_type));
trace_seq_printf(s, " length: %d", ev.length);
ev.error = tep_get_field_raw(s, event, "buf", record, &len, 1);
- if(!ev.error)
+ if (!ev.error)
return -1;
if (!find_ns_ev_decoder(ev.sec_type, &ns_ev_decoder)) {
int unit_matched = 0;
unsigned long value, tmp;
- /* check if env is vaild */
+ /* check if env is valid */
if (env && strlen(env)) {
/* All the character before unit must be digit */
for (i = 0; i < strlen(env) - 1; i++) {
}
if (sscanf(env, "%lu", &value) < 1 || !value)
goto parse;
- /* check if the unit is vaild */
+ /* check if the unit is valid */
unit = env + strlen(env) - 1;
/* no unit, all the character are value character */
if (isdigit(*unit)) {
config->unit = unit;
} else {
log(TERM, LOG_INFO, "Improper %s, set to default %s.\n",
- config->name, config->env);
+ config->name, config->env);
}
/* if env value string is greater than ulong_max, truncate the last digit */
if (config->overflow) {
/* when overflow, use basic unit */
- for (i = 0; config->units[i].name; i++) ;
- snprintf(str, size, "%lu%s", config->val, config->units[i-1].name);
+ for (i = 0; config->units[i].name; i++)
+ ;
+ snprintf(str, size, "%lu%s", config->val, config->units[i - 1].name);
log(TERM, LOG_INFO, "%s is set overflow(%s), truncate it\n",
- config->name, config->env);
+ config->name, config->env);
} else {
snprintf(str, size, "%s%s", config->env, config->unit);
}
parse_env_string(&threshold, threshold_string, sizeof(threshold_string));
parse_env_string(&cycle, cycle_string, sizeof(cycle_string));
log(TERM, LOG_INFO, "Threshold of memory Corrected Errors is %s / %s\n",
- threshold_string, cycle_string);
+ threshold_string, cycle_string);
}
void ras_page_account_init(void)
/* Offlining page is not required */
if (offline <= OFFLINE_ACCOUNT) {
log(TERM, LOG_INFO, "PAGE_CE_ACTION=%s, ignore to offline page at %#llx\n",
- offline_choice[offline].name, addr);
+ offline_choice[offline].name, addr);
return;
}
addr, page_state[pr->offlined]);
}
-static void page_record(struct page_record *pr, unsigned count, time_t time)
+static void page_record(struct page_record *pr, unsigned int count, time_t time)
{
unsigned long period = time - pr->start;
unsigned long tolerate;
return find;
}
-void ras_record_page_error(unsigned long long addr, unsigned count, time_t time)
+void ras_record_page_error(unsigned long long addr, unsigned int count, time_t time)
{
struct page_record *pr = NULL;
*/
static const struct db_fields mc_event_fields[] = {
- { .name="id", .type="INTEGER PRIMARY KEY" },
- { .name="timestamp", .type="TEXT" },
- { .name="err_count", .type="INTEGER" },
- { .name="err_type", .type="TEXT" },
- { .name="err_msg", .type="TEXT" },
- { .name="label", .type="TEXT" },
- { .name="mc", .type="INTEGER" },
- { .name="top_layer", .type="INTEGER" },
- { .name="middle_layer", .type="INTEGER" },
- { .name="lower_layer", .type="INTEGER" },
- { .name="address", .type="INTEGER" },
- { .name="grain", .type="INTEGER" },
- { .name="syndrome", .type="INTEGER" },
- { .name="driver_detail", .type="TEXT" },
+ { .name = "id", .type = "INTEGER PRIMARY KEY" },
+ { .name = "timestamp", .type = "TEXT" },
+ { .name = "err_count", .type = "INTEGER" },
+ { .name = "err_type", .type = "TEXT" },
+ { .name = "err_msg", .type = "TEXT" },
+ { .name = "label", .type = "TEXT" },
+ { .name = "mc", .type = "INTEGER" },
+ { .name = "top_layer", .type = "INTEGER" },
+ { .name = "middle_layer", .type = "INTEGER" },
+ { .name = "lower_layer", .type = "INTEGER" },
+ { .name = "address", .type = "INTEGER" },
+ { .name = "grain", .type = "INTEGER" },
+ { .name = "syndrome", .type = "INTEGER" },
+ { .name = "driver_detail", .type = "TEXT" },
};
static const struct db_table_descriptor mc_event_tab = {
sqlite3_bind_int (priv->stmt_mc_event, 7, ev->top_layer);
sqlite3_bind_int (priv->stmt_mc_event, 8, ev->middle_layer);
sqlite3_bind_int (priv->stmt_mc_event, 9, ev->lower_layer);
- sqlite3_bind_int64 (priv->stmt_mc_event, 10, ev->address);
- sqlite3_bind_int64 (priv->stmt_mc_event, 11, ev->grain);
- sqlite3_bind_int64 (priv->stmt_mc_event, 12, ev->syndrome);
+ sqlite3_bind_int64(priv->stmt_mc_event, 10, ev->address);
+ sqlite3_bind_int64(priv->stmt_mc_event, 11, ev->grain);
+ sqlite3_bind_int64(priv->stmt_mc_event, 12, ev->syndrome);
sqlite3_bind_text(priv->stmt_mc_event, 13, ev->driver_detail, -1, NULL);
rc = sqlite3_step(priv->stmt_mc_event);
if (rc != SQLITE_OK && rc != SQLITE_DONE)
#ifdef HAVE_AER
static const struct db_fields aer_event_fields[] = {
- { .name="id", .type="INTEGER PRIMARY KEY" },
- { .name="timestamp", .type="TEXT" },
- { .name="dev_name", .type="TEXT" },
- { .name="err_type", .type="TEXT" },
- { .name="err_msg", .type="TEXT" },
+ { .name = "id", .type = "INTEGER PRIMARY KEY" },
+ { .name = "timestamp", .type = "TEXT" },
+ { .name = "dev_name", .type = "TEXT" },
+ { .name = "err_type", .type = "TEXT" },
+ { .name = "err_msg", .type = "TEXT" },
};
static const struct db_table_descriptor aer_event_tab = {
#ifdef HAVE_NON_STANDARD
static const struct db_fields non_standard_event_fields[] = {
- { .name="id", .type="INTEGER PRIMARY KEY" },
- { .name="timestamp", .type="TEXT" },
- { .name="sec_type", .type="BLOB" },
- { .name="fru_id", .type="BLOB" },
- { .name="fru_text", .type="TEXT" },
- { .name="severity", .type="TEXT" },
- { .name="error", .type="BLOB" },
+ { .name = "id", .type = "INTEGER PRIMARY KEY" },
+ { .name = "timestamp", .type = "TEXT" },
+ { .name = "sec_type", .type = "BLOB" },
+ { .name = "fru_id", .type = "BLOB" },
+ { .name = "fru_text", .type = "TEXT" },
+ { .name = "severity", .type = "TEXT" },
+ { .name = "error", .type = "BLOB" },
};
static const struct db_table_descriptor non_standard_event_tab = {
return 0;
log(TERM, LOG_INFO, "non_standard_event store: %p\n", priv->stmt_non_standard_record);
- sqlite3_bind_text (priv->stmt_non_standard_record, 1, ev->timestamp, -1, NULL);
- sqlite3_bind_blob (priv->stmt_non_standard_record, 2, ev->sec_type, -1, NULL);
- sqlite3_bind_blob (priv->stmt_non_standard_record, 3, ev->fru_id, 16, NULL);
- sqlite3_bind_text (priv->stmt_non_standard_record, 4, ev->fru_text, -1, NULL);
- sqlite3_bind_text (priv->stmt_non_standard_record, 5, ev->severity, -1, NULL);
- sqlite3_bind_blob (priv->stmt_non_standard_record, 6, ev->error, ev->length, NULL);
+ sqlite3_bind_text(priv->stmt_non_standard_record, 1, ev->timestamp, -1, NULL);
+ sqlite3_bind_blob(priv->stmt_non_standard_record, 2, ev->sec_type, -1, NULL);
+ sqlite3_bind_blob(priv->stmt_non_standard_record, 3, ev->fru_id, 16, NULL);
+ sqlite3_bind_text(priv->stmt_non_standard_record, 4, ev->fru_text, -1, NULL);
+ sqlite3_bind_text(priv->stmt_non_standard_record, 5, ev->severity, -1, NULL);
+ sqlite3_bind_blob(priv->stmt_non_standard_record, 6, ev->error, ev->length, NULL);
rc = sqlite3_step(priv->stmt_non_standard_record);
if (rc != SQLITE_OK && rc != SQLITE_DONE)
#ifdef HAVE_ARM
static const struct db_fields arm_event_fields[] = {
- { .name="id", .type="INTEGER PRIMARY KEY" },
- { .name="timestamp", .type="TEXT" },
- { .name="error_count", .type="INTEGER" },
- { .name="affinity", .type="INTEGER" },
- { .name="mpidr", .type="INTEGER" },
- { .name="running_state", .type="INTEGER" },
- { .name="psci_state", .type="INTEGER" },
- { .name="err_info", .type="BLOB" },
- { .name="context_info", .type="BLOB" },
- { .name="vendor_info", .type="BLOB" },
+ { .name = "id", .type = "INTEGER PRIMARY KEY" },
+ { .name = "timestamp", .type = "TEXT" },
+ { .name = "error_count", .type = "INTEGER" },
+ { .name = "affinity", .type = "INTEGER" },
+ { .name = "mpidr", .type = "INTEGER" },
+ { .name = "running_state", .type = "INTEGER" },
+ { .name = "psci_state", .type = "INTEGER" },
+ { .name = "err_info", .type = "BLOB" },
+ { .name = "context_info", .type = "BLOB" },
+ { .name = "vendor_info", .type = "BLOB" },
};
static const struct db_table_descriptor arm_event_tab = {
return 0;
log(TERM, LOG_INFO, "arm_event store: %p\n", priv->stmt_arm_record);
- sqlite3_bind_text (priv->stmt_arm_record, 1, ev->timestamp, -1, NULL);
+ sqlite3_bind_text(priv->stmt_arm_record, 1, ev->timestamp, -1, NULL);
sqlite3_bind_int (priv->stmt_arm_record, 2, ev->error_count);
sqlite3_bind_int (priv->stmt_arm_record, 3, ev->affinity);
- sqlite3_bind_int64 (priv->stmt_arm_record, 4, ev->mpidr);
+ sqlite3_bind_int64(priv->stmt_arm_record, 4, ev->mpidr);
sqlite3_bind_int (priv->stmt_arm_record, 5, ev->running_state);
sqlite3_bind_int (priv->stmt_arm_record, 6, ev->psci_state);
- sqlite3_bind_blob (priv->stmt_arm_record, 7,
- ev->pei_error, ev->pei_len, NULL);
- sqlite3_bind_blob (priv->stmt_arm_record, 8,
- ev->ctx_error, ev->ctx_len, NULL);
- sqlite3_bind_blob (priv->stmt_arm_record, 9,
- ev->vsei_error, ev->oem_len, NULL);
+ sqlite3_bind_blob(priv->stmt_arm_record, 7,
+ ev->pei_error, ev->pei_len, NULL);
+ sqlite3_bind_blob(priv->stmt_arm_record, 8,
+ ev->ctx_error, ev->ctx_len, NULL);
+ sqlite3_bind_blob(priv->stmt_arm_record, 9,
+ ev->vsei_error, ev->oem_len, NULL);
rc = sqlite3_step(priv->stmt_arm_record);
if (rc != SQLITE_OK && rc != SQLITE_DONE)
#ifdef HAVE_EXTLOG
static const struct db_fields extlog_event_fields[] = {
- { .name="id", .type="INTEGER PRIMARY KEY" },
- { .name="timestamp", .type="TEXT" },
- { .name="etype", .type="INTEGER" },
- { .name="error_count", .type="INTEGER" },
- { .name="severity", .type="INTEGER" },
- { .name="address", .type="INTEGER" },
- { .name="fru_id", .type="BLOB" },
- { .name="fru_text", .type="TEXT" },
- { .name="cper_data", .type="BLOB" },
+ { .name = "id", .type = "INTEGER PRIMARY KEY" },
+ { .name = "timestamp", .type = "TEXT" },
+ { .name = "etype", .type = "INTEGER" },
+ { .name = "error_count", .type = "INTEGER" },
+ { .name = "severity", .type = "INTEGER" },
+ { .name = "address", .type = "INTEGER" },
+ { .name = "fru_id", .type = "BLOB" },
+ { .name = "fru_text", .type = "TEXT" },
+ { .name = "cper_data", .type = "BLOB" },
};
static const struct db_table_descriptor extlog_event_tab = {
return 0;
log(TERM, LOG_INFO, "extlog_record store: %p\n", priv->stmt_extlog_record);
- sqlite3_bind_text (priv->stmt_extlog_record, 1, ev->timestamp, -1, NULL);
+ sqlite3_bind_text(priv->stmt_extlog_record, 1, ev->timestamp, -1, NULL);
sqlite3_bind_int (priv->stmt_extlog_record, 2, ev->etype);
sqlite3_bind_int (priv->stmt_extlog_record, 3, ev->error_seq);
sqlite3_bind_int (priv->stmt_extlog_record, 4, ev->severity);
- sqlite3_bind_int64 (priv->stmt_extlog_record, 5, ev->address);
- sqlite3_bind_blob (priv->stmt_extlog_record, 6, ev->fru_id, 16, NULL);
- sqlite3_bind_text (priv->stmt_extlog_record, 7, ev->fru_text, -1, NULL);
- sqlite3_bind_blob (priv->stmt_extlog_record, 8, ev->cper_data, ev->cper_data_length, NULL);
+ sqlite3_bind_int64(priv->stmt_extlog_record, 5, ev->address);
+ sqlite3_bind_blob(priv->stmt_extlog_record, 6, ev->fru_id, 16, NULL);
+ sqlite3_bind_text(priv->stmt_extlog_record, 7, ev->fru_text, -1, NULL);
+ sqlite3_bind_blob(priv->stmt_extlog_record, 8, ev->cper_data, ev->cper_data_length, NULL);
rc = sqlite3_step(priv->stmt_extlog_record);
if (rc != SQLITE_OK && rc != SQLITE_DONE)
#ifdef HAVE_MCE
static const struct db_fields mce_record_fields[] = {
- { .name="id", .type="INTEGER PRIMARY KEY" },
- { .name="timestamp", .type="TEXT" },
+ { .name = "id", .type = "INTEGER PRIMARY KEY" },
+ { .name = "timestamp", .type = "TEXT" },
/* MCE registers */
- { .name="mcgcap", .type="INTEGER" },
- { .name="mcgstatus", .type="INTEGER" },
- { .name="status", .type="INTEGER" },
- { .name="addr", .type="INTEGER" }, // 5
- { .name="misc", .type="INTEGER" },
- { .name="ip", .type="INTEGER" },
- { .name="tsc", .type="INTEGER" },
- { .name="walltime", .type="INTEGER" },
- { .name="cpu", .type="INTEGER" }, // 10
- { .name="cpuid", .type="INTEGER" },
- { .name="apicid", .type="INTEGER" },
- { .name="socketid", .type="INTEGER" },
- { .name="cs", .type="INTEGER" },
- { .name="bank", .type="INTEGER" }, //15
- { .name="cpuvendor", .type="INTEGER" },
+ { .name = "mcgcap", .type = "INTEGER" },
+ { .name = "mcgstatus", .type = "INTEGER" },
+ { .name = "status", .type = "INTEGER" },
+ { .name = "addr", .type = "INTEGER" }, // 5
+ { .name = "misc", .type = "INTEGER" },
+ { .name = "ip", .type = "INTEGER" },
+ { .name = "tsc", .type = "INTEGER" },
+ { .name = "walltime", .type = "INTEGER" },
+ { .name = "cpu", .type = "INTEGER" }, // 10
+ { .name = "cpuid", .type = "INTEGER" },
+ { .name = "apicid", .type = "INTEGER" },
+ { .name = "socketid", .type = "INTEGER" },
+ { .name = "cs", .type = "INTEGER" },
+ { .name = "bank", .type = "INTEGER" }, //15
+ { .name = "cpuvendor", .type = "INTEGER" },
/* Parsed data - will likely change */
- { .name="bank_name", .type="TEXT" },
- { .name="error_msg", .type="TEXT" },
- { .name="mcgstatus_msg", .type="TEXT" },
- { .name="mcistatus_msg", .type="TEXT" }, // 20
- { .name="mcastatus_msg", .type="TEXT" },
- { .name="user_action", .type="TEXT" },
- { .name="mc_location", .type="TEXT" },
+ { .name = "bank_name", .type = "TEXT" },
+ { .name = "error_msg", .type = "TEXT" },
+ { .name = "mcgstatus_msg", .type = "TEXT" },
+ { .name = "mcistatus_msg", .type = "TEXT" }, // 20
+ { .name = "mcastatus_msg", .type = "TEXT" },
+ { .name = "user_action", .type = "TEXT" },
+ { .name = "mc_location", .type = "TEXT" },
};
static const struct db_table_descriptor mce_record_tab = {
return 0;
log(TERM, LOG_INFO, "mce_record store: %p\n", priv->stmt_mce_record);
- sqlite3_bind_text (priv->stmt_mce_record, 1, ev->timestamp, -1, NULL);
+ sqlite3_bind_text(priv->stmt_mce_record, 1, ev->timestamp, -1, NULL);
sqlite3_bind_int (priv->stmt_mce_record, 2, ev->mcgcap);
sqlite3_bind_int (priv->stmt_mce_record, 3, ev->mcgstatus);
- sqlite3_bind_int64 (priv->stmt_mce_record, 4, ev->status);
- sqlite3_bind_int64 (priv->stmt_mce_record, 5, ev->addr);
- sqlite3_bind_int64 (priv->stmt_mce_record, 6, ev->misc);
- sqlite3_bind_int64 (priv->stmt_mce_record, 7, ev->ip);
- sqlite3_bind_int64 (priv->stmt_mce_record, 8, ev->tsc);
- sqlite3_bind_int64 (priv->stmt_mce_record, 9, ev->walltime);
+ sqlite3_bind_int64(priv->stmt_mce_record, 4, ev->status);
+ sqlite3_bind_int64(priv->stmt_mce_record, 5, ev->addr);
+ sqlite3_bind_int64(priv->stmt_mce_record, 6, ev->misc);
+ sqlite3_bind_int64(priv->stmt_mce_record, 7, ev->ip);
+ sqlite3_bind_int64(priv->stmt_mce_record, 8, ev->tsc);
+ sqlite3_bind_int64(priv->stmt_mce_record, 9, ev->walltime);
sqlite3_bind_int (priv->stmt_mce_record, 10, ev->cpu);
sqlite3_bind_int (priv->stmt_mce_record, 11, ev->cpuid);
sqlite3_bind_int (priv->stmt_mce_record, 12, ev->apicid);
#ifdef HAVE_DEVLINK
static const struct db_fields devlink_event_fields[] = {
- { .name="id", .type="INTEGER PRIMARY KEY" },
- { .name="timestamp", .type="TEXT" },
- { .name="bus_name", .type="TEXT" },
- { .name="dev_name", .type="TEXT" },
- { .name="driver_name", .type="TEXT" },
- { .name="reporter_name", .type="TEXT" },
- { .name="msg", .type="TEXT" },
+ { .name = "id", .type = "INTEGER PRIMARY KEY" },
+ { .name = "timestamp", .type = "TEXT" },
+ { .name = "bus_name", .type = "TEXT" },
+ { .name = "dev_name", .type = "TEXT" },
+ { .name = "driver_name", .type = "TEXT" },
+ { .name = "reporter_name", .type = "TEXT" },
+ { .name = "msg", .type = "TEXT" },
};
static const struct db_table_descriptor devlink_event_tab = {
#ifdef HAVE_DISKERROR
static const struct db_fields diskerror_event_fields[] = {
- { .name="id", .type="INTEGER PRIMARY KEY" },
- { .name="timestamp", .type="TEXT" },
- { .name="dev", .type="TEXT" },
- { .name="sector", .type="INTEGER" },
- { .name="nr_sector", .type="INTEGER" },
- { .name="error", .type="TEXT" },
- { .name="rwbs", .type="TEXT" },
- { .name="cmd", .type="TEXT" },
+ { .name = "id", .type = "INTEGER PRIMARY KEY" },
+ { .name = "timestamp", .type = "TEXT" },
+ { .name = "dev", .type = "TEXT" },
+ { .name = "sector", .type = "INTEGER" },
+ { .name = "nr_sector", .type = "INTEGER" },
+ { .name = "error", .type = "TEXT" },
+ { .name = "rwbs", .type = "TEXT" },
+ { .name = "cmd", .type = "TEXT" },
};
static const struct db_table_descriptor diskerror_event_tab = {
#ifdef HAVE_MEMORY_FAILURE
static const struct db_fields mf_event_fields[] = {
- { .name="id", .type="INTEGER PRIMARY KEY" },
- { .name="timestamp", .type="TEXT" },
- { .name="pfn", .type="TEXT" },
- { .name="page_type", .type="TEXT" },
- { .name="action_result", .type="TEXT" },
+ { .name = "id", .type = "INTEGER PRIMARY KEY" },
+ { .name = "timestamp", .type = "TEXT" },
+ { .name = "pfn", .type = "TEXT" },
+ { .name = "page_type", .type = "TEXT" },
+ { .name = "action_result", .type = "TEXT" },
};
static const struct db_table_descriptor mf_event_tab = {
found = 0;
for (j = 0; j < col_count; j++) {
if (!strcmp(field->name,
- sqlite3_column_name(*stmt, j))) {
+ sqlite3_column_name(*stmt, j))) {
found = 1;
break;
}
return rc;
}
-int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras)
+int ras_mc_event_opendb(unsigned int cpu, struct ras_events *ras)
{
int rc;
sqlite3 *db;
struct sqlite3_priv *priv;
- printf("Calling %s()\n", __FUNCTION__);
+ printf("Calling %s()\n", __func__);
ras->db_ref_count++;
if (ras->db_ref_count > 1)
return -1;
struct stat st = {0};
+
if (stat(RASSTATEDIR, &st) == -1) {
if (errno != ENOENT) {
log(TERM, LOG_ERR,
rc = ras_mc_create_table(priv, &non_standard_event_tab);
if (rc == SQLITE_OK) {
rc = ras_mc_prepare_stmt(priv, &priv->stmt_non_standard_record,
- &non_standard_event_tab);
+ &non_standard_event_tab);
if (rc != SQLITE_OK)
goto error;
}
rc = ras_mc_create_table(priv, &arm_event_tab);
if (rc == SQLITE_OK) {
rc = ras_mc_prepare_stmt(priv, &priv->stmt_arm_record,
- &arm_event_tab);
+ &arm_event_tab);
if (rc != SQLITE_OK)
goto error;
}
rc = ras_mc_create_table(priv, &devlink_event_tab);
if (rc == SQLITE_OK) {
rc = ras_mc_prepare_stmt(priv, &priv->stmt_devlink_event,
- &devlink_event_tab);
+ &devlink_event_tab);
if (rc != SQLITE_OK)
goto error;
}
rc = ras_mc_create_table(priv, &diskerror_event_tab);
if (rc == SQLITE_OK) {
rc = ras_mc_prepare_stmt(priv, &priv->stmt_diskerror_event,
- &diskerror_event_tab);
+ &diskerror_event_tab);
if (rc != SQLITE_OK)
goto error;
}
}
#endif
-
#ifdef HAVE_MCE
if (priv->stmt_mce_record) {
rc = sqlite3_finalize(priv->stmt_mce_record);
#include "ras-report.h"
-static int setup_report_socket(void){
+static int setup_report_socket(void)
+{
int sockfd = -1;
int rc = -1;
struct sockaddr_un addr;
sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
- if (sockfd < 0){
+ if (sockfd < 0) {
return -1;
}
return sockfd;
}
-static int commit_report_basic(int sockfd){
+static int commit_report_basic(int sockfd)
+{
char buf[INPUT_BUFFER_SIZE];
struct utsname un;
int rc = -1;
- if(sockfd < 0){
+ if (sockfd < 0) {
return rc;
}
memset(&un, 0, sizeof(struct utsname));
rc = uname(&un);
- if(rc < 0){
+ if (rc < 0) {
return rc;
}
*/
sprintf(buf, "PUT / HTTP/1.1\r\n\r\n");
rc = write(sockfd, buf, strlen(buf));
- if(rc < strlen(buf)){
+ if (rc < strlen(buf)) {
return -1;
}
sprintf(buf, "PID=%d", (int)getpid());
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
return -1;
}
sprintf(buf, "EXECUTABLE=/boot/vmlinuz-%s", un.release);
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
return -1;
}
sprintf(buf, "TYPE=%s", "ras");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
return -1;
}
return 0;
}
-static int set_mc_event_backtrace(char *buf, struct ras_mc_event *ev){
+static int set_mc_event_backtrace(char *buf, struct ras_mc_event *ev)
+{
char bt_buf[MAX_BACKTRACE_SIZE];
- if(!buf || !ev)
+ if (!buf || !ev)
return -1;
sprintf(bt_buf, "BACKTRACE=" \
return 0;
}
-static int set_mce_event_backtrace(char *buf, struct mce_event *ev){
+static int set_mce_event_backtrace(char *buf, struct mce_event *ev)
+{
char bt_buf[MAX_BACKTRACE_SIZE];
- if(!buf || !ev)
+ if (!buf || !ev)
return -1;
sprintf(bt_buf, "BACKTRACE=" \
return 0;
}
-static int set_aer_event_backtrace(char *buf, struct ras_aer_event *ev){
+static int set_aer_event_backtrace(char *buf, struct ras_aer_event *ev)
+{
char bt_buf[MAX_BACKTRACE_SIZE];
- if(!buf || !ev)
+ if (!buf || !ev)
return -1;
sprintf(bt_buf, "BACKTRACE=" \
return 0;
}
-static int set_non_standard_event_backtrace(char *buf, struct ras_non_standard_event *ev){
+static int set_non_standard_event_backtrace(char *buf, struct ras_non_standard_event *ev)
+{
char bt_buf[MAX_BACKTRACE_SIZE];
- if(!buf || !ev)
+ if (!buf || !ev)
return -1;
sprintf(bt_buf, "BACKTRACE=" \
return 0;
}
-static int set_arm_event_backtrace(char *buf, struct ras_arm_event *ev){
+static int set_arm_event_backtrace(char *buf, struct ras_arm_event *ev)
+{
char bt_buf[MAX_BACKTRACE_SIZE];
- if(!buf || !ev)
+ if (!buf || !ev)
return -1;
sprintf(bt_buf, "BACKTRACE=" \
return 0;
}
-static int set_devlink_event_backtrace(char *buf, struct devlink_event *ev){
+static int set_devlink_event_backtrace(char *buf, struct devlink_event *ev)
+{
char bt_buf[MAX_BACKTRACE_SIZE];
- if(!buf || !ev)
+ if (!buf || !ev)
return -1;
sprintf(bt_buf, "BACKTRACE=" \
return 0;
}
-static int set_diskerror_event_backtrace(char *buf, struct diskerror_event *ev) {
+static int set_diskerror_event_backtrace(char *buf, struct diskerror_event *ev)
+{
char bt_buf[MAX_BACKTRACE_SIZE];
- if(!buf || !ev)
+ if (!buf || !ev)
return -1;
sprintf(bt_buf, "BACKTRACE=" \
return -1;
sprintf(bt_buf, "BACKTRACE=" \
- "timestamp=%s\n" \
- "pfn=%s\n" \
- "page_type=%s\n" \
- "action_result=%s\n", \
- ev->timestamp, \
- ev->pfn, \
- ev->page_type, \
- ev->action_result);
+ "timestamp=%s\n" \
+ "pfn=%s\n" \
+ "page_type=%s\n" \
+ "action_result=%s\n", \
+ ev->timestamp, \
+ ev->pfn, \
+ ev->page_type, \
+ ev->action_result);
strcat(buf, bt_buf);
return 0;
}
-static int commit_report_backtrace(int sockfd, int type, void *ev){
+static int commit_report_backtrace(int sockfd, int type, void *ev)
+{
char buf[MAX_BACKTRACE_SIZE];
char *pbuf = buf;
int rc = -1;
int buf_len = 0;
- if(sockfd < 0 || !ev){
+ if (sockfd < 0 || !ev) {
return -1;
}
memset(buf, 0, MAX_BACKTRACE_SIZE);
- switch(type){
+ switch (type) {
case MC_EVENT:
rc = set_mc_event_backtrace(buf, (struct ras_mc_event *)ev);
break;
return -1;
}
- if(rc < 0){
+ if (rc < 0) {
return -1;
}
buf_len = strlen(buf);
- for(;buf_len > INPUT_BUFFER_SIZE - 1; buf_len -= (INPUT_BUFFER_SIZE - 1)){
+ for (; buf_len > INPUT_BUFFER_SIZE - 1; buf_len -= (INPUT_BUFFER_SIZE - 1)) {
rc = write(sockfd, pbuf, INPUT_BUFFER_SIZE - 1);
- if(rc < INPUT_BUFFER_SIZE - 1){
+ if (rc < INPUT_BUFFER_SIZE - 1) {
return -1;
}
}
rc = write(sockfd, pbuf, buf_len + 1);
- if(rc < buf_len){
+ if (rc < buf_len) {
return -1;
}
return 0;
}
-int ras_report_mc_event(struct ras_events *ras, struct ras_mc_event *ev){
+int ras_report_mc_event(struct ras_events *ras, struct ras_mc_event *ev)
+{
char buf[MAX_MESSAGE_SIZE];
int sockfd = -1;
int done = 0;
memset(buf, 0, sizeof(buf));
sockfd = setup_report_socket();
- if(sockfd < 0){
+ if (sockfd < 0) {
return -1;
}
rc = commit_report_basic(sockfd);
- if(rc < 0){
+ if (rc < 0) {
goto mc_fail;
}
rc = commit_report_backtrace(sockfd, MC_EVENT, ev);
- if(rc < 0){
+ if (rc < 0) {
goto mc_fail;
}
sprintf(buf, "ANALYZER=%s", "rasdaemon-mc");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto mc_fail;
}
sprintf(buf, "REASON=%s", "EDAC driver report problem");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto mc_fail;
}
mc_fail:
- if(sockfd >= 0){
+ if (sockfd >= 0) {
close(sockfd);
}
- if(done){
+ if (done) {
return 0;
- }else{
+ } else {
return -1;
}
}
-int ras_report_aer_event(struct ras_events *ras, struct ras_aer_event *ev){
+int ras_report_aer_event(struct ras_events *ras, struct ras_aer_event *ev)
+{
char buf[MAX_MESSAGE_SIZE];
int sockfd = 0;
int done = 0;
memset(buf, 0, sizeof(buf));
sockfd = setup_report_socket();
- if(sockfd < 0){
+ if (sockfd < 0) {
return -1;
}
rc = commit_report_basic(sockfd);
- if(rc < 0){
+ if (rc < 0) {
goto aer_fail;
}
rc = commit_report_backtrace(sockfd, AER_EVENT, ev);
- if(rc < 0){
+ if (rc < 0) {
goto aer_fail;
}
sprintf(buf, "ANALYZER=%s", "rasdaemon-aer");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto aer_fail;
}
sprintf(buf, "REASON=%s", "PCIe AER driver report problem");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto aer_fail;
}
aer_fail:
- if(sockfd >= 0){
+ if (sockfd >= 0) {
close(sockfd);
}
- if(done){
+ if (done) {
return 0;
- }else{
+ } else {
return -1;
}
}
-int ras_report_non_standard_event(struct ras_events *ras, struct ras_non_standard_event *ev){
+int ras_report_non_standard_event(struct ras_events *ras, struct ras_non_standard_event *ev)
+{
char buf[MAX_MESSAGE_SIZE];
int sockfd = 0;
int rc = -1;
memset(buf, 0, sizeof(buf));
sockfd = setup_report_socket();
- if(sockfd < 0){
+ if (sockfd < 0) {
return rc;
}
rc = commit_report_basic(sockfd);
- if(rc < 0){
+ if (rc < 0) {
goto non_standard_fail;
}
rc = commit_report_backtrace(sockfd, NON_STANDARD_EVENT, ev);
- if(rc < 0){
+ if (rc < 0) {
goto non_standard_fail;
}
sprintf(buf, "ANALYZER=%s", "rasdaemon-non-standard");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto non_standard_fail;
}
sprintf(buf, "REASON=%s", "Unknown CPER section problem");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto non_standard_fail;
}
non_standard_fail:
- if(sockfd >= 0){
+ if (sockfd >= 0) {
close(sockfd);
}
return rc;
}
-int ras_report_arm_event(struct ras_events *ras, struct ras_arm_event *ev){
+int ras_report_arm_event(struct ras_events *ras, struct ras_arm_event *ev)
+{
char buf[MAX_MESSAGE_SIZE];
int sockfd = 0;
int rc = -1;
memset(buf, 0, sizeof(buf));
sockfd = setup_report_socket();
- if(sockfd < 0){
+ if (sockfd < 0) {
return rc;
}
rc = commit_report_basic(sockfd);
- if(rc < 0){
+ if (rc < 0) {
goto arm_fail;
}
rc = commit_report_backtrace(sockfd, ARM_EVENT, ev);
- if(rc < 0){
+ if (rc < 0) {
goto arm_fail;
}
sprintf(buf, "ANALYZER=%s", "rasdaemon-arm");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto arm_fail;
}
sprintf(buf, "REASON=%s", "ARM CPU report problem");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto arm_fail;
}
arm_fail:
- if(sockfd >= 0){
+ if (sockfd >= 0) {
close(sockfd);
}
return rc;
}
-int ras_report_mce_event(struct ras_events *ras, struct mce_event *ev){
+int ras_report_mce_event(struct ras_events *ras, struct mce_event *ev)
+{
char buf[MAX_MESSAGE_SIZE];
int sockfd = 0;
int done = 0;
memset(buf, 0, sizeof(buf));
sockfd = setup_report_socket();
- if(sockfd < 0){
+ if (sockfd < 0) {
return -1;
}
rc = commit_report_basic(sockfd);
- if(rc < 0){
+ if (rc < 0) {
goto mce_fail;
}
rc = commit_report_backtrace(sockfd, MCE_EVENT, ev);
- if(rc < 0){
+ if (rc < 0) {
goto mce_fail;
}
sprintf(buf, "ANALYZER=%s", "rasdaemon-mce");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto mce_fail;
}
sprintf(buf, "REASON=%s", "Machine Check driver report problem");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto mce_fail;
}
mce_fail:
- if(sockfd >= 0){
+ if (sockfd >= 0) {
close(sockfd);
}
- if(done){
+ if (done) {
return 0;
- }else{
+ } else {
return -1;
}
}
-int ras_report_devlink_event(struct ras_events *ras, struct devlink_event *ev){
+int ras_report_devlink_event(struct ras_events *ras, struct devlink_event *ev)
+{
char buf[MAX_MESSAGE_SIZE];
int sockfd = 0;
int done = 0;
memset(buf, 0, sizeof(buf));
sockfd = setup_report_socket();
- if(sockfd < 0){
+ if (sockfd < 0) {
return -1;
}
rc = commit_report_basic(sockfd);
- if(rc < 0){
+ if (rc < 0) {
goto devlink_fail;
}
rc = commit_report_backtrace(sockfd, DEVLINK_EVENT, ev);
- if(rc < 0){
+ if (rc < 0) {
goto devlink_fail;
}
sprintf(buf, "ANALYZER=%s", "rasdaemon-devlink");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto devlink_fail;
}
sprintf(buf, "REASON=%s", "devlink health report problem");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto devlink_fail;
}
devlink_fail:
- if(sockfd >= 0){
+ if (sockfd >= 0) {
close(sockfd);
}
- if(done){
+ if (done) {
return 0;
- }else{
+ } else {
return -1;
}
}
-int ras_report_diskerror_event(struct ras_events *ras, struct diskerror_event *ev){
+int ras_report_diskerror_event(struct ras_events *ras, struct diskerror_event *ev)
+{
char buf[MAX_MESSAGE_SIZE];
int sockfd = 0;
int done = 0;
memset(buf, 0, sizeof(buf));
sockfd = setup_report_socket();
- if(sockfd < 0){
+ if (sockfd < 0) {
return -1;
}
rc = commit_report_basic(sockfd);
- if(rc < 0){
+ if (rc < 0) {
goto diskerror_fail;
}
rc = commit_report_backtrace(sockfd, DISKERROR_EVENT, ev);
- if(rc < 0){
+ if (rc < 0) {
goto diskerror_fail;
}
sprintf(buf, "ANALYZER=%s", "rasdaemon-diskerror");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto diskerror_fail;
}
sprintf(buf, "REASON=%s", "disk I/O error");
rc = write(sockfd, buf, strlen(buf) + 1);
- if(rc < strlen(buf) + 1){
+ if (rc < strlen(buf) + 1) {
goto diskerror_fail;
}
done = 1;
diskerror_fail:
- if(sockfd >= 0){
+ if (sockfd >= 0) {
close(sockfd);
}
- if(done){
+ if (done) {
return 0;
- }else{
+ } else {
return -1;
}
}
return 0;
else
return -1;
-
}
int ras_report_cxl_general_media_event(struct ras_events *ras, struct ras_cxl_general_media_event *ev)
#define TOOL_DESCRIPTION "RAS daemon to log the RAS events."
#define ARGS_DOC "<options>"
#define DISABLE "DISABLE"
-char *choices_disable = NULL;
+char *choices_disable;
const char *argp_program_version = TOOL_NAME " " VERSION;
const char *argp_program_bug_address = "Mauro Carvalho Chehab <mchehab@kernel.org>";
{
struct arguments args;
int idx = -1;
+
choices_disable = getenv(DISABLE);
#ifdef HAVE_MCE
.children = offline_parser,
#endif
};
- memset (&args, 0, sizeof(args));
+ memset(&args, 0, sizeof(args));
user_hz = sysconf(_SC_CLK_TCK);
openlog(TOOL_NAME, 0, LOG_DAEMON);
if (!args.foreground)
- if (daemon(0,0))
+ if (daemon(0, 0))
exit(EXIT_FAILURE);
handle_ras_events(args.record_events);
struct rb_node *right = node->rb_right;
struct rb_node *parent = rb_parent(node);
- if ((node->rb_right = right->rb_left))
+ node->rb_right = right->rb_left;
+ if (node->rb_right)
rb_set_parent(right->rb_left, node);
right->rb_left = node;
parent->rb_left = right;
else
parent->rb_right = right;
- }
- else
+ } else
root->rb_node = right;
rb_set_parent(node, right);
}
struct rb_node *left = node->rb_left;
struct rb_node *parent = rb_parent(node);
- if ((node->rb_left = left->rb_right))
+ node->rb_left = left->rb_right;
+ if (node->rb_left)
rb_set_parent(left->rb_right, node);
left->rb_right = node;
parent->rb_right = left;
else
parent->rb_left = left;
- }
- else
+ } else
root->rb_node = left;
rb_set_parent(node, left);
}
{
{
register struct rb_node *uncle = gparent->rb_right;
+
if (uncle && rb_is_red(uncle))
{
rb_set_black(uncle);
if (parent->rb_right == node)
{
struct rb_node *tmp;
+
__rb_rotate_left(parent, root);
tmp = parent;
parent = node;
} else {
{
struct rb_node *uncle = gparent->rb_left;
+
if (uncle && rb_is_red(uncle))
{
rb_set_black(uncle);
if (parent->rb_left == node)
{
struct rb_node *tmp;
+
__rb_rotate_right(parent, root);
tmp = parent;
parent = node;
rb_set_red(other);
node = parent;
parent = rb_parent(node);
- }
- else
+ } else
{
if (!other->rb_right || rb_is_black(other->rb_right))
{
node = root->rb_node;
break;
}
- }
- else
+ } else
{
other = parent->rb_left;
if (rb_is_red(other))
rb_set_red(other);
node = parent;
parent = rb_parent(node);
- }
- else
+ } else
{
if (!other->rb_left || rb_is_black(other->rb_left))
{
parent->rb_left = child;
else
parent->rb_right = child;
- }
- else
+ } else
root->rb_node = child;
color:
if (node->rb_right) {
node = node->rb_right;
while (node->rb_left)
- node=node->rb_left;
+ node = node->rb_left;
return (struct rb_node *)node;
}
if (node->rb_left) {
node = node->rb_left;
while (node->rb_right)
- node=node->rb_right;
+ node = node->rb_right;
return (struct rb_node *)node;
}