Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions platform/nvidia-bluefield/bfscripts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

*
!.gitignore
!Makefile
41 changes: 41 additions & 0 deletions platform/nvidia-bluefield/bfscripts/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new file cannot have such header.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

# Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES.
# Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

.ONESHELL:
SHELL = /bin/bash
.SHELLFLAGS += -ex

$(addprefix $(DEST)/, $(MLNX_BLUEFIELD_BUILD_SCRIPTS)): $(DEST)/% :
rm -rf ./tmp/
mkdir ./tmp/
pushd ./tmp/

wget -O ${MLNX_BLUEFIELD_BUILD_SCRIPTS} "${BSD_BASE_URL}/build/install/distro/DEBS/${MLNX_BLUEFIELD_BUILD_SCRIPTS}"

mkdir -p bfscripts/DEBIAN
dpkg -e ${MLNX_BLUEFIELD_BUILD_SCRIPTS} bfscripts/DEBIAN
dpkg -x ${MLNX_BLUEFIELD_BUILD_SCRIPTS} bfscripts
rm -f ${MLNX_BLUEFIELD_BUILD_SCRIPTS}

# Remove postinst script as we don't want to enable systemd services from the package.
# We are interested only in a couple of scripts that package has.
rm -f bfscripts/DEBIAN/postinst

dpkg -b bfscripts ./

mv ${MLNX_BLUEFIELD_BUILD_SCRIPTS} $(DEST)/
popd
46 changes: 46 additions & 0 deletions platform/nvidia-bluefield/bluefield-platform-modules/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new file cannot have such header

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

# Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES.
# Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

.ONESHELL:
SHELL = /bin/bash
.SHELLFLAGS += -e

$(addprefix $(DEST)/, $(BF_PLATFORM_MODULE)): $(DEST)/% :

