Re: [PATCH net-next v5 2/3] ethtool: add a PHY receive byte total
From: James Hilliard
Date: Sun Nov 15 2026 - 23:12:53 EST
On Sun, Nov 15, 2026 at 8:25 AM Andrew Lunn <andrew@xxxxxxx> wrote:
>
> On Sun, Nov 15, 2026 at 12:45:46AM -0700, James Hilliard wrote:
>
> > The generic PHY receive-byte counter describes successfully received
> > traffic. Some PHYs instead count bytes in all received frames,
> > including frames with errors.
That restriction comes from the current kernel-doc definition of
ethtool_phy_stats.rx_bytes: "Total successfully received bytes".
It was the reason for introducing a separate inclusive byte counter.
I checked the PHY statistics callbacks in net-next and couldn't find
any driver populating rx_bytes. The original series [0] introduced
the byte fields, but its initial drivers only populated packet and
error counters.
>
> In the general case, that is wrong. A PHY basically does digital to
> analogue conversion. It takes a stream of bit from the MAC and
> converts them to analogue signals on the media. In the opposite
> direction, it recovers the analogue signals, converts it to digital,
> and passes it to the MAC.
>
> Thinks about SGMII. When running to 10Mbps, the MAC has to duplicate
> the bits 100 times. At 100Mbps, it duplicates the bits 10 times. The
> PHY then puts the bits onto the wire, it has no need to understand the
> duplication, the boundary between the MAC level bits, it is just a
> dumb DAC/ADC.
>
> In order to see frames, not a stream of bits, you need a MAC.
>
> Now, some PHYs do in fact have MACs. Those that implement PTP for
> example need to reassemble the bit stream into frames. Anything which
> does MACSEC. Or rate adaptation.
>
> But in the general case, its just a stream of bits. And the byte
> counters should be for the general case. And for SGMII, the definition
> is a bit more fuzzy, does it include the repetition or not?
Should we instead clarify the existing rx_bytes definition to include
errored traffic and use it for ACx00, dropping rx_bytes_total? That
would leave the existing packet counters unchanged.
For ACx00, the byte counter includes FCS and bytes from CRC-bad
frames. We also tested at 10 and 100 Mb/s over RMII: the byte counts
showed no tenfold inflation at 10 Mb/s despite its repeated interface
cycles.
[0] https://lore.kernel.org/r/20250110060517.711683-1-o.rempel@xxxxxxxxxxxxxx/
>
> If the PHY has a MAC, it can additionally fill in the frame counters.
>
> Andrew