[][MAC80211][mt76][Add EHT40+/EHT40-/HE40+/HE40- support by uci command]
[Description]
Add EHT40+/EHT40-/HE40+/HE40- support
Usage:
uci set wireless.radio0.htmode=EHT40+
uci set wireless.radio0.channel=6
uci set wireless.radio0.disabled=0
uci commit wireless
wifi reload
uci set wireless.radio0.htmode=EHT40-
uci set wireless.radio0.channel=6
uci set wireless.radio0.disabled=0
uci commit wireless
wifi reload
[Release-log]
N/A
Change-Id: I69fbaa0adbaef17cd72bf7d14420304ad7c1b069
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7423921
diff --git a/autobuild_mac80211_release/0001-master-mac80211-generate-hostapd-setting-from-ap-cap.patch b/autobuild_mac80211_release/0001-master-mac80211-generate-hostapd-setting-from-ap-cap.patch
index a8e85c0..8d16116 100644
--- a/autobuild_mac80211_release/0001-master-mac80211-generate-hostapd-setting-from-ap-cap.patch
+++ b/autobuild_mac80211_release/0001-master-mac80211-generate-hostapd-setting-from-ap-cap.patch
@@ -77,11 +77,36 @@
- VHT20|HT20|HE20) ;;
- HT40*|VHT40|VHT80|VHT160|HE40|HE80|HE160)
+ VHT20|HT20|HE20|EHT20) ;;
-+ HT40*|VHT40|VHT80|VHT160|HE40|HE80|HE160|EHT40|EHT80|EHT160|EHT320*)
++ HT40*|VHT40|VHT80|VHT160|HE40*|HE80|HE160|EHT40*|EHT80|EHT160|EHT320*)
case "$hwmode" in
a)
case "$(( (($channel / 4) + $chan_ofs) % 2 ))" in
-@@ -205,7 +207,7 @@ mac80211_hostapd_setup_base() {
+@@ -171,8 +173,22 @@ mac80211_hostapd_setup_base() {
+ ;;
+ *)
+ case "$htmode" in
+- HT40+) ht_capab="[HT40+]";;
+- HT40-) ht_capab="[HT40-]";;
++ HT40+|HE40+|EHT40+)
++ if [ "$channel" -gt 9 ]; then
++ echo "Could not set the center freq with this HT mode setting"
++ return 1
++ else
++ ht_capab="[HT40+]"
++ fi
++ ;;
++ HT40-|HE40-|EHT40-)
++ if [ "$channel" -lt 5 ]; then
++ echo "Could not set the center freq with this HT mode setting"
++ return 1
++ else
++ ht_capab="[HT40-]"
++ fi
++ ;;
+ *)
+ if [ "$channel" -lt 7 ]; then
+ ht_capab="[HT40+]"
+@@ -205,7 +221,7 @@ mac80211_hostapd_setup_base() {
dsss_cck_40:1
ht_cap_mask=0
@@ -90,7 +115,7 @@
ht_cap_mask="$(($ht_cap_mask | $cap))"
done
-@@ -236,8 +238,8 @@ mac80211_hostapd_setup_base() {
+@@ -236,8 +252,8 @@ mac80211_hostapd_setup_base() {
idx="$channel"
case "$htmode" in
@@ -101,7 +126,7 @@
case "$(( (($channel / 4) + $chan_ofs) % 2 ))" in
1) idx=$(($channel + 2));;
0) idx=$(($channel - 2));;
-@@ -245,7 +247,7 @@ mac80211_hostapd_setup_base() {
+@@ -245,7 +261,7 @@ mac80211_hostapd_setup_base() {
enable_ac=1
vht_center_seg0=$idx
;;
@@ -110,7 +135,7 @@
case "$(( (($channel / 4) + $chan_ofs) % 4 ))" in
1) idx=$(($channel + 6));;
2) idx=$(($channel + 2));;
-@@ -256,7 +258,7 @@ mac80211_hostapd_setup_base() {
+@@ -256,7 +272,7 @@ mac80211_hostapd_setup_base() {
vht_oper_chwidth=1
vht_center_seg0=$idx
;;
@@ -119,7 +144,7 @@
if [ "$band" = "6g" ]; then
case "$channel" in
1|5|9|13|17|21|25|29) idx=15;;
-@@ -277,6 +279,36 @@ mac80211_hostapd_setup_base() {
+@@ -277,6 +293,36 @@ mac80211_hostapd_setup_base() {
vht_oper_chwidth=2
vht_center_seg0=$idx
;;
@@ -156,7 +181,7 @@
esac
[ "$band" = "5g" ] && {
json_get_vars background_radar:0
-@@ -286,8 +318,9 @@ mac80211_hostapd_setup_base() {
+@@ -286,8 +332,9 @@ mac80211_hostapd_setup_base() {
[ "$band" = "6g" ] && {
op_class=
case "$htmode" in
@@ -168,7 +193,7 @@
esac
[ -n "$op_class" ] && append base_cfg "op_class=$op_class" "$N"
}
-@@ -315,7 +348,6 @@ mac80211_hostapd_setup_base() {
+@@ -315,7 +362,6 @@ mac80211_hostapd_setup_base() {
vht_link_adapt:3 \
vht160:2
@@ -176,7 +201,7 @@
append base_cfg "ieee80211ac=1" "$N"
vht_cap=0
for cap in $(iw phy "$phy" info | awk -F "[()]" '/VHT Capabilities/ { print $2 }'); do
-@@ -329,6 +361,12 @@ mac80211_hostapd_setup_base() {
+@@ -329,6 +375,12 @@ mac80211_hostapd_setup_base() {
[ "$rx_stbc" -lt "$cap_rx_stbc" ] && cap_rx_stbc="$rx_stbc"
vht_cap="$(( ($vht_cap & ~(0x700)) | ($cap_rx_stbc << 8) ))"
@@ -189,7 +214,7 @@
mac80211_add_capabilities vht_capab $vht_cap \
RXLDPC:0x10::$rxldpc \
SHORT-GI-80:0x20::$short_gi_80 \
-@@ -410,7 +448,7 @@ mac80211_hostapd_setup_base() {
+@@ -410,7 +462,7 @@ mac80211_hostapd_setup_base() {
# 802.11ax
enable_ax=0
case "$htmode" in
@@ -198,7 +223,7 @@
esac
if [ "$enable_ax" != "0" ]; then
-@@ -419,10 +457,11 @@ mac80211_hostapd_setup_base() {
+@@ -419,10 +471,11 @@ mac80211_hostapd_setup_base() {
he_su_beamformee:1 \
he_mu_beamformer:1 \
he_twt_required:0 \
@@ -211,7 +236,7 @@
he_bss_color_enabled:1
he_phy_cap=$(iw phy "$phy" info | sed -n '/HE Iftypes: AP/,$p' | awk -F "[()]" '/HE PHY Capabilities/ { print $2 }' | head -1)
-@@ -436,6 +475,11 @@ mac80211_hostapd_setup_base() {
+@@ -436,6 +489,11 @@ mac80211_hostapd_setup_base() {
append base_cfg "he_oper_centr_freq_seg0_idx=$vht_center_seg0" "$N"
}
@@ -223,7 +248,7 @@
mac80211_add_he_capabilities \
he_su_beamformer:${he_phy_cap:6:2}:0x80:$he_su_beamformer \
he_su_beamformee:${he_phy_cap:8:2}:0x1:$he_su_beamformee \
-@@ -443,7 +487,14 @@ mac80211_hostapd_setup_base() {
+@@ -443,7 +501,14 @@ mac80211_hostapd_setup_base() {
he_spr_psr_enabled:${he_phy_cap:14:2}:0x1:$he_spr_psr_enabled \
he_twt_required:${he_mac_cap:0:2}:0x6:$he_twt_required
@@ -238,7 +263,7 @@
append base_cfg "he_bss_color=$he_bss_color" "$N"
[ "$he_spr_non_srg_obss_pd_max_offset" -gt 0 ] && { \
append base_cfg "he_spr_non_srg_obss_pd_max_offset=$he_spr_non_srg_obss_pd_max_offset" "$N"
-@@ -484,12 +535,46 @@ mac80211_hostapd_setup_base() {
+@@ -484,12 +549,46 @@ mac80211_hostapd_setup_base() {
append base_cfg "he_mu_edca_ac_vo_timer=255" "$N"
fi
@@ -285,7 +310,7 @@
$base_cfg
EOF
-@@ -517,7 +602,7 @@ mac80211_hostapd_setup_bss() {
+@@ -517,7 +616,7 @@ mac80211_hostapd_setup_bss() {
append hostapd_cfg "wds_sta=1" "$N"
[ -n "$wds_bridge" ] && append hostapd_cfg "wds_bridge=$wds_bridge" "$N"
}
@@ -294,7 +319,7 @@
cat >> /var/run/hostapd-$phy.conf <<EOF
$hostapd_cfg
-@@ -527,6 +612,34 @@ ${max_listen_int:+max_listen_interval=$max_listen_int}
+@@ -527,6 +626,34 @@ ${max_listen_int:+max_listen_interval=$m
EOF
}
@@ -329,7 +354,7 @@
mac80211_get_addr() {
local phy="$1"
local idx="$(($2 + 1))"
-@@ -757,7 +870,13 @@ mac80211_prepare_vif() {
+@@ -757,7 +884,13 @@ mac80211_prepare_vif() {
json_select ..
@@ -344,7 +369,7 @@
macaddr="$(mac80211_generate_mac $phy)"
macidx="$(($macidx + 1))"
elif [ "$macaddr" = 'random' ]; then
-@@ -1058,6 +1177,9 @@ mac80211_setup_vif() {
+@@ -1058,6 +1191,9 @@ mac80211_setup_vif() {
json_select ..
[ -n "$failed" ] || wireless_add_vif "$name" "$ifname"
@@ -354,7 +379,7 @@
}
get_freq() {
-@@ -1122,6 +1244,10 @@ drv_mac80211_cleanup() {
+@@ -1122,6 +1258,10 @@ drv_mac80211_cleanup() {
hostapd_common_cleanup
}
@@ -365,7 +390,7 @@
drv_mac80211_setup() {
json_select config
json_get_vars \
-@@ -1219,6 +1345,16 @@ drv_mac80211_setup() {
+@@ -1219,6 +1359,16 @@ drv_mac80211_setup() {
for_each_interface "sta adhoc mesh" mac80211_set_noscan
[ -n "$has_ap" ] && mac80211_hostapd_setup_base "$phy"