Skip to content

Commit ada7c6a

Browse files
authored
Add pensando platform (sonic-net#15978)
This commit adds support for pensando asic called ELBA. ELBA is used in pci based cards and in smartswitches. #### Why I did it This commit introduces pensando platform which is based on ELBA ASIC. ##### Work item tracking - Microsoft ADO **(number only)**: #### How I did it Created platform/pensando folder and created makefiles specific to pensando. This mainly creates pensando docker (which OEM's need to download before building an image) which has all the userspace to initialize and use the DPU (ELBA ASIC). Output of the build process creates two images which can be used from ONIE and goldfw. Recommendation is use to use ONIE. #### How to verify it Load the SONiC image via ONIE or goldfw and make sure the interfaces are UP. ##### Description for the changelog Add pensando platform support.
1 parent ed8fa6a commit ada7c6a

File tree

163 files changed

+43782
-19
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+43782
-19
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ installer/x86_64/platforms/
4141
# Misc. files
4242
asic_config_checksum
4343
files/Aboot/boot0
44+
files/dsc/MANIFEST
45+
files/dsc/install_debian
46+
files/dsc/fs.zip
4447
files/initramfs-tools/arista-convertfs
4548
files/initramfs-tools/union-mount
4649

build_debian.sh

+20-7
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ TRUSTED_GPG_DIR=$BUILD_TOOL_PATH/trusted.gpg.d
5050
echo "Error: Invalid ONIE_IMAGE_PART_SIZE in onie image config file"
5151
exit 1
5252
}
53-
[ -n "$ONIE_INSTALLER_PAYLOAD" ] || {
54-
echo "Error: Invalid ONIE_INSTALLER_PAYLOAD in onie image config file"
53+
[ -n "$INSTALLER_PAYLOAD" ] || {
54+
echo "Error: Invalid INSTALLER_PAYLOAD in onie image config file"
5555
exit 1
5656
}
5757
[ -n "$FILESYSTEM_SQUASHFS" ] || {
@@ -753,14 +753,27 @@ sudo chroot $FILESYSTEM_ROOT update-initramfs -u
753753
## Convert initrd image to u-boot format
754754
if [[ $TARGET_BOOTLOADER == uboot ]]; then
755755
INITRD_FILE=initrd.img-${LINUX_KERNEL_VERSION}-${CONFIGURED_ARCH}
756+
KERNEL_FILE=vmlinuz-${LINUX_KERNEL_VERSION}-${CONFIGURED_ARCH}
756757
if [[ $CONFIGURED_ARCH == armhf ]]; then
757758
INITRD_FILE=initrd.img-${LINUX_KERNEL_VERSION}-armmp
758759
sudo LANG=C chroot $FILESYSTEM_ROOT mkimage -A arm -O linux -T ramdisk -C gzip -d /boot/$INITRD_FILE /boot/u${INITRD_FILE}
759760
## Overwriting the initrd image with uInitrd
760761
sudo LANG=C chroot $FILESYSTEM_ROOT mv /boot/u${INITRD_FILE} /boot/$INITRD_FILE
761762
elif [[ $CONFIGURED_ARCH == arm64 ]]; then
762-
sudo cp -v $PLATFORM_DIR/${sonic_asic_platform}-${CONFIGURED_ARCH}/sonic_fit.its $FILESYSTEM_ROOT/boot/
763-
sudo LANG=C chroot $FILESYSTEM_ROOT mkimage -f /boot/sonic_fit.its /boot/sonic_${CONFIGURED_ARCH}.fit
763+
if [[ $CONFIGURED_PLATFORM == pensando ]]; then
764+
## copy device tree file into boot (XXX: need to compile dtb from dts)
765+
sudo cp -v $PLATFORM_DIR/pensando/elba-asic-psci.dtb $FILESYSTEM_ROOT/boot/
766+
## make kernel as gzip file
767+
sudo LANG=C chroot $FILESYSTEM_ROOT gzip /boot/${KERNEL_FILE}
768+
sudo LANG=C chroot $FILESYSTEM_ROOT mv /boot/${KERNEL_FILE}.gz /boot/${KERNEL_FILE}
769+
## Convert initrd image to u-boot format
770+
sudo LANG=C chroot $FILESYSTEM_ROOT mkimage -A arm64 -O linux -T ramdisk -C gzip -d /boot/$INITRD_FILE /boot/u${INITRD_FILE}
771+
## Overwriting the initrd image with uInitrd
772+
sudo LANG=C chroot $FILESYSTEM_ROOT mv /boot/u${INITRD_FILE} /boot/$INITRD_FILE
773+
else
774+
sudo cp -v $PLATFORM_DIR/${sonic_asic_platform}-${CONFIGURED_ARCH}/sonic_fit.its $FILESYSTEM_ROOT/boot/
775+
sudo LANG=C chroot $FILESYSTEM_ROOT mkimage -f /boot/sonic_fit.its /boot/sonic_${CONFIGURED_ARCH}.fit
776+
fi
764777
fi
765778
fi
766779

@@ -811,7 +824,7 @@ if [[ "$CHANGE_DEFAULT_PASSWORD" == "y" ]]; then
811824
fi
812825

813826
## Compress most file system into squashfs file
814-
sudo rm -f $ONIE_INSTALLER_PAYLOAD $FILESYSTEM_SQUASHFS
827+
sudo rm -f $INSTALLER_PAYLOAD $FILESYSTEM_SQUASHFS
815828
## Output the file system total size for diag purpose
816829
## Note: -x to skip directories on different file systems, such as /proc
817830
sudo du -hsx $FILESYSTEM_ROOT
@@ -856,5 +869,5 @@ fi
856869
pushd $FILESYSTEM_ROOT && sudo tar -I $GZ_COMPRESS_PROGRAM -cf $OLDPWD/$FILESYSTEM_DOCKERFS -C ${DOCKERFS_PATH}var/lib/docker .; popd
857870

858871
## Compress together with /boot, /var/lib/docker and $PLATFORM_DIR as an installer payload zip file
859-
pushd $FILESYSTEM_ROOT && sudo tar -I $GZ_COMPRESS_PROGRAM -cf platform.tar.gz -C $PLATFORM_DIR . && sudo zip -n .gz $OLDPWD/$ONIE_INSTALLER_PAYLOAD -r boot/ platform.tar.gz; popd
860-
sudo zip -g -n .squashfs:.gz $ONIE_INSTALLER_PAYLOAD $FILESYSTEM_SQUASHFS $FILESYSTEM_DOCKERFS
872+
pushd $FILESYSTEM_ROOT && sudo tar -I $GZ_COMPRESS_PROGRAM -cf platform.tar.gz -C $PLATFORM_DIR . && sudo zip -n .gz $OLDPWD/$INSTALLER_PAYLOAD -r boot/ platform.tar.gz; popd
873+
sudo zip -g -n .squashfs:.gz $INSTALLER_PAYLOAD $FILESYSTEM_SQUASHFS $FILESYSTEM_DOCKERFS

build_image.sh

+36-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ fi
1818
echo "Error: Invalid ONIE_IMAGE_PART_SIZE in onie image config file"
1919
exit 1
2020
}
21-
[ -n "$ONIE_INSTALLER_PAYLOAD" ] || {
22-
echo "Error: Invalid ONIE_INSTALLER_PAYLOAD in onie image config file"
21+
[ -n "$INSTALLER_PAYLOAD" ] || {
22+
echo "Error: Invalid INSTALLER_PAYLOAD in onie image config file"
2323
exit 1
2424
}
2525

@@ -86,7 +86,7 @@ generate_onie_installer_image()
8686
## Note: Don't leave blank between lines. It is single line command.
8787
./onie-mk-demo.sh $CONFIGURED_ARCH $TARGET_MACHINE $TARGET_PLATFORM-$TARGET_MACHINE-$ONIEIMAGE_VERSION \
8888
installer platform/$TARGET_MACHINE/platform.conf $output_file OS $IMAGE_VERSION $ONIE_IMAGE_PART_SIZE \
89-
$ONIE_INSTALLER_PAYLOAD $SECURE_UPGRADE_SIGNING_CERT $SECURE_UPGRADE_DEV_SIGNING_KEY
89+
$INSTALLER_PAYLOAD $SECURE_UPGRADE_SIGNING_CERT $SECURE_UPGRADE_DEV_SIGNING_KEY
9090
}
9191

9292
# Generate asic-specific device list
@@ -175,7 +175,7 @@ elif [ "$IMAGE_TYPE" = "aboot" ]; then
175175
sudo rm -f $OUTPUT_ABOOT_IMAGE
176176
sudo rm -f $ABOOT_BOOT_IMAGE
177177
## Add main payload
178-
cp $ONIE_INSTALLER_PAYLOAD $OUTPUT_ABOOT_IMAGE
178+
cp $INSTALLER_PAYLOAD $OUTPUT_ABOOT_IMAGE
179179
## Add Aboot boot0 file
180180
j2 -f env files/Aboot/boot0.j2 ./onie-image.conf > files/Aboot/boot0
181181
sed -i -e "s/%%IMAGE_VERSION%%/$IMAGE_VERSION/g" files/Aboot/boot0
@@ -213,6 +213,38 @@ elif [ "$IMAGE_TYPE" = "aboot" ]; then
213213
[ -f "$CA_CERT" ] && cp "$CA_CERT" "$TARGET_CA_CERT"
214214
./scripts/sign_image.sh -i "$OUTPUT_ABOOT_IMAGE" -k "$SIGNING_KEY" -c "$SIGNING_CERT" -a "$TARGET_CA_CERT"
215215
fi
216+
217+
elif [ "$IMAGE_TYPE" = "dsc" ]; then
218+
echo "Build DSC installer"
219+
220+
dsc_installer_dir=files/dsc
221+
dsc_installer=$dsc_installer_dir/install_debian
222+
dsc_installer_manifest=$dsc_installer_dir/MANIFEST
223+
224+
mkdir -p `dirname $OUTPUT_DSC_IMAGE`
225+
sudo rm -f $OUTPUT_DSC_IMAGE
226+
227+
source ./onie-image.conf
228+
229+
j2 $dsc_installer.j2 > $dsc_installer
230+
export installer_sha=$(sha512sum "$dsc_installer" | awk '{print $1}')
231+
232+
export build_date=$(date -u)
233+
export build_user=$(id -un)
234+
export installer_payload_sha=$(sha512sum "$INSTALLER_PAYLOAD" | awk '{print $1}')
235+
j2 $dsc_installer_manifest.j2 > $dsc_installer_manifest
236+
237+
cp $INSTALLER_PAYLOAD $dsc_installer_dir
238+
tar cf $OUTPUT_DSC_IMAGE -C files/dsc $(basename $dsc_installer_manifest) $INSTALLER_PAYLOAD $(basename $dsc_installer)
239+
240+
echo "Build ONIE installer"
241+
mkdir -p `dirname $OUTPUT_ONIE_IMAGE`
242+
sudo rm -f $OUTPUT_ONIE_IMAGE
243+
244+
generate_device_list "./installer/platforms_asic"
245+
246+
generate_onie_installer_image
247+
216248
else
217249
echo "Error: Non supported image type $IMAGE_TYPE"
218250
exit 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# name lanes alias speed autoneg fec
2+
Ethernet1 0,1,2,3 Ethernet1 100000 on rs
3+
Ethernet2 4,5,6,7 Ethernet2 100000 on rs

device/pensando/arm64-elba-asic-r0/Pensando-elba/sai.profile

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Pensando-elba t1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pensando
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#
2+
# ssd_generic.py
3+
#
4+
# Generic implementation of the SSD health API
5+
# SSD models supported:
6+
# - InnoDisk
7+
# - StorFly
8+
# - Virtium
9+
10+
try:
11+
import re
12+
import subprocess
13+
from sonic_platform_base.sonic_ssd.ssd_base import SsdBase
14+
except ImportError as e:
15+
raise ImportError (str(e) + "- required module not found")
16+
17+
NOT_AVAILABLE = "N/A"
18+
MMC_DATA_PATH = "/sys/class/mmc_host/mmc0/mmc0:0001/{}"
19+
20+
class SsdUtil(SsdBase):
21+
"""
22+
Generic implementation of the SSD health API
23+
"""
24+
model = NOT_AVAILABLE
25+
serial = NOT_AVAILABLE
26+
firmware = NOT_AVAILABLE
27+
temperature = NOT_AVAILABLE
28+
health = NOT_AVAILABLE
29+
ssd_info = NOT_AVAILABLE
30+
vendor_ssd_info = NOT_AVAILABLE
31+
32+
def __init__(self, diskdev):
33+
34+
self.dev = diskdev
35+
try:
36+
self.model = ("emmc {}".format(open(MMC_DATA_PATH.format("name")).read())).replace("\n", "")
37+
self.serial = open(MMC_DATA_PATH.format("serial")).read().replace("\n", "")
38+
self.firmware = open(MMC_DATA_PATH.format("fwrev")).read().replace("\n", "")
39+
value = open(MMC_DATA_PATH.format("life_time")).read().replace("\n", "")
40+
[lifetime_a, lifetime_b] = [int(val, 16) for val in value.split()]
41+
lifetime = lifetime_a if lifetime_a >= lifetime_b else lifetime_b
42+
self.health = float(100 - (lifetime*10))
43+
except:
44+
pass
45+
46+
def get_health(self):
47+
"""
48+
Retrieves current disk health in percentages
49+
50+
Returns:
51+
A float number of current ssd health
52+
e.g. 83.5
53+
"""
54+
return self.health
55+
56+
def get_temperature(self):
57+
"""
58+
Retrieves current disk temperature in Celsius
59+
60+
Returns:
61+
A float number of current temperature in Celsius
62+
e.g. 40.1
63+
"""
64+
return self.temperature
65+
66+
def get_model(self):
67+
"""
68+
Retrieves model for the given disk device
69+
70+
Returns:
71+
A string holding disk model as provided by the manufacturer
72+
"""
73+
return self.model
74+
75+
def get_firmware(self):
76+
"""
77+
Retrieves firmware version for the given disk device
78+
79+
Returns:
80+
A string holding disk firmware version as provided by the manufacturer
81+
"""
82+
return self.firmware
83+
84+
def get_serial(self):
85+
"""
86+
Retrieves serial number for the given disk device
87+
88+
Returns:
89+
A string holding disk serial number as provided by the manufacturer
90+
"""
91+
return self.serial
92+
93+
def get_vendor_output(self):
94+
"""
95+
Retrieves vendor specific data for the given disk device
96+
97+
Returns:
98+
A string holding some vendor specific disk information
99+
"""
100+
return self.vendor_ssd_info
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"skip_thermalctld": true,
3+
"skip_fancontrol": true,
4+
"skip_ledd": true,
5+
"skip_psud": true,
6+
"skip_syseepromd": false,
7+
"skip_xcvrd": true,
8+
"skip_chassis_db_init": false,
9+
"skip_pcied": true
10+
}

