blob: d026a3debfaa431b0b504e7b16511174b034de39 [file] [log] [blame]
developer3e0400f2023-02-10 08:32:03 +08001diff --git a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
developer14d6f502023-03-31 14:08:27 +08002index 5aaba9a..54a5d88 100644
developer3e0400f2023-02-10 08:32:03 +08003--- a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
4+++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
developer14d6f502023-03-31 14:08:27 +08005@@ -160,8 +160,8 @@ mac80211_hostapd_setup_base() {
developer3e0400f2023-02-10 08:32:03 +08006 ieee80211n=1
7 ht_capab=
8 case "$htmode" in
9- VHT20|HT20|HE20) ;;
10- HT40*|VHT40|VHT80|VHT160|HE40|HE80|HE160)
11+ VHT20|HT20|HE20|EHT20) ;;
12+ HT40*|VHT40|VHT80|VHT160|HE40|HE80|HE160|EHT40|EHT80|EHT160|EHT320*)
13 case "$hwmode" in
14 a)
15 case "$(( (($channel / 4) + $chan_ofs) % 2 ))" in
developer14d6f502023-03-31 14:08:27 +080016@@ -205,7 +205,7 @@ mac80211_hostapd_setup_base() {
developer3e0400f2023-02-10 08:32:03 +080017 dsss_cck_40:1
18
19 ht_cap_mask=0
20- for cap in $(iw phy "$phy" info | grep 'Capabilities:' | cut -d: -f2); do
21+ for cap in $(iw phy "$phy" info | grep 'Capabilities: 0x' | cut -d: -f2); do
22 ht_cap_mask="$(($ht_cap_mask | $cap))"
23 done
24
developer14d6f502023-03-31 14:08:27 +080025@@ -236,8 +236,8 @@ mac80211_hostapd_setup_base() {
developer3e0400f2023-02-10 08:32:03 +080026
27 idx="$channel"
28 case "$htmode" in
29- VHT20|HE20) enable_ac=1;;
30- VHT40|HE40)
31+ VHT20|HE20|EHT20) enable_ac=1;;
32+ VHT40|HE40|EHT40)
33 case "$(( (($channel / 4) + $chan_ofs) % 2 ))" in
34 1) idx=$(($channel + 2));;
35 0) idx=$(($channel - 2));;
developer14d6f502023-03-31 14:08:27 +080036@@ -245,7 +245,7 @@ mac80211_hostapd_setup_base() {
developer3e0400f2023-02-10 08:32:03 +080037 enable_ac=1
38 vht_center_seg0=$idx
39 ;;
40- VHT80|HE80)
41+ VHT80|HE80|EHT80)
42 case "$(( (($channel / 4) + $chan_ofs) % 4 ))" in
43 1) idx=$(($channel + 6));;
44 2) idx=$(($channel + 2));;
developer14d6f502023-03-31 14:08:27 +080045@@ -256,7 +256,7 @@ mac80211_hostapd_setup_base() {
developer3e0400f2023-02-10 08:32:03 +080046 vht_oper_chwidth=1
47 vht_center_seg0=$idx
48 ;;
49- VHT160|HE160)
50+ VHT160|HE160|EHT160)
51 if [ "$band" = "6g" ]; then
52 case "$channel" in
53 1|5|9|13|17|21|25|29) idx=15;;
developer14d6f502023-03-31 14:08:27 +080054@@ -277,6 +277,36 @@ mac80211_hostapd_setup_base() {
developer3e0400f2023-02-10 08:32:03 +080055 vht_oper_chwidth=2
56 vht_center_seg0=$idx
57 ;;
58+ EHT320*)
59+ case "$channel" in
60+ 1|5|9|13|17|21|25|29) idx=31;;
61+ 33|37|41|45|49|53|57|61| \
62+ 65|69|73|77|81|85|89|93) idx=63;;
63+ 97|101|105|109|113|117|121|125| \
64+ 129|133|137|141|145|149|153|157) idx=127;;
65+ 161|165|169|173|177|181|185|189| \
66+ 193|197|201|205|209|213|217|221) idx=191;;
67+ esac
68+ if [[ "$htmode" = "EHT320-1" && "$channel" -ge "193" ]] ||
69+ [[ "$htmode" = "EHT320-2" && "$channel" -le "29" ]]; then
70+ echo "Could not set the center freq with this EHT setting"
71+ return 1
72+ elif [[ "$htmode" = "EHT320-1" && "$channel" -ge "33" ]]; then
73+ if [ "$channel" -gt $idx ]; then
74+ idx=$(($idx + 32))
75+ else
76+ idx=$(($idx - 32))
77+ fi
78+ fi
79+ vht_oper_chwidth=2
80+ if [ "$channel" -gt $idx ]; then
81+ vht_center_seg0=$(($idx + 16))
82+ else
83+ vht_center_seg0=$(($idx - 16))
84+ fi
85+ eht_oper_chwidth=9
86+ eht_oper_centr_freq_seg0_idx=$idx
87+ ;;
88 esac
89 [ "$band" = "5g" ] && {
90 json_get_vars background_radar:0
developer14d6f502023-03-31 14:08:27 +080091@@ -286,8 +316,9 @@ mac80211_hostapd_setup_base() {
developer3e0400f2023-02-10 08:32:03 +080092 [ "$band" = "6g" ] && {
93 op_class=
94 case "$htmode" in
95- HE20) op_class=131;;
96- HE*) op_class=$((132 + $vht_oper_chwidth))
97+ HE20|EHT20) op_class=131;;
98+ EHT320*) op_class=137;;
99+ HE*|EHT*) op_class=$((132 + $vht_oper_chwidth))
100 esac
101 [ -n "$op_class" ] && append base_cfg "op_class=$op_class" "$N"
102 }
developer14d6f502023-03-31 14:08:27 +0800103@@ -410,7 +441,7 @@ mac80211_hostapd_setup_base() {
developer3e0400f2023-02-10 08:32:03 +0800104 # 802.11ax
105 enable_ax=0
106 case "$htmode" in
107- HE*) enable_ax=1 ;;
108+ HE*|EHT*) enable_ax=1 ;;
109 esac
110
111 if [ "$enable_ax" != "0" ]; then
developer14d6f502023-03-31 14:08:27 +0800112@@ -484,6 +515,31 @@ mac80211_hostapd_setup_base() {
developer3e0400f2023-02-10 08:32:03 +0800113 append base_cfg "he_mu_edca_ac_vo_timer=255" "$N"
114 fi
115
116+ # 802.11be
117+ enable_be=0
118+ case "$htmode" in
119+ EHT*) enable_be=1 ;;
120+ esac
121+
122+ if [ "$enable_be" != "0" ]; then
123+ append base_cfg "ieee80211be=1" "$N"
developer14d6f502023-03-31 14:08:27 +0800124+ append base_cfg "eht_su_beamformer=1" "$N"
125+ append base_cfg "eht_su_beamformee=1" "$N"
126+ append base_cfg "eht_mu_beamformer=1" "$N"
developer3e0400f2023-02-10 08:32:03 +0800127+ [ "$hwmode" = "a" ] && {
128+ case $htmode in
129+ EHT320*)
130+ append base_cfg "eht_oper_chwidth=$eht_oper_chwidth" "$N"
131+ append base_cfg "eht_oper_centr_freq_seg0_idx=$eht_oper_centr_freq_seg0_idx" "$N"
132+ ;;
133+ *)
134+ append base_cfg "eht_oper_chwidth=$vht_oper_chwidth" "$N"
135+ append base_cfg "eht_oper_centr_freq_seg0_idx=$vht_center_seg0" "$N"
136+ ;;
137+ esac
138+ }
139+ fi
140+
141 hostapd_prepare_device_config "$hostapd_conf_file" nl80211
142 cat >> "$hostapd_conf_file" <<EOF
143 ${channel:+channel=$channel}
144diff --git a/package/kernel/mac80211/files/lib/wifi/mac80211.sh b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
developer14d6f502023-03-31 14:08:27 +0800145index 10a3f8b..80cd298 100644
developer3e0400f2023-02-10 08:32:03 +0800146--- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh
147+++ b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
148@@ -60,6 +60,8 @@ BEGIN {
149 if (vht && band != "1:") mode="VHT80"
150 if (he) mode="HE80"
151 if (he && band == "1:") mode="HE20"
152+ if (eht) mode="EHT80"
153+ if (eht && band == "1:") mode="EHT20"
154 sub("\\[", "", channel)
155 sub("\\]", "", channel)
156 bands = bands band channel ":" mode " "
157@@ -73,6 +75,7 @@ $1 == "Band" {
158 vht = ""
159 ht = ""
160 he = ""
161+ eht = ""
162 }
163
164 $0 ~ "Capabilities:" {
165@@ -87,6 +90,10 @@ $0 ~ "HE Iftypes" {
166 he=1
167 }
168
169+$0 ~ "EHT Iftypes" {
170+ eht=1
171+}
172+
173 $1 == "*" && $3 == "MHz" && $0 !~ /disabled/ && band && !channel {
174 channel = $4
175 }
176@@ -160,6 +167,10 @@ detect_mac80211() {
177
178 json_load_file /etc/board.json
179
180+ # generate random bytes for macaddr
181+ rand=$(hexdump -C /dev/urandom | head -n 1 &)
182+ killall hexdump
183+
184 for _dev in /sys/class/ieee80211/*; do
185 [ -e "$_dev" ] || continue
186
developer14d6f502023-03-31 14:08:27 +0800187@@ -205,6 +216,11 @@ detect_mac80211() {
developer3e0400f2023-02-10 08:32:03 +0800188 ;;
189 esac
190
191+ macaddr=""
192+ for i in $(seq 2 3); do
193+ macaddr=${macaddr}:$(echo $rand | cut -d ' ' -f $i)
194+ done
195+
196 uci -q batch <<-EOF
197 set wireless.${name}=wifi-device
198 set wireless.${name}.type=mac80211
developer14d6f502023-03-31 14:08:27 +0800199@@ -221,6 +237,8 @@ detect_mac80211() {
developer3e0400f2023-02-10 08:32:03 +0800200 set wireless.default_${name}.ssid=OpenWrt
201 set wireless.default_${name}.encryption=${encryption}
202
203+ set wireless.default_${name}.macaddr=00:0$(($devidx - 1)):55:66${macaddr}
204+
205 EOF
206 [ -n "$key" ] && {
207 uci -q set wireless.default_${name}.key=${key}