feat: GNSS and DPLL emulation for hardware-free T-GM testing - #9
Open
edcdavid wants to merge 16 commits into
Open
feat: GNSS and DPLL emulation for hardware-free T-GM testing#9edcdavid wants to merge 16 commits into
edcdavid wants to merge 16 commits into
Conversation
- Updated the DPLL initialization process to unregister the kernel's built-in DPLL netlink family and register a custom one for netdevsim devices, using a boolean flag instead of a static kernel pointer. - Prevent restoration of the kernel's built-in DPLL family during module exit, addressing potential memory issues on aarch64. - Added support for external pins in the nsim_dpll structure, including properties and capabilities for four new external pins. - Improved notification handling for external pins during DPLL device changes. - Adjusted cleanup routines to ensure proper unregistration of external pins on exit. - Improved logging to clarify the status of the kernel DPLL family during initialization and cleanup. - Updated the .gitignore file to include additional build artifacts.
- Changed the timecounter initialization in mock_phc_create to utilize ktime_get_clocktai_ns() instead of ktime_get_real_ns(), ensuring accurate timekeeping in the mock PHC implementation.
- Added a writable sysfs interface to allow user-space applications to control the lock status of DPLL devices. - Introduced `lock_status_show` and `lock_status_store` functions to handle reading and writing the lock status. - Updated the `nsim_dpll` structure to include a `lock_status` field and a pointer to the sysfs device. - Ensured proper cleanup of sysfs entries during DPLL device exit. - Initialized the lock status to `DPLL_LOCK_STATUS_LOCKED_HO_ACQ` during DPLL initialization.
- Added `dkms-install` and `dkms-uninstall` targets to the Makefile for managing DKMS modules, including installation and removal procedures. - Introduced `test-dpll` target in the Makefile to facilitate running DPLL unit tests. - Updated README to include detailed instructions for running DPLL unit tests, including usage examples and test coverage details. - Added a new script `test-dpll.sh` for executing DPLL unit tests, covering various aspects of DPLL emulation and device management.
- Replaced the global class-based sysfs interface with a per-instance kobject for DPLL devices, allowing multiple instances to coexist without naming conflicts. - Updated the `lock_status_show` and `lock_status_store` functions to use the new kobject structure. - Modified the `nsim_dpll` structure to include a kobject pointer and a kobj_attribute for lock status. - Enhanced the Makefile clean target to remove build artifacts more efficiently. - Updated the test script to reflect changes in the sysfs path for lock status, ensuring accurate testing of DPLL functionality.
- Updated the mock PHC implementation to capture the internal counter at the PPS edge, improving accuracy in timestamping external events. - Resynchronized the PHC timecounter to current TAI upon enabling external timestamping, ensuring minimal offset for timekeeping. - Added necessary spin locks to protect timecounter reads and initialization, enhancing thread safety in the mock implementation.
- Introduced TAI-based timekeeping in the mock PHC implementation, allowing for more accurate time synchronization. - Added fields for offset, frequency correction, and last TAI snapshot to the mock_phc structure. - Updated timekeeping functions to utilize the new TAI-based approach, ensuring the PHC time remains closely aligned with real TAI. - Removed unnecessary timecounter and cyclecounter references, streamlining the code for better clarity and performance.
- Updated the Makefile to include new test targets: `test-phc`, `test-gnss-ubx`, and `test-all`, facilitating comprehensive testing of the mock PHC and GNSS functionalities. - Introduced `test-gnss-ubx.sh` for unit testing GNSS device emulation and UBX protocol handling, covering various scenarios including signal blocking and NMEA parsing. - Added `test-phc.sh` for testing the mock PTP Hardware Clock, including time read/write, frequency adjustments, and event delivery. - Modified the mock PHC implementation to utilize CLOCK_MONOTONIC for improved timekeeping accuracy, ensuring resilience against time jumps.
- Updated the PTP mock implementation to support a new pin layout, including GNSS-1PPS and four external connectors (SMA1, SMA2, U.FL1, U.FL2). - Introduced a sysfs symlink for the PTP clock, allowing tools to easily locate the PTP device under the PCI device path. - Added a new function to retrieve the kobject for the mock PHC, improving device management and integration with the sysfs interface. - Enhanced the netdevsim structure to include a kobject for PTP compatibility, ensuring proper cleanup during device exit.
- Implemented the nsim_open and nsim_stop functions to manage the network device's carrier state. - Updated the nsim_netdev_ops and nsim_vf_netdev_ops structures to include the new open and stop operations, enhancing the netdevsim functionality.
- Eliminated the multicast flag from the net_device structure in the nsim_setup function, ensuring proper configuration for the simulated network device.
- Introduced a new field `last_extts_sec` in the `mock_phc` structure to prevent duplicate external timestamp events. - Updated the external timestamping logic to poll the PHC time and emit events only when the second counter increments, ensuring accurate event delivery. - Improved the timer rescheduling mechanism for better performance and reliability in timestamp generation. - Enhanced the `mock_phc_enable` function to properly initialize the external timestamping state.
linuxptp-daemon needs NAV-STATUS gpsFix to leave GNSS freerun; ACK-only replies left T-GM stuck at s0 despite locked DPLL and ts2phc.
Keep mock PHC on CLOCK_MONOTONIC with TAI-aligned EXTTS, drive DPLL holdover/freerun from NMEA GGA NoFix (Kind /sys is RO), and open GNSS devices with MODE=0666 for gpsd.
Give TGMBC cascading-holdover tests enough time to observe GM CC7 on the BC before the DPLL drops to FREERUN/CC248.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds kernel-side GNSS and DPLL behavior so netdevsim can stand in for a WPC NIC (U-blox + E810 DPLL) in Kind/ptp-operator CI, without GNSS hardware.
This is the
fix-dashboardstack rebased onto currentmain(virtual CLOCK_REALTIME + kernel 7.0).GNSS device
wpc=1) that gpsd/ts2phc can open as/dev/gnssN.MODE=0666ongnss*so gpsd (nobody) can keep the device; otherwise ts2phc starves for NMEA.DPLL
lock_statusvia per-device PCI sysfs (/sys/bus/pci/devices/<addr>/dpll/lock_status):locked/holdover/freerun.Mock PHC
ptp/sysfs symlink so tools find the clock next to the fake PCI device.Netdev / CI
ndo_open/ndo_stopcarrier; drop IFF_MULTICAST; forward PTP withoutdev_forward_skbso hwtstamps survive cross-netns (kernel 6.11+)./sys/class/nsim_ptpover/sys/class/ptpfor dashboard/pin sysfs.test-dpll.shafter module load.Consumed by ptp-operator GNSS simulation (k8snetworkplumbingwg/ptp-operator#229).
Test plan
make dkms-installon Ubuntu 24.04make test-dpll/test-phc/test-gnss-ubx(ormake test-all)tgm/tgmoc/tgmbcagainst this branchAssisted-By: Cursor