Skip to content

Commit c58bff2

Browse files
SahilChaudhariyanjundeng
authored andcommitted
Addressed followup comments for MtFuji elba dpu platform (sonic-net#22058)
Addressed two action items from PR sonic-net#18536 Removed home dir from dpu_pensando_util.py for copying files from Pensando firmware container: Earlier from Pensando firmware container, files were copied to first home dir /home/admin and then from there to shared directory /usr/share/sonic/device/. Dissolved config_db.json into minigraph.xml, platform.json and init_cfg.json Earlier config_db.json was copied from /usr/share/sonic/device/arm64-elba-asic-flash128-r0/config_db.json to /etc/sonic/config_db.json on first boot up post installation. Now on first boot, minigraph.xml and init_cfg.json gets copied to /etc/sonic and along with sonic default init_cfg.json, config_db.json is getting generated using sonic-cfggen command. This way, config_db.json will have flexibility for schema upgrades. Bug fix: Addressed slot id UNDEFINED issue for dpu_provisioning.sh and for DPU_STATE table entries --------- Signed-off-by: Sahil Chaudhari <[email protected]> Signed-off-by: Shantanu Shrivastava <[email protected]>
1 parent 373c8c7 commit c58bff2

File tree

15 files changed

+171
-162
lines changed

15 files changed

+171
-162
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#name lanes alias speed autoneg fec
2-
Ethernet0 0,1,2,3 etp1 200000 on rs
2+
Ethernet0 0,1,2,3 etp1 200000 off rs
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Pensando-elba t1
1+
Pensando-elba t1-smartswitch
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
{
2-
"interfaces": {},
3-
"DPU":{}
2+
"interfaces": {
3+
"Ethernet0": {
4+
"index": "1",
5+
"lanes": "0,1,2,3",
6+
"breakout_modes": {
7+
"1x200G": ["etp1"]
8+
}
9+
}
10+
},
11+
"DPU":{}
412
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
LOG_MSG() {
4+
echo "$1" | tee /dev/kmsg /dev/stderr /dev/console
5+
}
6+
7+
LOG_MSG "Flushing file system buffers..."
8+
sync
9+
10+
LOG_MSG "Flushing eMMC partitions..."
11+
for dev in $(lsblk -nd -o NAME | grep -E 'mmcblk'); do
12+
LOG_MSG "Flushing /dev/$dev"
13+
blockdev --flushbufs "/dev/$dev"
14+
done
15+
16+
LOG_MSG "Ensuring all IOs are completed..."
17+
sync
18+
sleep 2 # Give time for completion
19+
20+
LOG_MSG "Dropping caches..."
21+
LOG_MSG 3 > /proc/sys/vm/drop_caches
22+
LOG_MSG "Cache cleared."
23+
24+
LOG_MSG "Pre-reboot flush and cache clear complete."
25+
LOG_MSG "Platform specific pre-shutdown is successful"
26+
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"services_to_ignore": [],
2+
"services_to_ignore": ["vlanmgrd", "vxlanmgrd"],
33
"devices_to_ignore": ["psu","fan"],
44
"user_defined_checkers": ["fetch_dpu_status"],
55
"polling_interval": 60,
@@ -8,4 +8,4 @@
88
"normal": "green",
99
"booting": "amber_blink"
1010
}
11-
}
11+
}

files/dsc/dpu.init

+15
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,21 @@ function start_polaris()
6262
docker ps -a --format "{{.ID}}\t{{.Image}}" | grep "$IMAGE_NAME:$TAG" | awk '{print $1}' | xargs -I {} docker rm {}
6363

