diff -r a828660c511c -r d3d7683d16f5 wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/src/WlanLogicalChannel.cpp --- a/wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/src/WlanLogicalChannel.cpp Tue Aug 31 17:02:06 2010 +0300 +++ b/wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/src/WlanLogicalChannel.cpp Wed Sep 01 12:41:05 2010 +0100 @@ -16,7 +16,7 @@ */ /* -* %version: 61 % +* %version: 59.1.1 % */ #include "WlLddWlanLddConfig.h" @@ -41,8 +41,7 @@ const TUint32 KDmaTxMemSize = 4096; // equals to 1 MMU page on most systems // --------------------------------------------------------------------------- -// Note! This method is executed in the context of the user mode client -// thread, but in supervisor mode +// // --------------------------------------------------------------------------- // #ifndef RD_WLAN_DDK @@ -272,9 +271,6 @@ } // --------------------------------------------------------------------------- -// Note! This method is executed in the context of the user mode client -// thread, but in supervisor mode -// // If an error occurs in this method, we set iPdd to NULL to prevent // PDD object destruction in base class (DLogicalChannelBase) destructor. // DLogicalChannelBase destructor gets called as this logical channel instance @@ -610,11 +606,10 @@ // --------------------------------------------------------------------------- -// Note! This method is executed in the context of the user mode client -// thread, but in supervisor mode +// // --------------------------------------------------------------------------- // -TAny* DWlanLogicalChannel::DoControlFast( TInt aFunction, TAny* aParam ) +TAny* DWlanLogicalChannel::DoControlFast( TInt aFunction, TAny* param ) { TAny* ret( NULL ); TBool triggerTx ( EFalse ); @@ -626,6 +621,9 @@ iClient)); TraceDump(WLM_CMD_DETAILS, (("WLANLDD: function: 0x%x"), aFunction)); + // Note! We are executing in the context of the client's thread, but + // in supervisor mode + // acquire mutex // Enter critical section before requesting the mutex as // we are executing in the context of a user mode thread @@ -639,24 +637,70 @@ TraceDump(MUTEX, (("WLANLDD: DWlanLogicalChannel::DoControlFast: mutex acquired"))); - if ( iUnit == KUnitWlan ) - { - ret = OnMgmtSideControlFast( aFunction, aParam ); - } - else if ( iUnit == KUnitEthernet ) + switch ( aFunction ) { - ret = OnEthernetSideControlFast( aFunction, aParam, triggerTx ); - } - else - { - // unknown unit -#ifndef NDEBUG - TraceDump(ERROR_LEVEL, - ("WLANLDD: DWlanLogicalChannel::DoControlFast: unknown unit")); - TraceDump(ERROR_LEVEL, (("WLANLDD: aFunction: %d"), aFunction)); - TraceDump(ERROR_LEVEL, (("WLANLDD: unit: %d"), iUnit)); - os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); + case RPcmNetCardIf::EControlFastAllocTxBuffer: + ret = iEthernetFrameMemMngr->AllocTxBuffer( + reinterpret_cast(param) ); + + if ( !ret && iAddTxFrameAllowed ) + { + iAddTxFrameAllowed = EFalse; + + TraceDump( NWSA_TX, + ("WLANLDD: DWlanLogicalChannel::DoControlFast: stop flow from protocol stack") ); + } + break; + + case RPcmNetCardIf::EControlFastAddTxFrame: + { +#ifndef NDEBUG + if ( !iAddTxFrameAllowed ) + { + TraceDump(ERROR_LEVEL, + ("WLANLDD: DWlanLogicalChannel::DoControlFast: WARNING: AddTxFrame req. when flow ctrl is on")); + } #endif + if ( iEthernetFrameMemMngr->AllTxQueuesEmpty() ) + { + triggerTx = ETrue; + } + + TDataBuffer* discardFrame ( NULL ); + + ret = reinterpret_cast(iEthernetFrameMemMngr->AddTxFrame( + reinterpret_cast(param), + discardFrame, + iUmac.UserDataTxEnabled() )); + + if ( discardFrame ) + { + TraceDump( NWSA_TX_DETAILS, + (("WLANLDD: DWlanLogicalChannel::DoControlFast: have to drop tx frame of UP: %d"), + reinterpret_cast(param)->UserPriority()) ); + + iEthernetFrameMemMngr->FreeTxPacket( discardFrame ); + } + + if ( !ret ) + { + iAddTxFrameAllowed = EFalse; + + TraceDump( NWSA_TX, + ("WLANLDD: DWlanLogicalChannel::DoControlFast: stop flow from protocol stack") ); + } + break; + } + default: +#ifndef NDEBUG + TraceDump(ERROR_LEVEL, (("WLANLDD: unknown request: %d"), + aFunction)); + os_assert( + (TUint8*)("WLANLDD: panic"), + (TUint8*)(WLAN_FILE), + __LINE__ ); +#endif + break; } // release mutex @@ -681,7 +725,7 @@ // the lower priority thread will get paused and the higher priority // thread will get scheduled (to execute the DFC), we don't want the // higher priority thread to need to wait for the mutex. So we - // released the mutex first in this code block and after that enqueue + // released the mutex first in this code block and after that enque // the DFC request. if ( !( iFlags & KTxTriggerArmed ) ) { @@ -694,162 +738,6 @@ } // --------------------------------------------------------------------------- -// Note! This method is executed in the context of the user mode client -// thread, but in supervisor mode -// --------------------------------------------------------------------------- -// -TAny* DWlanLogicalChannel::OnMgmtSideControlFast( - TInt aFunction, - TAny* aParam ) - { - TAny* ret( NULL ); - - switch ( aFunction ) - { - // ========================================================== - // Get Rx frame - // ========================================================== - case RWlanLogicalChannel::EWlanControlFastGetRxFrame: - if ( iEthernetFrameMemMngr ) - { - ret = iEthernetFrameMemMngr->GetRxFrame( - reinterpret_cast(aParam) ); - } - break; - // ========================================================== - // Unknown request - // ========================================================== - default: -#ifndef NDEBUG - TraceDump(ERROR_LEVEL, (("WLANLDD: unknown request: %d"), - aFunction)); - os_assert( - (TUint8*)("WLANLDD: panic"), - (TUint8*)(WLAN_FILE), - __LINE__ ); -#endif - break; - } - - return ret; - } - -// --------------------------------------------------------------------------- -// Note! This method is executed in the context of the user mode client -// thread, but in supervisor mode -// --------------------------------------------------------------------------- -// -TAny* DWlanLogicalChannel::OnEthernetSideControlFast( - TInt aFunction, - TAny* aParam, - TBool& aTriggerTx ) - { - TAny* ret( NULL ); - aTriggerTx = EFalse; - - switch ( aFunction ) - { - // ========================================================== - // Alloc Tx buffer - // ========================================================== - case RPcmNetCardIf::EControlFastAllocTxBuffer: - if ( iEthernetFrameMemMngr ) - { - ret = iEthernetFrameMemMngr->AllocTxBuffer( - reinterpret_cast(aParam) ); - } - - if ( !ret && iAddTxFrameAllowed ) - { - iAddTxFrameAllowed = EFalse; - - TraceDump( NWSA_TX, - ("WLANLDD: DWlanLogicalChannel::OnEthernetSideControlFast: " - "stop flow from protocol stack") ); - } - break; - // ========================================================== - // Add Tx frame - // ========================================================== - case RPcmNetCardIf::EControlFastAddTxFrame: - { -#ifndef NDEBUG - if ( !iAddTxFrameAllowed ) - { - TraceDump(ERROR_LEVEL, - ("WLANLDD: DWlanLogicalChannel::OnEthernetSideControlFast: " - "WARNING: AddTxFrame req. when flow ctrl is on")); - } -#endif - if ( iEthernetFrameMemMngr && aParam ) - { - if ( iEthernetFrameMemMngr->AllTxQueuesEmpty() ) - { - aTriggerTx = ETrue; - } - - TDataBuffer* discardFrame ( NULL ); - - ret = reinterpret_cast( - iEthernetFrameMemMngr->AddTxFrame( - reinterpret_cast(aParam), - discardFrame, - iUmac.UserDataTxEnabled() )); - - if ( discardFrame ) - { - TraceDump( NWSA_TX_DETAILS, - (("WLANLDD: DWlanLogicalChannel::OnEthernetSideControlFast: " - "have to drop tx frame of UP: %d"), - reinterpret_cast( - aParam)->UserPriority()) ); - - iEthernetFrameMemMngr->FreeTxPacket( discardFrame ); - aTriggerTx = EFalse; - } - } - - if ( !ret ) - { - iAddTxFrameAllowed = EFalse; - - TraceDump( NWSA_TX, - ("WLANLDD: DWlanLogicalChannel::OnEthernetSideControlFast: " - "stop flow from protocol stack") ); - } - break; - } - // ========================================================== - // Get Rx frame - // ========================================================== - case RPcmNetCardIf::EControlFastGetRxFrame: - { - if ( iEthernetFrameMemMngr ) - { - ret = iEthernetFrameMemMngr->GetRxFrame( - reinterpret_cast(aParam) ); - } - } - break; - // ========================================================== - // Unknown request - // ========================================================== - default: -#ifndef NDEBUG - TraceDump(ERROR_LEVEL, (("WLANLDD: unknown request: %d"), - aFunction)); - os_assert( - (TUint8*)("WLANLDD: panic"), - (TUint8*)(WLAN_FILE), - __LINE__ ); -#endif - break; - } // switch - - return ret; - } - -// --------------------------------------------------------------------------- // // --------------------------------------------------------------------------- // @@ -857,7 +745,7 @@ { if ( iUnit == KUnitWlan ) { - if ( aMask & ( 1 << RWlanLogicalChannel::EWlanRequestNotify ) ) + if ( aMask & ( 1 << EWlanRequestNotify ) ) { TraceDump(INFO_LEVEL, ("WLANLDD: DWlanLogicalChannel::DoCancel: mgmt side notify cancel")); @@ -867,7 +755,7 @@ iClient, iWlanRequestNotifyStatus, KErrServerTerminated ); iWlanRequestNotifyStatus = NULL; } - else if ( aMask & ( 1 << RWlanLogicalChannel::EWlanRequestFrame ) ) + else if ( aMask & ( 1 << EWlanRequestFrame ) ) { TraceDump(INFO_LEVEL, ("WLANLDD: DWlanLogicalChannel::DoCancel: mgmt side frame read cancel")); @@ -879,8 +767,7 @@ else { TraceDump(ERROR_LEVEL, - (("WLANLDD: DWlanLogicalChannel::DoCancel: mgmt side " - "unhandled mask panic: 0x%08x"), + (("WLANLDD: DWlanLogicalChannel::DoCancel: mgmt side unhandled mask panic: 0x%08x"), aMask)); os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); } @@ -908,8 +795,7 @@ else { TraceDump(ERROR_LEVEL, - (("WLANLDD: DWlanLogicalChannel::DoCancel: user side " - "unhandled mask panic: 0x%08x"), + (("WLANLDD: DWlanLogicalChannel::DoCancel: user side unhandled mask panic: 0x%08x"), aMask)); os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); } @@ -927,13 +813,11 @@ // --------------------------------------------------------------------------- // TBool DWlanLogicalChannel::ProtocolStackDataReceiveComplete( - TDataBuffer*& aBufferStart, + const TDataBuffer*& aBufferStart, TUint32 aNumOfBuffers ) { - if ( iEthernetFrameMemMngr && - iEthernetFrameMemMngr->OnEthernetFrameRxComplete( - aBufferStart, - aNumOfBuffers ) ) + if ( iEthernetFrameMemMngr->OnEthernetFrameRxComplete( aBufferStart, + aNumOfBuffers ) ) { Kern::RequestComplete( iClient, iEthernetReceiveFrameStatus, KErrNone ); iEthernetReceiveFrameStatus = NULL; @@ -1016,17 +900,13 @@ TraceDump(UMAC_PROTO_CALLBACK, (("WLANLDD: aCompletionCode: %d"), aCompletionCode)); - if ( iEthernetFrameMemMngr ) - { - iEthernetFrameMemMngr->FreeTxPacket( aMetaHeader ); - } + iEthernetFrameMemMngr->FreeTxPacket( aMetaHeader ); TxProtocolStackData(); if ( !iAddTxFrameAllowed ) { - if ( iResumeTxStatus && - iEthernetFrameMemMngr && + if ( iResumeTxStatus && iEthernetFrameMemMngr->ResumeClientTx( iUmac.UserDataTxEnabled() ) ) { @@ -1097,24 +977,18 @@ // void DWlanLogicalChannel::TxManagementData() { - TDataBuffer* buffer( NULL ); - - if ( iEthernetFrameMemMngr ) + TDataBuffer* buffer = iEthernetFrameMemMngr->OnWriteEthernetFrame(); + + if ( !buffer ) { - buffer = iEthernetFrameMemMngr->OnWriteEthernetFrame(); - } - - if ( buffer ) - { - iUmac.WriteMgmtFrame( *buffer ); + TraceDump(ERROR_LEVEL, + ("WLANLDD: DWlanLogicalChannel::TxManagementData: " + "panic, no buffer")); + os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); } else { -#ifndef NDEBUG - os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); -#endif - Kern::RequestComplete( - iClient, iWlanSendFrameStatus, KErrGeneral ); + iUmac.WriteMgmtFrame( *buffer ); } } @@ -1124,7 +998,7 @@ // void DWlanLogicalChannel::TxProtocolStackData() { -#ifndef NDEBUG +#ifndef NDEBUG TUint packetsSubmitted ( 0 ); #endif @@ -1172,13 +1046,7 @@ // TBool DWlanLogicalChannel::OnReadEthernetFrameRequest() { - TBool ret( EFalse ); - - if ( iEthernetFrameMemMngr ) - { - ret = iEthernetFrameMemMngr->OnReadRequest(); - } - + const TBool ret = iEthernetFrameMemMngr->OnReadRequest(); return ret; } @@ -1580,17 +1448,17 @@ switch ( aReqNo ) { - case RWlanLogicalChannel::EWlanInitSystem: + case EWlanInitSystem: // bootup the chip and the system iWlanGeneralRequestStatus = aStatus; InitSystem( a1, sizeof(TOpenParam) ); break; - case RWlanLogicalChannel::EWlanFinitSystem: + case EWlanFinitSystem: // power down the chip and the system iWlanGeneralRequestStatus = aStatus; FinitSystem(); break; - case RWlanLogicalChannel::EWlanCommand: + case EWlanCommand: // management command iWlanGeneralRequestStatus = aStatus; @@ -1631,13 +1499,13 @@ output_buffer.iData, output_buffer.iLen ); break; - case RWlanLogicalChannel::EWlanRequestNotify: + case EWlanRequestNotify: // store the USER mode indication address; iIndicationBuffer = static_cast(a1); iWlanRequestNotifyStatus = aStatus; IndicationRequest( static_cast(a1) ); break; - case RWlanLogicalChannel::EWlanRequestFrame: + case EWlanRequestFrame: if ( OnReadEthernetFrameRequest() ) { // rx data to be completed exists @@ -1654,7 +1522,7 @@ iWlanReceiveFrameStatus = aStatus; } break; - case RWlanLogicalChannel::EWlanRequestSend: + case EWlanRequestSend: iWlanSendFrameStatus = aStatus; TxManagementData(); @@ -1857,7 +1725,7 @@ TAny* /*a2*/ ) { TInt ret( KErrNone ); - if ( aFunction == RWlanLogicalChannel::EWlanSvControlInitBuffers ) + if ( aFunction == EWlanSvControlInitBuffers ) { // initiliaze buffers for wlan mgmt client data xfer if ( a1 ) @@ -1878,7 +1746,7 @@ os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); } } - else if ( aFunction == RWlanLogicalChannel::EWlanSvControlFreeBuffers ) + else if ( aFunction == EWlanSvControlFreeBuffers ) { // free wlan mgmt client data xfer buffers OnReleaseEthernetFrameBuffers(); @@ -2020,16 +1888,13 @@ if ( iEthernetFrameMemMngr ) { TraceDump(NWSA_TX_DETAILS, - (("WLANLDD: DWlanLogicalChannel::SetMgmtSideTxOffsets: " - "aEthernetFrameTxOffset: %d"), + (("WLANLDD: DWlanLogicalChannel::SetMgmtSideTxOffsets: aEthernetFrameTxOffset: %d"), aEthernetFrameTxOffset )); TraceDump(NWSA_TX_DETAILS, - (("WLANLDD: DWlanLogicalChannel::SetMgmtSideTxOffsets: " - "aDot11FrameTxOffset: %d"), + (("WLANLDD: DWlanLogicalChannel::SetMgmtSideTxOffsets: aDot11FrameTxOffset: %d"), aDot11FrameTxOffset )); TraceDump(NWSA_TX_DETAILS, - (("WLANLDD: DWlanLogicalChannel::SetMgmtSideTxOffsets: " - "aSnapFrameTxOffset: %d"), + (("WLANLDD: DWlanLogicalChannel::SetMgmtSideTxOffsets: aSnapFrameTxOffset: %d"), aSnapFrameTxOffset )); iEthernetFrameMemMngr->SetTxOffsets( @@ -2066,13 +1931,12 @@ // --------------------------------------------------------------------------- // void DWlanLogicalChannel::MgmtDataReceiveComplete( - TDataBuffer*& aBufferStart, + const TDataBuffer*& aBufferStart, TUint32 aNumOfBuffers ) { - if ( iEthernetFrameMemMngr && - ( iEthernetFrameMemMngr->OnEthernetFrameRxComplete( - aBufferStart, - aNumOfBuffers ) ) ) + if ( iEthernetFrameMemMngr->OnEthernetFrameRxComplete( + aBufferStart, + aNumOfBuffers ) ) { Kern::RequestComplete( iClient, iWlanReceiveFrameStatus, KErrNone ); iWlanReceiveFrameStatus = NULL; @@ -2307,32 +2171,23 @@ void DWlanLogicalChannel::ReleaseIndicationListEntry( TIndicationListEntry* aEntry ) { - if ( aEntry ) + aEntry->next = NULL; + + if ( !iFreeIndicationListHead ) { - aEntry->next = NULL; - - if ( !iFreeIndicationListHead ) - { - iFreeIndicationListHead = aEntry; - } - else - { - TIndicationListEntry* tmp = iFreeIndicationListHead; - - while ( tmp->next ) - { - tmp = tmp->next; - } - - tmp->next = aEntry; - } + iFreeIndicationListHead = aEntry; } -#ifndef NDEBUG else { - os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); + TIndicationListEntry* tmp = iFreeIndicationListHead; + + while ( tmp->next ) + { + tmp = tmp->next; + } + + tmp->next = aEntry; } -#endif } // ---------------------------------------------------------------------------