From 9640abe06d70a9bdf207f42e89e255d4b5810319 Mon Sep 17 00:00:00 2001 From: Daiki AMINAKA <1991.daiki@gmail.com> Date: Thu, 14 Nov 2024 11:47:33 -0800 Subject: [PATCH] Extract common member variables (#4656) * Extract common member variables * fix * fix --- src/platform/datapath_epoll.c | 10 ---- src/platform/datapath_kqueue.c | 17 +------ src/platform/datapath_winkernel.c | 16 +------ src/platform/datapath_winuser.c | 10 ---- src/platform/platform_internal.h | 77 +++++++++++++------------------ 5 files changed, 35 insertions(+), 95 deletions(-) diff --git a/src/platform/datapath_epoll.c b/src/platform/datapath_epoll.c index f206e561da..2bbf9a6083 100644 --- a/src/platform/datapath_epoll.c +++ b/src/platform/datapath_epoll.c @@ -122,16 +122,6 @@ typedef struct CXPLAT_SEND_DATA { // QUIC_BUFFER ClientBuffer; - // - // The total buffer size for iovecs. - // - uint32_t TotalSize; - - // - // The send segmentation size the app asked for. - // - uint16_t SegmentSize; - // // Total number of packet buffers allocated (and iovecs used if !GSO). // diff --git a/src/platform/datapath_kqueue.c b/src/platform/datapath_kqueue.c index 329a5f9705..87efcf0428 100644 --- a/src/platform/datapath_kqueue.c +++ b/src/platform/datapath_kqueue.c @@ -83,6 +83,8 @@ typedef struct DATAPATH_RX_IO_BLOCK { // typedef struct CXPLAT_SEND_DATA { + CXPLAT_SEND_DATA_COMMON; + // // The proc context owning this send context. // @@ -108,16 +110,6 @@ typedef struct CXPLAT_SEND_DATA { // CXPLAT_LIST_ENTRY PendingSendLinkage; - // - // The total buffer size for Buffers. - // - uint32_t TotalSize; - - // - // The type of ECN markings needed for send. - // - CXPLAT_ECN_TYPE ECN; - // // Total number of Buffers currently in use. // @@ -143,11 +135,6 @@ typedef struct CXPLAT_SEND_DATA { // struct iovec Iovs[CXPLAT_MAX_BATCH_SEND]; - // - // The send segmentation size; zero if segmentation is not performed. - // - uint16_t SegmentSize; - } CXPLAT_SEND_DATA; typedef struct CXPLAT_DATAPATH_PARTITION CXPLAT_DATAPATH_PARTITION; diff --git a/src/platform/datapath_winkernel.c b/src/platform/datapath_winkernel.c index 9099615389..5fa2668aa8 100644 --- a/src/platform/datapath_winkernel.c +++ b/src/platform/datapath_winkernel.c @@ -199,6 +199,7 @@ typedef struct CXPLAT_DATAPATH_SEND_BUFFER { // Send context. // typedef struct CXPLAT_SEND_DATA { + CXPLAT_SEND_DATA_COMMON; CXPLAT_SOCKET* Binding; @@ -225,26 +226,11 @@ typedef struct CXPLAT_SEND_DATA { // CXPLAT_DATAPATH_SEND_BUFFER* TailBuf; - // - // The total buffer size for WsaBuffers. - // - uint32_t TotalSize; - - // - // The type of ECN markings needed for send. - // - CXPLAT_ECN_TYPE ECN; - // // The number of WSK buffers allocated. // UINT8 WskBufferCount; - // - // The send segmentation size; zero if segmentation is not performed. - // - UINT16 SegmentSize; - // // The QUIC_BUFFER returned to the client for segmented sends. // diff --git a/src/platform/datapath_winuser.c b/src/platform/datapath_winuser.c index be8f1f84a4..17e06c8aff 100644 --- a/src/platform/datapath_winuser.c +++ b/src/platform/datapath_winuser.c @@ -227,16 +227,6 @@ typedef struct CXPLAT_SEND_DATA { // CXPLAT_POOL* BufferPool; - // - // The total buffer size for WsaBuffers. - // - uint32_t TotalSize; - - // - // The send segmentation size; zero if segmentation is not performed. - // - uint16_t SegmentSize; - // // Set of flags set to configure the send behavior. // diff --git a/src/platform/platform_internal.h b/src/platform/platform_internal.h index be58ef523d..b590a64b81 100644 --- a/src/platform/platform_internal.h +++ b/src/platform/platform_internal.h @@ -61,6 +61,13 @@ typedef struct CXPLAT_DATAPATH_COMMON { // The Worker WorkerPool // CXPLAT_WORKER_POOL* WorkerPool; + + // + // Set of supported features. + // + uint32_t Features; + + CXPLAT_DATAPATH_RAW* RawDataPath; } CXPLAT_DATAPATH_COMMON; typedef struct CXPLAT_SOCKET_COMMON { @@ -73,6 +80,21 @@ typedef struct CXPLAT_SOCKET_COMMON { // The remote address and port. // QUIC_ADDR RemoteAddress; + + // + // Parent datapath. + // + CXPLAT_DATAPATH* Datapath; + + // + // The client context for this binding. + // + void *ClientContext; + + // + // The local interface's MTU. + // + uint16_t Mtu; } CXPLAT_SOCKET_COMMON; typedef struct CXPLAT_SEND_DATA_COMMON { @@ -82,6 +104,16 @@ typedef struct CXPLAT_SEND_DATA_COMMON { // The type of ECN markings needed for send. // uint8_t ECN; // CXPLAT_ECN_TYPE + + // + // The total buffer size for WsaBuffers. + // + uint32_t TotalSize; + + // + // The send segmentation size; zero if segmentation is not performed. + // + uint16_t SegmentSize; } CXPLAT_SEND_DATA_COMMON; typedef enum CXPLAT_DATAPATH_TYPE { @@ -396,11 +428,6 @@ typedef struct CXPLAT_DATAPATH { // CXPLAT_REF_COUNT RefCount; - // - // Set of supported features. - // - uint32_t Features; - // // The size of each receive datagram array element, including client context, // internal context, and padding. @@ -436,8 +463,6 @@ typedef struct CXPLAT_DATAPATH { uint8_t UseTcp : 1; - CXPLAT_DATAPATH_RAW* RawDataPath; - // // Per-processor completion contexts. // @@ -451,17 +476,6 @@ typedef struct CXPLAT_DATAPATH { typedef struct CXPLAT_SOCKET { CXPLAT_SOCKET_COMMON; - // - // Parent datapath. - // - // CXPLAT_DATAPATH_BASE* Datapath; - CXPLAT_DATAPATH* Datapath; - - // - // Client context pointer. - // - void *ClientContext; - // // Synchronization mechanism for cleanup. // @@ -472,11 +486,6 @@ typedef struct CXPLAT_SOCKET { // uint32_t RecvBufLen; - // - // The local interface's MTU. - // - uint16_t Mtu; - // // Indicates the binding connected to a remote IP address. // @@ -771,26 +780,11 @@ typedef struct QUIC_CACHEALIGN CXPLAT_SOCKET_CONTEXT { typedef struct CXPLAT_SOCKET { CXPLAT_SOCKET_COMMON; - // - // A pointer to datapath object. - // - CXPLAT_DATAPATH* Datapath; - - // - // The client context for this binding. - // - void *ClientContext; - // // Synchronization mechanism for cleanup. // CXPLAT_REF_COUNT RefCount; - // - // The MTU for this binding. - // - uint16_t Mtu; - // // The size of a receive buffer's payload. // @@ -898,11 +892,6 @@ typedef struct CXPLAT_DATAPATH { // CXPLAT_REF_COUNT RefCount; - // - // Set of supported features. - // - uint32_t Features; - // // The proc count to create per proc datapath state. // @@ -946,8 +935,6 @@ typedef struct CXPLAT_DATAPATH { uint8_t UseTcp : 1; - CXPLAT_DATAPATH_RAW* RawDataPath; - // // The per proc datapath contexts. //