Since the ath10k driver is getting along nicely, I reckon its time to get proper
802.11ac support to OpenWrt. This patch introduces 802.11ac support to 
base-files,
mac80211 and hostapd. Since the changes overall are rather small, I decided to
put everything in a single patch. Let me know if you prefer this to be split up.
The patch introduces a new hwmode "11acna" to the uci wireless configuration 
file.
It is a bit superfluous, since ac implies n and a, but this was the approach 
that
to me seemed to involve least changes. Also, I didn't yet include support for
VHT160 split in two 80 MHz bands, since it requires an additional user supplied
parameter for the channel of the second band. I'm also not sure if ACS support 
in
hostapd is required for ac-support, but I included it anyway. Finally, actually
using 80 MHz channels requires a new regulatory database, which comes when
compat-wireless is updated (not included here).

Signed-off-by: Matti Laakso <malaa...@elisanet.fi>
---
Index: package/base-files/files/sbin/wifi
===================================================================
--- package/base-files/files/sbin/wifi  (revision 38640)
+++ package/base-files/files/sbin/wifi  (working copy)
@@ -62,7 +62,7 @@
 wifi_fixup_hwmode() {
        local device="$1"
        local default="$2"
-       local hwmode hwmode_11n
+       local hwmode hwmode_11n hwmode_11ac
config_get channel "$device" channel
        config_get hwmode "$device" hwmode
@@ -79,6 +79,12 @@
                        esac
                        config_set "$device" hwmode_11n "$hwmode_11n"
                ;;
+               11ac*)
+                       hwmode_11n=a
+                       hwmode_11ac=a
+                       config_set "$device" hwmode_11n "$hwmode_11n"
+                       config_set "$device" hwmode_11ac "$hwmode_11ac"
+               ;;
                *)
                        hwmode=
                        if [ "${channel:-0}" -gt 0 ]; then
Index: package/kernel/mac80211/files/lib/wifi/mac80211.sh
===================================================================
--- package/kernel/mac80211/files/lib/wifi/mac80211.sh  (revision 38640)
+++ package/kernel/mac80211/files/lib/wifi/mac80211.sh  (working copy)
@@ -41,6 +41,50 @@
                        done
                        [ -n "$ht_capab" ] && append base_cfg "ht_capab=$ht_capab" 
"$N"
                }
+               config_get hwmode_11ac "$device" hwmode_11ac
+               [ -n "$hwmode_11ac" ] && {
+                       hwmode="$hwmode_11ac"
+                       append base_cfg "ieee80211ac=1" "$N"
+                       config_get htmode "$device" htmode
+                       config_get vhtmode "$device" vhtmode
+                       config_get vht_capab_list "$device" vht_capab
+                       idx="$channel"
+                       case "$vhtmode" in
+                               VHT80)
+                                       case "$channel" in
+                                               36|40|44|48) idx=42;;
+                                               52|56|60|64) idx=58;;
+                                               100|104|108|112) idx=106;;
+                                               116|120|124|128) idx=122;;
+                                               132|136|140|144) idx=138;;
+                                               149|153|157|161) idx=155;;
+                                       esac
+                                       append base_cfg "vht_oper_chwidth=1" 
"$N"
+                                       append base_cfg 
"vht_oper_centr_freq_seg0_idx=$idx" "$N"
+                               ;;
+                               VHT160)
+                                       case "$channel" in
+                                               36|40|44|48|52|56|60|64) 
idx=50;;
+                                               
100|104|108|112|116|120|124|128) idx=114;;
+                                       esac
+                                       append base_cfg "vht_oper_chwidth=2" 
"$N"
+                                       append base_cfg 
"vht_oper_centr_freq_seg0_idx=$idx" "$N"
+                               ;;
+                               *)
+                                       case "$htmode" in
+                                               HT20) ;;
+                                               HT40+) idx=$((idx+2));;
+                                               HT40-) idx=$((idx-2));;
+                                       esac
+                                       append base_cfg "vht_oper_chwidth=0" 
"$N"
+                                       append base_cfg 
"vht_oper_centr_freq_seg0_idx=$idx" "$N"
+                               ;;
+                       esac
+                       for cap in $vht_capab_list; do
+                               vht_capab="$vht_capab[$cap]"
+                       done
+                       [ -n "$vht_capab" ] && append base_cfg "vht_capab=$vht_capab" 
"$N"
+               }
        }
