This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Problem in getting CPTS Hardware Timestamp.

Can anybody please help me in getting Hardware Timestamp??

  The issue is with VAYU EVM XC5777X CPU Board (Jacinto 6) Booted through GLSDK 6.04 and using Linux version 3.11.

I am working with the implementation of the Hardware timestamping for the 802.1AS (Precision time protocol).
When I try to get Hardware timestamping for a packet which is sent from another vayu EVM J6 board, I don't get a timestamp value.
It says that the cmsg buffer is empty. It contains no data in it. The control length field of the control message received is equal t zero. I couldn't figure out the problem in my kernel.


My CPSW Driver is of 1.0 version. And Ubuntu 12.04 as my OS.

I have enabled some print statements in the below Kernel code(cpts.c) to debug my timestamp value.

Kernel Code:

static u64 cpts_find_ts(struct cpts *cpts, struct sk_buff *skb, int ev_type)
{
        static u64 ns = 0;
        struct cpts_event *event;
        struct list_head *this, *next;
        unsigned int class = sk_run_filter(skb, ptp_filter);

        unsigned long flags;
        u16 seqid;
        u8 mtype;

        if (class == PTP_CLASS_NONE)
        {
                return 0;
        }
        spin_lock_irqsave(&cpts->lock, flags);
        cpts_fifo_read(cpts, CPTS_EV_PUSH);
        list_for_each_safe(this, next, &cpts->events) {
               // printk("PTP Event class:%x,%d\n",class,cpts->events);
                event = list_entry(this, struct cpts_event, list);
                if (event_expired(event)) {
                        list_del_init(&event->list);
                        list_add(&event->list, &cpts->pool);
                        continue;
                }
                mtype = (event->high >> MESSAGE_TYPE_SHIFT) & MESSAGE_TYPE_MASK;
                seqid = (event->high >> SEQUENCE_ID_SHIFT) & SEQUENCE_ID_MASK;
                if (ev_type == event_type(event) &&
                    cpts_match(skb, class, seqid, mtype)) {
                        ns = timecounter_cyc2time(&cpts->tc, event->low);
                        printk("ns before: %ld\n",ns);
                        list_del_init(&event->list);
                        printk("ns middle: %ld\n",ns);
                        list_add(&event->list, &cpts->pool);
                        printk("ns after: %ld\n",ns);

                        break;
                }
        }
        spin_unlock_irqrestore(&cpts->lock, flags);
//printk("ns before return: %ld\n",ns);
        return ns;
}

void cpts_rx_timestamp(struct cpts *cpts, struct sk_buff *skb)
{
        u64 ns;
        struct skb_shared_hwtstamps *ssh;

        if (!cpts->rx_enable)
          {
                return;
          }
        ns = cpts_find_ts(cpts, skb, CPTS_EV_RX);

        if (!ns)
                return;
        ssh = skb_hwtstamps(skb);
        memset(ssh, 0, sizeof(*ssh));
        ssh->hwtstamp = ns_to_ktime(ns);

}

Note: The value of ns turns to be zero before the return statement, irrespective of it's values inside the spin lock.

  • Hi Jhon,

    I suggest you to verify the PTP packet content (whether the packet contain time stamp) before receiving it from the EVM J6 board. You can use a network sniffer program. I recommend you Wireshark application which can be executed on a PC under Linux or Window (there are releases for both OSs). The network interface of the PC with sniffer program must be connected on a network hub between both EVM J6 board or you also can use a switch supporting port monitor instead a hub.
    This test will determine where is the problem - missing time stamp - in the software of receiver board or in the sender.

    BR
    Tsvetolin Shulev
  • Hi Tsvetolin,

    Thank your for your kind reply!

    I would like to reframe my question in a more clear manner. I am actually trying to achieve timestamping for EVENT Packets (Eg: Sync, PDelay request) at the receiving end node. I am working to implement Precision Time Protocol to achieve Synchronization between 2 end nodes (Master & Slave).  As of my knowledge, usually, timestamp details are not packed along with any event packet's payload. So, it is not possible to find the problem using a sniffer program or Wireshark.

    Wireshark contains details of the packet, whichever is packed at the transmitting side. But I am finding difficulties in achieving timestamp at the receiving end node.

    I can get my Event Packets timestamped, when the packet is transmitted from PC and received in the EVM J6 side. But when a packet is packed by EVM J6 and sent from the same, that's where I face problem in getting HW Timestamp on another EVM J6.

    I could not figure this out using WIRESHARK tool.. I am working with KERNEL to fix this issue. Currently, I doubt on a particular function called "sock_recv_timestamp()" in the file "ti-glsdk_dra7xx-evm_6_04_00_02/board-support/linux/include/net/sock.h".  I guess, my Hardware timestamping is filtered out somewhere here. When I send packets from my PC, the condition(Hardware Timestamp FLAG check) is satisfied in this function. But, the same condition fails. I am struck over here.

    I'm a beginner. Please correct me if I am wrong.

    Please help me out to solve this issue.


    Thanks and Regards,

    Shylesh.

  • Hi Tsvetolin,

    I find that the packets that are packed by other hardwares like imx6 (Freescale processor) is Hardware timestamped by J6 EVM. But, any event packet packed by J6 is not Hardware Timestamped by other processors. I see that the packets from imx6 are Hardware timestamped by J6 EVM. Only the packets from J6 is not Hardware timestamped by other J6 or any other processor.

    Kindly help me to solve this.
    Thanks in advance.
  • Hi John,

    Check the linked below patch which adds support of the cpts device found in the gbe and 10gbe ethernet switches on the keystone platforms. PTP packet timetamping, Pulse per Second (PPS) and HW Timestamp are supported:
    git.ti.com/.../b4910f696208afef4d7ab1ca3b24d53cb929645d
    It is included in the ti-processor-sdk-linux-am57xx-evm-02.00.01.07 which can be downloaded from:
    software-dl.ti.com/.../index_FDS.html

    BR
    Tsvetolin Shulev
  • Hi Tsvetolin,

    The issue is actually solved. Moving from GLSDK 6.04 to GLSDK 7.03 solved the problem. The CPSW Driver had more changes that were to be implemented.
    Thanks for the reply!!

    Regards,
    Shylesh S.