developer | 2fd555a | 2023-07-25 05:48:15 +0800 | [diff] [blame] | 1 | From add7a84a8a3d33c120c47ff7662134cacbab858e Mon Sep 17 00:00:00 2001 |
developer | d3f0293 | 2023-03-21 14:55:54 +0800 | [diff] [blame] | 2 | From: Michael Lee <michael-cy.lee@mediatek.com> |
| 3 | Date: Wed, 22 Mar 2023 13:59:29 +0800 |
developer | 2fd555a | 2023-07-25 05:48:15 +0800 | [diff] [blame] | 4 | Subject: [PATCH 23/35] hostapd: mtk: Add channel information for hostapd |
developer | 81939a5 | 2023-03-25 15:31:11 +0800 | [diff] [blame] | 5 | reload |
developer | d3f0293 | 2023-03-21 14:55:54 +0800 | [diff] [blame] | 6 | |
| 7 | Add center channel, operating class, and bandwidth into the UPDATE |
| 8 | command when wpa_supplciant reloads hostapd. |
| 9 | Hostapd can correctly update its channel information. |
| 10 | |
| 11 | Signed-off-by: Michael Lee <michael-cy.lee@mediatek.com> |
| 12 | --- |
| 13 | hostapd/ctrl_iface.c | 11 +++++++++++ |
| 14 | wpa_supplicant/wpa_supplicant.c | 17 ++++++++++++++--- |
| 15 | 2 files changed, 25 insertions(+), 3 deletions(-) |
| 16 | |
| 17 | diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c |
developer | 2fd555a | 2023-07-25 05:48:15 +0800 | [diff] [blame] | 18 | index e1e9270..4c5d494 100644 |
developer | d3f0293 | 2023-03-21 14:55:54 +0800 | [diff] [blame] | 19 | --- a/hostapd/ctrl_iface.c |
| 20 | +++ b/hostapd/ctrl_iface.c |
| 21 | @@ -170,6 +170,17 @@ static struct hostapd_config *hostapd_ctrl_iface_config_read(const char *fname) |
| 22 | conf->hw_mode = atoi(val); |
| 23 | else if ((val = get_option(opt, "ieee80211n="))) |
| 24 | conf->ieee80211n = atoi(val); |
| 25 | + else if ((val = get_option(opt, "center_segment0="))) |
| 26 | + hostapd_set_oper_centr_freq_seg0_idx(conf, atoi(val)); |
| 27 | + else if ((val = get_option(opt, "center_segment1="))) |
| 28 | + hostapd_set_oper_centr_freq_seg1_idx(conf, atoi(val)); |
| 29 | + else if ((val = get_option(opt, "op_class="))) { |
| 30 | + enum oper_chan_width ch_width; |
| 31 | + |
| 32 | + conf->op_class = atoi(val); |
| 33 | + ch_width = op_class_to_ch_width(conf->op_class); |
| 34 | + hostapd_set_oper_chwidth(conf, ch_width); |
| 35 | + } |
| 36 | else |
| 37 | break; |
| 38 | } |
| 39 | diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c |
developer | 8eb72a3 | 2023-03-30 08:32:07 +0800 | [diff] [blame] | 40 | index 270da46..04c37b1 100644 |
developer | d3f0293 | 2023-03-21 14:55:54 +0800 | [diff] [blame] | 41 | --- a/wpa_supplicant/wpa_supplicant.c |
| 42 | +++ b/wpa_supplicant/wpa_supplicant.c |
| 43 | @@ -150,9 +150,10 @@ static int hostapd_reload(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) |
| 44 | char buf[256]; |
| 45 | size_t len = sizeof(buf); |
| 46 | enum hostapd_hw_mode hw_mode; |
| 47 | - u8 channel; |
developer | 5eb95ed | 2023-03-28 10:40:04 +0800 | [diff] [blame] | 48 | + u8 channel, center_segment0, center_segment1 = 0, op_class; |
developer | d3f0293 | 2023-03-21 14:55:54 +0800 | [diff] [blame] | 49 | int sec_chan = 0; |
| 50 | int ret; |
| 51 | + struct wpa_channel_info ci; |
| 52 | |
| 53 | if (!bss) |
| 54 | return -1; |
| 55 | @@ -165,9 +166,19 @@ static int hostapd_reload(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) |
| 56 | sec_chan = -1; |
| 57 | } |
| 58 | |
| 59 | + ret = wpa_drv_channel_info(wpa_s, &ci); |
| 60 | + if (ret) |
| 61 | + return -1; |
| 62 | + |
| 63 | + ieee80211_freq_to_chan(ci.center_frq1, ¢er_segment0); |
| 64 | + ieee80211_freq_to_chan(ci.center_frq2, ¢er_segment1); |
| 65 | + ieee80211_chaninfo_to_channel(ci.frequency, ci.chanwidth, sec_chan, |
| 66 | + &op_class, &channel); |
| 67 | hw_mode = ieee80211_freq_to_chan(bss->freq, &channel); |
| 68 | - if (asprintf(&cmd, "UPDATE channel=%d sec_chan=%d hw_mode=%d", |
| 69 | - channel, sec_chan, hw_mode) < 0) |
| 70 | + if (asprintf(&cmd, "UPDATE channel=%d center_segment0=%d " |
| 71 | + "center_segment1=%d sec_chan=%d hw_mode=%d op_class=%d", |
| 72 | + channel, center_segment0, center_segment1, sec_chan, |
| 73 | + hw_mode, op_class) < 0) |
| 74 | return -1; |
| 75 | |
| 76 | ret = wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL); |
| 77 | -- |
developer | 81939a5 | 2023-03-25 15:31:11 +0800 | [diff] [blame] | 78 | 2.18.0 |
developer | d3f0293 | 2023-03-21 14:55:54 +0800 | [diff] [blame] | 79 | |