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

The command line "-p" option is used to assign the port's phc_index.
If the port link goes down and then up, the port reverts to using
the phc_index associated with the network interface instead of the
phc clock provided by the "-p" option.


Add debug code to port.c to illustrate scenario where we use -p option
to use /dev/ptp1 instead /dev/ptp0 from the ethernet interface.

diff --git a/port.c b/port.c
index db3e9ac..0f60e40 100644
--- a/port.c
+++ b/port.c
@@ -2578,6 +2578,8 @@ void port_link_status(void *ctx, int linkup, int ts_index)
                                }
                                clock_sync_interval(p->clock, 
p->log_sync_interval);
                        }
+                       pr_warning("debug: %s: Link up, using p->phc_index = 
%d",
+                                  __func__, p->phc_index);
                }
        }
 
@@ -3064,6 +3066,10 @@ 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;
+                       pr_warning("debug: %s: p->phc_index = %d",
+                                  __func__, p->phc_index);
+                       pr_warning("debug: %s: interface_phc_index(interface) = 
%d",
+                                  __func__, interface_phc_index(interface));
                } else {
                        pr_err("port %d: PHC device mismatch", number);
                        pr_err("port %d: /dev/ptp%d requested, ptp%d attached",


$ ./ptp4l -mqs -p /dev/ptp1 -f standalone_G.8275.1.cfg


Example log with debug code:

// Port is assigned phc_index 1 from /dev/ptp1 from command line
ptp4l[39284.467]: selected /dev/ptp1 as PTP clock
ptp4l[39284.469]: port 1: taking /dev/ptp1 from the command line, not the 
attached ptp0
ptp4l[39284.469]: debug: port_open: p->phc_index = 1
ptp4l[39284.469]: debug: port_open: interface_phc_index(interface) = 0

...

// port link goes down
ptp4l[39299.221]: port 1: link down
ptp4l[39299.221]: port 1: LISTENING to FAULTY on FAULT_DETECTED (FT_UNSPECIFIED)
ptp4l[39299.288]: selected local clock 000a35.fffe.00bf01 as best master

...

// port link back up - expected phc_index to be 1, but assigned 0 instead
ptp4l[39302.255]: port 1: link up
ptp4l[39302.255]: debug: port_link_status: Link up, using p->phc_index = 0



Example log with debug code after fix:

// Port is assigned phc_index 1 from /dev/ptp1 from command line

ptp4l[39868.627]: port 1: taking /dev/ptp1 from the command line, not the 
attached ptp0
ptp4l[39868.627]: debug: port_open: p->phc_index = 1
ptp4l[39868.627]: debug: port_open: interface_phc_index(interface) = 0

...

// port link goes down
ptp4l[39877.753]: port 1: link down
ptp4l[39877.753]: port 1: LISTENING to FAULTY on FAULT_DETECTED (FT_UNSPECIFIED)
ptp4l[39877.808]: selected local clock 000a35.fffe.00bf01 as best master

...

// port link back up - phc_index remains 1
ptp4l[39880.783]: port 1: link up
ptp4l[39880.783]: debug: port_link_status: Link up, using p->phc_index = 1


Vincent Cheng (2):
  port: Add phc_from_cmdline to indicate the phc index was from the
    command line.
  port: Fix link down/up to continue using phc_index set from command
    line -p option.

 port.c         | 4 +++-
 port_private.h | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

-- 
2.7.4



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

Reply via email to