Skip to content

Commit

Permalink
Merge pull request #57 from Alan-Jowett/enable_xdp_on_windows
Browse files Browse the repository at this point in the history
Enable all tests on Windows
  • Loading branch information
Alan-Jowett authored Apr 11, 2024
2 parents cc04c54 + abe63b2 commit 8bd44f7
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 20 deletions.
46 changes: 40 additions & 6 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,44 @@ jobs:
name: build-${{env.BUILD_TYPE}}-${{inputs.platform}}
path: ${{github.workspace}}/build/bin

- name: Setup xdp directory
if: inputs.platform == 'windows-2019' || inputs.platform == 'windows-2022'
run: |
mkdir -p ${{github.workspace}}\xdp
- name: Download xdp-for-windows
if: inputs.platform == 'windows-2019' || inputs.platform == 'windows-2022'
working-directory: ${{ github.workspace }}\xdp
run: |
$ProgressPreference = 'SilentlyContinue'
$packageBaseUrl = Get-Content -Path "${{github.workspace}}/scripts/xdp_version.txt"
$packageUrl = $packageBaseUrl + "/xdp-for-windows.1.1.0.msi"
write-output "Downloading $packageUrl"
Invoke-WebRequest -Uri $packageUrl -OutFile xdp-for-windows.1.1.0.msi
dir *.msi
$packageUrl = $packageBaseUrl + "/xdp-devkit-x64-1.1.0.zip"
write-output "Downloading $packageUrl"
Invoke-WebRequest -Uri $packageUrl -OutFile xdp-devkit-x64-1.1.0.zip
dir *.zip
Expand-Archive -Path "xdp-devkit-x64-1.1.0.zip" -DestinationPath .
- name: Install xdp-for-windows
if: inputs.platform == 'windows-2019' || inputs.platform == 'windows-2022'
working-directory: ${{ github.workspace }}\xdp
run: |
$installPath = "${{ github.workspace }}\xdp"
Write-Output "xdp installPath: $installPath"
Write-Output "Installing XDP for Windows"
CertUtil.exe -addstore Root bin\CoreNetSignRoot.cer
CertUtil.exe -addstore TrustedPublisher bin\CoreNetSignRoot.cer
$process = Start-Process msiexec.exe -Wait -ArgumentList "/i xdp-for-windows.1.1.0.msi INSTALLFOLDER=$installPath /qn" -PassThru
if ($process.ExitCode -ne 0) { exit $process.ExitCode }
Write-Output "XDP for Windows installed"
sc.exe query xdp
reg.exe add HKLM\SYSTEM\CurrentControlSet\Services\xdp\Parameters /v XdpEbpfEnabled /d 1 /t REG_DWORD /f
sc.exe stop xdp
sc.exe start xdp
- name: Create results directory
run: |
mkdir -p ${{github.workspace}}/results
Expand Down Expand Up @@ -154,18 +192,14 @@ jobs:
if: (inputs.platform == 'windows-2019' || inputs.platform == 'windows-2022') && inputs.option == 'none'
working-directory: ${{github.workspace}}/build/bin
run: |
$pre_command = 'wpr.exe -start CPU'
$post_command = 'wpr.exe -stop ""${{github.workspace}}\results\%NAME%.etl""'
${{env.BUILD_TYPE}}\bpf_performance_runner.exe -i tests.yml -e .sys -r --pre "$pre_command" --post "$post_command" | Tee-Object -FilePath ${{github.workspace}}/results/native-${inputs.platform}-${{env.BUILD_TYPE}}.csv
${{env.BUILD_TYPE}}\bpf_performance_runner.exe -i tests.yml -e .sys -r | Tee-Object -FilePath ${{github.workspace}}/results/native-${inputs.platform}-${{env.BUILD_TYPE}}.csv
- name: Tests - Windows 2019 or Windows 2022 - JIT
if: (inputs.platform == 'windows-2019' || inputs.platform == 'windows-2022') && inputs.option == 'jit'
working-directory: ${{github.workspace}}/build/bin
# Run with option to ignore failing return code
run: |
$pre_command = 'wpr.exe -start CPU'
$post_command = 'wpr.exe -stop ""${{github.workspace}}\results\%NAME%-jit.etl""'
${{env.BUILD_TYPE}}\bpf_performance_runner.exe -i tests.yml -r --pre "$pre_command" --post "$post_command" | Tee-Object -FilePath ${{github.workspace}}/results/native-${inputs.platform}-${{env.BUILD_TYPE}}.csv
${{env.BUILD_TYPE}}\bpf_performance_runner.exe -i tests.yml -r | Tee-Object -FilePath ${{github.workspace}}/results/native-${inputs.platform}-${{env.BUILD_TYPE}}.csv
- name: Upload results
uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2 # v2.3.1
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ if (PLATFORM_WINDOWS)
execute_process(COMMAND "${EBPF_BIN_PATH}/export_program_info.exe" WORKING_DIRECTORY "${EBPF_BIN_PATH}" COMMAND_ERROR_IS_FATAL ANY)

