OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / system / wlan / ti / sta_dk_4_0_4_32 / common / src / Management / PowerMgr / PowerMgr.c
1 /** \file PowerMgr.c
2  *  \brief This is the PowerMgr module implementation.
3  *  \author Assaf Azulay
4  *  \date 24-Oct-2005
5  */
6 /****************************************************************************
7 **+-----------------------------------------------------------------------+**
8 **|                                                                       |**
9 **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved.      |**
10 **| All rights reserved.                                                  |**
11 **|                                                                       |**
12 **| Redistribution and use in source and binary forms, with or without    |**
13 **| modification, are permitted provided that the following conditions    |**
14 **| are met:                                                              |**
15 **|                                                                       |**
16 **|  * Redistributions of source code must retain the above copyright     |**
17 **|    notice, this list of conditions and the following disclaimer.      |**
18 **|  * Redistributions in binary form must reproduce the above copyright  |**
19 **|    notice, this list of conditions and the following disclaimer in    |**
20 **|    the documentation and/or other materials provided with the         |**
21 **|    distribution.                                                      |**
22 **|  * Neither the name Texas Instruments nor the names of its            |**
23 **|    contributors may be used to endorse or promote products derived    |**
24 **|    from this software without specific prior written permission.      |**
25 **|                                                                       |**
26 **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |**
27 **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |**
28 **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
29 **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |**
30 **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
31 **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |**
32 **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
33 **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
34 **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |**
35 **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
36 **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |**
37 **|                                                                       |**
38 **+-----------------------------------------------------------------------+**
39 ****************************************************************************/
40
41 /****************************************************************************
42  *                                                                          *
43  *   MODULE:  PowerMgr                                                      *
44  *   PURPOSE: PowerMgr Module implementation.                               *
45  *                                                                          *
46  ****************************************************************************/
47
48 #include "osTIType.h"
49 #include "osApi.h"
50 #include "paramOut.h"
51 #include "report.h"
52 #include "PowerMgr.h"
53 #include "PowerMgr_API.h"
54 #include "TrafficMonitorAPI.h"
55 #include "qosMngr_API.h"
56 #include "siteMgrApi.h"
57 #include "SoftGeminiApi.h"
58
59 /*****************************************************************************
60  **         Defines                                                         **
61  *****************************************************************************/
62 #define DEFAULT_LISTEN_INTERVAL (1)
63
64 #define BET_DISABLE 0
65 #define BET_ENABLE  1
66
67 /*****************************************************************************
68  **         Private Function prototypes                                      **
69  *****************************************************************************/
70
71 static void         powerSaveCompleteCB(TI_HANDLE hPowerMgr,UINT8 PSMode,UINT8 transStatus);
72 static void         PowerMgrTMThresholdCrossCB( TI_HANDLE hPowerMgr, UINT32 cookie );
73 static void         powerMgrDisableThresholdsIndications(TI_HANDLE hPowerMgr);
74 static void         powerMgrEnableThresholdsIndications(TI_HANDLE hPowerMgr);
75 static void         powerMgrStartAutoPowerMode(TI_HANDLE hPowerMgr);
76 static void         powerMgrRetryPsTimeout(TI_HANDLE hPowerMgr);
77 static void         powerMgrPowerProfileConfiguration(TI_HANDLE hPowerMgr, PowerMgr_PowerMode_e desiredPowerMode);
78 static TI_STATUS    powerMgrSendMBXWakeUpConditions(TI_HANDLE hPowerMgr,UINT8 listenInterval, PowerMgr_TnetWakeOn_e tnetWakeupOn);
79 static TI_STATUS    powerMgrNullPacketRateConfiguration(TI_HANDLE hPowerMgr);
80 static PowerMgr_PowerMode_e powerMgrGetHighestPriority(TI_HANDLE hPowerMgr);
81 static void         PowerMgr_setDozeModeInAuto(TI_HANDLE hPowerMgr,PowerMgr_PowerMode_e dozeMode);
82 static void         PowerMgrConfigBetToFw( TI_HANDLE hPowerMgr, UINT32 cookie );
83 static void         PowerMgr_PsPollFailureCB( TI_HANDLE hPowerMgr );
84 static void         powerMgr_PsPollFailureTimeout(TI_HANDLE hPowerMgr);
85 #ifdef CPU_LOAD
86         static void             powerMgr_CpuLoadTimeout(TI_HANDLE hPowerMgr);
87 #endif
88 static void powerMgr_SGSetUserDesiredwakeUpCond( TI_HANDLE hPowerMgr );
89
90
91 /*****************************************************************************
92  **         Public Function prototypes                                      **
93  *****************************************************************************/
94
95
96 /****************************************************************************************
97  *                        PowerMgr_create                                                           *
98  ****************************************************************************************
99 DESCRIPTION: Creates the object of the power Manager. 
100                 performs the following:
101                 -   Allocate the Power Manager handle
102                 -   Creates the retry timer
103                                                                                                                    
104 INPUT:          - hOs - Handle to OS        
105 OUTPUT:     
106 RETURN:     Handle to the Power Manager module on success, NULL otherwise
107 ****************************************************************************************/
108 TI_HANDLE PowerMgr_create(TI_HANDLE hOs)
109 {
110
111     PowerMgr_t * pPowerMgr = NULL;
112     pPowerMgr = (PowerMgr_t*) os_memoryAlloc (hOs, sizeof(PowerMgr_t));
113     if ( pPowerMgr == NULL )
114     {
115         WLAN_OS_REPORT(("PowerMgr_create - Memory Allocation Error!\n"));
116         return NULL;
117     }
118
119     os_memoryZero (hOs, pPowerMgr, sizeof(PowerMgr_t));
120
121     pPowerMgr->hOS = hOs;
122
123     /*create the timers */
124     pPowerMgr->hRetryPsTimer = os_timerCreate(pPowerMgr->hOS,
125                                               powerMgrRetryPsTimeout,
126                                               pPowerMgr);
127
128     pPowerMgr->hPsPollFailureTimer = os_timerCreate(pPowerMgr->hOS,
129                                             powerMgr_PsPollFailureTimeout,
130                                             pPowerMgr);
131
132         #ifdef CPU_LOAD
133                 pPowerMgr->hCpuLoadTimer = os_timerCreate(pPowerMgr->hOS,
134                                               powerMgr_CpuLoadTimeout,
135                                               pPowerMgr);
136         #endif
137
138
139     if ( (pPowerMgr->hPsPollFailureTimer == NULL) || (pPowerMgr->hRetryPsTimer == NULL) )
140     {
141         WLAN_OS_REPORT(("PowerMgr_create - Error in creating timer!\n"));
142         PowerMgr_destroy(pPowerMgr);
143         return NULL;
144     }
145
146     return pPowerMgr;
147
148 }
149
150
151 /****************************************************************************************
152 *                        powerSrv_destroy                                                          *
153 ****************************************************************************************
154 DESCRIPTION: Destroy the object of the power Manager.
155                -   delete Power Manager alocation
156                -   call the destroy function of the timer
157                                                                                                                   
158 INPUT:          - hPowerMgr - Handle to the Power Manager   
159 OUTPUT:     
160 RETURN:    TI_STATUS - OK on success else NOK.
161 ****************************************************************************************/
162 TI_STATUS PowerMgr_destroy(TI_HANDLE hPowerMgr)
163 {
164     PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
165
166     if ( pPowerMgr->hRetryPsTimer != NULL )
167     {
168         os_timerDestroy(pPowerMgr->hOS,
169                         pPowerMgr->hRetryPsTimer);
170     }
171
172     if ( pPowerMgr->hPsPollFailureTimer != NULL )
173     {
174         os_timerDestroy(pPowerMgr->hOS,
175             pPowerMgr->hPsPollFailureTimer);
176     }
177     os_memoryFree(pPowerMgr->hOS , pPowerMgr , sizeof(PowerMgr_t));
178
179     return OK;
180 }
181
182
183 /****************************************************************************************
184 *                        PowerMgr_init                                                         *
185 ****************************************************************************************
186 DESCRIPTION: Power Manager init function, called in configure phase.
187                                                                                                                  
188 INPUT:          - hPowerMgr             - Handle to the Power Manager
189           - hReport           - Handle to report.
190           - hSiteMgr          - Handle to site manager
191           - trafficMonitor        - Handle to Trrafic monitor
192           - pPowerMgrInitParams - initi parameters
193
194
195 OUTPUT:     
196 RETURN:    TI_STATUS - OK on success else NOK.
197 ****************************************************************************************/
198 TI_STATUS PowerMgr_init(    TI_HANDLE               hPowerMgr,
199                             TI_HANDLE               hMacServices,
200                             TI_HANDLE               hReport,
201                             TI_HANDLE               hSiteMgr,
202                             TI_HANDLE               hWhalCtrl,
203                             TI_HANDLE               hTrafficMonitor,
204                             TI_HANDLE               hSoftGemini, 
205                             PowerMgrInitParams_t *  pPowerMgrInitParams)
206 {
207     PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
208     UINT8 index;
209     /* used to initialize the Traffic Monitor for Auto Ps events */
210     TrafficAlertRegParm_t tmRegParam;
211     TI_STATUS status;
212
213     pPowerMgr->hReport      = hReport;
214     pPowerMgr->hTrafficMonitor = hTrafficMonitor;
215     pPowerMgr->hSiteMgr         = hSiteMgr;
216     pPowerMgr->hWhalCtrl        = hWhalCtrl;
217     pPowerMgr->hMacServices= hMacServices;
218     pPowerMgr->hSoftGemini = hSoftGemini;
219     pPowerMgr->psEnable         = FALSE;
220
221     /* init power management options */
222     pPowerMgr->beaconListenInterval = pPowerMgrInitParams->beaconListenInterval;
223     pPowerMgr->dtimListenInterval = pPowerMgrInitParams->dtimListenInterval;
224     pPowerMgr->defaultPowerLevel =  pPowerMgrInitParams->defaultPowerLevel;
225     pPowerMgr->PowerSavePowerLevel =  pPowerMgrInitParams->PowerSavePowerLevel;
226     pPowerMgr->powerMngPriority  = POWER_MANAGER_USER_PRIORITY;
227     pPowerMgr->maxFullBeaconInterval = pPowerMgrInitParams->MaximalFullBeaconReceptionInterval;
228     pPowerMgr->PsPollDeliveryFailureRecoveryPeriod = pPowerMgrInitParams->PsPollDeliveryFailureRecoveryPeriod;
229
230     /*
231      set AUTO PS parameters 
232      */
233     pPowerMgr->autoModeInterval = pPowerMgrInitParams->autoModeInterval;
234     pPowerMgr->autoModeActiveTH = pPowerMgrInitParams->autoModeActiveTH;
235     pPowerMgr->autoModeDozeTH = pPowerMgrInitParams->autoModeDozeTH;
236     pPowerMgr->autoModeDozeMode = pPowerMgrInitParams->autoModeDozeMode;
237
238     /*
239      register threshold in the traffic monitor.
240      */
241
242         pPowerMgr->betEnable = pPowerMgrInitParams->BetEnable; /* save BET enable flag for CLI configuration */
243         pPowerMgr->betTrafficEnable = FALSE;                   /* starting without BET */
244
245     /* BET thresholds */
246     /* general parameters */
247     tmRegParam.Context = pPowerMgr;
248     tmRegParam.TimeIntervalMs = BET_INTERVAL_VALUE;
249     tmRegParam.Trigger = TRAFF_EDGE;
250     tmRegParam.MonitorType = TX_RX_ALL_802_11_DATA_FRAMES;
251     tmRegParam.CallBack = PowerMgrConfigBetToFw;
252
253     /* BET enable event */
254     tmRegParam.Direction = TRAFF_DOWN;
255     tmRegParam.Threshold = pPowerMgrInitParams->BetEnableThreshold;
256         pPowerMgr->BetEnableThreshold = pPowerMgrInitParams->BetEnableThreshold;
257     tmRegParam.Cookie = (UINT32)BET_ENABLE;
258     pPowerMgr->betEnableTMEvent = TrafficMonitor_RegEvent(hTrafficMonitor,
259                                                              &tmRegParam,
260                                                              FALSE);
261     /* BET disable event */
262     tmRegParam.Direction = TRAFF_UP;
263     tmRegParam.Threshold = pPowerMgrInitParams->BetDisableThreshold;
264         pPowerMgr->BetDisableThreshold = pPowerMgrInitParams->BetDisableThreshold;
265     tmRegParam.Cookie = (UINT32)BET_DISABLE;
266     pPowerMgr->betDisableTMEvent = TrafficMonitor_RegEvent(hTrafficMonitor,
267                                                              &tmRegParam,
268                                                              FALSE);
269
270     if ( (pPowerMgr->betDisableTMEvent == NULL) ||
271          (pPowerMgr->betEnableTMEvent == NULL) )
272     {
273         WLAN_REPORT_INIT(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
274                          ("PowerMgr_init - TM - ERROR registering BET events - ABROTING init!\n"));
275         return NOK;
276     }
277     /*
278     set the events as resets for one another
279     */
280     status = TrafficMonitor_SetRstCondition(hTrafficMonitor,
281                                             pPowerMgr->betDisableTMEvent,
282                                             pPowerMgr->betEnableTMEvent,
283                                             TRUE);
284     if ( status != OK )
285     {
286         WLAN_REPORT_INIT(pPowerMgr->hReport,
287                          POWER_MANAGER_MODULE_LOG,
288                          ("PowerMgr_init - PowerMgr_init - ERROR binding BET events - ABROTING init!\n"));
289         return NOK;
290     }
291
292     /* general parameters */
293     tmRegParam.Context = pPowerMgr;
294     tmRegParam.Cookie = (UINT32)POWER_MODE_ACTIVE;
295     tmRegParam.TimeIntervalMs = pPowerMgr->autoModeInterval;
296     tmRegParam.Trigger = TRAFF_EDGE;
297     tmRegParam.MonitorType = TX_RX_ALL_802_11_DATA_FRAMES;
298
299     /* Active threshold */
300     tmRegParam.CallBack = PowerMgrTMThresholdCrossCB;
301     tmRegParam.Direction = TRAFF_UP;
302     tmRegParam.Threshold = pPowerMgr->autoModeActiveTH;
303     pPowerMgr->passToActiveTMEvent = TrafficMonitor_RegEvent(hTrafficMonitor,
304                                                              &tmRegParam,
305                                                              FALSE);
306     /* Doze threshold */
307     tmRegParam.Direction = TRAFF_DOWN;
308     tmRegParam.Threshold = pPowerMgr->autoModeDozeTH;
309     tmRegParam.Cookie = (UINT32)POWER_MODE_SHORT_DOZE; /* diffrentiation between long / short doze is done at the 
310                                                           CB, according to configuration at time of CB invokation */
311     pPowerMgr->passToDozeTMEvent = TrafficMonitor_RegEvent(hTrafficMonitor,
312                                                            &tmRegParam,
313                                                            FALSE);
314
315     if ( (pPowerMgr->passToActiveTMEvent == NULL) ||
316          (pPowerMgr->passToDozeTMEvent == NULL) )
317     {
318         WLAN_REPORT_INIT(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
319                          ("PowerMgr_init - PowerMgr_init - ERROR registering Auto mode events - ABROTING init!\n"));
320         return NOK;
321     }
322
323     /*
324     set the events as resets for one another
325     */
326     status = TrafficMonitor_SetRstCondition(hTrafficMonitor,
327                                             pPowerMgr->passToActiveTMEvent,
328                                             pPowerMgr->passToDozeTMEvent,
329                                             TRUE);
330     if ( status != OK )
331     {
332         WLAN_REPORT_INIT(pPowerMgr->hReport,
333                          POWER_MANAGER_MODULE_LOG,
334                          ("PowerMgr_init - PowerMgr_init - ERROR binding Auto mode events - ABROTING init!\n"));
335         return NOK;
336     }
337
338     /*
339     configure the initialize power mode
340     */
341     pPowerMgr->desiredPowerModeProfile = pPowerMgrInitParams->powerMode;
342     for ( index = 0;index < POWER_MANAGER_MAX_PRIORITY;index++ )
343     {
344         pPowerMgr->powerMngModePriority[index].powerMode = pPowerMgr->desiredPowerModeProfile;
345         pPowerMgr->powerMngModePriority[index].priorityEnable = FALSE;
346     }
347     pPowerMgr->powerMngModePriority[POWER_MANAGER_USER_PRIORITY].priorityEnable = TRUE;
348     /* set the defualt power policy */
349     MacServices_powerAutho_PowerPolicyUpdate(pPowerMgr->hMacServices, pPowerMgr->defaultPowerLevel);
350
351     /* Register and Enable the PsPoll failure */
352     whalCtrl_EventMbox_RegisterForEvent( pPowerMgr->hWhalCtrl, 
353         HAL_EVENT_PSPOLL_DELIVERY_FAILURE,
354         (void *)PowerMgr_PsPollFailureCB, 
355         hPowerMgr );
356     whalCtrl_EventMbox_Enable( pPowerMgr->hWhalCtrl, HAL_EVENT_PSPOLL_DELIVERY_FAILURE );
357
358
359     WLAN_REPORT_INIT(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
360                      ("PowerMgr_init - PowerMgr Initialized\n"));
361
362     return OK;
363 }
364
365 /****************************************************************************************
366  *                        PowerMgr_startPS                                                          *
367  ****************************************************************************************
368 DESCRIPTION: Start the power save algorithm of the driver and also the 802.11 PS.
369                                                                                                                    
370 INPUT:          - hPowerMgr             - Handle to the Power Manager
371
372 OUTPUT:     
373 RETURN:    TI_STATUS - OK or PENDING on success else NOK.\n
374 ****************************************************************************************/
375 TI_STATUS PowerMgr_startPS(TI_HANDLE hPowerMgr)
376 {
377     PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
378         int frameCount;
379
380     WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
381                             ("PowerMgr_startPS - called\n"));
382
383
384     if ( pPowerMgr->psEnable == TRUE )
385     {
386         WLAN_REPORT_ERROR(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
387                           ("PowerMgr_startPS - PS mechanism is already Enable! Aborting psEnable=%d !\n",
388                            pPowerMgr->psEnable));
389         /*
390         this is a FATAL ERROR of the power manager!
391         already enable power-save! thus return OK, but there is an error in the upper
392         layer that call tp PowerMgr_startPS() twice - should know that power-save
393         is already enable therefor print the Error message.
394         or
395         the state machine while NOT in PS can be only in ACTIVE state and in some cases in
396         PS_PENDING state. therefore the state machine is out of sync from it logic!
397         */
398         return OK;
399     }
400
401     pPowerMgr->psEnable = TRUE;
402     /*set the correct rate after connection*/
403     powerMgrNullPacketRateConfiguration(hPowerMgr);
404     /*
405     if in auto mode then need to refer to the threshold cross indication from the traffic monitor,
406     else it need to refer to the configured power mode profile from the user.
407     */
408
409     pPowerMgr->desiredPowerModeProfile = powerMgrGetHighestPriority(hPowerMgr);
410
411     if ( pPowerMgr->desiredPowerModeProfile == POWER_MODE_AUTO )
412     {
413         powerMgrStartAutoPowerMode(hPowerMgr);
414     }
415     else /*not auto mode - according to the current profle*/
416     {
417         powerMgrPowerProfileConfiguration(hPowerMgr, pPowerMgr->desiredPowerModeProfile);
418     }
419
420         
421         if (pPowerMgr->betEnable)
422         {
423                 TrafficMonitor_StartEventNotif(pPowerMgr->hTrafficMonitor,
424                                                                            pPowerMgr->betEnableTMEvent);
425
426                 TrafficMonitor_StartEventNotif(pPowerMgr->hTrafficMonitor,
427                                                                            pPowerMgr->betDisableTMEvent);
428
429         
430                 frameCount = TrafficMonitor_GetFrameBandwidth(pPowerMgr->hTrafficMonitor);
431         
432                 if (frameCount < pPowerMgr->BetEnableThreshold) 
433                 {
434                         pPowerMgr->betTrafficEnable = TRUE;
435                 }
436                 else if (frameCount > pPowerMgr->BetDisableThreshold) 
437                 {
438                         pPowerMgr->betTrafficEnable = FALSE;
439         }
440
441                 PowerMgrConfigBetToFw(hPowerMgr,pPowerMgr->betTrafficEnable);
442         }
443     
444     return OK;
445 }
446
447
448 /****************************************************************************************
449  *                        PowerMgr_stopPS                                                           *
450  ****************************************************************************************
451 DESCRIPTION: Stop the power save algorithm of the driver and also the 802.11 PS.
452                                                                                                                                
453 INPUT:          - hPowerMgr             - Handle to the Power Manager
454
455 OUTPUT:     
456 RETURN:    TI_STATUS - OK or PENDING on success else NOK.\n
457 ****************************************************************************************/
458 TI_STATUS PowerMgr_stopPS(TI_HANDLE hPowerMgr)
459 {
460     PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
461     /*TI_STATUS status;*/
462
463     WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
464                             ("PowerMgr_stopPS - called\n"));
465
466     if ( pPowerMgr->psEnable == FALSE )
467     {
468         WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
469                                 ("PowerMgr_stopPS - PS is already Disable! Aborting!\n"));
470         /*
471         Print Info message incase callng PowerMgr_stopPS() more than once in a row, without
472         calling to PowerMgr_startPS() in the middle.
473         this will return with OK and not doing the Stop action!
474         */
475         return OK;
476     }
477
478     pPowerMgr->psEnable = FALSE;
479     os_timerStop(pPowerMgr->hOS, pPowerMgr->hRetryPsTimer);
480
481     /* Check if PsPoll work-around is currently enabled */
482     if ( pPowerMgr->powerMngModePriority[POWER_MANAGER_PS_POLL_FAILURE_PRIORITY].priorityEnable == TRUE)
483     {
484         os_timerStop(pPowerMgr->hOS, pPowerMgr->hPsPollFailureTimer);
485         /* Exit the PsPoll work-around */
486         powerMgr_PsPollFailureTimeout( hPowerMgr );
487     }
488
489     if ( pPowerMgr->desiredPowerModeProfile == POWER_MODE_AUTO )
490     {
491         powerMgrDisableThresholdsIndications(hPowerMgr);
492     }
493
494     MacServices_powerSrv_SetPsMode(pPowerMgr->hMacServices, POWER_SAVE_OFF, FALSE,NULL, NULL, NULL);
495
496     /* set the power policy of the system */
497     MacServices_powerAutho_PowerPolicyUpdate(pPowerMgr->hMacServices, pPowerMgr->defaultPowerLevel);
498
499         if (pPowerMgr->betEnable)
500         {
501                 TrafficMonitor_StopEventNotif(pPowerMgr->hTrafficMonitor,
502                                                                           pPowerMgr->betEnableTMEvent);
503
504                 TrafficMonitor_StopEventNotif(pPowerMgr->hTrafficMonitor,
505                                                                           pPowerMgr->betDisableTMEvent);
506         }
507
508     return OK;
509 }
510
511
512 /****************************************************************************************
513  *                        PowerMgr_getPsStatus                                                          *
514  ****************************************************************************************
515 DESCRIPTION: returns the 802.11 power save status (enable / disable).
516                                                                                                                                
517 INPUT:          - hPowerMgr             - Handle to the Power Manager
518
519 OUTPUT:     
520 RETURN:    BOOLEAN - TRUE if enable else FALSE.\n
521 ****************************************************************************************/
522 BOOLEAN PowerMgr_getPsStatus(TI_HANDLE hPowerMgr)
523 {
524     PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
525     return  MacServices_powerSrv_getPsStatus(pPowerMgr->hMacServices);
526
527 }
528
529
530 /****************************************************************************************
531  *                        PowerMgr_setPowerMode                                                         *
532  ****************************************************************************************
533 DESCRIPTION: Configure of the PowerMode profile (auto / active / short doze / long doze).
534                                                                                                                                
535 INPUT:          - hPowerMgr             - Handle to the Power Manager
536             - thePowerMode      - the requested power mode (auto / active / short doze / long doze).
537 OUTPUT:     
538 RETURN:    TI_STATUS - OK on success else NOK.\n
539 ****************************************************************************************/
540 TI_STATUS PowerMgr_setPowerMode(TI_HANDLE hPowerMgr)
541 {
542     PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
543     PowerMgr_PowerMode_e powerMode;
544
545     /*in this way we will run with the highest priority that is enabled*/
546     powerMode = powerMgrGetHighestPriority(hPowerMgr);
547
548     /* sanity checking */
549     if ( powerMode >= POWER_MODE_MAX)
550     {
551         WLAN_REPORT_ERROR(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
552                           ("PowerMgr_setPowerMode - unknown parameter: %d\n", powerMode));
553         return NOK;
554     }
555
556     WLAN_REPORT_INFORMATION( pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
557                              ("PowerMgr_setPowerMode, power mode = %d\n", powerMode) );
558
559     if ( pPowerMgr->desiredPowerModeProfile != powerMode )
560     {
561         PowerMgr_PowerMode_e previousPowerModeProfile;
562         previousPowerModeProfile = pPowerMgr->desiredPowerModeProfile;
563         pPowerMgr->desiredPowerModeProfile = powerMode;
564
565         if ( pPowerMgr->desiredPowerModeProfile == POWER_MODE_AUTO )
566         {
567             if ( pPowerMgr->psEnable == TRUE )
568             {
569                 powerMgrStartAutoPowerMode(hPowerMgr);
570             }
571
572             /*
573             the transitions of state will be done according to the events from the
574             traffic monitor - therefor abort and wait event from the traffic monitor.
575             */
576             return OK;
577         }
578         else if ( previousPowerModeProfile == POWER_MODE_AUTO )
579         {
580             /*
581             if the old power mode is AUTO and the new power mode is NOT then need
582             to disable the thresholds indications from the traffic monitor.
583             */
584             powerMgrDisableThresholdsIndications(hPowerMgr);
585         }
586         if ( pPowerMgr->psEnable == TRUE )
587         {
588             powerMgrPowerProfileConfiguration(hPowerMgr, powerMode);
589         }
590     }
591     else
592     {
593         /*
594         the power mode is already configure to the module - don't need to do anything!
595         */
596         WLAN_REPORT_WARNING(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
597                             ("PowerMgr_setPowerMode - desiredPowerModeProfile == thePowerMode (=%d), ABORTING!\n",
598                              powerMode));
599     }
600
601     return OK;
602 }
603
604
605 /****************************************************************************************
606  *                        PowerMgr_reloadPowerMode                                      *
607  ****************************************************************************************
608 DESCRIPTION: Sends the current power mode configuration to the firmware.                                                                                        
609 INPUT:       - hPowerMgr             - Handle to the Power Manager
610 OUTPUT:     
611 RETURN:   
612 ****************************************************************************************/
613 void PowerMgr_reloadPowerMode(TI_HANDLE hPowerMgr)
614 {
615     PowerMgr_t * pPowerMgr = (PowerMgr_t *) hPowerMgr;
616
617     pPowerMgr->desiredPowerModeProfile = powerMgrGetHighestPriority(hPowerMgr);
618
619     if (pPowerMgr->psEnable == TRUE)
620     {
621         if (pPowerMgr->desiredPowerModeProfile == POWER_MODE_AUTO)
622         {
623             powerMgrStartAutoPowerMode(hPowerMgr);
624         }
625         else
626         {
627             powerMgrPowerProfileConfiguration(hPowerMgr, pPowerMgr->desiredPowerModeProfile);
628         }
629     }
630 }
631
632
633 /****************************************************************************************
634  *                        PowerMgr_setDozeModeInAuto                                    *
635  ****************************************************************************************
636 DESCRIPTION: Configure the doze mode (short-doze / long-doze) that auto mode will toggle between doze vs active.                                                                                        
637 INPUT:      - hPowerMgr             - Handle to the Power Manager
638             - dozeMode      - the requested doze mode when Mgr is in Auto mode (short-doze / long-doze)
639 OUTPUT:     
640 RETURN:   
641 ****************************************************************************************/
642 void PowerMgr_setDozeModeInAuto(TI_HANDLE hPowerMgr, PowerMgr_PowerMode_e dozeMode)
643 {
644     PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
645     PowerMgr_PowerMode_e powerMode = powerMgrGetHighestPriority(hPowerMgr);
646
647     /* check if we are trying to configure the same Doze mode */
648     if ( dozeMode != pPowerMgr->autoModeDozeMode )
649     {
650         WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
651                                 ("PowerMgr_setDozeModeInAuto - autoModeDozeMode == %d \n",
652                                  dozeMode));
653
654         pPowerMgr->autoModeDozeMode = dozeMode;
655
656         /* in case we are already in Auto mode, we have to set the wake up condition MIB */
657         if ( powerMode == POWER_MODE_AUTO )
658         {
659             if ( dozeMode == POWER_MODE_SHORT_DOZE )
660             {
661                 if ( pPowerMgr->beaconListenInterval > 1 )
662                 {
663                     powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->beaconListenInterval,TNET_WAKE_ON_N_BEACON);       
664                 }
665                 else
666                 {
667                     powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->beaconListenInterval,TNET_WAKE_ON_BEACON);     
668                 }
669             }
670             else  /* POWER_MODE_LONG_DOZE */
671             {
672                 if ( pPowerMgr->dtimListenInterval > 1 )
673                 {
674                     powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->dtimListenInterval,TNET_WAKE_ON_N_DTIM);       
675                 }
676                 else
677                 {
678                     powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->dtimListenInterval,TNET_WAKE_ON_DTIM);     
679                 }
680             }
681
682             WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
683                                     ("PowerMgr_setDozeModeInAuto - already in Auto\n"));
684         }
685     }
686     else
687     {
688         WLAN_REPORT_WARNING(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
689                             ("PowerMgr_setDozeModeInAuto - autoModeDozeMode == %d (same same ...)\n",
690                              dozeMode));
691     }
692 }
693
694 /****************************************************************************************
695  *                        PowerMgr_getPowerMode                                                         *
696  ****************************************************************************************
697 DESCRIPTION: Get the current PowerMode of the PowerMgr module. 
698                                                                                                                                
699 INPUT:          - hPowerMgr             - Handle to the Power Manager
700 OUTPUT:     
701 RETURN:    PowerMgr_PowerMode_e - (auto / active / short doze / long doze).\n
702 ****************************************************************************************/
703 PowerMgr_PowerMode_e PowerMgr_getPowerMode(TI_HANDLE hPowerMgr)
704 {
705     PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
706
707     return pPowerMgr->desiredPowerModeProfile;
708 }
709
710
711 /**
712  * \author Yossi Peery
713  * \date 2-August-2004\n
714  * \brief reset the power manager module due to recovry event.
715  *
716  * Function Scope \e Public.\n
717  * Parameters:\n
718  * 1) TI_HANDLE - handle to the PowerMgr object.\n
719  * Return Value: TI_STATUS - OK on success else NOK.\n
720  * \b Description:\n
721  * simulate the stop power save function without writing to the HW. just doing the
722  * logic parts of stop power save from the power manager to it state machine.
723  * the power controller and it state machine are reset in the whalCtrl recovry proccess.
724 */
725 TI_STATUS PowerMgr_swReset(TI_HANDLE hPowerMgr)
726 {
727     PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
728
729     WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
730                             ("PowerMgr_swReset() called\n"));
731
732
733     pPowerMgr->psEnable = FALSE;
734
735     if ( pPowerMgr->desiredPowerModeProfile == POWER_MODE_AUTO )
736     {
737         powerMgrDisableThresholdsIndications(hPowerMgr);
738     }
739     os_timerStop(pPowerMgr->hOS, pPowerMgr->hRetryPsTimer);
740     return OK;
741 }
742
743 TI_STATUS powerMgr_setParam(TI_HANDLE thePowerMgrHandle,
744                             paramInfo_t *theParamP)
745 {
746     PowerMgr_t *pPowerMgr = (PowerMgr_t*)thePowerMgrHandle;
747
748     switch ( theParamP->paramType )
749     {
750     case POWER_MGR_POWER_MODE:
751         pPowerMgr->powerMngModePriority[theParamP->content.powerMngPowerMode.powerMngPriority].powerMode
752                         = theParamP->content.powerMngPowerMode.PowerMode;
753         PowerMgr_setPowerMode(thePowerMgrHandle);
754                 if (pPowerMgr->betEnable)
755                 {
756                         PowerMgrConfigBetToFw(thePowerMgrHandle, pPowerMgr->betTrafficEnable );
757                 }
758         break;
759
760     case POWER_MGR_DISABLE_PRIORITY:
761         pPowerMgr->powerMngModePriority[theParamP->content.powerMngPriority].priorityEnable = FALSE;
762         PowerMgr_setPowerMode(thePowerMgrHandle);
763         break;
764
765     case POWER_MGR_ENABLE_PRIORITY:
766         pPowerMgr->powerMngModePriority[theParamP->content.powerMngPriority].priorityEnable = TRUE;
767         PowerMgr_setPowerMode(thePowerMgrHandle);
768         break;
769
770     case POWER_MGR_POWER_LEVEL_PS:
771         pPowerMgr->PowerSavePowerLevel = theParamP->content.PowerSavePowerLevel;
772         /* set the power policy of the system */
773                 if (pPowerMgr->psEnable && (pPowerMgr->desiredPowerModeProfile!=POWER_MODE_AUTO))
774                 {       /* If Connected  and not in AUTO mode */
775                         MacServices_powerAutho_PowerPolicyUpdate(pPowerMgr->hMacServices, pPowerMgr->PowerSavePowerLevel);
776                 }
777         break;
778
779     case POWER_MGR_POWER_LEVEL_DEFAULT:
780         pPowerMgr->defaultPowerLevel = theParamP->content.DefaultPowerLevel;
781                 /* set the power policy of the system */
782                 if (!pPowerMgr->psEnable)
783                 {       /* If not Connected */
784                         MacServices_powerAutho_PowerPolicyUpdate(pPowerMgr->hMacServices, pPowerMgr->defaultPowerLevel);
785                 }
786         break;
787
788     case POWER_MGR_POWER_LEVEL_DOZE_MODE:
789         PowerMgr_setDozeModeInAuto(thePowerMgrHandle,theParamP->content.powerMngDozeMode);
790                 if (pPowerMgr->betEnable)
791                 {
792                         PowerMgrConfigBetToFw(thePowerMgrHandle, pPowerMgr->betTrafficEnable );
793                 }
794         break;
795
796     default:
797         WLAN_REPORT_ERROR(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
798                           ("PowerMgr_setParam - ERROR - Param is not supported, %d\n\n",
799                            theParamP->paramType));
800
801         return PARAM_NOT_SUPPORTED;
802     }
803
804     return OK;
805 }
806
807
808
809 TI_STATUS powerMgr_getParam(TI_HANDLE thePowerMgrHandle,
810                             paramInfo_t *theParamP)
811 {
812     PowerMgr_t *pPowerMgr = (PowerMgr_t*)thePowerMgrHandle;
813
814     switch ( theParamP->paramType )
815     {
816     case POWER_MGR_POWER_MODE:
817         theParamP->content.PowerMode = PowerMgr_getPowerMode(thePowerMgrHandle);
818         break;
819
820     case POWER_MGR_POWER_LEVEL_PS:
821         theParamP->content.PowerSavePowerLevel = pPowerMgr->PowerSavePowerLevel;
822         break;
823
824     case POWER_MGR_POWER_LEVEL_DEFAULT:
825         theParamP->content.DefaultPowerLevel = pPowerMgr->defaultPowerLevel;
826         break;
827
828     case POWER_MGR_POWER_LEVEL_DOZE_MODE:
829         theParamP->content.powerMngDozeMode = pPowerMgr->autoModeDozeMode;
830         break;
831
832     default:
833         WLAN_REPORT_ERROR(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
834                           ("PowerMgr_getParam - ERROR - Param is not supported, %d\n\n",
835                            theParamP->paramType));
836         return PARAM_NOT_SUPPORTED;
837     }
838
839     return OK;
840 }
841
842
843 /*****************************************************************************
844  **         Private Function prototypes                                     **
845  *****************************************************************************/
846
847
848 /****************************************************************************************
849  *                        powerSaveCompleteCB                                                       *
850  ****************************************************************************************
851 DESCRIPTION: Callback for the Power server complete - gets the result of the request 
852               for PS or exit PS.
853                                                                                                                                
854 INPUT:          - hPowerMgr             - Handle to the Power Manager
855             - PSMode
856             - trasStatus            - result string form the FW.
857 OUTPUT:     
858 RETURN:    void.\n
859 ****************************************************************************************/
860 static void powerSaveCompleteCB(TI_HANDLE hPowerMgr,UINT8 PSMode,UINT8 transStatus)
861 {
862     PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
863
864     WLAN_REPORT_INFORMATION( pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
865                              ("powerSaveCompleteCB, statud = %d\n", transStatus) );
866
867     /* Handling the event*/
868     switch ( (EventsPowerSave_e)transStatus )
869     {
870     case ENTER_POWER_SAVE_FAIL:
871     case EXIT_POWER_SAVE_FAIL:
872         pPowerMgr->lastPsTransaction = transStatus;
873         os_timerStart(pPowerMgr->hOS,
874                       pPowerMgr->hRetryPsTimer,
875                       RE_ENTER_PS_TIMEOUT,
876                       FALSE);
877         break;
878
879     case ENTER_POWER_SAVE_SUCCESS:
880         if ( (pPowerMgr->lastPowerModeProfile == POWER_MODE_SHORT_DOZE) ||
881              (pPowerMgr->lastPowerModeProfile == POWER_MODE_LONG_DOZE)  ||
882                          (pPowerMgr->lastPowerModeProfile == POWER_MODE_PS_ONLY))
883         {
884             MacServices_powerAutho_PowerPolicyUpdate(pPowerMgr->hMacServices, pPowerMgr->PowerSavePowerLevel);
885         }
886
887     case EXIT_POWER_SAVE_SUCCESS:
888         break;
889
890     default:
891         WLAN_REPORT_ERROR( pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
892                            ("powerSaveCompleteCB: invliad status: %d\n", transStatus) );
893         break;
894     }
895 }
896
897 /**
898  * \author Ronen Kalish\n
899  * \date 30-Aug-2006\n
900  * \brief Power manager callback fro TM event notification
901  *
902  * Function Scope \e Public.\n
903  * \param hPowerMgr - handle to the power maanger object.\n
904  * \param cookie - values supplied during event registration (active / doze).\n
905  */
906 static void PowerMgrTMThresholdCrossCB( TI_HANDLE hPowerMgr, UINT32 cookie )
907 {
908     PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
909
910     WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
911                             ("PowerMgrTMThresholdCrossCB - TM notified threshold crossed, cookie: %d\n",
912                              cookie));
913
914     /* sanity cehcking - TM notifications should only be received when PM is enabled and in auto mode */
915     if ( (pPowerMgr->psEnable == TRUE) && (pPowerMgr->desiredPowerModeProfile == POWER_MODE_AUTO) )
916     {
917         switch ((PowerMgr_PowerMode_e)cookie)
918         {
919         case POWER_MODE_ACTIVE:
920             powerMgrPowerProfileConfiguration( hPowerMgr, POWER_MODE_ACTIVE );
921             break;
922
923         /* threshold crossed down - need to enter configured doze mode */
924         case POWER_MODE_SHORT_DOZE:
925             powerMgrPowerProfileConfiguration( hPowerMgr, pPowerMgr->autoModeDozeMode );
926             break;
927
928         default:
929             WLAN_REPORT_ERROR( pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
930                                ("PowerMgrTMThresholdCrossCB: TM notification with invalid cookie: %d!\n",
931                                 cookie) );
932             break;
933         }
934     }
935     else
936     {
937         WLAN_REPORT_ERROR( pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
938                            ("PowerMgrTMThresholdCrossCB: TM motification when psEnable is :%d or desired profile is: %d\n",
939                             pPowerMgr->psEnable, pPowerMgr->desiredPowerModeProfile) );
940     }
941
942 }
943
944 /****************************************************************************************
945 *                        powerMgrDisableThresholdsIndications                                           *
946 *****************************************************************************************
947 DESCRIPTION: This will send a disable message to the traffic monitor,
948                  to stop sending indications on threshold pass.
949
950                                                                                                                               
951 INPUT:          - hPowerMgr             - Handle to the Power Manager
952 OUTPUT:     
953 RETURN:    void.\n
954 ****************************************************************************************/
955 static void powerMgrDisableThresholdsIndications(TI_HANDLE hPowerMgr)
956 {
957     PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
958
959     /*
960     auto is not a static/fix state, else its a dynamic state that flows between
961     the 3 static/fix states: active, short-doze and long-doze.
962     */
963     TrafficMonitor_StopEventNotif(pPowerMgr->hTrafficMonitor,
964                                   pPowerMgr->passToActiveTMEvent);
965
966     TrafficMonitor_StopEventNotif(pPowerMgr->hTrafficMonitor,
967                                   pPowerMgr->passToDozeTMEvent);
968
969 }
970
971
972 /****************************************************************************************
973 *                        powerMgrEnableThresholdsIndications                                            *
974 *****************************************************************************************
975 DESCRIPTION: TThis will send an enable message to the traffic monitor,
976                 to start sending indications on threshold pass.
977
978                                                                                                                               
979 INPUT:          - hPowerMgr             - Handle to the Power Manager
980 OUTPUT:     
981 RETURN:    void.\n
982 ****************************************************************************************/
983 static void powerMgrEnableThresholdsIndications(TI_HANDLE hPowerMgr)
984 {
985     PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
986
987     WLAN_REPORT_INFORMATION( pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
988                              ("powerMgrEnableThresholdsIndications called\n") );
989     /*
990     auto is not a static/fix state, but rather a dynamic state that flows between
991     the 3 static/fix states: active, short-doze and long-doze.
992     */
993     TrafficMonitor_StartEventNotif(pPowerMgr->hTrafficMonitor,
994                                    pPowerMgr->passToActiveTMEvent);
995
996     TrafficMonitor_StartEventNotif(pPowerMgr->hTrafficMonitor,
997                                    pPowerMgr->passToDozeTMEvent);
998
999 }
1000
1001
1002 /****************************************************************************************
1003 *                        powerMgrStartAutoPowerMode                                                 *
1004 *****************************************************************************************
1005 DESCRIPTION: configure the power manager to enter into AUTO power mode. 
1006              The power manager will deside what power level will be applied 
1007              acording to the traffic monitor.
1008                                                                                                                               
1009 INPUT:          - hPowerMgr             - Handle to the Power Manager
1010 OUTPUT:     
1011 RETURN:    void.\n
1012 ****************************************************************************************/
1013 static void powerMgrStartAutoPowerMode(TI_HANDLE hPowerMgr)
1014 {
1015     PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
1016     int frameCount;
1017
1018     frameCount = TrafficMonitor_GetFrameBandwidth(pPowerMgr->hTrafficMonitor);
1019
1020     WLAN_REPORT_INFORMATION( pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
1021                              ("powerMgrStartAutoPowerMode: Starting auto power mode,"
1022                               "frame count=%d, TH=%d\n", frameCount, pPowerMgr->autoModeActiveTH) );
1023
1024     /*Activates the correct profile*/
1025     if ( frameCount >= pPowerMgr->autoModeActiveTH )
1026     {
1027         powerMgrPowerProfileConfiguration(hPowerMgr, POWER_MODE_ACTIVE);
1028     }
1029     else
1030     {
1031         powerMgrPowerProfileConfiguration(hPowerMgr, pPowerMgr->autoModeDozeMode);
1032
1033     }
1034     /* Activates the Trafic monitoe Events*/        
1035     powerMgrEnableThresholdsIndications(hPowerMgr);
1036 }
1037
1038 /****************************************************************************************
1039 *                        powerMgrRetryPsTimeout                                                     *
1040 *****************************************************************************************
1041 DESCRIPTION: Retry function if a PS/exit PS request failed
1042                                                                                                                               
1043 INPUT:          - hPowerMgr             - Handle to the Power Manager
1044 OUTPUT:     
1045 RETURN:    void.\n
1046 ****************************************************************************************/
1047 static void powerMgrRetryPsTimeout(TI_HANDLE hPowerMgr)
1048 {
1049     PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
1050     TI_STATUS powerStatus;
1051
1052     WLAN_REPORT_INFORMATION( pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
1053                              ("powerMgrRetryPsTimeout: timer expired.\n") );
1054
1055     if ( pPowerMgr->lastPsTransaction == ENTER_POWER_SAVE_FAIL )
1056     {
1057         powerStatus = MacServices_powerSrv_SetPsMode(pPowerMgr->hMacServices, POWER_SAVE_ON, TRUE , hPowerMgr,powerSaveCompleteCB,NULL);/*NULL as GWSI callback*/
1058         if ( powerStatus == POWER_SAVE_802_11_IS_CURRENT )
1059         {
1060             if ( (pPowerMgr->lastPowerModeProfile == POWER_MODE_SHORT_DOZE) || 
1061                  (pPowerMgr->lastPowerModeProfile == POWER_MODE_LONG_DOZE)  ||
1062                                  (pPowerMgr->lastPowerModeProfile == POWER_MODE_PS_ONLY))
1063             {
1064                 MacServices_powerAutho_PowerPolicyUpdate(pPowerMgr->hMacServices, pPowerMgr->PowerSavePowerLevel);              
1065             }
1066         }
1067     }
1068     else
1069     {
1070         powerStatus = MacServices_powerSrv_SetPsMode(pPowerMgr->hMacServices, POWER_SAVE_OFF, TRUE , hPowerMgr,powerSaveCompleteCB,NULL);/*NULL as GWSI callback*/
1071     }
1072
1073 }
1074
1075
1076 /****************************************************************************************
1077 *                        powerMgrPowerProfileConfiguration                                          *
1078 *****************************************************************************************
1079 DESCRIPTION: This function is the " builder " of the Power Save profiles. 
1080              acording to the desired Power mode.
1081                                                                                                                               
1082 INPUT:          - hPowerMgr             - Handle to the Power Manager
1083 OUTPUT:     
1084 RETURN:    void.\n
1085 ****************************************************************************************/
1086 static void powerMgrPowerProfileConfiguration(TI_HANDLE hPowerMgr, PowerMgr_PowerMode_e desiredPowerMode)
1087 {
1088     PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
1089     TI_STATUS powerStatus;
1090
1091     os_timerStop(pPowerMgr->hOS, pPowerMgr->hRetryPsTimer);
1092
1093         pPowerMgr->lastPowerModeProfile = desiredPowerMode;
1094
1095     switch ( desiredPowerMode )
1096     {
1097     case POWER_MODE_AUTO:
1098         WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
1099                                 ("PowerMode==AUTO - This mode should not be sent to the GWSI - we send AUTO instead\n"));
1100         break;
1101
1102     case POWER_MODE_ACTIVE:
1103         /* set AWAKE through */
1104         MacServices_powerAutho_PowerPolicyUpdate(pPowerMgr->hMacServices, POWERAUTHO_POLICY_AWAKE);
1105         powerStatus = MacServices_powerSrv_SetPsMode(pPowerMgr->hMacServices,
1106                                                      POWER_SAVE_OFF, 
1107                                                      TRUE , 
1108                                                      hPowerMgr,
1109                                                      powerSaveCompleteCB,
1110                                                      NULL);
1111         WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
1112                                 ("PowerMode==ACTIVE\n"));
1113         break;
1114
1115     case POWER_MODE_SHORT_DOZE:
1116         if ( pPowerMgr->beaconListenInterval > 1 )
1117         {
1118             powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->beaconListenInterval,TNET_WAKE_ON_N_BEACON);       
1119         }
1120         else
1121         {
1122             powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->beaconListenInterval,TNET_WAKE_ON_BEACON);     
1123         }
1124
1125         powerStatus = MacServices_powerSrv_SetPsMode(pPowerMgr->hMacServices, 
1126                                                      POWER_SAVE_ON, 
1127                                                      TRUE , 
1128                                                      hPowerMgr,
1129                                                      powerSaveCompleteCB,
1130                                                      NULL);
1131         if ( powerStatus == POWER_SAVE_802_11_IS_CURRENT )
1132         {
1133             MacServices_powerAutho_PowerPolicyUpdate(pPowerMgr->hMacServices, pPowerMgr->PowerSavePowerLevel);
1134         }
1135         WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
1136                                 ("PowerMode==SHORT_DOZE\n"));
1137         break;
1138
1139     case POWER_MODE_LONG_DOZE:
1140         if ( pPowerMgr->dtimListenInterval > 1 )
1141         {
1142             powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->dtimListenInterval,TNET_WAKE_ON_N_DTIM);       
1143         }
1144         else
1145         {
1146             powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->dtimListenInterval,TNET_WAKE_ON_DTIM);     
1147         }
1148         powerStatus = MacServices_powerSrv_SetPsMode(pPowerMgr->hMacServices, 
1149                                                      POWER_SAVE_ON, 
1150                                                      TRUE , 
1151                                                      hPowerMgr,
1152                                                      powerSaveCompleteCB,
1153                                                      NULL);
1154         if ( powerStatus == POWER_SAVE_802_11_IS_CURRENT )
1155         {
1156             MacServices_powerAutho_PowerPolicyUpdate(pPowerMgr->hMacServices, pPowerMgr->PowerSavePowerLevel);
1157         }
1158
1159         WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
1160                                 ("PowerMode==LONG_DOZE\n"));
1161         break;
1162
1163         case POWER_MODE_PS_ONLY:
1164                 /* When in SG PS mode, configure the user desired wake-up condition */
1165                 powerMgr_SGSetUserDesiredwakeUpCond(hPowerMgr);
1166         powerStatus = MacServices_powerSrv_SetPsMode(pPowerMgr->hMacServices, 
1167                                                      POWER_SAVE_ON, 
1168                                                      TRUE , 
1169                                                      hPowerMgr,
1170                                                      powerSaveCompleteCB,
1171                                                      NULL);
1172
1173                 /* In PS_ONLY we will use the last powerAutho policy of SHORT or LONG DOZE or ACTIVE */
1174                 if ( powerStatus == POWER_SAVE_802_11_IS_CURRENT )
1175                 {
1176                         MacServices_powerAutho_PowerPolicyUpdate(pPowerMgr->hMacServices, pPowerMgr->PowerSavePowerLevel);
1177                 }
1178
1179         WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
1180                                 ("PowerMode==PS_ONLY\n"));
1181         break;
1182
1183     default:
1184         WLAN_REPORT_ERROR(pPowerMgr->hReport,
1185                           POWER_MANAGER_MODULE_LOG,
1186                           ("PowerMgr_setWakeUpConfiguration - ERROR - PowerMode - unknown parameter: %d\n",
1187                            desiredPowerMode));
1188         return;
1189     }
1190
1191 }
1192
1193
1194 /****************************************************************************************
1195 *                        powerMgrSendMBXWakeUpConditions                                            *
1196 *****************************************************************************************
1197 DESCRIPTION: Tsend configuration of the power management option that holds in the command
1198                 mailbox inner sturcture.
1199                                                                                                                               
1200 INPUT:          - hPowerMgr             - Handle to the Power Manager
1201 OUTPUT:     
1202 RETURN:    TI_STATUS - OK on success else NOK.\n
1203 ****************************************************************************************/
1204 static TI_STATUS powerMgrSendMBXWakeUpConditions(TI_HANDLE hPowerMgr,
1205                                                  UINT8 listenInterval,
1206                                                  PowerMgr_TnetWakeOn_e tnetWakeupOn)
1207 {
1208     PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
1209     whalCtrl_powerMgmtConfig_t powerMgmtConfig;
1210     TI_STATUS status = OK;
1211
1212     powerMgmtConfig.listenInterval = listenInterval;
1213     powerMgmtConfig.tnetWakeupOn = tnetWakeupOn;
1214
1215     WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
1216                             ("powerMgrSendMBXWakeUpConditions: listenInterval = %d, tnetWakeupOn = %d\n",
1217                              listenInterval,tnetWakeupOn));
1218
1219     status = whalCtrl_wakeUpCondition(pPowerMgr->hWhalCtrl,
1220                                       powerMgmtConfig);
1221     if ( status != OK )
1222     {
1223         WLAN_REPORT_ERROR(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
1224                           ("powerMgrSendMBXWakeUpConditions - Error in wae up condition IE!\n"));
1225     }
1226     return status;
1227 }
1228
1229
1230
1231
1232 static TI_STATUS powerMgrNullPacketRateConfiguration(TI_HANDLE hPowerMgr)
1233 {
1234     paramInfo_t     param;
1235     PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
1236
1237     param.paramType = SITE_MGR_CURRENT_RATE_PAIR_PARAM;
1238     if ( siteMgr_getParam(pPowerMgr->hSiteMgr, &param) == OK )
1239     {
1240         MacServices_powerSrv_SetRateModulation(pPowerMgr->hMacServices, (UINT16)param.content.siteMgrCurrentRateMask.basicRateMask);
1241     }
1242     else
1243     {
1244         MacServices_powerSrv_SetRateModulation(pPowerMgr->hMacServices, (DRV_RATE_MASK_1_BARKER | DRV_RATE_MASK_2_BARKER));
1245         WLAN_REPORT_ERROR(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
1246                           ("powerMgrNullPacketRateConfiguration: error - faild to set rate so default was seted!\n"));
1247     }
1248     return OK;
1249
1250 }
1251
1252
1253 static PowerMgr_PowerMode_e powerMgrGetHighestPriority(TI_HANDLE hPowerMgr)
1254 {
1255     PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
1256     int index;
1257     for ( index = POWER_MANAGER_MAX_PRIORITY-1;index >= 0;index-- )
1258     {
1259         if ( pPowerMgr->powerMngModePriority[index].priorityEnable )
1260         {
1261
1262             return pPowerMgr->powerMngModePriority[index].powerMode;
1263         }
1264
1265     }
1266
1267     WLAN_REPORT_ERROR(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
1268                       ("powerMgrGetHighestPriority - error - faild to get highest priority! sefault deseired mode was returned !!!\n"));
1269     return pPowerMgr->desiredPowerModeProfile;
1270 }
1271
1272  /****************************************************************************************
1273  *                        PowerMgr_notifyFWReset                                                                                                                        *
1274  ****************************************************************************************
1275 DESCRIPTION: Notify the object of the power Manager about FW reset (recovery).
1276                                 -       call PowerSrv module to Set Ps Mode
1277                                 -       call PowerAutho Power Policy Update
1278                                                                                                                                    
1279 INPUT:          - hPowerMgr - Handle to the Power Manager       
1280 OUTPUT:         
1281 RETURN:    TI_STATUS - OK on success else NOK.
1282 ****************************************************************************************/
1283 TI_STATUS PowerMgr_notifyFWReset(TI_HANDLE hPowerMgr)
1284 {
1285         PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
1286
1287         if (pPowerMgr->psEnable)
1288         {
1289                 if (pPowerMgr->lastPowerModeProfile == POWER_MODE_SHORT_DOZE || 
1290                         pPowerMgr->lastPowerModeProfile == POWER_MODE_LONG_DOZE)
1291                 {
1292                         powerMgrPowerProfileConfiguration(hPowerMgr, pPowerMgr->lastPowerModeProfile);
1293                 }
1294         }
1295
1296     return OK;
1297 }
1298
1299  /****************************************************************************************
1300  *                        PowerMgrConfigBetToFw                                                                                                                 *
1301  ****************************************************************************************
1302 DESCRIPTION: callback from TM event notification.
1303                                 -       call PowerSrv module to Set Ps Mode
1304                                 -       call PowerAutho Power Policy Update
1305                                                                                                                                    
1306 INPUT:          - hPowerMgr - Handle to the Power Manager       
1307                 - BetEnable - cookie:values supplied during event registration
1308 OUTPUT:         
1309 RETURN:    None.
1310 ****************************************************************************************/
1311 static void PowerMgrConfigBetToFw( TI_HANDLE hPowerMgr, UINT32 BetEnable )
1312 {
1313     PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
1314     UINT8 MaximumConsecutiveET;
1315     UINT32 listenInterval;
1316     paramInfo_t param;
1317     UINT32 beaconInterval;
1318     UINT32 dtimPeriod;
1319     PowerMgr_PowerMode_e powerMode;
1320
1321     param.paramType = SITE_MGR_BEACON_INTERVAL_PARAM;
1322     siteMgr_getParam(pPowerMgr->hSiteMgr, &param);
1323     beaconInterval = param.content.beaconInterval;
1324
1325     param.paramType = SITE_MGR_DTIM_PERIOD_PARAM;
1326     siteMgr_getParam(pPowerMgr->hSiteMgr, &param);
1327     dtimPeriod = param.content.siteMgrDtimPeriod;
1328
1329     /* get actual Power Mode */
1330     if (pPowerMgr->desiredPowerModeProfile == POWER_MODE_AUTO)
1331     {
1332         powerMode = pPowerMgr->autoModeDozeMode;
1333     }
1334     else
1335     {
1336         powerMode = pPowerMgr->lastPowerModeProfile;
1337     }
1338
1339     /* calc ListenInterval */
1340     if (powerMode == POWER_MODE_SHORT_DOZE)
1341     {
1342         listenInterval = beaconInterval * pPowerMgr->beaconListenInterval;
1343     }
1344     else if (powerMode == POWER_MODE_LONG_DOZE)
1345     {
1346         listenInterval = dtimPeriod * beaconInterval * pPowerMgr->dtimListenInterval;
1347     }
1348     else
1349     {
1350         listenInterval = beaconInterval;
1351     }
1352
1353     if (listenInterval == 0)
1354     {
1355         WLAN_REPORT_WARNING(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
1356                                 ("PowerMgrConfigBetToFw: listenInterval is ZERO\n"));
1357         return;
1358     }
1359
1360     /* MaximumConsecutiveET = MaximalFullBeaconReceptionInterval / MAX( BeaconInterval, ListenInterval) */
1361     MaximumConsecutiveET = pPowerMgr->maxFullBeaconInterval / listenInterval;
1362
1363     WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
1364                             ("PowerMgrConfigBetToFw:\n \
1365                             Power Mode = %d\n \
1366                             beaconInterval = %d\n \
1367                             listenInterval = %d\n \
1368                             Bet Enable = %d\n \
1369                             MaximumConsecutiveET = %d\n",
1370                             powerMode,
1371                             beaconInterval,
1372                             listenInterval,
1373                             BetEnable,
1374                             MaximumConsecutiveET));
1375
1376     pPowerMgr->betTrafficEnable = BetEnable; /* save BET enable flag for CLI configuration */
1377
1378     whalCtrl_setBetParams (pPowerMgr->hWhalCtrl, BetEnable, MaximumConsecutiveET);
1379
1380 }
1381
1382
1383 /**
1384  * \date 10-April-2007\n
1385  * \brief Returns to the configured wakeup condition, when SG protective mode is done
1386  *
1387  * Function Scope \e Public.\n
1388  * Parameters:\n
1389  * 1) TI_HANDLE - handle to the PowerMgr object.\n
1390  * Return Value: void.\n
1391  */
1392 static void powerMgr_SGSetUserDesiredwakeUpCond( TI_HANDLE hPowerMgr )
1393 {
1394     PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
1395
1396
1397     if (pPowerMgr->psEnable) 
1398     {
1399       /* set wakeup condition according to user mode power save profile */
1400       switch ( pPowerMgr->powerMngModePriority[ POWER_MANAGER_USER_PRIORITY ].powerMode )
1401       {
1402       case POWER_MODE_AUTO:
1403         /*set wakeup condition according to doze mode in auto and wakup interval */
1404         if ( pPowerMgr->autoModeDozeMode == POWER_MODE_SHORT_DOZE )
1405         {
1406             /* short doze */
1407             if ( pPowerMgr->beaconListenInterval > 1 )
1408             {
1409                 powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->beaconListenInterval,TNET_WAKE_ON_N_BEACON);       
1410             }
1411             else
1412             {
1413                 powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->beaconListenInterval,TNET_WAKE_ON_BEACON);     
1414             }
1415         }
1416         else
1417         {
1418             /* long doze */
1419             if ( pPowerMgr->dtimListenInterval > 1 )
1420             {
1421                 powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->dtimListenInterval,TNET_WAKE_ON_N_DTIM);       
1422             }
1423             else
1424             {
1425                 powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->dtimListenInterval,TNET_WAKE_ON_DTIM);     
1426             }
1427         }
1428         break;
1429
1430       case POWER_MODE_ACTIVE:
1431         break;
1432
1433       case POWER_MODE_SHORT_DOZE:
1434         if ( pPowerMgr->beaconListenInterval > 1 )
1435         {
1436             powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->beaconListenInterval,TNET_WAKE_ON_N_BEACON);       
1437         }
1438         else
1439         {
1440             powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->beaconListenInterval,TNET_WAKE_ON_BEACON);     
1441         }
1442         break;
1443
1444       case POWER_MODE_LONG_DOZE:
1445         if ( pPowerMgr->dtimListenInterval > 1 )
1446         {
1447             powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->dtimListenInterval,TNET_WAKE_ON_N_DTIM);       
1448         }
1449         else
1450         {
1451             powerMgrSendMBXWakeUpConditions(hPowerMgr,pPowerMgr->dtimListenInterval,TNET_WAKE_ON_DTIM);     
1452         }
1453         break;
1454
1455       default:
1456         WLAN_REPORT_ERROR(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG,
1457                           ("powerMgr_SGExitShortDoze - ERROR - PowerMode for user prioirty is: %d\n",
1458                            pPowerMgr->powerMngModePriority[ POWER_MANAGER_USER_PRIORITY ].powerMode));
1459       }
1460     }/*end of if (psEnable)*/
1461 }
1462
1463
1464
1465 /****************************************************************************************
1466 *                        PowerMgr_PsPollFailureCB                                                                                                                       *
1467 ****************************************************************************************
1468 DESCRIPTION: Work around to solve AP bad behavior.
1469          Some old AP's have trouble with Ps-Poll - The solution will be to exit PS for a 
1470          period of time
1471                                                                                                                                
1472 INPUT:          - hPowerMgr - Handle to the Power Manager       
1473 OUTPUT:         
1474 RETURN:    
1475 ****************************************************************************************/
1476 static void PowerMgr_PsPollFailureCB( TI_HANDLE hPowerMgr )
1477 {
1478     PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
1479
1480     if ( pPowerMgr->PsPollDeliveryFailureRecoveryPeriod )
1481     {
1482         paramInfo_t param;
1483              
1484         WLAN_REPORT_WARNING(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG, 
1485             ("%s Oh boy, AP is not answering Ps-Poll's. enter active PS for %d Ms\n",
1486             __FUNCTION__, pPowerMgr->PsPollDeliveryFailureRecoveryPeriod));
1487
1488         /* Disable Soft Gemini */
1489         SoftGemini_startPsPollFailure(pPowerMgr->hSoftGemini);
1490
1491         /*
1492          * Set the system to Active power save 
1493          */
1494         param.paramType = POWER_MGR_POWER_MODE;
1495         param.content.powerMngPowerMode.PowerMode = POWER_MODE_ACTIVE;
1496         param.content.powerMngPowerMode.powerMngPriority = POWER_MANAGER_PS_POLL_FAILURE_PRIORITY;
1497         powerMgr_setParam(hPowerMgr,&param);
1498         
1499         param.paramType = POWER_MGR_ENABLE_PRIORITY;
1500         param.content.powerMngPriority = POWER_MANAGER_PS_POLL_FAILURE_PRIORITY;
1501         powerMgr_setParam(hPowerMgr,&param);
1502
1503         /*
1504          * Set timer to exit the active mode
1505          */
1506         os_timerStart(pPowerMgr->hOS,
1507             pPowerMgr->hPsPollFailureTimer,
1508             pPowerMgr->PsPollDeliveryFailureRecoveryPeriod,
1509             FALSE);
1510     } 
1511     else    /* Work-around is disabled */
1512     {
1513         WLAN_REPORT_WARNING(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG, 
1514             ("%s Oh boy, AP is not answering Ps-Poll's !!!\n",__FUNCTION__));
1515     }
1516
1517 }
1518
1519 /****************************************************************************************
1520 *                        powerMgr_PsPollFailureTimeout                                                                  *
1521 ****************************************************************************************
1522 DESCRIPTION: After the timeout of ps-poll failure - return to normal behavior
1523                                                                                                                                
1524 INPUT:          - hPowerMgr - Handle to the Power Manager       
1525 OUTPUT:         
1526 RETURN:    
1527 ****************************************************************************************/
1528 static void powerMgr_PsPollFailureTimeout(TI_HANDLE hPowerMgr)
1529 {
1530     PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
1531     paramInfo_t param;
1532
1533     WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG, 
1534         ("%s \n",__FUNCTION__));
1535     
1536     /* disable Ps-Poll priority */
1537     param.paramType = POWER_MGR_DISABLE_PRIORITY;
1538     param.content.powerMngPriority = POWER_MANAGER_PS_POLL_FAILURE_PRIORITY;
1539     powerMgr_setParam(hPowerMgr,&param);
1540
1541     /* return to normal Soft Gemini */
1542     SoftGemini_endPsPollFailure(pPowerMgr->hSoftGemini);
1543 }
1544
1545 void powerMgr_setCpuLoad(TI_HANDLE hPowerMgr, UINT32 uCpuLoad)
1546 {
1547         #ifdef CPU_LOAD
1548
1549                 PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
1550                 
1551                 pPowerMgr->uCpuLoad = uCpuLoad;
1552                 WLAN_OS_REPORT(("\n PowerMgr_setCpuLoad - Cpu Load = %d \n",
1553                                                    pPowerMgr->uCpuLoad));
1554
1555                 if (pPowerMgr->uCpuLoad > 0) 
1556                 {
1557                         os_timerStart(pPowerMgr->hOS,
1558                                                   pPowerMgr->hCpuLoadTimer,
1559                                                   RE_ENTER_CPU_LOAD_TIMEOUT,
1560                                                   TRUE);
1561                 }
1562                 else
1563                 {
1564                         os_timerStop(pPowerMgr->hOS, pPowerMgr->hCpuLoadTimer);
1565                 }
1566         #endif
1567 }
1568
1569 #ifdef CPU_LOAD
1570         /****************************************************************************************
1571         *                        powerMgr_CpuLoadTimeout                                                                        *
1572         ****************************************************************************************
1573         DESCRIPTION: After the timeout of cpu load - run in idle loop to simulate cpu load
1574                                                                                                                                                                                                                                    
1575         INPUT:          - hPowerMgr - Handle to the Power Manager       
1576         OUTPUT:         
1577         RETURN:    
1578         ****************************************************************************************/
1579         static void powerMgr_CpuLoadTimeout(TI_HANDLE hPowerMgr)
1580         {
1581                 PowerMgr_t *pPowerMgr = (PowerMgr_t*)hPowerMgr;
1582                 UINT32 uStallTime=0;
1583                 
1584                 WLAN_REPORT_INFORMATION(pPowerMgr->hReport, POWER_MANAGER_MODULE_LOG, 
1585                         ("CpuLoadTimeout : cpu= %d\n", pPowerMgr->uCpuLoad));
1586
1587                 #ifdef _WINDOWS
1588                 #else
1589                         while(uStallTime < (pPowerMgr->uCpuLoad * CPU_LOAD_MUL))
1590                         {
1591                                 uStallTime++;
1592                         }
1593                 #endif
1594         }
1595 #endif
1596