[OpenWrt-Devel] [PATCH 1/2] wifi: Introduce 802.11ac support

2014-01-16 Thread Sven Eckelmann
From: Matti Laakso malaa...@elisanet.fi

This patch introduces 802.11ac support to base-files, mac80211 and hostapd. The
split of VHT160 in two 80 MHz bands is not yet supported, since it requires an
additional user supplied parameter for the channel of the second band.

Signed-off-by: Matti Laakso malaa...@elisanet.fi
Signed-off-by: Simon Wunderlich si...@open-mesh.com
[s...@open-mesh.com: Rebased patch, renamed hwmode to ac,
fixed hostapd integration]
Signed-off-by: Sven Eckelmann s...@open-mesh.com
---
 package/base-files/files/sbin/wifi |  9 +++-
 .../mac80211/files/lib/netifd/wireless/mac80211.sh | 43 ++
 package/kernel/mac80211/files/lib/wifi/mac80211.sh | 51 +-
 .../config/netifd/patches/002-vht_support.patch| 42 ++
 .../services/hostapd/files/hostapd-full.config |  3 ++
 .../services/hostapd/files/hostapd-mini.config |  3 ++
 6 files changed, 148 insertions(+), 3 deletions(-)
 create mode 100644 package/network/config/netifd/patches/002-vht_support.patch

diff --git a/package/base-files/files/sbin/wifi 
b/package/base-files/files/sbin/wifi
index 051bc89..2c6de96 100755
--- a/package/base-files/files/sbin/wifi
+++ b/package/base-files/files/sbin/wifi
@@ -72,7 +72,7 @@ prepare_key_wep() {
 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
@@ -89,6 +89,12 @@ wifi_fixup_hwmode() {
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
@@ -203,6 +209,7 @@ scan_wifi() {
append DEVICES $section
config_set $section vifs 
config_set $section ht_capab 
+   config_set $section vht_capab 
;;
esac
 
diff --git a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh 
b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
index 1896fe0..301ec22 100644
--- a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
+++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
@@ -23,6 +23,7 @@ drv_mac80211_init_device_config() {
config_add_int rxantenna txantenna antenna_gain txpower
config_add_boolean noscan
config_add_array ht_capab
+   config_add_array vht_capab
 }
 
 drv_mac80211_init_iface_config() {
@@ -63,6 +64,48 @@ mac80211_hostapd_setup_base() {
[ -n $ht_capab ]  append base_cfg ht_capab=$ht_capab $N
}
 
+   [ $enable_vht -gt 0 ]  {
+   append base_cfg ieee80211ac=1 $N
+
+   json_get_values vht_capab_list 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
+   

Re: [OpenWrt-Devel] [PATCH 1/2] wifi: Introduce 802.11ac support

2014-01-16 Thread Matti Laakso
Thanks! Now I don't need to spend my weekend on this like I was about to!

I see one issue:

 +
 +     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
 +         mode_11n=
 +         mode_band=
 +         channel=36
 +         htmode=HT40+
 +
 +         append vht_capab   option vhtmode  VHT80 
 $N
 + 
 +         list=  list vht_capab
 +         [ $(($vht_cap  3)) -eq 1 ]  append 
 vht_capab $listMAX-MPDU-7991 $N
 +         [ $(($vht_cap  3)) -eq 2 ]  append 
 vht_capab $listMAX-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 $listTX-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 $listMU-BEAMFORMEE $N
 +         [ $(($vht_cap  2097152)) -eq 2097152 ]  
 append vht_capab $listVHT-TXOP-PS $N
 +         [ $(($vht_cap  4194304)) -eq 4194304 ]  
 append vht_capab $listHTC-VHT $N
 +         [ $(($vht_cap  201326592)) -eq 134217728 ] 
  append vht_capab $listVHT-LINK-ADAPT2 $N
 +         [ $(($vht_cap  201326592)) -eq 201326592 ] 
  append vht_capab $listVHT-LINK-ADAPT3 $N
 +         [ $(($vht_cap  268435456)) -eq 268435456 ] 
  append vht_capab $listRX-ANTENNA-PATTERN $N
 +         [ $(($vht_cap  536870912)) -eq 536870912 ] 
  append vht_capab $listTX-ANTENNA-PATTERN $N
 +     }
 +
 +     [ -n $htmode ]  append ht_capab  option htmode   
 $htmode $N
 +
           iw phy $dev info | grep -q '2412 MHz' || { 
 mode_band=a; channel=36; }

After this line hwmode will be 11aca instead of 11ac, so you should move this 
to the top of this snippet. 
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel