diff options
| author | Hanumanth Reddy Pothula <c_hpothu@codeaurora.org> | 2018-04-25 15:53:20 +0530 |
|---|---|---|
| committer | nshrivas <nshrivas@codeaurora.org> | 2018-05-15 08:59:04 -0700 |
| commit | 18c7305140b13328eb79dc220d6def3337467e34 (patch) | |
| tree | 011da523689d14208ca7d01a94326aa3bdeef464 | |
| parent | 2a621a1dbe947fdf70c935a826002cbbb62f5555 (diff) | |
qcacld-3.0: Use request manager for peer txrx rate
propagation from qcacld-2.0 to qcacld-3.0
We are transitioning to the new request manager framework. Change
wlan_hdd_get_txrx_rate() and hdd_get_peer_txrx_rate_cb() to
this framework.
Change-Id: I0df40f3cdbcb69f661be13a73a58a66dca9f0743
CRs-Fixed: 2235599
| -rw-r--r-- | core/hdd/src/wlan_hdd_cfg80211.c | 126 |
1 files changed, 56 insertions, 70 deletions
diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index b06c72e4c49c..c03fa489c36b 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -3984,6 +3984,10 @@ fail: return -EINVAL; } +struct peer_txrx_rate_priv { + struct sir_peer_info_ext peer_info_ext; +}; + /** * hdd_get_peer_txrx_rate_cb() - get station's txrx rate callback * @peer_info: pointer of peer information @@ -3995,66 +3999,33 @@ fail: static void hdd_get_peer_txrx_rate_cb(struct sir_peer_info_ext_resp *peer_info, void *context) { - struct statsContext *get_txrx_rate_context; - struct sir_peer_info_ext *txrx_rate; - hdd_adapter_t *adapter; - uint8_t staid; + struct hdd_request *request; + struct peer_txrx_rate_priv *priv; - if ((peer_info == NULL) || (context == NULL)) { - hdd_err("Bad param, peer_info [%pK] context [%pK]", - peer_info, context); - return; - } - - spin_lock(&hdd_context_lock); - /* - * 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 - */ - get_txrx_rate_context = context; - if (get_txrx_rate_context->magic != PEER_INFO_CONTEXT_MAGIC) { - /* - * the caller presumably timed out so there is nothing - * we can do - */ - spin_unlock(&hdd_context_lock); - hdd_warn("Invalid context, magic [%08x]", - get_txrx_rate_context->magic); + if (NULL == peer_info) { + hdd_err("Bad param, peer_info [%pK]", peer_info); return; } if (!peer_info->count) { - spin_unlock(&hdd_context_lock); hdd_err("Fail to get remote peer info"); return; } - adapter = get_txrx_rate_context->pAdapter; - txrx_rate = peer_info->info; - if (hdd_softap_get_sta_id(adapter, - &txrx_rate->peer_macaddr, - &staid) != QDF_STATUS_SUCCESS) { - spin_unlock(&hdd_context_lock); - hdd_err("Station MAC address does not matching"); + request = hdd_request_get(context); + if (!request) { + hdd_err("Obsolete request"); return; } - adapter->aStaInfo[staid].tx_rate = txrx_rate->tx_rate; - adapter->aStaInfo[staid].rx_rate = txrx_rate->rx_rate; - hdd_debug("%pM txrate %u rxrate %u", - txrx_rate->peer_macaddr.bytes, - adapter->aStaInfo[staid].tx_rate, - adapter->aStaInfo[staid].rx_rate); - - get_txrx_rate_context->magic = 0; + priv = hdd_request_priv(request); - /* notify the caller */ - complete(&get_txrx_rate_context->completion); + qdf_mem_copy(&priv->peer_info_ext, + peer_info->info, + sizeof(peer_info->info[0])); - /* serialization is complete */ - spin_unlock(&hdd_context_lock); + hdd_request_complete(request); + hdd_request_put(request); } /** @@ -4071,17 +4042,30 @@ static int wlan_hdd_get_txrx_rate(hdd_adapter_t *adapter, { QDF_STATUS status; int ret; - static struct statsContext context; + uint8_t staid; + void *cookie; struct sir_peer_info_ext_req txrx_rate_req; + struct hdd_request *request; + struct peer_txrx_rate_priv *priv; + static const struct hdd_request_params params = { + .priv_size = sizeof(*priv), + .timeout_ms = WLAN_WAIT_TIME_STATS, + }; if (adapter == NULL) { hdd_err("pAdapter is NULL"); return -EFAULT; } - init_completion(&context.completion); - context.magic = PEER_INFO_CONTEXT_MAGIC; - context.pAdapter = adapter; + request = hdd_request_alloc(¶ms); + if (!request) { + hdd_err("%s: Request allocation failure", + __func__); + return -ENOMEM; + } + + cookie = hdd_request_cookie(request); + priv = hdd_request_priv(request); qdf_mem_copy(&(txrx_rate_req.peer_macaddr), &macaddress, QDF_MAC_ADDR_SIZE); @@ -4089,36 +4073,38 @@ static int wlan_hdd_get_txrx_rate(hdd_adapter_t *adapter, txrx_rate_req.reset_after_request = 0; status = sme_get_peer_info_ext(WLAN_HDD_GET_HAL_CTX(adapter), &txrx_rate_req, - &context, + cookie, hdd_get_peer_txrx_rate_cb); if (status != QDF_STATUS_SUCCESS) { hdd_err("Unable to retrieve statistics for txrx_rate"); ret = -EFAULT; } else { - if (!wait_for_completion_timeout(&context.completion, - msecs_to_jiffies(WLAN_WAIT_TIME_STATS))) { + ret = hdd_request_wait_for_response(request); + if (ret) { hdd_err("SME timed out while retrieving txrx_rate"); ret = -EFAULT; } else { - ret = 0; + if (hdd_softap_get_sta_id(adapter, + &priv->peer_info_ext.peer_macaddr, + &staid) != QDF_STATUS_SUCCESS) { + hdd_err("Station MAC address does not matching"); + ret = -EFAULT; + } else { + adapter->aStaInfo[staid].tx_rate = + priv->peer_info_ext.tx_rate; + adapter->aStaInfo[staid].rx_rate = + priv->peer_info_ext.rx_rate; + + hdd_info("%pM tx rate %u rx rate %u", + priv->peer_info_ext.peer_macaddr.bytes, + adapter->aStaInfo[staid].tx_rate, + adapter->aStaInfo[staid].rx_rate); + ret = 0; + } } } - /* - * 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); + + hdd_request_put(request); return ret; } |
