summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Zhang <paulz@codeaurora.org>2018-04-24 17:25:33 +0800
committernshrivas <nshrivas@codeaurora.org>2018-05-08 22:04:43 -0700
commit0060ba500d1d71b6c17bf413e4d601245466efe7 (patch)
tree5688b4f8ecdac6641bfce9dee6c3f4cc87c2cdd5
parent063696c98dd419807da6a9794ba2d541e23f7db2 (diff)
qcacld-3.0: Use request manager for get_peer_rssi
We are transitioning to the new request manager framework. Change wlan_hdd_get_peer_rssi, hdd_get_peer_rssi_cb. Change-Id: I4d5350b4046063fe27cb68dea03408ca672b728f CRs-Fixed: 2229971
-rw-r--r--core/hdd/src/wlan_hdd_wext.c112
1 files changed, 46 insertions, 66 deletions
diff --git a/core/hdd/src/wlan_hdd_wext.c b/core/hdd/src/wlan_hdd_wext.c
index 48598dfd7cb3..b8141eb2cd5c 100644
--- a/core/hdd/src/wlan_hdd_wext.c
+++ b/core/hdd/src/wlan_hdd_wext.c
@@ -3751,6 +3751,10 @@ int wlan_hdd_get_link_speed(hdd_adapter_t *sta_adapter, uint32_t *link_speed)
return 0;
}
+struct peer_rssi_priv {
+ struct sir_peer_sta_info peer_sta_info;
+};
+
/**
* hdd_get_peer_rssi_cb() - get peer station's rssi callback
* @sta_rssi: pointer of peer information
@@ -3763,58 +3767,41 @@ int wlan_hdd_get_link_speed(hdd_adapter_t *sta_adapter, uint32_t *link_speed)
static void hdd_get_peer_rssi_cb(struct sir_peer_info_resp *sta_rssi,
void *context)
{
- struct statsContext *get_rssi_context;
+ struct hdd_request *request;
struct sir_peer_info *rssi_info;
+ struct peer_rssi_priv *priv;
uint8_t peer_num;
- hdd_adapter_t *padapter;
- if ((sta_rssi == NULL) || (context == NULL)) {
- hdd_err("Bad param, sta_rssi [%pK] context [%pK]",
- sta_rssi, context);
+ if (sta_rssi == NULL) {
+ hdd_err("Bad param, sta_rssi [%pK]", sta_rssi);
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_rssi_context = (struct statsContext *)context;
- padapter = get_rssi_context->pAdapter;
- if (get_rssi_context->magic != PEER_INFO_CONTEXT_MAGIC ||
- !padapter) {
- /*
- * the caller presumably timed out so there is nothing
- * we can do
- */
- spin_unlock(&hdd_context_lock);
- hdd_warn("Invalid context, magic [%08x], adapter [%pK]",
- get_rssi_context->magic, padapter);
+ request = hdd_request_get(context);
+ if (!request) {
+ hdd_err("Obsolete request.");
return;
}
+ priv = hdd_request_priv(request);
+
peer_num = sta_rssi->count;
rssi_info = sta_rssi->info;
- get_rssi_context->magic = 0;
hdd_debug("%d peers", peer_num);
if (peer_num > MAX_PEER_STA) {
- hdd_warn("Exceed max peer sta to handle one time %d", peer_num);
+ hdd_warn("Exceed max peer sta to handle one time %d",
+ peer_num);
peer_num = MAX_PEER_STA;
}
- qdf_mem_copy(padapter->peer_sta_info.info, rssi_info,
- peer_num * sizeof(*rssi_info));
- padapter->peer_sta_info.sta_num = peer_num;
-
- /* notify the caller */
- complete(&get_rssi_context->completion);
+ qdf_mem_copy(priv->peer_sta_info.info, rssi_info,
+ peer_num * sizeof(*rssi_info));
+ priv->peer_sta_info.sta_num = peer_num;
- /* serialization is complete */
- spin_unlock(&hdd_context_lock);
+ hdd_request_complete(request);
+ hdd_request_put(request);
}
int wlan_hdd_get_peer_rssi(hdd_adapter_t *adapter,
@@ -3822,62 +3809,55 @@ int wlan_hdd_get_peer_rssi(hdd_adapter_t *adapter,
int request_source)
{
QDF_STATUS status;
+ void *cookie;
int ret;
- static struct statsContext context;
struct sir_peer_info_req rssi_req;
+ struct hdd_request *request;
+ struct peer_rssi_priv *priv;
+ static const struct hdd_request_params params = {
+ .priv_size = sizeof(*priv),
+ .timeout_ms = WLAN_WAIT_TIME_STATS,
+ };
if (!adapter || !macaddress) {
- hdd_err("pAdapter [%pK], macaddress [%pK]", adapter, macaddress);
+ hdd_err("adapter [%pK], macaddress [%pK]",
+ adapter, macaddress);
return -EFAULT;
}
- init_completion(&context.completion);
- context.magic = PEER_INFO_CONTEXT_MAGIC;
- context.pAdapter = adapter;
+ request = hdd_request_alloc(&params);
+ if (!request) {
+ hdd_err("Request allocation failure");
+ return -ENOMEM;
+ }
+
+ cookie = hdd_request_cookie(request);
qdf_mem_copy(&(rssi_req.peer_macaddr), macaddress,
- QDF_MAC_ADDR_SIZE);
+ QDF_MAC_ADDR_SIZE);
rssi_req.sessionid = adapter->sessionId;
status = sme_get_peer_info(WLAN_HDD_GET_HAL_CTX(adapter),
- rssi_req,
- &context,
- hdd_get_peer_rssi_cb);
+ rssi_req,
+ cookie,
+ hdd_get_peer_rssi_cb);
if (status != QDF_STATUS_SUCCESS) {
hdd_err("Unable to retrieve statistics for rssi");
ret = -EFAULT;
- }
-
- else if (request_source != HDD_WLAN_GET_PEER_RSSI_SOURCE_DRIVER) {
- if (!wait_for_completion_timeout(&context.completion,
- msecs_to_jiffies(WLAN_WAIT_TIME_STATS))) {
+ } else if (request_source != HDD_WLAN_GET_PEER_RSSI_SOURCE_DRIVER) {
+ ret = hdd_request_wait_for_response(request);
+ if (ret) {
hdd_err("SME timed out while retrieving rssi");
ret = -EFAULT;
} else {
+ priv = hdd_request_priv(request);
+ adapter->peer_sta_info = priv->peer_sta_info;
ret = 0;
}
- goto set_magic;
} else {
ret = 0;
- return ret;
}
-set_magic:
- /*
- * 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;
}