From 6c1b53cdc0396fa9ed8033a6cb9145a3d5fb45ef Mon Sep 17 00:00:00 2001 From: ami-GS <1991.daiki@gmail.com> Date: Wed, 27 Nov 2024 13:38:02 -0800 Subject: [PATCH] unify datapath_raw_winXXX --- scripts/clog.inputs | 3 +- ...ser.c.clog.h => datapath_raw_win.c.clog.h} | 18 +-- ...ng.h => datapath_raw_win.c.clog.h.lttng.h} | 6 +- .../linux/datapath_raw_winkernel.c.clog.h | 12 -- ... => quic.clog_datapath_raw_win.c.clog.h.c} | 2 +- ...uic.clog_datapath_raw_winkernel.c.clog.h.c | 1 - src/platform/CMakeLists.txt | 2 +- ...apath_raw_winuser.c => datapath_raw_win.c} | 4 +- src/platform/datapath_raw_winkernel.c | 111 ------------------ src/platform/platform.kernel.vcxproj | 2 +- 10 files changed, 19 insertions(+), 142 deletions(-) rename src/generated/linux/{datapath_raw_winuser.c.clog.h => datapath_raw_win.c.clog.h} (80%) rename src/generated/linux/{datapath_raw_winuser.c.clog.h.lttng.h => datapath_raw_win.c.clog.h.lttng.h} (91%) delete mode 100644 src/generated/linux/datapath_raw_winkernel.c.clog.h rename src/generated/linux/{quic.clog_datapath_raw_winuser.c.clog.h.c => quic.clog_datapath_raw_win.c.clog.h.c} (75%) delete mode 100644 src/generated/linux/quic.clog_datapath_raw_winkernel.c.clog.h.c rename src/platform/{datapath_raw_winuser.c => datapath_raw_win.c} (99%) delete mode 100644 src/platform/datapath_raw_winkernel.c diff --git a/scripts/clog.inputs b/scripts/clog.inputs index e85137aa59..da956173f1 100644 --- a/scripts/clog.inputs +++ b/scripts/clog.inputs @@ -25,8 +25,7 @@ ../src/platform/datapath_raw_xdp_winuser.c ../src/platform/datapath_raw_xdp_winkernel.c ../src/platform/datapath_raw_xdp_linux.c -../src/platform/datapath_raw_winuser.c -../src/platform/datapath_raw_winkernel.c +../src/platform/datapath_raw_win.c ../src/platform/datapath_raw_linux.c ../src/platform/datapath_raw.c ../src/platform/crypt_bcrypt.c diff --git a/src/generated/linux/datapath_raw_winuser.c.clog.h b/src/generated/linux/datapath_raw_win.c.clog.h similarity index 80% rename from src/generated/linux/datapath_raw_winuser.c.clog.h rename to src/generated/linux/datapath_raw_win.c.clog.h index 117e6a05d6..87956cf105 100644 --- a/src/generated/linux/datapath_raw_winuser.c.clog.h +++ b/src/generated/linux/datapath_raw_win.c.clog.h @@ -2,16 +2,16 @@ #include #endif #undef TRACEPOINT_PROVIDER -#define TRACEPOINT_PROVIDER CLOG_DATAPATH_RAW_WINUSER_C +#define TRACEPOINT_PROVIDER CLOG_DATAPATH_RAW_WIN_C #undef TRACEPOINT_PROBE_DYNAMIC_LINKAGE #define TRACEPOINT_PROBE_DYNAMIC_LINKAGE #undef TRACEPOINT_INCLUDE -#define TRACEPOINT_INCLUDE "datapath_raw_winuser.c.clog.h.lttng.h" -#if !defined(DEF_CLOG_DATAPATH_RAW_WINUSER_C) || defined(TRACEPOINT_HEADER_MULTI_READ) -#define DEF_CLOG_DATAPATH_RAW_WINUSER_C +#define TRACEPOINT_INCLUDE "datapath_raw_win.c.clog.h.lttng.h" +#if !defined(DEF_CLOG_DATAPATH_RAW_WIN_C) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define DEF_CLOG_DATAPATH_RAW_WIN_C #include #define __int64 __int64_t -#include "datapath_raw_winuser.c.clog.h.lttng.h" +#include "datapath_raw_win.c.clog.h.lttng.h" #endif #include #ifndef _clog_MACRO_QuicTraceEvent @@ -34,7 +34,7 @@ extern "C" { ----------------------------------------------------------*/ #ifndef _clog_4_ARGS_TRACE_AllocFailure #define _clog_4_ARGS_TRACE_AllocFailure(uniqueId, encoded_arg_string, arg2, arg3)\ -tracepoint(CLOG_DATAPATH_RAW_WINUSER_C, AllocFailure , arg2, arg3);\ +tracepoint(CLOG_DATAPATH_RAW_WIN_C, AllocFailure , arg2, arg3);\ #endif @@ -54,7 +54,7 @@ tracepoint(CLOG_DATAPATH_RAW_WINUSER_C, AllocFailure , arg2, arg3);\ ----------------------------------------------------------*/ #ifndef _clog_4_ARGS_TRACE_LibraryErrorStatus #define _clog_4_ARGS_TRACE_LibraryErrorStatus(uniqueId, encoded_arg_string, arg2, arg3)\ -tracepoint(CLOG_DATAPATH_RAW_WINUSER_C, LibraryErrorStatus , arg2, arg3);\ +tracepoint(CLOG_DATAPATH_RAW_WIN_C, LibraryErrorStatus , arg2, arg3);\ #endif @@ -76,7 +76,7 @@ tracepoint(CLOG_DATAPATH_RAW_WINUSER_C, LibraryErrorStatus , arg2, arg3);\ ----------------------------------------------------------*/ #ifndef _clog_5_ARGS_TRACE_DatapathErrorStatus #define _clog_5_ARGS_TRACE_DatapathErrorStatus(uniqueId, encoded_arg_string, arg2, arg3, arg4)\ -tracepoint(CLOG_DATAPATH_RAW_WINUSER_C, DatapathErrorStatus , arg2, arg3, arg4);\ +tracepoint(CLOG_DATAPATH_RAW_WIN_C, DatapathErrorStatus , arg2, arg3, arg4);\ #endif @@ -87,5 +87,5 @@ tracepoint(CLOG_DATAPATH_RAW_WINUSER_C, DatapathErrorStatus , arg2, arg3, arg4); } #endif #ifdef CLOG_INLINE_IMPLEMENTATION -#include "quic.clog_datapath_raw_winuser.c.clog.h.c" +#include "quic.clog_datapath_raw_win.c.clog.h.c" #endif diff --git a/src/generated/linux/datapath_raw_winuser.c.clog.h.lttng.h b/src/generated/linux/datapath_raw_win.c.clog.h.lttng.h similarity index 91% rename from src/generated/linux/datapath_raw_winuser.c.clog.h.lttng.h rename to src/generated/linux/datapath_raw_win.c.clog.h.lttng.h index c552f06ebf..0a79251768 100644 --- a/src/generated/linux/datapath_raw_winuser.c.clog.h.lttng.h +++ b/src/generated/linux/datapath_raw_win.c.clog.h.lttng.h @@ -12,7 +12,7 @@ // arg2 = arg2 = "CXPLAT_DATAPATH" = arg2 // arg3 = arg3 = sizeof(CXPLAT_ROUTE_RESOLUTION_WORKER) = arg3 ----------------------------------------------------------*/ -TRACEPOINT_EVENT(CLOG_DATAPATH_RAW_WINUSER_C, AllocFailure, +TRACEPOINT_EVENT(CLOG_DATAPATH_RAW_WIN_C, AllocFailure, TP_ARGS( const char *, arg2, unsigned long long, arg3), @@ -35,7 +35,7 @@ TRACEPOINT_EVENT(CLOG_DATAPATH_RAW_WINUSER_C, AllocFailure, // arg2 = arg2 = Status = arg2 // arg3 = arg3 = "CxPlatThreadCreate" = arg3 ----------------------------------------------------------*/ -TRACEPOINT_EVENT(CLOG_DATAPATH_RAW_WINUSER_C, LibraryErrorStatus, +TRACEPOINT_EVENT(CLOG_DATAPATH_RAW_WIN_C, LibraryErrorStatus, TP_ARGS( unsigned int, arg2, const char *, arg3), @@ -60,7 +60,7 @@ TRACEPOINT_EVENT(CLOG_DATAPATH_RAW_WINUSER_C, LibraryErrorStatus, // arg3 = arg3 = Status = arg3 // arg4 = arg4 = "ResolveIpNetEntry2" = arg4 ----------------------------------------------------------*/ -TRACEPOINT_EVENT(CLOG_DATAPATH_RAW_WINUSER_C, DatapathErrorStatus, +TRACEPOINT_EVENT(CLOG_DATAPATH_RAW_WIN_C, DatapathErrorStatus, TP_ARGS( const void *, arg2, unsigned int, arg3, diff --git a/src/generated/linux/datapath_raw_winkernel.c.clog.h b/src/generated/linux/datapath_raw_winkernel.c.clog.h deleted file mode 100644 index 2bdc055cfd..0000000000 --- a/src/generated/linux/datapath_raw_winkernel.c.clog.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef CLOG_DO_NOT_INCLUDE_HEADER -#include -#endif -#ifdef __cplusplus -extern "C" { -#endif -#ifdef __cplusplus -} -#endif -#ifdef CLOG_INLINE_IMPLEMENTATION -#include "quic.clog_datapath_raw_winkernel.c.clog.h.c" -#endif diff --git a/src/generated/linux/quic.clog_datapath_raw_winuser.c.clog.h.c b/src/generated/linux/quic.clog_datapath_raw_win.c.clog.h.c similarity index 75% rename from src/generated/linux/quic.clog_datapath_raw_winuser.c.clog.h.c rename to src/generated/linux/quic.clog_datapath_raw_win.c.clog.h.c index 27a35db38e..b14ac8f031 100644 --- a/src/generated/linux/quic.clog_datapath_raw_winuser.c.clog.h.c +++ b/src/generated/linux/quic.clog_datapath_raw_win.c.clog.h.c @@ -4,4 +4,4 @@ #else #define TRACEPOINT_DEFINE #endif -#include "datapath_raw_winuser.c.clog.h" +#include "datapath_raw_win.c.clog.h" diff --git a/src/generated/linux/quic.clog_datapath_raw_winkernel.c.clog.h.c b/src/generated/linux/quic.clog_datapath_raw_winkernel.c.clog.h.c deleted file mode 100644 index 60649ebb50..0000000000 --- a/src/generated/linux/quic.clog_datapath_raw_winkernel.c.clog.h.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/src/platform/CMakeLists.txt b/src/platform/CMakeLists.txt index efed9cd98f..b4d5f18410 100644 --- a/src/platform/CMakeLists.txt +++ b/src/platform/CMakeLists.txt @@ -20,7 +20,7 @@ if("${CX_PLATFORM}" STREQUAL "windows") ${SYSTEM_PROCESSOR} STREQUAL "arm64ec") set(SOURCES ${SOURCES} datapath_raw_dummy.c) else() - set(SOURCES ${SOURCES} datapath_raw.c datapath_raw_winuser.c datapath_raw_socket.c datapath_raw_socket_win.c datapath_raw_socket_common.c datapath_raw_xdp_winuser.c) + set(SOURCES ${SOURCES} datapath_raw.c datapath_raw_win.c datapath_raw_socket.c datapath_raw_socket_win.c datapath_raw_socket_common.c datapath_raw_xdp_winuser.c) endif() else() set(SOURCES ${SOURCES} inline.c platform_posix.c storage_posix.c cgroup.c datapath_unix.c) diff --git a/src/platform/datapath_raw_winuser.c b/src/platform/datapath_raw_win.c similarity index 99% rename from src/platform/datapath_raw_winuser.c rename to src/platform/datapath_raw_win.c index 024fb0ef4c..ea93dc9b04 100644 --- a/src/platform/datapath_raw_winuser.c +++ b/src/platform/datapath_raw_win.c @@ -11,7 +11,7 @@ #include "datapath_raw_win.h" #ifdef QUIC_CLOG -#include "datapath_raw_winuser.c.clog.h" +#include "datapath_raw_win.c.clog.h" #endif #pragma warning(disable:4116) // unnamed type definition in parentheses @@ -241,5 +241,7 @@ CXPLAT_THREAD_CALLBACK(CxPlatRouteResolutionWorkerThread, Context) CXPLAT_FREE(Operation, QUIC_POOL_ROUTE_RESOLUTION_OPER); } +#ifndef _KERNEL_MODE return 0; +#endif } diff --git a/src/platform/datapath_raw_winkernel.c b/src/platform/datapath_raw_winkernel.c deleted file mode 100644 index 14023a58aa..0000000000 --- a/src/platform/datapath_raw_winkernel.c +++ /dev/null @@ -1,111 +0,0 @@ -/*++ - - Copyright (c) Microsoft Corporation. - Licensed under the MIT License. - -Abstract: - - QUIC Raw (i.e. DPDK or XDP) Datapath Implementation (User Mode) - ---*/ - -#include "datapath_raw_win.h" -#ifdef QUIC_CLOG -#include "datapath_raw_winkernel.c.clog.h" -#endif - -#pragma warning(disable:4116) // unnamed type definition in parentheses -#pragma warning(disable:4100) // unreferenced formal parameter - -_IRQL_requires_max_(PASSIVE_LEVEL) -void -CxPlatDataPathRouteWorkerUninitialize( - _In_ CXPLAT_ROUTE_RESOLUTION_WORKER* Worker - ) -{ - UNREFERENCED_PARAMETER(Worker); -} - -_IRQL_requires_max_(PASSIVE_LEVEL) -QUIC_STATUS -CxPlatDataPathRouteWorkerInitialize( - _Inout_ CXPLAT_DATAPATH_RAW* DataPath - ) -{ - UNREFERENCED_PARAMETER(DataPath); - return QUIC_STATUS_NOT_SUPPORTED; -} - -_IRQL_requires_max_(PASSIVE_LEVEL) -QUIC_STATUS -RawSocketCreateUdp( - _In_ CXPLAT_DATAPATH_RAW* Raw, - _In_ const CXPLAT_UDP_CONFIG* Config, - _Inout_ CXPLAT_SOCKET_RAW* Socket - ) -{ - CXPLAT_DBG_ASSERT(Socket != NULL); - QUIC_STATUS Status = QUIC_STATUS_SUCCESS; - - CxPlatRundownInitialize(&Socket->RawRundown); - Socket->RawDatapath = Raw; - Socket->CibirIdLength = Config->CibirIdLength; - Socket->CibirIdOffsetSrc = Config->CibirIdOffsetSrc; - Socket->CibirIdOffsetDst = Config->CibirIdOffsetDst; - Socket->AuxSocket = INVALID_SOCKET; - if (Config->CibirIdLength) { - memcpy(Socket->CibirId, Config->CibirId, Config->CibirIdLength); - } - - if (Config->RemoteAddress) { - CXPLAT_FRE_ASSERT(!QuicAddrIsWildCard(Config->RemoteAddress)); // No wildcard remote addresses allowed. - if (Socket->UseTcp) { - Socket->RemoteAddress = *Config->RemoteAddress; - } - Socket->Connected = TRUE; - } - - if (Config->LocalAddress) { - if (Socket->UseTcp) { - Socket->LocalAddress = *Config->LocalAddress; - } - if (QuicAddrIsWildCard(Config->LocalAddress)) { - if (!Socket->Connected) { - Socket->Wildcard = TRUE; - } - } else if (!Socket->Connected) { - // Assumes only connected sockets fully specify local address - Status = QUIC_STATUS_INVALID_STATE; - goto Error; - } - } else { - if (Socket->UseTcp) { - QuicAddrSetFamily(&Socket->LocalAddress, QUIC_ADDRESS_FAMILY_INET6); - } - if (!Socket->Connected) { - Socket->Wildcard = TRUE; - } - } - - CXPLAT_FRE_ASSERT(Socket->Wildcard ^ Socket->Connected); // Assumes either a pure wildcard listener or a - // connected socket; not both. - - Status = CxPlatTryAddSocket(&Raw->SocketPool, Socket); - if (QUIC_FAILED(Status)) { - goto Error; - } - - CxPlatDpRawPlumbRulesOnSocket(Socket, TRUE); - -Error: - - if (QUIC_FAILED(Status)) { - if (Socket != NULL) { - CxPlatRundownUninitialize(&Socket->RawRundown); - CxPlatZeroMemory(Socket, sizeof(CXPLAT_SOCKET_RAW) - sizeof(CXPLAT_SOCKET)); - Socket = NULL; - } - } - - return Status; -} \ No newline at end of file diff --git a/src/platform/platform.kernel.vcxproj b/src/platform/platform.kernel.vcxproj index 5676ee7fb6..9b1ad4b19d 100644 --- a/src/platform/platform.kernel.vcxproj +++ b/src/platform/platform.kernel.vcxproj @@ -25,7 +25,7 @@ - +