From 35722caede41709581f938f2958f4a09653e5e6a Mon Sep 17 00:00:00 2001 From: hanwckf Date: Sun, 14 Jan 2024 20:32:23 +0800 Subject: [PATCH] mediatek: tune smp settings --- package/mtk/applications/mtk-smp/files/smp.sh | 30 ++++++++++++++++--- .../hotplug.d/net/30-ext-devices-rps-setting | 9 +++--- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/package/mtk/applications/mtk-smp/files/smp.sh b/package/mtk/applications/mtk-smp/files/smp.sh index af610fe5d4..e764a3f07f 100755 --- a/package/mtk/applications/mtk-smp/files/smp.sh +++ b/package/mtk/applications/mtk-smp/files/smp.sh @@ -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 diff --git a/target/linux/mediatek/base-files/etc/hotplug.d/net/30-ext-devices-rps-setting b/target/linux/mediatek/base-files/etc/hotplug.d/net/30-ext-devices-rps-setting index dcfb8dc66b..494552c664 100644 --- a/target/linux/mediatek/base-files/etc/hotplug.d/net/30-ext-devices-rps-setting +++ b/target/linux/mediatek/base-files/etc/hotplug.d/net/30-ext-devices-rps-setting @@ -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