wlan: Control chan avoidance indication through ini and ioctl

Provide mechanism to user to enable or disable channel avoidance
indication through ioctl and also control this mechanism using
"gOptimizeCAevent" ini parameter.

By default "gOPtimizeCAevent" ini parameter is disabled. Ini param
controls the CA events based on the mode. If ini is enabled(1) then
firmware will send CA events only in SAP/GO mode and it will not send
any CA events in STA mode. If ini is disabled CA events are sent to
host in all the modes.

a. gOptimizeCAevent = 1
   - When host sends ioctl(enable), FW will send "ONE" CA indication
     to host(though it is duplicate).
   - When host sends ioctl(disable), FW doesnot perform any action.
   - Whenever any change in CA and WLAN is SAP/P2P-GO mode, FW will
     send CA ind to host regardless of the ioctl status.
b. gOptimizeCAevent = 0
   - FW will ignore ioctl request if received.
   - CxM behavior will be as per the current implementation.

Change-Id: Ie453f35f3316da8a010fd4b7107feb585eabd3a6
CRs-Fixed: 903249
diff --git a/CORE/WDA/src/wlan_qct_wda.c b/CORE/WDA/src/wlan_qct_wda.c
index 7e99384..6331d62 100644
--- a/CORE/WDA/src/wlan_qct_wda.c
+++ b/CORE/WDA/src/wlan_qct_wda.c
@@ -262,6 +262,7 @@
 
 VOS_STATUS WDA_ProcessMonStartReq( tWDA_CbContext *pWDA, void* wdaRequest);
 VOS_STATUS WDA_ProcessMonStopReq( tWDA_CbContext *pWDA, void* wdaRequest);
+VOS_STATUS WDA_ProcessEnableDisableCAEventInd(tWDA_CbContext *pWDA, tANI_U8 val);
 /*
  * FUNCTION: WDA_ProcessNanRequest
  * Process NAN request
@@ -2253,6 +2254,19 @@
    }
    tlvStruct = (tHalCfg *)( (tANI_U8 *) tlvStruct
                            + sizeof(tHalCfg) + tlvStruct->length) ;
+   /* QWLAN_HAL_CFG_OPTIMIZE_CA_EVENT */
+   tlvStruct->type = QWLAN_HAL_CFG_OPTIMIZE_CA_EVENT ;
+   tlvStruct->length = sizeof(tANI_U32);
+   configDataValue = (tANI_U32 *)(tlvStruct + 1);
+   if (wlan_cfgGetInt(pMac, WNI_CFG_OPTIMIZE_CA_EVENT,
+                                            configDataValue ) != eSIR_SUCCESS)
+   {
+      VOS_TRACE( VOS_MODULE_ID_WDA, VOS_TRACE_LEVEL_ERROR,
+               "Failed to get value for WNI_CFG_OPTIMIZE_CA_EVENT");
+      goto handle_failure;
+   }
+   tlvStruct = (tHalCfg *)( (tANI_U8 *) tlvStruct
+                           + sizeof(tHalCfg) + tlvStruct->length) ;
 
    wdiStartParams->usConfigBufferLen = (tANI_U8 *)tlvStruct - tlvStructStart ;
 #ifdef WLAN_DEBUG
@@ -14559,7 +14573,11 @@
          WDA_ProcessMonStopReq(pWDA,NULL);
          break;
       }
-
+      case WDA_SEND_FREQ_RANGE_CONTROL_IND:
+      {
+         WDA_ProcessEnableDisableCAEventInd(pWDA, pMsg->bodyval);
+         break;
+      }
       default:
       {
          VOS_TRACE( VOS_MODULE_ID_WDA, VOS_TRACE_LEVEL_INFO,
@@ -19614,3 +19632,22 @@
     }
     return CONVERT_WDI2VOS_STATUS(status);
 }
+
+VOS_STATUS WDA_ProcessEnableDisableCAEventInd(tWDA_CbContext *pWDA, tANI_U8 val)
+{
+    WDI_Status status;
+    VOS_TRACE( VOS_MODULE_ID_WDA, VOS_TRACE_LEVEL_INFO,
+                 FL("---> %s"), __func__);
+    status = WDI_EnableDisableCAEventInd(val);
+    if (WDI_STATUS_PENDING == status)
+    {
+        VOS_TRACE( VOS_MODULE_ID_WDA, VOS_TRACE_LEVEL_INFO,
+                 FL("pending status received "));
+    }
+    else if (WDI_STATUS_SUCCESS_SYNC != status)
+    {
+       VOS_TRACE( VOS_MODULE_ID_WDA, VOS_TRACE_LEVEL_ERROR,
+               FL("Failure status %d"), status);
+    }
+    return CONVERT_WDI2VOS_STATUS(status) ;
+}