TI中文支持网
TI专业的中文技术问题搜集分享网站

基于kernel4.19的双phydp83640时间戳同步问题

硬件环境:am3358+双phy83640,软件环境:pdk3.0

问题描述:在做双phy之间时间戳同步时,同步后仍存在520056的偏差,需要再次纠偏才能达到时间戳相同??具体描述如下:

phy1 和phy2 分别绑定网卡eth0、eth1,phy1的时间戳作为ptp的clock的时钟源,经分析kernel ,phy之间的时间戳同步主要是ifconfig eth* up

时的recalibrate(clock)函数中完成phy1 和phy2 之间的时间戳同步。测试情况如下:

情况1

问题出现在先执行ifconfig eth1 192.168.1.2; 再执行ifconfig eth0 192.168.111.51;phy1 和phy2 的时间戳同步后仍存在520056的偏差

[root@ZHU ]#ifconfig eth1 192.168.1.2;ifconfig eth0 192.168.111.51;
[ 49.161999] net eth1: initializing cpsw version 1.12 (0)
[ 49.167364] net eth0: initialized cpsw ale version 1.4
[ 49.172530] net eth0: ALE Table size 1024
[ 49.254980] drivers/net/phy/dp83640.c dp83640_config_init 1569 2
[ 49.264477] dp83640: master PTP_STS 0x0100
[ 49.268768] dp83640: master PTP_ESTS 0x00fd
[ 49.273576] dp83640: slave PTP_STS 0x0100
[ 49.277804] dp83640: slave PTP_ESTS 0x00fd[ 49.282612] dp83640: slave offset -1040080 nanoseconds
[ 49.289446] net eth1: phy found : id is : 0x20005ce1
[ 49.302024] IPv6: ADDRCONF(NETDEV_UP): eth1: link is not ready
[ 49.335430] net eth0: initializing cpsw version 1.12 (0)
[ 49.414981] drivers/net/phy/dp83640.c dp83640_config_init 1569 1
[ 49.424508] dp83640: master PTP_STS 0x0100
[ 49.428799] dp83640: master PTP_ESTS 0x00fd
[ 49.433606] dp83640: slave PTP_STS 0x0100
[ 49.437834] dp83640: slave PTP_ESTS 0x007d[ 49.442644] dp83640: slave offset -160691776 nanoseconds                        (修正值为负值)
[ 49.449673] net eth0: phy found : id is : 0x20005ce1
[ 49.460809] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 51.445711] cpsw 4a100000.ethernet eth0: Link is Up – 100Mbps/Full – flow control rx/tx
[ 51.453795] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

[root@ZHU ptptest]#./phc2sys -s /dev/ptp0 -C (自己修改函数,拥有时间戳同步函数功能类似recalibrate(clock),主要完成phy1和phy2时间戳同步)
command C …
[ 98.382021] dp83640: master PTP_STS 0x0100
[ 98.386298] dp83640: master PTP_ESTS 0x00bd
[ 98.390976] 58232 14678 48 0
[ 98.393964] dp83640: slave PTP_STS 0x0100
[ 98.398196] dp83640: slave PTP_ESTS 0x00bd[ 98.403000] 62464 14670 48 0
[ 98.405895] dp83640: slave offset 520056 nanoseconds  (此时,phy1和phy2的时间戳仍存在520056偏差)
[root@ZHU ptptest]#./phc2sys -s /dev/ptp0 -C                    (再次测试时间戳偏差变为0)
command C …
[ 104.404931] dp83640: master PTP_STS 0x0100
[ 104.409341] dp83640: master PTP_ESTS 0x00bd
[ 104.414018] 15160 15035 54 0
[ 104.417009] dp83640: slave PTP_STS 0x0100
[ 104.421232] dp83640: slave PTP_ESTS 0x00bd[ 104.426043] 15160 15035 54 0
[ 104.428935] dp83640: slave offset 0 nanoseconds    

情况2:

然而,先执行ifconfig eth0 192.168.111.51,再执行ifconfig eth1 192.168.1.2时phy1 和phy2 的时间戳同步后仍存在520056的偏差

[root@ZHU ]#ifconfig eth1 192.168.1.2;ifconfig eth0 192.168.111.51;
[ 30.394873] net eth1: initializing cpsw version 1.12 (0)
[ 30.400238] net eth0: initialized cpsw ale version 1.4
[ 30.405407] net eth0: ALE Table size 1024
[ 30.485060] drivers/net/phy/dp83640.c dp83640_config_init 1556 2
[ 30.494560] dp83640: master PTP_STS 0x0100
[ 30.498851] dp83640: master PTP_ESTS 0x00fd
[ 30.503659] dp83640: slave PTP_STS 0x0100
[ 30.507885] dp83640: slave PTP_ESTS 0x00fd[ 30.512629] dp83640: slave offset -1040040 nanoseconds
[ 30.521025] net eth1: phy found : id is : 0x20005ce1
[ 30.533566] IPv6: ADDRCONF(NETDEV_UP): eth1: link is not ready
[ 30.565511] net eth0: initializing cpsw version 1.12 (0)
[ 30.645063] drivers/net/phy/dp83640.c dp83640_config_init 1556 1
[ 30.654590] dp83640: master PTP_STS 0x0100
[ 30.658882] dp83640: master PTP_ESTS 0x00fd
[ 30.663689] dp83640: slave PTP_STS 0x0100
[ 30.667915] dp83640: slave PTP_ESTS 0x007d[ 30.672661] dp83640: slave offset -132674824 nanoseconds
[ 30.681250] net eth0: phy found : id is : 0x20005ce1
[ 30.692350] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 32.515803] cpsw 4a100000.ethernet eth1: Link is Up – 100Mbps/Full – flow control off
[ 32.523719] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
[ 32.675783] cpsw 4a100000.ethernet eth0: Link is Up – 100Mbps/Full – flow control rx/tx
[ 32.683847] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[root@ZHU ptptest]#./phc2sys -s /dev/ptp0 -C                    
command C …
[ 48.475865] drivers/net/phy/dp83640.c phy_hwstamp_vrify 470 1 1 9 590f a903
[ 48.483513] dp83640: master PTP_STS 0x0100
[ 48.487739] dp83640: master PTP_ESTS 0x00bd
[ 48.492417] 3024 10245 17 0
[ 48.495345] dp83640: slave PTP_STS 0x0100
[ 48.499567] dp83640: slave PTP_ESTS 0x00bd[ 48.504312] 3024 10245 17 0
[ 48.507117] dp83640: slave offset 0 nanoseconds (时间戳偏差为0)

经过反复测试 情况1中的问题(phy1和phy2存在时间戳的现象始终存在,而且时间戳偏差值大多数为520056,也可能为520016)

该问题可能是在 dp83640: slave offset -132674824 nanoseconds 的slave offset 的值为负值时,出现的该问题?有进一步测试,测试情况如下:

先给phy2增加一个时间戳,然后,在进行时间戳同步,发现仍不存在情况1中的现象

请问,情况1中的问题产生的原因是什么??可能的引起原因是什么??

Jian Zhou:

这个问题涉及到以太网PHY芯片,能否也同时到以太网PHY的论坛问下,看看能否多点debugging思路。

赞(0)
未经允许不得转载:TI中文支持网 » 基于kernel4.19的双phydp83640时间戳同步问题
分享到: 更多 (0)