Skip to content

Commit

Permalink
Add pensando platform (sonic-net#15978)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ashwin-h authored Dec 4, 2023
1 parent ed8fa6a commit ada7c6a
Show file tree
Hide file tree
Showing 163 changed files with 43,782 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ installer/x86_64/platforms/
# Misc. files
asic_config_checksum
files/Aboot/boot0
files/dsc/MANIFEST
files/dsc/install_debian
files/dsc/fs.zip
files/initramfs-tools/arista-convertfs
files/initramfs-tools/union-mount

Expand Down
27 changes: 20 additions & 7 deletions build_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ TRUSTED_GPG_DIR=$BUILD_TOOL_PATH/trusted.gpg.d
echo "Error: Invalid ONIE_IMAGE_PART_SIZE in onie image config file"
exit 1
}
[ -n "$ONIE_INSTALLER_PAYLOAD" ] || {
echo "Error: Invalid ONIE_INSTALLER_PAYLOAD in onie image config file"
[ -n "$INSTALLER_PAYLOAD" ] || {
echo "Error: Invalid INSTALLER_PAYLOAD in onie image config file"
exit 1
}
[ -n "$FILESYSTEM_SQUASHFS" ] || {
Expand Down Expand Up @@ -753,14 +753,27 @@ sudo chroot $FILESYSTEM_ROOT update-initramfs -u
## Convert initrd image to u-boot format
if [[ $TARGET_BOOTLOADER == uboot ]]; then
INITRD_FILE=initrd.img-${LINUX_KERNEL_VERSION}-${CONFIGURED_ARCH}
KERNEL_FILE=vmlinuz-${LINUX_KERNEL_VERSION}-${CONFIGURED_ARCH}
if [[ $CONFIGURED_ARCH == armhf ]]; then
INITRD_FILE=initrd.img-${LINUX_KERNEL_VERSION}-armmp
sudo LANG=C chroot $FILESYSTEM_ROOT mkimage -A arm -O linux -T ramdisk -C gzip -d /boot/$INITRD_FILE /boot/u${INITRD_FILE}
## Overwriting the initrd image with uInitrd
sudo LANG=C chroot $FILESYSTEM_ROOT mv /boot/u${INITRD_FILE} /boot/$INITRD_FILE
elif [[ $CONFIGURED_ARCH == arm64 ]]; then
sudo cp -v $PLATFORM_DIR/${sonic_asic_platform}-${CONFIGURED_ARCH}/sonic_fit.its $FILESYSTEM_ROOT/boot/
sudo LANG=C chroot $FILESYSTEM_ROOT mkimage -f /boot/sonic_fit.its /boot/sonic_${CONFIGURED_ARCH}.fit
if [[ $CONFIGURED_PLATFORM == pensando ]]; then
## copy device tree file into boot (XXX: need to compile dtb from dts)
sudo cp -v $PLATFORM_DIR/pensando/elba-asic-psci.dtb $FILESYSTEM_ROOT/boot/
## make kernel as gzip file
sudo LANG=C chroot $FILESYSTEM_ROOT gzip /boot/${KERNEL_FILE}
sudo LANG=C chroot $FILESYSTEM_ROOT mv /boot/${KERNEL_FILE}.gz /boot/${KERNEL_FILE}
## Convert initrd image to u-boot format
sudo LANG=C chroot $FILESYSTEM_ROOT mkimage -A arm64 -O linux -T ramdisk -C gzip -d /boot/$INITRD_FILE /boot/u${INITRD_FILE}
## Overwriting the initrd image with uInitrd
sudo LANG=C chroot $FILESYSTEM_ROOT mv /boot/u${INITRD_FILE} /boot/$INITRD_FILE
else
sudo cp -v $PLATFORM_DIR/${sonic_asic_platform}-${CONFIGURED_ARCH}/sonic_fit.its $FILESYSTEM_ROOT/boot/
sudo LANG=C chroot $FILESYSTEM_ROOT mkimage -f /boot/sonic_fit.its /boot/sonic_${CONFIGURED_ARCH}.fit
fi
fi
fi

Expand Down Expand Up @@ -811,7 +824,7 @@ if [[ "$CHANGE_DEFAULT_PASSWORD" == "y" ]]; then
fi

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

## Compress together with /boot, /var/lib/docker and $PLATFORM_DIR as an installer payload zip file
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
sudo zip -g -n .squashfs:.gz $ONIE_INSTALLER_PAYLOAD $FILESYSTEM_SQUASHFS $FILESYSTEM_DOCKERFS
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
sudo zip -g -n .squashfs:.gz $INSTALLER_PAYLOAD $FILESYSTEM_SQUASHFS $FILESYSTEM_DOCKERFS
40 changes: 36 additions & 4 deletions build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ fi
echo "Error: Invalid ONIE_IMAGE_PART_SIZE in onie image config file"
exit 1
}
[ -n "$ONIE_INSTALLER_PAYLOAD" ] || {
echo "Error: Invalid ONIE_INSTALLER_PAYLOAD in onie image config file"
[ -n "$INSTALLER_PAYLOAD" ] || {
echo "Error: Invalid INSTALLER_PAYLOAD in onie image config file"
exit 1
}

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

# Generate asic-specific device list
Expand Down Expand Up @@ -175,7 +175,7 @@ elif [ "$IMAGE_TYPE" = "aboot" ]; then
sudo rm -f $OUTPUT_ABOOT_IMAGE
sudo rm -f $ABOOT_BOOT_IMAGE
## Add main payload
cp $ONIE_INSTALLER_PAYLOAD $OUTPUT_ABOOT_IMAGE
cp $INSTALLER_PAYLOAD $OUTPUT_ABOOT_IMAGE
## Add Aboot boot0 file
j2 -f env files/Aboot/boot0.j2 ./onie-image.conf > files/Aboot/boot0
sed -i -e "s/%%IMAGE_VERSION%%/$IMAGE_VERSION/g" files/Aboot/boot0
Expand Down Expand Up @@ -213,6 +213,38 @@ elif [ "$IMAGE_TYPE" = "aboot" ]; then
[ -f "$CA_CERT" ] && cp "$CA_CERT" "$TARGET_CA_CERT"
./scripts/sign_image.sh -i "$OUTPUT_ABOOT_IMAGE" -k "$SIGNING_KEY" -c "$SIGNING_CERT" -a "$TARGET_CA_CERT"
fi

elif [ "$IMAGE_TYPE" = "dsc" ]; then
echo "Build DSC installer"

dsc_installer_dir=files/dsc
dsc_installer=$dsc_installer_dir/install_debian
dsc_installer_manifest=$dsc_installer_dir/MANIFEST

mkdir -p `dirname $OUTPUT_DSC_IMAGE`
sudo rm -f $OUTPUT_DSC_IMAGE

source ./onie-image.conf

j2 $dsc_installer.j2 > $dsc_installer
export installer_sha=$(sha512sum "$dsc_installer" | awk '{print $1}')

export build_date=$(date -u)
export build_user=$(id -un)
export installer_payload_sha=$(sha512sum "$INSTALLER_PAYLOAD" | awk '{print $1}')
j2 $dsc_installer_manifest.j2 > $dsc_installer_manifest

cp $INSTALLER_PAYLOAD $dsc_installer_dir
tar cf $OUTPUT_DSC_IMAGE -C files/dsc $(basename $dsc_installer_manifest) $INSTALLER_PAYLOAD $(basename $dsc_installer)

echo "Build ONIE installer"
mkdir -p `dirname $OUTPUT_ONIE_IMAGE`
sudo rm -f $OUTPUT_ONIE_IMAGE

generate_device_list "./installer/platforms_asic"

generate_onie_installer_image

else
echo "Error: Non supported image type $IMAGE_TYPE"
exit 1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# name lanes alias speed autoneg fec
Ethernet1 0,1,2,3 Ethernet1 100000 on rs
Ethernet2 4,5,6,7 Ethernet2 100000 on rs
Empty file.
1 change: 1 addition & 0 deletions device/pensando/arm64-elba-asic-r0/default_sku
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pensando-elba t1
1 change: 1 addition & 0 deletions device/pensando/arm64-elba-asic-r0/platform_asic
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pensando
100 changes: 100 additions & 0 deletions device/pensando/arm64-elba-asic-r0/plugins/ssd_util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#
# ssd_generic.py
#
# Generic implementation of the SSD health API
# SSD models supported:
# - InnoDisk
# - StorFly
# - Virtium

try:
import re
import subprocess
from sonic_platform_base.sonic_ssd.ssd_base import SsdBase
except ImportError as e:
raise ImportError (str(e) + "- required module not found")

NOT_AVAILABLE = "N/A"
MMC_DATA_PATH = "/sys/class/mmc_host/mmc0/mmc0:0001/{}"

class SsdUtil(SsdBase):
"""
Generic implementation of the SSD health API
"""
model = NOT_AVAILABLE
serial = NOT_AVAILABLE
firmware = NOT_AVAILABLE
temperature = NOT_AVAILABLE
health = NOT_AVAILABLE
ssd_info = NOT_AVAILABLE
vendor_ssd_info = NOT_AVAILABLE

def __init__(self, diskdev):

self.dev = diskdev
try:
self.model = ("emmc {}".format(open(MMC_DATA_PATH.format("name")).read())).replace("\n", "")
self.serial = open(MMC_DATA_PATH.format("serial")).read().replace("\n", "")
self.firmware = open(MMC_DATA_PATH.format("fwrev")).read().replace("\n", "")
value = open(MMC_DATA_PATH.format("life_time")).read().replace("\n", "")
[lifetime_a, lifetime_b] = [int(val, 16) for val in value.split()]
lifetime = lifetime_a if lifetime_a >= lifetime_b else lifetime_b
self.health = float(100 - (lifetime*10))
except:
pass

def get_health(self):
"""
Retrieves current disk health in percentages
Returns:
A float number of current ssd health
e.g. 83.5
"""
return self.health

def get_temperature(self):
"""
Retrieves current disk temperature in Celsius
Returns:
A float number of current temperature in Celsius
e.g. 40.1
"""
return self.temperature

def get_model(self):
"""
Retrieves model for the given disk device
Returns:
A string holding disk model as provided by the manufacturer
"""
return self.model

def get_firmware(self):
"""
Retrieves firmware version for the given disk device
Returns:
A string holding disk firmware version as provided by the manufacturer
"""
return self.firmware

def get_serial(self):
"""
Retrieves serial number for the given disk device
Returns:
A string holding disk serial number as provided by the manufacturer
"""
return self.serial

def get_vendor_output(self):
"""
Retrieves vendor specific data for the given disk device
Returns:
A string holding some vendor specific disk information
"""
return self.vendor_ssd_info
10 changes: 10 additions & 0 deletions device/pensando/arm64-elba-asic-r0/pmon_daemon_control.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"skip_thermalctld": true,
"skip_fancontrol": true,
"skip_ledd": true,
"skip_psud": true,
"skip_syseepromd": false,
"skip_xcvrd": true,
"skip_chassis_db_init": false,
"skip_pcied": true
}
3 changes: 3 additions & 0 deletions dockers/docker-orchagent/orchagent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ elif [ "$platform" == "mellanox" ]; then
ORCHAGENT_ARGS+=""
elif [ "$platform" == "innovium" ]; then
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
elif [ "$platform" == "pensando" ]; then
MAC_ADDRESS=$(ip link property add dev oob_mnic0 altname eth0; ip link show oob_mnic0 | grep ether | awk '{print $2}')
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
else
# Should we use the fallback MAC in case it is not found in Device.Metadata
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
Expand Down
9 changes: 9 additions & 0 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ IMAGE_DISTRO=$3
set -x -e

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

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

if [[ $CONFIGURED_PLATFORM == pensando ]]; then
#Disable rc.local
sudo LANG=C chroot $FILESYSTEM_ROOT chmod -x /etc/rc.local
sudo cp files/dsc/dpu.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM/
sudo cp files/dsc/dpu.init $FILESYSTEM_ROOT/etc/init.d/dpu
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable dpu.service
fi

SONIC_PACKAGE_MANAGER_FOLDER="/var/lib/sonic-package-manager/"
sudo mkdir -p $FILESYSTEM_ROOT/$SONIC_PACKAGE_MANAGER_FOLDER
target_machine="$TARGET_MACHINE" j2 $BUILD_TEMPLATES/packages.json.j2 | sudo tee $FILESYSTEM_ROOT/$SONIC_PACKAGE_MANAGER_FOLDER/packages.json
Expand Down
20 changes: 20 additions & 0 deletions files/dsc/MANIFEST.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"metadata_version": 1,
"package_version": 2,
"asic_compat": "elba",
"build_date": "{{ build_date }}",
"build_user": "{{ build_user }}",
"installer": {
"name": "install_debian",
"verify": {
"algorithm": "sha512",
"hash": "{{ installer_sha }}"
}
},
"shas": {
"fs.zip": "{{ installer_payload_sha }}"
},
"package_compat": {
"board_policy": "accept"
}
}
85 changes: 85 additions & 0 deletions files/dsc/dpu.init
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/bash

