blob: 927fbaf292ee2222a37b1e2c4e6999eb6987a4d4 [file] [log] [blame]
developer34770272023-09-12 09:34:36 +08001From 34205ed1077ac7e759cf112ec424966e48ad314f Mon Sep 17 00:00:00 2001
2From: Michael-CY Lee <michael-cy.lee@mediatek.com>
3Date: Mon, 11 Sep 2023 13:39:14 +0800
4Subject: [PATCH] ucode: mtk: synchronize bandwidth in AP/STA support
5
6Change-Id: I1ec83a1d218784de53509b771e2e5487a01e0da6
7---
8 .../network/services/hostapd/files/hostapd.uc | 40 +++++++++++++------
9 .../services/hostapd/files/wpa_supplicant.uc | 5 +++
10 2 files changed, 33 insertions(+), 12 deletions(-)
11
developer428a8d22023-09-01 15:00:06 +080012diff --git a/package/network/services/hostapd/files/hostapd.uc b/package/network/services/hostapd/files/hostapd.uc
developer34770272023-09-12 09:34:36 +080013index 43637ac7..7202a8df 100644
developer428a8d22023-09-01 15:00:06 +080014--- a/package/network/services/hostapd/files/hostapd.uc
15+++ b/package/network/services/hostapd/files/hostapd.uc
developer34770272023-09-12 09:34:36 +080016@@ -58,6 +58,7 @@ start_disabled=1
17 function iface_freq_info(iface, config, params)
18 {
19 let freq = params.frequency;
20+ let bw320_offset = params.bw320_offset;
21 if (!freq)
22 return null;
23
24@@ -66,25 +67,29 @@ function iface_freq_info(iface, config, params)
25 sec_offset = 0;
26
27 let width = 0;
28- for (let line in config.radio.data) {
29- if (!sec_offset && match(line, /^ht_capab=.*HT40/)) {
30- sec_offset = null; // auto-detect
31- continue;
32- }
33+ if (params.ch_width >= 0){
34+ width = params.ch_width;
35+ } else {
36+ for (let line in config.radio.data) {
37+ if (!sec_offset && match(line, /^ht_capab=.*HT40/)) {
38+ sec_offset = null; // auto-detect
39+ continue;
40+ }
41
42- let val = match(line, /^(vht_oper_chwidth|he_oper_chwidth|eht_oper_chwidth)=(\d+)/);
43- if (!val)
44- continue;
45+ let val = match(line, /^(vht_oper_chwidth|he_oper_chwidth|eht_oper_chwidth)=(\d+)/);
46+ if (!val)
47+ continue;
48
49- val = int(val[2]);
50- if (val > width)
51- width = val;
52+ val = int(val[2]);
53+ if (val > width)
54+ width = val;
55+ }
56 }
57
developer428a8d22023-09-01 15:00:06 +080058 if (freq < 4000)
59 width = 0;
60
developer34770272023-09-12 09:34:36 +080061- return hostapd.freq_info(freq, sec_offset, width);
62+ return hostapd.freq_info(freq, sec_offset, width, bw320_offset);
developer428a8d22023-09-01 15:00:06 +080063 }
64
developer34770272023-09-12 09:34:36 +080065 function iface_add(phy, config, phy_status)
66@@ -386,6 +391,8 @@ let main_obj = {
developer428a8d22023-09-01 15:00:06 +080067 up: true,
68 frequency: 0,
69 sec_chan_offset: 0,
developer34770272023-09-12 09:34:36 +080070+ ch_width: -1,
71+ bw320_offset: 1,
developer428a8d22023-09-01 15:00:06 +080072 csa: true,
73 csa_count: 0,
74 },
developer34770272023-09-12 09:34:36 +080075@@ -393,6 +400,15 @@ let main_obj = {
76 if (req.args.up == null || !req.args.phy)
77 return libubus.STATUS_INVALID_ARGUMENT;
78
79+ hostapd.printf(`ucode: mtk: apsta state update`);
80+ hostapd.printf(` * phy: ${req.args.phy}`);
81+ hostapd.printf(` * up: ${req.args.up}`);
82+ hostapd.printf(` * freqeuncy: ${req.args.frequency}`);
83+ hostapd.printf(` * sec_chan_offset: ${req.args.sec_chan_offset}`);
84+ hostapd.printf(` * ch_width: ${req.args.ch_width}`);
85+ hostapd.printf(` * bw320_offset: ${req.args.bw320_offset}`);
86+ hostapd.printf(` * csa: ${req.args.csa}`);
87+
88 let phy = req.args.phy;
89 let config = hostapd.data.config[phy];
90 if (!config || !config.bss || !config.bss[0] || !config.bss[0].ifname)
developer428a8d22023-09-01 15:00:06 +080091diff --git a/package/network/services/hostapd/files/wpa_supplicant.uc b/package/network/services/hostapd/files/wpa_supplicant.uc
developer34770272023-09-12 09:34:36 +080092index f8a3fcb5..c24ea03c 100644
developer428a8d22023-09-01 15:00:06 +080093--- a/package/network/services/hostapd/files/wpa_supplicant.uc
94+++ b/package/network/services/hostapd/files/wpa_supplicant.uc
developer34770272023-09-12 09:34:36 +080095@@ -226,6 +226,7 @@ function iface_hostapd_notify(phy, ifname, iface, state)
96 let status = iface.status();
97 let msg = { phy: phy };
98
99+ wpas.printf(`ucode: mtk: wpa_s in state ${state} notifies hostapd`);
100 switch (state) {
101 case "DISCONNECTED":
102 case "AUTHENTICATING":
103@@ -240,6 +241,8 @@ function iface_hostapd_notify(phy, ifname, iface, state)
developer428a8d22023-09-01 15:00:06 +0800104 msg.up = true;
105 msg.frequency = status.frequency;
106 msg.sec_chan_offset = status.sec_chan_offset;
107+ msg.ch_width = status.ch_width;
developer34770272023-09-12 09:34:36 +0800108+ msg.bw320_offset = status.bw320_offset;
developer428a8d22023-09-01 15:00:06 +0800109 break;
110 default:
111 return;
developer34770272023-09-12 09:34:36 +0800112@@ -256,6 +259,8 @@ function iface_channel_switch(phy, ifname, iface, info)
113 csa: true,
114 csa_count: info.csa_count ? info.csa_count - 1 : 0,
115 frequency: info.frequency,
116+ ch_width: info.ch_width,
117+ bw320_offset: info.bw320_offset,
118 sec_chan_offset: info.sec_chan_offset,
119 };
120 ubus.call("hostapd", "apsta_state", msg);
121--
1222.25.1
123