diff options
author | Alexander Filippov <a.filippov@yadro.com> | 2018-11-28 11:32:04 +0300 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2019-04-22 23:17:23 +0300 |
commit | 126f6677965ebb271f28aecc6e2e159889d461f5 (patch) | |
tree | b6da28983205b32fa92ac03ddb58656c5dc3c5b3 | |
parent | c8ce245817ed66a65bd459ca97767550a367a956 (diff) | |
download | openbmc-126f6677965ebb271f28aecc6e2e159889d461f5.tar.xz |
meta-openpower: Sync BMC MAC address to ethernet
On first BMC boot copy the MAC address set at manufacturing time into
the network DBus object.
On some OpenPOWER systems the MAC address is set by the manufacturer in
an EEPROM somewhere. If openpower-vpd-parser has forwarded the
information in that eeprom onto phosphor-inventory manager, this script
can further forward that on to the network stack of OpenBMC.
This is only done on genesis boot (or after a factory reset) so that a
manually configured address from the end user is not overridden.
(From meta-openpower rev: 6f08b5190e0e7d83d1ddc08771dd31be7d0561ca)
Change-Id: Ia15ce9217ad024a827e94c1dfd986ce19af7124d
Signed-off-by: Alexander Filippov <a.filippov@yadro.com>
Signed-off-by: Nagaraju Goruganti <ngorugan@in.ibm.com>
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
3 files changed, 91 insertions, 0 deletions
diff --git a/meta-openpower/recipes-phosphor/network/first-boot-set-mac/first-boot-set-mac.sh b/meta-openpower/recipes-phosphor/network/first-boot-set-mac/first-boot-set-mac.sh new file mode 100755 index 000000000..9f751a6c3 --- /dev/null +++ b/meta-openpower/recipes-phosphor/network/first-boot-set-mac/first-boot-set-mac.sh @@ -0,0 +1,57 @@ +#!/bin/sh -eu + +show_error() { + logger -p user.error -t bmc-first-init $@ +} + +sync_mac() { + + MAPPER_IFACE='xyz.openbmc_project.ObjectMapper' + MAPPER_PATH='/xyz/openbmc_project/object_mapper' + INVENTORY_PATH='/xyz/openbmc_project/inventory' + NETWORK_ITEM_IFACE='xyz.openbmc_project.Inventory.Item.NetworkInterface' + + NETWORK_ITEM_PATH=$(busctl --no-pager --verbose call \ + ${MAPPER_IFACE} \ + ${MAPPER_PATH} \ + ${MAPPER_IFACE} \ + GetSubTree sias \ + ${INVENTORY_PATH} 0 1 ${NETWORK_ITEM_IFACE} \ + 2>/dev/null | grep ${INVENTORY_PATH} || true) + + # ' STRING "/xyz/openbmc_project/inventory/system/chassis/ethernet";' + NETWORK_ITEM_PATH=${NETWORK_ITEM_PATH#*\"} + NETWORK_ITEM_PATH=${NETWORK_ITEM_PATH%\"*} + + NETWORK_ITEM_SERVICE=$(mapper get-service \ + ${NETWORK_ITEM_PATH} 2>/dev/null || true) + + if [[ -z "${NETWORK_ITEM_SERVICE}" ]]; then + show_error 'No Ethernet interface found in the Inventory. Is VPD EEPROM empty?' + return + fi + + MAC_ADDR=$(busctl get-property ${NETWORK_ITEM_SERVICE} \ + ${NETWORK_ITEM_PATH} \ + ${NETWORK_ITEM_IFACE} MACAddress) + + # 's "54:52:01:02:03:04"' + MAC_ADDR=${MAC_ADDR#*\"} + MAC_ADDR=${MAC_ADDR%\"*} + + if [[ -n "${MAC_ADDR}" ]]; then + busctl set-property xyz.openbmc_project.Network \ + /xyz/openbmc_project/network/$1 \ + xyz.openbmc_project.Network.MACAddress \ + MACAddress s ${MAC_ADDR} + fi +} + +if [ $# -eq 0 ] + then echo 'No Ethernet interface name is given' + exit 1 +fi + +sync_mac $1 + +systemctl disable first-boot-set-mac@${1}.service diff --git a/meta-openpower/recipes-phosphor/network/first-boot-set-mac/first-boot-set-mac@.service b/meta-openpower/recipes-phosphor/network/first-boot-set-mac/first-boot-set-mac@.service new file mode 100644 index 000000000..a7c913eb6 --- /dev/null +++ b/meta-openpower/recipes-phosphor/network/first-boot-set-mac/first-boot-set-mac@.service @@ -0,0 +1,14 @@ +[Unit] +Description=Init BMC MAC address for NIC %I +Wants=mapper-wait@-xyz-openbmc_project-inventory.service +After=mapper-wait@-xyz-openbmc_project-inventory.service +Wants=mapper-wait@-xyz-openbmc_project-network-%i.service +After=mapper-wait@-xyz-openbmc_project-network-%i.service + +[Service] +ExecStart=/usr/bin/first-boot-set-mac.sh %i +Type=oneshot +RemainAfterExit=Yes + +[Install] +WantedBy=multi-user.target diff --git a/meta-openpower/recipes-phosphor/network/first-boot-set-mac_1.0.bb b/meta-openpower/recipes-phosphor/network/first-boot-set-mac_1.0.bb new file mode 100644 index 000000000..0fd040d41 --- /dev/null +++ b/meta-openpower/recipes-phosphor/network/first-boot-set-mac_1.0.bb @@ -0,0 +1,20 @@ +SUMMARY = "Init BMC MAC address" +DESCRIPTION = "Setup BMC MAC address read from VPD" +PR = "r1" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${OPENPOWERBASE}/COPYING.apache-2.0;md5=34400b68072d710fecd0a2940a0d1658" + +inherit allarch systemd + +RDEPENDS_${PN} = "${VIRTUAL-RUNTIME_base-utils}" + +SYSTEMD_SERVICE_${PN} = "first-boot-set-mac@.service" + +SRC_URI = "file://${PN}.sh file://${PN}@.service" + +S = "${WORKDIR}" +do_install() { + install -d ${D}${bindir} ${D}${systemd_system_unitdir} + install ${PN}.sh ${D}${bindir}/ + install -m 644 ${PN}@.service ${D}${systemd_system_unitdir}/ +} |