summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--discover/ipmi.h2
-rw-r--r--discover/platform-powerpc.c30
-rw-r--r--lib/pb-protocol/pb-protocol.c18
-rw-r--r--lib/types/types.h1
-rw-r--r--ui/ncurses/nc-sysinfo.c8
5 files changed, 56 insertions, 3 deletions
diff --git a/discover/ipmi.h b/discover/ipmi.h
index 3b11683..eb2a183 100644
--- a/discover/ipmi.h
+++ b/discover/ipmi.h
@@ -9,12 +9,14 @@
enum ipmi_netfn {
IPMI_NETFN_CHASSIS = 0x0,
IPMI_NETFN_SE = 0x04,
+ IPMI_NETFN_TRANSPORT = 0x0c,
};
enum ipmi_cmd {
IPMI_CMD_CHASSIS_SET_SYSTEM_BOOT_OPTIONS = 0x08,
IPMI_CMD_CHASSIS_GET_SYSTEM_BOOT_OPTIONS = 0x09,
IPMI_CMD_SENSOR_SET = 0x30,
+ IPMI_CMD_TRANSPORT_GET_LAN_PARAMS = 0x02,
};
enum ipmi_sensor_ids {
diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c
index 23e63c1..2807934 100644
--- a/discover/platform-powerpc.c
+++ b/discover/platform-powerpc.c
@@ -989,6 +989,31 @@ static int set_ipmi_os_boot_sensor(struct platform_powerpc *platform)
return 0;
}
+static void get_ipmi_bmc_mac(struct platform *p, uint8_t *buf)
+{
+ struct platform_powerpc *platform = p->platform_data;
+ uint16_t resp_len = 8;
+ uint8_t resp[8];
+ uint8_t req[] = { 0x1, 0x5, 0x0, 0x0 };
+ int i, rc;
+
+ rc = ipmi_transaction(platform->ipmi, IPMI_NETFN_TRANSPORT,
+ IPMI_CMD_TRANSPORT_GET_LAN_PARAMS,
+ req, sizeof(req),
+ resp, &resp_len,
+ ipmi_timeout);
+
+ pb_debug("BMC MAC resp [%d][%d]:\n", rc, resp_len);
+
+ if (rc == 0 && resp_len > 0) {
+ for (i = 2; i < resp_len; i++) {
+ pb_debug(" %x", resp[i]);
+ buf[i - 2] = resp[i];
+ }
+ pb_debug("\n");
+ }
+}
+
static int load_config(struct platform *p, struct config *config)
{
struct platform_powerpc *platform = to_platform_powerpc(p);
@@ -1057,6 +1082,10 @@ static int get_sysinfo(struct platform *p, struct system_info *sysinfo)
sysinfo->identifier = talloc_steal(sysinfo, buf);
talloc_free(filename);
+ sysinfo->bmc_mac = talloc_zero_size(sysinfo, HWADDR_SIZE);
+ if (platform->ipmi)
+ get_ipmi_bmc_mac(p, sysinfo->bmc_mac);
+
return 0;
}
@@ -1085,7 +1114,6 @@ static bool probe(struct platform *p, void *ctx)
platform->get_ipmi_bootdev = get_ipmi_bootdev_ipmi;
platform->clear_ipmi_bootdev = clear_ipmi_bootdev_ipmi;
platform->set_os_boot_sensor = set_ipmi_os_boot_sensor;
-
} else if (!stat(sysparams_dir, &statbuf)) {
pb_debug("platform: using sysparams for IPMI paramters\n");
platform->get_ipmi_bootdev = get_ipmi_bootdev_sysparams;
diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c
index 7d45f51..ab5ea8a 100644
--- a/lib/pb-protocol/pb-protocol.c
+++ b/lib/pb-protocol/pb-protocol.c
@@ -239,6 +239,9 @@ int pb_protocol_system_info_len(const struct system_info *sysinfo)
4 + optional_strlen(bd_info->mountpoint);
}
+ /* BMC MAC */
+ len += HWADDR_SIZE;
+
return len;
}
@@ -420,6 +423,9 @@ int pb_protocol_serialise_system_info(const struct system_info *sysinfo,
pos += pb_protocol_serialise_string(pos, bd_info->mountpoint);
}
+ memcpy(pos, sysinfo->bmc_mac, HWADDR_SIZE);
+ pos += HWADDR_SIZE;
+
assert(pos <= buf + buf_len);
(void)buf_len;
@@ -850,8 +856,18 @@ int pb_protocol_deserialise_system_info(struct system_info *sysinfo,
sysinfo->blockdevs[i] = bd_info;
}
- rc = 0;
+ for (i = 0; i < HWADDR_SIZE; i++) {
+ if (pos[i] != 0) {
+ sysinfo->bmc_mac = talloc_memdup(sysinfo, pos, HWADDR_SIZE);
+ break;
+ }
+ }
+
+ pos += HWADDR_SIZE;
+ len -= HWADDR_SIZE;
+
+ rc = 0;
out:
return rc;
}
diff --git a/lib/types/types.h b/lib/types/types.h
index 6a2c258..702b6f5 100644
--- a/lib/types/types.h
+++ b/lib/types/types.h
@@ -93,6 +93,7 @@ struct blockdev_info {
struct system_info {
char *type;
char *identifier;
+ uint8_t *bmc_mac;
struct interface_info **interfaces;
unsigned int n_interfaces;
struct blockdev_info **blockdevs;
diff --git a/ui/ncurses/nc-sysinfo.c b/ui/ncurses/nc-sysinfo.c
index ac8ece7..5ced871 100644
--- a/ui/ncurses/nc-sysinfo.c
+++ b/ui/ncurses/nc-sysinfo.c
@@ -51,6 +51,7 @@ static void if_info_mac_str(struct interface_info *info,
static void sysinfo_screen_populate(struct sysinfo_screen *screen,
const struct system_info *sysinfo)
{
+ char macbuf[32];
unsigned int i;
text_screen_clear(&screen->text_scr);
@@ -78,6 +79,12 @@ static void sysinfo_screen_populate(struct sysinfo_screen *screen,
line(NULL);
}
+ if (sysinfo->bmc_mac) {
+ mac_str(sysinfo->bmc_mac, HWADDR_SIZE, macbuf, sizeof(macbuf));
+ line(_("Management (BMC) interface"));
+ line(_(" MAC: %s"), macbuf);
+ }
+
if (sysinfo->n_interfaces) {
line(NULL);
line(_("Network interfaces"));
@@ -85,7 +92,6 @@ static void sysinfo_screen_populate(struct sysinfo_screen *screen,
for (i = 0; i < sysinfo->n_interfaces; i++) {
struct interface_info *info = sysinfo->interfaces[i];
- char macbuf[32];
if_info_mac_str(info, macbuf, sizeof(macbuf));
OpenPOWER on IntegriCloud