From: Paul Kocialkowski <contact@paulk.fr>
To: James Hilliard <james.hilliard1@gmail.com>
Cc: u-boot@lists.u-boot-project.org,
Jerome Forissier <jerome.forissier@arm.com>,
Tom Rini <trini@konsulko.com>,
Andre Przywara <andre.przywara@arm.com>
Subject: Re: [PATCH] net: sun8i_emac: exclude the FCS from received packet lengths
Date: Sat, 21 Nov 2026 22:58:29 +0100 [thread overview]
Message-ID: <awIUBe7Y3znD9C8A@shepard> (raw)
In-Reply-To: <20261109-submit-sun8i-emac-fcs-v1-v1-1-fb0de3d8147c@gmail.com>
[-- 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 --]
prev parent reply other threads:[~2026-11-21 22:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=awIUBe7Y3znD9C8A@shepard \
--to=contact@paulk.fr \
--cc=andre.przywara@arm.com \
--cc=james.hilliard1@gmail.com \
--cc=jerome.forissier@arm.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox