wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/src/WlanLogicalChannel.cpp
changeset 17 41a8eba36f74
parent 13 ab7247ff6ef9
child 22 c6a1762761b8
child 25 a0fdcd0e4c56
child 34 13838cf40350
--- a/wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/src/WlanLogicalChannel.cpp	Fri Apr 16 16:56:12 2010 +0300
+++ b/wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/src/WlanLogicalChannel.cpp	Mon May 03 14:14:02 2010 +0300
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 57 %
+* %version: 59 %
 */
 
 #include "WlLddWlanLddConfig.h"
@@ -24,7 +24,6 @@
 #include "WlanLogicalChannel.h"
 #include "EthernetFrameMemMngr.h"
 #include "EtherCardIoc.h"
-#include "RWlanLogicalChannel.h"
 #include "Umac.h"
 #include "wllddoidmsgstorage.h"
 #include "WlanLogicalDevice.h"
@@ -186,11 +185,6 @@
     else if ( iUnit == KUnitEthernet )
         {
         iTxTriggerDfc.Cancel();
-        
-        // detach protocol stack side callback
-        TraceDump(INIT_LEVEL, 
-            ("WLANLDD: detach protocol stack side callback from UMAC"));
-        iUmac.DetachProtocolStackSideUmacCb();
         }
 
     if ( iEthernetFrameMemMngr )
@@ -443,8 +437,7 @@
         }
     else if ( iUnit == KUnitEthernet )
         {
-        // attach protocol stack side callbac
-        iUmac.AttachProtocolStackSideUmacCb( *this );
+        // nothing for now
         }
     else
         {
@@ -632,11 +625,15 @@
     // in supervisor mode
     
     // acquire mutex
+    // Enter critical section before requesting the mutex as
+    // we are executing in the context of a user mode thread
+    NKern::ThreadEnterCS();    
 #ifndef RD_WLAN_DDK
     Kern::MutexWait( iMutex );
 #else
     iOsa->MutexAcquire();
 #endif
+    NKern::ThreadLeaveCS();
     
     TraceDump(MUTEX, 
         (("WLANLDD: DWlanLogicalChannel::DoControlFast: mutex acquired")));
@@ -708,11 +705,15 @@
         }
     
     // release mutex
+    // Enter critical section before releasing the mutex as
+    // we are executing in the context of a user mode thread
+    NKern::ThreadEnterCS();    
 #ifndef RD_WLAN_DDK
     Kern::MutexSignal( iMutex );
 #else
     iOsa->MutexRelease();
 #endif 
+    NKern::ThreadLeaveCS();
     
     TraceDump(MUTEX, 
         ("WLANLDD: DWlanLogicalChannel::DoControlFast: mutex released"));
@@ -1010,7 +1011,7 @@
         TBool morePackets ( EFalse );
         iTxActive = ETrue;
         
-        while ( iUmac.TxPermitted( txQueueState ) && iEthernetFrameMemMngr )
+        while ( iEthernetFrameMemMngr && iUmac.TxPermitted( txQueueState ) )
             {
             TDataBuffer* metaHeader = 
                 iEthernetFrameMemMngr->GetTxFrame( txQueueState, morePackets );
@@ -1599,6 +1600,18 @@
             aSharedChunkInfo,
             vendorTxHdrLen,
             vendorTxTrailerLen );
+        
+        if ( ( iUnit == KUnitEthernet ) && 
+             ( ret == KErrNone ) )
+            {
+            // attach protocol stack side callback
+            TraceDump(INIT_LEVEL, 
+                ("WLANLDD: attach protocol stack side callback to UMAC"));
+            iUmac.AttachProtocolStackSideUmacCb( *this );
+    
+            // set frame Tx offset for protocol stack side 
+            iUmac.SetTxOffset();
+            }
         }
 
     return ret;
@@ -1614,6 +1627,14 @@
         {
         iEthernetFrameMemMngr->OnReleaseMemory( *iClient );    
         }
+
+    if ( iUnit == KUnitEthernet )
+        {
+        // detach protocol stack side callback
+        TraceDump(INIT_LEVEL, 
+            ("WLANLDD: detach protocol stack side callback from UMAC"));
+        iUmac.DetachProtocolStackSideUmacCb();
+        }
     }
 
 // ---------------------------------------------------------------------------
@@ -1671,9 +1692,6 @@
                     a1));
                 ret = OnInitialiseEthernetFrameBuffers( 
                     static_cast<TSharedChunkInfo*>(a1) );
-
-                // set frame Tx offset for protocol stack side 
-                iUmac.SetTxOffset();
                 }
             else
                 {