Skip to content

Commit 7c8089f

Browse files
committed
Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue
Tony Nguyen says: ==================== Intel Wired LAN Driver Updates 2021-12-14 This series contains updates to ice driver only. Karol corrects division that was causing incorrect calculations and adds a check to ensure stale timestamps are not being used. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 500f372 + 37e738b commit 7c8089f

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

drivers/net/ethernet/intel/ice/ice_ptp.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ static int ice_ptp_adjfine(struct ptp_clock_info *info, long scaled_ppm)
705705
scaled_ppm = -scaled_ppm;
706706
}
707707

708-
while ((u64)scaled_ppm > div_u64(U64_MAX, incval)) {
708+
while ((u64)scaled_ppm > div64_u64(U64_MAX, incval)) {
709709
/* handle overflow by scaling down the scaled_ppm and
710710
* the divisor, losing some precision
711711
*/
@@ -1540,19 +1540,16 @@ static void ice_ptp_tx_tstamp_work(struct kthread_work *work)
15401540
if (err)
15411541
continue;
15421542

1543-
/* Check if the timestamp is valid */
1544-
if (!(raw_tstamp & ICE_PTP_TS_VALID))
1543+
/* Check if the timestamp is invalid or stale */
1544+
if (!(raw_tstamp & ICE_PTP_TS_VALID) ||
1545+
raw_tstamp == tx->tstamps[idx].cached_tstamp)
15451546
continue;
15461547

1547-
/* clear the timestamp register, so that it won't show valid
1548-
* again when re-used.
1549-
*/
1550-
ice_clear_phy_tstamp(hw, tx->quad, phy_idx);
1551-
15521548
/* The timestamp is valid, so we'll go ahead and clear this
15531549
* index and then send the timestamp up to the stack.
15541550
*/
15551551
spin_lock(&tx->lock);
1552+
tx->tstamps[idx].cached_tstamp = raw_tstamp;
15561553
clear_bit(idx, tx->in_use);
15571554
skb = tx->tstamps[idx].skb;
15581555
tx->tstamps[idx].skb = NULL;

drivers/net/ethernet/intel/ice/ice_ptp.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,21 @@ struct ice_perout_channel {
5555
* struct ice_tx_tstamp - Tracking for a single Tx timestamp
5656
* @skb: pointer to the SKB for this timestamp request
5757
* @start: jiffies when the timestamp was first requested
58+
* @cached_tstamp: last read timestamp
5859
*
5960
* This structure tracks a single timestamp request. The SKB pointer is
6061
* provided when initiating a request. The start time is used to ensure that
6162
* we discard old requests that were not fulfilled within a 2 second time
6263
* window.
64+
* Timestamp values in the PHY are read only and do not get cleared except at
65+
* hardware reset or when a new timestamp value is captured. The cached_tstamp
66+
* field is used to detect the case where a new timestamp has not yet been
67+
* captured, ensuring that we avoid sending stale timestamp data to the stack.
6368
*/
6469
struct ice_tx_tstamp {
6570
struct sk_buff *skb;
6671
unsigned long start;
72+
u64 cached_tstamp;
6773
};
6874

6975
/**

0 commit comments

Comments
 (0)