diff options
| author | Linux Build Service Account <lnxbuild@localhost> | 2018-04-06 20:10:57 -0700 |
|---|---|---|
| committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2018-04-06 20:10:57 -0700 |
| commit | ff18fc8f56a6d22542111f7fe246a5e203a810e5 (patch) | |
| tree | 4fcaa6f67d08470c661494762dd1172f26148161 | |
| parent | a7e5e49ea1ed895052b9fa4f49a6acca5bd8ee4f (diff) | |
| parent | 575dc87b5ef11e5ec6c519fa9e2e0d0165b1f84b (diff) | |
Merge "qcacld-2.0: Use request manager for get link status"
| -rw-r--r-- | CORE/HDD/src/wlan_hdd_main.c | 159 |
1 files changed, 79 insertions, 80 deletions
diff --git a/CORE/HDD/src/wlan_hdd_main.c b/CORE/HDD/src/wlan_hdd_main.c index a0d18b50e528..4bfa59d494c5 100644 --- a/CORE/HDD/src/wlan_hdd_main.c +++ b/CORE/HDD/src/wlan_hdd_main.c @@ -4104,46 +4104,6 @@ void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) return; } -static void hdd_GetLink_statusCB(v_U8_t status, void *pContext) -{ - struct statsContext *pLinkContext; - hdd_adapter_t *pAdapter; - - if (NULL == pContext) { - hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Bad pContext [%pK]", - __func__, pContext); - return; - } - - pLinkContext = pContext; - pAdapter = pLinkContext->pAdapter; - - spin_lock(&hdd_context_lock); - - if ((NULL == pAdapter) || (LINK_STATUS_MAGIC != pLinkContext->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, pAdapter [%pK] magic [%08x]", - __func__, pAdapter, pLinkContext->magic); - return; - } - - /* context is valid so caller is still waiting */ - - /* paranoia: invalidate the magic */ - pLinkContext->magic = 0; - - /* copy over the status */ - pAdapter->linkStatus = status; - - /* notify the caller */ - complete(&pLinkContext->completion); - - /* serialization is complete */ - spin_unlock(&hdd_context_lock); -} - /** * hdd_get_fw_state_cb() - validates the context and notifies the caller * @callback_context: caller context @@ -4237,6 +4197,27 @@ bool wlan_hdd_get_fw_state(hdd_adapter_t *adapter) return fw_active; } +struct link_status_priv { + uint8_t link_status; +}; + +static void hdd_get_link_status_cb(uint8_t status, void *context) +{ + struct hdd_request *request; + struct link_status_priv *priv; + + request = hdd_request_get(context); + if (!request) { + hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Obsolete request", __func__); + return; + } + + priv = hdd_request_priv(request); + priv->link_status = status; + hdd_request_complete(request); + hdd_request_put(request); +} + /** * wlan_hdd_get_link_status() - get link status * @pAdapter: pointer to the adapter @@ -4251,50 +4232,68 @@ bool wlan_hdd_get_fw_state(hdd_adapter_t *adapter) */ static int wlan_hdd_get_link_status(hdd_adapter_t *pAdapter) { - hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); - hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); - struct statsContext context; - eHalStatus hstatus; - unsigned long rc; - - if (pHddCtx->isLogpInProgress) { - hddLog(LOGW, FL("LOGP in Progress. Ignore!!!")); - return 0; - } + hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); + hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); + eHalStatus hstatus; + int ret; + void *cookie; + struct hdd_request *request; + struct link_status_priv *priv; + static const struct hdd_request_params params = { + .priv_size = sizeof(*priv), + .timeout_ms = WLAN_WAIT_TIME_LINK_STATUS, + }; + + if (pHddCtx->isLogpInProgress) { + hddLog(LOGW, FL("LOGP in Progress. Ignore!!!")); + return 0; + } - if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) { - /* If not associated, then expected link status return value is 0 */ - hddLog(LOG1, FL("Not associated!")); - return 0; - } + if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) { + /* If not associated, then expected link status return value is 0 */ + hddLog(LOG1, FL("Not associated!")); + return 0; + } - init_completion(&context.completion); - context.pAdapter = pAdapter; - context.magic = LINK_STATUS_MAGIC; - hstatus = sme_getLinkStatus(WLAN_HDD_GET_HAL_CTX(pAdapter), - hdd_GetLink_statusCB, - &context, - pAdapter->sessionId); - if (eHAL_STATUS_SUCCESS != hstatus) { - hddLog(VOS_TRACE_LEVEL_ERROR, - "%s: Unable to retrieve link status", __func__); - /* return a cached value */ - } else { - /* request is sent -- wait for the response */ - rc = wait_for_completion_timeout(&context.completion, - msecs_to_jiffies(WLAN_WAIT_TIME_LINK_STATUS)); - if (!rc) { - hddLog(VOS_TRACE_LEVEL_ERROR, - FL("SME timed out while retrieving link status")); - } - } + request = hdd_request_alloc(¶ms); + if (!request) { + hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Request allocation failure", + __func__); + return 0; + } + cookie = hdd_request_cookie(request); - spin_lock(&hdd_context_lock); - context.magic = 0; - spin_unlock(&hdd_context_lock); + hstatus = sme_getLinkStatus(WLAN_HDD_GET_HAL_CTX(pAdapter), + hdd_get_link_status_cb, + cookie, + pAdapter->sessionId); + if (eHAL_STATUS_SUCCESS != hstatus) { + hddLog(VOS_TRACE_LEVEL_ERROR, + "%s: Unable to retrieve link status", __func__); + /* return a cached value */ + } else { + /* request is sent -- wait for the response */ + ret = hdd_request_wait_for_response(request); + if (ret) { + hddLog(VOS_TRACE_LEVEL_ERROR, + "%s: SME timed out while retrieving link status", + __func__); + /* return a cached value */ + } else { + /* update the adapter with the fresh results */ + priv = hdd_request_priv(request); + pAdapter->linkStatus = priv->link_status; + } + } + /* + * 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); - /* either callback updated pAdapter stats or it has cached data */ - return pAdapter->linkStatus; + /* either callback updated adapter stats or it has cached data */ + return pAdapter->linkStatus; } #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
