diff --git a/docs/features/time_slave/_assets/shm_ptp_engine/shm_ptp_engine_class.puml b/docs/features/time_slave/_assets/shm_ptp_engine/shm_ptp_engine_class.puml deleted file mode 100644 index 1b5486c6..00000000 --- a/docs/features/time_slave/_assets/shm_ptp_engine/shm_ptp_engine_class.puml +++ /dev/null @@ -1,105 +0,0 @@ -@startuml shm_ptp_engine_class_diagram -!theme plain - -title ShmPTPEngine: Class Diagram - -legend top left - |= Color |= Description | - | <#Beige> | Base classes / data types | - | <#Wheat> | PTPMachine / ShmPTPEngine | - | <#LightPink> | libTSClient IPC | -endlegend - -package "score::td" { - class "GPTPShmMachine" as real_machine #Wheat { - type alias for PTPMachine - -- - Constructed via CreateGPTPShmMachine() - } -} - -package "score::td (base classes)" { - abstract class "BaseMachine" as base_machine #Beige { - + GetName() : string - + Init() : bool - } - - abstract class "ProactiveMachine" as proactive_machine #Beige { - + Start() : void - + Stop() : void - } - - abstract class "PeriodicMachine" as periodic_machine #Beige { - # PeriodicTask() : void - } - - abstract class "Producer" as producer #Beige { - + SetPublishCallback(cb) : void - # Publish(data : T) : void - } - - class "PTPMachine" as ptp_machine #Wheat { - - engine_ : PTPEngine - + Init() : bool - + SetPublishCallback(cb) : void - # PeriodicTask() : void - } - - base_machine <|-- proactive_machine - proactive_machine <|-- periodic_machine - periodic_machine <|-- ptp_machine - producer <|.. ptp_machine -} - -package "score::td::details" { - class ShmPTPEngine #Wheat { - - ipc_name_ : string - - receiver_ : GptpIpcReceiver - - initialized_ : bool - + ShmPTPEngine(ipc_name : string) - + Initialize() : bool - + Deinitialize() : bool - + ReadPTPSnapshot(info : PtpTimeInfo&) : bool - } -} - -package "score::ts::details" { - class GptpIpcReceiver #LightPink { - + Init(name : string) : bool - + Receive() : optional - + Close() : void - } -} - -package "Data Types" { - class GptpIpcData #Beige { - + ptp_assumed_time : chrono::nanoseconds - + local_time : chrono::nanoseconds - + rate_deviation : double - + status : GptpIpcStatus - + sync_fup_data : GptpIpcSyncFupData - + pdelay_data : GptpIpcPDelayData - } - - class PtpTimeInfo #Beige { - + ptp_assumed_time - + local_time - + rate_deviation - + status - + sync_fup_data - + pdelay_data - } -} - -ptp_machine *-- ShmPTPEngine : PTPEngine = ShmPTPEngine -ShmPTPEngine *-- GptpIpcReceiver -ShmPTPEngine ..> GptpIpcData : reads -ShmPTPEngine ..> PtpTimeInfo : produces -real_machine --|> ptp_machine : alias - -note right of ShmPTPEngine - Maps GptpIpcData → PtpTimeInfo - on every ReadPTPSnapshot() call. -end note - -@enduml diff --git a/docs/features/time_slave/_assets/shm_ptp_engine/shm_ptp_engine_init_seq.puml b/docs/features/time_slave/_assets/shm_ptp_engine/shm_ptp_engine_init_seq.puml deleted file mode 100644 index 1a3d2f62..00000000 --- a/docs/features/time_slave/_assets/shm_ptp_engine/shm_ptp_engine_init_seq.puml +++ /dev/null @@ -1,82 +0,0 @@ -@startuml shm_ptp_engine_init_seq -!theme plain - -title ShmPTPEngine: Initialization Sequence - -hide footbox -autonumber "[00]" - -legend top left - |= Color |= Description | - | <#LightCyan> | TimeDaemon | - | <#Wheat> | GPTPShmMachine | - | <#LightPink> | libTSClient IPC | -endlegend - -participant "TimeBaseHandler" as tb #LightCyan -participant "GPTPShmMachine\n(PTPMachine)" as machine #Wheat -participant "ShmPTPEngine" as engine #Wheat -participant "GptpIpcReceiver" as receiver #LightPink -participant "MessageBroker" as broker #LightCyan - -== Construction == - -tb -> machine ** : CreateGPTPShmMachine("shm", "/gptp_ptp_info") -activate tb -activate machine -machine -> engine ** : ShmPTPEngine("/gptp_ptp_info") -engine -> receiver ** : GptpIpcReceiver() -machine --> tb -deactivate machine -deactivate tb - -== Initialization == - -tb -> machine : Init() -activate tb -activate machine -machine -> engine : Initialize() -activate engine -engine -> receiver : Init("/gptp_ptp_info") -activate receiver -note right of receiver - shm_open(O_RDONLY) - mmap(PROT_READ) - verify magic == 0x47505450 -end note -receiver --> engine : true / false -deactivate receiver -engine --> machine -deactivate engine -machine --> tb -deactivate machine -deactivate tb - -== Setup Producer == - -tb -> broker : subscribe machine to "raw_ptp_data" topic -activate tb -activate broker -broker -> machine : SetPublishCallback(broker::OnNewData) -activate machine -machine --> broker -deactivate machine -broker --> tb -deactivate broker -deactivate tb - -== Start Periodic Operation == - -tb -> machine : Start() -activate tb -activate machine -machine -> machine : start periodic thread -note right - Begin periodic IPC reads - from shared memory -end note -machine --> tb -deactivate machine -deactivate tb - -@enduml diff --git a/docs/features/time_slave/_assets/shm_ptp_engine/shm_ptp_engine_read_seq.puml b/docs/features/time_slave/_assets/shm_ptp_engine/shm_ptp_engine_read_seq.puml deleted file mode 100644 index 0a6a9142..00000000 --- a/docs/features/time_slave/_assets/shm_ptp_engine/shm_ptp_engine_read_seq.puml +++ /dev/null @@ -1,73 +0,0 @@ -@startuml shm_ptp_engine_read_seq -!theme plain - -title ShmPTPEngine: Periodic Read and Publish Workflow - -hide footbox -autonumber "[00]" - -legend top left - |= Color |= Description | - | <#Wheat> | GPTPShmMachine | - | <#LightPink> | libTSClient IPC | - | <#LightCyan> | Shared Memory | - | <#PaleTurquoise> | MessageBroker | - | <#LightBlue> | ControlFlowDivider | -endlegend - -participant "PTPMachine\n(PeriodicTask)" as machine #Wheat -participant "ShmPTPEngine" as engine #Wheat -participant "GptpIpcReceiver" as receiver #LightPink -participant "SharedMemory\n(GptpIpcRegion)" as shm #LightCyan -participant "MessageBroker" as broker #PaleTurquoise -participant "ControlFlowDivider" as cfd #LightBlue - -loop periodic (e.g., every 50 ms) - activate machine - machine -> machine : PeriodicTask() - - machine -> engine : ReadPTPSnapshot(info) - activate engine - engine -> receiver : Receive() - activate receiver - receiver -> shm : seqlock read (up to 20 retries) - activate shm - note right of shm - 1. read seq1 (acquire, must be even) - 2. memcpy GptpIpcData - 3. fence, read seq_confirm + seq - 4. verify seq1 == seq2 == seq3 - end note - shm --> receiver : GptpIpcData or contention - deactivate shm - receiver --> engine : optional - deactivate receiver - - alt data available - engine -> engine : map GptpIpcData → PtpTimeInfo - note right - status, ptp_assumed_time, - local_time, rate_deviation, - sync_fup_data, pdelay_data - end note - engine --> machine : true (PtpTimeInfo filled) - else no data (nullopt) - engine --> machine : false - end - deactivate engine - - alt ReadPTPSnapshot returned true - machine -> machine : Publish(PtpTimeInfo) - machine -> broker : publish_callback_(PtpTimeInfo) - activate broker - broker -> cfd : subscription.callback_(PtpTimeInfo) - activate cfd - cfd --> broker - deactivate cfd - broker --> machine - deactivate broker - end - deactivate machine -end - -@enduml diff --git a/docs/features/time_slave/_assets/ts_client/ipc_channel.puml b/docs/features/time_slave/_assets/ts_client/ipc_channel.puml deleted file mode 100644 index ba0ce3c7..00000000 --- a/docs/features/time_slave/_assets/ts_client/ipc_channel.puml +++ /dev/null @@ -1,71 +0,0 @@ -@startuml -!theme plain - -title libTSClient Shared Memory IPC - -legend top left - |= Color |= Description | - | <#LightPink> | IPC components | - | <#LightCyan> | Shared memory region | - | <#LightSalmon> | TimeDaemon adapter | -endlegend - -package "TimeSlave Process" { - class GptpIpcPublisher #LightPink { - - region_ : GptpIpcRegion* - - shm_resource_ : shared_ptr - - ipc_name_ : string - + Init(name) : bool - + Publish(data : GptpIpcData) : void - + Destroy() : void - } -} - -package "Shared Memory" { - class GptpIpcRegion <> #LightCyan { - + magic : atomic = 0x47505450 - + seq : atomic - + data : GptpIpcData - + seq_confirm : atomic - -- - 64-byte aligned for\ncache line efficiency - } -} - -package "TimeDaemon Process" { - class GptpIpcReceiver #LightPink { - - region_ : const GptpIpcRegion* - - shm_resource_ : shared_ptr - + Init(name) : bool - + Receive() : std::optional - + Close() : void - } - - class ShmPTPEngine #LightSalmon { - - receiver_ : GptpIpcReceiver - - ipc_name_ : string - + Initialize() : bool - + Deinitialize() : bool - + ReadPTPSnapshot(info : PtpTimeInfo&) : bool - } -} - -GptpIpcPublisher --> GptpIpcRegion : "shm_open(O_CREAT)\nmmap(PROT_WRITE)" -GptpIpcReceiver --> GptpIpcRegion : "shm_open(O_RDONLY)\nmmap(PROT_READ)" -ShmPTPEngine *-- GptpIpcReceiver -ShmPTPEngine ..> "PtpTimeInfo" : converts to - -note right of GptpIpcRegion - **Seqlock Protocol:** - Writer: seq++ (odd) → fence → memcpy → seq_confirm++, seq++ (even) - Reader: read seq1 (even) → memcpy → fence → read seq2, seq3 - retry if seq1 != seq2 or seq1 != seq3 - Retry up to 20 times on torn read -end note - -note bottom of ShmPTPEngine - Maps GptpIpcData fields to PtpTimeInfo. - Instantiated as GPTPShmMachine via CreateGPTPShmMachine(). -end note - -@enduml diff --git a/docs/features/time_slave/_assets/ts_client/ipc_sequence.puml b/docs/features/time_slave/_assets/ts_client/ipc_sequence.puml deleted file mode 100644 index 4139f95b..00000000 --- a/docs/features/time_slave/_assets/ts_client/ipc_sequence.puml +++ /dev/null @@ -1,52 +0,0 @@ -@startuml -!theme plain - -title libTSClient Seqlock IPC Protocol - -participant "TimeSlave\n(GptpIpcPublisher)" as PUB #LightPink -participant "SharedMemory\n(GptpIpcRegion)" as SHM #LightCyan -participant "TimeDaemon\n(GptpIpcReceiver)" as RCV #LightPink - -== Initialization == - -PUB -> SHM : shm_open("/gptp_ptp_info", O_CREAT | O_RDWR) -PUB -> SHM : ftruncate(sizeof(GptpIpcRegion)) -PUB -> SHM : mmap(PROT_READ | PROT_WRITE) -PUB -> SHM : write magic = 0x47505450 ('GPTP') - -... - -RCV -> SHM : shm_open("/gptp_ptp_info", O_RDONLY) -RCV -> SHM : mmap(PROT_READ) -RCV -> SHM : verify magic == 0x47505450 - -== Publish (Writer Side) == - -PUB -> SHM : seq.fetch_add(1, relaxed) // seq becomes odd (write in progress) -PUB -> SHM : atomic_thread_fence(release) -PUB -> SHM : memcpy(&data, &src, sizeof(GptpIpcData)) -PUB -> SHM : seq_confirm.store(seq+1, release) // seq_confirm becomes even -PUB -> SHM : seq.store(seq+1, release) // seq becomes even (write done) - -== Receive (Reader Side) == - -loop up to 20 retries - RCV -> SHM : seq1 = seq.load(acquire) - alt seq1 is odd (write in progress) - RCV -> RCV : retry - else seq1 is even - RCV -> SHM : memcpy(&local, &data, sizeof(GptpIpcData)) - RCV -> SHM : atomic_thread_fence(acq_rel) - RCV -> SHM : seq2 = seq_confirm.load(acquire) - RCV -> SHM : seq3 = seq.load(acquire) - alt seq1 == seq2 && seq1 == seq3 - RCV --> RCV : return GptpIpcData (consistent) - else torn read (new write started) - RCV -> RCV : retry - end - end -end - -RCV --> RCV : return std::nullopt (exhausted retries) - -@enduml diff --git a/score/time_slave/docs/architecture/.gitkeep b/score/time_slave/docs/architecture/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/score/time_slave/docs/component_classification.rst b/score/time_slave/docs/component_classification.rst deleted file mode 100644 index bf6b15db..00000000 --- a/score/time_slave/docs/component_classification.rst +++ /dev/null @@ -1,21 +0,0 @@ -.. - # ******************************************************************************* - # Copyright (c) 2026 Contributors to the Eclipse Foundation - # - # See the NOTICE file(s) distributed with this work for additional - # information regarding copyright ownership. - # - # This program and the accompanying materials are made available under the - # terms of the Apache License Version 2.0 which is available at - # https://www.apache.org/licenses/LICENSE-2.0 - # - # SPDX-License-Identifier: Apache-2.0 - # ******************************************************************************* - -Component Classification -======================== - -:Component: time_slave -:ASIL Level: QM -:Language: C++ -:Platform: Linux, QNX diff --git a/score/time_slave/docs/detailed_design/.gitkeep b/score/time_slave/docs/detailed_design/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/features/time_slave/_assets/gptp_engine/gptp_engine_class.puml b/score/time_slave/docs/detailed_design/_assets/gptp_engine/gptp_engine_class.puml similarity index 86% rename from docs/features/time_slave/_assets/gptp_engine/gptp_engine_class.puml rename to score/time_slave/docs/detailed_design/_assets/gptp_engine/gptp_engine_class.puml index 39209e23..ddb58bb0 100644 --- a/docs/features/time_slave/_assets/gptp_engine/gptp_engine_class.puml +++ b/score/time_slave/docs/detailed_design/_assets/gptp_engine/gptp_engine_class.puml @@ -1,3 +1,16 @@ +' ******************************************************************************* +' Copyright (c) 2026 Contributors to the Eclipse Foundation +' +' See the NOTICE file(s) distributed with this work for additional +' information regarding copyright ownership. +' +' This program and the accompanying materials are made available under the +' terms of the Apache License Version 2.0 which is available at +' https://www.apache.org/licenses/LICENSE-2.0 +' +' SPDX-License-Identifier: Apache-2.0 +' ******************************************************************************* + @startuml !theme plain diff --git a/docs/features/time_slave/_assets/gptp_engine/gptp_threading.puml b/score/time_slave/docs/detailed_design/_assets/gptp_engine/gptp_threading.puml similarity index 67% rename from docs/features/time_slave/_assets/gptp_engine/gptp_threading.puml rename to score/time_slave/docs/detailed_design/_assets/gptp_engine/gptp_threading.puml index 79ee3b2a..dd9e4d55 100644 --- a/docs/features/time_slave/_assets/gptp_engine/gptp_threading.puml +++ b/score/time_slave/docs/detailed_design/_assets/gptp_engine/gptp_threading.puml @@ -1,3 +1,16 @@ +' ******************************************************************************* +' Copyright (c) 2026 Contributors to the Eclipse Foundation +' +' See the NOTICE file(s) distributed with this work for additional +' information regarding copyright ownership. +' +' This program and the accompanying materials are made available under the +' terms of the Apache License Version 2.0 which is available at +' https://www.apache.org/licenses/LICENSE-2.0 +' +' SPDX-License-Identifier: Apache-2.0 +' ******************************************************************************* + @startuml gptp_threading_model title gPTP Engine Threading Model diff --git a/docs/features/time_slave/_assets/timeslave_class.puml b/score/time_slave/docs/detailed_design/_assets/timeslave_class.puml similarity index 86% rename from docs/features/time_slave/_assets/timeslave_class.puml rename to score/time_slave/docs/detailed_design/_assets/timeslave_class.puml index 6e2560ab..bc43227f 100644 --- a/docs/features/time_slave/_assets/timeslave_class.puml +++ b/score/time_slave/docs/detailed_design/_assets/timeslave_class.puml @@ -1,3 +1,16 @@ +' ******************************************************************************* +' Copyright (c) 2026 Contributors to the Eclipse Foundation +' +' See the NOTICE file(s) distributed with this work for additional +' information regarding copyright ownership. +' +' This program and the accompanying materials are made available under the +' terms of the Apache License Version 2.0 which is available at +' https://www.apache.org/licenses/LICENSE-2.0 +' +' SPDX-License-Identifier: Apache-2.0 +' ******************************************************************************* + @startuml !theme plain diff --git a/docs/features/time_slave/_assets/timeslave_data_flow.puml b/score/time_slave/docs/detailed_design/_assets/timeslave_data_flow.puml similarity index 77% rename from docs/features/time_slave/_assets/timeslave_data_flow.puml rename to score/time_slave/docs/detailed_design/_assets/timeslave_data_flow.puml index 3981db47..dd3ebbf2 100644 --- a/docs/features/time_slave/_assets/timeslave_data_flow.puml +++ b/score/time_slave/docs/detailed_design/_assets/timeslave_data_flow.puml @@ -1,3 +1,16 @@ +' ******************************************************************************* +' Copyright (c) 2026 Contributors to the Eclipse Foundation +' +' See the NOTICE file(s) distributed with this work for additional +' information regarding copyright ownership. +' +' This program and the accompanying materials are made available under the +' terms of the Apache License Version 2.0 which is available at +' https://www.apache.org/licenses/LICENSE-2.0 +' +' SPDX-License-Identifier: Apache-2.0 +' ******************************************************************************* + @startuml !theme plain diff --git a/docs/features/time_slave/_assets/timeslave_deployment.puml b/score/time_slave/docs/detailed_design/_assets/timeslave_deployment.puml similarity index 72% rename from docs/features/time_slave/_assets/timeslave_deployment.puml rename to score/time_slave/docs/detailed_design/_assets/timeslave_deployment.puml index 2e922ca9..2cd6c955 100644 --- a/docs/features/time_slave/_assets/timeslave_deployment.puml +++ b/score/time_slave/docs/detailed_design/_assets/timeslave_deployment.puml @@ -1,3 +1,16 @@ +' ******************************************************************************* +' Copyright (c) 2026 Contributors to the Eclipse Foundation +' +' See the NOTICE file(s) distributed with this work for additional +' information regarding copyright ownership. +' +' This program and the accompanying materials are made available under the +' terms of the Apache License Version 2.0 which is available at +' https://www.apache.org/licenses/LICENSE-2.0 +' +' SPDX-License-Identifier: Apache-2.0 +' ******************************************************************************* + @startuml !theme plain skinparam nodesep 40 diff --git a/score/time_slave/docs/detailed_design/chklst_impl_inspection.rst b/score/time_slave/docs/detailed_design/chklst_impl_inspection.rst new file mode 100644 index 00000000..b107011b --- /dev/null +++ b/score/time_slave/docs/detailed_design/chklst_impl_inspection.rst @@ -0,0 +1,125 @@ +.. + # ******************************************************************************* + # Copyright (c) 2026 Contributors to the Eclipse Foundation + # + # See the NOTICE file(s) distributed with this work for additional + # information regarding copyright ownership. + # + # This program and the accompanying materials are made available under the + # terms of the Apache License Version 2.0 which is available at + # https://www.apache.org/licenses/LICENSE-2.0 + # + # SPDX-License-Identifier: Apache-2.0 + # ******************************************************************************* + +.. document:: Time Slave Implementation Inspection Checklist + :id: doc__time_slave_impl_inspection + :status: draft + :version: 1 + :safety: ASIL_B + :security: YES + :realizes: wp__sw_implementation_inspection + :tags: time_slave + +.. note:: + Work in progress: structure, titles, and needs IDs only. Content and req/comp/feat traceability links to follow in later PRs. + +.. attention:: + The above directive must be updated according to your Component. + + - Adjust ``status`` to be ``valid`` + - Adjust ``safety``, ``security`` and ``tags`` according to your needs + +Implementation Inspection Checklist +=================================== + +Purpose +------- + +The purpose of this checklist is to collect the topics to be checked during implementation, +i.e. in the detailed design and the source code of the units. + +The checklist shall be agnostic to which programming language is used. Differences shall be treated +by linking to C++ or Rust specific documentation. + +Conduct +------- + +As described in the concept :need:`doc_concept__wp_inspections` the following "inspection roles" are expected to be filled: + +- content responsible (author): +- reviewer: +- moderator: + +Checklist +--------- + +It is mandatory to fill in the "passed" column with "yes" or "no" for each checklist item and additionally to add in the remarks why it is passed or not passed. +In case of "no" an issue link to the issue tracking system has to be added in the last column (if not solved in the same issue). +See also :need:`doc_concept__wp_inspections` for further information about reviews in general and inspection in particular. + +.. list-table:: Implementation Checklist + :header-rows: 1 + :widths: 10,30,50,6,6,8 + + * - Review ID + - Acceptance Criteria + - Guidance + - Passed + - Remarks + - Issue link + * - IMPL_01_01 + - Is the design according to guidelines? + - see :need:`gd_temp__detailed_design` and :need:`doc_concept__imp_concept` + (e.g. are the views done with the proposed UML diagrams) + - + - + - + * - IMPL_01_02 + - Is the implementation according to specification? + - Check if the linked component requirements are fulfilled + and detailed design also matches architecture description. + - + - + - + * - IMPL_01_03 + - Are the design decisions and constraints documented? + - Check also for plausibility of these. + - + - + - + * - IMPL_01_04 + - Are all external libraries used by the component specified in the detailed design? + - Check the automated dependency analysis. + Also make sure ASIL rated units also only use ASIL rated libraries. + - + - + - + * - IMPL_02_01 + - Are the static and dynamic code analysis reports verified for violations? + - All violations in ASIL related code must be justified. This includes the checks of coding guidelines. + - + - + - + * - IMPL_02_02 + - Do manual checks, that are derived from the coding guideline, find no safety critical error? + - Check this for the programming language used (e.g. C++ , Rust ) + - + - + - + * - IMPL_03_01 + - Do the UID of the interface in component documentation match the implemented interface names of the unit? + - Compare interface UIDs (which contains the interface name) in component architecture/detailed design documentation + with public interfaces in source code (e.g. API headers, traits, public types/functions). + - + - + - + * - IMPL_03_02 + - Are detailed design and source code consistent and is the respective traceability established ? + - Check if available static and dynamic design diagrams and the textual descriptions match the code + (e.g. naming of interfaces, units, functions/operations/messages, data types). + Check if the folder/file names of the units and its source code matches the intended functionality. + For example if a unit is named "communication" it should not contain code for "data processing". + - + - + - diff --git a/docs/features/time_slave/index.rst b/score/time_slave/docs/detailed_design/index.rst similarity index 72% rename from docs/features/time_slave/index.rst rename to score/time_slave/docs/detailed_design/index.rst index 31d2585f..e525e31b 100644 --- a/docs/features/time_slave/index.rst +++ b/score/time_slave/docs/detailed_design/index.rst @@ -1,12 +1,33 @@ -Concept for TimeSlave -====================== - -.. contents:: Table of Contents - :depth: 3 - :local: - -TimeSlave concept ------------------- +.. + # ******************************************************************************* + # Copyright (c) 2026 Contributors to the Eclipse Foundation + # + # See the NOTICE file(s) distributed with this work for additional + # information regarding copyright ownership. + # + # This program and the accompanying materials are made available under the + # terms of the Apache License Version 2.0 which is available at + # https://www.apache.org/licenses/LICENSE-2.0 + # + # SPDX-License-Identifier: Apache-2.0 + # ******************************************************************************* + +.. _time_slave_detailed_design_index: + +Time Slave Detailed Design +========================== + +.. document:: Time Slave Detailed Design + :id: doc__time_slave_detailed_design + :status: draft + :version: 1 + :safety: ASIL_B + :security: NO + :realizes: wp__sw_implementation + :tags: time_slave + +Description +----------- Use Cases ~~~~~~~~~ @@ -33,25 +54,35 @@ The raw architectural diagram is represented below. -Components decomposition -~~~~~~~~~~~~~~~~~~~~~~~~~ +Rationale Behind Decomposition into Units +----------------------------------------- + +TimeSlave is decomposed into seven implementation units following SOLID principles +(Single Responsibility, Open/Closed) and design patterns (Strategy, Facade): -The design consists of several sw components: +1. **TimeSlave Application** — Orchestrates the overall process lifecycle and periodic publish loop +2. **GptpEngine** — Core gPTP protocol engine managing the RxThread and PdelayThread for network I/O +3. **FrameCodec** — Encodes and decodes raw Ethernet frames for gPTP communication +4. **MessageParser** — Parses the PTP wire format (IEEE 1588-v2) from raw payload bytes +5. **SyncStateMachine** — Correlates Sync/FollowUp messages and computes clock offset and rate ratio +6. **PeerDelayMeasurer** — Implements the IEEE 802.1AS peer delay measurement protocol +7. **PhcAdjuster** — Synchronizes the PTP Hardware Clock on the NIC -1. `TimeSlave Application <#timeslave-application-sw-component>`_ -2. `GptpEngine <#gptpengine-sw-component>`_ -3. `FrameCodec <#framecodec-sw-component>`_ -4. `MessageParser <#messageparser-sw-component>`_ -5. `SyncStateMachine <#syncstatemachine-sw-component>`_ -6. `PeerDelayMeasurer <#peerdelaymeasurer-sw-component>`_ -7. `PhcAdjuster <#phcadjuster-sw-component>`_ -8. `libTSClient <#libtsclient-sw-component>`_ -9. `ShmPTPEngine <#shmptpengine-sw-component>`_ +This separation enables independent testing, exchangeability of platform-specific implementations +(raw sockets, PHC drivers), and clear responsibility boundaries critical for ASIL_B safety qualification. -Class view +TimeSlave publishes its ``GptpIpcData`` snapshot to shared memory using the ``GptpIpcPublisher`` +from the :ref:`ts_client ` component; the TimeDaemon-side +consumer (``ShmPTPEngine``) is documented in the :ref:`Time Daemon detailed design +`. + +Static Diagrams for Unit Interactions +------------------------------------- + +Class View ~~~~~~~~~~ -Main classes and components are presented on this diagram: +Main classes and unit relationships are presented on this diagram: .. raw:: html @@ -66,10 +97,13 @@ Main classes and components are presented on this diagram: -Data and control flow +Dynamic Diagrams for Unit Interactions +-------------------------------------- + +Data and Control Flow ~~~~~~~~~~~~~~~~~~~~~ -The Data and Control flow are presented in the following diagram: +The data and control flow between units is presented in the following diagram: .. raw:: html @@ -90,10 +124,10 @@ On this view you could see several "workers" scopes: Each control flow is implemented with the dedicated thread and is independent from another ones. -Control flows +Control Flows ^^^^^^^^^^^^^ -RxThread scope +RxThread Scope '''''''''''''' This control flow is responsible for the: @@ -103,8 +137,8 @@ This control flow is responsible for the: 3. correlate Sync/FollowUp pairs and compute clock offset and neighborRateRatio 4. update the shared ``PtpTimeInfo`` snapshot under mutex protection -PdelayThread scope -''''''''''''''''''' +PdelayThread Scope +'''''''''''''''''' This control flow is responsible for the: @@ -112,8 +146,8 @@ This control flow is responsible for the: 2. coordinate with the RxThread to receive PDelayResp and PDelayRespFollowUp messages 3. compute the peer delay using the IEEE 802.1AS formula: ``path_delay = ((t2 - t1) + (t4 - t3c)) / 2`` -Main thread (periodic publish) scope -'''''''''''''''''''''''''''''''''''''' +Main Thread (Periodic Publish) Scope +'''''''''''''''''''''''''''''''''''' This control flow is responsible for the: @@ -121,7 +155,7 @@ This control flow is responsible for the: 2. call ``GptpEngine::ReadPTPSnapshot(data)`` to copy the latest ``GptpIpcData`` into a local variable 3. publish to shared memory via ``GptpIpcPublisher::Publish(data)`` -Data types or events +Data Types or Events ^^^^^^^^^^^^^^^^^^^^ There are several data types, which components are communicating to each other: @@ -142,20 +176,22 @@ PDelayResult ``PDelayResult`` is produced by ``PeerDelayMeasurer`` and contains the computed path delay in nanoseconds and a validity flag. PtpTimeInfo -'''''''''''' +''''''''''' ``PtpTimeInfo`` is the TimeDaemon-internal aggregated snapshot. It is **not** the shared memory type; it is produced by ``ShmPTPEngine::ReadPTPSnapshot()`` by field-mapping from ``GptpIpcData`` into the format expected by the TimeDaemon pipeline. -SW Components decomposition -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Units Within Time Slave +----------------------- + +The following units comprise TimeSlave's internal implementation: -TimeSlave Application SW component -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +TimeSlave Application Unit +~~~~~~~~~~~~~~~~~~~~~~~~~~ The ``TimeSlave Application`` component is the main entry point for the TimeSlave process. It extends ``score::mw::lifecycle::Application`` and is responsible for orchestrating the overall lifecycle of the GptpEngine and the IPC publisher. -Component requirements -'''''''''''''''''''''' +Implementation Requirements +''''''''''''''''''''''''''' The ``TimeSlave Application`` has the following requirements: @@ -164,13 +200,13 @@ The ``TimeSlave Application`` has the following requirements: - On each loop iteration, ``TimeSlave Application`` shall call ``GptpEngine::FinalizeSnapshot()``, then ``GptpEngine::ReadPTPSnapshot(data)``, and publish the resulting ``GptpIpcData`` via ``GptpIpcPublisher::Publish(data)`` - The ``TimeSlave Application`` shall call ``GptpEngine::Deinitialize()`` and ``GptpIpcPublisher::Destroy()`` after the ``stop_token`` is set -GptpEngine SW component -^^^^^^^^^^^^^^^^^^^^^^^^ +GptpEngine Unit +~~~~~~~~~~~~~~~ The ``GptpEngine`` component is the core gPTP protocol engine. It manages two background threads (RxThread and PdelayThread) for network I/O and peer delay measurement, and exposes a thread-safe ``ReadPTPSnapshot()`` method for the main thread to read the latest time measurement. -Component requirements -'''''''''''''''''''''' +Implementation Requirements +''''''''''''''''''''''''''' The ``GptpEngine`` has the following requirements: @@ -181,7 +217,7 @@ The ``GptpEngine`` has the following requirements: - The ``GptpEngine`` shall support configurable parameters via ``GptpEngineOptions`` (interface name, PDelay interval, PDelay warmup, sync timeout, time-jump threshold, PHC configuration) - The ``GptpEngine`` shall support exchangeability of the raw socket implementation for different platforms (Linux, QNX) -Class view +Class View '''''''''' The Class Diagram is presented below: @@ -197,7 +233,7 @@ The Class Diagram is presented below: -Threading model +Threading Model ''''''''''''''' The GptpEngine operates with two background threads. The threading model is represented below: @@ -213,7 +249,7 @@ The GptpEngine operates with two background threads. The threading model is repr -Concurrency aspects +Concurrency Aspects ''''''''''''''''''' The ``GptpEngine`` uses the following synchronization mechanisms: @@ -223,7 +259,7 @@ The ``GptpEngine`` uses the following synchronization mechanisms: - The ``SyncStateMachine`` uses ``std::atomic`` for the timeout flag, which is read from the main thread and written from the RxThread Hardware timestamping fallback -''''''''''''''''''''''''''''''' +'''''''''''''''''''''''''''''' During ``Initialize()``, ``GptpEngine`` calls ``RawSocket::EnableHwTimestamping()`` to request NIC-level receive timestamps (``SO_TIMESTAMPING`` on Linux). If the NIC does not support hardware timestamping, the call returns ``false`` and a warning is logged: @@ -255,26 +291,26 @@ The engine continues to run normally. The difference between the two modes: The fallback does not affect protocol correctness — Sync/FollowUp correlation and peer delay measurement continue to work — but the computed clock offset will be less accurate due to higher receive timestamp jitter. -FrameCodec SW component -^^^^^^^^^^^^^^^^^^^^^^^^^ +FrameCodec Unit +~~~~~~~~~~~~~~~ The ``FrameCodec`` component handles raw Ethernet frame encoding and decoding for gPTP communication. -Component requirements -'''''''''''''''''''''' +Implementation Requirements +''''''''''''''''''''''''''' The ``FrameCodec`` has the following requirements: - The ``FrameCodec`` shall parse incoming Ethernet frames, extracting source/destination MAC addresses, handling 802.1Q VLAN tags, and validating the EtherType (``0x88F7``) - The ``FrameCodec`` shall construct outgoing Ethernet headers for PDelayReq frames using the standard PTP multicast destination MAC (``01:80:C2:00:00:0E``) -MessageParser SW component -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +MessageParser Unit +~~~~~~~~~~~~~~~~~~ The ``MessageParser`` component parses the PTP wire format (IEEE 1588-v2) from raw payload bytes. -Component requirements -'''''''''''''''''''''' +Implementation Requirements +''''''''''''''''''''''''''' The ``MessageParser`` has the following requirements: @@ -282,13 +318,13 @@ The ``MessageParser`` has the following requirements: - The ``MessageParser`` shall decode all relevant message types: Sync, FollowUp, PdelayReq, PdelayResp, PdelayRespFollowUp - The ``MessageParser`` shall use packed wire structures (``__attribute__((packed))``) for direct memory mapping of PTP messages -SyncStateMachine SW component -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +SyncStateMachine Unit +~~~~~~~~~~~~~~~~~~~~~ The ``SyncStateMachine`` component implements the two-step Sync/FollowUp correlation logic. It correlates incoming Sync and FollowUp messages by sequence ID, computes the clock offset and neighbor rate ratio, and detects time jumps. -Component requirements -'''''''''''''''''''''' +Implementation Requirements +''''''''''''''''''''''''''' The ``SyncStateMachine`` has the following requirements: @@ -298,12 +334,12 @@ The ``SyncStateMachine`` has the following requirements: - The ``SyncStateMachine`` shall detect forward and backward time jumps against configurable thresholds - The ``SyncStateMachine`` shall provide thread-safe timeout detection via ``std::atomic``, set when no Sync is received within the configured timeout -PeerDelayMeasurer SW component -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +PeerDelayMeasurer Unit +~~~~~~~~~~~~~~~~~~~~~~ The ``PeerDelayMeasurer`` component implements the IEEE 802.1AS two-step peer delay measurement protocol. It manages the four timestamps (``t1``, ``t2``, ``t3c``, ``t4``) across two threads. -Timestamp definitions +Timestamp Definitions ''''''''''''''''''''' .. list-table:: Peer Delay Timestamps (IEEE 802.1AS) @@ -337,8 +373,8 @@ The peer delay formula is: ``path_delay = ((t2 - t1) + (t4 - t3c)) / 2`` - ``(t4 - t3c)`` = propagation time from master → slave - The average of the two gives the one-way link delay -Component requirements -'''''''''''''''''''''' +Implementation Requirements +''''''''''''''''''''''''''' The ``PeerDelayMeasurer`` has the following requirements: @@ -349,13 +385,13 @@ The ``PeerDelayMeasurer`` has the following requirements: - The ``PeerDelayMeasurer`` shall suppress the path-delay result when more than one PDelayResp is received for a single PDelayReq (detection of non-time-aware bridges per IEEE 802.1AS) - The ``PeerDelayMeasurer`` shall provide thread-safe access to the ``PDelayResult`` via a mutex, as ``SendRequest()`` runs on the PdelayThread while response handlers are called from the RxThread -PhcAdjuster SW component -^^^^^^^^^^^^^^^^^^^^^^^^^^ +PhcAdjuster Unit +~~~~~~~~~~~~~~~~ The ``PhcAdjuster`` component synchronizes the PTP Hardware Clock (PHC) on the NIC. It applies step corrections for large offsets and frequency slew for smooth convergence of small offsets. -Component requirements -'''''''''''''''''''''' +Implementation Requirements +''''''''''''''''''''''''''' The ``PhcAdjuster`` has the following requirements: @@ -364,8 +400,8 @@ The ``PhcAdjuster`` has the following requirements: - The ``PhcAdjuster`` shall support platform-specific implementations: ``clock_adjtime()`` on Linux, EMAC PTP ioctls on QNX - The ``PhcAdjuster`` shall be configurable via ``PhcConfig`` (device path, step threshold, enable/disable flag) -Fallback behavior when PHC is unavailable -'''''''''''''''''''''''''''''''''''''''''' +Fallback Behavior When PHC Is Unavailable +''''''''''''''''''''''''''''''''''''''''' The ``PhcAdjuster`` degrades gracefully in two scenarios: @@ -379,75 +415,8 @@ The ``PhcAdjuster`` degrades gracefully in two scenarios: In both scenarios TimeSlave continues to track the master clock and publish accurate ``GptpIpcData`` snapshots (including offset and status flags) to shared memory. The downstream TimeDaemon and any applications consuming time are unaffected — only the NIC hardware clock itself will drift relative to PTP time. -libTSClient SW component -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The ``libTSClient`` component is the shared memory IPC library that connects the TimeSlave process to the TimeDaemon process. It provides a lock-free, single-writer/multi-reader communication channel using a seqlock protocol over POSIX shared memory. - -The component provides two sub components: publisher and receiver to be deployed on the TimeSlave and TimeDaemon sides accordingly. - -Component requirements -'''''''''''''''''''''' - -The ``libTSClient`` has the following requirements: - -- The ``libTSClient`` shall define a shared memory layout (``GptpIpcRegion``) with a magic number (``0x47505450`` = 'GPTP') for validation, an atomic seqlock counter (``seq``), a confirmation counter (``seq_confirm``), and a ``GptpIpcData`` data payload -- The ``libTSClient`` shall align the shared memory region to 64 bytes (cache line size) to prevent false sharing -- The ``libTSClient`` shall provide a ``GptpIpcPublisher`` component (in ``score::ts::details``) that creates and manages the POSIX shared memory segment and writes ``GptpIpcData`` using the seqlock protocol -- The ``libTSClient`` shall provide a ``GptpIpcReceiver`` component (in ``score::ts::details``) that opens the shared memory segment read-only and reads ``GptpIpcData`` with up to 20 seqlock retries -- The ``libTSClient`` shall use the POSIX shared memory name ``/gptp_ptp_info`` by default - -Class view -'''''''''' - -The Class Diagram is presented below: - -.. raw:: html - -
- -.. uml:: _assets/ts_client/ipc_channel.puml - :alt: Class Diagram - -.. raw:: html - -
- -Publish new data -'''''''''''''''' - -When ``TimeSlave Application`` has a new ``GptpIpcData`` snapshot, it publishes to the shared memory via the seqlock protocol: - -1. Increment ``seq`` (becomes odd — signals write in progress); a release fence is applied -2. ``memcpy`` the ``GptpIpcData`` -3. Store ``seq_confirm = seq + 1`` and increment ``seq`` (both become even — signals write complete) - -Receive data -'''''''''''' - -From TimeDaemon side, the receiver reads from the shared memory using the seqlock protocol with bounded retry: - -1. Read ``seq1`` with acquire ordering (must be even, otherwise retry — write in progress) -2. ``memcpy`` the ``GptpIpcData`` -3. Apply an acquire-release fence; read ``seq_confirm`` as ``seq2`` and re-read ``seq`` as ``seq3`` -4. If ``seq1 == seq2 == seq3``, the read is consistent; otherwise retry — torn read detected -5. Return ``std::optional`` (empty if all 20 retries exhausted) - -The seqlock protocol workflow is presented in the following sequence diagram: - -.. raw:: html - -
- -.. uml:: _assets/ts_client/ipc_sequence.puml - :alt: Seqlock Protocol - -.. raw:: html - -
- -Platform support -~~~~~~~~~~~~~~~~~ +Platform Support +~~~~~~~~~~~~~~~~ TimeSlave supports two target platforms with platform-specific implementations selected at compile time via Bazel ``select()``: @@ -474,7 +443,7 @@ TimeSlave supports two target platforms with platform-specific implementations s The ``RawSocket`` and ``NetworkIdentity`` interfaces provide the abstraction boundary. Platform-specific source files are organized under ``score/time_slave/src/gptp/platform/linux/`` and ``score/time_slave/src/gptp/platform/qnx/``. Instrumentation -~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~ ProbeManager ^^^^^^^^^^^^ @@ -515,7 +484,7 @@ Supported probe points (``ProbePoint`` enum): When a probe event is forwarded to the ``Recorder``, it is written with ``RecordEvent::kProbe`` and the ``ProbePoint`` value stored in the ``status_flags`` field of the CSV row. Recorder -^^^^^^^^^ +^^^^^^^^ Thread-safe CSV file writer. When enabled, appends one row per event to the configured file. The file is opened in append mode (``ios::app``); a CSV header is written only if the file is newly created (size == 0). @@ -575,7 +544,7 @@ Supported ``RecordEvent`` values written to the ``event`` column: Logging configuration ~~~~~~~~~~~~~~~~~~~~~ -The TimeSlave and its TimeDaemon-side adapter use the following logging contexts: +TimeSlave uses the following logging contexts: .. list-table:: Logging Contexts :header-rows: 1 @@ -590,9 +559,6 @@ The TimeSlave and its TimeDaemon-side adapter use the following logging contexts * - gPTP Engine (RxThread / PdelayThread) - GTPS - **GPTP** **SLAVE** engine — low-level protocol processing - * - ShmPTPEngine (TimeDaemon side) - - GPTP - - TimeDaemon **GPTP** machine adapter (Initialize / ReadPTPSnapshot) Variability ~~~~~~~~~~~ @@ -662,135 +628,22 @@ Protocol extensibility '''''''''''''''''''''' 1. The ``GptpEngine`` accepts injected ``RawSocket`` and ``NetworkIdentity`` dependencies, making it straightforward to test or replace individual platform abstractions -2. The shared memory IPC channel name is configurable (``GptpIpcPublisher::Init(name)`` / ``GptpIpcReceiver::Init(name)``), allowing multiple gPTP instances per ECU if needed +2. The shared memory IPC channel name is configurable (``GptpIpcPublisher::Init(name)``), allowing multiple gPTP instances per ECU if needed -TimeDaemon integration extensibility -'''''''''''''''''''''''''''''''''''''' +The ``GptpIpcPublisher`` used here, and the corresponding ``GptpIpcReceiver``/``ShmPTPEngine`` on the +consuming side, are documented in the :ref:`ts_client ` and +:ref:`Time Daemon ` detailed designs respectively. -1. The ``ShmPTPEngine`` implements the same ``PTPEngine`` concept as other ``PTPMachine`` backends, making it transparently exchangeable with any other engine implementation -2. Alternative IPC mechanisms (e.g., socket-based) can be introduced by implementing a new engine class without modifying the ``PTPMachine`` template or downstream components - -ShmPTPEngine SW component -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The ``ShmPTPEngine`` component (in ``score::td::details``) is the TimeDaemon-side adapter that reads ``GptpIpcData`` from the shared memory channel written by TimeSlave and converts it into the ``PtpTimeInfo`` structure expected by the TimeDaemon pipeline. - -It is instantiated as ``GPTPShmMachine`` — a type alias for ``PTPMachine`` — which connects ``ShmPTPEngine`` to the TimeDaemon's internal ``MessageBroker``. - -Component requirements -'''''''''''''''''''''' - -The ``ShmPTPEngine`` has the following requirements: - -- The ``ShmPTPEngine`` shall call ``GptpIpcReceiver::Init(ipc_name)`` during ``Initialize()`` to open the shared memory channel -- The ``ShmPTPEngine`` shall call ``GptpIpcReceiver::Receive()`` in ``ReadPTPSnapshot()`` to fetch the latest ``GptpIpcData`` -- The ``ShmPTPEngine`` shall map all fields of ``GptpIpcData`` to the corresponding fields of ``PtpTimeInfo`` (status flags, Sync/FollowUp data, peer-delay data, time references) -- The ``ShmPTPEngine`` shall call ``GptpIpcReceiver::Close()`` during ``Deinitialize()`` -- The ``ShmPTPEngine`` shall be instantiatable with a configurable IPC channel name (default: ``/gptp_ptp_info``) - -Class view -'''''''''' - -The Class Diagram is presented below: - -.. raw:: html - -
- -.. uml:: _assets/shm_ptp_engine/shm_ptp_engine_class.puml - :alt: Class Diagram - -.. raw:: html - -
- -Component initialization -'''''''''''''''''''''''' - -During initialization the ``ShmPTPEngine`` shall open the shared memory channel to be able to read from it. - -The initialization workflow is represented in the following sequence diagram: - -.. raw:: html - -
- -.. uml:: _assets/shm_ptp_engine/shm_ptp_engine_init_seq.puml - :alt: Initialization workflow - -.. raw:: html - -
- -Read PTP snapshot -''''''''''''''''' - -After ``ShmPTPEngine`` reads the latest ``GptpIpcData`` from shared memory, it maps it to ``PtpTimeInfo`` and publishes via the ``MessageBroker``. - -The periodic read and publish workflow is described below: - -.. raw:: html - -
- -.. uml:: _assets/shm_ptp_engine/shm_ptp_engine_read_seq.puml - :alt: Periodic read and publish workflow - -.. raw:: html - -
- -Data mapping -'''''''''''' - -``ShmPTPEngine::ReadPTPSnapshot()`` performs a field-by-field mapping from ``GptpIpcData`` to ``PtpTimeInfo``: - -.. list-table:: GptpIpcData → PtpTimeInfo Mapping - :header-rows: 1 - :widths: 50 50 - - * - ``GptpIpcData`` field - - ``PtpTimeInfo`` field - * - ``ptp_assumed_time`` - - ``ptp_assumed_time`` - * - ``local_time`` - - ``local_time`` (wrapped in ``ReferenceClock::time_point``) - * - ``rate_deviation`` - - ``rate_deviation`` - * - ``status.is_synchronized`` - - ``status.is_synchronized`` - * - ``status.is_timeout`` - - ``status.is_timeout`` - * - ``status.is_time_jump_future`` - - ``status.is_time_jump_future`` - * - ``status.is_time_jump_past`` - - ``status.is_time_jump_past`` - * - ``status.is_correct`` - - ``status.is_correct`` - * - ``sync_fup_data.*`` (9 fields) - - ``sync_fup_data.*`` (direct copy) - * - ``pdelay_data.*`` (12 fields) - - ``pdelay_data.*`` (direct copy) - -Factory -''''''' - -``CreateGPTPShmMachine(name, ipc_name)`` is a convenience factory function in ``score::td`` that creates a configured ``GPTPShmMachine`` (``shared_ptr``) backed by ``ShmPTPEngine``: - -.. code-block:: cpp - - auto machine = CreateGPTPShmMachine("shm", "/gptp_ptp_info"); - -Using in test environment -~~~~~~~~~~~~~~~~~~~~~~~~~~ +Using in Test Environment +~~~~~~~~~~~~~~~~~~~~~~~~~ Using in ITF ^^^^^^^^^^^^ Normal behavior is expected. TimeSlave runs as a standalone process, communicates over real Ethernet, and writes to ``/gptp_ptp_info`` shared memory as in production. -Using in Component Tests on the host -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Using in Component Tests on Host +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Overview '''''''' @@ -825,3 +678,12 @@ The ``GptpEngine`` provides a dedicated test constructor that accepts injected i This allows complete white-box testing of the Sync/FollowUp correlation, peer-delay measurement, timeout detection, and time-jump flagging logic by pushing crafted PTP frames directly into the ``FakeSocket`` queue. The ``GptpIpcPublisher`` and ``GptpIpcReceiver`` rely on POSIX shared memory (``shm_open``), which works on any Linux host, so ``ShmPTPEngine`` component tests can run end-to-end using real IPC without modification. + +Inspection Checklist +-------------------- + +The checklist for verification of the detailed design and code can be found here: + +.. toctree:: + + chklst_impl_inspection diff --git a/score/time_slave/docs/index.rst b/score/time_slave/docs/index.rst index 6e07edcd..18c7ece2 100644 --- a/score/time_slave/docs/index.rst +++ b/score/time_slave/docs/index.rst @@ -12,16 +12,56 @@ # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* -time_slave Component -==================== +.. _time_slave: + +Time Slave +########## + +.. document:: Time Slave + :id: doc__time_slave + :status: valid + :version: 1 + :safety: QM + :security: NO + :realizes: wp__cmpt_request + :tags: time_slave + +.. comp:: Time Slave + :id: comp__time_slave + :security: NO + :safety: QM + :status: valid + :implements: comp_req__time_slave__gptp_slave, comp_req__time_slave__time_publishing, comp_req__time_slave__sync_state, comp_req__time_slave__phc_sync, comp_req__time_slave__error_reporting, comp_req__time_slave__efficient_access + :belongs_to: feat__time[version==1] + + +Abstract +======== + +This component implements a gPTP (IEEE 802.1AS) time synchronization slave daemon that receives time synchronization data from network and publishes it to IPC for client applications. + +Specification +============= + +The component provides gPTP slave functionality with network message processing and IPC publishing: + +* :need:`comp_req__time_slave__gptp_slave` +* :need:`comp_req__time_slave__time_publishing` +* :need:`comp_req__time_slave__sync_state` +* :need:`comp_req__time_slave__phc_sync` +* :need:`comp_req__time_slave__error_reporting` +* :need:`comp_req__time_slave__efficient_access` + +Footnotes +========= + +Further Documentation of the component can be found in the following sections: + +Component Detail Information +============================ .. toctree:: :maxdepth: 1 - component_classification - architecture/index detailed_design/index requirements/index - manuals/index - safety_analysis/index - security_analysis/index diff --git a/score/time_slave/docs/requirements/.gitkeep b/score/time_slave/docs/requirements/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/score/time_slave/docs/requirements/chklst_req_inspection.rst b/score/time_slave/docs/requirements/chklst_req_inspection.rst new file mode 100644 index 00000000..1e4ae13b --- /dev/null +++ b/score/time_slave/docs/requirements/chklst_req_inspection.rst @@ -0,0 +1,182 @@ +.. + # ******************************************************************************* + # Copyright (c) 2026 Contributors to the Eclipse Foundation + # + # See the NOTICE file(s) distributed with this work for additional + # information regarding copyright ownership. + # + # This program and the accompanying materials are made available under the + # terms of the Apache License Version 2.0 which is available at + # https://www.apache.org/licenses/LICENSE-2.0 + # + # SPDX-License-Identifier: Apache-2.0 + # ******************************************************************************* + + +.. document:: Time Slave Requirements Inspection Checklist + :id: doc__time_slave_req_inspection + :status: draft + :version: 1 + :safety: QM + :security: NO + :realizes: wp__requirements_inspect + :tags: time_slave + +Requirement Inspection Checklist +================================ + +Purpose +------- + +The purpose of this requirement inspection checklist is to collect the topics to be checked during requirements inspection. + +Conduct +------- + +As described in the concept :need:`doc_concept__wp_inspections` the following "inspection roles" are expected to be filled: + +- content responsible (author): +- reviewer: +- moderator: +- test expert: + +Checklist +--------- + +It is mandatory to fill in the "passed" column with "yes" or "no" for each checklist item and additionally to add in the remarks why it is passed or not passed. +In case of "no" an issue link to the issue tracking system has to be added in the last column (if not solved in the same issue). +See also :need:`doc_concept__wp_inspections` for further information about reviews in general and inspection in particular. + +.. list-table:: Component Requirement Inspection Checklist + :header-rows: 1 + :widths: 10,30,50,6,6,8 + + * - Review ID + - Acceptance Criteria + - Guidance + - Passed + - Remarks + - Issue link + * - REQ_01_01 + - Is the requirement formulation template used? + - see :need:`gd_temp__req_formulation`, this includes the use of "shall". + - + - + - + * - REQ_02_01 + - Is the requirement description *comprehensible* ? + - If you think the requirement is hard to understand, comment here. + - + - + - + * - REQ_02_02 + - Is the requirement description *unambiguous* ? + - Especially search for "weak words" like "about", "etc.", "relevant" and others (see the internet documentation on this). This check shall be supported by tooling. + - + - + - + * - REQ_02_03 + - Is the requirement description *atomic* ? + - A good way to think about this is to consider if the requirement may be tested by one (positive) test case or needs more of these. The requirement formulation template should also avoid being non-atomic already. Note that there are cases where also non-atomic requirements are the better ones, for example if those are better understandable. + - + - + - + * - REQ_02_04 + - Is the requirement description *feasible* ? + - If at the time of the inspection the requirement has already some implementation, the answer is yes. This can be checked via traces, but also :need:`gd_req__req_attr_impl` shows this. In case the requirement has no implementation at the time of inspection (i.e. not implemented at least as "proof-of-concept"), a development expert should be invited to the Pull-Request review to explicitly check this item. + - + - + - + * - REQ_02_05 + - Is the requirement description *independent from implementation* ? + - This checkpoint should improve requirements definition in the sense that the "what" is described and not the "how" - the latter should be described in architecture/design derived from the requirement. But there can also be a good reason for this, for example we would require using a file format like JSON and even specify the formatting standard already on stakeholder requirement level because we want to be compatible. A finding in this checkpoint does not mean there is a safety problem in the requirement. + - + - + - + * - REQ_03_01 + - Is the *linkage to the parent requirement* correct? + - Linkage to correct levels and ASIL attributes is checked automatically, but it needs checking if the child requirement implements (at least) a part of the parent requirement. + - + - + - + * - REQ_04_01 + - Is the requirement *internally and externally consistent*? + - Does the requirement contradict other requirements within the same or higher levels? One may restrict the search to the feature for component requirements, for features to other features using same components. Is the description of the requirement consistent with all its attributes (if not already part of another check, e.g. does the title fit?). + - + - + - + * - REQ_05_01 + - Do the software requirements consider *timing constraints*? + - This checkpoint encourages to think about timing constraints even if those are not explicitly mentioned in the parent requirement. If the reviewer of a requirement already knows or suspects that the code execution will be consuming a lot of time, one should think of the expectation of a "user". + - + - + - + * - REQ_06_01 + - Does the requirement consider *external interfaces*? + - The SW platform's external interfaces (to the user) are defined in the Feature Architecture, so the Feature and Component Requirements should determine the input data use and setting of output data for these interfaces. Are all output values defined? + - + - + - + * - REQ_07_01 + - Is the *safety* attribute set correctly? + - Derived requirements are checked automatically, see :need:`gd_req__req_linkage_safety`. But for the top level requirements (and also all AoU) this needs to be checked manually for correctness. + - + - + - + * - REQ_07_02 + - Is the attribute *security* set correctly? + - For component requirements this checklist item is supported by automated check: "Every requirement which satisfies a feature requirement with security attribute set to YES inherits this". But the component requirements/architecture may additionally also be subject to a :need:`wp__sw_component_security_analysis`. + - + - + - + * - REQ_08_01 + - Is the requirement *verifiable*? + - If at the time of the inspection already tests are created for the requirement, the answer is yes. This can be checked via traces, but also :need:`gd_req__req_attr_test_covered` shows this. In case the requirement is not sufficiently traced to test cases already, a test expert is invited to the inspection to give their opinion whether the requirement is formulated in a way that supports test development and the available test infrastructure is sufficient to perform the test. + - + - + - + * - REQ_08_02 + - Is the requirement verifiable by design or code review in case it is not feasibly testable? + - In very rare cases a requirement may not be verifiable by test cases, for example a specific non-functional requirement. In this case a requirement analysis verifies the requirement by design/code review. If such a requirement is in scope of this inspection, please check this here and link to the respective review record. A test expert is invited to the inspection to confirm their opinion that the requirement is not testable. + - + - + - + * - REQ_09_01 + - Do the requirements that define a safety mechanism specify the error reaction leading to a safe state? + - Alternatively to the safe state there could also be "repair" mechanisms. Also do not forget to consider REQ_05_01 for these. + - + - + - + * - REQ_10_01 + - Is the requirement description *complete* ? + - For every requirement in the inspection, follow to its parent (feature) requirement(s) and then check if this/these are fulfilled completely by its/their linked children (component requirements, including those which are not in scope of the inspection). + - + - + - + +.. attention:: + The above checklist entries must be filled according to your component requirements in scope. + +Note: If a Review ID is not applicable for your requirement, then state "n/a" in status and comment accordingly in remarks. + +The following requirements in "valid" state and with "inspected" tag set are in the scope of this inspection: + +.. needtable:: + :filter: "time_slave" in docname and "requirements" in docname and docname is not None and status == "valid" + :style: table + :types: comp_req + :tags: time_slave + :columns: id;status;tags + :colwidths: 25,25,25 + :sort: title + +And also the following AoUs in "valid" state and with "inspected" tag set (for these please answer the questions above as if the AoUs are requirements, except question REQ_03_01): + +.. needtable:: + :filter: "time_slave" in docname and "requirements" in docname and docname is not None and status == "valid" + :style: table + :types: aou_req + :tags: time_slave + :columns: id;status;tags + :colwidths: 25,25,25 + :sort: title diff --git a/score/time_slave/docs/requirements/index.rst b/score/time_slave/docs/requirements/index.rst new file mode 100644 index 00000000..941267fa --- /dev/null +++ b/score/time_slave/docs/requirements/index.rst @@ -0,0 +1,171 @@ +.. + # ******************************************************************************* + # Copyright (c) 2026 Contributors to the Eclipse Foundation + # + # See the NOTICE file(s) distributed with this work for additional + # information regarding copyright ownership. + # + # This program and the accompanying materials are made available under the + # terms of the Apache License Version 2.0 which is available at + # https://www.apache.org/licenses/LICENSE-2.0 + # + # SPDX-License-Identifier: Apache-2.0 + # ******************************************************************************* + +Component Time Slave Requirements +################################## + +.. document:: Time Slave Requirements + :id: doc__time_slave_requirements + :status: draft + :version: 1 + :safety: QM + :security: NO + :realizes: wp__requirements_comp[version==1] + :tags: requirements, time_slave + +Functional Requirements +----------------------- + +.. comp_req:: gPTP Slave Protocol + :id: comp_req__time_slave__gptp_slave + :reqtype: Functional + :security: NO + :safety: QM + :derived_from: feat_req__time__vehicle_time_sync[version==1] + :status: invalid + :version: 1 + :satisfied_by: comp__time_slave + + The component shall receive and process gPTP (IEEE 802.1AS) protocol messages as a slave endpoint when connected to a network with a gPTP master. + +.. comp_req:: Time Data Publishing + :id: comp_req__time_slave__time_publishing + :reqtype: Functional + :security: NO + :safety: QM + :derived_from: feat_req__time__vehicle_time_sync[version==1] + :status: invalid + :version: 1 + :satisfied_by: comp__time_slave + + The component shall publish synchronized time data to IPC after each successful synchronization update from the gPTP master. + +.. comp_req:: Synchronization State Tracking + :id: comp_req__time_slave__sync_state + :reqtype: Functional + :security: NO + :safety: QM + :derived_from: feat_req__time__vehicle_time_sync[version==1] + :status: invalid + :version: 1 + :satisfied_by: comp__time_slave + + The component shall track synchronization state and report loss of synchronization when no valid gPTP messages are received within the configured timeout period. + +.. comp_req:: Hardware Clock Synchronization + :id: comp_req__time_slave__phc_sync + :reqtype: Functional + :security: NO + :safety: QM + :derived_from: feat_req__time__vehicle_time_sync[version==1] + :status: invalid + :version: 1 + :satisfied_by: comp__time_slave + + The component shall support synchronization of the PTP hardware clock with the gPTP master when hardware timestamping is available. + +.. comp_req:: Error Reporting + :id: comp_req__time_slave__error_reporting + :reqtype: Functional + :security: NO + :safety: QM + :derived_from: feat_req__time__vehicle_time_sync[version==1] + :status: invalid + :version: 1 + :satisfied_by: comp__time_slave + + The component shall report initialization failures and protocol errors via the logging interface when they occur. + +.. comp_req:: Lifecycle Management + :id: comp_req__time_slave__lifecycle + :reqtype: Functional + :security: NO + :safety: QM + :derived_from: feat_req__time__vehicle_time_sync[version==1] + :status: invalid + :version: 1 + :satisfied_by: comp__time_slave + + The component shall support lifecycle management including initialization, runtime execution, and graceful shutdown. + +.. comp_req:: Peer Delay Measurement + :id: comp_req__time_slave__peer_delay + :reqtype: Functional + :security: NO + :safety: QM + :derived_from: feat_req__time__vehicle_time_sync[version==1] + :status: invalid + :version: 1 + :satisfied_by: comp__time_slave + + The component shall measure network peer delay via IEEE 802.1AS PDelayReq/PDelayResp exchange and include it in published time data. + +.. comp_req:: Platform Portability + :id: comp_req__time_slave__platform_portability + :reqtype: Functional + :security: NO + :safety: QM + :derived_from: feat_req__time__vehicle_time_sync[version==1] + :status: invalid + :version: 1 + :satisfied_by: comp__time_slave + + The component shall support deployment on multiple target platforms (Linux, QNX) with platform-specific network and hardware clock adaptations. + +Non-Functional Requirements +--------------------------- + +.. comp_req:: Efficient Time Access + :id: comp_req__time_slave__efficient_access + :reqtype: Non-Functional + :security: NO + :safety: QM + :derived_from: feat_req__time__vehicle_time_ctrl_flow[version==1] + :status: invalid + :version: 1 + :satisfied_by: comp__time_slave + + The component shall publish time data via shared memory to enable fast client access without kernel calls. + +Assumption of Use Requirements +------------------------------ + +.. aou_req:: Network Interface Availability + :id: aou_req__time_slave__network_available + :reqtype: Process + :security: NO + :safety: QM + :status: invalid + :version: 1 + + The user shall ensure the configured network interface is available and supports hardware timestamping before starting the component. + +.. aou_req:: Single Instance Per Interface + :id: aou_req__time_slave__single_instance + :reqtype: Process + :security: NO + :safety: QM + :status: invalid + :version: 1 + + The user shall run only one time_slave instance per network interface to avoid protocol conflicts. + +.. needextend:: is_external == False and "time_slave" in id + :+tags: time_slave + + +.. toctree:: + :maxdepth: 1 + + chklst_req_inspection diff --git a/score/time_slave/docs/safety_analysis/.gitkeep b/score/time_slave/docs/safety_analysis/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/score/time_slave/docs/security_analysis/.gitkeep b/score/time_slave/docs/security_analysis/.gitkeep deleted file mode 100644 index e69de29b..00000000