bluetooth/btstack/linkmgr/AclDataQController.cpp
branchRCL_3
changeset 16 9f17f914e828
parent 0 29b1cd4cb562
child 23 5b153be919d4
equal deleted inserted replaced
14:f8503e232b0c 16:9f17f914e828
     1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 1999-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    22 #include <bluetooth/logger.h>
    22 #include <bluetooth/logger.h>
    23 #include "AclDataQController.h"
    23 #include "AclDataQController.h"
    24 #include "linkmgr.h"
    24 #include "linkmgr.h"
    25 #include "AclDataQ.h"
    25 #include "AclDataQ.h"
    26 #include "hcifacade.h"
    26 #include "hcifacade.h"
       
    27 #include "hostmbufpool.h"
       
    28 #include "linkflowcontrol.h"
       
    29 #include "linkconsts.h"
    27 
    30 
    28 #ifdef __FLOG_ACTIVE
    31 #ifdef __FLOG_ACTIVE
    29 _LIT8(KLogComponent, LOG_COMPONENT_LINKMGR);
    32 _LIT8(KLogComponent, LOG_COMPONENT_LINKMGR);
    30 #endif
    33 #endif
    31 
    34 
    48 
    51 
    49 	CACLDataQController* self = new(ELeave) CACLDataQController(aProtocol.HCIFacade(), aMuxer);
    52 	CACLDataQController* self = new(ELeave) CACLDataQController(aProtocol.HCIFacade(), aMuxer);
    50 	CleanupStack::PushL(self);
    53 	CleanupStack::PushL(self);
    51 	self->ConstructL(aProtocol, aBufSize, aFrameOverhead, aNumBufs);
    54 	self->ConstructL(aProtocol, aBufSize, aFrameOverhead, aNumBufs);
    52 	CleanupStack::Pop(self);
    55 	CleanupStack::Pop(self);
    53 
       
    54 	LOG1(_L("CACLDataQController::NewL self = 0x%08x"), self);
       
    55 	return self;
    56 	return self;
    56 	}
    57 	}
    57 
    58 
    58 CACLDataQController::CACLDataQController(CHCIFacade& aHCIFacade,
    59 CACLDataQController::CACLDataQController(CHCIFacade& aHCIFacade,
    59 										 CLinkMuxer& aMuxer)
    60 										 CLinkMuxer& aMuxer)
    65 	}
    66 	}
    66 
    67 
    67 CACLDataQController::~CACLDataQController()
    68 CACLDataQController::~CACLDataQController()
    68 	{
    69 	{
    69 	LOG_FUNC
    70 	LOG_FUNC
    70 
    71 	
       
    72 #ifdef HOSTCONTROLLER_TO_HOST_FLOW_CONTROL
       
    73 	delete iMBufPool;
       
    74 #endif
       
    75 	
    71 	delete iDataQ;
    76 	delete iDataQ;
    72 	iAclConns.Reset();
    77 	iAclConns.Reset();
    73 	iAclConns.Close();
    78 	iAclConns.Close();
    74 	}
    79 	}
    75 
    80 
    79 									 TUint aNumBufs)
    84 									 TUint aNumBufs)
    80 	{
    85 	{
    81 	LOG_FUNC
    86 	LOG_FUNC
    82 
    87 
    83 	iDataQ = CAclDataQ::NewL(aProtocol, aNumBufs, aBufSize, aFrameOverhead);
    88 	iDataQ = CAclDataQ::NewL(aProtocol, aNumBufs, aBufSize, aFrameOverhead);
       
    89 	
    84 
    90 
    85 #ifdef PROXY_COMMUNICATES
    91 #ifdef PROXY_COMMUNICATES
    86 	LOG(_L("\tPROXY_COMMUNICATES defined- reserving slots for broadcast channel"));
    92 	LOG(_L("\tPROXY_COMMUNICATES defined- reserving slots for broadcast channel"));
    87 
    93 
    88 	// Reserve BC one now
    94 	// Reserve BC one now
    89 	User::LeaveIfError(ACLLogicalLinkUp(KHCIBroadcastHandle, EFalse));
    95 	User::LeaveIfError(ACLLogicalLinkUp(KHCIBroadcastHandle, EFalse));
       
    96 #endif
       
    97 	
       
    98 #ifdef HOSTCONTROLLER_TO_HOST_FLOW_CONTROL
       
    99 	LOG(_L8("\tHOSTCONTROLLER_TO_HOST_FLOW_CONTROL defined- creating buffer pool"));
       
   100 	iMBufPool = CHostMBufPool::NewL(aProtocol.HCIFacade().CommandQController());
    90 #endif
   101 #endif
    91 	}
   102 	}
    92 
   103 
    93 void CACLDataQController::InitialDataCredits(TUint16 aCredits)
   104 void CACLDataQController::InitialDataCredits(TUint16 aCredits)
    94 /**
   105 /**
   425 	{
   436 	{
   426 	LOG_FUNC
   437 	LOG_FUNC
   427 	LOG1(_L("CACLDataQController::ACLLogicalLinkDown aConnH = %d"), 
   438 	LOG1(_L("CACLDataQController::ACLLogicalLinkDown aConnH = %d"), 
   428 		aConnH);
   439 		aConnH);
   429 
   440 
       
   441 #ifdef HOSTCONTROLLER_TO_HOST_FLOW_CONTROL
       
   442 	if(iMBufPool)
       
   443 		{
       
   444 		iMBufPool->InvalidateByConnH(aConnH);
       
   445 		// the packet completions should probably move to the iAclConns model
       
   446 		// to clean up this code.
       
   447 		}
       
   448 #endif // HOSTCONTROLLER_TO_HOST_FLOW_CONTROL
       
   449 
   430 	TInt connection = FindConnection(aConnH);
   450 	TInt connection = FindConnection(aConnH);
   431 		
   451 		
   432 	if ( connection == KErrNotFound )
   452 	if ( connection == KErrNotFound )
   433 		{
   453 		{
   434 		LOG(_L("CACLDataQController::ACLLogicalLinkDown (Connection not found)."));
   454 		LOG(_L("CACLDataQController::ACLLogicalLinkDown (Connection not found)."));
   618 		}
   638 		}
   619 
   639 
   620 	return rerr;
   640 	return rerr;
   621 	}
   641 	}
   622 
   642 
       
   643 RMBufChain CACLDataQController::PopulateInboundBufferL(THCIConnHandle aConnH, TUint8 aFlag, const TDesC8& aData)
       
   644 	{
       
   645 	LOG_FUNC
       
   646 	// make a new chain consisting of Flag(1st octet) followed by Data.
       
   647 	RMBufChain aclData;
       
   648 	static const TInt KFlagHeaderOffset = 0;
       
   649 	
       
   650 #ifdef HOSTCONTROLLER_TO_HOST_FLOW_CONTROL
       
   651 	// Check what flow control mode is in operation
       
   652 	TFlowControlMode flowControl = iLinkMuxer.FlowControlMode();
       
   653 	TBool ctrlerToHost = (flowControl == ETwoWayFlowControlEnabled) || (flowControl == EFlowControlFromHostControllerOnly);
       
   654 	if(ctrlerToHost)
       
   655 		{
       
   656 		__ASSERT_DEBUG(iMBufPool, Panic(ELinkMgrFlowControlChangeOfMind));
       
   657 		aclData = iMBufPool->TakeBufferL(aConnH);
       
   658 		aclData.CopyIn(aData, KLinkMgrIncomingBufferHeaderSize);
       
   659 		// return the reserved MBufs we didn't need to the global pool
       
   660 		aclData.TrimEnd(aData.Length() + KLinkMgrIncomingBufferHeaderSize);
       
   661 		}
       
   662 	else
       
   663 #endif // HOSTCONTROLLER_TO_HOST_FLOW_CONTROL
       
   664 		{
       
   665 		aclData.CreateL(aData, KLinkMgrIncomingBufferHeaderSize);
       
   666 		}
       
   667 	
       
   668 	aclData.First()->Ptr()[KFlagHeaderOffset] = aFlag;
       
   669 	
       
   670 	return aclData;
       
   671 	}
       
   672 
       
   673 void CACLDataQController::NoExplicitInboundPoolNeeded()
       
   674 	{
       
   675 	LOG_FUNC
       
   676 #ifdef HOSTCONTROLLER_TO_HOST_FLOW_CONTROL
       
   677 	delete iMBufPool;
       
   678 	iMBufPool = NULL;
       
   679 #endif // HOSTCONTROLLER_TO_HOST_FLOW_CONTROL
       
   680 	}
       
   681 
   623 //
   682 //
   624 // End of file
   683 // End of file