wlan_bearer/wlanldd/wlan_common/umac_common/src/UmacContextImpl.cpp
changeset 0 c40eb8fe8501
child 10 0abc8c98be24
equal deleted inserted replaced
-1:000000000000 0:c40eb8fe8501
       
     1 /*
       
     2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Implementation of the WlanContextImpl class
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 70 %
       
    20 */
       
    21 
       
    22 #include "config.h"
       
    23 #include "UmacContextImpl.h"
       
    24 #include "umacconnectcontext.h"
       
    25 #include "UmacWsaInitiliaze.h"
       
    26 #include "UmacWsaConfigure.h"
       
    27 #include "UmacWsaReadMib.h"
       
    28 #include "UmacWsaWriteMib.h"
       
    29 #include "UmacWsaJoin.h"
       
    30 #include "UmacWsaDisconnect.h"
       
    31 #include "UmacWsaScan.h"
       
    32 #include "umacwhastopscan.h"
       
    33 #include "UmacWsaSetBssParameters.h"
       
    34 #include "UmacWsaAddKey.h"
       
    35 #include "UmacWsaSetPsMode.h"
       
    36 #include "umacwhaconfigurequeue.h"
       
    37 #include "umacwhaconfigureac.h"
       
    38 #include "umacwharelease.h"
       
    39 
       
    40 #include "umacaddbroadcastwepkey.h"
       
    41 #include "umacconfiguretxqueueparams.h"
       
    42 #include "umacconfiguretxautoratepolicy.h"
       
    43 
       
    44 
       
    45 struct SWsaCommands
       
    46     {
       
    47     WlanConfigureTxQueueParams      iConfigureTxQueueParams;
       
    48     WlanAddBroadcastWepKey          iAddBroadcastWepKey;
       
    49     WlanConfigureTxAutoRatePolicy   iConfigureTxAutoRatePolicy;
       
    50     WlanWsaInitiliaze               iWsaInitiliaze;
       
    51     WlanWsaConfigure                iWsaConfigure;
       
    52     WlanWsaReadMib                  iWsaReadMib;
       
    53     WlanWsaWriteMib                 iWsaWriteMib;
       
    54     WlanWsaJoin                     iWsaJoin;
       
    55     WlanWsaDisconnect               iWsaDisconnect;
       
    56     WlanWsaScan                     iWsaScan;
       
    57     WlanWhaStopScan                 iWhaStopScan;
       
    58     WlanWsaSetBssParameters         iWsaSetBssParameters;
       
    59     WlanWsaAddKey                   iWsaAddKey;
       
    60     WlanWsaSetPsMode                iWsaSetPsMode;
       
    61     WlanWhaConfigureQueue           iWhaConfigureQueue;
       
    62     WlanWhaConfigureAc              iWhaConfigureAc;
       
    63     WlanWhaRelease                  iWlanWhaRelease;
       
    64     };
       
    65 
       
    66 // ================= MEMBER FUNCTIONS =======================
       
    67 
       
    68 // ---------------------------------------------------------------------------
       
    69 // 
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 WlanContextImpl::WlanContextImpl( Umac& aUmac ) : 
       
    73             iCurrentMacState( NULL ),
       
    74             iUmac( aUmac ), 
       
    75             iEnableUserData( EFalse ),
       
    76             iCurrentRxBuffer( NULL ),
       
    77             iInternalTxBufFree ( ETrue ),
       
    78             iInternalTxBufBeingWaited ( EFalse ),            
       
    79             iAlignNullData( 0 ), 
       
    80             iAlignQosNullData( 0 ),
       
    81             iConsecutiveBeaconsLostIndicated ( EFalse ),
       
    82             iConsecutiveTxFailuresIndicated ( EFalse ),
       
    83             iConsecutivePwrModeSetFailuresIndicated ( EFalse ),
       
    84             iFailedTxPacketCount ( 0 ), 
       
    85             iWsaCmdActive( EFalse ), 
       
    86             iWhaCommandAct( 0 ), 
       
    87             iWha( NULL ), 
       
    88             iWsaCommands( NULL ), 
       
    89             iEventDispatcher( aUmac ), 
       
    90             iPacketScheduler( *this ), 
       
    91             iDynamicPowerModeCntx ( *this ),
       
    92             iNullSendController( *this, *this ),
       
    93             iProprietarySnapHeader( KUndefinedSnapHeader )
       
    94     {
       
    95     OsTracePrint( KInitLevel, 
       
    96         (TUint8*)("UMAC: WlanContextImpl::WlanContextImpl(): this: 0x%08x"), 
       
    97         reinterpret_cast<TUint32>(this) );    
       
    98 
       
    99     os_memset( 
       
   100         iSupportedRatesLookUpTable, 
       
   101         0, 
       
   102         sizeof( iSupportedRatesLookUpTable ) );
       
   103 
       
   104     os_memset( &iWHASettings, 0, sizeof( iWHASettings ) );
       
   105 
       
   106     os_memset( 
       
   107         &iOurBssMembershipFeatureArray, 
       
   108         KUnallocated, 
       
   109         sizeof( iOurBssMembershipFeatureArray ) );
       
   110 
       
   111     os_memset( 
       
   112         &iHtBlockAckConfigure, 
       
   113         0, 
       
   114         sizeof( iHtBlockAckConfigure ) );
       
   115 
       
   116     ResetFrameStatistics();
       
   117     }
       
   118 
       
   119 // ---------------------------------------------------------------------------
       
   120 // 
       
   121 // ---------------------------------------------------------------------------
       
   122 //
       
   123 void WlanContextImpl::BootUp(
       
   124     const TUint8* aPda, 
       
   125     TUint32 aPdaLength,
       
   126     const TUint8* aFw, 
       
   127     TUint32 aFwLength )
       
   128     {    
       
   129     // boot the system up
       
   130     OsTracePrint( KInitLevel, (TUint8*)("UMAC:  WlanContextImpl::BootUp"));    
       
   131 
       
   132     iStates.iInitPhase1State.BootUp( *this, aPda, aPdaLength, aFw, aFwLength );
       
   133     }
       
   134 
       
   135 // ---------------------------------------------------------------------------
       
   136 // 
       
   137 // ---------------------------------------------------------------------------
       
   138 //
       
   139 WlanAddBroadcastWepKey& WlanContextImpl::AddBroadcastWepKey()
       
   140     {
       
   141     return iWsaCommands->iAddBroadcastWepKey;
       
   142     }
       
   143 
       
   144 // ---------------------------------------------------------------------------
       
   145 // 
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 WlanConfigureTxQueueParams& WlanContextImpl::ConfigureTxQueueParams()
       
   149     {
       
   150     return iWsaCommands->iConfigureTxQueueParams;
       
   151     }
       
   152 
       
   153 // ---------------------------------------------------------------------------
       
   154 // 
       
   155 // ---------------------------------------------------------------------------
       
   156 //
       
   157 WlanConfigureTxAutoRatePolicy& WlanContextImpl::ConfigureTxAutoRatePolicy()
       
   158     {
       
   159     return iWsaCommands->iConfigureTxAutoRatePolicy;    
       
   160     }
       
   161 
       
   162 // ---------------------------------------------------------------------------
       
   163 // 
       
   164 // ---------------------------------------------------------------------------
       
   165 //
       
   166 WlanWsaInitiliaze& WlanContextImpl::WsaInitiliaze()
       
   167     {
       
   168     return iWsaCommands->iWsaInitiliaze;
       
   169     }
       
   170 
       
   171 // ---------------------------------------------------------------------------
       
   172 // 
       
   173 // ---------------------------------------------------------------------------
       
   174 //
       
   175 WlanWsaConfigure& WlanContextImpl::WsaConfigure()
       
   176     {
       
   177     return iWsaCommands->iWsaConfigure;
       
   178     }
       
   179 
       
   180 // ---------------------------------------------------------------------------
       
   181 // 
       
   182 // ---------------------------------------------------------------------------
       
   183 //
       
   184 WlanWsaReadMib& WlanContextImpl::WsaReadMib()
       
   185     {
       
   186     return iWsaCommands->iWsaReadMib;
       
   187     }
       
   188 
       
   189 // ---------------------------------------------------------------------------
       
   190 // 
       
   191 // ---------------------------------------------------------------------------
       
   192 //
       
   193 WlanWsaWriteMib& WlanContextImpl::WsaWriteMib()
       
   194     {
       
   195     return iWsaCommands->iWsaWriteMib;
       
   196     }
       
   197 
       
   198 // ---------------------------------------------------------------------------
       
   199 // 
       
   200 // ---------------------------------------------------------------------------
       
   201 //
       
   202 WlanWsaJoin& WlanContextImpl::WsaJoin()
       
   203     {
       
   204     return iWsaCommands->iWsaJoin;
       
   205     }
       
   206 
       
   207 // ---------------------------------------------------------------------------
       
   208 // 
       
   209 // ---------------------------------------------------------------------------
       
   210 //
       
   211 WlanWsaDisconnect& WlanContextImpl::WsaDisconnect()
       
   212     {
       
   213     return iWsaCommands->iWsaDisconnect;
       
   214     }
       
   215 
       
   216 // ---------------------------------------------------------------------------
       
   217 // 
       
   218 // ---------------------------------------------------------------------------
       
   219 //
       
   220 WlanWsaSetBssParameters& WlanContextImpl::WsaSetBssParameters()
       
   221     {
       
   222     return iWsaCommands->iWsaSetBssParameters;
       
   223     }
       
   224 
       
   225 // ---------------------------------------------------------------------------
       
   226 // 
       
   227 // ---------------------------------------------------------------------------
       
   228 //
       
   229 WlanWsaScan& WlanContextImpl::WsaScan()
       
   230     {
       
   231     return iWsaCommands->iWsaScan;
       
   232     }
       
   233 
       
   234 // ---------------------------------------------------------------------------
       
   235 // 
       
   236 // ---------------------------------------------------------------------------
       
   237 //
       
   238 WlanWhaStopScan& WlanContextImpl::WhaStopScan()
       
   239     {
       
   240     return iWsaCommands->iWhaStopScan;
       
   241     }
       
   242 
       
   243 // ---------------------------------------------------------------------------
       
   244 // 
       
   245 // ---------------------------------------------------------------------------
       
   246 //
       
   247 WlanWsaAddKey& WlanContextImpl::WsaAddKey()
       
   248     {
       
   249     return iWsaCommands->iWsaAddKey;
       
   250     }
       
   251 
       
   252 // ---------------------------------------------------------------------------
       
   253 // 
       
   254 // ---------------------------------------------------------------------------
       
   255 //
       
   256 WlanWsaSetPsMode& WlanContextImpl::WsaSetPsMode()
       
   257     {
       
   258     return iWsaCommands->iWsaSetPsMode;
       
   259     }
       
   260 
       
   261 // ---------------------------------------------------------------------------
       
   262 // 
       
   263 // ---------------------------------------------------------------------------
       
   264 //
       
   265 WlanWhaConfigureQueue& WlanContextImpl::WhaConfigureQueue()
       
   266     {
       
   267     return iWsaCommands->iWhaConfigureQueue;
       
   268     }
       
   269 
       
   270 // ---------------------------------------------------------------------------
       
   271 // 
       
   272 // ---------------------------------------------------------------------------
       
   273 //
       
   274 WlanWhaConfigureAc& WlanContextImpl::WhaConfigureAc()
       
   275     {
       
   276     return iWsaCommands->iWhaConfigureAc;
       
   277     }
       
   278 
       
   279 // ---------------------------------------------------------------------------
       
   280 // 
       
   281 // ---------------------------------------------------------------------------
       
   282 //
       
   283 WlanWhaRelease& WlanContextImpl::WlanWhaRelease()
       
   284     {
       
   285     return iWsaCommands->iWlanWhaRelease;
       
   286     }
       
   287 
       
   288 // ---------------------------------------------------------------------------
       
   289 // 
       
   290 // ---------------------------------------------------------------------------
       
   291 //
       
   292 TBool WlanContextImpl::Initialize()
       
   293     {
       
   294     // deallocation of objecs allocated here is done in destructor
       
   295 
       
   296     iStates.iIdleScanningMode.Set( *this );
       
   297     iStates.iIbssScanningMode.Set( *this );
       
   298     iStates.iInfrastructureScanningMode.Set( *this );
       
   299 
       
   300     iCurrentMacState = &(iStates.iInitPhase1State);
       
   301 
       
   302     OsTracePrint( KInitLevel, (TUint8*)("UMAC: WlanContextImpl::Initialize: alloc WSA commands; size: %d"), sizeof(SWsaCommands));
       
   303 
       
   304     iWsaCommands 
       
   305         = static_cast<SWsaCommands*>(os_alloc( sizeof(SWsaCommands) )); 
       
   306     if ( !iWsaCommands ) 
       
   307         {        
       
   308         OsTracePrint( KErrorLevel, 
       
   309             (TUint8*)("UMAC: WlanContextImpl::Initialize: alloc WSA commands failure -> abort"));                        
       
   310         return EFalse;
       
   311         }
       
   312 
       
   313     new (iWsaCommands) SWsaCommands;
       
   314 
       
   315     // made it 
       
   316     return ETrue;
       
   317     }
       
   318 
       
   319 // ---------------------------------------------------------------------------
       
   320 // 
       
   321 // ---------------------------------------------------------------------------
       
   322 //
       
   323 WlanContextImpl::~WlanContextImpl()
       
   324     {
       
   325     OsTracePrint( KInitLevel, 
       
   326         (TUint8*)("UMAC: WlanContextImpl::~WlanContextImpl"));        
       
   327 
       
   328 #ifndef RD_WLAN_DDK
       
   329     delete iWha;
       
   330 #endif
       
   331     iWha = NULL;
       
   332 
       
   333     if ( iWsaCommands ) 
       
   334         {        
       
   335         iWsaCommands->~SWsaCommands();
       
   336         os_free( iWsaCommands );
       
   337         iWsaCommands = NULL;
       
   338         }
       
   339 
       
   340     iCurrentMacState = NULL;
       
   341     }
       
   342 
       
   343 // ---------------------------------------------------------------------------
       
   344 // 
       
   345 // ---------------------------------------------------------------------------
       
   346 //
       
   347 void WlanContextImpl::MakeLookUpTable()
       
   348     {    
       
   349     // make bit rate lookup table
       
   350 
       
   351     OsTracePrint( KUmacDetails, 
       
   352         (TUint8*)("UMAC * construct dot11 rate to WHA rate lookup table"));
       
   353 
       
   354     TUint index(0);
       
   355     
       
   356     if ( iWHASettings.iRates & WHA::KRate1Mbits )
       
   357         {
       
   358         iSupportedRatesLookUpTable[index].iSupportedRate = E802Dot11Rate1MBit;
       
   359         iSupportedRatesLookUpTable[index].iWsaRate = WHA::KRate1Mbits;
       
   360 
       
   361         OsTracePrint( KUmacDetails, (TUint8*)("current index: %d"), index);
       
   362         OsTracePrint( KUmacDetails, (TUint8*)("dot11 rate added: 0x%02x"), 
       
   363             iSupportedRatesLookUpTable[index].iSupportedRate);
       
   364         OsTracePrint( KUmacDetails, (TUint8*)("WHA rate added: 0x%08x"), 
       
   365             iSupportedRatesLookUpTable[index].iWsaRate);
       
   366 
       
   367         ++index;
       
   368         }
       
   369     if ( iWHASettings.iRates & WHA::KRate2Mbits )
       
   370         {
       
   371         iSupportedRatesLookUpTable[index].iSupportedRate = E802Dot11Rate2MBit;
       
   372         iSupportedRatesLookUpTable[index].iWsaRate = WHA::KRate2Mbits;
       
   373 
       
   374         OsTracePrint( KUmacDetails, (TUint8*)("current index: %d"), index);
       
   375         OsTracePrint( KUmacDetails, (TUint8*)("dot11 rate added: 0x%02x"), 
       
   376             iSupportedRatesLookUpTable[index].iSupportedRate);
       
   377         OsTracePrint( KUmacDetails, (TUint8*)("WHA rate added: 0x%08x"), 
       
   378             iSupportedRatesLookUpTable[index].iWsaRate);
       
   379 
       
   380         ++index;
       
   381         }
       
   382     if ( iWHASettings.iRates & WHA::KRate5_5Mbits )
       
   383         {
       
   384         iSupportedRatesLookUpTable[index].iSupportedRate = E802Dot11Rate5p5MBit;
       
   385         iSupportedRatesLookUpTable[index].iWsaRate = WHA::KRate5_5Mbits;
       
   386 
       
   387         OsTracePrint( KUmacDetails, (TUint8*)("current index: %d"), index);
       
   388         OsTracePrint( KUmacDetails, (TUint8*)("dot11 rate added: 0x%02x"), 
       
   389             iSupportedRatesLookUpTable[index].iSupportedRate);
       
   390         OsTracePrint( KUmacDetails, (TUint8*)("WHA rate added: 0x%08x"), 
       
   391             iSupportedRatesLookUpTable[index].iWsaRate);
       
   392 
       
   393         ++index;
       
   394         }
       
   395     if ( iWHASettings.iRates & WHA::KRate6Mbits )
       
   396         {
       
   397         iSupportedRatesLookUpTable[index].iSupportedRate = E802Dot11Rate6MBit;
       
   398         iSupportedRatesLookUpTable[index].iWsaRate = WHA::KRate6Mbits;
       
   399 
       
   400         OsTracePrint( KUmacDetails, (TUint8*)("current index: %d"), index);
       
   401         OsTracePrint( KUmacDetails, (TUint8*)("dot11 rate added: 0x%02x"), 
       
   402             iSupportedRatesLookUpTable[index].iSupportedRate);
       
   403         OsTracePrint( KUmacDetails, (TUint8*)("WHA rate added: 0x%08x"), 
       
   404             iSupportedRatesLookUpTable[index].iWsaRate);
       
   405 
       
   406         ++index;
       
   407         }
       
   408     if ( iWHASettings.iRates & WHA::KRate9Mbits )
       
   409         {
       
   410         iSupportedRatesLookUpTable[index].iSupportedRate = E802Dot11Rate9MBit;
       
   411         iSupportedRatesLookUpTable[index].iWsaRate = WHA::KRate9Mbits;
       
   412 
       
   413         OsTracePrint( KUmacDetails, (TUint8*)("current index: %d"), index);
       
   414         OsTracePrint( KUmacDetails, (TUint8*)("dot11 rate added: 0x%02x"), 
       
   415             iSupportedRatesLookUpTable[index].iSupportedRate);
       
   416         OsTracePrint( KUmacDetails, (TUint8*)("WHA rate added: 0x%08x"), 
       
   417             iSupportedRatesLookUpTable[index].iWsaRate);
       
   418 
       
   419         ++index;
       
   420         }
       
   421     if ( iWHASettings.iRates & WHA::KRate11Mbits )
       
   422         {
       
   423         iSupportedRatesLookUpTable[index].iSupportedRate = E802Dot11Rate11MBit;
       
   424         iSupportedRatesLookUpTable[index].iWsaRate = WHA::KRate11Mbits;
       
   425 
       
   426         OsTracePrint( KUmacDetails, (TUint8*)("current index: %d"), index);
       
   427         OsTracePrint( KUmacDetails, (TUint8*)("dot11 rate added: 0x%02x"), 
       
   428             iSupportedRatesLookUpTable[index].iSupportedRate);
       
   429         OsTracePrint( KUmacDetails, (TUint8*)("WHA rate added: 0x%08x"), 
       
   430             iSupportedRatesLookUpTable[index].iWsaRate);
       
   431 
       
   432         ++index;
       
   433         }
       
   434     if ( iWHASettings.iRates & WHA::KRate12Mbits )
       
   435         {
       
   436         iSupportedRatesLookUpTable[index].iSupportedRate = E802Dot11Rate12MBit;
       
   437         iSupportedRatesLookUpTable[index].iWsaRate = WHA::KRate12Mbits;
       
   438 
       
   439         OsTracePrint( KUmacDetails, (TUint8*)("current index: %d"), index);
       
   440         OsTracePrint( KUmacDetails, (TUint8*)("dot11 rate added: 0x%02x"), 
       
   441             iSupportedRatesLookUpTable[index].iSupportedRate);
       
   442         OsTracePrint( KUmacDetails, (TUint8*)("WHA rate added: 0x%08x"), 
       
   443             iSupportedRatesLookUpTable[index].iWsaRate);
       
   444 
       
   445         ++index;
       
   446         }
       
   447     if ( iWHASettings.iRates & WHA::KRate18Mbits )
       
   448         {
       
   449         iSupportedRatesLookUpTable[index].iSupportedRate = E802Dot11Rate18MBit;
       
   450         iSupportedRatesLookUpTable[index].iWsaRate = WHA::KRate18Mbits;
       
   451 
       
   452         OsTracePrint( KUmacDetails, (TUint8*)("current index: %d"), index);
       
   453         OsTracePrint( KUmacDetails, (TUint8*)("dot11 rate added: 0x%02x"), 
       
   454             iSupportedRatesLookUpTable[index].iSupportedRate);
       
   455         OsTracePrint( KUmacDetails, (TUint8*)("WHA rate added: 0x%08x"), 
       
   456             iSupportedRatesLookUpTable[index].iWsaRate);
       
   457 
       
   458         ++index;
       
   459         }
       
   460     if ( iWHASettings.iRates & WHA::KRate22Mbits )
       
   461         {
       
   462         iSupportedRatesLookUpTable[index].iSupportedRate = E802Dot11Rate22MBit;
       
   463         iSupportedRatesLookUpTable[index].iWsaRate = WHA::KRate22Mbits;
       
   464 
       
   465         OsTracePrint( KUmacDetails, (TUint8*)("current index: %d"), index);
       
   466         OsTracePrint( KUmacDetails, (TUint8*)("dot11 rate added: 0x%02x"), 
       
   467             iSupportedRatesLookUpTable[index].iSupportedRate);
       
   468         OsTracePrint( KUmacDetails, (TUint8*)("WHA rate added: 0x%08x"), 
       
   469             iSupportedRatesLookUpTable[index].iWsaRate);
       
   470 
       
   471         ++index;
       
   472         }
       
   473     if ( iWHASettings.iRates & WHA::KRate24Mbits )
       
   474         {
       
   475         iSupportedRatesLookUpTable[index].iSupportedRate = E802Dot11Rate24MBit;
       
   476         iSupportedRatesLookUpTable[index].iWsaRate = WHA::KRate24Mbits;
       
   477 
       
   478         OsTracePrint( KUmacDetails, (TUint8*)("current index: %d"), index);
       
   479         OsTracePrint( KUmacDetails, (TUint8*)("dot11 rate added: 0x%02x"), 
       
   480             iSupportedRatesLookUpTable[index].iSupportedRate);
       
   481         OsTracePrint( KUmacDetails, (TUint8*)("WHA rate added: 0x%08x"), 
       
   482             iSupportedRatesLookUpTable[index].iWsaRate);
       
   483 
       
   484         ++index;
       
   485         }
       
   486     if ( iWHASettings.iRates & WHA::KRate33Mbits )
       
   487         {
       
   488         iSupportedRatesLookUpTable[index].iSupportedRate = E802Dot11Rate33MBit;
       
   489         iSupportedRatesLookUpTable[index].iWsaRate = WHA::KRate33Mbits;
       
   490 
       
   491         OsTracePrint( KUmacDetails, (TUint8*)("current index: %d"), index);
       
   492         OsTracePrint( KUmacDetails, (TUint8*)("dot11 rate added: 0x%02x"), 
       
   493             iSupportedRatesLookUpTable[index].iSupportedRate);
       
   494         OsTracePrint( KUmacDetails, (TUint8*)("WHA rate added: 0x%08x"), 
       
   495             iSupportedRatesLookUpTable[index].iWsaRate);
       
   496 
       
   497         ++index;
       
   498         }
       
   499     if ( iWHASettings.iRates & WHA::KRate36Mbits )
       
   500         {
       
   501         iSupportedRatesLookUpTable[index].iSupportedRate = E802Dot11Rate36MBit;
       
   502         iSupportedRatesLookUpTable[index].iWsaRate = WHA::KRate36Mbits;
       
   503 
       
   504         OsTracePrint( KUmacDetails, (TUint8*)("current index: %d"), index);
       
   505         OsTracePrint( KUmacDetails, (TUint8*)("dot11 rate added: 0x%02x"), 
       
   506             iSupportedRatesLookUpTable[index].iSupportedRate);
       
   507         OsTracePrint( KUmacDetails, (TUint8*)("WHA rate added: 0x%08x"), 
       
   508             iSupportedRatesLookUpTable[index].iWsaRate);
       
   509 
       
   510         ++index;
       
   511         }
       
   512     if ( iWHASettings.iRates & WHA::KRate48Mbits )
       
   513         {
       
   514         iSupportedRatesLookUpTable[index].iSupportedRate = E802Dot11Rate48MBit;
       
   515         iSupportedRatesLookUpTable[index].iWsaRate = WHA::KRate48Mbits;
       
   516 
       
   517         OsTracePrint( KUmacDetails, (TUint8*)("current index: %d"), index);
       
   518         OsTracePrint( KUmacDetails, (TUint8*)("dot11 rate added: 0x%02x"), 
       
   519             iSupportedRatesLookUpTable[index].iSupportedRate);
       
   520         OsTracePrint( KUmacDetails, (TUint8*)("WHA rate added: 0x%08x"), 
       
   521             iSupportedRatesLookUpTable[index].iWsaRate);
       
   522 
       
   523         ++index;
       
   524         }
       
   525     if ( iWHASettings.iRates & WHA::KRate54Mbits )
       
   526         {
       
   527         iSupportedRatesLookUpTable[index].iSupportedRate = E802Dot11Rate54MBit;
       
   528         iSupportedRatesLookUpTable[index].iWsaRate = WHA::KRate54Mbits;
       
   529 
       
   530         OsTracePrint( KUmacDetails, (TUint8*)("current index: %d"), index);
       
   531         OsTracePrint( KUmacDetails, (TUint8*)("dot11 rate added: 0x%02x"), 
       
   532             iSupportedRatesLookUpTable[index].iSupportedRate);
       
   533         OsTracePrint( KUmacDetails, (TUint8*)("WHA rate added: 0x%08x"), 
       
   534             iSupportedRatesLookUpTable[index].iWsaRate);
       
   535 
       
   536         ++index;
       
   537         }                
       
   538     }
       
   539 
       
   540 // ---------------------------------------------------------------------------
       
   541 // 
       
   542 // ---------------------------------------------------------------------------
       
   543 //
       
   544 void WlanContextImpl::AttachWsa( WHA::Wha* aWha )
       
   545     {
       
   546     iWha = aWha;
       
   547 
       
   548     OsTracePrint( KInitLevel, 
       
   549         (TUint8*)("UMAC: WlanContextImpl::AttachWsa: address: 0x%08x"), 
       
   550         reinterpret_cast<TUint32>(iWha) );    
       
   551     OsTracePrint( KInitLevel, (TUint8*)("UMAC: WHA-CMD-Attach"));
       
   552     // attach the NWSA-callback
       
   553     iWha->Attach( *this );
       
   554     }
       
   555 
       
   556 // ---------------------------------------------------------------------------
       
   557 // 
       
   558 // ---------------------------------------------------------------------------
       
   559 //
       
   560 void WlanContextImpl::CommandResponse( 
       
   561     WHA::TCommandId aCommandId, 
       
   562     WHA::TStatus aStatus,
       
   563     const WHA::UCommandResponseParams& aCommandResponseParams )
       
   564     {
       
   565     OsTracePrint( KWsaCallback, 
       
   566         (TUint8*)("UMAC * WHA-CB-CommandResponse()"));
       
   567 
       
   568     iCurrentMacState->CommandResponse( 
       
   569         *this, 
       
   570         aCommandId,
       
   571         aStatus,
       
   572         aCommandResponseParams );
       
   573     }
       
   574 
       
   575 // ---------------------------------------------------------------------------
       
   576 // 
       
   577 // ---------------------------------------------------------------------------
       
   578 //
       
   579 TBool WlanContextImpl::OnDeferredWhaCommandComplete( 
       
   580     WHA::TCompleteCommandId aCompleteCommandId, 
       
   581     WHA::TStatus aStatus,
       
   582     const WHA::UCommandCompletionParams& aCommandCompletionParams )
       
   583     {
       
   584     if ( WsaCmdActive() )
       
   585         {
       
   586         // programming error
       
   587         OsAssert( (TUint8*)("UMAC: panic"), (TUint8*)(WLAN_FILE), __LINE__ );
       
   588         }
       
   589 
       
   590     return iCurrentMacState->CommandComplete( 
       
   591         *this, 
       
   592         aCompleteCommandId, 
       
   593         aStatus,
       
   594         aCommandCompletionParams );
       
   595     }
       
   596 
       
   597 // ---------------------------------------------------------------------------
       
   598 // 
       
   599 // ---------------------------------------------------------------------------
       
   600 //
       
   601 TBool WlanContextImpl::OnDeferredInternalEvent( TInternalEvent aInternalEvent )
       
   602     {
       
   603     OsTracePrint( KUmacDetails, 
       
   604         (TUint8*)("UMAC: WlanContextImpl::OnDeferredInternalEvent()"));    
       
   605     
       
   606     TBool stateChanged ( EFalse );
       
   607 
       
   608     if ( WsaCmdActive() )
       
   609         {
       
   610         // programming error
       
   611         OsAssert( (TUint8*)("UMAC: panic"), (TUint8*)(WLAN_FILE), __LINE__ );
       
   612         }
       
   613 
       
   614     switch ( aInternalEvent )
       
   615         {
       
   616         case KAcParamUpdate:
       
   617             stateChanged = iCurrentMacState->ConfigureAcParams( *this );
       
   618             break;
       
   619         case KPowerMgmtTransition:
       
   620             stateChanged = iCurrentMacState->ChangePowerMgmtMode( *this );
       
   621             break;
       
   622         case KTimeout:
       
   623             stateChanged = iCurrentMacState->OnTimeout( *this );
       
   624             break;
       
   625         case KVoiceCallEntryTimerTimeout:
       
   626             stateChanged = iCurrentMacState->OnVoiceCallEntryTimerTimeout( 
       
   627                 *this );
       
   628             break;
       
   629         case KNullTimerTimeout:
       
   630             stateChanged = iCurrentMacState->OnNullTimerTimeout( *this );
       
   631             break;
       
   632         case KNoVoiceTimerTimeout:
       
   633             stateChanged = iCurrentMacState->OnNoVoiceTimerTimeout( *this );
       
   634             break;
       
   635         case KKeepAliveTimerTimeout:
       
   636             stateChanged = iCurrentMacState->OnKeepAliveTimerTimeout( *this );
       
   637             break;
       
   638         case KActiveToLightPsTimerTimeout:
       
   639             stateChanged = iCurrentMacState->OnActiveToLightPsTimerTimeout( 
       
   640                 *this );
       
   641             break;
       
   642         case KLightPsToActiveTimerTimeout:
       
   643             stateChanged = iCurrentMacState->OnLightPsToActiveTimerTimeout( 
       
   644                 *this );
       
   645             break;
       
   646         case KLightPsToDeepPsTimerTimeout:
       
   647             stateChanged = iCurrentMacState->OnLightPsToDeepPsTimerTimeout( 
       
   648                 *this );
       
   649             break;
       
   650         case KSetCtsToSelf:
       
   651             stateChanged = iCurrentMacState->SetCtsToSelfMib( *this );
       
   652             break;
       
   653         case KSetRcpiTriggerLevel:
       
   654             stateChanged = iCurrentMacState->SetRcpiTriggerLevelMib( 
       
   655                 *this, 
       
   656                 WHA::KRcpiThresholdDefault, 
       
   657                 EFalse );
       
   658             break;
       
   659         case KSetHtBssOperation:
       
   660             stateChanged = iCurrentMacState->ConfigureHtBssOperation( *this );
       
   661             break;
       
   662         default:
       
   663             OsTracePrint( KErrorLevel, 
       
   664                 (TUint8*)("UMAC: aInternalEvent: %d"), aInternalEvent );
       
   665             OsAssert( 
       
   666                 (TUint8*)("UMAC: panic"), 
       
   667                 (TUint8*)(WLAN_FILE), 
       
   668                 __LINE__ );        
       
   669         }        
       
   670     return stateChanged;
       
   671     }
       
   672 // ---------------------------------------------------------------------------
       
   673 // 
       
   674 // ---------------------------------------------------------------------------
       
   675 //
       
   676 void WlanContextImpl::CommandComplete( 
       
   677     WHA::TCompleteCommandId aCompleteCommandId, 
       
   678     WHA::TStatus aStatus,
       
   679     const WHA::UCommandCompletionParams& aCommandCompletionParams )
       
   680     {
       
   681     OsTracePrint( KWsaCallback, 
       
   682         (TUint8*)("UMAC: WHA-CB-CommandComplete: aStatus: %d"),
       
   683         aStatus );
       
   684 
       
   685     if ( !WsaCmdActive() )
       
   686         {
       
   687         iCurrentMacState->CommandComplete( 
       
   688             *this, 
       
   689             aCompleteCommandId, 
       
   690             aStatus,
       
   691             aCommandCompletionParams );
       
   692         }
       
   693     else
       
   694         {
       
   695         // WHA command is in progress so we must defer this access
       
   696         iEventDispatcher.Register( 
       
   697             aCompleteCommandId, 
       
   698             aStatus,
       
   699             aCommandCompletionParams );
       
   700         }
       
   701     }
       
   702 
       
   703 // ---------------------------------------------------------------------------
       
   704 // 
       
   705 // ---------------------------------------------------------------------------
       
   706 //
       
   707 void WlanContextImpl::Indication( 
       
   708     WHA::TIndicationId aIndicationId,
       
   709     const WHA::UIndicationParams& aIndicationParams )
       
   710     {
       
   711     OsTracePrint( KWsaCallback, 
       
   712         (TUint8*)("UMAC: WHA-CB-Indication: indication: %d"), aIndicationId);
       
   713 
       
   714     iCurrentMacState->Indication( 
       
   715         *this, 
       
   716         aIndicationId, 
       
   717         aIndicationParams );
       
   718     }
       
   719 
       
   720 // Frame sending callbacks
       
   721 
       
   722 // ---------------------------------------------------------------------------
       
   723 // 
       
   724 // ---------------------------------------------------------------------------
       
   725 //
       
   726 void WlanContextImpl::SendPacketTransfer(
       
   727     WHA::TPacketId aPacketId )
       
   728     {
       
   729 #ifndef NDEBUG
       
   730     OsTracePrint( KWsaCallback | KWsaTx, 
       
   731         (TUint8*)("UMAC: WHA-CB-SendPacketTransfer: aPacketId: 0x%08x"),
       
   732         aPacketId );
       
   733 #endif // !NDEBUG
       
   734 
       
   735     iPacketScheduler.SendPacketTransfer( *this, aPacketId );
       
   736     }
       
   737 
       
   738 // ---------------------------------------------------------------------------
       
   739 // 
       
   740 // ---------------------------------------------------------------------------
       
   741 //
       
   742 void WlanContextImpl::SendPacketComplete(
       
   743     WHA::TStatus aStatus,
       
   744     WHA::TPacketId aPacketId,
       
   745     WHA::TRate aRate,
       
   746     TUint32 aPacketQueueDelay,
       
   747     TUint32 aMediaDelay,
       
   748     TUint8 aAckFailures,
       
   749     TUint16 aSequenceNumber )
       
   750     {
       
   751 #ifndef NDEBUG
       
   752     OsTracePrint( KWsaCallback | KWsaTx, (TUint8*)
       
   753         ("UMAC: WHA-CB-SendPacketComplete: aStatus: %d"),
       
   754         aStatus );
       
   755     OsTracePrint( KWsaTx, (TUint8*)
       
   756         ("UMAC: WHA-CB-SendPacketComplete: aPacketId: 0x%08x"),
       
   757         aPacketId );
       
   758     OsTracePrint( KWsaTx, (TUint8*)
       
   759         ("UMAC: WHA-CB-SendPacketComplete: aRate: 0x%08x"),
       
   760         aRate );
       
   761     OsTracePrint( KWsaTx, (TUint8*)
       
   762         ("UMAC: WHA-CB-SendPacketComplete: aPacketQueueDelay: %d"),
       
   763         aPacketQueueDelay );
       
   764     OsTracePrint( KWsaTx, (TUint8*)
       
   765         ("UMAC: WHA-CB-SendPacketComplete: aMediaDelay: %d"),
       
   766         aMediaDelay );
       
   767     OsTracePrint( KWsaTx, (TUint8*)
       
   768         ("UMAC: WHA-CB-SendPacketComplete: aAckFailures: %d"),
       
   769         aAckFailures );
       
   770     OsTracePrint( KWsaTx, (TUint8*)
       
   771         ("UMAC: WHA-CB-SendPacketComplete: aSequenceNumber: %d"),
       
   772         aSequenceNumber );
       
   773 #endif // !NDEBUG
       
   774     
       
   775     iPacketScheduler.SendPacketComplete( 
       
   776         *this,
       
   777         aStatus,
       
   778         aPacketId,
       
   779         aRate,
       
   780         aPacketQueueDelay,
       
   781         aMediaDelay,
       
   782         aAckFailures );
       
   783     }
       
   784 
       
   785 // Frame receive
       
   786 
       
   787 // ---------------------------------------------------------------------------
       
   788 // 
       
   789 // ---------------------------------------------------------------------------
       
   790 //
       
   791 TAny* WlanContextImpl::RequestForBuffer( 
       
   792     TUint16 aLength )
       
   793     {
       
   794 #ifndef NDEBUG
       
   795     OsTracePrint( KWsaCallback, 
       
   796         (TUint8*)("UMAC: WHA-CB-RequestForBuffer: aLength: %d"), aLength);
       
   797 #endif // !NDEBUG
       
   798 
       
   799     TAny* buffer = iCurrentMacState->RequestForBuffer( *this, aLength );
       
   800 
       
   801     return buffer;
       
   802     }
       
   803 
       
   804 // ---------------------------------------------------------------------------
       
   805 // 
       
   806 // ---------------------------------------------------------------------------
       
   807 //
       
   808 void WlanContextImpl::ReceivePacket( 
       
   809     WHA::TStatus aStatus,
       
   810     const void* aFrame,
       
   811     TUint16 aLength,
       
   812     WHA::TRate aRate,
       
   813     WHA::TRcpi aRcpi,
       
   814     WHA::TChannelNumber aChannel,
       
   815     void* aBuffer,
       
   816     TUint32 aFlags )
       
   817     {
       
   818 #ifndef NDEBUG
       
   819     OsTracePrint( KWsaCallback | KRxFrame, (TUint8*)
       
   820         ("UMAC: WHA-CB-ReceivePacket(): aStatus: %d"), aStatus);
       
   821     OsTracePrint( KWsaCallback | KRxFrame, (TUint8*)
       
   822         ("UMAC: aLength: %d"), aLength);
       
   823     OsTracePrint( KWsaCallback | KRxFrame, (TUint8*)
       
   824         ("UMAC: aBuffer: 0x%08x"), reinterpret_cast<TUint32>(aBuffer) );
       
   825     OsTracePrint( KWsaCallback | KRxFrame, (TUint8*)
       
   826         ("UMAC: aFlags: 0x%08x"), aFlags );
       
   827 
       
   828     if ( aFrame )
       
   829         {
       
   830         SDataMpduHeader* hdr 
       
   831             = reinterpret_cast<SDataMpduHeader*>(const_cast<TAny*>(aFrame));
       
   832     
       
   833         OsTracePrint( KRxFrame, 
       
   834             (TUint8*)("UMAC: WlanContextImpl::ReceivePacket: sequence nbr: %d"), 
       
   835             hdr->iHdr.SequenceNumber() );
       
   836         OsTracePrint( KRxFrame, 
       
   837             (TUint8*)("UMAC: WlanContextImpl::ReceivePacket: sequence nbr: 0x%04x"), 
       
   838             hdr->iHdr.SequenceNumber() );
       
   839         }
       
   840 #endif // !NDEBUG
       
   841 
       
   842     if ( !(WHASettings().iCapability & WHA::SSettings::KMultipleRxBuffers ) )
       
   843         {
       
   844         aBuffer = iCurrentRxBuffer;
       
   845         OsTracePrint( KRxFrame, (TUint8*)
       
   846             ("UMAC: single Rx buf mode; aBuffer set to: 0x%08x"), 
       
   847             reinterpret_cast<TUint32>(aBuffer) );
       
   848         }
       
   849 
       
   850 #ifndef NDEBUG
       
   851     if ( !aBuffer )
       
   852         {
       
   853         // the Rx buffer pointer is NULL. Irrespective of the mode (single or
       
   854         // multiple Rx buffers) this is a sign of an implementation error in 
       
   855         // the lower layers
       
   856         OsTracePrint( KErrorLevel, (TUint8*)("UMAC: Rx buf pointer is NULL") );
       
   857         OsAssert( (TUint8*)("UMAC: panic"),(TUint8*)(WLAN_FILE), __LINE__ );
       
   858         }
       
   859 #endif // !NDEBUG
       
   860     
       
   861     iCurrentMacState->ReceivePacket( 
       
   862         *this, 
       
   863         aStatus, 
       
   864         aFrame, 
       
   865         aLength, 
       
   866         aRate, 
       
   867         aRcpi, 
       
   868         aChannel,
       
   869         reinterpret_cast<TUint8*>(aBuffer), 
       
   870         aFlags );
       
   871     }
       
   872 
       
   873 // -----------------------------------------------------------------------------
       
   874 // 
       
   875 // -----------------------------------------------------------------------------
       
   876 //
       
   877 TBool WlanContextImpl::TxNullDataFrame( 
       
   878     WlanContextImpl& aCtxImpl, 
       
   879     TBool aQosNull )
       
   880     {
       
   881     return iCurrentMacState->TxNullDataFrame( aCtxImpl, aQosNull );
       
   882     }
       
   883 
       
   884 // -----------------------------------------------------------------------------
       
   885 // 
       
   886 // -----------------------------------------------------------------------------
       
   887 //
       
   888 WlanContextImpl::JoinedMulticastGroups::JoinedMulticastGroups()
       
   889     : iFirstFreeIndex( 0 )
       
   890     {
       
   891     os_memset( iStorage, 0, sizeof( iStorage ) );
       
   892     Reset();
       
   893     }
       
   894 
       
   895 // -----------------------------------------------------------------------------
       
   896 // 
       
   897 // -----------------------------------------------------------------------------
       
   898 //
       
   899 WlanContextImpl::TGroupAddStatus 
       
   900     WlanContextImpl::JoinedMulticastGroups::AddGroup( 
       
   901         const TMacAddress& aGroup )
       
   902     {
       
   903     TGroupAddStatus addStatus( EOk );
       
   904     TUint index( 0 );
       
   905     
       
   906     if ( iFirstFreeIndex == KMaxNbrOfGroups )
       
   907         {
       
   908         // container full, cannot add any more
       
   909         addStatus = EFull;
       
   910         }
       
   911     else
       
   912         {
       
   913         // not full
       
   914         
       
   915         if ( FindGroup( aGroup, index ) )
       
   916             {
       
   917             // group already exists, don't add again
       
   918             addStatus = EAlreadyExists;
       
   919             }
       
   920         else
       
   921             {
       
   922             // doesn't exist yet, so go ahead and add it            
       
   923             iStorage[iFirstFreeIndex] = aGroup;
       
   924             ++iFirstFreeIndex;
       
   925             }
       
   926         }
       
   927         
       
   928     return addStatus;
       
   929     }
       
   930 
       
   931 // -----------------------------------------------------------------------------
       
   932 // 
       
   933 // -----------------------------------------------------------------------------
       
   934 //
       
   935 TBool WlanContextImpl::JoinedMulticastGroups::RemoveGroup( 
       
   936     const TMacAddress& aGroup )
       
   937     {
       
   938     TBool foundAndRemoved( EFalse );
       
   939     TUint index( 0 );
       
   940     
       
   941     if ( FindGroup( aGroup, index ) )
       
   942         { 
       
   943         // entry found
       
   944         
       
   945         if ( index < ( iFirstFreeIndex - 1 ) )
       
   946             {
       
   947             // it wasn't the last (or the only) entry, so replace the entry to 
       
   948             // be removed with the last entry so that we don't create an empty 
       
   949             // slot in the middle (or in the beginning)
       
   950             iStorage[index] = iStorage[iFirstFreeIndex - 1];
       
   951             iFree[iFirstFreeIndex - 1] = ETrue;
       
   952             }
       
   953         else
       
   954             {
       
   955             // it was the last (and possibly also the only) entry
       
   956             // just mark the entry to be free
       
   957             iFree[index] = ETrue;
       
   958             }
       
   959 
       
   960         foundAndRemoved = ETrue;
       
   961         --iFirstFreeIndex;        
       
   962         }
       
   963         
       
   964     return foundAndRemoved;
       
   965     }
       
   966 
       
   967 // -----------------------------------------------------------------------------
       
   968 // 
       
   969 // -----------------------------------------------------------------------------
       
   970 //
       
   971 TUint8 WlanContextImpl::JoinedMulticastGroups::Count() const
       
   972     {
       
   973     return iFirstFreeIndex;
       
   974     }
       
   975 
       
   976 // -----------------------------------------------------------------------------
       
   977 // 
       
   978 // -----------------------------------------------------------------------------
       
   979 //
       
   980 TUint8 WlanContextImpl::JoinedMulticastGroups::GetGroups( 
       
   981     const TMacAddress*& aGroups ) const
       
   982     {
       
   983     aGroups = iStorage;
       
   984     return iFirstFreeIndex;
       
   985     }
       
   986 
       
   987 // -----------------------------------------------------------------------------
       
   988 // 
       
   989 // -----------------------------------------------------------------------------
       
   990 //
       
   991 void WlanContextImpl::JoinedMulticastGroups::Reset()
       
   992     {
       
   993     for (TUint8 i = 0; i < KMaxNbrOfGroups; i++ )
       
   994         {
       
   995         iFree[i] = ETrue;
       
   996         }
       
   997         
       
   998     iFirstFreeIndex = 0;
       
   999     }
       
  1000 
       
  1001 // -----------------------------------------------------------------------------
       
  1002 // 
       
  1003 // -----------------------------------------------------------------------------
       
  1004 //
       
  1005 TBool WlanContextImpl::JoinedMulticastGroups::FindGroup( 
       
  1006     const TMacAddress& aGroup, TUint& aIndex ) const
       
  1007     {
       
  1008     TBool found( EFalse );
       
  1009     TUint index( 0 );
       
  1010     
       
  1011     while ( !found && ( index < iFirstFreeIndex ) )
       
  1012         {
       
  1013         if ( aGroup == iStorage[index] )
       
  1014             {
       
  1015             found = ETrue;
       
  1016             aIndex = index;
       
  1017             }
       
  1018         else
       
  1019             {
       
  1020             ++index;
       
  1021             }
       
  1022         }
       
  1023         
       
  1024     return found;
       
  1025     }
       
  1026 
       
  1027 // -----------------------------------------------------------------------------
       
  1028 // 
       
  1029 // -----------------------------------------------------------------------------
       
  1030 //
       
  1031 void WlanContextImpl::UseShortSlotTime( 
       
  1032     TBool aValue )
       
  1033     {
       
  1034     if ( aValue )
       
  1035         {
       
  1036         iConnectContext.iFlags |= WlanConnectContext::KUseShortSlotTime;
       
  1037         }
       
  1038     else
       
  1039        {
       
  1040         iConnectContext.iFlags &= ~(WlanConnectContext::KUseShortSlotTime);
       
  1041         }
       
  1042     }
       
  1043 
       
  1044 // -----------------------------------------------------------------------------
       
  1045 // 
       
  1046 // -----------------------------------------------------------------------------
       
  1047 //
       
  1048 void WlanContextImpl::ProtectionBitSet( TBool aValue )
       
  1049     {
       
  1050     if ( aValue )
       
  1051         {
       
  1052         iConnectContext.iFlags |= WlanConnectContext::KProtectionBitSet;
       
  1053         }
       
  1054     else
       
  1055        {
       
  1056         iConnectContext.iFlags &= ~(WlanConnectContext::KProtectionBitSet);
       
  1057         }
       
  1058     }
       
  1059 
       
  1060 // -----------------------------------------------------------------------------
       
  1061 // 
       
  1062 // -----------------------------------------------------------------------------
       
  1063 //
       
  1064 void WlanContextImpl::QosEnabled( TBool aValue )
       
  1065     {
       
  1066     if ( aValue )
       
  1067         {
       
  1068         iConnectContext.iFlags |= WlanConnectContext::KQosEnabled;
       
  1069         }
       
  1070     else
       
  1071        {
       
  1072         iConnectContext.iFlags &= ~(WlanConnectContext::KQosEnabled);
       
  1073         }
       
  1074     }
       
  1075 
       
  1076 // -----------------------------------------------------------------------------
       
  1077 // 
       
  1078 // -----------------------------------------------------------------------------
       
  1079 //
       
  1080 void WlanContextImpl::UapsdEnabled( TBool aValue )
       
  1081     {
       
  1082     if ( aValue )
       
  1083         {
       
  1084         iConnectContext.iFlags |= WlanConnectContext::KUapsdEnabled;
       
  1085         }
       
  1086     else
       
  1087        {
       
  1088         iConnectContext.iFlags &= ~(WlanConnectContext::KUapsdEnabled);
       
  1089         }
       
  1090     }
       
  1091 
       
  1092 // -----------------------------------------------------------------------------
       
  1093 // 
       
  1094 // -----------------------------------------------------------------------------
       
  1095 //
       
  1096 void WlanContextImpl::MulticastFilteringDisAllowed( TBool aValue )
       
  1097     {
       
  1098     if ( aValue )
       
  1099         {
       
  1100         iConnectContext.iFlags |= WlanConnectContext::KMulticastFilteringDisAllowed;
       
  1101         }
       
  1102     else
       
  1103        {
       
  1104         iConnectContext.iFlags &= ~(WlanConnectContext::KMulticastFilteringDisAllowed);
       
  1105         }    
       
  1106     }
       
  1107 
       
  1108 // -----------------------------------------------------------------------------
       
  1109 // 
       
  1110 // -----------------------------------------------------------------------------
       
  1111 //
       
  1112 void WlanContextImpl::ErpIePresent( TBool aValue )
       
  1113     {
       
  1114     if ( aValue )
       
  1115         {
       
  1116         iConnectContext.iFlags |= WlanConnectContext::KErpIePresent;
       
  1117         }
       
  1118     else
       
  1119        {
       
  1120         iConnectContext.iFlags &= ~(WlanConnectContext::KErpIePresent);
       
  1121         }
       
  1122     }
       
  1123 
       
  1124 // -----------------------------------------------------------------------------
       
  1125 // 
       
  1126 // -----------------------------------------------------------------------------
       
  1127 //
       
  1128 void WlanContextImpl::DisassociatedByAp( TBool aValue )
       
  1129     {
       
  1130     if ( aValue )
       
  1131         {
       
  1132         iConnectContext.iFlags |= WlanConnectContext::KDisassociatedByAp;
       
  1133         }
       
  1134     else
       
  1135        {
       
  1136         iConnectContext.iFlags &= ~(WlanConnectContext::KDisassociatedByAp);
       
  1137         }
       
  1138     }
       
  1139 
       
  1140 // -----------------------------------------------------------------------------
       
  1141 // 
       
  1142 // -----------------------------------------------------------------------------
       
  1143 //
       
  1144 void WlanContextImpl::UapsdRequestedForVoice( TBool aValue )
       
  1145     {
       
  1146     if ( aValue )
       
  1147         {
       
  1148         iConnectContext.iFlags |= WlanConnectContext::KUapsdRequestedForVoice;
       
  1149         }
       
  1150     else
       
  1151        {
       
  1152         iConnectContext.iFlags &= ~(WlanConnectContext::KUapsdRequestedForVoice);
       
  1153         }
       
  1154     }
       
  1155 
       
  1156 // -----------------------------------------------------------------------------
       
  1157 // 
       
  1158 // -----------------------------------------------------------------------------
       
  1159 //
       
  1160 void WlanContextImpl::UapsdRequestedForVideo( TBool aValue )
       
  1161     {
       
  1162     if ( aValue )
       
  1163         {
       
  1164         iConnectContext.iFlags |= 
       
  1165             WlanConnectContext::KUapsdRequestedForVideo;
       
  1166         }
       
  1167     else
       
  1168        {
       
  1169         iConnectContext.iFlags &= 
       
  1170             ~(WlanConnectContext::KUapsdRequestedForVideo);
       
  1171         }
       
  1172     }
       
  1173 
       
  1174 // -----------------------------------------------------------------------------
       
  1175 // 
       
  1176 // -----------------------------------------------------------------------------
       
  1177 //
       
  1178 void WlanContextImpl::UapsdRequestedForBestEffort( TBool aValue )
       
  1179     {
       
  1180     if ( aValue )
       
  1181         {
       
  1182         iConnectContext.iFlags |= 
       
  1183             WlanConnectContext::KUapsdRequestedForBestEffort;
       
  1184         }
       
  1185     else
       
  1186        {
       
  1187         iConnectContext.iFlags &= 
       
  1188             ~(WlanConnectContext::KUapsdRequestedForBestEffort);
       
  1189         }
       
  1190     }
       
  1191 
       
  1192 // -----------------------------------------------------------------------------
       
  1193 // 
       
  1194 // -----------------------------------------------------------------------------
       
  1195 //
       
  1196 void WlanContextImpl::UapsdRequestedForBackground( TBool aValue )
       
  1197     {
       
  1198     if ( aValue )
       
  1199         {
       
  1200         iConnectContext.iFlags |= 
       
  1201             WlanConnectContext::KUapsdRequestedForBackground;
       
  1202         }
       
  1203     else
       
  1204        {
       
  1205         iConnectContext.iFlags &= 
       
  1206             ~(WlanConnectContext::KUapsdRequestedForBackground);
       
  1207         }
       
  1208     }
       
  1209 
       
  1210 // -----------------------------------------------------------------------------
       
  1211 // 
       
  1212 // -----------------------------------------------------------------------------
       
  1213 //
       
  1214 void WlanContextImpl::UapsdUsedForVoice( TBool aValue )
       
  1215     {
       
  1216     if ( aValue )
       
  1217         {
       
  1218         iConnectContext.iFlags |= WlanConnectContext::KUapsdUsedForVoice;
       
  1219         }
       
  1220     else
       
  1221        {
       
  1222         iConnectContext.iFlags &= ~(WlanConnectContext::KUapsdUsedForVoice);
       
  1223         }
       
  1224     }
       
  1225 
       
  1226 // -----------------------------------------------------------------------------
       
  1227 // 
       
  1228 // -----------------------------------------------------------------------------
       
  1229 //
       
  1230 void WlanContextImpl::UapsdUsedForVideo( TBool aValue )
       
  1231     {
       
  1232     if ( aValue )
       
  1233         {
       
  1234         iConnectContext.iFlags |= 
       
  1235             WlanConnectContext::KUapsdUsedForVideo;
       
  1236         }
       
  1237     else
       
  1238        {
       
  1239         iConnectContext.iFlags &= 
       
  1240             ~(WlanConnectContext::KUapsdUsedForVideo);
       
  1241         }
       
  1242     }
       
  1243 
       
  1244 // -----------------------------------------------------------------------------
       
  1245 // 
       
  1246 // -----------------------------------------------------------------------------
       
  1247 //
       
  1248 void WlanContextImpl::UapsdUsedForBestEffort( TBool aValue )
       
  1249     {
       
  1250     if ( aValue )
       
  1251         {
       
  1252         iConnectContext.iFlags |= 
       
  1253             WlanConnectContext::KUapsdUsedForBestEffort;
       
  1254         }
       
  1255     else
       
  1256        {
       
  1257         iConnectContext.iFlags &= 
       
  1258             ~(WlanConnectContext::KUapsdUsedForBestEffort);
       
  1259         }
       
  1260     }
       
  1261 
       
  1262 // -----------------------------------------------------------------------------
       
  1263 // 
       
  1264 // -----------------------------------------------------------------------------
       
  1265 //
       
  1266 void WlanContextImpl::UapsdUsedForBackground( TBool aValue )
       
  1267     {
       
  1268     if ( aValue )
       
  1269         {
       
  1270         iConnectContext.iFlags |= 
       
  1271             WlanConnectContext::KUapsdUsedForBackground;
       
  1272         }
       
  1273     else
       
  1274        {
       
  1275         iConnectContext.iFlags &= 
       
  1276             ~(WlanConnectContext::KUapsdUsedForBackground);
       
  1277         }
       
  1278     }
       
  1279 
       
  1280 // -----------------------------------------------------------------------------
       
  1281 // 
       
  1282 // -----------------------------------------------------------------------------
       
  1283 //
       
  1284 void WlanContextImpl::ApTestOpportunitySeekStarted( TBool aValue )
       
  1285     {
       
  1286     if ( aValue )
       
  1287         {
       
  1288         iConnectContext.iFlags |= 
       
  1289             WlanConnectContext::KApTestOpportunitySeekStarted;
       
  1290         }
       
  1291     else
       
  1292        {
       
  1293         iConnectContext.iFlags &= 
       
  1294             ~(WlanConnectContext::KApTestOpportunitySeekStarted);
       
  1295         }
       
  1296     }
       
  1297 
       
  1298 // -----------------------------------------------------------------------------
       
  1299 // 
       
  1300 // -----------------------------------------------------------------------------
       
  1301 //
       
  1302 void WlanContextImpl::ApTestOpportunityIndicated( TBool aValue )
       
  1303     {
       
  1304     if ( aValue )
       
  1305         {
       
  1306         iConnectContext.iFlags |= 
       
  1307             WlanConnectContext::KApTestOpportunityIndicated;
       
  1308         }
       
  1309     else
       
  1310        {
       
  1311         iConnectContext.iFlags &= 
       
  1312             ~(WlanConnectContext::KApTestOpportunityIndicated);
       
  1313         }
       
  1314     }
       
  1315 
       
  1316 // -----------------------------------------------------------------------------
       
  1317 // 
       
  1318 // -----------------------------------------------------------------------------
       
  1319 //
       
  1320 void WlanContextImpl::HtSupportedByNw( TBool aValue )
       
  1321     {
       
  1322     if ( aValue )
       
  1323         {
       
  1324         iConnectContext.iFlags |= 
       
  1325             WlanConnectContext::KHtSupportedByNw;
       
  1326         }
       
  1327     else
       
  1328        {
       
  1329         iConnectContext.iFlags &= 
       
  1330             ~(WlanConnectContext::KHtSupportedByNw);
       
  1331         }
       
  1332     }
       
  1333 
       
  1334 // -----------------------------------------------------------------------------
       
  1335 // 
       
  1336 // -----------------------------------------------------------------------------
       
  1337 //
       
  1338 void WlanContextImpl::Reassociate( TBool aValue )
       
  1339     {
       
  1340     if ( aValue )
       
  1341         {
       
  1342         iConnectContext.iFlags |= WlanConnectContext::KReassociate;
       
  1343         }
       
  1344     else
       
  1345        {
       
  1346         iConnectContext.iFlags &= ~(WlanConnectContext::KReassociate);
       
  1347         }
       
  1348     }
       
  1349 
       
  1350 // -----------------------------------------------------------------------------
       
  1351 // 
       
  1352 // -----------------------------------------------------------------------------
       
  1353 //
       
  1354 void WlanContextImpl::UseShortPreamble( TBool aValue )
       
  1355     {
       
  1356     if ( aValue )
       
  1357         {
       
  1358         iConnectContext.iFlags |= WlanConnectContext::KUseShortPreamble;
       
  1359         }
       
  1360     else
       
  1361        {
       
  1362         iConnectContext.iFlags &= ~(WlanConnectContext::KUseShortPreamble);
       
  1363         }
       
  1364     }
       
  1365 
       
  1366 // ---------------------------------------------------------------------------
       
  1367 // 
       
  1368 // ---------------------------------------------------------------------------
       
  1369 //
       
  1370 TPowerMgmtMode WlanContextImpl::CurrentPwrMgmtMode() const
       
  1371     {
       
  1372     if ( CurrentDot11PwrMgmtMode() == WHA::KPsDisable )
       
  1373         {
       
  1374         return EActive;
       
  1375         }
       
  1376     else
       
  1377         {
       
  1378         const TDot11PsModeWakeupSetting lightPsModeWakeupSetting = 
       
  1379             ClientLightPsModeConfig();
       
  1380         
       
  1381         if ( iWlanMib.iWlanWakeupInterval == 
       
  1382              lightPsModeWakeupSetting.iWakeupMode )
       
  1383             {
       
  1384             if ( iWlanMib.iWlanWakeupInterval 
       
  1385                  == EWakeUpIntervalEveryNthBeacon || 
       
  1386                  iWlanMib.iWlanWakeupInterval 
       
  1387                  == EWakeUpIntervalEveryNthDtim )
       
  1388                 {
       
  1389                 if ( iWlanMib.iWlanListenInterval == 
       
  1390                      lightPsModeWakeupSetting.iListenInterval )
       
  1391                     {
       
  1392                     return ELightPs;                
       
  1393                     }
       
  1394                 else
       
  1395                     {
       
  1396                     // implementation error
       
  1397                     OsAssert( (TUint8*)("UMAC: panic"), 
       
  1398                         (TUint8*)(WLAN_FILE), __LINE__ );
       
  1399                     // this return value is not relevant
       
  1400                     return ELightPs;                    
       
  1401                     }                        
       
  1402                 }
       
  1403             else
       
  1404                 {
       
  1405                 // for these wake-up modes a possible difference in listen
       
  1406                 // interval is not meaningful                
       
  1407                 return ELightPs;
       
  1408                 }
       
  1409             }
       
  1410         else 
       
  1411             {
       
  1412             const TDot11PsModeWakeupSetting deepPsModeWakeupSetting = 
       
  1413                 ClientDeepPsModeConfig();
       
  1414             
       
  1415             if ( iWlanMib.iWlanWakeupInterval == 
       
  1416                  deepPsModeWakeupSetting.iWakeupMode )
       
  1417                 {
       
  1418                 if ( iWlanMib.iWlanWakeupInterval 
       
  1419                      == EWakeUpIntervalEveryNthBeacon || 
       
  1420                      iWlanMib.iWlanWakeupInterval 
       
  1421                      == EWakeUpIntervalEveryNthDtim )
       
  1422                     {
       
  1423                     if ( iWlanMib.iWlanListenInterval == 
       
  1424                          deepPsModeWakeupSetting.iListenInterval )
       
  1425                         {
       
  1426                         return EDeepPs;                
       
  1427                         }
       
  1428                     else
       
  1429                         {
       
  1430                         // implementation error
       
  1431                         OsAssert( (TUint8*)("UMAC: panic"), 
       
  1432                             (TUint8*)(WLAN_FILE), __LINE__ );
       
  1433                         // this return value is not relevant
       
  1434                         return ELightPs;                    
       
  1435                         }                        
       
  1436                     }
       
  1437                 else
       
  1438                     {
       
  1439                     // for these wake-up modes a possible difference in listen
       
  1440                     // interval is not meaningful                
       
  1441                     return EDeepPs;
       
  1442                     }
       
  1443                 }
       
  1444             else
       
  1445                 {
       
  1446                 // implementation error
       
  1447                 OsAssert( (TUint8*)("UMAC: panic"), 
       
  1448                     (TUint8*)(WLAN_FILE), __LINE__ );
       
  1449                 // this return value is not relevant
       
  1450                 return EActive;
       
  1451                 }
       
  1452             }
       
  1453         }
       
  1454     }
       
  1455 
       
  1456 // ---------------------------------------------------------------------------
       
  1457 // 
       
  1458 // ---------------------------------------------------------------------------
       
  1459 //
       
  1460 void WlanContextImpl::DynamicPwrModeMgtDisabled( TBool aValue )
       
  1461     {
       
  1462     if ( aValue )
       
  1463         {
       
  1464         iConnectContext.iFlags |= 
       
  1465             WlanConnectContext::KDynamicPwrModeMgmtDisabled;
       
  1466         }
       
  1467     else
       
  1468        {
       
  1469         iConnectContext.iFlags &= 
       
  1470             ~(WlanConnectContext::KDynamicPwrModeMgmtDisabled);
       
  1471         }
       
  1472     }
       
  1473 
       
  1474 // ---------------------------------------------------------------------------
       
  1475 // 
       
  1476 // ---------------------------------------------------------------------------
       
  1477 //
       
  1478 TUint8* WlanContextImpl::GetRxBuffer( 
       
  1479     const TUint16 aLengthinBytes, 
       
  1480     TBool aInternal )
       
  1481     {
       
  1482     TUint8* buffer ( NULL );
       
  1483     
       
  1484     if ( aLengthinBytes <= KMaxDot11RxMpduLength )    
       
  1485         {
       
  1486         if ( aInternal )
       
  1487             {
       
  1488             buffer = iUmac.GetBufferForRxData( aLengthinBytes  );
       
  1489             }
       
  1490         else
       
  1491             {
       
  1492             buffer = iUmac.GetBufferForRxData( 
       
  1493                 aLengthinBytes + iWHASettings.iRxoffset );
       
  1494             
       
  1495             // set the current Rx buffer. This must be done only for 
       
  1496             // non-internal Rx buf requests, i.e. requests from WHA layer
       
  1497             iCurrentRxBuffer = buffer;
       
  1498             }
       
  1499         
       
  1500         if ( buffer )
       
  1501             {
       
  1502             OsTracePrint( KRxFrame, (TUint8*)
       
  1503                 ("UMAC: WlanContextImpl::GetRxBuffer: buf addr: 0x%08x"),
       
  1504                 reinterpret_cast<TUint32>(buffer) );
       
  1505             return buffer;
       
  1506             }
       
  1507         else
       
  1508             {
       
  1509             OsTracePrint( KRxFrame | KWarningLevel, (TUint8*)
       
  1510                 ("UMAC: WlanContextImpl::GetRxBuffer: WARNING: buffer reservation failed") );
       
  1511                 
       
  1512             return NULL;
       
  1513             }
       
  1514         }
       
  1515     else
       
  1516         {
       
  1517         OsTracePrint( KRxFrame | KWarningLevel, (TUint8*)
       
  1518             ("UMAC: WlanContextImpl::GetRxBuffer: WARNING: Buffer longer than max MPDU len requested. NULL returned") );
       
  1519         return NULL;        
       
  1520         }
       
  1521     }
       
  1522 
       
  1523 // ---------------------------------------------------------------------------
       
  1524 // 
       
  1525 // ---------------------------------------------------------------------------
       
  1526 //
       
  1527 TDataBuffer* WlanContextImpl::GetRxFrameMetaHeader()
       
  1528     {
       
  1529     return iUmac.GetRxFrameMetaHeader();
       
  1530     }
       
  1531 
       
  1532 // ---------------------------------------------------------------------------
       
  1533 // 
       
  1534 // ---------------------------------------------------------------------------
       
  1535 //
       
  1536 void WlanContextImpl::FreeRxFrameMetaHeader( TDataBuffer* aMetaHeader )
       
  1537     {
       
  1538     iUmac.FreeRxFrameMetaHeader( aMetaHeader );
       
  1539     }
       
  1540 
       
  1541 // ---------------------------------------------------------------------------
       
  1542 // 
       
  1543 // ---------------------------------------------------------------------------
       
  1544 //
       
  1545 TUint8* WlanContextImpl::TxBuffer( TBool aWaitIfNotFree )
       
  1546     {
       
  1547     TUint8* address ( NULL );
       
  1548     
       
  1549     if ( iInternalTxBufFree )
       
  1550         {
       
  1551         address = iUmac.DmaPrivateTxMemory() + iWHASettings.iTxFrameHeaderSpace;
       
  1552 
       
  1553         if ( address )
       
  1554             {
       
  1555             // valid address will be returned => mark buffer to be in use
       
  1556             iInternalTxBufFree = EFalse;
       
  1557 
       
  1558             OsTracePrint( KUmacDetails, (TUint8*)
       
  1559                 ("UMAC: WlanContextImpl::TxBuffer: internal Tx buf now in use"));
       
  1560             }
       
  1561         }
       
  1562     else
       
  1563         {
       
  1564         // buffer already in use. NULL will be returned.
       
  1565         
       
  1566         if ( aWaitIfNotFree )
       
  1567             {
       
  1568             // client would like to wait for the buffer to become free
       
  1569             
       
  1570             if ( !iInternalTxBufBeingWaited )
       
  1571                 {
       
  1572                 // the buffer is not being waited for currently
       
  1573                 
       
  1574                 // Note that someone is now waiting for the buffer
       
  1575                 iInternalTxBufBeingWaited = ETrue;
       
  1576 
       
  1577                 OsTracePrint( KUmacDetails, (TUint8*)
       
  1578                     ("UMAC: WlanContextImpl::TxBuffer: internal Tx buf already in use => now being waited for"));
       
  1579                 }
       
  1580             else
       
  1581                 {
       
  1582                 // the buffer is already being waited for. This is an
       
  1583                 // implementation error
       
  1584                 OsAssert( 
       
  1585                     (TUint8*)("UMAC: panic"), 
       
  1586                     (TUint8*)(WLAN_FILE), 
       
  1587                     __LINE__ );
       
  1588                 }
       
  1589             }
       
  1590         }
       
  1591         
       
  1592     return address;
       
  1593     }
       
  1594 
       
  1595 // ---------------------------------------------------------------------------
       
  1596 // 
       
  1597 // ---------------------------------------------------------------------------
       
  1598 //
       
  1599 TBool WlanContextImpl::OnBssRegained()
       
  1600     {
       
  1601     TBool ret( EFalse );
       
  1602 
       
  1603     if ( iConsecutiveBeaconsLostIndicated ||
       
  1604          iConsecutiveTxFailuresIndicated ||
       
  1605          iConsecutivePwrModeSetFailuresIndicated )
       
  1606         {
       
  1607         ResetBssLossIndications();
       
  1608         ret = ETrue;        
       
  1609         }
       
  1610 
       
  1611     return ret;
       
  1612     }
       
  1613 
       
  1614 // -----------------------------------------------------------------------------
       
  1615 //
       
  1616 // -----------------------------------------------------------------------------
       
  1617 //
       
  1618 TUint WlanContextImpl::AverageTxMediaDelay( 
       
  1619     WHA::TQueueId aAccessCategory ) const
       
  1620     {
       
  1621     const TUint totalTxDataFrameCount = 
       
  1622         iFrameStatistics.acSpecific[aAccessCategory].txUnicastDataFrameCount +
       
  1623         iFrameStatistics.acSpecific[aAccessCategory].txMulticastDataFrameCount;
       
  1624         
       
  1625     // return zero if no frames have been transmitted via this AC
       
  1626     return totalTxDataFrameCount ? 
       
  1627             iFrameStatistics.acSpecific[aAccessCategory].txMediaDelay /
       
  1628             totalTxDataFrameCount : 
       
  1629             0;
       
  1630     }
       
  1631 
       
  1632 // -----------------------------------------------------------------------------
       
  1633 // 
       
  1634 // -----------------------------------------------------------------------------
       
  1635 //
       
  1636 void WlanContextImpl::CalculateAverageTxMediaDelays()
       
  1637     {
       
  1638     for ( TUint accessCategory = 0; 
       
  1639           accessCategory < EQueueIdMax; 
       
  1640           ++accessCategory )
       
  1641         {
       
  1642         iFrameStatistics.acSpecific[accessCategory].txMediaDelay =
       
  1643             AverageTxMediaDelay( static_cast<WHA::TQueueId>(accessCategory) );
       
  1644         }    
       
  1645     }
       
  1646 
       
  1647 // ---------------------------------------------------------------------------
       
  1648 // 
       
  1649 // ---------------------------------------------------------------------------
       
  1650 //
       
  1651 void WlanContextImpl::UpdateTotalTxDelayHistogram( 
       
  1652     WHA::TQueueId aAccessCategory,
       
  1653     TUint aDelay )
       
  1654     {
       
  1655     const TUint KTotalTxDelayBin0UpperBound = 10000; // 10 ms
       
  1656     const TUint KTotalTxDelayBin1UpperBound = 20000; // 20 ms
       
  1657     const TUint KTotalTxDelayBin2UpperBound = 40000; // 40 ms
       
  1658 
       
  1659     if ( aDelay <= KTotalTxDelayBin0UpperBound )
       
  1660         {
       
  1661         ++iFrameStatistics.acSpecific[aAccessCategory].totalTxDelayBin0;
       
  1662 
       
  1663         OsTracePrint( KWsaTxDetails, (TUint8*)
       
  1664             ("UMAC: WlanContextImpl::UpdateTotalTxDelayHistogram: bin 0 cnt incremented. Count now: %d"),
       
  1665             iFrameStatistics.acSpecific[aAccessCategory].totalTxDelayBin0 );
       
  1666         }
       
  1667     else if ( aDelay > KTotalTxDelayBin0UpperBound && 
       
  1668               aDelay <= KTotalTxDelayBin1UpperBound )
       
  1669         {
       
  1670         ++iFrameStatistics.acSpecific[aAccessCategory].totalTxDelayBin1;
       
  1671 
       
  1672         OsTracePrint( KWsaTxDetails, (TUint8*)
       
  1673             ("UMAC: WlanContextImpl::UpdateTotalTxDelayHistogram: bin 1 cnt incremented. Count now: %d"),
       
  1674             iFrameStatistics.acSpecific[aAccessCategory].totalTxDelayBin1 );
       
  1675         }
       
  1676     else if ( aDelay > KTotalTxDelayBin1UpperBound && 
       
  1677               aDelay <= KTotalTxDelayBin2UpperBound )
       
  1678         {
       
  1679         ++iFrameStatistics.acSpecific[aAccessCategory].totalTxDelayBin2;
       
  1680 
       
  1681         OsTracePrint( KWsaTxDetails, (TUint8*)
       
  1682             ("UMAC: WlanContextImpl::UpdateTotalTxDelayHistogram: bin 2 cnt incremented. Count now: %d"),
       
  1683             iFrameStatistics.acSpecific[aAccessCategory].totalTxDelayBin2 );
       
  1684         }
       
  1685     else // aDelay > KTotalTxDelayBin2UpperBound
       
  1686         {
       
  1687         ++iFrameStatistics.acSpecific[aAccessCategory].totalTxDelayBin3;
       
  1688 
       
  1689         OsTracePrint( KWsaTxDetails, (TUint8*)
       
  1690             ("UMAC: WlanContextImpl::UpdateTotalTxDelayHistogram: bin 3 cnt incremented. Count now: %d"),
       
  1691             iFrameStatistics.acSpecific[aAccessCategory].totalTxDelayBin3 );
       
  1692         }    
       
  1693     }
       
  1694 
       
  1695 // -----------------------------------------------------------------------------
       
  1696 //
       
  1697 // -----------------------------------------------------------------------------
       
  1698 //
       
  1699 TUint WlanContextImpl::AverageTotalTxDelay( 
       
  1700     WHA::TQueueId aAccessCategory ) const
       
  1701     {
       
  1702     const TUint totalTxDataFrameCount = 
       
  1703         iFrameStatistics.acSpecific[aAccessCategory].txUnicastDataFrameCount +
       
  1704         iFrameStatistics.acSpecific[aAccessCategory].txMulticastDataFrameCount;
       
  1705         
       
  1706     // return zero if no frames have been transmitted via this AC
       
  1707     return totalTxDataFrameCount ? 
       
  1708             iFrameStatistics.acSpecific[aAccessCategory].totalTxDelay /
       
  1709             totalTxDataFrameCount : 
       
  1710             0;
       
  1711     }
       
  1712 
       
  1713 // -----------------------------------------------------------------------------
       
  1714 // 
       
  1715 // -----------------------------------------------------------------------------
       
  1716 //
       
  1717 void WlanContextImpl::CalculateAverageTotalTxDelays()
       
  1718     {
       
  1719     for ( TUint accessCategory = 0; 
       
  1720           accessCategory < EQueueIdMax; 
       
  1721           ++accessCategory )
       
  1722         {
       
  1723         iFrameStatistics.acSpecific[accessCategory].totalTxDelay =
       
  1724             AverageTotalTxDelay( static_cast<WHA::TQueueId>(accessCategory) );
       
  1725         }    
       
  1726     }
       
  1727 
       
  1728 // -----------------------------------------------------------------------------
       
  1729 // 
       
  1730 // -----------------------------------------------------------------------------
       
  1731 //
       
  1732 void WlanContextImpl::AddBssMembershipFeature( 
       
  1733     T802Dot11BssMembershipSelector aFeature )
       
  1734     {
       
  1735     TUint8 i ( 0 );
       
  1736 
       
  1737     do
       
  1738         {
       
  1739         if ( iOurBssMembershipFeatureArray[i] == KUnallocated )
       
  1740             {
       
  1741             iOurBssMembershipFeatureArray[i] = aFeature;
       
  1742 
       
  1743             OsTracePrint( KUmacDetails, (TUint8*)
       
  1744                 ("UMAC: WlanContextImpl::AddBssMembershipFeature: feature %d added to our feature list"),
       
  1745                 aFeature );            
       
  1746             
       
  1747             break;
       
  1748             }
       
  1749         else
       
  1750             {
       
  1751             ++i;
       
  1752             }
       
  1753         } while ( i != KMaxNumOfWlanFeatures );
       
  1754         
       
  1755 #ifndef NDEBUG 
       
  1756     if ( i == KMaxNumOfWlanFeatures )
       
  1757         {
       
  1758         // not enough space reserved for features
       
  1759         OsTracePrint( KErrorLevel, (TUint8*)
       
  1760             ("UMAC: WlanContextImpl::AddBssMembershipFeature: ERROR: not enough space reserved for features") );
       
  1761         OsAssert( 
       
  1762             (TUint8*)("UMAC: panic"), 
       
  1763             (TUint8*)(WLAN_FILE), __LINE__ );            
       
  1764         }
       
  1765 #endif
       
  1766     }
       
  1767 
       
  1768 // -----------------------------------------------------------------------------
       
  1769 // 
       
  1770 // -----------------------------------------------------------------------------
       
  1771 //
       
  1772 TBool WlanContextImpl::BssMembershipFeatureSupported( TUint8 aItem ) const
       
  1773     {
       
  1774     TBool supported ( EFalse );
       
  1775     
       
  1776     TUint8 i ( 0 );
       
  1777 
       
  1778     do
       
  1779         {
       
  1780         if ( aItem == iOurBssMembershipFeatureArray[i] )
       
  1781             {
       
  1782             supported = ETrue;
       
  1783 
       
  1784             OsTracePrint( KUmacDetails, (TUint8*)
       
  1785                 ("UMAC: WlanContextImpl::BssMembershipFeatureSupported: feature %d is supported by us"),
       
  1786                 aItem );            
       
  1787 
       
  1788             break;
       
  1789             }
       
  1790         else
       
  1791             {
       
  1792             ++i;
       
  1793             }
       
  1794         } while ( i != KMaxNumOfWlanFeatures );
       
  1795 
       
  1796     return supported;
       
  1797     }
       
  1798 
       
  1799 // -----------------------------------------------------------------------------
       
  1800 // 
       
  1801 // -----------------------------------------------------------------------------
       
  1802 //
       
  1803 void WlanContextImpl::OnPacketTransferComplete( 
       
  1804     WlanContextImpl& aCtxImpl, 
       
  1805     TUint32 aPacketId,
       
  1806     TDataBuffer* aMetaHeader )
       
  1807     {
       
  1808     iCurrentMacState->OnPacketTransferComplete( 
       
  1809         aCtxImpl, 
       
  1810         aPacketId,
       
  1811         aMetaHeader );
       
  1812     }
       
  1813 
       
  1814 // -----------------------------------------------------------------------------
       
  1815 // 
       
  1816 // -----------------------------------------------------------------------------
       
  1817 //
       
  1818 void WlanContextImpl::OnPacketSendComplete(
       
  1819     WlanContextImpl& aCtxImpl, 
       
  1820     WHA::TStatus aStatus,
       
  1821     TUint32 aPacketId,
       
  1822     WHA::TRate aRate,
       
  1823     TUint32 aPacketQueueDelay,
       
  1824     TUint32 aMediaDelay,
       
  1825     TUint aTotalTxDelay,
       
  1826     TUint8 aAckFailures,
       
  1827     WHA::TQueueId aQueueId,
       
  1828     WHA::TRate aRequestedRate,
       
  1829     TBool aMulticastData )
       
  1830     {
       
  1831     iCurrentMacState->OnPacketSendComplete(
       
  1832         aCtxImpl,
       
  1833         aStatus,
       
  1834         aPacketId,
       
  1835         aRate,
       
  1836         aPacketQueueDelay,
       
  1837         aMediaDelay,
       
  1838         aTotalTxDelay,
       
  1839         aAckFailures,
       
  1840         aQueueId,
       
  1841         aRequestedRate,
       
  1842         aMulticastData );
       
  1843     }
       
  1844 
       
  1845 // -----------------------------------------------------------------------------
       
  1846 // 
       
  1847 // -----------------------------------------------------------------------------
       
  1848 //
       
  1849 void WlanContextImpl::CallPacketSchedule( 
       
  1850     WlanContextImpl& aCtxImpl,
       
  1851     TBool aMore )
       
  1852     {
       
  1853     iCurrentMacState->CallPacketSchedule( aCtxImpl, aMore );
       
  1854     }
       
  1855 
       
  1856 // -----------------------------------------------------------------------------
       
  1857 // 
       
  1858 // -----------------------------------------------------------------------------
       
  1859 //
       
  1860 void WlanContextImpl::OnPacketFlushEvent(
       
  1861     WlanContextImpl& aCtxImpl, 
       
  1862     TUint32 aPacketId, 
       
  1863     TDataBuffer* aMetaHeader )
       
  1864     {
       
  1865     iCurrentMacState->OnPacketFlushEvent( aCtxImpl, aPacketId, aMetaHeader );
       
  1866     }
       
  1867 
       
  1868 // -----------------------------------------------------------------------------
       
  1869 // 
       
  1870 // -----------------------------------------------------------------------------
       
  1871 //
       
  1872 void WlanContextImpl::OnPacketPushPossible( 
       
  1873     WlanContextImpl& aCtxImpl )
       
  1874     {
       
  1875     iCurrentMacState->OnPacketPushPossible( aCtxImpl );
       
  1876     }