mediatek: tune smp settings

This commit is contained in:
hanwckf 2024-01-14 20:32:23 +08:00
parent 302556c1ac
commit 35722caede
2 changed files with 31 additions and 8 deletions

View File

@ -204,7 +204,7 @@ MT7986_dbdc1()
MT7981_whnat()
{
num_of_wifi=$1
storage=$2
is_usbnet=$2
DEFAULT_RPS=0
#Physical IRQ# setting
@ -244,6 +244,7 @@ MT7981_whnat()
CPU0_RPS="$ethif1 $ethif2 $wifi1 $wifi2 $wifi1_apcli0 $wifi2_apcli0"
CPU1_RPS=" $wifi1 $wifi2 $wifi1_apcli0 $wifi2_apcli0"
[ "$is_usbnet" = "1" ] && CPU1_RPS="$wifi1_apcli0 $wifi2_apcli0"
elif [ "$num_of_wifi" = "3" ]; then
CPU0_AFFINITY="$eth_tx $eth_rx0"
CPU1_AFFINITY="$PCIe0 $wifi1_irq $wifi2_irq $wifi3_irq $usb"
@ -669,6 +670,24 @@ scan_wifi_num()
dbg "# NUM_OF_WIFI=$NUM_OF_WIFI band(s)"
}
scan_usbnet()
{
for dev in /sys/class/net/*; do
[ -d "$dev" ] || continue
dev_name=$(basename $dev)
dev_prefix="${dev_name%%[0-9]*}"
if [ "$dev_prefix" = "usb" ] || [ "$dev_prefix" = "wwan" ]; then
IS_USBNET=1
return
fi
done
}
get_usbnet()
{
echo $IS_USBNET
}
get_wifi_num()
{
echo $NUM_OF_WIFI
@ -709,8 +728,9 @@ setup_model()
board=$(board_name)
num_of_wifi=$(get_wifi_num)
mt_whnat_en=$(module_exist "mt_whnat")
usbnet=$(get_usbnet)
logger -t "mtk_smp" "board=${board}, wifi_num=${num_of_wifi}, cpu_num=${NUM_OF_CPU}"
logger -t "mtk_smp" "board=${board}, wifi_num=${num_of_wifi}, cpu_num=${NUM_OF_CPU}, usbnet=${usbnet}"
case $board in
xiaomi,redmi-router-ax6000* |\
@ -720,7 +740,7 @@ setup_model()
jdcloud,re-cp-03 |\
tplink,tl-xdr608* |\
*7986*)
MT7986_whnat $num_of_wifi
MT7986_whnat $num_of_wifi $usbnet
;;
*mt3000* |\
glinet,x3000-emmc |\
@ -738,7 +758,7 @@ setup_model()
konka,komi-a31 |\
nradio,wt9103 |\
*7981*)
MT7981_whnat $num_of_wifi
MT7981_whnat $num_of_wifi $usbnet
;;
*)
if [ "$NUM_OF_CPU" = "4" ]; then
@ -873,6 +893,8 @@ RPS_IF_LIST="" # setup by getEthIfName/getWiFiIfName/every model
get_eth_if_name
get_wifi_if_name # It will add all wifi interfaces into $RPS_IF_LIST
dbg2 "# default RPS_IF_LIST=$RPS_IF_LIST"
IS_USBNET=0
scan_usbnet
setup_model
set_rps_cpu_bitmap
set_rps_cpus $DEFAULT_RPS

View File

@ -1,13 +1,14 @@
#!/bin/sh
[ "$ACTION" = add ] || exit
NPROCS="$(grep -c "^processor.*:" /proc/cpuinfo)"
[ "$NPROCS" -gt 1 ] || exit
IFNAME_PREFIX="${INTERFACE%%[0-9]*}"
if [ "${IFNAME_PREFIX}" = "usb" ] || [ "${IFNAME_PREFIX}" = "wwan" ]; then
# set usb/wwan rps to cpu0
echo 1 > /sys/class/net/${INTERFACE}/queues/rx-0/rps_cpus
if [ "$ACTION" = add ]; then
# set usb/wwan rps to cpu0
echo 1 > /sys/class/net/${INTERFACE}/queues/rx-0/rps_cpus
fi
[ -f /etc/init.d/mtk_smp ] && /etc/init.d/mtk_smp restart
fi