From f3856b7b4ec39f75ce165472ea7dd7f52d1cfa16 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 --- 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 +- 4 files changed, 5 insertions(+), 114 deletions(-) rename src/platform/{datapath_raw_winuser.c => datapath_raw_win.c} (99%) delete mode 100644 src/platform/datapath_raw_winkernel.c 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..b85de25baa 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_winkernel.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 @@ - +