From 91c5c0f7d7ee22a16f91c245bc4ae75f9a29647f Mon Sep 17 00:00:00 2001 From: Himanshu Agarwal Date: Tue, 13 Feb 2018 14:40:56 +0530 Subject: [PATCH] qcacld-3.0: Avoid 2.4Ghz channel in 40Mhz for SAP start When the channel list provided from hostapd contains both 2.4Ghz and 5Ghz channels and channel width is 40Mhz, scan happens on all the 2.4Ghz and 5Ghz channels and ACS algo runs on all the channels to find the best channel for starting SAP in 40Mhz. If a 2.4Ghz is selected, an OBSS scan happens on all the 2.4Ghz channels to check if there is any legacy BSS present on any overlapping channel. If any BSS is found, channel width fallbacks to 20Mhz and SAP gets started in 20Mhz bw instead of 40Mhz. This is generally the case with 2.4Ghz whereas there is no such issue in 5Ghz channels. Avoid 2.4Ghz channels for starting SAP in 40Mhz bw by assigning max weight to all the 2.4Ghz channels if 5Ghz channels are also present in the channel list provided from hostapd. Change-Id: I079d20b912282c9db5c9b51b1ed4b85a4aa9c5df CRs-Fixed: 2186658 --- core/sap/src/sap_ch_select.c | 74 +++++++++++++++++++++++++++++++++--- core/sap/src/sap_fsm.c | 28 ++++++++++++-- 2 files changed, 94 insertions(+), 8 deletions(-) diff --git a/core/sap/src/sap_ch_select.c b/core/sap/src/sap_ch_select.c index 281d2f00d85a..66414157c1fb 100644 --- a/core/sap/src/sap_ch_select.c +++ b/core/sap/src/sap_ch_select.c @@ -2107,6 +2107,56 @@ static void sap_sort_chl_weight_vht160(tSapChSelSpectInfo *pSpectInfoParams) } } +/** + * sap_allocate_max_weight_ht40_24_g() - allocate max weight for 40Mhz + * to all 2.4Ghz channels + * @spect_info_params: Pointer to the tSapChSelSpectInfo structure + * + * Return: none + */ +static void sap_allocate_max_weight_ht40_24_g( + tSapChSelSpectInfo *spect_info_params) +{ + tSapSpectChInfo *spect_info; + uint8_t j; + + /* + * Assign max weight for 40Mhz (SAP_ACS_WEIGHT_MAX * 2) to all + * 2.4 Ghz channels + */ + spect_info = spect_info_params->pSpectCh; + for (j = 0; j < spect_info_params->numSpectChans; j++) { + if ((spect_info[j].chNum >= WLAN_REG_CH_NUM(CHAN_ENUM_1) && + spect_info[j].chNum <= WLAN_REG_CH_NUM(CHAN_ENUM_14))) + spect_info[j].weight = SAP_ACS_WEIGHT_MAX * 2; + } +} + +/** + * sap_allocate_max_weight_ht40_5_g() - allocate max weight for 40Mhz + * to all 5Ghz channels + * @spect_info_params: Pointer to the tSapChSelSpectInfo structure + * + * Return: none + */ +static void sap_allocate_max_weight_ht40_5_g( + tSapChSelSpectInfo *spect_info_params) +{ + tSapSpectChInfo *spect_info; + uint8_t j; + + /* + * Assign max weight for 40Mhz (SAP_ACS_WEIGHT_MAX * 2) to all + * 5 Ghz channels + */ + spect_info = spect_info_params->pSpectCh; + for (j = 0; j < spect_info_params->numSpectChans; j++) { + if ((spect_info[j].chNum >= WLAN_REG_CH_NUM(CHAN_ENUM_36) && + spect_info[j].chNum <= WLAN_REG_CH_NUM(CHAN_ENUM_165))) + spect_info[j].weight = SAP_ACS_WEIGHT_MAX * 2; + } +} + /** * sap_sort_chl_weight_ht40_24_g() - to sort channel with the least weight * @pSpectInfoParams: Pointer to the tSapChSelSpectInfo structure @@ -2232,6 +2282,16 @@ static void sap_sort_chl_weight_ht40_24_g(tSapChSelSpectInfo *pSpectInfoParams, pSpectInfo[j].weight = SAP_ACS_WEIGHT_MAX * 2; } } + + pSpectInfo = pSpectInfoParams->pSpectCh; + for (j = 0; j < (pSpectInfoParams->numSpectChans); j++) { + QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, + "In %s, Channel=%d Weight= %d rssi=%d bssCount=%d", + __func__, pSpectInfo->chNum, pSpectInfo->weight, + pSpectInfo->rssiAgr, pSpectInfo->bssCount); + pSpectInfo++; + } + sap_sort_chl_weight(pSpectInfoParams); } @@ -2369,12 +2429,16 @@ static void sap_sort_chl_weight_all(struct sap_context *sap_ctx, switch (sap_ctx->acs_cfg->ch_width) { case CH_WIDTH_40MHZ: - if (eCSR_DOT11_MODE_11g == operatingBand) - sap_sort_chl_weight_ht40_24_g(pSpectInfoParams, domain); - else if (eCSR_DOT11_MODE_11a == operatingBand) - sap_sort_chl_weight_ht40_5_g(pSpectInfoParams); - else { + /* + * Assign max weight to all 5Ghz channels when operating band + * is 11g and to all 2.4Ghz channels when operating band is 11a + * or 11abg to avoid selection in ACS algorithm for starting SAP + */ + if (eCSR_DOT11_MODE_11g == operatingBand) { sap_sort_chl_weight_ht40_24_g(pSpectInfoParams, domain); + sap_allocate_max_weight_ht40_5_g(pSpectInfoParams); + } else { + sap_allocate_max_weight_ht40_24_g(pSpectInfoParams); sap_sort_chl_weight_ht40_5_g(pSpectInfoParams); } break; diff --git a/core/sap/src/sap_fsm.c b/core/sap/src/sap_fsm.c index 7c2de758fd03..3fa2168fec89 100644 --- a/core/sap/src/sap_fsm.c +++ b/core/sap/src/sap_fsm.c @@ -3210,6 +3210,7 @@ static QDF_STATUS sap_get_channel_list(struct sap_context *sap_ctx, #endif tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal); tSapChSelSpectInfo spect_info_obj = { NULL, 0 }; + uint16_t ch_width; if (NULL == hal) { QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR, @@ -3221,10 +3222,11 @@ static QDF_STATUS sap_get_channel_list(struct sap_context *sap_ctx, 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; QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO, - FL("startChannel %d, EndChannel %d, HW:%d"), - start_ch_num, end_ch_num, - sap_ctx->acs_cfg->hw_mode); + FL("startChannel %d, EndChannel %d, ch_width %d, HW:%d"), + start_ch_num, end_ch_num, ch_width, + sap_ctx->acs_cfg->hw_mode); wlansap_extend_to_acs_range(hal, &start_ch_num, &end_ch_num, &band_start_ch, &band_end_ch); @@ -3287,6 +3289,26 @@ static QDF_STATUS sap_get_channel_list(struct sap_context *sap_ctx, sap_ctx, &spect_info_obj)) 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_36) && + ((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_1) && + WLAN_REG_CH_NUM(loop_count) <= + WLAN_REG_CH_NUM(CHAN_ENUM_14)) + continue; + } + #ifdef FEATURE_WLAN_CH_AVOID for (i = 0; i < NUM_CHANNELS; i++) { if (safe_channels[i].channelNumber ==