Infrastructure: Mock NDIS Unit Test Harness
Type: Infrastructure / Test Engineering
Priority: P0
Phase: 07-verification-validation
Blocks: Full closure of TEST-PTP-CORR-001 (#199)
Traceability
Traces to: #149 (REQ-F-PTP-007: Hardware Timestamp Correlation)
Related to: #199 (TEST-PTP-CORR-001 — 13 tests not yet run)
Related to: #48 (REQ-F-IOCTL-PHC-004: Cross-Timestamp IOCTL — needed by Track B)
Related to: #177 (TEST-EVENT-001 — would also benefit from mock harness patterns)
Related to: #179 (TEST-EVENT-005 — would also benefit from mock harness patterns)
Context
Issue #199 was closed on 2026-03-27 with only 4 of 17 specified tests run (IT-CORR-001, 003, 004 PASS; IT-CORR-002 SKIP).
The remaining 13 tests (10 unit + 3 V&V) could not run because:
- Missing IOCTLs (
IOCTL_AVB_PHC_CROSSTIMESTAMP, IOCTL_AVB_GET_RX_TIMESTAMP)
- Different clock epochs between FastIo TX timestamp path (QPC-relative) and PHC query (SYSTIM-relative)
- No long-running monitoring script for 24h V&V test
- No gPTP infrastructure for production workload V&V
#199 has been reopened. This issue tracks the infrastructure work needed.
Objective
Build the infrastructure to enable all 13 remaining tests in #199, organized into four tracks.
Work Tracks
Track A — Extend IOCTL Harness (Sprint 5, ~2 days)
Add test cases to tests/integration/ptp_corr/test_ptp_corr_extended.c.
No new driver changes required.
Acceptance: avb_test_ptp_corr_ext.exe runs; all 5 tests PASS on ≥2 adapters.
Track B — IOCTL_AVB_PHC_CROSSTIMESTAMP (Sprint 5, ~3 days)
Implement IOCTL code 27 in src/device.c (per #48).
Returns {phcTimestampNs, systemTimestampTicks, correlationAccuracyNs}.
Acceptance: IT-CORR-002 no longer SKIP — PASS on all adapters. UT-CORR-003 PASS.
Track C — IOCTL_AVB_GET_RX_TIMESTAMP (Sprint 6, ~4 days)
Store NIC's hardware RX timestamp in AVB_ADAPTER_CONTEXT (via NDIS receive path).
Add new IOCTL (similar to IOCTL_AVB_GET_TX_TIMESTAMP).
Track D — Epoch Unification (Sprint 6, ~3 days)
Unify last_ndis_tx_timestamp (currently QPC-relative) and IOCTL_AVB_GET_TIMESTAMP (currently SYSTIM epoch) so both report values in the same domain. This enables the absolute bracket test phc_before ≤ txTs ≤ phc_after.
Preferred approach (Option D1):
Track E — Long-Running V&V Scripts (Sprint 5–Future)
Full Gate: #199 Can Re-close When
Reference Documents
Infrastructure: Mock NDIS Unit Test Harness
Type: Infrastructure / Test Engineering
Priority: P0
Phase: 07-verification-validation
Blocks: Full closure of TEST-PTP-CORR-001 (#199)
Traceability
Traces to: #149 (REQ-F-PTP-007: Hardware Timestamp Correlation)
Related to: #199 (TEST-PTP-CORR-001 — 13 tests not yet run)
Related to: #48 (REQ-F-IOCTL-PHC-004: Cross-Timestamp IOCTL — needed by Track B)
Related to: #177 (TEST-EVENT-001 — would also benefit from mock harness patterns)
Related to: #179 (TEST-EVENT-005 — would also benefit from mock harness patterns)
Context
Issue #199 was closed on 2026-03-27 with only 4 of 17 specified tests run (IT-CORR-001, 003, 004 PASS; IT-CORR-002 SKIP).
The remaining 13 tests (10 unit + 3 V&V) could not run because:
IOCTL_AVB_PHC_CROSSTIMESTAMP,IOCTL_AVB_GET_RX_TIMESTAMP)#199 has been reopened. This issue tracks the infrastructure work needed.
Objective
Build the infrastructure to enable all 13 remaining tests in #199, organized into four tracks.
Work Tracks
Track A — Extend IOCTL Harness (Sprint 5, ~2 days)
Add test cases to
tests/integration/ptp_corr/test_ptp_corr_extended.c.No new driver changes required.
IOCTL_AVB_SET_TIMESTAMP(0))Acceptance:
avb_test_ptp_corr_ext.exeruns; all 5 tests PASS on ≥2 adapters.Track B —
IOCTL_AVB_PHC_CROSSTIMESTAMP(Sprint 5, ~3 days)Implement IOCTL code 27 in
src/device.c(per #48).Returns
{phcTimestampNs, systemTimestampTicks, correlationAccuracyNs}.ops->get_systim()+KeQueryPerformanceCounterin one critical sectiontest_ptp_corr_extended.c: delta <10µsAcceptance: IT-CORR-002 no longer SKIP — PASS on all adapters. UT-CORR-003 PASS.
Track C —
IOCTL_AVB_GET_RX_TIMESTAMP(Sprint 6, ~4 days)Store NIC's hardware RX timestamp in
AVB_ADAPTER_CONTEXT(via NDIS receive path).Add new IOCTL (similar to
IOCTL_AVB_GET_TX_TIMESTAMP).IndicateReceiveNetBufferListsorReturnNetBufferListsTrack D — Epoch Unification (Sprint 6, ~3 days)
Unify
last_ndis_tx_timestamp(currently QPC-relative) andIOCTL_AVB_GET_TIMESTAMP(currently SYSTIM epoch) so both report values in the same domain. This enables the absolute bracket testphc_before ≤ txTs ≤ phc_after.Preferred approach (Option D1):
At
AvbBringUpHardware(), atomically read SYSTIM + QPC, computeepoch_offset_ns = systim_ns - qpc_nsStore
epoch_offset_nsinAVB_ADAPTER_CONTEXTFastIoTX path: storeqpc_ns(unchanged from current fix)IOCTL_AVB_GET_TIMESTAMP: returnsystim_ns - epoch_offset_ns— both now QPC-relativeVerify gPTP callers are not sensitive to PHC absolute epoch before implementing
Implement epoch_offset in
AvbBringUpHardware()Adjust
IOCTL_AVB_GET_TIMESTAMPhandlerUT-CORR-001: PASS (bracket test) in
test_ptp_corr_extended.cUT-CORR-010: PASS — test graceful behavior when TX HW timestamps disabled (via error inject path)
All existing PHC tests still PASS (full regression)
Track E — Long-Running V&V Scripts (Sprint 5–Future)
Full Gate: #199 Can Re-close When
Reference Documents
07-verification-validation/test-plans/TEST-PLAN-MOCK-NDIS-HARNESS.mdtests/integration/ptp_corr/test_ptp_corr.c