diff options
| author | Jingxiang Ge <jge@codeaurora.org> | 2018-04-26 07:45:15 +0800 |
|---|---|---|
| committer | nshrivas <nshrivas@codeaurora.org> | 2018-05-10 00:21:22 -0700 |
| commit | f89ff70b773750c0502f2f0fb60f405b00dce25b (patch) | |
| tree | 339f0061ad85519fe9a1b5875c60ffe15d4eea5b | |
| parent | 55d6f0fd249061bdab54c8a6066eb70a84e68aad (diff) | |
qcacld-3.0: Use request manager for peer info
qcacld-2.0 to qcacld-3.0 propagation
We are transitioning to the new request manager framework. Change
wlan_hdd_get_peer_info() and wlan_hdd_get_peer_info_cb() to
this framework.
Change-Id: I31015303e2502472c730b4a5c552a51d728f0e5c
CRs-Fixed: 2230998
| -rw-r--r-- | core/hdd/src/wlan_hdd_stats.c | 162 | ||||
| -rw-r--r-- | core/mac/inc/sir_api.h | 11 |
2 files changed, 94 insertions, 79 deletions
diff --git a/core/hdd/src/wlan_hdd_stats.c b/core/hdd/src/wlan_hdd_stats.c index 5468457738c0..51e305c7630c 100644 --- a/core/hdd/src/wlan_hdd_stats.c +++ b/core/hdd/src/wlan_hdd_stats.c @@ -3792,77 +3792,58 @@ static void wlan_hdd_fill_rate_info(hdd_ap_ctx_t *ap_ctx, flags); } +struct peer_info_priv { + struct sir_peer_sta_ext_info peer_sta_ext_info; +}; + /** * wlan_hdd_get_peer_info_cb() - get peer info callback * @sta_info: pointer of peer information * @context: get peer info callback context * - * This function will fill stats info of AP Context + * This function will fill stats info to peer info priv * */ static void wlan_hdd_get_peer_info_cb(struct sir_peer_info_ext_resp *sta_info, - void *context) + void *context) { - struct statsContext *get_peer_info_context; - struct sir_peer_info_ext *peer_info; - hdd_adapter_t *adapter; - hdd_ap_ctx_t *ap_ctx; - - if ((sta_info == NULL) || (context == NULL)) { - hdd_err("Bad param, sta_info [%pK] context [%pK]", - sta_info, context); - return; - } + struct hdd_request *request; + struct peer_info_priv *priv; + uint8_t sta_num; - 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_peer_info_context = context; - if (PEER_INFO_CONTEXT_MAGIC != - get_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_peer_info_context->magic); + if (!sta_info) { + hdd_err("Bad param, sta_info [%pK]", + sta_info); return; } if (!sta_info->count) { - spin_unlock(&hdd_context_lock); hdd_err("Fail to get remote peer info"); return; } - adapter = get_peer_info_context->pAdapter; - ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); - qdf_mem_zero(&ap_ctx->txrx_stats, - sizeof(ap_ctx->txrx_stats)); + if (sta_info->count > MAX_PEER_STA) { + hdd_warn("Exceed max peer number %d", sta_info->count); + sta_num = MAX_PEER_STA; + } else { + sta_num = sta_info->count; + } - peer_info = sta_info->info; - ap_ctx->txrx_stats.tx_packets = peer_info->tx_packets; - ap_ctx->txrx_stats.tx_bytes = peer_info->tx_bytes; - ap_ctx->txrx_stats.rx_packets = peer_info->rx_packets; - ap_ctx->txrx_stats.rx_bytes = peer_info->rx_bytes; - ap_ctx->txrx_stats.tx_retries = peer_info->tx_retries; - ap_ctx->txrx_stats.tx_failed = peer_info->tx_failed; - ap_ctx->txrx_stats.rssi = - peer_info->rssi + WLAN_HDD_TGT_NOISE_FLOOR_DBM; - wlan_hdd_fill_rate_info(ap_ctx, peer_info); + request = hdd_request_get(context); + if (!request) { + hdd_err("Obsolete request"); + return; + } - get_peer_info_context->magic = 0; + priv = hdd_request_priv(request); - /* notify the caller */ - complete(&get_peer_info_context->completion); + priv->peer_sta_ext_info.sta_num = sta_num; + qdf_mem_copy(&priv->peer_sta_ext_info.info, + sta_info->info, + sta_num * sizeof(sta_info->info[0])); - /* serialization is complete */ - spin_unlock(&hdd_context_lock); + hdd_request_complete(request); + hdd_request_put(request); } /** @@ -3878,54 +3859,77 @@ static int wlan_hdd_get_peer_info(hdd_adapter_t *adapter, struct qdf_mac_addr macaddress) { QDF_STATUS status; + void *cookie; int ret; - static struct statsContext context; + hdd_ap_ctx_t *ap_ctx = NULL; struct sir_peer_info_ext_req peer_info_req; + struct hdd_request *request; + struct peer_info_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"); + if (!adapter) { + hdd_err("adapter 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("Request allocation failure"); + return -ENOMEM; + } - qdf_mem_copy(&(peer_info_req.peer_macaddr), &macaddress, - QDF_MAC_ADDR_SIZE); + cookie = hdd_request_cookie(request); + priv = hdd_request_priv(request); + + qdf_mem_copy(&peer_info_req.peer_macaddr, &macaddress, + QDF_MAC_ADDR_SIZE); peer_info_req.sessionid = adapter->sessionId; peer_info_req.reset_after_request = 0; status = sme_get_peer_info_ext(WLAN_HDD_GET_HAL_CTX(adapter), - &peer_info_req, - &context, - wlan_hdd_get_peer_info_cb); + &peer_info_req, + cookie, + wlan_hdd_get_peer_info_cb); if (status != QDF_STATUS_SUCCESS) { hdd_err("Unable to retrieve statistics for peer info"); 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 peer info"); ret = -EFAULT; - } else + } else { + /* only support one peer by now */ + ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); + qdf_mem_zero(&ap_ctx->txrx_stats, + sizeof(struct hdd_fw_txrx_stats)); + + ap_ctx->txrx_stats.tx_packets = + priv->peer_sta_ext_info.info[0].tx_packets; + ap_ctx->txrx_stats.tx_bytes = + priv->peer_sta_ext_info.info[0].tx_bytes; + ap_ctx->txrx_stats.rx_packets = + priv->peer_sta_ext_info.info[0].rx_packets; + ap_ctx->txrx_stats.rx_bytes = + priv->peer_sta_ext_info.info[0].rx_bytes; + ap_ctx->txrx_stats.tx_retries = + priv->peer_sta_ext_info.info[0].tx_retries; + ap_ctx->txrx_stats.tx_failed = + priv->peer_sta_ext_info.info[0].tx_failed; + ap_ctx->txrx_stats.rssi = + priv->peer_sta_ext_info.info[0].rssi + + WLAN_HDD_TGT_NOISE_FLOOR_DBM; + wlan_hdd_fill_rate_info(ap_ctx, + &priv->peer_sta_ext_info.info[0]); 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; } diff --git a/core/mac/inc/sir_api.h b/core/mac/inc/sir_api.h index 8033d68fdc33..918bd22e45c1 100644 --- a/core/mac/inc/sir_api.h +++ b/core/mac/inc/sir_api.h @@ -4606,6 +4606,17 @@ struct sir_peer_sta_info { struct sir_peer_info info[MAX_PEER_STA]; }; +/** + * @sta_num: number of peer station which has valid info + * @info: peer extended information + * + * all SAP peer station's extended information retrieved + */ +struct sir_peer_sta_ext_info { + uint8_t sta_num; + struct sir_peer_info_ext info[MAX_PEER_STA]; +}; + typedef struct sSirAddPeriodicTxPtrn { /* MAC Address for the adapter */ struct qdf_mac_addr mac_address; |
