From: Oleksij Rempel <o.rempel@pengutronix.de>
To: Andrew Lunn <andrew@lunn.ch>
Cc: James Hilliard <james.hilliard1@gmail.com>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Randy Dunlap <rdunlap@infradead.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org
Subject: Re: [PATCH net-next v5 2/3] ethtool: add a PHY receive byte total
Date: Mon, 16 Nov 2026 19:11:58 +0100 [thread overview]
Message-ID: <avtHbulALsI61uVr@pengutronix.de> (raw)
In-Reply-To: <b84021aa-f843-4668-8172-0afcbb97c27f@lunn.ch>
On Mon, Nov 16, 2026 at 02:14:38PM +0100, Andrew Lunn wrote:
> > > Think about it.
> > >
> > > If you don't have a MAC, you don't have FCS.
> >
> > There are existing mainline PHY drivers exposing this functionality.
> > The QCA807x/QCA808x drivers use qcom_phy_counter_config() to enable
> > CRC checking, and qcom_phy_get_stats() reports the RX CRC-error count
> > through ethtool_phy_stats.rx_errors [0]. The IP101G driver also exposes
> > a phy_crc_errors counter separately from phy_symbol_errors [1].
> >
> > This demonstrates frame-aware diagnostic functionality within these
> > PHYs, rather than something every PHY necessarily implements.
> >
> > The generic byte counter need not require that functionality. My
> > question was whether rx_bytes should count received bytes without
> > conditioning the count on FCS validity. ACx00 could then report its
> > hardware byte total through that field, including bytes from frames
> > which its separate CRC checker identifies as bad.
>
> Read 802.3. What does an 802.3 defined PHY actually allow. That is
> ideally what the kernel should support with these counters. Lowest
> common denominator.
>
> So i would say RX bytes does not differentiate between the frames the
> MAC will later throw away because the FCS is wrong. I would say it is
> also O.K. to include the preamble, and the FCS, any padding up to 64
> byte frames, etc.
>
> Since this counter is not actually defined by 802.3, i would also
> allow some flexibility in its meaning. Different PHYs might have
> slightly different meanings.
>
> Look at it from the other direction. What is your use case? Does the
> exact definition actually matter? Does it matter if a different
> vendors PHY counts it differently? Does your use case require cross
> device compatibility?
>
> You have not actually said what your use case is. For new board
> bringup, debugging broken networking, the exact definition generally
> does not matter. The PHY RX counter is going up, the MAC is not,
> something between the MAC and the PHY. Neither the MAC nor the PHY
> counters are going up, something between the RJ45 and the PHY. The
> absolute values don't matter, its that they change which matters. But
> maybe your use case is different?
I agree that for bring-up the deltas are enough.
In the field the question is usually: is the board broken, or something
outside of it? The MAC counts FCS errors both when the line is noisy and
when the xMII corrupts frames. The PHY is the natural place to tell the
two apart, but only if we know whether its error counter checked the
FCS. Without that, the wrong part gets replaced.
I have seen a board where MAC and PHY both provided the xMII clock.
Frames were lost only when the clocks drifted into a bad phase, so
production tests did not catch it. A PHY that checks the FCS would show
a clean PHY side, while the MAC counts FCS errors from time to time.
So the meaning has to be known, even if it differs between PHYs. I am
fine with that, as long as rx_packets and rx_bytes describe the same
frames and the driver says what they include, for example which errored
frames are counted and whether rx_errors counts CRC or symbol errors.
That is the metadata I suggested in the v6 thread. The ACx00 byte total
also counts frames with a bad CRC, while its rx_packets does not, so it
does not fit rx_bytes.
Oleksij
next prev parent reply other threads:[~2026-11-16 18:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 7:45 [PATCH net-next v5 0/3] net: phy: report ACx00 receive statistics James Hilliard
2026-11-15 7:45 ` [PATCH net-next v5 1/3] docs: networking: correct the PHY statistics group name James Hilliard
2026-11-15 15:01 ` Andrew Lunn
2026-11-15 7:45 ` [PATCH net-next v5 2/3] ethtool: add a PHY receive byte total James Hilliard
2026-11-15 15:25 ` Andrew Lunn
2026-11-16 4:12 ` James Hilliard
2026-11-16 4:39 ` Andrew Lunn
2026-11-16 4:56 ` James Hilliard
2026-11-16 13:14 ` Andrew Lunn
2026-11-16 18:11 ` Oleksij Rempel [this message]
2026-11-16 8:06 ` netdev-bot+sashiko
2026-11-15 7:45 ` [PATCH net-next v5 3/3] net: phy: acx00: report receive statistics James Hilliard
2026-11-16 8:06 ` netdev-bot+sashiko
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=avtHbulALsI61uVr@pengutronix.de \
--to=o.rempel@pengutronix.de \
--cc=andrew@lunn.ch \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=james.hilliard1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rdunlap@infradead.org \
--cc=skhan@linuxfoundation.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