local country_ie=0
@@ -602,6 +646,7 @@
                [ "$found" -gt 0 ] && continue
mode_11n=""
+               mode_11ac=""
                mode_band="g"
                channel="11"
                ht_cap=0
@@ -624,6 +669,40 @@
                        [ "$(($ht_cap & 768))" -eq 768 ] && append ht_capab "$list   
RX-STBC123" "$N"
                        [ "$(($ht_cap & 4096))" -eq 4096 ] && append ht_capab "$list 
DSSS_CCK-40" "$N"
                }
+               vht_cap=0
+               for cap in $(iw phy "$dev" info | awk -F "[()]" '/VHT 
Capabilities/ { print $2 }'); do
+                       vht_cap="$(($vht_cap | $cap))"
+               done
+               vht_capab="";
+               [ "$vht_cap" -gt 0 ] && {
+                       mode_11ac="ac"
+                       append vht_capab " option vhtmode  VHT80" "$N"
+                       
+                       list="     list vht_capab"
+                       [ "$(($vht_cap & 3))" -eq 1 ] && append vht_capab "$list     
MAX-MPDU-7991" "$N"
+                       [ "$(($vht_cap & 3))" -eq 2 ] && append vht_capab "$list     
MAX-MPDU-11454" "$N"
+                       [ "$(($vht_cap & 12))" -eq 4 ] && append vht_capab "$list    
VHT160" "$N"
+                       [ "$(($vht_cap & 12))" -eq 8 ] && append vht_capab "$list    
VHT160-80PLUS80" "$N"
+                       [ "$(($vht_cap & 16))" -eq 16 ] && append vht_capab "$list   
RXLDPC" "$N"
+                       [ "$(($vht_cap & 32))" -eq 32 ] && append vht_capab "$list   
SHORT-GI-80" "$N"
+                       [ "$(($vht_cap & 64))" -eq 64 ] && append vht_capab "$list   
SHORT-GI-160" "$N"
+                       [ "$(($vht_cap & 128))" -eq 128 ] && append vht_capab "$list 
TX-STBC-2BY1" "$N"
+                       [ "$(($vht_cap & 1792))" -eq 256 ] && append vht_capab "$list        
RX-STBC-1" "$N"
+                       [ "$(($vht_cap & 1792))" -eq 512 ] && append vht_capab "$list        
RX-STBC-12" "$N"
+                       [ "$(($vht_cap & 1792))" -eq 768 ] && append vht_capab "$list        
RX-STBC-123" "$N"
+                       [ "$(($vht_cap & 1792))" -eq 1024 ] && append vht_capab "$list       
RX-STBC-1234" "$N"
+                       [ "$(($vht_cap & 2048))" -eq 2048 ] && append vht_capab "$list       
SU-BEAMFORMER" "$N"
+                       [ "$(($vht_cap & 4096))" -eq 4096 ] && append vht_capab "$list       
SU-BEAMFORMEE" "$N"
+                       [ "$(($vht_cap & 524288))" -eq 524288 ] && append vht_capab "$list   
MU-BEAMFORMER" "$N"
+                       [ "$(($vht_cap & 1048576))" -eq 1048576 ] && append vht_capab "$list 
MU-BEAMFORMEE" "$N"
+                       [ "$(($vht_cap & 2097152))" -eq 2097152 ] && append vht_capab "$list 
VHT-TXOP-PS" "$N"
+                       [ "$(($vht_cap & 4194304))" -eq 4194304 ] && append vht_capab "$list 
HTC-VHT" "$N"
+                       [ "$(($vht_cap & 201326592))" -eq 134217728 ] && append vht_capab 
"$list     VHT-LINK-ADAPT2" "$N"
+                       [ "$(($vht_cap & 201326592))" -eq 201326592 ] && append vht_capab 
"$list     VHT-LINK-ADAPT3" "$N"
+                       [ "$(($vht_cap & 268435456))" -eq 268435456 ] && append vht_capab 
"$list     RX-ANTENNA-PATTERN" "$N"
+                       [ "$(($vht_cap & 536870912))" -eq 536870912 ] && append vht_capab 
"$list     TX-ANTENNA-PATTERN" "$N"
+               }
+               
                iw phy "$dev" info | grep -q '2412 MHz' || { mode_band="a"; 
channel="36"; }
if [ -x /usr/bin/readlink ]; then
@@ -638,9 +717,10 @@
 config wifi-device  radio$devidx
        option type     mac80211
        option channel  ${channel}
-       option hwmode   11${mode_11n}${mode_band}
+       option hwmode   11${mode_11ac}${mode_11n}${mode_band}
 $dev_id
 $ht_capab
+$vht_capab
        # REMOVE THIS LINE TO ENABLE WIFI:
        option disabled 1
Index: package/network/services/hostapd/files/hostapd-full.config
===================================================================
--- package/network/services/hostapd/files/hostapd-full.config  (revision 38640)
+++ package/network/services/hostapd/files/hostapd-full.config  (working copy)
@@ -139,6 +139,9 @@
 # IEEE 802.11n (High Throughput) support
 CONFIG_IEEE80211N=y
+# IEEE 802.11ac (Very High Throughput) support
+CONFIG_IEEE80211AC=y
+
 # Remove debugging code that is printing out debug messages to stdout.
 # This can be used to reduce the size of the hostapd considerably if debugging
 # code is not needed.
@@ -163,4 +166,28 @@
 CONFIG_WPS=y
 CONFIG_FULL_DYNAMIC_VLAN=y
+# Automatic Channel Selection
+# This will allow hostapd to pick the channel automatically when channel is set
+# to "acs_survey" or "0". Eventually, other ACS algorithms can be added in
+# similar way.
+#
+# Automatic selection is currently only done through initialization, later on
+# we hope to do background checks to keep us moving to more ideal channels as
+# time goes by. ACS is currently only supported through the nl80211 driver and
+# your driver must have survey dump capability that is filled by the driver
+# during scanning.
+#
+# You can customize the ACS survey algorithm with the hostapd.conf variable
+# acs_num_scans.
+#
+# Supported ACS drivers:
+# * ath9k
+# * ath5k
+# * ath10k
+#
+# For more details refer to:
+# http://wireless.kernel.org/en/users/Documentation/acs
+#
+CONFIG_ACS=y
+
 CONFIG_UBUS=y
Index: package/network/services/hostapd/files/hostapd-mini.config
===================================================================
--- package/network/services/hostapd/files/hostapd-mini.config  (revision 38640)
+++ package/network/services/hostapd/files/hostapd-mini.config  (working copy)
@@ -138,6 +138,9 @@
 # IEEE 802.11n (High Throughput) support
 CONFIG_IEEE80211N=y
+# IEEE 802.11ac (Very High Throughput) support
+CONFIG_IEEE80211AC=y
+
 # Remove debugging code that is printing out debug messages to stdout.
 # This can be used to reduce the size of the hostapd considerably if debugging
 # code is not needed.
@@ -156,4 +159,28 @@
CONFIG_NO_DUMP_STATE=y +# Automatic Channel Selection
+# This will allow hostapd to pick the channel automatically when channel is set
+# to "acs_survey" or "0". Eventually, other ACS algorithms can be added in
+# similar way.
+#
+# Automatic selection is currently only done through initialization, later on
+# we hope to do background checks to keep us moving to more ideal channels as
+# time goes by. ACS is currently only supported through the nl80211 driver and
+# your driver must have survey dump capability that is filled by the driver
+# during scanning.
+#
+# You can customize the ACS survey algorithm with the hostapd.conf variable
+# acs_num_scans.
+#
+# Supported ACS drivers:
+# * ath9k
+# * ath5k
+# * ath10k
+#
+# For more details refer to:
+# http://wireless.kernel.org/en/users/Documentation/acs
+#
+CONFIG_ACS=y
+
 CONFIG_UBUS=y
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to