# Clean up
rm -rf drivers/* \
cfg/bluefield-modules.conf \
debian/bluefield-platform-modules.postinst

mkdir -p drivers/
mkdir -p cfg/

$(foreach kernel_module, $(BF_PLATFORM_DRIVERS), \
cp $(PROJECT_ROOT)/$(FILES_PATH)/$(kernel_module) drivers/
)

export driver_targets="$(BF_PLATFORM_DRIVERS)"
export kversion="$(KVERSION)"
j2 templates/bluefield-platform-modules.postinst.j2 > debian/bluefield-platform-modules.postinst
j2 templates/bluefield-modules.conf.j2 > cfg/bluefield-modules.conf

chmod +x debian/bluefield-platform-modules.postinst
chmod 0644 cfg/bluefield-modules.conf

DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -rfakeroot -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS)

mv ../$(BF_PLATFORM_MODULE) $(DEST)/
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash
#
# Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES.
# Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

cp_iface=Ethernet0
pidfile=/run/dhcl-internal.$cp_iface.pid
leasefile=/var/lib/dhcp/dhcl-internal.$cp_iface.leases

stop_cp_dhclient()
{
if [[ -f $pidfile ]]; then
kill $(cat $pidfile)
rm -f $pidfile
fi
rm -f $leasefile
}

start_cp_dhclient()
{
stop_cp_dhclient

/sbin/dhclient -pf $pidfile -lf $leasefile $cp_iface -nw
}

start()
{
modprobe mlx5_core
/usr/bin/mst start

hwsku=$(sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["hwsku"]')
if [[ $hwsku == *"-C1" ]]; then
start_cp_dhclient
fi
}

stop()
{
stop_cp_dhclient

/usr/bin/mst stop
rmmod mlx5_ib mlx5_core
}

case "$1" in
start|stop)
$1
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
;;
esac

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash
#
# Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES.
# Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

DUMP_FOLDER="/tmp/platform-dump"

dump_cmd () {
cmd=$1
output_fname=$2
timeout=$3
cmd_name=${cmd%% *}

if [ -x "$(command -v $cmd_name)" ];
then
# ignore shellcheck message SC2016. Arguments should be single-quoted (')
run_cmd="$cmd > $DUMP_FOLDER/$output_fname"
timeout "$timeout" bash -c "$run_cmd"
fi
}

rm -rf $DUMP_FOLDER
mkdir $DUMP_FOLDER

ls -Rla /sys/ > $DUMP_FOLDER/sysfs_tree
uname -a > $DUMP_FOLDER/sys_version
mkdir $DUMP_FOLDER/bin/
cp /usr/bin/platform-dump.sh $DUMP_FOLDER/bin/
cat /etc/os-release >> $DUMP_FOLDER/sys_version
cat /proc/interrupts > $DUMP_FOLDER/interrupts

dump_cmd "dmesg" "dmesg" "10"
dump_cmd "dmidecode -t1 -t2 -t 11" "dmidecode" "3"
dump_cmd "lsmod" "lsmod" "3"
dump_cmd "lspci -vvv" "lspci" "5"
dump_cmd "top -SHb -n 1 | tail -n +8 | sort -nrk 11" "top" "5"
dump_cmd "tail /sys/kernel/debug/mlxbf-ptm/monitors/status/*" "mlxbf-ptm-dump" "3"

tar czf /tmp/platform-dump.tar.gz -C $DUMP_FOLDER .
rm -rf $DUMP_FOLDER
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cfg/bluefield-modules.conf etc/modules-load.d/
udev/* etc/udev/rules.d/
modprobe.d/* etc/modprobe.d/
bin/* usr/bin/
systemd/* /lib/systemd/system/
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bluefield-platform-modules (1.0) unstable; urgency=low

* Initial Release

-- Oleksandr Ivantsiv <[email protected]> Fri, 23 Feb 2024 15:57:40 -0800
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Source: bluefield-platform-modules
Section: main
Priority: extra
Maintainer: Vivek Reddy Karri <[email protected]>
Build-Depends: debhelper (>= 8.0.0)
Standards-Version: 3.9.3

Package: bluefield-platform-modules
Version: 1.0
Architecture: arm64
Description: Kernel modules, udev rules, and system configuration files for the Nvidia Bluefield platform.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/make -f

export INSTALL_MOD_DIR:=extra

KVERSION ?= $(shell uname -r)
KERNEL_SRC := /lib/modules/$(KVERSION)
MOD_SRC_DIR:= $(shell pwd)/drivers

%:
dh $@

override_dh_auto_build:

override_dh_auto_install:
dh_installdirs -pbluefield-platform-modules $(KERNEL_SRC)/$(INSTALL_MOD_DIR);
cp $(MOD_SRC_DIR)/*.ko debian/bluefield-platform-modules/$(KERNEL_SRC)/$(INSTALL_MOD_DIR);

override_dh_clean:
dh_clean
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blacklist mlx5_core
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=DPU initialization routine
After=getty.target

[Service]
Type=oneshot
ExecStartPre=/usr/bin/bfrshlog "Linux up"
ExecStart=/usr/bin/bfrshlog "DPU is ready"
StandardOutput=journal+console

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

{% if driver_targets.strip() %}
{%- for k_module in driver_targets.strip().split() -%}
{{ k_module.split(".")[0] }}
{% endfor %}
{% endif -%}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# postinst script for sonic-platform-modules-bluefield2

set +e

depmod -a
{% if driver_targets.strip() %}
{%- for k_module in driver_targets.strip().split() -%}
modprobe {{ k_module.split(".")[0] }}
{% endfor %}
{% endif -%}

sync

systemctl enable [email protected]
systemctl enable [email protected]
systemctl enable [email protected]

#DEBHELPER#
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SUBSYSTEM=="net", ACTION=="add", DEVPATH=="/devices/pci0000:00/0000:00:00.0/0000:01:00.0/0000:02:00.0/0000:03:00.0/net/e*", ATTR{phys_port_name}=="p0", NAME="Ethernet0"
SUBSYSTEM=="net", ACTION=="add", DEVPATH=="/devices/pci0000:00/0000:00:00.0/0000:01:00.0/0000:02:00.0/0000:03:00.1/net/e*", ATTR{phys_port_name}=="p1", NAME="Ethernet4"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SUBSYSTEM=="net", ACTION=="add", DEVPATH=="/devices/platform/MLNXBF01:00/virtio1/net/eth*", NAME="tmfifo_net0"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SUBSYSTEM=="net", ACTION=="add", DEVPATH=="/devices/platform/MLNXBF17:00/net/e*", NAME="eth0"
59 changes: 59 additions & 0 deletions platform/nvidia-bluefield/docker-syncd-bluefield/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
##
## Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES.
## Apache-2.0
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##

{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %}
FROM docker-config-engine-bookworm-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}}

ARG docker_container_name

RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf

## Make apt-get non-interactive
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get install -y \
udev \
hwdata \
pciutils \
libpcap0.8 \
libxml2 \
python3-pip \
python3-dev \
python3-setuptools \
binutils-dev \
ethtool

{% if docker_syncd_bluefield_debs.strip() -%}
# Copy locally-built Debian package dependencies
{{ copy_files("debs/", docker_syncd_bluefield_debs.split(' '), "/debs/") }}

# Install locally-built Debian packages and implicitly install their dependencies
{{ install_debian_packages(docker_syncd_bluefield_debs.split(' ')) }}
{% endif %}

## Clean up
RUN apt-get clean -y && \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove python3-pip, python3-dev, and python3-setuptools.

apt-get autoclean -y && \
apt-get autoremove -y && \
rm -rf /debs

COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
COPY ["critical_processes", "/etc/supervisor/"]

ENTRYPOINT ["/usr/local/bin/supervisord"]
Empty file.
Loading