Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions misc/rasdaemon.env
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ TRIGGER_DIR=
# MC_UE_TRIGGER=mc_event_trigger
MC_CE_TRIGGER=
MC_UE_TRIGGER=
AER_CE_TRIGGER=
AER_UE_TRIGGER=

# CE Statistic Threshold
#
Expand Down
76 changes: 76 additions & 0 deletions ras-aer-handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
* Copyright (C) 2013 Mauro Carvalho Chehab <[email protected]>
*/

#define _GNU_SOURCE
#include <pci/pci.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <traceevent/kbuffer.h>
#include <unistd.h>
Expand All @@ -16,6 +18,7 @@
#include "ras-logger.h"
#include "ras-report.h"
#include "unified-sel.h"
#include "trigger.h"
#include "types.h"

/* bit field meaning for correctable error */
Expand Down Expand Up @@ -55,6 +58,47 @@ static const char *aer_uncor_errors[32] = {

static bool use_ipmitool = false;

#define MAX_ENV 30
static const char *aer_ce_trigger = NULL;
static const char *aer_ue_trigger = NULL;

void aer_event_trigger_setup(void)
{
const char *trigger;

trigger = getenv("AER_CE_TRIGGER");
if (trigger && strcmp(trigger, "")) {
aer_ce_trigger = trigger_check(trigger);

if (!aer_ce_trigger) {
log(ALL, LOG_ERR,
"Cannot access aer_event ce trigger `%s`\n",
trigger);
} else {
log(ALL, LOG_INFO,
"Setup aer_event ce trigger `%s`\n",
trigger);
}
} else {
log(TERM, LOG_ERR, "\t no AER_CE_TRIGGER (%p)\n", trigger);
}

trigger = getenv("AER_UE_TRIGGER");
if (trigger && strcmp(trigger, "")) {
aer_ue_trigger = trigger_check(trigger);

if (!aer_ue_trigger) {
log(ALL, LOG_ERR,
"Cannot access aer_event ue trigger `%s`\n",
trigger);
} else {
log(ALL, LOG_INFO,
"Setup aer_event ue trigger `%s`\n",
trigger);
}
}
}

void ras_aer_handler_init(int enable_ipmitool)
{
#ifdef HAVE_OPENBMC_UNIFIED_SEL
Expand Down Expand Up @@ -103,6 +147,32 @@ static void get_pci_dev_name(char *bdf, char *pci_name, ssize_t len, u16 *vendor
pci_cleanup(pacc);
}

static void run_aer_trigger(struct ras_aer_event *ev, const char *aer_trigger)
{
char *env[MAX_ENV];
int ei = 0;
int i;

if (asprintf(&env[ei++], "PATH=%s", getenv("PATH") ?: "/sbin:/usr/sbin:/bin:/usr/bin") < 0)
goto free;
if (asprintf(&env[ei++], "TIMESTAMP=%s", ev->timestamp) < 0)
goto free;
if (asprintf(&env[ei++], "TYPE=%s", ev->error_type) < 0)
goto free;
if (asprintf(&env[ei++], "MESSAGE=%s", ev->msg) < 0)
goto free;
if (asprintf(&env[ei++], "NAME=%s", ev->dev_name) < 0)
goto free;
env[ei] = NULL;
assert(ei < MAX_ENV);

run_trigger(aer_trigger, NULL, env, "aer_event");

free:
for (i = 0; i < ei; i++)
free(env[i]);
}

int ras_aer_event_handler(struct trace_seq *s,
struct tep_record *record,
struct tep_event *event, void *context)
Expand Down Expand Up @@ -270,5 +340,11 @@ int ras_aer_event_handler(struct trace_seq *s,
return -1;
#endif

if (aer_ce_trigger && !strcmp(ev.error_type, "Corrected"))
run_aer_trigger(&ev, aer_ce_trigger);

if (aer_ue_trigger && !strncmp(ev.error_type, "Uncorrected", 11))
run_aer_trigger(&ev, aer_ue_trigger);

return 0;
}
1 change: 1 addition & 0 deletions ras-aer-handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "ras-events.h"

void aer_event_trigger_setup(void);
int ras_aer_event_handler(struct trace_seq *s,
struct tep_record *record,
struct tep_event *event, void *context);
Expand Down
13 changes: 9 additions & 4 deletions ras-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "ras-events.h"
#include "ras-extlog-handler.h"
#include "ras-logger.h"
#include "ras-aer-handler.h"
#include "ras-mce-handler.h"
#include "ras-mc-handler.h"
#include "ras-memory-failure-handler.h"
Expand All @@ -47,15 +48,18 @@

/* Test for a little-endian machine */
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define ENDIAN KBUFFER_ENDIAN_LITTLE
#define ENDIAN TEP_LITTLE_ENDIAN
#else
#define ENDIAN KBUFFER_ENDIAN_BIG
#define ENDIAN TEP_BIG_ENDIAN
#endif

char *choices_disable;

static const struct event_trigger event_triggers[] = {
{ "mc_event", &mc_event_trigger_setup },
#ifdef HAVE_AER
{ "aer_event", &aer_event_trigger_setup },
#endif
#ifdef HAVE_MEMORY_FAILURE
{ "memory_failure_event", &mem_fail_event_trigger_setup },
#endif
Expand Down Expand Up @@ -418,6 +422,7 @@ static void parse_ras_data(struct pthread_data *pdata, struct kbuffer *kbuf,

/* TODO - logging */
trace_seq_init(&s);
tep_set_file_bigendian(pdata->ras->pevent, ENDIAN);
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,
Expand Down Expand Up @@ -498,7 +503,7 @@ static int read_ras_event_all_cpus(struct pthread_data *pdata,
return -ENOMEM;
}

kbuf = kbuffer_alloc(KBUFFER_LSIZE_8, ENDIAN);
kbuf = kbuffer_alloc(KBUFFER_LSIZE_SAME_AS_HOST, KBUFFER_ENDIAN_SAME_AS_HOST);
if (!kbuf) {
log(TERM, LOG_ERR, "Can't allocate kbuf\n");
free(page);
Expand Down Expand Up @@ -705,7 +710,7 @@ static void *handle_ras_events_cpu(void *priv)
return NULL;
}

kbuf = kbuffer_alloc(KBUFFER_LSIZE_8, ENDIAN);
kbuf = kbuffer_alloc(KBUFFER_LSIZE_SAME_AS_HOST, KBUFFER_ENDIAN_SAME_AS_HOST);
if (!kbuf) {
log(TERM, LOG_ERR, "Can't allocate kbuf");
free(page);
Expand Down