Skip to content

Commit

Permalink
net: mscc: ocelot: fix hardware timestamp dequeue logic
Browse files Browse the repository at this point in the history
The next hw timestamp should be snapshoot to the read registers
only once the current timestamp has been read.
If none of the pending skbs matches the current HW timestamp
just gracefully flush the available timestamp by reading it.

Signed-off-by: laurent brando <laurent.brando@nxp.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
laurent5791 authored and davem330 committed Jul 27, 2020
1 parent 367fe04 commit 5fd8220
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions drivers/net/ethernet/mscc/ocelot.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,21 +748,21 @@ void ocelot_get_txtstamp(struct ocelot *ocelot)

spin_unlock_irqrestore(&port->tx_skbs.lock, flags);

/* Next ts */
ocelot_write(ocelot, SYS_PTP_NXT_PTP_NXT, SYS_PTP_NXT);
/* Get the h/w timestamp */
ocelot_get_hwtimestamp(ocelot, &ts);

if (unlikely(!skb_match))
continue;

/* Get the h/w timestamp */
ocelot_get_hwtimestamp(ocelot, &ts);

/* Set the timestamp into the skb */
memset(&shhwtstamps, 0, sizeof(shhwtstamps));
shhwtstamps.hwtstamp = ktime_set(ts.tv_sec, ts.tv_nsec);
skb_tstamp_tx(skb_match, &shhwtstamps);

dev_kfree_skb_any(skb_match);

/* Next ts */
ocelot_write(ocelot, SYS_PTP_NXT_PTP_NXT, SYS_PTP_NXT);
}
}
EXPORT_SYMBOL(ocelot_get_txtstamp);
Expand Down

0 comments on commit 5fd8220

Please sign in to comment.