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.