Skip to content

Commit ae93aad

Browse files
authored
Add TX checksum offload for Windows XDP (#5080)
1 parent 91dc69a commit ae93aad

16 files changed

+544
-139
lines changed

src/generated/linux/datapath_raw_xdp_win.c.clog.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,25 @@
2929
#ifdef __cplusplus
3030
extern "C" {
3131
#endif
32+
/*----------------------------------------------------------
33+
// Decoder Ring for GetTxOffloadConfig
34+
// [ lib] %u, %u
35+
// QuicTraceLogInfo(
36+
GetTxOffloadConfig,
37+
"[ lib] %u, %u",
38+
Queue->Interface->ActualIfIndex, *TxChecksumOffload);
39+
// arg2 = arg2 = Queue->Interface->ActualIfIndex = arg2
40+
// arg3 = arg3 = *TxChecksumOffload = arg3
41+
----------------------------------------------------------*/
42+
#ifndef _clog_4_ARGS_TRACE_GetTxOffloadConfig
43+
#define _clog_4_ARGS_TRACE_GetTxOffloadConfig(uniqueId, encoded_arg_string, arg2, arg3)\
44+
tracepoint(CLOG_DATAPATH_RAW_XDP_WIN_C, GetTxOffloadConfig , arg2, arg3);\
45+
46+
#endif
47+
48+
49+
50+
3251
/*----------------------------------------------------------
3352
// Decoder Ring for FoundVF
3453
// [ xdp][%p] Found NetSvc-VF interfaces. NetSvc IfIdx:%lu, VF IfIdx:%lu

src/generated/linux/datapath_raw_xdp_win.c.clog.h.lttng.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11

22

33

4+
/*----------------------------------------------------------
5+
// Decoder Ring for GetTxOffloadConfig
6+
// [ lib] %u, %u
7+
// QuicTraceLogInfo(
8+
GetTxOffloadConfig,
9+
"[ lib] %u, %u",
10+
Queue->Interface->ActualIfIndex, *TxChecksumOffload);
11+
// arg2 = arg2 = Queue->Interface->ActualIfIndex = arg2
12+
// arg3 = arg3 = *TxChecksumOffload = arg3
13+
----------------------------------------------------------*/
14+
TRACEPOINT_EVENT(CLOG_DATAPATH_RAW_XDP_WIN_C, GetTxOffloadConfig,
15+
TP_ARGS(
16+
unsigned int, arg2,
17+
unsigned int, arg3),
18+
TP_FIELDS(
19+
ctf_integer(unsigned int, arg2, arg2)
20+
ctf_integer(unsigned int, arg3, arg3)
21+
)
22+
)
23+
24+
25+
426
/*----------------------------------------------------------
527
// Decoder Ring for FoundVF
628
// [ xdp][%p] Found NetSvc-VF interfaces. NetSvc IfIdx:%lu, VF IfIdx:%lu

src/inc/quic_datapath.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,18 @@ typedef struct CXPLAT_RAW_TCP_STATE {
191191
uint32_t SequenceNumber;
192192
} CXPLAT_RAW_TCP_STATE;
193193

194+
//
195+
// An opaque queue type. Each queue is associated with a single RSS queue on a
196+
// single interface.
197+
//
198+
typedef struct CXPLAT_QUEUE CXPLAT_QUEUE;
199+
194200
//
195201
// Structure to represent a network route.
196202
//
197203
typedef struct CXPLAT_ROUTE {
198204

199-
//
200-
// The (RSS) queue that this route is primarily associated with.
201-
//
202-
void* Queue;
205+
CXPLAT_QUEUE* Queue;
203206

204207
QUIC_ADDR RemoteAddress;
205208
QUIC_ADDR LocalAddress;

src/manifest/clog.sidecar

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5888,6 +5888,22 @@
58885888
],
58895889
"macroName": "QuicTraceLogConnWarning"
58905890
},
5891+
"GetTxOffloadConfig": {
5892+
"ModuleProperites": {},
5893+
"TraceString": "[ lib] %u, %u",
5894+
"UniqueId": "GetTxOffloadConfig",
5895+
"splitArgs": [
5896+
{
5897+
"DefinationEncoding": "u",
5898+
"MacroVariableName": "arg2"
5899+
},
5900+
{
5901+
"DefinationEncoding": "u",
5902+
"MacroVariableName": "arg3"
5903+
}
5904+
],
5905+
"macroName": "QuicTraceLogInfo"
5906+
},
58915907
"HandshakeConfirmedAck": {
58925908
"ModuleProperites": {},
58935909
"TraceString": "[conn][%p] Handshake confirmed (ack)",
@@ -15624,6 +15640,11 @@
1562415640
"TraceID": "GetPacketTypeFailure",
1562515641
"EncodingString": "[conn][%p] Failed to get packet type for control frames, 0x%x"
1562615642
},
15643+
{
15644+
"UniquenessHash": "72895611-1b21-d389-c78b-ab44b14b458f",
15645+
"TraceID": "GetTxOffloadConfig",
15646+
"EncodingString": "[ lib] %u, %u"
15647+
},
1562715648
{
1562815649
"UniquenessHash": "eeb31991-927b-2f3c-bfb7-12b7dea50ead",
1562915650
"TraceID": "HandshakeConfirmedAck",

src/platform/datapath_epoll.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,7 +1827,7 @@ CxPlatSocketContextRecvComplete(
18271827
QUIC_ADDR* LocalAddr = &IoBlock->Route.LocalAddress;
18281828
QUIC_ADDR* RemoteAddr = &IoBlock->Route.RemoteAddress;
18291829
CxPlatConvertFromMappedV6(RemoteAddr, RemoteAddr);
1830-
IoBlock->Route.Queue = SocketContext;
1830+
IoBlock->Route.Queue = (CXPLAT_QUEUE*)SocketContext;
18311831

18321832
//
18331833
// Process the ancillary control messages to get the local address,
@@ -2133,7 +2133,7 @@ CxPlatSocketReceiveTcpData(
21332133
}
21342134

21352135
IoBlock->Route.State = RouteResolved;
2136-
IoBlock->Route.Queue = SocketContext;
2136+
IoBlock->Route.Queue = (CXPLAT_QUEUE*)SocketContext;
21372137
IoBlock->RefCount = 0;
21382138

21392139
uint8_t* Buffer = (uint8_t*)IoBlock + DatapathPartition->Datapath->RecvBlockBufferOffset;
@@ -2235,10 +2235,10 @@ SendDataAlloc(
22352235
CXPLAT_DBG_ASSERT(Socket != NULL);
22362236
CXPLAT_DBG_ASSERT(Socket->Type != CXPLAT_SOCKET_UDP || Config->MaxPacketSize <= MAX_UDP_PAYLOAD_LENGTH);
22372237
if (Config->Route->Queue == NULL) {
2238-
Config->Route->Queue = &Socket->SocketContexts[0];
2238+
Config->Route->Queue = (CXPLAT_QUEUE*)&Socket->SocketContexts[0];
22392239
}
22402240

2241-
CXPLAT_SOCKET_CONTEXT* SocketContext = Config->Route->Queue;
2241+
CXPLAT_SOCKET_CONTEXT* SocketContext = (CXPLAT_SOCKET_CONTEXT*)Config->Route->Queue;
22422242
CXPLAT_DBG_ASSERT(SocketContext->Binding == Socket);
22432243
CXPLAT_DBG_ASSERT(SocketContext->Binding->Datapath == SocketContext->DatapathPartition->Datapath);
22442244
CXPLAT_SEND_DATA* SendData = CxPlatPoolAlloc(&SocketContext->DatapathPartition->SendBlockPool);

src/platform/datapath_kqueue.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ CxPlatSocketContextRecvComplete(
11081108
CxPlatConvertFromMappedV6(RemoteAddr, RemoteAddr);
11091109
}
11101110

1111-
RecvPacket->Route->Queue = SocketContext;
1111+
RecvPacket->Route->Queue = (CXPLAT_QUEUE*)SocketContext;
11121112
RecvPacket->TypeOfService = 0;
11131113
RecvPacket->HopLimitTTL = 0; // TODO: We are not supporting this on MacOS (yet) unless there's a business need.
11141114

@@ -1609,10 +1609,10 @@ CxPlatSendDataAlloc(
16091609
CXPLAT_DBG_ASSERT(Socket != NULL);
16101610

16111611
if (Config->Route->Queue == NULL) {
1612-
Config->Route->Queue = &Socket->SocketContexts[0];
1612+
Config->Route->Queue = (CXPLAT_QUEUE*)&Socket->SocketContexts[0];
16131613
}
16141614

1615-
CXPLAT_SOCKET_CONTEXT* SocketContext = Config->Route->Queue;
1615+
CXPLAT_SOCKET_CONTEXT* SocketContext = (CXPLAT_SOCKET_CONTEXT*)Config->Route->Queue;
16161616
CXPLAT_SEND_DATA* SendData = CxPlatPoolAlloc(&SocketContext->DatapathPartition->SendDataPool);
16171617
if (SendData != NULL) {
16181618
CxPlatZeroMemory(SendData, sizeof(*SendData));
@@ -2083,7 +2083,7 @@ CxPlatSocketSend(
20832083
UNREFERENCED_PARAMETER(Socket);
20842084
CXPLAT_DBG_ASSERT(Route->Queue);
20852085
CxPlatSocketSendInternal(
2086-
Route->Queue,
2086+
(CXPLAT_SOCKET_CONTEXT*)Route->Queue,
20872087
&Route->LocalAddress,
20882088
&Route->RemoteAddress,
20892089
SendData,

src/platform/datapath_raw.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,11 @@ RawSocketSend(
354354
CASTED_CLOG_BYTEARRAY(sizeof(Route->LocalAddress), &Route->LocalAddress));
355355
CXPLAT_DBG_ASSERT(Route->State == RouteResolved);
356356
CXPLAT_DBG_ASSERT(Route->Queue != NULL);
357-
const CXPLAT_INTERFACE* Interface = CxPlatDpRawGetInterfaceFromQueue(Route->Queue);
358357

359358
CxPlatFramingWriteHeaders(
360-
Socket, Route, &SendData->Buffer, SendData->ECN, SendData->DSCP,
361-
Interface->OffloadStatus.Transmit.NetworkLayerXsum,
362-
Interface->OffloadStatus.Transmit.TransportLayerXsum,
359+
Socket, Route, SendData, &SendData->Buffer, SendData->ECN, SendData->DSCP,
360+
CxPlatDpRawIsL3TxXsumOffloadedOnQueue(Route->Queue),
361+
CxPlatDpRawIsL4TxXsumOffloadedOnQueue(Route->Queue),
363362
Route->TcpState.SequenceNumber,
364363
Route->TcpState.AckNumber,
365364
TH_ACK);

src/platform/datapath_raw.h

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,27 @@ CxPlatDpRawAssignQueue(
170170
_IRQL_requires_max_(DISPATCH_LEVEL)
171171
const CXPLAT_INTERFACE*
172172
CxPlatDpRawGetInterfaceFromQueue(
173-
_In_ const void* Queue
173+
_In_ const CXPLAT_QUEUE* Queue
174+
);
175+
176+
//
177+
// Returns whether the L3 (i.e., network) layer transmit checksum offload is
178+
// enabled on the queue.
179+
//
180+
_IRQL_requires_max_(DISPATCH_LEVEL)
181+
BOOLEAN
182+
CxPlatDpRawIsL3TxXsumOffloadedOnQueue(
183+
_In_ const CXPLAT_QUEUE* Queue
184+
);
185+
186+
//
187+
// Returns whether the L3 (i.e., transport) layer transmit checksum offload is
188+
// enabled on the queue.
189+
//
190+
_IRQL_requires_max_(DISPATCH_LEVEL)
191+
BOOLEAN
192+
CxPlatDpRawIsL4TxXsumOffloadedOnQueue(
193+
_In_ const CXPLAT_QUEUE* Queue
174194
);
175195

176196
typedef struct HEADER_BACKFILL {
@@ -250,6 +270,27 @@ CxPlatDpRawTxEnqueue(
250270
_In_ CXPLAT_SEND_DATA* SendData
251271
);
252272

273+
//
274+
// Sets the TX send object to have the specified L3 checksum offload settings.
275+
//
276+
_IRQL_requires_max_(DISPATCH_LEVEL)
277+
void
278+
CxPlatDpRawTxSetL3ChecksumOffload(
279+
_In_ CXPLAT_SEND_DATA* SendData
280+
);
281+
282+
//
283+
// Sets the TX send object to have the specified L4 checksum offload settings.
284+
//
285+
_IRQL_requires_max_(DISPATCH_LEVEL)
286+
void
287+
CxPlatDpRawTxSetL4ChecksumOffload(
288+
_In_ CXPLAT_SEND_DATA* SendData,
289+
_In_ BOOLEAN IsIpv6,
290+
_In_ BOOLEAN IsTcp,
291+
_In_ uint8_t L4HeaderLength
292+
);
293+
253294
//
254295
// Raw Socket Interface
255296
//
@@ -372,6 +413,7 @@ void
372413
CxPlatFramingWriteHeaders(
373414
_In_ CXPLAT_SOCKET_RAW* Socket,
374415
_In_ const CXPLAT_ROUTE* Route,
416+
_Inout_ CXPLAT_SEND_DATA* SendData,
375417
_Inout_ QUIC_BUFFER* Buffer,
376418
_In_ CXPLAT_ECN_TYPE ECN,
377419
_In_ uint8_t DSCP,

src/platform/datapath_raw_dpdk.c

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,12 +535,31 @@ CxPlatDpRawAssignQueue(
535535
_IRQL_requires_max_(DISPATCH_LEVEL)
536536
const CXPLAT_INTERFACE*
537537
CxPlatDpRawGetInterfaceFromQueue(
538-
_In_ const void* Queue
538+
_In_ const CXPLAT_QUEUE* Queue
539539
)
540540
{
541541
return (const CXPLAT_INTERFACE*)Queue;
542542
}
543543

544+
_IRQL_requires_max_(DISPATCH_LEVEL)
545+
BOOLEAN
546+
CxPlatDpRawIsL3TxXsumOffloadedOnQueue(
547+
_In_ const CXPLAT_QUEUE* Queue
548+
)
549+
{
550+
return CxPlatDpRawGetInterfaceFromQueue(Queue)->OffloadStatus.Transmit.NetworkLayerXsum;
551+
}
552+
553+
554+
_IRQL_requires_max_(DISPATCH_LEVEL)
555+
BOOLEAN
556+
CxPlatDpRawIsL4TxXsumOffloadedOnQueue(
557+
_In_ const CXPLAT_QUEUE* Queue
558+
)
559+
{
560+
return CxPlatDpRawGetInterfaceFromQueue(Queue)->OffloadStatus.Transmit.TransportLayerXsum;
561+
}
562+
544563
static
545564
void
546565
CxPlatDpdkRx(
@@ -684,6 +703,30 @@ CxPlatDpRawTxEnqueue(
684703
CxPlatPoolFree(Packet);
685704
}
686705

706+
_IRQL_requires_max_(DISPATCH_LEVEL)
707+
void
708+
CxPlatDpRawTxSetL3ChecksumOffload(
709+
_In_ CXPLAT_SEND_DATA* SendData
710+
)
711+
{
712+
UNREFERENCED_PARAMETER(SendData);
713+
}
714+
715+
_IRQL_requires_max_(DISPATCH_LEVEL)
716+
void
717+
CxPlatDpRawTxSetL4ChecksumOffload(
718+
_In_ CXPLAT_SEND_DATA* SendData,
719+
_In_ BOOLEAN IsIpv6,
720+
_In_ BOOLEAN IsTcp,
721+
_In_ uint8_t L4HeaderLength
722+
)
723+
{
724+
UNREFERENCED_PARAMETER(SendData);
725+
UNREFERENCED_PARAMETER(IsIpv6);
726+
UNREFERENCED_PARAMETER(IsTcp);
727+
UNREFERENCED_PARAMETER(L4HeaderLength);
728+
}
729+
687730
static
688731
void
689732
CxPlatDpdkTx(

0 commit comments

Comments
 (0)