Skip to content

TEST-PTP-IOCTL-LAT-001: Verify IOCTL_AVB_GET_TIMESTAMP and IOCTL_AVB_SET_TIMESTAMP Dispatch Latency #323

Description

@zarfld

Requirement

Derived from #149 (REQ-F-PTP-001) acceptance criteria:

Get Clock Time (IOCTL_AVB_GET_CLOCK_TIME):

  • Latency: <5µs (from IOCTL dispatch to register read)

Set Clock Time (IOCTL_AVB_SET_CLOCK_TIME):

  • Latency: <10µs

Test Objective

Measure the round-trip latency of IOCTL_AVB_GET_TIMESTAMP and IOCTL_AVB_SET_TIMESTAMP
from user-mode DeviceIoControl call start to return, and verify the P50 is within the
latency budget defined in REQ-F-PTP-001.

Method

Use QueryPerformanceCounter bracketing around each DeviceIoControl call.
Collect 1000 samples. Compute P50, P95, P99.
The measurement includes kernel-transition overhead (unavoidable from user-mode).

Test Cases

TC-PTP-LAT-001a: GET_TIMESTAMP P50 latency < 5µs

Preconditions: Driver loaded, handle open, PHC running.

Steps:

  1. Call QueryPerformanceCountert0
  2. Call DeviceIoControl(IOCTL_AVB_GET_TIMESTAMP)
  3. Call QueryPerformanceCountert1
  4. Record latency_us = (t1 - t0) / freq * 1e6
  5. Repeat 1000 times
  6. Sort; extract P50

Acceptance Criterion: P50 < 5µs (REQ-F-PTP-001 §1)

Expected Status: ⚠️ May fail — kernel-transition from user-mode typically adds 1–3µs;
whether the total stays < 5µs depends on system load and driver implementation.


TC-PTP-LAT-001b: SET_TIMESTAMP P50 latency < 10µs

Steps:

  1. Bracket DeviceIoControl(IOCTL_AVB_SET_TIMESTAMP) with QPC
  2. Repeat 100 times (write operations; destructive to PHC state)
  3. Extract P50

Acceptance Criterion: P50 < 10µs (REQ-F-PTP-001 §2)


TC-PTP-LAT-001c: GET_TIMESTAMP returns non-zero incrementing value

Steps:

  1. Read PHC at t=0
  2. Sleep 100 ms
  3. Read PHC at t=1
  4. Assert phc_t1 > phc_t0

Acceptance Criterion: PHC is running (monotonically incrementing)

Acceptance Criteria Summary

  • IOCTL_AVB_GET_TIMESTAMP P50 latency < 5µs over 1000 calls
  • IOCTL_AVB_SET_TIMESTAMP P50 latency < 10µs over 100 calls
  • ✅ PHC timestamp monotonically increases between calls

Implementation

  • New test file: tests/integration/ptp/ptp_ioctl_latency_test.c
  • Build target: ptp_ioctl_latency_test

Traceability

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions