Skip to content

Commit 81e8f2e

Browse files
Manfred Rudigierdavem330
authored andcommitted
net: dp83640: Fix tx timestamp overflow handling.
PHY status frames are not reliable, the PHY may not be able to send them during heavy receive traffic. This overflow condition is signaled by the PHY in the next status frame, but the driver did not make use of it. Instead it always reported wrong tx timestamps to user space after an overflow happened because it assigned newly received tx timestamps to old packets in the queue. This commit fixes this issue by clearing the tx timestamp queue every time an overflow happens, so that no timestamps are delivered for overflow packets. This way time stamping will continue correctly after an overflow. Signed-off-by: Manfred Rudigier <manfred.rudigier@omicron.at> Acked-by: Richard Cochran <richardcochran@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7c13067 commit 81e8f2e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

drivers/net/phy/dp83640.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,11 @@ static void decode_rxts(struct dp83640_private *dp83640,
846846
struct skb_shared_hwtstamps *shhwtstamps = NULL;
847847
struct sk_buff *skb;
848848
unsigned long flags;
849+
u8 overflow;
850+
851+
overflow = (phy_rxts->ns_hi >> 14) & 0x3;
852+
if (overflow)
853+
pr_debug("rx timestamp queue overflow, count %d\n", overflow);
849854

850855
spin_lock_irqsave(&dp83640->rx_lock, flags);
851856

@@ -888,6 +893,7 @@ static void decode_txts(struct dp83640_private *dp83640,
888893
struct skb_shared_hwtstamps shhwtstamps;
889894
struct sk_buff *skb;
890895
u64 ns;
896+
u8 overflow;
891897

892898
/* We must already have the skb that triggered this. */
893899

@@ -897,6 +903,17 @@ static void decode_txts(struct dp83640_private *dp83640,
897903
pr_debug("have timestamp but tx_queue empty\n");
898904
return;
899905
}
906+
907+
overflow = (phy_txts->ns_hi >> 14) & 0x3;
908+
if (overflow) {
909+
pr_debug("tx timestamp queue overflow, count %d\n", overflow);
910+
while (skb) {
911+
skb_complete_tx_timestamp(skb, NULL);
912+
skb = skb_dequeue(&dp83640->tx_queue);
913+
}
914+
return;
915+
}
916+
900917
ns = phy2txts(phy_txts);
901918
memset(&shhwtstamps, 0, sizeof(shhwtstamps));
902919
shhwtstamps.hwtstamp = ns_to_ktime(ns);

0 commit comments

Comments
 (0)