Skip to content

Commit dc2b7dc

Browse files
oleksandrivantsivvivekrnvYakiv-Huryk
committed
[nvidia-bluefield] Add support for new "nvidia-bluefield" platform.
Signed-off-by: Oleksandr Ivantsiv <[email protected]> Co-authored-by: Vivek Reddy <[email protected]> Co-authored-by: Yakiv Huryk <[email protected]>
1 parent 9fdbdee commit dc2b7dc

File tree

123 files changed

+5653
-0
lines changed

Some content is hidden

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

123 files changed

+5653
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Ignore everything in this directory
2+
*
3+
# Except these files
4+
!.gitignore
5+
!Makefile
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#
2+
# Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES.
3+
# Apache-2.0
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
.ONESHELL:
19+
SHELL = /bin/bash
20+
.SHELLFLAGS += -ex
21+
22+
$(addprefix $(DEST)/, $(MLNX_BLUEFIELD_BUILD_SCRIPTS)): $(DEST)/% :
23+
rm -rf ./tmp/
24+
mkdir ./tmp/
25+
pushd ./tmp/
26+
27+
wget -O ${MLNX_BLUEFIELD_BUILD_SCRIPTS} "${BSD_BASE_URL}/build/install/distro/DEBS/${MLNX_BLUEFIELD_BUILD_SCRIPTS}"
28+
29+
mkdir -p bfscripts/DEBIAN
30+
dpkg -e ${MLNX_BLUEFIELD_BUILD_SCRIPTS} bfscripts/DEBIAN
31+
dpkg -x ${MLNX_BLUEFIELD_BUILD_SCRIPTS} bfscripts
32+
rm -f ${MLNX_BLUEFIELD_BUILD_SCRIPTS}
33+
34+
# Remove postinst script as we don't want to enable systemd services from the package.
35+
# We are interested only in a couple of scripts that package has.
36+
rm -f bfscripts/DEBIAN/postinst
37+
38+
dpkg -b bfscripts ./
39+
40+
mv ${MLNX_BLUEFIELD_BUILD_SCRIPTS} $(DEST)/
41+
popd
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#
2+
# Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES.
3+
# Apache-2.0
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
.ONESHELL:
19+
SHELL = /bin/bash
20+
.SHELLFLAGS += -e
21+
22+
$(addprefix $(DEST)/, $(BF_PLATFORM_MODULE)): $(DEST)/% :
23+
24+
# Clean up
25+
rm -rf drivers/* \
26+
cfg/bluefield-modules.conf \
27+
debian/bluefield-platform-modules.postinst
28+
29+
mkdir -p drivers/
30+
mkdir -p cfg/
31+
32+
$(foreach kernel_module, $(BF_PLATFORM_DRIVERS), \
33+
cp $(PROJECT_ROOT)/$(FILES_PATH)/$(kernel_module) drivers/
34+
)
35+
36+
export driver_targets="$(BF_PLATFORM_DRIVERS)"
37+
export kversion="$(KVERSION)"
38+
j2 templates/bluefield-platform-modules.postinst.j2 > debian/bluefield-platform-modules.postinst
39+
j2 templates/bluefield-modules.conf.j2 > cfg/bluefield-modules.conf
40+
41+
chmod +x debian/bluefield-platform-modules.postinst
42+
chmod 0644 cfg/bluefield-modules.conf
43+
44+
DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -rfakeroot -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS)
45+
46+
mv ../$(BF_PLATFORM_MODULE) $(DEST)/
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES.
4+
# Apache-2.0
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
cp_iface=Ethernet0
20+
pidfile=/run/dhclient.$cp_iface.pid
21+
leasefile=/var/lib/dhcp/dhclient.$cp_iface.leases
22+
23+
stop_cp_dhclient()
24+
{
25+
if [[ -f $pidfile ]]; then
26+
kill $(cat $pidfile)
27+
rm -f $pidfile
28+
fi
29+
rm -f $leasefile
30+
}
31+
32+
start_cp_dhclient()
33+
{
34+
stop_cp_dhclient
35+
36+
/sbin/dhclient -pf $pidfile -lf $leasefile $cp_iface -nw
37+
}
38+
39+
start()
40+
{
41+
modprobe mlx5_core
42+
/usr/bin/mst start
43+
44+
hwsku=$(sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["hwsku"]')
45+
if [[ $hwsku == *"-C1" ]]; then
46+
start_cp_dhclient
47+
fi
48+
}
49+
50+
stop()
51+
{
52+
stop_cp_dhclient
53+
54+
/usr/bin/mst stop
55+
rmmod mlx5_ib mlx5_core
56+
}
57+
58+
case "$1" in
59+
start|stop)
60+
$1
61+
;;
62+
*)
63+
echo "Usage: $0 {start|stop}"
64+
exit 1
65+
;;
66+
esac
67+
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES.
4+
# Apache-2.0
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
DUMP_FOLDER="/tmp/platform-dump"
20+
21+
dump_cmd () {
22+
cmd=$1
23+
output_fname=$2
24+
timeout=$3
25+
cmd_name=${cmd%% *}
26+
27+
if [ -x "$(command -v $cmd_name)" ];
28+
then
29+
# ignore shellcheck message SC2016. Arguments should be single-quoted (')
30+
run_cmd="$cmd > $DUMP_FOLDER/$output_fname"
31+
timeout "$timeout" bash -c "$run_cmd"
32+
fi
33+
}
34+
35+
rm -rf $DUMP_FOLDER
36+
mkdir $DUMP_FOLDER
37+
38+
ls -Rla /sys/ > $DUMP_FOLDER/sysfs_tree
39+
uname -a > $DUMP_FOLDER/sys_version
40+
mkdir $DUMP_FOLDER/bin/
41+
cp /usr/bin/platform-dump.sh $DUMP_FOLDER/bin/
42+
cat /etc/os-release >> $DUMP_FOLDER/sys_version
43+
cat /proc/interrupts > $DUMP_FOLDER/interrupts
44+
45+
dump_cmd "dmesg" "dmesg" "10"
46+
dump_cmd "dmidecode -t1 -t2 -t 11" "dmidecode" "3"
47+
dump_cmd "lsmod" "lsmod" "3"
48+
dump_cmd "lspci -vvv" "lspci" "5"
49+
dump_cmd "top -SHb -n 1 | tail -n +8 | sort -nrk 11" "top" "5"
50+
dump_cmd "tail /sys/kernel/debug/mlxbf-ptm/monitors/status/*" "mlxbf-ptm-dump" "3"
51+
52+
tar czf /tmp/platform-dump.tar.gz -C $DUMP_FOLDER .
53+
rm -rf $DUMP_FOLDER
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cfg/bluefield-modules.conf etc/modules-load.d/
2+
udev/* etc/udev/rules.d/
3+
modprobe.d/* etc/modprobe.d/
4+
bin/* usr/bin/
5+
systemd/* /lib/systemd/system/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
bluefield-platform-modules (1.0) unstable; urgency=low
2+
3+
* Initial Release
4+
5+
-- Oleksandr Ivantsiv <[email protected]> Fri, 23 Feb 2024 15:57:40 -0800
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
10
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Source: bluefield-platform-modules
2+
Section: main
3+
Priority: extra
4+
Maintainer: Vivek Reddy Karri <[email protected]>
5+
Build-Depends: debhelper (>= 8.0.0)
6+
Standards-Version: 3.9.3
7+
8+
Package: bluefield-platform-modules
9+
Version: 1.0
10+
Architecture: arm64
11+
Description: Kernel modules, udev rules, and system configuration files for the Nvidia Bluefield platform.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/make -f
2+
3+
export INSTALL_MOD_DIR:=extra
4+
5+
KVERSION ?= $(shell uname -r)
6+
KERNEL_SRC := /lib/modules/$(KVERSION)
7+
MOD_SRC_DIR:= $(shell pwd)/drivers
8+
9+
%:
10+
dh $@
11+
12+
override_dh_auto_build:
13+
14+
override_dh_auto_install:
15+
dh_installdirs -pbluefield-platform-modules $(KERNEL_SRC)/$(INSTALL_MOD_DIR);
16+
cp $(MOD_SRC_DIR)/*.ko debian/bluefield-platform-modules/$(KERNEL_SRC)/$(INSTALL_MOD_DIR);
17+
18+
override_dh_clean:
19+
dh_clean

0 commit comments

Comments
 (0)