wlan_bearer/wlannwif/etherpkt/sender_hw.cpp
changeset 0 c40eb8fe8501
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 "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:  Implements sender class for target
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 15 %
       
    20 */
       
    21 
       
    22 #include "am_debug.h"
       
    23 #include "sender_hw.h"
       
    24 #include "WlanProto.h"
       
    25 #include "carddrv.h"
       
    26 
       
    27 // Protocol blocks sending if it receives a return <= 0
       
    28 // This value should be propogated up through the stack
       
    29 const TInt KStopSending		= 0;
       
    30 const TInt KContinueSending	= 1;
       
    31 
       
    32 // ============================ MEMBER FUNCTIONS ===============================
       
    33 
       
    34 // ---------------------------------------------------------
       
    35 // CSender::Send()
       
    36 // ---------------------------------------------------------
       
    37 //
       
    38 TInt CSender::Send( RMBufChain& aPacket )
       
    39     {
       
    40 
       
    41 	TInt ret( KContinueSending );
       
    42 	
       
    43     TDataBuffer* txDataBuffer = iParent->iCard.AllocTxBuffer( 
       
    44         aPacket.Length()
       
    45         // size of the packet's UP value
       
    46         - 1  );
       
    47     
       
    48     if ( txDataBuffer )
       
    49         {
       
    50         //First buffer contains UP value
       
    51         RMBuf* rmbuf = aPacket.First();
       
    52         TInt num = aPacket.NumBufs();
       
    53     
       
    54         TUint8 UPValue = rmbuf->Get();
       
    55         
       
    56         txDataBuffer->SetUserPriority( UPValue );
       
    57     
       
    58         //Frame starts from second buffer
       
    59         rmbuf = rmbuf->Next();
       
    60         num--;
       
    61     
       
    62         for( TInt i(0); i < num; i++ )
       
    63             {
       
    64             txDataBuffer->AppendBuffer( rmbuf->Ptr(), rmbuf->Length() );
       
    65             
       
    66             rmbuf = rmbuf->Next();
       
    67             }
       
    68         
       
    69         if ( !iParent->iCard.AddTxFrame( txDataBuffer ) )
       
    70             {
       
    71             DEBUG("CSender::Send: AddTxPacket returned false => stop flow");
       
    72             ret = KStopSending;
       
    73             iStopSending = ETrue;
       
    74             RequestResumeTx();
       
    75             }
       
    76         }
       
    77     else
       
    78         {
       
    79         DEBUG("CSender::Send: Tx buf could't be allocated => stop flow");
       
    80         
       
    81         // in this case the Tx packet could possibly be kept - if seen
       
    82         // feasible - until ResumeTx completes and then re-submitted 
       
    83         
       
    84         ret = KStopSending;
       
    85         iStopSending = ETrue;
       
    86         RequestResumeTx();
       
    87         }
       
    88 	
       
    89     aPacket.Free();
       
    90 	
       
    91 	return ret;
       
    92     }
       
    93 
       
    94 // ---------------------------------------------------------
       
    95 // CSender::RequestResumeTx()
       
    96 // ---------------------------------------------------------
       
    97 //
       
    98 void CSender::RequestResumeTx()
       
    99     {
       
   100     if ( !iReqPending )
       
   101         {
       
   102         DEBUG("CSender::RequestResumeTx()");
       
   103     
       
   104         iReqPending = ETrue;
       
   105     	SetActive();	
       
   106         iParent->iCard.ResumeTx( iStatus );
       
   107         }
       
   108     }
       
   109 
       
   110 // ---------------------------------------------------------
       
   111 // CSender::RunL()
       
   112 // ---------------------------------------------------------
       
   113 //
       
   114 void CSender::RunL()
       
   115     {
       
   116     // Write completion from the LDD
       
   117 	DEBUG("CSender::RunL()");
       
   118 	
       
   119 	iReqPending = EFalse;
       
   120 
       
   121 	if (iStopSending)
       
   122 	    {
       
   123 		DEBUG("CSender::RunL(): resume flow");
       
   124 		iStopSending = EFalse;
       
   125 		iParent->iParent->ResumeSending();
       
   126 		}
       
   127 	else
       
   128 	    {
       
   129 	    DEBUG("CSender::RunL(): flow hasn't been stopped");
       
   130 	    }
       
   131     }