usbmgmt/usbmgr/device/classdrivers/ncm/classimplementation/ncmpktdrv/pktdrv/src/ncmpktdrv.cpp
branchRCL_3
changeset 16 012cc2ee6408
parent 15 f92a4f87e424
equal deleted inserted replaced
15:f92a4f87e424 16:012cc2ee6408
     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 #include "ncmpktdrv.h"
       
    19 
       
    20 #include "ncmengine.h"
       
    21 #include "ncmserver.h"
       
    22 #include "OstTraceDefinitions.h"
       
    23 #ifdef OST_TRACE_COMPILER_IN_USE
       
    24 #include "ncmpktdrvTraces.h"
       
    25 #endif
       
    26 
       
    27 
       
    28 /**
       
    29 Constructor. Packet Driver object.
       
    30 */
       
    31 CNcmPktDrv::CNcmPktDrv(CPktDrvFactory& aFactory) : CPktDrvBase(aFactory)
       
    32     {
       
    33     }
       
    34 
       
    35 /**
       
    36 Destructor.
       
    37 */
       
    38 CNcmPktDrv::~CNcmPktDrv()
       
    39     {
       
    40     delete iNcmServer;
       
    41     delete iEngine;
       
    42     }
       
    43 
       
    44 /**
       
    45 Construction of the CNcmDrvBase object
       
    46 @param aParent Pointer to the CLANLinkCommon class.
       
    47 */
       
    48 void CNcmPktDrv::ConstructL(CLANLinkCommon* aParent)
       
    49     {
       
    50     OstTraceFunctionEntry0(CNCMPKTDRV_CONSTRUCTL);
       
    51 
       
    52     iParent = aParent;
       
    53     iEngine = CNcmEngine::NewL(*this);
       
    54     iNcmServer = CNcmServer::NewL(*iEngine);
       
    55     }
       
    56 
       
    57 /**
       
    58 Call to LDD or subordinate object to start/initialise the Physical device
       
    59 */
       
    60 TInt CNcmPktDrv::StartInterface()
       
    61     {
       
    62     OstTraceFunctionEntry0(CNCMPKTDRV_STARTINTERFACE);
       
    63 
       
    64     TRAPD(err, iParent->FoundMACAddrL());
       
    65     if (KErrNone != err)
       
    66         {
       
    67         return err;
       
    68         }
       
    69 
       
    70     OstTrace0(TRACE_NORMAL, CNCMPKTDRV_STARTINTERFACE_DUP02, "CNcmPktDrv, calling LinkLayerUp");
       
    71     iParent->LinkLayerUp();
       
    72     OstTraceFunctionExit0(CNCMPKTDRV_STARTINTERFACE_DUP01);
       
    73     return err;
       
    74     }
       
    75 
       
    76 /**
       
    77 Call to LDD or subordinate object to stop/de-initialise the Physical device
       
    78 */
       
    79 TInt CNcmPktDrv::StopInterface()
       
    80     {
       
    81     OstTraceFunctionEntry0(CNCMPKTDRV_STOPINTERFACE);
       
    82 
       
    83     iEngine->Stop();
       
    84 
       
    85     return KErrNone;
       
    86     }
       
    87 
       
    88 /**
       
    89 Call to LDD or subordinate object to reset/re-initialise the Physical device
       
    90 */
       
    91 TInt CNcmPktDrv::ResetInterface()
       
    92     {
       
    93     return KErrNone;
       
    94     }
       
    95 
       
    96 /**
       
    97 EtherII MAC layer comments say we should free the packet buffer
       
    98 RMBuf could contain a chain so get into a contiguous buffer
       
    99 @param aPacket Reference to a chain of data buffers to be passed to the line.
       
   100 @return 0 Tells the higher layer to send no more data.
       
   101         1 Tells higher layer that it can send more data.
       
   102 */
       
   103 TInt CNcmPktDrv::Send(RMBufChain &aPacket)
       
   104     {
       
   105     TInt error = iEngine->Send(aPacket);
       
   106     aPacket.Free();
       
   107 
       
   108     return error;
       
   109     }
       
   110 
       
   111 /**
       
   112 Read the Available data.
       
   113 @param aBuffer A Reference to a buffer holding data.
       
   114 */
       
   115 void CNcmPktDrv::ReceiveEthFrame(RMBufPacket& aPacket)
       
   116     {
       
   117     iParent->Process(aPacket);
       
   118     }
       
   119 
       
   120 /**
       
   121 Resume Sending is a notification call into NIF from the lower layer telling the NIF that a
       
   122 previous sending congestion situation has been cleared and it can accept more downstack data.
       
   123 */
       
   124 void CNcmPktDrv::ResumeSending()
       
   125     {
       
   126     iParent->ResumeSending();
       
   127     }
       
   128 
       
   129 /**
       
   130 Call to LDD or subordinate object to set the receive mode of the LAN Device
       
   131 @param aMode The mode to be set for the LAN Device.
       
   132 @return KErrNotSupported LAN Device does not support.
       
   133 */
       
   134 TInt CNcmPktDrv::SetRxMode(TRxMode /*aMode*/)
       
   135     {
       
   136     return KErrNotSupported;
       
   137     }
       
   138 
       
   139 /**
       
   140 Call to LDD or subordinate object to Get the receive mode of the LAN Device
       
   141 @return KErrNotSupported LAN Device does not support.
       
   142 */
       
   143 TInt CNcmPktDrv::GetRxMode() const
       
   144     {
       
   145     return KErrNotSupported;
       
   146     }
       
   147 
       
   148 /**
       
   149 Call to LDD or subordinate object to get the Hardware address of the LAN Device
       
   150 @return NULL Failure.
       
   151         (NULL Terminated Binary String) The Hardware Address of the interface. LAN Device
       
   152         Specific
       
   153 */
       
   154 TUint8* CNcmPktDrv::GetInterfaceAddress()const
       
   155     {
       
   156     return iEngine->InterfaceAddress();
       
   157     }
       
   158 
       
   159 /**
       
   160 Call to LDD or subordinate object to set the Hardware address of the LAN Device.
       
   161 @param THWAddr Address of where the Multicast list should be written.
       
   162 @return KErrNone         if Successful
       
   163         KErrNotSupported LAN Device does not support.
       
   164         Implementation specific Error Code  Failure
       
   165 */
       
   166 TInt CNcmPktDrv::SetInterfaceAddress(const THWAddr&)
       
   167     {
       
   168     return KErrNotSupported;
       
   169     }
       
   170 
       
   171 /**
       
   172 Call to LDD or subordinate object to retrieve the Multicast List from the LAN Device
       
   173 @param aAddr Address of where the Multicast list should be written.
       
   174 @param n Output Parameter , number of Addresses written
       
   175 @return KErrNone         if Successful
       
   176         KErrNotSupported LAN Device does not support.
       
   177         Implementation specific Error Code  Failure
       
   178 */
       
   179 TInt CNcmPktDrv::GetMulticastList(const THWAddr* /*aAddr*/, TInt& /*n*/) const
       
   180     {
       
   181     return KErrNotSupported;
       
   182     }
       
   183 
       
   184 /**
       
   185 Call to LDD or subordinate object to set the Multicast List for the LAN Device.
       
   186 @param aAddr Address of where the Multicast list should be written.
       
   187 @param n Output Parameter , number of Addresses written
       
   188 @return KErrNone         if Successful
       
   189         KErrNotSupported LAN Device does not support.
       
   190         Implementation specific Error Code  Failure
       
   191 */
       
   192 TInt CNcmPktDrv::SetMulticastList(const THWAddr* /*aAddr*/, TInt /*n*/)
       
   193     {
       
   194     return KErrNotSupported;
       
   195     }
       
   196 
       
   197 /**
       
   198 Call to LDD or subordinate object to power up the LAN Device.
       
   199 @return KErrNone         if Successful
       
   200         KErrNotSupported LAN Device does not support.
       
   201         Implementation specific Error Code  Failure
       
   202 */
       
   203 TInt CNcmPktDrv::InterfacePowerUp()
       
   204     {
       
   205     return KErrNotSupported;
       
   206     }
       
   207 
       
   208 /**
       
   209 Call to LDD or subordinate object to power down the LAN Device
       
   210 @return KErrNone         if Successful
       
   211         KErrNotSupported LAN Device does not support.
       
   212         Implementation specific Error Code  Failure
       
   213 */
       
   214 TInt CNcmPktDrv::InterfacePowerDown()
       
   215     {
       
   216     return KErrNotSupported;
       
   217     }
       
   218 
       
   219 /**
       
   220 Call to LDD or subordinate object to suspend the LAN Device.
       
   221 @return KErrNone         if Successful
       
   222         KErrNotSupported LAN Device does not support.
       
   223         Implementation specific Error Code  Failure
       
   224 */
       
   225 TInt CNcmPktDrv::InterfaceSleep()
       
   226     {
       
   227     return KErrNotSupported;
       
   228     }
       
   229 
       
   230 /**
       
   231 Call to LDD or subordinate object to resume the LAN Device.
       
   232 @return KErrNone         if Successful
       
   233         KErrNotSupported LAN Device does not support.
       
   234         Implementation specific Error Code  Failure
       
   235 */
       
   236 TInt CNcmPktDrv::InterfaceResume()
       
   237     {
       
   238     return KErrNotSupported;
       
   239     }
       
   240 
       
   241 /**
       
   242 Receive notifications from agent
       
   243 */
       
   244 TInt CNcmPktDrv::Notification(enum TAgentToNifEventType aEvent, void* aInfo)
       
   245     {
       
   246     TInt retval = KErrNotSupported;
       
   247 
       
   248     return retval;
       
   249     }
       
   250 
       
   251 /**
       
   252 Receive Control() calls from agent/nifman/connection
       
   253 */
       
   254 TInt CNcmPktDrv::Control(TUint /*aLevel*/,TUint /*aName*/,TDes8& /*aOption*/, TAny* /*aSource*/)
       
   255     {
       
   256     return KErrNotSupported;
       
   257     }
       
   258 
       
   259 /**
       
   260 Report the progress of packet driver to NCM Class Controller for fatal error
       
   261 */
       
   262 void CNcmPktDrv::FatalErrorNotification(TInt aError)
       
   263     {
       
   264     iParent->IfProgress(ENcmPktDrvFatalError, aError);
       
   265     }
       
   266 
       
   267 #ifdef __OVER_DUMMYUSBSCLDD__
       
   268 TInt CNcmPktDrv::State() const
       
   269     {
       
   270     return iEngine->State();
       
   271     }
       
   272 #endif
       
   273