dockers/docker-orchagent/orchagent.sh

+3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ elif [ "$platform" == "mellanox" ]; then
6464
ORCHAGENT_ARGS+=""
6565
elif [ "$platform" == "innovium" ]; then
6666
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
67+
elif [ "$platform" == "pensando" ]; then
68+
MAC_ADDRESS=$(ip link property add dev oob_mnic0 altname eth0; ip link show oob_mnic0 | grep ether | awk '{print $2}')
69+
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
6770
else
6871
# Should we use the fallback MAC in case it is not found in Device.Metadata
6972
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"

files/build_templates/sonic_debian_extension.j2

+9
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ IMAGE_DISTRO=$3
3131
set -x -e
3232

3333
CONFIGURED_ARCH=$([ -f .arch ] && cat .arch || echo amd64)
34+
CONFIGURED_PLATFORM=$([ -f .platform ] && cat .platform || echo generic)
3435

3536
. functions.sh
3637
BUILD_SCRIPTS_DIR=files/build_scripts
@@ -762,6 +763,14 @@ sudo LANG=C DOCKER_HOST="$DOCKER_HOST" chroot $FILESYSTEM_ROOT docker tag {{imag
762763
fi
763764
{% endfor %}
764765

766+
if [[ $CONFIGURED_PLATFORM == pensando ]]; then
767+
#Disable rc.local
768+
sudo LANG=C chroot $FILESYSTEM_ROOT chmod -x /etc/rc.local
769+
sudo cp files/dsc/dpu.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM/
770+
sudo cp files/dsc/dpu.init $FILESYSTEM_ROOT/etc/init.d/dpu
771+
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable dpu.service
772+
fi
773+
765774
SONIC_PACKAGE_MANAGER_FOLDER="/var/lib/sonic-package-manager/"
766775
sudo mkdir -p $FILESYSTEM_ROOT/$SONIC_PACKAGE_MANAGER_FOLDER
767776
target_machine="$TARGET_MACHINE" j2 $BUILD_TEMPLATES/packages.json.j2 | sudo tee $FILESYSTEM_ROOT/$SONIC_PACKAGE_MANAGER_FOLDER/packages.json

files/dsc/MANIFEST.j2

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"metadata_version": 1,
3+
"package_version": 2,
4+
"asic_compat": "elba",
5+
"build_date": "{{ build_date }}",
6+
"build_user": "{{ build_user }}",
7+
"installer": {
8+
"name": "install_debian",
9+
"verify": {
10+
"algorithm": "sha512",
11+
"hash": "{{ installer_sha }}"
12+
}
13+
},
14+
"shas": {
15+
"fs.zip": "{{ installer_payload_sha }}"
16+
},
17+
"package_compat": {
18+
"board_policy": "accept"
19+
}
20+
}

files/dsc/dpu.init

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/bash
2+
3+
# {C} Copyright 2023 AMD Systems Inc. All rights reserved
4+
5+
# This script starts/stops dpu sw
6+
7+
8+
### BEGIN INIT INFO
9+
# Provides: load-dpu
10+
# Required-Start:
11+
# Required-Stop:
12+
# Should-Start:
13+
# Should-Stop:
14+
# Default-Start: S
15+
# Default-Stop: 0 6
16+
# Short-Description: Load dpu sw
17+
### END INIT INFO
18+
ACTIVE_FILE="/boot/active.txt"
19+
NIC_MOUNT=""
20+
LOG_FILE="/tmp/active_nic"
21+
TAG="latest"
22+
HOST_DIR=/host/dpu
23+
24+
function start_dpu()
25+
{
26+
modprobe ionic_mnic
27+
modprobe mnet_uio_pdrv_genirq
28+
modprobe mdev
29+
30+
mkdir -p $HOST_DIR/update
31+
mkdir -p $HOST_DIR/sysconfig/config0
32+
mkdir -p $HOST_DIR/sysconfig/config1
33+
mkdir -p $HOST_DIR/obfl
34+
mkdir -p $HOST_DIR/data
35+
mkdir -p $HOST_DIR/tmpfsshare
36+
mkdir -p $HOST_DIR/runfs
37+
mkdir -p $HOST_DIR/logfs
38+
mount -t tmpfs -o size=20M,mode=1777 tmpfs $HOST_DIR/tmpfsshare
39+
mount -t tmpfs -o size=20M,mode=0755 runs $HOST_DIR/runfs
40+
mount -t tmpfs -o size=20M,mode=0755 logfs $HOST_DIR/logfs
41+
42+
if [ -f "$ACTIVE_FILE" ]; then
43+
ACTIVE_CONTENTS=$(cat "$ACTIVE_FILE")
44+
ACTIVE_NIC=$(echo "$ACTIVE_CONTENTS" | cut -d " " -f 8-)
45+
if [ "$ACTIVE_NIC" = "/boot/nicA" ]; then
46+
NIC_MOUNT="-v /dev/shm:/dev/shm -v /boot/nicA/nic_core:/nic -v /boot/nicA/shared/conf/gen:/nic/conf/gen"
47+
elif [ "$ACTIVE_NIC" = "/boot/nicB" ]; then
48+
NIC_MOUNT="-v /dev/shm:/dev/shm -v /boot/nicB/nic_core:/nic -v /boot/nicB/shared/conf/gen:/nic/conf/gen"
49+
fi
50+
else
51+
echo "/boot/active.txt not present" > $LOG_FILE
52+
fi
53+
echo "Active Nic: $ACTIVE_NIC" >> $LOG_FILE
54+
echo "NIC_MOUNT: $NIC_MOUNT" >> $LOG_FILE
55+
56+
docker ps -a --format "{{.ID}}\t{{.Image}}" | grep "docker-dpu:latest" | awk '{print $1}' | xargs -I {} docker rm {}
57+
58+
docker run -v $HOST_DIR/update:/update -v $HOST_DIR/sysconfig/config0:/sysconfig/config0 -v $HOST_DIR/sysconfig/config1:/sysconfig/config1 -v $HOST_DIR/obfl:/obfl -v $HOST_DIR/data:/data -v $HOST_DIR/tmpfsshare:/tmp -v $HOST_DIR/runfs:/run -v $HOST_DIR/logfs:/var/log -v /sys:/sys $NIC_MOUNT --net=host --name=dpu --privileged docker-dpu:$TAG
59+
}
60+
61+
case "$1" in
62+
start)
63+
echo -n "Start dpu... "
64+
65+
start_dpu
66+
67+
echo "done."
68+
;;
69+
70+
stop)
71+
echo "Not supported"
72+
;;
73+
74+
force-reload|restart)
75+
echo "Not supported"
76+
;;
77+
78+
*)
79+
echo "Usage: /etc/init.d/dpu.init {start}"
80+
exit 1
81+
;;
82+
esac
83+
84+
exit 0
85+

0 commit comments

Comments
 (0)