wlan: MCC Adaptive Scheduler

MCC Adaptive Scheduler. By default this feature is disabled and can be
enabled using gEnableMCCAdaptiveScheduler=1 in INI file.

CR-Fixed: 434878
Change-Id: I9e5c41f2f2bf8318b4a4ce2bbd11fb1a04e69837
diff --git a/CORE/MAC/src/pe/lim/limLogDump.c b/CORE/MAC/src/pe/lim/limLogDump.c
index b1caa1f..c79e96a 100644
--- a/CORE/MAC/src/pe/lim/limLogDump.c
+++ b/CORE/MAC/src/pe/lim/limLogDump.c
@@ -70,6 +70,9 @@
 #include <limFT.h>
 #endif
 #include "smeInside.h"
+#include "wlan_qct_wda.h"
+
+void WDA_TimerTrafficStatsInd(tWDA_CbContext *pWDA);
 
 static char *getRole( tLimSystemRole role )
 {
@@ -2466,6 +2469,65 @@
 
   return p;
 }
+
+
+static char *
+dump_lim_mcc_policy_maker(tpAniSirGlobal pMac, tANI_U32 arg1,tANI_U32 arg2,tANI_U32 arg3, tANI_U32 arg4, char *p)
+{
+   VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_FATAL, "dump_lim_mcc_policy_maker arg = %d",arg1);
+    
+   if(arg1 == 0) //Disable feature completely
+   {  
+      WDA_TrafficStatsTimerActivate(FALSE);
+      if (ccmCfgSetInt(pMac, WNI_CFG_ENABLE_MCC_ADAPTIVE_SCHED, FALSE,
+          NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
+      {
+         limLog( pMac, LOGE, FL("Could not get WNI_CFG_ENABLE_MCC_ADAPTIVE_SCHED"));
+      }
+   }
+   else if(arg1 == 1) //Enable feature
+   {   
+      if (ccmCfgSetInt(pMac, WNI_CFG_ENABLE_MCC_ADAPTIVE_SCHED, TRUE,
+         NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
+      {
+        limLog( pMac, LOGE, FL("Could not set WNI_CFG_ENABLE_MCC_ADAPTIVE_SCHED"));
+      }    
+   }
+   else if(arg1 == 2) //Enable feature and activate periodic timer
+   {   
+      if (ccmCfgSetInt(pMac, WNI_CFG_ENABLE_MCC_ADAPTIVE_SCHED, TRUE,
+          NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
+      {
+         limLog( pMac, LOGE, FL("Could not set WNI_CFG_ENABLE_MCC_ADAPTIVE_SCHED"));
+      }
+      WDA_TrafficStatsTimerActivate(TRUE);
+   }
+   else if(arg1 == 3) //Enable only stats collection - Used for unit testing
+   {
+      VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_FATAL, "Enabling Traffic Stats in DTS");
+      WDI_DS_ActivateTrafficStats();
+   }
+   else if(arg1 == 4) //Send current stats snapshot to Riva -- Used for unit testing
+   {
+      v_VOID_t * pVosContext = vos_get_global_context(VOS_MODULE_ID_WDA, NULL);
+      tWDA_CbContext *pWDA =  vos_get_context(VOS_MODULE_ID_WDA, pVosContext);
+      ccmCfgSetInt(pMac, WNI_CFG_ENABLE_MCC_ADAPTIVE_SCHED, TRUE, NULL, eANI_BOOLEAN_FALSE);
+      WDA_TimerTrafficStatsInd(pWDA);
+      WDA_TrafficStatsTimerActivate(FALSE);
+      ccmCfgSetInt(pMac, WNI_CFG_ENABLE_MCC_ADAPTIVE_SCHED, FALSE,NULL, eANI_BOOLEAN_FALSE);
+   }
+   else if (arg1 == 5) //Change the periodicity of TX stats timer
+   {
+      v_VOID_t * pVosContext = vos_get_global_context(VOS_MODULE_ID_WDA, NULL);
+      tWDA_CbContext *pWDA =  vos_get_context(VOS_MODULE_ID_WDA, pVosContext);
+      if (tx_timer_change(&pWDA->wdaTimers.trafficStatsTimer, arg2, arg2) != TX_SUCCESS)
+      {
+          limLog(pMac, LOGP, FL("Disable timer before changing timeout value"));
+      }
+   }
+   return p;
+}
+
 static tDumpFuncEntry limMenuDumpTable[] = {
     {0,     "PE (300-499)",                                          NULL},
     {300,   "LIM: Dump state(s)/statistics <session id>",            dump_lim_info},
@@ -2535,6 +2597,7 @@
 #ifdef WLAN_FEATURE_11AC
     {366,   "PE.LIM: Send a VHT OPMode Action Frame",                dump_lim_vht_opmode_notification},
     {367,   "PE.LIM: Send a VHT Channel Switch Announcement",        dump_lim_vht_channel_switch_notification},
+    {368,   "PE.LIM: MCC Policy Maker",                              dump_lim_mcc_policy_maker},
 #endif
 };