Skip to content

Commit 0bda310

Browse files
committed
move CongestionControl related stuff to QUIC_PATH
1 parent ca43676 commit 0bda310

29 files changed

+1377
-655
lines changed

scripts/clog.inputs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
../src/core/stream.h
8989
../src/core/pathid.h
9090
../src/core/connection.h
91+
../src/core/path.h
9192
../src/test/lib/TestHelpers.h
9293
../src/test/lib/TestStream.cpp
9394
../src/test/lib/DataTest.cpp

src/core/ack_tracker.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ QuicAckTrackerAckPacket(
174174
)
175175
{
176176
QUIC_CONNECTION* Connection = QuicAckTrackerGetPacketSpace(Tracker)->Connection;
177+
QUIC_PATH* Path = QuicAckTrackerGetPacketSpace(Tracker)->PathID->Path;
177178
_Analysis_assume_(Connection != NULL);
178179

179180
//
@@ -190,6 +191,7 @@ QuicAckTrackerAckPacket(
190191
// Any time the largest known packet number is greater than the one
191192
// we just received, we consider it reordering.
192193
//
194+
Path->Stats.Recv.ReorderedPackets++;
193195
Connection->Stats.Recv.ReorderedPackets++;
194196
}
195197

src/core/bbr.c

Lines changed: 49 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,10 @@ BbrCongestionControlGetCongestionWindow(
217217
)
218218
{
219219
const QUIC_CONGESTION_CONTROL_BBR* Bbr = &Cc->Bbr;
220-
QUIC_CONNECTION* Connection = QuicCongestionControlGetPathID(Cc)->Connection;
220+
QUIC_PATH* Path = QuicCongestionControlGetPath(Cc);
221221

222222
const uint16_t DatagramPayloadLength =
223-
QuicPathGetDatagramPayloadSize(&Connection->Paths[0]);
223+
QuicPathGetDatagramPayloadSize(Path);
224224

225225
uint32_t MinCongestionWindow = kMinCwndInMss * DatagramPayloadLength;
226226

@@ -278,17 +278,18 @@ BbrCongestionControlIsAppLimited(
278278

279279
_IRQL_requires_max_(DISPATCH_LEVEL)
280280
void
281-
QuicConnLogBbr(
282-
_In_ QUIC_PATHID* const PathID
281+
QuicPathLogBbr(
282+
_In_ QUIC_PATH* const Path
283283
)
284284
{
285-
QUIC_CONGESTION_CONTROL* Cc = &PathID->CongestionControl;
285+
QUIC_CONGESTION_CONTROL* Cc = &Path->CongestionControl;
286286
QUIC_CONGESTION_CONTROL_BBR* Bbr = &Cc->Bbr;
287287

288288
QuicTraceEvent(
289-
ConnBbr,
290-
"[conn][%p] BBR: State=%u RState=%u CongestionWindow=%u BytesInFlight=%u BytesInFlightMax=%u MinRttEst=%lu EstBw=%lu AppLimited=%u",
291-
PathID->Connection,
289+
PathBbr,
290+
"[conn][%p][pathid][%hhu] BBR: State=%u RState=%u CongestionWindow=%u BytesInFlight=%u BytesInFlightMax=%u MinRttEst=%lu EstBw=%lu AppLimited=%u",
291+
Path->PathID->Connection,
292+
Path->PathID->ID,
292293
Bbr->BbrState,
293294
Bbr->RecoveryState,
294295
BbrCongestionControlGetCongestionWindow(Cc),
@@ -358,9 +359,8 @@ BbrCongestionControlLogOutFlowStatus(
358359
_In_ const QUIC_CONGESTION_CONTROL* Cc
359360
)
360361
{
361-
const QUIC_PATHID* PathID = QuicCongestionControlGetPathID(Cc);
362-
const QUIC_CONNECTION* Connection = PathID->Connection;
363-
const QUIC_PATH* Path = PathID->Path;
362+
const QUIC_PATH* Path = QuicCongestionControlGetPath(Cc);
363+
const QUIC_CONNECTION* Connection = Path->PathID->Connection;
364364
const QUIC_CONGESTION_CONTROL_BBR* Bbr = &Cc->Bbr;
365365

366366
QuicTraceEvent(
@@ -387,18 +387,18 @@ BbrCongestionControlUpdateBlockedState(
387387
_In_ BOOLEAN PreviousCanSendState
388388
)
389389
{
390-
QUIC_PATHID* PathID = QuicCongestionControlGetPathID(Cc);
391-
QUIC_CONNECTION* Connection = PathID->Connection;
392-
QuicConnLogOutFlowStats(PathID);
390+
QUIC_PATH* Path = QuicCongestionControlGetPath(Cc);
391+
QuicConnLogOutFlowStats(Path->PathID->Connection);
392+
QuicPathLogOutFlowStats(Path);
393393

394394
if (PreviousCanSendState != BbrCongestionControlCanSend(Cc)) {
395395
if (PreviousCanSendState) {
396-
QuicConnAddOutFlowBlockedReason(
397-
Connection, QUIC_FLOW_BLOCKED_CONGESTION_CONTROL);
396+
QuicPathAddOutFlowBlockedReason(
397+
Path, QUIC_FLOW_BLOCKED_CONGESTION_CONTROL);
398398
} else {
399-
QuicConnRemoveOutFlowBlockedReason(
400-
Connection, QUIC_FLOW_BLOCKED_CONGESTION_CONTROL);
401-
Connection->Send.LastFlushTime = CxPlatTimeUs64(); // Reset last flush time
399+
QuicPathRemoveOutFlowBlockedReason(
400+
Path, QUIC_FLOW_BLOCKED_CONGESTION_CONTROL);
401+
Path->PathID->Connection->Send.LastFlushTime = CxPlatTimeUs64(); // Reset last flush time
402402
return TRUE;
403403
}
404404
}
@@ -451,7 +451,7 @@ BbrCongestionControlOnDataSent(
451451
Bbr->BytesInFlight += NumRetransmittableBytes;
452452
if (Bbr->BytesInFlightMax < Bbr->BytesInFlight) {
453453
Bbr->BytesInFlightMax = Bbr->BytesInFlight;
454-
QuicSendBufferConnectionAdjust(QuicCongestionControlGetPathID(Cc)->Connection);
454+
QuicSendBufferConnectionAdjust(QuicCongestionControlGetPath(Cc));
455455
}
456456

457457
if (Bbr->Exemptions > 0) {
@@ -486,10 +486,10 @@ BbrCongestionControlUpdateRecoveryWindow(
486486
)
487487
{
488488
QUIC_CONGESTION_CONTROL_BBR* Bbr = &Cc->Bbr;
489-
QUIC_PATHID* PathID = QuicCongestionControlGetPathID(Cc);
489+
QUIC_PATH* Path = QuicCongestionControlGetPath(Cc);
490490

491491
const uint16_t DatagramPayloadLength =
492-
QuicPathGetDatagramPayloadSize(PathID->Path);
492+
QuicPathGetDatagramPayloadSize(Path);
493493

494494
CXPLAT_DBG_ASSERT(Bbr->RecoveryState != RECOVERY_STATE_NOT_RECOVERY);
495495

@@ -515,13 +515,13 @@ BbrCongestionControlHandleAckInProbeRtt(
515515
)
516516
{
517517
QUIC_CONGESTION_CONTROL_BBR* Bbr = &Cc->Bbr;
518-
QUIC_PATHID* PathID = QuicCongestionControlGetPathID(Cc);
518+
QUIC_PATH* Path = QuicCongestionControlGetPath(Cc);
519519

520520
Bbr->BandwidthFilter.AppLimited = TRUE;
521521
Bbr->BandwidthFilter.AppLimitedExitTarget = LargestSentPacketNumber;
522522

523523
const uint16_t DatagramPayloadLength =
524-
QuicPathGetDatagramPayloadSize(PathID->Path);
524+
QuicPathGetDatagramPayloadSize(Path);
525525

526526
if (!Bbr->ProbeRttEndTimeValid &&
527527
Bbr->BytesInFlight < BbrCongestionControlGetCongestionWindow(Cc) + DatagramPayloadLength) {
@@ -623,8 +623,8 @@ BbrCongestionControlGetSendAllowance(
623623
_In_ BOOLEAN TimeSinceLastSendValid
624624
)
625625
{
626-
QUIC_PATHID* PathID = QuicCongestionControlGetPathID(Cc);
627-
QUIC_CONNECTION* Connection = PathID->Connection;
626+
QUIC_PATH* Path = QuicCongestionControlGetPath(Cc);
627+
QUIC_CONNECTION* Connection = Path->PathID->Connection;
628628
QUIC_CONGESTION_CONTROL_BBR* Bbr = &Cc->Bbr;
629629

630630
uint64_t BandwidthEst = BbrCongestionControlGetBandwidth(Cc);
@@ -709,15 +709,14 @@ BbrCongestionControlSetSendQuantum(
709709
)
710710
{
711711
QUIC_CONGESTION_CONTROL_BBR *Bbr = &Cc->Bbr;
712-
QUIC_PATHID* PathID = QuicCongestionControlGetPathID(Cc);
713-
QUIC_CONNECTION* Connection = PathID->Connection;
712+
QUIC_PATH* Path = QuicCongestionControlGetPath(Cc);
714713

715714
uint64_t Bandwidth = BbrCongestionControlGetBandwidth(Cc);
716715

717716
uint64_t PacingRate = Bandwidth * Bbr->PacingGain / GAIN_UNIT;
718717

719718
const uint16_t DatagramPayloadLength =
720-
QuicPathGetDatagramPayloadSize(&Connection->Paths[0]);
719+
QuicPathGetDatagramPayloadSize(Path);
721720

722721
if (PacingRate < kLowPacingRateThresholdBytesPerSecond * BW_UNIT) {
723722
Bbr->SendQuantum = (uint64_t)DatagramPayloadLength;
@@ -737,15 +736,14 @@ BbrCongestionControlUpdateCongestionWindow(
737736
)
738737
{
739738
QUIC_CONGESTION_CONTROL_BBR *Bbr = &Cc->Bbr;
740-
QUIC_PATHID* PathID = QuicCongestionControlGetPathID(Cc);
741-
QUIC_CONNECTION* Connection = PathID->Connection;
739+
QUIC_PATH* Path = QuicCongestionControlGetPath(Cc);
742740

743741
if (Bbr->BbrState == BBR_STATE_PROBE_RTT) {
744742
return;
745743
}
746744

747745
const uint16_t DatagramPayloadLength =
748-
QuicPathGetDatagramPayloadSize(&Connection->Paths[0]);
746+
QuicPathGetDatagramPayloadSize(Path);
749747

750748
BbrCongestionControlSetSendQuantum(Cc);
751749

@@ -769,7 +767,7 @@ BbrCongestionControlUpdateCongestionWindow(
769767

770768
Bbr->CongestionWindow = CXPLAT_MAX(CongestionWindow, MinCongestionWindow);
771769

772-
QuicConnLogBbr(PathID);
770+
QuicPathLogBbr(Path);
773771
}
774772

775773
_IRQL_requires_max_(DISPATCH_LEVEL)
@@ -782,8 +780,8 @@ BbrCongestionControlOnDataAcknowledged(
782780
QUIC_CONGESTION_CONTROL_BBR* Bbr = &Cc->Bbr;
783781

784782
BOOLEAN PreviousCanSendState = BbrCongestionControlCanSend(Cc);
785-
QUIC_PATHID* PathID = QuicCongestionControlGetPathID(Cc);
786-
QUIC_CONNECTION* Connection = PathID->Connection;
783+
QUIC_PATH* Path = QuicCongestionControlGetPath(Cc);
784+
QUIC_CONNECTION* Connection = Path->PathID->Connection;
787785

788786
if (AckEvent->IsImplicit) {
789787
BbrCongestionControlUpdateCongestionWindow(
@@ -916,17 +914,18 @@ BbrCongestionControlOnDataLost(
916914
)
917915
{
918916
QUIC_CONGESTION_CONTROL_BBR *Bbr = &Cc->Bbr;
919-
QUIC_PATHID* PathID = QuicCongestionControlGetPathID(Cc);
920-
QUIC_CONNECTION* Connection = PathID->Connection;
917+
QUIC_PATH* Path = QuicCongestionControlGetPath(Cc);
918+
QUIC_CONNECTION* Connection = Path->PathID->Connection;
921919

922920
const uint16_t DatagramPayloadLength =
923-
QuicPathGetDatagramPayloadSize(&Connection->Paths[0]);
921+
QuicPathGetDatagramPayloadSize(Path);
924922

925923
QuicTraceEvent(
926924
ConnCongestionV2,
927925
"[conn][%p] Congestion event: IsEcn=%hu",
928926
Connection,
929927
FALSE);
928+
Path->Stats.Send.CongestionCount++;
930929
Connection->Stats.Send.CongestionCount++;
931930

932931
BOOLEAN PreviousCanSendState = BbrCongestionControlCanSend(Cc);
@@ -959,6 +958,7 @@ BbrCongestionControlOnDataLost(
959958
ConnPersistentCongestion,
960959
"[conn][%p] Persistent congestion event",
961960
Connection);
961+
Path->Stats.Send.PersistentCongestionCount++;
962962
Connection->Stats.Send.PersistentCongestionCount++;
963963
} else {
964964
Bbr->RecoveryWindow =
@@ -968,7 +968,7 @@ BbrCongestionControlOnDataLost(
968968
}
969969

970970
BbrCongestionControlUpdateBlockedState(Cc, PreviousCanSendState);
971-
QuicConnLogBbr(PathID);
971+
QuicPathLogBbr(Path);
972972
}
973973

974974
_IRQL_requires_max_(DISPATCH_LEVEL)
@@ -989,9 +989,8 @@ BbrCongestionControlSetAppLimited(
989989
{
990990
QUIC_CONGESTION_CONTROL_BBR *Bbr = &Cc->Bbr;
991991

992-
QUIC_PATHID* PathID = QuicCongestionControlGetPathID(Cc);
993-
QUIC_CONNECTION* Connection = PathID->Connection;
994-
uint64_t LargestSentPacketNumber = Connection->Paths[0].PathID->LossDetection.LargestSentPacketNumber;
992+
QUIC_PATH* Path = QuicCongestionControlGetPath(Cc);
993+
uint64_t LargestSentPacketNumber = Path->PathID->LossDetection.LargestSentPacketNumber;
995994

996995
if (Bbr->BytesInFlight > BbrCongestionControlGetCongestionWindow(Cc)) {
997996
return;
@@ -1010,11 +1009,10 @@ BbrCongestionControlReset(
10101009
{
10111010
QUIC_CONGESTION_CONTROL_BBR* Bbr = &Cc->Bbr;
10121011

1013-
QUIC_PATHID* PathID = QuicCongestionControlGetPathID(Cc);
1014-
QUIC_CONNECTION* Connection = PathID->Connection;
1012+
QUIC_PATH* Path = QuicCongestionControlGetPath(Cc);
10151013

10161014
const uint16_t DatagramPayloadLength =
1017-
QuicPathGetDatagramPayloadSize(&Connection->Paths[0]);
1015+
QuicPathGetDatagramPayloadSize(Path);
10181016

10191017
Bbr->CongestionWindow = Bbr->InitialCongestionWindowPackets * DatagramPayloadLength;
10201018
Bbr->InitialCongestionWindow = Bbr->InitialCongestionWindowPackets * DatagramPayloadLength;
@@ -1068,7 +1066,7 @@ BbrCongestionControlReset(
10681066
Bbr->BandwidthFilter.AppLimitedExitTarget = 0;
10691067

10701068
BbrCongestionControlLogOutFlowStatus(Cc);
1071-
QuicConnLogBbr(PathID);
1069+
QuicPathLogBbr(Path);
10721070
}
10731071

10741072

@@ -1104,11 +1102,10 @@ BbrCongestionControlInitialize(
11041102

11051103
QUIC_CONGESTION_CONTROL_BBR* Bbr = &Cc->Bbr;
11061104

1107-
QUIC_PATHID* PathID = QuicCongestionControlGetPathID(Cc);
1108-
QUIC_CONNECTION* Connection = PathID->Connection;
1105+
QUIC_PATH* Path = QuicCongestionControlGetPath(Cc);
11091106

11101107
const uint16_t DatagramPayloadLength =
1111-
QuicPathGetDatagramPayloadSize(&Connection->Paths[0]);
1108+
QuicPathGetDatagramPayloadSize(Path);
11121109

11131110
Bbr->InitialCongestionWindowPackets = Settings->InitialWindowPackets;
11141111

@@ -1165,6 +1162,7 @@ BbrCongestionControlInitialize(
11651162
.AppLimitedExitTarget = 0,
11661163
};
11671164

1168-
QuicConnLogOutFlowStats(PathID);
1169-
QuicConnLogBbr(PathID);
1165+
QuicConnLogOutFlowStats(Path->PathID->Connection);
1166+
QuicPathLogOutFlowStats(Path);
1167+
QuicPathLogBbr(Path);
11701168
}

src/core/congestion_control.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ QuicCongestionControlInitialize(
3030
default:
3131
QuicTraceLogConnWarning(
3232
InvalidCongestionControlAlgorithm,
33-
QuicCongestionControlGetPathID(Cc)->Connection,
33+
QuicCongestionControlGetPath(Cc)->PathID->Connection,
3434
"Unknown congestion control algorithm: %hu, fallback to Cubic",
3535
Settings->CongestionControlAlgorithm);
3636
__fallthrough;

0 commit comments

Comments
 (0)