--- a/bluetooth/btstack/l2cap/l2sap.cpp Thu Sep 23 17:06:47 2010 +0300
+++ b/bluetooth/btstack/l2cap/l2sap.cpp Wed Oct 13 16:20:29 2010 +0300
@@ -344,32 +344,6 @@
LOGBTDEVADDR(iRemoteDev);
}
-TUint CL2CAPConnectionSAP::GetOptimalMTUSize(TUint aMTU, TUint aPduSize, TBool aBasicMode) const
- {
- LOG_FUNC
-
- // If the negotiated MTU minus any overhead will fit into the optimal PDU then that
- // is the optimal MTU. The overhead will differ for basic and non-basic mode, for basic mode
- // we have to consider the SDU overhead as there is no fragment overhead and for non-basic we
- // consider the PDU overhead only (the additional SDU overhead is taken account of later if
- // more than one PDU is required for the optimal MTU).
- TUint optimalMTU = aMTU;
-
- // Calculate the size of the MTU + any overhead assuming that the MTU is not segmented
- TUint singlePduSize = aBasicMode ? (aMTU + CL2CapSDU::GetSDUOverhead(aBasicMode)) : aMTU;
-
- // If the unsegmented MTU + overhead can fit into the optimal PDU size then no
- // further calculation is required
- if(singlePduSize > aPduSize)
- {
- // The MTU will need to be segmented / fragmented (depending on L2CAP mode).
- // Calculate an MTU size that will be a factor of the PDU size.
- optimalMTU = aMTU - ((aMTU + CL2CapSDU::GetSDUOverhead(aBasicMode)) % aPduSize);
- }
-
- return optimalMTU;
- }
-
TInt CL2CAPConnectionSAP::SAPSetOption(TUint aLevel, TUint aName, const TDesC8& aOption)
{
LOG_FUNC
@@ -503,42 +477,35 @@
case KL2CAPOutboundMTUForBestPerformanceWithRestriction:
// get the restriction value
- if((aOption.Length() == sizeof(TInt)) && iL2CapDataQueue && iL2CapSAPSignalHandler)
+ if(aOption.Length() == sizeof(TInt))
{
- val = *reinterpret_cast<const TInt*>(aOption.Ptr());
-
- // Ensure that the restriction is less then the current MTU.
- if (val < iL2CapDataQueue->MaxOutgoingMTU())
+ if(iL2CapSAPSignalHandler && iL2CapDataQueue)
{
- // We now need to recalculate the optimal PDU size for the restricted MTU as
- // this is used in the calculation of the optimal MTU
- TPckgBuf<TInt> buf;
- TInt err = iL2CapSAPSignalHandler->GetOption(KSolBtACL, ELMOutboundACLSize, buf);
+ val = *reinterpret_cast<const TInt*>(aOption.Ptr());
- TInt optimalPduSize = HL2CapPDU::GetPDUOrFragmentSize(val, iL2CapDataQueue->MaximumPDUSize(), (err == KErrNone) ? buf() : 0, iL2CapDataQueue->IsBasicDataVersion());
+ TPckgBuf<TInt> aclBufSize;
+ TInt getAclBufSizeErr = iL2CapSAPSignalHandler->GetOption(KSolBtACL, ELMOutboundACLSize, aclBufSize);
- // update the data queue to use the new optimal PDU size from now on
- iL2CapDataQueue->SetOptimalPDUSize(optimalPduSize);
+ TRAP(rValue, val = iL2CapDataQueue->GetOptimalMTUSizeL(val, (getAclBufSizeErr == KErrNone) ? aclBufSize() : 0));
+ aOption = TPtrC8(reinterpret_cast<TUint8*>(&val), sizeof(TInt));
}
else
{
- // can't increase the MTU at this stage so just use the existing MTU
- val = iL2CapDataQueue->MaxOutgoingMTU();
+ rValue = KErrNotReady;
}
-
- // work out the optimal MTU
- val = GetOptimalMTUSize(val, iL2CapDataQueue->OptimalPDUSize(), iL2CapDataQueue->IsBasicDataVersion());
- aOption = TPtrC8(reinterpret_cast<TUint8*>(&val), sizeof(TInt));
- }
+ }
+ else
+ {
+ rValue = KErrArgument;
+ }
break;
case KL2CAPOutboundMTUForBestPerformance: //equals KL2CAPGetOutboundMTU
if(aOption.Length() == sizeof(TInt))
{
- if(iL2CapDataQueue && iL2CapSAPSignalHandler)
+ if(iL2CapDataQueue)
{
- // work out the optimal MTU
- val = GetOptimalMTUSize(iL2CapDataQueue->MaxOutgoingMTU(), iL2CapDataQueue->OptimalPDUSize(), iL2CapDataQueue->IsBasicDataVersion());
+ TRAP(rValue, val = iL2CapDataQueue->GetOptimalMTUSizeL());
aOption = TPtrC8(reinterpret_cast<TUint8*>(&val), sizeof(TInt));
}
else
@@ -1089,6 +1056,10 @@
{
dataConfig->SetChannelPriority(iChannelPriority);
}
+
+ TPckgBuf<TInt> aclBufSize;
+ TInt getAclBufSizeErr = iL2CapSAPSignalHandler->GetOption(KSolBtACL, ELMOutboundACLSize, aclBufSize);
+
TRAP(rerr, iL2CapDataQueue = CL2CapSDUQueue::NewL(*this,
aLocalPort,
aRemotePort,
@@ -1099,15 +1070,9 @@
aConfig.OutgoingFlushTimeout().Negotiated().FlushTimeoutDuration(),
aConfig.OutgoingMTU().Negotiated().MTU(),
aConfig.IncomingMTU().Negotiated().MTU(),
+ (getAclBufSizeErr == KErrNone) ? aclBufSize() : 0,
// Allow ourselves to drop SDUs we can't assemble if channel mode is not Reliable.
!TRetransmissionAndFlowControlOption::IsModeReliable(fec.IncomingLinkMode())));
-
- // Set the optimal PDU size that the data controller should use.
- TPckgBuf<TInt> buf;
- TInt err = iL2CapSAPSignalHandler->GetOption(KSolBtACL, ELMOutboundACLSize, buf);
-
- TInt optimalPduSize = HL2CapPDU::GetPDUOrFragmentSize(iL2CapDataQueue->MaxOutgoingMTU(), iL2CapDataQueue->MaximumPDUSize(), (err == KErrNone) ? buf() : 0, iL2CapDataQueue->IsBasicDataVersion());
- iL2CapDataQueue->SetOptimalPDUSize(optimalPduSize);
}
else
{