From bd267ee2e6c1ce5165bf8be9411b398709f83a8f Mon Sep 17 00:00:00 2001 From: Aditya Kumar Singh Date: Fri, 19 Nov 2021 19:51:04 +0530 Subject: [PATCH] hostapd: fix 6GHz chan switch issue If user doesnt provide HE parameter in the hostapd_cli chan_switch command, by default HE should be enabled for 6 GHz frequency range. This is because, 6 GHz does not support legacy mode. Similarly, if bandwidth isnt provided, 20 MHz should be taken as default bandwidth. Signed-off-by: Aditya Kumar Singh --- hostapd/ctrl_iface.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c index 664711d..3c2d51c 100644 --- a/hostapd/ctrl_iface.c +++ b/hostapd/ctrl_iface.c @@ -2530,12 +2530,24 @@ static int hostapd_ctrl_check_freq_params(struct hostapd_freq_params *params) { int idx, bw, bw_idx[] = { 20, 40, 80, 160 }; - if (is_6ghz_freq(params->freq) && params->center_freq1) { - idx = (params->center_freq1 - 5950) / 5; - bw = center_idx_to_bw_6ghz(idx); - - if (bw < 0 || (bw_idx[bw] != params->bandwidth)) - return -1; + if (is_6ghz_freq(params->freq)) { + /* Verify if HE was enabled by user or not. 6 GHz does not + * support legacy mode. Hence, enable HE if not given */ + if (!params->he_enabled) + params->he_enabled = 1; + + /* By default in 6 GHz, HE 20 mode should be selected */ + if (!params->center_freq1 && params->bandwidth == 0) { + params->center_freq1 = params->freq; + /* If bw is not given by user, by default assuming 20 */ + params->bandwidth = 20; + } else { + idx = (params->center_freq1 - 5950) / 5; + bw = center_idx_to_bw_6ghz(idx); + + if (bw < 0 || (bw_idx[bw] != params->bandwidth)) + return -1; + } } switch (params->bandwidth) { -- 2.7.4