Skip to contentSkip to conversation

dp83640: bug fixes

PATCH Applied Richard Cochran 2 participants 4 messages Jun 15, 2011 – Jun 17, 2011

Subsystems (4)
lore
Share & tools
lore

Richard Cochran

author maintainer
#0 lore raw

cover dp83640: bug fixes

This series fixes two status frame related bugs in the driver for the dp83640 phy. I am not sure whether you would call this a timer fix or a networking fix, so I put both groups on CC.

Thanks,
Richard

Richard Cochran (2):
dp83640: fix phy status frame event parsing
dp83640: drop PHY status frames in the driver.

 drivers/net/phy/dp83640.c |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)
author maintainer
#1 lore raw

PATCH 1/2 dp83640: fix phy status frame event parsing

If two eternal time stamp events occur at nearly the same time, the phyter will add an extra word into the status frame. This commit fixes the parsing code to recognize and skip over the extra word.

---
 drivers/net/phy/dp83640.c |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)
drivers/net/phy/dp83640.c +15 -5
index b0c9522..ead323e 100644
@@ -543,11 +543,20 @@ static void recalibrate(struct dp83640_clock *clock)
 
 /* time stamping methods */
 
-static void decode_evnt(struct dp83640_private *dp83640,
-			struct phy_txts *phy_txts, u16 ests)
+static int decode_evnt(struct dp83640_private *dp83640,
+		       void *data, u16 ests)
 {
+	struct phy_txts *phy_txts;
 	struct ptp_clock_event event;
 	int words = (ests >> EVNT_TS_LEN_SHIFT) & EVNT_TS_LEN_MASK;
+	u16 ext_status = 0;
+
+	if (ests & MULT_EVNT) {
+		ext_status = *(u16 *) data;
+		data += sizeof(ext_status);
+	}
+
+	phy_txts = data;
 
 	switch (words) { /* fall through in every case */
 	case 3:
@@ -565,6 +574,9 @@ static void decode_evnt(struct dp83640_private *dp83640,
 	event.timestamp = phy2txts(&dp83640->edata);
 
 	ptp_clock_event(dp83640->clock->ptp_clock, &event);
+
+	words = ext_status ? words + 2 : words + 1;
+	return words * sizeof(u16);
 }
 
 static void decode_rxts(struct dp83640_private *dp83640,
@@ -643,9 +655,7 @@ static void decode_status_frame(struct dp83640_private *dp83640,
 
 		} else if (PSF_EVNT == type && len >= sizeof(*phy_txts)) {
 
-			phy_txts = (struct phy_txts *) ptr;
-			decode_evnt(dp83640, phy_txts, ests);
-			size = sizeof(*phy_txts);
+			size = decode_evnt(dp83640, ptr, ests);
 
 		} else {
 			size = 0;
Signature · 1 line
1.7.0.4
author maintainer
#2 lore raw

PATCH 2/2 dp83640: drop PHY status frames in the driver.

In reply to Richard Cochran

The dp83640 PHY provides time stamp and other information via special PHY status frames. Previously, the driver decoded the frames and then let the network stack drop them. This works fine when the PTP messages come over UDP.

However, when receiving PTP messages via L2 packets, this creates a problem. The status frames use the official PTP destination MAC address, and so they are delivered to user space along with the "real" frames, causing confusion for applications.

This commit fixes the issue by simply dropping the PHY status frames in the driver.

---
 drivers/net/phy/dp83640.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/phy/dp83640.c +2 -2
index ead323e..2cd8dc5 100644
@@ -1044,8 +1044,8 @@ static bool dp83640_rxtstamp(struct phy_device *phydev,
 
 	if (is_status_frame(skb, type)) {
 		decode_status_frame(dp83640, skb);
-		/* Let the stack drop this frame. */
-		return false;
+		kfree_skb(skb);
+		return true;
 	}
 
 	SKB_PTP_TYPE(skb) = type;
Signature · 1 line
1.7.0.4
maintainer Applied
#3 lore raw
In reply to Richard Cochran

From: Richard Cochran <[email protected]>
Date: Wed, 15 Jun 2011 11:55:18 +0200

Quoted 3 lines

This series fixes two status frame related bugs in the driver for the dp83640 phy. I am not sure whether you would call this a timer fix or a networking fix, so I put both groups on CC.

I've applied both to net-2.6, thanks.