From a9cae43599306325954c2f3a7a3cbe513d6b4de1 Mon Sep 17 00:00:00 2001 From: Manjeet Singh Date: Tue, 28 Feb 2017 11:58:22 +0530 Subject: [PATCH] qcacld-3.0: Add support for band specific preference Add support for 5Ghz network RSSI boost/penalty preference based on ini values. Change-Id: Ia3ae5dcc35b9a85fde5a609f8f27ff8b4bc35cec CRs-fixed: 1085554 --- core/hdd/inc/wlan_hdd_cfg.h | 165 ++++++++++++++++++++++++++++++++++ core/hdd/src/wlan_hdd_cfg.c | 48 ++++++++++ core/hdd/src/wlan_hdd_main.c | 17 ++++ core/sme/inc/sme_api.h | 22 +++++ core/sme/src/common/sme_api.c | 44 +++++++++ 5 files changed, 296 insertions(+) diff --git a/core/hdd/inc/wlan_hdd_cfg.h b/core/hdd/inc/wlan_hdd_cfg.h index 52b5fcf729df..e3517cf915c1 100644 --- a/core/hdd/inc/wlan_hdd_cfg.h +++ b/core/hdd/inc/wlan_hdd_cfg.h @@ -9255,6 +9255,162 @@ enum dot11p_mode { #define CFG_RX_WAKELOCK_TIMEOUT_MIN (0) #define CFG_RX_WAKELOCK_TIMEOUT_MAX (100) +/* + * + * enable_5g_band_pref - Enable preference for 5G from INI. + * @Min: 0 + * @Max: 1 + * @Default: 0 + * This ini is used to enable 5G preference parameters. + * + * Related: 5g_rssi_boost_threshold, 5g_rssi_boost_factor, 5g_max_rssi_boost + * 5g_rssi_penalize_threshold, 5g_rssi_penalize_factor, 5g_max_rssi_penalize + * + * Supported Feature: 5G band preference + * + * Usage: External + * + * + */ + +#define CFG_ENABLE_5G_BAND_PREF_NAME "enable_5g_band_pref" +#define CFG_ENABLE_5G_BAND_PREF_MIN (0) +#define CFG_ENABLE_5G_BAND_PREF_MAX (1) +#define CFG_ENABLE_5G_BAND_PREF_DEFAULT (0) + +/* + * + * 5g_rssi_boost_threshold - A_band_boost_threshold above which 5 GHz is favored. + * @Min: -55 + * @Max: -70 + * @Default: -60 + * This ini is used to set threshold for 5GHz band preference. + * + * Related: 5g_rssi_boost_factor, 5g_max_rssi_boost + * 5g_rssi_penalize_threshold, 5g_rssi_penalize_factor, 5g_max_rssi_penalize + * + * Supported Feature: 5G band preference + * + * Usage: External + * + * + */ +#define CFG_5G_RSSI_BOOST_THRESHOLD_NAME "5g_rssi_boost_threshold" +#define CFG_5G_RSSI_BOOST_THRESHOLD_MIN (-55) +#define CFG_5G_RSSI_BOOST_THRESHOLD_MAX (-70) +#define CFG_5G_RSSI_BOOST_THRESHOLD_DEFAULT (-60) + +/* + * + * 5g_rssi_boost_factor - Factor by which 5GHz RSSI is boosted. + * @Min: 0 + * @Max: 2 + * @Default: 1 + * This ini is used to set the 5Ghz boost factor. + * + * Related: 5g_rssi_boost_threshold, 5g_max_rssi_boost + * 5g_rssi_penalize_threshold, 5g_rssi_penalize_factor, 5g_max_rssi_penalize + * + * Supported Feature: 5G band preference + * + * Usage: External + * + * + */ +#define CFG_5G_RSSI_BOOST_FACTOR_NAME "5g_rssi_boost_factor" +#define CFG_5G_RSSI_BOOST_FACTOR_MIN (0) +#define CFG_5G_RSSI_BOOST_FACTOR_MAX (2) +#define CFG_5G_RSSI_BOOST_FACTOR_DEFAULT (1) + +/* + * + * 5g_max_rssi_boost - Maximum boost that can be applied to 5GHz RSSI. + * @Min: 0 + * @Max: 20 + * @Default: 10 + * This ini is used to set maximum boost which can be given to a 5Ghz network. + * + * Related: 5g_rssi_boost_threshold, 5g_rssi_boost_factor + * 5g_rssi_penalize_threshold, 5g_rssi_penalize_factor, 5g_max_rssi_penalize + * + * Supported Feature: 5G band preference + * + * Usage: External + * + * + */ +#define CFG_5G_MAX_RSSI_BOOST_NAME "5g_max_rssi_boost" +#define CFG_5G_MAX_RSSI_BOOST_MIN (0) +#define CFG_5G_MAX_RSSI_BOOST_MAX (20) +#define CFG_5G_MAX_RSSI_BOOST_DEFAULT (10) + +/* + * + * 5g_rssi_penalize_threshold - A_band_penalize_threshold above which + * 5 GHz is not favored. + * @Min: -65 + * @Max: -80 + * @Default: -70 + * This ini is used to set threshold for 5GHz band preference. + * + * Related: 5g_rssi_penalize_factor, 5g_max_rssi_penalize + * 5g_rssi_boost_threshold, 5g_rssi_boost_factor, 5g_max_rssi_boost + * + * Supported Feature: 5G band preference + * + * Usage: External + * + * + */ +#define CFG_5G_RSSI_PENALIZE_THRESHOLD_NAME "5g_rssi_penalize_threshold" +#define CFG_5G_RSSI_PENALIZE_THRESHOLD_MIN (-65) +#define CFG_5G_RSSI_PENALIZE_THRESHOLD_MAX (-80) +#define CFG_5G_RSSI_PENALIZE_THRESHOLD_DEFAULT (-70) + +/* + * + * 5g_rssi_penalize_factor - Factor by which 5GHz RSSI is penalizeed. + * @Min: 0 + * @Max: 2 + * @Default: 1 + * This ini is used to set the 5Ghz penalize factor. + * + * Related: 5g_rssi_penalize_threshold, 5g_max_rssi_penalize + * 5g_rssi_boost_threshold, 5g_rssi_boost_factor, 5g_max_rssi_boost + * + * Supported Feature: 5G band preference + * + * Usage: External + * + * + */ +#define CFG_5G_RSSI_PENALIZE_FACTOR_NAME "5g_rssi_penalize_factor" +#define CFG_5G_RSSI_PENALIZE_FACTOR_MIN (0) +#define CFG_5G_RSSI_PENALIZE_FACTOR_MAX (2) +#define CFG_5G_RSSI_PENALIZE_FACTOR_DEFAULT (1) + +/* + * + * 5g_max_rssi_penalize - Maximum penalty that can be applied to 5GHz RSSI. + * @Min: 0 + * @Max: 20 + * @Default: 10 + * This ini is used to set maximum penalty which can be given to a 5Ghz network. + * + * Related: 5g_rssi_penalize_threshold, 5g_rssi_penalize_factor + * 5g_rssi_boost_threshold, 5g_rssi_boost_factor, 5g_max_rssi_boost + * + * Supported Feature: 5G band preference + * + * Usage: External + * + * + */ +#define CFG_5G_MAX_RSSI_PENALIZE_NAME "5g_max_rssi_penalize" +#define CFG_5G_MAX_RSSI_PENALIZE_MIN (0) +#define CFG_5G_MAX_RSSI_PENALIZE_MAX (20) +#define CFG_5G_MAX_RSSI_PENALIZE_DEFAULT (10) + /* * * g_max_sched_scan_plan_int - pno sched max scan plan interval. @@ -11528,6 +11684,15 @@ struct hdd_config { uint32_t num_disallowed_aps; bool oce_sta_enabled; bool oce_sap_enabled; + /* 5G preference parameters for boosting RSSI */ + bool enable_5g_band_pref; + int8_t rssi_boost_threshold_5g; + uint8_t rssi_boost_factor_5g; + uint8_t max_rssi_boost_5g; + /* 5G preference parameters for dropping RSSI*/ + int8_t rssi_penalize_threshold_5g; + uint8_t rssi_penalize_factor_5g; + uint8_t max_rssi_penalize_5g; }; #define VAR_OFFSET(_Struct, _Var) (offsetof(_Struct, _Var)) diff --git a/core/hdd/src/wlan_hdd_cfg.c b/core/hdd/src/wlan_hdd_cfg.c index 192fed5b46a5..84bd712f7cf3 100644 --- a/core/hdd/src/wlan_hdd_cfg.c +++ b/core/hdd/src/wlan_hdd_cfg.c @@ -4535,6 +4535,54 @@ struct reg_table_entry g_registry_table[] = { CFG_OCE_ENABLE_SAP_DEFAULT, CFG_OCE_ENABLE_SAP_MIN, CFG_OCE_ENABLE_SAP_MAX), + REG_VARIABLE(CFG_ENABLE_5G_BAND_PREF_NAME, WLAN_PARAM_Integer, + struct hdd_config, enable_5g_band_pref, + VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT, + CFG_ENABLE_5G_BAND_PREF_DEFAULT, + CFG_ENABLE_5G_BAND_PREF_MIN, + CFG_ENABLE_5G_BAND_PREF_MAX), + + REG_VARIABLE(CFG_5G_RSSI_BOOST_THRESHOLD_NAME, WLAN_PARAM_Integer, + struct hdd_config, rssi_boost_threshold_5g, + VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT, + CFG_5G_RSSI_BOOST_THRESHOLD_DEFAULT, + CFG_5G_RSSI_BOOST_THRESHOLD_MIN, + CFG_5G_RSSI_BOOST_THRESHOLD_MAX), + + REG_VARIABLE(CFG_5G_RSSI_BOOST_FACTOR_NAME, WLAN_PARAM_Integer, + struct hdd_config, rssi_boost_factor_5g, + VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT, + CFG_5G_RSSI_BOOST_FACTOR_DEFAULT, + CFG_5G_RSSI_BOOST_FACTOR_MIN, + CFG_5G_RSSI_BOOST_FACTOR_MAX), + + REG_VARIABLE(CFG_5G_MAX_RSSI_BOOST_NAME, WLAN_PARAM_Integer, + struct hdd_config, max_rssi_boost_5g, + VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT, + CFG_5G_MAX_RSSI_BOOST_DEFAULT, + CFG_5G_MAX_RSSI_BOOST_MIN, + CFG_5G_MAX_RSSI_BOOST_MAX), + + REG_VARIABLE(CFG_5G_RSSI_PENALIZE_THRESHOLD_NAME, WLAN_PARAM_Integer, + struct hdd_config, rssi_penalize_threshold_5g, + VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT, + CFG_5G_RSSI_PENALIZE_THRESHOLD_DEFAULT, + CFG_5G_RSSI_PENALIZE_THRESHOLD_MIN, + CFG_5G_RSSI_PENALIZE_THRESHOLD_MAX), + + REG_VARIABLE(CFG_5G_RSSI_PENALIZE_FACTOR_NAME, WLAN_PARAM_Integer, + struct hdd_config, rssi_penalize_factor_5g, + VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT, + CFG_5G_RSSI_PENALIZE_FACTOR_DEFAULT, + CFG_5G_RSSI_PENALIZE_FACTOR_MIN, + CFG_5G_RSSI_PENALIZE_FACTOR_MAX), + + REG_VARIABLE(CFG_5G_MAX_RSSI_PENALIZE_NAME, WLAN_PARAM_Integer, + struct hdd_config, max_rssi_penalize_5g, + VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT, + CFG_5G_MAX_RSSI_PENALIZE_DEFAULT, + CFG_5G_MAX_RSSI_PENALIZE_MIN, + CFG_5G_MAX_RSSI_PENALIZE_MAX), }; diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 3d673b249baf..d0d72ae47685 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -8886,6 +8886,7 @@ static int hdd_features_init(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter) { tSirTxPowerLimit hddtxlimit; QDF_STATUS status; + struct sme_5g_band_pref_params band_pref_params; int ret; ENTER(); @@ -8958,6 +8959,22 @@ static int hdd_features_init(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter) } } + if (hdd_ctx->config->enable_5g_band_pref) { + band_pref_params.rssi_boost_threshold_5g = + hdd_ctx->config->rssi_boost_threshold_5g; + band_pref_params.rssi_boost_factor_5g = + hdd_ctx->config->rssi_boost_factor_5g; + band_pref_params.max_rssi_boost_5g = + hdd_ctx->config->max_rssi_boost_5g; + band_pref_params.rssi_penalize_threshold_5g = + hdd_ctx->config->rssi_penalize_threshold_5g; + band_pref_params.rssi_penalize_factor_5g = + hdd_ctx->config->rssi_penalize_factor_5g; + band_pref_params.max_rssi_penalize_5g = + hdd_ctx->config->max_rssi_penalize_5g; + sme_set_5g_band_pref(hdd_ctx->hHal, &band_pref_params); + } + /* register P2P Listen Offload event callback */ if (wma_is_p2p_lo_capable()) sme_register_p2p_lo_event(hdd_ctx->hHal, hdd_ctx, diff --git a/core/sme/inc/sme_api.h b/core/sme/inc/sme_api.h index 7430373797be..77b5a971ed2d 100644 --- a/core/sme/inc/sme_api.h +++ b/core/sme/inc/sme_api.h @@ -219,6 +219,24 @@ struct sme_oem_capability { uint32_t reserved2; }; +/** + * struct sme_5g_pref_params : 5G preference params to be read from ini + * @rssi_boost_threshold_5g: RSSI threshold above which 5 GHz is favored + * @rssi_boost_factor_5g: Factor by which 5GHz RSSI is boosted + * @max_rssi_boost_5g: Maximum boost that can be applied to 5GHz RSSI + * @rssi_penalize_threshold_5g: RSSI threshold below which 5G is not favored + * @rssi_penalize_factor_5g: Factor by which 5GHz RSSI is penalized + * @max_rssi_penalize_5g: Maximum penalty that can be applied to 5G RSSI + */ +struct sme_5g_band_pref_params { + int8_t rssi_boost_threshold_5g; + uint8_t rssi_boost_factor_5g; + uint8_t max_rssi_boost_5g; + int8_t rssi_penalize_threshold_5g; + uint8_t rssi_penalize_factor_5g; + uint8_t max_rssi_penalize_5g; +}; + /*------------------------------------------------------------------------- Function declarations and documenation ------------------------------------------------------------------------*/ @@ -1662,4 +1680,8 @@ QDF_STATUS sme_get_peer_info_ext(tHalHandle hal, void *context, void (*callbackfn)(struct sir_peer_info_ext_resp *param, void *pcontext)); + +void sme_set_5g_band_pref(tHalHandle hal_handle, + struct sme_5g_band_pref_params *pref_params); + #endif /* #if !defined( __SME_API_H ) */ diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index 926d84fc88a5..4e53abbc5ce1 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -15979,6 +15979,50 @@ bool sme_roam_is_ese_assoc(tCsrRoamInfo *roam_info) { return roam_info->isESEAssoc; } + +/** + * sme_set_band_specific_pref(): If 5G preference is enabled,set boost/drop + * params from ini. + * @hal_handle: Handle returned by mac_open + * @5g_pref_params: pref params from ini. + * + * Returns: None + */ +void sme_set_5g_band_pref(tHalHandle hal_handle, + struct sme_5g_band_pref_params *pref_params) +{ + + tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle); + struct roam_ext_params *roam_params; + QDF_STATUS status = QDF_STATUS_SUCCESS; + + if (!pref_params) { + QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, + "Invalid 5G pref params!"); + return; + } + status = sme_acquire_global_lock(&mac_ctx->sme); + if (QDF_STATUS_SUCCESS == status) { + roam_params = &mac_ctx->roam.configParam.roam_params; + roam_params->raise_rssi_thresh_5g = + pref_params->rssi_boost_threshold_5g; + roam_params->raise_factor_5g = + pref_params->rssi_boost_factor_5g; + roam_params->max_raise_rssi_5g = + pref_params->max_rssi_boost_5g; + roam_params->drop_rssi_thresh_5g = + pref_params->rssi_penalize_threshold_5g; + roam_params->drop_factor_5g = + pref_params->rssi_penalize_factor_5g; + roam_params->max_drop_rssi_5g = + pref_params->max_rssi_penalize_5g; + + sme_release_global_lock(&mac_ctx->sme); + } else + QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, + "Unable to acquire global sme lock"); +} + #endif bool sme_neighbor_roam_is11r_assoc(tHalHandle hal_ctx, uint8_t session_id)