Skip to content

Commit

Permalink
Enable Raw datapath from kernel mode test (#4669)
Browse files Browse the repository at this point in the history
* Enable Raw datapath from test

* Update src/test/bin/winkernel/control.cpp

Co-authored-by: Nick Banks <[email protected]>

* enable for secnetperf

* take address

* fix build issue. copy is needed

* enable other execution config flags

* strtol for kernel mode

---------

Co-authored-by: Nick Banks <[email protected]>
  • Loading branch information
ami-GS and nibanks authored Nov 27, 2024
1 parent 3eb3fe0 commit 4eb7b0b
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 8 deletions.
47 changes: 40 additions & 7 deletions src/perf/lib/SecNetPerfMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,36 @@ uint8_t PerfDefaultAffinitizeThreads = false;
#ifdef _KERNEL_MODE
volatile int BufferCurrent;
char Buffer[BufferLength];
static inline LONG _strtol(const CHAR* nptr, CHAR** endptr, int base) {
UNREFERENCED_PARAMETER(base);
ULONG temp;
RtlCharToInteger(nptr, base, &temp);
if (endptr != NULL) {
const CHAR* ptr = nptr;
while (*ptr >= '0' && *ptr <= '9') {
ptr++;
}
*endptr = (CHAR*)ptr;
}
return (LONG)temp;
}

static inline ULONG _strtoul(const CHAR* nptr, CHAR** endptr, int base) {
UNREFERENCED_PARAMETER(base);
ULONG temp;
RtlCharToInteger(nptr, base, &temp);
if (endptr != NULL) {
const CHAR* ptr = nptr;
while (*ptr >= '0' && *ptr <= '9') {
ptr++;
}
*endptr = (CHAR*)ptr;
}
return temp;
}
#else
#define _strtol strtol
#define _strtoul strtoul
#endif

static
Expand Down Expand Up @@ -98,13 +128,16 @@ PrintHelp(
" -pollidle:<time_us> Amount of time to poll while idle before sleeping (default: 0).\n"
" -ecn:<0/1> Enables/disables sender-side ECN support. (def:0)\n"
" -qeo:<0/1> Allows/disallowes QUIC encryption offload. (def:0)\n"
#ifndef _KERNEL_MODE
#ifdef _KERNEL_MODE
" -io:<mode> Configures a requested network IO model to be used.\n"
" - {iocp, rio, xdp, qtip, wsk, epoll, kqueue}\n"
#else
" -io:<mode> Configures a requested network IO model to be used.\n"
" - {xdp}\n"
#endif // _KERNEL_MODE
" -cpu:<cpu_index> Specify the processor(s) to use.\n"
" -cipher:<value> Decimal value of 1 or more QUIC_ALLOWED_CIPHER_SUITE_FLAGS.\n"
" -highpri:<0/1> Configures MsQuic to run threads at high priority. (def:0)\n"
#endif // _KERNEL_MODE
"\n",
PERF_DEFAULT_PORT,
PERF_DEFAULT_PORT
Expand Down Expand Up @@ -144,10 +177,9 @@ QuicMainStart(
QUIC_EXECUTION_CONFIG* Config = (QUIC_EXECUTION_CONFIG*)RawConfig;
Config->PollingIdleTimeoutUs = 0; // Default to no polling.
bool SetConfig = false;

#ifndef _KERNEL_MODE
const char* IoMode = GetValue(argc, argv, "io");

#ifndef _KERNEL_MODE
if (IoMode && IsValue(IoMode, "qtip")) {
Config->Flags |= QUIC_EXECUTION_CONFIG_FLAG_QTIP;
SetConfig = true;
Expand All @@ -158,6 +190,8 @@ QuicMainStart(
SetConfig = true;
}

#endif // _KERNEL_MODE

if (IoMode && IsValue(IoMode, "xdp")) {
Config->Flags |= QUIC_EXECUTION_CONFIG_FLAG_XDP;
SetConfig = true;
Expand All @@ -166,15 +200,15 @@ QuicMainStart(
const char* CpuStr;
if ((CpuStr = GetValue(argc, argv, "cpu")) != nullptr) {
SetConfig = true;
if (strtol(CpuStr, nullptr, 10) == -1) {
if (_strtol(CpuStr, nullptr, 10) == -1) {
for (uint32_t i = 0; i < CxPlatProcCount() && Config->ProcessorCount < 256; ++i) {
Config->ProcessorList[Config->ProcessorCount++] = (uint16_t)i;
}
} else {
do {
if (*CpuStr == ',') CpuStr++;
Config->ProcessorList[Config->ProcessorCount++] =
(uint16_t)strtoul(CpuStr, (char**)&CpuStr, 10);
(uint16_t)_strtoul(CpuStr, (char**)&CpuStr, 10);
} while (*CpuStr && Config->ProcessorCount < 256);
}
}
Expand All @@ -190,7 +224,6 @@ QuicMainStart(
Config->Flags |= QUIC_EXECUTION_CONFIG_FLAG_AFFINITIZE;
SetConfig = true;
}
#endif // _KERNEL_MODE

if (TryGetValue(argc, argv, "pollidle", &Config->PollingIdleTimeoutUs)) {
SetConfig = true;
Expand Down
1 change: 1 addition & 0 deletions src/test/MsQuicTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ static const GUID QUIC_TEST_DEVICE_INSTANCE =

typedef struct {
BOOLEAN UseDuoNic;
QUIC_EXECUTION_CONFIG Config;
char CurrentDirectory[MAX_PATH];
} QUIC_TEST_CONFIGURATION_PARAMS;

Expand Down
4 changes: 3 additions & 1 deletion src/test/bin/quic_gtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class QuicTestEnvironment : public ::testing::Environment {
TRUE, NULL
)) != nullptr);

QUIC_EXECUTION_CONFIG Config = {QUIC_EXECUTION_CONFIG_FLAG_NONE, 0, 0, {0}};
if (TestingKernelMode) {
printf("Initializing for Kernel Mode tests\n");
const char* DriverName;
Expand All @@ -88,8 +89,10 @@ class QuicTestEnvironment : public ::testing::Environment {
ASSERT_TRUE(DriverService.Start());
ASSERT_TRUE(DriverClient.Initialize(&CertParams, DriverName));

Config.Flags |= UseDuoNic ? QUIC_EXECUTION_CONFIG_FLAG_XDP : QUIC_EXECUTION_CONFIG_FLAG_NONE;
QUIC_TEST_CONFIGURATION_PARAMS Params {
UseDuoNic,
Config,
};

#ifdef _WIN32
Expand All @@ -104,7 +107,6 @@ class QuicTestEnvironment : public ::testing::Environment {
MsQuic = new(std::nothrow) MsQuicApi();
ASSERT_TRUE(QUIC_SUCCEEDED(MsQuic->GetInitStatus()));
#if defined(QUIC_API_ENABLE_PREVIEW_FEATURES)
QUIC_EXECUTION_CONFIG Config = {QUIC_EXECUTION_CONFIG_FLAG_NONE, 0, 0, {0}};
if (UseQTIP) {
Config.PollingIdleTimeoutUs = 10000;
Config.Flags |= QUIC_EXECUTION_CONFIG_FLAG_QTIP;
Expand Down
13 changes: 13 additions & 0 deletions src/test/bin/winkernel/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,19 @@ QuicTestCtlEvtIoDeviceControl(
nullptr,
nullptr,
STRSAFE_NULL_ON_FAILURE);

#if defined(QUIC_API_ENABLE_PREVIEW_FEATURES)
QUIC_EXECUTION_CONFIG Config = Params->TestConfigurationParams.Config;
if (Config.Flags != QUIC_EXECUTION_CONFIG_FLAG_NONE) {
Status =
MsQuic->SetParam(
nullptr,
QUIC_PARAM_GLOBAL_EXECUTION_CONFIG,
sizeof(Config),
&Config);
}
#endif

break;

case IOCTL_QUIC_SET_CERT_PARAMS:
Expand Down

0 comments on commit 4eb7b0b

Please sign in to comment.