wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/src/WlanLogicalChannel.cpp
branchRCL_3
changeset 17 a828660c511c
parent 14 13838cf40350
child 18 d3d7683d16f5
equal deleted inserted replaced
16:5fb7af913dfd 17:a828660c511c
    14 * Description:   Implementation of the DWlanLogicalChannel class.
    14 * Description:   Implementation of the DWlanLogicalChannel class.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 59.1.1 %
    19 * %version: 61 %
    20 */
    20 */
    21 
    21 
    22 #include "WlLddWlanLddConfig.h"
    22 #include "WlLddWlanLddConfig.h"
    23 #include "wlanlddcommon.h"
    23 #include "wlanlddcommon.h"
    24 #include "WlanLogicalChannel.h"
    24 #include "WlanLogicalChannel.h"
    39 
    39 
    40 // Tx memory for frames created by UMAC
    40 // Tx memory for frames created by UMAC
    41 const TUint32 KDmaTxMemSize = 4096; // equals to 1 MMU page on most systems
    41 const TUint32 KDmaTxMemSize = 4096; // equals to 1 MMU page on most systems
    42 
    42 
    43 // ---------------------------------------------------------------------------
    43 // ---------------------------------------------------------------------------
    44 // 
    44 // Note! This method is executed in the context of the user mode client 
       
    45 // thread, but in supervisor mode
    45 // ---------------------------------------------------------------------------
    46 // ---------------------------------------------------------------------------
    46 //
    47 //
    47 #ifndef RD_WLAN_DDK
    48 #ifndef RD_WLAN_DDK
    48 DWlanLogicalChannel::DWlanLogicalChannel( 
    49 DWlanLogicalChannel::DWlanLogicalChannel( 
    49     DWlanLogicalDevice& aParent, 
    50     DWlanLogicalDevice& aParent, 
   269 
   270 
   270     return ret;
   271     return ret;
   271     }
   272     }
   272 
   273 
   273 // ---------------------------------------------------------------------------
   274 // ---------------------------------------------------------------------------
       
   275 // Note! This method is executed in the context of the user mode client 
       
   276 // thread, but in supervisor mode
       
   277 //
   274 // If an error occurs in this method, we set iPdd to NULL to prevent 
   278 // If an error occurs in this method, we set iPdd to NULL to prevent 
   275 // PDD object destruction in base class (DLogicalChannelBase) destructor.
   279 // PDD object destruction in base class (DLogicalChannelBase) destructor.
   276 // DLogicalChannelBase destructor gets called as this logical channel instance
   280 // DLogicalChannelBase destructor gets called as this logical channel instance
   277 // gets destoyed when this method returns with an error.
   281 // gets destoyed when this method returns with an error.
   278 // The PDD object gets destructed elsewhere.
   282 // The PDD object gets destructed elsewhere.
   604         (("WLANLDD: DWlanLogicalChannel::HandleMsg: mutex released")));
   608         (("WLANLDD: DWlanLogicalChannel::HandleMsg: mutex released")));
   605     }
   609     }
   606     
   610     
   607 
   611 
   608 // ---------------------------------------------------------------------------
   612 // ---------------------------------------------------------------------------
   609 // 
   613 // Note! This method is executed in the context of the user mode client 
   610 // ---------------------------------------------------------------------------
   614 // thread, but in supervisor mode
   611 //
   615 // ---------------------------------------------------------------------------
   612 TAny* DWlanLogicalChannel::DoControlFast( TInt aFunction, TAny* param )
   616 //
       
   617 TAny* DWlanLogicalChannel::DoControlFast( TInt aFunction, TAny* aParam )
   613     {
   618     {
   614     TAny* ret( NULL );
   619     TAny* ret( NULL );
   615     TBool triggerTx ( EFalse );    
   620     TBool triggerTx ( EFalse );    
   616     
   621     
   617     TraceDump(WLM_CMD_DETAILS, 
   622     TraceDump(WLM_CMD_DETAILS, 
   618         (("WLANLDD: DWlanLogicalChannel::DoControlFast: current thread 0x%08x"), 
   623         (("WLANLDD: DWlanLogicalChannel::DoControlFast: current thread 0x%08x"), 
   619         &Kern::CurrentThread()));       
   624         &Kern::CurrentThread()));       
   620     TraceDump(WLM_CMD_DETAILS, (("WLANLDD: channel creator thread: 0x%08x"), 
   625     TraceDump(WLM_CMD_DETAILS, (("WLANLDD: channel creator thread: 0x%08x"), 
   621         iClient));
   626         iClient));
   622     TraceDump(WLM_CMD_DETAILS, (("WLANLDD: function: 0x%x"), aFunction));
   627     TraceDump(WLM_CMD_DETAILS, (("WLANLDD: function: 0x%x"), aFunction));
   623     
       
   624     // Note! We are executing in the context of the client's thread, but
       
   625     // in supervisor mode
       
   626     
   628     
   627     // acquire mutex
   629     // acquire mutex
   628     // Enter critical section before requesting the mutex as
   630     // Enter critical section before requesting the mutex as
   629     // we are executing in the context of a user mode thread
   631     // we are executing in the context of a user mode thread
   630     NKern::ThreadEnterCS();    
   632     NKern::ThreadEnterCS();    
   635 #endif
   637 #endif
   636     
   638     
   637     TraceDump(MUTEX, 
   639     TraceDump(MUTEX, 
   638         (("WLANLDD: DWlanLogicalChannel::DoControlFast: mutex acquired")));
   640         (("WLANLDD: DWlanLogicalChannel::DoControlFast: mutex acquired")));
   639     
   641     
       
   642     if ( iUnit == KUnitWlan )
       
   643         {
       
   644         ret = OnMgmtSideControlFast( aFunction, aParam );
       
   645         }
       
   646     else if ( iUnit == KUnitEthernet )
       
   647         {
       
   648         ret = OnEthernetSideControlFast( aFunction, aParam, triggerTx );
       
   649         }
       
   650     else
       
   651         {
       
   652         // unknown unit
       
   653 #ifndef NDEBUG            
       
   654         TraceDump(ERROR_LEVEL, 
       
   655             ("WLANLDD: DWlanLogicalChannel::DoControlFast: unknown unit"));
       
   656         TraceDump(ERROR_LEVEL, (("WLANLDD: aFunction: %d"), aFunction));
       
   657         TraceDump(ERROR_LEVEL, (("WLANLDD: unit: %d"), iUnit));
       
   658         os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ );
       
   659 #endif
       
   660         }
       
   661     
       
   662     // release mutex
       
   663 #ifndef RD_WLAN_DDK
       
   664     Kern::MutexSignal( iMutex );
       
   665 #else
       
   666     iOsa->MutexRelease();
       
   667 #endif 
       
   668     // and exit from critical section
       
   669     NKern::ThreadLeaveCS();
       
   670     
       
   671     TraceDump(MUTEX, 
       
   672         ("WLANLDD: DWlanLogicalChannel::DoControlFast: mutex released"));
       
   673 
       
   674     if ( triggerTx )
       
   675         {
       
   676         // Trigger a new Tx - via a DFC. 
       
   677         // Note that we do this outside of mutex protection, as this block of 
       
   678         // code is executed by a lower priority (user side) thread, and the 
       
   679         // DFC by a higher priority (kernel side) thread, and the latter will 
       
   680         // also need to acquire the same mutex before it can proceed. So, as 
       
   681         // the lower priority thread will get paused and the higher priority 
       
   682         // thread will get scheduled (to execute the DFC), we don't want the 
       
   683         // higher priority thread to need to wait for the mutex. So we 
       
   684         // released the mutex first in this code block and after that enqueue 
       
   685         // the DFC request.
       
   686         if ( !( iFlags & KTxTriggerArmed ) )
       
   687             {
       
   688             iFlags |= KTxTriggerArmed;
       
   689             iTxTriggerDfc.Enque();
       
   690             }
       
   691         }
       
   692     
       
   693     return ret;
       
   694     }
       
   695 
       
   696 // ---------------------------------------------------------------------------
       
   697 // Note! This method is executed in the context of the user mode client 
       
   698 // thread, but in supervisor mode
       
   699 // ---------------------------------------------------------------------------
       
   700 //
       
   701 TAny* DWlanLogicalChannel::OnMgmtSideControlFast( 
       
   702     TInt aFunction, 
       
   703     TAny* aParam )
       
   704     {
       
   705     TAny* ret( NULL );
       
   706     
   640     switch ( aFunction )
   707     switch ( aFunction )
   641         {
   708         {
       
   709         // ==========================================================
       
   710         // Get Rx frame
       
   711         // ==========================================================        
       
   712         case RWlanLogicalChannel::EWlanControlFastGetRxFrame:
       
   713             if ( iEthernetFrameMemMngr )
       
   714                 {
       
   715                 ret = iEthernetFrameMemMngr->GetRxFrame( 
       
   716                         reinterpret_cast<TDataBuffer*>(aParam) );
       
   717                 }
       
   718             break;
       
   719         // ==========================================================
       
   720         // Unknown request
       
   721         // ==========================================================        
       
   722         default:
       
   723 #ifndef NDEBUG
       
   724             TraceDump(ERROR_LEVEL, (("WLANLDD: unknown request: %d"), 
       
   725                 aFunction));
       
   726             os_assert( 
       
   727                 (TUint8*)("WLANLDD: panic"), 
       
   728                 (TUint8*)(WLAN_FILE), 
       
   729                 __LINE__ );
       
   730 #endif
       
   731             break;
       
   732         }
       
   733     
       
   734     return ret;
       
   735     }
       
   736 
       
   737 // ---------------------------------------------------------------------------
       
   738 // Note! This method is executed in the context of the user mode client 
       
   739 // thread, but in supervisor mode
       
   740 // ---------------------------------------------------------------------------
       
   741 //
       
   742 TAny* DWlanLogicalChannel::OnEthernetSideControlFast( 
       
   743     TInt aFunction, 
       
   744     TAny* aParam,
       
   745     TBool& aTriggerTx )
       
   746     {
       
   747     TAny* ret( NULL );    
       
   748     aTriggerTx = EFalse;
       
   749     
       
   750     switch ( aFunction )
       
   751         {
       
   752         // ==========================================================
       
   753         // Alloc Tx buffer
       
   754         // ==========================================================        
   642         case RPcmNetCardIf::EControlFastAllocTxBuffer:
   755         case RPcmNetCardIf::EControlFastAllocTxBuffer:
   643             ret = iEthernetFrameMemMngr->AllocTxBuffer(
   756             if ( iEthernetFrameMemMngr )
   644                 reinterpret_cast<TUint>(param) );
   757                 {
       
   758                 ret = iEthernetFrameMemMngr->AllocTxBuffer(
       
   759                     reinterpret_cast<TUint>(aParam) );
       
   760                 }
   645             
   761             
   646             if ( !ret && iAddTxFrameAllowed )
   762             if ( !ret && iAddTxFrameAllowed )
   647                 {
   763                 {
   648                 iAddTxFrameAllowed = EFalse;
   764                 iAddTxFrameAllowed = EFalse;
   649                 
   765                 
   650                 TraceDump( NWSA_TX, 
   766                 TraceDump( NWSA_TX, 
   651                     ("WLANLDD: DWlanLogicalChannel::DoControlFast: stop flow from protocol stack") );        
   767                     ("WLANLDD: DWlanLogicalChannel::OnEthernetSideControlFast: "
       
   768                      "stop flow from protocol stack") );        
   652                 }
   769                 }
   653             break;
   770             break;            
   654             
   771         // ==========================================================
       
   772         // Add Tx frame
       
   773         // ==========================================================        
   655         case RPcmNetCardIf::EControlFastAddTxFrame:
   774         case RPcmNetCardIf::EControlFastAddTxFrame:
   656             {
   775             {
   657 #ifndef NDEBUG
   776 #ifndef NDEBUG
   658             if ( !iAddTxFrameAllowed )
   777             if ( !iAddTxFrameAllowed )
   659                 {
   778                 {
   660                 TraceDump(ERROR_LEVEL, 
   779                 TraceDump(ERROR_LEVEL, 
   661                     ("WLANLDD: DWlanLogicalChannel::DoControlFast: WARNING: AddTxFrame req. when flow ctrl is on"));
   780                     ("WLANLDD: DWlanLogicalChannel::OnEthernetSideControlFast: "
       
   781                      "WARNING: AddTxFrame req. when flow ctrl is on"));
   662                 }
   782                 }
   663 #endif
   783 #endif
   664             if ( iEthernetFrameMemMngr->AllTxQueuesEmpty() )
   784             if ( iEthernetFrameMemMngr && aParam )
   665                 {
   785                 {
   666                 triggerTx = ETrue;
   786                 if ( iEthernetFrameMemMngr->AllTxQueuesEmpty() )
   667                 }
   787                     {
   668             
   788                     aTriggerTx = ETrue;
   669             TDataBuffer* discardFrame ( NULL );
   789                     }
   670             
       
   671             ret = reinterpret_cast<TAny*>(iEthernetFrameMemMngr->AddTxFrame( 
       
   672                 reinterpret_cast<TDataBuffer*>(param),
       
   673                 discardFrame,
       
   674                 iUmac.UserDataTxEnabled() ));
       
   675             
       
   676             if ( discardFrame )
       
   677                 {
       
   678                 TraceDump( NWSA_TX_DETAILS, 
       
   679                     (("WLANLDD: DWlanLogicalChannel::DoControlFast: have to drop tx frame of UP: %d"),
       
   680                     reinterpret_cast<TDataBuffer*>(param)->UserPriority()) );
       
   681                 
   790                 
   682                 iEthernetFrameMemMngr->FreeTxPacket( discardFrame );
   791                 TDataBuffer* discardFrame ( NULL );
       
   792                 
       
   793                 ret = reinterpret_cast<TAny*>(
       
   794                           iEthernetFrameMemMngr->AddTxFrame( 
       
   795                               reinterpret_cast<TDataBuffer*>(aParam),
       
   796                               discardFrame,
       
   797                               iUmac.UserDataTxEnabled() ));
       
   798                 
       
   799                 if ( discardFrame )
       
   800                     {
       
   801                     TraceDump( NWSA_TX_DETAILS, 
       
   802                         (("WLANLDD: DWlanLogicalChannel::OnEthernetSideControlFast: "
       
   803                           "have to drop tx frame of UP: %d"),
       
   804                         reinterpret_cast<TDataBuffer*>(
       
   805                             aParam)->UserPriority()) );
       
   806                     
       
   807                     iEthernetFrameMemMngr->FreeTxPacket( discardFrame );
       
   808                     aTriggerTx = EFalse;
       
   809                     }
   683                 }
   810                 }
   684                 
   811                 
   685             if ( !ret )
   812             if ( !ret )
   686                 {
   813                 {
   687                 iAddTxFrameAllowed = EFalse;
   814                 iAddTxFrameAllowed = EFalse;
   688 
   815 
   689                 TraceDump( NWSA_TX, 
   816                 TraceDump( NWSA_TX, 
   690                     ("WLANLDD: DWlanLogicalChannel::DoControlFast: stop flow from protocol stack") );        
   817                     ("WLANLDD: DWlanLogicalChannel::OnEthernetSideControlFast: "
       
   818                      "stop flow from protocol stack") );
   691                 }
   819                 }
   692             break;
   820             break;
   693             }
   821             }            
       
   822         // ==========================================================
       
   823         // Get Rx frame
       
   824         // ==========================================================        
       
   825         case RPcmNetCardIf::EControlFastGetRxFrame:
       
   826             {
       
   827             if ( iEthernetFrameMemMngr )
       
   828                 {
       
   829                 ret = iEthernetFrameMemMngr->GetRxFrame( 
       
   830                         reinterpret_cast<TDataBuffer*>(aParam) );
       
   831                 }
       
   832             }
       
   833             break;
       
   834         // ==========================================================
       
   835         // Unknown request
       
   836         // ==========================================================        
   694         default:
   837         default:
   695 #ifndef NDEBUG
   838 #ifndef NDEBUG
   696             TraceDump(ERROR_LEVEL, (("WLANLDD: unknown request: %d"), 
   839             TraceDump(ERROR_LEVEL, (("WLANLDD: unknown request: %d"), 
   697                 aFunction));
   840                 aFunction));
   698             os_assert( 
   841             os_assert( 
   699                 (TUint8*)("WLANLDD: panic"), 
   842                 (TUint8*)("WLANLDD: panic"), 
   700                 (TUint8*)(WLAN_FILE), 
   843                 (TUint8*)(WLAN_FILE), 
   701                 __LINE__ );            
   844                 __LINE__ );            
   702 #endif
   845 #endif
   703             break;
   846             break;
   704         }
   847         } // switch
   705     
       
   706     // release mutex
       
   707 #ifndef RD_WLAN_DDK
       
   708     Kern::MutexSignal( iMutex );
       
   709 #else
       
   710     iOsa->MutexRelease();
       
   711 #endif 
       
   712     // and exit from critical section
       
   713     NKern::ThreadLeaveCS();
       
   714     
       
   715     TraceDump(MUTEX, 
       
   716         ("WLANLDD: DWlanLogicalChannel::DoControlFast: mutex released"));
       
   717 
       
   718     if ( triggerTx )
       
   719         {
       
   720         // Trigger a new Tx - via a DFC. 
       
   721         // Note that we do this outside of mutex protection, as this block of 
       
   722         // code is executed by a lower priority (user side) thread, and the 
       
   723         // DFC by a higher priority (kernel side) thread, and the latter will 
       
   724         // also need to acquire the same mutex before it can proceed. So, as 
       
   725         // the lower priority thread will get paused and the higher priority 
       
   726         // thread will get scheduled (to execute the DFC), we don't want the 
       
   727         // higher priority thread to need to wait for the mutex. So we 
       
   728         // released the mutex first in this code block and after that enque 
       
   729         // the DFC request.
       
   730         if ( !( iFlags & KTxTriggerArmed ) )
       
   731             {
       
   732             iFlags |= KTxTriggerArmed;
       
   733             iTxTriggerDfc.Enque();
       
   734             }
       
   735         }
       
   736     
   848     
   737     return ret;
   849     return ret;
   738     }
   850     }
   739 
   851 
   740 // ---------------------------------------------------------------------------
   852 // ---------------------------------------------------------------------------
   743 //
   855 //
   744 void DWlanLogicalChannel::DoCancel( TInt aMask )
   856 void DWlanLogicalChannel::DoCancel( TInt aMask )
   745     {
   857     {
   746     if ( iUnit == KUnitWlan )
   858     if ( iUnit == KUnitWlan )
   747         {
   859         {
   748         if ( aMask & ( 1 << EWlanRequestNotify ) )
   860         if ( aMask & ( 1 << RWlanLogicalChannel::EWlanRequestNotify ) )
   749             {
   861             {
   750             TraceDump(INFO_LEVEL, 
   862             TraceDump(INFO_LEVEL, 
   751                 ("WLANLDD: DWlanLogicalChannel::DoCancel: mgmt side notify cancel"));
   863                 ("WLANLDD: DWlanLogicalChannel::DoCancel: mgmt side notify cancel"));
   752 
   864 
   753             CancelIndicationRequest();
   865             CancelIndicationRequest();
   754             Kern::RequestComplete( 
   866             Kern::RequestComplete( 
   755                 iClient, iWlanRequestNotifyStatus, KErrServerTerminated );
   867                 iClient, iWlanRequestNotifyStatus, KErrServerTerminated );
   756             iWlanRequestNotifyStatus = NULL;
   868             iWlanRequestNotifyStatus = NULL;
   757             }        
   869             }        
   758         else if ( aMask & ( 1 << EWlanRequestFrame ) )
   870         else if ( aMask & ( 1 << RWlanLogicalChannel::EWlanRequestFrame ) )
   759             {
   871             {
   760             TraceDump(INFO_LEVEL, 
   872             TraceDump(INFO_LEVEL, 
   761                 ("WLANLDD: DWlanLogicalChannel::DoCancel: mgmt side frame read cancel"));
   873                 ("WLANLDD: DWlanLogicalChannel::DoCancel: mgmt side frame read cancel"));
   762 
   874 
   763             Kern::RequestComplete( 
   875             Kern::RequestComplete( 
   765             iWlanReceiveFrameStatus = NULL;
   877             iWlanReceiveFrameStatus = NULL;
   766             }
   878             }
   767         else
   879         else
   768             {
   880             {
   769             TraceDump(ERROR_LEVEL, 
   881             TraceDump(ERROR_LEVEL, 
   770                 (("WLANLDD: DWlanLogicalChannel::DoCancel: mgmt side unhandled mask panic: 0x%08x"), 
   882                 (("WLANLDD: DWlanLogicalChannel::DoCancel: mgmt side "
       
   883                   "unhandled mask panic: 0x%08x"), 
   771                 aMask));
   884                 aMask));
   772             os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ );
   885             os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ );
   773             }        
   886             }        
   774         }
   887         }
   775     else if ( iUnit == KUnitEthernet )
   888     else if ( iUnit == KUnitEthernet )
   793             iEthernetReceiveFrameStatus = NULL;
   906             iEthernetReceiveFrameStatus = NULL;
   794             }
   907             }
   795         else
   908         else
   796             {
   909             {
   797             TraceDump(ERROR_LEVEL, 
   910             TraceDump(ERROR_LEVEL, 
   798                 (("WLANLDD: DWlanLogicalChannel::DoCancel: user side unhandled mask panic: 0x%08x"), 
   911                 (("WLANLDD: DWlanLogicalChannel::DoCancel: user side "
       
   912                   "unhandled mask panic: 0x%08x"), 
   799                 aMask));
   913                 aMask));
   800             os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ );
   914             os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ );
   801             }        
   915             }        
   802         }
   916         }
   803     else
   917     else
   811 // ---------------------------------------------------------------------------
   925 // ---------------------------------------------------------------------------
   812 // 
   926 // 
   813 // ---------------------------------------------------------------------------
   927 // ---------------------------------------------------------------------------
   814 //
   928 //
   815 TBool DWlanLogicalChannel::ProtocolStackDataReceiveComplete( 
   929 TBool DWlanLogicalChannel::ProtocolStackDataReceiveComplete( 
   816     const TDataBuffer*& aBufferStart,
   930     TDataBuffer*& aBufferStart,
   817     TUint32 aNumOfBuffers )
   931     TUint32 aNumOfBuffers )
   818     {
   932     {
   819     if ( iEthernetFrameMemMngr->OnEthernetFrameRxComplete( aBufferStart, 
   933     if ( iEthernetFrameMemMngr && 
   820         aNumOfBuffers ) )
   934          iEthernetFrameMemMngr->OnEthernetFrameRxComplete( 
       
   935              aBufferStart, 
       
   936              aNumOfBuffers ) )
   821         {
   937         {
   822         Kern::RequestComplete( iClient, iEthernetReceiveFrameStatus, KErrNone );
   938         Kern::RequestComplete( iClient, iEthernetReceiveFrameStatus, KErrNone );
   823         iEthernetReceiveFrameStatus = NULL;
   939         iEthernetReceiveFrameStatus = NULL;
   824         }
   940         }
   825         
   941         
   898     TraceDump(UMAC_PROTO_CALLBACK, 
  1014     TraceDump(UMAC_PROTO_CALLBACK, 
   899         ("WLANLDD: DWlanLogicalChannel::OnTxProtocolStackDataComplete"));
  1015         ("WLANLDD: DWlanLogicalChannel::OnTxProtocolStackDataComplete"));
   900     TraceDump(UMAC_PROTO_CALLBACK, 
  1016     TraceDump(UMAC_PROTO_CALLBACK, 
   901         (("WLANLDD: aCompletionCode: %d"), aCompletionCode));
  1017         (("WLANLDD: aCompletionCode: %d"), aCompletionCode));
   902 
  1018 
   903     iEthernetFrameMemMngr->FreeTxPacket( aMetaHeader );
  1019     if ( iEthernetFrameMemMngr )
       
  1020         {
       
  1021         iEthernetFrameMemMngr->FreeTxPacket( aMetaHeader );
       
  1022         }
   904 
  1023 
   905     TxProtocolStackData();
  1024     TxProtocolStackData();
   906     
  1025     
   907     if ( !iAddTxFrameAllowed )
  1026     if ( !iAddTxFrameAllowed )
   908         {
  1027         {
   909         if ( iResumeTxStatus && 
  1028         if ( iResumeTxStatus &&
       
  1029              iEthernetFrameMemMngr &&
   910              iEthernetFrameMemMngr->ResumeClientTx( 
  1030              iEthernetFrameMemMngr->ResumeClientTx( 
   911                  iUmac.UserDataTxEnabled() ) )
  1031                  iUmac.UserDataTxEnabled() ) )
   912             {
  1032             {
   913             // resume Tx flow from protocol stack
  1033             // resume Tx flow from protocol stack
   914             
  1034             
   975 // 
  1095 // 
   976 // ---------------------------------------------------------------------------
  1096 // ---------------------------------------------------------------------------
   977 //
  1097 //
   978 void DWlanLogicalChannel::TxManagementData()
  1098 void DWlanLogicalChannel::TxManagementData()
   979     {
  1099     {
   980     TDataBuffer* buffer = iEthernetFrameMemMngr->OnWriteEthernetFrame();
  1100     TDataBuffer* buffer( NULL );
   981 
  1101     
   982     if ( !buffer )
  1102     if ( iEthernetFrameMemMngr )
   983         {
  1103         {
   984         TraceDump(ERROR_LEVEL, 
  1104         buffer = iEthernetFrameMemMngr->OnWriteEthernetFrame();
   985             ("WLANLDD: DWlanLogicalChannel::TxManagementData: "
  1105         }
   986              "panic, no buffer"));
  1106 
       
  1107     if ( buffer )
       
  1108         {
       
  1109         iUmac.WriteMgmtFrame( *buffer );
       
  1110         }
       
  1111     else
       
  1112         {
       
  1113 #ifndef NDEBUG
   987         os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ );
  1114         os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ );
   988         }
  1115 #endif
   989     else
  1116         Kern::RequestComplete( 
   990         {
  1117             iClient, iWlanSendFrameStatus, KErrGeneral );
   991         iUmac.WriteMgmtFrame( *buffer );
       
   992         }
  1118         }
   993     }
  1119     }
   994 
  1120 
   995 // ---------------------------------------------------------------------------
  1121 // ---------------------------------------------------------------------------
   996 // 
  1122 // 
   997 // ---------------------------------------------------------------------------
  1123 // ---------------------------------------------------------------------------
   998 //
  1124 //
   999 void DWlanLogicalChannel::TxProtocolStackData()
  1125 void DWlanLogicalChannel::TxProtocolStackData()
  1000     {
  1126     {
  1001 #ifndef NDEBUG    
  1127 #ifndef NDEBUG
  1002     TUint packetsSubmitted ( 0 );
  1128     TUint packetsSubmitted ( 0 );
  1003 #endif
  1129 #endif
  1004     
  1130     
  1005     if ( !iTxActive )
  1131     if ( !iTxActive )
  1006         {
  1132         {
  1044 // 
  1170 // 
  1045 // ---------------------------------------------------------------------------
  1171 // ---------------------------------------------------------------------------
  1046 //
  1172 //
  1047 TBool DWlanLogicalChannel::OnReadEthernetFrameRequest()
  1173 TBool DWlanLogicalChannel::OnReadEthernetFrameRequest()
  1048     {
  1174     {
  1049     const TBool ret = iEthernetFrameMemMngr->OnReadRequest();
  1175     TBool ret( EFalse );
       
  1176     
       
  1177     if ( iEthernetFrameMemMngr )
       
  1178         {
       
  1179         ret = iEthernetFrameMemMngr->OnReadRequest();
       
  1180         }
       
  1181     
  1050     return ret;
  1182     return ret;
  1051     }
  1183     }
  1052 
  1184 
  1053 // ---------------------------------------------------------------------------
  1185 // ---------------------------------------------------------------------------
  1054 // 
  1186 // 
  1446             }
  1578             }
  1447         }
  1579         }
  1448 
  1580 
  1449     switch ( aReqNo )
  1581     switch ( aReqNo )
  1450         {
  1582         {
  1451         case EWlanInitSystem:
  1583         case RWlanLogicalChannel::EWlanInitSystem:
  1452             // bootup the chip and the system
  1584             // bootup the chip and the system
  1453             iWlanGeneralRequestStatus = aStatus; 
  1585             iWlanGeneralRequestStatus = aStatus; 
  1454             InitSystem( a1, sizeof(TOpenParam) );
  1586             InitSystem( a1, sizeof(TOpenParam) );
  1455             break;
  1587             break;
  1456         case EWlanFinitSystem:
  1588         case RWlanLogicalChannel::EWlanFinitSystem:
  1457             // power down the chip and the system
  1589             // power down the chip and the system
  1458             iWlanGeneralRequestStatus = aStatus; 
  1590             iWlanGeneralRequestStatus = aStatus; 
  1459             FinitSystem();
  1591             FinitSystem();
  1460             break;
  1592             break;
  1461         case EWlanCommand:
  1593         case RWlanLogicalChannel::EWlanCommand:
  1462             // management command
  1594             // management command
  1463             iWlanGeneralRequestStatus = aStatus; 
  1595             iWlanGeneralRequestStatus = aStatus; 
  1464 
  1596 
  1465             // read the USER mode parameters to internal storage
  1597             // read the USER mode parameters to internal storage
  1466             ret = Kern::ThreadRawRead( 
  1598             ret = Kern::ThreadRawRead( 
  1497                 // because it is not accessed by UMAC and the 
  1629                 // because it is not accessed by UMAC and the 
  1498                 // actual user mode writing is done by OnOidCompleted method
  1630                 // actual user mode writing is done by OnOidCompleted method
  1499                 output_buffer.iData, 
  1631                 output_buffer.iData, 
  1500                 output_buffer.iLen );
  1632                 output_buffer.iLen );
  1501             break;
  1633             break;
  1502         case EWlanRequestNotify:
  1634         case RWlanLogicalChannel::EWlanRequestNotify:
  1503             // store the USER mode indication address;
  1635             // store the USER mode indication address;
  1504             iIndicationBuffer = static_cast<TIndication*>(a1);
  1636             iIndicationBuffer = static_cast<TIndication*>(a1);
  1505             iWlanRequestNotifyStatus = aStatus;
  1637             iWlanRequestNotifyStatus = aStatus;
  1506             IndicationRequest( static_cast<TIndication*>(a1) );
  1638             IndicationRequest( static_cast<TIndication*>(a1) );
  1507             break;
  1639             break;
  1508         case EWlanRequestFrame:
  1640         case RWlanLogicalChannel::EWlanRequestFrame:
  1509             if ( OnReadEthernetFrameRequest() )
  1641             if ( OnReadEthernetFrameRequest() )
  1510                 {
  1642                 {
  1511                 // rx data to be completed exists
  1643                 // rx data to be completed exists
  1512                 // complete it directly
  1644                 // complete it directly
  1513                 Kern::RequestComplete( 
  1645                 Kern::RequestComplete( 
  1520                 // no rx data for completion exists
  1652                 // no rx data for completion exists
  1521                 // store the pending request
  1653                 // store the pending request
  1522                 iWlanReceiveFrameStatus = aStatus;
  1654                 iWlanReceiveFrameStatus = aStatus;
  1523                 }
  1655                 }
  1524             break;
  1656             break;
  1525         case EWlanRequestSend:
  1657         case RWlanLogicalChannel::EWlanRequestSend:
  1526             iWlanSendFrameStatus = aStatus;
  1658             iWlanSendFrameStatus = aStatus;
  1527 
  1659 
  1528             TxManagementData();
  1660             TxManagementData();
  1529             break;
  1661             break;
  1530         default:
  1662         default:
  1723     TInt aFunction, 
  1855     TInt aFunction, 
  1724     TAny* a1, 
  1856     TAny* a1, 
  1725     TAny* /*a2*/ )
  1857     TAny* /*a2*/ )
  1726     {
  1858     {
  1727     TInt ret( KErrNone );
  1859     TInt ret( KErrNone );
  1728     if ( aFunction == EWlanSvControlInitBuffers )
  1860     if ( aFunction == RWlanLogicalChannel::EWlanSvControlInitBuffers )
  1729         {
  1861         {
  1730         // initiliaze buffers for wlan mgmt client data xfer
  1862         // initiliaze buffers for wlan mgmt client data xfer
  1731         if ( a1 )
  1863         if ( a1 )
  1732             {
  1864             {
  1733             TraceDump(INIT_LEVEL, 
  1865             TraceDump(INIT_LEVEL, 
  1744             TraceDump(ERROR_LEVEL, 
  1876             TraceDump(ERROR_LEVEL, 
  1745                 ("WLANLDD: DWlanLogicalChannel::OnMgmtSideControl(): init management client buffer pool panic"));
  1877                 ("WLANLDD: DWlanLogicalChannel::OnMgmtSideControl(): init management client buffer pool panic"));
  1746             os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ );
  1878             os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ );
  1747             }
  1879             }
  1748         }
  1880         }
  1749     else if ( aFunction == EWlanSvControlFreeBuffers )
  1881     else if ( aFunction == RWlanLogicalChannel::EWlanSvControlFreeBuffers )
  1750         {
  1882         {
  1751         // free wlan mgmt client data xfer buffers
  1883         // free wlan mgmt client data xfer buffers
  1752         OnReleaseEthernetFrameBuffers();        
  1884         OnReleaseEthernetFrameBuffers();        
  1753         }
  1885         }
  1754     else
  1886     else
  1886     TUint32 aSnapFrameTxOffset )
  2018     TUint32 aSnapFrameTxOffset )
  1887     {
  2019     {
  1888     if ( iEthernetFrameMemMngr )
  2020     if ( iEthernetFrameMemMngr )
  1889         {
  2021         {
  1890         TraceDump(NWSA_TX_DETAILS, 
  2022         TraceDump(NWSA_TX_DETAILS, 
  1891             (("WLANLDD: DWlanLogicalChannel::SetMgmtSideTxOffsets: aEthernetFrameTxOffset: %d"),
  2023             (("WLANLDD: DWlanLogicalChannel::SetMgmtSideTxOffsets: "
       
  2024               "aEthernetFrameTxOffset: %d"),
  1892             aEthernetFrameTxOffset ));
  2025             aEthernetFrameTxOffset ));
  1893         TraceDump(NWSA_TX_DETAILS, 
  2026         TraceDump(NWSA_TX_DETAILS, 
  1894             (("WLANLDD: DWlanLogicalChannel::SetMgmtSideTxOffsets: aDot11FrameTxOffset: %d"),
  2027             (("WLANLDD: DWlanLogicalChannel::SetMgmtSideTxOffsets: "
       
  2028               "aDot11FrameTxOffset: %d"),
  1895             aDot11FrameTxOffset ));
  2029             aDot11FrameTxOffset ));
  1896         TraceDump(NWSA_TX_DETAILS, 
  2030         TraceDump(NWSA_TX_DETAILS, 
  1897             (("WLANLDD: DWlanLogicalChannel::SetMgmtSideTxOffsets: aSnapFrameTxOffset: %d"),
  2031             (("WLANLDD: DWlanLogicalChannel::SetMgmtSideTxOffsets: "
       
  2032               "aSnapFrameTxOffset: %d"),
  1898             aSnapFrameTxOffset ));
  2033             aSnapFrameTxOffset ));
  1899 
  2034 
  1900         iEthernetFrameMemMngr->SetTxOffsets( 
  2035         iEthernetFrameMemMngr->SetTxOffsets( 
  1901             aEthernetFrameTxOffset, 
  2036             aEthernetFrameTxOffset, 
  1902             aDot11FrameTxOffset,
  2037             aDot11FrameTxOffset,
  1929 // ---------------------------------------------------------------------------
  2064 // ---------------------------------------------------------------------------
  1930 // 
  2065 // 
  1931 // ---------------------------------------------------------------------------
  2066 // ---------------------------------------------------------------------------
  1932 //
  2067 //
  1933 void DWlanLogicalChannel::MgmtDataReceiveComplete( 
  2068 void DWlanLogicalChannel::MgmtDataReceiveComplete( 
  1934     const TDataBuffer*& aBufferStart, 
  2069     TDataBuffer*& aBufferStart, 
  1935     TUint32 aNumOfBuffers )
  2070     TUint32 aNumOfBuffers )
  1936     {
  2071     {
  1937     if ( iEthernetFrameMemMngr->OnEthernetFrameRxComplete( 
  2072     if ( iEthernetFrameMemMngr && 
  1938         aBufferStart, 
  2073          ( iEthernetFrameMemMngr->OnEthernetFrameRxComplete( 
  1939         aNumOfBuffers ) )
  2074                aBufferStart, 
       
  2075                aNumOfBuffers ) ) )
  1940         {
  2076         {
  1941         Kern::RequestComplete( iClient, iWlanReceiveFrameStatus, KErrNone );
  2077         Kern::RequestComplete( iClient, iWlanReceiveFrameStatus, KErrNone );
  1942         iWlanReceiveFrameStatus = NULL;
  2078         iWlanReceiveFrameStatus = NULL;
  1943         }
  2079         }
  1944     }
  2080     }
  2169 // ---------------------------------------------------------------------------
  2305 // ---------------------------------------------------------------------------
  2170 //
  2306 //
  2171 void DWlanLogicalChannel::ReleaseIndicationListEntry(
  2307 void DWlanLogicalChannel::ReleaseIndicationListEntry(
  2172     TIndicationListEntry* aEntry )
  2308     TIndicationListEntry* aEntry )
  2173     {
  2309     {
  2174     aEntry->next = NULL;
  2310     if ( aEntry )
  2175 
  2311         {
  2176     if ( !iFreeIndicationListHead )
  2312         aEntry->next = NULL;
  2177         {
  2313     
  2178         iFreeIndicationListHead = aEntry;
  2314         if ( !iFreeIndicationListHead )
  2179         }
  2315             {
       
  2316             iFreeIndicationListHead = aEntry;
       
  2317             }
       
  2318         else
       
  2319             {
       
  2320             TIndicationListEntry* tmp = iFreeIndicationListHead;
       
  2321     
       
  2322             while ( tmp->next )
       
  2323                 {
       
  2324                 tmp = tmp->next;
       
  2325                 }
       
  2326     
       
  2327             tmp->next = aEntry;
       
  2328             }
       
  2329         }
       
  2330 #ifndef NDEBUG
  2180     else
  2331     else
  2181         {
  2332         {
  2182         TIndicationListEntry* tmp = iFreeIndicationListHead;
  2333         os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ );        
  2183 
  2334         }
  2184         while ( tmp->next )
  2335 #endif        
  2185             {
       
  2186             tmp = tmp->next;
       
  2187             }
       
  2188 
       
  2189         tmp->next = aEntry;
       
  2190         }
       
  2191     }
  2336     }
  2192 
  2337 
  2193 // ---------------------------------------------------------------------------
  2338 // ---------------------------------------------------------------------------
  2194 // 
  2339 // 
  2195 // ---------------------------------------------------------------------------
  2340 // ---------------------------------------------------------------------------