Commit e089315b authored by Adam Wujek's avatar Adam Wujek 💬 Committed by Alessandro Rubini

wr_nic: fix rx timestamps in nic-core.c

commit inspited by commit from spec-sw repo:
kernel/wr_nic: fix rx timestamps
c246c3ceSigned-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 3e74902a
......@@ -381,27 +381,33 @@ static void __wrn_rx_descriptor(struct wrn_dev *wrn, int desc)
wrn_ppsg_read_time(wrn, &counter_ppsg, &utc);
if (counter_ppsg < ts_r)
utc--;
if (WR_IS_NODE)
if (counter_ppsg < ts_r)
utc--;
if (WR_IS_SWITCH)
if (counter_ppsg < REFCLK_FREQ/4 && ts_r > 3*REFCLK_FREQ/4)
utc--;
ts.tv_sec = (s32)utc & 0x7fffffff;
cntr_diff = (ts_r & 0xf) - ts_f;
/* the bit says the rising edge cnter is 1tick ahead */
if(cntr_diff == 1 || cntr_diff == (-0xf))
if (cntr_diff == 1 || cntr_diff == (-0xf))
ts.tv_sec |= 0x80000000;
ts.tv_nsec = ts_r * NSEC_PER_TICK;
pr_debug("Timestamp: %li:%li, ahead = %d\n",
ts.tv_sec & 0x7fffffff,
ts.tv_nsec & 0x7fffffff,
ts.tv_sec & 0x80000000 ? 1 :0);
ts.tv_sec & 0x80000000 ? 1 : 0);
if (1) {
if (WR_IS_NODE) {
/* SPEC: don't do the strange stuff for wr-ptp */
ts.tv_sec &= ~0x80000000;
ts.tv_nsec &= 0x7fffffff;
}
/* If the timestamp was reported as incorrect, pass 0 instead */
if (! (r1 & NIC_RX1_D1_TS_INCORRECT)) {
hwts = skb_hwtstamps(skb);
hwts->hwtstamp = timespec_to_ktime(ts);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment