Skip to content

Commit

Permalink
Adding prebuilt dpu docker
Browse files Browse the repository at this point in the history
  • Loading branch information
shanshri committed Nov 28, 2023
1 parent 7190c62 commit 4e8ee73
Show file tree
Hide file tree
Showing 13 changed files with 134 additions and 24 deletions.
2 changes: 1 addition & 1 deletion dockers/docker-orchagent/orchagent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ elif [ "$platform" == "mellanox" ]; then
elif [ "$platform" == "innovium" ]; then
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
elif [ "$platform" == "pensando" ]; then
MAC_ADDRESS=$(ip link show oob_mnic0 | grep ether | awk '{print $2}')
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
Expand Down
6 changes: 0 additions & 6 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -764,12 +764,6 @@ fi
{% endfor %}

if [[ $CONFIGURED_PLATFORM == pensando ]]; then
#we need to start pciemgrd process soon at the bootup for pci txn to be up.
#if we don't start pciemgrd early pcie timeout happens and server reboots.
#pciemgrd runs as part of dpu docker. So load this at build time itself.
sudo LANG=C DOCKER_HOST="$DOCKER_HOST" chroot $FILESYSTEM_ROOT docker load -i boot/dpu_sw.tar
sudo LANG=C chroot $FILESYSTEM_ROOT rm -f boot/dpu_sw.tar

#Disable rc.local
sudo LANG=C chroot $FILESYSTEM_ROOT chmod -x /etc/rc.local
fi
Expand Down
1 change: 1 addition & 0 deletions files/scripts/docker-dpu-base.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/bin/bash
7 changes: 7 additions & 0 deletions platform/pensando/docker-dpu.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
DOCKER_DPU_STEM = docker-dpu
DOCKER_DPU = $(DOCKER_DPU_STEM).gz
DPATH := $($(DOCKER_DPU)_PATH)
DEP_FILES := platform/pensando/docker-dpu.dep platform/pensando/docker-dpu.mk

$(DOCKER_DPU)_CACHE_MODE := none
$(DOCKER_DPU)_DEP_FILES := $(DEP_FILES)
40 changes: 40 additions & 0 deletions platform/pensando/docker-dpu.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# docker dpu image for load
DOCKER_DPU_STEM = docker-dpu

DOCKER_DPU = $(DOCKER_DPU_STEM).gz

$(DOCKER_DPU)_PATH = $(PLATFORM_PATH)/$(DOCKER_DPU_STEM)

$(DOCKER_DPU)_LOAD_DOCKERS = $(DOCKER_DPU_BASE)

$(DOCKER_DPU)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BUSTER)

$(DOCKER_DPU)_DBG_DEPENDS += $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_DEPENDS)

$(DOCKER_DPU)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_IMAGE_PACKAGES)

SONIC_DOCKER_IMAGES += $(DOCKER_DPU)

$(DOCKER_DPU)_PACKAGE_NAME = dpu
$(DOCKER_DPU)_CONTAINER_NAME = dpu
$(DOCKER_DPU)_VERSION = 1.0.0
$(DOCKER_DPU)_RUN_OPT += --privileged -t
$(DOCKER_DPU)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro

#NIC_MOUNT="-v /dev/shm:/dev/shm -v /boot/nicA/nic_core:/nic -v /boot/nicA/shared/conf/gen:/nic/conf/gen"
$(DOCKER_DPU)_RUN_OPT += --privileged -t
$(DOCKER_DPU)_RUN_OPT += -v /host/dpu/update:/update
$(DOCKER_DPU)_RUN_OPT += -v /host/dpu/sysconfig/config0:/sysconfig/config0
$(DOCKER_DPU)_RUN_OPT += -v /host/dpu/sysconfig/config1:/sysconfig/config1
$(DOCKER_DPU)_RUN_OPT += -v /host/dpu/obfl:/obfl
$(DOCKER_DPU)_RUN_OPT += -v /host/dpu/data:/data
$(DOCKER_DPU)_RUN_OPT += -v /host/dpu/tmpfsshare:/tmp
$(DOCKER_DPU)_RUN_OPT += -v /host/dpu/runfs:/run
$(DOCKER_DPU)_RUN_OPT += -v /host/dpu/logfs:/var/log
$(DOCKER_DPU)_RUN_OPT += -v /sys:/sys
#$(DOCKER_DPU)_RUN_OPT += $NIC_MOUNT
$(DOCKER_DPU)_RUN_OPT += --net=host
$(DOCKER_DPU)_RUN_OPT += docker-dpu:v1

SONIC_BUSTER_DOCKERS += $(DOCKER_DPU)
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_DPU)
7 changes: 7 additions & 0 deletions platform/pensando/docker-dpu/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# DOWNLOADED_DOCKER_IMAGES
FROM docker-dpu-base

RUN echo "docker-dpu-base"

ENTRYPOINT ["/nic/tools/sysinit.sh", "classic", "hw", "30"]

38 changes: 25 additions & 13 deletions platform/pensando/dpu/debian/dpu.init
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/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:
Expand All @@ -14,20 +18,26 @@
ACTIVE_FILE="/boot/active.txt"
NIC_MOUNT=""
LOG_FILE="/tmp/active_nic"
TAG="latest"
HOST_DIR=/host/dpu

function start_dpu()
{
mkdir -p /host/dpu/update
mkdir -p /host/dpu/sysconfig/config0
mkdir -p /host/dpu/sysconfig/config1
mkdir -p /host/dpu/obfl
mkdir -p /host/dpu/data
mkdir -p /host/dpu/tmpfsshare
mkdir -p /host/dpu/runfs
mkdir -p /host/dpu/logfs
mount -t tmpfs -o size=20M,mode=1777 tmpfs /host/dpu/tmpfsshare
mount -t tmpfs -o size=20M,mode=0755 runs /host/dpu/runfs
mount -t tmpfs -o size=20M,mode=0755 logfs /host/dpu/logfs
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")
Expand All @@ -41,9 +51,11 @@ function start_dpu()
echo "/boot/active.txt not present" > $LOG_FILE
fi
echo "Active Nic: $ACTIVE_NIC" >> $LOG_FILE
echo "NIC_MOUNT: $NIC_MOUNT" >> $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/dpu/update:/update -v /host/dpu/sysconfig/config0:/sysconfig/config0 -v /host/dpu/sysconfig/config1:/sysconfig/config1 -v /host/dpu/obfl:/obfl -v /host/dpu/data:/data -v /host/dpu/tmpfsshare:/tmp -v /host/dpu/runfs:/run -v /host/dpu/logfs:/var/log -v /sys:/sys $NIC_MOUNT --net=host --privileged dpu:v1
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=docker-dpu --privileged docker-dpu:$TAG
}

case "$1" in
Expand Down
1 change: 0 additions & 1 deletion platform/pensando/dpu/debian/dpu.install
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
systemd/dpu.service lib/systemd/system
image/dpu_sw.tar /boot/
1 change: 1 addition & 0 deletions platform/pensando/rules.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include $(PLATFORM_PATH)/dpu.mk
include $(PLATFORM_PATH)/docker-dpu.mk
include $(PLATFORM_PATH)/one-image.mk
include $(PLATFORM_PATH)/sdk.mk
include $(PLATFORM_PATH)/docker-syncd-pensando.mk
Expand Down
4 changes: 4 additions & 0 deletions rules/docker-dpu-base.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DEP_FILES := rules/docker-dpu-base.dep rules/docker-dpu-base.mk

$(DOCKER_DPU_BASE)_CACHE_MODE := none
$(DOCKER_DPU_BASE)_DEP_FILES := $(DEP_FILES)
8 changes: 8 additions & 0 deletions rules/docker-dpu-base.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# docker dpu image for load

DOCKER_DPU_BASE_STEM = docker-dpu-base

DOCKER_DPU_BASE = $(DOCKER_DPU_BASE_STEM).gz

DOWNLOADED_DOCKER_IMAGES += $(DOCKER_DPU_BASE)

25 changes: 22 additions & 3 deletions scripts/prepare_docker_buildinfo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,27 @@ ENV IMAGENAME='${IMAGENAME}'
ENV DISTRO='${DISTRO}'
RUN pre_run_buildinfo '${IMAGENAME}'
'
DOWNLOADED_DOCKER_IMAGES_DOCKERFILE_PRE_SCRIPT='# Auto-Generated for buildinfo
ARG SONIC_VERSION_CACHE
ARG SONIC_VERSION_CONTROL_COMPONENTS
COPY ["buildinfo", "/usr/local/share/buildinfo"]
COPY vcache/ /sonic/target/vcache/'${IMAGENAME}'
COPY ["tmp_extract", "/"]
ENV IMAGENAME='${IMAGENAME}'
ENV DISTRO='${DISTRO}'
RUN pre_run_buildinfo '${IMAGENAME}'
'

