diff --git a/core/sap/src/sap_api_link_cntl.c b/core/sap/src/sap_api_link_cntl.c index bf694c2ed6db..2447879bcab7 100644 --- a/core/sap/src/sap_api_link_cntl.c +++ b/core/sap/src/sap_api_link_cntl.c @@ -325,14 +325,9 @@ wlansap_pre_start_bss_acs_scan_callback(tHalHandle hal_handle, void *pcontext, QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR, FL("CSR scan_status = eCSR_SCAN_ABORT/FAILURE (%d), choose default channel"), scan_status); -#ifdef SOFTAP_CHANNEL_RANGE - if (sap_ctx->acs_cfg->hw_mode == eCSR_DOT11_MODE_11a) - sap_ctx->channel = SAP_DEFAULT_5GHZ_CHANNEL; - else - sap_ctx->channel = SAP_DEFAULT_24GHZ_CHANNEL; -#else - sap_ctx->channel = SAP_DEFAULT_24GHZ_CHANNEL; -#endif + sap_ctx->channel = + sap_select_default_oper_chan(hal_handle, + sap_ctx->acs_cfg->hw_mode); sap_ctx->sap_state = eSAP_ACS_CHANNEL_SELECTED; sap_ctx->sap_status = eSAP_STATUS_SUCCESS; goto close_session; @@ -396,7 +391,9 @@ wlansap_pre_start_bss_acs_scan_callback(tHalHandle hal_handle, void *pcontext, goto close_session; } else { #else - sap_ctx->channel = SAP_DEFAULT_24GHZ_CHANNEL; + sap_ctx->channel = + sap_select_default_oper_chan(hal_handle, + sap_ctx->acs_cfg->hw_mode); } else { #endif /* Valid Channel Found from scan results. */ diff --git a/core/sap/src/sap_fsm.c b/core/sap/src/sap_fsm.c index 32fca747bc2e..8eef7af80814 100644 --- a/core/sap/src/sap_fsm.c +++ b/core/sap/src/sap_fsm.c @@ -2089,6 +2089,28 @@ sap_dfs_is_channel_in_nol_list(ptSapContext sap_context, return false; } +/** + * sap_select_default_oper_chan() - Select operating channel based on acs hwmode + * @hal: pointer to HAL + * @acs_hwmode: HW mode of ACS + * + * Return: selected operating channel + */ +uint8_t sap_select_default_oper_chan(tHalHandle hal, uint32_t acs_hwmode) +{ + uint8_t channel; + + if ((acs_hwmode == QCA_ACS_MODE_IEEE80211A) || + (acs_hwmode == QCA_ACS_MODE_IEEE80211AD)) + channel = SAP_DEFAULT_5GHZ_CHANNEL; + else + channel = SAP_DEFAULT_24GHZ_CHANNEL; + + QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO, + FL("channel selected to start bss %d"), channel); + return channel; +} + /** * sap_goto_channel_sel - Function for initiating scan request for SME * @sap_context: Sap Context value. @@ -2297,8 +2319,9 @@ QDF_STATUS sap_goto_channel_sel(ptSapContext sap_context, QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, FL("SAP Configuring default channel, Ch=%d"), sap_context->channel); - /* In case of error, switch to default channel */ - sap_context->channel = SAP_DEFAULT_24GHZ_CHANNEL; + sap_context->channel = + sap_select_default_oper_chan(h_hal, + sap_context->acs_cfg->hw_mode); #ifdef SOFTAP_CHANNEL_RANGE if (sap_context->channelList != NULL) { diff --git a/core/sap/src/sap_internal.h b/core/sap/src/sap_internal.h index e8e50f6350ed..dc52e2fe304c 100644 --- a/core/sap/src/sap_internal.h +++ b/core/sap/src/sap_internal.h @@ -434,4 +434,5 @@ QDF_STATUS sap_close_session(tHalHandle hHal, #ifdef __cplusplus } #endif +uint8_t sap_select_default_oper_chan(tHalHandle hal, uint32_t acs_hwmode); #endif