From: Felix Fietkau Date: Fri, 10 Jul 2026 10:23:19 +0000 (+0200) Subject: hostapd: ucode: fix CSA bandwidth for 320 MHz and 80+80 channels X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b92df1e8da528eda036c15237ac1ce047d4bbcea;p=thirdparty%2Fopenwrt.git hostapd: ucode: fix CSA bandwidth for 320 MHz and 80+80 channels switch_channel computed the CSA bandwidth as 40 << oper_chwidth, which mismaps oper_chwidth 3 (80+80, must be 80 MHz plus center_freq2) to 320 and 9 (320 MHz) to 20480. Map the operating channel width to the actual MHz bandwidth explicitly. Signed-off-by: Felix Fietkau --- diff --git a/package/network/services/hostapd/src/src/ap/ucode.c b/package/network/services/hostapd/src/src/ap/ucode.c index e1a365b7a62..4db5eddf7c5 100644 --- a/package/network/services/hostapd/src/src/ap/ucode.c +++ b/package/network/services/hostapd/src/src/ap/ucode.c @@ -739,10 +739,22 @@ uc_hostapd_iface_switch_channel(uc_vm_t *vm, size_t nargs) intval = ucv_int64_get(ucv_object_get(info, "oper_chwidth", NULL)); if (errno) intval = hostapd_get_oper_chwidth(conf); - if (intval) - csa.freq_params.bandwidth = 40 << intval; - else + switch (intval) { + case CONF_OPER_CHWIDTH_80MHZ: + case CONF_OPER_CHWIDTH_80P80MHZ: + /* 80+80 uses an 80 MHz primary segment plus center_freq2 */ + csa.freq_params.bandwidth = 80; + break; + case CONF_OPER_CHWIDTH_160MHZ: + csa.freq_params.bandwidth = 160; + break; + case CONF_OPER_CHWIDTH_320MHZ: + csa.freq_params.bandwidth = 320; + break; + default: csa.freq_params.bandwidth = csa.freq_params.sec_channel_offset ? 40 : 20; + break; + } if ((intval = ucv_int64_get(ucv_object_get(info, "frequency", NULL))) && !errno) csa.freq_params.freq = intval;