wlan: Use request manager for station stats
propagation from qcacld-2.0 to prima
We are transitioning to the new request manager framework. Change
wlan_hdd_get_station_stats() and hdd_get_station_statistics_cb() to
this framework.
Change-Id: I4f0255975e8c37fa91215bcddc7896bb8d309cf8
CRs-Fixed: 2213584
diff --git a/CORE/HDD/src/wlan_hdd_wext.c b/CORE/HDD/src/wlan_hdd_wext.c
index 43a699a..9ce2b3d 100644
--- a/CORE/HDD/src/wlan_hdd_wext.c
+++ b/CORE/HDD/src/wlan_hdd_wext.c
@@ -3505,66 +3505,48 @@
return VOS_STATUS_SUCCESS;
}
-static void hdd_get_station_statisticsCB(void *pStats, void *pContext)
+struct stats_ctx {
+ tCsrSummaryStatsInfo summary_stats;
+ tCsrGlobalClassAStatsInfo class_a_stats;
+};
+
+static void hdd_get_station_statistics_cb(void *stats, void *context)
{
- struct statsContext *pStatsContext;
- tCsrSummaryStatsInfo *pSummaryStats;
- tCsrGlobalClassAStatsInfo *pClassAStats;
- hdd_adapter_t *pAdapter;
+ tCsrSummaryStatsInfo *summary_stats;
+ tCsrGlobalClassAStatsInfo *class_a_stats;
+ struct hdd_request *request;
+ struct stats_ctx *priv;
- if (ioctl_debug)
- {
- pr_info("%s: pStats [%pK] pContext [%pK]\n",
- __func__, pStats, pContext);
- }
- if ((NULL == pStats) || (NULL == pContext))
- {
- hddLog(VOS_TRACE_LEVEL_ERROR,
- "%s: Bad param, pStats [%pK] pContext [%pK]",
- __func__, pStats, pContext);
- return;
- }
+ if (ioctl_debug) {
+ pr_info("%s: stats [%pK] context [%pK]\n",
+ __func__, stats, context);
+ }
- /* 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);
+ if (NULL == stats) {
+ hddLog(VOS_TRACE_LEVEL_ERROR,
+ "%s: Bad param, stats [%pK]",
+ __func__, stats);
+ return;
+ }
- pSummaryStats = (tCsrSummaryStatsInfo *)pStats;
- pClassAStats = (tCsrGlobalClassAStatsInfo *)( pSummaryStats + 1 );
- 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);
- if (ioctl_debug)
- {
- pr_info("%s: Invalid context, pAdapter [%pK] magic [%08x]\n",
- __func__, pAdapter, pStatsContext->magic);
- }
- return;
- }
+ request = hdd_request_get(context);
+ if (!request) {
+ hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request"));
+ return;
+ }
- /* context is valid so caller is still waiting */
+ summary_stats = (tCsrSummaryStatsInfo *)stats;
+ class_a_stats = (tCsrGlobalClassAStatsInfo *)(summary_stats + 1);
- /* paranoia: invalidate the magic */
- pStatsContext->magic = 0;
+ priv = hdd_request_priv(request);
- /* copy over the stats. do so as a struct copy */
- pAdapter->hdd_stats.summary_stat = *pSummaryStats;
- pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
+ /* copy over the stats. do so as a struct copy */
+ priv->summary_stats = *summary_stats;
+ priv->class_a_stats = *class_a_stats;
- /* notify the caller */
- complete(&pStatsContext->completion);
-
- /* serialization is complete */
- spin_unlock(&hdd_context_lock);
+ hdd_request_complete(request);
+ hdd_request_put(request);
}
VOS_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
@@ -3572,9 +3554,15 @@
hdd_station_ctx_t *pHddStaCtx;
hdd_ap_ctx_t *sap_ctx;
eHalStatus hstatus;
- long lrc;
- struct statsContext context;
tANI_U8 sta_id;
+ int ret;
+ void *cookie;
+ struct hdd_request *request;
+ struct stats_ctx *priv;
+ static const struct hdd_request_params params = {
+ .priv_size = sizeof(*priv),
+ .timeout_ms = WLAN_WAIT_TIME_STATS,
+ };
if (NULL == pAdapter)
{
@@ -3590,11 +3578,12 @@
sta_id = pHddStaCtx->conn_info.staId[0];
}
- /* we are connected
- prepare our callback context */
- init_completion(&context.completion);
- context.pAdapter = pAdapter;
- context.magic = STATS_CONTEXT_MAGIC;
+ request = hdd_request_alloc(¶ms);
+ if (!request) {
+ hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure"));
+ return VOS_STATUS_E_NOMEM;
+ }
+ cookie = hdd_request_cookie(request);
/* query only for Summary & Class A statistics */
hstatus = sme_GetStatistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
@@ -3602,11 +3591,11 @@
SME_SUMMARY_STATS |
SME_GLOBAL_CLASSA_STATS |
SME_PER_PKT_STATS,
- hdd_get_station_statisticsCB,
+ hdd_get_station_statistics_cb,
0, // not periodic
FALSE, //non-cached results
sta_id,
- &context);
+ cookie);
if (eHAL_STATUS_SUCCESS != hstatus)
{
hddLog(VOS_TRACE_LEVEL_ERROR,
@@ -3617,37 +3606,31 @@
else
{
/* request was sent -- wait for the response */
- lrc = wait_for_completion_interruptible_timeout(&context.completion,
- msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
-
- if (lrc <= 0)
+ ret = hdd_request_wait_for_response(request);
+ if (ret)
{
hddLog(VOS_TRACE_LEVEL_ERROR,
- "%s: SME %s while retrieving statistics",
- __func__, (0 == lrc) ? "timeout" : "interrupt");
+ FL("SME timeout while retrieving statistics"));
+ }
+ else
+ {
+ priv = hdd_request_priv(request);
+ pAdapter->hdd_stats.summary_stat = priv->summary_stats;
+ pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
}
}
- /* 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);
+ /*
+ * 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);
/* either callback updated pAdapter stats or it has cached data */
return VOS_STATUS_SUCCESS;
}
-
/*
* Support for the LINKSPEED private command
* Per the WiFi framework the response must be of the form