@@ -28,6 +28,7 @@
bool manufacturing_mode = false;
struct platform platform;
+const struct bmc_platform *bmc_platform = NULL;
DEFINE_LOG_ENTRY(OPAL_RC_ABNORMAL_REBOOT, OPAL_PLATFORM_ERR_EVT, OPAL_CEC,
OPAL_CEC_HARDWARE, OPAL_PREDICTIVE_ERR_FAULT_RECTIFY_REBOOT,
@@ -122,12 +123,24 @@ static int64_t generic_cec_power_down(uint64_t request __unused)
return OPAL_UNSUPPORTED;
}
+static struct bmc_platform generic_bmc = {
+ .name = "generic",
+};
+
static struct platform generic_platform = {
.name = "generic",
+ .bmc = &generic_bmc,
.init = generic_platform_init,
.cec_power_down = generic_cec_power_down,
};
+void set_bmc_platform(const struct bmc_platform *bmc)
+{
+ if (bmc)
+ prlog(PR_NOTICE, "PLAT: Detected BMC platform %s\n", bmc->name);
+ bmc_platform = bmc;
+}
+
void probe_platform(void)
{
struct platform *platforms = &__platforms_start;
@@ -154,8 +167,11 @@ void probe_platform(void)
}
prlog(PR_NOTICE, "PLAT: Detected %s platform\n", platform.name);
+
+ set_bmc_platform(platform.bmc);
}
+
int start_preload_resource(enum resource_id id, uint32_t subid,
void *buf, size_t *len)
{
@@ -334,6 +334,11 @@ static void ipmi_elog_poll(struct ipmi_msg *msg)
struct errorlog *elog_buf = (struct errorlog *) msg->user_data;
size_t req_size;
+ if (bmc_platform->ipmi_oem_partial_add_esel == 0) {
+ prlog(PR_WARNING, "BUG: Dropping ESEL on the floor due to buggy/mising code in OPAL for this BMC");
+ return;
+ }
+
ipmi_init_esel_record();
if (msg->cmd == IPMI_CMD(IPMI_RESERVE_SEL)) {
first = true;
@@ -386,7 +391,8 @@ static void ipmi_elog_poll(struct ipmi_msg *msg)
req_size = IPMI_MAX_REQ_SIZE;
}
- ipmi_init_msg(msg, IPMI_DEFAULT_INTERFACE, IPMI_PARTIAL_ADD_ESEL,
+ ipmi_init_msg(msg, IPMI_DEFAULT_INTERFACE,
+ bmc_platform->ipmi_oem_partial_add_esel,
ipmi_elog_poll, elog_buf, req_size, 2);
msg->data[0] = reservation_id & 0xff;
@@ -462,8 +468,19 @@ static void sel_pnor(uint8_t access)
if (granted)
occ_pnor_set_owner(PNOR_OWNER_EXTERNAL);
+ if (bmc_platform->ipmi_oem_pnor_access_status == 0) {
+ /**
+ * @fwts-label PNORAccessYeahButNoBut
+ * @fwts-advice OPAL doesn't know that the BMC supports
+ * PNOR access commands. This will be a bug in the OPAL
+ * support for this BMC.
+ */
+ prlog(PR_ERR, "PNOR BUG: access requested but BMC doesn't support request\n");
+ break;
+ }
+
/* Ack the request */
- msg = ipmi_mkmsg_simple(IPMI_PNOR_ACCESS_STATUS, &granted, 1);
+ msg = ipmi_mkmsg_simple(bmc_platform->ipmi_oem_pnor_access_status, &granted, 1);
ipmi_queue_msg(msg);
break;
case RELEASE_PNOR:
@@ -120,10 +120,6 @@
#define IPMI_GET_BT_CAPS IPMI_CODE(IPMI_NETFN_APP, 0x36)
#define IPMI_SET_SENSOR_READING IPMI_CODE(IPMI_NETFN_SE, 0x30)
-/* AMI OEM comamnds. AMI uses NETFN 0x3a and 0x32 */
-#define IPMI_PARTIAL_ADD_ESEL IPMI_CODE(0x32, 0xf0)
-#define IPMI_PNOR_ACCESS_STATUS IPMI_CODE(0x3a, 0x07)
-
/*
* IPMI response codes.
*/
@@ -31,6 +31,22 @@ enum resource_id {
#define RESOURCE_SUBID_NONE 0
#define RESOURCE_SUBID_SUPPORTED 1
+enum ipmi_oem_cmds {
+ IPMI_OEM_PARTIAL_ADD_ESEL,
+ IPMI_OEM_PNOR_ACCESS_STATUS
+};
+
+struct bmc_platform {
+ const char *name;
+
+ /*
+ * Map IPMI_OEM_X to vendor commands for this BMC
+ * 0 = unimplimented
+ */
+ uint32_t ipmi_oem_partial_add_esel;
+ uint32_t ipmi_oem_pnor_access_status;
+};
+
/*
* Each platform can provide a set of hooks
* that can affect the generic code
@@ -39,6 +55,13 @@ struct platform {
const char *name;
/*
+ * If BMC is constant, bmc platform specified here.
+ * Platforms can also call set_bmc_platform() if BMC platform is
+ * not a constant.
+ */
+ const struct bmc_platform *bmc;
+
+ /*
* Probe platform, return true on a match, called before
* any allocation has been performed outside of the heap
* so the platform can perform additional memory reservations
@@ -174,6 +197,7 @@ extern struct platform __platforms_start;
extern struct platform __platforms_end;
extern struct platform platform;
+extern const struct bmc_platform *bmc_platform;
extern bool manufacturing_mode;
@@ -189,4 +213,6 @@ extern int resource_loaded(enum resource_id id, uint32_t idx);
extern int wait_for_resource_loaded(enum resource_id id, uint32_t idx);
+extern void set_bmc_platform(const struct bmc_platform *bmc);
+
#endif /* __PLATFORM_H */
@@ -41,6 +41,8 @@ struct slot_table_entry {
const struct slot_table_entry *children;
};
+extern const struct bmc_platform astbmc_ami;
+
extern void astbmc_early_init(void);
extern int64_t astbmc_ipmi_reboot(void);
extern int64_t astbmc_ipmi_power_down(uint64_t request);
@@ -357,3 +357,9 @@ void astbmc_early_init(void)
prd_init();
}
+
+const struct bmc_platform astbmc_ami = {
+ .name = "AMI",
+ .ipmi_oem_partial_add_esel = IPMI_CODE(0x32, 0xf0),
+ .ipmi_oem_pnor_access_status = IPMI_CODE(0x3a, 0x07),
+};
@@ -146,6 +146,7 @@ static bool firestone_probe(void)
DECLARE_PLATFORM(firestone) = {
.name = "Firestone",
+ .bmc = &astbmc_ami,
.probe = firestone_probe,
.init = astbmc_init,
.pci_get_slot_info = slot_table_get_slot_info,
@@ -293,6 +293,7 @@ static bool garrison_probe(void)
DECLARE_PLATFORM(garrison) = {
.name = "Garrison",
+ .bmc = &astbmc_ami,
.probe = garrison_probe,
.init = astbmc_init,
.pci_get_slot_info = slot_table_get_slot_info,
@@ -141,6 +141,7 @@ static bool habanero_probe(void)
DECLARE_PLATFORM(habanero) = {
.name = "Habanero",
+ .bmc = &astbmc_ami,
.probe = habanero_probe,
.init = astbmc_init,
.pci_get_slot_info = slot_table_get_slot_info,
@@ -46,6 +46,7 @@ static bool palmetto_probe(void)
DECLARE_PLATFORM(palmetto) = {
.name = "Palmetto",
.probe = palmetto_probe,
+ .bmc = &astbmc_ami,
.init = astbmc_init,
.external_irq = astbmc_ext_irq_serirq_cpld,
.cec_power_down = astbmc_ipmi_power_down,
An out of tree platform (p8dtu) uses a different IPMI OEM command for IPMI_PARTIAL_ADD_ESEL. This exposed some assumptions about the BMC implementation in our core code. Now, with platform.bmc, each platform can dictate (or detect) the BMC that is present. We allow it to be set at runtime rather than purely statically in struct platform as it's possible to have differing BMC implementations on the one machine (e.g. AMI BMC or OpenBMC). Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com> --- Changes in V2: - just have the numbers in bmc_platform - have generic BMC platform, so bmc_platform always exists --- core/platform.c | 16 ++++++++++++++++ hw/ipmi/ipmi-sel.c | 21 +++++++++++++++++++-- include/ipmi.h | 4 ---- include/platform.h | 26 ++++++++++++++++++++++++++ platforms/astbmc/astbmc.h | 2 ++ platforms/astbmc/common.c | 6 ++++++ platforms/astbmc/firestone.c | 1 + platforms/astbmc/garrison.c | 1 + platforms/astbmc/habanero.c | 1 + platforms/astbmc/palmetto.c | 1 + 10 files changed, 73 insertions(+), 6 deletions(-)