diff -r 5fb7af913dfd -r a828660c511c wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/src/EthernetFrameMemMngr.cpp --- a/wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/src/EthernetFrameMemMngr.cpp Thu Aug 19 11:40:48 2010 +0300 +++ b/wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/src/EthernetFrameMemMngr.cpp Tue Aug 31 17:02:06 2010 +0300 @@ -16,7 +16,7 @@ */ /* -* %version: 24 % +* %version: 25 % */ #include "WlLddWlanLddConfig.h" @@ -170,8 +170,7 @@ { MarkMemFree(); - iFrameXferBlock = NULL; - iTxDataBuffer = NULL; + iFrameXferBlockBase = NULL; iRxDataChunk = NULL; } @@ -181,79 +180,11 @@ // TDataBuffer* DEthernetFrameMemMngr::OnWriteEthernetFrame() const { - if ( iTxDataBuffer->GetLength() >= sizeof( SEthernetHeader ) ) - { - return iTxDataBuffer; - } - else - { - os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); - return NULL; - } - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -TBool DEthernetFrameMemMngr::OnReadRequest() - { - TBool ret( EFalse ); - - if ( IsMemInUse() ) - { - if ( iCountCompleted ) - { - // free relevant buffers - DoFreeRxBuffers(); - iCountCompleted = 0; // no buffers anymore in process in user mode - - // make sure that the same buffers are not tried to be - // freed again thru the incremental freeing method - iFrameXferBlock->KeAllUserSideRxBuffersFreed(); - } - - if ( iCountTobeCompleted ) - { - // there are Rx buffers to be completed - - iFrameXferBlock->KeRxComplete( DoGetTobeCompletedBuffersStart(), - iCountTobeCompleted ); - // mark the completed buffers - assign( DoGetTobeCompletedBuffersStart(), - DoGetCompletedBuffersStart(), - iCountTobeCompleted ); - iCountCompleted = iCountTobeCompleted; - iCountTobeCompleted = 0; - - ret = ETrue; - // the frame Rx request won't be pending as the callee shall - // complete it - iReadStatus = ENotPending; - } - else - { - // there are no Rx buffers to be completed. The Rx request is - // left pending - iReadStatus = EPending; - } - } - else - { - os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); - } - - return ret; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void DEthernetFrameMemMngr::DoMarkRxBufFree( TUint8* /*aBufferToFree*/ ) - { // not supported in default handler +#ifndef NDEBUG os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); +#endif + return NULL; } // --------------------------------------------------------------------------- @@ -265,9 +196,9 @@ TUint32 aDot11FrameTxOffset, TUint32 aSnapFrameTxOffset ) { - if ( IsMemInUse() ) + if ( IsMemInUse() && iFrameXferBlockBase ) { - iFrameXferBlock->KeSetTxOffsets( + iFrameXferBlockBase->KeSetTxOffsets( aEthernetFrameTxOffset, aDot11FrameTxOffset, aSnapFrameTxOffset ); @@ -290,7 +221,7 @@ else { // we are trying to acquire an Rx buffer but our user mode client - // has not asked for the memorybuffer pool to be initialized. In this + // has not asked for the memory buffer pool to be initialized. In this // case NULL is returned, as no buffers are available TraceDump(RX_FRAME, ("WLANLDD: DEthernetFrameMemMngr::OnGetEthernetFrameRxBuffer: not initialized => failed")); @@ -307,7 +238,7 @@ { TDataBuffer* buffer ( NULL ); - if ( IsMemInUse() ) + if ( IsMemInUse() && iRxFrameMemoryPool ) { buffer = reinterpret_cast( iRxFrameMemoryPool->Alloc( sizeof( TDataBuffer ), ETrue ) ); @@ -335,8 +266,13 @@ // void DEthernetFrameMemMngr::FreeRxFrameMetaHeader( TDataBuffer* aMetaHeader ) { - if ( IsMemInUse() ) + if ( IsMemInUse() && iRxFrameMemoryPool ) { + TraceDump( RX_FRAME, + (("WLANLDD: DEthernetFrameMemMngr::FreeRxFrameMetaHeader: " + "at addr: 0x%08x"), + reinterpret_cast(aMetaHeader)) ); + iRxFrameMemoryPool->Free( aMetaHeader ); } else @@ -344,16 +280,74 @@ // the whole Rx memory pool - including aMetaHeader - has already // been deallocated, so nothing is done in this case TraceDump( RX_FRAME, - ("WLANLDD: MgmtFrameMemMngr::FreeRxFrameMetaHeader: Rx memory pool already deallocated; no action needed") ); + ("WLANLDD: MgmtFrameMemMngr::FreeRxFrameMetaHeader: Rx memory " + "pool already deallocated; no action needed") ); } } // --------------------------------------------------------------------------- +// Note! This method is executed in the context of the user mode client +// thread, but in supervisor mode +// --------------------------------------------------------------------------- +// +void DEthernetFrameMemMngr::FreeRxPacket( + TDataBuffer* aFrameToFreeInUserSpace ) + { + if ( IsMemInUse() && + aFrameToFreeInUserSpace && + iFrameXferBlockBase && + iRxFrameMemoryPool ) + { + TDataBuffer* frameToFreeInKernSpace ( + reinterpret_cast( + reinterpret_cast( + aFrameToFreeInUserSpace) + + iFrameXferBlockBase->UserToKernAddrOffset()) ); + + // first free the actual Rx frame buffer if relevant + if ( frameToFreeInKernSpace->KeFlags() & + TDataBuffer::KDontReleaseBuffer ) + { + // this buffer shall not be freed yet, so no action here + + TraceDump( RX_FRAME, + (("WLANLDD: DEthernetFrameMemMngr::FreeRxPacket: don't free " + "yet Rx buf at addr: 0x%08x"), + reinterpret_cast( + frameToFreeInKernSpace->KeGetBufferStart()) ) ); + } + else + { + TraceDump( RX_FRAME, + (("WLANLDD: DEthernetFrameMemMngr::FreeRxPacket: free Rx buf " + "at addr: 0x%08x"), + reinterpret_cast( + frameToFreeInKernSpace->KeGetBufferStart()) ) ); + + iRxFrameMemoryPool->Free( + frameToFreeInKernSpace->KeGetBufferStart() + // take into account the alignment padding + - iRxBufAlignmentPadding ); + } + + // free the Rx frame meta header + + TraceDump( RX_FRAME, + (("WLANLDD: DEthernetFrameMemMngr::FreeRxPacket: " + "free metahdr at addr: 0x%08x"), + reinterpret_cast(frameToFreeInKernSpace)) ); + + iRxFrameMemoryPool->Free( frameToFreeInKernSpace ); + aFrameToFreeInUserSpace = NULL; + } + } + +// --------------------------------------------------------------------------- // // --------------------------------------------------------------------------- // TBool DEthernetFrameMemMngr::OnEthernetFrameRxComplete( - const TDataBuffer*& aBufferStart, + TDataBuffer*& aBufferStart, TUint32 aNumOfBuffers ) { TBool ret( EFalse ); @@ -394,10 +388,22 @@ } // --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void DEthernetFrameMemMngr::DoMarkRxBufFree( TUint8* /*aBufferToFree*/ ) + { + // not suported in this default implementation +#ifndef NDEBUG + os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); +#endif + } + +// --------------------------------------------------------------------------- // This default implementation always returns NULL // --------------------------------------------------------------------------- // -TDataBuffer* DEthernetFrameMemMngr::AllocTxBuffer( TUint aLength ) +TDataBuffer* DEthernetFrameMemMngr::AllocTxBuffer( TUint /*aLength*/ ) { return NULL; } @@ -407,22 +413,16 @@ // --------------------------------------------------------------------------- // TBool DEthernetFrameMemMngr::AddTxFrame( - TDataBuffer* aPacketInUserSpace, - TDataBuffer*& aPacketInKernSpace, - TBool aUserDataTxEnabled ) + TDataBuffer* /*aPacketInUserSpace*/, + TDataBuffer*& /*aPacketInKernSpace*/, + TBool /*aUserDataTxEnabled*/ ) { - if ( IsMemInUse() ) - { - return (static_cast( - iFrameXferBlock))->AddTxFrame( - aPacketInUserSpace, - aPacketInKernSpace, - aUserDataTxEnabled ); - } - else - { - return EFalse; - } + // not suported in this default implementation +#ifndef NDEBUG + os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); +#endif + + return EFalse; } // --------------------------------------------------------------------------- @@ -430,18 +430,15 @@ // --------------------------------------------------------------------------- // TDataBuffer* DEthernetFrameMemMngr::GetTxFrame( - const TWhaTxQueueState& aTxQueueState, - TBool& aMore ) + const TWhaTxQueueState& /*aTxQueueState*/, + TBool& /*aMore*/ ) { - if ( IsMemInUse() && iFrameXferBlock ) - { - return (static_cast( - iFrameXferBlock))->GetTxFrame( aTxQueueState, aMore ); - } - else - { - return NULL; - } + // not suported in this default implementation +#ifndef NDEBUG + os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); +#endif + + return NULL; } // --------------------------------------------------------------------------- @@ -451,17 +448,24 @@ void DEthernetFrameMemMngr::FreeTxPacket( TDataBuffer*& /*aPacket*/ ) { // not suported in this default implementation +#ifndef NDEBUG os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); +#endif } // --------------------------------------------------------------------------- // // --------------------------------------------------------------------------- // -TBool DEthernetFrameMemMngr::ResumeClientTx( TBool aUserDataTxEnabled ) const +TBool DEthernetFrameMemMngr::ResumeClientTx( + TBool /*aUserDataTxEnabled*/ ) const { - return (static_cast( - iFrameXferBlock))->ResumeClientTx( aUserDataTxEnabled ); + // not suported in this default implementation +#ifndef NDEBUG + os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); +#endif + + return EFalse; } // --------------------------------------------------------------------------- @@ -470,6 +474,10 @@ // TBool DEthernetFrameMemMngr::AllTxQueuesEmpty() const { - return (static_cast( - iFrameXferBlock))->AllTxQueuesEmpty(); + // not suported in this default implementation +#ifndef NDEBUG + os_assert( (TUint8*)("WLANLDD: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); +#endif + + return EFalse; }