6464
docker run -v $HOST_DIR_POLARIS/update:/update -v $HOST_DIR_POLARIS/sysconfig/config0:/sysconfig/config0 -v $HOST_DIR_POLARIS/sysconfig/config1:/sysconfig/config1 -v $HOST_DIR_POLARIS/obfl/a:/obfl -v $HOST_DIR_POLARIS/obfl:/var/log/obfl -v $HOST_DIR_POLARIS/data:/data -v $HOST_DIR_POLARIS/share:/share -v $HOST_DIR_POLARIS/share:/external -v $HOST_DIR_POLARIS/mnt/a:/ro -v /dev:/dev -v /sys:/sys --net=host --name=$CONTAINER_NAME_POLARIS --privileged $IMAGE_NAME:$TAG &
65+
66+
if [ -f /boot/first_boot ]; then
67+
device="/usr/share/sonic/device"
68+
platform=$(grep 'onie_platform=' /host/machine.conf | cut -d '=' -f 2)
69+
echo "python3 -m pip install $device/$platform/sonic_platform-1.0-py3-none-any.whl"
70+
python3 -m pip install $device/$platform/sonic_platform-1.0-py3-none-any.whl
71+
rm /boot/first_boot
72+
fi
73+
74+
sleep 5
75+
INTERFACE="eth0-midplane"
76+
if ip link show "$INTERFACE" &> /dev/null; then
77+
echo "dhclient $INTERFACE"
78+
/usr/sbin/dhclient $INTERFACE
79+
fi
6580
}
6681

6782
function start_dpu()

platform/pensando/sonic-platform-modules-dpu/dpu/service/dpu_provisioning.service

-16
This file was deleted.

platform/pensando/sonic-platform-modules-dpu/dpu/utils/dpu_pensando_util.py

+72-35
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,81 @@ def run_cmd(cmd):
3535
return output
3636

3737
def fetch_dpu_files():
38+
api_helper_platform = apiHelper.get_platform()
39+
platform = api_helper_platform if api_helper_platform != None else "arm64-elba-asic-r0"
3840
docker_id = apiHelper.get_dpu_docker_imageID()
39-
cmd = "sudo docker cp {}:/tmp/fru.json /home/admin".format(docker_id)
40-
run_cmd(cmd)
41-
cmd = "sudo docker cp {}:/nic/bin/cpldapp /home/admin".format(docker_id)
42-
run_cmd(cmd)
43-
cmd = "sudo docker cp {}:/nic/lib/libpal.so /home/admin".format(docker_id)
44-
run_cmd(cmd)
45-
cmd = "sudo docker cp {}:/nic/lib/liblogger.so /home/admin".format(docker_id)
41+
cmd = "sudo docker cp {}:/tmp/fru.json /usr/share/sonic/device/{}/fru.json".format(docker_id, platform)
4642
run_cmd(cmd)
47-
cmd = "sudo docker cp {}:/nic/etc/VERSION.json /home/admin".format(docker_id)
43+
cmd = "sudo docker cp {}:/nic/etc/VERSION.json /usr/share/sonic/device/{}/VERSION.json".format(docker_id, platform)
4844
run_cmd(cmd)
4945
cmd = "sudo docker cp {}:/usr/bin/mmc /usr/local/bin".format(docker_id)
5046
run_cmd(cmd)
47+
try:
48+
slot_id = apiHelper.run_docker_cmd("cpldapp -r 0xA").strip()
49+
file = "/usr/share/sonic/device/{}/dpu_slot_id".format(apiHelper.get_platform())
50+
with open(file, "w") as f:
51+
f.write(slot_id)
52+
except Exception as e:
53+
log_err("failed to setup slot_id at platform dir due to {}".format(e))
54+
55+
try:
56+
board_id = apiHelper.run_docker_cmd("cpldapp -r 0x80").strip()
57+
file = "/usr/share/sonic/device/{}/dpu_board_id".format(apiHelper.get_platform())
58+
with open(file, "w") as f:
59+
f.write(board_id)
60+
except Exception as e:
61+
log_err("failed to setup board_id at platform dir due to {}".format(e))
62+
63+
64+
def setup_platform_components_json(slot_id):
65+
try:
66+
api_helper_platform = apiHelper.get_platform()
67+
platform = api_helper_platform if api_helper_platform != None else "arm64-elba-asic-r0"
68+
filename = "/usr/share/sonic/device/{}/platform_components.json".format(platform)
69+
with open(filename, "r") as f:
70+
data = json.load(f)
71+
72+
def replace_keys(obj):
73+
if isinstance(obj, dict):
74+
return {key.replace("-0", f"-{slot_id}"): replace_keys(value) for key, value in obj.items()}
75+
elif isinstance(obj, list):
76+
return [replace_keys(item) for item in obj]
77+
return obj
78+
79+
updated_data = replace_keys(data)
80+
81+
with open(filename, "w") as f:
82+
json.dump(updated_data, f, indent=4)
83+
log_info("successfully updated platform_components.json")
84+
except Exception as e:
85+
log_err("failed to setup platform_components.json due to {}".format(e))
86+
87+
def config_setup():
88+
try:
89+
from sonic_platform.chassis import Chassis
90+
slot_id = Chassis().get_my_slot()
91+
except Exception as e:
92+
log_err("failed to get slot id due to {}".format(e))
93+
94+
try:
95+
cmd = f'sonic-cfggen -a "{{\\"INTERFACE\\": {{\\"Ethernet0\\": {{}},\\"Ethernet0|18.{slot_id}.202.1/31\\": {{}}}}}}" --write-to-db'
96+
run_cmd(cmd)
97+
except Exception as e:
98+
log_err("failed to set Ethernet0 ip due to {}".format(e))
99+
100+
setup_platform_components_json(slot_id)
101+
102+
try:
103+
run_cmd("mkdir -p /host/images")
104+
run_cmd("mkdir -p /data")
105+
run_cmd("chmod +x /boot/install_file")
106+
except Exception as e:
107+
log_err("failed to setup fwutil due to {}".format(e))
108+
51109

