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>
---
v2:
 * reordered package/kernel/mac80211/files/lib/wifi/mac80211.sh to avoid
   11aca mode on 5GHz-only devices

 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
+                       vht_capab="$vht_capab[$cap]"
+               done
+               [ -n "$vht_capab" ] && append base_cfg "vht_capab=$vht_capab" 
"$N"
+       }
+
        hostapd_prepare_device_config "$hostapd_conf_file" nl80211
        cat >> "$hostapd_conf_file" <<EOF
 ${channel:+channel=$channel}
diff --git a/package/kernel/mac80211/files/lib/wifi/mac80211.sh 
b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
index e33b09a..672ef82 100644
--- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh
+++ b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
@@ -67,8 +67,11 @@ detect_mac80211() {
                [ "$found" -gt 0 ] && continue
 
                mode_11n=""
+               mode_11ac=""
                mode_band="g"
                channel="11"
+               htmode=""
+
                ht_cap=0
                for cap in $(iw phy "$dev" info | grep 'Capabilities:' | cut 
-d: -f2); do
                        ht_cap="$(($ht_cap | $cap))"
@@ -76,7 +79,8 @@ detect_mac80211() {
                ht_capab="";
                [ "$ht_cap" -gt 0 ] && {
                        mode_11n="n"
-                       append ht_capab "       option htmode   HT20" "$N"
+
+                       htmode="HT20"
 
                        list="  list ht_capab"
                        [ "$(($ht_cap & 1))" -eq 1 ] && append ht_capab "$list  
LDPC" "$N"
@@ -89,8 +93,50 @@ detect_mac80211() {
                        [ "$(($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"
                }
+
                iw phy "$dev" info | grep -q '2412 MHz' || { mode_band="a"; 
channel="36"; }
 
+               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 
"$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"
+               }
+
+               [ -n $htmode ] && append ht_capab "     option htmode   
$htmode" "$N"
+
                if [ -x /usr/bin/readlink ]; then
                        path="$(readlink -f /sys/class/ieee80211/${dev}/device)"
                        path="${path##/sys/devices/}"
@@ -103,9 +149,10 @@ detect_mac80211() {
 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
 
diff --git a/package/network/config/netifd/patches/002-vht_support.patch 
b/package/network/config/netifd/patches/002-vht_support.patch
new file mode 100644
index 0000000..41a51aa
--- /dev/null
+++ b/package/network/config/netifd/patches/002-vht_support.patch
@@ -0,0 +1,42 @@
+diff --git a/scripts/netifd-wireless.sh b/scripts/netifd-wireless.sh
+index 8c0ff78..1d091e4 100644
+--- a/scripts/netifd-wireless.sh
++++ b/scripts/netifd-wireless.sh
+@@ -43,7 +43,9 @@ _wdev_prepare_channel() {
+ 
+       auto_channel=0
+       enable_ht=0
++      enable_vht=0
+       htmode=
++      vhtmode=
+       hwmode="${hwmode##11}"
+       hwmode_n="${hwmode##n}"
+ 
+@@ -69,6 +71,18 @@ _wdev_prepare_channel() {
+               esac
+       }
+ 
++      [[ "ac" == "$hwmode" ]] && {
++              enable_ht=1
++              enable_vht=1
++              hwmode="$hwmode_n"
++
++              json_get_vars vhtmode
++              case "$vhtmode" in
++                      VHT80|VHT160);;
++                      *) vhtmode= ;;
++              esac
++      }
++
+       case "$hwmode" in
+               a|b|g) ;;
+               *)
+@@ -276,7 +290,7 @@ for_each_interface() {
+ }
+ 
+ _wdev_common_device_config() {
+-      config_add_string channel hwmode htmode
++      config_add_string channel hwmode htmode vhtmode
+ }
+ 
+ _wdev_common_iface_config() {
diff --git a/package/network/services/hostapd/files/hostapd-full.config 
b/package/network/services/hostapd/files/hostapd-full.config
index bc999c0..e021cd0 100644
--- a/package/network/services/hostapd/files/hostapd-full.config
+++ b/package/network/services/hostapd/files/hostapd-full.config
@@ -139,6 +139,9 @@ CONFIG_IEEE80211R=y
 # 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.
diff --git a/package/network/services/hostapd/files/hostapd-mini.config 
b/package/network/services/hostapd/files/hostapd-mini.config
index 01a04cb..3675709 100644
--- a/package/network/services/hostapd/files/hostapd-mini.config
+++ b/package/network/services/hostapd/files/hostapd-mini.config
@@ -138,6 +138,9 @@ CONFIG_PEERKEY=y
 # 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.
-- 
1.8.5.2
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to