From 15742566fd7c25ed5b2c43622a9a03670af80aac Mon Sep 17 00:00:00 2001 From: Pradeep Kumar Chitrapu Date: Thu, 22 Apr 2021 11:30:09 -0700 Subject: [PATCH] 6 GHz: Fix operating class in Supported Operating Classes element Previously, the secondary channel was set only in presence of HT capabilities based on HT40+ or HT40-. As HT capabilities and secondary_channel are not present for the 6 GHz bamd, this causes incorrect operating class indication in the Supported Operating Classes element. Fix this by assigning the secondary channel for bandwidths greater than 20 MHz in the 6 GHz band. Signed-off-by: Pradeep Kumar Chitrapu --- src/ap/hostapd.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c index e9aae6dcf..913a8e29e 100644 --- a/src/ap/hostapd.c +++ b/src/ap/hostapd.c @@ -1674,6 +1674,26 @@ static int configured_fixed_chan_to_freq(struct hostapd_iface *iface) } +static void hostapd_set_6ghz_sec_chan(struct hostapd_iface *iface) +{ + int bw, seg0; + + if (!is_6ghz_op_class(iface->conf->op_class)) + return; + + seg0 = hostapd_get_oper_centr_freq_seg0_idx(iface->conf); + bw = center_idx_to_bw_6ghz(seg0); + /* Assign the secondary channel if absent in config for + * bandwidths > 20 MHz */ + if (bw > 20 && !iface->conf->secondary_channel) { + if (((iface->conf->channel - 1) / 4) % 2) + iface->conf->secondary_channel = -1; + else + iface->conf->secondary_channel = 1; + } +} + + static int setup_interface2(struct hostapd_iface *iface) { iface->wait_channel_update = 0; @@ -1693,6 +1713,7 @@ static int setup_interface2(struct hostapd_iface *iface) ch_width = op_class_to_ch_width(iface->conf->op_class); hostapd_set_oper_chwidth(iface->conf, ch_width); + hostapd_set_6ghz_sec_chan(iface); } ret = hostapd_select_hw_mode(iface);