mctp: mctp-i2c.service: remove existing MCTP EID
Some device may lost its MCTP EID and become unreachable when host
power is off. As a short term solution, we need to restart mctp-i2c
service to setup MCTP endpoint again after host power is on.
Here we need to remove the existing MCTP EID as they may become
outdated.
Tested:
b/353851039#comment61
Fusion-Link:
Don't need as this service isn't used in presubmit platforms.
Google-Bug-Id: 383145677
Change-Id: I9cab98de0f4f0e62d5e7371f593cca9828773639
Signed-off-by: Jinliang Wang <jinliangw@google.com>
diff --git a/recipes-connectivity/mctp/mctp/init-mctp-i2c-endpoint.sh b/recipes-connectivity/mctp/mctp/init-mctp-i2c-endpoint.sh
index a0ccbec..989574d 100644
--- a/recipes-connectivity/mctp/mctp/init-mctp-i2c-endpoint.sh
+++ b/recipes-connectivity/mctp/mctp/init-mctp-i2c-endpoint.sh
@@ -8,6 +8,20 @@
mkdir -p "/var/run/mctp/"
conf_file="/var/run/mctp/mctp-i2c-binding.conf"
+
+existing_eids=$(cat /run/mctp/mctp-i2c-binding.conf | awk '{print $(NF-1),$NF}' | grep -v mctp)
+echo "$existing_eids" | while read line ; do
+ net=$(echo "$line" | awk '{print $1}')
+ eid=$(echo "$line" | awk '{print $2}')
+ if [ -z "$net" ] || [ -z "$eid" ]; then
+ break
+ fi
+ echo "Remove net: $net, eid: $eid"
+ busctl call xyz.openbmc_project.MCTP \
+ /xyz/openbmc_project/mctp/$net/$eid \
+ au.com.CodeConstruct.MCTP.Endpoint Remove
+done
+
echo "# object_path i2c_bus address mctp_net mctp_eid" >$conf_file
EID_BASE=60