developer | 3477027 | 2023-09-12 09:34:36 +0800 | [diff] [blame^] | 1 | From 34205ed1077ac7e759cf112ec424966e48ad314f Mon Sep 17 00:00:00 2001 |
| 2 | From: Michael-CY Lee <michael-cy.lee@mediatek.com> |
| 3 | Date: Mon, 11 Sep 2023 13:39:14 +0800 |
| 4 | Subject: [PATCH] ucode: mtk: synchronize bandwidth in AP/STA support |
| 5 | |
| 6 | Change-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 | |
developer | 428a8d2 | 2023-09-01 15:00:06 +0800 | [diff] [blame] | 12 | diff --git a/package/network/services/hostapd/files/hostapd.uc b/package/network/services/hostapd/files/hostapd.uc |
developer | 3477027 | 2023-09-12 09:34:36 +0800 | [diff] [blame^] | 13 | index 43637ac7..7202a8df 100644 |
developer | 428a8d2 | 2023-09-01 15:00:06 +0800 | [diff] [blame] | 14 | --- a/package/network/services/hostapd/files/hostapd.uc |
| 15 | +++ b/package/network/services/hostapd/files/hostapd.uc |
developer | 3477027 | 2023-09-12 09:34:36 +0800 | [diff] [blame^] | 16 | @@ -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 | |
developer | 428a8d2 | 2023-09-01 15:00:06 +0800 | [diff] [blame] | 58 | if (freq < 4000) |
| 59 | width = 0; |
| 60 | |
developer | 3477027 | 2023-09-12 09:34:36 +0800 | [diff] [blame^] | 61 | - return hostapd.freq_info(freq, sec_offset, width); |
| 62 | + return hostapd.freq_info(freq, sec_offset, width, bw320_offset); |
developer | 428a8d2 | 2023-09-01 15:00:06 +0800 | [diff] [blame] | 63 | } |
| 64 | |
developer | 3477027 | 2023-09-12 09:34:36 +0800 | [diff] [blame^] | 65 | function iface_add(phy, config, phy_status) |
| 66 | @@ -386,6 +391,8 @@ let main_obj = { |
developer | 428a8d2 | 2023-09-01 15:00:06 +0800 | [diff] [blame] | 67 | up: true, |
| 68 | frequency: 0, |
| 69 | sec_chan_offset: 0, |
developer | 3477027 | 2023-09-12 09:34:36 +0800 | [diff] [blame^] | 70 | + ch_width: -1, |
| 71 | + bw320_offset: 1, |
developer | 428a8d2 | 2023-09-01 15:00:06 +0800 | [diff] [blame] | 72 | csa: true, |
| 73 | csa_count: 0, |
| 74 | }, |
developer | 3477027 | 2023-09-12 09:34:36 +0800 | [diff] [blame^] | 75 | @@ -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) |
developer | 428a8d2 | 2023-09-01 15:00:06 +0800 | [diff] [blame] | 91 | diff --git a/package/network/services/hostapd/files/wpa_supplicant.uc b/package/network/services/hostapd/files/wpa_supplicant.uc |
developer | 3477027 | 2023-09-12 09:34:36 +0800 | [diff] [blame^] | 92 | index f8a3fcb5..c24ea03c 100644 |
developer | 428a8d2 | 2023-09-01 15:00:06 +0800 | [diff] [blame] | 93 | --- a/package/network/services/hostapd/files/wpa_supplicant.uc |
| 94 | +++ b/package/network/services/hostapd/files/wpa_supplicant.uc |
developer | 3477027 | 2023-09-12 09:34:36 +0800 | [diff] [blame^] | 95 | @@ -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) |
developer | 428a8d2 | 2023-09-01 15:00:06 +0800 | [diff] [blame] | 104 | msg.up = true; |
| 105 | msg.frequency = status.frequency; |
| 106 | msg.sec_chan_offset = status.sec_chan_offset; |
| 107 | + msg.ch_width = status.ch_width; |
developer | 3477027 | 2023-09-12 09:34:36 +0800 | [diff] [blame^] | 108 | + msg.bw320_offset = status.bw320_offset; |
developer | 428a8d2 | 2023-09-01 15:00:06 +0800 | [diff] [blame] | 109 | break; |
| 110 | default: |
| 111 | return; |
developer | 3477027 | 2023-09-12 09:34:36 +0800 | [diff] [blame^] | 112 | @@ -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 | -- |
| 122 | 2.25.1 |
| 123 | |