blob: f77b6a23b7a68207d55d20b16a083243921be9ba [file] [log] [blame]
developerce9e5092022-11-10 22:41:59 +08001diff --git a/package/kernel/mac80211/Makefile b/package/kernel/mac80211/Makefile
developera3facda2024-01-11 18:19:27 +08002index 17e0d945..c73238a2 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
developerafe1b5b2023-10-19 07:11:26 +080024@@ -297,6 +302,7 @@ define Build/Prepare
developer356ecec2022-11-14 10:25:04 +080025 mkdir -p $(PKG_BUILD_DIR)
26 $(PKG_UNPACK)
27 $(Build/Patch)
developerafe1b5b2023-10-19 07:11:26 +080028+ $(CP) $(SOURCE_PATH)/* $(PKG_BUILD_DIR) 2>/dev/null || :
developer356ecec2022-11-14 10:25:04 +080029 rm -rf \
30 $(PKG_BUILD_DIR)/include/linux/ssb \
31 $(PKG_BUILD_DIR)/include/linux/bcma \
developer67bb1212024-02-04 16:58:38 +080032diff --git a/package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh b/package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh
developer3df069f2024-01-15 09:40:28 +080033index 6572999f..5e44e663 100644
developer67bb1212024-02-04 16:58:38 +080034--- a/package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh
35+++ b/package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh
developer3df069f2024-01-15 09:40:28 +080036@@ -29,10 +29,12 @@ drv_mac80211_init_device_config() {
developer0ba09b62023-03-10 18:43:49 +080037 config_add_string path phy 'macaddr:macaddr'
38 config_add_string tx_burst
developer0ba09b62023-03-10 18:43:49 +080039 config_add_string distance
developer93607dd2023-08-30 04:53:00 +080040+ config_add_int mbssid mu_onoff sr_enable sr_enhanced rnr obss_interval
developer0ba09b62023-03-10 18:43:49 +080041 config_add_int beacon_int chanbw frag rts
developer93607dd2023-08-30 04:53:00 +080042 config_add_int rxantenna txantenna txpower min_tx_power
developer37215362023-09-15 14:16:34 +080043 config_add_int num_global_macaddr multiple_bssid
44 config_add_boolean noscan ht_coex acs_exclude_dfs background_radar
developer75c99f42023-09-04 11:28:21 +080045+ config_add_boolean noscan ht_coex acs_exclude_dfs background_radar background_cert_mode
46 config_add_array ht_capab
47 config_add_array channels
48 config_add_array scan_list
developer3df069f2024-01-15 09:40:28 +080049@@ -55,7 +57,10 @@ drv_mac80211_init_device_config() {
developer785b6502023-04-19 18:31:11 +080050 he_spr_sr_control \
51 he_spr_psr_enabled \
52 he_bss_color_enabled \
53- he_twt_required
54+ he_twt_required \
55+ he_twt_responder \
56+ etxbfen \
57+ itxbfen
58 config_add_int \
59 beamformer_antennas \
60 beamformee_antennas \
developer3df069f2024-01-15 09:40:28 +080061@@ -142,13 +147,11 @@ mac80211_hostapd_setup_base() {
developer0ba09b62023-03-10 18:43:49 +080062 [ -n "$acs_exclude_dfs" ] && [ "$acs_exclude_dfs" -gt 0 ] &&
63 append base_cfg "acs_exclude_dfs=1" "$N"
64
65- json_get_vars noscan ht_coex min_tx_power:0 tx_burst
developer93607dd2023-08-30 04:53:00 +080066+ json_get_vars noscan ht_coex min_tx_power:0 tx_burst mbssid mu_onoff rnr obss_interval
developer2c4f7e82023-05-11 19:56:55 +080067+ json_get_vars etxbfen:1 itxbfen:0
developer8d77be32022-10-20 15:08:25 +080068 json_get_values ht_capab_list ht_capab
developer20d67712022-03-02 14:09:32 +080069 json_get_values channel_list channels
70
71- [ "$auto_channel" = 0 ] && [ -z "$channel_list" ] && \
72- channel_list="$channel"
73-
developer622bc432024-01-08 10:52:16 +080074 [ "$min_tx_power" -gt 0 ] && append base_cfg "min_tx_power=$min_tx_power" "$N"
developer20d67712022-03-02 14:09:32 +080075
developer9b3248d2022-07-06 00:44:05 +080076 set_default noscan 0
developer3df069f2024-01-15 09:40:28 +080077@@ -162,21 +165,42 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +080078 ieee80211n=1
79 ht_capab=
80 case "$htmode" in
81- VHT20|HT20|HE20) ;;
82- HT40*|VHT40|VHT80|VHT160|HE40|HE80|HE160)
83+ VHT20|HT20|HE20|EHT20) ;;
developerbe3cf972023-04-27 09:58:26 +080084+ HT40*|VHT40|VHT80|VHT160|HE40*|HE80|HE160|EHT40*|EHT80|EHT160|EHT320*)
developer785b6502023-04-19 18:31:11 +080085 case "$hwmode" in
86 a)
87 case "$(( (($channel / 4) + $chan_ofs) % 2 ))" in
developerda1bac72023-09-19 10:32:47 +080088 1) ht_capab="[HT40+]";;
89 0) ht_capab="[HT40-]";;
90 esac
91+ case "$htmode" in
92+ HT40-|HE40-|EHT40-)
93+ if [ "$auto_channel" -gt 0 ]; then
94+ ht_capab="[HT40-]"
95+ fi
96+ ;;
97+ esac
developerbe3cf972023-04-27 09:58:26 +080098 ;;
99 *)
100 case "$htmode" in
101- HT40+) ht_capab="[HT40+]";;
102- HT40-) ht_capab="[HT40-]";;
103+ HT40+|HE40+|EHT40+)
104+ if [ "$channel" -gt 9 ]; then
105+ echo "Could not set the center freq with this HT mode setting"
106+ return 1
107+ else
108+ ht_capab="[HT40+]"
109+ fi
110+ ;;
111+ HT40-|HE40-|EHT40-)
developerda1bac72023-09-19 10:32:47 +0800112+ if [ "$channel" -lt 5 -a "$auto_channel" -eq 0 ]; then
developerbe3cf972023-04-27 09:58:26 +0800113+ echo "Could not set the center freq with this HT mode setting"
114+ return 1
115+ else
116+ ht_capab="[HT40-]"
117+ fi
118+ ;;
119 *)
developerda1bac72023-09-19 10:32:47 +0800120- if [ "$channel" -lt 7 ]; then
121+ if [ "$channel" -lt 7 -o "$auto_channel" -gt 0 ]; then
developerbe3cf972023-04-27 09:58:26 +0800122 ht_capab="[HT40+]"
developerda1bac72023-09-19 10:32:47 +0800123 else
124 ht_capab="[HT40-]"
developer3df069f2024-01-15 09:40:28 +0800125@@ -185,7 +209,6 @@ mac80211_hostapd_setup_base() {
developerda1bac72023-09-19 10:32:47 +0800126 esac
127 ;;
128 esac
129- [ "$auto_channel" -gt 0 ] && ht_capab="[HT40+]"
130 ;;
131 *) ieee80211n= ;;
132 esac
developer3df069f2024-01-15 09:40:28 +0800133@@ -196,6 +219,11 @@ mac80211_hostapd_setup_base() {
developer93607dd2023-08-30 04:53:00 +0800134 set_default ht_coex 0
135 append base_cfg "ht_coex=$ht_coex" "$N"
136
137+ [ "$ht_coex" -eq 1 ] && {
138+ set_default obss_interval 300
139+ append base_cfg "obss_interval=$obss_interval" "$N"
140+ }
141+
142 json_get_vars \
143 ldpc:1 \
144 greenfield:0 \
developer3df069f2024-01-15 09:40:28 +0800145@@ -207,7 +235,7 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800146 dsss_cck_40:1
147
148 ht_cap_mask=0
149- for cap in $(iw phy "$phy" info | grep 'Capabilities:' | cut -d: -f2); do
150+ for cap in $(iw phy "$phy" info | grep 'Capabilities: 0x' | cut -d: -f2); do
151 ht_cap_mask="$(($ht_cap_mask | $cap))"
152 done
153
developer3df069f2024-01-15 09:40:28 +0800154@@ -238,8 +266,8 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800155
156 idx="$channel"
157 case "$htmode" in
158- VHT20|HE20) enable_ac=1;;
159- VHT40|HE40)
160+ VHT20|HE20|EHT20) enable_ac=1;;
161+ VHT40|HE40|EHT40)
162 case "$(( (($channel / 4) + $chan_ofs) % 2 ))" in
163 1) idx=$(($channel + 2));;
164 0) idx=$(($channel - 2));;
developer3df069f2024-01-15 09:40:28 +0800165@@ -247,7 +275,7 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800166 enable_ac=1
167 vht_center_seg0=$idx
168 ;;
169- VHT80|HE80)
170+ VHT80|HE80|EHT80)
171 case "$(( (($channel / 4) + $chan_ofs) % 4 ))" in
172 1) idx=$(($channel + 6));;
173 2) idx=$(($channel + 2));;
developer3df069f2024-01-15 09:40:28 +0800174@@ -258,7 +286,7 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800175 vht_oper_chwidth=1
176 vht_center_seg0=$idx
177 ;;
178- VHT160|HE160)
179+ VHT160|HE160|EHT160)
180 if [ "$band" = "6g" ]; then
181 case "$channel" in
182 1|5|9|13|17|21|25|29) idx=15;;
developer3df069f2024-01-15 09:40:28 +0800183@@ -273,23 +301,64 @@ mac80211_hostapd_setup_base() {
developeradd8de62023-05-02 16:25:52 +0800184 case "$channel" in
185 36|40|44|48|52|56|60|64) idx=50;;
186 100|104|108|112|116|120|124|128) idx=114;;
187+ 149|153|157|161|165|169|173|177) idx=163;;
188 esac
189 fi
190 enable_ac=1
developer785b6502023-04-19 18:31:11 +0800191 vht_oper_chwidth=2
192 vht_center_seg0=$idx
193 ;;
194+ EHT320*)
195+ case "$channel" in
196+ 1|5|9|13|17|21|25|29) idx=31;;
197+ 33|37|41|45|49|53|57|61| \
198+ 65|69|73|77|81|85|89|93) idx=63;;
199+ 97|101|105|109|113|117|121|125| \
200+ 129|133|137|141|145|149|153|157) idx=127;;
201+ 161|165|169|173|177|181|185|189| \
202+ 193|197|201|205|209|213|217|221) idx=191;;
203+ esac
204+ if [[ "$htmode" = "EHT320-1" && "$channel" -ge "193" ]] ||
205+ [[ "$htmode" = "EHT320-2" && "$channel" -le "29" ]]; then
206+ echo "Could not set the center freq with this EHT setting"
207+ return 1
208+ elif [[ "$htmode" = "EHT320-1" && "$channel" -ge "33" ]]; then
209+ if [ "$channel" -gt $idx ]; then
210+ idx=$(($idx + 32))
211+ else
212+ idx=$(($idx - 32))
213+ fi
214+ fi
215+ vht_oper_chwidth=2
216+ if [ "$channel" -gt $idx ]; then
217+ vht_center_seg0=$(($idx + 16))
218+ else
219+ vht_center_seg0=$(($idx - 16))
220+ fi
221+ eht_oper_chwidth=9
222+ eht_oper_centr_freq_seg0_idx=$idx
developer39a1e782023-10-27 17:44:18 +0800223+
224+ case $htmode in
225+ EHT320-1) eht_bw320_offset=1;;
226+ EHT320-2) eht_bw320_offset=2;;
227+ EHT320) eht_bw320_offset=0;;
228+ esac
developer785b6502023-04-19 18:31:11 +0800229+ ;;
230 esac
231 [ "$band" = "5g" ] && {
developer75c99f42023-09-04 11:28:21 +0800232- json_get_vars background_radar:0
233+ json_get_vars \
234+ background_radar:0 \
235+ background_cert_mode:0 \
236
237 [ "$background_radar" -eq 1 ] && append base_cfg "enable_background_radar=1" "$N"
238+ [ "$background_cert_mode" -eq 1 ] && append base_cfg "background_radar_mode=1" "$N"
239 }
developer785b6502023-04-19 18:31:11 +0800240 [ "$band" = "6g" ] && {
241 op_class=
242 case "$htmode" in
243- HE20) op_class=131;;
244- HE*) op_class=$((132 + $vht_oper_chwidth))
245+ HE20|EHT20) op_class=131;;
246+ EHT320*) op_class=137;;
247+ HE*|EHT*) op_class=$((132 + $vht_oper_chwidth))
248 esac
249 [ -n "$op_class" ] && append base_cfg "op_class=$op_class" "$N"
250 }
developer3df069f2024-01-15 09:40:28 +0800251@@ -317,7 +386,6 @@ mac80211_hostapd_setup_base() {
developer8b04dfd2022-12-07 16:29:19 +0800252 vht_link_adapt:3 \
253 vht160:2
254
255- set_default tx_burst 2.0
256 append base_cfg "ieee80211ac=1" "$N"
257 vht_cap=0
258 for cap in $(iw phy "$phy" info | awk -F "[()]" '/VHT Capabilities/ { print $2 }'); do
developer3df069f2024-01-15 09:40:28 +0800259@@ -336,6 +404,12 @@ mac80211_hostapd_setup_base() {
260 short_gi_160=0
261 }
developer785b6502023-04-19 18:31:11 +0800262
263+ [ "$etxbfen" -eq 0 ] && {
264+ su_beamformer=0
265+ su_beamformee=0
266+ mu_beamformer=0
267+ }
268+
269 mac80211_add_capabilities vht_capab $vht_cap \
270 RXLDPC:0x10::$rxldpc \
271 SHORT-GI-80:0x20::$short_gi_80 \
developer3df069f2024-01-15 09:40:28 +0800272@@ -417,7 +491,7 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800273 # 802.11ax
274 enable_ax=0
275 case "$htmode" in
276- HE*) enable_ax=1 ;;
277+ HE*|EHT*) enable_ax=1 ;;
278 esac
279
280 if [ "$enable_ax" != "0" ]; then
developer3df069f2024-01-15 09:40:28 +0800281@@ -426,10 +500,11 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800282 he_su_beamformee:1 \
283 he_mu_beamformer:1 \
284 he_twt_required:0 \
285+ he_twt_responder \
286 he_spr_sr_control:3 \
287 he_spr_psr_enabled:0 \
288 he_spr_non_srg_obss_pd_max_offset:0 \
289- he_bss_color:128 \
290+ he_bss_color \
291 he_bss_color_enabled:1
292
293 he_phy_cap=$(iw phy "$phy" info | sed -n '/HE Iftypes: AP/,$p' | awk -F "[()]" '/HE PHY Capabilities/ { print $2 }' | head -1)
developer3df069f2024-01-15 09:40:28 +0800294@@ -443,6 +518,11 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800295 append base_cfg "he_oper_centr_freq_seg0_idx=$vht_center_seg0" "$N"
296 }
297
298+ [ "$etxbfen" -eq 0 ] && {
299+ he_su_beamformer=0
300+ he_mu_beamformer=0
301+ }
302+
303 mac80211_add_he_capabilities \
304 he_su_beamformer:${he_phy_cap:6:2}:0x80:$he_su_beamformer \
305 he_su_beamformee:${he_phy_cap:8:2}:0x1:$he_su_beamformee \
developer3df069f2024-01-15 09:40:28 +0800306@@ -450,7 +530,14 @@ mac80211_hostapd_setup_base() {
developer785b6502023-04-19 18:31:11 +0800307 he_spr_psr_enabled:${he_phy_cap:14:2}:0x1:$he_spr_psr_enabled \
308 he_twt_required:${he_mac_cap:0:2}:0x6:$he_twt_required
309
310+ if [ -n "$he_twt_responder" ]; then
311+ append base_cfg "he_twt_responder=$he_twt_responder" "$N"
312+ fi
313 if [ "$he_bss_color_enabled" -gt 0 ]; then
developer830efa72023-05-18 19:32:48 +0800314+ if !([ "$he_bss_color" -gt 0 ] && [ "$he_bss_color" -le 64 ]); then
developer785b6502023-04-19 18:31:11 +0800315+ rand=$(head -n 1 /dev/urandom | tr -dc 0-9 | head -c 2)
316+ he_bss_color=$((rand % 63 + 1))
317+ fi
318 append base_cfg "he_bss_color=$he_bss_color" "$N"
319 [ "$he_spr_non_srg_obss_pd_max_offset" -gt 0 ] && { \
320 append base_cfg "he_spr_non_srg_obss_pd_max_offset=$he_spr_non_srg_obss_pd_max_offset" "$N"
developer3df069f2024-01-15 09:40:28 +0800321@@ -469,26 +556,58 @@ mac80211_hostapd_setup_base() {
developer619eaa32023-08-29 13:33:51 +0800322 append base_cfg "he_mu_edca_qos_info_q_ack=0" "$N"
323 append base_cfg "he_mu_edca_qos_info_queue_request=0" "$N"
324 append base_cfg "he_mu_edca_qos_info_txop_request=0" "$N"
325- append base_cfg "he_mu_edca_ac_be_aifsn=8" "$N"
326+ append base_cfg "he_mu_edca_ac_be_aifsn=0" "$N"
327 append base_cfg "he_mu_edca_ac_be_aci=0" "$N"
328 append base_cfg "he_mu_edca_ac_be_ecwmin=9" "$N"
329 append base_cfg "he_mu_edca_ac_be_ecwmax=10" "$N"
developer7eeea332023-11-24 19:39:56 +0800330- append base_cfg "he_mu_edca_ac_be_timer=255" "$N"
developer619eaa32023-08-29 13:33:51 +0800331- append base_cfg "he_mu_edca_ac_bk_aifsn=15" "$N"
developer7eeea332023-11-24 19:39:56 +0800332+ append base_cfg "he_mu_edca_ac_be_timer=3" "$N"
developer619eaa32023-08-29 13:33:51 +0800333+ append base_cfg "he_mu_edca_ac_bk_aifsn=0" "$N"
334 append base_cfg "he_mu_edca_ac_bk_aci=1" "$N"
335 append base_cfg "he_mu_edca_ac_bk_ecwmin=9" "$N"
336 append base_cfg "he_mu_edca_ac_bk_ecwmax=10" "$N"
developer7eeea332023-11-24 19:39:56 +0800337- append base_cfg "he_mu_edca_ac_bk_timer=255" "$N"
338+ append base_cfg "he_mu_edca_ac_bk_timer=3" "$N"
developer619eaa32023-08-29 13:33:51 +0800339 append base_cfg "he_mu_edca_ac_vi_ecwmin=5" "$N"
340 append base_cfg "he_mu_edca_ac_vi_ecwmax=7" "$N"
341- append base_cfg "he_mu_edca_ac_vi_aifsn=5" "$N"
342+ append base_cfg "he_mu_edca_ac_vi_aifsn=0" "$N"
343 append base_cfg "he_mu_edca_ac_vi_aci=2" "$N"
developer7eeea332023-11-24 19:39:56 +0800344- append base_cfg "he_mu_edca_ac_vi_timer=255" "$N"
developer619eaa32023-08-29 13:33:51 +0800345- append base_cfg "he_mu_edca_ac_vo_aifsn=5" "$N"
developer7eeea332023-11-24 19:39:56 +0800346+ append base_cfg "he_mu_edca_ac_vi_timer=3" "$N"
developer619eaa32023-08-29 13:33:51 +0800347+ append base_cfg "he_mu_edca_ac_vo_aifsn=0" "$N"
348 append base_cfg "he_mu_edca_ac_vo_aci=3" "$N"
349 append base_cfg "he_mu_edca_ac_vo_ecwmin=5" "$N"
350 append base_cfg "he_mu_edca_ac_vo_ecwmax=7" "$N"
developer7eeea332023-11-24 19:39:56 +0800351- append base_cfg "he_mu_edca_ac_vo_timer=255" "$N"
352+ append base_cfg "he_mu_edca_ac_vo_timer=3" "$N"
353+ fi
354+
developer18015ad2023-07-13 13:18:19 +0800355+ set_default tx_burst 2
developer8b04dfd2022-12-07 16:29:19 +0800356+
developer785b6502023-04-19 18:31:11 +0800357+ # 802.11be
358+ enable_be=0
359+ case "$htmode" in
360+ EHT*) enable_be=1 ;;
361+ esac
362+
363+ if [ "$enable_be" != "0" ]; then
364+ append base_cfg "ieee80211be=1" "$N"
365+ if [ "$etxbfen" -eq 0 ]; then
366+ append base_cfg "eht_su_beamformee=1" "$N"
367+ else
368+ append base_cfg "eht_su_beamformer=1" "$N"
369+ append base_cfg "eht_su_beamformee=1" "$N"
370+ append base_cfg "eht_mu_beamformer=1" "$N"
371+ fi
372+ [ "$hwmode" = "a" ] && {
373+ case $htmode in
374+ EHT320*)
375+ append base_cfg "eht_oper_chwidth=$eht_oper_chwidth" "$N"
376+ append base_cfg "eht_oper_centr_freq_seg0_idx=$eht_oper_centr_freq_seg0_idx" "$N"
developer39a1e782023-10-27 17:44:18 +0800377+ append base_cfg "eht_bw320_offset=$eht_bw320_offset" "$N"
developer785b6502023-04-19 18:31:11 +0800378+ ;;
379+ *)
380+ append base_cfg "eht_oper_chwidth=$vht_oper_chwidth" "$N"
381+ append base_cfg "eht_oper_centr_freq_seg0_idx=$vht_center_seg0" "$N"
382+ ;;
383+ esac
384+ }
developer7eeea332023-11-24 19:39:56 +0800385 fi
386
developer8b04dfd2022-12-07 16:29:19 +0800387 hostapd_prepare_device_config "$hostapd_conf_file" nl80211
developer3df069f2024-01-15 09:40:28 +0800388@@ -497,6 +616,10 @@ ${channel:+channel=$channel}
developer0ba09b62023-03-10 18:43:49 +0800389 ${channel_list:+chanlist=$channel_list}
390 ${hostapd_noscan:+noscan=1}
391 ${tx_burst:+tx_queue_data2_burst=$tx_burst}
392+${mbssid:+mbssid=$mbssid}
developer785b6502023-04-19 18:31:11 +0800393+${mu_onoff:+mu_onoff=$mu_onoff}
394+${itxbfen:+ibf_enable=$itxbfen}
developer2c6592a2023-07-21 11:20:56 +0800395+${rnr:+rnr=$rnr}
developer37215362023-09-15 14:16:34 +0800396 ${multiple_bssid:+mbssid=$multiple_bssid}
397 #num_global_macaddr=$num_global_macaddr
developer0ba09b62023-03-10 18:43:49 +0800398 $base_cfg
developer3df069f2024-01-15 09:40:28 +0800399@@ -524,7 +647,7 @@ mac80211_hostapd_setup_bss() {
developer093e1a32023-02-24 16:10:53 +0800400 append hostapd_cfg "wds_sta=1" "$N"
401 [ -n "$wds_bridge" ] && append hostapd_cfg "wds_bridge=$wds_bridge" "$N"
402 }
403- [ "$staidx" -gt 0 -o "$start_disabled" -eq 1 ] && append hostapd_cfg "start_disabled=1" "$N"
404+ [ "$start_disabled" -eq 1 ] && append hostapd_cfg "start_disabled=1" "$N"
405
406 cat >> /var/run/hostapd-$phy.conf <<EOF
407 $hostapd_cfg
developer3df069f2024-01-15 09:40:28 +0800408@@ -535,6 +658,31 @@ ${max_listen_int:+max_listen_interval=$max_listen_int}
developer0ba09b62023-03-10 18:43:49 +0800409 EOF
410 }
411
412+mac80211_generate_mbssid_mac() {
413+ local phy="$1"
414+ local transmitted_bssid="$2"
developer1952bcd2023-06-20 20:14:37 +0800415+ local id="${mbssidx:-0}"
developer0ba09b62023-03-10 18:43:49 +0800416+
417+ local ref="$(cat /sys/class/ieee80211/${phy}/macaddress)"
developer0ba09b62023-03-10 18:43:49 +0800418+
419+ if [ -z "$transmitted_bssid" ]; then
420+ transmitted_bssid=$ref
421+ fi
422+
423+ if [ $id -eq 0 ]; then
424+ echo "$transmitted_bssid"
425+ return
426+ fi
427+
428+ local oIFS="$IFS"; IFS=":"; set -- $transmitted_bssid; IFS="$oIFS"
429+
430+ # Calculate nontransmitted bssid
developer0ba09b62023-03-10 18:43:49 +0800431+ b6="0x$6"
432+ ref_b6=$(($b6 % $max_mbssid))
developer1952bcd2023-06-20 20:14:37 +0800433+ b6=$(($b6 - $ref_b6 + ($ref_b6 + $id) % $max_mbssid))
developer0ba09b62023-03-10 18:43:49 +0800434+ printf "%s:%s:%s:%s:%s:%02x" $1 $2 $3 $4 $5 $b6
435+}
436+
437 mac80211_get_addr() {
438 local phy="$1"
439 local idx="$(($2 + 1))"
developer3df069f2024-01-15 09:40:28 +0800440@@ -658,7 +806,19 @@ mac80211_prepare_vif() {
developer24684862023-08-02 08:10:38 +0800441 json_add_string _ifname "$ifname"
developer0ba09b62023-03-10 18:43:49 +0800442
developer37215362023-09-15 14:16:34 +0800443 default_macaddr=
developer0ba09b62023-03-10 18:43:49 +0800444- if [ -z "$macaddr" ]; then
developerd2fbd572023-06-19 19:48:25 +0800445+ if [ "$mbssid" -gt 0 ] && [ "$mode" == "ap" ]; then
developer1952bcd2023-06-20 20:14:37 +0800446+ [ "$mbssidx" -eq 0 ] && {
447+ if [ -z $macaddr ]; then
448+ transmitted_bssid="$(mac80211_generate_mac $phy)"
449+ else
450+ # uci set mac address
451+ transmitted_bssid=$macaddr
452+ fi
453+ macidx="$(($macidx + 1))"
developer0ba09b62023-03-10 18:43:49 +0800454+ }
455+ macaddr="$(mac80211_generate_mbssid_mac $phy $transmitted_bssid)"
developer1952bcd2023-06-20 20:14:37 +0800456+ mbssidx="$(($mbssidx + 1))"
developer0ba09b62023-03-10 18:43:49 +0800457+ elif [ -z "$macaddr" ]; then
458 macaddr="$(mac80211_generate_mac $phy)"
459 macidx="$(($macidx + 1))"
developer37215362023-09-15 14:16:34 +0800460 default_macaddr=1
developer3df069f2024-01-15 09:40:28 +0800461@@ -916,12 +1076,28 @@ wpa_supplicant_set_config() {
developer6cfee682023-11-27 19:34:42 +0800462 }
463
464 hostapd_set_config() {
465+
466+ if [ "$inconsistent_country" -eq 1 ]; then
467+ echo "ERROR: Please use the same country for all the radios."
468+ wireless_setup_failed HOSTAPD_START_FAILED
469+ drv_mac80211_teardown
470+ return
471+ fi
472+
473 [ -n "$hostapd_ctrl" ] || {
developer3df069f2024-01-15 09:40:28 +0800474 ubus_call hostapd config_set '{ "phy": "'"$phy"'", "config": "", "prev_config": "'"${hostapd_conf_file}.prev"'" }' > /dev/null
developer6cfee682023-11-27 19:34:42 +0800475 return 0;
developer24684862023-08-02 08:10:38 +0800476 }
477
478 ubus wait_for hostapd
479+
480+ # each phy sleeps different times to prevent for ubus race condition.
481+ if [ "$phy" = "phy1" ]; then
developer8169b4f2023-10-12 09:34:58 +0800482+ sleep 3;
developer24684862023-08-02 08:10:38 +0800483+ elif [ "$phy" = "phy2" ]; then
developer8169b4f2023-10-12 09:34:58 +0800484+ sleep 6;
developer24684862023-08-02 08:10:38 +0800485+ fi
486+
developer3df069f2024-01-15 09:40:28 +0800487 local hostapd_res="$(ubus_call hostapd config_set "{ \"phy\": \"$phy\", \"config\":\"${hostapd_conf_file}\", \"prev_config\": \"${hostapd_conf_file}.prev\"}")"
developer24684862023-08-02 08:10:38 +0800488 ret="$?"
489 [ "$ret" != 0 -o -z "$hostapd_res" ] && {
developer3df069f2024-01-15 09:40:28 +0800490@@ -999,6 +1175,9 @@ mac80211_setup_vif() {
developerf0de14b2022-12-14 23:07:34 +0800491
492 json_select ..
493 [ -n "$failed" ] || wireless_add_vif "$name" "$ifname"
494+
495+ echo "Setup SMP Affinity"
496+ /sbin/smp-mt76.sh
497 }
498
499 get_freq() {
developer3df069f2024-01-15 09:40:28 +0800500@@ -1050,6 +1229,25 @@ mac80211_reset_config() {
developer37215362023-09-15 14:16:34 +0800501 wdev_tool "$phy" set_config '{}'
developer0ba09b62023-03-10 18:43:49 +0800502 }
503
504+mac80211_count_ap() {
505+ total_num_ap=$(($total_num_ap + 1))
506+}
507+
developer6cfee682023-11-27 19:34:42 +0800508+country_consistent_check() {
509+ local i
510+ inconsistent_country=0
511+ country_list="$(cat /etc/config/wireless | grep country | cut -d ' ' -f3 | tr -s "'\n" ' ')"
512+ for i in $country_list
513+ do
514+ ret="$(echo $country_list | awk '{print ($2 == "" || $1 == $2)}')"
515+ [ $ret = '0' ] && {
516+ inconsistent_country=1
517+ return
518+ }
519+ country_list="$(echo $country_list | sed -r 's/[A-Z]{2}( )*//')"
520+ done
521+}
522+
developer0ba09b62023-03-10 18:43:49 +0800523 drv_mac80211_setup() {
524 json_select config
525 json_get_vars \
developer3df069f2024-01-15 09:40:28 +0800526@@ -1058,7 +1256,8 @@ drv_mac80211_setup() {
developer93607dd2023-08-30 04:53:00 +0800527 txpower \
developer74503112023-06-29 17:34:49 +0800528 rxantenna txantenna \
developer37215362023-09-15 14:16:34 +0800529 frag rts beacon_int:100 htmode \
530- num_global_macaddr:1 multiple_bssid
531+ num_global_macaddr:1 multiple_bssid \
developer74503112023-06-29 17:34:49 +0800532+ sr_enable sr_enhanced
533 json_get_values basic_rate_list basic_rate
534 json_get_values scan_list scan_list
535 json_select ..
developer3df069f2024-01-15 09:40:28 +0800536@@ -1093,6 +1292,7 @@ drv_mac80211_setup() {
developer24684862023-08-02 08:10:38 +0800537
developer1952bcd2023-06-20 20:14:37 +0800538 macidx=0
539 staidx=0
540+ mbssidx=0
541
542 [ -n "$chanbw" ] && {
543 for file in /sys/kernel/debug/ieee80211/$phy/ath9k*/chanbw /sys/kernel/debug/ieee80211/$phy/ath5k/bwmode; do
developer3df069f2024-01-15 09:40:28 +0800544@@ -1141,14 +1341,29 @@ drv_mac80211_setup() {
developer24684862023-08-02 08:10:38 +0800545
546 wpa_supplicant_init_config
developer0ba09b62023-03-10 18:43:49 +0800547
548+ total_num_ap=0
549+ max_mbssid=1
550+ for_each_interface "ap" mac80211_count_ap
551+ total_num_ap=$(($total_num_ap - 1))
552+ while [ $total_num_ap -gt 0 ]
553+ do
554+ total_num_ap=$(($total_num_ap >> 1))
555+ max_mbssid=$(($max_mbssid << 1))
556+ done
557+
558 mac80211_prepare_iw_htmode
developer24684862023-08-02 08:10:38 +0800559 active_ifnames=
560 for_each_interface "ap sta adhoc mesh monitor" mac80211_prepare_vif
developer6cfee682023-11-27 19:34:42 +0800561 for_each_interface "ap sta adhoc mesh monitor" mac80211_setup_vif
562
563+ country_consistent_check
564+
developer24684862023-08-02 08:10:38 +0800565 [ -x /usr/sbin/wpa_supplicant ] && wpa_supplicant_set_config "$phy"
566 [ -x /usr/sbin/hostapd ] && hostapd_set_config "$phy"
developer74503112023-06-29 17:34:49 +0800567
568+ [ -n "$sr_enable" ] && echo "$sr_enable" > /sys/kernel/debug/ieee80211/$phy/mt76/sr_enable
569+ [ -n "$sr_enhanced" ] && echo "$sr_enhanced" > /sys/kernel/debug/ieee80211/$phy/mt76/sr_enhanced_enable
570+
developer24684862023-08-02 08:10:38 +0800571 [ -x /usr/sbin/wpa_supplicant ] && wpa_supplicant_start "$phy"
developer74503112023-06-29 17:34:49 +0800572
developer24684862023-08-02 08:10:38 +0800573 json_set_namespace wdev_uc prev
developer67bb1212024-02-04 16:58:38 +0800574diff --git a/package/network/config/wifi-scripts/files/lib/wifi/mac80211.sh b/package/network/config/wifi-scripts/files/lib/wifi/mac80211.sh
developera3facda2024-01-11 18:19:27 +0800575index e24a2a63..58a0c9ff 100644
developer67bb1212024-02-04 16:58:38 +0800576--- a/package/network/config/wifi-scripts/files/lib/wifi/mac80211.sh
577+++ b/package/network/config/wifi-scripts/files/lib/wifi/mac80211.sh
developer20ce7bd2023-05-20 13:25:14 +0800578@@ -60,6 +60,9 @@ BEGIN {
developer785b6502023-04-19 18:31:11 +0800579 if (vht && band != "1:") mode="VHT80"
580 if (he) mode="HE80"
581 if (he && band == "1:") mode="HE20"
developer20ce7bd2023-05-20 13:25:14 +0800582+ if (eht && band == "2:") mode="EHT160"
583+ if (eht && band == "4:") mode="EHT320"
developer785b6502023-04-19 18:31:11 +0800584+ if (eht && band == "1:") mode="EHT20"
585 sub("\\[", "", channel)
586 sub("\\]", "", channel)
587 bands = bands band channel ":" mode " "
developer20ce7bd2023-05-20 13:25:14 +0800588@@ -73,6 +76,7 @@ $1 == "Band" {
developer785b6502023-04-19 18:31:11 +0800589 vht = ""
590 ht = ""
591 he = ""
592+ eht = ""
593 }
594
595 $0 ~ "Capabilities:" {
developer20ce7bd2023-05-20 13:25:14 +0800596@@ -87,6 +91,18 @@ $0 ~ "HE Iftypes" {
developer785b6502023-04-19 18:31:11 +0800597 he=1
598 }
599
600+$0 ~ "EHT Iftypes" {
601+ eht=1
602+}
603+
developer20ce7bd2023-05-20 13:25:14 +0800604+$0 ~ / *HE MAC Capabilities \(0x000000000000\)/ {
605+ he=0
606+}
607+
608+$0 ~ / *EHT MAC Capabilities \(0x0000\)/ {
609+ eht=0
610+}
611+
developer785b6502023-04-19 18:31:11 +0800612 $1 == "*" && $3 == "MHz" && $0 !~ /disabled/ && band && !channel {
613 channel = $4
614 }
developerf7aff422023-11-14 11:11:34 +0800615@@ -120,6 +136,26 @@ get_band_defaults() {
developere2597ba2022-06-24 13:09:16 +0800616 mode_band="$band"
617 channel="$chan"
618 htmode="$mode"
619+ if [ "$band" = "6g" ]
620+ then
621+ encryption=sae
622+ key=12345678
developer20ce7bd2023-05-20 13:25:14 +0800623+ sae_pwe=2
624+ ieee80211w=2
developeradbb45b2023-06-09 14:43:01 +0800625+ channel=37
626+ mbssid=1
developerf7aff422023-11-14 11:11:34 +0800627+ mbo=1
developer75c99f42023-09-04 11:28:21 +0800628+ elif [ "$band" = "5g" ]
629+ then
630+ noscan=1
631+ encryption=none
632+ rnr=1
633+ background_radar=1
developere2597ba2022-06-24 13:09:16 +0800634+ else
developer659b07e2023-05-25 12:34:13 +0800635+ noscan=1
developere2597ba2022-06-24 13:09:16 +0800636+ encryption=none
developer2c6592a2023-07-21 11:20:56 +0800637+ rnr=1
developere2597ba2022-06-24 13:09:16 +0800638+ fi
639 done
640 }
641
developerf7aff422023-11-14 11:11:34 +0800642@@ -153,6 +189,10 @@ detect_mac80211() {
developer785b6502023-04-19 18:31:11 +0800643
644 json_load_file /etc/board.json
645
646+ # generate random bytes for macaddr
647+ rand=$(hexdump -C /dev/urandom | head -n 1 &)
648+ killall hexdump
649+
650 for _dev in /sys/class/ieee80211/*; do
651 [ -e "$_dev" ] || continue
652
developerf7aff422023-11-14 11:11:34 +0800653@@ -162,6 +202,14 @@ detect_mac80211() {
developere2597ba2022-06-24 13:09:16 +0800654 channel=""
655 htmode=""
656 ht_capab=""
657+ encryption=""
developer659b07e2023-05-25 12:34:13 +0800658+ noscan=""
developere2597ba2022-06-24 13:09:16 +0800659+ key=""
developer09257932023-05-09 13:41:30 +0800660+ sae_pwe=""
developer20ce7bd2023-05-20 13:25:14 +0800661+ ieee80211w=""
developeradbb45b2023-06-09 14:43:01 +0800662+ mbssid=""
developer2c6592a2023-07-21 11:20:56 +0800663+ rnr=""
developer75c99f42023-09-04 11:28:21 +0800664+ background_radar=""
developere2597ba2022-06-24 13:09:16 +0800665
666 get_band_defaults "$dev"
667
developered11bba2023-12-12 18:03:26 +0800668@@ -196,6 +244,19 @@ detect_mac80211() {
developer785b6502023-04-19 18:31:11 +0800669 ;;
670 esac
671
developer212c0d82023-07-13 19:41:47 +0800672+ macaddr=""
developer1325ba72023-06-26 13:43:31 +0800673+ if (dmesg | grep -q "eeprom load fail"); then
developer1952bcd2023-06-20 20:14:37 +0800674+ for i in $(seq 2 3); do
675+ macaddr=${macaddr}:$(echo $rand | cut -d ' ' -f $i)
676+ done
677+ macaddr="00:0$(($devidx - 1)):55:66${macaddr}"
developer1952bcd2023-06-20 20:14:37 +0800678+ fi
developer785b6502023-04-19 18:31:11 +0800679+
developered11bba2023-12-12 18:03:26 +0800680+ tx_burst=""
681+ if (lspci | grep -q "7992"); then
682+ tx_burst=0.0
683+ fi
684+
developer785b6502023-04-19 18:31:11 +0800685 uci -q batch <<-EOF
686 set wireless.${name}=wifi-device
687 set wireless.${name}.type=mac80211
developered11bba2023-12-12 18:03:26 +0800688@@ -203,15 +264,49 @@ detect_mac80211() {
developer09257932023-05-09 13:41:30 +0800689 set wireless.${name}.channel=${channel}
690 set wireless.${name}.band=${mode_band}
691 set wireless.${name}.htmode=$htmode
692- set wireless.${name}.disabled=1
developer20ce7bd2023-05-20 13:25:14 +0800693+ set wireless.${name}.country='US'
developer659b07e2023-05-25 12:34:13 +0800694+ set wireless.${name}.noscan=${noscan}
developer09257932023-05-09 13:41:30 +0800695+ set wireless.${name}.disabled=0
developeradbb45b2023-06-09 14:43:01 +0800696+EOF
697+ [ -n "$mbssid" ] && {
698+ uci -q set wireless.${name}.mbssid=${mbssid}
699+ }
developer2c6592a2023-07-21 11:20:56 +0800700+ [ -n "$rnr" ] && {
701+ uci -q set wireless.${name}.rnr=${rnr}
702+ }
developer75c99f42023-09-04 11:28:21 +0800703+ [ -n "$background_radar" ] && {
704+ uci -q set wireless.${name}.background_radar=${background_radar}
705+ }
developered11bba2023-12-12 18:03:26 +0800706+ [ -n "$tx_burst" ] && {
707+ uci -q set wireless.${name}.tx_burst=${tx_burst}
708+ }
developer09257932023-05-09 13:41:30 +0800709
developeradbb45b2023-06-09 14:43:01 +0800710+ uci -q batch <<-EOF
developer09257932023-05-09 13:41:30 +0800711 set wireless.default_${name}=wifi-iface
712 set wireless.default_${name}.device=${name}
developer8d77be32022-10-20 15:08:25 +0800713 set wireless.default_${name}.network=lan
714 set wireless.default_${name}.mode=ap
developer09257932023-05-09 13:41:30 +0800715- set wireless.default_${name}.ssid=OpenWrt
developer8d77be32022-10-20 15:08:25 +0800716- set wireless.default_${name}.encryption=none
developer09257932023-05-09 13:41:30 +0800717+ set wireless.default_${name}.ssid=OpenWrt-${mode_band}
developer8d77be32022-10-20 15:08:25 +0800718+ set wireless.default_${name}.encryption=${encryption}
developere2597ba2022-06-24 13:09:16 +0800719 EOF
developer212c0d82023-07-13 19:41:47 +0800720+
721+ # calibrated board will use eeprom macaddress, not ramdom address
722+ [ -n "$macaddr" ] && {
723+ uci -q set wireless.default_${name}.macaddr=${macaddr}
724+ }
725+
developere2597ba2022-06-24 13:09:16 +0800726+ [ -n "$key" ] && {
developer8d77be32022-10-20 15:08:25 +0800727+ uci -q set wireless.default_${name}.key=${key}
developere2597ba2022-06-24 13:09:16 +0800728+ }
developer09257932023-05-09 13:41:30 +0800729+ [ -n "$sae_pwe" ] && {
730+ uci -q set wireless.default_${name}.sae_pwe=${sae_pwe}
731+ }
developer20ce7bd2023-05-20 13:25:14 +0800732+ [ -n "$ieee80211w" ] && {
733+ uci -q set wireless.default_${name}.ieee80211w=${ieee80211w}
734+ }
developerf7aff422023-11-14 11:11:34 +0800735+ [ -n "$mbo" ] && {
736+ uci -q set wireless.default_${name}.mbo=${mbo}
737+ }
developere2597ba2022-06-24 13:09:16 +0800738 uci -q commit wireless
developer8d77be32022-10-20 15:08:25 +0800739 done
740 }
developer67bb1212024-02-04 16:58:38 +0800741diff --git a/package/network/config/wifi-scripts/files/lib/netifd/hostapd.sh b/package/network/config/wifi-scripts/files/lib/netifd/hostapd.sh
developera3facda2024-01-11 18:19:27 +0800742index 271c1f7b..80b95116 100644
developer67bb1212024-02-04 16:58:38 +0800743--- a/package/network/config/wifi-scripts/files/lib/netifd/hostapd.sh
744+++ b/package/network/config/wifi-scripts/files/lib/netifd/hostapd.sh
developer74503112023-06-29 17:34:49 +0800745@@ -60,7 +60,14 @@ hostapd_append_wpa_key_mgmt() {
developer93607dd2023-08-30 04:53:00 +0800746 append wpa_key_mgmt "WPA-EAP-SHA256"
developer74503112023-06-29 17:34:49 +0800747 ;;
748 sae)
749- append wpa_key_mgmt "SAE"
750+ case "$encryption" in
751+ *sae-ext*)
752+ append wpa_key_mgmt "SAE-EXT-KEY"
753+ ;;
754+ *)
755+ append wpa_key_mgmt "SAE"
756+ ;;
757+ esac
758 [ "${ieee80211r:-0}" -gt 0 ] && append wpa_key_mgmt "FT-SAE"
759 ;;
760 psk-sae)
developer93607dd2023-08-30 04:53:00 +0800761@@ -119,6 +126,7 @@ hostapd_common_add_device_config() {
developer74503112023-06-29 17:34:49 +0800762 config_add_int rts_threshold
763 config_add_int rssi_reject_assoc_rssi
764 config_add_int rssi_ignore_probe_request
765+ config_add_int rssi_reject_assoc_timeout
766 config_add_int maxassoc
767
768 config_add_string acs_chan_bias
developer93607dd2023-08-30 04:53:00 +0800769@@ -231,8 +239,10 @@ hostapd_prepare_device_config() {
developer74503112023-06-29 17:34:49 +0800770 hostapd_add_rate brlist "$br"
771 done
772
773+ json_get_vars rssi_reject_assoc_timeout
774 [ -n "$rssi_reject_assoc_rssi" ] && append base_cfg "rssi_reject_assoc_rssi=$rssi_reject_assoc_rssi" "$N"
775 [ -n "$rssi_ignore_probe_request" ] && append base_cfg "rssi_ignore_probe_request=$rssi_ignore_probe_request" "$N"
776+ [ -n "$rssi_reject_assoc_timeout" ] && append base_cfg "rssi_reject_assoc_timeout=$rssi_reject_assoc_timeout" "$N"
777 [ -n "$beacon_rate" ] && append base_cfg "beacon_rate=$beacon_rate" "$N"
778 [ -n "$rlist" ] && append base_cfg "supported_rates=$rlist" "$N"
779 [ -n "$brlist" ] && append base_cfg "basic_rates=$brlist" "$N"
developera3facda2024-01-11 18:19:27 +0800780@@ -383,6 +393,25 @@ hostapd_common_add_bss_config() {
developer82408892023-03-27 15:09:00 +0800781 config_add_string fils_dhcp
782
783 config_add_int ocv
784+
785+ config_add_int disable_eht
786+ config_add_int disable_he
787+ config_add_int disable_vht
788+ config_add_int disable_ht
developer813f5d72023-03-28 17:44:38 +0800789+
developerf166f542023-05-25 14:40:30 +0800790+ config_add_boolean beacon_prot interworking
developer74503112023-06-29 17:34:49 +0800791+
792+ config_add_int unsol_bcast_probe_resp_interval
793+ config_add_int fils_discovery_min_interval
794+ config_add_int fils_discovery_max_interval
795+ config_add_boolean rnr
796+
797+ config_add_array sae_groups
798+ config_add_array owe_groups
799+ config_add_array pairwise
800+ config_add_string group_cipher
developer875fbb72023-12-13 15:49:01 +0800801+ config_add_string group_mgmt_cipher
developer74503112023-06-29 17:34:49 +0800802+
developer82408892023-03-27 15:09:00 +0800803 }
804
805 hostapd_set_vlan_file() {
developera3facda2024-01-11 18:19:27 +0800806@@ -447,11 +476,11 @@ append_iw_nai_realm() {
developerf166f542023-05-25 14:40:30 +0800807 }
808
809 append_iw_venue_name() {
810- append bss_conf "venue_name=$1" "$N"
811+ [ -n "$1" ] && append bss_conf "venue_name=$1" "$N"
812 }
813
814 append_iw_venue_url() {
815- append bss_conf "venue_url=$1" "$N"
816+ [ -n "$1" ] && append bss_conf "venue_url=$1" "$N"
817 }
818
819 append_hs20_oper_friendly_name() {
developera3facda2024-01-11 18:19:27 +0800820@@ -569,7 +598,8 @@ hostapd_set_bss_options() {
developer74503112023-06-29 17:34:49 +0800821 ppsk airtime_bss_weight airtime_bss_limit airtime_sta_weight \
822 multicast_to_unicast_all proxy_arp per_sta_vif \
823 eap_server eap_user_file ca_cert server_cert private_key private_key_passwd server_id \
824- vendor_elements fils ocv
825+ vendor_elements fils ocv unsol_bcast_probe_resp_interval fils_discovery_min_interval \
developera3facda2024-01-11 18:19:27 +0800826+ fils_discovery_max_interval rnr group_cipher group_mgmt_cipher
developer74503112023-06-29 17:34:49 +0800827
828 set_default fils 0
829 set_default isolate 0
developera3facda2024-01-11 18:19:27 +0800830@@ -796,6 +826,36 @@ hostapd_set_bss_options() {
developer74503112023-06-29 17:34:49 +0800831 local auth_algs="$((($auth_mode_shared << 1) | $auth_mode_open))"
832 append bss_conf "auth_algs=${auth_algs:-1}" "$N"
833 append bss_conf "wpa=$wpa" "$N"
834+
835+ json_get_values pairwise pairwise
developer945ed992023-10-25 15:01:32 +0800836+ json_get_vars group_cipher
developer9097e5e2023-07-19 10:22:24 +0800837+ if [ -n "$pairwise" ]; then
838+ case "$pairwise" in
839+ *tkip+aes|*tkip+ccmp|*aes+tkip|*ccmp+tkip)
840+ wpa_cipher="CCMP TKIP"
841+ ;;
842+ *ccmp256)
843+ wpa_cipher="CCMP-256"
844+ ;;
845+ *aes|*ccmp)
846+ wpa_cipher="CCMP"
847+ ;;
848+ *tkip)
849+ wpa_cipher="TKIP"
850+ ;;
851+ *gcmp256)
852+ wpa_cipher="GCMP-256"
853+ ;;
854+ *gcmp)
855+ wpa_cipher="GCMP"
856+ ;;
857+ *)
858+ wpa_cipher=""
859+ ;;
860+ esac
861+ fi
developer74503112023-06-29 17:34:49 +0800862+ [ -n "$wpa_cipher" ] && wpa_pairwise="$wpa_cipher"
863+
864 [ -n "$wpa_pairwise" ] && append bss_conf "wpa_pairwise=$wpa_pairwise" "$N"
865
866 set_default wps_pushbutton 0
developera3facda2024-01-11 18:19:27 +0800867@@ -847,7 +907,7 @@ hostapd_set_bss_options() {
developerda723192023-05-22 19:46:10 +0800868 }
869
870 append bss_conf "ssid=$ssid" "$N"
871- [ -n "$network_bridge" ] && append bss_conf "bridge=$network_bridge${N}wds_bridge=" "$N"
872+ [ -n "$network_bridge" ] && append bss_conf "bridge=$network_bridge${N}wds_bridge=$network_bridge" "$N"
873 [ -n "$network_ifname" ] && append bss_conf "snoop_iface=$network_ifname" "$N"
874 [ -n "$iapp_interface" ] && {
875 local ifname
developer03fcbcb2024-01-26 14:26:38 +0800876@@ -912,6 +972,8 @@ hostapd_set_bss_options() {
developer74503112023-06-29 17:34:49 +0800877 fi
878
879 if [ "$wpa" -ge "2" ]; then
880+ json_get_values sae_groups sae_groups
881+ json_get_values owe_groups owe_groups
developer03fcbcb2024-01-26 14:26:38 +0800882 if [ "$ieee80211r" -gt "0" ]; then
883 json_get_vars mobility_domain ft_psk_generate_local ft_over_ds reassociation_deadline
884
885@@ -984,17 +1046,52 @@ hostapd_set_bss_options() {
developer74503112023-06-29 17:34:49 +0800886 append bss_conf "okc=$auth_cache" "$N"
887 [ "$auth_cache" = 0 -a "$fils" = 0 ] && append bss_conf "disable_pmksa_caching=1" "$N"
888
889+ [ -z "$group_cipher" ] && group_cipher="$wpa_cipher"
890+
891+ if [ -n "$sae_groups" -o -n "$owe_groups" ]; then
892+ case "$auth_type" in
893+ sae*)
894+ append bss_conf "sae_groups=$sae_groups" "$N"
895+ append bss_conf "group_cipher=$group_cipher" "$N"
896+ ;;
897+ owe)
898+ append bss_conf "owe_groups=$owe_groups" "$N"
899+ append bss_conf "group_cipher=$group_cipher" "$N"
900+ ;;
901+ esac
902+ fi
903+
developer813f5d72023-03-28 17:44:38 +0800904 # RSN -> allow management frame protection
905 case "$ieee80211w" in
906 [012])
907- json_get_vars ieee80211w_mgmt_cipher ieee80211w_max_timeout ieee80211w_retry_timeout
908+ json_get_vars ieee80211w_mgmt_cipher ieee80211w_max_timeout ieee80211w_retry_timeout beacon_prot
909 append bss_conf "ieee80211w=$ieee80211w" "$N"
910 [ "$ieee80211w" -gt "0" ] && {
developer875fbb72023-12-13 15:49:01 +0800911+ if [ -z "$group_mgmt_cipher" ]; then
912+ case "$group_cipher" in
913+ CCMP-256)
914+ ieee80211w_mgmt_cipher="BIP-CMAC-256"
915+ ;;
916+ CCMP)
917+ ieee80211w_mgmt_cipher="AES-128-CMAC"
918+ ;;
919+ GCMP-256)
920+ ieee80211w_mgmt_cipher="BIP-GMAC-256"
921+ ;;
922+ GCMP)
923+ ieee80211w_mgmt_cipher="BIP-GMAC-128"
924+ ;;
925+ esac
926+ else
927+ ieee80211w_mgmt_cipher="$group_mgmt_cipher"
928+ fi
developer813f5d72023-03-28 17:44:38 +0800929 if [ "$auth_type" = "eap192" ]; then
developer74503112023-06-29 17:34:49 +0800930 append bss_conf "group_mgmt_cipher=BIP-GMAC-256" "$N"
developer813f5d72023-03-28 17:44:38 +0800931 else
932 append bss_conf "group_mgmt_cipher=${ieee80211w_mgmt_cipher:-AES-128-CMAC}" "$N"
933 fi
934+ [ -n "$beacon_prot" ] && \
935+ append bss_conf "beacon_prot=$beacon_prot" "$N"
936 [ -n "$ieee80211w_max_timeout" ] && \
937 append bss_conf "assoc_sa_query_max_timeout=$ieee80211w_max_timeout" "$N"
938 [ -n "$ieee80211w_retry_timeout" ] && \
developer03fcbcb2024-01-26 14:26:38 +0800939@@ -1059,9 +1156,10 @@ hostapd_set_bss_options() {
developerf166f542023-05-25 14:40:30 +0800940 json_get_vars iw_roaming_consortium iw_domain_name iw_anqp_3gpp_cell_net iw_nai_realm
941 json_get_vars iw_anqp_elem iw_qos_map_set iw_ipaddr_type_availability iw_gas_address3
942 json_get_vars iw_venue_name iw_venue_url
943+ json_get_vars interworking
944
945 set_default iw_enabled 0
946- if [ "$iw_enabled" = "1" ]; then
947+ if [ "$iw_enabled" = "1" ] || [ "$interworking" = "1" ]; then
948 append bss_conf "interworking=1" "$N"
949 set_default iw_internet 1
950 set_default iw_asra 0
developer03fcbcb2024-01-26 14:26:38 +0800951@@ -1168,6 +1266,22 @@ hostapd_set_bss_options() {
developer74503112023-06-29 17:34:49 +0800952 append bss_conf "$val" "$N"
953 done
954
955+ if [ "$unsol_bcast_probe_resp_interval" -gt 0 ]; then
956+ append bss_conf "unsol_bcast_probe_resp_interval=$unsol_bcast_probe_resp_interval" "$N"
957+ fi
958+
959+ if [ -n "$fils_discovery_min_interval" ]; then
960+ append bss_conf "fils_discovery_min_interval=$fils_discovery_min_interval" "$N"
961+ fi
962+
963+ if [ -n "$fils_discovery_max_interval" ]; then
964+ append bss_conf "fils_discovery_max_interval=$fils_discovery_max_interval" "$N"
965+ fi
966+
967+ if [ -n "$rnr" ]; then
968+ append bss_conf "rnr=$rnr" "$N"
969+ fi
970+
developer5b3b7a92023-08-12 03:41:52 +0800971 append "$var" "$bss_conf" "$N"
972 return 0
973 }
developer03fcbcb2024-01-26 14:26:38 +0800974@@ -1255,6 +1369,7 @@ wpa_supplicant_prepare_interface() {
developer18015ad2023-07-13 13:18:19 +0800975 country_str="country=$country"
976 }
977
developer2cf3f4c2023-07-24 16:58:25 +0800978+ local tx_queue_data2_burst="tx_queue_data2_burst=0"
developer18015ad2023-07-13 13:18:19 +0800979 multiap_flag_file="${_config}.is_multiap"
980 if [ "$multi_ap" = "1" ]; then
981 touch "$multiap_flag_file"
developer03fcbcb2024-01-26 14:26:38 +0800982@@ -1266,6 +1381,7 @@ wpa_supplicant_prepare_interface() {
developer18015ad2023-07-13 13:18:19 +0800983 ${scan_list:+freq_list=$scan_list}
984 $ap_scan
985 $country_str
986+$tx_queue_data2_burst
987 EOF
988 return 0
989 }
developer03fcbcb2024-01-26 14:26:38 +0800990@@ -1537,12 +1653,39 @@ wpa_supplicant_add_network() {
developer74503112023-06-29 17:34:49 +0800991 ;;
992 esac
993
developerbb29b5e2023-07-25 20:41:04 +0800994- [ "$wpa_cipher" = GCMP ] && {
995- append network_data "pairwise=GCMP" "$N$T"
996- append network_data "group=GCMP" "$N$T"
997- }
developer74503112023-06-29 17:34:49 +0800998+ json_get_values pairwise pairwise
developer875fbb72023-12-13 15:49:01 +0800999+ json_get_vars group_cipher group_mgmt_cipher
developer9097e5e2023-07-19 10:22:24 +08001000+ if [ -n "$pairwise" ]; then
1001+ case "$pairwise" in
1002+ *tkip+aes|*tkip+ccmp|*aes+tkip|*ccmp+tkip)
1003+ wpa_cipher="CCMP TKIP"
1004+ ;;
1005+ *ccmp256)
1006+ wpa_cipher="CCMP-256"
1007+ ;;
1008+ *aes|*ccmp)
1009+ wpa_cipher="CCMP"
1010+ ;;
1011+ *tkip)
1012+ wpa_cipher="TKIP"
1013+ ;;
1014+ *gcmp256)
1015+ wpa_cipher="GCMP-256"
1016+ ;;
1017+ *gcmp)
1018+ wpa_cipher="GCMP"
1019+ ;;
1020+ *)
1021+ wpa_cipher=""
1022+ ;;
1023+ esac
1024+ fi
developer74503112023-06-29 17:34:49 +08001025+ [ -n "$wpa_cipher" ] && wpa_pairwise="$wpa_cipher"
developer74503112023-06-29 17:34:49 +08001026
1027 [ "$mode" = mesh ] || {
1028+ json_get_values sae_groups sae_groups
1029+ json_get_values owe_groups owe_groups
1030+
1031 case "$wpa" in
1032 1)
1033 append network_data "proto=WPA" "$N$T"
developer03fcbcb2024-01-26 14:26:38 +08001034@@ -1552,12 +1695,58 @@ wpa_supplicant_add_network() {
developer74503112023-06-29 17:34:49 +08001035 ;;
1036 esac
1037
1038+ [ -n "$wpa_pairwise" ] && append network_data "pairwise=$wpa_pairwise" "$N$T"
1039+ [ -z "$group_cipher" ] && group_cipher="$wpa_cipher"
1040+
1041+ if [ -n "$sae_groups" -o -n "$owe_groups" ]; then
1042+ case "$auth_type" in
1043+ sae*)
1044+ echo "sae_groups=$sae_groups" >> "$_config"
1045+ append network_data "group=$group_cipher" "$N$T"
1046+ ;;
1047+ owe)
1048+ append network_data "owe_group=$owe_groups" "$N$T"
1049+ append network_data "group=$group_cipher" "$N$T"
1050+ ;;
1051+ esac
1052+ fi
1053+
1054+ # RSN -> allow management frame protection
1055 case "$ieee80211w" in
1056 [012])
1057- [ "$wpa" -ge 2 ] && append network_data "ieee80211w=$ieee80211w" "$N$T"
1058+ json_get_vars ieee80211w_mgmt_cipher ieee80211w_max_timeout ieee80211w_retry_timeout beacon_prot
1059+ append network_data "ieee80211w=$ieee80211w" "$N$T"
1060+ [ "$ieee80211w" -gt "0" ] && {
developer875fbb72023-12-13 15:49:01 +08001061+ if [ -z "$group_mgmt_cipher" ]; then
1062+ case "$group_cipher" in
1063+ CCMP-256)
1064+ ieee80211w_mgmt_cipher="BIP-CMAC-256"
1065+ ;;
1066+ CCMP)
1067+ ieee80211w_mgmt_cipher="AES-128-CMAC"
1068+ ;;
1069+ GCMP-256)
1070+ ieee80211w_mgmt_cipher="BIP-GMAC-256"
1071+ ;;
1072+ GCMP)
1073+ ieee80211w_mgmt_cipher="BIP-GMAC-128"
1074+ ;;
1075+ esac
1076+ else
1077+ ieee80211w_mgmt_cipher="$group_mgmt_cipher"
1078+ fi
developer74503112023-06-29 17:34:49 +08001079+ if [ "$auth_type" = "eap192" ]; then
1080+ append network_data "group_mgmt=BIP-GMAC-256" "$N$T"
1081+ else
1082+ append network_data "group_mgmt=${ieee80211w_mgmt_cipher:-AES-128-CMAC}" "$N$T"
1083+ fi
1084+ [ -n "$beacon_prot" ] && \
1085+ append network_data "beacon_prot=$beacon_prot" "$N$T"
1086+ }
1087 ;;
1088 esac
1089 }
1090+
1091 [ -n "$bssid" ] && append network_data "bssid=$bssid" "$N$T"
1092 [ -n "$beacon_int" ] && append network_data "beacon_int=$beacon_int" "$N$T"
1093
developer03fcbcb2024-01-26 14:26:38 +08001094@@ -1568,6 +1757,20 @@ wpa_supplicant_add_network() {
developer82408892023-03-27 15:09:00 +08001095 [ -n "$bssid_blacklist" ] && append network_data "bssid_blacklist=$bssid_blacklist" "$N$T"
1096 [ -n "$bssid_whitelist" ] && append network_data "bssid_whitelist=$bssid_whitelist" "$N$T"
1097
1098+ local disable_eht
1099+ local disable_he
1100+ local disable_vht
1101+ local disable_ht
1102+ json_get_vars disable_eht
1103+ json_get_vars disable_he
1104+ json_get_vars disable_vht
1105+ json_get_vars disable_ht
1106+
1107+ [ -n "$disable_eht" ] && append network_data "disable_eht=$disable_eht" "$N$T"
1108+ [ -n "$disable_he" ] && append network_data "disable_he=$disable_he" "$N$T"
1109+ [ -n "$disable_vht" ] && append network_data "disable_vht=$disable_vht" "$N$T"
1110+ [ -n "$disable_ht" ] && append network_data "disable_ht=$disable_ht" "$N$T"
1111+
1112 [ -n "$basic_rate" ] && {
1113 local br rate_list=
1114 for br in $basic_rate; do
developer03fcbcb2024-01-26 14:26:38 +08001115@@ -1582,6 +1785,11 @@ wpa_supplicant_add_network() {
developer85839fe2023-02-23 10:32:51 +08001116 append network_data "mcast_rate=$mc_rate" "$N$T"
1117 }
1118
1119+ if [ "$auth_type" = "sae" ]; then
1120+ json_get_vars sae_pwe sae_pwe
1121+ [ -n "$sae_pwe" ] && echo "sae_pwe=$sae_pwe" >> "$_config"
1122+ fi
1123+
1124 if [ "$key_mgmt" = "WPS" ]; then
1125 echo "wps_cred_processing=1" >> "$_config"
1126 else