HE: Add helpers for getting the channel width parameters

Signed-off-by: Shashidhar Lakkavalli <slakkavalli@datto.com>
Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin 2019-05-20 09:55:07 +02:00 committed by Jouni Malinen
parent 39b9d059cd
commit c6b7ac077f
9 changed files with 181 additions and 104 deletions

View file

@ -595,7 +595,7 @@ acs_find_ideal_chan(struct hostapd_iface *iface)
n_chans = 2; n_chans = 2;
if (iface->conf->ieee80211ac) { if (iface->conf->ieee80211ac) {
switch (iface->conf->vht_oper_chwidth) { switch (hostapd_get_oper_chwidth(iface->conf)) {
case CHANWIDTH_80MHZ: case CHANWIDTH_80MHZ:
n_chans = 4; n_chans = 4;
break; break;
@ -648,7 +648,7 @@ acs_find_ideal_chan(struct hostapd_iface *iface)
if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211A && if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211A &&
iface->conf->ieee80211ac) { iface->conf->ieee80211ac) {
if (iface->conf->vht_oper_chwidth == if (hostapd_get_oper_chwidth(iface->conf) ==
CHANWIDTH_80MHZ && CHANWIDTH_80MHZ &&
!acs_usable_vht80_chan(chan)) { !acs_usable_vht80_chan(chan)) {
wpa_printf(MSG_DEBUG, wpa_printf(MSG_DEBUG,
@ -657,7 +657,7 @@ acs_find_ideal_chan(struct hostapd_iface *iface)
continue; continue;
} }
if (iface->conf->vht_oper_chwidth == if (hostapd_get_oper_chwidth(iface->conf) ==
CHANWIDTH_160MHZ && CHANWIDTH_160MHZ &&
!acs_usable_vht160_chan(chan)) { !acs_usable_vht160_chan(chan)) {
wpa_printf(MSG_DEBUG, wpa_printf(MSG_DEBUG,
@ -789,7 +789,7 @@ static void acs_adjust_center_freq(struct hostapd_iface *iface)
wpa_printf(MSG_DEBUG, "ACS: Adjusting VHT center frequency"); wpa_printf(MSG_DEBUG, "ACS: Adjusting VHT center frequency");
switch (iface->conf->vht_oper_chwidth) { switch (hostapd_get_oper_chwidth(iface->conf)) {
case CHANWIDTH_USE_HT: case CHANWIDTH_USE_HT:
offset = 2 * iface->conf->secondary_channel; offset = 2 * iface->conf->secondary_channel;
break; break;
@ -807,8 +807,8 @@ static void acs_adjust_center_freq(struct hostapd_iface *iface)
return; return;
} }
iface->conf->vht_oper_centr_freq_seg0_idx = hostapd_set_oper_centr_freq_seg0_idx(iface->conf,
iface->conf->channel + offset; iface->conf->channel + offset);
} }

View file

@ -911,6 +911,68 @@ struct hostapd_config {
}; };
static inline u8 hostapd_get_oper_chwidth(struct hostapd_config *conf)
{
#ifdef CONFIG_IEEE80211AX
if (conf->ieee80211ax)
return conf->he_oper_chwidth;
#endif /* CONFIG_IEEE80211AX */
return conf->vht_oper_chwidth;
}
static inline void
hostapd_set_oper_chwidth(struct hostapd_config *conf, u8 oper_chwidth)
{
#ifdef CONFIG_IEEE80211AX
if (conf->ieee80211ax)
conf->he_oper_chwidth = oper_chwidth;
#endif /* CONFIG_IEEE80211AX */
conf->vht_oper_chwidth = oper_chwidth;
}
static inline u8
hostapd_get_oper_centr_freq_seg0_idx(struct hostapd_config *conf)
{
#ifdef CONFIG_IEEE80211AX
if (conf->ieee80211ax)
return conf->he_oper_centr_freq_seg0_idx;
#endif /* CONFIG_IEEE80211AX */
return conf->vht_oper_centr_freq_seg0_idx;
}
static inline void
hostapd_set_oper_centr_freq_seg0_idx(struct hostapd_config *conf,
u8 oper_centr_freq_seg0_idx)
{
#ifdef CONFIG_IEEE80211AX
if (conf->ieee80211ax)
conf->he_oper_centr_freq_seg0_idx = oper_centr_freq_seg0_idx;
#endif /* CONFIG_IEEE80211AX */
conf->vht_oper_centr_freq_seg0_idx = oper_centr_freq_seg0_idx;
}
static inline u8
hostapd_get_oper_centr_freq_seg1_idx(struct hostapd_config *conf)
{
#ifdef CONFIG_IEEE80211AX
if (conf->ieee80211ax)
return conf->he_oper_centr_freq_seg1_idx;
#endif /* CONFIG_IEEE80211AX */
return conf->vht_oper_centr_freq_seg1_idx;
}
static inline void
hostapd_set_oper_centr_freq_seg1_idx(struct hostapd_config *conf,
u8 oper_centr_freq_seg1_idx)
{
#ifdef CONFIG_IEEE80211AX
if (conf->ieee80211ax)
conf->he_oper_centr_freq_seg1_idx = oper_centr_freq_seg1_idx;
#endif /* CONFIG_IEEE80211AX */
conf->vht_oper_centr_freq_seg1_idx = oper_centr_freq_seg1_idx;
}
int hostapd_mac_comp(const void *a, const void *b); int hostapd_mac_comp(const void *a, const void *b);
struct hostapd_config * hostapd_config_defaults(void); struct hostapd_config * hostapd_config_defaults(void);
void hostapd_config_defaults_bss(struct hostapd_bss_config *bss); void hostapd_config_defaults_bss(struct hostapd_bss_config *bss);

View file

@ -929,15 +929,15 @@ int hostapd_drv_do_acs(struct hostapd_data *hapd)
if (hapd->iface->conf->ieee80211n && params.ht40_enabled) if (hapd->iface->conf->ieee80211n && params.ht40_enabled)
params.ch_width = 40; params.ch_width = 40;
/* Note: VHT20 is defined by combination of ht_capab & vht_oper_chwidth /* Note: VHT20 is defined by combination of ht_capab & oper_chwidth
*/ */
if (hapd->iface->conf->ieee80211ac && params.ht40_enabled) { if (hapd->iface->conf->ieee80211ac && params.ht40_enabled) {
if (hapd->iface->conf->vht_oper_chwidth == CHANWIDTH_80MHZ) u8 oper_chwidth = hostapd_get_oper_chwidth(hapd->iface->conf);
if (oper_chwidth == CHANWIDTH_80MHZ)
params.ch_width = 80; params.ch_width = 80;
else if (hapd->iface->conf->vht_oper_chwidth == else if (oper_chwidth == CHANWIDTH_160MHZ ||
CHANWIDTH_160MHZ || oper_chwidth == CHANWIDTH_80P80MHZ)
hapd->iface->conf->vht_oper_chwidth ==
CHANWIDTH_80P80MHZ)
params.ch_width = 160; params.ch_width = 160;
} }

View file

@ -347,7 +347,7 @@ static u8 * hostapd_eid_supported_op_classes(struct hostapd_data *hapd, u8 *eid)
if (ieee80211_freq_to_channel_ext(hapd->iface->freq, if (ieee80211_freq_to_channel_ext(hapd->iface->freq,
hapd->iconf->secondary_channel, hapd->iconf->secondary_channel,
hapd->iconf->vht_oper_chwidth, hostapd_get_oper_chwidth(hapd->iconf),
&op_class, &channel) == &op_class, &channel) ==
NUM_HOSTAPD_MODES) NUM_HOSTAPD_MODES)
return eid; return eid;
@ -1426,9 +1426,9 @@ int ieee802_11_set_beacon(struct hostapd_data *hapd)
iconf->channel, iconf->ieee80211n, iconf->channel, iconf->ieee80211n,
iconf->ieee80211ac, iconf->ieee80211ac,
iconf->secondary_channel, iconf->secondary_channel,
iconf->vht_oper_chwidth, hostapd_get_oper_chwidth(iconf),
iconf->vht_oper_centr_freq_seg0_idx, hostapd_get_oper_centr_freq_seg0_idx(iconf),
iconf->vht_oper_centr_freq_seg1_idx, hostapd_get_oper_centr_freq_seg1_idx(iconf),
iface->current_mode->vht_capab) == 0) iface->current_mode->vht_capab) == 0)
params.freq = &freq; params.freq = &freq;

View file

@ -29,7 +29,7 @@ static int dfs_get_used_n_chans(struct hostapd_iface *iface, int *seg1)
n_chans = 2; n_chans = 2;
if (iface->conf->ieee80211ac) { if (iface->conf->ieee80211ac) {
switch (iface->conf->vht_oper_chwidth) { switch (hostapd_get_oper_chwidth(iface->conf)) {
case CHANWIDTH_USE_HT: case CHANWIDTH_USE_HT:
break; break;
case CHANWIDTH_80MHZ: case CHANWIDTH_80MHZ:
@ -188,8 +188,8 @@ static int is_in_chanlist(struct hostapd_iface *iface,
* The function assumes HT40+ operation. * The function assumes HT40+ operation.
* Make sure to adjust the following variables after calling this: * Make sure to adjust the following variables after calling this:
* - hapd->secondary_channel * - hapd->secondary_channel
* - hapd->vht_oper_centr_freq_seg0_idx * - hapd->vht/he_oper_centr_freq_seg0_idx
* - hapd->vht_oper_centr_freq_seg1_idx * - hapd->vht/he_oper_centr_freq_seg1_idx
*/ */
static int dfs_find_channel(struct hostapd_iface *iface, static int dfs_find_channel(struct hostapd_iface *iface,
struct hostapd_channel_data **ret_chan, struct hostapd_channel_data **ret_chan,
@ -246,7 +246,7 @@ static void dfs_adjust_center_freq(struct hostapd_iface *iface,
*oper_centr_freq_seg1_idx = 0; *oper_centr_freq_seg1_idx = 0;
switch (iface->conf->vht_oper_chwidth) { switch (hostapd_get_oper_chwidth(iface->conf)) {
case CHANWIDTH_USE_HT: case CHANWIDTH_USE_HT:
if (secondary_channel == 1) if (secondary_channel == 1)
*oper_centr_freq_seg0_idx = chan->chan + 2; *oper_centr_freq_seg0_idx = chan->chan + 2;
@ -290,22 +290,22 @@ static int dfs_get_start_chan_idx(struct hostapd_iface *iface, int *seg1_start)
/* VHT */ /* VHT */
if (iface->conf->ieee80211ac) { if (iface->conf->ieee80211ac) {
switch (iface->conf->vht_oper_chwidth) { switch (hostapd_get_oper_chwidth(iface->conf)) {
case CHANWIDTH_USE_HT: case CHANWIDTH_USE_HT:
break; break;
case CHANWIDTH_80MHZ: case CHANWIDTH_80MHZ:
channel_no = channel_no = hostapd_get_oper_centr_freq_seg0_idx(
iface->conf->vht_oper_centr_freq_seg0_idx - 6; iface->conf) - 6;
break; break;
case CHANWIDTH_160MHZ: case CHANWIDTH_160MHZ:
channel_no = channel_no = hostapd_get_oper_centr_freq_seg0_idx(
iface->conf->vht_oper_centr_freq_seg0_idx - 14; iface->conf) - 14;
break; break;
case CHANWIDTH_80P80MHZ: case CHANWIDTH_80P80MHZ:
channel_no = channel_no = hostapd_get_oper_centr_freq_seg0_idx(
iface->conf->vht_oper_centr_freq_seg0_idx - 6; iface->conf) - 6;
chan_seg1 = chan_seg1 = hostapd_get_oper_centr_freq_seg1_idx(
iface->conf->vht_oper_centr_freq_seg1_idx - 6; iface->conf) - 6;
break; break;
default: default:
wpa_printf(MSG_INFO, wpa_printf(MSG_INFO,
@ -348,7 +348,7 @@ static int dfs_get_start_chan_idx(struct hostapd_iface *iface, int *seg1_start)
mode->num_channels, channel_no, iface->conf->channel, mode->num_channels, channel_no, iface->conf->channel,
iface->conf->ieee80211n, iface->conf->ieee80211n,
iface->conf->secondary_channel, iface->conf->secondary_channel,
iface->conf->vht_oper_chwidth); hostapd_get_oper_chwidth(iface->conf));
for (i = 0; i < mode->num_channels; i++) { for (i = 0; i < mode->num_channels; i++) {
wpa_printf(MSG_DEBUG, "Available channel: %d", wpa_printf(MSG_DEBUG, "Available channel: %d",
@ -724,8 +724,8 @@ int hostapd_handle_dfs(struct hostapd_iface *iface)
iface->freq = channel->freq; iface->freq = channel->freq;
iface->conf->channel = channel->chan; iface->conf->channel = channel->chan;
iface->conf->secondary_channel = sec; iface->conf->secondary_channel = sec;
iface->conf->vht_oper_centr_freq_seg0_idx = cf1; hostapd_set_oper_centr_freq_seg0_idx(iface->conf, cf1);
iface->conf->vht_oper_centr_freq_seg1_idx = cf2; hostapd_set_oper_centr_freq_seg1_idx(iface->conf, cf2);
} }
} while (res); } while (res);
@ -736,20 +736,18 @@ int hostapd_handle_dfs(struct hostapd_iface *iface)
"freq=%d chan=%d sec_chan=%d, width=%d, seg0=%d, seg1=%d, cac_time=%ds", "freq=%d chan=%d sec_chan=%d, width=%d, seg0=%d, seg1=%d, cac_time=%ds",
iface->freq, iface->freq,
iface->conf->channel, iface->conf->secondary_channel, iface->conf->channel, iface->conf->secondary_channel,
iface->conf->vht_oper_chwidth, hostapd_get_oper_chwidth(iface->conf),
iface->conf->vht_oper_centr_freq_seg0_idx, hostapd_get_oper_centr_freq_seg0_idx(iface->conf),
iface->conf->vht_oper_centr_freq_seg1_idx, hostapd_get_oper_centr_freq_seg1_idx(iface->conf),
iface->dfs_cac_ms / 1000); iface->dfs_cac_ms / 1000);
res = hostapd_start_dfs_cac(iface, iface->conf->hw_mode, res = hostapd_start_dfs_cac(
iface->freq, iface, iface->conf->hw_mode, iface->freq, iface->conf->channel,
iface->conf->channel, iface->conf->ieee80211n, iface->conf->ieee80211ac,
iface->conf->ieee80211n, iface->conf->secondary_channel,
iface->conf->ieee80211ac, hostapd_get_oper_chwidth(iface->conf),
iface->conf->secondary_channel, hostapd_get_oper_centr_freq_seg0_idx(iface->conf),
iface->conf->vht_oper_chwidth, hostapd_get_oper_centr_freq_seg1_idx(iface->conf));
iface->conf->vht_oper_centr_freq_seg0_idx,
iface->conf->vht_oper_centr_freq_seg1_idx);
if (res) { if (res) {
wpa_printf(MSG_ERROR, "DFS start_dfs_cac() failed, %d", res); wpa_printf(MSG_ERROR, "DFS start_dfs_cac() failed, %d", res);
@ -868,8 +866,10 @@ static int hostapd_dfs_start_channel_switch_cac(struct hostapd_iface *iface)
iface->freq = channel->freq; iface->freq = channel->freq;
iface->conf->channel = channel->chan; iface->conf->channel = channel->chan;
iface->conf->secondary_channel = secondary_channel; iface->conf->secondary_channel = secondary_channel;
iface->conf->vht_oper_centr_freq_seg0_idx = oper_centr_freq_seg0_idx; hostapd_set_oper_centr_freq_seg0_idx(iface->conf,
iface->conf->vht_oper_centr_freq_seg1_idx = oper_centr_freq_seg1_idx; oper_centr_freq_seg0_idx);
hostapd_set_oper_centr_freq_seg1_idx(iface->conf,
oper_centr_freq_seg1_idx);
err = 0; err = 0;
hostapd_setup_interface_complete(iface, err); hostapd_setup_interface_complete(iface, err);
@ -934,10 +934,10 @@ static int hostapd_dfs_start_channel_switch(struct hostapd_iface *iface)
iface->freq = channel->freq; iface->freq = channel->freq;
iface->conf->channel = channel->chan; iface->conf->channel = channel->chan;
iface->conf->secondary_channel = secondary_channel; iface->conf->secondary_channel = secondary_channel;
iface->conf->vht_oper_centr_freq_seg0_idx = hostapd_set_oper_centr_freq_seg0_idx(iface->conf,
oper_centr_freq_seg0_idx; oper_centr_freq_seg0_idx);
iface->conf->vht_oper_centr_freq_seg1_idx = hostapd_set_oper_centr_freq_seg1_idx(iface->conf,
oper_centr_freq_seg1_idx; oper_centr_freq_seg1_idx);
hostapd_disable_iface(iface); hostapd_disable_iface(iface);
hostapd_enable_iface(iface); hostapd_enable_iface(iface);
@ -961,7 +961,7 @@ static int hostapd_dfs_start_channel_switch(struct hostapd_iface *iface)
iface->conf->ieee80211n, iface->conf->ieee80211n,
iface->conf->ieee80211ac, iface->conf->ieee80211ac,
secondary_channel, secondary_channel,
iface->conf->vht_oper_chwidth, hostapd_get_oper_chwidth(iface->conf),
oper_centr_freq_seg0_idx, oper_centr_freq_seg0_idx,
oper_centr_freq_seg1_idx, oper_centr_freq_seg1_idx,
iface->current_mode->vht_capab); iface->current_mode->vht_capab);
@ -984,10 +984,10 @@ static int hostapd_dfs_start_channel_switch(struct hostapd_iface *iface)
iface->freq = channel->freq; iface->freq = channel->freq;
iface->conf->channel = channel->chan; iface->conf->channel = channel->chan;
iface->conf->secondary_channel = secondary_channel; iface->conf->secondary_channel = secondary_channel;
iface->conf->vht_oper_centr_freq_seg0_idx = hostapd_set_oper_centr_freq_seg0_idx(iface->conf,
oper_centr_freq_seg0_idx; oper_centr_freq_seg0_idx);
iface->conf->vht_oper_centr_freq_seg1_idx = hostapd_set_oper_centr_freq_seg1_idx(iface->conf,
oper_centr_freq_seg1_idx; oper_centr_freq_seg1_idx);
hostapd_disable_iface(iface); hostapd_disable_iface(iface);
hostapd_enable_iface(iface); hostapd_enable_iface(iface);

View file

@ -853,9 +853,9 @@ void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht,
hapd->iconf->ch_switch_vht_config = 0; hapd->iconf->ch_switch_vht_config = 0;
hapd->iconf->secondary_channel = offset; hapd->iconf->secondary_channel = offset;
hapd->iconf->vht_oper_chwidth = chwidth; hostapd_set_oper_chwidth(hapd->iconf, chwidth);
hapd->iconf->vht_oper_centr_freq_seg0_idx = seg0_idx; hostapd_set_oper_centr_freq_seg0_idx(hapd->iconf, seg0_idx);
hapd->iconf->vht_oper_centr_freq_seg1_idx = seg1_idx; hostapd_set_oper_centr_freq_seg1_idx(hapd->iconf, seg1_idx);
is_dfs = ieee80211_is_dfs(freq, hapd->iface->hw_features, is_dfs = ieee80211_is_dfs(freq, hapd->iface->hw_features,
hapd->iface->num_hw_features); hapd->iface->num_hw_features);
@ -962,26 +962,29 @@ void hostapd_acs_channel_selected(struct hostapd_data *hapd,
if (hapd->iface->conf->ieee80211ac) { if (hapd->iface->conf->ieee80211ac) {
/* set defaults for backwards compatibility */ /* set defaults for backwards compatibility */
hapd->iconf->vht_oper_centr_freq_seg1_idx = 0; hostapd_set_oper_centr_freq_seg1_idx(hapd->iconf, 0);
hapd->iconf->vht_oper_centr_freq_seg0_idx = 0; hostapd_set_oper_centr_freq_seg0_idx(hapd->iconf, 0);
hapd->iconf->vht_oper_chwidth = CHANWIDTH_USE_HT; hostapd_set_oper_chwidth(hapd->iconf, CHANWIDTH_USE_HT);
if (acs_res->ch_width == 80) { if (acs_res->ch_width == 80) {
hapd->iconf->vht_oper_centr_freq_seg0_idx = hostapd_set_oper_centr_freq_seg0_idx(
acs_res->vht_seg0_center_ch; hapd->iconf, acs_res->vht_seg0_center_ch);
hapd->iconf->vht_oper_chwidth = CHANWIDTH_80MHZ; hostapd_set_oper_chwidth(hapd->iconf, CHANWIDTH_80MHZ);
} else if (acs_res->ch_width == 160) { } else if (acs_res->ch_width == 160) {
if (acs_res->vht_seg1_center_ch == 0) { if (acs_res->vht_seg1_center_ch == 0) {
hapd->iconf->vht_oper_centr_freq_seg0_idx = hostapd_set_oper_centr_freq_seg0_idx(
acs_res->vht_seg0_center_ch; hapd->iconf,
hapd->iconf->vht_oper_chwidth = acs_res->vht_seg0_center_ch);
CHANWIDTH_160MHZ; hostapd_set_oper_chwidth(hapd->iconf,
CHANWIDTH_160MHZ);
} else { } else {
hapd->iconf->vht_oper_centr_freq_seg0_idx = hostapd_set_oper_centr_freq_seg0_idx(
acs_res->vht_seg0_center_ch; hapd->iconf,
hapd->iconf->vht_oper_centr_freq_seg1_idx = acs_res->vht_seg0_center_ch);
acs_res->vht_seg1_center_ch; hostapd_set_oper_centr_freq_seg1_idx(
hapd->iconf->vht_oper_chwidth = hapd->iconf,
CHANWIDTH_80P80MHZ; acs_res->vht_seg1_center_ch);
hostapd_set_oper_chwidth(hapd->iconf,
CHANWIDTH_80P80MHZ);
} }
} }
} }

View file

@ -261,11 +261,14 @@ int hostapd_reload_config(struct hostapd_iface *iface)
hapd->iconf->ieee80211ac = oldconf->ieee80211ac; hapd->iconf->ieee80211ac = oldconf->ieee80211ac;
hapd->iconf->ht_capab = oldconf->ht_capab; hapd->iconf->ht_capab = oldconf->ht_capab;
hapd->iconf->vht_capab = oldconf->vht_capab; hapd->iconf->vht_capab = oldconf->vht_capab;
hapd->iconf->vht_oper_chwidth = oldconf->vht_oper_chwidth; hostapd_set_oper_chwidth(hapd->iconf,
hapd->iconf->vht_oper_centr_freq_seg0_idx = hostapd_get_oper_chwidth(oldconf));
oldconf->vht_oper_centr_freq_seg0_idx; hostapd_set_oper_centr_freq_seg0_idx(
hapd->iconf->vht_oper_centr_freq_seg1_idx = hapd->iconf,
oldconf->vht_oper_centr_freq_seg1_idx; hostapd_get_oper_centr_freq_seg0_idx(oldconf));
hostapd_set_oper_centr_freq_seg1_idx(
hapd->iconf,
hostapd_get_oper_centr_freq_seg1_idx(oldconf));
hapd->conf = newconf->bss[j]; hapd->conf = newconf->bss[j];
hostapd_reload_bss(hapd); hostapd_reload_bss(hapd);
} }
@ -1866,9 +1869,11 @@ static int hostapd_setup_interface_complete_sync(struct hostapd_iface *iface,
hapd->iconf->ieee80211n, hapd->iconf->ieee80211n,
hapd->iconf->ieee80211ac, hapd->iconf->ieee80211ac,
hapd->iconf->secondary_channel, hapd->iconf->secondary_channel,
hapd->iconf->vht_oper_chwidth, hostapd_get_oper_chwidth(hapd->iconf),
hapd->iconf->vht_oper_centr_freq_seg0_idx, hostapd_get_oper_centr_freq_seg0_idx(
hapd->iconf->vht_oper_centr_freq_seg1_idx)) { hapd->iconf),
hostapd_get_oper_centr_freq_seg1_idx(
hapd->iconf))) {
wpa_printf(MSG_ERROR, "Could not set channel for " wpa_printf(MSG_ERROR, "Could not set channel for "
"kernel driver"); "kernel driver");
goto fail; goto fail;
@ -3200,6 +3205,7 @@ static int hostapd_change_config_freq(struct hostapd_data *hapd,
struct hostapd_freq_params *old_params) struct hostapd_freq_params *old_params)
{ {
int channel; int channel;
u8 seg0, seg1;
if (!params->channel) { if (!params->channel) {
/* check if the new channel is supported by hw */ /* check if the new channel is supported by hw */
@ -3217,9 +3223,9 @@ static int hostapd_change_config_freq(struct hostapd_data *hapd,
conf->channel, conf->ieee80211n, conf->channel, conf->ieee80211n,
conf->ieee80211ac, conf->ieee80211ac,
conf->secondary_channel, conf->secondary_channel,
conf->vht_oper_chwidth, hostapd_get_oper_chwidth(conf),
conf->vht_oper_centr_freq_seg0_idx, hostapd_get_oper_centr_freq_seg0_idx(conf),
conf->vht_oper_centr_freq_seg1_idx, hostapd_get_oper_centr_freq_seg1_idx(conf),
conf->vht_capab)) conf->vht_capab))
return -1; return -1;
@ -3227,16 +3233,16 @@ static int hostapd_change_config_freq(struct hostapd_data *hapd,
case 0: case 0:
case 20: case 20:
case 40: case 40:
conf->vht_oper_chwidth = CHANWIDTH_USE_HT; hostapd_set_oper_chwidth(conf, CHANWIDTH_USE_HT);
break; break;
case 80: case 80:
if (params->center_freq2) if (params->center_freq2)
conf->vht_oper_chwidth = CHANWIDTH_80P80MHZ; hostapd_set_oper_chwidth(conf, CHANWIDTH_80P80MHZ);
else else
conf->vht_oper_chwidth = CHANWIDTH_80MHZ; hostapd_set_oper_chwidth(conf, CHANWIDTH_80MHZ);
break; break;
case 160: case 160:
conf->vht_oper_chwidth = CHANWIDTH_160MHZ; hostapd_set_oper_chwidth(conf, CHANWIDTH_160MHZ);
break; break;
default: default:
return -1; return -1;
@ -3246,9 +3252,11 @@ static int hostapd_change_config_freq(struct hostapd_data *hapd,
conf->ieee80211n = params->ht_enabled; conf->ieee80211n = params->ht_enabled;
conf->secondary_channel = params->sec_channel_offset; conf->secondary_channel = params->sec_channel_offset;
ieee80211_freq_to_chan(params->center_freq1, ieee80211_freq_to_chan(params->center_freq1,
&conf->vht_oper_centr_freq_seg0_idx); &seg0);
ieee80211_freq_to_chan(params->center_freq2, ieee80211_freq_to_chan(params->center_freq2,
&conf->vht_oper_centr_freq_seg1_idx); &seg1);
hostapd_set_oper_centr_freq_seg0_idx(conf, seg0);
hostapd_set_oper_centr_freq_seg1_idx(conf, seg1);
/* TODO: maybe call here hostapd_config_check here? */ /* TODO: maybe call here hostapd_config_check here? */
@ -3426,9 +3434,9 @@ hostapd_switch_channel_fallback(struct hostapd_iface *iface,
iface->freq = freq_params->freq; iface->freq = freq_params->freq;
iface->conf->channel = freq_params->channel; iface->conf->channel = freq_params->channel;
iface->conf->secondary_channel = freq_params->sec_channel_offset; iface->conf->secondary_channel = freq_params->sec_channel_offset;
iface->conf->vht_oper_centr_freq_seg0_idx = seg0_idx; hostapd_set_oper_centr_freq_seg0_idx(iface->conf, seg0_idx);
iface->conf->vht_oper_centr_freq_seg1_idx = seg1_idx; hostapd_set_oper_centr_freq_seg1_idx(iface->conf, seg1_idx);
iface->conf->vht_oper_chwidth = bw; hostapd_set_oper_chwidth(iface->conf, bw);
iface->conf->ieee80211n = freq_params->ht_enabled; iface->conf->ieee80211n = freq_params->ht_enabled;
iface->conf->ieee80211ac = freq_params->vht_enabled; iface->conf->ieee80211ac = freq_params->vht_enabled;

View file

@ -329,9 +329,9 @@ static void ieee80211n_check_scan(struct hostapd_iface *iface)
res = ieee80211n_allowed_ht40_channel_pair(iface); res = ieee80211n_allowed_ht40_channel_pair(iface);
if (!res) { if (!res) {
iface->conf->secondary_channel = 0; iface->conf->secondary_channel = 0;
iface->conf->vht_oper_centr_freq_seg0_idx = 0; hostapd_set_oper_centr_freq_seg0_idx(iface->conf, 0);
iface->conf->vht_oper_centr_freq_seg1_idx = 0; hostapd_set_oper_centr_freq_seg1_idx(iface->conf, 0);
iface->conf->vht_oper_chwidth = CHANWIDTH_USE_HT; hostapd_set_oper_chwidth(iface->conf, CHANWIDTH_USE_HT);
res = 1; res = 1;
wpa_printf(MSG_INFO, "Fallback to 20 MHz"); wpa_printf(MSG_INFO, "Fallback to 20 MHz");
} }

View file

@ -141,17 +141,19 @@ void hostapd_free_neighbor_db(struct hostapd_data *hapd)
static enum nr_chan_width hostapd_get_nr_chan_width(struct hostapd_data *hapd, static enum nr_chan_width hostapd_get_nr_chan_width(struct hostapd_data *hapd,
int ht, int vht) int ht, int vht)
{ {
u8 oper_chwidth = hostapd_get_oper_chwidth(hapd->iconf);
if (!ht && !vht) if (!ht && !vht)
return NR_CHAN_WIDTH_20; return NR_CHAN_WIDTH_20;
if (!hapd->iconf->secondary_channel) if (!hapd->iconf->secondary_channel)
return NR_CHAN_WIDTH_20; return NR_CHAN_WIDTH_20;
if (!vht || hapd->iconf->vht_oper_chwidth == CHANWIDTH_USE_HT) if (!vht || oper_chwidth == CHANWIDTH_USE_HT)
return NR_CHAN_WIDTH_40; return NR_CHAN_WIDTH_40;
if (hapd->iconf->vht_oper_chwidth == CHANWIDTH_80MHZ) if (oper_chwidth == CHANWIDTH_80MHZ)
return NR_CHAN_WIDTH_80; return NR_CHAN_WIDTH_80;
if (hapd->iconf->vht_oper_chwidth == CHANWIDTH_160MHZ) if (oper_chwidth == CHANWIDTH_160MHZ)
return NR_CHAN_WIDTH_160; return NR_CHAN_WIDTH_160;
if (hapd->iconf->vht_oper_chwidth == CHANWIDTH_80P80MHZ) if (oper_chwidth == CHANWIDTH_80P80MHZ)
return NR_CHAN_WIDTH_80P80; return NR_CHAN_WIDTH_80P80;
return NR_CHAN_WIDTH_20; return NR_CHAN_WIDTH_20;
} }
@ -205,16 +207,18 @@ void hostapd_neighbor_set_own_report(struct hostapd_data *hapd)
if (ieee80211_freq_to_channel_ext(hapd->iface->freq, if (ieee80211_freq_to_channel_ext(hapd->iface->freq,
hapd->iconf->secondary_channel, hapd->iconf->secondary_channel,
hapd->iconf->vht_oper_chwidth, hostapd_get_oper_chwidth(hapd->iconf),
&op_class, &channel) == &op_class, &channel) ==
NUM_HOSTAPD_MODES) NUM_HOSTAPD_MODES)
return; return;
width = hostapd_get_nr_chan_width(hapd, ht, vht); width = hostapd_get_nr_chan_width(hapd, ht, vht);
if (vht) { if (vht) {
center_freq1_idx = hapd->iconf->vht_oper_centr_freq_seg0_idx; center_freq1_idx = hostapd_get_oper_centr_freq_seg0_idx(
hapd->iconf);
if (width == NR_CHAN_WIDTH_80P80) if (width == NR_CHAN_WIDTH_80P80)
center_freq2_idx = center_freq2_idx =
hapd->iconf->vht_oper_centr_freq_seg1_idx; hostapd_get_oper_centr_freq_seg1_idx(
hapd->iconf);
} else if (ht) { } else if (ht) {
ieee80211_freq_to_chan(hapd->iface->freq + ieee80211_freq_to_chan(hapd->iface->freq +
10 * hapd->iconf->secondary_channel, 10 * hapd->iconf->secondary_channel,