-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ipmitool SEL logging of AER CEs on OpenBMC platforms
Signed-off-by: Krishna Dhulipala <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
- Loading branch information
1 parent
d22ed5e
commit abb10f6
Showing
9 changed files
with
160 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ const char *argp_program_bug_address = "Mauro Carvalho Chehab <[email protected] | |
struct arguments { | ||
int record_events; | ||
int enable_ras; | ||
int enable_ipmitool; | ||
int foreground; | ||
int offline; | ||
}; | ||
|
@@ -61,6 +62,11 @@ static error_t parse_opt(int k, char *arg, struct argp_state *state) | |
case 'r': | ||
args->record_events++; | ||
break; | ||
#endif | ||
#ifdef HAVE_OPENBMC_UNIFIED_SEL | ||
case 'i': | ||
args->enable_ipmitool++; | ||
break; | ||
#endif | ||
case 'f': | ||
args->foreground++; | ||
|
@@ -152,6 +158,9 @@ int main(int argc, char *argv[]) | |
{"record", 'r', 0, 0, "record events via sqlite3", 0}, | ||
#endif | ||
{"foreground", 'f', 0, 0, "run foreground, not daemonize"}, | ||
#ifdef HAVE_OPENBMC_UNIFIED_SEL | ||
{"ipmitool", 'i', 0, 0, "enable ipmitool logging", 0}, | ||
#endif | ||
#ifdef HAVE_MCE | ||
{"post-processing", 'p', 0, 0, | ||
"Post-processing MCE's with raw register values"}, | ||
|
@@ -200,7 +209,7 @@ int main(int argc, char *argv[]) | |
if (daemon(0, 0)) | ||
exit(EXIT_FAILURE); | ||
|
||
handle_ras_events(args.record_events); | ||
handle_ras_events(args.record_events, args.enable_ipmitool); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Copyright (c) 2023, Meta Platforms Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <stdbool.h> | ||
#include "ras-record.h" | ||
#include "ras-logger.h" | ||
#include "ras-report.h" | ||
#include "unified-sel.h" | ||
|
||
/* CPU Root Port Error ID corresponding to each status bit set */ | ||
static const char *cor_error_ids[32] = { | ||
/* Correctable errors */ | ||
[0] = "0x00", /* Receiver Error */ | ||
[6] = "0x01", /* Bad TLP */ | ||
[7] = "0x02", /* Bad DLLP */ | ||
[8] = "0x04", /* RELAY_NUM Rollover */ | ||
[12] = "0x03", /* Replay Timer Timeout */ | ||
[13] = "0x05", /* Advisory Non-Fatal */ | ||
[14] = "0x06", /* Corrected Internal */ | ||
[15] = "0x07", /* Header Log Overflow */ | ||
}; | ||
|
||
static int verify_id_log_sel(uint64_t status, | ||
const char **idarray, | ||
unsigned bus, | ||
unsigned dev_fn) | ||
{ | ||
int i; | ||
char openbmc_ipmi_add_sel[105]; | ||
|
||
/* | ||
* Get PCIe AER error source bus/dev/fn and save it to the BMC SEL | ||
* as a OpenBMC unified SEL record type. | ||
* The IPMI command and record fields are defined in IPMI Specification v2.0 (IPMI Spec) | ||
* ipmitool raw 0x0a 0x44 is "Add SEL Entry Command" defined in IPMI spec chapter 31.6 | ||
* The 16 byte that follow form the SEL Record | ||
* defined in IPMI spec chapter 32.1 "SEL Event Records" | ||
* Byte 1~2 are Record ID = 0x00 0x00, unused | ||
* Byte 3 is Record Type = 0xFB, OEM non-timestamped record type for OpenBMC unified SEL | ||
* Byte 4~16 are OEM defined | ||
* Byte 11: | ||
* Byte11[7:3] Device# | ||
* Byte11[2:0] Function# | ||
* Byte 12: Bus number | ||
* Byte 13-15: Reserved | ||
* Byte 16: ID of the error detected on the PCle device that triggered this SEL record | ||
*/ | ||
|
||
/* Potentially all error status bits could be set for a given PCIe device. | ||
* Therefore, iterate over all 32 bits each of cor and uncor errors | ||
*/ | ||
for (i = 0; i < 32; i++) { | ||
if ((status & (1 << i)) && idarray[i]) { | ||
sprintf(openbmc_ipmi_add_sel, | ||
"ipmitool raw 0x0a 0x44 0x00 0x00 0xFB 0x20 0x00 0x00 0x00 0x00 0x01 0x00 0x%02x 0x%02x 0x01 0x00 0xff %s", | ||
dev_fn, bus, idarray[i]); | ||
if (system(openbmc_ipmi_add_sel) != 0) | ||
return -1; | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
int openbmc_unified_sel_log(uint64_t severity, const char *dev_name, uint64_t status) | ||
{ | ||
int bus, dev, dev_fn, fn; | ||
|
||
sscanf(dev_name, "%*x:%x:%x.%x", &bus, &dev, &fn); | ||
dev_fn = (((dev & 0x1f) << 3) | (fn & 0x7)); | ||
|
||
/* Use the appropriate correctable error status ID | ||
* for a given severity level | ||
* */ | ||
if (severity == HW_EVENT_AER_CORRECTED) { | ||
if (verify_id_log_sel(status, cor_error_ids, bus, dev_fn) < 0) | ||
return -1; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright (c) 2023, Meta Platforms Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
*/ | ||
|
||
|
||
#ifndef _UNIFIED_SEL_H | ||
#define _UNIFIED_SEL_H | ||
|
||
int openbmc_unified_sel_log(uint64_t severity, const char *dev_name, uint64_t status); | ||
|
||
#endif |