Skip to content

TEST-NDIS-RECEIVE-PATH-001: Verify NDIS FilterReceive Packet Processing #290

Description

@zarfld

Issue Summary

Title: TEST-NDIS-RECEIVE-PATH-001: Verify NDIS FilterReceive Packet Processing

Objective: Validate NDIS FilterReceive and FilterReceiveNetBufferLists callbacks intercept incoming packets correctly, extract RX timestamps for PTP packets, forward non-PTP packets transparently with <1µs overhead, and maintain line-rate throughput (≥9.9 Gbps) with <0.01% packet drops.

Requirement: Traces to: #43 (REQ-F-NDIS-RECEIVE-001: FilterReceive / FilterReceiveNetBufferLists)


Test Cases

Test Case 1: Non-PTP Packet Fast Path (<1µs Overhead)

Given: Non-PTP Ethernet packet (EtherType 0x0800 = IPv4) received from miniport
When: FilterReceive callback invoked with NBL chain
Then:

  • EtherType check determines packet is NOT PTP (0x88F7)
  • No RX timestamp extraction attempted (fast path)
  • Packet forwarded via NdisFIndicateReceiveNetBufferLists immediately
  • Processing overhead <1µs (RDTSC entry to indicate call)
  • Packet reaches upper protocol driver unchanged

Expected Results:

  • Fast path latency P95 <1µs, P99 <1.5µs (RDTSC measurement)
  • No hardware register reads (RXSTMPL/RXSTMPH not accessed)
  • Zero memory allocations
  • Packet data unmodified (transparent forwarding)

Validation Method: RDTSC timing (entry to NdisFIndicateReceiveNetBufferLists), packet capture (Wireshark verify data unchanged), throughput test (iperf3 9.9+ Gbps)


Test Case 2: PTP Packet RX Timestamp Extraction (<5µs Total)

Given: PTP packet (EtherType 0x88F7) received from miniport
When: FilterReceive callback invoked
Then:

  • EtherType check detects PTP packet (0x88F7)
  • RX timestamp extracted from RXSTMPL/RXSTMPH registers (<4µs)
  • Timestamp stored in RX timestamp queue (lock-protected)
  • Packet forwarded via NdisFIndicateReceiveNetBufferLists
  • Total overhead <5µs (includes EtherType check + register read + queue store)

Expected Results:

  • PTP path latency P95 <5µs, P99 <7µs
  • RX timestamp queue contains entry with {sequence_id, timestamp}
  • Timestamp accessible via IOCTL_AVB_GET_RX_TIMESTAMP
  • Packet forwarded to upper driver

Validation Method: RDTSC timing breakdown (EtherType check ~500ns, register read ~3µs, queue store ~500ns), queue inspection (verify timestamp present), IOCTL query (retrieve timestamp)


Test Case 3: NBL Chain Processing (Multiple Packets)

Given: NBL chain with 10 packets (mix of PTP and non-PTP)
When: FilterReceive invoked with NumberOfNetBufferLists = 10
Then:

  • All 10 packets processed in loop
  • PTP packets timestamped (EtherType 0x88F7)
  • Non-PTP packets forwarded without timestamp
  • All 10 packets indicated via single NdisFIndicateReceiveNetBufferLists call
  • Processing time scales linearly O(n)

Expected Results:

  • 10 packets processed correctly (PTP timestamped, non-PTP fast path)
  • All 10 packets reach upper driver
  • Total processing time = n × per-packet overhead (linear scaling)
  • No dropped packets

Validation Method: Packet capture (verify 10 packets forwarded), RX timestamp queue (verify PTP entries), performance profiling (verify O(n) scaling)


Test Case 4: NDIS_RECEIVE_FLAGS_RESOURCES Fast Return

Given: Miniport indicates packets with NDIS_RECEIVE_FLAGS_RESOURCES set
When: FilterReceive invoked with ReceiveFlags.Resources = TRUE
Then:

  • Driver detects NDIS_RECEIVE_FLAGS_RESOURCES flag
  • Packets processed (EtherType check, timestamp extraction if PTP)
  • Packets indicated to upper driver immediately
  • No post-processing (no NdisFReturnNetBufferLists needed)
  • Control returns to miniport immediately after indicate call

