bluetooth/btstack/linkmgr/AclDataQController.h
changeset 0 29b1cd4cb562
child 16 9f17f914e828
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef _ACLDATAQCONTROLLER_H
       
    17 #define _ACLDATAQCONTROLLER_H
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <bttypes.h>
       
    21 
       
    22 class CAclDataQ;
       
    23 struct TDataQConnectionInfo;
       
    24 class CACLDataItem;
       
    25 class CLinkMgrProtocol;
       
    26 class CLinkMuxer;
       
    27 class CHCIFacade;
       
    28 
       
    29 /**
       
    30 	Controller of the ACL data Q and of the pending packet list.
       
    31 	This object holds in effect the model of how the HC operates its data 
       
    32 	pool, knows when ACL data are ready to be send-off for transmission and 
       
    33 	accounts for the ones pending transmission of the air interface.
       
    34 */
       
    35 NONSHARABLE_CLASS(CACLDataQController) : public CBase
       
    36 	{
       
    37 public:
       
    38 	static CACLDataQController* NewL(CLinkMgrProtocol& aProtocol,
       
    39 		CLinkMuxer& aMuxer,
       
    40 		TUint16 aBufSize,
       
    41 		TUint16 aFrameOverhead,
       
    42 		TUint aNumBufs);
       
    43 	~CACLDataQController();
       
    44 
       
    45 public:
       
    46 	void InitialDataCredits(TUint16 aCredits);
       
    47 	void AddItem(CACLDataItem& aACLFrame);
       
    48 	TBool IssueNextACLDataFragment();
       
    49 	void GetBufferInfo(TUint16& aBufSize, TUint& aNumBufs);
       
    50 	void GetDataQRecords(TUint& aQFillLevel, TUint16& aCredits);
       
    51 	CACLDataItem* GetFreeItem();
       
    52 
       
    53 	TInt SetFlushInProgress(THCIConnHandle aConnH);
       
    54 	void FlushComplete(TInt aErr, THCIConnHandle aConnH);
       
    55 	void FlushOccurred(THCIConnHandle aConnH); // TODO: not actually called by HCI facade
       
    56 	TInt ACLLogicalLinkUp(THCIConnHandle aConnH, TBool aIsParked);
       
    57 	void ACLLogicalLinkDown(THCIConnHandle aConnH);
       
    58 	void SetParked(THCIConnHandle aConnH, TBool aParked);
       
    59 	void CompletedPackets(THCIConnHandle aConnH, TUint16 aNo);
       
    60 
       
    61 private:
       
    62 	CACLDataQController(CHCIFacade& aHCIFacade, CLinkMuxer& aMuxer);
       
    63 	void ConstructL(CLinkMgrProtocol& aProtocol, TUint16 aBufSize, TUint16 aFrameOverhead, TUint aNumBufs);
       
    64 	
       
    65 	TInt FindConnection(THCIConnHandle aConnH);
       
    66 	TBool AnotherPacketAllowed(TDataQConnectionInfo& aRecord);
       
    67 	TBool SendItem(CACLDataItem& aItem);
       
    68 	static TBool LinkMatch(const TDataQConnectionInfo& aA, const TDataQConnectionInfo& aB);
       
    69 	THCIConnHandle HighestPriority();
       
    70 
       
    71 private: // owned
       
    72 	CAclDataQ*	iDataQ;
       
    73 	
       
    74 	// from HC, how many ACL packets we can send at any one time (varies 
       
    75 	// according to how many are pending NumberOfCompletedPackets)
       
    76 	TUint16		iDataCredits;
       
    77 
       
    78 	RArray<TDataQConnectionInfo> iAclConns;
       
    79 
       
    80 	// This is the index into iAclConns of the connection which last sent an 
       
    81 	// item. This is used when finding the next link to allow to send, to 
       
    82 	// implement fairer sharing of the link (otherwise connections near the 
       
    83 	// start of the array get precedence over connections near the end).
       
    84 	TUint iIndexOfLastSendingConn;
       
    85 
       
    86 	TUint16     iNumControllerBufs;
       
    87 
       
    88 private: // unowned
       
    89 	CLinkMuxer&	iLinkMuxer;
       
    90 	CHCIFacade& iHCIFacade;
       
    91 	};
       
    92 
       
    93 struct TDataQConnectionInfo
       
    94 	{
       
    95 public:
       
    96 	THCIConnHandle	iConnH;
       
    97 
       
    98 	// Number of packets that have been put on the queue but not yet sent over 
       
    99 	// the air.
       
   100 	TUint16			iPacketsQueued;
       
   101 
       
   102 	// Number of packets on the air but not yet reported sent. 
       
   103 	// (0-iPacketsPending) is the connection's priority when working out which 
       
   104 	// connection to send from next.
       
   105 	TUint16			iPacketsPending;
       
   106 
       
   107 	TBool			iParked;
       
   108 	TBool			iFlushInProgress;
       
   109 	};
       
   110 
       
   111 #endif // _ACLDATAQCONTROLLER_H