Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nvidia-bluefield] Add support for new "nvidia-bluefield" platform. #21

Closed
wants to merge 1 commit into from
Closed
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
5 changes: 5 additions & 0 deletions platform/nvidia-bluefield/bfscripts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ignore everything in this directory
*
# Except these files
!.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 @@
#
# 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 @@
#
# Copyright (c) 2021-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)/
67 changes: 67 additions & 0 deletions platform/nvidia-bluefield/bluefield-platform-modules/bin/bfnet.sh
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/dhclient.$cp_iface.pid
leasefile=/var/lib/dhcp/dhclient.$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 <oivantsiv@nvidia.com> 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 <vkarri@nvidia.com>
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.
19 changes: 19 additions & 0 deletions platform/nvidia-bluefield/bluefield-platform-modules/debian/rules
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,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 serial-getty@hvc0.service
systemctl enable serial-getty@ttyAMA0.service
systemctl enable serial-getty@ttyAMA1.service

#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"
Loading