wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/inc/MgmtFrameMemMngr.h
changeset 0 c40eb8fe8501
child 3 6524e815f76f
equal deleted inserted replaced
-1:000000000000 0:c40eb8fe8501
       
     1 /*
       
     2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Declaration of the MgmtFrameMemMngr class.
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 14 %
       
    20 */
       
    21 
       
    22 #ifndef MGMTFRAMEMMNGR_H
       
    23 #define MGMTFRAMEMMNGR_H
       
    24 
       
    25 #include "EthernetFrameMemMngr.h"
       
    26 
       
    27 class WlanChunk;
       
    28 
       
    29 
       
    30 /**
       
    31 *  Memory manager for management client frame Rx memory
       
    32 *
       
    33 *  @since S60 v3.1
       
    34 */
       
    35 class MgmtFrameMemMngr : public DEthernetFrameMemMngr
       
    36     {
       
    37 
       
    38 public:
       
    39 
       
    40     /** Ctor */
       
    41     MgmtFrameMemMngr( 
       
    42         DWlanLogicalChannel& aParent,
       
    43         WlanChunk*& aRxFrameMemoryPool,
       
    44         TBool aUseCachedMemory,
       
    45         TInt aRxFrameBufAllocationUnit ) : 
       
    46         DEthernetFrameMemMngr( aParent, aRxFrameMemoryPool ),
       
    47         iUseCachedMemory( aUseCachedMemory ),
       
    48         iRxFrameBufAllocationUnit ( aRxFrameBufAllocationUnit ),
       
    49         iChunkSize( 
       
    50             Kern::RoundToPageSize( 
       
    51                 4096 * 15 + KProtocolStackSideTxDataChunkSize ) ) // bytes
       
    52         {};
       
    53 
       
    54     /** Dtor */
       
    55     virtual ~MgmtFrameMemMngr() {};
       
    56 
       
    57 protected:
       
    58 
       
    59     /**
       
    60     * From DEthernetFrameMemMngr
       
    61     * Allocates a shared memory chunk for frame transfer between user
       
    62     * and kernel address spaces
       
    63     *
       
    64     * @since S60 3.1
       
    65     * @param aSharedMemoryChunk The shared memory chunk
       
    66     * @return system wide error code, KErrNone upon success
       
    67     */
       
    68     virtual TInt DoAllocate( DChunk*& aSharedMemoryChunk );
       
    69 
       
    70     /**
       
    71     * Opens a handle for user mode client to the shared memory chunk
       
    72     * allocated for frame transfer between user and kernel address spaces
       
    73     *
       
    74     * @since S60 3.1
       
    75     * @param aThread The user mode client thread
       
    76     * @param aSharedChunkInfo After successful return contains the handle to the
       
    77     *        chunk
       
    78     * @param aSharedMemoryChunk The shared memory chunk
       
    79     * @return system wide error code, KErrNone upon success
       
    80     */
       
    81     virtual TInt DoOpenHandle(
       
    82         DThread& aThread,
       
    83         TSharedChunkInfo& aSharedChunkInfo,
       
    84         DChunk* aSharedMemoryChunk );
       
    85 
       
    86     /**
       
    87     * From DEthernetFrameMemMngr
       
    88     * Gets a free rx buffer
       
    89     *
       
    90     * @since S60 3.1
       
    91     * @param aLengthinBytes Requested buffer length
       
    92     * @return buffer for Rx data upon success
       
    93     *         NULL otherwise
       
    94     */
       
    95     virtual TUint8* DoGetNextFreeRxBuffer( TUint aLengthinBytes );
       
    96 
       
    97     /**
       
    98     * From DEthernetFrameMemMngr
       
    99     * Gets called when rx frame read cycle has ended.
       
   100     *
       
   101     * @since S60 3.1
       
   102     * @param aBufferStart first element of the array that holds pointers to
       
   103     *        Rx frame meta headers
       
   104     * @param aNumOfBuffers number of meta header pointers in the array
       
   105     * @return ETrue if a pending user mode frame read request exists 
       
   106     *         and callee should complete it, 
       
   107     *         EFalse otherwise
       
   108     */
       
   109     virtual TBool DoEthernetFrameRxComplete( 
       
   110         const TDataBuffer*& aBufferStart, 
       
   111         TUint32 aNumOfBuffers );
       
   112 
       
   113     /**
       
   114     * From DEthernetFrameMemMngr
       
   115     * Gets start address of Rx buffers (their offset addresses)
       
   116     * that are waiting for completion to user mode
       
   117     *
       
   118     * @since S60 3.1
       
   119     * @return see above statement
       
   120     */
       
   121     virtual TUint32* DoGetTobeCompletedBuffersStart();
       
   122 
       
   123     /**
       
   124     * From DEthernetFrameMemMngr
       
   125     * Gets start address of Rx buffers (their offset addresses)
       
   126     * that have been completed to user mode
       
   127     *
       
   128     * @since S60 3.1
       
   129     * @return see above statement
       
   130     */
       
   131     virtual TUint32* DoGetCompletedBuffersStart();
       
   132 
       
   133     /**
       
   134     * From DEthernetFrameMemMngr
       
   135     * Gets called when user mode client issues a frame receive request 
       
   136     * and Rx buffers have been completed to it. The completed Rx frame 
       
   137     * buffers are freed.
       
   138     *
       
   139     * @since S60 3.1
       
   140     */
       
   141     virtual void DoFreeRxBuffers();
       
   142 
       
   143     /**
       
   144     * From DEthernetFrameMemMngr
       
   145     * Frees the specified Rx frame buffer
       
   146     *
       
   147     * @since S60 3.1
       
   148     * @param aBufferToFree The buffer to free
       
   149     */
       
   150     virtual void DoMarkRxBufFree( TUint8* aBufferToFree );
       
   151 
       
   152 private:
       
   153 
       
   154     /**
       
   155     * Returns the number of extra bytes required to align Rx buffer start
       
   156     * address, to be returned to WHA layer, to allocation unit boundary
       
   157     * @return See above
       
   158     */
       
   159     TInt RxBufAlignmentPadding() const;
       
   160     
       
   161     /**
       
   162     * From DEthernetFrameMemMngr
       
   163     * Memory finalization method.
       
   164     * Deallocates the shared memory chunk
       
   165     *
       
   166     * @since S60 3.1
       
   167     */
       
   168     virtual void OnReleaseMemory();
       
   169 
       
   170     // Prohibit copy constructor.
       
   171     MgmtFrameMemMngr( const MgmtFrameMemMngr& );
       
   172     // Prohibit assigment operator.
       
   173     MgmtFrameMemMngr& operator= ( const MgmtFrameMemMngr & ); 
       
   174     
       
   175 private:    // Data
       
   176 
       
   177     /** 
       
   178     * kernel address of the shared memory chunk
       
   179     */
       
   180     TLinAddr iChunkKernelAddr;
       
   181 
       
   182     /** 
       
   183     * array of TDataBuffer offset addresses, denoting Rx buffers,
       
   184     * which are waiting here in kernel mode to be completed 
       
   185     * to user mode, when the next frame receive request arrives
       
   186     */
       
   187     TUint32  iTobeCompletedBuffers[KMaxToBeCompletedRxBufs];
       
   188 
       
   189     /** 
       
   190     * array of TDataBuffer offset addresses, denoting Rx buffers, that are
       
   191     * currently under processing in user mode
       
   192     */
       
   193     TUint32  iCompletedBuffers[KMaxCompletedRxBufs];
       
   194 
       
   195     /** 
       
   196     * ETrue if cached frame transfer memory shall be used,
       
   197     * EFalse otherwise
       
   198     */
       
   199     TBool iUseCachedMemory;
       
   200 
       
   201     /**
       
   202     * size of the Rx frame buffer allocation unit in bytes
       
   203     */
       
   204     TInt iRxFrameBufAllocationUnit;
       
   205 
       
   206     /** size of the shared memory chunk */
       
   207     TInt iChunkSize;
       
   208     };
       
   209 
       
   210 #endif // MGMTFRAMEMMNGR_H