diff options
author | bings <bings@codeaurora.org> | 2018-07-31 15:01:39 +0800 |
---|---|---|
committer | Prashanth Swaminathan <prashanthsw@google.com> | 2018-09-02 14:01:32 -0700 |
commit | 7b8d1c927adc8c05cb3fb0acbe41a0968b51dd60 (patch) | |
tree | 9b149e365ece23914b267665c9214a58813180b7 | |
parent | 40d493685e8792bccc73cef82a4305dafc07cc30 (diff) | |
download | qcom-msm-v4.9-7b8d1c927adc8c05cb3fb0acbe41a0968b51dd60.tar.gz |
qcacld-2.0: Use request manager for enter bmps
We are transitioning to the new request manager framework. Change
wlan_hdd_enter_bmps to this framework.
Bug: 111906763
Test: None
Change-Id: I73a83260064deea2b4640287ee5f1853f1815f03
-rw-r--r-- | techpack/qcacld-2.0/CORE/HDD/src/wlan_hdd_wext.c | 223 |
1 files changed, 86 insertions, 137 deletions
diff --git a/techpack/qcacld-2.0/CORE/HDD/src/wlan_hdd_wext.c b/techpack/qcacld-2.0/CORE/HDD/src/wlan_hdd_wext.c index 6c760b4343e1..9e1abacc6387 100644 --- a/techpack/qcacld-2.0/CORE/HDD/src/wlan_hdd_wext.c +++ b/techpack/qcacld-2.0/CORE/HDD/src/wlan_hdd_wext.c @@ -3659,55 +3659,6 @@ static void iw_power_offload_callback_fn(void *context, tANI_U32 session_id, spin_unlock(&hdd_context_lock); } -/* Callback function registered with PMC to know status of PMC request */ -static void iw_power_callback_fn (void *pContext, eHalStatus status) -{ - struct statsContext *pStatsContext; - - if (NULL == pContext) - { - hddLog(VOS_TRACE_LEVEL_ERROR, - "%s: Bad param, pContext [%pK]", - __func__, pContext); - return; - } - - pStatsContext = (struct statsContext *)pContext; - - /* there is a race condition that exists between this callback - function and the caller since the caller could time out either - before or while this code is executing. we use a spinlock to - serialize these actions */ - spin_lock(&hdd_context_lock); - - if (POWER_CONTEXT_MAGIC != pStatsContext->magic) - { - /* the caller presumably timed out so there is nothing we can do */ - spin_unlock(&hdd_context_lock); - hddLog(VOS_TRACE_LEVEL_WARN, - "%s: Invalid context, magic [%08x]", - __func__, pStatsContext->magic); - - if (ioctl_debug) - { - pr_info("%s: Invalid context, magic [%08x]\n", - __func__, pStatsContext->magic); - } - return; - } - - /* context is valid so caller is still waiting */ - - /* paranoia: invalidate the magic */ - pStatsContext->magic = 0; - - /* notify the caller */ - complete(&pStatsContext->completion); - - /* serialization is complete */ - spin_unlock(&hdd_context_lock); -} - /* Callback function for tx per hit */ void hdd_tx_per_hit_cb (void *pCallbackContext) { @@ -4266,101 +4217,99 @@ static int iw_get_isolation(struct net_device *dev, VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode) { - struct statsContext context; - eHalStatus status; - hdd_context_t *pHddCtx; - - if (NULL == pAdapter) - { - hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL"); - return VOS_STATUS_E_FAULT; - } + struct hdd_request *request; + void *cookie; + eHalStatus status; + hdd_context_t *pHddCtx; + static const struct hdd_request_params params = { + .priv_size = 0, + .timeout_ms = WLAN_WAIT_TIME_POWER, + }; - hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode); - pHddCtx = WLAN_HDD_GET_CTX(pAdapter); - if (pHddCtx->isLogpInProgress) { - VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, - "%s:LOGP in Progress. Ignore!!!", __func__); - return VOS_STATUS_E_FAILURE; - } + if (NULL == pAdapter) + { + hddLog(VOS_TRACE_LEVEL_FATAL, "Adapter NULL"); + return VOS_STATUS_E_FAULT; + } - init_completion(&context.completion); + hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "power mode=%d", mode); + pHddCtx = WLAN_HDD_GET_CTX(pAdapter); + if (pHddCtx->isLogpInProgress) { + VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, + "%s:LOGP in Progress. Ignore!!!", __func__); + return VOS_STATUS_E_FAILURE; + } - context.pAdapter = pAdapter; - context.magic = POWER_CONTEXT_MAGIC; + request = hdd_request_alloc(¶ms); + if (!request) { + hddLog(VOS_TRACE_LEVEL_ERROR, + "%s: Request allocation failure", __func__); + return VOS_STATUS_E_NOMEM; + } - if (DRIVER_POWER_MODE_ACTIVE == mode) - { - hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering " - "Full Power", __func__); - status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter), - iw_power_callback_fn, &context, - eSME_FULL_PWR_NEEDED_BY_HDD); - // Enter Full power command received from GUI this means we are disconnected - // Set PMC remainInPowerActiveTillDHCP flag to disable auto BMPS entry by PMC - sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE); - if (eHAL_STATUS_PMC_PENDING == status) - { - unsigned long rc; - /* request was sent -- wait for the response */ - rc = wait_for_completion_timeout( - &context.completion, - msecs_to_jiffies(WLAN_WAIT_TIME_POWER)); + cookie = hdd_request_cookie(request); - if (!rc) { - hddLog(VOS_TRACE_LEVEL_ERROR, - FL("SME timed out while requesting full power")); - } - } - } - else if (DRIVER_POWER_MODE_AUTO == mode) - { - if (pHddCtx->cfg_ini->fIsBmpsEnabled) - { - hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ", - __func__); - // Enter BMPS command received from GUI this means DHCP is completed - // Clear PMC remainInPowerActiveTillDHCP flag to enable auto BMPS entry - sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), - FALSE); - status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), - iw_power_callback_fn, &context); - if (eHAL_STATUS_PMC_PENDING == status) - { - unsigned long rc; - /* request was sent -- wait for the response */ - rc = wait_for_completion_timeout( - &context.completion, - msecs_to_jiffies(WLAN_WAIT_TIME_POWER)); - if (!rc) { - hddLog(VOS_TRACE_LEVEL_ERROR, - FL("SME timed out while requesting BMPS")); - } - } - } - else - { - hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not " - "enabled in the cfg"); - } - } + if (DRIVER_POWER_MODE_ACTIVE == mode) + { + hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering " + "Full Power", __func__); + status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter), + iw_power_callback_func, cookie, + eSME_FULL_PWR_NEEDED_BY_HDD); + /* + * Enter Full power command received from GUI this means we are + * disconnected. Set PMC remainInPowerActiveTillDHCP flag to + * disable auto BMPS entry by PMC + */ + sme_SetDHCPTillPowerActiveFlag(pHddCtx->hHal, TRUE); + if (eHAL_STATUS_PMC_PENDING == status) + { + int rc; + /* request was sent -- wait for the response */ + rc = hdd_request_wait_for_response(request); + if (rc) + hddLog(VOS_TRACE_LEVEL_ERROR, + FL("SME timed out while requesting full power")); + } + } + else if (DRIVER_POWER_MODE_AUTO == mode) + { + if (pHddCtx->cfg_ini->fIsBmpsEnabled) + { + hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s:Wlan driver Entering Bmps ", + __func__); + /* + * Enter BMPS command received from GUI this means DHCP + * is completed. Clear PMC remainInPowerActiveTillDHCP + * flag to enable auto BMPS entry. + */ + sme_SetDHCPTillPowerActiveFlag( + WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE); + status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), + iw_power_callback_func, cookie); + if (eHAL_STATUS_PMC_PENDING == status) + { + int rc; + /* request was sent -- wait for the response */ + rc = hdd_request_wait_for_response(request); + if (rc) + hddLog(VOS_TRACE_LEVEL_ERROR, + FL("SME timed out while requesting BMPS")); + } + } else { + hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "BMPS is not " + "enabled in the cfg"); + } + } - /* either we never sent a request, we sent a request and received a - response or we sent a request and timed out. if we never sent a - request or if we sent a request and got a response, we want to - clear the magic out of paranoia. if we timed out there is a - race condition such that the callback function could be - executing at the same time we are. of primary concern is if the - callback function had already verified the "magic" but had not - yet set the completion variable when a timeout occurred. we - serialize these activities by invalidating the magic while - holding a shared spinlock which will cause us to block if the - callback is currently executing */ - spin_lock(&hdd_context_lock); - context.magic = 0; - spin_unlock(&hdd_context_lock); + /* + * either we never sent a request, we sent a request and + * received a response or we sent a request and timed out. + * regardless we are done with the request. + */ + hdd_request_put(request); - return VOS_STATUS_SUCCESS; + return VOS_STATUS_SUCCESS; } VOS_STATUS wlan_hdd_set_powersave(hdd_adapter_t *pAdapter, int mode) |