mac80211: support wildcard paths when matching phys
[openwrt/openwrt.git] / package / kernel / mac80211 / files / lib / netifd / wireless / mac80211.sh
index 00c2108bbf82953c8df6cbe2178b049977d8b7a9..e6241deb5f8c115033cc9264fe9b2830e1e77c56 100644 (file)
@@ -36,7 +36,13 @@ drv_mac80211_init_device_config() {
                htc_vht \
                rx_antenna_pattern \
                tx_antenna_pattern
-       config_add_int vht_max_mpdu vht_max_rx_stbc vht_link_adapt vht160
+       config_add_int vht_max_a_mpdu_len_exp vht_max_mpdu vht_link_adapt vht160 rx_stbc tx_stbc
+       config_add_boolean \
+               ldpc \
+               greenfield \
+               short_gi_20 \
+               short_gi_40 \
+               dsss_cck_40
 }
 
 drv_mac80211_init_iface_config() {
@@ -47,7 +53,7 @@ drv_mac80211_init_iface_config() {
        config_add_boolean wds powersave
        config_add_int maxassoc
        config_add_int max_listen_int
-       config_add_int dtim_interval
+       config_add_int dtim_period
 
        # mesh
        config_add_string mesh_id
@@ -121,7 +127,7 @@ mac80211_hostapd_setup_base() {
 
                json_get_vars \
                        ldpc:1 \
-                       greenfield:1 \
+                       greenfield:0 \
                        short_gi_20:1 \
                        short_gi_40:1 \
                        tx_stbc:1 \
@@ -142,13 +148,14 @@ mac80211_hostapd_setup_base() {
                        GF:0x10::$greenfield \
                        SHORT-GI-20:0x20::$short_gi_20 \
                        SHORT-GI-40:0x40::$short_gi_40 \
-                       TX-STBC:0x80::$max_tx_stbc \
+                       TX-STBC:0x80::$tx_stbc \
                        RX-STBC1:0x300:0x100:1 \
                        RX-STBC12:0x300:0x200:1 \
                        RX-STBC123:0x300:0x300:1 \
                        DSSS_CCK-40:0x1000::$dsss_cck_40
 
-               [ -n "$ht_capab" ] && append base_cfg "ht_capab=$ht_capab$ht_capab_flags" "$N"
+               ht_capab="$ht_capab$ht_capab_flags"
+               [ -n "$ht_capab" ] && append base_cfg "ht_capab=$ht_capab" "$N"
        }
 
        # 802.11ac
@@ -166,7 +173,7 @@ mac80211_hostapd_setup_base() {
                        append base_cfg "vht_oper_centr_freq_seg0_idx=$idx" "$N"
                ;;
                VHT80)
-                       case "$(( ($channel / 4) % 2 ))" in
+                       case "$(( ($channel / 4) % 4 ))" in
                                1) idx=$(($channel + 6));;
                                2) idx=$(($channel + 2));;
                                3) idx=$(($channel - 2));;
@@ -201,8 +208,10 @@ mac80211_hostapd_setup_base() {
                        htc_vht:1 \
                        rx_antenna_pattern:1 \
                        tx_antenna_pattern:1 \
+                       vht_max_a_mpdu_len_exp:7 \
                        vht_max_mpdu:11454 \
                        rx_stbc:4 \
+                       tx_stbc:4 \
                        vht_link_adapt:3 \
                        vht160:2
 
@@ -251,6 +260,24 @@ mac80211_hostapd_setup_base() {
                        vht_max_mpdu_hw=11454
                [ "$vht_max_mpdu_hw" != 3895 ] && \
                        vht_capab="$vht_capab[MAX-MPDU-$vht_max_mpdu_hw]"
+                       
+               # maximum A-MPDU length exponent
+               vht_max_a_mpdu_len_exp_hw=0
+               [ "$(($vht_cap & 58720256))" -ge 8388608 -a 1 -le "$vht_max_a_mpdu_len_exp" ] && \
+                       vht_max_a_mpdu_len_exp_hw=1
+               [ "$(($vht_cap & 58720256))" -ge 16777216 -a 2 -le "$vht_max_a_mpdu_len_exp" ] && \
+                       vht_max_a_mpdu_len_exp_hw=2
+               [ "$(($vht_cap & 58720256))" -ge 25165824 -a 3 -le "$vht_max_a_mpdu_len_exp" ] && \
+                       vht_max_a_mpdu_len_exp_hw=3
+               [ "$(($vht_cap & 58720256))" -ge 33554432 -a 4 -le "$vht_max_a_mpdu_len_exp" ] && \
+                       vht_max_a_mpdu_len_exp_hw=4
+               [ "$(($vht_cap & 58720256))" -ge 41943040 -a 5 -le "$vht_max_a_mpdu_len_exp" ] && \
+                       vht_max_a_mpdu_len_exp_hw=5
+               [ "$(($vht_cap & 58720256))" -ge 50331648 -a 6 -le "$vht_max_a_mpdu_len_exp" ] && \
+                       vht_max_a_mpdu_len_exp_hw=6
+               [ "$(($vht_cap & 58720256))" -ge 58720256 -a 7 -le "$vht_max_a_mpdu_len_exp" ] && \
+                       vht_max_a_mpdu_len_exp_hw=7
+               vht_capab="$vht_capab[MAX-A-MPDU-LEN-EXP$vht_max_a_mpdu_len_exp_hw]"
 
                # whether or not the STA supports link adaptation using VHT variant
                vht_link_adapt_hw=0
@@ -337,9 +364,13 @@ mac80211_generate_mac() {
 
 find_phy() {
        [ -n "$phy" -a -d /sys/class/ieee80211/$phy ] && return 0
-       [ -n "$path" -a -d "/sys/devices/$path/ieee80211" ] && {
-               phy="$(ls /sys/devices/$path/ieee80211 | grep -m 1 phy)"
-               [ -n "$phy" ] && return 0
+       [ -n "$path" ] && {
+               for phy in /sys/devices/$path/ieee80211/phy*; do
+                       [ -e "$phy" ] && {
+                               phy="${phy##*/}"
+                               return 0
+                       }
+               done
        }
        [ -n "$macaddr" ] && {
                for phy in $(ls /sys/class/ieee80211 2>/dev/null); do