From: Vincent Cheng <vincent.cheng...@renesas.com>

In the scenario where a port link goes down and up, current code checks
the port's phc_index against the interface's phc_index and if they are
different will set the port phc_index to the interface phc_index.

If the phc_index was initially set by the command line -p option, then we
end up using the wrong phc_index.

Fix is to skip updating the port phc_index with the interface phc_index
when port link is back up if it was initialy set from the command line.

Signed-off-by: Vincent Cheng <vincent.cheng...@renesas.com>
---
 port.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/port.c b/port.c
index db3e9ac..bdc73e4 100644
--- a/port.c
+++ b/port.c
@@ -2568,7 +2568,8 @@ void port_link_status(void *ctx, int linkup, int ts_index)
                                       "timestamping mode, set link status down 
by force.",
                                       interface_label(p->iface));
                                p->link_status = LINK_DOWN | LINK_STATE_CHANGED;
-                       } else if (p->phc_index != 
interface_phc_index(p->iface)) {
+                       } else if ((p->phc_index != 
interface_phc_index(p->iface)) &&
+                                  (!p->phc_from_cmdline)) {
                                p->phc_index = interface_phc_index(p->iface);
 
                                if (clock_switch_phc(p->clock, p->phc_index)) {
@@ -3064,6 +3065,7 @@ struct port *port_open(const char *phc_device,
                                   "not the attached ptp%d", number, phc_device,
                                   interface_phc_index(interface));
                        p->phc_index = phc_index;
+                       p->phc_from_cmdline = 1;
                } else {
                        pr_err("port %d: PHC device mismatch", number);
                        pr_err("port %d: /dev/ptp%d requested, ptp%d attached",
-- 
2.7.4



_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to