Use case is –
ptp4l in free_running mode – PTP syncs the TOD
PHC disciplined by other means, say PPS
phc2sys source is PHC.

With autocfg option phc2sys tries to get the phc_index from ptp4l to determine 
the source. But since ptp4l is free running mode, 
pmc_agent_query_port_properties will not give the phc_index. Ptp4l doesn’t know 
about PHC since it is not disciplining it.

Regards
Saravanan


From: Erez <erezge...@gmail.com>
Date: Tuesday, July 25, 2023 at 12:40 AM
To: Arun Saravanan <sa...@nvidia.com>
Cc: linuxptp-devel@lists.sourceforge.net <linuxptp-devel@lists.sourceforge.net>
Subject: Re: [Linuxptp-devel] [PATCH] PHC Index is invalid in phc2sys when 
ptp4l is in free_running mode.
External email: Use caution opening links or attachments



On Sun, 23 Jul 2023 at 21:28, Saravanan Arunachalam via Linuxptp-devel 
<linuxptp-devel@lists.sourceforge.net<mailto:linuxptp-devel@lists.sourceforge.net>>
 wrote:
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.

Why is it a problem?
And why do you think phc2sys needs to fix it?


Signed-off-by: Saravanan Arunachalam <sa...@nvidia.com<mailto: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<mailto:Linuxptp-devel@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to