1 From 91976250359b263a44861aebe553b20627fe487e Mon Sep 17 00:00:00 2001
2 From: Markus Theil <markus.theil@tu-ilmenau.de>
3 Date: Tue, 30 Jun 2020 13:53:17 +0200
4 Subject: [PATCH 01/19] HE/VHT: fix frequency setup with HE enabled
6 Some places in the code base were not using the
7 wrappers like hostapd_set_oper_centr_freq_seg0_idx
8 and friends. This could lead to errors, for example when
9 joining 80 MHz mesh networks. Fix this, by enforcing
10 usage of these wrappers.
12 wpa_supplicant_conf_ap_ht now checks for HE capability
13 before dealing with VHT in order for these wrappers to work,
14 as they first check HE support in the config.
16 While doing these changes, I've noticed that the extra
17 channel setup code for mesh networks in wpa_supplicant/mesh.c
18 should not be necessary anymore and dropped it.
19 wpa_supplicant_conf_ap_ht should handle this setup already.
21 Acked-by: John Crispin <john@phrozen.org>
22 Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
24 src/ap/dfs.c | 8 ++++----
25 wpa_supplicant/ap.c | 40 +++++++++++++++++++++++-----------------
26 wpa_supplicant/mesh.c | 24 ------------------------
27 3 files changed, 27 insertions(+), 45 deletions(-)
31 @@ -1028,7 +1028,7 @@ static int hostapd_dfs_start_channel_swi
34 struct hostapd_hw_modes *cmode = iface->current_mode;
35 - u8 current_vht_oper_chwidth = iface->conf->vht_oper_chwidth;
36 + u8 current_vht_oper_chwidth = hostapd_get_oper_chwidth(iface->conf);
38 wpa_printf(MSG_DEBUG, "%s called (CAC active: %s, CSA active: %s)",
39 __func__, iface->cac_started ? "yes" : "no",
40 @@ -1089,8 +1089,8 @@ static int hostapd_dfs_start_channel_swi
41 "freq=%d chan=%d sec_chan=%d", channel->freq,
42 channel->chan, secondary_channel);
44 - new_vht_oper_chwidth = iface->conf->vht_oper_chwidth;
45 - iface->conf->vht_oper_chwidth = current_vht_oper_chwidth;
46 + new_vht_oper_chwidth = hostapd_get_oper_chwidth(iface->conf);
47 + hostapd_set_oper_chwidth(iface->conf, current_vht_oper_chwidth);
49 /* Setup CSA request */
50 os_memset(&csa_settings, 0, sizeof(csa_settings));
51 @@ -1130,7 +1130,7 @@ static int hostapd_dfs_start_channel_swi
52 iface->freq = channel->freq;
53 iface->conf->channel = channel->chan;
54 iface->conf->secondary_channel = secondary_channel;
55 - iface->conf->vht_oper_chwidth = new_vht_oper_chwidth;
56 + hostapd_set_oper_chwidth(iface->conf, new_vht_oper_chwidth);
57 hostapd_set_oper_centr_freq_seg0_idx(iface->conf,
58 oper_centr_freq_seg0_idx);
59 hostapd_set_oper_centr_freq_seg1_idx(iface->conf,
60 --- a/wpa_supplicant/ap.c
61 +++ b/wpa_supplicant/ap.c
62 @@ -52,6 +52,7 @@ static void wpas_conf_ap_vht(struct wpa_
65 u8 channel = conf->channel;
67 #endif /* CONFIG_P2P */
69 if (!conf->secondary_channel)
70 @@ -59,19 +60,21 @@ static void wpas_conf_ap_vht(struct wpa_
72 /* Use the maximum oper channel width if it's given. */
73 if (ssid->max_oper_chwidth)
74 - conf->vht_oper_chwidth = ssid->max_oper_chwidth;
75 + hostapd_set_oper_chwidth(conf, ssid->max_oper_chwidth);
77 ieee80211_freq_to_chan(ssid->vht_center_freq2,
78 - &conf->vht_oper_centr_freq_seg1_idx);
80 + hostapd_set_oper_centr_freq_seg1_idx(conf, freq_seg_idx);
82 if (!ssid->p2p_group) {
83 if (!ssid->vht_center_freq1 ||
84 - conf->vht_oper_chwidth == CHANWIDTH_USE_HT)
85 + hostapd_get_oper_chwidth(conf) == CHANWIDTH_USE_HT)
87 ieee80211_freq_to_chan(ssid->vht_center_freq1,
88 - &conf->vht_oper_centr_freq_seg0_idx);
90 + hostapd_set_oper_centr_freq_seg0_idx(conf, freq_seg_idx);
91 wpa_printf(MSG_DEBUG, "VHT seg0 index %d for AP",
92 - conf->vht_oper_centr_freq_seg0_idx);
93 + hostapd_get_oper_centr_freq_seg0_idx(conf));
97 @@ -96,14 +99,14 @@ static void wpas_conf_ap_vht(struct wpa_
98 * try oper_cwidth 160 MHz first then VHT 80 MHz, if 160 MHz is
101 - conf->vht_oper_chwidth = CHANWIDTH_160MHZ;
102 + hostapd_set_oper_chwidth(conf, CHANWIDTH_160MHZ);
103 center_chan = wpas_p2p_get_vht160_center(wpa_s, mode, channel);
105 wpa_printf(MSG_DEBUG,
106 "VHT center channel %u for auto-selected 160 MHz bandwidth",
109 - conf->vht_oper_chwidth = CHANWIDTH_80MHZ;
110 + hostapd_set_oper_chwidth(conf, CHANWIDTH_80MHZ);
111 center_chan = wpas_p2p_get_vht80_center(wpa_s, mode,
113 wpa_printf(MSG_DEBUG,
114 @@ -115,9 +118,9 @@ static void wpas_conf_ap_vht(struct wpa_
118 - conf->vht_oper_centr_freq_seg0_idx = center_chan;
119 + hostapd_set_oper_centr_freq_seg0_idx(conf, center_chan);
120 wpa_printf(MSG_DEBUG, "VHT seg0 index %d for P2P GO",
121 - conf->vht_oper_centr_freq_seg0_idx);
122 + hostapd_get_oper_centr_freq_seg0_idx(conf));
124 #endif /* CONFIG_P2P */
126 @@ -125,9 +128,9 @@ no_vht:
127 wpa_printf(MSG_DEBUG,
128 "No VHT higher bandwidth support for the selected channel %d",
130 - conf->vht_oper_centr_freq_seg0_idx =
131 - conf->channel + conf->secondary_channel * 2;
132 - conf->vht_oper_chwidth = CHANWIDTH_USE_HT;
133 + hostapd_set_oper_centr_freq_seg0_idx(conf,
134 + conf->channel + conf->secondary_channel * 2);
135 + hostapd_set_oper_chwidth(conf, CHANWIDTH_USE_HT);
139 @@ -231,16 +234,19 @@ int wpa_supplicant_conf_ap_ht(struct wpa
140 HT_CAP_INFO_TX_STBC |
141 HT_CAP_INFO_MAX_AMSDU_SIZE);
143 + /* check this before VHT, because setting oper chan
144 + * width and friends is the same call for HE and VHT
145 + * and checks if conf->ieee8021ax == 1 */
146 + if (mode->he_capab[wpas_mode_to_ieee80211_mode(
147 + ssid->mode)].he_supported &&
149 + conf->ieee80211ax = 1;
151 if (mode->vht_capab && ssid->vht) {
152 conf->ieee80211ac = 1;
153 conf->vht_capab |= mode->vht_capab;
154 wpas_conf_ap_vht(wpa_s, ssid, conf, mode);
157 - if (mode->he_capab[wpas_mode_to_ieee80211_mode(
158 - ssid->mode)].he_supported &&
160 - conf->ieee80211ax = 1;
164 --- a/wpa_supplicant/mesh.c
165 +++ b/wpa_supplicant/mesh.c
166 @@ -333,30 +333,6 @@ static int wpa_supplicant_mesh_init(stru
171 - conf->secondary_channel = ssid->ht40;
172 - if (conf->hw_mode == HOSTAPD_MODE_IEEE80211A && ssid->vht) {
173 - if (ssid->max_oper_chwidth != DEFAULT_MAX_OPER_CHWIDTH)
174 - conf->vht_oper_chwidth = ssid->max_oper_chwidth;
175 - switch (conf->vht_oper_chwidth) {
176 - case CHANWIDTH_80MHZ:
177 - case CHANWIDTH_80P80MHZ:
178 - ieee80211_freq_to_chan(
180 - &conf->vht_oper_centr_freq_seg0_idx);
181 - conf->vht_oper_centr_freq_seg0_idx += ssid->ht40 * 2;
183 - case CHANWIDTH_160MHZ:
184 - ieee80211_freq_to_chan(
186 - &conf->vht_oper_centr_freq_seg0_idx);
187 - conf->vht_oper_centr_freq_seg0_idx += ssid->ht40 * 2;
188 - conf->vht_oper_centr_freq_seg0_idx += 40 / 5;
191 - ieee80211_freq_to_chan(ssid->vht_center_freq2,
192 - &conf->vht_oper_centr_freq_seg1_idx);
195 if (ssid->mesh_basic_rates == NULL) {