diff options
| author | Hong Shi <hongsh@codeaurora.org> | 2016-12-21 20:09:47 +0800 |
|---|---|---|
| committer | Ashish kumar goswami <agoswa@codeaurora.org> | 2017-01-04 15:50:06 +0530 |
| commit | 078e69b5becc6171081115ddcd5fb8a64b443974 (patch) | |
| tree | c80ccf457f08bf9c8bbe99eea3dd8c7901d42b4e | |
| parent | 50f430f60b3cd29d11901e4e4062b442e3491e31 (diff) | |
qcacld-2.0: Add ACS weight config option
Currently, ACS weights are hardcoded. This change is to make acs weights
configurable. The ini option gAutoChannelSelectWeight is defined as
combination of various acs weights, 4 bits for each. The availble acs
weights are rssi, bss count, noise floor, channel free, tx power range,
tx power throughput.
It will be modulated to original weights so no need to change the max
weight existed.
This change also fixed below bugs of ACS algorithm:
1. used original count statistics instead of delta value
2. wrong computation of channel free status
CRs-Fixed: 1103995
Change-Id: If8faa8c6ad9789df9d31a7377d9fbe53e9504019
| -rw-r--r-- | CORE/HDD/inc/wlan_hdd_cfg.h | 33 | ||||
| -rw-r--r-- | CORE/HDD/src/wlan_hdd_cfg.c | 9 | ||||
| -rw-r--r-- | CORE/HDD/src/wlan_hdd_cfg80211.c | 7 | ||||
| -rw-r--r-- | CORE/MAC/inc/sirApi.h | 4 | ||||
| -rw-r--r-- | CORE/MAC/src/pe/lim/limUtils.c | 60 | ||||
| -rw-r--r-- | CORE/SAP/inc/sapApi.h | 3 | ||||
| -rw-r--r-- | CORE/SAP/src/sapChSelect.c | 340 | ||||
| -rw-r--r-- | CORE/SAP/src/sapChSelect.h | 9 | ||||
| -rw-r--r-- | CORE/SAP/src/sapInternal.h | 3 | ||||
| -rw-r--r-- | CORE/SAP/src/sapModule.c | 5 | ||||
| -rw-r--r-- | CORE/SERVICES/WMA/wma.c | 82 |
11 files changed, 416 insertions, 139 deletions
diff --git a/CORE/HDD/inc/wlan_hdd_cfg.h b/CORE/HDD/inc/wlan_hdd_cfg.h index 132e5e557105..211937901e99 100644 --- a/CORE/HDD/inc/wlan_hdd_cfg.h +++ b/CORE/HDD/inc/wlan_hdd_cfg.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -1730,6 +1730,36 @@ typedef enum #define CFG_SAP_SCAN_BAND_PREFERENCE_MIN (0) #define CFG_SAP_SCAN_BAND_PREFERENCE_MAX (2) #define CFG_SAP_SCAN_BAND_PREFERENCE_DEFAULT (0) + +/* + * <ini> + * gAutoChannelSelectWeight - ACS channel weight + * @Min: 0x1 + * @Max: 0xFFFFFFFF + * @Default: 0x000000FF + * + * This ini is used to adjust weight of factors in + * acs algorithm. + * + * Supported Feature: ACS + * + * Usage: Internal/External + * + * bits 0-3: rssi weight + * bits 4-7: bss count weight + * bits 8-11: noise floor weight + * bits 12-15: channel free weight + * bits 16-19: tx power range weight + * bits 20-23: tx power throughput weight + * bits 24-31: reserved + * + * </ini> + */ +#define CFG_AUTO_CHANNEL_SELECT_WEIGHT "gAutoChannelSelectWeight" +#define CFG_AUTO_CHANNEL_SELECT_WEIGHT_MIN (0x1) +#define CFG_AUTO_CHANNEL_SELECT_WEIGHT_MAX (0xFFFFFFFF) +#define CFG_AUTO_CHANNEL_SELECT_WEIGHT_DEFAULT (0x000000FF) + #define CFG_ACS_BAND_SWITCH_THRESHOLD "gACSBandSwitchThreshold" #define CFG_ACS_BAND_SWITCH_THRESHOLD_MIN (0) #define CFG_ACS_BAND_SWITCH_THRESHOLD_MAX (4444) @@ -4863,6 +4893,7 @@ struct hdd_config { v_BOOL_t gEnableOverLapCh; v_BOOL_t fRegChangeDefCountry; v_U8_t acsScanBandPreference; + uint32_t auto_channel_select_weight; uint8_t enable_rts_sifsbursting; uint8_t max_mpdus_inampdu; uint16_t sap_max_mcs_txdata; diff --git a/CORE/HDD/src/wlan_hdd_cfg.c b/CORE/HDD/src/wlan_hdd_cfg.c index a15f5b694260..f1f724262d9e 100644 --- a/CORE/HDD/src/wlan_hdd_cfg.c +++ b/CORE/HDD/src/wlan_hdd_cfg.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -3352,6 +3352,13 @@ REG_TABLE_ENTRY g_registry_table[] = CFG_SAP_SCAN_BAND_PREFERENCE_MIN, CFG_SAP_SCAN_BAND_PREFERENCE_MAX ), + REG_VARIABLE( CFG_AUTO_CHANNEL_SELECT_WEIGHT, WLAN_PARAM_HexInteger, + hdd_config_t, auto_channel_select_weight, + VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT, + CFG_AUTO_CHANNEL_SELECT_WEIGHT_DEFAULT, + CFG_AUTO_CHANNEL_SELECT_WEIGHT_MIN, + CFG_AUTO_CHANNEL_SELECT_WEIGHT_MAX ), + #ifdef QCA_LL_TX_FLOW_CT REG_VARIABLE( CFG_LL_TX_FLOW_LWM, WLAN_PARAM_Integer, hdd_config_t, TxFlowLowWaterMark, diff --git a/CORE/HDD/src/wlan_hdd_cfg80211.c b/CORE/HDD/src/wlan_hdd_cfg80211.c index 935efcc136c4..7a42199f7f3b 100644 --- a/CORE/HDD/src/wlan_hdd_cfg80211.c +++ b/CORE/HDD/src/wlan_hdd_cfg80211.c @@ -9144,6 +9144,13 @@ static int __wlan_hdd_cfg80211_do_acs(struct wiphy *wiphy, sap_config->acs_cfg.ch_width = eHT_CHANNEL_WIDTH_40MHZ; } + sap_config->acsBandSwitchThreshold = + hdd_ctx->cfg_ini->acsBandSwitchThreshold; + + if (hdd_ctx->cfg_ini->auto_channel_select_weight) + sap_config->auto_channel_select_weight = + hdd_ctx->cfg_ini->auto_channel_select_weight; + hddLog(LOG1, FL("ACS Config for wlan%d: HW_MODE: %d ACS_BW: %d HT: %d VHT: %d START_CH: %d END_CH: %d"), adapter->dev->ifindex, sap_config->acs_cfg.hw_mode, ch_width, ht_enabled, vht_enabled, diff --git a/CORE/MAC/inc/sirApi.h b/CORE/MAC/inc/sirApi.h index 7e6b64d7a9a6..b4c0ac2c57c8 100644 --- a/CORE/MAC/inc/sirApi.h +++ b/CORE/MAC/inc/sirApi.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -3043,6 +3043,7 @@ typedef struct sLimScanChn * @bss_rx_cycle_count: BSS rx cycle count * @rx_11b_mode_data_duration: b-mode data rx time (units are microseconds) * @channel_id: channel index + * @cmd_flags: indicate which stat event is this status coming from */ struct lim_channel_status { uint32_t channelfreq; @@ -3055,6 +3056,7 @@ struct lim_channel_status { uint32_t bss_rx_cycle_count; uint32_t rx_11b_mode_data_duration; uint32_t channel_id; + uint32_t cmd_flags; }; typedef struct sSmeGetScanChnRsp diff --git a/CORE/MAC/src/pe/lim/limUtils.c b/CORE/MAC/src/pe/lim/limUtils.c index f1447c9033d3..eb86ae35821b 100644 --- a/CORE/MAC/src/pe/lim/limUtils.c +++ b/CORE/MAC/src/pe/lim/limUtils.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2016 The Linux Foundation. All rights reserved. + * Copyright (c) 2011-2017 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -6016,30 +6016,44 @@ void lim_add_channel_status_info(tpAniSirGlobal p_mac, uint8_t total_channel = channel_info->total_channel; if (ACS_FW_REPORT_PARAM_CONFIGURED) { - for (i = 0; i < total_channel; i++) { - if (channel_status_list[i].channel_id == channel_id) { - vos_mem_copy( - &channel_status_list[i], - channel_stat, - sizeof(*channel_status_list)); - found = true; - break; - } + for (i = 0; i < total_channel; i++) { + if (channel_status_list[i].channel_id == channel_id) { + if (channel_stat->cmd_flags == + WMI_CHAN_INFO_END_RESP && + channel_status_list[i].cmd_flags == + WMI_CHAN_INFO_START_RESP) { + /* adjust to delta value for counts */ + channel_stat->rx_clear_count -= + channel_status_list[i].rx_clear_count; + channel_stat->cycle_count -= + channel_status_list[i].cycle_count; + channel_stat->rx_frame_count -= + channel_status_list[i].rx_frame_count; + channel_stat->bss_rx_cycle_count -= + channel_status_list[i].bss_rx_cycle_count; + } + vos_mem_copy( + &channel_status_list[i], + channel_stat, + sizeof(*channel_status_list)); + found = true; + break; } - if (!found) { - if (total_channel < - SIR_MAX_SUPPORTED_ACS_CHANNEL_LIST) { - vos_mem_copy( - &channel_status_list[total_channel++], - channel_stat, - sizeof(*channel_status_list)); - channel_info->total_channel = total_channel; - } else { - PELOGW(limLog(p_mac, LOGW, - FL("Chan cnt exceed, channel_id=%d"), - channel_id);) - } + } + if (!found) { + if (total_channel < + SIR_MAX_SUPPORTED_ACS_CHANNEL_LIST) { + vos_mem_copy( + &channel_status_list[total_channel++], + channel_stat, + sizeof(*channel_status_list)); + channel_info->total_channel = total_channel; + } else { + PELOGW(limLog(p_mac, LOGW, + FL("Chan cnt exceed, channel_id=%d"), + channel_id);) } + } } return; } diff --git a/CORE/SAP/inc/sapApi.h b/CORE/SAP/inc/sapApi.h index edfab54d9b54..9993edf1bc60 100644 --- a/CORE/SAP/inc/sapApi.h +++ b/CORE/SAP/inc/sapApi.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -555,6 +555,7 @@ typedef struct sap_Config { eCsrBand scanBandPreference; v_BOOL_t enOverLapCh; v_U16_t acsBandSwitchThreshold; + uint32_t auto_channel_select_weight; struct sap_acs_cfg acs_cfg; #ifdef WLAN_FEATURE_11W v_BOOL_t mfpRequired; diff --git a/CORE/SAP/src/sapChSelect.c b/CORE/SAP/src/sapChSelect.c index d10be8c733fb..5d8474053bc6 100644 --- a/CORE/SAP/src/sapChSelect.c +++ b/CORE/SAP/src/sapChSelect.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -96,6 +96,50 @@ acs_band = eCSR_DOT11_MODE_11a;\ } +#define ACS_WEIGHT_AMOUNT_LOCAL 40 + +#define ACS_WEIGHT_AMOUNT_CONFIG(weights) \ + (((weights) & 0xf) + \ + (((weights) & 0xf0) >> 4) + \ + (((weights) & 0xf00) >> 8) + \ + (((weights) & 0xf000) >> 12) + \ + (((weights) & 0xf0000) >> 16) + \ + (((weights) & 0xf00000) >> 20)) + +/* + * LSH/RSH 4 to enhance the accurate since + * need to do modulation to ACS_WEIGHT_AMOUNT_LOCAL. + */ +#define ACS_WEIGHT_COMPUTE(weights, weight, factor, base) \ + ((((((((weight) << 4) * ACS_WEIGHT_AMOUNT_LOCAL * (factor)) + \ + (ACS_WEIGHT_AMOUNT_CONFIG((weights)) >> 1)) / \ + ACS_WEIGHT_AMOUNT_CONFIG((weights))) + \ + ((base) >> 1)) / (base)) \ + >> 4) + +#define ACS_WEIGHT_CFG_TO_LOCAL(weights, weight) \ + ((((((weight) << 4) * ACS_WEIGHT_AMOUNT_LOCAL) + \ + (ACS_WEIGHT_AMOUNT_CONFIG((weights)) >> 1)) / \ + ACS_WEIGHT_AMOUNT_CONFIG((weights))) >> 4) + +#define ACS_WEIGHT_SOFTAP_RSSI_CFG(weights) \ + ((weights) & 0xf) + +#define ACS_WEIGHT_SOFTAP_COUNT_CFG(weights) \ + (((weights) & 0xf0) >> 4) + +#define ACS_WEIGHT_SOFTAP_NOISE_FLOOR_CFG(weights) \ + (((weights) & 0xf00) >> 8) + +#define ACS_WEIGHT_SOFTAP_CHANNEL_FREE_CFG(weights) \ + (((weights) & 0xf000) >> 12) + +#define ACS_WEIGHT_SOFTAP_TX_POWER_RANGE_CFG(weights) \ + (((weights) & 0xf0000) >> 16) + +#define ACS_WEIGHT_SOFTAP_TX_POWER_THROUGHPUT_CFG(weights) \ + (((weights) & 0xf00000) >> 20) + #ifdef FEATURE_WLAN_CH_AVOID sapSafeChannelType safeChannels[NUM_20MHZ_RF_CHANNELS] = { @@ -700,6 +744,7 @@ v_BOOL_t sapChanSelInit(tHalHandle halHandle, PARAMETERS IN + sap_ctx : Softap context rssi : Max signal strength receieved from a BSS for the channel count : Number of BSS observed in the channel @@ -708,27 +753,47 @@ v_BOOL_t sapChanSelInit(tHalHandle halHandle, SIDE EFFECTS ============================================================================*/ -v_U32_t sapweightRssiCount(v_S7_t rssi, v_U16_t count) +v_U32_t sapweightRssiCount(ptSapContext sap_ctx, v_S7_t rssi, v_U16_t count) { v_S31_t rssiWeight=0; v_S31_t countWeight=0; v_U32_t rssicountWeight=0; + uint8_t softap_rssi_weight_cfg, softap_count_weight_cfg; + uint8_t softap_rssi_weight_local, softap_count_weight_local; + + softap_rssi_weight_cfg = + ACS_WEIGHT_SOFTAP_RSSI_CFG(sap_ctx->auto_channel_select_weight); + + softap_count_weight_cfg = + ACS_WEIGHT_SOFTAP_COUNT_CFG(sap_ctx->auto_channel_select_weight); + + softap_rssi_weight_local = + ACS_WEIGHT_CFG_TO_LOCAL(sap_ctx->auto_channel_select_weight, + softap_rssi_weight_cfg); + + softap_count_weight_local = + ACS_WEIGHT_CFG_TO_LOCAL(sap_ctx->auto_channel_select_weight, + softap_count_weight_cfg); // Weight from RSSI - rssiWeight = SOFTAP_RSSI_WEIGHT * (rssi - SOFTAP_MIN_RSSI) - /(SOFTAP_MAX_RSSI - SOFTAP_MIN_RSSI); + rssiWeight = ACS_WEIGHT_COMPUTE(sap_ctx->auto_channel_select_weight, + softap_rssi_weight_cfg, + rssi - SOFTAP_MIN_RSSI, + SOFTAP_MAX_RSSI - SOFTAP_MIN_RSSI); - if(rssiWeight > SOFTAP_RSSI_WEIGHT) - rssiWeight = SOFTAP_RSSI_WEIGHT; + if(rssiWeight > softap_rssi_weight_local) + rssiWeight = softap_rssi_weight_local; else if (rssiWeight < 0) rssiWeight = 0; // Weight from data count - countWeight = SOFTAP_COUNT_WEIGHT * (count - SOFTAP_MIN_COUNT) - /(SOFTAP_MAX_COUNT - SOFTAP_MIN_COUNT); + countWeight = ACS_WEIGHT_COMPUTE(sap_ctx->auto_channel_select_weight, + softap_count_weight_cfg, + count - SOFTAP_MIN_COUNT, + SOFTAP_MAX_COUNT - SOFTAP_MIN_COUNT); - if(countWeight > SOFTAP_COUNT_WEIGHT) - countWeight = SOFTAP_COUNT_WEIGHT; + if(countWeight > softap_count_weight_local) + countWeight = softap_count_weight_local; rssicountWeight = rssiWeight + countWeight; @@ -762,84 +827,229 @@ void sap_clear_channel_status(tpAniSirGlobal p_mac) { csr_clear_channel_status(p_mac); } + /** - * sap_weight_channel_status() - compute chan status weight + * sap_weight_channel_noise_floor() - compute noise floor weight + * @sap_ctx: sap context * @chn_stat: Pointer to chan status info * - * Return: chan status weight + * Return: channel noise floor weight + */ +uint32_t sap_weight_channel_noise_floor(ptSapContext sap_ctx, + struct lim_channel_status *channel_stat) +{ + uint32_t noise_floor_weight; + uint8_t softap_nf_weight_cfg; + uint8_t softap_nf_weight_local; + + softap_nf_weight_cfg = + ACS_WEIGHT_SOFTAP_NOISE_FLOOR_CFG + (sap_ctx->auto_channel_select_weight); + + softap_nf_weight_local = + ACS_WEIGHT_CFG_TO_LOCAL(sap_ctx->auto_channel_select_weight, + softap_nf_weight_cfg); + + if (channel_stat == NULL || channel_stat->channelfreq == 0) { + VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO, + "In %s, Directly return max weight due to" + "sanity check failed.", __func__); + return softap_nf_weight_local; + } + + noise_floor_weight = (channel_stat->noise_floor == 0) ? 0 : + (ACS_WEIGHT_COMPUTE( + sap_ctx->auto_channel_select_weight, + softap_nf_weight_cfg, + channel_stat->noise_floor - + SOFTAP_MIN_NF, + SOFTAP_MAX_NF - SOFTAP_MIN_NF)); + + if (noise_floor_weight > softap_nf_weight_local) + noise_floor_weight = softap_nf_weight_local; + else if (noise_floor_weight < 0) + noise_floor_weight = 0; + + VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, + "In %s, nf=%d, nfwc=%d, nfwl=%d, nfw=%d", + __func__, channel_stat->noise_floor, + softap_nf_weight_cfg, softap_nf_weight_local, + noise_floor_weight); + + return noise_floor_weight; +} + +/** + * sap_weight_channel_free() - compute channel free weight + * @sap_ctx: sap context + * @chn_stat: Pointer to chan status info + * + * Return: channel free weight */ -uint32_t sap_weight_channel_status(struct lim_channel_status *channel_stat) +uint32_t sap_weight_channel_free(ptSapContext sap_ctx, + struct lim_channel_status *channel_stat) { - int32_t noisefloor_weight = 0; - uint32_t chnfree_weight = 0; - uint32_t txpwr_weight_lowspeed = 0; - uint32_t txpwr_weight_highspeed = 0; - uint32_t channelstatus_weight = 0; + uint32_t channel_free_weight; + uint8_t softap_channel_free_weight_cfg; + uint8_t softap_channel_free_weight_local; uint32_t rx_clear_count = 0; uint32_t cycle_count = 0; - uint32_t chan_tx_pwr_throughput = 0; - if (channel_stat == NULL || channel_stat->channelfreq == 0) - return 0; + softap_channel_free_weight_cfg = + ACS_WEIGHT_SOFTAP_CHANNEL_FREE_CFG + (sap_ctx->auto_channel_select_weight); + + softap_channel_free_weight_local = + ACS_WEIGHT_CFG_TO_LOCAL(sap_ctx->auto_channel_select_weight, + softap_channel_free_weight_cfg); + + if (channel_stat == NULL || channel_stat->channelfreq == 0) { + VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO, + "In %s, Directly return max weight due to" + "sanity check failed.", __func__); + return softap_channel_free_weight_local; + } rx_clear_count = channel_stat->rx_clear_count; cycle_count = channel_stat->cycle_count; - chan_tx_pwr_throughput = - channel_stat->chan_tx_pwr_throughput; - VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, - "chan id=%d freq=%d nf=%d rx_cnt=%d cycle_cnt=%d tx_pwr_throughput=%d", - channel_stat->channel_id, - channel_stat->channelfreq, channel_stat->noise_floor, - rx_clear_count, cycle_count, chan_tx_pwr_throughput); + /* LSH 4, otherwise it is always 0. */ + channel_free_weight = (cycle_count == 0) ? 0 : + (ACS_WEIGHT_COMPUTE( + sap_ctx->auto_channel_select_weight, + softap_channel_free_weight_cfg, + (rx_clear_count << 4)/cycle_count - + (SOFTAP_MIN_CHNFREE << 4), + (SOFTAP_MAX_CHNFREE - + SOFTAP_MIN_CHNFREE) << 4)); - noisefloor_weight = (channel_stat->noise_floor == 0) ? 0 : - (SOFTAP_NF_WEIGHT * - (channel_stat->noise_floor - SOFTAP_MIN_NF) - /(SOFTAP_MAX_NF - SOFTAP_MIN_NF)); + if (channel_free_weight > softap_channel_free_weight_local) + channel_free_weight = softap_channel_free_weight_local; - if (noisefloor_weight > SOFTAP_NF_WEIGHT) - noisefloor_weight = SOFTAP_NF_WEIGHT; - else if (noisefloor_weight < 0) - noisefloor_weight = 0; + VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, + "In %s, rcc=%d, cc=%d, cfwc=%d, cfwl=%d, cfw=%d", + __func__, rx_clear_count, cycle_count, + softap_channel_free_weight_cfg, + softap_channel_free_weight_local, + channel_free_weight); - chnfree_weight = (cycle_count == 0) ? 0 : - (SOFTAP_CHNFREE_WEIGHT * - (rx_clear_count/cycle_count - - SOFTAP_MIN_CHNFREE) - /(SOFTAP_MAX_CHNFREE - SOFTAP_MIN_CHNFREE)); + return channel_free_weight; +} - if (chnfree_weight > SOFTAP_CHNFREE_WEIGHT) - chnfree_weight = SOFTAP_CHNFREE_WEIGHT; +/** + * sap_weight_channel_txpwr_range() - compute channel tx power range weight + * @sap_ctx: sap context + * @chn_stat: Pointer to chan status info + * + * Return: tx power range weight + */ +uint32_t sap_weight_channel_txpwr_range(ptSapContext sap_ctx, + struct lim_channel_status *channel_stat) +{ + uint32_t txpwr_weight_low_speed; + uint8_t softap_txpwr_range_weight_cfg; + uint8_t softap_txpwr_range_weight_local; + + softap_txpwr_range_weight_cfg = + ACS_WEIGHT_SOFTAP_TX_POWER_RANGE_CFG + (sap_ctx->auto_channel_select_weight); + + softap_txpwr_range_weight_local = + ACS_WEIGHT_CFG_TO_LOCAL(sap_ctx->auto_channel_select_weight, + softap_txpwr_range_weight_cfg); + + if (channel_stat == NULL || channel_stat->channelfreq == 0) { + VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO, + "In %s, Directly return max weight due to" + "sanity check failed.", __func__); + return softap_txpwr_range_weight_local; + } - txpwr_weight_lowspeed = (channel_stat->chan_tx_pwr_range == 0) ? 0 : - (SOFTAP_TXPWR_WEIGHT * - (SOFTAP_MAX_TXPWR - - channel_stat->chan_tx_pwr_range) - /(SOFTAP_MAX_TXPWR - SOFTAP_MIN_TXPWR)); + txpwr_weight_low_speed = (channel_stat->chan_tx_pwr_range == 0) ? 0 : + (ACS_WEIGHT_COMPUTE( + sap_ctx->auto_channel_select_weight, + softap_txpwr_range_weight_cfg, + SOFTAP_MAX_TXPWR - + channel_stat->chan_tx_pwr_range, + SOFTAP_MAX_TXPWR - SOFTAP_MIN_TXPWR)); - if (txpwr_weight_lowspeed > SOFTAP_TXPWR_WEIGHT) - txpwr_weight_lowspeed = SOFTAP_TXPWR_WEIGHT; + if (txpwr_weight_low_speed > softap_txpwr_range_weight_local) + txpwr_weight_low_speed = softap_txpwr_range_weight_local; - txpwr_weight_highspeed = (chan_tx_pwr_throughput == 0) ? 0 : - (SOFTAP_TXPWR_WEIGHT * - (SOFTAP_MAX_TXPWR - - chan_tx_pwr_throughput) - /(SOFTAP_MAX_TXPWR - SOFTAP_MIN_TXPWR)); + VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, + "In %s, tpr=%d, tprwc=%d, tprwl=%d, tprw=%d", + __func__, channel_stat->chan_tx_pwr_range, + softap_txpwr_range_weight_cfg, + softap_txpwr_range_weight_local, + txpwr_weight_low_speed); - if (txpwr_weight_highspeed > SOFTAP_TXPWR_WEIGHT) - txpwr_weight_highspeed = SOFTAP_TXPWR_WEIGHT; + return txpwr_weight_low_speed; +} +/** + * sap_weight_channel_txpwr_tput() - compute channel tx power throughput weight + * @sap_ctx: sap context + * @chn_stat: Pointer to chan status info + * + * Return: tx power throughput weight + */ +uint32_t sap_weight_channel_txpwr_tput(ptSapContext sap_ctx, + struct lim_channel_status *channel_stat) +{ + uint32_t txpwr_weight_high_speed; + uint8_t softap_txpwr_tput_weight_cfg; + uint8_t softap_txpwr_tput_weight_local; + + softap_txpwr_tput_weight_cfg = + ACS_WEIGHT_SOFTAP_TX_POWER_THROUGHPUT_CFG + (sap_ctx->auto_channel_select_weight); + + softap_txpwr_tput_weight_local = + ACS_WEIGHT_CFG_TO_LOCAL(sap_ctx->auto_channel_select_weight, + softap_txpwr_tput_weight_cfg); + + if (channel_stat == NULL || channel_stat->channelfreq == 0) { + VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO, + "In %s, Directly return max weight due to" + "sanity check failed.", __func__); + return softap_txpwr_tput_weight_local; + } + + txpwr_weight_high_speed = (channel_stat->chan_tx_pwr_throughput == 0) ? 0 : + (ACS_WEIGHT_COMPUTE( + sap_ctx->auto_channel_select_weight, + softap_txpwr_tput_weight_cfg, + SOFTAP_MAX_TXPWR - + channel_stat->chan_tx_pwr_throughput, + SOFTAP_MAX_TXPWR - SOFTAP_MIN_TXPWR)); - channelstatus_weight = noisefloor_weight + chnfree_weight + - txpwr_weight_lowspeed + txpwr_weight_highspeed; + if (txpwr_weight_high_speed > softap_txpwr_tput_weight_local) + txpwr_weight_high_speed = softap_txpwr_tput_weight_local; VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, - "In %s, nfWt=%d, chnfreeWt=%d, txpwrLspeedWt=%d, txpwrHspeedWt=%d", - __func__, noisefloor_weight, chnfree_weight, - txpwr_weight_lowspeed, txpwr_weight_highspeed); + "In %s, tpt=%d, tptwc=%d, tptwl=%d, tptw=%d", + __func__, channel_stat->chan_tx_pwr_throughput, + softap_txpwr_tput_weight_cfg, + softap_txpwr_tput_weight_local, + txpwr_weight_high_speed); + + return txpwr_weight_high_speed; +} - return channelstatus_weight; +/** + * sap_weight_channel_status() - compute chan status weight + * @sap_ctx: sap context + * @chn_stat: Pointer to chan status info + * + * Return: chan status weight + */ +uint32_t sap_weight_channel_status(ptSapContext sap_ctx, + struct lim_channel_status *channel_stat) +{ + return sap_weight_channel_noise_floor(sap_ctx, channel_stat) + + sap_weight_channel_free(sap_ctx, channel_stat) + + sap_weight_channel_txpwr_range(sap_ctx, channel_stat) + + sap_weight_channel_txpwr_tput(sap_ctx, channel_stat); } /*========================================================================== @@ -1974,8 +2184,8 @@ void sapComputeSpectWeight( tSapChSelSpectInfo* pSpectInfoParams, rssi = (v_S7_t)pSpectCh->rssiAgr; pSpectCh->weight = SAPDFS_NORMALISE_1000 * - (sapweightRssiCount(rssi, pSpectCh->bssCount) - + sap_weight_channel_status( + (sapweightRssiCount(sap_ctx, rssi, pSpectCh->bssCount) + + sap_weight_channel_status(sap_ctx, sap_get_channel_status(pMac, pSpectCh->chNum))); pSpectCh->weight_copy = pSpectCh->weight; diff --git a/CORE/SAP/src/sapChSelect.h b/CORE/SAP/src/sapChSelect.h index 4392999e51ba..9ad66dbfec55 100644 --- a/CORE/SAP/src/sapChSelect.h +++ b/CORE/SAP/src/sapChSelect.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2014, 2016 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2017, 2017 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -78,8 +78,6 @@ #define SOFTAP_MAX_RSSI (0) #define SOFTAP_MIN_COUNT (0) #define SOFTAP_MAX_COUNT (60) -#define SOFTAP_RSSI_WEIGHT (20) -#define SOFTAP_COUNT_WEIGHT (20) #define SOFTAP_MIN_NF (-120) #define SOFTAP_MAX_NF (-60) @@ -88,11 +86,6 @@ #define SOFTAP_MIN_TXPWR (0) #define SOFTAP_MAX_TXPWR (63) -#define SOFTAP_NF_WEIGHT (20) -#define SOFTAP_CHNFREE_WEIGHT (20) -#define SOFTAP_TXPWR_WEIGHT (20) - - #define SAP_DEFAULT_24GHZ_CHANNEL (6) #define SAP_DEFAULT_LOW_5GHZ_CHANNEL (40) #define SAP_DEFAULT_MID_5GHZ_CHANNEL (100) diff --git a/CORE/SAP/src/sapInternal.h b/CORE/SAP/src/sapInternal.h index daa3d21881b0..e5dde94ae375 100644 --- a/CORE/SAP/src/sapInternal.h +++ b/CORE/SAP/src/sapInternal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -267,6 +267,7 @@ typedef struct sSapContext { eCsrBand currentPreferredBand; eCsrBand scanBandPreference; v_U16_t acsBandSwitchThreshold; + uint32_t auto_channel_select_weight; tSapAcsChannelInfo acsBestChannelInfo; tANI_BOOLEAN enableOverLapCh; diff --git a/CORE/SAP/src/sapModule.c b/CORE/SAP/src/sapModule.c index a8bc5d955036..607d7e08e395 100644 --- a/CORE/SAP/src/sapModule.c +++ b/CORE/SAP/src/sapModule.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -654,6 +654,7 @@ WLANSAP_SetScanAcsChannelParams(tsap_Config_t *pConfig, #endif pSapCtx->scanBandPreference = pConfig->scanBandPreference; pSapCtx->acsBandSwitchThreshold = pConfig->acsBandSwitchThreshold; + pSapCtx->auto_channel_select_weight = pConfig->auto_channel_select_weight; pSapCtx->pUsrContext = pUsrContext; pSapCtx->enableOverLapCh = pConfig->enOverLapCh; /* @@ -774,6 +775,8 @@ WLANSAP_StartBss #endif pSapCtx->scanBandPreference = pConfig->scanBandPreference; pSapCtx->acsBandSwitchThreshold = pConfig->acsBandSwitchThreshold; + pSapCtx->auto_channel_select_weight = + pConfig->auto_channel_select_weight; pSapCtx->pUsrContext = pUsrContext; pSapCtx->enableOverLapCh = pConfig->enOverLapCh; pSapCtx->acs_cfg = &pConfig->acs_cfg; diff --git a/CORE/SERVICES/WMA/wma.c b/CORE/SERVICES/WMA/wma.c index 857c53ce1668..31e37b6a66d3 100644 --- a/CORE/SERVICES/WMA/wma.c +++ b/CORE/SERVICES/WMA/wma.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2017 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -7922,43 +7922,51 @@ wma_chan_info_event_handler(void *handle, u_int8_t *event_buf, return -EINVAL; } event = param_buf->fixed_param; - if (event->cmd_flags == WMA_CHAN_END_RESP) { - channel_status = - vos_mem_malloc(sizeof(*channel_status)); - if (!channel_status) { - WMA_LOGE - (FL("Mem alloc fail")); - return -ENOMEM; - } - WMA_LOGI( - FL("freq=%d nf=%d rx_cnt=%d tx_pwr=%d"), - event->freq, - event->noise_floor, - event->rx_clear_count, - event->chan_tx_pwr_tp); - - channel_status->channelfreq = event->freq; - channel_status->noise_floor = event->noise_floor; - channel_status->rx_clear_count = - event->rx_clear_count; - channel_status->cycle_count = event->cycle_count; - channel_status->chan_tx_pwr_range = - event->chan_tx_pwr_range; - channel_status->chan_tx_pwr_throughput = - event->chan_tx_pwr_tp; - channel_status->rx_frame_count = - event->rx_frame_count; - channel_status->bss_rx_cycle_count = - event->my_bss_rx_cycle_count; - channel_status->rx_11b_mode_data_duration = - event->rx_11b_mode_data_duration; - channel_status->channel_id = - vos_freq_to_chan(event->freq); - - wma_send_msg(handle, - WDA_RX_CHN_STATUS_EVENT, - (void *) channel_status, 0); + channel_status = + vos_mem_malloc(sizeof(*channel_status)); + if (!channel_status) { + WMA_LOGE(FL("Mem alloc fail")); + return -ENOMEM; } + WMA_LOGI(FL("freq=%d nf=%d rx_cnt=%d cycle_count=%d " + "tx_pwr_range=%d tx_pwr_tput=%d " + "rx_frame_count=%d my_bss_rx_cycle_count=%d " + "rx_11b_mode_data_duration=%d cmd_flags=%d"), + event->freq, + event->noise_floor, + event->rx_clear_count, + event->cycle_count, + event->chan_tx_pwr_range, + event->chan_tx_pwr_tp, + event->rx_frame_count, + event->my_bss_rx_cycle_count, + event->rx_11b_mode_data_duration, + event->cmd_flags + ); + + channel_status->channelfreq = event->freq; + channel_status->noise_floor = event->noise_floor; + channel_status->rx_clear_count = + event->rx_clear_count; + channel_status->cycle_count = event->cycle_count; + channel_status->chan_tx_pwr_range = + event->chan_tx_pwr_range; + channel_status->chan_tx_pwr_throughput = + event->chan_tx_pwr_tp; + channel_status->rx_frame_count = + event->rx_frame_count; + channel_status->bss_rx_cycle_count = + event->my_bss_rx_cycle_count; + channel_status->rx_11b_mode_data_duration = + event->rx_11b_mode_data_duration; + channel_status->channel_id = + vos_freq_to_chan(event->freq); + channel_status->cmd_flags = + event->cmd_flags; + + wma_send_msg(handle, + WDA_RX_CHN_STATUS_EVENT, + (void *) channel_status, 0); } return 0; } |
