blob: 561a8d3282a84267c0067fff6204ef8710b4d19c [file] [log] [blame]
developerce9e5092022-11-10 22:41:59 +08001diff --git a/package/kernel/mac80211/Makefile b/package/kernel/mac80211/Makefile
developeradd54322024-04-22 18:57:56 +08002index 566cfdd7..0298600c 100644
developerce9e5092022-11-10 22:41:59 +08003--- a/package/kernel/mac80211/Makefile
4+++ b/package/kernel/mac80211/Makefile
developer404df542024-03-26 06:13:54 +08005@@ -22,6 +22,7 @@ PKG_SOURCE:=backports-$(PKG_VERSION).tar.xz
6 PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(if $(BUILD_VARIANT),$(PKG_NAME)-$(BUILD_VARIANT)/)backports-$(PKG_VERSION)
developerce9e5092022-11-10 22:41:59 +08007 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 = \
developer404df542024-03-26 06:13:54 +080013@@ -80,6 +81,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
developer404df542024-03-26 06:13:54 +080022 config-$(call config_package,cfg80211,$(ALL_VARIANTS)) += CFG80211
developer6ec8e342022-11-21 18:47:15 +080023 config-$(CONFIG_PACKAGE_CFG80211_TESTMODE) += NL80211_TESTMODE
developeradd54322024-04-22 18:57:56 +080024@@ -304,6 +309,7 @@ define Build/Prepare
25 rm -rf $(PKG_BUILD_DIR)
developer356ecec2022-11-14 10:25:04 +080026 mkdir -p $(PKG_BUILD_DIR)
27 $(PKG_UNPACK)
developerafe1b5b2023-10-19 07:11:26 +080028+ $(CP) $(SOURCE_PATH)/* $(PKG_BUILD_DIR) 2>/dev/null || :
developerb537dd92024-04-22 00:51:57 +080029 $(Build/Patch)
developer356ecec2022-11-14 10:25:04 +080030 rm -rf \
31 $(PKG_BUILD_DIR)/include/linux/ssb \
developer404df542024-03-26 06:13:54 +080032diff --git a/package/network/config/wifi-scripts/files/lib/netifd/hostapd.sh b/package/network/config/wifi-scripts/files/lib/netifd/hostapd.sh
developeradd54322024-04-22 18:57:56 +080033index 763702e7..3537e3ae 100644
developer404df542024-03-26 06:13:54 +080034--- a/package/network/config/wifi-scripts/files/lib/netifd/hostapd.sh
35+++ b/package/network/config/wifi-scripts/files/lib/netifd/hostapd.sh
36@@ -60,7 +60,14 @@ hostapd_append_wpa_key_mgmt() {
37 append wpa_key_mgmt "WPA-EAP-SHA256"
38 ;;
39 sae)
40- append wpa_key_mgmt "SAE"
41+ case "$encryption" in
42+ *sae-ext*)
43+ append wpa_key_mgmt "SAE-EXT-KEY"
44+ ;;
45+ *)
46+ append wpa_key_mgmt "SAE"
47+ ;;
48+ esac
49 [ "${ieee80211r:-0}" -gt 0 ] && append wpa_key_mgmt "FT-SAE"
50 ;;
51 psk-sae)
52@@ -119,6 +126,7 @@ hostapd_common_add_device_config() {
53 config_add_int rts_threshold
54 config_add_int rssi_reject_assoc_rssi
55 config_add_int rssi_ignore_probe_request
56+ config_add_int rssi_reject_assoc_timeout
57 config_add_int maxassoc
developer20d67712022-03-02 14:09:32 +080058
developer404df542024-03-26 06:13:54 +080059 config_add_string acs_chan_bias
60@@ -231,8 +239,10 @@ hostapd_prepare_device_config() {
61 hostapd_add_rate brlist "$br"
62 done
developer20d67712022-03-02 14:09:32 +080063
developer404df542024-03-26 06:13:54 +080064+ json_get_vars rssi_reject_assoc_timeout
65 [ -n "$rssi_reject_assoc_rssi" ] && append base_cfg "rssi_reject_assoc_rssi=$rssi_reject_assoc_rssi" "$N"
66 [ -n "$rssi_ignore_probe_request" ] && append base_cfg "rssi_ignore_probe_request=$rssi_ignore_probe_request" "$N"
67+ [ -n "$rssi_reject_assoc_timeout" ] && append base_cfg "rssi_reject_assoc_timeout=$rssi_reject_assoc_timeout" "$N"
68 [ -n "$beacon_rate" ] && append base_cfg "beacon_rate=$beacon_rate" "$N"
69 [ -n "$rlist" ] && append base_cfg "supported_rates=$rlist" "$N"
70 [ -n "$brlist" ] && append base_cfg "basic_rates=$brlist" "$N"
71@@ -383,6 +393,25 @@ hostapd_common_add_bss_config() {
72 config_add_string fils_dhcp
developer93607dd2023-08-30 04:53:00 +080073
developer404df542024-03-26 06:13:54 +080074 config_add_int ocv
developer93607dd2023-08-30 04:53:00 +080075+
developer404df542024-03-26 06:13:54 +080076+ config_add_int disable_eht
77+ config_add_int disable_he
78+ config_add_int disable_vht
79+ config_add_int disable_ht
80+
81+ config_add_boolean beacon_prot interworking
82+
83+ config_add_int unsol_bcast_probe_resp_interval
84+ config_add_int fils_discovery_min_interval
85+ config_add_int fils_discovery_max_interval
86+ config_add_boolean rnr
87+
88+ config_add_array sae_groups
89+ config_add_array owe_groups
90+ config_add_array pairwise
91+ config_add_string group_cipher
92+ config_add_string group_mgmt_cipher
93+
94 }
developer785b6502023-04-19 18:31:11 +080095
developer404df542024-03-26 06:13:54 +080096 hostapd_set_vlan_file() {
97@@ -447,11 +476,11 @@ append_iw_nai_realm() {
98 }
developer785b6502023-04-19 18:31:11 +080099
developer404df542024-03-26 06:13:54 +0800100 append_iw_venue_name() {
101- append bss_conf "venue_name=$1" "$N"
102+ [ -n "$1" ] && append bss_conf "venue_name=$1" "$N"
103 }
developer785b6502023-04-19 18:31:11 +0800104
developer404df542024-03-26 06:13:54 +0800105 append_iw_venue_url() {
106- append bss_conf "venue_url=$1" "$N"
107+ [ -n "$1" ] && append bss_conf "venue_url=$1" "$N"
108 }
109
110 append_hs20_oper_friendly_name() {
111@@ -569,7 +598,8 @@ hostapd_set_bss_options() {
112 ppsk airtime_bss_weight airtime_bss_limit airtime_sta_weight \
113 multicast_to_unicast_all proxy_arp per_sta_vif \
114 eap_server eap_user_file ca_cert server_cert private_key private_key_passwd server_id \
115- vendor_elements fils ocv
116+ vendor_elements fils ocv unsol_bcast_probe_resp_interval fils_discovery_min_interval \
117+ fils_discovery_max_interval rnr group_cipher group_mgmt_cipher
118
119 set_default fils 0
120 set_default isolate 0
121@@ -796,6 +826,36 @@ hostapd_set_bss_options() {
122 local auth_algs="$((($auth_mode_shared << 1) | $auth_mode_open))"
123 append bss_conf "auth_algs=${auth_algs:-1}" "$N"
124 append bss_conf "wpa=$wpa" "$N"
developer39a1e782023-10-27 17:44:18 +0800125+
developer404df542024-03-26 06:13:54 +0800126+ json_get_values pairwise pairwise
127+ json_get_vars group_cipher
128+ if [ -n "$pairwise" ]; then
129+ case "$pairwise" in
130+ *tkip+aes|*tkip+ccmp|*aes+tkip|*ccmp+tkip)
131+ wpa_cipher="CCMP TKIP"
132+ ;;
133+ *ccmp256)
134+ wpa_cipher="CCMP-256"
135+ ;;
136+ *aes|*ccmp)
137+ wpa_cipher="CCMP"
138+ ;;
139+ *tkip)
140+ wpa_cipher="TKIP"
141+ ;;
142+ *gcmp256)
143+ wpa_cipher="GCMP-256"
144+ ;;
145+ *gcmp)
146+ wpa_cipher="GCMP"
147+ ;;
148+ *)
149+ wpa_cipher=""
150+ ;;
151+ esac
152+ fi
153+ [ -n "$wpa_cipher" ] && wpa_pairwise="$wpa_cipher"
154+
155 [ -n "$wpa_pairwise" ] && append bss_conf "wpa_pairwise=$wpa_pairwise" "$N"
developer75c99f42023-09-04 11:28:21 +0800156
developer404df542024-03-26 06:13:54 +0800157 set_default wps_pushbutton 0
158@@ -847,7 +907,7 @@ hostapd_set_bss_options() {
developer785b6502023-04-19 18:31:11 +0800159 }
developer8b04dfd2022-12-07 16:29:19 +0800160
developer404df542024-03-26 06:13:54 +0800161 append bss_conf "ssid=$ssid" "$N"
162- [ -n "$network_bridge" ] && append bss_conf "bridge=$network_bridge${N}wds_bridge=" "$N"
163+ [ -n "$network_bridge" ] && append bss_conf "bridge=$network_bridge${N}wds_bridge=$network_bridge" "$N"
164 [ -n "$network_ifname" ] && append bss_conf "snoop_iface=$network_ifname" "$N"
165 [ -n "$iapp_interface" ] && {
166 local ifname
167@@ -912,6 +972,8 @@ hostapd_set_bss_options() {
168 fi
developer785b6502023-04-19 18:31:11 +0800169
developer404df542024-03-26 06:13:54 +0800170 if [ "$wpa" -ge "2" ]; then
171+ json_get_values sae_groups sae_groups
172+ json_get_values owe_groups owe_groups
173 if [ "$ieee80211r" -gt "0" ]; then
174 json_get_vars mobility_domain ft_psk_generate_local ft_over_ds reassociation_deadline
developer785b6502023-04-19 18:31:11 +0800175
developer404df542024-03-26 06:13:54 +0800176@@ -984,17 +1046,52 @@ hostapd_set_bss_options() {
177 append bss_conf "okc=$auth_cache" "$N"
178 [ "$auth_cache" = 0 -a "$fils" = 0 ] && append bss_conf "disable_pmksa_caching=1" "$N"
179
180+ [ -z "$group_cipher" ] && group_cipher="$wpa_cipher"
181+
182+ if [ -n "$sae_groups" -o -n "$owe_groups" ]; then
183+ case "$auth_type" in
184+ sae*)
185+ append bss_conf "sae_groups=$sae_groups" "$N"
186+ append bss_conf "group_cipher=$group_cipher" "$N"
187+ ;;
188+ owe)
189+ append bss_conf "owe_groups=$owe_groups" "$N"
190+ append bss_conf "group_cipher=$group_cipher" "$N"
191+ ;;
192+ esac
193+ fi
194+
195 # RSN -> allow management frame protection
196 case "$ieee80211w" in
197 [012])
198- json_get_vars ieee80211w_mgmt_cipher ieee80211w_max_timeout ieee80211w_retry_timeout
199+ json_get_vars ieee80211w_mgmt_cipher ieee80211w_max_timeout ieee80211w_retry_timeout beacon_prot
200 append bss_conf "ieee80211w=$ieee80211w" "$N"
201 [ "$ieee80211w" -gt "0" ] && {
202+ if [ -z "$group_mgmt_cipher" ]; then
203+ case "$group_cipher" in
204+ CCMP-256)
205+ ieee80211w_mgmt_cipher="BIP-CMAC-256"
206+ ;;
207+ CCMP)
208+ ieee80211w_mgmt_cipher="AES-128-CMAC"
209+ ;;
210+ GCMP-256)
211+ ieee80211w_mgmt_cipher="BIP-GMAC-256"
212+ ;;
213+ GCMP)
214+ ieee80211w_mgmt_cipher="BIP-GMAC-128"
215+ ;;
216+ esac
217+ else
218+ ieee80211w_mgmt_cipher="$group_mgmt_cipher"
219+ fi
220 if [ "$auth_type" = "eap192" ]; then
221 append bss_conf "group_mgmt_cipher=BIP-GMAC-256" "$N"
222 else
223 append bss_conf "group_mgmt_cipher=${ieee80211w_mgmt_cipher:-AES-128-CMAC}" "$N"
224 fi
225+ [ -n "$beacon_prot" ] && \
226+ append bss_conf "beacon_prot=$beacon_prot" "$N"
227 [ -n "$ieee80211w_max_timeout" ] && \
228 append bss_conf "assoc_sa_query_max_timeout=$ieee80211w_max_timeout" "$N"
229 [ -n "$ieee80211w_retry_timeout" ] && \
230@@ -1059,9 +1156,10 @@ hostapd_set_bss_options() {
231 json_get_vars iw_roaming_consortium iw_domain_name iw_anqp_3gpp_cell_net iw_nai_realm
232 json_get_vars iw_anqp_elem iw_qos_map_set iw_ipaddr_type_availability iw_gas_address3
233 json_get_vars iw_venue_name iw_venue_url
234+ json_get_vars interworking
developer785b6502023-04-19 18:31:11 +0800235
developer404df542024-03-26 06:13:54 +0800236 set_default iw_enabled 0
237- if [ "$iw_enabled" = "1" ]; then
238+ if [ "$iw_enabled" = "1" ] || [ "$interworking" = "1" ]; then
239 append bss_conf "interworking=1" "$N"
240 set_default iw_internet 1
241 set_default iw_asra 0
242@@ -1168,6 +1266,22 @@ hostapd_set_bss_options() {
243 append bss_conf "$val" "$N"
244 done
developer785b6502023-04-19 18:31:11 +0800245
developer404df542024-03-26 06:13:54 +0800246+ if [ "$unsol_bcast_probe_resp_interval" -gt 0 ]; then
247+ append bss_conf "unsol_bcast_probe_resp_interval=$unsol_bcast_probe_resp_interval" "$N"
248+ fi
developer785b6502023-04-19 18:31:11 +0800249+
developer404df542024-03-26 06:13:54 +0800250+ if [ -n "$fils_discovery_min_interval" ]; then
251+ append bss_conf "fils_discovery_min_interval=$fils_discovery_min_interval" "$N"
developer7eeea332023-11-24 19:39:56 +0800252+ fi
253+
developer404df542024-03-26 06:13:54 +0800254+ if [ -n "$fils_discovery_max_interval" ]; then
255+ append bss_conf "fils_discovery_max_interval=$fils_discovery_max_interval" "$N"
256+ fi
developer8b04dfd2022-12-07 16:29:19 +0800257+
developer404df542024-03-26 06:13:54 +0800258+ if [ -n "$rnr" ]; then
259+ append bss_conf "rnr=$rnr" "$N"
260+ fi
developer785b6502023-04-19 18:31:11 +0800261+
developer404df542024-03-26 06:13:54 +0800262 append "$var" "$bss_conf" "$N"
263 return 0
264 }
265@@ -1255,6 +1369,7 @@ wpa_supplicant_prepare_interface() {
266 country_str="country=$country"
developer093e1a32023-02-24 16:10:53 +0800267 }
developer093e1a32023-02-24 16:10:53 +0800268
developer404df542024-03-26 06:13:54 +0800269+ local tx_queue_data2_burst="tx_queue_data2_burst=0"
270 multiap_flag_file="${_config}.is_multiap"
271 if [ "$multi_ap" = "1" ]; then
272 touch "$multiap_flag_file"
273@@ -1266,6 +1381,7 @@ wpa_supplicant_prepare_interface() {
274 ${scan_list:+freq_list=$scan_list}
275 $ap_scan
276 $country_str
277+$tx_queue_data2_burst
developer0ba09b62023-03-10 18:43:49 +0800278 EOF
developer404df542024-03-26 06:13:54 +0800279 return 0
developer0ba09b62023-03-10 18:43:49 +0800280 }
developer404df542024-03-26 06:13:54 +0800281@@ -1537,12 +1653,39 @@ wpa_supplicant_add_network() {
282 ;;
283 esac
284
285- [ "$wpa_cipher" = GCMP ] && {
286- append network_data "pairwise=GCMP" "$N$T"
287- append network_data "group=GCMP" "$N$T"
288- }
289+ json_get_values pairwise pairwise
290+ json_get_vars group_cipher group_mgmt_cipher
291+ if [ -n "$pairwise" ]; then
292+ case "$pairwise" in
293+ *tkip+aes|*tkip+ccmp|*aes+tkip|*ccmp+tkip)
294+ wpa_cipher="CCMP TKIP"
295+ ;;
296+ *ccmp256)
297+ wpa_cipher="CCMP-256"
298+ ;;
299+ *aes|*ccmp)
300+ wpa_cipher="CCMP"
301+ ;;
302+ *tkip)
303+ wpa_cipher="TKIP"
304+ ;;
305+ *gcmp256)
306+ wpa_cipher="GCMP-256"
307+ ;;
308+ *gcmp)
309+ wpa_cipher="GCMP"
310+ ;;
311+ *)
312+ wpa_cipher=""
313+ ;;
314+ esac
315+ fi
316+ [ -n "$wpa_cipher" ] && wpa_pairwise="$wpa_cipher"
317
318 [ "$mode" = mesh ] || {
319+ json_get_values sae_groups sae_groups
320+ json_get_values owe_groups owe_groups
321+
322 case "$wpa" in
323 1)
324 append network_data "proto=WPA" "$N$T"
325@@ -1552,12 +1695,58 @@ wpa_supplicant_add_network() {
326 ;;
327 esac
328
329+ [ -n "$wpa_pairwise" ] && append network_data "pairwise=$wpa_pairwise" "$N$T"
330+ [ -z "$group_cipher" ] && group_cipher="$wpa_cipher"
331+
332+ if [ -n "$sae_groups" -o -n "$owe_groups" ]; then
333+ case "$auth_type" in
334+ sae*)
335+ echo "sae_groups=$sae_groups" >> "$_config"
336+ append network_data "group=$group_cipher" "$N$T"
337+ ;;
338+ owe)
339+ append network_data "owe_group=$owe_groups" "$N$T"
340+ append network_data "group=$group_cipher" "$N$T"
341+ ;;
342+ esac
343+ fi
344+
345+ # RSN -> allow management frame protection
346 case "$ieee80211w" in
347 [012])
348- [ "$wpa" -ge 2 ] && append network_data "ieee80211w=$ieee80211w" "$N$T"
349+ json_get_vars ieee80211w_mgmt_cipher ieee80211w_max_timeout ieee80211w_retry_timeout beacon_prot
350+ append network_data "ieee80211w=$ieee80211w" "$N$T"
351+ [ "$ieee80211w" -gt "0" ] && {
352+ if [ -z "$group_mgmt_cipher" ]; then
353+ case "$group_cipher" in
354+ CCMP-256)
355+ ieee80211w_mgmt_cipher="BIP-CMAC-256"
356+ ;;
357+ CCMP)
358+ ieee80211w_mgmt_cipher="AES-128-CMAC"
359+ ;;
360+ GCMP-256)
361+ ieee80211w_mgmt_cipher="BIP-GMAC-256"
362+ ;;
363+ GCMP)
364+ ieee80211w_mgmt_cipher="BIP-GMAC-128"
365+ ;;
366+ esac
367+ else
368+ ieee80211w_mgmt_cipher="$group_mgmt_cipher"
369+ fi
370+ if [ "$auth_type" = "eap192" ]; then
371+ append network_data "group_mgmt=BIP-GMAC-256" "$N$T"
372+ else
373+ append network_data "group_mgmt=${ieee80211w_mgmt_cipher:-AES-128-CMAC}" "$N$T"
374+ fi
375+ [ -n "$beacon_prot" ] && \
376+ append network_data "beacon_prot=$beacon_prot" "$N$T"
377+ }
378 ;;
379 esac
380 }
381+
382 [ -n "$bssid" ] && append network_data "bssid=$bssid" "$N$T"
383 [ -n "$beacon_int" ] && append network_data "beacon_int=$beacon_int" "$N$T"
384
385@@ -1568,6 +1757,20 @@ wpa_supplicant_add_network() {
386 [ -n "$bssid_blacklist" ] && append network_data "bssid_blacklist=$bssid_blacklist" "$N$T"
387 [ -n "$bssid_whitelist" ] && append network_data "bssid_whitelist=$bssid_whitelist" "$N$T"
developer0ba09b62023-03-10 18:43:49 +0800388
developer404df542024-03-26 06:13:54 +0800389+ local disable_eht
390+ local disable_he
391+ local disable_vht
392+ local disable_ht
393+ json_get_vars disable_eht
394+ json_get_vars disable_he
395+ json_get_vars disable_vht
396+ json_get_vars disable_ht
developer0ba09b62023-03-10 18:43:49 +0800397+
developer404df542024-03-26 06:13:54 +0800398+ [ -n "$disable_eht" ] && append network_data "disable_eht=$disable_eht" "$N$T"
399+ [ -n "$disable_he" ] && append network_data "disable_he=$disable_he" "$N$T"
400+ [ -n "$disable_vht" ] && append network_data "disable_vht=$disable_vht" "$N$T"
401+ [ -n "$disable_ht" ] && append network_data "disable_ht=$disable_ht" "$N$T"
developer0ba09b62023-03-10 18:43:49 +0800402+
developer404df542024-03-26 06:13:54 +0800403 [ -n "$basic_rate" ] && {
404 local br rate_list=
405 for br in $basic_rate; do
406@@ -1582,6 +1785,11 @@ wpa_supplicant_add_network() {
407 append network_data "mcast_rate=$mc_rate" "$N$T"
408 }
409
410+ if [ "$auth_type" = "sae" ]; then
411+ json_get_vars sae_pwe sae_pwe
412+ [ -n "$sae_pwe" ] && echo "sae_pwe=$sae_pwe" >> "$_config"
developer0ba09b62023-03-10 18:43:49 +0800413+ fi
414+
developer404df542024-03-26 06:13:54 +0800415 if [ "$key_mgmt" = "WPS" ]; then
416 echo "wps_cred_processing=1" >> "$_config"
417 else
418diff --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
developer3cd85db2024-05-14 11:17:21 +0800419index bc59c303..2508d9cf 100755
developer404df542024-03-26 06:13:54 +0800420--- a/package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh
421+++ b/package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh
422@@ -29,10 +29,12 @@ drv_mac80211_init_device_config() {
423 config_add_string path phy 'macaddr:macaddr'
424 config_add_string tx_burst
425 config_add_string distance
426+ config_add_int mbssid mu_onoff sr_enable sr_enhanced rnr obss_interval
427 config_add_int beacon_int chanbw frag rts
428 config_add_int rxantenna txantenna txpower min_tx_power
429 config_add_int num_global_macaddr multiple_bssid
430 config_add_boolean noscan ht_coex acs_exclude_dfs background_radar
431+ config_add_boolean noscan ht_coex acs_exclude_dfs background_radar background_cert_mode
432 config_add_array ht_capab
433 config_add_array channels
434 config_add_array scan_list
435@@ -55,7 +57,10 @@ drv_mac80211_init_device_config() {
436 he_spr_sr_control \
437 he_spr_psr_enabled \
438 he_bss_color_enabled \
439- he_twt_required
440+ he_twt_required \
441+ he_twt_responder \
442+ etxbfen \
443+ itxbfen
444 config_add_int \
445 beamformer_antennas \
446 beamformee_antennas \
447@@ -142,13 +147,11 @@ mac80211_hostapd_setup_base() {
448 [ -n "$acs_exclude_dfs" ] && [ "$acs_exclude_dfs" -gt 0 ] &&
449 append base_cfg "acs_exclude_dfs=1" "$N"
developer0ba09b62023-03-10 18:43:49 +0800450
developer404df542024-03-26 06:13:54 +0800451- json_get_vars noscan ht_coex min_tx_power:0 tx_burst
452+ json_get_vars noscan ht_coex min_tx_power:0 tx_burst mbssid mu_onoff rnr obss_interval
453+ json_get_vars etxbfen:1 itxbfen:0
454 json_get_values ht_capab_list ht_capab
455 json_get_values channel_list channels
developer6cfee682023-11-27 19:34:42 +0800456
developer404df542024-03-26 06:13:54 +0800457- [ "$auto_channel" = 0 ] && [ -z "$channel_list" ] && \
458- channel_list="$channel"
459-
460 [ "$min_tx_power" -gt 0 ] && append base_cfg "min_tx_power=$min_tx_power" "$N"
developer24684862023-08-02 08:10:38 +0800461
developer404df542024-03-26 06:13:54 +0800462 set_default noscan 0
463@@ -162,21 +165,42 @@ mac80211_hostapd_setup_base() {
464 ieee80211n=1
465 ht_capab=
466 case "$htmode" in
467- VHT20|HT20|HE20) ;;
468- HT40*|VHT40|VHT80|VHT160|HE40|HE80|HE160)
469+ VHT20|HT20|HE20|EHT20) ;;
470+ HT40*|VHT40|VHT80|VHT160|HE40*|HE80|HE160|EHT40*|EHT80|EHT160|EHT320*)
471 case "$hwmode" in
472 a)
473 case "$(( (($channel / 4) + $chan_ofs) % 2 ))" in
474 1) ht_capab="[HT40+]";;
475 0) ht_capab="[HT40-]";;
476 esac
477+ case "$htmode" in
478+ HT40-|HE40-|EHT40-)
479+ if [ "$auto_channel" -gt 0 ]; then
480+ ht_capab="[HT40-]"
481+ fi
482+ ;;
483+ esac
484 ;;
485 *)
486 case "$htmode" in
487- HT40+) ht_capab="[HT40+]";;
488- HT40-) ht_capab="[HT40-]";;
489+ HT40+|HE40+|EHT40+)
490+ if [ "$channel" -gt 9 ]; then
491+ echo "Could not set the center freq with this HT mode setting"
492+ return 1
493+ else
494+ ht_capab="[HT40+]"
495+ fi
496+ ;;
497+ HT40-|HE40-|EHT40-)
498+ if [ "$channel" -lt 5 -a "$auto_channel" -eq 0 ]; then
499+ echo "Could not set the center freq with this HT mode setting"
500+ return 1
501+ else
502+ ht_capab="[HT40-]"
503+ fi
504+ ;;
505 *)
506- if [ "$channel" -lt 7 ]; then
507+ if [ "$channel" -lt 7 -o "$auto_channel" -gt 0 ]; then
508 ht_capab="[HT40+]"
509 else
510 ht_capab="[HT40-]"
511@@ -185,7 +209,6 @@ mac80211_hostapd_setup_base() {
512 esac
513 ;;
514 esac
515- [ "$auto_channel" -gt 0 ] && ht_capab="[HT40+]"
516 ;;
517 *) ieee80211n= ;;
518 esac
519@@ -196,6 +219,11 @@ mac80211_hostapd_setup_base() {
520 set_default ht_coex 0
521 append base_cfg "ht_coex=$ht_coex" "$N"
522
523+ [ "$ht_coex" -eq 1 ] && {
524+ set_default obss_interval 300
525+ append base_cfg "obss_interval=$obss_interval" "$N"
526+ }
developer24684862023-08-02 08:10:38 +0800527+
developer404df542024-03-26 06:13:54 +0800528 json_get_vars \
529 ldpc:1 \
530 greenfield:0 \
531@@ -207,7 +235,7 @@ mac80211_hostapd_setup_base() {
532 dsss_cck_40:1
533
534 ht_cap_mask=0
535- for cap in $(iw phy "$phy" info | grep 'Capabilities:' | cut -d: -f2); do
536+ for cap in $(iw phy "$phy" info | grep 'Capabilities: 0x' | cut -d: -f2); do
537 ht_cap_mask="$(($ht_cap_mask | $cap))"
538 done
539
540@@ -238,8 +266,8 @@ mac80211_hostapd_setup_base() {
541
542 idx="$channel"
543 case "$htmode" in
544- VHT20|HE20) enable_ac=1;;
545- VHT40|HE40)
546+ VHT20|HE20|EHT20) enable_ac=1;;
547+ VHT40|HE40|EHT40)
548 case "$(( (($channel / 4) + $chan_ofs) % 2 ))" in
549 1) idx=$(($channel + 2));;
550 0) idx=$(($channel - 2));;
551@@ -247,7 +275,7 @@ mac80211_hostapd_setup_base() {
552 enable_ac=1
553 vht_center_seg0=$idx
554 ;;
555- VHT80|HE80)
556+ VHT80|HE80|EHT80)
557 case "$(( (($channel / 4) + $chan_ofs) % 4 ))" in
558 1) idx=$(($channel + 6));;
559 2) idx=$(($channel + 2));;
560@@ -258,7 +286,7 @@ mac80211_hostapd_setup_base() {
561 vht_oper_chwidth=1
562 vht_center_seg0=$idx
563 ;;
564- VHT160|HE160)
565+ VHT160|HE160|EHT160)
566 if [ "$band" = "6g" ]; then
567 case "$channel" in
568 1|5|9|13|17|21|25|29) idx=15;;
569@@ -280,17 +308,57 @@ mac80211_hostapd_setup_base() {
570 vht_oper_chwidth=2
571 vht_center_seg0=$idx
572 ;;
573+ EHT320*)
574+ case "$channel" in
575+ 1|5|9|13|17|21|25|29) idx=31;;
576+ 33|37|41|45|49|53|57|61| \
577+ 65|69|73|77|81|85|89|93) idx=63;;
578+ 97|101|105|109|113|117|121|125| \
579+ 129|133|137|141|145|149|153|157) idx=127;;
580+ 161|165|169|173|177|181|185|189| \
581+ 193|197|201|205|209|213|217|221) idx=191;;
582+ esac
583+ if [[ "$htmode" = "EHT320-1" && "$channel" -ge "193" ]] ||
584+ [[ "$htmode" = "EHT320-2" && "$channel" -le "29" ]]; then
585+ echo "Could not set the center freq with this EHT setting"
586+ return 1
587+ elif [[ "$htmode" = "EHT320-1" && "$channel" -ge "33" ]]; then
588+ if [ "$channel" -gt $idx ]; then
589+ idx=$(($idx + 32))
590+ else
591+ idx=$(($idx - 32))
592+ fi
593+ fi
594+ vht_oper_chwidth=2
595+ if [ "$channel" -gt $idx ]; then
596+ vht_center_seg0=$(($idx + 16))
597+ else
598+ vht_center_seg0=$(($idx - 16))
599+ fi
600+ eht_oper_chwidth=9
601+ eht_oper_centr_freq_seg0_idx=$idx
developer24684862023-08-02 08:10:38 +0800602+
developer404df542024-03-26 06:13:54 +0800603+ case $htmode in
604+ EHT320-1) eht_bw320_offset=1;;
605+ EHT320-2) eht_bw320_offset=2;;
606+ EHT320) eht_bw320_offset=0;;
607+ esac
608+ ;;
609 esac
610 [ "$band" = "5g" ] && {
611- json_get_vars background_radar:0
612+ json_get_vars \
613+ background_radar:0 \
614+ background_cert_mode:0 \
developerf0de14b2022-12-14 23:07:34 +0800615
developer404df542024-03-26 06:13:54 +0800616 [ "$background_radar" -eq 1 ] && append base_cfg "enable_background_radar=1" "$N"
617+ [ "$background_cert_mode" -eq 1 ] && append base_cfg "background_radar_mode=1" "$N"
618 }
619 [ "$band" = "6g" ] && {
620 op_class=
621 case "$htmode" in
622- HE20) op_class=131;;
623- HE*) op_class=$((132 + $vht_oper_chwidth))
624+ HE20|EHT20) op_class=131;;
625+ EHT320*) op_class=137;;
626+ HE*|EHT*) op_class=$((132 + $vht_oper_chwidth))
627 esac
628 [ -n "$op_class" ] && append base_cfg "op_class=$op_class" "$N"
629 }
630@@ -318,7 +386,6 @@ mac80211_hostapd_setup_base() {
631 vht_link_adapt:3 \
632 vht160:2
developerf0de14b2022-12-14 23:07:34 +0800633
developer404df542024-03-26 06:13:54 +0800634- set_default tx_burst 2.0
635 append base_cfg "ieee80211ac=1" "$N"
636 vht_cap=0
637 for cap in $(iw phy "$phy" info | awk -F "[()]" '/VHT Capabilities/ { print $2 }'); do
638@@ -337,6 +404,12 @@ mac80211_hostapd_setup_base() {
639 short_gi_160=0
640 }
developer0ba09b62023-03-10 18:43:49 +0800641
developer404df542024-03-26 06:13:54 +0800642+ [ "$etxbfen" -eq 0 ] && {
643+ su_beamformer=0
644+ su_beamformee=0
645+ mu_beamformer=0
developer6cfee682023-11-27 19:34:42 +0800646+ }
developer6cfee682023-11-27 19:34:42 +0800647+
developer404df542024-03-26 06:13:54 +0800648 mac80211_add_capabilities vht_capab $vht_cap \
649 RXLDPC:0x10::$rxldpc \
650 SHORT-GI-80:0x20::$short_gi_80 \
651@@ -418,7 +491,7 @@ mac80211_hostapd_setup_base() {
652 # 802.11ax
653 enable_ax=0
654 case "$htmode" in
655- HE*) enable_ax=1 ;;
656+ HE*|EHT*) enable_ax=1 ;;
657 esac
developer0ba09b62023-03-10 18:43:49 +0800658
developer404df542024-03-26 06:13:54 +0800659 if [ "$enable_ax" != "0" ]; then
660@@ -427,10 +500,11 @@ mac80211_hostapd_setup_base() {
661 he_su_beamformee:1 \
662 he_mu_beamformer:1 \
663 he_twt_required:0 \
664+ he_twt_responder \
665 he_spr_sr_control:3 \
666 he_spr_psr_enabled:0 \
667 he_spr_non_srg_obss_pd_max_offset:0 \
668- he_bss_color:128 \
669+ he_bss_color \
670 he_bss_color_enabled:1
developer6cfee682023-11-27 19:34:42 +0800671
developer404df542024-03-26 06:13:54 +0800672 he_phy_cap=$(iw phy "$phy" info | sed -n '/HE Iftypes: .*AP/,$p' | awk -F "[()]" '/HE PHY Capabilities/ { print $2 }' | head -1)
673@@ -444,6 +518,11 @@ mac80211_hostapd_setup_base() {
674 append base_cfg "he_oper_centr_freq_seg0_idx=$vht_center_seg0" "$N"
675 }
developer74503112023-06-29 17:34:49 +0800676
developer404df542024-03-26 06:13:54 +0800677+ [ "$etxbfen" -eq 0 ] && {
678+ he_su_beamformer=0
679+ he_mu_beamformer=0
680+ }
developer74503112023-06-29 17:34:49 +0800681+
developer404df542024-03-26 06:13:54 +0800682 mac80211_add_he_capabilities \
683 he_su_beamformer:${he_phy_cap:6:2}:0x80:$he_su_beamformer \
684 he_su_beamformee:${he_phy_cap:8:2}:0x1:$he_su_beamformee \
685@@ -451,7 +530,14 @@ mac80211_hostapd_setup_base() {
686 he_spr_psr_enabled:${he_phy_cap:14:2}:0x1:$he_spr_psr_enabled \
687 he_twt_required:${he_mac_cap:0:2}:0x6:$he_twt_required
developer785b6502023-04-19 18:31:11 +0800688
developer404df542024-03-26 06:13:54 +0800689+ if [ -n "$he_twt_responder" ]; then
690+ append base_cfg "he_twt_responder=$he_twt_responder" "$N"
691+ fi
692 if [ "$he_bss_color_enabled" -gt 0 ]; then
693+ if !([ "$he_bss_color" -gt 0 ] && [ "$he_bss_color" -le 64 ]); then
694+ rand=$(head -n 1 /dev/urandom | tr -dc 0-9 | head -c 2)
695+ he_bss_color=$((rand % 63 + 1))
696+ fi
697 append base_cfg "he_bss_color=$he_bss_color" "$N"
698 [ "$he_spr_non_srg_obss_pd_max_offset" -gt 0 ] && { \
699 append base_cfg "he_spr_non_srg_obss_pd_max_offset=$he_spr_non_srg_obss_pd_max_offset" "$N"
700@@ -470,26 +556,58 @@ mac80211_hostapd_setup_base() {
701 append base_cfg "he_mu_edca_qos_info_q_ack=0" "$N"
702 append base_cfg "he_mu_edca_qos_info_queue_request=0" "$N"
703 append base_cfg "he_mu_edca_qos_info_txop_request=0" "$N"
704- append base_cfg "he_mu_edca_ac_be_aifsn=8" "$N"
705+ append base_cfg "he_mu_edca_ac_be_aifsn=0" "$N"
706 append base_cfg "he_mu_edca_ac_be_aci=0" "$N"
707 append base_cfg "he_mu_edca_ac_be_ecwmin=9" "$N"
708 append base_cfg "he_mu_edca_ac_be_ecwmax=10" "$N"
709- append base_cfg "he_mu_edca_ac_be_timer=255" "$N"
710- append base_cfg "he_mu_edca_ac_bk_aifsn=15" "$N"
711+ append base_cfg "he_mu_edca_ac_be_timer=3" "$N"
712+ append base_cfg "he_mu_edca_ac_bk_aifsn=0" "$N"
713 append base_cfg "he_mu_edca_ac_bk_aci=1" "$N"
714 append base_cfg "he_mu_edca_ac_bk_ecwmin=9" "$N"
715 append base_cfg "he_mu_edca_ac_bk_ecwmax=10" "$N"
716- append base_cfg "he_mu_edca_ac_bk_timer=255" "$N"
717+ append base_cfg "he_mu_edca_ac_bk_timer=3" "$N"
718 append base_cfg "he_mu_edca_ac_vi_ecwmin=5" "$N"
719 append base_cfg "he_mu_edca_ac_vi_ecwmax=7" "$N"
720- append base_cfg "he_mu_edca_ac_vi_aifsn=5" "$N"
721+ append base_cfg "he_mu_edca_ac_vi_aifsn=0" "$N"
722 append base_cfg "he_mu_edca_ac_vi_aci=2" "$N"
723- append base_cfg "he_mu_edca_ac_vi_timer=255" "$N"
724- append base_cfg "he_mu_edca_ac_vo_aifsn=5" "$N"
725+ append base_cfg "he_mu_edca_ac_vi_timer=3" "$N"
726+ append base_cfg "he_mu_edca_ac_vo_aifsn=0" "$N"
727 append base_cfg "he_mu_edca_ac_vo_aci=3" "$N"
728 append base_cfg "he_mu_edca_ac_vo_ecwmin=5" "$N"
729 append base_cfg "he_mu_edca_ac_vo_ecwmax=7" "$N"
730- append base_cfg "he_mu_edca_ac_vo_timer=255" "$N"
731+ append base_cfg "he_mu_edca_ac_vo_timer=3" "$N"
732+ fi
developer20ce7bd2023-05-20 13:25:14 +0800733+
developer404df542024-03-26 06:13:54 +0800734+ set_default tx_burst 2
developer20ce7bd2023-05-20 13:25:14 +0800735+
developer404df542024-03-26 06:13:54 +0800736+ # 802.11be
737+ enable_be=0
738+ case "$htmode" in
739+ EHT*) enable_be=1 ;;
740+ esac
741+
742+ if [ "$enable_be" != "0" ]; then
743+ append base_cfg "ieee80211be=1" "$N"
744+ if [ "$etxbfen" -eq 0 ]; then
745+ append base_cfg "eht_su_beamformee=1" "$N"
developere2597ba2022-06-24 13:09:16 +0800746+ else
developer404df542024-03-26 06:13:54 +0800747+ append base_cfg "eht_su_beamformer=1" "$N"
748+ append base_cfg "eht_su_beamformee=1" "$N"
749+ append base_cfg "eht_mu_beamformer=1" "$N"
developere2597ba2022-06-24 13:09:16 +0800750+ fi
developer404df542024-03-26 06:13:54 +0800751+ [ "$hwmode" = "a" ] && {
752+ case $htmode in
753+ EHT320*)
754+ append base_cfg "eht_oper_chwidth=$eht_oper_chwidth" "$N"
755+ append base_cfg "eht_oper_centr_freq_seg0_idx=$eht_oper_centr_freq_seg0_idx" "$N"
756+ append base_cfg "eht_bw320_offset=$eht_bw320_offset" "$N"
757+ ;;
758+ *)
759+ append base_cfg "eht_oper_chwidth=$vht_oper_chwidth" "$N"
760+ append base_cfg "eht_oper_centr_freq_seg0_idx=$vht_center_seg0" "$N"
761+ ;;
762+ esac
763+ }
764 fi
developere2597ba2022-06-24 13:09:16 +0800765
developer404df542024-03-26 06:13:54 +0800766 hostapd_prepare_device_config "$hostapd_conf_file" nl80211
767@@ -498,6 +616,10 @@ ${channel:+channel=$channel}
768 ${channel_list:+chanlist=$channel_list}
769 ${hostapd_noscan:+noscan=1}
770 ${tx_burst:+tx_queue_data2_burst=$tx_burst}
771+${mbssid:+mbssid=$mbssid}
772+${mu_onoff:+mu_onoff=$mu_onoff}
773+${itxbfen:+ibf_enable=$itxbfen}
774+${rnr:+rnr=$rnr}
775 ${multiple_bssid:+mbssid=$multiple_bssid}
776 #num_global_macaddr=$num_global_macaddr
777 $base_cfg
778@@ -525,7 +647,7 @@ mac80211_hostapd_setup_bss() {
779 append hostapd_cfg "wds_sta=1" "$N"
780 [ -n "$wds_bridge" ] && append hostapd_cfg "wds_bridge=$wds_bridge" "$N"
781 }
782- [ "$staidx" -gt 0 -o "$start_disabled" -eq 1 ] && append hostapd_cfg "start_disabled=1" "$N"
783+ [ "$start_disabled" -eq 1 ] && append hostapd_cfg "start_disabled=1" "$N"
developer785b6502023-04-19 18:31:11 +0800784
developer404df542024-03-26 06:13:54 +0800785 cat >> /var/run/hostapd-$phy.conf <<EOF
786 $hostapd_cfg
787@@ -536,6 +658,31 @@ ${max_listen_int:+max_listen_interval=$max_listen_int}
788 EOF
789 }
developer785b6502023-04-19 18:31:11 +0800790
developer404df542024-03-26 06:13:54 +0800791+mac80211_generate_mbssid_mac() {
792+ local phy="$1"
793+ local transmitted_bssid="$2"
794+ local id="${mbssidx:-0}"
developer785b6502023-04-19 18:31:11 +0800795+
developer404df542024-03-26 06:13:54 +0800796+ local ref="$(cat /sys/class/ieee80211/${phy}/macaddress)"
developer785b6502023-04-19 18:31:11 +0800797+
developer404df542024-03-26 06:13:54 +0800798+ if [ -z "$transmitted_bssid" ]; then
799+ transmitted_bssid=$ref
800+ fi
developered11bba2023-12-12 18:03:26 +0800801+
developer404df542024-03-26 06:13:54 +0800802+ if [ $id -eq 0 ]; then
803+ echo "$transmitted_bssid"
804+ return
805+ fi
developer212c0d82023-07-13 19:41:47 +0800806+
developer404df542024-03-26 06:13:54 +0800807+ local oIFS="$IFS"; IFS=":"; set -- $transmitted_bssid; IFS="$oIFS"
developer212c0d82023-07-13 19:41:47 +0800808+
developer404df542024-03-26 06:13:54 +0800809+ # Calculate nontransmitted bssid
810+ b6="0x$6"
811+ ref_b6=$(($b6 % $max_mbssid))
812+ b6=$(($b6 - $ref_b6 + ($ref_b6 + $id) % $max_mbssid))
813+ printf "%s:%s:%s:%s:%s:%02x" $1 $2 $3 $4 $5 $b6
814+}
815+
816 mac80211_get_addr() {
817 local phy="$1"
818 local idx="$(($2 + 1))"
819@@ -659,7 +806,19 @@ mac80211_prepare_vif() {
820 json_add_string _ifname "$ifname"
821
822 default_macaddr=
823- if [ -z "$macaddr" ]; then
824+ if [ "$mbssid" -gt 0 ] && [ "$mode" == "ap" ]; then
825+ [ "$mbssidx" -eq 0 ] && {
826+ if [ -z $macaddr ]; then
827+ transmitted_bssid="$(mac80211_generate_mac $phy)"
828+ else
829+ # uci set mac address
830+ transmitted_bssid=$macaddr
831+ fi
832+ macidx="$(($macidx + 1))"
developerf7aff422023-11-14 11:11:34 +0800833+ }
developer404df542024-03-26 06:13:54 +0800834+ macaddr="$(mac80211_generate_mbssid_mac $phy $transmitted_bssid)"
835+ mbssidx="$(($mbssidx + 1))"
836+ elif [ -z "$macaddr" ]; then
837 macaddr="$(mac80211_generate_mac $phy)"
838 macidx="$(($macidx + 1))"
839 default_macaddr=1
developer3cd85db2024-05-14 11:17:21 +0800840@@ -917,6 +1076,14 @@ wpa_supplicant_set_config() {
developer8d77be32022-10-20 15:08:25 +0800841 }
developer82408892023-03-27 15:09:00 +0800842
developer404df542024-03-26 06:13:54 +0800843 hostapd_set_config() {
developer82408892023-03-27 15:09:00 +0800844+
developer404df542024-03-26 06:13:54 +0800845+ if [ "$inconsistent_country" -eq 1 ]; then
846+ echo "ERROR: Please use the same country for all the radios."
847+ wireless_setup_failed HOSTAPD_START_FAILED
848+ drv_mac80211_teardown
849+ return
850+ fi
developer813f5d72023-03-28 17:44:38 +0800851+
developer404df542024-03-26 06:13:54 +0800852 [ -n "$hostapd_ctrl" ] || {
853 ubus_call hostapd config_set '{ "phy": "'"$phy"'", "config": "", "prev_config": "'"${hostapd_conf_file}.prev"'" }' > /dev/null
854 return 0;
developer3cd85db2024-05-14 11:17:21 +0800855@@ -1000,6 +1167,9 @@ mac80211_setup_vif() {
developer404df542024-03-26 06:13:54 +0800856
857 json_select ..
858 [ -n "$failed" ] || wireless_add_vif "$name" "$ifname"
developer74503112023-06-29 17:34:49 +0800859+
developer404df542024-03-26 06:13:54 +0800860+ echo "Setup SMP Affinity"
861+ /sbin/smp-mt76.sh
developer82408892023-03-27 15:09:00 +0800862 }
863
developer404df542024-03-26 06:13:54 +0800864 get_freq() {
developer3cd85db2024-05-14 11:17:21 +0800865@@ -1051,6 +1221,25 @@ mac80211_reset_config() {
developer404df542024-03-26 06:13:54 +0800866 wdev_tool "$phy" set_config '{}'
developerf166f542023-05-25 14:40:30 +0800867 }
868
developer404df542024-03-26 06:13:54 +0800869+mac80211_count_ap() {
870+ total_num_ap=$(($total_num_ap + 1))
871+}
872+
873+country_consistent_check() {
874+ local i
875+ inconsistent_country=0
876+ country_list="$(cat /etc/config/wireless | grep country | cut -d ' ' -f3 | tr -s "'\n" ' ')"
877+ for i in $country_list
878+ do
879+ ret="$(echo $country_list | awk '{print ($2 == "" || $1 == $2)}')"
880+ [ $ret = '0' ] && {
881+ inconsistent_country=1
882+ return
883+ }
884+ country_list="$(echo $country_list | sed -r 's/[A-Z]{2}( )*//')"
885+ done
886+}
887+
888 drv_mac80211_setup() {
889 json_select config
890 json_get_vars \
developer3cd85db2024-05-14 11:17:21 +0800891@@ -1059,7 +1248,8 @@ drv_mac80211_setup() {
developer404df542024-03-26 06:13:54 +0800892 txpower \
893 rxantenna txantenna \
894 frag rts beacon_int:100 htmode \
895- num_global_macaddr:1 multiple_bssid
896+ num_global_macaddr:1 multiple_bssid \
897+ sr_enable sr_enhanced
898 json_get_values basic_rate_list basic_rate
899 json_get_values scan_list scan_list
900 json_select ..
developer3cd85db2024-05-14 11:17:21 +0800901@@ -1090,10 +1280,18 @@ drv_mac80211_setup() {
902 }
903 }
904
905+ # each phy sleeps different times to prevent for ubus race condition.
906+ if [ "$phy" = "phy1" ]; then
907+ sleep 3;
908+ elif [ "$phy" = "phy2" ]; then
909+ sleep 6;
910+ fi
911+
912 hostapd_conf_file="/var/run/hostapd-$phy.conf"
developerf166f542023-05-25 14:40:30 +0800913
developer404df542024-03-26 06:13:54 +0800914 macidx=0
915 staidx=0
916+ mbssidx=0
developerf166f542023-05-25 14:40:30 +0800917
developer404df542024-03-26 06:13:54 +0800918 [ -n "$chanbw" ] && {
919 for file in /sys/kernel/debug/ieee80211/$phy/ath9k*/chanbw /sys/kernel/debug/ieee80211/$phy/ath5k/bwmode; do
developer3cd85db2024-05-14 11:17:21 +0800920@@ -1142,14 +1340,29 @@ drv_mac80211_setup() {
developer74503112023-06-29 17:34:49 +0800921
developer404df542024-03-26 06:13:54 +0800922 wpa_supplicant_init_config
923
924+ total_num_ap=0
925+ max_mbssid=1
926+ for_each_interface "ap" mac80211_count_ap
927+ total_num_ap=$(($total_num_ap - 1))
928+ while [ $total_num_ap -gt 0 ]
929+ do
930+ total_num_ap=$(($total_num_ap >> 1))
931+ max_mbssid=$(($max_mbssid << 1))
932+ done
developer74503112023-06-29 17:34:49 +0800933+
developer404df542024-03-26 06:13:54 +0800934 mac80211_prepare_iw_htmode
935 active_ifnames=
936 for_each_interface "ap sta adhoc mesh monitor" mac80211_prepare_vif
937 for_each_interface "ap sta adhoc mesh monitor" mac80211_setup_vif
developer74503112023-06-29 17:34:49 +0800938
developer404df542024-03-26 06:13:54 +0800939+ country_consistent_check
940+
941 [ -x /usr/sbin/wpa_supplicant ] && wpa_supplicant_set_config "$phy"
942 [ -x /usr/sbin/hostapd ] && hostapd_set_config "$phy"
developerda723192023-05-22 19:46:10 +0800943
developer404df542024-03-26 06:13:54 +0800944+ [ -n "$sr_enable" ] && echo "$sr_enable" > /sys/kernel/debug/ieee80211/$phy/mt76/sr_enable
945+ [ -n "$sr_enhanced" ] && echo "$sr_enhanced" > /sys/kernel/debug/ieee80211/$phy/mt76/sr_enhanced_enable
946+
947 [ -x /usr/sbin/wpa_supplicant ] && wpa_supplicant_start "$phy"
developer74503112023-06-29 17:34:49 +0800948
developer404df542024-03-26 06:13:54 +0800949 json_set_namespace wdev_uc prev
950diff --git a/package/network/config/wifi-scripts/files/lib/wifi/mac80211.sh b/package/network/config/wifi-scripts/files/lib/wifi/mac80211.sh
developeradd54322024-04-22 18:57:56 +0800951index e24a2a63..3c78e1a1 100644
developer404df542024-03-26 06:13:54 +0800952--- a/package/network/config/wifi-scripts/files/lib/wifi/mac80211.sh
953+++ b/package/network/config/wifi-scripts/files/lib/wifi/mac80211.sh
954@@ -60,6 +60,9 @@ BEGIN {
955 if (vht && band != "1:") mode="VHT80"
956 if (he) mode="HE80"
957 if (he && band == "1:") mode="HE20"
958+ if (eht && band == "2:") mode="EHT160"
959+ if (eht && band == "4:") mode="EHT320"
960+ if (eht && band == "1:") mode="EHT20"
961 sub("\\[", "", channel)
962 sub("\\]", "", channel)
963 bands = bands band channel ":" mode " "
964@@ -73,6 +76,7 @@ $1 == "Band" {
965 vht = ""
966 ht = ""
967 he = ""
968+ eht = ""
969 }
developer03fcbcb2024-01-26 14:26:38 +0800970
developer404df542024-03-26 06:13:54 +0800971 $0 ~ "Capabilities:" {
972@@ -87,6 +91,18 @@ $0 ~ "HE Iftypes" {
973 he=1
974 }
developer74503112023-06-29 17:34:49 +0800975
developer404df542024-03-26 06:13:54 +0800976+$0 ~ "EHT Iftypes" {
977+ eht=1
978+}
developer74503112023-06-29 17:34:49 +0800979+
developer404df542024-03-26 06:13:54 +0800980+$0 ~ / *HE MAC Capabilities \(0x000000000000\)/ {
981+ he=0
982+}
developer74503112023-06-29 17:34:49 +0800983+
developer404df542024-03-26 06:13:54 +0800984+$0 ~ / *EHT MAC Capabilities \(0x0000\)/ {
985+ eht=0
986+}
987+
988 $1 == "*" && $3 == "MHz" && $0 !~ /disabled/ && band && !channel {
989 channel = $4
990 }
991@@ -120,6 +136,26 @@ get_band_defaults() {
992 mode_band="$band"
993 channel="$chan"
994 htmode="$mode"
995+ if [ "$band" = "6g" ]
996+ then
997+ encryption=sae
998+ key=12345678
999+ sae_pwe=2
1000+ ieee80211w=2
1001+ channel=37
1002+ mbssid=1
1003+ mbo=1
1004+ elif [ "$band" = "5g" ]
1005+ then
1006+ noscan=1
1007+ encryption=none
1008+ rnr=1
1009+ background_radar=1
1010+ else
1011+ noscan=1
1012+ encryption=none
1013+ rnr=1
1014+ fi
developer74503112023-06-29 17:34:49 +08001015 done
developer5b3b7a92023-08-12 03:41:52 +08001016 }
developer18015ad2023-07-13 13:18:19 +08001017
developeradd54322024-04-22 18:57:56 +08001018@@ -148,11 +184,20 @@ check_board_phy() {
1019
1020 detect_mac80211() {
1021 devidx=0
1022+ disabled=0
1023 config_load wireless
1024 config_foreach check_devidx wifi-device
developer74503112023-06-29 17:34:49 +08001025
developer404df542024-03-26 06:13:54 +08001026 json_load_file /etc/board.json
developer74503112023-06-29 17:34:49 +08001027
developer404df542024-03-26 06:13:54 +08001028+ # generate random bytes for macaddr
1029+ rand=$(hexdump -C /dev/urandom | head -n 1 &)
1030+ killall hexdump
developer74503112023-06-29 17:34:49 +08001031+
developeradd54322024-04-22 18:57:56 +08001032+ if (dmesg | grep -q "WM_TM"); then
1033+ disabled=1
1034+ fi
1035+
developer404df542024-03-26 06:13:54 +08001036 for _dev in /sys/class/ieee80211/*; do
1037 [ -e "$_dev" ] || continue
1038
developeradd54322024-04-22 18:57:56 +08001039@@ -162,6 +207,14 @@ detect_mac80211() {
developer404df542024-03-26 06:13:54 +08001040 channel=""
1041 htmode=""
1042 ht_capab=""
1043+ encryption=""
1044+ noscan=""
1045+ key=""
1046+ sae_pwe=""
1047+ ieee80211w=""
1048+ mbssid=""
1049+ rnr=""
1050+ background_radar=""
1051
1052 get_band_defaults "$dev"
1053
developeradd54322024-04-22 18:57:56 +08001054@@ -196,6 +249,19 @@ detect_mac80211() {
developer404df542024-03-26 06:13:54 +08001055 ;;
developer74503112023-06-29 17:34:49 +08001056 esac
1057
developer404df542024-03-26 06:13:54 +08001058+ macaddr=""
1059+ if (dmesg | grep -q "eeprom load fail"); then
1060+ for i in $(seq 2 3); do
1061+ macaddr=${macaddr}:$(echo $rand | cut -d ' ' -f $i)
1062+ done
1063+ macaddr="00:0$(($devidx - 1)):55:66${macaddr}"
developer74503112023-06-29 17:34:49 +08001064+ fi
1065+
developer404df542024-03-26 06:13:54 +08001066+ tx_burst=""
1067+ if (lspci | grep -q "7992"); then
1068+ tx_burst=0.0
1069+ fi
developer74503112023-06-29 17:34:49 +08001070+
developer404df542024-03-26 06:13:54 +08001071 uci -q batch <<-EOF
1072 set wireless.${name}=wifi-device
1073 set wireless.${name}.type=mac80211
developeradd54322024-04-22 18:57:56 +08001074@@ -203,15 +269,49 @@ detect_mac80211() {
developer404df542024-03-26 06:13:54 +08001075 set wireless.${name}.channel=${channel}
1076 set wireless.${name}.band=${mode_band}
1077 set wireless.${name}.htmode=$htmode
1078- set wireless.${name}.disabled=1
1079+ set wireless.${name}.country='US'
1080+ set wireless.${name}.noscan=${noscan}
developeradd54322024-04-22 18:57:56 +08001081+ set wireless.${name}.disabled=${disabled}
developer404df542024-03-26 06:13:54 +08001082+EOF
1083+ [ -n "$mbssid" ] && {
1084+ uci -q set wireless.${name}.mbssid=${mbssid}
1085+ }
1086+ [ -n "$rnr" ] && {
1087+ uci -q set wireless.${name}.rnr=${rnr}
1088+ }
1089+ [ -n "$background_radar" ] && {
1090+ uci -q set wireless.${name}.background_radar=${background_radar}
1091+ }
1092+ [ -n "$tx_burst" ] && {
1093+ uci -q set wireless.${name}.tx_burst=${tx_burst}
1094+ }
developer82408892023-03-27 15:09:00 +08001095
developer404df542024-03-26 06:13:54 +08001096+ uci -q batch <<-EOF
1097 set wireless.default_${name}=wifi-iface
1098 set wireless.default_${name}.device=${name}
1099 set wireless.default_${name}.network=lan
1100 set wireless.default_${name}.mode=ap
1101- set wireless.default_${name}.ssid=OpenWrt
1102- set wireless.default_${name}.encryption=none
1103+ set wireless.default_${name}.ssid=OpenWrt-${mode_band}
1104+ set wireless.default_${name}.encryption=${encryption}
1105 EOF
developer82408892023-03-27 15:09:00 +08001106+
developer404df542024-03-26 06:13:54 +08001107+ # calibrated board will use eeprom macaddress, not ramdom address
1108+ [ -n "$macaddr" ] && {
1109+ uci -q set wireless.default_${name}.macaddr=${macaddr}
1110+ }
developer85839fe2023-02-23 10:32:51 +08001111+
developer404df542024-03-26 06:13:54 +08001112+ [ -n "$key" ] && {
1113+ uci -q set wireless.default_${name}.key=${key}
1114+ }
1115+ [ -n "$sae_pwe" ] && {
1116+ uci -q set wireless.default_${name}.sae_pwe=${sae_pwe}
1117+ }
1118+ [ -n "$ieee80211w" ] && {
1119+ uci -q set wireless.default_${name}.ieee80211w=${ieee80211w}
1120+ }
1121+ [ -n "$mbo" ] && {
1122+ uci -q set wireless.default_${name}.mbo=${mbo}
1123+ }
1124 uci -q commit wireless
1125 done
1126 }