Thread: [Linuxptp-users] bad message due to padding of FOLLOW_UP and DELAY_REQ
PTP IEEE 1588 stack for Linux
Brought to you by:
rcochran
|
From: Peter B. <pe...@be...> - 2022-01-12 15:14:45
|
Hi, I have a setup with TI processor using the cpsw driver from Linux mainline, kernel version 5.4. I'm using IEEE 802.3 network transport and sending PTP frames on Ethernet. When sending SYNC, FOLLOW_UP and DELAY_REQ that has a length of 58 bytes they get padded up to 64 bytes. When receiving FOLLOW_UP and DELAY_REQ in linuxptp they are dropped with message "bad message" because the stack treats the padding as a TLV entry (suffix_post_recv in msg.c returns 4) and the pdulen and messageLength mismatch. IEEE 802.3 minimum PDU size is 64 bytes. PTP messages SYNC, FOLLOW_UP and DELAY_REQ is smaller than that, 58 bytes. Are there any spec telling how to send PTP messages smaller than 64 bytes on Ethernet? On the other side in my setup I have a PC with e1000e driver. On that side when sending SYNC, FOLLOW_UP and DELAY_REQ over Ethernet the PDUs are padded to 60 bytes. Also tested a NXP processor (i.Mx8mp) and that one also padded to 60 bytes. A slightly different approach that is working with linuxptp. Is my issue with the TI processor a driver issue with the cpsw driver in Linux? Thanks, /Peter |
|
From: Miroslav L. <mli...@re...> - 2022-01-12 16:26:25
|
On Wed, Jan 12, 2022 at 03:57:55PM +0100, Peter Bergin wrote: > IEEE 802.3 minimum PDU size is 64 bytes. PTP messages SYNC, FOLLOW_UP and > DELAY_REQ is smaller than that, 58 bytes. Are there any spec telling how to > send PTP messages smaller than 64 bytes on Ethernet? FWIW, the minimum length of an Ethernet frame includes the 32-bit frame check sequence (FCS), i.e. the minimum payload length (assuming no VLAN tags, etc) is 46 octets. The minimum length of a PTP message is 44 octets, so at most 2 octets are needed to pad a PTP message to the required length. If more padding is needed, the PTP specification allows messages to be padded to (almost) any length with the PAD TLV, but I'm not sure if it is supposed to be the only way. -- Miroslav Lichvar |
|
From: Richard C. <ric...@gm...> - 2022-01-13 04:11:27
|
On Wed, Jan 12, 2022 at 03:57:55PM +0100, Peter Bergin wrote:
> I have a setup with TI processor using the cpsw driver from Linux mainline,
> kernel version 5.4. I'm using IEEE 802.3 network transport and sending PTP
> frames on Ethernet. When sending SYNC, FOLLOW_UP and DELAY_REQ that has a
> length of 58 bytes they get padded up to 64 bytes.
I tried layer2 with a Beagle Board Black (am335x), and I also saw the
SIX bytes of padding. Wireshark hates this, and shows a FCS error
(but actually I think it assumes the last 4 bytes are FCS, but in fact
the FCS has been stripped by the MAX)
As Miroslav pointed out, padding SIX bytes is wrong.
> On the other side in my setup I have a PC with e1000e driver. On that side
> when sending SYNC, FOLLOW_UP and DELAY_REQ over Ethernet the PDUs are padded
> to 60 bytes.
This is correct.
44 (PTP PDU) + 14 (L2 dst+src+type) + 4 (FCS) = 62 bytes
Two bytes padding are needed to make 64 bytes. Not SIX bytes.
The TI MAC (or driver?) is padding six bytes instead of two.
Somebody should tell TI about their bug.
Thanks,
Richard
|
|
From: Peter B. <pe...@be...> - 2022-01-13 08:45:05
|
On 2022-01-13 05:11, Richard Cochran wrote: > On Wed, Jan 12, 2022 at 03:57:55PM +0100, Peter Bergin wrote: > >> I have a setup with TI processor using the cpsw driver from Linux mainline, >> kernel version 5.4. I'm using IEEE 802.3 network transport and sending PTP >> frames on Ethernet. When sending SYNC, FOLLOW_UP and DELAY_REQ that has a >> length of 58 bytes they get padded up to 64 bytes. > I tried layer2 with a Beagle Board Black (am335x), and I also saw the > SIX bytes of padding. Wireshark hates this, and shows a FCS error > (but actually I think it assumes the last 4 bytes are FCS, but in fact > the FCS has been stripped by the MAX) > > As Miroslav pointed out, padding SIX bytes is wrong. > >> On the other side in my setup I have a PC with e1000e driver. On that side >> when sending SYNC, FOLLOW_UP and DELAY_REQ over Ethernet the PDUs are padded >> to 60 bytes. > This is correct. > > 44 (PTP PDU) + 14 (L2 dst+src+type) + 4 (FCS) = 62 bytes > > Two bytes padding are needed to make 64 bytes. Not SIX bytes. > > The TI MAC (or driver?) is padding six bytes instead of two. > > Somebody should tell TI about their bug. > Thanks for the confirmation Richard! I did some more research around this and it turned out is was already fixed in v5.14 upstream. For reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=acc68b8d2a1196c4db806947606f162dbeed2274 Backporting relevant stuff of this patch to my 5.4 kernel solved the padding problem. /Peter |
|
From: Richard C. <ric...@gm...> - 2022-01-13 15:27:48
|
On Thu, Jan 13, 2022 at 09:44:50AM +0100, Peter Bergin wrote: > Backporting relevant stuff of this patch to my 5.4 kernel solved the padding > problem. Cool. Glad it was a driver issue and not a bug in silicon! Cheers, Richard |