* [PATCH] net: sun8i_emac: exclude the FCS from received packet lengths
@ 2026-11-09 8:06 James Hilliard
2026-11-21 21:58 ` Paul Kocialkowski
0 siblings, 1 reply; 2+ messages in thread
From: James Hilliard @ 2026-11-09 8:06 UTC (permalink / raw)
To: u-boot
Cc: Jerome Forissier, Tom Rini, Paul Kocialkowski, Andre Przywara,
James Hilliard
The RX descriptor length includes the four-byte Ethernet FCS. The driver
does not enable FCS stripping, so subtract it from the length returned
to the network stack after checking the complete frame length.
Otherwise the wol command treats the FCS as an optional four-byte
password when an Ethernet magic packet has no password. A four-byte
password is instead exported as six bytes containing part of the FCS.
IPv4 protocols generally hide this error by using their own lengths.
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/net/sun8i_emac.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c
index 41c52f56d7a..0199e2b5c30 100644
--- a/drivers/net/sun8i_emac.c
+++ b/drivers/net/sun8i_emac.c
@@ -518,7 +518,8 @@ static int sun8i_emac_eth_recv(struct udevice *dev, int flags, uchar **packetp)
*packetp = (uchar *)(ulong)desc_p->buf_addr;
- return length;
+ /* The descriptor length includes the FCS, not part of the payload. */
+ return length - ETH_FCS_LEN;
}
static int sun8i_emac_eth_send(struct udevice *dev, void *packet, int length)
---
base-commit: 1ed1749575f28b406c241218eb6a200574574a25
change-id: 20260928-submit-sun8i-emac-fcs-v1-5b0185c991c5
Best regards,
--
James Hilliard <james.hilliard1@gmail.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: sun8i_emac: exclude the FCS from received packet lengths
2026-11-09 8:06 [PATCH] net: sun8i_emac: exclude the FCS from received packet lengths James Hilliard
@ 2026-11-21 21:58 ` Paul Kocialkowski
0 siblings, 0 replies; 2+ messages in thread
From: Paul Kocialkowski @ 2026-11-21 21:58 UTC (permalink / raw)
To: James Hilliard; +Cc: u-boot, Jerome Forissier, Tom Rini, Andre Przywara
[-- Attachment #1: Type: text/plain, Size: 2543 bytes --]
Hi James,
On Mon 09 Nov 26, 01:06, James Hilliard wrote:
> The RX descriptor length includes the four-byte Ethernet FCS. The driver
> does not enable FCS stripping, so subtract it from the length returned
> to the network stack after checking the complete frame length.
Looks like a good catch!
So there is a STRIP_FCS bit (bit 28 of register EMAC_RX_CTL0) that is
usually set by the Allwinner BSP Linux driver. It would maybe be better
to define the bit and use it instead of receiving the useless FCS and
tweaking the size.
However the mainline Linux implementation seems to assume that auto FCS
stripping (called ACS) is disabled (and does not clear the bit).
I don't think the unit gets properly reset by Linux before use, so this
could have bad side effects. There is a soft reset but only done for
chips without an internal ephy.
Feel free to check if this approach would affect Linux or not if you
prefer it. Otherwise I'm fine with the current proposal, but I'll see
what others think about this.
Reviewed-by: Paul Kocialkowski <paulk@sys-base.io>
All the best,
Paul
> Otherwise the wol command treats the FCS as an optional four-byte
> password when an Ethernet magic packet has no password. A four-byte
> password is instead exported as six bytes containing part of the FCS.
> IPv4 protocols generally hide this error by using their own lengths.
>
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> ---
> drivers/net/sun8i_emac.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c
> index 41c52f56d7a..0199e2b5c30 100644
> --- a/drivers/net/sun8i_emac.c
> +++ b/drivers/net/sun8i_emac.c
> @@ -518,7 +518,8 @@ static int sun8i_emac_eth_recv(struct udevice *dev, int flags, uchar **packetp)
>
> *packetp = (uchar *)(ulong)desc_p->buf_addr;
>
> - return length;
> + /* The descriptor length includes the FCS, not part of the payload. */
> + return length - ETH_FCS_LEN;
> }
>
> static int sun8i_emac_eth_send(struct udevice *dev, void *packet, int length)
>
> ---
> base-commit: 1ed1749575f28b406c241218eb6a200574574a25
> change-id: 20260928-submit-sun8i-emac-fcs-v1-5b0185c991c5
>
> Best regards,
> --
> James Hilliard <james.hilliard1@gmail.com>
>
--
Paul Kocialkowski,
Free software developer - https://www.paulk.fr/
Independent contractor - sys-base - https://www.sys-base.io/
Contributor to fully free software support for selected hardware.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-21 22:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-09 8:06 [PATCH] net: sun8i_emac: exclude the FCS from received packet lengths James Hilliard
2026-11-21 21:58 ` Paul Kocialkowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox