All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: dp83640: Fix tx timestamp overflow handling.
@ 2016-01-20 10:22 Manfred Rudigier
  2016-01-20 13:25 ` Richard Cochran
  0 siblings, 1 reply; 3+ messages in thread
From: Manfred Rudigier @ 2016-01-20 10:22 UTC (permalink / raw)
  To: davem; +Cc: richardcochran, netdev, Manfred Rudigier

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>
---
 drivers/net/phy/dp83640.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
index 180f699..7a240fc 100644
--- a/drivers/net/phy/dp83640.c
+++ b/drivers/net/phy/dp83640.c
@@ -846,6 +846,11 @@ static void decode_rxts(struct dp83640_private *dp83640,
 	struct skb_shared_hwtstamps *shhwtstamps = NULL;
 	struct sk_buff *skb;
 	unsigned long flags;
+	u8 overflow;
+
+	overflow = (phy_rxts->ns_hi >> 14) & 0x3;
+	if (overflow)
+		pr_debug("rx timestamp queue overflow, count %d\n", overflow);
 
 	spin_lock_irqsave(&dp83640->rx_lock, flags);
 
@@ -888,6 +893,7 @@ static void decode_txts(struct dp83640_private *dp83640,
 	struct skb_shared_hwtstamps shhwtstamps;
 	struct sk_buff *skb;
 	u64 ns;
+	u8 overflow;
 
 	/* We must already have the skb that triggered this. */
 
@@ -897,6 +903,17 @@ static void decode_txts(struct dp83640_private *dp83640,
 		pr_debug("have timestamp but tx_queue empty\n");
 		return;
 	}
+
+	overflow = (phy_txts->ns_hi >> 14) & 0x3;
+	if (overflow) {
+		pr_debug("tx timestamp queue overflow, count %d\n", overflow);
+		while (skb) {
+			skb_complete_tx_timestamp(skb, NULL);
+			skb = skb_dequeue(&dp83640->tx_queue);
+		}
+		return;
+	}
+
 	ns = phy2txts(phy_txts);
 	memset(&shhwtstamps, 0, sizeof(shhwtstamps));
 	shhwtstamps.hwtstamp = ns_to_ktime(ns);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: dp83640: Fix tx timestamp overflow handling.
  2016-01-20 10:22 [PATCH] net: dp83640: Fix tx timestamp overflow handling Manfred Rudigier
@ 2016-01-20 13:25 ` Richard Cochran
  2016-01-21  2:54   ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Cochran @ 2016-01-20 13:25 UTC (permalink / raw)
  To: Manfred Rudigier; +Cc: davem, netdev

On Wed, Jan 20, 2016 at 11:22:28AM +0100, Manfred Rudigier wrote:
> 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.

Hi Manfred,

Thanks for finding and fixing this bug.

Dave, this patch should also go into stable.

Acked-by: Richard Cochran <richardcochran@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: dp83640: Fix tx timestamp overflow handling.
  2016-01-20 13:25 ` Richard Cochran
@ 2016-01-21  2:54   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2016-01-21  2:54 UTC (permalink / raw)
  To: richardcochran; +Cc: manfred.rudigier, netdev

From: Richard Cochran <richardcochran@gmail.com>
Date: Wed, 20 Jan 2016 14:25:45 +0100

> On Wed, Jan 20, 2016 at 11:22:28AM +0100, Manfred Rudigier wrote:
>> 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.
> 
> Hi Manfred,
> 
> Thanks for finding and fixing this bug.
> 
> Dave, this patch should also go into stable.
> 
> Acked-by: Richard Cochran <richardcochran@gmail.com>

Applied and queued up for -stable, thanks everyone.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-01-21  2:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-20 10:22 [PATCH] net: dp83640: Fix tx timestamp overflow handling Manfred Rudigier
2016-01-20 13:25 ` Richard Cochran
2016-01-21  2:54   ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.