wifi-scripts: fix setting tx power on some drivers
authorFelix Fietkau <nbd@nbd.name>
Sat, 4 Jan 2025 10:52:50 +0000 (11:52 +0100)
committerFelix Fietkau <nbd@nbd.name>
Sat, 4 Jan 2025 10:55:04 +0000 (11:55 +0100)
On some drivers, setting the tx power on the interface is not enough.
Set it for the phy as well.

Fixes: 04fb05914ea7 ("wifi-scripts: add multi-radio config support")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
package/network/config/wifi-scripts/files-ucode/lib/netifd/wireless/mac80211.sh
package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh

index 93ab404d57cf12f851bed5146633dd9d3bd9e80b..9b86abcee5d2155340e98f1dc2f48574e33af1c0 100755 (executable)
@@ -195,6 +195,7 @@ function setup_phy(phy, config, data) {
        log(`Configuring '${phy}' txantenna: ${config.txantenna}, rxantenna: ${config.rxantenna} distance: ${config.distance}`);
        system(`iw phy ${phy} set antenna ${config.txantenna} ${config.rxantenna}`);
        system(`iw phy ${phy} set distance ${config.distance}`);
+       system(`iw phy ${phy} set txpower ${config.txpower}`);
 
        if (config.frag)
                system(`iw phy ${phy} set frag ${frag}`);
index 5d9bf8ee09eb80520087a1481b4a5efb556fc994..9e9922e0b35ffc7cb3c3412c3ef7ab7de580c2dd 100755 (executable)
@@ -1210,6 +1210,14 @@ drv_mac80211_setup() {
        wdev_tool "$phy$phy_suffix" set_config "$(json_dump)" $active_ifnames
        json_set_namespace "$prev"
 
+       [ -z "$phy_suffix" ] && {
+               if [ -n "$txpower" ]; then
+                       iw phy "$phy" set txpower fixed "${txpower%%.*}00"
+               else
+                       iw phy "$phy" set txpower auto
+               fi
+       }
+
        for_each_interface "ap sta adhoc mesh monitor" mac80211_set_vif_txpower
        wireless_set_up
 }