# Add the auto-generate code if it is not added in the target Dockerfile
if [ ! -f $DOCKERFILE_TARGET ] || ! grep -q "Auto-Generated for buildinfo" $DOCKERFILE_TARGET; then
# Insert the docker build script before the RUN command
LINE_NUMBER=$(grep -Fn -m 1 'RUN' $DOCKERFILE | cut -d: -f1)
TEMP_FILE=$(mktemp)
awk -v text="${DOCKERFILE_PRE_SCRIPT}" -v linenumber=$LINE_NUMBER 'NR==linenumber{print text}1' $DOCKERFILE > $TEMP_FILE

if ! grep -q "DOWNLOADED_DOCKER_IMAGES" $DOCKERFILE_TARGET; then
awk -v text="${DOCKERFILE_PRE_SCRIPT}" -v linenumber=$LINE_NUMBER 'NR==linenumber{print text}1' $DOCKERFILE > $TEMP_FILE
else
awk -v text="${DOWNLOADED_DOCKER_IMAGES_DOCKERFILE_PRE_SCRIPT}" -v linenumber=$LINE_NUMBER 'NR==linenumber{print text}1' $DOCKERFILE > $TEMP_FILE
fi
# Append the docker build script at the end of the docker file
echo -e "\nRUN post_run_buildinfo ${IMAGENAME} " >> $TEMP_FILE
echo -e "\nRUN post_run_cleanup ${IMAGENAME} " >> $TEMP_FILE
Expand All @@ -73,7 +86,13 @@ fi

# Copy the build info config
mkdir -p ${BUILDINFO_PATH}
cp -rf src/sonic-build-hooks/buildinfo/* $BUILDINFO_PATH
if ! grep -q "DOWNLOADED_DOCKER_IMAGES" $DOCKERFILE_TARGET; then
cp -rf src/sonic-build-hooks/buildinfo/* $BUILDINFO_PATH
else
cp -rf src/sonic-build-hooks/buildinfo/* $BUILDINFO_PATH
mkdir -p $DOCKERFILE_PATH/tmp_extract
dpkg --extract $BUILDINFO_PATH/sonic-build-hooks_1.0_all.deb $DOCKERFILE_PATH/tmp_extract
fi

# Generate the version lock files
scripts/versions_manager.py generate -t "$BUILDINFO_VERSION_PATH" -n "$IMAGENAME" -d "$DISTRO" -a "$ARCH"
Expand Down
18 changes: 18 additions & 0 deletions slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,24 @@ $(foreach IMAGE,$(DOCKER_IMAGES), $(eval $(IMAGE)_FILES_PATH := $(FILES_PATH)))
$(foreach IMAGE,$(DOCKER_DBG_IMAGES), $(eval $(IMAGE)_DEBS_PATH := $(DEBS_PATH)))
$(foreach IMAGE,$(DOCKER_DBG_IMAGES), $(eval $(IMAGE)_FILES_PATH := $(FILES_PATH)))

# Targets for downloaded docker images
$(addprefix $(TARGET_PATH)/,$(DOWNLOADED_DOCKER_IMAGES)) : $(TARGET_PATH)/%.gz : .platform \
$$(%.gz_DEP_FILES)
$(HEADER)

cp files/$(DOWNLOADED_DOCKER_IMAGES) target/$(DOWNLOADED_DOCKER_IMAGES)

$(FOOTER)

DOCKER_LOAD_DOWNLOADED_TARGETS = $(addsuffix -load,$(addprefix $(TARGET_PATH)/, \
$(DOWNLOADED_DOCKER_IMAGES)))

$(DOCKER_LOAD_DOWNLOADED_TARGETS) : $(TARGET_PATH)/%.gz-load : .platform docker-start $$(TARGET_PATH)/$$*.gz
$(HEADER)
$(call docker-image-load,$*)
$(FOOTER)


# Targets for building docker images
$(addprefix $(TARGET_PATH)/, $(DOCKER_IMAGES)) : $(TARGET_PATH)/%.gz : .platform docker-start \
$$(addprefix $$($$*.gz_DEBS_PATH)/,$$($$*.gz_DEPENDS)) \
Expand Down

0 comments on commit 4e8ee73

Please sign in to comment.