From 80f96b5b4b36b9f74dcf0b750665393bfe240d3d Mon Sep 17 00:00:00 2001 From: "Chandrasekaran, Manishekar" Date: Tue, 20 Jan 2015 11:24:02 +0530 Subject: qcacld: Enable/Disable MAS during STA+Miracast MCC and adjust quota When miracast session starts and MCC is in place, MAS will be disabled and 70% quota will be provided to P2P interface. When miracast session ends, MAS will be enabled and 50-50 quota will be restored back to STA-P2P interfaces. Change-Id: I58538ddd68fcc5ae19973d0d13d95b14131f8652 CRs-Fixed: 775989 --- CORE/HDD/inc/wlan_hdd_main.h | 6 ++ CORE/HDD/src/wlan_hdd_assoc.c | 8 ++ CORE/HDD/src/wlan_hdd_main.c | 183 +++++++++++++++++++++++++++++++++++++- CORE/MAC/src/include/sirParams.h | 3 + CORE/SERVICES/WMA/wma.c | 38 ++++++++ CORE/SME/inc/smeInternal.h | 3 +- CORE/SME/inc/sme_Api.h | 24 +++++ CORE/SME/src/sme_common/sme_Api.c | 82 +++++++++++++++++ 8 files changed, 344 insertions(+), 3 deletions(-) diff --git a/CORE/HDD/inc/wlan_hdd_main.h b/CORE/HDD/inc/wlan_hdd_main.h index d90d9dedd873..598dd4389393 100644 --- a/CORE/HDD/inc/wlan_hdd_main.h +++ b/CORE/HDD/inc/wlan_hdd_main.h @@ -1140,6 +1140,9 @@ struct hdd_adapter_s /* Set mac address locally administered bit */ #define WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macaddr) (macaddr[0] &= 0xFD) +#define HDD_DEFAULT_MCC_P2P_QUOTA 70 +#define HDD_RESET_MCC_P2P_QUOTA 50 + typedef struct hdd_adapter_list_node { hdd_list_node_t node; // MUST be first element @@ -1518,6 +1521,7 @@ struct hdd_context_s atomic_t auto_suspend_state; atomic_t auto_suspend_stop_requested; #endif + uint8_t miracast_value; }; /*--------------------------------------------------------------------------- @@ -1757,4 +1761,6 @@ int hdd_wlan_go_set_mcc_p2p_quota(hdd_adapter_t *hostapd_adapter, uint32_t set_value); int hdd_wlan_set_mcc_p2p_quota(hdd_adapter_t *hostapd_adapter, uint32_t set_value); +int hdd_set_mas(hdd_adapter_t *hostapd_adapter, uint8_t filter_type); +uint8_t hdd_is_mcc_in_24G(hdd_context_t *hdd_ctx); #endif // end #if !defined( WLAN_HDD_MAIN_H ) diff --git a/CORE/HDD/src/wlan_hdd_assoc.c b/CORE/HDD/src/wlan_hdd_assoc.c index 7869352ccd5b..6c38b0d8e95c 100644 --- a/CORE/HDD/src/wlan_hdd_assoc.c +++ b/CORE/HDD/src/wlan_hdd_assoc.c @@ -1416,6 +1416,8 @@ static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCs int ft_carrier_on = FALSE; #endif v_BOOL_t hddDisconInProgress = FALSE; + tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); + tpAniSirGlobal pMac = PMAC_STRUCT(hHal); unsigned long rc; hdd_adapter_t *sap_adapter; hdd_ap_ctx_t *hdd_ap_ctx; @@ -1472,6 +1474,12 @@ static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCs /* Indicate 'connect' status to user space */ hdd_SendAssociationEvent(dev,pRoamInfo); + if (hdd_is_mcc_in_24G(pHddCtx)) { + if ((pMac != NULL) && (pHddCtx->miracast_value)) { + hdd_set_mas(pAdapter, pHddCtx->miracast_value); + } + } + // Initialize the Linkup event completion variable INIT_COMPLETION(pAdapter->linkup_event_var); diff --git a/CORE/HDD/src/wlan_hdd_main.c b/CORE/HDD/src/wlan_hdd_main.c index 239633212036..b45c55f22c5c 100755 --- a/CORE/HDD/src/wlan_hdd_main.c +++ b/CORE/HDD/src/wlan_hdd_main.c @@ -4726,13 +4726,18 @@ static void hdd_wma_send_fastreassoc_cmd(int sessionId, tSirMacAddr bssid, int hdd_set_miracast_mode(hdd_adapter_t *pAdapter, tANI_U8 *command) { tHalHandle hHal = WLAN_HDD_GET_CTX(pAdapter)->hHal; - tpAniSirGlobal pMac = PMAC_STRUCT(hHal); tANI_U8 filterType = 0; + hdd_context_t *pHddCtx = NULL; tANI_U8 *value; int ret; + eHalStatus ret_status; value = command + 9; + pHddCtx = WLAN_HDD_GET_CTX(pAdapter); + if (!pHddCtx) + return -EFAULT; + /* Convert the value from ascii to integer */ ret = kstrtou8(value, 10, &filterType); if (ret < 0) { @@ -4751,10 +4756,184 @@ int hdd_set_miracast_mode(hdd_adapter_t *pAdapter, tANI_U8 *command) return -EINVAL; } hddLog(VOS_TRACE_LEVEL_INFO, "%s: miracast mode %hu", __func__, filterType); - pMac->fMiracastSessionPresent = filterType; + pHddCtx->miracast_value = filterType; + + ret_status = sme_set_miracast(hHal, filterType); + if (eHAL_STATUS_SUCCESS != ret_status) { + hddLog(LOGE, "Failed to set miracast"); + return -EBUSY; + } + + if (hdd_is_mcc_in_24G(pHddCtx)) { + return hdd_set_mas(pAdapter, filterType); + } + return 0; } +/** + * hdd_set_mas() - Function to set MAS value to UMAC + * @adapter: Pointer to HDD adapter + * @mas_value: 0-Disable, 1-Enable MAS + * + * This function passes down the value of MAS to UMAC + * + * Return: Configuration message posting status, SUCCESS or Fail + * + */ +int32_t hdd_set_mas(hdd_adapter_t *adapter, tANI_U8 mas_value) +{ + hdd_context_t *hdd_ctx = NULL; + eHalStatus ret_status; + + hdd_ctx = WLAN_HDD_GET_CTX(adapter); + if (!hdd_ctx) + return -EFAULT; + + if (mas_value) { + /* Miracast is ON. Disable MAS and configure P2P quota */ + if (hdd_ctx->cfg_ini->enableMCCAdaptiveScheduler) { + if (cfgSetInt(hdd_ctx->hHal, + WNI_CFG_ENABLE_MCC_ADAPTIVE_SCHED, 0) + != eSIR_SUCCESS) { + hddLog(LOGE, + "Could not pass on WNI_CFG_ENABLE_MCC_ADAPTIVE_SCHED to CCM"); + } + + ret_status = sme_set_mas(false); + if (eHAL_STATUS_SUCCESS != ret_status) { + hddLog(LOGE, "Failed to disable MAS"); + return -EBUSY; + } + } + + /* Config p2p quota */ + if (adapter->device_mode == WLAN_HDD_INFRA_STATION) + hdd_wlan_set_mcc_p2p_quota(adapter, + 100 - HDD_DEFAULT_MCC_P2P_QUOTA); + else if (adapter->device_mode == WLAN_HDD_P2P_GO) + hdd_wlan_go_set_mcc_p2p_quota(adapter, + HDD_DEFAULT_MCC_P2P_QUOTA); + else + hdd_wlan_set_mcc_p2p_quota(adapter, + HDD_DEFAULT_MCC_P2P_QUOTA); + } else { + /* Reset p2p quota */ + if (adapter->device_mode == WLAN_HDD_P2P_GO) + hdd_wlan_go_set_mcc_p2p_quota(adapter, + HDD_RESET_MCC_P2P_QUOTA); + else + hdd_wlan_set_mcc_p2p_quota(adapter, + HDD_RESET_MCC_P2P_QUOTA); + + /* Miracast is OFF. Enable MAS and reset P2P quota */ + if (hdd_ctx->cfg_ini->enableMCCAdaptiveScheduler) { + if (cfgSetInt(hdd_ctx->hHal, + WNI_CFG_ENABLE_MCC_ADAPTIVE_SCHED, 1) + != eSIR_SUCCESS) { + hddLog(LOGE, "Could not pass on WNI_CFG_ENABLE_MCC_ADAPTIVE_SCHED to CCM"); + } + + /* Enable MAS */ + ret_status = sme_set_mas(true); + if (eHAL_STATUS_SUCCESS != ret_status) { + hddLog(LOGE, "Unable to enable MAS"); + return -EBUSY; + } + } + } + + return 0; +} + +/** + * hdd_is_mcc_in_24G() - Function to check for MCC in 2.4GHz + * @hdd_ctx: Pointer to HDD context + * + * This function is used to check for MCC operation in 2.4GHz band. + * STA, P2P and SAP adapters are only considered. + * + * Return: Non zero value if MCC is detected in 2.4GHz band + * + */ +uint8_t hdd_is_mcc_in_24G(hdd_context_t *hdd_ctx) +{ + VOS_STATUS status; + hdd_adapter_t *hdd_adapter = NULL; + hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; + uint8_t ret = 0; + hdd_station_ctx_t *sta_ctx; + hdd_ap_ctx_t *ap_ctx; + uint8_t ch1 = 0, ch2 = 0; + uint8_t channel = 0; + hdd_hostapd_state_t *hostapd_state; + + status = hdd_get_front_adapter(hdd_ctx, &adapter_node); + + /* loop through all adapters and check MCC for STA,P2P,SAP adapters */ + while (NULL != adapter_node && VOS_STATUS_SUCCESS == status) { + hdd_adapter = adapter_node->pAdapter; + + if (!((hdd_adapter->device_mode >= WLAN_HDD_INFRA_STATION) + || (hdd_adapter->device_mode + <= WLAN_HDD_P2P_GO))) { + /* skip for other adapters */ + status = hdd_get_next_adapter(hdd_ctx, + adapter_node, &next); + adapter_node = next; + continue; + } else { + if (WLAN_HDD_INFRA_STATION == + hdd_adapter->device_mode || + WLAN_HDD_P2P_CLIENT == + hdd_adapter->device_mode) { + sta_ctx = + WLAN_HDD_GET_STATION_CTX_PTR( + hdd_adapter); + if (eConnectionState_Associated == + sta_ctx->conn_info.connState) + channel = + sta_ctx->conn_info. + operationChannel; + } else if (WLAN_HDD_P2P_GO == + hdd_adapter->device_mode || + WLAN_HDD_SOFTAP == + hdd_adapter->device_mode) { + ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(hdd_adapter); + hostapd_state = + WLAN_HDD_GET_HOSTAP_STATE_PTR( + hdd_adapter); + if (hostapd_state->bssState == BSS_START && + hostapd_state->vosStatus == + VOS_STATUS_SUCCESS) + channel = ap_ctx->operatingChannel; + } + + if ((ch1 == 0) || + ((ch2 != 0) && (ch2 != channel))) { + ch1 = channel; + } else if ((ch2 == 0) || + ((ch1 != 0) && (ch1 != channel))) { + ch2 = channel; + } + + if ((ch1 != 0 && ch2 != 0) && (ch1 != ch2) && + ((ch1 <= SIR_11B_CHANNEL_END) && + (ch2 <= SIR_11B_CHANNEL_END))) { + hddLog(LOGE, + "MCC in 2.4Ghz on channels %d and %d", + ch1, ch2); + return 1; + } + + status = hdd_get_next_adapter(hdd_ctx, + adapter_node, &next); + adapter_node = next; + } + } + return ret; +} + /** * wlan_hdd_get_link_speed() - get link speed * @pAdapter: pointer to the adapter diff --git a/CORE/MAC/src/include/sirParams.h b/CORE/MAC/src/include/sirParams.h index 840351a6eccf..d582c136a482 100644 --- a/CORE/MAC/src/include/sirParams.h +++ b/CORE/MAC/src/include/sirParams.h @@ -698,6 +698,9 @@ typedef struct sSirMbMsgP2p #define SIR_HAL_UPDATE_Q2Q_IE_IND (SIR_HAL_ITC_MSG_TYPES_BEGIN + 310) #endif /* FEATURE_AP_MCC_CH_AVOIDANCE */ +#define SIR_HAL_SET_MAS (SIR_HAL_ITC_MSG_TYPES_BEGIN + 311) +#define SIR_HAL_SET_MIRACAST (SIR_HAL_ITC_MSG_TYPES_BEGIN + 312) + #define SIR_HAL_MSG_TYPES_END (SIR_HAL_MSG_TYPES_BEGIN + 0x1FF) // CFG message types diff --git a/CORE/SERVICES/WMA/wma.c b/CORE/SERVICES/WMA/wma.c index 910233f30310..2fffeb458dba 100644 --- a/CORE/SERVICES/WMA/wma.c +++ b/CORE/SERVICES/WMA/wma.c @@ -23121,6 +23121,39 @@ static void wma_ocb_set_sched_req(void *wma_handle, } } +/** + * wma_process_set_mas() - Function to enable/disable MAS + * @wma: Pointer to WMA handle + * @mas_val: 1-Enable MAS, 0-Disable MAS + * + * This function enables/disables the MAS value + * + * Return: VOS_STATUS_SUCCESS for success otherwise failure + * + */ +VOS_STATUS wma_process_set_mas(tp_wma_handle wma, + uint32_t *mas_val) +{ + uint32_t val; + + if (NULL == wma || NULL == mas_val) { + WMA_LOGE("%s: Invalid input to enable/disable MAS", __func__); + return VOS_STATUS_E_FAILURE; + } + + val = (*mas_val); + + if (VOS_STATUS_SUCCESS != + wma_set_enable_disable_mcc_adaptive_scheduler(val)) { + WMA_LOGE("%s: Unable to enable/disable MAS", __func__); + return VOS_STATUS_E_FAILURE; + } else { + WMA_LOGE("%s: Value is %d", __func__, val); + } + + return VOS_STATUS_SUCCESS; +} + /* * function : wma_mc_process_msg * Description : @@ -23810,6 +23843,11 @@ VOS_STATUS wma_mc_process_msg(v_VOID_t *vos_context, vos_msg_t *msg) wma_auto_resume_req(wma_handle); break; #endif + case SIR_HAL_SET_MAS: + wma_process_set_mas(wma_handle, + (u_int32_t *)msg->bodyptr); + vos_mem_free(msg->bodyptr); + break; default: WMA_LOGD("unknow msg type %x", msg->type); /* Do Nothing? MSG Body should be freed at here */ diff --git a/CORE/SME/inc/smeInternal.h b/CORE/SME/inc/smeInternal.h index 3b4af201158c..0b210aa18543 100644 --- a/CORE/SME/inc/smeInternal.h +++ b/CORE/SME/inc/smeInternal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2014 The Linux Foundation. All rights reserved. + * Copyright (c) 2011-2015 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -184,6 +184,7 @@ typedef struct tagSmeStruct #ifdef FEATURE_BUS_AUTO_SUSPEND bool enable_bus_auto_suspend; #endif + uint8_t miracast_value; } tSmeStruct, *tpSmeStruct; diff --git a/CORE/SME/inc/sme_Api.h b/CORE/SME/inc/sme_Api.h index 07eaddde22d7..ac8a956e0b9b 100644 --- a/CORE/SME/inc/sme_Api.h +++ b/CORE/SME/inc/sme_Api.h @@ -4237,4 +4237,28 @@ eHalStatus sme_configure_bus_auto_suspend_ind(tHalHandle hHal, void *context); #endif +/** + * sme_enable_disable_mas() - Function to set MAS value to UMAC + * @val: 1-Enable, 0-Disable + * + * This function passes down the value of MAS to the UMAC. A + * value of 1 will enable MAS and a value of 0 will disable MAS + * + * Return: Configuration message posting status, SUCCESS or Fail + * + */ +eHalStatus sme_set_mas(tANI_U32 val); + +/** + * sme_set_miracast() - Function to set miracast value to UMAC + * @hal: Handle returned by macOpen + * @filter_type: 0-Disabled, 1-Source, 2-sink + * + * This function passes down the value of miracast set by + * framework to UMAC + * + * Return: Configuration message posting status, SUCCESS or Fail + * + */ +eHalStatus sme_set_miracast(tHalHandle hal, uint8_t filter_type); #endif //#if !defined( __SME_API_H ) diff --git a/CORE/SME/src/sme_common/sme_Api.c b/CORE/SME/src/sme_common/sme_Api.c index b62589049534..b8f6a9a7e611 100644 --- a/CORE/SME/src/sme_common/sme_Api.c +++ b/CORE/SME/src/sme_common/sme_Api.c @@ -13046,6 +13046,88 @@ eHalStatus sme_ChAvoidUpdateReq } #endif /* FEATURE_WLAN_CH_AVOID */ +/** + * sme_set_miracast() - Function to set miracast value to UMAC + * @hal: Handle returned by macOpen + * @filter_type: 0-Disabled, 1-Source, 2-sink + * + * This function passes down the value of miracast set by + * framework to UMAC + * + * Return: Configuration message posting status, SUCCESS or Fail + * + */ +eHalStatus sme_set_miracast(tHalHandle hal, uint8_t filter_type) +{ + vos_msg_t msg; + uint32_t *val; + tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal); + + val = vos_mem_malloc(sizeof(*val)); + if (NULL == val || NULL == mac_ptr) { + VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, + "%s: Invalid pointer", __func__); + return eHAL_STATUS_E_MALLOC_FAILED; + } + + *val = filter_type; + + msg.type = SIR_HAL_SET_MIRACAST; + msg.reserved = 0; + msg.bodyptr = val; + + if (!VOS_IS_STATUS_SUCCESS( + vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))) { + VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, + "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!", + __func__); + vos_mem_free(val); + return eHAL_STATUS_FAILURE; + } + + mac_ptr->sme.miracast_value = filter_type; + return eHAL_STATUS_SUCCESS; +} + +/** + * sme_set_mas() - Function to set MAS value to UMAC + * @val: 1-Enable, 0-Disable + * + * This function passes down the value of MAS to the UMAC. A + * value of 1 will enable MAS and a value of 0 will disable MAS + * + * Return: Configuration message posting status, SUCCESS or Fail + * + */ +eHalStatus sme_set_mas(uint32_t val) +{ + vos_msg_t msg; + uint32_t *ptr_val; + + ptr_val = vos_mem_malloc(sizeof(*ptr_val)); + if (NULL == ptr_val) { + VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, + "%s: could not allocate ptr_val", __func__); + return eHAL_STATUS_E_MALLOC_FAILED; + } + + *ptr_val = val; + + msg.type = SIR_HAL_SET_MAS; + msg.reserved = 0; + msg.bodyptr = ptr_val; + + if (!VOS_IS_STATUS_SUCCESS( + vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))) { + VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, + "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!", + __func__); + vos_mem_free(ptr_val); + return eHAL_STATUS_FAILURE; + } + return eHAL_STATUS_SUCCESS; +} + /* ------------------------------------------------------------------------- \fn sme_RoamChannelChangeReq \brief API to Indicate Channel change to new target channel -- cgit v1.2.3