Re: [PATCH net-next v5 2/3] ethtool: add a PHY receive byte total

From: James Hilliard

Date: Mon Nov 16 2026 - 16:09:53 EST


On Mon, Nov 16, 2026 at 6:14 AM Andrew Lunn <andrew@xxxxxxx> 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.

FCS validation is part of the MAC functionality defined by 802.3.
Counting received bytes at the PHY need not depend on that validation.
The PHY CRC counters I mentioned are additional hardware diagnostics,
not functionality that every PHY must implement.

The original statistics interface also distinguishes the IEEE-defined
eth-phy statistics from the additional phydev counters [0]. For
rx_bytes, the common meaning can be received-byte activity without
requiring the PHY to determine whether the MAC will accept the frame.

> 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.

That matches the ACx00 byte counter: it includes the Ethernet header,
padding and FCS, including bytes from frames with an invalid FCS. It
excludes the preamble and SFD.

The separate counter was prompted by the existing kernel-doc wording,
"Total successfully received bytes", rather than an IEEE requirement
or a need for successful-only byte accounting.

> 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.

For this use case, documenting those differences is sufficient. I
don't need identical byte boundaries across vendors, and whether a
counter includes the preamble does not change its diagnostic value.

> 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?

The use case is the board bring-up and networking diagnosis you
describe: exposing the counters already available in the PHY to help
locate where traffic is being lost. It is the same PHY/MAC comparison
described in the diagnostics work accompanying this interface [1].

For example, in our tests the PHY byte and CRC-error counters advanced
for traffic that the MAC discarded before DMA. That distinguishes
traffic reaching the PHY but being rejected downstream from traffic
not reaching the PHY at all.

A common interface is useful for inspecting that activity across
devices, but exact cross-device byte totals are not required. The
important point here is that received traffic remains visible even
when the MAC subsequently rejects it.

[0] https://lore.kernel.org/r/20240829174342.3255168-3-kuba@xxxxxxxxxx/
[1] https://lore.kernel.org/r/20241221081530.3003900-5-o.rempel@xxxxxxxxxxxxxx/

> 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?
>
> Andrew
>
>
>