The pmc call to ptp4l to get phc_index returns invalid value since in free_running mode, ptp4l sets phc_index to -1. Adding a socket call in phc2sys to get the phc_index.
Signed-off-by: Saravanan Arunachalam <sa...@nvidia.com> --- phc2sys.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/phc2sys.c b/phc2sys.c index 19e8012..6df9fef 100644 --- a/phc2sys.c +++ b/phc2sys.c @@ -299,6 +299,7 @@ static void clock_reinit(struct phc2sys_private *priv, struct clock *clock, { int err = -1, phc_index = -1, phc_switched = 0, timestamping; char iface[IFNAMSIZ], phc_device[19]; + struct sk_ts_info ts_info; enum port_state state; struct port *p; clockid_t clkid = CLOCK_INVALID; @@ -323,6 +324,10 @@ static void clock_reinit(struct phc2sys_private *priv, struct clock *clock, free(clock->device); clock->device = strdup(iface); } + if (phc_index < 0) { + sk_get_ts_info(iface, &ts_info); + phc_index = ts_info.phc_index; + } /* Check if phc index changed */ if (clock->phc_index != phc_index) { snprintf(phc_device, sizeof(phc_device), "/dev/ptp%d", @@ -838,6 +843,7 @@ static int phc2sys_recv_subscribed(void *context, struct ptp_message *msg, static int auto_init_ports(struct phc2sys_private *priv, int add_rt) { int err, number_ports, phc_index, timestamping; + struct sk_ts_info ts_info; enum port_state state; char iface[IFNAMSIZ]; struct clock *clock; @@ -887,6 +893,10 @@ static int auto_init_ports(struct phc2sys_private *priv, int add_rt) /* ignore ports with software time stamping */ continue; } + if (phc_index < 0) { + sk_get_ts_info(iface, &ts_info); + phc_index = ts_info.phc_index; + } port = port_add(priv, i, iface, phc_index); if (!port) return -1; -- 2.20.1 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel