On Wed, Nov 05, 2014 at 03:02:14PM +0100, Miroslav Lichvar wrote:
> The PHC device would need to be reopened when a new port becomes
> slave.
I assumed the code did this. Oh well. That needs to be fixed.
> There is also the problem that the master port will be sending sync
> messages before it's actually synchronized to the slave port by
> phc2sys. Maybe a new management message could be introduced to mark
> the port as synchronized from phc2sys and allow ptp4l to switch it to
> the master state.
Really once a port goes SLAVE, then all the other ports should be
synched, regardless of state. I had coded this up, but I didn't get so
far as to posting a patch (below).
Thanks,
Richard
---
diff --git a/phc2sys.c b/phc2sys.c
index 47ee3b8..cf47990 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -310,14 +310,23 @@ static void reconfigure(struct node *node)
c->state = c->new_state;
- if (c->state == PS_SLAVE) {
- src = c;
- src_cnt++;
- } else if (c->state == PS_UNCALIBRATED) {
- src_cnt++;
- } else if (c->state == PS_MASTER) {
+ switch (c->state) {
+ case PS_FAULTY:
+ case PS_DISABLED:
+ case PS_LISTENING:
+ case PS_PRE_MASTER:
+ case PS_MASTER:
+ case PS_PASSIVE:
pr_info("selecting %s for synchronization", c->device);
dst_cnt++;
+ break;
+ case PS_UNCALIBRATED:
+ src_cnt++;
+ break;
+ case PS_SLAVE:
+ src = c;
+ src_cnt++;
+ break;
}
}
if (src_cnt > 1) {
@@ -559,6 +568,23 @@ static int do_pps_loop(struct node *node, struct clock
*clock, int fd)
return 0;
}
+static int update_needed(struct clock *c)
+{
+ switch (c->state) {
+ case PS_FAULTY:
+ case PS_DISABLED:
+ case PS_LISTENING:
+ case PS_PRE_MASTER:
+ case PS_MASTER:
+ case PS_PASSIVE:
+ return 1;
+ case PS_UNCALIBRATED:
+ case PS_SLAVE:
+ break;
+ }
+ return 0;
+}
+
static int do_loop(struct node *node, int subscriptions)
{
struct timespec interval;
@@ -590,7 +616,7 @@ static int do_loop(struct node *node, int subscriptions)
continue;
LIST_FOREACH(clock, &node->clocks, list) {
- if (clock->state != PS_MASTER)
+ if (!update_needed(clock))
continue;
if (clock->clkid == CLOCK_REALTIME &&
------------------------------------------------------------------------------
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel