From abe63b2b2e4643ea57ac4bcf01edc7a23b72091c Mon Sep 17 00:00:00 2001 From: Alan Jowett Date: Thu, 11 Apr 2024 13:20:07 -0700 Subject: [PATCH] Enable all tests on Windows Signed-off-by: Alan Jowett --- .github/workflows/Build.yml | 46 ++++++++++++++++++++++++++++++++----- CMakeLists.txt | 3 ++- bpf/tests.yml | 11 +++++---- runner/runner.cc | 44 ++++++++++++++++++++++++++++------- scripts/xdp_version.txt | 1 + 5 files changed, 85 insertions(+), 20 deletions(-) create mode 100644 scripts/xdp_version.txt diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index 3cd7266..d27194b 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -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 @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index beab9de..c1ad1ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") diff --git a/bpf/tests.yml b/bpf/tests.yml index af8f63e..79daed4 100644 --- a/bpf/tests.yml +++ b/bpf/tests.yml @@ -381,7 +381,8 @@ 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 @@ -389,7 +390,8 @@ 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_plus_100: all @@ -397,7 +399,8 @@ 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_minus_100: all @@ -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 @@ -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 diff --git a/runner/runner.cc b/runner/runner.cc index 470a5dc..e34bcf7 100644 --- a/runner/runner.cc +++ b/runner/runner.cc @@ -204,6 +204,8 @@ main(int argc, char** argv) int iteration_count = test["iteration_count"].as(); std::optional 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()) { @@ -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(); + } + + // Check if pass_context is defined and use it. + if (test["pass_context"].IsDefined()) { + pass_context = test["pass_context"].as(); + } + // Override batch size if specified on command line. if (batch_size_override.has_value()) { batch_size = batch_size_override.value(); @@ -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(data_in.size()); - opts.ctx_size_out = static_cast(data_out.size()); + if (pass_data) { + opts.data_in = data_in.data(); + opts.data_out = data_out.data(); + opts.data_size_in = static_cast(data_in.size()); + opts.data_size_out = static_cast(data_out.size()); + } + if (pass_context) { + opts.ctx_in = data_in.data(); + opts.ctx_out = data_out.data(); + opts.ctx_size_in = static_cast(data_in.size()); + opts.ctx_size_out = static_cast(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); @@ -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(i); - opt.ctx_in = data_in.data(); - opt.ctx_out = data_out.data(); - opt.ctx_size_in = static_cast(data_in.size()); - opt.ctx_size_out = static_cast(data_out.size()); + if (pass_data) { + opt.data_in = data_in.data(); + opt.data_out = data_out.data(); + opt.data_size_in = static_cast(data_in.size()); + opt.data_size_out = static_cast(data_out.size()); + } + if (pass_context) { + opt.ctx_in = data_in.data(); + opt.ctx_out = data_out.data(); + opt.ctx_size_in = static_cast(data_in.size()); + opt.ctx_size_out = static_cast(data_out.size()); + } #if defined(HAS_BPF_TEST_RUN_OPTS_BATCH_SIZE) opt.batch_size = batch_size; #endif diff --git a/scripts/xdp_version.txt b/scripts/xdp_version.txt new file mode 100644 index 0000000..e0cbe5d --- /dev/null +++ b/scripts/xdp_version.txt @@ -0,0 +1 @@ +https://github.com/microsoft/xdp-for-windows/releases/download/v1.1.0%2B3b7480bf \ No newline at end of file