By running two separate ptp4l instances (more so with the `-s` option that enable client only mode), you have that both interfaces can become clients at the same time. When this occurs, and the peripheral hardware clocks of both interface gets synchronized, which one should be used by phc2sys to synchronize the system clock?
What I want to achieve is to have one single instance of ptp4l running on multiple ports synchronizing one single hardware clock. I want to implement a boundary clock that synchronize to an upstream master on one port, and provides it's clock as a master on the others.
ptp4l can work with more than one interface. The LinuxPTP documentation says so and I've also achieved what I want to do with the SJA1110 switch. What I did was to enable the DSA driver for the SJA and to run `ptp4l -i p2 -i p3 -2 -m`. The DSA driver exposes the switch interfaces in linux, and they have the same hardware clock (ethtool also reports so, showing clock 4). Since the two ports have the same hardware clock, ptp4l can use both of them. In this configuration I see that ptp4l chooses one master over one of the two interfaces, and if that master fails, a new master is selected from the other. And the board itself can become the master if the BMCA algorithm chooses so. And with this I can also run `phc2sys -a -rr -m` to automatically synchronize the system clock to the hardware clock if the board is a slave, or the hardware clock to the system clock if it acts as the grandmaster.
Since I enabled the "External Timestamp Mode" for pfe1 and pfe2 (as described by my first post), pfe1 and pfe2 hardware clocks are derived by the hardware clock of pfe0. By running what you provided, that is two ptp4l instances in client only mode, when ptp4l needs to adjust the hardware clocks, it gives an error.
root@s32g399ardb3:~# ptp4l -i pfe2 -2 -m
ptp4l[72513.760]: selected /dev/ptp3 as PTP clock
ptp4l[72513.796]: port 1 (pfe2): INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[72513.796]: port 0 (/var/run/ptp4l): INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[72513.796]: port 0 (/var/run/ptp4lro): INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[72514.342]: port 1 (pfe2): new foreign master 00049f.fffe.096f15-1
ptp4l[72518.342]: selected best master clock 00049f.fffe.096f15
ptp4l[72518.343]: port 1 (pfe2): LISTENING to UNCALIBRATED on RS_SLAVE
ptp4l[72520.342]: master offset -1593121442 s0 freq +227123 path delay 788
ptp4l[72521.349]: failed to adjust the clock: Operation not supported
ptp4l[72522.342]: master offset -1593112737 s0 freq +231478 path delay -211
ptp4l[72523.349]: failed to adjust the clock: Operation not supported
And this does make sense becase if I tell the board that hardware clocks of pfe1 and pfe2 are derived from pfe0, then I cannot momdify them.
So my problem is. With the "External Timestamp Mode" enabled for pfe1 and pfe2, why in Linux the pfe1 and pfe2 peripherals are not related to hardware clock 1 but are instead related to their clocks (2 and 3 respectively). I mean, with the DSA driver for the SJA1110, different interfaces are related to the same hardware clock (in this case `/dev/ptp4`). Please refer to my first post for more details. So, is it a bug or do i need to configure something else? Maybe there is something else to modify in the device tree that I'm missing?
Would it also be possible to give some reference to documentation? Like, if ptp4l does not support multiple ports, where can I find this documented?
Btw, thanks a lot @alejandro_e for helping me.