From a3a8ca972abf4f66788b14cf65bcbc62d6f6af0c Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Tue, 12 Oct 2021 23:18:52 -0700 Subject: meta-google: ipmi-fru-sh: Add method for initializing eeproms This makes it possible to create new specifications besides the default mapping of OF name to eeprom path. Right now this provides backward compatability with anything that uses of_name_to_eeprom and only provides a new explicit specifier for that specification. Change-Id: If02d9cb392a48e0698b10644d7ade3220bde3eb5 Signed-off-by: William A. Kennington III --- meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh | 30 ++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'meta-google/recipes-google/ipmi') diff --git a/meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh b/meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh index 335e0b21c..3ae0f0864 100644 --- a/meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh +++ b/meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh @@ -42,6 +42,32 @@ of_name_to_eeprom() { echo "$eeproms" } +declare -A IPMI_FRU_EEPROM_FILE=() + +ipmi_fru_alloc() { + local name="$1" + local -n ret="$2" + + # Pick the first free index to return as the allocated entry + for (( ret = 0; ret < "${#IPMI_FRU_EEPROM_FILE[@]}"; ++ret )); do + [ -n "${IPMI_FRU_EEPROM_FILE[@]+1}" ] || break + done + + if [[ "$name" =~ ^of-name:(.*)$ || "$name" =~ ^([^:]*)$ ]]; then + local ofn="${BASH_REMATCH[1]}" + local file + file="$(of_name_to_eeprom "$ofn")" || return + IPMI_FRU_EEPROM_FILE["$ret"]="$file" + else + echo "Invalid IPMI FRU eeprom specification: $name" >&2 + return 1 + fi +} + +ipmi_fru_free() { + unset 'IPMI_FRU_EEPROM_FILE[$1]' +} + checksum() { local -n checksum_arr="$1" local checksum=0 @@ -61,7 +87,7 @@ fix_checksum() { } read_bytes() { - local file="$1" + local file="${IPMI_FRU_EEPROM_FILE["$1"]-$1}" local offset="$2" local size="$3" @@ -71,7 +97,7 @@ read_bytes() { } write_bytes() { - local file="$1" + local file="${IPMI_FRU_EEPROM_FILE["$1"]-$1}" local offset="$2" local -n bytes_arr="$3" -- cgit v1.2.3 From a810614ad3f15e006f40f5214f9e85f93ccee37b Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Tue, 12 Oct 2021 23:25:05 -0700 Subject: meta-google: ipmi-fru-sh: Add lookup for FruDevice names This makes it possible to specify a FRU lookup by a dynamically discovered FRUs from entity manager. Change-Id: Icf83aa3eff1cbc08a8fa3f99754e5c10e3e583fc Signed-off-by: William A. Kennington III --- meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'meta-google/recipes-google/ipmi') diff --git a/meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh b/meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh index 3ae0f0864..940be7fb0 100644 --- a/meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh +++ b/meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh @@ -44,6 +44,33 @@ of_name_to_eeprom() { declare -A IPMI_FRU_EEPROM_FILE=() +ipmi_fru_device_to_file() { + local fdn="$1" + + local json + json="$(busctl -j call xyz.openbmc_project.FruDevice \ + /xyz/openbmc_project/FruDevice/"$fdn" org.freedesktop.DBus.Properties \ + GetAll s xyz.openbmc_project.FruDevice)" || return 80 + + local jqq='.data[0] | (.BUS.data | tostring) + " " + (.ADDRESS.data | tostring)' + local busaddr + busaddr="$(echo "$json" | jq -r "$jqq")" || return + + # FRU 0 is hardcoded and FruDevice does not report the correct bus for it + # Hardcode a workaround for this specifically known bus + if [ "$busaddr" = '0 0' ]; then + echo "/etc/fru/baseboard.fru.bin" + else + local dev="$(printf '%d-%04x' $busaddr)" + local efile="/sys/bus/i2c/devices/$dev/eeprom" + # The at24 eeprom driver is not guaranteed to be bound + if [ ! -e "$efile" ]; then + echo "$dev" >/sys/bus/i2c/drivers/at24/bind || return + fi + echo "$efile" + fi +} + ipmi_fru_alloc() { local name="$1" local -n ret="$2" @@ -58,6 +85,19 @@ ipmi_fru_alloc() { local file file="$(of_name_to_eeprom "$ofn")" || return IPMI_FRU_EEPROM_FILE["$ret"]="$file" + elif [[ "$name" =~ ^frudev-name:(.*)$ ]]; then + local fdn="${BASH_REMATCH[1]}" + local start=$SECONDS + local file + while (( SECONDS - start < 60 )); do + local rc=0 + file="$(ipmi_fru_device_to_file "$fdn")" || rc=$? + (( rc == 0 )) && break + # Immediately return any errors, 80 is special to signify retry + (( rc != 80 )) && return $rc + sleep 1 + done + IPMI_FRU_EEPROM_FILE["$ret"]="$file" else echo "Invalid IPMI FRU eeprom specification: $name" >&2 return 1 -- cgit v1.2.3 From c71203f0567feac56a56d116f7a952cf4256eb45 Mon Sep 17 00:00:00 2001 From: Andrew Geissler Date: Thu, 14 Oct 2021 18:50:18 +0000 Subject: google-ipmi-sys: srcrev bump b69209b498..b4e3704c17 Willy Tu (5): build: Update to c++20 and meson >= 0.57.0 Add Google Copyright 2021 test: Replace the C++ MOCK_METHOD macros with the new MOCK_METHOD google-ipmi-sys: Refactor to use new version of OEM IPMI Handler google-ipmi-sys: Convert input to use std::span Change-Id: I4a4d3416bcc48ca1e4c902969d669a1a4aca6d2f Signed-off-by: Andrew Geissler --- meta-google/recipes-google/ipmi/google-ipmi-sys_git.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'meta-google/recipes-google/ipmi') diff --git a/meta-google/recipes-google/ipmi/google-ipmi-sys_git.bb b/meta-google/recipes-google/ipmi/google-ipmi-sys_git.bb index 1310f7e00..727d57f59 100644 --- a/meta-google/recipes-google/ipmi/google-ipmi-sys_git.bb +++ b/meta-google/recipes-google/ipmi/google-ipmi-sys_git.bb @@ -19,7 +19,7 @@ DEPENDS += " \ S = "${WORKDIR}/git" SRC_URI = "git://github.com/openbmc/google-ipmi-sys" -SRCREV = "b69209b498bf9b1c009c528e40280d13e68f8dbd" +SRCREV = "b4e3704c17be6a081e3c713b8173edc973bf87d7" FILES:${PN} += "${libdir}/ipmid-providers" -- cgit v1.2.3 From a7532a6b3629e7b8e1690769f70d4d9dcc3f7056 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Fri, 15 Oct 2021 15:55:39 -0700 Subject: meta-google: ipmi-fru: Direct read support We can't dynamically bind to the at24 driver if the eeprom is not in the kernel's device tree. Since this support was intended to be used for dynamic FRUs, it is broken when the kernel has the entries removed. Change-Id: I99c774191c22d67e518fe9435b1446b80efb5600 Signed-off-by: William A. Kennington III --- meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh | 72 ++++++++++++++++------ 1 file changed, 52 insertions(+), 20 deletions(-) (limited to 'meta-google/recipes-google/ipmi') diff --git a/meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh b/meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh index 940be7fb0..d02eeab47 100644 --- a/meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh +++ b/meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh @@ -23,6 +23,20 @@ IPMI_FRU_COMMON_HEADER_MULTI_RECORD_OFFSET_IDX=5 IPMI_FRU_AREA_HEADER_SIZE_IDX=1 IPMI_FRU_CHECKSUM_IDX=-1 +offset_1bw() { + local addr="$1" + local off="$2" + local extra="${3-0}" + echo w$((1+extra))@$addr $(( off & 0xff )) +} + +offset_2bw() { + local addr="$1" + local off="$2" + local extra="${3-0}" + echo w$((2+extra))@$addr $(( (off >> 8) & 0xff )) $(( off & 0xff )) +} + of_name_to_eeproms() { local names if ! names="$(grep -xl "$1" /sys/bus/i2c/devices/*/of_node/name)"; then @@ -42,10 +56,14 @@ of_name_to_eeprom() { echo "$eeproms" } +# Each element is a `filename` declare -A IPMI_FRU_EEPROM_FILE=() +# Each element is a `bus` + `addr` + `offset_bytes_func` +declare -A IPMI_FRU_EEPROM_BUSADDR=() -ipmi_fru_device_to_file() { +ipmi_fru_device_alloc() { local fdn="$1" + local idx="$2" local json json="$(busctl -j call xyz.openbmc_project.FruDevice \ @@ -54,20 +72,21 @@ ipmi_fru_device_to_file() { local jqq='.data[0] | (.BUS.data | tostring) + " " + (.ADDRESS.data | tostring)' local busaddr - busaddr="$(echo "$json" | jq -r "$jqq")" || return + busaddr=($(echo "$json" | jq -r "$jqq")) || return # FRU 0 is hardcoded and FruDevice does not report the correct bus for it # Hardcode a workaround for this specifically known bus - if [ "$busaddr" = '0 0' ]; then - echo "/etc/fru/baseboard.fru.bin" + if (( busaddr[0] == 0 && busaddr[1] == 0 )); then + IPMI_FRU_EEPROM_FILE["$idx"]=/etc/fru/baseboard.fru.bin else - local dev="$(printf '%d-%04x' $busaddr)" - local efile="/sys/bus/i2c/devices/$dev/eeprom" - # The at24 eeprom driver is not guaranteed to be bound - if [ ! -e "$efile" ]; then - echo "$dev" >/sys/bus/i2c/drivers/at24/bind || return + local offset_bw=offset_2bw + local rsp + rsp=$(i2ctransfer -f -y ${busaddr[0]} $(offset_1bw ${busaddr[1]} 0) r1) || return + # FRUs never start with 0xff bytes, so we can figure out addressing mode + if (( rsp != 0xff )); then + offset_bw=offset_1bw fi - echo "$efile" + IPMI_FRU_EEPROM_BUSADDR["$idx"]="${busaddr[*]} $offset_bw" fi } @@ -77,7 +96,8 @@ ipmi_fru_alloc() { # Pick the first free index to return as the allocated entry for (( ret = 0; ret < "${#IPMI_FRU_EEPROM_FILE[@]}"; ++ret )); do - [ -n "${IPMI_FRU_EEPROM_FILE[@]+1}" ] || break + [ -n "${IPMI_FRU_EEPROM_FILE[@]+1}" ] || \ + [ -n "${IPMI_FRU_EEPROM_BUSADDR[@]+1}" ]|| break done if [[ "$name" =~ ^of-name:(.*)$ || "$name" =~ ^([^:]*)$ ]]; then @@ -91,13 +111,12 @@ ipmi_fru_alloc() { local file while (( SECONDS - start < 60 )); do local rc=0 - file="$(ipmi_fru_device_to_file "$fdn")" || rc=$? + ipmi_fru_device_alloc "$fdn" "$ret" || rc=$? (( rc == 0 )) && break # Immediately return any errors, 80 is special to signify retry (( rc != 80 )) && return $rc sleep 1 done - IPMI_FRU_EEPROM_FILE["$ret"]="$file" else echo "Invalid IPMI FRU eeprom specification: $name" >&2 return 1 @@ -106,6 +125,7 @@ ipmi_fru_alloc() { ipmi_fru_free() { unset 'IPMI_FRU_EEPROM_FILE[$1]' + unset 'IPMI_FRU_EEPROM_BUSADDR[$1]' } checksum() { @@ -127,24 +147,36 @@ fix_checksum() { } read_bytes() { + local busaddr=(${IPMI_FRU_EEPROM_BUSADDR["$1"]-}) local file="${IPMI_FRU_EEPROM_FILE["$1"]-$1}" local offset="$2" local size="$3" - echo "Reading $file at $offset for $size" >&2 - dd if="$file" bs=1 count="$size" skip="$offset" 2>/dev/null | \ - hexdump -v -e '1/1 "%d "' + if (( "${#busaddr[@]}" > 0)); then + echo "Reading ${busaddr[*]} at $offset for $size" >&2 + i2ctransfer -f -y ${busaddr[0]} $(${busaddr[2]} ${busaddr[1]} $offset) r$size + else + echo "Reading $file at $offset for $size" >&2 + dd if="$file" bs=1 count="$size" skip="$offset" 2>/dev/null | \ + hexdump -v -e '1/1 "%d "' + fi } write_bytes() { + local busaddr=(${IPMI_FRU_EEPROM_BUSADDR["$1"]-}) local file="${IPMI_FRU_EEPROM_FILE["$1"]-$1}" local offset="$2" local -n bytes_arr="$3" - local hexstr - hexstr="$(printf '\\x%x' "${bytes_arr[@]}")" || return - echo "Writing $file at $offset for ${#bytes_arr[@]}" >&2 - printf "$hexstr" | dd of="$file" bs=1 seek=$offset 2>/dev/null + if (( "${#busaddr[@]}" > 0)); then + echo "Writing ${busaddr[*]} at $offset for ${#bytes_arr[@]}" >&2 + i2ctransfer -f -y ${busaddr[0]} $(${busaddr[2]} ${busaddr[1]} $offset ${#bytes_arr[@]}) ${bytes_arr[@]} + else + local hexstr + hexstr="$(printf '\\x%x' "${bytes_arr[@]}")" || return + echo "Writing $file at $offset for ${#bytes_arr[@]}" >&2 + printf "$hexstr" | dd of="$file" bs=1 seek=$offset 2>/dev/null + fi } read_header() { -- cgit v1.2.3 From 3039e73523b6e72db600e66090115bfc8b3bc913 Mon Sep 17 00:00:00 2001 From: Andrew Geissler Date: Mon, 25 Oct 2021 08:50:15 +0000 Subject: google-ipmi-i2c: srcrev bump b7d431199a..d78cbec9ef Manojkiran Eda (1): Add OWNERS file Change-Id: I6229b878254f752a54faf2054cd27ee362799e3c Signed-off-by: Andrew Geissler --- meta-google/recipes-google/ipmi/google-ipmi-i2c_git.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'meta-google/recipes-google/ipmi') diff --git a/meta-google/recipes-google/ipmi/google-ipmi-i2c_git.bb b/meta-google/recipes-google/ipmi/google-ipmi-i2c_git.bb index 3d5504ea1..c58382ab6 100644 --- a/meta-google/recipes-google/ipmi/google-ipmi-i2c_git.bb +++ b/meta-google/recipes-google/ipmi/google-ipmi-i2c_git.bb @@ -14,7 +14,7 @@ DEPENDS += "phosphor-ipmi-host" S = "${WORKDIR}/git" SRC_URI = "git://github.com/openbmc/google-ipmi-i2c" -SRCREV = "b7d431199ac519e7c3cd5f3341d67f2ff0e09e10" +SRCREV = "d78cbec9efb29526d913cc02d61e0b9bf5cff5ae" FILES:${PN}:append = " ${libdir}/ipmid-providers/lib*${SOLIBS}" FILES:${PN}:append = " ${libdir}/host-ipmid/lib*${SOLIBS}" -- cgit v1.2.3 From 367ca4f62f11ffa62e0caec9c2cf7e095ee21048 Mon Sep 17 00:00:00 2001 From: Andrew Geissler Date: Mon, 25 Oct 2021 08:50:25 +0000 Subject: google-ipmi-sys: srcrev bump b4e3704c17..f647e99165 Manojkiran Eda (1): Add OWNERS file Change-Id: I3c5adab1a8a560e174a2823a37d907f92a90df73 Signed-off-by: Andrew Geissler --- meta-google/recipes-google/ipmi/google-ipmi-sys_git.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'meta-google/recipes-google/ipmi') diff --git a/meta-google/recipes-google/ipmi/google-ipmi-sys_git.bb b/meta-google/recipes-google/ipmi/google-ipmi-sys_git.bb index 727d57f59..e84884028 100644 --- a/meta-google/recipes-google/ipmi/google-ipmi-sys_git.bb +++ b/meta-google/recipes-google/ipmi/google-ipmi-sys_git.bb @@ -19,7 +19,7 @@ DEPENDS += " \ S = "${WORKDIR}/git" SRC_URI = "git://github.com/openbmc/google-ipmi-sys" -SRCREV = "b4e3704c17be6a081e3c713b8173edc973bf87d7" +SRCREV = "f647e99165065feabb35aa744059cf6a2af46f1e" FILES:${PN} += "${libdir}/ipmid-providers" -- cgit v1.2.3 From 297f9830330e159653953c439c5a09750ebb1b2d Mon Sep 17 00:00:00 2001 From: Andrew Geissler Date: Thu, 11 Nov 2021 17:30:13 +0000 Subject: google-ipmi-sys: srcrev bump f647e99165..40fe522255 Willy Tu (1): copyright: Add Google Copyright to test helper.cpp Change-Id: I9465595985668960370f746830a21e3fef246ac8 Signed-off-by: Andrew Geissler --- meta-google/recipes-google/ipmi/google-ipmi-sys_git.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'meta-google/recipes-google/ipmi') diff --git a/meta-google/recipes-google/ipmi/google-ipmi-sys_git.bb b/meta-google/recipes-google/ipmi/google-ipmi-sys_git.bb index e84884028..d136eb245 100644 --- a/meta-google/recipes-google/ipmi/google-ipmi-sys_git.bb +++ b/meta-google/recipes-google/ipmi/google-ipmi-sys_git.bb @@ -19,7 +19,7 @@ DEPENDS += " \ S = "${WORKDIR}/git" SRC_URI = "git://github.com/openbmc/google-ipmi-sys" -SRCREV = "f647e99165065feabb35aa744059cf6a2af46f1e" +SRCREV = "40fe52225515f6ec82858795638add0b4c8e94af" FILES:${PN} += "${libdir}/ipmid-providers" -- cgit v1.2.3