wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/src/WlanLogicalChannel.cpp
changeset 22 c6a1762761b8
parent 17 41a8eba36f74
child 35 5e6ba967244f
equal deleted inserted replaced
19:629e60dfa279 22:c6a1762761b8
    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 %
    19 * %version: 60 %
    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();    
   636     NKern::ThreadLeaveCS();
   638     NKern::ThreadLeaveCS();
   637     
   639     
   638     TraceDump(MUTEX, 
   640     TraceDump(MUTEX, 
   639         (("WLANLDD: DWlanLogicalChannel::DoControlFast: mutex acquired")));
   641         (("WLANLDD: DWlanLogicalChannel::DoControlFast: mutex acquired")));
   640     
   642     
   641     switch ( aFunction )
   643     if ( iUnit == KUnitWlan )
   642         {
   644         {
   643         case RPcmNetCardIf::EControlFastAllocTxBuffer:
   645         ret = OnMgmtSideControlFast( aFunction, aParam );
   644             ret = iEthernetFrameMemMngr->AllocTxBuffer(
   646         }
   645                 reinterpret_cast<TUint>(param) );
   647     else if ( iUnit == KUnitEthernet )
   646             
   648         {
   647             if ( !ret && iAddTxFrameAllowed )
   649         ret = OnEthernetSideControlFast( aFunction, aParam, triggerTx );
   648                 {
   650         }
   649                 iAddTxFrameAllowed = EFalse;
   651     else
   650                 
   652         {
   651                 TraceDump( NWSA_TX, 
   653         // unknown unit
   652                     ("WLANLDD: DWlanLogicalChannel::DoControlFast: stop flow from protocol stack") );        
   654 #ifndef NDEBUG            
   653                 }
   655         TraceDump(ERROR_LEVEL, 
   654             break;
   656             ("WLANLDD: DWlanLogicalChannel::DoControlFast: unknown unit"));
   655             
   657         TraceDump(ERROR_LEVEL, (("WLANLDD: aFunction: %d"), aFunction));
   656         case RPcmNetCardIf::EControlFastAddTxFrame:
   658         TraceDump(ERROR_LEVEL, (("WLANLDD: unit: %d"), iUnit));
   657             {
   659         os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ );
   658 #ifndef NDEBUG
       
   659             if ( !iAddTxFrameAllowed )
       
   660                 {
       
   661                 TraceDump(ERROR_LEVEL, 
       
   662                     ("WLANLDD: DWlanLogicalChannel::DoControlFast: WARNING: AddTxFrame req. when flow ctrl is on"));
       
   663                 }
       
   664 #endif
   660 #endif
   665             if ( iEthernetFrameMemMngr->AllTxQueuesEmpty() )
       
   666                 {
       
   667                 triggerTx = ETrue;
       
   668                 }
       
   669             
       
   670             TDataBuffer* discardFrame ( NULL );
       
   671             
       
   672             ret = reinterpret_cast<TAny*>(iEthernetFrameMemMngr->AddTxFrame( 
       
   673                 reinterpret_cast<TDataBuffer*>(param),
       
   674                 discardFrame,
       
   675                 iUmac.UserDataTxEnabled() ));
       
   676             
       
   677             if ( discardFrame )
       
   678                 {
       
   679                 TraceDump( NWSA_TX_DETAILS, 
       
   680                     (("WLANLDD: DWlanLogicalChannel::DoControlFast: have to drop tx frame of UP: %d"),
       
   681                     reinterpret_cast<TDataBuffer*>(param)->UserPriority()) );
       
   682                 
       
   683                 iEthernetFrameMemMngr->FreeTxPacket( discardFrame );
       
   684                 }
       
   685                 
       
   686             if ( !ret )
       
   687                 {
       
   688                 iAddTxFrameAllowed = EFalse;
       
   689 
       
   690                 TraceDump( NWSA_TX, 
       
   691                     ("WLANLDD: DWlanLogicalChannel::DoControlFast: stop flow from protocol stack") );        
       
   692                 }
       
   693             break;
       
   694             }
       
   695         default:
       
   696 #ifndef NDEBUG
       
   697             TraceDump(ERROR_LEVEL, (("WLANLDD: unknown request: %d"), 
       
   698                 aFunction));
       
   699             os_assert( 
       
   700                 (TUint8*)("WLANLDD: panic"), 
       
   701                 (TUint8*)(WLAN_FILE), 
       
   702                 __LINE__ );            
       
   703 #endif
       
   704             break;
       
   705         }
   661         }
   706     
   662     
   707     // release mutex
   663     // release mutex
   708     // Enter critical section before releasing the mutex as
   664     // Enter critical section before releasing the mutex as
   709     // we are executing in the context of a user mode thread
   665     // we are executing in the context of a user mode thread
   726         // DFC by a higher priority (kernel side) thread, and the latter will 
   682         // DFC by a higher priority (kernel side) thread, and the latter will 
   727         // also need to acquire the same mutex before it can proceed. So, as 
   683         // also need to acquire the same mutex before it can proceed. So, as 
   728         // the lower priority thread will get paused and the higher priority 
   684         // the lower priority thread will get paused and the higher priority 
   729         // thread will get scheduled (to execute the DFC), we don't want the 
   685         // thread will get scheduled (to execute the DFC), we don't want the 
   730         // higher priority thread to need to wait for the mutex. So we 
   686         // higher priority thread to need to wait for the mutex. So we 
   731         // released the mutex first in this code block and after that enque 
   687         // released the mutex first in this code block and after that enqueue 
   732         // the DFC request.
   688         // the DFC request.
   733         if ( !( iFlags & KTxTriggerArmed ) )
   689         if ( !( iFlags & KTxTriggerArmed ) )
   734             {
   690             {
   735             iFlags |= KTxTriggerArmed;
   691             iFlags |= KTxTriggerArmed;
   736             iTxTriggerDfc.Enque();
   692             iTxTriggerDfc.Enque();
   739     
   695     
   740     return ret;
   696     return ret;
   741     }
   697     }
   742 
   698 
   743 // ---------------------------------------------------------------------------
   699 // ---------------------------------------------------------------------------
       
   700 // Note! This method is executed in the context of the user mode client 
       
   701 // thread, but in supervisor mode
       
   702 // ---------------------------------------------------------------------------
       
   703 //
       
   704 TAny* DWlanLogicalChannel::OnMgmtSideControlFast( 
       
   705     TInt aFunction, 
       
   706     TAny* aParam )
       
   707     {
       
   708     TAny* ret( NULL );
       
   709     
       
   710     switch ( aFunction )
       
   711         {
       
   712         // ==========================================================
       
   713         // Get Rx frame
       
   714         // ==========================================================        
       
   715         case RWlanLogicalChannel::EWlanControlFastGetRxFrame:
       
   716             if ( iEthernetFrameMemMngr )
       
   717                 {
       
   718                 ret = iEthernetFrameMemMngr->GetRxFrame( 
       
   719                         reinterpret_cast<TDataBuffer*>(aParam) );
       
   720                 }
       
   721             break;
       
   722         // ==========================================================
       
   723         // Unknown request
       
   724         // ==========================================================        
       
   725         default:
       
   726 #ifndef NDEBUG
       
   727             TraceDump(ERROR_LEVEL, (("WLANLDD: unknown request: %d"), 
       
   728                 aFunction));
       
   729             os_assert( 
       
   730                 (TUint8*)("WLANLDD: panic"), 
       
   731                 (TUint8*)(WLAN_FILE), 
       
   732                 __LINE__ );
       
   733 #endif
       
   734             break;
       
   735         }
       
   736     
       
   737     return ret;
       
   738     }
       
   739 
       
   740 // ---------------------------------------------------------------------------
       
   741 // Note! This method is executed in the context of the user mode client 
       
   742 // thread, but in supervisor mode
       
   743 // ---------------------------------------------------------------------------
       
   744 //
       
   745 TAny* DWlanLogicalChannel::OnEthernetSideControlFast( 
       
   746     TInt aFunction, 
       
   747     TAny* aParam,
       
   748     TBool& aTriggerTx )
       
   749     {
       
   750     TAny* ret( NULL );    
       
   751     aTriggerTx = EFalse;
       
   752     
       
   753     switch ( aFunction )
       
   754         {
       
   755         // ==========================================================
       
   756         // Alloc Tx buffer
       
   757         // ==========================================================        
       
   758         case RPcmNetCardIf::EControlFastAllocTxBuffer:
       
   759             if ( iEthernetFrameMemMngr )
       
   760                 {
       
   761                 ret = iEthernetFrameMemMngr->AllocTxBuffer(
       
   762                     reinterpret_cast<TUint>(aParam) );
       
   763                 }
       
   764             
       
   765             if ( !ret && iAddTxFrameAllowed )
       
   766                 {
       
   767                 iAddTxFrameAllowed = EFalse;
       
   768                 
       
   769                 TraceDump( NWSA_TX, 
       
   770                     ("WLANLDD: DWlanLogicalChannel::OnEthernetSideControlFast: "
       
   771                      "stop flow from protocol stack") );        
       
   772                 }
       
   773             break;            
       
   774         // ==========================================================
       
   775         // Add Tx frame
       
   776         // ==========================================================        
       
   777         case RPcmNetCardIf::EControlFastAddTxFrame:
       
   778             {
       
   779 #ifndef NDEBUG
       
   780             if ( !iAddTxFrameAllowed )
       
   781                 {
       
   782                 TraceDump(ERROR_LEVEL, 
       
   783                     ("WLANLDD: DWlanLogicalChannel::OnEthernetSideControlFast: "
       
   784                      "WARNING: AddTxFrame req. when flow ctrl is on"));
       
   785                 }
       
   786 #endif
       
   787             if ( iEthernetFrameMemMngr && aParam )
       
   788                 {
       
   789                 if ( iEthernetFrameMemMngr->AllTxQueuesEmpty() )
       
   790                     {
       
   791                     aTriggerTx = ETrue;
       
   792                     }
       
   793                 
       
   794                 TDataBuffer* discardFrame ( NULL );
       
   795                 
       
   796                 ret = reinterpret_cast<TAny*>(
       
   797                           iEthernetFrameMemMngr->AddTxFrame( 
       
   798                               reinterpret_cast<TDataBuffer*>(aParam),
       
   799                               discardFrame,
       
   800                               iUmac.UserDataTxEnabled() ));
       
   801                 
       
   802                 if ( discardFrame )
       
   803                     {
       
   804                     TraceDump( NWSA_TX_DETAILS, 
       
   805                         (("WLANLDD: DWlanLogicalChannel::OnEthernetSideControlFast: "
       
   806                           "have to drop tx frame of UP: %d"),
       
   807                         reinterpret_cast<TDataBuffer*>(
       
   808                             aParam)->UserPriority()) );
       
   809                     
       
   810                     iEthernetFrameMemMngr->FreeTxPacket( discardFrame );
       
   811                     aTriggerTx = EFalse;
       
   812                     }
       
   813                 }
       
   814                 
       
   815             if ( !ret )
       
   816                 {
       
   817                 iAddTxFrameAllowed = EFalse;
       
   818 
       
   819                 TraceDump( NWSA_TX, 
       
   820                     ("WLANLDD: DWlanLogicalChannel::OnEthernetSideControlFast: "
       
   821                      "stop flow from protocol stack") );
       
   822                 }
       
   823             break;
       
   824             }            
       
   825         // ==========================================================
       
   826         // Get Rx frame
       
   827         // ==========================================================        
       
   828         case RPcmNetCardIf::EControlFastGetRxFrame:
       
   829             {
       
   830             if ( iEthernetFrameMemMngr )
       
   831                 {
       
   832                 ret = iEthernetFrameMemMngr->GetRxFrame( 
       
   833                         reinterpret_cast<TDataBuffer*>(aParam) );
       
   834                 }
       
   835             }
       
   836             break;
       
   837         // ==========================================================
       
   838         // Unknown request
       
   839         // ==========================================================        
       
   840         default:
       
   841 #ifndef NDEBUG
       
   842             TraceDump(ERROR_LEVEL, (("WLANLDD: unknown request: %d"), 
       
   843                 aFunction));
       
   844             os_assert( 
       
   845                 (TUint8*)("WLANLDD: panic"), 
       
   846                 (TUint8*)(WLAN_FILE), 
       
   847                 __LINE__ );            
       
   848 #endif
       
   849             break;
       
   850         } // switch
       
   851     
       
   852     return ret;
       
   853     }
       
   854 
       
   855 // ---------------------------------------------------------------------------
   744 // 
   856 // 
   745 // ---------------------------------------------------------------------------
   857 // ---------------------------------------------------------------------------
   746 //
   858 //
   747 void DWlanLogicalChannel::DoCancel( TInt aMask )
   859 void DWlanLogicalChannel::DoCancel( TInt aMask )
   748     {
   860     {
   749     if ( iUnit == KUnitWlan )
   861     if ( iUnit == KUnitWlan )
   750         {
   862         {
   751         if ( aMask & ( 1 << EWlanRequestNotify ) )
   863         if ( aMask & ( 1 << RWlanLogicalChannel::EWlanRequestNotify ) )
   752             {
   864             {
   753             TraceDump(INFO_LEVEL, 
   865             TraceDump(INFO_LEVEL, 
   754                 ("WLANLDD: DWlanLogicalChannel::DoCancel: mgmt side notify cancel"));
   866                 ("WLANLDD: DWlanLogicalChannel::DoCancel: mgmt side notify cancel"));
   755 
   867 
   756             CancelIndicationRequest();
   868             CancelIndicationRequest();
   757             Kern::RequestComplete( 
   869             Kern::RequestComplete( 
   758                 iClient, iWlanRequestNotifyStatus, KErrServerTerminated );
   870                 iClient, iWlanRequestNotifyStatus, KErrServerTerminated );
   759             iWlanRequestNotifyStatus = NULL;
   871             iWlanRequestNotifyStatus = NULL;
   760             }        
   872             }        
   761         else if ( aMask & ( 1 << EWlanRequestFrame ) )
   873         else if ( aMask & ( 1 << RWlanLogicalChannel::EWlanRequestFrame ) )
   762             {
   874             {
   763             TraceDump(INFO_LEVEL, 
   875             TraceDump(INFO_LEVEL, 
   764                 ("WLANLDD: DWlanLogicalChannel::DoCancel: mgmt side frame read cancel"));
   876                 ("WLANLDD: DWlanLogicalChannel::DoCancel: mgmt side frame read cancel"));
   765 
   877 
   766             Kern::RequestComplete( 
   878             Kern::RequestComplete( 
   768             iWlanReceiveFrameStatus = NULL;
   880             iWlanReceiveFrameStatus = NULL;
   769             }
   881             }
   770         else
   882         else
   771             {
   883             {
   772             TraceDump(ERROR_LEVEL, 
   884             TraceDump(ERROR_LEVEL, 
   773                 (("WLANLDD: DWlanLogicalChannel::DoCancel: mgmt side unhandled mask panic: 0x%08x"), 
   885                 (("WLANLDD: DWlanLogicalChannel::DoCancel: mgmt side "
       
   886                   "unhandled mask panic: 0x%08x"), 
   774                 aMask));
   887                 aMask));
   775             os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ );
   888             os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ );
   776             }        
   889             }        
   777         }
   890         }
   778     else if ( iUnit == KUnitEthernet )
   891     else if ( iUnit == KUnitEthernet )
   796             iEthernetReceiveFrameStatus = NULL;
   909             iEthernetReceiveFrameStatus = NULL;
   797             }
   910             }
   798         else
   911         else
   799             {
   912             {
   800             TraceDump(ERROR_LEVEL, 
   913             TraceDump(ERROR_LEVEL, 
   801                 (("WLANLDD: DWlanLogicalChannel::DoCancel: user side unhandled mask panic: 0x%08x"), 
   914                 (("WLANLDD: DWlanLogicalChannel::DoCancel: user side "
       
   915                   "unhandled mask panic: 0x%08x"), 
   802                 aMask));
   916                 aMask));
   803             os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ );
   917             os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ );
   804             }        
   918             }        
   805         }
   919         }
   806     else
   920     else
   814 // ---------------------------------------------------------------------------
   928 // ---------------------------------------------------------------------------
   815 // 
   929 // 
   816 // ---------------------------------------------------------------------------
   930 // ---------------------------------------------------------------------------
   817 //
   931 //
   818 TBool DWlanLogicalChannel::ProtocolStackDataReceiveComplete( 
   932 TBool DWlanLogicalChannel::ProtocolStackDataReceiveComplete( 
   819     const TDataBuffer*& aBufferStart,
   933     TDataBuffer*& aBufferStart,
   820     TUint32 aNumOfBuffers )
   934     TUint32 aNumOfBuffers )
   821     {
   935     {
   822     if ( iEthernetFrameMemMngr->OnEthernetFrameRxComplete( aBufferStart, 
   936     if ( iEthernetFrameMemMngr && 
   823         aNumOfBuffers ) )
   937          iEthernetFrameMemMngr->OnEthernetFrameRxComplete( 
       
   938              aBufferStart, 
       
   939              aNumOfBuffers ) )
   824         {
   940         {
   825         Kern::RequestComplete( iClient, iEthernetReceiveFrameStatus, KErrNone );
   941         Kern::RequestComplete( iClient, iEthernetReceiveFrameStatus, KErrNone );
   826         iEthernetReceiveFrameStatus = NULL;
   942         iEthernetReceiveFrameStatus = NULL;
   827         }
   943         }
   828         
   944         
   901     TraceDump(UMAC_PROTO_CALLBACK, 
  1017     TraceDump(UMAC_PROTO_CALLBACK, 
   902         ("WLANLDD: DWlanLogicalChannel::OnTxProtocolStackDataComplete"));
  1018         ("WLANLDD: DWlanLogicalChannel::OnTxProtocolStackDataComplete"));
   903     TraceDump(UMAC_PROTO_CALLBACK, 
  1019     TraceDump(UMAC_PROTO_CALLBACK, 
   904         (("WLANLDD: aCompletionCode: %d"), aCompletionCode));
  1020         (("WLANLDD: aCompletionCode: %d"), aCompletionCode));
   905 
  1021 
   906     iEthernetFrameMemMngr->FreeTxPacket( aMetaHeader );
  1022     if ( iEthernetFrameMemMngr )
       
  1023         {
       
  1024         iEthernetFrameMemMngr->FreeTxPacket( aMetaHeader );
       
  1025         }
   907 
  1026 
   908     TxProtocolStackData();
  1027     TxProtocolStackData();
   909     
  1028     
   910     if ( !iAddTxFrameAllowed )
  1029     if ( !iAddTxFrameAllowed )
   911         {
  1030         {
   912         if ( iResumeTxStatus && 
  1031         if ( iResumeTxStatus &&
       
  1032              iEthernetFrameMemMngr &&
   913              iEthernetFrameMemMngr->ResumeClientTx( 
  1033              iEthernetFrameMemMngr->ResumeClientTx( 
   914                  iUmac.UserDataTxEnabled() ) )
  1034                  iUmac.UserDataTxEnabled() ) )
   915             {
  1035             {
   916             // resume Tx flow from protocol stack
  1036             // resume Tx flow from protocol stack
   917             
  1037             
   978 // 
  1098 // 
   979 // ---------------------------------------------------------------------------
  1099 // ---------------------------------------------------------------------------
   980 //
  1100 //
   981 void DWlanLogicalChannel::TxManagementData()
  1101 void DWlanLogicalChannel::TxManagementData()
   982     {
  1102     {
   983     TDataBuffer* buffer = iEthernetFrameMemMngr->OnWriteEthernetFrame();
  1103     TDataBuffer* buffer( NULL );
   984 
  1104     
   985     if ( !buffer )
  1105     if ( iEthernetFrameMemMngr )
   986         {
  1106         {
   987         TraceDump(ERROR_LEVEL, 
  1107         buffer = iEthernetFrameMemMngr->OnWriteEthernetFrame();
   988             ("WLANLDD: DWlanLogicalChannel::TxManagementData: "
  1108         }
   989              "panic, no buffer"));
  1109 
       
  1110     if ( buffer )
       
  1111         {
       
  1112         iUmac.WriteMgmtFrame( *buffer );
       
  1113         }
       
  1114     else
       
  1115         {
       
  1116 #ifndef NDEBUG
   990         os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ );
  1117         os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ );
   991         }
  1118 #endif
   992     else
  1119         Kern::RequestComplete( 
   993         {
  1120             iClient, iWlanSendFrameStatus, KErrGeneral );
   994         iUmac.WriteMgmtFrame( *buffer );
       
   995         }
  1121         }
   996     }
  1122     }
   997 
  1123 
   998 // ---------------------------------------------------------------------------
  1124 // ---------------------------------------------------------------------------
   999 // 
  1125 // 
  1000 // ---------------------------------------------------------------------------
  1126 // ---------------------------------------------------------------------------
  1001 //
  1127 //
  1002 void DWlanLogicalChannel::TxProtocolStackData()
  1128 void DWlanLogicalChannel::TxProtocolStackData()
  1003     {
  1129     {
  1004 #ifndef NDEBUG    
  1130 #ifndef NDEBUG
  1005     TUint packetsSubmitted ( 0 );
  1131     TUint packetsSubmitted ( 0 );
  1006 #endif
  1132 #endif
  1007     
  1133     
  1008     if ( !iTxActive )
  1134     if ( !iTxActive )
  1009         {
  1135         {
  1047 // 
  1173 // 
  1048 // ---------------------------------------------------------------------------
  1174 // ---------------------------------------------------------------------------
  1049 //
  1175 //
  1050 TBool DWlanLogicalChannel::OnReadEthernetFrameRequest()
  1176 TBool DWlanLogicalChannel::OnReadEthernetFrameRequest()
  1051     {
  1177     {
  1052     const TBool ret = iEthernetFrameMemMngr->OnReadRequest();
  1178     TBool ret( EFalse );
       
  1179     
       
  1180     if ( iEthernetFrameMemMngr )
       
  1181         {
       
  1182         ret = iEthernetFrameMemMngr->OnReadRequest();
       
  1183         }
       
  1184     
  1053     return ret;
  1185     return ret;
  1054     }
  1186     }
  1055 
  1187 
  1056 // ---------------------------------------------------------------------------
  1188 // ---------------------------------------------------------------------------
  1057 // 
  1189 // 
  1449             }
  1581             }
  1450         }
  1582         }
  1451 
  1583 
  1452     switch ( aReqNo )
  1584     switch ( aReqNo )
  1453         {
  1585         {
  1454         case EWlanInitSystem:
  1586         case RWlanLogicalChannel::EWlanInitSystem:
  1455             // bootup the chip and the system
  1587             // bootup the chip and the system
  1456             iWlanGeneralRequestStatus = aStatus; 
  1588             iWlanGeneralRequestStatus = aStatus; 
  1457             InitSystem( a1, sizeof(TOpenParam) );
  1589             InitSystem( a1, sizeof(TOpenParam) );
  1458             break;
  1590             break;
  1459         case EWlanFinitSystem:
  1591         case RWlanLogicalChannel::EWlanFinitSystem:
  1460             // power down the chip and the system
  1592             // power down the chip and the system
  1461             iWlanGeneralRequestStatus = aStatus; 
  1593             iWlanGeneralRequestStatus = aStatus; 
  1462             FinitSystem();
  1594             FinitSystem();
  1463             break;
  1595             break;
  1464         case EWlanCommand:
  1596         case RWlanLogicalChannel::EWlanCommand:
  1465             // management command
  1597             // management command
  1466             iWlanGeneralRequestStatus = aStatus; 
  1598             iWlanGeneralRequestStatus = aStatus; 
  1467 
  1599 
  1468             // read the USER mode parameters to internal storage
  1600             // read the USER mode parameters to internal storage
  1469             ret = Kern::ThreadRawRead( 
  1601             ret = Kern::ThreadRawRead( 
  1500                 // because it is not accessed by UMAC and the 
  1632                 // because it is not accessed by UMAC and the 
  1501                 // actual user mode writing is done by OnOidCompleted method
  1633                 // actual user mode writing is done by OnOidCompleted method
  1502                 output_buffer.iData, 
  1634                 output_buffer.iData, 
  1503                 output_buffer.iLen );
  1635                 output_buffer.iLen );
  1504             break;
  1636             break;
  1505         case EWlanRequestNotify:
  1637         case RWlanLogicalChannel::EWlanRequestNotify:
  1506             // store the USER mode indication address;
  1638             // store the USER mode indication address;
  1507             iIndicationBuffer = static_cast<TIndication*>(a1);
  1639             iIndicationBuffer = static_cast<TIndication*>(a1);
  1508             iWlanRequestNotifyStatus = aStatus;
  1640             iWlanRequestNotifyStatus = aStatus;
  1509             IndicationRequest( static_cast<TIndication*>(a1) );
  1641             IndicationRequest( static_cast<TIndication*>(a1) );
  1510             break;
  1642             break;
  1511         case EWlanRequestFrame:
  1643         case RWlanLogicalChannel::EWlanRequestFrame:
  1512             if ( OnReadEthernetFrameRequest() )
  1644             if ( OnReadEthernetFrameRequest() )
  1513                 {
  1645                 {
  1514                 // rx data to be completed exists
  1646                 // rx data to be completed exists
  1515                 // complete it directly
  1647                 // complete it directly
  1516                 Kern::RequestComplete( 
  1648                 Kern::RequestComplete( 
  1523                 // no rx data for completion exists
  1655                 // no rx data for completion exists
  1524                 // store the pending request
  1656                 // store the pending request
  1525                 iWlanReceiveFrameStatus = aStatus;
  1657                 iWlanReceiveFrameStatus = aStatus;
  1526                 }
  1658                 }
  1527             break;
  1659             break;
  1528         case EWlanRequestSend:
  1660         case RWlanLogicalChannel::EWlanRequestSend:
  1529             iWlanSendFrameStatus = aStatus;
  1661             iWlanSendFrameStatus = aStatus;
  1530 
  1662 
  1531             TxManagementData();
  1663             TxManagementData();
  1532             break;
  1664             break;
  1533         default:
  1665         default:
  1726     TInt aFunction, 
  1858     TInt aFunction, 
  1727     TAny* a1, 
  1859     TAny* a1, 
  1728     TAny* /*a2*/ )
  1860     TAny* /*a2*/ )
  1729     {
  1861     {
  1730     TInt ret( KErrNone );
  1862     TInt ret( KErrNone );
  1731     if ( aFunction == EWlanSvControlInitBuffers )
  1863     if ( aFunction == RWlanLogicalChannel::EWlanSvControlInitBuffers )
  1732         {
  1864         {
  1733         // initiliaze buffers for wlan mgmt client data xfer
  1865         // initiliaze buffers for wlan mgmt client data xfer
  1734         if ( a1 )
  1866         if ( a1 )
  1735             {
  1867             {
  1736             TraceDump(INIT_LEVEL, 
  1868             TraceDump(INIT_LEVEL, 
  1747             TraceDump(ERROR_LEVEL, 
  1879             TraceDump(ERROR_LEVEL, 
  1748                 ("WLANLDD: DWlanLogicalChannel::OnMgmtSideControl(): init management client buffer pool panic"));
  1880                 ("WLANLDD: DWlanLogicalChannel::OnMgmtSideControl(): init management client buffer pool panic"));
  1749             os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ );
  1881             os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ );
  1750             }
  1882             }
  1751         }
  1883         }
  1752     else if ( aFunction == EWlanSvControlFreeBuffers )
  1884     else if ( aFunction == RWlanLogicalChannel::EWlanSvControlFreeBuffers )
  1753         {
  1885         {
  1754         // free wlan mgmt client data xfer buffers
  1886         // free wlan mgmt client data xfer buffers
  1755         OnReleaseEthernetFrameBuffers();        
  1887         OnReleaseEthernetFrameBuffers();        
  1756         }
  1888         }
  1757     else
  1889     else
  1889     TUint32 aSnapFrameTxOffset )
  2021     TUint32 aSnapFrameTxOffset )
  1890     {
  2022     {
  1891     if ( iEthernetFrameMemMngr )
  2023     if ( iEthernetFrameMemMngr )
  1892         {
  2024         {
  1893         TraceDump(NWSA_TX_DETAILS, 
  2025         TraceDump(NWSA_TX_DETAILS, 
  1894             (("WLANLDD: DWlanLogicalChannel::SetMgmtSideTxOffsets: aEthernetFrameTxOffset: %d"),
  2026             (("WLANLDD: DWlanLogicalChannel::SetMgmtSideTxOffsets: "
       
  2027               "aEthernetFrameTxOffset: %d"),
  1895             aEthernetFrameTxOffset ));
  2028             aEthernetFrameTxOffset ));
  1896         TraceDump(NWSA_TX_DETAILS, 
  2029         TraceDump(NWSA_TX_DETAILS, 
  1897             (("WLANLDD: DWlanLogicalChannel::SetMgmtSideTxOffsets: aDot11FrameTxOffset: %d"),
  2030             (("WLANLDD: DWlanLogicalChannel::SetMgmtSideTxOffsets: "
       
  2031               "aDot11FrameTxOffset: %d"),
  1898             aDot11FrameTxOffset ));
  2032             aDot11FrameTxOffset ));
  1899         TraceDump(NWSA_TX_DETAILS, 
  2033         TraceDump(NWSA_TX_DETAILS, 
  1900             (("WLANLDD: DWlanLogicalChannel::SetMgmtSideTxOffsets: aSnapFrameTxOffset: %d"),
  2034             (("WLANLDD: DWlanLogicalChannel::SetMgmtSideTxOffsets: "
       
  2035               "aSnapFrameTxOffset: %d"),
  1901             aSnapFrameTxOffset ));
  2036             aSnapFrameTxOffset ));
  1902 
  2037 
  1903         iEthernetFrameMemMngr->SetTxOffsets( 
  2038         iEthernetFrameMemMngr->SetTxOffsets( 
  1904             aEthernetFrameTxOffset, 
  2039             aEthernetFrameTxOffset, 
  1905             aDot11FrameTxOffset,
  2040             aDot11FrameTxOffset,
  1932 // ---------------------------------------------------------------------------
  2067 // ---------------------------------------------------------------------------
  1933 // 
  2068 // 
  1934 // ---------------------------------------------------------------------------
  2069 // ---------------------------------------------------------------------------
  1935 //
  2070 //
  1936 void DWlanLogicalChannel::MgmtDataReceiveComplete( 
  2071 void DWlanLogicalChannel::MgmtDataReceiveComplete( 
  1937     const TDataBuffer*& aBufferStart, 
  2072     TDataBuffer*& aBufferStart, 
  1938     TUint32 aNumOfBuffers )
  2073     TUint32 aNumOfBuffers )
  1939     {
  2074     {
  1940     if ( iEthernetFrameMemMngr->OnEthernetFrameRxComplete( 
  2075     if ( iEthernetFrameMemMngr && 
  1941         aBufferStart, 
  2076          ( iEthernetFrameMemMngr->OnEthernetFrameRxComplete( 
  1942         aNumOfBuffers ) )
  2077                aBufferStart, 
       
  2078                aNumOfBuffers ) ) )
  1943         {
  2079         {
  1944         Kern::RequestComplete( iClient, iWlanReceiveFrameStatus, KErrNone );
  2080         Kern::RequestComplete( iClient, iWlanReceiveFrameStatus, KErrNone );
  1945         iWlanReceiveFrameStatus = NULL;
  2081         iWlanReceiveFrameStatus = NULL;
  1946         }
  2082         }
  1947     }
  2083     }
  2172 // ---------------------------------------------------------------------------
  2308 // ---------------------------------------------------------------------------
  2173 //
  2309 //
  2174 void DWlanLogicalChannel::ReleaseIndicationListEntry(
  2310 void DWlanLogicalChannel::ReleaseIndicationListEntry(
  2175     TIndicationListEntry* aEntry )
  2311     TIndicationListEntry* aEntry )
  2176     {
  2312     {
  2177     aEntry->next = NULL;
  2313     if ( aEntry )
  2178 
  2314         {
  2179     if ( !iFreeIndicationListHead )
  2315         aEntry->next = NULL;
  2180         {
  2316     
  2181         iFreeIndicationListHead = aEntry;
  2317         if ( !iFreeIndicationListHead )
  2182         }
  2318             {
       
  2319             iFreeIndicationListHead = aEntry;
       
  2320             }
       
  2321         else
       
  2322             {
       
  2323             TIndicationListEntry* tmp = iFreeIndicationListHead;
       
  2324     
       
  2325             while ( tmp->next )
       
  2326                 {
       
  2327                 tmp = tmp->next;
       
  2328                 }
       
  2329     
       
  2330             tmp->next = aEntry;
       
  2331             }
       
  2332         }
       
  2333 #ifndef NDEBUG
  2183     else
  2334     else
  2184         {
  2335         {
  2185         TIndicationListEntry* tmp = iFreeIndicationListHead;
  2336         os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ );        
  2186 
  2337         }
  2187         while ( tmp->next )
  2338 #endif        
  2188             {
       
  2189             tmp = tmp->next;
       
  2190             }
       
  2191 
       
  2192         tmp->next = aEntry;
       
  2193         }
       
  2194     }
  2339     }
  2195 
  2340 
  2196 // ---------------------------------------------------------------------------
  2341 // ---------------------------------------------------------------------------
  2197 // 
  2342 // 
  2198 // ---------------------------------------------------------------------------
  2343 // ---------------------------------------------------------------------------