summaryrefslogtreecommitdiffstats
path: root/discover
diff options
context:
space:
mode:
authorSam Mendoza-Jonas <sam@mendozajonas.com>2016-01-29 15:16:34 +1100
committerSam Mendoza-Jonas <sam@mendozajonas.com>2016-02-10 16:21:08 +1100
commitd531395a3ff60730238854b127925978f6eab289 (patch)
treee2dcc3ec892e43c0a3a2f5f03020a85f7fda7a31 /discover
parentd974c3c39237c8e94bb3a51d3511d18dea01043e (diff)
downloadtalos-petitboot-d531395a3ff60730238854b127925978f6eab289.tar.gz
talos-petitboot-d531395a3ff60730238854b127925978f6eab289.zip
Retrieve BMC version info via IPMI
On BMC machines the "Get Device ID" and "Get BMC Golden Side Version" IPMI commands are available. If possible retrieve some interesting version numbers and display them in the System Information screen. Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'discover')
-rw-r--r--discover/ipmi.h4
-rw-r--r--discover/platform-powerpc.c91
2 files changed, 95 insertions, 0 deletions
diff --git a/discover/ipmi.h b/discover/ipmi.h
index eb2a183..611cd49 100644
--- a/discover/ipmi.h
+++ b/discover/ipmi.h
@@ -9,7 +9,9 @@
enum ipmi_netfn {
IPMI_NETFN_CHASSIS = 0x0,
IPMI_NETFN_SE = 0x04,
+ IPMI_NETFN_APP = 0x06,
IPMI_NETFN_TRANSPORT = 0x0c,
+ IPMI_NETFN_AMI = 0x3a,
};
enum ipmi_cmd {
@@ -17,6 +19,8 @@ enum ipmi_cmd {
IPMI_CMD_CHASSIS_GET_SYSTEM_BOOT_OPTIONS = 0x09,
IPMI_CMD_SENSOR_SET = 0x30,
IPMI_CMD_TRANSPORT_GET_LAN_PARAMS = 0x02,
+ IPMI_CMD_APP_GET_DEVICE_ID = 0x01,
+ IPMI_CMD_APP_GET_DEVICE_ID_GOLDEN = 0x1a,
};
enum ipmi_sensor_ids {
diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c
index 46f81d2..78b76d3 100644
--- a/discover/platform-powerpc.c
+++ b/discover/platform-powerpc.c
@@ -1023,6 +1023,94 @@ static void get_ipmi_bmc_mac(struct platform *p, uint8_t *buf)
}
pb_debug("\n");
}
+
+}
+
+/*
+ * Retrieve info from the "Get Device ID" IPMI commands.
+ * See Chapter 20.1 in the IPMIv2 specification.
+ */
+static void get_ipmi_bmc_versions(struct platform *p, struct system_info *info)
+{
+ struct platform_powerpc *platform = p->platform_data;
+ uint16_t resp_len = 16;
+ uint8_t resp[16], bcd;
+ uint32_t aux_version;
+ int i, rc;
+
+ /* Retrieve info from current side */
+ rc = ipmi_transaction(platform->ipmi, IPMI_NETFN_APP,
+ IPMI_CMD_APP_GET_DEVICE_ID,
+ NULL, 0,
+ resp, &resp_len,
+ ipmi_timeout);
+
+ pb_debug("BMC version resp [%d][%d]:\n", rc, resp_len);
+ if (resp_len > 0) {
+ for (i = 0; i < resp_len; i++) {
+ pb_debug(" %x", resp[i]);
+ }
+ pb_debug("\n");
+ }
+
+ if (rc == 0 && resp_len == 16) {
+ info->bmc_current = talloc_array(info, char *, 4);
+ info->n_bmc_current = 4;
+
+ info->bmc_current[0] = talloc_asprintf(info, "Device ID: 0x%x",
+ resp[1]);
+ info->bmc_current[1] = talloc_asprintf(info, "Device Rev: 0x%x",
+ resp[2]);
+ bcd = resp[4] & 0x0f;
+ bcd += 10 * (resp[4] >> 4);
+ memcpy(&aux_version, &resp[12], sizeof(aux_version));
+ info->bmc_current[2] = talloc_asprintf(info,
+ "Firmware version: %u.%u.%u",
+ resp[3], bcd, aux_version);
+ bcd = resp[5] & 0x0f;
+ bcd += 10 * (resp[5] >> 4);
+ info->bmc_current[3] = talloc_asprintf(info, "IPMI version: %u",
+ bcd);
+ } else
+ pb_log("Failed to retrieve Device ID from IPMI\n");
+
+ /* Retrieve info from golden side */
+ memset(resp, 0, sizeof(resp));
+ resp_len = 16;
+ rc = ipmi_transaction(platform->ipmi, IPMI_NETFN_AMI,
+ IPMI_CMD_APP_GET_DEVICE_ID_GOLDEN,
+ NULL, 0,
+ resp, &resp_len,
+ ipmi_timeout);
+
+ pb_debug("BMC golden resp [%d][%d]:\n", rc, resp_len);
+ if (resp_len > 0) {
+ for (i = 0; i < resp_len; i++) {
+ pb_debug(" %x", resp[i]);
+ }
+ pb_debug("\n");
+ }
+
+ if (rc == 0 && resp_len == 16) {
+ info->bmc_golden = talloc_array(info, char *, 4);
+ info->n_bmc_golden = 4;
+
+ info->bmc_golden[0] = talloc_asprintf(info, "Device ID: 0x%x",
+ resp[1]);
+ info->bmc_golden[1] = talloc_asprintf(info, "Device Rev: 0x%x",
+ resp[2]);
+ bcd = resp[4] & 0x0f;
+ bcd += 10 * (resp[4] >> 4);
+ memcpy(&aux_version, &resp[12], sizeof(aux_version));
+ info->bmc_golden[2] = talloc_asprintf(info,
+ "Firmware version: %u.%u.%u",
+ resp[3], bcd, aux_version);
+ bcd = resp[5] & 0x0f;
+ bcd += 10 * (resp[5] >> 4);
+ info->bmc_golden[3] = talloc_asprintf(info, "IPMI version: %u",
+ bcd);
+ } else
+ pb_log("Failed to retrieve Golden Device ID from IPMI\n");
}
static int load_config(struct platform *p, struct config *config)
@@ -1097,6 +1185,9 @@ static int get_sysinfo(struct platform *p, struct system_info *sysinfo)
if (platform->ipmi)
get_ipmi_bmc_mac(p, sysinfo->bmc_mac);
+ if (platform->ipmi)
+ get_ipmi_bmc_versions(p, sysinfo);
+
if (platform->get_platform_versions)
platform->get_platform_versions(sysinfo);
OpenPOWER on IntegriCloud