diff options
| author | bings <bings@codeaurora.org> | 2016-11-29 11:33:18 +0800 |
|---|---|---|
| committer | qcabuildsw <qcabuildsw@localhost> | 2016-12-29 13:23:36 -0800 |
| commit | 41126456e876623ddff40ff860388b5696904b1c (patch) | |
| tree | 25db9f106091a9302f7246e437a1a4e6d479035c | |
| parent | f491da118f73f771818521edd6e61c79ad616953 (diff) | |
qcacld-3.0: Fix calculating channel weight in sap_sort_chl_weight_all
qcacld-2.0 to qcacld-3.0 propagation
Currently if acs configs channel width as 40/80MHZ, it may select
invalid channel as its second channel.
When doing sapSelectChannel, if acs configs channel width as
40/80MHZ, every candidate channel and its adjacent channel should
be checked whether it can satisfy 40/80MHZ or not. Mark the weight
of the channel that can't satisfy 40/80MHZ as max value
in sapSortChlWeightAll, so it will not be selected.
Change-Id: I69abbb752be8d0fae2644a9000156735048d6d16
CRs-Fixed: 1085469
| -rw-r--r-- | core/cds/inc/cds_reg_service.h | 11 | ||||
| -rw-r--r-- | core/cds/src/cds_reg_service.c | 21 | ||||
| -rw-r--r-- | core/sap/src/sap_ch_select.c | 124 |
3 files changed, 154 insertions, 2 deletions
diff --git a/core/cds/inc/cds_reg_service.h b/core/cds/inc/cds_reg_service.h index b3ed3ca468e3..5549493b414b 100644 --- a/core/cds/inc/cds_reg_service.h +++ b/core/cds/inc/cds_reg_service.h @@ -330,6 +330,11 @@ enum phy_ch_width { CH_WIDTH_MAX }; +#define HT40PLUS_2G_FCC_CH_END 7 +#define HT40PLUS_2G_EURJAP_CH_END 9 +#define HT40MINUS_2G_CH_START 5 +#define HT40MINUS_2G_CH_END 13 + /** * struct ch_params_s * @ch_width: channel width @@ -370,6 +375,12 @@ extern struct regulatory_channel reg_channels[NUM_CHANNELS]; QDF_STATUS cds_get_reg_domain_from_country_code(v_REGDOMAIN_t *pRegDomain, const uint8_t *country_alpha2, enum country_src source); +/** + * cds_is_fcc_regdomian() - is the regdomain FCC + * + * Return: true on FCC regdomain, false otherwise + */ +bool cds_is_fcc_regdomain(void); QDF_STATUS cds_read_default_country(uint8_t *default_country); diff --git a/core/cds/src/cds_reg_service.c b/core/cds/src/cds_reg_service.c index a8bc3e58984c..12e2a9a3a107 100644 --- a/core/cds/src/cds_reg_service.c +++ b/core/cds/src/cds_reg_service.c @@ -38,6 +38,7 @@ #include "cds_reg_service.h" #include "cds_regdomain.h" #include "sme_api.h" +#include "wlan_hdd_main.h" const struct chan_map chan_mapping[NUM_CHANNELS] = { [CHAN_ENUM_1] = {2412, 1}, @@ -659,6 +660,26 @@ QDF_STATUS cds_get_reg_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr, return QDF_STATUS_SUCCESS; } +/** + * cds_is_fcc_regdomian() - is the regdomain FCC + * + * Return: true on FCC regdomain, false otherwise + */ +bool cds_is_fcc_regdomain(void) +{ + v_REGDOMAIN_t domainId; + hdd_context_t *hdd_ctx; + + hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); + if (wlan_hdd_validate_context(hdd_ctx)) + return false; + cds_get_reg_domain_from_country_code(&domainId, + hdd_ctx->reg.alpha2, SOURCE_QUERY); + if (REGDOMAIN_FCC == domainId) + return true; + return false; +} + /* * cds_is_dsrc_channel() - is the channel DSRC * @center_freq: center freq of the channel diff --git a/core/sap/src/sap_ch_select.c b/core/sap/src/sap_ch_select.c index 77475acaa080..4183da112e36 100644 --- a/core/sap/src/sap_ch_select.c +++ b/core/sap/src/sap_ch_select.c @@ -1418,6 +1418,49 @@ static void sap_sort_chl_weight(tSapChSelSpectInfo *pSpectInfoParams) } /** + * set_ht80_chl_bit() - to set availabe channel to ht80 channel bitmap + * @channel_bitmap: Pointer to the chan_bonding_bitmap structure + * @spect_info_params: Pointer to the tSapChSelSpectInfo structure + * + * Return: none + */ +static void set_ht80_chl_bit(chan_bonding_bitmap *channel_bitmap, + tSapChSelSpectInfo *spec_info_params) +{ + uint8_t i, j; + tSapSpectChInfo *spec_info; + int start_channel = 0; + channel_bitmap->chanBondingSet[0].startChannel = + acs_ht80_channels[0].chStartNum; + channel_bitmap->chanBondingSet[1].startChannel = + acs_ht80_channels[1].chStartNum; + channel_bitmap->chanBondingSet[2].startChannel = + acs_ht80_channels[2].chStartNum; + channel_bitmap->chanBondingSet[3].startChannel = + acs_ht80_channels[3].chStartNum; + channel_bitmap->chanBondingSet[4].startChannel = + acs_ht80_channels[4].chStartNum; + channel_bitmap->chanBondingSet[5].startChannel = + acs_ht80_channels[5].chStartNum; + + spec_info = spec_info_params->pSpectCh; + for (j = 0; j < spec_info_params->numSpectChans; j++) { + for (i = 0; i < MAX_80MHZ_BANDS; i++) { + start_channel = + channel_bitmap->chanBondingSet[i].startChannel; + if (spec_info[j].chNum >= start_channel && + (spec_info[j].chNum <= + start_channel + 12)) { + channel_bitmap->chanBondingSet[i].channelMap |= + 1 << ((spec_info[j].chNum - + start_channel)/4); + break; + } + } + } +} + +/** * sap_sort_chl_weight_ht80() - to sort the channels with the least weight * @pSpectInfoParams: Pointer to the tSapChSelSpectInfo structure * @@ -1430,7 +1473,15 @@ static void sap_sort_chl_weight_ht80(tSapChSelSpectInfo *pSpectInfoParams) uint8_t i, j, n; tSapSpectChInfo *pSpectInfo; uint8_t minIdx; + int start_channel = 0; + chan_bonding_bitmap *channel_bitmap; + channel_bitmap = qdf_mem_malloc(sizeof(chan_bonding_bitmap)); + if (NULL == channel_bitmap) { + QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, + "%s: Failed to allocate memory", __func__); + return; + } pSpectInfo = pSpectInfoParams->pSpectCh; /* for each HT80 channel, calculate the combined weight of the four 20MHz weight */ @@ -1498,6 +1549,24 @@ static void sap_sort_chl_weight_ht80(tSapChSelSpectInfo *pSpectInfoParams) pSpectInfo[j + minIdx].weight = acs_ht80_channels[i].weight; } + /* + * mark the weight of the channel that can't satisfy 80MHZ + * as max value, so that it will be sorted to the bottom + */ + set_ht80_chl_bit(channel_bitmap, pSpectInfoParams); + for (j = 0; j < pSpectInfoParams->numSpectChans; j++) { + for (i = 0; i < MAX_80MHZ_BANDS; i++) { + start_channel = + channel_bitmap->chanBondingSet[i].startChannel; + if (pSpectInfo[j].chNum >= start_channel && + (pSpectInfo[j].chNum <= + start_channel + 12) && + channel_bitmap->chanBondingSet[i].channelMap != + SAP_80MHZ_MASK) + pSpectInfo[j].weight = SAP_ACS_WEIGHT_MAX * 4; + } + } + pSpectInfo = pSpectInfoParams->pSpectCh; for (j = 0; j < pSpectInfoParams->numSpectChans; j++) { if (CHANNEL_165 == pSpectInfo[j].chNum) { @@ -1516,6 +1585,7 @@ static void sap_sort_chl_weight_ht80(tSapChSelSpectInfo *pSpectInfoParams) pSpectInfo->rssiAgr, pSpectInfo->bssCount); pSpectInfo++; } + qdf_mem_free(channel_bitmap); } /** @@ -1670,6 +1740,7 @@ static void sap_sort_chl_weight_ht40_24_g(tSapChSelSpectInfo *pSpectInfoParams) uint8_t i, j; tSapSpectChInfo *pSpectInfo; uint32_t tmpWeight1, tmpWeight2; + uint32_t ht40plus2gendch = 0; pSpectInfo = pSpectInfoParams->pSpectCh; /* @@ -1753,6 +1824,33 @@ static void sap_sort_chl_weight_ht40_24_g(tSapChSelSpectInfo *pSpectInfoParams) } } } + /* + * Every channel should be checked. Add the check for the omissive + * channel. Mark the channel whose combination can't satisfy 40MHZ + * as max value, so that it will be sorted to the bottom. + */ + if (cds_is_fcc_regdomain()) + ht40plus2gendch = HT40PLUS_2G_FCC_CH_END; + else + ht40plus2gendch = HT40PLUS_2G_EURJAP_CH_END; + for (i = HT40MINUS_2G_CH_START; i <= ht40plus2gendch; i++) { + for (j = 0; j < pSpectInfoParams->numSpectChans; j++) { + if (pSpectInfo[j].chNum == i && + ((pSpectInfo[j].chNum + 4) != + pSpectInfo[j+4].chNum) && + ((pSpectInfo[j].chNum - 4) != + pSpectInfo[j-4].chNum)) + pSpectInfo[j].weight = SAP_ACS_WEIGHT_MAX * 2; + } + } + for (i = ht40plus2gendch + 1; i <= HT40MINUS_2G_CH_END; i++) { + for (j = 0; j < pSpectInfoParams->numSpectChans; j++) { + if (pSpectInfo[j].chNum == i && + (pSpectInfo[j].chNum - 4) != + pSpectInfo[j-4].chNum) + pSpectInfo[j].weight = SAP_ACS_WEIGHT_MAX * 2; + } + } sap_sort_chl_weight(pSpectInfoParams); } @@ -1816,6 +1914,22 @@ static void sap_sort_chl_weight_ht40_5_g(tSapChSelSpectInfo *pSpectInfoParams) pSpectInfo[j].weight = SAP_ACS_WEIGHT_MAX * 2; } + /* + *Every channel should be checked. Add the check for the omissive + * channel. Mark the channel whose combination can't satisfy 40MHZ + * as max value, so that it will be sorted to the bottom + */ + for (j = 1; j < pSpectInfoParams->numSpectChans; j++) { + for (i = 0; i < ARRAY_SIZE(acs_ht40_channels5_g); i++) { + if (pSpectInfo[j].chNum == + (acs_ht40_channels5_g[i].chStartNum + 4) && + pSpectInfo[j-1].chNum != + acs_ht40_channels5_g[i].chStartNum) { + pSpectInfo[j].weight = SAP_ACS_WEIGHT_MAX * 2; + break; + } + } + } /* avoid channel 165 by setting its weight to max */ pSpectInfo = pSpectInfoParams->pSpectCh; for (j = 0; j < pSpectInfoParams->numSpectChans; j++) { @@ -2073,6 +2187,7 @@ uint8_t sap_select_channel(tHalHandle hal, ptSapContext sap_ctx, tSapChSelSpectInfo spect_info_obj = { NULL, 0 }; tSapChSelSpectInfo *spect_info = &spect_info_obj; uint8_t best_ch_num = SAP_CHANNEL_NOT_SELECTED; + uint32_t ht40plus2gendch = 0; #ifdef SOFTAP_CHANNEL_RANGE uint8_t count; uint32_t start_ch_num, end_ch_num, tmp_ch_num, operating_band = 0; @@ -2215,7 +2330,12 @@ uint8_t sap_select_channel(tHalHandle hal, ptSapContext sap_ctx, (sap_ctx->acs_cfg->ch_width != CH_WIDTH_40MHZ)) goto sap_ch_sel_end; - if ((best_ch_num >= 5) && (best_ch_num <= 7)) { + if (cds_is_fcc_regdomain()) + ht40plus2gendch = HT40PLUS_2G_FCC_CH_END; + else + ht40plus2gendch = HT40PLUS_2G_EURJAP_CH_END; + if ((best_ch_num >= HT40MINUS_2G_CH_START) && + (best_ch_num <= ht40plus2gendch)) { int weight_below, weight_above, i; tSapSpectChInfo *pspect_info; @@ -2236,7 +2356,7 @@ uint8_t sap_select_channel(tHalHandle hal, ptSapContext sap_ctx, sap_ctx->acs_cfg->pri_ch + 4; } else if (best_ch_num >= 1 && best_ch_num <= 4) { sap_ctx->acs_cfg->ht_sec_ch = sap_ctx->acs_cfg->pri_ch + 4; - } else if (best_ch_num >= 8 && best_ch_num <= 13) { + } else if (best_ch_num > ht40plus2gendch && best_ch_num <= HT40MINUS_2G_CH_END) { sap_ctx->acs_cfg->ht_sec_ch = sap_ctx->acs_cfg->pri_ch - 4; } else if (best_ch_num == 14) { sap_ctx->acs_cfg->ht_sec_ch = 0; |
