usbmgmt/usbmgr/device/classdrivers/ncm/classimplementation/ncmpktdrv/pktdrv/inc/ncmdatasender.h
branchRCL_3
changeset 15 f92a4f87e424
equal deleted inserted replaced
14:d3e8e7d462dd 15:f92a4f87e424
       
     1 /*
       
     2 * Copyright (c) 2010 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 "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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 /**
       
    20 @file
       
    21 @internalComponent
       
    22 */
       
    23 
       
    24 
       
    25 #ifndef NCMDATASENDER_H
       
    26 #define NCMDATASENDER_H
       
    27 
       
    28 #include <e32base.h>
       
    29 
       
    30 #ifndef __OVER_DUMMYUSBSCLDD__
       
    31 #include <d32usbcsc.h>
       
    32 #else
       
    33 #include <dummyusbsclddapi.h>
       
    34 #include <usb/testncm/ethinter.h>
       
    35 #endif
       
    36 
       
    37 #include "ncmntbbuilder.h"
       
    38 #include "ncmpktdrvcommon.h"
       
    39 
       
    40 
       
    41 class CNcmDataInterface;
       
    42 class RDevUsbcScClient;
       
    43 class CNcmBufferManager;
       
    44 class CNcmNtbBuildPolicy;
       
    45 
       
    46 
       
    47 NONSHARABLE_CLASS(MNcmNtbBuildObserver)
       
    48     {
       
    49 public:    
       
    50     /**
       
    51     * send a NTB out, this is interface with CNtbBuilder
       
    52     *
       
    53     * @param aBuffer contain a whole NTB.
       
    54     */
       
    55     virtual void SendNtbPayload(TNcmBuffer& aBuffer) = 0;
       
    56     };
       
    57 
       
    58 
       
    59 
       
    60 /**
       
    61 Responsible for sending Ncm packet data
       
    62 */
       
    63 
       
    64 NONSHARABLE_CLASS(CNcmDataSender) : public CActive, 
       
    65                                     public MNcmNtbBuildObserver
       
    66 
       
    67     {
       
    68 public:
       
    69     static CNcmDataSender* NewL(RDevUsbcScClient& aPort, CNcmDataInterface& aParent);
       
    70     ~CNcmDataSender();
       
    71 
       
    72 public:
       
    73     /** derived from MNcmNtbBuildObserver */
       
    74     void SendNtbPayload(TNcmBuffer& aBuffer);
       
    75 
       
    76 public:    
       
    77     /**
       
    78      * change NtbInMax size
       
    79      *
       
    80      * @param aSize, new NtbInMax size
       
    81      * @param aIsAltZero, is alternate setting 0
       
    82      * @return KErrNone           if success, 
       
    83      *         KErrArgument       if the aSize is bigger than 65535, 
       
    84      *           KErrUnknown        if aSize is too bigger and can't create enough buffer block
       
    85      */
       
    86     TInt SetNtbInMaxSize(TInt aSize, TBool aIsAltZero=ETrue);
       
    87     void RunL();
       
    88     void Start();
       
    89     /**
       
    90      * send a ethernet frame
       
    91      *
       
    92      * @param aPacket, the ethernet frame
       
    93      * @return KErrNone            if success, 
       
    94      *         KErrNotReady        if sender is not started.
       
    95      *         KErrCongestion      if there is less buffers, need to start flow control.  
       
    96      */    
       
    97     TInt Send(RMBufChain& aPacket);
       
    98     void GetNtbParam(TNcmNtbInParam& aParam);
       
    99     void Stop();
       
   100     TInt SetInEpBufferSize(TUint aSize);		
       
   101     inline TInt NtbInMaxSize(); 
       
   102   
       
   103 private:
       
   104     CNcmDataSender(RDevUsbcScClient& aPort, CNcmDataInterface& aParent);
       
   105     void ConstructL();
       
   106     void SendNtbComplete();
       
   107     TInt StartNewNtb();
       
   108     void DoCancel();
       
   109         
       
   110 private:
       
   111     RDevUsbcScClient&           iPort;
       
   112     CNcmDataInterface&          iParent;
       
   113     /**
       
   114     * LDD Endpoint buffer for in NCM in endpoint
       
   115     */    
       
   116     TEndpointBuffer             iEpOut;
       
   117     /**
       
   118     * store the buffers to be sent to LDD
       
   119     */    
       
   120     RArray<TNcmBuffer>          iTxArray;
       
   121     /**
       
   122     * store the buffer is on sending
       
   123     */
       
   124     TNcmBuffer                  iSendingBuffer;
       
   125     /**
       
   126     * there is a buffer currenly on sending
       
   127     */
       
   128     TBool                       iIsSending;
       
   129     TBool                       iStarted;
       
   130     CNcmNtbBuilder*             iNtbBuilder;
       
   131     CNcmBufferManager*          iBufferManager;
       
   132     CNcmNtbBuildPolicy*         iBuildPolicy;
       
   133     /**
       
   134     * networking may send packet when data sender is not started, use this to determin if do send resuming when start
       
   135     */
       
   136     TBool                       iStopSending;
       
   137     
       
   138     };
       
   139 
       
   140 // Inline functions
       
   141 #include "ncmdatasender.inl"
       
   142 
       
   143 #endif //NCMDATASENDER_H