From e706f489819f7bc0b22c47346f7c16bd2c561897 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Sat, 1 Nov 2014 19:21:40 +0100 Subject: [PATCH] port: allow running a boundary clock with multiple clock devices. If the user has configured the appropriate option, then simply warn about the clock device mismatch, and then go on in "JBOD" mode. Whenever the port enters the uncalibrated state, it tells the clock to switch to the new PHC device. Signed-off-by: Richard Cochran --- fault.c | 1 + fault.h | 1 + port.c | 28 ++++++++++++++++++++++++---- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/fault.c b/fault.c index 7fcf019..3976f8c 100644 --- a/fault.c +++ b/fault.c @@ -21,6 +21,7 @@ static const char *fault_type_str[FT_CNT] = { "FT_UNSPECIFIED", "FT_BAD_PEER_NETWORK", + "FT_SWITCH_PHC", }; const char *ft_str(enum fault_type ft) diff --git a/fault.h b/fault.h index 8d62c38..fd42b82 100644 --- a/fault.h +++ b/fault.h @@ -21,6 +21,7 @@ enum fault_type { FT_UNSPECIFIED = 0, FT_BAD_PEER_NETWORK, + FT_SWITCH_PHC, FT_CNT, }; diff --git a/port.c b/port.c index aa9354b..18a956d 100644 --- a/port.c +++ b/port.c @@ -29,6 +29,7 @@ #include "filter.h" #include "missing.h" #include "msg.h" +#include "phc.h" #include "port.h" #include "print.h" #include "sk.h" @@ -68,6 +69,8 @@ struct port { enum timestamp_type timestamping; struct fdarray fda; int fault_fd; + int phc_index; + int jbod; struct foreign_clock *best; enum syfu_state syfu; struct ptp_message *last_syncfup; @@ -2138,6 +2141,15 @@ int port_dispatch(struct port *p, enum fsm_event event, int mdiff) p->state = next; port_notify_event(p, NOTIFY_PORT_STATE); + + if (p->jbod && next == PS_UNCALIBRATED) { + if (clock_switch_phc(p->clock, p->phc_index)) { + p->last_fault_type = FT_SWITCH_PHC; + return port_dispatch(p, EV_FAULT_DETECTED, 0); + } + clock_sync_interval(p->clock, p->log_sync_interval); + } + return 0; } @@ -2483,15 +2495,23 @@ struct port *port_open(int phc_index, memset(p, 0, sizeof(*p)); + p->phc_index = phc_index; + p->jbod = interface->boundary_clock_jbod; + if (interface->transport == TRANS_UDS) ; /* UDS cannot have a PHC. */ else if (!interface->ts_info.valid) pr_warning("port %d: get_ts_info not supported", number); else if (phc_index >= 0 && phc_index != interface->ts_info.phc_index) { - pr_err("port %d: PHC device mismatch", number); - pr_err("port %d: /dev/ptp%d requested, but /dev/ptp%d attached", - number, phc_index, interface->ts_info.phc_index); - goto err_port; + if (interface->boundary_clock_jbod) { + pr_warning("port %d: just a bunch of devices", number); + p->phc_index = interface->ts_info.phc_index; + } else { + pr_err("port %d: PHC device mismatch", number); + pr_err("port %d: /dev/ptp%d requested, ptp%d attached", + number, phc_index, interface->ts_info.phc_index); + goto err_port; + } } p->pod = interface->pod;