summaryrefslogtreecommitdiff
path: root/meta-facebook/meta-yosemite4/recipes-phosphor/state/phosphor-state-manager/rescan-cxl-eid
blob: 6f5e3bec48ffce4d67762d5afd9ae7a97ccfe621 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash

# CXL need about 30 seconds to boot up. Wait 30 seconds then start polling CXLs status.
sleep 30

wf_eid=$(($1 * 10 + 2))
count=0

# retry getting EID to maximum 60 seconds
while [ $count -lt 15 ]; do
    count=$((count + 1))
    sleep 2

    output=$(pldmtool raw -m "$wf_eid" -d 0x80 0x02 0x3A 0x04 0x01)

    rx_line=$(echo "$output" | grep "Rx:")
    rx_data=$(echo "$rx_line" | awk '{print $4,$5,$6,$7,$8,$9,$10,$11,$12,$13}')

    cxl1_ready=$(echo "$rx_data" | awk '{print substr($7,1,2)}')
    cxl2_ready=$(echo "$rx_data" | awk '{print substr($10,1,2)}')

    if [ "$cxl1_ready" == "01" ]; then
        if ! busctl call xyz.openbmc_project.MCTP /xyz/openbmc_project/mctp au.com.CodeConstruct.MCTP SetupEndpointByConfigPath s /xyz/openbmc_project/inventory/system/board/Yosemite_4_Wailua_Falls_Slot_"$1"/CXL1; then
            continue
        fi
    fi

    if [ "$cxl2_ready" == "01" ]; then
        if ! busctl call xyz.openbmc_project.MCTP /xyz/openbmc_project/mctp au.com.CodeConstruct.MCTP SetupEndpointByConfigPath s /xyz/openbmc_project/inventory/system/board/Yosemite_4_Wailua_Falls_Slot_"$1"/CXL2; then
            continue
        fi
    fi

    if [ "$cxl1_ready" == "01" ] && [ "$cxl2_ready" == "01" ]; then
        break
    fi

done