PTP timestamping

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

PTP timestamping

跳至解决方案
3,131 次查看
LordStark3232
Contributor I

Hi,

I am trying hw timestamping using timestamping.c (basically sending - receiving ptp packets) on p3041. I added PTP_ENBL_TXTS_IOCTL and PTP_GET_TIME ioctls in the given code. I set clock source as mac clk. I saw counter is incrementing (PTP_GET_TIME ) at user space application. When I send UDP packets (sendpacket), wireshark capturing ptp packets but timestamps always zero. (port: 319)

And I want to ask about testptp.c. It is using clock_gettime() function. Is it getting counter value of 1588 module? And can I use it as hardware timestamp.

Do you have any idea?

Thank you

 

0 项奖励
1 解答
3,103 次查看
yipingwang
NXP TechSupport
NXP TechSupport

Please refer to Open Source Software Block Diagram as the following.

yipingwang_0-1615282242231.png

Timestamp Processing in Open Source

•A shared time stamp structure – struct skb_shared_hwtstamps.

       struct  skb_shared_hwtstamps {

                            ktime_t hwtstamp;

                            ktime_t syststamp; /* hwtstamp transformed to system time base */

       };

•Time stamps for received packets was stored in the skb. Get a pointer to the shared time stamp structure by calling skb_hwtstamps(). Then set the time stamps in the structure skb_shared_hwtstamps.

•For outgoing packets, skb_hwtstamp_tx() clones the original skb and adds the timestamp to structure skb_shared_hwtstamps. The cloned skb with the send timestamp attached is looped back to the socket's error queue.

•PTPd get the RX timestamp by calling recvmsg() and the TX timestamp by calling recvmsg(flags=MSG_ERRQUEUE).

 

在原帖中查看解决方案

0 项奖励
5 回复数
3,104 次查看
yipingwang
NXP TechSupport
NXP TechSupport

Please refer to Open Source Software Block Diagram as the following.

yipingwang_0-1615282242231.png

Timestamp Processing in Open Source

•A shared time stamp structure – struct skb_shared_hwtstamps.

       struct  skb_shared_hwtstamps {

                            ktime_t hwtstamp;

                            ktime_t syststamp; /* hwtstamp transformed to system time base */

       };

•Time stamps for received packets was stored in the skb. Get a pointer to the shared time stamp structure by calling skb_hwtstamps(). Then set the time stamps in the structure skb_shared_hwtstamps.

•For outgoing packets, skb_hwtstamp_tx() clones the original skb and adds the timestamp to structure skb_shared_hwtstamps. The cloned skb with the send timestamp attached is looped back to the socket's error queue.

•PTPd get the RX timestamp by calling recvmsg() and the TX timestamp by calling recvmsg(flags=MSG_ERRQUEUE).

 

0 项奖励
3,094 次查看
LordStark3232
Contributor I

Hi yipingwang,

When I send ptp packet (followup or sync) at User Space App, do I have to add timestamp inside of ptp packet or controller automatically add timestamp outgoing packets?.

I can succesfuly read my loop back timestamp with recvmsg(MSG_ERRQUEUE) from transmitter side but receiver side not getting timestamp when it receives ptp packet. 

0 项奖励
3,067 次查看
yipingwang
NXP TechSupport
NXP TechSupport

Please enable 1588 driver for PTPd stack

Device Drivers --->
  PTP clock support --->
     <*> Freescale DPAA as PTP clock

0 项奖励
3,063 次查看
LordStark3232
Contributor I

I have this configuration.

Device Drivers --->
  PTP clock support --->
     <*> Freescale dTSEC as PTP clock

When I transmit some PTP package for example Followup, I can read my transmit time stamp calling receive with MSG_ERRORQUE flag. But receiver is not getting these time stamps from received packet. Time stamp fields in received PTP packet is always zero which is not set. 

Do I have to add timestamp fields at software or should I expect dTSEC to add timestamps automatically (which is not adding ts right now).

Also in dpaa document, it is stated TCTRL[TTSE] causes return of time-stamp value from dTSEC. I guess it is not adding any time-stamp into PTP messages.

0 项奖励
3,044 次查看
yipingwang
NXP TechSupport
NXP TechSupport

Please refer to the attached patch for ptpd from NXP.

0 项奖励