From ba0d0c71365f3eef4b5abbfc00302415a3667aed Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 9 Apr 2025 13:24:17 +0200 Subject: [PATCH 1/5] test/snp: NOT_STARTED error is not a test failure In case the network has not been started before (say by pxe test) the shutdown and stop functions may return NOT_STARTED. This is normal behavior and not a test failure. Signed-off-by: Gerd Hoffmann --- uefi-test-runner/src/proto/network/snp.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/uefi-test-runner/src/proto/network/snp.rs b/uefi-test-runner/src/proto/network/snp.rs index 5229ce833..c6c841411 100644 --- a/uefi-test-runner/src/proto/network/snp.rs +++ b/uefi-test-runner/src/proto/network/snp.rs @@ -17,14 +17,12 @@ pub fn test() { let simple_network = simple_network.unwrap(); // Check shutdown - simple_network - .shutdown() - .expect("Failed to shutdown Simple Network"); + let res = simple_network.shutdown(); + assert!(res == Ok(()) || res == Err(Status::NOT_STARTED.into())); // Check stop - simple_network - .stop() - .expect("Failed to stop Simple Network"); + let res = simple_network.stop(); + assert!(res == Ok(()) || res == Err(Status::NOT_STARTED.into())); // Check start simple_network From 6e8418e0782c87fcca2605eede0791011fe2b828 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 9 Apr 2025 13:25:05 +0200 Subject: [PATCH 2/5] test/snp: UNSUPPORTED for statistics is not a test failure The edk2 virtio-net driver does not support statistics and returns UNSUPPORTED. This is correct behavior. Signed-off-by: Gerd Hoffmann --- uefi-test-runner/src/proto/network/snp.rs | 30 ++++++++++++++++------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/uefi-test-runner/src/proto/network/snp.rs b/uefi-test-runner/src/proto/network/snp.rs index c6c841411..c7db1943e 100644 --- a/uefi-test-runner/src/proto/network/snp.rs +++ b/uefi-test-runner/src/proto/network/snp.rs @@ -34,7 +34,10 @@ pub fn test() { .initialize(0, 0) .expect("Failed to initialize Simple Network"); - simple_network.reset_statistics().unwrap(); + // edk2 virtio-net driver does not support statistics, so + // allow UNSUPPORTED (same for collect_statistics below). + let res = simple_network.reset_statistics(); + assert!(res == Ok(()) || res == Err(Status::UNSUPPORTED.into())); // Reading the interrupt status clears it simple_network.get_interrupt_status().unwrap(); @@ -111,13 +114,22 @@ pub fn test() { assert_eq!(buffer[42..47], [4, 4, 3, 2, 1]); // Get stats - let stats = simple_network - .collect_statistics() - .expect("Failed to collect statistics"); - info!("Stats: {:?}", stats); - - // One frame should have been transmitted and one received - assert_eq!(stats.tx_total_frames().unwrap(), 1); - assert_eq!(stats.rx_total_frames().unwrap(), 1); + let res = simple_network.collect_statistics(); + match res { + Ok(stats) => { + info!("Stats: {:?}", stats); + + // One frame should have been transmitted and one received + assert_eq!(stats.tx_total_frames().unwrap(), 1); + assert_eq!(stats.rx_total_frames().unwrap(), 1); + } + Err(e) => { + if e == Status::UNSUPPORTED.into() { + info!("Stats: unsupported."); + } else { + panic!("{e}"); + } + } + } } } From 3e8c28573d689c65ec28327c69fb6dcd6a8d7c7b Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 9 Apr 2025 13:38:54 +0200 Subject: [PATCH 3/5] test/snp: drop multicast from packet filter. The test case does not use multicast. The edk2 virtio-net driver does not support multicast. Drop it from packet filter. Signed-off-by: Gerd Hoffmann --- uefi-test-runner/src/proto/network/snp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uefi-test-runner/src/proto/network/snp.rs b/uefi-test-runner/src/proto/network/snp.rs index c7db1943e..1bdaab20e 100644 --- a/uefi-test-runner/src/proto/network/snp.rs +++ b/uefi-test-runner/src/proto/network/snp.rs @@ -45,7 +45,7 @@ pub fn test() { // Set receive filters simple_network .receive_filters( - ReceiveFlags::UNICAST | ReceiveFlags::MULTICAST | ReceiveFlags::BROADCAST, + ReceiveFlags::UNICAST | ReceiveFlags::BROADCAST, ReceiveFlags::empty(), false, None, From 47ba7efa6a3c156b427ecdea23563e28f951fc53 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 9 Apr 2025 14:17:40 +0200 Subject: [PATCH 4/5] xtask/qemu: switch to virtio-net nic. Use virtio-net instead of e1000. This gets network going on non-x86 platforms (aarch64, riscv64). While being at it switch qemu network configuration to modern netdev method. Signed-off-by: Gerd Hoffmann --- xtask/src/qemu.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xtask/src/qemu.rs b/xtask/src/qemu.rs index ec658a565..d233dd35b 100644 --- a/xtask/src/qemu.rs +++ b/xtask/src/qemu.rs @@ -503,8 +503,10 @@ pub fn run_qemu(arch: UefiArch, opt: &QemuOpt) -> Result<()> { // examples since it slows down the boot some. let echo_service = if !opt.disable_network && opt.example.is_none() { cmd.args([ - "-nic", - "user,model=e1000,net=192.168.17.0/24,tftp=uefi-test-runner/tftp/,bootfile=fake-boot-file", + "-netdev", + "user,id=net0,net=192.168.17.0/24,tftp=uefi-test-runner/tftp/,bootfile=fake-boot-file", + "-device", + "virtio-net-pci,netdev=net0", ]); Some(net::EchoService::start()) } else { From 36a493546f413d204dcc37f20c5ccae88d68e1d5 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 10 Apr 2025 14:02:00 +0200 Subject: [PATCH 5/5] xtask: turn on PXE tests for all platforms With the switch to virtio-net we have networking on all platforms. Turn on the pxe test everywhere. Also serves as workaround for https://github.com/rust-osdev/uefi-rs/issues/1617 Signed-off-by: Gerd Hoffmann --- xtask/src/main.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/xtask/src/main.rs b/xtask/src/main.rs index c98dec829..89f61a285 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -153,9 +153,8 @@ fn run_vm_tests(opt: &QemuOpt) -> Result<()> { features.push(Feature::DebugSupport); } - // Enable the PXE test unless networking is disabled or the arch doesn't - // support it. - if *opt.target == UefiArch::X86_64 && !opt.disable_network { + // Enable the PXE test unless networking is disabled + if !opt.disable_network { features.push(Feature::Pxe); }