PTP timestamping

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PTP timestamping

Jump to solution
3,076 Views
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 Kudos
1 Solution
3,048 Views
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).

 

View solution in original post

0 Kudos
5 Replies
3,049 Views
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 Kudos
3,039 Views
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 Kudos
3,012 Views
yipingwang
NXP TechSupport
NXP TechSupport

Please enable 1588 driver for PTPd stack

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

0 Kudos
3,008 Views
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 Kudos
2,989 Views
yipingwang
NXP TechSupport
NXP TechSupport

Please refer to the attached patch for ptpd from NXP.

0 Kudos