52110
def set_onie_version():
111+
api_helper_platform = apiHelper.get_platform()
112+
platform = api_helper_platform if api_helper_platform != None else "arm64-elba-asic-r0"
53113
version = ''
54114
try:
55115
cmd = 'cat /host/machine.conf | grep -i onie_version'
@@ -66,36 +126,14 @@ def set_onie_version():
66126
version = "Not Available"
67127
pass
68128
try:
69-
fru_file = "/home/admin/fru.json"
129+
fru_file = "/usr/share/sonic/device/{}/fru.json".format(platform)
70130
data = json.load(open(fru_file))
71131
data["onie_version"] = version
72132
with open(fru_file, "w") as json_file:
73133
json.dump(data, json_file, indent=4)
74134
except:
75135
pass
76136

77-
def cp_to_shared_mem():
78-
api_helper_platform = apiHelper.get_platform()
79-
platform = api_helper_platform if api_helper_platform != None else "arm64-elba-asic-r0"
80-
cmd = "sudo cp /home/admin/fru.json /usr/share/sonic/device/{}/fru.json".format(platform)
81-
run_cmd(cmd)
82-
cmd = "sudo cp /home/admin/cpldapp /usr/share/sonic/device/{}/cpldapp".format(platform)
83-
run_cmd(cmd)
84-
cmd = "sudo cp /home/admin/libpal.so /usr/share/sonic/device/{}/libpal.so".format(platform)
85-
run_cmd(cmd)
86-
cmd = "sudo cp /home/admin/liblogger.so /usr/share/sonic/device/{}/liblogger.so".format(platform)
87-
run_cmd(cmd)
88-
cmd = "sudo cp /home/admin/VERSION.json /usr/share/sonic/device/{}/VERSION.json".format(platform)
89-
run_cmd(cmd)
90-
91-
def set_cpldapp():
92-
cmd = "sudo cp /home/admin/cpldapp /usr/local/bin"
93-
run_cmd(cmd)
94-
cmd = "sudo cp /home/admin/libpal.so /lib/libpal.so"
95-
run_cmd(cmd)
96-
cmd = "sudo cp /home/admin/liblogger.so /lib/liblogger.so"
97-
run_cmd(cmd)
98-
99137
def set_ubootenv_config():
100138
cmd = "cat /proc/mtd | grep -e 'ubootenv' | awk '{print $1}' | tr -dc '0-9'"
101139
mtd_ubootenv = run_cmd(cmd)
@@ -111,7 +149,7 @@ def configure_iptable_rules():
111149
pass
112150

