diff --git a/components/fw_offload/core/inc/wlan_fw_offload_main.h b/components/fw_offload/core/inc/wlan_fw_offload_main.h index a479691d54..0a29742d54 100644 --- a/components/fw_offload/core/inc/wlan_fw_offload_main.h +++ b/components/fw_offload/core/inc/wlan_fw_offload_main.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2012 - 2018 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -33,12 +33,40 @@ #define fwol_info(params...) QDF_TRACE_INFO(QDF_MODULE_ID_FWOL, params) #define fwol_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_FWOL, params) +/** + * struct wlan_fwol_three_antenna_btc - Three antenna BTC config items + * @btc_mode: Config BTC mode + * @antenna_isolation: Antenna isolation + * @max_tx_power_for_btc: Max wlan tx power in co-ex scenario + * @wlan_low_rssi_threshold: Wlan low rssi threshold for BTC mode switching + * @bt_low_rssi_threshold: BT low rssi threshold for BTC mode switching + * @bt_interference_low_ll: Lower limit of low level BT interference + * @bt_interference_low_ul: Upper limit of low level BT interference + * @bt_interference_medium_ll: Lower limit of medium level BT interference + * @bt_interference_medium_ul: Upper limit of medium level BT interference + * @bt_interference_high_ll: Lower limit of high level BT interference + * @bt_interference_high_ul: Upper limit of high level BT interference + */ +struct wlan_fwol_coex_config { + uint8_t btc_mode; + uint8_t antenna_isolation; + uint8_t max_tx_power_for_btc; + int16_t wlan_low_rssi_threshold; + int16_t bt_low_rssi_threshold; + int16_t bt_interference_low_ll; + int16_t bt_interference_low_ul; + int16_t bt_interference_medium_ll; + int16_t bt_interference_medium_ul; + int16_t bt_interference_high_ll; + int16_t bt_interference_high_ul; +}; + /** * struct wlan_fwol_cfg - fwol config items + * coex_config: coex config items */ struct wlan_fwol_cfg { - /* Add CFG and INI items here */ - int test; + struct wlan_fwol_coex_config coex_config; }; /** diff --git a/components/fw_offload/core/src/wlan_fw_offload_main.c b/components/fw_offload/core/src/wlan_fw_offload_main.c index 7c9cc28809..475890b269 100644 --- a/components/fw_offload/core/src/wlan_fw_offload_main.c +++ b/components/fw_offload/core/src/wlan_fw_offload_main.c @@ -28,6 +28,32 @@ struct wlan_fwol_psoc_obj *fwol_get_psoc_obj(struct wlan_objmgr_psoc *psoc) WLAN_UMAC_COMP_FWOL); } +static void +fwol_update_coex_config_in_cfg(struct wlan_objmgr_psoc *psoc, + struct wlan_fwol_coex_config *coex_config) +{ + coex_config->btc_mode = cfg_get(psoc, CFG_BTC_MODE); + coex_config->antenna_isolation = cfg_get(psoc, CFG_ANTENNA_ISOLATION); + coex_config->max_tx_power_for_btc = + cfg_get(psoc, CFG_MAX_TX_POWER_FOR_BTC); + coex_config->wlan_low_rssi_threshold = + cfg_get(psoc, CFG_WLAN_LOW_RSSI_THRESHOLD); + coex_config->bt_low_rssi_threshold = + cfg_get(psoc, CFG_BT_LOW_RSSI_THRESHOLD); + coex_config->bt_interference_low_ll = + cfg_get(psoc, CFG_BT_INTERFERENCE_LOW_LL); + coex_config->bt_interference_low_ul = + cfg_get(psoc, CFG_BT_INTERFERENCE_LOW_UL); + coex_config->bt_interference_medium_ll = + cfg_get(psoc, CFG_BT_INTERFERENCE_MEDIUM_LL); + coex_config->bt_interference_medium_ul = + cfg_get(psoc, CFG_BT_INTERFERENCE_MEDIUM_UL); + coex_config->bt_interference_high_ll = + cfg_get(psoc, CFG_BT_INTERFERENCE_HIGH_LL); + coex_config->bt_interference_high_ul = + cfg_get(psoc, CFG_BT_INTERFERENCE_HIGH_UL); +} + QDF_STATUS fwol_cfg_on_psoc_enable(struct wlan_objmgr_psoc *psoc) { QDF_STATUS status = QDF_STATUS_SUCCESS; @@ -41,7 +67,8 @@ QDF_STATUS fwol_cfg_on_psoc_enable(struct wlan_objmgr_psoc *psoc) } fwol_cfg = &fwol_obj->cfg; - /* Populate the CFG and INI here using CFG_GET */ + + fwol_update_coex_config_in_cfg(psoc, &fwol_cfg->coex_config); return status; } diff --git a/components/fw_offload/dispatcher/inc/cfg_coex.h b/components/fw_offload/dispatcher/inc/cfg_coex.h new file mode 100644 index 0000000000..11f68c0037 --- /dev/null +++ b/components/fw_offload/dispatcher/inc/cfg_coex.h @@ -0,0 +1,251 @@ +/* + * Copyright (c) 2012 - 2018 The Linux Foundation. All rights reserved. + * + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all + * copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/** + * DOC: This file contains centralized definitions of converged configuration. + */ + +#ifndef __CFG_COEX_H +#define __CFG_COEX_H + +/* + * + * gSetBTCMode - Config BTC mode + * @Min: 0 + * @Max: 2 + * @Default: 0 + * + * 0 - TDD + * 1 - FDD + * 2 - Hybrid + * + * Usage: External + * + * + */ +#define CFG_BTC_MODE CFG_INI_UINT( \ + "gSetBTCMode", \ + 0, \ + 2, \ + 0, \ + CFG_VALUE_OR_DEFAULT, \ + "BTC mode") + +/* + * + * gSetAntennaIsolation - Set Antenna Isolation + * @Min: 0 + * @Max: 255 + * @Default: 25 + * + * Usage: External + * + * + */ +#define CFG_ANTENNA_ISOLATION CFG_INI_UINT( \ + "gSetAntennaIsolation", \ + 0, \ + 255, \ + 25, \ + CFG_VALUE_OR_DEFAULT, \ + "Antenna Isolation") + +/* + * + * gSetMaxTxPowerForBTC - Set Max WLAN Tx power in COEX scenario + * @Min: 0 + * @Max: 100 + * @Default: 100 + * + * Usage: External + * + * + */ +#define CFG_MAX_TX_POWER_FOR_BTC CFG_INI_UINT( \ + "gSetMaxTxPowerForBTC", \ + 0, \ + 100, \ + 100, \ + CFG_VALUE_OR_DEFAULT, \ + "Max Tx Power for BTC") + +/* + * + * gSetWlanLowRssiThreshold - Set WLAN low RSSI threshold for BTC mode switching + * @Min: -100 + * @Max: 0 + * @Default: -80 + * + * Usage: External + * + * + */ +#define CFG_WLAN_LOW_RSSI_THRESHOLD CFG_INI_INT( \ + "gSetWlanLowRssiThreshold", \ + -100, \ + 0, \ + -80, \ + CFG_VALUE_OR_DEFAULT, \ + "WLAN Low RSSI Threshold") + +/* + * + * gSetBtLowRssiThreshold - Set BT low RSSI threshold for BTC mode switching + * @Min: -100 + * @Max: 0 + * @Default: -80 + * + * Usage: External + * + * + */ +#define CFG_BT_LOW_RSSI_THRESHOLD CFG_INI_INT( \ + "gSetBtLowRssiThreshold", \ + -100, \ + 0, \ + -80, \ + CFG_VALUE_OR_DEFAULT, \ + "BT Low RSSI Threshold") + +/* + * + * gSetBtInterferenceLowLL - Set lower limit of low level BT interference + * @Min: -100 + * @Max: 100 + * @Default: -25 + * + * Usage: External + * + * + */ +#define CFG_BT_INTERFERENCE_LOW_LL CFG_INI_INT( \ + "gSetBtInterferenceLowLL", \ + -100, \ + 100, \ + -25, \ + CFG_VALUE_OR_DEFAULT, \ + "BT Interference Low LL") + +/* + * + * gSetBtInterferenceLowUL - Set upper limit of low level BT interference + * @Min: -100 + * @Max: 100 + * @Default: -21 + * + * Usage: External + * + * + */ +#define CFG_BT_INTERFERENCE_LOW_UL CFG_INI_INT( \ + "gSetBtInterferenceLowUL", \ + -100, \ + 100, \ + -21, \ + CFG_VALUE_OR_DEFAULT, \ + "BT Interference Low UL") + +/* + * + * gSetBtInterferenceMediumLL - Set lower limit of medium level BT interference + * @Min: -100 + * @Max: 100 + * @Default: -20 + * + * Usage: External + * + * + */ +#define CFG_BT_INTERFERENCE_MEDIUM_LL CFG_INI_INT( \ + "gSetBtInterferenceMediumLL", \ + -100, \ + 100, \ + -20, \ + CFG_VALUE_OR_DEFAULT, \ + "BT Interference Medium LL") + +/* + * + * gSetBtInterferenceMediumUL - Set upper limit of medium level BT interference + * @Min: -100 + * @Max: 100 + * @Default: -16 + * + * Usage: External + * + * + */ +#define CFG_BT_INTERFERENCE_MEDIUM_UL CFG_INI_INT( \ + "gSetBtInterferenceMediumUL", \ + -100, \ + 100, \ + -16, \ + CFG_VALUE_OR_DEFAULT, \ + "BT Interference Medium UL") + +/* + * + * gSetBtInterferenceHighLL - Set lower limit of high level BT interference + * @Min: -100 + * @Max: 100 + * @Default: -15 + * + * Usage: External + * + * + */ +#define CFG_BT_INTERFERENCE_HIGH_LL CFG_INI_INT( \ + "gSetBtInterferenceHighLL", \ + -100, \ + 100, \ + -15, \ + CFG_VALUE_OR_DEFAULT, \ + "BT Interference High LL") + +/* + * + * gSetBtInterferenceHighUL - Set upper limit of high level BT interference + * @Min: -100 + * @Max: 100 + * @Default: -11 + * + * Usage: External + * + * + */ +#define CFG_BT_INTERFERENCE_HIGH_UL CFG_INI_INT( \ + "gSetBtInterferenceHighUL", \ + -100, \ + 100, \ + -11, \ + CFG_VALUE_OR_DEFAULT, \ + "BT Interference High UL") + +#define CFG_COEX_ALL \ + CFG(CFG_BTC_MODE) \ + CFG(CFG_ANTENNA_ISOLATION) \ + CFG(CFG_MAX_TX_POWER_FOR_BTC) \ + CFG(CFG_WLAN_LOW_RSSI_THRESHOLD) \ + CFG(CFG_BT_LOW_RSSI_THRESHOLD) \ + CFG(CFG_BT_INTERFERENCE_LOW_LL) \ + CFG(CFG_BT_INTERFERENCE_LOW_UL) \ + CFG(CFG_BT_INTERFERENCE_MEDIUM_LL) \ + CFG(CFG_BT_INTERFERENCE_MEDIUM_UL) \ + CFG(CFG_BT_INTERFERENCE_HIGH_LL) \ + CFG(CFG_BT_INTERFERENCE_HIGH_UL) +#endif diff --git a/components/fw_offload/dispatcher/inc/cfg_fwol.h b/components/fw_offload/dispatcher/inc/cfg_fwol.h index a6ee83bef1..29f9321f3b 100644 --- a/components/fw_offload/dispatcher/inc/cfg_fwol.h +++ b/components/fw_offload/dispatcher/inc/cfg_fwol.h @@ -23,7 +23,10 @@ #include "cfg_converged.h" #include "qdf_types.h" -#define CFG_FWOL_ALL +#include "cfg_coex.h" + +#define CFG_FWOL_ALL \ + CFG_COEX_ALL #endif /* __CFG_FWOL_H */ diff --git a/components/fw_offload/dispatcher/inc/wlan_fwol_ucfg_api.h b/components/fw_offload/dispatcher/inc/wlan_fwol_ucfg_api.h index 418c451957..41e3fb28ef 100644 --- a/components/fw_offload/dispatcher/inc/wlan_fwol_ucfg_api.h +++ b/components/fw_offload/dispatcher/inc/wlan_fwol_ucfg_api.h @@ -26,6 +26,8 @@ #include #include +#include "wlan_fw_offload_main.h" + /** * ucfg_fwol_psoc_open() - FWOL component Open * @psoc: pointer to psoc object @@ -64,4 +66,15 @@ QDF_STATUS ucfg_fwol_init(void); */ void ucfg_fwol_deinit(void); +/** + * ucfg_fwol_get_coex_config_params() - Get coex config params + * @psoc: Pointer to psoc object + * @coex_config: Pointer to struct wlan_fwol_coex_config + * + * Return: QDF_STATUS + */ +QDF_STATUS +ucfg_fwol_get_coex_config_params(struct wlan_objmgr_psoc *psoc, + struct wlan_fwol_coex_config *coex_config); + #endif /* _WLAN_FWOL_UCFG_API_H_ */ diff --git a/components/fw_offload/dispatcher/src/wlan_fwol_ucfg_api.c b/components/fw_offload/dispatcher/src/wlan_fwol_ucfg_api.c index d9a5d3af3e..aa86662843 100644 --- a/components/fw_offload/dispatcher/src/wlan_fwol_ucfg_api.c +++ b/components/fw_offload/dispatcher/src/wlan_fwol_ucfg_api.c @@ -149,3 +149,19 @@ void ucfg_fwol_deinit(void) fwol_err("unable to unregister psoc create handle"); } +QDF_STATUS +ucfg_fwol_get_coex_config_params(struct wlan_objmgr_psoc *psoc, + struct wlan_fwol_coex_config *coex_config) +{ + struct wlan_fwol_psoc_obj *fwol_obj; + + fwol_obj = fwol_get_psoc_obj(psoc); + if (!fwol_obj) { + fwol_err("Failed to get fwol obj"); + return QDF_STATUS_E_FAILURE; + } + + *coex_config = fwol_obj->cfg.coex_config; + + return QDF_STATUS_SUCCESS; +} diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 61d062a001..605a8a130c 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -4550,6 +4550,108 @@ error: return -EINVAL; } +/** + * hdd_send_coex_config_params() - Send coex config params to FW + * @hdd_ctx: HDD context + * @adapter: Primary adapter context + * + * This function is used to send all coex config related params to FW + * + * Return: 0 on success and -EINVAL on failure + */ +static int hdd_send_coex_config_params(struct hdd_context *hdd_ctx, + struct hdd_adapter *adapter) +{ + struct coex_config_params coex_cfg_params = {0}; + struct wlan_fwol_coex_config config = {0}; + struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; + QDF_STATUS status; + + if (!hdd_ctx) { + hdd_err("hdd_ctx is invalid"); + goto err; + } + + if (!adapter) { + hdd_err("adapter is invalid"); + goto err; + } + + if (!psoc) { + hdd_err("HDD psoc is invalid"); + goto err; + } + + status = ucfg_fwol_get_coex_config_params(psoc, &config); + if (QDF_IS_STATUS_ERROR(status)) { + hdd_err("Unable to get coex config params"); + goto err; + } + + coex_cfg_params.vdev_id = adapter->session_id; + coex_cfg_params.config_type = WMI_COEX_CONFIG_TX_POWER; + coex_cfg_params.config_arg1 = config.max_tx_power_for_btc; + + status = sme_send_coex_config_cmd(&coex_cfg_params); + if (QDF_IS_STATUS_ERROR(status)) { + hdd_err("Failed to send coex Tx power"); + goto err; + } + + coex_cfg_params.config_type = WMI_COEX_CONFIG_HANDOVER_RSSI; + coex_cfg_params.config_arg1 = config.wlan_low_rssi_threshold; + + status = sme_send_coex_config_cmd(&coex_cfg_params); + if (QDF_IS_STATUS_ERROR(status)) { + hdd_err("Failed to send coex handover RSSI"); + goto err; + } + + coex_cfg_params.config_type = WMI_COEX_CONFIG_BTC_MODE; + coex_cfg_params.config_arg1 = config.btc_mode; + + status = sme_send_coex_config_cmd(&coex_cfg_params); + if (QDF_IS_STATUS_ERROR(status)) { + hdd_err("Failed to send coex BTC mode"); + goto err; + } + + coex_cfg_params.config_type = WMI_COEX_CONFIG_ANTENNA_ISOLATION; + coex_cfg_params.config_arg1 = config.antenna_isolation; + + status = sme_send_coex_config_cmd(&coex_cfg_params); + if (QDF_IS_STATUS_ERROR(status)) { + hdd_err("Failed to send coex antenna isolation"); + goto err; + } + + coex_cfg_params.config_type = WMI_COEX_CONFIG_BT_LOW_RSSI_THRESHOLD; + coex_cfg_params.config_arg1 = config.bt_low_rssi_threshold; + + status = sme_send_coex_config_cmd(&coex_cfg_params); + if (QDF_IS_STATUS_ERROR(status)) { + hdd_err("Failed to send coex BT low RSSI threshold"); + goto err; + } + + coex_cfg_params.config_type = WMI_COEX_CONFIG_BT_INTERFERENCE_LEVEL; + coex_cfg_params.config_arg1 = config.bt_interference_low_ll; + coex_cfg_params.config_arg2 = config.bt_interference_low_ul; + coex_cfg_params.config_arg3 = config.bt_interference_medium_ll; + coex_cfg_params.config_arg4 = config.bt_interference_medium_ul; + coex_cfg_params.config_arg5 = config.bt_interference_high_ll; + coex_cfg_params.config_arg6 = config.bt_interference_high_ul; + + status = sme_send_coex_config_cmd(&coex_cfg_params); + if (QDF_IS_STATUS_ERROR(status)) { + hdd_err("Failed to send coex BT interference level"); + goto err; + } + return 0; +err: + return -EINVAL; +} + /** * hdd_set_fw_params() - Set parameters to firmware * @adapter: HDD adapter @@ -4701,6 +4803,13 @@ int hdd_set_fw_params(struct hdd_adapter *adapter) } hdd_set_fw_log_params(hdd_ctx, adapter); + + ret = hdd_send_coex_config_params(hdd_ctx, adapter); + if (ret) { + hdd_warn("Error initializing coex config params"); + goto error; + } + hdd_exit(); return 0; diff --git a/core/sme/inc/sme_api.h b/core/sme/inc/sme_api.h index 3c7d8f1535..454633f8ee 100644 --- a/core/sme/inc/sme_api.h +++ b/core/sme/inc/sme_api.h @@ -1775,6 +1775,14 @@ QDF_STATUS sme_get_sar_power_limits(tHalHandle hal, QDF_STATUS sme_set_sar_power_limits(tHalHandle hal, struct sar_limit_cmd_params *sar_limit_cmd); +/** + * sme_send_coex_config_cmd() - Send COEX config params + * @coex_cfg_params: struct to coex config params + * + * Return: QDF_STATUS + */ +QDF_STATUS sme_send_coex_config_cmd(struct coex_config_params *coex_cfg_params); + void sme_set_cc_src(tHalHandle hal_handle, enum country_src); diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index be83f9267c..9f605aa870 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -14774,6 +14774,18 @@ QDF_STATUS sme_set_sar_power_limits(tHalHandle hal, return wma_set_sar_limit(wma_handle, sar_limit_cmd); } +QDF_STATUS sme_send_coex_config_cmd(struct coex_config_params *coex_cfg_params) +{ + void *wma_handle; + + wma_handle = cds_get_context(QDF_MODULE_ID_WMA); + if (!wma_handle) { + sme_err("wma handle is NULL"); + return QDF_STATUS_E_FAILURE; + } + return wma_send_coex_config_cmd(wma_handle, coex_cfg_params); +} + #ifdef WLAN_FEATURE_FIPS QDF_STATUS sme_fips_request(tHalHandle hal, struct fips_params *param, wma_fips_cb callback, void *context) diff --git a/core/wma/inc/wma_api.h b/core/wma/inc/wma_api.h index efb77b1c62..ca3ce0f2ed 100644 --- a/core/wma/inc/wma_api.h +++ b/core/wma/inc/wma_api.h @@ -320,6 +320,18 @@ QDF_STATUS wma_get_sar_limit(WMA_HANDLE handle, QDF_STATUS wma_set_sar_limit(WMA_HANDLE handle, struct sar_limit_cmd_params *sar_limit_params); +/** + * wma_send_coex_config_cmd() - Send coex config params + * @wma_handle: wma handle + * @coex_cfg_params: struct to coex cofig params + * + * This function sends WMI command to send coex cofig params + * + * Return: QDF_STATUS + */ +QDF_STATUS wma_send_coex_config_cmd(WMA_HANDLE wma_handle, + struct coex_config_params *coex_cfg_params); + /** * wma_set_qpower_config() - update qpower config in wma * @vdev_id: the Id of the vdev to configure diff --git a/core/wma/src/wma_features.c b/core/wma/src/wma_features.c index 676a63ea49..9de9bd2f8b 100644 --- a/core/wma/src/wma_features.c +++ b/core/wma/src/wma_features.c @@ -5397,6 +5397,26 @@ QDF_STATUS wma_set_sar_limit(WMA_HANDLE handle, return ret; } +QDF_STATUS wma_send_coex_config_cmd(WMA_HANDLE wma_handle, + struct coex_config_params *coex_cfg_params) +{ + tp_wma_handle wma = (tp_wma_handle)wma_handle; + + if (!wma || !wma->wmi_handle) { + WMA_LOGE("%s: WMA is closed, can not issue coex config command", + __func__); + return QDF_STATUS_E_INVAL; + } + + if (!coex_cfg_params) { + WMA_LOGE("%s: coex cfg params ptr NULL", __func__); + return QDF_STATUS_E_INVAL; + } + + return wmi_unified_send_coex_config_cmd(wma->wmi_handle, + coex_cfg_params); +} + /** * wma_get_arp_stats_handler() - handle arp stats data * indicated by FW