wlan: Use request manager to handle WE_SET_POWER requests
propagation from qcacld-2.0 to prima.
Use the new request manager framework for handling WE_SET_POWER
related iw requests.
Change-Id: I1d833ced2096a92b855cc861c84a448029e592b7
CRs-Fixed: 2213539
diff --git a/CORE/HDD/src/wlan_hdd_wext.c b/CORE/HDD/src/wlan_hdd_wext.c
index 6e0a5bb..2fcdded 100644
--- a/CORE/HDD/src/wlan_hdd_wext.c
+++ b/CORE/HDD/src/wlan_hdd_wext.c
@@ -4074,6 +4074,27 @@
pEncryptedDataRsp->encryptedPayload.length, 0);
}
+/**
+ * iw_power_callback_func() - Callback function registered with PMC
+ * @context: cookie originally registered with PMC
+ * @status: status code indicated by PMC state machine
+ *
+ * Return: None
+ */
+static void iw_power_callback_func(void *context, eHalStatus status)
+{
+ struct hdd_request *request = hdd_request_get(context);
+
+ if (!request) {
+ hddLog(VOS_TRACE_LEVEL_ERROR,
+ "%s: Obsolete request", __func__);
+ return;
+ }
+
+ hdd_request_complete(request);
+ hdd_request_put(request);
+}
+
VOS_STATUS wlan_hdd_enter_bmps(hdd_adapter_t *pAdapter, int mode)
{
struct statsContext context;
@@ -5858,6 +5879,8 @@
#ifdef CONFIG_HAS_EARLYSUSPEND
v_U8_t nEnableSuspendOld;
#endif
+ void *cookie;
+ struct hdd_request *request;
ENTER();
pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
@@ -5952,47 +5975,42 @@
{
case 0: //Full Power
{
- struct statsContext context;
eHalStatus status = eHAL_STATUS_FAILURE;
-
- init_completion(&context.completion);
-
- context.pAdapter = pAdapter;
- context.magic = POWER_CONTEXT_MAGIC;
+ static const struct hdd_request_params params = {
+ .priv_size = 0,
+ .timeout_ms = WLAN_WAIT_TIME_POWER,
+ };
if (NULL == hHal)
return -EINVAL;
+ 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);
+
status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
- iw_power_callback_fn, &context,
+ iw_power_callback_func, cookie,
eSME_FULL_PWR_NEEDED_BY_HDD);
if (eHAL_STATUS_PMC_PENDING == status)
{
- int lrc = wait_for_completion_interruptible_timeout(
- &context.completion,
- msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
-
- if (lrc <= 0)
- {
+ ret = hdd_request_wait_for_response(request);
+ if (ret) {
hddLog(VOS_TRACE_LEVEL_ERROR,
- "%s: SME %s while requesting fullpower",
- __func__, (0 == lrc) ?
- "timeout" : "interrupt");
+ FL("SME timeout while requesting bmps"));
}
}
- /* either we have a response or we timed out. 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);
hddLog(LOGE, "iwpriv Full Power completed");
break;
@@ -6011,45 +6029,40 @@
break;
case 3: //Request Bmps
{
- struct statsContext context;
eHalStatus status = eHAL_STATUS_FAILURE;
-
- init_completion(&context.completion);
-
- context.pAdapter = pAdapter;
- context.magic = POWER_CONTEXT_MAGIC;
+ static const struct hdd_request_params params = {
+ .priv_size = 0,
+ .timeout_ms = WLAN_WAIT_TIME_POWER,
+ };
if (NULL == hHal)
return -EINVAL;
+ 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);
+
status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter),
- iw_power_callback_fn, &context);
+ iw_power_callback_func, cookie);
if (eHAL_STATUS_PMC_PENDING == status)
{
- int lrc = wait_for_completion_interruptible_timeout(
- &context.completion,
- msecs_to_jiffies(WLAN_WAIT_TIME_POWER));
- if (lrc <= 0)
- {
+ ret = hdd_request_wait_for_response(request);
+ if (ret) {
hddLog(VOS_TRACE_LEVEL_ERROR,
- "%s: SME %s while requesting BMPS",
- __func__, (0 == lrc) ? "timeout" :
- "interrupt");
+ FL("SME timeout while requesting fullpower"));
}
}
- /* either we have a response or we timed out. 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);
hddLog(LOGE, "iwpriv Request BMPS completed");
break;