113151
def pcie_tx_setup():
114-
dpu_slot_id = int(run_cmd("cpldapp -r 0xA").strip(), 16)
152+
dpu_slot_id = int(apiHelper.run_docker_cmd("cpldapp -r 0xA").strip(), 16)
115153
if dpu_slot_id == 6 or dpu_slot_id == 7:
116154
run_cmd("docker exec polaris /nic/tools/run-aacs-server.sh -p 9001 export SERDES_DUT_IP=localhost:9001")
117155
run_cmd("docker exec -e SERDES_ADDR=1:1-1:3f -e SERDES_DUT_IP=localhost:9001 -e SERDES_SBUS_RINGS=4 polaris aapl serdes -addr 1:39 -pre 0 -post 0 -atten 10")
@@ -131,13 +169,12 @@ def main():
131169
set_ubootenv_config()
132170
except:
133171
pass
134-
time.sleep(10)
172+
time.sleep(5)
135173
configure_iptable_rules()
136174
fetch_dpu_files()
175+
config_setup()
137176
time.sleep(5)
138177
set_onie_version()
139-
cp_to_shared_mem()
140-
set_cpldapp()
141178
pcie_tx_setup()
142179

143180
if __name__ == "__main__":

platform/pensando/sonic-platform-modules-dpu/dpu/utils/dpu_provisioning.sh

-75
This file was deleted.

platform/pensando/sonic-platform-modules-dpu/dpu/utils/fetch_dpu_status

-2
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,11 @@ class DPUHealthUpdater():
291291
]
292292
fvs_data.extend(fvs_control_plane_data)
293293

294-
self.delete_dpu_health_table_entries()
295294
for name, value in fvs_data:
296295
self.db.hset(self.table, name, value)
297296

298297
except Exception as e:
299298
log_err(f'Failed to refresh platform health status due to {e}, deleting db table')
300-
self.delete_dpu_health_table_entries()
301299

302300
def run(self):
303301
self.platform_health_stats = self._fetch_monitor_list()

platform/pensando/sonic-platform-modules-dpu/sonic_platform/chassis.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
REBOOT_CAUSE_SOFTWARE = "Software causes"
3131
REBOOT_CAUSE_EXTERNAL = "External causes"
3232
RESET_CAUSE_PATH = "/sys/firmware/pensando/rstcause/this_cause"
33+
DOCKER_HWSKU_PATH = '/usr/share/sonic/platform'
3334

3435
#cpld masks for system led
3536
SYSTEM_LED_GREEN = 0x7
@@ -72,9 +73,6 @@ def __init__(self):
7273
self._api_helper = APIHelper()
7374
ChassisBase.__init__(self)
7475

75-
if not self._api_helper.is_host():
76-
self._api_helper.setup_cpldapp()
77-
7876
log_info("System chassis is ready")
7977

8078
##############################################
@@ -88,7 +86,7 @@ def initizalize_system_led(self):
8886
def get_status_led(self):
8987
cmd = "cpldapp -r {}".format(str(SYSTEM_LED_REG))
9088
try:
91-
output = self._api_helper.runCMD(cmd)
89+
output = self._api_helper.run_docker_cmd(cmd)
9290
reg_val = int(output, 16)
9391
if (reg_val & SYSTEM_LED_GREEN):
9492
return self.STATUS_LED_COLOR_GREEN
@@ -361,8 +359,16 @@ def get_system_eeprom_info(self):
361359
def get_my_slot(self):
362360
cmd = "cpldapp -r 0xA"
363361
try:
364-
slot_id = self._api_helper.runCMD(cmd)
365-
return int(slot_id,16)
362+
if self._api_helper.is_host():
363+
slot_id = self._api_helper.run_docker_cmd(cmd)
364+
return int(slot_id,16)
365+
else:
366+
slot_id_file = DOCKER_HWSKU_PATH + "/dpu_slot_id"
367+
slot_id_hex = open(slot_id_file, "r").read()
368+
if slot_id_hex:
369+
slot_id = int(slot_id_hex, 16)
370+
return slot_id
371+
return -1
366372
except:
367373
return -1
368374

0 commit comments

Comments
 (0)