summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiachao Wu <jiacwu@codeaurora.org>2018-03-19 18:16:55 +0800
committerGerrit - the friendly Code Review server <code-review@localhost>2018-04-08 20:53:18 -0700
commit2201be54bab98288aafecdf4676271ab04baa8cf (patch)
tree7f0038e7540813a2837036b637e325a6613d8e02
parent9bf0fceeb14f970564e8d77c2799b0bbf969ca1d (diff)
qcacld-2.0: Use request manager for linkspeed
We are transitioning to the new request manager framework. Change wlan_hdd_get_linkspeed_for_peermac() to this framework. Note that this framework provides the infrastructure to pass data from the response thread to the request thread and hence eliminates the need to maintain tSirLinkSpeedInfo in the HDD adapter struct. Change-Id: Ie0c84c271cee188e8bd1663095022daefd703f97 CRs-Fixed: 2207694
-rw-r--r--CORE/HDD/inc/wlan_hdd_wext.h3
-rw-r--r--CORE/HDD/src/wlan_hdd_hostapd.c114
-rw-r--r--CORE/HDD/src/wlan_hdd_wext.c50
3 files changed, 73 insertions, 94 deletions
diff --git a/CORE/HDD/inc/wlan_hdd_wext.h b/CORE/HDD/inc/wlan_hdd_wext.h
index 6a47ede7e6e7..bf8fe01114d5 100644
--- a/CORE/HDD/inc/wlan_hdd_wext.h
+++ b/CORE/HDD/inc/wlan_hdd_wext.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
*
* Previously licensed under the ISC license by Qualcomm Atheros, Inc.
*
@@ -428,7 +428,6 @@ extern VOS_STATUS wlan_hdd_get_linkspeed_for_peermac(hdd_adapter_t *pAdapter,
tSirMacAddr macAddress);
void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter);
void hdd_GetClassA_statisticsCB(void *pStats, void *pContext);
-void hdd_GetLink_SpeedCB(tSirLinkSpeedInfo *pLinkSpeed, void *pContext);
VOS_STATUS wlan_hdd_check_ula_done(hdd_adapter_t *pAdapter);
diff --git a/CORE/HDD/src/wlan_hdd_hostapd.c b/CORE/HDD/src/wlan_hdd_hostapd.c
index 05c464c963b9..521f6e889244 100644
--- a/CORE/HDD/src/wlan_hdd_hostapd.c
+++ b/CORE/HDD/src/wlan_hdd_hostapd.c
@@ -6681,69 +6681,99 @@ iw_set_ap_genie(struct net_device *dev,
return ret;
}
+struct linkspeed_priv {
+ tSirLinkSpeedInfo linkspeed_info;
+};
+
+static void
+hdd_get_link_speed_cb(tSirLinkSpeedInfo *linkspeed_info, void *cookie)
+{
+ struct hdd_request *request;
+ struct linkspeed_priv *priv;
+
+ if (NULL == linkspeed_info)
+ {
+ hddLog(VOS_TRACE_LEVEL_ERROR,
+ "%s: Bad param, linkspeed_info [%pK] cookie [%pK]",
+ __func__, linkspeed_info, cookie);
+ return;
+ }
+
+ request = hdd_request_get(cookie);
+ if (!request) {
+ hddLog(VOS_TRACE_LEVEL_ERROR,"Obsolete request");
+ return;
+ }
+
+ priv = hdd_request_priv(request);
+ priv->linkspeed_info = *linkspeed_info;
+ hdd_request_complete(request);
+ hdd_request_put(request);
+}
VOS_STATUS wlan_hdd_get_linkspeed_for_peermac(hdd_adapter_t *pAdapter,
tSirMacAddr macAddress)
{
eHalStatus hstatus;
- unsigned long rc;
- struct linkspeedContext context;
- tSirLinkSpeedInfo *linkspeed_req;
+ VOS_STATUS status = VOS_STATUS_SUCCESS;
+ void *cookie;
+ tSirLinkSpeedInfo *linkspeed_info;
+ int ret;
+ struct hdd_request *request;
+ struct linkspeed_priv *priv;
+ static const struct hdd_request_params params = {
+ .priv_size = sizeof(*priv),
+ .timeout_ms = WLAN_WAIT_TIME_STATS,
+ };
if (NULL == pAdapter)
{
hddLog(VOS_TRACE_LEVEL_ERROR, "%s: pAdapter is NULL", __func__);
return VOS_STATUS_E_FAULT;
}
- linkspeed_req = (tSirLinkSpeedInfo *)vos_mem_malloc(sizeof(*linkspeed_req));
- if (NULL == linkspeed_req)
- {
+
+ request = hdd_request_alloc(&params);
+ if (!request) {
VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
"%s Request Buffer Alloc Fail", __func__);
return VOS_STATUS_E_INVAL;
}
- init_completion(&context.completion);
- context.pAdapter = pAdapter;
- context.magic = LINK_CONTEXT_MAGIC;
-
- vos_mem_copy(linkspeed_req->peer_macaddr, macAddress, sizeof(tSirMacAddr) );
- hstatus = sme_GetLinkSpeed( WLAN_HDD_GET_HAL_CTX(pAdapter),
- linkspeed_req,
- &context,
- hdd_GetLink_SpeedCB);
+ cookie = hdd_request_cookie(request);
+ priv = hdd_request_priv(request);
+
+ linkspeed_info = &priv->linkspeed_info;
+ vos_mem_copy(linkspeed_info->peer_macaddr, macAddress, sizeof(tSirMacAddr) );
+ hstatus = sme_GetLinkSpeed(WLAN_HDD_GET_HAL_CTX(pAdapter),
+ linkspeed_info,
+ cookie,
+ hdd_get_link_speed_cb);
+
if (eHAL_STATUS_SUCCESS != hstatus)
{
hddLog(VOS_TRACE_LEVEL_ERROR,
- "%s: Unable to retrieve statistics for link speed",
- __func__);
- vos_mem_free(linkspeed_req);
+ "%s: Unable to retrieve statistics for link speed, ret(%d)",
+ __func__, hstatus);
+ status = VOS_STATUS_E_INVAL;
+ goto cleanup;
}
- else
- {
- rc = wait_for_completion_timeout(&context.completion,
- msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
- if (!rc) {
- hddLog(VOS_TRACE_LEVEL_ERROR,
- "%s: SME timed out while retrieving link speed",
- __func__);
- }
+ ret = hdd_request_wait_for_response(request);
+ if (!ret) {
+ hddLog(VOS_TRACE_LEVEL_ERROR,
+ "%s: SME timed out while retrieving link speed,ret(%d)",
+ __func__, ret);
+ status = VOS_STATUS_E_INVAL;
+ goto cleanup;
}
+ pAdapter->ls_stats.estLinkSpeed = linkspeed_info->estLinkSpeed;
- /* 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);
- return VOS_STATUS_SUCCESS;
+cleanup:
+ /*
+ * 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 status;
}
diff --git a/CORE/HDD/src/wlan_hdd_wext.c b/CORE/HDD/src/wlan_hdd_wext.c
index ed2d3901bc93..2e23d3b4c7df 100644
--- a/CORE/HDD/src/wlan_hdd_wext.c
+++ b/CORE/HDD/src/wlan_hdd_wext.c
@@ -3749,56 +3749,6 @@ void hdd_GetClassA_statisticsCB(void *pStats, void *pContext)
spin_unlock(&hdd_context_lock);
}
-void hdd_GetLink_SpeedCB(tSirLinkSpeedInfo *pLinkSpeed, void *pContext)
-{
- struct linkspeedContext *pLinkSpeedContext;
- hdd_adapter_t *pAdapter;
-
- if ((NULL == pLinkSpeed) || (NULL == pContext))
- {
- hddLog(VOS_TRACE_LEVEL_ERROR,
- "%s: Bad param, pLinkSpeed [%pK] pContext [%pK]",
- __func__, pLinkSpeed, pContext);
- return;
- }
- spin_lock(&hdd_context_lock);
- pLinkSpeedContext = pContext;
- pAdapter = pLinkSpeedContext->pAdapter;
-
- /* 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 */
-
- if ((NULL == pAdapter) || (LINK_CONTEXT_MAGIC != pLinkSpeedContext->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, pLinkSpeedContext->magic);
- if (ioctl_debug)
- {
- pr_info("%s: Invalid context, pAdapter [%pK] magic [%08x]\n",
- __func__, pAdapter, pLinkSpeedContext->magic);
- }
- return;
- }
- /* context is valid so caller is still waiting */
-
- /* paranoia: invalidate the magic */
- pLinkSpeedContext->magic = 0;
-
- /* copy over the stats. do so as a struct copy */
- pAdapter->ls_stats = *pLinkSpeed;
-
- /* notify the caller */
- complete(&pLinkSpeedContext->completion);
-
- /* serialization is complete */
- spin_unlock(&hdd_context_lock);
-}
-
VOS_STATUS wlan_hdd_get_classAstats(hdd_adapter_t *pAdapter)
{
hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);