# {C} Copyright 2023 AMD Systems Inc. All rights reserved

# This script starts/stops dpu sw


### BEGIN INIT INFO
# Provides: load-dpu
# Required-Start:
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: S
# Default-Stop: 0 6
# Short-Description: Load dpu sw
### END INIT INFO
ACTIVE_FILE="/boot/active.txt"
NIC_MOUNT=""
LOG_FILE="/tmp/active_nic"
TAG="latest"
HOST_DIR=/host/dpu

function start_dpu()
{
modprobe ionic_mnic
modprobe mnet_uio_pdrv_genirq
modprobe mdev

mkdir -p $HOST_DIR/update
mkdir -p $HOST_DIR/sysconfig/config0
mkdir -p $HOST_DIR/sysconfig/config1
mkdir -p $HOST_DIR/obfl
mkdir -p $HOST_DIR/data
mkdir -p $HOST_DIR/tmpfsshare
mkdir -p $HOST_DIR/runfs
mkdir -p $HOST_DIR/logfs
mount -t tmpfs -o size=20M,mode=1777 tmpfs $HOST_DIR/tmpfsshare
mount -t tmpfs -o size=20M,mode=0755 runs $HOST_DIR/runfs
mount -t tmpfs -o size=20M,mode=0755 logfs $HOST_DIR/logfs

if [ -f "$ACTIVE_FILE" ]; then
ACTIVE_CONTENTS=$(cat "$ACTIVE_FILE")
ACTIVE_NIC=$(echo "$ACTIVE_CONTENTS" | cut -d " " -f 8-)
if [ "$ACTIVE_NIC" = "/boot/nicA" ]; then
NIC_MOUNT="-v /dev/shm:/dev/shm -v /boot/nicA/nic_core:/nic -v /boot/nicA/shared/conf/gen:/nic/conf/gen"
elif [ "$ACTIVE_NIC" = "/boot/nicB" ]; then
NIC_MOUNT="-v /dev/shm:/dev/shm -v /boot/nicB/nic_core:/nic -v /boot/nicB/shared/conf/gen:/nic/conf/gen"
fi
else
echo "/boot/active.txt not present" > $LOG_FILE
fi
echo "Active Nic: $ACTIVE_NIC" >> $LOG_FILE
echo "NIC_MOUNT: $NIC_MOUNT" >> $LOG_FILE

docker ps -a --format "{{.ID}}\t{{.Image}}" | grep "docker-dpu:latest" | awk '{print $1}' | xargs -I {} docker rm {}

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
}

case "$1" in
start)
echo -n "Start dpu... "

start_dpu

echo "done."
;;

stop)
echo "Not supported"
;;

force-reload|restart)
echo "Not supported"
;;

*)
echo "Usage: /etc/init.d/dpu.init {start}"
exit 1
;;
esac

exit 0

Loading

0 comments on commit ada7c6a

Please sign in to comment.