From d5be7814b34959c3ec8ad39080ff76eaf7571b8c Mon Sep 17 00:00:00 2001 From: Joe AE6XE Date: Sun, 24 Feb 2019 14:03:24 -0800 Subject: [PATCH] aredn: enable ath9k auto distance capability (#367) --- configs/common.config | 1 + files/www/cgi-bin/setup | 27 ++++++------ files/www/help.html | 10 ++++- patches/712-auto-distance-settings.patch | 54 ++++++++++++++++++++++++ patches/series | 1 + 5 files changed, 79 insertions(+), 14 deletions(-) create mode 100644 patches/712-auto-distance-settings.patch diff --git a/configs/common.config b/configs/common.config index 16baf4d0..5a5539cf 100644 --- a/configs/common.config +++ b/configs/common.config @@ -104,3 +104,4 @@ CONFIG_PACKAGE_kmod-ipip=y CONFIG_IMAGEOPT=y CONFIG_VERSIONOPT=y CONFIG_VERSION_DIST="AREDN" +CONFIG_PACKAGE_ATH_DYNACK=y diff --git a/files/www/cgi-bin/setup b/files/www/cgi-bin/setup index 0926144b..6280dfa3 100755 --- a/files/www/cgi-bin/setup +++ b/files/www/cgi-bin/setup @@ -189,12 +189,19 @@ $parms{wifi_txpower} = $wifi_txpower; if(($parms{button_apply} or $parms{button_save}) and $wifi_enable ) { - if($wifi_distance < 1 or $wifi_distance =~ /\D/) + if($wifi_distance < 0 or $wifi_distance =~ /\D/) { push (@errors, "invalid distance value"); } else { $cmd = ""; - $cmd .= "iw phy ${phy} set distance $wifi_distance >/dev/null 2>&1;"; + if ( $wifi_distance eq "0" ) + { + $cmd .= "iw phy ${phy} set distance auto >/dev/null 2>&1;"; + } + else + { + $cmd .= "iw phy ${phy} set distance $wifi_distance >/dev/null 2>&1;"; + } $cmd .= "iw dev $wifiintf set txpower fixed ${wifi_txpower}00 >/dev/null 2>&1;"; system $cmd; } @@ -555,12 +562,8 @@ function updDist(x) { document.getElementsByName('wifi_distance_disp_meters')[0].value = xc; dist_meters.value = xc; - // if default, then ALERT! - if(dist_meters.value==0) { - distBox.className = 'dist-alert'; - } else { - distBox.className = 'dist-norm'; - } + // default of 0 means 'auto', so full range is always dist-norm + distBox.className = 'dist-norm'; } @@ -757,15 +760,15 @@ if ( ${wifi_enable} ) for($i = wifi_maxpower($wifi_channel); $i >= 1; --$i) { selopt($i+$txpoweroffset ." dBm", $i, $wifi_txpower) } print "  \n"; - print "Distance to
FARTHEST Neighbor\n"; + print "Distance to
FARTHEST Neighbor

'0' is auto

\n"; $wifi_distance=int($wifi_distance); # in meters $wifi_distance_disp_km=int($wifi_distance/1000); $wifi_distance_disp_miles=sprintf("%.2f",$wifi_distance_disp_km*.621371192); - print " miles
"; - print " kilometers
"; - print " meters
"; + print " mi
"; + print " km
"; + print " m
"; print "
"; print ""; diff --git a/files/www/help.html b/files/www/help.html index ff9579c0..2fe9d5be 100644 --- a/files/www/help.html +++ b/files/www/help.html @@ -371,12 +371,18 @@ The Distance setting adjusts the RF retry timer to define how long the transmitter will wait for an acknowledgement from a Neighbor station. If the distance parameter is too short, then the transmitter will send duplicate data packets before the acknowledgement -has had time to return. This value is only applicable to nodes that can +has had time to return. If the distance parameter is too long, then the +transmitter will wait extra time before considering the data lost to re-transmit. +This value is only applicable to nodes that can be communicated with directly over RF and not multiple hop nodes on the greater mesh network. The value should be set to the distance in meters to the farthest direct RF node you expect to communicate with. Change the distance value by moving the slider. Distance values will be in multiples -of 1000 meters (approximately 0.62 miles). A value of zero is not allowed. +of 1000 meters (approximately 0.62 miles). A value of '0' will cause +the radio to auto determine the RF retry timer based on measuring the +actual time it takes acknowledgement packets to be received back. The +automatic timer is set using a Exponential Weighted Moving Average (EWMA) method. +'auto' is the default setting and in most all situations the optimal setting. The best way to test an optimal distance settings is to do an 'iperf' test directly between 2 nodes to measure the performance of this RF channel. Try different distance settings to peak out the iperf throughput. diff --git a/patches/712-auto-distance-settings.patch b/patches/712-auto-distance-settings.patch new file mode 100644 index 00000000..213e2bed --- /dev/null +++ b/patches/712-auto-distance-settings.patch @@ -0,0 +1,54 @@ +Index: openwrt/package/kernel/mac80211/patches/569-dynack-aredn-long-dist-defaults.patch +=================================================================== +--- /dev/null ++++ openwrt/package/kernel/mac80211/patches/569-dynack-aredn-long-dist-defaults.patch +@@ -0,0 +1,32 @@ ++--- a/drivers/net/wireless/ath/ath9k/dynack.c +++++ b/drivers/net/wireless/ath/ath9k/dynack.c ++@@ -21,7 +21,8 @@ ++ #define COMPUTE_TO (5 * HZ) ++ #define LATEACK_DELAY (10 * HZ) ++ #define LATEACK_TO 256 ++-#define MAX_DELAY 300 +++/* AREDN max distance set to 150km */ +++#define MAX_DELAY 1054 ++ #define EWMA_LEVEL 96 ++ #define EWMA_DIV 128 ++ ++@@ -293,7 +294,8 @@ ++ void ath_dynack_node_init(struct ath_hw *ah, struct ath_node *an) ++ { ++ /* ackto = slottime + sifs + air delay */ ++- u32 ackto = 9 + 16 + 64; +++ /* AREDN starting point is 20km */ +++ u32 ackto = 9 + 16 + 171; ++ struct ath_dynack *da = &ah->dynack; ++ ++ an->ackto = ackto; ++@@ -328,7 +330,8 @@ ++ void ath_dynack_reset(struct ath_hw *ah) ++ { ++ /* ackto = slottime + sifs + air delay */ ++- u32 ackto = 9 + 16 + 64; +++ /* AREDN starting point is 20km */ +++ u32 ackto = 9 + 16 + 171; ++ struct ath_dynack *da = &ah->dynack; ++ ++ da->lto = jiffies; +Index: openwrt/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh +=================================================================== +--- openwrt.orig/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh ++++ openwrt/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh +@@ -788,7 +788,11 @@ drv_mac80211_setup() { + + iw phy "$phy" set antenna $txantenna $rxantenna >/dev/null 2>&1 + iw phy "$phy" set antenna_gain $antenna_gain +- iw phy "$phy" set distance "$distance" ++ if [ $distance -eq 0 -a -d /sys/kernel/debug/ieee80211/$phy/ath9k ]; then ++ iw phy "$phy" set distance auto ++ else ++ iw phy "$phy" set distance "$distance" ++ fi + + [ -n "$frag" ] && iw phy "$phy" set frag "${frag%%.*}" + [ -n "$rts" ] && iw phy "$phy" set rts "${rts%%.*}" diff --git a/patches/series b/patches/series index 21af57df..f3201eba 100644 --- a/patches/series +++ b/patches/series @@ -21,3 +21,4 @@ 709-iperf-fw-restart.patch 710-no-ping6-traceroute6.patch 711-nano-xw-switch-config.patch +712-auto-distance-settings.patch