I'm using HW timestamps. The device works this way: it has
a) free running clock which can be programmed to give you desired
frequency by taking adjustments in freq and time
b) logic that determines if any of the PTP packet is received or transmitted
c) latch the timestamp and generate interrupt when event b) occurs
Here's some piece of code that handles the timestamping: It's little
more than just timestamping the packet since it also handles invoking
some APIs to manipulate sk_buff
if (status & MACB_PTP_TX_INT_FLAGS) {
if (!bp->txstamp_skb) {
netdev_err(bp->dev,"TX timestamp for NULL packet ?");
} else {
memset(&shhwtstamps, 0,sizeof(shhwtstamps));
shhwtstamps.hwtstamp = ns_to_ktime(nsec);
netdev_vdbg(bp->dev,"macb_ptp_tstamp_complete txstamp_skb =
0x%x ts = %llu\n",
(int)bp->txstamp_skb, shhwtstamps.hwtstamp.tv64);
/* Writing 0 to IER bit has no effect, if you want to
* really disable, write to IDR with bit 1
*/
skb_complete_tx_timestamp(bp->txstamp_skb, &shhwtstamps);
}
macb_writel(bp, IER, MACB_PTP_TX_INT_FLAGS);
} else if (status & MACB_PTP_RX_INT_FLAGS) {
if (bp->rxstamp_skb == NULL) {
netdev_err(bp->dev,"NULL descriptor stored for rx handler\n");
macb_writel(bp, IER, MACB_PTP_RX_INT_FLAGS);
return;
}
pshhwtstamps = skb_hwtstamps(bp->rxstamp_skb);
/* Note that pshhwtstamps doesn't point to the same variable now */
memset(pshhwtstamps, 0, sizeof(*pshhwtstamps));
pshhwtstamps->hwtstamp = ns_to_ktime(nsec);
netdev_vdbg(bp->dev,"macb_ptp_tstamp_complete rxstamp_skb = 0x%x
ts = %llu\n",
(int)bp->rxstamp_skb, pshhwtstamps->hwtstamp.tv64);
if(!nsec) netdev_err(bp->dev,"RX buffer has 0 ts!!");
netif_rx(bp->rxstamp_skb); <===================================
this is where I give the packet to net stack
macb_writel(bp, IER, MACB_PTP_RX_INT_FLAGS);
} else {
netdev_err(bp->dev,"ERR ! received interrupt for no reason\n");
}
Other than these, there are couple of functions to store the tx and rx
buffers which get diverted on the path different from normal UDP
Please let me know if you ant other information
-Makarand
Post by Richard CochranPost by Makarand KulkarniIt's the macb/gem device (drivers/net/ethernet). I added parts
over it to support timestamping as described in
ptp.txt in documentation section
So you added support for software transmit time stamps?
(This means adding a single line of code.)
Post by Makarand KulkarniWould this be the right mailer to put some diffs specific to a
particular device ? I joined couple of days back,
so not sure
For Linux network drivers, the netdev list is the right place, but we
can also discuss this here. I really suspect that you have a driver
issue related to your custom modifications.
Post by Makarand KulkarniWhen you say bad time stamps, what exactly would you
1) timestamps are continuously increasing
2) delta between consecutive ones are fairly constant
3) delta between time reported by sender and time received is
fairly stable
The first question is, are you using software time stamping?
Thanks,
Richard
--
Best Regards,
Makarand