blob: 264d818e57587b96634685ae4db44a6b6d2122d5 [file] [log] [blame]
developerce9e5092022-11-10 22:41:59 +08001diff --git a/package/kernel/mac80211/Makefile b/package/kernel/mac80211/Makefile
developer74503112023-06-29 17:34:49 +08002index a7472ee7..f06c889b 100644
developerce9e5092022-11-10 22:41:59 +08003--- a/package/kernel/mac80211/Makefile
4+++ b/package/kernel/mac80211/Makefile
developerad1f3172023-05-02 11:10:08 +08005@@ -20,6 +20,7 @@ PKG_SOURCE:=backports-$(PKG_VERSION).tar.xz
developerce9e5092022-11-10 22:41:59 +08006 PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/backports-$(PKG_VERSION)
7 PKG_BUILD_PARALLEL:=1
developer356ecec2022-11-14 10:25:04 +08008
developerce9e5092022-11-10 22:41:59 +08009+SOURCE_PATH:=./src
10 PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
developer356ecec2022-11-14 10:25:04 +080011
developerce9e5092022-11-10 22:41:59 +080012 PKG_DRIVERS = \
developerad1f3172023-05-02 11:10:08 +080013@@ -72,6 +73,10 @@ config-y:= \
developer6ec8e342022-11-21 18:47:15 +080014 WLAN_VENDOR_ST \
15 WLAN_VENDOR_TI \
16 WLAN_VENDOR_ZYDAS \
17+ MAC80211_DEBUG_MENU \
18+ MAC80211_MLME_DEBUG \
19+ MAC80211_STA_DEBUG \
20+ MAC80211_HT_DEBUG \
21
22 config-$(call config_package,cfg80211) += CFG80211
23 config-$(CONFIG_PACKAGE_CFG80211_TESTMODE) += NL80211_TESTMODE
developerad1f3172023-05-02 11:10:08 +080024@@ -297,6 +302,8 @@ define Build/Prepare
developer356ecec2022-11-14 10:25:04 +080025 mkdir -p $(PKG_BUILD_DIR)
26 $(PKG_UNPACK)
27 $(Build/Patch)
28+ $(CP) $(SOURCE_PATH)/net $(PKG_BUILD_DIR) 2>/dev/null || :
29+ $(CP) $(SOURCE_PATH)/include $(PKG_BUILD_DIR) 2>/dev/null || :
30 rm -rf \
31 $(PKG_BUILD_DIR)/include/linux/ssb \
32 $(PKG_BUILD_DIR)/include/linux/bcma \
developer20d67712022-03-02 14:09:32 +080033diff --git a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
developer2c6592a2023-07-21 11:20:56 +080034index 5aaba9af..e6e9e540 100644
developer20d67712022-03-02 14:09:32 +080035--- a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
36+++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
developer0ba09b62023-03-10 18:43:49 +080037@@ -27,6 +27,7 @@ drv_mac80211_init_device_config() {
38
39 config_add_string path phy 'macaddr:macaddr'
40 config_add_string tx_burst
developer2c6592a2023-07-21 11:20:56 +080041+ config_add_int mbssid mu_onoff sr_enable sr_enhanced rnr
developer0ba09b62023-03-10 18:43:49 +080042 config_add_string distance
43 config_add_int beacon_int chanbw frag rts
44 config_add_int rxantenna txantenna antenna_gain txpower min_tx_power
developer785b6502023-04-19 18:31:11 +080045@@ -53,7 +54,10 @@ drv_mac80211_init_device_config() {
46 he_spr_sr_control \
47 he_spr_psr_enabled \
48 he_bss_color_enabled \
49- he_twt_required
50+ he_twt_required \
51+ he_twt_responder \
52+ etxbfen \
53+ itxbfen
54 config_add_int \
55 beamformer_antennas \
56 beamformee_antennas \
57@@ -140,13 +144,11 @@ mac80211_hostapd_setup_base() {
developer0ba09b62023-03-10 18:43:49 +080058 [ -n "$acs_exclude_dfs" ] && [ "$acs_exclude_dfs" -gt 0 ] &&
59 append base_cfg "acs_exclude_dfs=1" "$N"
60
61- json_get_vars noscan ht_coex min_tx_power:0 tx_burst
developer2c6592a2023-07-21 11:20:56 +080062+ json_get_vars noscan ht_coex min_tx_power:0 tx_burst mbssid mu_onoff rnr
developer2c4f7e82023-05-11 19:56:55 +080063+ json_get_vars etxbfen:1 itxbfen:0
developer8d77be32022-10-20 15:08:25 +080064 json_get_values ht_capab_list ht_capab
developer20d67712022-03-02 14:09:32 +080065 json_get_values channel_list channels
66
67- [ "$auto_channel" = 0 ] && [ -z "$channel_list" ] && \
68- channel_list="$channel"
69-
developer9b3248d2022-07-06 00:44:05 +080070 [ "$min_tx_power" -gt 0 ] && append base_cfg "min_tx_power=$min_tx_power"
developer20d67712022-03-02 14:09:32 +080071
developer9b3248d2022-07-06 00:44:05 +080072 set_default noscan 0
developer785b6502023-04-19 18:31:11 +080073@@ -160,8 +162,8 @@ mac80211_hostapd_setup_base() {
74 ieee80211n=1
75 ht_capab=
76 case "$htmode" in
77- VHT20|HT20|HE20) ;;
78- HT40*|VHT40|VHT80|VHT160|HE40|HE80|HE160)
79+ VHT20|HT20|HE20|EHT20) ;;
developerbe3cf972023-04-27 09:58:26 +080080+ HT40*|VHT40|VHT80|VHT160|HE40*|HE80|HE160|EHT40*|EHT80|EHT160|EHT320*)
developer785b6502023-04-19 18:31:11 +080081 case "$hwmode" in
82 a)
83 case "$(( (($channel / 4) + $chan_ofs) % 2 ))" in
developerbe3cf972023-04-27 09:58:26 +080084@@ -171,8 +173,22 @@ mac80211_hostapd_setup_base() {
85 ;;
86 *)
87 case "$htmode" in
88- HT40+) ht_capab="[HT40+]";;
89- HT40-) ht_capab="[HT40-]";;
90+ HT40+|HE40+|EHT40+)
91+ if [ "$channel" -gt 9 ]; then
92+ echo "Could not set the center freq with this HT mode setting"
93+ return 1
94+ else
95+ ht_capab="[HT40+]"
96+ fi
97+ ;;
98+ HT40-|HE40-|EHT40-)
99+ if [ "$channel" -lt 5 ]; then
100+ echo "Could not set the center freq with this HT mode setting"
101+ return 1
102+ else
103+ ht_capab="[HT40-]"
104+ fi
105+ ;;
106 *)
107 if [ "$channel" -lt 7 ]; then
108 ht_capab="[HT40+]"
109@@ -205,7 +221,7 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800110 dsss_cck_40:1
111
112 ht_cap_mask=0
113- for cap in $(iw phy "$phy" info | grep 'Capabilities:' | cut -d: -f2); do
114+ for cap in $(iw phy "$phy" info | grep 'Capabilities: 0x' | cut -d: -f2); do
115 ht_cap_mask="$(($ht_cap_mask | $cap))"
116 done
117
developerbe3cf972023-04-27 09:58:26 +0800118@@ -236,8 +252,8 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800119
120 idx="$channel"
121 case "$htmode" in
122- VHT20|HE20) enable_ac=1;;
123- VHT40|HE40)
124+ VHT20|HE20|EHT20) enable_ac=1;;
125+ VHT40|HE40|EHT40)
126 case "$(( (($channel / 4) + $chan_ofs) % 2 ))" in
127 1) idx=$(($channel + 2));;
128 0) idx=$(($channel - 2));;
developerbe3cf972023-04-27 09:58:26 +0800129@@ -245,7 +261,7 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800130 enable_ac=1
131 vht_center_seg0=$idx
132 ;;
133- VHT80|HE80)
134+ VHT80|HE80|EHT80)
135 case "$(( (($channel / 4) + $chan_ofs) % 4 ))" in
136 1) idx=$(($channel + 6));;
137 2) idx=$(($channel + 2));;
developerbe3cf972023-04-27 09:58:26 +0800138@@ -256,7 +272,7 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800139 vht_oper_chwidth=1
140 vht_center_seg0=$idx
141 ;;
142- VHT160|HE160)
143+ VHT160|HE160|EHT160)
144 if [ "$band" = "6g" ]; then
145 case "$channel" in
146 1|5|9|13|17|21|25|29) idx=15;;
developeradd8de62023-05-02 16:25:52 +0800147@@ -271,12 +287,43 @@ mac80211_hostapd_setup_base() {
148 case "$channel" in
149 36|40|44|48|52|56|60|64) idx=50;;
150 100|104|108|112|116|120|124|128) idx=114;;
151+ 149|153|157|161|165|169|173|177) idx=163;;
152 esac
153 fi
154 enable_ac=1
developer785b6502023-04-19 18:31:11 +0800155 vht_oper_chwidth=2
156 vht_center_seg0=$idx
157 ;;
158+ EHT320*)
159+ case "$channel" in
160+ 1|5|9|13|17|21|25|29) idx=31;;
161+ 33|37|41|45|49|53|57|61| \
162+ 65|69|73|77|81|85|89|93) idx=63;;
163+ 97|101|105|109|113|117|121|125| \
164+ 129|133|137|141|145|149|153|157) idx=127;;
165+ 161|165|169|173|177|181|185|189| \
166+ 193|197|201|205|209|213|217|221) idx=191;;
167+ esac
168+ if [[ "$htmode" = "EHT320-1" && "$channel" -ge "193" ]] ||
169+ [[ "$htmode" = "EHT320-2" && "$channel" -le "29" ]]; then
170+ echo "Could not set the center freq with this EHT setting"
171+ return 1
172+ elif [[ "$htmode" = "EHT320-1" && "$channel" -ge "33" ]]; then
173+ if [ "$channel" -gt $idx ]; then
174+ idx=$(($idx + 32))
175+ else
176+ idx=$(($idx - 32))
177+ fi
178+ fi
179+ vht_oper_chwidth=2
180+ if [ "$channel" -gt $idx ]; then
181+ vht_center_seg0=$(($idx + 16))
182+ else
183+ vht_center_seg0=$(($idx - 16))
184+ fi
185+ eht_oper_chwidth=9
186+ eht_oper_centr_freq_seg0_idx=$idx
187+ ;;
188 esac
189 [ "$band" = "5g" ] && {
190 json_get_vars background_radar:0
developeradd8de62023-05-02 16:25:52 +0800191@@ -286,8 +333,9 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800192 [ "$band" = "6g" ] && {
193 op_class=
194 case "$htmode" in
195- HE20) op_class=131;;
196- HE*) op_class=$((132 + $vht_oper_chwidth))
197+ HE20|EHT20) op_class=131;;
198+ EHT320*) op_class=137;;
199+ HE*|EHT*) op_class=$((132 + $vht_oper_chwidth))
200 esac
201 [ -n "$op_class" ] && append base_cfg "op_class=$op_class" "$N"
202 }
developeradd8de62023-05-02 16:25:52 +0800203@@ -315,7 +363,6 @@ mac80211_hostapd_setup_base() {
developer8b04dfd2022-12-07 16:29:19 +0800204 vht_link_adapt:3 \
205 vht160:2
206
207- set_default tx_burst 2.0
208 append base_cfg "ieee80211ac=1" "$N"
209 vht_cap=0
210 for cap in $(iw phy "$phy" info | awk -F "[()]" '/VHT Capabilities/ { print $2 }'); do
developeradd8de62023-05-02 16:25:52 +0800211@@ -329,6 +376,12 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800212 [ "$rx_stbc" -lt "$cap_rx_stbc" ] && cap_rx_stbc="$rx_stbc"
213 vht_cap="$(( ($vht_cap & ~(0x700)) | ($cap_rx_stbc << 8) ))"
214
215+ [ "$etxbfen" -eq 0 ] && {
216+ su_beamformer=0
217+ su_beamformee=0
218+ mu_beamformer=0
219+ }
220+
221 mac80211_add_capabilities vht_capab $vht_cap \
222 RXLDPC:0x10::$rxldpc \
223 SHORT-GI-80:0x20::$short_gi_80 \
developeradd8de62023-05-02 16:25:52 +0800224@@ -410,7 +463,7 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800225 # 802.11ax
226 enable_ax=0
227 case "$htmode" in
228- HE*) enable_ax=1 ;;
229+ HE*|EHT*) enable_ax=1 ;;
230 esac
231
232 if [ "$enable_ax" != "0" ]; then
developeradd8de62023-05-02 16:25:52 +0800233@@ -419,10 +472,11 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800234 he_su_beamformee:1 \
235 he_mu_beamformer:1 \
236 he_twt_required:0 \
237+ he_twt_responder \
238 he_spr_sr_control:3 \
239 he_spr_psr_enabled:0 \
240 he_spr_non_srg_obss_pd_max_offset:0 \
241- he_bss_color:128 \
242+ he_bss_color \
243 he_bss_color_enabled:1
244
245 he_phy_cap=$(iw phy "$phy" info | sed -n '/HE Iftypes: AP/,$p' | awk -F "[()]" '/HE PHY Capabilities/ { print $2 }' | head -1)
developeradd8de62023-05-02 16:25:52 +0800246@@ -436,6 +490,11 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800247 append base_cfg "he_oper_centr_freq_seg0_idx=$vht_center_seg0" "$N"
248 }
249
250+ [ "$etxbfen" -eq 0 ] && {
251+ he_su_beamformer=0
252+ he_mu_beamformer=0
253+ }
254+
255 mac80211_add_he_capabilities \
256 he_su_beamformer:${he_phy_cap:6:2}:0x80:$he_su_beamformer \
257 he_su_beamformee:${he_phy_cap:8:2}:0x1:$he_su_beamformee \
developeradd8de62023-05-02 16:25:52 +0800258@@ -443,7 +502,14 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800259 he_spr_psr_enabled:${he_phy_cap:14:2}:0x1:$he_spr_psr_enabled \
260 he_twt_required:${he_mac_cap:0:2}:0x6:$he_twt_required
261
262+ if [ -n "$he_twt_responder" ]; then
263+ append base_cfg "he_twt_responder=$he_twt_responder" "$N"
264+ fi
265 if [ "$he_bss_color_enabled" -gt 0 ]; then
developer830efa72023-05-18 19:32:48 +0800266+ if !([ "$he_bss_color" -gt 0 ] && [ "$he_bss_color" -le 64 ]); then
developer785b6502023-04-19 18:31:11 +0800267+ rand=$(head -n 1 /dev/urandom | tr -dc 0-9 | head -c 2)
268+ he_bss_color=$((rand % 63 + 1))
269+ fi
270 append base_cfg "he_bss_color=$he_bss_color" "$N"
271 [ "$he_spr_non_srg_obss_pd_max_offset" -gt 0 ] && { \
272 append base_cfg "he_spr_non_srg_obss_pd_max_offset=$he_spr_non_srg_obss_pd_max_offset" "$N"
developer2c6592a2023-07-21 11:20:56 +0800273@@ -484,12 +550,47 @@ mac80211_hostapd_setup_base() {
developer8b04dfd2022-12-07 16:29:19 +0800274 append base_cfg "he_mu_edca_ac_vo_timer=255" "$N"
275 fi
276
developer18015ad2023-07-13 13:18:19 +0800277+ set_default tx_burst 2
developer8b04dfd2022-12-07 16:29:19 +0800278+
developer785b6502023-04-19 18:31:11 +0800279+ # 802.11be
280+ enable_be=0
281+ case "$htmode" in
282+ EHT*) enable_be=1 ;;
283+ esac
284+
285+ if [ "$enable_be" != "0" ]; then
286+ append base_cfg "ieee80211be=1" "$N"
287+ if [ "$etxbfen" -eq 0 ]; then
288+ append base_cfg "eht_su_beamformee=1" "$N"
289+ else
290+ append base_cfg "eht_su_beamformer=1" "$N"
291+ append base_cfg "eht_su_beamformee=1" "$N"
292+ append base_cfg "eht_mu_beamformer=1" "$N"
293+ fi
294+ [ "$hwmode" = "a" ] && {
295+ case $htmode in
296+ EHT320*)
297+ append base_cfg "eht_oper_chwidth=$eht_oper_chwidth" "$N"
298+ append base_cfg "eht_oper_centr_freq_seg0_idx=$eht_oper_centr_freq_seg0_idx" "$N"
299+ ;;
300+ *)
301+ append base_cfg "eht_oper_chwidth=$vht_oper_chwidth" "$N"
302+ append base_cfg "eht_oper_centr_freq_seg0_idx=$vht_center_seg0" "$N"
303+ ;;
304+ esac
305+ }
306+ fi
307+
developer8b04dfd2022-12-07 16:29:19 +0800308 hostapd_prepare_device_config "$hostapd_conf_file" nl80211
309 cat >> "$hostapd_conf_file" <<EOF
310 ${channel:+channel=$channel}
developer0ba09b62023-03-10 18:43:49 +0800311 ${channel_list:+chanlist=$channel_list}
312 ${hostapd_noscan:+noscan=1}
313 ${tx_burst:+tx_queue_data2_burst=$tx_burst}
314+${mbssid:+mbssid=$mbssid}
developer785b6502023-04-19 18:31:11 +0800315+${mu_onoff:+mu_onoff=$mu_onoff}
316+${itxbfen:+ibf_enable=$itxbfen}
developer2c6592a2023-07-21 11:20:56 +0800317+${rnr:+rnr=$rnr}
developer0ba09b62023-03-10 18:43:49 +0800318 $base_cfg
319
320 EOF
developer2c6592a2023-07-21 11:20:56 +0800321@@ -517,7 +618,7 @@ mac80211_hostapd_setup_bss() {
developer093e1a32023-02-24 16:10:53 +0800322 append hostapd_cfg "wds_sta=1" "$N"
323 [ -n "$wds_bridge" ] && append hostapd_cfg "wds_bridge=$wds_bridge" "$N"
324 }
325- [ "$staidx" -gt 0 -o "$start_disabled" -eq 1 ] && append hostapd_cfg "start_disabled=1" "$N"
326+ [ "$start_disabled" -eq 1 ] && append hostapd_cfg "start_disabled=1" "$N"
327
328 cat >> /var/run/hostapd-$phy.conf <<EOF
329 $hostapd_cfg
developer2c6592a2023-07-21 11:20:56 +0800330@@ -527,6 +628,31 @@ ${max_listen_int:+max_listen_interval=$max_listen_int}
developer0ba09b62023-03-10 18:43:49 +0800331 EOF
332 }
333
334+mac80211_generate_mbssid_mac() {
335+ local phy="$1"
336+ local transmitted_bssid="$2"
developer1952bcd2023-06-20 20:14:37 +0800337+ local id="${mbssidx:-0}"
developer0ba09b62023-03-10 18:43:49 +0800338+
339+ local ref="$(cat /sys/class/ieee80211/${phy}/macaddress)"
developer0ba09b62023-03-10 18:43:49 +0800340+
341+ if [ -z "$transmitted_bssid" ]; then
342+ transmitted_bssid=$ref
343+ fi
344+
345+ if [ $id -eq 0 ]; then
346+ echo "$transmitted_bssid"
347+ return
348+ fi
349+
350+ local oIFS="$IFS"; IFS=":"; set -- $transmitted_bssid; IFS="$oIFS"
351+
352+ # Calculate nontransmitted bssid
developer0ba09b62023-03-10 18:43:49 +0800353+ b6="0x$6"
354+ ref_b6=$(($b6 % $max_mbssid))
developer1952bcd2023-06-20 20:14:37 +0800355+ b6=$(($b6 - $ref_b6 + ($ref_b6 + $id) % $max_mbssid))
developer0ba09b62023-03-10 18:43:49 +0800356+ printf "%s:%s:%s:%s:%s:%02x" $1 $2 $3 $4 $5 $b6
357+}
358+
359 mac80211_get_addr() {
360 local phy="$1"
361 local idx="$(($2 + 1))"
developer2c6592a2023-07-21 11:20:56 +0800362@@ -757,7 +883,19 @@ mac80211_prepare_vif() {
developer0ba09b62023-03-10 18:43:49 +0800363
364 json_select ..
365
366- if [ -z "$macaddr" ]; then
developerd2fbd572023-06-19 19:48:25 +0800367+ if [ "$mbssid" -gt 0 ] && [ "$mode" == "ap" ]; then
developer1952bcd2023-06-20 20:14:37 +0800368+ [ "$mbssidx" -eq 0 ] && {
369+ if [ -z $macaddr ]; then
370+ transmitted_bssid="$(mac80211_generate_mac $phy)"
371+ else
372+ # uci set mac address
373+ transmitted_bssid=$macaddr
374+ fi
375+ macidx="$(($macidx + 1))"
developer0ba09b62023-03-10 18:43:49 +0800376+ }
377+ macaddr="$(mac80211_generate_mbssid_mac $phy $transmitted_bssid)"
developer1952bcd2023-06-20 20:14:37 +0800378+ mbssidx="$(($mbssidx + 1))"
developer0ba09b62023-03-10 18:43:49 +0800379+ elif [ -z "$macaddr" ]; then
380 macaddr="$(mac80211_generate_mac $phy)"
381 macidx="$(($macidx + 1))"
382 elif [ "$macaddr" = 'random' ]; then
developer2c6592a2023-07-21 11:20:56 +0800383@@ -1058,6 +1196,9 @@ mac80211_setup_vif() {
developerf0de14b2022-12-14 23:07:34 +0800384
385 json_select ..
386 [ -n "$failed" ] || wireless_add_vif "$name" "$ifname"
387+
388+ echo "Setup SMP Affinity"
389+ /sbin/smp-mt76.sh
390 }
391
392 get_freq() {
developer2c6592a2023-07-21 11:20:56 +0800393@@ -1122,6 +1263,10 @@ drv_mac80211_cleanup() {
developer0ba09b62023-03-10 18:43:49 +0800394 hostapd_common_cleanup
395 }
396
397+mac80211_count_ap() {
398+ total_num_ap=$(($total_num_ap + 1))
399+}
400+
401 drv_mac80211_setup() {
402 json_select config
403 json_get_vars \
developer2c6592a2023-07-21 11:20:56 +0800404@@ -1129,7 +1274,8 @@ drv_mac80211_setup() {
developer74503112023-06-29 17:34:49 +0800405 country chanbw distance \
406 txpower antenna_gain \
407 rxantenna txantenna \
408- frag rts beacon_int:100 htmode
409+ frag rts beacon_int:100 htmode \
410+ sr_enable sr_enhanced
411 json_get_values basic_rate_list basic_rate
412 json_get_values scan_list scan_list
413 json_select ..
developer2c6592a2023-07-21 11:20:56 +0800414@@ -1180,6 +1326,7 @@ drv_mac80211_setup() {
developer1952bcd2023-06-20 20:14:37 +0800415 no_ap=1
416 macidx=0
417 staidx=0
418+ mbssidx=0
419
420 [ -n "$chanbw" ] && {
421 for file in /sys/kernel/debug/ieee80211/$phy/ath9k*/chanbw /sys/kernel/debug/ieee80211/$phy/ath5k/bwmode; do
developer2c6592a2023-07-21 11:20:56 +0800422@@ -1219,6 +1366,16 @@ drv_mac80211_setup() {
developer0ba09b62023-03-10 18:43:49 +0800423 for_each_interface "sta adhoc mesh" mac80211_set_noscan
424 [ -n "$has_ap" ] && mac80211_hostapd_setup_base "$phy"
425
426+ total_num_ap=0
427+ max_mbssid=1
428+ for_each_interface "ap" mac80211_count_ap
429+ total_num_ap=$(($total_num_ap - 1))
430+ while [ $total_num_ap -gt 0 ]
431+ do
432+ total_num_ap=$(($total_num_ap >> 1))
433+ max_mbssid=$(($max_mbssid << 1))
434+ done
435+
436 mac80211_prepare_iw_htmode
437 for_each_interface "sta adhoc mesh monitor" mac80211_prepare_vif
438 NEWAPLIST=
developer2c6592a2023-07-21 11:20:56 +0800439@@ -1251,6 +1408,14 @@ drv_mac80211_setup() {
developerad1f3172023-05-02 11:10:08 +0800440 if [ "$no_reload" != "0" ]; then
441 add_ap=1
442 ubus wait_for hostapd
443+
444+ # each phy sleeps different times to prevent for ubus race condition.
445+ if [ "$phy" = "phy1" ]; then
446+ sleep 1;
447+ elif [ "$phy" = "phy2" ]; then
448+ sleep 2;
449+ fi
450+
451 local hostapd_res="$(ubus call hostapd config_add "{\"iface\":\"$primary_ap\", \"config\":\"${hostapd_conf_file}\"}")"
452 ret="$?"
453 [ "$ret" != 0 -o -z "$hostapd_res" ] && {
developer2c6592a2023-07-21 11:20:56 +0800454@@ -1266,6 +1431,9 @@ drv_mac80211_setup() {
developer74503112023-06-29 17:34:49 +0800455 [ "${add_ap}" = 1 ] && sleep 1
456 for_each_interface "ap" mac80211_setup_vif
457
458+ [ -n "$sr_enable" ] && echo "$sr_enable" > /sys/kernel/debug/ieee80211/$phy/mt76/sr_enable
459+ [ -n "$sr_enhanced" ] && echo "$sr_enhanced" > /sys/kernel/debug/ieee80211/$phy/mt76/sr_enhanced_enable
460+
461 NEWSPLIST=
462 NEWUMLIST=
463
developer9b3248d2022-07-06 00:44:05 +0800464diff --git a/package/kernel/mac80211/files/lib/wifi/mac80211.sh b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
developer2c6592a2023-07-21 11:20:56 +0800465index e24a2a63..20e60688 100644
developere2597ba2022-06-24 13:09:16 +0800466--- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh
467+++ b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
developer20ce7bd2023-05-20 13:25:14 +0800468@@ -60,6 +60,9 @@ BEGIN {
developer785b6502023-04-19 18:31:11 +0800469 if (vht && band != "1:") mode="VHT80"
470 if (he) mode="HE80"
471 if (he && band == "1:") mode="HE20"
developer20ce7bd2023-05-20 13:25:14 +0800472+ if (eht && band == "2:") mode="EHT160"
473+ if (eht && band == "4:") mode="EHT320"
developer785b6502023-04-19 18:31:11 +0800474+ if (eht && band == "1:") mode="EHT20"
475 sub("\\[", "", channel)
476 sub("\\]", "", channel)
477 bands = bands band channel ":" mode " "
developer20ce7bd2023-05-20 13:25:14 +0800478@@ -73,6 +76,7 @@ $1 == "Band" {
developer785b6502023-04-19 18:31:11 +0800479 vht = ""
480 ht = ""
481 he = ""
482+ eht = ""
483 }
484
485 $0 ~ "Capabilities:" {
developer20ce7bd2023-05-20 13:25:14 +0800486@@ -87,6 +91,18 @@ $0 ~ "HE Iftypes" {
developer785b6502023-04-19 18:31:11 +0800487 he=1
488 }
489
490+$0 ~ "EHT Iftypes" {
491+ eht=1
492+}
493+
developer20ce7bd2023-05-20 13:25:14 +0800494+$0 ~ / *HE MAC Capabilities \(0x000000000000\)/ {
495+ he=0
496+}
497+
498+$0 ~ / *EHT MAC Capabilities \(0x0000\)/ {
499+ eht=0
500+}
501+
developer785b6502023-04-19 18:31:11 +0800502 $1 == "*" && $3 == "MHz" && $0 !~ /disabled/ && band && !channel {
503 channel = $4
504 }
developer2c6592a2023-07-21 11:20:56 +0800505@@ -120,6 +136,19 @@ get_band_defaults() {
developere2597ba2022-06-24 13:09:16 +0800506 mode_band="$band"
507 channel="$chan"
508 htmode="$mode"
509+ if [ "$band" = "6g" ]
510+ then
511+ encryption=sae
512+ key=12345678
developer20ce7bd2023-05-20 13:25:14 +0800513+ sae_pwe=2
514+ ieee80211w=2
developeradbb45b2023-06-09 14:43:01 +0800515+ channel=37
516+ mbssid=1
developere2597ba2022-06-24 13:09:16 +0800517+ else
developer659b07e2023-05-25 12:34:13 +0800518+ noscan=1
developere2597ba2022-06-24 13:09:16 +0800519+ encryption=none
developer2c6592a2023-07-21 11:20:56 +0800520+ rnr=1
developere2597ba2022-06-24 13:09:16 +0800521+ fi
522 done
523 }
524
developer2c6592a2023-07-21 11:20:56 +0800525@@ -153,6 +182,10 @@ detect_mac80211() {
developer785b6502023-04-19 18:31:11 +0800526
527 json_load_file /etc/board.json
528
529+ # generate random bytes for macaddr
530+ rand=$(hexdump -C /dev/urandom | head -n 1 &)
531+ killall hexdump
532+
533 for _dev in /sys/class/ieee80211/*; do
534 [ -e "$_dev" ] || continue
535
developer2c6592a2023-07-21 11:20:56 +0800536@@ -162,6 +195,13 @@ detect_mac80211() {
developere2597ba2022-06-24 13:09:16 +0800537 channel=""
538 htmode=""
539 ht_capab=""
540+ encryption=""
developer659b07e2023-05-25 12:34:13 +0800541+ noscan=""
developere2597ba2022-06-24 13:09:16 +0800542+ key=""
developer09257932023-05-09 13:41:30 +0800543+ sae_pwe=""
developer20ce7bd2023-05-20 13:25:14 +0800544+ ieee80211w=""
developeradbb45b2023-06-09 14:43:01 +0800545+ mbssid=""
developer2c6592a2023-07-21 11:20:56 +0800546+ rnr=""
developere2597ba2022-06-24 13:09:16 +0800547
548 get_band_defaults "$dev"
549
developer2c6592a2023-07-21 11:20:56 +0800550@@ -196,6 +236,14 @@ detect_mac80211() {
developer785b6502023-04-19 18:31:11 +0800551 ;;
552 esac
553
developer212c0d82023-07-13 19:41:47 +0800554+ macaddr=""
developer1325ba72023-06-26 13:43:31 +0800555+ if (dmesg | grep -q "eeprom load fail"); then
developer1952bcd2023-06-20 20:14:37 +0800556+ for i in $(seq 2 3); do
557+ macaddr=${macaddr}:$(echo $rand | cut -d ' ' -f $i)
558+ done
559+ macaddr="00:0$(($devidx - 1)):55:66${macaddr}"
developer1952bcd2023-06-20 20:14:37 +0800560+ fi
developer785b6502023-04-19 18:31:11 +0800561+
562 uci -q batch <<-EOF
563 set wireless.${name}=wifi-device
564 set wireless.${name}.type=mac80211
developer2c6592a2023-07-21 11:20:56 +0800565@@ -203,15 +251,40 @@ detect_mac80211() {
developer09257932023-05-09 13:41:30 +0800566 set wireless.${name}.channel=${channel}
567 set wireless.${name}.band=${mode_band}
568 set wireless.${name}.htmode=$htmode
569- set wireless.${name}.disabled=1
developer20ce7bd2023-05-20 13:25:14 +0800570+ set wireless.${name}.country='US'
developer659b07e2023-05-25 12:34:13 +0800571+ set wireless.${name}.noscan=${noscan}
developer09257932023-05-09 13:41:30 +0800572+ set wireless.${name}.disabled=0
developeradbb45b2023-06-09 14:43:01 +0800573+EOF
574+ [ -n "$mbssid" ] && {
575+ uci -q set wireless.${name}.mbssid=${mbssid}
576+ }
developer2c6592a2023-07-21 11:20:56 +0800577+ [ -n "$rnr" ] && {
578+ uci -q set wireless.${name}.rnr=${rnr}
579+ }
developer09257932023-05-09 13:41:30 +0800580
developeradbb45b2023-06-09 14:43:01 +0800581+ uci -q batch <<-EOF
developer09257932023-05-09 13:41:30 +0800582 set wireless.default_${name}=wifi-iface
583 set wireless.default_${name}.device=${name}
developer8d77be32022-10-20 15:08:25 +0800584 set wireless.default_${name}.network=lan
585 set wireless.default_${name}.mode=ap
developer09257932023-05-09 13:41:30 +0800586- set wireless.default_${name}.ssid=OpenWrt
developer8d77be32022-10-20 15:08:25 +0800587- set wireless.default_${name}.encryption=none
developer09257932023-05-09 13:41:30 +0800588+ set wireless.default_${name}.ssid=OpenWrt-${mode_band}
developer8d77be32022-10-20 15:08:25 +0800589+ set wireless.default_${name}.encryption=${encryption}
developere2597ba2022-06-24 13:09:16 +0800590 EOF
developer212c0d82023-07-13 19:41:47 +0800591+
592+ # calibrated board will use eeprom macaddress, not ramdom address
593+ [ -n "$macaddr" ] && {
594+ uci -q set wireless.default_${name}.macaddr=${macaddr}
595+ }
596+
developere2597ba2022-06-24 13:09:16 +0800597+ [ -n "$key" ] && {
developer8d77be32022-10-20 15:08:25 +0800598+ uci -q set wireless.default_${name}.key=${key}
developere2597ba2022-06-24 13:09:16 +0800599+ }
developer09257932023-05-09 13:41:30 +0800600+ [ -n "$sae_pwe" ] && {
601+ uci -q set wireless.default_${name}.sae_pwe=${sae_pwe}
602+ }
developer20ce7bd2023-05-20 13:25:14 +0800603+ [ -n "$ieee80211w" ] && {
604+ uci -q set wireless.default_${name}.ieee80211w=${ieee80211w}
605+ }
developere2597ba2022-06-24 13:09:16 +0800606 uci -q commit wireless
developer8d77be32022-10-20 15:08:25 +0800607 done
608 }
developer85839fe2023-02-23 10:32:51 +0800609diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh
developer9097e5e2023-07-19 10:22:24 +0800610index bf3625c9..6ce28b4c 100644
developer85839fe2023-02-23 10:32:51 +0800611--- a/package/network/services/hostapd/files/hostapd.sh
612+++ b/package/network/services/hostapd/files/hostapd.sh
developer74503112023-06-29 17:34:49 +0800613@@ -60,7 +60,14 @@ hostapd_append_wpa_key_mgmt() {
614 [ "${ieee80211w:-0}" -gt 0 ] && append wpa_key_mgmt "WPA-EAP-SHA256"
615 ;;
616 sae)
617- append wpa_key_mgmt "SAE"
618+ case "$encryption" in
619+ *sae-ext*)
620+ append wpa_key_mgmt "SAE-EXT-KEY"
621+ ;;
622+ *)
623+ append wpa_key_mgmt "SAE"
624+ ;;
625+ esac
626 [ "${ieee80211r:-0}" -gt 0 ] && append wpa_key_mgmt "FT-SAE"
627 ;;
628 psk-sae)
629@@ -115,6 +122,7 @@ hostapd_common_add_device_config() {
630 config_add_int rts_threshold
631 config_add_int rssi_reject_assoc_rssi
632 config_add_int rssi_ignore_probe_request
633+ config_add_int rssi_reject_assoc_timeout
634 config_add_int maxassoc
635
636 config_add_string acs_chan_bias
637@@ -227,8 +235,10 @@ hostapd_prepare_device_config() {
638 hostapd_add_rate brlist "$br"
639 done
640
641+ json_get_vars rssi_reject_assoc_timeout
642 [ -n "$rssi_reject_assoc_rssi" ] && append base_cfg "rssi_reject_assoc_rssi=$rssi_reject_assoc_rssi" "$N"
643 [ -n "$rssi_ignore_probe_request" ] && append base_cfg "rssi_ignore_probe_request=$rssi_ignore_probe_request" "$N"
644+ [ -n "$rssi_reject_assoc_timeout" ] && append base_cfg "rssi_reject_assoc_timeout=$rssi_reject_assoc_timeout" "$N"
645 [ -n "$beacon_rate" ] && append base_cfg "beacon_rate=$beacon_rate" "$N"
646 [ -n "$rlist" ] && append base_cfg "supported_rates=$rlist" "$N"
647 [ -n "$brlist" ] && append base_cfg "basic_rates=$brlist" "$N"
648@@ -379,6 +389,24 @@ hostapd_common_add_bss_config() {
developer82408892023-03-27 15:09:00 +0800649 config_add_string fils_dhcp
650
651 config_add_int ocv
652+
653+ config_add_int disable_eht
654+ config_add_int disable_he
655+ config_add_int disable_vht
656+ config_add_int disable_ht
developer813f5d72023-03-28 17:44:38 +0800657+
developerf166f542023-05-25 14:40:30 +0800658+ config_add_boolean beacon_prot interworking
developer74503112023-06-29 17:34:49 +0800659+
660+ config_add_int unsol_bcast_probe_resp_interval
661+ config_add_int fils_discovery_min_interval
662+ config_add_int fils_discovery_max_interval
663+ config_add_boolean rnr
664+
665+ config_add_array sae_groups
666+ config_add_array owe_groups
667+ config_add_array pairwise
668+ config_add_string group_cipher
669+
developer82408892023-03-27 15:09:00 +0800670 }
671
672 hostapd_set_vlan_file() {
developer74503112023-06-29 17:34:49 +0800673@@ -443,11 +471,11 @@ append_iw_nai_realm() {
developerf166f542023-05-25 14:40:30 +0800674 }
675
676 append_iw_venue_name() {
677- append bss_conf "venue_name=$1" "$N"
678+ [ -n "$1" ] && append bss_conf "venue_name=$1" "$N"
679 }
680
681 append_iw_venue_url() {
682- append bss_conf "venue_url=$1" "$N"
683+ [ -n "$1" ] && append bss_conf "venue_url=$1" "$N"
684 }
685
686 append_hs20_oper_friendly_name() {
developer74503112023-06-29 17:34:49 +0800687@@ -565,7 +593,8 @@ hostapd_set_bss_options() {
688 ppsk airtime_bss_weight airtime_bss_limit airtime_sta_weight \
689 multicast_to_unicast_all proxy_arp per_sta_vif \
690 eap_server eap_user_file ca_cert server_cert private_key private_key_passwd server_id \
691- vendor_elements fils ocv
692+ vendor_elements fils ocv unsol_bcast_probe_resp_interval fils_discovery_min_interval \
693+ fils_discovery_max_interval rnr group_cipher
694
695 set_default fils 0
696 set_default isolate 0
developer9097e5e2023-07-19 10:22:24 +0800697@@ -793,6 +822,35 @@ hostapd_set_bss_options() {
developer74503112023-06-29 17:34:49 +0800698 local auth_algs="$((($auth_mode_shared << 1) | $auth_mode_open))"
699 append bss_conf "auth_algs=${auth_algs:-1}" "$N"
700 append bss_conf "wpa=$wpa" "$N"
701+
702+ json_get_values pairwise pairwise
developer9097e5e2023-07-19 10:22:24 +0800703+ if [ -n "$pairwise" ]; then
704+ case "$pairwise" in
705+ *tkip+aes|*tkip+ccmp|*aes+tkip|*ccmp+tkip)
706+ wpa_cipher="CCMP TKIP"
707+ ;;
708+ *ccmp256)
709+ wpa_cipher="CCMP-256"
710+ ;;
711+ *aes|*ccmp)
712+ wpa_cipher="CCMP"
713+ ;;
714+ *tkip)
715+ wpa_cipher="TKIP"
716+ ;;
717+ *gcmp256)
718+ wpa_cipher="GCMP-256"
719+ ;;
720+ *gcmp)
721+ wpa_cipher="GCMP"
722+ ;;
723+ *)
724+ wpa_cipher=""
725+ ;;
726+ esac
727+ fi
developer74503112023-06-29 17:34:49 +0800728+ [ -n "$wpa_cipher" ] && wpa_pairwise="$wpa_cipher"
729+
730 [ -n "$wpa_pairwise" ] && append bss_conf "wpa_pairwise=$wpa_pairwise" "$N"
731
732 set_default wps_pushbutton 0
developer9097e5e2023-07-19 10:22:24 +0800733@@ -844,7 +902,7 @@ hostapd_set_bss_options() {
developerda723192023-05-22 19:46:10 +0800734 }
735
736 append bss_conf "ssid=$ssid" "$N"
737- [ -n "$network_bridge" ] && append bss_conf "bridge=$network_bridge${N}wds_bridge=" "$N"
738+ [ -n "$network_bridge" ] && append bss_conf "bridge=$network_bridge${N}wds_bridge=$network_bridge" "$N"
739 [ -n "$network_ifname" ] && append bss_conf "snoop_iface=$network_ifname" "$N"
740 [ -n "$iapp_interface" ] && {
741 local ifname
developer9097e5e2023-07-19 10:22:24 +0800742@@ -957,6 +1015,8 @@ hostapd_set_bss_options() {
developer74503112023-06-29 17:34:49 +0800743 fi
744
745 if [ "$wpa" -ge "2" ]; then
746+ json_get_values sae_groups sae_groups
747+ json_get_values owe_groups owe_groups
748 if [ -n "$network_bridge" -a "$rsn_preauth" = 1 ]; then
749 set_default auth_cache 1
750 append bss_conf "rsn_preauth=1" "$N"
developer9097e5e2023-07-19 10:22:24 +0800751@@ -975,17 +1035,42 @@ hostapd_set_bss_options() {
developer74503112023-06-29 17:34:49 +0800752 append bss_conf "okc=$auth_cache" "$N"
753 [ "$auth_cache" = 0 -a "$fils" = 0 ] && append bss_conf "disable_pmksa_caching=1" "$N"
754
755+ [ -z "$group_cipher" ] && group_cipher="$wpa_cipher"
756+
757+ if [ -n "$sae_groups" -o -n "$owe_groups" ]; then
758+ case "$auth_type" in
759+ sae*)
760+ append bss_conf "sae_groups=$sae_groups" "$N"
761+ append bss_conf "group_cipher=$group_cipher" "$N"
762+ ;;
763+ owe)
764+ append bss_conf "owe_groups=$owe_groups" "$N"
765+ append bss_conf "group_cipher=$group_cipher" "$N"
766+ ;;
767+ esac
768+ fi
769+
developer813f5d72023-03-28 17:44:38 +0800770 # RSN -> allow management frame protection
771 case "$ieee80211w" in
772 [012])
773- json_get_vars ieee80211w_mgmt_cipher ieee80211w_max_timeout ieee80211w_retry_timeout
774+ json_get_vars ieee80211w_mgmt_cipher ieee80211w_max_timeout ieee80211w_retry_timeout beacon_prot
775 append bss_conf "ieee80211w=$ieee80211w" "$N"
776 [ "$ieee80211w" -gt "0" ] && {
developer74503112023-06-29 17:34:49 +0800777+ case "$group_cipher" in
778+ CCMP*)
779+ ieee80211w_mgmt_cipher="AES-128-CMAC"
780+ ;;
781+ GCMP-256)
782+ [[ "$encryption" != "*owe*" ]] && ieee80211w_mgmt_cipher="BIP-GMAC-256"
783+ ;;
784+ esac
developer813f5d72023-03-28 17:44:38 +0800785 if [ "$auth_type" = "eap192" ]; then
developer74503112023-06-29 17:34:49 +0800786 append bss_conf "group_mgmt_cipher=BIP-GMAC-256" "$N"
developer813f5d72023-03-28 17:44:38 +0800787 else
788 append bss_conf "group_mgmt_cipher=${ieee80211w_mgmt_cipher:-AES-128-CMAC}" "$N"
789 fi
790+ [ -n "$beacon_prot" ] && \
791+ append bss_conf "beacon_prot=$beacon_prot" "$N"
792 [ -n "$ieee80211w_max_timeout" ] && \
793 append bss_conf "assoc_sa_query_max_timeout=$ieee80211w_max_timeout" "$N"
794 [ -n "$ieee80211w_retry_timeout" ] && \
developer9097e5e2023-07-19 10:22:24 +0800795@@ -1050,9 +1135,10 @@ hostapd_set_bss_options() {
developerf166f542023-05-25 14:40:30 +0800796 json_get_vars iw_roaming_consortium iw_domain_name iw_anqp_3gpp_cell_net iw_nai_realm
797 json_get_vars iw_anqp_elem iw_qos_map_set iw_ipaddr_type_availability iw_gas_address3
798 json_get_vars iw_venue_name iw_venue_url
799+ json_get_vars interworking
800
801 set_default iw_enabled 0
802- if [ "$iw_enabled" = "1" ]; then
803+ if [ "$iw_enabled" = "1" ] || [ "$interworking" = "1" ]; then
804 append bss_conf "interworking=1" "$N"
805 set_default iw_internet 1
806 set_default iw_asra 0
developer9097e5e2023-07-19 10:22:24 +0800807@@ -1159,6 +1245,22 @@ hostapd_set_bss_options() {
developer74503112023-06-29 17:34:49 +0800808 append bss_conf "$val" "$N"
809 done
810
811+ if [ "$unsol_bcast_probe_resp_interval" -gt 0 ]; then
812+ append bss_conf "unsol_bcast_probe_resp_interval=$unsol_bcast_probe_resp_interval" "$N"
813+ fi
814+
815+ if [ -n "$fils_discovery_min_interval" ]; then
816+ append bss_conf "fils_discovery_min_interval=$fils_discovery_min_interval" "$N"
817+ fi
818+
819+ if [ -n "$fils_discovery_max_interval" ]; then
820+ append bss_conf "fils_discovery_max_interval=$fils_discovery_max_interval" "$N"
821+ fi
822+
823+ if [ -n "$rnr" ]; then
824+ append bss_conf "rnr=$rnr" "$N"
825+ fi
826+
827 bss_md5sum="$(echo $bss_conf | md5sum | cut -d" " -f1)"
828 append bss_conf "config_id=$bss_md5sum" "$N"
829
developer9097e5e2023-07-19 10:22:24 +0800830@@ -1249,6 +1351,7 @@ wpa_supplicant_prepare_interface() {
developer18015ad2023-07-13 13:18:19 +0800831 country_str="country=$country"
832 }
833
developer2cf3f4c2023-07-24 16:58:25 +0800834+ local tx_queue_data2_burst="tx_queue_data2_burst=0"
developer18015ad2023-07-13 13:18:19 +0800835 multiap_flag_file="${_config}.is_multiap"
836 if [ "$multi_ap" = "1" ]; then
837 touch "$multiap_flag_file"
developer9097e5e2023-07-19 10:22:24 +0800838@@ -1260,6 +1363,7 @@ wpa_supplicant_prepare_interface() {
developer18015ad2023-07-13 13:18:19 +0800839 ${scan_list:+freq_list=$scan_list}
840 $ap_scan
841 $country_str
842+$tx_queue_data2_burst
843 EOF
844 return 0
845 }
developer9097e5e2023-07-19 10:22:24 +0800846@@ -1531,12 +1635,43 @@ wpa_supplicant_add_network() {
developer74503112023-06-29 17:34:49 +0800847 ;;
848 esac
849
850+ json_get_values pairwise pairwise
developer9097e5e2023-07-19 10:22:24 +0800851+ if [ -n "$pairwise" ]; then
852+ case "$pairwise" in
853+ *tkip+aes|*tkip+ccmp|*aes+tkip|*ccmp+tkip)
854+ wpa_cipher="CCMP TKIP"
855+ ;;
856+ *ccmp256)
857+ wpa_cipher="CCMP-256"
858+ ;;
859+ *aes|*ccmp)
860+ wpa_cipher="CCMP"
861+ ;;
862+ *tkip)
863+ wpa_cipher="TKIP"
864+ ;;
865+ *gcmp256)
866+ wpa_cipher="GCMP-256"
867+ ;;
868+ *gcmp)
869+ wpa_cipher="GCMP"
870+ ;;
871+ *)
872+ wpa_cipher=""
873+ ;;
874+ esac
875+ fi
developer74503112023-06-29 17:34:49 +0800876+ [ -n "$wpa_cipher" ] && wpa_pairwise="$wpa_cipher"
877+
878 [ "$wpa_cipher" = GCMP ] && {
879 append network_data "pairwise=GCMP" "$N$T"
880 append network_data "group=GCMP" "$N$T"
881 }
882
883 [ "$mode" = mesh ] || {
884+ json_get_values sae_groups sae_groups
885+ json_get_values owe_groups owe_groups
886+
887 case "$wpa" in
888 1)
889 append network_data "proto=WPA" "$N$T"
developer9097e5e2023-07-19 10:22:24 +0800890@@ -1546,12 +1681,48 @@ wpa_supplicant_add_network() {
developer74503112023-06-29 17:34:49 +0800891 ;;
892 esac
893
894+ [ -n "$wpa_pairwise" ] && append network_data "pairwise=$wpa_pairwise" "$N$T"
895+ [ -z "$group_cipher" ] && group_cipher="$wpa_cipher"
896+
897+ if [ -n "$sae_groups" -o -n "$owe_groups" ]; then
898+ case "$auth_type" in
899+ sae*)
900+ echo "sae_groups=$sae_groups" >> "$_config"
901+ append network_data "group=$group_cipher" "$N$T"
902+ ;;
903+ owe)
904+ append network_data "owe_group=$owe_groups" "$N$T"
905+ append network_data "group=$group_cipher" "$N$T"
906+ ;;
907+ esac
908+ fi
909+
910+ # RSN -> allow management frame protection
911 case "$ieee80211w" in
912 [012])
913- [ "$wpa" -ge 2 ] && append network_data "ieee80211w=$ieee80211w" "$N$T"
914+ json_get_vars ieee80211w_mgmt_cipher ieee80211w_max_timeout ieee80211w_retry_timeout beacon_prot
915+ append network_data "ieee80211w=$ieee80211w" "$N$T"
916+ [ "$ieee80211w" -gt "0" ] && {
917+ case "$group_cipher" in
918+ CCMP*)
919+ ieee80211w_mgmt_cipher="AES-128-CMAC"
920+ ;;
921+ GCMP-256)
922+ [[ "$encryption" != "*owe*" ]] && ieee80211w_mgmt_cipher="BIP-GMAC-256"
923+ ;;
924+ esac
925+ if [ "$auth_type" = "eap192" ]; then
926+ append network_data "group_mgmt=BIP-GMAC-256" "$N$T"
927+ else
928+ append network_data "group_mgmt=${ieee80211w_mgmt_cipher:-AES-128-CMAC}" "$N$T"
929+ fi
930+ [ -n "$beacon_prot" ] && \
931+ append network_data "beacon_prot=$beacon_prot" "$N$T"
932+ }
933 ;;
934 esac
935 }
936+
937 [ -n "$bssid" ] && append network_data "bssid=$bssid" "$N$T"
938 [ -n "$beacon_int" ] && append network_data "beacon_int=$beacon_int" "$N$T"
939
developer9097e5e2023-07-19 10:22:24 +0800940@@ -1562,6 +1733,20 @@ wpa_supplicant_add_network() {
developer82408892023-03-27 15:09:00 +0800941 [ -n "$bssid_blacklist" ] && append network_data "bssid_blacklist=$bssid_blacklist" "$N$T"
942 [ -n "$bssid_whitelist" ] && append network_data "bssid_whitelist=$bssid_whitelist" "$N$T"
943
944+ local disable_eht
945+ local disable_he
946+ local disable_vht
947+ local disable_ht
948+ json_get_vars disable_eht
949+ json_get_vars disable_he
950+ json_get_vars disable_vht
951+ json_get_vars disable_ht
952+
953+ [ -n "$disable_eht" ] && append network_data "disable_eht=$disable_eht" "$N$T"
954+ [ -n "$disable_he" ] && append network_data "disable_he=$disable_he" "$N$T"
955+ [ -n "$disable_vht" ] && append network_data "disable_vht=$disable_vht" "$N$T"
956+ [ -n "$disable_ht" ] && append network_data "disable_ht=$disable_ht" "$N$T"
957+
958 [ -n "$basic_rate" ] && {
959 local br rate_list=
960 for br in $basic_rate; do
developer9097e5e2023-07-19 10:22:24 +0800961@@ -1576,6 +1761,11 @@ wpa_supplicant_add_network() {
developer85839fe2023-02-23 10:32:51 +0800962 append network_data "mcast_rate=$mc_rate" "$N$T"
963 }
964
965+ if [ "$auth_type" = "sae" ]; then
966+ json_get_vars sae_pwe sae_pwe
967+ [ -n "$sae_pwe" ] && echo "sae_pwe=$sae_pwe" >> "$_config"
968+ fi
969+
970 if [ "$key_mgmt" = "WPS" ]; then
971 echo "wps_cred_processing=1" >> "$_config"
972 else