sonic-buildimage/platform/broadcom/saibcm-modules/debian/opennsl-modules.init
byu343 6581decf38
[saibcm-modules]: Add linux_ngknet for trident4/tomahawk4 chips (#10517)
Why I did it
For trident4/tomahawk4, linux_ngknet.ko and linux_ngknetcb.ko have to be installed. Also, the kernel modules to load on such chips are different from existing ones, so we add an option is_ltsw_chip to determine the kernel modules to load. The option is_ltsw_chip is controlled by adding 'is_ltsw_chip=1' to platform_env.conf or not.

How to verify it
We verified that existing platforms still work after this change; and for platforms with trident4/tomahawk4, we can load the different kernel modules as expected after adding 'is_ltsw_chip=1' to platform_env.conf
2022-04-09 10:46:09 -07:00

137 lines
3.3 KiB
Bash
Executable File

#!/bin/bash
# This script load/unload opennsl kernel modules
### BEGIN INIT INFO
# Provides: load-opennsl-modules
# Required-Start:
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: S
# Default-Stop: 0 6
# Short-Description: Load OpenNSL kernel modules
### END INIT INFO
function create_devices()
{
if [[ $is_ltsw_chip -eq 1 ]]; then
rm -f /dev/linux_ngbde
rm -f /dev/linux_ngknet
rm -f /dev/linux_ngknetcb
mknod /dev/linux_ngbde c 120 0
mknod /dev/linux_ngknet c 121 0
mknod /dev/linux_ngknetcb c 122 0
else
rm -f /dev/linux-knet-cb
rm -f /dev/linux-bcm-knet
rm -f /dev/linux-bcm-bde
rm -f /dev/linux-kernel-bde
rm -f /dev/linux_ngbde
mknod /dev/linux_ngbde c 120 0
mknod /dev/linux-knet-cb c 121 0
mknod /dev/linux-bcm-knet c 122 0
mknod /dev/linux-bcm-bde c 126 0
mknod /dev/linux-kernel-bde c 127 0
fi
}
# linux-kernel-bde debug=4 ==> Verbose level debug
# dma_debug=1 ==> Enable DMA debug
# linux-bcm-knet debug=0x5020 ==> Enable KNET Warning(0x1000),
# Events(0x20) and Instance(0x4000)
# level logs
function load_kernel_modules()
{
if [[ $is_ltsw_chip -eq 1 ]]; then
insmod /lib/modules/$(uname -r)/extra/psample.ko
modprobe linux_ngbde
modprobe linux_ngknet
modprobe linux_ngknetcb
else
modprobe linux-kernel-bde dmasize=$dmasize maxpayload=128 debug=4 dma_debug=1 usemsi=$usemsi
modprobe linux-user-bde
# Using insmod with absolute path for psample to make sure bcm psample is loaded.
# There is a different psample.ko module getting created at net/psample/psample.ko
insmod /lib/modules/$(uname -r)/extra/psample.ko
modprobe linux-bcm-knet use_rx_skb=1 rx_buffer_size=9238 debug=0x5020 default_mtu=9100
modprobe linux-knet-cb
modprobe linux_ngbde
fi
}
function remove_kernel_modules()
{
if [[ $is_ltsw_chip -eq 1 ]]; then
rmmod linux_ngknetcb
rmmod linux_ngknet
rmmod linux_ngbde
rmmod psample.ko
else
rmmod psample.ko
rmmod linux-knet-cb
rmmod linux-bcm-knet
rmmod linux-user-bde
rmmod linux-kernel-bde
rmmod linux_ngbde
fi
}
function load_platform_env()
{
. /host/machine.conf
if [ -n "$aboot_platform" ]; then
platform=$aboot_platform
elif [ -n "$onie_platform" ]; then
platform=$onie_platform
else
platform="unknown"
fi
# Set the default configuration for dmasize and usemsi parameters
dmasize=32M
usemsi=0
is_ltsw_chip=0
# Source the platform env file
env_file="/usr/share/sonic/device/$platform/platform_env.conf"
source $env_file
}
case "$1" in
start)
echo -n "Load OpenNSL kernel modules... "
load_platform_env
create_devices
load_kernel_modules
echo "done."
;;
stop)
echo -n "Unload OpenNSL kernel modules... "
load_platform_env
remove_kernel_modules
echo "done."
;;
force-reload|restart)
echo "Not supported"
;;
*)
echo "Usage: /etc/init.d/opennsl-modules.init {start|stop}"
exit 1
;;
esac
exit 0