# Download the XDP-dev-kit from GitHub
file(DOWNLOAD "https://github.com/microsoft/xdp-for-windows/releases/download/v1.1.0%2B3b7480bf/xdp-devkit-x64-1.1.0.zip" "${PROJECT_BINARY_DIR}/packages/xdp-devkit.zip")
file(READ "${CMAKE_SOURCE_DIR}/scripts/xdp_version.txt" XDP_VERSION)
file(DOWNLOAD "${XDP_VERSION}/xdp-devkit-x64-1.1.0.zip" "${PROJECT_BINARY_DIR}/packages/xdp-devkit.zip")
# Unzip the XDP-dev-kit
# Create folder xdp-devkit
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/packages/xdp-devkit")
Expand Down
11 changes: 6 additions & 5 deletions bpf/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -381,23 +381,26 @@ tests:
description: Tests the bpf_xdp_adjust_head helper.
elf_file: xdp.o
iteration_count: 1000000
platform: Linux
program_type: xdp
pass_data: true
program_cpu_assignment:
test_bpf_xdp_adjust_head_0: all

- name: bpf_xdp_adjust_head_positive
description: Tests the bpf_xdp_adjust_head helper.
elf_file: xdp.o
iteration_count: 1000000
platform: Linux
program_type: xdp
pass_data: true
program_cpu_assignment:
test_bpf_xdp_adjust_head_plus_100: all

- name: bpf_xdp_adjust_head_negative
description: Tests the bpf_xdp_adjust_head helper.
elf_file: xdp.o
iteration_count: 1000000
platform: Linux
program_type: xdp
pass_data: true
program_cpu_assignment:
test_bpf_xdp_adjust_head_minus_100: all

Expand Down Expand Up @@ -452,7 +455,6 @@ tests:
- name: BPF_MAP_TYPE_HASH_OF_MAPS read
description: Tests the BPF_MAP_TYPE_HASH_OF_MAPS map type.
elf_file: hash_of_array.o
platform: Linux
map_state_preparation:
program: prepare
iteration_count: 8192
Expand All @@ -463,7 +465,6 @@ tests:
- name: BPF_MAP_TYPE_HASH_OF_MAPS update
description: Tests the BPF_MAP_TYPE_HASH_OF_MAPS map type.
elf_file: hash_of_array.o
platform: Linux
map_state_preparation:
program: prepare
iteration_count: 8192
Expand Down
44 changes: 36 additions & 8 deletions runner/runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ main(int argc, char** argv)
int iteration_count = test["iteration_count"].as<int>();
std::optional<std::string> program_type;
int batch_size;
bool pass_data = false;
bool pass_context = true;

// Check if value "platform" is defined and matches the current platform.
if (test["platform"].IsDefined()) {
Expand All @@ -226,6 +228,16 @@ main(int argc, char** argv)
batch_size = 64;
}

// Check if pass_data is defined and use it.
if (test["pass_data"].IsDefined()) {
pass_data = test["pass_data"].as<bool>();
}

// Check if pass_context is defined and use it.
if (test["pass_context"].IsDefined()) {
pass_context = test["pass_context"].as<bool>();
}

// Override batch size if specified on command line.
if (batch_size_override.has_value()) {
batch_size = batch_size_override.value();
Expand Down Expand Up @@ -308,10 +320,18 @@ main(int argc, char** argv)
memset(&opts, 0, sizeof(opts));
opts.sz = sizeof(opts);
opts.repeat = prep_program_iterations;
opts.ctx_in = data_in.data();
opts.ctx_out = data_out.data();
opts.ctx_size_in = static_cast<uint32_t>(data_in.size());
opts.ctx_size_out = static_cast<uint32_t>(data_out.size());
if (pass_data) {
opts.data_in = data_in.data();
opts.data_out = data_out.data();
opts.data_size_in = static_cast<uint32_t>(data_in.size());
opts.data_size_out = static_cast<uint32_t>(data_out.size());
}
if (pass_context) {
opts.ctx_in = data_in.data();
opts.ctx_out = data_out.data();
opts.ctx_size_in = static_cast<uint32_t>(data_in.size());
opts.ctx_size_out = static_cast<uint32_t>(data_out.size());
}

if (bpf_prog_test_run_opts(bpf_program__fd(map_state_preparation_program), &opts)) {
throw std::runtime_error("Failed to run map_state_preparation program " + prep_program_name);
Expand Down Expand Up @@ -411,10 +431,18 @@ main(int argc, char** argv)
opt.sz = sizeof(opt);
opt.repeat = iteration_count_override.value_or(iteration_count);
opt.cpu = static_cast<uint32_t>(i);
opt.ctx_in = data_in.data();
opt.ctx_out = data_out.data();
opt.ctx_size_in = static_cast<uint32_t>(data_in.size());
opt.ctx_size_out = static_cast<uint32_t>(data_out.size());
if (pass_data) {
opt.data_in = data_in.data();
opt.data_out = data_out.data();
opt.data_size_in = static_cast<uint32_t>(data_in.size());
opt.data_size_out = static_cast<uint32_t>(data_out.size());
}
if (pass_context) {
opt.ctx_in = data_in.data();
opt.ctx_out = data_out.data();
opt.ctx_size_in = static_cast<uint32_t>(data_in.size());
opt.ctx_size_out = static_cast<uint32_t>(data_out.size());
}
#if defined(HAS_BPF_TEST_RUN_OPTS_BATCH_SIZE)
opt.batch_size = batch_size;
#endif
Expand Down
1 change: 1 addition & 0 deletions scripts/xdp_version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/microsoft/xdp-for-windows/releases/download/v1.1.0%2B3b7480bf

0 comments on commit 8bd44f7

Please sign in to comment.