blob: 2b57f70afc374181001aebe7a386ea207baba607 [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
2index a055005..0c31ad4 100644
3--- a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
4+++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
5@@ -157,8 +157,8 @@ mac80211_hostapd_setup_base() {
6 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
16@@ -202,7 +202,7 @@ mac80211_hostapd_setup_base() {
17 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
25@@ -233,8 +233,8 @@ mac80211_hostapd_setup_base() {
26
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));;
36@@ -242,7 +242,7 @@ mac80211_hostapd_setup_base() {
37 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));;
45@@ -253,7 +253,7 @@ mac80211_hostapd_setup_base() {
46 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;;
54@@ -274,6 +274,36 @@ mac80211_hostapd_setup_base() {
55 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
91@@ -283,8 +313,9 @@ mac80211_hostapd_setup_base() {
92 [ "$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 }
103@@ -407,7 +438,7 @@ mac80211_hostapd_setup_base() {
104 # 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
112@@ -481,6 +512,28 @@ mac80211_hostapd_setup_base() {
113 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"
124+ [ "$hwmode" = "a" ] && {
125+ case $htmode in
126+ EHT320*)
127+ append base_cfg "eht_oper_chwidth=$eht_oper_chwidth" "$N"
128+ append base_cfg "eht_oper_centr_freq_seg0_idx=$eht_oper_centr_freq_seg0_idx" "$N"
129+ ;;
130+ *)
131+ append base_cfg "eht_oper_chwidth=$vht_oper_chwidth" "$N"
132+ append base_cfg "eht_oper_centr_freq_seg0_idx=$vht_center_seg0" "$N"
133+ ;;
134+ esac
135+ }
136+ fi
137+
138 hostapd_prepare_device_config "$hostapd_conf_file" nl80211
139 cat >> "$hostapd_conf_file" <<EOF
140 ${channel:+channel=$channel}
141diff --git a/package/kernel/mac80211/files/lib/wifi/mac80211.sh b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
142index 438bf92..cb85bac 100644
143--- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh
144+++ b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
145@@ -60,6 +60,8 @@ BEGIN {
146 if (vht && band != "1:") mode="VHT80"
147 if (he) mode="HE80"
148 if (he && band == "1:") mode="HE20"
149+ if (eht) mode="EHT80"
150+ if (eht && band == "1:") mode="EHT20"
151 sub("\\[", "", channel)
152 sub("\\]", "", channel)
153 bands = bands band channel ":" mode " "
154@@ -73,6 +75,7 @@ $1 == "Band" {
155 vht = ""
156 ht = ""
157 he = ""
158+ eht = ""
159 }
160
161 $0 ~ "Capabilities:" {
162@@ -87,6 +90,10 @@ $0 ~ "HE Iftypes" {
163 he=1
164 }
165
166+$0 ~ "EHT Iftypes" {
167+ eht=1
168+}
169+
170 $1 == "*" && $3 == "MHz" && $0 !~ /disabled/ && band && !channel {
171 channel = $4
172 }
173@@ -160,6 +167,10 @@ detect_mac80211() {
174
175 json_load_file /etc/board.json
176
177+ # generate random bytes for macaddr
178+ rand=$(hexdump -C /dev/urandom | head -n 1 &)
179+ killall hexdump
180+
181 for _dev in /sys/class/ieee80211/*; do
182 [ -e "$_dev" ] || continue
183
184@@ -201,6 +212,11 @@ detect_mac80211() {
185 ;;
186 esac
187
188+ macaddr=""
189+ for i in $(seq 2 3); do
190+ macaddr=${macaddr}:$(echo $rand | cut -d ' ' -f $i)
191+ done
192+
193 uci -q batch <<-EOF
194 set wireless.${name}=wifi-device
195 set wireless.${name}.type=mac80211
196@@ -217,6 +233,8 @@ detect_mac80211() {
197 set wireless.default_${name}.ssid=OpenWrt
198 set wireless.default_${name}.encryption=${encryption}
199
200+ set wireless.default_${name}.macaddr=00:0$(($devidx - 1)):55:66${macaddr}
201+
202 EOF
203 [ -n "$key" ] && {
204 uci -q set wireless.default_${name}.key=${key}
205--
2062.25.1
207