summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMin Liu <minliu@codeaurora.org>2018-03-19 15:23:41 +0800
committerMin Liu <minliu@codeaurora.org>2018-04-13 11:04:08 +0800
commit62c2ffbbdc9595bb6b59d3033f6630363b375584 (patch)
treea598eb6324092943330072e3ed7df9db0102f5fa
parent00b4aa51d0ed2869fd43a4ebb63b77832a46898b (diff)
qcacld-2.0: Use request manager for tsm metrics
Propagation from qcacld-3.0 to qcacld-2.0 We are transitioning to the new request manager framework. Change hdd_get_tsm_stats() and hdd_GetTsmStatsCB() 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 temporary tsmStats in the HDD adapter struct. Change-Id: I799ec4eb32a37a1edaef6d3c1fcaa10a7a9130af CRs-Fixed: 2207636
-rw-r--r--CORE/HDD/src/wlan_hdd_main.c191
1 files changed, 73 insertions, 118 deletions
diff --git a/CORE/HDD/src/wlan_hdd_main.c b/CORE/HDD/src/wlan_hdd_main.c
index ef85064e22fb..b8240dea7ed5 100644
--- a/CORE/HDD/src/wlan_hdd_main.c
+++ b/CORE/HDD/src/wlan_hdd_main.c
@@ -4761,135 +4761,90 @@ static VOS_STATUS hdd_parse_ese_beacon_req(tANI_U8 *pValue,
return VOS_STATUS_SUCCESS;
}
-static void hdd_GetTsmStatsCB( tAniTrafStrmMetrics tsmMetrics,
- const tANI_U32 staId,
- void *pContext )
-{
- struct statsContext *pStatsContext = NULL;
- hdd_adapter_t *pAdapter = NULL;
+struct tsm_priv {
+ tAniTrafStrmMetrics tsm_metrics;
+};
- if (NULL == pContext) {
- hddLog(VOS_TRACE_LEVEL_ERROR,
- "%s: Bad param, pContext [%pK]",
- __func__, pContext);
- return;
- }
+static void hdd_GetTsmStatsCB(tAniTrafStrmMetrics tsmMetrics,
+ const tANI_U32 staId,
+ void *pContext)
+{
+ struct hdd_request *request;
+ struct tsm_priv *priv;
- /* 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 */
- spin_lock(&hdd_context_lock);
+ ENTER();
+ request = hdd_request_get(pContext);
+ if (!request) {
+ hddLog(LOGE, FL("Obsolete request"));
+ return;
+ }
+ priv = hdd_request_priv(request);
+ priv->tsm_metrics = tsmMetrics;
+ hdd_request_complete(request);
+ hdd_request_put(request);
+ EXIT();
+}
- pStatsContext = pContext;
- pAdapter = pStatsContext->pAdapter;
- if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->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, pStatsContext->magic);
- return;
- }
+static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter,
+ const tANI_U8 tid,
+ tAniTrafStrmMetrics* pTsmMetrics)
+{
+ hdd_station_ctx_t *pHddStaCtx = NULL;
+ eHalStatus hstatus;
+ VOS_STATUS vstatus = VOS_STATUS_SUCCESS;
+ int ret;
+ hdd_context_t *pHddCtx = NULL;
+ void *cookie;
+ struct hdd_request *request;
+ struct tsm_priv *priv;
+ static const struct hdd_request_params params = {
+ .priv_size = sizeof(*priv),
+ .timeout_ms = WLAN_WAIT_TIME_STATS,
+ };
- /* context is valid so caller is still waiting */
+ if (!pAdapter) {
+ hddLog(LOGE, FL("pAdapter is NULL"));
+ return VOS_STATUS_E_FAULT;
+ }
- /* paranoia: invalidate the magic */
- pStatsContext->magic = 0;
-
- /* copy over the tsm stats */
- pAdapter->tsmStats.UplinkPktQueueDly = tsmMetrics.UplinkPktQueueDly;
- vos_mem_copy(pAdapter->tsmStats.UplinkPktQueueDlyHist,
- tsmMetrics.UplinkPktQueueDlyHist,
- sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/
- sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0]));
- pAdapter->tsmStats.UplinkPktTxDly = tsmMetrics.UplinkPktTxDly;
- pAdapter->tsmStats.UplinkPktLoss = tsmMetrics.UplinkPktLoss;
- pAdapter->tsmStats.UplinkPktCount = tsmMetrics.UplinkPktCount;
- pAdapter->tsmStats.RoamingCount = tsmMetrics.RoamingCount;
- pAdapter->tsmStats.RoamingDly = tsmMetrics.RoamingDly;
+ pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
+ pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
- /* notify the caller */
- complete(&pStatsContext->completion);
-
- /* serialization is complete */
- spin_unlock(&hdd_context_lock);
-}
+ request = hdd_request_alloc(&params);
+ if (!request) {
+ hddLog(LOGE, FL("Request allocation failure"));
+ return VOS_STATUS_E_NOMEM;
+ }
+ cookie = hdd_request_cookie(request);
-static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter,
- const tANI_U8 tid,
- tAniTrafStrmMetrics* pTsmMetrics)
-{
- hdd_station_ctx_t *pHddStaCtx = NULL;
- eHalStatus hstatus;
- VOS_STATUS vstatus = VOS_STATUS_SUCCESS;
- unsigned long rc;
- struct statsContext context;
- hdd_context_t *pHddCtx = NULL;
-
- if (NULL == pAdapter) {
- hddLog(LOGE, FL("pAdapter is NULL"));
- return VOS_STATUS_E_FAULT;
- }
+ /* query tsm stats */
+ hstatus = sme_GetTsmStats(pHddCtx->hHal, hdd_GetTsmStatsCB,
+ pHddStaCtx->conn_info.staId[ 0 ],
+ pHddStaCtx->conn_info.bssId,
+ cookie, pHddCtx->pvosContext, tid);
+ if (eHAL_STATUS_SUCCESS != hstatus) {
+ hddLog(VOS_TRACE_LEVEL_ERROR,
+ "%s: Unable to retrieve tsm statistics",
+ __func__);
+ vstatus = VOS_STATUS_E_FAULT;
+ goto cleanup;
+ }
- pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
- pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
+ ret = hdd_request_wait_for_response(request);
+ if (ret) {
+ hddLog(LOGE,
+ FL("SME timed out while retrieving tsm statistics"));
+ vstatus = VOS_STATUS_E_TIMEOUT;
+ goto cleanup;
+ }
- /* we are connected prepare our callback context */
- init_completion(&context.completion);
- context.pAdapter = pAdapter;
- context.magic = STATS_CONTEXT_MAGIC;
-
- /* query tsm stats */
- hstatus = sme_GetTsmStats(pHddCtx->hHal, hdd_GetTsmStatsCB,
- pHddStaCtx->conn_info.staId[ 0 ],
- pHddStaCtx->conn_info.bssId,
- &context, pHddCtx->pvosContext, tid);
- if (eHAL_STATUS_SUCCESS != hstatus) {
- hddLog(VOS_TRACE_LEVEL_ERROR,
- "%s: Unable to retrieve statistics",
- __func__);
- vstatus = VOS_STATUS_E_FAULT;
- } else {
- /* request was sent -- wait for the response */
- 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 statistics",
- __func__);
- vstatus = VOS_STATUS_E_TIMEOUT;
- }
- }
+ priv = hdd_request_priv(request);
+ *pTsmMetrics = priv->tsm_metrics;
- /* 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);
+cleanup:
+ hdd_request_put(request);
- if (VOS_STATUS_SUCCESS == vstatus) {
- pTsmMetrics->UplinkPktQueueDly = pAdapter->tsmStats.UplinkPktQueueDly;
- vos_mem_copy(pTsmMetrics->UplinkPktQueueDlyHist,
- pAdapter->tsmStats.UplinkPktQueueDlyHist,
- sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/
- sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0]));
- pTsmMetrics->UplinkPktTxDly = pAdapter->tsmStats.UplinkPktTxDly;
- pTsmMetrics->UplinkPktLoss = pAdapter->tsmStats.UplinkPktLoss;
- pTsmMetrics->UplinkPktCount = pAdapter->tsmStats.UplinkPktCount;
- pTsmMetrics->RoamingCount = pAdapter->tsmStats.RoamingCount;
- pTsmMetrics->RoamingDly = pAdapter->tsmStats.RoamingDly;
- }
- return vstatus;
+ return vstatus;
}
/**