From 77fe1a2d52468170f245686e24efedae6d5e1668 Mon Sep 17 00:00:00 2001 From: Ruben Nijveld Date: Thu, 6 Feb 2025 12:18:53 +0100 Subject: [PATCH] Add the slave-only instance configuration option to statime-linux --- docs/man/statime.toml.5.md | 3 +++ docs/precompiled/man/statime.toml.5 | 3 +++ statime-linux/src/config/mod.rs | 7 +++++++ statime-linux/src/main.rs | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/man/statime.toml.5.md b/docs/man/statime.toml.5.md index 29572f8c7..05013b2b3 100644 --- a/docs/man/statime.toml.5.md +++ b/docs/man/statime.toml.5.md @@ -32,6 +32,9 @@ will be indicated by each configuration setting shown. `sdo-id` = *u12* (**0**) : The "source domain identity" of this PTP instance. Together with the `domain` it identifies a domain. +`slave-only` = *bool* (**false**) +: Forbids this instance to ever become a master on any port. + `priority1` = *priority* (**128**) : A tie breaker for the best master clock algorithm in the range `0..256`. `0` being the highest priority and `255` the lowest. diff --git a/docs/precompiled/man/statime.toml.5 b/docs/precompiled/man/statime.toml.5 index 0b26006a9..b81f1ede9 100644 --- a/docs/precompiled/man/statime.toml.5 +++ b/docs/precompiled/man/statime.toml.5 @@ -33,6 +33,9 @@ domain. The \[lq]source domain identity\[rq] of this PTP instance. Together with the \f[CR]domain\f[R] it identifies a domain. .TP +\f[CR]slave\-only\f[R] = \f[I]bool\f[R] (\f[B]false\f[R]) +Forbids this instance to ever become a master on any port. +.TP \f[CR]priority1\f[R] = \f[I]priority\f[R] (\f[B]128\f[R]) A tie breaker for the best master clock algorithm in the range \f[CR]0..256\f[R]. diff --git a/statime-linux/src/config/mod.rs b/statime-linux/src/config/mod.rs index bb8eeda6e..62b300d9a 100644 --- a/statime-linux/src/config/mod.rs +++ b/statime-linux/src/config/mod.rs @@ -24,6 +24,8 @@ pub struct Config { pub sdo_id: u16, #[serde(default = "default_domain")] pub domain: u8, + #[serde(default = "default_slave_only")] + pub slave_only: bool, #[serde(default, deserialize_with = "deserialize_clock_identity")] pub identity: Option, #[serde(default = "default_priority1")] @@ -190,6 +192,10 @@ fn default_sdo_id() -> u16 { 0x000 } +fn default_slave_only() -> bool { + false +} + fn default_announce_interval() -> i8 { 1 } @@ -281,6 +287,7 @@ interface = "enp0s31f6" loglevel: LogLevel::Info, sdo_id: 0x000, domain: 0, + slave_only: false, identity: None, priority1: 128, priority2: 128, diff --git a/statime-linux/src/main.rs b/statime-linux/src/main.rs index dbce7992c..268ba8809 100644 --- a/statime-linux/src/main.rs +++ b/statime-linux/src/main.rs @@ -268,7 +268,7 @@ async fn actual_main() { priority_1: config.priority1, priority_2: config.priority2, domain_number: config.domain, - slave_only: false, + slave_only: config.slave_only, sdo_id: SdoId::try_from(config.sdo_id).expect("sdo-id should be between 0 and 4095"), path_trace: config.path_trace, };