blob: 19983cd3b99eb4cfeb3bb73af5c694b23eeb8589 [file] [log] [blame]
developerce9e5092022-11-10 22:41:59 +08001diff --git a/package/kernel/mac80211/Makefile b/package/kernel/mac80211/Makefile
developer813f5d72023-03-28 17:44:38 +08002index b7059fe6..62c13eb2 100644
developerce9e5092022-11-10 22:41:59 +08003--- a/package/kernel/mac80211/Makefile
4+++ b/package/kernel/mac80211/Makefile
developerf0de14b2022-12-14 23:07:34 +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 = \
developerf0de14b2022-12-14 23:07:34 +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
developerf0de14b2022-12-14 23:07:34 +080024@@ -297,6 +302,8 @@ define Build/Prepare
developer356ecec2022-11-14 10:25:04 +080025 mkdir -p $(PKG_BUILD_DIR)
26 $(PKG_UNPACK)
27 $(Build/Patch)
28+ $(CP) $(SOURCE_PATH)/net $(PKG_BUILD_DIR) 2>/dev/null || :
29+ $(CP) $(SOURCE_PATH)/include $(PKG_BUILD_DIR) 2>/dev/null || :
30 rm -rf \
31 $(PKG_BUILD_DIR)/include/linux/ssb \
32 $(PKG_BUILD_DIR)/include/linux/bcma \
developer20d67712022-03-02 14:09:32 +080033diff --git a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
developer813f5d72023-03-28 17:44:38 +080034index 5aaba9af..6d051038 100644
developer20d67712022-03-02 14:09:32 +080035--- a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
36+++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
developer0ba09b62023-03-10 18:43:49 +080037@@ -27,6 +27,7 @@ drv_mac80211_init_device_config() {
38
39 config_add_string path phy 'macaddr:macaddr'
40 config_add_string tx_burst
41+ config_add_int mbssid
42 config_add_string distance
43 config_add_int beacon_int chanbw frag rts
44 config_add_int rxantenna txantenna antenna_gain txpower min_tx_power
45@@ -140,13 +141,10 @@ mac80211_hostapd_setup_base() {
46 [ -n "$acs_exclude_dfs" ] && [ "$acs_exclude_dfs" -gt 0 ] &&
47 append base_cfg "acs_exclude_dfs=1" "$N"
48
49- json_get_vars noscan ht_coex min_tx_power:0 tx_burst
50+ json_get_vars noscan ht_coex min_tx_power:0 tx_burst mbssid
developer8d77be32022-10-20 15:08:25 +080051 json_get_values ht_capab_list ht_capab
developer20d67712022-03-02 14:09:32 +080052 json_get_values channel_list channels
53
54- [ "$auto_channel" = 0 ] && [ -z "$channel_list" ] && \
55- channel_list="$channel"
56-
developer9b3248d2022-07-06 00:44:05 +080057 [ "$min_tx_power" -gt 0 ] && append base_cfg "min_tx_power=$min_tx_power"
developer20d67712022-03-02 14:09:32 +080058
developer9b3248d2022-07-06 00:44:05 +080059 set_default noscan 0
developer0ba09b62023-03-10 18:43:49 +080060@@ -315,7 +313,6 @@ mac80211_hostapd_setup_base() {
developer8b04dfd2022-12-07 16:29:19 +080061 vht_link_adapt:3 \
62 vht160:2
63
64- set_default tx_burst 2.0
65 append base_cfg "ieee80211ac=1" "$N"
66 vht_cap=0
67 for cap in $(iw phy "$phy" info | awk -F "[()]" '/VHT Capabilities/ { print $2 }'); do
developer0ba09b62023-03-10 18:43:49 +080068@@ -484,12 +481,15 @@ mac80211_hostapd_setup_base() {
developer8b04dfd2022-12-07 16:29:19 +080069 append base_cfg "he_mu_edca_ac_vo_timer=255" "$N"
70 fi
71
developer9851a292022-12-15 17:33:43 +080072+ set_default tx_burst 5.9
developer8b04dfd2022-12-07 16:29:19 +080073+
74 hostapd_prepare_device_config "$hostapd_conf_file" nl80211
75 cat >> "$hostapd_conf_file" <<EOF
76 ${channel:+channel=$channel}
developer0ba09b62023-03-10 18:43:49 +080077 ${channel_list:+chanlist=$channel_list}
78 ${hostapd_noscan:+noscan=1}
79 ${tx_burst:+tx_queue_data2_burst=$tx_burst}
80+${mbssid:+mbssid=$mbssid}
81 $base_cfg
82
83 EOF
84@@ -517,7 +517,7 @@ mac80211_hostapd_setup_bss() {
developer093e1a32023-02-24 16:10:53 +080085 append hostapd_cfg "wds_sta=1" "$N"
86 [ -n "$wds_bridge" ] && append hostapd_cfg "wds_bridge=$wds_bridge" "$N"
87 }
88- [ "$staidx" -gt 0 -o "$start_disabled" -eq 1 ] && append hostapd_cfg "start_disabled=1" "$N"
89+ [ "$start_disabled" -eq 1 ] && append hostapd_cfg "start_disabled=1" "$N"
90
91 cat >> /var/run/hostapd-$phy.conf <<EOF
92 $hostapd_cfg
developer0ba09b62023-03-10 18:43:49 +080093@@ -527,6 +527,34 @@ ${max_listen_int:+max_listen_interval=$max_listen_int}
94 EOF
95 }
96
97+mac80211_generate_mbssid_mac() {
98+ local phy="$1"
99+ local transmitted_bssid="$2"
100+ local id="${macidx:-0}"
101+
102+ local ref="$(cat /sys/class/ieee80211/${phy}/macaddress)"
103+ local mask="$(cat /sys/class/ieee80211/${phy}/address_mask)"
104+
105+ if [ -z "$transmitted_bssid" ]; then
106+ transmitted_bssid=$ref
107+ fi
108+
109+ if [ $id -eq 0 ]; then
110+ echo "$transmitted_bssid"
111+ return
112+ fi
113+
114+ local oIFS="$IFS"; IFS=":"; set -- $transmitted_bssid; IFS="$oIFS"
115+
116+ # Calculate nontransmitted bssid
117+ macidx=$(($id + 1))
118+ mbssid_idx=$(($macidx - 1))
119+ b6="0x$6"
120+ ref_b6=$(($b6 % $max_mbssid))
121+ b6=$(($b6 - $ref_b6 + ($ref_b6 + $mbssid_idx) % $max_mbssid))
122+ printf "%s:%s:%s:%s:%s:%02x" $1 $2 $3 $4 $5 $b6
123+}
124+
125 mac80211_get_addr() {
126 local phy="$1"
127 local idx="$(($2 + 1))"
128@@ -757,7 +785,13 @@ mac80211_prepare_vif() {
129
130 json_select ..
131
132- if [ -z "$macaddr" ]; then
133+ if [ "$mbssid" -gt 0 ]; then
134+ [ "$macidx" -eq 0 ] && {
135+ transmitted_bssid=$macaddr
136+ }
137+ macaddr="$(mac80211_generate_mbssid_mac $phy $transmitted_bssid)"
138+ macidx="$(($macidx + 1))"
139+ elif [ -z "$macaddr" ]; then
140 macaddr="$(mac80211_generate_mac $phy)"
141 macidx="$(($macidx + 1))"
142 elif [ "$macaddr" = 'random' ]; then
143@@ -1058,6 +1092,9 @@ mac80211_setup_vif() {
developerf0de14b2022-12-14 23:07:34 +0800144
145 json_select ..
146 [ -n "$failed" ] || wireless_add_vif "$name" "$ifname"
147+
148+ echo "Setup SMP Affinity"
149+ /sbin/smp-mt76.sh
150 }
151
152 get_freq() {
developer0ba09b62023-03-10 18:43:49 +0800153@@ -1122,6 +1159,10 @@ drv_mac80211_cleanup() {
154 hostapd_common_cleanup
155 }
156
157+mac80211_count_ap() {
158+ total_num_ap=$(($total_num_ap + 1))
159+}
160+
161 drv_mac80211_setup() {
162 json_select config
163 json_get_vars \
164@@ -1219,6 +1260,16 @@ drv_mac80211_setup() {
165 for_each_interface "sta adhoc mesh" mac80211_set_noscan
166 [ -n "$has_ap" ] && mac80211_hostapd_setup_base "$phy"
167
168+ total_num_ap=0
169+ max_mbssid=1
170+ for_each_interface "ap" mac80211_count_ap
171+ total_num_ap=$(($total_num_ap - 1))
172+ while [ $total_num_ap -gt 0 ]
173+ do
174+ total_num_ap=$(($total_num_ap >> 1))
175+ max_mbssid=$(($max_mbssid << 1))
176+ done
177+
178 mac80211_prepare_iw_htmode
179 for_each_interface "sta adhoc mesh monitor" mac80211_prepare_vif
180 NEWAPLIST=
developer9b3248d2022-07-06 00:44:05 +0800181diff --git a/package/kernel/mac80211/files/lib/wifi/mac80211.sh b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
developer813f5d72023-03-28 17:44:38 +0800182index e24a2a63..10a3f8b4 100644
developere2597ba2022-06-24 13:09:16 +0800183--- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh
184+++ b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
developer8d77be32022-10-20 15:08:25 +0800185@@ -120,6 +120,13 @@ get_band_defaults() {
developere2597ba2022-06-24 13:09:16 +0800186 mode_band="$band"
187 channel="$chan"
188 htmode="$mode"
189+ if [ "$band" = "6g" ]
190+ then
191+ encryption=sae
192+ key=12345678
193+ else
194+ encryption=none
195+ fi
196 done
197 }
198
developer8d77be32022-10-20 15:08:25 +0800199@@ -162,6 +169,8 @@ detect_mac80211() {
developere2597ba2022-06-24 13:09:16 +0800200 channel=""
201 htmode=""
202 ht_capab=""
203+ encryption=""
204+ key=""
205
206 get_band_defaults "$dev"
207
developer093e1a32023-02-24 16:10:53 +0800208@@ -210,8 +219,12 @@ detect_mac80211() {
developer8d77be32022-10-20 15:08:25 +0800209 set wireless.default_${name}.network=lan
210 set wireless.default_${name}.mode=ap
211 set wireless.default_${name}.ssid=OpenWrt
212- set wireless.default_${name}.encryption=none
213+ set wireless.default_${name}.encryption=${encryption}
214+
developere2597ba2022-06-24 13:09:16 +0800215 EOF
216+ [ -n "$key" ] && {
developer8d77be32022-10-20 15:08:25 +0800217+ uci -q set wireless.default_${name}.key=${key}
developere2597ba2022-06-24 13:09:16 +0800218+ }
219 uci -q commit wireless
developer8d77be32022-10-20 15:08:25 +0800220 done
221 }
developer85839fe2023-02-23 10:32:51 +0800222diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh
developer813f5d72023-03-28 17:44:38 +0800223index 28bd2106..5e21d0d6 100644
developer85839fe2023-02-23 10:32:51 +0800224--- a/package/network/services/hostapd/files/hostapd.sh
225+++ b/package/network/services/hostapd/files/hostapd.sh
developer813f5d72023-03-28 17:44:38 +0800226@@ -376,6 +376,13 @@ hostapd_common_add_bss_config() {
developer82408892023-03-27 15:09:00 +0800227 config_add_string fils_dhcp
228
229 config_add_int ocv
230+
231+ config_add_int disable_eht
232+ config_add_int disable_he
233+ config_add_int disable_vht
234+ config_add_int disable_ht
developer813f5d72023-03-28 17:44:38 +0800235+
236+ config_add_boolean beacon_prot
developer82408892023-03-27 15:09:00 +0800237 }
238
239 hostapd_set_vlan_file() {
developer813f5d72023-03-28 17:44:38 +0800240@@ -975,7 +982,7 @@ hostapd_set_bss_options() {
241 # RSN -> allow management frame protection
242 case "$ieee80211w" in
243 [012])
244- json_get_vars ieee80211w_mgmt_cipher ieee80211w_max_timeout ieee80211w_retry_timeout
245+ json_get_vars ieee80211w_mgmt_cipher ieee80211w_max_timeout ieee80211w_retry_timeout beacon_prot
246 append bss_conf "ieee80211w=$ieee80211w" "$N"
247 [ "$ieee80211w" -gt "0" ] && {
248 if [ "$auth_type" = "eap192" ]; then
249@@ -983,6 +990,8 @@ hostapd_set_bss_options() {
250 else
251 append bss_conf "group_mgmt_cipher=${ieee80211w_mgmt_cipher:-AES-128-CMAC}" "$N"
252 fi
253+ [ -n "$beacon_prot" ] && \
254+ append bss_conf "beacon_prot=$beacon_prot" "$N"
255 [ -n "$ieee80211w_max_timeout" ] && \
256 append bss_conf "assoc_sa_query_max_timeout=$ieee80211w_max_timeout" "$N"
257 [ -n "$ieee80211w_retry_timeout" ] && \
258@@ -1559,6 +1568,20 @@ wpa_supplicant_add_network() {
developer82408892023-03-27 15:09:00 +0800259 [ -n "$bssid_blacklist" ] && append network_data "bssid_blacklist=$bssid_blacklist" "$N$T"
260 [ -n "$bssid_whitelist" ] && append network_data "bssid_whitelist=$bssid_whitelist" "$N$T"
261
262+ local disable_eht
263+ local disable_he
264+ local disable_vht
265+ local disable_ht
266+ json_get_vars disable_eht
267+ json_get_vars disable_he
268+ json_get_vars disable_vht
269+ json_get_vars disable_ht
270+
271+ [ -n "$disable_eht" ] && append network_data "disable_eht=$disable_eht" "$N$T"
272+ [ -n "$disable_he" ] && append network_data "disable_he=$disable_he" "$N$T"
273+ [ -n "$disable_vht" ] && append network_data "disable_vht=$disable_vht" "$N$T"
274+ [ -n "$disable_ht" ] && append network_data "disable_ht=$disable_ht" "$N$T"
275+
276 [ -n "$basic_rate" ] && {
277 local br rate_list=
278 for br in $basic_rate; do
developer813f5d72023-03-28 17:44:38 +0800279@@ -1573,6 +1596,11 @@ wpa_supplicant_add_network() {
developer85839fe2023-02-23 10:32:51 +0800280 append network_data "mcast_rate=$mc_rate" "$N$T"
281 }
282
283+ if [ "$auth_type" = "sae" ]; then
284+ json_get_vars sae_pwe sae_pwe
285+ [ -n "$sae_pwe" ] && echo "sae_pwe=$sae_pwe" >> "$_config"
286+ fi
287+
288 if [ "$key_mgmt" = "WPS" ]; then
289 echo "wps_cred_processing=1" >> "$_config"
290 else