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 <richardcochran@gmail.com>master
parent
a96797a7fc
commit
e706f48981
1
fault.c
1
fault.c
|
@ -21,6 +21,7 @@
|
||||||
static const char *fault_type_str[FT_CNT] = {
|
static const char *fault_type_str[FT_CNT] = {
|
||||||
"FT_UNSPECIFIED",
|
"FT_UNSPECIFIED",
|
||||||
"FT_BAD_PEER_NETWORK",
|
"FT_BAD_PEER_NETWORK",
|
||||||
|
"FT_SWITCH_PHC",
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *ft_str(enum fault_type ft)
|
const char *ft_str(enum fault_type ft)
|
||||||
|
|
1
fault.h
1
fault.h
|
@ -21,6 +21,7 @@
|
||||||
enum fault_type {
|
enum fault_type {
|
||||||
FT_UNSPECIFIED = 0,
|
FT_UNSPECIFIED = 0,
|
||||||
FT_BAD_PEER_NETWORK,
|
FT_BAD_PEER_NETWORK,
|
||||||
|
FT_SWITCH_PHC,
|
||||||
FT_CNT,
|
FT_CNT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
28
port.c
28
port.c
|
@ -29,6 +29,7 @@
|
||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
#include "missing.h"
|
#include "missing.h"
|
||||||
#include "msg.h"
|
#include "msg.h"
|
||||||
|
#include "phc.h"
|
||||||
#include "port.h"
|
#include "port.h"
|
||||||
#include "print.h"
|
#include "print.h"
|
||||||
#include "sk.h"
|
#include "sk.h"
|
||||||
|
@ -68,6 +69,8 @@ struct port {
|
||||||
enum timestamp_type timestamping;
|
enum timestamp_type timestamping;
|
||||||
struct fdarray fda;
|
struct fdarray fda;
|
||||||
int fault_fd;
|
int fault_fd;
|
||||||
|
int phc_index;
|
||||||
|
int jbod;
|
||||||
struct foreign_clock *best;
|
struct foreign_clock *best;
|
||||||
enum syfu_state syfu;
|
enum syfu_state syfu;
|
||||||
struct ptp_message *last_syncfup;
|
struct ptp_message *last_syncfup;
|
||||||
|
@ -2138,6 +2141,15 @@ int port_dispatch(struct port *p, enum fsm_event event, int mdiff)
|
||||||
|
|
||||||
p->state = next;
|
p->state = next;
|
||||||
port_notify_event(p, NOTIFY_PORT_STATE);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2483,15 +2495,23 @@ struct port *port_open(int phc_index,
|
||||||
|
|
||||||
memset(p, 0, sizeof(*p));
|
memset(p, 0, sizeof(*p));
|
||||||
|
|
||||||
|
p->phc_index = phc_index;
|
||||||
|
p->jbod = interface->boundary_clock_jbod;
|
||||||
|
|
||||||
if (interface->transport == TRANS_UDS)
|
if (interface->transport == TRANS_UDS)
|
||||||
; /* UDS cannot have a PHC. */
|
; /* UDS cannot have a PHC. */
|
||||||
else if (!interface->ts_info.valid)
|
else if (!interface->ts_info.valid)
|
||||||
pr_warning("port %d: get_ts_info not supported", number);
|
pr_warning("port %d: get_ts_info not supported", number);
|
||||||
else if (phc_index >= 0 && phc_index != interface->ts_info.phc_index) {
|
else if (phc_index >= 0 && phc_index != interface->ts_info.phc_index) {
|
||||||
pr_err("port %d: PHC device mismatch", number);
|
if (interface->boundary_clock_jbod) {
|
||||||
pr_err("port %d: /dev/ptp%d requested, but /dev/ptp%d attached",
|
pr_warning("port %d: just a bunch of devices", number);
|
||||||
number, phc_index, interface->ts_info.phc_index);
|
p->phc_index = interface->ts_info.phc_index;
|
||||||
goto err_port;
|
} 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;
|
p->pod = interface->pod;
|
||||||
|
|
Loading…
Reference in New Issue