meta-facebook: harma: Add MCTP PLDM support

Add MCTP PLDM support for PSOC sensor readings and
firmware update.

Testing:

root@bmc:~# busctl tree xyz.openbmc_project.MCTP
└─ /xyz
  └─ /xyz/openbmc_project
    └─ /xyz/openbmc_project/mctp
      └─ /xyz/openbmc_project/mctp/1
        ├─ /xyz/openbmc_project/mctp/1/10
        └─ /xyz/openbmc_project/mctp/1/8

root@bmc:~# pldmtool raw -d 0x80 0x05 0x02 -m 0x0a
pldmtool: Tx: 80 05 02
pldmtool: Rx: 00 05 02 00 00 00 00 00 07 00 01 0a
00 00 32 30 32 33 2e 34 38 2e 30 31 ff ff 00 00 00
00 00 00 00 01 0c 00 00 00 00 00 00 00 00 00 00 00
00 01 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00
4d 50 53 20 33 64 65 37 34 39 62 61 ff ff 01 00 00
00 00 00 00 01 0c 00 00 00 00 00 00 00 00 00 00 00
00 01 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00
4d 50 53 20 33 64 65 37 34 39 62 61 ff ff 03 00 00
00 00 00 00 01 07 00 00 00 00 00 00 00 00 00 00 00
00 01 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00
45 52 52 4f 52 3a 38 ff ff 04 00 00 00 00 00 00 01
07 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00
00 00 00 00 00 00 10 00 00 00 00 00 45 52 52 4f 52
3a 38 ff ff 05 00 00 00 00 00 00 01 07 00 00 00 00
00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00
00 10 00 00 00 00 00 45 52 52 4f 52 3a 38 ff ff 06
00 00 00 00 00 00 01 07 00 00 00 00 00 00 00 00 00
00 00 00 01 00 00 00 00 00 00 00 00 00 10 00 00 00
00 00 45 52 52 4f 52 3a 38 ff ff 07 00 00 00 00 00
00 01 08 00 00 00 00 00 00 00 00 00 00 00 00 01 00
00 00 00 00 00 00 00 00 20 00 00 00 00 00 30 30 30
32 30 30 30 31

Change-Id: Ib375325b49ddf6759785d079790c72581db668b5
Signed-off-by: Daniel Hsu <Daniel-Hsu@quantatw.com>
diff --git a/meta-facebook/meta-harma/recipes-networking/mctp/files/setup-local-eid b/meta-facebook/meta-harma/recipes-networking/mctp/files/setup-local-eid
new file mode 100644
index 0000000..a72606f
--- /dev/null
+++ b/meta-facebook/meta-harma/recipes-networking/mctp/files/setup-local-eid
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+# Set mctpi2c link up and assign local address.
+localEid=8
+busNum=9
+maxRetries=5
+retryInterval=1
+
+retry_command() {
+
+    command="$1"
+    retries=0
+
+    while [ $retries -lt $maxRetries ]; do
+        if bash -c "$command"; then
+            return 0
+        else
+            retries=$((retries + 1))
+            echo "Retry $retries/$maxRetries: Command failed. Retrying in $retryInterval seconds..."
+            sleep $retryInterval
+        fi
+    done
+
+    return 1
+}
+
+# Retry mctp link command
+if ! retry_command "mctp link set mctpi2c${busNum} up"; then
+    echo "Failed to set mctp link after $maxRetries attempts."
+    exit 1
+fi
+
+# Check if local EID is already set
+mctpOutput=$(mctp address show)
+if echo "$mctpOutput" | grep -q "mctpi2c${busNum}"; then
+    echo "mctpi2c${busNum} local EID already set"
+else
+    # Retry mctp addr add command
+    if ! retry_command "mctp addr add ${localEid} dev mctpi2c${busNum}"; then
+        echo "Failed to add mctp address after $maxRetries attempts."
+        exit 1
+    fi
+fi
+echo "mctpi2c${busNum} local EID set to ${localEid}"
+exit 0
\ No newline at end of file