Expected Results:

  • Fast return confirmed (no post-processing code executed)
  • Packets forwarded correctly
  • Miniport retains ownership (no return call)
  • Processing latency <2µs (minimal overhead due to fast path)

Validation Method: NDIS flag inspection, ETW trace (verify no NdisFReturnNetBufferLists call), RDTSC timing (verify fast return <2µs)


Test Case 5: NULL NBL Pointer Validation (Crash Prevention)

Given: Malicious or buggy miniport passes NULL NBL pointer
When: FilterReceive invoked with NetBufferLists = NULL
Then:

  • Driver validates NBL pointer before dereferencing
  • Detects NULL pointer
  • Returns NDIS_STATUS_INVALID_PARAMETER immediately
  • No access violation (no crash)
  • Event logged: "FilterReceive: NULL NBL pointer"

Expected Results:

  • No BSOD (crash prevented)
  • NDIS_STATUS_INVALID_PARAMETER returned
  • Event ID logged to ETW
  • System remains stable

Validation Method: Unit test with NULL pointer injection, WinDbg (verify no access violation), Event Viewer (verify error logged), Driver Verifier (no crash)


Test Case 6: Malformed Packet EtherType Parse Failure

Given: Malformed Ethernet packet (truncated header, missing EtherType field)
When: FilterReceive attempts EtherType parsing
Then:

  • Parse fails gracefully (buffer length check prevents out-of-bounds read)
  • Packet classified as non-PTP (safe default)
  • Packet forwarded transparently to upper driver
  • Warning logged: "Malformed packet, EtherType parse failed"
  • No timestamp extraction attempted

Expected Results:

  • No access violation (bounds checking)
  • Packet forwarded (not dropped)
  • PTP detection skipped
  • Warning event logged

Validation Method: Fuzz testing (malformed packet injection), packet capture (verify forwarded), Event Viewer (warning logged), WinDbg (no crash)


Test Case 7: RX Timestamp Queue Full (Overflow Handling)

Given: RX timestamp queue full (e.g., 100 entries max, all occupied)
When: New PTP packet arrives requiring timestamp storage
Then:

  • Driver attempts queue insertion
  • Detects queue full condition
  • Oldest timestamp evicted (FIFO policy) OR new timestamp dropped (policy-dependent)
  • Warning logged: "RX timestamp queue full, timestamp lost"
  • Packet still forwarded to upper driver

Expected Results:

  • Queue overflow handled gracefully (no crash)
  • Packet forwarded despite queue full
  • Warning event logged
  • Timestamp lost (expected behavior under extreme load)

Validation Method: Queue overflow test (saturate with 100+ PTP packets), Event Viewer (overflow warning), packet capture (verify forwarding continues)


Test Case 8: RXSTMPL/RXSTMPH Read Timeout (Hardware Unresponsive)

Given: Hardware RX timestamp registers (RXSTMPL @ 0x1C008, RXSTMPH @ 0x1C00C) unresponsive (e.g., device reset in progress)
When: FilterReceive attempts RX timestamp read
Then:

  • Register read times out after 1ms (or returns 0xFFFFFFFF)
  • Error logged: "RX timestamp read timeout"
  • Packet forwarded without timestamp
  • Processing continues (non-fatal error)

Expected Results:

  • Timeout handled gracefully
  • Packet not dropped (forwarded anyway)
  • Error event logged
  • System stable

Validation Method: Hardware simulation (inject register read timeout), Event Viewer (timeout error logged), packet capture (verify forwarding), Driver Verifier (no hang)


Test Case 9: Line-Rate Throughput Non-PTP (≥9.9 Gbps)

Given: iperf3 server receiving at 10 Gbps (1500-byte frames)
When: FilterReceive processes 100% non-PTP traffic for 10 minutes
Then:

  • Throughput ≥9.9 Gbps sustained (≥99% line rate)
  • Packet drop rate <0.01% (max 1 in 10,000 packets)
  • CPU overhead <5% (per-packet processing efficient)
  • Zero memory allocation (Driver Verifier confirms)

Expected Results:

  • iperf3 reports ≥9.9 Gbps throughput
  • Packet loss <0.01%
  • CPU utilization <5%
  • No memory leaks (Driver Verifier pool tracking)

Validation Method: iperf3 throughput measurement, Performance Monitor (CPU%), Driver Verifier (pool usage), 10-minute stress test


Test Case 10: Throughput with PTP Traffic Mix (≥9.0 Gbps)

Given: 10 Gbps traffic: 90% non-PTP (IPv4) + 10% PTP (EtherType 0x88F7)
When: FilterReceive processes mixed traffic for 10 minutes
Then:

  • Throughput ≥9.0 Gbps (accounting for PTP timestamping overhead)
  • PTP packets timestamped (10% of total)
  • Non-PTP packets fast path (90% of total)
  • Packet drop rate <0.01%
  • RX timestamp queue contains PTP entries

Expected Results:

  • Mixed traffic throughput ≥9.0 Gbps
  • Timestamp extraction overhead ~5µs per PTP packet (10% load)
  • Total overhead acceptable (900 Mbps budget for 10% PTP)
  • Packet loss <0.01%

Validation Method: iperf3 + PTP packet generator, throughput measurement, RX timestamp queue inspection, packet loss analysis


Test Case 11: Device Not Initialized (FilterAttach Incomplete)

Given: Miniport indicates packets BEFORE FilterAttach completes (race condition)
When: FilterReceive invoked with FilterModuleContext not fully initialized
Then:

  • Driver validates device context state
  • Detects uninitialized context (e.g., RegisterLock NULL)
  • Returns NDIS_STATUS_NOT_INITIALIZED
  • Packets dropped (or queued until initialization complete)
  • Event logged: "FilterReceive called before FilterAttach complete"

Expected Results:

  • No crash (context validation)
  • NDIS_STATUS_NOT_INITIALIZED returned
  • Packets handled safely (drop or queue)
  • Event logged

Validation Method: Timing race condition simulation (invoke FilterReceive early), WinDbg (context state inspection), Event Viewer (error logged), Driver Verifier (no crash)


Test Case 12: 24-Hour Stress Test (Stability and Leak Detection)

Given: 10 Gbps RX traffic (90% non-PTP, 10% PTP) for 24 hours
When: FilterReceive processes ~8 billion packets (10 Gbps × 86400s ÷ 1500 bytes)
Then:

  • Zero crashes or hangs
  • Zero memory leaks (Driver Verifier pool tracking)
  • Throughput stable ≥9.9 Gbps (non-degrading)
  • Packet drop rate <0.01% maintained
  • CPU overhead <5% maintained
  • RX timestamp queue functional (no corruption)

Expected Results:

  • 24-hour uptime confirmed
  • No memory leaks (pool usage flat)
  • Performance metrics stable
  • System responsive

Validation Method: 24-hour stress test (iperf3 + PTP generator), Performance Monitor (CPU/memory graphs), Driver Verifier (pool tracking), system stability (no BSOD)


Test Execution Plan

Test Phases:

  1. Phase 1: Fast Path Validation (Test Cases 1, 4, 9) - Non-PTP forwarding <1µs
  2. Phase 2: PTP Timestamp Path (Test Cases 2, 10) - PTP timestamp extraction <5µs
  3. Phase 3: Error Handling (Test Cases 5-8, 11) - Null pointers, malformed packets, timeouts
  4. Phase 4: Multi-Packet Processing (Test Case 3) - NBL chain handling
  5. Phase 5: Stress Testing (Test Case 12) - 24-hour endurance test

Test Environment:

  • Hardware: Intel I225-V NIC (10 Gbps capable)
  • OS: Windows 10/11 x64 with Driver Verifier enabled (low resource simulation)
  • Tools: iperf3 (throughput), PTP packet generator, RDTSC timing, WinDbg, ETW tracing, Wireshark

Pass Criteria:

  • All 12 test cases pass
  • Non-PTP fast path <1µs P95
  • PTP path <5µs P95
  • Line-rate throughput ≥9.9 Gbps (non-PTP), ≥9.0 Gbps (mixed)
  • Packet drop rate <0.01%
  • Zero crashes or memory leaks in 24-hour test

Traceability


Test Metadata

Test Type: Functional, Performance, Stress
Test Priority: Critical
Test Execution: Automated (throughput) + Manual (error injection)
Test Duration: ~25 hours (1 hour functional + 24 hours stress test)
Prerequisites: Intel I225 NIC, iperf3, PTP generator, Driver Verifier, RDTSC timing infrastructure

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions