wlan_bearer/wlanldd/wlan_common/umac_common/src/umacdynamicpowermodemgmtcntx.cpp
branchRCL_3
changeset 34 13838cf40350
parent 0 c40eb8fe8501
equal deleted inserted replaced
21:af3fb27c7511 34:13838cf40350
     1 /*
     1 /*
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    14 * Description:   Implementation of the WlanDynamicPowerModeMgmtCntx class
    14 * Description:   Implementation of the WlanDynamicPowerModeMgmtCntx class
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 14 %
    19 * %version: 15 %
    20 */
    20 */
    21 
    21 
    22 #include "config.h"
    22 #include "config.h"
    23 #include "umacdynamicpowermodemgmtcntx.h"
    23 #include "umacdynamicpowermodemgmtcntx.h"
    24 #include "UmacContextImpl.h"
    24 #include "UmacContextImpl.h"
    53     iToActiveTimeout( KDefaultToActiveTimeout ),
    53     iToActiveTimeout( KDefaultToActiveTimeout ),
    54     iToDeepPsTimeout( KDefaultToDeepPsTimeout ),
    54     iToDeepPsTimeout( KDefaultToDeepPsTimeout ),
    55     iActiveCntx( NULL ),
    55     iActiveCntx( NULL ),
    56     iWlanContextImpl( aWlanCtxImpl ) 
    56     iWlanContextImpl( aWlanCtxImpl ) 
    57     {
    57     {
       
    58     iActiveParamsBackup.iToLightPsTimeout = KDefaultToLightPsTimeout;
       
    59     iActiveParamsBackup.iToLightPsFrameThreshold = 
       
    60         WlanActiveModePowerModeMgr::KDefaultToLightPsFrameThreshold;
       
    61     iActiveParamsBackup.iUapsdRxFrameLengthThreshold = 
       
    62         WlanPowerModeMgrBase::KDefaultUapsdRxFrameLengthThreshold;
    58     os_memset( iIgnoreTraffic, 0, sizeof( iIgnoreTraffic ) );
    63     os_memset( iIgnoreTraffic, 0, sizeof( iIgnoreTraffic ) );
    59     }
    64     }
    60 
    65 
    61 // ---------------------------------------------------------------------------
    66 // ---------------------------------------------------------------------------
    62 // 
    67 // 
   156 // 
   161 // 
   157 // ---------------------------------------------------------------------------
   162 // ---------------------------------------------------------------------------
   158 //
   163 //
   159 TPowerMgmtModeChange WlanDynamicPowerModeMgmtCntx::OnFrameTx( 
   164 TPowerMgmtModeChange WlanDynamicPowerModeMgmtCntx::OnFrameTx( 
   160     WHA::TQueueId aQueueId,
   165     WHA::TQueueId aQueueId,
   161     TUint16 aEtherType )
   166     TUint16 aEtherType,
       
   167     T802Dot11FrameControlTypeMask aDot11FrameType )
   162     {
   168     {
   163     TPowerMgmtModeChange powerMgmtModeChange( ENoChange );
   169     TPowerMgmtModeChange powerMgmtModeChange( ENoChange );
   164 
   170 
   165     if ( iActiveCntx )
   171     if ( iActiveCntx )
   166         {
   172         {
   170             {
   176             {
   171             powerMgmtModeChange = iActiveCntx->OnFrameTx( 
   177             powerMgmtModeChange = iActiveCntx->OnFrameTx( 
   172                 iWlanContextImpl, 
   178                 iWlanContextImpl, 
   173                 aQueueId,
   179                 aQueueId,
   174                 aEtherType,
   180                 aEtherType,
       
   181                 aDot11FrameType,
   175                 iIgnoreTraffic[aQueueId] );
   182                 iIgnoreTraffic[aQueueId] );
   176             
   183             
   177             if ( powerMgmtModeChange != ENoChange )
   184             if ( powerMgmtModeChange != ENoChange )
   178                 {
   185                 {
       
   186                 iStateChange = ETrue;
       
   187             
   179                 // as we will do a mode change, cancel any possibly running 
   188                 // as we will do a mode change, cancel any possibly running 
   180                 // power mode management timers
   189                 // power mode management timers
   181                 CancelTimeouts();
   190                 CancelTimeouts();
       
   191                 
       
   192                 if ( aDot11FrameType == E802Dot11FrameTypeDataNull ||
       
   193                      aEtherType == KArpType )
       
   194                     {
       
   195                     // modify temporarily the Active mode parameters
       
   196                     SetKeepAliveActiveModeParameters();
       
   197                     }
   182                 }
   198                 }
   183             }        
   199             }        
   184         else
   200         else
   185             {
   201             {
   186             // state change already signalled from this power mode context, 
   202             // state change already signalled from this power mode context, 
   228                 aPayloadLength,
   244                 aPayloadLength,
   229                 aDaType );
   245                 aDaType );
   230             
   246             
   231             if ( powerMgmtModeChange != ENoChange )
   247             if ( powerMgmtModeChange != ENoChange )
   232                 {
   248                 {
       
   249                 iStateChange = ETrue;
       
   250             
   233                 // as we will do a mode change, cancel any possibly running 
   251                 // as we will do a mode change, cancel any possibly running 
   234                 // power mode management timers
   252                 // power mode management timers
   235                 CancelTimeouts();
   253                 CancelTimeouts();
   236                 }
   254                 }
   237             }        
   255             }        
   258 
   276 
   259 // ---------------------------------------------------------------------------
   277 // ---------------------------------------------------------------------------
   260 // 
   278 // 
   261 // ---------------------------------------------------------------------------
   279 // ---------------------------------------------------------------------------
   262 //
   280 //
       
   281 TPowerMgmtModeChange WlanDynamicPowerModeMgmtCntx::OnPsModeErrorIndication()
       
   282     {
       
   283     TPowerMgmtModeChange powerMgmtModeChange( ENoChange );
       
   284 
       
   285     if ( iActiveCntx )
       
   286         {
       
   287         // we have an active context, i.e. we are doing power mode mgmt
       
   288         
       
   289         if ( !iStateChange )
       
   290             {
       
   291             powerMgmtModeChange = iActiveCntx->OnPsModeErrorIndication();
       
   292             
       
   293             if ( powerMgmtModeChange != ENoChange )
       
   294                 {
       
   295                 iStateChange = ETrue;
       
   296                 
       
   297                 // as we will do a mode change, cancel any possibly running 
       
   298                 // power mode management timers
       
   299                 CancelTimeouts();
       
   300                 
       
   301                 // modify temporarily the Active mode parameters
       
   302                 SetPsModeErrorActiveModeParameters();
       
   303                 }
       
   304             }
       
   305         else
       
   306             {
       
   307             // state change already signalled from this power mode context, 
       
   308             // don't do it more than once. No action needed
       
   309             OsTracePrint( KPwrStateTransition, (TUint8*)
       
   310                 ("UMAC: WlanDynamicPowerModeMgmtCntx::OnPsModeErrorIndication: "
       
   311                  "statechange already signalled") );
       
   312             }
       
   313         }
       
   314     else
       
   315         {
       
   316         // dynamic power mode mgmt is not active => "No change" will be 
       
   317         // returned. No action needed
       
   318         }
       
   319         
       
   320     OsTracePrint( KPwrStateTransition, (TUint8*)
       
   321         ("UMAC: WlanDynamicPowerModeMgmtCntx::OnPsModeErrorIndication: "
       
   322          "statechange: %d"),
       
   323         powerMgmtModeChange );
       
   324     
       
   325     return powerMgmtModeChange;
       
   326     }
       
   327 
       
   328 // ---------------------------------------------------------------------------
       
   329 // 
       
   330 // ---------------------------------------------------------------------------
       
   331 //
   263 TBool WlanDynamicPowerModeMgmtCntx::OnActiveToLightPsTimerTimeout()
   332 TBool WlanDynamicPowerModeMgmtCntx::OnActiveToLightPsTimerTimeout()
   264     {
   333     {
   265     if ( ( iActiveCntx == &iActiveModeCntx ) && 
   334     if ( ( iActiveCntx == &iActiveModeCntx ) && 
   266          ( iFlags & KToLightPsTimerStarted ) &&
   335          ( iFlags & KToLightPsTimerStarted ) &&
   267          ( !iStateChange ) )
   336          ( !iStateChange ) )
   271         iStateChange = iActiveCntx->OnActiveToLightPsTimerTimeout();
   340         iStateChange = iActiveCntx->OnActiveToLightPsTimerTimeout();
   272         
   341         
   273         OsTracePrint( KPwrStateTransition, (TUint8*)
   342         OsTracePrint( KPwrStateTransition, (TUint8*)
   274             ("UMAC: WlanDynamicPowerModeMgmtCntx::OnActiveToLightPsTimerTimeout: change state: %d"),
   343             ("UMAC: WlanDynamicPowerModeMgmtCntx::OnActiveToLightPsTimerTimeout: change state: %d"),
   275             iStateChange );
   344             iStateChange );
       
   345         
       
   346         // make sure that the WLAN Mgmt Client provided Active mode 
       
   347         // parameter values are again used the next time by default
       
   348         //
       
   349         RestoreActiveModeParameters();
   276         
   350         
   277         if ( !iStateChange )
   351         if ( !iStateChange )
   278             {
   352             {
   279             RegisterToLightPsTimeout();
   353             RegisterToLightPsTimeout();
   280             }
   354             }
   290         // a state change has already been signalled from this power mode 
   364         // a state change has already been signalled from this power mode 
   291         // context.
   365         // context.
   292         // In all these cases the timeout is not relevant and we take no action
   366         // In all these cases the timeout is not relevant and we take no action
   293         OsTracePrint( KPwrStateTransition, (TUint8*)
   367         OsTracePrint( KPwrStateTransition, (TUint8*)
   294             ("UMAC: WlanDynamicPowerModeMgmtCntx::OnActiveToLightPsTimerTimeout: not relevant timeout") );
   368             ("UMAC: WlanDynamicPowerModeMgmtCntx::OnActiveToLightPsTimerTimeout: not relevant timeout") );
       
   369         
       
   370         // however, make sure that the WLAN Mgmt Client provided Active mode
       
   371         // parameter values are again used the next time by default
       
   372         //
       
   373         RestoreActiveModeParameters();        
   295         }
   374         }
   296     
   375     
   297     return iStateChange;
   376     return iStateChange;
   298     }
   377     }
   299 
   378 
   404     iToDeepPsTimeout = aToDeepPsTimeout;
   483     iToDeepPsTimeout = aToDeepPsTimeout;
   405     iLightPsModeCntx.SetParameters(
   484     iLightPsModeCntx.SetParameters(
   406         aToActiveFrameThreshold,
   485         aToActiveFrameThreshold,
   407         aToDeepPsFrameThreshold,
   486         aToDeepPsFrameThreshold,
   408         aUapsdRxFrameLengthThreshold );
   487         aUapsdRxFrameLengthThreshold );
       
   488     
       
   489     iDeepPsModeCntx.SetParameters( aUapsdRxFrameLengthThreshold );
       
   490     
       
   491     // take also a backup of the Active mode parameters
       
   492     //
       
   493     iActiveParamsBackup.iToLightPsTimeout = aToLightPsTimeout;
       
   494     iActiveParamsBackup.iToLightPsFrameThreshold = aToLightPsFrameThreshold;
       
   495     iActiveParamsBackup.iUapsdRxFrameLengthThreshold = 
       
   496         aUapsdRxFrameLengthThreshold;    
   409     }
   497     }
   410 
   498 
   411 // ---------------------------------------------------------------------------
   499 // ---------------------------------------------------------------------------
   412 // 
   500 // 
   413 // ---------------------------------------------------------------------------
   501 // ---------------------------------------------------------------------------