Commit 2331038a authored by Richard Cochran's avatar Richard Cochran Committed by David S. Miller

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: default avatarRichard Cochran <richard.cochran@omicron.at>
Signed-off-by: default avatarDavid S. Miller <davem@conan.davemloft.net>
parent f1dc045e
...@@ -543,11 +543,20 @@ static void recalibrate(struct dp83640_clock *clock) ...@@ -543,11 +543,20 @@ static void recalibrate(struct dp83640_clock *clock)
/* time stamping methods */ /* time stamping methods */
static void decode_evnt(struct dp83640_private *dp83640, static int decode_evnt(struct dp83640_private *dp83640,
struct phy_txts *phy_txts, u16 ests) void *data, u16 ests)
{ {
struct phy_txts *phy_txts;
struct ptp_clock_event event; struct ptp_clock_event event;
int words = (ests >> EVNT_TS_LEN_SHIFT) & EVNT_TS_LEN_MASK; 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 */ switch (words) { /* fall through in every case */
case 3: case 3:
...@@ -565,6 +574,9 @@ static void decode_evnt(struct dp83640_private *dp83640, ...@@ -565,6 +574,9 @@ static void decode_evnt(struct dp83640_private *dp83640,
event.timestamp = phy2txts(&dp83640->edata); event.timestamp = phy2txts(&dp83640->edata);
ptp_clock_event(dp83640->clock->ptp_clock, &event); 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, static void decode_rxts(struct dp83640_private *dp83640,
...@@ -643,9 +655,7 @@ static void decode_status_frame(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)) { } else if (PSF_EVNT == type && len >= sizeof(*phy_txts)) {
phy_txts = (struct phy_txts *) ptr; size = decode_evnt(dp83640, ptr, ests);
decode_evnt(dp83640, phy_txts, ests);
size = sizeof(*phy_txts);
} else { } else {
size = 0; size = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment