Created
October 9, 2024 23:13
-
-
Save qosmio/9e2c6c7d6245397e491b8ddb0ad6d6bc to your computer and use it in GitHub Desktop.
Script to reload ath11k/ath10k for NSS or non-NSS builds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -x | |
# shellcheck disable=2070,2144 | |
# | |
# This script is used to reload the ath11k/ath10k driver without | |
# requiring a reboot. It is intended to be used for debugging purposes | |
# when trying new drivers, firmware, or disabling NSS wifi offload. | |
# Save this script to `/usr/bin/ath_reload` and make it executable. | |
# By default, the script will reload the driver with whatever options | |
# are currently set in the kernel module. | |
# | |
# You can also pass options: | |
# | |
# To disable NSS offload: | |
# ath_reload nss_offload=0 nss_redirect=0 | |
# | |
# To reenable NSS offload after disabling it: | |
# ath_reload nss_offload=1 | |
# | |
# For tri-band devices that use ath11k + ath10k: | |
# ath_reload nss_offload=1 nss_redirect=1 | |
# | |
# NOTE: There is NO need to enable `nss_redirect=1` for ath11k ONLY devices. | |
# It should technically already be off. | |
# | |
# Don't specify `frame_mode` unless you know what you're doing. | |
# The default is 2 (ethernet frames). | |
# | |
# This script will output everything it's doing to the console, and run | |
# `logread -l40 -f` to show you system log. You can `CTRL+C` to exit. | |
# | |
# It is advised you run this over a wired connection or serial console. | |
if [ -r /sys/module/ath11k/parameters/nss_offload ]; then | |
[ -z "$nss_redirect" ] && nss_redirect=$(cat /sys/module/mac80211/parameters/nss_redirect 2> /dev/null) | |
[ -z "$nss_offload" ] && nss_offload=$(cat /sys/module/ath11k/parameters/nss_offload 2> /dev/null) | |
nss_redirect="nss_redirect=${nss_redirect:-0}" | |
nss_offload="nss_offload=${nss_offload:-1}" | |
fi | |
[ -z "$frame_mode" ] && frame_mode=$(cat /sys/module/ath11k/parameters/frame_mode 2> /dev/null) | |
[ -z "$debug_mask" ] && debug_mask=$(cat /sys/module/ath11k/parameters/debug_mask 2> /dev/null) | |
frame_mode=${frame_mode:-2} | |
debug_mask=${debug_mask:-0x0} | |
[ -r /etc/init.d/qca-nss-ecm ] && service qca-nss-ecm stop | |
/etc/init.d/wpad stop | |
/sbin/wifi down | |
lsmod | sort -k1,3r | awk '$1 ~ /ath10k|ath11k/{print $1}' | while read -r module; do rmmod "$module"; done | |
rmmod ath | |
rmmod mac80211 | |
rmmod cfg80211 | |
sleep 1 | |
modprobe cfg80211 | |
insmod mac80211 "${nss_redirect}" | |
insmod ath11k frame_mode="${frame_mode}" "${nss_offload}" debug_mask="${debug_mask}" "$@" | |
modprobe ath11k_ahb | |
[ -r /lib/modules/*/ath10k_pci.ko ] && { | |
[ -z "$ath10k_debug_mask" ] && debug_mask=$(cat /sys/module/ath10k_core/parameters/debug_mask 2> /dev/null) | |
ath10k_debug_mask=${ath10k_debug_mask:-0x0} | |
modprobe ath | |
insmod ath10k_core debug_mask="${ath10k_debug_mask}" | |
modprobe ath10k_pci | |
} | |
[ -r /etc/init.d/qca-nss-ecm ] && service qca-nss-ecm start | |
/etc/init.d/wpad start | |
/sbin/wifi up | |
[ -n $SHLVL ] && [ $SHLVL -gt 0 ] && logread -l40 -f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment