aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/phy
diff options
context:
space:
mode:
authorRichard Cochran <richardcochran@gmail.com>2011-06-14 19:55:19 -0400
committerDavid S. Miller <davem@conan.davemloft.net>2011-06-16 23:48:12 -0400
commit2331038a96ecdad76c50ab223fd48d656d8a1184 (patch)
tree43f58b2082b28e5ff56fbfb94fb6eee5db63fccf /drivers/net/phy
parentf1dc045e685ea5424b3445c1ccaa0a25b3d661ec (diff)
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. Signed-off-by: Richard Cochran <richard.cochran@omicron.at> Signed-off-by: David S. Miller <davem@conan.davemloft.net>
Diffstat (limited to 'drivers/net/phy')
-rw-r--r--drivers/net/phy/dp83640.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
index b0c9522bb535..ead323e56739 100644
--- a/drivers/net/phy/dp83640.c
+++ b/drivers/net/phy/dp83640.c
@@ -543,11 +543,20 @@ static void recalibrate(struct dp83640_clock *clock)
543 543
544/* time stamping methods */ 544/* time stamping methods */
545 545
546static void decode_evnt(struct dp83640_private *dp83640, 546static int decode_evnt(struct dp83640_private *dp83640,
547 struct phy_txts *phy_txts, u16 ests) 547 void *data, u16 ests)
548{ 548{
549 struct phy_txts *phy_txts;
549 struct ptp_clock_event event; 550 struct ptp_clock_event event;
550 int words = (ests >> EVNT_TS_LEN_SHIFT) & EVNT_TS_LEN_MASK; 551 int words = (ests >> EVNT_TS_LEN_SHIFT) & EVNT_TS_LEN_MASK;
552 u16 ext_status = 0;
553
554 if (ests & MULT_EVNT) {
555 ext_status = *(u16 *) data;
556 data += sizeof(ext_status);
557 }
558
559 phy_txts = data;
551 560
552 switch (words) { /* fall through in every case */ 561 switch (words) { /* fall through in every case */
553 case 3: 562 case 3:
@@ -565,6 +574,9 @@ static void decode_evnt(struct dp83640_private *dp83640,
565 event.timestamp = phy2txts(&dp83640->edata); 574 event.timestamp = phy2txts(&dp83640->edata);
566 575
567 ptp_clock_event(dp83640->clock->ptp_clock, &event); 576 ptp_clock_event(dp83640->clock->ptp_clock, &event);
577
578 words = ext_status ? words + 2 : words + 1;
579 return words * sizeof(u16);
568} 580}
569 581
570static void decode_rxts(struct dp83640_private *dp83640, 582static void decode_rxts(struct dp83640_private *dp83640,
@@ -643,9 +655,7 @@ static void decode_status_frame(struct dp83640_private *dp83640,
643 655
644 } else if (PSF_EVNT == type && len >= sizeof(*phy_txts)) { 656 } else if (PSF_EVNT == type && len >= sizeof(*phy_txts)) {
645 657
646 phy_txts = (struct phy_txts *) ptr; 658 size = decode_evnt(dp83640, ptr, ests);
647 decode_evnt(dp83640, phy_txts, ests);
648 size = sizeof(*phy_txts);
649 659
650 } else { 660 } else {
651 size = 0; 661 size = 0;