Commit 2331038a96ecdad76c50ab223fd48d656d8a1184
Committed by
David S. Miller
1 parent
f1dc045e68
Exists in
master
and in
39 other branches
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>
Showing 1 changed file with 15 additions and 5 deletions Side-by-side Diff
drivers/net/phy/dp83640.c
... | ... | @@ -543,12 +543,21 @@ |
543 | 543 | |
544 | 544 | /* time stamping methods */ |
545 | 545 | |
546 | -static void decode_evnt(struct dp83640_private *dp83640, | |
547 | - struct phy_txts *phy_txts, u16 ests) | |
546 | +static int decode_evnt(struct dp83640_private *dp83640, | |
547 | + void *data, u16 ests) | |
548 | 548 | { |
549 | + struct phy_txts *phy_txts; | |
549 | 550 | struct ptp_clock_event event; |
550 | 551 | int words = (ests >> EVNT_TS_LEN_SHIFT) & EVNT_TS_LEN_MASK; |
552 | + u16 ext_status = 0; | |
551 | 553 | |
554 | + if (ests & MULT_EVNT) { | |
555 | + ext_status = *(u16 *) data; | |
556 | + data += sizeof(ext_status); | |
557 | + } | |
558 | + | |
559 | + phy_txts = data; | |
560 | + | |
552 | 561 | switch (words) { /* fall through in every case */ |
553 | 562 | case 3: |
554 | 563 | dp83640->edata.sec_hi = phy_txts->sec_hi; |
... | ... | @@ -565,6 +574,9 @@ |
565 | 574 | event.timestamp = phy2txts(&dp83640->edata); |
566 | 575 | |
567 | 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 | |
570 | 582 | static void decode_rxts(struct dp83640_private *dp83640, |
... | ... | @@ -643,9 +655,7 @@ |
643 | 655 | |
644 | 656 | } else if (PSF_EVNT == type && len >= sizeof(*phy_txts)) { |
645 | 657 | |
646 | - phy_txts = (struct phy_txts *) ptr; | |
647 | - decode_evnt(dp83640, phy_txts, ests); | |
648 | - size = sizeof(*phy_txts); | |
658 | + size = decode_evnt(dp83640, ptr, ests); | |
649 | 659 | |
650 | 660 | } else { |
651 | 661 | size = 0; |