diff --git a/core/sap/inc/sap_api.h b/core/sap/inc/sap_api.h index 1594a38fa159..6e21622755d9 100644 --- a/core/sap/inc/sap_api.h +++ b/core/sap/inc/sap_api.h @@ -632,14 +632,6 @@ typedef struct tagSapStruct { bool enable_dfs_phy_error_logs; } tSapStruct, *tpSapStruct; -#ifdef FEATURE_WLAN_CH_AVOID -/* Store channel safety information */ -typedef struct { - uint16_t channelNumber; - bool isSafe; -} sapSafeChannelType; -#endif /* FEATURE_WLAN_CH_AVOID */ - /** * struct sap_context - per-BSS Context for SAP * diff --git a/core/sap/src/sap_api_link_cntl.c b/core/sap/src/sap_api_link_cntl.c index 0456128a9a84..0a5afef3b5aa 100644 --- a/core/sap/src/sap_api_link_cntl.c +++ b/core/sap/src/sap_api_link_cntl.c @@ -232,6 +232,45 @@ wlansap_calculate_chan_from_scan_result(mac_handle_t mac_handle, return oper_channel; } +static void +wlansap_filter_unsafe_ch(struct wlan_objmgr_psoc *psoc, + struct sap_context *sap_ctx) +{ + uint16_t i; + uint16_t num_safe_ch = 0; + + /* + * There are two channel list, one acs cfg channel list, and one + * sap_ctx->freq_list, the unsafe channels for acs cfg is updated here + * and the sap_ctx->freq list would be handled in sap_chan_sel_init + * which would consider more params other than unsafe channels. + * So the two lists now would be in sync. But in case the ACS weight + * calculation does not get through due to no scan result or no chan + * selected, or any other reason, the default channel is chosen which + * would contain the channels in acs cfg. Now since the scan takes time + * there could be channels present in acs cfg that could become unsafe + * in the mean time, so it is better to filter out those channels from + * the acs channel list before chosing one of them as a default channel + */ + for (i = 0; i < sap_ctx->acs_cfg->ch_list_count; i++) { + if (!policy_mgr_is_safe_channel(psoc, + sap_ctx->acs_cfg->ch_list[i])) { + sap_debug("unsafe ch %d removed from acs list", + sap_ctx->acs_cfg->ch_list[i]); + continue; + } + /* Add only safe channels to the acs cfg ch list */ + sap_ctx->acs_cfg->ch_list[num_safe_ch++] = + sap_ctx->acs_cfg->ch_list[i]; + } + + sap_debug("Updated ACS ch list len %d", num_safe_ch); + sap_ctx->acs_cfg->ch_list_count = num_safe_ch; + + for (i = 0; i < num_safe_ch; i++) + sap_debug("Ch %d", sap_ctx->acs_cfg->ch_list[i]); +} + QDF_STATUS wlansap_pre_start_bss_acs_scan_callback(mac_handle_t mac_handle, struct sap_context *sap_ctx, uint8_t sessionid, @@ -243,6 +282,20 @@ QDF_STATUS wlansap_pre_start_bss_acs_scan_callback(mac_handle_t mac_handle, host_log_acs_scan_done(acs_scan_done_status_str(scan_status), sessionid, scanid); + + /* This has to be done before the ACS selects default channel */ + wlansap_filter_unsafe_ch(mac_ctx->psoc, sap_ctx); + + if (!sap_ctx->acs_cfg->ch_list_count) { + sap_err("No channel left for SAP operation, hotspot fail"); + sap_ctx->chan_freq = SAP_CHANNEL_NOT_SELECTED; + sap_ctx->acs_cfg->pri_ch = SAP_CHANNEL_NOT_SELECTED; + sap_config_acs_result(mac_handle, sap_ctx, 0); + sap_ctx->sap_state = eSAP_ACS_CHANNEL_SELECTED; + sap_ctx->sap_status = eSAP_START_BSS_CHANNEL_NOT_SELECTED; + goto close_session; + + } if (eCSR_SCAN_SUCCESS != scan_status) { QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR, FL("CSR scan_status = eCSR_SCAN_ABORT/FAILURE (%d), choose default channel"), diff --git a/core/sap/src/sap_ch_select.c b/core/sap/src/sap_ch_select.c index cff9e7c480e0..2ad41540ddc2 100644 --- a/core/sap/src/sap_ch_select.c +++ b/core/sap/src/sap_ch_select.c @@ -118,52 +118,6 @@ #define ACS_WEIGHT_SOFTAP_TX_POWER_THROUGHPUT_CFG(weights) \ (((weights) & 0xf00000) >> 20) -#ifdef FEATURE_WLAN_CH_AVOID -sapSafeChannelType safe_channels[NUM_CHANNELS] = { - {1, true}, - {2, true}, - {3, true}, - {4, true}, - {5, true}, - {6, true}, - {7, true}, - {8, true}, - {9, true}, - {10, true}, - {11, true}, - {12, true}, - {13, true}, - {14, true}, - {36, true}, - {40, true}, - {44, true}, - {48, true}, - {52, true}, - {56, true}, - {60, true}, - {64, true}, - {100, true}, - {104, true}, - {108, true}, - {112, true}, - {116, true}, - {120, true}, - {124, true}, - {128, true}, - {132, true}, - {136, true}, - {140, true}, - {144, true}, - {149, true}, - {153, true}, - {157, true}, - {161, true}, - {165, true}, - {169, true}, - {173, true}, -}; -#endif - typedef struct { uint16_t chStartNum; uint32_t weight; @@ -399,93 +353,6 @@ static void sap_process_avoid_ie(mac_handle_t mac_handle, } #endif /* FEATURE_AP_MCC_CH_AVOIDANCE */ -#ifdef FEATURE_WLAN_CH_AVOID -/*========================================================================== - FUNCTION sap_update_unsafe_channel_list - - DESCRIPTION - Function Undate unsafe channel list table - - DEPENDENCIES - NA. - - IN - SapContext pointer - - RETURN VALUE - NULL - ============================================================================*/ -static void sap_update_unsafe_channel_list(mac_handle_t mac_handle, - struct sap_context *sap_ctx) -{ - uint16_t i, j; - uint16_t unsafe_channel_list[NUM_CHANNELS]; - uint16_t unsafe_channel_count = 0; - struct mac_context *mac_ctx = NULL; - - qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); - - if (!qdf_ctx) { - QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_FATAL, - "qdf_ctx is NULL"); - return; - } - mac_ctx = MAC_CONTEXT(mac_handle); - - /* Flush, default set all channel safe */ - for (i = 0; i < NUM_CHANNELS; i++) { - safe_channels[i].isSafe = true; - } - - /* Try to find unsafe channel */ -#if defined(FEATURE_WLAN_STA_AP_MODE_DFS_DISABLE) - for (i = 0; i < NUM_CHANNELS; i++) { - if (sap_ctx->dfs_ch_disable == true) { - if (wlan_reg_is_dfs_ch(mac_ctx->pdev, - safe_channels[i].channelNumber)) { - safe_channels[i].isSafe = false; - QDF_TRACE(QDF_MODULE_ID_SAP, - QDF_TRACE_LEVEL_INFO_HIGH, - "%s: DFS Ch %d is not safe in" - " Concurrent mode", - __func__, - safe_channels[i].channelNumber); - } - } - } -#endif - pld_get_wlan_unsafe_channel(qdf_ctx->dev, - unsafe_channel_list, - &unsafe_channel_count, - sizeof(unsafe_channel_list)); - - unsafe_channel_count = QDF_MIN(unsafe_channel_count, - (uint16_t)NUM_CHANNELS); - - for (i = 0; i < unsafe_channel_count; i++) { - for (j = 0; j < NUM_CHANNELS; j++) { - if (safe_channels[j].channelNumber == - unsafe_channel_list[i]) { - /* Found unsafe channel, update it */ - safe_channels[j].isSafe = false; - QDF_TRACE(QDF_MODULE_ID_SAP, - QDF_TRACE_LEVEL_ERROR, - FL("CH %d is not safe"), - unsafe_channel_list[i]); - break; - } - } - } - - return; -} -#else -static void sap_update_unsafe_channel_list(mac_handle_t mac_handle, - struct sap_context *sap_ctx) -{ -} -#endif /* FEATURE_WLAN_CH_AVOID */ - /** * sap_channel_in_acs_channel_list() - check if channel in acs channel list * @channel_num: channel to check @@ -593,9 +460,6 @@ static bool sap_chan_sel_init(mac_handle_t mac_handle, uint16_t channelnum = 0; struct mac_context *mac = MAC_CONTEXT(mac_handle); bool chSafe = true; -#ifdef FEATURE_WLAN_CH_AVOID - uint16_t i; -#endif bool include_dfs_ch = true; uint8_t chan_num; bool sta_sap_scc_on_dfs_chan = @@ -666,19 +530,8 @@ static bool sap_chan_sel_init(mac_handle_t mac_handle, } } -#ifdef FEATURE_WLAN_CH_AVOID - for (i = 0; i < NUM_CHANNELS; i++) { - if ((safe_channels[i].channelNumber == channel) && - (false == safe_channels[i].isSafe)) { - QDF_TRACE(QDF_MODULE_ID_SAP, - QDF_TRACE_LEVEL_INFO_HIGH, - "In %s, Ch %d is not safe", __func__, - channel); - chSafe = false; - break; - } - } -#endif /* FEATURE_WLAN_CH_AVOID */ + if (!policy_mgr_is_safe_channel(mac->psoc, channel)) + chSafe = false; /* OFDM rates are not supported on channel 14 */ if (channel == 14 && @@ -2561,8 +2414,6 @@ uint8_t sap_select_channel(mac_handle_t mac_handle, QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, "In %s, Running SAP Ch Select", __func__); - sap_update_unsafe_channel_list(mac_handle, sap_ctx); - /* * If ACS weight is not enabled on noise_floor/channel_free/tx_power, * then skip acs process if no bss found. diff --git a/core/sap/src/sap_fsm.c b/core/sap/src/sap_fsm.c index 072540f6eee6..1719fad33887 100644 --- a/core/sap/src/sap_fsm.c +++ b/core/sap/src/sap_fsm.c @@ -73,10 +73,6 @@ /*---------------------------------------------------------------------------- * External declarations for global context * -------------------------------------------------------------------------*/ -#ifdef FEATURE_WLAN_CH_AVOID -extern sapSafeChannelType safe_channels[]; -#endif /* FEATURE_WLAN_CH_AVOID */ - /*---------------------------------------------------------------------------- * Static Variable Definitions * -------------------------------------------------------------------------*/ @@ -676,11 +672,31 @@ sap_chan_bond_dfs_sub_chan(struct sap_context *sap_context, uint8_t sap_select_default_oper_chan(struct sap_acs_cfg *acs_cfg) { - if (!acs_cfg || !acs_cfg->ch_list) + uint16_t i; + + if (!acs_cfg || !acs_cfg->ch_list || !acs_cfg->ch_list_count) return 0; + /* + * There could be both 2.4Ghz and 5ghz channels present in the list + * based upon the Hw mode received from hostapd, it is always better + * to chose a default 5ghz operating channel than 2.4ghz, as it can + * provide a better throughput, latency than 2.4ghz. Also 40 Mhz is + * rare in 2.4ghz band, so 5ghz should be preferred. If we get a 5Ghz + * chan in the acs cfg ch list , we should go for that first else the + * default channel can be 2.4ghz. + */ + + for (i = 0; i < acs_cfg->ch_list_count; i++) { + if (WLAN_CHAN_IS_5GHZ(acs_cfg->ch_list[i])) { + sap_debug("default channel chosen as %d", + acs_cfg->ch_list[i]); + return acs_cfg->ch_list[i]; + } + } + sap_debug("default channel chosen as %d", acs_cfg->ch_list[0]); - /* Return the default channel as first channel in list */ + return acs_cfg->ch_list[0]; } @@ -3222,9 +3238,6 @@ static QDF_STATUS sap_get_freq_list(struct sap_context *sap_ctx, uint8_t start_ch_num, band_start_ch; uint8_t end_ch_num, band_end_ch; uint32_t en_lte_coex; -#ifdef FEATURE_WLAN_CH_AVOID - uint8_t i; -#endif struct mac_context *mac_ctx; tSapChSelSpectInfo spect_info_obj = { NULL, 0 }; uint16_t ch_width; @@ -3238,6 +3251,9 @@ static QDF_STATUS sap_get_freq_list(struct sap_context *sap_ctx, } dfs_master_enable = mac_ctx->mlme_cfg->dfs_cfg.dfs_master_capable; + if (sap_ctx->dfs_mode == ACS_DFS_MODE_DISABLE) + dfs_master_enable = false; + start_ch_num = sap_ctx->acs_cfg->start_ch; end_ch_num = sap_ctx->acs_cfg->end_ch; ch_width = sap_ctx->acs_cfg->ch_width; @@ -3304,6 +3320,20 @@ static QDF_STATUS sap_get_freq_list(struct sap_context *sap_ctx, ))) continue; + /* check if the channel is in NOL blacklist */ + if (sap_dfs_is_channel_in_nol_list(sap_ctx, + WLAN_REG_CH_NUM(loop_count), + PHY_SINGLE_CHANNEL_CENTERED)) { + sap_debug("Ch %d in NOL list", + WLAN_REG_CH_NUM(loop_count)); + continue; + } + + /* Skip DSRC channels */ + if (wlan_reg_is_dsrc_chan(mac_ctx->pdev, + WLAN_REG_CH_NUM(loop_count))) + continue; + /* * Skip the channels which are not in ACS config from user * space @@ -3332,33 +3362,7 @@ static QDF_STATUS sap_get_freq_list(struct sap_context *sap_ctx, wlan_reg_is_etsi13_srd_chan(mac_ctx->pdev, WLAN_REG_CH_NUM(loop_count))) continue; - /* - * If we have any 5Ghz channel in the channel list - * and bw is 40/80/160 Mhz then we don't want SAP to - * come up in 2.4Ghz as for 40Mhz, 2.4Ghz channel is - * not preferred and 80/160Mhz is not allowed for 2.4Ghz - * band. So, don't even scan on 2.4Ghz channels if bw is - * 40/80/160Mhz and channel list has any 5Ghz channel. - */ - if (end_ch_num >= WLAN_REG_CH_NUM(CHAN_ENUM_5180) && - ((ch_width == CH_WIDTH_40MHZ) || - (ch_width == CH_WIDTH_80MHZ) || - (ch_width == CH_WIDTH_80P80MHZ) || - (ch_width == CH_WIDTH_160MHZ))) { - if (WLAN_REG_CH_NUM(loop_count) >= - WLAN_REG_CH_NUM(CHAN_ENUM_2412) && - WLAN_REG_CH_NUM(loop_count) <= - WLAN_REG_CH_NUM(CHAN_ENUM_2484)) - continue; - } -#ifdef FEATURE_WLAN_CH_AVOID - for (i = 0; i < NUM_CHANNELS; i++) { - if (safe_channels[i].channelNumber == - WLAN_REG_CH_NUM(loop_count)) { - /* Check if channel is safe */ - if (true == safe_channels[i].isSafe) { -#endif #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE uint8_t ch; @@ -3395,12 +3399,6 @@ static QDF_STATUS sap_get_freq_list(struct sap_context *sap_ctx, list[ch_count] = wlan_reg_chan_to_freq(mac_ctx->pdev, WLAN_REG_CH_NUM(loop_count)); ch_count++; -#endif -#ifdef FEATURE_WLAN_CH_AVOID - } - break; - } - } #endif } if (0 == ch_count) {