From 9a655f12d74a3e0488df73ac35ddd3fe81688767 Mon Sep 17 00:00:00 2001 From: Matt Day Date: Tue, 22 Sep 2026 14:12:37 +0000 Subject: [PATCH 1/2] Add initial qnx_code_inventory.md --- docs/index.rst | 6 ++++ docs/internal/qnx_code_inventory.md | 44 +++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 docs/internal/qnx_code_inventory.md diff --git a/docs/index.rst b/docs/index.rst index 4a401bb6..067a4117 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -45,6 +45,12 @@ For a detailed concept and architectural design, please refer to the :doc:`time_ features/index module/index +.. toctree:: + :maxdepth: 1 + :caption: Internal + + internal/qnx_code_inventory + Project Layout -------------- diff --git a/docs/internal/qnx_code_inventory.md b/docs/internal/qnx_code_inventory.md new file mode 100644 index 00000000..7d1378eb --- /dev/null +++ b/docs/internal/qnx_code_inventory.md @@ -0,0 +1,44 @@ +# QNX-Specific Code Inventory: score_time + +> **Context:** This document identifies and catalogs all code segments within this repository that contain native QNX API dependencies and cannot be compiled, executed, or tested in a standard Linux environment. This inventory is critical to justify our Linux-based code coverage strategy to safety assessors for the end-of-year QM Release. + +--- + +## Metadata +* **Component / Module:** `score_time` +* **Owner Team:** `COM` +* **Technical Contact:** `Jochen Speck / JochenMatthias.Speck@etas.com` +* **Date of Last Assessment:** `2026-09-24` + +--- + +## Summary Metrics +* **Total Files Scanned:** `333 (124 .cpp; 120 .h; 89 BUILD)` +* **Files with QNX Dependencies:** `13 (9 .cpp/.h; 4 QNX image/test configuration)` +* **Estimated Total Lines of Code (LoC) Affected:** `1222 LoC (843 .cpp/.h; 379 QNX image/test configuration)` +* **Affected % of Repository Codebase:** `5% (843 of 15632 .cpp/.h LoC)` + +> **LoC basis:** Non-blank, non-comment lines. Only production sources are counted; unit tests, mocks and `BUILD` files are excluded, except in the QNX reference integration package where the `BUILD` file is itself the QNX image definition. + +--- + +## QNX Dependency Inventory + +| File Path & Line Range | QNX API / Header Dependency | Est. LoC | Root Cause (Why is it not testable on Linux?) | Verification Alternative (How is this tested instead?) | +|---|---|---|---|---| +|[score/time/high_res_steady_time/src/details/qtime/**](../../score/time/high_res_steady_time/src/details/qtime/)|1. `#include ` : `SYSPAGE_ENTRY(qtime)->cycles_per_sec`.
2. `#include "score/os/qnx/neutrino.h"` : `score::os::qnx::Neutrino::instance().ClockCycles()`.|113|Contains QNX platform-specific implementations of functions used in the high resolution steady clock.|QNX-only unit tests (`target_compatible_with = ["@platforms//os:qnx"]`): `high_res_steady_qclock_test`, `tick_provider_test`, `factory_test`.| +|[score/time_slave/src/gptp/platform/qnx/**](../../score/time_slave/src/gptp/platform/qnx/)|1. `#include ` : `/dev/bpf`, `BIOCSETIF`, `BIOCSSEESENT`, `BIOCIMMEDIATE`, `BIOCPROMISC`, `BIOCSTSTAMP`, `BIOCSETF`, `BIOCGBLEN`.
2. `#include ` : `IFNAMSIZ`, `struct ifreq`, `IFF_PROMISC`, `IFF_ALLMULTI`, `SIOCGIFFLAGS`, `SIOCSIFFLAGS`, `SIOCADDMULTI`.
3. `#include ` : `AF_LINK`, `struct sockaddr_dl`, `LLADDR`.
4. Qualcomm EMAC driver ioctls via `struct ifdrv` / `SIOCGDRVSPEC`: `PTP_GET_TIME` (0x102), `PTP_SET_TIME` (0x103), `EMAC_PTP_ADJ_FREQ_PPM` (52).|724|Contains QNX platform-specific implementations of the raw socket (BPF frame RX/TX with hardware timestamps), network identity (MAC address lookup) and PHC adjuster (EMAC clock step/frequency adjustment) used by the time slave.|No unit tests exercise these sources: `raw_socket_test` is Linux-only (`target_compatible_with = ["@platforms//os:linux"]`) and `bpf_device_path_test.cpp` has no Bazel target and includes a header that does not exist. The only QNX verification is the `time_slave_qnx_ref_integ` QEMU smoke test (binary/config deployment and config parsing).| +|[score/time_slave/src/gptp/details/ptp_types.h#L25-L30](../../score/time_slave/src/gptp/details/ptp_types.h#L25-L30)|None (preprocessor guard for QNX definition).|6| A simple data struct must be defined which is otherwise available via `#include `.|Unnecessary due to trivial definition.| +|[score/time_slave/tests/reference_integration/qnx/**](../../score/time_slave/tests/reference_integration/qnx/)|1. `qnx_ifs` rule (`@score_rules_imagefs//rules/qnx:ifs.bzl`) : QNX SDP `mkifs` image build.
2. `init.build` / `tools.build` : `procnto-smp-instr`, `startup-x86`, `procmgr_symlink`, `io-sock` with `devs-vtnet_pci.so`, `devc-ser8250`, `pci-server`, `slogger2`, and QNX runtime libraries (`ldqnx-64.so.2`, `libsocket`, etc.).|379|QNX IFS boot image definition and deployed configuration for the `time_slave_qnx_ref_integ` test. All targets are `target_compatible_with = ["@platforms//os:qnx"]` and require the QNX SDP toolchain and licence to build.|Not applicable (test infrastructure, not production code). The image is built and booted under QEMU by `time_slave_qnx_ref_integ`, which verifies deployment and config parsing of the QNX binary.| + +--- + +## Verification Strategy for Excluded Code +> **Status:** Not yet assessed. This section is intentionally deferred beyond the current revision of this inventory. +> +> Until then, the current verification of each excluded item is recorded in the *Verification Alternative* column of the [QNX Dependency Inventory](#qnx-dependency-inventory). + +--- + +## Action Items / Refactoring Opportunities +> **Status:** Not yet assessed. This section is intentionally deferred beyond the current revision of this inventory. From 31abb146b43c9f08b0c8d5d10f38f7ca694c708c Mon Sep 17 00:00:00 2001 From: Matt Day Date: Thu, 24 Sep 2026 09:31:20 +0000 Subject: [PATCH 2/2] Fix minor issues found when reviewing QNX-specific code: stale comment, unused includes, mismatched signature --- score/time_slave/src/gptp/details/network_identity_impl.h | 2 +- score/time_slave/src/gptp/platform/qnx/raw_socket.cpp | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/score/time_slave/src/gptp/details/network_identity_impl.h b/score/time_slave/src/gptp/details/network_identity_impl.h index f7311104..11d07fbf 100644 --- a/score/time_slave/src/gptp/details/network_identity_impl.h +++ b/score/time_slave/src/gptp/details/network_identity_impl.h @@ -30,7 +30,7 @@ namespace details * * The identity is built from the interface's EUI-48 MAC address by inserting * 0xFF 0xFE at positions 3–4 to form an EUI-64 (per IEEE 1588-2019 §7.5.2.2). - * Platform implementation: Linux + QNX via #ifdef. + * Platform implementation: Linux + QNX, selected via Bazel select() in BUILD. */ class NetworkIdentityImpl : public NetworkIdentity { diff --git a/score/time_slave/src/gptp/platform/qnx/raw_socket.cpp b/score/time_slave/src/gptp/platform/qnx/raw_socket.cpp index 6a912c87..7908ea46 100644 --- a/score/time_slave/src/gptp/platform/qnx/raw_socket.cpp +++ b/score/time_slave/src/gptp/platform/qnx/raw_socket.cpp @@ -12,9 +12,7 @@ ********************************************************************************/ #include "score/time_slave/src/gptp/details/raw_socket_impl.h" -#include #include -#include #include #include #include @@ -24,7 +22,7 @@ extern "C" { int qnx_raw_open(const char* ifname); int qnx_raw_recv(int fd, void* buf, int len, ::timespec* hwts, int nonblock); -int qnx_raw_send(int fd, void* buf, int len, ::timespec* hwts); +int qnx_raw_send(int fd, const void* buf, int len, ::timespec* hwts); } // extern "C" namespace score @@ -83,7 +81,7 @@ int RawSocketImpl::Send(const void* buf, int len, ::timespec& hwts) { if (fd_ < 0 || buf == nullptr || len <= 0) return -1; - return qnx_raw_send(fd_, const_cast(buf), len, &hwts); + return qnx_raw_send(fd_, buf, len, &hwts); } } // namespace details